~ubuntu-branches/ubuntu/lucid/autoconf/lucid

« back to all changes in this revision

Viewing changes to bin/autoreconf.in

  • Committer: Bazaar Package Importer
  • Author(s): Ben Pfaff
  • Date: 2002-03-27 21:52:33 UTC
  • Revision ID: james.westby@ubuntu.com-20020327215233-r3gmxall0x27s306
Tags: upstream-2.53
ImportĀ upstreamĀ versionĀ 2.53

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! @PERL@ -w
 
2
# -*- perl -*-
 
3
# @configure_input@
 
4
 
 
5
eval 'exec @PERL@ -S $0 ${1+"$@"}'
 
6
    if 0;
 
7
 
 
8
# autoreconf - install the GNU Build System in a directory tree
 
9
# Copyright 1994, 1999, 2000, 2001 Free Software Foundation, Inc.
 
10
 
 
11
# This program is free software; you can redistribute it and/or modify
 
12
# it under the terms of the GNU General Public License as published by
 
13
# the Free Software Foundation; either version 2, or (at your option)
 
14
# any later version.
 
15
 
 
16
# This program is distributed in the hope that it will be useful,
 
17
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
18
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
19
# GNU General Public License for more details.
 
20
 
 
21
# You should have received a copy of the GNU General Public License
 
22
# along with this program; if not, write to the Free Software
 
23
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 
24
# 02111-1307, USA.
 
25
 
 
26
# Written by David J. MacKenzie.
 
27
# Extended and rewritten in Perl by Akim Demaille.
 
28
 
 
29
BEGIN
 
30
{
 
31
  my $perllibdir = $ENV{'autom4te_perllibdir'} || '@datadir@';
 
32
  unshift @INC, "$perllibdir";
 
33
}
 
34
 
 
35
use Autom4te::General;
 
36
use Autom4te::XFile;
 
37
use Cwd 'chdir', 'cwd';
 
38
use strict;
 
39
 
 
40
## ----------- ##
 
41
## Variables.  ##
 
42
## ----------- ##
 
43
 
 
44
# $HELP
 
45
# -----
 
46
$help = "Usage: $0 [OPTION] ... [CONFIGURE-AC or DIRECTORY] ...
 
47
 
 
48
Run `autoconf' (and `autoheader', `aclocal', `automake', `gettextize',
 
49
and `libtoolize' where appropriate) repeatedly to remake the GNU Build
 
50
System files in the DIRECTORIES or the directory trees driven by
 
51
CONFIGURE-AC (defaulting to `.').
 
52
 
 
53
By default, it only remakes those files that are older than their
 
54
predecessors.  If you install new versions of the GNU Build System,
 
55
running `autoreconf' remakes all of the files by giving it the
 
56
`--force' option.
 
57
 
 
58
Operation modes:
 
59
  -h, --help      print this help, then exit
 
60
  -V, --version   print version number, then exit
 
61
  -v, --verbose   verbosely report processing
 
62
  -d, --debug     don't remove temporary files
 
63
  -f, --force     consider all files obsolete
 
64
  -i, --install   copy missing auxiliary files
 
65
  -s, --symlink   instead of copying, install symbolic links
 
66
 
 
67
Library directories:
 
68
  -I, --include=DIR  look for FILES in DIR (cumulative)
 
69
 
 
70
The environment variables AUTOCONF, AUTOHEADER, AUTOMAKE, ACLOCAL,
 
71
GETTEXTIZE, LIBTOOLIZE are honored.
 
72
 
 
73
Report bugs to <bug-autoconf\@gnu.org>.
 
74
";
 
75
 
 
76
# $VERSION
 
77
# --------
 
78
$version = "autoreconf (@PACKAGE_NAME@) @VERSION@
 
79
Written by David J. MacKenzie and Akim Demaille.
 
80
 
 
81
Copyright 2002 Free Software Foundation, Inc.
 
82
This is free software; see the source for copying conditions.  There is NO
 
83
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
84
";
 
85
 
 
86
# Lib files.
 
87
my $autoconf   = $ENV{'AUTOCONF'}   || '@autoconf-name@';
 
88
my $autoheader = $ENV{'AUTOHEADER'} || '@autoheader-name@';
 
