Created
June 16, 2011 23:11
-
-
Save fbs/1030535 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| NAME := tetris | |
| CXX := g++ | |
| SIZE := size | |
| DEBUGGER := ddd | |
| DEBUGGERFLAGS := | |
| # Default target is debug | |
| ifeq ($(TARGET),) | |
| TARGET=debug | |
| endif | |
| # Warning flags | |
| WARNFLAGS := -W -Wall -pedantic-errors -Wextra \ | |
| -Wformat -Wformat-nonliteral -Wpointer-arith \ | |
| -Wcast-align -Wconversion | |
| # Flags for the debug build | |
| DEBUGFLAGS := -ggdb | |
| # Optimize flags | |
| OPTIFLAGS := -Os | |
| # Include | |
| INCLUDE := $(shell pkg-config pkg-config --cflags gtkmm-2.4) | |
| # Linker flags | |
| ELDFLAGS := $(shell pkg-config pkg-config --libs gtkmm-2.4) | |
| LDFLAGS := $(ELDFLAGS) | |
| # Flags depend on target | |
| ifeq ($(TARGET),debug) | |
| CXXFLAGS := $(DEBUGFLAGS) $(DEBUGFLAGS) $(WARNFLAGS) $(OPTIFLAGS) $(INCLUDE) | |
| else | |
| CXXFLAGS := $(WARNFLAGS) $(OPTIFLAGS) $(INCLUDE) | |
| endif | |
| # Source files | |
| SRCS := $(wildcard src/*.cpp) | |
| OBJS := $(SRCS:.cpp=.o) | |
| .PHONY: all clean inform initialize tar | |
| all: inform build size | |
| build: $(OBJS) | |
| @echo "Linking" | |
| @echo "Flags:" | |
| $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $(TARGET)/$(NAME) \ | |
| $(subst src/,$(TARGET)/,$(OBJS)) | |
| clean: | |
| rm -rf debug/* release/* | |
| inform: | |
| ifneq ($(TARGET),release) | |
| ifneq ($(TARGET),debug) | |
| @echo "Invalid configuration "$(TARGET)" specified." | |
| @echo "You must specify a configuration when running make, e.g." | |
| @echo "make TARGET=debug" | |
| @echo | |
| @echo "Possible choices for configuration are 'release' and 'debug'" | |
| @exit 1 | |
| endif | |
| endif | |
| @echo "Configuration is: "$(TARGET) | |
| @echo "----------------------------" | |
| initialize: | |
| @mkdir debug release src | |
| $(OBJS): %.o: %.cpp | |
| @echo "Compiling" | |
| $(CXX) -c $(CXXFLAGS) -o $(TARGET)/$(subst src/,,$@) $< | |
| debug: build | |
| $(DEBUGGER) $(DEBUGGERFLAG) $(TARGET)/$(NAME) | |
| size: build | |
| @echo | |
| $(SIZE) -t $(TARGET)/$(NAME) | |
| tar: $(SRCS) | |
| $(shell tar -cf source.tar src/*) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment