1 #/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2 # * Arachnoid - Makefile *
3 # * http://bitbucket.org/wahrhaft/mupen64plus-video-arachnoid/ *
4 # * Copyright (C) 2009 Richard42, Jon Ring *
6 # * This program is free software; you can redistribute it and/or modify *
7 # * it under the terms of the GNU General Public License as published by *
8 # * the Free Software Foundation; either version 2 of the License, or *
9 # * (at your option) any later version. *
11 # * This program is distributed in the hope that it will be useful, *
12 # * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 # * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 # * GNU General Public License for more details. *
16 # * You should have received a copy of the GNU General Public License *
17 # * along with this program; if not, write to the *
18 # * Free Software Foundation, Inc., *
19 # * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
20 # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
21 # Makefile for mupen64plus-video-arachnoid
23 # detect operation system
24 UNAME ?= $(shell uname -s)
25 ifeq ("$(UNAME)","Linux")
30 ifeq ("$(UNAME)","linux")
35 ifneq ("$(filter GNU hurd,$(UNAME))","")
40 ifeq ("$(UNAME)","Darwin")
42 LDLIBS += -liconv -lpng
46 ifeq ("$(UNAME)","FreeBSD")
51 ifeq ("$(UNAME)","OpenBSD")
55 $(warning OS type "$(UNAME)" not officially supported.')
57 ifneq ("$(filter GNU/kFreeBSD kfreebsd,$(UNAME))","")
62 ifeq ("$(patsubst MINGW%,MINGW,$(UNAME))","MINGW")
69 $(error OS type "$(UNAME)" not supported. Please file bug report at 'http://code.google.com/p/mupen64plus/issues')
72 # detect system architecture
73 HOST_CPU ?= $(shell uname -m)
75 ifneq ("$(filter x86_64 amd64,$(HOST_CPU))","")
77 ifeq ("$(BITS)", "32")
78 ARCH_DETECTED := 64BITS_32
80 ARCH_DETECTED := 64BITS
84 ifneq ("$(filter pentium i%86,$(HOST_CPU))","")
86 ARCH_DETECTED := 32BITS
88 ifneq ("$(filter ppc macppc socppc powerpc,$(HOST_CPU))","")
90 ARCH_DETECTED := 32BITS
93 $(warning Architecture "$(HOST_CPU)" not officially supported.')
95 ifneq ("$(filter ppc64 powerpc64,$(HOST_CPU))","")
97 ARCH_DETECTED := 64BITS
100 $(warning Architecture "$(HOST_CPU)" not officially supported.')
102 ifneq ("$(filter arm%,$(HOST_CPU))","")
103 ifeq ("$(filter arm%b,$(HOST_CPU))","")
105 ARCH_DETECTED := 32BITS
107 CFLAGS += -mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp -mtune=cortex-a8 -fsigned-char -ffast-math -fpermissive
108 CFLAGS += -DHAVE_GLES
109 $(warning Architecture "$(HOST_CPU)" not officially supported.')
113 # base CFLAGS, LDLIBS, and LDFLAGS
116 CFLAGS += $(OPTFLAGS) $(WARNFLAGS) -ffast-math -fno-strict-aliasing -fvisibility=hidden -I../../src \
117 -I../../src/hash -I../../src/ucodes -I../../src/GBI -I../../src/RDP -I../../src/utils \
118 -I../../src/log -I../../src/RSP -I../../src/framebuffer -I../../src/math -I../../src/renderer \
119 -I../../src/Assembler -I../../src/texture -I../../src/config -I../../src/Combiner
120 CXXFLAGS += -fvisibility-inlines-hidden
123 # On OS X, add a few extra flags to elegantly support cross-compilation and backward
124 # compatibility (and also the flags to link against OpenGL)
126 # Select the proper SDK
127 # Also, SDKs are stored in a different location since XCode 4.3
128 OSX_SDK ?= $(shell sw_vers -productVersion | cut -f1 -f2 -d .)
129 OSX_XCODEMAJ = $(shell xcodebuild -version | grep '[0-9]*\.[0-9]*' | cut -f2 -d ' ' | cut -f1 -d .)
130 OSX_XCODEMIN = $(shell xcodebuild -version | grep '[0-9]*\.[0-9]*' | cut -f2 -d ' ' | cut -f2 -d .)
131 OSX_XCODEGE43 = $(shell echo "`expr $(OSX_XCODEMAJ) \>= 4``expr $(OSX_XCODEMIN) \>= 3`")
132 ifeq ($(OSX_XCODEGE43), 11)
133 OSX_SYSROOT := /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs
135 OSX_SYSROOT := /Developer/SDKs
139 ifeq ($(ARCH_DETECTED), 64BITS)
140 CFLAGS += -arch x86_64 -mmacosx-version-min=$(OSX_SDK) -isysroot $(OSX_SYSROOT)/MacOSX$(OSX_SDK).sdk
143 CFLAGS += -arch i686 -mmacosx-version-min=$(OSX_SDK) -isysroot $(OSX_SYSROOT)/MacOSX$(OSX_SDK).sdk
148 # search for OpenGL libraries
150 GL_LDLIBS = -framework OpenGL
153 GL_LDLIBS = -lopengl32
156 ifeq ($(origin GL_CFLAGS) $(origin GL_LDLIBS), undefined undefined)
157 ifeq ($(origin PKG_CONFIG), undefined)
158 PKG_CONFIG = $(CROSS_COMPILE)pkg-config
159 ifeq ($(shell which $(PKG_CONFIG) 2>/dev/null),)
160 $(error $(PKG_CONFIG) not found)
164 ifeq ($(shell $(PKG_CONFIG) --modversion gl 2>/dev/null),)
165 $(error No OpenGL development libraries found!)
167 #GL_CFLAGS += $(shell $(PKG_CONFIG) --cflags gl)
168 #GL_LDLIBS += $(shell $(PKG_CONFIG) --libs gl)
169 GL_CFLAGS += $(shell sdl-config --cflags)
170 GL_LDLIBS += $(shell sdl-config --libs)
171 GL_CFLAGS += -I/mnt/utmp/codeblocks/usr/include/GLES
172 GL_LDLIBS += -lGLES_CM -lEGL -lrt
174 CFLAGS += $(GL_CFLAGS)
175 LDLIBS += $(GL_LDLIBS)
182 ifeq ($(OS), FREEBSD)
187 # Since we are building a shared library, we must compile with -fPIC on some architectures
188 # 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
195 ifeq ($(BIG_ENDIAN), 1)
196 CFLAGS += -DM64P_BIG_ENDIAN
199 # set mupen64plus core API header path
200 ifneq ("$(APIDIR)","")
201 CFLAGS += "-I$(APIDIR)"
203 TRYDIR = ../../../mupen64plus-core/src/api
204 ifneq ("$(wildcard $(TRYDIR)/m64p_types.h)","")
205 CFLAGS += -I$(TRYDIR)
207 TRYDIR = /usr/local/include/mupen64plus
208 ifneq ("$(wildcard $(TRYDIR)/m64p_types.h)","")
209 CFLAGS += -I$(TRYDIR)
211 TRYDIR = /usr/include/mupen64plus
212 ifneq ("$(wildcard $(TRYDIR)/m64p_types.h)","")
213 CFLAGS += -I$(TRYDIR)
219 # set special flags per-system
221 # only export api symbols
222 LDFLAGS += -Wl,-version-script,$(SRCDIR)/video_api_export.ver
224 ifneq ($(OS), FREEBSD)
226 # tweak flags for 32-bit build on 64-bit system
227 ifeq ($(ARCH_DETECTED), 64BITS_32)
229 LDFLAGS += -Wl,-m,elf_i386
233 ifeq ($(ARCH_DETECTED), 64BITS_32)
234 $(error Do not use the BITS=32 option with FreeBSD, use -m32 and -m elf_i386)
238 # reduced compile output when running make without V=1
239 ifneq ($(findstring $(MAKEFLAGS),s),s)
241 Q_CC = @echo ' CC '$@;
242 Q_CXX = @echo ' CXX '$@;
243 Q_LD = @echo ' LD '$@;
247 # set base program pointers and flags
248 CC = $(CROSS_COMPILE)gcc
249 CXX = $(CROSS_COMPILE)g++
253 COMPILE.c = $(Q_CC)$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c
254 COMPILE.cc = $(Q_CXX)$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c
255 LINK.o = $(Q_LD)$(CXX) $(CXXFLAGS) $(LDFLAGS) $(TARGET_ARCH)
257 # set special flags for given Makefile parameters
260 INSTALL_STRIP_FLAG ?=
262 INSTALL_STRIP_FLAG ?= -s
265 # set installation options
270 SHAREDIR := $(PREFIX)/share/mupen64plus
273 LIBDIR := $(PREFIX)/lib
276 PLUGINDIR := $(LIBDIR)/mupen64plus
281 OBJDIR = _obj$(POSTFIX)
283 # list of source files to compile
286 $(SRCDIR)/log/Logger.cpp \
287 $(SRCDIR)/config/Config.cpp \
288 $(SRCDIR)/config/StringFunctions.cpp \
289 $(SRCDIR)/GraphicsPlugin.cpp \
290 $(SRCDIR)/OpenGLManager.cpp \
291 $(SRCDIR)/renderer/OpenGLRenderer.cpp \
292 $(SRCDIR)/framebuffer/FrameBuffer.cpp \
293 $(SRCDIR)/FogManager.cpp \
294 $(SRCDIR)/MultiTexturingExt.cpp \
295 $(SRCDIR)/ExtensionChecker.cpp \
296 $(SRCDIR)/SecondaryColorExt.cpp \
297 $(SRCDIR)/Memory.cpp \
298 $(SRCDIR)/math/Matrix4.cpp \
299 $(SRCDIR)/texture/CachedTexture.cpp \
300 $(SRCDIR)/texture/TextureCache.cpp \
301 $(SRCDIR)/texture/ImageFormatSelector.cpp \
302 $(SRCDIR)/hash/CRCCalculator.cpp \
303 $(SRCDIR)/hash/CRCCalculator2.cpp \
304 $(SRCDIR)/texture/TextureLoader.cpp \
305 $(SRCDIR)/DisplayListParser.cpp \
307 $(SRCDIR)/ucodes/UCodeSelector.cpp \
308 $(SRCDIR)/ucodes/UCode0.cpp \
309 $(SRCDIR)/ucodes/UCode1.cpp \
310 $(SRCDIR)/ucodes/UCode2.cpp \
311 $(SRCDIR)/ucodes/UCode3.cpp \
312 $(SRCDIR)/ucodes/UCode4.cpp \
313 $(SRCDIR)/ucodes/UCode5.cpp \
314 $(SRCDIR)/ucodes/UCode6.cpp \
315 $(SRCDIR)/ucodes/UCode7.cpp \
316 $(SRCDIR)/ucodes/UCode8.cpp \
317 $(SRCDIR)/ucodes/UCode9.cpp \
318 $(SRCDIR)/ucodes/UCode10.cpp \
319 $(SRCDIR)/GBI/GBI.cpp \
320 $(SRCDIR)/RSP/RSP.cpp \
321 $(SRCDIR)/RSP/RSPMatrixManager.cpp \
322 $(SRCDIR)/RSP/RSPVertexManager.cpp \
323 $(SRCDIR)/RSP/RSPLightManager.cpp \
324 $(SRCDIR)/Combiner/AdvancedCombinerManager.cpp \
325 $(SRCDIR)/Combiner/CombinerBase.cpp \
326 $(SRCDIR)/Combiner/AdvancedTexEnvCombiner.cpp \
327 $(SRCDIR)/Combiner/SimpleTexEnvCombiner.cpp \
328 $(SRCDIR)/Combiner/DummyCombiner.cpp \
329 $(SRCDIR)/Combiner/CombinerStageMerger.cpp \
330 $(SRCDIR)/Combiner/CombinerStageCreator.cpp \
331 $(SRCDIR)/Combiner/CombinerCache.cpp \
332 $(SRCDIR)/RomDetector.cpp \
333 $(SRCDIR)/RDP/RDP.cpp \
334 $(SRCDIR)/RDP/RDPInstructions.cpp \
335 $(SRCDIR)/renderer/eglport.cpp \
336 $(SRCDIR)/renderer/OpenGL2DRenderer.cpp \
339 SOURCE += $(SRCDIR)/osal_dynamiclib_win32.cpp
341 SOURCE += $(SRCDIR)/osal_dynamiclib_unix.cpp
345 # generate a list of object files build, make a temporary directory for them
346 OBJECTS := $(patsubst $(SRCDIR)/%.cpp, $(OBJDIR)/%.o, $(filter %.cpp, $(SOURCE)))
347 OBJDIRS = $(dir $(OBJECTS))
348 $(shell $(MKDIR) $(OBJDIRS))
352 TARGET = mupen64plus-video-arachnoid$(POSTFIX).$(SO_EXTENSION)
354 @echo "Mupen64plus-video-arachnoid N64 Graphics plugin makefile. "
356 @echo " all == Build Mupen64plus-video-arachnoid plugin"
357 @echo " clean == remove object files"
358 @echo " rebuild == clean and re-build all"
359 @echo " install == Install Mupen64Plus-video-arachnoid plugin"
360 @echo " uninstall == Uninstall Mupen64Plus-video-arachnoid plugin"
362 @echo " BITS=32 == build 32-bit binaries on 64-bit machine"
363 @echo " APIDIR=path == path to find Mupen64Plus Core headers"
364 @echo " OPTFLAGS=flag == compiler optimization (default: -O3 -flto)"
365 @echo " WARNFLAGS=flag == compiler warning levels (default: -Wall)"
366 @echo " PIC=(1|0) == Force enable/disable of position independent code"
367 @echo " POSTFIX=name == String added to the name of the the build (default: '')"
368 @echo " Install Options:"
369 @echo " PREFIX=path == install/uninstall prefix (default: /usr/local)"
370 @echo " LIBDIR=path == library prefix (default: PREFIX/lib)"
371 @echo " PLUGINDIR=path == path to install plugin libraries (default: LIBDIR/mupen64plus)"
372 @echo " DESTDIR=path == path to prepend to all installation paths (only for packagers)"
373 @echo " Debugging Options:"
374 @echo " DEBUG=1 == add debugging symbols"
375 @echo " V=1 == show verbose compiler output"
380 $(INSTALL) -d "$(DESTDIR)$(PLUGINDIR)"
381 $(INSTALL) -m 0644 $(INSTALL_STRIP_FLAG) $(TARGET) "$(DESTDIR)$(PLUGINDIR)"
384 $(RM) "$(DESTDIR)$(PLUGINDIR)/$(TARGET)"
388 $(RM) -r $(OBJDIR) $(TARGET)
390 # build dependency files
392 -include $(OBJECTS:.o=.d)
394 CXXFLAGS += $(CFLAGS)
396 # standard build rules
397 $(OBJDIR)/%.o: $(SRCDIR)/%.c
398 $(COMPILE.c) -o $@ $<
400 $(OBJDIR)/%.o: $(SRCDIR)/%.cpp
401 $(COMPILE.cc) -o $@ $<
403 $(TARGET): $(OBJECTS)
404 $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@
406 .PHONY: all clean install uninstall targets