~ubuntu-branches/ubuntu/precise/mupen64plus-input-sdl/precise

« back to all changes in this revision

Viewing changes to projects/unix/Makefile

  • Committer: Bazaar Package Importer
  • Author(s): Sven Eckelmann
  • Date: 2011-07-24 14:23:47 UTC
  • Revision ID: james.westby@ubuntu.com-20110724142347-zc80fvzlhbncvtm1
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, hurd_os.patch
  - Add rewrite_makefile.patch, Rewrite Makefile to fix flags and linking
  - Add inputautocfg.patch, Update InputAutoCfg.ini from mercurial
  - Add mouse_sensitivity.patch, Add mouse sensitivity

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
  SO_EXTENSION = so
39
39
  SHARED = -shared
40
40
endif
41
 
ifneq ("$(filter GNU hurd,$(UNAME))","")
42
 
  OS = LINUX
43
 
  SO_EXTENSION = so
44
 
  SHARED = -shared
45
 
endif
46
41
ifeq ("$(UNAME)","Darwin")
47
42
  OS = OSX
48
43
  SO_EXTENSION = dylib
53
48
  SO_EXTENSION = so
54
49
  SHARED = -shared
55
50
endif
 
51
ifeq ("$(UNAME)","OpenBSD")
 
52
  OS = FREEBSD
 
53
  SO_EXTENSION = so
 
54
  SHARED = -shared
 
55
  $(warning OS type "$(UNAME)" not officially supported.')
 
56
endif
56
57
ifneq ("$(filter GNU/kFreeBSD kfreebsd,$(UNAME))","")
57
58
  OS = LINUX
58
59
  SO_EXTENSION = so
91
92
  $(error CPU type "$(HOST_CPU)" not supported.  Please file bug report at 'http://code.google.com/p/mupen64plus/issues')
92
93
endif
93
94
 
94
 
# base CFLAGS, LIBS, and LDFLAGS
95
 
CFLAGS += -ffast-math -fno-strict-aliasing -fvisibility=hidden -I../../src
96
 
LDFLAGS += -ldl
97
 
ifneq ($(OS), FREEBSD)
98
 
  CFLAGS += -pipe
99
 
endif
 
95
# base CFLAGS, LDLIBS, and LDFLAGS
 
96
OPTFLAGS ?= -O3
 
97
CFLAGS += $(OPTFLAGS) -ffast-math -fno-strict-aliasing -fvisibility=hidden -I../../src
 
98
LDFLAGS += $(SHARED)
100
99
 
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
105
 
endif
 
103
  PIC ?= 1
 
104
endif
 
105
ifeq ($(PIC), 1)
 
106
  CFLAGS += -fPIC
 
107
  LDFLAGS += -fPIC
 
108
endif
 
109
 
106
110
# tweak flags for 32-bit build on 64-bit system
107
111
ifeq ($(ARCH_DETECTED), 64BITS_32)
108
112
  CFLAGS += -m32
109
 
  LDFLAGS += -m32 -m elf_i386
 
113
  LDFLAGS += -m32 -Wl,-m,elf_i386
110
114
endif
111
115
 
112
116
# set special flags per-system
116
120
  endif
117
121
endif
118
122
ifeq ($(OS), LINUX)
119
 
  ifeq ($(CPU), X86)
120
 
    ifeq ($(ARCH_DETECTED), 64BITS)
121
 
      CFLAGS +=
122
 
      LDFLAGS += -ldl
123
 
    else
124
 
      CFLAGS += -mmmx -msse -fomit-frame-pointer
125
 
      LDFLAGS += -ldl
126
 
    endif
127
 
  endif
 
123
  LDLIBS += -ldl
128
124
endif
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
133
 
      LDFLAGS += -ldl
 
129
      LDLIBS += -ldl
134
130
    else
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
 
133
      LDLIBS += -ldl
137
134
    endif
138
135
  endif
139
136
endif
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
150
147
else
151
148
    CFLAGS  += $(shell sdl-config --cflags)
152
 
    LDFLAGS += $(shell sdl-config --libs)
 
149
    LDLIBS += $(shell sdl-config --libs)
153
150
endif
154
151
 
155
152
# set mupen64plus core API header path
174
171
  endif
175
172
endif
176
173
 
177
 
# set shell function names
178
 
CC      ?= gcc
179
 
CXX     ?= g++
180
 
LD      ?= g++
181
 
INSTALL ?= install
182
 
ifeq ($(OS),OSX)
183
 
  STRIP ?= strip -x 
184
 
else
185
 
  STRIP ?= strip -s
186
 
endif
 
174
# reduced compile output when running make without V=1
 
175
ifneq ($(findstring $(MAKEFLAGS),s),s)
 
176
ifndef V
 
177
    Q_CC = @echo '    CC  '$@;
 
178
    Q_LD = @echo '    LD  '$@;
 
179
endif
 
180
endif
 
181
 
 
182
# set base program pointers and flags
 
183
CC       ?= gcc
 
184
CXX      ?= g++
 
185
RM       ?= rm -f
 
186
INSTALL  ?= install
 
187
MKDIR ?= mkdir -p
 
188
COMPILE.c = $(Q_CC)$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c
 
189
LINK.o = $(Q_LD)$(CC) $(LDFLAGS) $(TARGET_ARCH)
187
190
 
188
191
# set special flags for given Makefile parameters
189
192
ifeq ($(DEBUG),1)
190
193
  CFLAGS += -g
191
 
  STRIP = true # disable binary strip
 
194
  INSTALL_STRIP_FLAG ?= 
 
195
else
 
196
  INSTALL_STRIP_FLAG ?= -s
192
197
endif
193
198
ifeq ($(PLUGINDBG), 1)
194
199
  CFLAGS += -D_DEBUG
202
207
  SHAREDIR := $(PREFIX)/share/mupen64plus
203
208
endif
204
209
ifeq ($(LIBDIR),)
205
 
  LIBDIR := $(PREFIX)/lib/mupen64plus
 
210
  LIBDIR := $(PREFIX)/lib
 
211
endif
 
212
ifeq ($(PLUGINDIR),)
 
213
  PLUGINDIR := $(LIBDIR)/mupen64plus
206
214
endif
207
215
 
208
216
SRCDIR = ../../src
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))
222
230
 
