diff --git a/Makefile b/Makefile
index d5da5a09a369772238f94b55f3cd986e68f8bef5..af8eb019721dbb5f4399c042a15552c3ac109866 100644
--- a/Makefile
+++ b/Makefile
@@ -5,6 +5,7 @@ DISTFILES=Makefile abuild abuild.conf APKBUILD.proto
 
 prefix ?= /usr
 sysconfdir ?= /etc
+datadir ?= $(prefix)/share/$(PACKAGE)
 
 P=$(PACKAGE)-$(VERSION)
 
@@ -13,12 +14,13 @@ help:
 	@echo "usage: make install [ DESTDIR=<path> ]"
 	@echo "       make dist"
 
-install: abuild abuild.conf APKBUILD.proto
+install: abuild abuild.conf APKBUILD.proto functions.sh
 	mkdir -p $(DESTDIR)/$(prefix)/bin $(DESTDIR)/$(sysconfdir) \
-		$(DESTDIR)/$(prefix)/share/abuild
+		$(DESTDIR)/$(datadir)
 	cp abuild $(DESTDIR)/$(prefix)/bin/
 	cp abuild.conf $(DESTDIR)/$(sysconfdir)/
 	cp APKBUILD.proto $(DESTDIR)/$(prefix)/share/abuild
+	cp functions.sh $(DESTDIR)/$(datadir)/
 
 dist:	$(P).tar.gz
 
diff --git a/abuild b/abuild
index bd82e4b2b61dd789474011599c15d727983b38df..d8c475d842ed42e021d2d9cf40fe676791898f8e 100755
--- a/abuild
+++ b/abuild
@@ -14,6 +14,20 @@ abuild_ver=0.9
 MAKEAPK_CONF=${MAKEAPK_CONF:-/etc/abuild.conf}
 [ -f "$MAKEAPK_CONF" ] && . "$MAKEAPK_CONF"
 
+# source functions
+# if abuild was not run from PATH, then look for func lib at same location
+if [ -z "$FUNCLIB" ]; then
+	FUNCLIB="${0##/*}/functions.sh"
+	[ -f "$FUNCLIB"	] || FUNCLIB=/usr/share/abuild/functions.sh
+fi
+
+if ! [ -f "$FUNCLIB" ]; then
+	echo "$FUNCLIB: not found" >&2
+	exit 1
+fi
+. "$FUNCLIB"
+	
+
 startdir="$PWD"
 srcdir=${srcdir:-"$startdir/src"}
 pkgdir=${pkgdir:-"$startdir/pkg"}
@@ -25,39 +39,6 @@ PKGDEST=${PKGDEST:-$startdir}
 
 default_cmds="sanitycheck builddeps clean fetch md5check unpack rootpkg"
 
-#colors
-if [ -n "$USE_COLORS" ]; then
-	NORMAL="\033[1;0m"
-	STRONG="\033[1;1m"
-	RED="\033[1;31m"
-	GREEN="\033[1;32m"
-	YELLOW="\033[1;33m"
-	BLUE="\033[1;34m"
-fi	
-	
-
-# functions
-msg() {
-	local prompt="$GREEN>>>${NORMAL}"
-	local fake="${FAKEROOTKEY:+${BLUE}(fakeroot)${NORMAL} }"
-	local name="${STRONG}${subpkgname:-$pkgname}${NORMAL}"
-	[ -z "$quiet" ] && printf "${prompt} ${fake}${name}: $@\n" >&2
-}
-
-warning() {
-	local prompt="${YELLOW}>>> WARNING: ${NORMAL}"
-	local fake="${FAKEROOTKEY:+${BLUE}(fakeroot)${NORMAL} }"
-	local name="${STRONG}${subpkgname:-$pkgname}${NORMAL}"
-	printf "${prompt} ${fake}${name}: $@\n" >&2
-}
-
-error() {
-	local prompt="${RED}>>> ERROR: ${NORMAL}"
-	local fake="${FAKEROOTKEY:+${BLUE}(fakeroot)${NORMAL} }"
-	local name="${STRONG}${subpkgname:-$pkgname}${NORMAL}"
-	printf "${prompt} ${fake}${name}: $@\n" >&2
-}
-
 set_xterm_title() {
 	if [ "$TERM" = xterm ]; then
 		 printf "\033]0;$1\007" >&2
diff --git a/functions.sh b/functions.sh
new file mode 100644
index 0000000000000000000000000000000000000000..6dde80cb715077cfc1f58acb65d4b2b0902bbd32
--- /dev/null
+++ b/functions.sh
@@ -0,0 +1,34 @@
+
+#colors
+if [ -n "$USE_COLORS" ]; then
+	NORMAL="\033[1;0m"
+	STRONG="\033[1;1m"
+	RED="\033[1;31m"
+	GREEN="\033[1;32m"
+	YELLOW="\033[1;33m"
+	BLUE="\033[1;34m"
+fi	
+	
+
+# functions
+msg() {
+	local prompt="$GREEN>>>${NORMAL}"
+	local fake="${FAKEROOTKEY:+${BLUE}(fakeroot)${NORMAL} }"
+	local name="${STRONG}${subpkgname:-$pkgname}${NORMAL}"
+	[ -z "$quiet" ] && printf "${prompt} ${fake}${name}: $@\n" >&2
+}
+
+warning() {
+	local prompt="${YELLOW}>>> WARNING: ${NORMAL}"
+	local fake="${FAKEROOTKEY:+${BLUE}(fakeroot)${NORMAL} }"
+	local name="${STRONG}${subpkgname:-$pkgname}${NORMAL}"
+	printf "${prompt} ${fake}${name}: $@\n" >&2
+}
+
+error() {
+	local prompt="${RED}>>> ERROR: ${NORMAL}"
+	local fake="${FAKEROOTKEY:+${BLUE}(fakeroot)${NORMAL} }"
+	local name="${STRONG}${subpkgname:-$pkgname}${NORMAL}"
+	printf "${prompt} ${fake}${name}: $@\n" >&2
+}
+