~ubuntu-branches/ubuntu/saucy/mupen64plus-video-arachnoid/saucy

« back to all changes in this revision

Viewing changes to .pc/rewrite_makefile.patch/projects/unix/Makefile

  • Committer: Bazaar Package Importer
  • Author(s): Sven Eckelmann
  • Date: 2011-07-24 14:24:36 UTC
  • Revision ID: james.westby@ubuntu.com-20110724142436-a4dvgma6mgfsp9pq
Tags: 1.99.4-3
* Upload to unstable
* 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
  - Add array_bounds.patch, Fix write past the end of m_fillColor when
    initialising CombinerBase
  - Add mipmapping.patch, Add mipmapping support
* Depend on pkg-config in debian/control for new Makefile

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 
2
# *   Arachnoid - Makefile                                                  *
 
3
# *   http://bitbucket.org/wahrhaft/mupen64plus-video-arachnoid/            *
 
4
# *   Copyright (C) 2009 Richard42, Jon Ring                                *
 
5
# *                                                                         *
 
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.                                   *
 
10
# *                                                                         *
 
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.                          *
 
15
# *                                                                         *
 
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 mupen64plus-video-arachnoid
 
22
 
 
23
# detect operation system
 
24
UNAME = $(shell uname -s)
 
25
ifeq ("$(UNAME)","Linux")
 
26
  OS = LINUX
 
27
  SO_EXTENSION = so
 
28
  SHARED = -shared
 
29
endif
 
30
ifeq ("$(UNAME)","linux")
 
31
  OS = LINUX
 
32
  SO_EXTENSION = so
 
33
  SHARED = -shared
 
34
endif
 
35
ifneq ("$(filter GNU hurd,$(UNAME))","")
 
36
  OS = LINUX
 
37
  SO_EXTENSION = so
 
38
  SHARED = -shared
 
39
endif
 
40
ifeq ("$(UNAME)","Darwin")
 
41
  OS = OSX
 
42
  LDFLAGS += -liconv -lpng
 
43
  SO_EXTENSION = dylib
 
44
  SHARED = -bundle
 
45
endif
 
46
ifeq ("$(UNAME)","FreeBSD")
 
47
  OS = FREEBSD
 
48
  SO_EXTENSION = so
 
49
  SHARED = -shared
 
50
endif
 
51
ifneq ("$(filter GNU/kFreeBSD kfreebsd,$(UNAME))","")
 
52
  OS = LINUX
 
53
  SO_EXTENSION = so
 
54
  SHARED = -shared
 
55
endif
 
56
 
 
57
# detect system architecture
 
58
HOST_CPU ?= $(shell uname -m)
 
59
NO_ASM ?= 1
 
60
ifneq ("$(filter x86_64 amd64,$(HOST_CPU))","")
 
61
  CPU := X86
 
62
  ifeq ("$(BITS)", "32")
 
63
    ARCH_DETECTED := 64BITS_32
 
64
  else
 
65
    ARCH_DETECTED := 64BITS
 
66
  endif
 
67
endif
 
68
ifneq ("$(filter pentium i%86,$(HOST_CPU))","")
 
69
  CPU := X86
 
70
  ARCH_DETECTED := 32BITS
 
71
endif
 
72
ifneq ("$(filter ppc powerpc,$(HOST_CPU))","")
 
73
  CPU := PPC
 
74
  ARCH_DETECTED := 32BITS
 
75
endif
 
76
ifneq ("$(filter ppc64 powerpc64,$(HOST_CPU))","")
 
77
  CPU := PPC
 
78
  ARCH_DETECTED := 64BITS
 
79
endif
 
80
 
 
81
# base CFLAGS, LIBS, and LDFLAGS
 
82
CFLAGS += -ffast-math -funroll-loops -fexpensive-optimizations -fno-strict-aliasing -fvisibility=hidden -I../../src \
 
83
                 -I../../src/hash -I../../src/ucodes -I../../src/GBI -I../../src/RDP -I../../src/utils \
 
84
                 -I../../src/log -I../../src/RSP -I../../src/framebuffer -I../../src/math -I../../src/renderer \
 
85
                 -I../../src/Assembler -I../../src/texture -I../../src/config -I../../src/Combiner 
 
86
ifneq ($(OS), FREEBSD)
 