89
my $automake   = $ENV{'AUTOMAKE'}   || 'automake';
 
90
my $aclocal    = $ENV{'ACLOCAL'}    || 'aclocal';
 
91
my $libtoolize = $ENV{'LIBTOOLIZE'} || 'libtoolize';
 
92
my $gettextize = $ENV{'GETTEXTIZE'} || 'gettextize';
 
93
 
 
94
 
 
95
# --install -- as --add-missing in other tools.
 
96
my $install = 0;
 
97
my @include;
 
98
my $status = 0;
 
99
# symlink -- when --install, use symlinks instead.
 
100
my $symlink = 0;
 
101
 
 
102
# The directory where autoreconf was run.
 
103
my $cwd = cwd;
 
104
 
 
105
## ---------- ##
 
106
## Routines.  ##
 
107
## ---------- ##
 
108
 
 
109
 
 
110
# parse_args ()
 
111
# -------------
 
112
# Process any command line arguments.
 
113
sub parse_args ()
 
114
{
 
115
  my $srcdir;
 
116
 
 
117
  getopt ('I|include|A|autoconf-dir|m|macrodir|l|localdir=s' => \@include,
 
118
          'i|install'                                        => \$install,
 
119
          's|symlink'                                        => \$symlink);
 
120
 
 
121
  # Even if the user specified a configure.ac, trim to get the
 
122
  # directory, and look for configure.ac again.  Because (i) the code
 
123
  # is simpler, and (ii) we are still able to diagnose simultaneous
 
124
  # presence of configure.ac and configure.in.
 
125
  @ARGV = map { /configure\.(ac|in)$/ ? dirname ($_) : $_ } @ARGV;
 
126
  push @ARGV, '.' unless @ARGV;
 
127
 
 
128
  if ($verbose && $debug)
 
129
    {
 
130
      xsystem ("$autoconf --version | sed 1q >&2");
 
131
      print STDERR "\n";
 
132
      xsystem ("$autoheader --version | sed 1q >&2");
 
133
      print STDERR "\n";
 
134
      xsystem ("$automake --version | sed 1q >&2");
 
135
      print STDERR "\n";
 
136
      xsystem ("$aclocal --version | sed 1q >&2");
 
137
      print STDERR "\n";
 
138
      xsystem ("$gettextize --version | sed 1q >&2");
 
139
      print STDERR "\n";
 
140
      xsystem ("$libtoolize --version | sed 1q >&2");
 
141
      print STDERR "\n";
 
142
    }
 
143
 
 
144
  # Dispatch autoreconf's option to the tools.
 
145
  # --include;
 
146
  $autoconf   .= join (' --include=', '', @include);
 
147
  $autoheader .= join (' --include=', '', @include);
 
148
 
 
149
  # --install and --symlink;
 
150
  if ($install)
 
151
    {
 
152
      $automake   .= ' --add-missing';
 
153
      $automake   .= ' --copy' unless $symlink;
 
154
      $gettextize .= ' --copy' unless $symlink;
 
155
      $libtoolize .= ' --copy' unless $symlink;
 
156
    }
 
157
  # --force;
 
158
  if ($force)
 
159
    {
 
160
      $autoconf   .= ' --force';
 
161
      $autoheader .= ' --force';
 
162
      $automake   .= ' --force-missing';
 
163
      $gettextize .= ' --force';
 
164
      $libtoolize .= ' --force';
 
165
    }
 
166
  else
 
167
    {
 
168
      $automake .= ' --no-force';
 
169
    }
 
170
  # --debug;
 
171
  if ($debug)
 
172
    {
 
173
      $autoconf   .= ' --verbose --debug';
 
174
      $autoheader .= ' --verbose --debug';
 
175
      $automake   .= ' --verbose';
 
176
      $aclocal    .= ' --verbose';
 
177
      $libtoolize .= ' --debug';
 
178
    }
 
179
}
 
180
 
 
181
 
 
182
# &autoreconf ($DIRECTORY)
 
183
# ------------------------
 
184
# Reconf the $DIRECTORY.
 
185
sub autoreconf ($)
 
