5 eval 'exec @PERL@ -S $0 ${1+"$@"}'
8 # automake - create Makefile.in from Makefile.am
9 # Copyright (C) 1994, 1995, 1996, 1997, 1998 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 $SUFFIX_RULE_PATTERN = "^\\.([a-zA-Z]+)\\.([a-zA-Z]+)\$";
44 $MACRO_PATTERN = "^([A-Za-z][A-Za-z0-9_]*)[ \t]*:?=[ \t]*(.*)\$";
45 $BOGUS_MACRO_PATTERN = "^([^ \t]*)[ \t]*:?=[ \t]*(.*)\$";
46 $GNITS_VERSION_PATTERN = "[0-9]+\\.[0-9]+([a-z]|\\.[0-9]+)?";
47 $IF_PATTERN = "^if[ \t]+\([A-Za-z][A-Za-z0-9_]*\)[ \t]*\(#.*\)?\$";
48 $ELSE_PATTERN = "^else[ \t]*\(#.*\)?\$";
49 $ENDIF_PATTERN = "^endif[ \t]*\(#.*\)?\$";
51 # Some regular expressions. One reason to put them here is that it
52 # makes indentation work better in Emacs.
53 $AC_CONFIG_AUX_DIR_PATTERN = "AC_CONFIG_AUX_DIR\\(([^)]+)\\)";
54 $AM_INIT_AUTOMAKE_PATTERN = "AM_INIT_AUTOMAKE\\([^,]*,([^,)]+)[,)]";
55 $AM_PACKAGE_VERSION_PATTERN = "^\\s*\\[?([^]\\s]+)\\]?\\s*\$";
56 # Note that there is no AC_PATH_TOOL. But we don't really care.
57 $AC_CHECK_PATTERN = "AC_(CHECK|PATH)_(PROG|PROGS|TOOL)\\(\\[?(\\w+)";
58 $AM_MISSING_PATTERN = "AM_MISSING_PROG\\(\\[?(\\w+)";
59 # Just check for alphanumeric in AC_SUBST. If you do AC_SUBST(5),
61 $AC_SUBST_PATTERN = "AC_SUBST\\(\\[?(\\w+)";
62 $AM_CONDITIONAL_PATTERN = "AM_CONDITIONAL\\((\\w+)";
64 # Constants to define the "strictness" level.
71 # Variables global to entire run.
73 # TRUE if we should always generate Makefile.in.
74 $force_generation = 1;
76 # Strictness level as set on command line.
77 $default_strictness = $GNU;
79 # Name of strictness level, as set on command line.
80 $default_strictness_name = 'gnu';
82 # This is TRUE if GNU make specific automatic dependency generation
83 # code should be included in generated Makefile.in.
84 $cmdline_use_dependencies = 1;
86 # This is the name of a dependency makefile bit (usually for inclusion in a
87 # SMakefile or similar); empty if not set.
90 # TRUE if in verbose mode.
93 # This holds our (eventual) exit status. We don't actually exit until
94 # we have processed all input files.
97 # From the Perl manual.
98 $symlink_exists = (eval 'symlink ("", "");', $@ eq '');
100 # TRUE if missing standard files should be installed.
103 # Files found by scanning configure.in for LIBOBJS.
106 # True if AM_C_PROTOTYPES appears in configure.in.
107 $am_c_prototypes = 0;
109 # Names used in AC_CONFIG_HEADER call. @config_fullnames holds the
110 # name which appears in AC_CONFIG_HEADER, colon and all.
111 # @config_names holds the file names. @config_headers holds the '.in'
112 # files. Ordinarily these are similar, but they can be different if
113 # the weird "NAME:FILE" syntax is used.
114 @config_fullnames = ();
116 @config_headers = ();
117 # Line number at which AC_CONFIG_HEADER appears in configure.in.
118 $config_header_line = 0;
120 # Directory where output files go. Actually, output files are
121 # relative to this directory.
122 $output_directory = '.';
124 # Relative location of top build directory.
127 # Absolute location of top build directory.
128 $build_directory = '';
130 # Name of srcdir as given in build directory's Makefile. For
134 # List of Makefile.am's to process, and their corresponding outputs.
138 # List of files in AC_OUTPUT without Makefile.am, and their outputs.
139 @other_input_files = ();
140 # Line number at which AC_OUTPUT seen.
143 # List of directories to search for configure-required files. This
144 # can be set by AC_CONFIG_AUX_DIR.
145 @config_aux_path = ('.', '..', '../..');
146 $config_aux_dir = '';
148 # Whether AC_PROG_MAKE_SET has been seen in configure.in.
151 # Whether AM_GNU_GETTEXT has been seen in configure.in.
153 # Line number at which AM_GNU_GETTEXT seen.
154 $ac_gettext_line = 0;
156 # Whether ALL_LINGUAS has been seen.
160 # Line number at which it appears.
161 $all_linguas_line = 0;
163 # 1 if AC_PROG_INSTALL seen, 2 if AM_PROG_INSTALL seen.
164 $seen_prog_install = 0;
166 # 1 if any scripts installed, 0 otherwise.
167 $scripts_installed = 0;
169 # Whether AC_PATH_XTRA has been seen in configure.in.
172 # TRUE if AC_DECL_YYTEXT was seen.
173 $seen_decl_yytext = 0;
175 # TRUE if we've seen AC_CANONICAL_(HOST|SYSTEM). The presence of
176 # AC_CHECK_TOOL also sets this.
179 # TRUE if we've seen AC_ARG_PROGRAM.
182 # TRUE if we've seen AM_PROG_LIBTOOL.
186 # Files installed by libtoolize.
187 @libtoolize_files = ('ltconfig', 'ltmain.sh', 'config.guess', 'config.sub');
189 # TRUE if we've seen AM_MAINTAINER_MODE.
190 $seen_maint_mode = 0;
192 # TRUE if we've seen PACKAGE and VERSION.
196 # Actual version we've seen.
197 $package_version = '';
199 # Line number where we saw version definition.
200 $package_version_line = 0;
202 # TRUE if we've seen AM_PATH_LISPDIR.
205 # TRUE if we've seen AM_EXEEXT.
208 # Hash table of discovered configure substitutions. Keys are names,
209 # values are meaningless.
210 %configure_vars = ();
212 # Charsets used by maintainer and in distribution. MAINT_CHARSET is
213 # handled in a funny way: if seen in the top-level Makefile.am, it is
214 # used for every directory which does not specify a different value.
215 # The rationale here is that some directories (eg gettext) might be
216 # distributions of other packages, and thus require their own charset
217 # info. However, the DIST_CHARSET must be the same for the entire
218 # package; it can only be set at top-level.
219 # FIXME: this yields bugs when rebuilding. What to do? Always
220 # read (and sometimes discard) top-level Makefile.am?
222 $dist_charset = 'utf8'; # recode doesn't support this yet.
224 # Name of input file ("Makefile.in") and output file ("Makefile.am").
225 # These have no directory components.
229 # TRUE if --cygnus seen.
232 # Keys of this hash are names of dependency files to ignore.
233 %omit_dependencies = ();
235 # Hash table of AM_CONDITIONAL variables seen in configure.
236 %configure_cond = ();
238 # Map from obsolete macros to hints for new macros.
239 # FIXME complete the list so that there are no `0' hints.
242 'AC_FEATURE_CTYPE', "use \`AC_HEADER_STDC'",
243 'AC_FEATURE_ERRNO', "add \`strerror' to \`AC_REPLACE_FUNCS(...)'",
244 'AC_FEATURE_EXIT', 0,
245 'AC_SYSTEM_HEADER', 0,
247 # Note that we do not handle this one, because it is still run
248 # from AM_CONFIG_HEADER. So we deal with it specially in
250 # 'AC_CONFIG_HEADER', "use \`AM_CONFIG_HEADER'",
252 'fp_C_PROTOTYPES', "use \`AM_C_PROTOTYPES'",
253 'fp_PROG_CC_STDC', "use \`AM_PROG_CC_STDC'",
254 'fp_PROG_INSTALL', "use \`AM_PROG_INSTALL'",
255 'fp_WITH_DMALLOC', "use \`AM_WITH_DMALLOC'",
256 'fp_WITH_REGEX', "use \`AM_WITH_REGEX'",
257 'gm_PROG_LIBTOOL', "use \`AM_PROG_LIBTOOL'",
258 'jm_MAINTAINER_MODE', "use \`AM_MAINTAINER_MODE'",
259 'md_TYPE_PTRDIFF_T', "use \`AM_TYPE_PTRDIFF_T'",
260 'ud_PATH_LISPDIR', "use \`AM_PATH_LISPDIR'",
262 # Now part of autoconf proper, under a different name.
263 'AM_FUNC_FNMATCH', "use \`AC_FUNC_FNMATCH'",
264 'fp_FUNC_FNMATCH', "use \`AC_FUNC_FNMATCH'",
265 'AM_SANITY_CHECK_CC', "automatically done by \`AC_PROG_CC'",
267 # These aren't quite obsolete.
271 # Regexp to match the above macros.
272 $obsolete_rx = '(' . join ('|', keys %obsolete_macros) . ')';
276 &initialize_global_constants;
278 # Parse command line.
279 &parse_arguments (@ARGV);
281 # Do configure.in scan only once.
284 die "automake: no \`Makefile.am' found or specified\n"
287 # If --generate-deps was given, we don't do anything else
291 die "automake: Must specify --include-deps (or -i) when generating\n"
292 if ($use_dependencies);
293 die "automake: Must provide --build-dir when generating\n"
294 if (!$build_directory);
295 die "automake: Must provide --srcdir-name when generating\n"
298 open(GDEP, ">$output_directory/.dep_segment")
299 || die "automake: Could not open `$output_directory/.dep_segment': $!\n";
301 &handle_dependencies;
302 print GDEP $output_rules;
308 # Now do all the work on each file.
309 foreach $am_file (@input_files)
311 if (! -f ($am_file . '.am'))
313 &am_error ("\`" . $am_file . ".am' does not exist");
317 &generate_makefile ($output_files{$am_file}, $am_file);
321 if ($seen_prog_install <= $scripts_installed)
323 &am_conf_error (($scripts_installed ? 'AM_PROG_INSTALL' : 'AC_PROG_INSTALL')
324 . " must be used in configure.in");
325 &keyed_aclocal_warning ('AM_PROG_INSTALL')
326 if $scripts_installed;
332 ################################################################
334 # Parse command line.
337 local (@arglist) = @_;
340 &set_strictness ('gnu');
344 if ($arglist[0] eq "--version")
346 print "automake (GNU $PACKAGE) $VERSION\n\n";
347 print "Copyright (C) 1998 Free Software Foundation, Inc.\n";
348 print "This is free software; see the source for copying conditions. There is NO\n";
349 print "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n";
350 print "Written by Tom Tromey <tromey\@cygnus.com>\n";
354 elsif ($arglist[0] eq "--help")
358 elsif ($arglist[0] =~ /^--amdir=(.+)$/)
362 elsif ($arglist[0] eq '--amdir')
364 &require_argument (@arglist);
366 $am_dir = $arglist[0];
368 elsif ($arglist[0] =~ /^--build-dir=(.+)$/)
371 $build_directory = $1 . '/';
373 elsif ($arglist[0] eq '--build-dir')
375 &require_argument (@arglist);
378 $build_directory = $arglist[0] . '/';
380 elsif ($arglist[0] =~ /^--srcdir-name=(.+)$/)
384 elsif ($arglist[0] eq '--srcdir-name')
386 &require_argument (@arglist);
388 $srcdir_name = $arglist[0];
390 elsif ($arglist[0] eq '--gnu')
392 &set_strictness ('gnu');
394 elsif ($arglist[0] eq '--gnits')
396 &set_strictness ('gnits');
398 elsif ($arglist[0] eq '--cygnus')
402 elsif ($arglist[0] eq '--foreign')
404 &set_strictness ('foreign');
406 elsif ($arglist[0] eq '--include-deps' || $arglist[0] eq '-i')
408 $cmdline_use_dependencies = 0;
410 elsif ($arglist[0] eq '--generate-deps')
414 elsif ($arglist[0] eq '--no-force')
416 $force_generation = 0;
418 elsif ($arglist[0] =~ /^--output-dir=(.*)$/)
420 # Set output directory.
421 $output_directory = $1;
423 elsif ($arglist[0] eq '--output-dir' || $arglist[0] eq '-o')
425 &require_argument (@arglist);
427 $output_directory = $arglist[0];
429 elsif ($arglist[0] eq '--add-missing' || $arglist[0] eq '-a')
433 elsif ($arglist[0] eq '--verbose' || $arglist[0] eq '-v')
437 elsif ($arglist[0] eq '--')
439 # Stop option processing.
441 push (@input_files, @arglist);
444 elsif ($arglist[0] =~ /^-/)
446 die "automake: unrecognized option -- \`$arglist[0]'\nTry \`automake --help' for more information.\n";
450 # Handle $local:$input syntax. Note that we only examine
451 # the first ":" file to see if it is automake input; the
452 # rest are just taken verbatim. We still keep all the
453 # files around for dependency checking, however.
454 local ($local, $input, @rest) = split (/:/, $arglist[0]);
461 # Strip .in; later on .am is tacked on. That is how
462 # the automake input file is found. Maybe not the
463 # best way, but it is easy to explain. FIXME: should
464 # be error if .in is missing.
467 push (@input_files, $input);
468 $output_files{$input} = join (':', ($local, @rest));
474 # Take global strictness from whatever we currently have set.
475 $default_strictness = $strictness;
476 $default_strictness_name = $strictness_name;
479 # Ensure argument exists, or die.
482 local ($arg, @arglist) = @_;
483 die "automake: no argument given for option \`$arg'\n"
487 ################################################################
489 # Generate a Makefile.in given the name of the corresponding Makefile and
490 # the name of the file output by config.status.
491 sub generate_makefile
493 local ($output, $makefile) = @_;
495 ($am_file_name = $makefile) =~ s/^.*\///;
496 $in_file_name = $am_file_name . '.in';
497 $am_file_name .= '.am';
499 # $OUTPUT is encoded. If it contains a ":" then the first element
500 # is the real output file, and all remaining elements are input
501 # files. We don't scan or otherwise deal with these input file,
502 # other than to mark them as dependencies. See scan_configure for
504 local (@secondary_inputs);
505 ($output, @secondary_inputs) = split (/:/, $output);
507 &initialize_per_input;
508 $relative_dir = &dirname ($output);
509 $am_relative_dir = &dirname ($makefile);
511 # At the toplevel directory, we might need config.guess, config.sub
512 # or libtool scripts (ltconfig and ltmain.sh).
513 if ($relative_dir eq '.')
515 # libtool requires some files.
516 &require_conf_file_with_conf_line ($libtool_line, $FOREIGN,
520 # AC_CANONICAL_HOST and AC_CANONICAL_SYSTEM need config.guess and
522 &require_config_file ($FOREIGN, 'config.guess', 'config.sub')
526 # We still need Makefile.in here, because sometimes the `dist'
527 # target doesn't re-run automake.
528 if ($am_relative_dir eq $relative_dir)
530 # Only distribute the files if they are in the same subdir as
531 # the generated makefile.
532 &push_dist_common ($in_file_name, $am_file_name);
534 push (@sources, '$(SOURCES)')
535 if &variable_defined ('SOURCES');
536 push (@objects, '$(OBJECTS)')
537 if &variable_defined ('OBJECTS');
539 &read_am_file ($makefile . '.am');
542 # Fatal error. Just return, so we can continue with next file.
546 # Check first, because we might modify some state.
548 &check_gnu_standards;
549 &check_gnits_standards;
551 &handle_configure ($output, $makefile, @secondary_inputs);
558 &handle_built_sources;
560 # This must be run after all the sources are scanned.
561 &handle_yacc_lex_cxx;
563 # Re-init SOURCES and OBJECTS. FIXME: other code shouldn't depend
564 # on this (but currently does).
565 $contents{'SOURCES'} = join (' ', @sources);
566 $contents{'OBJECTS'} = join (' ', @objects);
576 &handle_minor_options;
577 &handle_dist ($makefile);
578 &handle_dependencies;
581 &handle_merge_targets ($output);
588 if (! -d ($output_directory . '/' . $am_relative_dir))
590 mkdir ($output_directory . '/' . $am_relative_dir, 0755);
593 local ($out_file) = $output_directory . '/' . $makefile . ".in";
594 if (! $force_generation && -e $out_file)
596 local ($am_time) = (stat ($makefile . '.am'))[9];
597 local ($in_time) = (stat ($out_file))[9];
598 # FIXME: should cache these times.
599 local ($conf_time) = (stat ('configure.in'))[9];
600 # FIXME: how to do unsigned comparison?
601 if ($am_time < $in_time || $am_time < $conf_time)
608 local ($acl_time) = (stat _)[9];
609 return if ($am_time < $acl_time);
613 if (! open (GM_FILE, "> " . $out_file))
615 warn "automake: ${am_file}.in: cannot write: $!\n";
619 print "automake: creating ", $makefile, ".in\n" if $verbose;
621 print GM_FILE $output_vars;
622 # We make sure that `all:' is the first target.
623 print GM_FILE $output_all;
624 print GM_FILE $output_header;
625 print GM_FILE $output_rules;
626 print GM_FILE $output_trailer;
631 ################################################################
633 # Handle AUTOMAKE_OPTIONS variable. Return 1 on error, 0 otherwise.
636 if (&variable_defined ('AUTOMAKE_OPTIONS'))
638 foreach (&variable_value_as_list ('AUTOMAKE_OPTIONS', ''))
641 if ($_ eq 'gnits' || $_ eq 'gnu' || $_ eq 'foreign')
643 &set_strictness ($_);
645 elsif ($_ eq 'cygnus')
651 # An option like "../lib/ansi2knr" is allowed. With
652 # no path prefix, we assume the required programs are
653 # in this directory. We save the actual option for
655 $options{'ansi2knr'} = $_;
657 elsif ($_ eq 'no-installman' || $_ eq 'no-installinfo'
658 || $_ eq 'dist-shar' || $_ eq 'dist-zip'
659 || $_ eq 'dist-tarZ' || $_ eq 'dejagnu'
660 || $_ eq 'no-texinfo.tex'
661 || $_ eq 'readme-alpha' || $_ eq 'check-news')
663 # Explicitly recognize these.
665 elsif ($_ eq 'no-dependencies')
667 $use_dependencies = 0;
669 elsif (/([0-9]+)\.([0-9]+)([a-z])?/)
671 # Got a version number.
673 local ($rmajor, $rminor, $ralpha) = ($1, $2, $3);
675 if ($VERSION !~ /([0-9]+)\.([0-9]+)([a-z])?/)
678 "automake: programming error: version is incorrect\n";
681 local ($tmajor, $tminor, $talpha) = ($1, $2, $3);
683 # 2.0 is better than 1.0.
684 # 1.2 is better than 1.1.
685 # 1.2a is better than 1.2.
686 if ($rmajor > $tmajor
687 || ($rmajor == $tmajor && $rminor > $tminor)
688 || ($rminor == $tminor && $rminor == $tminor
689 && $ralpha gt $talpha))
691 &am_line_error ('AUTOMAKE_OPTIONS',
692 "require version $_, only have $VERSION");
698 &am_line_error ('AUTOMAKE_OPTIONS',
699 "option \`" . $_ . "\' not recognized");
704 if ($strictness == $GNITS)
706 $options{'readme-alpha'} = 1;
707 $options{'check-news'} = 1;
713 # Return object extension. Just once, put some code into the output.
714 # Argument is the name of the output file
715 sub get_object_extension
720 $dir_holds_sources = 1;
722 # Maybe require libtool library object files.
723 local ($extension) = '.o';
724 $extension = '.lo' if ($out =~ /\.la$/);
726 if (! $included_generic_compile)
730 if (&variable_defined ('CONFIG_HEADER'))
733 foreach $one_hdr (split (' ', &variable_value ('CONFIG_HEADER')))
736 ($var = &dirname ($one_hdr)) =~ s/(\W)/\\$1/g;
737 $xform .= ' ' if $xform;
738 $xform .= '-I' . $var;
741 $xform = 's/\@CONFIG_INCLUDE_SPEC\@/' . $xform . '/go;';
742 $output_vars .= &file_contents_with_transform ($xform,
745 &file_contents_with_transform
746 ($use_dependencies ? 's/^NOTDEPEND.*$//;' : 's/^NOTDEPEND//;',
749 &push_phony_cleaners ('compile');
751 # If using X, include some extra variable definitions. NOTE
752 # we don't want to force these into CFLAGS or anything,
753 # because not all programs will necessarily use X.
757 foreach $var ('X_CFLAGS', 'X_LIBS', 'X_EXTRA_LIBS', 'X_PRE_LIBS')
759 &define_configure_variable ($var);
763 push (@suffixes, '.c', '.o', '.S', '.s');
764 push (@clean, 'compile');
766 $included_generic_compile = 1;
769 if ($seen_libtool && ! $included_libtool_compile)
771 # Output the libtool compilation rules.
773 &file_contents_with_transform
774 ($use_dependencies ? 's/^NOTDEPEND.*$//;' : 's/^NOTDEPEND//;',
777 &push_phony_cleaners ('libtool');
779 push (@suffixes, '.lo');
780 push (@clean, 'libtool');
782 $included_libtool_compile = 1;
785 # Check for automatic de-ANSI-fication.
786 if (defined $options{'ansi2knr'})
788 $extension = '$U' . $extension;
789 if (! $included_knr_compile)
791 if (! $am_c_prototypes)
793 &am_line_error ('AUTOMAKE_OPTIONS',
794 "option \`ansi2knr' in use but \`AM_C_PROTOTYPES' not in configure.in");
795 &keyed_aclocal_warning ('AM_C_PROTOTYPES');
796 # Only give this error once.
797 $am_c_prototypes = 1;
800 # Only require ansi2knr files if they should appear in
802 if ($options{'ansi2knr'} eq 'ansi2knr')
804 &require_file_with_line ('AUTOMAKE_OPTIONS', $FOREIGN,
805 'ansi2knr.c', 'ansi2knr.1');
806 $output_rules .= &file_contents ('kr-extra');
807 push (@clean, 'krextra');
808 &push_phony_cleaners ('krextra');
811 # Generate rules to build ansi2knr. If it is in some
812 # other directory, then generate dependencies but have the
813 # rule just run elsewhere.
814 $output_rules .= ($options{'ansi2knr'} . ': '
815 . $options{'ansi2knr'} . ".o\n");
816 if ($options{'ansi2knr'} eq 'ansi2knr')
818 $output_rules .= ("\t\$(LINK) ansi2knr.o \$(LIBS)\n"
819 . "ansi2knr.o: \$(CONFIG_HEADER)\n\n");
823 $output_rules .= ("\tcd " . &dirname ($options{'ansi2knr'})
824 . " && \$(MAKE) ansi2knr\n\n");
825 # This is required for non-GNU makes.
826 $output_rules .= ($options{'ansi2knr'} . ".o:\n");
827 $output_rules .= ("\tcd " . &dirname ($options{'ansi2knr'})
828 . " && \$(MAKE) ansi2knr.o\n\n");
831 # Make sure ansi2knr can be found: if no path specified,
833 if ($options{'ansi2knr'} eq 'ansi2knr')
835 # Substitution from AM_C_PROTOTYPES. This makes it be
836 # built only when necessary.
837 &define_configure_variable ('ANSI2KNR');
838 # ansi2knr needs to be built before subdirs, so unshift it.
839 unshift (@all, '$(ANSI2KNR)');
843 # Found in another directory.
844 &define_variable ("ANSI2KNR", $options{'ansi2knr'});
847 $output_rules .= &file_contents ('clean-kr');
850 &push_phony_cleaners ('kr');
852 $included_knr_compile = 1;
859 # Handle yacc and lex.
860 sub handle_yacc_lex_cxx
863 # First do yacc and lex.
866 local ($yacc_count) = scalar (keys %yacc_sources);
867 local ($lex_count) = scalar (keys %lex_sources);
871 local ($file, $base, $hname, $cname);
872 local (%seen_suffix) = ();
873 foreach $file (keys %yacc_sources)
876 &output_yacc_build_rule ($1, $yacc_count > 1)
877 if (! defined $seen_suffix{$1});
878 $seen_suffix{$1} = 1;
880 # Now generate rule to make the header file. This should
881 # only be generated if `yacc -d' specified. But right now
882 # there is no way to determine that. FIXME: the
883 # AM_FOOFLAGS idea would suffice here.
884 $file =~ /^(.*)\.(y|yy|y\+\+|yxx)$/;
886 ($hname = $2) =~ tr/y/h/;
887 ($cname = $2) =~ tr/y/c/;
888 $output_rules .= "${base}.${hname}: ${base}.${cname}\n";
890 # If the files are built in the build directory, then we
891 # want to remove them with `make clean'. If they are in
892 # srcdir they shouldn't be touched. However, we can't
893 # determine this statically, and the GNU rules say that
894 # yacc/lex output files should be removed by
895 # maintainer-clean. So that's what we do.
896 push (@maintainer_clean_files, $base . $hname, $base . $cname);
898 $output_rules .= "\n";
900 if (! defined $configure_vars{'YACC'})
902 &am_error ("yacc source seen but \`YACC' not defined in \`configure.in'");
904 if (&variable_defined ('YACCFLAGS'))
906 &am_line_error ('YACCFLAGS',
907 "\`YACCFLAGS' obsolete; use \`YFLAGS' instead");
912 local (%seen_suffix) = ();
913 local ($file, $cname);
914 foreach $file (keys %lex_sources)
917 &output_lex_build_rule ($1, $lex_count > 1)
918 if (! defined $seen_suffix{$1});
919 $seen_suffix{$1} = 1;
921 # If the files are built in the build directory, then we
922 # want to remove them with `make clean'. If they are in
923 # srcdir they shouldn't be touched. However, we can't
924 # determine this statically, and the GNU rules say that
925 # yacc/lex output files should be removed by
926 # maintainer-clean. So that's what we do.
927 $file =~ /^(.*)\.(l|ll|l\+\+|lxx)$/;
928 ($cname = $2) =~ tr/y/c/;
929 push (@maintainer_clean_files, $1 . $cname);
932 if (! defined $configure_vars{'LEX'})
934 &am_error ("lex source seen but \`LEX' not defined in \`configure.in'");
936 if (! $seen_decl_yytext)
938 &am_error ("lex source seen but \`AC_DECL_YYTEXT' not in \`configure.in'");
942 if ($yacc_count > 1 || $lex_count > 1)
944 # If there is more than one distinct yacc (resp lex) source
945 # file in a given directory, then the `ylwrap' program is
946 # required to allow parallel builds to work correctly. FIXME:
947 # for now, no line number.
948 &require_config_file ($FOREIGN, 'ylwrap');
949 if ($config_aux_dir ne '.' && $config_aux_dir ne '')
951 &define_variable ('YLWRAP', $config_aux_dir . "/ylwrap");
955 &define_variable ('YLWRAP', '$(srcdir)/ylwrap');
962 local ($ltcompile, $ltlink) = ('', '');
965 &define_configure_variable ("LIBTOOL");
966 $ltcompile = '$(LIBTOOL) --mode=compile ';
967 $ltlink = '$(LIBTOOL) --mode=link ';
973 local (@cxx_list) = keys %cxx_extensions;
974 local ($cxx_count) = scalar @cxx_list;
977 push (@suffixes, @cxx_list);
979 &define_configure_variable ("CXXFLAGS");
980 &define_variable ('CXXCOMPILE', '$(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)');
981 &define_variable ('LTCXXCOMPILE',
982 $ltcompile . '$(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)')
985 &define_variable ('CXXLINK', $ltlink . '$(CXX) $(AM_CXXFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@');
988 foreach $ext (@cxx_list)
990 $output_rules .= ("$ext.o:\n"
991 . "\t\$(CXXCOMPILE) -c \$<\n");
992 $output_rules .= ("$ext.lo:\n"
993 . "\t\$(LTCXXCOMPILE) -c \$<\n")
997 if (! defined $configure_vars{'CXX'})
999 &am_error ("C++ source seen but \`CXX' not defined in \`configure.in'");
1004 # Handle some ansi2knr cleanup.
1007 # Push all libobjs files onto de_ansi_files. We actually only
1008 # push files which exist in the current directory, and which are
1009 # genuine source files. This is moderately lame. FIXME.
1011 foreach $file (keys %libsources)
1013 if ($file =~ /^(.*)\.[cly]$/ && -f "$relative_dir/$file")
1015 $de_ansi_files{$1} = 1;
1019 if (defined $options{'ansi2knr'} && keys %de_ansi_files)
1021 # Make all _.c files depend on their corresponding .c files.
1022 local ($base, @objects);
1023 foreach $base (sort (keys %de_ansi_files))
1025 # Each _.c file must depend on ansi2knr; otherwise it
1026 # might be used in a parallel build before it is built.
1027 # We need to support files in the srcdir and in the build
1028 # dir (because these files might be auto-generated. But
1029 # we can't use $< -- some makes only define $< during a
1031 $output_rules .= ($base . "_.c: $base.c \$(ANSI2KNR)\n\t"
1032 . '$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) '
1033 . '`if test -f $(srcdir)/' . $base . '.c'
1034 . '; then echo $(srcdir)/' . $base . '.c'
1035 . '; else echo ' . $base . '.c; fi` '
1036 . '| $(ANSI2KNR) ' . $base . "_.c\n");
1037 push (@objects, $base . '_.o');
1038 push (@objects, $base . '_.lo') if $seen_libtool;
1041 # Make all _.o (and _.lo) files depend on ansi2knr.
1042 # Use a sneaky little hack to make it print nicely.
1043 &pretty_print_rule ('', '', @objects, ':', '$(ANSI2KNR)');
1047 # Last, handle some C cleanup.
1049 if ($seen_any_source)
1051 &define_configure_variable ('CFLAGS');
1052 &define_variable ('COMPILE',
1053 '$(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)');
1054 &define_variable ('LTCOMPILE',
1056 '$(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)')
1058 &define_variable ('LINK', $ltlink . '$(CC) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@');
1061 if ($seen_c_source && ! defined $configure_vars{'CC'})
1063 &am_line_error ($seen_c_source,
1064 "C source seen but \`CC' not defined in \`configure.in'");
1069 # Output a rule to build from a YACC source. The output from YACC is
1070 # compiled with C or C++, depending on the extension of the YACC file.
1071 sub output_yacc_build_rule
1073 local ($yacc_suffix, $use_ylwrap, $c_suffix) = @_;
1076 ($suffix = $yacc_suffix) =~ tr/y/c/;
1077 push (@suffixes, $yacc_suffix, $suffix);
1079 # Generate rule for c/c++.
1080 $output_rules .= "$yacc_suffix$suffix:\n\t";
1084 $output_rules .= ('$(SHELL) $(YLWRAP)'
1085 . ' "$(YACC)" $< y.tab.c $*' . $suffix
1086 . ' y.tab.h $*.h -- $(AM_YFLAGS) $(YFLAGS)');
1090 $output_rules .= ('$(YACC) $(AM_YFLAGS) $(YFLAGS) $< && mv y.tab.c $*'
1092 . "\tif test -f y.tab.h; then \\\n"
1093 . "\tif cmp -s y.tab.h \$*.h; then rm -f y.tab.h; else mv y.tab.h \$*.h; fi; \\\n"
1096 $output_rules .= "\n";
1099 sub output_lex_build_rule
1101 local ($lex_suffix, $use_ylwrap) = @_;
1104 ($c_suffix = $lex_suffix) =~ tr/l/c/;
1105 push (@suffixes, $lex_suffix);
1106 &define_configure_variable ('LEX_OUTPUT_ROOT');
1107 &define_configure_variable ('LEXLIB');
1108 $output_rules .= "$lex_suffix$c_suffix:\n\t";
1112 # Is the $@ correct here? If so, why not use it in the ylwrap
1113 # build rule for yacc above?
1114 $output_rules .= '$(SHELL) $(YLWRAP)'
1115 . ' "$(LEX)" $< $(LEX_OUTPUT_ROOT).c $@ -- $(AM_LFLAGS) $(LFLAGS)';
1119 $output_rules .= '$(LEX) $(AM_LFLAGS) $(LFLAGS) $< && mv $(LEX_OUTPUT_ROOT).c $@';
1121 $output_rules .= "\n";
1125 # Check to make sure a source defined in LIBOBJS is not explicitly
1126 # mentioned. This is a separate function (as opposed to being inlined
1127 # in handle_source_transform) because it isn't always appropriate to
1129 sub check_libobjs_sources
1131 local ($one_file, $unxformed) = @_;
1133 local ($prefix, $file, @files);
1134 foreach $prefix ('', 'EXTRA_')
1136 if (&variable_defined ($prefix . $one_file . '_SOURCES'))
1138 @files = &variable_value_as_list (($prefix
1139 . $one_file . '_SOURCES'),
1142 elsif ($prefix eq '')
1144 @files = ($unxformed . '.c');
1151 foreach $file (@files)
1153 if (defined $libsources{$file})
1155 &am_line_error ($prefix . $one_file . '_SOURCES',
1156 "automatically discovered file \`$file' should not be explicitly mentioned");
1162 # Does much of the actual work for handle_source_transform.
1164 # pattern matching object extension (e.g., .o)
1165 # list of source files to transform
1167 # first element is name of linker to use (empty string for default linker)
1168 # remaining elements are names of `.o's
1169 sub handle_single_transform_list
1171 local ($objpat, @files) = @_;
1172 local ($linker) = '';
1173 local (@result) = ();
1174 local ($nonansi_obj) = $obj;
1175 $nonansi_obj =~ s/_//g;
1178 # Turn sources into objects.
1181 # Skip header files, including C++-ish ones. The list
1182 # of C++ header extensions comes from Emacs 19.32
1189 # Skip things that look like configure substitutions.
1192 # Include appropriate file for lex or yacc source in
1193 # distribution. If the extension is the regular '.y' or
1194 # '.l', we assume C compilation, and the generated file
1195 # has exension .c. Otherwise, we compile with C++, and
1196 # make the following association: (yy -> cc, y++ -> c++,
1197 # yxx -> cxx), similarly for .ll, etc.
1198 if (/^(.*)\.(y|yy|y\+\+|yxx)$/)
1203 &push_dist_common ("$1.$ext");
1204 $yacc_sources{$_} = 1;
1206 elsif (/^(.*)\.(l|ll|l\+\+|lxx)$/)
1211 &push_dist_common ("$1.$ext");
1212 $lex_sources{$_} = 1;
1215 # Strip any directory prefix.
1216 $_ = &basename ($_);
1218 local ($is_cxx) = 0;
1219 # Transform source files into .o files. List of C++
1220 # extensions comes from Emacs 19.34 etags.
1221 if (s/\.(c\+\+|cc|cpp|cxx|C)$/$nonansi_obj/)
1223 $cxx_extensions{'.' . $1} = 1;
1224 $linker = 'CXXLINK';
1227 elsif (s/\.(yy|y\+\+|yxx|ll|l\+\+|lxx)$/$nonansi_obj/)
1229 # Compiling lex or yacc with C++
1232 $cxx_extensions{".$ext"} = 1;
1233 $linker = 'CXXLINK';
1235 elsif (s/\.([Ff]|f90|for)$/$nonansi_obj/)
1237 # FORTRAN support. FIXME: not finished.
1239 elsif (s/\.[sS]$/$nonansi_obj/)
1241 # .s is assembly. Just rewrite it. FIXME: not finished.
1243 elsif (defined ($options{'ansi2knr'}) && s/_\.[cly]$/_.c/)
1245 # FIXME include line number in error.
1246 &am_error ("C source file \`$_' would be deleted by ansi2knr rules");
1248 elsif (s/\.[cly]$//)
1250 # .c is C. .l is lex. .y is yacc.
1252 # Note: first we rewrite (eg) foo.c to foo and push
1253 # the file onto the list of deansified files. Then we add
1254 # $obj, which can either be `_.o', or simply `.o' if
1255 # deansification is not required.
1256 $de_ansi_files{$_} = 1;
1260 elsif (/\.$source_suffix_pattern$/)
1262 # We just rewrite it. Maybe we should do more.
1263 s//.$suffix_rules{$1}/;
1264 $objpat = "\\." . $suffix_rules{$1};
1268 # No error message here. Used to have one, but it was
1273 $seen_any_source = 1 unless $is_cxx;
1276 # Transform .o or $o file into .P file (for automatic
1279 $dep_files{'.deps/' . $_} = 1;
1283 return ($linker, @result);
1286 # Handle SOURCE->OBJECT transform for one program or library.
1288 # canonical (transformed) name of object to build
1289 # actual name of object to build
1290 # object extension (ie either `.o' or `$o'.
1291 # Return result is name of linker variable that must be used.
1292 # Empty return means just use `LINK'.
1293 sub handle_source_transform
1295 # one_file is canonical name. unxformed is given name. obj is
1297 local ($one_file, $unxformed, $obj) = @_;
1298 local ($objpat) = $obj;
1299 $objpat =~ s/(\W)/\\$1/g;
1300 # Handle explicit `.o' as well as whatever we're passed.
1301 $objpat = '(' . $objpat . "|\\.o)";
1303 local ($linker) = '';
1305 if (&variable_defined ($one_file . "_OBJECTS"))
1307 &am_line_error ($one_file . '_OBJECTS',
1308 $one_file . '_OBJECTS', 'should not be defined');
1309 # No point in continuing.
1313 local (@files, @result, $prefix, $temp);
1314 foreach $prefix ('', 'EXTRA_')
1317 local ($var) = $prefix . $one_file . "_SOURCES";
1318 if (&variable_defined ($var))
1320 push (@sources, '$(' . $prefix . $one_file . "_SOURCES)");
1321 push (@objects, '$(' . $prefix . $one_file . "_OBJECTS)")
1322 unless $prefix eq 'EXTRA_';
1323 local (@conds) = &variable_conditions ($var);
1326 @files = &variable_value_as_list ($var, '');
1330 local ($cond, $cond_var_name);
1332 local (@namelist) = ();
1333 foreach $cond (@conds)
1335 @files = &variable_value_as_list ($var, $cond);
1336 ($temp, @result) = &handle_single_transform_list ($objpat,
1338 $linker = $temp if $linker eq '';
1340 # We have to have a new name for each such
1341 # variable. Then we define the _OBJECTS variable
1342 # as the union of all such variables. Hopefully
1343 # this is the Right Thing.
1344 $cond_var_name = 'cond' . $count . $one_file . '_OBJECTS';
1345 &define_pretty_variable ($cond_var_name, $cond, @result)
1346 unless $prefix eq 'EXTRA_';
1347 push (@namelist, '$(' . $cond_var_name . ')');
1351 &define_pretty_variable ($one_file . '_OBJECTS', '',
1357 elsif ($prefix eq '')
1359 &define_variable ($one_file . "_SOURCES", $unxformed . ".c");
1360 push (@sources, $unxformed . '.c');
1361 push (@objects, $unxformed . $obj);
1362 push (@files, $unxformed . '.c');
1365 ($temp, @result) = &handle_single_transform_list ($objpat, @files);
1366 $linker = $temp if $linker eq '';
1367 &define_pretty_variable ($one_file . "_OBJECTS", '', @result)
1368 unless $prefix eq 'EXTRA_';
1374 # Handle the BUILT_SOURCES variable.
1375 sub handle_built_sources
1377 return unless &variable_defined ('BUILT_SOURCES');
1379 local (@sources) = &variable_value_as_list ('BUILT_SOURCES', 'all');
1381 foreach $s (@sources)
1385 # FIXME: is this really the right thing to do?
1386 &am_line_error ('BUILT_SOURCES',
1387 "\`BUILT_SOURCES' should not contain a configure substitution");
1392 # We don't care about the return value of this function. We just
1393 # want to make sure to update %dep_files with the contents of
1395 &handle_single_transform_list ("\\.o", @sources);
1398 # Special-case @ALLOCA@ and @LIBOBJS@ in _LDADD or _LIBADD variables.
1399 # Also, generate _DEPENDENCIES variable if appropriate.
1401 # transformed name of object being built, or empty string if no object
1402 # name of _LDADD/_LIBADD-type variable to examine
1403 # boolean (lex_seen) which is true if a lex source file was seen in this
1404 # object. valid only for LDADDs, not LIBADDs.
1405 # Returns 1 if LIBOBJS seen, 0 otherwise.
1406 sub handle_lib_objects
1408 local ($xname, $var, $lex_seen) = @_;
1411 die "automake: programming error 1 in handle_lib_objects\n"
1412 if ! &variable_defined ($var);
1414 die "automake: programming error 2 in handle_lib_objects\n"
1415 if $lex_seen && $var =~ /LIBADD/;
1417 local (@conds) = &variable_conditions ($var);
1420 $ret = &handle_lib_objects_cond ($xname, $var, $lex_seen, '');
1426 foreach $cond (@conds)
1428 if (&handle_lib_objects_cond ($xname, $var, $lex_seen, $cond))
1438 # Subroutine of handle_lib_objects: handle a particular condition.
1439 sub handle_lib_objects_cond
1441 local ($xname, $var, $lex_seen, $cond) = @_;
1443 # We recognize certain things that are commonly put in LIBADD or
1446 local (@dep_list) = ();
1448 local ($seen_libobjs) = 0;
1449 local ($flagvar) = 0;
1451 foreach $lsearch (&variable_value_as_list ($var, $cond))
1453 # Skip -lfoo and -Ldir; these are explicitly allowed.
1454 next if $lsearch =~ /^-[lL]/;
1455 if (! $flagvar && $lsearch =~ /^-/)
1457 if ($var =~ /^(.*)LDADD$/)
1459 &am_line_error ($var, "linker flags such as \`$lsearch' belong in \`${1}LDFLAGS");
1463 # Only get this error once.
1465 &am_line_error ($var, "you cannot use linker flags such as \`$lsearch' in \`$var'");
1469 # Assume we have a file of some sort, and push it onto the
1470 # dependency list. Autoconf substitutions are not pushed;
1471 # rarely is a new dependency substituted into (eg) foo_LDADD
1472 # -- but "bad things (eg -lX11) are routinely substituted.
1473 # Note that LIBOBJS and ALLOCA are exceptions to this rule,
1474 # and handled specially below.
1475 push (@dep_list, $lsearch)
1476 unless $lsearch =~ /^\@.*\@$/;
1478 # Automatically handle @LIBOBJS@ and @ALLOCA@. Basically this
1479 # means adding entries to dep_files.
1480 if ($lsearch =~ /^\@(LT)?LIBOBJS\@$/)
1482 push (@dep_list, $lsearch);
1484 if (! keys %libsources)
1486 &am_line_error ($var, "\@$1" . "LIBOBJS\@ seen but never set in \`configure.in'");
1489 local ($iter, $rewrite);
1490 foreach $iter (keys %libsources)
1492 if ($iter =~ /\.[cly]$/)
1494 $seen_c_source = $var;
1495 $seen_any_source = 1;
1498 if ($iter =~ /\.h$/)
1500 &require_file_with_line ($var, $FOREIGN, $iter);
1502 elsif ($iter ne 'alloca.c')
1504 ($rewrite = $iter) =~ s/\.c$/.P/;
1505 $dep_files{'.deps/' . $rewrite} = 1;
1506 &require_file_with_line ($var, $FOREIGN, $iter);
1510 elsif ($lsearch =~ /^\@(LT)?ALLOCA\@$/)
1512 push (@dep_list, $lsearch);
1513 &am_line_error ($var,
1514 "\@$1" . "ALLOCA\@ seen but \`AC_FUNC_ALLOCA' not in \`configure.in'")
1515 if ! defined $libsources{'alloca.c'};
1516 $dep_files{'.deps/alloca.P'} = 1;
1517 &require_file_with_line ($var, $FOREIGN, 'alloca.c');
1518 $seen_c_source = $var;
1519 $seen_any_source = 1;
1523 if ($xname ne '' && ! &variable_defined ($xname . '_DEPENDENCIES', $cond))
1525 &define_pretty_variable ($xname . '_DEPENDENCIES', $cond, @dep_list);
1528 return $seen_libobjs;
1531 # Canonicalize a name, and check to make sure the non-canonical name
1532 # is never used. Returns canonical name. Arguments are name and a
1533 # list of suffixes to check for.
1534 sub check_canonical_spelling
1536 local ($name, @suffixes) = @_;
1537 local ($xname, $xt);
1539 ($xname = $name) =~ tr/A-Za-z0-9_/_/c;
1540 if ($xname ne $name)
1543 foreach $xt (@suffixes)
1545 &am_line_error ($name . $xt,
1546 "invalid variable \`" . $name . $xt
1547 . "'; should be \`" . $xname . $xt . "'")
1548 if &variable_defined ($name . $xt);
1555 # Handle C programs.
1558 local (@proglist) = &am_install_var ('-clean',
1559 'progs', 'PROGRAMS',
1560 'bin', 'sbin', 'libexec', 'pkglib',
1562 return if ! @proglist;
1564 # If a program is installed, this is required. We only want this
1565 # error to appear once.
1566 &am_conf_error ("AC_ARG_PROGRAM must be used in configure.in")
1567 unless $seen_arg_prog;
1570 local ($one_file, $xname, $munge);
1572 local ($seen_libobjs) = 0;
1573 foreach $one_file (@proglist)
1575 local ($obj) = &get_object_extension ($one_file);
1577 # Canonicalize names and check for misspellings.
1578 $xname = &check_canonical_spelling ($one_file, '_LDADD', '_LDFLAGS',
1579 '_SOURCES', '_OBJECTS',
1582 # FIXME: Using a trick to figure out if any lex sources appear
1583 # in our program; should use some cleaner method.
1584 local ($lex_num) = scalar (keys %lex_sources);
1585 local ($linker) = &handle_source_transform ($xname, $one_file, $obj);
1586 local ($lex_file_seen) = (scalar (keys %lex_sources) > $lex_num);
1589 if (&variable_defined ($xname . "_LDADD"))
1591 if (&handle_lib_objects ($xname, $xname . '_LDADD',
1601 # User didn't define prog_LDADD override. So do it.
1602 &define_variable ($xname . '_LDADD', '$(LDADD)');
1604 # This does a bit too much work. But we need it to
1605 # generate _DEPENDENCIES when appropriate.
1606 if (&variable_defined ('LDADD'))
1608 if (&handle_lib_objects ($xname, 'LDADD', $lex_file_seen))
1614 elsif (! &variable_defined ($xname . '_DEPENDENCIES'))
1616 &define_variable ($xname . '_DEPENDENCIES', '');
1621 if (&variable_defined ($xname . '_LIBADD'))
1623 &am_line_error ($xname . '_LIBADD',
1624 "use \`" . $xname . "_LDADD', not \`"
1625 . $xname . "_LIBADD'");
1628 if (! &variable_defined ($xname . '_LDFLAGS'))
1630 # Define the prog_LDFLAGS variable.
1631 &define_variable ($xname . '_LDFLAGS', '');
1634 # Determine program to use for link.
1636 if (&variable_defined ($xname . '_LINK'))
1638 $xlink = $xname . '_LINK';
1642 $xlink = $linker ? $linker : 'LINK';
1646 if ($seen_exeext && $one_file !~ /\./)
1648 $xexe = 's/\@EXEEXT\@/\$(EXEEXT)/g;';
1652 $xexe = 's/\@EXEEXT\@//g;';
1656 &file_contents_with_transform
1657 ('s/\@PROGRAM\@/' . $one_file . '/go;'
1658 . 's/\@XPROGRAM\@/' . $xname . '/go;'
1659 . 's/\@XLINK\@/' . $xlink . '/go;'
1664 if (&variable_defined ('LDADD') && &handle_lib_objects ('', 'LDADD', 0))
1671 foreach $one_file (@proglist)
1673 # Canonicalize names.
1674 ($xname = $one_file) =~ tr/A-Za-z0-9_/_/c;
1676 if (&variable_defined ($xname . '_LDADD'))
1678 &check_libobjs_sources ($xname, $xname . '_LDADD');
1680 elsif (&variable_defined ('LDADD'))
1682 &check_libobjs_sources ($xname, 'LDADD');
1690 sub handle_libraries
1692 local (@liblist) = &am_install_var ('-clean',
1693 'libs', 'LIBRARIES',
1694 'lib', 'pkglib', 'noinst', 'check');
1695 return if ! @liblist;
1697 local (%valid) = &am_primary_prefixes ('LIBRARIES', 'lib', 'pkglib',
1699 if (! defined $configure_vars{'RANLIB'})
1702 foreach $key (keys %valid)
1704 if (&variable_defined ($key . '_LIBRARIES'))
1706 &am_line_error ($key . '_LIBRARIES', "library used but \`RANLIB' not defined in \`configure.in'");
1707 # Only get this error once.
1708 $configure_vars{'RANLIB'} = 1;
1717 local ($seen_libobjs) = 0;
1718 foreach $onelib (@liblist)
1720 # Check that the library fits the standard naming convention.
1721 if ($onelib !~ /^lib.*\.a$/)
1723 # FIXME should put line number here. That means mapping
1724 # from library name back to variable name.
1725 &am_error ("\`$onelib' is not a standard library name");
1728 local ($obj) = &get_object_extension ($onelib);
1730 # Canonicalize names and check for misspellings.
1731 $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_SOURCES',
1732 '_OBJECTS', '_DEPENDENCIES');
1734 if (&variable_defined ($xlib . '_LIBADD'))
1736 if (&handle_lib_objects ($xlib, $xlib . '_LIBADD', 0))
1743 # Generate support for conditional object inclusion in
1745 &define_variable ($xlib . "_LIBADD", '');
1748 if (&variable_defined ($xlib . '_LDADD'))
1750 &am_line_error ($xlib . '_LDADD',
1751 "use \`" . $xlib . "_LIBADD', not \`"
1752 . $xlib . "_LDADD'");
1755 # Make sure we at look at this.
1756 &examine_variable ($xlib . '_DEPENDENCIES');
1758 &handle_source_transform ($xlib, $onelib, $obj);
1761 &file_contents_with_transform ('s/\@LIBRARY\@/' . $onelib . '/go;'
1769 foreach $onelib (@liblist)
1771 # Canonicalize names.
1772 ($xlib = $onelib) =~ tr/A-Za-z0-9_/_/c;
1773 if (&variable_defined ($xlib . '_LIBADD'))
1775 &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
1780 &define_variable ('AR', 'ar');
1781 &define_configure_variable ('RANLIB');
1784 # Handle shared libraries.
1785 sub handle_ltlibraries
1787 local (@liblist) = &am_install_var ('-clean',
1788 'ltlib', 'LTLIBRARIES',
1790 return if ! @liblist;
1793 local (%valid) = &am_primary_prefixes ('LTLIBRARIES', 'lib', 'pkglib');
1796 foreach $key (keys %valid)
1798 if (&variable_defined ($key . '_LTLIBRARIES'))
1802 &am_line_error ($key . '_LTLIBRARIES', "library used but \`LIBTOOL' not defined in \`configure.in'");
1803 # Only get this error once.
1804 $configure_vars{'LIBTOOL'} = 1;
1808 # Get the installation directory of each library.
1809 for (&variable_value_as_list ($key . '_LTLIBRARIES', 'all'))
1813 &am_error ("\`$_' is already going to be installed in \`$instdirs{$_}'");
1817 $instdirs{$_} = $key;
1826 local ($seen_libobjs) = 0;
1827 foreach $onelib (@liblist)
1829 # Check that the library fits the standard naming convention.
1830 if ($onelib !~ /^lib.*\.la$/)
1832 # FIXME this should only be a warning for foreign packages
1833 # FIXME should put line number here. That means mapping
1834 # from library name back to variable name.
1835 &am_error ("\`$onelib' is not a standard libtool library name");
1838 local ($obj) = &get_object_extension ($onelib);
1840 # Canonicalize names and check for misspellings.
1841 $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_LDFLAGS',
1842 '_SOURCES', '_OBJECTS',
1845 if (! &variable_defined ($xlib . '_LDFLAGS'))
1847 # Define the lib_LDFLAGS variable.
1848 &define_variable ($xlib . '_LDFLAGS', '');
1851 if (&variable_defined ($xlib . '_LIBADD'))
1853 if (&handle_lib_objects ($xlib, $xlib . '_LIBADD', 0))
1860 # Generate support for conditional object inclusion in
1862 &define_variable ($xlib . "_LIBADD", '');
1865 if (&variable_defined ($xlib . '_LDADD'))
1867 &am_line_error ($xlib . '_LDADD',
1868 "use \`" . $xlib . "_LIBADD', not \`"
1869 . $xlib . "_LDADD'");
1872 # Make sure we at look at this.
1873 &examine_variable ($xlib . '_DEPENDENCIES');
1875 local ($linker) = &handle_source_transform ($xlib, $onelib, $obj);
1877 # Determine program to use for link.
1879 if (&variable_defined ($xlib . '_LINK'))
1881 $xlink = $xlib . '_LINK';
1885 $xlink = $linker ? $linker : 'LINK';
1889 if ($instdirs{$onelib} eq 'EXTRA')
1891 # It's an EXTRA_ library, so we can't specify -rpath.
1893 $rpath = 's/\@RPATH\@//go;';
1897 $rpath = ('s/\@RPATH\@/-rpath \$(' . $instdirs{$onelib}
1902 &file_contents_with_transform ('s/\@LTLIBRARY\@/'
1904 . 's/\@XLTLIBRARY\@/'
1907 . 's/\@XLINK\@/' . $xlink . '/go;',
1913 foreach $onelib (@liblist)
1915 # Canonicalize names.
1916 ($xlib = $onelib) =~ tr/A-Za-z0-9_/_/c;
1917 if (&variable_defined ($xlib . '_LIBADD'))
1919 &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
1925 # See if any _SOURCES variable were misspelled. Also, make sure that
1926 # EXTRA_ variables don't contain configure substitutions.
1929 local ($varname, $primary);
1930 foreach $varname (keys %contents)
1932 foreach $primary ('_SOURCES', '_LIBADD', '_LDADD', '_LDFLAGS',
1935 if ($varname =~ /$primary$/ && ! $content_seen{$varname})
1937 &am_line_error ($varname,
1938 "invalid unused variable name: \`$varname'");
1947 # NOTE we no longer automatically clean SCRIPTS, because it is
1948 # useful to sometimes distribute scripts verbatim. This happens
1949 # eg in Automake itself.
1950 &am_install_var ('scripts', 'SCRIPTS',
1951 'bin', 'sbin', 'libexec', 'pkgdata',
1954 # Set $scripts_installed if appropriate. Make sure we only find
1955 # scripts which are actually installed -- this is why we can't
1956 # simply use the return value of am_install_var.
1957 local (%valid) = &am_primary_prefixes ('SCRIPTS', 'bin', 'sbin',
1958 'libexec', 'pkgdata',
1961 foreach $key (keys %valid)
1963 if ($key ne 'noinst'
1965 && &variable_defined ($key . '_SCRIPTS'))
1967 $scripts_installed = 1;
1968 # push (@check_tests, 'check-' . $key . 'SCRIPTS');
1972 if ($scripts_installed)
1974 # If a program is installed, this is required. We only want this
1975 # error to appear once.
1976 &am_conf_error ("AC_ARG_PROGRAM must be used in configure.in")
1977 unless $seen_arg_prog;
1982 # Search a file for a "version.texi" Texinfo include. Return the name
1983 # of the include file if found, or the empty string if not. A
1984 # "version.texi" file is actually any file whose name matches
1986 sub scan_texinfo_file
1988 local ($filename) = @_;
1990 if (! open (TEXI, $filename))
1992 &am_error ("couldn't open \`$filename': $!");
1995 print "automake: reading $filename\n" if $verbose;
1997 local ($vfile, $outfile);
2000 if (/^\@setfilename +(\S+)/)
2006 if (/^\@include\s+(vers[^.]*\.texi)\s*$/)
2008 # Found version.texi include.
2015 return ($outfile, $vfile);
2018 # Handle all Texinfo source.
2021 &am_line_error ('TEXINFOS',
2022 "\`TEXINFOS' is an anachronism; use \`info_TEXINFOS'")
2023 if &variable_defined ('TEXINFOS');
2024 return if (! &variable_defined ('info_TEXINFOS')
2025 && ! &variable_defined ('html_TEXINFOS'));
2027 local (@texis) = &variable_value_as_list ('info_TEXINFOS', 'all');
2029 local (@info_deps_list, @dvis_list, @texi_deps);
2030 local ($infobase, $info_cursor);
2034 local ($tc_cursor, @texi_cleans);
2037 foreach $info_cursor (@texis)
2039 # FIXME: This is mildly hacky, since it recognizes "txinfo".
2040 # I don't feel like making it right.
2041 ($infobase = $info_cursor) =~ s/\.te?xi(nfo)?$//;
2043 # If 'version.texi' is referenced by input file, then include
2044 # automatic versioning capability.
2045 local ($out_file, $vtexi) = &scan_texinfo_file ($relative_dir
2046 . "/" . $info_cursor);
2048 if ($out_file eq '')
2050 &am_error ("\`$info_cursor' missing \@setfilename");
2054 if ($out_file =~ /\.(.+)$/ && $1 ne 'info')
2056 # FIXME should report line number in input file.
2057 &am_error ("output of \`$info_cursor', \`$out_file', has unrecognized extension");
2063 &am_error ("\`$vtexi', included in \`$info_cursor', also included in \`$versions{$vtexi}'")
2064 if (defined $versions{$vtexi});
2065 $versions{$vtexi} = $info_cursor;
2067 # We number the stamp-vti files. This is doable since the
2068 # actual names don't matter much. We only number starting
2069 # with the second one, so that the common case looks nice.
2070 $vti = 'vti' . ($done ? $done : '');
2071 &push_dist_common ($vtexi, 'stamp-' . $vti);
2072 push (@clean, $vti);
2074 # Only require once.
2075 &require_conf_file_with_line ('info_TEXINFOS', $FOREIGN,
2081 ($conf_pat = $config_aux_dir) =~ s/(\W)/\\$1/g;
2083 &file_contents_with_transform
2084 ('s/\@TEXI\@/' . $info_cursor . '/g; '
2085 . 's/\@VTI\@/' . $vti . '/g; '
2086 . 's/\@VTEXI\@/' . $vtexi . '/g;'
2087 . 's,\@MDDIR\@,' . $conf_pat . ',g;',
2090 &push_phony_cleaners ($vti);
2093 # If user specified file_TEXINFOS, then use that as explicit
2096 push (@texi_deps, $info_cursor);
2097 push (@texi_deps, $vtexi) if $vtexi;
2099 # Canonicalize name first.
2100 ($canonical = $infobase) =~ tr/A-Za-z0-9_/_/c;
2101 if (&variable_defined ($canonical . "_TEXINFOS"))
2103 push (@texi_deps, '$(' . $canonical . '_TEXINFOS)');
2104 &push_dist_common ('$(' . $canonical . '_TEXINFOS)');
2107 $output_rules .= ("\n" . $out_file . ": "
2108 . join (' ', @texi_deps)
2109 . "\n" . $infobase . ".dvi: "
2110 . join (' ', @texi_deps)
2113 push (@info_deps_list, $out_file);
2114 push (@dvis_list, $infobase . '.dvi');
2116 # Generate list of things to clean for this target. We do
2117 # this explicitly because otherwise too many things could be
2118 # removed. In particular the ".log" extension might
2119 # reasonably be used in other contexts by the user.
2120 foreach $tc_cursor ('aux', 'cp', 'cps', 'dvi', 'fn', 'fns',
2121 'ky', 'kys', 'ps', 'log', 'pg', 'toc', 'tp', 'tps',
2122 'vr', 'vrs', 'op', 'tr', 'cv', 'cn')
2124 push (@texi_cleans, $infobase . '.' . $tc_cursor);
2128 # Find these programs wherever they may lie. Yes, this has
2129 # intimate knowledge of the structure of the texinfo distribution.
2130 &define_program_variable ('MAKEINFO', 'build', 'texinfo/makeinfo',
2132 # Circumlocution to avoid accidental
2133 # configure substitution.
2135 &define_program_variable ('TEXI2DVI', 'src', 'texinfo/util',
2138 # Set transform for including texinfos.am. First, handle --cygnus
2143 $xform = 's/^NOTCYGNUS.*$//; s/^CYGNUS//;';
2147 $xform = 's/^CYGNUS.*$//; s/^NOTCYGNUS//;';
2150 # Handle location of texinfo.tex.
2151 local ($need_texi_file) = 0;
2154 &define_variable ('TEXINFO_TEX',
2155 '$(top_srcdir)/../texinfo/texinfo.tex');
2157 elsif ($config_aux_dir ne '.' && $config_aux_dir ne '')
2159 &define_variable ('TEXINFO_TEX', $config_aux_dir . '/texinfo.tex');
2161 elsif (! &variable_defined ('TEXINFO_TEX'))
2163 &define_variable ('TEXINFO_TEX', '$(srcdir)/texinfo.tex');
2167 $need_texi_file = 1;
2169 local ($xxform) = &dirname (&variable_value ('TEXINFO_TEX'));
2170 $xxform =~ s/(\W)/\\$1/g;
2171 $xform .= ' s/\@TEXINFODIR\@/' . $xxform . '/g;';
2173 $output_rules .= &file_contents_with_transform ($xform, 'texinfos');
2174 push (@phony, 'install-info-am', 'uninstall-info');
2175 push (@dist_targets, 'dist-info');
2177 # How to clean. The funny name is due to --cygnus influence; in
2178 # Cygnus mode, `clean-info' is a target that users can use.
2179 $output_rules .= "\nmostlyclean-aminfo:\n";
2180 &pretty_print_rule ("\t-rm -f", "\t ", @texi_cleans);
2181 $output_rules .= ("\nclean-aminfo:\n\ndistclean-aminfo:\n\n"
2182 . "maintainer-clean-aminfo:\n\t"
2183 # Eww. But how else can we find all the output
2184 # files from makeinfo?
2185 . 'for i in $(INFO_DEPS); do' . " \\\n"
2186 . "\t" . ' rm -f $$i;' . " \\\n"
2187 . "\t" . ' if test "`echo $$i-[0-9]*`" != "$$i-[0-9]*"; then' . " \\\n"
2188 . "\t" . ' rm -f $$i-[0-9]*;' . " \\\n"
2189 . "\t" . ' fi;' . " \\\n"
2191 &push_phony_cleaners ('aminfo');
2194 $output_rules .= "clean-info: mostlyclean-aminfo\n";
2197 push (@suffixes, '.texi', '.texinfo', '.txi', '.info', '.dvi', '.ps');
2199 if (! defined $options{'no-installinfo'})
2201 push (@uninstall, 'uninstall-info');
2202 push (@installdirs, '$(DESTDIR)$(infodir)');
2203 unshift (@install_data, 'install-info-am');
2205 # Make sure documentation is made and installed first. Use
2206 # $(INFO_DEPS), not 'info', because otherwise recursive makes
2207 # get run twice during "make all".
2208 unshift (@all, '$(INFO_DEPS)');
2210 push (@clean, 'aminfo');
2211 push (@info, '$(INFO_DEPS)');
2212 push (@dvi, '$(DVIS)');
2214 &define_variable ("INFO_DEPS", join (' ', @info_deps_list));
2215 &define_variable ("DVIS", join (' ', @dvis_list));
2216 # This next isn't strictly needed now -- the places that look here
2217 # could easily be changed to look in info_TEXINFOS. But this is
2218 # probably better, in case noinst_TEXINFOS is ever supported.
2219 &define_variable ("TEXINFOS", &variable_value ('info_TEXINFOS'));
2221 # Do some error checking. Note that this file is not required
2222 # when in Cygnus mode; instead we defined TEXINFO_TEX explicitly
2224 &require_file_with_line ('info_TEXINFOS', $FOREIGN, 'texinfo.tex')
2225 if $need_texi_file && ! defined $options{'no-texinfo.tex'};
2228 # Handle any man pages.
2229 sub handle_man_pages
2231 &am_line_error ('MANS', "\`MANS' is an anachronism; use \`man_MANS'")
2232 if &variable_defined ('MANS');
2233 return if ! &variable_defined ('man_MANS');
2235 # Find all the sections in use. We do this by first looking for
2236 # "standard" sections, and then looking for any additional
2237 # sections used in man_MANS.
2238 local ($sect, %sections, %vlist);
2239 # Add more sections as needed.
2240 foreach $sect ('0'..'9', 'n', 'l')
2242 if (&variable_defined ('man' . $sect . '_MANS'))
2244 $sections{$sect} = 1;
2245 $vlist{'$(man' . $sect . '_MANS)'} = 1;
2249 if (&variable_defined ('man_MANS'))
2251 $vlist{'$(man_MANS)'} = 1;
2252 foreach (&variable_value_as_list ('man_MANS', 'all'))
2254 # A page like `foo.1c' goes into man1dir.
2255 if (/\.([0-9a-z])([a-z]*)$/)
2263 # Now for each section, generate an install and unintall rule.
2264 # Sort sections so output is deterministic.
2266 foreach $sect (sort keys %sections)
2268 &define_variable ('man' . $sect . 'dir', '$(mandir)/man' . $sect);
2269 push (@installdirs, '$(DESTDIR)$(mandir)/man' . $sect)
2270 unless defined $options{'no-installman'};
2271 $output_rules .= &file_contents_with_transform ('s/\@SECTION\@/'
2274 push (@phony, 'install-man' . $sect, 'uninstall-man' . $sect);
2275 push (@namelist, 'install-man' . $sect);
2278 # We don't really need this, but we use it in case we ever want to
2279 # support noinst_MANS.
2280 &define_variable ("MANS", join (' ', sort keys %vlist));
2282 # Generate list of install dirs.
2283 $output_rules .= ("install-man: \$(MANS)\n"
2284 . "\t\@\$(NORMAL_INSTALL)\n");
2285 &pretty_print_rule ("\t\$(MAKE)", "\t ", @namelist);
2286 push (@phony, 'install-man');
2288 $output_rules .= "uninstall-man:\n\t\@\$(NORMAL_UNINSTALL)\n";
2289 grep ($_ = 'un' . $_, @namelist);
2290 &pretty_print_rule ("\t\$(MAKE)", "\t ", @namelist);
2291 push (@phony, 'uninstall-man');
2293 $output_vars .= &file_contents ('mans-vars');
2295 if (! defined $options{'no-installman'})
2297 push (@install_data, 'install-man');
2298 push (@uninstall, 'uninstall-man');
2299 push (@all, '$(MANS)');
2303 # Handle DATA variables.
2306 &am_install_var ('data', 'DATA', 'data', 'sysconf',
2307 'sharedstate', 'localstate', 'pkgdata',
2314 push (@phony, 'tags');
2315 local (@tag_deps) = ();
2316 if (&variable_defined ('SUBDIRS'))
2318 $output_rules .= ("tags-recursive:\n"
2319 . "\tlist=\'\$(SUBDIRS)\'; for subdir in \$\$list; do \\\n"
2320 # Never fail here if a subdir fails; it
2322 . "\t (cd \$\$subdir && \$(MAKE) tags); \\\n"
2324 push (@tag_deps, 'tags-recursive');
2325 push (@phony, 'tags-recursive');
2328 if ($dir_holds_sources
2329 || $dir_holds_headers
2330 || &variable_defined ('ETAGS_ARGS')
2333 local ($xform) = '';
2335 foreach $one_hdr (@config_headers)
2337 if ($relative_dir eq &dirname ($one_hdr))
2339 # The config header is in this directory. So require it.
2341 ($var = &basename ($one_hdr)) =~ s/(\W)/\\$1/g;
2342 $xform .= ' ' if $xform;
2346 $xform = ('s/\@CONFIG\@/' . $xform . '/;'
2347 . 's/\@DIRS\@/' . join (' ', @tag_deps) . '/;');
2349 if (&variable_defined ('SUBDIRS'))
2351 $xform .= 's/^SUBDIRS//;';
2355 $xform .= 's/^SUBDIRS.*$//;';
2358 $output_rules .= &file_contents_with_transform ($xform, 'tags');
2359 $output_rules .= &file_contents ('tags-clean');
2360 push (@clean, 'tags');
2361 &push_phony_cleaners ('tags');
2362 &examine_variable ('TAGS_DEPENDENCIES');
2364 elsif (&variable_defined ('TAGS_DEPENDENCIES'))
2366 &am_line_error ('TAGS_DEPENDENCIES',
2367 "doesn't make sense to define \`TAGS_DEPENDENCIES' without sources or \`ETAGS_ARGS'");
2371 # Every Makefile must define some sort of TAGS rule.
2372 # Otherwise, it would be possible for a top-level "make TAGS"
2373 # to fail because some subdirectory failed.
2374 $output_rules .= "tags: TAGS\nTAGS:\n\n";
2378 # Worker for handle_dist.
2379 sub handle_dist_worker
2381 local ($makefile) = @_;
2383 $output_rules .= 'distdir: $(DISTFILES)' . "\n";
2385 # Initialization; only at top level.
2386 if ($relative_dir eq '.')
2388 if (defined $options{'check-news'})
2390 # For Gnits users, this is pretty handy. Look at 15 lines
2391 # in case some explanatory text is desirable.
2392 $output_rules .= ' @if sed 15q $(srcdir)/NEWS | fgrep -e "$(VERSION)" > /dev/null; then :; else \\
2393 echo "NEWS not updated; not releasing" 1>&2; \\
2400 # Create dist directory.
2401 $output_rules .= ("\t-rm -rf \$(distdir)\n"
2402 . "\tmkdir \$(distdir)\n"
2403 . "\t-chmod 777 \$(distdir)\n");
2406 # Only run automake in `dist' target if --include-deps and
2407 # `no-dependencies' not specified. That way the recipient of a
2408 # distribution can run "make dist" and not need Automake. You
2409 # might be wondering why we run automake once for each directory
2410 # we distribute, instead of running it once at the top level. The
2411 # answer is that we want to run automake after the dependencies
2412 # have been generated. This occurs when "make" is run in the
2413 # subdir. So automake must be run after make has updated the
2414 # Makefile, which means that it must run once per directory.
2415 if ($use_dependencies)
2419 # There are several directories we need to know about
2420 # when rebuilding the Makefile.ins. They are:
2421 # here - The absolute path to our topmost build directory.
2422 # top_distdir - The absolute path to the top of our dist
2424 # distdir - The path to our sub-part of the dist hierarchy.
2425 # If this directory is the topmost directory, we set
2426 # top_distdir from distdir; that lets us pass in distdir
2427 # from an enclosing package.
2428 "\t" . 'here=`cd $(top_builddir) && pwd`; ' . "\\\n"
2429 . "\t" . 'top_distdir=`cd $('
2430 . (($relative_dir eq '.') ? 'distdir' : 'top_distdir')
2431 . ') && pwd`; ' . "\\\n"
2432 . "\t" . 'distdir=`cd $(distdir) && pwd`; ' . "\\\n"
2433 . "\tcd \$(top_srcdir) \\\n"
2434 . "\t && \$(AUTOMAKE) --include-deps --build-dir=\$\$here --srcdir-name=\$(top_srcdir) --output-dir=\$\$top_distdir "
2435 # Set strictness of output.
2436 . ($cygnus_mode ? '--cygnus' : ('--' . $strictness_name))
2437 . ($cmdline_use_dependencies ? '' : ' --include-deps')
2438 . " " . $makefile . "\n"
2442 # Scan EXTRA_DIST to see if we need to distribute anything from a
2443 # subdir. If so, add it to the list. I didn't want to do this
2444 # originally, but there were so many requests that I finally
2447 if (&variable_defined ('EXTRA_DIST'))
2449 # FIXME: This should be fixed to work with conditionals. That
2450 # will require only making the entries in @dist_dirs under the
2451 # appropriate condition. This is meaningful if the nature of
2452 # the distribution should depend upon the configure options
2454 foreach (&variable_value_as_list ('EXTRA_DIST', ''))
2457 next unless s,/+[^/]+$,,;
2458 push (@dist_dirs, $_)
2464 # Prepend $(distdir) to each directory given. Doing it via a
2465 # hash lets us ensure that each directory is used only once.
2467 grep ($dhash{'$(distdir)/' . $_} = 1, @dist_dirs);
2468 $output_rules .= "\t";
2469 &pretty_print_rule ('$(mkinstalldirs)', "\t ", sort keys %dhash);
2472 # In loop, test for file existence because sometimes a file gets
2473 # included in DISTFILES twice. For example this happens when a
2474 # single source file is used in building more than one program.
2475 # Also, there are situations in which "ln" can fail. For instance
2476 # a file to distribute could actually be a cross-filesystem
2477 # symlink -- this can easily happen if "gettextize" was run on the
2479 $output_rules .= "\t\@for file in \$(DISTFILES); do \\\n";
2482 $output_rules .= "\t if test -f \$\$file; then d=.; else d=\$(srcdir); fi; \\\n";
2486 $output_rules .= "\t d=\$(srcdir); \\\n";
2488 $output_rules .= ' test -f $(distdir)/$$file \\
2489 || ln $$d/$$file $(distdir)/$$file 2> /dev/null \\
2490 || cp -p $$d/$$file $(distdir)/$$file; \\
2494 # If we have SUBDIRS, create all dist subdirectories and do
2496 if (&variable_defined ('SUBDIRS'))
2498 # If SUBDIRS is conditionally defined, then set DIST_SUBDIRS
2499 # to all possible directories, and use it.
2500 if (! &variable_conditions ('SUBDIRS'))
2502 $dist_subdir_name = 'SUBDIRS';
2506 $dist_subdir_name = 'DIST_SUBDIRS';
2507 if (! &variable_defined ('DIST_SUBDIRS'))
2509 &define_pretty_variable ('DIST_SUBDIRS', '',
2510 &variable_value_as_list ('SUBDIRS',
2515 # Test for directory existence here because previous automake
2516 # invocation might have created some directories. Note that
2517 # we explicitly set distdir for the subdir make; that lets us
2518 # mix-n-match many automake-using packages into one large
2519 # package, and have "dist" at the top level do the right
2520 # thing. If we're in the topmost directory, then we use
2521 # `distdir' instead of `top_distdir'; this lets us work
2522 # correctly with an enclosing package.
2524 ("\t" . 'for subdir in $(' . $dist_subdir_name . '); do ' . "\\\n"
2525 . "\t" . ' test -d $(distdir)/$$subdir ' . "\\\n"
2526 . "\t" . ' || mkdir $(distdir)/$$subdir ' . "\\\n"
2527 . "\t" . ' || exit 1; ' . "\\\n"
2528 . "\t" . ' chmod 777 $(distdir)/$$subdir; ' . "\\\n"
2529 . "\t" . ' (cd $$subdir && $(MAKE) top_distdir=../$('
2530 . (($relative_dir eq '.') ? 'distdir' : 'top_distdir')
2531 . ') distdir=../$(distdir)/$$subdir distdir) ' . "\\\n"
2532 . "\t" . ' || exit 1; ' . "\\\n"
2536 # If the target `dist-hook' exists, make sure it is run. This
2537 # allows users to do random weird things to the distribution
2538 # before it is packaged up.
2539 push (@dist_targets, 'dist-hook') if defined $contents{'dist-hook'};
2542 foreach $targ (@dist_targets)
2544 # We must explicitly set distdir and top_distdir for these
2546 $output_rules .= "\t\$(MAKE) top_distdir=\"\$(top_distdir)\" distdir=\"\$(distdir)\" $targ\n";
2549 push (@phony, 'distdir');
2552 # Handle 'dist' target.
2555 local ($makefile) = @_;
2557 # Set up maint_charset.
2558 $local_maint_charset = &variable_value ('MAINT_CHARSET')
2559 if &variable_defined ('MAINT_CHARSET');
2560 $maint_charset = $local_maint_charset
2561 if $relative_dir eq '.';
2563 if (&variable_defined ('DIST_CHARSET'))
2565 &am_line_error ('DIST_CHARSET',
2566 "DIST_CHARSET defined but no MAINT_CHARSET defined")
2567 if ! $local_maint_charset;
2568 if ($relative_dir eq '.')
2570 $dist_charset = &variable_value ('DIST_CHARSET')
2574 &am_line_error ('DIST_CHARSET',
2575 "DIST_CHARSET can only be defined at top level");
2579 # Look for common files that should be included in distribution.
2581 foreach $cfile (@common_files)
2583 if (-f ($relative_dir . "/" . $cfile))
2585 &push_dist_common ($cfile);
2589 # Keys of %dist_common are names of files to distributed. We put
2590 # README first because it then becomes easier to make a
2591 # Usenet-compliant shar file (in these, README must be first).
2592 # FIXME: do more ordering of files here.
2594 if (defined $dist_common{'README'})
2596 push (@coms, 'README');
2597 delete $dist_common{'README'};
2599 push (@coms, sort keys %dist_common);
2601 &define_pretty_variable ("DIST_COMMON", '', @coms);
2602 $output_vars .= "\n";
2605 $output_vars .= &file_contents ('dist-vars') . "\n";
2606 &define_variable ('TAR', $TAR);
2607 &define_variable ('GZIP', '--best');
2609 # Put these things in rules section so it is easier for whoever
2610 # reads Makefile.in.
2611 if (! &variable_defined ('distdir'))
2613 if ($relative_dir eq '.')
2615 $output_rules .= "\n" . 'distdir = $(PACKAGE)-$(VERSION)' . "\n";
2619 $output_rules .= ("\n"
2620 . 'distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)'
2624 if ($relative_dir eq '.')
2626 $output_rules .= "top_distdir = \$(distdir)\n\n";
2630 $output_rules .= "\nsubdir = " . $relative_dir . "\n\n";
2633 # Generate 'dist' target, and maybe dist-shar / dist-zip / dist-tarZ.
2634 if ($relative_dir eq '.')
2636 # Rule to check whether a distribution is viable.
2637 $output_rules .= ('# This target untars the dist file and tries a VPATH configuration. Then
2638 # it guarantees that the distribution is self-contained by making another
2642 GZIP=$(GZIP) $(TAR) zxf $(distdir).tar.gz
2643 mkdir $(distdir)/=build
2644 mkdir $(distdir)/=inst
2645 dc_install_base=`cd $(distdir)/=inst && pwd`; \\'
2646 . (defined $contents{'distcheck-hook'}
2647 ? "\t\$(MAKE) distcheck-hook"
2650 cd $(distdir)/=build \\
2653 . ($seen_gettext ? '--with-included-gettext ' : '')
2654 . '--srcdir=.. --prefix=$$dc_install_base \\
2658 && $(MAKE) install \\
2659 && $(MAKE) installcheck \\
2662 @echo "========================"; \\
2663 echo "$(distdir).tar.gz is ready for distribution"; \\
2664 echo "========================"
2667 local ($dist_all) = ('dist-all: distdir' . "\n"
2670 foreach $curs ('dist', 'dist-shar', 'dist-zip', 'dist-tarZ')
2672 if (defined $options{$curs} || $curs eq 'dist')
2674 $output_rules .= ($curs . ': distdir' . "\n"
2678 $dist_all .= $dist{$curs};
2681 $output_rules .= $dist_all . $dist_trailer;
2684 # Generate distdir target.
2685 &handle_dist_worker ($makefile);
2688 # Scan a single dependency file and rewrite the dependencies as
2689 # appropriate. Essentially this means:
2690 # * Clean out absolute dependencies which are not desirable.
2691 # * Rewrite other dependencies to be relative to $(top_srcdir).
2692 sub scan_dependency_file
2694 local ($depfile) = @_;
2696 if (! open (DEP_FILE, $depfile))
2698 &am_error ("couldn't open \`$depfile': $!");
2701 print "automake: reading $depfile\n" if $verbose;
2703 # Sometimes it is necessary to omit some dependencies.
2704 local (%omit) = %omit_dependencies;
2705 if (&variable_defined ('OMIT_DEPENDENCIES'))
2707 # FIXME: Doesn't work with conditionals. I'm not sure if this
2709 grep ($omit{$_} = 1,
2710 &variable_value_as_list ('OMIT_DEPENDENCIES', ''));
2713 local ($first_line) = 1;
2714 local ($last_line) = 0;
2715 local ($target, @dependencies);
2716 local ($one_dep, $xform);
2719 local ($srcdir_rx, $fixup_rx);
2720 ($fixup_rx = $srcdir_name . '/' . $relative_dir . '/')
2722 ($srcdir_rx = $srcdir_name . '/') =~ s/(\W)/\\$1/g;
2724 local ($rewrite_builddir) = (($top_builddir eq '.')
2726 : $top_builddir . '/');
2732 # If LAST_LINE set then we've already seen what we thought
2733 # was the last line.
2736 next if (/$WHITE_PATTERN/o);
2740 # No trailing "\" means this should be the last line.
2746 if (! /^([^:]+:)(.+)$/)
2749 &am_error ("\`$depfile' has incorrect format");
2755 # Make sure to strip the .P file from the target.
2756 ($target = $1) =~ s, *\.deps/[^.]+\.P,,;
2761 foreach $one_dep (split (' ', $_))
2763 ($just_file = $one_dep) =~ s,^.*/,,;
2764 next if defined $omit{$just_file};
2766 if ($one_dep =~ /^$fixup_rx/)
2768 # The dependency points to the current directory in
2770 ($xform = $one_dep) =~ s/^$fixup_rx//;
2771 push (@dependencies, $xform);
2773 elsif ($one_dep =~ /^$srcdir_rx/)
2775 # The dependency is in some other directory in the package.
2776 ($xform = $one_dep) =~ s/^$srcdir_rx/$rewrite_builddir/;
2777 push (@dependencies, $xform);
2779 elsif ($one_dep =~ /^\//)
2781 # Absolute path; ignore.
2785 # Anything else is assumed to be correct.
2786 push (@dependencies, $one_dep);
2791 &pretty_print_rule ($target, "\t", @dependencies);
2796 # Handle auto-dependency code.
2797 sub handle_dependencies
2799 # Make sure this variable is always marked as used.
2800 &examine_variable ('OMIT_DEPENDENCIES');
2802 if ($use_dependencies)
2804 # Include GNU-make-specific auto-dep code. Don't include it
2805 # if DEP_FILES would be empty.
2806 if ($dir_holds_sources && keys %dep_files)
2808 &define_pretty_variable ('DEP_FILES', '', sort keys %dep_files);
2809 $output_rules .= &file_contents ('depend');
2810 push (@clean, 'depend');
2811 &push_phony_cleaners ('depend');
2813 &file_contents_with_transform ('s/\@EXT\@/.c/g;'
2817 foreach $ext (sort keys %cxx_extensions)
2820 &file_contents_with_transform ('s/\@EXT\@/' . $ext .'/g;'
2821 . 's/\@PFX\@/CXX/g;',
2826 elsif ($build_directory ne '')
2828 # Include any auto-generated deps that are present. Note that
2829 # $build_directory ends in a "/".
2830 if (-d ($build_directory . $relative_dir . "/.deps"))
2834 foreach $depfile (&my_glob ($build_directory
2835 . $relative_dir . "/.deps/*.P"))
2837 &scan_dependency_file ($depfile);
2840 $output_rules .= "\n";
2845 # Handle subdirectories.
2848 return if ! &variable_defined ('SUBDIRS');
2850 # Make sure each directory mentioned in SUBDIRS actually exists.
2852 foreach $dir (&variable_value_as_list ('SUBDIRS', 'all'))
2854 # Skip directories substituted by configure.
2855 next if $dir =~ /^\@.*\@$/;
2857 if (! -d $am_relative_dir . '/' . $dir)
2859 &am_line_error ('SUBDIRS',
2860 "required directory $am_relative_dir/$dir does not exist");
2864 &am_line_error ('SUBDIRS', "directory should not contain \`/'")
2868 local ($xform) = ('s/\@INSTALLINFO\@/' .
2869 (defined $options{'no-installinfo'}
2870 ? 'install-info-recursive'
2873 $output_rules .= &file_contents_with_transform ($xform, 'subdirs');
2875 # Push a bunch of phony targets.
2877 foreach $phonies ('-data', '-exec', 'dirs')
2879 push (@phony, 'install' . $phonies . '-recursive');
2880 push (@phony, 'uninstall' . $phonies . '-recursive');
2882 foreach $phonies ('all', 'check', 'installcheck', 'info', 'dvi')
2884 push (@phony, $phonies . '-recursive');
2886 &push_phony_cleaners ('recursive');
2888 push (@check_tests, "check-recursive");
2889 push (@installcheck, "installcheck-recursive");
2890 push (@info, "info-recursive");
2891 push (@dvi, "dvi-recursive");
2893 $recursive_install = 1;
2896 # Handle aclocal.m4.
2897 sub handle_aclocal_m4
2899 local ($regen_aclocal) = 0;
2900 if (-f 'aclocal.m4')
2902 &define_variable ("ACLOCAL_M4", '$(top_srcdir)/aclocal.m4');
2903 &push_dist_common ('aclocal.m4');
2905 if (open (ACLOCAL, '< aclocal.m4'))
2911 if ($line =~ 'generated automatically by aclocal')
2918 local ($acinclude) = 0;
2919 if (-f 'acinclude.m4')
2925 # Note that it might be possible that aclocal.m4 doesn't exist but
2926 # should be auto-generated. This case probably isn't very
2930 local (@ac_deps) = (
2931 ($seen_maint_mode ? "\@MAINT\@" : "") ,
2933 ($acinclude ? ' acinclude.m4' : '')
2936 # Scan all -I directories for m4 files. These are our
2938 if (&variable_defined ('ACLOCAL_AMFLAGS'))
2940 local ($examine_next, $amdir) = 0;
2941 foreach $amdir (&variable_value_as_list ('ACLOCAL_AMFLAGS', ''))
2946 if ($amdir !~ /^\// && -d $amdir)
2948 push (@ac_deps, &my_glob ($amdir . '/*.m4'));
2951 elsif ($amdir eq '-I')
2958 &pretty_print_rule ("\$(ACLOCAL_M4):", "\t\t", @ac_deps);
2960 $output_rules .= ("\t"
2961 . 'cd $(srcdir) && $(ACLOCAL)'
2962 . (&variable_defined ('ACLOCAL_AMFLAGS')
2963 ? ' $(ACLOCAL_AMFLAGS)' : '')
2968 # Rewrite a list of input files into a form suitable to put on a
2969 # dependency list. The idea is that if an input file has a directory
2970 # part the same as the current directory, then the directory part is
2971 # simply removed. But if the directory part is different, then
2972 # $(top_srcdir) is prepended. Among other things, this is used to
2973 # generate the dependency list for the output files generated by
2974 # AC_OUTPUT. Consider what the dependencies should look like in this
2976 # AC_OUTPUT(src/out:src/in1:lib/in2)
2977 sub rewrite_inputs_into_dependencies
2979 local (@inputs) = @_;
2980 local ($single, @newinputs);
2982 foreach $single (@inputs)
2984 if (&dirname ($single) eq $relative_dir)
2986 push (@newinputs, &basename ($single));
2990 push (@newinputs, '$(top_srcdir)/' . $single);
2997 # Handle remaking and configure stuff.
2998 # We need the name of the input file, to do proper remaking rules.
2999 sub handle_configure
3001 local ($local, $input, @secondary_inputs) = @_;
3003 # If SUBDIRS defined, require AC_PROG_MAKE_SET.
3004 &am_line_error ('SUBDIRS', "AC_PROG_MAKE_SET must be used in configure.in")
3005 if &variable_defined ('SUBDIRS') && ! $seen_make_set;
3007 local ($top_reldir);
3009 local ($input_base) = &basename ($input);
3010 local ($local_base) = &basename ($local);
3012 local ($amfile) = $input_base . '.am';
3013 # We know we can always add '.in' because it really should be an
3014 # error if the .in was missing originally.
3015 local ($infile) = '$(srcdir)/' . $input_base . '.in';
3016 local ($colon_infile);
3017 if ($local ne $input || @secondary_inputs)
3019 $colon_infile = ':' . $input . '.in';
3021 $colon_infile .= ':' . join (':', @secondary_inputs)
3022 if @secondary_inputs;
3024 local (@rewritten) = &rewrite_inputs_into_dependencies (@secondary_inputs);
3025 # This rule remakes the Makefile.in. Note use of @MAINT@ forces
3026 # us to abandon pretty-printing. Sigh.
3027 $output_rules .= ($infile
3028 # NOTE perl 5.003 (with -w) gives a
3029 # uninitialized value error on the next line.
3032 . ($seen_maint_mode ? '@MAINT@ ' : '')
3034 . '$(top_srcdir)/configure.in $(ACLOCAL_M4)' . "\n"
3035 . "\tcd \$(top_srcdir) && \$(AUTOMAKE) "
3036 . ($cygnus_mode ? '--cygnus' : ('--' . $strictness_name))
3037 . ($cmdline_use_dependencies ? '' : ' --include-deps')
3038 . ' ' . $input . $colon_infile . "\n\n");
3040 # This rule remakes the Makefile.
3041 $output_rules .= ($local_base
3042 # NOTE: bogus uninit value error on next line;
3043 # see comment above.
3046 . join (' ', @rewritten)
3047 . ' $(top_builddir)/config.status'
3048 # NOTE: Makefile only depends on BUILT_SOURCES
3049 # when dependencies are being computed. This is
3050 # a workaround for an obscure bug with
3051 # AC_LINK_FILES. Anyway, when dependencies are
3052 # turned off, this shouldn't matter.
3053 . ($use_dependencies ? ' $(BUILT_SOURCES)' : '')
3055 . "\tcd \$(top_builddir) \\\n"
3056 . "\t && CONFIG_FILES="
3057 . (($relative_dir eq '.') ? '$@' : '$(subdir)/$@')
3059 . ' CONFIG_HEADERS= $(SHELL) ./config.status'
3062 if ($relative_dir ne '.')
3065 $top_reldir = '../';
3070 $output_rules .= &file_contents ('remake');
3071 &examine_variable ('CONFIGURE_DEPENDENCIES');
3075 # If we have a configure header, require it.
3077 local (@local_fullnames) = @config_fullnames;
3078 local (@local_names) = @config_names;
3079 local ($hdr_index) = 0;
3080 local ($distclean_config) = '';
3081 foreach $one_hdr (@config_headers)
3083 local ($one_fullname) = shift (@local_fullnames);
3084 local ($one_name) = shift (@local_names);
3086 if ($relative_dir eq &dirname ($one_hdr))
3088 local ($ch_sans_dir) = &basename ($one_hdr);
3089 local ($cn_sans_dir) = &basename ($one_name);
3091 &require_file_with_conf_line ($config_header_line,
3092 $FOREIGN, $ch_sans_dir);
3094 # Header defined and in this directory.
3096 if (-f $relative_dir . '/acconfig.h')
3098 push (@files, 'acconfig.h');
3100 if (-f $one_name . '.top')
3102 push (@files, "${cn_sans_dir}.top");
3104 if (-f $one_name . '.bot')
3106 push (@files, "${cn_sans_dir}.bot");
3109 &push_dist_common (@files);
3111 local ($stamp_name) = 'stamp-h';
3112 $stamp_name .= "${hdr_index}" if scalar (@config_headers) > 1;
3114 local ($xform) = '';
3116 $xform = 's,\@FILES\@,' . join (' ', @files) . ',;';
3117 $xform .= 's,\@CONFIG_HEADER\@,' . "${cn_sans_dir}" . ',;';
3118 $xform .= 's,\@CONFIG_HEADER_IN\@,' . "${ch_sans_dir}" . ',;';
3119 $xform .= 's,\@CONFIG_HEADER_FULL\@,' . "${one_fullname}" . ',;';
3120 $xform .= 's,\@STAMP\@,' . "${stamp_name}" . ',;';
3122 $output_rules .= &file_contents_with_transform ($xform,
3125 &touch ($relative_dir . "/${stamp_name}.in");
3126 &require_file_with_conf_line ($config_header_line, $FOREIGN,
3127 "${stamp_name}.in");
3129 $distclean_config .= ' ' if $distclean_config;
3130 $distclean_config .= $cn_sans_dir;
3134 if ($distclean_config)
3136 $output_rules .= &file_contents_with_transform ('s,\@FILES\@,'
3140 push (@clean, 'hdr');
3141 &push_phony_cleaners ('hdr');
3144 # Set location of mkinstalldirs.
3145 if ($config_aux_dir ne '.' && $config_aux_dir ne '')
3147 &define_variable ('mkinstalldirs', ('$(SHELL) ' . $config_aux_dir
3148 . '/mkinstalldirs'));
3152 &define_variable ('mkinstalldirs',
3153 '$(SHELL) $(top_srcdir)/mkinstalldirs');
3156 &am_line_error ('CONFIG_HEADER',
3157 "\`CONFIG_HEADER' is an anachronism; now determined from \`configure.in'")
3158 if &variable_defined ('CONFIG_HEADER');
3161 local ($config_header) = '';
3162 foreach $one_name (@config_names)
3164 # Generate CONFIG_HEADER define.
3166 if ($relative_dir eq &dirname ($one_name))
3168 $one_hdr = &basename ($one_name);
3172 $one_hdr = "${top_builddir}/${one_name}";
3175 $config_header .= ' ' if $config_header;
3176 $config_header .= $one_hdr;
3180 &define_variable ("CONFIG_HEADER", $config_header);
3183 # Now look for other files in this directory which must be remade
3184 # by config.status, and generate rules for them.
3185 local (@actual_other_files) = ();
3186 local ($file, $local);
3187 local (@inputs, @rewritten_inputs, $single);
3188 local ($need_rewritten);
3189 foreach $file (@other_input_files)
3191 if ($file =~ /^([^:]*):(.*)$/)
3193 # This is the ":" syntax of AC_OUTPUT.
3195 $local = &basename ($file);
3196 @inputs = split (':', $2);
3197 @rewritten_inputs = &rewrite_inputs_into_dependencies (@inputs);
3198 $need_rewritten = 1;
3203 $local = &basename ($file);
3204 @inputs = ($local . '.in');
3206 &rewrite_inputs_into_dependencies ($file . '.in');
3207 $need_rewritten = 0;
3210 # Skip files not in this directory.
3211 next unless &dirname ($file) eq $relative_dir;
3213 # Skip any file that is an automake input.
3214 next if -f $file . '.am';
3216 # Some users have been tempted to put `stamp-h' in the
3217 # AC_OUTPUT line. This won't do the right thing, so we
3218 # explicitly fail here.
3219 if ($local eq 'stamp-h')
3221 # FIXME: allow real filename.
3222 &am_conf_error ('configure.in', $ac_output_line,
3223 'stamp-h should not appear in AC_OUTPUT');
3227 $output_rules .= ($local . ': '
3228 . '$(top_builddir)/config.status '
3229 . join (' ', @rewritten_inputs) . "\n"
3231 . 'cd $(top_builddir) && CONFIG_FILES='
3232 . ($relative_dir eq '.' ? '' : '$(subdir)/')
3233 . '$@' . ($need_rewritten
3234 ? (':' . join (':', @rewritten_inputs))
3236 . ' CONFIG_HEADERS= $(SHELL) ./config.status'
3238 push (@actual_other_files, $local);
3240 # Require all input files.
3241 &require_file_with_conf_line ($ac_output_line, $FOREIGN,
3245 # These files get removed by "make clean".
3246 &define_pretty_variable ('CONFIG_CLEAN_FILES', '', @actual_other_files);
3252 $dir_holds_headers = &am_install_var ('header', 'HEADERS', 'include',
3253 'oldinclude', 'pkginclude',
3259 return if ! $seen_gettext || $relative_dir ne '.';
3261 if (! &variable_defined ('SUBDIRS'))
3264 ("AM_GNU_GETTEXT in configure.in but SUBDIRS not defined");
3268 &require_file_with_conf_line ($ac_gettext_line, $FOREIGN, 'ABOUT-NLS')
3271 if (&variable_defined ('SUBDIRS'))
3275 "AM_GNU_GETTEXT in configure.in but \`po' not in SUBDIRS")
3276 if $contents{'SUBDIRS'} !~ /\bpo\b/;
3279 "AM_GNU_GETTEXT in configure.in but \`intl' not in SUBDIRS")
3280 if $contents{'SUBDIRS'} !~ /\bintl\b/;
3283 # Ensure that each language in ALL_LINGUAS has a .po file, and
3284 # each po file is mentioned in ALL_LINGUAS.
3287 local (%linguas) = ();
3288 grep ($linguas{$_} = 1, split (' ', $all_linguas));
3295 &am_line_error ($all_linguas_line,
3296 ("po/$_.po exists but \`$_' not in \`ALL_LINGUAS'"))
3300 foreach (keys %linguas)
3302 &am_line_error ($all_linguas_line,
3303 "$_ in \`ALL_LINGUAS' but po/$_.po does not exist")
3309 &am_error ("AM_GNU_GETTEXT in configure.in but \`ALL_LINGUAS' not defined");
3313 # Handle footer elements.
3316 if ($contents{'SOURCES'})
3318 # NOTE don't use define_pretty_variable here, because
3319 # $contents{...} is already defined.
3320 $output_vars .= 'SOURCES = ' . $contents{'SOURCES'} . "\n";
3322 if ($contents{'OBJECTS'})
3324 # NOTE don't use define_pretty_variable here, because
3325 # $contents{...} is already defined.
3326 $output_vars .= 'OBJECTS = ' . $contents{'OBJECTS'} . "\n";
3328 if ($contents{'SOURCES'} || $contents{'OBJECTS'})
3330 $output_vars .= "\n";
3333 if (&variable_defined ('SUFFIXES'))
3335 # Push actual suffixes, and not $(SUFFIXES). Some versions of
3336 # make do not like variable substitutions on the .SUFFIXES
3338 push (@suffixes, &variable_value_as_list ('SUFFIXES', ''));
3340 if (&target_defined ('.SUFFIXES'))
3342 &am_line_error ('.SUFFIXES',
3343 "use variable \`SUFFIXES', not target \`.SUFFIXES'");
3346 # Note: AIX 4.1 /bin/make will fail if any suffix rule appears
3347 # before .SUFFIXES. So we make sure that .SUFFIXES appears before
3348 # anything else, by sticking it right after the default: target.
3349 $output_header .= ".SUFFIXES:\n";
3353 # Make sure suffixes has unique elements. Sort them to ensure
3354 # the output remains consistent.
3357 grep ($suffixes{$_} = 1, @suffixes);
3359 $output_header .= (".SUFFIXES: "
3360 . join (' ', sort keys %suffixes)
3363 $output_trailer .= &file_contents ('footer');
3366 # Deal with installdirs target.
3367 sub handle_installdirs
3369 # GNU Makefile standards recommend this.
3370 $output_rules .= ("installdirs:"
3371 . ($recursive_install
3372 ? " installdirs-recursive\n"
3374 push (@phony, 'installdirs');
3377 &pretty_print_rule ("\t" . '$(mkinstalldirs) ', "\t\t",
3380 $output_rules .= "\n";
3383 # There are several targets which need to be merged. This is because
3384 # their complete definition is compiled from many parts. Note that we
3385 # avoid double colon rules, otherwise we'd use them instead.
3386 sub handle_merge_targets
3388 local ($makefile) = @_;
3390 # There are a few install-related variables that you should not define.
3392 foreach $var ('PRE_INSTALL', 'POST_INSTALL', 'NORMAL_INSTALL')
3394 if (&variable_defined ($var))
3396 &am_line_error ($var, "\`$var' should not be defined");
3400 # Put this at the beginning for the sake of non-GNU makes. This
3401 # is still wrong if these makes can run parallel jobs. But it is
3403 unshift (@all, &basename ($makefile));
3406 foreach $one_name (@config_names)
3408 push (@all, &basename ($one_name))
3409 if &dirname ($one_name) eq $relative_dir;
3412 &do_one_merge_target ('info', @info);
3413 &do_one_merge_target ('dvi', @dvi);
3414 &do_check_merge_target;
3415 &do_one_merge_target ('installcheck', @installcheck);
3417 if (defined $options{'no-installinfo'})
3419 # FIXME: this is kind of a hack; should find another way to
3420 # know that this is required.
3422 if (grep ($_ eq 'install-info-am', @phony))
3424 push (@dirs, 'install-info-am');
3426 if (&variable_defined ('SUBDIRS'))
3428 push (@dirs, 'install-info-recursive');
3430 &do_one_merge_target ('install-info', @dirs);
3433 # Handle the various install targets specially. We do this so
3434 # that (eg) "make install-exec" will run "install-exec-recursive"
3435 # if required, but "make install" won't run it twice. Step one is
3436 # to see if the user specified local versions of any of the
3437 # targets we handle. "all" is treated as one of these since
3438 # "install" can run it.
3439 push (@install_exec, 'install-exec-local')
3440 if defined $contents{'install-exec-local'};
3441 push (@install_data, 'install-data-local')
3442 if defined $contents{'install-data-local'};
3443 push (@uninstall, 'uninstall-local')
3444 if defined $contents{'uninstall-local'};
3446 foreach $utarg ('uninstall-data-local', 'uninstall-data-hook',
3447 'uninstall-exec-local', 'uninstall-exec-hook')
3449 if (defined $contents{$utarg})
3452 ($x = $utarg) =~ s/(data|exec)-//;
3453 &am_line_error ($utarg, "use \`$x', not \`$utarg'");
3456 push (@all, 'all-local')
3457 if defined $contents{'all-local'};
3459 if (defined $contents{'install-local'})
3461 &am_line_error ('install-local',
3462 "use \`install-data' or \`install-exec', not \`install'");
3465 # Step two: if we are doing recursive makes, write out the
3466 # appropriate rules.
3468 if ($recursive_install)
3470 push (@install, 'install-recursive');
3474 local (@hackall) = ();
3476 local ($local_headers) = '';
3477 foreach $one_name (@config_names)
3479 if (&dirname ($one_name) eq $relative_dir)
3481 $local_headers .= ' ' if $local_headers;
3482 $local_headers .= &basename ($one_name);
3488 # This is kind of a hack, but I couldn't see a better
3489 # way to handle it. In this particular case, we need
3490 # to make sure config.h is built before we recurse.
3491 # We can't do this by changing the order of
3492 # dependencies to the "all" because that breaks when
3493 # using parallel makes. Instead we handle things
3495 $output_rules .= ("all-recursive-am: ${local_headers}"
3496 . "\n\t" . '$(MAKE) all-recursive'
3498 push (@hackall, 'all-recursive-am');
3499 push (@phony, 'all-recursive-am');
3503 push (@hackall, 'all-recursive');
3506 $output_rules .= ('all-am: '
3510 push (@all, 'all-am');
3511 push (@phony, 'all-am');
3515 @all = ('all-recursive');
3517 # Must always generate `all-am' target, so it can be
3518 # referred to elsewhere.
3519 $output_rules .= "all-am:\n";
3523 $output_rules .= ('install-exec-am: '
3524 . join (' ', @install_exec)
3526 @install_exec = ('install-exec-recursive', 'install-exec-am');
3527 push (@install, 'install-exec-am');
3528 push (@phony, 'install-exec-am');
3532 @install_exec = ('install-exec-recursive');
3536 $output_rules .= ('install-data-am: '
3537 . join (' ', @install_data)
3539 @install_data = ('install-data-recursive', 'install-data-am');
3540 push (@install, 'install-data-am');
3541 push (@phony, 'install-data-am');
3545 @install_data = ('install-data-recursive');
3549 $output_rules .= ('uninstall-am: '
3550 . join (' ', @uninstall)
3552 @uninstall = ('uninstall-recursive', 'uninstall-am');
3553 push (@phony, 'uninstall-am');
3557 @uninstall = ('uninstall-recursive');
3561 # Step three: print definitions users can use. Code below knows
3562 # that install-exec is done before install-data, beware.
3563 $output_rules .= ("install-exec: "
3564 . join (' ', @install_exec)
3566 $output_rules .= "\t\@\$(NORMAL_INSTALL)\n";
3567 if (defined $contents{'install-exec-hook'})
3569 $output_rules .= "\t" . '$(MAKE) install-exec-hook' . "\n";
3571 $output_rules .= "\n";
3572 push (@install, 'install-exec') if !$recursive_install;
3573 push (@phony, 'install-exec');
3575 $output_rules .= ("install-data: "
3576 . join (' ', @install_data)
3578 $output_rules .= "\t\@\$(NORMAL_INSTALL)\n";
3579 if (defined $contents{'install-data-hook'})
3581 $output_rules .= "\t" . '$(MAKE) install-data-hook' . "\n";
3583 $output_rules .= "\n";
3584 push (@install, 'install-data') if !$recursive_install;
3585 push (@phony, 'install-data');
3587 # If no dependencies for 'install', add 'all'. Why? That way
3588 # "make install" at top level of distclean'd distribution won't
3589 # fail because stuff in 'lib' fails to build.
3590 if (! @install || (scalar (@install) == 2
3591 && $install[0] eq 'install-exec'
3592 && $install[1] eq 'install-data'))
3594 push (@install, 'all');
3596 $output_rules .= ('install: '
3597 . join (' ', @install)
3598 # Use "@:" as empty command so nothing prints.
3602 . join (' ', @uninstall)
3604 push (@phony, 'install', 'uninstall');
3606 $output_all = 'all: ' . join (' ', @all) . "\n\n";
3607 push (@phony, 'all');
3609 # Generate the new 'install-strip' target. Must set
3610 # INSTALL_SCRIPT to avoid stripping scripts.
3611 $output_rules .= ("install-strip:\n\t"
3612 . '$(MAKE) INSTALL_PROGRAM=\'$(INSTALL_PROGRAM) -s\' INSTALL_SCRIPT=\'$(INSTALL_PROGRAM)\' install'
3616 # Helper for handle_merge_targets.
3617 sub do_one_merge_target
3619 local ($name, @values) = @_;
3621 if (defined $contents{$name . '-local'})
3623 # User defined local form of target. So include it.
3624 push (@values, $name . '-local');
3625 push (@phony, $name . '-local');
3628 &pretty_print_rule ($name . ":", "\t\t", @values);
3629 push (@phony, $name);
3632 # Handle check merge target specially.
3633 sub do_check_merge_target
3635 if (defined $contents{'check-local'})
3637 # User defined local form of target. So include it.
3638 push (@check_tests, 'check-local');
3639 push (@phony, 'check-local');
3642 # In --cygnus mode, check doesn't depend on all.
3645 if (! &variable_defined ('SUBDIRS'))
3647 # 'check' must depend on `all', but not when doing
3649 unshift (@check, 'all');
3653 # When subdirs are used, do the `all' build and then do
3654 # all the recursive stuff. Actually use `all-am' because
3655 # it doesn't recurse; we rely on the check target in the
3656 # subdirs to do the required builds there.
3657 unshift (@check, 'all-am');
3661 # The check target must depend on the local equivalent of `all',
3662 # to ensure all the primary targets are built. Also it must
3663 # depend on the test code named in @check.
3664 &pretty_print_rule ('check:', "\t\t", @check);
3666 # Now the check rules must explicitly run anything named in
3667 # @check_tests. This is done via a separate make invocation to
3668 # avoid problems with parallel makes. Every time I write code
3669 # like this I wonder: how could you invent a parallel make and not
3670 # provide any real synchronization facilities? The official
3671 # answer is that you can push the dependencies out to the leaves
3672 # of the dependency tree. That seems fairly gross to me.
3673 &pretty_print_rule ("\t\$(MAKE)", "\t ", @check_tests)
3677 # Handle all 'clean' targets.
3680 local ($xform) = '';
3683 # Don't include `MAINTAINER'; it is handled specially below.
3684 foreach $name ('MOSTLY', '', 'DIST')
3686 if (! &variable_defined ($name . 'CLEANFILES'))
3688 $xform .= 's/^' . $name . 'CLEAN.*$//;';
3692 $xform .= 's/^' . $name . 'CLEAN//;';
3696 # Built sources are automatically removed by maintainer-clean.
3697 push (@maintainer_clean_files, '$(BUILT_SOURCES')
3698 if &variable_defined ('BUILT_SOURCES');
3699 push (@maintainer_clean_files, '$(MAINTAINERCLEANFILES)')
3700 if &variable_defined ('MAINTAINERCLEANFILES');
3701 if (! @maintainer_clean_files)
3703 $xform .= 's/^MAINTAINERCLEAN.*$//;';
3707 $xform .= ('s/^MAINTAINERCLEAN//;'
3708 # Join with no space to avoid spurious `test -z'
3709 # success at runtime.
3710 . 's,\@MCFILES\@,' . join ('', @maintainer_clean_files)
3712 # A space is required in the join here.
3713 . 's,\@MFILES\@,' . join (' ', @maintainer_clean_files)
3717 $output_rules .= &file_contents_with_transform ($xform, 'clean');
3719 push (@clean, 'generic');
3720 &push_phony_cleaners ('generic');
3722 local ($target) = $recursive_install ? 'clean-am' : 'clean';
3723 &do_one_clean_target ($target, 'mostly', '', @clean);
3724 &do_one_clean_target ($target, '', 'mostly', @clean);
3725 &do_one_clean_target ($target, 'dist', '', @clean);
3726 &do_one_clean_target ($target, 'maintainer-', 'dist', @clean);
3728 push (@phony, 'clean', 'mostlyclean', 'distclean', 'maintainer-clean');
3731 if ($recursive_install)
3733 # Do -recursive before -am. If you aren't doing a parallel
3734 # make, this can be nicer.
3735 @deps = ('recursive', 'am');
3736 &do_one_clean_target ('', 'mostly', '', @deps);
3737 &do_one_clean_target ('', '', '', @deps);
3738 &do_one_clean_target ('', 'dist', '', @deps);
3739 &do_one_clean_target ('', 'maintainer-', '', @deps);
3743 # Helper for handle_clean.
3744 sub do_one_clean_target
3746 local ($target, $name, $last_name, @deps) = @_;
3748 # Special case: if target not passed, then don't generate
3749 # dependency on next "lower" clean target (eg no
3750 # clean<-mostlyclean derivation). In this case the target is
3751 # implicitly known to be 'clean'.
3752 local ($flag) = $target;
3753 $target = 'clean' if ! $flag;
3755 grep (($_ = $name . 'clean-' . $_) && 0, @deps);
3758 if ($last_name || $name ne 'mostly')
3760 push (@deps, $last_name . $target);
3764 # If a -local version of the rule is given, add it to the list.
3765 if (defined $contents{$name . $target . '-local'})
3767 push (@deps, $name . $target . '-local');
3770 # Print the target and the dependencies.
3771 &pretty_print_rule ($name . $target . ": ", "\t\t", @deps);
3773 # FIXME: shouldn't we really print these messages before running
3775 if ($name . $target eq 'maintainer-clean')
3777 # Print a special warning.
3779 ("\t\@echo \"This command is intended for maintainers to use;\"\n"
3780 . "\t\@echo \"it deletes files that may require special "
3781 . "tools to rebuild.\"\n");
3783 $output_rules .= "\t-rm -f config.status\n"
3784 if $relative_dir eq '.';
3786 elsif ($name . $target eq 'distclean')
3788 $output_rules .= "\t-rm -f config.status\n";
3789 $output_rules .= "\t-rm -f libtool\n" if $seen_libtool;
3791 $output_rules .= "\n";
3794 # Handle .PHONY target.
3797 &pretty_print_rule ('.PHONY:', "", @phony);
3798 $output_rules .= "\n";
3801 # Handle TESTS variable and other checks.
3804 if (defined $options{'dejagnu'})
3806 push (@check_tests, 'check-DEJAGNU');
3807 push (@phony, 'check-DEJAGNU');
3812 $xform = 's/^CYGNUS//;';
3816 $xform = 's/^CYGNUS.*$//;';
3818 $output_rules .= &file_contents_with_transform ($xform, 'dejagnu');
3820 # In Cygnus mode, these are found in the build tree.
3821 # Otherwise they are looked for in $PATH.
3822 &define_program_variable ('EXPECT', 'build', 'expect', 'expect');
3823 &define_program_variable ('RUNTEST', 'src', 'dejagnu', 'runtest');
3825 # Note that in the rule we don't directly generate site.exp to
3826 # avoid the possibility of a corrupted site.exp if make is
3827 # interrupted. Jim Meyering has some useful text on this
3829 $output_rules .= ("site.exp: Makefile\n"
3830 . "\t\@echo 'Making a new site.exp file...'\n"
3831 . "\t-\@rm -f site.bak\n"
3832 . "\t\@echo '## these variables are automatically generated by make ##' > \$\@-t\n"
3833 . "\t\@echo '# Do not edit here. If you wish to override these values' >> \$\@-t\n"
3834 . "\t\@echo '# edit the last section' >> \$\@-t\n"
3835 . "\t\@echo 'set tool \$(DEJATOOL)' >> \$\@-t\n"
3836 . "\t\@echo 'set srcdir \$(srcdir)' >> \$\@-t\n"
3837 . "\t\@echo 'set objdir' \`pwd\` >> \$\@-t\n");
3839 # Extra stuff for AC_CANONICAL_*
3840 local (@whatlist) = ();
3841 if ($seen_canonical)
3843 push (@whatlist, 'host')
3846 # Extra stuff only for AC_CANONICAL_SYSTEM.
3847 if ($seen_canonical == $AC_CANONICAL_SYSTEM)
3849 push (@whatlist, 'target', 'build');
3853 foreach $c1 (@whatlist)
3855 foreach $c2 ('alias', 'triplet')
3857 $output_rules .= "\t\@echo 'set ${c1}_${c2} \$(${c1}_${c2})' >> \$\@-t\n";
3861 $output_rules .= ("\t\@echo '## All variables above are generated by configure. Do Not Edit ##' >> \$\@-t\n"
3862 . "\t-\@sed '1,/^## All variables above are.*##/ d' site.bak >> \$\@-t\n"
3863 . "\t-\@mv site.exp site.bak\n"
3864 . "\t\@mv \$\@-t site.exp\n");
3869 foreach $c ('DEJATOOL', 'RUNTEST', 'RUNTESTFLAGS')
3871 if (&variable_defined ($c))
3873 &am_line_error ($c, "\`$c' defined but \`dejagnu' not in \`AUTOMAKE_OPTIONS'");
3878 if (&variable_defined ('TESTS'))
3880 push (@check_tests, 'check-TESTS');
3881 push (@phony, 'check-TESTS');
3883 $output_rules .= 'check-TESTS: $(TESTS)
3884 @failed=0; all=0; \\
3885 srcdir=$(srcdir); export srcdir; \\
3886 for tst in $(TESTS); do \\
3887 if test -f $$tst; then dir=.; \\
3888 else dir="$(srcdir)"; fi; \\
3889 if $(TESTS_ENVIRONMENT) $$dir/$$tst; then \\
3890 all=`expr $$all + 1`; \\
3891 echo "PASS: $$tst"; \\
3892 elif test $$? -ne 77; then \\
3893 all=`expr $$all + 1`; \\
3894 failed=`expr $$failed + 1`; \\
3895 echo "FAIL: $$tst"; \\
3898 if test "$$failed" -eq 0; then \\
3899 banner="All $$all tests passed"; \\
3901 banner="$$failed of $$all tests failed"; \\
3903 dashes=`echo "$$banner" | sed s/./=/g`; \\
3907 test "$$failed" -eq 0
3912 # Handle Emacs Lisp.
3913 sub handle_emacs_lisp
3915 local (@elfiles) = &am_install_var ('lisp', 'LISP', 'lisp', 'noinst');
3920 &define_configure_variable ('lispdir');
3921 &define_configure_variable ('EMACS');
3922 $output_rules .= (".el.elc:\n"
3923 . "\t\@echo 'WARNING: Warnings can be ignored. :-)'\n"
3924 . "\tif test \$(EMACS) != no; then \\\n"
3925 . "\t EMACS=\$(EMACS) \$(SHELL) \$(srcdir)/elisp-comp \$<; \\\n"
3927 push (@suffixes, '.el', '.elc');
3929 # Generate .elc files.
3930 grep ($_ .= 'c', @elfiles);
3931 &define_pretty_variable ('ELCFILES', '', @elfiles);
3933 $output_rules .= &file_contents ('lisp-clean');
3934 push (@clean, 'lisp');
3935 &push_phony_cleaners ('lisp');
3937 push (@all, '$(ELCFILES)');
3940 if (&variable_defined ('lisp_LISP'))
3942 $varname = 'lisp_LISP';
3943 &am_error ("\`lisp_LISP' defined but \`AM_PATH_LISPDIR' not in \`configure.in'")
3948 $varname = 'noinst_LISP';
3951 &require_file_with_line ($varname, $FOREIGN, 'elisp-comp');
3958 local (@sourcelist) = &am_install_var ('-clean', 'java', 'JAVA',
3959 'java', 'noinst', 'check');
3960 return if ! @sourcelist;
3962 &define_variable ('JAVAC', 'javac');
3963 &define_variable ('JAVACFLAGS', '');
3964 &define_variable ('CLASSPATH_ENV',
3965 'CLASSPATH=$(JAVAROOT):$(srcdir)/$(JAVAROOT):$$CLASSPATH');
3966 &define_variable ('JAVAROOT', '$(top_builddir)');
3968 local (%valid) = &am_primary_prefixes ('JAVA', 'java', 'noinst', 'check');
3970 local ($dir, $curs);
3971 foreach $curs (keys %valid)
3973 if (! &variable_defined ($curs . '_JAVA') || $curs eq 'noinst'
3974 || $curs eq 'EXTRA')
3981 print STDERR "got $curs\n";
3982 &am_line_error ($curs . '_JAVA',
3983 "multiple _JAVA primaries in use");
3988 $output_rules .= ('class' . $dir . '.stamp: $(' . $dir . '_JAVA)' . "\n"
3989 . "\t" . '$(CLASSPATH_ENV) $(JAVAC) -d $(JAVAROOT) '
3990 . '$(JAVACFLAGS) $?' . "\n"
3991 . "\t" . 'echo timestamp > class' . $dir . '.stamp'
3993 push (@all, 'class' . $dir . '.stamp');
3994 &push_dist_common ('$(' . $dir . '_JAVA)');
3997 # Handle some of the minor options.
3998 sub handle_minor_options
4000 if (defined $options{'readme-alpha'})
4002 if ($relative_dir eq '.')
4004 if ($package_version !~ /^$GNITS_VERSION_PATTERN$/)
4006 # FIXME: allow real filename.
4007 &am_conf_line_error ('configure.in',
4008 $package_version_line,
4009 "version \`$package_version' doesn't follow Gnits standards");
4011 elsif (defined $1 && -f 'README-alpha')
4013 # This means we have an alpha release. See
4014 # GNITS_VERSION_PATTERN for details.
4015 &require_file ($FOREIGN, 'README-alpha');
4021 ################################################################
4023 # Scan one file for interesting things. Subroutine of scan_configure.
4024 sub scan_one_configure_file
4026 local ($filename) = @_;
4028 open (CONFIGURE, $filename)
4029 || die "automake: couldn't open \`$filename': $!\n";
4030 print "automake: reading $filename\n" if $verbose;
4034 # Remove comments from current line.
4038 # Skip macro definitions. Otherwise we might be confused into
4039 # thinking that a macro that was only defined was actually
4043 # Follow includes. This is a weirdness commonly in use at
4044 # Cygnus and hopefully nowhere else.
4045 if (/sinclude\((.*)\)/ && -f $1)
4047 &scan_one_configure_file ($1);
4050 # Populate libobjs array.
4051 if (/AC_FUNC_ALLOCA/)
4053 $libsources{'alloca.c'} = 1;
4055 elsif (/AC_FUNC_GETLOADAVG/)
4057 $libsources{'getloadavg.c'} = 1;
4059 elsif (/AC_FUNC_MEMCMP/)
4061 $libsources{'memcmp.c'} = 1;
4063 elsif (/AC_STRUCT_ST_BLOCKS/)
4065 $libsources{'fileblocks.c'} = 1;
4067 elsif (/A[CM]_REPLACE_GNU_GETOPT/)
4069 $libsources{'getopt.c'} = 1;
4070 $libsources{'getopt1.c'} = 1;
4072 elsif (/AM_FUNC_STRTOD/)
4074 $libsources{'strtod.c'} = 1;
4076 elsif (/AM_WITH_REGEX/)
4078 $libsources{'rx.c'} = 1;
4079 $libsources{'rx.h'} = 1;
4080 $libsources{'regex.c'} = 1;
4081 $libsources{'regex.h'} = 1;
4082 $omit_dependencies{'rx.h'} = 1;
4083 $omit_dependencies{'regex.h'} = 1;
4085 elsif (/AM_FUNC_MKTIME/)
4087 $libsources{'mktime.c'} = 1;
4089 elsif (/AM_FUNC_ERROR_AT_LINE/)
4091 $libsources{'error.c'} = 1;
4092 $libsources{'error.h'} = 1;
4094 elsif (/AM_FUNC_OBSTACK/)
4096 $libsources{'obstack.c'} = 1;
4097 $libsources{'obstack.h'} = 1;
4099 elsif (/LIBOBJS="(.*)\s+\$LIBOBJS"/
4100 || /LIBOBJS="\$LIBOBJS\s+(.*)"/)
4102 foreach $libobj_iter (split (' ', $1))
4104 if ($libobj_iter =~ /^(.*)\.o$/)
4106 $libsources{$1 . '.c'} = 1;
4111 if (! $in_ac_replace && s/AC_REPLACE_FUNCS\s*\(\[?//)
4117 $in_ac_replace = 0 if s/[\]\)].*$//;
4118 # Remove trailing backslash.
4122 # Need to skip empty elements for Perl 4.
4124 $libsources{$_ . '.c'} = 1;
4128 if (/$obsolete_rx/o)
4131 if ($obsolete_macros{$1})
4133 $hint = '; ' . $obsolete_macros{$1};
4135 &am_conf_line_error ($filename, $., "\`$1' is obsolete$hint");
4138 # Process the AC_OUTPUT macro.
4139 if (! $in_ac_output && s/AC_OUTPUT\s*\(\[?//)
4142 $ac_output_line = $.;
4146 local ($closing) = 0;
4153 # Look at potential Makefile.am's.
4156 # Must skip empty string for Perl 4.
4157 next if $_ eq "\\" || $_ eq '';
4159 # Handle $local:$input syntax. Note that we ignore
4160 # every input file past the first, though we keep
4161 # those around for later.
4162 local ($local, $input, @rest) = split (/:/);
4169 # FIXME: should be error if .in is missing.
4170 $input =~ s/\.in$//;
4173 if (-f $input . '.am')
4175 # We have a file that automake should generate.
4176 push (@make_input_list, $input);
4177 $make_list{$input} = join (':', ($local, @rest));
4181 # We have a file that automake should cause to be
4182 # rebuilt, but shouldn't generate itself.
4183 push (@other_input_files, $_);
4187 if ($closing && @make_input_list == 0 && @other_input_files == 0)
4189 &am_conf_line_error ($filename, $ac_output_line,
4190 "No files mentioned in \`AC_OUTPUT'");
4195 if (/$AC_CONFIG_AUX_DIR_PATTERN/o)
4197 @config_aux_path = $1;
4200 # Check for ansi2knr.
4201 $am_c_prototypes = 1 if /AM_C_PROTOTYPES/;
4203 # Check for exe extension stuff.
4207 $configure_vars{'EXEEXT'} = 1;
4210 # Check for NLS support.
4211 if (/AM_GNU_GETTEXT/)
4214 $ac_gettext_line = $.;
4215 $omit_dependencies{'libintl.h'} = 1;
4218 # Look for ALL_LINGUAS.
4219 if (/ALL_LINGUAS="(.*)"$/ || /ALL_LINGUAS=(.*)$/)
4223 $all_linguas_line = $.;
4226 # Handle configuration headers. A config header of `[$1]'
4227 # means we are actually scanning AM_CONFIG_HEADER from
4229 if (/A([CM])_CONFIG_HEADER\s*\((.*)\)/
4234 "\`AC_CONFIG_HEADER' is obsolete; use \`AM_CONFIG_HEADER'")
4237 $config_header_line = $.;
4239 foreach $one_hdr (split (' ', $2))
4241 push (@config_fullnames, $one_hdr);
4242 if ($one_hdr =~ /^([^:]+):(.+)$/)
4244 push (@config_names, $1);
4245 push (@config_headers, $2);
4249 push (@config_names, $one_hdr);
4250 push (@config_headers, $one_hdr . '.in');
4255 # Handle AC_CANONICAL_*. Always allow upgrading to
4256 # AC_CANONICAL_SYSTEM, but never downgrading.
4257 $seen_canonical = $AC_CANONICAL_HOST
4258 if ! $seen_canonical
4259 && (/AC_CANONICAL_HOST/ || /AC_CHECK_TOOL/);
4260 $seen_canonical = $AC_CANONICAL_SYSTEM if /AC_CANONICAL_SYSTEM/;
4262 $seen_path_xtra = 1 if /AC_PATH_XTRA/;
4264 # This macro handles several different things.
4265 if (/$AM_INIT_AUTOMAKE_PATTERN/o)
4271 $seen_prog_install = 2;
4272 ($package_version = $1) =~ s/$AM_PACKAGE_VERSION_PATTERN/$1/o;
4273 $package_version_line = $.;
4276 # This is like AM_INIT_AUTOMAKE, but doesn't actually set the
4277 # package and version number. (This might change in the
4278 # future). Yes, I'm not above hacking Automake so it works
4279 # well with other GNU tools -- that is actually the point.
4280 if (/AM_INIT_GUILE_MODULE/)
4286 $seen_prog_install = 2;
4287 @config_aux_path = ('..');
4290 # Some things required by Automake.
4291 $seen_make_set = 1 if /AC_PROG_MAKE_SET/;
4292 $seen_arg_prog = 1 if /AC_ARG_PROGRAM/;
4296 $configure_vars{'LEX'} = 1;
4297 $seen_decl_yytext = 1;
4299 if (/AC_DECL_YYTEXT/ && $filename =~ /configure\.in$/)
4301 &am_conf_line_warning ($filename, $.,
4302 "\`AC_DECL_YYTEXT' is obsolete; use \`AM_PROG_LEX'");
4304 if (/AC_PROG_LEX/ && $filename =~ /configure\.in$/)
4306 &am_conf_line_warning ($filename, $.,
4307 "\`AC_PROG_LEX' is obsolete; use \`AM_PROG_LEX'");
4310 if (/AC_PROG_(YACC|RANLIB|CC|CXXCPP|CXX|LEX|AWK|CPP|LN_S)/)
4312 $configure_vars{$1} = 1;
4314 if (/$AC_CHECK_PATTERN/o)
4316 $configure_vars{$3} = 1;
4318 if (/$AM_MISSING_PATTERN/o
4322 && $1 ne 'AUTOHEADER')
4324 $configure_vars{$1} = 1;
4327 # Explicitly avoid ANSI2KNR -- we AC_SUBST that in protos.m4,
4328 # but later define it elsewhere. This is pretty hacky. We
4329 # also explicitly avoid INSTALL_SCRIPT and some other
4330 # variables because they are defined in header-vars.am.
4332 if (/$AC_SUBST_PATTERN/o
4334 && $1 ne 'INSTALL_SCRIPT'
4335 && $1 ne 'INSTALL_DATA')
4337 $configure_vars{$1} = 1;
4340 $seen_decl_yytext = 1 if /AC_DECL_YYTEXT/;
4341 $seen_maint_mode = 1 if /AM_MAINTAINER_MODE/;
4342 $seen_package = 1 if /PACKAGE=/;
4344 # Skip VERSION of [$2]; that is from AM_INIT_AUTOMAKE.
4345 if (/\bVERSION=(\S+)/ && $1 ne '[$2]')
4348 $package_version = $1;
4349 $package_version_line = $.;
4356 # Weird conditionals here because it is always allowed to
4357 # upgrade to AM_PROG_INSTALL but never to downgrade to
4359 $seen_prog_install = 1 if ! $seen_prog_install && /AC_PROG_INSTALL/;
4360 $seen_prog_install = 2 if /AM_PROG_INSTALL/;
4362 $seen_lispdir = 1 if /AM_PATH_LISPDIR/;
4364 if (/AM_PROG_LIBTOOL/)
4368 $configure_vars{'LIBTOOL'} = 1;
4369 $configure_vars{'RANLIB'} = 1;
4370 $configure_vars{'CC'} = 1;
4371 # AM_PROG_LIBTOOL runs AC_CANONICAL_HOST. Make sure we
4372 # never downgrade (if we've seen AC_CANONICAL_SYSTEM).
4373 $seen_canonical = $AC_CANONICAL_HOST if ! $seen_canonical;
4376 if (/$AM_CONDITIONAL_PATTERN/o)
4378 $configure_cond{$1} = 1;
4385 # Scan configure.in and aclocal.m4 for interesting things. We must
4386 # scan aclocal.m4 because there might be AC_SUBSTs and such there.
4389 # Reinitialize libsources here. This isn't really necessary,
4390 # since we currently assume there is only one configure.in. But
4391 # that won't always be the case.
4394 local ($in_ac_output, $in_ac_replace) = (0, 0);
4395 local (%make_list, @make_input_list);
4396 local ($libobj_iter);
4398 &scan_one_configure_file ('configure.in');
4399 &scan_one_configure_file ('aclocal.m4')
4402 # Set input and output files if not specified by user.
4405 @input_files = @make_input_list;
4406 %output_files = %make_list;
4409 &am_conf_error ("\`PACKAGE' not defined in configure.in")
4411 &am_conf_error ("\`VERSION' not defined in configure.in")
4414 # Look for some files we need. Always check for these. This
4415 # check must be done for every run, even those where we are only
4416 # looking at a subdir Makefile. We must set relative_dir so that
4417 # the file-finding machinery works.
4418 local ($relative_dir) = '.';
4419 &require_config_file ($FOREIGN, 'install-sh', 'mkinstalldirs', 'missing');
4420 &am_error ("\`install.sh' is an anachronism; use \`install-sh' instead")
4421 if -f $config_aux_path[0] . '/install.sh';
4424 ################################################################
4426 # Set up for Cygnus mode.
4429 return unless $cygnus_mode;
4431 &set_strictness ('foreign');
4432 $options{'no-installinfo'} = 1;
4433 $options{'no-dependencies'} = 1;
4434 $use_dependencies = 0;
4436 if (! $seen_maint_mode)
4438 &am_conf_error ("\`AM_MAINTAINER_MODE' required when --cygnus specified");
4443 &am_conf_error ("\`AM_EXEEXT' required when --cygnus specified");
4447 # Do any extra checking for GNU standards.
4448 sub check_gnu_standards
4450 if ($relative_dir eq '.')
4452 # In top level (or only) directory.
4453 &require_file ($GNU, 'INSTALL', 'NEWS', 'README', 'COPYING',
4454 'AUTHORS', 'ChangeLog');
4457 if ($strictness >= $GNU)
4459 if (defined $options{'no-installman'})
4461 &am_line_error ('AUTOMAKE_OPTIONS',
4462 "option \`no-installman' disallowed by GNU standards");
4465 if (defined $options{'no-installinfo'})
4467 &am_line_error ('AUTOMAKE_OPTIONS',
4468 "option \`no-installinfo' disallowed by GNU standards");
4473 # Do any extra checking for GNITS standards.
4474 sub check_gnits_standards
4476 if ($strictness >= $GNITS)
4478 if (-f $relative_dir . '/COPYING.LIB')
4480 &am_error ("\`${relative_dir}/COPYING.LIB' disallowed by Gnits standards");
4484 if ($relative_dir eq '.')
4486 # In top level (or only) directory.
4487 &require_file ($GNITS, 'THANKS');
4491 ################################################################
4493 # Pretty-print something. HEAD is what should be printed at the
4494 # beginning of the first line, FILL is what should be printed at the
4495 # beginning of every subsequent line.
4496 sub pretty_print_internal
4498 local ($head, $fill, @values) = @_;
4500 local ($column) = length ($head);
4501 local ($result) = $head;
4503 # Fill length is number of characters. However, each Tab
4504 # character counts for eight. So we count the number of Tabs and
4506 local ($fill_length) = length ($fill);
4507 $fill_length += 7 * ($fill =~ tr/\t/\t/d);
4509 local ($bol) = ($head eq '');
4512 # "71" because we also print a space.
4513 if ($column + length ($_) > 71)
4515 $result .= " \\\n" . $fill;
4516 $column = $fill_length;
4520 $result .= ' ' unless ($bol);
4522 $column += length ($_) + 1;
4530 # Pretty-print something and append to output_vars.
4533 $output_vars .= &pretty_print_internal (@_);
4536 # Pretty-print something and append to output_rules.
4537 sub pretty_print_rule
4539 $output_rules .= &pretty_print_internal (@_);
4543 ################################################################
4545 # See if a target exists.
4548 local ($target) = @_;
4549 return defined $targets{$target};
4552 # See if two conditionals are the same.
4553 sub conditional_same
4555 local ($cond1, $cond2) = @_;
4557 return (&conditional_true_when ($cond1, $cond2)
4558 && &conditional_true_when ($cond2, $cond1));
4561 # See if a conditional is true. Both arguments are conditional
4562 # strings. This returns true if the first conditional is true when
4563 # the second conditional is true.
4564 sub conditional_true_when
4566 local ($cond, $when) = @_;
4568 # Check the easy case first.
4574 # Check each component of $cond, which looks @COND1@@COND2@.
4575 foreach $comp (split ('@', $cond))
4577 # The way we split will give null strings between each
4581 if (index ($when, '@' . $comp . '@') == -1)
4590 # Check for an ambiguous conditional. This is called when a variable
4591 # or target is being defined conditionally. If we already know about
4592 # a definition that is true under the same conditions, then we have an
4594 sub check_ambiguous_conditional
4596 local ($var_name, $cond) = @_;
4597 local (@cond_vals) = split (' ', $conditional{$var_name});
4600 local ($vcond) = shift (@cond_vals);
4602 if (&conditional_true_when ($vcond, $cond)
4603 || &conditional_true_when ($cond, $vcond))
4605 &am_line_error ($var_name,
4606 "$var_name multiply defined in condition");
4611 # See if a variable exists. The first argument is the variable name,
4612 # and the optional second argument is the condition which we should
4613 # check. If no condition is given, we currently return true if the
4614 # variable is defined under any condition.
4615 sub variable_defined
4617 local ($var, $cond) = @_;
4618 if (defined $targets{$var})
4620 &am_line_error ($var, "\`$var' is target; expected variable");
4623 elsif (defined $contents{$var})
4625 if ($cond && $conditional{$var})
4627 # We have been asked to check for a particular condition,
4628 # and the variable is defined conditionally. We need to
4629 # look through the conditions under which the variable is
4630 # defined, and see if any of them match the conditional we
4631 # have been asked to check.
4632 local (@cond_vars) = split (' ', $conditional{$var});
4635 if (&conditional_same ($cond, shift (@cond_vars)))
4637 # Even a conditional examination is good enough
4638 # for us. FIXME: really should maintain examined
4639 # status on a per-condition basis.
4640 $content_seen{$var} = 1;
4646 # The variable is not defined for the given condition.
4650 $content_seen{$var} = 1;
4656 # Mark a variable as examined.
4657 sub examine_variable
4660 &variable_defined ($var);
4663 # Quote a value in order to put it in $conditional. We need to quote
4664 # spaces, and we need to handle null strings, so that we can later
4665 # retrieve values by splitting on space.
4670 $val = '\002' if $val eq '';
4674 # Unquote a value in $conditional.
4675 sub unquote_cond_val
4679 $val = '' if $val eq '\002';
4683 # Return the set of conditions for which a variable is defined.
4685 # If the variable is not defined conditionally, and is not defined in
4686 # terms of any variables which are defined conditionally, then this
4687 # returns the empty list.
4689 # If the variable is defined conditionally, but is not defined in
4690 # terms of any variables which are defined conditionally, then this
4691 # returns the list of conditions for which the variable is defined.
4693 # If the variable is defined in terms of any variables which are
4694 # defined conditionally, then this returns a full set of permutations
4695 # of the subvariable conditions. For example, if the variable is
4696 # defined in terms of a variable which is defined for @COND_TRUE@,
4697 # then this returns both @COND_TRUE@ and @COND_FALSE@. This is
4698 # because we will need to define the variable under both conditions.
4700 sub variable_conditions
4706 foreach $cond (&variable_conditions_sub ($var, '', ()))
4708 $uniqify{$cond} = 1;
4711 return keys %uniqify;
4714 # A subroutine of variable_conditions. We only return conditions
4715 # which are true for all the conditions in @PARENT_CONDS.
4716 sub variable_conditions_sub
4718 local ($var, $parent, @parent_conds) = @_;
4719 local (@new_conds) = ();
4721 if (! $conditional{$var})
4723 foreach (split (' ', $contents{$var}))
4725 # If a comment seen, just leave.
4728 # Handle variable substitutions.
4729 if (/^\$\{(.*)\}$/ || /^\$\((.*)\)$/)
4732 &variable_conditions_sub ($1, $var, @parent_conds));
4736 return &variable_conditions_reduce (@new_conds);
4739 local (@this_conds) = ();
4740 local (@condvals) = split (' ', $conditional{$var});
4743 local ($cond) = shift (@condvals);
4744 local ($val) = &unquote_cond_val (shift (@condvals));
4749 local ($parent_cond);
4750 foreach $parent_cond (@parent_conds)
4752 if (! &conditional_true_when ($parent_cond, $cond))
4762 push (@this_conds, $cond);
4764 push (@parent_conds, $cond);
4765 local (@subvar_conds) = ();
4766 foreach (split (' ', $val))
4768 # If a comment seen, just leave.
4771 # Handle variable substitutions.
4772 if (/^\$\{(.*)\}$/ || /^\$\((.*)\)$/)
4774 push (@subvar_conds,
4775 &variable_conditions_sub ($1, $var, @parent_conds));
4778 pop (@parent_conds);
4780 # If there are no conditional subvariables, then we want to
4781 # return this condition. Otherwise, we want to return the
4782 # permutations of the subvariables.
4783 if (! @subvar_conds)
4785 push (@new_conds, $cond);
4789 push (@new_conds, &variable_conditions_reduce (@subvar_conds));
4796 # If we are being called on behalf of another variable, we need to
4797 # return all possible permutations of the conditions. We have
4798 # already handled everything in @this_conds along with their
4799 # subvariables. We now need to add any permutations that are not
4802 foreach $this_cond (@this_conds)
4805 &variable_conditions_permutations (split('@', $this_cond));
4807 foreach $perm (@perms)
4811 foreach $scan (@this_conds)
4813 if (&conditional_true_when ($perm, $scan)
4814 || &conditional_true_when ($scan, $perm))
4825 local ($parent_cond);
4826 foreach $parent_cond (@parent_conds)
4828 if (! &conditional_true_when ($parent_cond, $perm))
4838 # This permutation was not already handled, and is valid
4840 push (@new_conds, $perm);
4847 # Subroutine for variable_conditions_sort
4848 sub variable_conditions_cmp
4854 return (length ($as) <=> length ($bs)
4858 # Sort a list of conditionals so that only the exclusive ones are
4859 # retained. For example, if both @COND1_TRUE@@COND2_TRUE@ and
4860 # @COND1_TRUE@ are in the list, discard the latter.
4861 sub variable_conditions_reduce
4863 local (@conds) = @_;
4866 foreach $cond (sort variable_conditions_cmp @conds)
4870 foreach $scan (@ret)
4872 if (&conditional_true_when ($cond, $scan))
4885 # Return a list of permutations of a conditional string.
4886 sub variable_conditions_permutations
4888 local (@comps) = @_;
4891 local ($comp) = shift (@comps);
4892 return &variable_conditions_permutations (@comps)
4894 local ($neg) = $comp;
4895 $neg =~ s/TRUE$/TRUEO/;
4896 $neg =~ s/FALSE$/TRUE/;
4897 $neg =~ s/TRUEO$/FALSE/;
4900 foreach $sub (&variable_conditions_permutations (@comps))
4902 push (@ret, '@' . $comp . '@' . $sub);
4903 push (@ret, '@' . $neg . '@' . $sub);
4907 push (@ret, '@' . $comp . '@');
4908 push (@ret, '@' . $neg . '@');
4913 # Warn if a variable is conditionally defined. This is called if we
4914 # are using the value of a variable.
4915 sub variable_conditionally_defined
4917 local ($var, $parent) = @_;
4918 if ($conditional{$var})
4922 &am_line_error ($parent,
4923 "warning: automake does not support conditional definition of $var in $parent");
4927 &am_line_error ($parent,
4928 "warning: automake does not support $var being defined conditionally")
4933 # Get the value of a variable. This just returns $contents, but warns
4934 # if the variable is conditionally defined.
4938 &variable_conditionally_defined ($var);
4939 return $contents{$var};
4942 # Convert a variable value to a list, split as whitespace. This will
4943 # recursively follow $(...) and ${...} inclusions. It preserves @...@
4944 # substitutions. If COND is 'all', then all values under all
4945 # conditions should be returned; if COND is a particular condition
4946 # (all conditions are surrounded by @...@) then only the value for
4947 # that condition should be returned; otherwise, warn if VAR is
4948 # conditionally defined.
4951 local ($var, $val, $cond) = @_;
4954 foreach (split (' ', $val))
4956 # If a comment seen, just leave.
4959 # Handle variable substitutions.
4960 if (/^\$\{([^}]*)\}$/ || /^\$\(([^)]*)\)$/)
4962 local ($varname) = $1;
4964 # If the user uses a losing variable name, just ignore it.
4965 # This isn't ideal, but people have requested it.
4966 next if ($varname =~ /\@.*\@/);
4970 if ($varname =~ /^([^:]*):([^=]*)=(.*)$/)
4974 ($from = $2) =~ s/(\W)/\\$1/g;
4978 @temp_list = &variable_value_as_list ($1, $cond, $var);
4980 # Now rewrite the value if appropriate.
4983 grep (s/$from$/$to/, @temp_list);
4986 push (@result, @temp_list);
4997 # Return contents of variable as list, split as whitespace. This will
4998 # recursively follow $(...) and ${...} inclusions. It preserves @...@
4999 # substitutions. If COND is 'all', then all values under all
5000 # conditions should be returned; if COND is a particular condition
5001 # (all conditions are surrounded by @...@) then only the value for
5002 # that condition should be returned; otherwise, warn if VAR is
5003 # conditionally defined. If PARENT is specified, it is the name of
5004 # the including variable; this is only used for error reports.
5005 sub variable_value_as_list
5007 local ($var, $cond, $parent) = @_;
5010 if (defined $targets{$var})
5012 &am_line_error ($var, "\`$var' is target; expected variable");
5014 elsif (! defined $contents{$var})
5016 &am_line_error ($parent, "variable \`$var' not defined");
5018 elsif ($cond eq 'all' && $conditional{$var})
5020 local (@condvals) = split (' ', $conditional{$var});
5024 local ($val) = &unquote_cond_val (shift (@condvals));
5025 push (@result, &value_to_list ($var, $val, $cond));
5028 elsif ($cond && $conditional{$var})
5030 local (@condvals) = split (' ', $conditional{$var});
5034 local ($vcond) = shift (@condvals);
5035 local ($val) = &unquote_cond_val (shift (@condvals));
5036 if (&conditional_true_when ($vcond, $cond))
5038 # Warn if we have an ambiguity. It's hard to know how
5039 # to handle this case correctly.
5040 &variable_conditionally_defined ($var, $parent)
5043 push (@result, &value_to_list ($var, $val, $cond));
5049 &variable_conditionally_defined ($var, $parent);
5050 $content_seen{$var} = 1;
5051 push (@result, &value_to_list ($var, $contents{$var}, $cond));
5057 # Define a new variable, but only if not already defined.
5060 local ($var, $value) = @_;
5062 if (! defined $contents{$var})
5064 $output_vars .= $var . ' = ' . $value . "\n";
5065 $contents{$var} = $value;
5066 $content_seen{$var} = 1;
5070 # Like define_variable, but the value is a list, and the variable may
5071 # be defined conditionally. The second argument is the conditional
5072 # under which the value should be defined; this should be the empty
5073 # string to define the variable unconditionally. The third argument
5074 # is a list holding the values to use for the variable. The value is
5075 # pretty printed in the output file.
5076 sub define_pretty_variable
5078 local ($var, $cond, @value) = @_;
5079 if (! defined $contents{$var}
5080 || ($cond && ! &variable_defined ($var, $cond)))
5082 $contents{$var} = join (' ', @value);
5085 if ($conditional{$var})
5087 $conditional{$var} .= ' ';
5091 $conditional{$var} = '';
5093 $conditional{$var} .= ($cond
5095 . "e_cond_val ($contents{$var}));
5097 &pretty_print ($cond . $var . ' = ', $cond, @value);
5098 $content_seen{$var} = 1;
5102 # Like define_variable, but define a variable to be the configure
5103 # substitution by the same name.
5104 sub define_configure_variable
5107 local ($value) = '@' . $var . '@';
5108 &define_variable ($var, $value);
5111 # Define a variable that represents a program to run. If in Cygnus
5112 # mode, the program is searched for in the build (or source) tree.
5113 # Otherwise no searching is done at all. Arguments are:
5114 # * VAR Name of variable to define
5115 # * WHATDIR Either `src' or `build', depending on where program should
5116 # be found. (runtest is in srcdir!)
5117 # * SUBDIR Subdir of top-level dir
5118 # * PROGRAM Name of program
5119 # * OVERRIDE If specified, the name of the program to use when not in
5120 # Cygnus mode. Defaults to PROGRAM.
5121 sub define_program_variable
5123 local ($var, $whatdir, $subdir, $program, $override) = @_;
5127 $override = $program;
5132 local ($full) = ('$(top_' . $whatdir . 'dir)/../'
5133 . $subdir . '/' . $program);
5134 &define_variable ($var, ('`if test -f ' . $full
5135 . '; then echo ' . $full . '; else echo '
5136 . $program . '; fi`'));
5140 &define_variable ($var, $override);
5145 ################################################################
5147 # Read Makefile.am and set up %contents. Simultaneously copy lines
5148 # from Makefile.am into $output_trailer or $output_vars as
5149 # appropriate. NOTE we put rules in the trailer section. We want
5150 # user rules to come after our generated stuff.
5153 local ($amfile) = @_;
5155 open (AM_FILE, $amfile) || die "automake: couldn't open \`$amfile': $!\n";
5156 print "automake: reading $amfile\n" if $verbose;
5158 $output_vars = ("# $in_file_name generated automatically by automake "
5159 . $VERSION . " from $am_file_name\n");
5161 # Generate copyright for generated Makefile.in.
5162 $output_vars .= $gen_copyright;
5164 local ($saw_bk) = 0;
5165 local ($was_rule) = 0;
5166 local ($spacing) = '';
5167 local ($comment) = '';
5168 local ($last_var_name) = '';
5173 if (/$IGNORE_PATTERN/o)
5175 # Merely delete comments beginning with two hashes.
5177 elsif (/$WHITE_PATTERN/o)
5179 # Stick a single white line before the incoming macro or rule.
5183 elsif (/$COMMENT_PATTERN/o)
5185 # Stick comments before the incoming macro or rule. Make
5186 # sure a blank line preceeds first block of comments.
5187 $spacing = "\n" unless $blank;
5189 $comment .= $spacing . $_;
5198 $output_vars .= $comment . "\n";
5201 local ($am_vars) = '';
5203 local ($is_ok_macro);
5207 unless substr ($_, -1, 1) eq "\n";
5209 $_ =~ s/\@MAINT\@//g
5210 unless $seen_maint_mode;
5212 if (/$IGNORE_PATTERN/o)
5214 # Merely delete comments beginning with two hashes.
5216 elsif (/$WHITE_PATTERN/o)
5218 # Stick a single white line before the incoming macro or rule.
5221 elsif (/$COMMENT_PATTERN/o)
5223 # Stick comments before the incoming macro or rule.
5224 $comment .= $spacing . $_;
5231 $output_trailer .= join ('', @conditional_stack) . $_;
5236 $am_vars .= join ('', @conditional_stack) . $_;
5238 # Chop newline and backslash if this line is
5239 # continued. FIXME: maybe ensure trailing whitespace
5243 $contents{$last_var_name} .= $_;
5244 if (@conditional_stack)
5246 $conditional{$last_var_name} .= "e_cond_val ($_);
5250 elsif (/$IF_PATTERN/o)
5252 &am_line_error ($., "$1 does not appear in AM_CONDITIONAL")
5253 if (! $configure_cond{$1});
5254 push (@conditional_stack, "\@" . $1 . "_TRUE\@");
5256 elsif (/$ELSE_PATTERN/o)
5258 if (! @conditional_stack)
5260 &am_line_error ($., "else without if");
5262 elsif ($conditional_stack[$#conditional_stack] =~ /_FALSE\@$/)
5264 &am_line_error ($., "else after else");
5268 $conditional_stack[$#conditional_stack]
5269 =~ s/_TRUE\@$/_FALSE\@/;
5272 elsif (/$ENDIF_PATTERN/o)
5274 if (! @conditional_stack)
5276 &am_line_error ($., "endif without if");
5280 pop @conditional_stack;
5283 elsif (/$RULE_PATTERN/o)
5287 if (defined $contents{$1}
5288 && (@conditional_stack
5289 ? ! defined $conditional{$1}
5290 : defined $conditional{$1}))
5293 "$1 defined both conditionally and unconditionally");
5295 # Value here doesn't matter; for targets we only note
5299 local ($cond_string) = join ('', @conditional_stack);
5300 if (@conditional_stack)
5302 if ($conditional{$1})
5304 &check_ambiguous_conditional ($1, $cond_string);
5305 $conditional{$1} .= ' ';
5309 $conditional{$1} = '';
5311 $conditional{$1} .= $cond_string . ' 1';
5313 $content_lines{$1} = $.;
5314 $output_trailer .= $comment . $spacing . $cond_string . $_;
5315 $comment = $spacing = '';
5318 # Check the rule for being a suffix rule. If so, store in
5321 local ($source_suffix);
5322 local ($object_suffix);
5324 if (($source_suffix, $object_suffix) = ($1 =~ $SUFFIX_RULE_PATTERN))
5326 $suffix_rules{$source_suffix} = $object_suffix;
5327 print "Sources ending in .$source_suffix become .$object_suffix\n" if $verbose;
5328 $source_suffix_pattern = "(" . join('|', keys %suffix_rules) . ")";
5331 # FIXME: make sure both suffixes are in SUFFIXES? Or set
5332 # SUFFIXES from suffix_rules?
5334 elsif (($is_ok_macro = /$MACRO_PATTERN/o)
5335 || /$BOGUS_MACRO_PATTERN/o)
5337 # Found a macro definition.
5339 $last_var_name = $1;
5340 if (defined $contents{$1}
5341 && (@conditional_stack
5342 ? ! defined $conditional{$1}
5343 : defined $conditional{$1}))
5346 "$1 defined both conditionally and unconditionally");
5348 if ($2 ne '' && substr ($2, -1) eq "\\")
5350 $contents{$last_var_name} = substr ($2, 0, length ($2) - 1);
5354 $contents{$last_var_name} = $2;
5356 local ($cond_string) = join ('', @conditional_stack);
5357 if (@conditional_stack)
5359 if ($conditional{$last_var_name})
5361 &check_ambiguous_conditional ($last_var_name,
5363 $conditional{$last_var_name} .= ' ';
5367 $conditional{$last_var_name} = '';
5369 local ($val) = $contents{$last_var_name};
5370 $conditional{$last_var_name} .= ($cond_string
5372 . "e_cond_val ($val));
5374 $content_lines{$last_var_name} = $.;
5375 $am_vars .= $comment . $spacing . $cond_string . $_;
5376 $comment = $spacing = '';
5380 &am_line_error ($., "bad macro name \`$last_var_name'")
5385 # This isn't an error; it is probably a continued rule.
5386 # In fact, this is what we assume.
5388 $output_trailer .= ($comment . $spacing
5389 . join ('', @conditional_stack) . $_);
5390 $comment = $spacing = '';
5397 $output_trailer .= $comment;
5399 &am_error ("unterminated conditionals: " . join (' ', @conditional_stack))
5400 if (@conditional_stack);
5402 # Compute relative location of the top object directory.
5403 local (@topdir) = ();
5404 foreach (split (/\//, $relative_dir))
5406 next if $_ eq '.' || $_ eq '';
5413 push (@topdir, '..');
5416 @topdir = ('.') if ! @topdir;
5418 $top_builddir = join ('/', @topdir);
5420 ($build_rx = $top_builddir) =~ s/(\W)/\\$1/g;
5421 $output_vars .= &file_contents_with_transform
5422 ('s/\@top_builddir\@/' . $build_rx . '/g;',
5425 # Generate some useful variables when AC_CANONICAL_* used. FIXME:
5426 # this should use generic %configure_vars method.
5427 if ($seen_canonical)
5429 local ($curs, %vars);
5430 $vars{'host_alias'} = 'host_alias';
5431 $vars{'host_triplet'} = 'host';
5432 if ($seen_canonical == $AC_CANONICAL_SYSTEM)
5434 $vars{'build_alias'} = 'build_alias';
5435 $vars{'build_triplet'} = 'build';
5436 $vars{'target_alias'} = 'target_alias';
5437 $vars{'target_triplet'} = 'target';
5439 foreach $curs (sort keys %vars)
5441 $output_vars .= "$curs = \@$vars{$curs}\@\n";
5442 $contents{$curs} = "\@$vars{$curs}\@";
5447 foreach $curs (sort keys %configure_vars)
5449 &define_configure_variable ($curs);
5452 $output_vars .= $am_vars;
5455 ################################################################
5457 sub initialize_global_constants
5459 # Values for AC_CANONICAL_*
5460 $AC_CANONICAL_HOST = 1;
5461 $AC_CANONICAL_SYSTEM = 2;
5463 # Associative array of standard directory names. Entry is TRUE if
5464 # corresponding directory should be installed during
5465 # 'install-exec' phase.
5483 # Commonly found files we look for and automatically include in
5487 "README", "THANKS", "TODO", "NEWS", "COPYING", "COPYING.LIB",
5488 "INSTALL", "ABOUT-NLS", "ChangeLog", "configure", "configure.in",
5489 "config.guess", "config.sub", "AUTHORS", "BACKLOG", "ABOUT-GNU",
5490 "libversion.in", "mdate-sh", "mkinstalldirs", "install-sh",
5491 'texinfo.tex', "ansi2knr.c", "ansi2knr.1", 'elisp-comp',
5492 'ylwrap', 'acinclude.m4', @libtoolize_files,
5496 # Commonly used files we auto-include, but only sometimes.
5499 "aclocal.m4", "acconfig.h", "config.h.top",
5500 "config.h.bot", "stamp-h.in", 'stamp-vti'
5504 -a, --add-missing add missing standard files to package
5505 --amdir=DIR directory storing config files
5506 --build-dir=DIR directory where build being done (for dependencies)
5507 --cygnus assume program is part of Cygnus-style tree
5508 --foreign set strictness to foreign
5509 --gnits set strictness to gnits
5510 --gnu set strictness to gnu
5511 --help print this help, then exit
5512 -i, --include-deps include generated dependencies in Makefile.in
5513 --no-force only update Makefile.in's that are out of date
5514 -o DIR, --output-dir=DIR
5515 put generated Makefile.in's into DIR
5516 --srcdir-name=DIR name used for srcdir (for dependencies)
5517 -v, --verbose verbosely list files processed
5518 --version print version number, then exit\n";
5520 # Copyright on generated Makefile.ins.
5522 # Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
5523 # This Makefile.in is free software; the Free Software Foundation
5524 # gives unlimited permission to copy and/or distribute it,
5525 # with or without modifications, as long as this notice is preserved.
5527 # This program is distributed in the hope that it will be useful,
5528 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
5529 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
5530 # PARTICULAR PURPOSE.
5533 # Ignore return result from chmod, because it might give an error
5534 # if we chmod a symlink.
5535 $dist_header = "\t" . '-chmod -R a+r $(distdir)' . "\n";
5536 $dist{'dist-tarZ'} = ("\t"
5537 . '$(TAR) chf - $(distdir) | compress -c > $(distdir).tar.Z'
5539 $dist{'dist-shar'} = ("\t"
5540 . 'shar $(distdir) | gzip > $(distdir).shar.gz'
5542 $dist{'dist-zip'} = "\t" . 'zip -rq $(distdir).zip $(distdir)' . "\n";
5543 $dist{'dist'} = "\t" . 'GZIP=$(GZIP) $(TAR) chozf $(distdir).tar.gz $(distdir)' . "\n";
5544 $dist_trailer = "\t" . '-rm -rf $(distdir)' . "\n";
5547 # (Re)-Initialize per-Makefile.am variables.
5548 sub initialize_per_input
5550 # These two variables are used when generating each Makefile.in.
5551 # They hold the Makefile.in until it is ready to be printed.
5554 $output_trailer = '';
5556 $output_header = '';
5558 # Suffixes found during a run.
5561 # This holds the contents of a Makefile.am, as parsed by
5565 # This holds the names which are targets. These also appear in
5569 # For a variable or target which is defined conditionally, this
5570 # holds an array of the conditional values. The array is composed
5571 # of pairs of condition strings (the variables which configure
5572 # will substitute) and values (the value of a target is
5573 # meaningless). For an unconditional variable, this is empty.
5576 # This holds the line numbers at which various elements of
5577 # %contents are defined.
5578 %content_lines = ();
5580 # This holds a 1 if a particular variable was examined.
5583 # This is the conditional stack.
5584 @conditional_stack = ();
5586 # This holds the "relative directory" of the current Makefile.in.
5587 # Eg for src/Makefile.in, this is "src".
5590 # This holds a list of files that are included in the
5594 # List of dependencies for the obvious targets.
5610 # A list of files deleted by `maintainer-clean'.
5611 @maintainer_clean_files = ();
5613 # These are pretty obvious, too. They are used to define the
5614 # SOURCES and OBJECTS variables.
5618 # TRUE if current directory holds any C source files.
5619 $dir_holds_sources = 0;
5621 # These variables track inclusion of various compile-related .am
5622 # files. $included_generic_compile is TRUE if the basic code has
5623 # been included. $included_knr_compile is TRUE if the ansi2knr
5624 # code has been included. $included_libtool_compile is TRUE if
5625 # libtool support has been included.
5626 $included_generic_compile = 0;
5627 $included_knr_compile = 0;
5628 $included_libtool_compile = 0;
5630 # TRUE if current directory holds any headers.
5631 $dir_holds_headers = 0;
5633 # TRUE if install targets should work recursively.
5634 $recursive_install = 0;
5639 # Strictness levels.
5640 $strictness = $default_strictness;
5641 $strictness_name = $default_strictness_name;
5643 # Options from AUTOMAKE_OPTIONS.
5646 # Whether or not dependencies are handled. Can be further changed
5647 # in handle_options.
5648 $use_dependencies = $cmdline_use_dependencies;
5651 $local_maint_charset = $maint_charset;
5653 # All yacc and lex source filenames for this directory. Use
5654 # filenames instead of raw count so that multiple instances are
5655 # counted correctly (eg one yacc file can appear in multiple
5656 # programs without harm).
5660 # C++ source extensions we've seen.
5661 %cxx_extensions = ();
5663 # TRUE if we've seen any non-C++ sources. This actually holds a
5664 # line number or the name of a symbol corresponding to a line
5665 # number where the C sources were seen. If it is -1 then it means
5666 # we couldn't (easily) figure out which line of the Makefile.am
5667 # mentioned the sources.
5670 # TRUE if we've seen any sources at all.
5671 $seen_any_source = 0;
5673 # This is a list of all targets to run during "make dist".
5676 # Keys in this hash are the basenames of files which must depend
5678 %de_ansi_files = ();
5680 # This maps the source extension of a suffix rule to its
5681 # corresponding output extension.
5686 ################################################################
5688 # Return contents of a file from $am_dir, automatically skipping
5689 # macros or rules which are already known. Runs command on each line
5690 # as it is read; this command can modify $_.
5691 sub file_contents_with_transform
5693 local ($command, $basename) = @_;
5694 local ($file) = $am_dir . '/' . $basename . '.am';
5696 if ($command ne '' && substr ($command, -1) ne ';')
5698 die "automake: programming error in file_contents_with_transform: $command\n";
5701 open (FC_FILE, $file)
5702 || die "automake: installation error: cannot open \`$file'\n";
5704 # print "automake: reading $file\n" if $verbose;
5706 local ($was_rule) = 0;
5707 local ($result_vars) = '';
5708 local ($result_rules) = '';
5709 local ($comment) = '';
5710 local ($spacing) = "\n";
5711 local ($skipping) = 0;
5716 $_ =~ s/\@MAINT\@//g
5717 unless $seen_maint_mode;
5719 $had_chars = length ($_) && $_ ne "\n";
5721 # If the transform caused all the characters to go away, then
5722 # ignore the line. Why do this? Because in Perl 4, a "next"
5723 # inside of an eval doesn't affect a loop outside the eval.
5724 # So we can't pass in a "transform" that uses next. We used
5725 # to do this. "Empty" also means consisting of a single
5727 next if $had_chars && ($_ eq '' || $_ eq "\n");
5729 if (/$IGNORE_PATTERN/o)
5731 # Merely delete comments beginning with two hashes.
5733 elsif (/$WHITE_PATTERN/o)
5735 # Stick a single white line before the incoming macro or rule.
5738 elsif (/$COMMENT_PATTERN/o)
5740 # Stick comments before the incoming macro or rule.
5741 $comment .= $spacing . $_;
5748 $result_rules .= $_ if ! $skipping;
5752 $result_vars .= $_ if ! $skipping;
5756 elsif (/$RULE_PATTERN/o)
5760 $skipping = defined $contents{$1};
5761 $result_rules .= $comment . $spacing . $_ if ! $skipping;
5762 $comment = $spacing = '';
5765 elsif (/$MACRO_PATTERN/o)
5767 # Found a variable reference.
5769 $skipping = defined $contents{$1};
5770 $result_vars .= $comment . $spacing . $_ if ! $skipping;
5771 $comment = $spacing = '';
5776 # This isn't an error; it is probably a continued rule.
5777 # In fact, this is what we assume.
5779 $result_rules .= $comment . $spacing . $_ if ! $skipping;
5780 $comment = $spacing = '';
5786 return $result_vars . $result_rules . $comment;
5789 # Like file_contents_with_transform, but no transform.
5792 return &file_contents_with_transform ('', @_);
5795 # Find all variable prefixes that are used for install directories. A
5796 # prefix `zar' qualifies iff:
5797 # * `zardir' is a variable.
5798 # * `zar_PRIMARY' is a variable.
5799 sub am_primary_prefixes
5801 local ($primary, @prefixes) = @_;
5803 local (%valid, $varname);
5804 grep ($valid{$_} = 0, @prefixes);
5805 $valid{'EXTRA'} = 0;
5806 foreach $varname (keys %contents)
5808 if ($varname =~ /^(.*)_$primary$/)
5810 if (! defined $valid{$1}
5811 && ! &variable_defined ($1 . 'dir')
5812 # Note that a configure variable is always legitimate.
5813 # It is natural to name such variables after the
5814 # primary, so we explicitly allow it.
5815 && ! defined $configure_vars{$varname})
5817 &am_line_error ($varname, "invalid variable \`$varname'");
5821 # Ensure all extended prefixes are actually used.
5830 # Handle `where_HOW' variable magic. Does all lookups, generates
5831 # install code, and possibly generates code to define the primary
5832 # variable. The first argument is the name of the .am file to munge,
5833 # the second argument is the primary variable (eg HEADERS), and all
5834 # subsequent arguments are possible installation locations. Returns
5835 # list of all values of all _HOW targets.
5837 # FIXME: this should be rewritten to be cleaner. It should be broken
5838 # up into multiple functions.
5840 # Usage is: am_install_var (OPTION..., file, HOW, where...)
5845 local ($do_clean) = 0;
5848 if (defined $configure_vars{'LIBTOOL'})
5850 # Transform '@LIBTOOL ...@' to '$(LIBTOOL) ...'
5851 $ltxform = 's/\@LIBTOOL([^\@]*)\@/\$(LIBTOOL) $1/;';
5855 # Delete '@LIBTOOL ...@'
5856 $ltxform = 's/\@LIBTOOL([^\@]*)\@//;';
5862 $cygxform = 's/\@EXEEXT\@//g;';
5866 $cygxform = 's/\@EXEEXT\@/\$(EXEEXT)/g;';
5871 if ($args[0] eq '-clean')
5875 elsif ($args[0] !~ /^-/)
5881 local ($file, $primary, @prefixes) = @args;
5884 local (@result) = ();
5886 # Now that configure substitutions are allowed in where_HOW
5887 # variables, it is an error to actually define the primary. We
5888 # allow `JAVA', as it is customarily used to mean the Java
5889 # interpreter. This is but one of several Java hacks.
5890 &am_line_error ($primary, "\`$primary' is an anachronism")
5891 if &variable_defined ($primary) && $primary ne 'JAVA';
5894 # Look for misspellings. It is an error to have a variable ending
5895 # in a "reserved" suffix whose prefix is unknown, eg
5896 # "bni_PROGRAMS". However, unusual prefixes are allowed if a
5897 # variable of the same name (with "dir" appended) exists. For
5898 # instance, if the variable "zardir" is defined, then
5899 # "zar_PROGRAMS" becomes valid. This is to provide a little extra
5900 # flexibility in those cases which need it. Perhaps it should be
5901 # disallowed in the Gnits case? The problem is, sometimes it is
5902 # useful to put things in a subdir of eg pkgdatadir, perhaps even
5904 local (%valid) = &am_primary_prefixes ($primary, @prefixes);
5906 # If a primary includes a configure substitution, then the EXTRA_
5907 # form is required. Otherwise we can't properly do our job.
5908 local ($require_extra);
5909 local ($warned_about_extra) = 0;
5911 local ($clean_file) = $file . '-clean';
5914 foreach $X (sort keys %valid)
5916 $one_name = $X . '_' . $primary;
5917 if (&variable_defined ($one_name))
5919 # Append actual contents of where_PRIMARY variable to
5922 foreach $rcurs (&variable_value_as_list ($one_name, 'all'))
5924 # Skip configure substitutions. Possibly bogus.
5925 if ($rcurs =~ /^\@.*\@$/)
5929 if (! $warned_about_extra)
5931 $warned_about_extra = 1;
5932 &am_line_error ($one_name,
5933 "\`$one_name' contains configure substitution, but shouldn't");
5936 # Check here to make sure variables defined in
5937 # configure.in do not imply that EXTRA_PRIMARY
5939 elsif (! defined $configure_vars{$one_name})
5941 $require_extra = $one_name;
5947 push (@result, $rcurs);
5950 # "EXTRA" shouldn't be used when generating clean targets,
5951 # all, or install targets.
5952 next if $X eq 'EXTRA';
5954 # A blatant hack: we rewrite each _PROGRAMS primary to
5955 # include EXEEXT when in Cygwin32 mode.
5956 if ($seen_exeext && $primary eq 'PROGRAMS')
5958 local (@conds) = &variable_conditions ($one_name);
5959 local (@one_binlist);
5961 # FIXME: this definitely loses aesthetically; it
5962 # redefines $ONE_NAME. Instead we should arrange for
5963 # variable definitions to be output later, instead of
5969 foreach $rcurs (&variable_value_as_list ($one_name, ''))
5971 if ($rcurs =~ /\./ || $rcurs =~ /^\@.*\@$/)
5973 push (@one_binlist, $rcurs);
5977 push (@one_binlist, $rcurs . '$(EXEEXT)');
5981 delete $contents{$one_name};
5982 &define_pretty_variable ($one_name, '', @one_binlist);
5987 local ($condvals) = '';
5988 foreach $cond (@conds)
5991 local (@condval) = &variable_value_as_list ($one_name,
5993 foreach $rcurs (@condval)
5995 if ($rcurs =~ /\./ || $rcurs =~ /^\@.*\@$/)
5997 push (@one_binlist, $rcurs);
6001 push (@one_binlist, $rcurs . '$(EXEEXT)');
6005 push (@condvals, $cond);
6006 push (@condvals, join (' ', @one_binlist));
6009 delete $contents{$one_name};
6013 $cond = shift (@condvals);
6014 local (@val) = split (' ', shift (@condvals));
6015 &define_pretty_variable ($one_name, $cond, @val);
6023 &file_contents_with_transform ('s/\@DIR\@/' . $X . '/go;'
6027 push (@clean, $X . $primary);
6028 &push_phony_cleaners ($X . $primary);
6033 push (@check, '$(' . $one_name . ')');
6037 push (@used, '$(' . $one_name . ')');
6039 if ($X eq 'noinst' || $X eq 'check')
6041 # Objects which don't get installed by default.
6046 &file_contents_with_transform ('s/\@DIR\@/' . $X . '/g;'
6047 . $ltxform . $cygxform,
6050 push (@uninstall, 'uninstall-' . $X . $primary);
6051 push (@phony, 'uninstall-' . $X . $primary);
6052 push (@installdirs, '$(DATADIR)$(' . $X . 'dir)');
6053 if (defined $exec_dir_p{$X} ? $exec_dir_p{$X} : ($X =~ /exec/))
6055 push (@install_exec, 'install-' . $X . $primary);
6056 push (@phony, 'install-' . $X . $primary);
6060 push (@install_data, 'install-' . $X . $primary);
6061 push (@phony, 'install-' . $X . $primary);
6066 # The JAVA variable is used as the name of the Java interpreter.
6067 if (@used && $primary ne 'JAVA')
6070 &define_pretty_variable ($primary, '', @used);
6071 $output_vars .= "\n";
6074 if ($require_extra && ! &variable_defined ('EXTRA_' . $primary))
6076 &am_line_error ($require_extra,
6077 "\`$require_extra' contains configure substitution, but \`EXTRA_$primary' not defined");
6080 # Push here because PRIMARY might be configure time determined.
6081 push (@all, '$(' . $primary . ')')
6082 if @used && $primary ne 'JAVA';
6088 ################################################################
6090 # This variable is local to the "require file" set of functions.
6091 @require_file_paths = ();
6093 # Verify that the file must exist in the current directory. Usage:
6094 # require_file (isconfigure, line_number, strictness, file) strictness
6095 # is the strictness level at which this file becomes required. Must
6096 # set require_file_paths before calling this function.
6097 # require_file_paths is set to hold a single directory (the one in
6098 # which the first file was found) before return.
6099 sub require_file_internal
6101 local ($is_configure, $line, $mystrict, @files) = @_;
6102 local ($file, $fullfile);
6103 local ($found_it, $errfile, $errdir);
6106 foreach $file (@files)
6109 foreach $dir (@require_file_paths)
6113 $fullfile = $relative_dir . "/" . $file;
6114 $errdir = $relative_dir unless $errdir;
6118 $fullfile = $dir . "/" . $file;
6119 $errdir = $dir unless $errdir;
6122 # Use different name for "error filename". Otherwise on
6123 # an error the bad file will be reported as eg
6124 # `../../install-sh' when using the default
6126 $errfile = $errdir . '/' . $file;
6131 # FIXME: Once again, special-case `.'.
6132 &push_dist_common ($file)
6133 if $dir eq $relative_dir || $dir eq '.';
6141 # Prune the path list.
6142 @require_file_paths = $save_dir;
6146 if ($strictness >= $mystrict)
6148 local ($trailer) = '';
6149 local ($suppress) = 0;
6151 # Only install missing files according to our desired
6153 local ($message) = "required file \`$errfile' not found";
6158 # Maybe run libtoolize.
6160 && grep ($_ eq $file, @libtoolize_files)
6161 && system ('libtoolize', '--automake'))
6163 $message = "installing \`$errfile'";
6165 $trailer = "; cannot run \`libtoolize': $!";
6167 elsif (-f ($am_dir . '/' . $file))
6169 # Install the missing file. Symlink if we
6170 # can, copy if we must. Note: delete the file
6171 # first, in case it is a dangling symlink.
6172 $message = "installing \`$errfile'";
6174 if ($symlink_exists)
6176 if (! symlink ($am_dir . '/' . $file, $errfile))
6179 $trailer = "; error while making link: $!\n";
6182 elsif (! system ('cp', $am_dir . '/' . $file, $errfile))
6185 $trailer = "\n error while making link\n";
6190 local ($save) = $exit_status;
6193 # FIXME: allow actual file to be specified.
6194 &am_conf_line_error ('configure.in', $line,
6195 "$message$trailer");
6199 &am_line_error ($line, "$message$trailer");
6201 $exit_status = $save if $suppress;
6207 # Like require_file_with_line, but error messages refer to
6208 # configure.in, not the current Makefile.am.
6209 sub require_file_with_conf_line
6211 @require_file_paths = '.';
6212 &require_file_internal (1, @_);
6215 sub require_file_with_line
6217 @require_file_paths = '.';
6218 &require_file_internal (0, @_);
6223 @require_file_paths = '.';
6224 &require_file_internal (0, '', @_);
6227 # Require a file that is also required by Autoconf. Looks in
6228 # configuration path, as specified by AC_CONFIG_AUX_DIR.
6229 sub require_config_file
6231 @require_file_paths = @config_aux_path;
6232 &require_file_internal (1, '', @_);
6233 local ($dir) = $require_file_paths[0];
6234 @config_aux_path = @require_file_paths;
6237 $config_aux_dir = '.';
6241 $config_aux_dir = '$(top_srcdir)/' . $dir;
6245 # Assumes that the line number is in Makefile.am.
6246 sub require_conf_file_with_line
6248 @require_file_paths = @config_aux_path;
6249 &require_file_internal (0, @_);
6250 local ($dir) = $require_file_paths[0];
6251 @config_aux_path = @require_file_paths;
6254 $config_aux_dir = '.';
6258 $config_aux_dir = '$(top_srcdir)/' . $dir;
6262 # Assumes that the line number is in Makefile.am.
6263 sub require_conf_file_with_conf_line
6265 @require_file_paths = @config_aux_path;
6266 &require_file_internal (1, @_);
6267 local ($dir) = $require_file_paths[0];
6268 @config_aux_path = @require_file_paths;
6271 $config_aux_dir = '.';
6275 $config_aux_dir = '$(top_srcdir)/' . $dir;
6279 ################################################################
6281 # Push a list of files onto dist_common.
6282 sub push_dist_common
6284 local (@files) = @_;
6287 foreach $file (@files)
6289 $dist_common{$file} = 1;
6293 # Push a list of clean targets onto phony.
6294 sub push_phony_cleaners
6298 foreach $target ('mostly', 'dist', '', 'maintainer-')
6300 push (@phony, $target . 'clean-' . $base);
6307 $strictness_name = $_[0];
6308 if ($strictness_name eq 'gnu')
6312 elsif ($strictness_name eq 'gnits')
6314 $strictness = $GNITS;
6316 elsif ($strictness_name eq 'foreign')
6318 $strictness = $FOREIGN;
6322 die "automake: level \`$strictness_name' not recognized\n";
6327 ################################################################
6329 # Return directory name of file.
6335 ($sub = $file) =~ s,/+[^/]+$,,g;
6336 $sub = '.' if $sub eq $file;
6340 # Return file name of a file.
6346 ($sub = $file) =~s,^.*/+,,g;
6355 open (TOUCH, ">> $file");
6359 # Glob something. Do this to avoid indentation screwups everywhere we
6360 # want to glob. Gross!
6367 ################################################################
6369 # Print an error message and set exit status.
6372 warn "automake: ${am_file}.am: ", join (' ', @_), "\n";
6378 local ($symbol, @args) = @_;
6380 if ($symbol && "$symbol" ne '-1')
6382 # If SYMBOL not already a line number, look it up in Makefile.am.
6383 if ($symbol =~ /^\d+$/)
6387 elsif (defined $content_lines{$symbol})
6389 $symbol = $content_lines{$symbol} . ': ';
6393 # A single space, to provide nice separation.
6396 warn "${am_file}.am:", $symbol, join (' ', @args), "\n";
6405 # Like am_error, but while scanning configure.in.
6408 # FIXME: can run in subdirs.
6409 warn "automake: configure.in: ", join (' ', @_), "\n";
6413 # Error message with line number referring to configure.in.
6414 sub am_conf_line_error
6416 local ($file, $line, @args) = @_;
6420 warn "$file: $line: ", join (' ', @args), "\n";
6425 &am_conf_error (@args);
6429 # Warning message with line number referring to configure.in.
6430 # Does not affect exit_status
6431 sub am_conf_line_warning
6433 local ($saved_exit_status) = $exit_status;
6434 &am_conf_line_error (@_);
6435 $exit_status = $saved_exit_status;
6438 # Tell user where our aclocal.m4 is, but only once.
6439 sub keyed_aclocal_warning
6442 warn "automake: macro \`$key' can be generated by \`aclocal'\n";
6445 # Print usage information.
6448 print "Usage: automake [OPTION] ... [Makefile]...\n\n";
6449 print "Generate Makefile.in for autoconf from Makefile.am\n";
6451 print "\nFiles which are automatically distributed, if found:\n";
6452 $~ = "USAGE_FORMAT";
6453 local (@lcomm) = sort ((@common_files, @common_sometimes));
6454 local ($one, $two, $three, $four);
6457 $one = shift @lcomm;
6458 $two = @lcomm ? shift @lcomm : '';
6459 $three = @lcomm ? shift @lcomm : '';
6460 $four = @lcomm ? shift @lcomm : '';
6464 print "\nReport bugs to <automake-bugs\@gnu.org>.\n";
6469 format USAGE_FORMAT =
6470 @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<
6471 $one, $two, $three, $four