renatofilho@21: #!/bin/sh
renatofilho@21: # Run this to generate all the initial makefiles, etc.
renatofilho@21: 
renatofilho@21: DIE=0
renatofilho@21: package=gmyth
renatofilho@21: srcfile=configure.ac
renatofilho@21: 
renatofilho@21: # a quick cvs co if necessary to alleviate the pain - may remove this
renatofilho@21: # when developers get a clue ;)
renatofilho@21: if test ! -d common; 
renatofilho@21: then 
renatofilho@21:   echo "+ getting common/ from svn"
renatofilho@21:  svn co common 
renatofilho@21: fi
renatofilho@21: 
renatofilho@21: # source helper functions
renatofilho@21: if test ! -f common/autogen-helper.sh;
renatofilho@21: then
renatofilho@21:   echo There is something wrong with your source tree.
renatofilho@21:   echo You are missing common/autogen-helper.sh
renatofilho@21:   exit 1
renatofilho@21: fi
renatofilho@21: . common/autogen-helper.sh
renatofilho@21: 
renatofilho@21: CONFIGURE_DEF_OPT='--enable-maintainer-mode'
renatofilho@21: 
renatofilho@21: autogen_options 
renatofilho@21: 
renatofilho@21: echo -n "+ check for build tools"
renatofilho@21: if test ! -z "$NOCHECK"; then echo " skipped"; else  echo; fi
renatofilho@21: version_check "autoconf" "$AUTOCONF autoconf autoconf-2.54 autoconf-2.53" \
renatofilho@21:               "ftp://ftp.gnu.org/pub/gnu/autoconf/" 2 53 || DIE=1
renatofilho@21: version_check "automake" "$AUTOMAKE automake automake-1.9 automake-1.8 automake-1.7 automake-1.6" \
renatofilho@21:               "ftp://ftp.gnu.org/pub/gnu/automake/" 1 6 || DIE=1
renatofilho@21: version_check "libtoolize" "$LIBTOOLIZE libtoolize" \
renatofilho@21:               "ftp://ftp.gnu.org/pub/gnu/libtool/" 1 5 0 || DIE=1
renatofilho@21: version_check "pkg-config" "" \
renatofilho@21:               "http://www.freedesktop.org/software/pkgconfig" 0 8 0 || DIE=1
renatofilho@21: 
renatofilho@21: die_check $DIE
renatofilho@21: 
renatofilho@21: aclocal_check || DIE=1
renatofilho@21: autoheader_check || DIE=1
renatofilho@21: 
renatofilho@21: die_check $DIE
renatofilho@21: 
renatofilho@21: # if no arguments specified then this will be printed
renatofilho@21: if test -z "$*"; then
renatofilho@21:   echo "+ checking for autogen.sh options"
renatofilho@21:   echo "  This autogen script will automatically run ./configure as:"
renatofilho@21:   echo "  ./configure $CONFIGURE_DEF_OPT"
renatofilho@21:   echo "  To pass any additional options, please specify them on the $0"
renatofilho@21:   echo "  command line."
renatofilho@21: fi
renatofilho@21: 
renatofilho@21: toplevel_check $srcfile
renatofilho@21: 
renatofilho@21: tool_run "$aclocal" "-I m4 $ACLOCAL_FLAGS"
renatofilho@21: tool_run "$libtoolize" "--copy --force"
renatofilho@21: tool_run "$autoheader"
renatofilho@21: 
renatofilho@21: # touch the stamp-h.in build stamp so we don't re-run autoheader in maintainer mode -- wingo
renatofilho@21: echo timestamp > stamp-h.in 2> /dev/null
renatofilho@21: 
renatofilho@21: tool_run "$autoconf"
renatofilho@21: tool_run "$automake" "-a -c"
renatofilho@21: 
renatofilho@21: # if enable exists, add an -enable option for each of the lines in that file
renatofilho@21: if test -f enable; then
renatofilho@21:   for a in `cat enable`; do
renatofilho@21:     CONFIGURE_FILE_OPT="--enable-$a"
renatofilho@21:   done
renatofilho@21: fi
renatofilho@21: 
renatofilho@21: # if disable exists, add an -disable option for each of the lines in that file
renatofilho@21: if test -f disable; then
renatofilho@21:   for a in `cat disable`; do
renatofilho@21:     CONFIGURE_FILE_OPT="$CONFIGURE_FILE_OPT --disable-$a"
renatofilho@21:   done
renatofilho@21: fi
renatofilho@21: 
renatofilho@21: test -n "$NOCONFIGURE" && {
renatofilho@21:   echo "+ skipping configure stage for package $package, as requested."
renatofilho@21:   echo "+ autogen.sh done."
renatofilho@21:   exit 0
renatofilho@21: }
renatofilho@21: 
renatofilho@21: echo "+ running configure ... "
renatofilho@21: test ! -z "$CONFIGURE_DEF_OPT" && echo "  ./configure default flags: $CONFIGURE_DEF_OPT"
renatofilho@21: test ! -z "$CONFIGURE_EXT_OPT" && echo "  ./configure external flags: $CONFIGURE_EXT_OPT"
renatofilho@21: test ! -z "$CONFIGURE_FILE_OPT" && echo "  ./configure enable/disable flags: $CONFIGURE_FILE_OPT"
renatofilho@21: echo
renatofilho@21: 
renatofilho@21: ./configure $CONFIGURE_DEF_OPT $CONFIGURE_EXT_OPT $CONFIGURE_FILE_OPT || {
renatofilho@21:         echo "  configure failed"
renatofilho@21:         exit 1
renatofilho@21: }
renatofilho@21: 
renatofilho@21: echo "Now type 'make' to compile $package."