87
  CFLAGS += -pipe -O3
 
88
endif
 
89
CXXFLAGS += -fvisibility-inlines-hidden
 
90
 
 
91
# On OS X, add a few extra flags to elegantly support cross-compilation and backward
 
92
# compatibility (and also the flags to link against OpenGL)
 
93
ifeq ($(OS), OSX)
 
94
  ifeq ($(CPU), X86)
 
95
    ifeq ($(ARCH_DETECTED), 64BITS)
 
96
      CFLAGS += -arch x86_64 -mmacosx-version-min=10.5 -isysroot /Developer/SDKs/MacOSX10.5.sdk
 
97
      LDFLAGS += -bundle -framework OpenGL -arch x86_64 -mmacosx-version-min=10.4 -isysroot /Developer/SDKs/MacOSX10.5.sdk
 
98
    else
 
99
      CFLAGS += -arch i686 -mmacosx-version-min=10.5 -isysroot /Developer/SDKs/MacOSX10.5.sdk
 
100
      LDFLAGS += -bundle -framework OpenGL -arch i686 -mmacosx-version-min=10.4 -isysroot /Developer/SDKs/MacOSX10.5.sdk
 
101
    endif
 
102
  endif
 
103
else
 
104
  # flags for other Unices
 
105
  LDFLAGS += -ldl -lGL -lGLU -lpthread
 
106
endif
 
107
 
 
108
 
 
109
ifeq ($(ARCH_DETECTED), 64BITS)
 
110
  CFLAGS += -fPIC
 
111
endif
 
112
 
 
113
# set mupen64plus core API header path
 
114
ifneq ("$(APIDIR)","")
 
115
  CFLAGS += "-I$(APIDIR)"
 
116
else
 
117
  TRYDIR = ../../../mupen64plus-core/src/api
 
118
  ifneq ("$(wildcard $(TRYDIR)/m64p_types.h)","")
 
119
    CFLAGS += -I$(TRYDIR)
 
120
  else
 
121
    TRYDIR = /usr/local/include/mupen64plus
 
122
    ifneq ("$(wildcard $(TRYDIR)/m64p_types.h)","")
 
123
      CFLAGS += -I$(TRYDIR)
 
124
    else
 
125
      TRYDIR = /usr/include/mupen64plus
 
126
      ifneq ("$(wildcard $(TRYDIR)/m64p_types.h)","")
 
127
        CFLAGS += -I$(TRYDIR)
 
128
      endif
 
129
    endif
 
130
  endif
 
131
endif
 
132
 
 
133
# set special flags per-system
 
134
ifeq ($(OS), LINUX)
 
135
  # only export api symbols
 
136
  LDFLAGS += -Wl,-version-script,$(SRCDIR)/video_api_export.ver
 
137
endif
 
138
ifneq ($(OS), FREEBSD)
 
139
  ifeq ($(CPU), X86)
 
140
    ifeq ($(ARCH_DETECTED), 64BITS)
 
141
      CFLAGS += -march=athlon64
 
142
    else
 
143
      CFLAGS += -mmmx -msse -march=i686 -mtune=pentium-m -fomit-frame-pointer
 
144
    endif
 
145
    # tweak flags for 32-bit build on 64-bit system
 
146
    ifeq ($(ARCH_DETECTED), 64BITS_32)
 
147
      CFLAGS += -m32
 
148
      LDFLAGS += -m32 -m elf_i386
 
149
    endif
 
150
  endif
 
151
else
 
152
  ifeq ($(ARCH_DETECTED), 64BITS_32)
 
153
    $(error Do not use the BITS=32 option with FreeBSD, use -m32 and -m elf_i386)
 
154
  endif
 
155
endif
 
156
ifeq ($(CPU), PPC)
 
157
  CFLAGS += -mcpu=powerpc
 
158
endif
 
159
 
 
160
# set shell function names
 
161
# set shell function names
 
162
CC      ?= gcc
 
163
CXX     ?= g++
 
164
INSTALL ?= install
 
165
ifeq ($(OS),LINUX)
 
166
  STRIP = strip -s
 
167
endif
 
168
ifeq ($(OS),OSX)
 
169
  STRIP = strip -x 
 
170
endif
 
171
 
 
172
# set special flags for given Makefile parameters
 
