Created
October 15, 2012 13:43
-
-
Save schlady/3892520 to your computer and use it in GitHub Desktop.
Makefile with release and debug mode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CXXFLAGS=-Wall -Wextra -Werror -DLINUX | |
CXX_DEBUG_FLAGS=-g3 -DDEBUG_ALL | |
CXX_RELEASE_FLAGS=-O3 | |
.PHONY: debug | |
debug: CXXFLAGS+=$(CXX_DEBUG_FLAGS) | |
debug: HelloWorldD | |
.PHONY: release | |
release: CXXFLAGS+=$(CXX_RELEASE_FLAGS) | |
release: HelloWorld | |
DEBUG_OBJECTS = $(addprefix $(PROJECT_ROOT_DIR)/debug_obj/,$(SOURCES:.cpp=.o)) | |
RELEASE_OBJECTS = $(addprefix $(PROJECT_ROOT_DIR)/release_obj/,$(SOURCES:.cpp=.o)) | |
HelloWorldD: $(DEBUG_OBJECTS) | |
HelloWorld: $(RELEASE_OBJECTS) | |
# And let's add three lines just to ensure that the flags will be correct in case | |
# someone tries to make an object without going through "debug" or "release": | |
CXX_BASE_FLAGS=-Wall -Wextra -Werror -DLINUX | |
$(DEBUG_OBJECTS): CXXFLAGS=$(CXX_BASE_FLAGS) $(CXX_DEBUG_FLAGS) | |
$(RELEASE_OBJECTS): CXXFLAGS=$(CXX_BASE_FLAGS) $(CXX_RELEASE_FLAGS) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment