Unix Programming - How to do this with make ?

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > April 2004 > How to do this with make ?





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 How to do this with make ?
Olivier Scalbert

2004-04-30, 8:34 am

Hello,

I need to convert a set of svg files located in the 'svg' directory in a
set of png files located in the 'png' directory.
Suppose the conversion tool is called 'conv', I need to do:
conv svg/image0001.svg png/image0001.png
conv svg/image0002.svg png/image0002.png
conv svg/image0003.svg png/image0003.png
....

How can I automate this with a makefile, in such way that if a svg is
changed then only the corresponding png is regenerated ?
I am using gnu make.

Thanks very much!

Olivier


Måns Rullgård

2004-04-30, 8:34 am

Olivier Scalbert <olivier.scalbert@algosyn.com> writes:

> Hello,
>
> I need to convert a set of svg files located in the 'svg' directory in
> a set of png files located in the 'png' directory.
> Suppose the conversion tool is called 'conv', I need to do:
> conv svg/image0001.svg png/image0001.png
> conv svg/image0002.svg png/image0002.png
> conv svg/image0003.svg png/image0003.png
> ...
>
> How can I automate this with a makefile, in such way that if a svg is
> changed then only the corresponding png is regenerated ?
> I am using gnu make.


%.png: %.svg
conv $^ $@

That's a tab on the second line.

--
Måns Rullgård
mru@kth.se
Ralf Fassel

2004-04-30, 9:34 am

* Måns Rullgård <mru@kth.se>
| %.png: %.svg

png/%.png: svg/%.svg

?

If I read the OP correctly, the .png and .svg files were meant to go
to different directories...

R'
Olivier Scalbert

2004-04-30, 9:34 am

Måns Rullgård wrote:

>Olivier Scalbert <olivier.scalbert@algosyn.com> writes:
>
>
>
>
>%.png: %.svg
> conv $^ $@
>
>That's a tab on the second line.
>
>
>

Thanks for the answer !
However make says: no targets ans stop ...

Måns Rullgård

2004-04-30, 9:34 am

Ralf Fassel <ralfixx@gmx.de> writes:

> * Måns Rullgård <mru@kth.se>
> | %.png: %.svg
>
> png/%.png: svg/%.svg
>
> ?
>
> If I read the OP correctly, the .png and .svg files were meant to go
> to different directories...


Sorry, my mistake. Your version should work, if I am not mistaken.



--
Måns Rullgård
mru@kth.se
Måns Rullgård

2004-04-30, 9:34 am

Olivier Scalbert <olivier.scalbert@algosyn.com> writes:

> Måns Rullgård wrote:
>
> Thanks for the answer !
> However make says: no targets ans stop ...


You'll need to add the png files as dependencies to some target. See
also another reply about the different directories for the svg and the
png files. To convert all svg files into png files you could do
something like this (untested):

PNGS = $(subst svg,png,$(wildcard svg/*.svg))

all: $(PNGS)

png/%.png: svg:%.svg
conv $^ $@

--
Måns Rullgård
mru@kth.se
Olivier Scalbert

2004-04-30, 9:34 am

Måns Rullgård wrote:

>Olivier Scalbert <olivier.scalbert@algosyn.com> writes:
>
>
>
>
>You'll need to add the png files as dependencies to some target. See
>also another reply about the different directories for the svg and the
>png files. To convert all svg files into png files you could do
>something like this (untested):
>
>PNGS = $(subst svg,png,$(wildcard svg/*.svg))
>
>all: $(PNGS)
>
>png/%.png: svg:%.svg
> conv $^ $@
>
>
>

Thanks very much, it works perfectly !
Do you know a good book or article on make ?
Thanks
Olivier
Måns Rullgård

2004-04-30, 9:34 am

Olivier Scalbert <olivier.scalbert@algosyn.com> writes:

> Thanks very much, it works perfectly !
> Do you know a good book or article on make ?


The texinfo manual that comes with gnu make is pretty good.

--
Måns Rullgård
mru@kth.se
Olivier Scalbert

2004-04-30, 9:34 am

Måns Rullgård wrote:

>Olivier Scalbert <olivier.scalbert@algosyn.com> writes:
>
>
>
>
>The texinfo manual that comes with gnu make is pretty good.
>
>
>

thx
Mohun Biswas

2004-04-30, 9:34 am

Måns Rullgård wrote:
> The texinfo manual that comes with gnu make is pretty good.


Same data, different format:
http://www.gnu.org/software/make/ma..._mono/make.html
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com