--- scripts/macport_build.py.orig	2013-02-26 07:56:41.000000000 -0600
+++ scripts/macport_build.py	2013-02-27 20:39:32.000000000 -0600
@@ -5,6 +5,7 @@
 import subprocess
 import sys
 from optparse import OptionParser
+from translations import compile_translations
 
 import configfile
 
@@ -15,68 +16,179 @@
 		print("Error: " + cmd)
 		exit(1)
 
-def build (prefix):
+def build(prefix, cc, cflags, ldflags):
+	compile_translations ()
+	
 	#libbirdfont
 	run("mkdir -p build/libbirdfont")
 	run("mkdir -p build/bin")
 
-	run("valac -C --basedir build/libbirdfont/ --enable-experimental-non-null --enable-experimental --define=MAC --library libbirdfont -H build/libbirdfont/birdfont.h libbirdfont/* --pkg libxml-2.0 --pkg gio-2.0  --pkg cairo --pkg libsoup-2.4 --pkg gdk-pixbuf-2.0 --pkg webkit-1.0")
+	run("""valac \
+		-C \
+		--basedir build/libbirdfont/ \
+		--enable-experimental-non-null \
+		--enable-experimental \
+		--define=MAC \
+		--library libbirdfont \
+		-H build/libbirdfont/birdfont.h \
+		libbirdfont/* \
+		--pkg libxml-2.0 \
+		--pkg gio-2.0 \
+		--pkg cairo \
+		--pkg libsoup-2.4 \
+		--pkg gdk-pixbuf-2.0 \
+		--pkg webkit-1.0""")
 	run("cp libbirdfont/*.c build/libbirdfont/")
 
-	run("""gcc -c build/libbirdfont/*.c -shared -fno-common -fPIC -D 'GETTEXT_PACKAGE="birdfont"' $(pkg-config --cflags --libs libxml-2.0) $(pkg-config --cflags --libs gio-2.0) $(pkg-config --cflags --libs cairo) $(pkg-config --cflags --libs glib-2.0) $(pkg-config --cflags --libs gdk-pixbuf-2.0) $(pkg-config --cflags --libs webkit-1.0) -I ./build/mac/birdfont""")
+	run(cc + " " + cflags + """ \
+		-c build/libbirdfont/*.c \
+		-fno-common \
+		-fPIC \
+		-D 'GETTEXT_PACKAGE="birdfont"' \
+		$(pkg-config --cflags libxml-2.0) \
+		$(pkg-config --cflags gio-2.0) \
+		$(pkg-config --cflags cairo) \
+		$(pkg-config --cflags glib-2.0) \
+		$(pkg-config --cflags gdk-pixbuf-2.0) \
+		$(pkg-config --cflags webkit-1.0) \
+		-I ./build/mac/birdfont""")
 	run("mv ./*.o build/libbirdfont/ ")
 
-	run("gcc -dynamiclib -Wl,-headerpad_max_install_names,-undefined,dynamic_lookup,-compatibility_version,1.0,-current_version,1.0,-install_name,/usr/local/lib/libbirdfont.dylib -shared build/libbirdfont/*.o $(pkg-config --cflags --libs libxml-2.0) $(pkg-config --cflags --libs gio-2.0) $(pkg-config --cflags --libs cairo) $(pkg-config --cflags --libs glib-2.0) $(pkg-config --cflags --libs gdk-pixbuf-2.0) $(pkg-config --cflags --libs webkit-1.0) -shared -o libbirdfont.dylib")
+	run(cc + " " + ldflags + """ \
+		-dynamiclib -Wl,-headerpad_max_install_names,-undefined,dynamic_lookup,-compatibility_version,1.0,-current_version,1.0,-install_name,""" + prefix + """/lib/libbirdfont.dylib -shared build/libbirdfont/*.o \
+		 $(pkg-config --libs libxml-2.0) \
+		 $(pkg-config --libs gio-2.0) \
+		 $(pkg-config --libs cairo) \
+		 $(pkg-config --libs glib-2.0) \
+		 $(pkg-config --libs gdk-pixbuf-2.0) \
+		 $(pkg-config --libs webkit-1.0) \
+		 -shared -o libbirdfont.dylib""")
 	run("mv libbirdfont.dylib build/bin/")
-	run ("install_name_tool -id " + prefix + "/lib/libbirdfont.dylib build/bin/libbirdfont.dylib")
 
 	# birdfont
 	run("mkdir -p build/birdfont")
 	
