Unix Programming - Using make to convert files?

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > April 2007 > Using make to convert files?





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Using make to convert files?
desktop

2007-04-28, 1:18 pm

I have a folder "test" containing the folder "pic" where I put some .eps
files now and then. In the test folder I would like to put a makefile
that converts the .eps files to .pdf files (using epstopdf) IF new .eps
files are added or if they have changed.

Is it possible to use make for this??

The problem is that it should find out what the filenames are:

<newfile>.eps:
epstopdf <newfile>.eps


But I don't know how to make this, any ideas?
Roberto Waltman

2007-04-28, 1:18 pm

desktop wrote:
>...
>The problem is that it should find out what the filenames are:
>
><newfile>.eps:
> epstopdf <newfile>.eps
>
>
>But I don't know how to make this, any ideas?


See:

http://www.gnu.org/software/make/ma...matic-Variables


Roberto Waltman

[ Please reply to the group,
return address is invalid ]
Pascal Bourguignon

2007-04-28, 1:18 pm

desktop <fff@sss.com> writes:

> I have a folder "test" containing the folder "pic" where I put some
> .eps files now and then. In the test folder I would like to put a
> makefile that converts the .eps files to .pdf files (using epstopdf)
> IF new .eps files are added or if they have changed.
>
> Is it possible to use make for this??


Yes.

> The problem is that it should find out what the filenames are:
>
> <newfile>.eps:
> epstopdf <newfile>.eps
>
>
> But I don't know how to make this, any ideas?



[pjb@thalassa t]$ cat Makefile
..SUFFIXES: .pdf .eps
..eps.pdf: ; epstopdf $<
SRC=$(shell echo *.eps)
EPS=$(SRC:.eps=.pdf)
all:$(EPS)
[pjb@thalassa t]$ ls
../ ../ Makefile a.eps b.eps c.eps
[pjb@thalassa t]$ make -n
epstopdf a.eps
epstopdf b.eps
epstopdf c.eps
[pjb@thalassa t]$


--
__Pascal Bourguignon__ http://www.informatimago.com/

PLEASE NOTE: Some quantum physics theories suggest that when the
consumer is not directly observing this product, it may cease to
exist or will exist only in a vague and undetermined state.
Pascal Bourguignon

2007-04-28, 1:18 pm

Pascal Bourguignon <pjb@informatimago.com> writes:

> desktop <fff@sss.com> writes:
>
>
> Yes.
>
>
>
> [pjb@thalassa t]$ cat Makefile
> .SUFFIXES: .pdf .eps
> .eps.pdf: ; epstopdf $<
> SRC=$(shell echo *.eps)
> EPS=$(SRC:.eps=.pdf)
> all:$(EPS)
> [pjb@thalassa t]$ ls
> ./ ../ Makefile a.eps b.eps c.eps
> [pjb@thalassa t]$ make -n
> epstopdf a.eps
> epstopdf b.eps
> epstopdf c.eps
> [pjb@thalassa t]$


Of course, s/EPS/PDF/ :

..SUFFIXES: .pdf .eps
..eps.pdf: ; epstopdf $<
SRC=$(shell echo *.eps)
PDF=$(SRC:.eps=.pdf)
all:$(PDF)

--
__Pascal Bourguignon__ http://www.informatimago.com/
Small brave carnivores
Kill pine cones and mosquitoes
Fear vacuum cleaner
Gianni Mariani

2007-04-28, 7:19 pm

desktop wrote:
> I have a folder "test" containing the folder "pic" where I put some .eps
> files now and then. In the test folder I would like to put a makefile
> that converts the .eps files to .pdf files (using epstopdf) IF new .eps
> files are added or if they have changed.
>
> Is it possible to use make for this??
>
> The problem is that it should find out what the filenames are:
>
> <newfile>.eps:
> epstopdf <newfile>.eps
>
>
> But I don't know how to make this, any ideas?


In GNU make...

EPSFILES=$(wildcard *.eps)
PDFFILES=$(EPSFILES:%.eps=%.pdf)

all: $(PDFFILES)

%.pdf : %.eps
echo create $@ from $<
epstopdf $<
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com