5 eval 'exec @PERL@ -S $0 ${1+"$@"}'
8 # automake - create Makefile.in from Makefile.am
9 # Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
11 # This program is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by
13 # the Free Software Foundation; either version 2, or (at your option)
16 # This program is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write to the Free Software
23 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
26 # Originally written by David Mackenzie <djm@gnu.ai.mit.edu>.
27 # Perl reimplementation by Tom Tromey <tromey@cygnus.com>.
30 # Parameters set by configure. Not to be changed. NOTE: assign
31 # VERSION as string so that eg version 0.30 will print correctly.
32 $VERSION = "@VERSION@";
33 $PACKAGE = "@PACKAGE@";
35 $am_dir = "@datadir@/@PACKAGE@";
39 $IGNORE_PATTERN = "^##([^#].*)?\$";
40 $WHITE_PATTERN = "^[ \t]*\$";
41 $COMMENT_PATTERN = "^#";
42 $RULE_PATTERN = "^([\$a-zA-Z_.][-.a-zA-Z0-9_(){}/]*) *:([^=].*|)\$";
43 $MACRO_PATTERN = "^([A-Za-z][A-Za-z0-9_]*)[ \t]*:?=[ \t]*(.*)\$";
44 $BOGUS_MACRO_PATTERN = "^([^ \t]*)[ \t]*:?=[ \t]*(.*)\$";
45 $GNITS_VERSION_PATTERN = "[0-9]+\\.[0-9]+([a-z]|\\.[0-9]+)?";
47 # Some regular expressions. One reason to put them here is that it
48 # makes indentation work better in Emacs.
49 $AC_CONFIG_AUX_DIR_PATTERN = "AC_CONFIG_AUX_DIR\\(([^)]+)\\)";
50 $AM_INIT_AUTOMAKE_PATTERN = "AM_INIT_AUTOMAKE\\([^,]*,([^)]+)\\)";
51 $AM_PACKAGE_VERSION_PATTERN = "^\\s*\\[?([^]\\s]+)\\]?\\s*\$";
52 # Note that there is no AC_PATH_TOOL. But we don't really care.
53 $AC_CHECK_PATTERN = "AC_(CHECK|PATH)_(PROG|PROGS|TOOL)\\(\\[?([^]),]+)";
54 # Just check for alphanumeric in AC_SUBST. If you do AC_SUBST(5),
56 $AC_SUBST_PATTERN = "AC_SUBST\\(\\[?(\\w+)";
58 # Constants to define the "strictness" level.
65 # Variables global to entire run.
67 # TRUE if we should always generate Makefile.in.
68 $force_generation = 1;
70 # Strictness level as set on command line.
71 $default_strictness = $GNU;
73 # Name of strictness level, as set on command line.
74 $default_strictness_name = 'gnu';
76 # This is TRUE if GNU make specific automatic dependency generation
77 # code should be included in generated Makefile.in.
78 $cmdline_use_dependencies = 1;
80 # TRUE if in verbose mode.
83 # This holds our (eventual) exit status. We don't actually exit until
84 # we have processed all input files.
87 # From the Perl manual.
88 $symlink_exists = (eval 'symlink ("", "");', $@ eq '');
90 # TRUE if missing standard files should be installed.
93 # Files found by scanning configure.in for LIBOBJS.
96 # True if AM_C_PROTOTYPES appears in configure.in.
99 # Names used in AC_CONFIG_HEADER call. $config_name is the actual
100 # (first) argument. $config_header is the '.in' file. Ordinarily the
101 # second is derived from the first, but they can be different if the
102 # weird "NAME:FILE" syntax is used.
105 # Line number at which AC_CONFIG_HEADER appears in configure.in.
106 $config_header_line = 0;
108 # Directory where output files go. Actually, output files are
109 # relative to this directory.
110 $output_directory = '.';
112 # Relative location of top build directory.
115 # Absolute location of top build directory.
116 $build_directory = '';
118 # Name of srcdir as given in build directory's Makefile. For
122 # List of Makefile.am's to process, and their corresponding outputs.
126 # List of files in AC_OUTPUT without Makefile.am, and their outputs.
127 @other_input_files = ();
128 # Line number at which AC_OUTPUT seen.
131 # List of directories to search for configure-required files. This
132 # can be set by AC_CONFIG_AUX_DIR.
133 @config_aux_path = ('.', '..', '../..');
134 $config_aux_dir = '';
136 # Whether AC_PROG_MAKE_SET has been seen in configure.in.
139 # Whether AM_GNU_GETTEXT has been seen in configure.in.
141 # Line number at which AM_GNU_GETTEXT seen.
142 $ac_gettext_line = 0;
144 # Whether ALL_LINGUAS has been seen.
148 # Line number at which it appears.
149 $all_linguas_line = 0;
151 # 1 if AC_PROG_INSTALL seen, 2 if AM_PROG_INSTALL seen.
152 $seen_prog_install = 0;
154 # 1 if any scripts installed, 0 otherwise.
155 $scripts_installed = 0;
157 # Whether AC_PATH_XTRA has been seen in configure.in.
160 # TRUE if AC_DECL_YYTEXT was seen.
161 $seen_decl_yytext = 0;
163 # TRUE if we've seen AC_CANONICAL_(HOST|SYSTEM). The presence of
164 # AC_CHECK_TOOL also sets this.
167 # TRUE if we've seen AC_ARG_PROGRAM.
170 # TRUE if we've seen AM_PROG_LIBTOOL.
174 # Files installed by libtoolize.
175 @libtoolize_files = ('ltconfig', 'ltmain.sh', 'config.guess', 'config.sub');
177 # TRUE if we've seen AM_MAINTAINER_MODE.
178 $seen_maint_mode = 0;
180 # TRUE if we've seen PACKAGE and VERSION.
184 # Actual version we've seen.
185 $package_version = '';
187 # Line number where we saw version definition.
188 $package_version_line = 0;
190 # TRUE if we've seen AM_PATH_LISPDIR.
193 # Hash table of discovered configure substitutions. Keys are names,
194 # values are meaningless.
195 %configure_vars = ();
197 # Charsets used by maintainer and in distribution. MAINT_CHARSET is
198 # handled in a funny way: if seen in the top-level Makefile.am, it is
199 # used for every directory which does not specify a different value.
200 # The rationale here is that some directories (eg gettext) might be
201 # distributions of other packages, and thus require their own charset
202 # info. However, the DIST_CHARSET must be the same for the entire
203 # package; it can only be set at top-level.
204 # FIXME: this yields bugs when rebuilding. What to do? Always
205 # read (and sometimes discard) top-level Makefile.am?
207 $dist_charset = 'utf8'; # recode doesn't support this yet.
209 # Name of input file ("Makefile.in") and output file ("Makefile.am").
210 # These have no directory components.
214 # TRUE if --cygnus seen.
217 # Keys of this hash are names of dependency files to ignore.
218 %omit_dependencies = ();
222 &initialize_global_constants;
224 # Parse command line.
225 &parse_arguments (@ARGV);
227 # Do configure.in scan only once.
230 die "automake: no \`Makefile.am' found or specified\n"
233 # Now do all the work on each file.
234 foreach $am_file (@input_files)
236 if (! -f ($am_file . '.am'))
238 &am_error ("\`" . $am_file . ".am' does not exist");
242 &generate_makefile ($output_files{$am_file}, $am_file);
246 if ($seen_prog_install <= $scripts_installed)
248 &am_conf_error (($scripts_installed ? 'AM_PROG_INSTALL' : 'AC_PROG_INSTALL')
249 . " must be used in configure.in");
250 &keyed_aclocal_warning ('AM_PROG_INSTALL')
251 if $scripts_installed;
257 ################################################################
259 # Parse command line.
262 local (@arglist) = @_;
265 &set_strictness ('gnu');
269 if ($arglist[0] eq "--version")
271 print "automake (GNU $PACKAGE) $VERSION\n";
272 print "Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.\n";
273 print "automake comes with ABSOLUTELY NO WARRANTY.\n";
274 print "You may redistribute copies of automake\n";
275 print "under the terms of the GNU General Public License.\n";
276 print "For more information about these matters, see the file named COPYING.\n";
279 elsif ($arglist[0] eq "--help")
283 elsif ($arglist[0] =~ /^--amdir=(.+)$/)
287 elsif ($arglist[0] eq '--amdir')
289 &require_argument (@arglist);
291 $am_dir = $arglist[0];
293 elsif ($arglist[0] =~ /^--build-dir=(.+)$/)
296 $build_directory = $1 . '/';
298 elsif ($arglist[0] eq '--build-dir')
300 &require_argument (@arglist);
303 $build_directory = $arglist[0] . '/';
305 elsif ($arglist[0] =~ /^--srcdir-name=(.+)$/)
309 elsif ($arglist[0] eq '--srcdir-name')
311 &require_argument (@arglist);
313 $srcdir_name = $arglist[0];
315 elsif ($arglist[0] eq '--gnu')
317 &set_strictness ('gnu');
319 elsif ($arglist[0] eq '--gnits')
321 &set_strictness ('gnits');
323 elsif ($arglist[0] eq '--cygnus')
327 elsif ($arglist[0] eq '--foreign')
329 &set_strictness ('foreign');
331 elsif ($arglist[0] eq '--include-deps' || $arglist[0] eq '-i')
333 $cmdline_use_dependencies = 0;
335 elsif ($arglist[0] eq '--no-force')
337 $force_generation = 0;
339 elsif ($arglist[0] =~ /^--output-dir=(.*)$/)
341 # Set output directory.
342 $output_directory = $1;
344 elsif ($arglist[0] eq '--output-dir' || $arglist[0] eq '-o')
346 &require_argument (@arglist);
348 $output_directory = $arglist[0];
350 elsif ($arglist[0] eq '--add-missing' || $arglist[0] eq '-a')
354 elsif ($arglist[0] eq '--verbose' || $arglist[0] eq '-v')
358 elsif ($arglist[0] eq '--')
360 # Stop option processing.
362 push (@input_files, @arglist);
365 elsif ($arglist[0] =~ /^-/)
367 die "automake: unrecognized option -- \`$arglist[0]'\nTry \`automake --help' for more information.\n";
371 # Handle $local:$input syntax. Note that we only examine
372 # the first ":" file to see if it is automake input; the
373 # rest are just taken verbatim. We still keep all the
374 # files around for dependency checking, however.
375 local ($local, $input, @rest) = split (/:/, $arglist[0]);
382 # Strip .in; later on .am is tacked on. That is how
383 # the automake input file is found. Maybe not the
384 # best way, but it is easy to explain. FIXME: should
385 # be error if .in is missing.
388 push (@input_files, $input);
389 $output_files{$input} = join (':', ($local, @rest));
395 # Take global strictness from whatever we currently have set.
396 $default_strictness = $strictness;
397 $default_strictness_name = $strictness_name;
400 # Ensure argument exists, or die.
403 local ($arg, @arglist) = @_;
404 die "automake: no argument given for option \`$arg'\n"
408 ################################################################
410 # Generate a Makefile.in given the name of the corresponding Makefile and
411 # the name of the file output by config.status.
412 sub generate_makefile
414 local ($output, $makefile) = @_;
416 ($am_file_name = $makefile) =~ s/^.*\///;
417 $in_file_name = $am_file_name . '.in';
418 $am_file_name .= '.am';
420 # $OUTPUT is encoded. If it contains a ":" then the first element
421 # is the real output file, and all remaining elements are input
422 # files. We don't scan or otherwise deal with these input file,
423 # other than to mark them as dependencies. See scan_configure for
425 local (@secondary_inputs);
426 ($output, @secondary_inputs) = split (/:/, $output);
428 &initialize_per_input;
429 $relative_dir = &dirname ($output);
430 $am_relative_dir = &dirname ($makefile);
432 # At the toplevel directory, we might need config.guess, config.sub
433 # or libtool scripts (ltconfig and ltmain.sh).
434 if ($relative_dir eq '.')
436 # libtool requires some files.
437 &require_conf_file_with_conf_line ($libtool_line, $FOREIGN,
441 # AC_CANONICAL_HOST and AC_CANONICAL_SYSTEM need config.guess and
443 &require_config_file ($FOREIGN, 'config.guess', 'config.sub')
447 # We still need Makefile.in here, because sometimes the `dist'
448 # target doesn't re-run automake.
449 if ($am_relative_dir eq $relative_dir)
451 # Only distribute the files if they are in the same subdir as
452 # the generated makefile.
453 &push_dist_common ($in_file_name, $am_file_name);
455 push (@sources, '$(SOURCES)')
456 if &variable_defined ('SOURCES');
457 push (@objects, '$(OBJECTS)')
458 if &variable_defined ('OBJECTS');
460 # This is always the default target. This gives us freedom to do
461 # things in whatever order is convenient. Note that we set up
462 # $output_header here so that we can insert some text just after
463 # the "default" target, but before any other targets. In
464 # particular we want to support the .SUFFIX hack here; this is
465 # documented elsewhere.
466 $output_header = "default: all\n\n";
467 push (@phony, 'default');
469 &read_am_file ($makefile . '.am');
472 # Fatal error. Just return, so we can continue with next file.
476 # Check first, because we might modify some state.
478 &check_gnu_standards;
479 &check_gnits_standards;
481 &handle_configure ($output, $makefile, @secondary_inputs);
487 &handle_built_sources;
489 # This must be run after all the sources are scanned.
490 &handle_yacc_lex_cxx;
492 # Re-init SOURCES and OBJECTS. FIXME: other code shouldn't depend
493 # on this (but currently does).
494 $contents{'SOURCES'} = join (' ', @sources);
495 $contents{'OBJECTS'} = join (' ', @objects);
505 &handle_dependencies;
508 &handle_merge_targets;
515 if (! -d ($output_directory . '/' . $am_relative_dir))
517 mkdir ($output_directory . '/' . $am_relative_dir, 0755);
520 local ($out_file) = $output_directory . '/' . $makefile . ".in";
521 if (! $force_generation && -e $out_file)
523 local ($am_time) = (stat ($makefile . '.am'))[9];
524 local ($in_time) = (stat ($out_file))[9];
525 # FIXME: how to do unsigned comparison?
526 if ($am_time < $in_time)
533 if (! open (GM_FILE, "> " . $out_file))
535 warn "automake: ${am_file}.in: cannot open: $!\n";
539 print "automake: creating ", $makefile, ".in\n" if $verbose;
541 print GM_FILE $output_vars;
542 print GM_FILE $output_header;
543 print GM_FILE $output_rules;
544 print GM_FILE $output_trailer;
549 ################################################################
551 # Handle AUTOMAKE_OPTIONS variable. Return 1 on error, 0 otherwise.
554 return 0 if ! &variable_defined ('AUTOMAKE_OPTIONS');
556 foreach (&variable_value_as_list ('AUTOMAKE_OPTIONS'))
559 if ($_ eq 'gnits' || $_ eq 'gnu' || $_ eq 'foreign')
561 &set_strictness ($_);
565 # An option like "../lib/ansi2knr" is allowed. With no
566 # path prefix, we assume the required programs are in this
567 # directory. We save the actual option for later.
568 $options{'ansi2knr'} = $_;
570 elsif ($_ eq 'no-installman' || $_ eq 'no-installinfo'
571 || $_ eq 'dist-shar' || $_ eq 'dist-zip'
572 || $_ eq 'dist-tarZ' || $_ eq 'dejagnu'
573 || $_ eq 'no-texinfo.tex')
575 # Explicitly recognize these.
577 elsif ($_ eq 'no-dependencies')
579 $use_dependencies = 0;
581 elsif (/([0-9]+)\.([0-9]+)/)
583 # Got a version number. Note that alpha releases count as
584 # the next higher release. Note also that we assume there
585 # will be a maximum of 100 minor releases for any given
587 local ($rmajor, $rminor) = ($1, $2);
588 if ($VERSION !~ /([0-9]+)\.([0-9]+)([a-z])?/)
591 "automake: programming error: version is incorrect\n";
594 local ($tmajor, $tminor) = ($1, $2);
595 # Handle alpha versions.
596 ++$tminor if defined $3;
598 if ($rmajor > $tmajor || ($rmajor == $tmajor && $rminor > $tminor))
600 &am_line_error ('AUTOMAKE_OPTIONS',
601 "require version $_, only have $VERSION");
607 &am_line_error ('AUTOMAKE_OPTIONS',
608 'option ', $_, 'not recognized');
615 # Return object extension. Just once, put some code into the output.
616 # Argument is the name of the output file
617 sub get_object_extension
622 $dir_holds_sources = 1;
624 # Maybe require libtool library object files.
625 local ($l, $extension) = ('', 'o');
626 $l = 'l' if ($out =~ /^lib.*\.la$/);
628 if (! $included_generic_compile)
632 if (&variable_defined ('CONFIG_HEADER'))
634 ($xform = &dirname ($contents{'CONFIG_HEADER'}))
636 $xform = '-I' . $xform;
638 $xform = 's/\@CONFIG_INCLUDE_SPEC\@/' . $xform . '/go;';
639 $output_vars .= &file_contents_with_transform ($xform,
641 $output_rules .= &file_contents ('compile');
642 &push_phony_cleaners ('compile');
644 # If using X, include some extra variable definitions. NOTE
645 # we don't want to force these into CFLAGS or anything,
646 # because not all programs will necessarily use X.
650 foreach $var ('X_CFLAGS', 'X_LIBS', 'X_EXTRA_LIBS', 'X_PRE_LIBS')
652 &define_configure_variable ($var);
656 push (@suffixes, '.c', '.o');
657 push (@clean, 'compile');
659 $included_generic_compile = 1;
662 if ($seen_libtool && ! $included_libtool_compile)
664 # Output the libtool compilation rules.
665 $output_rules .= &file_contents ('libtool');
666 &push_phony_cleaners ('libtool');
668 push (@suffixes, '.lo');
669 push (@clean, 'libtool');
671 $included_libtool_compile = 1;
674 # Check for automatic de-ANSI-fication.
675 if (defined $options{'ansi2knr'})
678 if (! $included_knr_compile)
680 if (! $am_c_prototypes)
682 &am_line_error ('AUTOMAKE_OPTIONS',
683 "option \`ansi2knr' in use but \`AM_C_PROTOTYPES' not in configure.in");
684 &keyed_aclocal_warning ('AM_C_PROTOTYPES');
685 # Only give this error once.
686 $am_c_prototypes = 1;
689 push (@suffixes, '._c', '._o');
690 push (@suffixes, '.l_o') if $seen_libtool;
692 # Only require ansi2knr files if they should appear in
694 if ($options{'ansi2knr'} eq 'ansi2knr')
696 &require_file_with_line ('AUTOMAKE_OPTIONS', $FOREIGN,
697 'ansi2knr.c', 'ansi2knr.1');
698 $output_rules .= &file_contents ('kr-extra');
699 push (@clean, 'krextra');
700 &push_phony_cleaners ('krextra');
703 &define_variable ('o', "\@U\@o");
705 # Make sure ansi2knr can be found: if no path specified,
707 local ($apath) = $options{'ansi2knr'};
710 # Found in another directory.
711 &define_variable ("ANSI2KNR", $apath);
715 # Substitution from AM_C_PROTOTYPES. This makes it be
716 # built only when necessary.
717 &define_configure_variable ('ANSI2KNR');
718 # ansi2knr needs to be built before subdirs, so unshift it.
719 unshift (@all, '$(ANSI2KNR)');
722 $output_rules .= &file_contents ('compile-kr');
723 $output_rules .= &file_contents ('clean-kr');
726 &push_phony_cleaners ('kr');
728 $included_knr_compile = 1;
732 return '.' . $l . $extension;
735 # Handle yacc and lex.
736 sub handle_yacc_lex_cxx
739 # First do yacc and lex.
742 local ($yacc_count) = scalar (keys %yacc_sources);
743 local ($lex_count) = scalar (keys %lex_sources);
747 local (%seen_suffix) = ();
748 foreach (keys %yacc_sources)
751 output_yacc_build_rule ($1, $yacc_count > 1)
752 if (! defined $seen_suffix{$1});
753 $seen_suffix{$1} = 1;
756 if (! defined $configure_vars{'YACC'})
758 &am_error ("yacc source seen but \`YACC' not defined in \`configure.in'");
763 local (%seen_suffix) = ();
764 foreach (keys %lex_sources)
767 output_lex_build_rule ($1, $lex_count > 1)
768 if (! defined $seen_suffix{$1});
769 $seen_suffix{$1} = 1;
772 if (! defined $configure_vars{'LEX'})
774 &am_error ("lex source seen but \`LEX' not defined in \`configure.in'");
776 if (! $seen_decl_yytext)
778 &am_error ("lex source seen but \`AC_DECL_YYTEXT' not in \`configure.in'");
782 if ($yacc_count > 1 || $lex_count > 1)
784 # If there is more than one distinct yacc (resp lex) source
785 # file in a given directory, then the `interlock' program is
786 # required to allow parallel builds to work correctly. FIXME:
787 # for now, no line number.
788 &require_config_file ($FOREIGN, 'interlock', 'ylwrap');
789 if ($config_aux_dir ne '.' && $config_aux_dir ne '')
791 &define_variable ('INTERLOCK', $config_aux_dir . "/interlock");
792 &define_variable ('YLWRAP', $config_aux_dir . "/ylwrap");
796 &define_variable ('INTERLOCK', '$(srcdir)/interlock');
797 &define_variable ('YLWRAP', '$(srcdir)/ylwrap');
804 local ($libtool) = '';
807 &define_configure_variable ("LIBTOOL");
808 $libtool = '$(LIBTOOL) --mode=link ';
814 local (@cxx_list) = keys %cxx_extensions;
815 local ($cxx_count) = scalar @cxx_list;
818 push (@suffixes, @cxx_list);
820 &define_configure_variable ("CXXFLAGS");
821 &define_variable ('CXXCOMPILE', '$(CXX) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CXXFLAGS)');
822 &define_variable ('CXXLINK', $libtool . '$(CXX) $(LDFLAGS) -o $@');
825 foreach $ext (@cxx_list)
827 $output_rules .= ("$ext.o:\n"
828 . "\t\$(CXXCOMPILE) -c \$<\n");
829 $output_rules .= ("$ext.lo:\n"
830 . "\t\$(LIBTOOL) --mode=compile \x$(CXXCOMPILE) -c \$<\n")
834 if (! defined $configure_vars{'CXX'})
836 &am_error ("C++ source seen but \`CXX' not defined in \`configure.in'");
841 # Handle some ansi2knr cleanup.
843 if (defined $options{'ansi2knr'} && keys %de_ansi_objects)
845 # Make all ._o files depend on ansi2knr. Use a sneaky little
846 # hack to make it print nicely.
847 &pretty_print_rule ('', '', (sort keys %de_ansi_objects,
848 ':', '$(ANSI2KNR)'));
852 # Last, handle some C cleanup.
856 &define_configure_variable ('CFLAGS');
857 &define_variable ('COMPILE',
858 '$(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)');
859 &define_variable ('LINK', $libtool . '$(CC) $(LDFLAGS) -o $@');
861 if (! defined $configure_vars{'CC'})
864 ("C source seen but \`CC' not defined in \`configure.in'");
870 # Output a rule to build from a YACC source. The output from YACC is
871 # compiled with C or C++, depending on the extension of the YACC file.
872 sub output_yacc_build_rule
874 local ($yacc_suffix, $use_interlock) = @_;
877 ($c_suffix = $yacc_suffix) =~ tr/y/c/;
878 push (@suffixes, $yacc_suffix);
879 $output_rules .= "$yacc_suffix$c_suffix:\n\t";
883 $output_rules .= '$(SHELL) $(INTERLOCK) =yacclockdir $(YLWRAP)'
884 . ' "$(YACC)" y.tab.c $*' . $c_suffix
885 . ' y.tab.h $*.h -- $(YFLAGS) $<';
889 $output_rules .= ('$(YACC) $(YFLAGS) $< && mv y.tab.c $@' . "\n"
890 . "\tif test -f y.tab.h; then \\\n"
891 . "\tif cmp -s y.tab.h \$*.h; then rm -f y.tab.h; else mv y.tab.h \$*.h; fi; \\\n"
894 $output_rules .= "\n";
897 sub output_lex_build_rule
899 local ($lex_suffix, $use_interlock) = @_;
902 ($c_suffix = $lex_suffix) =~ tr/l/c/;
903 push (@suffixes, $lex_suffix);
904 &define_configure_variable ('LEX_OUTPUT_ROOT');
905 &define_configure_variable ('LEXLIB');
906 $output_rules .= "$lex_suffix$c_suffix:\n\t";
910 # is the $@ correct here? If so, why not use it in the
911 # interlock build rule for yacc above?
912 $output_rules .= '$(SHELL) $(INTERLOCK) =lexlockdir $(YLWRAP)'
913 . ' "$(LEX)" $(LEX_OUTPUT_ROOT).c $@ -- $(LFLAGS) $<';
917 $output_rules .= '$(LEX) $(LFLAGS) $< && mv $(LEX_OUTPUT_ROOT).c $@';
919 $output_rules .= "\n";
923 # Check to make sure a source defined in LIBOBJS is not explicitly
924 # mentioned. This is a separate function (as opposed to being inlined
925 # in handle_source_transform) because it isn't always appropriate to
927 sub check_libobjs_sources
929 local ($one_file, $unxformed) = @_;
931 local ($prefix, $file, @files);
932 foreach $prefix ('', 'EXTRA_')
934 if (&variable_defined ($prefix . $one_file . '_SOURCES'))
936 @files = &variable_value_as_list ($prefix
937 . $one_file . '_SOURCES');
939 elsif ($prefix eq '')
941 @files = ($unxformed . '.c');
948 foreach $file (@files)
950 if (defined $libsources{$file})
952 &am_line_error ($prefix . $one_file . '_SOURCES',
953 "automatically discovered file \`$file' should not be explicitly mentioned");
959 # Does much of the actual work for handle_source_transform.
961 # list of source files to transform
963 # first element is name of linker to use (empty string for default linker)
964 # remaining elements are names of `.o's
965 sub handle_single_transform_list
968 local ($linker) = '';
969 local (@result) = ();
970 local ($nonansi_obj) = $obj;
971 $nonansi_obj =~ s/_//g;
974 # Turn sources into objects.
977 # Skip header files, including C++-ish ones. The list
978 # of C++ header extensions comes from Emacs 19.32
985 # Skip things that look like configure substitutions.
988 # Include appropriate file for lex or yacc source in
989 # distribution. If the extension is the regular '.y' or
990 # '.l', we assume C compilation, and the generated file
991 # has exension .c. Otherwise, we compile with C++, and
992 # make the following association: (yy -> cc, y++ -> c++,
993 # yxx -> cxx), similarly for .ll, etc.
994 if (/^(.*)\.(y|yy|y\+\+|yxx)$/)
999 &push_dist_common ("$1.$ext");
1000 $yacc_sources{$_} = 1;
1002 elsif (/^(.*)\.(l|ll|l\+\+|lxx)$/)
1007 &push_dist_common ("$1.$ext");
1008 $lex_sources{$_} = 1;
1011 # Transform source files into .o files. List of C++
1012 # extensions comes from Emacs 19.34 etags.
1013 if (s/\.(c\+\+|cc|cpp|cxx|C)$/$nonansi_obj/)
1015 $cxx_extensions{'.' . $1} = 1;
1016 $linker = 'CXXLINK';
1018 elsif (s/\.(yy|y\+\+|yxx|ll|l\+\+|lxx)$/$nonansi_obj/)
1020 # Compiling lex or yacc with C++
1023 $cxx_extensions{".$ext"} = 1;
1024 $linker = 'CXXLINK';
1026 elsif (s/\.([Ff]\\|f90\\|for)$/$nonansi_obj/)
1028 # FORTRAN support. FIXME: not finished.
1030 elsif (s/\.[sS]$/$nonansi_obj/)
1032 # .s is assembly. Just rewrite it. FIXME: not finished.
1034 elsif (s/\.[cly]$/._o/)
1036 # .c is C. .l is lex. .y is yacc.
1038 # Note: first we rewrite (eg) foo.c to foo._o and push
1039 # the file onto the list of objects that require
1040 # ansi2knr. Then we rewrite ._o to $obj; $obj can be
1041 # simply `.o' if deansification is not really
1043 $de_ansi_objects{$_} = 1;
1049 # No error message here. Used to have one, but it was
1056 # Transform .o or $o file into .P file (for automatic
1059 $dep_files{'.deps/' . $_} = 1;
1063 return ($linker, @result);
1066 # Handle SOURCE->OBJECT transform for one program or library.
1068 # canonical (transformed) name of object to build
1069 # actual name of object to build
1070 # object extension (ie either `.o' or `$o'.
1071 # Return result is name of linker variable that must be used.
1072 # Empty return means just use `LINK'.
1073 sub handle_source_transform
1075 # one_file is canonical name. unxformed is given name. obj is
1077 local ($one_file, $unxformed, $obj) = @_;
1078 local ($objpat) = $obj;
1079 $objpat =~ s/(\W)/\\$1/g;
1080 # Handle explicit `.o' as well as whatever we're passed.
1081 $objpat = '(' . $objpat . "|\\.o)";
1083 local ($linker) = '';
1085 if (&variable_defined ($one_file . "_OBJECTS"))
1087 &am_line_error ($one_file . '_OBJECTS',
1088 $one_file . '_OBJECTS', 'should not be defined');
1089 # No point in continuing.
1093 local (@files, @result, $prefix, $temp);
1094 foreach $prefix ('', 'EXTRA_')
1097 if (&variable_defined ($prefix . $one_file . "_SOURCES"))
1099 push (@sources, '$(' . $prefix . $one_file . "_SOURCES)");
1100 push (@objects, '$(' . $prefix . $one_file . "_OBJECTS)")
1101 unless $prefix eq 'EXTRA_';
1102 @files = &variable_value_as_list ($prefix
1103 . $one_file . "_SOURCES");
1105 elsif ($prefix eq '')
1107 &define_variable ($one_file . "_SOURCES", $unxformed . ".c");
1108 push (@sources, $unxformed . '.c');
1109 push (@objects, $unxformed . $obj);
1110 push (@files, $unxformed . '.c');
1113 ($temp, @result) = &handle_single_transform_list (@files);
1114 $linker = $temp if $linker eq '';
1115 &define_pretty_variable ($one_file . "_OBJECTS", @result)
1116 unless $prefix eq 'EXTRA_';
1119 if (&variable_defined ('CONFIG_HEADER'))
1121 $output_rules .= ('$(' . $one_file . "_OBJECTS): "
1122 . $contents{'CONFIG_HEADER'} . "\n");
1128 # Handle the BUILT_SOURCES variable.
1129 sub handle_built_sources
1131 return unless &variable_defined ('BUILT_SOURCES');
1132 push (@all, '$(BUILT_SOURCES)');
1134 local (@sources) = &variable_value_as_list ('BUILT_SOURCES');
1136 foreach $s (@sources)
1140 # FIXME: is this really the right thing to do?
1141 &am_line_error ('BUILT_SOURCES', "\`BUILT_SOURCES' should not contain a configure substitution");
1146 # We don't care about the return value of this function. We just
1147 # want to make sure to update %dep_files with the contents of
1149 &handle_single_transform_list (@sources);
1152 # Special-case @ALLOCA@ and @LIBOBJS@ in _LDADD or _LIBADD variables.
1153 # Also, generate _DEPENDENCIES variable if appropriate.
1155 # transformed name of object being built, or empty string if no object
1156 # name of _LDADD/_LIBADD-type variable to examine
1157 # boolean (lex_seen) which is true if a lex source file was seen in this
1158 # object. valid only for LDADDs, not LIBADDs. If set, LEXLIB
1160 # Returns 1 if LIBOBJS seen, 0 otherwise.
1161 sub handle_lib_objects
1163 local ($xname, $var, $lex_seen) = @_;
1165 die "automake: programming error 1 in handle_lib_objects\n"
1166 if ! &variable_defined ($var);
1168 die "automake: programming error 2 in handle_lib_objects\n"
1169 if $lex_seen && $var =~ /LIBADD/;
1171 # We recognize certain things that are commonly put in LIBADD or
1174 local (@dep_list) = ();
1176 # If no lex source seen, just assume this is ok.
1177 local ($lex_ok) = $lex_seen ? 0 : 1;
1179 local ($seen_libobjs) = 0;
1180 local ($flagvar) = 0;
1182 foreach $lsearch (&variable_value_as_list ($var))
1184 # Skip -lfoo and -Ldir; these are explicitly allowed.
1185 next if $lsearch =~ /^-[lL]/;
1186 if (! $flagvar && $lsearch =~ /^-/)
1188 if ($var =~ /^(.*)LDADD$/)
1190 &am_line_error ($var, "linker flags such as \`$lsearch' belong in \`${1}LDFLAGS");
1194 # Only get this error once.
1196 &am_line_error ($var, "you cannot use linker flags such as \`$lsearch' in \`$var'");
1200 # Assume we have a file of some sort, and push it onto the
1201 # dependency list. Autoconf substitutions are not pushed;
1202 # rarely is a new dependency substituted into (eg) foo_LDADD
1203 # -- but "bad things (eg -lX11) are routinely substituted.
1204 # Note that LIBOBJS and ALLOCA are exceptions to this rule,
1205 # and handled specially below.
1206 push (@dep_list, $lsearch)
1207 unless $lsearch =~ /^\@.*\@$/;
1209 # Automatically handle @LIBOBJS@ and @ALLOCA@. Basically this
1210 # means adding entries to dep_files.
1211 if ($lsearch eq '@LIBOBJS@')
1213 push (@dep_list, $lsearch);
1215 if (! keys %libsources)
1217 &am_line_error ($var, "\@LIBOBJS\@ seen but never set in \`configure.in'");
1220 local ($iter, $rewrite);
1221 foreach $iter (keys %libsources)
1223 if ($iter =~ /\.h$/)
1225 &require_file_with_line ($var, $FOREIGN, $iter);
1227 elsif ($iter ne 'alloca.c')
1229 ($rewrite = $iter) =~ s/\.c$/.P/;
1230 $dep_files{'.deps/' . $rewrite} = 1;
1231 &require_file_with_line ($var, $FOREIGN, $iter);
1235 elsif ($lsearch eq '@ALLOCA@')
1237 push (@dep_list, $lsearch);
1238 &am_line_error ($var,
1239 "\@ALLOCA\@ seen but \`AC_FUNC_ALLOCA' not in \`configure.in'")
1240 if ! defined $libsources{'alloca.c'};
1241 $dep_files{'.deps/alloca.P'} = 1;
1242 &require_file_with_line ($var, $FOREIGN, 'alloca.c');
1244 elsif ($lsearch eq '@LEXLIB@')
1246 # FIXME: variable_value_as_list requires us to force
1247 # @LEXLIB@ here, where we'd really prefer $(LEXLIB).
1248 # Nasty -- this will have to wait until many cleanups are
1257 &am_line_error ($var, 'lex source file used without @LEXLIB@');
1260 if ($xname ne '' && ! &variable_defined ($xname . '_DEPENDENCIES'))
1262 &define_pretty_variable ($xname . '_DEPENDENCIES', @dep_list);
1265 return $seen_libobjs;
1268 # Handle C programs.
1271 local (@proglist) = &am_install_var ('-clean', '-ltlibs',
1272 'progs', 'PROGRAMS',
1273 'bin', 'sbin', 'libexec', 'pkglib',
1275 return if ! @proglist;
1277 # If a program is installed, this is required. We only want this
1278 # error to appear once.
1279 &am_conf_error ("AC_ARG_PROGRAM must be used in configure.in")
1280 unless $seen_arg_prog;
1283 local ($one_file, $xname, $munge);
1285 local ($seen_libobjs) = 0;
1286 foreach $one_file (@proglist)
1288 local ($obj) = &get_object_extension ($one_file);
1290 # Canonicalize names.
1291 ($xname = $one_file) =~ tr/A-Za-z0-9_/_/c;
1292 if ($xname ne $one_file)
1295 foreach $xt ('_LDADD', '_LDFLAGS', '_SOURCES', '_OBJECTS', '_DEPENDENCIES')
1297 &am_line_error ($one_file . $xt,
1298 "invalid variable \`" . $one_file . $xt
1299 . "'; should be \`" . $xname . $xt . "'")
1300 if &variable_defined ($one_file . $xt);
1304 # FIXME: Using a trick to figure out if any lex sources appear
1305 # in our program; should use some cleaner method.
1306 local ($lex_num) = scalar (keys %lex_sources);
1307 local ($linker) = &handle_source_transform ($xname, $one_file, $obj);
1308 local ($lex_file_seen) = (scalar (keys %lex_sources) > $lex_num);
1311 if (&variable_defined ($xname . "_LDADD"))
1313 if (&handle_lib_objects ($xname, $xname . '_LDADD',
1323 # User didn't define prog_LDADD override. So do it.
1324 &define_variable ($xname . '_LDADD', '$(LDADD)');
1326 # This does a bit too much work. But we need it to
1327 # generate _DEPENDENCIES when appropriate.
1328 if (&variable_defined ('LDADD'))
1330 if (&handle_lib_objects ($xname, 'LDADD', $lex_file_seen))
1339 if (! &variable_defined ($xname . '_LDFLAGS'))
1341 # Define the prog_LDFLAGS variable.
1342 &define_variable ($xname . '_LDFLAGS', '');
1347 &am_line_error ($xname . $xt,
1348 'lex source file used without @LEXLIB@');
1351 # Determine program to use for link.
1353 if (&variable_defined ($xname . '_LINK'))
1355 $xlink = $xname . '_LINK';
1359 $xlink = $linker ? $linker : 'LINK';
1363 &file_contents_with_transform
1364 ('s/\@PROGRAM\@/' . $one_file . '/go;'
1365 . 's/\@XPROGRAM\@/' . $xname . '/go;'
1366 . 's/\@XLINK\@/' . $xlink . '/go;',
1370 if (&variable_defined ('LDADD') && &handle_lib_objects ('', 'LDADD', 0))
1377 foreach $one_file (@proglist)
1379 # Canonicalize names.
1380 ($xname = $one_file) =~ tr/A-Za-z0-9_/_/c;
1382 if (&variable_defined ($xname . '_LDADD'))
1384 &check_libobjs_sources ($xname, $xname . '_LDADD');
1386 elsif (&variable_defined ('LDADD'))
1388 &check_libobjs_sources ($xname, 'LDADD');
1396 sub handle_libraries
1398 local (@liblist) = &am_install_var ('-clean',
1399 'libs', 'LIBRARIES',
1400 'lib', 'pkglib', 'noinst', 'check');
1401 return if ! @liblist;
1403 local (%valid) = &am_primary_prefixes ('LIBRARIES', 'lib', 'pkglib',
1405 if (! defined $configure_vars{'RANLIB'})
1408 foreach $key (keys %valid)
1410 if (&variable_defined ($key . '_LIBRARIES'))
1412 &am_line_error ($key . '_LIBRARIES', "library used but \`RANLIB' not defined in \`configure.in'");
1413 # Only get this error once.
1414 $configure_vars{'RANLIB'} = 1;
1423 local ($seen_libobjs) = 0;
1424 foreach $onelib (@liblist)
1426 # Check that the library fits the standard naming convention.
1427 if ($onelib !~ /^lib.*\.a$/)
1429 # FIXME this should only be a warning for foreign packages
1430 # FIXME should put line number here. That means mapping
1431 # from library name back to variable name.
1432 &am_error ("\`$onelib' is not a standard library name");
1435 local ($obj) = &get_object_extension ($onelib);
1437 # Canonicalize names.
1438 ($xlib = $onelib) =~ tr/A-Za-z0-9_/_/c;
1439 if ($xlib ne $onelib)
1442 foreach $xt ('_LIBADD', '_SOURCES', '_OBJECTS', '_DEPENDENCIES')
1444 &am_line_error ($onelib . $xt,
1445 "invalid variable \`" . $onelib . $xt
1446 . "'; should be \`" . $xlib . $xt . "'")
1447 if &variable_defined ($onelib . $xt);
1451 if (&variable_defined ($xlib . '_LIBADD'))
1453 if (&handle_lib_objects ($xlib, $xlib . '_LIBADD', 0))
1460 # Generate support for conditional object inclusion in
1462 &define_variable ($xlib . "_LIBADD", '');
1465 &handle_source_transform ($xlib, $onelib, $obj);
1468 &file_contents_with_transform ('s/\@LIBRARY\@/' . $onelib . '/go;'
1476 foreach $onelib (@liblist)
1478 # Canonicalize names.
1479 ($xlib = $onelib) =~ tr/A-Za-z0-9_/_/c;
1480 if (&variable_defined ($xlib . '_LIBADD'))
1482 &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
1487 &define_variable ('AR', 'ar');
1488 &define_configure_variable ('RANLIB');
1491 # See if any _SOURCES variable were misspelled. Also, make sure that
1492 # EXTRA_ variables don't contain configure substitutions.
1495 local ($varname, $primary, $ckey);
1496 foreach $varname (keys %contents)
1498 foreach $primary ('_SOURCES', '_LIBADD', '_LDADD', '_LDFLAGS', '_DEPENDENCIES')
1500 if ($varname =~ /$primary$/ && ! $content_seen{$varname})
1502 &am_line_error ($varname,
1503 "invalid unused variable name: \`$varname'");
1507 if ($varname =~ /^EXTRA_/)
1509 foreach $ckey (&variable_value_as_list ($varname))
1511 if ($ckey =~ /^\@.*\@$/)
1513 &am_line_error ($varname, "variable \`$varname' must not contain configure substitution");
1524 # NOTE we no longer automatically clean SCRIPTS, because it is
1525 # useful to sometimes distribute scripts verbatim. This happens
1526 # eg in Automake itself.
1527 &am_install_var ('scripts', 'SCRIPTS',
1528 'bin', 'sbin', 'libexec', 'pkgdata',
1531 # Set $scripts_installed if appropriate. Make sure we only find
1532 # scripts which are actually installed -- this is why we can't
1533 # simply use the return value of am_install_var.
1534 local (%valid) = &am_primary_prefixes ('SCRIPTS', 'bin', 'sbin',
1535 'libexec', 'pkgdata',
1538 foreach $key (keys %valid)
1540 if ($key ne 'noinst'
1542 && &variable_defined ($key . '_SCRIPTS'))
1544 $scripts_installed = 1;
1545 # push (@check_tests, 'check-' . $key . 'SCRIPTS');
1549 if ($scripts_installed)
1551 # If a program is installed, this is required. We only want this
1552 # error to appear once.
1553 &am_conf_error ("AC_ARG_PROGRAM must be used in configure.in")
1554 unless $seen_arg_prog;
1559 # Search a file for a "version.texi" Texinfo include. Return the name
1560 # of the include file if found, or the empty string if not. A
1561 # "version.texi" file is actually any file whose name matches
1563 sub scan_texinfo_file
1565 local ($filename) = @_;
1567 if (! open (TEXI, $filename))
1569 &am_error ("couldn't open \`$filename': $!");
1572 print "automake: reading $filename\n" if $verbose;
1574 local ($vfile, $outfile);
1577 if (/^\@setfilename +(\S+)/)
1583 if (/^\@include\s+(vers[^.]*\.texi)\s*$/)
1585 # Found version.texi include.
1592 return ($outfile, $vfile);
1595 # Handle all Texinfo source.
1598 &am_line_error ('TEXINFOS',
1599 "\`TEXINFOS' is an anachronism; use \`info_TEXINFOS'")
1600 if &variable_defined ('TEXINFOS');
1601 return if (! &variable_defined ('info_TEXINFOS')
1602 && ! &variable_defined ('html_TEXINFOS'));
1604 local (@texis) = &variable_value_as_list ('info_TEXINFOS');
1606 local (@info_deps_list, @dvis_list, @texi_deps);
1607 local ($infobase, $info_cursor);
1611 local ($tc_cursor, @texi_cleans);
1614 foreach $info_cursor (@texis)
1616 ($infobase = $info_cursor) =~ s/\.texi(nfo)?$//;
1618 # If 'version.texi' is referenced by input file, then include
1619 # automatic versioning capability.
1620 local ($out_file, $vtexi) = &scan_texinfo_file ($relative_dir
1621 . "/" . $info_cursor);
1623 if ($out_file eq '')
1625 &am_error ("\`$info_cursor' missing \@setfilename");
1629 if ($out_file =~ /\.(.+)$/ && $1 ne 'info')
1631 # FIXME should report line number in input file.
1632 &am_error ("output of \`$info_cursor', \`$out_file', has unrecognized extension");
1638 &am_error ("\`$vtexi', included in \`$info_cursor', also included in \`$versions{$vtexi}'")
1639 if (defined $versions{$vtexi});
1640 $versions{$vtexi} = $info_cursor;
1642 # We number the stamp-vti files. This is doable since the
1643 # actual names don't matter much. We only number starting
1644 # with the second one, so that the common case looks nice.
1645 $vti = 'vti' . ($done ? $done : '');
1646 &push_dist_common ($vtexi, 'stamp-' . $vti);
1647 push (@clean, $vti);
1649 # Only require once.
1650 &require_conf_file_with_line ('info_TEXINFOS', $FOREIGN,
1656 ($conf_pat = $config_aux_dir) =~ s/(\W)/\\$1/g;
1658 &file_contents_with_transform
1659 ('s/\@TEXI\@/' . $info_cursor . '/g; '
1660 . 's/\@VTI\@/' . $vti . '/g; '
1661 . 's/\@VTEXI\@/' . $vtexi . '/g;'
1662 . 's,\@MDDIR\@,' . $conf_pat . ',g;',
1665 &push_phony_cleaners ($vti);
1668 # If user specified file_TEXINFOS, then use that as explicit
1671 push (@texi_deps, $info_cursor);
1672 push (@texi_deps, $vtexi) if $vtexi;
1674 # Canonicalize name first.
1675 ($canonical = $infobase) =~ tr/A-Za-z0-9_/_/c;
1676 if (&variable_defined ($canonical . "_TEXINFOS"))
1678 push (@texi_deps, '$(' . $canonical . '_TEXINFOS)');
1679 &push_dist_common ('$(' . $canonical . '_TEXINFOS)');
1682 $output_rules .= ("\n" . $out_file . ": "
1683 . join (' ', @texi_deps)
1684 . "\n" . $infobase . ".dvi: "
1685 . join (' ', @texi_deps)
1688 push (@info_deps_list, $out_file);
1689 push (@dvis_list, $infobase . '.dvi');
1691 # Generate list of things to clean for this target. We do
1692 # this explicitly because otherwise too many things could be
1693 # removed. In particular the ".log" extension might
1694 # reasonably be used in other contexts by the user.
1695 foreach $tc_cursor ('aux', 'cp', 'cps', 'dvi', 'fn', 'fns',
1696 'ky', 'log', 'pg', 'toc', 'tp', 'tps',
1699 push (@texi_cleans, $infobase . '.' . $tc_cursor);
1703 # Find these programs wherever they may lie. Yes, this has
1704 # intimate knowledge of the structure of the texinfo distribution.
1705 &define_program_variable ('MAKEINFO', 'build', 'texinfo/makeinfo',
1707 &define_program_variable ('TEXI2DVI', 'src', 'texinfo/util',
1713 $xform = 's/^NOTCYGNUS.*$//; s/^CYGNUS//;';
1717 $xform = 's/^CYGNUS.*$//; s/^NOTCYGNUS//;';
1719 $output_rules .= &file_contents_with_transform ($xform, 'texinfos');
1720 push (@phony, 'install-info-am', 'uninstall-info');
1721 push (@dist_targets, 'dist-info');
1724 $output_rules .= "\nmostlyclean-info:\n";
1725 &pretty_print_rule ("\trm -f", "\t ", @texi_cleans);
1726 $output_rules .= ("\nclean-info:\n\ndistclean-info:\n\n"
1727 . "maintainer-clean-info:\n\t"
1728 . 'for i in $(INFO_DEPS); do rm -f `eval echo $$i*`; done'
1730 &push_phony_cleaners ('info');
1732 push (@suffixes, '.texi', '.texinfo', '.info', '.dvi', '.ps');
1734 if (! defined $options{'no-installinfo'})
1736 push (@uninstall, 'uninstall-info');
1737 push (@installdirs, '$(infodir)');
1738 unshift (@install_data, 'install-info-am');
1740 # Make sure documentation is made and installed first. Use
1741 # $(INFO_DEPS), not 'info', because otherwise recursive makes
1742 # get run twice during "make all".
1743 unshift (@all, '$(INFO_DEPS)');
1745 push (@clean, 'info');
1746 push (@info, '$(INFO_DEPS)');
1747 push (@dvi, '$(DVIS)');
1749 &define_variable ("INFO_DEPS", join (' ', @info_deps_list));
1750 &define_variable ("DVIS", join (' ', @dvis_list));
1751 # This next isn't strictly needed now -- the places that look here
1752 # could easily be changed to look in info_TEXINFOS. But this is
1753 # probably better, in case noinst_TEXINFOS is ever supported.
1754 &define_variable ("TEXINFOS", $contents{'info_TEXINFOS'});
1756 # Do some error checking. Note that this file is not required
1757 # when in Cygnus mode -- a bletcherous hack.
1758 &require_file_with_line ('info_TEXINFOS',
1759 $cygnus_mode ? $GNU : $FOREIGN,
1761 unless defined $options{'no-texinfo.tex'};
1764 # Handle any man pages.
1765 sub handle_man_pages
1767 &am_line_error ('MANS', "\`MANS' is an anachronism; use \`man_MANS'")
1768 if &variable_defined ('MANS');
1769 return if ! &variable_defined ('man_MANS');
1771 # We generate the manpage install code by hand to avoid the use of
1772 # basename in the generated Makefile.
1773 local (@mans) = &variable_value_as_list ('man_MANS');
1774 local (%sections, %inames, %mbases, %secmap, %fullsecmap);
1778 # FIXME: statement without effect:
1779 /^(.*)\.([0-9])([a-z]*)$/;
1784 $fullsecmap{$i} = $2 . $3;
1788 # We don't really need this, but we use it in case we ever want to
1789 # support noinst_MANS.
1790 &define_variable ("MANS", $contents{'man_MANS'});
1792 # Generate list of install dirs.
1793 $output_rules .= "install-man: \$(MANS)\n";
1794 $output_rules .= "\t\$(NORMAL_INSTALL)\n";
1795 # Sort keys so that output is deterministic.
1796 foreach (sort keys %sections)
1798 push (@installdirs, '$(mandir)/man' . $_)
1799 unless defined $options{'no-installman'};
1800 $output_rules .= ("\t" . '$(mkinstalldirs) $(mandir)/man'
1803 push (@phony, 'install-man');
1805 # Generate install target.
1807 foreach $key (sort keys %inames)
1809 $_ = $install_man_format;
1810 s/\@SECTION\@/$secmap{$key}/g;
1811 s/\@MAN\@/$inames{$key}/g;
1812 s/\@FULLSECT\@/$fullsecmap{$key}/g;
1813 s/\@MANBASE\@/$mbases{$key}/g;
1814 $output_rules .= $_;
1816 $output_rules .= "\n";
1818 $output_rules .= "uninstall-man:\n";
1819 foreach $key (sort keys %inames)
1821 $_ = $uninstall_man_format;
1822 s/\@SECTION\@/$secmap{$key}/g;
1823 s/\@MAN\@/$inames{$key}/g;
1824 s/\@FULLSECT\@/$fullsecmap{$key}/g;
1825 s/\@MANBASE\@/$mbases{$key}/g;
1826 $output_rules .= $_;
1828 $output_rules .= "\n";
1829 push (@phony, 'uninstall-man');
1831 $output_vars .= &file_contents ('mans-vars');
1833 if (! defined $options{'no-installman'})
1835 push (@install_data, 'install-man');
1836 push (@uninstall, 'uninstall-man');
1837 push (@all, '$(MANS)');
1841 # Handle DATA variables.
1844 &am_install_var ('data', 'DATA', 'data', 'sysconf',
1845 'sharedstate', 'localstate', 'pkgdata',
1852 push (@phony, 'tags');
1853 local (@tag_deps) = ();
1854 if (&variable_defined ('SUBDIRS'))
1856 $output_rules .= ("tags-recursive:\n"
1857 . "\tlist=\"\$(SUBDIRS)\"; for subdir in \$\$list; do \\\n"
1858 # Never fail here if a subdir fails; it
1860 . "\t (cd \$\$subdir && \$(MAKE) tags); \\\n"
1862 push (@tag_deps, 'tags-recursive');
1863 push (@phony, 'tags-recursive');
1866 if ($dir_holds_sources
1867 || $dir_holds_headers
1868 || &variable_defined ('ETAGS_ARGS')
1871 local ($xform) = '';
1872 if ($config_header && $relative_dir eq &dirname ($config_header))
1874 # The config header is in this directory. So require it.
1875 ($xform = &basename ($config_header)) =~ s/(\W)/\\$1/g;
1877 $xform = ('s/\@CONFIG\@/' . $xform . '/;'
1878 . 's/\@DIRS\@/' . join (' ', @tag_deps) . '/;');
1880 $output_rules .= &file_contents_with_transform ($xform, 'tags');
1881 $output_rules .= &file_contents ('tags-clean');
1882 push (@clean, 'tags');
1883 &push_phony_cleaners ('tags');
1884 &examine_variable ('TAGS_DEPENDENCIES');
1886 elsif (&variable_defined ('TAGS_DEPENDENCIES'))
1888 &am_line_error ('TAGS_DEPENDENCIES',
1889 "doesn't make sense to define \`TAGS_DEPENDENCIES' without sources or \`ETAGS_ARGS'");
1893 # Every Makefile must define some sort of TAGS rule.
1894 # Otherwise, it would be possible for a top-level "make TAGS"
1895 # to fail because some subdirectory failed.
1896 $output_rules .= "tags: TAGS\nTAGS:\n\n";
1900 # Worker for handle_dist.
1901 sub handle_dist_worker
1903 $output_rules .= 'distdir: $(DISTFILES)' . "\n";
1905 # Initialization; only at top level.
1906 if ($relative_dir eq '.')
1908 if ($strictness >= $GNITS)
1910 # For Gnits users, this is pretty handy. Look at 15 lines
1911 # in case some explanatory text is desirable.
1912 $output_rules .= ' @if sed 15q $(srcdir)/NEWS | fgrep -e "$(VERSION)" > /dev/null; then :; else \\
1913 echo "NEWS not updated; not releasing" 1>&2; \\
1921 # Create dist directory.
1924 -chmod 755 $(distdir)
1927 # Only run automake in `dist' target if --include-deps not
1928 # specified. That way the recipient of a distribution can run
1929 # "make dist" and not need Automake.
1930 if ($cmdline_use_dependencies)
1934 # We need an absolute path for --output-dir. Thus the
1936 ' here=`pwd`; distdir=`cd $(distdir) && pwd` \\
1938 && automake --include-deps --build-dir=$$here --srcdir-name=$(srcdir) --output-dir=$$distdir '
1939 # Set strictness of output.
1940 . ($cygnus_mode ? '--cygnus' : ('--' . $strictness_name))
1946 # Scan EXTRA_DIST to see if we need to distribute anything from a
1947 # subdir. If so, add it to the list. I didn't want to do this
1948 # originally, but there were so many requests that I finally
1951 if (&variable_defined ('EXTRA_DIST'))
1953 foreach (&variable_value_as_list ('EXTRA_DIST'))
1956 next unless s,/+[^/]+$,,;
1957 push (@dist_dirs, $_)
1963 # Prepend $(distdir) to each directory given. Doing it via a
1964 # hash lets us ensure that each directory is used only once.
1966 grep ($dhash{'$(distdir)/' . $_} = 1, @dist_dirs);
1967 $output_rules .= "\t";
1968 &pretty_print_rule ('$(mkinstalldirs)', "\t ", sort keys %dhash);
1971 # In loop, test for file existence because sometimes a file gets
1972 # included in DISTFILES twice. For example this happens when a
1973 # single source file is used in building more than one program.
1974 # Also, there are situations in which "ln" can fail. For instance
1975 # a file to distribute could actually be a cross-filesystem
1976 # symlink -- this can easily happen if "gettextize" was run on the
1978 $output_rules .= "\t\@for file in \$(DISTFILES); do \\\n";
1981 $output_rules .= "\t if test -f \$\$file; then d=.; else d=\$(srcdir); fi; \\\n";
1985 $output_rules .= "\t d=\$(srcdir); \\\n";
1987 $output_rules .= ' test -f $(distdir)/$$file \\
1988 || ln $$d/$$file $(distdir)/$$file 2> /dev/null \\
1989 || cp -p $$d/$$file $(distdir)/$$file; \\
1993 # If we have SUBDIRS, create all dist subdirectories and do
1995 if (&variable_defined ('SUBDIRS'))
1997 # Test for directory existence here because previous automake
1998 # invocation might have created some directories. Note that
1999 # we explicitly set distdir for the subdir make; that lets us
2000 # mix-n-match many automake-using packages into one large
2001 # package, and have "dist" at the top level do the right
2003 $output_rules .= ' for subdir in $(SUBDIRS); do \\
2004 test -d $(distdir)/$$subdir \\
2005 || mkdir $(distdir)/$$subdir \\
2007 chmod 755 $(distdir)/$$subdir; \\
2008 (cd $$subdir && $(MAKE) distdir=../$(distdir)/$$subdir distdir) \\
2014 # If the target `dist-hook' exists, make sure it is run. This
2015 # allows users to do random weird things to the distribution
2016 # before it is packaged up.
2017 push (@dist_targets, 'dist-hook') if defined $contents{'dist-hook'};
2020 foreach $targ (@dist_targets)
2022 # We must explicitly set distdir for these sub-makes.
2023 $output_rules .= "\t\$(MAKE) distdir=\"\$(distdir)\" $targ\n";
2026 push (@phony, 'distdir');
2029 # Handle 'dist' target.
2032 # Set up maint_charset.
2033 $local_maint_charset = $contents{'MAINT_CHARSET'}
2034 if &variable_defined ('MAINT_CHARSET');
2035 $maint_charset = $local_maint_charset
2036 if $relative_dir eq '.';
2038 if (&variable_defined ('DIST_CHARSET'))
2040 &am_line_error ('DIST_CHARSET',
2041 "DIST_CHARSET defined but no MAINT_CHARSET defined")
2042 if ! $local_maint_charset;
2043 if ($relative_dir eq '.')
2045 $dist_charset = $contents{'DIST_CHARSET'}
2049 &am_line_error ('DIST_CHARSET',
2050 "DIST_CHARSET can only be defined at top level");
2054 # Look for common files that should be included in distribution.
2056 foreach $cfile (@common_files)
2058 if (-f ($relative_dir . "/" . $cfile))
2060 &push_dist_common ($cfile);
2064 # Keys of %dist_common are names of files to distributed. We put
2065 # README first because it then becomes easier to make a
2066 # Usenet-compliant shar file (in these, README must be first).
2067 # FIXME: do more ordering of files here.
2069 if (defined $dist_common{'README'})
2071 push (@coms, 'README');
2072 undef $dist_common{'README'};
2074 push (@coms, sort keys %dist_common);
2076 &define_pretty_variable ("DIST_COMMON", @coms);
2077 $output_vars .= "\n";
2080 $output_vars .= &file_contents ('dist-vars') . "\n";
2081 &define_variable ('TAR', $TAR);
2082 &define_variable ('GZIP', '--best');
2084 # Put these things in rules section so it is easier for whoever
2085 # reads Makefile.in.
2086 if (! &variable_defined ('distdir'))
2088 if ($relative_dir eq '.')
2090 $output_rules .= "\n" . 'distdir = $(PACKAGE)-$(VERSION)' . "\n";
2094 $output_rules .= ("\n"
2095 . 'distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)'
2099 if ($relative_dir ne '.')
2101 $output_rules .= "\nsubdir = " . $relative_dir . "\n";
2104 # Generate 'dist' target, and maybe dist-shar / dist-zip / dist-tarZ.
2105 if ($relative_dir eq '.')
2107 # Rule to check whether a distribution is viable.
2108 $output_rules .= ('# This target untars the dist file and tries a VPATH configuration. Then
2109 # it guarantees that the distribution is self-contained by making another
2113 GZIP=$(GZIP) $(TAR) zxf $(distdir).tar.gz
2114 mkdir $(distdir)/=build
2115 mkdir $(distdir)/=inst
2116 dc_install_base=`cd $(distdir)/=inst && pwd`; \\'
2117 . (defined $contents{'distcheck-hook'}
2118 ? "\t\$(MAKE) distcheck-hook"
2121 cd $(distdir)/=build \\
2124 . ($seen_gettext ? '--with-included-gettext ' : '')
2125 . '--srcdir=.. --prefix=$$dc_install_base \\
2129 && $(MAKE) install \\
2130 && $(MAKE) installcheck \\
2133 @echo "========================"; \\
2134 echo "$(distdir).tar.gz is ready for distribution"; \\
2135 echo "========================"
2138 local ($dist_all) = ('dist-all: distdir' . "\n"
2141 foreach $curs ('dist', 'dist-shar', 'dist-zip', 'dist-tarZ')
2143 if (defined $options{$curs} || $curs eq 'dist')
2145 $output_rules .= ($curs . ': distdir' . "\n"
2149 $dist_all .= $dist{$curs};
2152 $output_rules .= $dist_all . $dist_trailer;
2155 # Generate distdir target.
2156 &handle_dist_worker;
2159 # Scan a single dependency file and rewrite the dependencies as
2160 # appropriate. Essentially this means:
2161 # * Clean out absolute dependencies which are not desirable.
2162 # * Rewrite other dependencies to be relative to $(top_srcdir).
2163 sub scan_dependency_file
2165 local ($depfile) = @_;
2167 if (! open (DEP_FILE, $depfile))
2169 &am_error ("couldn't open \`$depfile': $!");
2172 print "automake: reading $depfile\n" if $verbose;
2174 # Sometimes it is necessary to omit some dependencies.
2175 local (%omit) = %omit_dependencies;
2176 if (&variable_defined ('OMIT_DEPENDENCIES'))
2178 grep ($omit{$_} = 1, &variable_value_as_list ('OMIT_DEPENDENCIES'));
2181 local ($first_line) = 1;
2182 local ($last_line) = 0;
2183 local ($target, @dependencies);
2184 local ($one_dep, $xform);
2187 local ($srcdir_rx, $fixup_rx);
2188 # If the top srcdir is absolute, then the current directory is
2189 # just relative_dir. But if the top srcdir is relative, then we
2190 # need to add some dots first. The same holds when matching
2192 if ($srcdir_name =~ /^\//)
2194 ($fixup_rx = $srcdir_name . '/' . $relative_dir . '/')
2196 ($srcdir_rx = $srcdir_name . '/') =~ s/(\W)/\\$1/g;
2200 ($fixup_rx = ($srcdir_name . '/' . $top_builddir . '/'
2201 . $relative_dir . '/')) =~ s/(\W)/\\$1/g;
2202 $srcdir_rx = $srcdir_name . '/';
2203 # Don't append a spurious "." to the regex.
2204 $srcdir_rx .= $top_builddir
2205 unless $top_builddir eq '.';
2206 $srcdir_rx =~ s/(\W)/\\$1/g;
2209 local ($rewrite_builddir) = (($top_builddir eq '.')
2211 : $top_builddir . '/');
2217 # If LAST_LINE set then we've already seen what we thought
2218 # was the last line.
2221 next if (/$WHITE_PATTERN/o);
2225 # No trailing "\" means this should be the last line.
2231 if (! /^([^:]+:)(.+)$/)
2234 &am_error ("\`$depfile' has incorrect format");
2245 foreach $one_dep (split (' ', $_))
2247 if ($one_dep =~ /^$fixup_rx/)
2249 # The dependency points to the current directory in
2251 ($xform = $one_dep) =~ s/^$fixup_rx//;
2252 push (@dependencies, $xform);
2254 elsif ($one_dep =~ /^$srcdir_rx/)
2256 # The dependency is in some other directory in the package.
2257 ($xform = $one_dep) =~ s/^$srcdir_rx/$rewrite_builddir/;
2258 push (@dependencies, $xform);
2260 elsif ($one_dep =~ /^\//)
2262 # Absolute path; ignore.
2266 # Anything else is assumed to be correct. But first
2267 # make sure it is not on our list of dependencies to
2269 ($just_file = $one_dep) =~ s,^.*/,,;
2270 push (@dependencies, $one_dep)
2271 if ! defined $omit{$just_file};
2276 &pretty_print_rule ($target, "\t", @dependencies);
2281 # Handle auto-dependency code.
2282 sub handle_dependencies
2284 if ($use_dependencies)
2286 # Include GNU-make-specific auto-dep code.
2287 if ($dir_holds_sources)
2289 &define_pretty_variable ('DEP_FILES', sort keys %dep_files);
2290 $output_rules .= &file_contents ('depend');
2291 push (@clean, 'depend');
2292 &push_phony_cleaners ('depend');
2294 &file_contents_with_transform ('s/\@EXT\@/.c/g;'
2295 . 's/\@MKDEP\@/MKDEP/g;'
2299 local ($need_cxx) = 0;
2300 foreach $ext (sort keys %cxx_extensions)
2303 &file_contents_with_transform ('s/\@EXT\@/' . $ext .'/g;'
2304 . 's/\@MKDEP\@/CXXMKDEP/g;'
2311 &define_variable ('CXXMKDEP', '$(CXX) -M $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CXXFLAGS)');
2315 elsif ($build_directory ne '')
2317 # Include any auto-generated deps that are present. Note that
2318 # $build_directory ends in a "/".
2319 if (-d ($build_directory . $relative_dir . "/.deps")
2320 && -f ($build_directory . $relative_dir . "/.deps/.P"))
2324 foreach $depfile (&my_glob ($build_directory
2325 . $relative_dir . "/.deps/*.P"))
2327 &scan_dependency_file ($depfile);
2330 $output_rules .= "\n";
2335 # Handle subdirectories.
2338 return if ! &variable_defined ('SUBDIRS');
2340 # Make sure each directory mentioned in SUBDIRS actually exists.
2342 foreach $dir (&variable_value_as_list ('SUBDIRS'))
2344 # Skip directories substituted by configure.
2345 next if $dir =~ /^\@.*\@$/;
2347 if (! -d $am_relative_dir . '/' . $dir)
2349 &am_line_error ('SUBDIRS',
2350 "required directory $am_relative_dir/$dir does not exist");
2354 &am_relative_dir ('SUBDIRS',
2355 "directory should not contain \`/'")
2359 local ($xform) = ('s/\@INSTALLINFO\@/' .
2360 (defined $options{'no-installinfo'}
2361 ? 'install-info-recursive'
2364 $output_rules .= &file_contents_with_transform ($xform, 'subdirs');
2366 # Push a bunch of phony targets.
2368 foreach $phonies ('-data', '-exec', 'dirs')
2370 push (@phony, 'install' . $phonies . '-recursive');
2371 push (@phony, 'uninstall' . $phonies . '-recursive');
2373 foreach $phonies ('all', 'check', 'installcheck', 'info', 'dvi')
2375 push (@phony, $phonies . '-recursive');
2377 &push_phony_cleaners ('recursive');
2379 push (@check_tests, "check-recursive");
2380 push (@installcheck, "installcheck-recursive");
2381 push (@info, "info-recursive");
2382 push (@dvi, "dvi-recursive");
2384 $recursive_install = 1;
2387 # Handle aclocal.m4.
2388 sub handle_aclocal_m4
2390 local ($regen_aclocal) = 0;
2391 if (-f 'aclocal.m4')
2393 &define_variable ("ACLOCAL", '$(top_srcdir)/aclocal.m4');
2394 &push_dist_common ('aclocal.m4');
2396 if (open (ACLOCAL, '< aclocal.m4'))
2402 if ($line =~ 'generated automatically by aclocal')
2409 local ($acinclude) = 0;
2410 if (-f 'acinclude.m4')
2416 # Note that it might be possible that aclocal.m4 doesn't exist but
2417 # should be auto-generated. This case probably isn't very
2421 local (@ac_deps) = (
2422 ($seen_maint_mode ? "\@MAINT\@" : "") ,
2424 ($acinclude ? ' acinclude.m4' : '')
2427 # Scan all -I directories for m4 files. These are our
2429 if (&variable_defined ('ACLOCAL_AMFLAGS'))
2432 foreach $amdir (&variable_value_as_list ('ACLOCAL_AMFLAGS'))
2434 if ($amdir =~ s/^-I//
2438 push (@ac_deps, &my_glob ($am_dir . '/*.m4'));
2443 &pretty_print_rule ("\$(srcdir)/aclocal.m4:", "\t\t", @ac_deps);
2445 $output_rules .= ("\t"
2446 . 'cd $(srcdir) && aclocal'
2447 . (&variable_defined ('ACLOCAL_AMFLAGS')
2448 ? ' $(ACLOCAL_AMFLAGS)' : '')
2453 # Rewrite a list of input files into a form suitable to put on a
2454 # dependency list. The idea is that if an input file has a directory
2455 # part the same as the current directory, then the directory part is
2456 # simply removed. But if the directory part is different, then
2457 # $(top_srcdir) is prepended. Among other things, this is used to
2458 # generate the dependency list for the output files generated by
2459 # AC_OUTPUT. Consider what the dependencies should look like in this
2461 # AC_OUTPUT(src/out:src/in1:lib/in2)
2462 sub rewrite_inputs_into_dependencies
2464 local (@inputs) = @_;
2465 local ($single, @newinputs);
2467 foreach $single (@inputs)
2469 if (&dirname ($single) eq $relative_dir)
2471 push (@newinputs, &basename ($single));
2475 push (@newinputs, '$(top_srcdir)/' . $single);
2482 # Handle remaking and configure stuff.
2483 # We need the name of the input file, to do proper remaking rules.
2484 sub handle_configure
2486 local ($local, $input, @secondary_inputs) = @_;
2488 # If SUBDIRS defined, require AC_PROG_MAKE_SET.
2489 &am_line_error ('SUBDIRS', "AC_PROG_MAKE_SET must be used in configure.in")
2490 if &variable_defined ('SUBDIRS') && ! $seen_make_set;
2492 local ($top_reldir);
2494 local ($input_base) = &basename ($input);
2495 local ($local_base) = &basename ($local);
2497 local ($amfile) = $input_base . '.am';
2498 # We know we can always add '.in' because it really should be an
2499 # error if the .in was missing originally.
2500 local ($infile) = '$(srcdir)/' . $input_base . '.in';
2501 local ($colon_infile);
2502 if ($local ne $input)
2504 $colon_infile = ':' . $input . '.in';
2506 $colon_infile .= ':' . join (':', @secondary_inputs)
2507 if @secondary_inputs;
2509 local (@rewritten) = &rewrite_inputs_into_dependencies (@secondary_inputs);
2510 # This rule remakes the Makefile.in. Note use of @MAINT@ forces
2511 # us to abandon pretty-printing. Sigh.
2512 $output_rules .= ($infile
2513 # NOTE perl 5.003 (with -w) gives a
2514 # uninitialized value error on the next line.
2517 . ($seen_maint_mode ? '@MAINT@ ' : '')
2519 . '$(top_srcdir)/configure.in $(ACLOCAL) '
2520 . join (' ', @rewritten) . "\n"
2521 . "\tcd \$(top_srcdir) && automake "
2522 . ($cygnus_mode ? '--cygnus' : ('--' . $strictness_name))
2523 . ' ' . $input . $colon_infile . "\n\n");
2525 # This rule remakes the Makefile.
2526 $output_rules .= ($local_base
2527 # NOTE: bogus uninit value error on next line;
2528 # see comment above.
2531 . '$(top_builddir)/config.status $(BUILT_SOURCES)'
2533 . "\tcd \$(top_builddir) \\\n"
2534 . "\t && CONFIG_FILES="
2535 . (($relative_dir eq '.') ? '$@' : '$(subdir)/$@')
2537 . ' CONFIG_HEADERS= $(SHELL) ./config.status'
2540 if ($relative_dir ne '.')
2543 $top_reldir = '../';
2548 $output_rules .= &file_contents ('remake');
2549 &examine_variable ('CONFIGURE_DEPENDENCIES');
2553 # If we have a configure header, require it.
2554 if ($config_header && $relative_dir eq &dirname ($config_header))
2556 local ($ch_sans_dir) = &basename ($config_header);
2557 local ($cn_sans_dir) = &basename ($config_name);
2559 &require_file_with_conf_line ($config_header_line,
2560 $FOREIGN, $ch_sans_dir);
2562 # Header defined and in this directory.
2564 if (-f $relative_dir . '/acconfig.h')
2566 push (@files, 'acconfig.h');
2568 if (-f $config_name . '.top')
2570 push (@files, "${cn_sans_dir}.top");
2572 if (-f $config_name . '.bot')
2574 push (@files, "${cn_sans_dir}.bot");
2577 &push_dist_common (@files);
2578 $output_rules .= &file_contents_with_transform ('s/\@FILES\@/'
2579 . join (' ', @files)
2583 &touch ($relative_dir . '/stamp-h.in');
2584 &require_file_with_conf_line ($config_header_line, $FOREIGN,
2587 push (@clean, 'hdr');
2588 &push_phony_cleaners ('hdr');
2589 &define_variable ("CONFIG_HEADER_IN", "${ch_sans_dir}");
2592 # Set location of mkinstalldirs.
2593 if ($config_aux_dir ne '.' && $config_aux_dir ne '')
2595 &define_variable ('mkinstalldirs', ('$(SHELL) ' . $config_aux_dir
2596 . '/mkinstalldirs'));
2600 &define_variable ('mkinstalldirs',
2601 '$(SHELL) $(top_srcdir)/mkinstalldirs');
2604 &am_line_error ('CONFIG_HEADER',
2605 "\`CONFIG_HEADER' is an anachronism; now determined from \`configure.in'")
2606 if &variable_defined ('CONFIG_HEADER');
2610 # Generate CONFIG_HEADER define.
2611 if ($relative_dir eq &dirname ($config_name))
2613 &define_variable ("CONFIG_HEADER", &basename ($config_name));
2617 &define_variable ("CONFIG_HEADER",
2618 "${top_builddir}/${config_name}");
2622 # Now look for other files in this directory which must be remade
2623 # by config.status, and generate rules for them.
2624 local (@actual_other_files) = ();
2625 local ($file, $local);
2626 local (@inputs, @rewritten_inputs, $single);
2627 foreach $file (@other_input_files)
2629 if ($file =~ /^(.*):(.*)$/)
2631 # This is the ":" syntax of AC_OUTPUT.
2633 $local = &basename ($file);
2634 @inputs = split (':', $2);
2635 @rewritten_inputs = &rewrite_inputs_into_dependencies (@inputs);
2640 $local = &basename ($file);
2641 @inputs = ($local . '.in');
2643 &rewrite_inputs_into_dependencies ($file . '.in');
2646 # Skip files not in this directory.
2647 next unless &dirname ($file) eq $relative_dir;
2649 # Skip the config header.
2650 next if $local eq $top_builddir . '/' . $config_name;
2652 # Skip any Makefile.
2653 next if $local eq 'Makefile';
2655 $output_rules .= ($local . ': '
2656 . '$(top_builddir)/config.status '
2657 . join (' ', @rewritten_inputs) . "\n"
2659 . 'cd $(top_builddir) && CONFIG_FILES='
2660 . ($relative_dir eq '.' ? '' : '$(subdir)/')
2661 . '$@' . (length (@rewritten_inputs) > 1
2662 ? (':' . join (':', @rewritten_inputs))
2664 . ' CONFIG_HEADERS= ./config.status'
2666 push (@actual_other_files, $local);
2668 # Require all input files.
2669 &require_file_with_conf_line ($ac_output_line, $FOREIGN,
2673 # These files get removed by "make clean".
2674 &define_pretty_variable ('CONFIG_CLEAN_FILES', @actual_other_files);
2680 $dir_holds_headers = &am_install_var ('header', 'HEADERS', 'include',
2681 'oldinclude', 'pkginclude',
2687 return if ! $seen_gettext || $relative_dir ne '.';
2689 if (! &variable_defined ('SUBDIRS'))
2692 ("AM_GNU_GETTEXT in configure.in but SUBDIRS not defined");
2696 &require_file_with_conf_line ($ac_gettext_line, $FOREIGN, 'ABOUT-NLS')
2699 if (&variable_defined ('SUBDIRS'))
2703 "AM_GNU_GETTEXT in configure.in but \`po' not in SUBDIRS")
2704 if $contents{'SUBDIRS'} !~ /\bpo\b/;
2707 "AM_GNU_GETTEXT in configure.in but \`intl' not in SUBDIRS")
2708 if $contents{'SUBDIRS'} !~ /\bintl\b/;
2711 # Ensure that each language in ALL_LINGUAS has a .po file, and
2712 # each po file is mentioned in ALL_LINGUAS.
2715 local (%linguas) = ();
2716 grep ($linguas{$_} = 1, split (' ', $all_linguas));
2723 &am_line_error ($all_linguas_line,
2724 ("po/$_.po exists but \`$_' not in \`ALL_LINGUAS'"))
2728 foreach (keys %linguas)
2730 &am_line_error ($all_linguas_line,
2731 "$_ in \`ALL_LINGUAS' but po/$_.po does not exist")
2737 &am_error ("AM_GNU_GETTEXT in configure.in but \`ALL_LINGUAS' not defined");
2741 # Handle footer elements.
2744 if ($contents{'SOURCES'})
2746 # NOTE don't use define_pretty_variable here, because
2747 # $contents{...} is already defined.
2748 $output_vars .= 'SOURCES = ' . $contents{'SOURCES'} . "\n";
2750 if ($contents{'OBJECTS'})
2752 # NOTE don't use define_pretty_variable here, because
2753 # $contents{...} is already defined.
2754 $output_vars .= 'OBJECTS = ' . $contents{'OBJECTS'} . "\n";
2756 if ($contents{'SOURCES'} || $contents{'OBJECTS'})
2758 $output_vars .= "\n";
2761 if (&variable_defined ('SUFFIXES'))
2763 # Push actual suffixes, and not $(SUFFIXES). Some versions of
2764 # make do not like variable substitutions on the .SUFFIXES
2766 push (@suffixes, &variable_value_as_list ('SUFFIXES'));
2769 # Note: AIX 4.1 /bin/make will fail if any suffix rule appears
2770 # before .SUFFIXES. So we make sure that .SUFFIXES appears before
2771 # anything else, by sticking it right after the default: target.
2772 $output_header .= ".SUFFIXES:\n";
2775 $output_header .= ".SUFFIXES: " . join (' ', @suffixes) . "\n";
2777 $output_trailer .= &file_contents ('footer');
2780 # Deal with installdirs target.
2781 sub handle_installdirs
2783 # GNU Makefile standards recommend this.
2784 $output_rules .= ("installdirs:"
2785 . ($recursive_install
2786 ? " installdirs-recursive\n"
2788 push (@phony, 'installdirs');
2791 &pretty_print_rule ("\t" . '$(mkinstalldirs) ', "\t\t",
2794 $output_rules .= "\n";
2797 # There are several targets which need to be merged. This is because
2798 # their complete definition is compiled from many parts. Note that we
2799 # avoid double colon rules, otherwise we'd use them instead.
2800 sub handle_merge_targets
2802 # There are a few install-related variables that you should not define.
2804 foreach $var ('PRE_INSTALL', 'POST_INSTALL', 'NORMAL_INSTALL')
2806 if (&variable_defined ($var))
2808 &am_line_error ($var, "\`$var' should not be defined");
2812 push (@all, 'Makefile');
2813 push (@all, &basename ($config_name))
2814 if $config_name && &dirname ($config_name) eq $relative_dir;
2816 &do_one_merge_target ('info', @info);
2817 &do_one_merge_target ('dvi', @dvi);
2818 &do_check_merge_target;
2819 &do_one_merge_target ('installcheck', @installcheck);
2821 if (defined $options{'no-installinfo'})
2823 # FIXME: this is kind of a hack; should find another way to
2824 # know that this is required.
2826 if (grep ($_ eq 'install-info-am', @phony))
2828 push (@dirs, 'install-info-am');
2830 if (&variable_defined ('SUBDIRS'))
2832 push (@dirs, 'install-info-recursive');
2834 &do_one_merge_target ('install-info', @dirs);
2837 # Handle the various install targets specially. We do this so
2838 # that (eg) "make install-exec" will run "install-exec-recursive"
2839 # if required, but "make install" won't run it twice. Step one is
2840 # to see if the user specified local versions of any of the
2841 # targets we handle. "all" is treated as one of these since
2842 # "install" can run it.
2843 push (@install_exec, 'install-exec-local')
2844 if defined $contents{'install-exec-local'};
2845 push (@install_data, 'install-data-local')
2846 if defined $contents{'install-data-local'};
2847 push (@uninstall, 'uninstall-local')
2848 if defined $contents{'uninstall-local'};
2850 foreach $utarg ('uninstall-data-local', 'uninstall-data-hook',
2851 'uninstall-exec-local', 'uninstall-exec-hook')
2853 if (defined $contents{$utarg})
2856 ($x = $utarg) =~ s/(data|exec)-//;
2857 &am_line_error ($utarg, "use \`$x', not \`$utarg'");
2860 push (@all, 'all-local')
2861 if defined $contents{'all-local'};
2863 if (defined $contents{'install-local'})
2865 &am_line_error ('install-local',
2866 "use \`install-data' or \`install-exec', not \`install'");
2869 # Step two: if we are doing recursive makes, write out the
2870 # appropriate rules.
2872 if ($recursive_install)
2874 push (@install, 'install-recursive');
2878 local (@hackall) = ();
2879 if ($config_name && &dirname ($config_name) eq $relative_dir)
2882 # This is kind of a hack, but I couldn't see a better
2883 # way to handle it. In this particular case, we need
2884 # to make sure config.h is built before we recurse.
2885 # We can't do this by changing the order of
2886 # dependencies to the "all" because that breaks when
2887 # using parallel makes. Instead we handle things
2889 $output_rules .= ('all-recursive-am: $(CONFIG_HEADER)'
2890 . "\n\t" . '$(MAKE) all-recursive'
2892 push (@hackall, 'all-recursive-am');
2893 push (@phony, 'all-recursive-am');
2897 push (@hackall, 'all-recursive');
2900 $output_rules .= ('all-am: '
2904 push (@all, 'all-am');
2905 push (@phony, 'all-am');
2909 @all = ('all-recursive');
2911 # Must always generate `all-am' target, so it can be
2912 # referred to elsewhere.
2913 $output_rules .= "all-am:\n";
2917 $output_rules .= ('install-exec-am: '
2918 . join (' ', @install_exec)
2920 @install_exec = ('install-exec-recursive', 'install-exec-am');
2921 push (@install, 'install-exec-am');
2922 push (@phony, 'install-exec-am');
2926 @install_exec = ('install-exec-recursive');
2930 $output_rules .= ('install-data-am: '
2931 . join (' ', @install_data)
2933 @install_data = ('install-data-recursive', 'install-data-am');
2934 push (@install, 'install-data-am');
2935 push (@phony, 'install-data-am');
2939 @install_data = ('install-data-recursive');
2943 $output_rules .= ('uninstall-am: '
2944 . join (' ', @uninstall)
2946 @uninstall = ('uninstall-recursive', 'uninstall-am');
2947 push (@phony, 'uninstall-am');
2951 @uninstall = ('uninstall-recursive');
2955 # Step three: print definitions users can use. Code below knows
2956 # that install-exec is done before install-data, beware.
2957 $output_rules .= ("install-exec: "
2958 . join (' ', @install_exec)
2960 $output_rules .= "\t\$(NORMAL_INSTALL)\n";
2961 if (defined $contents{'install-exec-hook'})
2963 $output_rules .= "\t" . '$(MAKE) install-exec-hook' . "\n";
2965 $output_rules .= "\n";
2966 push (@install, 'install-exec') if !$recursive_install;
2967 push (@phony, 'install-exec');
2969 $output_rules .= ("install-data: "
2970 . join (' ', @install_data)
2972 $output_rules .= "\t\$(NORMAL_INSTALL)\n";
2973 if (defined $contents{'install-data-hook'})
2975 $output_rules .= "\t" . '$(MAKE) install-data-hook' . "\n";
2977 $output_rules .= "\n";
2978 push (@install, 'install-data') if !$recursive_install;
2979 push (@phony, 'install-data');
2981 # If no dependencies for 'install', add 'all'. Why? That way
2982 # "make install" at top level of distclean'd distribution won't
2983 # fail because stuff in 'lib' fails to build.
2984 if (! @install || (scalar (@install) == 2
2985 && $install[0] eq 'install-exec'
2986 && $install[1] eq 'install-data'))
2988 push (@install, 'all');
2990 $output_rules .= ('install: '
2991 . join (' ', @install)
2992 # Use "@:" as empty command so nothing prints.
2996 . join (' ', @uninstall)
2998 push (@phony, 'install', 'uninstall');
3000 $output_rules .= ('all: '
3003 push (@phony, 'all');
3005 # Generate the new 'install-strip' target.
3006 $output_rules .= ("install-strip:\n\t"
3007 . '$(MAKE) INSTALL_PROGRAM=\'$(INSTALL_PROGRAM) -s\' install'
3011 # Helper for handle_merge_targets.
3012 sub do_one_merge_target
3014 local ($name, @values) = @_;
3016 if (defined $contents{$name . '-local'})
3018 # User defined local form of target. So include it.
3019 push (@values, $name . '-local');
3020 push (@phony, $name . '-local');
3023 &pretty_print_rule ($name . ":", "\t\t", @values);
3024 push (@phony, $name);
3027 # Handle check merge target specially.
3028 sub do_check_merge_target
3030 if (defined $contents{'check-local'})
3032 # User defined local form of target. So include it.
3033 push (@check_tests, 'check-local');
3034 push (@phony, 'check-local');
3037 if (! &variable_defined ('SUBDIRS'))
3039 # 'check' must depend on `all', but not when doing recursive
3041 unshift (@check, 'all');
3045 # When subdirs are used, do the `all' build and then do all
3046 # the recursive stuff. Actually use `all-am' because it
3047 # doesn't recurse; we rely on the check target in the subdirs
3048 # to do the required builds there.
3049 unshift (@check, 'all-am');
3052 # The check target must depend on the local equivalent of `all',
3053 # to ensure all the primary targets are built. Also it must
3054 # depend on the test code named in @check.
3055 &pretty_print_rule ('check:', "\t\t", @check);
3057 # Now the check rules must explicitly run anything named in
3058 # @check_tests. This is done via a separate make invocation to
3059 # avoid problems with parallel makes. Every time I write code
3060 # like this I wonder: how could you invent a parallel make and not
3061 # provide any real synchronization facilities?
3062 &pretty_print_rule ("\t\$(MAKE)", "\t ", @check_tests);
3065 # Handle all 'clean' targets.
3068 push (@clean, 'generic');
3069 $output_rules .= &file_contents ('clean');
3070 &push_phony_cleaners ('generic');
3072 local ($target) = $recursive_install ? 'clean-am' : 'clean';
3073 &do_one_clean_target ($target, 'mostly', '', @clean);
3074 &do_one_clean_target ($target, '', 'mostly', @clean);
3075 &do_one_clean_target ($target, 'dist', '', @clean);
3076 &do_one_clean_target ($target, 'maintainer-', 'dist', @clean);
3078 push (@phony, 'clean', 'mostlyclean', 'distclean', 'maintainer-clean');
3081 if ($recursive_install)
3083 # Do -recursive before -am. If you aren't doing a parallel
3084 # make, this can be nicer.
3085 @deps = ('recursive', 'am');
3086 &do_one_clean_target ('', 'mostly', '', @deps);
3087 &do_one_clean_target ('', '', '', @deps);
3088 &do_one_clean_target ('', 'dist', '', @deps);
3089 &do_one_clean_target ('', 'maintainer-', '', @deps);
3093 # Helper for handle_clean.
3094 sub do_one_clean_target
3096 local ($target, $name, $last_name, @deps) = @_;
3098 # Special case: if target not passed, then don't generate
3099 # dependency on next "lower" clean target (eg no
3100 # clean<-mostlyclean derivation). In this case the target is
3101 # implicitly known to be 'clean'.
3102 local ($flag) = $target;
3103 $target = 'clean' if ! $flag;
3105 grep (($_ = $name . 'clean-' . $_) && 0, @deps);
3108 if ($last_name || $name ne 'mostly')
3110 push (@deps, $last_name . $target);
3114 # If a -local version of the rule is given, add it to the list.
3115 if (defined $contents{$name . $target . '-local'})
3117 push (@deps, $name . $target . '-local');
3120 # Print the target and the dependencies.
3121 &pretty_print_rule ($name . $target . ": ", "\t\t", @deps);
3123 # FIXME: shouldn't we really print these messages before running
3125 if ($name . $target eq 'maintainer-clean')
3127 # Print a special warning.
3129 ("\t\@echo \"This command is intended for maintainers to use;\"\n"
3130 . "\t\@echo \"it deletes files that may require special "
3131 . "tools to rebuild.\"\n");
3133 $output_rules .= "\trm -f config.status\n"
3134 if $relative_dir eq '.';
3136 elsif ($name . $target eq 'distclean')
3138 $output_rules .= "\trm -f config.status\n";
3139 $output_rules .= "\trm -f libtool\n" if $seen_libtool;
3141 $output_rules .= "\n";
3144 # Handle .PHONY target.
3147 &pretty_print_rule ('.PHONY:', "", @phony);
3148 $output_rules .= "\n";
3151 # Handle TESTS variable and other checks.
3154 if (defined $options{'dejagnu'})
3156 push (@check_tests, 'check-DEJAGNU');
3157 push (@phony, 'check-DEJAGNU');
3162 $xform = 's/^CYGNUS//;';
3166 $xform = 's/^CYGNUS.*$//;';
3168 $output_rules .= &file_contents_with_transform ($xform, 'dejagnu');
3170 # In Cygnus mode, these are found in the build tree.
3171 # Otherwise they are looked for in $PATH.
3172 &define_program_variable ('EXPECT', 'build', 'expect', 'expect');
3173 &define_program_variable ('RUNTEST', 'src', 'dejagnu', 'runtest');
3175 # Note that in the rule we don't directly generate site.exp to
3176 # avoid the possibility of a corrupted site.exp if make is
3177 # interrupted. Jim Meyering has some useful text on this
3179 $output_rules .= ("site.exp: Makefile\n"
3180 . "\t\@echo 'Making a new site.exp file...'\n"
3181 . "\t-\@rm -f site.bak\n"
3182 . "\t\@echo '## these variables are automatically generated by make ##' > \$\@-t\n"
3183 . "\t\@echo '# Do not edit here. If you wish to override these values' >> \$\@-t\n"
3184 . "\t\@echo '# edit the last section' >> \$\@-t\n"
3185 . "\t\@echo 'set tool \$(DEJATOOL)' >> \$\@-t\n"
3186 . "\t\@echo 'set srcdir \$(srcdir)' >> \$\@-t\n"
3187 . "\t\@echo 'set objdir' \`pwd\` >> \$\@-t\n");
3189 # Extra stuff for AC_CANONICAL_*
3190 local (@whatlist) = ();
3191 if ($seen_canonical)
3193 push (@whatlist, 'host')
3196 # Extra stuff only for AC_CANONICAL_SYSTEM.
3197 if ($seen_canonical == $AC_CANONICAL_SYSTEM)
3199 push (@whatlist, 'target', 'build');
3203 foreach $c1 (@whatlist)
3205 foreach $c2 ('alias', 'triplet')
3207 $output_rules .= "\t\@echo 'set ${c1}_${c2} \$(${c1}_${c2})' >> \$\@-t\n";
3211 $output_rules .= ("\t\@echo '## All variables above are generated by configure. Do Not Edit ##' >> \$\@-t\n"
3212 . "\t-\@sed '1,/^## All variables above are.*##/ d' site.bak >> \$\@-t\n"
3213 . "\t-\@mv site.exp site.bak\n"
3214 . "\t\@mv \$\@-t site.exp\n");
3219 foreach $c ('DEJATOOL', 'RUNTEST', 'RUNTESTFLAGS')
3221 if (&variable_defined ($c))
3223 &am_line_error ($c, "\`$c' defined but \`dejagnu' not in \`AUTOMAKE_OPTIONS'");
3228 if (&variable_defined ('TESTS'))
3230 push (@check_tests, 'check-TESTS');
3231 push (@phony, 'check-TESTS');
3233 $output_rules .= 'check-TESTS: $(TESTS)
3234 @failed=0; all=0; \\
3235 srcdir=$(srcdir); export srcdir; \\
3236 for tst in $(TESTS); do \\
3237 all=`expr $$all + 1`; \\
3238 if test -f $$tst; then dir=.; \\
3239 else dir="$(srcdir)"; fi; \\
3240 if $(TESTS_ENVIRONMENT) $$dir/$$tst; then \\
3241 echo "PASS: $$tst"; \\
3243 failed=`expr $$failed + 1`; \\
3244 echo "FAIL: $$tst"; \\
3247 if test "$$failed" -eq 0; then \\
3248 echo "========================"; \\
3249 echo "All $$all tests passed"; \\
3250 echo "========================"; \\
3252 echo "$$failed of $$all tests failed"; \\
3259 # Handle Emacs Lisp.
3260 sub handle_emacs_lisp
3262 local (@elfiles) = &am_install_var ('lisp', 'LISP', 'lisp', 'noinst');
3267 &define_configure_variable ('lispdir');
3268 &define_configure_variable ('EMACS');
3269 $output_rules .= (".el.elc:\n"
3270 . "\t\@echo 'WARNING: Warnings can be ignored. :-)'\n"
3271 . "\tEMACS=\$(EMACS) \$(SHELL) \$(srcdir)/elisp-comp \$<\n");
3272 push (@suffixes, '.el', '.elc');
3274 # Generate .elc files.
3275 grep ($_ .= 'c', @elfiles);
3276 &define_pretty_variable ('ELCFILES', @elfiles);
3278 push (@clean, 'lisp');
3279 &push_phony_cleaners ('lisp');
3281 push (@all, '$(ELCFILES)');
3284 if (&variable_defined ('lisp_LISP'))
3286 $varname = 'lisp_LISP';
3287 &am_error ("\`lisp_LISP' defined but \`AM_PATH_LISPDIR' not in \`configure.in'")
3292 $varname = 'noinst_LISP';
3295 &require_file_with_line ($varname, $FOREIGN, 'elisp-comp');
3299 ################################################################
3301 # Scan one file for interesting things. Subroutine of scan_configure.
3302 sub scan_one_configure_file
3304 local ($filename) = @_;
3306 open (CONFIGURE, $filename)
3307 || die "automake: couldn't open \`$filename': $!\n";
3308 print "automake: reading $filename\n" if $verbose;
3312 # Remove comments from current line.
3316 # Skip macro definitions. Otherwise we might be confused into
3317 # thinking that a macro that was only defined was actually
3321 # Populate libobjs array.
3322 if (/AC_FUNC_ALLOCA/)
3324 $libsources{'alloca.c'} = 1;
3326 elsif (/AC_FUNC_GETLOADAVG/)
3328 $libsources{'getloadavg.c'} = 1;
3330 elsif (/AC_FUNC_MEMCMP/)
3332 $libsources{'memcmp.c'} = 1;
3334 elsif (/AC_STRUCT_ST_BLOCKS/)
3336 $libsources{'fileblocks.c'} = 1;
3338 elsif (/A[CM]_REPLACE_GNU_GETOPT/)
3340 $libsources{'getopt.c'} = 1;
3341 $libsources{'getopt1.c'} = 1;
3343 elsif (/AM_FUNC_STRTOD/)
3345 $libsources{'strtod.c'} = 1;
3347 elsif (/AM_WITH_REGEX/)
3349 $libsources{'rx.c'} = 1;
3350 $libsources{'rx.h'} = 1;
3351 $libsources{'regex.c'} = 1;
3352 $libsources{'regex.h'} = 1;
3353 $omit_dependencies{'rx.h'} = 1;
3354 $omit_dependencies{'regex.h'} = 1;
3356 elsif (/AM_FUNC_MKTIME/)
3358 $libsources{'mktime.c'} = 1;
3360 elsif (/AM_FUNC_ERROR_AT_LINE/)
3362 $libsources{'error.c'} = 1;
3363 $libsources{'error.h'} = 1;
3365 elsif (/AM_FUNC_OBSTACK/)
3367 $libsources{'obstack.c'} = 1;
3368 $libsources{'obstack.h'} = 1;
3370 elsif (/LIBOBJS="(.*)\s+\$LIBOBJS"/
3371 || /LIBOBJS="\$LIBOBJS\s+(.*)"/)
3373 foreach $libobj_iter (split (' ', $1))
3375 if ($libobj_iter =~ /^(.*)\.o$/)
3377 $libsources{$1 . '.c'} = 1;
3382 if (! $in_ac_replace && s/AC_REPLACE_FUNCS\s*\(\[?//)
3388 $in_ac_replace = 0 if s/[\]\)].*$//;
3389 # Remove trailing backslash.
3393 # Need to skip empty elements for Perl 4.
3395 $libsources{$_ . '.c'} = 1;
3399 if (/(fp_WITH_DMALLOC|fp_WITH_REGEX|fp_FUNC_FNMATCH|fp_PROG_INSTALL|fp_C_PROTOTYPES|jm_MAINTAINER_MODE|ud_GNU_GETTEXT)/)
3401 &am_conf_line_error ($filename, $., "\`$1' is obsolete; use corresponding \`AM_' macro");
3404 # Process the AC_OUTPUT macro.
3405 if (! $in_ac_output && s/AC_OUTPUT\s*\(\[?//)
3408 $ac_output_line = $.;
3412 $in_ac_output = 0 if s/[\]\),].*$//;
3414 # Look at potential Makefile.am's.
3419 # Handle $local:$input syntax. Note that we ignore
3420 # every input file past the first, though we keep
3421 # those around for later.
3422 local ($local, $input, @rest) = split (/:/);
3429 # FIXME: should be error if .in is missing.
3430 $input =~ s/\.in$//;
3433 if (-f $input . '.am')
3435 # We have a file that automake should generate.
3436 push (@make_input_list, $input);
3437 $make_list{$input} = join (':', ($local, @rest));
3441 # We have a file that automake should cause to be
3442 # rebuilt, but shouldn't generate itself.
3443 push (@other_input_files, $_);
3448 if (/$AC_CONFIG_AUX_DIR_PATTERN/o)
3450 @config_aux_path = $1;
3453 # Check for ansi2knr.
3454 $am_c_prototypes = 1 if /AM_C_PROTOTYPES/;
3456 # Check for NLS support.
3457 if (/AM_GNU_GETTEXT/)
3460 $ac_gettext_line = $.;
3461 $omit_dependencies{'libintl.h'} = 1;
3464 # Look for ALL_LINGUAS.
3465 if (/ALL_LINGUAS="(.*)"$/ || /ALL_LINGUAS=(.*)$/)
3469 $all_linguas_line = $.;
3472 # Handle configuration headers. A config header of `[$1]'
3473 # means we are actually scanning AM_CONFIG_HEADER from
3475 if (/A([CM])_CONFIG_HEADER\s*\((.*)\)/
3480 "use \`AM_CONFIG_HEADER', not \`AC_CONFIG_HEADER'")
3483 $config_header_line = $.;
3485 if ($config_name =~ /^([^:]+):(.+)$/)
3488 $config_header = $2;
3492 $config_header = $config_name . '.in';
3496 # Handle AC_CANONICAL_*. Always allow upgrading to
3497 # AC_CANONICAL_SYSTEM, but never downgrading.
3498 $seen_canonical = $AC_CANONICAL_HOST
3499 if ! $seen_canonical
3500 && (/AC_CANONICAL_HOST/ || /AC_CHECK_TOOL/);
3501 $seen_canonical = $AC_CANONICAL_SYSTEM if /AC_CANONICAL_SYSTEM/;
3503 $seen_path_xtra = 1 if /AC_PATH_XTRA/;
3505 # This macro handles several different things.
3506 if (/$AM_INIT_AUTOMAKE_PATTERN/o)
3512 $seen_prog_install = 2;
3513 ($package_version = $1) =~ s/$AM_PACKAGE_VERSION_PATTERN/$1/o;
3514 $package_version_line = $.;
3517 # This is like AM_INIT_AUTOMAKE, but doesn't actually set the
3518 # package and version number. (This might change in the
3519 # future). Yes, I'm not above hacking Automake so it works
3520 # well with other GNU tools -- that is actually the point.
3521 if (/AM_INIT_GUILE_MODULE/)
3527 $seen_prog_install = 2;
3528 @config_aux_path = ('..');
3531 # Some things required by Automake.
3532 $seen_make_set = 1 if /AC_PROG_MAKE_SET/;
3533 $seen_arg_prog = 1 if /AC_ARG_PROGRAM/;
3535 if (/AC_PROG_(YACC|RANLIB|CC|CXX|LEX)/)
3537 $configure_vars{$1} = 1;
3539 if (/$AC_CHECK_PATTERN/o)
3541 $configure_vars{$3} = 1;
3543 if (/$AC_SUBST_PATTERN/o)
3545 $configure_vars{$1} = 1;
3548 $seen_decl_yytext = 1 if /AC_DECL_YYTEXT/;
3549 $seen_maint_mode = 1 if /AM_MAINTAINER_MODE/;
3550 $seen_package = 1 if /PACKAGE=/;
3552 # Skip VERSION of [$2]; that is from AM_INIT_AUTOMAKE.
3553 if (/\bVERSION=(\S+)/ && $1 ne '[$2]')
3556 $package_version = $1;
3557 $package_version_line = $.;
3564 # Weird conditionals here because it is always allowed to
3565 # upgrade to AM_PROG_INSTALL but never to downgrade to
3567 $seen_prog_install = 1 if ! $seen_prog_install && /AC_PROG_INSTALL/;
3568 $seen_prog_install = 2 if /AM_PROG_INSTALL/;
3570 $seen_lispdir = 1 if /AM_PATH_LISPDIR/;
3572 if (/AM_PROG_LIBTOOL/)
3576 $configure_vars{'RANLIB'} = 1;
3577 $configure_vars{'CC'} = 1;
3578 # AM_PROG_LIBTOOL runs AC_CANONICAL_HOST. Make sure we
3579 # never downgrade (if we've seen AC_CANONICAL_SYSTEM).
3580 $seen_canonical = $AC_CANONICAL_HOST if ! $seen_canonical;
3587 # Scan configure.in and aclocal.m4 for interesting things. We must
3588 # scan aclocal.m4 because there might be AC_SUBSTs and such there.
3591 # Reinitialize libsources here. This isn't really necessary,
3592 # since we currently assume there is only one configure.in. But
3593 # that won't always be the case.
3596 local ($in_ac_output, $in_ac_replace) = (0, 0);
3597 local (%make_list, @make_input_list);
3598 local ($libobj_iter);
3600 &scan_one_configure_file ('configure.in');
3601 &scan_one_configure_file ('aclocal.m4')
3604 # Set input and output files if not specified by user.
3607 @input_files = @make_input_list;
3608 %output_files = %make_list;
3611 &am_conf_error ("\`PACKAGE' not defined in configure.in")
3613 &am_conf_error ("\`VERSION' not defined in configure.in")
3616 # Look for some files we need. Always check for these. This
3617 # check must be done for every run, even those where we are only
3618 # looking at a subdir Makefile. We must set relative_dir so that
3619 # the file-finding machinery works.
3620 local ($relative_dir) = '.';
3621 &require_config_file ($FOREIGN, 'install-sh', 'mkinstalldirs');
3622 &am_error ("\`install.sh' is an anachronism; use \`install-sh' instead")
3623 if -f $config_aux_path[0] . '/install.sh';
3626 ################################################################
3628 # Set up for Cygnus mode.
3631 return unless $cygnus_mode;
3633 &set_strictness ('foreign');
3634 $options{'no-installinfo'} = 1;
3635 $options{'no-dependencies'} = 1;
3636 $use_dependencies = 0;
3638 if (! $seen_maint_mode)
3640 &am_conf_error ("\`AM_MAINTAINER_MODE' required when --cygnus specified");
3644 # Do any extra checking for GNU standards.
3645 sub check_gnu_standards
3647 if ($relative_dir eq '.')
3649 # In top level (or only) directory.
3650 &require_file ($GNU, 'INSTALL', 'NEWS', 'README', 'COPYING',
3651 'AUTHORS', 'ChangeLog');
3654 if ($strictness >= $GNU)
3656 if (defined $options{'no-installman'})
3658 &am_line_error ('AUTOMAKE_OPTIONS',
3659 "option \`no-installman' disallowed by GNU standards");
3662 if (defined $options{'no-installinfo'})
3664 &am_line_error ('AUTOMAKE_OPTIONS',
3665 "option \`no-installinfo' disallowed by GNU standards");
3670 # Do any extra checking for GNITS standards.
3671 sub check_gnits_standards
3673 if ($strictness >= $GNITS)
3675 if (-f $relative_dir . '/COPYING.LIB')
3677 &am_error ("\`${relative_dir}/COPYING.LIB' disallowed by Gnits standards");
3680 if ($relative_dir eq '.')
3682 if ($package_version !~ /^$GNITS_VERSION_PATTERN$/)
3684 # FIXME: allow real filename.
3685 &am_conf_line_error ('configure.in',
3686 $package_version_line,
3687 "version \`$package_version' doesn't follow Gnits standards");
3689 elsif (defined $1 && -f 'README-alpha')
3691 # This means we have an alpha release. See
3692 # GNITS_VERSION_PATTERN for details.
3693 &require_file ($GNITS, 'README-alpha');
3698 if ($relative_dir eq '.')
3700 # In top level (or only) directory.
3701 &require_file ($GNITS, 'THANKS');
3705 ################################################################
3707 # Pretty-print something. HEAD is what should be printed at the
3708 # beginning of the first line, FILL is what should be printed at the
3709 # beginning of every subsequent line.
3710 sub pretty_print_internal
3712 local ($head, $fill, @values) = @_;
3714 local ($column) = length ($head);
3715 local ($result) = $head;
3717 # Fill length is number of characters. However, each Tab
3718 # character counts for eight. So we count the number of Tabs and
3720 local ($fill_length) = length ($fill);
3721 $fill_length += 7 * ($fill =~ tr/\t/\t/d);
3723 local ($bol) = ($head eq '');
3726 # "71" because we also print a space.
3727 if ($column + length ($_) > 71)
3729 $result .= " \\\n" . $fill;
3730 $column = $fill_length;
3734 $result .= ' ' unless ($bol);
3736 $column += length ($_) + 1;
3744 # Pretty-print something and append to output_vars.
3747 $output_vars .= &pretty_print_internal (@_);
3750 # Pretty-print something and append to output_rules.
3751 sub pretty_print_rule
3753 $output_rules .= &pretty_print_internal (@_);
3757 ################################################################
3759 # See if a variable exists.
3760 sub variable_defined
3763 if (defined $targets{$var})
3765 &am_line_error ($var, "\`$var' is target; expected variable");
3768 elsif (defined $contents{$var})
3770 $content_seen{$var} = 1;
3776 # Mark a variable as examined.
3777 sub examine_variable
3780 &variable_defined ($var);
3783 # Return contents of variable as list, split as whitespace. This will
3784 # recursively follow $(...) and ${...} inclusions. It preserves @...@
3785 # substitutions. If PARENT is specified, it is the name of the
3786 # including variable; this is only used for error reports.
3787 sub variable_value_as_list
3789 local ($var, $parent) = @_;
3792 if (defined $targets{$var})
3794 &am_line_error ($var, "\`$var' is target; expected variable");
3796 elsif (! defined $contents{$var})
3798 &am_line_error ($parent, "variable \`$var' not defined");
3803 $content_seen{$var} = 1;
3804 foreach (split (' ', $contents{$var}))
3806 # If a comment seen, just leave.
3809 # Handle variable substitutions.
3810 if (/^\$\{(.*)\}$/ || /^\$\((.*)\)$/)
3812 local ($varname) = $1;
3814 if ($varname =~ /^([^:]*):([^=]*)=(.*)$/)
3818 ($from = $2) =~ s/(\W)/\\$1/g;
3822 @temp_list = &variable_value_as_list ($1, $var);
3824 # Now rewrite the value if appropriate.
3827 grep (s/$from$/$to/, @temp_list);
3830 push (@result, @temp_list);
3842 # Define a new variable, but only if not already defined.
3845 local ($var, $value) = @_;
3847 if (! defined $contents{$var})
3849 $output_vars .= $var . ' = ' . $value . "\n";
3850 $contents{$var} = $value;
3851 $content_seen{$var} = 1;
3855 # Like define_variable, but second arg is a list, and is
3857 sub define_pretty_variable
3859 local ($var, @value) = @_;
3860 if (! defined $contents{$var})
3862 $contents{$var} = join (' ', @value);
3863 &pretty_print ($var . ' = ', '', @value);
3864 $content_seen{$var} = 1;
3868 # Like define_variable, but define a variable to be the configure
3869 # substitution by the same name.
3870 sub define_configure_variable
3873 local ($value) = '@' . $var . '@';
3874 &define_variable ($var, $value);
3877 # Define a variable that represents a program to run. If in Cygnus
3878 # mode, the program is searched for in the build (or source) tree.
3879 # Otherwise no searching is done at all. Arguments are:
3880 # * VAR Name of variable to define
3881 # * WHATDIR Either `src' or `build', depending on where program should
3882 # be found. (runtest is in srcdir!)
3883 # * SUBDIR Subdir of top-level dir
3884 # * PROGRAM Name of program
3885 sub define_program_variable
3887 local ($var, $whatdir, $subdir, $program) = @_;
3891 local ($full) = ('$(top_' . $whatdir . 'dir)/../'
3892 . $subdir . '/' . $program);
3893 &define_variable ($var, ('`if test -f ' . $full
3894 . '; then echo ' . $full . '; else echo '
3895 . $program . '; fi`'));
3899 &define_variable ($var, $program);
3904 ################################################################
3906 # Read Makefile.am and set up %contents. Simultaneously copy lines
3907 # from Makefile.am into $output_trailer or $output_vars as
3908 # appropriate. NOTE we put rules in the trailer section. We want
3909 # user rules to come after our generated stuff.
3912 local ($amfile) = @_;
3914 open (AM_FILE, $amfile) || die "automake: couldn't open \`$amfile': $!\n";
3915 print "automake: reading $amfile\n" if $verbose;
3917 $output_vars = ("# $in_file_name generated automatically by automake "
3918 . $VERSION . " from $am_file_name\n");
3920 # Generate copyright for generated Makefile.in.
3921 $output_vars .= $gen_copyright;
3923 local ($saw_bk) = 0;
3924 local ($was_rule) = 0;
3925 local ($spacing) = '';
3926 local ($comment) = '';
3927 local ($last_var_name) = '';
3932 if (/$IGNORE_PATTERN/o)
3934 # Merely delete comments beginning with two hashes.
3936 elsif (/$WHITE_PATTERN/o)
3938 # Stick a single white line before the incoming macro or rule.
3942 elsif (/$COMMENT_PATTERN/o)
3944 # Stick comments before the incoming macro or rule. Make
3945 # sure a blank line preceeds first block of comments.
3946 $spacing = "\n" unless $blank;
3948 $comment .= $spacing . $_;
3957 $output_vars .= $comment . "\n";
3960 local ($am_vars) = '';
3962 local ($is_ok_macro);
3966 unless substr ($_, -1, 1) eq "\n";
3968 $_ =~ s/\@MAINT\@//g
3969 unless $seen_maint_mode;
3971 if (/$IGNORE_PATTERN/o)
3973 # Merely delete comments beginning with two hashes.
3975 elsif (/$WHITE_PATTERN/o)
3977 # Stick a single white line before the incoming macro or rule.
3980 elsif (/$COMMENT_PATTERN/o)
3982 # Stick comments before the incoming macro or rule.
3983 $comment .= $spacing . $_;
3990 $output_trailer .= $_;
3997 # Chop newline and backslash if this line is
3998 # continued. FIXME: maybe ensure trailing whitespace
4002 $contents{$last_var_name} .= $_;
4005 elsif (/$RULE_PATTERN/o)
4007 # warn "** Saw rule .$1.\n";
4010 # Value here doesn't matter; for targets we only note
4014 $content_lines{$1} = $.;
4015 $output_trailer .= $comment . $spacing . $_;
4016 $comment = $spacing = '';
4019 elsif (($is_ok_macro = /$MACRO_PATTERN/o)
4020 || /$BOGUS_MACRO_PATTERN/o)
4022 # Found a macro definition.
4024 $last_var_name = $1;
4025 if (substr ($2, -1) eq "\\")
4027 $contents{$1} = substr ($2, 0, length ($2) - 1);
4033 $content_lines{$1} = $.;
4034 $am_vars .= $comment . $spacing . $_;
4035 $comment = $spacing = '';
4039 &am_line_error ($., "bad macro name \`$1'")
4044 # This isn't an error; it is probably a continued rule.
4045 # In fact, this is what we assume.
4047 $output_trailer .= $comment . $spacing . $_;
4048 $comment = $spacing = '';
4055 $output_trailer .= $comment;
4057 # Compute relative location of the top object directory.
4058 local (@topdir) = ();
4059 foreach (split (/\//, $relative_dir))
4061 next if $_ eq '.' || $_ eq '';
4068 push (@topdir, '..');
4071 @topdir = ('.') if ! @topdir;
4073 $top_builddir = join ('/', @topdir);
4075 ($build_rx = $top_builddir) =~ s/(\W)/\\$1/g;
4076 $output_vars .= &file_contents_with_transform
4077 ('s/\@top_builddir\@/' . $build_rx . '/g;',
4080 # Generate some useful variables when AC_CANONICAL_* used. FIXME:
4081 # this should use generic %configure_vars method.
4082 if ($seen_canonical)
4084 local ($curs, %vars);
4085 $vars{'host_alias'} = 'host_alias';
4086 $vars{'host_triplet'} = 'host';
4087 if ($seen_canonical == $AC_CANONICAL_SYSTEM)
4089 $vars{'build_alias'} = 'build_alias';
4090 $vars{'build_triplet'} = 'build';
4091 $vars{'target_alias'} = 'target_alias';
4092 $vars{'target_triplet'} = 'target';
4094 foreach $curs (sort keys %vars)
4096 $output_vars .= "$curs = \@$vars{$curs}\@\n";
4097 $contents{$curs} = "\@$vars{$curs}\@";
4102 foreach $curs (sort keys %configure_vars)
4104 &define_configure_variable ($curs);
4107 $output_vars .= $am_vars;
4110 ################################################################
4112 sub initialize_global_constants
4114 # Values for AC_CANONICAL_*
4115 $AC_CANONICAL_HOST = 1;
4116 $AC_CANONICAL_SYSTEM = 2;
4118 # Associative array of standard directory names. Entry is TRUE if
4119 # corresponding directory should be installed during
4120 # 'install-exec' phase.
4138 # Helper text for dealing with man pages.
4139 $install_man_format =
4140 ' @sect=@SECTION@; \\
4141 inst=`echo "@MANBASE@" | sed \'$(transform)\'`.@FULLSECT@; \\
4142 if test -f $(srcdir)/@MAN@; then file=$(srcdir)/@MAN@; \\
4143 else file=@MAN@; fi; \\
4144 echo " $(INSTALL_DATA) $$file $(mandir)/man$$sect/$$inst"; \\
4145 $(INSTALL_DATA) $$file $(mandir)/man$$sect/$$inst
4148 $uninstall_man_format =
4149 ' inst=`echo "@MANBASE@" | sed \'$(transform)\'`.@FULLSECT@; \\
4150 rm -f $(mandir)/man@SECTION@/$$inst
4153 # Commonly found files we look for and automatically include in
4157 "README", "THANKS", "TODO", "NEWS", "COPYING", "COPYING.LIB",
4158 "INSTALL", "ABOUT-NLS", "ChangeLog", "configure", "configure.in",
4159 "config.guess", "config.sub", "AUTHORS", "BACKLOG", "ABOUT-GNU",
4160 "libversion.in", "mdate-sh", "mkinstalldirs", "install-sh",
4161 'texinfo.tex', "ansi2knr.c", "ansi2knr.1", 'elisp-comp',
4162 'interlock', 'ylwrap', 'acinclude.m4', @libtoolize_files
4165 # Commonly used files we auto-include, but only sometimes.
4168 "aclocal.m4", "acconfig.h", "config.h.top",
4169 "config.h.bot", "stamp-h.in", 'stamp-vti'
4173 -a, --add-missing add missing standard files to package
4174 --amdir=DIR directory storing config files
4175 --build-dir=DIR directory where build being done (for dependencies)
4176 --cygnus assume program is part of Cygnus-style tree
4177 --foreign set strictness to foreign
4178 --gnits set strictness to gnits
4179 --gnu set strictness to gnu
4180 --help print this help, then exit
4181 -i, --include-deps include generated dependencies in Makefile.in
4182 --no-force only update Makefile.in's that are out of date
4183 -o DIR, --output-dir=DIR
4184 put generated Makefile.in's into DIR
4185 --srcdir-name=DIR name used for srcdir (for dependencies)
4186 -v, --verbose verbosely list files processed
4187 --version print version number, then exit\n";
4189 # Copyright on generated Makefile.ins.
4191 # Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
4192 # This Makefile.in is free software; the Free Software Foundation
4193 # gives unlimited permission to copy, distribute and modify it.
4196 # Ignore return result from chmod, because it might give an error
4197 # if we chmod a symlink.
4198 $dist_header = "\t" . '-chmod -R a+r $(distdir)' . "\n";
4199 $dist{'tarZ'} = ("\t"
4200 . '$(TAR) chf - $(distdir) | compress -c > $(distdir).tar.Z'
4202 $dist{'shar'} = ("\t"
4203 . 'shar $(distdir) | gzip > $(distdir).shar.gz'
4205 $dist{'zip'} = "\t" . 'zip -rq $(distdir).zip $(distdir)' . "\n";
4206 $dist{'dist'} = "\t" . 'GZIP=$(GZIP) $(TAR) chozf $(distdir).tar.gz $(distdir)' . "\n";
4207 $dist_trailer = "\t" . 'rm -rf $(distdir)' . "\n";
4210 # (Re)-Initialize per-Makefile.am variables.
4211 sub initialize_per_input
4213 # These two variables are used when generating each Makefile.in.
4214 # They hold the Makefile.in until it is ready to be printed.
4217 $output_trailer = '';
4218 $output_header = '';
4220 # Suffixes found during a run.
4223 # This holds the contents of a Makefile.am, as parsed by
4227 # This holds the names which are targets. These also appear in
4231 # This holds the line numbers at which various elements of
4232 # %contents are defined.
4233 %content_lines = ();
4235 # This holds a 1 if a particular variable was examined.
4238 # This holds the "relative directory" of the current Makefile.in.
4239 # Eg for src/Makefile.in, this is "src".
4242 # This holds a list of files that are included in the
4246 # List of dependencies for the obvious targets.
4262 # These are pretty obvious, too. They are used to define the
4263 # SOURCES and OBJECTS variables.
4267 # TRUE if current directory holds any C source files.
4268 $dir_holds_sources = 0;
4270 # These variables track inclusion of various compile-related .am
4271 # files. $included_generic_compile is TRUE if the basic code has
4272 # been included. $included_knr_compile is TRUE if the ansi2knr
4273 # code has been included. $included_libtool_compile is TRUE if
4274 # libtool support has been included.
4275 $included_generic_compile = 0;
4276 $included_knr_compile = 0;
4277 $included_libtool_compile = 0;
4279 # TRUE if current directory holds any headers.
4280 $dir_holds_headers = 0;
4282 # TRUE if install targets should work recursively.
4283 $recursive_install = 0;
4288 # Strictness levels.
4289 $strictness = $default_strictness;
4290 $strictness_name = $default_strictness_name;
4292 # Options from AUTOMAKE_OPTIONS.
4295 # Whether or not dependencies are handled. Can be further changed
4296 # in handle_options.
4297 $use_dependencies = $cmdline_use_dependencies;
4300 $local_maint_charset = $maint_charset;
4302 # All yacc and lex source filenames for this directory. Use
4303 # filenames instead of raw count so that multiple instances are
4304 # counted correctly (eg one yacc file can appear in multiple
4305 # programs without harm).
4309 # C++ source extensions we've seen.
4310 %cxx_extensions = ();
4312 # TRUE if we've seen any non-C++ sources.
4315 # This is a list of all targets to run during "make dist".
4318 # Keys in this hash are the names of ._o files which must depend
4320 %de_ansi_objects = ();
4324 ################################################################
4326 # Return contents of a file from $am_dir, automatically skipping
4327 # macros or rules which are already known. Runs command on each line
4328 # as it is read; this command can modify $_.
4329 sub file_contents_with_transform
4331 local ($command, $basename) = @_;
4332 local ($file) = $am_dir . '/' . $basename . '.am';
4334 if ($command ne '' && substr ($command, -1) ne ';')
4336 die "automake: programming error in file_contents_with_transform\n";
4339 open (FC_FILE, $file)
4340 || die "automake: installation error: cannot open \`$file'\n";
4342 # print "automake: reading $file\n" if $verbose;
4344 local ($was_rule) = 0;
4345 local ($result_vars) = '';
4346 local ($result_rules) = '';
4347 local ($comment) = '';
4348 local ($spacing) = "\n";
4349 local ($skipping) = 0;
4354 $_ =~ s/\@MAINT\@//g
4355 unless $seen_maint_mode;
4357 $had_chars = length ($_);
4359 # If the transform caused all the characters to go away, then
4360 # ignore the line. Why do this? Because in Perl 4, a "next"
4361 # inside of an eval doesn't affect a loop outside the eval.
4362 # So we can't pass in a "transform" that uses next. We used
4364 next if $had_chars && $_ eq '';
4366 if (/$IGNORE_PATTERN/o)
4368 # Merely delete comments beginning with two hashes.
4370 elsif (/$WHITE_PATTERN/o)
4372 # Stick a single white line before the incoming macro or rule.
4375 elsif (/$COMMENT_PATTERN/o)
4377 # Stick comments before the incoming macro or rule.
4378 $comment .= $spacing . $_;
4385 $result_rules .= $_ if ! $skipping;
4389 $result_vars .= $_ if ! $skipping;
4393 elsif (/$RULE_PATTERN/o)
4395 # warn "** Found rule .$1.\n";
4398 $skipping = defined $contents{$1};
4399 # warn "** Skip $skipping\n" if $skipping;
4400 $result_rules .= $comment . $spacing . $_ if ! $skipping;
4401 $comment = $spacing = '';
4404 elsif (/$MACRO_PATTERN/o)
4406 # warn "** Found macro .$1.\n";
4407 # Found a variable reference.
4409 $skipping = defined $contents{$1};
4410 # warn "** Skip $skipping\n" if $skipping;
4411 $result_vars .= $comment . $spacing . $_ if ! $skipping;
4412 $comment = $spacing = '';
4417 # This isn't an error; it is probably a continued rule.
4418 # In fact, this is what we assume.
4420 $result_rules .= $comment . $spacing . $_ if ! $skipping;
4421 $comment = $spacing = '';
4427 return $result_vars . $result_rules . $comment;
4430 # Like file_contents_with_transform, but no transform.
4433 return &file_contents_with_transform ('', @_);
4436 # Find all variable prefixes that are used for install directories. A
4437 # prefix `zar' qualifies iff:
4438 # * `zardir' is a variable.
4439 # * `zar_PRIMARY' is a variable.
4440 sub am_primary_prefixes
4442 local ($primary, @prefixes) = @_;
4444 local (%valid, $varname);
4445 grep ($valid{$_} = 0, @prefixes);
4446 $valid{'EXTRA'} = 0;
4447 foreach $varname (keys %contents)
4449 if ($varname =~ /^(.*)_$primary$/)
4451 if (! defined $valid{$1}
4452 && ! &variable_defined ($1 . 'dir')
4453 # Note that a configure variable is always legitimate.
4454 # It is natural to name such variables after the
4455 # primary, so we explicitly allow it.
4456 && ! defined $configure_vars{$varname})
4458 &am_line_error ($varname, "invalid variable \"$varname\"");
4462 # Ensure all extended prefixes are actually used.
4471 # Handle `where_HOW' variable magic. Does all lookups, generates
4472 # install code, and possibly generates code to define the primary
4473 # variable. The first argument is the name of the .am file to munge,
4474 # the second argument is the primary variable (eg HEADERS), and all
4475 # subsequent arguments are possible installation locations. Returns
4476 # list of all values of all _HOW targets.
4478 # FIXME: this should be rewritten to be cleaner. It should be broken
4479 # up into multiple functions.
4481 # Usage is: am_install_var (OPTION..., file, HOW, where...)
4486 local ($do_clean, $do_ltlibs) = (0, 0);
4487 local ($more_xform) = '';
4490 if ($args[0] eq '-clean')
4494 if ($args[0] eq '-ltlibs')
4499 # Note that we explicitly set the mode, to avoid
4500 # lossage if the program name isn't what we expect.
4501 $more_xform = 's/\@LIBTOOL\@/\$(LIBTOOL) --mode=install/;';
4505 $more_xform = 's/\@LIBTOOL\@//;';
4508 elsif ($args[0] !~ /^-/)
4514 local ($file, $primary, @prefixes) = @args;
4515 unshift (@prefixes, 'lib') if ($do_ltlibs);
4518 local (@result) = ();
4520 # Now that configure substitutions are allowed in where_HOW
4521 # variables, it is an error to actually define the primary.
4522 &am_line_error ($primary, "\`$primary' is an anachronism")
4523 if &variable_defined ($primary);
4526 # Look for misspellings. It is an error to have a variable ending
4527 # in a "reserved" suffix whose prefix is unknown, eg
4528 # "bni_PROGRAMS". However, unusual prefixes are allowed if a
4529 # variable of the same name (with "dir" appended) exists. For
4530 # instance, if the variable "zardir" is defined, then
4531 # "zar_PROGRAMS" becomes valid. This is to provide a little extra
4532 # flexibility in those cases which need it. Perhaps it should be
4533 # disallowed in the Gnits case? The problem is, sometimes it is
4534 # useful to put things in a subdir of eg pkgdatadir, perhaps even
4536 local (%valid) = &am_primary_prefixes ($primary, @prefixes);
4538 # If a primary includes a configure substitution, then the EXTRA_
4539 # form is required. Otherwise we can't properly do our job.
4540 local ($require_extra);
4541 local ($warned_about_extra) = 0;
4543 local ($clean_file) = $file . '-clean';
4546 foreach $X (sort keys %valid)
4548 $one_name = $X . '_' . $primary;
4549 if (&variable_defined ($one_name))
4551 # Append actual contents of where_PRIMARY variable to
4554 foreach $rcurs (&variable_value_as_list ($one_name))
4556 # Skip configure substitutions. Possibly bogus.
4557 if ($rcurs =~ /^\@.*\@$/)
4561 if (! $warned_about_extra)
4563 $warned_about_extra = 1;
4564 &am_line_error ($one_name,
4565 "\`$one_name' contains configure substitution, but shouldn't");
4568 # Check here to make sure variables defined in
4569 # configure.in do not imply that EXTRA_PRIMARY
4571 elsif (! defined $configure_vars{$one_name})
4573 $require_extra = $one_name;
4580 if ($rcurs =~ /^lib.*\.l?a$/)
4582 if (! $seen_libtool)
4584 &am_line_error ($one_name,
4585 "\`$rcurs' is a libtool library name, but AM_PROG_LIBTOOL is not in \`configure.in'");
4589 # Check that libtool libraries go only into
4590 # libdir. Ignore `EXTRA' libtool libraries.
4591 if ($rcurs =~ /^lib.*\.la$/ && $X ne 'lib'
4594 &am_line_error ($one_name,
4595 "libtool library \`$rcurs' must only be installed in libdir");
4597 elsif ($X =~ /^s?bin|libexec$/)
4599 &am_line_error ($one_name,
4600 "library \`$rcurs' must not be installed in a binary directory");
4605 &am_line_error ($one_name,
4606 "only libraries (not \`$rcurs') may be installed in libdir");
4609 push (@result, $rcurs);
4612 # "EXTRA" shouldn't be used when generating clean targets,
4613 # @all, or install targets.
4614 next if $X eq 'EXTRA';
4619 &file_contents_with_transform ('s/\@DIR\@/' . $X . '/go;',
4622 push (@clean, $X . $primary);
4623 &push_phony_cleaners ($X . $primary);
4628 push (@check, '$(' . $one_name . ')');
4632 push (@used, '$(' . $one_name . ')');
4634 if ($X eq 'noinst' || $X eq 'check')
4636 # Objects which don't get installed by default.
4640 if ($do_ltlibs && $X eq 'lib')
4643 &file_contents_with_transform ('s/\@DIR\@/' . $X . '/go;',
4649 &file_contents_with_transform ('s/\@DIR\@/' . $X . '/g;'
4654 push (@uninstall, 'uninstall-' . $X . $primary);
4655 push (@phony, 'uninstall-' . $X . $primary);
4656 push (@installdirs, '$(' . $X . 'dir)');
4657 if (defined $exec_dir_p{$X} ? $exec_dir_p{$X} : ($X =~ /exec/))
4659 push (@install_exec, 'install-' . $X . $primary);
4660 push (@phony, 'install-' . $X . $primary);
4664 push (@install_data, 'install-' . $X . $primary);
4665 push (@phony, 'install-' . $X . $primary);
4673 &define_pretty_variable ($primary, @used);
4674 $output_vars .= "\n";
4677 if ($require_extra && ! &variable_defined ('EXTRA_' . $primary))
4679 &am_line_error ($require_extra,
4680 "\`$require_extra' contains configure substitution, but \`EXTRA_$primary' not defined");
4683 # Push here because PRIMARY might be configure time determined.
4684 push (@all, '$(' . $primary . ')')
4691 ################################################################
4693 # This variable is local to the "require file" set of functions.
4694 @require_file_paths = ();
4696 # Verify that the file must exist in the current directory. Usage:
4697 # require_file (isconfigure, line_number, strictness, file) strictness
4698 # is the strictness level at which this file becomes required. Must
4699 # set require_file_paths before calling this function.
4700 # require_file_paths is set to hold a single directory (the one in
4701 # which the first file was found) before return.
4702 sub require_file_internal
4704 local ($is_configure, $line, $mystrict, @files) = @_;
4705 local ($file, $fullfile);
4706 local ($found_it, $errfile, $errdir);
4709 foreach $file (@files)
4712 foreach $dir (@require_file_paths)
4716 $fullfile = $relative_dir . "/" . $file;
4717 $errdir = $relative_dir unless $errdir;
4721 $fullfile = $dir . "/" . $file;
4722 $errdir = $dir unless $errdir;
4725 # Use different name for "error filename". Otherwise on
4726 # an error the bad file will be reported as eg
4727 # `../../install-sh' when using the default
4729 $errfile = $errdir . '/' . $file;
4734 # FIXME: Once again, special-case `.'.
4735 &push_dist_common ($file)
4736 if $dir eq $relative_dir || $dir eq '.';
4744 # Prune the path list.
4745 @require_file_paths = $save_dir;
4749 if ($strictness >= $mystrict)
4751 local ($trailer) = '';
4752 local ($suppress) = 0;
4754 # Only install missing files according to our desired
4758 $trailer = "; installing";
4761 # Maybe run libtoolize.
4763 && grep ($_ eq $file, @libtoolize_files)
4764 && system ('libtoolize', '--automake'))
4767 $trailer .= "; cannot run \`libtoolize': $!";
4769 elsif (-f ($am_dir . '/' . $file))
4771 # Install the missing file. Symlink if we
4772 # can, copy if we must. Note: delete the file
4773 # first, in case it is a dangling symlink.
4775 if ($symlink_exists)
4777 if (! symlink ($am_dir . '/' . $file, $errfile))
4780 $trailer .= "; error while making link: $!\n";
4783 elsif (! system ('cp', $am_dir . '/' . $file, $errfile))
4786 $trailer .= "\n error while making link\n";
4791 local ($save) = $exit_status;
4794 # FIXME: allow actual file to be specified.
4796 ('configure.in', $line,
4797 "required file \"$errfile\" not found$trailer");
4803 "required file \"$errfile\" not found$trailer");
4805 $exit_status = $save if $suppress;
4811 # Like require_file_with_line, but error messages refer to
4812 # configure.in, not the current Makefile.am.
4813 sub require_file_with_conf_line
4815 @require_file_paths = '.';
4816 &require_file_internal (1, @_);
4819 sub require_file_with_line
4821 @require_file_paths = '.';
4822 &require_file_internal (0, @_);
4827 @require_file_paths = '.';
4828 &require_file_internal (0, '', @_);
4831 # Require a file that is also required by Autoconf. Looks in
4832 # configuration path, as specified by AC_CONFIG_AUX_DIR.
4833 sub require_config_file
4835 @require_file_paths = @config_aux_path;
4836 &require_file_internal (1, '', @_);
4837 local ($dir) = $require_file_paths[0];
4838 @config_aux_path = @require_file_paths;
4841 $config_aux_dir = '.';
4845 $config_aux_dir = '$(top_srcdir)/' . $dir;
4849 # Assumes that the line number is in Makefile.am.
4850 sub require_conf_file_with_line
4852 @require_file_paths = @config_aux_path;
4853 &require_file_internal (0, @_);
4854 local ($dir) = $require_file_paths[0];
4855 @config_aux_path = @require_file_paths;
4858 $config_aux_dir = '.';
4862 $config_aux_dir = '$(top_srcdir)/' . $dir;
4866 # Assumes that the line number is in Makefile.am.
4867 sub require_conf_file_with_conf_line
4869 @require_file_paths = @config_aux_path;
4870 &require_file_internal (1, @_);
4871 local ($dir) = $require_file_paths[0];
4872 @config_aux_path = @require_file_paths;
4875 $config_aux_dir = '.';
4879 $config_aux_dir = '$(top_srcdir)/' . $dir;
4883 ################################################################
4885 # Push a list of files onto dist_common.
4886 sub push_dist_common
4888 local (@files) = @_;
4891 foreach $file (@files)
4893 $dist_common{$file} = 1;
4897 # Push a list of clean targets onto phony.
4898 sub push_phony_cleaners
4902 foreach $target ('mostly', 'dist', '', 'maintainer-')
4904 push (@phony, $target . 'clean-' . $base);
4911 $strictness_name = $_[0];
4912 if ($strictness_name eq 'gnu')
4916 elsif ($strictness_name eq 'gnits')
4918 $strictness = $GNITS;
4920 elsif ($strictness_name eq 'foreign')
4922 $strictness = $FOREIGN;
4926 die "automake: level \`$strictness_name' not recognized\n";
4931 ################################################################
4933 # Return directory name of file.
4939 ($sub = $file) =~ s,/+[^/]+$,,g;
4940 $sub = '.' if $sub eq $file;
4944 # Return file name of a file.
4950 ($sub = $file) =~s,^.*/+,,g;
4959 open (TOUCH, ">> $file");
4963 # Glob something. Do this to avoid indentation screwups everywhere we
4964 # want to glob. Gross!
4971 ################################################################
4973 # Print an error message and set exit status.
4976 warn "automake: ${am_file}.am: ", join (' ', @_), "\n";
4982 local ($symbol, @args) = @_;
4986 # If SYMBOL not already a line number, look it up in Makefile.am.
4987 if ($symbol =~ /^\d+$/)
4991 elsif (defined $content_lines{$symbol})
4993 $symbol = $content_lines{$symbol} . ': ';
4997 # A single space, to provide nice separation.
5000 warn "${am_file}.am:", $symbol, join (' ', @args), "\n";
5009 # Like am_error, but while scanning configure.in.
5012 # FIXME: can run in subdirs.
5013 warn "automake: configure.in: ", join (' ', @_), "\n";
5017 # Error message with line number referring to configure.in.
5018 sub am_conf_line_error
5020 local ($file, $line, @args) = @_;
5024 warn "$file: $line: ", join (' ', @args), "\n";
5029 &am_conf_error (@args);
5033 # Tell user where our aclocal.m4 is, but only once.
5034 sub keyed_aclocal_warning
5037 warn "automake: macro \`$key' can be generated by \`aclocal'\n";
5040 # Print usage information.
5043 print "Usage: automake [OPTION] ... [Makefile]...\n";
5045 print "\nFiles which are automatically distributed, if found:\n";
5046 $~ = "USAGE_FORMAT";
5047 local (@lcomm) = sort ((@common_files, @common_sometimes));
5048 local ($one, $two, $three, $four);
5051 $one = shift @lcomm;
5052 $two = @lcomm ? shift @lcomm : '';
5053 $three = @lcomm ? shift @lcomm : '';
5054 $four = @lcomm ? shift @lcomm : '';
5058 print "\nReport bugs to <bug-gnu-utils\@prep.ai.mit.edu>\n";
5063 format USAGE_FORMAT =
5064 @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<
5065 $one, $two, $three, $four