5 eval 'exec @PERL@ -S $0 ${1+"$@"}'
8 # automake - create Makefile.in from Makefile.am
9 # Copyright (C) 1994, 1995, 1996, 1997 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 $AM_MISSING_PATTERN = "AM_MISSING_PROG\\(\\[?(\\w+)";
55 # Just check for alphanumeric in AC_SUBST. If you do AC_SUBST(5),
57 $AC_SUBST_PATTERN = "AC_SUBST\\(\\[?(\\w+)";
59 # Constants to define the "strictness" level.
66 # Variables global to entire run.
68 # TRUE if we should always generate Makefile.in.
69 $force_generation = 1;
71 # Strictness level as set on command line.
72 $default_strictness = $GNU;
74 # Name of strictness level, as set on command line.
75 $default_strictness_name = 'gnu';
77 # This is TRUE if GNU make specific automatic dependency generation
78 # code should be included in generated Makefile.in.
79 $cmdline_use_dependencies = 1;
81 # TRUE if in verbose mode.
84 # This holds our (eventual) exit status. We don't actually exit until
85 # we have processed all input files.
88 # From the Perl manual.
89 $symlink_exists = (eval 'symlink ("", "");', $@ eq '');
91 # TRUE if missing standard files should be installed.
94 # Files found by scanning configure.in for LIBOBJS.
97 # True if AM_C_PROTOTYPES appears in configure.in.
100 # Names used in AC_CONFIG_HEADER call. @config_fullnames holds the
101 # name which appears in AC_CONFIG_HEADER, colon and all.
102 # @config_names holds the file names. @config_headers holds the '.in'
103 # files. Ordinarily these are similar, but they can be different if
104 # the weird "NAME:FILE" syntax is used.
105 @config_fullnames = ();
107 @config_headers = ();
108 # Line number at which AC_CONFIG_HEADER appears in configure.in.
109 $config_header_line = 0;
111 # Directory where output files go. Actually, output files are
112 # relative to this directory.
113 $output_directory = '.';
115 # Relative location of top build directory.
118 # Absolute location of top build directory.
119 $build_directory = '';
121 # Name of srcdir as given in build directory's Makefile. For
125 # List of Makefile.am's to process, and their corresponding outputs.
129 # List of files in AC_OUTPUT without Makefile.am, and their outputs.
130 @other_input_files = ();
131 # Line number at which AC_OUTPUT seen.
134 # List of directories to search for configure-required files. This
135 # can be set by AC_CONFIG_AUX_DIR.
136 @config_aux_path = ('.', '..', '../..');
137 $config_aux_dir = '';
139 # Whether AC_PROG_MAKE_SET has been seen in configure.in.
142 # Whether AM_GNU_GETTEXT has been seen in configure.in.
144 # Line number at which AM_GNU_GETTEXT seen.
145 $ac_gettext_line = 0;
147 # Whether ALL_LINGUAS has been seen.
151 # Line number at which it appears.
152 $all_linguas_line = 0;
154 # 1 if AC_PROG_INSTALL seen, 2 if AM_PROG_INSTALL seen.
155 $seen_prog_install = 0;
157 # 1 if any scripts installed, 0 otherwise.
158 $scripts_installed = 0;
160 # Whether AC_PATH_XTRA has been seen in configure.in.
163 # TRUE if AC_DECL_YYTEXT was seen.
164 $seen_decl_yytext = 0;
166 # TRUE if we've seen AC_CANONICAL_(HOST|SYSTEM). The presence of
167 # AC_CHECK_TOOL also sets this.
170 # TRUE if we've seen AC_ARG_PROGRAM.
173 # TRUE if we've seen AM_PROG_LIBTOOL.
177 # Files installed by libtoolize.
178 @libtoolize_files = ('ltconfig', 'ltmain.sh', 'config.guess', 'config.sub');
180 # TRUE if we've seen AM_MAINTAINER_MODE.
181 $seen_maint_mode = 0;
183 # TRUE if we've seen PACKAGE and VERSION.
187 # Actual version we've seen.
188 $package_version = '';
190 # Line number where we saw version definition.
191 $package_version_line = 0;
193 # TRUE if we've seen AM_PATH_LISPDIR.
196 # TRUE if we've seen AM_CYGWIN32.
199 # Hash table of discovered configure substitutions. Keys are names,
200 # values are meaningless.
201 %configure_vars = ();
203 # Charsets used by maintainer and in distribution. MAINT_CHARSET is
204 # handled in a funny way: if seen in the top-level Makefile.am, it is
205 # used for every directory which does not specify a different value.
206 # The rationale here is that some directories (eg gettext) might be
207 # distributions of other packages, and thus require their own charset
208 # info. However, the DIST_CHARSET must be the same for the entire
209 # package; it can only be set at top-level.
210 # FIXME: this yields bugs when rebuilding. What to do? Always
211 # read (and sometimes discard) top-level Makefile.am?
213 $dist_charset = 'utf8'; # recode doesn't support this yet.
215 # Name of input file ("Makefile.in") and output file ("Makefile.am").
216 # These have no directory components.
220 # TRUE if --cygnus seen.
223 # Keys of this hash are names of dependency files to ignore.
224 %omit_dependencies = ();
226 # Map from obsolete macros to hints for new macros.
227 # FIXME complete the list so that there are no `0' hints.
230 'AC_FEATURE_CTYPE', "use \`AC_HEADER_STDC'",
231 'AC_FEATURE_ERRNO', "add \`strerror' to \`AC_REPLACE_FUNCS(...)'",
232 'AC_FEATURE_EXIT', 0,
233 'AC_SYSTEM_HEADER', 0,
235 # Note that we do not handle this one, because it is still run
236 # from AM_CONFIG_HEADER. So we deal with it specially in
238 # 'AC_CONFIG_HEADER', "use \`AM_CONFIG_HEADER'",
240 'fp_C_PROTOTYPES', "use \`AM_C_PROTOTYPES'",
241 'fp_PROG_CC_STDC', "use \`AM_PROG_CC_STDC'",
242 'fp_PROG_INSTALL', "use \`AM_PROG_INSTALL'",
243 'fp_WITH_DMALLOC', "use \`AM_WITH_DMALLOC'",
244 'fp_WITH_REGEX', "use \`AM_WITH_REGEX'",
245 'gm_PROG_LIBTOOL', "use \`AM_PROG_LIBTOOL'",
246 'jm_MAINTAINER_MODE', "use \`AM_MAINTAINER_MODE'",
247 'md_TYPE_PTRDIFF_T', "use \`AM_TYPE_PTRDIFF_T'",
248 'ud_PATH_LISPDIR', "use \`AM_PATH_LISPDIR'",
250 # Now part of autoconf proper, under a different name.
251 'AM_FUNC_FNMATCH', "use \`AC_FUNC_FNMATCH'",
252 'fp_FUNC_FNMATCH', "use \`AC_FUNC_FNMATCH'",
253 'AM_SANITY_CHECK_CC', "automatically done by \`AC_PROG_CC'",
255 # These aren't quite obsolete.
259 # Regexp to match the above macros.
260 $obsolete_rx = '(' . join ('|', keys %obsolete_macros) . ')';
264 &initialize_global_constants;
266 # Parse command line.
267 &parse_arguments (@ARGV);
269 # Do configure.in scan only once.
272 die "automake: no \`Makefile.am' found or specified\n"
275 # Now do all the work on each file.
276 foreach $am_file (@input_files)
278 if (! -f ($am_file . '.am'))
280 &am_error ("\`" . $am_file . ".am' does not exist");
284 &generate_makefile ($output_files{$am_file}, $am_file);
288 if ($seen_prog_install <= $scripts_installed)
290 &am_conf_error (($scripts_installed ? 'AM_PROG_INSTALL' : 'AC_PROG_INSTALL')
291 . " must be used in configure.in");
292 &keyed_aclocal_warning ('AM_PROG_INSTALL')
293 if $scripts_installed;
299 ################################################################
301 # Parse command line.
304 local (@arglist) = @_;
307 &set_strictness ('gnu');
311 if ($arglist[0] eq "--version")
313 print "automake (GNU $PACKAGE) $VERSION\n\n";
314 print "Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.\n";
315 print "This is free software; see the source for copying conditions. There is NO\n";
316 print "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n";
317 print "Written by Tom Tromey <tromey\@cygnus.com>\n";
321 elsif ($arglist[0] eq "--help")
325 elsif ($arglist[0] =~ /^--amdir=(.+)$/)
329 elsif ($arglist[0] eq '--amdir')
331 &require_argument (@arglist);
333 $am_dir = $arglist[0];
335 elsif ($arglist[0] =~ /^--build-dir=(.+)$/)
338 $build_directory = $1 . '/';
340 elsif ($arglist[0] eq '--build-dir')
342 &require_argument (@arglist);
345 $build_directory = $arglist[0] . '/';
347 elsif ($arglist[0] =~ /^--srcdir-name=(.+)$/)
351 elsif ($arglist[0] eq '--srcdir-name')
353 &require_argument (@arglist);
355 $srcdir_name = $arglist[0];
357 elsif ($arglist[0] eq '--gnu')
359 &set_strictness ('gnu');
361 elsif ($arglist[0] eq '--gnits')
363 &set_strictness ('gnits');
365 elsif ($arglist[0] eq '--cygnus')
369 elsif ($arglist[0] eq '--foreign')
371 &set_strictness ('foreign');
373 elsif ($arglist[0] eq '--include-deps' || $arglist[0] eq '-i')
375 $cmdline_use_dependencies = 0;
377 elsif ($arglist[0] eq '--no-force')
379 $force_generation = 0;
381 elsif ($arglist[0] =~ /^--output-dir=(.*)$/)
383 # Set output directory.
384 $output_directory = $1;
386 elsif ($arglist[0] eq '--output-dir' || $arglist[0] eq '-o')
388 &require_argument (@arglist);
390 $output_directory = $arglist[0];
392 elsif ($arglist[0] eq '--add-missing' || $arglist[0] eq '-a')
396 elsif ($arglist[0] eq '--verbose' || $arglist[0] eq '-v')
400 elsif ($arglist[0] eq '--')
402 # Stop option processing.
404 push (@input_files, @arglist);
407 elsif ($arglist[0] =~ /^-/)
409 die "automake: unrecognized option -- \`$arglist[0]'\nTry \`automake --help' for more information.\n";
413 # Handle $local:$input syntax. Note that we only examine
414 # the first ":" file to see if it is automake input; the
415 # rest are just taken verbatim. We still keep all the
416 # files around for dependency checking, however.
417 local ($local, $input, @rest) = split (/:/, $arglist[0]);
424 # Strip .in; later on .am is tacked on. That is how
425 # the automake input file is found. Maybe not the
426 # best way, but it is easy to explain. FIXME: should
427 # be error if .in is missing.
430 push (@input_files, $input);
431 $output_files{$input} = join (':', ($local, @rest));
437 # Take global strictness from whatever we currently have set.
438 $default_strictness = $strictness;
439 $default_strictness_name = $strictness_name;
442 # Ensure argument exists, or die.
445 local ($arg, @arglist) = @_;
446 die "automake: no argument given for option \`$arg'\n"
450 ################################################################
452 # Generate a Makefile.in given the name of the corresponding Makefile and
453 # the name of the file output by config.status.
454 sub generate_makefile
456 local ($output, $makefile) = @_;
458 ($am_file_name = $makefile) =~ s/^.*\///;
459 $in_file_name = $am_file_name . '.in';
460 $am_file_name .= '.am';
462 # $OUTPUT is encoded. If it contains a ":" then the first element
463 # is the real output file, and all remaining elements are input
464 # files. We don't scan or otherwise deal with these input file,
465 # other than to mark them as dependencies. See scan_configure for
467 local (@secondary_inputs);
468 ($output, @secondary_inputs) = split (/:/, $output);
470 &initialize_per_input;
471 $relative_dir = &dirname ($output);
472 $am_relative_dir = &dirname ($makefile);
474 # At the toplevel directory, we might need config.guess, config.sub
475 # or libtool scripts (ltconfig and ltmain.sh).
476 if ($relative_dir eq '.')
478 # libtool requires some files.
479 &require_conf_file_with_conf_line ($libtool_line, $FOREIGN,
483 # AC_CANONICAL_HOST and AC_CANONICAL_SYSTEM need config.guess and
485 &require_config_file ($FOREIGN, 'config.guess', 'config.sub')
489 # We still need Makefile.in here, because sometimes the `dist'
490 # target doesn't re-run automake.
491 if ($am_relative_dir eq $relative_dir)
493 # Only distribute the files if they are in the same subdir as
494 # the generated makefile.
495 &push_dist_common ($in_file_name, $am_file_name);
497 push (@sources, '$(SOURCES)')
498 if &variable_defined ('SOURCES');
499 push (@objects, '$(OBJECTS)')
500 if &variable_defined ('OBJECTS');
502 # This is always the default target. This gives us freedom to do
503 # things in whatever order is convenient. Note that we set up
504 # $output_header here so that we can insert some text just after
505 # the "default" target, but before any other targets. In
506 # particular we want to support the .SUFFIX hack here; this is
507 # documented elsewhere.
508 $output_header = "default: all\n\n";
509 push (@phony, 'default');
511 &read_am_file ($makefile . '.am');
514 # Fatal error. Just return, so we can continue with next file.
518 # Check first, because we might modify some state.
520 &check_gnu_standards;
521 &check_gnits_standards;
523 &handle_configure ($output, $makefile, @secondary_inputs);
530 &handle_built_sources;
532 # This must be run after all the sources are scanned.
533 &handle_yacc_lex_cxx;
535 # Re-init SOURCES and OBJECTS. FIXME: other code shouldn't depend
536 # on this (but currently does).
537 $contents{'SOURCES'} = join (' ', @sources);
538 $contents{'OBJECTS'} = join (' ', @objects);
548 &handle_dependencies;
551 &handle_merge_targets ($makefile);
558 if (! -d ($output_directory . '/' . $am_relative_dir))
560 mkdir ($output_directory . '/' . $am_relative_dir, 0755);
563 local ($out_file) = $output_directory . '/' . $makefile . ".in";
564 if (! $force_generation && -e $out_file)
566 local ($am_time) = (stat ($makefile . '.am'))[9];
567 local ($in_time) = (stat ($out_file))[9];
568 # FIXME: how to do unsigned comparison?
569 if ($am_time < $in_time)
576 if (! open (GM_FILE, "> " . $out_file))
578 warn "automake: ${am_file}.in: cannot open: $!\n";
582 print "automake: creating ", $makefile, ".in\n" if $verbose;
584 print GM_FILE $output_vars;
585 print GM_FILE $output_header;
586 print GM_FILE $output_rules;
587 print GM_FILE $output_trailer;
592 ################################################################
594 # Handle AUTOMAKE_OPTIONS variable. Return 1 on error, 0 otherwise.
597 return 0 if ! &variable_defined ('AUTOMAKE_OPTIONS');
599 foreach (&variable_value_as_list ('AUTOMAKE_OPTIONS'))
602 if ($_ eq 'gnits' || $_ eq 'gnu' || $_ eq 'foreign')
604 &set_strictness ($_);
608 # An option like "../lib/ansi2knr" is allowed. With no
609 # path prefix, we assume the required programs are in this
610 # directory. We save the actual option for later.
611 $options{'ansi2knr'} = $_;
613 elsif ($_ eq 'no-installman' || $_ eq 'no-installinfo'
614 || $_ eq 'dist-shar' || $_ eq 'dist-zip'
615 || $_ eq 'dist-tarZ' || $_ eq 'dejagnu'
616 || $_ eq 'no-texinfo.tex')
618 # Explicitly recognize these.
620 elsif ($_ eq 'no-dependencies')
622 $use_dependencies = 0;
624 elsif (/([0-9]+)\.([0-9]+)/)
626 # Got a version number. Note that alpha releases count as
627 # the next higher release. Note also that we assume there
628 # will be a maximum of 100 minor releases for any given
630 local ($rmajor, $rminor) = ($1, $2);
631 if ($VERSION !~ /([0-9]+)\.([0-9]+)([a-z])?/)
634 "automake: programming error: version is incorrect\n";
637 local ($tmajor, $tminor) = ($1, $2);
638 # Handle alpha versions.
639 ++$tminor if defined $3;
641 if ($rmajor > $tmajor || ($rmajor == $tmajor && $rminor > $tminor))
643 &am_line_error ('AUTOMAKE_OPTIONS',
644 "require version $_, only have $VERSION");
650 &am_line_error ('AUTOMAKE_OPTIONS',
651 'option ', $_, 'not recognized');
658 # Return object extension. Just once, put some code into the output.
659 # Argument is the name of the output file
660 sub get_object_extension
665 $dir_holds_sources = 1;
667 # Maybe require libtool library object files.
668 local ($l, $extension) = ('', 'o');
669 $l = 'l' if ($out =~ /^lib.*\.la$/);
671 if (! $included_generic_compile)
675 if (&variable_defined ('CONFIG_HEADER'))
678 foreach $one_hdr (split (' ', $contents{'CONFIG_HEADER'}))
681 ($var = &dirname ($one_hdr)) =~ s/(\W)/\\$1/g;
682 $xform .= ' ' if $xform;
683 $xform .= '-I' . $var;
686 $xform = 's/\@CONFIG_INCLUDE_SPEC\@/' . $xform . '/go;';
687 $output_vars .= &file_contents_with_transform ($xform,
689 $output_rules .= &file_contents ('compile');
690 &push_phony_cleaners ('compile');
692 # If using X, include some extra variable definitions. NOTE
693 # we don't want to force these into CFLAGS or anything,
694 # because not all programs will necessarily use X.
698 foreach $var ('X_CFLAGS', 'X_LIBS', 'X_EXTRA_LIBS', 'X_PRE_LIBS')
700 &define_configure_variable ($var);
704 push (@suffixes, '.c', '.o');
705 push (@clean, 'compile');
707 $included_generic_compile = 1;
710 if ($seen_libtool && ! $included_libtool_compile)
712 # Output the libtool compilation rules.
713 $output_rules .= &file_contents ('libtool');
714 &push_phony_cleaners ('libtool');
716 push (@suffixes, '.lo');
717 push (@clean, 'libtool');
719 $included_libtool_compile = 1;
722 # Check for automatic de-ANSI-fication.
723 if (defined $options{'ansi2knr'})
726 if (! $included_knr_compile)
728 if (! $am_c_prototypes)
730 &am_line_error ('AUTOMAKE_OPTIONS',
731 "option \`ansi2knr' in use but \`AM_C_PROTOTYPES' not in configure.in");
732 &keyed_aclocal_warning ('AM_C_PROTOTYPES');
733 # Only give this error once.
734 $am_c_prototypes = 1;
737 push (@suffixes, '._c', '._o');
738 push (@suffixes, '.l_o') if $seen_libtool;
740 # Only require ansi2knr files if they should appear in
742 if ($options{'ansi2knr'} eq 'ansi2knr')
744 &require_file_with_line ('AUTOMAKE_OPTIONS', $FOREIGN,
745 'ansi2knr.c', 'ansi2knr.1');
746 $output_rules .= &file_contents ('kr-extra');
747 push (@clean, 'krextra');
748 &push_phony_cleaners ('krextra');
751 # Generate rules to build ansi2knr. If it is in some
752 # other directory, then generate dependencies but have the
753 # rule just run elsewhere.
754 $output_rules .= ($options{'ansi2knr'} . ': '
755 . $options{'ansi2knr'} . ".o\n");
756 if ($options{'ansi2knr'} eq 'ansi2knr')
758 $output_rules .= ("\t\$(LINK) ansi2knr.o \$(LIBS)\n"
759 . "ansi2knr.o: \$(CONFIG_HEADER)\n\n");
763 $output_rules .= ("\tcd " . &dirname ($options{'ansi2knr'})
764 . " && \$(MAKE) ansi2knr\n\n");
767 &define_variable ('o', "\@U\@o");
769 # Make sure ansi2knr can be found: if no path specified,
771 if ($options{'ansi2knr'} eq 'ansi2knr')
773 # Substitution from AM_C_PROTOTYPES. This makes it be
774 # built only when necessary.
775 &define_configure_variable ('ANSI2KNR');
776 # ansi2knr needs to be built before subdirs, so unshift it.
777 unshift (@all, '$(ANSI2KNR)');
781 # Found in another directory.
782 &define_variable ("ANSI2KNR", &dirname ($options{'ansi2knr'}));
785 $output_rules .= &file_contents ('compile-kr');
786 $output_rules .= &file_contents ('clean-kr');
789 &push_phony_cleaners ('kr');
791 $included_knr_compile = 1;
795 return '.' . $l . $extension;
798 # Handle yacc and lex.
799 sub handle_yacc_lex_cxx
802 # First do yacc and lex.
805 local ($yacc_count) = scalar (keys %yacc_sources);
806 local ($lex_count) = scalar (keys %lex_sources);
810 local (%seen_suffix) = ();
811 foreach (keys %yacc_sources)
814 &output_yacc_build_rule ($1, $yacc_count > 1)
815 if (! defined $seen_suffix{$1});
816 $seen_suffix{$1} = 1;
819 if (! defined $configure_vars{'YACC'})
821 &am_error ("yacc source seen but \`YACC' not defined in \`configure.in'");
826 local (%seen_suffix) = ();
827 foreach (keys %lex_sources)
830 &output_lex_build_rule ($1, $lex_count > 1)
831 if (! defined $seen_suffix{$1});
832 $seen_suffix{$1} = 1;
835 if (! defined $configure_vars{'LEX'})
837 &am_error ("lex source seen but \`LEX' not defined in \`configure.in'");
839 if (! $seen_decl_yytext)
841 &am_error ("lex source seen but \`AC_DECL_YYTEXT' not in \`configure.in'");
845 if ($yacc_count > 1 || $lex_count > 1)
847 # If there is more than one distinct yacc (resp lex) source
848 # file in a given directory, then the `interlock' program is
849 # required to allow parallel builds to work correctly. FIXME:
850 # for now, no line number.
851 &require_config_file ($FOREIGN, 'interlock', 'ylwrap');
852 if ($config_aux_dir ne '.' && $config_aux_dir ne '')
854 &define_variable ('INTERLOCK', $config_aux_dir . "/interlock");
855 &define_variable ('YLWRAP', $config_aux_dir . "/ylwrap");
859 &define_variable ('INTERLOCK', '$(srcdir)/interlock');
860 &define_variable ('YLWRAP', '$(srcdir)/ylwrap');
867 local ($ltcompile, $ltlink) = ('', '');
870 &define_configure_variable ("LIBTOOL");
871 $ltcompile = '$(LIBTOOL) --mode=compile ';
872 $ltlink = '$(LIBTOOL) --mode=link ';
878 local (@cxx_list) = keys %cxx_extensions;
879 local ($cxx_count) = scalar @cxx_list;
882 push (@suffixes, @cxx_list);
884 &define_configure_variable ("CXXFLAGS");
885 &define_variable ('CXXCOMPILE', '$(CXX) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CXXFLAGS)');
886 &define_variable ('LTCXXCOMPILE',
887 $ltcompile . '$(CXX) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CXXFLAGS)')
890 &define_variable ('CXXLINK', $ltlink . '$(CXX) $(LDFLAGS) -o $@');
893 foreach $ext (@cxx_list)
895 $output_rules .= ("$ext.o:\n"
896 . "\t\$(CXXCOMPILE) -c \$<\n");
897 $output_rules .= ("$ext.lo:\n"
898 . "\t\$(LTCXXCOMPILE) -c \$<\n")
902 if (! defined $configure_vars{'CXX'})
904 &am_error ("C++ source seen but \`CXX' not defined in \`configure.in'");
909 # Handle some ansi2knr cleanup.
911 if (defined $options{'ansi2knr'} && keys %de_ansi_objects)
913 # Make all ._o files depend on ansi2knr. Use a sneaky little
914 # hack to make it print nicely.
915 &pretty_print_rule ('', '', ((sort keys %de_ansi_objects),
916 ':', '$(ANSI2KNR)'));
917 # The ._c files also depend on ansi2knr. We need both because
918 # some makes don't apply transitivity through implicit rules.
919 local (%de_ansi_sources, $x);
920 foreach $x (keys %de_ansi_objects)
923 $de_ansi_sources{$x} = 1;
925 &pretty_print_rule ('', '', ((sort keys %de_ansi_sources),
926 ':', '$(ANSI2KNR)'));
930 # Last, handle some C cleanup.
934 &define_configure_variable ('CFLAGS');
935 &define_variable ('COMPILE',
936 '$(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)');
937 &define_variable ('LTCOMPILE',
939 '$(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)')
941 &define_variable ('LINK', $ltlink . '$(CC) $(LDFLAGS) -o $@');
943 if (! defined $configure_vars{'CC'})
945 &am_line_error ($seen_c_source,
946 "C source seen but \`CC' not defined in \`configure.in'");
952 # Output a rule to build from a YACC source. The output from YACC is
953 # compiled with C or C++, depending on the extension of the YACC file.
954 sub output_yacc_build_rule
956 local ($yacc_suffix, $use_interlock, $c_suffix) = @_;
958 local ($c_suffix, $suffix);
959 ($c_suffix = $yacc_suffix) =~ tr/y/c/;
960 push (@suffixes, $yacc_suffix, $c_suffix, '.h');
962 # Generate rule for c/c++ and header file. Probably should only
963 # do header if `yacc -d' is run.
964 foreach $suffix ($c_suffix, '.h')
966 $output_rules .= "$yacc_suffix$suffix:\n\t";
970 $output_rules .= ('$(SHELL) $(INTERLOCK) =yacclockdir $(YLWRAP)'
971 . ' "$(YACC)" y.tab.c $*' . $suffix
972 . ' y.tab.h $*.h -- $(YFLAGS) $<');
976 $output_rules .= ('$(YACC) $(YFLAGS) $< && mv y.tab.c $@' . "\n"
977 . "\tif test -f y.tab.h; then \\\n"
978 . "\tif cmp -s y.tab.h \$*.h; then rm -f y.tab.h; else mv y.tab.h \$*.h; fi; \\\n"
981 $output_rules .= "\n";
985 sub output_lex_build_rule
987 local ($lex_suffix, $use_interlock) = @_;
990 ($c_suffix = $lex_suffix) =~ tr/l/c/;
991 push (@suffixes, $lex_suffix);
992 &define_configure_variable ('LEX_OUTPUT_ROOT');
993 &define_configure_variable ('LEXLIB');
994 $output_rules .= "$lex_suffix$c_suffix:\n\t";
998 # is the $@ correct here? If so, why not use it in the
999 # interlock build rule for yacc above?
1000 $output_rules .= '$(SHELL) $(INTERLOCK) =lexlockdir $(YLWRAP)'
1001 . ' "$(LEX)" $(LEX_OUTPUT_ROOT).c $@ -- $(LFLAGS) $<';
1005 $output_rules .= '$(LEX) $(LFLAGS) $< && mv $(LEX_OUTPUT_ROOT).c $@';
1007 $output_rules .= "\n";
1011 # Check to make sure a source defined in LIBOBJS is not explicitly
1012 # mentioned. This is a separate function (as opposed to being inlined
1013 # in handle_source_transform) because it isn't always appropriate to
1015 sub check_libobjs_sources
1017 local ($one_file, $unxformed) = @_;
1019 local ($prefix, $file, @files);
1020 foreach $prefix ('', 'EXTRA_')
1022 if (&variable_defined ($prefix . $one_file . '_SOURCES'))
1024 @files = &variable_value_as_list ($prefix
1025 . $one_file . '_SOURCES');
1027 elsif ($prefix eq '')
1029 @files = ($unxformed . '.c');
1036 foreach $file (@files)
1038 if (defined $libsources{$file})
1040 &am_line_error ($prefix . $one_file . '_SOURCES',
1041 "automatically discovered file \`$file' should not be explicitly mentioned");
1047 # Does much of the actual work for handle_source_transform.
1049 # list of source files to transform
1051 # first element is name of linker to use (empty string for default linker)
1052 # remaining elements are names of `.o's
1053 sub handle_single_transform_list
1055 local (@files) = @_;
1056 local ($linker) = '';
1057 local (@result) = ();
1058 local ($nonansi_obj) = $obj;
1059 $nonansi_obj =~ s/_//g;
1060 if (length (@files))
1062 # Turn sources into objects.
1065 # Skip header files, including C++-ish ones. The list
1066 # of C++ header extensions comes from Emacs 19.32
1073 # Skip things that look like configure substitutions.
1076 # Include appropriate file for lex or yacc source in
1077 # distribution. If the extension is the regular '.y' or
1078 # '.l', we assume C compilation, and the generated file
1079 # has exension .c. Otherwise, we compile with C++, and
1080 # make the following association: (yy -> cc, y++ -> c++,
1081 # yxx -> cxx), similarly for .ll, etc.
1082 if (/^(.*)\.(y|yy|y\+\+|yxx)$/)
1087 &push_dist_common ("$1.$ext");
1088 $yacc_sources{$_} = 1;
1090 elsif (/^(.*)\.(l|ll|l\+\+|lxx)$/)
1095 &push_dist_common ("$1.$ext");
1096 $lex_sources{$_} = 1;
1099 # Transform source files into .o files. List of C++
1100 # extensions comes from Emacs 19.34 etags.
1101 if (s/\.(c\+\+|cc|cpp|cxx|C)$/$nonansi_obj/)
1103 $cxx_extensions{'.' . $1} = 1;
1104 $linker = 'CXXLINK';
1106 elsif (s/\.(yy|y\+\+|yxx|ll|l\+\+|lxx)$/$nonansi_obj/)
1108 # Compiling lex or yacc with C++
1111 $cxx_extensions{".$ext"} = 1;
1112 $linker = 'CXXLINK';
1114 elsif (s/\.([Ff]\\|f90\\|for)$/$nonansi_obj/)
1116 # FORTRAN support. FIXME: not finished.
1118 elsif (s/\.[sS]$/$nonansi_obj/)
1120 # .s is assembly. Just rewrite it. FIXME: not finished.
1122 elsif (s/\.[cly]$/._o/)
1124 # .c is C. .l is lex. .y is yacc.
1126 # Note: first we rewrite (eg) foo.c to foo._o and push
1127 # the file onto the list of objects that require
1128 # ansi2knr. Then we rewrite ._o to $obj; $obj can be
1129 # simply `.o' if deansification is not really
1131 $de_ansi_objects{$_} = 1;
1133 $seen_c_source = -1 unless $seen_c_source;
1137 # No error message here. Used to have one, but it was
1144 # Transform .o or $o file into .P file (for automatic
1147 $dep_files{'.deps/' . $_} = 1;
1151 return ($linker, @result);
1154 # Handle SOURCE->OBJECT transform for one program or library.
1156 # canonical (transformed) name of object to build
1157 # actual name of object to build
1158 # object extension (ie either `.o' or `$o'.
1159 # Return result is name of linker variable that must be used.
1160 # Empty return means just use `LINK'.
1161 sub handle_source_transform
1163 # one_file is canonical name. unxformed is given name. obj is
1165 local ($one_file, $unxformed, $obj) = @_;
1166 local ($objpat) = $obj;
1167 $objpat =~ s/(\W)/\\$1/g;
1168 # Handle explicit `.o' as well as whatever we're passed.
1169 $objpat = '(' . $objpat . "|\\.o)";
1171 local ($linker) = '';
1173 if (&variable_defined ($one_file . "_OBJECTS"))
1175 &am_line_error ($one_file . '_OBJECTS',
1176 $one_file . '_OBJECTS', 'should not be defined');
1177 # No point in continuing.
1181 local (@files, @result, $prefix, $temp);
1182 foreach $prefix ('', 'EXTRA_')
1185 if (&variable_defined ($prefix . $one_file . "_SOURCES"))
1187 push (@sources, '$(' . $prefix . $one_file . "_SOURCES)");
1188 push (@objects, '$(' . $prefix . $one_file . "_OBJECTS)")
1189 unless $prefix eq 'EXTRA_';
1190 @files = &variable_value_as_list ($prefix
1191 . $one_file . "_SOURCES");
1193 elsif ($prefix eq '')
1195 &define_variable ($one_file . "_SOURCES", $unxformed . ".c");
1196 push (@sources, $unxformed . '.c');
1197 push (@objects, $unxformed . $obj);
1198 push (@files, $unxformed . '.c');
1201 ($temp, @result) = &handle_single_transform_list (@files);
1202 $linker = $temp if $linker eq '';
1203 &define_pretty_variable ($one_file . "_OBJECTS", @result)
1204 unless $prefix eq 'EXTRA_';
1210 # Handle the BUILT_SOURCES variable.
1211 sub handle_built_sources
1213 return unless &variable_defined ('BUILT_SOURCES');
1214 push (@all, '$(BUILT_SOURCES)');
1216 local (@sources) = &variable_value_as_list ('BUILT_SOURCES');
1218 foreach $s (@sources)
1222 # FIXME: is this really the right thing to do?
1223 &am_line_error ('BUILT_SOURCES', "\`BUILT_SOURCES' should not contain a configure substitution");
1228 # We don't care about the return value of this function. We just
1229 # want to make sure to update %dep_files with the contents of
1231 &handle_single_transform_list (@sources);
1234 # Special-case @ALLOCA@ and @LIBOBJS@ in _LDADD or _LIBADD variables.
1235 # Also, generate _DEPENDENCIES variable if appropriate.
1237 # transformed name of object being built, or empty string if no object
1238 # name of _LDADD/_LIBADD-type variable to examine
1239 # boolean (lex_seen) which is true if a lex source file was seen in this
1240 # object. valid only for LDADDs, not LIBADDs. If set, LEXLIB
1242 # Returns 1 if LIBOBJS seen, 0 otherwise.
1243 sub handle_lib_objects
1245 local ($xname, $var, $lex_seen) = @_;
1247 die "automake: programming error 1 in handle_lib_objects\n"
1248 if ! &variable_defined ($var);
1250 die "automake: programming error 2 in handle_lib_objects\n"
1251 if $lex_seen && $var =~ /LIBADD/;
1253 # We recognize certain things that are commonly put in LIBADD or
1256 local (@dep_list) = ();
1258 # If no lex source seen, just assume this is ok.
1259 local ($lex_ok) = $lex_seen ? 0 : 1;
1261 local ($seen_libobjs) = 0;
1262 local ($flagvar) = 0;
1264 foreach $lsearch (&variable_value_as_list ($var))
1266 # Skip -lfoo and -Ldir; these are explicitly allowed.
1267 next if $lsearch =~ /^-[lL]/;
1268 if (! $flagvar && $lsearch =~ /^-/)
1270 if ($var =~ /^(.*)LDADD$/)
1272 &am_line_error ($var, "linker flags such as \`$lsearch' belong in \`${1}LDFLAGS");
1276 # Only get this error once.
1278 &am_line_error ($var, "you cannot use linker flags such as \`$lsearch' in \`$var'");
1282 # Assume we have a file of some sort, and push it onto the
1283 # dependency list. Autoconf substitutions are not pushed;
1284 # rarely is a new dependency substituted into (eg) foo_LDADD
1285 # -- but "bad things (eg -lX11) are routinely substituted.
1286 # Note that LIBOBJS and ALLOCA are exceptions to this rule,
1287 # and handled specially below.
1288 push (@dep_list, $lsearch)
1289 unless $lsearch =~ /^\@.*\@$/;
1291 # Automatically handle @LIBOBJS@ and @ALLOCA@. Basically this
1292 # means adding entries to dep_files.
1293 if ($lsearch =~ /^\@(LT)?LIBOBJS\@$/)
1295 push (@dep_list, $lsearch);
1297 if (! keys %libsources)
1299 &am_line_error ($var, "\@$1" . "LIBOBJS\@ seen but never set in \`configure.in'");
1302 local ($iter, $rewrite);
1303 foreach $iter (keys %libsources)
1305 if ($iter =~ /\.[cly]$/)
1307 $seen_c_source = $var;
1310 if ($iter =~ /\.h$/)
1312 &require_file_with_line ($var, $FOREIGN, $iter);
1314 elsif ($iter ne 'alloca.c')
1316 ($rewrite = $iter) =~ s/\.c$/.P/;
1317 $dep_files{'.deps/' . $rewrite} = 1;
1318 &require_file_with_line ($var, $FOREIGN, $iter);
1322 elsif ($lsearch =~ /^\@(LT)?ALLOCA\@$/)
1324 push (@dep_list, $lsearch);
1325 &am_line_error ($var,
1326 "\@$1" . "ALLOCA\@ seen but \`AC_FUNC_ALLOCA' not in \`configure.in'")
1327 if ! defined $libsources{'alloca.c'};
1328 $dep_files{'.deps/alloca.P'} = 1;
1329 &require_file_with_line ($var, $FOREIGN, 'alloca.c');
1330 $seen_c_source = $var;
1332 elsif ($lsearch eq '@LEXLIB@')
1334 # FIXME: variable_value_as_list requires us to force
1335 # @LEXLIB@ here, where we'd really prefer $(LEXLIB).
1336 # Nasty -- this will have to wait until many cleanups are
1344 &am_line_error ($var, 'lex source file used without @LEXLIB@');
1347 if ($xname ne '' && ! &variable_defined ($xname . '_DEPENDENCIES'))
1349 &define_pretty_variable ($xname . '_DEPENDENCIES', @dep_list);
1352 return $seen_libobjs;
1355 # Canonicalize a name, and check to make sure the non-canonical name
1356 # is never used. Returns canonical name. Arguments are name and a
1357 # list of suffixes to check for.
1358 sub check_canonical_spelling
1360 local ($name, @suffixes) = @_;
1361 local ($xname, $xt);
1363 ($xname = $name) =~ tr/A-Za-z0-9_/_/c;
1364 if ($xname ne $name)
1367 foreach $xt (@suffixes)
1369 &am_line_error ($name . $xt,
1370 "invalid variable \`" . $name . $xt
1371 . "'; should be \`" . $xname . $xt . "'")
1372 if &variable_defined ($name . $xt);
1379 # Handle C programs.
1382 local (@proglist) = &am_install_var ('-clean',
1383 'progs', 'PROGRAMS',
1384 'bin', 'sbin', 'libexec', 'pkglib',
1386 return if ! @proglist;
1388 # If a program is installed, this is required. We only want this
1389 # error to appear once.
1390 &am_conf_error ("AC_ARG_PROGRAM must be used in configure.in")
1391 unless $seen_arg_prog;
1394 local ($one_file, $xname, $munge);
1396 local ($seen_libobjs) = 0;
1397 foreach $one_file (@proglist)
1399 local ($obj) = &get_object_extension ($one_file);
1401 # Canonicalize names and check for misspellings.
1402 $xname = &check_canonical_spelling ($one_file, '_LDADD', '_LDFLAGS',
1403 '_SOURCES', '_OBJECTS',
1406 # FIXME: Using a trick to figure out if any lex sources appear
1407 # in our program; should use some cleaner method.
1408 local ($lex_num) = scalar (keys %lex_sources);
1409 local ($linker) = &handle_source_transform ($xname, $one_file, $obj);
1410 local ($lex_file_seen) = (scalar (keys %lex_sources) > $lex_num);
1413 if (&variable_defined ($xname . "_LDADD"))
1415 if (&handle_lib_objects ($xname, $xname . '_LDADD',
1425 # User didn't define prog_LDADD override. So do it.
1426 &define_variable ($xname . '_LDADD', '$(LDADD)');
1428 # This does a bit too much work. But we need it to
1429 # generate _DEPENDENCIES when appropriate.
1430 if (&variable_defined ('LDADD'))
1432 if (&handle_lib_objects ($xname, 'LDADD', $lex_file_seen))
1441 if (&variable_defined ($xname . '_LIBADD'))
1443 &am_line_error ($xname . '_LIBADD',
1444 "use \`" . $xname . "_LDADD', not \`"
1445 . $xname . "_LIBADD'");
1448 if (! &variable_defined ($xname . '_LDFLAGS'))
1450 # Define the prog_LDFLAGS variable.
1451 &define_variable ($xname . '_LDFLAGS', '');
1456 &am_line_error ($xname . $xt,
1457 'lex source file used without @LEXLIB@');
1460 # Determine program to use for link.
1462 if (&variable_defined ($xname . '_LINK'))
1464 $xlink = $xname . '_LINK';
1468 $xlink = $linker ? $linker : 'LINK';
1472 if (! $seen_cygwin32)
1474 $cygxform = 's/^CYGWIN.*$//; s/^NOTCYGWIN//;';
1478 $cygxform = 's/^NOTCYGWIN.*$//; s/^CYGWIN//;';
1482 &file_contents_with_transform
1483 ('s/\@PROGRAM\@/' . $one_file . '/go;'
1484 . 's/\@XPROGRAM\@/' . $xname . '/go;'
1485 . 's/\@XLINK\@/' . $xlink . '/go;'
1490 if (&variable_defined ('LDADD') && &handle_lib_objects ('', 'LDADD', 0))
1497 foreach $one_file (@proglist)
1499 # Canonicalize names.
1500 ($xname = $one_file) =~ tr/A-Za-z0-9_/_/c;
1502 if (&variable_defined ($xname . '_LDADD'))
1504 &check_libobjs_sources ($xname, $xname . '_LDADD');
1506 elsif (&variable_defined ('LDADD'))
1508 &check_libobjs_sources ($xname, 'LDADD');
1516 sub handle_libraries
1518 local (@liblist) = &am_install_var ('-clean',
1519 'libs', 'LIBRARIES',
1520 'lib', 'pkglib', 'noinst', 'check');
1521 return if ! @liblist;
1523 local (%valid) = &am_primary_prefixes ('LIBRARIES', 'lib', 'pkglib',
1525 if (! defined $configure_vars{'RANLIB'})
1528 foreach $key (keys %valid)
1530 if (&variable_defined ($key . '_LIBRARIES'))
1532 &am_line_error ($key . '_LIBRARIES', "library used but \`RANLIB' not defined in \`configure.in'");
1533 # Only get this error once.
1534 $configure_vars{'RANLIB'} = 1;
1543 local ($seen_libobjs) = 0;
1544 foreach $onelib (@liblist)
1546 # Check that the library fits the standard naming convention.
1547 if ($onelib !~ /^lib.*\.a$/)
1549 # FIXME this should only be a warning for foreign packages
1550 # FIXME should put line number here. That means mapping
1551 # from library name back to variable name.
1552 &am_error ("\`$onelib' is not a standard library name");
1555 local ($obj) = &get_object_extension ($onelib);
1557 # Canonicalize names and check for misspellings.
1558 $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_SOURCES',
1559 '_OBJECTS', '_DEPENDENCIES');
1561 if (&variable_defined ($xlib . '_LIBADD'))
1563 if (&handle_lib_objects ($xlib, $xlib . '_LIBADD', 0))
1570 # Generate support for conditional object inclusion in
1572 &define_variable ($xlib . "_LIBADD", '');
1575 if (&variable_defined ($xlib . '_LDADD'))
1577 &am_line_error ($xlib . '_LDADD',
1578 "use \`" . $xlib . "_LIBADD', not \`"
1579 . $xlib . "_LDADD'");
1582 &handle_source_transform ($xlib, $onelib, $obj);
1585 &file_contents_with_transform ('s/\@LIBRARY\@/' . $onelib . '/go;'
1593 foreach $onelib (@liblist)
1595 # Canonicalize names.
1596 ($xlib = $onelib) =~ tr/A-Za-z0-9_/_/c;
1597 if (&variable_defined ($xlib . '_LIBADD'))
1599 &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
1604 &define_variable ('AR', 'ar');
1605 &define_configure_variable ('RANLIB');
1608 # Handle shared libraries.
1609 sub handle_ltlibraries
1611 local (@liblist) = &am_install_var ('-clean',
1612 'ltlib', 'LTLIBRARIES',
1614 return if ! @liblist;
1617 local (%valid) = &am_primary_prefixes ('LTLIBRARIES', 'lib', 'pkglib');
1620 foreach $key (keys %valid)
1622 if (&variable_defined ($key . '_LTLIBRARIES'))
1626 &am_line_error ($key . '_LTLIBRARIES', "library used but \`LIBTOOL' not defined in \`configure.in'");
1627 # Only get this error once.
1628 $configure_vars{'LIBTOOL'} = 1;
1632 # Get the installation directory of each library.
1633 for (&variable_value_as_list ($key . '_LTLIBRARIES'))
1637 &am_error ("\`$_' is already going to be installed in \`$instdirs{$_}'");
1641 $instdirs{$_} = $key;
1650 local ($seen_libobjs) = 0;
1651 foreach $onelib (@liblist)
1653 # Check that the library fits the standard naming convention.
1654 if ($onelib !~ /^lib.*\.la$/)
1656 # FIXME this should only be a warning for foreign packages
1657 # FIXME should put line number here. That means mapping
1658 # from library name back to variable name.
1659 &am_error ("\`$onelib' is not a standard libtool library name");
1662 local ($obj) = &get_object_extension ($onelib);
1664 # Canonicalize names and check for misspellings.
1665 $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_LDFLAGS',
1666 '_SOURCES', '_OBJECTS',
1669 if (! &variable_defined ($xlib . '_LDFLAGS'))
1671 # Define the lib_LDFLAGS variable.
1672 &define_variable ($xlib . '_LDFLAGS', '');
1675 if (&variable_defined ($xlib . '_LIBADD'))
1677 if (&handle_lib_objects ($xlib, $xlib . '_LIBADD', 0))
1684 # Generate support for conditional object inclusion in
1686 &define_variable ($xlib . "_LIBADD", '');
1689 if (&variable_defined ($xlib . '_LDADD'))
1691 &am_line_error ($xlib . '_LDADD',
1692 "use \`" . $xlib . "_LIBADD', not \`"
1693 . $xlib . "_LDADD'");
1696 local ($linker) = &handle_source_transform ($xlib, $onelib, $obj);
1698 # Determine program to use for link.
1700 if (&variable_defined ($xlib . '_LINK'))
1702 $xlink = $xlib . '_LINK';
1706 $xlink = $linker ? $linker : 'LINK';
1710 if ($instdirs{$onelib} eq 'EXTRA')
1712 # It's an EXTRA_ library, so we can't specify -rpath.
1714 $rpath = 's/\@RPATH\@//go;';
1718 $rpath = ('s/\@RPATH\@/-rpath \$(' . $instdirs{$onelib}
1723 &file_contents_with_transform ('s/\@LTLIBRARY\@/'
1725 . 's/\@XLTLIBRARY\@/'
1728 . 's/\@XLINK\@/' . $xlink . '/go;',
1734 foreach $onelib (@liblist)
1736 # Canonicalize names.
1737 ($xlib = $onelib) =~ tr/A-Za-z0-9_/_/c;
1738 if (&variable_defined ($xlib . '_LIBADD'))
1740 &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
1746 # See if any _SOURCES variable were misspelled. Also, make sure that
1747 # EXTRA_ variables don't contain configure substitutions.
1750 local ($varname, $primary);
1751 foreach $varname (keys %contents)
1753 foreach $primary ('_SOURCES', '_LIBADD', '_LDADD', '_LDFLAGS', '_DEPENDENCIES')
1755 if ($varname =~ /$primary$/ && ! $content_seen{$varname})
1757 &am_line_error ($varname,
1758 "invalid unused variable name: \`$varname'");
1767 # NOTE we no longer automatically clean SCRIPTS, because it is
1768 # useful to sometimes distribute scripts verbatim. This happens
1769 # eg in Automake itself.
1770 &am_install_var ('scripts', 'SCRIPTS',
1771 'bin', 'sbin', 'libexec', 'pkgdata',
1774 # Set $scripts_installed if appropriate. Make sure we only find
1775 # scripts which are actually installed -- this is why we can't
1776 # simply use the return value of am_install_var.
1777 local (%valid) = &am_primary_prefixes ('SCRIPTS', 'bin', 'sbin',
1778 'libexec', 'pkgdata',
1781 foreach $key (keys %valid)
1783 if ($key ne 'noinst'
1785 && &variable_defined ($key . '_SCRIPTS'))
1787 $scripts_installed = 1;
1788 # push (@check_tests, 'check-' . $key . 'SCRIPTS');
1792 if ($scripts_installed)
1794 # If a program is installed, this is required. We only want this
1795 # error to appear once.
1796 &am_conf_error ("AC_ARG_PROGRAM must be used in configure.in")
1797 unless $seen_arg_prog;
1802 # Search a file for a "version.texi" Texinfo include. Return the name
1803 # of the include file if found, or the empty string if not. A
1804 # "version.texi" file is actually any file whose name matches
1806 sub scan_texinfo_file
1808 local ($filename) = @_;
1810 if (! open (TEXI, $filename))
1812 &am_error ("couldn't open \`$filename': $!");
1815 print "automake: reading $filename\n" if $verbose;
1817 local ($vfile, $outfile);
1820 if (/^\@setfilename +(\S+)/)
1826 if (/^\@include\s+(vers[^.]*\.texi)\s*$/)
1828 # Found version.texi include.
1835 return ($outfile, $vfile);
1838 # Handle all Texinfo source.
1841 &am_line_error ('TEXINFOS',
1842 "\`TEXINFOS' is an anachronism; use \`info_TEXINFOS'")
1843 if &variable_defined ('TEXINFOS');
1844 return if (! &variable_defined ('info_TEXINFOS')
1845 && ! &variable_defined ('html_TEXINFOS'));
1847 local (@texis) = &variable_value_as_list ('info_TEXINFOS');
1849 local (@info_deps_list, @dvis_list, @texi_deps);
1850 local ($infobase, $info_cursor);
1854 local ($tc_cursor, @texi_cleans);
1857 foreach $info_cursor (@texis)
1859 ($infobase = $info_cursor) =~ s/\.texi(nfo)?$//;
1861 # If 'version.texi' is referenced by input file, then include
1862 # automatic versioning capability.
1863 local ($out_file, $vtexi) = &scan_texinfo_file ($relative_dir
1864 . "/" . $info_cursor);
1866 if ($out_file eq '')
1868 &am_error ("\`$info_cursor' missing \@setfilename");
1872 if ($out_file =~ /\.(.+)$/ && $1 ne 'info')
1874 # FIXME should report line number in input file.
1875 &am_error ("output of \`$info_cursor', \`$out_file', has unrecognized extension");
1881 &am_error ("\`$vtexi', included in \`$info_cursor', also included in \`$versions{$vtexi}'")
1882 if (defined $versions{$vtexi});
1883 $versions{$vtexi} = $info_cursor;
1885 # We number the stamp-vti files. This is doable since the
1886 # actual names don't matter much. We only number starting
1887 # with the second one, so that the common case looks nice.
1888 $vti = 'vti' . ($done ? $done : '');
1889 &push_dist_common ($vtexi, 'stamp-' . $vti);
1890 push (@clean, $vti);
1892 # Only require once.
1893 &require_conf_file_with_line ('info_TEXINFOS', $FOREIGN,
1899 ($conf_pat = $config_aux_dir) =~ s/(\W)/\\$1/g;
1901 &file_contents_with_transform
1902 ('s/\@TEXI\@/' . $info_cursor . '/g; '
1903 . 's/\@VTI\@/' . $vti . '/g; '
1904 . 's/\@VTEXI\@/' . $vtexi . '/g;'
1905 . 's,\@MDDIR\@,' . $conf_pat . ',g;',
1908 &push_phony_cleaners ($vti);
1911 # If user specified file_TEXINFOS, then use that as explicit
1914 push (@texi_deps, $info_cursor);
1915 push (@texi_deps, $vtexi) if $vtexi;
1917 # Canonicalize name first.
1918 ($canonical = $infobase) =~ tr/A-Za-z0-9_/_/c;
1919 if (&variable_defined ($canonical . "_TEXINFOS"))
1921 push (@texi_deps, '$(' . $canonical . '_TEXINFOS)');
1922 &push_dist_common ('$(' . $canonical . '_TEXINFOS)');
1925 $output_rules .= ("\n" . $out_file . ": "
1926 . join (' ', @texi_deps)
1927 . "\n" . $infobase . ".dvi: "
1928 . join (' ', @texi_deps)
1931 push (@info_deps_list, $out_file);
1932 push (@dvis_list, $infobase . '.dvi');
1934 # Generate list of things to clean for this target. We do
1935 # this explicitly because otherwise too many things could be
1936 # removed. In particular the ".log" extension might
1937 # reasonably be used in other contexts by the user.
1938 foreach $tc_cursor ('aux', 'cp', 'cps', 'dvi', 'fn', 'fns',
1939 'ky', 'log', 'pg', 'toc', 'tp', 'tps',
1940 'vr', 'vrs', 'op', 'tr', 'cv')
1942 push (@texi_cleans, $infobase . '.' . $tc_cursor);
1946 # Find these programs wherever they may lie. Yes, this has
1947 # intimate knowledge of the structure of the texinfo distribution.
1948 &define_program_variable ('MAKEINFO', 'build', 'texinfo/makeinfo',
1950 # Circumlocution to avoid accidental
1951 # configure substitution.
1953 &define_program_variable ('TEXI2DVI', 'src', 'texinfo/util',
1956 # Set transform for including texinfos.am. First, handle --cygnus
1961 $xform = 's/^NOTCYGNUS.*$//; s/^CYGNUS//;';
1965 $xform = 's/^CYGNUS.*$//; s/^NOTCYGNUS//;';
1968 # Handle location of texinfo.tex.
1971 &define_variable ('TEXINFO_TEX',
1972 '$(top_srcdir)/../texinfo/texinfo.tex');
1974 elsif (! &variable_defined ('TEXINFO_TEX'))
1976 &define_variable ('TEXINFO_TEX', '$(srcdir)/texinfo.tex');
1978 local ($xxform) = &dirname ($contents{'TEXINFO_TEX'});
1979 $xxform =~ s/(\W)/\\$1/g;
1980 $xform .= ' s/\@TEXINFODIR\@/' . $xxform . '/g;';
1982 $output_rules .= &file_contents_with_transform ($xform, 'texinfos');
1983 push (@phony, 'install-info-am', 'uninstall-info');
1984 push (@dist_targets, 'dist-info');
1986 # How to clean. The funny name is due to --cygnus influence; in
1987 # Cygnus mode, `clean-info' is a target that users can use.
1988 $output_rules .= "\nmostlyclean-aminfo:\n";
1989 &pretty_print_rule ("\trm -f", "\t ", @texi_cleans);
1990 $output_rules .= ("\nclean-aminfo:\n\ndistclean-aminfo:\n\n"
1991 . "maintainer-clean-aminfo:\n\t"
1992 . 'for i in $(INFO_DEPS); do rm -f `eval echo $$i*`; done'
1994 &push_phony_cleaners ('aminfo');
1997 $output_rules .= "clean-info: mostlyclean-aminfo\n";
2000 push (@suffixes, '.texi', '.texinfo', '.info', '.dvi', '.ps');
2002 if (! defined $options{'no-installinfo'})
2004 push (@uninstall, 'uninstall-info');
2005 push (@installdirs, '$(infodir)');
2006 unshift (@install_data, 'install-info-am');
2008 # Make sure documentation is made and installed first. Use
2009 # $(INFO_DEPS), not 'info', because otherwise recursive makes
2010 # get run twice during "make all".
2011 unshift (@all, '$(INFO_DEPS)');
2013 push (@clean, 'info');
2014 push (@info, '$(INFO_DEPS)');
2015 push (@dvi, '$(DVIS)');
2017 &define_variable ("INFO_DEPS", join (' ', @info_deps_list));
2018 &define_variable ("DVIS", join (' ', @dvis_list));
2019 # This next isn't strictly needed now -- the places that look here
2020 # could easily be changed to look in info_TEXINFOS. But this is
2021 # probably better, in case noinst_TEXINFOS is ever supported.
2022 &define_variable ("TEXINFOS", $contents{'info_TEXINFOS'});
2024 # Do some error checking. Note that this file is not required
2025 # when in Cygnus mode; instead we defined TEXINFO_TEX explicitly
2027 &require_file_with_line ('info_TEXINFOS', $FOREIGN, 'texinfo.tex')
2028 unless (defined $options{'no-texinfo.tex'}
2029 || &variable_defined ('TEXINFO_TEX'));
2032 # Handle any man pages.
2033 sub handle_man_pages
2035 &am_line_error ('MANS', "\`MANS' is an anachronism; use \`man_MANS'")
2036 if &variable_defined ('MANS');
2037 return if ! &variable_defined ('man_MANS');
2039 # We generate the manpage install code by hand to avoid the use of
2040 # basename in the generated Makefile.
2041 local (@mans) = &variable_value_as_list ('man_MANS');
2042 local (%sections, %inames, %mbases, %secmap, %fullsecmap);
2046 # FIXME: statement without effect:
2047 /^(.*)\.([0-9])([a-z]*)$/;
2052 $fullsecmap{$i} = $2 . $3;
2056 # We don't really need this, but we use it in case we ever want to
2057 # support noinst_MANS.
2058 &define_variable ("MANS", $contents{'man_MANS'});
2060 # Generate list of install dirs.
2061 $output_rules .= "install-man: \$(MANS)\n";
2062 $output_rules .= "\t\$(NORMAL_INSTALL)\n";
2063 # Sort keys so that output is deterministic.
2064 foreach (sort keys %sections)
2066 push (@installdirs, '$(mandir)/man' . $_)
2067 unless defined $options{'no-installman'};
2068 $output_rules .= ("\t" . '$(mkinstalldirs) $(mandir)/man'
2071 push (@phony, 'install-man');
2073 # Generate install target.
2075 foreach $key (sort keys %inames)
2077 $_ = $install_man_format;
2078 s/\@SECTION\@/$secmap{$key}/g;
2079 s/\@MAN\@/$inames{$key}/g;
2080 s/\@FULLSECT\@/$fullsecmap{$key}/g;
2081 s/\@MANBASE\@/$mbases{$key}/g;
2082 $output_rules .= $_;
2084 $output_rules .= "\n";
2086 $output_rules .= "uninstall-man:\n\t\$(NORMAL_UNINSTALL)\n";
2087 foreach $key (sort keys %inames)
2089 $_ = $uninstall_man_format;
2090 s/\@SECTION\@/$secmap{$key}/g;
2091 s/\@MAN\@/$inames{$key}/g;
2092 s/\@FULLSECT\@/$fullsecmap{$key}/g;
2093 s/\@MANBASE\@/$mbases{$key}/g;
2094 $output_rules .= $_;
2096 $output_rules .= "\n";
2097 push (@phony, 'uninstall-man');
2099 $output_vars .= &file_contents ('mans-vars');
2101 if (! defined $options{'no-installman'})
2103 push (@install_data, 'install-man');
2104 push (@uninstall, 'uninstall-man');
2105 push (@all, '$(MANS)');
2109 # Handle DATA variables.
2112 &am_install_var ('data', 'DATA', 'data', 'sysconf',
2113 'sharedstate', 'localstate', 'pkgdata',
2120 push (@phony, 'tags');
2121 local (@tag_deps) = ();
2122 if (&variable_defined ('SUBDIRS'))
2124 $output_rules .= ("tags-recursive:\n"
2125 . "\tlist=\'\$(SUBDIRS)\'; for subdir in \$\$list; do \\\n"
2126 # Never fail here if a subdir fails; it
2128 . "\t (cd \$\$subdir && \$(MAKE) tags); \\\n"
2130 push (@tag_deps, 'tags-recursive');
2131 push (@phony, 'tags-recursive');
2134 if ($dir_holds_sources
2135 || $dir_holds_headers
2136 || &variable_defined ('ETAGS_ARGS')
2139 local ($xform) = '';
2141 foreach $one_hdr (@config_headers)
2143 if ($relative_dir eq &dirname ($one_hdr))
2145 # The config header is in this directory. So require it.
2147 ($var = &basename ($one_hdr)) =~ s/(\W)/\\$1/g;
2148 $xform .= ' ' if $xform;
2152 $xform = ('s/\@CONFIG\@/' . $xform . '/;'
2153 . 's/\@DIRS\@/' . join (' ', @tag_deps) . '/;');
2155 if (&variable_defined ('SUBDIRS'))
2157 $xform .= 's/^SUBDIRS//;';
2161 $xform .= 's/^SUBDIRS.*$//;';
2164 $output_rules .= &file_contents_with_transform ($xform, 'tags');
2165 $output_rules .= &file_contents ('tags-clean');
2166 push (@clean, 'tags');
2167 &push_phony_cleaners ('tags');
2168 &examine_variable ('TAGS_DEPENDENCIES');
2170 elsif (&variable_defined ('TAGS_DEPENDENCIES'))
2172 &am_line_error ('TAGS_DEPENDENCIES',
2173 "doesn't make sense to define \`TAGS_DEPENDENCIES' without sources or \`ETAGS_ARGS'");
2177 # Every Makefile must define some sort of TAGS rule.
2178 # Otherwise, it would be possible for a top-level "make TAGS"
2179 # to fail because some subdirectory failed.
2180 $output_rules .= "tags: TAGS\nTAGS:\n\n";
2184 # Worker for handle_dist.
2185 sub handle_dist_worker
2187 $output_rules .= 'distdir: $(DISTFILES)' . "\n";
2189 # Initialization; only at top level.
2190 if ($relative_dir eq '.')
2192 if ($strictness >= $GNITS)
2194 # For Gnits users, this is pretty handy. Look at 15 lines
2195 # in case some explanatory text is desirable.
2196 $output_rules .= ' @if sed 15q $(srcdir)/NEWS | fgrep -e "$(VERSION)" > /dev/null; then :; else \\
2197 echo "NEWS not updated; not releasing" 1>&2; \\
2205 # Create dist directory.
2208 -chmod 755 $(distdir)
2211 # Only run automake in `dist' target if --include-deps and
2212 # `no-dependencies' not specified. That way the recipient of
2213 # a distribution can run "make dist" and not need Automake.
2214 if ($use_dependencies)
2218 # We need an absolute path for --output-dir. Thus the
2220 ' here=`pwd`; distdir=`cd $(distdir) && pwd` \\
2222 && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(srcdir) --output-dir=$$distdir '
2223 # Set strictness of output.
2224 . ($cygnus_mode ? '--cygnus' : ('--' . $strictness_name))
2230 # Scan EXTRA_DIST to see if we need to distribute anything from a
2231 # subdir. If so, add it to the list. I didn't want to do this
2232 # originally, but there were so many requests that I finally
2235 if (&variable_defined ('EXTRA_DIST'))
2237 foreach (&variable_value_as_list ('EXTRA_DIST'))
2240 next unless s,/+[^/]+$,,;
2241 push (@dist_dirs, $_)
2247 # Prepend $(distdir) to each directory given. Doing it via a
2248 # hash lets us ensure that each directory is used only once.
2250 grep ($dhash{'$(distdir)/' . $_} = 1, @dist_dirs);
2251 $output_rules .= "\t";
2252 &pretty_print_rule ('$(mkinstalldirs)', "\t ", sort keys %dhash);
2255 # In loop, test for file existence because sometimes a file gets
2256 # included in DISTFILES twice. For example this happens when a
2257 # single source file is used in building more than one program.
2258 # Also, there are situations in which "ln" can fail. For instance
2259 # a file to distribute could actually be a cross-filesystem
2260 # symlink -- this can easily happen if "gettextize" was run on the
2262 $output_rules .= "\t\@for file in \$(DISTFILES); do \\\n";
2265 $output_rules .= "\t if test -f \$\$file; then d=.; else d=\$(srcdir); fi; \\\n";
2269 $output_rules .= "\t d=\$(srcdir); \\\n";
2271 $output_rules .= ' test -f $(distdir)/$$file \\
2272 || ln $$d/$$file $(distdir)/$$file 2> /dev/null \\
2273 || cp -p $$d/$$file $(distdir)/$$file; \\
2277 # If we have SUBDIRS, create all dist subdirectories and do
2279 if (&variable_defined ('SUBDIRS'))
2281 # Test for directory existence here because previous automake
2282 # invocation might have created some directories. Note that
2283 # we explicitly set distdir for the subdir make; that lets us
2284 # mix-n-match many automake-using packages into one large
2285 # package, and have "dist" at the top level do the right
2287 $output_rules .= ' for subdir in $(SUBDIRS); do \\
2288 test -d $(distdir)/$$subdir \\
2289 || mkdir $(distdir)/$$subdir \\
2291 chmod 755 $(distdir)/$$subdir; \\
2292 (cd $$subdir && $(MAKE) distdir=../$(distdir)/$$subdir distdir) \\
2298 # If the target `dist-hook' exists, make sure it is run. This
2299 # allows users to do random weird things to the distribution
2300 # before it is packaged up.
2301 push (@dist_targets, 'dist-hook') if defined $contents{'dist-hook'};
2304 foreach $targ (@dist_targets)
2306 # We must explicitly set distdir for these sub-makes.
2307 $output_rules .= "\t\$(MAKE) distdir=\"\$(distdir)\" $targ\n";
2310 push (@phony, 'distdir');
2313 # Handle 'dist' target.
2316 # Set up maint_charset.
2317 $local_maint_charset = $contents{'MAINT_CHARSET'}
2318 if &variable_defined ('MAINT_CHARSET');
2319 $maint_charset = $local_maint_charset
2320 if $relative_dir eq '.';
2322 if (&variable_defined ('DIST_CHARSET'))
2324 &am_line_error ('DIST_CHARSET',
2325 "DIST_CHARSET defined but no MAINT_CHARSET defined")
2326 if ! $local_maint_charset;
2327 if ($relative_dir eq '.')
2329 $dist_charset = $contents{'DIST_CHARSET'}
2333 &am_line_error ('DIST_CHARSET',
2334 "DIST_CHARSET can only be defined at top level");
2338 # Look for common files that should be included in distribution.
2340 foreach $cfile (@common_files)
2342 if (-f ($relative_dir . "/" . $cfile))
2344 &push_dist_common ($cfile);
2348 # Keys of %dist_common are names of files to distributed. We put
2349 # README first because it then becomes easier to make a
2350 # Usenet-compliant shar file (in these, README must be first).
2351 # FIXME: do more ordering of files here.
2353 if (defined $dist_common{'README'})
2355 push (@coms, 'README');
2356 delete $dist_common{'README'};
2358 push (@coms, sort keys %dist_common);
2360 &define_pretty_variable ("DIST_COMMON", @coms);
2361 $output_vars .= "\n";
2364 $output_vars .= &file_contents ('dist-vars') . "\n";
2365 &define_variable ('TAR', $TAR);
2366 &define_variable ('GZIP', '--best');
2368 # Put these things in rules section so it is easier for whoever
2369 # reads Makefile.in.
2370 if (! &variable_defined ('distdir'))
2372 if ($relative_dir eq '.')
2374 $output_rules .= "\n" . 'distdir = $(PACKAGE)-$(VERSION)' . "\n";
2378 $output_rules .= ("\n"
2379 . 'distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)'
2383 if ($relative_dir ne '.')
2385 $output_rules .= "\nsubdir = " . $relative_dir . "\n";
2388 # Generate 'dist' target, and maybe dist-shar / dist-zip / dist-tarZ.
2389 if ($relative_dir eq '.')
2391 # Rule to check whether a distribution is viable.
2392 $output_rules .= ('# This target untars the dist file and tries a VPATH configuration. Then
2393 # it guarantees that the distribution is self-contained by making another
2397 GZIP=$(GZIP) $(TAR) zxf $(distdir).tar.gz
2398 mkdir $(distdir)/=build
2399 mkdir $(distdir)/=inst
2400 dc_install_base=`cd $(distdir)/=inst && pwd`; \\'
2401 . (defined $contents{'distcheck-hook'}
2402 ? "\t\$(MAKE) distcheck-hook"
2405 cd $(distdir)/=build \\
2408 . ($seen_gettext ? '--with-included-gettext ' : '')
2409 . '--srcdir=.. --prefix=$$dc_install_base \\
2413 && $(MAKE) install \\
2414 && $(MAKE) installcheck \\
2417 @echo "========================"; \\
2418 echo "$(distdir).tar.gz is ready for distribution"; \\
2419 echo "========================"
2422 local ($dist_all) = ('dist-all: distdir' . "\n"
2425 foreach $curs ('dist', 'dist-shar', 'dist-zip', 'dist-tarZ')
2427 if (defined $options{$curs} || $curs eq 'dist')
2429 $output_rules .= ($curs . ': distdir' . "\n"
2433 $dist_all .= $dist{$curs};
2436 $output_rules .= $dist_all . $dist_trailer;
2439 # Generate distdir target.
2440 &handle_dist_worker;
2443 # Scan a single dependency file and rewrite the dependencies as
2444 # appropriate. Essentially this means:
2445 # * Clean out absolute dependencies which are not desirable.
2446 # * Rewrite other dependencies to be relative to $(top_srcdir).
2447 sub scan_dependency_file
2449 local ($depfile) = @_;
2451 if (! open (DEP_FILE, $depfile))
2453 &am_error ("couldn't open \`$depfile': $!");
2456 print "automake: reading $depfile\n" if $verbose;
2458 # Sometimes it is necessary to omit some dependencies.
2459 local (%omit) = %omit_dependencies;
2460 if (&variable_defined ('OMIT_DEPENDENCIES'))
2462 grep ($omit{$_} = 1, &variable_value_as_list ('OMIT_DEPENDENCIES'));
2465 local ($first_line) = 1;
2466 local ($last_line) = 0;
2467 local ($target, @dependencies);
2468 local ($one_dep, $xform);
2471 local ($srcdir_rx, $fixup_rx);
2472 # If the top srcdir is absolute, then the current directory is
2473 # just relative_dir. But if the top srcdir is relative, then we
2474 # need to add some dots first. The same holds when matching
2476 if ($srcdir_name =~ /^\//)
2478 ($fixup_rx = $srcdir_name . '/' . $relative_dir . '/')
2480 ($srcdir_rx = $srcdir_name . '/') =~ s/(\W)/\\$1/g;
2484 ($fixup_rx = ($srcdir_name . '/' . $top_builddir . '/'
2485 . $relative_dir . '/')) =~ s/(\W)/\\$1/g;
2486 $srcdir_rx = $srcdir_name . '/';
2487 # Don't append a spurious "." to the regex.
2488 $srcdir_rx .= $top_builddir
2489 unless $top_builddir eq '.';
2490 $srcdir_rx =~ s/(\W)/\\$1/g;
2493 local ($rewrite_builddir) = (($top_builddir eq '.')
2495 : $top_builddir . '/');
2501 # If LAST_LINE set then we've already seen what we thought
2502 # was the last line.
2505 next if (/$WHITE_PATTERN/o);
2509 # No trailing "\" means this should be the last line.
2515 if (! /^([^:]+:)(.+)$/)
2518 &am_error ("\`$depfile' has incorrect format");
2524 # Make sure to strip the .P file from the target.
2525 ($target = $1) =~ s, *\.deps/[^.]+\.P,,;
2530 foreach $one_dep (split (' ', $_))
2532 if ($one_dep =~ /^$fixup_rx/)
2534 # The dependency points to the current directory in
2536 ($xform = $one_dep) =~ s/^$fixup_rx//;
2537 push (@dependencies, $xform);
2539 elsif ($one_dep =~ /^$srcdir_rx/)
2541 # The dependency is in some other directory in the package.
2542 ($xform = $one_dep) =~ s/^$srcdir_rx/$rewrite_builddir/;
2543 push (@dependencies, $xform);
2545 elsif ($one_dep =~ /^\//)
2547 # Absolute path; ignore.
2551 # Anything else is assumed to be correct. But first
2552 # make sure it is not on our list of dependencies to
2554 ($just_file = $one_dep) =~ s,^.*/,,;
2555 push (@dependencies, $one_dep)
2556 if ! defined $omit{$just_file};
2561 &pretty_print_rule ($target, "\t", @dependencies);
2566 # Handle auto-dependency code.
2567 sub handle_dependencies
2569 if ($use_dependencies)
2571 # Include GNU-make-specific auto-dep code.
2572 if ($dir_holds_sources)
2574 &define_pretty_variable ('DEP_FILES', sort keys %dep_files);
2575 $output_rules .= &file_contents ('depend');
2576 push (@clean, 'depend');
2577 &push_phony_cleaners ('depend');
2579 &file_contents_with_transform ('s/\@EXT\@/.c/g;'
2580 . 's/\@MKDEP\@/MKDEP/g;'
2584 local ($need_cxx) = 0;
2585 foreach $ext (sort keys %cxx_extensions)
2588 &file_contents_with_transform ('s/\@EXT\@/' . $ext .'/g;'
2589 . 's/\@MKDEP\@/CXXMKDEP/g;'
2596 &define_variable ('CXXMKDEP', '$(CXX) -M $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CXXFLAGS)');
2600 elsif ($build_directory ne '')
2602 # Include any auto-generated deps that are present. Note that
2603 # $build_directory ends in a "/".
2604 if (-d ($build_directory . $relative_dir . "/.deps")
2605 && -f ($build_directory . $relative_dir . "/.deps/.P"))
2609 foreach $depfile (&my_glob ($build_directory
2610 . $relative_dir . "/.deps/*.P"))
2612 &scan_dependency_file ($depfile);
2615 $output_rules .= "\n";
2620 # Handle subdirectories.
2623 return if ! &variable_defined ('SUBDIRS');
2625 # Make sure each directory mentioned in SUBDIRS actually exists.
2627 foreach $dir (&variable_value_as_list ('SUBDIRS'))
2629 # Skip directories substituted by configure.
2630 next if $dir =~ /^\@.*\@$/;
2632 if (! -d $am_relative_dir . '/' . $dir)
2634 &am_line_error ('SUBDIRS',
2635 "required directory $am_relative_dir/$dir does not exist");
2639 &am_line_error ('SUBDIRS', "directory should not contain \`/'")
2643 local ($xform) = ('s/\@INSTALLINFO\@/' .
2644 (defined $options{'no-installinfo'}
2645 ? 'install-info-recursive'
2648 $output_rules .= &file_contents_with_transform ($xform, 'subdirs');
2650 # Push a bunch of phony targets.
2652 foreach $phonies ('-data', '-exec', 'dirs')
2654 push (@phony, 'install' . $phonies . '-recursive');
2655 push (@phony, 'uninstall' . $phonies . '-recursive');
2657 foreach $phonies ('all', 'check', 'installcheck', 'info', 'dvi')
2659 push (@phony, $phonies . '-recursive');
2661 &push_phony_cleaners ('recursive');
2663 push (@check_tests, "check-recursive");
2664 push (@installcheck, "installcheck-recursive");
2665 push (@info, "info-recursive");
2666 push (@dvi, "dvi-recursive");
2668 $recursive_install = 1;
2671 # Handle aclocal.m4.
2672 sub handle_aclocal_m4
2674 local ($regen_aclocal) = 0;
2675 if (-f 'aclocal.m4')
2677 &define_variable ("ACLOCAL_M4", '$(top_srcdir)/aclocal.m4');
2678 &push_dist_common ('aclocal.m4');
2680 if (open (ACLOCAL, '< aclocal.m4'))
2686 if ($line =~ 'generated automatically by aclocal')
2693 local ($acinclude) = 0;
2694 if (-f 'acinclude.m4')
2700 # Note that it might be possible that aclocal.m4 doesn't exist but
2701 # should be auto-generated. This case probably isn't very
2705 local (@ac_deps) = (
2706 ($seen_maint_mode ? "\@MAINT\@" : "") ,
2708 ($acinclude ? ' acinclude.m4' : '')
2711 # Scan all -I directories for m4 files. These are our
2713 if (&variable_defined ('ACLOCAL_AMFLAGS'))
2716 foreach $amdir (&variable_value_as_list ('ACLOCAL_AMFLAGS'))
2718 if ($amdir =~ s/^-I//
2722 push (@ac_deps, &my_glob ($am_dir . '/*.m4'));
2727 &pretty_print_rule ("\$(ACLOCAL_M4):", "\t\t", @ac_deps);
2729 $output_rules .= ("\t"
2730 . 'cd $(srcdir) && $(ACLOCAL)'
2731 . (&variable_defined ('ACLOCAL_AMFLAGS')
2732 ? ' $(ACLOCAL_AMFLAGS)' : '')
2737 # Rewrite a list of input files into a form suitable to put on a
2738 # dependency list. The idea is that if an input file has a directory
2739 # part the same as the current directory, then the directory part is
2740 # simply removed. But if the directory part is different, then
2741 # $(top_srcdir) is prepended. Among other things, this is used to
2742 # generate the dependency list for the output files generated by
2743 # AC_OUTPUT. Consider what the dependencies should look like in this
2745 # AC_OUTPUT(src/out:src/in1:lib/in2)
2746 sub rewrite_inputs_into_dependencies
2748 local (@inputs) = @_;
2749 local ($single, @newinputs);
2751 foreach $single (@inputs)
2753 if (&dirname ($single) eq $relative_dir)
2755 push (@newinputs, &basename ($single));
2759 push (@newinputs, '$(top_srcdir)/' . $single);
2766 # Handle remaking and configure stuff.
2767 # We need the name of the input file, to do proper remaking rules.
2768 sub handle_configure
2770 local ($local, $input, @secondary_inputs) = @_;
2772 # If SUBDIRS defined, require AC_PROG_MAKE_SET.
2773 &am_line_error ('SUBDIRS', "AC_PROG_MAKE_SET must be used in configure.in")
2774 if &variable_defined ('SUBDIRS') && ! $seen_make_set;
2776 local ($top_reldir);
2778 local ($input_base) = &basename ($input);
2779 local ($local_base) = &basename ($local);
2781 local ($amfile) = $input_base . '.am';
2782 # We know we can always add '.in' because it really should be an
2783 # error if the .in was missing originally.
2784 local ($infile) = '$(srcdir)/' . $input_base . '.in';
2785 local ($colon_infile);
2786 if ($local ne $input)
2788 $colon_infile = ':' . $input . '.in';
2790 $colon_infile .= ':' . join (':', @secondary_inputs)
2791 if @secondary_inputs;
2793 local (@rewritten) = &rewrite_inputs_into_dependencies (@secondary_inputs);
2794 # This rule remakes the Makefile.in. Note use of @MAINT@ forces
2795 # us to abandon pretty-printing. Sigh.
2796 $output_rules .= ($infile
2797 # NOTE perl 5.003 (with -w) gives a
2798 # uninitialized value error on the next line.
2801 . ($seen_maint_mode ? '@MAINT@ ' : '')
2803 . '$(top_srcdir)/configure.in $(ACLOCAL_M4) '
2804 . join (' ', @rewritten) . "\n"
2805 . "\tcd \$(top_srcdir) && \$(AUTOMAKE) "
2806 . ($cygnus_mode ? '--cygnus' : ('--' . $strictness_name))
2807 . ' ' . $input . $colon_infile . "\n\n");
2809 # This rule remakes the Makefile.
2810 $output_rules .= ($local_base
2811 # NOTE: bogus uninit value error on next line;
2812 # see comment above.
2815 . '$(top_builddir)/config.status $(BUILT_SOURCES)'
2817 . "\tcd \$(top_builddir) \\\n"
2818 . "\t && CONFIG_FILES="
2819 . (($relative_dir eq '.') ? '$@' : '$(subdir)/$@')
2821 . ' CONFIG_HEADERS= $(SHELL) ./config.status'
2824 if ($relative_dir ne '.')
2827 $top_reldir = '../';
2832 $output_rules .= &file_contents ('remake');
2833 &examine_variable ('CONFIGURE_DEPENDENCIES');
2837 # If we have a configure header, require it.
2839 local (@local_fullnames) = @config_fullnames;
2840 local (@local_names) = @config_names;
2841 local ($hdr_index) = 0;
2842 local ($distclean_config) = '';
2843 foreach $one_hdr (@config_headers)
2845 local ($one_fullname) = shift (@local_fullnames);
2846 local ($one_name) = shift (@local_names);
2848 if ($relative_dir eq &dirname ($one_hdr))
2850 local ($ch_sans_dir) = &basename ($one_hdr);
2851 local ($cn_sans_dir) = &basename ($one_name);
2853 &require_file_with_conf_line ($config_header_line,
2854 $FOREIGN, $ch_sans_dir);
2856 # Header defined and in this directory.
2858 if (-f $relative_dir . '/acconfig.h')
2860 push (@files, 'acconfig.h');
2862 if (-f $one_name . '.top')
2864 push (@files, "${cn_sans_dir}.top");
2866 if (-f $one_name . '.bot')
2868 push (@files, "${cn_sans_dir}.bot");
2871 &push_dist_common (@files);
2873 local ($stamp_name) = 'stamp-h';
2874 $stamp_name .= "${hdr_index}" if scalar (@config_headers) > 1;
2876 local ($xform) = '';
2878 $xform = 's/\@FILES\@/' . join (' ', @files) . '/;';
2879 $xform .= 's/\@CONFIG_HEADER\@/' . "${cn_sans_dir}" . '/;';
2880 $xform .= 's/\@CONFIG_HEADER_IN\@/' . "${ch_sans_dir}" . '/;';
2881 $xform .= 's/\@CONFIG_HEADER_FULL\@/' . "${one_fullname}" . '/;';
2882 $xform .= 's/\@STAMP\@/' . "${stamp_name}" . '/;';
2884 $output_rules .= &file_contents_with_transform ($xform,
2887 &touch ($relative_dir . "/${stamp_name}.in");
2888 &require_file_with_conf_line ($config_header_line, $FOREIGN,
2889 "${stamp_name}.in");
2891 $distclean_config .= ' ' if $distclean_config;
2892 $distclean_config .= $cn_sans_dir;
2896 if ($distclean_config)
2898 $output_rules .= &file_contents_with_transform ('s/\@FILES\@/'
2902 push (@clean, 'hdr');
2903 &push_phony_cleaners ('hdr');
2906 # Set location of mkinstalldirs.
2907 if ($config_aux_dir ne '.' && $config_aux_dir ne '')
2909 &define_variable ('mkinstalldirs', ('$(SHELL) ' . $config_aux_dir
2910 . '/mkinstalldirs'));
2914 &define_variable ('mkinstalldirs',
2915 '$(SHELL) $(top_srcdir)/mkinstalldirs');
2918 &am_line_error ('CONFIG_HEADER',
2919 "\`CONFIG_HEADER' is an anachronism; now determined from \`configure.in'")
2920 if &variable_defined ('CONFIG_HEADER');
2923 local ($config_header) = '';
2924 foreach $one_name (@config_names)
2926 # Generate CONFIG_HEADER define.
2928 if ($relative_dir eq &dirname ($one_name))
2930 $one_hdr = &basename ($one_name);
2934 $one_hdr = "${top_builddir}/${one_name}";
2937 $config_header .= ' ' if $config_header;
2938 $config_header .= $one_hdr;
2942 &define_variable ("CONFIG_HEADER", $config_header);
2945 # Now look for other files in this directory which must be remade
2946 # by config.status, and generate rules for them.
2947 local (@actual_other_files) = ();
2948 local ($file, $local);
2949 local (@inputs, @rewritten_inputs, $single);
2950 foreach $file (@other_input_files)
2952 if ($file =~ /^(.*):(.*)$/)
2954 # This is the ":" syntax of AC_OUTPUT.
2956 $local = &basename ($file);
2957 @inputs = split (':', $2);
2958 @rewritten_inputs = &rewrite_inputs_into_dependencies (@inputs);
2963 $local = &basename ($file);
2964 @inputs = ($local . '.in');
2966 &rewrite_inputs_into_dependencies ($file . '.in');
2969 # Skip files not in this directory.
2970 next unless &dirname ($file) eq $relative_dir;
2972 # Skip any file that is an automake input.
2973 next if -f $file . '.am';
2975 # Some users have been tempted to put `stamp-h' in the
2976 # AC_OUTPUT line. This won't do the right thing, so we
2977 # explicitly fail here.
2978 if ($local eq 'stamp-h')
2980 # FIXME: allow real filename.
2981 &am_conf_error ('configure.in', $ac_output_line,
2982 'stamp-h should not appear in AC_OUTPUT');
2986 $output_rules .= ($local . ': '
2987 . '$(top_builddir)/config.status '
2988 . join (' ', @rewritten_inputs) . "\n"
2990 . 'cd $(top_builddir) && CONFIG_FILES='
2991 . ($relative_dir eq '.' ? '' : '$(subdir)/')
2992 . '$@' . (length (@rewritten_inputs) > 1
2993 ? (':' . join (':', @rewritten_inputs))
2995 . ' CONFIG_HEADERS= ./config.status'
2997 push (@actual_other_files, $local);
2999 # Require all input files.
3000 &require_file_with_conf_line ($ac_output_line, $FOREIGN,
3004 # These files get removed by "make clean".
3005 &define_pretty_variable ('CONFIG_CLEAN_FILES', @actual_other_files);
3011 $dir_holds_headers = &am_install_var ('header', 'HEADERS', 'include',
3012 'oldinclude', 'pkginclude',
3018 return if ! $seen_gettext || $relative_dir ne '.';
3020 if (! &variable_defined ('SUBDIRS'))
3023 ("AM_GNU_GETTEXT in configure.in but SUBDIRS not defined");
3027 &require_file_with_conf_line ($ac_gettext_line, $FOREIGN, 'ABOUT-NLS')
3030 if (&variable_defined ('SUBDIRS'))
3034 "AM_GNU_GETTEXT in configure.in but \`po' not in SUBDIRS")
3035 if $contents{'SUBDIRS'} !~ /\bpo\b/;
3038 "AM_GNU_GETTEXT in configure.in but \`intl' not in SUBDIRS")
3039 if $contents{'SUBDIRS'} !~ /\bintl\b/;
3042 # Ensure that each language in ALL_LINGUAS has a .po file, and
3043 # each po file is mentioned in ALL_LINGUAS.
3046 local (%linguas) = ();
3047 grep ($linguas{$_} = 1, split (' ', $all_linguas));
3054 &am_line_error ($all_linguas_line,
3055 ("po/$_.po exists but \`$_' not in \`ALL_LINGUAS'"))
3059 foreach (keys %linguas)
3061 &am_line_error ($all_linguas_line,
3062 "$_ in \`ALL_LINGUAS' but po/$_.po does not exist")
3068 &am_error ("AM_GNU_GETTEXT in configure.in but \`ALL_LINGUAS' not defined");
3072 # Handle footer elements.
3075 if ($contents{'SOURCES'})
3077 # NOTE don't use define_pretty_variable here, because
3078 # $contents{...} is already defined.
3079 $output_vars .= 'SOURCES = ' . $contents{'SOURCES'} . "\n";
3081 if ($contents{'OBJECTS'})
3083 # NOTE don't use define_pretty_variable here, because
3084 # $contents{...} is already defined.
3085 $output_vars .= 'OBJECTS = ' . $contents{'OBJECTS'} . "\n";
3087 if ($contents{'SOURCES'} || $contents{'OBJECTS'})
3089 $output_vars .= "\n";
3092 if (&variable_defined ('SUFFIXES'))
3094 # Push actual suffixes, and not $(SUFFIXES). Some versions of
3095 # make do not like variable substitutions on the .SUFFIXES
3097 push (@suffixes, &variable_value_as_list ('SUFFIXES'));
3099 if (&target_defined ('.SUFFIXES'))
3101 &am_line_error ('.SUFFIXES',
3102 "use variable \`SUFFIXES', not target \`.SUFFIXES'");
3105 # Note: AIX 4.1 /bin/make will fail if any suffix rule appears
3106 # before .SUFFIXES. So we make sure that .SUFFIXES appears before
3107 # anything else, by sticking it right after the default: target.
3108 $output_header .= ".SUFFIXES:\n";
3112 # Make sure suffixes has unique elements. Sort them to ensure
3113 # the output remains consistent.
3116 grep ($suffixes{$_} = 1, @suffixes);
3118 $output_header .= (".SUFFIXES: "
3119 . join (' ', sort keys %suffixes)
3122 $output_trailer .= &file_contents ('footer');
3125 # Deal with installdirs target.
3126 sub handle_installdirs
3128 # GNU Makefile standards recommend this.
3129 $output_rules .= ("installdirs:"
3130 . ($recursive_install
3131 ? " installdirs-recursive\n"
3133 push (@phony, 'installdirs');
3136 &pretty_print_rule ("\t" . '$(mkinstalldirs) ', "\t\t",
3139 $output_rules .= "\n";
3142 # There are several targets which need to be merged. This is because
3143 # their complete definition is compiled from many parts. Note that we
3144 # avoid double colon rules, otherwise we'd use them instead.
3145 sub handle_merge_targets
3147 local ($makefile) = @_;
3149 # There are a few install-related variables that you should not define.
3151 foreach $var ('PRE_INSTALL', 'POST_INSTALL', 'NORMAL_INSTALL')
3153 if (&variable_defined ($var))
3155 &am_line_error ($var, "\`$var' should not be defined");
3159 # Put this at the beginning for the sake of non-GNU makes. This
3160 # is still wrong if these makes can run parallel jobs. But it is
3162 unshift (@all, &basename ($makefile));
3165 foreach $one_name (@config_names)
3167 push (@all, &basename ($one_name))
3168 if &dirname ($one_name) eq $relative_dir;
3171 &do_one_merge_target ('info', @info);
3172 &do_one_merge_target ('dvi', @dvi);
3173 &do_check_merge_target;
3174 &do_one_merge_target ('installcheck', @installcheck);
3176 if (defined $options{'no-installinfo'})
3178 # FIXME: this is kind of a hack; should find another way to
3179 # know that this is required.
3181 if (grep ($_ eq 'install-info-am', @phony))
3183 push (@dirs, 'install-info-am');
3185 if (&variable_defined ('SUBDIRS'))
3187 push (@dirs, 'install-info-recursive');
3189 &do_one_merge_target ('install-info', @dirs);
3192 # Handle the various install targets specially. We do this so
3193 # that (eg) "make install-exec" will run "install-exec-recursive"
3194 # if required, but "make install" won't run it twice. Step one is
3195 # to see if the user specified local versions of any of the
3196 # targets we handle. "all" is treated as one of these since
3197 # "install" can run it.
3198 push (@install_exec, 'install-exec-local')
3199 if defined $contents{'install-exec-local'};
3200 push (@install_data, 'install-data-local')
3201 if defined $contents{'install-data-local'};
3202 push (@uninstall, 'uninstall-local')
3203 if defined $contents{'uninstall-local'};
3205 foreach $utarg ('uninstall-data-local', 'uninstall-data-hook',
3206 'uninstall-exec-local', 'uninstall-exec-hook')
3208 if (defined $contents{$utarg})
3211 ($x = $utarg) =~ s/(data|exec)-//;
3212 &am_line_error ($utarg, "use \`$x', not \`$utarg'");
3215 push (@all, 'all-local')
3216 if defined $contents{'all-local'};
3218 if (defined $contents{'install-local'})
3220 &am_line_error ('install-local',
3221 "use \`install-data' or \`install-exec', not \`install'");
3224 # Step two: if we are doing recursive makes, write out the
3225 # appropriate rules.
3227 if ($recursive_install)
3229 push (@install, 'install-recursive');
3233 local (@hackall) = ();
3235 local ($local_headers) = '';
3236 foreach $one_name (@config_names)
3238 if (&dirname ($one_name) eq $relative_dir)
3240 $local_headers .= ' ' if $local_headers;
3241 $local_headers .= &basename ($one_name);
3247 # This is kind of a hack, but I couldn't see a better
3248 # way to handle it. In this particular case, we need
3249 # to make sure config.h is built before we recurse.
3250 # We can't do this by changing the order of
3251 # dependencies to the "all" because that breaks when
3252 # using parallel makes. Instead we handle things
3254 $output_rules .= ("all-recursive-am: ${local_headers}"
3255 . "\n\t" . '$(MAKE) all-recursive'
3257 push (@hackall, 'all-recursive-am');
3258 push (@phony, 'all-recursive-am');
3262 push (@hackall, 'all-recursive');
3265 $output_rules .= ('all-am: '
3269 push (@all, 'all-am');
3270 push (@phony, 'all-am');
3274 @all = ('all-recursive');
3276 # Must always generate `all-am' target, so it can be
3277 # referred to elsewhere.
3278 $output_rules .= "all-am:\n";
3282 $output_rules .= ('install-exec-am: '
3283 . join (' ', @install_exec)
3285 @install_exec = ('install-exec-recursive', 'install-exec-am');
3286 push (@install, 'install-exec-am');
3287 push (@phony, 'install-exec-am');
3291 @install_exec = ('install-exec-recursive');
3295 $output_rules .= ('install-data-am: '
3296 . join (' ', @install_data)
3298 @install_data = ('install-data-recursive', 'install-data-am');
3299 push (@install, 'install-data-am');
3300 push (@phony, 'install-data-am');
3304 @install_data = ('install-data-recursive');
3308 $output_rules .= ('uninstall-am: '
3309 . join (' ', @uninstall)
3311 @uninstall = ('uninstall-recursive', 'uninstall-am');
3312 push (@phony, 'uninstall-am');
3316 @uninstall = ('uninstall-recursive');
3320 # Step three: print definitions users can use. Code below knows
3321 # that install-exec is done before install-data, beware.
3322 $output_rules .= ("install-exec: "
3323 . join (' ', @install_exec)
3325 $output_rules .= "\t\@\$(NORMAL_INSTALL)\n";
3326 if (defined $contents{'install-exec-hook'})
3328 $output_rules .= "\t" . '$(MAKE) install-exec-hook' . "\n";
3330 $output_rules .= "\n";
3331 push (@install, 'install-exec') if !$recursive_install;
3332 push (@phony, 'install-exec');
3334 $output_rules .= ("install-data: "
3335 . join (' ', @install_data)
3337 $output_rules .= "\t\@\$(NORMAL_INSTALL)\n";
3338 if (defined $contents{'install-data-hook'})
3340 $output_rules .= "\t" . '$(MAKE) install-data-hook' . "\n";
3342 $output_rules .= "\n";
3343 push (@install, 'install-data') if !$recursive_install;
3344 push (@phony, 'install-data');
3346 # If no dependencies for 'install', add 'all'. Why? That way
3347 # "make install" at top level of distclean'd distribution won't
3348 # fail because stuff in 'lib' fails to build.
3349 if (! @install || (scalar (@install) == 2
3350 && $install[0] eq 'install-exec'
3351 && $install[1] eq 'install-data'))
3353 push (@install, 'all');
3355 $output_rules .= ('install: '
3356 . join (' ', @install)
3357 # Use "@:" as empty command so nothing prints.
3361 . join (' ', @uninstall)
3363 push (@phony, 'install', 'uninstall');
3365 $output_rules .= ('all: '
3368 push (@phony, 'all');
3370 # Generate the new 'install-strip' target.
3371 $output_rules .= ("install-strip:\n\t"
3372 . '$(MAKE) INSTALL_PROGRAM=\'$(INSTALL_PROGRAM) -s\' install'
3376 # Helper for handle_merge_targets.
3377 sub do_one_merge_target
3379 local ($name, @values) = @_;
3381 if (defined $contents{$name . '-local'})
3383 # User defined local form of target. So include it.
3384 push (@values, $name . '-local');
3385 push (@phony, $name . '-local');
3388 &pretty_print_rule ($name . ":", "\t\t", @values);
3389 push (@phony, $name);
3392 # Handle check merge target specially.
3393 sub do_check_merge_target
3395 if (defined $contents{'check-local'})
3397 # User defined local form of target. So include it.
3398 push (@check_tests, 'check-local');
3399 push (@phony, 'check-local');
3402 if (! &variable_defined ('SUBDIRS'))
3404 # 'check' must depend on `all', but not when doing recursive
3406 unshift (@check, 'all');
3410 # When subdirs are used, do the `all' build and then do all
3411 # the recursive stuff. Actually use `all-am' because it
3412 # doesn't recurse; we rely on the check target in the subdirs
3413 # to do the required builds there.
3414 unshift (@check, 'all-am');
3417 # The check target must depend on the local equivalent of `all',
3418 # to ensure all the primary targets are built. Also it must
3419 # depend on the test code named in @check.
3420 &pretty_print_rule ('check:', "\t\t", @check);
3422 # Now the check rules must explicitly run anything named in
3423 # @check_tests. This is done via a separate make invocation to
3424 # avoid problems with parallel makes. Every time I write code
3425 # like this I wonder: how could you invent a parallel make and not
3426 # provide any real synchronization facilities?
3427 &pretty_print_rule ("\t\$(MAKE)", "\t ", @check_tests);
3430 # Handle all 'clean' targets.
3433 push (@clean, 'generic');
3434 $output_rules .= &file_contents ('clean');
3435 &push_phony_cleaners ('generic');
3437 local ($target) = $recursive_install ? 'clean-am' : 'clean';
3438 &do_one_clean_target ($target, 'mostly', '', @clean);
3439 &do_one_clean_target ($target, '', 'mostly', @clean);
3440 &do_one_clean_target ($target, 'dist', '', @clean);
3441 &do_one_clean_target ($target, 'maintainer-', 'dist', @clean);
3443 push (@phony, 'clean', 'mostlyclean', 'distclean', 'maintainer-clean');
3446 if ($recursive_install)
3448 # Do -recursive before -am. If you aren't doing a parallel
3449 # make, this can be nicer.
3450 @deps = ('recursive', 'am');
3451 &do_one_clean_target ('', 'mostly', '', @deps);
3452 &do_one_clean_target ('', '', '', @deps);
3453 &do_one_clean_target ('', 'dist', '', @deps);
3454 &do_one_clean_target ('', 'maintainer-', '', @deps);
3458 # Helper for handle_clean.
3459 sub do_one_clean_target
3461 local ($target, $name, $last_name, @deps) = @_;
3463 # Special case: if target not passed, then don't generate
3464 # dependency on next "lower" clean target (eg no
3465 # clean<-mostlyclean derivation). In this case the target is
3466 # implicitly known to be 'clean'.
3467 local ($flag) = $target;
3468 $target = 'clean' if ! $flag;
3470 grep (($_ = $name . 'clean-' . $_) && 0, @deps);
3473 if ($last_name || $name ne 'mostly')
3475 push (@deps, $last_name . $target);
3479 # If a -local version of the rule is given, add it to the list.
3480 if (defined $contents{$name . $target . '-local'})
3482 push (@deps, $name . $target . '-local');
3485 # Print the target and the dependencies.
3486 &pretty_print_rule ($name . $target . ": ", "\t\t", @deps);
3488 # FIXME: shouldn't we really print these messages before running
3490 if ($name . $target eq 'maintainer-clean')
3492 # Print a special warning.
3494 ("\t\@echo \"This command is intended for maintainers to use;\"\n"
3495 . "\t\@echo \"it deletes files that may require special "
3496 . "tools to rebuild.\"\n");
3498 $output_rules .= "\trm -f config.status\n"
3499 if $relative_dir eq '.';
3501 elsif ($name . $target eq 'distclean')
3503 $output_rules .= "\trm -f config.status\n";
3504 $output_rules .= "\trm -f libtool\n" if $seen_libtool;
3506 $output_rules .= "\n";
3509 # Handle .PHONY target.
3512 &pretty_print_rule ('.PHONY:', "", @phony);
3513 $output_rules .= "\n";
3516 # Handle TESTS variable and other checks.
3519 if (defined $options{'dejagnu'})
3521 push (@check_tests, 'check-DEJAGNU');
3522 push (@phony, 'check-DEJAGNU');
3527 $xform = 's/^CYGNUS//;';
3531 $xform = 's/^CYGNUS.*$//;';
3533 $output_rules .= &file_contents_with_transform ($xform, 'dejagnu');
3535 # In Cygnus mode, these are found in the build tree.
3536 # Otherwise they are looked for in $PATH.
3537 &define_program_variable ('EXPECT', 'build', 'expect', 'expect');
3538 &define_program_variable ('RUNTEST', 'src', 'dejagnu', 'runtest');
3540 # Note that in the rule we don't directly generate site.exp to
3541 # avoid the possibility of a corrupted site.exp if make is
3542 # interrupted. Jim Meyering has some useful text on this
3544 $output_rules .= ("site.exp: Makefile\n"
3545 . "\t\@echo 'Making a new site.exp file...'\n"
3546 . "\t-\@rm -f site.bak\n"
3547 . "\t\@echo '## these variables are automatically generated by make ##' > \$\@-t\n"
3548 . "\t\@echo '# Do not edit here. If you wish to override these values' >> \$\@-t\n"
3549 . "\t\@echo '# edit the last section' >> \$\@-t\n"
3550 . "\t\@echo 'set tool \$(DEJATOOL)' >> \$\@-t\n"
3551 . "\t\@echo 'set srcdir \$(srcdir)' >> \$\@-t\n"
3552 . "\t\@echo 'set objdir' \`pwd\` >> \$\@-t\n");
3554 # Extra stuff for AC_CANONICAL_*
3555 local (@whatlist) = ();
3556 if ($seen_canonical)
3558 push (@whatlist, 'host')
3561 # Extra stuff only for AC_CANONICAL_SYSTEM.
3562 if ($seen_canonical == $AC_CANONICAL_SYSTEM)
3564 push (@whatlist, 'target', 'build');
3568 foreach $c1 (@whatlist)
3570 foreach $c2 ('alias', 'triplet')
3572 $output_rules .= "\t\@echo 'set ${c1}_${c2} \$(${c1}_${c2})' >> \$\@-t\n";
3576 $output_rules .= ("\t\@echo '## All variables above are generated by configure. Do Not Edit ##' >> \$\@-t\n"
3577 . "\t-\@sed '1,/^## All variables above are.*##/ d' site.bak >> \$\@-t\n"
3578 . "\t-\@mv site.exp site.bak\n"
3579 . "\t\@mv \$\@-t site.exp\n");
3584 foreach $c ('DEJATOOL', 'RUNTEST', 'RUNTESTFLAGS')
3586 if (&variable_defined ($c))
3588 &am_line_error ($c, "\`$c' defined but \`dejagnu' not in \`AUTOMAKE_OPTIONS'");
3593 if (&variable_defined ('TESTS'))
3595 push (@check_tests, 'check-TESTS');
3596 push (@phony, 'check-TESTS');
3598 $output_rules .= 'check-TESTS: $(TESTS)
3599 @failed=0; all=0; \\
3600 srcdir=$(srcdir); export srcdir; \\
3601 for tst in $(TESTS); do \\
3602 all=`expr $$all + 1`; \\
3603 if test -f $$tst; then dir=.; \\
3604 else dir="$(srcdir)"; fi; \\
3605 if $(TESTS_ENVIRONMENT) $$dir/$$tst; then \\
3606 echo "PASS: $$tst"; \\
3608 failed=`expr $$failed + 1`; \\
3609 echo "FAIL: $$tst"; \\
3612 if test "$$failed" -eq 0; then \\
3613 echo "========================"; \\
3614 echo "All $$all tests passed"; \\
3615 echo "========================"; \\
3617 echo "$$failed of $$all tests failed"; \\
3624 # Handle Emacs Lisp.
3625 sub handle_emacs_lisp
3627 local (@elfiles) = &am_install_var ('lisp', 'LISP', 'lisp', 'noinst');
3632 &define_configure_variable ('lispdir');
3633 &define_configure_variable ('EMACS');
3634 $output_rules .= (".el.elc:\n"
3635 . "\t\@echo 'WARNING: Warnings can be ignored. :-)'\n"
3636 . "\tif test \$(EMACS) != no; then \\\n"
3637 . "\t EMACS=\$(EMACS) \$(SHELL) \$(srcdir)/elisp-comp \$<; \\\n"
3639 push (@suffixes, '.el', '.elc');
3641 # Generate .elc files.
3642 grep ($_ .= 'c', @elfiles);
3643 &define_pretty_variable ('ELCFILES', @elfiles);
3645 push (@clean, 'lisp');
3646 &push_phony_cleaners ('lisp');
3648 push (@all, '$(ELCFILES)');
3651 if (&variable_defined ('lisp_LISP'))
3653 $varname = 'lisp_LISP';
3654 &am_error ("\`lisp_LISP' defined but \`AM_PATH_LISPDIR' not in \`configure.in'")
3659 $varname = 'noinst_LISP';
3662 &require_file_with_line ($varname, $FOREIGN, 'elisp-comp');
3666 ################################################################
3668 # Scan one file for interesting things. Subroutine of scan_configure.
3669 sub scan_one_configure_file
3671 local ($filename) = @_;
3673 open (CONFIGURE, $filename)
3674 || die "automake: couldn't open \`$filename': $!\n";
3675 print "automake: reading $filename\n" if $verbose;
3679 # Remove comments from current line.
3683 # Skip macro definitions. Otherwise we might be confused into
3684 # thinking that a macro that was only defined was actually
3688 # Populate libobjs array.
3689 if (/AC_FUNC_ALLOCA/)
3691 $libsources{'alloca.c'} = 1;
3693 elsif (/AC_FUNC_GETLOADAVG/)
3695 $libsources{'getloadavg.c'} = 1;
3697 elsif (/AC_FUNC_MEMCMP/)
3699 $libsources{'memcmp.c'} = 1;
3701 elsif (/AC_STRUCT_ST_BLOCKS/)
3703 $libsources{'fileblocks.c'} = 1;
3705 elsif (/A[CM]_REPLACE_GNU_GETOPT/)
3707 $libsources{'getopt.c'} = 1;
3708 $libsources{'getopt1.c'} = 1;
3710 elsif (/AM_FUNC_STRTOD/)
3712 $libsources{'strtod.c'} = 1;
3714 elsif (/AM_WITH_REGEX/)
3716 $libsources{'rx.c'} = 1;
3717 $libsources{'rx.h'} = 1;
3718 $libsources{'regex.c'} = 1;
3719 $libsources{'regex.h'} = 1;
3720 $omit_dependencies{'rx.h'} = 1;
3721 $omit_dependencies{'regex.h'} = 1;
3723 elsif (/AM_FUNC_MKTIME/)
3725 $libsources{'mktime.c'} = 1;
3727 elsif (/AM_FUNC_ERROR_AT_LINE/)
3729 $libsources{'error.c'} = 1;
3730 $libsources{'error.h'} = 1;
3732 elsif (/AM_FUNC_OBSTACK/)
3734 $libsources{'obstack.c'} = 1;
3735 $libsources{'obstack.h'} = 1;
3737 elsif (/LIBOBJS="(.*)\s+\$LIBOBJS"/
3738 || /LIBOBJS="\$LIBOBJS\s+(.*)"/)
3740 foreach $libobj_iter (split (' ', $1))
3742 if ($libobj_iter =~ /^(.*)\.o$/)
3744 $libsources{$1 . '.c'} = 1;
3749 if (! $in_ac_replace && s/AC_REPLACE_FUNCS\s*\(\[?//)
3755 $in_ac_replace = 0 if s/[\]\)].*$//;
3756 # Remove trailing backslash.
3760 # Need to skip empty elements for Perl 4.
3762 $libsources{$_ . '.c'} = 1;
3766 if (/$obsolete_rx/o)
3769 if ($obsolete_macros{$1})
3771 $hint = '; ' . $obsolete_macros{$1};
3773 &am_conf_line_error ($filename, $., "\`$1' is obsolete$hint");
3776 # Process the AC_OUTPUT macro.
3777 if (! $in_ac_output && s/AC_OUTPUT\s*\(\[?//)
3780 $ac_output_line = $.;
3784 $in_ac_output = 0 if s/[\]\),].*$//;
3786 # Look at potential Makefile.am's.
3791 # Handle $local:$input syntax. Note that we ignore
3792 # every input file past the first, though we keep
3793 # those around for later.
3794 local ($local, $input, @rest) = split (/:/);
3801 # FIXME: should be error if .in is missing.
3802 $input =~ s/\.in$//;
3805 if (-f $input . '.am')
3807 # We have a file that automake should generate.
3808 push (@make_input_list, $input);
3809 $make_list{$input} = join (':', ($local, @rest));
3813 # We have a file that automake should cause to be
3814 # rebuilt, but shouldn't generate itself.
3815 push (@other_input_files, $_);
3820 if (/$AC_CONFIG_AUX_DIR_PATTERN/o)
3822 @config_aux_path = $1;
3825 # Check for ansi2knr.
3826 $am_c_prototypes = 1 if /AM_C_PROTOTYPES/;
3828 # Check for Cygwin32.
3832 $configure_vars{'EXEEXT'} = 1;
3835 # Check for NLS support.
3836 if (/AM_GNU_GETTEXT/)
3839 $ac_gettext_line = $.;
3840 $omit_dependencies{'libintl.h'} = 1;
3843 # Look for ALL_LINGUAS.
3844 if (/ALL_LINGUAS="(.*)"$/ || /ALL_LINGUAS=(.*)$/)
3848 $all_linguas_line = $.;
3851 # Handle configuration headers. A config header of `[$1]'
3852 # means we are actually scanning AM_CONFIG_HEADER from
3854 if (/A([CM])_CONFIG_HEADER\s*\((.*)\)/
3859 "\`AC_CONFIG_HEADER' is obsolete; use \`AM_CONFIG_HEADER'")
3862 $config_header_line = $.;
3864 foreach $one_hdr (split (' ', $2))
3866 push (@config_fullnames, $one_hdr);
3867 if ($one_hdr =~ /^([^:]+):(.+)$/)
3869 push (@config_names, $1);
3870 push (@config_headers, $2);
3874 push (@config_names, $one_hdr);
3875 push (@config_headers, $one_hdr . '.in');
3880 # Handle AC_CANONICAL_*. Always allow upgrading to
3881 # AC_CANONICAL_SYSTEM, but never downgrading.
3882 $seen_canonical = $AC_CANONICAL_HOST
3883 if ! $seen_canonical
3884 && (/AC_CANONICAL_HOST/ || /AC_CHECK_TOOL/);
3885 $seen_canonical = $AC_CANONICAL_SYSTEM if /AC_CANONICAL_SYSTEM/;
3887 $seen_path_xtra = 1 if /AC_PATH_XTRA/;
3889 # This macro handles several different things.
3890 if (/$AM_INIT_AUTOMAKE_PATTERN/o)
3896 $seen_prog_install = 2;
3897 ($package_version = $1) =~ s/$AM_PACKAGE_VERSION_PATTERN/$1/o;
3898 $package_version_line = $.;
3901 # This is like AM_INIT_AUTOMAKE, but doesn't actually set the
3902 # package and version number. (This might change in the
3903 # future). Yes, I'm not above hacking Automake so it works
3904 # well with other GNU tools -- that is actually the point.
3905 if (/AM_INIT_GUILE_MODULE/)
3911 $seen_prog_install = 2;
3912 @config_aux_path = ('..');
3915 # Some things required by Automake.
3916 $seen_make_set = 1 if /AC_PROG_MAKE_SET/;
3917 $seen_arg_prog = 1 if /AC_ARG_PROGRAM/;
3919 if (/AC_PROG_(YACC|RANLIB|CC|CXX|LEX|AWK|CPP|CXXCPP|LN_S)/)
3921 $configure_vars{$1} = 1;
3923 if (/$AC_CHECK_PATTERN/o)
3925 $configure_vars{$3} = 1;
3927 if (/$AM_MISSING_PATTERN/o)
3929 $configure_vars{$1} = 1;
3932 # Explicitly avoid ANSI2KNR -- we AC_SUBST that in protos.m4,
3933 # but later define it elsewhere. This is pretty hacky. We
3934 # also explicitly avoid INSTALL_SCRIPT because it is defined
3935 # in header-vars.am. FIXME.
3936 if (/$AC_SUBST_PATTERN/o
3938 && $1 ne 'INSTALL_SCRIPT')
3940 $configure_vars{$1} = 1;
3943 $seen_decl_yytext = 1 if /AC_DECL_YYTEXT/;
3944 $seen_maint_mode = 1 if /AM_MAINTAINER_MODE/;
3945 $seen_package = 1 if /PACKAGE=/;
3947 # Skip VERSION of [$2]; that is from AM_INIT_AUTOMAKE.
3948 if (/\bVERSION=(\S+)/ && $1 ne '[$2]')
3951 $package_version = $1;
3952 $package_version_line = $.;
3959 # Weird conditionals here because it is always allowed to
3960 # upgrade to AM_PROG_INSTALL but never to downgrade to
3962 $seen_prog_install = 1 if ! $seen_prog_install && /AC_PROG_INSTALL/;
3963 $seen_prog_install = 2 if /AM_PROG_INSTALL/;
3965 $seen_lispdir = 1 if /AM_PATH_LISPDIR/;
3967 if (/AM_PROG_LIBTOOL/)
3971 $configure_vars{'LIBTOOL'} = 1;
3972 $configure_vars{'RANLIB'} = 1;
3973 $configure_vars{'CC'} = 1;
3974 # AM_PROG_LIBTOOL runs AC_CANONICAL_HOST. Make sure we
3975 # never downgrade (if we've seen AC_CANONICAL_SYSTEM).
3976 $seen_canonical = $AC_CANONICAL_HOST if ! $seen_canonical;
3983 # Scan configure.in and aclocal.m4 for interesting things. We must
3984 # scan aclocal.m4 because there might be AC_SUBSTs and such there.
3987 # Reinitialize libsources here. This isn't really necessary,
3988 # since we currently assume there is only one configure.in. But
3989 # that won't always be the case.
3992 local ($in_ac_output, $in_ac_replace) = (0, 0);
3993 local (%make_list, @make_input_list);
3994 local ($libobj_iter);
3996 &scan_one_configure_file ('configure.in');
3997 &scan_one_configure_file ('aclocal.m4')
4000 # Set input and output files if not specified by user.
4003 @input_files = @make_input_list;
4004 %output_files = %make_list;
4007 &am_conf_error ("\`PACKAGE' not defined in configure.in")
4009 &am_conf_error ("\`VERSION' not defined in configure.in")
4012 # Look for some files we need. Always check for these. This
4013 # check must be done for every run, even those where we are only
4014 # looking at a subdir Makefile. We must set relative_dir so that
4015 # the file-finding machinery works.
4016 local ($relative_dir) = '.';
4017 &require_config_file ($FOREIGN, 'install-sh', 'mkinstalldirs', 'missing');
4018 &am_error ("\`install.sh' is an anachronism; use \`install-sh' instead")
4019 if -f $config_aux_path[0] . '/install.sh';
4022 ################################################################
4024 # Set up for Cygnus mode.
4027 return unless $cygnus_mode;
4029 &set_strictness ('foreign');
4030 $options{'no-installinfo'} = 1;
4031 $options{'no-dependencies'} = 1;
4032 $use_dependencies = 0;
4034 if (! $seen_maint_mode)
4036 &am_conf_error ("\`AM_MAINTAINER_MODE' required when --cygnus specified");
4039 if (! $seen_cygwin32)
4041 &am_conf_error ("\`AM_CYGWIN32' required when --cygnus specified");
4045 # Do any extra checking for GNU standards.
4046 sub check_gnu_standards
4048 if ($relative_dir eq '.')
4050 # In top level (or only) directory.
4051 &require_file ($GNU, 'INSTALL', 'NEWS', 'README', 'COPYING',
4052 'AUTHORS', 'ChangeLog');
4055 if ($strictness >= $GNU)
4057 if (defined $options{'no-installman'})
4059 &am_line_error ('AUTOMAKE_OPTIONS',
4060 "option \`no-installman' disallowed by GNU standards");
4063 if (defined $options{'no-installinfo'})
4065 &am_line_error ('AUTOMAKE_OPTIONS',
4066 "option \`no-installinfo' disallowed by GNU standards");
4071 # Do any extra checking for GNITS standards.
4072 sub check_gnits_standards
4074 if ($strictness >= $GNITS)
4076 if (-f $relative_dir . '/COPYING.LIB')
4078 &am_error ("\`${relative_dir}/COPYING.LIB' disallowed by Gnits standards");
4081 if ($relative_dir eq '.')
4083 if ($package_version !~ /^$GNITS_VERSION_PATTERN$/)
4085 # FIXME: allow real filename.
4086 &am_conf_line_error ('configure.in',
4087 $package_version_line,
4088 "version \`$package_version' doesn't follow Gnits standards");
4090 elsif (defined $1 && -f 'README-alpha')
4092 # This means we have an alpha release. See
4093 # GNITS_VERSION_PATTERN for details.
4094 &require_file ($GNITS, 'README-alpha');
4099 if ($relative_dir eq '.')
4101 # In top level (or only) directory.
4102 &require_file ($GNITS, 'THANKS');
4106 ################################################################
4108 # Pretty-print something. HEAD is what should be printed at the
4109 # beginning of the first line, FILL is what should be printed at the
4110 # beginning of every subsequent line.
4111 sub pretty_print_internal
4113 local ($head, $fill, @values) = @_;
4115 local ($column) = length ($head);
4116 local ($result) = $head;
4118 # Fill length is number of characters. However, each Tab
4119 # character counts for eight. So we count the number of Tabs and
4121 local ($fill_length) = length ($fill);
4122 $fill_length += 7 * ($fill =~ tr/\t/\t/d);
4124 local ($bol) = ($head eq '');
4127 # "71" because we also print a space.
4128 if ($column + length ($_) > 71)
4130 $result .= " \\\n" . $fill;
4131 $column = $fill_length;
4135 $result .= ' ' unless ($bol);
4137 $column += length ($_) + 1;
4145 # Pretty-print something and append to output_vars.
4148 $output_vars .= &pretty_print_internal (@_);
4151 # Pretty-print something and append to output_rules.
4152 sub pretty_print_rule
4154 $output_rules .= &pretty_print_internal (@_);
4158 ################################################################
4160 # See if a target exists.
4163 local ($target) = @_;
4164 return defined $targets{$target};
4167 # See if a variable exists.
4168 sub variable_defined
4171 if (defined $targets{$var})
4173 &am_line_error ($var, "\`$var' is target; expected variable");
4176 elsif (defined $contents{$var})
4178 $content_seen{$var} = 1;
4184 # Mark a variable as examined.
4185 sub examine_variable
4188 &variable_defined ($var);
4191 # Return contents of variable as list, split as whitespace. This will
4192 # recursively follow $(...) and ${...} inclusions. It preserves @...@
4193 # substitutions. If PARENT is specified, it is the name of the
4194 # including variable; this is only used for error reports.
4195 sub variable_value_as_list
4197 local ($var, $parent) = @_;
4200 if (defined $targets{$var})
4202 &am_line_error ($var, "\`$var' is target; expected variable");
4204 elsif (! defined $contents{$var})
4206 &am_line_error ($parent, "variable \`$var' not defined");
4211 $content_seen{$var} = 1;
4212 foreach (split (' ', $contents{$var}))
4214 # If a comment seen, just leave.
4217 # Handle variable substitutions.
4218 if (/^\$\{(.*)\}$/ || /^\$\((.*)\)$/)
4220 local ($varname) = $1;
4222 if ($varname =~ /^([^:]*):([^=]*)=(.*)$/)
4226 ($from = $2) =~ s/(\W)/\\$1/g;
4230 @temp_list = &variable_value_as_list ($1, $var);
4232 # Now rewrite the value if appropriate.
4235 grep (s/$from$/$to/, @temp_list);
4238 push (@result, @temp_list);
4250 # Define a new variable, but only if not already defined.
4253 local ($var, $value) = @_;
4255 if (! defined $contents{$var})
4257 $output_vars .= $var . ' = ' . $value . "\n";
4258 $contents{$var} = $value;
4259 $content_seen{$var} = 1;
4263 # Like define_variable, but second arg is a list, and is
4265 sub define_pretty_variable
4267 local ($var, @value) = @_;
4268 if (! defined $contents{$var})
4270 $contents{$var} = join (' ', @value);
4271 &pretty_print ($var . ' = ', '', @value);
4272 $content_seen{$var} = 1;
4276 # Like define_variable, but define a variable to be the configure
4277 # substitution by the same name.
4278 sub define_configure_variable
4281 local ($value) = '@' . $var . '@';
4282 &define_variable ($var, $value);
4285 # Define a variable that represents a program to run. If in Cygnus
4286 # mode, the program is searched for in the build (or source) tree.
4287 # Otherwise no searching is done at all. Arguments are:
4288 # * VAR Name of variable to define
4289 # * WHATDIR Either `src' or `build', depending on where program should
4290 # be found. (runtest is in srcdir!)
4291 # * SUBDIR Subdir of top-level dir
4292 # * PROGRAM Name of program
4293 # * OVERRIDE If specified, the name of the program to use when not in
4294 # Cygnus mode. Defaults to PROGRAM.
4295 sub define_program_variable
4297 local ($var, $whatdir, $subdir, $program, $override) = @_;
4301 $override = $program;
4306 local ($full) = ('$(top_' . $whatdir . 'dir)/../'
4307 . $subdir . '/' . $program);
4308 &define_variable ($var, ('`if test -f ' . $full
4309 . '; then echo ' . $full . '; else echo '
4310 . $program . '; fi`'));
4314 &define_variable ($var, $override);
4319 ################################################################
4321 # Read Makefile.am and set up %contents. Simultaneously copy lines
4322 # from Makefile.am into $output_trailer or $output_vars as
4323 # appropriate. NOTE we put rules in the trailer section. We want
4324 # user rules to come after our generated stuff.
4327 local ($amfile) = @_;
4329 open (AM_FILE, $amfile) || die "automake: couldn't open \`$amfile': $!\n";
4330 print "automake: reading $amfile\n" if $verbose;
4332 $output_vars = ("# $in_file_name generated automatically by automake "
4333 . $VERSION . " from $am_file_name\n");
4335 # Generate copyright for generated Makefile.in.
4336 $output_vars .= $gen_copyright;
4338 local ($saw_bk) = 0;
4339 local ($was_rule) = 0;
4340 local ($spacing) = '';
4341 local ($comment) = '';
4342 local ($last_var_name) = '';
4347 if (/$IGNORE_PATTERN/o)
4349 # Merely delete comments beginning with two hashes.
4351 elsif (/$WHITE_PATTERN/o)
4353 # Stick a single white line before the incoming macro or rule.
4357 elsif (/$COMMENT_PATTERN/o)
4359 # Stick comments before the incoming macro or rule. Make
4360 # sure a blank line preceeds first block of comments.
4361 $spacing = "\n" unless $blank;
4363 $comment .= $spacing . $_;
4372 $output_vars .= $comment . "\n";
4375 local ($am_vars) = '';
4377 local ($is_ok_macro);
4381 unless substr ($_, -1, 1) eq "\n";
4383 $_ =~ s/\@MAINT\@//g
4384 unless $seen_maint_mode;
4386 if (/$IGNORE_PATTERN/o)
4388 # Merely delete comments beginning with two hashes.
4390 elsif (/$WHITE_PATTERN/o)
4392 # Stick a single white line before the incoming macro or rule.
4395 elsif (/$COMMENT_PATTERN/o)
4397 # Stick comments before the incoming macro or rule.
4398 $comment .= $spacing . $_;
4405 $output_trailer .= $_;
4412 # Chop newline and backslash if this line is
4413 # continued. FIXME: maybe ensure trailing whitespace
4417 $contents{$last_var_name} .= $_;
4420 elsif (/$RULE_PATTERN/o)
4422 # warn "** Saw rule .$1.\n";
4425 # Value here doesn't matter; for targets we only note
4429 $content_lines{$1} = $.;
4430 $output_trailer .= $comment . $spacing . $_;
4431 $comment = $spacing = '';
4434 elsif (($is_ok_macro = /$MACRO_PATTERN/o)
4435 || /$BOGUS_MACRO_PATTERN/o)
4437 # Found a macro definition.
4439 $last_var_name = $1;
4440 if ($2 ne '' && substr ($2, -1) eq "\\")
4442 $contents{$1} = substr ($2, 0, length ($2) - 1);
4448 $content_lines{$1} = $.;
4449 $am_vars .= $comment . $spacing . $_;
4450 $comment = $spacing = '';
4454 &am_line_error ($., "bad macro name \`$1'")
4459 # This isn't an error; it is probably a continued rule.
4460 # In fact, this is what we assume.
4462 $output_trailer .= $comment . $spacing . $_;
4463 $comment = $spacing = '';
4470 $output_trailer .= $comment;
4472 # Compute relative location of the top object directory.
4473 local (@topdir) = ();
4474 foreach (split (/\//, $relative_dir))
4476 next if $_ eq '.' || $_ eq '';
4483 push (@topdir, '..');
4486 @topdir = ('.') if ! @topdir;
4488 $top_builddir = join ('/', @topdir);
4490 ($build_rx = $top_builddir) =~ s/(\W)/\\$1/g;
4491 $output_vars .= &file_contents_with_transform
4492 ('s/\@top_builddir\@/' . $build_rx . '/g;',
4495 # Generate some useful variables when AC_CANONICAL_* used. FIXME:
4496 # this should use generic %configure_vars method.
4497 if ($seen_canonical)
4499 local ($curs, %vars);
4500 $vars{'host_alias'} = 'host_alias';
4501 $vars{'host_triplet'} = 'host';
4502 if ($seen_canonical == $AC_CANONICAL_SYSTEM)
4504 $vars{'build_alias'} = 'build_alias';
4505 $vars{'build_triplet'} = 'build';
4506 $vars{'target_alias'} = 'target_alias';
4507 $vars{'target_triplet'} = 'target';
4509 foreach $curs (sort keys %vars)
4511 $output_vars .= "$curs = \@$vars{$curs}\@\n";
4512 $contents{$curs} = "\@$vars{$curs}\@";
4517 foreach $curs (sort keys %configure_vars)
4519 &define_configure_variable ($curs);
4522 $output_vars .= $am_vars;
4525 ################################################################
4527 sub initialize_global_constants
4529 # Values for AC_CANONICAL_*
4530 $AC_CANONICAL_HOST = 1;
4531 $AC_CANONICAL_SYSTEM = 2;
4533 # Associative array of standard directory names. Entry is TRUE if
4534 # corresponding directory should be installed during
4535 # 'install-exec' phase.
4553 # Helper text for dealing with man pages.
4554 $install_man_format =
4555 ' @sect=@SECTION@; \\
4556 inst=`echo "@MANBASE@" | sed \'$(transform)\'`.@FULLSECT@; \\
4557 if test -f $(srcdir)/@MAN@; then file=$(srcdir)/@MAN@; \\
4558 else file=@MAN@; fi; \\
4559 echo " $(INSTALL_DATA) $$file $(mandir)/man$$sect/$$inst"; \\
4560 $(INSTALL_DATA) $$file $(mandir)/man$$sect/$$inst
4563 $uninstall_man_format =
4564 ' inst=`echo "@MANBASE@" | sed \'$(transform)\'`.@FULLSECT@; \\
4565 rm -f $(mandir)/man@SECTION@/$$inst
4568 # Commonly found files we look for and automatically include in
4572 "README", "THANKS", "TODO", "NEWS", "COPYING", "COPYING.LIB",
4573 "INSTALL", "ABOUT-NLS", "ChangeLog", "configure", "configure.in",
4574 "config.guess", "config.sub", "AUTHORS", "BACKLOG", "ABOUT-GNU",
4575 "libversion.in", "mdate-sh", "mkinstalldirs", "install-sh",
4576 'texinfo.tex', "ansi2knr.c", "ansi2knr.1", 'elisp-comp',
4577 'interlock', 'ylwrap', 'acinclude.m4', @libtoolize_files,
4581 # Commonly used files we auto-include, but only sometimes.
4584 "aclocal.m4", "acconfig.h", "config.h.top",
4585 "config.h.bot", "stamp-h.in", 'stamp-vti'
4589 -a, --add-missing add missing standard files to package
4590 --amdir=DIR directory storing config files
4591 --build-dir=DIR directory where build being done (for dependencies)
4592 --cygnus assume program is part of Cygnus-style tree
4593 --foreign set strictness to foreign
4594 --gnits set strictness to gnits
4595 --gnu set strictness to gnu
4596 --help print this help, then exit
4597 -i, --include-deps include generated dependencies in Makefile.in
4598 --no-force only update Makefile.in's that are out of date
4599 -o DIR, --output-dir=DIR
4600 put generated Makefile.in's into DIR
4601 --srcdir-name=DIR name used for srcdir (for dependencies)
4602 -v, --verbose verbosely list files processed
4603 --version print version number, then exit\n";
4605 # Copyright on generated Makefile.ins.
4607 # Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
4608 # This Makefile.in is free software; the Free Software Foundation
4609 # gives unlimited permission to copy, distribute and modify it.
4612 # Ignore return result from chmod, because it might give an error
4613 # if we chmod a symlink.
4614 $dist_header = "\t" . '-chmod -R a+r $(distdir)' . "\n";
4615 $dist{'tarZ'} = ("\t"
4616 . '$(TAR) chf - $(distdir) | compress -c > $(distdir).tar.Z'
4618 $dist{'shar'} = ("\t"
4619 . 'shar $(distdir) | gzip > $(distdir).shar.gz'
4621 $dist{'zip'} = "\t" . 'zip -rq $(distdir).zip $(distdir)' . "\n";
4622 $dist{'dist'} = "\t" . 'GZIP=$(GZIP) $(TAR) chozf $(distdir).tar.gz $(distdir)' . "\n";
4623 $dist_trailer = "\t" . 'rm -rf $(distdir)' . "\n";
4626 # (Re)-Initialize per-Makefile.am variables.
4627 sub initialize_per_input
4629 # These two variables are used when generating each Makefile.in.
4630 # They hold the Makefile.in until it is ready to be printed.
4633 $output_trailer = '';
4634 $output_header = '';
4636 # Suffixes found during a run.
4639 # This holds the contents of a Makefile.am, as parsed by
4643 # This holds the names which are targets. These also appear in
4647 # This holds the line numbers at which various elements of
4648 # %contents are defined.
4649 %content_lines = ();
4651 # This holds a 1 if a particular variable was examined.
4654 # This holds the "relative directory" of the current Makefile.in.
4655 # Eg for src/Makefile.in, this is "src".
4658 # This holds a list of files that are included in the
4662 # List of dependencies for the obvious targets.
4678 # These are pretty obvious, too. They are used to define the
4679 # SOURCES and OBJECTS variables.
4683 # TRUE if current directory holds any C source files.
4684 $dir_holds_sources = 0;
4686 # These variables track inclusion of various compile-related .am
4687 # files. $included_generic_compile is TRUE if the basic code has
4688 # been included. $included_knr_compile is TRUE if the ansi2knr
4689 # code has been included. $included_libtool_compile is TRUE if
4690 # libtool support has been included.
4691 $included_generic_compile = 0;
4692 $included_knr_compile = 0;
4693 $included_libtool_compile = 0;
4695 # TRUE if current directory holds any headers.
4696 $dir_holds_headers = 0;
4698 # TRUE if install targets should work recursively.
4699 $recursive_install = 0;
4704 # Strictness levels.
4705 $strictness = $default_strictness;
4706 $strictness_name = $default_strictness_name;
4708 # Options from AUTOMAKE_OPTIONS.
4711 # Whether or not dependencies are handled. Can be further changed
4712 # in handle_options.
4713 $use_dependencies = $cmdline_use_dependencies;
4716 $local_maint_charset = $maint_charset;
4718 # All yacc and lex source filenames for this directory. Use
4719 # filenames instead of raw count so that multiple instances are
4720 # counted correctly (eg one yacc file can appear in multiple
4721 # programs without harm).
4725 # C++ source extensions we've seen.
4726 %cxx_extensions = ();
4728 # TRUE if we've seen any non-C++ sources. This actually holds a
4729 # line number or the name of a symbol corresponding to a line
4730 # number where the C sources were seen. If it is -1 then it means
4731 # we couldn't (easily) figure out which line of the Makefile.am
4732 # mentioned the sources.
4735 # This is a list of all targets to run during "make dist".
4738 # Keys in this hash are the names of ._o files which must depend
4740 %de_ansi_objects = ();
4744 ################################################################
4746 # Return contents of a file from $am_dir, automatically skipping
4747 # macros or rules which are already known. Runs command on each line
4748 # as it is read; this command can modify $_.
4749 sub file_contents_with_transform
4751 local ($command, $basename) = @_;
4752 local ($file) = $am_dir . '/' . $basename . '.am';
4754 if ($command ne '' && substr ($command, -1) ne ';')
4756 die "automake: programming error in file_contents_with_transform\n";
4759 open (FC_FILE, $file)
4760 || die "automake: installation error: cannot open \`$file'\n";
4762 # print "automake: reading $file\n" if $verbose;
4764 local ($was_rule) = 0;
4765 local ($result_vars) = '';
4766 local ($result_rules) = '';
4767 local ($comment) = '';
4768 local ($spacing) = "\n";
4769 local ($skipping) = 0;
4774 $_ =~ s/\@MAINT\@//g
4775 unless $seen_maint_mode;
4777 $had_chars = length ($_) && $_ ne "\n";
4779 # If the transform caused all the characters to go away, then
4780 # ignore the line. Why do this? Because in Perl 4, a "next"
4781 # inside of an eval doesn't affect a loop outside the eval.
4782 # So we can't pass in a "transform" that uses next. We used
4783 # to do this. "Empty" also means consisting of a single
4785 next if $had_chars && ($_ eq '' || $_ eq "\n");
4787 if (/$IGNORE_PATTERN/o)
4789 # Merely delete comments beginning with two hashes.
4791 elsif (/$WHITE_PATTERN/o)
4793 # Stick a single white line before the incoming macro or rule.
4796 elsif (/$COMMENT_PATTERN/o)
4798 # Stick comments before the incoming macro or rule.
4799 $comment .= $spacing . $_;
4806 $result_rules .= $_ if ! $skipping;
4810 $result_vars .= $_ if ! $skipping;
4814 elsif (/$RULE_PATTERN/o)
4816 # warn "** Found rule .$1.\n";
4819 $skipping = defined $contents{$1};
4820 # warn "** Skip $skipping\n" if $skipping;
4821 $result_rules .= $comment . $spacing . $_ if ! $skipping;
4822 $comment = $spacing = '';
4825 elsif (/$MACRO_PATTERN/o)
4827 # warn "** Found macro .$1.\n";
4828 # Found a variable reference.
4830 $skipping = defined $contents{$1};
4831 # warn "** Skip $skipping\n" if $skipping;
4832 $result_vars .= $comment . $spacing . $_ if ! $skipping;
4833 $comment = $spacing = '';
4838 # This isn't an error; it is probably a continued rule.
4839 # In fact, this is what we assume.
4841 $result_rules .= $comment . $spacing . $_ if ! $skipping;
4842 $comment = $spacing = '';
4848 return $result_vars . $result_rules . $comment;
4851 # Like file_contents_with_transform, but no transform.
4854 return &file_contents_with_transform ('', @_);
4857 # Find all variable prefixes that are used for install directories. A
4858 # prefix `zar' qualifies iff:
4859 # * `zardir' is a variable.
4860 # * `zar_PRIMARY' is a variable.
4861 sub am_primary_prefixes
4863 local ($primary, @prefixes) = @_;
4865 local (%valid, $varname);
4866 grep ($valid{$_} = 0, @prefixes);
4867 $valid{'EXTRA'} = 0;
4868 foreach $varname (keys %contents)
4870 if ($varname =~ /^(.*)_$primary$/)
4872 if (! defined $valid{$1}
4873 && ! &variable_defined ($1 . 'dir')
4874 # Note that a configure variable is always legitimate.
4875 # It is natural to name such variables after the
4876 # primary, so we explicitly allow it.
4877 && ! defined $configure_vars{$varname})
4879 &am_line_error ($varname, "invalid variable \"$varname\"");
4883 # Ensure all extended prefixes are actually used.
4892 # Handle `where_HOW' variable magic. Does all lookups, generates
4893 # install code, and possibly generates code to define the primary
4894 # variable. The first argument is the name of the .am file to munge,
4895 # the second argument is the primary variable (eg HEADERS), and all
4896 # subsequent arguments are possible installation locations. Returns
4897 # list of all values of all _HOW targets.
4899 # FIXME: this should be rewritten to be cleaner. It should be broken
4900 # up into multiple functions.
4902 # Usage is: am_install_var (OPTION..., file, HOW, where...)
4907 local ($do_clean) = 0;
4910 if (defined $configure_vars{'LIBTOOL'})
4912 # Transform '@LIBTOOL ...@' to '$(LIBTOOL) ...'
4913 $ltxform = 's/\@LIBTOOL([^\@]*)\@/\$(LIBTOOL) $1/;';
4917 # Delete '@LIBTOOL ...@'
4918 $ltxform = 's/\@LIBTOOL([^\@]*)\@//;';
4922 if (! $seen_cygwin32)
4924 $cygxform = 's/\@EXEEXT\@//g; s/^NOTCYGWIN//; s/^CYGWIN.*$//;';
4928 $cygxform = 's/\@EXEEXT\@/\$(EXEEXT)/g; s/^CYGWIN//; s/^NOTCYGWIN.*$//;';
4933 if ($args[0] eq '-clean')
4937 elsif ($args[0] !~ /^-/)
4943 local ($file, $primary, @prefixes) = @args;
4946 local (@result) = ();
4948 # Now that configure substitutions are allowed in where_HOW
4949 # variables, it is an error to actually define the primary.
4950 &am_line_error ($primary, "\`$primary' is an anachronism")
4951 if &variable_defined ($primary);
4954 # Look for misspellings. It is an error to have a variable ending
4955 # in a "reserved" suffix whose prefix is unknown, eg
4956 # "bni_PROGRAMS". However, unusual prefixes are allowed if a
4957 # variable of the same name (with "dir" appended) exists. For
4958 # instance, if the variable "zardir" is defined, then
4959 # "zar_PROGRAMS" becomes valid. This is to provide a little extra
4960 # flexibility in those cases which need it. Perhaps it should be
4961 # disallowed in the Gnits case? The problem is, sometimes it is
4962 # useful to put things in a subdir of eg pkgdatadir, perhaps even
4964 local (%valid) = &am_primary_prefixes ($primary, @prefixes);
4966 # If a primary includes a configure substitution, then the EXTRA_
4967 # form is required. Otherwise we can't properly do our job.
4968 local ($require_extra);
4969 local ($warned_about_extra) = 0;
4971 local ($clean_file) = $file . '-clean';
4974 foreach $X (sort keys %valid)
4976 $one_name = $X . '_' . $primary;
4977 if (&variable_defined ($one_name))
4979 # Append actual contents of where_PRIMARY variable to
4982 foreach $rcurs (&variable_value_as_list ($one_name))
4984 # Skip configure substitutions. Possibly bogus.
4985 if ($rcurs =~ /^\@.*\@$/)
4989 if (! $warned_about_extra)
4991 $warned_about_extra = 1;
4992 &am_line_error ($one_name,
4993 "\`$one_name' contains configure substitution, but shouldn't");
4996 # Check here to make sure variables defined in
4997 # configure.in do not imply that EXTRA_PRIMARY
4999 elsif (! defined $configure_vars{$one_name})
5001 $require_extra = $one_name;
5005 push (@result, $rcurs);
5008 # "EXTRA" shouldn't be used when generating clean targets,
5009 # @all, or install targets.
5010 next if $X eq 'EXTRA';
5015 &file_contents_with_transform ('s/\@DIR\@/' . $X . '/go;'
5019 push (@clean, $X . $primary);
5020 &push_phony_cleaners ($X . $primary);
5025 push (@check, '$(' . $one_name . ')');
5029 push (@used, '$(' . $one_name . ')');
5031 if ($X eq 'noinst' || $X eq 'check')
5033 # Objects which don't get installed by default.
5038 &file_contents_with_transform ('s/\@DIR\@/' . $X . '/g;'
5039 . $ltxform . $cygxform,
5042 push (@uninstall, 'uninstall-' . $X . $primary);
5043 push (@phony, 'uninstall-' . $X . $primary);
5044 push (@installdirs, '$(' . $X . 'dir)');
5045 if (defined $exec_dir_p{$X} ? $exec_dir_p{$X} : ($X =~ /exec/))
5047 push (@install_exec, 'install-' . $X . $primary);
5048 push (@phony, 'install-' . $X . $primary);
5052 push (@install_data, 'install-' . $X . $primary);
5053 push (@phony, 'install-' . $X . $primary);
5061 &define_pretty_variable ($primary, @used);
5062 $output_vars .= "\n";
5065 if ($require_extra && ! &variable_defined ('EXTRA_' . $primary))
5067 &am_line_error ($require_extra,
5068 "\`$require_extra' contains configure substitution, but \`EXTRA_$primary' not defined");
5071 # Push here because PRIMARY might be configure time determined.
5072 push (@all, '$(' . $primary . ')')
5079 ################################################################
5081 # This variable is local to the "require file" set of functions.
5082 @require_file_paths = ();
5084 # Verify that the file must exist in the current directory. Usage:
5085 # require_file (isconfigure, line_number, strictness, file) strictness
5086 # is the strictness level at which this file becomes required. Must
5087 # set require_file_paths before calling this function.
5088 # require_file_paths is set to hold a single directory (the one in
5089 # which the first file was found) before return.
5090 sub require_file_internal
5092 local ($is_configure, $line, $mystrict, @files) = @_;
5093 local ($file, $fullfile);
5094 local ($found_it, $errfile, $errdir);
5097 foreach $file (@files)
5100 foreach $dir (@require_file_paths)
5104 $fullfile = $relative_dir . "/" . $file;
5105 $errdir = $relative_dir unless $errdir;
5109 $fullfile = $dir . "/" . $file;
5110 $errdir = $dir unless $errdir;
5113 # Use different name for "error filename". Otherwise on
5114 # an error the bad file will be reported as eg
5115 # `../../install-sh' when using the default
5117 $errfile = $errdir . '/' . $file;
5122 # FIXME: Once again, special-case `.'.
5123 &push_dist_common ($file)
5124 if $dir eq $relative_dir || $dir eq '.';
5132 # Prune the path list.
5133 @require_file_paths = $save_dir;
5137 if ($strictness >= $mystrict)
5139 local ($trailer) = '';
5140 local ($suppress) = 0;
5142 # Only install missing files according to our desired
5146 $trailer = "; installing";
5149 # Maybe run libtoolize.
5151 && grep ($_ eq $file, @libtoolize_files)
5152 && system ('libtoolize', '--automake'))
5155 $trailer .= "; cannot run \`libtoolize': $!";
5157 elsif (-f ($am_dir . '/' . $file))
5159 # Install the missing file. Symlink if we
5160 # can, copy if we must. Note: delete the file
5161 # first, in case it is a dangling symlink.
5163 if ($symlink_exists)
5165 if (! symlink ($am_dir . '/' . $file, $errfile))
5168 $trailer .= "; error while making link: $!\n";
5171 elsif (! system ('cp', $am_dir . '/' . $file, $errfile))
5174 $trailer .= "\n error while making link\n";
5179 local ($save) = $exit_status;
5182 # FIXME: allow actual file to be specified.
5184 ('configure.in', $line,
5185 "required file \"$errfile\" not found$trailer");
5191 "required file \"$errfile\" not found$trailer");
5193 $exit_status = $save if $suppress;
5199 # Like require_file_with_line, but error messages refer to
5200 # configure.in, not the current Makefile.am.
5201 sub require_file_with_conf_line
5203 @require_file_paths = '.';
5204 &require_file_internal (1, @_);
5207 sub require_file_with_line
5209 @require_file_paths = '.';
5210 &require_file_internal (0, @_);
5215 @require_file_paths = '.';
5216 &require_file_internal (0, '', @_);
5219 # Require a file that is also required by Autoconf. Looks in
5220 # configuration path, as specified by AC_CONFIG_AUX_DIR.
5221 sub require_config_file
5223 @require_file_paths = @config_aux_path;
5224 &require_file_internal (1, '', @_);
5225 local ($dir) = $require_file_paths[0];
5226 @config_aux_path = @require_file_paths;
5229 $config_aux_dir = '.';
5233 $config_aux_dir = '$(top_srcdir)/' . $dir;
5237 # Assumes that the line number is in Makefile.am.
5238 sub require_conf_file_with_line
5240 @require_file_paths = @config_aux_path;
5241 &require_file_internal (0, @_);
5242 local ($dir) = $require_file_paths[0];
5243 @config_aux_path = @require_file_paths;
5246 $config_aux_dir = '.';
5250 $config_aux_dir = '$(top_srcdir)/' . $dir;
5254 # Assumes that the line number is in Makefile.am.
5255 sub require_conf_file_with_conf_line
5257 @require_file_paths = @config_aux_path;
5258 &require_file_internal (1, @_);
5259 local ($dir) = $require_file_paths[0];
5260 @config_aux_path = @require_file_paths;
5263 $config_aux_dir = '.';
5267 $config_aux_dir = '$(top_srcdir)/' . $dir;
5271 ################################################################
5273 # Push a list of files onto dist_common.
5274 sub push_dist_common
5276 local (@files) = @_;
5279 foreach $file (@files)
5281 $dist_common{$file} = 1;
5285 # Push a list of clean targets onto phony.
5286 sub push_phony_cleaners
5290 foreach $target ('mostly', 'dist', '', 'maintainer-')
5292 push (@phony, $target . 'clean-' . $base);
5299 $strictness_name = $_[0];
5300 if ($strictness_name eq 'gnu')
5304 elsif ($strictness_name eq 'gnits')
5306 $strictness = $GNITS;
5308 elsif ($strictness_name eq 'foreign')
5310 $strictness = $FOREIGN;
5314 die "automake: level \`$strictness_name' not recognized\n";
5319 ################################################################
5321 # Return directory name of file.
5327 ($sub = $file) =~ s,/+[^/]+$,,g;
5328 $sub = '.' if $sub eq $file;
5332 # Return file name of a file.
5338 ($sub = $file) =~s,^.*/+,,g;
5347 open (TOUCH, ">> $file");
5351 # Glob something. Do this to avoid indentation screwups everywhere we
5352 # want to glob. Gross!
5359 ################################################################
5361 # Print an error message and set exit status.
5364 warn "automake: ${am_file}.am: ", join (' ', @_), "\n";
5370 local ($symbol, @args) = @_;
5372 if ($symbol && "$symbol" ne '-1')
5374 # If SYMBOL not already a line number, look it up in Makefile.am.
5375 if ($symbol =~ /^\d+$/)
5379 elsif (defined $content_lines{$symbol})
5381 $symbol = $content_lines{$symbol} . ': ';
5385 # A single space, to provide nice separation.
5388 warn "${am_file}.am:", $symbol, join (' ', @args), "\n";
5397 # Like am_error, but while scanning configure.in.
5400 # FIXME: can run in subdirs.
5401 warn "automake: configure.in: ", join (' ', @_), "\n";
5405 # Error message with line number referring to configure.in.
5406 sub am_conf_line_error
5408 local ($file, $line, @args) = @_;
5412 warn "$file: $line: ", join (' ', @args), "\n";
5417 &am_conf_error (@args);
5421 # Tell user where our aclocal.m4 is, but only once.
5422 sub keyed_aclocal_warning
5425 warn "automake: macro \`$key' can be generated by \`aclocal'\n";
5428 # Print usage information.
5431 print "Usage: automake [OPTION] ... [Makefile]...\n";
5433 print "\nFiles which are automatically distributed, if found:\n";
5434 $~ = "USAGE_FORMAT";
5435 local (@lcomm) = sort ((@common_files, @common_sometimes));
5436 local ($one, $two, $three, $four);
5439 $one = shift @lcomm;
5440 $two = @lcomm ? shift @lcomm : '';
5441 $three = @lcomm ? shift @lcomm : '';
5442 $four = @lcomm ? shift @lcomm : '';
5446 print "\nReport bugs to <automake-bugs\@gnu.ai.mit.edu>\n";
5451 format USAGE_FORMAT =
5452 @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<
5453 $one, $two, $three, $four