source: scripts/untested/autotools/wrappers/am-wrapper-1.sh @ d1afb9e

clfs-1.2clfs-2.1clfs-3.0.0-systemdclfs-3.0.0-sysvinitsystemdsysvinit
Last change on this file since d1afb9e was d1afb9e, checked in by Jim Gifford <clfs@…>, 18 years ago

r587@server (orig r585): ryan | 2005-08-05 21:51:35 -0700
Add a sane autotools build to the mix.
Blatantly stolen from gentoo...



  • Property mode set to 100755
File size: 3.3 KB
Line 
1#!/bin/bash
2# Copyright 1999-2004 Gentoo Foundation
3# Distributed under the terms of the GNU General Public License v2
4# $Header: /var/cvsroot/gentoo-x86/sys-devel/automake-wrapper/files/am-wrapper-1.sh,v 1.4 2005/05/14 17:42:00 vapier 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 automake-1.9
12# - runs automake-1.8 if:
13#   - envvar WANT_AUTOMAKE is set to `1.8'
14#     -or-
15#   - `Makefile.in' was generated by automake-1.8
16#     -or-
17#   - 'aclocal.m4' contain AM_AUTOMAKE_VERSION, specifying the use of 1.8
18# - runs automake-1.7 if:
19#   - envvar WANT_AUTOMAKE is set to `1.7'
20#     -or-
21#   - `Makefile.in' was generated by automake-1.7
22#     -or-
23#   - 'aclocal.m4' contain AM_AUTOMAKE_VERSION, specifying the use of 1.7
24# - runs automake-1.6 if:
25#   - envvar WANT_AUTOMAKE is set to `1.6'
26#     -or-
27#   - `Makefile.in'
28#     -or-
29#   - 'aclocal.m4' contain AM_AUTOMAKE_VERSION, specifying the use of 1.6
30# - runs automake-1.5 if:
31#   - envvar WANT_AUTOMAKE is set to `1.5'
32#     -or-
33#   - `Makefile.in' was generated by automake-1.5
34#     -or-
35#   - 'aclocal.m4' contain AM_AUTOMAKE_VERSION, specifying the use of 1.5
36# - runs automake-1.4 if:
37#   - envvar WANT_AUTOMAKE is set to `1.4'
38#     -or-
39#   - `Makefile.in' was generated by automake-1.4
40#     -or-
41#   - 'aclocal.m4' contain AM_AUTOMAKE_VERSION, specifying the use of 1.4
42
43if [ "${0##*/}" = "am-wrapper.sh" ] ; then
44        echo "Don't call this script directly." >&2
45        exit 1
46fi
47
48vers="1.9 1.8 1.7 1.6 1.5 1.4"
49
50for v in ${vers} ; do
51        eval binary_${v/./_}="${0}-${v}"
52done
53binary="${binary_1_9}"
54
55#
56# Check the WANT_AUTOMAKE setting
57#
58for v in ${vers} x ; do
59        if [ "${v}" = "x" ] ; then
60                unset WANT_AUTOMAKE
61                break
62        fi
63
64        if [ "${WANT_AUTOMAKE}" = "${v}" ] ; then
65                binary="binary_${v/./_}"
66                binary="${!binary}"
67                break
68        fi
69done
70
71do_awk() {
72        local file=$1 ; shift
73        local arg=$1 ; shift
74        echo $(gawk "{ if (match(\$0, \"$*\", res)) { print res[${arg}]; exit } }" ${file})
75}
76
77#
78# autodetect routine
79#
80if [ -z "${WANT_AUTOMAKE}" ] ; then
81        if [ -r "Makefile.in" ] ; then
82                confversion_mf=$(do_awk Makefile.in 2 "^# Makefile.in generated (automatically )?by automake ([0-9].[0-9])")
83        fi
84        if [ -r "aclocal.m4" ] ; then
85                confversion_ac=$(do_awk aclocal.m4 1 'generated automatically by aclocal ([0-9].[0-9])')
86                confversion_am=$(do_awk aclocal.m4 1 '[[:space:]]*\\[?AM_AUTOMAKE_VERSION\\(\\[?([0-9].[0-9])[^)]*\\]?\\)')
87        fi
88
89        for v in ${vers} ; do
90                if [ "${confversion_mf}" = "${v}" ] \
91                   || [ "${confversion_ac}" = "${v}" ] \
92                   || [ "${confversion_am}" = "${v}" ] ; then
93                        binary="binary_${v/./_}"
94                        binary="${!binary}"
95                        break
96                fi
97        done
98fi
99
100if [ "${WANT_AMWRAPPER_DEBUG}" ] ; then
101        if [ "${WANT_AUTOMAKE}" ] ; then
102                echo "am-wrapper: DEBUG: WANT_AUTOMAKE is set to ${WANT_AUTOMAKE}" >&2
103        fi
104        echo "am-wrapper: DEBUG: will execute <$binary>" >&2
105fi
106
107#
108# for further consistency
109#
110for v in ${vers} ; do
111        mybin="binary_${v/./_}"
112        if [ "${binary}" = "${!mybin}" ] ; then
113                export WANT_AUTOMAKE="${v}"
114        fi
115done
116
117#
118# Now try to run the binary
119#
120if [ ! -x "${binary}" ] ; then
121        echo "am-wrapper: $binary is missing or not executable." >&2
122        echo "            Please try emerging the correct version of automake." >&2
123        exit 1
124fi
125
126exec "$binary" "$@"
127
128echo "am-wrapper: was unable to exec $binary !?" >&2
129exit 1
Note: See TracBrowser for help on using the repository browser.