--- ./Makefile.orig	Wed Nov 21 19:16:33 2007
+++ ./Makefile	Wed Dec 12 03:13:49 2007
@@ -20,7 +20,6 @@
 
 # Where to install things:
 
-PREFIX=/usr/local
 
 
 # Root directory to place files when creating packages.
@@ -48,9 +47,9 @@
 # Docs and man page:
 
 DOC_PREFIX=$(PKG_ROOT)$(PREFIX)/share/doc/tuxpaint
-DEVDOC_PREFIX=$(PKG_ROOT)$(PREFIX)/share/doc/tuxpaint-dev
-MAN_PREFIX=$(PKG_ROOT)$(PREFIX)/share/man
-DEVMAN_PREFIX=$(PKG_ROOT)$(PREFIX)/share/man
+DEVDOC_PREFIX=$(PKG_ROOT)$(PREFIX)/share/doc/tuxpaint/dev
+MAN_PREFIX=$(PKG_ROOT)$(PREFIX)/man
+DEVMAN_PREFIX=$(PKG_ROOT)$(PREFIX)/man
 
 
 # 'System-wide' Config file:
@@ -119,12 +118,8 @@
 SDL_CFLAGS=$(shell sdl-config --cflags) $(SVG_CFLAGS)
 
 
-SVG_LIB=-lrsvg-2 -lcairo
-SVG_CFLAGS=-I/usr/include/librsvg-2/librsvg \
-	-I/usr/include/gtk-2.0 \
-	-I/usr/include/glib-2.0 \
-	-I/usr/lib/glib-2.0/include \
-	-I/usr/include/cairo
+SVG_LIB=`pkg-config --libs librsvg-2.0 cairo`
+SVG_CFLAGS=`pkg-config --cflags librsvg-2.0 cairo`
 
 PAPER_LIB=-lpaper
 ARCH_LIBS=obj/postscript_print.o
@@ -134,7 +129,8 @@
 
 #-ffast-math
 OPTFLAGS=-O2
-CFLAGS=$(OPTFLAGS) -W -Wall -fno-common -ffloat-store \
+MYCFLAGS:=$(CFLAGS)
+CFLAGS+=$(OPTFLAGS) -W -Wall -fno-common -ffloat-store -I$(LOCALBASE)/include \
 	-Wcast-align -Wredundant-decls \
 	-Wbad-function-cast -Wwrite-strings \
 	-Waggregate-return \
@@ -352,8 +348,7 @@
 		install-magic-plugin-dev \
 		install-icon install-gettext install-im install-importscript \
 		install-default-config install-example-stamps \
-		install-example-starters \
-		install-gnome install-kde install-kde-icons
+		install-example-starters
 	@echo
 	@echo "--------------------------------------------------------------"
 	@echo
@@ -540,7 +535,7 @@
 	@-rm -f src/tp_magic_api.h
 	@-rm -f tp-magic-config
 	@if [ -d trans ]; then rmdir trans; fi
-	@cd magic ; make clean$(TARGET_PASSTHRU)
+	@cd magic ; $(MAKE) clean$(TARGET_PASSTHRU)
 	@echo
 
 clean-win32:
@@ -596,8 +591,10 @@
 	@echo
 	@echo "...Installing default config file..."
 	@install -d $(CONFDIR)
-	@cp src/tuxpaint.conf $(CONFDIR)
-	@chmod 644 $(CONFDIR)/tuxpaint.conf
+	@cp src/tuxpaint.conf $(CONFDIR)/tuxpaint.conf.sample
+	@chmod 644 $(CONFDIR)/tuxpaint.conf.sample
+	@test -f $(CONFDIR)/tuxpaint.conf || \
+		cp $(CONFDIR)/tuxpaint.conf.sample $(CONFDIR)/tuxpaint.conf
 
 
 # Install example stamps
@@ -725,9 +722,6 @@
 	@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
 
 
 # Install the program:
@@ -840,12 +834,6 @@
 	@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
 	@# tuxpaint-import.1
 	@cp src/manpage/tuxpaint-import.1 $(MAN_PREFIX)/man1/
 	@gzip -f $(MAN_PREFIX)/man1/tuxpaint-import.1
@@ -873,7 +861,7 @@
 		$(SDL_LIBS) \
 		$(SVG_LIB) \
 		$(PAPER_LIB) \
-		-lm $(ARCH_LINKS)
+		-lm $(ARCH_LINKS) -lintl -lpng
 	@$(RSRC_CMD)
 	@$(MIMESET_CMD)
 
@@ -1003,7 +991,7 @@
 # Go into 'magic' subdirectory and buld magic plug-ins
 
 magic-plugins:	src/tp_magic_api.h
-	@cd magic ; make $(TARGET_PASSTHRU)
+	@cd magic ; $(MAKE) $(TARGET_PASSTHRU)
 
 
 src/tp_magic_api.h:	src/tp_magic_api.h.in
@@ -1015,13 +1003,13 @@
 tp-magic-config:	src/tp-magic-config.sh.in Makefile
 	@echo
 	@echo "...Generating 'Magic' tool API configuration script..."
-	@sed src/tp-magic-config.sh.in -e s/__VERSION__/$(VER_VERSION)/ \
+	@sed -e s/__VERSION__/$(VER_VERSION)/ \
 		-e s/__APIVERSION__/$(MAGIC_API_VERSION)/ \
 		-e s=__INCLUDE__=$(INCLUDE_PREFIX)/tuxpaint= \
 		-e s=__DATAPREFIX__=$(DATA_PREFIX)= \
 		-e s=__PLUGINPREFIX__=$(MAGIC_PREFIX)= \
 		-e s=__PLUGINDOCPREFIX__=$(DOC_PREFIX)/magic-docs= \
-		> tp-magic-config
+		src/tp-magic-config.sh.in > tp-magic-config
 
 # Make the "obj" directory to throw the object(s) into:
 # (not necessary any more; bjk 2006.02.20)
