summaryrefslogtreecommitdiffstats
path: root/aclocal.sh
blob: 03585c8e1efc3001d5b90e544f9ce8616e07e1f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#! /bin/sh

# This script is a work-alike of `aclocal' contained in the GNU automake
# package. It is needed because our aclocal.m4 must be generated from the
# non-gettext .m4 files in /usr/share/aclocal and from the gettext specific
# .m4 files in the local m4 directory.
# With   "aclocal --acdir=m4"
# we get an error: macro `AM_INIT_AUTOMAKE' not found in library
# With   "aclocal -I m4"
# we get an error: duplicated macro `AM_GNU_GETTEXT'
# The solution is to put all the .m4 files into a temporary directory.

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.

set -e

if test $# = 0; then
  echo "Usage: $0 aclocal-program [aclocal-options]" 1>&2
  exit 1
fi

# The command line is of the form
#   /somepath/aclocal ...
# or
#   /somepath/missing aclocal ...
# or
#   /bin/sh /somepath/missing aclocal ...
# or
#   /bin/sh /somepath/missing aclocal --run ...
# Extract the first part.
ACLOCAL="$1"
shift
ACLOCAL2=
ACLOCAL3=
case "$ACLOCAL" in
  *sh)
    ACLOCAL="$1"
    shift
    ;;
esac
case "$ACLOCAL" in
  *missing)
    ACLOCAL2="$1"
    shift
    case "$1" in
      --run)
        ACLOCAL3="$1"
        shift
        ;;
    esac
    ;;
esac

# Prepare temporary directory.
mkdir aclocal.tmp
trap "rm -rf aclocal.tmp; exit 1" 1 2 15

# First, copy the standard m4 files.
for f in `"$ACLOCAL" $ACLOCAL2 $ACLOCAL3 --print-ac-dir`/*.m4; do
  cp $f aclocal.tmp
done

# Then, copy the contents of any -I directories, overriding previously
# copied files of the same name.
options=""
last_was_I=no
for arg
do
  if test $last_was_I = yes; then
    for f in "$arg"/*.m4; do
      cp $f aclocal.tmp
    done
    last_was_I=no
  else
    case "$arg" in
      -I) last_was_I=yes;;
      *)  last_was_I=no options="$options $arg";;
    esac
  fi
done

# Now call `aclocal' for real.
"$ACLOCAL" $ACLOCAL2 $ACLOCAL3 --acdir=aclocal.tmp $options

# Clean up temporary directory.
rm -rf aclocal.tmp