summaryrefslogtreecommitdiff
path: root/Build/source/reautoconf
blob: b822e97ab9133e1360b88b3ac5725bfbf93ccf2e (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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#! /bin/sh

# $Id$
# This "reautoconf" script found at the root of the TeX Live source tree 
# runs aclocal and autoconf (from PATH) in all relevant directories.
#
# Copyright 2008 Karl Berry.
# Copyright 2005 Olaf Weber.
# Copyright 2004 - 2008 Peter Breitenlohner.
#
# 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.

unset CDPATH

usage="Usage: $0 [OPTION]... [DIR]...
  Run \`aclocal' (if applicable) and \`autoconf' in a selection
  of the directories DIR... (default all) in TeX Live source tree.

Options:
  -h, --help      display this help and exit successfully
  -f, --force     include some optional packages
  -n, --dry-run   don't run any commands; just print them
  -q, --quiet     don't echo commands
  -v, --verbose   verbosely report processing (default)

Selection:
  packages using KPSE macros are included
  packages using automake are excluded
  packages using GNU autoconf 2.60 or later:
    with \`--force' included, otherwise excluded
  packages using old autoconf versions are excluded

Environment variables:
  TL_ACLOCAL:    program to use instead of aclocal from PATH
  TL_AUTOCONF:   program to use instead of autoconf from PATH
  TL_AUTOHEADER: program to use instead of autoheader from PATH"

force=no
do_cmd=eval
do_say=echo

list=

for option
do
  case $option in
    -h | --help) echo "$usage"; exit 0
      ;;
    -f | --force) force=yes
      ;;
    -n | --dry-run) do_cmd=:
      ;;
    -q | --quiet) do_say=:
      ;;
    -v | --verbose) do_say=echo
      ;;
    -*) echo "$0: *** unrecognized option \`$option'"
      echo "$usage"; exit 1
      ;;
    *) list="$list $option"
      ;;
  esac
done

[ "$do_cmd" = : ] && do_say=echo	# -n implies -v

[ -f ./texk/make/common.mk ] || {
	echo "$0: *** can't find ./texk/make/common.mk (from `pwd`)" >&2
	exit 1
}

: ${TL_ACLOCAL=aclocal}
echo "$0: using \"$TL_ACLOCAL\" = `$TL_ACLOCAL --version | sed 1q`"
echo "$0: if you want to use a different aclocal, set TL_ACLOCAL."
: ${TL_AUTOCONF=autoconf}
echo "$0: using \"$TL_AUTOCONF\" = `$TL_AUTOCONF --version | sed 1q`"
echo "$0: if you want to use a different autoconf, set TL_AUTOCONF."
: ${TL_AUTOHEADER=autoheader}
echo "$0: using \"$TL_AUTOHEADER\" = `$TL_AUTOHEADER --version | sed 1q`"
echo "$0: if you want to use a different autoheader, set TL_AUTOHEADER."

# Give users a chance to quit here
# and set TL_ACLOCAL, TL_AUTOCONF and/or TL_AUTOHEADER
$do_cmd sleep 5

do_it () {
  $do_say "$0: running \"$@\""
  $do_cmd "$@"
}

# process one directory
do_one () {	# $base=configure.{in,ac}, $dir=current, $dir/$rdir->./texk/m4 with the KPSE macros
  if grep 'AM_INIT_AUTOMAKE' $base >/dev/null 2>&1; then
    $do_say "$0: $dir/$base ... uses automake, skipped."
  elif grep 'm4_include(\['$rdir'/kpse_.*\.m4])' aclocal.m4 >/dev/null 2>&1; then
    $do_say "$0: $dir/$base ... uses KPSE macros"
    do_it "$TL_ACLOCAL -I $rdir && date >stamp-aclocal"
    if grep '^kpse_include \.\./make/config.mk$' Makefile.in >/dev/null 2>&1; then
      do_it "$TL_AUTOHEADER && date >stamp-auto.in"
    fi
    do_it $TL_AUTOCONF
  elif grep '# Generated by GNU Autoconf 2.6' configure >/dev/null 2>&1; then
    if test "$force" = yes; then
      $do_say "$0: $dir/$base ... uses modern autoconf, forced"
      do_it $TL_AUTOCONF
    else
      $do_say "$0: $dir/$base ... uses modern autoconf, skipped"
    fi
  else
    $do_say "$0: $dir/$base ... uses older autoconf, skipped."
  fi
}

if test "x$list" = x; then
  list=". `find libs utils texk -name configure.in -o -name configure.ac |
    sed 's,/configure\...\$,,'`"
fi

# Autoconf in all directories
for dir in $list; do
  if test -f "$dir/configure.in"; then
    base=configure.in
  elif test -f "$dir/configure.ac"; then
    base=configure.ac
  else
    continue
  fi
  case $dir in
    .)
      rdir=texk/m4
    ;;
    texk)
      rdir=m4
    ;;
    texk/*)
      rdir=`echo $dir | sed -e 's,^texk/,,' -e 's,[^/]*,..,g'`/m4
    ;;
    *)
      rdir=`echo $dir | sed 's,[^/]*,..,g'`/texk/m4
    ;;
  esac
  (cd $dir; do_one)
done

echo "$0: done."