~ubuntu-branches/ubuntu/natty/pd-zexy/natty

« back to all changes in this revision

Viewing changes to build/autoconf/autogen.sh

  • Committer: Bazaar Package Importer
  • Author(s): Jonas Smedegaard, IOhannes m zmölnig, Jonas Smedegaard
  • Date: 2010-08-20 12:17:41 UTC
  • mfrom: (2.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20100820121741-4kxozn8b9rhee9fr
Tags: 2.2.3-1
* New upstream version

[ IOhannes m zmölnig ]
* Adopt package, on behalf of Multimedia Team.
  Closes: #546964
* Simply debian/rules with CDBS, and don't unconditionally strip
  binaries.
  Closes: #437763
* Install into /usr/lib/pd/extra/zexy/. Document usage in REAME.Debian
  and warn about change in NEWS.
* git'ify package. Add Vcs-* stanzas to control file.
* Use dpkg source format 3.0 (quilt). Drop build-dependency on quilt.

[ Jonas Smedegaard ]
* Enable CDBS copyright-check routine.
* Add copyright and licensing header to debian/rules.
* Add myself as uploader.
* Rewrite debian/copyright using rev. 135 of draft DEP5 format.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
#                        a u t o g e n . s h
 
3
#
 
4
# Copyright (c) 2005-2007 United States Government as represented by
 
5
# the U.S. Army Research Laboratory.
 
6
#
 
7
# Redistribution and use in source and binary forms, with or without
 
8
# modification, are permitted provided that the following conditions
 
9
# are met:
 
10
#
 
11
# 1. Redistributions of source code must retain the above copyright
 
12
# notice, this list of conditions and the following disclaimer.
 
13
#
 
14
# 2. Redistributions in binary form must reproduce the above
 
15
# copyright notice, this list of conditions and the following
 
16
# disclaimer in the documentation and/or other materials provided
 
17
# with the distribution.
 
18
#
 
19
# 3. The name of the author may not be used to endorse or promote
 
20
# products derived from this software without specific prior written
 
21
# permission.
 
22
#
 
23
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
 
24
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 
25
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 
26
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
 
27
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 
28
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 
29
# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 
30
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 
31
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 
32
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 
33
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
34
#
 
35
###
 
36
#
 
37
# Script for automatically preparing the sources for compilation by
 
38
# performing the myrid of necessary steps.  The script attempts to
 
39
# detect proper version support, and outputs warnings about particular
 
40
# systems that have autotool peculiarities.
 
41
#
 
42
# Basically, if everything is set up and installed correctly, the
 
43
# script will validate that minimum versions of the GNU Build System
 
44
# tools are installed, account for several common configuration
 
45
# issues, and then simply run autoreconf for you.
 
46
#
 
47
# If autoreconf fails, which can happen for many valid configurations,
 
48
# this script proceeds to run manual preparation steps effectively
 
49
# providing a POSIX shell script (mostly complete) reimplementation of
 
50
# autoreconf.
 
51
#
 
52
# The AUTORECONF, AUTOCONF, AUTOMAKE, LIBTOOLIZE, ACLOCAL
 
53
# environment variables and corresponding _OPTIONS variables (e.g.
 
54
# AUTORECONF_OPTIONS) may be used to override the default automatic
 
55
# detection behaviors.  Similarly the _VERSION variables will override
 
56
# the minimum required version numbers.
 
57
#
 
58
# Examples:
 
59
#
 
60
#   To obtain help on usage:
 
61
#     ./autogen.sh --help
 
62
#
 
63
#   To obtain verbose output:
 
64
#     ./autogen.sh --verbose
 
65
#
 
66
#   To skip autoreconf and prepare manually:
 
67
#     AUTORECONF=false ./autogen.sh
 
68
#
 
69
#   To verbosely try running with an older (unsupported) autoconf:
 
70
#     AUTOCONF_VERSION=2.50 ./autogen.sh --verbose
 
71
#
 
72
# Author: Christopher Sean Morrison <morrison@brlcad.org>
 
73
#
 
74
######################################################################
 
75
 
 
76
# set to minimum acceptible version of autoconf
 
77
if [ "x$AUTOCONF_VERSION" = "x" ] ; then
 
78
    AUTOCONF_VERSION=2.52
 
79
fi
 
80
# set to minimum acceptible version of automake
 
81
if [ "x$AUTOMAKE_VERSION" = "x" ] ; then
 
82
    AUTOMAKE_VERSION=1.6.0
 
83
fi
 
84
# set to minimum acceptible version of libtool
 
85
if [ "x$LIBTOOL_VERSION" = "x" ] ; then
 
86
    LIBTOOL_VERSION=1.4.2
 
87
fi
 
88
 
 
89
 
 
90
##################
 
91
# ident function #
 
92
##################
 
93
ident ( ) {
 
94
    # extract copyright from header
 
95
    __copyright="`grep Copyright $AUTOGEN_SH | head -${HEAD_N}1 | awk '{print $4}'`"
 
96
    if [ "x$__copyright" = "x" ] ; then
 
97
        __copyright="`date +%Y`"
 
98
    fi
 
99
 
 
100
    # extract version from CVS Id string
 
101
    __id="$Id: autogen.sh,v 14.97 2007/06/18 22:25:02 brlcad Exp $"
 
102
    __version="`echo $__id | sed 's/.*\([0-9][0-9][0-9][0-9]\)[-\/]\([0-9][0-9]\)[-\/]\([0-9][0-9]\).*/\1\2\3/'`"
 
103
    if [ "x$__version" = "x" ] ; then
 
104
        __version=""
 
105
    fi
 
106
 
 
107
    echo "autogen.sh build preparation script by Christopher Sean Morrison"
 
108
    echo "revised 3-clause BSD-style license, copyright (c) $__copyright"
 
109
    echo "script version $__version, ISO/IEC 9945 POSIX shell script"
 
110
}
 
111
 
 
112
 
 
113
##################
 
114
# USAGE FUNCTION #
 
115
##################
 
116
usage ( ) {
 
117
    echo "Usage: $AUTOGEN_SH [-h|--help] [-v|--verbose] [-q|--quiet] [--version]"
 
118
    echo "    --help     Help on $NAME_OF_AUTOGEN usage"
 
119
    echo "    --verbose  Verbose progress output"
 
120
    echo "    --quiet    Quiet suppressed progress output"
 
121
    echo "    --version  Only perform GNU Build System version checks"
 
122
    echo
 
123
    echo "Description: This script will validate that minimum versions of the"
 
124
    echo "GNU Build System tools are installed and then run autoreconf for you."
 
125
    echo "Should autoreconf fail, manual preparation steps will be run"
 
126
    echo "potentially accounting for several common preparation issues.  The"
 
127
 
 
128
    echo "AUTORECONF, AUTOCONF, AUTOMAKE, LIBTOOLIZE, ACLOCAL"
 
129
    echo "PROJECT, & CONFIGURE environment variables and corresponding _OPTIONS"
 
130
    echo "variables (e.g. AUTORECONF_OPTIONS) may be used to override the"
 
131
    echo "default automatic detection behavior."
 
132
    echo
 
133
 
 
134
    ident
 
135
 
 
136
    return 0
 
137
}
 
138
 
 
139
 
 
140
##########################
 
141
# VERSION_ERROR FUNCTION #
 
142
##########################
 
143
version_error ( ) {
 
144
    if [ "x$1" = "x" ] ; then
 
145
        echo "INTERNAL ERROR: version_error was not provided a version"
 
146
        exit 1
 
147
    fi
 
148
    if [ "x$2" = "x" ] ; then
 
149
        echo "INTERNAL ERROR: version_error was not provided an application name"
 
150
        exit 1
 
151
    fi
 
152
    $ECHO
 
153
    $ECHO "ERROR:  To prepare the ${PROJECT} build system from scratch,"
 
154
    $ECHO "        at least version $1 of $2 must be installed."
 
155
    $ECHO
 
156
    $ECHO "$NAME_OF_AUTOGEN does not need to be run on the same machine that will"
 
157
    $ECHO "run configure or make.  Either the GNU Autotools will need to be installed"
 
158
    $ECHO "or upgraded on this system, or $NAME_OF_AUTOGEN must be run on the source"
 
159
    $ECHO "code on another system and then transferred to here. -- Cheers!"
 
160
    $ECHO
 
161
}
 
162
 
 
163
##########################
 
164
# VERSION_CHECK FUNCTION #
 
165
##########################
 
166
version_check ( ) {
 
167
    if [ "x$1" = "x" ] ; then
 
168
        echo "INTERNAL ERROR: version_check was not provided a minimum version"
 
169
        exit 1
 
170
    fi
 
171
    _min="$1"
 
172
    if [ "x$2" = "x" ] ; then
 
173
        echo "INTERNAL ERROR: version check was not provided a comparison version"
 
174
        exit 1
 
175
    fi
 
176
    _cur="$2"
 
177
 
 
178
    # needed to handle versions like 1.10 and 1.4-p6
 
179
    _min="`echo ${_min}. | sed 's/[^0-9]/./g' | sed 's/\.\././g'`"
 
180
    _cur="`echo ${_cur}. | sed 's/[^0-9]/./g' | sed 's/\.\././g'`"
 
181
 
 
182
    _min_major="`echo $_min | cut -d. -f1`"
 
183
    _min_minor="`echo $_min | cut -d. -f2`"
 
184
    _min_patch="`echo $_min | cut -d. -f3`"
 
185
 
 
186
    _cur_major="`echo $_cur | cut -d. -f1`"
 
187
    _cur_minor="`echo $_cur | cut -d. -f2`"
 
188
    _cur_patch="`echo $_cur | cut -d. -f3`"
 
189
 
 
190
    if [ "x$_min_major" = "x" ] ; then
 
191
        _min_major=0
 
192
    fi
 
193
    if [ "x$_min_minor" = "x" ] ; then
 
194
        _min_minor=0
 
195
    fi
 
196
    if [ "x$_min_patch" = "x" ] ; then
 
197
        _min_patch=0
 
198
    fi
 
199
    if [ "x$_cur_minor" = "x" ] ; then
 
200
        _cur_major=0
 
201
    fi
 
202
    if [ "x$_cur_minor" = "x" ] ; then
 
203
        _cur_minor=0
 
204
    fi
 
205
    if [ "x$_cur_patch" = "x" ] ; then
 
206
        _cur_patch=0
 
207
    fi
 
208
 
 
209
    $VERBOSE_ECHO "Checking if ${_cur_major}.${_cur_minor}.${_cur_patch} is greater than ${_min_major}.${_min_minor}.${_min_patch}"
 
210
 
 
211
    if [ $_min_major -lt $_cur_major ] ; then
 
212
        return 0
 
213
    elif [ $_min_major -eq $_cur_major ] ; then
 
214
        if [ $_min_minor -lt $_cur_minor ] ; then
 
215
            return 0
 
216
        elif [ $_min_minor -eq $_cur_minor ] ; then
 
217
            if [ $_min_patch -lt $_cur_patch ] ; then
 
218
                return 0
 
219
            elif [ $_min_patch -eq $_cur_patch ] ; then
 
220
                return 0
 
221
            fi
 
222
        fi
 
223
    fi
 
224
    return 1
 
225
}
 
226
 
 
227
 
 
228
######################################
 
229
# LOCATE_CONFIGURE_TEMPLATE FUNCTION #
 
230
######################################
 
231
locate_configure_template ( ) {
 
232
    _pwd="`pwd`"
 
233
    if test -f "./configure.ac" ; then
 
234
        echo "./configure.ac"
 
235
    elif test -f "./configure.in" ; then
 
236
        echo "./configure.in"
 
237
    elif test -f "$_pwd/configure.ac" ; then
 
238
        echo "$_pwd/configure.ac"
 
239
    elif test -f "$_pwd/configure.in" ; then
 
240
        echo "$_pwd/configure.in"
 
241
    elif test -f "$PATH_TO_AUTOGEN/configure.ac" ; then
 
242
        echo "$PATH_TO_AUTOGEN/configure.ac"
 
243
    elif test -f "$PATH_TO_AUTOGEN/configure.in" ; then
 
244
        echo "$PATH_TO_AUTOGEN/configure.in"
 
245
    fi
 
246
}
 
247
 
 
248
 
 
249
##################
 
250
# argument check #
 
251
##################
 
252
ARGS="$*"
 
253
PATH_TO_AUTOGEN="`dirname $0`"
 
254
NAME_OF_AUTOGEN="`basename $0`"
 
255
AUTOGEN_SH="$PATH_TO_AUTOGEN/$NAME_OF_AUTOGEN"
 
256
 
 
257
LIBTOOL_M4="${PATH_TO_AUTOGEN}/misc/libtool.m4"
 
258
 
 
259
if [ "x$HELP" = "x" ] ; then
 
260
    HELP=no
 
261
fi
 
262
if [ "x$QUIET" = "x" ] ; then
 
263
    QUIET=no
 
264
fi
 
265
if [ "x$VERBOSE" = "x" ] ; then
 
266
    VERBOSE=no
 
267
fi
 
268
if [ "x$VERSION_ONLY" = "x" ] ; then
 
269
    VERSION_ONLY=no
 
270
fi
 
271
if [ "x$AUTORECONF_OPTIONS" = "x" ] ; then
 
272
    AUTORECONF_OPTIONS="-i -f"
 
273
fi
 
274
if [ "x$AUTOCONF_OPTIONS" = "x" ] ; then
 
275
    AUTOCONF_OPTIONS="-f"
 
276
fi
 
277
if [ "x$ACLOCAL_OPTIONS" = "x" ] ; then
 
278
    ACLOCAL_OPTIONS=""
 
279
fi
 
280
for arg in $ARGS ; do
 
281
    case "x$arg" in
 
282
        x--help) HELP=yes ;;
 
