1 #/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2 # * Mupen64plus-input-sdl - Makefile *
3 # * Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ *
4 # * Copyright (C) 2007-2009 Richard Goedeken *
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 SDL Input plugin in Mupen64plus
23 # detect operating system
24 UNAME ?= $(shell uname -s)
26 ifeq ("$(UNAME)","Linux")
31 ifeq ("$(UNAME)","linux")
36 ifneq ("$(filter GNU hurd,$(UNAME))","")
41 ifeq ("$(UNAME)","Darwin")
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)
76 ifneq ("$(filter x86_64 amd64,$(HOST_CPU))","")
78 ifeq ("$(BITS)", "32")
79 ARCH_DETECTED := 64BITS_32
82 ARCH_DETECTED := 64BITS
86 ifneq ("$(filter pentium i%86,$(HOST_CPU))","")
88 ARCH_DETECTED := 32BITS
91 ifneq ("$(filter ppc macppc socppc powerpc,$(HOST_CPU))","")
93 ARCH_DETECTED := 32BITS
96 $(warning Architecture "$(HOST_CPU)" not officially supported.')
98 ifneq ("$(filter ppc64 powerpc64,$(HOST_CPU))","")
100 ARCH_DETECTED := 64BITS
103 $(warning Architecture "$(HOST_CPU)" not officially supported.')
105 ifneq ("$(filter arm%,$(HOST_CPU))","")
106 ifeq ("$(filter arm%b,$(HOST_CPU))","")
108 ARCH_DETECTED := 32BITS
110 CFLAGS += -mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp -mtune=cortex-a8 -fsigned-char
111 $(warning Architecture "$(HOST_CPU)" not officially supported.')
114 ifeq ("$(CPU)","NONE")
115 $(error CPU type "$(HOST_CPU)" not supported. Please file bug report at 'http://code.google.com/p/mupen64plus/issues')
118 # base CFLAGS, LDLIBS, and LDFLAGS
121 CFLAGS += $(OPTFLAGS) $(WARNFLAGS) -ffast-math -fno-strict-aliasing -fvisibility=hidden -I../../src -D_GNU_SOURCE=1
124 # Since we are building a shared library, we must compile with -fPIC on some architectures
125 # 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
132 ifeq ($(BIG_ENDIAN), 1)
133 CFLAGS += -DM64P_BIG_ENDIAN
136 # tweak flags for 32-bit build on 64-bit system
137 ifeq ($(ARCH_DETECTED), 64BITS_32)
139 LDFLAGS += -Wl,-m,elf_i386
142 # set special flags per-system
143 ifeq ($(OS), FREEBSD)
144 ifeq ($(ARCH_DETECTED), 64BITS_32)
145 $(error Do not use the BITS=32 option with FreeBSD, use -m32 and -m elf_i386)
152 # Select the proper SDK
153 # Also, SDKs are stored in a different location since XCode 4.3
154 OSX_SDK ?= $(shell sw_vers -productVersion | cut -f1 -f2 -d .)
155 OSX_XCODEMAJ = $(shell xcodebuild -version | grep '[0-9]*\.[0-9]*' | cut -f2 -d ' ' | cut -f1 -d .)
156 OSX_XCODEMIN = $(shell xcodebuild -version | grep '[0-9]*\.[0-9]*' | cut -f2 -d ' ' | cut -f2 -d .)
157 OSX_XCODEGE43 = $(shell echo "`expr $(OSX_XCODEMAJ) \>= 4``expr $(OSX_XCODEMIN) \>= 3`")
158 ifeq ($(OSX_XCODEGE43), 11)
159 OSX_SYSROOT := /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs
161 OSX_SYSROOT := /Developer/SDKs
165 ifeq ($(ARCH_DETECTED), 64BITS)
166 CFLAGS += -arch x86_64 -mmacosx-version-min=$(OSX_SDK) -isysroot $(OSX_SYSROOT)/MacOSX$(OSX_SDK).sdk
169 CFLAGS += -mmmx -msse -fomit-frame-pointer -arch i686 -mmacosx-version-min=$(OSX_SDK) -isysroot $(OSX_SYSROOT)/MacOSX$(OSX_SDK).sdk
170 LDLIBS += -ldl -read_only_relocs suppress
175 # test for presence of SDL
176 ifeq ($(origin SDL_CFLAGS) $(origin SDL_LDLIBS), undefined undefined)
177 SDL_CONFIG = $(CROSS_COMPILE)sdl-config
178 ifeq ($(shell which $(SDL_CONFIG) 2>/dev/null),)
179 $(error No SDL development libraries found!)
181 SDL_CFLAGS += $(shell $(SDL_CONFIG) --cflags)
182 SDL_LDLIBS += $(shell $(SDL_CONFIG) --libs)
184 CFLAGS += $(SDL_CFLAGS)
185 LDLIBS += $(SDL_LDLIBS)
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_LD = @echo ' LD '$@;
217 # set base program pointers and flags
218 CC = $(CROSS_COMPILE)gcc
219 CXX = $(CROSS_COMPILE)g++
223 COMPILE.c = $(Q_CC)$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c
224 LINK.o = $(Q_LD)$(CC) $(CFLAGS) $(LDFLAGS) $(TARGET_ARCH)
226 # set special flags for given Makefile parameters
229 INSTALL_STRIP_FLAG ?=
232 INSTALL_STRIP_FLAG ?= -s
235 ifeq ($(PLUGINDBG), 1)
239 # set installation options
244 SHAREDIR := $(PREFIX)/share/mupen64plus
247 LIBDIR := $(PREFIX)/lib
250 PLUGINDIR := $(LIBDIR)/mupen64plus
254 OBJDIR = _obj$(POSTFIX)
256 # list of source files to compile
259 $(SRCDIR)/autoconfig.c \
263 SOURCE += $(SRCDIR)/osal_dynamiclib_win32.c
265 SOURCE += $(SRCDIR)/osal_dynamiclib_unix.c
268 # generate a list of object files build, make a temporary directory for them
269 OBJECTS := $(patsubst $(SRCDIR)/%.c, $(OBJDIR)/%.o, $(filter %.c, $(SOURCE)))
270 OBJDIRS = $(dir $(OBJECTS))
271 $(shell $(MKDIR) $(OBJDIRS))
274 TARGET = mupen64plus-input-sdl$(POSTFIX).$(SO_EXTENSION)
277 @echo "Mupen64Plus-input-sdl makefile. "
279 @echo " all == Build Mupen64Plus SDL input plugin"
280 @echo " clean == remove object files"
281 @echo " rebuild == clean and re-build all"
282 @echo " install == Install Mupen64Plus SDL input plugin"
283 @echo " uninstall == Uninstall Mupen64Plus SDL input plugin"
285 @echo " BITS=32 == build 32-bit binaries on 64-bit machine"
286 @echo " APIDIR=path == path to find Mupen64Plus Core headers"
287 @echo " OPTFLAGS=flag == compiler optimization (default: -O3 -flto)"
288 @echo " WARNFLAGS=flag == compiler warning levels (default: -Wall)"
289 @echo " PIC=(1|0) == Force enable/disable of position independent code"
290 @echo " POSTFIX=name == String added to the name of the the build (default: '')"
291 @echo " Install Options:"
292 @echo " PREFIX=path == install/uninstall prefix (default: /usr/local)"
293 @echo " SHAREDIR=path == path to install shared data files (default: PREFIX/share/mupen64plus)"
294 @echo " LIBDIR=path == library prefix (default: PREFIX/lib)"
295 @echo " PLUGINDIR=path == path to install plugin libraries (default: LIBDIR/mupen64plus)"
296 @echo " DESTDIR=path == path to prepend to all installation paths (only for packagers)"
297 @echo " Debugging Options:"
298 @echo " DEBUG=1 == add debugging symbols"
299 @echo " PLUGINDBG=1 == print extra debugging information while running"
300 @echo " V=1 == show verbose compiler output"
305 $(INSTALL) -d "$(DESTDIR)$(PLUGINDIR)"
306 $(INSTALL) -m 0644 $(INSTALL_STRIP_FLAG) $(TARGET) "$(DESTDIR)$(PLUGINDIR)"
307 $(INSTALL) -d "$(DESTDIR)$(SHAREDIR)"
308 $(INSTALL) -m 0644 "../../data/InputAutoCfg.ini" "$(DESTDIR)$(SHAREDIR)"
311 $(RM) "$(DESTDIR)$(PLUGINDIR)/$(TARGET)"
312 $(RM) "$(DESTDIR)$(SHAREDIR)/InputAutoCfg.ini"
315 $(RM) -r $(OBJDIR) $(TARGET)
319 # build dependency files
321 -include $(OBJECTS:.o=.d)
323 # standard build rules
324 $(OBJDIR)/%.o: $(SRCDIR)/%.c
325 $(COMPILE.c) -o $@ $<
327 $(TARGET): $(OBJECTS)
328 $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@
330 .PHONY: all clean install uninstall targets