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