283
        x-[hH]) HELP=yes ;;
 
284
        x--quiet) QUIET=yes ;;
 
285
        x-[qQ]) QUIET=yes ;;
 
286
        x--verbose) VERBOSE=yes ;;
 
287
        x-[vV]) VERBOSE=yes ;;
 
288
        x--version) VERSION_ONLY=yes ;;
 
289
        *)
 
290
            echo "Unknown option: $arg"
 
291
            echo
 
292
            usage
 
293
            exit 1
 
294
            ;;
 
295
    esac
 
296
done
 
297
 
 
298
 
 
299
#####################
 
300
# environment check #
 
301
#####################
 
302
 
 
303
# sanity check before recursions potentially begin
 
304
if [ ! -f "$AUTOGEN_SH" ] ; then
 
305
    echo "INTERNAL ERROR: $AUTOGEN_SH does not exist"
 
306
    if [ ! "x$0" = "x$AUTOGEN_SH" ] ; then
 
307
        echo "INTERNAL ERROR: dirname/basename inconsistency: $0 != $AUTOGEN_SH"
 
308
    fi
 
309
    exit 1
 
310
fi
 
311
 
 
312
# force locale setting to C so things like date output as expected
 
313
LC_ALL=C
 
314
 
 
315
# commands that this script expects
 
316
for __cmd in echo head tail pwd ; do
 
317
    echo "test" | $__cmd > /dev/null 2>&1
 
318
    if [ $? != 0 ] ; then
 
319
        echo "INTERNAL ERROR: '${__cmd}' command is required"
 
320
        exit 2
 
321
    fi
 
322
done
 
323
echo "test" | grep "test" > /dev/null 2>&1
 
324
if test ! x$? = x0 ; then
 
325
    echo "INTERNAL ERROR: grep command is required"
 
326
    exit 1
 
327
fi
 
328
echo "test" | sed "s/test/test/" > /dev/null 2>&1
 
329
if test ! x$? = x0 ; then
 
330
    echo "INTERNAL ERROR: sed command is required"
 
331
    exit 1
 
332
fi
 
333
 
 
334
 
 
335
# determine the behavior of echo
 
336
case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
 
337
    *c*,-n*) ECHO_N= ECHO_C='
 
338
' ECHO_T='      ' ;;
 
339
    *c*,*  ) ECHO_N=-n ECHO_C= ECHO_T= ;;
 
340
    *)       ECHO_N= ECHO_C='\c' ECHO_T= ;;
 
341
esac
 
342
 
 
343
# determine the behavior of head
 
344
case "x`echo 'head' | head -n 1 2>&1`" in
 
345
    *xhead*) HEAD_N="n " ;;
 
346
    *) HEAD_N="" ;;
 
347
esac
 
348
 
 
349
# determine the behavior of tail
 
350
case "x`echo 'tail' | tail -n 1 2>&1`" in
 
351
    *xtail*) TAIL_N="n " ;;
 
352
    *) TAIL_N="" ;;
 
353
esac
 
354
 
 
355
VERBOSE_ECHO=:
 
356
ECHO=:
 
357
if [ "x$QUIET" = "xyes" ] ; then
 
358
    if [ "x$VERBOSE" = "xyes" ] ; then
 
359
        echo "Verbose output quelled by quiet option.  Further output disabled."
 
360
    fi
 
361
else
 
362
    ECHO=echo
 
363
    if [ "x$VERBOSE" = "xyes" ] ; then
 
364
        echo "Verbose output enabled"
 
365
        VERBOSE_ECHO=echo
 
366
    fi
 
367
fi
 
368
 
 
369
 
 
370
# allow a recursive run to disable further recursions
 
371
if [ "x$RUN_RECURSIVE" = "x" ] ; then
 
372
    RUN_RECURSIVE=yes
 
373
fi
 
374
 
 
375
 
 
376
################################################
 
