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