help-gnu-utils
[Top][All Lists]
Advanced

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

How to simplify this makefile?


From: Bob Stark
Subject: How to simplify this makefile?
Date: 4 May 2004 02:29:55 -0700

I use gnu make on a win32 platform to build multiple powerpoint files
into a single acrobat PDF file, using two command-line utilities I
wrote (printppt.exe and mergepdf.exe).

Lately I have wanted to build both color and monochrome versions of
the PDF files, one for printing, the other for online view. These
build from the same sources, but use different printppt command-line
parameters.

I have a makefile (included below) which works, but has more
hard-coded into it than I know it should. This is a simple class, but
some have 18 chapters. Look at the "I wish" section below to see the
targets that I want to make generic.

I have the following directory structure:
source/00cover.ppt
source/01overview.ppt
source/02WebView.ppt
source/Makefile
Materials/PT3443.pdf
Materials/PT3443Color.pdf

There are intermediate pdf files created; Since they are different,
but have the same filenames, I put the monochrome ones in the source
directory, and put the new color ones in the Materials directory.

Here is the Makefile:

# Makefile for building the student workbook
# Instructions:
# To build the monochrome version into a PDF file:
#   make book           (or just make)
# To build the color version into a PDF file:
#   make colorbook
# To delete temporary output files:
#   make clean

# Define macros for use in rules & targets, below...
PTNUM=PT3443
PDFFILE=..\Materials\${PTNUM}.pdf
PDFCOLOR=..\Materials\${PTNUM}Color.pdf
PRINTER=-PRINTER="Acrobat Distiller"

CHAPTER00=00cover.pdf
CHAPTER01=01overview.pdf
CHAPTER02=02WebView.pdf

CHAPTERS=${CHAPTER00} ${CHAPTER01} ${CHAPTER02}
CHAPTERSCOLOR=..\Materials\${CHAPTER00}         \
              ..\Materials\${CHAPTER01}         \
              ..\Materials\${CHAPTER02}         \

.SUFFIXES  :                    # Clean out default suffixes
.SUFFIXES  : .pdf .ppt          # Define suffixes that make acts on

book       : COLOR = NO
book       : ${PDFFILE}

colorbook  : COLOR = YES
colorbook  : ${PDFCOLOR}

# Rule to create intermediate PDF files from PPT slides
.ppt.pdf :
        printppt ${PRINTER} -COLOR=${COLOR} -WHAT=NOTES -FILES=${<}
# Note: ${<} is the name of current prereq file, e.g. the PPT file
# Note: address@hidden is the name of current target file, e.g. the PDF file

# These are leftover attempts from things that didn't work
#..\Materials\00cover.pdf : 00cover.ppt
#$(..\Materials\%.pdf) : %.ppt
#${CHAPTERSCOLOR} : 00cover.ppt 01overview.ppt 02WebView.ppt 

# I wish I could get wild cards to handle the following set of
# targets to be generic, like .ppt.pdf above
..\Materials\00cover.pdf : 00cover.ppt
        printppt ${PRINTER} -COLOR=${COLOR} -OUTDIR=..\Materials -WHAT=NOTES
-FILES=${<}

..\Materials\01overview.pdf : 01overview.ppt
        printppt ${PRINTER} -COLOR=${COLOR} -OUTDIR=..\Materials -WHAT=NOTES
-FILES=${<}

..\Materials\02WebView.pdf : 02WebView.ppt
        printppt ${PRINTER} -COLOR=${COLOR} -OUTDIR=..\Materials -WHAT=NOTES
-FILES=${<}

${PDFFILE} : ${CHAPTERS}
        -del ${PDFFILE}
        mergepdf -INFILES="0*.pdf" -OUTFILE="address@hidden"

${PDFCOLOR} : ${CHAPTERSCOLOR}
        -del ${PDFCOLOR}
        mergepdf -INFILES="..\Materials\0*.pdf" -OUTFILE="address@hidden"

clean      :
        echo Deleting intermediate PDF files...
        -del *.pdf
        -del ..\Materials\0*.pdf


reply via email to

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