377
# check for help arg and bypass version checks #
 
378
################################################
 
379
if [ "x`echo $ARGS | sed 's/.*[hH][eE][lL][pP].*/help/'`" = "xhelp" ] ; then
 
380
    HELP=yes
 
381
fi
 
382
if [ "x$HELP" = "xyes" ] ; then
 
383
    usage
 
384
    $ECHO "---"
 
385
    $ECHO "Help was requested.  No preparation or configuration will be performed."
 
386
    exit 0
 
387
fi
 
388
 
 
389
 
 
390
#######################
 
391
# set up signal traps #
 
392
#######################
 
393
untrap_abnormal ( ) {
 
394
    for sig in 1 2 13 15; do
 
395
        trap - $sig
 
396
    done
 
397
}
 
398
 
 
399
# do this cleanup whenever we exit.
 
400
trap '
 
401
    # start from the root
 
402
    if test -d "$START_PATH" ; then
 
403
        cd "$START_PATH"
 
404
    fi
 
405
 
 
406
    # restore/delete backup files
 
407
    if test "x$PFC_INIT" = "x1" ; then
 
408
        recursive_restore
 
409
    fi
 
410
' 0
 
411
 
 
412
# trap SIGHUP (1), SIGINT (2), SIGPIPE (13), SIGTERM (15)
 
413
for sig in 1 2 13 15; do
 
414
    trap '
 
415
        $ECHO ""
 
416
        $ECHO "Aborting $NAME_OF_AUTOGEN: caught signal '$sig'"
 
417
 
 
418
        # start from the root
 
419
        if test -d "$START_PATH" ; then
 
420
            cd "$START_PATH"
 
421
        fi
 
422
 
 
423
        # clean up on abnormal exit
 
424
        $VERBOSE_ECHO "rm -rf autom4te.cache"
 
425
        rm -rf autom4te.cache
 
426
 
 
427
        if test -f "acinclude.m4.$$.backup" ; then
 
428
            $VERBOSE_ECHO "cat acinclude.m4.$$.backup > acinclude.m4"
 
429
            chmod u+w acinclude.m4
 
430
            cat acinclude.m4.$$.backup > acinclude.m4
 
431
 
 
432
            $VERBOSE_ECHO "rm -f acinclude.m4.$$.backup"
 
433
            rm -f acinclude.m4.$$.backup
 
434
        fi
 
435
 
 
436
        { (exit 1); exit 1; }
 
437
' $sig
 
438
done
 
439
 
 
440
 
 
441
#############################
 
442
# look for a configure file #
 
443
#############################
 
444
if [ "x$CONFIGURE" = "x" ] ; then
 
445
    CONFIGURE="`locate_configure_template`"
 
446
    if [ ! "x$CONFIGURE" = "x" ] ; then
 
447
        $VERBOSE_ECHO "Found a configure template: $CONFIGURE"
 
448
    fi
 
449
else
 
450
    $ECHO "Using CONFIGURE environment variable override: $CONFIGURE"
 
451
fi
 
452
if [ "x$CONFIGURE" = "x" ] ; then
 
453
    if [ "x$VERSION_ONLY" = "xyes" ] ; then
 
454
        CONFIGURE=/dev/null
 
455
    else
 
456
        $ECHO
 
457
        $ECHO "A configure.ac or configure.in file could not be located implying"
 
458
        $ECHO "that the GNU Build System is at least not used in this directory.  In"
 
459
        $ECHO "any case, there is nothing to do here without one of those files."
 
460
        $ECHO
 
461
        $ECHO "ERROR: No configure.in or configure.ac file found in `pwd`"
 
462
        exit 1
 
463
    fi
 
464
fi
 
465
 
 
466
####################
 
467
# get project name #
 
468
####################
 
469
if [ "x$PROJECT" = "x" ] ; then
 
470
    PROJECT="`grep AC_INIT $CONFIGURE | grep -v '.*#.*AC_INIT' | tail -${TAIL_N}1 | sed 's/^[   ]*AC_INIT(\([^,)]*\).*/\1/' | sed 's/.*\[\(.*\)\].*/\1/'`"
 
471
    if [ "x$PROJECT" = "xAC_INIT" ] ; then
 
472
        # projects might be using the older/deprecated arg-less AC_INIT .. look for AM_INIT_AUTOMAKE instead
 
473
        PROJECT="`grep AM_INIT_AUTOMAKE $CONFIGURE | grep -v '.*#.*AM_INIT_AUTOMAKE' | tail -${TAIL_N}1 | sed 's/^[     ]*AM_INIT_AUTOMAKE(\([^,)]*\).*/\1/' | sed 's/.*\[\(.*\)\].*/\1/'`"
 
474
    fi
 
475
    if [ "x$PROJECT" = "xAM_INIT_AUTOMAKE" ] ; then
 
476
        PROJECT="project"
 
477
    fi
 
478
    if [ "x$PROJECT" = "x" ] ; then
 
479
        PROJECT="project"
 
480
    fi
 
481
else
 
482
    $ECHO "Using PROJECT environment variable override: $PROJECT"
 
483
fi
 
484
$ECHO "Preparing the $PROJECT build system...please wait"
 
485
$ECHO
 
486
 
 
487
 
 
488
########################
 
489
# check for autoreconf #
 
490
########################
 
491
HAVE_AUTORECONF=no
 
492
if [ "x$AUTORECONF" = "x" ] ; then
 
493
    for AUTORECONF in autoreconf ; do
 
494
        $VERBOSE_ECHO "Checking autoreconf version: $AUTORECONF --version"
 
495
        $AUTORECONF --version > /dev/null 2>&1
 
496
        if [ $? = 0 ] ; then
 
497
            HAVE_AUTORECONF=yes
 
498
            break
 
499
        fi
 
500
    done
 
501
else
 
502
    HAVE_AUTORECONF=yes
 
503
    $ECHO "Using AUTORECONF environment variable override: $AUTORECONF"
 
504
fi
 
505
 
 
506
 
 
507
##########################
 
508
# autoconf version check #
 
509
##########################
 
510
_acfound=no
 
511
if [ "x$AUTOCONF" = "x" ] ; then
 
512
    for AUTOCONF in autoconf ; do
 
513
        $VERBOSE_ECHO "Checking autoconf version: $AUTOCONF --version"
 
514
        $AUTOCONF --version > /dev/null 2>&1
 
515
        if [ $? = 0 ] ; then
 
516
            _acfound=yes
 
517
            break
 
518
        fi
 
519
    done
 
520
else
 
521
    _acfound=yes
 
522
    $ECHO "Using AUTOCONF environment variable override: $AUTOCONF"
 
523
fi
 
524
 
 
525
_report_error=no
 
526
if [ ! "x$_acfound" = "xyes" ] ; then
 
527
    $ECHO "ERROR:  Unable to locate GNU Autoconf."
 
528
    _report_error=yes
 
529
else
 
530
    _version="`$AUTOCONF --version | head -${HEAD_N}1 | sed 's/[^0-9]*\([0-9\.][0-9\.]*\)/\1/'`"
 
531
    if [ "x$_version" = "x" ] ; then
 
532
        _version="0.0.0"
 
533
    fi
 
534
    $ECHO "Found GNU Autoconf version $_version"
 
535
    version_check "$AUTOCONF_VERSION" "$_version"
 
536
    if [ $? -ne 0 ] ; then
 
537
        _report_error=yes
 
538
    fi
 
539
fi
 
540
if [ "x$_report_error" = "xyes" ] ; then
 
541
    version_error "$AUTOCONF_VERSION" "GNU Autoconf"
 
542
    exit 1
 
543
fi
 
544
 
 
545
 
 
546
##########################
 
547
# automake version check #
 
548
##########################
 
549
_amfound=no
 
550
if [ "x$AUTOMAKE" = "x" ] ; then
 
551
    for AUTOMAKE in automake ; do
 
552
        $VERBOSE_ECHO "Checking automake version: $AUTOMAKE --version"
 
553
        $AUTOMAKE --version > /dev/null 2>&1
 
554
        if [ $? = 0 ] ; then
 
555
            _amfound=yes
 
556
            break
 
557
        fi
 
558
    done
 
559
else
 
560
    _amfound=yes
 
561
    $ECHO "Using AUTOMAKE environment variable override: $AUTOMAKE"
 
562
fi
 
563
 
 
564
 
 
565
_report_error=no
 
566
if [ ! "x$_amfound" = "xyes" ] ; then
 
567
    $ECHO
 
568
    $ECHO "ERROR: Unable to locate GNU Automake."
 
569
    _report_error=yes
 
570
else
 
571
    _version="`$AUTOMAKE --version | head -${HEAD_N}1 | sed 's/[^0-9]*\([0-9\.][0-9\.]*\)/\1/'`"
 
572
    if [ "x$_version" = "x" ] ; then
 
573
        _version="0.0.0"
 
