1
#/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2
# * Mupen64plus-video-z64 - Makefile *
3
# * http://bitbucket.org/wahrhaft/mupen64plus-video-z64/ *
4
# * Copyright (C) 2010 Jon Ring *
5
# * Copyright (C) 2007-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 Video 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
ifneq ("$(filter GNU/kFreeBSD kfreebsd,$(UNAME))","")
59
$(error OS type "$(UNAME)" not supported. Please file bug report at 'http://code.google.com/p/mupen64plus/issues')
62
# detect system architecture
63
HOST_CPU ?= $(shell uname -m)
65
ifneq ("$(filter x86_64 amd64,$(HOST_CPU))","")
67
ifeq ("$(BITS)", "32")
68
ARCH_DETECTED := 64BITS_32
70
ARCH_DETECTED := 64BITS
73
ifneq ("$(filter pentium i%86,$(HOST_CPU))","")
75
ARCH_DETECTED := 32BITS
77
# PPC doesn't work yet
78
#ifneq ("$(filter ppc powerpc,$(HOST_CPU))","")
80
# ARCH_DETECTED := 32BITS
83
#ifneq ("$(filter ppc64 powerpc64,$(HOST_CPU))","")
85
# ARCH_DETECTED := 64BITS
88
ifeq ("$(CPU)","NONE")
89
$(error CPU type "$(HOST_CPU)" not supported. Please file bug report at 'http://code.google.com/p/mupen64plus/issues')
92
# base CFLAGS, LIBS, and LDFLAGS
93
CFLAGS += -Wall -ffast-math -funroll-loops -fexpensive-optimizations -fno-strict-aliasing -fvisibility=hidden -I../../src
94
CXXFLAGS += -fvisibility-inlines-hidden
95
LDFLAGS += -ldl -lGLEW
97
# Since we are building a shared library, we must compile with -fPIC for x86_64 CPUs.
98
# 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
99
ifeq ($(ARCH_DETECTED), 64BITS)
100
CFLAGS += -fpic -DPIC
102
# tweak flags for 32-bit build on 64-bit system
103
ifeq ($(ARCH_DETECTED), 64BITS_32)
104
ifeq ($(OS), FREEBSD)
105
$(error Do not use the BITS=32 option with FreeBSD, use -m32 and -m elf_i386)
108
LDFLAGS += -m32 -m elf_i386
111
# set special flags per-system
117
# only export api symbols
118
LDFLAGS += -Wl,-version-script,$(SRCDIR)/video_api_export.ver
120
ifeq ($(ARCH_DETECTED), 64BITS)
121
CFLAGS += -pipe -O3 -march=athlon64
123
CFLAGS += -pipe -O3 -mmmx -msse -march=i686 -mtune=pentium-m -fomit-frame-pointer
129
ifeq ($(ARCH_DETECTED), 64BITS)
130
CFLAGS += -pipe -O3 -arch x86_64 -mmacosx-version-min=10.5 -isysroot /Developer/SDKs/MacOSX10.5.sdk
131
LDFLAGS += -bundle -framework OpenGL -arch x86_64
133
CFLAGS += -pipe -O3 -mmmx -msse -fomit-frame-pointer -arch i686 -mmacosx-version-min=10.5 -isysroot /Developer/SDKs/MacOSX10.5.sdk
134
LDFLAGS += -bundle -framework OpenGL -arch i686
139
CFLAGS += -mcpu=powerpc
142
# test for presence of SDL
143
ifeq ($(shell which sdl-config 2>/dev/null),)
144
$(error No SDL development libraries found!)
147
CFLAGS += `${SDL_CONFIG} --cflags`
148
LDFLAGS += `${SDL_CONFIG} --libs`
151
CFLAGS += $(shell sdl-config --cflags) -DPIC
152
# sdl-config on mac screws up when we're trying to build a library and not an executable
153
# SDL 1.3 is supposed to fix that, if it's ever released
154
LDFLAGS += -L/usr/local/lib -lSDL -Wl,-framework,Cocoa
157
CFLAGS += $(shell sdl-config --cflags)
158
LDFLAGS += $(shell sdl-config --libs)
161
# set mupen64plus core API header path
162
ifneq ("$(APIDIR)","")
163
CFLAGS += "-I$(APIDIR)"
165
TRYDIR = ../../../mupen64plus-core/src/api
166
ifneq ("$(wildcard $(TRYDIR)/m64p_types.h)","")
167
CFLAGS += -I$(TRYDIR)
169
TRYDIR = /usr/local/include/mupen64plus
170
ifneq ("$(wildcard $(TRYDIR)/m64p_types.h)","")
171
CFLAGS += -I$(TRYDIR)
173
TRYDIR = /usr/include/mupen64plus
174
ifneq ("$(wildcard $(TRYDIR)/m64p_types.h)","")
175
CFLAGS += -I$(TRYDIR)
177
$(error Mupen64Plus API header files not found! Use makefile parameter APIDIR to force a location.)
183
# set shell function names
193
# set special flags for given Makefile parameters
196
STRIP = true # disable binary strip
199
# set installation options
204
SHAREDIR := $(PREFIX)/share/mupen64plus
207
LIBDIR := $(PREFIX)/lib/mupen64plus
213
# list of source files to compile
216
$(SRCDIR)/rgl_settings.cpp \
217
$(SRCDIR)/rgl_tiles.cpp \
218
$(SRCDIR)/rgl_rendermode.cpp \
219
$(SRCDIR)/rgl_geometry.cpp \
220
$(SRCDIR)/rgl_debugger.cpp \
221
$(SRCDIR)/rgl_osdep.cpp \
223
$(SRCDIR)/glshader.cpp \
224
$(SRCDIR)/disasm.cpp \
225
$(SRCDIR)/maingl.cpp \
226
$(SRCDIR)/osal_dynamiclib_unix.c
228
# generate a list of object files build, make a temporary directory for them
229
OBJECTS := $(patsubst $(SRCDIR)/%.c, $(OBJDIR)/%.o, $(filter %.c, $(SOURCE)))
230
OBJECTS += $(patsubst $(SRCDIR)/%.cpp, $(OBJDIR)/%.o, $(filter %.cpp, $(SOURCE)))
231
OBJDIRS = $(dir $(OBJECTS))
232
$(shell mkdir -p $(OBJDIRS))
235
TARGET = mupen64plus-video-z64.$(SO_EXTENSION)
238
@echo "Mupen64plus-video-z64 N64 Graphics plugin makefile. "
240
@echo " all == Build Mupen64plus-video-rice plugin"
241
@echo " clean == remove object files"
242
@echo " rebuild == clean and re-build all"
243
@echo " install == Install Mupen64Plus-video-rice plugin"
244
@echo " uninstall == Uninstall Mupen64Plus-video-rice plugin"
246
@echo " BITS=32 == build 32-bit binaries on 64-bit machine"
247
@echo " APIDIR=path == path to find Mupen64Plus Core headers"
248
@echo " Install Options:"
249
@echo " PREFIX=path == install/uninstall prefix (default: /usr/local)"
250
@echo " SHAREDIR=path == path to install shared data files (default: PREFIX/share/mupen64plus)"
251
@echo " LIBDIR=path == path to install plugin libraries (default: PREFIX/lib/mupen64plus)"
252
@echo " DESTDIR=path == path to prepend to all installation paths (only for packagers)"
253
@echo " Debugging Options:"
254
@echo " DEBUG=1 == add debugging symbols"
255
@echo " V=1 == show verbose compiler output"
260
$(INSTALL) -d -v "$(DESTDIR)$(LIBDIR)"
261
$(INSTALL) -m 0644 $(TARGET) "$(DESTDIR)$(LIBDIR)"
262
$(INSTALL) -d -v "$(DESTDIR)$(SHAREDIR)"
265
rm -f "$(DESTDIR)$(LIBDIR)/$(TARGET)"
268
rm -rf ./_obj/* $(TARGET)
273
# build dependency files
275
-include $(OBJECTS:.o=.d)
277
CXXFLAGS += $(CFLAGS)
279
# reduced compile output when running make without V=1
280
ifneq ($(findstring $(MAKEFLAGS),s),s)
282
Q_CC = @echo ' CC '$@;
283
Q_CXX = @echo ' CXX '$@;
284
Q_LD = @echo ' LD '$@;
289
$(TARGET): $(OBJECTS)
290
$(Q_LD)$(CXX) $(SHARED) $^ $(LDFLAGS) -o $@
293
$(OBJDIR)/%.o: $(SRCDIR)/%.c
294
$(Q_CC)$(CC) -o $@ $(CFLAGS) -c $<
296
$(OBJDIR)/%.o: $(SRCDIR)/%.cpp
297
$(Q_CXX)$(CXX) -o $@ $(CXXFLAGS) -c $<