Make Utiltiy Hints
From SnOwy - Ed's Wiki Notebook
keywords: makefile
Contents |
Case Sensitivity
- make is case sensitive despite the underlying file system and operating system.
Concurrent execution (parallel)
make -j3
Causes make to build three concurrent dependency graphs.
Uninformative Error Messages
makefile:4: *** missing separator. Stop.
Where "4" can be any line number in the makefile-- this means that the make utility was expecting tab characters but instead got spaces.
Automatic variables
$@ -- the first target $< -- the first prerequisite $+ -- all the prerequisites listed in precise order; duplications are retained
Andre's help
This allows a parameter substitution -- in this case, the binary is called "dssp", the targets are ".dssp" files, and the inputs are ".pdb" files.
Note: patsubst is a builtin function, so is wildcard; gnumake's built-in functions take the form "$(<function_name> <args <, ...>>)".
all: $(patsubst %.pdb, %.dssp, $(wildcard *.pdb)) %.dssp: %.pdb dssp $< $@ .PHONY: all #Thanks to Andre's Scary Magical Make Knowledge. # $< is the first prerequisite, in this case it's a %.pdb in *.pdb # $@ is the target, in this case it's a %.dssp in *.dssp
This one allows one to pass three parameters-- the first parameter indicates inputs, the second and third are targets.
all: $(patsubst dssp/%.dssp, fasta/%.fasta, $(wildcard dssp/*.dssp))\ $(patsubst dssp/%.dssp, fasta/%.fastasse, $(wildcard dssp/*.dssp)) fasta/%.fasta fastasse/%.fastasse: dssp/%.dssp python dssp2fasta.py dssp/$*.dssp fasta/$*.fasta fastasse/$*.fastasse .PHONY: all
This example corresponds to using ImageMagick's convert commandline utility ...
all_convert: $(patsubst %.png, %.eps, $(wildcard *.png)) %.eps: %.png convert $< $@
It should be a bit easier to understand than earlier examples (since there are fewer things happening).
- this makefile creates one eps for every png inside the current directory when run
Another imagemagick example -- this time including subdirectories ...
all_convert: $(patsubst colourimages/%.png, greyimages/%.png, $(wildcard colourimages/*.png)) greyimages/%.png: colourimages/%.png convert $< -colorspace Gray -alpha off $@
In this example, imagemagick is called to convert colour images to grey images
- notice that the file extension stays the same, but make utility respects the directory structure