574
    fi
 
575
    $ECHO "Found GNU Automake version $_version"
 
576
    version_check "$AUTOMAKE_VERSION" "$_version" 
 
577
    if [ $? -ne 0 ] ; then
 
578
        _report_error=yes
 
579
    fi
 
580
fi
 
581
if [ "x$_report_error" = "xyes" ] ; then
 
582
    version_error "$AUTOMAKE_VERSION" "GNU Automake"
 
583
    exit 1
 
584
fi
 
585
 
 
586
 
 
587
########################
 
588
# check for libtoolize #
 
589
########################
 
590
HAVE_LIBTOOLIZE=yes
 
591
HAVE_ALT_LIBTOOLIZE=no
 
592
_ltfound=no
 
593
if [ "x$LIBTOOLIZE" = "x" ] ; then
 
594
    LIBTOOLIZE=libtoolize
 
595
    $VERBOSE_ECHO "Checking libtoolize version: $LIBTOOLIZE --version"
 
596
    $LIBTOOLIZE --version > /dev/null 2>&1
 
597
    if [ ! $? = 0 ] ; then
 
598
        HAVE_LIBTOOLIZE=no
 
599
        $ECHO
 
600
        if [ "x$HAVE_AUTORECONF" = "xno" ] ; then
 
601
            $ECHO "Warning:  libtoolize does not appear to be available."
 
602
        else
 
603
            $ECHO "Warning:  libtoolize does not appear to be available.  This means that"
 
604
            $ECHO "the automatic build preparation via autoreconf will probably not work."
 
605
            $ECHO "Preparing the build by running each step individually, however, should"
 
606
            $ECHO "work and will be done automatically for you if autoreconf fails."
 
607
        fi
 
608
 
 
609
        # look for some alternates
 
610
        for tool in glibtoolize libtoolize15 libtoolize14 libtoolize13 ; do
 
611
            $VERBOSE_ECHO "Checking libtoolize alternate: $tool --version"
 
612
            _glibtoolize="`$tool --version > /dev/null 2>&1`"
 
613
            if [ $? = 0 ] ; then
 
614
                $VERBOSE_ECHO "Found $tool --version"
 
615
                _glti="`which $tool`"
 
616
                if [ "x$_glti" = "x" ] ; then
 
617
                    $VERBOSE_ECHO "Cannot find $tool with which"
 
618
                    continue;
 
619
                fi
 
620
                if test ! -f "$_glti" ; then
 
621
                    $VERBOSE_ECHO "Cannot use $tool, $_glti is not a file"
 
622
                    continue;
 
623
                fi
 
624
                _gltidir="`dirname $_glti`"
 
625
                if [ "x$_gltidir" = "x" ] ; then
 
626
                    $VERBOSE_ECHO "Cannot find $tool path with dirname of $_glti"
 
627
                    continue;
 
628
                fi
 
629
                if test ! -d "$_gltidir" ; then
 
630
                    $VERBOSE_ECHO "Cannot use $tool, $_gltidir is not a directory"
 
631
                    continue;
 
632
                fi
 
633
                HAVE_ALT_LIBTOOLIZE=yes
 
634
                LIBTOOLIZE="$tool"
 
635
                $ECHO
 
636
                $ECHO "Fortunately, $tool was found which means that your system may simply"
 
637
                $ECHO "have a non-standard or incomplete GNU Autotools install.  If you have"
 
638
                $ECHO "sufficient system access, it may be possible to quell this warning by"
 
639
                $ECHO "running:"
 
640
                $ECHO
 
641
                sudo -V > /dev/null 2>&1
 
642
                if [ $? = 0 ] ; then
 
643
                    $ECHO "   sudo ln -s $_glti $_gltidir/libtoolize"
 
644
                    $ECHO
 
645
                else
 
646
                    $ECHO "   ln -s $_glti $_gltidir/libtoolize"
 
647
                    $ECHO
 
648
                    $ECHO "Run that as root or with proper permissions to the $_gltidir directory"
 
649
                    $ECHO
 
650
                fi
 
651
                _ltfound=yes
 
652
                break
 
653
            fi
 
654
        done
 
655
    else
 
656
        _ltfound=yes
 
657
    fi
 
658
else
 
659
    _ltfound=yes
 
660
    $ECHO "Using LIBTOOLIZE environment variable override: $LIBTOOLIZE"
 
661
fi
 
662
 
 
663
 
 
664
############################
 
665
# libtoolize version check #
 
666
############################
 
667
_report_error=no
 
668
if [ ! "x$_ltfound" = "xyes" ] ; then
 
669
    $ECHO
 
670
    $ECHO "ERROR: Unable to locate GNU Libtool."
 
671
    _report_error=yes
 
672
else
 
673
    _version="`$LIBTOOLIZE --version | head -${HEAD_N}1 | sed 's/[^0-9]*\([0-9\.][0-9\.]*\)/\1/'`"
 
674
    if [ "x$_version" = "x" ] ; then
 
675
        _version="0.0.0"
 
676
    fi
 
677
    $ECHO "Found GNU Libtool version $_version"
 
678
    version_check "$LIBTOOL_VERSION" "$_version" 
 
679
    if [ $? -ne 0 ] ; then
 
680
        _report_error=yes
 
681
    fi
 
682
fi
 
683
if [ "x$_report_error" = "xyes" ] ; then
 
684
    version_error "$LIBTOOL_VERSION" "GNU Libtool"
 
685
    exit 1
 
686
fi
 
687
 
 
688
 
 
689
#####################
 
690
# check for aclocal #
 
691
#####################
 
692
if [ "x$ACLOCAL" = "x" ] ; then
 
693
    for ACLOCAL in aclocal ; do
 
694
        $VERBOSE_ECHO "Checking aclocal version: $ACLOCAL --version"
 
695
        $ACLOCAL --version > /dev/null 2>&1
 
696
        if [ $? = 0 ] ; then
 
697
            break
 
698
        fi
 
699
    done
 
700
else
 
701
    $ECHO "Using ACLOCAL environment variable override: $ACLOCAL"
 
702
fi
 
703
 
 
704
 
 
705
#########################
 
706
# check if version only #
 
707
#########################
 
708
$VERBOSE_ECHO "Checking whether to only output version information"
 
709
if [ "x$VERSION_ONLY" = "xyes" ] ; then
 
710
    $ECHO
 
711
    ident
 
712
    $ECHO "---"
 
713
    $ECHO "Version requested.  No preparation or configuration will be performed."
 
714
    exit 0
 
715
fi
 
716
 
 
717
 
 
718
#################################
 
719
# PROTECT_FROM_CLOBBER FUNCTION #
 
720
#################################
 
721
protect_from_clobber ( ) {
 
722
    PFC_INIT=1
 
723
 
 
724
    # protect COPYING & INSTALL from overwrite by automake.  the
 
725
    # automake force option will (inappropriately) ignore the existing
 
726
    # contents of a COPYING and/or INSTALL files (depending on the
 
727
    # version) instead of just forcing *missing* files like it does
 
728
    # for AUTHORS, NEWS, and README. this is broken but extremely
 
729
    # prevalent behavior, so we protect against it by keeping a backup
 
730
    # of the file that can later be restored.
 
731
 
 
732
    if test -f COPYING ; then
 
733
        if test -f COPYING.$$.protect_from_automake.backup ; then
 
734
            $VERBOSE_ECHO "Already backed up COPYING in `pwd`"
 
735
        else
 
736
            $VERBOSE_ECHO "Backing up COPYING in `pwd`"
 
737
            $VERBOSE_ECHO "cp -p COPYING COPYING.$$.protect_from_automake.backup"
 
738
            cp -p COPYING COPYING.$$.protect_from_automake.backup
 
739
        fi
 
740
    fi
 
741
    if test -f INSTALL ; then
 
742
        if test -f INSTALL.$$.protect_from_automake.backup ; then
 
743
            $VERBOSE_ECHO "Already backed up INSTALL in `pwd`"
 
744
        else
 
745
            $VERBOSE_ECHO "Backing up INSTALL in `pwd`"
 
746
            $VERBOSE_ECHO "cp -p INSTALL INSTALL.$$.protect_from_automake.backup"
 
747
            cp -p INSTALL INSTALL.$$.protect_from_automake.backup
 
748
        fi
 
749
    fi
 
750
}
 
751
 
 
752
 
 
753
##############################
 
754
# RECURSIVE_PROTECT FUNCTION #
 
755
##############################
 
