Magellan Linux

Annotation of /trunk/am-wrapper/am-wrapper.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3076 - (hide annotations) (download) (as text)
Mon May 14 10:39:53 2018 UTC (5 years, 11 months ago) by niro
File MIME type: application/x-sh
File size: 5878 byte(s)
-support automake-1.16
1 niro 1916 #!/bin/bash
2     # Copyright 1999-2006 Gentoo Foundation
3     # Distributed under the terms of the GNU General Public License v2
4     # $Header: /root/magellan-cvs/src/automake/am-wrapper-4.sh,v 1.1 2009-05-23 21:25:25 niro Exp $
5    
6     # Based on the am-wrapper.pl script provided by MandrakeSoft
7     # Rewritten in bash by Gregorio Guidi
8     #
9     # Executes the correct automake version.
10     #
11 niro 3076 # - defaults to newest version available (hopefully automake-1.16)
12     # - runs automake-1.16 if:
13     # - envvar WANT_AUTOMAKE is set to `1.16'
14     # -or-
15     # - `Makefile.in' was generated by automake-1.16
16     # -or-
17     # - 'aclocal.m4' contain AM_AUTOMAKE_VERSION, specifying the use of 1.16
18 niro 2851 # - runs automake-1.15 if:
19     # - envvar WANT_AUTOMAKE is set to `1.15'
20     # -or-
21     # - `Makefile.in' was generated by automake-1.15
22     # -or-
23     # - 'aclocal.m4' contain AM_AUTOMAKE_VERSION, specifying the use of 1.15
24 niro 2168 # - runs automake-1.14 if:
25     # - envvar WANT_AUTOMAKE is set to `1.14'
26     # -or-
27     # - `Makefile.in' was generated by automake-1.14
28     # -or-
29     # - 'aclocal.m4' contain AM_AUTOMAKE_VERSION, specifying the use of 1.14
30 niro 2007 # - runs automake-1.13 if:
31     # - envvar WANT_AUTOMAKE is set to `1.13'
32     # -or-
33     # - `Makefile.in' was generated by automake-1.13
34     # -or-
35     # - 'aclocal.m4' contain AM_AUTOMAKE_VERSION, specifying the use of 1.13
36 niro 1916 # - runs automake-1.12 if:
37     # - envvar WANT_AUTOMAKE is set to `1.12'
38     # -or-
39     # - `Makefile.in' was generated by automake-1.12
40     # -or-
41     # - 'aclocal.m4' contain AM_AUTOMAKE_VERSION, specifying the use of 1.12
42     # - runs automake-1.11 if:
43     # - envvar WANT_AUTOMAKE is set to `1.11'
44     # -or-
45     # - `Makefile.in' was generated by automake-1.11
46     # -or-
47     # - 'aclocal.m4' contain AM_AUTOMAKE_VERSION, specifying the use of 1.11
48     # - runs automake-1.10 if:
49     # - envvar WANT_AUTOMAKE is set to `1.10'
50     # -or-
51     # - `Makefile.in' was generated by automake-1.10
52     # -or-
53     # - 'aclocal.m4' contain AM_AUTOMAKE_VERSION, specifying the use of 1.10
54     # - runs automake-1.9 if:
55     # - envvar WANT_AUTOMAKE is set to `1.9'
56     # -or-
57     # - `Makefile.in' was generated by automake-1.9
58     # -or-
59     # - 'aclocal.m4' contain AM_AUTOMAKE_VERSION, specifying the use of 1.9
60     # - runs automake-1.8 if:
61     # - envvar WANT_AUTOMAKE is set to `1.8'
62     # -or-
63     # - `Makefile.in' was generated by automake-1.8
64     # -or-
65     # - 'aclocal.m4' contain AM_AUTOMAKE_VERSION, specifying the use of 1.8
66     # - runs automake-1.7 if:
67     # - envvar WANT_AUTOMAKE is set to `1.7'
68     # -or-
69     # - `Makefile.in' was generated by automake-1.7
70     # -or-
71     # - 'aclocal.m4' contain AM_AUTOMAKE_VERSION, specifying the use of 1.7
72     # - runs automake-1.6 if:
73     # - envvar WANT_AUTOMAKE is set to `1.6'
74     # -or-
75     # - `Makefile.in'
76     # -or-
77     # - 'aclocal.m4' contain AM_AUTOMAKE_VERSION, specifying the use of 1.6
78     # - runs automake-1.5 if:
79     # - envvar WANT_AUTOMAKE is set to `1.5'
80     # -or-
81     # - `Makefile.in' was generated by automake-1.5
82     # -or-
83     # - 'aclocal.m4' contain AM_AUTOMAKE_VERSION, specifying the use of 1.5
84     # - runs automake-1.4 if:
85     # - envvar WANT_AUTOMAKE is set to `1.4'
86     # -or-
87     # - `Makefile.in' was generated by automake-1.4
88     # -or-
89     # - 'aclocal.m4' contain AM_AUTOMAKE_VERSION, specifying the use of 1.4
90    
91     if [ "${0##*/}" = "am-wrapper.sh" ] ; then
92     echo "Don't call this script directly." >&2
93     exit 1
94     fi
95    
96 niro 3076 vers="1.16 1.15 1.14 1.13 1.12 1.11 1.10 1.9 1.8 1.7 1.6 1.5 1.4"
97 niro 1916
98     #
99     # Export the proper variable/versions and try to locate a usuable
100     # default (newer versions are preferred)
101     #
102     binary=""
103     for v in ${vers} ; do
104     eval binary_${v/./_}="${0}-${v}"
105    
106     if [ -z "${binary}" ] && [ -x "${0}-${v}" ] ; then
107     binary="${0}-${v}"
108     fi
109     done
110     if [ -z "${binary}" ] ; then
111     echo "am-wrapper: Unable to locate any usuable version of automake." >&2
112     echo " I tried these versions: ${vers}" >&2
113     echo " With a base name of '${0}'." >&2
114     exit 1
115     fi
116    
117     #
118     # Check the WANT_AUTOMAKE setting. We accept a whitespace delimited
119     # list of automake versions.
120     #
121     if [ -n "${WANT_AUTOMAKE}" ] ; then
122     for v in ${vers} x ; do
123     if [ "${v}" = "x" ] ; then
124     echo "am-wrapper: warning: invalid WANT_AUTOMAKE '${WANT_AUTOMAKE}'; ignoring." >&2
125     unset WANT_AUTOMAKE
126     break
127     fi
128    
129     for wx in ${WANT_AUTOMAKE} ; do
130     if [ "${wx}" = "${v}" ] ; then
131     binary="binary_${v/./_}"
132     binary="${!binary}"
133     v="x"
134     fi
135     done
136     [ "${v}" = "x" ] && break
137     done
138     fi
139    
140     #
141     # autodetect helpers
142     #
143     do_awk() {
144     local file=$1 ; shift
145     local arg=$1 ; shift
146     echo $(gawk "{ if (match(\$0, \"$*\", res)) { print res[${arg}]; exit } }" ${file})
147     }
148    
149     #
150     # autodetect routine
151     #
152     if [ -z "${WANT_AUTOMAKE}" ] ; then
153     if [ -r "Makefile.in" ] ; then
154     confversion_mf=$(do_awk Makefile.in 2 "^# Makefile.in generated (automatically )?by automake ([0-9].[0-9]+)")
155     fi
156     if [ -r "aclocal.m4" ] ; then
157     confversion_ac=$(do_awk aclocal.m4 1 'generated automatically by aclocal ([0-9].[0-9]+)')
158     confversion_am=$(do_awk aclocal.m4 1 '[[:space:]]*\\[?AM_AUTOMAKE_VERSION\\(\\[?([0-9].[0-9]+)[^)]*\\]?\\)')
159     fi
160    
161     for v in ${vers} ; do
162     if [ "${confversion_mf}" = "${v}" ] \
163     || [ "${confversion_ac}" = "${v}" ] \
164     || [ "${confversion_am}" = "${v}" ] ; then
165     binary="binary_${v/./_}"
166     binary="${!binary}"
167     break
168     fi
169     done
170     fi
171    
172     if [ "${WANT_AMWRAPPER_DEBUG}" ] ; then
173     if [ "${WANT_AUTOMAKE}" ] ; then
174     echo "am-wrapper: DEBUG: WANT_AUTOMAKE is set to ${WANT_AUTOMAKE}" >&2
175     fi
176     echo "am-wrapper: DEBUG: will execute <$binary>" >&2
177     fi
178    
179     #
180     # for further consistency
181     #
182     for v in ${vers} ; do
183     mybin="binary_${v/./_}"
184     if [ "${binary}" = "${!mybin}" ] ; then
185     export WANT_AUTOMAKE="${v}"
186     fi
187     done
188    
189     #
190     # Now try to run the binary
191     #
192     if [ ! -x "${binary}" ] ; then
193     echo "am-wrapper: $binary is missing or not executable." >&2
194     echo " Please try emerging the correct version of automake." >&2
195     exit 1
196     fi
197    
198     exec "$binary" "$@"
199    
200     echo "am-wrapper: was unable to exec $binary !?" >&2
201     exit 1