From 2192e9c74e1cf869ba8be0e7a85bc018248698d5 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Wed, 20 Oct 2010 15:49:02 -0400 Subject: [PATCH] Add CC, CFLAGS, and LDFLAGS to the Makefile for easy customization. --- src/sawsim.nw | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/sawsim.nw b/src/sawsim.nw index f926b1c..f70f986 100644 --- a/src/sawsim.nw +++ b/src/sawsim.nw @@ -3881,7 +3881,7 @@ TENSION_MODEL_SRC = $(BUILD_DIR)/tension_model_utils.c $(BUILD_DIR)/global.h \ $(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) - gcc -g -o $@ $< $(TENSION_MODEL_MODS:%=$(BUILD_DIR)/%.c) $(LIBS:%=-l%) + $(CC) $(CFLAGS) $(LDFLAGS) -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 @@ -5211,7 +5211,7 @@ K_MODEL_SRC = $(BUILD_DIR)/k_model_utils.c $(BUILD_DIR)/global.h \ $(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) - gcc -g -o $@ $< $(K_MODEL_MODS:%=$(BUILD_DIR)/%.c) $(LIBS:%=-l%) + $(CC) $(CFLAGS) $(LDFLAGS) -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 @ @@ -6567,6 +6567,11 @@ Extract the makefile with The sed is needed because notangle replaces tabs with eight spaces, but [[make]] needs tabs. <>= +# Customize compilation +CC = gcc +CFLAGS = +LDFLAGS = + # Decide what directories to put things in SRC_DIR = src BUILD_DIR = build @@ -6625,11 +6630,11 @@ clean : $(CHECK_BINS:%=clean_%) $(SAWSIM_MODS:%=clean_%) \ # Various builds of sawsim $(BIN_DIR)/sawsim : $(SAWSIM_SRC) | $(BIN_DIR) - gcc -g -o $@ $< $(SAWSIM_MODS:%=$(BUILD_DIR)/%.c) $(LIBS:%=-l%) + $(CC) $(CFLAGS) $(LDFLAGS) -g -o $@ $< $(SAWSIM_MODS:%=$(BUILD_DIR)/%.c) $(LIBS:%=-l%) $(BIN_DIR)/sawsim_static : $(SAWSIM_SRC) | $(BIN_DIR) - gcc -g -static -o $@ $< $(SAWSIM_MODS:%=$(BUILD_DIR)/%.c) $(LIBS:%=-l%) + $(CC) $(CFLAGS) $(LDFLAGS) -g -static -o $@ $< $(SAWSIM_MODS:%=$(BUILD_DIR)/%.c) $(LIBS:%=-l%) $(BIN_DIR)/sawsim_profile : $(SAWSIM_SRC) | $(BIN_DIR) - gcc -g -pg -o $@ $< $(SAWSIM_MODS:%=$(BUILD_DIR)/%.c) $(LIBS:%=-l%) + $(CC) $(CFLAGS) $(LDFLAGS) -g -pg -o $@ $< $(SAWSIM_MODS:%=$(BUILD_DIR)/%.c) $(LIBS:%=-l%) # Create the directories $(BUILD_DIR) $(BIN_DIR) $(DOC_DIR) : @@ -6670,7 +6675,7 @@ $(BUILD_DIR)/check_sawsim.c : $(SRC_DIR)/sawsim.nw $(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) - gcc -g -o $@ $< $(SAWSIM_MODS:%=$(BUILD_DIR)/%.c) $(CHECK_LIBS:%=-l%) + $(CC) $(CFLAGS) $(LDFLAGS) -g -o $@ $< $(SAWSIM_MODS:%=$(BUILD_DIR)/%.c) $(CHECK_LIBS:%=-l%) clean_check_sawsim : rm -f $(BIN_DIR)/check_sawsim $(BUILD_DIR)/check_sawsim.c # ... and the modules @@ -6681,7 +6686,7 @@ $(CHECK_BINS:%=$(BIN_DIR)/%) : $$(subst $(BIN_DIR),$(BUILD_DIR),$$@).c \ $$(patsubst %,$(BUILD_DIR)/%.c,$$($$(subst $(BIN_DIR)/,,$$@_MODS)))\ $$(patsubst %,$(BUILD_DIR)/%.h,$$($$(subst $(BIN_DIR)/,,$$@_MODS)))\ $$(BUILD_DIR)/global.h | $(BIN_DIR) - gcc -g -o $@ $< $(@:$(BIN_DIR)/check_%=$(BUILD_DIR)/%.c) \ + $(CC) $(CFLAGS) $(LDFLAGS) -g -o $@ $< $(@:$(BIN_DIR)/check_%=$(BUILD_DIR)/%.c) \ $(patsubst %,$(BUILD_DIR)/%.c,$($(subst $(BIN_DIR)/,,$@_MODS)))\ $(CHECK_LIBS:%=-l%) # TODO: clean up the required modules too -- 2.26.2