756
recursive_protect ( ) {
 
757
 
 
758
    # for projects using recursive configure, run the build
 
759
    # preparation steps for the subdirectories.  this function assumes
 
760
    # START_PATH was set to pwd before recursion begins so that
 
761
    # relative paths work.
 
762
 
 
763
    # git 'r done, protect COPYING and INSTALL from being clobbered
 
764
    protect_from_clobber
 
765
 
 
766
    if test -d autom4te.cache ; then
 
767
        $VERBOSE_ECHO "Found an autom4te.cache directory, deleting it"
 
768
        $VERBOSE_ECHO "rm -rf autom4te.cache"
 
769
        rm -rf autom4te.cache
 
770
    fi
 
771
 
 
772
    # find configure template
 
773
    _configure="`locate_configure_template`"
 
774
    if [ "x$_configure" = "x" ] ; then
 
775
        return
 
776
    fi
 
777
    # $VERBOSE_ECHO "Looking for configure template found `pwd`/$_configure"
 
778
 
 
779
    # look for subdirs
 
780
    # $VERBOSE_ECHO "Looking for subdirs in `pwd`"
 
781
    _det_config_subdirs="`grep AC_CONFIG_SUBDIRS $_configure | grep -v '.*#.*AC_CONFIG_SUBDIRS' | sed 's/^[     ]*AC_CONFIG_SUBDIRS(\(.*\)).*/\1/' | sed 's/.*\[\(.*\)\].*/\1/'`"
 
782
    CHECK_DIRS=""
 
783
    for dir in $_det_config_subdirs ; do
 
784
        if test -d "`pwd`/$dir" ; then
 
785
            CHECK_DIRS="$CHECK_DIRS \"`pwd`/$dir\""
 
786
        fi
 
787
    done
 
788
 
 
789
    # process subdirs
 
790
    if [ ! "x$CHECK_DIRS" = "x" ] ; then
 
791
        $VERBOSE_ECHO "Recursively scanning the following directories:"
 
792
        $VERBOSE_ECHO "  $CHECK_DIRS"
 
793
        for dir in $CHECK_DIRS ; do
 
794
            $VERBOSE_ECHO "Protecting files from automake in $dir"
 
795
            cd "$START_PATH"
 
796
            eval "cd $dir"
 
797
 
 
798
            # recursively git 'r done
 
799
            recursive_protect
 
800
        done
 
801
    fi
 
802
} # end of recursive_protect
 
803
 
 
804
 
 
805
#############################
 
806
# RESTORE_CLOBBERED FUNCION #
 
807
#############################
 
808
restore_clobbered ( ) {
 
809
 
 
810
    # The automake (and autoreconf by extension) -f/--force-missing
 
811
    # option may overwrite COPYING and INSTALL even if they do exist.
 
812
    # Here we restore the files if necessary.
 
813
 
 
814
    spacer=no
 
815
 
 
816
    # COPYING
 
817
    if test -f COPYING.$$.protect_from_automake.backup ; then
 
818
        if test -f COPYING ; then
 
819
            # compare entire content, restore if needed
 
820
            if test "x`cat COPYING`" != "x`cat COPYING.$$.protect_from_automake.backup`" ; then
 
821
                if test "x$spacer" = "xno" ; then
 
822
                    $VERBOSE_ECHO
 
823
                    spacer=yes
 
824
                fi
 
825
                # restore the backup
 
826
                $VERBOSE_ECHO "Restoring COPYING from backup (automake -f likely clobbered it)"
 
827
                $VERBOSE_ECHO "rm -f COPYING"
 
828
                rm -f COPYING
 
829
                $VERBOSE_ECHO "mv COPYING.$$.protect_from_automake.backup COPYING"
 
830
                mv COPYING.$$.protect_from_automake.backup COPYING
 
831
            fi # check contents
 
832
        elif test -f COPYING.$$.protect_from_automake.backup ; then
 
833
            $VERBOSE_ECHO "mv COPYING.$$.protect_from_automake.backup COPYING"
 
834
            mv COPYING.$$.protect_from_automake.backup COPYING
 
835
        fi # -f COPYING
 
836
 
 
837
        # just in case
 
838
        $VERBOSE_ECHO "rm -f COPYING.$$.protect_from_automake.backup"
 
839
        rm -f COPYING.$$.protect_from_automake.backup
 
840
    fi # -f COPYING.$$.protect_from_automake.backup
 
841
 
 
842
    # INSTALL
 
843
    if test -f INSTALL.$$.protect_from_automake.backup ; then
 
844
        if test -f INSTALL ; then
 
845
            # compare entire content, restore if needed
 
846
            if test "x`cat INSTALL`" != "x`cat INSTALL.$$.protect_from_automake.backup`" ; then
 
847
                if test "x$spacer" = "xno" ; then
 
848
                    $VERBOSE_ECHO
 
849
                    spacer=yes
 
850
                fi
 
851
                # restore the backup
 
852
                $VERBOSE_ECHO "Restoring INSTALL from backup (automake -f likely clobbered it)"
 
853
                $VERBOSE_ECHO "rm -f INSTALL"
 
854
                rm -f INSTALL
 
855
                $VERBOSE_ECHO "mv INSTALL.$$.protect_from_automake.backup INSTALL"
 
856
                mv INSTALL.$$.protect_from_automake.backup INSTALL
 
857
            fi # check contents
 
858
        elif test -f INSTALL.$$.protect_from_automake.backup ; then
 
859
            $VERBOSE_ECHO "mv INSTALL.$$.protect_from_automake.backup INSTALL"
 
860
            mv INSTALL.$$.protect_from_automake.backup INSTALL
 
861
        fi # -f INSTALL
 
862
 
 
863
        # just in case
 
864
        $VERBOSE_ECHO "rm -f INSTALL.$$.protect_from_automake.backup"
 
865
        rm -f INSTALL.$$.protect_from_automake.backup
 
866
    fi # -f INSTALL.$$.protect_from_automake.backup
 
867
 
 
868
    CONFIGURE="`locate_configure_template`"
 
869
    if [ "x$CONFIGURE" = "x" ] ; then
 
870
        return
 
871
    fi
 
872
 
 
873
    _aux_dir="`grep AC_CONFIG_AUX_DIR $CONFIGURE | grep -v '.*#.*AC_CONFIG_AUX_DIR' | tail -${TAIL_N}1 | sed 's/^[      ]*AC_CONFIG_AUX_DIR(\(.*\)).*/\1/' | sed 's/.*\[\(.*\)\].*/\1/'`"
 
874
    if test ! -d "$_aux_dir" ; then
 
875
        _aux_dir=.
 
876
    fi
 
877
 
 
878
    for file in config.guess config.sub ltmain.sh ; do
 
879
        if test -f "${_aux_dir}/${file}" ; then
 
880
            $VERBOSE_ECHO "rm -f \"${_aux_dir}/${file}.backup\""
 
881
            rm -f "${_aux_dir}/${file}.backup"
 
882
        fi
 
883
    done
 
884
} # end of restore_clobbered
 
885
 
 
886
 
 
887
##############################
 
888
# RECURSIVE_RESTORE FUNCTION #
 
889
##############################
 
890
recursive_restore ( ) {
 
891
 
 
892
    # restore COPYING and INSTALL from backup if they were clobbered
 
893
    # for each directory recursively.
 
894
 
 
895
    # git 'r undone
 
896
    restore_clobbered
 
897
 
 
898
    # find configure template
 
899
    _configure="`locate_configure_template`"
 
900
    if [ "x$_configure" = "x" ] ; then
 
901
        return
 
902
    fi
 
903
 
 
904
    # look for subdirs
 
905
    _det_config_subdirs="`grep AC_CONFIG_SUBDIRS $_configure | grep -v '.*#.*AC_CONFIG_SUBDIRS' | sed 's/^[     ]*AC_CONFIG_SUBDIRS(\(.*\)).*/\1/' | sed 's/.*\[\(.*\)\].*/\1/'`"
 
906
    CHECK_DIRS=""
 
907
    for dir in $_det_config_subdirs ; do
 
908
        if test -d "`pwd`/$dir" ; then
 
909
            CHECK_DIRS="$CHECK_DIRS \"`pwd`/$dir\""
 
910
        fi
 
911
    done
 
912
 
 
913
    # process subdirs
 
914
    if [ ! "x$CHECK_DIRS" = "x" ] ; then
 
915
        $VERBOSE_ECHO "Recursively scanning the following directories:"
 
916
        $VERBOSE_ECHO "  $CHECK_DIRS"
 
917
        for dir in $CHECK_DIRS ; do
 
918
            $VERBOSE_ECHO "Checking files for automake damage in $dir"
 
919
            cd "$START_PATH"
 
920
            eval "cd $dir"
 
921
 
 
922
            # recursively git 'r undone
 
923
            recursive_restore
 
924
        done
 
925
    fi
 
926
} # end of recursive_restore
 
927
 
 
928
 
 
929
#######################
 
930
# INITIALIZE FUNCTION #
 
931
#######################
 
