home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 November / CPNL0711.ISO / communic / email / Evolution-2.8.2-2.msi / Data1.cab / gnome_autogen.sh < prev    next >
Linux/UNIX/POSIX Shell Script  |  2007-03-07  |  14KB  |  429 lines

  1. #!/bin/sh
  2. # Run this to generate all the initial makefiles, etc.
  3.  
  4. #name of package
  5. PKG_NAME=${PKG_NAME:-Package}
  6. srcdir=${srcdir:-.}
  7.  
  8. # default version requirements ...
  9. REQUIRED_AUTOCONF_VERSION=${REQUIRED_AUTOCONF_VERSION:-2.53}
  10. REQUIRED_AUTOMAKE_VERSION=${REQUIRED_AUTOMAKE_VERSION:-1.4}
  11. REQUIRED_LIBTOOL_VERSION=${REQUIRED_LIBTOOL_VERSION:-1.4.3}
  12. REQUIRED_GETTEXT_VERSION=${REQUIRED_GETTEXT_VERSION:-0.10.40}
  13. REQUIRED_GLIB_GETTEXT_VERSION=${REQUIRED_GLIB_GETTEXT_VERSION:-2.2.0}
  14. REQUIRED_INTLTOOL_VERSION=${REQUIRED_INTLTOOL_VERSION:-0.25}
  15. REQUIRED_PKG_CONFIG_VERSION=${REQUIRED_PKG_CONFIG_VERSION:-0.14.0}
  16. REQUIRED_GTK_DOC_VERSION=${REQUIRED_GTK_DOC_VERSION:-1.0}
  17. REQUIRED_DOC_COMMON_VERSION=${REQUIRED_DOC_COMMON_VERSION:-2.3.0}
  18. REQUIRED_GNOME_DOC_UTILS_VERSION=${REQUIRED_GNOME_DOC_UTILS_VERSION:-0.3.2}
  19.  
  20. # a list of required m4 macros.  Package can set an initial value
  21. REQUIRED_M4MACROS=${REQUIRED_M4MACROS:-}
  22. FORBIDDEN_M4MACROS=${FORBIDDEN_M4MACROS:-}
  23.  
  24. # Not all echo versions allow -n, so we check what is possible. This test is
  25. # based on the one in autoconf.
  26. case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
  27.   *c*,-n*) ECHO_N= ;;
  28.   *c*,*  ) ECHO_N=-n ;;
  29.   *)       ECHO_N= ;;
  30. esac
  31.  
  32. # some terminal codes ...
  33. boldface="`tput bold 2>/dev/null`"
  34. normal="`tput sgr0 2>/dev/null`"
  35. printbold() {
  36.     echo $ECHO_N "$boldface"
  37.     echo "$@"
  38.     echo $ECHO_N "$normal"
  39. }    
  40. printerr() {
  41.     echo "$@" >&2
  42. }
  43.  
  44. # Usage:
  45. #     compare_versions MIN_VERSION ACTUAL_VERSION
  46. # returns true if ACTUAL_VERSION >= MIN_VERSION
  47. compare_versions() {
  48.     ch_min_version=$1
  49.     ch_actual_version=$2
  50.     ch_status=0
  51.     IFS="${IFS=         }"; ch_save_IFS="$IFS"; IFS="."
  52.     set $ch_actual_version
  53.     for ch_min in $ch_min_version; do
  54.         ch_cur=`echo $1 | sed 's/[^0-9].*$//'`; shift # remove letter suffixes
  55.         if [ -z "$ch_min" ]; then break; fi
  56.         if [ -z "$ch_cur" ]; then ch_status=1; break; fi
  57.         if [ $ch_cur -gt $ch_min ]; then break; fi
  58.         if [ $ch_cur -lt $ch_min ]; then ch_status=1; break; fi
  59.     done
  60.     IFS="$ch_save_IFS"
  61.     return $ch_status
  62. }
  63.  
  64. # Usage:
  65. #     version_check PACKAGE VARIABLE CHECKPROGS MIN_VERSION SOURCE
  66. # checks to see if the package is available
  67. version_check() {
  68.     vc_package=$1
  69.     vc_variable=$2
  70.     vc_checkprogs=$3
  71.     vc_min_version=$4
  72.     vc_source=$5
  73.     vc_status=1
  74.  
  75.     vc_checkprog=`eval echo "\\$$vc_variable"`
  76.     if [ -n "$vc_checkprog" ]; then
  77.     printbold "using $vc_checkprog for $vc_package"
  78.     return 0
  79.     fi
  80.  
  81.     if test "x$vc_package" = "xautomake" -a "x$vc_min_version" = "x1.4"; then
  82.     vc_comparator="="
  83.     else
  84.     vc_comparator=">="
  85.     fi
  86.     printbold "checking for $vc_package $vc_comparator $vc_min_version..."
  87.     for vc_checkprog in $vc_checkprogs; do
  88.     echo $ECHO_N "  testing $vc_checkprog... "
  89.     if $vc_checkprog --version < /dev/null > /dev/null 2>&1; then
  90.         vc_actual_version=`$vc_checkprog --version | head -n 1 | \
  91.                                sed 's/^.*[     ]\([0-9.]*[a-z]*\).*$/\1/'`
  92.         if compare_versions $vc_min_version $vc_actual_version; then
  93.         echo "found $vc_actual_version"
  94.         # set variable
  95.         eval "$vc_variable=$vc_checkprog"
  96.         vc_status=0
  97.         break
  98.         else
  99.         echo "too old (found version $vc_actual_version)"
  100.         fi
  101.     else
  102.         echo "not found."
  103.     fi
  104.     done
  105.     if [ "$vc_status" != 0 ]; then
  106.     printerr "***Error***: You must have $vc_package $vc_comparator $vc_min_version installed"
  107.     printerr "  to build $PKG_NAME.  Download the appropriate package for"
  108.     printerr "  from your distribution or get the source tarball at"
  109.         printerr "    $vc_source"
  110.     printerr
  111.     fi
  112.     return $vc_status
  113. }
  114.  
  115. # Usage:
  116. #     require_m4macro filename.m4
  117. # adds filename.m4 to the list of required macros
  118. require_m4macro() {
  119.     case "$REQUIRED_M4MACROS" in
  120.     $1\ * | *\ $1\ * | *\ $1) ;;
  121.     *) REQUIRED_M4MACROS="$REQUIRED_M4MACROS $1" ;;
  122.     esac
  123. }
  124.  
  125. forbid_m4macro() {
  126.     case "$FORBIDDEN_M4MACROS" in
  127.     $1\ * | *\ $1\ * | *\ $1) ;;
  128.     *) FORBIDDEN_M4MACROS="$FORBIDDEN_M4MACROS $1" ;;
  129.     esac
  130. }
  131.  
  132. # Usage:
  133. #     check_m4macros
  134. # Checks that all the requested macro files are in the aclocal macro path
  135. # Uses REQUIRED_M4MACROS and ACLOCAL variables.
  136. check_m4macros() {
  137.     # construct list of macro directories
  138.     cm_macrodirs="`$ACLOCAL --print-ac-dir`"
  139.     set - $ACLOCAL_FLAGS
  140.     while [ $# -gt 0 ]; do
  141.     if [ "$1" = "-I" ]; then
  142.         cm_macrodirs="$cm_macrodirs $2"
  143.         shift
  144.     fi
  145.     shift
  146.     done
  147.  
  148.     cm_status=0
  149.     if [ -n "$REQUIRED_M4MACROS" ]; then
  150.     printbold "Checking for required M4 macros..."
  151.     # check that each macro file is in one of the macro dirs
  152.     for cm_macro in $REQUIRED_M4MACROS; do
  153.         cm_macrofound=false
  154.         for cm_dir in $cm_macrodirs; do
  155.         if [ -f "$cm_dir/$cm_macro" ]; then
  156.             cm_macrofound=true
  157.             break
  158.         fi
  159.         # The macro dir in Cygwin environments may contain a file
  160.         # called dirlist containing other directories to look in.
  161.         if [ -f "$cm_dir/dirlist" ]; then
  162.             for cm_otherdir in `cat $cm_dir/dirlist`; do
  163.             if [ -f "$cm_otherdir/$cm_macro" ]; then
  164.                 cm_macrofound=true
  165.                     break
  166.             fi
  167.             done
  168.         fi
  169.         done
  170.         if $cm_macrofound; then
  171.         :
  172.         else
  173.         printerr "  $cm_macro not found"
  174.         cm_status=1
  175.         fi
  176.     done
  177.     fi
  178.     if [ -n "$FORBIDDEN_M4MACROS" ]; then
  179.     printbold "Checking for forbidden M4 macros..."
  180.     # check that each macro file is in one of the macro dirs
  181.     for cm_macro in $FORBIDDEN_M4MACROS; do
  182.         cm_macrofound=false
  183.         for cm_dir in $cm_macrodirs; do
  184.         if [ -f "$cm_dir/$cm_macro" ]; then
  185.             cm_macrofound=true
  186.             break
  187.         fi
  188.         done
  189.         if $cm_macrofound; then
  190.         printerr "  $cm_macro found (should be cleared from macros dir)"
  191.         cm_status=1
  192.         fi
  193.     done
  194.     fi
  195.     if [ "$cm_status" != 0 ]; then
  196.     printerr "***Error***: some autoconf macros required to build $PKG_NAME"
  197.     printerr "  were not found in your aclocal path, or some forbidden"
  198.     printerr "  macros were found.  Perhaps you need to adjust your"
  199.     printerr "  ACLOCAL_FLAGS?"
  200.     printerr
  201.     fi
  202.     return $cm_status
  203. }
  204.  
  205. # try to catch the case where the macros2/ directory hasn't been cleared out.
  206. forbid_m4macro gnome-cxx-check.m4
  207.  
  208. want_libtool=false
  209. want_gettext=false
  210. want_glib_gettext=false
  211. want_intltool=false
  212. want_pkg_config=false
  213. want_gtk_doc=false
  214. want_gnome_doc_utils=false
  215.  
  216. configure_files="`find $srcdir -name '{arch}' -prune -o -name configure.ac -print -o -name configure.in -print`"
  217. for configure_ac in $configure_files; do
  218.     if grep "^A[CM]_PROG_LIBTOOL" $configure_ac >/dev/null || \
  219.        grep "^LT_INIT" $configure_ac >/dev/null; then
  220.     want_libtool=true
  221.     fi
  222.     if grep "^AM_GNU_GETTEXT" $configure_ac >/dev/null; then
  223.     want_gettext=true
  224.     fi
  225.     if grep "^AM_GLIB_GNU_GETTEXT" $configure_ac >/dev/null; then
  226.     want_glib_gettext=true
  227.     fi
  228.     if grep "^\(AC\|IT\)_PROG_INTLTOOL" $configure_ac >/dev/null; then
  229.     want_intltool=true
  230.     fi
  231.     if grep "^PKG_CHECK_MODULES" $configure_ac >/dev/null; then
  232.     want_pkg_config=true
  233.     fi
  234.     if grep "^GTK_DOC_CHECK" $configure_ac >/dev/null; then
  235.     want_gtk_doc=true
  236.     fi
  237.     if grep "^GNOME_DOC_INIT" $configure_ac >/dev/null; then
  238.         want_gnome_doc_utils=true
  239.     fi
  240. done
  241.  
  242. DIE=0
  243.  
  244. #tell Mandrake autoconf wrapper we want autoconf 2.5x, not 2.13
  245. WANT_AUTOCONF_2_5=1
  246. export WANT_AUTOCONF_2_5
  247. version_check autoconf AUTOCONF 'autoconf2.50 autoconf autoconf-2.53' $REQUIRED_AUTOCONF_VERSION \
  248.     "http://ftp.gnu.org/pub/gnu/autoconf/autoconf-$REQUIRED_AUTOCONF_VERSION.tar.gz" || DIE=1
  249. AUTOHEADER=`echo $AUTOCONF | sed s/autoconf/autoheader/`
  250.  
  251. case $REQUIRED_AUTOMAKE_VERSION in
  252.     1.4*) automake_progs="automake-1.4" ;;
  253.     1.5*) automake_progs="automake-1.5 automake-1.6 automake-1.7 automake-1.8 automake-1.9" ;;
  254.     1.6*) automake_progs="automake-1.6 automake-1.7 automake-1.8 automake-1.9" ;;
  255.     1.7*) automake_progs="automake-1.7 automake-1.8 automake-1.9" ;;
  256.     1.8*) automake_progs="automake-1.8 automake-1.9" ;;
  257.     1.9*) automake_progs="automake-1.9" ;;
  258. esac
  259. version_check automake AUTOMAKE "$automake_progs" $REQUIRED_AUTOMAKE_VERSION \
  260.     "http://ftp.gnu.org/pub/gnu/automake/automake-$REQUIRED_AUTOMAKE_VERSION.tar.gz" || DIE=1
  261. ACLOCAL=`echo $AUTOMAKE | sed s/automake/aclocal/`
  262.  
  263. if $want_libtool; then
  264.     version_check libtool LIBTOOLIZE libtoolize $REQUIRED_LIBTOOL_VERSION \
  265.         "http://ftp.gnu.org/pub/gnu/libtool/libtool-$REQUIRED_LIBTOOL_VERSION.tar.gz" || DIE=1
  266.     require_m4macro libtool.m4
  267. fi
  268.  
  269. if $want_gettext; then
  270.     version_check gettext GETTEXTIZE gettextize $REQUIRED_GETTEXT_VERSION \
  271.         "http://ftp.gnu.org/pub/gnu/gettext/gettext-$REQUIRED_GETTEXT_VERSION.tar.gz" || DIE=1
  272.     require_m4macro gettext.m4
  273. fi
  274.  
  275. if $want_glib_gettext; then
  276.     version_check glib-gettext GLIB_GETTEXTIZE glib-gettextize $REQUIRED_GLIB_GETTEXT_VERSION \
  277.         "ftp://ftp.gtk.org/pub/gtk/v2.2/glib-$REQUIRED_GLIB_GETTEXT_VERSION.tar.gz" || DIE=1
  278.     require_m4macro glib-gettext.m4
  279. fi
  280.  
  281. if $want_intltool; then
  282.     version_check intltool INTLTOOLIZE intltoolize $REQUIRED_INTLTOOL_VERSION \
  283.         "http://ftp.gnome.org/pub/GNOME/sources/intltool/" || DIE=1
  284.     require_m4macro intltool.m4
  285. fi
  286.  
  287. if $want_pkg_config; then
  288.     version_check pkg-config PKG_CONFIG pkg-config $REQUIRED_PKG_CONFIG_VERSION \
  289.         "'http://www.freedesktop.org/software/pkgconfig/releases/pkgconfig-$REQUIRED_PKG_CONFIG_VERSION.tar.gz" || DIE=1
  290.     require_m4macro pkg.m4
  291. fi
  292.  
  293. if $want_gtk_doc; then
  294.     version_check gtk-doc GTKDOCIZE gtkdocize $REQUIRED_GTK_DOC_VERSION \
  295.         "http://ftp.gnome.org/pub/GNOME/sources/gtk-doc/" || DIE=1
  296.     require_m4macro gtk-doc.m4
  297. fi
  298.  
  299. if $want_gnome_doc_utils; then
  300.     version_check gnome-doc-utils GNOME_DOC_PREPARE gnome-doc-prepare $REQUIRED_GNOME_DOC_UTILS_VERSION \
  301.         "http://ftp.gnome.org/pub/GNOME/sources/gnome-doc-utils/" || DIE=1
  302. fi
  303.  
  304. if [ "x$USE_COMMON_DOC_BUILD" = "xyes" ]; then
  305.     version_check gnome-common DOC_COMMON gnome-doc-common \
  306.         $REQUIRED_DOC_COMMON_VERSION " " || DIE=1
  307. fi
  308.  
  309. check_m4macros || DIE=1
  310.  
  311. if [ "$DIE" -eq 1 ]; then
  312.   exit 1
  313. fi
  314.  
  315. if [ "$#" = 0 ]; then
  316.   printerr "**Warning**: I am going to run \`configure' with no arguments."
  317.   printerr "If you wish to pass any to it, please specify them on the"
  318.   printerr \`$0\'" command line."
  319.   printerr
  320. fi
  321.  
  322. topdir=`pwd`
  323. for configure_ac in $configure_files; do 
  324.     dirname=`dirname $configure_ac`
  325.     basename=`basename $configure_ac`
  326.     if [ -f $dirname/NO-AUTO-GEN ]; then
  327.     echo skipping $dirname -- flagged as no auto-gen
  328.     elif [ ! -w $dirname ]; then
  329.         echo skipping $dirname -- directory is read only
  330.     else
  331.     printbold "Processing $configure_ac"
  332.     cd $dirname
  333.  
  334.         # Note that the order these tools are called should match what
  335.         # autoconf's "autoupdate" package does.  See bug 138584 for
  336.         # details.
  337.  
  338.         # programs that might install new macros get run before aclocal
  339.     if grep "^A[CM]_PROG_LIBTOOL" $basename >/dev/null || \
  340.        grep "^LT_INIT" $basename >/dev/null; then
  341.         printbold "Running $LIBTOOLIZE..."
  342.         $LIBTOOLIZE --force --copy || exit 1
  343.     fi
  344.  
  345.     if grep "^AM_GLIB_GNU_GETTEXT" $basename >/dev/null; then
  346.         printbold "Running $GLIB_GETTEXTIZE... Ignore non-fatal messages."
  347.         echo "no" | $GLIB_GETTEXTIZE --force --copy || exit 1
  348.     elif grep "^AM_GNU_GETTEXT" $basename >/dev/null; then
  349.        if grep "^AM_GNU_GETTEXT_VERSION" $basename > /dev/null; then
  350.            printbold "Running autopoint..."
  351.         autopoint --force || exit 1
  352.        else
  353.             printbold "Running $GETTEXTIZE... Ignore non-fatal messages."
  354.             echo "no" | $GETTEXTIZE --force --copy || exit 1
  355.        fi
  356.     fi
  357.  
  358.     if grep "^\(AC\|IT\)_PROG_INTLTOOL" $basename >/dev/null; then
  359.         printbold "Running $INTLTOOLIZE..."
  360.         $INTLTOOLIZE --force --copy --automake || exit 1
  361.     fi
  362.     if grep "^GTK_DOC_CHECK" $basename >/dev/null; then
  363.         printbold "Running $GTKDOCIZE..."
  364.         $GTKDOCIZE --copy || exit 1
  365.     fi
  366.  
  367.     if [ "x$USE_COMMON_DOC_BUILD" = "xyes" ]; then
  368.         printbold "Running gnome-doc-common..."
  369.         gnome-doc-common --copy || exit 1
  370.     fi
  371.     if grep "^GNOME_DOC_INIT" $basename >/dev/null; then
  372.         printbold "Running $GNOME_DOC_PREPARE..."
  373.         $GNOME_DOC_PREPARE --copy || exit 1
  374.     fi
  375.  
  376.         # Now run aclocal to pull in any additional macros needed
  377.  
  378.     # if the AC_CONFIG_MACRO_DIR() macro is used, pass that
  379.     # directory to aclocal.
  380.     m4dir=`cat "$basename" | grep '^AC_CONFIG_MACRO_DIR' | sed -n -e 's/AC_CONFIG_MACRO_DIR(\([^()]*\))/\1/p' | sed -e 's/^\[\(.*\)\]$/\1/' | sed -e 1q`
  381.     if [ -n "$m4dir" ]; then
  382.         m4dir="-I $m4dir"
  383.     fi
  384.     printbold "Running $ACLOCAL..."
  385.     $ACLOCAL $m4dir $ACLOCAL_FLAGS || exit 1
  386.  
  387.     if grep "GNOME_AUTOGEN_OBSOLETE" aclocal.m4 >/dev/null; then
  388.         printerr "*** obsolete gnome macros were used in $configure_ac"
  389.     fi
  390.  
  391.     # Now that all the macros are sorted, run autoconf and autoheader ...
  392.     printbold "Running $AUTOCONF..."
  393.     $AUTOCONF || exit 1
  394.     if grep "^A[CM]_CONFIG_HEADER" $basename >/dev/null; then
  395.         printbold "Running $AUTOHEADER..."
  396.         $AUTOHEADER || exit 1
  397.         # this prevents automake from thinking config.h.in is out of
  398.         # date, since autoheader doesn't touch the file if it doesn't
  399.         # change.
  400.         test -f config.h.in && touch config.h.in
  401.     fi
  402.  
  403.     # Finally, run automake to create the makefiles ...
  404.     printbold "Running $AUTOMAKE..."
  405.         cp -pf COPYING COPYING.autogen_bak
  406.         cp -pf INSTALL INSTALL.autogen_bak
  407.     if [ $REQUIRED_AUTOMAKE_VERSION != 1.4 ]; then
  408.         $AUTOMAKE --gnu --add-missing --force --copy || exit 1
  409.     else
  410.         $AUTOMAKE --gnu --add-missing --copy || exit 1
  411.     fi
  412.         cmp COPYING COPYING.autogen_bak || cp -pf COPYING.autogen_bak COPYING
  413.         cmp INSTALL INSTALL.autogen_bak || cp -pf INSTALL.autogen_bak INSTALL
  414.         rm -f COPYING.autogen_bak INSTALL.autogen_bak
  415.  
  416.     cd "$topdir"
  417.     fi
  418. done
  419.  
  420. conf_flags="--enable-maintainer-mode"
  421.  
  422. if test x$NOCONFIGURE = x; then
  423.     printbold Running $srcdir/configure $conf_flags "$@" ...
  424.     $srcdir/configure $conf_flags "$@" \
  425.     && echo Now type \`make\' to compile $PKG_NAME || exit 1
  426. else
  427.     echo Skipping configure process.
  428. fi
  429.