Streamline building Tennix on Mac OS X (static)
[tennix.git] / makefile
blob9053514e5466afe1adec823fae0b04dfa75c55bf
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 = 1.0
30 UNAME = $(shell uname)
32 PREFIX ?= /usr/local
33 BINDIR ?= $(PREFIX)/bin
34 DATAROOTDIR ?= $(PREFIX)/share
35 DATADIR ?= $(DATAROOTDIR)/games
37 LIBS =
38 CFLAGS += -std=c99 -W -Wall -ansi -pedantic -Wcast-qual -Wwrite-strings -DVERSION=\"$(RELEASE)\" -O2 -DPREFIX=\"$(PREFIX)\" -g
40 USE_PYTHON ?= 1
41 PYTHON_VERSION = 2.5
43 ifeq ($(USE_PYTHON),1)
44 CFLAGS += -I/usr/include/python$(PYTHON_VERSION)/ -DTENNIX_PYTHON
45 LIBS += -lpython$(PYTHON_VERSION)
46 endif
48 ifeq ($(NONFREE_LOCATIONS),1)
49 CFLAGS += -DNONFREE_LOCATIONS
50 endif
52 ifeq ($(UPDRECTANGLE),1)
53 CFLAGS += -DDRAW_UPDATE_RECTANGLE
54 endif
56 ifeq ($(DELUXE),1)
57 CFLAGS += -DDELUXE_EDITION
58 endif
60 ifeq ($(DEBUG),1)
61 CFLAGS += -DDEBUG
62 endif
64 ifeq ($(MAEMO),1)
65 CFLAGS += -DMAEMO
66 endif
68 ifeq ($(UNAME),Darwin)
69 SDLLIBS=$$(sdl-config --prefix)/lib
70 LIBS += $$(sdl-config --static-libs) $(SDLLIBS)/libSDL_mixer.a $(SDLLIBS)/libSDL_image.a $(SDLLIBS)/libSDL_ttf.a $$(freetype-config --prefix)/lib/libfreetype.a
71 CFLAGS += $$(sdl-config --cflags) -lz
72 else
73 LIBS += $$(sdl-config --libs) -lSDL_mixer -lSDL_image -lSDL_ttf
74 CFLAGS += $$(sdl-config --cflags)
75 endif
77 SRC = tennix.c game.c graphics.c input.c util.c sound.c animation.c
78 OBJ = tennix.o game.o graphics.o input.o util.o sound.o animation.o archive-lib.o SDL_rotozoom.o
79 ifeq ($(MSYSTEM),MINGW32)
80 OBJ += tennixres.o
81 endif
82 ifeq ($(USE_PYTHON),1)
83 OBJ += tennixpy.o
84 endif
86 TOARCHIVE=$(wildcard data/*.ogg data/*.ttf wildcard data/*.png voice/*.ogg *.py)
88 WIN32LIBS = *.dll
89 OSXAPP = Tennix.app
91 DATAFILES = README README.*
92 DATAFILES_OSX = $(DATAFILES) data/Tennix.icns
94 tennix: $(OBJ) tennix.tnx
95 $(CC) $(CFLAGS) -o tennix $(OBJ) $(LIBS)
96 test -f tennix.exe && upx tennix.exe || true
98 ChangeLog:
99 git log >ChangeLog
101 install: tennix
102 install -d -m 755 $(DESTDIR)$(BINDIR)
103 install -d -m 755 $(DESTDIR)$(DATAROOTDIR)/pixmaps
104 install -d -m 755 $(DESTDIR)$(DATAROOTDIR)/applications
105 install -d -m 755 $(DESTDIR)$(DATAROOTDIR)/man/man6
106 install -d -m 755 $(DESTDIR)$(DATAROOTDIR)/icons/hicolor/scalable/apps
107 install -d -m 755 $(DESTDIR)$(DATADIR)/tennix
108 install -m 755 tennix $(DESTDIR)$(BINDIR)/
109 install -m 644 tennix.6 $(DESTDIR)$(DATAROOTDIR)/man/man6/
110 install -m 644 data/icon.png $(DESTDIR)$(DATAROOTDIR)/pixmaps/tennix.png
111 install -m 644 data/icon.svg $(DESTDIR)$(DATAROOTDIR)/icons/hicolor/scalable/apps/tennix.svg
112 install -m 644 tennix.desktop $(DESTDIR)$(DATAROOTDIR)/applications/
113 install -m 644 tennix.tnx $(DESTDIR)$(DATADIR)/tennix/
115 tennix.o: tennix.c tennix.h game.h graphics.h input.h util.h animation.h sound.h locations.h util.h
116 graphics.o: graphics.c graphics.h tennix.h archive.h sound.h
117 game.o: game.c game.h graphics.h tennix.h sound.h input.h util.h
118 sound.o: sound.c sound.h tennix.h archive.h graphics.h
119 input.o: input.c input.h tennix.h graphics.h game.h util.h tennixpy.h
120 util.o: util.c util.h tennix.h
121 animation.o: animation.c animation.h graphics.h tennix.h credits.h
122 tennixpy.o: tennix.c tennix.h game.h archive.h
123 SDL_rotozoom.o: SDL_rotozoom.c SDL_rotozoom.h
125 archive-lib.o: archive.c archive.h
126 $(CC) -c -o $@ $<
128 tennixar: archive dump
130 archive.o: archive.c archive.h
131 $(CC) $(CFLAGS) -DTENNIXAR_STANDALONE -c -o $@ $<
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