173
ifeq ($(DEBUG),1)
 
174
  CFLAGS += -g  -fno-inline -Werror
 
175
  STRIP = true # disable binary strip
 
176
endif
 
177
 
 
178
# set installation options
 
179
ifeq ($(PREFIX),)
 
180
  PREFIX := /usr/local
 
181
endif
 
182
ifeq ($(SHAREDIR),)
 
183
  SHAREDIR := $(PREFIX)/share/mupen64plus
 
184
endif
 
185
ifeq ($(LIBDIR),)
 
186
  LIBDIR := $(PREFIX)/lib/mupen64plus
 
187
endif
 
188
 
 
189
 
 
190
SRCDIR = ../../src
 
191
OBJDIR = _obj
 
192
 
 
193
# list of source files to compile
 
194
SOURCE = \
 
195
        $(SRCDIR)/main.cpp \
 
196
        $(SRCDIR)/log/Logger.cpp \
 
197
        $(SRCDIR)/config/Config.cpp \
 
198
        $(SRCDIR)/config/StringFunctions.cpp \
 
199
        $(SRCDIR)/GraphicsPlugin.cpp \
 
200
        $(SRCDIR)/OpenGLManager.cpp \
 
201
        $(SRCDIR)/renderer/OpenGLRenderer.cpp \
 
202
        $(SRCDIR)/framebuffer/FrameBuffer.cpp \
 
203
        $(SRCDIR)/renderer/OpenGL2DRenderer.cpp \
 
204
        $(SRCDIR)/FogManager.cpp \
 
205
        $(SRCDIR)/MultiTexturingExt.cpp \
 
206
        $(SRCDIR)/ExtensionChecker.cpp \
 
207
        $(SRCDIR)/SecondaryColorExt.cpp \
 
208
        $(SRCDIR)/Memory.cpp \
 
209
        $(SRCDIR)/math/Matrix4.cpp \
 
210
        $(SRCDIR)/texture/CachedTexture.cpp \
 
211
        $(SRCDIR)/texture/TextureCache.cpp \
 
212
        $(SRCDIR)/texture/ImageFormatSelector.cpp \
 
213
        $(SRCDIR)/hash/CRCCalculator.cpp \
 
214
        $(SRCDIR)/hash/CRCCalculator2.cpp \
 
215
        $(SRCDIR)/texture/TextureLoader.cpp \
 
216
        $(SRCDIR)/DisplayListParser.cpp \
 
217
        $(SRCDIR)/VI.cpp \
 
218
        $(SRCDIR)/ucodes/UCodeSelector.cpp \
 
219
        $(SRCDIR)/ucodes/UCode0.cpp \
 
220
        $(SRCDIR)/ucodes/UCode1.cpp \
 
221
        $(SRCDIR)/ucodes/UCode2.cpp \
 
222
        $(SRCDIR)/ucodes/UCode3.cpp \
 
223
        $(SRCDIR)/ucodes/UCode4.cpp \
 
224
        $(SRCDIR)/ucodes/UCode5.cpp \
 
225
        $(SRCDIR)/ucodes/UCode6.cpp \
 
226
        $(SRCDIR)/ucodes/UCode7.cpp \
 
227
        $(SRCDIR)/ucodes/UCode8.cpp \
 
228
        $(SRCDIR)/ucodes/UCode9.cpp \
 
229
        $(SRCDIR)/ucodes/UCode10.cpp \
 
230
        $(SRCDIR)/GBI/GBI.cpp \
 
231
        $(SRCDIR)/RSP/RSP.cpp \
 
232
        $(SRCDIR)/RSP/RSPMatrixManager.cpp \
 
233
        $(SRCDIR)/RSP/RSPVertexManager.cpp \
 
234
        $(SRCDIR)/RSP/RSPLightManager.cpp \
 
235
        $(SRCDIR)/Combiner/AdvancedCombinerManager.cpp \
 
236
        $(SRCDIR)/Combiner/CombinerBase.cpp \
 
237
        $(SRCDIR)/Combiner/AdvancedTexEnvCombiner.cpp \
 
238
        $(SRCDIR)/Combiner/SimpleTexEnvCombiner.cpp \
 
239
        $(SRCDIR)/Combiner/DummyCombiner.cpp \
 