186
{
 
187
  my ($directory) = @_;
 
188
 
 
189
  verbose "working in `$directory'";
 
190
  chdir $directory
 
191
    or die "$me: cannot chdir to $directory: $!\n";
 
192
 
 
193
  my $configure_ac = find_configure_ac;
 
194
  die "$me: cannot find `configure.ac' in `$directory'\n"
 
195
    unless $configure_ac;
 
196
 
 
197
  # ---------------------- #
 
198
  # Is it using Autoconf?  #
 
199
  # ---------------------- #
 
200
 
 
201
  my $uses_autoconf;
 
202
  my $configure_ac_file = new Autom4te::XFile $configure_ac;
 
203
  while ($_ = $configure_ac_file->getline)
 
204
     {
 
205
       if (/AC_INIT/)
 
206
         {
 
207
           $uses_autoconf = 1;
 
208
           last;
 
209
         }
 
210
     }
 
211
  if (!$uses_autoconf)
 
212
    {
 
213
      verbose "$configure_ac: not using Autoconf";
 
214
      return;
 
215
    }
 
216
 
 
217
 
 
218
  # ----------------- #
 
219
  # Running aclocal.  #
 
220
  # ----------------- #
 
221
 
 
222
  # Run it first: it might discover new macros to add, e.g.,
 
223
  # AC_PROG_LIBTOOL, which we will trace later to see if Libtool is
 
224
  # used.
 
225
  #
 
226
  # Always run it.  Tracking its sources for up-to-dateness is too
 
227
  # complex and too error prone.  The best we can do is avoiding
 
228
  # nuking the time stamp.
 
229
  my $uses_aclocal = 1;
 
230
 
 
231
  # Nevertheless, if aclocal.m4 exists and is not made by aclocal,
 
232
  # don't run aclocal.
 
233
 
 
234
  if (-f 'aclocal.m4')
 
235
    {
 
236
      my $aclocal_m4 = new Autom4te::XFile 'aclocal.m4';
 
237
      $_ = $aclocal_m4->getline;
 
238
      $uses_aclocal = 0
 
239
        unless /generated.*by aclocal/;
 
240
    }
 
241
 
 
242
  # If there are flags for aclocal in Makefile.am, use them.
 
243
  my $aclocal_flags = '';
 
244
  if ($uses_aclocal && -f 'Makefile.am')
 
245
    {
 
246
      my $makefile = new Autom4te::XFile 'Makefile.am';
 
247
      while ($_ = $makefile->getline)
 
248
        {
 
249
          if (/^ACLOCAL_[A-Z_]*FLAGS\s*=\s*(.*)/)
 
250
            {
 
251
              $aclocal_flags = $1;
 
252
              last;
 
253
            }
 
254
        }
 
255
    }
 
256
 
 
257
  if (!$uses_aclocal)
 
258
    {
 
259
      verbose "$configure_ac: not using aclocal";
 
260
    }
 
261
  else
 
262
    {
 
263
      xsystem ("$aclocal $aclocal_flags --output=aclocal.m4t");
 
264
      # aclocal may produce no output.
 
265
      update_file ('aclocal.m4t', 'aclocal.m4')
 
266
        if -f 'aclocal.m4t';
 
267
    }
 
268
 
 
269
 
 
270
 
 
271
  # ------------------------------- #
 
272
  # See what tools will be needed.  #
 
273
  # ------------------------------- #
 
274
 
 
275
  # Perform a single trace reading to avoid --force forcing a rerun
 
276
  # between two --trace, that's useless.  If there is no AC_INIT, then
 
277
  # we are not interested: it looks like a Cygnus thingy.
 
278
  my $uses_gettext;
 
279
  my $uses_libtool;
 
280
  my $uses_autoheader;
 
281
  my @subdir;
 
282
  my $traces = new Autom4te::XFile
 
283
    ("$autoconf"
 
284
     . join (' --trace=', '',
 
285
             'AC_INIT', 'AM_GNU_GETTEXT', 'AC_PROG_LIBTOOL',
 
286
             'AC_CONFIG_HEADERS',
 
287
             'AC_CONFIG_SUBDIRS:AC_CONFIG_SUBDIRS:\$1')
 
288
     . ' |');
 
289
  while ($_ = $traces->getline)
 
290
    {
 
291
      $uses_autoconf = 1            if /AC_INIT/;
 
292
      $uses_gettext = 1             if /AM_GNU_GETTEXT/;
 
293
      $uses_libtool = 1             if /AC_PROG_LIBTOOL/;
 
294
      $uses_autoheader = 1          if /AC_CONFIG_HEADERS/;
 
295
      push @subdir, split (' ', $1) if /AC_CONFIG_SUBDIRS:(.*)/;
 
296
    }
 
297
 
 
298
  # The subdirs are *optional*, they may not exist.
 
299
  foreach (@subdir)
 
300
    {
 
301
      if (-d)
 
302
        {
 
303
          verbose "$configure_ac: subdirectory $_ to autoreconf";
 
304
          push @ARGV, $_;
 
305
        }
 
306
      else
 
307
        {
 
308
          verbose "$configure_ac: subdirectory $_ not present";
 
309
        }
 
310
    }
 
311
 
 
312
 
 
313
 
 
314
  # -------------------- #
 
315
  # Running gettexitze.  #
 
316
  # -------------------- #
 
317
 
 
318
  if (!$uses_gettext)
 
319
    {
 
320
      verbose "$configure_ac: not using Gettext";
 
321
    }
 
322
  elsif (-d 'intl' && !$force)
 
323
    {
 
324
      verbose "$configure_ac: not running gettextize: `intl' is already present";
 
325
    }
 
326
  elsif ($install)
 
327
    {
 
328
      xsystem ($gettextize);
 
329
    }
 
330
  else
 
331
    {
 
332
      verbose "$configure_ac: not running gettextize: --install not given";
 
333
    }
 
334
 
 
335
 
 
336
  # -------------------- #
 
337
  # Running libtoolize.  #
 
338
  # -------------------- #
 
339
 
 
340
  if (!$uses_libtool)
 
341
    {
 
342
      verbose "$configure_ac: not using Libtool";
 
343
    }
 
344
  elsif ($install)
 
345
    {
 
346
      xsystem ($libtoolize);
 
347
    }
 
348
  else
 
349
    {
 
350
      verbose "$configure_ac: not running libtoolize: --install not given";
 
351
    }
 
352
 
 
353
 
 
354
  # ------------------ #
 
355
  # Running automake.  #
 
356
  # ------------------ #
 
357
 
 
358
  # Assumes that there is a Makefile.am in the topmost directory.
 
359
  if (!-f 'Makefile.am')
 
360
    {
 
361
      verbose "$configure_ac: not using Automake";
 
362
    }
 
363
  else
 
364
    {
 
365
      # We should always run automake, and let it decide whether it shall
 
366
      # update the file or not.  In fact, the effect of `$force' is already
 
367
      # included in `$automake' via `--no-force'.
 
368
      xsystem ($automake);
 
369
    }
 
370
 
 
371
 
 
372
  # ------------------ #
 
373
  # Running autoconf.  #
 
374
  # ------------------ #
 
375
 
 
376
  # Don't try to be smarter than `autoconf', which does its own
 
377
  # up to date checkings.
 
378
  xsystem ($autoconf);
 
379
 
 
380
 
 
381
  # -------------------- #
 
382
  # Running autoheader.  #
 
383
  # -------------------- #
 
384
 
 
385
  # We now consider that if AC_CONFIG_HEADERS is used, then autoheader
 
386
  # is used too.
 
387
  # Just as for autoconf, up to date ness is performed by the tool itself.
 
388
  if (!$uses_autoheader)
 
389
    {
 
390
      verbose "$configure_ac: not using Autoheader";
 
391
    }
 
392
  else
 
393
    {
 
394
      xsystem ($autoheader);
 
395
    }
 
396
 
 
397
  chdir $cwd
 
398
    or die "$me: cannot chdir to $cwd: $!\n";
 
399
}
 
400
 
 
401
 
 
402
## ------ ##
 
403
## Main.  ##
 
404
## ------ ##
 
405
 
 
406
# When debugging, it is convenient that all the related temporary
 
407
# files be at the same place.
 
408
mktmpdir ('ar');
 
409
$ENV{'TMPDIR'} = $tmp;
 
410
parse_args;
 
411
 
 
412
# Autoreconf all the given configure.ac.  A while loop, not a for,
 
413
# since the list can change at runtime because of AC_CONFIG_SUBDIRS.
 
414
autoreconf (shift @ARGV)
 
415
  while (@ARGV);