# Makefile for tuxpaint-config

# Tux Paint Configuration Tool - A GUI-based configurator for
#                              Tux Paint, a simple drawing program for children.

# Torsten Giebl <wizard@turricane.org>
# Jan Wynholds
# Bill Kendrick <bill@newbreedsoftware.com>

# http://www.newbreedsoftware.com/tuxpaint/

# November 12, 2002 - September 4, 2004


# Where to install things:

PREFIX=/usr/local


# Program:

BIN_PREFIX=$(PREFIX)/bin


# Data:

DATA_PREFIX=$(PREFIX)/share/tuxpaint-config/


# Docs and man page:

DOC_PREFIX=$(PREFIX)/share/doc/tuxpaint-config/
MAN_PREFIX=$(PREFIX)/share/man/


# Tux Paint's 'System-wide' Config file:

ifeq ($(PREFIX),/usr)
  CONFDIR=/etc/tuxpaint
else
  CONFDIR=$(PREFIX)/etc/tuxpaint
endif


# Icons and launchers:

ICON_PREFIX=$(PREFIX)/share/pixmaps/
X11_ICON_PREFIX=$(PREFIX)/X11R6/include/X11/pixmaps/
GNOME_PREFIX=`gnome-config --prefix`
KDE_PREFIX=`kde-config --install apps --expandvars`
KDE_ICON_PREFIX=`kde-config --install icon --expandvars`


# Locale files

LOCALE_PREFIX=$(PREFIX)/share/locale/
# LOCALE_PREFIX=/usr/share/locale/


# Built with sound by default  (override with "make nosound")

NOSOUNDFLAG=__SOUND


# Libraries, paths, and flags:

FLTK_CFLAGS=`fltk-config --cxxflags`
FLTK_LIBS=`fltk-config --ldstaticflags`

# The entire set of CFLAGS:

CFLAGS=-O2 -Wall $(FLTK_CFLAGS) -DDATA_PREFIX=\"$(DATA_PREFIX)\" \
	-D$(NOSOUNDFLAG) -DDOC_PREFIX=\"$(DOC_PREFIX)\" \
	-DLOCALEDIR=\"$(LOCALE_PREFIX)\" -DCONFDIR=\"$(CONFDIR)\"


# "make" with no arguments builds the program and man page from sources:

all:	tuxpaint-config translations
	@echo
	@echo "Done compiling."
	@echo "Now (probably as 'root' superuser), run 'make install'"
	@echo "to install Tux Paint Configuration Tool."
	@echo



# "make install" installs all of the various parts
# (depending on the *PREFIX variables at the top, you probably need
# to do this as superuser ("root"))

install:	install-bin install-data install-man install-doc \
		install-gnome install-kde install-kde-icons \
		install-icon install-gettext
	@echo
	@echo "All done! Now (preferably NOT as 'root' superuser),"
	@echo "you can type the command 'tuxpaint-config' to run the"
	@echo "configuration tool!"
	@echo
	@echo "Enjoy!"
	@echo


# "make clean" deletes the program, the compiled objects and the
# built man page (returns to factory archive, pretty much...)

