1 1.1 christos #! @PERL@ -w 2 1.1 christos # -*- perl -*- 3 1.1 christos # @configure_input@ 4 1.1 christos 5 1.1 christos eval 'case $# in 0) exec @PERL@ -S "$0";; *) exec @PERL@ -S "$0" "$@";; esac' 6 1.1 christos if 0; 7 1.1 christos 8 1.1 christos # autoreconf - install the GNU Build System in a directory tree 9 1.1 christos # Copyright (C) 1994, 1999-2012 Free Software Foundation, Inc. 10 1.1 christos 11 1.1 christos # This program is free software: you can redistribute it and/or modify 12 1.1 christos # it under the terms of the GNU General Public License as published by 13 1.1 christos # the Free Software Foundation, either version 3 of the License, or 14 1.1 christos # (at your option) any later version. 15 1.1 christos 16 1.1 christos # This program is distributed in the hope that it will be useful, 17 1.1 christos # but WITHOUT ANY WARRANTY; without even the implied warranty of 18 1.1 christos # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 1.1 christos # GNU General Public License for more details. 20 1.1 christos 21 1.1 christos # You should have received a copy of the GNU General Public License 22 1.1 christos # along with this program. If not, see <http://www.gnu.org/licenses/>. 23 1.1 christos 24 1.1 christos # Written by David J. MacKenzie. 25 1.1 christos # Extended and rewritten in Perl by Akim Demaille. 26 1.1 christos 27 1.1 christos BEGIN 28 1.1 christos { 29 1.1 christos my $pkgdatadir = $ENV{'autom4te_perllibdir'} || '@pkgdatadir@'; 30 1.1 christos unshift @INC, $pkgdatadir; 31 1.1 christos 32 1.1 christos # Override SHELL. On DJGPP SHELL may not be set to a shell 33 1.1 christos # that can handle redirection and quote arguments correctly, 34 1.1 christos # e.g.: COMMAND.COM. For DJGPP always use the shell that configure 35 1.1 christos # has detected. 36 1.1 christos $ENV{'SHELL'} = '@SHELL@' if ($^O eq 'dos'); 37 1.1 christos } 38 1.1 christos 39 1.1 christos use Autom4te::ChannelDefs; 40 1.1 christos use Autom4te::Channels; 41 1.1 christos use Autom4te::Configure_ac; 42 1.1 christos use Autom4te::FileUtils; 43 1.1 christos use Autom4te::General; 44 1.1 christos use Autom4te::XFile; 45 1.1 christos # Do not use Cwd::chdir, since it might hang. 46 1.1 christos use Cwd 'cwd'; 47 1.1 christos use strict; 48 1.1 christos 49 1.1 christos ## ----------- ## 50 1.1 christos ## Variables. ## 51 1.1 christos ## ----------- ## 52 1.1 christos 53 1.1 christos # $HELP 54 1.1 christos # ----- 55 1.1 christos $help = "Usage: $0 [OPTION]... [DIRECTORY]... 56 1.1 christos 57 1.1 christos Run `autoconf' (and `autoheader', `aclocal', `automake', `autopoint' 58 1.1 christos (formerly `gettextize'), and `libtoolize' where appropriate) 59 1.1 christos repeatedly to remake the GNU Build System files in specified 60 1.1 christos DIRECTORIES and their subdirectories (defaulting to `.'). 61 1.1 christos 62 1.1 christos By default, it only remakes those files that are older than their 63 1.1 christos sources. If you install new versions of the GNU Build System, 64 1.1 christos you can make `autoreconf' remake all of the files by giving it the 65 1.1 christos `--force' option. 66 1.1 christos 67 1.1 christos Operation modes: 68 1.1 christos -h, --help print this help, then exit 69 1.1 christos -V, --version print version number, then exit 70 1.1 christos -v, --verbose verbosely report processing 71 1.1 christos -d, --debug don't remove temporary files 72 1.1 christos -f, --force consider all files obsolete 73 1.1 christos -i, --install copy missing auxiliary files 74 1.1 christos --no-recursive don't rebuild sub-packages 75 1.1 christos -s, --symlink with -i, install symbolic links instead of copies 76 1.1 christos -m, --make when applicable, re-run ./configure && make 77 1.1 christos -W, --warnings=CATEGORY report the warnings falling in CATEGORY [syntax] 78 1.1 christos 79 1.1 christos " . Autom4te::ChannelDefs::usage . " 80 1.1 christos 81 1.1 christos The environment variable \`WARNINGS\' is honored. Some subtools might 82 1.1 christos support other warning types, using \`all' is encouraged. 83 1.1 christos 84 1.1 christos Library directories: 85 1.1 christos -B, --prepend-include=DIR prepend directory DIR to search path 86 1.1 christos -I, --include=DIR append directory DIR to search path 87 1.1 christos 88 1.1 christos The environment variables AUTOM4TE, AUTOCONF, AUTOHEADER, AUTOMAKE, 89 1.1 christos ACLOCAL, AUTOPOINT, LIBTOOLIZE, M4, and MAKE are honored. 90 1.1 christos 91 1.1 christos Report bugs to <bug-autoconf\@gnu.org>. 92 1.1 christos GNU Autoconf home page: <http://www.gnu.org/software/autoconf/>. 93 1.1 christos General help using GNU software: <http://www.gnu.org/gethelp/>. 94 1.1 christos "; 95 1.1 christos 96 1.1 christos # $VERSION 97 1.1 christos # -------- 98 1.1 christos $version = "autoreconf (@PACKAGE_NAME@) @VERSION@ 99 1.1 christos Copyright (C) @RELEASE_YEAR@ Free Software Foundation, Inc. 100 1.1 christos License GPLv3+/Autoconf: GNU GPL version 3 or later 101 1.1 christos <http://gnu.org/licenses/gpl.html>, <http://gnu.org/licenses/exceptions.html> 102 1.1 christos This is free software: you are free to change and redistribute it. 103 1.1 christos There is NO WARRANTY, to the extent permitted by law. 104 1.1 christos 105 1.1 christos Written by David J. MacKenzie and Akim Demaille. 106 1.1 christos "; 107 1.1 christos 108 1.1 christos # Lib files. 109 1.1 christos my $autoconf = $ENV{'AUTOCONF'} || '@bindir@/@autoconf-name@'; 110 1.1 christos my $autoheader = $ENV{'AUTOHEADER'} || '@bindir@/@autoheader-name@'; 111 1.1 christos my $autom4te = $ENV{'AUTOM4TE'} || '@bindir@/@autom4te-name@'; 112 1.1 christos my $automake = $ENV{'AUTOMAKE'} || 'automake'; 113 1.1 christos my $aclocal = $ENV{'ACLOCAL'} || 'aclocal'; 114 1.1 christos my $libtoolize = $ENV{'LIBTOOLIZE'} || 'libtoolize'; 115 1.1 christos my $autopoint = $ENV{'AUTOPOINT'} || 'autopoint'; 116 1.1 christos my $make = $ENV{'MAKE'} || 'make'; 117 1.1 christos 118 1.1 christos # --install -- as --add-missing in other tools. 119 1.1 christos my $install = 0; 120 1.1 christos # symlink -- when --install, use symlinks instead. 121 1.1 christos my $symlink = 0; 122 1.1 christos # Does aclocal support --force? 123 1.1 christos my $aclocal_supports_force = 0; 124 1.1 christos # Does aclocal support -Wfoo? 125 1.1 christos my $aclocal_supports_warnings = 0; 126 1.1 christos # Does automake support --force-missing? 127 1.1 christos my $automake_supports_force_missing = 0; 128 1.1 christos # Does automake support -Wfoo? 129 1.1 christos my $automake_supports_warnings = 0; 130 1.1 christos 131 1.1 christos my @prepend_include; 132 1.1 christos my @include; 133 1.1 christos 134 1.1 christos # List of command line warning requests. 135 1.1 christos my @warning; 136 1.1 christos 137 1.1 christos # Rerun `./configure && make'? 138 1.1 christos my $run_make = 0; 139 1.1 christos 140 1.1 christos # Recurse into subpackages 141 1.1 christos my $recursive = 1; 142 1.1 christos 143 1.1 christos ## ---------- ## 144 1.1 christos ## Routines. ## 145 1.1 christos ## ---------- ## 146 1.1 christos 147 1.1 christos 148 1.1 christos # parse_args () 149 1.1 christos # ------------- 150 1.1 christos # Process any command line arguments. 151 1.1 christos sub parse_args () 152 1.1 christos { 153 1.1 christos my $srcdir; 154 1.1 christos 155 1.1 christos getopt ("W|warnings=s" => \@warning, 156 1.1 christos 'I|include=s' => \@include, 157 1.1 christos 'B|prepend-include=s' => \@prepend_include, 158 1.1 christos 'i|install' => \$install, 159 1.1 christos 's|symlink' => \$symlink, 160 1.1 christos 'm|make' => \$run_make, 161 1.1 christos 'recursive!' => \$recursive); 162 1.1 christos 163 1.1 christos # Split the warnings as a list of elements instead of a list of 164 1.1 christos # lists. 165 1.1 christos @warning = map { split /,/ } @warning; 166 1.1 christos parse_WARNINGS; 167 1.1 christos parse_warnings '--warnings', @warning; 168 1.1 christos 169 1.1 christos # Even if the user specified a configure.ac, trim to get the 170 1.1 christos # directory, and look for configure.ac again. Because (i) the code 171 1.1 christos # is simpler, and (ii) we are still able to diagnose simultaneous 172 1.1 christos # presence of configure.ac and configure.in. 173 1.1 christos @ARGV = map { /configure\.(ac|in)$/ ? dirname ($_) : $_ } @ARGV; 174 1.1 christos push @ARGV, '.' unless @ARGV; 175 1.1 christos 176 1.1 christos if ($verbose && $debug) 177 1.1 christos { 178 1.1 christos for my $prog ($autoconf, $autoheader, 179 1.1 christos $automake, $aclocal, 180 1.1 christos $autopoint, 181 1.1 christos $libtoolize) 182 1.1 christos { 183 1.1 christos xsystem ("$prog --version | sed 1q >&2"); 184 1.1 christos print STDERR "\n"; 185 1.1 christos } 186 1.1 christos } 187 1.1 christos 188 1.1 christos my $aclocal_help = `$aclocal --help 2>/dev/null`; 189 1.1 christos my $automake_help = `$automake --help 2>/dev/null`; 190 1.1 christos $aclocal_supports_force = $aclocal_help =~ /--force/; 191 1.1 christos $aclocal_supports_warnings = $aclocal_help =~ /--warnings/; 192 1.1 christos $automake_supports_force_missing = $automake_help =~ /--force-missing/; 193 1.1 christos $automake_supports_warnings = $automake_help =~ /--warnings/; 194 1.1 christos 195 1.1 christos # Dispatch autoreconf's option to the tools. 196 1.1 christos # --include; 197 1.1 christos $aclocal .= join (' -I ', '', map { shell_quote ($_) } @include); 198 1.1 christos $autoconf .= join (' --include=', '', map { shell_quote ($_) } @include); 199 1.1 christos $autoconf .= join (' --prepend-include=', '', map { shell_quote ($_) } @prepend_include); 200 1.1 christos $autoheader .= join (' --include=', '', map { shell_quote ($_) } @include); 201 1.1 christos $autoheader .= join (' --prepend-include=', '', map { shell_quote ($_) } @prepend_include); 202 1.1 christos 203 1.1 christos # --install and --symlink; 204 1.1 christos if ($install) 205 1.1 christos { 206 1.1 christos $automake .= ' --add-missing'; 207 1.1 christos $automake .= ' --copy' unless $symlink; 208 1.1 christos $libtoolize .= ' --copy' unless $symlink; 209 1.1 christos } 210 1.1 christos # --force; 211 1.1 christos if ($force) 212 1.1 christos { 213 1.1 christos $aclocal .= ' --force' 214 1.1 christos if $aclocal_supports_force; 215 1.1 christos $autoconf .= ' --force'; 216 1.1 christos $autoheader .= ' --force'; 217 1.1 christos $automake .= ' --force-missing' 218 1.1 christos if $automake_supports_force_missing; 219 1.1 christos $autopoint .= ' --force'; 220 1.1 christos $libtoolize .= ' --force'; 221 1.1 christos } 222 1.1 christos else 223 1.1 christos { 224 1.1 christos # The implementation of --no-force is bogus in all implementations 225 1.1 christos # of Automake up to 1.8, so we avoid it in these cases. (Automake 226 1.1 christos # 1.8 is the first version where aclocal supports force, hence 227 1.1 christos # the condition.) 228 1.1 christos $automake .= ' --no-force' 229 1.1 christos if $aclocal_supports_force; 230 1.1 christos } 231 1.1 christos # --verbose --verbose or --debug; 232 1.1 christos if ($verbose > 1 || $debug) 233 1.1 christos { 234 1.1 christos $autoconf .= ' --verbose'; 235 1.1 christos $autoheader .= ' --verbose'; 236 1.1 christos $automake .= ' --verbose'; 237 1.1 christos $aclocal .= ' --verbose'; 238 1.1 christos } 239 1.1 christos if ($debug) 240 1.1 christos { 241 1.1 christos $autoconf .= ' --debug'; 242 1.1 christos $autoheader .= ' --debug'; 243 1.1 christos $libtoolize .= ' --debug'; 244 1.1 christos } 245 1.1 christos # --warnings; 246 1.1 christos if (@warning) 247 1.1 christos { 248 1.1 christos my $warn = ' --warnings=' . join (',', @warning); 249 1.1 christos $autoconf .= $warn; 250 1.1 christos $autoheader .= $warn; 251 1.1 christos $automake .= $warn 252 1.1 christos if $automake_supports_warnings; 253 1.1 christos $aclocal .= $warn 254 1.1 christos if $aclocal_supports_warnings; 255 1.1 christos } 256 1.1 christos } 257 1.1 christos 258 1.1 christos 259 1.1 christos # &run_aclocal ($ACLOCAL, $FLAGS) 260 1.1 christos # ------------------------------- 261 1.1 christos # Update aclocal.m4 as lazily as possible, as aclocal pre-1.8 always 262 1.1 christos # overwrites aclocal.m4, hence triggers autoconf, autoheader, automake 263 1.1 christos # etc. uselessly. aclocal 1.8+ does not need this. 264 1.1 christos sub run_aclocal ($$) 265 1.1 christos { 266 1.1 christos my ($aclocal, $flags) = @_; 267 1.1 christos 268 1.1 christos # aclocal 1.8+ does all this for free. It can be recognized by its 269 1.1 christos # --force support. 270 1.1 christos if ($aclocal_supports_force) 271 1.1 christos { 272 1.1 christos xsystem ("$aclocal $flags"); 273 1.1 christos } 274 1.1 christos else 275 1.1 christos { 276 1.1 christos xsystem ("$aclocal $flags --output=aclocal.m4t"); 277 1.1 christos # aclocal may produce no output. 278 1.1 christos if (-f 'aclocal.m4t') 279 1.1 christos { 280 1.1 christos update_file ('aclocal.m4t', 'aclocal.m4'); 281 1.1 christos # Make sure that the local m4 files are older than 282 1.1 christos # aclocal.m4. 283 1.1 christos # 284 1.1 christos # Why is not always the case? Because we already run 285 1.1 christos # aclocal at first (before tracing), which, for instance, 286 1.1 christos # can find Gettext's macros in .../share/aclocal, so we may 287 1.1 christos # have had the right aclocal.m4 already. Then autopoint is 288 1.1 christos # run, and installs locally these M4 files. Then 289 1.1 christos # autoreconf, via update_file, sees it is the _same_ 290 1.1 christos # aclocal.m4, and doesn't change its timestamp. But later, 291 1.1 christos # Automake's Makefile expresses that aclocal.m4 depends on 292 1.1 christos # these local files, which are newer, so it triggers aclocal 293 1.1 christos # again. 294 1.1 christos # 295 1.1 christos # To make sure aclocal.m4 is no older, we change the 296 1.1 christos # modification times of the local M4 files to be not newer 297 1.1 christos # than it. 298 1.1 christos # 299 1.1 christos # First, where are the local files? 300 1.1 christos my $aclocal_local_dir = '.'; 301 1.1 christos if ($flags =~ /-I\s+(\S+)/) 302 1.1 christos { 303 1.1 christos $aclocal_local_dir = $1; 304 1.1 christos } 305 1.1 christos # All the local files newer than aclocal.m4 are to be 306 1.1 christos # made not newer than it. 307 1.1 christos my $aclocal_m4_mtime = mtime ('aclocal.m4'); 308 1.1 christos for my $file (glob ("$aclocal_local_dir/*.m4"), 'acinclude.m4') 309 1.1 christos { 310 1.1 christos if ($aclocal_m4_mtime < mtime ($file)) 311 1.1 christos { 312 1.1 christos debug "aging $file to be not newer than aclocal.m4"; 313 1.1 christos utime $aclocal_m4_mtime, $aclocal_m4_mtime, $file; 314 1.1 christos } 315 1.1 christos } 316 1.1 christos } 317 1.1 christos } 318 1.1 christos } 319 1.1 christos 320 1.1 christos # &autoreconf_current_directory 321 1.1 christos # ----------------------------- 322 1.1 christos sub autoreconf_current_directory () 323 1.1 christos { 324 1.1 christos my $configure_ac = find_configure_ac; 325 1.1 christos 326 1.1 christos # ---------------------- # 327 1.1 christos # Is it using Autoconf? # 328 1.1 christos # ---------------------- # 329 1.1 christos 330 1.1 christos my $uses_autoconf; 331 1.1 christos my $uses_gettext; 332 1.1 christos if (-f $configure_ac) 333 1.1 christos { 334 1.1 christos my $configure_ac_file = new Autom4te::XFile "< $configure_ac"; 335 1.1 christos while ($_ = $configure_ac_file->getline) 336 1.1 christos { 337 1.1 christos s/#.*//; 338 1.1 christos s/dnl.*//; 339 1.1 christos $uses_autoconf = 1 if /AC_INIT/; 340 1.1 christos # See below for why we look for gettext here. 341 1.1 christos $uses_gettext = 1 if /^AM_GNU_GETTEXT_VERSION/; 342 1.1 christos } 343 1.1 christos } 344 1.1 christos if (!$uses_autoconf) 345 1.1 christos { 346 1.1 christos verb "$configure_ac: not using Autoconf"; 347 1.1 christos return; 348 1.1 christos } 349 1.1 christos 350 1.1 christos 351 1.1 christos # ------------------- # 352 1.1 christos # Running autopoint. # 353 1.1 christos # ------------------- # 354 1.1 christos 355 1.1 christos # Gettext is a bit of a problem: its macros are not necessarily 356 1.1 christos # visible to aclocal, so if we start with a completely striped down 357 1.1 christos # package (think of a fresh CVS checkout), running `aclocal' first 358 1.1 christos # will fail: the Gettext macros are missing. 359 1.1 christos # 360 1.1 christos # Therefore, we can't use the traces to decide if we use Gettext or 361 1.1 christos # not. I guess that once Gettext move to 2.5x we will be able to, 362 1.1 christos # but in the meanwhile forget it. 363 1.1 christos # 364 1.1 christos # We can only grep for AM_GNU_GETTEXT_VERSION in configure.ac. You 365 1.1 christos # might think this approach is naive, and indeed it is, as it 366 1.1 christos # prevents one to embed AM_GNU_GETTEXT_VERSION in another *.m4, but 367 1.1 christos # anyway we don't limit the generality, since... that's what 368 1.1 christos # autopoint does. Actually, it is even more restrictive, as it 369 1.1 christos # greps for `^AM_GNU_GETTEXT_VERSION('. We did this above, while 370 1.1 christos # scanning configure.ac. 371 1.1 christos if (!$uses_gettext) 372 1.1 christos { 373 1.1 christos verb "$configure_ac: not using Gettext"; 374 1.1 christos } 375 1.1 christos elsif (!$install) 376 1.1 christos { 377 1.1 christos verb "$configure_ac: not running autopoint: --install not given"; 378 1.1 christos } 379 1.1 christos else 380 1.1 christos { 381 1.1 christos xsystem_hint ("autopoint is needed because this package uses Gettext", "$autopoint"); 382 1.1 christos } 383 1.1 christos 384 1.1 christos 385 1.1 christos # ----------------- # 386 1.1 christos # Running aclocal. # 387 1.1 christos # ----------------- # 388 1.1 christos 389 1.1 christos # Run it first: it might discover new macros to add, e.g., 390 1.1 christos # AC_PROG_LIBTOOL, which we will trace later to see if Libtool is 391 1.1 christos # used. 392 1.1 christos # 393 1.1 christos # Always run it. Tracking its sources for up-to-dateness is too 394 1.1 christos # complex and too error prone. The best we can do is avoiding 395 1.1 christos # nuking the time stamp. 396 1.1 christos my $uses_aclocal = 1; 397 1.1 christos 398 1.1 christos # Nevertheless, if aclocal.m4 exists and is not made by aclocal, 399 1.1 christos # don't run aclocal. 400 1.1 christos 401 1.1 christos if (-f 'aclocal.m4') 402 1.1 christos { 403 1.1 christos my $aclocal_m4 = new Autom4te::XFile 'aclocal.m4'; 404 1.1 christos $_ = $aclocal_m4->getline; 405 1.1 christos $uses_aclocal = 0 406 1.1 christos unless defined ($_) && /generated.*by aclocal/; 407 1.1 christos } 408 1.1 christos 409 1.1 christos # If there are flags for aclocal in Makefile.am, use them. 410 1.1 christos my $aclocal_flags = ''; 411 1.1 christos if ($uses_aclocal && -f 'Makefile.am') 412 1.1 christos { 413 1.1 christos my $makefile = new Autom4te::XFile 'Makefile.am'; 414 1.1 christos while ($_ = $makefile->getline) 415 1.1 christos { 416 1.1 christos if (/^ACLOCAL_[A-Z_]*FLAGS\s*=\s*(.*)/) 417 1.1 christos { 418 1.1 christos $aclocal_flags = $1; 419 1.1 christos last; 420 1.1 christos } 421 1.1 christos } 422 1.1 christos } 423 1.1 christos 424 1.1 christos if (!$uses_aclocal) 425 1.1 christos { 426 1.1 christos verb "$configure_ac: not using aclocal"; 427 1.1 christos } 428 1.1 christos else 429 1.1 christos { 430 1.1 christos # Some file systems have sub-second time stamps, and if so we may 431 1.1 christos # run into trouble later, after we rerun autoconf and set the 432 1.1 christos # time stamps of input files to be no greater than aclocal.m4, 433 1.1 christos # because the time-stamp-setting operation (utime) has a 434 1.1 christos # resolution of only 1 second. Work around the problem by 435 1.1 christos # ensuring that there is at least a one-second window before the 436 1.1 christos # time stamp of aclocal.m4t in which no file time stamps can 437 1.1 christos # fall. 438 1.1 christos sleep 1; 439 1.1 christos 440 1.1 christos run_aclocal ($aclocal, $aclocal_flags); 441 1.1 christos } 442 1.1 christos 443 1.1 christos # We might have to rerun aclocal if Libtool (or others) imports new 444 1.1 christos # macros. 445 1.1 christos my $rerun_aclocal = 0; 446 1.1 christos 447 1.1 christos 448 1.1 christos 449 1.1 christos # ------------------------------- # 450 1.1 christos # See what tools will be needed. # 451 1.1 christos # ------------------------------- # 452 1.1 christos 453 1.1 christos # Perform a single trace reading to avoid --force forcing a rerun 454 1.1 christos # between two --trace, that's useless. If there is no AC_INIT, then 455 1.1 christos # we are not interested: it looks like a Cygnus thingy. 456 1.1 christos my $aux_dir; 457 1.1 christos my $uses_gettext_via_traces; 458 1.1 christos my $uses_libtool; 459 1.1 christos my $uses_libltdl; 460 1.1 christos my $uses_autoheader; 461 1.1 christos my $uses_automake; 462 1.1 christos my @subdir; 463 1.1 christos verb "$configure_ac: tracing"; 464 1.1 christos my $traces = new Autom4te::XFile 465 1.1 christos ("$autoconf" 466 1.1 christos . join (' ', 467 1.1 christos map { ' --trace=' . $_ . ':\$n::\${::}%' } 468 1.1 christos # If you change this list, update the 469 1.1 christos # `Autoreconf-preselections' section of autom4te.in. 470 1.1 christos 'AC_CONFIG_AUX_DIR', 471 1.1 christos 'AC_CONFIG_HEADERS', 472 1.1 christos 'AC_CONFIG_SUBDIRS', 473 1.1 christos 'AC_INIT', 474 1.1 christos 'AC_PROG_LIBTOOL', 475 1.1 christos 'LT_INIT', 476 1.1 christos 'LT_CONFIG_LTDL_DIR', 477 1.1 christos 'AM_GNU_GETTEXT', 478 1.1 christos 'AM_INIT_AUTOMAKE', 479 1.1 christos ) 480 1.1 christos . ' |'); 481 1.1 christos while ($_ = $traces->getline) 482 1.1 christos { 483 1.1 christos chomp; 484 1.1 christos my ($macro, @args) = split (/::/); 485 1.1 christos $aux_dir = $args[0] if $macro eq "AC_CONFIG_AUX_DIR"; 486 1.1 christos $uses_autoconf = 1 if $macro eq "AC_INIT"; 487 1.1 christos $uses_gettext_via_traces = 1 if $macro eq "AM_GNU_GETTEXT"; 488 1.1 christos $uses_libtool = 1 if $macro eq "AC_PROG_LIBTOOL" 489 1.1 christos || $macro eq "LT_INIT"; 490 1.1 christos $uses_libltdl = 1 if $macro eq "LT_CONFIG_LTDL_DIR"; 491 1.1 christos $uses_autoheader = 1 if $macro eq "AC_CONFIG_HEADERS"; 492 1.1 christos $uses_automake = 1 if $macro eq "AM_INIT_AUTOMAKE"; 493 1.1 christos push @subdir, split (' ', $args[0]) 494 1.1 christos if $macro eq "AC_CONFIG_SUBDIRS" && $recursive; 495 1.1 christos } 496 1.1 christos 497 1.1 christos # The subdirs are *optional*, they may not exist. 498 1.1 christos foreach (@subdir) 499 1.1 christos { 500 1.1 christos if (-d) 501 1.1 christos { 502 1.1 christos verb "$configure_ac: adding subdirectory $_ to autoreconf"; 503 1.1 christos autoreconf ($_); 504 1.1 christos } 505 1.1 christos else 506 1.1 christos { 507 1.1 christos verb "$configure_ac: subdirectory $_ not present"; 508 1.1 christos } 509 1.1 christos } 510 1.1 christos 511 1.1 christos # Gettext consistency checks... 512 1.1 christos error "$configure_ac: AM_GNU_GETTEXT is used, but not AM_GNU_GETTEXT_VERSION" 513 1.1 christos if $uses_gettext_via_traces && ! $uses_gettext; 514 1.1 christos error "$configure_ac: AM_GNU_GETTEXT_VERSION is used, but not AM_GNU_GETTEXT" 515 1.1 christos if $uses_gettext && ! $uses_gettext_via_traces; 516 1.1 christos 517 1.1 christos 518 1.1 christos # ---------------------------- # 519 1.1 christos # Setting up the source tree. # 520 1.1 christos # ---------------------------- # 521 1.1 christos 522 1.1 christos # libtoolize, automake --add-missing etc. will drop files in the 523 1.1 christos # $AUX_DIR. But these tools fail to install these files if the 524 1.1 christos # directory itself does not exist, which valid: just imagine a CVS 525 1.1 christos # repository with hand written code only (there is not even a need 526 1.1 christos # for a Makefile.am!). 527 1.1 christos 528 1.1 christos if (defined $aux_dir && ! -d $aux_dir) 529 1.1 christos { 530 1.1 christos verb "$configure_ac: creating directory $aux_dir"; 531 1.1 christos mkdir $aux_dir, 0755 532 1.1 christos or error "cannot create $aux_dir: $!"; 533 1.1 christos } 534 1.1 christos 535 1.1 christos 536 1.1 christos # -------------------- # 537 1.1 christos # Running libtoolize. # 538 1.1 christos # -------------------- # 539 1.1 christos 540 1.1 christos if (!$uses_libtool) 541 1.1 christos { 542 1.1 christos verb "$configure_ac: not using Libtool"; 543 1.1 christos } 544 1.1 christos elsif ($install) 545 1.1 christos { 546 1.1 christos if ($uses_libltdl) 547 1.1 christos { 548 1.1 christos $libtoolize .= " --ltdl"; 549 1.1 christos } 550 1.1 christos xsystem_hint ("libtoolize is needed because this package uses Libtool", $libtoolize); 551 1.1 christos $rerun_aclocal = 1; 552 1.1 christos } 553 1.1 christos else 554 1.1 christos { 555 1.1 christos verb "$configure_ac: not running libtoolize: --install not given"; 556 1.1 christos } 557 1.1 christos 558 1.1 christos 559 1.1 christos 560 1.1 christos # ------------------- # 561 1.1 christos # Rerunning aclocal. # 562 1.1 christos # ------------------- # 563 1.1 christos 564 1.1 christos # If we re-installed Libtool or Gettext, the macros might have changed. 565 1.1 christos # Automake also needs an up-to-date aclocal.m4. 566 1.1 christos if ($rerun_aclocal) 567 1.1 christos { 568 1.1 christos if (!$uses_aclocal) 569 1.1 christos { 570 1.1 christos verb "$configure_ac: not using aclocal"; 571 1.1 christos } 572 1.1 christos else 573 1.1 christos { 574 1.1 christos run_aclocal ($aclocal, $aclocal_flags); 575 1.1 christos } 576 1.1 christos } 577 1.1 christos 578 1.1 christos 579 1.1 christos # ------------------ # 580 1.1 christos # Running autoconf. # 581 1.1 christos # ------------------ # 582 1.1 christos 583 1.1 christos # Don't try to be smarter than `autoconf', which does its own up to 584 1.1 christos # date checks. 585 1.1 christos # 586 1.1 christos # We prefer running autoconf before autoheader, because (i) the 587 1.1 christos # latter runs the former, and (ii) autoconf is stricter than 588 1.1 christos # autoheader. So all in all, autoconf should give better error 589 1.1 christos # messages. 590 1.1 christos xsystem ($autoconf); 591 1.1 christos 592 1.1 christos 593 1.1 christos # -------------------- # 594 1.1 christos # Running autoheader. # 595 1.1 christos # -------------------- # 596 1.1 christos 597 1.1 christos # We now consider that if AC_CONFIG_HEADERS is used, then autoheader 598 1.1 christos # is used too. 599 1.1 christos # 600 1.1 christos # Just as for autoconf, up to date ness is performed by the tool 601 1.1 christos # itself. 602 1.1 christos # 603 1.1 christos # Run it before automake, since the latter checks the presence of 604 1.1 christos # config.h.in when it sees an AC_CONFIG_HEADERS. 605 1.1 christos if (!$uses_autoheader) 606 1.1 christos { 607 1.1 christos verb "$configure_ac: not using Autoheader"; 608 1.1 christos } 609 1.1 christos else 610 1.1 christos { 611 1.1 christos xsystem ($autoheader); 612 1.1 christos } 613 1.1 christos 614 1.1 christos 615 1.1 christos # ------------------ # 616 1.1 christos # Running automake. # 617 1.1 christos # ------------------ # 618 1.1 christos 619 1.1 christos if (!$uses_automake) 620 1.1 christos { 621 1.1 christos verb "$configure_ac: not using Automake"; 622 1.1 christos } 623 1.1 christos else 624 1.1 christos { 625 1.1 christos # We should always run automake, and let it decide whether it shall 626 1.1 christos # update the file or not. In fact, the effect of `$force' is already 627 1.1 christos # included in `$automake' via `--no-force'. 628 1.1 christos xsystem ($automake); 629 1.1 christos } 630 1.1 christos 631 1.1 christos 632 1.1 christos # -------------- # 633 1.1 christos # Running make. # 634 1.1 christos # -------------- # 635 1.1 christos 636 1.1 christos if ($run_make) 637 1.1 christos { 638 1.1 christos if (!-f "config.status") 639 1.1 christos { 640 1.1 christos verb "no config.status: cannot re-make"; 641 1.1 christos } 642 1.1 christos else 643 1.1 christos { 644 1.1 christos xsystem ("./config.status --recheck"); 645 1.1 christos xsystem ("./config.status"); 646 1.1 christos if (!-f "Makefile") 647 1.1 christos { 648 1.1 christos verb "no Makefile: cannot re-make"; 649 1.1 christos } 650 1.1 christos else 651 1.1 christos { 652 1.1 christos xsystem ("$make"); 653 1.1 christos } 654 1.1 christos } 655 1.1 christos } 656 1.1 christos } 657 1.1 christos 658 1.1 christos 659 1.1 christos # &autoreconf ($DIRECTORY) 660 1.1 christos # ------------------------ 661 1.1 christos # Reconf the $DIRECTORY. 662 1.1 christos sub autoreconf ($) 663 1.1 christos { 664 1.1 christos my ($directory) = @_; 665 1.1 christos my $cwd = cwd; 666 1.1 christos 667 1.1 christos # The format for this message is not free: taken from Emacs, itself 668 1.1 christos # using GNU Make's format. 669 1.1 christos verb "Entering directory `$directory'"; 670 1.1 christos chdir $directory 671 1.1 christos or error "cannot chdir to $directory: $!"; 672 1.1 christos 673 1.1 christos autoreconf_current_directory; 674 1.1 christos 675 1.1 christos # The format is not free: taken from Emacs, itself using GNU Make's 676 1.1 christos # format. 677 1.1 christos verb "Leaving directory `$directory'"; 678 1.1 christos chdir $cwd 679 1.1 christos or error "cannot chdir to $cwd: $!"; 680 1.1 christos } 681 1.1 christos 682 1.1 christos 683 1.1 christos ## ------ ## 684 1.1 christos ## Main. ## 685 1.1 christos ## ------ ## 686 1.1 christos 687 1.1 christos # When debugging, it is convenient that all the related temporary 688 1.1 christos # files be at the same place. 689 1.1 christos mktmpdir ('ar'); 690 1.1 christos $ENV{'TMPDIR'} = $tmp; 691 1.1 christos parse_args; 692 1.1 christos 693 1.1 christos # Autoreconf all the given configure.ac. Unless `--no-recursive' is passed, 694 1.1 christos # AC_CONFIG_SUBDIRS will be traversed in &autoreconf_current_directory. 695 1.1 christos $ENV{'AUTOM4TE'} = $autom4te; 696 1.1 christos for my $directory (@ARGV) 697 1.1 christos { 698 1.1 christos require_configure_ac ($directory); 699 1.1 christos autoreconf ($directory); 700 1.1 christos } 701 1.1 christos 702 1.1 christos ### Setup "GNU" style for perl-mode and cperl-mode. 703 1.1 christos ## Local Variables: 704 1.1 christos ## perl-indent-level: 2 705 1.1 christos ## perl-continued-statement-offset: 2 706 1.1 christos ## perl-continued-brace-offset: 0 707 1.1 christos ## perl-brace-offset: 0 708 1.1 christos ## perl-brace-imaginary-offset: 0 709 1.1 christos ## perl-label-offset: -2 710 1.1 christos ## cperl-indent-level: 2 711 1.1 christos ## cperl-brace-offset: 0 712 1.1 christos ## cperl-continued-brace-offset: 0 713 1.1 christos ## cperl-label-offset: -2 714 1.1 christos ## cperl-extra-newline-before-brace: t 715 1.1 christos ## cperl-merge-trailing-else: nil 716 1.1 christos ## cperl-continued-statement-offset: 2 717 1.1 christos ## End: 718