~ubuntu-branches/ubuntu/vivid/mupen64plus-video-z64/vivid-proposed

« back to all changes in this revision

Viewing changes to .pc/default-optimisations.patch/projects/unix/Makefile

  • Committer: Bazaar Package Importer
  • Author(s): Sven Eckelmann
  • Date: 2011-07-24 14:24:52 UTC
  • Revision ID: james.westby@ubuntu.com-20110724142452-amlc2lknfu9dgeot
Tags: 1.99.4-3
* Upload to unstable
* debian/control:
  - Build against libglew1.6
  - Depend on pkg-config for new Makefile
* debian/rules:
  - Mark all targets as phony
  - Force PIC using Makefile option
  - Remove unintended optimization flags
* debian/patches:
  - Remove obsolete default-optimisations.patch
  - Add rewrite_makefile.patch, Rewrite Makefile to fix flags and linking

Show diffs side-by-side

added added

removed removed

Lines of Context:
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                             *
7
 
# *                                                                         *
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.                                   *
12
 
# *                                                                         *
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.                          *
17
 
# *                                                                         *
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
24
 
 
25
 
# detect operating system
26
 
UNAME = $(shell uname -s)
27
 
OS := NONE
28
 
ifeq ("$(UNAME)","Linux")
29
 
  OS = LINUX
30
 
  SO_EXTENSION = so
31
 
  SHARED = -shared
32
 
endif
33
 
ifeq ("$(UNAME)","linux")
34
 
  OS = LINUX
35
 
  SO_EXTENSION = so
36
 
  SHARED = -shared
37
 
endif
38
 
ifneq ("$(filter GNU hurd,$(UNAME))","")
39
 
  OS = LINUX
40
 
  SO_EXTENSION = so
41
 
  SHARED = -shared
42
 
endif
43
 
ifeq ("$(UNAME)","Darwin")
44
 
  OS = OSX
45
 
  SO_EXTENSION = dylib
46
 
  SHARED = -bundle
47
 
endif
48
 
ifeq ("$(UNAME)","FreeBSD")
49
 
  OS = FREEBSD
50
 
  SO_EXTENSION = so
51
 
  SHARED = -shared
52
 
endif
53
 
ifneq ("$(filter GNU/kFreeBSD kfreebsd,$(UNAME))","")
54
 
  OS = LINUX
55
 
  SO_EXTENSION = so
56
 
  SHARED = -shared
57
 
endif
58
 
ifeq ("$(OS)","NONE")
59
 
  $(error OS type "$(UNAME)" not supported.  Please file bug report at 'http://code.google.com/p/mupen64plus/issues')
60
 
endif
61
 
 
62
 
# detect system architecture
63
 
HOST_CPU ?= $(shell uname -m)
64
 
CPU := NONE
65
 
ifneq ("$(filter x86_64 amd64,$(HOST_CPU))","")
66
 
  CPU := X86
67
 
  ifeq ("$(BITS)", "32")
68
 
    ARCH_DETECTED := 64BITS_32
69
 
  else
70
 
    ARCH_DETECTED := 64BITS
71
 
  endif
72
 
endif
73
 
ifneq ("$(filter pentium i%86,$(HOST_CPU))","")
74
 
  CPU := X86
75
 
  ARCH_DETECTED := 32BITS
76
 
endif
77
 
# PPC doesn't work yet
78
 
#ifneq ("$(filter ppc powerpc,$(HOST_CPU))","")
79
 
#  CPU := PPC
80
 
#  ARCH_DETECTED := 32BITS
81
 
#  NO_ASM := 1
82
 
#endif
83
 
#ifneq ("$(filter ppc64 powerpc64,$(HOST_CPU))","")
84
 
#  CPU := PPC
85
 
#  ARCH_DETECTED := 64BITS
86
 
#  NO_ASM := 1
87
 
#endif
88
 
ifeq ("$(CPU)","NONE")
89
 
  $(error CPU type "$(HOST_CPU)" not supported.  Please file bug report at 'http://code.google.com/p/mupen64plus/issues')
90
 
endif
91
 
 
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
96
 
 
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
101
 
endif
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)
106
 
  endif
107
 
  CFLAGS += -m32
108
 
  LDFLAGS += -m32 -m elf_i386
109
 
endif
110
 
 
111
 
# set special flags per-system
112
 
ifeq ($(OS),FREEBSD)
113
 
  LDFLAGS += -lGL
114
 
endif
115
 
ifeq ($(OS), LINUX)
116
 
  LDFLAGS += -lGL
117
 
  # only export api symbols
118
 
  LDFLAGS += -Wl,-version-script,$(SRCDIR)/video_api_export.ver
119
 
  ifeq ($(CPU), X86)
120
 
    ifeq ($(ARCH_DETECTED), 64BITS)
121
 
      CFLAGS += -pipe -O3 -march=athlon64
122
 
    else
123
 
      CFLAGS += -pipe -O3 -mmmx -msse -march=i686 -mtune=pentium-m -fomit-frame-pointer
124
 
    endif
125
 
  endif
126
 
endif
127
 
ifeq ($(OS), OSX)
128
 
  ifeq ($(CPU), X86)
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
132
 
    else
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
135
 
    endif
136
 
  endif
137
 
endif
138
 
ifeq ($(CPU), PPC)
139
 
  CFLAGS += -mcpu=powerpc
140
 
endif
141
 
 
142
 
# test for presence of SDL
143
 
ifeq ($(shell which sdl-config 2>/dev/null),)
144
 
  $(error No SDL development libraries found!)
