cd $root/src
notice "$MENUTRUE" "Getting GD lib's with zlib+PNG+JPEG+Freetype2+T1libs support ready...\n"

. $root/bin/libtruetype1
. $root/bin/libz
. $root/bin/libpng
. $root/bin/libjpeg
#. $root/bin/libxpm
. $root/bin/libfreetype2


if [ $LIBTRUETYPE1_DIR ] && [ $LIBZ_DIR ] && [ $LIBPNG_DIR ] && [ $LIBJPEG_DIR ] && [ $LIBFREETYPE2_DIR ]
then


###############################################################################################

 cd $root/src   
 check_source "gd-${GD}.tar.gz" "http://www.boutell.com/gd/http/gd-${GD}.tar.gz"            

 notice "$MENUTRUE" " Setting up GD with PNG, zlib, JPEG, Freetype2, and TrueType1 support...\n"
 explode gd-$GD.tar.gz
 notice "$MENUTRUE" "  Untared GD library...\n"
 test -d "$root/src/gd" && rm -rf "$root/src/gd"
 $MV -f gd-$GD gd
 cd gd

 notice "$MENUTRUE" "  Compiling GD library with zlib+PNG+JPEG+Freetype+T1lib support..."

 #$LN -s $root/src/freetype-${FREETYPE}/include/freetype freetype
 $LN -s ${LIBFREETYPE2_DIR}/include/freetype2/freetype freetype

 export CPPFLAGS="-I$LOCAL_PATH/include -I$LIBTRUETYPE1_DIR/include -I$LIBZ_DIR/include -I$LIBPNG_DIR/include -I$LIBJPEG_DIR/include -I$LIBFREETYPE2_DIR/include"
 $MAKE install LIBDIRS=-L$LOCAL_PATH/lib INSTALL_BIN=$LOCAL_PATH/bin INSTALL_LIB=$LOCAL_PATH/lib INSTALL_INCLUDE=$LOCAL_PATH/include &> $logdir/gd-make-install.log
 testcheck $? gd-make-install.log

 $MAKE libgd.a &> $logdir/gd-make-libgd.a.log
 testcheck $? gd-libgd.a.log

 $CP -f libgd.a $LOCAL_PATH/lib &> $logdir/gd-copy.log
 testcheck $? gd-copy.log
 echo " [$DONE]"

 cd ..
 notice "$MENUTRUE" " GD library setup.\n"
 export LIBGD_DIR="$LOCAL_PATH";

 CONFIGPHP="$CONFIGPHP--with-gd=\"$LIBGD_DIR\" $r--with-zlib $r--enable-gd-native-tt $r--with-t1lib=\"$LIBTRUETYPE1_DIR\" $r--with-jpeg-dir=\"$LIBJPEG_DIR\" $r--with-png-dir=\"$LIBPNG_DIR\" $r--with-zlib-dir=\"$LIBZ_DIR\" $r--with-ttf $r--with-freetype-dir=\"$LIBFREETYPE2_DIR\" $r"

###############################################################################################

notice "$MENUTRUE" "GD library with zlib+PNG+JPEG+Freetype2+T1lib support setup!\n"


else
  notice "$MENUFALSE" "Missing a lib required by GD!\n"
  echo -e  "LIBTRUETYPE1_DIR=$LIBTRUETYPE1_DIR\nLIBZ_DIR=$LIBZ_DIR\nLIBPNG_DIR=$LIBPNG_DIR\nLIBJPEG_DIR=$LIBJPEG_DIR\nLIBFREETYPE2_DIR=$LIBFREETYPE2_DIR"
  exit 1
fi



cd $root