240
        $(SRCDIR)/Combiner/CombinerStageMerger.cpp \
 
241
        $(SRCDIR)/Combiner/CombinerStageCreator.cpp \
 
242
        $(SRCDIR)/Combiner/CombinerCache.cpp \
 
243
        $(SRCDIR)/RomDetector.cpp \
 
244
        $(SRCDIR)/RDP/RDP.cpp \
 
245
        $(SRCDIR)/RDP/RDPInstructions.cpp \
 
246
        $(SRCDIR)/osal_dynamiclib_unix.cpp
 
247
 
 
248
 
 
249
# generate a list of object files build, make a temporary directory for them
 
250
OBJECTS := $(patsubst $(SRCDIR)/%.cpp, $(OBJDIR)/%.o, $(filter %.cpp, $(SOURCE)))
 
251
OBJDIRS = $(dir $(OBJECTS))
 
252
$(shell mkdir -p $(OBJDIRS))
 
253
 
 
254
# build targets
 
255
 
 
256
TARGET = mupen64plus-video-arachnoid.$(SO_EXTENSION)
 
257
targets:
 
258
        @echo "Mupen64plus-video-arachnoid N64 Graphics plugin makefile. "
 
259
        @echo "  Targets:"
 
260
        @echo "    all           == Build Mupen64plus-video-arachnoid plugin"
 
261
        @echo "    clean         == remove object files"
 
262
        @echo "    rebuild       == clean and re-build all"
 
263
        @echo "    install       == Install Mupen64Plus-video-arachnoid plugin"
 
264
        @echo "    uninstall     == Uninstall Mupen64Plus-video-arachnoid plugin"
 
265
        @echo "  Options:"
 
266
        @echo "    BITS=32       == build 32-bit binaries on 64-bit machine"
 
267
        @echo "    APIDIR=path   == path to find Mupen64Plus Core headers"
 
268
        @echo "  Install Options:"
 
269
        @echo "    PREFIX=path   == install/uninstall prefix (default: /usr/local)"
 
270
        @echo "    LIBDIR=path   == path to install plugin libraries (default: PREFIX/lib/mupen64plus)"
 
271
        @echo "    DESTDIR=path  == path to prepend to all installation paths (only for packagers)"
 
272
        @echo "  Debugging Options:"
 
273
        @echo "    DEBUG=1       == add debugging symbols"
 
274
        @echo "    V=1           == show verbose compiler output"
 
275
 
 
276
all: $(TARGET)
 
277
 
 
278
install: $(TARGET)
 
279
        $(INSTALL) -d -v "$(DESTDIR)$(LIBDIR)"
 
280
        $(INSTALL) -m 0644 $(TARGET) "$(DESTDIR)$(LIBDIR)"
 
281
 
 
282
uninstall:
 
283
        rm -f "$(DESTDIR)$(LIBDIR)/$(TARGET)"
 
284
 
 
285
 
 
286
clean:
 
287
        rm -rf ./_obj mupen64plus-video-arachnoid.$(SO_EXTENSION)
 
288
 
 
289
# build dependency files
 
290
CFLAGS += -MD
 
291
-include $(OBJECTS:.o=.d)
 
292
 
 
293
CXXFLAGS += $(CFLAGS)
 
294
 
 
295
# reduced compile output when running make without V=1
 
296
ifneq ($(findstring $(MAKEFLAGS),s),s)
 
297
ifndef V
 
298
        Q_CC  = @echo '    CC  '$@;
 
299
        Q_CXX = @echo '    CXX '$@;
 
300
        Q_LD  = @echo '    LD  '$@;
 
301
endif
 
302
endif
 
303
 
 
304
# build rules
 
305
$(TARGET): $(OBJECTS)
 
306
        $(Q_LD)$(CXX) $(SHARED) $^ $(LDFLAGS) -o $@
 
307
        $(STRIP) $@
 
308
 
 
309
$(OBJDIR)/%.o: $(SRCDIR)/%.c
 
310
        $(Q_CC)$(CC) -o $@ $(CFLAGS) -c $<
 
311
 
 
312
$(OBJDIR)/%.o: $(SRCDIR)/%.cpp
 
313
        $(Q_CXX)$(CXX) -o $@ $(CXXFLAGS) -c $<