forked from CleverRaven/Cataclysm-DDA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
157 lines (127 loc) · 3.45 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# Platforms:
# Linux native
# (don't need to do anything)
# Linux 64-bit
# make NATIVE=linux64
# Linux 32-bit
# make NATIVE=linux32
# Linux cross-compile to Win32
# make CROSS=i686-pc-mingw32-
# Win32
# Run: make NATIVE=win32
# Build types:
# Debug (no optimizations)
# Default
# Release (turn on optimizations)
# make RELEASE=1
# comment these to toggle them as one sees fit.
# WARNINGS will spam hundreds of warnings, mostly safe, if turned on
# DEBUG is best turned on if you plan to debug in gdb -- please do!
# PROFILE is for use with gprof or a similar program -- don't bother generally
#WARNINGS = -Wall -Wextra -Wno-switch -Wno-sign-compare -Wno-missing-braces -Wno-unused-parameter -Wno-char-subscripts
# Uncomment below to disable warnings
WARNINGS = -w
DEBUG = -g
#PROFILE = -pg
#OTHERS = -O3
#DEFINES = -DNDEBUG
# Disable debug. Comment this out to get logging.
#DEFINES = -DENABLE_LOGGING
# Limit debug to level. Comment out all for all levels.
#DEFINES += -DDEBUG_INFO
#DEFINES += -DDEBUG_WARNING
#DEFINES += -DDEBUG_ERROR
#DEFINES += -DDEBUG_PEDANTIC_INFO
# Limit debug to section. Comment out all for all levels.
#DEFINES += -DDEBUG_ENABLE_MAIN
#DEFINES += -DDEBUG_ENABLE_MAP
#DEFINES += -DDEBUG_ENABLE_MAP_GEN
#DEFINES += -DDEBUG_ENABLE_GAME
VERSION = 0.3
TARGET = cataclysm
W32TARGET = cataclysm.exe
BINDIST_DIR = bindist
ODIR = obj
W32ODIR = objwin
DDIR = .deps
OS = $(shell uname -o)
CXX = $(CROSS)g++
# enable optimizations. slow to build
ifdef RELEASE
OTHERS += -O3
DEBUG =
endif
CXXFLAGS = $(WARNINGS) $(DEBUG) $(PROFILE) $(OTHERS) -MMD
BINDIST_EXTRAS = README data cataclysm-launcher
BINDIST = cataclysmdda-$(VERSION).tar.gz
W32BINDIST = cataclysmdda-$(VERSION).zip
BINDIST_CMD = tar -czvf $(BINDIST) $(BINDIST_DIR)
W32BINDIST_CMD = zip -r $(W32BINDIST) $(BINDIST_DIR)
# is this section even being used anymore?
# SOMEBODY PLEASE CHECK
#ifeq ($(OS), Msys)
# LDFLAGS = -static -lpdcurses
#else
LDFLAGS = -lncurses
#endif
# Linux 64-bit
ifeq ($(NATIVE), linux64)
CXXFLAGS += -m64
else
# Linux 32-bit
ifeq ($(NATIVE), linux32)
CXXFLAGS += -m32
endif
endif
# Win32 (mingw32?)
ifeq ($(NATIVE), win32)
TARGET = $(W32TARGET)
BINDIST = $(W32BINDIST)
BINDIST_CMD = $(W32BINDIST_CMD)
ODIR = $(W32ODIR)
W32LDFLAGS = -Wl,-stack,12000000,-subsystem,windows
LDFLAGS += -static -lgdi32
endif
# MXE cross-compile to win32
ifeq ($(CROSS), i686-pc-mingw32-)
TARGET = $(W32TARGET)
BINDIST = $(W32BINDIST)
BINDIST_CMD = $(W32BINDIST_CMD)
ODIR = $(W32ODIR)
LDFLAGS += -lgdi32
endif
SOURCES = $(wildcard *.cpp)
HEADERS = $(wildcard *.h)
_OBJS = $(SOURCES:.cpp=.o)
OBJS = $(patsubst %,$(ODIR)/%,$(_OBJS))
all: $(TARGET)
@
$(TARGET): $(ODIR) $(DDIR) $(OBJS)
$(CXX) $(W32FLAGS) -o $(TARGET) $(DEFINES) $(CXXFLAGS) \
$(OBJS) $(LDFLAGS)
$(ODIR):
mkdir $(ODIR)
$(DDIR):
@mkdir $(DDIR)
$(ODIR)/%.o: %.cpp
$(CXX) $(DEFINES) $(CXXFLAGS) -c $< -o $@
clean:
rm -f $(TARGET) $(W32TARGET) $(ODIR)/*.o $(ODIR)/*.d $(W32ODIR)/*.o $(W32BINDIST) \
$(BINDIST)
rm -rf $(BINDIST_DIR)
bindist: $(BINDIST)
$(BINDIST): $(TARGET) $(BINDIST_EXTRAS)
rm -rf $(BINDIST_DIR)
mkdir -p $(BINDIST_DIR)
cp -R $(TARGET) $(BINDIST_EXTRAS) $(BINDIST_DIR)
$(BINDIST_CMD)
export ODIR _OBJS LDFLAGS CXX W32FLAGS DEFINES CXXFLAGS
ctags: $(SOURCES) $(HEADERS)
ctags $(SOURCES) $(HEADERS)
tests: $(ODIR) $(DDIR) $(OBJS)
$(MAKE) -C tests
check: tests
$(MAKE) -C tests check
.PHONY: tests check
-include $(SOURCES:%.cpp=$(DEPDIR)/%.P)
-include ${OBJS:.o=.d}