d07c171f |
1 | #/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
2 | # * Mupen64plus-video-rice - Makefile * |
3 | # * Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ * |
4 | # * Copyright (C) 2007-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 RiceVideo 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 | PIC = 1 # force PIC under OSX |
47 | endif |
48 | ifeq ("$(UNAME)","FreeBSD") |
49 | OS = FREEBSD |
50 | SO_EXTENSION = so |
51 | SHARED = -shared |
52 | endif |
53 | ifeq ("$(UNAME)","OpenBSD") |
54 | OS = FREEBSD |
55 | SO_EXTENSION = so |
56 | SHARED = -shared |
57 | $(warning OS type "$(UNAME)" not officially supported.') |
58 | endif |
59 | ifneq ("$(filter GNU/kFreeBSD kfreebsd,$(UNAME))","") |
60 | OS = LINUX |
61 | SO_EXTENSION = so |
62 | SHARED = -shared |
63 | endif |
64 | ifeq ("$(patsubst MINGW%,MINGW,$(UNAME))","MINGW") |
65 | OS = MINGW |
66 | SO_EXTENSION = dll |
67 | SHARED = -shared |
68 | PIC = 0 |
69 | endif |
70 | ifeq ("$(OS)","NONE") |
71 | $(error OS type "$(UNAME)" not supported. Please file bug report at 'http://code.google.com/p/mupen64plus/issues') |
72 | endif |
73 | |
74 | # detect system architecture |
75 | HOST_CPU ?= $(shell uname -m) |
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 | NO_ASM := 1 |
98 | $(warning Architecture "$(HOST_CPU)" not officially supported.') |
99 | endif |
100 | ifneq ("$(filter ppc64 powerpc64,$(HOST_CPU))","") |
101 | CPU := PPC |
102 | ARCH_DETECTED := 64BITS |
103 | BIG_ENDIAN := 1 |
104 | PIC ?= 1 |
105 | NO_ASM := 1 |
106 | $(warning Architecture "$(HOST_CPU)" not officially supported.') |
107 | endif |
108 | ifneq ("$(filter arm%,$(HOST_CPU))","") |
109 | ifeq ("$(filter arm%b,$(HOST_CPU))","") |
110 | CPU := ARM |
111 | ARCH_DETECTED := 32BITS |
112 | PIC ?= 1 |
113 | POSTFIX ?= es1 |
114 | NO_ASM := 1 |
115 | CFLAGS += -mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp -mtune=cortex-a8 -fsigned-char -ffast-math -fpermissive |
116 | CFLAGS += -DANDROID |
117 | CFLAGS += -DPAULSCODE |
118 | CFLAGS += -DHAVE_GLES |
119 | $(warning Architecture "$(HOST_CPU)" not officially supported.') |
120 | endif |
121 | endif |
122 | ifeq ("$(CPU)","NONE") |
123 | $(error CPU type "$(HOST_CPU)" not supported. Please file bug report at 'http://code.google.com/p/mupen64plus/issues') |
124 | endif |
125 | |
126 | # base CFLAGS, LDLIBS, and LDFLAGS |
2d262872 |
127 | OPTFLAGS ?= -O3 |
128 | #-flto -fuse-linker-plugin |
d07c171f |
129 | WARNFLAGS ?= -Wall |
130 | CFLAGS += $(OPTFLAGS) $(WARNFLAGS) -ffast-math -fno-strict-aliasing -fvisibility=hidden -I../../src |
131 | CXXFLAGS += -fvisibility-inlines-hidden |
132 | LDFLAGS += $(SHARED) |
133 | |
134 | ifeq ($(CPU), X86) |
135 | CFLAGS += -msse |
136 | endif |
137 | |
138 | # Since we are building a shared library, we must compile with -fPIC on some architectures |
139 | # 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 |
140 | ifeq ($(PIC), 1) |
141 | CFLAGS += -fPIC |
142 | else |
143 | CFLAGS += -fno-PIC |
144 | endif |
145 | |
146 | ifeq ($(BIG_ENDIAN), 1) |
147 | CFLAGS += -DM64P_BIG_ENDIAN |
148 | endif |
149 | |
150 | # tweak flags for 32-bit build on 64-bit system |
151 | ifeq ($(ARCH_DETECTED), 64BITS_32) |
152 | ifeq ($(OS), FREEBSD) |
153 | $(error Do not use the BITS=32 option with FreeBSD, use -m32 and -m elf_i386) |
154 | endif |
155 | CFLAGS += -m32 |
156 | LDFLAGS += -Wl,-m,elf_i386 |
157 | endif |
158 | |
159 | # set special flags per-system |
160 | ifeq ($(OS), LINUX) |
161 | LDLIBS += -ldl |
162 | # only export api symbols |
163 | LDFLAGS += -Wl,-version-script,$(SRCDIR)/video_api_export.ver |
164 | endif |
165 | ifeq ($(OS), OSX) |
166 | # Select the proper SDK |
167 | # Also, SDKs are stored in a different location since XCode 4.3 |
168 | OSX_SDK ?= $(shell sw_vers -productVersion | cut -f1 -f2 -d .) |
169 | OSX_XCODEMAJ = $(shell xcodebuild -version | grep '[0-9]*\.[0-9]*' | cut -f2 -d ' ' | cut -f1 -d .) |
170 | OSX_XCODEMIN = $(shell xcodebuild -version | grep '[0-9]*\.[0-9]*' | cut -f2 -d ' ' | cut -f2 -d .) |
171 | OSX_XCODEGE43 = $(shell echo "`expr $(OSX_XCODEMAJ) \>= 4``expr $(OSX_XCODEMIN) \>= 3`") |
172 | ifeq ($(OSX_XCODEGE43), 11) |
173 | OSX_SYSROOT := /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs |
174 | else |
175 | OSX_SYSROOT := /Developer/SDKs |
176 | endif |
177 | |
178 | ifeq ($(CPU), X86) |
179 | ifeq ($(ARCH_DETECTED), 64BITS) |
180 | CFLAGS += -pipe -arch x86_64 -mmacosx-version-min=$(OSX_SDK) -isysroot $(OSX_SYSROOT)/MacOSX$(OSX_SDK).sdk |
181 | LDFLAGS += -bundle |
182 | LDLIBS += -ldl |
183 | else |
184 | CFLAGS += -pipe -mmmx -msse -fomit-frame-pointer -arch i686 -mmacosx-version-min=$(OSX_SDK) -isysroot $(OSX_SYSROOT)/MacOSX$(OSX_SDK).sdk |
185 | LDFLAGS += -bundle |
186 | LDLIBS += -ldl |
187 | endif |
188 | endif |
189 | endif |
190 | |
191 | # test for essential build dependencies |
192 | ifeq ($(origin PKG_CONFIG), undefined) |
193 | PKG_CONFIG = $(CROSS_COMPILE)pkg-config |
194 | ifeq ($(shell which $(PKG_CONFIG) 2>/dev/null),) |
195 | $(error $(PKG_CONFIG) not found) |
196 | endif |
197 | endif |
198 | |
199 | ifeq ($(origin LIBPNG_CFLAGS) $(origin LIBPNG_LDLIBS), undefined undefined) |
200 | ifeq ($(shell $(PKG_CONFIG) --modversion libpng 2>/dev/null),) |
201 | $(error No libpng development libraries found!) |
202 | endif |
203 | LIBPNG_CFLAGS += $(shell $(PKG_CONFIG) --cflags libpng) |
204 | LIBPNG_LDLIBS += $(shell $(PKG_CONFIG) --libs libpng) |
205 | endif |
206 | CFLAGS += $(LIBPNG_CFLAGS) |
207 | LDLIBS += $(LIBPNG_LDLIBS) |
208 | |
209 | # search for OpenGL libraries |
210 | ifeq ($(OS), OSX) |
211 | GL_LDLIBS = -framework OpenGL |
212 | endif |
213 | ifeq ($(OS), MINGW) |
214 | GL_LDLIBS = -lopengl32 |
215 | endif |
216 | ifeq ($(origin GL_CFLAGS) $(origin GL_LDLIBS), undefined undefined) |
217 | ifeq ($(shell $(PKG_CONFIG) --modversion gl 2>/dev/null),) |
218 | $(error No OpenGL development libraries found!) |
219 | endif |
220 | # GL_CFLAGS += $(shell $(PKG_CONFIG) --cflags gl) |
221 | # GL_LDLIBS += $(shell $(PKG_CONFIG) --libs gl) |
222 | GL_CFLAGS += -I/mnt/utmp/codeblocks/usr/include/GLES |
223 | GL_LDLIBS += -lGLES_CM -lEGL -lrt |
224 | endif |
225 | CFLAGS += $(GL_CFLAGS) |
226 | LDLIBS += $(GL_LDLIBS) |
227 | |
228 | # test for presence of SDL |
229 | ifeq ($(origin SDL_CFLAGS) $(origin SDL_LDLIBS), undefined undefined) |
230 | SDL_CONFIG = $(CROSS_COMPILE)sdl-config |
231 | ifeq ($(shell which $(SDL_CONFIG) 2>/dev/null),) |
232 | $(error No SDL development libraries found!) |
233 | endif |
234 | SDL_CFLAGS += $(shell $(SDL_CONFIG) --cflags) |
235 | SDL_LDLIBS += $(shell $(SDL_CONFIG) --libs) |
236 | endif |
237 | CFLAGS += $(SDL_CFLAGS) |
238 | LDLIBS += $(SDL_LDLIBS) |
239 | |
240 | # set mupen64plus core API header path |
241 | ifneq ("$(APIDIR)","") |
242 | CFLAGS += "-I$(APIDIR)" |
243 | else |
244 | TRYDIR = ../../../mupen64plus-core/src/api |
245 | ifneq ("$(wildcard $(TRYDIR)/m64p_types.h)","") |
246 | CFLAGS += -I$(TRYDIR) |
247 | else |
248 | TRYDIR = /usr/local/include/mupen64plus |
249 | ifneq ("$(wildcard $(TRYDIR)/m64p_types.h)","") |
250 | CFLAGS += -I$(TRYDIR) |
251 | else |
252 | TRYDIR = /usr/include/mupen64plus |
253 | ifneq ("$(wildcard $(TRYDIR)/m64p_types.h)","") |
254 | CFLAGS += -I$(TRYDIR) |
255 | else |
256 | $(error Mupen64Plus API header files not found! Use makefile parameter APIDIR to force a location.) |
257 | endif |
258 | endif |
259 | endif |
260 | endif |
261 | |
262 | # reduced compile output when running make without V=1 |
263 | ifneq ($(findstring $(MAKEFLAGS),s),s) |
264 | ifndef V |
265 | Q_CC = @echo ' CC '$@; |
266 | Q_CXX = @echo ' CXX '$@; |
267 | Q_LD = @echo ' LD '$@; |
268 | endif |
269 | endif |
270 | |
271 | # set base program pointers and flags |
272 | CC = $(CROSS_COMPILE)gcc |
273 | CXX = $(CROSS_COMPILE)g++ |
274 | RM ?= rm -f |
275 | INSTALL ?= install |
276 | MKDIR ?= mkdir -p |
277 | COMPILE.c = $(Q_CC)$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c |
278 | COMPILE.cc = $(Q_CXX)$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c |
279 | LINK.o = $(Q_LD)$(CXX) $(CXXFLAGS) $(LDFLAGS) $(TARGET_ARCH) |
280 | |
281 | # set special flags for given Makefile parameters |
282 | ifeq ($(DEBUG),1) |
283 | CFLAGS += -g |
284 | INSTALL_STRIP_FLAG ?= |
285 | else |
286 | ifneq ($(OS),OSX) |
287 | INSTALL_STRIP_FLAG ?= -s |
288 | endif |
289 | endif |
290 | ifeq ($(NO_ASM), 1) |
291 | CFLAGS += -DNO_ASM |
292 | endif |
293 | |
294 | # set installation options |
295 | ifeq ($(PREFIX),) |
296 | PREFIX := /usr/local |
297 | endif |
298 | ifeq ($(SHAREDIR),) |
299 | SHAREDIR := $(PREFIX)/share/mupen64plus |
300 | endif |
301 | ifeq ($(LIBDIR),) |
302 | LIBDIR := $(PREFIX)/lib |
303 | endif |
304 | ifeq ($(PLUGINDIR),) |
305 | PLUGINDIR := $(LIBDIR)/mupen64plus |
306 | endif |
307 | |
308 | SRCDIR = ../../src |
309 | OBJDIR = _obj$(POSTFIX) |
310 | |
311 | # list of source files to compile |
312 | SOURCE = \ |
313 | $(SRCDIR)/Blender.cpp \ |
314 | $(SRCDIR)/Combiner.cpp \ |
315 | $(SRCDIR)/CombinerTable.cpp \ |
316 | $(SRCDIR)/Config.cpp \ |
317 | $(SRCDIR)/ConvertImage.cpp \ |
318 | $(SRCDIR)/ConvertImage16.cpp \ |
319 | $(SRCDIR)/Debugger.cpp \ |
320 | $(SRCDIR)/DecodedMux.cpp \ |
321 | $(SRCDIR)/DeviceBuilder.cpp \ |
322 | $(SRCDIR)/DirectXDecodedMux.cpp \ |
323 | $(SRCDIR)/FrameBuffer.cpp \ |
324 | $(SRCDIR)/GeneralCombiner.cpp \ |
325 | $(SRCDIR)/GraphicsContext.cpp \ |
326 | $(SRCDIR)/OGLCombiner.cpp \ |
327 | $(SRCDIR)/OGLExtensions.cpp \ |
328 | $(SRCDIR)/OGLDecodedMux.cpp \ |
329 | $(SRCDIR)/OGLExtCombiner.cpp \ |
330 | $(SRCDIR)/OGLExtRender.cpp \ |
331 | $(SRCDIR)/OGLGraphicsContext.cpp \ |
332 | $(SRCDIR)/OGLRender.cpp \ |
333 | $(SRCDIR)/OGLRenderExt.cpp \ |
334 | $(SRCDIR)/OGLTexture.cpp \ |
335 | $(SRCDIR)/Render.cpp \ |
336 | $(SRCDIR)/RenderBase.cpp \ |
337 | $(SRCDIR)/RenderExt.cpp \ |
338 | $(SRCDIR)/RenderTexture.cpp \ |
339 | $(SRCDIR)/RSP_Parser.cpp \ |
340 | $(SRCDIR)/RSP_S2DEX.cpp \ |
341 | $(SRCDIR)/Texture.cpp \ |
342 | $(SRCDIR)/TextureFilters.cpp \ |
343 | $(SRCDIR)/TextureFilters_2xsai.cpp \ |
344 | $(SRCDIR)/TextureFilters_hq2x.cpp \ |
345 | $(SRCDIR)/TextureFilters_hq4x.cpp \ |
346 | $(SRCDIR)/TextureManager.cpp \ |
347 | $(SRCDIR)/VectorMath.cpp \ |
348 | $(SRCDIR)/Video.cpp \ |
349 | $(SRCDIR)/liblinux/BMGImage.c \ |
350 | $(SRCDIR)/liblinux/BMGUtils.c \ |
351 | $(SRCDIR)/liblinux/bmp.c \ |
352 | $(SRCDIR)/liblinux/pngrw.c \ |
353 | $(SRCDIR)/eglport.c \ |
354 | |
355 | |
356 | ifeq ($(OS),MINGW) |
357 | SOURCE += \ |
358 | $(SRCDIR)/osal_dynamiclib_win32.c \ |
359 | $(SRCDIR)/osal_files_win32.c |
360 | else |
361 | SOURCE += \ |
362 | $(SRCDIR)/osal_dynamiclib_unix.c \ |
363 | $(SRCDIR)/osal_files_unix.c |
364 | endif |
365 | |
366 | # generate a list of object files build, make a temporary directory for them |
367 | OBJECTS := $(patsubst $(SRCDIR)/%.c, $(OBJDIR)/%.o, $(filter %.c, $(SOURCE))) |
368 | OBJECTS += $(patsubst $(SRCDIR)/%.cpp, $(OBJDIR)/%.o, $(filter %.cpp, $(SOURCE))) |
369 | OBJDIRS = $(dir $(OBJECTS)) |
370 | $(shell $(MKDIR) $(OBJDIRS)) |
371 | |
372 | # build targets |
373 | TARGET = mupen64plus-video-rice$(POSTFIX).$(SO_EXTENSION) |
374 | |
375 | targets: |
376 | @echo "Mupen64plus-video-rice N64 Graphics plugin makefile. " |
377 | @echo " Targets:" |
378 | @echo " all == Build Mupen64plus-video-rice plugin" |
379 | @echo " clean == remove object files" |
380 | @echo " rebuild == clean and re-build all" |
381 | @echo " install == Install Mupen64Plus-video-rice plugin" |
382 | @echo " uninstall == Uninstall Mupen64Plus-video-rice plugin" |
383 | @echo " Options:" |
384 | @echo " BITS=32 == build 32-bit binaries on 64-bit machine" |
385 | @echo " NO_ASM=1 == build without inline assembly code (x86 MMX/SSE)" |
386 | @echo " APIDIR=path == path to find Mupen64Plus Core headers" |
387 | @echo " OPTFLAGS=flag == compiler optimization (default: -O3 -flto)" |
388 | @echo " WARNFLAGS=flag == compiler warning levels (default: -Wall)" |
389 | @echo " PIC=(1|0) == Force enable/disable of position independent code" |
390 | @echo " POSTFIX=name == String added to the name of the the build (default: '')" |
391 | @echo " Install Options:" |
392 | @echo " PREFIX=path == install/uninstall prefix (default: /usr/local)" |
393 | @echo " SHAREDIR=path == path to install shared data files (default: PREFIX/share/mupen64plus)" |
394 | @echo " LIBDIR=path == library prefix (default: PREFIX/lib)" |
395 | @echo " PLUGINDIR=path == path to install plugin libraries (default: LIBDIR/mupen64plus)" |
396 | @echo " DESTDIR=path == path to prepend to all installation paths (only for packagers)" |
397 | @echo " Debugging Options:" |
398 | @echo " DEBUG=1 == add debugging symbols" |
399 | @echo " V=1 == show verbose compiler output" |
400 | |
401 | all: $(TARGET) |
402 | |
403 | install: $(TARGET) |
404 | $(INSTALL) -d "$(DESTDIR)$(PLUGINDIR)" |
405 | $(INSTALL) -m 0644 $(INSTALL_STRIP_FLAG) $(TARGET) "$(DESTDIR)$(PLUGINDIR)" |
406 | $(INSTALL) -d "$(DESTDIR)$(SHAREDIR)" |
407 | $(INSTALL) -m 0644 "../../data/RiceVideoLinux.ini" "$(DESTDIR)$(SHAREDIR)" |
408 | |
409 | uninstall: |
410 | $(RM) "$(DESTDIR)$(PLUGINDIR)/$(TARGET)" |
411 | $(RM) "$(DESTDIR)$(SHAREDIR)/RiceVideoLinux.ini" |
412 | |
413 | clean: |
414 | $(RM) -r $(OBJDIR) $(TARGET) |
415 | |
416 | rebuild: clean all |
417 | |
418 | # build dependency files |
419 | CFLAGS += -MD |
420 | -include $(OBJECTS:.o=.d) |
421 | |
422 | CXXFLAGS += $(CFLAGS) |
423 | |
424 | # standard build rules |
425 | $(OBJDIR)/%.o: $(SRCDIR)/%.c |
426 | $(COMPILE.c) -o $@ $< |
427 | |
428 | $(OBJDIR)/%.o: $(SRCDIR)/%.cpp |
429 | $(COMPILE.cc) -o $@ $< |
430 | |
431 | $(TARGET): $(OBJECTS) |
432 | $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@ |
433 | |
434 | .PHONY: all clean install uninstall targets |