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