145
 
endif
146
 
ifeq ($(OS),FREEBSD)
147
 
    CFLAGS  += `${SDL_CONFIG} --cflags`
148
 
    LDFLAGS += `${SDL_CONFIG} --libs`
149
 
endif
150
 
ifeq ($(OS),OSX)
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
155
 
endif
156
 
ifeq ($(OS),LINUX)
157
 
    CFLAGS  += $(shell sdl-config --cflags)
158
 
    LDFLAGS += $(shell sdl-config --libs)
159
 
endif
160
 
 
161
 
# set mupen64plus core API header path
162
 
ifneq ("$(APIDIR)","")
163
 
  CFLAGS += "-I$(APIDIR)"
164
 
else
165
 
  TRYDIR = ../../../mupen64plus-core/src/api
166
 
  ifneq ("$(wildcard $(TRYDIR)/m64p_types.h)","")
167
 
    CFLAGS += -I$(TRYDIR)
168
 
  else
169
 
    TRYDIR = /usr/local/include/mupen64plus
170
 
    ifneq ("$(wildcard $(TRYDIR)/m64p_types.h)","")
171
 
      CFLAGS += -I$(TRYDIR)
172
 
    else
173
 
      TRYDIR = /usr/include/mupen64plus
174
 
      ifneq ("$(wildcard $(TRYDIR)/m64p_types.h)","")
175
 
        CFLAGS += -I$(TRYDIR)
176
 
      else
177
 
        $(error Mupen64Plus API header files not found! Use makefile parameter APIDIR to force a location.)
178
 
      endif
179
 
    endif
180
 
  endif
181
 
endif
182
 
 
183
 
# set shell function names
184
 
CC      ?= gcc
185
 
CXX     ?= g++
186
 
INSTALL ?= install
187
 
ifeq ($(OS),OSX)
188
 
  STRIP ?= strip -x 
189
 
else
190
 
  STRIP ?= strip -s
191
 
endif
192
 
 
193
 
# set special flags for given Makefile parameters
194
 
ifeq ($(DEBUG),1)
195
 
  CFLAGS += -g
196
 
  STRIP = true # disable binary strip
197
 
endif
198
 
 
199
 
# set installation options
200
 
ifeq ($(PREFIX),)
201
 
  PREFIX := /usr/local
202
 
endif
203
 
ifeq ($(SHAREDIR),)
204
 
  SHAREDIR := $(PREFIX)/share/mupen64plus
205
 
endif
206
 
ifeq ($(LIBDIR),)
207
 
  LIBDIR := $(PREFIX)/lib/mupen64plus
208
 
endif
209
 
 
210
 
SRCDIR = ../../src
211
 
OBJDIR = _obj
212
 
 
213
 
# list of source files to compile
214
 
SOURCE = \
215
 
        $(SRCDIR)/rgl.cpp \
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 \
222
 
        $(SRCDIR)/rdp.cpp \
223
 
        $(SRCDIR)/glshader.cpp \
224
 
        $(SRCDIR)/disasm.cpp \
225
 
        $(SRCDIR)/maingl.cpp \
226
 
        $(SRCDIR)/osal_dynamiclib_unix.c
227
 
 
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))
233
 
 
234
 
# build targets
235
 
TARGET = mupen64plus-video-z64.$(SO_EXTENSION)
236
 
 
237
 
targets:
238
 
        @echo "Mupen64plus-video-z64 N64 Graphics plugin makefile. "
239
 
        @echo "  Targets:"
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"
245
 
        @echo "  Options:"
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"
256
 
 
257
 
all: $(TARGET)
258
 
 
259
 
install: $(TARGET)
260
 
        $(INSTALL) -d -v "$(DESTDIR)$(LIBDIR)"
261
 
        $(INSTALL) -m 0644 $(TARGET) "$(DESTDIR)$(LIBDIR)"
262
 
        $(INSTALL) -d -v "$(DESTDIR)$(SHAREDIR)"
263
 
 
264
 
uninstall:
265
 
        rm -f "$(DESTDIR)$(LIBDIR)/$(TARGET)"
266
 
 
267
 
clean:
268
 
        rm -rf ./_obj/* $(TARGET)
269
 
        rmdir ./_obj
270
 
 
271
 
rebuild: clean all
272
 
 
273
 
# build dependency files
274
 
CFLAGS += -MD
275
 
-include $(OBJECTS:.o=.d)
276
 
 
277
 
CXXFLAGS += $(CFLAGS)
278
 
 
279
 
# reduced compile output when running make without V=1
280
 
ifneq ($(findstring $(MAKEFLAGS),s),s)
281
 
ifndef V
282
 
        Q_CC  = @echo '    CC  '$@;
283
 
        Q_CXX = @echo '    CXX '$@;
284
 
        Q_LD  = @echo '    LD  '$@;
285
 
endif
286
 
endif
287
 
 
288
 
# build rules
289
 
$(TARGET): $(OBJECTS)
290
 
        $(Q_LD)$(CXX) $(SHARED) $^ $(LDFLAGS) -o $@
291
 
        $(STRIP) $@
292
 
 
293
 
$(OBJDIR)/%.o: $(SRCDIR)/%.c
294
 
        $(Q_CC)$(CC) -o $@ $(CFLAGS) -c $<
295
 
 
296
 
$(OBJDIR)/%.o: $(SRCDIR)/%.cpp
297
 
        $(Q_CXX)$(CXX) -o $@ $(CXXFLAGS) -c $<