-	run("valac -C --enable-experimental-non-null --enable-experimental --define=MAC birdfont/* --vapidir=./ --pkg libxml-2.0 --pkg gio-2.0  --pkg cairo --pkg libsoup-2.4 --pkg gdk-pixbuf-2.0 --pkg webkit-1.0 --pkg gtk+-2.0 --pkg libbirdfont")
+	run("""valac \
+		-C \
+		--enable-experimental-non-null \
+		--enable-experimental \
+		--define=MAC birdfont/* \
+		--vapidir=./ \
+		--pkg libxml-2.0 \
+		--pkg gio-2.0  \
+		--pkg cairo \
+		--pkg libsoup-2.4 \
+		--pkg gdk-pixbuf-2.0 \
+		--pkg webkit-1.0 \
+		--pkg gtk+-2.0\
+		--pkg libbirdfont""")
 	run("mv birdfont/*.c build/birdfont/")
 
-	run("""gcc -c ./build/libbirdfont/birdfont.h build/birdfont/*.c -D 'GETTEXT_PACKAGE="birdfont"' $(pkg-config --cflags libxml-2.0) $(pkg-config --cflags gio-2.0) $(pkg-config --cflags cairo) $(pkg-config --cflags glib-2.0) $(pkg-config --cflags gdk-pixbuf-2.0) $(pkg-config --cflags webkit-1.0) -I ./build/libbirdfont/""")
+	run(cc + " " + cflags + """\
+		-c ./build/libbirdfont/birdfont.h build/birdfont/*.c \
+		-D 'GETTEXT_PACKAGE="birdfont"' \
+		$(pkg-config --cflags libxml-2.0) \
+		$(pkg-config --cflags gio-2.0) \
+		$(pkg-config --cflags cairo) \
+		$(pkg-config --cflags glib-2.0) \
+		$(pkg-config --cflags gdk-pixbuf-2.0) \
+		$(pkg-config --cflags webkit-1.0) \
+		-I ./build/libbirdfont/""")
 	run("mv ./*.o build/birdfont/")
 
-	run("gcc build/birdfont/*.o ./build/bin/libbirdfont.dylib $(pkg-config --cflags --libs libxml-2.0) $(pkg-config --cflags --libs gio-2.0) $(pkg-config --cflags --libs cairo) $(pkg-config --cflags --libs glib-2.0) $(pkg-config --cflags --libs gdk-pixbuf-2.0) $(pkg-config --cflags --libs webkit-1.0) $(pkg-config --cflags --libs gtk+-2.0) -o ./build/bin/birdfont")
+	run(cc + " " + ldflags + """ \
+		build/birdfont/*.o ./build/bin/libbirdfont.dylib \
+		$(pkg-config --libs libxml-2.0) \
+		$(pkg-config --libs gio-2.0) \
+		$(pkg-config --libs cairo) \
+		$(pkg-config --libs glib-2.0) \
+		$(pkg-config --libs gdk-pixbuf-2.0) \
+		$(pkg-config --libs webkit-1.0) \
+		$(pkg-config --libs gtk+-2.0) \
+		-o ./build/bin/birdfont""")
 
 	# birdfont-export
 	run("mkdir -p build/birdfont-export")
 	
-	run("valac -C --enable-experimental-non-null --enable-experimental --define=MAC birdfont-export/* --vapidir=./ --pkg libxml-2.0 --pkg gio-2.0  --pkg cairo --pkg libsoup-2.4 --pkg gdk-pixbuf-2.0 --pkg webkit-1.0 --pkg gtk+-2.0 --pkg libbirdfont")
+	run("""valac \
+		-C \
+		--enable-experimental-non-null \
+		--enable-experimental \
+		--define=MAC birdfont-export/* \
+		--vapidir=./ \
+		--pkg libxml-2.0 \
+		--pkg gio-2.0  \
+		--pkg cairo \
+		--pkg libsoup-2.4 \
+		--pkg gdk-pixbuf-2.0 \
+		--pkg webkit-1.0 \
+		--pkg gtk+-2.0 \
+		--pkg libbirdfont""")
 	run("mv birdfont-export/*.c build/birdfont-export/")
 
-	run("""gcc -c ./build/libbirdfont/birdfont.h build/birdfont-export/*.c -D 'GETTEXT_PACKAGE="birdfont"' $(pkg-config --cflags libxml-2.0) $(pkg-config --cflags gio-2.0) $(pkg-config --cflags cairo) $(pkg-config --cflags glib-2.0) $(pkg-config --cflags gdk-pixbuf-2.0) $(pkg-config --cflags webkit-1.0) -I ./build/libbirdfont/""")
+	run(cc + " " + cflags + """ \
+		-c ./build/libbirdfont/birdfont.h build/birdfont-export/*.c \
+		-D 'GETTEXT_PACKAGE="birdfont"' \
+		$(pkg-config --cflags libxml-2.0) \
+		$(pkg-config --cflags gio-2.0) \
+		$(pkg-config --cflags cairo) \
+		$(pkg-config --cflags glib-2.0) \
+		$(pkg-config --cflags gdk-pixbuf-2.0) \
+		$(pkg-config --cflags webkit-1.0) \
+		-I ./build/libbirdfont/""")
 	run("mv ./*.o build/birdfont-export/")
 
