gui="$1"
if test "$gui" = ""; then
	gui=unix
fi

configure_args="--enable-warnings --enable-fatal-warnings"

function genlinks() {
	case `uname -s` in
	   Darwin) prefix=/opt/local ;;
	   *) prefix=/usr ;;
	esac 
	for i in compile config.guess config.sub depcomp install-sh missing; do 
		$GTK_LN_S $prefix/share/automake-$GTK_AMVERSION/$i $i
	done
	cd m4
	for i in amversion.m4 auxdir.m4 cond-if.m4 cond.m4 depend.m4 depout.m4 header.m4 init.m4 install-sh.m4 lead-dot.m4 maintainer.m4 make.m4 minuso.m4 missing.m4 mkdirp.m4 options.m4 protos.m4 sanity.m4 silent.m4 strip.m4 substnot.m4 tar.m4 prog-cc-c-o.m4 runlog.m4; do
		$GTK_LN_S $prefix/share/aclocal-$GTK_AMVERSION/$i $i
	done
	cd ..
	LC_ALL=C LANG=C LC_TYPE=C $prefix/bin/aclocal-$GTK_AMVERSION -I m4
	LC_ALL=C LANG=C LC_TYPE=C $prefix/bin/automake-$GTK_AMVERSION
	LC_ALL=C LANG=C LC_TYPE=C $prefix/bin/autoheader
	LC_ALL=C LANG=C LC_TYPE=C $prefix/bin/autoconf
}

function rmlinks() {
	for i in compile config.guess config.sub depcomp install-sh missing; do 
		rm -f $i
	done
	cd m4
	for i in amversion.m4 auxdir.m4 cond-if.m4 cond.m4 depend.m4 depout.m4 header.m4 init.m4 install-sh.m4 lead-dot.m4 maintainer.m4 make.m4 minuso.m4 missing.m4 mkdirp.m4 options.m4 protos.m4 sanity.m4 silent.m4 strip.m4 substnot.m4 tar.m4 prog-cc-c-o.m4 runlog.m4; do
		rm -f $i
	done
	cd ..
}

case $gui in
gem|tos)
	. $HOME/gtk/profile /
	PKG_CONFIG_LIBDIR=/usr/m68k-atari-mint/sys-root/usr/lib/pkgconfig
	PKG_CONFIG_PATH=/usr/m68k-atari-mint/sys-root/usr/lib/pkgconfig
	./configure $configure_args --with-gui=gem --host=m68k-atari-mint
	;;
win32)
	. $HOME/gtk/profile /
	./configure $configure_args --with-gui=win32 --host=i686-pc-mingw32
	;;
win64)
	. $HOME/gtk/profile /
	export PKG_CONFIG_PATH=/usr/x86_64-w64-mingw32/lib/pkgconfig
	export PKG_CONFIG_LIBDIR=$PKG_CONFIG_PATH
	./configure $configure_args --with-gui=win32 --host=x86_64-w64-mingw32
	;;
unix|gtk2)
	# . $HOME/gtk/profile
	./configure $configure_args --with-gui=gtk2
	;;
macosx|cocoa|darwin)
	. $HOME/gtk/profile /
	./configure $configure_args --with-gui=cocoa
	;;
none)
	. $HOME/gtk/profile /
	./configure $configure_args --with-gui=none
	;;
genlinks)
	. $HOME/gtk/profile /
	genlinks
	;;
rmlinks)
	. $HOME/gtk/profile /
	rmlinks
	;;
*)
	echo "unsupported gui $gui" >&2
	;;
esac