223
231
# build dependency files
224
232
CFLAGS += -MD
225
233
-include $(OBJECTS:.o=.d)
226
234
 
227
 
# reduced compile output when running make without V=1
228
 
ifneq ($(findstring $(MAKEFLAGS),s),s)
229
 
ifndef V
230
 
    Q_CC = @echo '    CC  '$@;
231
 
    Q_LD = @echo '    LD  '$@;
232
 
endif
233
 
endif
234
 
 
235
235
# build targets
236
236
TARGET = mupen64plus-input-sdl.$(SO_EXTENSION)
237
237
 
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"
257
261
 
258
262
all: $(TARGET)
259
263
 
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)"
265
269
 
266
270
uninstall:
267
 
        rm -f "$(DESTDIR)$(LIBDIR)/$(TARGET)"
 
271
        $(RM) "$(DESTDIR)$(PLUGINDIR)/$(TARGET)"
 
272
        $(RM) "$(DESTDIR)$(SHAREDIR)/InputAutoCfg.ini"
268
273
 
269
274
clean:
270
 
        rm -rf ./_obj/* $(TARGET)
271
 
        rmdir ./_obj
 
275
        $(RM) -r ./_obj $(TARGET)
272
276
 
273
277
rebuild: clean all
274
278
 
275
 
# build rules
 
279
# standard build rules
 
280
$(OBJDIR)/%.o: $(SRCDIR)/%.c
 
281
        $(COMPILE.c) -o $@ $<
 
282
 
276
283
$(TARGET): $(OBJECTS)
277
 
        $(Q_LD)$(CC) $(SHARED) $^ $(LDFLAGS) -o $@
278
 
        $(STRIP) $@
279
 
 
280
 
$(OBJDIR)/%.o: $(SRCDIR)/%.c
281
 
        $(Q_CC)$(CC) -o $@ $(CFLAGS) -c $<
282
 
 
283
 
 
 
284
        $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@
 
285
 
 
286
.PHONY: all clean install uninstall targets