51
ifeq ("$(UNAME)","OpenBSD")
55
$(warning OS type "$(UNAME)" not officially supported.')
56
57
ifneq ("$(filter GNU/kFreeBSD kfreebsd,$(UNAME))","")
91
92
$(error CPU type "$(HOST_CPU)" not supported. Please file bug report at 'http://code.google.com/p/mupen64plus/issues')
94
# base CFLAGS, LIBS, and LDFLAGS
95
CFLAGS += -ffast-math -fno-strict-aliasing -fvisibility=hidden -I../../src
97
ifneq ($(OS), FREEBSD)
95
# base CFLAGS, LDLIBS, and LDFLAGS
97
CFLAGS += $(OPTFLAGS) -ffast-math -fno-strict-aliasing -fvisibility=hidden -I../../src
101
100
# Since we are building a shared library, we must compile with -fPIC for x86_64 CPUs.
102
101
# On 32-bit systems we do not want to use -fPIC because we don't have to and it has a big performance penalty on this arch
103
102
ifeq ($(ARCH_DETECTED), 64BITS)
104
CFLAGS += -fpic -DPIC
106
110
# tweak flags for 32-bit build on 64-bit system
107
111
ifeq ($(ARCH_DETECTED), 64BITS_32)
109
LDFLAGS += -m32 -m elf_i386
113
LDFLAGS += -m32 -Wl,-m,elf_i386
112
116
# set special flags per-system
118
122
ifeq ($(OS), LINUX)
120
ifeq ($(ARCH_DETECTED), 64BITS)
124
CFLAGS += -mmmx -msse -fomit-frame-pointer
129
125
ifeq ($(OS), OSX)
130
126
ifeq ($(CPU), X86)
131
127
ifeq ($(ARCH_DETECTED), 64BITS)
132
128
CFLAGS += -arch x86_64 -mmacosx-version-min=10.5 -isysroot /Developer/SDKs/MacOSX10.5.sdk
135
131
CFLAGS += -mmmx -msse -fomit-frame-pointer -arch i686 -mmacosx-version-min=10.5 -isysroot /Developer/SDKs/MacOSX10.5.sdk
136
LDFLAGS += -arch i686 -ldl
132
LDFLAGS += -arch i686
146
143
CFLAGS += $(shell sdl-config --cflags)
147
144
# sdl-config on mac screws up when we're trying to build a library and not an executable
148
145
# SDL 1.3 is supposed to fix that, if it's ever released
149
LDFLAGS += -L/usr/local/lib -lSDL -Wl,-framework,Cocoa
146
LDLIBS += -L/usr/local/lib -lSDL -Wl,-framework,Cocoa
151
148
CFLAGS += $(shell sdl-config --cflags)
152
LDFLAGS += $(shell sdl-config --libs)
149
LDLIBS += $(shell sdl-config --libs)
155
152
# set mupen64plus core API header path
177
# set shell function names
174
# reduced compile output when running make without V=1
175
ifneq ($(findstring $(MAKEFLAGS),s),s)
177
Q_CC = @echo ' CC '$@;
178
Q_LD = @echo ' LD '$@;
182
# set base program pointers and flags
188
COMPILE.c = $(Q_CC)$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c
189
LINK.o = $(Q_LD)$(CC) $(LDFLAGS) $(TARGET_ARCH)
188
191
# set special flags for given Makefile parameters
189
192
ifeq ($(DEBUG),1)
191
STRIP = true # disable binary strip
194
INSTALL_STRIP_FLAG ?=
196
INSTALL_STRIP_FLAG ?= -s
193
198
ifeq ($(PLUGINDBG), 1)
194
199
CFLAGS += -D_DEBUG
218
226
# generate a list of object files build, make a temporary directory for them
219
227
OBJECTS := $(patsubst $(SRCDIR)/%.c, $(OBJDIR)/%.o, $(filter %.c, $(SOURCE)))
220
228
OBJDIRS = $(dir $(OBJECTS))
221
$(shell mkdir -p $(OBJDIRS))
229
$(shell $(MKDIR) $(OBJDIRS))
223
231
# build dependency files
225
233
-include $(OBJECTS:.o=.d)
227
# reduced compile output when running make without V=1
228
ifneq ($(findstring $(MAKEFLAGS),s),s)
230
Q_CC = @echo ' CC '$@;
231
Q_LD = @echo ' LD '$@;
236
236
TARGET = mupen64plus-input-sdl.$(SO_EXTENSION)
246
246
@echo " Options:"
247
247
@echo " BITS=32 == build 32-bit binaries on 64-bit machine"
248
248
@echo " APIDIR=path == path to find Mupen64Plus Core headers"
249
@echo " OPTFLAGS=flag == compiler optimization (default: -O3)"
250
@echo " PIC=(1|0) == Force enable/disable of position independent code"
249
251
@echo " Install Options:"
250
252
@echo " PREFIX=path == install/uninstall prefix (default: /usr/local)"
251
253
@echo " SHAREDIR=path == path to install shared data files (default: PREFIX/share/mupen64plus)"
252
@echo " LIBDIR=path == path to install plugin libraries (default: PREFIX/lib/mupen64plus)"
254
@echo " LIBDIR=path == library prefix (default: PREFIX/lib)"
255
@echo " PLUGINDIR=path == path to install plugin libraries (default: LIBDIR/mupen64plus)"
253
256
@echo " DESTDIR=path == path to prepend to all installation paths (only for packagers)"
254
257
@echo " Debugging Options:"
255
258
@echo " DEBUG=1 == add debugging symbols"
256
259
@echo " PLUGINDBG=1 == print extra debugging information while running"
260
@echo " V=1 == show verbose compiler output"
260
264
install: $(TARGET)
261
$(INSTALL) -d -v "$(DESTDIR)$(LIBDIR)"
262
$(INSTALL) -m 0644 $(TARGET) "$(DESTDIR)$(LIBDIR)"
263
$(INSTALL) -d -v "$(DESTDIR)$(SHAREDIR)"
265
$(INSTALL) -d "$(DESTDIR)$(PLUGINDIR)"
266
$(INSTALL) -m 0644 $(INSTALL_STRIP_FLAG) $(TARGET) "$(DESTDIR)$(PLUGINDIR)"
267
$(INSTALL) -d "$(DESTDIR)$(SHAREDIR)"
264
268
$(INSTALL) -m 0644 "../../data/InputAutoCfg.ini" "$(DESTDIR)$(SHAREDIR)"
267
rm -f "$(DESTDIR)$(LIBDIR)/$(TARGET)"
271
$(RM) "$(DESTDIR)$(PLUGINDIR)/$(TARGET)"
272
$(RM) "$(DESTDIR)$(SHAREDIR)/InputAutoCfg.ini"
270
rm -rf ./_obj/* $(TARGET)
275
$(RM) -r ./_obj $(TARGET)
273
277
rebuild: clean all
279
# standard build rules
280
$(OBJDIR)/%.o: $(SRCDIR)/%.c
281
$(COMPILE.c) -o $@ $<
276
283
$(TARGET): $(OBJECTS)
277
$(Q_LD)$(CC) $(SHARED) $^ $(LDFLAGS) -o $@
280
$(OBJDIR)/%.o: $(SRCDIR)/%.c
281
$(Q_CC)$(CC) -o $@ $(CFLAGS) -c $<
284
$(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@
286
.PHONY: all clean install uninstall targets