forked from enzo1982/freac
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile-options
316 lines (271 loc) · 6.57 KB
/
Makefile-options
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
########## fre:ac options makefile ##########
SMOOTHVER = 0.9
BOCAVER = 1.0
# Find source folder and set vpath
SRCDIR = $(abspath $(dir $(firstword $(MAKEFILE_LIST))))
vpath %.c "$(SRCDIR)"
vpath %.cc "$(SRCDIR)"
vpath %.cpp "$(SRCDIR)"
vpath %.m "$(SRCDIR)"
vpath %.mm "$(SRCDIR)"
vpath %.rc "$(SRCDIR)"
vpath %.ico "$(SRCDIR)"
# Define makein and cleanin macros
ifeq ("$(SRCDIR)","$(CURDIR)")
makein = cd $(1) && $(MAKE) $(2) && cd ..
cleanin = cd $(1) && $(MAKE) clean && cd ..
else
makein = mkdir -p $(1) && cd $(1) && $(MAKE) -f "$(SRCDIR)"/$(1)/Makefile $(2) && cd ..
cleanin = mkdir -p $(1) && cd $(1) && $(MAKE) -f "$(SRCDIR)"/$(1)/Makefile clean && cd .. && (rmdir $(1) || true)
endif
# Find architecture and system
UNAME = $(shell uname)
MACHINE = $(shell $(CC) -dumpmachine)
ifneq ($(findstring arm,$(MACHINE)),)
ifneq ($(BUILD_ARM),False)
BUILD_ARM = True
endif
else ifneq ($(findstring aarch64,$(MACHINE)),)
ifneq ($(BUILD_ARM64),False)
BUILD_ARM64 = True
endif
else ifneq ($(findstring mips,$(MACHINE)),)
ifneq ($(BUILD_MIPS),False)
BUILD_MIPS = True
endif
else ifneq ($(findstring powerpc,$(MACHINE)),)
ifneq ($(BUILD_PPC),False)
BUILD_PPC = True
endif
else ifneq ($(findstring powerpc64,$(MACHINE)),)
ifneq ($(BUILD_PPC64),False)
BUILD_PPC64 = True
endif
else ifneq ($(findstring x86_64,$(MACHINE)),)
ifneq ($(BUILD_X86),True)
ifneq ($(BUILD_X86_64),False)
BUILD_X86_64 = True
endif
endif
else ifneq ($(findstring amd64,$(MACHINE)),)
ifneq ($(BUILD_X86),True)
ifneq ($(BUILD_X86_64),False)
BUILD_X86_64 = True
endif
endif
else
ifneq ($(BUILD_X86),False)
ifneq ($(BUILD_X86_64),True)
BUILD_X86 = True
endif
endif
endif
# Treat MSYS and MinGW the same
ifneq ($(findstring MSYS,$(UNAME)),)
UNAME = MINGW
endif
ifneq ($(findstring MINGW,$(UNAME)),)
# Set executable and shared object extensions
EXECUTABLE = .exe
SHARED = .dll
# Build on Win32
BUILD_WIN32 = True
else
# Set executable and shared object extensions
EXECUTABLE =
SHARED = .so
BUILD_UNIX = True
ifeq ($(UNAME),Linux)
BUILD_LINUX = True
else ifeq ($(UNAME),FreeBSD)
BUILD_FREEBSD = True
else ifeq ($(UNAME),OpenBSD)
BUILD_OPENBSD = True
else ifeq ($(UNAME),NetBSD)
BUILD_NETBSD = True
else ifeq ($(UNAME),SunOS)
BUILD_SOLARIS = True
else ifeq ($(UNAME),Haiku)
BUILD_HAIKU = True
else ifeq ($(UNAME),GNU)
BUILD_GNU = True
else ifeq ($(UNAME),Darwin)
# Set shared object extension
SHARED = .dylib
BUILD_OSX = True
# Build universal binaries
ifneq ($(BUILD_X86),False)
BUILD_X86 = True
endif
ifneq ($(BUILD_X86_64),False)
BUILD_X86_64 = True
endif
ifneq ($(BUILD_PPC),False)
BUILD_PPC = True
endif
endif
endif
# Set default commands
ifndef OBJC
OBJC = $(CC)
endif
ifndef OBJCXX
OBJCXX = $(CXX)
endif
ifeq ($(LD),ld)
LD = $(CC)
endif
LDCONFIG = /sbin/ldconfig
INSTALL = install
ifeq ($(BUILD_SOLARIS),True)
INSTALL = ginstall
endif
INSTALL_PROGRAM = $(INSTALL)
INSTALL_DATA = $(INSTALL) -m 644
# Set output folders
BINDIR = bin
LIBDIR = lib
ifeq ($(BUILD_WIN32),True)
ifeq ($(BUILD_X86_64),True)
BINDIR = bin64
LIBDIR = lib64
endif
else ifeq ($(BUILD_OSX),True)
ifeq ($(BUILD_X86_64),True)
BINDIR = bin64
LIBDIR = lib64
else ifeq ($(BUILD_PPC64),True)
BINDIR = bin64
LIBDIR = lib64
endif
endif
# Set install folders
ifndef prefix
prefix = /usr/local
ifeq ($(BUILD_HAIKU),True)
prefix = /system/non-packaged
endif
endif
bindir = $(prefix)/bin
libdir = $(prefix)/lib
includedir = $(prefix)/include
datadir = $(prefix)/share
ifeq ($(BUILD_HAIKU),True)
includedir = $(prefix)/develop/headers
datadir = $(prefix)/data
endif
# Set release specific options
ifeq ($(findstring release,$(config)),release)
ifeq ($(BUILD_FREEBSD),True)
override CC = clang
override CXX = clang
override OBJC = clang
override OBJCXX = clang
override LD = clang
else ifeq ($(BUILD_OSX),True)
override CC = gcc
override CXX = gcc
override OBJC = gcc
override OBJCXX = gcc
override LD = gcc
endif
override CFLAGS = -pipe -g0 -Wall -Os -DFREAC_DATE=\"$(shell date +"%Y%m%d")\"
override CXXFLAGS =
override OBJCFLAGS =
override OBJCXXFLAGS =
override LDFLAGS = -pipe
ifneq ($(RTTI),True)
ifneq ($(BUILD_HAIKU),True)
override CXXFLAGS += -fno-rtti
override OBJCXXFLAGS += -fno-rtti
endif
endif
ifneq ($(EXCEPTION),True)
override CXXFLAGS += -fno-exceptions
override OBJCXXFLAGS += -fno-exceptions
endif
ifeq ($(BUILD_OSX),True)
override LDFLAGS += -Wl,-x
ifeq ($(BUILD_X86),True)
override CFLAGS += -arch i386 -Xarch_i386 -march=prescott
override LDFLAGS += -arch i386
endif
ifeq ($(BUILD_X86_64),True)
override CFLAGS += -arch x86_64 -Xarch_x86_64 -march=core2
override LDFLAGS += -arch x86_64
endif
ifeq ($(BUILD_PPC),True)
override CFLAGS += -arch ppc -Xarch_ppc -mcpu=G4
override LDFLAGS += -arch ppc
endif
ifeq ($(BUILD_PPC64),True)
override CFLAGS += -arch ppc64 -Xarch_ppc64 -mcpu=G5
override LDFLAGS += -arch ppc64
endif
else
override LDFLAGS += -s
ifeq ($(BUILD_X86),True)
override CFLAGS += -m32
override LDFLAGS += -m32
else ifeq ($(BUILD_X86_64),True)
override CFLAGS += -m64
override LDFLAGS += -m64
endif
endif
override CXXFLAGS += $(CFLAGS)
override OBJCFLAGS += $(CFLAGS)
override OBJCXXFLAGS += $(CFLAGS)
ifneq ($(BUILD_WIN32),True)
ifneq ($(BUILD_OSX),True)
override LDFLAGS += -Wl,-rpath,.
endif
endif
# Use V8 when building on a supported platform
ifeq ($(BUILD_X86),True)
USE_V8 = True
else ifeq ($(BUILD_X86_64),True)
USE_V8 = True
else ifeq ($(BUILD_ARM),True)
USE_V8 = True
else ifeq ($(BUILD_MIPS),True)
USE_V8 = True
endif
endif
# Set debug specific options
ifeq ($(findstring debug,$(config)),debug)
override CFLAGS = -pipe -g -Wall -DDEBUG
override CXXFLAGS =
override OBJCFLAGS =
override OBJCXXFLAGS =
override LDFLAGS = -pipe
ifneq ($(RTTI),True)
ifneq ($(BUILD_HAIKU),True)
override CXXFLAGS += -fno-rtti
override OBJCXXFLAGS += -fno-rtti
endif
endif
ifneq ($(EXCEPTION),True)
override CXXFLAGS += -fno-exceptions
override OBJCXXFLAGS += -fno-exceptions
endif
override CXXFLAGS += $(CFLAGS)
override OBJCFLAGS += $(CFLAGS)
override OBJCXXFLAGS += $(CFLAGS)
ifneq ($(BUILD_WIN32),True)
ifneq ($(BUILD_OSX),True)
override LDFLAGS += -Wl,-rpath,.
endif
endif
# Use V8 when building on a supported platform
ifeq ($(BUILD_X86),True)
USE_V8 = True
else ifeq ($(BUILD_X86_64),True)
USE_V8 = True
else ifeq ($(BUILD_ARM),True)
USE_V8 = True
else ifeq ($(BUILD_MIPS),True)
USE_V8 = True
endif
endif
# Clear config variable
config =