clean:
	-rm -f tuxpaint-config tuxpaint-config.exe
	-rm -f obj/*.o
	if [ -d obj ]; then rmdir obj; fi
	-rm -f trans/*.mo
	if [ -d trans ]; then rmdir trans; fi


# "make uninstall" should remove the various parts from their
# installation locations.  BE SURE the *PREFIX variables at the top
# are the same as they were when you installed, of course!!!

uninstall:
#	if [ "x$(GNOME_PREFIX)" != "x" ]; then \
#	  -rm $(GNOME_PREFIX)/share/gnome/apps/Graphics/tuxpaint-config.desktop; \
#	  -rm $(GNOME_PREFIX)/share/pixmaps/tuxpaint-config.png; \
#	fi
#	if [ "x$(KDE_PREFIX)" != "x" ]; then \
#	  -rm $(KDE_PREFIX)/Preferences/tuxpaint-config.desktop; \
#	fi
	-rm $(ICON_PREFIX)tuxpaint-config.png
	-rm $(X11_ICON_PREFIX)tuxpaint-config.xpm
	-rm $(BIN_PREFIX)/tuxpaint-config
	-rm -r $(DATA_PREFIX)
	-rm -r $(DOC_PREFIX)
	-rm $(MAN_PREFIX)/man1/tuxpaint-config.1.gz


# Install a launcher icon in the Gnome menu, under "???"

install-gnome:
#	@echo
#	@echo "...Installing launcher icon into GNOME..."
#	if [ "x$(GNOME_PREFIX)" != "x" ]; then \
#	 install -d $(GNOME_PREFIX)/share/pixmaps; \
#	 cp data/images/icon.png $(GNOME_PREFIX)/share/pixmaps/tuxpaint.png; \
#	 chmod 644 $(GNOME_PREFIX)/share/pixmaps/tuxpaint.png; \
#	 install -d $(GNOME_PREFIX)/share/gnome/apps/Graphics; \
#	 cp src/tuxpaint.desktop $(GNOME_PREFIX)/share/gnome/apps/Graphics/; \
#	 chmod 644 $(GNOME_PREFIX)/share/gnome/apps/Graphics/tuxpaint.desktop; \
#	fi


# Install a launcher icon in the KDE menu...

install-kde:
	@echo
	@echo "...Installing launcher icon into KDE..."
#	if [ "x$(KDE_PREFIX)" != "x" ]; then \
#	  install -d $(KDE_PREFIX)/Preferences/; \
#	  cp src/tuxpaint-config.desktop $(KDE_PREFIX)/Preferences/; \
#	  chmod 644 $(KDE_PREFIX)/Preferences/tuxpaint-config.desktop; \
#	fi


install-kde-icons:
	echo "...Installing launcher icon graphics into KDE..."
	@if [ "x$(KDE_ICON_PREFIX)" != "x" ]; then \
	  cp data/images/icon48x48.png \
		$(KDE_ICON_PREFIX)/hicolor/48x48/apps/tuxpaint-config.png; \
	  cp data/images/icon32x32.png \
		$(KDE_ICON_PREFIX)/hicolor/32x32/apps/tuxpaint-config.png; \
	  cp data/images/icon16x16.png \
		$(KDE_ICON_PREFIX)/hicolor/16x16/apps/tuxpaint-config.png; \
	fi


# Install the PNG icon (for GNOME, KDE, etc.)
# and the 24-color 32x32 XPM (for other Window managers):

install-icon:
	@echo
	@echo "...Installing launcher icon graphics..."
	install -d $(ICON_PREFIX)
	cp data/images/icon.png $(ICON_PREFIX)tuxpaint-config.png
	chmod 644 $(ICON_PREFIX)tuxpaint-config.png
	install -d $(X11_ICON_PREFIX)
	cp data/images/icon32x32.xpm $(X11_ICON_PREFIX)tuxpaint-config.xpm
	chmod 644 $(X11_ICON_PREFIX)tuxpaint-config.xpm


# Install the program:

install-bin:
	@echo
	@echo "...Installing program itself..."
	cp tuxpaint-config $(BIN_PREFIX)
	chmod a+rx,g-w,o-w $(BIN_PREFIX)/tuxpaint-config


# Install the data (sound, graphics, fonts):

install-data:
	@echo
	@echo "...Installing data files..."
	install -d $(DATA_PREFIX)
	cp -R data/* $(DATA_PREFIX)
	chmod -R a+rX,g-w,o-w $(DATA_PREFIX)


# Install the translated text:

install-gettext:
	@echo
	@echo "...Installing translation files..."



# Install the text documentation:

install-doc:
	@echo
	@echo "...Installing documentation..."
	@echo "(English)"
	install -d $(DOC_PREFIX)
	cp docs/AUTHORS.txt $(DOC_PREFIX)
	cp docs/CHANGES.txt $(DOC_PREFIX)
	cp docs/COPYING.txt $(DOC_PREFIX)
	cp docs/README.txt $(DOC_PREFIX)
	cp docs/TODO.txt $(DOC_PREFIX)
	@echo "(...Setting permissions)"
	chmod a+rx,g-w,o-w $(DOC_PREFIX)


# Install the man page:

install-man:
	@echo "...Installing man pages..."
	# man1 directory...
	install -d $(MAN_PREFIX)/man1/
	# tuxpaint-config.1
	cp src/tuxpaint-config.1 $(MAN_PREFIX)/man1/
	gzip -f $(MAN_PREFIX)/man1/tuxpaint-config.1
	chmod a+rx,g-w,o-w $(MAN_PREFIX)/man1/tuxpaint-config.1.gz


# Build the program!

tuxpaint-config:	obj/tuxpaint-config.o obj/tuxpaint-config2.o	\
			obj/defaults.o
	$(CXX) $(CFLAGS) -o tuxpaint-config obj/tuxpaint-config.o 	\
			obj/tuxpaint-config2.o obj/defaults.o $(FLTK_LIBS)


# Build the object for the program!

obj/tuxpaint-config.o:	src/tuxpaint-config.cxx obj src/version.h src/about.h
	$(CXX) $(CFLAGS) -c src/tuxpaint-config.cxx -o obj/tuxpaint-config.o

obj/tuxpaint-config2.o:	src/tuxpaint-config2.cxx obj src/version.h src/about.h
	$(CXX) $(CFLAGS) -c src/tuxpaint-config2.cxx -o obj/tuxpaint-config2.o

obj/defaults.o:	src/defaults.cxx obj
	$(CXX) $(CFLAGS) -c src/defaults.cxx -o obj/defaults.o


# Build the translation files for gettext

translations:	trans

trans:
	mkdir trans


# Make the "obj" directory to throw the object(s) into:

obj:
	mkdir obj