-	run("gcc build/birdfont-export/*.o ./build/bin/libbirdfont.dylib $(pkg-config --cflags --libs libxml-2.0) $(pkg-config --cflags --libs gio-2.0) $(pkg-config --cflags --libs cairo) $(pkg-config --cflags --libs glib-2.0) $(pkg-config --cflags --libs gdk-pixbuf-2.0) $(pkg-config --cflags --libs webkit-1.0) $(pkg-config --cflags --libs gtk+-2.0) -o ./build/bin/birdfont-export")
+	run(cc + " " + ldflags + " \
+		build/birdfont-export/*.o \
+		./build/bin/libbirdfont.dylib \
+		$(pkg-config --libs libxml-2.0) \
+		$(pkg-config --libs gio-2.0) \
+		$(pkg-config --libs cairo) \
+		$(pkg-config --libs glib-2.0) \
+		$(pkg-config --libs gdk-pixbuf-2.0) \
+		$(pkg-config --libs webkit-1.0) \
+		$(pkg-config --libs gtk+-2.0) \
+		-o ./build/bin/birdfont-export")
 
 	run("touch build/installed")
 	run("touch build/configured")
+	
 
-def build_app ():
+def build_app (prefix):
 	# application launcher
 	run("mkdir -p build/BirdFont.app")
 	run("mkdir -p build/BirdFont.app/Contents")
-	run("mkdir -p build/BirdFont.app/Contents/MacOs")
+	run("mkdir -p build/BirdFont.app/Contents/MacOS")
 	run("mkdir -p build/BirdFont.app/Contents/Resources")
-
-	run("cp resources/mac/birdfont.sh build/BirdFont.app/Contents/MacOs")
+	
+	startup = open ('build/BirdFont.app/Contents/MacOS/birdfont.sh', 'w+')
+	startup.write ("#!/bin/bash\n")
+	startup.write ("cd \"${0%/*}\"\n")
+	startup.write (prefix + "/bin/birdfont\n")
+	
 	run("cp resources/mac/Info.plist build/BirdFont.app/Contents/")	
 	run("cp resources/mac/birdfont.icns build/BirdFont.app/Contents/Resources")
 
 parser = OptionParser()
-parser.add_option ("-p", "--prefix", dest="prefix", help="install prefix", metavar="PREFIX")
-parser.add_option ("-d", "--dest", dest="dest", help="install to this directory", metavar="DEST")
+parser.add_option("-p", "--prefix", dest="prefix", help="install prefix", metavar="PREFIX")
+parser.add_option("-d", "--dest", dest="dest", help="install to this directory", metavar="DEST")
+parser.add_option("-c", "--cc", dest="cc", help="select the C compiler", metavar="CC")
+parser.add_option("-f", "--cflags", dest="cflags", help="set compiler flags", metavar="CFLAGS")
+parser.add_option("-l", "--ldflags", dest="ldflags", help="set linker flags", metavar="LDFLAGS")
 
 (options, args) = parser.parse_args()
 
 if not options.prefix:
 	options.prefix = "/opt/local"
+if not options.cc:
+	options.cc = "gcc"
+if not options.cflags:
+	options.cflags = ""
+if not options.ldflags:
+	options.ldflags = ""
 
-build (options.prefix)
-build_app ()
+build_app (options.prefix)	
+build (options.prefix, options.cc, options.cflags, options.ldflags)
 
 
 
--- scripts/macport_install.py.orig	2013-02-26 07:56:41.000000000 -0600
+++ scripts/macport_install.py	2013-02-27 20:39:13.000000000 -0600
@@ -39,6 +39,16 @@
 install ('build/bin/birdfont-export', '/bin')	
 install ('build/bin/libbirdfont.dylib', '/lib')
 
+for file in os.listdir('./layout'):
+	install ('layout/' + file, '/share/birdfont/layout')
+
+for file in os.listdir('./icons'):
+	install ('icons/' + file, '/share/birdfont/icons')
+	
+for lang_dir in glob.glob('build/locale/*'):
+	lc = lang_dir.replace ('build/locale/', "")
+	install ('build/locale/' + lc + '/LC_MESSAGES/birdfont.mo', '/share/locale/' + lc + '/LC_MESSAGES' );
+		
 # install application launcher
 if options.app:
 	subprocess.check_call ('mkdir -p ' + dest + '/Applications/', shell=True)
