From: W. Trevor King Date: Tue, 2 Sep 2008 13:21:46 +0000 (-0400) Subject: Made directory prerequisites order-only prerequisites. X-Git-Tag: v0.5~8 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=d72f47bb21b045b289c35d31cec45779baa8ae21;p=sawsim.git Made directory prerequisites order-only prerequisites. Avoids excessive rebuilding. See http://www.kolpackov.net/pipermail/notes/2004-January/000001.html http://www.gnu.org/software/make/manual/html_node/Prerequisite-Types.html http://savannah.gnu.org/support/?104349 for details --- diff --git a/src/sawsim.nw b/src/sawsim.nw index 7b9c1f2..c43a9b3 100644 --- a/src/sawsim.nw +++ b/src/sawsim.nw @@ -3125,13 +3125,20 @@ TENSION_MODEL_MODS = tension_model parse list tension_balance 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} @@ -3866,9 +3873,9 @@ check_k_model_MODS = parse string_eval 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 @@ -5064,15 +5071,15 @@ void get_options(int argc, char **argv, environment_t *env, The comment blocks in this [[noweb]] file are in \LaTeX\ with \BibTeX\ citations. The comment blocks are extracted (with nicely formatted code blocks), using <>= -$(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 <>= $(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" @@ -5151,7 +5158,7 @@ all : ./Makefile $(BINS:%=$(BIN_DIR)/%) $(DOCS:%=$(DOC_DIR)/%) ; 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 > $@ @@ -5168,11 +5175,11 @@ clean : $(CHECK_BINS:%=clean_%) $(SAWSIM_MODS:%=clean_%) \ $(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 @@ -5184,25 +5191,25 @@ $(BUILD_DIR) $(BIN_DIR) $(DOC_DIR) : # 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. @@ -5213,7 +5220,7 @@ $(BUILD_DIR)/check_sawsim.c : $(SRC_DIR)/sawsim.nw 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 @@ -5224,7 +5231,7 @@ $(CHECK_BINS:%=$(BIN_DIR)/%) : $$(subst $(BIN_DIR),$(BUILD_DIR),$$@).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%)