help-make
[Top][All Lists]
Advanced

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

Re: conditional file parameters in make command?


From: Mike Shal
Subject: Re: conditional file parameters in make command?
Date: Thu, 26 Mar 2009 17:03:45 -0400

On 3/26/09, Erik <address@hidden> wrote:
> Mike Shal skrev:
>
> > On 3/26/09, Erik <address@hidden> wrote:
>  >>
>  >>  But which is the right way to build that into the Makefile?
>  >
>  > Maybe you would be better off doing this in the shell rather than in
>  > make?
>
>
> I think make can do it just fine (I do not want to have another script
>  file in the directory). I RTFM and wrote this, which seems to work:
>  pagecount = $(shell pdfinfo $(1)|egrep "^Pages: *[[:digit:]]+"|sed
>  "address@hidden: *\([[:digit:]]\+\)@\1@")
>  odd       = $(shell echo $(pagecount)%2|bc|grep 1)
>  filled    = $(1) $(if $(call odd,$(1)),emptypage.pdf)
>
> whole.pdf: 1.pdf 2.pdf 3.pdf 4.pdf 5.pdf 6.pdf 7.pdf 8.pdf 9.pdf
>
>     gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=$@ -dBATCH $(foreach
>  x,$^,$(call filled,$x)) || rm -f $@
>
>

Just to be clear, I wasn't suggesting creating a separate script file.
Instead of the single 'gs' command, there would be a for loop and the
gs command in the Makefile.

But if you already have it working with $(shell) and you're happy with
it, I see no reason to switch :)

-Mike




reply via email to

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