forked from martin-tornqvist/ia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
76 lines (61 loc) · 1.59 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#
# When calling this makefile, the "BUILD" variable can be set to either
# "release", or "debug", e.g.:
#
# > make BUILD=debug
#
# Running "make" alone will build in release mode
#
CXX?=g++
BUILD?=release
# Directiories
SRC_DIR=src
INC_DIR=include
TARGET_DIR=target
ASSETS_DIR=assets
# Includes
INC_DIR_debug=$(INC_DIR)/debug_mode_incl
INC_DIR_release=$(INC_DIR)/release_mode_incl
INCLUDES=-I $(INC_DIR) -I $(INC_DIR_$(BUILD))
#Flags
CXXFLAGS_release=-O2
CXXFLAGS_debug=-O0 -g
CXXFLAGS=-std=c++11 -Wall -Wextra -fno-rtti -fno-exceptions $(shell sdl2-config --cflags) $(CXXFLAGS_$(BUILD))
# For building 32-bit binaries on x86_64 platform
# CXXFLAGS+=-m32 -march=i686
#LDFLAGS=-L/usr/lib/i386-linux-gnu -lSDL -lSDL_image -lSDL_mixer
LDFLAGS=$(shell sdl2-config --libs) -lSDL2_image -lSDL2_mixer
# Output and sources
EXECUTABLE=ia
SOURCES=$(wildcard $(SRC_DIR)/*.cpp)
OBJECTS=$(SOURCES:.cpp=.o)
DEPENDS=$(SOURCES:.cpp=.d)
# Various bash commands
RM=rm -rf
MV=mv -f
MKDIR=mkdir -p
CP=cp -r
CAT=cat
# Make targets
all: $(EXECUTABLE)
$(EXECUTABLE): $(OBJECTS)
$(CXX) $^ -o $@ $(LDFLAGS)
$(RM) $(TARGET_DIR)
$(MKDIR) $(TARGET_DIR)
$(MV) $(EXECUTABLE) $(TARGET_DIR)
$(CP) $(ASSETS_DIR)/* $(TARGET_DIR)
%.o: %.cpp
$(CXX) -c $(CXXFLAGS) $(INCLUDES) $< -o $@
# Optional auto dependency tracking
-include depends.mk
depends: $(DEPENDS)
%.d:
$(CXX) -MM $(CXXFLAGS) $(INCLUDES) $(@:.d=.cpp) -MF depends.tmp -MT$(@:.d=.o)
$(CAT) depends.tmp >> depends.mk
$(RM) depends.tmp
clean-depends:
$(RM) depends.mk
# Remove object files
clean:
$(RM) $(TARGET_DIR) $(OBJECTS) $(EXECUTABLE)
.PHONY: all depends clean clean-depends