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