autogen.sh
author John Bailey <rekkanoryo@rekkanoryo.org>
Sun Aug 30 20:10:58 2009 -0400 (2009-08-30)
changeset 1046 93089a7ce7f6
parent 980 024928dc4d64
child 1067 2282a87fa776
permissions -rwxr-xr-x
Merge
     1 #! /bin/sh
     2 # Guifications - The end-all, be-all notification framework
     3 # Copyright (C) 2003-2008 Gary Kramlich <grim@reaperworld.com>
     4 #
     5 # This program is free software; you can redistribute it and/or modify it
     6 # under the terms of the GNU General Public License as published by the Free
     7 # Software Foundation; either version 2 of the License, or (at your option)
     8 # any later version.
     9 #
    10 # This program is distributed in the hope that it will be useful, but WITHOUT
    11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    12 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
    13 # more details.
    14 #
    15 # You should have received a copy of the GNU General Public License along with
    16 # this program; if not, write to the Free Software Foundation, Inc., 51
    17 # Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
    18 
    19 ###############################################################################
    20 # Usage
    21 ###############################################################################
    22 # This script uses a config file that can be used to stash common arguments
    23 # passed to configure or environment variables that need to be set before
    24 # configure is called.  The configuration file is a simple shell script that
    25 # gets sourced.
    26 #
    27 # By default, the config file that is used is named 'autogen.args'.  This can
    28 # be configured below.
    29 #
    30 # Available options that are handled are as follow:
    31 #   ACLOCAL_FLAGS - command line arguments to pass to aclocal
    32 #   AUTOCONF_FLAGS - command line arguments to pass to autoconf
    33 #   AUTOHEADER_FLAGS - command line arguments to pass to autoheader
    34 #   AUTOMAKE_FLAGS - command line arguments to pass to automake flags
    35 #   CONFIGURE_FLAGS - command line arguments to pass to configure
    36 #   INTLTOOLIZE_FLAGS - command line arguments to pass to intltoolize
    37 #   LIBTOOLIZE_FLAGS - command line arguments to pass to libtoolize
    38 #
    39 # Other helpful notes:
    40 #   If you're using a different c compiler, you can override the environment
    41 #   variable in 'autogen.args'.  For example, say you're using distcc, just add
    42 #   the following to 'autogen.args':
    43 #
    44 #       CC="distcc"
    45 #
    46 #   This will work for any influential environment variable to configure.
    47 ###############################################################################
    48 PACKAGE="Purple Plugin Pack"
    49 ARGS_FILE="autogen.args"
    50 export CFLAGS
    51 export LDFLAGS
    52 
    53 libtoolize="libtoolize"
    54 case $(uname -s) in
    55 	Darwin*)
    56 		libtoolize="glibtoolize"
    57 		;;
    58 	*)
    59 esac
    60 
    61 ###############################################################################
    62 # Some helper functions
    63 ###############################################################################
    64 check () {
    65 	CMD=$1
    66 
    67 	printf "%s" "checking for ${CMD}... "
    68 	BIN=`which ${CMD} 2>/dev/null`
    69 
    70 	if [ x"${BIN}" = x"" ] ; then
    71 		echo "not found."
    72 		echo "${CMD} is required to build ${PACKAGE}!"
    73 		exit 1;
    74 	fi
    75 
    76 	echo "${BIN}"
    77 }
    78 
    79 run_or_die () { # beotch
    80 	CMD=$1
    81 	shift
    82 
    83 	OUTPUT=`mktemp autogen-XXXXXX`
    84 
    85 	printf "%s" "running ${CMD} ${@}... "
    86 	${CMD} ${@} >${OUTPUT} 2>&1
    87 
    88 	if [ $? != 0 ] ; then
    89 		echo "failed."
    90 		cat ${OUTPUT}
    91 		rm -f ${OUTPUT}
    92 		exit 1
    93 	else
    94 		echo "done."
    95 		cat ${OUTPUT}
    96 
    97 		rm -f ${OUTPUT}
    98 	fi
    99 }
   100 
   101 ###############################################################################
   102 # We really start here, yes, very sneaky!
   103 ###############################################################################
   104 FIGLET=`which figlet 2> /dev/null`
   105 if [ x"${FIGLET}" != x"" ] ; then
   106 	${FIGLET} -f small ${PACKAGE}
   107 	echo "build system is being generated"
   108 else
   109 	echo "autogenerating build system for '${PACKAGE}'"
   110 fi
   111 
   112 ###############################################################################
   113 # Look for our args file
   114 ###############################################################################
   115 printf "%s" "checking for ${ARGS_FILE}: "
   116 if [ -f ${ARGS_FILE} ] ; then
   117 	echo "found."
   118 	printf "%s" "sourcing ${ARGS_FILE}: "
   119 	. "`dirname "$0"`"/${ARGS_FILE}
   120 	echo "done."
   121 else
   122 	echo "not found."
   123 fi
   124 
   125 ###############################################################################
   126 # Check for our required helpers
   127 ###############################################################################
   128 check "$libtoolize";		LIBTOOLIZE=${BIN};
   129 check "intltoolize";		INTLTOOLIZE=${BIN};
   130 check "aclocal";		ACLOCAL=${BIN};
   131 check "autoheader";		AUTOHEADER=${BIN};
   132 check "automake";		AUTOMAKE=${BIN};
   133 check "autoconf";		AUTOCONF=${BIN};
   134 check "python";			PYTHON=${BIN};
   135 
   136 ###############################################################################
   137 # Build pluginpack.m4
   138 ###############################################################################
   139 CONFIG_FILE="plugin_pack.m4"
   140 
   141 printf "%s" "creating ${CONFIG_FILE} ..."
   142 ${PYTHON} plugin_pack.py config_file > ${CONFIG_FILE}
   143 echo " done."
   144 
   145 ###############################################################################
   146 # Run all of our helpers
   147 ###############################################################################
   148 run_or_die ${LIBTOOLIZE} ${LIBTOOLIZE_FLAGS:-"-c -f --automake"}
   149 run_or_die ${INTLTOOLIZE} ${INTLTOOLIZE_FLAGS:-"-c -f --automake"}
   150 run_or_die ${ACLOCAL} ${ACLOCAL_FLAGS}
   151 run_or_die ${AUTOHEADER} ${AUTOHEADER_FLAGS}
   152 run_or_die ${AUTOMAKE} ${AUTOMAKE_FLAGS:-"-a -c --gnu"}
   153 run_or_die ${AUTOCONF} ${AUTOCONF_FLAGS}
   154 
   155 ###############################################################################
   156 # Run configure
   157 ###############################################################################
   158 echo "running ./configure ${CONFIGURE_FLAGS} $@"
   159 ./configure ${CONFIGURE_FLAGS} $@