932
initialize ( ) {
 
933
 
 
934
    # this routine performs a variety of directory-specific
 
935
    # initializations.  some are sanity checks, some are preventive,
 
936
    # and some are necessary setup detection.
 
937
    #
 
938
    # this function sets:
 
939
    #   CONFIGURE
 
940
    #   SEARCH_DIRS
 
941
    #   CONFIG_SUBDIRS
 
942
 
 
943
    ##################################
 
944
    # check for a configure template #
 
945
    ##################################
 
946
    CONFIGURE="`locate_configure_template`"
 
947
    if [ "x$CONFIGURE" = "x" ] ; then
 
948
        $ECHO
 
949
        $ECHO "A configure.ac or configure.in file could not be located implying"
 
950
        $ECHO "that the GNU Build System is at least not used in this directory.  In"
 
951
        $ECHO "any case, there is nothing to do here without one of those files."
 
952
        $ECHO
 
953
        $ECHO "ERROR: No configure.in or configure.ac file found in `pwd`"
 
954
        exit 1
 
955
    fi
 
956
 
 
957
    #####################
 
958
    # detect an aux dir #
 
959
    #####################
 
960
    _aux_dir="`grep AC_CONFIG_AUX_DIR $CONFIGURE | grep -v '.*#.*AC_CONFIG_AUX_DIR' | tail -${TAIL_N}1 | sed 's/^[      ]*AC_CONFIG_AUX_DIR(\(.*\)).*/\1/' | sed 's/.*\[\(.*\)\].*/\1/'`"
 
961
    if test ! -d "$_aux_dir" ; then
 
962
        _aux_dir=.
 
963
    else
 
964
        $VERBOSE_ECHO "Detected auxillary directory: $_aux_dir"
 
965
    fi
 
966
 
 
967
    ################################
 
968
    # detect a recursive configure #
 
969
    ################################
 
970
    CONFIG_SUBDIRS=""
 
971
    _det_config_subdirs="`grep AC_CONFIG_SUBDIRS $CONFIGURE | grep -v '.*#.*AC_CONFIG_SUBDIRS' | sed 's/^[      ]*AC_CONFIG_SUBDIRS(\(.*\)).*/\1/' | sed 's/.*\[\(.*\)\].*/\1/'`"
 
972
    for dir in $_det_config_subdirs ; do
 
973
        if test -d "`pwd`/$dir" ; then
 
974
            $VERBOSE_ECHO "Detected recursive configure directory: `pwd`/$dir"
 
975
            CONFIG_SUBDIRS="$CONFIG_SUBDIRS `pwd`/$dir"
 
976
        fi
 
977
    done
 
978
 
 
979
    ##########################################
 
980
    # make sure certain required files exist #
 
981
    ##########################################
 
982
    for file in AUTHORS COPYING ChangeLog INSTALL NEWS README ; do
 
983
        if test ! -f $file ; then
 
984
            $VERBOSE_ECHO "Touching ${file} since it does not exist"
 
985
            touch $file
 
986
        fi
 
987
    done
 
988
 
 
989
    ##################################################
 
990
    # make sure certain generated files do not exist #
 
991
    ##################################################
 
992
    for file in config.guess config.sub ltmain.sh ; do
 
993
        if test -f "${_aux_dir}/${file}" ; then
 
994
            $VERBOSE_ECHO "mv -f \"${_aux_dir}/${file}\" \"${_aux_dir}/${file}.backup\""
 
995
            mv -f "${_aux_dir}/${file}" "${_aux_dir}/${file}.backup"
 
996
        fi
 
997
    done
 
998
 
 
999
    ############################
 
1000
    # search alternate m4 dirs #
 
1001
    ############################
 
1002
    SEARCH_DIRS=""
 
1003
    for dir in m4 ; do
 
1004
        if [ -d $dir ] ; then
 
1005
            $VERBOSE_ECHO "Found extra aclocal search directory: $dir"
 
1006
            SEARCH_DIRS="$SEARCH_DIRS -I $dir"
 
1007
        fi
 
1008
    done
 
1009
 
 
1010
    ######################################
 
1011
    # remove any previous build products #
 
1012
    ######################################
 
1013
    if test -d autom4te.cache ; then
 
1014
        $VERBOSE_ECHO "Found an autom4te.cache directory, deleting it"
 
1015
        $VERBOSE_ECHO "rm -rf autom4te.cache"
 
1016
        rm -rf autom4te.cache
 
1017
    fi
 
1018
# tcl/tk (and probably others) have a customized aclocal.m4, so can't delete it
 
1019
#     if test -f aclocal.m4 ; then
 
1020
#       $VERBOSE_ECHO "Found an aclocal.m4 file, deleting it"
 
1021
#       $VERBOSE_ECHO "rm -f aclocal.m4"
 
1022
#       rm -f aclocal.m4
 
1023
#     fi
 
1024
 
 
1025
} # end of initialize()
 
1026
 
 
1027
 
 
1028
##############
 
1029
# initialize #
 
1030
##############
 
1031
 
 
1032
# stash path
 
1033
START_PATH="`pwd`"
 
1034
 
 
1035
# Before running autoreconf or manual steps, some prep detection work
 
1036
# is necessary or useful.  Only needs to occur once per directory, but
 
1037
# does need to traverse the entire subconfigure hierarchy to protect
 
1038
# files from being clobbered even by autoreconf.
 
1039
recursive_protect
 
1040
 
 
1041
# start from where we started
 
1042
cd "$START_PATH"
 
1043
 
 
1044
# get ready to process
 
1045
initialize
 
1046
 
 
1047
 
 
1048
############################################
 
1049
# prepare build via autoreconf or manually #
 
1050
############################################
 
1051
reconfigure_manually=no
 
1052
if [ "x$HAVE_AUTORECONF" = "xyes" ] ; then
 
1053
    $ECHO
 
1054
    $ECHO $ECHO_N "Automatically preparing build ... $ECHO_C"
 
1055
 
 
1056
    $VERBOSE_ECHO "$AUTORECONF $SEARCH_DIRS $AUTORECONF_OPTIONS"
 
1057
    autoreconf_output="`$AUTORECONF $SEARCH_DIRS $AUTORECONF_OPTIONS 2>&1`"
 
1058
    ret=$?
 
1059
    $VERBOSE_ECHO "$autoreconf_output"
 
1060
 
 
1061
    if [ ! $ret = 0 ] ; then
 
1062
        if [ "x$HAVE_ALT_LIBTOOLIZE" = "xyes" ] ; then
 
1063
            if [ ! "x`echo \"$autoreconf_output\" | grep libtoolize | grep \"No such file or directory\"`" = "x" ] ; then
 
1064
                $ECHO
 
1065
                $ECHO "Warning: autoreconf failed but due to what is usually a common libtool"
 
1066
                $ECHO "misconfiguration issue.  This problem is encountered on systems that"
 
1067
                $ECHO "have installed libtoolize under a different name without providing a"
 
1068
                $ECHO "symbolic link or without setting the LIBTOOLIZE environment variable."
 
1069
                $ECHO
 
1070
                $ECHO "Restarting the preparation steps with LIBTOOLIZE set to $LIBTOOLIZE"
 
1071
 
 
1072
                export LIBTOOLIZE
 
1073
                RUN_RECURSIVE=no
 
1074
                export RUN_RECURSIVE
 
1075
                untrap_abnormal
 
1076
 
 
1077
                $VERBOSE_ECHO sh $AUTOGEN_SH "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9"
 
1078
                sh "$AUTOGEN_SH" "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9"
 
1079
                exit $?
 
1080
            fi
 
1081
        fi
 
1082
 
 
1083
        $ECHO "Warning: $AUTORECONF failed"
 
1084
 
 
1085
        if test -f ltmain.sh ; then
 
1086
            $ECHO "libtoolize being run by autoreconf is not creating ltmain.sh in the auxillary directory like it should"
 
1087
        fi
 
1088
 
 
1089
        $ECHO "Attempting to run the preparation steps individually"
 
1090
        reconfigure_manually=yes
 
1091
    fi
 
1092
else
 
1093
    reconfigure_manually=yes
 
1094
fi
 
1095
 
 
1096
 
 
1097
############################
 
1098
# LIBTOOL_FAILURE FUNCTION #
 
1099
############################
 
