From: Daniel Karbach Date: Wed, 11 Mar 2015 12:39:16 +0000 (+0100) Subject: increased convenience in build process X-Git-Url: http://git.localhorst.tv/?a=commitdiff_plain;h=e5b1f5ef948724145ec2ed5777f4da1d6d862afd;p=blank.git increased convenience in build process * make "release" the default target * add "profile" build * add shorthand targets for launching, debugging, profiling --- diff --git a/.gitignore b/.gitignore index e8f25c7..d599a31 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,7 @@ *.swo blank blank.debug +blank.profile build +cachegrind.out.* +callgrind.out.* diff --git a/Makefile b/Makefile index e44a871..67b9bf1 100644 --- a/Makefile +++ b/Makefile @@ -14,43 +14,60 @@ LDXXFLAGS ?= LDXXFLAGS += $(PKGLIBS) DEBUG_FLAGS = -g3 -O0 +PROFILE_FLAGS = -DNDEBUG -O1 -g3 RELEASE_FLAGS = -DNDEBUG -O2 SOURCE_DIR := src DEBUG_DIR := build/debug +PROFILE_DIR := build/profile RELEASE_DIR := build/release -DIR := $(RELEASE_DIR) $(DEBUG_DIR) build +DIR := $(RELEASE_DIR) $(DEBUG_DIR) $(PROFILE_DIR) build SRC := $(wildcard $(SOURCE_DIR)/*.cpp) RELEASE_OBJ := $(patsubst $(SOURCE_DIR)/%.cpp, $(RELEASE_DIR)/%.o, $(SRC)) DEBUG_OBJ := $(patsubst $(SOURCE_DIR)/%.cpp, $(DEBUG_DIR)/%.o, $(SRC)) +PROFILE_OBJ := $(patsubst $(SOURCE_DIR)/%.cpp, $(PROFILE_DIR)/%.o, $(SRC)) RELEASE_DEP := $(RELEASE_OBJ:.o=.d) DEBUG_DEP := $(DEBUG_OBJ:.o=.d) +PROFILE_DEP := $(PROFILE_OBJ:.o=.d) RELEASE_BIN := blank DEBUG_BIN := blank.debug -OBJ := $(RELEASE_OBJ) $(DEBUG_OBJ) -DEP := $(RELEASE_DEP) $(DEBUG_DEP) -BIN := $(RELEASE_BIN) $(DEBUG_BIN) - -all: $(BIN) +PROFILE_BIN := blank.profile +OBJ := $(RELEASE_OBJ) $(DEBUG_OBJ) $(PROFILE_OBJ) +DEP := $(RELEASE_DEP) $(DEBUG_DEP) $(PROFILE_DEP) +BIN := $(RELEASE_BIN) $(DEBUG_BIN) $(PROFILE_BIN) release: $(RELEASE_BIN) +all: $(BIN) + debug: $(DEBUG_BIN) +profile: $(PROFILE_BIN) + run: blank ./blank gdb: blank.debug gdb ./blank.debug +cachegrind: blank.profile + valgrind ./blank.profile + +callgrind: blank.profile + valgrind --tool=callgrind \ + --branch-sim=yes --cacheuse=yes --cache-sim=yes \ + --collect-bus=yes --collect-systime=yes --collect-jumps=yes \ + --dump-instr=yes --simulate-hwpref=yes --simulate-wb=yes \ + ./blank.profile + clean: rm -df $(OBJ) $(DEP) $(DIR) distclean: clean - rm -f $(BIN) + rm -f $(BIN) cachegrind.out.* callgrind.out.* -.PHONY: all release debug run gdb clean distclean +.PHONY: all release debug profile run gdb cachegrind callgrind clean distclean -include $(DEP) @@ -62,6 +79,10 @@ $(DEBUG_BIN): $(DEBUG_OBJ) @echo link: $@ @$(LDXX) -o $@ $(CXXFLAGS) $(LDXXFLAGS) $(DEBUG_FLAGS) $^ +$(PROFILE_BIN): $(PROFILE_OBJ) + @echo link: $@ + @$(LDXX) -o $@ $(CXXFLAGS) $(LDXXFLAGS) $(PROFILE_FLAGS) $^ + $(RELEASE_DIR)/%.o: $(SOURCE_DIR)/%.cpp | $(RELEASE_DIR) @echo compile: $@ @$(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $(RELEASE_FLAGS) -o $@ -MMD -MP -MF"$(@:.o=.d)" -MT"$@" $< @@ -70,5 +91,9 @@ $(DEBUG_DIR)/%.o: $(SOURCE_DIR)/%.cpp | $(DEBUG_DIR) @echo compile: $@ @$(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $(DEBUG_FLAGS) -o $@ -MMD -MP -MF"$(@:.o=.d)" -MT"$@" $< +$(PROFILE_DIR)/%.o: $(SOURCE_DIR)/%.cpp | $(PROFILE_DIR) + @echo compile: $@ + @$(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $(PROFILE_FLAGS) -o $@ -MMD -MP -MF"$(@:.o=.d)" -MT"$@" $< + $(DIR): @mkdir -p "$@"