Streamline the archive loading mechanism
[tennix.git] / makefile
blob56ac8a4f64ed9563a90c872a86e163a4999b4c25
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.
22 CC = g++
25 ifeq ($(MKCALLGRAPH),1)
26 CC = nccgen -ncgcc -ncld -ncfabs
27 LD = nccld
28 endif
30 RELEASE = 1.0
32 UNAME = $(shell uname)
34 PREFIX ?= /usr/local
35 BINDIR ?= $(PREFIX)/bin
36 DATAROOTDIR ?= $(PREFIX)/share
37 DATADIR ?= $(DATAROOTDIR)/games
39 LIBS =
40 CFLAGS += -W -Wall -ansi -pedantic -Wcast-qual -Wwrite-strings -DVERSION=\"$(RELEASE)\" -O2 -DPREFIX=\"$(PREFIX)\" -g
41 CXXFLAGS += $(CFLAGS)
43 USE_PYTHON ?= 1
45 ifeq ($(USE_PYTHON),1)
46 CFLAGS += `python-config --includes` -DTENNIX_PYTHON
47 LIBS += `python-config --libs`
48 endif
50 ifeq ($(NONFREE_LOCATIONS),1)
51 CFLAGS += -DNONFREE_LOCATIONS
52 endif
54 ifeq ($(UPDRECTANGLE),1)
55 CFLAGS += -DDRAW_UPDATE_RECTANGLE
56 endif
58 ifeq ($(DELUXE),1)
59 CFLAGS += -DDELUXE_EDITION
60 endif
62 ifeq ($(DEBUG),1)
63 CFLAGS += -DDEBUG
64 endif
66 ifeq ($(MAEMO),1)
67 CFLAGS += -DMAEMO
68 endif
70 ifeq ($(UNAME),Darwin)
71 SDLLIBS=$$(sdl-config --prefix)/lib
72 LIBS += $$(sdl-config --static-libs) $(SDLLIBS)/libSDL_mixer.a $(SDLLIBS)/libSDL_image.a $(SDLLIBS)/libSDL_ttf.a $(SDLLIBS)/libSDL_net.a $$(freetype-config --prefix)/lib/libfreetype.a
73 CFLAGS += $$(sdl-config --cflags) -lz
74 else
75 LIBS += $$(sdl-config --libs) -lSDL_mixer -lSDL_image -lSDL_ttf -lSDL_net
76 CFLAGS += $$(sdl-config --cflags)
77 endif
79 SRC = tennix.cc game.c graphics.cc input.c util.c sound.cc animation.c network.c
80 OBJ = tennix.o game.o graphics.o input.o util.o sound.o animation.o archive.o SDL_rotozoom.o network.o
81 ifeq ($(MSYSTEM),MINGW32)
82 OBJ += tennixres.o
83 endif
84 ifeq ($(USE_PYTHON),1)
85 OBJ += tennixpy.o
86 endif
88 TOARCHIVE=$(wildcard data/*.ogg data/*.ttf wildcard data/*.png voice/*.ogg *.py)
90 WIN32LIBS = *.dll
91 OSXAPP = Tennix.app
93 DATAFILES = README README.*
94 DATAFILES_OSX = $(DATAFILES) data/Tennix.icns
96 tennix: $(OBJ) tennix.tnx
97 $(CC) $(CFLAGS) -o tennix $(OBJ) $(LIBS)
98 test -f tennix.exe && upx tennix.exe || true
100 ChangeLog:
101 git log >ChangeLog
103 install: tennix
104 install -d -m 755 $(DESTDIR)$(BINDIR)
105 install -d -m 755 $(DESTDIR)$(DATAROOTDIR)/pixmaps
106 install -d -m 755 $(DESTDIR)$(DATAROOTDIR)/applications
107 install -d -m 755 $(DESTDIR)$(DATAROOTDIR)/man/man6
108 install -d -m 755 $(DESTDIR)$(DATAROOTDIR)/icons/hicolor/scalable/apps
109 install -d -m 755 $(DESTDIR)$(DATADIR)/tennix
110 install -m 755 tennix $(DESTDIR)$(BINDIR)/
111 install -m 644 tennix.6 $(DESTDIR)$(DATAROOTDIR)/man/man6/
112 install -m 644 data/icon.png $(DESTDIR)$(DATAROOTDIR)/pixmaps/tennix.png
113 install -m 644 data/icon.svg $(DESTDIR)$(DATAROOTDIR)/icons/hicolor/scalable/apps/tennix.svg
114 install -m 644 tennix.desktop $(DESTDIR)$(DATAROOTDIR)/applications/
115 install -m 644 tennix.tnx $(DESTDIR)$(DATADIR)/tennix/
117 archive.o: archive.cc archive.cc
118 tennix.o: tennix.cc tennix.h game.h graphics.h input.h util.h animation.h sound.h locations.h util.h archive.hh
119 graphics.o: graphics.cc graphics.h tennix.h archive.hh sound.h
120 game.o: game.c game.h graphics.h tennix.h sound.h input.h util.h network.h
121 sound.o: sound.cc sound.h tennix.h archive.hh graphics.h
122 input.o: input.c input.h tennix.h graphics.h game.h util.h tennixpy.h archive.hh
123 util.o: util.c util.h tennix.h
124 animation.o: animation.c animation.h graphics.h tennix.h credits.h
125 tennixpy.o: tennixpy.cc tennix.h game.h archive.hh
126 network.o: network.c network.h game.h
127 SDL_rotozoom.o: SDL_rotozoom.c SDL_rotozoom.h
129 tennixar: archive dump
131 archive: archivetool.cc archive.o archive.hh
133 dump: archive
134 ln -s archive dump
136 tennix.tnx: archive $(TOARCHIVE)
137 rm -f tennix.tnx
138 ./archive $@ $(TOARCHIVE)
140 # Mac OS X-specific targets
141 release-osx: tennix tennix.tnx ChangeLog
142 mkdir -p $(OSXAPP)/Contents/{MacOS,/Resources}
143 cp -rpv tennix $(OSXAPP)/Contents/MacOS/Tennix
144 cp -rpv tennix.tnx $(DATAFILES_OSX) ChangeLog $(OSXAPP)/Contents/Resources/
145 sed -e 's/TENNIX_VERSION/$(RELEASE)/' osxapp.plist >$(OSXAPP)/Contents/Info.plist
146 echo 'APPL????' >$(OSXAPP)/Contents/PkgInfo
147 zip -r tennix-$(RELEASE)-macosx.zip $(OSXAPP)
148 # End Mac OS X-specific targets
150 # Windows-specific targets
151 release-win32: tennix ChangeLog
152 zip tennix-$(RELEASE)-win32.zip tennix.exe $(WIN32LIBS) $(DATAFILES) ChangeLog
154 tennix-installer.iss: tennix-installer.iss.in
155 sed tennix-installer.iss.in -e 's/{version}/$(RELEASE)/g' >tennix-installer.iss
157 release-win32-setup: tennix ChangeLog tennix-installer.iss
158 iscc tennix-installer.iss
160 tennixres.o: tennix.res
161 windres tennix.res tennixres.o
162 # End Windows-specific targets
164 release-bin: tennix ChangeLog
165 tar czvf tennix-$(RELEASE)-bin.tar.gz tennix $(DATAFILES) ChangeLog
167 release: distclean ChangeLog
168 mkdir -p .release-tmp/tennix-$(RELEASE)/
169 cp -rv * .release-tmp/tennix-$(RELEASE)/
170 rm -rf .release-tmp/tennix-$(RELEASE)/.git
171 tar czvf tennix-$(RELEASE).tar.gz -C .release-tmp tennix-$(RELEASE)
172 rm -rf .release-tmp
174 clean:
175 rm -f *.o tennix tennix.exe archive archive.exe dump dump.exe
176 rm -rf $(OSXAPP) tennix-*-macosx.zip
177 rm -f tennixres.o tennix-installer.iss tennix-*-win32-setup.exe
178 rm -f tennix.tnx
180 distclean: clean
181 rm -rf tennix-$(RELEASE).zip tennix-$(RELEASE)-bin.tar.gz ChangeLog .release-tmp tennix-$(RELEASE).tar.gz
183 .PHONY: distclean clean release-bin release-win32 release-win32-setup release-osx install tennixar