Fix a severe bug on non-x86 machines (archive segfault)
[tennix.git] / makefile
blob08b020c7ed1fee4d438e38d393e080f0b0d2995b
3 # Tennix! SDL Port
4 # Copyright (C) 2003, 2007, 2008, 2009 Thomas Perl <thp@thpinfo.com>
5 #
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License
8 # as published by the Free Software Foundation; either version 2
9 # of the License, or (at your option) any later version.
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.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19 # MA 02110-1301, USA.
23 ifeq ($(MKCALLGRAPH),1)
24 CC = nccgen -ncgcc -ncld -ncfabs
25 LD = nccld
26 endif
28 RELEASE = 0.7.0
30 TARGET ?= default
32 PREFIX ?= usr/local/
33 BINARY_INSTALL_DIR ?= $(PREFIX)/bin
35 LIBS =
36 CFLAGS += -Wall -DVERSION=\"$(RELEASE)\" -O2 -DPREFIX=\"$(PREFIX)\"
38 ifeq ($(UPDRECTANGLE),1)
39 CFLAGS += -DDRAW_UPDATE_RECTANGLE
40 endif
42 ifeq ($(DELUXE),1)
43 CFLAGS += -DDELUXE_EDITION
44 endif
46 ifeq ($(DEBUG),1)
47 CFLAGS += -DDEBUG
48 endif
50 ifeq ($(MAEMO),1)
51 CFLAGS += -DMAEMO -mfpu=vfp -mfloat-abi=softfp -mcpu=arm1136j-s
52 endif
54 ifeq ($(TARGET),cocoa)
55 LIBS += SDLmain.m -framework SDL -framework Cocoa -framework SDL_image -framework SDL_mixer
56 CFLAGS += -I/Library/Frameworks/SDL.framework/Headers -I/Library/Frameworks/SDL_image.framework/Headers -I/Library/Frameworks/SDL_mixer.framework/Headers -DMACOSX
57 else
58 LIBS += $$(sdl-config --libs) -lSDL_mixer -lSDL_image
59 CFLAGS += $$(sdl-config --cflags)
60 endif
62 SRC = tennix.c game.c graphics.c input.c sound.c
63 OBJ = tennix.o game.o graphics.o input.o sound.o archive-lib.o
64 ifeq ($(MSYSTEM),MINGW32)
65 OBJ += tennixres.o
66 endif
68 TOARCHIVE=$(wildcard data/*.ogg wildcard data/*.png voice/*.ogg)
70 WIN32LIBS = *.dll
71 OSXAPP = Tennix.app
73 DATAFILES = README README.*
74 ifeq ($(TARGET),cocoa)
75 DATAFILES += data/Tennix.icns
76 endif
78 tennix: $(OBJ) tennix.tnx
79 $(CC) $(CFLAGS) -o tennix $(OBJ) $(LIBS)
80 test -f tennix.exe && upx tennix.exe || true
82 ChangeLog:
83 git log >ChangeLog
85 install: tennix
86 install -d $(DESTDIR)/$(BINARY_INSTALL_DIR) $(DESTDIR)/$(PREFIX)/share/pixmaps $(DESTDIR)/$(PREFIX)/share/applications $(DESTDIR)/$(PREFIX)/share/man/man6 $(DESTDIR)/$(PREFIX)/share/icons/hicolor/scalable/apps $(DESTDIR)/$(PREFIX)/share/tennix
87 install -s tennix $(DESTDIR)/$(BINARY_INSTALL_DIR)/tennix
88 install tennix.6 $(DESTDIR)/$(PREFIX)/share/man/man6/tennix.6
89 install -m644 data/icon.png $(DESTDIR)/$(PREFIX)/share/pixmaps/tennix.png
90 install -m644 data/icon.svg $(DESTDIR)/$(PREFIX)/share/icons/hicolor/scalable/apps/tennix.svg
91 install -m644 tennix.desktop $(DESTDIR)/$(PREFIX)/share/applications/
92 install -m644 tennix.tnx $(DESTDIR)/$(PREFIX)/share/tennix/
94 tennix.o: tennix.c tennix.h game.h graphics.h input.h sound.h
95 graphics.o: graphics.c graphics.h tennix.h archive.h sound.h
96 game.o: game.c game.h graphics.h tennix.h sound.h input.h
97 sound.o: sound.c sound.h tennix.h archive.h graphics.h
99 archive-lib.o: archive.c archive.h
100 $(CC) -c -o $@ $<
102 tennixar: archive dump
104 archive.o: archive.c archive.h
105 $(CC) -DTENNIXAR_STANDALONE -c -o $@ $<
107 dump: archive
108 ln -s archive dump
110 tennix.tnx: archive $(TOARCHIVE)
111 rm -f tennix.tnx
112 ./archive $@ $(TOARCHIVE)
114 # Mac OS X-specific targets
115 release-osx: tennix ChangeLog
116 mkdir -p $(OSXAPP)/Contents/{MacOS,/Resources}
117 cp -rpv tennix $(OSXAPP)/Contents/MacOS/Tennix
118 cp -rpv $(DATAFILES) ChangeLog $(OSXAPP)/Contents/Resources/
119 sed -e 's/TENNIX_VERSION/$(RELEASE)/' osxapp.plist >$(OSXAPP)/Contents/Info.plist
120 echo 'APPL????' >$(OSXAPP)/Contents/PkgInfo
121 zip -r tennix-$(RELEASE)-macosx.zip $(OSXAPP)
122 # End Mac OS X-specific targets
124 # Windows-specific targets
125 release-win32: tennix ChangeLog
126 zip tennix-$(RELEASE)-win32.zip tennix.exe $(WIN32LIBS) $(DATAFILES) ChangeLog
128 tennix-installer.iss: tennix-installer.iss.in
129 sed tennix-installer.iss.in -e 's/{version}/$(RELEASE)/g' >tennix-installer.iss
131 release-win32-setup: tennix ChangeLog tennix-installer.iss
132 iscc tennix-installer.iss
134 tennixres.o: tennix.res
135 windres tennix.res tennixres.o
136 # End Windows-specific targets
138 release-bin: tennix ChangeLog
139 tar czvf tennix-$(RELEASE)-bin.tar.gz tennix $(DATAFILES) ChangeLog
141 release: distclean ChangeLog
142 mkdir -p .release-tmp/tennix-$(RELEASE)/
143 cp -rv * .release-tmp/tennix-$(RELEASE)/
144 rm -rf .release-tmp/tennix-$(RELEASE)/.git
145 tar czvf tennix-$(RELEASE).tar.gz -C .release-tmp tennix-$(RELEASE)
146 rm -rf .release-tmp
148 clean:
149 rm -f *.o tennix tennix.exe archive archive.exe dump dump.exe
150 rm -rf $(OSXAPP) tennix-*-macosx.zip
151 rm -f tennixres.o tennix-installer.iss tennix-*-win32-setup.exe
152 rm -f tennix.tnx
154 distclean: clean
155 rm -rf tennix-$(RELEASE).zip tennix-$(RELEASE)-bin.tar.gz ChangeLog .release-tmp tennix-$(RELEASE).tar.gz
157 .PHONY: distclean clean release-bin release-win32 release-win32-setup release-osx install tennixar