| 1 |
#! /bin/bash |
| 2 |
AUTO_STABLE=${AUTO_STABLE:-/usr/autotool/stable} |
| 3 |
AUTO_DEVEL=${AUTO_DEVEL:-/usr/autotool/devel} |
| 4 |
|
| 5 |
me=`echo "$0" | sed -e 's,.*[\\/],,'` |
| 6 |
|
| 7 |
help="\ |
| 8 |
Try \`$me --help' for more information." |
| 9 |
|
| 10 |
exit_missing_arg="\ |
| 11 |
echo \"$me: option \\\`\$1' requires an argument\" >&2 |
| 12 |
echo \"\$help\" >&2 |
| 13 |
exit 1" |
| 14 |
|
| 15 |
# Set up variables |
| 16 |
unset autosense_input |
| 17 |
unset opt_version |
| 18 |
unset opt_help |
| 19 |
unset opt_debug |
| 20 |
unset opt_verbose |
| 21 |
unset opt_force |
| 22 |
unset opt_localdir |
| 23 |
unset opt_autoconf_dir |
| 24 |
unset opt_macrodir |
| 25 |
unset opt_include |
| 26 |
unset includes |
| 27 |
unset opt_prepend_include |
| 28 |
unset prepend_includes |
| 29 |
unset opt_warnings |
| 30 |
unset warnings |
| 31 |
unset opt_stop |
| 32 |
# Parse command line. We have to do this in case the user |
| 33 |
# specifies the input file or uses stdin. If so, then |
| 34 |
# we must accommodate...but we can only do that if we |
| 35 |
# parse ALL possible options. This gets ugly if the |
| 36 |
# two versions of autoconf accept different options. |
| 37 |
while test $# -gt 0 ; do |
| 38 |
optarg=`expr "x$1" : 'x--[^=]*=\(.*\)' \| \ |
| 39 |
"x$1" : 'x-.\(.*\)'` |
| 40 |
case $1 in |
| 41 |
|
| 42 |
--version | -V ) |
| 43 |
opt_version="--version" |
| 44 |
shift ;; |
| 45 |
|
| 46 |
|
| 47 |
--help | -h ) |
| 48 |
opt_help="--help" |
| 49 |
shift ;; |
| 50 |
|
| 51 |
|
| 52 |
--debug | -d ) |
| 53 |
opt_debug="--debug" |
| 54 |
shift ;; |
| 55 |
|
| 56 |
|
| 57 |
--verbose | -v ) |
| 58 |
opt_verbose="--verbose" |
| 59 |
shift ;; |
| 60 |
|
| 61 |
|
| 62 |
--force | -f ) |
| 63 |
opt_force="--force" |
| 64 |
shift ;; |
| 65 |
|
| 66 |
|
| 67 |
--localdir=* | -l?* ) |
| 68 |
opt_localdir="--localdir=$optarg" |
| 69 |
shift ;; |
| 70 |
--localdir | -l ) |
| 71 |
test $# = 1 && eval "$exit_missing_arg" |
| 72 |
shift |
| 73 |
opt_localdir="--localdir=$1" |
| 74 |
shift ;; |
| 75 |
|
| 76 |
|
| 77 |
--autoconf-dir=* | -A?* ) |
| 78 |
opt_autoconf_dir="--autoconf-dir=$optarg" |
| 79 |
shift ;; |
| 80 |
--autoconf-dir | -A ) |
| 81 |
test $# = 1 && eval "$exit_missing_arg" |
| 82 |
shift |
| 83 |
opt_autoconf_dir="--autoconf-dir=$1" |
| 84 |
shift ;; |
| 85 |
|
| 86 |
|
| 87 |
--macrodir=* | -m?* ) |
| 88 |
opt_macrodir="--macrodir=$optarg" |
| 89 |
shift ;; |
| 90 |
--macrodir | -m ) |
| 91 |
test $# = 1 && eval "$exit_missing_arg" |
| 92 |
shift |
| 93 |
opt_macrodir="--macrodir=$1" |
| 94 |
shift ;; |
| 95 |
|
| 96 |
|
| 97 |
--include=* | -I?* ) |
| 98 |
includes="$includes --include=$optarg" |
| 99 |
shift ;; |
| 100 |
--include | -I ) |
| 101 |
test $# = 1 && eval "$exit_missing_arg" |
| 102 |
shift |
| 103 |
includes="$includes --include=$1" |
| 104 |
shift ;; |
| 105 |
|
| 106 |
|
| 107 |
--prepend-include=* | -B?* ) |
| 108 |
prepend_includes="$prepend_includes --prepend-include=$optarg" |
| 109 |
shift ;; |
| 110 |
--prepend-include | -B ) |
| 111 |
test $# = 1 && eval "$exit_missing_arg" |
| 112 |
shift |
| 113 |
prepend_includes="$prepend_includes --prepend-include=$1" |
| 114 |
shift ;; |
| 115 |
|
| 116 |
|
| 117 |
--warnings=* | -W?* ) |
| 118 |
warnings=$warnings,$optarg |
| 119 |
shift ;; |
| 120 |
--warnings | -W ) |
| 121 |
test $# = 1 && eval "$exit_missing_arg" |
| 122 |
shift |
| 123 |
warnings=$warnings,$1 |
| 124 |
shift ;; |
| 125 |
|
| 126 |
|
| 127 |
-- ) # Stop option processing |
| 128 |
shift |
| 129 |
opt_stop="--" |
| 130 |
break ;; |
| 131 |
|
| 132 |
|
| 133 |
- ) # Use stdin as input. |
| 134 |
break ;; |
| 135 |
|
| 136 |
|
| 137 |
-* ) |
| 138 |
exec >&2 |
| 139 |
echo "$me: invalid option $1" |
| 140 |
echo "$help" |
| 141 |
exit 1 ;; |
| 142 |
|
| 143 |
|
| 144 |
* ) |
| 145 |
break ;; |
| 146 |
esac |
| 147 |
done |
| 148 |
|
| 149 |
# Special handling for the options that can be called |
| 150 |
# multiple times. |
| 151 |
if [ "x$includes" != "x" ] ; then |
| 152 |
opt_include="$includes" |
| 153 |
fi |
| 154 |
if [ "x$prepend_includes" != "x" ] ; then |
| 155 |
opt_prepend_include="$prepend_includes" |
| 156 |
fi |
| 157 |
if [ "x$warnings" != "x" ] ; then |
| 158 |
opt_warnings="--warnings=$warnings" |
| 159 |
fi |
| 160 |
|
| 161 |
# Trap on 0 to stop playing with `rm'. |
| 162 |
$debug || |
| 163 |
{ |
| 164 |
trap 'status=$?; rm -rf $tmp && exit $status' 0 |
| 165 |
trap '(exit 1); exit 1' 1 2 13 15 |
| 166 |
} |
| 167 |
|
| 168 |
|
| 169 |
unset VER |
| 170 |
unset SHORTCUT_DEVEL |
| 171 |
unset SHORTCUT_STABLE |
| 172 |
if [ -n "${WANT_AUTOCONF_VER}" ] ; then |
| 173 |
VER=${WANT_AUTOCONF_VER} |
| 174 |
|
| 175 |
# some duplicated code (from setpath.frag), but oh well |
| 176 |
VER_MAJ=`echo $VER | awk -F. '{print $1}'` |
| 177 |
VER_MIN=`echo $VER | awk -F. '{print $2}'` |
| 178 |
|
| 179 |
if [ "x${VER_MIN}" != "x" ] ; then |
| 180 |
if (( ${VER_MIN} <= 13 )) ; then |
| 181 |
SHORTCUT_STABLE="yes" |
| 182 |
else |
| 183 |
SHORTCUT_DEVEL="yes" |
| 184 |
fi |
| 185 |
fi |
| 186 |
fi |
| 187 |
|
| 188 |
|
| 189 |
# Find the input file. |
| 190 |
case $# in |
| 191 |
0) |
| 192 |
case `ls configure.ac configure.in 2>/dev/null` in |
| 193 |
*ac*in ) |
| 194 |
echo "$me: warning: both \`configure.ac' and \`configure.in' are present." >&2 |
| 195 |
echo "$me: warning: proceeding with \`configure.ac'." >&2 |
| 196 |
infile=configure.ac;; |
| 197 |
*ac ) infile=configure.ac;; |
| 198 |
*in ) infile=configure.in;; |
| 199 |
* ) |
| 200 |
# if --version is supplied but no file is found, generate generic |
| 201 |
# version message. First, call DEVEL --version, echo divider, |
| 202 |
# then call STABLE --version, another divider, and finally |
| 203 |
# an explanatory message. That way, programs that try to |
| 204 |
# parse the output of --version won't be confused: they will |
| 205 |
# see DEVEL's version information and will discard everything else |
| 206 |
# (since they already discard all the license gobbledygook) |
| 207 |
# |
| 208 |
# On the other hand, if VER is already established (e.g. |
| 209 |
# WANT_AUTOCONF_VER is set), then only print the "right" one. |
| 210 |
if [ -n "$SHORTCUT_DEVEL" ] ; then |
| 211 |
if [ -n "$opt_version" ] ; then |
| 212 |
${AUTO_DEVEL}/bin/autoheader --version |
| 213 |
exit 0 |
| 214 |
elif [ -n "$opt_help" ] ; then |
| 215 |
${AUTO_DEVEL}/bin/autoheader --help |
| 216 |
exit 0 |
| 217 |
else |
| 218 |
echo "$me: no input file" >&2 |
| 219 |
exit 1 |
| 220 |
fi |
| 221 |
elif [ -n "$SHORTCUT_STABLE" ] ; then |
| 222 |
if [ -n "$opt_version" ] ; then |
| 223 |
${AUTO_STABLE}/bin/autoheader --version |
| 224 |
exit 0 |
| 225 |
elif [ -n "$opt_help" ] ; then |
| 226 |
${AUTO_STABLE}/bin/autoheader --help |
| 227 |
exit 0 |
| 228 |
else |
| 229 |
echo "$me: no input file" >&2 |
| 230 |
exit 1 |
| 231 |
fi |
| 232 |
else |
| 233 |
if [ -n "$opt_version" ]; then |
| 234 |
${AUTO_DEVEL}/bin/autoheader --version |
| 235 |
echo "--------------------------------------------------------" |
| 236 |
${AUTO_STABLE}/bin/autoheader --version |
| 237 |
echo "--------------------------------------------------------" |
| 238 |
echo "This is autoheader-wrapper, which will hand off execution" |
| 239 |
echo "to one of the two real versions listed above, depending" |
| 240 |
echo "on the contents of configure.in/configure.ac. Since the" |
| 241 |
echo "wrapper was called from within a directory in which those" |
| 242 |
echo "files are not found, this generic 'version' message is" |
| 243 |
echo "displayed." |
| 244 |
exit 0 |
| 245 |
elif [ -n "$opt_help" ]; then |
| 246 |
${AUTO_DEVEL}/bin/autoheader --help |
| 247 |
echo "" |
| 248 |
echo "--------------------------------------------------------" |
| 249 |
echo "------ Above: 'devel' help. Below: 'stable' help ------" |
| 250 |
echo "--------------------------------------------------------" |
| 251 |
echo "" |
| 252 |
${AUTO_STABLE}/bin/autoheader --help |
| 253 |
echo "" |
| 254 |
echo "--------------------------------------------------------" |
| 255 |
echo "------ Above: 'stable' help. Below: 'wrapper' help ----" |
| 256 |
echo "--------------------------------------------------------" |
| 257 |
echo "" |
| 258 |
echo "This is autoheader-wrapper, which will hand off execution" |
| 259 |
echo "to one of the two real versions listed above, depending" |
| 260 |
echo "on the contents of configure.in/configure.ac. Since the" |
| 261 |
echo "wrapper was called from within a directory in which those" |
| 262 |
echo "files are not found, this generic 'help' message is" |
| 263 |
echo "displayed." |
| 264 |
exit 0 |
| 265 |
else |
| 266 |
echo "$me: no input file" >&2 |
| 267 |
exit 1 |
| 268 |
fi |
| 269 |
fi |
| 270 |
;; |
| 271 |
esac |
| 272 |
autosense_input=true ;; |
| 273 |
1) infile=$1 ;; |
| 274 |
*) exec >&2 |
| 275 |
echo "$me: invalid number of arguments." |
| 276 |
echo "$help" |
| 277 |
(exit 1); exit 1 ;; |
| 278 |
esac |
| 279 |
|
| 280 |
|
| 281 |
# Create a (secure) tmp directory for tmp files. |
| 282 |
: ${TMPDIR=/tmp} |
| 283 |
{ |
| 284 |
tmp=`(umask 077 && mktemp -d -q "$TMPDIR/acXXXXXX") 2>/dev/null` && |
| 285 |
test -n "$tmp" && test -d "$tmp" |
| 286 |
} || |
| 287 |
{ |
| 288 |
tmp=$TMPDIR/ac$$ |
| 289 |
(umask 077 && mkdir $tmp) |
| 290 |
} || |
| 291 |
{ |
| 292 |
echo "$me: cannot create a temporary directory in $TMPDIR" >&2 |
| 293 |
(exit 1); exit 1; |
| 294 |
} |
| 295 |
|
| 296 |
|
| 297 |
# We need an actual file. |
| 298 |
if test z$infile = z-; then |
| 299 |
infile=$tmp/stdin |
| 300 |
cat >$infile |
| 301 |
elif test ! -r "$infile"; then |
| 302 |
echo "$me: $infile: No such file or directory" >&2 |
| 303 |
(exit 1); exit 1 |
| 304 |
fi |
| 305 |
|
| 306 |
|
| 307 |
# Find the version |
| 308 |
if [ -z "${VER}" ] ; then |
| 309 |
VER=`sed -n -e '/AC_PREREQ/s/[^(]*([[]*\([[:digit:]\.]*\)[]]*).*$/\1/p' < $infile` |
| 310 |
fi |
| 311 |
|
| 312 |
VER_MAJ=`echo $VER | awk -F. '{print $1}'` |
| 313 |
VER_MIN=`echo $VER | awk -F. '{print $2}'` |
| 314 |
|
| 315 |
# Set the PATH appropriately |
| 316 |
if [ "x${VER_MIN}" != "x" ] ; then |
| 317 |
if (( ${VER_MIN} <= 13 )) ; then |
| 318 |
if [ ! -x ${AUTO_STABLE}/bin/autoheader ] ; then |
| 319 |
echo "Can't find ${AUTO_STABLE}/bin/autoheader" 2>&1 |
| 320 |
exit 1 |
| 321 |
fi |
| 322 |
export PATH=${AUTO_STABLE}/bin:${PATH} |
| 323 |
export M4PATH=${AUTO_STABLE}/share/autoconf:${M4PATH} |
| 324 |
else |
| 325 |
if [ ! -x ${AUTO_DEVEL}/bin/autoheader ] ; then |
| 326 |
echo "Can't find ${AUTO_DEVEL}/bin/autoheader" 2>&1 |
| 327 |
exit 1 |
| 328 |
fi |
| 329 |
export PATH=${AUTO_DEVEL}/bin:${PATH} |
| 330 |
export M4PATH=${AUTO_DEVEL}/share/autoconf:${M4PATH} |
| 331 |
fi |
| 332 |
else |
| 333 |
if [ ! -x ${AUTO_DEVEL}/bin/autoheader ] ; then |
| 334 |
echo "Can't find ${AUTO_DEVEL}/bin/autoheader" 2>&1 |
| 335 |
exit 1 |
| 336 |
fi |
| 337 |
export PATH=${AUTO_DEVEL}/bin:${PATH} |
| 338 |
export M4PATH=${AUTO_DEVEL}/share/autoconf:${M4PATH} |
| 339 |
fi |
| 340 |
|
| 341 |
|
| 342 |
# exec the "real" autoheader |
| 343 |
if [ "z$infile" == "z$tmp/stdin" ] ; then |
| 344 |
autoheader $opt_version $opt_help \ |
| 345 |
$opt_debug $opt_verbose $opt_localdir \ |
| 346 |
$opt_include $opt_prepend_include $opt_autoconf_dir $opt_macrodir |
| 347 |
$opt_warnings $opt_force \ |
| 348 |
$opt_stop - < $infile |
| 349 |
rm -rf $tmp |
| 350 |
elif [ "z$autosense_input" == "ztrue" ] ; then |
| 351 |
rm -rf $tmp |
| 352 |
exec autoheader $opt_version $opt_help \ |
| 353 |
$opt_debug $opt_verbose $opt_localdir \ |
| 354 |
$opt_include $opt_prepend_include $opt_autoconf_dir $opt_macrodir \ |
| 355 |
$opt_warnings $opt_force \ |
| 356 |
$opt_stop |
| 357 |
else |
| 358 |
rm -rf $tmp |
| 359 |
exec autoheader $opt_version $opt_help \ |
| 360 |
$opt_debug $opt_verbose $opt_localdir \ |
| 361 |
$opt_include $opt_prepend_include $opt_autoconf_dir $opt_macrodir |
| 362 |
$opt_warnings $opt_force \ |
| 363 |
$opt_stop $infile |
| 364 |
fi |