$OpenBSD: patch-Makefile,v 1.4 2008/10/23 12:39:00 ajacoutot Exp $
--- Makefile.orig	Tue Jul  1 02:16:48 2008
+++ Makefile	Thu Oct 16 18:02:53 2008
@@ -91,7 +91,7 @@ windows_PREFIX:=/usr/local
 osx_PREFIX:=/usr/local
 beos_PREFIX:=/boot/apps/Games/TuxPaint
 linux_PREFIX:=/usr/local
-PREFIX:=$($(OS)_PREFIX)
+PREFIX:=${TRUEPREFIX}
 
 
 # Root directory to place files when creating packages.
@@ -122,24 +122,20 @@ MAGIC_PREFIX:=$(DESTDIR)$(PREFIX)/lib/tuxpaint/plugins
 
 # Docs and man page:
 DOC_PREFIX:=$(DESTDIR)$(PREFIX)/share/doc/tuxpaint
-DEVDOC_PREFIX:=$(DESTDIR)$(PREFIX)/share/doc/tuxpaint-dev
-MAN_PREFIX:=$(DESTDIR)$(PREFIX)/share/man
-DEVMAN_PREFIX:=$(DESTDIR)$(PREFIX)/share/man
+DEVDOC_PREFIX:=$(DESTDIR)$(PREFIX)/share/doc/tuxpaint/tuxpaint-dev
+MAN_PREFIX:=$(DESTDIR)$(PREFIX)/man
+DEVMAN_PREFIX:=$(DESTDIR)$(PREFIX)/man
 
 
 # 'System-wide' Config file:
-ifeq ($(PREFIX),/usr)
-  CONFDIR:=$(DESTDIR)/etc/tuxpaint
-else
-  CONFDIR:=$(DESTDIR)$(PREFIX)/etc/tuxpaint
-endif
+CONFDIR=${SYSCONFDIR}/tuxpaint
 
 # Icons and launchers:
 ICON_PREFIX:=$(DESTDIR)$(PREFIX)/share/pixmaps
 X11_ICON_PREFIX:=$(DESTDIR)$(PREFIX)/X11R6/include/X11/pixmaps
-GNOME_PREFIX:=$(shell gnome-config --prefix 2> /dev/null)
-KDE_PREFIX:=$(shell kde-config --install apps --expandvars 2> /dev/null)
-KDE_ICON_PREFIX:=$(shell kde-config --install icon --expandvars 2> /dev/null)
+#GNOME_PREFIX:=$(shell gnome-config --prefix 2> /dev/null)
+#KDE_PREFIX:=$(shell kde-config --install apps --expandvars 2> /dev/null)
+#KDE_ICON_PREFIX:=$(shell kde-config --install icon --expandvars 2> /dev/null)
 
 # Maemo flag
 MAEMOFLAG:=
@@ -199,8 +195,9 @@ endif
 # The entire set of CFLAGS:
 
 #-ffast-math
-OPTFLAGS:=-O2
-CFLAGS:=$(CPPFLAGS) $(OPTFLAGS) -W -Wall -fno-common -ffloat-store \
+#OPTFLAGS:=-O2
+CFLAGS:=-I${LOCALBASE}/include \
+	$(CPPFLAGS) $(OPTFLAGS) -W -Wall -fno-common -ffloat-store \
 	$(call comptest,-fvisibility=hidden,) \
 	-Wcast-align -Wredundant-decls \
 	-Wbad-function-cast -Wwrite-strings \
@@ -233,19 +230,6 @@ MOUSE_CFLAGS:=-Isrc/$(MOUSEDIR) -D$(CURSOR_SHAPES)_CUR
 #
 .PHONY: all
 all:	tuxpaint translations magic-plugins tp-magic-config
-	@echo
-	@echo "--------------------------------------------------------------"
-	@echo
-	@echo "Done compiling."
-	@echo
-	@echo "Now run 'make install' with any options you ran 'make' with."
-	@echo "to install Tux Paint."
-	@echo
-	@echo "You may need superuser ('root') privileges, depending on"
-	@echo "where you're installing."
-	@echo "(Depending on your system, you either need to 'su' first,"
-	@echo "or run 'sudo make install'.)"
-	@echo
 
 .PHONY: releaseclean
 releaseclean:
@@ -300,7 +284,10 @@ MOFILES:=$(patsubst src/po/%.po,trans/%.mo,$(POFILES))
 INSTALLED_MOFILES:=$(patsubst trans/%.mo,$(LOCALE_PREFIX)/%/LC_MESSAGES/tuxpaint.mo,$(MOFILES))
 
 $(INSTALLED_MOFILES): $(LOCALE_PREFIX)/%/LC_MESSAGES/tuxpaint.mo: trans/%.mo
-	install -D -m 644 $< $@
+	@cd trans ; \
+	    for i in `ls *.mo` ; do \
+	        ${BSD_INSTALL_DATA_DIR} $(DESTDIR)$(PREFIX)/share/locale/`basename $$i .mo`/LC_MESSAGES && \
+	        ${BSD_INSTALL_DATA} $$i $(DESTDIR)$(PREFIX)/share/locale/`basename $$i .mo`/LC_MESSAGES/tuxpaint.mo ; done
 
 .PHONY: uninstall-i18n
 uninstall-i18n:
@@ -402,24 +389,7 @@ install:	install-bin install-data install-man install-
 		install-magic-plugin-dev \
 		install-icon install-gettext install-im install-importscript \
 		install-default-config install-example-stamps \
-		install-example-starters \
-		$(ARCH_INSTALL)
-	@echo
-	@echo "--------------------------------------------------------------"
-	@echo
-	@echo "All done! Now (preferably NOT as 'root' superuser),"
-	@echo "you can type the command 'tuxpaint' to run the program!!!"
-	@echo
-	@echo "For more information, see the 'tuxpaint' man page,"
-	@echo "run 'tuxpaint --usage' or see $(DOC_PREFIX)/README.txt"
-	@echo
-	@echo "Visit Tux Paint's home page for more information, updates"
-	@echo "and to learn how you can help out!"
-	@echo
-	@echo "  http://www.tuxpaint.org/"
-	@echo
-	@echo "Enjoy!"
-	@echo
+		install-example-starters
 
 .PHONY: install-magic-plugins
 install-magic-plugins:
@@ -553,9 +523,8 @@ uninstall:	uninstall-i18n
 install-default-config:
 	@echo
 	@echo "...Installing default config file..."
-	@install -d $(CONFDIR)
-	@cp src/tuxpaint.conf $(CONFDIR)
-	@chmod 644 $(CONFDIR)/tuxpaint.conf
+	${BSD_INSTALL_DATA_DIR} $(DESTDIR)$(PREFIX)/share/examples/tuxpaint
+	${BSD_INSTALL_DATA} src/tuxpaint.conf $(DESTDIR)$(PREFIX)/share/examples/tuxpaint
 
 
 # Install example stamps
@@ -563,7 +532,7 @@ install-default-config:
 install-example-stamps:
 	@echo
 	@echo "...Installing example stamps..."
-	@install -d $(DATA_PREFIX)/stamps
+	${BSD_INSTALL_DATA_DIR} $(DATA_PREFIX)/stamps
 	@cp -R stamps/* $(DATA_PREFIX)/stamps
 	@chmod -R a+rX,g-w,o-w $(DATA_PREFIX)/stamps
 
@@ -572,7 +541,10 @@ STARTERS:=$(wildcard starters/*.*)
 INSTALLED_STARTERS:=$(patsubst %,$(DATA_PREFIX)/%,$(STARTERS))
 
 $(INSTALLED_STARTERS): $(DATA_PREFIX)/%: %
-	install -D -m 644 $< $@
+	@cd starters ; \
+	    ${BSD_INSTALL_DATA_DIR} $(DESTDIR)$(PREFIX)/share/tuxpaint/starters ; \
+	    for i in `ls *.*` ; do \
+	        ${BSD_INSTALL_DATA} $$i $(DESTDIR)$(PREFIX)/share/tuxpaint/starters ; done
 
 # Install example starters
 .PHONY: install-example-starters
@@ -681,12 +653,9 @@ install-kde-icons:
 install-icon:
 	@echo
 	@echo "...Installing launcher icon graphics..."
-	@install -d $(ICON_PREFIX)
-	@cp data/images/icon.png $(ICON_PREFIX)/tuxpaint.png
-	@chmod 644 $(ICON_PREFIX)/tuxpaint.png
-	@install -d $(X11_ICON_PREFIX)
-	@cp data/images/icon32x32.xpm $(X11_ICON_PREFIX)/tuxpaint.xpm
-	@chmod 644 $(X11_ICON_PREFIX)/tuxpaint.xpm
+	${BSD_INSTALL_DATA_DIR} $(ICON_PREFIX)
+	${BSD_INSTALL_DATA} data/images/icon.png $(ICON_PREFIX)/tuxpaint.png
+	${BSD_INSTALL_DATA} data/images/icon32x32.xpm $(ICON_PREFIX)/tuxpaint.xpm
 
 
 # Install the program:
@@ -694,9 +663,8 @@ install-icon:
 install-bin:
 	@echo
 	@echo "...Installing program itself..."
-	@install -d $(BIN_PREFIX)
-	@cp tuxpaint $(BIN_PREFIX)
-	@chmod a+rx,g-w,o-w $(BIN_PREFIX)/tuxpaint$(EXE_EXT)
+	${BSD_INSTALL_DATA_DIR} $(BIN_PREFIX)
+	${BSD_INSTALL_PROGRAM} tuxpaint $(BIN_PREFIX)
 
 # Install the required Windows DLLs into the 'bdist' directory
 .PHONY: install-dlls
@@ -761,8 +729,7 @@ install-dlls:
 install-importscript:
 	@echo
 	@echo "...Installing 'tuxpaint-import' script..."
-	@cp src/tuxpaint-import.sh $(BIN_PREFIX)/tuxpaint-import
-	@chmod a+rx,g-w,o-w $(BIN_PREFIX)/tuxpaint-import
+	${BSD_INSTALL_SCRIPT} src/tuxpaint-import.sh $(BIN_PREFIX)/tuxpaint-import
 
 
 # Install the data (sound, graphics, fonts):
@@ -770,12 +737,14 @@ install-importscript:
 install-data:
 	@echo
 	@echo "...Installing data files..."
-	@install -d $(DATA_PREFIX)
+	${BSD_INSTALL_DATA_DIR} $(DATA_PREFIX)
 	@cp -R data/* $(DATA_PREFIX)
 	@chmod -R a+rX,g-w,o-w $(DATA_PREFIX)
+	${BSD_INSTALL_DATA_DIR} $(DESTDIR)$(PREFIX)/share/applications
+	${BSD_INSTALL_DATA} src/tuxpaint.desktop $(DESTDIR)$(PREFIX)/share/applications
 	@echo
 	@echo "...Installing fonts..."
-	@install -d $(DATA_PREFIX)/fonts/locale
+	${BSD_INSTALL_DATA_DIR} $(DATA_PREFIX)/fonts/locale
 	@cp -R fonts/locale/* $(DATA_PREFIX)/fonts/locale
 	@chmod -R a+rX,g-w,o-w $(DATA_PREFIX)/fonts/locale
 
@@ -786,7 +755,7 @@ install-data:
 install-doc:
 	@echo
 	@echo "...Installing documentation..."
-	@install -d $(DOC_PREFIX)
+	${BSD_INSTALL_DATA_DIR} $(DOC_PREFIX)
 	@cp -R docs/* $(DOC_PREFIX)
 	@cp -R magic/magic-docs $(DOC_PREFIX)
 	@chmod a=rX,g=rX,u=rwX $(DOC_PREFIX)
@@ -798,25 +767,13 @@ install-man:
 	@echo
 	@echo "...Installing man pages..."
 	@# man1 directory...
-	@install -d $(MAN_PREFIX)/man1
+	${BSD_INSTALL_MAN_DIR} $(MAN_PREFIX)/man1
 	@# tuxpaint.1
-	@cp src/manpage/tuxpaint.1 $(MAN_PREFIX)/man1
-	@gzip -f $(MAN_PREFIX)/man1/tuxpaint.1
-	@chmod a+rx,g-w,o-w $(MAN_PREFIX)/man1/tuxpaint.1.gz
-	@# pl/man1 directory...
-	@install -d $(MAN_PREFIX)/pl/man1/
-	@# tuxpaint-pl.1
-	@cp src/manpage/tuxpaint-pl.1 $(MAN_PREFIX)/pl/man1/tuxpaint.1
-	@gzip -f $(MAN_PREFIX)/pl/man1/tuxpaint.1
-	@chmod a+rx,g-w,o-w $(MAN_PREFIX)/pl/man1/tuxpaint.1.gz
+	${BSD_INSTALL_MAN} src/manpage/tuxpaint.1 $(MAN_PREFIX)/man1
 	@# tuxpaint-import.1
-	@cp src/manpage/tuxpaint-import.1 $(MAN_PREFIX)/man1/
-	@gzip -f $(MAN_PREFIX)/man1/tuxpaint-import.1
-	@chmod a+rx,g-w,o-w $(MAN_PREFIX)/man1/tuxpaint-import.1.gz
+	${BSD_INSTALL_MAN} src/manpage/tuxpaint-import.1 $(MAN_PREFIX)/man1
 	@# tp-magic-config.1
-	@cp src/manpage/tp-magic-config.1 $(MAN_PREFIX)/man1/
-	@gzip -f $(MAN_PREFIX)/man1/tp-magic-config.1
-	@chmod a+rx,g-w,o-w $(MAN_PREFIX)/man1/tp-magic-config.1.gz
+	${BSD_INSTALL_MAN} src/manpage/tp-magic-config.1 $(MAN_PREFIX)/man1
 
 
 
@@ -830,7 +787,7 @@ tuxpaint:	obj/tuxpaint.o obj/i18n.o obj/im.o obj/curso
 	@echo "...Linking Tux Paint..."
 	$(CC) $(CFLAGS) $(DEBUG_FLAGS) $(SDL_CFLAGS) $(DEFS) \
 		-o tuxpaint $^ \
-		$(SDL_LIBS) $(SVG_LIB) $(ARCH_LINKS)
+		$(SDL_LIBS) $(SVG_LIB) $(ARCH_LINKS) $(PAPER_LIB) -lutf8 -lpaper
 	@$(RSRC_CMD)
 	@$(MIMESET_CMD)
 
@@ -993,7 +950,7 @@ linux_PLUGIN_LIBS:=
 PLUGIN_LIBS:=$($(OS)_PLUGIN_LIBS)
 
 #MAGIC_CFLAGS:=-g3 -O2 -fvisibility=hidden -fno-common -W -Wstrict-prototypes -Wmissing-prototypes -Wall $(MAGIC_SDL_CPPFLAGS) -Isrc/
-MAGIC_CFLAGS:=-g3 -O2 -fno-common -W -Wstrict-prototypes -Wmissing-prototypes -Wall $(MAGIC_SDL_CPPFLAGS) -Isrc/
+MAGIC_CFLAGS:=-g3 $(OPTFLAGS) -fno-common -W -Wstrict-prototypes -Wmissing-prototypes -Wall $(MAGIC_SDL_CPPFLAGS) -Isrc/
 SHARED_FLAGS:=-shared -fpic
 
 MAGIC_C:=$(wildcard magic/src/*.c)
