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 |
70282791 |
111 | #CFLAGS += -mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp -mtune=cortex-a8 -fsigned-char -ftree-vectorize |
112 | CFLAGS += -fsigned-char |
113 | CFLAGS += -mcpu=native -mtune=native -marm -mfpu=neon |
d9e74a6f |
114 | $(warning Architecture "$(HOST_CPU)" not officially supported.') |
115 | endif |
116 | endif |
117 | ifeq ("$(CPU)","NONE") |
118 | $(error CPU type "$(HOST_CPU)" not supported. Please file bug report at 'http://code.google.com/p/mupen64plus/issues') |
119 | endif |
120 | |
121 | # base CFLAGS, LDLIBS, and LDFLAGS |
122 | OPTFLAGS ?= -O3 |
123 | WARNFLAGS ?= -Wall |
124 | CFLAGS += $(OPTFLAGS) $(WARNFLAGS) -ffast-math -fno-strict-aliasing -fvisibility=hidden -I../../src |
125 | CXXFLAGS += -fvisibility-inlines-hidden |
126 | LDFLAGS += $(SHARED) |
127 | |
128 | # Since we are building a shared library, we must compile with -fPIC on some architectures |
129 | # 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 |
130 | ifeq ($(PIC), 1) |
131 | CFLAGS += -fPIC |
132 | else |
133 | CFLAGS += -fno-PIC |
134 | endif |
135 | |
136 | ifeq ($(BIG_ENDIAN), 1) |
137 | CFLAGS += -DM64P_BIG_ENDIAN |
138 | endif |
139 | |
140 | # tweak flags for 32-bit build on 64-bit system |
141 | ifeq ($(ARCH_DETECTED), 64BITS_32) |
142 | ifeq ($(OS), FREEBSD) |
143 | $(error Do not use the BITS=32 option with FreeBSD, use -m32 and -m elf_i386) |
144 | endif |
145 | CFLAGS += -m32 |
146 | LDFLAGS += -Wl,-m,elf_i386 |
147 | endif |
148 | |
149 | # set special flags per-system |
150 | ifeq ($(OS), LINUX) |
151 | # only export api symbols |
152 | LDFLAGS += -Wl,-version-script,$(SRCDIR)/rsp_api_export.ver |
153 | endif |
154 | ifeq ($(OS), OSX) |
2d262872 |
155 | #xcode-select has been around since XCode 3.0, i.e. OS X 10.5 |
156 | OSX_SDK_ROOT = $(shell xcode-select -print-path)/Platforms/MacOSX.platform/Developer/SDKs |
157 | OSX_SDK_PATH = $(OSX_SDK_ROOT)/$(shell ls $(OSX_SDK_ROOT) | tail -1) |
d9e74a6f |
158 | |
159 | ifeq ($(CPU), X86) |
160 | ifeq ($(ARCH_DETECTED), 64BITS) |
2d262872 |
161 | CFLAGS += -pipe -arch x86_64 -mmacosx-version-min=10.5 -isysroot $(OSX_SDK_PATH) |
d9e74a6f |
162 | else |
2d262872 |
163 | CFLAGS += -pipe -mmmx -msse -fomit-frame-pointer -arch i686 -mmacosx-version-min=10.5 -isysroot $(OSX_SDK_PATH) |
d9e74a6f |
164 | LDFLAGS += -read_only_relocs suppress |
165 | endif |
166 | endif |
167 | endif |
168 | |
169 | # set mupen64plus core API header path |
170 | ifneq ("$(APIDIR)","") |
171 | CFLAGS += "-I$(APIDIR)" |
172 | else |
173 | TRYDIR = ../../../mupen64plus-core/src/api |
174 | ifneq ("$(wildcard $(TRYDIR)/m64p_types.h)","") |
175 | CFLAGS += -I$(TRYDIR) |
176 | else |
177 | TRYDIR = /usr/local/include/mupen64plus |
178 | ifneq ("$(wildcard $(TRYDIR)/m64p_types.h)","") |
179 | CFLAGS += -I$(TRYDIR) |
180 | else |
181 | TRYDIR = /usr/include/mupen64plus |
182 | ifneq ("$(wildcard $(TRYDIR)/m64p_types.h)","") |
183 | CFLAGS += -I$(TRYDIR) |
184 | else |
185 | $(error Mupen64Plus API header files not found! Use makefile parameter APIDIR to force a location.) |
186 | endif |
187 | endif |
188 | endif |
189 | endif |
190 | |
191 | # reduced compile output when running make without V=1 |
192 | ifneq ($(findstring $(MAKEFLAGS),s),s) |
193 | ifndef V |
194 | Q_CC = @echo ' CC '$@; |
195 | Q_CXX = @echo ' CXX '$@; |
196 | Q_LD = @echo ' LD '$@; |
197 | endif |
198 | endif |
199 | |
200 | # set base program pointers and flags |
201 | CC = $(CROSS_COMPILE)gcc |
202 | CXX = $(CROSS_COMPILE)g++ |
203 | RM ?= rm -f |
204 | INSTALL ?= install |
205 | MKDIR ?= mkdir -p |
206 | COMPILE.c = $(Q_CC)$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c |
207 | COMPILE.cc = $(Q_CXX)$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c |
208 | LINK.o = $(Q_LD)$(CXX) $(CXXFLAGS) $(LDFLAGS) $(TARGET_ARCH) |
209 | |
210 | # set special flags for given Makefile parameters |
211 | ifeq ($(DEBUG),1) |
212 | CFLAGS += -g |
213 | INSTALL_STRIP_FLAG ?= |
214 | else |
215 | ifneq ($(OS),OSX) |
216 | INSTALL_STRIP_FLAG ?= -s |
217 | endif |
218 | endif |
219 | |
220 | # set installation options |
221 | ifeq ($(PREFIX),) |
222 | PREFIX := /usr/local |
223 | endif |
224 | ifeq ($(LIBDIR),) |
225 | LIBDIR := $(PREFIX)/lib |
226 | endif |
227 | ifeq ($(PLUGINDIR),) |
228 | PLUGINDIR := $(LIBDIR)/mupen64plus |
229 | endif |
230 | |
231 | SRCDIR = ../../src |
232 | OBJDIR = _obj$(POSTFIX) |
233 | |
234 | # list of source files to compile |
235 | SOURCE = \ |
236 | $(SRCDIR)/main.c \ |
237 | $(SRCDIR)/alist.c \ |
238 | $(SRCDIR)/cicx105.c \ |
239 | $(SRCDIR)/jpeg.c \ |
0a8a0368 |
240 | $(SRCDIR)/musyx.c \ |
241 | $(SRCDIR)/ucode3.c \ |
242 | $(SRCDIR)/ucode2.c \ |
243 | $(SRCDIR)/ucode1.c \ |
244 | $(SRCDIR)/ucode3mp3.c |
d9e74a6f |
245 | |
246 | # generate a list of object files build, make a temporary directory for them |
247 | OBJECTS := $(patsubst $(SRCDIR)/%.c, $(OBJDIR)/%.o, $(filter %.c, $(SOURCE))) |
248 | OBJECTS += $(patsubst $(SRCDIR)/%.cpp, $(OBJDIR)/%.o, $(filter %.cpp, $(SOURCE))) |
249 | OBJDIRS = $(dir $(OBJECTS)) |
250 | $(shell $(MKDIR) $(OBJDIRS)) |
251 | |
252 | # build targets |
253 | TARGET = mupen64plus-rsp-hle$(POSTFIX).$(SO_EXTENSION) |
254 | |
255 | targets: |
256 | @echo "Mupen64Plus-rsp-hle makefile. " |
257 | @echo " Targets:" |
258 | @echo " all == Build Mupen64Plus rsp-hle plugin" |
259 | @echo " clean == remove object files" |
260 | @echo " rebuild == clean and re-build all" |
261 | @echo " install == Install Mupen64Plus rsp-hle plugin" |
262 | @echo " uninstall == Uninstall Mupen64Plus rsp-hle plugin" |
263 | @echo " Options:" |
264 | @echo " BITS=32 == build 32-bit binaries on 64-bit machine" |
265 | @echo " APIDIR=path == path to find Mupen64Plus Core headers" |
266 | @echo " OPTFLAGS=flag == compiler optimization (default: -O3 -flto)" |
267 | @echo " WARNFLAGS=flag == compiler warning levels (default: -Wall)" |
268 | @echo " PIC=(1|0) == Force enable/disable of position independent code" |
269 | @echo " POSTFIX=name == String added to the name of the the build (default: '')" |
270 | @echo " Install Options:" |
271 | @echo " PREFIX=path == install/uninstall prefix (default: /usr/local)" |
272 | @echo " LIBDIR=path == library prefix (default: PREFIX/lib)" |
273 | @echo " PLUGINDIR=path == path to install plugin libraries (default: LIBDIR/mupen64plus)" |
274 | @echo " DESTDIR=path == path to prepend to all installation paths (only for packagers)" |
275 | @echo " Debugging Options:" |
276 | @echo " DEBUG=1 == add debugging symbols" |
277 | @echo " V=1 == show verbose compiler output" |
278 | |
279 | all: $(TARGET) |
280 | |
281 | install: $(TARGET) |
282 | $(INSTALL) -d "$(DESTDIR)$(PLUGINDIR)" |
283 | $(INSTALL) -m 0644 $(INSTALL_STRIP_FLAG) $(TARGET) "$(DESTDIR)$(PLUGINDIR)" |
284 | |
285 | uninstall: |
286 | $(RM) "$(DESTDIR)$(PLUGINDIR)/$(TARGET)" |
287 | |
288 | clean: |
289 | $(RM) -r $(OBJDIR) $(TARGET) |
290 | |
291 | rebuild: clean all |
292 | |
293 | # build dependency files |
2d262872 |
294 | CFLAGS += -MD -MP |
d9e74a6f |
295 | -include $(OBJECTS:.o=.d) |
296 | |
297 | CXXFLAGS += $(CFLAGS) |
298 | |
299 | # standard build rules |
300 | $(OBJDIR)/%.o: $(SRCDIR)/%.c |
301 | $(COMPILE.c) -o $@ $< |
302 | |
303 | $(OBJDIR)/%.o: $(SRCDIR)/%.cpp |
304 | $(COMPILE.cc) -o $@ $< |
305 | |
306 | $(TARGET): $(OBJECTS) |
307 | $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@ |
308 | |
309 | .PHONY: all clean install uninstall targets |