Magellan Linux

Annotation of /trunk/autoconf/ac-wrapper-4.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1215 - (hide annotations) (download) (as text)
Fri Dec 3 20:06:12 2010 UTC (13 years, 11 months ago) by niro
File MIME type: application/x-sh
File size: 4271 byte(s)
-updated wrapper for autoconf-2.68
1 niro 117 #!/bin/bash
2     # Copyright 1999-2006 Gentoo Foundation
3     # Distributed under the terms of the GNU General Public License v2
4 niro 1099 # $Header: /root/magellan-cvs/src/autoconf/ac-wrapper-4.sh,v 1.5 2010-08-19 19:24:26 niro Exp $
5 niro 117
6     # Based on the ac-wrapper.pl script provided by MandrakeSoft
7     # Rewritten in bash by Gregorio Guidi
8     #
9     # Executes the correct autoconf version.
10     #
11     # - defaults to newest version available (hopefully autoconf-2.60)
12     # - runs autoconf 2.13 if:
13     # - envvar WANT_AUTOCONF is set to `2.1'
14     # -or-
15     # - `ac{local,include}.m4' or `configure.{in,ac}' have AC_PREREQ(2.1) (not higher)
16     # -or-
17     # - `configure' is already present and was generated by autoconf 2.13
18    
19     if [[ ${0##*/} == "ac-wrapper.sh" ]] ; then
20     echo "Don't call this script directly" >&2
21     exit 1
22     fi
23    
24     if [[ ${WANT_AUTOCONF} == "2.1" && ${0##*/} == "autom4te" ]] ; then
25     echo "ac-wrapper: Autoconf 2.13 doesn't contain autom4te." >&2
26     echo " Either unset WANT_AUTOCONF or don't execute anything" >&2
27     echo " that would use autom4te." >&2
28     exit 1
29     fi
30    
31     #
32     # Set up bindings between actual version and WANT_AUTOCONF
33     #
34 niro 1215 vers="2.68:2.6 2.67:2.6 2.59:2.5 2.13:2.1"
35 niro 117
36     binary=""
37     for v in ${vers} ; do
38     auto_ver=${v%:*}
39     if [ -z "${binary}" ] && [ -x "${0}-${auto_ver}" ] ; then
40     binary="${0}-${auto_ver}"
41     fi
42     done
43     if [ -z "${binary}" ] ; then
44     echo "ac-wrapper: Unable to locate any usuable version of autoconf." >&2
45     echo " I tried these versions: ${vers}" >&2
46     echo " With a base name of '${0}'." >&2
47     exit 1
48     fi
49    
50     #
51     # Check the WANT_AUTOCONF setting. We accept a whitespace delimited
52     # list of autoconf versions.
53     #
54     if [ -n "${WANT_AUTOCONF}" ] ; then
55     for v in ${vers} x ; do
56     if [ "${v}" = "x" ] ; then
57     echo "ac-wrapper: warning: invalid WANT_AUTOCONF '${WANT_AUTOCONF}'; ignoring." >&2
58     unset WANT_AUTOCONF
59     break
60     fi
61    
62     auto_ver=${v%:*}
63     want_ver=${v#*:}
64     for wx in ${WANT_AUTOCONF} ; do
65     if [ "${wx}" = "${want_ver}" ] && [ -x "${0}-${auto_ver}" ] ; then
66     binary="${0}-${auto_ver}"
67     v="x"
68     fi
69     done
70     [ "${v}" = "x" ] && break
71     done
72     fi
73    
74     #
75     # autodetect helpers
76     #
77     acprereq_version() {
78     gawk \
79     '($0 !~ /^[[:space:]]*(#|dnl)/) {
80     if (match($0, "AC_PREREQ\\(\\[?([0-9]\\.[0-9])", res))
81     VERSIONS[COUNT++] = res[1]
82     }
83    
84     END {
85     asort(VERSIONS)
86     print VERSIONS[COUNT]
87     }' "$@"
88     }
89    
90     generated_version() {
91     gawk \
92     '{
93     if (match($0,
94     "^# Generated (by (GNU )?Autoconf|automatically using autoconf version) ([0-9].[0-9])",
95     res)) {
96     print res[3]
97     exit
98     }
99     }' "$@"
100     }
101    
102     #
103     # autodetect routine
104     #
105     if [[ ${WANT_AUTOCONF} == "2.1" ]] && [ -f "configure.ac" ] ; then
106     echo "ac-wrapper: Since configure.ac is present, aclocal always use" >&2
107     echo " autoconf 2.59+, which conflicts with your choice and" >&2
108     echo " causes error. You have two options:" >&2
109     echo " 1. Try execute command again after removing configure.ac" >&2
110     echo " 2. Don't set WANT_AUTOCONF" >&2
111     exit 1
112     fi
113    
114     if [[ ${WANT_AUTOCONF} != "2.5" ]] && [[ -n ${WANT_AUTOMAKE} ]] ; then
115     # Automake-1.7 and better require autoconf-2.5x so if WANT_AUTOMAKE
116     # is set to an older version, let's do some sanity checks.
117     case "${WANT_AUTOMAKE}" in
118     1.[456])
119     acfiles=$(ls ac{local,include}.m4 configure.{in,ac} 2>/dev/null)
120     [[ -n ${acfiles} ]] && confversion=$(acprereq_version ${acfiles})
121    
122     [[ -z ${confversion} && -r "configure" ]] \
123     && confversion=$(generated_version configure)
124    
125     if [[ ${confversion} == "2.1" && ! -f "configure.ac" ]] ; then
126     binary="${0}-2.13"
127     fi
128     esac
129     fi
130    
131     if [[ -n ${WANT_ACWRAPPER_DEBUG} ]] ; then
132     if [[ -n ${WANT_AUTOCONF} ]] ; then
133     echo "ac-wrapper: DEBUG: WANT_AUTOCONF is set to ${WANT_AUTOCONF}" >&2
134     fi
135     echo "ac-wrapper: DEBUG: will execute <${binary}>" >&2
136     fi
137    
138     #
139     # for further consistency
140     #
141     for v in ${vers} ; do
142     auto_ver=${v%:*}
143     want_ver=${v#*:}
144     if [ "${binary}" = "${0}-${auto_ver}" ] ; then
145     export WANT_AUTOCONF="${want_ver}"
146     fi
147     done
148    
149     #
150     # Now try to run the binary
151     #
152     if [[ ! -x ${binary} ]] ; then
153     # this shouldn't happen
154     echo "ac-wrapper: ${binary} is missing or not executable." >&2
155     echo " Please try emerging the correct version of autoconf." >&2
156     exit 1
157     fi
158    
159     exec "${binary}" "$@"
160    
161     echo "ac-wrapper: was unable to exec ${binary} !?" >&2
162     exit 1