Code clean-ups and makefile optimizations
[tennix.git] / makefile
blobfe160886ff426bf9bc26506c23ef4ab79af52f25
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.1.1
32 PREFIX ?= /usr/local
33 BINDIR ?= $(PREFIX)/bin
34 DATAROOTDIR ?= $(PREFIX)/share
35 DATADIR ?= $(DATAROOTDIR)/games
37 CFLAGS += -W -Wall -DVERSION=\"$(RELEASE)\" -O2 -DPREFIX=\"$(PREFIX)\"
38 CXXFLAGS += $(CFLAGS)
40 USE_PYTHON ?= 1
42 ifeq ($(USE_PYTHON),1)
43 PYTHON_INCLUDES := $(shell python-config --includes)
44 PYTHON_LIBS := $(shell python-config --libs)
45 CFLAGS += $(PYTHON_INCLUDES) -DTENNIX_PYTHON
46 LIBS += $(PYTHON_LIBS)
47 endif
49 ifeq ($(NONFREE_LOCATIONS),1)
50 CFLAGS += -DNONFREE_LOCATIONS
51 endif
53 ifeq ($(UPDRECTANGLE),1)
54 CFLAGS += -DDRAW_UPDATE_RECTANGLE
55 endif
57 ifeq ($(DELUXE),1)
58 CFLAGS += -DDELUXE_EDITION
59 endif
61 ifeq ($(DEBUG),1)
62 CFLAGS += -DDEBUG
63 endif
65 ifeq ($(MAEMO),1)
66 CFLAGS += -DMAEMO
67 endif
69 SDL_LIBS := $(shell sdl-config --libs)
70 SDL_CFLAGS := $(shell sdl-config --cflags)
72 LIBS += $(SDL_LIBS) -lSDL_mixer -lSDL_image -lSDL_ttf -lSDL_net
73 CFLAGS += $(SDL_CFLAGS)
75 OBJ = tennix.o game.o graphics.o input.o util.o sound.o animation.o archive.o SDL_rotozoom.o network.o
77 ifeq ($(MSYSTEM),MINGW32)
78 OBJ += tennixres.o
79 endif
80 ifeq ($(USE_PYTHON),1)
81 OBJ += tennixpy.o
82 endif
84 TOARCHIVE=$(wildcard data/*.ogg data/*.ttf wildcard data/*.png voice/*.ogg *.py)
86 WIN32LIBS = *.dll
87 OSXAPP = Tennix.app
89 DATAFILES = README README.*
90 DATAFILES_OSX = $(DATAFILES) data/Tennix.icns
92 tennix: $(OBJ) tennix.tnx
93 $(CC) $(CFLAGS) -o tennix $(OBJ) $(LIBS)
94 test -f tennix.exe && upx tennix.exe || true
96 ChangeLog:
97 git log >ChangeLog
99 install: tennix
100 install -d -m 755 $(DESTDIR)$(BINDIR)
101 install -d -m 755 $(DESTDIR)$(DATAROOTDIR)/pixmaps
102 install -d -m 755 $(DESTDIR)$(DATAROOTDIR)/applications
103 install -d -m 755 $(DESTDIR)$(DATAROOTDIR)/man/man6
104 install -d -m 755 $(DESTDIR)$(DATAROOTDIR)/icons/hicolor/scalable/apps
105 install -d -m 755 $(DESTDIR)$(DATADIR)/tennix
106 install -m 755 tennix $(DESTDIR)$(BINDIR)/
107 install -m 644 tennix.6 $(DESTDIR)$(DATAROOTDIR)/man/man6/
108 install -m 644 data/icon.png $(DESTDIR)$(DATAROOTDIR)/pixmaps/tennix.png
109 install -m 644 data/icon.svg $(DESTDIR)$(DATAROOTDIR)/icons/hicolor/scalable/apps/tennix.svg
110 install -m 644 tennix.desktop $(DESTDIR)$(DATAROOTDIR)/applications/
111 install -m 644 tennix.tnx $(DESTDIR)$(DATADIR)/tennix/
113 archive.o: archive.cc archive.cc
114 tennix.o: tennix.cc tennix.h game.h graphics.h input.h util.h animation.h sound.h locations.h util.h archive.hh
115 graphics.o: graphics.cc graphics.h tennix.h archive.hh sound.h
116 game.o: game.c game.h graphics.h tennix.h sound.h input.h util.h network.h
117 sound.o: sound.cc sound.h tennix.h archive.hh graphics.h
118 input.o: input.c input.h tennix.h graphics.h game.h util.h tennixpy.h archive.hh
119 util.o: util.c util.h tennix.h
120 animation.o: animation.c animation.h graphics.h tennix.h credits.h
121 tennixpy.o: tennixpy.cc tennix.h game.h archive.hh
122 network.o: network.c network.h game.h
123 SDL_rotozoom.o: SDL_rotozoom.c SDL_rotozoom.h
125 tennixar: archive dump
127 archive: archivetool.cc archive.o archive.hh
129 dump: archive
130 ln -s archive dump
132 tennix.tnx: archive $(TOARCHIVE)
133 rm -f tennix.tnx
134 ./archive $@ $(TOARCHIVE)
136 # Mac OS X-specific targets
137 release-osx: tennix tennix.tnx ChangeLog
138 mkdir -p $(OSXAPP)/Contents/{MacOS,/Resources}
139 cp -rpv tennix $(OSXAPP)/Contents/MacOS/Tennix
140 cp -rpv tennix.tnx $(DATAFILES_OSX) ChangeLog $(OSXAPP)/Contents/Resources/
141 sed -e 's/TENNIX_VERSION/$(RELEASE)/' osxapp.plist >$(OSXAPP)/Contents/Info.plist
142 echo 'APPL????' >$(OSXAPP)/Contents/PkgInfo
143 zip -r tennix-$(RELEASE)-macosx.zip $(OSXAPP)
144 # End Mac OS X-specific targets
146 # Windows-specific targets
147 release-win32: tennix ChangeLog
148 zip tennix-$(RELEASE)-win32.zip tennix.exe $(WIN32LIBS) $(DATAFILES) ChangeLog
150 tennix-installer.iss: tennix-installer.iss.in
151 sed tennix-installer.iss.in -e 's/{version}/$(RELEASE)/g' >tennix-installer.iss
153 release-win32-setup: tennix ChangeLog tennix-installer.iss
154 iscc tennix-installer.iss
156 tennixres.o: tennix.res
157 windres tennix.res tennixres.o
158 # End Windows-specific targets
160 release-bin: tennix ChangeLog
161 tar czvf tennix-$(RELEASE)-bin.tar.gz tennix $(DATAFILES) ChangeLog
163 release: distclean ChangeLog
164 mkdir -p .release-tmp/tennix-$(RELEASE)/
165 cp -rv * .release-tmp/tennix-$(RELEASE)/
166 rm -rf .release-tmp/tennix-$(RELEASE)/.git
167 tar czvf tennix-$(RELEASE).tar.gz -C .release-tmp tennix-$(RELEASE)
168 rm -rf .release-tmp
170 clean:
171 rm -f *.o tennix tennix.exe archive archive.exe dump dump.exe
172 rm -rf $(OSXAPP) tennix-*-macosx.zip
173 rm -f tennixres.o tennix-installer.iss tennix-*-win32-setup.exe
174 rm -f tennix.tnx
176 distclean: clean
177 rm -rf tennix-$(RELEASE).zip tennix-$(RELEASE)-bin.tar.gz ChangeLog .release-tmp tennix-$(RELEASE).tar.gz
179 .PHONY: distclean clean release-bin release-win32 release-win32-setup release-osx install tennixar