1CC?=gcc 2 3SDLCONFIG=${SDL_CONFIG} 4 5ifndef prefix 6 prefix=${PREFIX} 7 #prefix=/usr 8endif 9 10ifndef datadir 11 datadir=$(prefix)/share 12endif 13 14ifndef mandir 15 mandir=$(prefix)/man 16endif 17 18ifndef bindir 19 bindir=$(prefix)/bin 20endif 21 22 23ifndef highscoredir 24 highscoredir=/var/games 25 #highscoredir=/var/lib/games 26endif 27 28 29CFLAGS+=-Wall $(SDL_CFLAGS) -DDATAPREFIX=\"$(datadir)/icebreaker\" -DHISCOREPREFIX=\"$(highscoredir)\" 30 31SRC=icebreaker.c cursor.c grid.c laundry.c line.c penguin.c sound.c \ 32 level.c intro.c text.c status.c transition.c hiscore.c dialog.c \ 33 menu.c options.c fullscreen.c themes.c event.c titlebar.c benchmark.c \ 34 misc.c lock.c delay.c 35 36DISTFILES=$(wildcard *.c *.h *.bmp *.ibt *.wav *.sh *.rc *.ico *.desktop *.man.in *.nsi.in *.spec README* TODO LICENSE INSTALL ChangeLog Makefile*) 37 38SDL_MIXER=-lSDL_mixer 39SDL_LIB=$(SDL_MIXER) $(SDL_LDFLAGS) 40SDL_CFLAGS := $(shell $(SDLCONFIG) --cflags) 41SDL_LDFLAGS := $(shell $(SDLCONFIG) --libs) 42VERSION := $(shell awk '/^\#define VERSION/ { print $$3 }' icebreaker.h) 43VERDATE := $(shell date -r $(shell stat -f %m icebreaker.h) +"%d %B %Y") 44 45CROSSTOOLSPATH=/usr/local/cross-tools 46# note that you almost certainly want to set wine to use the tty driver instead 47# of x11 -- can you do that on the command line? 48UNIX2DOS=unix2dos 49MAKENSIS=wine /usr/local/NSIS/makensis.exe 50 51RPMARCH=i386 52RPMOPTS= 53 54ifneq ($(VERSION),$(shell awk '/^Version:/ { print $$2 }' icebreaker.spec)) 55 $(error Version in spec file doesn't match version in icebreaker.h! ) 56endif 57 58RPMRELEASE := $(shell awk '/^\Release:/ { print $$2 }' icebreaker.spec) 59PRERELEASE := $(shell awk '/^\Release:/ { print $$2 }' icebreaker.spec | grep pre) 60 61ifneq ($(strip $(PRERELEASE)),) 62 ifeq ($(shell awk '/^%define.*isprerelease/ { print $$3 }' icebreaker.spec),0) 63 $(error .spec file has -pre release tag, but sets "isprerelease" to 0. Fix that) 64 endif 65 ifndef OPTIMIZE 66 OPTIMIZE=-g 67 endif 68 VERSIONSTRING := $(VERSION)-$(PRERELEASE) 69 $(warning Building prerelease version.) 70else 71 ifeq ($(shell awk '/^%define.*isprerelease/ { print $$3 }' icebreaker.spec),1) 72 $(error .spec file has final release tag, but sets "isprerelease" to 1. Fix that) 73 endif 74 ifndef OPTIMIZE 75 OPTIMIZE=-O3 76 endif 77 VERSIONSTRING := $(VERSION) 78endif 79 80 81all: icebreaker man 82 83.PHONY: clean 84clean: 85 [ -d icebreaker-$(VERSIONSTRING) ] && rm -rf icebreaker-$(VERSIONSTRING) || true 86 [ -d rpmbuild ] && rm -rf rpmbuild || true 87 [ -d win32.build ] && rm -rf win32.build || true 88 -rm -f icebreaker 89 -rm -f icebreaker.6 90 -rm -f icebreaker.nsi 91 -rm -f *.o 92 -rm -f *.d 93 -rm -f *.tgz 94 -rm -f *.zip 95 -rm -f *.exe 96 -rm -f *.rpm 97 98dist: tgz win32 rpm 99 ls -lh --color=yes icebreaker-$(VERSION)* 100 101tgz: icebreaker-$(VERSIONSTRING).tgz 102 103icebreaker-$(VERSIONSTRING).tgz: $(DISTFILES) 104 [ -d icebreaker-$(VERSIONSTRING) ] && rm -rf icebreaker-$(VERSIONSTRING) || true 105 mkdir icebreaker-$(VERSIONSTRING) 106 cp -p * icebreaker-$(VERSIONSTRING) || true 107 (cd icebreaker-$(VERSIONSTRING); make clean) 108 tar czf icebreaker-$(VERSIONSTRING).tgz icebreaker-$(VERSIONSTRING) 109 [ -d icebreaker-$(VERSIONSTRING) ] && rm -rf icebreaker-$(VERSIONSTRING) || true 110 tar tzf icebreaker-$(VERSIONSTRING).tgz 111 112rpm: srcrpm binrpm 113 114srcrpm: icebreaker-$(VERSION)-$(RPMRELEASE).src.rpm 115binrpm: $(RPMARCH)rpm 116$(RPMARCH)rpm: icebreaker-$(VERSION)-$(RPMRELEASE).$(RPMARCH).rpm 117 118icebreaker-$(VERSION)-$(RPMRELEASE).src.rpm: icebreaker-$(VERSIONSTRING).tgz icebreaker.spec 119 [ -d rpmbuild ] && rm -rf rpmbuild || true 120 mkdir -p rpmbuild/tmp 121 rpmbuild --rcfile /usr/lib/rpm/rpmrc:rpmrc -bs icebreaker.spec 122 [ -d rpmbuild ] && rm -rf rpmbuild || true 123 124icebreaker-$(VERSION)-$(RPMRELEASE).$(RPMARCH).rpm: icebreaker-$(VERSIONSTRING).tgz icebreaker.spec 125 [ -d rpmbuild ] && rm -rf rpmbuild || true 126 mkdir -p rpmbuild/tmp; mkdir -p rpmbuild/build 127 rpmbuild --rcfile /usr/lib/rpm/rpmrc:rpmrc -bb icebreaker.spec 128 [ -d rpmbuild ] && rm -rf rpmbuild || true 129 130win32: icebreaker-$(VERSIONSTRING).exe 131 132icebreaker-$(VERSIONSTRING).exe: icebreaker.nsi icebreaker-$(VERSIONSTRING).zip 133 [ -d icebreaker-$(VERSIONSTRING) ] && rm -rf icebreaker-$(VERSIONSTRING) || true 134 unzip -b icebreaker-$(VERSIONSTRING).zip 135 touch icebreaker-$(VERSIONSTRING)/lockhelper.lck 136 (cd icebreaker-$(VERSIONSTRING); \ 137 $(MAKENSIS) ../icebreaker.nsi; \ 138 test -f icebreaker-$(VERSIONSTRING).exe) 139 mv -f icebreaker-$(VERSIONSTRING)/icebreaker-$(VERSIONSTRING).exe icebreaker-$(VERSIONSTRING).exe 140 [ -d icebreaker-$(VERSIONSTRING) ] && rm -rf icebreaker-$(VERSIONSTRING) || true 141 ls -l icebreaker-$(VERSIONSTRING).exe 142 143zip: icebreaker-$(VERSIONSTRING).zip 144 145icebreaker-$(VERSIONSTRING).zip: icebreaker.exe icebreaker-$(VERSIONSTRING).tgz 146 [ -d icebreaker-$(VERSIONSTRING) ] && rm -rf icebreaker-$(VERSIONSTRING) || true 147 mkdir icebreaker-$(VERSIONSTRING) 148 cp icebreaker.exe icebreaker-$(VERSIONSTRING) 149 cp icebreaker-$(VERSIONSTRING).tgz icebreaker-$(VERSIONSTRING)/icebreaker-$(VERSIONSTRING)-src.tgz 150 cp $(CROSSTOOLSPATH)/i386-mingw32msvc/lib/SDL.dll icebreaker-$(VERSIONSTRING) 151 cp $(CROSSTOOLSPATH)/i386-mingw32msvc/lib/SDL_mixer.dll icebreaker-$(VERSIONSTRING) 152 cp *.wav icebreaker-$(VERSIONSTRING) 153 cp *.bmp icebreaker-$(VERSIONSTRING) 154 for i in *.ibt; do $(UNIX2DOS) -n $$i icebreaker-$(VERSIONSTRING)/$$i; done 155 $(UNIX2DOS) -n ChangeLog icebreaker-$(VERSIONSTRING)/ChangeLog.txt 156 $(UNIX2DOS) -n LICENSE icebreaker-$(VERSIONSTRING)/LICENSE.txt 157 $(UNIX2DOS) -n README icebreaker-$(VERSIONSTRING)/README.txt 158 $(UNIX2DOS) -n README.SDL icebreaker-$(VERSIONSTRING)/README-SDL.txt 159 $(UNIX2DOS) -n README.themes icebreaker-$(VERSIONSTRING)/README-themes.txt 160 $(UNIX2DOS) -n TODO icebreaker-$(VERSIONSTRING)/TODO.txt 161 zip -r icebreaker-$(VERSIONSTRING).zip icebreaker-$(VERSIONSTRING) 162 [ -d icebreaker-$(VERSIONSTRING) ] && rm -rf icebreaker-$(VERSIONSTRING) || true 163 unzip -t icebreaker-$(VERSIONSTRING).zip 164 165beos: 166 make -f Makefile.beos 167 168osx: 169 make -f Makefile.osx 170 171icebreaker.exe: $(DISTFILES) 172 [ -f $(CROSSTOOLSPATH)/i386-mingw32msvc/lib/SDL.dll ] 173 [ -d win32.build ] && rm -rf win32.build || true 174 mkdir win32.build 175 cp -p * win32.build || true 176 (cd win32.build; make clean; make -f Makefile.w32; mv icebreaker.exe ..) 177 [ -d win32.build ] && rm -rf win32.build || true 178 179icebreaker: $(SRC:.c=.o) 180 $(CC) $(LDFLAGS) $^ -o icebreaker $(SDL_LIB) 181 182man: icebreaker.6 183 184%.nsi: %.nsi.in icebreaker.spec icebreaker.h 185 sed 's/\%ICEBREAKERVERSION/$(VERSIONSTRING)/' $< > $@ 186 187%.6: %.man.in 188 sed 's/\$$VERSION/$(VERSION)/' $< | \ 189 sed 's/\$$VERDATE/$(VERDATE)/' | \ 190 sed 's?\$$HIGHSCOREDIR?$(highscoredir)/?' > $@ 191 192install-mkdirs: 193 mkdir -p ${DESTDIR}$(datadir)/icebreaker 194 mkdir -p ${DESTDIR}$(bindir) 195 mkdir -p ${DESTDIR}$(highscoredir) 196 mkdir -p ${DESTDIR}$(mandir)/man6 197 198themes-install: install-themes 199 200install-themes: 201 ${BSD_INSTALL_DATA} *.ibt ${DESTDIR}$(datadir)/icebreaker 202 ${BSD_INSTALL_DATA} *.wav *.bmp ${DESTDIR}$(datadir)/icebreaker 203 204install-bin: icebreaker 205 ${BSD_INSTALL_PROGRAM} icebreaker ${DESTDIR}$(bindir) 206 207install-man: icebreaker.6 208 ${BSD_INSTALL_MAN} icebreaker.6 ${DESTDIR}$(mandir)/man6 209 210install-scorefile: 211 touch ${DESTDIR}$(highscoredir)/icebreaker.scores.sample 212 213 214install: all install-mkdirs install-themes install-bin install-man install-scorefile 215 216%.d: %.c 217 set -e; $(CC) -M $(CFLAGS) $< \ 218 | sed 's/\($*\)\.o[ :]*/\1.o $@ : /g' > $@; \ 219 [ -s $@ ] || rm -f $@ 220 221include $(SRC:.c=.d) 222