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