-
Notifications
You must be signed in to change notification settings - Fork 3
/
pre.mk
397 lines (375 loc) · 10.4 KB
/
pre.mk
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
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
#/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
# * Mupen64plus - pre.mk *
# * Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ *
# * Copyright (C) 2007-2008 DarkJeztr Tillin9 Richard42 *
# * *
# * This program is free software; you can redistribute it and/or modify *
# * it under the terms of the GNU General Public License as published by *
# * the Free Software Foundation; either version 2 of the License, or *
# * (at your option) any later version. *
# * *
# * This program is distributed in the hope that it will be useful, *
# * but WITHOUT ANY WARRANTY; without even the implied warranty of *
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
# * GNU General Public License for more details. *
# * *
# * You should have received a copy of the GNU General Public License *
# * along with this program; if not, write to the *
# * Free Software Foundation, Inc., *
# * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
# * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
# detect system architecture: i386, x86_64, PPC/PPC64, ALPHA, ARM, AVR32, HPPA,
# IA64, M32R, M68K, MIPS, S390, SH3, SH4, SPARC
HOST_CPU ?= $(shell uname -m)
NO_ASM ?= 1
ifneq ("$(filter x86_64 amd64,$(HOST_CPU))","")
CPU := X86
ifeq ("$(BITS)", "32")
ARCH_DETECTED := 64BITS_32
else
ARCH_DETECTED := 64BITS
endif
NO_ASM := 0
CPU_ENDIANNESS := LITTLE
endif
ifneq ("$(filter pentium i%86,$(HOST_CPU))","")
CPU := X86
ARCH_DETECTED := 32BITS
NO_ASM := 0
CPU_ENDIANNESS := LITTLE
endif
ifneq ("$(filter ppc powerpc,$(HOST_CPU))","")
CPU := PPC
ARCH_DETECTED := 32BITS
NO_ASM := 1
CPU_ENDIANNESS := BIG
endif
ifneq ("$(filter ppc64 powerpc64,$(HOST_CPU))","")
CPU := PPC
ARCH_DETECTED := 64BITS
NO_ASM := 1
CPU_ENDIANNESS := BIG
endif
ifneq ("$(filter alpha%,$(HOST_CPU))","")
CPU := ALPHA
ARCH_DETECTED := 64BITS
NO_ASM := 1
CPU_ENDIANNESS := LITTLE
endif
ifneq ("$(filter arm%b,$(HOST_CPU))","")
CPU := ARM
ARCH_DETECTED := 32BITS
NO_ASM := 1
CPU_ENDIANNESS := BIG
else
ifneq ("$(filter arm%,$(HOST_CPU))","")
CPU := ARM
ARCH_DETECTED := 32BITS
NO_ASM := 1
CPU_ENDIANNESS := LITTLE
endif
endif
ifneq ("$(filter hppa%b,$(HOST_CPU))","")
CPU := HPPA
ARCH_DETECTED := 32BITS
NO_ASM := 1
CPU_ENDIANNESS := BIG
endif
ifeq ("$(HOST_CPU)","ia64")
CPU := IA64
ARCH_DETECTED := 64BITS
NO_ASM := 1
CPU_ENDIANNESS := LITTLE
endif
ifeq ("$(HOST_CPU)","avr32")
CPU := AVR32
ARCH_DETECTED := 32BITS
NO_ASM := 1
CPU_ENDIANNESS := BIG
endif
ifeq ("$(HOST_CPU)","m32r")
CPU := M32R
ARCH_DETECTED := 32BITS
NO_ASM := 1
CPU_ENDIANNESS := BIG
endif
ifeq ("$(HOST_CPU)","m68k")
CPU := M68K
ARCH_DETECTED := 32BITS
NO_ASM := 1
CPU_ENDIANNESS := BIG
endif
ifneq ("$(filter mips mipseb,$(HOST_CPU))","")
CPU := MIPS
ARCH_DETECTED := 32BITS
NO_ASM := 1
CPU_ENDIANNESS := BIG
endif
ifeq ("$(HOST_CPU)","mipsel")
CPU := MIPS
ARCH_DETECTED := 32BITS
NO_ASM := 1
CPU_ENDIANNESS := LITTLE
endif
ifeq ("$(HOST_CPU)","s390")
CPU := S390
ARCH_DETECTED := 32BITS
NO_ASM := 1
CPU_ENDIANNESS := BIG
endif
ifeq ("$(HOST_CPU)","s390x")
CPU := S390
ARCH_DETECTED := 64BITS
NO_ASM := 1
CPU_ENDIANNESS := BIG
endif
ifeq ("$(HOST_CPU)","sh3")
CPU := SH3
ARCH_DETECTED := 32BITS
NO_ASM := 1
CPU_ENDIANNESS := LITTLE
endif
ifeq ("$(HOST_CPU)","sh3eb")
CPU := SH3
ARCH_DETECTED := 32BITS
NO_ASM := 1
CPU_ENDIANNESS := BIG
endif
ifeq ("$(HOST_CPU)","sh4")
CPU := SH4
ARCH_DETECTED := 32BITS
NO_ASM := 1
CPU_ENDIANNESS := LITTLE
endif
ifeq ("$(HOST_CPU)","sh4eb")
CPU := SH4
ARCH_DETECTED := 32BITS
NO_ASM := 1
CPU_ENDIANNESS := BIG
endif
ifeq ("$(HOST_CPU)","sparc")
CPU := SPARC
ARCH_DETECTED := 32BITS
NO_ASM := 1
CPU_ENDIANNESS := BIG
endif
# detect operation system. Currently just linux and OSX.
UNAME = $(shell uname -s)
ifeq ("$(UNAME)","Linux")
OS = LINUX
endif
ifeq ("$(UNAME)","linux")
OS = LINUX
endif
ifeq ("$(UNAME)","Darwin")
OS = OSX
LDFLAGS += -liconv -lpng
endif
ifeq ("$(UNAME)","FreeBSD")
OS = FREEBSD
endif
ifeq ($(OS),)
$(warning OS not supported or detected, using default linux options.)
OS = LINUX
endif
# test for presence of SDL
ifeq ($(shell which sdl-config 2>/dev/null),)
$(error No SDL development libraries found!)
endif
ifeq ($(OS),FREEBSD)
SDL_FLAGS = `${SDL_CONFIG} --cflags`
SDL_LIBS = `${SDL_CONFIG} --libs`
else
SDL_FLAGS = $(shell sdl-config --cflags)
SDL_LIBS = $(shell sdl-config --libs)
endif
# test for presence of FreeType
ifeq ($(shell which freetype-config 2>/dev/null),)
$(error freetype-config not installed!)
endif
FREETYPE_LIBS = $(shell freetype-config --libs)
FREETYPE_FLAGS = $(shell freetype-config --cflags)
# set Freetype flags
FREETYPEINC = $(shell pkg-config --cflags freetype2)
CFLAGS += $(FREETYPEINC)
# detect GUI options
ifeq ($(GUI),)
GUI = GTK2
endif
# set GTK2 flags and libraries
# ideally we don't always do this, only when using the Gtk GUI,
# but too many plugins require it...
# test for presence of GTK 2.0
ifeq ($(shell which pkg-config 2>/dev/null),)
$(error pkg-config not installed!)
endif
ifneq ("$(shell pkg-config gtk+-2.0 --modversion | head -c 2)", "2.")
$(error No GTK 2.x development libraries found!)
endif
# set GTK flags and libraries
GTK_FLAGS = $(shell pkg-config gtk+-2.0 --cflags)
GTK_LIBS = $(shell pkg-config gtk+-2.0 --libs)
GTHREAD_LIBS = $(shell pkg-config gthread-2.0 --libs)
# set Qt flags and libraries
# some distros append -qt4 to the binaries so look for those first
ifeq ($(GUI), QT4)
ifneq ($(USES_QT4),)
QMAKE = ${shell which qmake-qt4 2>/dev/null}
ifeq ($(QMAKE),)
QMAKE = ${shell which qmake 2>/dev/null}
endif
ifeq ($(QMAKE),)
$(error qmake from Qt not found! Make sure the Qt binaries are in your PATH)
endif
MOC = $(shell which moc-qt4 2>/dev/null)
ifeq ($(MOC),)
MOC = $(shell which moc 2>/dev/null)
endif
ifeq ($(MOC),)
$(error moc from Qt not found! Make sure the Qt binaries are in your PATH)
endif
UIC = $(shell which uic-qt4 2>/dev/null)
ifeq ($(UIC),)
UIC = $(shell which uic 2>/dev/null)
endif
ifeq ($(UIC),)
$(error uic from Qt not found! Make sure the Qt binaries are in your PATH)
endif
RCC = $(shell which rcc-qt4 2>/dev/null)
ifeq ($(RCC),)
RCC = $(shell which rcc 2>/dev/null)
endif
ifeq ($(RCC),)
$(error rcc from Qt not found! Make sure the Qt binaries are in your PATH)
endif
LRELEASE = $(shell which lrelease-qt4 2>/dev/null)
ifeq ($(LRELEASE),)
LRELEASE = $(shell which lrelease 2>/dev/null)
endif
ifeq ($(LRELEASE),)
$(error lrelease from Qt not found! Make sure the Qt binaries are in your PATH)
endif
QT_FLAGS = $(shell pkg-config QtCore QtGui --cflags)
QT_LIBS = $(shell pkg-config QtCore QtGui --libs)
# define Gtk flags when using Qt4 gui so it can load plugins, etc.
endif
endif
# set base program pointers and flags
ifeq ($(OS),FREEBSD)
CC ?= gcc
CXX ?= g++
LD ?= g++
RM ?= rm
RM_F ?= rm -f
MV ?= mv
CP ?= cp
MD ?= mkdir
FIND ?= find
PROF ?= gprof
INSTALL ?= ginstall
STRIP ?= strip -s
else
CC = gcc
CXX = g++
LD = g++
RM = rm
RM_F = rm -f
MV = mv
CP = cp
MD = mkdir
FIND = find
PROF = gprof
INSTALL = ginstall
ifeq ($(OS),LINUX)
STRIP = strip -s
endif
ifeq ($(OS),OSX)
STRIP = strip -x
endif
endif
# create SVN version defines
MUPEN_RELEASE = 1.5
ifneq ($(RELEASE),)
MUPEN_VERSION = $(VER)
PLUGIN_VERSION = $(VER)
else
ifeq ($(shell svn info ./ 2>/dev/null),)
MUPEN_VERSION = $(MUPEN_RELEASE)-development
PLUGIN_VERSION = $(MUPEN_RELEASE)-development
else
SVN_REVISION = $(shell svn info ./ 2>/dev/null | sed -n '/^Revision: /s/^Revision: //p')
SVN_BRANCH = $(shell svn info ./ 2>/dev/null | sed -n '/^URL: /s/.*mupen64plus.//1p')
SVN_DIFFHASH = $(shell svn diff ./ 2>/dev/null | md5sum | sed '/.*/s/ -//;/^d41d8cd98f00b204e9800998ecf8427e/d')
MUPEN_VERSION = $(MUPEN_RELEASE)-$(SVN_BRANCH)-r$(SVN_REVISION) $(SVN_DIFFHASH)
PLUGIN_VERSION = $(MUPEN_RELEASE)-$(SVN_BRANCH)-r$(SVN_REVISION)
endif
endif
# set base CFLAGS and LDFLAGS
CFLAGS += -ffast-math -funroll-loops -fexpensive-optimizations -fno-strict-aliasing
ifneq ($(OS), FREEBSD)
CFLAGS += -pipe -O3
endif
ifeq ($(OS), FREEBSD)
CORE_LDFLAGS += -lz -lm -lpng -lfreetype
else
CORE_LDFLAGS += -lz -lm -lpng -lfreetype -ldl
endif
# set special flags per-system
ifneq ($(OS), FREEBSD)
ifeq ($(CPU), X86)
ifeq ($(ARCH_DETECTED), 64BITS)
CFLAGS += -march=athlon64
else
CFLAGS += -mmmx -msse -march=i686 -mtune=pentium-m
ifneq ($(PROFILE), 1)
CFLAGS += -fomit-frame-pointer
endif
endif
# tweak flags for 32-bit build on 64-bit system
ifeq ($(ARCH_DETECTED), 64BITS_32)
CFLAGS += -m32
LDFLAGS += -m32 -m elf_i386
endif
endif
else
ifeq ($(ARCH_DETECTED), 64BITS_32)
$(error Do not use the BITS=32 option with FreeBSD, use -m32 and -m elf_i386)
endif
endif
ifeq ($(CPU), PPC)
CFLAGS += -mcpu=powerpc
endif
ifeq ($(CPU_ENDIANNESS), BIG)
CFLAGS += -D_BIG_ENDIAN
endif
# set CFLAGS, LIBS, and LDFLAGS according to the target OS
ifeq ($(OS),FREEBSD)
PLUGIN_LDFLAGS = -Wl,-Bsymbolic -shared
LIBGL_LIBS = -L${LOCALBASE}/lib -lGL -lGLU
endif
ifeq ($(OS),LINUX)
PLUGIN_LDFLAGS = -Wl,-Bsymbolic -shared
LIBGL_LIBS = -L/usr/X11R6/lib -lGL -lGLU
endif
ifeq ($(OS),OSX)
PLUGIN_LDFLAGS = -bundle
LIBGL_LIBS = -framework OpenGL
QMAKE_FLAGS = -spec macx-g++
endif
# set flags for compile options.
# set CFLAGS macro for no assembly language if required
ifeq ($(NO_ASM), 1)
CFLAGS += -DNO_ASM
endif
# set variables for profiling
ifeq ($(PROFILE), 1)
CFLAGS += -pg -g
LDFLAGS += -pg
STRIP = true
else # set variables for debugging symbols
ifeq ($(DBGSYM), 1)
CFLAGS += -g
STRIP = true
endif
endif
SO_EXTENSION = so