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);
1310 if (&variable_defined ($xname . "_LDADD"))
1312 if (&handle_lib_objects ($xname, $xname . '_LDADD',
1321 # User didn't define prog_LDADD override. So do it.
1322 &define_variable ($xname . '_LDADD', '$(LDADD)');
1324 # This does a bit too much work. But we need it to
1325 # generate _DEPENDENCIES when appropriate.
1326 if (&variable_defined ('LDADD'))
1328 if (&handle_lib_objects ($xname, 'LDADD', $lex_file_seen))
1336 if (! &variable_defined ($xname . '_LDFLAGS'))
1338 # Define the prog_LDFLAGS variable.
1339 &define_variable ($xname . '_LDFLAGS', '');
1344 &am_line_error ($one_file . $xt,
1345 'lex source file used without @LEXLIB@');
1348 # Determine program to use for link.
1350 if (&variable_defined ($xname . '_LINK'))
1352 $xlink = $xname . '_LINK';
1356 $xlink = $linker ? $linker : 'LINK';
1360 &file_contents_with_transform
1361 ('s/\@PROGRAM\@/' . $one_file . '/go;'
1362 . 's/\@XPROGRAM\@/' . $xname . '/go;'
1363 . 's/\@XLINK\@/' . $xlink . '/go;',
1367 if (&variable_defined ('LDADD') && &handle_lib_objects ('', 'LDADD', 0))
1374 foreach $one_file (@proglist)
1376 # Canonicalize names.
1377 ($xname = $one_file) =~ tr/A-Za-z0-9_/_/c;
1379 if (&variable_defined ($xname . '_LDADD'))
1381 &check_libobjs_sources ($xname, $xname . '_LDADD');
1383 elsif (&variable_defined ('LDADD'))
1385 &check_libobjs_sources ($xname, 'LDADD');
1393 sub handle_libraries
1395 local (@liblist) = &am_install_var ('-clean',
1396 'libs', 'LIBRARIES',
1397 'lib', 'pkglib', 'noinst', 'check');
1398 return if ! @liblist;
1400 local (%valid) = &am_primary_prefixes ('LIBRARIES', 'lib', 'pkglib',
1402 if (! defined $configure_vars{'RANLIB'})
1405 foreach $key (keys %valid)
1407 if (&variable_defined ($key . '_LIBRARIES'))
1409 &am_line_error ($key . '_LIBRARIES', "library used but \`RANLIB' not defined in \`configure.in'");
1410 # Only get this error once.
1411 $configure_vars{'RANLIB'} = 1;
1420 local ($seen_libobjs) = 0;
1421 foreach $onelib (@liblist)
1423 # Check that the library fits the standard naming convention.
1424 if ($onelib !~ /^lib.*\.a$/)
1426 # FIXME this should only be a warning for foreign packages
1427 # FIXME should put line number here. That means mapping
1428 # from library name back to variable name.
1429 &am_error ("\`$onelib' is not a standard library name");
1432 local ($obj) = &get_object_extension ($onelib);
1434 # Canonicalize names.
1435 ($xlib = $onelib) =~ tr/A-Za-z0-9_/_/c;
1436 if ($xlib ne $onelib)
1439 foreach $xt ('_LIBADD', '_SOURCES', '_OBJECTS', '_DEPENDENCIES')
1441 &am_line_error ($onelib . $xt,
1442 "invalid variable \`" . $onelib . $xt
1443 . "'; should be \`" . $xlib . $xt . "'")
1444 if &variable_defined ($onelib . $xt);
1448 if (&variable_defined ($xlib . '_LIBADD'))
1450 if (&handle_lib_objects ($xlib, $xlib . '_LIBADD', 0))
1457 # Generate support for conditional object inclusion in
1459 &define_variable ($xlib . "_LIBADD", '');
1462 &handle_source_transform ($xlib, $onelib, $obj);
1465 &file_contents_with_transform ('s/\@LIBRARY\@/' . $onelib . '/go;'
1473 foreach $onelib (@liblist)
1475 # Canonicalize names.
1476 ($xlib = $onelib) =~ tr/A-Za-z0-9_/_/c;
1477 if (&variable_defined ($xlib . '_LIBADD'))
1479 &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
1484 &define_variable ('AR', 'ar');
1485 &define_configure_variable ('RANLIB');
1488 # See if any _SOURCES variable were misspelled. Also, make sure that
1489 # EXTRA_ variables don't contain configure substitutions.
1492 local ($varname, $primary, $ckey);
1493 foreach $varname (keys %contents)
1495 foreach $primary ('_SOURCES', '_LIBADD', '_LDADD', '_LDFLAGS', '_DEPENDENCIES')
1497 if ($varname =~ /$primary$/ && ! $content_seen{$varname})
1499 &am_line_error ($varname,
1500 "invalid unused variable name: \`$varname'");
1504 if ($varname =~ /^EXTRA_/)
1506 foreach $ckey (&variable_value_as_list ($varname))
1508 if ($ckey =~ /^\@.*\@$/)
1510 &am_line_error ($varname, "variable \`$varname' must not contain configure substitution");
1521 # NOTE we no longer automatically clean SCRIPTS, because it is
1522 # useful to sometimes distribute scripts verbatim. This happens
1523 # eg in Automake itself.
1524 &am_install_var ('scripts', 'SCRIPTS',
1525 'bin', 'sbin', 'libexec', 'pkgdata',
1528 # Set $scripts_installed if appropriate. Make sure we only find
1529 # scripts which are actually installed -- this is why we can't
1530 # simply use the return value of am_install_var.
1531 local (%valid) = &am_primary_prefixes ('SCRIPTS', 'bin', 'sbin',
1532 'libexec', 'pkgdata',
1535 foreach $key (keys %valid)
1537 if ($key ne 'noinst'
1539 && &variable_defined ($key . '_SCRIPTS'))
1541 $scripts_installed = 1;
1542 # push (@check_tests, 'check-' . $key . 'SCRIPTS');
1546 if ($scripts_installed)
1548 # If a program is installed, this is required. We only want this
1549 # error to appear once.
1550 &am_conf_error ("AC_ARG_PROGRAM must be used in configure.in")
1551 unless $seen_arg_prog;
1556 # Search a file for a "version.texi" Texinfo include. Return the name
1557 # of the include file if found, or the empty string if not. A
1558 # "version.texi" file is actually any file whose name matches
1560 sub scan_texinfo_file
1562 local ($filename) = @_;
1564 if (! open (TEXI, $filename))
1566 &am_error ("couldn't open \`$filename': $!");
1569 print "automake: reading $filename\n" if $verbose;
1571 local ($vfile, $outfile);
1574 if (/^\@setfilename +(\S+)/)
1580 if (/^\@include\s+(vers[^.]*\.texi)\s*$/)
1582 # Found version.texi include.
1589 return ($outfile, $vfile);
1592 # Handle all Texinfo source.
1595 &am_line_error ('TEXINFOS',
1596 "\`TEXINFOS' is an anachronism; use \`info_TEXINFOS'")
1597 if &variable_defined ('TEXINFOS');
1598 return if (! &variable_defined ('info_TEXINFOS')
1599 && ! &variable_defined ('html_TEXINFOS'));
1601 local (@texis) = &variable_value_as_list ('info_TEXINFOS');
1603 local (@info_deps_list, @dvis_list, @texi_deps);
1604 local ($infobase, $info_cursor);
1608 local ($tc_cursor, @texi_cleans);
1611 foreach $info_cursor (@texis)
1613 ($infobase = $info_cursor) =~ s/\.texi(nfo)?$//;
1615 # If 'version.texi' is referenced by input file, then include
1616 # automatic versioning capability.
1617 local ($out_file, $vtexi) = &scan_texinfo_file ($relative_dir
1618 . "/" . $info_cursor);
1620 if ($out_file eq '')
1622 &am_error ("\`$info_cursor' missing \@setfilename");
1626 if ($out_file =~ /\.(.+)$/ && $1 ne 'info')
1628 # FIXME should report line number in input file.
1629 &am_error ("output of \`$info_cursor', \`$out_file', has unrecognized extension");
1635 &am_error ("\`$vtexi', included in \`$info_cursor', also included in \`$versions{$vtexi}'")
1636 if (defined $versions{$vtexi});
1637 $versions{$vtexi} = $info_cursor;
1639 # We number the stamp-vti files. This is doable since the
1640 # actual names don't matter much. We only number starting
1641 # with the second one, so that the common case looks nice.
1642 $vti = 'vti' . ($done ? $done : '');
1643 &push_dist_common ($vtexi, 'stamp-' . $vti);
1644 push (@clean, $vti);
1646 # Only require once.
1647 &require_conf_file_with_line ('info_TEXINFOS', $FOREIGN,
1653 ($conf_pat = $config_aux_dir) =~ s/(\W)/\\$1/g;
1655 &file_contents_with_transform
1656 ('s/\@TEXI\@/' . $info_cursor . '/g; '
1657 . 's/\@VTI\@/' . $vti . '/g; '
1658 . 's/\@VTEXI\@/' . $vtexi . '/g;'
1659 . 's,\@MDDIR\@,' . $conf_pat . ',g;',
1662 &push_phony_cleaners ($vti);
1665 # If user specified file_TEXINFOS, then use that as explicit
1668 push (@texi_deps, $info_cursor);
1669 push (@texi_deps, $vtexi) if $vtexi;
1671 # Canonicalize name first.
1672 ($canonical = $infobase) =~ tr/A-Za-z0-9_/_/c;
1673 if (&variable_defined ($canonical . "_TEXINFOS"))
1675 push (@texi_deps, '$(' . $canonical . '_TEXINFOS)');
1676 &push_dist_common ('$(' . $canonical . '_TEXINFOS)');
1679 $output_rules .= ("\n" . $out_file . ": "
1680 . join (' ', @texi_deps)
1681 . "\n" . $infobase . ".dvi: "
1682 . join (' ', @texi_deps)
1685 push (@info_deps_list, $out_file);
1686 push (@dvis_list, $infobase . '.dvi');
1688 # Generate list of things to clean for this target. We do
1689 # this explicitly because otherwise too many things could be
1690 # removed. In particular the ".log" extension might
1691 # reasonably be used in other contexts by the user.
1692 foreach $tc_cursor ('aux', 'cp', 'cps', 'dvi', 'fn', 'fns',
1693 'ky', 'log', 'pg', 'toc', 'tp', 'tps',
1696 push (@texi_cleans, $infobase . '.' . $tc_cursor);
1700 # Find these programs wherever they may lie. Yes, this has
1701 # intimate knowledge of the structure of the texinfo distribution.
1702 &define_program_variable ('MAKEINFO', 'build', 'texinfo/makeinfo',
1704 &define_program_variable ('TEXI2DVI', 'src', 'texinfo/util',
1710 $xform = 's/^NOTCYGNUS.*$//; s/^CYGNUS//;';
1714 $xform = 's/^CYGNUS.*$//; s/^NOTCYGNUS//;';
1716 $output_rules .= &file_contents_with_transform ($xform, 'texinfos');
1717 push (@phony, 'install-info-am', 'uninstall-info');
1718 push (@dist_targets, 'dist-info');
1721 $output_rules .= "\nmostlyclean-info:\n";
1722 &pretty_print_rule ("\trm -f", "\t ", @texi_cleans);
1723 $output_rules .= ("\nclean-info:\n\ndistclean-info:\n\n"
1724 . "maintainer-clean-info:\n\t"
1725 . 'for i in $(INFO_DEPS); do rm -f `eval echo $$i*`; done'
1727 &push_phony_cleaners ('info');
1729 push (@suffixes, '.texi', '.texinfo', '.info', '.dvi', '.ps');
1731 if (! defined $options{'no-installinfo'})
1733 push (@uninstall, 'uninstall-info');
1734 push (@installdirs, '$(infodir)');
1735 unshift (@install_data, 'install-info-am');
1737 # Make sure documentation is made and installed first. Use
1738 # $(INFO_DEPS), not 'info', because otherwise recursive makes
1739 # get run twice during "make all".
1740 unshift (@all, '$(INFO_DEPS)');
1742 push (@clean, 'info');
1743 push (@info, '$(INFO_DEPS)');
1744 push (@dvi, '$(DVIS)');
1746 &define_variable ("INFO_DEPS", join (' ', @info_deps_list));
1747 &define_variable ("DVIS", join (' ', @dvis_list));
1748 # This next isn't strictly needed now -- the places that look here
1749 # could easily be changed to look in info_TEXINFOS. But this is
1750 # probably better, in case noinst_TEXINFOS is ever supported.
1751 &define_variable ("TEXINFOS", $contents{'info_TEXINFOS'});
1753 # Do some error checking. Note that this file is not required
1754 # when in Cygnus mode -- a bletcherous hack.
1755 &require_file_with_line ('info_TEXINFOS',
1756 $cygnus_mode ? $GNU : $FOREIGN,
1758 unless defined $options{'no-texinfo.tex'};
1761 # Handle any man pages.
1762 sub handle_man_pages
1764 &am_line_error ('MANS', "\`MANS' is an anachronism; use \`man_MANS'")
1765 if &variable_defined ('MANS');
1766 return if ! &variable_defined ('man_MANS');
1768 # We generate the manpage install code by hand to avoid the use of
1769 # basename in the generated Makefile.
1770 local (@mans) = &variable_value_as_list ('man_MANS');
1771 local (%sections, %inames, %mbases, %secmap, %fullsecmap);
1775 # FIXME: statement without effect:
1776 /^(.*)\.([0-9])([a-z]*)$/;
1781 $fullsecmap{$i} = $2 . $3;
1785 # We don't really need this, but we use it in case we ever want to
1786 # support noinst_MANS.
1787 &define_variable ("MANS", $contents{'man_MANS'});
1789 # Generate list of install dirs.
1790 $output_rules .= "install-man: \$(MANS)\n";
1791 $output_rules .= "\t\$(NORMAL_INSTALL)\n";
1792 # Sort keys so that output is deterministic.
1793 foreach (sort keys %sections)
1795 push (@installdirs, '$(mandir)/man' . $_)
1796 unless defined $options{'no-installman'};
1797 $output_rules .= ("\t" . '$(mkinstalldirs) $(mandir)/man'
1800 push (@phony, 'install-man');
1802 # Generate install target.
1804 foreach $key (sort keys %inames)
1806 $_ = $install_man_format;
1807 s/\@SECTION\@/$secmap{$key}/g;
1808 s/\@MAN\@/$inames{$key}/g;
1809 s/\@FULLSECT\@/$fullsecmap{$key}/g;
1810 s/\@MANBASE\@/$mbases{$key}/g;
1811 $output_rules .= $_;
1813 $output_rules .= "\n";
1815 $output_rules .= "uninstall-man:\n";
1816 foreach $key (sort keys %inames)
1818 $_ = $uninstall_man_format;
1819 s/\@SECTION\@/$secmap{$key}/g;
1820 s/\@MAN\@/$inames{$key}/g;
1821 s/\@FULLSECT\@/$fullsecmap{$key}/g;
1822 s/\@MANBASE\@/$mbases{$key}/g;
1823 $output_rules .= $_;
1825 $output_rules .= "\n";
1826 push (@phony, 'uninstall-man');
1828 $output_vars .= &file_contents ('mans-vars');
1830 if (! defined $options{'no-installman'})
1832 push (@install_data, 'install-man');
1833 push (@uninstall, 'uninstall-man');
1834 push (@all, '$(MANS)');
1838 # Handle DATA variables.
1841 &am_install_var ('data', 'DATA', 'data', 'sysconf',
1842 'sharedstate', 'localstate', 'pkgdata',
1849 push (@phony, 'tags');
1850 local (@tag_deps) = ();
1851 if (&variable_defined ('SUBDIRS'))
1853 $output_rules .= ("tags-recursive:\n"
1854 . "\tlist=\"\$(SUBDIRS)\"; for subdir in \$\$list; do \\\n"
1855 # Never fail here if a subdir fails; it
1857 . "\t (cd \$\$subdir && \$(MAKE) tags); \\\n"
1859 push (@tag_deps, 'tags-recursive');
1860 push (@phony, 'tags-recursive');
1863 if ($dir_holds_sources
1864 || $dir_holds_headers
1865 || &variable_defined ('ETAGS_ARGS'))
1867 local ($xform) = '';
1868 if ($config_header && $relative_dir eq &dirname ($config_header))
1870 # The config header is in this directory. So require it.
1871 ($xform = &basename ($config_header)) =~ s/(\W)/\\$1/g;
1873 $xform = ('s/\@CONFIG\@/' . $xform . '/;'
1874 . 's/\@DIRS\@/' . join (' ', @tag_deps) . '/;');
1876 $output_rules .= &file_contents_with_transform ($xform, 'tags');
1877 $output_rules .= &file_contents ('tags-clean');
1878 push (@clean, 'tags');
1879 &push_phony_cleaners ('tags');
1880 &examine_variable ('TAGS_DEPENDENCIES');
1882 elsif (&variable_defined ('TAGS_DEPENDENCIES'))
1884 &am_line_error ('TAGS_DEPENDENCIES',
1885 "doesn't make sense to define \`TAGS_DEPENDENCIES' without sources or \`ETAGS_ARGS'");
1889 # Every Makefile must define some sort of TAGS rule.
1890 # Otherwise, it would be possible for a top-level "make TAGS"
1891 # to fail because some subdirectory failed.
1892 $output_rules .= "tags: TAGS\nTAGS:\n\n";
1896 # Worker for handle_dist.
1897 sub handle_dist_worker
1899 $output_rules .= 'distdir: $(DISTFILES)' . "\n";
1901 # Initialization; only at top level.
1902 if ($relative_dir eq '.')
1904 if ($strictness >= $GNITS)
1906 # For Gnits users, this is pretty handy. Look at 15 lines
1907 # in case some explanatory text is desirable.
1908 $output_rules .= ' @if sed 15q $(srcdir)/NEWS | fgrep -e "$(VERSION)" > /dev/null; then :; else \\
1909 echo "NEWS not updated; not releasing" 1>&2; \\
1917 # Create dist directory.
1920 -chmod 755 $(distdir)
1923 # Only run automake in `dist' target if --include-deps not
1924 # specified. That way the recipient of a distribution can run
1925 # "make dist" and not need Automake.
1926 if ($cmdline_use_dependencies)
1930 # We need an absolute path for --output-dir. Thus the
1932 ' here=`pwd`; distdir=`cd $(distdir) && pwd` \\
1934 && automake --include-deps --build-dir=$$here --srcdir-name=$(srcdir) --output-dir=$$distdir '
1935 # Set strictness of output.
1936 . ($cygnus_mode ? '--cygnus' : ('--' . $strictness_name))
1942 # Scan EXTRA_DIST to see if we need to distribute anything from a
1943 # subdir. If so, add it to the list. I didn't want to do this
1944 # originally, but there were so many requests that I finally
1947 if (&variable_defined ('EXTRA_DIST'))
1949 foreach (&variable_value_as_list ('EXTRA_DIST'))
1952 next unless s,/+[^/]+$,,;
1953 push (@dist_dirs, $_)
1959 # Prepend $(distdir) to each directory given. Doing it via a
1960 # hash lets us ensure that each directory is used only once.
1962 grep ($dhash{'$(distdir)/' . $_} = 1, @dist_dirs);
1963 $output_rules .= "\t";
1964 &pretty_print_rule ('$(mkinstalldirs)', "\t ", sort keys %dhash);
1967 # In loop, test for file existence because sometimes a file gets
1968 # included in DISTFILES twice. For example this happens when a
1969 # single source file is used in building more than one program.
1970 # Also, there are situations in which "ln" can fail. For instance
1971 # a file to distribute could actually be a cross-filesystem
1972 # symlink -- this can easily happen if "gettextize" was run on the
1974 $output_rules .= "\t\@for file in \$(DISTFILES); do \\\n";
1977 $output_rules .= "\t if test -f \$\$file; then d=.; else d=\$(srcdir); fi; \\\n";
1981 $output_rules .= "\t d=\$(srcdir); \\\n";
1983 $output_rules .= ' test -f $(distdir)/$$file \\
1984 || ln $$d/$$file $(distdir)/$$file 2> /dev/null \\
1985 || cp -p $$d/$$file $(distdir)/$$file; \\
1989 # If we have SUBDIRS, create all dist subdirectories and do
1991 if (&variable_defined ('SUBDIRS'))
1993 # Test for directory existence here because previous automake
1994 # invocation might have created some directories. Note that
1995 # we explicitly set distdir for the subdir make; that lets us
1996 # mix-n-match many automake-using packages into one large
1997 # package, and have "dist" at the top level do the right
1999 $output_rules .= ' for subdir in $(SUBDIRS); do \\
2000 test -d $(distdir)/$$subdir \\
2001 || mkdir $(distdir)/$$subdir \\
2003 chmod 755 $(distdir)/$$subdir; \\
2004 (cd $$subdir && $(MAKE) distdir=../$(distdir)/$$subdir distdir) \\
2010 # If the target `dist-hook' exists, make sure it is run. This
2011 # allows users to do random weird things to the distribution
2012 # before it is packaged up.
2013 push (@dist_targets, 'dist-hook') if defined $contents{'dist-hook'};
2016 foreach $targ (@dist_targets)
2018 # We must explicitly set distdir for these sub-makes.
2019 $output_rules .= "\t\$(MAKE) distdir=\"\$(distdir)\" $targ\n";
2022 push (@phony, 'distdir');
2025 # Handle 'dist' target.
2028 # Set up maint_charset.
2029 $local_maint_charset = $contents{'MAINT_CHARSET'}
2030 if &variable_defined ('MAINT_CHARSET');
2031 $maint_charset = $local_maint_charset
2032 if $relative_dir eq '.';
2034 if (&variable_defined ('DIST_CHARSET'))
2036 &am_line_error ('DIST_CHARSET',
2037 "DIST_CHARSET defined but no MAINT_CHARSET defined")
2038 if ! $local_maint_charset;
2039 if ($relative_dir eq '.')
2041 $dist_charset = $contents{'DIST_CHARSET'}
2045 &am_line_error ('DIST_CHARSET',
2046 "DIST_CHARSET can only be defined at top level");
2050 # Look for common files that should be included in distribution.
2052 foreach $cfile (@common_files)
2054 if (-f ($relative_dir . "/" . $cfile))
2056 &push_dist_common ($cfile);
2060 # Keys of %dist_common are names of files to distributed. We put
2061 # README first because it then becomes easier to make a
2062 # Usenet-compliant shar file (in these, README must be first).
2063 # FIXME: do more ordering of files here.
2065 if (defined $dist_common{'README'})
2067 push (@coms, 'README');
2068 undef $dist_common{'README'};
2070 push (@coms, sort keys %dist_common);
2072 &define_pretty_variable ("DIST_COMMON", @coms);
2073 $output_vars .= "\n";
2076 $output_vars .= &file_contents ('dist-vars') . "\n";
2077 &define_variable ('TAR', $TAR);
2078 &define_variable ('GZIP', '--best');
2080 # Put these things in rules section so it is easier for whoever
2081 # reads Makefile.in.
2082 if (! &variable_defined ('distdir'))
2084 if ($relative_dir eq '.')
2086 $output_rules .= "\n" . 'distdir = $(PACKAGE)-$(VERSION)' . "\n";
2090 $output_rules .= ("\n"
2091 . 'distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)'
2095 if ($relative_dir ne '.')
2097 $output_rules .= "\nsubdir = " . $relative_dir . "\n";
2100 # Generate 'dist' target, and maybe dist-shar / dist-zip / dist-tarZ.
2101 if ($relative_dir eq '.')
2103 # Rule to check whether a distribution is viable.
2104 $output_rules .= ('# This target untars the dist file and tries a VPATH configuration. Then
2105 # it guarantees that the distribution is self-contained by making another
2109 GZIP=$(GZIP) $(TAR) zxf $(distdir).tar.gz
2110 mkdir $(distdir)/=build
2111 mkdir $(distdir)/=inst
2112 dc_install_base=`cd $(distdir)/=inst && pwd`; \\'
2113 . (defined $contents{'distcheck-hook'}
2114 ? "\t\$(MAKE) distcheck-hook"
2117 cd $(distdir)/=build \\
2120 . ($seen_gettext ? '--with-included-gettext ' : '')
2121 . '--srcdir=.. --prefix=$$dc_install_base \\
2125 && $(MAKE) install \\
2126 && $(MAKE) installcheck \\
2129 @echo "========================"; \\
2130 echo "$(distdir).tar.gz is ready for distribution"; \\
2131 echo "========================"
2134 local ($dist_all) = ('dist-all: distdir' . "\n"
2137 foreach $curs ('dist', 'dist-shar', 'dist-zip', 'dist-tarZ')
2139 if (defined $options{$curs} || $curs eq 'dist')
2141 $output_rules .= ($curs . ': distdir' . "\n"
2145 $dist_all .= $dist{$curs};
2148 $output_rules .= $dist_all . $dist_trailer;
2151 # Generate distdir target.
2152 &handle_dist_worker;
2155 # Scan a single dependency file and rewrite the dependencies as
2156 # appropriate. Essentially this means:
2157 # * Clean out absolute dependencies which are not desirable.
2158 # * Rewrite other dependencies to be relative to $(top_srcdir).
2159 sub scan_dependency_file
2161 local ($depfile) = @_;
2163 if (! open (DEP_FILE, $depfile))
2165 &am_error ("couldn't open \`$depfile': $!");
2168 print "automake: reading $depfile\n" if $verbose;
2170 # Sometimes it is necessary to omit some dependencies.
2171 local (%omit) = %omit_dependencies;
2172 if (&variable_defined ('OMIT_DEPENDENCIES'))
2174 grep ($omit{$_} = 1, &variable_value_as_list ('OMIT_DEPENDENCIES'));
2177 local ($first_line) = 1;
2178 local ($last_line) = 0;
2179 local ($target, @dependencies);
2180 local ($one_dep, $xform);
2183 local ($srcdir_rx, $fixup_rx);
2184 # If the top srcdir is absolute, then the current directory is
2185 # just relative_dir. But if the top srcdir is relative, then we
2186 # need to add some dots first. The same holds when matching
2188 if ($srcdir_name =~ /^\//)
2190 ($fixup_rx = $srcdir_name . '/' . $relative_dir . '/')
2192 ($srcdir_rx = $srcdir_name . '/') =~ s/(\W)/\\$1/g;
2196 ($fixup_rx = ($srcdir_name . '/' . $top_builddir . '/'
2197 . $relative_dir . '/')) =~ s/(\W)/\\$1/g;
2198 $srcdir_rx = $srcdir_name . '/';
2199 # Don't append a spurious "." to the regex.
2200 $srcdir_rx .= $top_builddir
2201 unless $top_builddir eq '.';
2202 $srcdir_rx =~ s/(\W)/\\$1/g;
2205 local ($rewrite_builddir) = (($top_builddir eq '.')
2207 : $top_builddir . '/');
2213 # If LAST_LINE set then we've already seen what we thought
2214 # was the last line.
2217 next if (/$WHITE_PATTERN/o);
2221 # No trailing "\" means this should be the last line.
2227 if (! /^([^:]+:)(.+)$/)
2230 &am_error ("\`$depfile' has incorrect format");
2241 foreach $one_dep (split (' ', $_))
2243 if ($one_dep =~ /^$fixup_rx/)
2245 # The dependency points to the current directory in
2247 ($xform = $one_dep) =~ s/^$fixup_rx//;
2248 push (@dependencies, $xform);
2250 elsif ($one_dep =~ /^$srcdir_rx/)
2252 # The dependency is in some other directory in the package.
2253 ($xform = $one_dep) =~ s/^$srcdir_rx/$rewrite_builddir/;
2254 push (@dependencies, $xform);
2256 elsif ($one_dep =~ /^\//)
2258 # Absolute path; ignore.
2262 # Anything else is assumed to be correct. But first
2263 # make sure it is not on our list of dependencies to
2265 ($just_file = $one_dep) =~ s,^.*/,,;
2266 push (@dependencies, $one_dep)
2267 if ! defined $omit{$just_file};
2272 &pretty_print_rule ($target, "\t", @dependencies);
2277 # Handle auto-dependency code.
2278 sub handle_dependencies
2280 if ($use_dependencies)
2282 # Include GNU-make-specific auto-dep code.
2283 if ($dir_holds_sources)
2285 &define_pretty_variable ('DEP_FILES', sort keys %dep_files);
2286 $output_rules .= &file_contents ('depend');
2287 push (@clean, 'depend');
2288 &push_phony_cleaners ('depend');
2290 &file_contents_with_transform ('s/\@EXT\@/.c/g;'
2291 . 's/\@MKDEP\@/MKDEP/g;'
2295 local ($need_cxx) = 0;
2296 foreach $ext (sort keys %cxx_extensions)
2299 &file_contents_with_transform ('s/\@EXT\@/' . $ext .'/g;'
2300 . 's/\@MKDEP\@/CXXMKDEP/g;'
2307 &define_variable ('CXXMKDEP', '$(CXX) -M $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CXXFLAGS)');
2311 elsif ($build_directory ne '')
2313 # Include any auto-generated deps that are present. Note that
2314 # $build_directory ends in a "/".
2315 if (-d ($build_directory . $relative_dir . "/.deps")
2316 && -f ($build_directory . $relative_dir . "/.deps/.P"))
2320 foreach $depfile (&my_glob ($build_directory
2321 . $relative_dir . "/.deps/*.P"))
2323 &scan_dependency_file ($depfile);
2326 $output_rules .= "\n";
2331 # Handle subdirectories.
2334 return if ! &variable_defined ('SUBDIRS');
2336 # Make sure each directory mentioned in SUBDIRS actually exists.
2338 foreach $dir (&variable_value_as_list ('SUBDIRS'))
2340 # Skip directories substituted by configure.
2341 next if $dir =~ /^\@.*\@$/;
2343 if (! -d $am_relative_dir . '/' . $dir)
2345 &am_line_error ('SUBDIRS',
2346 "required directory $am_relative_dir/$dir does not exist");
2350 &am_relative_dir ('SUBDIRS',
2351 "directory should not contain \`/'")
2355 local ($xform) = ('s/\@INSTALLINFO\@/' .
2356 (defined $options{'no-installinfo'}
2357 ? 'install-info-recursive'
2360 $output_rules .= &file_contents_with_transform ($xform, 'subdirs');
2362 # Push a bunch of phony targets.
2364 foreach $phonies ('-data', '-exec', 'dirs')
2366 push (@phony, 'install' . $phonies . '-recursive');
2367 push (@phony, 'uninstall' . $phonies . '-recursive');
2369 foreach $phonies ('all', 'check', 'installcheck', 'info', 'dvi')
2371 push (@phony, $phonies . '-recursive');
2373 &push_phony_cleaners ('recursive');
2375 push (@check_tests, "check-recursive");
2376 push (@installcheck, "installcheck-recursive");
2377 push (@info, "info-recursive");
2378 push (@dvi, "dvi-recursive");
2380 $recursive_install = 1;
2383 # Handle aclocal.m4.
2384 sub handle_aclocal_m4
2386 local ($regen_aclocal) = 0;
2387 if (-f 'aclocal.m4')
2389 &define_variable ("ACLOCAL", '$(top_srcdir)/aclocal.m4');
2390 &push_dist_common ('aclocal.m4');
2392 if (open (ACLOCAL, '< aclocal.m4'))
2398 if ($line =~ 'generated automatically by aclocal')
2405 local ($acinclude) = 0;
2406 if (-f 'acinclude.m4')
2412 # Note that it might be possible that aclocal.m4 doesn't exist but
2413 # should be auto-generated. This case probably isn't very
2417 local (@ac_deps) = (
2418 ($seen_maint_mode ? "\@MAINT\@" : "") ,
2420 ($acinclude ? ' acinclude.m4' : '')
2423 # Scan all -I directories for m4 files. These are our
2425 if (&variable_defined ('ACLOCAL_AMFLAGS'))
2428 foreach $amdir (&variable_value_as_list ('ACLOCAL_AMFLAGS'))
2430 if ($amdir =~ s/^-I//
2434 push (@ac_deps, &my_glob ($am_dir . '/*.m4'));
2439 &pretty_print_rule ("\$(srcdir)/aclocal.m4:", "\t\t", @ac_deps);
2441 $output_rules .= ("\t"
2442 . 'cd $(srcdir) && aclocal'
2443 . (&variable_defined ('ACLOCAL_AMFLAGS')
2444 ? ' $(ACLOCAL_AMFLAGS)' : '')
2449 # Rewrite a list of input files into a form suitable to put on a
2450 # dependency list. The idea is that if an input file has a directory
2451 # part the same as the current directory, then the directory part is
2452 # simply removed. But if the directory part is different, then
2453 # $(top_srcdir) is prepended. Among other things, this is used to
2454 # generate the dependency list for the output files generated by
2455 # AC_OUTPUT. Consider what the dependencies should look like in this
2457 # AC_OUTPUT(src/out:src/in1:lib/in2)
2458 sub rewrite_inputs_into_dependencies
2460 local (@inputs) = @_;
2461 local ($single, @newinputs);
2463 foreach $single (@inputs)
2465 if (&dirname ($single) eq $relative_dir)
2467 push (@newinputs, &basename ($single));
2471 push (@newinputs, '$(top_srcdir)/' . $single);
2478 # Handle remaking and configure stuff.
2479 # We need the name of the input file, to do proper remaking rules.
2480 sub handle_configure
2482 local ($local, $input, @secondary_inputs) = @_;
2484 # If SUBDIRS defined, require AC_PROG_MAKE_SET.
2485 &am_line_error ('SUBDIRS', "AC_PROG_MAKE_SET must be used in configure.in")
2486 if &variable_defined ('SUBDIRS') && ! $seen_make_set;
2488 local ($top_reldir);
2490 # Handle $local:$input syntax again.
2491 local ($infile, $colon_infile);
2493 local ($input_base) = &basename ($input);
2494 local ($local_base) = &basename ($local);
2496 local ($amfile) = $input_base . '.am';
2497 # We know we can always add '.in' because it really should be an
2498 # error if the .in was missing originally.
2499 $infile = '$(srcdir)/' . $input_base . '.in';
2500 if ($local ne $input)
2502 $colon_infile = ':' . $input . '.in';
2504 $colon_infile .= ':' . join (':', @secondary_inputs)
2505 if @secondary_inputs;
2507 local (@rewritten) = &rewrite_inputs_into_dependencies (@secondary_inputs);
2508 # This rule remakes the Makefile.in. Note use of @MAINT@ forces
2509 # us to abandon pretty-printing. Sigh.
2510 $output_rules .= ($infile . ': ' . ($seen_maint_mode ? '@MAINT@ ' : '')
2512 . '$(top_srcdir)/configure.in $(ACLOCAL) '
2513 . join (' ', @rewritten) . "\n"
2514 . "\tcd \$(top_srcdir) && automake "
2515 . ($cygnus_mode ? '--cygnus' : ('--' . $strictness_name))
2516 . ' ' . $input . $colon_infile . "\n\n");
2518 # This rule remakes the Makefile.
2519 $output_rules .= ($local_base . ': ' . $infile . ' '
2520 . '$(top_builddir)/config.status $(BUILT_SOURCES)'
2522 . "\tcd \$(top_builddir) \\\n"
2523 . "\t && CONFIG_FILES="
2524 . (($relative_dir eq '.') ? '$@' : '$(subdir)/$@')
2526 . ' CONFIG_HEADERS= $(SHELL) ./config.status'
2529 if ($relative_dir ne '.')
2532 $top_reldir = '../';
2537 $output_rules .= &file_contents ('remake');
2538 &examine_variable ('CONFIGURE_DEPENDENCIES');
2542 # If we have a configure header, require it.
2543 if ($config_header && $relative_dir eq &dirname ($config_header))
2545 local ($ch_sans_dir) = &basename ($config_header);
2546 local ($cn_sans_dir) = &basename ($config_name);
2548 &require_file_with_conf_line ($config_header_line,
2549 $FOREIGN, $ch_sans_dir);
2551 # Header defined and in this directory.
2553 if (-f $relative_dir . '/acconfig.h')
2555 push (@files, 'acconfig.h');
2557 if (-f $config_name . '.top')
2559 push (@files, "${cn_sans_dir}.top");
2561 if (-f $config_name . '.bot')
2563 push (@files, "${cn_sans_dir}.bot");
2566 &push_dist_common (@files);
2567 $output_rules .= &file_contents_with_transform ('s/\@FILES\@/'
2568 . join (' ', @files)
2572 &touch ($relative_dir . '/stamp-h.in');
2573 &require_file_with_conf_line ($config_header_line, $FOREIGN,
2576 push (@clean, 'hdr');
2577 &push_phony_cleaners ('hdr');
2578 &define_variable ("CONFIG_HEADER_IN", "${ch_sans_dir}");
2581 # Set location of mkinstalldirs.
2582 if ($config_aux_dir ne '.' && $config_aux_dir ne '')
2584 &define_variable ('mkinstalldirs', ('$(SHELL) ' . $config_aux_dir
2585 . '/mkinstalldirs'));
2589 &define_variable ('mkinstalldirs',
2590 '$(SHELL) $(top_srcdir)/mkinstalldirs');
2593 &am_line_error ('CONFIG_HEADER',
2594 "\`CONFIG_HEADER' is an anachronism; now determined from \`configure.in'")
2595 if &variable_defined ('CONFIG_HEADER');
2599 # Generate CONFIG_HEADER define.
2600 if ($relative_dir eq &dirname ($config_name))
2602 &define_variable ("CONFIG_HEADER", &basename ($config_name));
2606 &define_variable ("CONFIG_HEADER",
2607 "${top_builddir}/${config_name}");
2611 # Now look for other files in this directory which must be remade
2612 # by config.status, and generate rules for them.
2613 local (@actual_other_files) = ();
2614 local ($file, $local);
2615 local (@inputs, @rewritten_inputs, $single);
2616 foreach $file (@other_input_files)
2618 if ($file =~ /^(.*):(.*)$/)
2620 # This is the ":" syntax of AC_OUTPUT.
2622 $local = &basename ($file);
2623 @inputs = split (':', $2);
2624 @rewritten_inputs = &rewrite_inputs_into_dependencies (@inputs);
2629 $local = &basename ($file);
2630 @inputs = ($local . '.in');
2632 &rewrite_inputs_into_dependencies ($file . '.in');
2635 # Skip files not in this directory.
2636 next unless &dirname ($file) eq $relative_dir;
2638 # Skip the config header.
2639 next if $local eq $top_builddir . '/' . $config_name;
2641 # Skip any Makefile.
2642 next if $local eq 'Makefile';
2644 $output_rules .= ($local . ': '
2645 . '$(top_builddir)/config.status '
2646 . join (' ', @rewritten_inputs) . "\n"
2648 . 'cd $(top_builddir) && CONFIG_FILES='
2649 . ($relative_dir eq '.' ? '' : '$(subdir)/')
2650 . '$@' . (length (@rewritten_inputs) > 1
2651 ? (':' . join (':', @rewritten_inputs))
2653 . ' CONFIG_HEADERS= ./config.status'
2655 push (@actual_other_files, $local);
2657 # Require all input files.
2658 &require_file_with_conf_line ($ac_output_line, $FOREIGN,
2662 # These files get removed by "make clean".
2663 &define_pretty_variable ('CONFIG_CLEAN_FILES', @actual_other_files);
2669 $dir_holds_headers = &am_install_var ('header', 'HEADERS', 'include',
2670 'oldinclude', 'pkginclude',
2676 return if ! $seen_gettext || $relative_dir ne '.';
2678 if (! &variable_defined ('SUBDIRS'))
2681 ("AM_GNU_GETTEXT in configure.in but SUBDIRS not defined");
2685 &require_file_with_conf_line ($ac_gettext_line, $FOREIGN, 'ABOUT-NLS')
2688 if (&variable_defined ('SUBDIRS'))
2692 "AM_GNU_GETTEXT in configure.in but \`po' not in SUBDIRS")
2693 if $contents{'SUBDIRS'} !~ /\bpo\b/;
2696 "AM_GNU_GETTEXT in configure.in but \`intl' not in SUBDIRS")
2697 if $contents{'SUBDIRS'} !~ /\bintl\b/;
2700 # Ensure that each language in ALL_LINGUAS has a .po file, and
2701 # each po file is mentioned in ALL_LINGUAS.
2704 local (%linguas) = ();
2705 grep ($linguas{$_} = 1, split (' ', $all_linguas));
2712 &am_line_error ($all_linguas_line,
2713 ("po/$_.po exists but \`$_' not in \`ALL_LINGUAS'"))
2717 foreach (keys %linguas)
2719 &am_line_error ($all_linguas_line,
2720 "$_ in \`ALL_LINGUAS' but po/$_.po does not exist")
2726 &am_error ("AM_GNU_GETTEXT in configure.in but \`ALL_LINGUAS' not defined");
2730 # Handle footer elements.
2733 if ($contents{'SOURCES'})
2735 # NOTE don't use define_pretty_variable here, because
2736 # $contents{...} is already defined.
2737 $output_vars .= 'SOURCES = ' . $contents{'SOURCES'} . "\n";
2739 if ($contents{'OBJECTS'})
2741 # NOTE don't use define_pretty_variable here, because
2742 # $contents{...} is already defined.
2743 $output_vars .= 'OBJECTS = ' . $contents{'OBJECTS'} . "\n";
2745 if ($contents{'SOURCES'} || $contents{'OBJECTS'})
2747 $output_vars .= "\n";
2750 if (&variable_defined ('SUFFIXES'))
2752 # Push actual suffixes, and not $(SUFFIXES). Some versions of
2753 # make do not like variable substitutions on the .SUFFIXES
2755 push (@suffixes, &variable_value_as_list ('SUFFIXES'));
2758 # Note: AIX 4.1 /bin/make will fail if any suffix rule appears
2759 # before .SUFFIXES. So we make sure that .SUFFIXES appears before
2760 # anything else, by sticking it right after the default: target.
2761 $output_header .= ".SUFFIXES:\n";
2764 $output_header .= ".SUFFIXES: " . join (' ', @suffixes) . "\n";
2766 $output_trailer .= &file_contents ('footer');
2769 # Deal with installdirs target.
2770 sub handle_installdirs
2772 # GNU Makefile standards recommend this.
2773 $output_rules .= ("installdirs:"
2774 . ($recursive_install
2775 ? " installdirs-recursive\n"
2777 push (@phony, 'installdirs');
2780 &pretty_print_rule ("\t" . '$(mkinstalldirs) ', "\t\t",
2783 $output_rules .= "\n";
2786 # There are several targets which need to be merged. This is because
2787 # their complete definition is compiled from many parts. Note that we
2788 # avoid double colon rules, otherwise we'd use them instead.
2789 sub handle_merge_targets
2791 # There are a few install-related variables that you should not define.
2793 foreach $var ('PRE_INSTALL', 'POST_INSTALL', 'NORMAL_INSTALL')
2795 if (&variable_defined ($var))
2797 &am_line_error ($var, "\`$var' should not be defined");
2801 push (@all, 'Makefile');
2802 push (@all, &basename ($config_name))
2803 if $config_name && &dirname ($config_name) eq $relative_dir;
2805 &do_one_merge_target ('info', @info);
2806 &do_one_merge_target ('dvi', @dvi);
2807 &do_check_merge_target;
2808 &do_one_merge_target ('installcheck', @installcheck);
2810 if (defined $options{'no-installinfo'})
2812 # FIXME: this is kind of a hack; should find another way to
2813 # know that this is required.
2815 if (grep ($_ eq 'install-info-am', @phony))
2817 push (@dirs, 'install-info-am');
2819 if (&variable_defined ('SUBDIRS'))
2821 push (@dirs, 'install-info-recursive');
2823 &do_one_merge_target ('install-info', @dirs);
2826 # Handle the various install targets specially. We do this so
2827 # that (eg) "make install-exec" will run "install-exec-recursive"
2828 # if required, but "make install" won't run it twice. Step one is
2829 # to see if the user specified local versions of any of the
2830 # targets we handle. "all" is treated as one of these since
2831 # "install" can run it.
2832 push (@install_exec, 'install-exec-local')
2833 if defined $contents{'install-exec-local'};
2834 push (@install_data, 'install-data-local')
2835 if defined $contents{'install-data-local'};
2836 push (@uninstall, 'uninstall-local')
2837 if defined $contents{'uninstall-local'};
2839 foreach $utarg ('uninstall-data-local', 'uninstall-data-hook',
2840 'uninstall-exec-local', 'uninstall-exec-hook')
2842 if (defined $contents{$utarg})
2845 ($x = $utarg) =~ s/(data|exec)-//;
2846 &am_line_error ($utarg, "use \`$x', not \`$utarg'");
2849 push (@all, 'all-local')
2850 if defined $contents{'all-local'};
2852 if (defined $contents{'install-local'})
2854 &am_line_error ('install-local',
2855 "use \`install-data' or \`install-exec', not \`install'");
2858 # Step two: if we are doing recursive makes, write out the
2859 # appropriate rules.
2861 if ($recursive_install)
2863 push (@install, 'install-recursive');
2867 local (@hackall) = ();
2868 if ($config_name && &dirname ($config_name) eq $relative_dir)
2871 # This is kind of a hack, but I couldn't see a better
2872 # way to handle it. In this particular case, we need
2873 # to make sure config.h is built before we recurse.
2874 # We can't do this by changing the order of
2875 # dependencies to the "all" because that breaks when
2876 # using parallel makes. Instead we handle things
2878 $output_rules .= ('all-recursive-am: $(CONFIG_HEADER)'
2879 . "\n\t" . '$(MAKE) all-recursive'
2881 push (@hackall, 'all-recursive-am');
2882 push (@phony, 'all-recursive-am');
2886 push (@hackall, 'all-recursive');
2889 $output_rules .= ('all-am: '
2893 push (@all, 'all-am');
2894 push (@phony, 'all-am');
2898 @all = ('all-recursive');
2900 # Must always generate `all-am' target, so it can be
2901 # referred to elsewhere.
2902 $output_rules .= "all-am:\n";
2906 $output_rules .= ('install-exec-am: '
2907 . join (' ', @install_exec)
2909 @install_exec = ('install-exec-recursive', 'install-exec-am');
2910 push (@install, 'install-exec-am');
2911 push (@phony, 'install-exec-am');
2915 @install_exec = ('install-exec-recursive');
2919 $output_rules .= ('install-data-am: '
2920 . join (' ', @install_data)
2922 @install_data = ('install-data-recursive', 'install-data-am');
2923 push (@install, 'install-data-am');
2924 push (@phony, 'install-data-am');
2928 @install_data = ('install-data-recursive');
2932 $output_rules .= ('uninstall-am: '
2933 . join (' ', @uninstall)
2935 @uninstall = ('uninstall-recursive', 'uninstall-am');
2936 push (@phony, 'uninstall-am');
2940 @uninstall = ('uninstall-recursive');
2944 # Step three: print definitions users can use. Code below knows
2945 # that install-exec is done before install-data, beware.
2946 $output_rules .= ("install-exec: "
2947 . join (' ', @install_exec)
2949 $output_rules .= "\t\$(NORMAL_INSTALL)\n";
2950 if (defined $contents{'install-exec-hook'})
2952 $output_rules .= "\t" . '$(MAKE) install-exec-hook' . "\n";
2954 $output_rules .= "\n";
2955 push (@install, 'install-exec') if !$recursive_install;
2956 push (@phony, 'install-exec');
2958 $output_rules .= ("install-data: "
2959 . join (' ', @install_data)
2961 $output_rules .= "\t\$(NORMAL_INSTALL)\n";
2962 if (defined $contents{'install-data-hook'})
2964 $output_rules .= "\t" . '$(MAKE) install-data-hook' . "\n";
2966 $output_rules .= "\n";
2967 push (@install, 'install-data') if !$recursive_install;
2968 push (@phony, 'install-data');
2970 # If no dependencies for 'install', add 'all'. Why? That way
2971 # "make install" at top level of distclean'd distribution won't
2972 # fail because stuff in 'lib' fails to build.
2973 if (! @install || (scalar (@install) == 2
2974 && $install[0] eq 'install-exec'
2975 && $install[1] eq 'install-data'))
2977 push (@install, 'all');
2979 $output_rules .= ('install: '
2980 . join (' ', @install)
2981 # Use "@:" as empty command so nothing prints.
2985 . join (' ', @uninstall)
2987 push (@phony, 'install', 'uninstall');
2989 $output_rules .= ('all: '
2992 push (@phony, 'all');
2994 # Generate the new 'install-strip' target.
2995 $output_rules .= ("install-strip:\n\t"
2996 . '$(MAKE) INSTALL_PROGRAM=\'$(INSTALL_PROGRAM) -s\' install'
3000 # Helper for handle_merge_targets.
3001 sub do_one_merge_target
3003 local ($name, @values) = @_;
3005 if (defined $contents{$name . '-local'})
3007 # User defined local form of target. So include it.
3008 push (@values, $name . '-local');
3009 push (@phony, $name . '-local');
3012 &pretty_print_rule ($name . ":", "\t\t", @values);
3013 push (@phony, $name);
3016 # Handle check merge target specially.
3017 sub do_check_merge_target
3019 if (defined $contents{'check-local'})
3021 # User defined local form of target. So include it.
3022 push (@check_tests, 'check-local');
3023 push (@phony, 'check-local');
3026 if (! &variable_defined ('SUBDIRS'))
3028 # 'check' must depend on `all', but not when doing recursive
3030 unshift (@check, 'all');
3034 # When subdirs are used, do the `all' build and then do all
3035 # the recursive stuff. Actually use `all-am' because it
3036 # doesn't recurse; we rely on the check target in the subdirs
3037 # to do the required builds there.
3038 unshift (@check, 'all-am');
3041 # The check target must depend on the local equivalent of `all',
3042 # to ensure all the primary targets are built. Also it must
3043 # depend on the test code named in @check.
3044 &pretty_print_rule ('check:', "\t\t", @check);
3046 # Now the check rules must explicitly run anything named in
3047 # @check_tests. This is done via a separate make invocation to
3048 # avoid problems with parallel makes. Every time I write code
3049 # like this I wonder: how could you invent a parallel make and not
3050 # provide any real synchronization facilities?
3051 &pretty_print_rule ("\t\$(MAKE)", "\t ", @check_tests);
3054 # Handle all 'clean' targets.
3057 push (@clean, 'generic');
3058 $output_rules .= &file_contents ('clean');
3059 &push_phony_cleaners ('generic');
3061 local ($target) = $recursive_install ? 'clean-am' : 'clean';
3062 &do_one_clean_target ($target, 'mostly', '', @clean);
3063 &do_one_clean_target ($target, '', 'mostly', @clean);
3064 &do_one_clean_target ($target, 'dist', '', @clean);
3065 &do_one_clean_target ($target, 'maintainer-', 'dist', @clean);
3067 push (@phony, 'clean', 'mostlyclean', 'distclean', 'maintainer-clean');
3070 if ($recursive_install)
3072 # Do -recursive before -am. If you aren't doing a parallel
3073 # make, this can be nicer.
3074 @deps = ('recursive', 'am');
3075 &do_one_clean_target ('', 'mostly', '', @deps);
3076 &do_one_clean_target ('', '', '', @deps);
3077 &do_one_clean_target ('', 'dist', '', @deps);
3078 &do_one_clean_target ('', 'maintainer-', '', @deps);
3082 # Helper for handle_clean.
3083 sub do_one_clean_target
3085 local ($target, $name, $last_name, @deps) = @_;
3087 # Special case: if target not passed, then don't generate
3088 # dependency on next "lower" clean target (eg no
3089 # clean<-mostlyclean derivation). In this case the target is
3090 # implicitly known to be 'clean'.
3091 local ($flag) = $target;
3092 $target = 'clean' if ! $flag;
3094 grep (($_ = $name . 'clean-' . $_) && 0, @deps);
3097 if ($last_name || $name ne 'mostly')
3099 push (@deps, $last_name . $target);
3103 # If a -local version of the rule is given, add it to the list.
3104 if (defined $contents{$name . $target . '-local'})
3106 push (@deps, $name . $target . '-local');
3109 # Print the target and the dependencies.
3110 &pretty_print_rule ($name . $target . ": ", "\t\t", @deps);
3112 # FIXME: shouldn't we really print these messages before running
3114 if ($name . $target eq 'maintainer-clean')
3116 # Print a special warning.
3118 ("\t\@echo \"This command is intended for maintainers to use;\"\n"
3119 . "\t\@echo \"it deletes files that may require special "
3120 . "tools to rebuild.\"\n");
3122 $output_rules .= "\trm -f config.status\n"
3123 if $relative_dir eq '.';
3125 elsif ($name . $target eq 'distclean')
3127 $output_rules .= "\trm -f config.status\n";
3128 $output_rules .= "\trm -f libtool\n" if $seen_libtool;
3130 $output_rules .= "\n";
3133 # Handle .PHONY target.
3136 &pretty_print_rule ('.PHONY:', "", @phony);
3137 $output_rules .= "\n";
3140 # Handle TESTS variable and other checks.
3143 if (defined $options{'dejagnu'})
3145 push (@check_tests, 'check-DEJAGNU');
3146 push (@phony, 'check-DEJAGNU');
3151 $xform = 's/^CYGNUS//;';
3155 $xform = 's/^CYGNUS.*$//;';
3157 $output_rules .= &file_contents_with_transform ($xform, 'dejagnu');
3159 # In Cygnus mode, these are found in the build tree.
3160 # Otherwise they are looked for in $PATH.
3161 &define_program_variable ('EXPECT', 'build', 'expect', 'expect');
3162 &define_program_variable ('RUNTEST', 'src', 'dejagnu', 'runtest');
3164 # Note that in the rule we don't directly generate site.exp to
3165 # avoid the possibility of a corrupted site.exp if make is
3166 # interrupted. Jim Meyering has some useful text on this
3168 $output_rules .= ("site.exp: Makefile\n"
3169 . "\t\@echo 'Making a new site.exp file...'\n"
3170 . "\t-\@rm -f site.bak\n"
3171 . "\t\@echo '## these variables are automatically generated by make ##' > \$\@-t\n"
3172 . "\t\@echo '# Do not edit here. If you wish to override these values' >> \$\@-t\n"
3173 . "\t\@echo '# edit the last section' >> \$\@-t\n"
3174 . "\t\@echo 'set tool \$(DEJATOOL)' >> \$\@-t\n"
3175 . "\t\@echo 'set srcdir \$(srcdir)' >> \$\@-t\n"
3176 . "\t\@echo 'set objdir' \`pwd\` >> \$\@-t\n");
3178 # Extra stuff for AC_CANONICAL_*
3179 local (@whatlist) = ();
3180 if ($seen_canonical)
3182 push (@whatlist, 'host')
3185 # Extra stuff only for AC_CANONICAL_SYSTEM.
3186 if ($seen_canonical == $AC_CANONICAL_SYSTEM)
3188 push (@whatlist, 'target', 'build');
3192 foreach $c1 (@whatlist)
3194 foreach $c2 ('alias', 'triplet')
3196 $output_rules .= "\t\@echo 'set ${c1}_${c2} \$(${c1}_${c2})' >> \$\@-t\n";
3200 $output_rules .= ("\t\@echo '## All variables above are generated by configure. Do Not Edit ##' >> \$\@-t\n"
3201 . "\t-\@sed '1,/^## All variables above are.*##/ d' site.bak >> \$\@-t\n"
3202 . "\t-\@mv site.exp site.bak\n"
3203 . "\t\@mv \$\@-t site.exp\n");
3208 foreach $c ('DEJATOOL', 'RUNTEST', 'RUNTESTFLAGS')
3210 if (&variable_defined ($c))
3212 &am_line_error ($c, "\`$c' defined but \`dejagnu' not in \`AUTOMAKE_OPTIONS'");
3217 if (&variable_defined ('TESTS'))
3219 push (@check_tests, 'check-TESTS');
3220 push (@phony, 'check-TESTS');
3222 $output_rules .= 'check-TESTS: $(TESTS)
3223 @failed=0; all=0; \\
3224 srcdir=$(srcdir); export srcdir; \\
3225 for tst in $(TESTS); do \\
3226 all=`expr $$all + 1`; \\
3227 if test -f $$tst; then dir=.; \\
3228 else dir="$(srcdir)"; fi; \\
3229 if $(TESTS_ENVIRONMENT) $$dir/$$tst; then \\
3230 echo "PASS: $$tst"; \\
3232 failed=`expr $$failed + 1`; \\
3233 echo "FAIL: $$tst"; \\
3236 if test "$$failed" -eq 0; then \\
3237 echo "========================"; \\
3238 echo "All $$all tests passed"; \\
3239 echo "========================"; \\
3241 echo "$$failed of $$all tests failed"; \\
3247 # Handle Emacs Lisp.
3248 sub handle_emacs_lisp
3250 local (@elfiles) = &am_install_var ('lisp', 'LISP', 'lisp', 'noinst');
3255 &define_configure_variable ('lispdir');
3256 &define_configure_variable ('EMACS');
3257 $output_rules .= (".el.elc:\n"
3258 . "\t\@echo 'WARNING: Warnings can be ignored. :-)'\n"
3259 . "\tEMACS=\$(EMACS) \$(SHELL) \$(srcdir)/elisp-comp \$<\n");
3260 push (@suffixes, '.el', '.elc');
3262 # Generate .elc files.
3263 grep ($_ .= 'c', @elfiles);
3264 &define_pretty_variable ('ELCFILES', @elfiles);
3266 push (@clean, 'lisp');
3267 &push_phony_cleaners ('lisp');
3269 push (@all, '$(ELCFILES)');
3272 if (&variable_defined ('lisp_LISP'))
3274 $varname = 'lisp_LISP';
3275 &am_error ("\`lisp_LISP' defined but \`AM_PATH_LISPDIR' not in \`configure.in'")
3280 $varname = 'noinst_LISP';
3283 &require_file_with_line ($varname, $FOREIGN, 'elisp-comp');
3287 ################################################################
3289 # Scan one file for interesting things. Subroutine of scan_configure.
3290 sub scan_one_configure_file
3292 local ($filename) = @_;
3294 open (CONFIGURE, $filename)
3295 || die "automake: couldn't open \`$filename': $!\n";
3296 print "automake: reading $filename\n" if $verbose;
3300 # Remove comments from current line.
3304 # Skip macro definitions. Otherwise we might be confused into
3305 # thinking that a macro that was only defined was actually
3309 # Populate libobjs array.
3310 if (/AC_FUNC_ALLOCA/)
3312 $libsources{'alloca.c'} = 1;
3314 elsif (/AC_FUNC_GETLOADAVG/)
3316 $libsources{'getloadavg.c'} = 1;
3318 elsif (/AC_FUNC_MEMCMP/)
3320 $libsources{'memcmp.c'} = 1;
3322 elsif (/AC_STRUCT_ST_BLOCKS/)
3324 $libsources{'fileblocks.c'} = 1;
3326 elsif (/A[CM]_REPLACE_GNU_GETOPT/)
3328 $libsources{'getopt.c'} = 1;
3329 $libsources{'getopt1.c'} = 1;
3331 elsif (/AM_FUNC_STRTOD/)
3333 $libsources{'strtod.c'} = 1;
3335 elsif (/AM_WITH_REGEX/)
3337 $libsources{'rx.c'} = 1;
3338 $libsources{'rx.h'} = 1;
3339 $libsources{'regex.c'} = 1;
3340 $libsources{'regex.h'} = 1;
3341 $omit_dependencies{'rx.h'} = 1;
3342 $omit_dependencies{'regex.h'} = 1;
3344 elsif (/AM_FUNC_MKTIME/)
3346 $libsources{'mktime.c'} = 1;
3348 elsif (/AM_FUNC_ERROR_AT_LINE/)
3350 $libsources{'error.c'} = 1;
3351 $libsources{'error.h'} = 1;
3353 elsif (/AM_FUNC_OBSTACK/)
3355 $libsources{'obstack.c'} = 1;
3356 $libsources{'obstack.h'} = 1;
3358 elsif (/LIBOBJS="(.*)\s+\$LIBOBJS"/
3359 || /LIBOBJS="\$LIBOBJS\s+(.*)"/)
3361 foreach $libobj_iter (split (' ', $1))
3363 if ($libobj_iter =~ /^(.*)\.o$/)
3365 $libsources{$1 . '.c'} = 1;
3370 if (! $in_ac_replace && s/AC_REPLACE_FUNCS\s*\(\[?//)
3376 $in_ac_replace = 0 if s/[\]\)].*$//;
3377 # Remove trailing backslash.
3381 # Need to skip empty elements for Perl 4.
3383 $libsources{$_ . '.c'} = 1;
3387 if (/(fp_WITH_DMALLOC|fp_WITH_REGEX|fp_FUNC_FNMATCH|fp_PROG_INSTALL|fp_C_PROTOTYPES|jm_MAINTAINER_MODE|ud_GNU_GETTEXT)/)
3389 &am_conf_line_error ($filename, $., "\`$1' is obsolete; use corresponding \`AM_' macro");
3392 # Process the AC_OUTPUT macro.
3393 if (! $in_ac_output && s/AC_OUTPUT\s*\(\[?//)
3396 $ac_output_line = $.;
3400 $in_ac_output = 0 if s/[\]\),].*$//;
3402 # Look at potential Makefile.am's.
3407 # Handle $local:$input syntax. Note that we ignore
3408 # every input file past the first, though we keep
3409 # those around for later.
3410 local ($local, $input, @rest) = split (/:/);
3417 # FIXME: should be error if .in is missing.
3418 $input =~ s/\.in$//;
3421 if (-f $input . '.am')
3423 # We have a file that automake should generate.
3424 push (@make_input_list, $input);
3425 $make_list{$input} = join (':', ($local, @rest));
3429 # We have a file that automake should cause to be
3430 # rebuilt, but shouldn't generate itself.
3431 push (@other_input_files, $_);
3436 if (/$AC_CONFIG_AUX_DIR_PATTERN/o)
3438 @config_aux_path = $1;
3441 # Check for ansi2knr.
3442 $am_c_prototypes = 1 if /AM_C_PROTOTYPES/;
3444 # Check for NLS support.
3445 if (/AM_GNU_GETTEXT/)
3448 $ac_gettext_line = $.;
3449 $omit_dependencies{'libintl.h'} = 1;
3452 # Look for ALL_LINGUAS.
3453 if (/ALL_LINGUAS="(.*)"$/ || /ALL_LINGUAS=(.*)$/)
3457 $all_linguas_line = $.;
3460 # Handle configuration headers. A config header of `[$1]'
3461 # means we are actually scanning AM_CONFIG_HEADER from
3463 if (/A([CM])_CONFIG_HEADER\s*\((.*)\)/
3468 "use \`AM_CONFIG_HEADER', not \`AC_CONFIG_HEADER'")
3471 $config_header_line = $.;
3473 if ($config_name =~ /^([^:]+):(.+)$/)
3476 $config_header = $2;
3480 $config_header = $config_name . '.in';
3484 # Handle AC_CANONICAL_*. Always allow upgrading to
3485 # AC_CANONICAL_SYSTEM, but never downgrading.
3486 $seen_canonical = $AC_CANONICAL_HOST
3487 if ! $seen_canonical
3488 && (/AC_CANONICAL_HOST/ || /AC_CHECK_TOOL/);
3489 $seen_canonical = $AC_CANONICAL_SYSTEM if /AC_CANONICAL_SYSTEM/;
3491 $seen_path_xtra = 1 if /AC_PATH_XTRA/;
3493 # This macro handles several different things.
3494 if (/$AM_INIT_AUTOMAKE_PATTERN/o)
3500 $seen_prog_install = 2;
3501 ($package_version = $1) =~ s/$AM_PACKAGE_VERSION_PATTERN/$1/o;
3502 $package_version_line = $.;
3505 # This is like AM_INIT_AUTOMAKE, but doesn't actually set the
3506 # package and version number. (This might change in the
3507 # future). Yes, I'm not above hacking Automake so it works
3508 # well with other GNU tools -- that is actually the point.
3509 if (/AM_INIT_GUILE_MODULE/)
3515 $seen_prog_install = 2;
3516 @config_aux_path = ('..');
3519 # Some things required by Automake.
3520 $seen_make_set = 1 if /AC_PROG_MAKE_SET/;
3521 $seen_arg_prog = 1 if /AC_ARG_PROGRAM/;
3523 if (/AC_PROG_(YACC|RANLIB|CC|CXX|LEX)/)
3525 $configure_vars{$1} = 1;
3527 if (/$AC_CHECK_PATTERN/o)
3529 $configure_vars{$3} = 1;
3531 if (/$AC_SUBST_PATTERN/o)
3533 $configure_vars{$1} = 1;
3536 $seen_decl_yytext = 1 if /AC_DECL_YYTEXT/;
3537 $seen_maint_mode = 1 if /AM_MAINTAINER_MODE/;
3538 $seen_package = 1 if /PACKAGE=/;
3540 # Skip VERSION of [$2]; that is from AM_INIT_AUTOMAKE.
3541 if (/\bVERSION=(\S+)/ && $1 ne '[$2]')
3544 $package_version = $1;
3545 $package_version_line = $.;
3552 # Weird conditionals here because it is always allowed to
3553 # upgrade to AM_PROG_INSTALL but never to downgrade to
3555 $seen_prog_install = 1 if ! $seen_prog_install && /AC_PROG_INSTALL/;
3556 $seen_prog_install = 2 if /AM_PROG_INSTALL/;
3558 $seen_lispdir = 1 if /AM_PATH_LISPDIR/;
3560 if (/AM_PROG_LIBTOOL/)
3564 $configure_vars{'RANLIB'} = 1;
3565 $configure_vars{'CC'} = 1;
3566 # AM_PROG_LIBTOOL runs AC_CANONICAL_HOST. Make sure we
3567 # never downgrade (if we've seen AC_CANONICAL_SYSTEM).
3568 $seen_canonical = $AC_CANONICAL_HOST if ! $seen_canonical;
3575 # Scan configure.in and aclocal.m4 for interesting things. We must
3576 # scan aclocal.m4 because there might be AC_SUBSTs and such there.
3579 # Reinitialize libsources here. This isn't really necessary,
3580 # since we currently assume there is only one configure.in. But
3581 # that won't always be the case.
3584 local ($in_ac_output, $in_ac_replace) = (0, 0);
3585 local (%make_list, @make_input_list);
3586 local ($libobj_iter);
3588 &scan_one_configure_file ('configure.in');
3589 &scan_one_configure_file ('aclocal.m4')
3592 # Set input and output files if not specified by user.
3595 @input_files = @make_input_list;
3596 %output_files = %make_list;
3599 &am_conf_error ("\`PACKAGE' not defined in configure.in")
3601 &am_conf_error ("\`VERSION' not defined in configure.in")
3604 # Look for some files we need. Always check for these. This
3605 # check must be done for every run, even those where we are only
3606 # looking at a subdir Makefile. We must set relative_dir so that
3607 # the file-finding machinery works.
3608 local ($relative_dir) = '.';
3609 &require_config_file ($FOREIGN, 'install-sh', 'mkinstalldirs');
3610 &am_error ("\`install.sh' is an anachronism; use \`install-sh' instead")
3611 if -f $config_aux_path[0] . '/install.sh';
3614 ################################################################
3616 # Set up for Cygnus mode.
3619 return unless $cygnus_mode;
3621 &set_strictness ('foreign');
3622 $options{'no-installinfo'} = 1;
3623 $options{'no-dependencies'} = 1;
3624 $use_dependencies = 0;
3626 if (! $seen_maint_mode)
3628 &am_conf_error ("\`AM_MAINTAINER_MODE' required when --cygnus specified");
3632 # Do any extra checking for GNU standards.
3633 sub check_gnu_standards
3635 if ($relative_dir eq '.')
3637 # In top level (or only) directory.
3638 &require_file ($GNU, 'INSTALL', 'NEWS', 'README', 'COPYING',
3639 'AUTHORS', 'ChangeLog');
3642 if ($strictness >= $GNU)
3644 if (defined $options{'no-installman'})
3646 &am_line_error ('AUTOMAKE_OPTIONS',
3647 "option \`no-installman' disallowed by GNU standards");
3650 if (defined $options{'no-installinfo'})
3652 &am_line_error ('AUTOMAKE_OPTIONS',
3653 "option \`no-installinfo' disallowed by GNU standards");
3658 # Do any extra checking for GNITS standards.
3659 sub check_gnits_standards
3661 if ($strictness >= $GNITS)
3663 if (-f $relative_dir . '/COPYING.LIB')
3665 &am_error ("\`${relative_dir}/COPYING.LIB' disallowed by Gnits standards");
3668 if ($relative_dir eq '.')
3670 if ($package_version !~ /^$GNITS_VERSION_PATTERN$/)
3672 # FIXME: allow real filename.
3673 &am_conf_line_error ('configure.in',
3674 $package_version_line,
3675 "version \`$package_version' doesn't follow Gnits standards");
3677 elsif (defined $1 && -f 'README-alpha')
3679 # This means we have an alpha release. See
3680 # GNITS_VERSION_PATTERN for details.
3681 &require_file ($GNITS, 'README-alpha');
3686 if ($relative_dir eq '.')
3688 # In top level (or only) directory.
3689 &require_file ($GNITS, 'THANKS');
3693 ################################################################
3695 # Pretty-print something. HEAD is what should be printed at the
3696 # beginning of the first line, FILL is what should be printed at the
3697 # beginning of every subsequent line.
3698 sub pretty_print_internal
3700 local ($head, $fill, @values) = @_;
3702 local ($column) = length ($head);
3703 local ($result) = $head;
3705 # Fill length is number of characters. However, each Tab
3706 # character counts for eight. So we count the number of Tabs and
3708 local ($fill_length) = length ($fill);
3709 $fill_length += 7 * ($fill =~ tr/\t/\t/d);
3711 local ($bol) = ($head eq '');
3714 # "71" because we also print a space.
3715 if ($column + length ($_) > 71)
3717 $result .= " \\\n" . $fill;
3718 $column = $fill_length;
3722 $result .= ' ' unless ($bol);
3724 $column += length ($_) + 1;
3732 # Pretty-print something and append to output_vars.
3735 $output_vars .= &pretty_print_internal (@_);
3738 # Pretty-print something and append to output_rules.
3739 sub pretty_print_rule
3741 $output_rules .= &pretty_print_internal (@_);
3745 ################################################################
3747 # See if a variable exists.
3748 sub variable_defined
3751 if (defined $targets{$var})
3753 &am_line_error ($var, "\`$var' is target; expected variable");
3756 elsif (defined $contents{$var})
3758 $content_seen{$var} = 1;
3764 # Mark a variable as examined.
3765 sub examine_variable
3768 &variable_defined ($var);
3771 # Return contents of variable as list, split as whitespace. This will
3772 # recursively follow $(...) and ${...} inclusions. It preserves @...@
3773 # substitutions. If PARENT is specified, it is the name of the
3774 # including variable; this is only used for error reports.
3775 sub variable_value_as_list
3777 local ($var, $parent) = @_;
3780 if (defined $targets{$var})
3782 &am_line_error ($var, "\`$var' is target; expected variable");
3784 elsif (! defined $contents{$var})
3786 &am_line_error ($parent, "variable \`$var' not defined");
3791 $content_seen{$var} = 1;
3792 foreach (split (' ', $contents{$var}))
3794 # If a comment seen, just leave.
3797 # Handle variable substitutions.
3798 if (/^\$\{(.*)\}$/ || /^\$\((.*)\)$/)
3800 local ($varname) = $1;
3802 if ($varname =~ /^([^:]*):([^=]*)=(.*)$/)
3806 ($from = $2) =~ s/(\W)/\\$1/g;
3810 @temp_list = &variable_value_as_list ($1, $var);
3812 # Now rewrite the value if appropriate.
3815 grep (s/$from$/$to/, @temp_list);
3818 push (@result, @temp_list);
3830 # Define a new variable, but only if not already defined.
3833 local ($var, $value) = @_;
3835 if (! defined $contents{$var})
3837 $output_vars .= $var . ' = ' . $value . "\n";
3838 $contents{$var} = $value;
3839 $content_seen{$var} = 1;
3843 # Like define_variable, but second arg is a list, and is
3845 sub define_pretty_variable
3847 local ($var, @value) = @_;
3848 if (! defined $contents{$var})
3850 $contents{$var} = join (' ', @value);
3851 &pretty_print ($var . ' = ', '', @value);
3852 $content_seen{$var} = 1;
3856 # Like define_variable, but define a variable to be the configure
3857 # substitution by the same name.
3858 sub define_configure_variable
3861 local ($value) = '@' . $var . '@';
3862 &define_variable ($var, $value);
3865 # Define a variable that represents a program to run. If in Cygnus
3866 # mode, the program is searched for in the build (or source) tree.
3867 # Otherwise no searching is done at all. Arguments are:
3868 # * VAR Name of variable to define
3869 # * WHATDIR Either `src' or `build', depending on where program should
3870 # be found. (runtest is in srcdir!)
3871 # * SUBDIR Subdir of top-level dir
3872 # * PROGRAM Name of program
3873 sub define_program_variable
3875 local ($var, $whatdir, $subdir, $program) = @_;
3879 local ($full) = ('$(top_' . $whatdir . 'dir)/../'
3880 . $subdir . '/' . $program);
3881 &define_variable ($var, ('`if test -f ' . $full
3882 . '; then echo ' . $full . '; else echo '
3883 . $program . '; fi`'));
3887 &define_variable ($var, $program);
3892 ################################################################
3894 # Read Makefile.am and set up %contents. Simultaneously copy lines
3895 # from Makefile.am into $output_trailer or $output_vars as
3896 # appropriate. NOTE we put rules in the trailer section. We want
3897 # user rules to come after our generated stuff.
3900 local ($amfile) = @_;
3902 open (AM_FILE, $amfile) || die "automake: couldn't open \`$amfile': $!\n";
3903 print "automake: reading $amfile\n" if $verbose;
3905 $output_vars = ("# $in_file_name generated automatically by automake "
3906 . $VERSION . " from $am_file_name\n");
3908 # Generate copyright for generated Makefile.in.
3909 $output_vars .= $gen_copyright;
3911 local ($saw_bk) = 0;
3912 local ($was_rule) = 0;
3913 local ($spacing) = '';
3914 local ($comment) = '';
3915 local ($last_var_name) = '';
3920 if (/$IGNORE_PATTERN/o)
3922 # Merely delete comments beginning with two hashes.
3924 elsif (/$WHITE_PATTERN/o)
3926 # Stick a single white line before the incoming macro or rule.
3930 elsif (/$COMMENT_PATTERN/o)
3932 # Stick comments before the incoming macro or rule. Make
3933 # sure a blank line preceeds first block of comments.
3934 $spacing = "\n" unless $blank;
3936 $comment .= $spacing . $_;
3945 $output_vars .= $comment . "\n";
3948 local ($am_vars) = '';
3950 local ($is_ok_macro);
3954 unless substr ($_, -1, 1) eq "\n";
3956 $_ =~ s/\@MAINT\@//g
3957 unless $seen_maint_mode;
3959 if (/$IGNORE_PATTERN/o)
3961 # Merely delete comments beginning with two hashes.
3963 elsif (/$WHITE_PATTERN/o)
3965 # Stick a single white line before the incoming macro or rule.
3968 elsif (/$COMMENT_PATTERN/o)
3970 # Stick comments before the incoming macro or rule.
3971 $comment .= $spacing . $_;
3978 $output_trailer .= $_;
3985 # Chop newline and backslash if this line is
3986 # continued. FIXME: maybe ensure trailing whitespace
3990 $contents{$last_var_name} .= $_;
3993 elsif (/$RULE_PATTERN/o)
3995 # warn "** Saw rule .$1.\n";
3998 # Value here doesn't matter; for targets we only note
4002 $content_lines{$1} = $.;
4003 $output_trailer .= $comment . $spacing . $_;
4004 $comment = $spacing = '';
4007 elsif (($is_ok_macro = /$MACRO_PATTERN/o)
4008 || /$BOGUS_MACRO_PATTERN/o)
4010 # Found a macro definition.
4012 $last_var_name = $1;
4013 if (substr ($2, -1) eq "\\")
4015 $contents{$1} = substr ($2, 0, length ($2) - 1);
4021 $content_lines{$1} = $.;
4022 $am_vars .= $comment . $spacing . $_;
4023 $comment = $spacing = '';
4027 &am_line_error ($., "bad macro name \`$1'")
4032 # This isn't an error; it is probably a continued rule.
4033 # In fact, this is what we assume.
4035 $output_trailer .= $comment . $spacing . $_;
4036 $comment = $spacing = '';
4043 $output_trailer .= $comment;
4045 # Compute relative location of the top object directory.
4046 local (@topdir) = ();
4047 foreach (split (/\//, $relative_dir))
4049 next if $_ eq '.' || $_ eq '';
4056 push (@topdir, '..');
4059 @topdir = ('.') if ! @topdir;
4061 $top_builddir = join ('/', @topdir);
4063 ($build_rx = $top_builddir) =~ s/(\W)/\\$1/g;
4064 $output_vars .= &file_contents_with_transform
4065 ('s/\@top_builddir\@/' . $build_rx . '/g;',
4068 # Generate some useful variables when AC_CANONICAL_* used. FIXME:
4069 # this should use generic %configure_vars method.
4070 if ($seen_canonical)
4072 local ($curs, %vars);
4073 $vars{'host_alias'} = 'host_alias';
4074 $vars{'host_triplet'} = 'host';
4075 if ($seen_canonical == $AC_CANONICAL_SYSTEM)
4077 $vars{'build_alias'} = 'build_alias';
4078 $vars{'build_triplet'} = 'build';
4079 $vars{'target_alias'} = 'target_alias';
4080 $vars{'target_triplet'} = 'target';
4082 foreach $curs (sort keys %vars)
4084 $output_vars .= "$curs = \@$vars{$curs}\@\n";
4085 $contents{$curs} = "\@$vars{$curs}\@";
4090 foreach $curs (sort keys %configure_vars)
4092 &define_configure_variable ($curs);
4095 $output_vars .= $am_vars;
4098 ################################################################
4100 sub initialize_global_constants
4102 # Values for AC_CANONICAL_*
4103 $AC_CANONICAL_HOST = 1;
4104 $AC_CANONICAL_SYSTEM = 2;
4106 # Associative array of standard directory names. Entry is TRUE if
4107 # corresponding directory should be installed during
4108 # 'install-exec' phase.
4126 # Helper text for dealing with man pages.
4127 $install_man_format =
4128 ' @sect=@SECTION@; \\
4129 inst=`echo "@MANBASE@" | sed \'$(transform)\'`.@FULLSECT@; \\
4130 if test -f $(srcdir)/@MAN@; then file=$(srcdir)/@MAN@; \\
4131 else file=@MAN@; fi; \\
4132 echo " $(INSTALL_DATA) $$file $(mandir)/man$$sect/$$inst"; \\
4133 $(INSTALL_DATA) $$file $(mandir)/man$$sect/$$inst
4136 $uninstall_man_format =
4137 ' inst=`echo "@MANBASE@" | sed \'$(transform)\'`.@FULLSECT@; \\
4138 rm -f $(mandir)/man@SECTION@/$$inst
4141 # Commonly found files we look for and automatically include in
4145 "README", "THANKS", "TODO", "NEWS", "COPYING", "COPYING.LIB",
4146 "INSTALL", "ABOUT-NLS", "ChangeLog", "configure", "configure.in",
4147 "config.guess", "config.sub", "AUTHORS", "BACKLOG", "ABOUT-GNU",
4148 "libversion.in", "mdate-sh", "mkinstalldirs", "install-sh",
4149 'texinfo.tex', "ansi2knr.c", "ansi2knr.1", 'elisp-comp',
4150 'interlock', 'ylwrap', 'acinclude.m4', @libtoolize_files
4153 # Commonly used files we auto-include, but only sometimes.
4156 "aclocal.m4", "acconfig.h", "config.h.top",
4157 "config.h.bot", "stamp-h.in", 'stamp-vti'
4161 -a, --add-missing add missing standard files to package
4162 --amdir=DIR directory storing config files
4163 --build-dir=DIR directory where build being done (for dependencies)
4164 --cygnus assume program is part of Cygnus-style tree
4165 --foreign set strictness to foreign
4166 --gnits set strictness to gnits
4167 --gnu set strictness to gnu
4168 --help print this help, then exit
4169 -i, --include-deps include generated dependencies in Makefile.in
4170 --no-force only update Makefile.in's that are out of date
4171 -o DIR, --output-dir=DIR
4172 put generated Makefile.in's into DIR
4173 --srcdir-name=DIR name used for srcdir (for dependencies)
4174 -v, --verbose verbosely list files processed
4175 --version print version number, then exit\n";
4177 # Copyright on generated Makefile.ins.
4179 # Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
4180 # This Makefile.in is free software; the Free Software Foundation
4181 # gives unlimited permission to copy, distribute and modify it.
4184 # Ignore return result from chmod, because it might give an error
4185 # if we chmod a symlink.
4186 $dist_header = "\t" . '-chmod -R a+r $(distdir)' . "\n";
4187 $dist{'tarZ'} = ("\t"
4188 . '$(TAR) chf - $(distdir) | compress -c > $(distdir).tar.Z'
4190 $dist{'shar'} = ("\t"
4191 . 'shar $(distdir) | gzip > $(distdir).shar.gz'
4193 $dist{'zip'} = "\t" . 'zip -rq $(distdir).zip $(distdir)' . "\n";
4194 $dist{'dist'} = "\t" . 'GZIP=$(GZIP) $(TAR) chozf $(distdir).tar.gz $(distdir)' . "\n";
4195 $dist_trailer = "\t" . 'rm -rf $(distdir)' . "\n";
4198 # (Re)-Initialize per-Makefile.am variables.
4199 sub initialize_per_input
4201 # These two variables are used when generating each Makefile.in.
4202 # They hold the Makefile.in until it is ready to be printed.
4205 $output_trailer = '';
4206 $output_header = '';
4208 # Suffixes found during a run.
4211 # This holds the contents of a Makefile.am, as parsed by
4215 # This holds the names which are targets. These also appear in
4219 # This holds the line numbers at which various elements of
4220 # %contents are defined.
4221 %content_lines = ();
4223 # This holds a 1 if a particular variable was examined.
4226 # This holds the "relative directory" of the current Makefile.in.
4227 # Eg for src/Makefile.in, this is "src".
4230 # This holds a list of files that are included in the
4234 # List of dependencies for the obvious targets.
4250 # These are pretty obvious, too. They are used to define the
4251 # SOURCES and OBJECTS variables.
4255 # TRUE if current directory holds any C source files.
4256 $dir_holds_sources = 0;
4258 # These variables track inclusion of various compile-related .am
4259 # files. $included_generic_compile is TRUE if the basic code has
4260 # been included. $included_knr_compile is TRUE if the ansi2knr
4261 # code has been included. $included_libtool_compile is TRUE if
4262 # libtool support has been included.
4263 $included_generic_compile = 0;
4264 $included_knr_compile = 0;
4265 $included_libtool_compile = 0;
4267 # TRUE if current directory holds any headers.
4268 $dir_holds_headers = 0;
4270 # TRUE if install targets should work recursively.
4271 $recursive_install = 0;
4276 # Strictness levels.
4277 $strictness = $default_strictness;
4278 $strictness_name = $default_strictness_name;
4280 # Options from AUTOMAKE_OPTIONS.
4283 # Whether or not dependencies are handled. Can be further changed
4284 # in handle_options.
4285 $use_dependencies = $cmdline_use_dependencies;
4288 $local_maint_charset = $maint_charset;
4290 # All yacc and lex source filenames for this directory. Use
4291 # filenames instead of raw count so that multiple instances are
4292 # counted correctly (eg one yacc file can appear in multiple
4293 # programs without harm).
4297 # C++ source extensions we've seen.
4298 %cxx_extensions = ();
4300 # TRUE if we've seen any non-C++ sources.
4303 # This is a list of all targets to run during "make dist".
4306 # Keys in this hash are the names of ._o files which must depend
4308 %de_ansi_objects = ();
4312 ################################################################
4314 # Return contents of a file from $am_dir, automatically skipping
4315 # macros or rules which are already known. Runs command on each line
4316 # as it is read; this command can modify $_.
4317 sub file_contents_with_transform
4319 local ($command, $basename) = @_;
4320 local ($file) = $am_dir . '/' . $basename . '.am';
4322 if ($command ne '' && substr ($command, -1) ne ';')
4324 die "automake: programming error in file_contents_with_transform\n";
4327 open (FC_FILE, $file)
4328 || die "automake: installation error: cannot open \`$file'\n";
4330 # print "automake: reading $file\n" if $verbose;
4332 local ($was_rule) = 0;
4333 local ($result_vars) = '';
4334 local ($result_rules) = '';
4335 local ($comment) = '';
4336 local ($spacing) = "\n";
4337 local ($skipping) = 0;
4342 $_ =~ s/\@MAINT\@//g
4343 unless $seen_maint_mode;
4345 $had_chars = length ($_);
4347 # If the transform caused all the characters to go away, then
4348 # ignore the line. Why do this? Because in Perl 4, a "next"
4349 # inside of an eval doesn't affect a loop outside the eval.
4350 # So we can't pass in a "transform" that uses next. We used
4352 next if $had_chars && $_ eq '';
4354 if (/$IGNORE_PATTERN/o)
4356 # Merely delete comments beginning with two hashes.
4358 elsif (/$WHITE_PATTERN/o)
4360 # Stick a single white line before the incoming macro or rule.
4363 elsif (/$COMMENT_PATTERN/o)
4365 # Stick comments before the incoming macro or rule.
4366 $comment .= $spacing . $_;
4373 $result_rules .= $_ if ! $skipping;
4377 $result_vars .= $_ if ! $skipping;
4381 elsif (/$RULE_PATTERN/o)
4383 # warn "** Found rule .$1.\n";
4386 $skipping = defined $contents{$1};
4387 # warn "** Skip $skipping\n" if $skipping;
4388 $result_rules .= $comment . $spacing . $_ if ! $skipping;
4389 $comment = $spacing = '';
4392 elsif (/$MACRO_PATTERN/o)
4394 # warn "** Found macro .$1.\n";
4395 # Found a variable reference.
4397 $skipping = defined $contents{$1};
4398 # warn "** Skip $skipping\n" if $skipping;
4399 $result_vars .= $comment . $spacing . $_ if ! $skipping;
4400 $comment = $spacing = '';
4405 # This isn't an error; it is probably a continued rule.
4406 # In fact, this is what we assume.
4408 $result_rules .= $comment . $spacing . $_ if ! $skipping;
4409 $comment = $spacing = '';
4415 return $result_vars . $result_rules . $comment;
4418 # Like file_contents_with_transform, but no transform.
4421 return &file_contents_with_transform ('', @_);
4424 # Find all variable prefixes that are used for install directories. A
4425 # prefix `zar' qualifies iff:
4426 # * `zardir' is a variable.
4427 # * `zar_PRIMARY' is a variable.
4428 sub am_primary_prefixes
4430 local ($primary, @prefixes) = @_;
4432 local (%valid, $varname);
4433 grep ($valid{$_} = 0, @prefixes);
4434 $valid{'EXTRA'} = 0;
4435 foreach $varname (keys %contents)
4437 if ($varname =~ /^(.*)_$primary$/)
4439 if (! defined $valid{$1}
4440 && ! &variable_defined ($1 . 'dir')
4441 # Note that a configure variable is always legitimate.
4442 # It is natural to name such variables after the
4443 # primary, so we explicitly allow it.
4444 && ! defined $configure_vars{$varname})
4446 &am_line_error ($varname, "invalid variable \"$varname\"");
4450 # Ensure all extended prefixes are actually used.
4459 # Handle `where_HOW' variable magic. Does all lookups, generates
4460 # install code, and possibly generates code to define the primary
4461 # variable. The first argument is the name of the .am file to munge,
4462 # the second argument is the primary variable (eg HEADERS), and all
4463 # subsequent arguments are possible installation locations. Returns
4464 # list of all values of all _HOW targets.
4466 # FIXME: this should be rewritten to be cleaner. It should be broken
4467 # up into multiple functions.
4469 # Usage is: am_install_var (OPTION..., file, HOW, where...)
4474 local ($do_clean, $do_ltlibs) = (0, 0);
4475 local ($more_xform) = '';
4478 if ($args[0] eq '-clean')
4482 if ($args[0] eq '-ltlibs')
4487 # Note that we explicitly set the mode, to avoid
4488 # lossage if the program name isn't what we expect.
4489 $more_xform = 's/\@LIBTOOL\@/\$(LIBTOOL) --mode=install/;';
4493 $more_xform = 's/\@LIBTOOL\@//;';
4496 elsif ($args[0] !~ /^-/)
4502 local ($file, $primary, @prefixes) = @args;
4503 unshift (@prefixes, 'lib') if ($do_ltlibs);
4506 local (@result) = ();
4508 # Now that configure substitutions are allowed in where_HOW
4509 # variables, it is an error to actually define the primary.
4510 &am_line_error ($primary, "\`$primary' is an anachronism")
4511 if &variable_defined ($primary);
4514 # Look for misspellings. It is an error to have a variable ending
4515 # in a "reserved" suffix whose prefix is unknown, eg
4516 # "bni_PROGRAMS". However, unusual prefixes are allowed if a
4517 # variable of the same name (with "dir" appended) exists. For
4518 # instance, if the variable "zardir" is defined, then
4519 # "zar_PROGRAMS" becomes valid. This is to provide a little extra
4520 # flexibility in those cases which need it. Perhaps it should be
4521 # disallowed in the Gnits case? The problem is, sometimes it is
4522 # useful to put things in a subdir of eg pkgdatadir, perhaps even
4524 local (%valid) = &am_primary_prefixes ($primary, @prefixes);
4526 # If a primary includes a configure substitution, then the EXTRA_
4527 # form is required. Otherwise we can't properly do our job.
4528 local ($require_extra);
4529 local ($warned_about_extra) = 0;
4531 local ($clean_file) = $file . '-clean';
4534 foreach $X (sort keys %valid)
4536 $one_name = $X . '_' . $primary;
4537 if (&variable_defined ($one_name))
4539 # Append actual contents of where_PRIMARY variable to
4542 foreach $rcurs (&variable_value_as_list ($one_name))
4544 # Skip configure substitutions. Possibly bogus.
4545 if ($rcurs =~ /^\@.*\@$/)
4549 if (! $warned_about_extra)
4551 $warned_about_extra = 1;
4552 &am_line_error ($one_name,
4553 "\`$one_name' contains configure substitution, but shouldn't");
4556 # Check here to make sure variables defined in
4557 # configure.in do not imply that EXTRA_PRIMARY
4559 elsif (! defined $configure_vars{$one_name})
4561 $require_extra = $one_name;
4568 if ($rcurs =~ /^lib.*\.l?a$/)
4570 if (! $seen_libtool)
4572 &am_line_error ($one_name,
4573 "\`$rcurs' is a libtool library name, but AM_PROG_LIBTOOL is not in \`configure.in'");
4577 # Check that libtool libraries go only into
4578 # libdir. Ignore `EXTRA' libtool libraries.
4579 if ($rcurs =~ /^lib.*\.la$/ && $X ne 'lib'
4582 &am_line_error ($one_name,
4583 "libtool library \`$rcurs' must only be installed in libdir");
4585 elsif ($X =~ /^s?bin|libexec$/)
4587 &am_line_error ($one_name,
4588 "library \`$rcurs' must not be installed in a binary directory");
4593 &am_line_error ($one_name,
4594 "only libraries (not \`$rcurs') may be installed in libdir");
4597 push (@result, $rcurs);
4600 # "EXTRA" shouldn't be used when generating clean targets,
4601 # @all, or install targets.
4602 next if $X eq 'EXTRA';
4607 &file_contents_with_transform ('s/\@DIR\@/' . $X . '/go;',
4610 push (@clean, $X . $primary);
4611 &push_phony_cleaners ($X . $primary);
4616 push (@check, '$(' . $one_name . ')');
4620 push (@used, '$(' . $one_name . ')');
4622 if ($X eq 'noinst' || $X eq 'check')
4624 # Objects which don't get installed by default.
4628 if ($do_ltlibs && $X eq 'lib')
4631 &file_contents_with_transform ('s/\@DIR\@/' . $X . '/go;',
4637 &file_contents_with_transform ('s/\@DIR\@/' . $X . '/g;'
4642 push (@uninstall, 'uninstall-' . $X . $primary);
4643 push (@phony, 'uninstall-' . $X . $primary);
4644 push (@installdirs, '$(' . $X . 'dir)');
4645 if (defined $exec_dir_p{$X} ? $exec_dir_p{$X} : ($X =~ /exec/))
4647 push (@install_exec, 'install-' . $X . $primary);
4648 push (@phony, 'install-' . $X . $primary);
4652 push (@install_data, 'install-' . $X . $primary);
4653 push (@phony, 'install-' . $X . $primary);
4661 &define_pretty_variable ($primary, @used);
4662 $output_vars .= "\n";
4665 if ($require_extra && ! &variable_defined ('EXTRA_' . $primary))
4667 &am_line_error ($require_extra,
4668 "\`$require_extra' contains configure substitution, but \`EXTRA_$primary' not defined");
4671 # Push here because PRIMARY might be configure time determined.
4672 push (@all, '$(' . $primary . ')')
4679 ################################################################
4681 # This variable is local to the "require file" set of functions.
4682 @require_file_paths = ();
4684 # Verify that the file must exist in the current directory. Usage:
4685 # require_file (isconfigure, line_number, strictness, file) strictness
4686 # is the strictness level at which this file becomes required. Must
4687 # set require_file_paths before calling this function.
4688 # require_file_paths is set to hold a single directory (the one in
4689 # which the first file was found) before return.
4690 sub require_file_internal
4692 local ($is_configure, $line, $mystrict, @files) = @_;
4693 local ($file, $fullfile);
4694 local ($found_it, $errfile, $errdir);
4697 foreach $file (@files)
4700 foreach $dir (@require_file_paths)
4704 $fullfile = $relative_dir . "/" . $file;
4705 $errdir = $relative_dir unless $errdir;
4709 $fullfile = $dir . "/" . $file;
4710 $errdir = $dir unless $errdir;
4713 # Use different name for "error filename". Otherwise on
4714 # an error the bad file will be reported as eg
4715 # `../../install-sh' when using the default
4717 $errfile = $errdir . '/' . $file;
4722 # FIXME: Once again, special-case `.'.
4723 &push_dist_common ($file)
4724 if $dir eq $relative_dir || $dir eq '.';
4732 # Prune the path list.
4733 @require_file_paths = $save_dir;
4737 if ($strictness >= $mystrict)
4739 local ($trailer) = '';
4740 local ($suppress) = 0;
4742 # Only install missing files according to our desired
4746 $trailer = "; installing";
4749 # Maybe run libtoolize.
4751 && grep ($_ eq $file, @libtoolize_files)
4752 && system ('libtoolize', '--automake'))
4755 $trailer .= "; cannot run \`libtoolize': $!";
4757 elsif (-f ($am_dir . '/' . $file))
4759 # Install the missing file. Symlink if we
4760 # can, copy if we must. Note: delete the file
4761 # first, in case it is a dangling symlink.
4763 if ($symlink_exists)
4765 if (! symlink ($am_dir . '/' . $file, $errfile))
4768 $trailer .= "; error while making link: $!\n";
4771 elsif (! system ('cp', $am_dir . '/' . $file, $errfile))
4774 $trailer .= "\n error while making link\n";
4779 local ($save) = $exit_status;
4782 # FIXME: allow actual file to be specified.
4784 ('configure.in', $line,
4785 "required file \"$errfile\" not found$trailer");
4791 "required file \"$errfile\" not found$trailer");
4793 $exit_status = $save if $suppress;
4799 # Like require_file_with_line, but error messages refer to
4800 # configure.in, not the current Makefile.am.
4801 sub require_file_with_conf_line
4803 @require_file_paths = '.';
4804 &require_file_internal (1, @_);
4807 sub require_file_with_line
4809 @require_file_paths = '.';
4810 &require_file_internal (0, @_);
4815 @require_file_paths = '.';
4816 &require_file_internal (0, '', @_);
4819 # Require a file that is also required by Autoconf. Looks in
4820 # configuration path, as specified by AC_CONFIG_AUX_DIR.
4821 sub require_config_file
4823 @require_file_paths = @config_aux_path;
4824 &require_file_internal (1, '', @_);
4825 local ($dir) = $require_file_paths[0];
4826 @config_aux_path = @require_file_paths;
4829 $config_aux_dir = '.';
4833 $config_aux_dir = '$(top_srcdir)/' . $dir;
4837 # Assumes that the line number is in Makefile.am.
4838 sub require_conf_file_with_line
4840 @require_file_paths = @config_aux_path;
4841 &require_file_internal (0, @_);
4842 local ($dir) = $require_file_paths[0];
4843 @config_aux_path = @require_file_paths;
4846 $config_aux_dir = '.';
4850 $config_aux_dir = '$(top_srcdir)/' . $dir;
4854 # Assumes that the line number is in Makefile.am.
4855 sub require_conf_file_with_conf_line
4857 @require_file_paths = @config_aux_path;
4858 &require_file_internal (1, @_);
4859 local ($dir) = $require_file_paths[0];
4860 @config_aux_path = @require_file_paths;
4863 $config_aux_dir = '.';
4867 $config_aux_dir = '$(top_srcdir)/' . $dir;
4871 ################################################################
4873 # Push a list of files onto dist_common.
4874 sub push_dist_common
4876 local (@files) = @_;
4879 foreach $file (@files)
4881 $dist_common{$file} = 1;
4885 # Push a list of clean targets onto phony.
4886 sub push_phony_cleaners
4890 foreach $target ('mostly', 'dist', '', 'maintainer-')
4892 push (@phony, $target . 'clean-' . $base);
4899 $strictness_name = $_[0];
4900 if ($strictness_name eq 'gnu')
4904 elsif ($strictness_name eq 'gnits')
4906 $strictness = $GNITS;
4908 elsif ($strictness_name eq 'foreign')
4910 $strictness = $FOREIGN;
4914 die "automake: level \`$strictness_name' not recognized\n";
4919 ################################################################
4921 # Return directory name of file.
4927 ($sub = $file) =~ s,/+[^/]+$,,g;
4928 $sub = '.' if $sub eq $file;
4932 # Return file name of a file.
4938 ($sub = $file) =~s,^.*/+,,g;
4947 open (TOUCH, ">> $file");
4951 # Glob something. Do this to avoid indentation screwups everywhere we
4952 # want to glob. Gross!
4959 ################################################################
4961 # Print an error message and set exit status.
4964 warn "automake: ${am_file}.am: ", join (' ', @_), "\n";
4970 local ($symbol, @args) = @_;
4974 # If SYMBOL not already a line number, look it up in Makefile.am.
4975 $symbol = $content_lines{$symbol} unless $symbol =~ /^\d+$/;
4976 $symbol .= ': ' if $symbol;
4977 warn "${am_file}.am:", $symbol, join (' ', @args), "\n";
4986 # Like am_error, but while scanning configure.in.
4989 # FIXME: can run in subdirs.
4990 warn "automake: configure.in: ", join (' ', @_), "\n";
4994 # Error message with line number referring to configure.in.
4995 sub am_conf_line_error
4997 local ($file, $line, @args) = @_;
5001 warn "$file: $line: ", join (' ', @args), "\n";
5006 &am_conf_error (@args);
5010 # Tell user where our aclocal.m4 is, but only once.
5011 sub keyed_aclocal_warning
5014 warn "automake: macro \`$key' can be generated by \`aclocal'\n";
5017 # Print usage information.
5020 print "Usage: automake [OPTION] ... [Makefile]...\n";
5022 print "\nFiles which are automatically distributed, if found:\n";
5023 $~ = "USAGE_FORMAT";
5024 local (@lcomm) = sort ((@common_files, @common_sometimes));
5025 local ($one, $two, $three, $four);
5028 $one = shift @lcomm;
5029 $two = @lcomm ? shift @lcomm : '';
5030 $three = @lcomm ? shift @lcomm : '';
5031 $four = @lcomm ? shift @lcomm : '';
5035 print "\nReport bugs to <bug-gnu-utils\@prep.ai.mit.edu>\n";
5040 format USAGE_FORMAT =
5041 @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<
5042 $one, $two, $three, $four