1100
libtool_failure ( ) {
 
1101
 
 
1102
    # libtool is rather error-prone in comparison to the other
 
1103
    # autotools and this routine attempts to compensate for some
 
1104
    # common failures.  the output after a libtoolize failure is
 
1105
    # parsed for an error related to AC_PROG_LIBTOOL and if found, we
 
1106
    # attempt to inject a project-provided libtool.m4 file.
 
1107
 
 
1108
    _autoconf_output="$1"
 
1109
 
 
1110
    if [ "x$RUN_RECURSIVE" = "xno" ] ; then
 
1111
        # we already tried the libtool.m4, don't try again
 
1112
        return 1
 
1113
    fi
 
1114
 
 
1115
    if test -f "$LIBTOOL_M4" ; then
 
1116
        found_libtool="`$ECHO $_autoconf_output | grep AC_PROG_LIBTOOL`"
 
1117
        if test ! "x$found_libtool" = "x" ; then
 
1118
            if test -f acinclude.m4 ; then
 
1119
                rm -f acinclude.m4.$$.backup
 
1120
                $VERBOSE_ECHO "cat acinclude.m4 > acinclude.m4.$$.backup"
 
1121
                cat acinclude.m4 > acinclude.m4.$$.backup
 
1122
            fi
 
1123
            $VERBOSE_ECHO "cat \"$LIBTOOL_M4\" >> acinclude.m4"
 
1124
            chmod u+w acinclude.m4
 
1125
            cat "$LIBTOOL_M4" >> acinclude.m4
 
1126
 
 
1127
            # don't keep doing this
 
1128
            RUN_RECURSIVE=no
 
1129
            export RUN_RECURSIVE
 
1130
            untrap_abnormal
 
1131
 
 
1132
            $ECHO
 
1133
            $ECHO "Restarting the preparation steps with libtool macros in acinclude.m4"
 
1134
            $VERBOSE_ECHO sh $AUTOGEN_SH "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9"
 
1135
            sh "$AUTOGEN_SH" "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9"
 
1136
            exit $?
 
1137
        fi
 
1138
    fi
 
1139
}
 
1140
 
 
1141
 
 
1142
###########################
 
1143
# MANUAL_AUTOGEN FUNCTION #
 
1144
###########################
 
1145
manual_autogen ( ) {
 
1146
 
 
1147
    ##################################################
 
1148
    # Manual preparation steps taken are as follows: #
 
1149
    #   aclocal [-I m4]                              #
 
1150
    #   libtoolize --automake -c -f                  #
 
1151
    #   aclocal [-I m4]                              #
 
1152
    #   autoconf -f                                  #
 
1153
    #   automake -a -c -f                            #
 
1154
    ##################################################
 
1155
 
 
1156
    ###########
 
1157
    # aclocal #
 
1158
    ###########
 
1159
    $VERBOSE_ECHO "$ACLOCAL $SEARCH_DIRS $ACLOCAL_OPTIONS"
 
1160
    aclocal_output="`$ACLOCAL $SEARCH_DIRS $ACLOCAL_OPTIONS 2>&1`"
 
1161
    ret=$?
 
1162
    $VERBOSE_ECHO "$aclocal_output"
 
1163
    if [ ! $ret = 0 ] ; then $ECHO "ERROR: $ACLOCAL failed" && exit 2 ; fi
 
1164
 
 
1165
    ##############
 
1166
    # libtoolize #
 
1167
    ##############
 
1168
    need_libtoolize=no
 
1169
    for feature in AC_PROG_LIBTOOL LT_INIT ; do
 
1170
        $VERBOSE_ECHO "Searching for $feature in $CONFIGURE"
 
1171
        found="`grep \"^$feature.*\" $CONFIGURE`"
 
1172
        if [ ! "x$found" = "x" ] ; then
 
1173
            need_libtoolize=yes
 
1174
            break
 
1175
        fi
 
1176
    done
 
1177
    if [ "x$need_libtoolize" = "xyes" ] ; then
 
1178
        if [ "x$HAVE_LIBTOOLIZE" = "xyes" ] ; then
 
1179
            $VERBOSE_ECHO "$LIBTOOLIZE $LIBTOOLIZE_OPTIONS"
 
1180
            libtoolize_output="`$LIBTOOLIZE $LIBTOOLIZE_OPTIONS 2>&1`"
 
1181
            ret=$?
 
1182
            $VERBOSE_ECHO "$libtoolize_output"
 
1183
            
 
1184
            if [ ! $ret = 0 ] ; then $ECHO "ERROR: $LIBTOOLIZE failed" && exit 2 ; fi
 
1185
        else
 
1186
            if [ "x$HAVE_ALT_LIBTOOLIZE" = "xyes" ] ; then
 
1187
                $VERBOSE_ECHO "$LIBTOOLIZE $ALT_LIBTOOLIZE_OPTIONS"
 
1188
                libtoolize_output="`$LIBTOOLIZE $ALT_LIBTOOLIZE_OPTIONS 2>&1`"
 
1189
                ret=$?
 
1190
                $VERBOSE_ECHO "$libtoolize_output"
 
1191
                
 
1192
                if [ ! $ret = 0 ] ; then $ECHO "ERROR: $LIBTOOLIZE failed" && exit 2 ; fi
 
1193
            fi
 
1194
        fi
 
1195
 
 
1196
        ###########
 
1197
        # aclocal #
 
1198
        ###########
 
1199
        # re-run again as instructed by libtoolize
 
1200
        $VERBOSE_ECHO "$ACLOCAL $SEARCH_DIRS $ACLOCAL_OPTIONS"
 
1201
        aclocal_output="`$ACLOCAL $SEARCH_DIRS $ACLOCAL_OPTIONS 2>&1`"
 
1202
        ret=$?
 
1203
        $VERBOSE_ECHO "$aclocal_output"
 
1204
 
 
1205
        # libtoolize might put ltmain.sh in the wrong place
 
1206
        if test -f ltmain.sh ; then
 
1207
            if test ! -f "${_aux_dir}/ltmain.sh" ; then
 
1208
                $ECHO
 
1209
                $ECHO "Warning:  $LIBTOOLIZE is creating ltmain.sh in the wrong directory"
 
1210
                $ECHO
 
1211
                $ECHO "Fortunately, the problem can be worked around by simply copying the"
 
1212
                $ECHO "file to the appropriate location (${_aux_dir}/).  This has been done for you."
 
1213
                $ECHO
 
1214
                $VERBOSE_ECHO "cp -p ltmain.sh \"${_aux_dir}/ltmain.sh\""
 
1215
                cp -p ltmain.sh "${_aux_dir}/ltmain.sh"
 
1216
                $ECHO $ECHO_N "Continuing build preparation ... $ECHO_C"
 
1217
            fi
 
1218
        fi # ltmain.sh
 
1219
    fi # need_libtoolize
 
1220
 
 
1221
    ############
 
1222
    # autoconf #
 
1223
    ############
 
1224
    $VERBOSE_ECHO
 
1225
    $VERBOSE_ECHO "$AUTOCONF $AUTOCONF_OPTIONS"
 
1226
    autoconf_output="`$AUTOCONF $AUTOCONF_OPTIONS 2>&1`"
 
1227
    ret=$?
 
1228
    $VERBOSE_ECHO "$autoconf_output"
 
1229
 
 
1230
    if [ ! $ret = 0 ] ; then
 
1231
        # retry without the -f and check for usage of macros that are too new
 
1232
        ac2_59_macros="AC_C_RESTRICT AC_INCLUDES_DEFAULT AC_LANG_ASSERT AC_LANG_WERROR AS_SET_CATFILE"
 
1233
        ac2_55_macros="AC_COMPILER_IFELSE AC_FUNC_MBRTOWC AC_HEADER_STDBOOL AC_LANG_CONFTEST AC_LANG_SOURCE AC_LANG_PROGRAM AC_LANG_CALL AC_LANG_FUNC_TRY_LINK AC_MSG_FAILURE AC_PREPROC_IFELSE"
 
1234
        ac2_54_macros="AC_C_BACKSLASH_A AC_CONFIG_LIBOBJ_DIR AC_GNU_SOURCE AC_PROG_EGREP AC_PROG_FGREP AC_REPLACE_FNMATCH AC_FUNC_FNMATCH_GNU AC_FUNC_REALLOC AC_TYPE_MBSTATE_T"
 
1235
 
 
1236
        macros_to_search=""
 
1237
        ac_major="`echo ${AUTOCONF_VERSION}. | cut -d. -f1 | sed 's/[^0-9]//g'`"
 
1238
        ac_minor="`echo ${AUTOCONF_VERSION}. | cut -d. -f2 | sed 's/[^0-9]//g'`"
 
1239
        
 
1240
        if [ $ac_major -lt 2 ] ; then
 
1241
            macros_to_search="$ac2_59_macros $ac2_55_macros $ac2_54_macros"
 
1242
        else
 
1243
            if [ $ac_minor -lt 54 ] ; then
 
1244
                macros_to_search="$ac2_59_macros $ac2_55_macros $ac2_54_macros"
 
1245
            elif [ $ac_minor -lt 55 ] ; then
 
1246
                macros_to_search="$ac2_59_macros $ac2_55_macros"
 
1247
            elif [ $ac_minor -lt 59 ] ; then
 
1248
                macros_to_search="$ac2_59_macros"
 
1249
            fi
 
1250
        fi
 
1251
 
 
1252
        configure_ac_macros=__none__
 
1253
        for feature in $macros_to_search ; do
 
1254
            $VERBOSE_ECHO "Searching for $feature in $CONFIGURE"
 
1255
            found="`grep \"^$feature.*\" $CONFIGURE`"
 
1256
            if [ ! "x$found" = "x" ] ; then
 
1257
                if [ "x$configure_ac_macros" = "x__none__" ] ; then
 
1258
                    configure_ac_macros="$feature"
 
1259
                else
 
1260
                    configure_ac_macros="$feature $configure_ac_macros"
 
1261
                fi
 
1262
            fi
 
1263
        done
 
1264
        if [ ! "x$configure_ac_macros" = "x__none__" ] ; then
 
1265
            $ECHO
 
1266
            $ECHO "Warning:  Unsupported macros were found in $CONFIGURE"
 
1267
            $ECHO
 
1268
            $ECHO "The `echo $CONFIGURE | basename` file was scanned in order to determine if any"
 
1269
            $ECHO "unsupported macros are used that exceed the minimum version"
 
1270
            $ECHO "settings specified within this file.  As such, the following macros"
 
1271
            $ECHO "should be removed from configure.ac or the version numbers in this"
 
1272
            $ECHO "file should be increased:"
 
1273
            $ECHO
 
1274
            $ECHO "$configure_ac_macros"
 
1275
            $ECHO
 
1276
            $ECHO $ECHO_N "Ignorantly continuing build preparation ... $ECHO_C"
 
1277
        fi
 
1278
 
 
1279
        ###################
 
1280
        # autoconf, retry #
 
1281
        ###################
 
1282
        $VERBOSE_ECHO
 
1283
        $VERBOSE_ECHO "$AUTOCONF"
 
1284
        autoconf_output="`$AUTOCONF 2>&1`"
 
1285
        ret=$?
 
1286
        $VERBOSE_ECHO "$autoconf_output"
 
1287
 
 
1288
        if [ ! $ret = 0 ] ; then
 
1289
            # test if libtool is busted
 
1290
            libtool_failure "$autoconf_output"
 
1291
 
 
1292
            # let the user know what went wrong
 
1293
            cat <<EOF
 
1294
$autoconf_output
 
1295
EOF
 
1296
            $ECHO "ERROR: $AUTOCONF failed"
 
1297
            exit 2
 
1298
        else
 
1299
            # autoconf sans -f and possibly sans unsupported options succeed so warn verbosely
 
1300
            $ECHO
 
1301
            $ECHO "Warning: autoconf seems to have succeeded by removing the following options:"
 
1302
            $ECHO "     AUTOCONF_OPTIONS=\"$AUTOCONF_OPTIONS\""
 
1303
            $ECHO
 
1304
            $ECHO "Removing those options should not be necessary and indicate some other"
 
1305
            $ECHO "problem with the build system.  The build preparation is highly suspect"
 
1306
            $ECHO "and may result in configuration or compilation errors.  Consider"
 
1307
            if [ "x$VERBOSE_ECHO" = "x:" ] ; then
 
1308
                $ECHO "rerunning the build preparation with verbose output enabled."
 
1309
                $ECHO " $AUTOGEN_SH --verbose"
 
1310
            else
 
1311
                $ECHO "reviewing the minimum GNU Autotools version settings contained in"
 
1312
                $ECHO "this script along with the macros being used in your `echo $CONFIGURE | basename` file."
 
1313
            fi
 
1314
            $ECHO
 
1315
            $ECHO $ECHO_N "Continuing build preparation ... $ECHO_C"
 
1316
        fi # autoconf ret = 0
 
1317
    fi # autoconf ret = 0
 
1318
 
 
1319
    ############
 
1320
    # automake #
 
1321
    ############
 
1322
    need_automake=no
 
1323
    for feature in AM_INIT_AUTOMAKE ; do
 
1324
        $VERBOSE_ECHO "Searching for $feature in $CONFIGURE"
 
1325
        found="`grep \"^$feature.*\" $CONFIGURE`"
 
1326
        if [ ! "x$found" = "x" ] ; then
 
1327
            need_automake=yes
 
1328
            break
 
1329
        fi
 
1330
    done
 
1331
 
 
1332
    if [ "x$need_automake" = "xyes" ] ; then
 
1333
        $VERBOSE_ECHO "$AUTOMAKE $AUTOMAKE_OPTIONS"
 
1334
        automake_output="`$AUTOMAKE $AUTOMAKE_OPTIONS 2>&1`"
 
1335
        ret=$?
 
1336
        $VERBOSE_ECHO "$automake_output"
 
1337
        
 
1338
        if [ ! $ret = 0 ] ; then
 
1339
 
 
1340
            ###################
 
1341
            # automake, retry #
 
1342
            ###################
 
1343
            $VERBOSE_ECHO
 
1344
            $VERBOSE_ECHO "$AUTOMAKE $ALT_AUTOMAKE_OPTIONS"
 
1345
            # retry without the -f
 
1346
            automake_output="`$AUTOMAKE $ALT_AUTOMAKE_OPTIONS 2>&1`"
 
1347
            ret=$?
 
1348
            $VERBOSE_ECHO "$automake_output"
 
1349
            
 
1350
            if [ ! $ret = 0 ] ; then
 
1351
                # test if libtool is busted
 
1352
                libtool_failure "$automake_output"
 
1353
 
 
1354
                # let the user know what went wrong
 
1355
                cat <<EOF
 
1356
$automake_output
 
1357
EOF
 
1358
                $ECHO "ERROR: $AUTOMAKE failed"
 
1359
                exit 2
 
1360
            fi # automake retry
 
1361
        fi # automake ret = 0
 
1362
    fi # need_automake
 
1363
} # end of manual_autogen
 
