| prev | Draft Version 590 (Mon Dec 5 17:01:43 2005) | next |
.o extensionoverlap.o from overlap.c: just run cc overlap.ccc *.c is slow and inefficient if only one of your 117 source files has changedoverlap.c uses code in rectangle.coverlap.c, you'll be using out-of-date rectanglesTime: 1.2271 Concentration: 0.0050 Yield: 11.41 Time: 2.5094 Concentration: 0.0055 Yield: 11.20 Time: 3.7440 Concentration: 0.0060 Yield: 10.90
dat2csv.py that reformats data as a tablehello.mk:
hydroxyl_422.csv : hydroxyl_422.dat python dat2csv.py hydroxyl_422.dat > hydroxyl_422.csv
hydroxyl_422.csv is the target of the rulehydroxyl_422.dat is its prerequisite
make -f hello.mk
dat2csv.py)make -f hello.mk againhydroxyl_422.csv is newer than its prerequisite, so the action is not executedhydroxyl_422.csv : hydroxyl_422.dat python dat2csv.py hydroxyl_422.dat > hydroxyl_422.csv methyl_422.csv : methyl_422.dat python dat2csv.py methyl_422.dat > methyl_422.csv
make -f double.mk, only hydroxyl_422.csv is compiledmake -f double.mk methyl_422.csv to build methyl_422.csvall : hydroxyl_422.csv methyl_422.csv hydroxyl_422.csv : hydroxyl_422.dat python dat2csv.py hydroxyl_422.dat > hydroxyl_422.csv methyl_422.csv : methyl_422.dat python dat2csv.py methyl_422.dat > methyl_422.csv
make -f phony.mk all recreates both .csv files"all": recompile everything"clean": delete all temporary files, and everything produced by compilation"install": copy files to system directoriesmake, and then make installall : hydroxyl_422.csv methyl_422.csv hydroxyl_422.csv : hydroxyl_422.dat python dat2csv.py $< > $@ methyl_422.csv : methyl_422.dat python dat2csv.py $< > $@
"@" at the start of the action line prevents this"%" to represent the stem of the file's name in the target and prerequisitesall : hydroxyl_422.csv methyl_422.csv %.csv : %.dat python dat2csv.py $< > $@ clean : @rm -f *.csv
make -f rule.mk clean will get rid of all the generated files-f flag stands for “force”
rm not to report an error when trying to delete files that don't existhydroxyl_422.csv and hydroxyl_480.csv to create hydroxyl_all.csv, and similarly for the methyl files, using summarize.pyhydroxyl_all must be rewritten if it is older than either hydroxyl_422.csv or hydroxyl_480.csv
.dat filessummarize.py and dat2csv.py
all : hydroxyl_all.csv methyl_all.csv %_all.csv : %_422.csv %_480.csv summarize.py python summarize.py $^ > $@ %.csv : %.dat dat2csv.py python dat2csv.py $< > $@ clean : @rm -f *.csv
python dat2csv.py hydroxyl_422.dat > hydroxyl_422.csv python dat2csv.py hydroxyl_480.dat > hydroxyl_480.csv python summarize.py hydroxyl_422.csv hydroxyl_480.csv > hydroxyl_all.csv python dat2csv.py methyl_422.dat > methyl_422.csv python dat2csv.py methyl_480.dat > methyl_480.csv python summarize.py methyl_422.csv methyl_480.csv > methyl_all.csv rm hydroxyl_480.csv methyl_422.csv hydroxyl_422.csv methyl_480.csv
%_all.csv takes precedence over the rule %.csv
INPUT_DIR = /lab/gamma2100
all : hydroxyl_all.csv methyl_all.csv
%_all.csv : %_422.csv %_480.csv
python summarize.py $^ > $@
%.csv : ${INPUT_DIR}/%.dat
python dat2csv.py $< > $@
clean :
@rm -f *.csv
"$" in front of the name, and parentheses or braces around it"$XYZ" as the value of the variable "X", followed by the characters "YZ"name=value pairs on the command linemake -f macro.mk sets INPUT_DIR to /lab/gamma2100make INPUT_DIR=/oldcrankymachine -f macro.mk uses /oldcrankymachine${HOME} in a Makefile without having defined itVAL = original
echo :
@echo "VAL is" ${VAL}
$ make -f env.mk echo
VAL is original
$ make -f env.mk VAR=changed echo
VAL is changed
echo to print things as Make executesdel or rm to delete files?CruiseControl and Bitten will both handle the detailsExercise 14.1:
How can you stop Make from removing intermediate files automatically when it finishes processing?
Exercise 14.2:
Make gets definitions from environment variables, command-line parameters, and explicit definitions in Makefiles. What order does it check these in?
| prev | Copyright © 2005, Python Software Foundation. See License for details. | next |