1# Makefile for tuxpaint-config 2 3# Tux Paint Configuration Tool - A GUI-based configurator for 4# Tux Paint, a simple drawing program for children. 5 6# Torsten Giebl <wizard@turricane.org> 7# Jan Wynholds 8# Bill Kendrick <bill@newbreedsoftware.com> 9# Martin Fuhrer <mfuhrer@gmail.com> 10 11# http://www.tuxpaint.org/ 12 13# November 12, 2002 - July 6, 2009 14# $Id: Makefile,v 1.39 2009/07/06 16:21:09 wkendrick Exp $ 15 16 17VER_VERSION=0.0.13 18VER_DATE=`date +"%Y-%m-%d"` 19 20 21# Where to install things: 22 23PREFIX=/usr/local 24 25 26# Program: 27 28BIN_PREFIX=$(PREFIX)/bin 29EXE_EXT= 30 31 32# Data: 33 34DATA_PREFIX=$(PREFIX)/share/tuxpaint-config/ 35 36 37# Docs and man page: 38 39DOC_PREFIX=$(PREFIX)/share/doc/tuxpaint-config/ 40MAN_PREFIX=$(PREFIX)/share/man/ 41 42 43# Tux Paint's 'System-wide' Config file: 44 45ifeq ($(PREFIX),/usr) 46 CONFDIR=/etc/tuxpaint 47else 48 CONFDIR=$(PREFIX)/etc/tuxpaint 49endif 50 51 52# Icons and launchers: 53 54ICON_PREFIX=$(PREFIX)/share/pixmaps/ 55X11_ICON_PREFIX=$(PREFIX)/X11R6/include/X11/pixmaps/ 56GNOME_PREFIX=$(shell gnome-config --prefix 2> /dev/null) 57KDE_PREFIX=$(shell kde-config --install apps --expandvars 2> /dev/null) 58KDE_ICON_PREFIX=$(shell kde-config --install icon --expandvars 2> /dev/null) 59 60 61# Locale files 62 63LOCALE_PREFIX=$(PREFIX)/share/locale/ 64# LOCALE_PREFIX=/usr/share/locale/ 65 66 67# Built with sound by default (override with "make nosound") 68 69NOSOUNDFLAG=__SOUND 70 71 72# Libraries, paths, and flags: 73 74# FIXME: UTF-8 required for translations; we need to see if we can 75# use fltk-utf8 (and fallback to regular fltk, if not). 76# I did not have luck using fltk-utf8, even in English, though :( 77# -bjk 2008.07.16 78#FLTK_CFLAGS=`fltk-utf8-config --cxxflags` 79#FLTK_LIBS=`fltk-utf8-config --ldflags` 80 81FLTK_CFLAGS=`fltk-config --cxxflags` 82FLTK_LIBS=`fltk-config --ldflags` 83 84PAPER_LIB=-lpaper 85 86# Default CFLAGS: 87CFLAGS=-O2 -Wall 88 89# The entire set of CFLAGS: 90ALL_CFLAGS=$(CFLAGS) $(FLTK_CFLAGS) -DDATA_PREFIX=\"$(DATA_PREFIX)\" \ 91 -D$(NOSOUNDFLAG) -DDOC_PREFIX=\"$(DOC_PREFIX)\" \ 92 -DLOCALEDIR=\"$(LOCALE_PREFIX)\" -DCONFDIR=\"$(CONFDIR)\" \ 93 -DVER_VERSION=\"$(VER_VERSION)\" -DVER_DATE=\"$(VER_DATE)\" 94 95 96# "make" with no arguments builds the program and man page from sources: 97 98all: tuxpaint-config translations 99 @echo 100 @echo "Done compiling." 101 @echo "Now (probably as 'root' superuser), run 'make install'" 102 @echo "to install Tux Paint Configuration Tool." 103 @echo 104 105releaseclean: 106 @echo 107 @echo "Cleaning release directory" 108 @echo 109 @rm -rf "build/tuxpaint-config-$(VER_VERSION)" "build/tuxpaint-config-$(VER_VERSION).tar.gz" 110 @-if [ -d build ] ; then rmdir build ; fi 111 112releasedir: build/tuxpaint-config-$(VER_VERSION) 113 114build/tuxpaint-config-$(VER_VERSION): 115 @echo 116 @echo "Creating release directory" 117 @echo 118 @mkdir -p build/tuxpaint-config-$(VER_VERSION) 119 @find . -follow \ 120 \( -wholename '*/CVS' -o -name .cvsignore -o -name 'build' -o -name '.#*' \) \ 121 -prune -o -type f -exec cp --parents -vdp \{\} build/tuxpaint-config-$(VER_VERSION)/ \; 122 123release: releasedir 124 @echo 125 @echo "Creating release tarball" 126 @echo 127 @cd build ; \ 128 tar -czvf tuxpaint-config-$(VER_VERSION).tar.gz \ 129 tuxpaint-config-$(VER_VERSION) 130 131 132win32: 133 make \ 134 EXE_EXT=.exe \ 135 ICON_PREFIX=./ \ 136 X11_ICON_PREFIX=./ \ 137 CONFDIR=$(PREFIX)/etc/tuxpaint \ 138 ARCH_LINKS=$(shell if [ "x$$OSTYPE" == "xcygwin" ]; then echo -n "-lintl"; else echo -n "-lintl-8"; fi ) \ 139 ARCH_LIBS="obj/resource.o obj/win32utils.o" \ 140 PAPER_LIB= 141 142install-win32: 143 @strip -s tuxpaint-config.exe 144 make install \ 145 EXE_EXT=.exe \ 146 ICON_PREFIX=./ \ 147 X11_ICON_PREFIX=./ \ 148 CONFDIR=$(PREFIX)/etc/tuxpaint \ 149 ARCH_LINKS=$(shell if [ "x$$OSTYPE" == "xcygwin" ]; then echo -n "-lintl"; else echo -n "-lintl-8"; fi ) \ 150 ARCH_LIBS="obj/resource.o obj/win32utils.o" 151 152# "make install" installs all of the various parts 153# (depending on the *PREFIX variables at the top, you probably need 154# to do this as superuser ("root")) 155 156install: install-bin install-data install-man install-doc \ 157 install-gnome install-kde install-kde-icons \ 158 install-icon install-gettext 159 @echo 160 @echo "All done! Now (preferably NOT as 'root' superuser)," 161 @echo "you can type the command 'tuxpaint-config' to run the" 162 @echo "configuration tool!" 163 @echo 164 @echo "Enjoy!" 165 @echo 166 167 168# "make clean" deletes the program, the compiled objects and the 169# built man page (returns to factory archive, pretty much...) 170 171clean: 172 @echo "Cleaning up the build directory ($(PWD))" 173 @-rm -f tuxpaint-config tuxpaint-config.exe 174 @-rm -f obj/*.o 175 @#if [ -d obj ]; then rmdir obj; fi 176 @-rm -f trans/*.mo 177 @if [ -d trans ]; then rmdir trans; fi 178 179 180# "make uninstall" should remove the various parts from their 181# installation locations. BE SURE the *PREFIX variables at the top 182# are the same as they were when you installed, of course!!! 183 184uninstall: 185 -if [ "x$(GNOME_PREFIX)" != "x" ]; then \ 186 rm $(GNOME_PREFIX)/share/applications/tuxpaint-config.desktop; \ 187 rm $(GNOME_PREFIX)/share/pixmaps/tuxpaint-config.png; \ 188 fi 189 -if [ "x$(KDE_PREFIX)" != "x" ]; then \ 190 rm $(KDE_PREFIX)/Preferences/tuxpaint-config.desktop; \ 191 fi 192 -rm $(ICON_PREFIX)tuxpaint-config.png 193 -rm $(X11_ICON_PREFIX)tuxpaint-config.xpm 194 -rm $(BIN_PREFIX)/tuxpaint-config 195 -rm -r $(DATA_PREFIX) 196 -rm -r $(DOC_PREFIX) 197 -rm $(MAN_PREFIX)/man1/tuxpaint-config.1.gz 198 199 200# Install a launcher icon in the Gnome menu, under "Graphhics" 201 202install-gnome: 203 @echo 204 @echo "...Installing launcher icon into GNOME..." 205 @if [ "x$(GNOME_PREFIX)" != "x" ]; then \ 206 install -d $(DESTDIR)$(GNOME_PREFIX)/share/pixmaps; \ 207 $(BSD_INSTALL_DATA) data/images/icon.png $(DESTDIR)$(GNOME_PREFIX)/share/pixmaps/tuxpaint-config.png; \ 208 install -d $(DESTDIR)$(GNOME_PREFIX)/share/applications; \ 209 $(BSD_INSTALL_DATA) src/tuxpaint-config.desktop $(DESTDIR)$(GNOME_PREFIX)/share/applications/; \ 210 fi 211 212 213# Install a launcher icon in the KDE menu... 214 215install-kde: 216 @echo 217 @echo "...Installing launcher icon into KDE..." 218 @if [ "x$(KDE_PREFIX)" != "x" ]; then \ 219 install -d $(DESTDIR)$(KDE_PREFIX)/Preferences/; \ 220 $(BSD_INSTALL_DATA) src/tuxpaint-config.desktop $(DESTDIR)$(KDE_PREFIX)/Preferences/; \ 221 fi 222 223 224install-kde-icons: 225 @echo "...Installing launcher icon graphics into KDE..." 226 @if [ "x$(KDE_ICON_PREFIX)" != "x" ]; then \ 227 cp data/images/icon48x48.png \ 228 $(KDE_ICON_PREFIX)/hicolor/48x48/apps/tuxpaint-config.png; \ 229 cp data/images/icon32x32.png \ 230 $(KDE_ICON_PREFIX)/hicolor/32x32/apps/tuxpaint-config.png; \ 231 cp data/images/icon16x16.png \ 232 $(KDE_ICON_PREFIX)/hicolor/16x16/apps/tuxpaint-config.png; \ 233 fi 234 235 236# Install the PNG icon (for GNOME, KDE, etc.) 237# and the 24-color 32x32 XPM (for other Window managers): 238 239install-icon: 240 @echo 241 @echo "...Installing launcher icon graphics..." 242 @install -d $(DESTDIR)$(ICON_PREFIX) 243 $(BSD_INSTALL_DATA) data/images/icon.png $(DESTDIR)$(ICON_PREFIX)tuxpaint-config.png 244 @install -d $(DESTDIR)$(X11_ICON_PREFIX) 245 $(BSD_INSTALL_DATA) data/images/icon32x32.xpm $(DESTDIR)$(X11_ICON_PREFIX)tuxpaint-config.xpm 246 247 248# Install the program: 249 250install-bin: 251 @echo 252 @echo "...Installing program itself..." 253 $(BSD_INSTALL_PROGRAM) tuxpaint-config $(DESTDIR)$(BIN_PREFIX) 254 255 256# Install the data (sound, graphics, fonts): 257 258install-data: 259 @echo 260 @echo "...Installing data files..." 261 @install -d $(DESTDIR)$(DATA_PREFIX) 262 @install -d $(DESTDIR)$(DATA_PREFIX)/images 263 $(BSD_INSTALL_DATA) data/images/* $(DESTDIR)$(DATA_PREFIX)/images 264 265 266# Install the text documentation: 267 268install-doc: 269 @echo 270 @echo "...Installing documentation..." 271 @echo "(English)" 272 @install -d $(DESTDIR)$(DOC_PREFIX) 273 @install -d $(DESTDIR)$(DOC_PREFIX)/html 274 $(BSD_INSTALL_DATA) docs/AUTHORS.txt $(DESTDIR)$(DOC_PREFIX) 275 $(BSD_INSTALL_DATA) docs/CHANGES.txt $(DESTDIR)$(DOC_PREFIX) 276 $(BSD_INSTALL_DATA) docs/COPYING.txt $(DESTDIR)$(DOC_PREFIX) 277 $(BSD_INSTALL_DATA) docs/README.txt $(DESTDIR)$(DOC_PREFIX) 278 $(BSD_INSTALL_DATA) docs/html/README.html $(DESTDIR)$(DOC_PREFIX)/html 279 $(BSD_INSTALL_DATA) docs/TODO.txt $(DESTDIR)$(DOC_PREFIX) 280 281 282# Install the man page: 283 284install-man: 285 @echo "...Installing man pages..." 286 # man1 directory... 287 @install -d $(DESTDIR)$(MAN_PREFIX)/man1/ 288 # tuxpaint-config.1 289 $(BSD_INSTALL_MAN) src/tuxpaint-config.1 $(DESTDIR)$(MAN_PREFIX)/man1/ 290 @gzip -9f $(DESTDIR)$(MAN_PREFIX)/man1/tuxpaint-config.1 291 292 293# Build the program! 294 295tuxpaint-config: obj/tuxpaint-config.o obj/tuxpaint-config2.o \ 296 obj/defaults.o $(ARCH_LIBS) 297 @echo Linking 298 $(CXX) $(ALL_CFLAGS) -o tuxpaint-config obj/tuxpaint-config.o \ 299 obj/tuxpaint-config2.o obj/defaults.o $(ARCH_LIBS) \ 300 $(FLTK_LIBS) $(ARCH_LINKS) $(PAPER_LIB) 301 302 303# Build the object for the program! 304 305obj/tuxpaint-config.o: src/tuxpaint-config.cxx src/version.h src/about.h 306 @echo Compiling tuxpaint-config.cxx 307 $(CXX) $(ALL_CFLAGS) -c src/tuxpaint-config.cxx -o obj/tuxpaint-config.o 308 309obj/tuxpaint-config2.o: src/tuxpaint-config2.cxx src/version.h src/about.h 310 @echo Compiling tuxpaint-config2.cxx 311 $(CXX) $(ALL_CFLAGS) -c src/tuxpaint-config2.cxx -o obj/tuxpaint-config2.o 312 313obj/defaults.o: src/defaults.cxx 314 @echo Compiling defaults.cxx 315 $(CXX) $(ALL_CFLAGS) -c src/defaults.cxx -o obj/defaults.o 316 317obj/win32utils.o: src/win32utils.cxx src/win32utils.h 318 @echo Compiling win32utils.cxx 319 $(CXX) $(ALL_CFLAGS) -c src/win32utils.cxx -o obj/win32utils.o 320 321obj/resource.o: visualc/resource.rc visualc/resource.h 322 @echo 323 @echo "...Compiling win32 resources..." 324 @windres -i visualc/resource.rc -o obj/resource.o 325 326 327# Translation stuff: 328 329POFILES:=$(wildcard src/po/*.po) 330MOFILES:=$(patsubst src/po/%.po,trans/%.mo,$(POFILES)) 331INSTALLED_MOFILES:=$(patsubst trans/%.mo,$(DESTDIR)$(LOCALE_PREFIX)/%/LC_MESSAGES/tuxpaint-config.mo,$(MOFILES)) 332 333$(INSTALLED_MOFILES): $(DESTDIR)$(LOCALE_PREFIX)/%/LC_MESSAGES/tuxpaint-config.mo: trans/%.mo 334 test -d `dirname $@` || mkdir -p `dirname $@` 335 $(BSD_INSTALL_DATA) $< $@ 336 337.PHONY: uninstall-i18n 338uninstall-i18n: 339 -rm $(LOCALE_PREFIX)/*/LC_MESSAGES/tuxpaint-config.mo 340 341 342# Install the translated text: 343# We can install *.mo files if they were already generated, or if it can be 344# generated from the *.po files. The *.mo files can be generated from the 345# *.po files if we have the converter program, msgfmt, installed in the 346# system. So we test for both and install them if either case is found 347# to be true. If neither case is found to be true, we'll just install 348# Tux Paint without the translation files. 349.PHONY: install-gettext 350ifeq "$(wildcard trans/*.mo)$(shell msgfmt -h)" "" 351install-gettext: 352 @echo 353 @echo "--------------------------------------------------------------" 354 @echo "Cannot install translation files because no translation files" 355 @echo "were found (trans/*.mo) and the 'msgfmt' program is not installed." 356 @echo "You will not be able to run Tux Paint in non-U.S. English modes." 357 @echo "--------------------------------------------------------------" 358else 359install-gettext: $(INSTALLED_MOFILES) 360endif 361 362 363# Build the translation files for gettext 364 365$(MOFILES): trans/%.mo: src/po/%.po 366 msgfmt -o $@ $< 367 368.PHONY: translations 369ifeq "$(shell msgfmt -h)" "" 370translations: trans 371 @echo "--------------------------------------------------------------" 372 @echo "Cannot find program 'msgfmt'!" 373 @echo "No translation files will be prepared." 374 @echo "Install gettext to run Tux Paint in non-U.S. English modes." 375 @echo "--------------------------------------------------------------" 376else 377translations: trans $(MOFILES) 378endif 379 380trans: 381 @echo 382 @echo "...Preparing translation files..." 383 @mkdir trans 384 385 386# Make the "obj" directory to throw the object(s) into: 387 388obj: 389 @mkdir obj 390 391