5 eval 'exec @PERL@ -S $0 ${1+"$@"}'
8 # automake - create Makefile.in from Makefile.am
9 # Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
10 # Free Software Foundation, Inc.
12 # This program is free software; you can redistribute it and/or modify
13 # it under the terms of the GNU General Public License as published by
14 # the Free Software Foundation; either version 2, or (at your option)
17 # This program is distributed in the hope that it will be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # GNU General Public License for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, write to the Free Software
24 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
27 # Originally written by David Mackenzie <djm@gnu.ai.mit.edu>.
28 # Perl reimplementation by Tom Tromey <tromey@cygnus.com>.
34 # Parameters set by configure. Not to be changed. NOTE: assign
35 # VERSION as string so that eg version 0.30 will print correctly.
36 my $VERSION = "@VERSION@";
37 my $PACKAGE = "@PACKAGE@";
38 my $prefix = "@prefix@";
39 my $am_dir = "@datadir@/@PACKAGE@";
42 my $IGNORE_PATTERN = "^##([^#].*)?\$";
43 my $WHITE_PATTERN = "^[ \t]*\$";
44 my $COMMENT_PATTERN = "^#";
45 my $TARGET_PATTERN="[\$a-zA-Z_.][-.a-zA-Z0-9_(){}/\$]*";
46 my $RULE_PATTERN = "^($TARGET_PATTERN) *:([^=].*|)\$";
47 my $SUFFIX_RULE_PATTERN = "^\\.([a-zA-Z0-9]+)\\.([a-zA-Z0-9]+)\$";
48 # Only recognize leading spaces, not leading tabs. If we recognize
49 # leading tabs here then we need to make the reader smarter, because
50 # otherwise it will think rules like `foo=bar; \' are errors.
51 my $MACRO_PATTERN = "^ *([A-Za-z0-9_\@]+)[ \t]*([:+]?)=[ \t]*(.*)\$";
52 my $BOGUS_MACRO_PATTERN = "^ *([^ \t]*)[ \t]*([:+]?)=[ \t]*(.*)\$";
53 my $GNITS_VERSION_PATTERN = "[0-9]+\\.[0-9]+([a-z]|\\.[0-9]+)?";
54 my $IF_PATTERN = "^if[ \t]+\([A-Za-z][A-Za-z0-9_]*\)[ \t]*\(#.*\)?\$";
55 my $ELSE_PATTERN = "^else[ \t]*\(#.*\)?\$";
56 my $ENDIF_PATTERN = "^endif[ \t]*\(#.*\)?\$";
57 my $PATH_PATTERN='(\\w|[/.-])+';
58 # This will pass through anything not of the prescribed form.
59 my $INCLUDE_PATTERN = "^include[ \t]+((\\\$\\\(top_srcdir\\\)/${PATH_PATTERN})|(\\\$\\\(srcdir\\\)/${PATH_PATTERN})|([^/\\\$]${PATH_PATTERN}))[ \t]*(#.*)?\$";
61 # Some regular expressions. One reason to put them here is that it
62 # makes indentation work better in Emacs.
63 my $AC_CONFIG_AUX_DIR_PATTERN = "AC_CONFIG_AUX_DIR\\(([^)]+)\\)";
64 my $AM_INIT_AUTOMAKE_PATTERN = "AM_INIT_AUTOMAKE\\([^,]*,([^,)]+)[,)]";
65 my $AM_PACKAGE_VERSION_PATTERN = "^\\s*\\[?([^]\\s]+)\\]?\\s*\$";
66 # Note that there is no AC_PATH_TOOL. But we don't really care.
67 my $AC_CHECK_PATTERN = "AC_(CHECK|PATH)_(PROG|PROGS|TOOL)\\(\\[?(\\w+)";
68 my $AM_MISSING_PATTERN = "AM_MISSING_PROG\\(\\[?(\\w+)";
69 # Just check for alphanumeric in AC_SUBST. If you do AC_SUBST(5),
71 my $AC_SUBST_PATTERN = "AC_SUBST\\(\\[?(\\w+)";
72 my $AM_CONDITIONAL_PATTERN = "AM_CONDITIONAL\\((\\w+)";
74 # Constants to define the "strictness" level.
79 # These constants are returned by lang_*_rewrite functions.
80 # LANG_SUBDIR means that the resulting object file should be in a
81 # subdir if the source file is. In this case the file name cannot
82 # have `..' components.
89 # Variables global to entire run.
91 # Variables related to the options.
93 # TRUE if we should always generate Makefile.in.
94 my $force_generation = 1;
96 # Strictness level as set on command line.
97 my $default_strictness = $GNU;
99 # Name of strictness level, as set on command line.
100 my $default_strictness_name = 'gnu';
102 # This is TRUE if automatic dependency generation code should be
103 # included in generated Makefile.in.
104 my $cmdline_use_dependencies = 1;
106 # TRUE if in verbose mode.
109 # This holds our (eventual) exit status. We don't actually exit until
110 # we have processed all input files.
113 # From the Perl manual.
114 my $symlink_exists = (eval 'symlink ("", "");', $@ eq '');
116 # TRUE if missing standard files should be installed.
119 # TRUE if we should copy missing files; otherwise symlink if possible.
120 my $copy_missing = 0;
122 # TRUE if we should always update files that we know about.
123 my $force_missing = 0;
125 # List of targets we must always output.
126 # FIXME: Complete, and remove falsely required targets.
127 my %required_targets =
134 # FIXME: Not required, temporary hack until install-data and install-exec
136 'install-data-am' => 1,
137 'install-exec-am' => 1,
142 # Variables filled during files scanning.
144 # Name of the top autoconf input: `configure.ac' or `configure.in'.
145 my $configure_ac = '';
147 # Files found by scanning configure.ac for LIBOBJS.
150 # True if AM_C_PROTOTYPES appears in configure.ac.
151 my $am_c_prototypes = 0;
153 # Names used in AC_CONFIG_HEADER call. @config_fullnames holds the
154 # name which appears in AC_CONFIG_HEADER, colon and all.
155 # @config_names holds the file names. @config_headers holds the '.in'
156 # files. Ordinarily these are similar, but they can be different if
157 # the weird "NAME:FILE" syntax is used.
158 my @config_fullnames = ();
159 my @config_names = ();
160 my @config_headers = ();
161 # Line number at which AC_CONFIG_HEADER appears in configure.ac.
162 my $config_header_line = 0;
164 # Directory where output files go. Actually, output files are
165 # relative to this directory.
166 my $output_directory = '.';
168 # List of Makefile.am's to process, and their corresponding outputs.
169 my @input_files = ();
170 my %output_files = ();
172 # Complete list of Makefile.am's that exist.
173 my @configure_input_files = ();
175 # List of files in AC_OUTPUT without Makefile.am, and their outputs.
176 my @other_input_files = ();
177 # Line number at which AC_OUTPUT seen.
178 my $ac_output_line = 0;
180 # List of directories to search for configure-required files. This
181 # can be set by AC_CONFIG_AUX_DIR.
182 my @config_aux_path = ('.', '..', '../..');
183 my $config_aux_dir = '';
185 # Whether AC_PROG_MAKE_SET has been seen in configure.ac.
186 my $seen_make_set = 0;
188 # Whether AM_GNU_GETTEXT has been seen in configure.ac.
189 my $seen_gettext = 0;
190 # Line number at which AM_GNU_GETTEXT seen.
191 my $ac_gettext_line = 0;
193 # Whether ALL_LINGUAS has been seen.
194 my $seen_linguas = '';
196 my $all_linguas = '';
197 # Line number at which it appears.
198 my $all_linguas_line = 0;
200 # 1 if AC_PROG_INSTALL seen.
201 my $seen_prog_install = 0;
203 # Whether AC_PATH_XTRA has been seen in configure.ac.
204 my $seen_path_xtra = 0;
206 # TRUE if AC_DECL_YYTEXT was seen.
207 my $seen_decl_yytext = 0;
209 # TRUE if we've seen AC_CANONICAL_(HOST|SYSTEM). The presence of
210 # AC_CHECK_TOOL also sets this.
211 my $seen_canonical = 0;
213 # TRUE if we've seen AC_ARG_PROGRAM.
214 my $seen_arg_prog = 0;
216 # TRUE if we've seen AC_PROG_LIBTOOL.
217 my $seen_libtool = 0;
218 my $libtool_line = 0;
220 # Files installed by libtoolize.
221 my @libtoolize_files = ('ltmain.sh', 'config.guess', 'config.sub');
222 # ltconfig appears here for compatibility with old versions of libtool.
223 my @libtoolize_sometimes = ('ltconfig', 'ltcf-c.sh', 'ltcf-cxx.sh',
226 # TRUE if we've seen AM_MAINTAINER_MODE.
227 my $seen_maint_mode = 0;
229 # Actual version we've seen.
230 my $package_version = '';
232 # Line number where we saw version definition.
233 my $package_version_line = 0;
235 # TRUE if we've seen AM_PATH_LISPDIR.
236 my $seen_lispdir = 0;
238 # TRUE if we've seen AM_CHECK_PYTHON.
239 my $seen_pythondir = 0;
241 # TRUE if we've seen AC_EXEEXT.
244 # TRUE if we've seen AC_OBJEXT.
247 # TRUE if we've seen AC_ENABLE_MULTILIB.
248 my $seen_multilib = 0;
250 # TRUE if we've seen AM_PROG_CC_C_O
253 # TRUE if we've seen AM_INIT_AUTOMAKE.
254 my $seen_init_automake = 0;
256 # Hash table of discovered configure substitutions. Keys are names,
257 # values are `FILE:LINE' strings which are used by error message
259 my %configure_vars = ();
261 # This is used to keep track of which variable definitions we are
262 # scanning. It is only used in certain limited ways, but it has to be
263 # global. It is declared just for documentation purposes.
264 my %vars_scanned = ();
266 # Charsets used by maintainer and in distribution. MAINT_CHARSET is
267 # handled in a funny way: if seen in the top-level Makefile.am, it is
268 # used for every directory which does not specify a different value.
269 # The rationale here is that some directories (eg gettext) might be
270 # distributions of other packages, and thus require their own charset
271 # info. However, the DIST_CHARSET must be the same for the entire
272 # package; it can only be set at top-level.
273 # FIXME: this yields bugs when rebuilding. What to do? Always
274 # read (and sometimes discard) top-level Makefile.am?
275 my $maint_charset = '';
276 my $dist_charset = 'utf8'; # recode doesn't support this yet.
278 # Name of input file ("Makefile.in") and output file ("Makefile.am").
279 # These have no directory components.
280 my $am_file_name = '';
281 my $in_file_name = '';
283 # TRUE if --cygnus seen.
286 # Hash table of AM_CONDITIONAL variables seen in configure.
287 my %configure_cond = ();
289 # Map from obsolete macros to hints for new macros.
290 # If you change this, change the corresponding list in aclocal.in.
291 # FIXME: should just put this into a single file.
292 my %obsolete_macros =
294 'AC_FEATURE_CTYPE', "use \`AC_HEADER_STDC'",
295 'AC_FEATURE_ERRNO', "add \`strerror' to \`AC_REPLACE_FUNCS(...)'",
296 'AC_FEATURE_EXIT', '',
297 'AC_SYSTEM_HEADER', '',
299 # Note that we do not handle this one, because it is still run
300 # from AM_CONFIG_HEADER. So we deal with it specially in
301 # &scan_autoconf_files.
302 # 'AC_CONFIG_HEADER', "use \`AM_CONFIG_HEADER'",
304 'fp_C_PROTOTYPES', "use \`AM_C_PROTOTYPES'",
305 'fp_PROG_CC_STDC', "use \`AM_PROG_CC_STDC'",
306 'fp_PROG_INSTALL', "use \`AC_PROG_INSTALL'",
307 'fp_WITH_DMALLOC', "use \`AM_WITH_DMALLOC'",
308 'fp_WITH_REGEX', "use \`AM_WITH_REGEX'",
309 'gm_PROG_LIBTOOL', "use \`AM_PROG_LIBTOOL'",
310 'jm_MAINTAINER_MODE', "use \`AM_MAINTAINER_MODE'",
311 'md_TYPE_PTRDIFF_T', "use \`AM_TYPE_PTRDIFF_T'",
312 'ud_PATH_LISPDIR', "use \`AM_PATH_LISPDIR'",
313 'ud_GNU_GETTEXT', "use \`AM_GNU_GETTEXT'",
315 # Now part of autoconf proper, under a different name.
316 'AM_FUNC_FNMATCH', "use \`AC_FUNC_FNMATCH'",
317 'fp_FUNC_FNMATCH', "use \`AC_FUNC_FNMATCH'",
318 'AM_SANITY_CHECK_CC', "automatically done by \`AC_PROG_CC'",
319 'AM_PROG_INSTALL', "use \`AC_PROG_INSTALL'",
320 'AM_EXEEXT', "use \`AC_EXEEXT'",
321 'AM_CYGWIN32', "use \`AC_CYGWIN'",
322 'AM_MINGW32', "use \`AC_MINGW32'",
323 'AM_FUNC_MKTIME', "use \`AC_FUNC_MKTIME'",
325 # These aren't quite obsolete.
329 # Regexp to match the above macros.
330 my $obsolete_rx = '(\b' . join ('\b|\b', keys %obsolete_macros) . '\b)';
332 # This maps extensions onto language names.
333 my %extension_map = ();
335 # This maps languages names onto properties.
336 my %language_map = ();
338 # This holds all the files that would go in `dist_common' which we
339 # discovered while scanning configure.ac. We might distribute these
340 # in the top-level Makefile.in.
341 my %configure_dist_common = ();
344 # Initialize global constants and our list of languages that are
345 # internally supported.
346 &initialize_global_constants;
348 ®ister_language ('c', 'ansi-p=1', 'autodep=', 'flags=CFLAGS',
349 'compile=$(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)',
350 'compiler-name=COMPILE',
353 ®ister_language ('cxx', 'linker=CXXLINK', 'autodep=CXX', 'flags=CXXFLAGS',
354 'compile=$(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)',
355 'compiler-name=CXXCOMPILE',
356 'output-arg=-c -o $@',
357 'c++', 'cc', 'cpp', 'cxx', 'C');
358 ®ister_language ('objc', 'linker=OBJCLINK', 'autodep=OBJC',
360 'compile=$(OBJC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_OBJCFLAGS) $(OBJCFLAGS)',
361 'compiler-name=OBJCCOMPILE',
362 'output-arg=-c -o $@',
364 ®ister_language ('header',
365 'h', 'H', 'hxx', 'h++', 'hh', 'hpp', 'inc');
367 # For now, yacc and lex can't be handled on a per-exe basis.
368 ®ister_language ('yacc', 'ansi-p=1', 'derived-autodep=yes',
370 ®ister_language ('yaccxx', 'linker=CXXLINK', 'derived-autodep=yes',
371 'y++', 'yy', 'yxx', 'ypp');
372 ®ister_language ('lex', 'ansi-p=1', 'derived-autodep=yes',
374 ®ister_language ('lexxx', 'linker=CXXLINK', 'derived-autodep=yes',
375 'l++', 'll', 'lxx', 'lpp');
377 ®ister_language ('asm',
378 'flags=CFLAGS', # FIXME: asmflags?
379 'compile=$(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)', # FIXME: a different compiler?
380 'compiler-name=COMPILE',
384 ®ister_language ('f77', 'linker=F77LINK', 'flags=FFLAGS',
385 'compile=$(F77) $(AM_FFLAGS) $(FFLAGS)',
386 'compiler-name=F77COMPILE',
387 'output-arg=-c -o $@',
389 ®ister_language ('ppf77', 'linker=F77LINK', 'flags=FFLAGS',
390 'compile=$(F77) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FFLAGS) $(FFLAGS)',
391 'compiler-name=PPF77COMPILE',
392 'output-arg=-c -o $@',
394 ®ister_language ('ratfor', 'linker=F77LINK',
395 'flags=RFLAGS', # FIXME also FFLAGS.
396 'compile=$(F77) $(AM_FFLAGS) $(FFLAGS) $(AM_RFLAGS) $(RFLAGS)',
397 'compiler-name=RCOMPILE',
398 'output-arg=-c -o $@',
400 # FIXME: for now we can't do dependency tracking for Java.
402 ®ister_language ('java', 'linker=GCJLINK', 'flags=GCJFLAGS',
403 'compile=$(GCJ) $(DEFS) $(INCLUDES) $(AM_GCJFLAGS) $(GCJFLAGS)',
404 'compiler-name=GCJCOMPILE',
405 'output-arg=-c -o $@',
406 'java', 'class', 'zip', 'jar');
409 # Parse command line.
410 &parse_arguments (@ARGV);
412 # Do configure.ac scan only once.
413 &scan_autoconf_files;
415 die "automake: no \`Makefile.am' found or specified\n"
418 # Now do all the work on each file.
419 foreach my $am_file (@input_files)
421 if (! -f ($am_file . '.am'))
423 &am_error ("\`" . $am_file . ".am' does not exist");
427 &generate_makefile ($output_files{$am_file}, $am_file);
431 &am_conf_error ("AC_PROG_INSTALL must be used")
432 if (! $seen_prog_install);
437 ################################################################
439 # prog_error (@PRINT-ME)
440 # ----------------------
441 # Signal a programming error, display PRINT-ME, and exit 1.
444 print STDERR "automake: programming error: @_\n";
452 # Return LIST with no duplicates.
457 foreach my $item (@_)
459 if (! defined $seen{$item})
469 ################################################################
474 # Return directory name of file.
480 ($sub = $file) =~ s,/+[^/]+$,,g;
481 $sub = '.' if $sub eq $file;
489 # Return file name of a file.
495 ($sub = $file) =~s,^.*/+,,g;
501 # &backname ($REL-DIR)
502 # --------------------
503 # If I `cd $REL-DIR', then to come back, I should `cd $BACKPATH'.
504 # For instance `src/foo' => `../..'.
505 # Works with non strictly increasing paths, i.e., `src/../lib' => `..'.
510 foreach (split (/\//, $file))
512 next if $_ eq '.' || $_ eq '';
522 return join ('/', @res) || '.';
525 ################################################################
527 # Parse command line.
533 &set_strictness ('gnu');
537 if ($arglist[0] eq "--version")
539 print "automake (GNU $PACKAGE) $VERSION\n\n";
540 print "Copyright 2000, 2001 Free Software Foundation, Inc.\n";
541 print "This is free software; see the source for copying conditions. There is NO\n";
542 print "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n";
543 print "Written by Tom Tromey <tromey\@cygnus.com>\n";
547 elsif ($arglist[0] eq "--help")
551 elsif ($arglist[0] =~ /^--amdir=(.+)$/)
555 elsif ($arglist[0] eq '--amdir')
557 &require_argument (@arglist);
559 $am_dir = $arglist[0];
561 elsif ($arglist[0] eq '--gnu')
563 &set_strictness ('gnu');
565 elsif ($arglist[0] eq '--gnits')
567 &set_strictness ('gnits');
569 elsif ($arglist[0] eq '--cygnus')
573 elsif ($arglist[0] eq '--foreign')
575 &set_strictness ('foreign');
577 elsif ($arglist[0] eq '--include-deps')
579 $cmdline_use_dependencies = 1;
581 elsif ($arglist[0] eq '--ignore-deps' || $arglist[0] eq '-i')
583 $cmdline_use_dependencies = 0;
585 elsif ($arglist[0] eq '--no-force')
587 $force_generation = 0;
589 elsif ($arglist[0] eq '--force-missing')
593 elsif ($arglist[0] =~ /^--output-dir=(.*)$/)
595 # Set output directory.
596 $output_directory = $1;
598 elsif ($arglist[0] eq '--output-dir' || $arglist[0] eq '-o')
600 &require_argument (@arglist);
602 $output_directory = $arglist[0];
604 elsif ($arglist[0] eq '--add-missing' || $arglist[0] eq '-a')
608 elsif ($arglist[0] eq '--copy' || $arglist[0] eq '-c')
612 elsif ($arglist[0] eq '--verbose' || $arglist[0] eq '-v')
616 elsif ($arglist[0] eq '--')
618 # Stop option processing.
620 push (@input_files, @arglist);
623 elsif ($arglist[0] =~ /^-/)
625 die "automake: unrecognized option -- \`$arglist[0]'\nTry \`automake --help' for more information.\n";
629 # Handle $local:$input syntax. Note that we only examine
630 # the first ":" file to see if it is automake input; the
631 # rest are just taken verbatim. We still keep all the
632 # files around for dependency checking, however.
633 my ($local, $input, @rest) = split (/:/, $arglist[0]);
640 # Strip .in; later on .am is tacked on. That is how
641 # the automake input file is found. Maybe not the
642 # best way, but it is easy to explain. FIXME: should
643 # be error if .in is missing.
646 push (@input_files, $input);
647 $output_files{$input} = join (':', ($local, @rest));
653 # Take global strictness from whatever we currently have set.
654 $default_strictness = $strictness;
655 $default_strictness_name = $strictness_name;
658 # Ensure argument exists, or die.
661 my ($arg, @arglist) = @_;
662 die "automake: no argument given for option \`$arg'\n"
666 ################################################################
668 # Generate a Makefile.in given the name of the corresponding Makefile and
669 # the name of the file output by config.status.
670 sub generate_makefile
672 my ($output, $makefile) = @_;
674 ($am_file_name = $makefile) =~ s/^.*\///;
675 $in_file_name = $am_file_name . '.in';
676 $am_file_name .= '.am';
678 # $OUTPUT is encoded. If it contains a ":" then the first element
679 # is the real output file, and all remaining elements are input
680 # files. We don't scan or otherwise deal with these input file,
681 # other than to mark them as dependencies. See
682 # &scan_autoconf_files for details.
683 my (@secondary_inputs);
684 ($output, @secondary_inputs) = split (/:/, $output);
686 &initialize_per_input;
687 $relative_dir = dirname ($output);
688 $am_relative_dir = dirname ($makefile);
690 # At the toplevel directory, we might need config.guess, config.sub
691 # or libtool scripts (ltconfig and ltmain.sh).
692 if ($relative_dir eq '.')
694 # libtool requires some files.
695 &require_conf_file_with_conf_line ($libtool_line, $FOREIGN,
699 # AC_CANONICAL_HOST and AC_CANONICAL_SYSTEM need config.guess and
701 &require_config_file ($FOREIGN, 'config.guess', 'config.sub')
705 # We still need Makefile.in here, because sometimes the `dist'
706 # target doesn't re-run automake.
707 if ($am_relative_dir eq $relative_dir)
709 # Only distribute the files if they are in the same subdir as
710 # the generated makefile.
711 &push_dist_common ($in_file_name, $am_file_name);
714 push (@sources, '$(SOURCES)')
715 if &variable_defined ('SOURCES');
716 push (@objects, '$(OBJECTS)')
717 if &variable_defined ('OBJECTS');
719 &read_main_am_file ($makefile . '.am');
722 # Fatal error. Just return, so we can continue with next file.
726 # Must do this after reading .am file. See read_main_am_file to
727 # understand weird tricks we play there with variables.
728 &define_variable ('subdir', $relative_dir);
730 # Check first, because we might modify some state.
732 &check_gnu_standards;
733 &check_gnits_standards;
735 &handle_configure ($output, $makefile, @secondary_inputs);
742 # This must be run after all the sources are scanned.
745 # Re-init SOURCES and OBJECTS. FIXME: other code shouldn't depend
746 # on this (but currently does).
747 $contents{'SOURCES'} = join (' ', @sources);
748 $contents{'OBJECTS'} = join (' ', @objects);
749 &define_pretty_variable ('DIST_SOURCES', '', @dist_sources);
761 &handle_minor_options;
762 &handle_dependencies;
765 # This must come after most other rules.
766 &handle_dist ($makefile);
769 &handle_merge_targets ($output);
772 &handle_factored_dependencies;
776 if (! -d ($output_directory . '/' . $am_relative_dir))
778 mkdir ($output_directory . '/' . $am_relative_dir, 0755);
781 my ($out_file) = $output_directory . '/' . $makefile . ".in";
782 if (! $force_generation && -e $out_file)
784 my ($am_time) = (stat ($makefile . '.am'))[9];
785 my ($in_time) = (stat ($out_file))[9];
786 # FIXME: should cache these times.
787 my ($conf_time) = (stat ($configure_ac))[9];
788 # FIXME: how to do unsigned comparison?
789 if ($am_time < $in_time || $am_time < $conf_time)
796 my ($acl_time) = (stat _)[9];
797 return if ($am_time < $acl_time);
801 my $gm_file = new IO::File "> $out_file";
804 warn "automake: ${am_file}.in: cannot write: $!\n";
808 print "automake: creating ", $makefile, ".in\n" if $verbose;
810 # In case we're running under MSWindows, don't write with CRLF
811 # (as it causes problems for the dependency-file extraction in
812 # AM_OUTPUT_DEPENDENCY_COMMANDS).
815 print $gm_file $output_vars;
816 # We make sure that `all:' is the first target.
817 print $gm_file $output_all;
818 print $gm_file $output_header;
819 print $gm_file $output_rules;
820 print $gm_file $output_trailer;
822 if (! $gm_file->close)
824 warn "automake: $am_file.in: cannot close: $!\n";
830 ################################################################
832 # Handle AUTOMAKE_OPTIONS variable. Return 1 on error, 0 otherwise.
835 if (&variable_defined ('AUTOMAKE_OPTIONS'))
837 foreach (&variable_value_as_list ('AUTOMAKE_OPTIONS', ''))
840 if ($_ eq 'gnits' || $_ eq 'gnu' || $_ eq 'foreign')
842 &set_strictness ($_);
844 elsif ($_ eq 'cygnus')
850 # An option like "../lib/ansi2knr" is allowed. With
851 # no path prefix, we assume the required programs are
852 # in this directory. We save the actual option for
854 $options{'ansi2knr'} = $_;
856 elsif ($_ eq 'no-installman' || $_ eq 'no-installinfo'
857 || $_ eq 'dist-shar' || $_ eq 'dist-zip'
858 || $_ eq 'dist-tarZ' || $_ eq 'dist-bzip2'
859 || $_ eq 'dejagnu' || $_ eq 'no-texinfo.tex'
860 || $_ eq 'readme-alpha' || $_ eq 'check-news'
861 || $_ eq 'subdir-objects' || $_ eq 'nostdinc')
863 # Explicitly recognize these.
865 elsif ($_ eq 'no-dependencies')
867 $use_dependencies = 0;
869 elsif (/([0-9]+)\.([0-9]+)([a-z])?/)
871 # Got a version number.
873 my ($rmajor, $rminor, $ralpha) = ($1, $2, $3);
875 &prog_error ("version is incorrect: $VERSION")
876 if $VERSION !~ /([0-9]+)\.([0-9]+)([a-z])?/;
878 my ($tmajor, $tminor, $talpha) = ($1, $2, $3);
880 # 2.0 is better than 1.0.
881 # 1.2 is better than 1.1.
882 # 1.2a is better than 1.2.
883 if ($rmajor > $tmajor
884 || ($rmajor == $tmajor && $rminor > $tminor)
885 || ($rminor == $tminor && $rminor == $tminor
886 && $ralpha gt $talpha))
888 &am_line_error ('AUTOMAKE_OPTIONS',
889 "require version $_, only have $VERSION");
895 &am_line_error ('AUTOMAKE_OPTIONS',
896 "option \`" . $_ . "\' not recognized");
901 if ($strictness == $GNITS)
903 $options{'readme-alpha'} = 1;
904 $options{'check-news'} = 1;
911 # get_object_extension ($OUT)
912 # ---------------------------
913 # Return object extension. Just once, put some code into the output.
914 # OUT is the name of the output file
915 sub get_object_extension
919 # Maybe require libtool library object files.
920 my $extension = '.o';
921 $extension = '.$(OBJEXT)' if $seen_objext;
922 $extension = '.lo' if ($out =~ /\.la$/);
924 if (! $included_generic_compile)
927 my $default_include = '';
928 if (! defined $options{'nostdinc'})
930 $default_include = ' -I. -I$(srcdir)';
932 if (&variable_defined ('CONFIG_HEADER'))
934 foreach my $hdr (split (' ', &variable_value ('CONFIG_HEADER')))
936 $default_include .= ' -I' . dirname ($hdr);
940 my $xform = &transform ('DEFAULT_INCLUDES' => $default_include);
941 $output_vars .= &file_contents ('comp-vars', $xform);
944 &file_contents ('compile',
945 &transform_cond ('OBJEXT' => $seen_objext));
947 # If using X, include some extra variable definitions. NOTE
948 # we don't want to force these into CFLAGS or anything,
949 # because not all programs will necessarily use X.
952 foreach my $var ('X_CFLAGS',
953 'X_LIBS', 'X_EXTRA_LIBS', 'X_PRE_LIBS')
955 &define_configure_variable ($var);
959 push (@suffixes, '.c', '.o');
960 push (@suffixes, '.obj') if $seen_objext;
962 $included_generic_compile = 1;
965 if ($seen_libtool && ! $included_libtool_compile)
967 # Output the libtool compilation rules.
968 $output_rules .= &file_contents ('libtool');
970 push (@suffixes, '.lo');
972 $included_libtool_compile = 1;
975 # Check for automatic de-ANSI-fication.
976 if (defined $options{'ansi2knr'})
978 $extension = '$U' . $extension;
979 if (! $included_knr_compile)
981 if (! $am_c_prototypes)
983 &am_line_error ('AUTOMAKE_OPTIONS',
984 "option \`ansi2knr' in use but \`AM_C_PROTOTYPES' not in \`$configure_ac'");
985 &keyed_aclocal_warning ('AM_C_PROTOTYPES');
986 # Only give this error once.
987 $am_c_prototypes = 1;
990 # Only require ansi2knr files if they should appear in
992 if ($options{'ansi2knr'} eq 'ansi2knr')
994 &require_file_with_line ('AUTOMAKE_OPTIONS', $FOREIGN,
995 'ansi2knr.c', 'ansi2knr.1');
996 $output_rules .= &file_contents ('kr-extra');
999 # Generate rules to build ansi2knr. If it is in some
1000 # other directory, then generate dependencies but have the
1001 # rule just run elsewhere.
1002 $objext = $seen_objext ? ".\$(OBJEXT)" : ".o";
1003 $output_rules .= ($options{'ansi2knr'} . ': '
1004 . $options{'ansi2knr'} . $objext . "\n");
1005 if ($options{'ansi2knr'} eq 'ansi2knr')
1007 $output_rules .= ("\t\$(LINK) ansi2knr" . $objext
1009 . "ansi2knr" . $objext
1010 . ": \$(CONFIG_HEADER)\n\n");
1014 $output_rules .= ("\tcd " . dirname ($options{'ansi2knr'})
1015 . " && \$(MAKE) \$(AM_MAKEFLAGS) "
1017 # This is required for non-GNU makes.
1018 $output_rules .= ($options{'ansi2knr'} . $objext . ":\n");
1019 $output_rules .= ("\tcd " . dirname ($options{'ansi2knr'})
1020 . " && \$(MAKE) \$(AM_MAKEFLAGS)"
1021 . " ansi2knr" . $objext . "\n\n");
1024 # Make sure ansi2knr can be found: if no path specified,
1026 if ($options{'ansi2knr'} eq 'ansi2knr')
1028 # Substitution from AM_C_PROTOTYPES. This makes it be
1029 # built only when necessary.
1030 &define_configure_variable ('ANSI2KNR');
1031 # ansi2knr needs to be built before subdirs, so unshift it.
1032 unshift (@all, '$(ANSI2KNR)');
1036 # Found in another directory.
1037 &define_variable ("ANSI2KNR", $options{'ansi2knr'});
1040 $output_rules .= &file_contents ('clean-kr');
1042 $included_knr_compile = 1;
1049 # Call finish function for each language that was used.
1050 sub finish_languages
1052 my ($ltcompile, $ltlink) = &libtool_compiler;
1056 foreach my $ext (sort keys %extension_seen)
1058 my $lang = $extension_map{$ext};
1060 # Generate the appropriate rules for this extension. If
1061 # dependency tracking was requested, and this extension
1062 # supports it, then we don't generate the rule here.
1065 if ($use_dependencies && $language_map{$lang . '-autodep'} ne 'no')
1067 # Don't generate the rule, but still generate the variables.
1068 if (defined $language_map{$lang . '-compile'})
1070 $comp = $language_map{$lang . '-compile'};
1073 elsif (defined $language_map{$lang . '-compile'})
1075 $comp = $language_map{$lang . '-compile'};
1077 my $outarg = $language_map{$lang . '-output-arg'};
1078 if ($language_map{$lang . '-flags'} eq 'CFLAGS')
1080 # C compilers don't always support -c -o.
1081 if (defined $options{'subdir-objects'})
1083 $outarg .= ' -o $@';
1088 . $language_map{$lang . '-compiler-name'}
1091 $output_rules .= (".$ext.o:\n"
1094 # FIXME: Using cygpath should be somehow conditional.
1095 $output_rules .= (".$ext.obj:\n"
1097 . " \`cygpath -w \$<\`\n")
1099 $output_rules .= (".$ext.lo:\n"
1101 . $language_map{$lang . '-compiler-name'}
1103 . $language_map{$lang . '-output-arg'}
1104 # We can always use -c -o with libtool.
1105 . ($language_map{$lang . '-flags'} eq 'CFLAGS'
1111 push (@suffixes, '.' . $ext);
1113 # The rest of the loop is done once per language.
1114 next if defined $done{$lang};
1117 $non_c = 0 if $lang !~ /(objc|cxx|f77|ratfor)$/;
1121 &define_compiler_variable ($language_map{$lang . '-compiler-name'},
1124 # The compiler's flag must be a configure variable.
1125 if (defined $language_map{$lang . '-flags'})
1127 &define_configure_variable ($language_map{$lang . '-flags'});
1130 # Compute the function name of the finisher and then call it.
1131 my $name = 'lang_' . $lang . '_finish';
1135 # If the project is entirely C++ or entirely Fortran 77, don't
1136 # bother with the C stuff. But if anything else creeps in, then use
1138 if ($need_link || ! $non_c || scalar keys %suffix_rules > 0)
1140 if (! defined $done{'c'})
1142 &define_configure_variable ($language_map{'c-flags'});
1143 &define_compiler_variable ($language_map{'c-compiler-name'},
1145 $language_map{'c-compile'});
1147 &define_variable ('CCLD', '$(CC)');
1148 &define_variable ('LINK',
1149 $ltlink . '$(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@');
1153 # Output a rule to build from a YACC source. The output from YACC is
1154 # compiled with C or C++, depending on the extension of the YACC file.
1155 sub output_yacc_build_rule
1157 my ($yacc_suffix, $use_ylwrap) = @_;
1159 my $c_suffix = $yacc_suffix;
1160 $c_suffix =~ tr/y/c/;
1161 push (@suffixes, $yacc_suffix, $c_suffix);
1163 # Generate rule for c/c++.
1164 $output_rules .= "$yacc_suffix$c_suffix:\n\t";
1168 $output_rules .= ('$(SHELL) $(YLWRAP)'
1169 . ' "$(YACC)" $< y.tab.c $*' . $c_suffix
1170 . ' y.tab.h $*.h -- $(AM_YFLAGS) $(YFLAGS)');
1174 $output_rules .= ('$(YACC) $(AM_YFLAGS) $(YFLAGS) $< && mv y.tab.c $*'
1176 . "\tif test -f y.tab.h; then \\\n"
1177 . "\tif cmp -s y.tab.h \$*.h; then rm -f y.tab.h; else mv y.tab.h \$*.h; fi; \\\n"
1180 $output_rules .= "\n";
1183 sub output_lex_build_rule
1185 my ($lex_suffix, $use_ylwrap) = @_;
1187 (my $c_suffix = $lex_suffix) =~ tr/l/c/;
1189 push (@suffixes, $lex_suffix);
1190 &define_configure_variable ('LEX_OUTPUT_ROOT');
1191 &define_configure_variable ('LEXLIB');
1192 $output_rules .= "$lex_suffix$c_suffix:\n\t";
1196 # Is the $@ correct here? If so, why not use it in the ylwrap
1197 # build rule for yacc above?
1198 $output_rules .= '$(SHELL) $(YLWRAP)'
1199 . ' "$(LEX)" $< $(LEX_OUTPUT_ROOT).c $@ -- $(AM_LFLAGS) $(LFLAGS)';
1203 $output_rules .= '$(LEX) $(AM_LFLAGS) $(LFLAGS) $< && mv $(LEX_OUTPUT_ROOT).c $@';
1205 $output_rules .= "\n";
1209 # Check to make sure a source defined in LIBOBJS is not explicitly
1210 # mentioned. This is a separate function (as opposed to being inlined
1211 # in handle_source_transform) because it isn't always appropriate to
1213 sub check_libobjs_sources
1215 my ($one_file, $unxformed) = @_;
1217 foreach my $prefix ('', 'EXTRA_', 'dist_', 'nodist_',
1218 'dist_EXTRA_', 'nodist_EXTRA_')
1221 if (&variable_defined ($prefix . $one_file . '_SOURCES'))
1223 @files = &variable_value_as_list (($prefix
1224 . $one_file . '_SOURCES'),
1227 elsif ($prefix eq '')
1229 @files = ($unxformed . '.c');
1236 foreach my $file (@files)
1238 if (defined $libsources{$file})
1240 &am_line_error ($prefix . $one_file . '_SOURCES',
1241 "automatically discovered file \`$file' should not be explicitly mentioned");
1248 # ($LINKER, @OBJECTS)
1249 # handle_single_transform_list ($VAR, $DERIVED, $OBJ, @FILES)
1250 # -----------------------------------------------------------
1251 # Does much of the actual work for handle_source_transform.
1253 # $DERIVED is the name of resulting executable or library
1254 # $OBJ is the object extension (e.g., `$U.lo')
1255 # @FILES is the list of source files to transform
1257 # $LINKER is name of linker to use (empty string for default linker)
1258 # @OBJECTS are names of objects
1259 sub handle_single_transform_list
1261 my ($var, $derived, $obj, @files) = @_;
1263 my $nonansi_obj = $obj;
1264 $nonansi_obj =~ s/\$U//g;
1265 my %linkers_used = ();
1267 # Turn sources into objects.
1270 # Configure substitutions in _SOURCES variables are errors.
1273 &am_line_error ($var, "$var includes configure substitution \`$_'");
1277 # If the source file is in a subdirectory then the `.o' is
1278 # put into the current directory.
1280 # Split file name into base and extension.
1281 my ($linker, $object);
1282 next if ! /^((.*)\/)?([^\/]*)\.(.*)$/;
1290 # We must generate a rule for the object if it requires
1295 $extension = &derive_suffix ($extension);
1296 $lang = $extension_map{$extension};
1299 &saw_extension ($extension);
1300 # Found the language, so see what it says.
1301 my $subr = 'lang_' . $lang . '_rewrite';
1302 # Note: computed subr call.
1303 my $r = & $subr ($directory, $base, $extension);
1304 # Skip this entry if we were asked not to process it.
1305 next if $r == $LANG_IGNORE;
1307 # Now extract linker and other info.
1308 $linker = $language_map{$lang . '-linker'};
1311 if ($language_map{$lang . '-ansi-p'})
1313 $object = $base . $obj;
1314 $this_obj_ext = $obj;
1318 $object = $base . $nonansi_obj;
1319 $this_obj_ext = $nonansi_obj;
1322 if ($language_map{$lang . '-flags'} ne ''
1323 && &variable_defined ($derived . '_'
1324 . $language_map{$lang . '-flags'}))
1326 # We have a per-executable flag in effect for this
1327 # object. In this case we rewrite the object's
1328 # name to ensure it is unique. We also require
1329 # the `compile' program to deal with compilers
1330 # where `-c -o' does not work.
1332 # We choose the name `DERIVED-OBJECT' to ensure
1333 # (1) uniqueness, and (2) continuity between
1334 # invocations. However, this will result in a
1335 # name that is too long for losing systems, in
1336 # some situations. So we provide _SHORTNAME to
1339 my $dname = $derived;
1340 if (&variable_defined ($derived . '_SHORTNAME'))
1342 # FIXME: should use the same conditional as
1343 # the _SOURCES variable. But this is really
1344 # silly overkill -- nobody should have
1345 # conditional shortnames.
1346 $dname = &variable_value ($derived . '_SHORTNAME');
1348 $object = $dname . '-' . $object;
1350 &require_file ($FOREIGN, 'compile')
1353 &prog_error ("$lang flags defined without compiler")
1354 if ! defined $language_map{$lang . '-compile'};
1356 # Compute the rule to compile this object.
1357 my $flag = $language_map{$lang . '-flags'};
1358 my $val = "(${derived}_${flag}";
1359 ($rule = $language_map{$lang . '-compile'}) =~
1362 $rule .= ' ' . $language_map{$lang . '-output-arg'};
1363 # For C we have to add the -o, because the
1364 # standard rule doesn't include it.
1365 if ($language_map{$lang . '-flags'} eq 'CFLAGS')
1373 # If rewrite said it was ok, put the object into a
1375 if ($r == $LANG_SUBDIR && $directory ne '')
1377 $object = $directory . '/' . $object;
1378 $xbase = $directory . '/' . $base;
1381 # If doing dependency tracking, then we can't print
1382 # the rule. If we have a subdir object, we need to
1383 # generate an explicit rule. Actually, in any case
1384 # where the object is not in `.' we need a special
1385 # rule. The per-object rules in this case are
1386 # generated later, by add_depend2.
1387 if (($use_dependencies
1389 && $language_map{$lang . '-autodep'} ne 'no')
1390 || $directory ne '')
1393 my $obj_sans_ext = substr ($object, 0,
1394 - length ($this_obj_ext));
1395 $lang_specific_files{$lang} .= (' ' . $derived
1397 . ' ' . $obj_sans_ext);
1400 elsif ($extension eq 'o')
1402 # This is probably the result of a direct suffix rule.
1403 # In this case we just accept the rewrite. FIXME:
1404 # this fails if we want libtool objects.
1405 $object = $base . '.' . $extension;
1410 # No error message here. Used to have one, but it was
1415 $linkers_used{$linker} = 1;
1417 push (@result, $object);
1419 if (defined $object_map{$object})
1421 if ($object_map{$object} ne $full)
1423 &am_error ("object \`$object' created by \`$full' and \`$object_map{$object}'");
1429 $object_map{$object} = $full;
1431 # If file is in subdirectory, we need explicit
1433 if ($directory ne '' || $renamed)
1435 push (@dep_list, $full);
1438 # If resulting object is in subdir, we need to make
1439 # sure the subdir exists at build time.
1440 if ($object =~ /\//)
1442 # FIXME: check that $DIRECTORY is somewhere in the
1445 # We don't allow `..' in object file names for
1446 # *any* source, not just Java. For Java it just
1447 # doesn't make sense, but in general it is
1448 # a problem because we can't pick a good name for
1450 if ($object =~ /(\/|^)\.\.\//)
1452 &am_error ("\`$full' contains \`..' component but should not");
1455 push (@dep_list, $directory . '/.dirstamp');
1457 # If we're generating dependencies, we also want
1458 # to make sure that the appropriate subdir of the
1459 # .deps directory is created.
1460 if ($use_dependencies)
1462 push (@dep_list, '.deps/' . $directory . '/.dirstamp');
1465 if (! defined $directory_map{$directory})
1467 $directory_map{$directory} = 1;
1468 $output_rules .= ($directory . "/.dirstamp:\n"
1469 . "\t\@\$(mkinstalldirs) $directory\n"
1470 . "\t\@: > $directory/.dirstamp\n");
1471 if ($use_dependencies)
1473 $output_rules .= ('.deps/' . $directory
1475 . "\t\@\$(mkinstalldirs) .deps/$directory\n"
1476 . "\t\@: > .deps/$directory/.dirstamp\n");
1481 &pretty_print_rule ($object . ':', "\t", @dep_list)
1482 if scalar @dep_list > 0 || $rule ne '';
1484 # Print the rule if we have one.
1487 # Turn `$@' into name of our object file.
1488 my $xform = $object;
1489 $xform =~ s,/,\\/,g;
1490 $rule =~ s/\$\@/$xform/;
1492 # We cannot use $< here since this is an explicit
1493 # rule and not all makes handle that.
1494 $rule .= " \`test -f $full || echo '\$(srcdir)/'\`$full";
1496 # FIXME: handle .lo and .obj as well.
1497 $output_rules .= "\t" . $rule . "\n";
1501 # Transform .o or $o file into .P file (for automatic
1504 && ($language_map{$lang . '-autodep'} ne 'no'
1505 || $language_map{$lang . '-derived-autodep'} eq 'yes'))
1507 my $depfile = $object;
1508 $depfile =~ s/\.([^.]*)$/.P$1/;
1509 $depfile =~ s/\$\(OBJEXT\)$/o/ if $seen_objext;
1510 $dep_files{'$(DEPDIR)/' . $depfile} = 1;
1514 return (&resolve_linker (%linkers_used), @result);
1519 # Handle SOURCE->OBJECT transform for one program or library.
1521 # canonical (transformed) name of object to build
1522 # actual name of object to build
1523 # object extension (ie either `.o' or `$o'.
1524 # Return result is name of linker variable that must be used.
1525 # Empty return means just use `LINK'.
1526 sub handle_source_transform
1528 # one_file is canonical name. unxformed is given name. obj is
1530 my ($one_file, $unxformed, $obj) = @_;
1534 if (&variable_defined ($one_file . "_OBJECTS"))
1536 &am_line_error ($one_file . '_OBJECTS',
1537 $one_file . '_OBJECTS', 'should not be defined');
1538 # No point in continuing.
1542 my (@files, @result, $temp);
1544 foreach my $prefix ('', 'EXTRA_', 'dist_', 'nodist_',
1545 'dist_EXTRA_', 'nodist_EXTRA_')
1547 # We are going to define _OBJECTS variables using the prefix.
1548 # Then we glom them all together. So we can't use the null
1549 # prefix here as we need it later.
1550 my $xpfx = ($prefix eq '') ? 'am_' : $prefix;
1553 my $var = $prefix . $one_file . "_SOURCES";
1554 if (&variable_defined ($var))
1556 # Keep track of which prefixes we saw.
1557 $used_pfx{$xpfx} = 1
1558 unless $prefix =~ /EXTRA_/;
1560 push (@sources, '$(' . $prefix . $one_file . "_SOURCES)");
1561 push (@objects, '$(' . $xpfx . $one_file . "_OBJECTS)")
1562 unless $prefix =~ /EXTRA_/;
1563 push (@dist_sources, '$(' . $prefix . $one_file . "_SOURCES)")
1564 unless $prefix =~ /^nodist_/;
1565 my @conds = &variable_conditions ($var);
1568 @files = &variable_value_as_list ($var, '');
1572 foreach my $cond (@conds)
1574 @files = &variable_value_as_list ($var, $cond);
1576 &handle_single_transform_list ($var, $one_file, $obj,
1578 $linker = $temp if $linker eq '';
1580 # Define _OBJECTS conditionally.
1581 &define_pretty_variable ($xpfx . $one_file . '_OBJECTS',
1583 unless $prefix =~ /EXTRA_/;
1590 # Avoid defining needless variables.
1591 next if (scalar @files == 0);
1593 ($temp, @result) = &handle_single_transform_list ($var, $one_file,
1595 $linker = $temp if $linker eq '';
1596 &define_pretty_variable ($xpfx . $one_file . "_OBJECTS", '', @result)
1597 unless $prefix =~ /EXTRA_/;
1600 my @keys = sort keys %used_pfx;
1601 if (scalar @keys == 0)
1603 &define_variable ($one_file . "_SOURCES", $unxformed . ".c");
1604 push (@sources, $unxformed . '.c');
1605 push (@dist_sources, $unxformed . '.c');
1606 push (@objects, $unxformed . $obj);
1607 push (@files, $unxformed . '.c');
1609 ($temp, @result) = &handle_single_transform_list ($one_file . '_SOURCES',
1612 $linker = $temp if $linker eq '';
1613 &define_pretty_variable ($one_file . "_OBJECTS", '', @result)
1617 grep ($_ = '$(' . $_ . $one_file . '_OBJECTS)', @keys);
1618 &define_pretty_variable ($one_file . '_OBJECTS', '', @keys);
1621 # If we want to use `LINK' we must make sure it is defined.
1631 # handle_lib_objects ()
1632 # ---------------------
1633 # Special-case @ALLOCA@ and @LIBOBJS@ in _LDADD or _LIBADD variables.
1634 # Also, generate _DEPENDENCIES variable if appropriate.
1636 # transformed name of object being built, or empty string if no object
1637 # name of _LDADD/_LIBADD-type variable to examine
1638 # boolean (lex_seen) which is true if a lex source file was seen in this
1639 # object. valid only for LDADDs, not LIBADDs.
1640 # Returns 1 if LIBOBJS seen, 0 otherwise.
1641 sub handle_lib_objects
1643 my ($xname, $var, $lex_seen) = @_;
1646 &prog_error ("handle_lib_objects: $var undefined")
1647 if ! &variable_defined ($var);
1649 &prog_error ("handle_lib_objects: lex_seen and $var =~ /LIBADD/")
1650 if $lex_seen && $var =~ /LIBADD/;
1652 my @conds = &variable_conditions ($var);
1655 $ret = &handle_lib_objects_cond ($xname, $var, $lex_seen, '');
1660 foreach my $cond (@conds)
1662 if (&handle_lib_objects_cond ($xname, $var, $lex_seen, $cond))
1672 # Subroutine of handle_lib_objects: handle a particular condition.
1673 sub handle_lib_objects_cond
1675 my ($xname, $var, $lex_seen, $cond) = @_;
1677 # We recognize certain things that are commonly put in LIBADD or
1681 my $seen_libobjs = 0;
1684 foreach my $lsearch (&variable_value_as_list ($var, $cond))
1686 # Skip -lfoo and -Ldir; these are explicitly allowed.
1687 next if $lsearch =~ /^-[lL]/;
1688 if (! $flagvar && $lsearch =~ /^-/)
1690 if ($var =~ /^(.*)LDADD$/)
1692 # Skip -dlopen and -dlpreopen; these are explicitly allowed.
1693 next if $lsearch =~ /^-dl(pre)?open$/;
1694 &am_line_error ($var, "linker flags such as \`$lsearch' belong in \`${1}LDFLAGS");
1698 # Only get this error once.
1700 &am_line_error ($var, "linker flags such as \`$lsearch' belong in \`${1}LDFLAGS");
1704 # Assume we have a file of some sort, and push it onto the
1705 # dependency list. Autoconf substitutions are not pushed;
1706 # rarely is a new dependency substituted into (eg) foo_LDADD
1707 # -- but "bad things (eg -lX11) are routinely substituted.
1708 # Note that LIBOBJS and ALLOCA are exceptions to this rule,
1709 # and handled specially below.
1710 push (@dep_list, $lsearch)
1711 unless $lsearch =~ /^\@.*\@$/;
1713 # Automatically handle @LIBOBJS@ and @ALLOCA@. Basically this
1714 # means adding entries to dep_files.
1715 if ($lsearch =~ /^\@(LT)?LIBOBJS\@$/)
1717 my $myobjext = ($1 ? 'l' : '') . 'o';
1719 push (@dep_list, $lsearch);
1721 if (! keys %libsources
1722 && ! &variable_defined ($1 . 'LIBOBJS'))
1724 &am_line_error ($var, "\@$1" . "LIBOBJS\@ seen but never set in \`$configure_ac'");
1727 foreach my $iter (keys %libsources)
1729 if ($iter =~ /\.([cly])$/)
1731 &saw_extension ($1);
1732 &saw_extension ('c');
1735 if ($iter =~ /\.h$/)
1737 &require_file_with_line ($var, $FOREIGN, $iter);
1739 elsif ($iter ne 'alloca.c')
1741 my $rewrite = $iter;
1742 $rewrite =~ s/\.c$/.P$myobjext/;
1743 $dep_files{'$(DEPDIR)/' . $rewrite} = 1;
1744 ($rewrite = $iter) =~ s/(\W)/\\$1/g;
1745 $rewrite = "^" . $rewrite . "\$";
1746 # Only require the file if it is not a built source.
1747 if (! &variable_defined ('BUILT_SOURCES')
1748 || ! grep (/$rewrite/,
1749 &variable_value_as_list ('BUILT_SOURCES',
1752 &require_file_with_line ($var, $FOREIGN, $iter);
1757 elsif ($lsearch =~ /^\@(LT)?ALLOCA\@$/)
1759 my $myobjext = ($1 ? 'l' : '') . 'o';
1761 push (@dep_list, $lsearch);
1762 &am_line_error ($var,
1763 "\@$1" . "ALLOCA\@ seen but \`AC_FUNC_ALLOCA' not in \`$configure_ac'")
1764 if ! defined $libsources{'alloca.c'};
1765 $dep_files{'$(DEPDIR)/alloca.P' . $myobjext} = 1;
1766 &require_file_with_line ($var, $FOREIGN, 'alloca.c');
1767 &saw_extension ('c');
1771 if ($xname ne '' && ! &variable_defined ($xname . '_DEPENDENCIES', $cond))
1773 &define_pretty_variable ($xname . '_DEPENDENCIES', $cond, @dep_list);
1776 return $seen_libobjs;
1779 # Canonicalize the input parameter
1783 $string =~ tr/A-Za-z0-9_\@/_/c;
1787 # Canonicalize a name, and check to make sure the non-canonical name
1788 # is never used. Returns canonical name. Arguments are name and a
1789 # list of suffixes to check for.
1790 sub check_canonical_spelling
1792 my ($name, @suffixes) = @_;
1794 my $xname = &canonicalize ($name);
1795 if ($xname ne $name)
1797 foreach my $xt (@suffixes)
1799 &am_line_error ($name . $xt,
1800 "invalid variable \`" . $name . $xt
1801 . "'; should be \`" . $xname . $xt . "'")
1802 if &variable_defined ($name . $xt);
1810 # handle_programs ()
1811 # ------------------
1812 # Handle C programs.
1815 my @proglist = &am_install_var ('-clean',
1816 'progs', 'PROGRAMS',
1817 'bin', 'sbin', 'libexec', 'pkglib',
1819 return if ! @proglist;
1821 # If a program is installed, this is required. We only want this
1822 # error to appear once.
1823 &am_conf_error ("AC_ARG_PROGRAM must be used")
1824 unless $seen_arg_prog;
1827 my $seen_libobjs = 0;
1828 foreach my $one_file (@proglist)
1830 my $obj = &get_object_extension ($one_file);
1832 # Canonicalize names and check for misspellings.
1833 my $xname = &check_canonical_spelling ($one_file, '_LDADD', '_LDFLAGS',
1834 '_SOURCES', '_OBJECTS',
1837 # FIXME: Using a trick to figure out if any lex sources appear
1838 # in our program; should use some cleaner method.
1839 my $lex_num = scalar (keys %lex_sources);
1840 my $linker = &handle_source_transform ($xname, $one_file, $obj);
1841 my $lex_file_seen = (scalar (keys %lex_sources) > $lex_num);
1844 if (&variable_defined ($xname . "_LDADD"))
1846 if (&handle_lib_objects ($xname, $xname . '_LDADD',
1856 # User didn't define prog_LDADD override. So do it.
1857 &define_variable ($xname . '_LDADD', '$(LDADD)');
1859 # This does a bit too much work. But we need it to
1860 # generate _DEPENDENCIES when appropriate.
1861 if (&variable_defined ('LDADD'))
1863 if (&handle_lib_objects ($xname, 'LDADD', $lex_file_seen))
1869 elsif (! &variable_defined ($xname . '_DEPENDENCIES'))
1871 &define_variable ($xname . '_DEPENDENCIES', '');
1876 if (&variable_defined ($xname . '_LIBADD'))
1878 &am_line_error ($xname . '_LIBADD',
1879 "use \`" . $xname . "_LDADD', not \`"
1880 . $xname . "_LIBADD'");
1883 if (! &variable_defined ($xname . '_LDFLAGS'))
1885 # Define the prog_LDFLAGS variable.
1886 &define_variable ($xname . '_LDFLAGS', '');
1889 # Determine program to use for link.
1891 if (&variable_defined ($xname . '_LINK'))
1893 $xlink = $xname . '_LINK';
1897 $xlink = $linker ? $linker : 'LINK';
1901 if ($seen_exeext && $one_file !~ /\./)
1903 $exeext = '$(EXEEXT)';
1906 $output_rules .= &file_contents ('program',
1907 &transform ('EXEEXT' => $exeext,
1908 'PROGRAM' => $one_file,
1909 'XPROGRAM' => $xname,
1910 'XLINK' => $xlink));
1913 if (&variable_defined ('LDADD') && &handle_lib_objects ('', 'LDADD', 0))
1920 foreach my $one_file (@proglist)
1922 my $xname = &canonicalize ($one_file);
1924 if (&variable_defined ($xname . '_LDADD'))
1926 &check_libobjs_sources ($xname, $xname . '_LDADD');
1928 elsif (&variable_defined ('LDADD'))
1930 &check_libobjs_sources ($xname, 'LDADD');
1937 # handle_libraries ()
1938 # -------------------
1940 sub handle_libraries
1942 my @liblist = &am_install_var ('-clean',
1943 'libs', 'LIBRARIES',
1944 'lib', 'pkglib', 'noinst', 'check');
1945 return if ! @liblist;
1947 my %valid = &am_primary_prefixes ('LIBRARIES', 0, 'lib', 'pkglib',
1949 if (! defined $configure_vars{'RANLIB'})
1951 foreach my $key (keys %valid)
1953 if (&variable_defined ($key . '_LIBRARIES'))
1955 &am_line_error ($key . '_LIBRARIES', "library used but \`RANLIB' not defined in \`$configure_ac'");
1956 # Only get this error once. If this is ever printed,
1958 $configure_vars{'RANLIB'} = 'BUG';
1964 my $seen_libobjs = 0;
1965 foreach my $onelib (@liblist)
1967 # Check that the library fits the standard naming convention.
1968 if ($onelib !~ /^lib.*\.a$/)
1970 # FIXME should put line number here. That means mapping
1971 # from library name back to variable name.
1972 &am_error ("\`$onelib' is not a standard library name");
1975 my $obj = &get_object_extension ($onelib);
1977 # Canonicalize names and check for misspellings.
1978 my $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_SOURCES',
1979 '_OBJECTS', '_DEPENDENCIES',
1982 if (! &variable_defined ($xlib . '_AR'))
1984 &define_variable ($xlib . '_AR', '$(AR) cru');
1987 if (&variable_defined ($xlib . '_LIBADD'))
1989 if (&handle_lib_objects ($xlib, $xlib . '_LIBADD', 0))
1996 # Generate support for conditional object inclusion in
1998 &define_variable ($xlib . "_LIBADD", '');
2001 if (&variable_defined ($xlib . '_LDADD'))
2003 &am_line_error ($xlib . '_LDADD',
2004 "use \`" . $xlib . "_LIBADD', not \`"
2005 . $xlib . "_LDADD'");
2008 # Make sure we at look at this.
2009 &examine_variable ($xlib . '_DEPENDENCIES');
2011 &handle_source_transform ($xlib, $onelib, $obj);
2013 $output_rules .= &file_contents ('library',
2014 &transform ('LIBRARY' => $onelib,
2015 'XLIBRARY' => $xlib));
2020 foreach my $onelib (@liblist)
2022 my $xlib = &canonicalize ($onelib);
2023 if (&variable_defined ($xlib . '_LIBADD'))
2025 &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
2030 &define_variable ('AR', 'ar');
2031 &define_configure_variable ('RANLIB');
2035 # handle_ltlibraries ()
2036 # ---------------------
2037 # Handle shared libraries.
2038 sub handle_ltlibraries
2040 my @liblist = &am_install_var ('-clean',
2041 'ltlib', 'LTLIBRARIES',
2042 'noinst', 'lib', 'pkglib', 'check');
2043 return if ! @liblist;
2046 my %valid = &am_primary_prefixes ('LTLIBRARIES', 0, 'lib', 'pkglib',
2049 foreach my $key (keys %valid)
2051 if (&variable_defined ($key . '_LTLIBRARIES'))
2055 &am_line_error ($key . '_LTLIBRARIES', "library used but \`LIBTOOL' not defined in \`$configure_ac'");
2056 # Only get this error once. If this is ever printed,
2058 $configure_vars{'LIBTOOL'} = 'BUG';
2062 # Get the installation directory of each library.
2063 for (&variable_value_as_list ($key . '_LTLIBRARIES', 'all'))
2067 &am_error ("\`$_' is already going to be installed in \`$instdirs{$_}'");
2071 $instdirs{$_} = $key;
2077 my $seen_libobjs = 0;
2078 foreach my $onelib (@liblist)
2080 my $obj = &get_object_extension ($onelib);
2082 # Canonicalize names and check for misspellings.
2083 my $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_LDFLAGS',
2084 '_SOURCES', '_OBJECTS',
2087 if (! &variable_defined ($xlib . '_LDFLAGS'))
2089 # Define the lib_LDFLAGS variable.
2090 &define_variable ($xlib . '_LDFLAGS', '');
2093 # Check that the library fits the standard naming convention.
2094 $libname_rx = "^lib.*\.la";
2095 if ((&variable_defined ($xlib . '_LDFLAGS')
2096 && grep (/-module/, &variable_value_as_list ($xlib . '_LDFLAGS',
2098 || (&variable_defined ('LDFLAGS')
2099 && grep (/-module/, &variable_value_as_list ('LDFLAGS',
2102 # Relax name checking for libtool modules.
2103 $libname_rx = "\.la";
2105 if ($onelib !~ /$libname_rx$/)
2107 # FIXME this should only be a warning for foreign packages
2108 # FIXME should put line number here. That means mapping
2109 # from library name back to variable name.
2110 &am_error ("\`$onelib' is not a standard libtool library name");
2113 if (&variable_defined ($xlib . '_LIBADD'))
2115 if (&handle_lib_objects ($xlib, $xlib . '_LIBADD', 0))
2122 # Generate support for conditional object inclusion in
2124 &define_variable ($xlib . "_LIBADD", '');
2127 if (&variable_defined ($xlib . '_LDADD'))
2129 &am_line_error ($xlib . '_LDADD',
2130 "use \`" . $xlib . "_LIBADD', not \`"
2131 . $xlib . "_LDADD'");
2134 # Make sure we at look at this.
2135 &examine_variable ($xlib . '_DEPENDENCIES');
2137 my $linker = &handle_source_transform ($xlib, $onelib, $obj);
2139 # Determine program to use for link.
2141 if (&variable_defined ($xlib . '_LINK'))
2143 $xlink = $xlib . '_LINK';
2147 $xlink = $linker ? $linker : 'LINK';
2151 if ($instdirs{$onelib} eq 'EXTRA'
2152 || $instdirs{$onelib} eq 'noinst'
2153 || $instdirs{$onelib} eq 'check')
2155 # It's an EXTRA_ library, so we can't specify -rpath,
2156 # because we don't know where the library will end up.
2157 # The user probably knows, but generally speaking automake
2158 # doesn't -- and in fact configure could decide
2159 # dynamically between two different locations.
2164 $rpath = ('-rpath $(' . $instdirs{$onelib} . 'dir)');
2167 $output_rules .= &file_contents ('ltlibrary',
2168 &transform ('LTLIBRARY' => $onelib,
2169 'XLTLIBRARY' => $xlib,
2171 'XLINK' => $xlink));
2176 foreach my $onelib (@liblist)
2178 my $xlib = &canonicalize ($onelib);
2179 if (&variable_defined ($xlib . '_LIBADD'))
2181 &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
2187 # See if any _SOURCES variable were misspelled. Also, make sure that
2188 # EXTRA_ variables don't contain configure substitutions.
2191 foreach my $varname (keys %contents)
2193 foreach my $primary ('_SOURCES', '_LIBADD', '_LDADD', '_LDFLAGS',
2196 if ($varname =~ /$primary$/ && ! $content_seen{$varname})
2198 &am_line_error ($varname,
2199 "invalid unused variable name: \`$varname'");
2208 # NOTE we no longer automatically clean SCRIPTS, because it is
2209 # useful to sometimes distribute scripts verbatim. This happens
2210 # eg in Automake itself.
2211 &am_install_var ('-candist', 'scripts', 'SCRIPTS',
2212 'bin', 'sbin', 'libexec', 'pkgdata',
2215 my $scripts_installed = 0;
2216 # Set $scripts_installed if appropriate. Make sure we only find
2217 # scripts which are actually installed -- this is why we can't
2218 # simply use the return value of am_install_var.
2219 my %valid = &am_primary_prefixes ('SCRIPTS', 1, 'bin', 'sbin',
2220 'libexec', 'pkgdata',
2222 foreach my $key (keys %valid)
2224 if ($key ne 'noinst'
2226 && &variable_defined ($key . '_SCRIPTS'))
2228 $scripts_installed = 1;
2229 # push (@check_tests, 'check-' . $key . 'SCRIPTS');
2233 if ($scripts_installed)
2235 # If a program is installed, this is required. We only want this
2236 # error to appear once.
2237 &am_conf_error ("AC_ARG_PROGRAM must be used")
2238 unless $seen_arg_prog;
2243 # Search a file for a "version.texi" Texinfo include. Return the name
2244 # of the include file if found, or the empty string if not. A
2245 # "version.texi" file is actually any file whose name matches
2247 sub scan_texinfo_file
2249 my ($filename) = @_;
2251 my $texi = new IO::File ("< $filename");
2254 &am_error ("couldn't open \`$filename': $!");
2257 print "automake: reading $filename\n" if $verbose;
2259 my ($outfile, $vfile);
2260 while ($_ = $texi->getline)
2262 if (/^\@setfilename +(\S+)/)
2268 if (/^\@include\s+(vers[^.]*\.texi)\s*$/)
2270 # Found version.texi include.
2277 return ($outfile, $vfile);
2283 # Handle all Texinfo source.
2286 &am_line_error ('TEXINFOS',
2287 "\`TEXINFOS' is an anachronism; use \`info_TEXINFOS'")
2288 if &variable_defined ('TEXINFOS');
2289 return if (! &variable_defined ('info_TEXINFOS')
2290 && ! &variable_defined ('html_TEXINFOS'));
2292 if (&variable_defined ('html_TEXINFOS'))
2294 &am_line_error ('html_TEXINFOS',
2295 "HTML generation not yet supported");
2299 my @texis = &variable_value_as_list ('info_TEXINFOS', 'all');
2301 my (@info_deps_list, @dvis_list, @texi_deps);
2308 foreach my $info_cursor (@texis)
2310 my $infobase = $info_cursor;
2311 $infobase =~ s/\.(txi|texinfo|texi)$//;
2313 if ($infobase eq $info_cursor)
2315 # FIXME: report line number.
2316 &am_error ("texinfo file \`$info_cursor' has unrecognized extension");
2319 $texi_suffixes{$1} = 1;
2321 # If 'version.texi' is referenced by input file, then include
2322 # automatic versioning capability.
2323 my ($out_file, $vtexi) = &scan_texinfo_file ($relative_dir
2324 . "/" . $info_cursor);
2326 if ($out_file eq '')
2328 &am_error ("\`$info_cursor' missing \@setfilename");
2332 if ($out_file =~ /\.(.+)$/ && $1 ne 'info')
2334 # FIXME should report line number in input file.
2335 &am_error ("output of \`$info_cursor', \`$out_file', has unrecognized extension");
2341 &am_error ("\`$vtexi', included in \`$info_cursor', also included in \`$versions{$vtexi}'")
2342 if (defined $versions{$vtexi});
2343 $versions{$vtexi} = $info_cursor;
2345 # We number the stamp-vti files. This is doable since the
2346 # actual names don't matter much. We only number starting
2347 # with the second one, so that the common case looks nice.
2348 my $vti = ($done ? $done : 'vti');
2351 &push_dist_common ($vtexi, 'stamp-' . $vti);
2353 &require_conf_file_with_line ('info_TEXINFOS', $FOREIGN,
2357 if ($config_aux_dir eq '.' || $config_aux_dir eq '')
2359 $conf_dir = '$(srcdir)/';
2363 $conf_dir = $config_aux_dir;
2364 $conf_dir .= '/' unless $conf_dir =~ /\/$/;
2367 &file_contents ('texi-vers',
2368 &transform ('TEXI' => $info_cursor,
2371 'MDDIR' => $conf_dir,
2372 'CONFIGURE_AC' => $configure_ac));
2375 # If user specified file_TEXINFOS, then use that as explicit
2378 push (@texi_deps, $info_cursor);
2379 # Prefix with $(srcdir) because some version of make won't
2380 # work if the target has it and the dependency doesn't.
2381 push (@texi_deps, '$(srcdir)/' . $vtexi) if $vtexi;
2383 my $canonical = &canonicalize ($infobase);
2384 if (&variable_defined ($canonical . "_TEXINFOS"))
2386 push (@texi_deps, '$(' . $canonical . '_TEXINFOS)');
2387 &push_dist_common ('$(' . $canonical . '_TEXINFOS)');
2390 $output_rules .= ("\n" . $out_file . ": "
2391 . join (' ', @texi_deps)
2392 . "\n" . $infobase . ".dvi: "
2393 . join (' ', @texi_deps)
2396 push (@info_deps_list, $out_file);
2397 push (@dvis_list, $infobase . '.dvi');
2399 # Generate list of things to clean for this target. We do
2400 # this explicitly because otherwise too many things could be
2401 # removed. In particular the ".log" extension might
2402 # reasonably be used in other contexts by the user.
2403 # FIXME: this is really out of control.
2404 foreach my $tc_cursor ('aux', 'cp', 'cps', 'dvi', 'fn', 'fns', 'pgs',
2405 'ky', 'kys', 'ps', 'log', 'pg', 'toc', 'tp',
2406 'tps', 'vr', 'vrs', 'op', 'tr', 'cv', 'cn',
2409 push (@texi_cleans, $infobase . '.' . $tc_cursor);
2413 # Find these programs wherever they may lie. Yes, this has
2414 # intimate knowledge of the structure of the texinfo distribution.
2415 &define_program_variable ('MAKEINFO', 'build', 'texinfo/makeinfo',
2417 # Circumlocution to avoid accidental
2418 # configure substitution.
2420 &define_program_variable ('TEXI2DVI', 'src', 'texinfo/util',
2423 # Handle location of texinfo.tex.
2424 my $need_texi_file = 0;
2428 $texinfodir = '$(top_srcdir)/../texinfo';
2429 &define_variable ('TEXINFO_TEX', "$texinfodir/texinfo.tex");
2432 elsif ($config_aux_dir ne '.' && $config_aux_dir ne '')
2434 $texinfodir = $config_aux_dir;
2435 &define_variable ('TEXINFO_TEX', "$texinfodir/texinfo.tex");
2436 $need_texi_file = 2; # so that we require_conf_file later
2438 elsif (&variable_defined ('TEXINFO_TEX'))
2440 # The user defined TEXINFO_TEX so assume he knows what he is
2442 $texinfodir = ('$(srcdir)/'
2443 . dirname (&variable_value ('TEXINFO_TEX')));
2447 $texinfodir = '$(srcdir)';
2448 $need_texi_file = 1;
2452 &transform ('TEXINFODIR' => $texinfodir,
2453 'TEXICLEAN' => &pretty_print_internal ("\t-rm -f",
2456 foreach my $txsfx (sort keys %texi_suffixes)
2458 $output_rules .= &file_contents ('texibuild',
2460 . &transform ('SUFFIX' => $txsfx));
2462 $output_rules .= &file_contents ('texinfos', $xform);
2463 push (@dist_targets, 'dist-info');
2464 push (@suffixes, '.texi', '.texinfo', '.txi', '.info', '.dvi', '.ps');
2466 if (! defined $options{'no-installinfo'})
2468 # Make sure documentation is made and installed first. Use
2469 # $(INFO_DEPS), not 'info', because otherwise recursive makes
2470 # get run twice during "make all".
2471 unshift (@all, '$(INFO_DEPS)');
2473 push (@info, '$(INFO_DEPS)');
2474 push (@dvi, '$(DVIS)');
2476 &define_variable ("INFO_DEPS", join (' ', @info_deps_list));
2477 &define_variable ("DVIS", join (' ', @dvis_list));
2478 # This next isn't strictly needed now -- the places that look here
2479 # could easily be changed to look in info_TEXINFOS. But this is
2480 # probably better, in case noinst_TEXINFOS is ever supported.
2481 &define_variable ("TEXINFOS", &variable_value ('info_TEXINFOS'));
2483 # Do some error checking. Note that this file is not required
2484 # when in Cygnus mode; instead we defined TEXINFO_TEX explicitly
2486 if ($need_texi_file && ! defined $options{'no-texinfo.tex'})
2488 if ($need_texi_file > 1)
2490 &require_conf_file_with_line ('info_TEXINFOS', $FOREIGN,
2495 &require_file_with_line ('info_TEXINFOS', $FOREIGN, 'texinfo.tex');
2500 # Handle any man pages.
2501 sub handle_man_pages
2503 &am_line_error ('MANS', "\`MANS' is an anachronism; use \`man_MANS'")
2504 if &variable_defined ('MANS');
2506 # Find all the sections in use. We do this by first looking for
2507 # "standard" sections, and then looking for any additional
2508 # sections used in man_MANS.
2509 my (%sections, %vlist);
2510 # Add more sections as needed.
2511 foreach my $sect ('0'..'9', 'n', 'l')
2513 if (&variable_defined ('man' . $sect . '_MANS'))
2515 $sections{$sect} = 1;
2516 $vlist{'$(man' . $sect . '_MANS)'} = 1;
2520 if (&variable_defined ('man_MANS'))
2522 $vlist{'$(man_MANS)'} = 1;
2523 foreach (&variable_value_as_list ('man_MANS', 'all'))
2525 # A page like `foo.1c' goes into man1dir.
2526 if (/\.([0-9a-z])([a-z]*)$/)
2533 return unless %sections;
2535 # Now for each section, generate an install and unintall rule.
2536 # Sort sections so output is deterministic.
2537 foreach my $sect (sort keys %sections)
2539 &define_variable ('man' . $sect . 'dir', '$(mandir)/man' . $sect);
2540 $output_rules .= &file_contents ('mans',
2541 &transform ('SECTION', $sect));
2544 # We don't really need this, but we use it in case we ever want to
2545 # support noinst_MANS.
2546 &define_variable ("MANS", join (' ', sort keys %vlist));
2548 $output_vars .= &file_contents ('mans-vars');
2550 if (! defined $options{'no-installman'})
2552 push (@all, '$(MANS)');
2556 # Handle DATA variables.
2559 &am_install_var ('-noextra', '-candist', 'data', 'DATA',
2560 'data', 'sysconf', 'sharedstate', 'localstate',
2561 'pkgdata', 'noinst', 'check');
2568 if (&variable_defined ('SUBDIRS'))
2570 $output_rules .= ("tags-recursive:\n"
2571 . "\tlist=\'\$(SUBDIRS)\'; for subdir in \$\$list; do \\\n"
2572 # Never fail here if a subdir fails; it
2574 . "\t test \"\$\$subdir\" = . || (cd \$\$subdir"
2575 . " && \$(MAKE) \$(AM_MAKEFLAGS) tags); \\\n"
2577 push (@tag_deps, 'tags-recursive');
2578 &depend ('.PHONY', 'tags-recursive');
2581 if (&saw_sources_p (1)
2582 || &variable_defined ('ETAGS_ARGS')
2586 foreach my $one_hdr (@config_headers)
2588 if ($relative_dir eq dirname ($one_hdr))
2590 # The config header is in this directory. So require it.
2591 $config .= ' ' if $config;
2592 $config .= basename ($one_hdr);
2596 &file_contents ('tags',
2597 &transform ('CONFIG' => $config,
2598 'DIRS' => join (' ', @tag_deps)));
2599 $output_rules .= &file_contents ('tags-clean');
2600 &examine_variable ('TAGS_DEPENDENCIES');
2602 elsif (&variable_defined ('TAGS_DEPENDENCIES'))
2604 &am_line_error ('TAGS_DEPENDENCIES',
2605 "doesn't make sense to define \`TAGS_DEPENDENCIES' without sources or \`ETAGS_ARGS'");
2609 # Every Makefile must define some sort of TAGS rule.
2610 # Otherwise, it would be possible for a top-level "make TAGS"
2611 # to fail because some subdirectory failed.
2612 $output_rules .= "tags: TAGS\nTAGS:\n\n";
2616 # Handle multilib support.
2619 return unless $seen_multilib;
2621 $output_rules .= &file_contents ('multilib');
2626 # &dist_cmp ($A, $B)
2627 # --------------------
2628 # Subroutine for &handle_dist: sort files to dist.
2630 # We put README first because it then becomes easier to make a
2631 # Usenet-compliant shar file (in these, README must be first).
2633 # FIXME: do more ordering of files here.
2646 # handle_dist ($MAKEFILE)
2647 # -----------------------
2648 # Handle 'dist' target.
2651 my ($makefile) = @_;
2653 # `make dist' isn't used in a Cygnus-style tree.
2654 # Omit the rules so that people don't try to use them.
2655 return if $cygnus_mode;
2657 # Set up maint_charset.
2658 $local_maint_charset = &variable_value ('MAINT_CHARSET')
2659 if &variable_defined ('MAINT_CHARSET');
2660 $maint_charset = $local_maint_charset
2661 if $relative_dir eq '.';
2663 if (&variable_defined ('DIST_CHARSET'))
2665 &am_line_error ('DIST_CHARSET',
2666 "DIST_CHARSET defined but no MAINT_CHARSET defined")
2667 if ! $local_maint_charset;
2668 if ($relative_dir eq '.')
2670 $dist_charset = &variable_value ('DIST_CHARSET')
2674 &am_line_error ('DIST_CHARSET',
2675 "DIST_CHARSET can only be defined at top level");
2679 # Look for common files that should be included in distribution.
2680 foreach my $cfile (@common_files)
2682 if (-f ($relative_dir . "/" . $cfile))
2684 &push_dist_common ($cfile);
2688 # Always require configure.ac and configure at top level, even if
2689 # they don't exist. This is especially important for configure,
2690 # since it won't be created until autoconf is run -- which might
2691 # be after automake is run.
2692 &push_dist_common ($configure_ac, 'configure')
2693 if $relative_dir eq '.';
2695 # We might copy elements from %configure_dist_common to
2696 # %dist_common if we think we need to. If the file appears in our
2697 # directory, we would have discovered it already, so we don't
2698 # check that. But if the file is in a subdir without a Makefile,
2699 # we want to distribute it here if we are doing `.'. Ugly!
2700 if ($relative_dir eq '.')
2702 foreach my $iter (keys %configure_dist_common)
2704 if (! &is_make_dir (dirname ($iter)))
2706 &push_dist_common ($iter);
2711 # Keys of %dist_common are names of files to distributed.
2712 &define_pretty_variable ("DIST_COMMON", '',
2713 sort dist_cmp keys %dist_common);
2714 $output_vars .= "\n";
2716 # Now that we've processed %dist_common, disallow further attempts
2718 $handle_dist_run = 1;
2720 # Scan EXTRA_DIST to see if we need to distribute anything from a
2721 # subdir. If so, add it to the list. I didn't want to do this
2722 # originally, but there were so many requests that I finally
2724 if (&variable_defined ('EXTRA_DIST'))
2726 # FIXME: This should be fixed to work with conditionals. That
2727 # will require only making the entries in %dist_dirs under the
2728 # appropriate condition. This is meaningful if the nature of
2729 # the distribution should depend upon the configure options
2731 foreach (&variable_value_as_list ('EXTRA_DIST', ''))
2734 next unless s,/+[^/]+$,,;
2740 # We have to check DIST_COMMON for extra directories in case the
2741 # user put a source used in AC_OUTPUT into a subdir.
2742 foreach (&variable_value_as_list ('DIST_COMMON', 'all'))
2745 next unless s,/+[^/]+$,,;
2750 # Rule to check whether a distribution is viable.
2752 &transform_cond ('TOPDIR' => ($relative_dir eq '.'),
2753 'DISTCHECK-HOOK' => &target_defined ('distcheck-hook'),
2754 'GETTEXT' => $seen_gettext);
2756 if (scalar keys %dist_dirs)
2758 # Prepend $(distdir) to each directory given.
2760 grep ($rewritten{'$(distdir)/' . $_} = 1, keys %dist_dirs);
2761 $xform .= &transform ('DISTDIRS', join (' ', sort keys %rewritten));
2765 $xform .= 's/.*\@DISTDIRS\@.*//g;';
2768 # If we have SUBDIRS, create all dist subdirectories and do
2770 if (&variable_defined ('SUBDIRS'))
2772 # If SUBDIRS is conditionally defined, then set DIST_SUBDIRS
2773 # to all possible directories, and use it. If DIST_SUBDIRS is
2774 # defined, just use it.
2775 my $dist_subdir_name;
2776 if (&variable_conditions ('SUBDIRS')
2777 || &variable_defined ('DIST_SUBDIRS'))
2779 $dist_subdir_name = 'DIST_SUBDIRS';
2780 if (! &variable_defined ('DIST_SUBDIRS'))
2782 &define_pretty_variable
2783 ('DIST_SUBDIRS', '',
2784 uniq (&variable_value_as_list ('SUBDIRS', 'all')));
2789 $dist_subdir_name = 'SUBDIRS';
2790 # We always define this because that is what `distclean'
2792 &define_pretty_variable ('DIST_SUBDIRS', '', '$(SUBDIRS)');
2795 $xform .= &transform ('DIST_SUBDIR_NAME' => $dist_subdir_name);
2798 # If the target `dist-hook' exists, make sure it is run. This
2799 # allows users to do random weird things to the distribution
2800 # before it is packaged up.
2801 push (@dist_targets, 'dist-hook')
2802 if &target_defined ('dist-hook');
2804 my $top_distdir = backname ($relative_dir);
2807 &file_contents ('distdir',
2809 . &transform ('DIST-TARGETS' => join (" ", @dist_targets),
2810 'TOP_DISTDIR' => $top_distdir)
2811 . &transform_cond ('DISTDIR' =>
2812 ! &variable_defined ('distdir')));
2816 # add_depend2 ($LANG)
2817 # -------------------
2818 # A subroutine of handle_dependencies. This function includes
2819 # `depend2' with appropriate transformations.
2824 # Get information on $LANG.
2825 my $pfx = $language_map{"$lang-autodep"};
2826 my $fpfx = ($pfx eq '') ? 'CC' : $pfx;
2827 my $flag = $language_map{"$lang-flags"};
2829 # First include code for ordinary objects.
2830 my $xform = (&transform ('PFX' => $pfx,
2832 . &transform_cond ('OBJEXT' => $seen_objext,
2833 'LIBTOOL' => $seen_libtool));
2835 # This function can be called even when we don't want dependency
2836 # tracking. This happens when we need an explicit rule for some
2837 # target. In this case we don't want to include the generic code.
2838 if ($use_dependencies)
2840 my $compile = '$(' . $pfx . 'COMPILE)';
2841 my $ltcompile = '$(LT' . $pfx . 'COMPILE)';
2842 my $xform1 = ($xform
2843 . &transform ('BASE' => '$*',
2848 'COMPILE' => $compile,
2849 'LTCOMPILE' => $ltcompile));
2851 foreach my $ext (&lang_extensions ($lang))
2853 $output_rules .= (&file_contents ('depend2',
2854 &transform ('EXT' => $ext)
2861 # If dependency tracking is disabled, we just elide the code.
2862 $xform .= 's/\@AMDEP\@.*$//;';
2865 # Now include code for each specially handled object with this
2867 my @list = grep ($_ ne '', split (' ', $lang_specific_files{$lang}));
2868 my $max = scalar @list;
2870 my ($derived, $source, $obj);
2871 my %seen_files = ();
2874 $derived = $list[$i];
2875 $source = $list[$i + 1];
2876 $obj = $list[$i + 2];
2879 # We might see a given object twice, for instance if it is
2880 # used under different conditions.
2881 next if defined $seen_files{$obj};
2882 $seen_files{$obj} = 1;
2884 my $val = "${derived}_${flag}";
2886 my $obj_compile = $language_map{"$lang-compile"};
2887 $obj_compile =~ s/\(AM_$flag/\($val/;
2888 my $obj_ltcompile = '$(LIBTOOL) --mode=compile ' . $obj_compile;
2890 # Generate a transform which will turn suffix targets in
2891 # depend2.am into real targets for the particular objects we
2897 . &transform ('COMPILE' => $obj_compile,
2898 'LTCOMPILE' => $obj_ltcompile,
2899 # Handle source and obj transforms.
2900 'OBJ' => $obj . '.o',
2901 'OBJOBJ' => $obj . '.obj',
2902 'LTOBJ' => $obj . '.lo',
2904 'SOURCE' => $source)
2905 # Generate rule for `.o'.
2906 . 's/^\@EXT\@\.o:/' . "\Q$obj.o: $source\E" . '/g;'
2907 # Maybe generate rule for `.lo'. Might be eliminated
2909 . 's/^\@EXT\@\.lo:/' . "\Q$obj.lo: $source\E" . '/g;'
2910 # Maybe generate rule for `.obj'. Might be
2911 # eliminated by $XFORM.
2912 . 's/^\@EXT\@\.obj:/' . "\Q$obj.obj: $source\E" . '/g;');
2916 # Handle auto-dependency code.
2917 sub handle_dependencies
2919 if ($use_dependencies)
2921 # Include auto-dep code. Don't include it if DEP_FILES would
2923 if (&saw_sources_p (0) && keys %dep_files)
2925 my $config_aux_dir_specified = ($config_aux_dir ne '.'
2926 && $config_aux_dir ne '');
2928 # Set $require_file_found{'depcomp'} if the depcomp file exists,
2929 # before calling require_config_file on `depcomp'. This makes
2930 # require_file_internal skip its buggy existence test that would
2931 # make automake fail (with `required file `lib/depcomp' not found')
2932 # when AC_CONFIG_AUX_DIR is not set. See tests/subdir4.test.
2933 my $depcomp_dir = ($config_aux_dir_specified ? $config_aux_dir
2935 $require_file_found{'depcomp'} = 1 if -f "$depcomp_dir/depcomp";
2937 # Set location of depcomp.
2938 my $prefix = ($config_aux_dir_specified ? $config_aux_dir
2941 &define_variable ('depcomp', "\$(SHELL) $prefix/depcomp");
2943 &require_config_file ($FOREIGN, 'depcomp');
2945 my @deplist = sort keys %dep_files;
2947 # We define this as a conditional variable because BSD
2948 # make can't handle backslashes for continuing comments on
2949 # the following line.
2950 &define_pretty_variable ('DEP_FILES', 'AMDEP', @deplist);
2952 # Generate each `include' individually. Irix 6 make will
2953 # not properly include several files resulting from a
2954 # variable expansion; generating many separate includes
2956 $output_rules .= "\n";
2957 foreach my $iter (@deplist)
2959 $output_rules .= "\@AMDEP\@\@_am_include\@ " . $iter . "\n";
2962 $output_rules .= &file_contents ('depend');
2967 &define_variable ('depcomp', '');
2970 foreach my $key (sort keys %language_map)
2972 next unless $key =~ /^(.*)-autodep$/;
2973 next if $language_map{$key} eq 'no';
2978 # Handle subdirectories.
2982 unless &variable_defined ('SUBDIRS');
2984 # Make sure each directory mentioned in SUBDIRS actually exists.
2985 foreach my $dir (&variable_value_as_list ('SUBDIRS', 'all'))
2987 # Skip directories substituted by configure.
2988 next if $dir =~ /^\@.*\@$/;
2990 if (! -d $am_relative_dir . '/' . $dir)
2992 &am_line_error ('SUBDIRS',
2993 "required directory $am_relative_dir/$dir does not exist");
2997 &am_line_error ('SUBDIRS', "directory should not contain \`/'")
3002 &file_contents ('subdirs',
3004 ('INSTALLINFO' => (defined $options{'no-installinfo'}
3005 ? 'install-info-recursive'
3009 # Handle aclocal.m4.
3010 sub handle_aclocal_m4
3012 my $regen_aclocal = 0;
3013 if (-f 'aclocal.m4')
3015 &define_variable ("ACLOCAL_M4", '$(top_srcdir)/aclocal.m4');
3016 &push_dist_common ('aclocal.m4');
3018 my $aclocal = new IO::File ("< aclocal.m4");
3021 my $line = $aclocal->getline;
3024 if ($line =~ 'generated automatically by aclocal')
3032 if (-f 'acinclude.m4')
3038 # Note that it might be possible that aclocal.m4 doesn't exist but
3039 # should be auto-generated. This case probably isn't very
3043 my @ac_deps = (($seen_maint_mode ? "\@MAINTAINER_MODE_TRUE\@": "") ,
3045 ($acinclude ? ' acinclude.m4' : ''));
3047 if (&variable_defined ('ACLOCAL_M4_SOURCES'))
3049 push (@ac_deps, "\$(ACLOCAL_M4_SOURCES)");
3051 elsif (&variable_defined ('ACLOCAL_AMFLAGS'))
3053 # Scan all -I directories for m4 files. These are our
3055 my $examine_next = 0;
3056 foreach my $amdir (&variable_value_as_list ('ACLOCAL_AMFLAGS', ''))
3061 if ($amdir !~ /^\// && -d $amdir)
3063 foreach my $ac_dep (&my_glob ($amdir . '/*.m4'))
3065 $ac_dep =~ s/^\.\/+//;
3066 push (@ac_deps, $ac_dep)
3067 unless $ac_dep eq "aclocal.m4"
3068 || $ac_dep eq "acinclude.m4";
3072 elsif ($amdir eq '-I')
3079 &pretty_print_rule ("\$(ACLOCAL_M4):", "\t\t", @ac_deps);
3081 $output_rules .= ("\t"
3082 . 'cd $(srcdir) && $(ACLOCAL)'
3083 . (&variable_defined ('ACLOCAL_AMFLAGS')
3084 ? ' $(ACLOCAL_AMFLAGS)' : '')
3089 # Rewrite a list of input files into a form suitable to put on a
3090 # dependency list. The idea is that if an input file has a directory
3091 # part the same as the current directory, then the directory part is
3092 # simply removed. But if the directory part is different, then
3093 # $(top_srcdir) is prepended. Among other things, this is used to
3094 # generate the dependency list for the output files generated by
3095 # AC_OUTPUT. Consider what the dependencies should look like in this
3097 # AC_OUTPUT(src/out:src/in1:lib/in2)
3098 # The first argument, ADD_SRCDIR, is 1 if $(top_srcdir) should be added.
3099 # If 0 then files that require this addition will simply be ignored.
3100 sub rewrite_inputs_into_dependencies
3102 my ($add_srcdir, @inputs) = @_;
3105 foreach my $single (@inputs)
3107 if (dirname ($single) eq $relative_dir)
3109 push (@newinputs, basename ($single));
3113 push (@newinputs, '$(top_srcdir)/' . $single);
3120 # Handle remaking and configure stuff.
3121 # We need the name of the input file, to do proper remaking rules.
3122 sub handle_configure
3124 my ($local, $input, @secondary_inputs) = @_;
3126 my $input_base = basename ($input);
3127 my $local_base = basename ($local);
3129 my $amfile = $input_base . '.am';
3130 # We know we can always add '.in' because it really should be an
3131 # error if the .in was missing originally.
3132 my $infile = '$(srcdir)/' . $input_base . '.in';
3134 if ($local ne $input || @secondary_inputs)
3136 $colon_infile = ':' . $input . '.in';
3138 $colon_infile .= ':' . join (':', @secondary_inputs)
3139 if @secondary_inputs;
3141 my @rewritten = &rewrite_inputs_into_dependencies (1, @secondary_inputs);
3143 # This rule remakes the Makefile.in. Note use of
3144 # @MAINTAINER_MODE_TRUE@ forces us to abandon pretty-printing.
3146 $output_rules .= ($infile
3147 # NOTE perl 5.003 (with -w) gives a
3148 # uninitialized value error on the next line.
3151 . ($seen_maint_mode ? "\@MAINTAINER_MODE_TRUE\@ " : '')
3153 . '$(top_srcdir)/' . $configure_ac .' $(ACLOCAL_M4)'
3154 . ' ' . join (' ', @include_stack)
3156 . "\tcd \$(top_srcdir) && \$(AUTOMAKE) "
3157 . ($cygnus_mode ? '--cygnus' : ('--' . $strictness_name))
3158 . ($cmdline_use_dependencies ? '' : ' --ignore-deps')
3159 . ' ' . $input . $colon_infile . "\n\n");
3161 # This rule remakes the Makefile.
3162 $output_rules .= ($local_base
3163 # NOTE: bogus uninit value error on next line;
3164 # see comment above.
3167 . join (' ', @rewritten)
3168 . ' $(top_builddir)/config.status'
3170 . "\tcd \$(top_builddir) \\\n"
3171 . "\t && CONFIG_FILES="
3172 . (($relative_dir eq '.') ? '$@' : '$(subdir)/$@')
3174 . ' CONFIG_HEADERS= CONFIG_LINKS= $(SHELL) ./config.status'
3178 if ($relative_dir ne '.')
3181 $top_reldir = '../';
3187 &file_contents ('remake',
3188 &transform ('CONFIGURE_AC' => $configure_ac));
3189 &examine_variable ('CONFIG_STATUS_DEPENDENCIES');
3190 &examine_variable ('CONFIGURE_DEPENDENCIES');
3193 &push_dist_common ('acconfig.h')
3197 # If we have a configure header, require it.
3198 my @local_fullnames = @config_fullnames;
3199 my @local_names = @config_names;
3201 my $distclean_config = '';
3202 foreach my $one_hdr (@config_headers)
3204 my $one_fullname = shift (@local_fullnames);
3205 my $one_name = shift (@local_names);
3207 my $header_dir = dirname ($one_name);
3209 # If the header is in the current directory we want to build
3210 # the header here. Otherwise, if we're at the topmost
3211 # directory and the header's directory doesn't have a
3212 # Makefile, then we also want to build the header.
3213 if ($relative_dir eq $header_dir
3214 || ($relative_dir eq '.' && ! &is_make_dir ($header_dir)))
3216 my ($cn_sans_dir, $stamp_dir);
3217 if ($relative_dir eq $header_dir)
3219 $cn_sans_dir = basename ($one_name);
3224 $cn_sans_dir = $one_name;
3225 if ($header_dir eq '.')
3231 $stamp_dir = $header_dir . '/';
3235 # Compute relative path from directory holding output
3236 # header to directory holding input header. FIXME:
3237 # doesn't handle case where we have multiple inputs.
3239 if (dirname ($one_hdr) eq $relative_dir)
3241 $ch_sans_dir = basename ($one_hdr);
3245 $ch_sans_dir = backname ($relative_dir) . '/' . $one_hdr;
3248 &require_file_with_conf_line ($config_header_line,
3249 $FOREIGN, $ch_sans_dir);
3251 # Header defined and in this directory.
3253 if (-f $one_name . '.top')
3255 push (@files, "${cn_sans_dir}.top");
3257 if (-f $one_name . '.bot')
3259 push (@files, "${cn_sans_dir}.bot");
3262 &push_dist_common (@files);
3264 # For now, acconfig.h can only appear in the top srcdir.
3265 if (-f 'acconfig.h')
3267 if ($relative_dir eq '.')
3269 push (@files, 'acconfig.h');
3273 push (@files, '$(top_srcdir)/acconfig.h');
3277 my $stamp_name = 'stamp-h';
3278 $stamp_name .= "${hdr_index}" if scalar (@config_headers) > 1;
3281 my $out_dir = dirname ($ch_sans_dir);
3283 $xform = &transform ('CONFIGURE_AC' => $configure_ac,
3284 'FILES' => join (' ', @files),
3285 'CONFIG_HEADER' => $cn_sans_dir,
3286 'CONFIG_HEADER_IN' => $ch_sans_dir,
3287 'CONFIG_HEADER_FULL' => $one_fullname,
3288 'STAMP' => "$stamp_dir$stamp_name",
3289 'SRC_STAMP' => "$out_dir/$stamp_name");
3291 $output_rules .= &file_contents ('remake-hdr', $xform);
3293 &create ("${relative_dir}/${out_dir}/${stamp_name}.in");
3294 &require_file_with_conf_line ($config_header_line, $FOREIGN,
3295 "${out_dir}/${stamp_name}.in");
3297 $distclean_config .= ' ' if $distclean_config;
3298 $distclean_config .= $cn_sans_dir;
3302 if ($distclean_config)
3305 &file_contents ('clean-hdr',
3306 &transform ('FILES' => $distclean_config));
3309 # Set location of mkinstalldirs.
3310 if ($config_aux_dir ne '.' && $config_aux_dir ne '')
3312 &define_variable ('mkinstalldirs', ('$(SHELL) ' . $config_aux_dir
3313 . '/mkinstalldirs'));
3317 &define_variable ('mkinstalldirs',
3318 '$(SHELL) $(top_srcdir)/mkinstalldirs');
3321 &am_line_error ('CONFIG_HEADER',
3322 "\`CONFIG_HEADER' is an anachronism; now determined from \`$configure_ac'")
3323 if &variable_defined ('CONFIG_HEADER');
3325 my $config_header = '';
3326 foreach my $one_name (@config_names)
3328 # Generate CONFIG_HEADER define.
3330 if ($relative_dir eq dirname ($one_name))
3332 $one_hdr = basename ($one_name);
3336 $one_hdr = "\$(top_builddir)/${one_name}";
3339 $config_header .= ' ' if $config_header;
3340 $config_header .= $one_hdr;
3344 &define_variable ("CONFIG_HEADER", $config_header);
3347 # Now look for other files in this directory which must be remade
3348 # by config.status, and generate rules for them.
3349 my @actual_other_files = ();
3350 foreach my $lfile (@other_input_files)
3353 my (@inputs, @rewritten_inputs);
3354 my ($need_rewritten);
3355 if ($lfile =~ /^([^:]*):(.*)$/)
3357 # This is the ":" syntax of AC_OUTPUT.
3359 $local = basename ($file);
3360 @inputs = split (':', $2);
3361 @rewritten_inputs = &rewrite_inputs_into_dependencies (1, @inputs);
3362 $need_rewritten = 1;
3368 $local = basename ($file);
3369 @inputs = ($file . '.in');
3371 &rewrite_inputs_into_dependencies (1, @inputs);
3372 $need_rewritten = 0;
3375 # Make sure the dist directory for each input file is created.
3376 # We only have to do this at the topmost level though. This
3377 # is a bit ugly but it easier than spreading out the logic,
3378 # especially in cases like AC_OUTPUT(foo/out:bar/in), where
3379 # there is no Makefile in bar/.
3380 if ($relative_dir eq '.')
3384 $dist_dirs{dirname ($_)} = 1;
3388 # We skip any automake input files, as they are handled
3389 # elsewhere. We also skip files that aren't in this
3390 # directory. However, if the file's directory does not have a
3391 # Makefile, and we are currently doing `.', then we create a
3392 # rule to rebuild the file in the subdir.
3393 next if -f $file . '.am';
3394 my $fd = dirname ($file);
3395 if ($fd ne $relative_dir)
3397 if ($relative_dir eq '.' && ! &is_make_dir ($fd))
3407 # Some users have been tempted to put `stamp-h' in the
3408 # AC_OUTPUT line. This won't do the right thing, so we
3409 # explicitly fail here.
3410 if ($local eq 'stamp-h')
3412 # FIXME: allow real filename.
3413 &am_conf_error ($configure_ac, $ac_output_line,
3414 'stamp-h should not appear in AC_OUTPUT');
3418 $output_rules .= ($local . ': '
3419 . '$(top_builddir)/config.status '
3420 . join (' ', @rewritten_inputs) . "\n"
3422 . 'cd $(top_builddir) && CONFIG_FILES='
3423 . ($relative_dir eq '.' ? '' : '$(subdir)/')
3424 . '$@' . ($need_rewritten
3425 ? (':' . join (':', @inputs))
3427 . ' CONFIG_HEADERS= CONFIG_LINKS= $(SHELL) ./config.status'
3429 push (@actual_other_files, $local);
3431 # Require all input files.
3432 &require_file_with_conf_line ($ac_output_line, $FOREIGN,
3433 &rewrite_inputs_into_dependencies (0, @inputs));
3436 # These files get removed by "make clean".
3437 &define_pretty_variable ('CONFIG_CLEAN_FILES', '', @actual_other_files);
3443 my @r = &am_install_var ('-defaultdist', 'header', 'HEADERS', 'include',
3444 'oldinclude', 'pkginclude',
3448 next unless /\.(.*)$/;
3449 &saw_extension ($1);
3455 return if ! $seen_gettext || $relative_dir ne '.';
3457 if (! &variable_defined ('SUBDIRS'))
3460 ("AM_GNU_GETTEXT used but SUBDIRS not defined");
3464 my @subdirs = &variable_value_as_list ('SUBDIRS', 'all');
3465 &am_line_error ('SUBDIRS',
3466 "AM_GNU_GETTEXT used but \`po' not in SUBDIRS")
3467 if ! grep ('po', @subdirs);
3468 &am_line_error ('SUBDIRS',
3469 "AM_GNU_GETTEXT used but \`intl' not in SUBDIRS")
3470 if ! grep ('intl', @subdirs);
3472 &require_file_with_conf_line ($ac_gettext_line, $GNU, 'ABOUT-NLS');
3474 # Ensure that each language in ALL_LINGUAS has a .po file, and
3475 # each po file is mentioned in ALL_LINGUAS.
3479 grep ($linguas{$_} = 1, split (' ', $all_linguas));
3486 &am_line_error ($all_linguas_line,
3487 ("po/$_.po exists but \`$_' not in \`ALL_LINGUAS'"))
3491 foreach (keys %linguas)
3493 &am_line_error ($all_linguas_line,
3494 "$_ in \`ALL_LINGUAS' but po/$_.po does not exist")
3500 &am_error ("AM_GNU_GETTEXT in \`$configure_ac' but \`ALL_LINGUAS' not defined");
3504 # Handle footer elements.
3507 if ($contents{'SOURCES'})
3509 # NOTE don't use define_pretty_variable here, because
3510 # $contents{...} is already defined.
3511 $output_vars .= 'SOURCES = ' . $contents{'SOURCES'} . "\n";
3513 if ($contents{'OBJECTS'})
3515 # NOTE don't use define_pretty_variable here, because
3516 # $contents{...} is already defined.
3517 $output_vars .= 'OBJECTS = ' . $contents{'OBJECTS'} . "\n";
3519 if ($contents{'SOURCES'} || $contents{'OBJECTS'})
3521 $output_vars .= "\n";
3524 if (&target_defined ('.SUFFIXES'))
3526 &am_line_error ('.SUFFIXES',
3527 "use variable \`SUFFIXES', not target \`.SUFFIXES'");
3530 # Note: AIX 4.1 /bin/make will fail if any suffix rule appears
3531 # before .SUFFIXES. So we make sure that .SUFFIXES appears before
3532 # anything else, by sticking it right after the default: target.
3533 $output_header .= ".SUFFIXES:\n";
3534 if (@suffixes || &variable_defined ('SUFFIXES'))
3536 # Make sure suffixes has unique elements. Sort them to ensure
3537 # the output remains consistent. However, $(SUFFIXES) is
3538 # always at the start of the list, unsorted. This is done
3539 # because make will choose rules depending on the ordering of
3540 # suffixes, and this lets the user have some control. Push
3541 # actual suffixes, and not $(SUFFIXES). Some versions of make
3542 # do not like variable substitutions on the .SUFFIXES line.
3543 my @user_suffixes = (&variable_defined ('SUFFIXES')
3544 ? &variable_value_as_list ('SUFFIXES', '')
3548 grep ($suffixes{$_} = 1, @suffixes);
3549 delete @suffixes{@user_suffixes};
3551 $output_header .= (".SUFFIXES: "
3552 . join (' ', @user_suffixes, sort keys %suffixes)
3555 $output_trailer .= &file_contents ('footer');
3558 # Deal with installdirs target.
3559 sub handle_installdirs
3561 $output_rules .= &file_contents
3563 transform ('_am_installdirs' => $am_var_defs{'_am_installdirs'}));
3566 # There are several targets which need to be merged. This is because
3567 # their complete definition is compiled from many parts. Note that we
3568 # avoid double colon rules, otherwise we'd use them instead.
3569 sub handle_merge_targets
3571 my ($makefile) = @_;
3573 # There are a few install-related variables that you should not define.
3574 foreach my $var ('PRE_INSTALL', 'POST_INSTALL', 'NORMAL_INSTALL')
3576 if (&variable_defined ($var))
3578 &am_line_error ($var, "\`$var' should not be defined");
3582 # Put this at the beginning for the sake of non-GNU makes. This
3583 # is still wrong if these makes can run parallel jobs. But it is
3585 unshift (@all, basename ($makefile));
3587 foreach my $one_name (@config_names)
3589 push (@all, basename ($one_name))
3590 if dirname ($one_name) eq $relative_dir;
3593 &do_one_merge_target ('info', @info);
3594 &do_one_merge_target ('dvi', @dvi);
3595 &do_check_merge_target;
3597 if (defined $options{'no-installinfo'})
3599 &do_one_merge_target ('install-info', '');
3601 elsif (&target_defined ('install-info-local'))
3603 &am_line_error ('install-info-local',
3604 "\`install-info-local' target defined but \`no-installinfo' option not in use");
3607 if (@all || &variable_defined ('BUILT_SOURCES'))
3609 my $local_headers = '';
3610 $local_headers = '$(BUILT_SOURCES)'
3611 if &variable_defined ('BUILT_SOURCES');
3612 foreach my $one_name (@config_names)
3614 if (dirname ($one_name) eq $relative_dir)
3616 $local_headers .= ' ' if $local_headers;
3617 $local_headers .= basename ($one_name);
3622 # We need to make sure config.h is built before we
3623 # recurse. We also want to make sure that built sources
3624 # are built before any ordinary `all' targets are run. We
3625 # can't do this by changing the order of dependencies to
3626 # the "all" because that breaks when using parallel makes.
3627 # Instead we handle things explicitly.
3628 $output_rules .= ("all-redirect: ${local_headers}"
3630 . '$(MAKE) $(AM_MAKEFLAGS) '
3631 . (&variable_defined ('SUBDIRS')
3632 ? 'all-recursive' : 'all-am')
3634 $all_target = 'all-redirect';
3635 &depend ('.PHONY', 'all-redirect');
3639 if (&variable_defined('lib_LTLIBRARIES') &&
3640 &variable_defined('bin_PROGRAMS'))
3642 $output_rules .= "install-binPROGRAMS: install-libLTLIBRARIES\n\n";
3644 # Print definitions users can use.
3645 &do_one_merge_target ('all', @all);
3649 # &do_one_merge_target ($NAME, @VALUES)
3650 # -------------------------------------
3651 # Helper for handle_merge_targets. Note that handle_merge_targets
3652 # relies on the fact that this doesn't add an extra \n at the end.
3653 sub do_one_merge_target
3655 my ($name, @values) = @_;
3658 if (&target_defined ("$name-local"))
3660 # User defined local form of target. So include it.
3661 if (defined $dependencies{"$name-am"})
3663 depend ("$name-am", "$name-local");
3667 push (@values, "$name-local");
3669 &depend ('.PHONY', "$name-local");
3672 # FIXME: Gross, should disapear once all these targets properly
3673 # registered in %dependencies.
3674 if (!defined $dependencies {"$name-am"})
3676 &pretty_print_rule ("$name-am:", "\t\t", @values);
3679 # To understand this special case, see handle_merge_targets.
3682 # If we aren't using a redirect target then find the
3683 # appropriate actual redirect.
3684 if ($all_target eq '')
3686 $all_target = (&variable_defined ('SUBDIRS')
3687 ? 'all-recursive' : 'all-am');
3690 $output_all = "all: $all_target\n";
3694 my $lname = ($name .
3695 (&variable_defined ('SUBDIRS') ? '-recursive' : '-am'));
3696 &pretty_print_rule ($name . ":", "\t\t", $lname);
3698 &depend ('.PHONY', $name . '-am', $name);
3702 # Handle check merge target specially.
3703 sub do_check_merge_target
3705 if (&target_defined ('check-local'))
3707 # User defined local form of target. So include it.
3708 push (@check_tests, 'check-local');
3709 &depend ('.PHONY', 'check-local');
3712 # In --cygnus mode, check doesn't depend on all.
3715 # Just run the local check rules.
3716 &pretty_print_rule ('check-am:', "\t\t", @check);
3720 # The check target must depend on the local equivalent of
3721 # `all', to ensure all the primary targets are built. Then it
3722 # must build the local check rules.
3723 $output_rules .= "check-am: all-am\n";
3724 &pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ",
3728 &pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ",
3732 &depend ('.PHONY', 'check', 'check-am');
3733 $output_rules .= ("check: "
3734 . (&variable_defined ('SUBDIRS')
3735 ? 'check-recursive' : 'check-am')
3739 # Handle all 'clean' targets.
3744 # Don't include `MAINTAINER'; it is handled specially below.
3745 foreach my $name ('MOSTLY', '', 'DIST')
3747 $xform .= &transform_cond ("${name}CLEAN"
3748 => &variable_defined ("${name}CLEANFILES"));
3751 # Built sources are automatically removed by maintainer-clean.
3752 push (@maintainer_clean_files, '\$(BUILT_SOURCES)')
3753 if &variable_defined ('BUILT_SOURCES');
3754 push (@maintainer_clean_files, '\$(MAINTAINERCLEANFILES)')
3755 if &variable_defined ('MAINTAINERCLEANFILES');
3756 if (! @maintainer_clean_files)
3758 $xform .= 's/^MAINTAINERCLEAN.*$//;';
3762 $xform .= ('s/^MAINTAINERCLEAN//;'
3763 # Join with no space to avoid spurious `test -z'
3764 # success at runtime.
3765 . 's,\@MCFILES\@,' . join ('', @maintainer_clean_files)
3767 # A space is required in the join here.
3768 . 's,\@MFILES\@,' . join (' ', @maintainer_clean_files)
3772 $output_rules .= &file_contents ('clean', $xform);
3774 # We special-case config.status here. If we do it as part of the
3775 # normal clean processing for this directory, then it might be
3776 # removed before some subdir is cleaned. However, that subdir's
3777 # Makefile depends on config.status.
3778 if ($relative_dir eq '.')
3780 $actions{'distclean'} .= "\t-rm -f config.status\n";
3781 $actions{'maintainer-clean'} .= "\t-rm -f config.status\n";
3786 # &depend ($CATEGORY, @DEPENDENDEES)
3787 # ----------------------------------
3788 # The target $CATEGORY depends on @DEPENDENDEES.
3791 my ($category, @dependendees) = @_;
3793 push (@{$dependencies{$category}}, @dependendees);
3798 # &target_cmp ($A, $B)
3799 # --------------------
3800 # Subroutine for &handle_factored_dependencies to let `.PHONY' be last.
3813 # &handle_factored_dependencies ()
3814 # --------------------------------
3815 # Handle everything related to gathered targets.
3816 sub handle_factored_dependencies
3819 foreach my $utarg ('uninstall-data-local', 'uninstall-data-hook',
3820 'uninstall-exec-local', 'uninstall-exec-hook')
3822 if (&target_defined ($utarg))
3825 $x =~ s/(data|exec)-//;
3826 &am_line_error ($utarg, "use \`$x', not \`$utarg'");
3830 if (&target_defined ('install-local'))
3832 &am_line_error ('install-local',
3833 "use \`install-data-local' or \`install-exec-local', not \`install-local'");
3836 # Install the -local hooks.
3837 foreach (keys %dependencies)
3839 # Hooks are installed on the -am targets.
3841 if (&target_defined ("$_-local"))
3843 depend ("$_-am", "$_-local");
3844 &depend ('.PHONY', "$_-local");
3848 # Install the -hook hooks.
3849 # FIXME: Why not be as liberal as we are with -local hooks?
3850 foreach ('install-exec', 'install-data')
3852 if (&target_defined ("$_-hook"))
3854 $actions{"$_-am"} .=
3855 ("\t\@\$(NORMAL_INSTALL)\n"
3856 . "\t" . '$(MAKE) $(AM_MAKEFLAGS) ' . "$_-hook\n");
3860 # Actually output gathered targets.
3861 foreach (sort target_cmp keys %dependencies)
3863 # If there is nothing about this guy, skip it.
3865 unless (@{$dependencies{$_}}
3867 || $required_targets{$_});
3868 &pretty_print_rule ("$_:", "\t",
3869 uniq (sort @{$dependencies{$_}}));
3870 $output_rules .= $actions{$_};
3871 $output_rules .= "\n";
3876 # &handle_tests_dejagnu ()
3877 # ------------------------
3878 sub handle_tests_dejagnu
3880 push (@check_tests, 'check-DEJAGNU');
3882 # In Cygnus mode, these are found in the build tree.
3883 # Otherwise they are looked for in $PATH.
3884 &define_program_variable ('EXPECT', 'build', 'expect', 'expect');
3885 &define_program_variable ('RUNTEST', 'src', 'dejagnu', 'runtest');
3887 # Only create site.exp rule if user hasn't already written
3890 &file_contents ('dejagnu',
3892 ('SITE-EXP' => ! &target_defined ('site.exp'),
3893 'BUILD' => $seen_canonical == $AC_CANONICAL_SYSTEM,
3894 'HOST' => $seen_canonical,
3895 'TARGET' => $seen_canonical == $AC_CANONICAL_SYSTEM));
3899 # Handle TESTS variable and other checks.
3902 if (defined $options{'dejagnu'})
3904 &handle_tests_dejagnu;
3908 foreach my $c ('DEJATOOL', 'RUNTEST', 'RUNTESTFLAGS')
3911 "\`$c' defined but \`dejagnu' not in \`AUTOMAKE_OPTIONS'")
3912 if &variable_defined ($c);
3916 if (&variable_defined ('TESTS'))
3918 push (@check_tests, 'check-TESTS');
3919 $output_rules .= &file_contents ('check');
3923 # Handle Emacs Lisp.
3924 sub handle_emacs_lisp
3926 my @elfiles = &am_install_var ('-candist', 'lisp', 'LISP',
3932 &define_configure_variable ('lispdir');
3933 &define_configure_variable ('EMACS');
3934 $output_rules .= (".el.elc:\n"
3935 . "\t\@echo 'WARNING: Warnings can be ignored. :-)'\n"
3936 . "\tif test \$(EMACS) != no; then \\\n"
3937 . "\t EMACS=\$(EMACS) \$(SHELL) \$(srcdir)/elisp-comp \$<; \\\n"
3939 push (@suffixes, '.el', '.elc');
3941 # Generate .elc files.
3942 grep ($_ .= 'c', @elfiles);
3943 &define_pretty_variable ('ELCFILES', '', @elfiles);
3945 $output_rules .= &file_contents ('lisp-clean');
3947 push (@all, '$(ELCFILES)');
3950 if (&variable_defined ('lisp_LISP'))
3952 $varname = 'lisp_LISP';
3953 &am_error ("\`lisp_LISP' defined but \`AM_PATH_LISPDIR' not in \`$configure_ac'")
3958 $varname = 'noinst_LISP';
3961 &require_file_with_line ($varname, $FOREIGN, 'elisp-comp');
3968 my @pyfiles = &am_install_var ('-defaultdist', 'python', 'PYTHON',
3969 'python', 'noinst');
3970 return if ! @pyfiles;
3972 # Found some python.
3973 &define_configure_variable ('pythondir');
3974 &define_configure_variable ('PYTHON');
3976 $output_rules .= &file_contents ('python-clean');
3978 &am_error ("\`python_PYTHON' defined but \`AM_CHECK_PYTHON' not in \`$configure_ac'")
3979 if ! $seen_pythondir && &variable_defined ('python_PYTHON');
3981 if ($config_aux_dir eq '.' || $config_aux_dir eq '')
3983 &define_variable ('py_compile', '$(top_srcdir)/py-compile');
3987 &define_variable ('py_compile', $config_aux_dir . '/py-compile');
3994 my @sourcelist = &am_install_var ('-candist', '-clean',
3996 'java', 'noinst', 'check');
3997 return if ! @sourcelist;
3999 &define_variable ('JAVAC', 'javac');
4000 &define_variable ('JAVACFLAGS', '');
4001 &define_variable ('CLASSPATH_ENV',
4002 'CLASSPATH=$(JAVAROOT):$(srcdir)/$(JAVAROOT):$$CLASSPATH');
4003 &define_variable ('JAVAROOT', '$(top_builddir)');
4005 my %valid = &am_primary_prefixes ('JAVA', 1,
4006 'java', 'noinst', 'check');
4009 foreach my $curs (keys %valid)
4011 if (! &variable_defined ($curs . '_JAVA') || $curs eq 'EXTRA')
4018 &am_line_error ($curs . '_JAVA',
4019 "multiple _JAVA primaries in use");
4024 $output_rules .= ('class' . $dir . '.stamp: $(' . $dir . '_JAVA)' . "\n"
4025 . "\t" . '$(CLASSPATH_ENV) $(JAVAC) -d $(JAVAROOT) '
4026 . '$(JAVACFLAGS) $?' . "\n"
4027 . "\t" . 'echo timestamp > class' . $dir . '.stamp'
4029 push (@all, 'class' . $dir . '.stamp');
4030 &push_dist_common ('$(' . $dir . '_JAVA)');
4033 # Handle some of the minor options.
4034 sub handle_minor_options
4036 if (defined $options{'readme-alpha'})
4038 if ($relative_dir eq '.')
4040 if ($package_version !~ /^$GNITS_VERSION_PATTERN$/)
4042 # FIXME: allow real filename.
4043 &am_conf_line_error ($configure_ac,
4044 $package_version_line,
4045 "version \`$package_version' doesn't follow Gnits standards");
4047 elsif (defined $1 && -f 'README-alpha')
4049 # This means we have an alpha release. See
4050 # GNITS_VERSION_PATTERN for details.
4051 &require_file ($FOREIGN, 'README-alpha');
4057 ################################################################
4059 # &scan_autoconf_config_files ($CONFIG-FILES)
4060 # -------------------------------------------
4061 # Study $CONFIG-FILES which is the first argument to AC_CONFIG_FILES
4063 sub scan_autoconf_config_files
4065 # Look at potential Makefile.am's.
4068 # Must skip empty string for Perl 4.
4069 next if $_ eq "\\" || $_ eq '';
4071 # Handle $local:$input syntax. Note that we ignore
4072 # every input file past the first, though we keep
4073 # those around for later.
4074 my ($local, $input, @rest) = split (/:/);
4081 # FIXME: should be error if .in is missing.
4082 $input =~ s/\.in$//;
4085 if (-f $input . '.am')
4087 # We have a file that automake should generate.
4088 push (@make_input_list, $input);
4089 $make_list{$input} = join (':', ($local, @rest));
4093 # We have a file that automake should cause to be
4094 # rebuilt, but shouldn't generate itself.
4095 push (@other_input_files, $_);
4101 # &scan_autoconf_traces ($FILENAME)
4102 # ---------------------------------
4103 # FIXME: For the time being, we don't care about the FILENAME.
4104 sub scan_autoconf_traces
4106 my ($filename) = @_;
4108 my $traces = "$ENV{amtraces} ";
4110 $traces .= ' -t AC_CONFIG_FILES';
4111 $traces .= ' -t AC_LIBSOURCE';
4112 $traces .= ' -t AC_SUBST';
4114 my $tracefh = new IO::File ("$traces |");
4117 die "automake: couldn't open \`$traces': $!\n";
4119 print "automake: reading $traces\n" if $verbose;
4121 while ($_ = $tracefh->getline)
4124 my ($file, $line, $macro, @args) = split /:/;
4125 my $here = "$file:$line";
4127 # Alphabetical ordering please.
4128 if ($macro eq 'AC_CONFIG_FILES')
4130 # Look at potential Makefile.am's.
4131 &scan_autoconf_config_files ($args[0]);
4133 elsif ($macro eq 'AC_LIBSOURCE')
4135 my $source = "$args[0].c";
4136 # We should actually also `close' the sources: getopt.c
4137 # wants getopt.h etc. But actually it should be done in the
4138 # macro itself, i.e., we have to first fix Autoconf to extend
4139 # _AC_LIBOBJ_DECL and use it the in various macros.
4140 if (!defined $libsources{$source})
4142 print STDERR "traces: discovered $source\n";
4143 $libsources{$source} = $here;
4146 elsif ($macro eq 'AC_SUBST')
4148 if (!defined $configure_vars{$args[0]})
4150 print STDERR "traces: discovered AC_SUBST($args[0])\n";
4151 $configure_vars{$args[0]} = $here;
4157 || die "automake: close: $traces: $!\n";
4161 # &scan_one_autoconf_file ($FILENAME)
4162 # -----------------------------------
4163 # Scan one file for interesting things. Subroutine of
4164 # &scan_autoconf_files.
4165 sub scan_one_autoconf_file
4167 my ($filename) = @_;
4169 my $configfh = new IO::File ("< $filename");
4172 die "automake: couldn't open \`$filename': $!\n";
4174 print "automake: reading $filename\n" if $verbose;
4176 my ($in_ac_output, $in_ac_replace) = (0, 0);
4177 while ($_ = $configfh->getline)
4179 # Remove comments from current line.
4183 # Skip macro definitions. Otherwise we might be confused into
4184 # thinking that a macro that was only defined was actually
4188 # Follow includes. This is a weirdness commonly in use at
4189 # Cygnus and hopefully nowhere else.
4190 if (/sinclude\((.*)\)/ && -f $1)
4192 &scan_one_autoconf_file ($1);
4195 # Populate libobjs array.
4196 if (/AC_FUNC_ALLOCA/)
4198 $libsources{'alloca.c'} = 1;
4200 elsif (/AC_FUNC_GETLOADAVG/)
4202 $libsources{'getloadavg.c'} = 1;
4204 elsif (/AC_FUNC_MEMCMP/)
4206 $libsources{'memcmp.c'} = 1;
4208 elsif (/AC_STRUCT_ST_BLOCKS/)
4210 $libsources{'fileblocks.c'} = 1;
4212 elsif (/A[CM]_REPLACE_GNU_GETOPT/)
4214 $libsources{'getopt.c'} = 1;
4215 $libsources{'getopt1.c'} = 1;
4217 elsif (/AM_FUNC_STRTOD/)
4219 $libsources{'strtod.c'} = 1;
4221 elsif (/AM_WITH_REGEX/)
4223 $libsources{'rx.c'} = 1;
4224 $libsources{'rx.h'} = 1;
4225 $libsources{'regex.c'} = 1;
4226 $libsources{'regex.h'} = 1;
4228 elsif (/AC_FUNC_MKTIME/)
4230 $libsources{'mktime.c'} = 1;
4232 elsif (/AM_FUNC_ERROR_AT_LINE/)
4234 $libsources{'error.c'} = 1;
4235 $libsources{'error.h'} = 1;
4237 elsif (/AM_FUNC_OBSTACK/)
4239 $libsources{'obstack.c'} = 1;
4240 $libsources{'obstack.h'} = 1;
4242 elsif (/LIBOBJS="(.*)\s+\$LIBOBJS"/
4243 || /LIBOBJS="\$LIBOBJS\s+(.*)"/)
4245 foreach my $libobj_iter (split (' ', $1))
4247 if ($libobj_iter =~ /^(.*)\.o(bj)?$/
4248 || $libobj_iter =~ /^(.*)\.\$ac_objext$/
4249 || $libobj_iter =~ /^(.*)\.\$\{ac_objext\}$/)
4251 $libsources{$1 . '.c'} = 1;
4255 elsif (/AC_LIBOBJ\(([^)]+)\)/)
4257 $libsources{"$1.c"} = 1;
4260 if (! $in_ac_replace && s/AC_REPLACE_FUNCS\s*\(\[?//)
4266 $in_ac_replace = 0 if s/[\]\)].*$//;
4267 # Remove trailing backslash.
4271 # Need to skip empty elements for Perl 4.
4273 $libsources{$_ . '.c'} = 1;
4277 if (/$obsolete_rx/o)
4280 if ($obsolete_macros{$1} ne '')
4282 $hint = '; ' . $obsolete_macros{$1};
4284 &am_conf_line_error ($filename, $., "\`$1' is obsolete$hint");
4287 # Process the AC_OUTPUT and AC_CONFIG_FILES macros.
4288 if (! $in_ac_output && s/AC_(OUTPUT|CONFIG_FILES)\s*\(\[?//)
4291 $ac_output_line = $.;
4302 # Look at potential Makefile.am's.
4303 &scan_autoconf_config_files ($_);
4305 if ($closing && @make_input_list == 0 && @other_input_files == 0)
4307 &am_conf_line_error ($filename, $ac_output_line,
4308 "No files mentioned in \`AC_OUTPUT'");
4313 if (/$AC_CONFIG_AUX_DIR_PATTERN/o)
4315 @config_aux_path = &unquote_m4_arg ($1);
4318 # Check for ansi2knr.
4319 $am_c_prototypes = 1 if /AM_C_PROTOTYPES/;
4321 # Check for exe extension stuff.
4325 $configure_vars{'EXEEXT'} = $filename . ':' . $.;
4331 $configure_vars{'OBJEXT'} = $filename . ':' . $.;
4334 # Check for `-c -o' code.
4335 $seen_cc_c_o = 1 if /AM_PROG_CC_C_O/;
4337 # Check for NLS support.
4338 if (/AM_GNU_GETTEXT/)
4341 $ac_gettext_line = $.;
4344 # Look for ALL_LINGUAS.
4345 if (/ALL_LINGUAS="(.*)"$/ || /ALL_LINGUAS=(.*)$/)
4349 $all_linguas_line = $.;
4352 # Handle configuration headers. A config header of `[$1]'
4353 # means we are actually scanning AM_CONFIG_HEADER from
4355 if (/A([CM])_CONFIG_HEADERS?\s*\((.*)\)/
4359 ($filename, $., "\`automake requires \`AM_CONFIG_HEADER', not \`AC_CONFIG_HEADER'")
4362 $config_header_line = $.;
4363 foreach my $one_hdr (split (' ', &unquote_m4_arg ($2)))
4365 push (@config_fullnames, $one_hdr);
4366 if ($one_hdr =~ /^([^:]+):(.+)$/)
4368 push (@config_names, $1);
4369 push (@config_headers, $2);
4373 push (@config_names, $one_hdr);
4374 push (@config_headers, $one_hdr . '.in');
4379 # Handle AC_CANONICAL_*. Always allow upgrading to
4380 # AC_CANONICAL_SYSTEM, but never downgrading.
4381 $seen_canonical = $AC_CANONICAL_HOST
4382 if ! $seen_canonical
4383 && (/AC_CANONICAL_HOST/ || /AC_CHECK_TOOL/);
4384 $seen_canonical = $AC_CANONICAL_SYSTEM if /AC_CANONICAL_SYSTEM/;
4386 $seen_path_xtra = 1 if /AC_PATH_XTRA/;
4388 # This macro handles several different things.
4389 if (/$AM_INIT_AUTOMAKE_PATTERN/o)
4393 $seen_prog_install = 1;
4394 ($package_version = $1) =~ s/$AM_PACKAGE_VERSION_PATTERN/$1/o;
4395 $package_version_line = $.;
4396 $seen_init_automake = 1;
4399 # Some things required by Automake.
4400 $seen_make_set = 1 if /AC_PROG_MAKE_SET/;
4401 $seen_arg_prog = 1 if /AC_ARG_PROGRAM/;
4405 $configure_vars{'LEX'} = $filename . ':' . $.;
4406 $seen_decl_yytext = 1;
4408 if (/AC_DECL_YYTEXT/ && $filename =~ /configure\.(ac|in)$/)
4410 &am_conf_line_warning ($filename, $., "\`AC_DECL_YYTEXT' is covered by \`AM_PROG_LEX'");
4412 if (/AC_PROG_LEX/ && $filename =~ /configure\.(ac|in)$/)
4414 &am_conf_line_warning ($filename, $., "automake requires \`AM_PROG_LEX', not \`AC_PROG_LEX'");
4417 if (/AC_PROG_(F77|YACC|RANLIB|CC|CXXCPP|CXX|LEX|AWK|CPP|LN_S)/)
4419 $configure_vars{$1} = $filename . ':' . $.;
4421 if (/$AC_CHECK_PATTERN/o)
4423 $configure_vars{$3} = $filename . ':' . $.;
4425 if (/$AM_MISSING_PATTERN/o
4429 && $1 ne 'AUTOHEADER')
4431 $configure_vars{$1} = $filename . ':' . $.;
4434 # Explicitly avoid ANSI2KNR -- we AC_SUBST that in protos.m4,
4435 # but later define it elsewhere. This is pretty hacky. We
4436 # also explicitly avoid INSTALL_SCRIPT and some other
4437 # variables because they are defined in header-vars.am.
4439 if (/$AC_SUBST_PATTERN/o
4441 && $1 ne 'INSTALL_SCRIPT'
4442 && $1 ne 'INSTALL_DATA')
4444 $configure_vars{$1} = $filename . ':' . $.;
4447 $seen_decl_yytext = 1 if /AC_DECL_YYTEXT/;
4448 if (/AM_MAINTAINER_MODE/)
4450 $seen_maint_mode = 1;
4451 $configure_cond{'MAINTAINER_MODE'} = 1;
4454 $seen_prog_install = 1 if /AC_PROG_INSTALL/;
4455 $seen_lispdir = 1 if /AM_PATH_LISPDIR/;
4456 $seen_pythondir = 1 if /AM_PATH_PYTHON/;
4458 if (/A(C|M)_PROG_LIBTOOL/)
4460 # We're not ready for this yet. People still use a
4461 # libtool with no AC_PROG_LIBTOOL. Once that is the
4462 # dominant version we can reenable this code -- but next
4463 # time by mentioning the macro in %obsolete_macros, both
4464 # here and in aclocal.in.
4466 # if (/AM_PROG_LIBTOOL/)
4468 # &am_conf_line_warning ($filename, $., "\`AM_PROG_LIBTOOL' is obsolete, use \`AC_PROG_LIBTOOL' instead");
4472 $configure_vars{'LIBTOOL'} = $filename . ':' . $.;
4473 $configure_vars{'RANLIB'} = $filename . ':' . $.;
4474 $configure_vars{'CC'} = $filename . ':' . $.;
4475 # AC_PROG_LIBTOOL runs AC_CANONICAL_HOST. Make sure we
4476 # never downgrade (if we've seen AC_CANONICAL_SYSTEM).
4477 $seen_canonical = $AC_CANONICAL_HOST if ! $seen_canonical;
4480 $seen_multilib = 1 if (/AM_ENABLE_MULTILIB/);
4482 if (/$AM_CONDITIONAL_PATTERN/o)
4484 $configure_cond{$1} = 1;
4487 # Check for Fortran 77 intrinsic and run-time libraries.
4488 if (/AC_F77_LIBRARY_LDFLAGS/)
4490 $configure_vars{'FLIBS'} = $filename . ':' . $.;
4498 # &scan_autoconf_files ()
4499 # -----------------------
4500 # Check whether we use `configure.ac' or `configure.in'.
4501 # Scan it (and possibly `aclocal.m4') for interesting things.
4502 # We must scan aclocal.m4 because there might be AC_SUBSTs and such there.
4503 sub scan_autoconf_files
4505 # Reinitialize libsources here. This isn't really necessary,
4506 # since we currently assume there is only one configure.ac. But
4507 # that won't always be the case.
4510 # Watchout: these guys need dynamic scope!
4512 local @make_input_list;
4514 warn "automake: both \`configure.ac' and \`configure.in' present:"
4515 . " ignoring \`configure.in'\n"
4516 if -f 'configure.ac' && -f 'configure.in';
4517 $configure_ac = 'configure.in'
4518 if -f 'configure.in';
4519 $configure_ac = 'configure.ac'
4520 if -f 'configure.ac';
4521 die "automake: \`configure.ac' or \`configure.in' is required\n"
4524 &scan_one_autoconf_file ($configure_ac);
4525 &scan_one_autoconf_file ('aclocal.m4')
4528 if (defined $ENV{'amtraces'})
4530 warn 'automake: Autoconf traces is an experimental feature';
4531 warn 'automake: use at your own risks';
4533 &scan_autoconf_traces ($configure_ac);
4536 # Set input and output files if not specified by user.
4539 @input_files = @make_input_list;
4540 %output_files = %make_list;
4543 @configure_input_files = @make_input_list;
4545 &am_conf_error ("\`AM_INIT_AUTOMAKE' must be used")
4546 if ! $seen_init_automake;
4548 # Always require AC_PROG_MAKE_SET. We might randomly use $(MAKE)
4549 # for our own reasons.
4550 &am_conf_error ("\`AC_PROG_MAKE_SET' must be used")
4551 if ! $seen_make_set;
4553 # Look for some files we need. Always check for these. This
4554 # check must be done for every run, even those where we are only
4555 # looking at a subdir Makefile. We must set relative_dir so that
4556 # the file-finding machinery works.
4557 # Needs dynamic scopes.
4558 local $relative_dir = '.';
4559 &require_config_file ($FOREIGN, 'install-sh', 'mkinstalldirs', 'missing');
4560 &am_error ("\`install.sh' is an anachronism; use \`install-sh' instead")
4561 if -f $config_aux_path[0] . '/install.sh';
4563 &require_config_file ($FOREIGN, 'py-compile')
4566 # Preserve dist_common for later.
4567 %configure_dist_common = %dist_common;
4570 ################################################################
4572 # Set up for Cygnus mode.
4575 return unless $cygnus_mode;
4577 &set_strictness ('foreign');
4578 $options{'no-installinfo'} = 1;
4579 $options{'no-dependencies'} = 1;
4580 $use_dependencies = 0;
4582 if (! $seen_maint_mode)
4584 &am_conf_error ("\`AM_MAINTAINER_MODE' required when --cygnus specified");
4589 &am_conf_error ("\`AC_EXEEXT' required when --cygnus specified");
4593 # Do any extra checking for GNU standards.
4594 sub check_gnu_standards
4596 if ($relative_dir eq '.')
4598 # In top level (or only) directory.
4599 &require_file ($GNU, 'INSTALL', 'NEWS', 'README', 'COPYING',
4600 'AUTHORS', 'ChangeLog');
4603 if ($strictness >= $GNU)
4605 if (defined $options{'no-installman'})
4607 &am_line_error ('AUTOMAKE_OPTIONS',
4608 "option \`no-installman' disallowed by GNU standards");
4611 if (defined $options{'no-installinfo'})
4613 &am_line_error ('AUTOMAKE_OPTIONS',
4614 "option \`no-installinfo' disallowed by GNU standards");
4619 # Do any extra checking for GNITS standards.
4620 sub check_gnits_standards
4622 if ($relative_dir eq '.')
4624 # In top level (or only) directory.
4625 &require_file ($GNITS, 'THANKS');
4629 ################################################################
4631 # Functions to handle files of each language.
4633 # Each `lang_X_rewrite' function follows a simple formula:
4634 # * Args are the directory, base name and extension of the file.
4635 # * Return value is 1 if file is to be dealt with, 0 otherwise.
4636 # Much of the actual processing is handled in handle_single_transform_list.
4637 # These functions exist so that auxiliary information can be recorded
4638 # for a later cleanup pass. Note that the calls to these functions
4639 # are computed, so don't bother searching for their precise names
4642 # This is just a convenience function that can be used to determine
4643 # when a subdir object should be used.
4646 return defined $options{'subdir-objects'} ? $LANG_SUBDIR : $LANG_PROCESS;
4649 # Rewrite a single C source file.
4652 my ($directory, $base, $ext) = @_;
4654 if (defined $options{'ansi2knr'} && $base =~ /_$/)
4656 # FIXME: include line number in error.
4657 &am_error ("C source file \`$base.c' would be deleted by ansi2knr rules");
4660 my $r = $LANG_PROCESS;
4661 if (defined $options{'subdir-objects'})
4664 $base = $directory . '/' . $base;
4668 # Only give error once.
4670 # FIXME: line number.
4671 &am_error ("C objects in subdir but \`AM_PROG_CC_C_O' not in \`$configure_ac'");
4674 &require_file ($FOREIGN, 'compile')
4675 if $relative_dir eq '.';
4678 $de_ansi_files{$base} = 1;
4682 # Rewrite a single C++ source file.
4683 sub lang_cxx_rewrite
4685 return &lang_sub_obj;
4688 # Rewrite a single header file.
4689 sub lang_header_rewrite
4691 # Header files are simply ignored.
4692 return $LANG_IGNORE;
4695 # Rewrite a single yacc file.
4696 sub lang_yacc_rewrite
4698 my ($directory, $base, $ext) = @_;
4700 my $r = &lang_c_rewrite ($directory, $base, $ext);
4702 if ($r == $LANG_SUBDIR)
4704 $pfx = $directory . '/';
4706 $yacc_sources{$pfx . $base . '.' . $ext} = 1;
4708 &saw_extension ('c');
4710 &push_dist_common ($pfx . $base . '.' . $ext);
4714 # Rewrite a single yacc++ file.
4715 sub lang_yaccxx_rewrite
4717 my ($directory, $base, $ext) = @_;
4719 my $r = $LANG_PROCESS;
4721 if (defined $options{'subdir-objects'})
4723 $pfx = $directory . '/';
4726 $yacc_sources{$pfx . $base . '.' . $ext} = 1;
4728 &saw_extension ($ext);
4730 &push_dist_common ($pfx . $base . '.' . $ext);
4734 # Rewrite a single lex file.
4735 sub lang_lex_rewrite
4737 my ($directory, $base, $ext) = @_;
4739 my $r = &lang_c_rewrite ($directory, $base, $ext);
4741 if ($r == $LANG_SUBDIR)
4743 $pfx = $directory . '/';
4745 $lex_sources{$pfx . $base . '.' . $ext} = 1;
4747 &saw_extension ('c');
4749 &push_dist_common ($pfx . $base . '.' . $ext);
4753 # Rewrite a single lex++ file.
4754 sub lang_lexxx_rewrite
4756 my ($directory, $base, $ext) = @_;
4758 my $r = $LANG_PROCESS;
4760 if (defined $options{'subdir-objects'})
4762 $pfx = $directory . '/';
4765 $lex_sources{$pfx . $base . '.' . $ext} = 1;
4767 &saw_extension ($ext);
4769 &push_dist_common ($pfx . $base . '.' . $ext);
4773 # Rewrite a single assembly file.
4774 sub lang_asm_rewrite
4776 return &lang_sub_obj;
4779 # Rewrite a single Fortran 77 file.
4780 sub lang_f77_rewrite
4782 return $LANG_PROCESS;
4785 # Rewrite a single preprocessed Fortran 77 file.
4786 sub lang_ppf77_rewrite
4788 return $LANG_PROCESS;
4791 # Rewrite a single ratfor file.
4792 sub lang_ratfor_rewrite
4794 return $LANG_PROCESS;
4797 # Rewrite a single Objective C file.
4798 sub lang_objc_rewrite
4800 return &lang_sub_obj;
4803 # Rewrite a single Java file.
4804 sub lang_java_rewrite
4806 return $LANG_SUBDIR;
4809 # The lang_X_finish functions are called after all source file
4810 # processing is done. Each should handle defining rules for the
4811 # language, etc. A finish function is only called if a source file of
4812 # the appropriate type has been seen.
4816 # Push all libobjs files onto de_ansi_files. We actually only
4817 # push files which exist in the current directory, and which are
4818 # genuine source files.
4819 foreach my $file (keys %libsources)
4821 if ($file =~ /^(.*)\.[cly]$/ && -f "$relative_dir/$file")
4823 $de_ansi_files{$1} = 1;
4827 if (defined $options{'ansi2knr'} && keys %de_ansi_files)
4829 # Make all _.c files depend on their corresponding .c files.
4831 foreach my $base (sort keys %de_ansi_files)
4833 # Each _.c file must depend on ansi2knr; otherwise it
4834 # might be used in a parallel build before it is built.
4835 # We need to support files in the srcdir and in the build
4836 # dir (because these files might be auto-generated. But
4837 # we can't use $< -- some makes only define $< during a
4839 $output_rules .= ($base . "_.c: $base.c \$(ANSI2KNR)\n\t"
4840 . '$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) '
4841 . '`if test -f $(srcdir)/' . $base . '.c'
4842 . '; then echo $(srcdir)/' . $base . '.c'
4843 . '; else echo ' . $base . '.c; fi` '
4844 . "| sed 's/^# \\([0-9]\\)/#line \\1/' "
4845 . '| $(ANSI2KNR) > ' . $base . "_.c\n");
4846 push (@objects, $base . '_'
4847 . ($seen_objext ? '.$(OBJEXT)' : '.o'));
4848 push (@objects, $base . '_.lo') if $seen_libtool;
4851 # Make all _.o (and _.lo) files depend on ansi2knr.
4852 # Use a sneaky little hack to make it print nicely.
4853 &pretty_print_rule ('', '', @objects, ':', '$(ANSI2KNR)');
4856 if (! defined $configure_vars{'CC'})
4858 # FIXME: line number.
4859 &am_error ("C source seen but \`CC' not defined in \`$configure_ac'");
4865 my ($ltcompile, $ltlink) = &libtool_compiler;
4867 &define_variable ('CXXLD', '$(CXX)');
4868 &define_variable ('CXXLINK', $ltlink . '$(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@');
4870 if (! defined $configure_vars{'CXX'})
4872 &am_error ("C++ source seen but \`CXX' not defined in \`$configure_ac'");
4876 sub lang_header_finish
4881 # This is a helper for both lex and yacc.
4882 sub yacc_lex_finish_helper
4884 return if defined $language_scratch{'lex-yacc-done'};
4885 $language_scratch{'lex-yacc-done'} = 1;
4887 # If there is more than one distinct yacc (resp lex) source file
4888 # in a given directory, then the `ylwrap' program is required to
4889 # allow parallel builds to work correctly. FIXME: for now, no
4891 &require_config_file ($FOREIGN, 'ylwrap');
4892 if ($config_aux_dir ne '.' && $config_aux_dir ne '')
4894 &define_variable ('YLWRAP', $config_aux_dir . "/ylwrap");
4898 &define_variable ('YLWRAP', '$(srcdir)/ylwrap');
4902 sub lang_yacc_finish
4904 return if defined $language_scratch{'yacc-done'};
4905 $language_scratch{'yacc-done'} = 1;
4907 my %seen_suffix = ();
4908 my @yacc_files = sort keys %yacc_sources;
4909 my $yacc_count = scalar (@yacc_files);
4910 foreach my $file (@yacc_files)
4913 &output_yacc_build_rule ($1, $yacc_count > 1)
4914 if ! defined $seen_suffix{$1};
4915 $seen_suffix{$1} = 1;
4917 $file =~ /^(.*)\.(y|yy|y\+\+|yxx|ypp)$/;
4919 my $hname = 'h'; # Always use `.h' for header file.
4923 if ((&variable_defined ('AM_YFLAGS')
4924 && &variable_value ('AM_YFLAGS') =~ /(^|\s)-d(\s|$)/)
4925 || (&variable_defined ('YFLAGS')
4926 && &variable_value ('YFLAGS') =~ /(^|\s)-d(\s|$)/)) {
4927 # Now generate rule to make the header file. This should only
4928 # be generated if `yacc -d' specified.
4929 $output_rules .= "${base}.${hname}: ${base}.${cname}\n";
4931 # If the files are built in the build directory, then we want
4932 # to remove them with `make clean'. If they are in srcdir
4933 # they shouldn't be touched. However, we can't determine this
4934 # statically, and the GNU rules say that yacc/lex output files
4935 # should be removed by maintainer-clean. So that's what we
4937 push (@maintainer_clean_files, "${base}.${hname}");
4939 &push_dist_common ("${base}.${hname}");
4941 push (@maintainer_clean_files, "${base}.${cname}");
4943 $output_rules .= "\n";
4945 if (! defined $configure_vars{'YACC'})
4947 &am_error ("yacc source seen but \`YACC' not defined in \`$configure_ac'");
4949 if (&variable_defined ('YACCFLAGS'))
4951 &am_line_error ('YACCFLAGS',
4952 "\`YACCFLAGS' obsolete; use \`YFLAGS' instead");
4955 if ($yacc_count > 1)
4957 &yacc_lex_finish_helper;
4961 sub lang_yaccxx_finish
4968 return if defined $language_scratch{'lex-done'};
4969 $language_scratch{'lex-done'} = 1;
4971 my %seen_suffix = ();
4972 my $lex_count = scalar (keys %lex_sources);
4973 foreach my $file (sort keys %lex_sources)
4976 &output_lex_build_rule ($1, $lex_count > 1)
4977 if (! defined $seen_suffix{$1});
4978 $seen_suffix{$1} = 1;
4980 # If the files are built in the build directory, then we want
4981 # to remove them with `make clean'. If they are in srcdir
4982 # they shouldn't be touched. However, we can't determine this
4983 # statically, and the GNU rules say that yacc/lex output files
4984 # should be removed by maintainer-clean. So that's what we
4986 $file =~ /^(.*)\.(l|ll|l\+\+|lxx|lpp)$/;
4988 ($cname = $2) =~ tr/l/c/;
4989 push (@maintainer_clean_files, "${1}.${cname}");
4992 if (! defined $configure_vars{'LEX'})
4994 &am_error ("lex source seen but \`LEX' not defined in \`$configure_ac'");
4996 if (! $seen_decl_yytext)
4998 &am_error ("lex source seen but \`AC_DECL_YYTEXT' not in \`$configure_ac'");
5003 &yacc_lex_finish_helper;
5007 sub lang_lexxx_finish
5014 # We need the C code for assembly.
5020 # FIXME: this function can be called more than once. We should
5021 # arrange for it to only do anything the first time through.
5023 my ($ltcompile, $ltlink) = &libtool_compiler;
5025 &define_variable ('F77LD', '$(F77)');
5026 &define_variable ('F77LINK',
5027 $ltlink . '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@');
5029 if (! defined $configure_vars{'F77'})
5031 &am_error ("Fortran 77 source seen but \`F77' not defined in \`$configure_ac'");
5035 # Preprocessed Fortran 77
5037 # The current support for preprocessing Fortran 77 just involves passing
5038 # `$(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS)' as additional flags
5039 # to the Fortran 77 compiler, since this is how GNU Make does it; see
5040 # the `GNU Make Manual, Edition 0.51 for `make' Version 3.76 Beta'
5041 # (specifically, from info file `(make)Catalogue of Rules').
5043 # A better approach would be to write an Autoconf test
5044 # (i.e. AC_PROG_FPP) for a Fortran 77 preprocessor, because not all
5045 # Fortran 77 compilers know how to do preprocessing. The Autoconf macro
5046 # AC_PROG_FPP should test the Fortran 77 compiler first for
5047 # preprocessing capabilities, and then fall back on cpp (if cpp were
5049 sub lang_ppf77_finish
5053 # We also handle the case of preprocessing `.F' files into `.f'
5055 $output_rules .= (".F.f:\n"
5056 . "\t\$(F77COMPILE) -F \$<\n");
5059 sub lang_ratfor_finish
5063 # We also handle the case of preprocessing `.r' files into `.f'
5065 $output_rules .= (".r.f:\n"
5066 . "\t\$(RCOMPILE) -F \$<\n");
5069 sub lang_objc_finish
5071 my ($ltcompile, $ltlink) = &libtool_compiler;
5073 &define_variable ('OBJCLD', '$(OBJC)');
5074 &define_variable ('OBJCLINK', $ltlink . '$(OBJCLD) $(AM_OBJCFLAGS) $(OBJCFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@');
5076 if (! defined $configure_vars{'OBJC'})
5078 &am_error ("Objective C source seen but \`OBJC' not defined in \`$configure_ac'");
5082 sub lang_java_finish
5084 my ($ltcompile, $ltlink) = &libtool_compiler;
5086 &define_variable ('GCJLD', '$(GCJ)');
5087 &define_variable ('GCJLINK', $ltlink . '$(GCJLD) $(AM_GCJFLAGS) $(GCJFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@');
5089 if (! defined $configure_vars{'GCJ'})
5091 &am_error ("Java source seen but \`GCJ' not defined in \`$configure_ac'");
5095 # A helper which computes a sorted list of all extensions for LANG.
5100 foreach my $key (sort keys %extension_seen)
5102 push (@r, '.' . $key) if $extension_map{$key} eq $lang;
5107 # A helper which decides whether libtool is needed. Returns prefix
5108 # for compiler and linker.
5109 sub libtool_compiler
5111 my ($ltcompile, $ltlink) = ('', '');
5114 &define_configure_variable ("LIBTOOL");
5115 $ltcompile = '$(LIBTOOL) --mode=compile ';
5116 $ltlink = '$(LIBTOOL) --mode=link ';
5118 return ($ltcompile, $ltlink);
5121 # Given a hash table of linker names, pick the name that has the most
5122 # precedence. This is lame, but something has to have global
5123 # knowledge in order to eliminate the conflict. Add more linkers as
5130 if defined $linkers{'GCJLINK'};
5132 if defined $linkers{'CXXLINK'};
5134 if defined $linkers{'F77LINK'};
5136 if defined $linkers{'OBJCLINK'};
5140 # Called to indicate that an extension was used.
5144 $extension_seen{$ext} = 1;
5147 # Called to ask whether source files have been seen . If HEADERS is 1,
5148 # headers can be included.
5159 my @exts = &lang_extensions ('header');
5163 return scalar keys %extension_seen > $headers;
5166 # Register a single language. LANGUAGE is the name of the language.
5167 # Each OPTION is either of the form NAME=VALUE, or is a file extension
5169 sub register_language
5171 my ($language, @options) = @_;
5174 $language_map{$language . '-ansi-p'} = 0;
5175 $language_map{$language . '-linker'} = '';
5176 $language_map{$language . '-autodep'} = 'no';
5177 $language_map{$language . '-derived-autodep'} = 'no';
5179 foreach my $iter (@options)
5181 if ($iter =~ /^(.*)=(.*)$/)
5183 $language_map{$language . '-' . $1} = $2;
5185 elsif (defined $extension_map{$iter})
5187 &prog_error ("duplicate extension $iter");
5191 $extension_map{$iter} = $language;
5196 # This function is used to find a path from a user-specified suffix to
5197 # `o' or to some other suffix we recognize internally, eg `cc'.
5200 my ($source_ext) = @_;
5202 # FIXME: hard-coding `o' is a mistake. Doing something
5203 # intelligent is harder.
5204 while ($extension_map{$source_ext} eq ''
5205 && $source_ext ne 'o'
5206 && defined $suffix_rules{$source_ext})
5208 $source_ext = $suffix_rules{$source_ext};
5215 ################################################################
5217 # Pretty-print something. HEAD is what should be printed at the
5218 # beginning of the first line, FILL is what should be printed at the
5219 # beginning of every subsequent line.
5220 sub pretty_print_internal
5222 my ($head, $fill, @values) = @_;
5224 my $column = length ($head);
5227 # Fill length is number of characters. However, each Tab
5228 # character counts for eight. So we count the number of Tabs and
5230 my $fill_length = length ($fill);
5231 $fill_length += 7 * ($fill =~ tr/\t/\t/d);
5233 my $bol = $head eq '';
5236 # "71" because we also print a space.
5237 if ($column + length ($_) > 71)
5239 $result .= " \\\n" . $fill;
5240 $column = $fill_length;
5244 $result .= ' ' unless $bol;
5246 $column += length ($_) + 1;
5254 # Pretty-print something and append to output_vars.
5257 $output_vars .= &pretty_print_internal (@_);
5260 # Pretty-print something and append to output_rules.
5261 sub pretty_print_rule
5263 $output_rules .= &pretty_print_internal (@_);
5267 ################################################################
5269 # See if a target exists.
5273 return defined $targets{$target};
5277 # &make_condition (@CONDITIONS)
5278 # -----------------------------
5279 # Transform a list of conditions (themselves can be an internal list
5280 # of conditions, e.g., @CONDITIONS = ('cond1 cond2', 'cond3')) into a
5281 # Make conditional (a pattern for AC_SUBST).
5282 # Correctly returns the empty string when there are no conditions.
5285 my $res = join ('@@', @_);
5289 $res = '@' . $res . '@';
5294 # See if two conditionals are the same.
5295 sub conditional_same
5297 my ($cond1, $cond2) = @_;
5299 return (&conditional_true_when ($cond1, $cond2)
5300 && &conditional_true_when ($cond2, $cond1));
5306 sub conditional_dump ()
5308 print STDERR "%conditional =\n";
5310 foreach my $var (sort keys %conditional)
5312 print STDERR " $var = \n";
5313 print STDERR " {\n";
5314 foreach my $vcond (sort by_condition keys %{$conditional{$var}})
5316 print STDERR " $vcond => $conditional{$var}{$vcond}\n";
5318 print STDERR " }\n";
5325 # &conditional_true_when ($COND, $WHEN)
5326 # -------------------------------------
5327 # See if a conditional is true. Both arguments are conditional
5328 # strings. This returns true if the first conditional is true when
5329 # the second conditional is true.
5330 # For instance with $COND = @FOO@@BAR@, and $WHEN = @FOO@@BAR@@BAZ@,
5331 # obviously return 1, and 0 when, for instance, $WHEN = @FOO@.
5332 sub conditional_true_when ($$)
5334 my ($cond, $when) = @_;
5336 # Check each component of $cond, which looks @COND1@@COND2@.
5337 foreach my $comp (split (' ', $cond))
5339 if (index ($when, $comp) == -1)
5350 # &conditionals_true_when (@CONDS, @WHENS)
5351 # ----------------------------------------
5352 # Same as above, but true if all the @CONDS are true when *ALL*
5353 # the @WHENS are sufficient.
5355 # If there are no @CONDS, then return true, of course. *BUT*, even if there
5356 # are @CONDS but @WHENS is empty, return true. This is counter intuitive,
5357 # and against all the rules of logic, but is needed by the current code.
5358 # FIXME: Do something saner when the logic of conditionals is understood.
5359 sub conditionals_true_when (@@)
5361 my (@conds, @whens) = @_;
5363 foreach my $cond (@conds)
5365 foreach my $when (@whens)
5368 unless conditional_true_when ($cond, $when);
5375 # Check for an ambiguous conditional. This is called when a variable
5376 # or target is being defined conditionally. If we already know about
5377 # a definition that is true under the same conditions, then we have an
5379 sub check_ambiguous_conditional ($$)
5381 my ($var, $cond) = @_;
5382 foreach my $vcond (keys %{$conditional{$var}})
5384 if (&conditional_true_when ($vcond, $cond)
5385 || &conditional_true_when ($cond, $vcond))
5387 &am_line_error ($var,
5388 "$var multiply defined in condition");
5395 # &variable_defined ($VAR, [$COND])
5396 # ---------------------------------
5397 # See if a variable exists. $VAR is the variable name, and $COND is
5398 # the condition which we should check. If no condition is given, we
5399 # currently return true if the variable is defined under any
5401 sub variable_defined ($$)
5403 my ($var, $cond) = @_;
5405 if (defined $contents{$var})
5407 if ($cond && $conditional{$var})
5409 # We have been asked to check for a particular condition,
5410 # and the variable is defined conditionally. We need to
5411 # look through the conditions under which the variable is
5412 # defined, and see if any of them match the conditional we
5413 # have been asked to check.
5414 foreach my $vcond (keys %{$conditional{$var}})
5416 if (&conditional_same ($cond, $vcond))
5418 # Even a conditional examination is good enough
5419 # for us. FIXME: really should maintain examined
5420 # status on a per-condition basis.
5421 $content_seen{$var} = 1;
5426 # The variable is not defined for the given condition.
5430 $content_seen{$var} = 1;
5434 &am_line_error ($var, "\`$var' is a target; expected a variable")
5435 if defined $targets{$var};
5440 # Mark a variable as examined.
5441 sub examine_variable
5444 &variable_defined ($var);
5447 # Return the set of conditions for which a variable is defined.
5449 # If the variable is not defined conditionally, and is not defined in
5450 # terms of any variables which are defined conditionally, then this
5451 # returns the empty list.
5453 # If the variable is defined conditionally, but is not defined in
5454 # terms of any variables which are defined conditionally, then this
5455 # returns the list of conditions for which the variable is defined.
5457 # If the variable is defined in terms of any variables which are
5458 # defined conditionally, then this returns a full set of permutations
5459 # of the subvariable conditions. For example, if the variable is
5460 # defined in terms of a variable which is defined for @COND_TRUE@,
5461 # then this returns both @COND_TRUE@ and @COND_FALSE@. This is
5462 # because we will need to define the variable under both conditions.
5464 sub variable_conditions
5471 foreach my $cond (&variable_conditions_sub ($var, '', ()))
5473 $uniqify{$cond} = 1;
5476 @uniq_list = sort by_condition keys %uniqify;
5477 # Note we cannot just do `return sort keys %uniqify', because this
5478 # function is sometimes used in a scalar context.
5482 # &variable_conditions_sub ($VAR, $PARENT, @PARENT_CONDS)
5483 # -------------------------------------------------------
5484 # A subroutine of variable_conditions. We only return conditions
5485 # which are true for all the conditions in @PARENT_CONDS.
5486 sub variable_conditions_sub
5488 my ($var, $parent, @parent_conds) = @_;
5491 if (defined $vars_scanned{$var})
5493 &am_line_error ($parent, "variable \`$var' recursively defined");
5496 $vars_scanned{$var} = 1;
5498 if (! $conditional{$var})
5500 foreach (split (' ', $contents{$var}))
5502 # If a comment seen, just leave.
5505 # Handle variable substitutions.
5506 if (/^\$\{(.*)\}$/ || /^\$\((.*)\)$/)
5509 &variable_conditions_sub ($1, $var, @parent_conds));
5513 # Now we want to return all permutations of the subvariable
5516 foreach my $item (@new_conds)
5518 foreach (split (' ', $item))
5521 $allconds{$_ . '_TRUE'} = 1;
5525 # Unset our entry in vars_scanned. We only care about recursive
5527 delete $vars_scanned{$var};
5529 return &variable_conditions_permutations (sort keys %allconds);
5532 my @this_conds = ();
5533 foreach my $vcond (keys %{$conditional{$var}})
5536 if ! conditionals_true_when ((@parent_conds), ($vcond));
5538 push (@this_conds, $vcond);
5540 push (@parent_conds, $vcond);
5541 my @subvar_conds = ();
5542 foreach (split (' ', ${$conditional{$var}}{$vcond}))
5544 # If a comment seen, just leave.
5547 # Handle variable substitutions.
5548 if (/^\$\{(.*)\}$/ || /^\$\((.*)\)$/)
5550 push (@subvar_conds,
5551 &variable_conditions_sub ($1, $var, @parent_conds));
5554 pop (@parent_conds);
5556 # If there are no conditional subvariables, then we want to
5557 # return this condition. Otherwise, we want to return the
5558 # permutations of the subvariables.
5559 if (! @subvar_conds)
5561 push (@new_conds, $vcond);
5565 push (@new_conds, &variable_conditions_reduce (@subvar_conds));
5569 # Unset our entry in vars_scanned. We only care about recursive
5571 delete $vars_scanned{$var};
5576 # If we are being called on behalf of another variable, we need to
5577 # return all possible permutations of the conditions. We have
5578 # already handled everything in @this_conds along with their
5579 # subvariables. We now need to add any permutations that are not
5581 foreach my $this_cond (@this_conds)
5584 &variable_conditions_permutations (split(' ', $this_cond));
5585 foreach my $perm (@perms)
5588 foreach my $scan (@this_conds)
5590 if (&conditional_true_when ($perm, $scan)
5591 || &conditional_true_when ($scan, $perm))
5600 if ! conditionals_true_when ((@parent_conds), ($perm));
5602 # This permutation was not already handled, and is valid
5604 push (@new_conds, $perm);
5612 # Compare condition names.
5613 # Issue them in alphabetical order, foo_TRUE before foo_FALSE.
5616 $a =~ /^(.*)_(TRUE|FALSE)$/;
5617 my ($aname, $abool) = ($1, $2);
5618 $b =~ /^(.*)_(TRUE|FALSE)$/;
5619 my ($bname, $bbool) = ($1, $2);
5620 return ($aname cmp $bname
5621 # Don't bother with IFs, given that TRUE is after FALSE
5622 # just cmp in the reverse order.
5623 || $bbool cmp $abool
5629 # Filter a list of conditionals so that only the exclusive ones are
5630 # retained. For example, if both `COND1_TRUE COND2_TRUE' and
5631 # `COND1_TRUE' are in the list, discard the latter.
5632 sub variable_conditions_reduce
5636 foreach my $cond (@conds)
5639 if ! conditionals_true_when (($cond), (@ret));
5646 # Return a list of permutations of a conditional string.
5647 sub variable_conditions_permutations
5652 my $comp = shift (@comps);
5653 return &variable_conditions_permutations (@comps)
5656 $neg =~ s/TRUE$/TRUEO/;
5657 $neg =~ s/FALSE$/TRUE/;
5658 $neg =~ s/TRUEO$/FALSE/;
5660 foreach my $sub (&variable_conditions_permutations (@comps))
5662 push (@ret, $comp . $sub);
5663 push (@ret, $neg . $sub);
5673 # Warn if a variable is conditionally defined. This is called if we
5674 # are using the value of a variable.
5675 sub variable_conditionally_defined
5677 my ($var, $parent) = @_;
5678 if ($conditional{$var})
5682 &am_line_error ($parent,
5683 "warning: automake does not support conditional definition of $var in $parent");
5687 &am_line_error ($parent,
5688 "warning: automake does not support $var being defined conditionally")
5693 # Get the value of a variable. This just returns $contents, but warns
5694 # if the variable is conditionally defined.
5698 &variable_conditionally_defined ($var);
5699 return $contents{$var};
5704 # &value_to_list ($VAR, $VAL, $COND)
5705 # ----------------------------------
5706 # Convert a variable value to a list, split as whitespace. This will
5707 # recursively follow $(...) and ${...} inclusions. It preserves @...@
5710 # If COND is 'all', then all values under all conditions should be
5711 # returned; if COND is a particular condition (all conditions are
5712 # surrounded by @...@) then only the value for that condition should
5713 # be returned; otherwise, warn if VAR is conditionally defined.
5714 # SCANNED is a global hash listing whose keys are all the variables
5715 # already scanned; it is an error to rescan a variable.
5718 my ($var, $val, $cond) = @_;
5722 $val =~ s/\\(\n|$)/ /g;
5724 foreach (split (' ', $val))
5726 # If a comment seen, just leave.
5729 # Handle variable substitutions.
5730 if (/^\$\{([^}]*)\}$/ || /^\$\(([^)]*)\)$/)
5734 # If the user uses a losing variable name, just ignore it.
5735 # This isn't ideal, but people have requested it.
5736 next if ($varname =~ /\@.*\@/);
5740 if ($varname =~ /^([^:]*):([^=]*)=(.*)$/)
5744 ($from = $2) =~ s/(\W)/\\$1/g;
5748 @temp_list = &variable_value_as_list_worker ($1, $cond, $var);
5750 # Now rewrite the value if appropriate.
5753 grep (s/$from$/$to/, @temp_list);
5756 push (@result, @temp_list);
5767 # Return contents of variable as list, split as whitespace. This will
5768 # recursively follow $(...) and ${...} inclusions. It preserves @...@
5769 # substitutions. If COND is 'all', then all values under all
5770 # conditions should be returned; if COND is a particular condition
5771 # (all conditions are surrounded by @...@) then only the value for
5772 # that condition should be returned; otherwise, warn if VAR is
5773 # conditionally defined. If PARENT is specified, it is the name of
5774 # the including variable; this is only used for error reports.
5775 sub variable_value_as_list_worker
5777 my ($var, $cond, $parent) = @_;
5780 if (! defined $contents{$var} && ! defined $am_var_defs{$var})
5782 if (defined $targets{$var})
5784 &am_line_error ($var, "\`$var' is a target; expected a variable");
5788 &am_line_error ($parent, "variable \`$var' not defined");
5791 elsif (defined $vars_scanned{$var})
5793 # `vars_scanned' is a global we use to keep track of which
5794 # variables we've already examined.
5795 &am_line_error ($parent, "variable \`$var' recursively defined");
5797 elsif ($cond eq 'all' && $conditional{$var})
5799 $vars_scanned{$var} = 1;
5800 foreach my $vcond (keys %{$conditional{$var}})
5802 my $val = ${$conditional{$var}}{$vcond};
5803 push (@result, &value_to_list ($var, $val, $cond));
5806 elsif ($cond && $conditional{$var})
5808 $vars_scanned{$var} = 1;
5810 foreach my $vcond (keys %{$conditional{$var}})
5812 my $val = ${$conditional{$var}}{$vcond};
5813 if (&conditional_true_when ($vcond, $cond))
5815 # Warn if we have an ambiguity. It's hard to know how
5816 # to handle this case correctly.
5817 &variable_conditionally_defined ($var, $parent)
5820 push (@result, &value_to_list ($var, $val, $cond));
5824 elsif (defined $am_var_defs{$var})
5826 $vars_scanned{$var} = 1;
5827 &variable_conditionally_defined ($var, $parent);
5828 $content_seen{$var} = 1;
5829 push (@result, &value_to_list ($var, $am_var_defs{$var}, $cond));
5833 $vars_scanned{$var} = 1;
5834 &variable_conditionally_defined ($var, $parent);
5835 $content_seen{$var} = 1;
5836 push (@result, &value_to_list ($var, $contents{$var}, $cond));
5839 # Unset our entry in vars_scanned. We only care about recursive
5841 delete $vars_scanned{$var};
5846 # This is just a wrapper for variable_value_as_list_worker that
5847 # initializes the global hash `vars_scanned'. This hash is used to
5848 # avoid infinite recursion.
5849 sub variable_value_as_list
5851 my ($var, $cond, $parent) = @_;
5853 return &variable_value_as_list_worker ($var, $cond, $parent);
5857 # define_variable ($VAR, $VALUE)
5858 # ------------------------------
5859 # Define a new variable VAR to VALUE, but only if not already defined.
5862 my ($var, $value) = @_;
5864 if (! defined $contents{$var})
5866 $output_vars .= $var . ' = ' . $value . "\n";
5867 $contents{$var} = $value;
5868 $content_seen{$var} = 1;
5870 elsif ($var_was_plus_eq{$var})
5872 &am_line_error ($var,
5873 "internally generated variable \`$var' was set with \`+='");
5877 # Like define_variable, but the value is a list, and the variable may
5878 # be defined conditionally. The second argument is the conditional
5879 # under which the value should be defined; this should be the empty
5880 # string to define the variable unconditionally. The third argument
5881 # is a list holding the values to use for the variable. The value is
5882 # pretty printed in the output file.
5883 sub define_pretty_variable
5885 my ($var, $cond, @value) = @_;
5886 if (! defined $contents{$var}
5887 || ($cond && ! &variable_defined ($var, $cond)))
5889 $contents{$var} = join (' ', @value);
5892 ${$conditional{$var}}{$cond} = $contents{$var};
5894 my $make_condition = &make_condition ($cond);
5895 &pretty_print ($make_condition . $var . ' = ',
5896 $make_condition, @value);
5897 $content_seen{$var} = 1;
5901 # Like define_variable, but define a variable to be the configure
5902 # substitution by the same name.
5903 sub define_configure_variable
5906 my $value = '@' . $var . '@';
5907 &define_variable ($var, $value);
5910 # Define a compiler variable. We also handle defining the `LT'
5911 # version of the command when using libtool.
5912 sub define_compiler_variable
5914 my ($var, $ltcompile, $value) = @_;
5916 &define_variable ($name, $value);
5917 &define_variable ('LT' . $name, $ltcompile . $value)
5921 # Define a variable that represents a program to run. If in Cygnus
5922 # mode, the program is searched for in the build (or source) tree.
5923 # Otherwise no searching is done at all. Arguments are:
5924 # * VAR Name of variable to define
5925 # * WHATDIR Either `src' or `build', depending on where program should
5926 # be found. (runtest is in srcdir!)
5927 # * SUBDIR Subdir of top-level dir
5928 # * PROGRAM Name of program
5929 # * OVERRIDE If specified, the name of the program to use when not in
5930 # Cygnus mode. Defaults to PROGRAM.
5931 sub define_program_variable
5933 my ($var, $whatdir, $subdir, $program, $override) = @_;
5937 $override = $program;
5942 my $full = ('$(top_' . $whatdir . 'dir)/../'
5943 . $subdir . '/' . $program);
5944 &define_variable ($var, ('`if test -f ' . $full
5945 . '; then echo ' . $full . '; else echo '
5946 . $program . '; fi`'));
5950 &define_variable ($var, $override);
5955 ################################################################
5957 # Read Makefile.am and set up %contents. Simultaneously copy lines
5958 # from Makefile.am into $output_trailer or $output_vars as
5959 # appropriate. NOTE we put rules in the trailer section. We want
5960 # user rules to come after our generated stuff.
5965 my $am_file = new IO::File ("< $amfile");
5968 die "automake: couldn't open \`$amfile': $!\n";
5970 print "automake: reading $amfile\n" if $verbose;
5976 while ($_ = $am_file->getline)
5978 if (/$IGNORE_PATTERN/o)
5980 # Merely delete comments beginning with two hashes.
5982 elsif (/$WHITE_PATTERN/o)
5984 # Stick a single white line before the incoming macro or rule.
5988 elsif (/$COMMENT_PATTERN/o)
5990 # Stick comments before the incoming macro or rule. Make
5991 # sure a blank line preceeds first block of comments.
5992 $spacing = "\n" unless $blank;
5994 $comment .= $spacing . $_;
6003 $output_vars .= $comment . "\n";
6007 # We save the conditional stack on entry, and then check to make
6008 # sure it is the same on exit. This lets us conditonally include
6010 my @saved_cond_stack = @conditional_stack;
6015 my $last_var_name = '';
6019 unless substr ($_, -1, 1) eq "\n";
6021 # Don't look at MAINTAINER_MODE_TRUE here. That shouldn't be
6022 # used by users. @MAINT@ is an anachronism now.
6023 $_ =~ s/\@MAINT\@//g
6024 unless $seen_maint_mode;
6026 if (/$IGNORE_PATTERN/o)
6028 # Merely delete comments beginning with two hashes.
6030 elsif (/$WHITE_PATTERN/o)
6032 # Stick a single white line before the incoming macro or rule.
6034 &am_line_error ($., "blank line following trailing backslash")
6037 elsif (/$COMMENT_PATTERN/o)
6039 # Stick comments before the incoming macro or rule.
6040 $comment .= $spacing . $_;
6042 &am_line_error ($., "comment following trailing backslash")
6049 $output_trailer .= &make_condition (@conditional_stack);
6050 $output_trailer .= $_;
6056 $contents{$last_var_name} .= ' '
6057 unless $contents{$last_var_name} =~ /\s$/;
6058 $contents{$last_var_name} .= $_;
6059 if (@conditional_stack)
6061 my $cond_string = join (' ', @conditional_stack);
6062 ${conditional{$last_var_name}}{$cond_string} .= $_;
6066 elsif (/$IF_PATTERN/o)
6068 &am_line_error ($., "$1 does not appear in AM_CONDITIONAL")
6069 if (! $configure_cond{$1});
6070 push (@conditional_stack, "$1_TRUE");
6072 elsif (/$ELSE_PATTERN/o)
6074 if (! @conditional_stack)
6076 &am_line_error ($., "else without if");
6078 elsif ($conditional_stack[$#conditional_stack] =~ /_FALSE$/)
6080 &am_line_error ($., "else after else");
6084 $conditional_stack[$#conditional_stack]
6085 =~ s/_TRUE$/_FALSE/;
6088 elsif (/$ENDIF_PATTERN/o)
6090 if (! @conditional_stack)
6092 &am_line_error ($., "endif without if");
6096 pop @conditional_stack;
6099 elsif (/$RULE_PATTERN/o)
6103 if (defined $targets{$1}
6104 && (@conditional_stack
6105 ? ! defined $target_conditional{$1}
6106 : defined $target_conditional{$1}))
6109 "$1 defined both conditionally and unconditionally");
6111 # Value here doesn't matter; for targets we only note
6114 if (@conditional_stack)
6116 my $cond_string = join (' ', @conditional_stack);
6117 if ($target_conditional{$1})
6119 &check_ambiguous_conditional ($1, $cond_string);
6121 ${$target_conditional{$1}}{$cond_string} = '1';
6123 $content_lines{$1} = $.;
6124 $output_trailer .= $comment . $spacing;
6125 $output_trailer .= &make_condition (@conditional_stack);
6126 $output_trailer .= $_;
6127 $comment = $spacing = '';
6130 # Check the rule for being a suffix rule. If so, store in
6136 if (($source_suffix, $object_suffix)
6137 = ($1 =~ $SUFFIX_RULE_PATTERN))
6139 $suffix_rules{$source_suffix} = $object_suffix;
6140 print "Sources ending in .$source_suffix become .$object_suffix\n"
6142 $source_suffix_pattern = "(" . join ('|', keys %suffix_rules) . ")";
6145 # FIXME: make sure both suffixes are in SUFFIXES? Or set
6146 # SUFFIXES from suffix_rules?
6148 elsif (($is_ok_macro = /$MACRO_PATTERN/o)
6149 || /$BOGUS_MACRO_PATTERN/o)
6151 # Found a macro definition.
6153 $last_var_name = $1;
6154 if (defined $contents{$1}
6155 && (@conditional_stack
6156 ? ! defined $conditional{$1}
6157 : defined $conditional{$1}))
6160 "$1 defined both conditionally and unconditionally");
6163 if ($3 ne '' && substr ($3, -1) eq "\\")
6165 # We preserve the `\' because otherwise the long lines
6166 # that are generated will be truncated by broken
6176 if (! defined $contents{$last_var_name})
6178 # The first assignment to a macro sets the line
6179 # number. Ideally I suppose we would associate line
6180 # numbers with random bits of text.
6181 $content_lines{$last_var_name} = $.;
6183 # If first assignment, set `+=' indicator.
6184 $var_was_plus_eq{$last_var_name} =
6186 && ! defined $am_var_defs{$last_var_name});
6191 if (! defined $contents{$last_var_name}
6192 && defined $am_var_defs{$last_var_name})
6194 $contents{$last_var_name} = $am_var_defs{$last_var_name};
6196 if (substr ($contents{$last_var_name}, -1) eq "\n")
6198 # Insert a backslash before a trailing newline.
6199 $contents{$last_var_name}
6200 = substr ($contents{$last_var_name}, 0, -1) . "\\\n";
6202 $contents{$last_var_name} .= ' ' . $value;
6206 $contents{$last_var_name} = $value;
6209 # Handle conditionalized macros.
6210 if (@conditional_stack)
6212 my $cond_string = join (' ', @conditional_stack);
6214 if ($conditional{$last_var_name})
6218 # If we're adding to the conditional, and it
6219 # exists, then we might want to simply replace
6220 # the old value with the new one.
6221 foreach my $vcond (keys %{$conditional{$last_var_name}})
6223 if (&conditional_same ($vcond, $cond_string))
6226 ${$conditional{$last_var_name}}{$vcond}
6234 &check_ambiguous_conditional ($last_var_name,
6236 ${$conditional{$last_var_name}}{$cond_string} = $value;
6240 # FIXME: this doesn't always work correctly; it will group
6241 # all comments for a given variable, no matter where
6243 $am_vars{$last_var_name} = $comment . $spacing;
6244 $def_type{$last_var_name} = ($type eq ':') ? ':' : '';
6245 push (@var_list, $last_var_name);
6246 $comment = $spacing = '';
6250 &am_line_error ($., "bad macro name \`$last_var_name'")
6253 elsif (/$INCLUDE_PATTERN/o)
6257 if ($path =~ s/^\$\(top_srcdir\)\///)
6259 push (@include_stack, "\$\(top_srcdir\)/$path");
6263 $path =~ s/\$\(srcdir\)\///;
6264 push (@include_stack, "\$\(srcdir\)/$path");
6265 $path = $relative_dir . "/" . $path;
6267 &read_am_file ($path);
6271 # This isn't an error; it is probably a continued rule.
6272 # In fact, this is what we assume.
6274 $output_trailer .= $comment . $spacing;
6275 $output_trailer .= &make_condition (@conditional_stack);
6276 $output_trailer .= $_;
6277 $comment = $spacing = '';
6281 $_ = $am_file->getline;
6284 $output_trailer .= $comment;
6286 if (join (' ', @saved_cond_stack) ne join (' ', @conditional_stack))
6288 if (@conditional_stack)
6290 &am_error ("unterminated conditionals: @conditional_stack");
6294 # FIXME: better error message here.
6295 &am_error ("conditionals not nested in include file");
6301 # define_standard_variables ()
6302 # ----------------------------
6303 # A helper for read_main_am_file which initializes configure variables
6304 # and variables from header-vars.am. This is a subr so we can call it
6306 sub define_standard_variables
6309 &file_contents ('header-vars',
6311 ('BUILD' => $seen_canonical == $AC_CANONICAL_SYSTEM,
6312 'HOST' => $seen_canonical,
6313 'TARGET' => $seen_canonical == $AC_CANONICAL_SYSTEM)
6315 ('top_builddir' => backname ($relative_dir)));
6317 foreach my $curs (sort keys %configure_vars)
6319 &define_configure_variable ($curs);
6323 # Read main am file.
6324 sub read_main_am_file
6328 # The keys here are variables we want to dump at the end of this
6329 # function. The values are corresponding comments.
6330 # Need dynamic scopes.
6331 local %am_vars = ();
6332 local @var_list = ();
6333 local %def_type = ();
6335 # This supports the strange variable tricks we are about to play.
6336 &prog_error ("variable defined before read_main_am_file")
6337 if scalar keys %contents > 0;
6339 # We want to predefine as many variables as possible. This lets
6340 # the user set them with `+=' in Makefile.am. However, we don't
6341 # want these initial definitions to end up in the output quite
6342 # yet. So we adopt a hack: read the `.am' file twice, throwing
6343 # away the output the first time. We also squirrel away a list of
6344 # all the variables defined by the .am file so that we know which
6345 # ones to remove from the content list.
6348 &define_standard_variables;
6349 my %saved_contents = %contents;
6351 # Read user file, but discard text of variable assignments we just
6354 &read_am_file ($amfile);
6356 # Now dump the variables that were defined. We do it in the same
6357 # order in which they were defined (skipping duplicates).
6359 foreach my $var (@var_list)
6365 $output_vars .= $am_vars{$var};
6366 if ($conditional{$var})
6368 foreach my $vcond (sort by_condition keys %{$conditional{$var}})
6370 my $val = ${$conditional{$var}}{$vcond};
6371 my $output_var = ($var . ' '
6372 . $def_type{$var} . "= "
6374 $output_var =~ s/^/&make_condition ($vcond)/meg;
6375 $output_vars .= $output_var . "\n";
6380 $output_vars .= ($var . ' ' . $def_type{$var} . '= '
6381 . $contents{$var} . "\n");
6385 # Generate copyright header for generated Makefile.in.
6386 my $ov = $output_vars;
6387 $output_vars = ("# $in_file_name generated automatically by automake "
6388 . $VERSION . " from $am_file_name\n");
6389 $output_vars .= $gen_copyright;
6391 # Now go through and delete all the variables that the user did
6393 foreach my $var (keys %saved_contents)
6395 if ($contents{$var} eq $saved_contents{$var})
6397 delete $contents{$var};
6401 # Re-read the standard variables, and this time keep their
6402 # contributions to the output. Then add the user's output to the
6404 &define_standard_variables;
6405 $output_vars .= $ov;
6408 ################################################################
6410 sub initialize_global_constants
6412 # Values for AC_CANONICAL_*
6413 $AC_CANONICAL_HOST = 1;
6414 $AC_CANONICAL_SYSTEM = 2;
6416 # Commonly found files we look for and automatically include in
6420 'README', 'THANKS', 'TODO', 'NEWS', 'COPYING', 'COPYING.LIB',
6421 'INSTALL', 'ABOUT-NLS', 'ChangeLog', 'configure.ac',
6422 'configure.in', 'configure', 'config.guess', 'config.sub',
6423 'AUTHORS', 'BACKLOG', 'ABOUT-GNU', 'libversion.in',
6424 'mdate-sh', 'mkinstalldirs', 'install-sh', 'texinfo.tex',
6425 'ansi2knr.c', 'ansi2knr.1', 'elisp-comp',
6426 # ltconfig appears here for compatibility with old versions
6428 'ylwrap', 'acinclude.m4', @libtoolize_files, @libtoolize_sometimes,
6429 'missing', 'depcomp', 'compile', 'py-compile'
6432 # Commonly used files we auto-include, but only sometimes.
6435 'aclocal.m4', 'acconfig.h', 'config.h.top',
6436 'config.h.bot', 'stamp-h.in', 'stamp-vti'
6439 # Copyright on generated Makefile.ins.
6441 # Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
6442 # Free Software Foundation, Inc.
6443 # This Makefile.in is free software; the Free Software Foundation
6444 # gives unlimited permission to copy and/or distribute it,
6445 # with or without modifications, as long as this notice is preserved.
6447 # This program is distributed in the hope that it will be useful,
6448 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
6449 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
6450 # PARTICULAR PURPOSE.
6454 # (Re)-Initialize per-Makefile.am variables.
6455 sub initialize_per_input
6457 # These two variables are used when generating each Makefile.in.
6458 # They hold the Makefile.in until it is ready to be printed.
6461 $output_trailer = '';
6463 $output_header = '';
6465 # Suffixes found during a run.
6468 # This holds the contents of a Makefile.am, as parsed by
6472 # This maps a variable name onto a flag. The flag is true iff the
6473 # variable was first defined with `+='.
6474 %var_was_plus_eq = ();
6476 # This holds definitions of all variables defined in .am files.
6477 # This is used during startup to determine which variables can be
6478 # assigned with `+='.
6481 # For a variable or target $ITEM which is defined conditionally,
6482 # this holds a hash of the conditional values. The keys of
6483 # %CONDITIONAL{$ITEM} are the conditions (the variables which
6484 # configure will substitute), and the values, the associated
6485 # values (meaningless for targets).
6487 # By definition, for an unconditional variable, this is empty.
6490 # This holds the line numbers at which various elements of
6491 # %contents are defined.
6492 %content_lines = ();
6494 # This holds a 1 if a particular variable was examined.
6497 # This holds the names which are targets. These also appear in
6501 # Same as %CONDITIONAL, but for targets.
6502 %target_conditional = ();
6504 # This is the conditional stack.
6505 @conditional_stack = ();
6507 # This holds the set of included files.
6508 @include_stack = ();
6510 # This holds the "relative directory" of the current Makefile.in.
6511 # Eg for src/Makefile.in, this is "src".
6514 # This holds a list of files that are included in the
6518 # This holds a list of directories which we must create at `dist'
6519 # time. This is used in some strange scenarios involving weird
6520 # AC_OUTPUT commands.
6523 # List of dependencies for the obvious targets.
6530 # Holds the dependencies of targets which dependencies are factored.
6531 # Typically, `.PHONY' will appear in plenty of *.am files, but must
6532 # be output once. Arguably all pure dependencies could be subject
6533 # to this factorization, but it is not unpleasant to have paragraphs
6534 # in Makefile: keeping related stuff altogether.
6537 # Installing/uninstalling.
6538 'install-data-am' => [],
6539 'install-exec-am' => [],
6540 'install-man' => [],
6541 'uninstall-man' => [],
6542 'uninstall-am' => [],
6543 'installcheck-am' => [],
6547 'mostlyclean-am' => [],
6548 'maintainer-clean-am' => [],
6549 'distclean-am' => [],
6551 'mostlyclean' => [],
6552 'maintainer-clean' => [],
6561 # Holds the factored actions. Tied to %DEPENDENCIES, i.e., filled
6562 # only when keys exists in %DEPENDENCIES.
6565 # A list of files deleted by `maintainer-clean'.
6566 @maintainer_clean_files = ();
6568 # These are pretty obvious, too. They are used to define the
6569 # SOURCES and OBJECTS variables.
6572 # Sources which go in the distribution.
6575 # This hash maps object file names onto their corresponding source
6576 # file names. This is used to ensure that each object is created
6577 # by a single source file.
6580 # This keeps track of the directories for which we've already
6581 # created `.dirstamp' code.
6582 %directory_map = ();
6584 # These variables track inclusion of various compile-related .am
6585 # files. $included_generic_compile is TRUE if the basic code has
6586 # been included. $included_knr_compile is TRUE if the ansi2knr
6587 # code has been included. $included_libtool_compile is TRUE if
6588 # libtool support has been included.
6589 $included_generic_compile = 0;
6590 $included_knr_compile = 0;
6591 $included_libtool_compile = 0;
6596 # Strictness levels.
6597 $strictness = $default_strictness;
6598 $strictness_name = $default_strictness_name;
6600 # Options from AUTOMAKE_OPTIONS.
6603 # Whether or not dependencies are handled. Can be further changed
6604 # in handle_options.
6605 $use_dependencies = $cmdline_use_dependencies;
6608 $local_maint_charset = $maint_charset;
6610 # All yacc and lex source filenames for this directory. Use
6611 # filenames instead of raw count so that multiple instances are
6612 # counted correctly (eg one yacc file can appear in multiple
6613 # programs without harm).
6617 # This is a list of all targets to run during "make dist".
6620 # Keys in this hash are the basenames of files which must depend
6622 %de_ansi_files = ();
6624 # This maps the source extension of a suffix rule to its
6625 # corresponding output extension.
6628 # This is a regular expression which matches all the known source
6629 # suffix. A source suffix is one that appears in the first
6630 # position of a suffix rule.
6631 $source_suffix_pattern = '';
6633 # This is the name of the redirect `all' target to use.
6636 # This keeps track of which extensions we've seen (that we care
6638 %extension_seen = ();
6640 # This is random scratch space for the language finish functions.
6641 # Don't randomly overwrite it; examine other uses of keys first.
6642 %language_scratch = ();
6644 # We keep track of which objects need special (per-executable)
6645 # handling on a per-language basis.
6646 %lang_specific_files = ();
6648 # This is set when `handle_dist' has finished. Once this happens,
6649 # we should no longer push on dist_common.
6650 $handle_dist_run = 0;
6652 # True if we need `LINK' defined. This is a hack.
6657 ################################################################
6660 # &flatten ($STRING)
6661 # ------------------
6662 # Flatten the $STRING and return the result.
6677 # &file_contents ($BASENAME, [$COMMAND])
6678 # --------------------------------------
6679 # Return contents of a file from $am_dir, automatically skipping
6680 # macros or rules which are already known. Runs command on each line
6681 # as it is read; this command can modify $_.
6684 my ($basename, $command) = @_;
6686 # Sanity check over COMMAND, and complete it with global options.
6687 &prog_error ("file_contents: $command")
6688 if $command ne '' && substr ($command, -1) ne ';';
6690 &transform_cond ('CYGNUS' => $cygnus_mode,
6692 'SHAR' => $options{'dist-shar'},
6693 'BZIP2' => $options{'dist-bzip2'},
6694 'ZIP' => $options{'dist-zip'},
6695 'COMPRESS' => $options{'dist-tarZ'},
6697 'INSTALL-INFO' => !$options{'no-installinfo'},
6698 'INSTALL-MAN' => !$options{'no-installman'},
6699 'CK-NEWS' => $options{'check-news'},
6701 'SUBDIRS' => &variable_defined ('SUBDIRS'));
6703 # Swallow the file and applied the COMMAND.
6704 my $file = $am_dir . '/' . $basename . '.am';
6705 my $fc_file = new IO::File ("< $file");
6708 die "automake: installation error: cannot open \`$file'\n";
6711 # print "automake: reading $file\n" if $verbose;
6713 # Swallow into $CONTENTS the whole content of the file, after
6714 # having performed the $COMMAND, and removed Automake comments.
6717 while ($_ = $fc_file->getline)
6719 $_ =~ s/\@MAINTAINER_MODE_TRUE\@//g
6720 unless $seen_maint_mode;
6722 $had_chars = length ($_) && $_ ne "\n";
6724 # If the transform caused all the characters to go away, then
6725 # ignore the line. Why do this? Because in Perl 4, a "next"
6726 # inside of an eval doesn't affect a loop outside the eval.
6727 # So we can't pass in a "transform" that uses next. We used
6728 # to do this. "Empty" also means consisting of a single
6730 next if $had_chars && ($_ eq '' || $_ eq "\n");
6732 # Merely delete comments beginning with two hashes.
6733 next if /$IGNORE_PATTERN/o;
6740 # We don't need more than two consecutive new-lines.
6741 $contents =~ s/\n{3,}/\n\n/g;
6743 # A rule has three parts: a list of targets, a list of dependencies,
6744 # and optionally actions.
6746 "^($TARGET_PATTERN(?:(?:\\\\\n|\\s)+$TARGET_PATTERN)*) *:([^=].*|)\$";
6749 # Process each Make `paragraph'.
6751 # A Make `paragraph' is delimited by a new line which is not
6752 # escaped, and not followed by a tab or a comment.
6754 # Frankly, unless you like fighting with Perl (you're a freak!),
6755 # if I were you I would not try some other implementation, it's
6756 # very easy falling either into extremely low RE matching
6757 # (backtracking...), or worse yet: infloop... For instance, (my)
6758 # perl goes loopy if you try to
6760 # $result_rules =~ /^($TARGET_PATTERN *)+: ($TARGET_PATTERN *)+\n\n/sm
6761 my $result_vars = '';
6762 my $result_rules = '';
6764 foreach (split (/(?<!\\)\n(?![\t#])/, $contents))
6766 # Strip leading new lines. This can happen for comments:
6767 # the pattern above allows `\n\n# comment' to yield
6772 &am_file_error ("$basename.am",
6773 "blank line following trailing backslash:\n$_")
6775 &am_file_error ("$basename.am",
6776 "comment following trailing backslash:\n$_")
6781 # Stick empty line before the incoming macro or rule.
6784 elsif (/$COMMENT_PATTERN/mso)
6786 # Stick comments before the incoming macro or rule.
6789 elsif (/$RULE_PATTERN/mso)
6791 # Separate relationship from optional actions: the first
6792 # `new-line tab" not preceded by backslash (continuation
6794 # I'm quite shoked! It seems that (\\\n|[^\n]) is not the
6795 # same as `([^\n]|\\\n)!!! Don't swap it, it breaks.
6796 my ($relationship, $actions) =
6797 /^((?:\\\n|[^\n])*)(?:\n(\t.*))?$/som;
6799 # Separate targets from dependencies: the first colon.
6800 $relationship =~ /^([^:]+\S+) *: *(.*)$/som;
6801 my ($targets, $dependencies) = ($1, $2);
6802 # Remove the escaped new lines.
6803 # I don't know why, but I have to use a tmp $flat_deps.
6804 my $flat_deps = &flatten ($dependencies);
6805 my @deps = split (' ', $flat_deps);
6807 foreach (split (' ' , $targets))
6809 if (defined $dependencies{$_})
6811 &depend ($_, @deps);
6812 $actions{$_} .= $actions;
6816 # Free lance dependency. Output the rule for all the
6817 # targets instead of one by one.
6818 if (!defined $targets{$targets})
6820 # Some hair to avoid spurious trailing blank
6821 # when there are no dependencies.
6822 $result_rules .= "$separator$comment";
6823 $result_rules .= "$targets:";
6824 $result_rules .= " $dependencies"
6826 $result_rules .= "\n";
6827 # Only add actions if we found some. Otherwise
6828 # we can end up with a spurious newline. See
6830 $result_rules .= "$actions\n"
6833 $comment = $separator = '';
6838 elsif (/$MACRO_PATTERN/mso)
6840 my ($var, $type, $val) = ($1, $2, $3);
6841 &prog_error ("$file:$.: macro \`$var' with trailing backslash")
6843 # Accumulating variables must not be output.
6846 $am_var_defs{$var} .= ($am_var_defs{$var} && ' ') . $val;
6850 $am_var_defs{$var} = $val;
6851 $result_vars .= "$separator$comment$_\n"
6852 unless defined $contents{$var};
6854 $comment = $separator = '';
6858 # This isn't an error; it is probably some tokens which
6859 # configure is supposed to replace, such as `@SET-MAKE@'.
6860 $result_rules .= "$separator$comment$_\n";
6861 $comment = $separator = '';
6865 return $result_vars . $result_rules . $comment;
6870 # &transform (%PAIRS)
6871 # -------------------
6872 # Create a replacement expression suitable for file_contents
6873 # to replace each key of %PAIRS by its value. Also uses &transform_cond
6880 while (my ($token, $val) = each %pairs)
6882 $result .= "s/\Q\@$token\@\E/\Q$val\E/g;";
6885 $result .= &transform_cond (%pairs);
6891 # &transform_cond (%PAIRS)
6892 # ------------------------
6893 # For each pair ($TOKEN => $COND), if $COND is positive then create a regexp
6894 # that removes `?$TOKEN?', otherwise that removes the whole line containing
6895 # `?$TOKEN?'. Do the converse for the token `?!$TOKEN?'.
6896 sub transform_cond (%)
6901 while (my ($token, $val) = each %pairs)
6905 $result .= "s/\Q?$token?\E//g;s/^.*\Q?!$token?\E.*\$//g;";
6909 $result .= "s/\Q?!$token?\E//g;s/^.*\Q?$token?\E.*\$//g;";
6916 # Find all variable prefixes that are used for install directories. A
6917 # prefix `zar' qualifies iff:
6918 # * `zardir' is a variable.
6919 # * `zar_PRIMARY' is a variable.
6920 sub am_primary_prefixes
6922 my ($primary, $can_dist, @prefixes) = @_;
6925 grep ($valid{$_} = 0, @prefixes);
6926 $valid{'EXTRA'} = 0;
6927 foreach my $varname (keys %contents)
6929 if ($varname =~ /^(nobase_)?(dist_|nodist_)?(.*)_$primary$/)
6931 if (($2 ne '' && ! $can_dist)
6932 || (! defined $valid{$3} && ! &variable_defined ($3 . 'dir')))
6934 # Note that a configure variable is always legitimate.
6935 # It is natural to name such variables after the
6936 # primary, so we explicitly allow it.
6937 if (! defined $configure_vars{$varname})
6939 &am_line_error ($varname, "invalid variable \`$varname'");
6944 # Ensure all extended prefixes are actually used.
6945 $valid{$1 . $2 . $3} = 1;
6953 # Handle `where_HOW' variable magic. Does all lookups, generates
6954 # install code, and possibly generates code to define the primary
6955 # variable. The first argument is the name of the .am file to munge,
6956 # the second argument is the primary variable (eg HEADERS), and all
6957 # subsequent arguments are possible installation locations. Returns
6958 # list of all values of all _HOW targets.
6960 # FIXME: this should be rewritten to be cleaner. It should be broken
6961 # up into multiple functions.
6963 # Usage is: am_install_var (OPTION..., file, HOW, where...)
6969 if (defined $configure_vars{'LIBTOOL'})
6971 # Transform '@LIBTOOL ...@' to '$(LIBTOOL) ...'
6972 $ltxform = 's/\@LIBTOOL([^\@]*)\@/\$(LIBTOOL) $1/;';
6976 # Delete '@LIBTOOL ...@'
6977 $ltxform = 's/\@LIBTOOL([^\@]*)\@//;';
6983 $cygxform = 's/\@EXEEXT\@//g;';
6987 $cygxform = 's/\@EXEEXT\@/\$(EXEEXT)/g;';
6993 my $default_dist = 0;
6996 if ($args[0] eq '-clean')
7000 elsif ($args[0] eq '-noextra')
7004 elsif ($args[0] eq '-candist')
7008 elsif ($args[0] eq '-defaultdist')
7013 elsif ($args[0] !~ /^-/)
7020 my ($file, $primary, @prefixes) = @args;
7022 # Now that configure substitutions are allowed in where_HOW
7023 # variables, it is an error to actually define the primary. We
7024 # allow `JAVA', as it is customarily used to mean the Java
7025 # interpreter. This is but one of several Java hacks. Similarly,
7026 # `PYTHON' is customarily used to mean the Python interpreter.
7027 &am_line_error ($primary, "\`$primary' is an anachronism")
7028 if &variable_defined ($primary)
7029 && ($primary ne 'JAVA' && $primary ne 'PYTHON');
7032 # Look for misspellings. It is an error to have a variable ending
7033 # in a "reserved" suffix whose prefix is unknown, eg
7034 # "bni_PROGRAMS". However, unusual prefixes are allowed if a
7035 # variable of the same name (with "dir" appended) exists. For
7036 # instance, if the variable "zardir" is defined, then
7037 # "zar_PROGRAMS" becomes valid. This is to provide a little extra
7038 # flexibility in those cases which need it.
7039 my %valid = &am_primary_prefixes ($primary, $can_dist, @prefixes);
7041 # If a primary includes a configure substitution, then the EXTRA_
7042 # form is required. Otherwise we can't properly do our job.
7044 my $warned_about_extra = 0;
7049 foreach my $X (sort keys %valid)
7051 my $one_name = $X . '_' . $primary;
7052 if (&variable_defined ($one_name))
7054 my $strip_subdir = 1;
7055 # If subdir prefix should be preserved, do so.
7056 if ($X =~ /^nobase_/)
7063 # If files should be distributed, do so.
7066 if (($default_dist && $one_name !~ /^nodist_/)
7067 || (! $default_dist && $one_name =~ /^dist_/))
7069 &push_dist_common ('$(' . $one_name . ')');
7071 ($nodir_name = $X) =~ s/^(dist|nodist)_//;
7078 # Append actual contents of where_PRIMARY variable to
7080 foreach my $rcurs (&variable_value_as_list ($one_name, 'all'))
7082 # Skip configure substitutions. Possibly bogus.
7083 if ($rcurs =~ /^\@.*\@$/)
7087 if (! $warned_about_extra)
7089 $warned_about_extra = 1;
7090 &am_line_error ($one_name,
7091 "\`$one_name' contains configure substitution, but shouldn't");
7094 # Check here to make sure variables defined in
7095 # configure.ac do not imply that EXTRA_PRIMARY
7097 elsif (! defined $configure_vars{$one_name})
7099 $require_extra = $one_name
7106 push (@result, $rcurs);
7109 # A blatant hack: we rewrite each _PROGRAMS primary to
7110 # include EXEEXT when in Cygwin32 mode.
7111 if ($seen_exeext && $primary eq 'PROGRAMS')
7113 my @conds = &variable_conditions ($one_name);
7115 # FIXME: This code is mad, rewrite!
7117 # FIXME: this definitely loses aesthetically; it
7118 # redefines $ONE_NAME. Instead we should arrange for
7119 # variable definitions to be output later, instead of
7124 my @one_binlist = ();
7125 foreach my $rcurs (&variable_value_as_list ($one_name, ''))
7127 if ($rcurs =~ /\./ || $rcurs =~ /^\@.*\@$/)
7129 push (@one_binlist, $rcurs);
7133 push (@one_binlist, $rcurs . '$(EXEEXT)');
7137 delete $contents{$one_name};
7138 &define_pretty_variable ($one_name, '', @one_binlist);
7143 foreach my $cond (@conds)
7145 my @one_binlist = ();
7146 my @condval = &variable_value_as_list ($one_name,
7148 foreach my $rcurs (@condval)
7150 if ($rcurs =~ /\./ || $rcurs =~ /^\@.*\@$/)
7152 push (@one_binlist, $rcurs);
7156 push (@one_binlist, $rcurs . '$(EXEEXT)');
7160 push (@condvals, $cond);
7161 push (@condvals, join (' ', @one_binlist));
7164 delete $contents{$one_name};
7168 $cond = shift (@condvals);
7169 my @val = split (' ', shift (@condvals));
7170 &define_pretty_variable ($one_name, $cond, @val);
7175 # "EXTRA" shouldn't be used when generating clean targets,
7176 # all, or install targets.
7179 # We used to warn if EXTRA_FOO was defined uselessly,
7180 # but this was annoying.
7187 &file_contents ($file . '-clean',
7188 &transform ('DIR' => $X)
7194 push (@check, '$(' . $one_name . ')');
7198 push (@used, '$(' . $one_name . ')');
7200 if ($X eq 'noinst' || $X eq 'check')
7202 # Objects which don't get installed by default.
7207 &file_contents ($file,
7208 &transform ('DIR' => $X,
7209 'NDIR' => $nodir_name)
7210 . &transform_cond ('BASE' => $strip_subdir,
7211 'EXEC' => $X =~ /exec/)
7217 # The JAVA variable is used as the name of the Java interpreter.
7218 # The PYTHON variable is used as the name of the Python interpreter.
7219 if (@used && $primary ne 'JAVA' && $primary ne 'PYTHON')
7222 &define_pretty_variable ($primary, '', @used);
7223 $output_vars .= "\n";
7226 if ($require_extra && ! &variable_defined ('EXTRA_' . $primary))
7228 &am_line_error ($require_extra,
7229 "\`$require_extra' contains configure substitution, but \`EXTRA_$primary' not defined");
7232 # Push here because PRIMARY might be configure time determined.
7233 push (@all, '$(' . $primary . ')')
7234 if @used && $primary ne 'JAVA' && $primary ne 'PYTHON';
7236 # Make the result unique. This lets the user use conditionals in
7237 # a natural way, but still lets us program lazily -- we don't have
7238 # to worry about handling a particular object more than once.
7239 return uniq (sort @result);
7243 ################################################################
7245 # Each key in this hash is the name of a directory holding a
7246 # Makefile.in. These variables are local to `is_make_dir'.
7248 my $make_dirs_set = 0;
7253 if (! $make_dirs_set)
7255 foreach my $iter (@configure_input_files)
7257 $make_dirs{dirname ($iter)} = 1;
7259 # We also want to notice Makefile.in's.
7260 foreach my $iter (@other_input_files)
7262 if ($iter =~ /Makefile\.in$/)
7264 $make_dirs{dirname ($iter)} = 1;
7269 return defined $make_dirs{$dir};
7272 ################################################################
7274 # This variable is local to the "require file" set of functions.
7275 my @require_file_paths = ();
7277 # If a file name appears as a key in this hash, then it has already
7278 # been checked for. This variable is local to the "require file"
7280 %require_file_found = ();
7282 # See if we want to push this file onto dist_common. This function
7283 # encodes the rules for deciding when to do so.
7284 sub maybe_push_required_file
7286 my ($dir, $file, $fullfile) = @_;
7288 # FIXME: Once again, special-case `.'.
7289 if ($dir eq $relative_dir || $dir eq '.')
7291 &push_dist_common ($file);
7293 elsif ($relative_dir eq '.' && ! &is_make_dir ($dir))
7295 # If we are doing the topmost directory, and the file is in a
7296 # subdir which does not have a Makefile, then we distribute it
7298 &push_dist_common ($fullfile);
7302 # Verify that the file must exist in the current directory. Usage:
7303 # require_file (isconfigure, line_number, strictness, file) strictness
7304 # is the strictness level at which this file becomes required. Must
7305 # set require_file_paths before calling this function.
7306 # require_file_paths is set to hold a single directory (the one in
7307 # which the first file was found) before return.
7308 sub require_file_internal
7310 my ($is_configure, $line, $mystrict, @files) = @_;
7312 my ($found_it, $dangling_sym, $errfile, $errdir);
7315 foreach my $file (@files)
7317 # If we've already looked for it, we're done.
7318 next if defined $require_file_found{$file};
7319 $require_file_found{$file} = 1;
7323 foreach my $dir (@require_file_paths)
7327 $fullfile = $relative_dir . "/" . $file;
7328 $errdir = $relative_dir unless $errdir;
7332 $fullfile = $dir . "/" . $file;
7333 $errdir = $dir unless $errdir;
7336 # Use different name for "error filename". Otherwise on
7337 # an error the bad file will be reported as eg
7338 # `../../install-sh' when using the default
7340 $errfile = $errdir . '/' . $file;
7342 if (-l $fullfile && ! -f readlink ($fullfile))
7347 elsif (-f $fullfile)
7350 &maybe_push_required_file ($dir, $file, $fullfile);
7356 if ($found_it && ! $force_missing)
7358 # Prune the path list.
7359 @require_file_paths = $save_dir;
7363 if ($strictness >= $mystrict)
7365 if ($dangling_sym && ($force_missing || $add_missing))
7373 # Only install missing files according to our desired
7375 my $message = "required file \`$errfile' not found";
7380 # Maybe run libtoolize.
7381 my @syslist = ('libtoolize', '--automake');
7382 push @syslist, '--copy'
7385 && grep ($_ eq $file, @libtoolize_files)
7386 && system (@syslist))
7388 $message = "installing \`$errfile'";
7390 $trailer = "; cannot run \`libtoolize': $!";
7392 elsif (-f ($am_dir . '/' . $file))
7394 # Install the missing file. Symlink if we
7395 # can, copy if we must. Note: delete the file
7396 # first, in case it is a dangling symlink.
7397 $message = "installing \`$errfile'";
7398 # Windows Perl will hang if we try to delete a
7399 # file that doesn't exist.
7400 unlink ($errfile) if -f $errfile;
7401 if ($symlink_exists && ! $copy_missing)
7403 if (! symlink ($am_dir . '/' . $file, $errfile))
7406 $trailer = "; error while making link: $!";
7409 elsif (system ('cp', $am_dir . '/' . $file, $errfile))
7412 $trailer = "\n error while copying";
7416 &maybe_push_required_file (dirname ($errfile),
7420 my $save = $exit_status;
7423 # FIXME: allow actual file to be specified.
7424 &am_conf_line_error ($configure_ac, $line,
7425 "$message$trailer");
7429 &am_line_error ($line, "$message$trailer");
7431 $exit_status = $save if $suppress;
7437 # Like require_file_with_line, but error messages refer to
7438 # configure.ac, not the current Makefile.am.
7439 sub require_file_with_conf_line
7441 @require_file_paths = '.';
7442 &require_file_internal (1, @_);
7445 sub require_file_with_line
7447 @require_file_paths = '.';
7448 &require_file_internal (0, @_);
7453 @require_file_paths = '.';
7454 &require_file_internal (0, '', @_);
7457 # Require a file that is also required by Autoconf. Looks in
7458 # configuration path, as specified by AC_CONFIG_AUX_DIR.
7459 sub require_config_file
7461 @require_file_paths = @config_aux_path;
7462 &require_file_internal (1, '', @_);
7463 my $dir = $require_file_paths[0];
7464 @config_aux_path = @require_file_paths;
7467 $config_aux_dir = '.';
7471 $config_aux_dir = '$(top_srcdir)/' . $dir;
7475 # Assumes that the line number is in Makefile.am.
7476 sub require_conf_file_with_line
7478 @require_file_paths = @config_aux_path;
7479 &require_file_internal (0, @_);
7480 my $dir = $require_file_paths[0];
7481 @config_aux_path = @require_file_paths;
7484 $config_aux_dir = '.';
7488 $config_aux_dir = '$(top_srcdir)/' . $dir;
7492 # Assumes that the line number is in configure.ac.
7493 sub require_conf_file_with_conf_line
7495 @require_file_paths = @config_aux_path;
7496 &require_file_internal (1, @_);
7497 my $dir = $require_file_paths[0];
7498 @config_aux_path = @require_file_paths;
7501 $config_aux_dir = '.';
7505 $config_aux_dir = '$(top_srcdir)/' . $dir;
7509 ################################################################
7511 # Push a list of files onto dist_common.
7512 sub push_dist_common
7514 foreach my $file (@_)
7516 if (! defined $dist_common{$file})
7518 &prog_error ("push_dist_common run after handle_dist")
7519 if $handle_dist_run;
7520 $dist_common{$file} = 1;
7529 $strictness_name = $_[0];
7530 if ($strictness_name eq 'gnu')
7534 elsif ($strictness_name eq 'gnits')
7536 $strictness = $GNITS;
7538 elsif ($strictness_name eq 'foreign')
7540 $strictness = $FOREIGN;
7544 die "automake: level \`$strictness_name' not recognized\n";
7549 ################################################################
7551 # Ensure a file exists.
7556 my $touch = new IO::File (">> $file");
7560 # Glob something. Do this to avoid indentation screwups everywhere we
7561 # want to glob. Gross!
7568 # Remove one level of brackets and strip leading spaces,
7569 # as does m4 to function arguments.
7575 my @letters = split //;
7584 next if $depth == 1;
7589 next if $depth == 0;
7590 # don't count orphan right brackets
7591 $depth = 0 if $depth < 0;
7595 return join '', @result;
7598 ################################################################
7600 # Print an error message and set exit status.
7603 warn "automake: ${am_file}.am: @_\n";
7608 # am_file_error ($FILE, @ARGS)
7609 # ----------------------------
7612 my ($file, @args) = @_;
7614 warn "$file: @args\n";
7620 my ($symbol, @args) = @_;
7622 if ($symbol && "$symbol" ne '-1')
7624 my $file = "${am_file}.am";
7626 if ($symbol =~ /^\d+$/)
7628 # SYMBOL is a line number, so just add the colon.
7629 $file .= ':' . $symbol;
7631 elsif (defined $content_lines{$symbol})
7633 # SYMBOL is a variable defined in Makefile.am, so add the
7634 # line number we saved from there.
7635 $file .= ':' . $content_lines{$symbol};
7637 elsif (defined $configure_vars{$symbol})
7639 # SYMBOL is a variable defined in configure.ac, so add the
7640 # appropriate line number.
7641 $file = $configure_vars{$symbol};
7645 # Couldn't find the line number.
7647 warn $file, ": @args\n";
7656 # Like am_error, but while scanning configure.ac.
7659 # FIXME: can run in subdirs.
7660 warn "automake: $configure_ac: @_\n";
7664 # Error message with line number referring to configure.ac.
7665 sub am_conf_line_error
7667 my ($file, $line, @args) = @_;
7671 warn "$file: $line: @args\n";
7676 &am_conf_error (@args);
7680 # Warning message with line number referring to configure.ac.
7681 # Does not affect exit_status
7682 sub am_conf_line_warning
7684 my $saved_exit_status = $exit_status;
7685 &am_conf_line_error (@_);
7686 $exit_status = $saved_exit_status;
7689 # Tell user where our aclocal.m4 is, but only once.
7690 sub keyed_aclocal_warning
7693 warn "automake: macro \`$key' can be generated by \`aclocal'\n";
7696 # Print usage information.
7700 Usage: automake [OPTION] ... [Makefile]...
7702 Generate Makefile.in for configure from Makefile.am
7705 --help print this help, then exit
7706 --version print version number, then exit
7707 -v, --verbose verbosely list files processed
7708 -o, --output-dir=DIR put generated Makefile.in's into DIR
7709 --no-force only update Makefile.in's that are out of date
7711 Dependency tracking:
7712 -i, --ignore-deps disable dependency tracking code
7713 --include-deps enable dependency tracking code
7716 --cygnus assume program is part of Cygnus-style tree
7717 --foreign set strictness to foreign
7718 --gnits set strictness to gnits
7719 --gnu set strictness to gnu
7722 -a, --add-missing add missing standard files to package
7723 --amdir=DIR directory storing config files
7724 -c, --copy with -a, copy missing files (default is symlink)
7725 --force-missing force update of standard files
7730 foreach my $iter (sort ((@common_files, @common_sometimes)))
7732 push (@lcomm, $iter) unless $iter eq $last;
7736 my ($one, $two, $three, $four, $max);
7737 print "\nFiles which are automatically distributed, if found:\n";
7738 format USAGE_FORMAT =
7739 @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<
7740 $one, $two, $three, $four
7742 $~ = "USAGE_FORMAT";
7743 $max = int (($#lcomm + 1) / 4);
7745 for (my $i = 0; $i < $max; ++$i)
7748 $two = $lcomm[$max + $i];
7749 $three = $lcomm[2 * $max + $i];
7750 $four = $lcomm[3 * $max + $i];
7754 my $mod = ($#lcomm + 1) % 4;
7757 $one = $lcomm[$max];
7758 $two = ($mod > 1) ? $lcomm[2 * $max] : '';
7759 $three = ($mod > 2) ? $lcomm[3 * $max] : '';
7760 $four = ($mod > 3) ? $lcomm[4 * $max] : '';
7764 print "\nReport bugs to <bug-automake\@gnu.org>.\n";