1 2# Makefile for blinkensisters/LostPixels 3# 4# (C) 2006 Wolfgang Dautermann 5# See LICENSE for licensing information 6# 7# I believe, that some of the constructs are GNU Make specific, 8# so if GNU make is not the default make on your system, you will 9# need to install it (and then usually execute "gmake" instead of "make") 10# 11# I will try to make that build system as portable as possible, but if you have some trouble, 12# try using the GNU tools 13 14 15# Commands to use (if you have problems, try using the GNU versions (sometimes called gsed, gcp, gtar, ...)) 16CC=g++ 17GREP=grep 18SED=sed 19SDLCONFIG=sdl-config 20INSTALL=install 21MAKEDEPEND=makedepend 22CP=cp 23CD=cd 24RM=rm 25LN=ln 26FIND=find 27TAR=tar 28GZIP=gzip 29BZIP2=bzip2 30RPMBUILD=rpmbuild 31STRIP=strip 32 33PREFIX=/usr/local 34BINDIR=$(PREFIX)/bin 35SHAREDIR=$(PREFIX)/share/blinkensisters 36DOCDIR=$(PREFIX)/share/doc/blinkensisters 37MENUDIR=/usr/share/applications/ 38ICONDIR=/usr/share/pixmaps/ 39 40# track dependencies (will require the makedepend program, recommended for developers) 41# or not (then I recommend a "make clean" before each "make") 42# set either "DEPENDENCIES=" or "DEPENDENCIES=true") 43# 44# you can also call "make DEPENDENCIES=true" 45DEPENDENCIES= 46 47 48# get the version number from globals.h 49VERSION=$(shell $(GREP) "^.define VERSION " globals.h | $(SED) "s/^.define.VERSION.//" | $(SED) "s/\\\"//g" ) 50 51# sound support enabled in globals.h? 52DISABLESOUND=$(shell $(GREP) "^.define.DISABLE_SOUND" globals.h | $(SED) "s/^.define.//") 53# network support enabled in globals.h? 54DISABLENETWORK=$(shell $(GREP) "^.define.DISABLE_NETWORK" globals.h | $(SED) "s/^.define.//") 55 56CFLAGS += -c -I. -IBlinkenBMF/ -IBlinkenLUA/LuaSocket/headers/ -IBlinkenLUA/LuaBindings/headers/ -IBlinkenLUA/LuaMain/headers/ -IBlinkenLib/headers/ -ISDL_gfx/ 57CFLAGS += $(shell $(SDLCONFIG) --cflags) 58CFLAGS += -DRESPATH="\"$(SHAREDIR)/\"" 59# only on Gnu compilers: 60CFLAGS += -Wall -O3 61 62LDFLAGS = $(shell $(SDLCONFIG) --libs) 63 64LIBS = -lSDL -lSDL_image -lSDL_ttf 65ifneq ($(DISABLESOUND),DISABLE_SOUND) 66LIBS += -lSDL_mixer 67else 68$(warning "Sound disabled. If you want to enable sound support, you can do this by commenting out the DISABLE_SOUND define in globals.h") 69endif 70 71ifneq ($(DISABLENETWORK),DISABLE_NETWORK) 72LIBS += -lSDL_net 73else 74$(warning "Network disabled. If you want to enable networking support, you can do this by commenting out the DISABLE_NETWORK define in globals.h") 75endif 76 77LOSTPIXELSOURCES = ${wildcard *.cpp BlinkenLUA/LuaSocket/source/*.cpp BlinkenLUA/LuaBindings/source/*.cpp BlinkenLUA/LuaMain/source/*.cpp BlinkenBMF/minilzo.cpp BlinkenBMF/bmfconvert.cpp BlinkenLib/source/*.cpp SDL_gfx/*.cpp} 78BMFCOMPRESSSOURCES = BlinkenBMF/minilzo.cpp BlinkenBMF/bmfcompress.cpp BlinkenBMF/bmfconvert.cpp 79BMFDECOMPRESSSOURCES = BlinkenBMF/minilzo.cpp BlinkenBMF/bmfdecompress.cpp BlinkenBMF/bmfconvert.cpp 80 81HEADERS = $(wildcard *.h BlinkenLUA/source/*.h BlinkenBMF/*.h BlinkenLUA/LuaSocket/headers/*.h BlinkenLUA/LuaBindings/headers/*.h BlinkenLUA/LuaMain/headers/*.h BlinkenLib/headers/*.h SDL_gfx/*.h) 82 83LOSTPIXELOBJECTS = $(LOSTPIXELSOURCES:.cpp=.o) 84BMFCOMPRESSOBJECTS = $(BMFCOMPRESSSOURCES:.cpp=.o) 85BMFDECOMPRESSOBJECTS = $(BMFDECOMPRESSSOURCES:.cpp=.o) 86 87# the name of the package - used as name of the generated tar.gz, tar.bz2, rpm, ... 88PACKAGENAME = LostPixels 89 90# Enable "make install DESTDIR=some-path" to make it easier 91# to build RPMs, DEBs, ... 92DESTDIR= 93 94 95all: LostPixels bmfcompress bmfdecompress basedata.bmf blinkenplayer 96 97LostPixels: $(LOSTPIXELOBJECTS) Makefile 98 $(CC) $(LDFLAGS) $(LOSTPIXELOBJECTS) -o $@ $(LIBS) 99 100bmfcompress: $(BMFCOMPRESSOBJECTS) Makefile 101 $(CC) $(LDFLAGS) $(BMFCOMPRESSOBJECTS) -o $@ 102 103bmfdecompress: $(BMFDECOMPRESSOBJECTS) Makefile 104 $(CC) $(LDFLAGS) $(BMFDECOMPRESSOBJECTS) -o $@ 105 106blinkenplayer: BlinkenPlayer/*.cpp BlinkenPlayer/*.h *.cpp *.h 107ifneq ($(DISABLESOUND),DISABLE_SOUND) 108 $(MAKE) -C BlinkenPlayer 109else 110 @echo "BlinkenPlayer will not be build - sound disabled" 111endif 112 113.cpp.o: Makefile 114 $(CC) $(CFLAGS) $< -o $@ 115 116basedata.bmf: bmfcompress BASEDATA/config BASEDATA/GFX/* BASEDATA/SND/* BASEDATA/TTF/* BASEDATA/LEVELS/* 117 $(CD) BASEDATA ; ../bmfcompress META config ../basedata.bmf 118 119install: LostPixels bmfcompress bmfdecompress basedata.bmf blinkenplayer 120 $(INSTALL) -m 755 -d ${DESTDIR}${BINDIR} 121 $(INSTALL) -m 755 -d ${DESTDIR}${SHAREDIR} 122 $(INSTALL) -m 755 -d ${DESTDIR}${DOCDIR} 123 $(CP) LostPixels ${DESTDIR}${BINDIR} 124 $(CP) bmfcompress ${DESTDIR}${BINDIR} 125 $(CP) bmfdecompress ${DESTDIR}${BINDIR} 126 $(CP) basedata.bmf ${DESTDIR}$(SHAREDIR) 127ifneq ($(DISABLESOUND),DISABLE_SOUND) 128 $(CP) blinkenplayer ${DESTDIR}${BINDIR} 129endif 130 $(CP) DOC/* ${DESTDIR}$(DOCDIR) 131 $(CP) BASEDATA/GFX/splash.jpg ${DESTDIR}$(SHAREDIR) 132 $(CP) BASEDATA/TTF/*.ttf ${DESTDIR}$(SHAREDIR) 133 ## create a "blinkensisters" symlink for compatibility with previous versions. 134 #$(CD) ${DESTDIR}${BINDIR} ; $(LN) -s $(EXECUTABLE) blinkensisters 135 136uninstall: 137 $(RM) ${DESTDIR}${BINDIR}/LostPixels 138 $(RM) ${DESTDIR}${BINDIR}/bmfcompress 139 $(RM) ${DESTDIR}${BINDIR}/bmfdecompress 140 $(RM) ${DESTDIR}${SHAREDIR}/basedata.bmf 141ifneq ($(DISABLESOUND),DISABLE_SOUND) 142 $(RM) ${DESTDIR}${BINDIR}/blinkenplayer 143endif 144 #$(RM) ${DESTDIR}${BINDIR}/blinkensisters # symlink for compatibility with previous versions. 145 $(RM) -rf ${DESTDIR}$(SHAREDIR) 146 $(RM) -rf ${DESTDIR}$(DOCDIR) 147 148menu-install: 149 $(INSTALL) -m 755 -d ${DESTDIR}$(MENUDIR) 150 $(INSTALL) -m 755 -d ${DESTDIR}$(ICONDIR) 151 $(CP) LostPixels.desktop ${DESTDIR}$(MENUDIR) 152 $(CP) BASEDATA/GFX/lostpixels.ico ${DESTDIR}$(ICONDIR) 153ifneq ($(DISABLESOUND),DISABLE_SOUND) 154 $(CP) BlinkenPlayer.desktop ${DESTDIR}$(MENUDIR) 155 $(CP) BASEDATA/GFX/blinkenplayer.ico ${DESTDIR}$(ICONDIR) 156endif 157 158menu-uninstall: 159 $(RM) ${DESTDIR}$(MENUDIR)/LostPixels.desktop 160 $(RM) ${DESTDIR}$(ICONDIR)/lostpixels.ico 161ifneq ($(DISABLESOUND),DISABLE_SOUND) 162 $(RM) ${DESTDIR}$(MENUDIR)/BlinkenPlayer.desktop 163 $(RM) ${DESTDIR}$(ICONDIR)/blinkenplayer.ico 164endif 165 166 167# currently not used (als library) in our project, may be useful for other projects? 168# FIXME: Naming of the library? Is a such small library useful? 169libsmallcmdopt.a: cmdopts.h cmdopts.o 170 ar rc $@ cmdopts.o 171 ranlib $@ 172 173clean: 174 $(RM) -f LostPixels bmfcompress bmfdecompress basedata.bmf $(LOSTPIXELOBJECTS) $(BMFCOMPRESSOBJECTS) $(BMFDECOMPRESSOBJECTS) 175 $(RM) -f $(PACKAGENAME)-$(VERSION).tar $(PACKAGENAME)-$(VERSION).tar.gz $(PACKAGENAME)-$(VERSION).tar.bz2 176 $(RM) -rf cmake-build/* 177 $(MAKE) -C BlinkenPlayer clean 178 @echo "# DO NOT DELETE" >.depend 179 180strip: LostPixels bmfcompress bmfdecompress blinkenplayer 181 $(STRIP) LostPixels 182 $(STRIP) bmfcompress 183 $(STRIP) bmfdecompress 184ifneq ($(DISABLESOUND),DISABLE_SOUND) 185 $(STRIP) blinkenplayer 186endif 187 188 189#### Usage 190help: 191 @echo "Useful make targets:" 192 @echo " all - build all as needed (default)" 193 @echo " install - install files" 194 @echo " uninstall - remove installed files" 195 @echo " menu-install - integration in Windowmanager (KDE,...) menu" 196 @echo " menu-uninstall - remove integration in Windowmanager (KDE,...) menu" 197 @echo " clean - remove all generated files" 198 @echo " tar - build a tar-archive of all files" 199 @echo " tar.gz - build a tar.gz-archive of all files" 200 @echo " tar.bz2 - build a tar.bz2-archive of all files" 201 @echo " rpm - build rpm package (experimental)" 202 @echo " (read the comments in the Makefile before using that target)" 203 @echo " solaris-pkg - build solaris package (experimental)" 204 @echo " help - display this help" 205 @echo 206 @echo " You can add the following variables to the build process:" 207 @echo " make PREFIX=/path/to/somewhere" 208 @echo " make install PREFIX=/path/to/somewhere" 209 @echo " Build and installs in /path/to/somewhere instead /usr/local" 210 @echo 211 @echo " make DEPENDENCIES=true" 212 @echo " build LostPixels using full dependency tracking." 213 @echo " (needs the 'makedepend'-program which is often not installed" 214 @echo " - so this is not the default)" 215 @echo " If you do not build using full dependency tracking a warning is given" 216 @echo " I recommend always do a 'make clean' before a new 'make' in that case" 217 218 219 220# Every Makefile should have that targets 221love: 222 @echo "Not war!" 223war: 224 @echo "No! Make love!" 225 226 227ifdef DEPENDENCIES 228# rule for building dependency lists, and writing them to a file ".depend". 229.depend: $(LOSTPIXELSOURCES) $(BMFCOMPRESSSOURCES) $(BMFDECOMPRESSSOURCES) $(HEADERS) 230 @echo "# DO NOT DELETE" >.depend 231 $(MAKEDEPEND) -f- -- $(CFLAGS) -- $(LOSTPIXELSOURCES) $(BMFCOMPRESSSOURCES) $(BMFDECOMPRESSSOURCES) $(HEADERS) > .depend 232else 233# output a warning, that no full dependency tracking is enabled by default 234$(warning "Warning: no full dependency tracking (regarding the c++-files) enabled (one needs the 'makedepend' program for that task and often it is not installed). I suggest either a 'make clean' before a new build or doing a 'make DEPENDENCIES=true' (which will enable full dependency tracking)") 235 236endif 237 238tar: clean 239 $(LN) -s . $(PACKAGENAME)-$(VERSION) 240 $(FIND) $(PACKAGENAME)-$(VERSION)/ -type f -o -type l | $(GREP) -v .svn | $(TAR) -T - -cvf $(PACKAGENAME)-$(VERSION).tar 241 $(RM) $(PACKAGENAME)-$(VERSION) 242 243tar.gz: tar 244 $(GZIP) $(PACKAGENAME)-$(VERSION).tar 245 246 247tar.bz2: tar 248 $(BZIP2) $(PACKAGENAME)-$(VERSION).tar 249 250# 251# "make rpm" will work only (on RPM-based systems, of course) if you have 252# write permissions to /usr/src/rpm/* (usually only root) or you 253# tell rpm to use a different build area, see 254# http://www.rpm.org/max-rpm/s1-rpm-anywhere-different-build-area.html 255# 256rpm: tar.gz 257 $(RPMBUILD) --define 'version $(VERSION)' -ta $(PACKAGENAME)-${VERSION}.tar.gz 258 259 260# experimental target for creating solaris packages 261solaris-pkg: 262 $(MAKE) install DESTDIR=/tmp/blinkensisterspackage 263 (echo 'i pkginfo'; pkgproto /tmp/blinkensisterspackage=/ ) >prototype 264 pkgmk -o 265 pkgtrans -s /var/spool/pkg /tmp/blinkensisters.pkg blinkensisters 266 rm -rf /var/spool/pkg/blinkensisters 267 rm -rf /tmp/blinkensisterspackage 268 @echo "Package written to /tmp/blinkensisters.pkg" 269 @echo "you can install it now using "pkgadd -d /tmp/blinkensisters.pkg" 270 271.PHONY: clean .depend 272 273# include a dependency file if one exists 274ifdef DEPENDENCIES 275ifeq (.depend,$(wildcard .depend)) 276include .depend 277endif 278endif 279