2
0

autoreconf.in 21 KB

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