#!/bin/sh

# main defines
./libdep.sh c "-Wall -O -I." "-L." -clean
if [ "$?" = "5" ]; then
exit
fi
echo "$*" > .libdep.args
# conditional libraries
echo "Configuring EasyGTK for your system... "
TRY=`grep "gtk-1.2" .libdep.args`
if [ "$TRY" = "" ]; then
./libdep.sh gtk-1.2 "`gtk-config --cflags` -I/usr/X11R6/include/X11" "`gtk-config --libs`" -fail "The GTK library version 1.2 is needed for EasyGTK to compile" 
if [ "$?" = "5" ]; then
exit
fi
fi
TRY=`grep "Imlib" .libdep.args`
if [ "$TRY" = "" ]; then
./libdep.sh Imlib "-DUSE_IMLIB" "-lgdk_imlib `imlib-config --libs` -I/usr/include/glib" 
if [ "$?" = "5" ]; then
exit
fi
fi
TRY=`grep "Magick" .libdep.args`
if [ "$TRY" = "" ]; then
./libdep.sh Magick "-DUSE_MAGICK -I/usr/X11R6/include/X11/magick -I/usr/local/include/magick" "-L/usr/local/lib -lMagick -ltiff -ljpeg" 
if [ "$?" = "5" ]; then
exit
fi
fi
TRY=`grep "gnome" .libdep.args`
if [ "$TRY" = "" ]; then
./libdep.sh gnome "-DUSE_GNOME `gnome-config --cflags gnome gnomeui`" "`gnome-config --libs gnome gnomeui`" 
if [ "$?" = "5" ]; then
exit
fi
fi
# output creation
echo "Creating Makefile"
echo -n "CFLAGS = " > Makefile
cat .libdep.cflags >> Makefile
echo "" >> Makefile
echo -n "LIBS = " >> Makefile
cat .libdep.libs >> Makefile
echo "" >> Makefile
cat Makefile.libdep >> Makefile
