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

Re: how to use makefile to work with psnup



Michael Marsh wrote:
> On 12/14/05, H. S. <hs.samix@gmail.com> wrote:
> 
>>I am trying to make a makefile to convert PDFs in a directory to 4-up
>>PDFs using psnup but I am not able to.
> 
> 
> Off hand, I'd probably use something like:
> 
> #### BEGIN MAKEFILE ####
> SRCS := $(filter-out %-4up.pdf,$(wildcard *.pdf))
> DESTS := $(patsubst %.pdf,%-4up.pdf,$(SRCS))
> 
> default : $(DESTS)
> 
> %.ps : %.pdf
>         acroread -toPostScript $<
> 
> %-4up.ps  : %.ps
>         psnup -m0.5cm -l -Pletter -pletter -4 $< > $@
> 
> %-4up.pdf  : %-4up.ps
>         ps2pdf $<
> 
> #### END MAKEFILE ####
> 
> Remember to change the spaces to tabs for the action lines.  Gmail
> won't let me enter a tab by hand.  There's a circular dependency, but
> it doesn't seem to cause problems.  Since you have tighter naming
> rules, you can probably change
> 
> %.ps : %.pdf
> 
> to
> 
> %N.ps : %N.pdf
> 


That gave me a start. The circular dependency was a problem. Had to
change a few things to arrive at the following makefile which works
(tried "make -n" and all commands seem to work as expected):
############ start ############################################

SRCS:= $(filter-out %-4up.pdf,$(wildcard *.pdf))
DESTS:= $(patsubst %N.pdf,%N-4up.pdf,$(SRCS))

.SUFFIXES:
.SUFFIXES: .pdf .ps  N.ps N.pdf  N-4up.pdf N-4up.ps


default : $(DESTS)

P:
        echo $(DESTS)

%N.ps: %N.pdf
#       echo "First Step: making PS of $<"
        acroread -toPostScript $<

%N-4up.ps  : %N.ps
#       echo "Second Step: Makaing psnup of $<"
        psnup -m0.5cm -l -Pletter -pletter -4 $< > $@

%N-4up.pdf  : %N-4up.ps
#       echo "Third Step: making PDF of psnup"
        ps2pdf $<

############ end   ############################################

Defining the suffixes was important. And the restrictions on the output
filenames (*N.pdf and *N-4up.pdf) actually helped in resolving the
circular dependencies.

Thanks,
->HS






Reply to: