$OpenBSD: patch-Makefile,v 1.7 2014/09/04 11:56:52 ajacoutot Exp $
--- Makefile.orig	Tue Aug 19 09:28:33 2014
+++ Makefile	Thu Sep  4 13:43:47 2014
@@ -37,7 +37,7 @@ STDC_LIB:=-lstdc++.r4
 endif
 else
 OS:=linux
-GPERF:=/usr/bin/gperf
+GPERF:=${LOCALBASE}/bin/gperf
 endif
 endif
 endif
@@ -110,7 +110,7 @@ osx_PREFIX:=/usr/local
 
 beos_PREFIX=$(shell finddir B_APPS_DIRECTORY)/TuxPaint
 linux_PREFIX:=/usr/local
-PREFIX:=$($(OS)_PREFIX)
+PREFIX:=${TRUEPREFIX}
 
 # Root directory to place files when creating packages.
 # PKG_ROOT is the old name for this, and should be undefined.
@@ -143,19 +143,15 @@ MAGIC_PREFIX:=$(DESTDIR)$(LIBDIR)/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
 
 # BASH tab-completion file:
 COMPLETIONDIR:=$(DESTDIR)/etc/bash_completion.d
 
 # 'System-wide' Config file:
-ifeq ($(PREFIX),/usr)
-  CONFDIR:=$(DESTDIR)/etc/tuxpaint
-else
-  CONFDIR:=$(DESTDIR)$(PREFIX)/etc/tuxpaint
-endif
+CONFDIR=${SYSCONFDIR}/tuxpaint
 
 ifeq ($(SYSNAME),Haiku)
   CONFDIR:=$(shell finddir B_USER_SETTINGS_DIRECTORY)/TuxPaint
@@ -164,9 +160,9 @@ endif
 # 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:=
@@ -225,8 +221,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 \
 	$(if $(filter windows,$(OS)),,$(call comptest,-fvisibility=hidden,)) \
 	-Wcast-align -Wredundant-decls \
 	-Wbad-function-cast -Wwrite-strings \
@@ -259,20 +256,6 @@ MOUSE_CFLAGS:=-Isrc/$(MOUSEDIR) -D$(CURSOR_SHAPES)_CUR
 #
 .PHONY: all
 all:	tuxpaint translations magic-plugins tp-magic-config
-# thumb-starters
-	@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:
@@ -451,23 +434,6 @@ install:	install-bin install-data install-man install-
 		install-bash-completion \
 		install-osk \
 		$(ARCH_INSTALL)
-#install-thumb-starters
-	@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
 
 .PHONY: install-magic-plugins
 install-magic-plugins:
@@ -609,9 +575,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 BASH completion file:
 .PHONY: install-bash-completion
@@ -628,7 +593,7 @@ install-bash-completion:
 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
 
@@ -675,7 +640,10 @@ $(THUMB_STARTERS):
 	fi
 
 $(INSTALLED_THUMB_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
 
 .PHONY: echo-thumb-starters
 echo-thumb-starters:
@@ -817,12 +785,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:
@@ -830,9 +795,8 @@ install-icon:
 install-bin:
 	@echo
 	@echo "...Installing program itself..."
-	@install -d $(BIN_PREFIX)
-	@cp tuxpaint$(EXE_EXT) $(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
@@ -909,8 +873,7 @@ install-haiku:
 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):
@@ -918,12 +881,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
 
@@ -943,7 +908,7 @@ install-osk:
 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 -R a=rX,g=rX,u=rwX $(DOC_PREFIX)
@@ -955,25 +920,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
 
 
 
@@ -987,7 +940,7 @@ tuxpaint:	obj/tuxpaint.o obj/i18n.o obj/im.o obj/curso
 	@echo "...Linking Tux Paint..."
 	$(CC) $(CFLAGS) $(LDFLAGS) $(DEBUG_FLAGS) $(SDL_CFLAGS) $(FRIBIDI_CFLAGS) $(DEFS) \
 		-o tuxpaint $^ \
-		$(SDL_LIBS) $(SVG_LIB) $(ARCH_LINKS)
+		$(SDL_LIBS) $(SVG_LIB) $(ARCH_LINKS) $(PAPER_LIB) -lpaper
 	@$(RSRC_CMD)
 	@$(MIMESET_CMD)
 
@@ -1178,8 +1131,8 @@ 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/
-SHARED_FLAGS:=-shared -fpic -Wl,--warn-shared-textrel
+MAGIC_CFLAGS:=-g3 -fno-common -W -Wstrict-prototypes -Wmissing-prototypes -Wall $(MAGIC_SDL_CPPFLAGS) -Isrc/ -I${LOCALBASE}/include
+SHARED_FLAGS:=-shared -fpic
 
 MAGIC_C:=$(wildcard magic/src/*.c)
 MAGIC_SO:=$(patsubst magic/src/%.c,magic/%.$(SO_TYPE),$(MAGIC_C))
