TENSION_MODEL_SRC = $(BUILD_DIR)/tension_model_utils.c $(BUILD_DIR)/global.h \
$(TENSION_MODEL_MODS:%=$(BUILD_DIR)/%.c) \
$(TENSION_MODEL_MODS:%=$(BUILD_DIR)/%.h)
-$(BUILD_DIR)/tension_model_utils.c : $(SRC_DIR)/sawsim.nw $(BUILD_DIR)
+$(BUILD_DIR)/tension_model_utils.c : $(SRC_DIR)/sawsim.nw | $(BUILD_DIR)
notangle -Rtension-model-utils.c $< > $@
-$(BIN_DIR)/tension_model_utils : $(TENSION_MODEL_SRC) $(BIN_DIR)
+$(BIN_DIR)/tension_model_utils : $(TENSION_MODEL_SRC) | $(BIN_DIR)
gcc -g -o $@ $< $(TENSION_MODEL_MODS:%=$(BUILD_DIR)/%.c) $(LIBS:%=-l%)
clean_tension_model_utils :
rm -f $(BUILD_DIR)/tension_model_utils.c $(BIN_DIR)/tension_model_utils
-@
+@ The pipe symbol [[|]] marks the prerequisits following it (in this
+case, the directories) as ‘order-only’ prerequisites. The timestamp
+on these prerequisits does not effect whether the rules are executed.
+This is appropriate for directories, where we don't need to recompile
+after an unrelated has been added to the directory, but only when the
+source prerequisites change. See the [[make]] documentation for more
+details
+(\url{http://www.gnu.org/software/make/manual/html_node/Prerequisite-Types.html}).
\subsection{Null}
\label{sec.null_tension}
K_MODEL_MODS = k_model parse string_eval
K_MODEL_SRC = $(BUILD_DIR)/k_model_utils.c $(BUILD_DIR)/global.h \
$(K_MODEL_MODS:%=$(BUILD_DIR)/%.c) $(K_MODEL_MODS:%=$(BUILD_DIR)/%.h)
-$(BUILD_DIR)/k_model_utils.c : $(SRC_DIR)/sawsim.nw $(BUILD)
+$(BUILD_DIR)/k_model_utils.c : $(SRC_DIR)/sawsim.nw | $(BUILD)
notangle -Rk-model-utils.c $< > $@
-$(BIN_DIR)/k_model_utils : $(K_MODEL_SRC) $(BIN_DIR)
+$(BIN_DIR)/k_model_utils : $(K_MODEL_SRC) | $(BIN_DIR)
gcc -g -o $@ $< $(K_MODEL_MODS:%=$(BUILD_DIR)/%.c) $(LIBS:%=-l%)
clean_k_model_utils :
rm -f $(BUILD_DIR)/k_model_utils.c $(BIN_DIR)/k_model_utils
The comment blocks in this [[noweb]] file are in \LaTeX\ with \BibTeX\ citations.
The comment blocks are extracted (with nicely formatted code blocks), using
<<latex makefile lines>>=
-$(BUILD_DIR)/sawsim.tex : $(SRC_DIR)/sawsim.nw $(BUILD_DIR)
+$(BUILD_DIR)/sawsim.tex : $(SRC_DIR)/sawsim.nw | $(BUILD_DIR)
noweave -latex -index -delay $< > $@
-$(BUILD_DIR)/sawsim.bib : $(SRC_DIR)/sawsim.bib $(BUILD_DIR)
+$(BUILD_DIR)/sawsim.bib : $(SRC_DIR)/sawsim.bib | $(BUILD_DIR)
cp -f $< $@
@
and compiled using
<<latex makefile lines>>=
$(DOC_DIR)/sawsim.pdf : $(BUILD_DIR)/sawsim.tex $(BUILD_DIR)/sawsim.bib \
- $(DOC_DIR)
+ | $(DOC_DIR)
$(SHELL) -e -c "cd $(BUILD_DIR) && pdflatex sawsim"
$(SHELL) -e -c "cd $(BUILD_DIR) && bibtex sawsim"
$(SHELL) -e -c "cd $(BUILD_DIR) && pdflatex sawsim"
view : $(DOC_DIR)/sawsim.pdf
xpdf $< &
-profile : $(BIN_DIR)/sawsim_profile $(BIN_DIR)
+profile : $(BIN_DIR)/sawsim_profile | $(BIN_DIR)
$(BIN_DIR)/sawsim_profile -v1e-6 -Mhooke -A.05 -U1 -kkramers_integ \
-mnull -Mwlc -A0.39e-9,28e-9 -F8
gprof $(BIN_DIR)/sawsim_profile gmon.out > $@
$(SHELL) -e -c "rmdir $(BUILD_DIR) $(BIN_DIR) $(DOC_DIR)"
# Various builds of sawsim
-$(BIN_DIR)/sawsim : $(SAWSIM_SRC) $(BIN_DIR)
+$(BIN_DIR)/sawsim : $(SAWSIM_SRC) | $(BIN_DIR)
gcc -g -o $@ $< $(SAWSIM_MODS:%=$(BUILD_DIR)/%.c) $(LIBS:%=-l%)
-$(BIN_DIR)/sawsim_static : $(SAWSIM_SRC) $(BIN_DIR)
+$(BIN_DIR)/sawsim_static : $(SAWSIM_SRC) | $(BIN_DIR)
gcc -g -static -o $@ $< $(SAWSIM_MODS:%=$(BUILD_DIR)/%.c) $(LIBS:%=-l%)
-$(BIN_DIR)/sawsim_profile : $(SAWSIM_SRC) $(BIN_DIR)
+$(BIN_DIR)/sawsim_profile : $(SAWSIM_SRC) | $(BIN_DIR)
gcc -g -pg -o $@ $< $(SAWSIM_MODS:%=$(BUILD_DIR)/%.c) $(LIBS:%=-l%)
# Create the directories
# and then $(BUILD_DIR) doesn't match in $$(subst $(BUILD_DIR), ...)
.SECONDEXPANSION:
$(FREE_SAWSIM_MODS:%=$(BUILD_DIR)/%.h) : $$(subst $(BUILD_DIR),$(SRC_DIR),$$@)\
- $(BUILD_DIR)
+ | $(BUILD_DIR)
cp -f $< $@
.SECONDEXPANSION:
$(FREE_SAWSIM_MODS:%=$(BUILD_DIR)/%.c) : $$(subst $(BUILD_DIR),$(SRC_DIR),$$@)\
- $(BUILD_DIR)
+ | $(BUILD_DIR)
cp -f $< $@
## Basic source generated with noweb
# The central files sawsim.c and global.h...
-$(BUILD_DIR)/sawsim.c : $(SRC_DIR)/sawsim.nw $(BUILD_DIR)
+$(BUILD_DIR)/sawsim.c : $(SRC_DIR)/sawsim.nw | $(BUILD_DIR)
notangle $< > $@
-$(BUILD_DIR)/global.h : $(SRC_DIR)/sawsim.nw $(BUILD_DIR)
+$(BUILD_DIR)/global.h : $(SRC_DIR)/sawsim.nw | $(BUILD_DIR)
notangle -Rglobal.h $< > $@
# ... and the modules
-$(NW_SAWSIM_MODS:%=$(BUILD_DIR)/%.h) : $(SRC_DIR)/sawsim.nw $(BUILD_DIR)
+$(NW_SAWSIM_MODS:%=$(BUILD_DIR)/%.h) : $(SRC_DIR)/sawsim.nw | $(BUILD_DIR)
notangle -R$(subst _,-,$(@:$(BUILD_DIR)/%=%)) $< > $@
-$(NW_SAWSIM_MODS:%=$(BUILD_DIR)/%.c) : $(SRC_DIR)/sawsim.nw $(BUILD_DIR)
+$(NW_SAWSIM_MODS:%=$(BUILD_DIR)/%.c) : $(SRC_DIR)/sawsim.nw | $(BUILD_DIR)
notangle -R$(subst _,-,$(@:$(BUILD_DIR)/%=%)) $< > $@
-$(CHECK_BINS:%=$(BUILD_DIR)/%.c) : $(SRC_DIR)/sawsim.nw $(BUILD_DIR)
+$(CHECK_BINS:%=$(BUILD_DIR)/%.c) : $(SRC_DIR)/sawsim.nw | $(BUILD_DIR)
notangle -R$(subst _,-,$(@:$(BUILD_DIR)/%=%)) $< > $@
# Note: I use `_' as a space in my file names, but noweb doesn't like
# that so we use `-' to name the noweb roots and substitute here.
notangle -Rchecks $< > $@
$(BIN_DIR)/check_sawsim : $(BUILD_DIR)/check_sawsim.c $(BUILD_DIR)/global.h \
$(SAWSIM_MODS:%=$(BUILD_DIR)/%.c) \
- $(SAWSIM_MODS:%=$(BUILD_DIR)/%.h) $(BIN_DIR)
+ $(SAWSIM_MODS:%=$(BUILD_DIR)/%.h) | $(BIN_DIR)
gcc -g -o $@ $< $(SAWSIM_MODS:%=$(BUILD_DIR)/%.c) $(CHECK_LIBS:%=-l%)
clean_check_sawsim :
rm -f $(BIN_DIR)/check_sawsim $(BUILD_DIR)/check_sawsim.c
$$(subst $(BIN_DIR)/check_,$(BUILD_DIR)/,$$@).h \
$$(patsubst %,$(BUILD_DIR)/%.c,$$($$(subst $(BIN_DIR)/,,$$@_MODS)))\
$$(patsubst %,$(BUILD_DIR)/%.h,$$($$(subst $(BIN_DIR)/,,$$@_MODS)))\
- $$(BUILD_DIR)/global.h $(BIN_DIR)
+ $$(BUILD_DIR)/global.h | $(BIN_DIR)
gcc -g -o $@ $< $(@:$(BIN_DIR)/check_%=$(BUILD_DIR)/%.c) \
$(patsubst %,$(BUILD_DIR)/%.c,$($(subst $(BIN_DIR)/,,$@_MODS)))\
$(CHECK_LIBS:%=-l%)