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)\\(\\[?(\\w+)";
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 # TRUE if we've seen AM_CYGWIN32.
196 # Hash table of discovered configure substitutions. Keys are names,
197 # values are meaningless.
198 %configure_vars = ();
200 # Charsets used by maintainer and in distribution. MAINT_CHARSET is
201 # handled in a funny way: if seen in the top-level Makefile.am, it is
202 # used for every directory which does not specify a different value.
203 # The rationale here is that some directories (eg gettext) might be
204 # distributions of other packages, and thus require their own charset
205 # info. However, the DIST_CHARSET must be the same for the entire
206 # package; it can only be set at top-level.
207 # FIXME: this yields bugs when rebuilding. What to do? Always
208 # read (and sometimes discard) top-level Makefile.am?
210 $dist_charset = 'utf8'; # recode doesn't support this yet.
212 # Name of input file ("Makefile.in") and output file ("Makefile.am").
213 # These have no directory components.
217 # TRUE if --cygnus seen.
220 # Keys of this hash are names of dependency files to ignore.
221 %omit_dependencies = ();
223 # Map from obsolete macros to hints for new macros.
224 # FIXME complete the list so that there are no `0' hints.
227 'AC_FEATURE_CTYPE', "use \`AC_HEADER_STDC'",
228 'AC_FEATURE_ERRNO', "add \`strerror' to \`AC_REPLACE_FUNCS(...)'",
229 'AC_FEATURE_EXIT', 0,
230 'AC_SYSTEM_HEADER', 0,
232 # Note that we do not handle this one, because it is still run
233 # from AM_CONFIG_HEADER. So we deal with it specially in
235 # 'AC_CONFIG_HEADER', "use \`AM_CONFIG_HEADER'",
237 'fp_C_PROTOTYPES', "use \`AM_C_PROTOTYPES'",
238 'fp_PROG_CC_STDC', "use \`AM_PROG_CC_STDC'",
239 'fp_PROG_INSTALL', "use \`AM_PROG_INSTALL'",
240 'fp_WITH_DMALLOC', "use \`AM_WITH_DMALLOC'",
241 'fp_WITH_REGEX', "use \`AM_WITH_REGEX'",
242 'gm_PROG_LIBTOOL', "use \`AM_PROG_LIBTOOL'",
243 'jm_MAINTAINER_MODE', "use \`AM_MAINTAINER_MODE'",
244 'md_TYPE_PTRDIFF_T', "use \`AM_TYPE_PTRDIFF_T'",
245 'ud_PATH_LISPDIR', "use \`AM_PATH_LISPDIR'",
247 # Now part of autoconf proper, under a different name.
248 'AM_FUNC_FNMATCH', "use \`AC_FUNC_FNMATCH'",
249 'fp_FUNC_FNMATCH', "use \`AC_FUNC_FNMATCH'",
250 'AM_SANITY_CHECK_CC', "automatically done by \`AC_PROG_CC'",
252 # These aren't quite obsolete.
256 # Regexp to match the above macros.
257 $obsolete_rx = '(' . join ('|', keys %obsolete_macros) . ')';
261 &initialize_global_constants;
263 # Parse command line.
264 &parse_arguments (@ARGV);
266 # Do configure.in scan only once.
269 die "automake: no \`Makefile.am' found or specified\n"
272 # Now do all the work on each file.
273 foreach $am_file (@input_files)
275 if (! -f ($am_file . '.am'))
277 &am_error ("\`" . $am_file . ".am' does not exist");
281 &generate_makefile ($output_files{$am_file}, $am_file);
285 if ($seen_prog_install <= $scripts_installed)
287 &am_conf_error (($scripts_installed ? 'AM_PROG_INSTALL' : 'AC_PROG_INSTALL')
288 . " must be used in configure.in");
289 &keyed_aclocal_warning ('AM_PROG_INSTALL')
290 if $scripts_installed;
296 ################################################################
298 # Parse command line.
301 local (@arglist) = @_;
304 &set_strictness ('gnu');
308 if ($arglist[0] eq "--version")
310 print "automake (GNU $PACKAGE) $VERSION\n\n";
311 print "Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.\n";
312 print "This is free software; see the source for copying conditions. There is NO\n";
313 print "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n";
314 print "Written by Tom Tromey <tromey\@cygnus.com>\n";
318 elsif ($arglist[0] eq "--help")
322 elsif ($arglist[0] =~ /^--amdir=(.+)$/)
326 elsif ($arglist[0] eq '--amdir')
328 &require_argument (@arglist);
330 $am_dir = $arglist[0];
332 elsif ($arglist[0] =~ /^--build-dir=(.+)$/)
335 $build_directory = $1 . '/';
337 elsif ($arglist[0] eq '--build-dir')
339 &require_argument (@arglist);
342 $build_directory = $arglist[0] . '/';
344 elsif ($arglist[0] =~ /^--srcdir-name=(.+)$/)
348 elsif ($arglist[0] eq '--srcdir-name')
350 &require_argument (@arglist);
352 $srcdir_name = $arglist[0];
354 elsif ($arglist[0] eq '--gnu')
356 &set_strictness ('gnu');
358 elsif ($arglist[0] eq '--gnits')
360 &set_strictness ('gnits');
362 elsif ($arglist[0] eq '--cygnus')
366 elsif ($arglist[0] eq '--foreign')
368 &set_strictness ('foreign');
370 elsif ($arglist[0] eq '--include-deps' || $arglist[0] eq '-i')
372 $cmdline_use_dependencies = 0;
374 elsif ($arglist[0] eq '--no-force')
376 $force_generation = 0;
378 elsif ($arglist[0] =~ /^--output-dir=(.*)$/)
380 # Set output directory.
381 $output_directory = $1;
383 elsif ($arglist[0] eq '--output-dir' || $arglist[0] eq '-o')
385 &require_argument (@arglist);
387 $output_directory = $arglist[0];
389 elsif ($arglist[0] eq '--add-missing' || $arglist[0] eq '-a')
393 elsif ($arglist[0] eq '--verbose' || $arglist[0] eq '-v')
397 elsif ($arglist[0] eq '--')
399 # Stop option processing.
401 push (@input_files, @arglist);
404 elsif ($arglist[0] =~ /^-/)
406 die "automake: unrecognized option -- \`$arglist[0]'\nTry \`automake --help' for more information.\n";
410 # Handle $local:$input syntax. Note that we only examine
411 # the first ":" file to see if it is automake input; the
412 # rest are just taken verbatim. We still keep all the
413 # files around for dependency checking, however.
414 local ($local, $input, @rest) = split (/:/, $arglist[0]);
421 # Strip .in; later on .am is tacked on. That is how
422 # the automake input file is found. Maybe not the
423 # best way, but it is easy to explain. FIXME: should
424 # be error if .in is missing.
427 push (@input_files, $input);
428 $output_files{$input} = join (':', ($local, @rest));
434 # Take global strictness from whatever we currently have set.
435 $default_strictness = $strictness;
436 $default_strictness_name = $strictness_name;
439 # Ensure argument exists, or die.
442 local ($arg, @arglist) = @_;
443 die "automake: no argument given for option \`$arg'\n"
447 ################################################################
449 # Generate a Makefile.in given the name of the corresponding Makefile and
450 # the name of the file output by config.status.
451 sub generate_makefile
453 local ($output, $makefile) = @_;
455 ($am_file_name = $makefile) =~ s/^.*\///;
456 $in_file_name = $am_file_name . '.in';
457 $am_file_name .= '.am';
459 # $OUTPUT is encoded. If it contains a ":" then the first element
460 # is the real output file, and all remaining elements are input
461 # files. We don't scan or otherwise deal with these input file,
462 # other than to mark them as dependencies. See scan_configure for
464 local (@secondary_inputs);
465 ($output, @secondary_inputs) = split (/:/, $output);
467 &initialize_per_input;
468 $relative_dir = &dirname ($output);
469 $am_relative_dir = &dirname ($makefile);
471 # At the toplevel directory, we might need config.guess, config.sub
472 # or libtool scripts (ltconfig and ltmain.sh).
473 if ($relative_dir eq '.')
475 # libtool requires some files.
476 &require_conf_file_with_conf_line ($libtool_line, $FOREIGN,
480 # AC_CANONICAL_HOST and AC_CANONICAL_SYSTEM need config.guess and
482 &require_config_file ($FOREIGN, 'config.guess', 'config.sub')
486 # We still need Makefile.in here, because sometimes the `dist'
487 # target doesn't re-run automake.
488 if ($am_relative_dir eq $relative_dir)
490 # Only distribute the files if they are in the same subdir as
491 # the generated makefile.
492 &push_dist_common ($in_file_name, $am_file_name);
494 push (@sources, '$(SOURCES)')
495 if &variable_defined ('SOURCES');
496 push (@objects, '$(OBJECTS)')
497 if &variable_defined ('OBJECTS');
499 # This is always the default target. This gives us freedom to do
500 # things in whatever order is convenient. Note that we set up
501 # $output_header here so that we can insert some text just after
502 # the "default" target, but before any other targets. In
503 # particular we want to support the .SUFFIX hack here; this is
504 # documented elsewhere.
505 $output_header = "default: all\n\n";
506 push (@phony, 'default');
508 &read_am_file ($makefile . '.am');
511 # Fatal error. Just return, so we can continue with next file.
515 # Check first, because we might modify some state.
517 &check_gnu_standards;
518 &check_gnits_standards;
520 &handle_configure ($output, $makefile, @secondary_inputs);
527 &handle_built_sources;
529 # This must be run after all the sources are scanned.
530 &handle_yacc_lex_cxx;
532 # Re-init SOURCES and OBJECTS. FIXME: other code shouldn't depend
533 # on this (but currently does).
534 $contents{'SOURCES'} = join (' ', @sources);
535 $contents{'OBJECTS'} = join (' ', @objects);
545 &handle_dependencies;
548 &handle_merge_targets;
555 if (! -d ($output_directory . '/' . $am_relative_dir))
557 mkdir ($output_directory . '/' . $am_relative_dir, 0755);
560 local ($out_file) = $output_directory . '/' . $makefile . ".in";
561 if (! $force_generation && -e $out_file)
563 local ($am_time) = (stat ($makefile . '.am'))[9];
564 local ($in_time) = (stat ($out_file))[9];
565 # FIXME: how to do unsigned comparison?
566 if ($am_time < $in_time)
573 if (! open (GM_FILE, "> " . $out_file))
575 warn "automake: ${am_file}.in: cannot open: $!\n";
579 print "automake: creating ", $makefile, ".in\n" if $verbose;
581 print GM_FILE $output_vars;
582 print GM_FILE $output_header;
583 print GM_FILE $output_rules;
584 print GM_FILE $output_trailer;
589 ################################################################
591 # Handle AUTOMAKE_OPTIONS variable. Return 1 on error, 0 otherwise.
594 return 0 if ! &variable_defined ('AUTOMAKE_OPTIONS');
596 foreach (&variable_value_as_list ('AUTOMAKE_OPTIONS'))
599 if ($_ eq 'gnits' || $_ eq 'gnu' || $_ eq 'foreign')
601 &set_strictness ($_);
605 # An option like "../lib/ansi2knr" is allowed. With no
606 # path prefix, we assume the required programs are in this
607 # directory. We save the actual option for later.
608 $options{'ansi2knr'} = $_;
610 elsif ($_ eq 'no-installman' || $_ eq 'no-installinfo'
611 || $_ eq 'dist-shar' || $_ eq 'dist-zip'
612 || $_ eq 'dist-tarZ' || $_ eq 'dejagnu'
613 || $_ eq 'no-texinfo.tex')
615 # Explicitly recognize these.
617 elsif ($_ eq 'no-dependencies')
619 $use_dependencies = 0;
621 elsif (/([0-9]+)\.([0-9]+)/)
623 # Got a version number. Note that alpha releases count as
624 # the next higher release. Note also that we assume there
625 # will be a maximum of 100 minor releases for any given
627 local ($rmajor, $rminor) = ($1, $2);
628 if ($VERSION !~ /([0-9]+)\.([0-9]+)([a-z])?/)
631 "automake: programming error: version is incorrect\n";
634 local ($tmajor, $tminor) = ($1, $2);
635 # Handle alpha versions.
636 ++$tminor if defined $3;
638 if ($rmajor > $tmajor || ($rmajor == $tmajor && $rminor > $tminor))
640 &am_line_error ('AUTOMAKE_OPTIONS',
641 "require version $_, only have $VERSION");
647 &am_line_error ('AUTOMAKE_OPTIONS',
648 'option ', $_, 'not recognized');
655 # Return object extension. Just once, put some code into the output.
656 # Argument is the name of the output file
657 sub get_object_extension
662 $dir_holds_sources = 1;
664 # Maybe require libtool library object files.
665 local ($l, $extension) = ('', 'o');
666 $l = 'l' if ($out =~ /^lib.*\.la$/);
668 if (! $included_generic_compile)
672 if (&variable_defined ('CONFIG_HEADER'))
674 ($xform = &dirname ($contents{'CONFIG_HEADER'}))
676 $xform = '-I' . $xform;
678 $xform = 's/\@CONFIG_INCLUDE_SPEC\@/' . $xform . '/go;';
679 $output_vars .= &file_contents_with_transform ($xform,
681 $output_rules .= &file_contents ('compile');
682 &push_phony_cleaners ('compile');
684 # If using X, include some extra variable definitions. NOTE
685 # we don't want to force these into CFLAGS or anything,
686 # because not all programs will necessarily use X.
690 foreach $var ('X_CFLAGS', 'X_LIBS', 'X_EXTRA_LIBS', 'X_PRE_LIBS')
692 &define_configure_variable ($var);
696 push (@suffixes, '.c', '.o');
697 push (@clean, 'compile');
699 $included_generic_compile = 1;
702 if ($seen_libtool && ! $included_libtool_compile)
704 # Output the libtool compilation rules.
705 $output_rules .= &file_contents ('libtool');
706 &push_phony_cleaners ('libtool');
708 push (@suffixes, '.lo');
709 push (@clean, 'libtool');
711 $included_libtool_compile = 1;
714 # Check for automatic de-ANSI-fication.
715 if (defined $options{'ansi2knr'})
718 if (! $included_knr_compile)
720 if (! $am_c_prototypes)
722 &am_line_error ('AUTOMAKE_OPTIONS',
723 "option \`ansi2knr' in use but \`AM_C_PROTOTYPES' not in configure.in");
724 &keyed_aclocal_warning ('AM_C_PROTOTYPES');
725 # Only give this error once.
726 $am_c_prototypes = 1;
729 push (@suffixes, '._c', '._o');
730 push (@suffixes, '.l_o') if $seen_libtool;
732 # Only require ansi2knr files if they should appear in
734 if ($options{'ansi2knr'} eq 'ansi2knr')
736 &require_file_with_line ('AUTOMAKE_OPTIONS', $FOREIGN,
737 'ansi2knr.c', 'ansi2knr.1');
738 $output_rules .= &file_contents ('kr-extra');
739 push (@clean, 'krextra');
740 &push_phony_cleaners ('krextra');
743 &define_variable ('o', "\@U\@o");
745 # Make sure ansi2knr can be found: if no path specified,
747 local ($apath) = $options{'ansi2knr'};
750 # Found in another directory.
751 &define_variable ("ANSI2KNR", $apath);
755 # Substitution from AM_C_PROTOTYPES. This makes it be
756 # built only when necessary.
757 &define_configure_variable ('ANSI2KNR');
758 # ansi2knr needs to be built before subdirs, so unshift it.
759 unshift (@all, '$(ANSI2KNR)');
762 $output_rules .= &file_contents ('compile-kr');
763 $output_rules .= &file_contents ('clean-kr');
766 &push_phony_cleaners ('kr');
768 $included_knr_compile = 1;
772 return '.' . $l . $extension;
775 # Handle yacc and lex.
776 sub handle_yacc_lex_cxx
779 # First do yacc and lex.
782 local ($yacc_count) = scalar (keys %yacc_sources);
783 local ($lex_count) = scalar (keys %lex_sources);
787 local (%seen_suffix) = ();
788 foreach (keys %yacc_sources)
791 &output_yacc_build_rule ($1, $yacc_count > 1)
792 if (! defined $seen_suffix{$1});
793 $seen_suffix{$1} = 1;
796 if (! defined $configure_vars{'YACC'})
798 &am_error ("yacc source seen but \`YACC' not defined in \`configure.in'");
803 local (%seen_suffix) = ();
804 foreach (keys %lex_sources)
807 &output_lex_build_rule ($1, $lex_count > 1)
808 if (! defined $seen_suffix{$1});
809 $seen_suffix{$1} = 1;
812 if (! defined $configure_vars{'LEX'})
814 &am_error ("lex source seen but \`LEX' not defined in \`configure.in'");
816 if (! $seen_decl_yytext)
818 &am_error ("lex source seen but \`AC_DECL_YYTEXT' not in \`configure.in'");
822 if ($yacc_count > 1 || $lex_count > 1)
824 # If there is more than one distinct yacc (resp lex) source
825 # file in a given directory, then the `interlock' program is
826 # required to allow parallel builds to work correctly. FIXME:
827 # for now, no line number.
828 &require_config_file ($FOREIGN, 'interlock', 'ylwrap');
829 if ($config_aux_dir ne '.' && $config_aux_dir ne '')
831 &define_variable ('INTERLOCK', $config_aux_dir . "/interlock");
832 &define_variable ('YLWRAP', $config_aux_dir . "/ylwrap");
836 &define_variable ('INTERLOCK', '$(srcdir)/interlock');
837 &define_variable ('YLWRAP', '$(srcdir)/ylwrap');
844 local ($ltcompile, $ltlink) = ('', '');
847 &define_configure_variable ("LIBTOOL");
848 $ltcompile = '$(LIBTOOL) --mode=compile ';
849 $ltlink = '$(LIBTOOL) --mode=link ';
855 local (@cxx_list) = keys %cxx_extensions;
856 local ($cxx_count) = scalar @cxx_list;
859 push (@suffixes, @cxx_list);
861 &define_configure_variable ("CXXFLAGS");
862 &define_variable ('CXXCOMPILE', '$(CXX) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CXXFLAGS)');
863 &define_variable ('LTCXXCOMPILE',
864 $ltcompile . '$(CXX) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CXXFLAGS)')
867 &define_variable ('CXXLINK', $ltlink . '$(CXX) $(LDFLAGS) -o $@');
870 foreach $ext (@cxx_list)
872 $output_rules .= ("$ext.o:\n"
873 . "\t\$(CXXCOMPILE) -c \$<\n");
874 $output_rules .= ("$ext.lo:\n"
875 . "\t\$(LTCXXCOMPILE) -c \$<\n")
879 if (! defined $configure_vars{'CXX'})
881 &am_error ("C++ source seen but \`CXX' not defined in \`configure.in'");
886 # Handle some ansi2knr cleanup.
888 if (defined $options{'ansi2knr'} && keys %de_ansi_objects)
890 # Make all ._o files depend on ansi2knr. Use a sneaky little
891 # hack to make it print nicely.
892 &pretty_print_rule ('', '', (sort keys %de_ansi_objects,
893 ':', '$(ANSI2KNR)'));
897 # Last, handle some C cleanup.
901 &define_configure_variable ('CFLAGS');
902 &define_variable ('COMPILE',
903 '$(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)');
904 &define_variable ('LTCOMPILE',
906 '$(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)')
908 &define_variable ('LINK', $ltlink . '$(CC) $(LDFLAGS) -o $@');
910 if (! defined $configure_vars{'CC'})
912 &am_line_error ($seen_c_source,
913 "C source seen but \`CC' not defined in \`configure.in'");
919 # Output a rule to build from a YACC source. The output from YACC is
920 # compiled with C or C++, depending on the extension of the YACC file.
921 sub output_yacc_build_rule
923 local ($yacc_suffix, $use_interlock) = @_;
926 ($c_suffix = $yacc_suffix) =~ tr/y/c/;
927 push (@suffixes, $yacc_suffix);
928 $output_rules .= "$yacc_suffix$c_suffix:\n\t";
932 $output_rules .= '$(SHELL) $(INTERLOCK) =yacclockdir $(YLWRAP)'
933 . ' "$(YACC)" y.tab.c $*' . $c_suffix
934 . ' y.tab.h $*.h -- $(YFLAGS) $<';
938 $output_rules .= ('$(YACC) $(YFLAGS) $< && mv y.tab.c $@' . "\n"
939 . "\tif test -f y.tab.h; then \\\n"
940 . "\tif cmp -s y.tab.h \$*.h; then rm -f y.tab.h; else mv y.tab.h \$*.h; fi; \\\n"
943 $output_rules .= "\n";
946 sub output_lex_build_rule
948 local ($lex_suffix, $use_interlock) = @_;
951 ($c_suffix = $lex_suffix) =~ tr/l/c/;
952 push (@suffixes, $lex_suffix);
953 &define_configure_variable ('LEX_OUTPUT_ROOT');
954 &define_configure_variable ('LEXLIB');
955 $output_rules .= "$lex_suffix$c_suffix:\n\t";
959 # is the $@ correct here? If so, why not use it in the
960 # interlock build rule for yacc above?
961 $output_rules .= '$(SHELL) $(INTERLOCK) =lexlockdir $(YLWRAP)'
962 . ' "$(LEX)" $(LEX_OUTPUT_ROOT).c $@ -- $(LFLAGS) $<';
966 $output_rules .= '$(LEX) $(LFLAGS) $< && mv $(LEX_OUTPUT_ROOT).c $@';
968 $output_rules .= "\n";
972 # Check to make sure a source defined in LIBOBJS is not explicitly
973 # mentioned. This is a separate function (as opposed to being inlined
974 # in handle_source_transform) because it isn't always appropriate to
976 sub check_libobjs_sources
978 local ($one_file, $unxformed) = @_;
980 local ($prefix, $file, @files);
981 foreach $prefix ('', 'EXTRA_')
983 if (&variable_defined ($prefix . $one_file . '_SOURCES'))
985 @files = &variable_value_as_list ($prefix
986 . $one_file . '_SOURCES');
988 elsif ($prefix eq '')
990 @files = ($unxformed . '.c');
997 foreach $file (@files)
999 if (defined $libsources{$file})
1001 &am_line_error ($prefix . $one_file . '_SOURCES',
1002 "automatically discovered file \`$file' should not be explicitly mentioned");
1008 # Does much of the actual work for handle_source_transform.
1010 # list of source files to transform
1012 # first element is name of linker to use (empty string for default linker)
1013 # remaining elements are names of `.o's
1014 sub handle_single_transform_list
1016 local (@files) = @_;
1017 local ($linker) = '';
1018 local (@result) = ();
1019 local ($nonansi_obj) = $obj;
1020 $nonansi_obj =~ s/_//g;
1021 if (length (@files))
1023 # Turn sources into objects.
1026 # Skip header files, including C++-ish ones. The list
1027 # of C++ header extensions comes from Emacs 19.32
1034 # Skip things that look like configure substitutions.
1037 # Include appropriate file for lex or yacc source in
1038 # distribution. If the extension is the regular '.y' or
1039 # '.l', we assume C compilation, and the generated file
1040 # has exension .c. Otherwise, we compile with C++, and
1041 # make the following association: (yy -> cc, y++ -> c++,
1042 # yxx -> cxx), similarly for .ll, etc.
1043 if (/^(.*)\.(y|yy|y\+\+|yxx)$/)
1048 &push_dist_common ("$1.$ext");
1049 $yacc_sources{$_} = 1;
1051 elsif (/^(.*)\.(l|ll|l\+\+|lxx)$/)
1056 &push_dist_common ("$1.$ext");
1057 $lex_sources{$_} = 1;
1060 # Transform source files into .o files. List of C++
1061 # extensions comes from Emacs 19.34 etags.
1062 if (s/\.(c\+\+|cc|cpp|cxx|C)$/$nonansi_obj/)
1064 $cxx_extensions{'.' . $1} = 1;
1065 $linker = 'CXXLINK';
1067 elsif (s/\.(yy|y\+\+|yxx|ll|l\+\+|lxx)$/$nonansi_obj/)
1069 # Compiling lex or yacc with C++
1072 $cxx_extensions{".$ext"} = 1;
1073 $linker = 'CXXLINK';
1075 elsif (s/\.([Ff]\\|f90\\|for)$/$nonansi_obj/)
1077 # FORTRAN support. FIXME: not finished.
1079 elsif (s/\.[sS]$/$nonansi_obj/)
1081 # .s is assembly. Just rewrite it. FIXME: not finished.
1083 elsif (s/\.[cly]$/._o/)
1085 # .c is C. .l is lex. .y is yacc.
1087 # Note: first we rewrite (eg) foo.c to foo._o and push
1088 # the file onto the list of objects that require
1089 # ansi2knr. Then we rewrite ._o to $obj; $obj can be
1090 # simply `.o' if deansification is not really
1092 $de_ansi_objects{$_} = 1;
1094 $seen_c_source = -1 unless $seen_c_source;
1098 # No error message here. Used to have one, but it was
1105 # Transform .o or $o file into .P file (for automatic
1108 $dep_files{'.deps/' . $_} = 1;
1112 return ($linker, @result);
1115 # Handle SOURCE->OBJECT transform for one program or library.
1117 # canonical (transformed) name of object to build
1118 # actual name of object to build
1119 # object extension (ie either `.o' or `$o'.
1120 # Return result is name of linker variable that must be used.
1121 # Empty return means just use `LINK'.
1122 sub handle_source_transform
1124 # one_file is canonical name. unxformed is given name. obj is
1126 local ($one_file, $unxformed, $obj) = @_;
1127 local ($objpat) = $obj;
1128 $objpat =~ s/(\W)/\\$1/g;
1129 # Handle explicit `.o' as well as whatever we're passed.
1130 $objpat = '(' . $objpat . "|\\.o)";
1132 local ($linker) = '';
1134 if (&variable_defined ($one_file . "_OBJECTS"))
1136 &am_line_error ($one_file . '_OBJECTS',
1137 $one_file . '_OBJECTS', 'should not be defined');
1138 # No point in continuing.
1142 local (@files, @result, $prefix, $temp);
1143 foreach $prefix ('', 'EXTRA_')
1146 if (&variable_defined ($prefix . $one_file . "_SOURCES"))
1148 push (@sources, '$(' . $prefix . $one_file . "_SOURCES)");
1149 push (@objects, '$(' . $prefix . $one_file . "_OBJECTS)")
1150 unless $prefix eq 'EXTRA_';
1151 @files = &variable_value_as_list ($prefix
1152 . $one_file . "_SOURCES");
1154 elsif ($prefix eq '')
1156 &define_variable ($one_file . "_SOURCES", $unxformed . ".c");
1157 push (@sources, $unxformed . '.c');
1158 push (@objects, $unxformed . $obj);
1159 push (@files, $unxformed . '.c');
1162 ($temp, @result) = &handle_single_transform_list (@files);
1163 $linker = $temp if $linker eq '';
1164 &define_pretty_variable ($one_file . "_OBJECTS", @result)
1165 unless $prefix eq 'EXTRA_';
1168 if (&variable_defined ('CONFIG_HEADER'))
1170 $output_rules .= ('$(' . $one_file . "_OBJECTS): "
1171 . $contents{'CONFIG_HEADER'} . "\n");
1177 # Handle the BUILT_SOURCES variable.
1178 sub handle_built_sources
1180 return unless &variable_defined ('BUILT_SOURCES');
1181 push (@all, '$(BUILT_SOURCES)');
1183 local (@sources) = &variable_value_as_list ('BUILT_SOURCES');
1185 foreach $s (@sources)
1189 # FIXME: is this really the right thing to do?
1190 &am_line_error ('BUILT_SOURCES', "\`BUILT_SOURCES' should not contain a configure substitution");
1195 # We don't care about the return value of this function. We just
1196 # want to make sure to update %dep_files with the contents of
1198 &handle_single_transform_list (@sources);
1201 # Special-case @ALLOCA@ and @LIBOBJS@ in _LDADD or _LIBADD variables.
1202 # Also, generate _DEPENDENCIES variable if appropriate.
1204 # transformed name of object being built, or empty string if no object
1205 # name of _LDADD/_LIBADD-type variable to examine
1206 # boolean (lex_seen) which is true if a lex source file was seen in this
1207 # object. valid only for LDADDs, not LIBADDs. If set, LEXLIB
1209 # Returns 1 if LIBOBJS seen, 0 otherwise.
1210 sub handle_lib_objects
1212 local ($xname, $var, $lex_seen) = @_;
1214 die "automake: programming error 1 in handle_lib_objects\n"
1215 if ! &variable_defined ($var);
1217 die "automake: programming error 2 in handle_lib_objects\n"
1218 if $lex_seen && $var =~ /LIBADD/;
1220 # We recognize certain things that are commonly put in LIBADD or
1223 local (@dep_list) = ();
1225 # If no lex source seen, just assume this is ok.
1226 local ($lex_ok) = $lex_seen ? 0 : 1;
1228 local ($seen_libobjs) = 0;
1229 local ($flagvar) = 0;
1231 foreach $lsearch (&variable_value_as_list ($var))
1233 # Skip -lfoo and -Ldir; these are explicitly allowed.
1234 next if $lsearch =~ /^-[lL]/;
1235 if (! $flagvar && $lsearch =~ /^-/)
1237 if ($var =~ /^(.*)LDADD$/)
1239 &am_line_error ($var, "linker flags such as \`$lsearch' belong in \`${1}LDFLAGS");
1243 # Only get this error once.
1245 &am_line_error ($var, "you cannot use linker flags such as \`$lsearch' in \`$var'");
1249 # Assume we have a file of some sort, and push it onto the
1250 # dependency list. Autoconf substitutions are not pushed;
1251 # rarely is a new dependency substituted into (eg) foo_LDADD
1252 # -- but "bad things (eg -lX11) are routinely substituted.
1253 # Note that LIBOBJS and ALLOCA are exceptions to this rule,
1254 # and handled specially below.
1255 push (@dep_list, $lsearch)
1256 unless $lsearch =~ /^\@.*\@$/;
1258 # Automatically handle @LIBOBJS@ and @ALLOCA@. Basically this
1259 # means adding entries to dep_files.
1260 if ($lsearch =~ /^\@(LT)?LIBOBJS\@$/)
1262 push (@dep_list, $lsearch);
1264 if (! keys %libsources)
1266 &am_line_error ($var, "\@$1" . "LIBOBJS\@ seen but never set in \`configure.in'");
1269 local ($iter, $rewrite);
1270 foreach $iter (keys %libsources)
1272 if ($iter =~ /\.[cly]$/)
1274 $seen_c_source = $var;
1277 if ($iter =~ /\.h$/)
1279 &require_file_with_line ($var, $FOREIGN, $iter);
1281 elsif ($iter ne 'alloca.c')
1283 ($rewrite = $iter) =~ s/\.c$/.P/;
1284 $dep_files{'.deps/' . $rewrite} = 1;
1285 &require_file_with_line ($var, $FOREIGN, $iter);
1289 elsif ($lsearch =~ /^\@(LT)?ALLOCA\@$/)
1291 push (@dep_list, $lsearch);
1292 &am_line_error ($var,
1293 "\@$1" . "ALLOCA\@ seen but \`AC_FUNC_ALLOCA' not in \`configure.in'")
1294 if ! defined $libsources{'alloca.c'};
1295 $dep_files{'.deps/alloca.P'} = 1;
1296 &require_file_with_line ($var, $FOREIGN, 'alloca.c');
1297 $seen_c_source = $var;
1299 elsif ($lsearch eq '@LEXLIB@')
1301 # FIXME: variable_value_as_list requires us to force
1302 # @LEXLIB@ here, where we'd really prefer $(LEXLIB).
1303 # Nasty -- this will have to wait until many cleanups are
1311 &am_line_error ($var, 'lex source file used without @LEXLIB@');
1314 if ($xname ne '' && ! &variable_defined ($xname . '_DEPENDENCIES'))
1316 &define_pretty_variable ($xname . '_DEPENDENCIES', @dep_list);
1319 return $seen_libobjs;
1322 # Handle C programs.
1325 local (@proglist) = &am_install_var ('-clean',
1326 'progs', 'PROGRAMS',
1327 'bin', 'sbin', 'libexec', 'pkglib',
1329 return if ! @proglist;
1331 # If a program is installed, this is required. We only want this
1332 # error to appear once.
1333 &am_conf_error ("AC_ARG_PROGRAM must be used in configure.in")
1334 unless $seen_arg_prog;
1337 local ($one_file, $xname, $munge);
1339 local ($seen_libobjs) = 0;
1340 foreach $one_file (@proglist)
1342 local ($obj) = &get_object_extension ($one_file);
1344 # Canonicalize names.
1345 ($xname = $one_file) =~ tr/A-Za-z0-9_/_/c;
1346 if ($xname ne $one_file)
1349 foreach $xt ('_LDADD', '_LDFLAGS', '_SOURCES', '_OBJECTS', '_DEPENDENCIES')
1351 &am_line_error ($one_file . $xt,
1352 "invalid variable \`" . $one_file . $xt
1353 . "'; should be \`" . $xname . $xt . "'")
1354 if &variable_defined ($one_file . $xt);
1358 # FIXME: Using a trick to figure out if any lex sources appear
1359 # in our program; should use some cleaner method.
1360 local ($lex_num) = scalar (keys %lex_sources);
1361 local ($linker) = &handle_source_transform ($xname, $one_file, $obj);
1362 local ($lex_file_seen) = (scalar (keys %lex_sources) > $lex_num);
1365 if (&variable_defined ($xname . "_LDADD"))
1367 if (&handle_lib_objects ($xname, $xname . '_LDADD',
1377 # User didn't define prog_LDADD override. So do it.
1378 &define_variable ($xname . '_LDADD', '$(LDADD)');
1380 # This does a bit too much work. But we need it to
1381 # generate _DEPENDENCIES when appropriate.
1382 if (&variable_defined ('LDADD'))
1384 if (&handle_lib_objects ($xname, 'LDADD', $lex_file_seen))
1393 if (! &variable_defined ($xname . '_LDFLAGS'))
1395 # Define the prog_LDFLAGS variable.
1396 &define_variable ($xname . '_LDFLAGS', '');
1401 &am_line_error ($xname . $xt,
1402 'lex source file used without @LEXLIB@');
1405 # Determine program to use for link.
1407 if (&variable_defined ($xname . '_LINK'))
1409 $xlink = $xname . '_LINK';
1413 $xlink = $linker ? $linker : 'LINK';
1417 if (! $seen_cygwin32)
1419 $cygxform = 's/^CYGWIN.*$//; s/^NOTCYGWIN//;';
1423 $cygxform = 's/^NOTCYGWIN.*$//; s/^CYGWIN//;';
1427 &file_contents_with_transform
1428 ('s/\@PROGRAM\@/' . $one_file . '/go;'
1429 . 's/\@XPROGRAM\@/' . $xname . '/go;'
1430 . 's/\@XLINK\@/' . $xlink . '/go;'
1435 if (&variable_defined ('LDADD') && &handle_lib_objects ('', 'LDADD', 0))
1442 foreach $one_file (@proglist)
1444 # Canonicalize names.
1445 ($xname = $one_file) =~ tr/A-Za-z0-9_/_/c;
1447 if (&variable_defined ($xname . '_LDADD'))
1449 &check_libobjs_sources ($xname, $xname . '_LDADD');
1451 elsif (&variable_defined ('LDADD'))
1453 &check_libobjs_sources ($xname, 'LDADD');
1461 sub handle_libraries
1463 local (@liblist) = &am_install_var ('-clean',
1464 'libs', 'LIBRARIES',
1465 'lib', 'pkglib', 'noinst', 'check');
1466 return if ! @liblist;
1468 local (%valid) = &am_primary_prefixes ('LIBRARIES', 'lib', 'pkglib',
1470 if (! defined $configure_vars{'RANLIB'})
1473 foreach $key (keys %valid)
1475 if (&variable_defined ($key . '_LIBRARIES'))
1477 &am_line_error ($key . '_LIBRARIES', "library used but \`RANLIB' not defined in \`configure.in'");
1478 # Only get this error once.
1479 $configure_vars{'RANLIB'} = 1;
1488 local ($seen_libobjs) = 0;
1489 foreach $onelib (@liblist)
1491 # Check that the library fits the standard naming convention.
1492 if ($onelib !~ /^lib.*\.a$/)
1494 # FIXME this should only be a warning for foreign packages
1495 # FIXME should put line number here. That means mapping
1496 # from library name back to variable name.
1497 &am_error ("\`$onelib' is not a standard library name");
1500 local ($obj) = &get_object_extension ($onelib);
1502 # Canonicalize names.
1503 ($xlib = $onelib) =~ tr/A-Za-z0-9_/_/c;
1504 if ($xlib ne $onelib)
1507 foreach $xt ('_LIBADD', '_SOURCES', '_OBJECTS', '_DEPENDENCIES')
1509 &am_line_error ($onelib . $xt,
1510 "invalid variable \`" . $onelib . $xt
1511 . "'; should be \`" . $xlib . $xt . "'")
1512 if &variable_defined ($onelib . $xt);
1516 if (&variable_defined ($xlib . '_LIBADD'))
1518 if (&handle_lib_objects ($xlib, $xlib . '_LIBADD', 0))
1525 # Generate support for conditional object inclusion in
1527 &define_variable ($xlib . "_LIBADD", '');
1530 &handle_source_transform ($xlib, $onelib, $obj);
1533 &file_contents_with_transform ('s/\@LIBRARY\@/' . $onelib . '/go;'
1541 foreach $onelib (@liblist)
1543 # Canonicalize names.
1544 ($xlib = $onelib) =~ tr/A-Za-z0-9_/_/c;
1545 if (&variable_defined ($xlib . '_LIBADD'))
1547 &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
1552 &define_variable ('AR', 'ar');
1553 &define_configure_variable ('RANLIB');
1556 # Handle shared libraries.
1557 sub handle_ltlibraries
1559 local (@liblist) = &am_install_var ('-clean',
1560 'ltlib', 'LTLIBRARIES',
1562 return if ! @liblist;
1565 local (%valid) = &am_primary_prefixes ('LTLIBRARIES', 'lib', 'pkglib');
1568 foreach $key (keys %valid)
1570 if (&variable_defined ($key . '_LTLIBRARIES'))
1574 &am_line_error ($key . '_LTLIBRARIES', "library used but \`LIBTOOL' not defined in \`configure.in'");
1575 # Only get this error once.
1576 $configure_vars{'LIBTOOL'} = 1;
1580 # Get the installation directory of each library.
1581 next if ($key eq 'EXTRA');
1582 for (&variable_value_as_list ($key . '_LTLIBRARIES'))
1586 &am_error ("\`$_' is already going to be installed in \`$instdirs{$_}'");
1590 $instdirs{$_} = $key;
1599 local ($seen_libobjs) = 0;
1600 foreach $onelib (@liblist)
1602 # Check that the library fits the standard naming convention.
1603 if ($onelib !~ /^lib.*\.la$/)
1605 # FIXME this should only be a warning for foreign packages
1606 # FIXME should put line number here. That means mapping
1607 # from library name back to variable name.
1608 &am_error ("\`$onelib' is not a standard libtool library name");
1611 local ($obj) = &get_object_extension ($onelib);
1613 # Canonicalize names.
1614 ($xlib = $onelib) =~ tr/A-Za-z0-9_/_/c;
1615 if ($xlib ne $onelib)
1618 foreach $xt ('_LIBADD', '_LDFLAGS', '_SOURCES', '_OBJECTS', '_DEPENDENCIES')
1620 &am_line_error ($onelib . $xt,
1621 "invalid variable \`" . $onelib . $xt
1622 . "'; should be \`" . $xlib . $xt . "'")
1623 if &variable_defined ($onelib . $xt);
1627 if (! &variable_defined ($xlib . '_LDFLAGS'))
1629 # Define the lib_LDFLAGS variable.
1630 &define_variable ($xlib . '_LDFLAGS', '');
1633 if (&variable_defined ($xlib . '_LIBADD'))
1635 if (&handle_lib_objects ($xlib, $xlib . '_LIBADD', 0))
1642 # Generate support for conditional object inclusion in
1644 &define_variable ($xlib . "_LIBADD", '');
1647 local ($linker) = &handle_source_transform ($xlib, $onelib, $obj);
1649 # Determine program to use for link.
1651 if (&variable_defined ($xlib . '_LINK'))
1653 $xlink = $xlib . '_LINK';
1657 $xlink = $linker ? $linker : 'LINK';
1662 &file_contents_with_transform ('s/\@LTLIBRARY\@/'
1664 . 's/\@XLTLIBRARY\@/'
1667 . $instdirs{$onelib} . '/go;'
1668 . 's/\@XLINK\@/' . $xlink . '/go;',
1674 foreach $onelib (@liblist)
1676 # Canonicalize names.
1677 ($xlib = $onelib) =~ tr/A-Za-z0-9_/_/c;
1678 if (&variable_defined ($xlib . '_LIBADD'))
1680 &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
1686 # See if any _SOURCES variable were misspelled. Also, make sure that
1687 # EXTRA_ variables don't contain configure substitutions.
1690 local ($varname, $primary);
1691 foreach $varname (keys %contents)
1693 foreach $primary ('_SOURCES', '_LIBADD', '_LDADD', '_LDFLAGS', '_DEPENDENCIES')
1695 if ($varname =~ /$primary$/ && ! $content_seen{$varname})
1697 &am_line_error ($varname,
1698 "invalid unused variable name: \`$varname'");
1707 # NOTE we no longer automatically clean SCRIPTS, because it is
1708 # useful to sometimes distribute scripts verbatim. This happens
1709 # eg in Automake itself.
1710 &am_install_var ('scripts', 'SCRIPTS',
1711 'bin', 'sbin', 'libexec', 'pkgdata',
1714 # Set $scripts_installed if appropriate. Make sure we only find
1715 # scripts which are actually installed -- this is why we can't
1716 # simply use the return value of am_install_var.
1717 local (%valid) = &am_primary_prefixes ('SCRIPTS', 'bin', 'sbin',
1718 'libexec', 'pkgdata',
1721 foreach $key (keys %valid)
1723 if ($key ne 'noinst'
1725 && &variable_defined ($key . '_SCRIPTS'))
1727 $scripts_installed = 1;
1728 # push (@check_tests, 'check-' . $key . 'SCRIPTS');
1732 if ($scripts_installed)
1734 # If a program is installed, this is required. We only want this
1735 # error to appear once.
1736 &am_conf_error ("AC_ARG_PROGRAM must be used in configure.in")
1737 unless $seen_arg_prog;
1742 # Search a file for a "version.texi" Texinfo include. Return the name
1743 # of the include file if found, or the empty string if not. A
1744 # "version.texi" file is actually any file whose name matches
1746 sub scan_texinfo_file
1748 local ($filename) = @_;
1750 if (! open (TEXI, $filename))
1752 &am_error ("couldn't open \`$filename': $!");
1755 print "automake: reading $filename\n" if $verbose;
1757 local ($vfile, $outfile);
1760 if (/^\@setfilename +(\S+)/)
1766 if (/^\@include\s+(vers[^.]*\.texi)\s*$/)
1768 # Found version.texi include.
1775 return ($outfile, $vfile);
1778 # Handle all Texinfo source.
1781 &am_line_error ('TEXINFOS',
1782 "\`TEXINFOS' is an anachronism; use \`info_TEXINFOS'")
1783 if &variable_defined ('TEXINFOS');
1784 return if (! &variable_defined ('info_TEXINFOS')
1785 && ! &variable_defined ('html_TEXINFOS'));
1787 local (@texis) = &variable_value_as_list ('info_TEXINFOS');
1789 local (@info_deps_list, @dvis_list, @texi_deps);
1790 local ($infobase, $info_cursor);
1794 local ($tc_cursor, @texi_cleans);
1797 foreach $info_cursor (@texis)
1799 ($infobase = $info_cursor) =~ s/\.texi(nfo)?$//;
1801 # If 'version.texi' is referenced by input file, then include
1802 # automatic versioning capability.
1803 local ($out_file, $vtexi) = &scan_texinfo_file ($relative_dir
1804 . "/" . $info_cursor);
1806 if ($out_file eq '')
1808 &am_error ("\`$info_cursor' missing \@setfilename");
1812 if ($out_file =~ /\.(.+)$/ && $1 ne 'info')
1814 # FIXME should report line number in input file.
1815 &am_error ("output of \`$info_cursor', \`$out_file', has unrecognized extension");
1821 &am_error ("\`$vtexi', included in \`$info_cursor', also included in \`$versions{$vtexi}'")
1822 if (defined $versions{$vtexi});
1823 $versions{$vtexi} = $info_cursor;
1825 # We number the stamp-vti files. This is doable since the
1826 # actual names don't matter much. We only number starting
1827 # with the second one, so that the common case looks nice.
1828 $vti = 'vti' . ($done ? $done : '');
1829 &push_dist_common ($vtexi, 'stamp-' . $vti);
1830 push (@clean, $vti);
1832 # Only require once.
1833 &require_conf_file_with_line ('info_TEXINFOS', $FOREIGN,
1839 ($conf_pat = $config_aux_dir) =~ s/(\W)/\\$1/g;
1841 &file_contents_with_transform
1842 ('s/\@TEXI\@/' . $info_cursor . '/g; '
1843 . 's/\@VTI\@/' . $vti . '/g; '
1844 . 's/\@VTEXI\@/' . $vtexi . '/g;'
1845 . 's,\@MDDIR\@,' . $conf_pat . ',g;',
1848 &push_phony_cleaners ($vti);
1851 # If user specified file_TEXINFOS, then use that as explicit
1854 push (@texi_deps, $info_cursor);
1855 push (@texi_deps, $vtexi) if $vtexi;
1857 # Canonicalize name first.
1858 ($canonical = $infobase) =~ tr/A-Za-z0-9_/_/c;
1859 if (&variable_defined ($canonical . "_TEXINFOS"))
1861 push (@texi_deps, '$(' . $canonical . '_TEXINFOS)');
1862 &push_dist_common ('$(' . $canonical . '_TEXINFOS)');
1865 $output_rules .= ("\n" . $out_file . ": "
1866 . join (' ', @texi_deps)
1867 . "\n" . $infobase . ".dvi: "
1868 . join (' ', @texi_deps)
1871 push (@info_deps_list, $out_file);
1872 push (@dvis_list, $infobase . '.dvi');
1874 # Generate list of things to clean for this target. We do
1875 # this explicitly because otherwise too many things could be
1876 # removed. In particular the ".log" extension might
1877 # reasonably be used in other contexts by the user.
1878 foreach $tc_cursor ('aux', 'cp', 'cps', 'dvi', 'fn', 'fns',
1879 'ky', 'log', 'pg', 'toc', 'tp', 'tps',
1880 'vr', 'vrs', 'op', 'tr', 'cv')
1882 push (@texi_cleans, $infobase . '.' . $tc_cursor);
1886 # Find these programs wherever they may lie. Yes, this has
1887 # intimate knowledge of the structure of the texinfo distribution.
1888 &define_program_variable ('MAKEINFO', 'build', 'texinfo/makeinfo',
1890 &define_program_variable ('TEXI2DVI', 'src', 'texinfo/util',
1893 # Set transform for including texinfos.am. First, handle --cygnus
1898 $xform = 's/^NOTCYGNUS.*$//; s/^CYGNUS//;';
1902 $xform = 's/^CYGNUS.*$//; s/^NOTCYGNUS//;';
1905 # Handle location of texinfo.tex.
1908 &define_variable ('TEXINFO_TEX',
1909 '$(top_srcdir)/../texinfo/texinfo.tex');
1911 elsif (! &variable_defined ('TEXINFO_TEX'))
1913 &define_variable ('TEXINFO_TEX', '$(srcdir)/texinfo.tex');
1915 local ($xxform) = &dirname ($contents{'TEXINFO_TEX'});
1916 $xxform =~ s/(\W)/\\$1/g;
1917 $xform .= ' s/\@TEXINFODIR\@/' . $xxform . '/g;';
1919 $output_rules .= &file_contents_with_transform ($xform, 'texinfos');
1920 push (@phony, 'install-info-am', 'uninstall-info');
1921 push (@dist_targets, 'dist-info');
1924 $output_rules .= "\nmostlyclean-info:\n";
1925 &pretty_print_rule ("\trm -f", "\t ", @texi_cleans);
1926 $output_rules .= ("\nclean-info:\n\ndistclean-info:\n\n"
1927 . "maintainer-clean-info:\n\t"
1928 . 'for i in $(INFO_DEPS); do rm -f `eval echo $$i*`; done'
1930 &push_phony_cleaners ('info');
1932 push (@suffixes, '.texi', '.texinfo', '.info', '.dvi', '.ps');
1934 if (! defined $options{'no-installinfo'})
1936 push (@uninstall, 'uninstall-info');
1937 push (@installdirs, '$(infodir)');
1938 unshift (@install_data, 'install-info-am');
1940 # Make sure documentation is made and installed first. Use
1941 # $(INFO_DEPS), not 'info', because otherwise recursive makes
1942 # get run twice during "make all".
1943 unshift (@all, '$(INFO_DEPS)');
1945 push (@clean, 'info');
1946 push (@info, '$(INFO_DEPS)');
1947 push (@dvi, '$(DVIS)');
1949 &define_variable ("INFO_DEPS", join (' ', @info_deps_list));
1950 &define_variable ("DVIS", join (' ', @dvis_list));
1951 # This next isn't strictly needed now -- the places that look here
1952 # could easily be changed to look in info_TEXINFOS. But this is
1953 # probably better, in case noinst_TEXINFOS is ever supported.
1954 &define_variable ("TEXINFOS", $contents{'info_TEXINFOS'});
1956 # Do some error checking. Note that this file is not required
1957 # when in Cygnus mode; instead we defined TEXINFO_TEX explicitly
1959 &require_file_with_line ('info_TEXINFOS', $FOREIGN, 'texinfo.tex')
1960 unless (defined $options{'no-texinfo.tex'}
1961 || &variable_defined ('TEXINFO_TEX'));
1964 # Handle any man pages.
1965 sub handle_man_pages
1967 &am_line_error ('MANS', "\`MANS' is an anachronism; use \`man_MANS'")
1968 if &variable_defined ('MANS');
1969 return if ! &variable_defined ('man_MANS');
1971 # We generate the manpage install code by hand to avoid the use of
1972 # basename in the generated Makefile.
1973 local (@mans) = &variable_value_as_list ('man_MANS');
1974 local (%sections, %inames, %mbases, %secmap, %fullsecmap);
1978 # FIXME: statement without effect:
1979 /^(.*)\.([0-9])([a-z]*)$/;
1984 $fullsecmap{$i} = $2 . $3;
1988 # We don't really need this, but we use it in case we ever want to
1989 # support noinst_MANS.
1990 &define_variable ("MANS", $contents{'man_MANS'});
1992 # Generate list of install dirs.
1993 $output_rules .= "install-man: \$(MANS)\n";
1994 $output_rules .= "\t\$(NORMAL_INSTALL)\n";
1995 # Sort keys so that output is deterministic.
1996 foreach (sort keys %sections)
1998 push (@installdirs, '$(mandir)/man' . $_)
1999 unless defined $options{'no-installman'};
2000 $output_rules .= ("\t" . '$(mkinstalldirs) $(mandir)/man'
2003 push (@phony, 'install-man');
2005 # Generate install target.
2007 foreach $key (sort keys %inames)
2009 $_ = $install_man_format;
2010 s/\@SECTION\@/$secmap{$key}/g;
2011 s/\@MAN\@/$inames{$key}/g;
2012 s/\@FULLSECT\@/$fullsecmap{$key}/g;
2013 s/\@MANBASE\@/$mbases{$key}/g;
2014 $output_rules .= $_;
2016 $output_rules .= "\n";
2018 $output_rules .= "uninstall-man:\n\t\$(NORMAL_UNINSTALL)\n";
2019 foreach $key (sort keys %inames)
2021 $_ = $uninstall_man_format;
2022 s/\@SECTION\@/$secmap{$key}/g;
2023 s/\@MAN\@/$inames{$key}/g;
2024 s/\@FULLSECT\@/$fullsecmap{$key}/g;
2025 s/\@MANBASE\@/$mbases{$key}/g;
2026 $output_rules .= $_;
2028 $output_rules .= "\n";
2029 push (@phony, 'uninstall-man');
2031 $output_vars .= &file_contents ('mans-vars');
2033 if (! defined $options{'no-installman'})
2035 push (@install_data, 'install-man');
2036 push (@uninstall, 'uninstall-man');
2037 push (@all, '$(MANS)');
2041 # Handle DATA variables.
2044 &am_install_var ('data', 'DATA', 'data', 'sysconf',
2045 'sharedstate', 'localstate', 'pkgdata',
2052 push (@phony, 'tags');
2053 local (@tag_deps) = ();
2054 if (&variable_defined ('SUBDIRS'))
2056 $output_rules .= ("tags-recursive:\n"
2057 . "\tlist=\"\$(SUBDIRS)\"; for subdir in \$\$list; do \\\n"
2058 # Never fail here if a subdir fails; it
2060 . "\t (cd \$\$subdir && \$(MAKE) tags); \\\n"
2062 push (@tag_deps, 'tags-recursive');
2063 push (@phony, 'tags-recursive');
2066 if ($dir_holds_sources
2067 || $dir_holds_headers
2068 || &variable_defined ('ETAGS_ARGS')
2071 local ($xform) = '';
2072 if ($config_header && $relative_dir eq &dirname ($config_header))
2074 # The config header is in this directory. So require it.
2075 ($xform = &basename ($config_header)) =~ s/(\W)/\\$1/g;
2077 $xform = ('s/\@CONFIG\@/' . $xform . '/;'
2078 . 's/\@DIRS\@/' . join (' ', @tag_deps) . '/;');
2080 $output_rules .= &file_contents_with_transform ($xform, 'tags');
2081 $output_rules .= &file_contents ('tags-clean');
2082 push (@clean, 'tags');
2083 &push_phony_cleaners ('tags');
2084 &examine_variable ('TAGS_DEPENDENCIES');
2086 elsif (&variable_defined ('TAGS_DEPENDENCIES'))
2088 &am_line_error ('TAGS_DEPENDENCIES',
2089 "doesn't make sense to define \`TAGS_DEPENDENCIES' without sources or \`ETAGS_ARGS'");
2093 # Every Makefile must define some sort of TAGS rule.
2094 # Otherwise, it would be possible for a top-level "make TAGS"
2095 # to fail because some subdirectory failed.
2096 $output_rules .= "tags: TAGS\nTAGS:\n\n";
2100 # Worker for handle_dist.
2101 sub handle_dist_worker
2103 $output_rules .= 'distdir: $(DISTFILES)' . "\n";
2105 # Initialization; only at top level.
2106 if ($relative_dir eq '.')
2108 if ($strictness >= $GNITS)
2110 # For Gnits users, this is pretty handy. Look at 15 lines
2111 # in case some explanatory text is desirable.
2112 $output_rules .= ' @if sed 15q $(srcdir)/NEWS | fgrep -e "$(VERSION)" > /dev/null; then :; else \\
2113 echo "NEWS not updated; not releasing" 1>&2; \\
2121 # Create dist directory.
2124 -chmod 755 $(distdir)
2127 # Only run automake in `dist' target if --include-deps not
2128 # specified. That way the recipient of a distribution can run
2129 # "make dist" and not need Automake.
2130 if ($cmdline_use_dependencies)
2134 # We need an absolute path for --output-dir. Thus the
2136 ' here=`pwd`; distdir=`cd $(distdir) && pwd` \\
2138 && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(srcdir) --output-dir=$$distdir '
2139 # Set strictness of output.
2140 . ($cygnus_mode ? '--cygnus' : ('--' . $strictness_name))
2146 # Scan EXTRA_DIST to see if we need to distribute anything from a
2147 # subdir. If so, add it to the list. I didn't want to do this
2148 # originally, but there were so many requests that I finally
2151 if (&variable_defined ('EXTRA_DIST'))
2153 foreach (&variable_value_as_list ('EXTRA_DIST'))
2156 next unless s,/+[^/]+$,,;
2157 push (@dist_dirs, $_)
2163 # Prepend $(distdir) to each directory given. Doing it via a
2164 # hash lets us ensure that each directory is used only once.
2166 grep ($dhash{'$(distdir)/' . $_} = 1, @dist_dirs);
2167 $output_rules .= "\t";
2168 &pretty_print_rule ('$(mkinstalldirs)', "\t ", sort keys %dhash);
2171 # In loop, test for file existence because sometimes a file gets
2172 # included in DISTFILES twice. For example this happens when a
2173 # single source file is used in building more than one program.
2174 # Also, there are situations in which "ln" can fail. For instance
2175 # a file to distribute could actually be a cross-filesystem
2176 # symlink -- this can easily happen if "gettextize" was run on the
2178 $output_rules .= "\t\@for file in \$(DISTFILES); do \\\n";
2181 $output_rules .= "\t if test -f \$\$file; then d=.; else d=\$(srcdir); fi; \\\n";
2185 $output_rules .= "\t d=\$(srcdir); \\\n";
2187 $output_rules .= ' test -f $(distdir)/$$file \\
2188 || ln $$d/$$file $(distdir)/$$file 2> /dev/null \\
2189 || cp -p $$d/$$file $(distdir)/$$file; \\
2193 # If we have SUBDIRS, create all dist subdirectories and do
2195 if (&variable_defined ('SUBDIRS'))
2197 # Test for directory existence here because previous automake
2198 # invocation might have created some directories. Note that
2199 # we explicitly set distdir for the subdir make; that lets us
2200 # mix-n-match many automake-using packages into one large
2201 # package, and have "dist" at the top level do the right
2203 $output_rules .= ' for subdir in $(SUBDIRS); do \\
2204 test -d $(distdir)/$$subdir \\
2205 || mkdir $(distdir)/$$subdir \\
2207 chmod 755 $(distdir)/$$subdir; \\
2208 (cd $$subdir && $(MAKE) distdir=../$(distdir)/$$subdir distdir) \\
2214 # If the target `dist-hook' exists, make sure it is run. This
2215 # allows users to do random weird things to the distribution
2216 # before it is packaged up.
2217 push (@dist_targets, 'dist-hook') if defined $contents{'dist-hook'};
2220 foreach $targ (@dist_targets)
2222 # We must explicitly set distdir for these sub-makes.
2223 $output_rules .= "\t\$(MAKE) distdir=\"\$(distdir)\" $targ\n";
2226 push (@phony, 'distdir');
2229 # Handle 'dist' target.
2232 # Set up maint_charset.
2233 $local_maint_charset = $contents{'MAINT_CHARSET'}
2234 if &variable_defined ('MAINT_CHARSET');
2235 $maint_charset = $local_maint_charset
2236 if $relative_dir eq '.';
2238 if (&variable_defined ('DIST_CHARSET'))
2240 &am_line_error ('DIST_CHARSET',
2241 "DIST_CHARSET defined but no MAINT_CHARSET defined")
2242 if ! $local_maint_charset;
2243 if ($relative_dir eq '.')
2245 $dist_charset = $contents{'DIST_CHARSET'}
2249 &am_line_error ('DIST_CHARSET',
2250 "DIST_CHARSET can only be defined at top level");
2254 # Look for common files that should be included in distribution.
2256 foreach $cfile (@common_files)
2258 if (-f ($relative_dir . "/" . $cfile))
2260 &push_dist_common ($cfile);
2264 # Keys of %dist_common are names of files to distributed. We put
2265 # README first because it then becomes easier to make a
2266 # Usenet-compliant shar file (in these, README must be first).
2267 # FIXME: do more ordering of files here.
2269 if (defined $dist_common{'README'})
2271 push (@coms, 'README');
2272 delete $dist_common{'README'};
2274 push (@coms, sort keys %dist_common);
2276 &define_pretty_variable ("DIST_COMMON", @coms);
2277 $output_vars .= "\n";
2280 $output_vars .= &file_contents ('dist-vars') . "\n";
2281 &define_variable ('TAR', $TAR);
2282 &define_variable ('GZIP', '--best');
2284 # Put these things in rules section so it is easier for whoever
2285 # reads Makefile.in.
2286 if (! &variable_defined ('distdir'))
2288 if ($relative_dir eq '.')
2290 $output_rules .= "\n" . 'distdir = $(PACKAGE)-$(VERSION)' . "\n";
2294 $output_rules .= ("\n"
2295 . 'distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)'
2299 if ($relative_dir ne '.')
2301 $output_rules .= "\nsubdir = " . $relative_dir . "\n";
2304 # Generate 'dist' target, and maybe dist-shar / dist-zip / dist-tarZ.
2305 if ($relative_dir eq '.')
2307 # Rule to check whether a distribution is viable.
2308 $output_rules .= ('# This target untars the dist file and tries a VPATH configuration. Then
2309 # it guarantees that the distribution is self-contained by making another
2313 GZIP=$(GZIP) $(TAR) zxf $(distdir).tar.gz
2314 mkdir $(distdir)/=build
2315 mkdir $(distdir)/=inst
2316 dc_install_base=`cd $(distdir)/=inst && pwd`; \\'
2317 . (defined $contents{'distcheck-hook'}
2318 ? "\t\$(MAKE) distcheck-hook"
2321 cd $(distdir)/=build \\
2324 . ($seen_gettext ? '--with-included-gettext ' : '')
2325 . '--srcdir=.. --prefix=$$dc_install_base \\
2329 && $(MAKE) install \\
2330 && $(MAKE) installcheck \\
2333 @echo "========================"; \\
2334 echo "$(distdir).tar.gz is ready for distribution"; \\
2335 echo "========================"
2338 local ($dist_all) = ('dist-all: distdir' . "\n"
2341 foreach $curs ('dist', 'dist-shar', 'dist-zip', 'dist-tarZ')
2343 if (defined $options{$curs} || $curs eq 'dist')
2345 $output_rules .= ($curs . ': distdir' . "\n"
2349 $dist_all .= $dist{$curs};
2352 $output_rules .= $dist_all . $dist_trailer;
2355 # Generate distdir target.
2356 &handle_dist_worker;
2359 # Scan a single dependency file and rewrite the dependencies as
2360 # appropriate. Essentially this means:
2361 # * Clean out absolute dependencies which are not desirable.
2362 # * Rewrite other dependencies to be relative to $(top_srcdir).
2363 sub scan_dependency_file
2365 local ($depfile) = @_;
2367 if (! open (DEP_FILE, $depfile))
2369 &am_error ("couldn't open \`$depfile': $!");
2372 print "automake: reading $depfile\n" if $verbose;
2374 # Sometimes it is necessary to omit some dependencies.
2375 local (%omit) = %omit_dependencies;
2376 if (&variable_defined ('OMIT_DEPENDENCIES'))
2378 grep ($omit{$_} = 1, &variable_value_as_list ('OMIT_DEPENDENCIES'));
2381 local ($first_line) = 1;
2382 local ($last_line) = 0;
2383 local ($target, @dependencies);
2384 local ($one_dep, $xform);
2387 local ($srcdir_rx, $fixup_rx);
2388 # If the top srcdir is absolute, then the current directory is
2389 # just relative_dir. But if the top srcdir is relative, then we
2390 # need to add some dots first. The same holds when matching
2392 if ($srcdir_name =~ /^\//)
2394 ($fixup_rx = $srcdir_name . '/' . $relative_dir . '/')
2396 ($srcdir_rx = $srcdir_name . '/') =~ s/(\W)/\\$1/g;
2400 ($fixup_rx = ($srcdir_name . '/' . $top_builddir . '/'
2401 . $relative_dir . '/')) =~ s/(\W)/\\$1/g;
2402 $srcdir_rx = $srcdir_name . '/';
2403 # Don't append a spurious "." to the regex.
2404 $srcdir_rx .= $top_builddir
2405 unless $top_builddir eq '.';
2406 $srcdir_rx =~ s/(\W)/\\$1/g;
2409 local ($rewrite_builddir) = (($top_builddir eq '.')
2411 : $top_builddir . '/');
2417 # If LAST_LINE set then we've already seen what we thought
2418 # was the last line.
2421 next if (/$WHITE_PATTERN/o);
2425 # No trailing "\" means this should be the last line.
2431 if (! /^([^:]+:)(.+)$/)
2434 &am_error ("\`$depfile' has incorrect format");
2445 foreach $one_dep (split (' ', $_))
2447 if ($one_dep =~ /^$fixup_rx/)
2449 # The dependency points to the current directory in
2451 ($xform = $one_dep) =~ s/^$fixup_rx//;
2452 push (@dependencies, $xform);
2454 elsif ($one_dep =~ /^$srcdir_rx/)
2456 # The dependency is in some other directory in the package.
2457 ($xform = $one_dep) =~ s/^$srcdir_rx/$rewrite_builddir/;
2458 push (@dependencies, $xform);
2460 elsif ($one_dep =~ /^\//)
2462 # Absolute path; ignore.
2466 # Anything else is assumed to be correct. But first
2467 # make sure it is not on our list of dependencies to
2469 ($just_file = $one_dep) =~ s,^.*/,,;
2470 push (@dependencies, $one_dep)
2471 if ! defined $omit{$just_file};
2476 &pretty_print_rule ($target, "\t", @dependencies);
2481 # Handle auto-dependency code.
2482 sub handle_dependencies
2484 if ($use_dependencies)
2486 # Include GNU-make-specific auto-dep code.
2487 if ($dir_holds_sources)
2489 &define_pretty_variable ('DEP_FILES', sort keys %dep_files);
2490 $output_rules .= &file_contents ('depend');
2491 push (@clean, 'depend');
2492 &push_phony_cleaners ('depend');
2494 &file_contents_with_transform ('s/\@EXT\@/.c/g;'
2495 . 's/\@MKDEP\@/MKDEP/g;'
2499 local ($need_cxx) = 0;
2500 foreach $ext (sort keys %cxx_extensions)
2503 &file_contents_with_transform ('s/\@EXT\@/' . $ext .'/g;'
2504 . 's/\@MKDEP\@/CXXMKDEP/g;'
2511 &define_variable ('CXXMKDEP', '$(CXX) -M $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CXXFLAGS)');
2515 elsif ($build_directory ne '')
2517 # Include any auto-generated deps that are present. Note that
2518 # $build_directory ends in a "/".
2519 if (-d ($build_directory . $relative_dir . "/.deps")
2520 && -f ($build_directory . $relative_dir . "/.deps/.P"))
2524 foreach $depfile (&my_glob ($build_directory
2525 . $relative_dir . "/.deps/*.P"))
2527 &scan_dependency_file ($depfile);
2530 $output_rules .= "\n";
2535 # Handle subdirectories.
2538 return if ! &variable_defined ('SUBDIRS');
2540 # Make sure each directory mentioned in SUBDIRS actually exists.
2542 foreach $dir (&variable_value_as_list ('SUBDIRS'))
2544 # Skip directories substituted by configure.
2545 next if $dir =~ /^\@.*\@$/;
2547 if (! -d $am_relative_dir . '/' . $dir)
2549 &am_line_error ('SUBDIRS',
2550 "required directory $am_relative_dir/$dir does not exist");
2554 &am_relative_dir ('SUBDIRS',
2555 "directory should not contain \`/'")
2559 local ($xform) = ('s/\@INSTALLINFO\@/' .
2560 (defined $options{'no-installinfo'}
2561 ? 'install-info-recursive'
2564 $output_rules .= &file_contents_with_transform ($xform, 'subdirs');
2566 # Push a bunch of phony targets.
2568 foreach $phonies ('-data', '-exec', 'dirs')
2570 push (@phony, 'install' . $phonies . '-recursive');
2571 push (@phony, 'uninstall' . $phonies . '-recursive');
2573 foreach $phonies ('all', 'check', 'installcheck', 'info', 'dvi')
2575 push (@phony, $phonies . '-recursive');
2577 &push_phony_cleaners ('recursive');
2579 push (@check_tests, "check-recursive");
2580 push (@installcheck, "installcheck-recursive");
2581 push (@info, "info-recursive");
2582 push (@dvi, "dvi-recursive");
2584 $recursive_install = 1;
2587 # Handle aclocal.m4.
2588 sub handle_aclocal_m4
2590 local ($regen_aclocal) = 0;
2591 if (-f 'aclocal.m4')
2593 &define_variable ("ACLOCAL_M4", '$(top_srcdir)/aclocal.m4');
2594 &push_dist_common ('aclocal.m4');
2596 if (open (ACLOCAL, '< aclocal.m4'))
2602 if ($line =~ 'generated automatically by aclocal')
2609 local ($acinclude) = 0;
2610 if (-f 'acinclude.m4')
2616 # Note that it might be possible that aclocal.m4 doesn't exist but
2617 # should be auto-generated. This case probably isn't very
2621 local (@ac_deps) = (
2622 ($seen_maint_mode ? "\@MAINT\@" : "") ,
2624 ($acinclude ? ' acinclude.m4' : '')
2627 # Scan all -I directories for m4 files. These are our
2629 if (&variable_defined ('ACLOCAL_AMFLAGS'))
2632 foreach $amdir (&variable_value_as_list ('ACLOCAL_AMFLAGS'))
2634 if ($amdir =~ s/^-I//
2638 push (@ac_deps, &my_glob ($am_dir . '/*.m4'));
2643 &pretty_print_rule ("\$(srcdir)/aclocal.m4:", "\t\t", @ac_deps);
2645 $output_rules .= ("\t"
2646 . 'cd $(srcdir) && $(ACLOCAL)'
2647 . (&variable_defined ('ACLOCAL_AMFLAGS')
2648 ? ' $(ACLOCAL_AMFLAGS)' : '')
2653 # Rewrite a list of input files into a form suitable to put on a
2654 # dependency list. The idea is that if an input file has a directory
2655 # part the same as the current directory, then the directory part is
2656 # simply removed. But if the directory part is different, then
2657 # $(top_srcdir) is prepended. Among other things, this is used to
2658 # generate the dependency list for the output files generated by
2659 # AC_OUTPUT. Consider what the dependencies should look like in this
2661 # AC_OUTPUT(src/out:src/in1:lib/in2)
2662 sub rewrite_inputs_into_dependencies
2664 local (@inputs) = @_;
2665 local ($single, @newinputs);
2667 foreach $single (@inputs)
2669 if (&dirname ($single) eq $relative_dir)
2671 push (@newinputs, &basename ($single));
2675 push (@newinputs, '$(top_srcdir)/' . $single);
2682 # Handle remaking and configure stuff.
2683 # We need the name of the input file, to do proper remaking rules.
2684 sub handle_configure
2686 local ($local, $input, @secondary_inputs) = @_;
2688 # If SUBDIRS defined, require AC_PROG_MAKE_SET.
2689 &am_line_error ('SUBDIRS', "AC_PROG_MAKE_SET must be used in configure.in")
2690 if &variable_defined ('SUBDIRS') && ! $seen_make_set;
2692 local ($top_reldir);
2694 local ($input_base) = &basename ($input);
2695 local ($local_base) = &basename ($local);
2697 local ($amfile) = $input_base . '.am';
2698 # We know we can always add '.in' because it really should be an
2699 # error if the .in was missing originally.
2700 local ($infile) = '$(srcdir)/' . $input_base . '.in';
2701 local ($colon_infile);
2702 if ($local ne $input)
2704 $colon_infile = ':' . $input . '.in';
2706 $colon_infile .= ':' . join (':', @secondary_inputs)
2707 if @secondary_inputs;
2709 local (@rewritten) = &rewrite_inputs_into_dependencies (@secondary_inputs);
2710 # This rule remakes the Makefile.in. Note use of @MAINT@ forces
2711 # us to abandon pretty-printing. Sigh.
2712 $output_rules .= ($infile
2713 # NOTE perl 5.003 (with -w) gives a
2714 # uninitialized value error on the next line.
2717 . ($seen_maint_mode ? '@MAINT@ ' : '')
2719 . '$(top_srcdir)/configure.in $(ACLOCAL_M4) '
2720 . join (' ', @rewritten) . "\n"
2721 . "\tcd \$(top_srcdir) && \$(AUTOMAKE) "
2722 . ($cygnus_mode ? '--cygnus' : ('--' . $strictness_name))
2723 . ' ' . $input . $colon_infile . "\n\n");
2725 # This rule remakes the Makefile.
2726 $output_rules .= ($local_base
2727 # NOTE: bogus uninit value error on next line;
2728 # see comment above.
2731 . '$(top_builddir)/config.status $(BUILT_SOURCES)'
2733 . "\tcd \$(top_builddir) \\\n"
2734 . "\t && CONFIG_FILES="
2735 . (($relative_dir eq '.') ? '$@' : '$(subdir)/$@')
2737 . ' CONFIG_HEADERS= $(SHELL) ./config.status'
2740 if ($relative_dir ne '.')
2743 $top_reldir = '../';
2748 $output_rules .= &file_contents ('remake');
2749 &examine_variable ('CONFIGURE_DEPENDENCIES');
2753 # If we have a configure header, require it.
2754 if ($config_header && $relative_dir eq &dirname ($config_header))
2756 local ($ch_sans_dir) = &basename ($config_header);
2757 local ($cn_sans_dir) = &basename ($config_name);
2759 &require_file_with_conf_line ($config_header_line,
2760 $FOREIGN, $ch_sans_dir);
2762 # Header defined and in this directory.
2764 if (-f $relative_dir . '/acconfig.h')
2766 push (@files, 'acconfig.h');
2768 if (-f $config_name . '.top')
2770 push (@files, "${cn_sans_dir}.top");
2772 if (-f $config_name . '.bot')
2774 push (@files, "${cn_sans_dir}.bot");
2777 &push_dist_common (@files);
2778 $output_rules .= &file_contents_with_transform ('s/\@FILES\@/'
2779 . join (' ', @files)
2783 &touch ($relative_dir . '/stamp-h.in');
2784 &require_file_with_conf_line ($config_header_line, $FOREIGN,
2787 push (@clean, 'hdr');
2788 &push_phony_cleaners ('hdr');
2789 &define_variable ("CONFIG_HEADER_IN", "${ch_sans_dir}");
2790 &define_variable ('CONFIG_HEADER_FULL', $config_name);
2793 # Set location of mkinstalldirs.
2794 if ($config_aux_dir ne '.' && $config_aux_dir ne '')
2796 &define_variable ('mkinstalldirs', ('$(SHELL) ' . $config_aux_dir
2797 . '/mkinstalldirs'));
2801 &define_variable ('mkinstalldirs',
2802 '$(SHELL) $(top_srcdir)/mkinstalldirs');
2805 &am_line_error ('CONFIG_HEADER',
2806 "\`CONFIG_HEADER' is an anachronism; now determined from \`configure.in'")
2807 if &variable_defined ('CONFIG_HEADER');
2811 # Generate CONFIG_HEADER define.
2812 if ($relative_dir eq &dirname ($config_name))
2814 &define_variable ("CONFIG_HEADER", &basename ($config_name));
2818 &define_variable ("CONFIG_HEADER",
2819 "${top_builddir}/${config_name}");
2823 # Now look for other files in this directory which must be remade
2824 # by config.status, and generate rules for them.
2825 local (@actual_other_files) = ();
2826 local ($file, $local);
2827 local (@inputs, @rewritten_inputs, $single);
2828 foreach $file (@other_input_files)
2830 if ($file =~ /^(.*):(.*)$/)
2832 # This is the ":" syntax of AC_OUTPUT.
2834 $local = &basename ($file);
2835 @inputs = split (':', $2);
2836 @rewritten_inputs = &rewrite_inputs_into_dependencies (@inputs);
2841 $local = &basename ($file);
2842 @inputs = ($local . '.in');
2844 &rewrite_inputs_into_dependencies ($file . '.in');
2847 # Skip files not in this directory.
2848 next unless &dirname ($file) eq $relative_dir;
2850 # Skip the config header.
2851 next if $local eq $top_builddir . '/' . $config_name;
2853 # Skip any Makefile.
2854 next if $local eq 'Makefile';
2856 $output_rules .= ($local . ': '
2857 . '$(top_builddir)/config.status '
2858 . join (' ', @rewritten_inputs) . "\n"
2860 . 'cd $(top_builddir) && CONFIG_FILES='
2861 . ($relative_dir eq '.' ? '' : '$(subdir)/')
2862 . '$@' . (length (@rewritten_inputs) > 1
2863 ? (':' . join (':', @rewritten_inputs))
2865 . ' CONFIG_HEADERS= ./config.status'
2867 push (@actual_other_files, $local);
2869 # Require all input files.
2870 &require_file_with_conf_line ($ac_output_line, $FOREIGN,
2874 # These files get removed by "make clean".
2875 &define_pretty_variable ('CONFIG_CLEAN_FILES', @actual_other_files);
2881 $dir_holds_headers = &am_install_var ('header', 'HEADERS', 'include',
2882 'oldinclude', 'pkginclude',
2888 return if ! $seen_gettext || $relative_dir ne '.';
2890 if (! &variable_defined ('SUBDIRS'))
2893 ("AM_GNU_GETTEXT in configure.in but SUBDIRS not defined");
2897 &require_file_with_conf_line ($ac_gettext_line, $FOREIGN, 'ABOUT-NLS')
2900 if (&variable_defined ('SUBDIRS'))
2904 "AM_GNU_GETTEXT in configure.in but \`po' not in SUBDIRS")
2905 if $contents{'SUBDIRS'} !~ /\bpo\b/;
2908 "AM_GNU_GETTEXT in configure.in but \`intl' not in SUBDIRS")
2909 if $contents{'SUBDIRS'} !~ /\bintl\b/;
2912 # Ensure that each language in ALL_LINGUAS has a .po file, and
2913 # each po file is mentioned in ALL_LINGUAS.
2916 local (%linguas) = ();
2917 grep ($linguas{$_} = 1, split (' ', $all_linguas));
2924 &am_line_error ($all_linguas_line,
2925 ("po/$_.po exists but \`$_' not in \`ALL_LINGUAS'"))
2929 foreach (keys %linguas)
2931 &am_line_error ($all_linguas_line,
2932 "$_ in \`ALL_LINGUAS' but po/$_.po does not exist")
2938 &am_error ("AM_GNU_GETTEXT in configure.in but \`ALL_LINGUAS' not defined");
2942 # Handle footer elements.
2945 if ($contents{'SOURCES'})
2947 # NOTE don't use define_pretty_variable here, because
2948 # $contents{...} is already defined.
2949 $output_vars .= 'SOURCES = ' . $contents{'SOURCES'} . "\n";
2951 if ($contents{'OBJECTS'})
2953 # NOTE don't use define_pretty_variable here, because
2954 # $contents{...} is already defined.
2955 $output_vars .= 'OBJECTS = ' . $contents{'OBJECTS'} . "\n";
2957 if ($contents{'SOURCES'} || $contents{'OBJECTS'})
2959 $output_vars .= "\n";
2962 if (&variable_defined ('SUFFIXES'))
2964 # Push actual suffixes, and not $(SUFFIXES). Some versions of
2965 # make do not like variable substitutions on the .SUFFIXES
2967 push (@suffixes, &variable_value_as_list ('SUFFIXES'));
2969 if (&target_defined ('.SUFFIXES'))
2971 &am_line_error ('.SUFFIXES',
2972 "use variable \`SUFFIXES', not target \`.SUFFIXES'");
2975 # Note: AIX 4.1 /bin/make will fail if any suffix rule appears
2976 # before .SUFFIXES. So we make sure that .SUFFIXES appears before
2977 # anything else, by sticking it right after the default: target.
2978 $output_header .= ".SUFFIXES:\n";
2981 $output_header .= ".SUFFIXES: " . join (' ', @suffixes) . "\n";
2983 $output_trailer .= &file_contents ('footer');
2986 # Deal with installdirs target.
2987 sub handle_installdirs
2989 # GNU Makefile standards recommend this.
2990 $output_rules .= ("installdirs:"
2991 . ($recursive_install
2992 ? " installdirs-recursive\n"
2994 push (@phony, 'installdirs');
2997 &pretty_print_rule ("\t" . '$(mkinstalldirs) ', "\t\t",
3000 $output_rules .= "\n";
3003 # There are several targets which need to be merged. This is because
3004 # their complete definition is compiled from many parts. Note that we
3005 # avoid double colon rules, otherwise we'd use them instead.
3006 sub handle_merge_targets
3008 # There are a few install-related variables that you should not define.
3010 foreach $var ('PRE_INSTALL', 'POST_INSTALL', 'NORMAL_INSTALL')
3012 if (&variable_defined ($var))
3014 &am_line_error ($var, "\`$var' should not be defined");
3018 push (@all, 'Makefile');
3019 push (@all, &basename ($config_name))
3020 if $config_name && &dirname ($config_name) eq $relative_dir;
3022 &do_one_merge_target ('info', @info);
3023 &do_one_merge_target ('dvi', @dvi);
3024 &do_check_merge_target;
3025 &do_one_merge_target ('installcheck', @installcheck);
3027 if (defined $options{'no-installinfo'})
3029 # FIXME: this is kind of a hack; should find another way to
3030 # know that this is required.
3032 if (grep ($_ eq 'install-info-am', @phony))
3034 push (@dirs, 'install-info-am');
3036 if (&variable_defined ('SUBDIRS'))
3038 push (@dirs, 'install-info-recursive');
3040 &do_one_merge_target ('install-info', @dirs);
3043 # Handle the various install targets specially. We do this so
3044 # that (eg) "make install-exec" will run "install-exec-recursive"
3045 # if required, but "make install" won't run it twice. Step one is
3046 # to see if the user specified local versions of any of the
3047 # targets we handle. "all" is treated as one of these since
3048 # "install" can run it.
3049 push (@install_exec, 'install-exec-local')
3050 if defined $contents{'install-exec-local'};
3051 push (@install_data, 'install-data-local')
3052 if defined $contents{'install-data-local'};
3053 push (@uninstall, 'uninstall-local')
3054 if defined $contents{'uninstall-local'};
3056 foreach $utarg ('uninstall-data-local', 'uninstall-data-hook',
3057 'uninstall-exec-local', 'uninstall-exec-hook')
3059 if (defined $contents{$utarg})
3062 ($x = $utarg) =~ s/(data|exec)-//;
3063 &am_line_error ($utarg, "use \`$x', not \`$utarg'");
3066 push (@all, 'all-local')
3067 if defined $contents{'all-local'};
3069 if (defined $contents{'install-local'})
3071 &am_line_error ('install-local',
3072 "use \`install-data' or \`install-exec', not \`install'");
3075 # Step two: if we are doing recursive makes, write out the
3076 # appropriate rules.
3078 if ($recursive_install)
3080 push (@install, 'install-recursive');
3084 local (@hackall) = ();
3085 if ($config_name && &dirname ($config_name) eq $relative_dir)
3088 # This is kind of a hack, but I couldn't see a better
3089 # way to handle it. In this particular case, we need
3090 # to make sure config.h is built before we recurse.
3091 # We can't do this by changing the order of
3092 # dependencies to the "all" because that breaks when
3093 # using parallel makes. Instead we handle things
3095 $output_rules .= ('all-recursive-am: $(CONFIG_HEADER)'
3096 . "\n\t" . '$(MAKE) all-recursive'
3098 push (@hackall, 'all-recursive-am');
3099 push (@phony, 'all-recursive-am');
3103 push (@hackall, 'all-recursive');
3106 $output_rules .= ('all-am: '
3110 push (@all, 'all-am');
3111 push (@phony, 'all-am');
3115 @all = ('all-recursive');
3117 # Must always generate `all-am' target, so it can be
3118 # referred to elsewhere.
3119 $output_rules .= "all-am:\n";
3123 $output_rules .= ('install-exec-am: '
3124 . join (' ', @install_exec)
3126 @install_exec = ('install-exec-recursive', 'install-exec-am');
3127 push (@install, 'install-exec-am');
3128 push (@phony, 'install-exec-am');
3132 @install_exec = ('install-exec-recursive');
3136 $output_rules .= ('install-data-am: '
3137 . join (' ', @install_data)
3139 @install_data = ('install-data-recursive', 'install-data-am');
3140 push (@install, 'install-data-am');
3141 push (@phony, 'install-data-am');
3145 @install_data = ('install-data-recursive');
3149 $output_rules .= ('uninstall-am: '
3150 . join (' ', @uninstall)
3152 @uninstall = ('uninstall-recursive', 'uninstall-am');
3153 push (@phony, 'uninstall-am');
3157 @uninstall = ('uninstall-recursive');
3161 # Step three: print definitions users can use. Code below knows
3162 # that install-exec is done before install-data, beware.
3163 $output_rules .= ("install-exec: "
3164 . join (' ', @install_exec)
3166 $output_rules .= "\t\$(NORMAL_INSTALL)\n";
3167 if (defined $contents{'install-exec-hook'})
3169 $output_rules .= "\t" . '$(MAKE) install-exec-hook' . "\n";
3171 $output_rules .= "\n";
3172 push (@install, 'install-exec') if !$recursive_install;
3173 push (@phony, 'install-exec');
3175 $output_rules .= ("install-data: "
3176 . join (' ', @install_data)
3178 $output_rules .= "\t\$(NORMAL_INSTALL)\n";
3179 if (defined $contents{'install-data-hook'})
3181 $output_rules .= "\t" . '$(MAKE) install-data-hook' . "\n";
3183 $output_rules .= "\n";
3184 push (@install, 'install-data') if !$recursive_install;
3185 push (@phony, 'install-data');
3187 # If no dependencies for 'install', add 'all'. Why? That way
3188 # "make install" at top level of distclean'd distribution won't
3189 # fail because stuff in 'lib' fails to build.
3190 if (! @install || (scalar (@install) == 2
3191 && $install[0] eq 'install-exec'
3192 && $install[1] eq 'install-data'))
3194 push (@install, 'all');
3196 $output_rules .= ('install: '
3197 . join (' ', @install)
3198 # Use "@:" as empty command so nothing prints.
3202 . join (' ', @uninstall)
3204 push (@phony, 'install', 'uninstall');
3206 $output_rules .= ('all: '
3209 push (@phony, 'all');
3211 # Generate the new 'install-strip' target.
3212 $output_rules .= ("install-strip:\n\t"
3213 . '$(MAKE) INSTALL_PROGRAM=\'$(INSTALL_PROGRAM) -s\' install'
3217 # Helper for handle_merge_targets.
3218 sub do_one_merge_target
3220 local ($name, @values) = @_;
3222 if (defined $contents{$name . '-local'})
3224 # User defined local form of target. So include it.
3225 push (@values, $name . '-local');
3226 push (@phony, $name . '-local');
3229 &pretty_print_rule ($name . ":", "\t\t", @values);
3230 push (@phony, $name);
3233 # Handle check merge target specially.
3234 sub do_check_merge_target
3236 if (defined $contents{'check-local'})
3238 # User defined local form of target. So include it.
3239 push (@check_tests, 'check-local');
3240 push (@phony, 'check-local');
3243 if (! &variable_defined ('SUBDIRS'))
3245 # 'check' must depend on `all', but not when doing recursive
3247 unshift (@check, 'all');
3251 # When subdirs are used, do the `all' build and then do all
3252 # the recursive stuff. Actually use `all-am' because it
3253 # doesn't recurse; we rely on the check target in the subdirs
3254 # to do the required builds there.
3255 unshift (@check, 'all-am');
3258 # The check target must depend on the local equivalent of `all',
3259 # to ensure all the primary targets are built. Also it must
3260 # depend on the test code named in @check.
3261 &pretty_print_rule ('check:', "\t\t", @check);
3263 # Now the check rules must explicitly run anything named in
3264 # @check_tests. This is done via a separate make invocation to
3265 # avoid problems with parallel makes. Every time I write code
3266 # like this I wonder: how could you invent a parallel make and not
3267 # provide any real synchronization facilities?
3268 &pretty_print_rule ("\t\$(MAKE)", "\t ", @check_tests);
3271 # Handle all 'clean' targets.
3274 push (@clean, 'generic');
3275 $output_rules .= &file_contents ('clean');
3276 &push_phony_cleaners ('generic');
3278 local ($target) = $recursive_install ? 'clean-am' : 'clean';
3279 &do_one_clean_target ($target, 'mostly', '', @clean);
3280 &do_one_clean_target ($target, '', 'mostly', @clean);
3281 &do_one_clean_target ($target, 'dist', '', @clean);
3282 &do_one_clean_target ($target, 'maintainer-', 'dist', @clean);
3284 push (@phony, 'clean', 'mostlyclean', 'distclean', 'maintainer-clean');
3287 if ($recursive_install)
3289 # Do -recursive before -am. If you aren't doing a parallel
3290 # make, this can be nicer.
3291 @deps = ('recursive', 'am');
3292 &do_one_clean_target ('', 'mostly', '', @deps);
3293 &do_one_clean_target ('', '', '', @deps);
3294 &do_one_clean_target ('', 'dist', '', @deps);
3295 &do_one_clean_target ('', 'maintainer-', '', @deps);
3299 # Helper for handle_clean.
3300 sub do_one_clean_target
3302 local ($target, $name, $last_name, @deps) = @_;
3304 # Special case: if target not passed, then don't generate
3305 # dependency on next "lower" clean target (eg no
3306 # clean<-mostlyclean derivation). In this case the target is
3307 # implicitly known to be 'clean'.
3308 local ($flag) = $target;
3309 $target = 'clean' if ! $flag;
3311 grep (($_ = $name . 'clean-' . $_) && 0, @deps);
3314 if ($last_name || $name ne 'mostly')
3316 push (@deps, $last_name . $target);
3320 # If a -local version of the rule is given, add it to the list.
3321 if (defined $contents{$name . $target . '-local'})
3323 push (@deps, $name . $target . '-local');
3326 # Print the target and the dependencies.
3327 &pretty_print_rule ($name . $target . ": ", "\t\t", @deps);
3329 # FIXME: shouldn't we really print these messages before running
3331 if ($name . $target eq 'maintainer-clean')
3333 # Print a special warning.
3335 ("\t\@echo \"This command is intended for maintainers to use;\"\n"
3336 . "\t\@echo \"it deletes files that may require special "
3337 . "tools to rebuild.\"\n");
3339 $output_rules .= "\trm -f config.status\n"
3340 if $relative_dir eq '.';
3342 elsif ($name . $target eq 'distclean')
3344 $output_rules .= "\trm -f config.status\n";
3345 $output_rules .= "\trm -f libtool\n" if $seen_libtool;
3347 $output_rules .= "\n";
3350 # Handle .PHONY target.
3353 &pretty_print_rule ('.PHONY:', "", @phony);
3354 $output_rules .= "\n";
3357 # Handle TESTS variable and other checks.
3360 if (defined $options{'dejagnu'})
3362 push (@check_tests, 'check-DEJAGNU');
3363 push (@phony, 'check-DEJAGNU');
3368 $xform = 's/^CYGNUS//;';
3372 $xform = 's/^CYGNUS.*$//;';
3374 $output_rules .= &file_contents_with_transform ($xform, 'dejagnu');
3376 # In Cygnus mode, these are found in the build tree.
3377 # Otherwise they are looked for in $PATH.
3378 &define_program_variable ('EXPECT', 'build', 'expect', 'expect');
3379 &define_program_variable ('RUNTEST', 'src', 'dejagnu', 'runtest');
3381 # Note that in the rule we don't directly generate site.exp to
3382 # avoid the possibility of a corrupted site.exp if make is
3383 # interrupted. Jim Meyering has some useful text on this
3385 $output_rules .= ("site.exp: Makefile\n"
3386 . "\t\@echo 'Making a new site.exp file...'\n"
3387 . "\t-\@rm -f site.bak\n"
3388 . "\t\@echo '## these variables are automatically generated by make ##' > \$\@-t\n"
3389 . "\t\@echo '# Do not edit here. If you wish to override these values' >> \$\@-t\n"
3390 . "\t\@echo '# edit the last section' >> \$\@-t\n"
3391 . "\t\@echo 'set tool \$(DEJATOOL)' >> \$\@-t\n"
3392 . "\t\@echo 'set srcdir \$(srcdir)' >> \$\@-t\n"
3393 . "\t\@echo 'set objdir' \`pwd\` >> \$\@-t\n");
3395 # Extra stuff for AC_CANONICAL_*
3396 local (@whatlist) = ();
3397 if ($seen_canonical)
3399 push (@whatlist, 'host')
3402 # Extra stuff only for AC_CANONICAL_SYSTEM.
3403 if ($seen_canonical == $AC_CANONICAL_SYSTEM)
3405 push (@whatlist, 'target', 'build');
3409 foreach $c1 (@whatlist)
3411 foreach $c2 ('alias', 'triplet')
3413 $output_rules .= "\t\@echo 'set ${c1}_${c2} \$(${c1}_${c2})' >> \$\@-t\n";
3417 $output_rules .= ("\t\@echo '## All variables above are generated by configure. Do Not Edit ##' >> \$\@-t\n"
3418 . "\t-\@sed '1,/^## All variables above are.*##/ d' site.bak >> \$\@-t\n"
3419 . "\t-\@mv site.exp site.bak\n"
3420 . "\t\@mv \$\@-t site.exp\n");
3425 foreach $c ('DEJATOOL', 'RUNTEST', 'RUNTESTFLAGS')
3427 if (&variable_defined ($c))
3429 &am_line_error ($c, "\`$c' defined but \`dejagnu' not in \`AUTOMAKE_OPTIONS'");
3434 if (&variable_defined ('TESTS'))
3436 push (@check_tests, 'check-TESTS');
3437 push (@phony, 'check-TESTS');
3439 $output_rules .= 'check-TESTS: $(TESTS)
3440 @failed=0; all=0; \\
3441 srcdir=$(srcdir); export srcdir; \\
3442 for tst in $(TESTS); do \\
3443 all=`expr $$all + 1`; \\
3444 if test -f $$tst; then dir=.; \\
3445 else dir="$(srcdir)"; fi; \\
3446 if $(TESTS_ENVIRONMENT) $$dir/$$tst; then \\
3447 echo "PASS: $$tst"; \\
3449 failed=`expr $$failed + 1`; \\
3450 echo "FAIL: $$tst"; \\
3453 if test "$$failed" -eq 0; then \\
3454 echo "========================"; \\
3455 echo "All $$all tests passed"; \\
3456 echo "========================"; \\
3458 echo "$$failed of $$all tests failed"; \\
3465 # Handle Emacs Lisp.
3466 sub handle_emacs_lisp
3468 local (@elfiles) = &am_install_var ('lisp', 'LISP', 'lisp', 'noinst');
3473 &define_configure_variable ('lispdir');
3474 &define_configure_variable ('EMACS');
3475 $output_rules .= (".el.elc:\n"
3476 . "\t\@echo 'WARNING: Warnings can be ignored. :-)'\n"
3477 . "\tif test \$(EMACS) != no; then \\\n"
3478 . "\t EMACS=\$(EMACS) \$(SHELL) \$(srcdir)/elisp-comp \$<; \\\n"
3480 push (@suffixes, '.el', '.elc');
3482 # Generate .elc files.
3483 grep ($_ .= 'c', @elfiles);
3484 &define_pretty_variable ('ELCFILES', @elfiles);
3486 push (@clean, 'lisp');
3487 &push_phony_cleaners ('lisp');
3489 push (@all, '$(ELCFILES)');
3492 if (&variable_defined ('lisp_LISP'))
3494 $varname = 'lisp_LISP';
3495 &am_error ("\`lisp_LISP' defined but \`AM_PATH_LISPDIR' not in \`configure.in'")
3500 $varname = 'noinst_LISP';
3503 &require_file_with_line ($varname, $FOREIGN, 'elisp-comp');
3507 ################################################################
3509 # Scan one file for interesting things. Subroutine of scan_configure.
3510 sub scan_one_configure_file
3512 local ($filename) = @_;
3514 open (CONFIGURE, $filename)
3515 || die "automake: couldn't open \`$filename': $!\n";
3516 print "automake: reading $filename\n" if $verbose;
3520 # Remove comments from current line.
3524 # Skip macro definitions. Otherwise we might be confused into
3525 # thinking that a macro that was only defined was actually
3529 # Populate libobjs array.
3530 if (/AC_FUNC_ALLOCA/)
3532 $libsources{'alloca.c'} = 1;
3534 elsif (/AC_FUNC_GETLOADAVG/)
3536 $libsources{'getloadavg.c'} = 1;
3538 elsif (/AC_FUNC_MEMCMP/)
3540 $libsources{'memcmp.c'} = 1;
3542 elsif (/AC_STRUCT_ST_BLOCKS/)
3544 $libsources{'fileblocks.c'} = 1;
3546 elsif (/A[CM]_REPLACE_GNU_GETOPT/)
3548 $libsources{'getopt.c'} = 1;
3549 $libsources{'getopt1.c'} = 1;
3551 elsif (/AM_FUNC_STRTOD/)
3553 $libsources{'strtod.c'} = 1;
3555 elsif (/AM_WITH_REGEX/)
3557 $libsources{'rx.c'} = 1;
3558 $libsources{'rx.h'} = 1;
3559 $libsources{'regex.c'} = 1;
3560 $libsources{'regex.h'} = 1;
3561 $omit_dependencies{'rx.h'} = 1;
3562 $omit_dependencies{'regex.h'} = 1;
3564 elsif (/AM_FUNC_MKTIME/)
3566 $libsources{'mktime.c'} = 1;
3568 elsif (/AM_FUNC_ERROR_AT_LINE/)
3570 $libsources{'error.c'} = 1;
3571 $libsources{'error.h'} = 1;
3573 elsif (/AM_FUNC_OBSTACK/)
3575 $libsources{'obstack.c'} = 1;
3576 $libsources{'obstack.h'} = 1;
3578 elsif (/LIBOBJS="(.*)\s+\$LIBOBJS"/
3579 || /LIBOBJS="\$LIBOBJS\s+(.*)"/)
3581 foreach $libobj_iter (split (' ', $1))
3583 if ($libobj_iter =~ /^(.*)\.o$/)
3585 $libsources{$1 . '.c'} = 1;
3590 if (! $in_ac_replace && s/AC_REPLACE_FUNCS\s*\(\[?//)
3596 $in_ac_replace = 0 if s/[\]\)].*$//;
3597 # Remove trailing backslash.
3601 # Need to skip empty elements for Perl 4.
3603 $libsources{$_ . '.c'} = 1;
3607 if (/$obsolete_rx/o)
3610 if ($obsolete_macros{$1})
3612 $hint = '; ' . $obsolete_macros{$1};
3614 &am_conf_line_error ($filename, $., "\`$1' is obsolete$hint");
3617 # Process the AC_OUTPUT macro.
3618 if (! $in_ac_output && s/AC_OUTPUT\s*\(\[?//)
3621 $ac_output_line = $.;
3625 $in_ac_output = 0 if s/[\]\),].*$//;
3627 # Look at potential Makefile.am's.
3632 # Handle $local:$input syntax. Note that we ignore
3633 # every input file past the first, though we keep
3634 # those around for later.
3635 local ($local, $input, @rest) = split (/:/);
3642 # FIXME: should be error if .in is missing.
3643 $input =~ s/\.in$//;
3646 if (-f $input . '.am')
3648 # We have a file that automake should generate.
3649 push (@make_input_list, $input);
3650 $make_list{$input} = join (':', ($local, @rest));
3654 # We have a file that automake should cause to be
3655 # rebuilt, but shouldn't generate itself.
3656 push (@other_input_files, $_);
3661 if (/$AC_CONFIG_AUX_DIR_PATTERN/o)
3663 @config_aux_path = $1;
3666 # Check for ansi2knr.
3667 $am_c_prototypes = 1 if /AM_C_PROTOTYPES/;
3669 # Check for Cygwin32.
3673 $configure_vars{'EXEEXT'} = 1;
3676 # Check for NLS support.
3677 if (/AM_GNU_GETTEXT/)
3680 $ac_gettext_line = $.;
3681 $omit_dependencies{'libintl.h'} = 1;
3684 # Look for ALL_LINGUAS.
3685 if (/ALL_LINGUAS="(.*)"$/ || /ALL_LINGUAS=(.*)$/)
3689 $all_linguas_line = $.;
3692 # Handle configuration headers. A config header of `[$1]'
3693 # means we are actually scanning AM_CONFIG_HEADER from
3695 if (/A([CM])_CONFIG_HEADER\s*\((.*)\)/
3700 "\`AC_CONFIG_HEADER' is obsolete; use \`AM_CONFIG_HEADER'")
3703 $config_header_line = $.;
3705 if ($config_name =~ /^([^:]+):(.+)$/)
3708 $config_header = $2;
3712 $config_header = $config_name . '.in';
3716 # Handle AC_CANONICAL_*. Always allow upgrading to
3717 # AC_CANONICAL_SYSTEM, but never downgrading.
3718 $seen_canonical = $AC_CANONICAL_HOST
3719 if ! $seen_canonical
3720 && (/AC_CANONICAL_HOST/ || /AC_CHECK_TOOL/);
3721 $seen_canonical = $AC_CANONICAL_SYSTEM if /AC_CANONICAL_SYSTEM/;
3723 $seen_path_xtra = 1 if /AC_PATH_XTRA/;
3725 # This macro handles several different things.
3726 if (/$AM_INIT_AUTOMAKE_PATTERN/o)
3732 $seen_prog_install = 2;
3733 ($package_version = $1) =~ s/$AM_PACKAGE_VERSION_PATTERN/$1/o;
3734 $package_version_line = $.;
3737 # This is like AM_INIT_AUTOMAKE, but doesn't actually set the
3738 # package and version number. (This might change in the
3739 # future). Yes, I'm not above hacking Automake so it works
3740 # well with other GNU tools -- that is actually the point.
3741 if (/AM_INIT_GUILE_MODULE/)
3747 $seen_prog_install = 2;
3748 @config_aux_path = ('..');
3751 # Some things required by Automake.
3752 $seen_make_set = 1 if /AC_PROG_MAKE_SET/;
3753 $seen_arg_prog = 1 if /AC_ARG_PROGRAM/;
3755 if (/AC_PROG_(YACC|RANLIB|CC|CXX|LEX)/)
3757 $configure_vars{$1} = 1;
3759 if (/$AC_CHECK_PATTERN/o)
3761 $configure_vars{$3} = 1;
3764 # Explicitly avoid ANSI2KNR -- we AC_SUBST that in protos.m4,
3765 # but later define it elsewhere. This is pretty hacky.
3766 if (/$AC_SUBST_PATTERN/o && $1 ne 'ANSI2KNR')
3768 $configure_vars{$1} = 1;
3771 $seen_decl_yytext = 1 if /AC_DECL_YYTEXT/;
3772 $seen_maint_mode = 1 if /AM_MAINTAINER_MODE/;
3773 $seen_package = 1 if /PACKAGE=/;
3775 # Skip VERSION of [$2]; that is from AM_INIT_AUTOMAKE.
3776 if (/\bVERSION=(\S+)/ && $1 ne '[$2]')
3779 $package_version = $1;
3780 $package_version_line = $.;
3787 # Weird conditionals here because it is always allowed to
3788 # upgrade to AM_PROG_INSTALL but never to downgrade to
3790 $seen_prog_install = 1 if ! $seen_prog_install && /AC_PROG_INSTALL/;
3791 $seen_prog_install = 2 if /AM_PROG_INSTALL/;
3793 $seen_lispdir = 1 if /AM_PATH_LISPDIR/;
3795 if (/AM_PROG_LIBTOOL/)
3799 $configure_vars{'LIBTOOL'} = 1;
3800 $configure_vars{'RANLIB'} = 1;
3801 $configure_vars{'CC'} = 1;
3802 # AM_PROG_LIBTOOL runs AC_CANONICAL_HOST. Make sure we
3803 # never downgrade (if we've seen AC_CANONICAL_SYSTEM).
3804 $seen_canonical = $AC_CANONICAL_HOST if ! $seen_canonical;
3811 # Scan configure.in and aclocal.m4 for interesting things. We must
3812 # scan aclocal.m4 because there might be AC_SUBSTs and such there.
3815 # Reinitialize libsources here. This isn't really necessary,
3816 # since we currently assume there is only one configure.in. But
3817 # that won't always be the case.
3820 local ($in_ac_output, $in_ac_replace) = (0, 0);
3821 local (%make_list, @make_input_list);
3822 local ($libobj_iter);
3824 &scan_one_configure_file ('configure.in');
3825 &scan_one_configure_file ('aclocal.m4')
3828 # Set input and output files if not specified by user.
3831 @input_files = @make_input_list;
3832 %output_files = %make_list;
3835 &am_conf_error ("\`PACKAGE' not defined in configure.in")
3837 &am_conf_error ("\`VERSION' not defined in configure.in")
3840 # Look for some files we need. Always check for these. This
3841 # check must be done for every run, even those where we are only
3842 # looking at a subdir Makefile. We must set relative_dir so that
3843 # the file-finding machinery works.
3844 local ($relative_dir) = '.';
3845 &require_config_file ($FOREIGN, 'install-sh', 'mkinstalldirs', 'missing');
3846 &am_error ("\`install.sh' is an anachronism; use \`install-sh' instead")
3847 if -f $config_aux_path[0] . '/install.sh';
3850 ################################################################
3852 # Set up for Cygnus mode.
3855 return unless $cygnus_mode;
3857 &set_strictness ('foreign');
3858 $options{'no-installinfo'} = 1;
3859 $options{'no-dependencies'} = 1;
3860 $use_dependencies = 0;
3862 if (! $seen_maint_mode)
3864 &am_conf_error ("\`AM_MAINTAINER_MODE' required when --cygnus specified");
3867 if (! $seen_cygwin32)
3869 &am_conf_error ("\`AM_CYGWIN32' required when --cygnus specified");
3873 # Do any extra checking for GNU standards.
3874 sub check_gnu_standards
3876 if ($relative_dir eq '.')
3878 # In top level (or only) directory.
3879 &require_file ($GNU, 'INSTALL', 'NEWS', 'README', 'COPYING',
3880 'AUTHORS', 'ChangeLog');
3883 if ($strictness >= $GNU)
3885 if (defined $options{'no-installman'})
3887 &am_line_error ('AUTOMAKE_OPTIONS',
3888 "option \`no-installman' disallowed by GNU standards");
3891 if (defined $options{'no-installinfo'})
3893 &am_line_error ('AUTOMAKE_OPTIONS',
3894 "option \`no-installinfo' disallowed by GNU standards");
3899 # Do any extra checking for GNITS standards.
3900 sub check_gnits_standards
3902 if ($strictness >= $GNITS)
3904 if (-f $relative_dir . '/COPYING.LIB')
3906 &am_error ("\`${relative_dir}/COPYING.LIB' disallowed by Gnits standards");
3909 if ($relative_dir eq '.')
3911 if ($package_version !~ /^$GNITS_VERSION_PATTERN$/)
3913 # FIXME: allow real filename.
3914 &am_conf_line_error ('configure.in',
3915 $package_version_line,
3916 "version \`$package_version' doesn't follow Gnits standards");
3918 elsif (defined $1 && -f 'README-alpha')
3920 # This means we have an alpha release. See
3921 # GNITS_VERSION_PATTERN for details.
3922 &require_file ($GNITS, 'README-alpha');
3927 if ($relative_dir eq '.')
3929 # In top level (or only) directory.
3930 &require_file ($GNITS, 'THANKS');
3934 ################################################################
3936 # Pretty-print something. HEAD is what should be printed at the
3937 # beginning of the first line, FILL is what should be printed at the
3938 # beginning of every subsequent line.
3939 sub pretty_print_internal
3941 local ($head, $fill, @values) = @_;
3943 local ($column) = length ($head);
3944 local ($result) = $head;
3946 # Fill length is number of characters. However, each Tab
3947 # character counts for eight. So we count the number of Tabs and
3949 local ($fill_length) = length ($fill);
3950 $fill_length += 7 * ($fill =~ tr/\t/\t/d);
3952 local ($bol) = ($head eq '');
3955 # "71" because we also print a space.
3956 if ($column + length ($_) > 71)
3958 $result .= " \\\n" . $fill;
3959 $column = $fill_length;
3963 $result .= ' ' unless ($bol);
3965 $column += length ($_) + 1;
3973 # Pretty-print something and append to output_vars.
3976 $output_vars .= &pretty_print_internal (@_);
3979 # Pretty-print something and append to output_rules.
3980 sub pretty_print_rule
3982 $output_rules .= &pretty_print_internal (@_);
3986 ################################################################
3988 # See if a target exists.
3991 local ($target) = @_;
3992 return defined $targets{$target};
3995 # See if a variable exists.
3996 sub variable_defined
3999 if (defined $targets{$var})
4001 &am_line_error ($var, "\`$var' is target; expected variable");
4004 elsif (defined $contents{$var})
4006 $content_seen{$var} = 1;
4012 # Mark a variable as examined.
4013 sub examine_variable
4016 &variable_defined ($var);
4019 # Return contents of variable as list, split as whitespace. This will
4020 # recursively follow $(...) and ${...} inclusions. It preserves @...@
4021 # substitutions. If PARENT is specified, it is the name of the
4022 # including variable; this is only used for error reports.
4023 sub variable_value_as_list
4025 local ($var, $parent) = @_;
4028 if (defined $targets{$var})
4030 &am_line_error ($var, "\`$var' is target; expected variable");
4032 elsif (! defined $contents{$var})
4034 &am_line_error ($parent, "variable \`$var' not defined");
4039 $content_seen{$var} = 1;
4040 foreach (split (' ', $contents{$var}))
4042 # If a comment seen, just leave.
4045 # Handle variable substitutions.
4046 if (/^\$\{(.*)\}$/ || /^\$\((.*)\)$/)
4048 local ($varname) = $1;
4050 if ($varname =~ /^([^:]*):([^=]*)=(.*)$/)
4054 ($from = $2) =~ s/(\W)/\\$1/g;
4058 @temp_list = &variable_value_as_list ($1, $var);
4060 # Now rewrite the value if appropriate.
4063 grep (s/$from$/$to/, @temp_list);
4066 push (@result, @temp_list);
4078 # Define a new variable, but only if not already defined.
4081 local ($var, $value) = @_;
4083 if (! defined $contents{$var})
4085 $output_vars .= $var . ' = ' . $value . "\n";
4086 $contents{$var} = $value;
4087 $content_seen{$var} = 1;
4091 # Like define_variable, but second arg is a list, and is
4093 sub define_pretty_variable
4095 local ($var, @value) = @_;
4096 if (! defined $contents{$var})
4098 $contents{$var} = join (' ', @value);
4099 &pretty_print ($var . ' = ', '', @value);
4100 $content_seen{$var} = 1;
4104 # Like define_variable, but define a variable to be the configure
4105 # substitution by the same name.
4106 sub define_configure_variable
4109 local ($value) = '@' . $var . '@';
4110 &define_variable ($var, $value);
4113 # Define a variable that represents a program to run. If in Cygnus
4114 # mode, the program is searched for in the build (or source) tree.
4115 # Otherwise no searching is done at all. Arguments are:
4116 # * VAR Name of variable to define
4117 # * WHATDIR Either `src' or `build', depending on where program should
4118 # be found. (runtest is in srcdir!)
4119 # * SUBDIR Subdir of top-level dir
4120 # * PROGRAM Name of program
4121 sub define_program_variable
4123 local ($var, $whatdir, $subdir, $program) = @_;
4127 local ($full) = ('$(top_' . $whatdir . 'dir)/../'
4128 . $subdir . '/' . $program);
4129 &define_variable ($var, ('`if test -f ' . $full
4130 . '; then echo ' . $full . '; else echo '
4131 . $program . '; fi`'));
4135 &define_variable ($var, $program);
4140 ################################################################
4142 # Read Makefile.am and set up %contents. Simultaneously copy lines
4143 # from Makefile.am into $output_trailer or $output_vars as
4144 # appropriate. NOTE we put rules in the trailer section. We want
4145 # user rules to come after our generated stuff.
4148 local ($amfile) = @_;
4150 open (AM_FILE, $amfile) || die "automake: couldn't open \`$amfile': $!\n";
4151 print "automake: reading $amfile\n" if $verbose;
4153 $output_vars = ("# $in_file_name generated automatically by automake "
4154 . $VERSION . " from $am_file_name\n");
4156 # Generate copyright for generated Makefile.in.
4157 $output_vars .= $gen_copyright;
4159 local ($saw_bk) = 0;
4160 local ($was_rule) = 0;
4161 local ($spacing) = '';
4162 local ($comment) = '';
4163 local ($last_var_name) = '';
4168 if (/$IGNORE_PATTERN/o)
4170 # Merely delete comments beginning with two hashes.
4172 elsif (/$WHITE_PATTERN/o)
4174 # Stick a single white line before the incoming macro or rule.
4178 elsif (/$COMMENT_PATTERN/o)
4180 # Stick comments before the incoming macro or rule. Make
4181 # sure a blank line preceeds first block of comments.
4182 $spacing = "\n" unless $blank;
4184 $comment .= $spacing . $_;
4193 $output_vars .= $comment . "\n";
4196 local ($am_vars) = '';
4198 local ($is_ok_macro);
4202 unless substr ($_, -1, 1) eq "\n";
4204 $_ =~ s/\@MAINT\@//g
4205 unless $seen_maint_mode;
4207 if (/$IGNORE_PATTERN/o)
4209 # Merely delete comments beginning with two hashes.
4211 elsif (/$WHITE_PATTERN/o)
4213 # Stick a single white line before the incoming macro or rule.
4216 elsif (/$COMMENT_PATTERN/o)
4218 # Stick comments before the incoming macro or rule.
4219 $comment .= $spacing . $_;
4226 $output_trailer .= $_;
4233 # Chop newline and backslash if this line is
4234 # continued. FIXME: maybe ensure trailing whitespace
4238 $contents{$last_var_name} .= $_;
4241 elsif (/$RULE_PATTERN/o)
4243 # warn "** Saw rule .$1.\n";
4246 # Value here doesn't matter; for targets we only note
4250 $content_lines{$1} = $.;
4251 $output_trailer .= $comment . $spacing . $_;
4252 $comment = $spacing = '';
4255 elsif (($is_ok_macro = /$MACRO_PATTERN/o)
4256 || /$BOGUS_MACRO_PATTERN/o)
4258 # Found a macro definition.
4260 $last_var_name = $1;
4261 if ($2 ne '' && substr ($2, -1) eq "\\")
4263 $contents{$1} = substr ($2, 0, length ($2) - 1);
4269 $content_lines{$1} = $.;
4270 $am_vars .= $comment . $spacing . $_;
4271 $comment = $spacing = '';
4275 &am_line_error ($., "bad macro name \`$1'")
4280 # This isn't an error; it is probably a continued rule.
4281 # In fact, this is what we assume.
4283 $output_trailer .= $comment . $spacing . $_;
4284 $comment = $spacing = '';
4291 $output_trailer .= $comment;
4293 # Compute relative location of the top object directory.
4294 local (@topdir) = ();
4295 foreach (split (/\//, $relative_dir))
4297 next if $_ eq '.' || $_ eq '';
4304 push (@topdir, '..');
4307 @topdir = ('.') if ! @topdir;
4309 $top_builddir = join ('/', @topdir);
4311 ($build_rx = $top_builddir) =~ s/(\W)/\\$1/g;
4312 $output_vars .= &file_contents_with_transform
4313 ('s/\@top_builddir\@/' . $build_rx . '/g;',
4316 # Generate some useful variables when AC_CANONICAL_* used. FIXME:
4317 # this should use generic %configure_vars method.
4318 if ($seen_canonical)
4320 local ($curs, %vars);
4321 $vars{'host_alias'} = 'host_alias';
4322 $vars{'host_triplet'} = 'host';
4323 if ($seen_canonical == $AC_CANONICAL_SYSTEM)
4325 $vars{'build_alias'} = 'build_alias';
4326 $vars{'build_triplet'} = 'build';
4327 $vars{'target_alias'} = 'target_alias';
4328 $vars{'target_triplet'} = 'target';
4330 foreach $curs (sort keys %vars)
4332 $output_vars .= "$curs = \@$vars{$curs}\@\n";
4333 $contents{$curs} = "\@$vars{$curs}\@";
4338 foreach $curs (sort keys %configure_vars)
4340 &define_configure_variable ($curs);
4343 $output_vars .= $am_vars;
4346 ################################################################
4348 sub initialize_global_constants
4350 # Values for AC_CANONICAL_*
4351 $AC_CANONICAL_HOST = 1;
4352 $AC_CANONICAL_SYSTEM = 2;
4354 # Associative array of standard directory names. Entry is TRUE if
4355 # corresponding directory should be installed during
4356 # 'install-exec' phase.
4374 # Helper text for dealing with man pages.
4375 $install_man_format =
4376 ' @sect=@SECTION@; \\
4377 inst=`echo "@MANBASE@" | sed \'$(transform)\'`.@FULLSECT@; \\
4378 if test -f $(srcdir)/@MAN@; then file=$(srcdir)/@MAN@; \\
4379 else file=@MAN@; fi; \\
4380 echo " $(INSTALL_DATA) $$file $(mandir)/man$$sect/$$inst"; \\
4381 $(INSTALL_DATA) $$file $(mandir)/man$$sect/$$inst
4384 $uninstall_man_format =
4385 ' inst=`echo "@MANBASE@" | sed \'$(transform)\'`.@FULLSECT@; \\
4386 rm -f $(mandir)/man@SECTION@/$$inst
4389 # Commonly found files we look for and automatically include in
4393 "README", "THANKS", "TODO", "NEWS", "COPYING", "COPYING.LIB",
4394 "INSTALL", "ABOUT-NLS", "ChangeLog", "configure", "configure.in",
4395 "config.guess", "config.sub", "AUTHORS", "BACKLOG", "ABOUT-GNU",
4396 "libversion.in", "mdate-sh", "mkinstalldirs", "install-sh",
4397 'texinfo.tex', "ansi2knr.c", "ansi2knr.1", 'elisp-comp',
4398 'interlock', 'ylwrap', 'acinclude.m4', @libtoolize_files,
4402 # Commonly used files we auto-include, but only sometimes.
4405 "aclocal.m4", "acconfig.h", "config.h.top",
4406 "config.h.bot", "stamp-h.in", 'stamp-vti'
4410 -a, --add-missing add missing standard files to package
4411 --amdir=DIR directory storing config files
4412 --build-dir=DIR directory where build being done (for dependencies)
4413 --cygnus assume program is part of Cygnus-style tree
4414 --foreign set strictness to foreign
4415 --gnits set strictness to gnits
4416 --gnu set strictness to gnu
4417 --help print this help, then exit
4418 -i, --include-deps include generated dependencies in Makefile.in
4419 --no-force only update Makefile.in's that are out of date
4420 -o DIR, --output-dir=DIR
4421 put generated Makefile.in's into DIR
4422 --srcdir-name=DIR name used for srcdir (for dependencies)
4423 -v, --verbose verbosely list files processed
4424 --version print version number, then exit\n";
4426 # Copyright on generated Makefile.ins.
4428 # Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
4429 # This Makefile.in is free software; the Free Software Foundation
4430 # gives unlimited permission to copy, distribute and modify it.
4433 # Ignore return result from chmod, because it might give an error
4434 # if we chmod a symlink.
4435 $dist_header = "\t" . '-chmod -R a+r $(distdir)' . "\n";
4436 $dist{'tarZ'} = ("\t"
4437 . '$(TAR) chf - $(distdir) | compress -c > $(distdir).tar.Z'
4439 $dist{'shar'} = ("\t"
4440 . 'shar $(distdir) | gzip > $(distdir).shar.gz'
4442 $dist{'zip'} = "\t" . 'zip -rq $(distdir).zip $(distdir)' . "\n";
4443 $dist{'dist'} = "\t" . 'GZIP=$(GZIP) $(TAR) chozf $(distdir).tar.gz $(distdir)' . "\n";
4444 $dist_trailer = "\t" . 'rm -rf $(distdir)' . "\n";
4447 # (Re)-Initialize per-Makefile.am variables.
4448 sub initialize_per_input
4450 # These two variables are used when generating each Makefile.in.
4451 # They hold the Makefile.in until it is ready to be printed.
4454 $output_trailer = '';
4455 $output_header = '';
4457 # Suffixes found during a run.
4460 # This holds the contents of a Makefile.am, as parsed by
4464 # This holds the names which are targets. These also appear in
4468 # This holds the line numbers at which various elements of
4469 # %contents are defined.
4470 %content_lines = ();
4472 # This holds a 1 if a particular variable was examined.
4475 # This holds the "relative directory" of the current Makefile.in.
4476 # Eg for src/Makefile.in, this is "src".
4479 # This holds a list of files that are included in the
4483 # List of dependencies for the obvious targets.
4499 # These are pretty obvious, too. They are used to define the
4500 # SOURCES and OBJECTS variables.
4504 # TRUE if current directory holds any C source files.
4505 $dir_holds_sources = 0;
4507 # These variables track inclusion of various compile-related .am
4508 # files. $included_generic_compile is TRUE if the basic code has
4509 # been included. $included_knr_compile is TRUE if the ansi2knr
4510 # code has been included. $included_libtool_compile is TRUE if
4511 # libtool support has been included.
4512 $included_generic_compile = 0;
4513 $included_knr_compile = 0;
4514 $included_libtool_compile = 0;
4516 # TRUE if current directory holds any headers.
4517 $dir_holds_headers = 0;
4519 # TRUE if install targets should work recursively.
4520 $recursive_install = 0;
4525 # Strictness levels.
4526 $strictness = $default_strictness;
4527 $strictness_name = $default_strictness_name;
4529 # Options from AUTOMAKE_OPTIONS.
4532 # Whether or not dependencies are handled. Can be further changed
4533 # in handle_options.
4534 $use_dependencies = $cmdline_use_dependencies;
4537 $local_maint_charset = $maint_charset;
4539 # All yacc and lex source filenames for this directory. Use
4540 # filenames instead of raw count so that multiple instances are
4541 # counted correctly (eg one yacc file can appear in multiple
4542 # programs without harm).
4546 # C++ source extensions we've seen.
4547 %cxx_extensions = ();
4549 # TRUE if we've seen any non-C++ sources. This actually holds a
4550 # line number or the name of a symbol corresponding to a line
4551 # number where the C sources were seen. If it is -1 then it means
4552 # we couldn't (easily) figure out which line of the Makefile.am
4553 # mentioned the sources.
4556 # This is a list of all targets to run during "make dist".
4559 # Keys in this hash are the names of ._o files which must depend
4561 %de_ansi_objects = ();
4565 ################################################################
4567 # Return contents of a file from $am_dir, automatically skipping
4568 # macros or rules which are already known. Runs command on each line
4569 # as it is read; this command can modify $_.
4570 sub file_contents_with_transform
4572 local ($command, $basename) = @_;
4573 local ($file) = $am_dir . '/' . $basename . '.am';
4575 if ($command ne '' && substr ($command, -1) ne ';')
4577 die "automake: programming error in file_contents_with_transform\n";
4580 open (FC_FILE, $file)
4581 || die "automake: installation error: cannot open \`$file'\n";
4583 # print "automake: reading $file\n" if $verbose;
4585 local ($was_rule) = 0;
4586 local ($result_vars) = '';
4587 local ($result_rules) = '';
4588 local ($comment) = '';
4589 local ($spacing) = "\n";
4590 local ($skipping) = 0;
4595 $_ =~ s/\@MAINT\@//g
4596 unless $seen_maint_mode;
4598 $had_chars = length ($_) && $_ ne "\n";
4600 # If the transform caused all the characters to go away, then
4601 # ignore the line. Why do this? Because in Perl 4, a "next"
4602 # inside of an eval doesn't affect a loop outside the eval.
4603 # So we can't pass in a "transform" that uses next. We used
4604 # to do this. "Empty" also means consisting of a single
4606 next if $had_chars && ($_ eq '' || $_ eq "\n");
4608 if (/$IGNORE_PATTERN/o)
4610 # Merely delete comments beginning with two hashes.
4612 elsif (/$WHITE_PATTERN/o)
4614 # Stick a single white line before the incoming macro or rule.
4617 elsif (/$COMMENT_PATTERN/o)
4619 # Stick comments before the incoming macro or rule.
4620 $comment .= $spacing . $_;
4627 $result_rules .= $_ if ! $skipping;
4631 $result_vars .= $_ if ! $skipping;
4635 elsif (/$RULE_PATTERN/o)
4637 # warn "** Found rule .$1.\n";
4640 $skipping = defined $contents{$1};
4641 # warn "** Skip $skipping\n" if $skipping;
4642 $result_rules .= $comment . $spacing . $_ if ! $skipping;
4643 $comment = $spacing = '';
4646 elsif (/$MACRO_PATTERN/o)
4648 # warn "** Found macro .$1.\n";
4649 # Found a variable reference.
4651 $skipping = defined $contents{$1};
4652 # warn "** Skip $skipping\n" if $skipping;
4653 $result_vars .= $comment . $spacing . $_ if ! $skipping;
4654 $comment = $spacing = '';
4659 # This isn't an error; it is probably a continued rule.
4660 # In fact, this is what we assume.
4662 $result_rules .= $comment . $spacing . $_ if ! $skipping;
4663 $comment = $spacing = '';
4669 return $result_vars . $result_rules . $comment;
4672 # Like file_contents_with_transform, but no transform.
4675 return &file_contents_with_transform ('', @_);
4678 # Find all variable prefixes that are used for install directories. A
4679 # prefix `zar' qualifies iff:
4680 # * `zardir' is a variable.
4681 # * `zar_PRIMARY' is a variable.
4682 sub am_primary_prefixes
4684 local ($primary, @prefixes) = @_;
4686 local (%valid, $varname);
4687 grep ($valid{$_} = 0, @prefixes);
4688 $valid{'EXTRA'} = 0;
4689 foreach $varname (keys %contents)
4691 if ($varname =~ /^(.*)_$primary$/)
4693 if (! defined $valid{$1}
4694 && ! &variable_defined ($1 . 'dir')
4695 # Note that a configure variable is always legitimate.
4696 # It is natural to name such variables after the
4697 # primary, so we explicitly allow it.
4698 && ! defined $configure_vars{$varname})
4700 &am_line_error ($varname, "invalid variable \"$varname\"");
4704 # Ensure all extended prefixes are actually used.
4713 # Handle `where_HOW' variable magic. Does all lookups, generates
4714 # install code, and possibly generates code to define the primary
4715 # variable. The first argument is the name of the .am file to munge,
4716 # the second argument is the primary variable (eg HEADERS), and all
4717 # subsequent arguments are possible installation locations. Returns
4718 # list of all values of all _HOW targets.
4720 # FIXME: this should be rewritten to be cleaner. It should be broken
4721 # up into multiple functions.
4723 # Usage is: am_install_var (OPTION..., file, HOW, where...)
4728 local ($do_clean) = 0;
4731 if (defined $configure_vars{'LIBTOOL'})
4733 # Transform '@LIBTOOL ...@' to '$(LIBTOOL) ...'
4734 $ltxform = 's/\@LIBTOOL([^\@]*)\@/\$(LIBTOOL) $1/;';
4738 # Delete '@LIBTOOL ...@'
4739 $ltxform = 's/\@LIBTOOL([^\@]*)\@//;';
4743 if (! $seen_cygwin32)
4745 $cygxform = 's/\@EXEEXT\@//g; s/^NOTCYGWIN//; s/^CYGWIN.*$//;';
4749 $cygxform = 's/\@EXEEXT\@/\$(EXEEXT)/g; s/^CYGWIN//; s/^NOTCYGWIN.*$//;';
4754 if ($args[0] eq '-clean')
4758 elsif ($args[0] !~ /^-/)
4764 local ($file, $primary, @prefixes) = @args;
4767 local (@result) = ();
4769 # Now that configure substitutions are allowed in where_HOW
4770 # variables, it is an error to actually define the primary.
4771 &am_line_error ($primary, "\`$primary' is an anachronism")
4772 if &variable_defined ($primary);
4775 # Look for misspellings. It is an error to have a variable ending
4776 # in a "reserved" suffix whose prefix is unknown, eg
4777 # "bni_PROGRAMS". However, unusual prefixes are allowed if a
4778 # variable of the same name (with "dir" appended) exists. For
4779 # instance, if the variable "zardir" is defined, then
4780 # "zar_PROGRAMS" becomes valid. This is to provide a little extra
4781 # flexibility in those cases which need it. Perhaps it should be
4782 # disallowed in the Gnits case? The problem is, sometimes it is
4783 # useful to put things in a subdir of eg pkgdatadir, perhaps even
4785 local (%valid) = &am_primary_prefixes ($primary, @prefixes);
4787 # If a primary includes a configure substitution, then the EXTRA_
4788 # form is required. Otherwise we can't properly do our job.
4789 local ($require_extra);
4790 local ($warned_about_extra) = 0;
4792 local ($clean_file) = $file . '-clean';
4795 foreach $X (sort keys %valid)
4797 $one_name = $X . '_' . $primary;
4798 if (&variable_defined ($one_name))
4800 # Append actual contents of where_PRIMARY variable to
4803 foreach $rcurs (&variable_value_as_list ($one_name))
4805 # Skip configure substitutions. Possibly bogus.
4806 if ($rcurs =~ /^\@.*\@$/)
4810 if (! $warned_about_extra)
4812 $warned_about_extra = 1;
4813 &am_line_error ($one_name,
4814 "\`$one_name' contains configure substitution, but shouldn't");
4817 # Check here to make sure variables defined in
4818 # configure.in do not imply that EXTRA_PRIMARY
4820 elsif (! defined $configure_vars{$one_name})
4822 $require_extra = $one_name;
4826 push (@result, $rcurs);
4829 # "EXTRA" shouldn't be used when generating clean targets,
4830 # @all, or install targets.
4831 next if $X eq 'EXTRA';
4836 &file_contents_with_transform ('s/\@DIR\@/' . $X . '/go;'
4840 push (@clean, $X . $primary);
4841 &push_phony_cleaners ($X . $primary);
4846 push (@check, '$(' . $one_name . ')');
4850 push (@used, '$(' . $one_name . ')');
4852 if ($X eq 'noinst' || $X eq 'check')
4854 # Objects which don't get installed by default.
4859 &file_contents_with_transform ('s/\@DIR\@/' . $X . '/g;'
4860 . $ltxform . $cygxform,
4863 push (@uninstall, 'uninstall-' . $X . $primary);
4864 push (@phony, 'uninstall-' . $X . $primary);
4865 push (@installdirs, '$(' . $X . 'dir)');
4866 if (defined $exec_dir_p{$X} ? $exec_dir_p{$X} : ($X =~ /exec/))
4868 push (@install_exec, 'install-' . $X . $primary);
4869 push (@phony, 'install-' . $X . $primary);
4873 push (@install_data, 'install-' . $X . $primary);
4874 push (@phony, 'install-' . $X . $primary);
4882 &define_pretty_variable ($primary, @used);
4883 $output_vars .= "\n";
4886 if ($require_extra && ! &variable_defined ('EXTRA_' . $primary))
4888 &am_line_error ($require_extra,
4889 "\`$require_extra' contains configure substitution, but \`EXTRA_$primary' not defined");
4892 # Push here because PRIMARY might be configure time determined.
4893 push (@all, '$(' . $primary . ')')
4900 ################################################################
4902 # This variable is local to the "require file" set of functions.
4903 @require_file_paths = ();
4905 # Verify that the file must exist in the current directory. Usage:
4906 # require_file (isconfigure, line_number, strictness, file) strictness
4907 # is the strictness level at which this file becomes required. Must
4908 # set require_file_paths before calling this function.
4909 # require_file_paths is set to hold a single directory (the one in
4910 # which the first file was found) before return.
4911 sub require_file_internal
4913 local ($is_configure, $line, $mystrict, @files) = @_;
4914 local ($file, $fullfile);
4915 local ($found_it, $errfile, $errdir);
4918 foreach $file (@files)
4921 foreach $dir (@require_file_paths)
4925 $fullfile = $relative_dir . "/" . $file;
4926 $errdir = $relative_dir unless $errdir;
4930 $fullfile = $dir . "/" . $file;
4931 $errdir = $dir unless $errdir;
4934 # Use different name for "error filename". Otherwise on
4935 # an error the bad file will be reported as eg
4936 # `../../install-sh' when using the default
4938 $errfile = $errdir . '/' . $file;
4943 # FIXME: Once again, special-case `.'.
4944 &push_dist_common ($file)
4945 if $dir eq $relative_dir || $dir eq '.';
4953 # Prune the path list.
4954 @require_file_paths = $save_dir;
4958 if ($strictness >= $mystrict)
4960 local ($trailer) = '';
4961 local ($suppress) = 0;
4963 # Only install missing files according to our desired
4967 $trailer = "; installing";
4970 # Maybe run libtoolize.
4972 && grep ($_ eq $file, @libtoolize_files)
4973 && system ('libtoolize', '--automake'))
4976 $trailer .= "; cannot run \`libtoolize': $!";
4978 elsif (-f ($am_dir . '/' . $file))
4980 # Install the missing file. Symlink if we
4981 # can, copy if we must. Note: delete the file
4982 # first, in case it is a dangling symlink.
4984 if ($symlink_exists)
4986 if (! symlink ($am_dir . '/' . $file, $errfile))
4989 $trailer .= "; error while making link: $!\n";
4992 elsif (! system ('cp', $am_dir . '/' . $file, $errfile))
4995 $trailer .= "\n error while making link\n";
5000 local ($save) = $exit_status;
5003 # FIXME: allow actual file to be specified.
5005 ('configure.in', $line,
5006 "required file \"$errfile\" not found$trailer");
5012 "required file \"$errfile\" not found$trailer");
5014 $exit_status = $save if $suppress;
5020 # Like require_file_with_line, but error messages refer to
5021 # configure.in, not the current Makefile.am.
5022 sub require_file_with_conf_line
5024 @require_file_paths = '.';
5025 &require_file_internal (1, @_);
5028 sub require_file_with_line
5030 @require_file_paths = '.';
5031 &require_file_internal (0, @_);
5036 @require_file_paths = '.';
5037 &require_file_internal (0, '', @_);
5040 # Require a file that is also required by Autoconf. Looks in
5041 # configuration path, as specified by AC_CONFIG_AUX_DIR.
5042 sub require_config_file
5044 @require_file_paths = @config_aux_path;
5045 &require_file_internal (1, '', @_);
5046 local ($dir) = $require_file_paths[0];
5047 @config_aux_path = @require_file_paths;
5050 $config_aux_dir = '.';
5054 $config_aux_dir = '$(top_srcdir)/' . $dir;
5058 # Assumes that the line number is in Makefile.am.
5059 sub require_conf_file_with_line
5061 @require_file_paths = @config_aux_path;
5062 &require_file_internal (0, @_);
5063 local ($dir) = $require_file_paths[0];
5064 @config_aux_path = @require_file_paths;
5067 $config_aux_dir = '.';
5071 $config_aux_dir = '$(top_srcdir)/' . $dir;
5075 # Assumes that the line number is in Makefile.am.
5076 sub require_conf_file_with_conf_line
5078 @require_file_paths = @config_aux_path;
5079 &require_file_internal (1, @_);
5080 local ($dir) = $require_file_paths[0];
5081 @config_aux_path = @require_file_paths;
5084 $config_aux_dir = '.';
5088 $config_aux_dir = '$(top_srcdir)/' . $dir;
5092 ################################################################
5094 # Push a list of files onto dist_common.
5095 sub push_dist_common
5097 local (@files) = @_;
5100 foreach $file (@files)
5102 $dist_common{$file} = 1;
5106 # Push a list of clean targets onto phony.
5107 sub push_phony_cleaners
5111 foreach $target ('mostly', 'dist', '', 'maintainer-')
5113 push (@phony, $target . 'clean-' . $base);
5120 $strictness_name = $_[0];
5121 if ($strictness_name eq 'gnu')
5125 elsif ($strictness_name eq 'gnits')
5127 $strictness = $GNITS;
5129 elsif ($strictness_name eq 'foreign')
5131 $strictness = $FOREIGN;
5135 die "automake: level \`$strictness_name' not recognized\n";
5140 ################################################################
5142 # Return directory name of file.
5148 ($sub = $file) =~ s,/+[^/]+$,,g;
5149 $sub = '.' if $sub eq $file;
5153 # Return file name of a file.
5159 ($sub = $file) =~s,^.*/+,,g;
5168 open (TOUCH, ">> $file");
5172 # Glob something. Do this to avoid indentation screwups everywhere we
5173 # want to glob. Gross!
5180 ################################################################
5182 # Print an error message and set exit status.
5185 warn "automake: ${am_file}.am: ", join (' ', @_), "\n";
5191 local ($symbol, @args) = @_;
5193 if ($symbol && "$symbol" ne '-1')
5195 # If SYMBOL not already a line number, look it up in Makefile.am.
5196 if ($symbol =~ /^\d+$/)
5200 elsif (defined $content_lines{$symbol})
5202 $symbol = $content_lines{$symbol} . ': ';
5206 # A single space, to provide nice separation.
5209 warn "${am_file}.am:", $symbol, join (' ', @args), "\n";
5218 # Like am_error, but while scanning configure.in.
5221 # FIXME: can run in subdirs.
5222 warn "automake: configure.in: ", join (' ', @_), "\n";
5226 # Error message with line number referring to configure.in.
5227 sub am_conf_line_error
5229 local ($file, $line, @args) = @_;
5233 warn "$file: $line: ", join (' ', @args), "\n";
5238 &am_conf_error (@args);
5242 # Tell user where our aclocal.m4 is, but only once.
5243 sub keyed_aclocal_warning
5246 warn "automake: macro \`$key' can be generated by \`aclocal'\n";
5249 # Print usage information.
5252 print "Usage: automake [OPTION] ... [Makefile]...\n";
5254 print "\nFiles which are automatically distributed, if found:\n";
5255 $~ = "USAGE_FORMAT";
5256 local (@lcomm) = sort ((@common_files, @common_sometimes));
5257 local ($one, $two, $three, $four);
5260 $one = shift @lcomm;
5261 $two = @lcomm ? shift @lcomm : '';
5262 $three = @lcomm ? shift @lcomm : '';
5263 $four = @lcomm ? shift @lcomm : '';
5267 print "\nReport bugs to <automake-bugs\@gnu.ai.mit.edu>\n";
5272 format USAGE_FORMAT =
5273 @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<
5274 $one, $two, $three, $four