1364
 
 
1365
 
 
1366
#####################################
 
1367
# RECURSIVE_MANUAL_AUTOGEN FUNCTION #
 
1368
#####################################
 
1369
recursive_manual_autogen ( ) {
 
1370
 
 
1371
    # run the build preparation steps manually for this directory
 
1372
    manual_autogen
 
1373
 
 
1374
    # for projects using recursive configure, run the build
 
1375
    # preparation steps for the subdirectories.
 
1376
    if [ ! "x$CONFIG_SUBDIRS" = "x" ] ; then
 
1377
        $VERBOSE_ECHO "Recursively configuring the following directories:"
 
1378
        $VERBOSE_ECHO "  $CONFIG_SUBDIRS"
 
1379
        for dir in $CONFIG_SUBDIRS ; do
 
1380
            $VERBOSE_ECHO "Processing recursive configure in $dir"
 
1381
            cd "$START_PATH"
 
1382
            cd "$dir"
 
1383
 
 
1384
            # new directory, prepare
 
1385
            initialize
 
1386
 
 
1387
            # run manual steps for the subdir and any others below
 
1388
            recursive_manual_autogen
 
1389
        done
 
1390
    fi
 
1391
}
 
1392
 
 
1393
 
 
1394
################################
 
1395
# run manual preparation steps #
 
1396
################################
 
1397
if [ "x$reconfigure_manually" = "xyes" ] ; then
 
1398
    $ECHO
 
1399
    $ECHO $ECHO_N "Preparing build ... $ECHO_C"
 
1400
 
 
1401
    recursive_manual_autogen
 
1402
fi
 
1403
 
 
1404
 
 
1405
#########################
 
1406
# restore and summarize #
 
1407
#########################
 
1408
cd "$START_PATH"
 
1409
 
 
1410
# restore COPYING and INSTALL from backup if necessary
 
1411
recursive_restore
 
1412
 
 
1413
# make sure we end up with a configure script
 
1414
config_ac="`locate_configure_template`"
 
1415
config="`echo $config_ac | sed 's/\.ac$//' | sed 's/\.in$//'`"
 
1416
if [ "x$config" = "x" ] ; then
 
1417
    $VERBOSE_ECHO "Could not locate the configure template (from `pwd`)"
 
1418
fi
 
1419
 
 
1420
# summarize
 
1421
$ECHO "done"
 
1422
$ECHO
 
1423
if test "x$config" = "x" -o ! -f "$config" ; then
 
1424
    $ECHO "WARNING: The $PROJECT build system should now be prepared but there"
 
1425
    $ECHO "does not seem to be a resulting configure file.  This is unexpected"
 
1426
    $ECHO "and likely the result of an error.  You should run $NAME_OF_AUTOGEN"
 
1427
    $ECHO "with the --verbose option to get more details on a potential"
 
1428
    $ECHO "misconfiguration."
 
1429
else
 
1430
    $ECHO "The $PROJECT build system is now prepared.  To build here, run:"
 
1431
    $ECHO "  $config"
 
1432
    $ECHO "  make"
 
1433
fi
 
1434
 
 
1435
 
 
1436
# Local Variables:
 
1437
# mode: sh
 
1438
# tab-width: 8
 
1439
# sh-basic-offset: 4
 
1440
# sh-indentation: 4
 
1441
# indent-tabs-mode: t
 
1442
# End:
 
1443
# ex: shiftwidth=4 tabstop=8