help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

make and (hard or sym)links


From: Madas Pál
Subject: make and (hard or sym)links
Date: Thu, 11 Jan 2007 19:44:15 +0100
User-agent: Thunderbird 1.5.0.5 (X11/20060809)

Hi.

I have a makefile that generates different size thumbnails from jpg images. It works fine but I have no idea how I could generate hard (or soft) linked targets when the sources are hard (or soft) linked.

The original pictures are stored as
jpg/dir20070111/1.jpg
jpg/dir20070111/2.jpg
etc

The thumbnails (generated by make) will be
jpeg/0225/dir20070111/1.0225.jpeg
jpeg/0225/dir20070111/2.0225.jpeg
etc

jpeg/0600/dir20070111/1.0600.jpeg
jpeg/0600/dir20070100/2.0600.jpeg
etc

There is no problem until there is only one (filesystem) link for each original picture. (Makefile is attached.)

But sometimes I want the same original file linked also in a second directory
jpg/anotherdir/1.jpg   <--- this is linked to jpg/dir20070111/1.jpg

and I want the target
jpeg/0225/anotherdir/1.0225.jpg <-- this _should be_ linked to jpeg/0225/anotherdir/1.0225.jpeg

Any suggestions to solve the problem?

Thank you in advance:

Madas Pál

PS (apologies) I am new at the list. I am not a make expert; in fact, it is the only one makefile I ever made... I tried to get help using google, but make and link are very common (and misleading) words (or at least I could mislead google...)
CD= cd
CV= convert
MD= @mkdir -p
MV= mv
RM= rm

djpg=  jpg
d0225= jpeg/0225
d0600= jpeg/0600
d0750= jpeg/0750
d0960= jpeg/0960
d1200= jpeg/1200

ldir=  $(wildcard $(djpg)/*)
l0225= $(patsubst $(djpg)/%, $(d0225)/%, $(ldir))
l0600= $(patsubst $(djpg)/%, $(d0600)/%, $(ldir))
l0750= $(patsubst $(djpg)/%, $(d0750)/%, $(ldir))
l0960= $(patsubst $(djpg)/%, $(d0960)/%, $(ldir))
l1200= $(patsubst $(djpg)/%, $(d1200)/%, $(ldir))

ljpg=  $(wildcard $(djpg)/*/*.jpg)

t0225= $(patsubst $(djpg)/%.jpg, $(d0225)/%.0225.jpeg, $(ljpg))
u0225= $(filter-out $(t0225), $(wildcard $(d0225)/*/*))

t0600= $(patsubst $(djpg)/%.jpg, $(d0600)/%.0600.jpeg, $(ljpg))
u0600= $(filter-out $(t0600), $(wildcard $(d0600)/*/*))

t0750= $(patsubst $(djpg)/%.jpg, $(d0750)/%.0750.jpeg, $(ljpg))
u0750= $(filter-out $(t0750), $(wildcard $(d0750)/*/*))

t0960= $(patsubst $(djpg)/%.jpg, $(d0960)/%.0960.jpeg, $(ljpg))
u0960= $(filter-out $(t0960), $(wildcard $(d0960)/*/*))

t1200= $(patsubst $(djpg)/%.jpg, $(d1200)/%.1200.jpeg, $(ljpg))
u1200= $(filter-out $(t1200), $(wildcard $(d1200)/*/*))

$(d0225)/%.0225.jpeg: $(djpg)/%.jpg
        $(CV) -geometry 0225x0225 $< $@
$(d0600)/%.0600.jpeg: $(djpg)/%.jpg
        $(CV) -geometry 0600x0600 $< $@
$(d0750)/%.0750.jpeg: $(djpg)/%.jpg
        $(CV) -geometry 0750x0750 $< $@
$(d0960)/%.0960.jpeg: $(djpg)/%.jpg
        $(CV) -geometry 0960x0960 $< $@
$(d1200)/%.1200.jpeg: $(djpg)/%.jpg
        $(CV) -geometry 1200x1200 $< $@

all:    mkd jpeg

jpeg:   $(t0225) $(t0600) $(t0750) $(t0960) $(t1200)

clean:  cjpeg

cjpeg:
        $(RM) $(u0225) $(u0600) $(u0750) $(u0960) $(u1200)

mkd:
        $(MD) $(l0225) $(l0600) $(l0750) $(l0960) $(l1200)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]