1 #/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2 # * mupen64plus-rsp-z64 - Makefile *
3 # * http://bitbucket.org/wahrhaft/mupen64plus-rsp-z64/ *
4 # * Copyright (C) 2010 Jon Ring *
5 # * Copyright (C) 2008-2009 Richard Goedeken *
6 # * Copyright (C) 2007-2008 DarkJeztr Tillin9 *
8 # * This program is free software; you can redistribute it and/or modify *
9 # * it under the terms of the GNU General Public License as published by *
10 # * the Free Software Foundation; either version 2 of the License, or *
11 # * (at your option) any later version. *
13 # * This program is distributed in the hope that it will be useful, *
14 # * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 # * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 # * GNU General Public License for more details. *
18 # * You should have received a copy of the GNU General Public License *
19 # * along with this program; if not, write to the *
20 # * Free Software Foundation, Inc., *
21 # * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
22 # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
23 # Makefile for Z64 RSP plugin in Mupen64plus.
25 # detect operating system
26 UNAME ?= $(shell uname -s)
28 ifeq ("$(UNAME)","Linux")
33 ifeq ("$(UNAME)","linux")
38 ifneq ("$(filter GNU hurd,$(UNAME))","")
43 ifeq ("$(UNAME)","Darwin")
48 ifeq ("$(UNAME)","FreeBSD")
53 ifeq ("$(UNAME)","OpenBSD")
57 $(warning OS type "$(UNAME)" not officially supported.')
59 ifneq ("$(filter GNU/kFreeBSD kfreebsd,$(UNAME))","")
64 ifeq ("$(patsubst MINGW%,MINGW,$(UNAME))","MINGW")
71 $(error OS type "$(UNAME)" not supported. Please file bug report at 'http://code.google.com/p/mupen64plus/issues')
74 # detect system architecture
75 HOST_CPU ?= $(shell uname -m)
78 ifneq ("$(filter x86_64 amd64,$(HOST_CPU))","")
80 ifeq ("$(BITS)", "32")
81 ARCH_DETECTED := 64BITS_32
84 ARCH_DETECTED := 64BITS
88 ifneq ("$(filter pentium i%86,$(HOST_CPU))","")
90 ARCH_DETECTED := 32BITS
93 ifneq ("$(filter ppc macppc socppc powerpc,$(HOST_CPU))","")
95 ARCH_DETECTED := 32BITS
98 $(warning Architecture "$(HOST_CPU)" not officially supported.')
100 ifneq ("$(filter ppc64 powerpc64,$(HOST_CPU))","")
102 ARCH_DETECTED := 64BITS
105 $(warning Architecture "$(HOST_CPU)" not officially supported.')
107 ifneq ("$(filter arm%,$(HOST_CPU))","")
108 ifeq ("$(filter arm%b,$(HOST_CPU))","")
110 ARCH_DETECTED := 32BITS
113 CFLAGS += -mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp -mtune=cortex-a8 -fsigned-char
114 $(warning Architecture "$(HOST_CPU)" not officially supported.')
117 ifeq ("$(CPU)","NONE")
118 $(error CPU type "$(HOST_CPU)" not supported. Please file bug report at 'http://code.google.com/p/mupen64plus/issues')
121 # base CFLAGS, LDLIBS, and LDFLAGS
122 OPTFLAGS ?= -O3 -flto
124 CFLAGS += $(OPTFLAGS) $(WARNFLAGS) -ffast-math -fno-strict-aliasing -fvisibility=hidden -I../../src
125 CXXFLAGS += -fvisibility-inlines-hidden
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
136 ifeq ($(HLEVIDEO), 1)
137 CFLAGS += -DVIDEO_HLE_ALLOWED
141 ifeq ($(BIG_ENDIAN), 1)
142 CFLAGS += -DM64P_BIG_ENDIAN
145 # tweak flags for 32-bit build on 64-bit system
146 ifeq ($(ARCH_DETECTED), 64BITS_32)
147 ifeq ($(OS), FREEBSD)
148 $(error Do not use the BITS=32 option with FreeBSD, use -m32 and -m elf_i386)
151 LDFLAGS += -Wl,-m,elf_i386
154 # set special flags per-system
156 # only export api symbols
157 LDFLAGS += -Wl,-version-script,$(SRCDIR)/rsp_api_export.ver
160 ifeq ($(OS), FREEBSD)
164 # Select the proper SDK
165 # Also, SDKs are stored in a different location since XCode 4.3
166 OSX_SDK ?= $(shell sw_vers -productVersion | cut -f1 -f2 -d .)
167 OSX_XCODEMAJ = $(shell xcodebuild -version | grep '[0-9]*\.[0-9]*' | cut -f2 -d ' ' | cut -f1 -d .)
168 OSX_XCODEMIN = $(shell xcodebuild -version | grep '[0-9]*\.[0-9]*' | cut -f2 -d ' ' | cut -f2 -d .)
169 OSX_XCODEGE43 = $(shell echo "`expr $(OSX_XCODEMAJ) \>= 4``expr $(OSX_XCODEMIN) \>= 3`")
170 ifeq ($(OSX_XCODEGE43), 11)
171 OSX_SYSROOT := /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs
173 OSX_SYSROOT := /Developer/SDKs
177 ifeq ($(ARCH_DETECTED), 64BITS)
178 CFLAGS += -pipe -arch x86_64 -mmacosx-version-min=$(OSX_SDK) -isysroot $(OSX_SYSROOT)/MacOSX$(OSX_SDK).sdk
181 CFLAGS += -pipe -mmmx -msse -fomit-frame-pointer -arch i686 -mmacosx-version-min=$(OSX_SDK) -isysroot $(OSX_SYSROOT)/MacOSX$(OSX_SDK).sdk
187 # set mupen64plus core API header path
188 ifneq ("$(APIDIR)","")
189 CFLAGS += "-I$(APIDIR)"
191 TRYDIR = ../../../mupen64plus-core/src/api
192 ifneq ("$(wildcard $(TRYDIR)/m64p_types.h)","")
193 CFLAGS += -I$(TRYDIR)
195 TRYDIR = /usr/local/include/mupen64plus
196 ifneq ("$(wildcard $(TRYDIR)/m64p_types.h)","")
197 CFLAGS += -I$(TRYDIR)
199 TRYDIR = /usr/include/mupen64plus
200 ifneq ("$(wildcard $(TRYDIR)/m64p_types.h)","")
201 CFLAGS += -I$(TRYDIR)
203 $(error Mupen64Plus API header files not found! Use makefile parameter APIDIR to force a location.)
209 # reduced compile output when running make without V=1
210 ifneq ($(findstring $(MAKEFLAGS),s),s)
212 Q_CC = @echo ' CC '$@;
213 Q_CXX = @echo ' CXX '$@;
214 Q_LD = @echo ' LD '$@;
218 # set base program pointers and flags
219 CC = $(CROSS_COMPILE)gcc
220 CXX = $(CROSS_COMPILE)g++
224 COMPILE.c = $(Q_CC)$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c
225 COMPILE.cc = $(Q_CXX)$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c
226 LINK.o = $(Q_LD)$(CXX) $(CXXFLAGS) $(LDFLAGS) $(TARGET_ARCH)
228 # set special flags for given Makefile parameters
231 INSTALL_STRIP_FLAG ?=
233 INSTALL_STRIP_FLAG ?= -s
236 # set installation options
241 LIBDIR := $(PREFIX)/lib
244 PLUGINDIR := $(LIBDIR)/mupen64plus
248 OBJDIR = _obj$(POSTFIX)
250 # list of source files to compile
253 $(SRCDIR)/rsp_opinfo.cpp \
254 $(SRCDIR)/rsp_recomp.cpp \
255 $(SRCDIR)/rsp_dasm.cpp \
256 $(SRCDIR)/main_rsp.cpp
258 # generate a list of object files build, make a temporary directory for them
259 OBJECTS := $(patsubst $(SRCDIR)/%.c, $(OBJDIR)/%.o, $(filter %.c, $(SOURCE)))
260 OBJECTS += $(patsubst $(SRCDIR)/%.cpp, $(OBJDIR)/%.o, $(filter %.cpp, $(SOURCE)))
261 OBJDIRS = $(dir $(OBJECTS))
262 $(shell $(MKDIR) $(OBJDIRS))
265 TARGET = mupen64plus-rsp-z64$(POSTFIX).$(SO_EXTENSION)
268 @echo "Mupen64Plus-rsp-z64 makefile. "
270 @echo " all == Build Mupen64Plus rsp-hle plugin"
271 @echo " clean == remove object files"
272 @echo " rebuild == clean and re-build all"
273 @echo " install == Install Mupen64Plus rsp-hle plugin"
274 @echo " uninstall == Uninstall Mupen64Plus rsp-hle plugin"
276 @echo " BITS=32 == build 32-bit binaries on 64-bit machine"
277 @echo " APIDIR=path == path to find Mupen64Plus Core headers"
278 @echo " OPTFLAGS=flag == compiler optimization (default: -O3 -flto)"
279 @echo " WARNFLAGS=flag == compiler warning levels (default: -Wall)"
280 @echo " PIC=(1|0) == Force enable/disable of position independent code"
281 @echo " HLEVIDEO=(1|0) == Move task of gfx emulation to a HLE video plugins"
282 @echo " POSTFIX=name == String added to the name of the the build (default: '')"
283 @echo " Install Options:"
284 @echo " PREFIX=path == install/uninstall prefix (default: /usr/local)"
285 @echo " LIBDIR=path == library prefix (default: PREFIX/lib)"
286 @echo " PLUGINDIR=path == path to install plugin libraries (default: LIBDIR/mupen64plus)"
287 @echo " DESTDIR=path == path to prepend to all installation paths (only for packagers)"
288 @echo " Debugging Options:"
289 @echo " DEBUG=1 == add debugging symbols"
290 @echo " V=1 == show verbose compiler output"
295 $(INSTALL) -d "$(DESTDIR)$(PLUGINDIR)"
296 $(INSTALL) -m 0644 $(INSTALL_STRIP_FLAG) $(TARGET) "$(DESTDIR)$(PLUGINDIR)"
299 $(RM) "$(DESTDIR)$(PLUGINDIR)/$(TARGET)"
302 $(RM) -r $(OBJDIR) $(TARGET)
306 # build dependency files
308 -include $(OBJECTS:.o=.d)
310 CXXFLAGS += $(CFLAGS)
312 # standard build rules
313 $(OBJDIR)/%.o: $(SRCDIR)/%.c
314 $(COMPILE.c) -o $@ $<
316 $(OBJDIR)/%.o: $(SRCDIR)/%.cpp
317 $(COMPILE.cc) -o $@ $<
319 $(TARGET): $(OBJECTS)
320 $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@
322 .PHONY: all clean install uninstall targets