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';
1416 local ($cygxform) = '';
1417 if (! $seen_cygwin32)
1419 $cygxform .= 's/^CYGWIN.*$//;';
1423 &file_contents_with_transform
1424 ('s/\@PROGRAM\@/' . $one_file . '/go;'
1425 . 's/\@XPROGRAM\@/' . $xname . '/go;'
1426 . 's/\@XLINK\@/' . $xlink . '/go;'
1431 if (&variable_defined ('LDADD') && &handle_lib_objects ('', 'LDADD', 0))
1438 foreach $one_file (@proglist)
1440 # Canonicalize names.
1441 ($xname = $one_file) =~ tr/A-Za-z0-9_/_/c;
1443 if (&variable_defined ($xname . '_LDADD'))
1445 &check_libobjs_sources ($xname, $xname . '_LDADD');
1447 elsif (&variable_defined ('LDADD'))
1449 &check_libobjs_sources ($xname, 'LDADD');
1457 sub handle_libraries
1459 local (@liblist) = &am_install_var ('-clean',
1460 'libs', 'LIBRARIES',
1461 'lib', 'pkglib', 'noinst', 'check');
1462 return if ! @liblist;
1464 local (%valid) = &am_primary_prefixes ('LIBRARIES', 'lib', 'pkglib',
1466 if (! defined $configure_vars{'RANLIB'})
1469 foreach $key (keys %valid)
1471 if (&variable_defined ($key . '_LIBRARIES'))
1473 &am_line_error ($key . '_LIBRARIES', "library used but \`RANLIB' not defined in \`configure.in'");
1474 # Only get this error once.
1475 $configure_vars{'RANLIB'} = 1;
1484 local ($seen_libobjs) = 0;
1485 foreach $onelib (@liblist)
1487 # Check that the library fits the standard naming convention.
1488 if ($onelib !~ /^lib.*\.a$/)
1490 # FIXME this should only be a warning for foreign packages
1491 # FIXME should put line number here. That means mapping
1492 # from library name back to variable name.
1493 &am_error ("\`$onelib' is not a standard library name");
1496 local ($obj) = &get_object_extension ($onelib);
1498 # Canonicalize names.
1499 ($xlib = $onelib) =~ tr/A-Za-z0-9_/_/c;
1500 if ($xlib ne $onelib)
1503 foreach $xt ('_LIBADD', '_SOURCES', '_OBJECTS', '_DEPENDENCIES')
1505 &am_line_error ($onelib . $xt,
1506 "invalid variable \`" . $onelib . $xt
1507 . "'; should be \`" . $xlib . $xt . "'")
1508 if &variable_defined ($onelib . $xt);
1512 if (&variable_defined ($xlib . '_LIBADD'))
1514 if (&handle_lib_objects ($xlib, $xlib . '_LIBADD', 0))
1521 # Generate support for conditional object inclusion in
1523 &define_variable ($xlib . "_LIBADD", '');
1526 &handle_source_transform ($xlib, $onelib, $obj);
1529 &file_contents_with_transform ('s/\@LIBRARY\@/' . $onelib . '/go;'
1537 foreach $onelib (@liblist)
1539 # Canonicalize names.
1540 ($xlib = $onelib) =~ tr/A-Za-z0-9_/_/c;
1541 if (&variable_defined ($xlib . '_LIBADD'))
1543 &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
1548 &define_variable ('AR', 'ar');
1549 &define_configure_variable ('RANLIB');
1552 # Handle shared libraries.
1553 sub handle_ltlibraries
1555 local (@liblist) = &am_install_var ('-clean',
1556 'ltlib', 'LTLIBRARIES',
1558 return if ! @liblist;
1561 local (%valid) = &am_primary_prefixes ('LTLIBRARIES', 'lib', 'pkglib');
1564 foreach $key (keys %valid)
1566 if (&variable_defined ($key . '_LTLIBRARIES'))
1570 &am_line_error ($key . '_LTLIBRARIES', "library used but \`LIBTOOL' not defined in \`configure.in'");
1571 # Only get this error once.
1572 $configure_vars{'LIBTOOL'} = 1;
1576 # Get the installation directory of each library.
1577 next if ($key eq 'EXTRA');
1578 for (&variable_value_as_list ($key . '_LTLIBRARIES'))
1582 &am_error ("\`$_' is already going to be installed in \`$instdirs{$_}'");
1586 $instdirs{$_} = $key;
1595 local ($seen_libobjs) = 0;
1596 foreach $onelib (@liblist)
1598 # Check that the library fits the standard naming convention.
1599 if ($onelib !~ /^lib.*\.la$/)
1601 # FIXME this should only be a warning for foreign packages
1602 # FIXME should put line number here. That means mapping
1603 # from library name back to variable name.
1604 &am_error ("\`$onelib' is not a standard libtool library name");
1607 local ($obj) = &get_object_extension ($onelib);
1609 # Canonicalize names.
1610 ($xlib = $onelib) =~ tr/A-Za-z0-9_/_/c;
1611 if ($xlib ne $onelib)
1614 foreach $xt ('_LIBADD', '_LDFLAGS', '_SOURCES', '_OBJECTS', '_DEPENDENCIES')
1616 &am_line_error ($onelib . $xt,
1617 "invalid variable \`" . $onelib . $xt
1618 . "'; should be \`" . $xlib . $xt . "'")
1619 if &variable_defined ($onelib . $xt);
1623 if (! &variable_defined ($xlib . '_LDFLAGS'))
1625 # Define the lib_LDFLAGS variable.
1626 &define_variable ($xlib . '_LDFLAGS', '');
1629 if (&variable_defined ($xlib . '_LIBADD'))
1631 if (&handle_lib_objects ($xlib, $xlib . '_LIBADD', 0))
1638 # Generate support for conditional object inclusion in
1640 &define_variable ($xlib . "_LIBADD", '');
1643 local ($linker) = &handle_source_transform ($xlib, $onelib, $obj);
1645 # Determine program to use for link.
1647 if (&variable_defined ($xlib . '_LINK'))
1649 $xlink = $xlib . '_LINK';
1653 $xlink = $linker ? $linker : 'LINK';
1658 &file_contents_with_transform ('s/\@LTLIBRARY\@/'
1660 . 's/\@XLTLIBRARY\@/'
1663 . $instdirs{$onelib} . '/go;'
1664 . 's/\@XLINK\@/' . $xlink . '/go;',
1670 foreach $onelib (@liblist)
1672 # Canonicalize names.
1673 ($xlib = $onelib) =~ tr/A-Za-z0-9_/_/c;
1674 if (&variable_defined ($xlib . '_LIBADD'))
1676 &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
1682 # See if any _SOURCES variable were misspelled. Also, make sure that
1683 # EXTRA_ variables don't contain configure substitutions.
1686 local ($varname, $primary);
1687 foreach $varname (keys %contents)
1689 foreach $primary ('_SOURCES', '_LIBADD', '_LDADD', '_LDFLAGS', '_DEPENDENCIES')
1691 if ($varname =~ /$primary$/ && ! $content_seen{$varname})
1693 &am_line_error ($varname,
1694 "invalid unused variable name: \`$varname'");
1703 # NOTE we no longer automatically clean SCRIPTS, because it is
1704 # useful to sometimes distribute scripts verbatim. This happens
1705 # eg in Automake itself.
1706 &am_install_var ('scripts', 'SCRIPTS',
1707 'bin', 'sbin', 'libexec', 'pkgdata',
1710 # Set $scripts_installed if appropriate. Make sure we only find
1711 # scripts which are actually installed -- this is why we can't
1712 # simply use the return value of am_install_var.
1713 local (%valid) = &am_primary_prefixes ('SCRIPTS', 'bin', 'sbin',
1714 'libexec', 'pkgdata',
1717 foreach $key (keys %valid)
1719 if ($key ne 'noinst'
1721 && &variable_defined ($key . '_SCRIPTS'))
1723 $scripts_installed = 1;
1724 # push (@check_tests, 'check-' . $key . 'SCRIPTS');
1728 if ($scripts_installed)
1730 # If a program is installed, this is required. We only want this
1731 # error to appear once.
1732 &am_conf_error ("AC_ARG_PROGRAM must be used in configure.in")
1733 unless $seen_arg_prog;
1738 # Search a file for a "version.texi" Texinfo include. Return the name
1739 # of the include file if found, or the empty string if not. A
1740 # "version.texi" file is actually any file whose name matches
1742 sub scan_texinfo_file
1744 local ($filename) = @_;
1746 if (! open (TEXI, $filename))
1748 &am_error ("couldn't open \`$filename': $!");
1751 print "automake: reading $filename\n" if $verbose;
1753 local ($vfile, $outfile);
1756 if (/^\@setfilename +(\S+)/)
1762 if (/^\@include\s+(vers[^.]*\.texi)\s*$/)
1764 # Found version.texi include.
1771 return ($outfile, $vfile);
1774 # Handle all Texinfo source.
1777 &am_line_error ('TEXINFOS',
1778 "\`TEXINFOS' is an anachronism; use \`info_TEXINFOS'")
1779 if &variable_defined ('TEXINFOS');
1780 return if (! &variable_defined ('info_TEXINFOS')
1781 && ! &variable_defined ('html_TEXINFOS'));
1783 local (@texis) = &variable_value_as_list ('info_TEXINFOS');
1785 local (@info_deps_list, @dvis_list, @texi_deps);
1786 local ($infobase, $info_cursor);
1790 local ($tc_cursor, @texi_cleans);
1793 foreach $info_cursor (@texis)
1795 ($infobase = $info_cursor) =~ s/\.texi(nfo)?$//;
1797 # If 'version.texi' is referenced by input file, then include
1798 # automatic versioning capability.
1799 local ($out_file, $vtexi) = &scan_texinfo_file ($relative_dir
1800 . "/" . $info_cursor);
1802 if ($out_file eq '')
1804 &am_error ("\`$info_cursor' missing \@setfilename");
1808 if ($out_file =~ /\.(.+)$/ && $1 ne 'info')
1810 # FIXME should report line number in input file.
1811 &am_error ("output of \`$info_cursor', \`$out_file', has unrecognized extension");
1817 &am_error ("\`$vtexi', included in \`$info_cursor', also included in \`$versions{$vtexi}'")
1818 if (defined $versions{$vtexi});
1819 $versions{$vtexi} = $info_cursor;
1821 # We number the stamp-vti files. This is doable since the
1822 # actual names don't matter much. We only number starting
1823 # with the second one, so that the common case looks nice.
1824 $vti = 'vti' . ($done ? $done : '');
1825 &push_dist_common ($vtexi, 'stamp-' . $vti);
1826 push (@clean, $vti);
1828 # Only require once.
1829 &require_conf_file_with_line ('info_TEXINFOS', $FOREIGN,
1835 ($conf_pat = $config_aux_dir) =~ s/(\W)/\\$1/g;
1837 &file_contents_with_transform
1838 ('s/\@TEXI\@/' . $info_cursor . '/g; '
1839 . 's/\@VTI\@/' . $vti . '/g; '
1840 . 's/\@VTEXI\@/' . $vtexi . '/g;'
1841 . 's,\@MDDIR\@,' . $conf_pat . ',g;',
1844 &push_phony_cleaners ($vti);
1847 # If user specified file_TEXINFOS, then use that as explicit
1850 push (@texi_deps, $info_cursor);
1851 push (@texi_deps, $vtexi) if $vtexi;
1853 # Canonicalize name first.
1854 ($canonical = $infobase) =~ tr/A-Za-z0-9_/_/c;
1855 if (&variable_defined ($canonical . "_TEXINFOS"))
1857 push (@texi_deps, '$(' . $canonical . '_TEXINFOS)');
1858 &push_dist_common ('$(' . $canonical . '_TEXINFOS)');
1861 $output_rules .= ("\n" . $out_file . ": "
1862 . join (' ', @texi_deps)
1863 . "\n" . $infobase . ".dvi: "
1864 . join (' ', @texi_deps)
1867 push (@info_deps_list, $out_file);
1868 push (@dvis_list, $infobase . '.dvi');
1870 # Generate list of things to clean for this target. We do
1871 # this explicitly because otherwise too many things could be
1872 # removed. In particular the ".log" extension might
1873 # reasonably be used in other contexts by the user.
1874 foreach $tc_cursor ('aux', 'cp', 'cps', 'dvi', 'fn', 'fns',
1875 'ky', 'log', 'pg', 'toc', 'tp', 'tps',
1876 'vr', 'vrs', 'op', 'tr', 'cv')
1878 push (@texi_cleans, $infobase . '.' . $tc_cursor);
1882 # Find these programs wherever they may lie. Yes, this has
1883 # intimate knowledge of the structure of the texinfo distribution.
1884 &define_program_variable ('MAKEINFO', 'build', 'texinfo/makeinfo',
1886 &define_program_variable ('TEXI2DVI', 'src', 'texinfo/util',
1892 $xform = 's/^NOTCYGNUS.*$//; s/^CYGNUS//;';
1896 $xform = 's/^CYGNUS.*$//; s/^NOTCYGNUS//;';
1898 $output_rules .= &file_contents_with_transform ($xform, 'texinfos');
1899 push (@phony, 'install-info-am', 'uninstall-info');
1900 push (@dist_targets, 'dist-info');
1903 $output_rules .= "\nmostlyclean-info:\n";
1904 &pretty_print_rule ("\trm -f", "\t ", @texi_cleans);
1905 $output_rules .= ("\nclean-info:\n\ndistclean-info:\n\n"
1906 . "maintainer-clean-info:\n\t"
1907 . 'for i in $(INFO_DEPS); do rm -f `eval echo $$i*`; done'
1909 &push_phony_cleaners ('info');
1911 push (@suffixes, '.texi', '.texinfo', '.info', '.dvi', '.ps');
1913 if (! defined $options{'no-installinfo'})
1915 push (@uninstall, 'uninstall-info');
1916 push (@installdirs, '$(infodir)');
1917 unshift (@install_data, 'install-info-am');
1919 # Make sure documentation is made and installed first. Use
1920 # $(INFO_DEPS), not 'info', because otherwise recursive makes
1921 # get run twice during "make all".
1922 unshift (@all, '$(INFO_DEPS)');
1924 push (@clean, 'info');
1925 push (@info, '$(INFO_DEPS)');
1926 push (@dvi, '$(DVIS)');
1928 &define_variable ("INFO_DEPS", join (' ', @info_deps_list));
1929 &define_variable ("DVIS", join (' ', @dvis_list));
1930 # This next isn't strictly needed now -- the places that look here
1931 # could easily be changed to look in info_TEXINFOS. But this is
1932 # probably better, in case noinst_TEXINFOS is ever supported.
1933 &define_variable ("TEXINFOS", $contents{'info_TEXINFOS'});
1935 # Do some error checking. Note that this file is not required
1936 # when in Cygnus mode -- a bletcherous hack.
1937 &require_file_with_line ('info_TEXINFOS',
1938 $cygnus_mode ? $GNU : $FOREIGN,
1940 unless defined $options{'no-texinfo.tex'};
1943 # Handle any man pages.
1944 sub handle_man_pages
1946 &am_line_error ('MANS', "\`MANS' is an anachronism; use \`man_MANS'")
1947 if &variable_defined ('MANS');
1948 return if ! &variable_defined ('man_MANS');
1950 # We generate the manpage install code by hand to avoid the use of
1951 # basename in the generated Makefile.
1952 local (@mans) = &variable_value_as_list ('man_MANS');
1953 local (%sections, %inames, %mbases, %secmap, %fullsecmap);
1957 # FIXME: statement without effect:
1958 /^(.*)\.([0-9])([a-z]*)$/;
1963 $fullsecmap{$i} = $2 . $3;
1967 # We don't really need this, but we use it in case we ever want to
1968 # support noinst_MANS.
1969 &define_variable ("MANS", $contents{'man_MANS'});
1971 # Generate list of install dirs.
1972 $output_rules .= "install-man: \$(MANS)\n";
1973 $output_rules .= "\t\$(NORMAL_INSTALL)\n";
1974 # Sort keys so that output is deterministic.
1975 foreach (sort keys %sections)
1977 push (@installdirs, '$(mandir)/man' . $_)
1978 unless defined $options{'no-installman'};
1979 $output_rules .= ("\t" . '$(mkinstalldirs) $(mandir)/man'
1982 push (@phony, 'install-man');
1984 # Generate install target.
1986 foreach $key (sort keys %inames)
1988 $_ = $install_man_format;
1989 s/\@SECTION\@/$secmap{$key}/g;
1990 s/\@MAN\@/$inames{$key}/g;
1991 s/\@FULLSECT\@/$fullsecmap{$key}/g;
1992 s/\@MANBASE\@/$mbases{$key}/g;
1993 $output_rules .= $_;
1995 $output_rules .= "\n";
1997 $output_rules .= "uninstall-man:\n";
1998 foreach $key (sort keys %inames)
2000 $_ = $uninstall_man_format;
2001 s/\@SECTION\@/$secmap{$key}/g;
2002 s/\@MAN\@/$inames{$key}/g;
2003 s/\@FULLSECT\@/$fullsecmap{$key}/g;
2004 s/\@MANBASE\@/$mbases{$key}/g;
2005 $output_rules .= $_;
2007 $output_rules .= "\n";
2008 push (@phony, 'uninstall-man');
2010 $output_vars .= &file_contents ('mans-vars');
2012 if (! defined $options{'no-installman'})
2014 push (@install_data, 'install-man');
2015 push (@uninstall, 'uninstall-man');
2016 push (@all, '$(MANS)');
2020 # Handle DATA variables.
2023 &am_install_var ('data', 'DATA', 'data', 'sysconf',
2024 'sharedstate', 'localstate', 'pkgdata',
2031 push (@phony, 'tags');
2032 local (@tag_deps) = ();
2033 if (&variable_defined ('SUBDIRS'))
2035 $output_rules .= ("tags-recursive:\n"
2036 . "\tlist=\"\$(SUBDIRS)\"; for subdir in \$\$list; do \\\n"
2037 # Never fail here if a subdir fails; it
2039 . "\t (cd \$\$subdir && \$(MAKE) tags); \\\n"
2041 push (@tag_deps, 'tags-recursive');
2042 push (@phony, 'tags-recursive');
2045 if ($dir_holds_sources
2046 || $dir_holds_headers
2047 || &variable_defined ('ETAGS_ARGS')
2050 local ($xform) = '';
2051 if ($config_header && $relative_dir eq &dirname ($config_header))
2053 # The config header is in this directory. So require it.
2054 ($xform = &basename ($config_header)) =~ s/(\W)/\\$1/g;
2056 $xform = ('s/\@CONFIG\@/' . $xform . '/;'
2057 . 's/\@DIRS\@/' . join (' ', @tag_deps) . '/;');
2059 $output_rules .= &file_contents_with_transform ($xform, 'tags');
2060 $output_rules .= &file_contents ('tags-clean');
2061 push (@clean, 'tags');
2062 &push_phony_cleaners ('tags');
2063 &examine_variable ('TAGS_DEPENDENCIES');
2065 elsif (&variable_defined ('TAGS_DEPENDENCIES'))
2067 &am_line_error ('TAGS_DEPENDENCIES',
2068 "doesn't make sense to define \`TAGS_DEPENDENCIES' without sources or \`ETAGS_ARGS'");
2072 # Every Makefile must define some sort of TAGS rule.
2073 # Otherwise, it would be possible for a top-level "make TAGS"
2074 # to fail because some subdirectory failed.
2075 $output_rules .= "tags: TAGS\nTAGS:\n\n";
2079 # Worker for handle_dist.
2080 sub handle_dist_worker
2082 $output_rules .= 'distdir: $(DISTFILES)' . "\n";
2084 # Initialization; only at top level.
2085 if ($relative_dir eq '.')
2087 if ($strictness >= $GNITS)
2089 # For Gnits users, this is pretty handy. Look at 15 lines
2090 # in case some explanatory text is desirable.
2091 $output_rules .= ' @if sed 15q $(srcdir)/NEWS | fgrep -e "$(VERSION)" > /dev/null; then :; else \\
2092 echo "NEWS not updated; not releasing" 1>&2; \\
2100 # Create dist directory.
2103 -chmod 755 $(distdir)
2106 # Only run automake in `dist' target if --include-deps not
2107 # specified. That way the recipient of a distribution can run
2108 # "make dist" and not need Automake.
2109 if ($cmdline_use_dependencies)
2113 # We need an absolute path for --output-dir. Thus the
2115 ' here=`pwd`; distdir=`cd $(distdir) && pwd` \\
2117 && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(srcdir) --output-dir=$$distdir '
2118 # Set strictness of output.
2119 . ($cygnus_mode ? '--cygnus' : ('--' . $strictness_name))
2125 # Scan EXTRA_DIST to see if we need to distribute anything from a
2126 # subdir. If so, add it to the list. I didn't want to do this
2127 # originally, but there were so many requests that I finally
2130 if (&variable_defined ('EXTRA_DIST'))
2132 foreach (&variable_value_as_list ('EXTRA_DIST'))
2135 next unless s,/+[^/]+$,,;
2136 push (@dist_dirs, $_)
2142 # Prepend $(distdir) to each directory given. Doing it via a
2143 # hash lets us ensure that each directory is used only once.
2145 grep ($dhash{'$(distdir)/' . $_} = 1, @dist_dirs);
2146 $output_rules .= "\t";
2147 &pretty_print_rule ('$(mkinstalldirs)', "\t ", sort keys %dhash);
2150 # In loop, test for file existence because sometimes a file gets
2151 # included in DISTFILES twice. For example this happens when a
2152 # single source file is used in building more than one program.
2153 # Also, there are situations in which "ln" can fail. For instance
2154 # a file to distribute could actually be a cross-filesystem
2155 # symlink -- this can easily happen if "gettextize" was run on the
2157 $output_rules .= "\t\@for file in \$(DISTFILES); do \\\n";
2160 $output_rules .= "\t if test -f \$\$file; then d=.; else d=\$(srcdir); fi; \\\n";
2164 $output_rules .= "\t d=\$(srcdir); \\\n";
2166 $output_rules .= ' test -f $(distdir)/$$file \\
2167 || ln $$d/$$file $(distdir)/$$file 2> /dev/null \\
2168 || cp -p $$d/$$file $(distdir)/$$file; \\
2172 # If we have SUBDIRS, create all dist subdirectories and do
2174 if (&variable_defined ('SUBDIRS'))
2176 # Test for directory existence here because previous automake
2177 # invocation might have created some directories. Note that
2178 # we explicitly set distdir for the subdir make; that lets us
2179 # mix-n-match many automake-using packages into one large
2180 # package, and have "dist" at the top level do the right
2182 $output_rules .= ' for subdir in $(SUBDIRS); do \\
2183 test -d $(distdir)/$$subdir \\
2184 || mkdir $(distdir)/$$subdir \\
2186 chmod 755 $(distdir)/$$subdir; \\
2187 (cd $$subdir && $(MAKE) distdir=../$(distdir)/$$subdir distdir) \\
2193 # If the target `dist-hook' exists, make sure it is run. This
2194 # allows users to do random weird things to the distribution
2195 # before it is packaged up.
2196 push (@dist_targets, 'dist-hook') if defined $contents{'dist-hook'};
2199 foreach $targ (@dist_targets)
2201 # We must explicitly set distdir for these sub-makes.
2202 $output_rules .= "\t\$(MAKE) distdir=\"\$(distdir)\" $targ\n";
2205 push (@phony, 'distdir');
2208 # Handle 'dist' target.
2211 # Set up maint_charset.
2212 $local_maint_charset = $contents{'MAINT_CHARSET'}
2213 if &variable_defined ('MAINT_CHARSET');
2214 $maint_charset = $local_maint_charset
2215 if $relative_dir eq '.';
2217 if (&variable_defined ('DIST_CHARSET'))
2219 &am_line_error ('DIST_CHARSET',
2220 "DIST_CHARSET defined but no MAINT_CHARSET defined")
2221 if ! $local_maint_charset;
2222 if ($relative_dir eq '.')
2224 $dist_charset = $contents{'DIST_CHARSET'}
2228 &am_line_error ('DIST_CHARSET',
2229 "DIST_CHARSET can only be defined at top level");
2233 # Look for common files that should be included in distribution.
2235 foreach $cfile (@common_files)
2237 if (-f ($relative_dir . "/" . $cfile))
2239 &push_dist_common ($cfile);
2243 # Keys of %dist_common are names of files to distributed. We put
2244 # README first because it then becomes easier to make a
2245 # Usenet-compliant shar file (in these, README must be first).
2246 # FIXME: do more ordering of files here.
2248 if (defined $dist_common{'README'})
2250 push (@coms, 'README');
2251 delete $dist_common{'README'};
2253 push (@coms, sort keys %dist_common);
2255 &define_pretty_variable ("DIST_COMMON", @coms);
2256 $output_vars .= "\n";
2259 $output_vars .= &file_contents ('dist-vars') . "\n";
2260 &define_variable ('TAR', $TAR);
2261 &define_variable ('GZIP', '--best');
2263 # Put these things in rules section so it is easier for whoever
2264 # reads Makefile.in.
2265 if (! &variable_defined ('distdir'))
2267 if ($relative_dir eq '.')
2269 $output_rules .= "\n" . 'distdir = $(PACKAGE)-$(VERSION)' . "\n";
2273 $output_rules .= ("\n"
2274 . 'distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)'
2278 if ($relative_dir ne '.')
2280 $output_rules .= "\nsubdir = " . $relative_dir . "\n";
2283 # Generate 'dist' target, and maybe dist-shar / dist-zip / dist-tarZ.
2284 if ($relative_dir eq '.')
2286 # Rule to check whether a distribution is viable.
2287 $output_rules .= ('# This target untars the dist file and tries a VPATH configuration. Then
2288 # it guarantees that the distribution is self-contained by making another
2292 GZIP=$(GZIP) $(TAR) zxf $(distdir).tar.gz
2293 mkdir $(distdir)/=build
2294 mkdir $(distdir)/=inst
2295 dc_install_base=`cd $(distdir)/=inst && pwd`; \\'
2296 . (defined $contents{'distcheck-hook'}
2297 ? "\t\$(MAKE) distcheck-hook"
2300 cd $(distdir)/=build \\
2303 . ($seen_gettext ? '--with-included-gettext ' : '')
2304 . '--srcdir=.. --prefix=$$dc_install_base \\
2308 && $(MAKE) install \\
2309 && $(MAKE) installcheck \\
2312 @echo "========================"; \\
2313 echo "$(distdir).tar.gz is ready for distribution"; \\
2314 echo "========================"
2317 local ($dist_all) = ('dist-all: distdir' . "\n"
2320 foreach $curs ('dist', 'dist-shar', 'dist-zip', 'dist-tarZ')
2322 if (defined $options{$curs} || $curs eq 'dist')
2324 $output_rules .= ($curs . ': distdir' . "\n"
2328 $dist_all .= $dist{$curs};
2331 $output_rules .= $dist_all . $dist_trailer;
2334 # Generate distdir target.
2335 &handle_dist_worker;
2338 # Scan a single dependency file and rewrite the dependencies as
2339 # appropriate. Essentially this means:
2340 # * Clean out absolute dependencies which are not desirable.
2341 # * Rewrite other dependencies to be relative to $(top_srcdir).
2342 sub scan_dependency_file
2344 local ($depfile) = @_;
2346 if (! open (DEP_FILE, $depfile))
2348 &am_error ("couldn't open \`$depfile': $!");
2351 print "automake: reading $depfile\n" if $verbose;
2353 # Sometimes it is necessary to omit some dependencies.
2354 local (%omit) = %omit_dependencies;
2355 if (&variable_defined ('OMIT_DEPENDENCIES'))
2357 grep ($omit{$_} = 1, &variable_value_as_list ('OMIT_DEPENDENCIES'));
2360 local ($first_line) = 1;
2361 local ($last_line) = 0;
2362 local ($target, @dependencies);
2363 local ($one_dep, $xform);
2366 local ($srcdir_rx, $fixup_rx);
2367 # If the top srcdir is absolute, then the current directory is
2368 # just relative_dir. But if the top srcdir is relative, then we
2369 # need to add some dots first. The same holds when matching
2371 if ($srcdir_name =~ /^\//)
2373 ($fixup_rx = $srcdir_name . '/' . $relative_dir . '/')
2375 ($srcdir_rx = $srcdir_name . '/') =~ s/(\W)/\\$1/g;
2379 ($fixup_rx = ($srcdir_name . '/' . $top_builddir . '/'
2380 . $relative_dir . '/')) =~ s/(\W)/\\$1/g;
2381 $srcdir_rx = $srcdir_name . '/';
2382 # Don't append a spurious "." to the regex.
2383 $srcdir_rx .= $top_builddir
2384 unless $top_builddir eq '.';
2385 $srcdir_rx =~ s/(\W)/\\$1/g;
2388 local ($rewrite_builddir) = (($top_builddir eq '.')
2390 : $top_builddir . '/');
2396 # If LAST_LINE set then we've already seen what we thought
2397 # was the last line.
2400 next if (/$WHITE_PATTERN/o);
2404 # No trailing "\" means this should be the last line.
2410 if (! /^([^:]+:)(.+)$/)
2413 &am_error ("\`$depfile' has incorrect format");
2424 foreach $one_dep (split (' ', $_))
2426 if ($one_dep =~ /^$fixup_rx/)
2428 # The dependency points to the current directory in
2430 ($xform = $one_dep) =~ s/^$fixup_rx//;
2431 push (@dependencies, $xform);
2433 elsif ($one_dep =~ /^$srcdir_rx/)
2435 # The dependency is in some other directory in the package.
2436 ($xform = $one_dep) =~ s/^$srcdir_rx/$rewrite_builddir/;
2437 push (@dependencies, $xform);
2439 elsif ($one_dep =~ /^\//)
2441 # Absolute path; ignore.
2445 # Anything else is assumed to be correct. But first
2446 # make sure it is not on our list of dependencies to
2448 ($just_file = $one_dep) =~ s,^.*/,,;
2449 push (@dependencies, $one_dep)
2450 if ! defined $omit{$just_file};
2455 &pretty_print_rule ($target, "\t", @dependencies);
2460 # Handle auto-dependency code.
2461 sub handle_dependencies
2463 if ($use_dependencies)
2465 # Include GNU-make-specific auto-dep code.
2466 if ($dir_holds_sources)
2468 &define_pretty_variable ('DEP_FILES', sort keys %dep_files);
2469 $output_rules .= &file_contents ('depend');
2470 push (@clean, 'depend');
2471 &push_phony_cleaners ('depend');
2473 &file_contents_with_transform ('s/\@EXT\@/.c/g;'
2474 . 's/\@MKDEP\@/MKDEP/g;'
2478 local ($need_cxx) = 0;
2479 foreach $ext (sort keys %cxx_extensions)
2482 &file_contents_with_transform ('s/\@EXT\@/' . $ext .'/g;'
2483 . 's/\@MKDEP\@/CXXMKDEP/g;'
2490 &define_variable ('CXXMKDEP', '$(CXX) -M $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CXXFLAGS)');
2494 elsif ($build_directory ne '')
2496 # Include any auto-generated deps that are present. Note that
2497 # $build_directory ends in a "/".
2498 if (-d ($build_directory . $relative_dir . "/.deps")
2499 && -f ($build_directory . $relative_dir . "/.deps/.P"))
2503 foreach $depfile (&my_glob ($build_directory
2504 . $relative_dir . "/.deps/*.P"))
2506 &scan_dependency_file ($depfile);
2509 $output_rules .= "\n";
2514 # Handle subdirectories.
2517 return if ! &variable_defined ('SUBDIRS');
2519 # Make sure each directory mentioned in SUBDIRS actually exists.
2521 foreach $dir (&variable_value_as_list ('SUBDIRS'))
2523 # Skip directories substituted by configure.
2524 next if $dir =~ /^\@.*\@$/;
2526 if (! -d $am_relative_dir . '/' . $dir)
2528 &am_line_error ('SUBDIRS',
2529 "required directory $am_relative_dir/$dir does not exist");
2533 &am_relative_dir ('SUBDIRS',
2534 "directory should not contain \`/'")
2538 local ($xform) = ('s/\@INSTALLINFO\@/' .
2539 (defined $options{'no-installinfo'}
2540 ? 'install-info-recursive'
2543 $output_rules .= &file_contents_with_transform ($xform, 'subdirs');
2545 # Push a bunch of phony targets.
2547 foreach $phonies ('-data', '-exec', 'dirs')
2549 push (@phony, 'install' . $phonies . '-recursive');
2550 push (@phony, 'uninstall' . $phonies . '-recursive');
2552 foreach $phonies ('all', 'check', 'installcheck', 'info', 'dvi')
2554 push (@phony, $phonies . '-recursive');
2556 &push_phony_cleaners ('recursive');
2558 push (@check_tests, "check-recursive");
2559 push (@installcheck, "installcheck-recursive");
2560 push (@info, "info-recursive");
2561 push (@dvi, "dvi-recursive");
2563 $recursive_install = 1;
2566 # Handle aclocal.m4.
2567 sub handle_aclocal_m4
2569 local ($regen_aclocal) = 0;
2570 if (-f 'aclocal.m4')
2572 &define_variable ("ACLOCAL_M4", '$(top_srcdir)/aclocal.m4');
2573 &push_dist_common ('aclocal.m4');
2575 if (open (ACLOCAL, '< aclocal.m4'))
2581 if ($line =~ 'generated automatically by aclocal')
2588 local ($acinclude) = 0;
2589 if (-f 'acinclude.m4')
2595 # Note that it might be possible that aclocal.m4 doesn't exist but
2596 # should be auto-generated. This case probably isn't very
2600 local (@ac_deps) = (
2601 ($seen_maint_mode ? "\@MAINT\@" : "") ,
2603 ($acinclude ? ' acinclude.m4' : '')
2606 # Scan all -I directories for m4 files. These are our
2608 if (&variable_defined ('ACLOCAL_AMFLAGS'))
2611 foreach $amdir (&variable_value_as_list ('ACLOCAL_AMFLAGS'))
2613 if ($amdir =~ s/^-I//
2617 push (@ac_deps, &my_glob ($am_dir . '/*.m4'));
2622 &pretty_print_rule ("\$(srcdir)/aclocal.m4:", "\t\t", @ac_deps);
2624 $output_rules .= ("\t"
2625 . 'cd $(srcdir) && $(ACLOCAL)'
2626 . (&variable_defined ('ACLOCAL_AMFLAGS')
2627 ? ' $(ACLOCAL_AMFLAGS)' : '')
2632 # Rewrite a list of input files into a form suitable to put on a
2633 # dependency list. The idea is that if an input file has a directory
2634 # part the same as the current directory, then the directory part is
2635 # simply removed. But if the directory part is different, then
2636 # $(top_srcdir) is prepended. Among other things, this is used to
2637 # generate the dependency list for the output files generated by
2638 # AC_OUTPUT. Consider what the dependencies should look like in this
2640 # AC_OUTPUT(src/out:src/in1:lib/in2)
2641 sub rewrite_inputs_into_dependencies
2643 local (@inputs) = @_;
2644 local ($single, @newinputs);
2646 foreach $single (@inputs)
2648 if (&dirname ($single) eq $relative_dir)
2650 push (@newinputs, &basename ($single));
2654 push (@newinputs, '$(top_srcdir)/' . $single);
2661 # Handle remaking and configure stuff.
2662 # We need the name of the input file, to do proper remaking rules.
2663 sub handle_configure
2665 local ($local, $input, @secondary_inputs) = @_;
2667 # If SUBDIRS defined, require AC_PROG_MAKE_SET.
2668 &am_line_error ('SUBDIRS', "AC_PROG_MAKE_SET must be used in configure.in")
2669 if &variable_defined ('SUBDIRS') && ! $seen_make_set;
2671 local ($top_reldir);
2673 local ($input_base) = &basename ($input);
2674 local ($local_base) = &basename ($local);
2676 local ($amfile) = $input_base . '.am';
2677 # We know we can always add '.in' because it really should be an
2678 # error if the .in was missing originally.
2679 local ($infile) = '$(srcdir)/' . $input_base . '.in';
2680 local ($colon_infile);
2681 if ($local ne $input)
2683 $colon_infile = ':' . $input . '.in';
2685 $colon_infile .= ':' . join (':', @secondary_inputs)
2686 if @secondary_inputs;
2688 local (@rewritten) = &rewrite_inputs_into_dependencies (@secondary_inputs);
2689 # This rule remakes the Makefile.in. Note use of @MAINT@ forces
2690 # us to abandon pretty-printing. Sigh.
2691 $output_rules .= ($infile
2692 # NOTE perl 5.003 (with -w) gives a
2693 # uninitialized value error on the next line.
2696 . ($seen_maint_mode ? '@MAINT@ ' : '')
2698 . '$(top_srcdir)/configure.in $(ACLOCAL_M4) '
2699 . join (' ', @rewritten) . "\n"
2700 . "\tcd \$(top_srcdir) && \$(AUTOMAKE) "
2701 . ($cygnus_mode ? '--cygnus' : ('--' . $strictness_name))
2702 . ' ' . $input . $colon_infile . "\n\n");
2704 # This rule remakes the Makefile.
2705 $output_rules .= ($local_base
2706 # NOTE: bogus uninit value error on next line;
2707 # see comment above.
2710 . '$(top_builddir)/config.status $(BUILT_SOURCES)'
2712 . "\tcd \$(top_builddir) \\\n"
2713 . "\t && CONFIG_FILES="
2714 . (($relative_dir eq '.') ? '$@' : '$(subdir)/$@')
2716 . ' CONFIG_HEADERS= $(SHELL) ./config.status'
2719 if ($relative_dir ne '.')
2722 $top_reldir = '../';
2727 $output_rules .= &file_contents ('remake');
2728 &examine_variable ('CONFIGURE_DEPENDENCIES');
2732 # If we have a configure header, require it.
2733 if ($config_header && $relative_dir eq &dirname ($config_header))
2735 local ($ch_sans_dir) = &basename ($config_header);
2736 local ($cn_sans_dir) = &basename ($config_name);
2738 &require_file_with_conf_line ($config_header_line,
2739 $FOREIGN, $ch_sans_dir);
2741 # Header defined and in this directory.
2743 if (-f $relative_dir . '/acconfig.h')
2745 push (@files, 'acconfig.h');
2747 if (-f $config_name . '.top')
2749 push (@files, "${cn_sans_dir}.top");
2751 if (-f $config_name . '.bot')
2753 push (@files, "${cn_sans_dir}.bot");
2756 &push_dist_common (@files);
2757 $output_rules .= &file_contents_with_transform ('s/\@FILES\@/'
2758 . join (' ', @files)
2762 &touch ($relative_dir . '/stamp-h.in');
2763 &require_file_with_conf_line ($config_header_line, $FOREIGN,
2766 push (@clean, 'hdr');
2767 &push_phony_cleaners ('hdr');
2768 &define_variable ("CONFIG_HEADER_IN", "${ch_sans_dir}");
2769 &define_variable ('CONFIG_HEADER_FULL', $config_name);
2772 # Set location of mkinstalldirs.
2773 if ($config_aux_dir ne '.' && $config_aux_dir ne '')
2775 &define_variable ('mkinstalldirs', ('$(SHELL) ' . $config_aux_dir
2776 . '/mkinstalldirs'));
2780 &define_variable ('mkinstalldirs',
2781 '$(SHELL) $(top_srcdir)/mkinstalldirs');
2784 &am_line_error ('CONFIG_HEADER',
2785 "\`CONFIG_HEADER' is an anachronism; now determined from \`configure.in'")
2786 if &variable_defined ('CONFIG_HEADER');
2790 # Generate CONFIG_HEADER define.
2791 if ($relative_dir eq &dirname ($config_name))
2793 &define_variable ("CONFIG_HEADER", &basename ($config_name));
2797 &define_variable ("CONFIG_HEADER",
2798 "${top_builddir}/${config_name}");
2802 # Now look for other files in this directory which must be remade
2803 # by config.status, and generate rules for them.
2804 local (@actual_other_files) = ();
2805 local ($file, $local);
2806 local (@inputs, @rewritten_inputs, $single);
2807 foreach $file (@other_input_files)
2809 if ($file =~ /^(.*):(.*)$/)
2811 # This is the ":" syntax of AC_OUTPUT.
2813 $local = &basename ($file);
2814 @inputs = split (':', $2);
2815 @rewritten_inputs = &rewrite_inputs_into_dependencies (@inputs);
2820 $local = &basename ($file);
2821 @inputs = ($local . '.in');
2823 &rewrite_inputs_into_dependencies ($file . '.in');
2826 # Skip files not in this directory.
2827 next unless &dirname ($file) eq $relative_dir;
2829 # Skip the config header.
2830 next if $local eq $top_builddir . '/' . $config_name;
2832 # Skip any Makefile.
2833 next if $local eq 'Makefile';
2835 $output_rules .= ($local . ': '
2836 . '$(top_builddir)/config.status '
2837 . join (' ', @rewritten_inputs) . "\n"
2839 . 'cd $(top_builddir) && CONFIG_FILES='
2840 . ($relative_dir eq '.' ? '' : '$(subdir)/')
2841 . '$@' . (length (@rewritten_inputs) > 1
2842 ? (':' . join (':', @rewritten_inputs))
2844 . ' CONFIG_HEADERS= ./config.status'
2846 push (@actual_other_files, $local);
2848 # Require all input files.
2849 &require_file_with_conf_line ($ac_output_line, $FOREIGN,
2853 # These files get removed by "make clean".
2854 &define_pretty_variable ('CONFIG_CLEAN_FILES', @actual_other_files);
2860 $dir_holds_headers = &am_install_var ('header', 'HEADERS', 'include',
2861 'oldinclude', 'pkginclude',
2867 return if ! $seen_gettext || $relative_dir ne '.';
2869 if (! &variable_defined ('SUBDIRS'))
2872 ("AM_GNU_GETTEXT in configure.in but SUBDIRS not defined");
2876 &require_file_with_conf_line ($ac_gettext_line, $FOREIGN, 'ABOUT-NLS')
2879 if (&variable_defined ('SUBDIRS'))
2883 "AM_GNU_GETTEXT in configure.in but \`po' not in SUBDIRS")
2884 if $contents{'SUBDIRS'} !~ /\bpo\b/;
2887 "AM_GNU_GETTEXT in configure.in but \`intl' not in SUBDIRS")
2888 if $contents{'SUBDIRS'} !~ /\bintl\b/;
2891 # Ensure that each language in ALL_LINGUAS has a .po file, and
2892 # each po file is mentioned in ALL_LINGUAS.
2895 local (%linguas) = ();
2896 grep ($linguas{$_} = 1, split (' ', $all_linguas));
2903 &am_line_error ($all_linguas_line,
2904 ("po/$_.po exists but \`$_' not in \`ALL_LINGUAS'"))
2908 foreach (keys %linguas)
2910 &am_line_error ($all_linguas_line,
2911 "$_ in \`ALL_LINGUAS' but po/$_.po does not exist")
2917 &am_error ("AM_GNU_GETTEXT in configure.in but \`ALL_LINGUAS' not defined");
2921 # Handle footer elements.
2924 if ($contents{'SOURCES'})
2926 # NOTE don't use define_pretty_variable here, because
2927 # $contents{...} is already defined.
2928 $output_vars .= 'SOURCES = ' . $contents{'SOURCES'} . "\n";
2930 if ($contents{'OBJECTS'})
2932 # NOTE don't use define_pretty_variable here, because
2933 # $contents{...} is already defined.
2934 $output_vars .= 'OBJECTS = ' . $contents{'OBJECTS'} . "\n";
2936 if ($contents{'SOURCES'} || $contents{'OBJECTS'})
2938 $output_vars .= "\n";
2941 if (&variable_defined ('SUFFIXES'))
2943 # Push actual suffixes, and not $(SUFFIXES). Some versions of
2944 # make do not like variable substitutions on the .SUFFIXES
2946 push (@suffixes, &variable_value_as_list ('SUFFIXES'));
2948 if (&target_defined ('.SUFFIXES'))
2950 &am_line_error ('.SUFFIXES',
2951 "use variable \`SUFFIXES', not target \`.SUFFIXES'");
2954 # Note: AIX 4.1 /bin/make will fail if any suffix rule appears
2955 # before .SUFFIXES. So we make sure that .SUFFIXES appears before
2956 # anything else, by sticking it right after the default: target.
2957 $output_header .= ".SUFFIXES:\n";
2960 $output_header .= ".SUFFIXES: " . join (' ', @suffixes) . "\n";
2962 $output_trailer .= &file_contents ('footer');
2965 # Deal with installdirs target.
2966 sub handle_installdirs
2968 # GNU Makefile standards recommend this.
2969 $output_rules .= ("installdirs:"
2970 . ($recursive_install
2971 ? " installdirs-recursive\n"
2973 push (@phony, 'installdirs');
2976 &pretty_print_rule ("\t" . '$(mkinstalldirs) ', "\t\t",
2979 $output_rules .= "\n";
2982 # There are several targets which need to be merged. This is because
2983 # their complete definition is compiled from many parts. Note that we
2984 # avoid double colon rules, otherwise we'd use them instead.
2985 sub handle_merge_targets
2987 # There are a few install-related variables that you should not define.
2989 foreach $var ('PRE_INSTALL', 'POST_INSTALL', 'NORMAL_INSTALL')
2991 if (&variable_defined ($var))
2993 &am_line_error ($var, "\`$var' should not be defined");
2997 push (@all, 'Makefile');
2998 push (@all, &basename ($config_name))
2999 if $config_name && &dirname ($config_name) eq $relative_dir;
3001 &do_one_merge_target ('info', @info);
3002 &do_one_merge_target ('dvi', @dvi);
3003 &do_check_merge_target;
3004 &do_one_merge_target ('installcheck', @installcheck);
3006 if (defined $options{'no-installinfo'})
3008 # FIXME: this is kind of a hack; should find another way to
3009 # know that this is required.
3011 if (grep ($_ eq 'install-info-am', @phony))
3013 push (@dirs, 'install-info-am');
3015 if (&variable_defined ('SUBDIRS'))
3017 push (@dirs, 'install-info-recursive');
3019 &do_one_merge_target ('install-info', @dirs);
3022 # Handle the various install targets specially. We do this so
3023 # that (eg) "make install-exec" will run "install-exec-recursive"
3024 # if required, but "make install" won't run it twice. Step one is
3025 # to see if the user specified local versions of any of the
3026 # targets we handle. "all" is treated as one of these since
3027 # "install" can run it.
3028 push (@install_exec, 'install-exec-local')
3029 if defined $contents{'install-exec-local'};
3030 push (@install_data, 'install-data-local')
3031 if defined $contents{'install-data-local'};
3032 push (@uninstall, 'uninstall-local')
3033 if defined $contents{'uninstall-local'};
3035 foreach $utarg ('uninstall-data-local', 'uninstall-data-hook',
3036 'uninstall-exec-local', 'uninstall-exec-hook')
3038 if (defined $contents{$utarg})
3041 ($x = $utarg) =~ s/(data|exec)-//;
3042 &am_line_error ($utarg, "use \`$x', not \`$utarg'");
3045 push (@all, 'all-local')
3046 if defined $contents{'all-local'};
3048 if (defined $contents{'install-local'})
3050 &am_line_error ('install-local',
3051 "use \`install-data' or \`install-exec', not \`install'");
3054 # Step two: if we are doing recursive makes, write out the
3055 # appropriate rules.
3057 if ($recursive_install)
3059 push (@install, 'install-recursive');
3063 local (@hackall) = ();
3064 if ($config_name && &dirname ($config_name) eq $relative_dir)
3067 # This is kind of a hack, but I couldn't see a better
3068 # way to handle it. In this particular case, we need
3069 # to make sure config.h is built before we recurse.
3070 # We can't do this by changing the order of
3071 # dependencies to the "all" because that breaks when
3072 # using parallel makes. Instead we handle things
3074 $output_rules .= ('all-recursive-am: $(CONFIG_HEADER)'
3075 . "\n\t" . '$(MAKE) all-recursive'
3077 push (@hackall, 'all-recursive-am');
3078 push (@phony, 'all-recursive-am');
3082 push (@hackall, 'all-recursive');
3085 $output_rules .= ('all-am: '
3089 push (@all, 'all-am');
3090 push (@phony, 'all-am');
3094 @all = ('all-recursive');
3096 # Must always generate `all-am' target, so it can be
3097 # referred to elsewhere.
3098 $output_rules .= "all-am:\n";
3102 $output_rules .= ('install-exec-am: '
3103 . join (' ', @install_exec)
3105 @install_exec = ('install-exec-recursive', 'install-exec-am');
3106 push (@install, 'install-exec-am');
3107 push (@phony, 'install-exec-am');
3111 @install_exec = ('install-exec-recursive');
3115 $output_rules .= ('install-data-am: '
3116 . join (' ', @install_data)
3118 @install_data = ('install-data-recursive', 'install-data-am');
3119 push (@install, 'install-data-am');
3120 push (@phony, 'install-data-am');
3124 @install_data = ('install-data-recursive');
3128 $output_rules .= ('uninstall-am: '
3129 . join (' ', @uninstall)
3131 @uninstall = ('uninstall-recursive', 'uninstall-am');
3132 push (@phony, 'uninstall-am');
3136 @uninstall = ('uninstall-recursive');
3140 # Step three: print definitions users can use. Code below knows
3141 # that install-exec is done before install-data, beware.
3142 $output_rules .= ("install-exec: "
3143 . join (' ', @install_exec)
3145 $output_rules .= "\t\$(NORMAL_INSTALL)\n";
3146 if (defined $contents{'install-exec-hook'})
3148 $output_rules .= "\t" . '$(MAKE) install-exec-hook' . "\n";
3150 $output_rules .= "\n";
3151 push (@install, 'install-exec') if !$recursive_install;
3152 push (@phony, 'install-exec');
3154 $output_rules .= ("install-data: "
3155 . join (' ', @install_data)
3157 $output_rules .= "\t\$(NORMAL_INSTALL)\n";
3158 if (defined $contents{'install-data-hook'})
3160 $output_rules .= "\t" . '$(MAKE) install-data-hook' . "\n";
3162 $output_rules .= "\n";
3163 push (@install, 'install-data') if !$recursive_install;
3164 push (@phony, 'install-data');
3166 # If no dependencies for 'install', add 'all'. Why? That way
3167 # "make install" at top level of distclean'd distribution won't
3168 # fail because stuff in 'lib' fails to build.
3169 if (! @install || (scalar (@install) == 2
3170 && $install[0] eq 'install-exec'
3171 && $install[1] eq 'install-data'))
3173 push (@install, 'all');
3175 $output_rules .= ('install: '
3176 . join (' ', @install)
3177 # Use "@:" as empty command so nothing prints.
3181 . join (' ', @uninstall)
3183 push (@phony, 'install', 'uninstall');
3185 $output_rules .= ('all: '
3188 push (@phony, 'all');
3190 # Generate the new 'install-strip' target.
3191 $output_rules .= ("install-strip:\n\t"
3192 . '$(MAKE) INSTALL_PROGRAM=\'$(INSTALL_PROGRAM) -s\' install'
3196 # Helper for handle_merge_targets.
3197 sub do_one_merge_target
3199 local ($name, @values) = @_;
3201 if (defined $contents{$name . '-local'})
3203 # User defined local form of target. So include it.
3204 push (@values, $name . '-local');
3205 push (@phony, $name . '-local');
3208 &pretty_print_rule ($name . ":", "\t\t", @values);
3209 push (@phony, $name);
3212 # Handle check merge target specially.
3213 sub do_check_merge_target
3215 if (defined $contents{'check-local'})
3217 # User defined local form of target. So include it.
3218 push (@check_tests, 'check-local');
3219 push (@phony, 'check-local');
3222 if (! &variable_defined ('SUBDIRS'))
3224 # 'check' must depend on `all', but not when doing recursive
3226 unshift (@check, 'all');
3230 # When subdirs are used, do the `all' build and then do all
3231 # the recursive stuff. Actually use `all-am' because it
3232 # doesn't recurse; we rely on the check target in the subdirs
3233 # to do the required builds there.
3234 unshift (@check, 'all-am');
3237 # The check target must depend on the local equivalent of `all',
3238 # to ensure all the primary targets are built. Also it must
3239 # depend on the test code named in @check.
3240 &pretty_print_rule ('check:', "\t\t", @check);
3242 # Now the check rules must explicitly run anything named in
3243 # @check_tests. This is done via a separate make invocation to
3244 # avoid problems with parallel makes. Every time I write code
3245 # like this I wonder: how could you invent a parallel make and not
3246 # provide any real synchronization facilities?
3247 &pretty_print_rule ("\t\$(MAKE)", "\t ", @check_tests);
3250 # Handle all 'clean' targets.
3253 push (@clean, 'generic');
3254 $output_rules .= &file_contents ('clean');
3255 &push_phony_cleaners ('generic');
3257 local ($target) = $recursive_install ? 'clean-am' : 'clean';
3258 &do_one_clean_target ($target, 'mostly', '', @clean);
3259 &do_one_clean_target ($target, '', 'mostly', @clean);
3260 &do_one_clean_target ($target, 'dist', '', @clean);
3261 &do_one_clean_target ($target, 'maintainer-', 'dist', @clean);
3263 push (@phony, 'clean', 'mostlyclean', 'distclean', 'maintainer-clean');
3266 if ($recursive_install)
3268 # Do -recursive before -am. If you aren't doing a parallel
3269 # make, this can be nicer.
3270 @deps = ('recursive', 'am');
3271 &do_one_clean_target ('', 'mostly', '', @deps);
3272 &do_one_clean_target ('', '', '', @deps);
3273 &do_one_clean_target ('', 'dist', '', @deps);
3274 &do_one_clean_target ('', 'maintainer-', '', @deps);
3278 # Helper for handle_clean.
3279 sub do_one_clean_target
3281 local ($target, $name, $last_name, @deps) = @_;
3283 # Special case: if target not passed, then don't generate
3284 # dependency on next "lower" clean target (eg no
3285 # clean<-mostlyclean derivation). In this case the target is
3286 # implicitly known to be 'clean'.
3287 local ($flag) = $target;
3288 $target = 'clean' if ! $flag;
3290 grep (($_ = $name . 'clean-' . $_) && 0, @deps);
3293 if ($last_name || $name ne 'mostly')
3295 push (@deps, $last_name . $target);
3299 # If a -local version of the rule is given, add it to the list.
3300 if (defined $contents{$name . $target . '-local'})
3302 push (@deps, $name . $target . '-local');
3305 # Print the target and the dependencies.
3306 &pretty_print_rule ($name . $target . ": ", "\t\t", @deps);
3308 # FIXME: shouldn't we really print these messages before running
3310 if ($name . $target eq 'maintainer-clean')
3312 # Print a special warning.
3314 ("\t\@echo \"This command is intended for maintainers to use;\"\n"
3315 . "\t\@echo \"it deletes files that may require special "
3316 . "tools to rebuild.\"\n");
3318 $output_rules .= "\trm -f config.status\n"
3319 if $relative_dir eq '.';
3321 elsif ($name . $target eq 'distclean')
3323 $output_rules .= "\trm -f config.status\n";
3324 $output_rules .= "\trm -f libtool\n" if $seen_libtool;
3326 $output_rules .= "\n";
3329 # Handle .PHONY target.
3332 &pretty_print_rule ('.PHONY:', "", @phony);
3333 $output_rules .= "\n";
3336 # Handle TESTS variable and other checks.
3339 if (defined $options{'dejagnu'})
3341 push (@check_tests, 'check-DEJAGNU');
3342 push (@phony, 'check-DEJAGNU');
3347 $xform = 's/^CYGNUS//;';
3351 $xform = 's/^CYGNUS.*$//;';
3353 $output_rules .= &file_contents_with_transform ($xform, 'dejagnu');
3355 # In Cygnus mode, these are found in the build tree.
3356 # Otherwise they are looked for in $PATH.
3357 &define_program_variable ('EXPECT', 'build', 'expect', 'expect');
3358 &define_program_variable ('RUNTEST', 'src', 'dejagnu', 'runtest');
3360 # Note that in the rule we don't directly generate site.exp to
3361 # avoid the possibility of a corrupted site.exp if make is
3362 # interrupted. Jim Meyering has some useful text on this
3364 $output_rules .= ("site.exp: Makefile\n"
3365 . "\t\@echo 'Making a new site.exp file...'\n"
3366 . "\t-\@rm -f site.bak\n"
3367 . "\t\@echo '## these variables are automatically generated by make ##' > \$\@-t\n"
3368 . "\t\@echo '# Do not edit here. If you wish to override these values' >> \$\@-t\n"
3369 . "\t\@echo '# edit the last section' >> \$\@-t\n"
3370 . "\t\@echo 'set tool \$(DEJATOOL)' >> \$\@-t\n"
3371 . "\t\@echo 'set srcdir \$(srcdir)' >> \$\@-t\n"
3372 . "\t\@echo 'set objdir' \`pwd\` >> \$\@-t\n");
3374 # Extra stuff for AC_CANONICAL_*
3375 local (@whatlist) = ();
3376 if ($seen_canonical)
3378 push (@whatlist, 'host')
3381 # Extra stuff only for AC_CANONICAL_SYSTEM.
3382 if ($seen_canonical == $AC_CANONICAL_SYSTEM)
3384 push (@whatlist, 'target', 'build');
3388 foreach $c1 (@whatlist)
3390 foreach $c2 ('alias', 'triplet')
3392 $output_rules .= "\t\@echo 'set ${c1}_${c2} \$(${c1}_${c2})' >> \$\@-t\n";
3396 $output_rules .= ("\t\@echo '## All variables above are generated by configure. Do Not Edit ##' >> \$\@-t\n"
3397 . "\t-\@sed '1,/^## All variables above are.*##/ d' site.bak >> \$\@-t\n"
3398 . "\t-\@mv site.exp site.bak\n"
3399 . "\t\@mv \$\@-t site.exp\n");
3404 foreach $c ('DEJATOOL', 'RUNTEST', 'RUNTESTFLAGS')
3406 if (&variable_defined ($c))
3408 &am_line_error ($c, "\`$c' defined but \`dejagnu' not in \`AUTOMAKE_OPTIONS'");
3413 if (&variable_defined ('TESTS'))
3415 push (@check_tests, 'check-TESTS');
3416 push (@phony, 'check-TESTS');
3418 $output_rules .= 'check-TESTS: $(TESTS)
3419 @failed=0; all=0; \\
3420 srcdir=$(srcdir); export srcdir; \\
3421 for tst in $(TESTS); do \\
3422 all=`expr $$all + 1`; \\
3423 if test -f $$tst; then dir=.; \\
3424 else dir="$(srcdir)"; fi; \\
3425 if $(TESTS_ENVIRONMENT) $$dir/$$tst; then \\
3426 echo "PASS: $$tst"; \\
3428 failed=`expr $$failed + 1`; \\
3429 echo "FAIL: $$tst"; \\
3432 if test "$$failed" -eq 0; then \\
3433 echo "========================"; \\
3434 echo "All $$all tests passed"; \\
3435 echo "========================"; \\
3437 echo "$$failed of $$all tests failed"; \\
3444 # Handle Emacs Lisp.
3445 sub handle_emacs_lisp
3447 local (@elfiles) = &am_install_var ('lisp', 'LISP', 'lisp', 'noinst');
3452 &define_configure_variable ('lispdir');
3453 &define_configure_variable ('EMACS');
3454 $output_rules .= (".el.elc:\n"
3455 . "\t\@echo 'WARNING: Warnings can be ignored. :-)'\n"
3456 . "\tif test \$(EMACS) != no; then \\\n"
3457 . "\t EMACS=\$(EMACS) \$(SHELL) \$(srcdir)/elisp-comp \$<; \\\n"
3459 push (@suffixes, '.el', '.elc');
3461 # Generate .elc files.
3462 grep ($_ .= 'c', @elfiles);
3463 &define_pretty_variable ('ELCFILES', @elfiles);
3465 push (@clean, 'lisp');
3466 &push_phony_cleaners ('lisp');
3468 push (@all, '$(ELCFILES)');
3471 if (&variable_defined ('lisp_LISP'))
3473 $varname = 'lisp_LISP';
3474 &am_error ("\`lisp_LISP' defined but \`AM_PATH_LISPDIR' not in \`configure.in'")
3479 $varname = 'noinst_LISP';
3482 &require_file_with_line ($varname, $FOREIGN, 'elisp-comp');
3486 ################################################################
3488 # Scan one file for interesting things. Subroutine of scan_configure.
3489 sub scan_one_configure_file
3491 local ($filename) = @_;
3493 open (CONFIGURE, $filename)
3494 || die "automake: couldn't open \`$filename': $!\n";
3495 print "automake: reading $filename\n" if $verbose;
3499 # Remove comments from current line.
3503 # Skip macro definitions. Otherwise we might be confused into
3504 # thinking that a macro that was only defined was actually
3508 # Populate libobjs array.
3509 if (/AC_FUNC_ALLOCA/)
3511 $libsources{'alloca.c'} = 1;
3513 elsif (/AC_FUNC_GETLOADAVG/)
3515 $libsources{'getloadavg.c'} = 1;
3517 elsif (/AC_FUNC_MEMCMP/)
3519 $libsources{'memcmp.c'} = 1;
3521 elsif (/AC_STRUCT_ST_BLOCKS/)
3523 $libsources{'fileblocks.c'} = 1;
3525 elsif (/A[CM]_REPLACE_GNU_GETOPT/)
3527 $libsources{'getopt.c'} = 1;
3528 $libsources{'getopt1.c'} = 1;
3530 elsif (/AM_FUNC_STRTOD/)
3532 $libsources{'strtod.c'} = 1;
3534 elsif (/AM_WITH_REGEX/)
3536 $libsources{'rx.c'} = 1;
3537 $libsources{'rx.h'} = 1;
3538 $libsources{'regex.c'} = 1;
3539 $libsources{'regex.h'} = 1;
3540 $omit_dependencies{'rx.h'} = 1;
3541 $omit_dependencies{'regex.h'} = 1;
3543 elsif (/AM_FUNC_MKTIME/)
3545 $libsources{'mktime.c'} = 1;
3547 elsif (/AM_FUNC_ERROR_AT_LINE/)
3549 $libsources{'error.c'} = 1;
3550 $libsources{'error.h'} = 1;
3552 elsif (/AM_FUNC_OBSTACK/)
3554 $libsources{'obstack.c'} = 1;
3555 $libsources{'obstack.h'} = 1;
3557 elsif (/LIBOBJS="(.*)\s+\$LIBOBJS"/
3558 || /LIBOBJS="\$LIBOBJS\s+(.*)"/)
3560 foreach $libobj_iter (split (' ', $1))
3562 if ($libobj_iter =~ /^(.*)\.o$/)
3564 $libsources{$1 . '.c'} = 1;
3569 if (! $in_ac_replace && s/AC_REPLACE_FUNCS\s*\(\[?//)
3575 $in_ac_replace = 0 if s/[\]\)].*$//;
3576 # Remove trailing backslash.
3580 # Need to skip empty elements for Perl 4.
3582 $libsources{$_ . '.c'} = 1;
3586 if (/$obsolete_rx/o)
3589 if ($obsolete_macros{$1})
3591 $hint = '; ' . $obsolete_macros{$1};
3593 &am_conf_line_error ($filename, $., "\`$1' is obsolete$hint");
3596 # Process the AC_OUTPUT macro.
3597 if (! $in_ac_output && s/AC_OUTPUT\s*\(\[?//)
3600 $ac_output_line = $.;
3604 $in_ac_output = 0 if s/[\]\),].*$//;
3606 # Look at potential Makefile.am's.
3611 # Handle $local:$input syntax. Note that we ignore
3612 # every input file past the first, though we keep
3613 # those around for later.
3614 local ($local, $input, @rest) = split (/:/);
3621 # FIXME: should be error if .in is missing.
3622 $input =~ s/\.in$//;
3625 if (-f $input . '.am')
3627 # We have a file that automake should generate.
3628 push (@make_input_list, $input);
3629 $make_list{$input} = join (':', ($local, @rest));
3633 # We have a file that automake should cause to be
3634 # rebuilt, but shouldn't generate itself.
3635 push (@other_input_files, $_);
3640 if (/$AC_CONFIG_AUX_DIR_PATTERN/o)
3642 @config_aux_path = $1;
3645 # Check for ansi2knr.
3646 $am_c_prototypes = 1 if /AM_C_PROTOTYPES/;
3648 # Check for Cygwin32.
3652 $configure_vars{'EXEEXT'} = 1;
3655 # Check for NLS support.
3656 if (/AM_GNU_GETTEXT/)
3659 $ac_gettext_line = $.;
3660 $omit_dependencies{'libintl.h'} = 1;
3663 # Look for ALL_LINGUAS.
3664 if (/ALL_LINGUAS="(.*)"$/ || /ALL_LINGUAS=(.*)$/)
3668 $all_linguas_line = $.;
3671 # Handle configuration headers. A config header of `[$1]'
3672 # means we are actually scanning AM_CONFIG_HEADER from
3674 if (/A([CM])_CONFIG_HEADER\s*\((.*)\)/
3679 "\`AC_CONFIG_HEADER' is obsolete; use \`AM_CONFIG_HEADER'")
3682 $config_header_line = $.;
3684 if ($config_name =~ /^([^:]+):(.+)$/)
3687 $config_header = $2;
3691 $config_header = $config_name . '.in';
3695 # Handle AC_CANONICAL_*. Always allow upgrading to
3696 # AC_CANONICAL_SYSTEM, but never downgrading.
3697 $seen_canonical = $AC_CANONICAL_HOST
3698 if ! $seen_canonical
3699 && (/AC_CANONICAL_HOST/ || /AC_CHECK_TOOL/);
3700 $seen_canonical = $AC_CANONICAL_SYSTEM if /AC_CANONICAL_SYSTEM/;
3702 $seen_path_xtra = 1 if /AC_PATH_XTRA/;
3704 # This macro handles several different things.
3705 if (/$AM_INIT_AUTOMAKE_PATTERN/o)
3711 $seen_prog_install = 2;
3712 ($package_version = $1) =~ s/$AM_PACKAGE_VERSION_PATTERN/$1/o;
3713 $package_version_line = $.;
3716 # This is like AM_INIT_AUTOMAKE, but doesn't actually set the
3717 # package and version number. (This might change in the
3718 # future). Yes, I'm not above hacking Automake so it works
3719 # well with other GNU tools -- that is actually the point.
3720 if (/AM_INIT_GUILE_MODULE/)
3726 $seen_prog_install = 2;
3727 @config_aux_path = ('..');
3730 # Some things required by Automake.
3731 $seen_make_set = 1 if /AC_PROG_MAKE_SET/;
3732 $seen_arg_prog = 1 if /AC_ARG_PROGRAM/;
3734 if (/AC_PROG_(YACC|RANLIB|CC|CXX|LEX)/)
3736 $configure_vars{$1} = 1;
3738 if (/$AC_CHECK_PATTERN/o)
3740 $configure_vars{$3} = 1;
3742 if (/$AC_SUBST_PATTERN/o)
3744 $configure_vars{$1} = 1;
3747 $seen_decl_yytext = 1 if /AC_DECL_YYTEXT/;
3748 $seen_maint_mode = 1 if /AM_MAINTAINER_MODE/;
3749 $seen_package = 1 if /PACKAGE=/;
3751 # Skip VERSION of [$2]; that is from AM_INIT_AUTOMAKE.
3752 if (/\bVERSION=(\S+)/ && $1 ne '[$2]')
3755 $package_version = $1;
3756 $package_version_line = $.;
3763 # Weird conditionals here because it is always allowed to
3764 # upgrade to AM_PROG_INSTALL but never to downgrade to
3766 $seen_prog_install = 1 if ! $seen_prog_install && /AC_PROG_INSTALL/;
3767 $seen_prog_install = 2 if /AM_PROG_INSTALL/;
3769 $seen_lispdir = 1 if /AM_PATH_LISPDIR/;
3771 if (/AM_PROG_LIBTOOL/)
3775 $configure_vars{'LIBTOOL'} = 1;
3776 $configure_vars{'RANLIB'} = 1;
3777 $configure_vars{'CC'} = 1;
3778 # AM_PROG_LIBTOOL runs AC_CANONICAL_HOST. Make sure we
3779 # never downgrade (if we've seen AC_CANONICAL_SYSTEM).
3780 $seen_canonical = $AC_CANONICAL_HOST if ! $seen_canonical;
3787 # Scan configure.in and aclocal.m4 for interesting things. We must
3788 # scan aclocal.m4 because there might be AC_SUBSTs and such there.
3791 # Reinitialize libsources here. This isn't really necessary,
3792 # since we currently assume there is only one configure.in. But
3793 # that won't always be the case.
3796 local ($in_ac_output, $in_ac_replace) = (0, 0);
3797 local (%make_list, @make_input_list);
3798 local ($libobj_iter);
3800 &scan_one_configure_file ('configure.in');
3801 &scan_one_configure_file ('aclocal.m4')
3804 # Set input and output files if not specified by user.
3807 @input_files = @make_input_list;
3808 %output_files = %make_list;
3811 &am_conf_error ("\`PACKAGE' not defined in configure.in")
3813 &am_conf_error ("\`VERSION' not defined in configure.in")
3816 # Look for some files we need. Always check for these. This
3817 # check must be done for every run, even those where we are only
3818 # looking at a subdir Makefile. We must set relative_dir so that
3819 # the file-finding machinery works.
3820 local ($relative_dir) = '.';
3821 &require_config_file ($FOREIGN, 'install-sh', 'mkinstalldirs', 'missing');
3822 &am_error ("\`install.sh' is an anachronism; use \`install-sh' instead")
3823 if -f $config_aux_path[0] . '/install.sh';
3826 ################################################################
3828 # Set up for Cygnus mode.
3831 return unless $cygnus_mode;
3833 &set_strictness ('foreign');
3834 $options{'no-installinfo'} = 1;
3835 $options{'no-dependencies'} = 1;
3836 $use_dependencies = 0;
3838 if (! $seen_maint_mode)
3840 &am_conf_error ("\`AM_MAINTAINER_MODE' required when --cygnus specified");
3843 if (! $seen_cygwin32)
3845 &am_conf_error ("\`AM_CYGWIN32' required when --cygnus specified");
3849 # Do any extra checking for GNU standards.
3850 sub check_gnu_standards
3852 if ($relative_dir eq '.')
3854 # In top level (or only) directory.
3855 &require_file ($GNU, 'INSTALL', 'NEWS', 'README', 'COPYING',
3856 'AUTHORS', 'ChangeLog');
3859 if ($strictness >= $GNU)
3861 if (defined $options{'no-installman'})
3863 &am_line_error ('AUTOMAKE_OPTIONS',
3864 "option \`no-installman' disallowed by GNU standards");
3867 if (defined $options{'no-installinfo'})
3869 &am_line_error ('AUTOMAKE_OPTIONS',
3870 "option \`no-installinfo' disallowed by GNU standards");
3875 # Do any extra checking for GNITS standards.
3876 sub check_gnits_standards
3878 if ($strictness >= $GNITS)
3880 if (-f $relative_dir . '/COPYING.LIB')
3882 &am_error ("\`${relative_dir}/COPYING.LIB' disallowed by Gnits standards");
3885 if ($relative_dir eq '.')
3887 if ($package_version !~ /^$GNITS_VERSION_PATTERN$/)
3889 # FIXME: allow real filename.
3890 &am_conf_line_error ('configure.in',
3891 $package_version_line,
3892 "version \`$package_version' doesn't follow Gnits standards");
3894 elsif (defined $1 && -f 'README-alpha')
3896 # This means we have an alpha release. See
3897 # GNITS_VERSION_PATTERN for details.
3898 &require_file ($GNITS, 'README-alpha');
3903 if ($relative_dir eq '.')
3905 # In top level (or only) directory.
3906 &require_file ($GNITS, 'THANKS');
3910 ################################################################
3912 # Pretty-print something. HEAD is what should be printed at the
3913 # beginning of the first line, FILL is what should be printed at the
3914 # beginning of every subsequent line.
3915 sub pretty_print_internal
3917 local ($head, $fill, @values) = @_;
3919 local ($column) = length ($head);
3920 local ($result) = $head;
3922 # Fill length is number of characters. However, each Tab
3923 # character counts for eight. So we count the number of Tabs and
3925 local ($fill_length) = length ($fill);
3926 $fill_length += 7 * ($fill =~ tr/\t/\t/d);
3928 local ($bol) = ($head eq '');
3931 # "71" because we also print a space.
3932 if ($column + length ($_) > 71)
3934 $result .= " \\\n" . $fill;
3935 $column = $fill_length;
3939 $result .= ' ' unless ($bol);
3941 $column += length ($_) + 1;
3949 # Pretty-print something and append to output_vars.
3952 $output_vars .= &pretty_print_internal (@_);
3955 # Pretty-print something and append to output_rules.
3956 sub pretty_print_rule
3958 $output_rules .= &pretty_print_internal (@_);
3962 ################################################################
3964 # See if a target exists.
3967 local ($target) = @_;
3968 return defined $targets{$target};
3971 # See if a variable exists.
3972 sub variable_defined
3975 if (defined $targets{$var})
3977 &am_line_error ($var, "\`$var' is target; expected variable");
3980 elsif (defined $contents{$var})
3982 $content_seen{$var} = 1;
3988 # Mark a variable as examined.
3989 sub examine_variable
3992 &variable_defined ($var);
3995 # Return contents of variable as list, split as whitespace. This will
3996 # recursively follow $(...) and ${...} inclusions. It preserves @...@
3997 # substitutions. If PARENT is specified, it is the name of the
3998 # including variable; this is only used for error reports.
3999 sub variable_value_as_list
4001 local ($var, $parent) = @_;
4004 if (defined $targets{$var})
4006 &am_line_error ($var, "\`$var' is target; expected variable");
4008 elsif (! defined $contents{$var})
4010 &am_line_error ($parent, "variable \`$var' not defined");
4015 $content_seen{$var} = 1;
4016 foreach (split (' ', $contents{$var}))
4018 # If a comment seen, just leave.
4021 # Handle variable substitutions.
4022 if (/^\$\{(.*)\}$/ || /^\$\((.*)\)$/)
4024 local ($varname) = $1;
4026 if ($varname =~ /^([^:]*):([^=]*)=(.*)$/)
4030 ($from = $2) =~ s/(\W)/\\$1/g;
4034 @temp_list = &variable_value_as_list ($1, $var);
4036 # Now rewrite the value if appropriate.
4039 grep (s/$from$/$to/, @temp_list);
4042 push (@result, @temp_list);
4054 # Define a new variable, but only if not already defined.
4057 local ($var, $value) = @_;
4059 if (! defined $contents{$var})
4061 $output_vars .= $var . ' = ' . $value . "\n";
4062 $contents{$var} = $value;
4063 $content_seen{$var} = 1;
4067 # Like define_variable, but second arg is a list, and is
4069 sub define_pretty_variable
4071 local ($var, @value) = @_;
4072 if (! defined $contents{$var})
4074 $contents{$var} = join (' ', @value);
4075 &pretty_print ($var . ' = ', '', @value);
4076 $content_seen{$var} = 1;
4080 # Like define_variable, but define a variable to be the configure
4081 # substitution by the same name.
4082 sub define_configure_variable
4085 local ($value) = '@' . $var . '@';
4086 &define_variable ($var, $value);
4089 # Define a variable that represents a program to run. If in Cygnus
4090 # mode, the program is searched for in the build (or source) tree.
4091 # Otherwise no searching is done at all. Arguments are:
4092 # * VAR Name of variable to define
4093 # * WHATDIR Either `src' or `build', depending on where program should
4094 # be found. (runtest is in srcdir!)
4095 # * SUBDIR Subdir of top-level dir
4096 # * PROGRAM Name of program
4097 sub define_program_variable
4099 local ($var, $whatdir, $subdir, $program) = @_;
4103 local ($full) = ('$(top_' . $whatdir . 'dir)/../'
4104 . $subdir . '/' . $program);
4105 &define_variable ($var, ('`if test -f ' . $full
4106 . '; then echo ' . $full . '; else echo '
4107 . $program . '; fi`'));
4111 &define_variable ($var, $program);
4116 ################################################################
4118 # Read Makefile.am and set up %contents. Simultaneously copy lines
4119 # from Makefile.am into $output_trailer or $output_vars as
4120 # appropriate. NOTE we put rules in the trailer section. We want
4121 # user rules to come after our generated stuff.
4124 local ($amfile) = @_;
4126 open (AM_FILE, $amfile) || die "automake: couldn't open \`$amfile': $!\n";
4127 print "automake: reading $amfile\n" if $verbose;
4129 $output_vars = ("# $in_file_name generated automatically by automake "
4130 . $VERSION . " from $am_file_name\n");
4132 # Generate copyright for generated Makefile.in.
4133 $output_vars .= $gen_copyright;
4135 local ($saw_bk) = 0;
4136 local ($was_rule) = 0;
4137 local ($spacing) = '';
4138 local ($comment) = '';
4139 local ($last_var_name) = '';
4144 if (/$IGNORE_PATTERN/o)
4146 # Merely delete comments beginning with two hashes.
4148 elsif (/$WHITE_PATTERN/o)
4150 # Stick a single white line before the incoming macro or rule.
4154 elsif (/$COMMENT_PATTERN/o)
4156 # Stick comments before the incoming macro or rule. Make
4157 # sure a blank line preceeds first block of comments.
4158 $spacing = "\n" unless $blank;
4160 $comment .= $spacing . $_;
4169 $output_vars .= $comment . "\n";
4172 local ($am_vars) = '';
4174 local ($is_ok_macro);
4178 unless substr ($_, -1, 1) eq "\n";
4180 $_ =~ s/\@MAINT\@//g
4181 unless $seen_maint_mode;
4183 if (/$IGNORE_PATTERN/o)
4185 # Merely delete comments beginning with two hashes.
4187 elsif (/$WHITE_PATTERN/o)
4189 # Stick a single white line before the incoming macro or rule.
4192 elsif (/$COMMENT_PATTERN/o)
4194 # Stick comments before the incoming macro or rule.
4195 $comment .= $spacing . $_;
4202 $output_trailer .= $_;
4209 # Chop newline and backslash if this line is
4210 # continued. FIXME: maybe ensure trailing whitespace
4214 $contents{$last_var_name} .= $_;
4217 elsif (/$RULE_PATTERN/o)
4219 # warn "** Saw rule .$1.\n";
4222 # Value here doesn't matter; for targets we only note
4226 $content_lines{$1} = $.;
4227 $output_trailer .= $comment . $spacing . $_;
4228 $comment = $spacing = '';
4231 elsif (($is_ok_macro = /$MACRO_PATTERN/o)
4232 || /$BOGUS_MACRO_PATTERN/o)
4234 # Found a macro definition.
4236 $last_var_name = $1;
4237 if ($2 ne '' && substr ($2, -1) eq "\\")
4239 $contents{$1} = substr ($2, 0, length ($2) - 1);
4245 $content_lines{$1} = $.;
4246 $am_vars .= $comment . $spacing . $_;
4247 $comment = $spacing = '';
4251 &am_line_error ($., "bad macro name \`$1'")
4256 # This isn't an error; it is probably a continued rule.
4257 # In fact, this is what we assume.
4259 $output_trailer .= $comment . $spacing . $_;
4260 $comment = $spacing = '';
4267 $output_trailer .= $comment;
4269 # Compute relative location of the top object directory.
4270 local (@topdir) = ();
4271 foreach (split (/\//, $relative_dir))
4273 next if $_ eq '.' || $_ eq '';
4280 push (@topdir, '..');
4283 @topdir = ('.') if ! @topdir;
4285 $top_builddir = join ('/', @topdir);
4287 ($build_rx = $top_builddir) =~ s/(\W)/\\$1/g;
4288 $output_vars .= &file_contents_with_transform
4289 ('s/\@top_builddir\@/' . $build_rx . '/g;',
4292 # Generate some useful variables when AC_CANONICAL_* used. FIXME:
4293 # this should use generic %configure_vars method.
4294 if ($seen_canonical)
4296 local ($curs, %vars);
4297 $vars{'host_alias'} = 'host_alias';
4298 $vars{'host_triplet'} = 'host';
4299 if ($seen_canonical == $AC_CANONICAL_SYSTEM)
4301 $vars{'build_alias'} = 'build_alias';
4302 $vars{'build_triplet'} = 'build';
4303 $vars{'target_alias'} = 'target_alias';
4304 $vars{'target_triplet'} = 'target';
4306 foreach $curs (sort keys %vars)
4308 $output_vars .= "$curs = \@$vars{$curs}\@\n";
4309 $contents{$curs} = "\@$vars{$curs}\@";
4314 foreach $curs (sort keys %configure_vars)
4316 &define_configure_variable ($curs);
4319 $output_vars .= $am_vars;
4322 ################################################################
4324 sub initialize_global_constants
4326 # Values for AC_CANONICAL_*
4327 $AC_CANONICAL_HOST = 1;
4328 $AC_CANONICAL_SYSTEM = 2;
4330 # Associative array of standard directory names. Entry is TRUE if
4331 # corresponding directory should be installed during
4332 # 'install-exec' phase.
4350 # Helper text for dealing with man pages.
4351 $install_man_format =
4352 ' @sect=@SECTION@; \\
4353 inst=`echo "@MANBASE@" | sed \'$(transform)\'`.@FULLSECT@; \\
4354 if test -f $(srcdir)/@MAN@; then file=$(srcdir)/@MAN@; \\
4355 else file=@MAN@; fi; \\
4356 echo " $(INSTALL_DATA) $$file $(mandir)/man$$sect/$$inst"; \\
4357 $(INSTALL_DATA) $$file $(mandir)/man$$sect/$$inst
4360 $uninstall_man_format =
4361 ' inst=`echo "@MANBASE@" | sed \'$(transform)\'`.@FULLSECT@; \\
4362 rm -f $(mandir)/man@SECTION@/$$inst
4365 # Commonly found files we look for and automatically include in
4369 "README", "THANKS", "TODO", "NEWS", "COPYING", "COPYING.LIB",
4370 "INSTALL", "ABOUT-NLS", "ChangeLog", "configure", "configure.in",
4371 "config.guess", "config.sub", "AUTHORS", "BACKLOG", "ABOUT-GNU",
4372 "libversion.in", "mdate-sh", "mkinstalldirs", "install-sh",
4373 'texinfo.tex', "ansi2knr.c", "ansi2knr.1", 'elisp-comp',
4374 'interlock', 'ylwrap', 'acinclude.m4', @libtoolize_files,
4378 # Commonly used files we auto-include, but only sometimes.
4381 "aclocal.m4", "acconfig.h", "config.h.top",
4382 "config.h.bot", "stamp-h.in", 'stamp-vti'
4386 -a, --add-missing add missing standard files to package
4387 --amdir=DIR directory storing config files
4388 --build-dir=DIR directory where build being done (for dependencies)
4389 --cygnus assume program is part of Cygnus-style tree
4390 --foreign set strictness to foreign
4391 --gnits set strictness to gnits
4392 --gnu set strictness to gnu
4393 --help print this help, then exit
4394 -i, --include-deps include generated dependencies in Makefile.in
4395 --no-force only update Makefile.in's that are out of date
4396 -o DIR, --output-dir=DIR
4397 put generated Makefile.in's into DIR
4398 --srcdir-name=DIR name used for srcdir (for dependencies)
4399 -v, --verbose verbosely list files processed
4400 --version print version number, then exit\n";
4402 # Copyright on generated Makefile.ins.
4404 # Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
4405 # This Makefile.in is free software; the Free Software Foundation
4406 # gives unlimited permission to copy, distribute and modify it.
4409 # Ignore return result from chmod, because it might give an error
4410 # if we chmod a symlink.
4411 $dist_header = "\t" . '-chmod -R a+r $(distdir)' . "\n";
4412 $dist{'tarZ'} = ("\t"
4413 . '$(TAR) chf - $(distdir) | compress -c > $(distdir).tar.Z'
4415 $dist{'shar'} = ("\t"
4416 . 'shar $(distdir) | gzip > $(distdir).shar.gz'
4418 $dist{'zip'} = "\t" . 'zip -rq $(distdir).zip $(distdir)' . "\n";
4419 $dist{'dist'} = "\t" . 'GZIP=$(GZIP) $(TAR) chozf $(distdir).tar.gz $(distdir)' . "\n";
4420 $dist_trailer = "\t" . 'rm -rf $(distdir)' . "\n";
4423 # (Re)-Initialize per-Makefile.am variables.
4424 sub initialize_per_input
4426 # These two variables are used when generating each Makefile.in.
4427 # They hold the Makefile.in until it is ready to be printed.
4430 $output_trailer = '';
4431 $output_header = '';
4433 # Suffixes found during a run.
4436 # This holds the contents of a Makefile.am, as parsed by
4440 # This holds the names which are targets. These also appear in
4444 # This holds the line numbers at which various elements of
4445 # %contents are defined.
4446 %content_lines = ();
4448 # This holds a 1 if a particular variable was examined.
4451 # This holds the "relative directory" of the current Makefile.in.
4452 # Eg for src/Makefile.in, this is "src".
4455 # This holds a list of files that are included in the
4459 # List of dependencies for the obvious targets.
4475 # These are pretty obvious, too. They are used to define the
4476 # SOURCES and OBJECTS variables.
4480 # TRUE if current directory holds any C source files.
4481 $dir_holds_sources = 0;
4483 # These variables track inclusion of various compile-related .am
4484 # files. $included_generic_compile is TRUE if the basic code has
4485 # been included. $included_knr_compile is TRUE if the ansi2knr
4486 # code has been included. $included_libtool_compile is TRUE if
4487 # libtool support has been included.
4488 $included_generic_compile = 0;
4489 $included_knr_compile = 0;
4490 $included_libtool_compile = 0;
4492 # TRUE if current directory holds any headers.
4493 $dir_holds_headers = 0;
4495 # TRUE if install targets should work recursively.
4496 $recursive_install = 0;
4501 # Strictness levels.
4502 $strictness = $default_strictness;
4503 $strictness_name = $default_strictness_name;
4505 # Options from AUTOMAKE_OPTIONS.
4508 # Whether or not dependencies are handled. Can be further changed
4509 # in handle_options.
4510 $use_dependencies = $cmdline_use_dependencies;
4513 $local_maint_charset = $maint_charset;
4515 # All yacc and lex source filenames for this directory. Use
4516 # filenames instead of raw count so that multiple instances are
4517 # counted correctly (eg one yacc file can appear in multiple
4518 # programs without harm).
4522 # C++ source extensions we've seen.
4523 %cxx_extensions = ();
4525 # TRUE if we've seen any non-C++ sources. This actually holds a
4526 # line number or the name of a symbol corresponding to a line
4527 # number where the C sources were seen. If it is -1 then it means
4528 # we couldn't (easily) figure out which line of the Makefile.am
4529 # mentioned the sources.
4532 # This is a list of all targets to run during "make dist".
4535 # Keys in this hash are the names of ._o files which must depend
4537 %de_ansi_objects = ();
4541 ################################################################
4543 # Return contents of a file from $am_dir, automatically skipping
4544 # macros or rules which are already known. Runs command on each line
4545 # as it is read; this command can modify $_.
4546 sub file_contents_with_transform
4548 local ($command, $basename) = @_;
4549 local ($file) = $am_dir . '/' . $basename . '.am';
4551 if ($command ne '' && substr ($command, -1) ne ';')
4553 die "automake: programming error in file_contents_with_transform\n";
4556 open (FC_FILE, $file)
4557 || die "automake: installation error: cannot open \`$file'\n";
4559 # print "automake: reading $file\n" if $verbose;
4561 local ($was_rule) = 0;
4562 local ($result_vars) = '';
4563 local ($result_rules) = '';
4564 local ($comment) = '';
4565 local ($spacing) = "\n";
4566 local ($skipping) = 0;
4571 $_ =~ s/\@MAINT\@//g
4572 unless $seen_maint_mode;
4574 $had_chars = length ($_);
4576 # If the transform caused all the characters to go away, then
4577 # ignore the line. Why do this? Because in Perl 4, a "next"
4578 # inside of an eval doesn't affect a loop outside the eval.
4579 # So we can't pass in a "transform" that uses next. We used
4581 next if $had_chars && $_ eq '';
4583 if (/$IGNORE_PATTERN/o)
4585 # Merely delete comments beginning with two hashes.
4587 elsif (/$WHITE_PATTERN/o)
4589 # Stick a single white line before the incoming macro or rule.
4592 elsif (/$COMMENT_PATTERN/o)
4594 # Stick comments before the incoming macro or rule.
4595 $comment .= $spacing . $_;
4602 $result_rules .= $_ if ! $skipping;
4606 $result_vars .= $_ if ! $skipping;
4610 elsif (/$RULE_PATTERN/o)
4612 # warn "** Found rule .$1.\n";
4615 $skipping = defined $contents{$1};
4616 # warn "** Skip $skipping\n" if $skipping;
4617 $result_rules .= $comment . $spacing . $_ if ! $skipping;
4618 $comment = $spacing = '';
4621 elsif (/$MACRO_PATTERN/o)
4623 # warn "** Found macro .$1.\n";
4624 # Found a variable reference.
4626 $skipping = defined $contents{$1};
4627 # warn "** Skip $skipping\n" if $skipping;
4628 $result_vars .= $comment . $spacing . $_ if ! $skipping;
4629 $comment = $spacing = '';
4634 # This isn't an error; it is probably a continued rule.
4635 # In fact, this is what we assume.
4637 $result_rules .= $comment . $spacing . $_ if ! $skipping;
4638 $comment = $spacing = '';
4644 return $result_vars . $result_rules . $comment;
4647 # Like file_contents_with_transform, but no transform.
4650 return &file_contents_with_transform ('', @_);
4653 # Find all variable prefixes that are used for install directories. A
4654 # prefix `zar' qualifies iff:
4655 # * `zardir' is a variable.
4656 # * `zar_PRIMARY' is a variable.
4657 sub am_primary_prefixes
4659 local ($primary, @prefixes) = @_;
4661 local (%valid, $varname);
4662 grep ($valid{$_} = 0, @prefixes);
4663 $valid{'EXTRA'} = 0;
4664 foreach $varname (keys %contents)
4666 if ($varname =~ /^(.*)_$primary$/)
4668 if (! defined $valid{$1}
4669 && ! &variable_defined ($1 . 'dir')
4670 # Note that a configure variable is always legitimate.
4671 # It is natural to name such variables after the
4672 # primary, so we explicitly allow it.
4673 && ! defined $configure_vars{$varname})
4675 &am_line_error ($varname, "invalid variable \"$varname\"");
4679 # Ensure all extended prefixes are actually used.
4688 # Handle `where_HOW' variable magic. Does all lookups, generates
4689 # install code, and possibly generates code to define the primary
4690 # variable. The first argument is the name of the .am file to munge,
4691 # the second argument is the primary variable (eg HEADERS), and all
4692 # subsequent arguments are possible installation locations. Returns
4693 # list of all values of all _HOW targets.
4695 # FIXME: this should be rewritten to be cleaner. It should be broken
4696 # up into multiple functions.
4698 # Usage is: am_install_var (OPTION..., file, HOW, where...)
4703 local ($do_clean) = 0;
4706 if (defined $configure_vars{'LIBTOOL'})
4708 # Transform '@LIBTOOL ...@' to '$(LIBTOOL) ...'
4709 $ltxform = 's/\@LIBTOOL([^\@]*)\@/\$(LIBTOOL) $1/;';
4713 # Delete '@LIBTOOL ...@'
4714 $ltxform = 's/\@LIBTOOL([^\@]*)\@//;';
4718 if (! $seen_cygwin32)
4720 $cygxform = 's/\@EXEEXT\@//g; s/^NOTCYGWIN.*$//;';
4724 $cygxform .= 's/^CYGWIN.*$//;';
4729 if ($args[0] eq '-clean')
4733 elsif ($args[0] !~ /^-/)
4739 local ($file, $primary, @prefixes) = @args;
4742 local (@result) = ();
4744 # Now that configure substitutions are allowed in where_HOW
4745 # variables, it is an error to actually define the primary.
4746 &am_line_error ($primary, "\`$primary' is an anachronism")
4747 if &variable_defined ($primary);
4750 # Look for misspellings. It is an error to have a variable ending
4751 # in a "reserved" suffix whose prefix is unknown, eg
4752 # "bni_PROGRAMS". However, unusual prefixes are allowed if a
4753 # variable of the same name (with "dir" appended) exists. For
4754 # instance, if the variable "zardir" is defined, then
4755 # "zar_PROGRAMS" becomes valid. This is to provide a little extra
4756 # flexibility in those cases which need it. Perhaps it should be
4757 # disallowed in the Gnits case? The problem is, sometimes it is
4758 # useful to put things in a subdir of eg pkgdatadir, perhaps even
4760 local (%valid) = &am_primary_prefixes ($primary, @prefixes);
4762 # If a primary includes a configure substitution, then the EXTRA_
4763 # form is required. Otherwise we can't properly do our job.
4764 local ($require_extra);
4765 local ($warned_about_extra) = 0;
4767 local ($clean_file) = $file . '-clean';
4770 foreach $X (sort keys %valid)
4772 $one_name = $X . '_' . $primary;
4773 if (&variable_defined ($one_name))
4775 # Append actual contents of where_PRIMARY variable to
4778 foreach $rcurs (&variable_value_as_list ($one_name))
4780 # Skip configure substitutions. Possibly bogus.
4781 if ($rcurs =~ /^\@.*\@$/)
4785 if (! $warned_about_extra)
4787 $warned_about_extra = 1;
4788 &am_line_error ($one_name,
4789 "\`$one_name' contains configure substitution, but shouldn't");
4792 # Check here to make sure variables defined in
4793 # configure.in do not imply that EXTRA_PRIMARY
4795 elsif (! defined $configure_vars{$one_name})
4797 $require_extra = $one_name;
4801 push (@result, $rcurs);
4804 # "EXTRA" shouldn't be used when generating clean targets,
4805 # @all, or install targets.
4806 next if $X eq 'EXTRA';
4811 &file_contents_with_transform ('s/\@DIR\@/' . $X . '/go;'
4815 push (@clean, $X . $primary);
4816 &push_phony_cleaners ($X . $primary);
4821 push (@check, '$(' . $one_name . ')');
4825 push (@used, '$(' . $one_name . ')');
4827 if ($X eq 'noinst' || $X eq 'check')
4829 # Objects which don't get installed by default.
4834 &file_contents_with_transform ('s/\@DIR\@/' . $X . '/g;'
4835 . $ltxform . $cygxform,
4838 push (@uninstall, 'uninstall-' . $X . $primary);
4839 push (@phony, 'uninstall-' . $X . $primary);
4840 push (@installdirs, '$(' . $X . 'dir)');
4841 if (defined $exec_dir_p{$X} ? $exec_dir_p{$X} : ($X =~ /exec/))
4843 push (@install_exec, 'install-' . $X . $primary);
4844 push (@phony, 'install-' . $X . $primary);
4848 push (@install_data, 'install-' . $X . $primary);
4849 push (@phony, 'install-' . $X . $primary);
4857 &define_pretty_variable ($primary, @used);
4858 $output_vars .= "\n";
4861 if ($require_extra && ! &variable_defined ('EXTRA_' . $primary))
4863 &am_line_error ($require_extra,
4864 "\`$require_extra' contains configure substitution, but \`EXTRA_$primary' not defined");
4867 # Push here because PRIMARY might be configure time determined.
4868 push (@all, '$(' . $primary . ')')
4875 ################################################################
4877 # This variable is local to the "require file" set of functions.
4878 @require_file_paths = ();
4880 # Verify that the file must exist in the current directory. Usage:
4881 # require_file (isconfigure, line_number, strictness, file) strictness
4882 # is the strictness level at which this file becomes required. Must
4883 # set require_file_paths before calling this function.
4884 # require_file_paths is set to hold a single directory (the one in
4885 # which the first file was found) before return.
4886 sub require_file_internal
4888 local ($is_configure, $line, $mystrict, @files) = @_;
4889 local ($file, $fullfile);
4890 local ($found_it, $errfile, $errdir);
4893 foreach $file (@files)
4896 foreach $dir (@require_file_paths)
4900 $fullfile = $relative_dir . "/" . $file;
4901 $errdir = $relative_dir unless $errdir;
4905 $fullfile = $dir . "/" . $file;
4906 $errdir = $dir unless $errdir;
4909 # Use different name for "error filename". Otherwise on
4910 # an error the bad file will be reported as eg
4911 # `../../install-sh' when using the default
4913 $errfile = $errdir . '/' . $file;
4918 # FIXME: Once again, special-case `.'.
4919 &push_dist_common ($file)
4920 if $dir eq $relative_dir || $dir eq '.';
4928 # Prune the path list.
4929 @require_file_paths = $save_dir;
4933 if ($strictness >= $mystrict)
4935 local ($trailer) = '';
4936 local ($suppress) = 0;
4938 # Only install missing files according to our desired
4942 $trailer = "; installing";
4945 # Maybe run libtoolize.
4947 && grep ($_ eq $file, @libtoolize_files)
4948 && system ('libtoolize', '--automake'))
4951 $trailer .= "; cannot run \`libtoolize': $!";
4953 elsif (-f ($am_dir . '/' . $file))
4955 # Install the missing file. Symlink if we
4956 # can, copy if we must. Note: delete the file
4957 # first, in case it is a dangling symlink.
4959 if ($symlink_exists)
4961 if (! symlink ($am_dir . '/' . $file, $errfile))
4964 $trailer .= "; error while making link: $!\n";
4967 elsif (! system ('cp', $am_dir . '/' . $file, $errfile))
4970 $trailer .= "\n error while making link\n";
4975 local ($save) = $exit_status;
4978 # FIXME: allow actual file to be specified.
4980 ('configure.in', $line,
4981 "required file \"$errfile\" not found$trailer");
4987 "required file \"$errfile\" not found$trailer");
4989 $exit_status = $save if $suppress;
4995 # Like require_file_with_line, but error messages refer to
4996 # configure.in, not the current Makefile.am.
4997 sub require_file_with_conf_line
4999 @require_file_paths = '.';
5000 &require_file_internal (1, @_);
5003 sub require_file_with_line
5005 @require_file_paths = '.';
5006 &require_file_internal (0, @_);
5011 @require_file_paths = '.';
5012 &require_file_internal (0, '', @_);
5015 # Require a file that is also required by Autoconf. Looks in
5016 # configuration path, as specified by AC_CONFIG_AUX_DIR.
5017 sub require_config_file
5019 @require_file_paths = @config_aux_path;
5020 &require_file_internal (1, '', @_);
5021 local ($dir) = $require_file_paths[0];
5022 @config_aux_path = @require_file_paths;
5025 $config_aux_dir = '.';
5029 $config_aux_dir = '$(top_srcdir)/' . $dir;
5033 # Assumes that the line number is in Makefile.am.
5034 sub require_conf_file_with_line
5036 @require_file_paths = @config_aux_path;
5037 &require_file_internal (0, @_);
5038 local ($dir) = $require_file_paths[0];
5039 @config_aux_path = @require_file_paths;
5042 $config_aux_dir = '.';
5046 $config_aux_dir = '$(top_srcdir)/' . $dir;
5050 # Assumes that the line number is in Makefile.am.
5051 sub require_conf_file_with_conf_line
5053 @require_file_paths = @config_aux_path;
5054 &require_file_internal (1, @_);
5055 local ($dir) = $require_file_paths[0];
5056 @config_aux_path = @require_file_paths;
5059 $config_aux_dir = '.';
5063 $config_aux_dir = '$(top_srcdir)/' . $dir;
5067 ################################################################
5069 # Push a list of files onto dist_common.
5070 sub push_dist_common
5072 local (@files) = @_;
5075 foreach $file (@files)
5077 $dist_common{$file} = 1;
5081 # Push a list of clean targets onto phony.
5082 sub push_phony_cleaners
5086 foreach $target ('mostly', 'dist', '', 'maintainer-')
5088 push (@phony, $target . 'clean-' . $base);
5095 $strictness_name = $_[0];
5096 if ($strictness_name eq 'gnu')
5100 elsif ($strictness_name eq 'gnits')
5102 $strictness = $GNITS;
5104 elsif ($strictness_name eq 'foreign')
5106 $strictness = $FOREIGN;
5110 die "automake: level \`$strictness_name' not recognized\n";
5115 ################################################################
5117 # Return directory name of file.
5123 ($sub = $file) =~ s,/+[^/]+$,,g;
5124 $sub = '.' if $sub eq $file;
5128 # Return file name of a file.
5134 ($sub = $file) =~s,^.*/+,,g;
5143 open (TOUCH, ">> $file");
5147 # Glob something. Do this to avoid indentation screwups everywhere we
5148 # want to glob. Gross!
5155 ################################################################
5157 # Print an error message and set exit status.
5160 warn "automake: ${am_file}.am: ", join (' ', @_), "\n";
5166 local ($symbol, @args) = @_;
5168 if ($symbol && "$symbol" ne '-1')
5170 # If SYMBOL not already a line number, look it up in Makefile.am.
5171 if ($symbol =~ /^\d+$/)
5175 elsif (defined $content_lines{$symbol})
5177 $symbol = $content_lines{$symbol} . ': ';
5181 # A single space, to provide nice separation.
5184 warn "${am_file}.am:", $symbol, join (' ', @args), "\n";
5193 # Like am_error, but while scanning configure.in.
5196 # FIXME: can run in subdirs.
5197 warn "automake: configure.in: ", join (' ', @_), "\n";
5201 # Error message with line number referring to configure.in.
5202 sub am_conf_line_error
5204 local ($file, $line, @args) = @_;
5208 warn "$file: $line: ", join (' ', @args), "\n";
5213 &am_conf_error (@args);
5217 # Tell user where our aclocal.m4 is, but only once.
5218 sub keyed_aclocal_warning
5221 warn "automake: macro \`$key' can be generated by \`aclocal'\n";
5224 # Print usage information.
5227 print "Usage: automake [OPTION] ... [Makefile]...\n";
5229 print "\nFiles which are automatically distributed, if found:\n";
5230 $~ = "USAGE_FORMAT";
5231 local (@lcomm) = sort ((@common_files, @common_sometimes));
5232 local ($one, $two, $three, $four);
5235 $one = shift @lcomm;
5236 $two = @lcomm ? shift @lcomm : '';
5237 $three = @lcomm ? shift @lcomm : '';
5238 $four = @lcomm ? shift @lcomm : '';
5242 print "\nReport bugs to <automake-bugs\@gnu.ai.mit.edu>\n";
5247 format USAGE_FORMAT =
5248 @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<
5249 $one, $two, $three, $four