d9e74a6f |
1 | #/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
2 | # * mupen64plus-rsp-hle - Makefile * |
3 | # * Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ * |
4 | # * Copyright (C) 2008-2009 Richard Goedeken * |
5 | # * Copyright (C) 2007-2008 DarkJeztr Tillin9 * |
6 | # * * |
7 | # * This program is free software; you can redistribute it and/or modify * |
8 | # * it under the terms of the GNU General Public License as published by * |
9 | # * the Free Software Foundation; either version 2 of the License, or * |
10 | # * (at your option) any later version. * |
11 | # * * |
12 | # * This program is distributed in the hope that it will be useful, * |
13 | # * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
14 | # * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
15 | # * GNU General Public License for more details. * |
16 | # * * |
17 | # * You should have received a copy of the GNU General Public License * |
18 | # * along with this program; if not, write to the * |
19 | # * Free Software Foundation, Inc., * |
20 | # * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * |
21 | # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
22 | # Makefile for Mupen64 HLE RSP plugin in Mupen64plus. |
23 | |
24 | # detect operating system |
25 | UNAME ?= $(shell uname -s) |
26 | OS := NONE |
27 | ifeq ("$(UNAME)","Linux") |
28 | OS = LINUX |
29 | SO_EXTENSION = so |
30 | SHARED = -shared |
31 | endif |
32 | ifeq ("$(UNAME)","linux") |
33 | OS = LINUX |
34 | SO_EXTENSION = so |
35 | SHARED = -shared |
36 | endif |
37 | ifneq ("$(filter GNU hurd,$(UNAME))","") |
38 | OS = LINUX |
39 | SO_EXTENSION = so |
40 | SHARED = -shared |
41 | endif |
42 | ifeq ("$(UNAME)","Darwin") |
43 | OS = OSX |
44 | SO_EXTENSION = dylib |
45 | SHARED = -bundle |
46 | endif |
47 | ifeq ("$(UNAME)","FreeBSD") |
48 | OS = FREEBSD |
49 | SO_EXTENSION = so |
50 | SHARED = -shared |
51 | endif |
52 | ifeq ("$(UNAME)","OpenBSD") |
53 | OS = FREEBSD |
54 | SO_EXTENSION = so |
55 | SHARED = -shared |
56 | $(warning OS type "$(UNAME)" not officially supported.') |
57 | endif |
58 | ifneq ("$(filter GNU/kFreeBSD kfreebsd,$(UNAME))","") |
59 | OS = LINUX |
60 | SO_EXTENSION = so |
61 | SHARED = -shared |
62 | endif |
63 | ifeq ("$(patsubst MINGW%,MINGW,$(UNAME))","MINGW") |
64 | OS = MINGW |
65 | SO_EXTENSION = dll |
66 | SHARED = -shared |
67 | PIC = 0 |
68 | endif |
69 | ifeq ("$(OS)","NONE") |
70 | $(error OS type "$(UNAME)" not supported. Please file bug report at 'http://code.google.com/p/mupen64plus/issues') |
71 | endif |
72 | |
73 | # detect system architecture |
74 | HOST_CPU ?= $(shell uname -m) |
75 | NO_ASM ?= 1 |
76 | CPU := NONE |
77 | ifneq ("$(filter x86_64 amd64,$(HOST_CPU))","") |
78 | CPU := X86 |
79 | ifeq ("$(BITS)", "32") |
80 | ARCH_DETECTED := 64BITS_32 |
81 | PIC ?= 0 |
82 | else |
83 | ARCH_DETECTED := 64BITS |
84 | PIC ?= 1 |
85 | endif |
86 | endif |
87 | ifneq ("$(filter pentium i%86,$(HOST_CPU))","") |
88 | CPU := X86 |
89 | ARCH_DETECTED := 32BITS |
90 | PIC ?= 0 |
91 | endif |
92 | ifneq ("$(filter ppc macppc socppc powerpc,$(HOST_CPU))","") |
93 | CPU := PPC |
94 | ARCH_DETECTED := 32BITS |
95 | BIG_ENDIAN := 1 |
96 | PIC ?= 1 |
97 | $(warning Architecture "$(HOST_CPU)" not officially supported.') |
98 | endif |
99 | ifneq ("$(filter ppc64 powerpc64,$(HOST_CPU))","") |
100 | CPU := PPC |
101 | ARCH_DETECTED := 64BITS |
102 | BIG_ENDIAN := 1 |
103 | PIC ?= 1 |
104 | $(warning Architecture "$(HOST_CPU)" not officially supported.') |
105 | endif |
106 | ifneq ("$(filter arm%,$(HOST_CPU))","") |
107 | ifeq ("$(filter arm%b,$(HOST_CPU))","") |
108 | CPU := ARM |
109 | ARCH_DETECTED := 32BITS |
110 | PIC ?= 1 |
111 | CFLAGS += -mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp -mtune=cortex-a8 -fsigned-char |
112 | $(warning Architecture "$(HOST_CPU)" not officially supported.') |
113 | endif |
114 | endif |
115 | ifeq ("$(CPU)","NONE") |
116 | $(error CPU type "$(HOST_CPU)" not supported. Please file bug report at 'http://code.google.com/p/mupen64plus/issues') |
117 | endif |
118 | |
119 | # base CFLAGS, LDLIBS, and LDFLAGS |
120 | OPTFLAGS ?= -O3 |
121 | WARNFLAGS ?= -Wall |
122 | CFLAGS += $(OPTFLAGS) $(WARNFLAGS) -ffast-math -fno-strict-aliasing -fvisibility=hidden -I../../src |
123 | CXXFLAGS += -fvisibility-inlines-hidden |
124 | LDFLAGS += $(SHARED) |
125 | |
126 | # Since we are building a shared library, we must compile with -fPIC on some architectures |
127 | # On 32-bit x86 systems we do not want to use -fPIC because we don't have to and it has a big performance penalty on this arch |
128 | ifeq ($(PIC), 1) |
129 | CFLAGS += -fPIC |
130 | else |
131 | CFLAGS += -fno-PIC |
132 | endif |
133 | |
134 | ifeq ($(BIG_ENDIAN), 1) |
135 | CFLAGS += -DM64P_BIG_ENDIAN |
136 | endif |
137 | |
138 | # tweak flags for 32-bit build on 64-bit system |
139 | ifeq ($(ARCH_DETECTED), 64BITS_32) |
140 | ifeq ($(OS), FREEBSD) |
141 | $(error Do not use the BITS=32 option with FreeBSD, use -m32 and -m elf_i386) |
142 | endif |
143 | CFLAGS += -m32 |
144 | LDFLAGS += -Wl,-m,elf_i386 |
145 | endif |
146 | |
147 | # set special flags per-system |
148 | ifeq ($(OS), LINUX) |
149 | # only export api symbols |
150 | LDFLAGS += -Wl,-version-script,$(SRCDIR)/rsp_api_export.ver |
151 | endif |
152 | ifeq ($(OS), OSX) |
153 | # Select the proper SDK |
154 | # Also, SDKs are stored in a different location since XCode 4.3 |
155 | OSX_SDK ?= $(shell sw_vers -productVersion | cut -f1 -f2 -d .) |
156 | OSX_XCODEMAJ = $(shell xcodebuild -version | grep '[0-9]*\.[0-9]*' | cut -f2 -d ' ' | cut -f1 -d .) |
157 | OSX_XCODEMIN = $(shell xcodebuild -version | grep '[0-9]*\.[0-9]*' | cut -f2 -d ' ' | cut -f2 -d .) |
158 | OSX_XCODEGE43 = $(shell echo "`expr $(OSX_XCODEMAJ) \>= 4``expr $(OSX_XCODEMIN) \>= 3`") |
159 | ifeq ($(OSX_XCODEGE43), 11) |
160 | OSX_SYSROOT := /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs |
161 | else |
162 | OSX_SYSROOT := /Developer/SDKs |
163 | endif |
164 | |
165 | ifeq ($(CPU), X86) |
166 | ifeq ($(ARCH_DETECTED), 64BITS) |
167 | CFLAGS += -pipe -arch x86_64 -mmacosx-version-min=$(OSX_SDK) -isysroot $(OSX_SYSROOT)/MacOSX$(OSX_SDK).sdk |
168 | else |
169 | CFLAGS += -pipe -mmmx -msse -fomit-frame-pointer -arch i686 -mmacosx-version-min=$(OSX_SDK) -isysroot $(OSX_SYSROOT)/MacOSX$(OSX_SDK).sdk |
170 | LDFLAGS += -read_only_relocs suppress |
171 | endif |
172 | endif |
173 | endif |
174 | |
175 | # set mupen64plus core API header path |
176 | ifneq ("$(APIDIR)","") |
177 | CFLAGS += "-I$(APIDIR)" |
178 | else |
179 | TRYDIR = ../../../mupen64plus-core/src/api |
180 | ifneq ("$(wildcard $(TRYDIR)/m64p_types.h)","") |
181 | CFLAGS += -I$(TRYDIR) |
182 | else |
183 | TRYDIR = /usr/local/include/mupen64plus |
184 | ifneq ("$(wildcard $(TRYDIR)/m64p_types.h)","") |
185 | CFLAGS += -I$(TRYDIR) |
186 | else |
187 | TRYDIR = /usr/include/mupen64plus |
188 | ifneq ("$(wildcard $(TRYDIR)/m64p_types.h)","") |
189 | CFLAGS += -I$(TRYDIR) |
190 | else |
191 | $(error Mupen64Plus API header files not found! Use makefile parameter APIDIR to force a location.) |
192 | endif |
193 | endif |
194 | endif |
195 | endif |
196 | |
197 | # reduced compile output when running make without V=1 |
198 | ifneq ($(findstring $(MAKEFLAGS),s),s) |
199 | ifndef V |
200 | Q_CC = @echo ' CC '$@; |
201 | Q_CXX = @echo ' CXX '$@; |
202 | Q_LD = @echo ' LD '$@; |
203 | endif |
204 | endif |
205 | |
206 | # set base program pointers and flags |
207 | CC = $(CROSS_COMPILE)gcc |
208 | CXX = $(CROSS_COMPILE)g++ |
209 | RM ?= rm -f |
210 | INSTALL ?= install |
211 | MKDIR ?= mkdir -p |
212 | COMPILE.c = $(Q_CC)$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c |
213 | COMPILE.cc = $(Q_CXX)$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c |
214 | LINK.o = $(Q_LD)$(CXX) $(CXXFLAGS) $(LDFLAGS) $(TARGET_ARCH) |
215 | |
216 | # set special flags for given Makefile parameters |
217 | ifeq ($(DEBUG),1) |
218 | CFLAGS += -g |
219 | INSTALL_STRIP_FLAG ?= |
220 | else |
221 | ifneq ($(OS),OSX) |
222 | INSTALL_STRIP_FLAG ?= -s |
223 | endif |
224 | endif |
225 | |
226 | # set installation options |
227 | ifeq ($(PREFIX),) |
228 | PREFIX := /usr/local |
229 | endif |
230 | ifeq ($(LIBDIR),) |
231 | LIBDIR := $(PREFIX)/lib |
232 | endif |
233 | ifeq ($(PLUGINDIR),) |
234 | PLUGINDIR := $(LIBDIR)/mupen64plus |
235 | endif |
236 | |
237 | SRCDIR = ../../src |
238 | OBJDIR = _obj$(POSTFIX) |
239 | |
240 | # list of source files to compile |
241 | SOURCE = \ |
242 | $(SRCDIR)/main.c \ |
243 | $(SRCDIR)/alist.c \ |
244 | $(SRCDIR)/cicx105.c \ |
245 | $(SRCDIR)/jpeg.c \ |
246 | $(SRCDIR)/ucode3.cpp \ |
247 | $(SRCDIR)/ucode2.cpp \ |
248 | $(SRCDIR)/ucode1.cpp \ |
249 | $(SRCDIR)/ucode3mp3.cpp |
250 | |
251 | # generate a list of object files build, make a temporary directory for them |
252 | OBJECTS := $(patsubst $(SRCDIR)/%.c, $(OBJDIR)/%.o, $(filter %.c, $(SOURCE))) |
253 | OBJECTS += $(patsubst $(SRCDIR)/%.cpp, $(OBJDIR)/%.o, $(filter %.cpp, $(SOURCE))) |
254 | OBJDIRS = $(dir $(OBJECTS)) |
255 | $(shell $(MKDIR) $(OBJDIRS)) |
256 | |
257 | # build targets |
258 | TARGET = mupen64plus-rsp-hle$(POSTFIX).$(SO_EXTENSION) |
259 | |
260 | targets: |
261 | @echo "Mupen64Plus-rsp-hle makefile. " |
262 | @echo " Targets:" |
263 | @echo " all == Build Mupen64Plus rsp-hle plugin" |
264 | @echo " clean == remove object files" |
265 | @echo " rebuild == clean and re-build all" |
266 | @echo " install == Install Mupen64Plus rsp-hle plugin" |
267 | @echo " uninstall == Uninstall Mupen64Plus rsp-hle plugin" |
268 | @echo " Options:" |
269 | @echo " BITS=32 == build 32-bit binaries on 64-bit machine" |
270 | @echo " APIDIR=path == path to find Mupen64Plus Core headers" |
271 | @echo " OPTFLAGS=flag == compiler optimization (default: -O3 -flto)" |
272 | @echo " WARNFLAGS=flag == compiler warning levels (default: -Wall)" |
273 | @echo " PIC=(1|0) == Force enable/disable of position independent code" |
274 | @echo " POSTFIX=name == String added to the name of the the build (default: '')" |
275 | @echo " Install Options:" |
276 | @echo " PREFIX=path == install/uninstall prefix (default: /usr/local)" |
277 | @echo " LIBDIR=path == library prefix (default: PREFIX/lib)" |
278 | @echo " PLUGINDIR=path == path to install plugin libraries (default: LIBDIR/mupen64plus)" |
279 | @echo " DESTDIR=path == path to prepend to all installation paths (only for packagers)" |
280 | @echo " Debugging Options:" |
281 | @echo " DEBUG=1 == add debugging symbols" |
282 | @echo " V=1 == show verbose compiler output" |
283 | |
284 | all: $(TARGET) |
285 | |
286 | install: $(TARGET) |
287 | $(INSTALL) -d "$(DESTDIR)$(PLUGINDIR)" |
288 | $(INSTALL) -m 0644 $(INSTALL_STRIP_FLAG) $(TARGET) "$(DESTDIR)$(PLUGINDIR)" |
289 | |
290 | uninstall: |
291 | $(RM) "$(DESTDIR)$(PLUGINDIR)/$(TARGET)" |
292 | |
293 | clean: |
294 | $(RM) -r $(OBJDIR) $(TARGET) |
295 | |
296 | rebuild: clean all |
297 | |
298 | # build dependency files |
299 | CFLAGS += -MD |
300 | -include $(OBJECTS:.o=.d) |
301 | |
302 | CXXFLAGS += $(CFLAGS) |
303 | |
304 | # standard build rules |
305 | $(OBJDIR)/%.o: $(SRCDIR)/%.c |
306 | $(COMPILE.c) -o $@ $< |
307 | |
308 | $(OBJDIR)/%.o: $(SRCDIR)/%.cpp |
309 | $(COMPILE.cc) -o $@ $< |
310 | |
311 | $(TARGET): $(OBJECTS) |
312 | $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@ |
313 | |
314 | .PHONY: all clean install uninstall targets |