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