5 eval 'exec @PERL@ -S $0 ${1+"$@"}'
8 # automake - create Makefile.in from Makefile.am
9 # Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
10 # Free Software Foundation, Inc.
12 # This program is free software; you can redistribute it and/or modify
13 # it under the terms of the GNU General Public License as published by
14 # the Free Software Foundation; either version 2, or (at your option)
17 # This program is distributed in the hope that it will be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # GNU General Public License for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, write to the Free Software
24 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
27 # Originally written by David Mackenzie <djm@gnu.ai.mit.edu>.
28 # Perl reimplementation by Tom Tromey <tromey@cygnus.com>.
32 # Parameters set by configure. Not to be changed. NOTE: assign
33 # VERSION as string so that eg version 0.30 will print correctly.
34 $VERSION = "@VERSION@";
35 $PACKAGE = "@PACKAGE@";
37 $am_dir = "@datadir@/@PACKAGE@";
40 $IGNORE_PATTERN = "^##([^#].*)?\$";
41 $WHITE_PATTERN = "^[ \t]*\$";
42 $COMMENT_PATTERN = "^#";
43 $TARGET_PATTERN="[\$a-zA-Z_.][-.a-zA-Z0-9_(){}/\$]*";
44 $RULE_PATTERN = "^($TARGET_PATTERN) *:([^=].*|)\$";
45 $SUFFIX_RULE_PATTERN = "^\\.([a-zA-Z0-9]+)\\.([a-zA-Z0-9]+)\$";
46 # Only recognize leading spaces, not leading tabs. If we recognize
47 # leading tabs here then we need to make the reader smarter, because
48 # otherwise it will think rules like `foo=bar; \' are errors.
49 $MACRO_PATTERN = "^ *([A-Za-z0-9_]+)[ \t]*([:+]?)=[ \t]*(.*)\$";
50 $BOGUS_MACRO_PATTERN = "^ *([^ \t]*)[ \t]*([:+]?)=[ \t]*(.*)\$";
51 $GNITS_VERSION_PATTERN = "[0-9]+\\.[0-9]+([a-z]|\\.[0-9]+)?";
52 $IF_PATTERN = "^if[ \t]+\([A-Za-z][A-Za-z0-9_]*\)[ \t]*\(#.*\)?\$";
53 $ELSE_PATTERN = "^else[ \t]*\(#.*\)?\$";
54 $ENDIF_PATTERN = "^endif[ \t]*\(#.*\)?\$";
55 $PATH_PATTERN='(\\w|[/.-])+';
56 # This will pass through anything not of the prescribed form.
57 $INCLUDE_PATTERN = "^include[ \t]+((\\\$\\\(top_srcdir\\\)/${PATH_PATTERN})|(\\\$\\\(srcdir\\\)/${PATH_PATTERN})|([^/\\\$]${PATH_PATTERN}))[ \t]*(#.*)?\$";
59 # Some regular expressions. One reason to put them here is that it
60 # makes indentation work better in Emacs.
61 $AC_CONFIG_AUX_DIR_PATTERN = "AC_CONFIG_AUX_DIR\\(([^)]+)\\)";
62 $AM_INIT_AUTOMAKE_PATTERN = "AM_INIT_AUTOMAKE\\([^,]*,([^,)]+)[,)]";
63 $AM_PACKAGE_VERSION_PATTERN = "^\\s*\\[?([^]\\s]+)\\]?\\s*\$";
64 # Note that there is no AC_PATH_TOOL. But we don't really care.
65 $AC_CHECK_PATTERN = "AC_(CHECK|PATH)_(PROG|PROGS|TOOL)\\(\\[?(\\w+)";
66 $AM_MISSING_PATTERN = "AM_MISSING_PROG\\(\\[?(\\w+)";
67 # Just check for alphanumeric in AC_SUBST. If you do AC_SUBST(5),
69 $AC_SUBST_PATTERN = "AC_SUBST\\(\\[?(\\w+)";
70 $AM_CONDITIONAL_PATTERN = "AM_CONDITIONAL\\((\\w+)";
72 # Constants to define the "strictness" level.
77 # These constants are returned by lang_*_rewrite functions.
78 # LANG_SUBDIR means that the resulting object file should be in a
79 # subdir if the source file is. In this case the file name cannot
80 # have `..' components.
87 # Variables global to entire run.
89 # Variables related to the options.
91 # TRUE if we should always generate Makefile.in.
92 $force_generation = 1;
94 # Strictness level as set on command line.
95 $default_strictness = $GNU;
97 # Name of strictness level, as set on command line.
98 $default_strictness_name = 'gnu';
100 # This is TRUE if automatic dependency generation code should be
101 # included in generated Makefile.in.
102 $cmdline_use_dependencies = 1;
104 # TRUE if in verbose mode.
107 # This holds our (eventual) exit status. We don't actually exit until
108 # we have processed all input files.
111 # From the Perl manual.
112 $symlink_exists = (eval 'symlink ("", "");', $@ eq '');
114 # TRUE if missing standard files should be installed.
117 # TRUE if we should copy missing files; otherwise symlink if possible.
120 # TRUE if we should always update files that we know about.
124 # Variables filled during files scanning.
126 # Name of the top autoconf input: `configure.ac' or `configure.in'.
129 # Files found by scanning configure.ac for LIBOBJS.
132 # True if AM_C_PROTOTYPES appears in configure.ac.
133 $am_c_prototypes = 0;
135 # Names used in AC_CONFIG_HEADER call. @config_fullnames holds the
136 # name which appears in AC_CONFIG_HEADER, colon and all.
137 # @config_names holds the file names. @config_headers holds the '.in'
138 # files. Ordinarily these are similar, but they can be different if
139 # the weird "NAME:FILE" syntax is used.
140 @config_fullnames = ();
142 @config_headers = ();
143 # Line number at which AC_CONFIG_HEADER appears in configure.ac.
144 $config_header_line = 0;
146 # Directory where output files go. Actually, output files are
147 # relative to this directory.
148 $output_directory = '.';
150 # Relative location of top build directory.
153 # List of Makefile.am's to process, and their corresponding outputs.
157 # Complete list of Makefile.am's that exist.
158 @configure_input_files = ();
160 # List of files in AC_OUTPUT without Makefile.am, and their outputs.
161 @other_input_files = ();
162 # Line number at which AC_OUTPUT seen.
165 # List of directories to search for configure-required files. This
166 # can be set by AC_CONFIG_AUX_DIR.
167 @config_aux_path = ('.', '..', '../..');
168 $config_aux_dir = '';
170 # Whether AC_PROG_MAKE_SET has been seen in configure.ac.
173 # Whether AM_GNU_GETTEXT has been seen in configure.ac.
175 # Line number at which AM_GNU_GETTEXT seen.
176 $ac_gettext_line = 0;
178 # Whether ALL_LINGUAS has been seen.
182 # Line number at which it appears.
183 $all_linguas_line = 0;
185 # 1 if AC_PROG_INSTALL seen.
186 $seen_prog_install = 0;
188 # Whether AC_PATH_XTRA has been seen in configure.ac.
191 # TRUE if AC_DECL_YYTEXT was seen.
192 $seen_decl_yytext = 0;
194 # TRUE if we've seen AC_CANONICAL_(HOST|SYSTEM). The presence of
195 # AC_CHECK_TOOL also sets this.
198 # TRUE if we've seen AC_ARG_PROGRAM.
201 # TRUE if we've seen AC_PROG_LIBTOOL.
205 # Files installed by libtoolize.
206 @libtoolize_files = ('ltmain.sh', 'config.guess', 'config.sub');
207 # ltconfig appears here for compatibility with old versions of libtool.
208 @libtoolize_sometimes = ('ltconfig', 'ltcf-c.sh', 'ltcf-cxx.sh',
211 # TRUE if we've seen AM_MAINTAINER_MODE.
212 $seen_maint_mode = 0;
214 # Actual version we've seen.
215 $package_version = '';
217 # Line number where we saw version definition.
218 $package_version_line = 0;
220 # TRUE if we've seen AM_PATH_LISPDIR.
223 # TRUE if we've seen AM_CHECK_PYTHON.
226 # TRUE if we've seen AC_EXEEXT.
229 # TRUE if we've seen AC_OBJEXT.
232 # TRUE if we've seen AC_ENABLE_MULTILIB.
235 # TRUE if we've seen AM_PROG_CC_C_O
238 # TRUE if we've seen AM_INIT_AUTOMAKE.
239 $seen_init_automake = 0;
241 # Hash table of discovered configure substitutions. Keys are names,
242 # values are `FILE:LINE' strings which are used by error message
244 %configure_vars = ();
246 # This is used to keep track of which variable definitions we are
247 # scanning. It is only used in certain limited ways, but it has to be
248 # global. It is declared just for documentation purposes.
251 # Charsets used by maintainer and in distribution. MAINT_CHARSET is
252 # handled in a funny way: if seen in the top-level Makefile.am, it is
253 # used for every directory which does not specify a different value.
254 # The rationale here is that some directories (eg gettext) might be
255 # distributions of other packages, and thus require their own charset
256 # info. However, the DIST_CHARSET must be the same for the entire
257 # package; it can only be set at top-level.
258 # FIXME: this yields bugs when rebuilding. What to do? Always
259 # read (and sometimes discard) top-level Makefile.am?
261 $dist_charset = 'utf8'; # recode doesn't support this yet.
263 # Name of input file ("Makefile.in") and output file ("Makefile.am").
264 # These have no directory components.
268 # TRUE if --cygnus seen.
271 # Hash table of AM_CONDITIONAL variables seen in configure.
272 %configure_cond = ();
274 # Map from obsolete macros to hints for new macros.
275 # If you change this, change the corresponding list in aclocal.in.
276 # FIXME: should just put this into a single file.
279 'AC_FEATURE_CTYPE', "use \`AC_HEADER_STDC'",
280 'AC_FEATURE_ERRNO', "add \`strerror' to \`AC_REPLACE_FUNCS(...)'",
281 'AC_FEATURE_EXIT', '',
282 'AC_SYSTEM_HEADER', '',
284 # Note that we do not handle this one, because it is still run
285 # from AM_CONFIG_HEADER. So we deal with it specially in
286 # &scan_autoconf_files.
287 # 'AC_CONFIG_HEADER', "use \`AM_CONFIG_HEADER'",
289 'fp_C_PROTOTYPES', "use \`AM_C_PROTOTYPES'",
290 'fp_PROG_CC_STDC', "use \`AM_PROG_CC_STDC'",
291 'fp_PROG_INSTALL', "use \`AC_PROG_INSTALL'",
292 'fp_WITH_DMALLOC', "use \`AM_WITH_DMALLOC'",
293 'fp_WITH_REGEX', "use \`AM_WITH_REGEX'",
294 'gm_PROG_LIBTOOL', "use \`AM_PROG_LIBTOOL'",
295 'jm_MAINTAINER_MODE', "use \`AM_MAINTAINER_MODE'",
296 'md_TYPE_PTRDIFF_T', "use \`AM_TYPE_PTRDIFF_T'",
297 'ud_PATH_LISPDIR', "use \`AM_PATH_LISPDIR'",
298 'ud_GNU_GETTEXT', "use \`AM_GNU_GETTEXT'",
300 # Now part of autoconf proper, under a different name.
301 'AM_FUNC_FNMATCH', "use \`AC_FUNC_FNMATCH'",
302 'fp_FUNC_FNMATCH', "use \`AC_FUNC_FNMATCH'",
303 'AM_SANITY_CHECK_CC', "automatically done by \`AC_PROG_CC'",
304 'AM_PROG_INSTALL', "use \`AC_PROG_INSTALL'",
305 'AM_EXEEXT', "use \`AC_EXEEXT'",
306 'AM_CYGWIN32', "use \`AC_CYGWIN'",
307 'AM_MINGW32', "use \`AC_MINGW32'",
308 'AM_FUNC_MKTIME', "use \`AC_FUNC_MKTIME'",
310 # These aren't quite obsolete.
314 # Regexp to match the above macros.
315 $obsolete_rx = '(\b' . join ('\b|\b', keys %obsolete_macros) . '\b)';
317 # This maps extensions onto language names.
320 # This maps languages names onto properties.
323 # This holds all the files that would go in `dist_common' which we
324 # discovered while scanning configure.ac. We might distribute these
325 # in the top-level Makefile.in.
326 %configure_dist_common = ();
329 # Initialize global constants and our list of languages that are
330 # internally supported.
331 &initialize_global_constants;
333 ®ister_language ('c', 'ansi-p=1', 'autodep=', 'flags=CFLAGS',
334 'compile=$(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)',
335 'compiler-name=COMPILE',
338 ®ister_language ('cxx', 'linker=CXXLINK', 'autodep=CXX', 'flags=CXXFLAGS',
339 'compile=$(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)',
340 'compiler-name=CXXCOMPILE',
341 'output-arg=-c -o $@',
342 'c++', 'cc', 'cpp', 'cxx', 'C');
343 ®ister_language ('objc', 'linker=OBJCLINK', 'autodep=OBJC',
345 'compile=$(OBJC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_OBJCFLAGS) $(OBJCFLAGS)',
346 'compiler-name=OBJCCOMPILE',
347 'output-arg=-c -o $@',
349 ®ister_language ('header',
350 'h', 'H', 'hxx', 'h++', 'hh', 'hpp', 'inc');
352 # For now, yacc and lex can't be handled on a per-exe basis.
353 ®ister_language ('yacc', 'ansi-p=1', 'derived-autodep=yes',
355 ®ister_language ('yaccxx', 'linker=CXXLINK', 'derived-autodep=yes',
356 'y++', 'yy', 'yxx', 'ypp');
357 ®ister_language ('lex', 'ansi-p=1', 'derived-autodep=yes',
359 ®ister_language ('lexxx', 'linker=CXXLINK', 'derived-autodep=yes',
360 'l++', 'll', 'lxx', 'lpp');
362 ®ister_language ('asm',
363 'flags=CFLAGS', # FIXME: asmflags?
364 'compile=$(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)', # FIXME: a different compiler?
365 'compiler-name=COMPILE',
369 ®ister_language ('f77', 'linker=F77LINK', 'flags=FFLAGS',
370 'compile=$(F77) $(AM_FFLAGS) $(FFLAGS)',
371 'compiler-name=F77COMPILE',
372 'output-arg=-c -o $@',
374 ®ister_language ('ppf77', 'linker=F77LINK', 'flags=FFLAGS',
375 'compile=$(F77) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FFLAGS) $(FFLAGS)',
376 'compiler-name=PPF77COMPILE',
377 'output-arg=-c -o $@',
379 ®ister_language ('ratfor', 'linker=F77LINK',
380 'flags=RFLAGS', # FIXME also FFLAGS.
381 'compile=$(F77) $(AM_FFLAGS) $(FFLAGS) $(AM_RFLAGS) $(RFLAGS)',
382 'compiler-name=RCOMPILE',
383 'output-arg=-c -o $@',
385 # FIXME: for now we can't do dependency tracking for Java.
387 ®ister_language ('java', 'linker=GCJLINK', 'flags=GCJFLAGS',
388 'compile=$(GCJ) $(DEFS) $(INCLUDES) $(AM_GCJFLAGS) $(GCJFLAGS)',
389 'compiler-name=GCJCOMPILE',
390 'output-arg=-c -o $@',
391 'java', 'class', 'zip', 'jar');
394 # Parse command line.
395 &parse_arguments (@ARGV);
397 # Do configure.ac scan only once.
398 &scan_autoconf_files;
400 die "automake: no \`Makefile.am' found or specified\n"
403 # Now do all the work on each file.
404 foreach $am_file (@input_files)
406 if (! -f ($am_file . '.am'))
408 &am_error ("\`" . $am_file . ".am' does not exist");
412 &generate_makefile ($output_files{$am_file}, $am_file);
416 &am_conf_error ("AC_PROG_INSTALL must be used")
417 if (! $seen_prog_install);
422 ################################################################
425 # prog_error (@PRINT-ME)
426 # ----------------------
427 # Signal a programming error, display PRINT-ME, and exit 1.
430 print STDERR "automake: programming error: @_\n";
435 ################################################################
437 # Parse command line.
440 local (@arglist) = @_;
443 &set_strictness ('gnu');
447 if ($arglist[0] eq "--version")
449 print "automake (GNU $PACKAGE) $VERSION\n\n";
450 print "Copyright 2000 Free Software Foundation, Inc.\n";
451 print "This is free software; see the source for copying conditions. There is NO\n";
452 print "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n";
453 print "Written by Tom Tromey <tromey\@cygnus.com>\n";
457 elsif ($arglist[0] eq "--help")
461 elsif ($arglist[0] =~ /^--amdir=(.+)$/)
465 elsif ($arglist[0] eq '--amdir')
467 &require_argument (@arglist);
469 $am_dir = $arglist[0];
471 elsif ($arglist[0] eq '--gnu')
473 &set_strictness ('gnu');
475 elsif ($arglist[0] eq '--gnits')
477 &set_strictness ('gnits');
479 elsif ($arglist[0] eq '--cygnus')
483 elsif ($arglist[0] eq '--foreign')
485 &set_strictness ('foreign');
487 elsif ($arglist[0] eq '--include-deps')
489 $cmdline_use_dependencies = 1;
491 elsif ($arglist[0] eq '--ignore-deps' || $arglist[0] eq '-i')
493 $cmdline_use_dependencies = 0;
495 elsif ($arglist[0] eq '--no-force')
497 $force_generation = 0;
499 elsif ($arglist[0] eq '--force-missing')
503 elsif ($arglist[0] =~ /^--output-dir=(.*)$/)
505 # Set output directory.
506 $output_directory = $1;
508 elsif ($arglist[0] eq '--output-dir' || $arglist[0] eq '-o')
510 &require_argument (@arglist);
512 $output_directory = $arglist[0];
514 elsif ($arglist[0] eq '--add-missing' || $arglist[0] eq '-a')
518 elsif ($arglist[0] eq '--copy' || $arglist[0] eq '-c')
522 elsif ($arglist[0] eq '--verbose' || $arglist[0] eq '-v')
526 elsif ($arglist[0] eq '--')
528 # Stop option processing.
530 push (@input_files, @arglist);
533 elsif ($arglist[0] =~ /^-/)
535 die "automake: unrecognized option -- \`$arglist[0]'\nTry \`automake --help' for more information.\n";
539 # Handle $local:$input syntax. Note that we only examine
540 # the first ":" file to see if it is automake input; the
541 # rest are just taken verbatim. We still keep all the
542 # files around for dependency checking, however.
543 local ($local, $input, @rest) = split (/:/, $arglist[0]);
550 # Strip .in; later on .am is tacked on. That is how
551 # the automake input file is found. Maybe not the
552 # best way, but it is easy to explain. FIXME: should
553 # be error if .in is missing.
556 push (@input_files, $input);
557 $output_files{$input} = join (':', ($local, @rest));
563 # Take global strictness from whatever we currently have set.
564 $default_strictness = $strictness;
565 $default_strictness_name = $strictness_name;
568 # Ensure argument exists, or die.
571 local ($arg, @arglist) = @_;
572 die "automake: no argument given for option \`$arg'\n"
576 ################################################################
578 # Generate a Makefile.in given the name of the corresponding Makefile and
579 # the name of the file output by config.status.
580 sub generate_makefile
582 local ($output, $makefile) = @_;
584 ($am_file_name = $makefile) =~ s/^.*\///;
585 $in_file_name = $am_file_name . '.in';
586 $am_file_name .= '.am';
588 # $OUTPUT is encoded. If it contains a ":" then the first element
589 # is the real output file, and all remaining elements are input
590 # files. We don't scan or otherwise deal with these input file,
591 # other than to mark them as dependencies. See
592 # &scan_autoconf_files for details.
593 local (@secondary_inputs);
594 ($output, @secondary_inputs) = split (/:/, $output);
596 &initialize_per_input;
597 $relative_dir = &dirname ($output);
598 $am_relative_dir = &dirname ($makefile);
600 # At the toplevel directory, we might need config.guess, config.sub
601 # or libtool scripts (ltconfig and ltmain.sh).
602 if ($relative_dir eq '.')
604 # libtool requires some files.
605 &require_conf_file_with_conf_line ($libtool_line, $FOREIGN,
609 # AC_CANONICAL_HOST and AC_CANONICAL_SYSTEM need config.guess and
611 &require_config_file ($FOREIGN, 'config.guess', 'config.sub')
615 # We still need Makefile.in here, because sometimes the `dist'
616 # target doesn't re-run automake.
617 if ($am_relative_dir eq $relative_dir)
619 # Only distribute the files if they are in the same subdir as
620 # the generated makefile.
621 &push_dist_common ($in_file_name, $am_file_name);
624 push (@sources, '$(SOURCES)')
625 if &variable_defined ('SOURCES');
626 push (@objects, '$(OBJECTS)')
627 if &variable_defined ('OBJECTS');
629 &read_main_am_file ($makefile . '.am');
632 # Fatal error. Just return, so we can continue with next file.
636 # Must do this after reading .am file. See read_main_am_file to
637 # understand weird tricks we play there with variables.
638 &define_variable ('subdir', $relative_dir);
640 # Check first, because we might modify some state.
642 &check_gnu_standards;
643 &check_gnits_standards;
645 &handle_configure ($output, $makefile, @secondary_inputs);
652 # This must be run after all the sources are scanned.
655 # Re-init SOURCES and OBJECTS. FIXME: other code shouldn't depend
656 # on this (but currently does).
657 $contents{'SOURCES'} = join (' ', @sources);
658 $contents{'OBJECTS'} = join (' ', @objects);
659 &define_pretty_variable ('DIST_SOURCES', '', @dist_sources);
671 &handle_minor_options;
672 &handle_dependencies;
675 # This must come after most other rules.
676 &handle_dist ($makefile);
679 &handle_merge_targets ($output);
682 &handle_factored_dependencies;
686 if (! -d ($output_directory . '/' . $am_relative_dir))
688 mkdir ($output_directory . '/' . $am_relative_dir, 0755);
691 local ($out_file) = $output_directory . '/' . $makefile . ".in";
692 if (! $force_generation && -e $out_file)
694 local ($am_time) = (stat ($makefile . '.am'))[9];
695 local ($in_time) = (stat ($out_file))[9];
696 # FIXME: should cache these times.
697 local ($conf_time) = (stat ($configure_ac))[9];
698 # FIXME: how to do unsigned comparison?
699 if ($am_time < $in_time || $am_time < $conf_time)
706 local ($acl_time) = (stat _)[9];
707 return if ($am_time < $acl_time);
711 if (! open (GM_FILE, "> " . $out_file))
713 warn "automake: ${am_file}.in: cannot write: $!\n";
717 print "automake: creating ", $makefile, ".in\n" if $verbose;
719 # In case we're running under MSWindows, don't write with CRLF
720 # (as it causes problems for the dependency-file extraction in
721 # AM_OUTPUT_DEPENDENCY_COMMANDS).
724 print GM_FILE $output_vars;
725 # We make sure that `all:' is the first target.
726 print GM_FILE $output_all;
727 print GM_FILE $output_header;
728 print GM_FILE $output_rules;
729 print GM_FILE $output_trailer;
731 if (! close (GM_FILE))
733 warn "automake: $am_file.in: cannot close: $!\n";
739 ################################################################
741 # Handle AUTOMAKE_OPTIONS variable. Return 1 on error, 0 otherwise.
744 if (&variable_defined ('AUTOMAKE_OPTIONS'))
746 foreach (&variable_value_as_list ('AUTOMAKE_OPTIONS', ''))
749 if ($_ eq 'gnits' || $_ eq 'gnu' || $_ eq 'foreign')
751 &set_strictness ($_);
753 elsif ($_ eq 'cygnus')
759 # An option like "../lib/ansi2knr" is allowed. With
760 # no path prefix, we assume the required programs are
761 # in this directory. We save the actual option for
763 $options{'ansi2knr'} = $_;
765 elsif ($_ eq 'no-installman' || $_ eq 'no-installinfo'
766 || $_ eq 'dist-shar' || $_ eq 'dist-zip'
767 || $_ eq 'dist-tarZ' || $_ eq 'dist-bzip2'
768 || $_ eq 'dejagnu' || $_ eq 'no-texinfo.tex'
769 || $_ eq 'readme-alpha' || $_ eq 'check-news'
770 || $_ eq 'subdir-objects' || $_ eq 'nostdinc')
772 # Explicitly recognize these.
774 elsif ($_ eq 'no-dependencies')
776 $use_dependencies = 0;
778 elsif (/([0-9]+)\.([0-9]+)([a-z])?/)
780 # Got a version number.
782 local ($rmajor, $rminor, $ralpha) = ($1, $2, $3);
784 &prog_error ("version is incorrect: $VERSION")
785 if $VERSION !~ /([0-9]+)\.([0-9]+)([a-z])?/;
787 local ($tmajor, $tminor, $talpha) = ($1, $2, $3);
789 # 2.0 is better than 1.0.
790 # 1.2 is better than 1.1.
791 # 1.2a is better than 1.2.
792 if ($rmajor > $tmajor
793 || ($rmajor == $tmajor && $rminor > $tminor)
794 || ($rminor == $tminor && $rminor == $tminor
795 && $ralpha gt $talpha))
797 &am_line_error ('AUTOMAKE_OPTIONS',
798 "require version $_, only have $VERSION");
804 &am_line_error ('AUTOMAKE_OPTIONS',
805 "option \`" . $_ . "\' not recognized");
810 if ($strictness == $GNITS)
812 $options{'readme-alpha'} = 1;
813 $options{'check-news'} = 1;
820 # get_object_extension ($OUT)
821 # ---------------------------
822 # Return object extension. Just once, put some code into the output.
823 # OUT is the name of the output file
824 sub get_object_extension
828 # Maybe require libtool library object files.
829 local ($extension) = '.o';
830 $extension = '.$(OBJEXT)' if $seen_objext;
831 $extension = '.lo' if ($out =~ /\.la$/);
833 if (! $included_generic_compile)
836 local ($default_include) = '';
837 if (! defined $options{'nostdinc'})
839 $default_include = ' -I. -I$(srcdir)';
841 if (&variable_defined ('CONFIG_HEADER'))
844 foreach $one_hdr (split (' ',
845 &variable_value ('CONFIG_HEADER')))
847 $default_include .= ' -I' . &dirname ($one_hdr);
851 local ($xform) = &transform ('DEFAULT_INCLUDES' => $default_include);
852 $output_vars .= &file_contents ('comp-vars', $xform);
854 $xform = $seen_objext ? 's/^OBJEXT//;' : 's/^OBJEXT.*$//;';
855 $output_rules .= &file_contents ('compile', $xform);
857 # If using X, include some extra variable definitions. NOTE
858 # we don't want to force these into CFLAGS or anything,
859 # because not all programs will necessarily use X.
863 foreach $var ('X_CFLAGS', 'X_LIBS', 'X_EXTRA_LIBS', 'X_PRE_LIBS')
865 &define_configure_variable ($var);
869 push (@suffixes, '.c', '.o');
870 push (@suffixes, '.obj') if $seen_objext;
872 $included_generic_compile = 1;
875 if ($seen_libtool && ! $included_libtool_compile)
877 # Output the libtool compilation rules.
878 $output_rules .= &file_contents ('libtool');
880 push (@suffixes, '.lo');
882 $included_libtool_compile = 1;
885 # Check for automatic de-ANSI-fication.
886 if (defined $options{'ansi2knr'})
888 $extension = '$U' . $extension;
889 if (! $included_knr_compile)
891 if (! $am_c_prototypes)
893 &am_line_error ('AUTOMAKE_OPTIONS',
894 "option \`ansi2knr' in use but \`AM_C_PROTOTYPES' not in \`$configure_ac'");
895 &keyed_aclocal_warning ('AM_C_PROTOTYPES');
896 # Only give this error once.
897 $am_c_prototypes = 1;
900 # Only require ansi2knr files if they should appear in
902 if ($options{'ansi2knr'} eq 'ansi2knr')
904 &require_file_with_line ('AUTOMAKE_OPTIONS', $FOREIGN,
905 'ansi2knr.c', 'ansi2knr.1');
906 $output_rules .= &file_contents ('kr-extra');
909 # Generate rules to build ansi2knr. If it is in some
910 # other directory, then generate dependencies but have the
911 # rule just run elsewhere.
912 $objext = $seen_objext ? ".\$(OBJEXT)" : ".o";
913 $output_rules .= ($options{'ansi2knr'} . ': '
914 . $options{'ansi2knr'} . $objext . "\n");
915 if ($options{'ansi2knr'} eq 'ansi2knr')
917 $output_rules .= ("\t\$(LINK) ansi2knr" . $objext
919 . "ansi2knr" . $objext
920 . ": \$(CONFIG_HEADER)\n\n");
924 $output_rules .= ("\tcd " . &dirname ($options{'ansi2knr'})
925 . " && \$(MAKE) \$(AM_MAKEFLAGS) "
927 # This is required for non-GNU makes.
928 $output_rules .= ($options{'ansi2knr'} . $objext . ":\n");
929 $output_rules .= ("\tcd " . &dirname ($options{'ansi2knr'})
930 . " && \$(MAKE) \$(AM_MAKEFLAGS)"
931 . " ansi2knr" . $objext . "\n\n");
934 # Make sure ansi2knr can be found: if no path specified,
936 if ($options{'ansi2knr'} eq 'ansi2knr')
938 # Substitution from AM_C_PROTOTYPES. This makes it be
939 # built only when necessary.
940 &define_configure_variable ('ANSI2KNR');
941 # ansi2knr needs to be built before subdirs, so unshift it.
942 unshift (@all, '$(ANSI2KNR)');
946 # Found in another directory.
947 &define_variable ("ANSI2KNR", $options{'ansi2knr'});
950 $output_rules .= &file_contents ('clean-kr');
952 $included_knr_compile = 1;
959 # Call finish function for each language that was used.
962 local ($ltcompile, $ltlink) = &libtool_compiler;
964 local ($ext, $name, $lang, %done);
966 foreach $ext (sort keys %extension_seen)
968 $lang = $extension_map{$ext};
970 # Generate the appropriate rules for this extension. If
971 # dependency tracking was requested, and this extension
972 # supports it, then we don't generate the rule here.
975 if ($use_dependencies && $language_map{$lang . '-autodep'} ne 'no')
977 # Don't generate the rule, but still generate the variables.
978 if (defined $language_map{$lang . '-compile'})
980 $comp = $language_map{$lang . '-compile'};
983 elsif (defined $language_map{$lang . '-compile'})
985 $comp = $language_map{$lang . '-compile'};
987 local ($outarg) = $language_map{$lang . '-output-arg'};
988 if ($language_map{$lang . '-flags'} eq 'CFLAGS')
990 # C compilers don't always support -c -o.
991 if (defined $options{'subdir-objects'})
997 local ($full) = ("\t\$("
998 . $language_map{$lang . '-compiler-name'}
1001 $output_rules .= (".$ext.o:\n"
1004 # FIXME: Using cygpath should be somehow conditional.
1005 $output_rules .= (".$ext.obj:\n"
1007 . " \`cygpath -w \$<\`\n")
1009 $output_rules .= (".$ext.lo:\n"
1011 . $language_map{$lang . '-compiler-name'}
1013 . $language_map{$lang . '-output-arg'}
1014 # We can always use -c -o with libtool.
1015 . ($language_map{$lang . '-flags'} eq 'CFLAGS'
1021 push (@suffixes, '.' . $ext);
1023 # The rest of the loop is done once per language.
1024 next if defined $done{$lang};
1027 $non_c = 0 if $lang !~ /(objc|cxx|f77|ratfor)$/;
1031 &define_compiler_variable ($language_map{$lang . '-compiler-name'},
1034 # The compiler's flag must be a configure variable.
1035 if (defined $language_map{$lang . '-flags'})
1037 &define_configure_variable ($language_map{$lang . '-flags'});
1040 # Compute the function name of the finisher and then call it.
1041 $name = 'lang_' . $lang . '_finish';
1045 # If the project is entirely C++ or entirely Fortran 77, don't
1046 # bother with the C stuff. But if anything else creeps in, then use
1048 if ($need_link || ! $non_c || scalar keys %suffix_rules > 0)
1050 if (! defined $done{'c'})
1052 &define_configure_variable ($language_map{'c-flags'});
1053 &define_compiler_variable ($language_map{'c-compiler-name'},
1055 $language_map{'c-compile'});
1057 &define_variable ('CCLD', '$(CC)');
1058 &define_variable ('LINK', $ltlink . '$(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@');
1062 # Output a rule to build from a YACC source. The output from YACC is
1063 # compiled with C or C++, depending on the extension of the YACC file.
1064 sub output_yacc_build_rule
1066 local ($yacc_suffix, $use_ylwrap, $c_suffix) = @_;
1069 ($suffix = $yacc_suffix) =~ tr/y/c/;
1070 push (@suffixes, $yacc_suffix, $suffix);
1072 # Generate rule for c/c++.
1073 $output_rules .= "$yacc_suffix$suffix:\n\t";
1077 $output_rules .= ('$(SHELL) $(YLWRAP)'
1078 . ' "$(YACC)" $< y.tab.c $*' . $suffix
1079 . ' y.tab.h $*.h -- $(AM_YFLAGS) $(YFLAGS)');
1083 $output_rules .= ('$(YACC) $(AM_YFLAGS) $(YFLAGS) $< && mv y.tab.c $*'
1085 . "\tif test -f y.tab.h; then \\\n"
1086 . "\tif cmp -s y.tab.h \$*.h; then rm -f y.tab.h; else mv y.tab.h \$*.h; fi; \\\n"
1089 $output_rules .= "\n";
1092 sub output_lex_build_rule
1094 local ($lex_suffix, $use_ylwrap) = @_;
1097 ($c_suffix = $lex_suffix) =~ tr/l/c/;
1098 push (@suffixes, $lex_suffix);
1099 &define_configure_variable ('LEX_OUTPUT_ROOT');
1100 &define_configure_variable ('LEXLIB');
1101 $output_rules .= "$lex_suffix$c_suffix:\n\t";
1105 # Is the $@ correct here? If so, why not use it in the ylwrap
1106 # build rule for yacc above?
1107 $output_rules .= '$(SHELL) $(YLWRAP)'
1108 . ' "$(LEX)" $< $(LEX_OUTPUT_ROOT).c $@ -- $(AM_LFLAGS) $(LFLAGS)';
1112 $output_rules .= '$(LEX) $(AM_LFLAGS) $(LFLAGS) $< && mv $(LEX_OUTPUT_ROOT).c $@';
1114 $output_rules .= "\n";
1118 # Check to make sure a source defined in LIBOBJS is not explicitly
1119 # mentioned. This is a separate function (as opposed to being inlined
1120 # in handle_source_transform) because it isn't always appropriate to
1122 sub check_libobjs_sources
1124 local ($one_file, $unxformed) = @_;
1126 local ($prefix, $file, @files);
1127 foreach $prefix ('', 'EXTRA_', 'dist_', 'nodist_',
1128 'dist_EXTRA_', 'nodist_EXTRA_')
1130 if (&variable_defined ($prefix . $one_file . '_SOURCES'))
1132 @files = &variable_value_as_list (($prefix
1133 . $one_file . '_SOURCES'),
1136 elsif ($prefix eq '')
1138 @files = ($unxformed . '.c');
1145 foreach $file (@files)
1147 if (defined $libsources{$file})
1149 &am_line_error ($prefix . $one_file . '_SOURCES',
1150 "automatically discovered file \`$file' should not be explicitly mentioned");
1157 # ($LINKER, @OBJECTS)
1158 # handle_single_transform_list ($VAR, $DERIVED, $OBJ, @FILES)
1159 # -----------------------------------------------------------
1160 # Does much of the actual work for handle_source_transform.
1162 # $DERIVED is the name of resulting executable or library
1163 # $OBJ is the object extension (e.g., `$U.lo')
1164 # @FILES is the list of source files to transform
1166 # $LINKER is name of linker to use (empty string for default linker)
1167 # @OBJECTS are names of objects
1168 sub handle_single_transform_list
1170 local ($var, $derived, $obj, @files) = @_;
1171 local (@result) = ();
1172 local ($nonansi_obj) = $obj;
1173 $nonansi_obj =~ s/\$U//g;
1174 local (%linkers_used) = ();
1176 # Turn sources into objects.
1179 # Configure substitutions in _SOURCES variables are errors.
1182 &am_line_error ($var, "$var includes configure substitution \`$_'");
1186 # If the source file is in a subdirectory then the `.o' is
1187 # put into the current directory.
1189 # Split file name into base and extension.
1190 local ($full, $directory, $base, $extension, $linker, $object);
1191 next if ! /^((.*)\/)?([^\/]*)\.(.*)$/;
1197 local ($xbase) = $base;
1199 # We must generate a rule for the object if it requires
1202 local ($renamed) = 0;
1204 $extension = &derive_suffix ($extension);
1205 local ($lang) = $extension_map{$extension};
1208 &saw_extension ($extension);
1209 # Found the language, so see what it says.
1210 local ($subr) = 'lang_' . $lang . '_rewrite';
1211 # Note: computed subr call.
1212 local ($r) = & $subr ($directory, $base, $extension);
1213 # Skip this entry if we were asked not to process it.
1214 next if $r == $LANG_IGNORE;
1216 # Now extract linker and other info.
1217 $linker = $language_map{$lang . '-linker'};
1219 local ($this_obj_ext);
1220 if ($language_map{$lang . '-ansi-p'})
1222 $object = $base . $obj;
1223 $this_obj_ext = $obj;
1227 $object = $base . $nonansi_obj;
1228 $this_obj_ext = $nonansi_obj;
1231 if ($language_map{$lang . '-flags'} ne ''
1232 && &variable_defined ($derived . '_'
1233 . $language_map{$lang . '-flags'}))
1235 # We have a per-executable flag in effect for this
1236 # object. In this case we rewrite the object's
1237 # name to ensure it is unique. We also require
1238 # the `compile' program to deal with compilers
1239 # where `-c -o' does not work.
1241 # We choose the name `DERIVED-OBJECT' to ensure
1242 # (1) uniqueness, and (2) continuity between
1243 # invocations. However, this will result in a
1244 # name that is too long for losing systems, in
1245 # some situations. So we provide _SHORTNAME to
1248 local ($dname) = $derived;
1249 if (&variable_defined ($derived . '_SHORTNAME'))
1251 # FIXME: should use the same conditional as
1252 # the _SOURCES variable. But this is really
1253 # silly overkill -- nobody should have
1254 # conditional shortnames.
1255 $dname = &variable_value ($derived . '_SHORTNAME');
1257 $object = $dname . '-' . $object;
1259 &require_file ($FOREIGN, 'compile')
1262 &prog_error ("$lang flags defined without compiler")
1263 if ! defined $language_map{$lang . '-compile'};
1265 # Compute the rule to compile this object.
1266 local ($flag) = $language_map{$lang . '-flags'};
1267 local ($val) = "(${derived}_${flag}";
1268 ($rule = $language_map{$lang . '-compile'}) =~
1271 $rule .= ' ' . $language_map{$lang . '-output-arg'};
1272 # For C we have to add the -o, because the
1273 # standard rule doesn't include it.
1274 if ($language_map{$lang . '-flags'} eq 'CFLAGS')
1282 # If rewrite said it was ok, put the object into a
1284 if ($r == $LANG_SUBDIR && $directory ne '')
1286 $object = $directory . '/' . $object;
1287 $xbase = $directory . '/' . $base;
1290 # If doing dependency tracking, then we can't print
1291 # the rule. If we have a subdir object, we need to
1292 # generate an explicit rule. Actually, in any case
1293 # where the object is not in `.' we need a special
1294 # rule. The per-object rules in this case are
1295 # generated later, by add_depend2.
1296 if (($use_dependencies
1298 && $language_map{$lang . '-autodep'} ne 'no')
1299 || $directory ne '')
1302 local ($obj_sans_ext) = substr ($object, 0,
1303 - length ($this_obj_ext));
1304 $lang_specific_files{$lang} .= (' ' . $derived
1306 . ' ' . $obj_sans_ext);
1309 elsif ($extension eq 'o')
1311 # This is probably the result of a direct suffix rule.
1312 # In this case we just accept the rewrite. FIXME:
1313 # this fails if we want libtool objects.
1314 $object = $base . '.' . $extension;
1319 # No error message here. Used to have one, but it was
1324 $linkers_used{$linker} = 1;
1326 push (@result, $object);
1328 if (defined $object_map{$object})
1330 if ($object_map{$object} ne $full)
1332 &am_error ("object \`$object' created by \`$full' and \`$object_map{$object}'");
1337 local (@dep_list) = ();
1338 $object_map{$object} = $full;
1340 # If file is in subdirectory, we need explicit
1342 if ($directory ne '' || $renamed)
1344 push (@dep_list, $full);
1347 # If resulting object is in subdir, we need to make
1348 # sure the subdir exists at build time.
1349 if ($object =~ /\//)
1351 # FIXME: check that $DIRECTORY is somewhere in the
1354 # We don't allow `..' in object file names for
1355 # *any* source, not just Java. For Java it just
1356 # doesn't make sense, but in general it is
1357 # a problem because we can't pick a good name for
1359 if ($object =~ /(\/|^)\.\.\//)
1361 &am_error ("\`$full' contains \`..' component but should not");
1364 push (@dep_list, $directory . '/.dirstamp');
1366 # If we're generating dependencies, we also want
1367 # to make sure that the appropriate subdir of the
1368 # .deps directory is created.
1369 if ($use_dependencies)
1371 push (@dep_list, '.deps/' . $directory . '/.dirstamp');
1374 if (! defined $directory_map{$directory})
1376 $directory_map{$directory} = 1;
1377 $output_rules .= ($directory . "/.dirstamp:\n"
1378 . "\t\@\$(mkinstalldirs) $directory\n"
1379 . "\t\@: > $directory/.dirstamp\n");
1380 if ($use_dependencies)
1382 $output_rules .= ('.deps/' . $directory
1384 . "\t\@\$(mkinstalldirs) .deps/$directory\n"
1385 . "\t\@: > .deps/$directory/.dirstamp\n");
1390 &pretty_print_rule ($object . ':', "\t", @dep_list)
1391 if scalar @dep_list > 0 || $rule ne '';
1393 # Print the rule if we have one.
1396 # Turn `$@' into name of our object file.
1398 ($xform = $object) =~ s,/,\\/,g;
1399 $rule =~ s/\$\@/$xform/;
1401 # We cannot use $< here since this is an explicit
1402 # rule and not all makes handle that.
1403 $rule .= " \`test -f $full || echo '\$(srcdir)/'\`$full";
1405 # FIXME: handle .lo and .obj as well.
1406 $output_rules .= "\t" . $rule . "\n";
1410 # Transform .o or $o file into .P file (for automatic
1413 && ($language_map{$lang . '-autodep'} ne 'no'
1414 || $language_map{$lang . '-derived-autodep'} eq 'yes'))
1416 local ($depfile) = $object;
1417 $depfile =~ s/\.([^.]*)$/.P$1/;
1418 $depfile =~ s/\$\(OBJEXT\)$/o/ if $seen_objext;
1419 $dep_files{'$(DEPDIR)/' . $depfile} = 1;
1423 return (&resolve_linker (%linkers_used), @result);
1428 # Handle SOURCE->OBJECT transform for one program or library.
1430 # canonical (transformed) name of object to build
1431 # actual name of object to build
1432 # object extension (ie either `.o' or `$o'.
1433 # Return result is name of linker variable that must be used.
1434 # Empty return means just use `LINK'.
1435 sub handle_source_transform
1437 # one_file is canonical name. unxformed is given name. obj is
1439 local ($one_file, $unxformed, $obj) = @_;
1441 local ($linker) = '';
1443 if (&variable_defined ($one_file . "_OBJECTS"))
1445 &am_line_error ($one_file . '_OBJECTS',
1446 $one_file . '_OBJECTS', 'should not be defined');
1447 # No point in continuing.
1451 local (@files, @result, $prefix, $temp, $xpfx);
1452 local (%used_pfx) = ();
1453 foreach $prefix ('', 'EXTRA_', 'dist_', 'nodist_',
1454 'dist_EXTRA_', 'nodist_EXTRA_')
1456 # We are going to define _OBJECTS variables using the prefix.
1457 # Then we glom them all together. So we can't use the null
1458 # prefix here as we need it later.
1459 $xpfx = ($prefix eq '') ? 'am_' : $prefix;
1462 local ($var) = $prefix . $one_file . "_SOURCES";
1463 if (&variable_defined ($var))
1465 # Keep track of which prefixes we saw.
1466 $used_pfx{$xpfx} = 1
1467 unless $prefix =~ /EXTRA_/;
1469 push (@sources, '$(' . $prefix . $one_file . "_SOURCES)");
1470 push (@objects, '$(' . $xpfx . $one_file . "_OBJECTS)")
1471 unless $prefix =~ /EXTRA_/;
1472 push (@dist_sources, '$(' . $prefix . $one_file . "_SOURCES)")
1473 unless $prefix =~ /^nodist_/;
1474 local (@conds) = &variable_conditions ($var);
1477 @files = &variable_value_as_list ($var, '');
1482 foreach $cond (@conds)
1484 @files = &variable_value_as_list ($var, $cond);
1486 &handle_single_transform_list ($var, $one_file, $obj,
1488 $linker = $temp if $linker eq '';
1490 # Define _OBJECTS conditionally.
1491 &define_pretty_variable ($xpfx . $one_file . '_OBJECTS',
1493 unless $prefix =~ /EXTRA_/;
1500 # Avoid defining needless variables.
1501 next if (scalar @files == 0);
1503 ($temp, @result) = &handle_single_transform_list ($var, $one_file,
1505 $linker = $temp if $linker eq '';
1506 &define_pretty_variable ($xpfx . $one_file . "_OBJECTS", '', @result)
1507 unless $prefix =~ /EXTRA_/;
1510 local (@keys) = sort keys %used_pfx;
1511 if (scalar @keys == 0)
1513 &define_variable ($one_file . "_SOURCES", $unxformed . ".c");
1514 push (@sources, $unxformed . '.c');
1515 push (@dist_sources, $unxformed . '.c');
1516 push (@objects, $unxformed . $obj);
1517 push (@files, $unxformed . '.c');
1519 ($temp, @result) = &handle_single_transform_list ($one_file . '_SOURCES',
1522 $linker = $temp if $linker eq '';
1523 &define_pretty_variable ($one_file . "_OBJECTS", '', @result)
1527 grep ($_ = '$(' . $_ . $one_file . '_OBJECTS)', @keys);
1528 &define_pretty_variable ($one_file . '_OBJECTS', '', @keys);
1531 # If we want to use `LINK' we must make sure it is defined.
1541 # handle_lib_objects ()
1542 # ---------------------
1543 # Special-case @ALLOCA@ and @LIBOBJS@ in _LDADD or _LIBADD variables.
1544 # Also, generate _DEPENDENCIES variable if appropriate.
1546 # transformed name of object being built, or empty string if no object
1547 # name of _LDADD/_LIBADD-type variable to examine
1548 # boolean (lex_seen) which is true if a lex source file was seen in this
1549 # object. valid only for LDADDs, not LIBADDs.
1550 # Returns 1 if LIBOBJS seen, 0 otherwise.
1551 sub handle_lib_objects
1553 local ($xname, $var, $lex_seen) = @_;
1556 &prog_error ("handle_lib_objects: $var undefined")
1557 if ! &variable_defined ($var);
1559 &prog_error ("handle_lib_objects: lex_seen and $var =~ /LIBADD/")
1560 if $lex_seen && $var =~ /LIBADD/;
1562 local (@conds) = &variable_conditions ($var);
1565 $ret = &handle_lib_objects_cond ($xname, $var, $lex_seen, '');
1571 foreach $cond (@conds)
1573 if (&handle_lib_objects_cond ($xname, $var, $lex_seen, $cond))
1583 # Subroutine of handle_lib_objects: handle a particular condition.
1584 sub handle_lib_objects_cond
1586 local ($xname, $var, $lex_seen, $cond) = @_;
1588 # We recognize certain things that are commonly put in LIBADD or
1591 local (@dep_list) = ();
1593 local ($seen_libobjs) = 0;
1594 local ($flagvar) = 0;
1596 foreach $lsearch (&variable_value_as_list ($var, $cond))
1598 # Skip -lfoo and -Ldir; these are explicitly allowed.
1599 next if $lsearch =~ /^-[lL]/;
1600 if (! $flagvar && $lsearch =~ /^-/)
1602 if ($var =~ /^(.*)LDADD$/)
1604 # Skip -dlopen and -dlpreopen; these are explicitly allowed.
1605 next if $lsearch =~ /^-dl(pre)?open$/;
1606 &am_line_error ($var, "linker flags such as \`$lsearch' belong in \`${1}LDFLAGS");
1610 # Only get this error once.
1612 &am_line_error ($var, "linker flags such as \`$lsearch' belong in \`${1}LDFLAGS");
1616 # Assume we have a file of some sort, and push it onto the
1617 # dependency list. Autoconf substitutions are not pushed;
1618 # rarely is a new dependency substituted into (eg) foo_LDADD
1619 # -- but "bad things (eg -lX11) are routinely substituted.
1620 # Note that LIBOBJS and ALLOCA are exceptions to this rule,
1621 # and handled specially below.
1622 push (@dep_list, $lsearch)
1623 unless $lsearch =~ /^\@.*\@$/;
1625 # Automatically handle @LIBOBJS@ and @ALLOCA@. Basically this
1626 # means adding entries to dep_files.
1627 if ($lsearch =~ /^\@(LT)?LIBOBJS\@$/)
1629 local ($myobjext) = ($1 ? 'l' : '') . 'o';
1631 push (@dep_list, $lsearch);
1633 if (! keys %libsources
1634 && ! &variable_defined ($1 . 'LIBOBJS'))
1636 &am_line_error ($var, "\@$1" . "LIBOBJS\@ seen but never set in \`$configure_ac'");
1639 local ($iter, $rewrite);
1640 foreach $iter (keys %libsources)
1642 if ($iter =~ /\.([cly])$/)
1644 &saw_extension ($1);
1645 &saw_extension ('c');
1648 if ($iter =~ /\.h$/)
1650 &require_file_with_line ($var, $FOREIGN, $iter);
1652 elsif ($iter ne 'alloca.c')
1654 ($rewrite = $iter) =~ s/\.c$/.P$myobjext/;
1655 $dep_files{'$(DEPDIR)/' . $rewrite} = 1;
1656 ($rewrite = $iter) =~ s/(\W)/\\$1/g;
1657 $rewrite = "^" . $rewrite . "\$";
1658 # Only require the file if it is not a built source.
1659 if (! &variable_defined ('BUILT_SOURCES')
1660 || ! grep (/$rewrite/,
1661 &variable_value_as_list ('BUILT_SOURCES',
1664 &require_file_with_line ($var, $FOREIGN, $iter);
1669 elsif ($lsearch =~ /^\@(LT)?ALLOCA\@$/)
1671 local ($myobjext) = ($1 ? 'l' : '') . 'o';
1673 push (@dep_list, $lsearch);
1674 &am_line_error ($var,
1675 "\@$1" . "ALLOCA\@ seen but \`AC_FUNC_ALLOCA' not in \`$configure_ac'")
1676 if ! defined $libsources{'alloca.c'};
1677 $dep_files{'$(DEPDIR)/alloca.P' . $myobjext} = 1;
1678 &require_file_with_line ($var, $FOREIGN, 'alloca.c');
1679 &saw_extension ('c');
1683 if ($xname ne '' && ! &variable_defined ($xname . '_DEPENDENCIES', $cond))
1685 &define_pretty_variable ($xname . '_DEPENDENCIES', $cond, @dep_list);
1688 return $seen_libobjs;
1691 # Canonicalize a name, and check to make sure the non-canonical name
1692 # is never used. Returns canonical name. Arguments are name and a
1693 # list of suffixes to check for.
1694 sub check_canonical_spelling
1696 local ($name, @suffixes) = @_;
1697 local ($xname, $xt);
1699 ($xname = $name) =~ tr/A-Za-z0-9_/_/c;
1700 if ($xname ne $name)
1703 foreach $xt (@suffixes)
1705 &am_line_error ($name . $xt,
1706 "invalid variable \`" . $name . $xt
1707 . "'; should be \`" . $xname . $xt . "'")
1708 if &variable_defined ($name . $xt);
1716 # handle_programs ()
1717 # ------------------
1718 # Handle C programs.
1721 local (@proglist) = &am_install_var ('-clean',
1722 'progs', 'PROGRAMS',
1723 'bin', 'sbin', 'libexec', 'pkglib',
1725 return if ! @proglist;
1727 # If a program is installed, this is required. We only want this
1728 # error to appear once.
1729 &am_conf_error ("AC_ARG_PROGRAM must be used")
1730 unless $seen_arg_prog;
1733 local ($one_file, $xname, $munge);
1735 local ($seen_libobjs) = 0;
1736 foreach $one_file (@proglist)
1738 local ($obj) = &get_object_extension ($one_file);
1740 # Canonicalize names and check for misspellings.
1741 $xname = &check_canonical_spelling ($one_file, '_LDADD', '_LDFLAGS',
1742 '_SOURCES', '_OBJECTS',
1745 # FIXME: Using a trick to figure out if any lex sources appear
1746 # in our program; should use some cleaner method.
1747 local ($lex_num) = scalar (keys %lex_sources);
1748 local ($linker) = &handle_source_transform ($xname, $one_file, $obj);
1749 local ($lex_file_seen) = (scalar (keys %lex_sources) > $lex_num);
1752 if (&variable_defined ($xname . "_LDADD"))
1754 if (&handle_lib_objects ($xname, $xname . '_LDADD',
1764 # User didn't define prog_LDADD override. So do it.
1765 &define_variable ($xname . '_LDADD', '$(LDADD)');
1767 # This does a bit too much work. But we need it to
1768 # generate _DEPENDENCIES when appropriate.
1769 if (&variable_defined ('LDADD'))
1771 if (&handle_lib_objects ($xname, 'LDADD', $lex_file_seen))
1777 elsif (! &variable_defined ($xname . '_DEPENDENCIES'))
1779 &define_variable ($xname . '_DEPENDENCIES', '');
1784 if (&variable_defined ($xname . '_LIBADD'))
1786 &am_line_error ($xname . '_LIBADD',
1787 "use \`" . $xname . "_LDADD', not \`"
1788 . $xname . "_LIBADD'");
1791 if (! &variable_defined ($xname . '_LDFLAGS'))
1793 # Define the prog_LDFLAGS variable.
1794 &define_variable ($xname . '_LDFLAGS', '');
1797 # Determine program to use for link.
1799 if (&variable_defined ($xname . '_LINK'))
1801 $xlink = $xname . '_LINK';
1805 $xlink = $linker ? $linker : 'LINK';
1808 local ($exeext) = '';
1809 if ($seen_exeext && $one_file !~ /\./)
1811 $exeext = '$(EXEEXT)';
1814 $output_rules .= &file_contents ('program',
1815 &transform ('EXEEXT' => $exeext,
1816 'PROGRAM' => $one_file,
1817 'XPROGRAM' => $xname,
1818 'XLINK' => $xlink));
1821 if (&variable_defined ('LDADD') && &handle_lib_objects ('', 'LDADD', 0))
1828 foreach $one_file (@proglist)
1830 # Canonicalize names.
1831 ($xname = $one_file) =~ tr/A-Za-z0-9_/_/c;
1833 if (&variable_defined ($xname . '_LDADD'))
1835 &check_libobjs_sources ($xname, $xname . '_LDADD');
1837 elsif (&variable_defined ('LDADD'))
1839 &check_libobjs_sources ($xname, 'LDADD');
1846 # handle_libraries ()
1847 # -------------------
1849 sub handle_libraries
1851 local (@liblist) = &am_install_var ('-clean',
1852 'libs', 'LIBRARIES',
1853 'lib', 'pkglib', 'noinst', 'check');
1854 return if ! @liblist;
1856 local (%valid) = &am_primary_prefixes ('LIBRARIES', 0, 'lib', 'pkglib',
1858 if (! defined $configure_vars{'RANLIB'})
1861 foreach $key (keys %valid)
1863 if (&variable_defined ($key . '_LIBRARIES'))
1865 &am_line_error ($key . '_LIBRARIES', "library used but \`RANLIB' not defined in \`$configure_ac'");
1866 # Only get this error once. If this is ever printed,
1868 $configure_vars{'RANLIB'} = 'BUG';
1877 local ($seen_libobjs) = 0;
1878 foreach $onelib (@liblist)
1880 # Check that the library fits the standard naming convention.
1881 if ($onelib !~ /^lib.*\.a$/)
1883 # FIXME should put line number here. That means mapping
1884 # from library name back to variable name.
1885 &am_error ("\`$onelib' is not a standard library name");
1888 local ($obj) = &get_object_extension ($onelib);
1890 # Canonicalize names and check for misspellings.
1891 $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_SOURCES',
1892 '_OBJECTS', '_DEPENDENCIES', '_AR');
1894 if (! &variable_defined ($xlib . '_AR'))
1896 &define_variable ($xlib . '_AR', '$(AR) cru');
1899 if (&variable_defined ($xlib . '_LIBADD'))
1901 if (&handle_lib_objects ($xlib, $xlib . '_LIBADD', 0))
1908 # Generate support for conditional object inclusion in
1910 &define_variable ($xlib . "_LIBADD", '');
1913 if (&variable_defined ($xlib . '_LDADD'))
1915 &am_line_error ($xlib . '_LDADD',
1916 "use \`" . $xlib . "_LIBADD', not \`"
1917 . $xlib . "_LDADD'");
1920 # Make sure we at look at this.
1921 &examine_variable ($xlib . '_DEPENDENCIES');
1923 &handle_source_transform ($xlib, $onelib, $obj);
1925 $output_rules .= &file_contents ('library',
1926 &transform ('LIBRARY' => $onelib,
1927 'XLIBRARY' => $xlib));
1932 foreach $onelib (@liblist)
1934 # Canonicalize names.
1935 ($xlib = $onelib) =~ tr/A-Za-z0-9_/_/c;
1936 if (&variable_defined ($xlib . '_LIBADD'))
1938 &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
1943 &define_variable ('AR', 'ar');
1944 &define_configure_variable ('RANLIB');
1948 # handle_ltlibraries ()
1949 # ---------------------
1950 # Handle shared libraries.
1951 sub handle_ltlibraries
1953 local (@liblist) = &am_install_var ('-clean',
1954 'ltlib', 'LTLIBRARIES',
1955 'noinst', 'lib', 'pkglib', 'check');
1956 return if ! @liblist;
1959 local (%valid) = &am_primary_prefixes ('LTLIBRARIES', 0, 'lib', 'pkglib',
1963 foreach $key (keys %valid)
1965 if (&variable_defined ($key . '_LTLIBRARIES'))
1969 &am_line_error ($key . '_LTLIBRARIES', "library used but \`LIBTOOL' not defined in \`$configure_ac'");
1970 # Only get this error once. If this is ever printed,
1972 $configure_vars{'LIBTOOL'} = 'BUG';
1976 # Get the installation directory of each library.
1977 for (&variable_value_as_list ($key . '_LTLIBRARIES', 'all'))
1981 &am_error ("\`$_' is already going to be installed in \`$instdirs{$_}'");
1985 $instdirs{$_} = $key;
1994 local ($seen_libobjs) = 0;
1995 foreach $onelib (@liblist)
1997 local ($obj) = &get_object_extension ($onelib);
1999 # Canonicalize names and check for misspellings.
2000 $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_LDFLAGS',
2001 '_SOURCES', '_OBJECTS',
2004 if (! &variable_defined ($xlib . '_LDFLAGS'))
2006 # Define the lib_LDFLAGS variable.
2007 &define_variable ($xlib . '_LDFLAGS', '');
2010 # Check that the library fits the standard naming convention.
2011 $libname_rx = "^lib.*\.la";
2012 if ((&variable_defined ($xlib . '_LDFLAGS')
2013 && grep (/-module/, &variable_value_as_list ($xlib . '_LDFLAGS',
2015 || (&variable_defined ('LDFLAGS')
2016 && grep (/-module/, &variable_value_as_list ('LDFLAGS',
2019 # Relax name checking for libtool modules.
2020 $libname_rx = "\.la";
2022 if ($onelib !~ /$libname_rx$/)
2024 # FIXME this should only be a warning for foreign packages
2025 # FIXME should put line number here. That means mapping
2026 # from library name back to variable name.
2027 &am_error ("\`$onelib' is not a standard libtool library name");
2030 if (&variable_defined ($xlib . '_LIBADD'))
2032 if (&handle_lib_objects ($xlib, $xlib . '_LIBADD', 0))
2039 # Generate support for conditional object inclusion in
2041 &define_variable ($xlib . "_LIBADD", '');
2044 if (&variable_defined ($xlib . '_LDADD'))
2046 &am_line_error ($xlib . '_LDADD',
2047 "use \`" . $xlib . "_LIBADD', not \`"
2048 . $xlib . "_LDADD'");
2051 # Make sure we at look at this.
2052 &examine_variable ($xlib . '_DEPENDENCIES');
2054 local ($linker) = &handle_source_transform ($xlib, $onelib, $obj);
2056 # Determine program to use for link.
2058 if (&variable_defined ($xlib . '_LINK'))
2060 $xlink = $xlib . '_LINK';
2064 $xlink = $linker ? $linker : 'LINK';
2068 if ($instdirs{$onelib} eq 'EXTRA'
2069 || $instdirs{$onelib} eq 'noinst'
2070 || $instdirs{$onelib} eq 'check')
2072 # It's an EXTRA_ library, so we can't specify -rpath,
2073 # because we don't know where the library will end up.
2074 # The user probably knows, but generally speaking automake
2075 # doesn't -- and in fact configure could decide
2076 # dynamically between two different locations.
2081 $rpath = ('-rpath $(' . $instdirs{$onelib} . 'dir)');
2084 $output_rules .= &file_contents ('ltlibrary',
2085 &transform ('LTLIBRARY' => $onelib,
2086 'XLTLIBRARY' => $xlib,
2088 'XLINK' => $xlink));
2093 foreach $onelib (@liblist)
2095 # Canonicalize names.
2096 ($xlib = $onelib) =~ tr/A-Za-z0-9_/_/c;
2097 if (&variable_defined ($xlib . '_LIBADD'))
2099 &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
2105 # See if any _SOURCES variable were misspelled. Also, make sure that
2106 # EXTRA_ variables don't contain configure substitutions.
2109 local ($varname, $primary);
2110 foreach $varname (keys %contents)
2112 foreach $primary ('_SOURCES', '_LIBADD', '_LDADD', '_LDFLAGS',
2115 if ($varname =~ /$primary$/ && ! $content_seen{$varname})
2117 &am_line_error ($varname,
2118 "invalid unused variable name: \`$varname'");
2127 # NOTE we no longer automatically clean SCRIPTS, because it is
2128 # useful to sometimes distribute scripts verbatim. This happens
2129 # eg in Automake itself.
2130 &am_install_var ('-candist', 'scripts', 'SCRIPTS',
2131 'bin', 'sbin', 'libexec', 'pkgdata',
2134 local ($scripts_installed) = 0;
2135 # Set $scripts_installed if appropriate. Make sure we only find
2136 # scripts which are actually installed -- this is why we can't
2137 # simply use the return value of am_install_var.
2138 local (%valid) = &am_primary_prefixes ('SCRIPTS', 1, 'bin', 'sbin',
2139 'libexec', 'pkgdata',
2142 foreach $key (keys %valid)
2144 if ($key ne 'noinst'
2146 && &variable_defined ($key . '_SCRIPTS'))
2148 $scripts_installed = 1;
2149 # push (@check_tests, 'check-' . $key . 'SCRIPTS');
2153 if ($scripts_installed)
2155 # If a program is installed, this is required. We only want this
2156 # error to appear once.
2157 &am_conf_error ("AC_ARG_PROGRAM must be used")
2158 unless $seen_arg_prog;
2163 # Search a file for a "version.texi" Texinfo include. Return the name
2164 # of the include file if found, or the empty string if not. A
2165 # "version.texi" file is actually any file whose name matches
2167 sub scan_texinfo_file
2169 local ($filename) = @_;
2171 if (! open (TEXI, $filename))
2173 &am_error ("couldn't open \`$filename': $!");
2176 print "automake: reading $filename\n" if $verbose;
2178 local ($vfile, $outfile);
2181 if (/^\@setfilename +(\S+)/)
2187 if (/^\@include\s+(vers[^.]*\.texi)\s*$/)
2189 # Found version.texi include.
2196 return ($outfile, $vfile);
2202 # Handle all Texinfo source.
2205 &am_line_error ('TEXINFOS',
2206 "\`TEXINFOS' is an anachronism; use \`info_TEXINFOS'")
2207 if &variable_defined ('TEXINFOS');
2208 return if (! &variable_defined ('info_TEXINFOS')
2209 && ! &variable_defined ('html_TEXINFOS'));
2211 if (&variable_defined ('html_TEXINFOS'))
2213 &am_line_error ('html_TEXINFOS',
2214 "HTML generation not yet supported");
2218 local (@texis) = &variable_value_as_list ('info_TEXINFOS', 'all');
2220 local (@info_deps_list, @dvis_list, @texi_deps);
2221 local ($infobase, $info_cursor);
2225 local ($tc_cursor, @texi_cleans);
2228 foreach $info_cursor (@texis)
2230 # FIXME: This is mildly hacky, since it recognizes "txinfo".
2231 # I don't feel like making it right.
2232 ($infobase = $info_cursor) =~ s/\.te?xi(nfo)?$//;
2234 # If 'version.texi' is referenced by input file, then include
2235 # automatic versioning capability.
2236 local ($out_file, $vtexi) = &scan_texinfo_file ($relative_dir
2237 . "/" . $info_cursor);
2239 if ($out_file eq '')
2241 &am_error ("\`$info_cursor' missing \@setfilename");
2245 if ($out_file =~ /\.(.+)$/ && $1 ne 'info')
2247 # FIXME should report line number in input file.
2248 &am_error ("output of \`$info_cursor', \`$out_file', has unrecognized extension");
2254 &am_error ("\`$vtexi', included in \`$info_cursor', also included in \`$versions{$vtexi}'")
2255 if (defined $versions{$vtexi});
2256 $versions{$vtexi} = $info_cursor;
2258 # We number the stamp-vti files. This is doable since the
2259 # actual names don't matter much. We only number starting
2260 # with the second one, so that the common case looks nice.
2261 $vti = ($done ? $done : 'vti');
2264 &push_dist_common ($vtexi, 'stamp-' . $vti);
2266 &require_conf_file_with_line ('info_TEXINFOS', $FOREIGN,
2270 if ($config_aux_dir eq '.' || $config_aux_dir eq '')
2272 $conf_dir = '$(srcdir)/';
2276 $conf_dir = $config_aux_dir;
2277 $conf_dir .= '/' unless $conf_dir =~ /\/$/;
2280 &file_contents ('texi-vers',
2281 &transform ('TEXI' => $info_cursor,
2284 'MDDIR' => $conf_dir,
2285 'CONFIGURE_AC' => $configure_ac));
2288 # If user specified file_TEXINFOS, then use that as explicit
2291 push (@texi_deps, $info_cursor);
2292 # Prefix with $(srcdir) because some version of make won't
2293 # work if the target has it and the dependency doesn't.
2294 push (@texi_deps, '$(srcdir)/' . $vtexi) if $vtexi;
2296 # Canonicalize name first.
2297 ($canonical = $infobase) =~ tr/A-Za-z0-9_/_/c;
2298 if (&variable_defined ($canonical . "_TEXINFOS"))
2300 push (@texi_deps, '$(' . $canonical . '_TEXINFOS)');
2301 &push_dist_common ('$(' . $canonical . '_TEXINFOS)');
2304 $output_rules .= ("\n" . $out_file . ": "
2305 . join (' ', @texi_deps)
2306 . "\n" . $infobase . ".dvi: "
2307 . join (' ', @texi_deps)
2310 push (@info_deps_list, $out_file);
2311 push (@dvis_list, $infobase . '.dvi');
2313 # Generate list of things to clean for this target. We do
2314 # this explicitly because otherwise too many things could be
2315 # removed. In particular the ".log" extension might
2316 # reasonably be used in other contexts by the user.
2317 # FIXME: this is really out of control.
2318 foreach $tc_cursor ('aux', 'cp', 'cps', 'dvi', 'fn', 'fns', 'pgs',
2319 'ky', 'kys', 'ps', 'log', 'pg', 'toc', 'tp', 'tps',
2320 'vr', 'vrs', 'op', 'tr', 'cv', 'cn', 'cm', 'ov')
2322 push (@texi_cleans, $infobase . '.' . $tc_cursor);
2326 # Find these programs wherever they may lie. Yes, this has
2327 # intimate knowledge of the structure of the texinfo distribution.
2328 &define_program_variable ('MAKEINFO', 'build', 'texinfo/makeinfo',
2330 # Circumlocution to avoid accidental
2331 # configure substitution.
2333 &define_program_variable ('TEXI2DVI', 'src', 'texinfo/util',
2336 # Set transform for including texinfos.am. First, handle --cygnus
2341 $xform = 's/^NOTCYGNUS.*$//; s/^CYGNUS//;';
2345 $xform = 's/^CYGNUS.*$//; s/^NOTCYGNUS//;';
2348 # Handle location of texinfo.tex.
2349 local ($need_texi_file) = 0;
2350 local ($texinfodir);
2353 $texinfodir = '$(top_srcdir)/../texinfo';
2354 &define_variable ('TEXINFO_TEX', "$texinfodir/texinfo.tex");
2357 elsif ($config_aux_dir ne '.' && $config_aux_dir ne '')
2359 $texinfodir = $config_aux_dir;
2360 &define_variable ('TEXINFO_TEX', "$texinfodir/texinfo.tex");
2361 $need_texi_file = 2; # so that we require_conf_file later
2363 elsif (&variable_defined ('TEXINFO_TEX'))
2365 # The user defined TEXINFO_TEX so assume he knows what he is
2367 $texinfodir = ('$(srcdir)/'
2368 . &dirname (&variable_value ('TEXINFO_TEX')));
2372 $texinfodir = '$(srcdir)';
2373 $need_texi_file = 1;
2375 $xform .= &transform ('TEXINFODIR' => $texinfodir,
2376 'TEXICLEAN' => &pretty_print_internal ("\t-rm -f",
2380 $output_rules .= &file_contents ('texinfos', $xform);
2381 push (@dist_targets, 'dist-info');
2385 $output_rules .= "clean-info: mostlyclean-aminfo\n";
2388 push (@suffixes, '.texi', '.texinfo', '.txi', '.info', '.dvi', '.ps');
2390 if (! defined $options{'no-installinfo'})
2392 push (@uninstall, 'uninstall-info');
2393 push (@installdirs, '$(DESTDIR)$(infodir)');
2394 unshift (@install_data, 'install-info-am');
2396 # Make sure documentation is made and installed first. Use
2397 # $(INFO_DEPS), not 'info', because otherwise recursive makes
2398 # get run twice during "make all".
2399 unshift (@all, '$(INFO_DEPS)');
2401 push (@info, '$(INFO_DEPS)');
2402 push (@dvi, '$(DVIS)');
2404 &define_variable ("INFO_DEPS", join (' ', @info_deps_list));
2405 &define_variable ("DVIS", join (' ', @dvis_list));
2406 # This next isn't strictly needed now -- the places that look here
2407 # could easily be changed to look in info_TEXINFOS. But this is
2408 # probably better, in case noinst_TEXINFOS is ever supported.
2409 &define_variable ("TEXINFOS", &variable_value ('info_TEXINFOS'));
2411 # Do some error checking. Note that this file is not required
2412 # when in Cygnus mode; instead we defined TEXINFO_TEX explicitly
2414 if ($need_texi_file && ! defined $options{'no-texinfo.tex'})
2416 if ($need_texi_file > 1)
2418 &require_conf_file_with_line ('info_TEXINFOS', $FOREIGN,
2423 &require_file_with_line ('info_TEXINFOS', $FOREIGN, 'texinfo.tex');
2428 # Handle any man pages.
2429 sub handle_man_pages
2431 &am_line_error ('MANS', "\`MANS' is an anachronism; use \`man_MANS'")
2432 if &variable_defined ('MANS');
2434 # Find all the sections in use. We do this by first looking for
2435 # "standard" sections, and then looking for any additional
2436 # sections used in man_MANS.
2437 local ($sect, %sections, %vlist);
2439 # Add more sections as needed.
2440 foreach $sect ('0'..'9', 'n', 'l')
2442 if (&variable_defined ('man' . $sect . '_MANS'))
2444 $sections{$sect} = 1;
2445 $vlist{'$(man' . $sect . '_MANS)'} = 1;
2450 if (&variable_defined ('man_MANS'))
2452 $vlist{'$(man_MANS)'} = 1;
2453 foreach (&variable_value_as_list ('man_MANS', 'all'))
2455 # A page like `foo.1c' goes into man1dir.
2456 if (/\.([0-9a-z])([a-z]*)$/)
2464 return unless $found;
2466 # Now for each section, generate an install and unintall rule.
2467 # Sort sections so output is deterministic.
2469 foreach $sect (sort keys %sections)
2471 &define_variable ('man' . $sect . 'dir', '$(mandir)/man' . $sect);
2472 push (@installdirs, '$(DESTDIR)$(mandir)/man' . $sect)
2473 unless defined $options{'no-installman'};
2474 $output_rules .= &file_contents ('mans',
2475 &transform ('SECTION', $sect));
2476 push (@namelist, 'install-man' . $sect);
2479 # We don't really need this, but we use it in case we ever want to
2480 # support noinst_MANS.
2481 &define_variable ("MANS", join (' ', sort keys %vlist));
2483 # Generate list of install dirs.
2484 $output_rules .= ("install-man: \$(MANS)\n"
2485 . "\t\@\$(NORMAL_INSTALL)\n");
2486 &pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ", @namelist);
2487 &depend ('.PHONY', 'install-man');
2489 $output_rules .= "uninstall-man:\n\t\@\$(NORMAL_UNINSTALL)\n";
2490 grep ($_ = 'un' . $_, @namelist);
2491 &pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ", @namelist);
2492 &depend ('.PHONY', 'uninstall-man');
2494 $output_vars .= &file_contents ('mans-vars');
2496 if (! defined $options{'no-installman'})
2498 push (@install_data, 'install-man');
2499 push (@uninstall, 'uninstall-man');
2500 push (@all, '$(MANS)');
2504 # Handle DATA variables.
2507 &am_install_var ('-noextra', '-candist', 'data', 'DATA',
2508 'data', 'sysconf', 'sharedstate', 'localstate',
2509 'pkgdata', 'noinst', 'check');
2515 local (@tag_deps) = ();
2516 if (&variable_defined ('SUBDIRS'))
2518 $output_rules .= ("tags-recursive:\n"
2519 . "\tlist=\'\$(SUBDIRS)\'; for subdir in \$\$list; do \\\n"
2520 # Never fail here if a subdir fails; it
2522 . "\t test \"\$\$subdir\" = . || (cd \$\$subdir"
2523 . " && \$(MAKE) \$(AM_MAKEFLAGS) tags); \\\n"
2525 push (@tag_deps, 'tags-recursive');
2526 &depend ('.PHONY', 'tags-recursive');
2529 if (&saw_sources_p (1)
2530 || &variable_defined ('ETAGS_ARGS')
2533 local ($config) = '';
2535 foreach $one_hdr (@config_headers)
2537 if ($relative_dir eq &dirname ($one_hdr))
2539 # The config header is in this directory. So require it.
2540 $config .= ' ' if $config;
2541 $config .= &basename ($one_hdr);
2544 local $xform = &transform ('CONFIG' => $xform,
2545 'DIRS' => join (' ', @tag_deps));
2547 if (&variable_defined ('SUBDIRS'))
2549 $xform .= 's/^SUBDIRS//;';
2553 $xform .= 's/^SUBDIRS.*$//;';
2556 $output_rules .= &file_contents ('tags', $xform);
2557 $output_rules .= &file_contents ('tags-clean');
2558 &examine_variable ('TAGS_DEPENDENCIES');
2560 elsif (&variable_defined ('TAGS_DEPENDENCIES'))
2562 &am_line_error ('TAGS_DEPENDENCIES',
2563 "doesn't make sense to define \`TAGS_DEPENDENCIES' without sources or \`ETAGS_ARGS'");
2567 # Every Makefile must define some sort of TAGS rule.
2568 # Otherwise, it would be possible for a top-level "make TAGS"
2569 # to fail because some subdirectory failed.
2570 $output_rules .= "tags: TAGS\nTAGS:\n\n";
2574 # Handle multilib support.
2577 return unless $seen_multilib;
2579 $output_rules .= &file_contents ('multilib');
2582 # Worker for handle_dist.
2583 sub handle_dist_worker
2585 my ($makefile) = @_;
2588 # Initialization; only at top level.
2589 if ($relative_dir eq '.')
2591 $xform .= 's/\@TOPDIR\@//g;';
2595 $xform .= 's/\@TOPDIR\@.*//g;';
2598 if (defined $options{'check-news'})
2600 $xform .= 's/\@CK-NEWS\@//g;';
2604 $xform .= 's/\@CK-NEWS\@.*//g;';
2607 # Scan EXTRA_DIST to see if we need to distribute anything from a
2608 # subdir. If so, add it to the list. I didn't want to do this
2609 # originally, but there were so many requests that I finally
2611 if (&variable_defined ('EXTRA_DIST'))
2613 # FIXME: This should be fixed to work with conditionals. That
2614 # will require only making the entries in @dist_dirs under the
2615 # appropriate condition. This is meaningful if the nature of
2616 # the distribution should depend upon the configure options
2618 foreach (&variable_value_as_list ('EXTRA_DIST', ''))
2621 next unless s,/+[^/]+$,,;
2627 # We have to check DIST_COMMON for extra directories in case the
2628 # user put a source used in AC_OUTPUT into a subdir.
2629 foreach (&variable_value_as_list ('DIST_COMMON', 'all'))
2632 next unless s,/+[^/]+$,,;
2637 if (scalar keys %dist_dirs)
2639 # Prepend $(distdir) to each directory given. Doing it via a
2640 # hash lets us ensure that each directory is used only once.
2641 grep ($dist_dirs{'$(distdir)/' . $_} = 1, keys %dist_dirs);
2642 $xform .= &transform ('DISTDIRS', join (' ', sort keys %dist_dirs));
2646 $xform .= 's/.*\@DISTDIRS\@.*//g;';
2651 $xform .= 's/\@CYGNUS\@\t*/\t/g;';
2652 $xform .= 's/.*\@NCYGNUS\@.*//g;';
2656 $xform .= 's/\@NCYGNUS\@\t*/\t/g;';
2657 $xform .= 's/.*\@CYGNUS\@.*//g;';
2660 # If we have SUBDIRS, create all dist subdirectories and do
2662 if (&variable_defined ('SUBDIRS'))
2664 # If SUBDIRS is conditionally defined, then set DIST_SUBDIRS
2665 # to all possible directories, and use it. If DIST_SUBDIRS is
2666 # defined, just use it.
2667 local ($dist_subdir_name);
2668 if (&variable_conditions ('SUBDIRS')
2669 || &variable_defined ('DIST_SUBDIRS'))
2671 $dist_subdir_name = 'DIST_SUBDIRS';
2672 if (! &variable_defined ('DIST_SUBDIRS'))
2674 local (@full_list) = &variable_value_as_list ('SUBDIRS',
2676 local (@ds_list, %uniq, $iter);
2677 foreach $iter (@full_list)
2679 if (! defined $uniq{$iter})
2682 push (@ds_list, $iter);
2685 &define_pretty_variable ('DIST_SUBDIRS', '', @ds_list);
2690 $dist_subdir_name = 'SUBDIRS';
2691 # We always define this because that is what `distclean'
2693 &define_pretty_variable ('DIST_SUBDIRS', '', '$(SUBDIRS)');
2696 $xform .= ('s/\@SUBDIRS\@//g;'
2697 . &transform ('DIST_SUBDIR_NAME'
2698 => $dist_subdir_name,
2700 => (($relative_dir eq '.')
2701 ? 'distdir' : 'top_distdir')));
2705 $xform .= 's/\@SUBDIRS\@.*//g;';
2708 $output_rules .= &file_contents ('distdir', $xform);
2710 # If the target `dist-hook' exists, make sure it is run. This
2711 # allows users to do random weird things to the distribution
2712 # before it is packaged up.
2713 push (@dist_targets, 'dist-hook') if &target_defined ('dist-hook');
2716 foreach $targ (@dist_targets)
2718 # We must explicitly set distdir and top_distdir for these
2720 $output_rules .= ("\t\$(MAKE) \$(AM_MAKEFLAGS)"
2721 . " top_distdir=\"\$(top_distdir)\""
2722 . " distdir=\"\$(distdir)\" $targ\n");
2726 # Handle 'dist' target.
2729 local ($makefile) = @_;
2731 # Set up maint_charset.
2732 $local_maint_charset = &variable_value ('MAINT_CHARSET')
2733 if &variable_defined ('MAINT_CHARSET');
2734 $maint_charset = $local_maint_charset
2735 if $relative_dir eq '.';
2737 if (&variable_defined ('DIST_CHARSET'))
2739 &am_line_error ('DIST_CHARSET',
2740 "DIST_CHARSET defined but no MAINT_CHARSET defined")
2741 if ! $local_maint_charset;
2742 if ($relative_dir eq '.')
2744 $dist_charset = &variable_value ('DIST_CHARSET')
2748 &am_line_error ('DIST_CHARSET',
2749 "DIST_CHARSET can only be defined at top level");
2753 # Look for common files that should be included in distribution.
2755 foreach $cfile (@common_files)
2757 if (-f ($relative_dir . "/" . $cfile))
2759 &push_dist_common ($cfile);
2763 # Always require configure.ac and configure at top level, even if
2764 # they don't exist. This is especially important for configure,
2765 # since it won't be created until autoconf is run -- which might
2766 # be after automake is run.
2767 &push_dist_common ($configure_ac, 'configure')
2768 if $relative_dir eq '.';
2770 # We might copy elements from %configure_dist_common to
2771 # %dist_common if we think we need to. If the file appears in our
2772 # directory, we would have discovered it already, so we don't
2773 # check that. But if the file is in a subdir without a Makefile,
2774 # we want to distribute it here if we are doing `.'. Ugly!
2775 if ($relative_dir eq '.')
2778 foreach $iter (keys %configure_dist_common)
2780 if (! &is_make_dir (&dirname ($iter)))
2782 &push_dist_common ($iter);
2787 # Keys of %dist_common are names of files to distributed. We put
2788 # README first because it then becomes easier to make a
2789 # Usenet-compliant shar file (in these, README must be first).
2790 # FIXME: do more ordering of files here.
2792 if (defined $dist_common{'README'})
2794 push (@coms, 'README');
2795 delete $dist_common{'README'};
2797 push (@coms, sort keys %dist_common);
2799 # Now that we've processed %dist_common, disallow further attempts
2801 $handle_dist_run = 1;
2803 &define_pretty_variable ("DIST_COMMON", '', @coms);
2804 $output_vars .= "\n";
2807 $output_vars .= &file_contents ('dist-vars') . "\n";
2808 &define_variable ('GZIP_ENV', '--best');
2810 # Put these things in rules section so it is easier for whoever
2811 # reads Makefile.in.
2812 if (! &variable_defined ('distdir'))
2814 if ($relative_dir eq '.')
2816 $output_rules .= "\n" . 'distdir = $(PACKAGE)-$(VERSION)' . "\n";
2820 $output_rules .= ("\n"
2821 . 'distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)'
2825 if ($relative_dir eq '.')
2827 $output_rules .= "top_distdir = \$(distdir)\n";
2829 $output_rules .= "\n";
2831 # Generate 'dist' target, and maybe other dist targets.
2832 if ($relative_dir eq '.')
2834 # Rule to check whether a distribution is viable.
2835 local ($xform) = '';
2837 if (&target_defined ('distcheck-hook'))
2839 $xform .= 's/^DISTHOOK//;';
2843 $xform .= 's/^DISTHOOK.*$//;';
2847 $xform .= 's/^GETTEXT//;';
2851 $xform .= 's/^GETTEXT.*$//;';
2854 # Arg, this file should have been named `distcheck'.
2855 $output_rules .= &file_contents ('dist', $xform);
2857 local ($dist_all) = ('dist-all: distdir' . "\n"
2860 foreach $curs ('dist', 'dist-shar', 'dist-zip', 'dist-tarZ',
2863 if (defined $options{$curs} || $curs eq 'dist')
2865 $output_rules .= ($curs . ': distdir' . "\n"
2869 $dist_all .= $dist{$curs};
2872 $output_rules .= $dist_all . $dist_trailer;
2875 # Generate distdir target.
2876 &handle_dist_worker ($makefile);
2880 # add_depend2 ($LANG)
2881 # -------------------
2882 # A subroutine of handle_dependencies. This function includes
2883 # `depend2' with appropriate transformations.
2888 # Get information on $LANG.
2889 my $pfx = $language_map{"$lang-autodep"};
2890 my $fpfx = ($pfx eq '') ? 'CC' : $pfx;
2891 my $flag = $language_map{"$lang-flags"};
2893 # First include code for ordinary objects.
2894 local ($xform, $ext);
2895 $xform = &transform ('PFX' => $pfx,
2897 $xform .= $seen_objext ? 's/^OBJEXT//;' : 's/^OBJEXT.*$//;';
2898 $xform .= $seen_libtool ? 's/^LIBTOOL//;' : 's/^LIBTOOL.*$//;';
2900 # This function can be called even when we don't want dependency
2901 # tracking. This happens when we need an explicit rule for some
2902 # target. In this case we don't want to include the generic code.
2903 if ($use_dependencies)
2905 my $compile = '$(' . $pfx . 'COMPILE)';
2906 my $ltcompile = '$(LT' . $pfx . 'COMPILE)';
2907 my $xform1 = ($xform
2908 . &transform ('BASE' => '$*',
2913 'COMPILE' => $compile,
2914 'LTCOMPILE' => $ltcompile));
2916 foreach $ext (&lang_extensions ($lang))
2918 $output_rules .= (&file_contents ('depend2',
2919 &transform ('EXT' => $ext)
2925 # Now include code for each specially handled object with this
2927 local (@list) = grep ($_ ne '', split (' ', $lang_specific_files{$lang}));
2928 local ($max) = scalar @list;
2930 local ($derived, $source, $obj);
2932 # If dependency tracking is disabled, we just elide the code.
2933 if (! $use_dependencies)
2935 $xform .= 's/\@AMDEP\@.*$//;';
2940 $derived = $list[$i];
2941 $source = $list[$i + 1];
2942 $obj = $list[$i + 2];
2945 my $val = "${derived}_${flag}";
2947 my $obj_compile = $language_map{"$lang-compile"};
2948 $obj_compile =~ s/\(AM_$flag/\($val/;
2949 my $obj_ltcompile = '$(LIBTOOL) --mode=compile ' . $obj_compile;
2951 # Generate a transform which will turn suffix targets in
2952 # depend2.am into real targets for the particular objects we
2958 . &transform ('COMPILE' => $obj_compile,
2959 'LTCOMPILE' => $obj_ltcompile,
2960 # Handle source and obj transforms.
2961 'OBJ' => $obj . '.o',
2962 'OBJOBJ' => $obj . '.obj',
2963 'LTOBJ' => $obj . '.lo',
2965 'SOURCE' => $source)
2966 # Generate rule for `.o'.
2967 . 's/^\@EXT\@\.o:/' . "\Q$obj.o: $source\E" . '/g;'
2968 # Maybe generate rule for `.lo'. Might be eliminated
2970 . 's/^\@EXT\@\.lo:/' . "\Q$obj.lo: $source\E" . '/g;'
2971 # Maybe generate rule for `.obj'. Might be
2972 # eliminated by $XFORM.
2973 . 's/^\@EXT\@\.obj:/' . "\Q$obj.obj: $source\E" . '/g;');
2977 # Handle auto-dependency code.
2978 sub handle_dependencies
2980 if ($use_dependencies)
2982 # Include auto-dep code. Don't include it if DEP_FILES would
2984 if (&saw_sources_p (0) && keys %dep_files)
2986 local ($config_aux_dir_specified) = ($config_aux_dir ne '.'
2987 && $config_aux_dir ne '');
2989 # Set $require_file_found{'depcomp'} if the depcomp file exists,
2990 # before calling require_config_file on `depcomp'. This makes
2991 # require_file_internal skip its buggy existence test that would
2992 # make automake fail (with `required file `lib/depcomp' not found')
2993 # when AC_CONFIG_AUX_DIR is not set. See tests/subdir4.test.
2994 local ($depcomp_dir) = ($config_aux_dir_specified ? $config_aux_dir
2996 $require_file_found{'depcomp'} = 1 if -f "$depcomp_dir/depcomp";
2998 # Set location of depcomp.
2999 local ($prefix) = ($config_aux_dir_specified ? $config_aux_dir
3002 &define_variable ('depcomp', "\$(SHELL) $prefix/depcomp");
3004 &require_config_file ($FOREIGN, 'depcomp');
3007 local (@deplist) = sort keys %dep_files;
3009 # We define this as a conditional variable because BSD
3010 # make can't handle backslashes for continuing comments on
3011 # the following line.
3012 &define_pretty_variable ('DEP_FILES', "\@AMDEP\@", @deplist);
3014 # Generate each `include' individually. Irix 6 make will
3015 # not properly include several files resulting from a
3016 # variable expansion; generating many separate includes
3018 $output_rules .= "\n";
3019 foreach $iter (@deplist)
3021 $output_rules .= "\@AMDEP\@\@AMINCLUDE\@ " . $iter . "\n";
3024 $output_rules .= &file_contents ('depend');
3029 &define_variable ('depcomp', '');
3032 local ($key, $lang, $ext, $xform);
3033 foreach $key (sort keys %language_map)
3035 next unless $key =~ /^(.*)-autodep$/;
3036 next if $language_map{$key} eq 'no';
3041 # Handle subdirectories.
3044 return if ! &variable_defined ('SUBDIRS');
3046 # Make sure each directory mentioned in SUBDIRS actually exists.
3048 foreach $dir (&variable_value_as_list ('SUBDIRS', 'all'))
3050 # Skip directories substituted by configure.
3051 next if $dir =~ /^\@.*\@$/;
3053 if (! -d $am_relative_dir . '/' . $dir)
3055 &am_line_error ('SUBDIRS',
3056 "required directory $am_relative_dir/$dir does not exist");
3060 &am_line_error ('SUBDIRS', "directory should not contain \`/'")
3064 local ($xform) = ('s/\@INSTALLINFO\@/' .
3065 (defined $options{'no-installinfo'}
3066 ? 'install-info-recursive'
3069 $output_rules .= &file_contents ('subdirs', $xform);
3071 $recursive_install = 1;
3074 # Handle aclocal.m4.
3075 sub handle_aclocal_m4
3077 local ($regen_aclocal) = 0;
3078 if (-f 'aclocal.m4')
3080 &define_variable ("ACLOCAL_M4", '$(top_srcdir)/aclocal.m4');
3081 &push_dist_common ('aclocal.m4');
3083 if (open (ACLOCAL, '< aclocal.m4'))
3089 if ($line =~ 'generated automatically by aclocal')
3096 local ($acinclude) = 0;
3097 if (-f 'acinclude.m4')
3103 # Note that it might be possible that aclocal.m4 doesn't exist but
3104 # should be auto-generated. This case probably isn't very
3108 local (@ac_deps) = (
3110 ? "\@MAINTAINER_MODE_TRUE\@"
3113 ($acinclude ? ' acinclude.m4' : '')
3116 if (&variable_defined ('ACLOCAL_M4_SOURCES'))
3118 push (@ac_deps, "\$(ACLOCAL_M4_SOURCES)");
3120 elsif (&variable_defined ('ACLOCAL_AMFLAGS'))
3122 # Scan all -I directories for m4 files. These are our
3124 local ($examine_next, $amdir) = 0;
3125 foreach $amdir (&variable_value_as_list ('ACLOCAL_AMFLAGS', ''))
3130 if ($amdir !~ /^\// && -d $amdir)
3132 foreach $ac_dep (&my_glob ($amdir . '/*.m4'))
3134 $ac_dep =~ s/^\.\/+//;
3135 push (@ac_deps, $ac_dep)
3136 unless $ac_dep eq "aclocal.m4"
3137 || $ac_dep eq "acinclude.m4";
3141 elsif ($amdir eq '-I')
3148 &pretty_print_rule ("\$(ACLOCAL_M4):", "\t\t", @ac_deps);
3150 $output_rules .= ("\t"
3151 . 'cd $(srcdir) && $(ACLOCAL)'
3152 . (&variable_defined ('ACLOCAL_AMFLAGS')
3153 ? ' $(ACLOCAL_AMFLAGS)' : '')
3158 # Rewrite a list of input files into a form suitable to put on a
3159 # dependency list. The idea is that if an input file has a directory
3160 # part the same as the current directory, then the directory part is
3161 # simply removed. But if the directory part is different, then
3162 # $(top_srcdir) is prepended. Among other things, this is used to
3163 # generate the dependency list for the output files generated by
3164 # AC_OUTPUT. Consider what the dependencies should look like in this
3166 # AC_OUTPUT(src/out:src/in1:lib/in2)
3167 # The first argument, ADD_SRCDIR, is 1 if $(top_srcdir) should be added.
3168 # If 0 then files that require this addition will simply be ignored.
3169 sub rewrite_inputs_into_dependencies
3171 local ($add_srcdir, @inputs) = @_;
3172 local ($single, @newinputs);
3174 foreach $single (@inputs)
3176 if (&dirname ($single) eq $relative_dir)
3178 push (@newinputs, &basename ($single));
3182 push (@newinputs, '$(top_srcdir)/' . $single);
3189 # Handle remaking and configure stuff.
3190 # We need the name of the input file, to do proper remaking rules.
3191 sub handle_configure
3193 local ($local, $input, @secondary_inputs) = @_;
3195 local ($top_reldir);
3197 local ($input_base) = &basename ($input);
3198 local ($local_base) = &basename ($local);
3200 local ($amfile) = $input_base . '.am';
3201 # We know we can always add '.in' because it really should be an
3202 # error if the .in was missing originally.
3203 local ($infile) = '$(srcdir)/' . $input_base . '.in';
3204 local ($colon_infile);
3205 if ($local ne $input || @secondary_inputs)
3207 $colon_infile = ':' . $input . '.in';
3209 $colon_infile .= ':' . join (':', @secondary_inputs)
3210 if @secondary_inputs;
3212 local (@rewritten) = &rewrite_inputs_into_dependencies (1,
3215 # This rule remakes the Makefile.in. Note use of
3216 # @MAINTAINER_MODE_TRUE@ forces us to abandon pretty-printing.
3218 $output_rules .= ($infile
3219 # NOTE perl 5.003 (with -w) gives a
3220 # uninitialized value error on the next line.
3223 . ($seen_maint_mode ? "\@MAINTAINER_MODE_TRUE\@ " : '')
3225 . '$(top_srcdir)/' . $configure_ac .' $(ACLOCAL_M4)'
3226 . ' ' . join (' ', @include_stack)
3228 . "\tcd \$(top_srcdir) && \$(AUTOMAKE) "
3229 . ($cygnus_mode ? '--cygnus' : ('--' . $strictness_name))
3230 . ($cmdline_use_dependencies ? '' : ' --ignore-deps')
3231 . ' ' . $input . $colon_infile . "\n\n");
3233 # This rule remakes the Makefile.
3234 $output_rules .= ($local_base
3235 # NOTE: bogus uninit value error on next line;
3236 # see comment above.
3239 . join (' ', @rewritten)
3240 . ' $(top_builddir)/config.status'
3242 . "\tcd \$(top_builddir) \\\n"
3243 . "\t && CONFIG_FILES="
3244 . (($relative_dir eq '.') ? '$@' : '$(subdir)/$@')
3246 . ' CONFIG_HEADERS= CONFIG_LINKS= CONFIG_COMMANDS= $(SHELL) ./config.status'
3249 if ($relative_dir ne '.')
3252 $top_reldir = '../';
3256 local ($xform) = &transform ('CONFIGURE_AC' => $configure_ac);
3258 $output_rules .= &file_contents ('remake', $xform);
3259 &examine_variable ('CONFIG_STATUS_DEPENDENCIES');
3260 &examine_variable ('CONFIGURE_DEPENDENCIES');
3263 &push_dist_common ('acconfig.h')
3267 # If we have a configure header, require it.
3269 local (@local_fullnames) = @config_fullnames;
3270 local (@local_names) = @config_names;
3271 local ($hdr_index) = 0;
3272 local ($distclean_config) = '';
3273 foreach $one_hdr (@config_headers)
3275 local ($one_fullname) = shift (@local_fullnames);
3276 local ($one_name) = shift (@local_names);
3278 local ($header_dir) = &dirname ($one_name);
3280 # If the header is in the current directory we want to build
3281 # the header here. Otherwise, if we're at the topmost
3282 # directory and the header's directory doesn't have a
3283 # Makefile, then we also want to build the header.
3284 if ($relative_dir eq $header_dir
3285 || ($relative_dir eq '.' && ! &is_make_dir ($header_dir)))
3287 local ($ch_sans_dir, $cn_sans_dir, $stamp_dir);
3288 if ($relative_dir eq $header_dir)
3290 $cn_sans_dir = &basename ($one_name);
3295 $cn_sans_dir = $one_name;
3296 if ($header_dir eq '.')
3302 $stamp_dir = $header_dir . '/';
3306 # Compute relative path from directory holding output
3307 # header to directory holding input header. FIXME:
3308 # doesn't handle case where we have multiple inputs.
3309 if (&dirname ($one_hdr) eq $relative_dir)
3311 $ch_sans_dir = &basename ($one_hdr);
3315 local (@rel_out_path);
3316 # FIXME this chunk of code should be its own sub.
3317 # It is used elsewhere.
3318 foreach (split (/\//, $relative_dir))
3320 next if $_ eq '' || $_ eq '.';
3323 # FIXME: actually this is an error.
3328 push (@rel_out_path, '..');
3333 $ch_sans_dir = join ('/', @rel_out_path) . '/' . $one_hdr;
3337 $ch_sans_dir = $one_hdr;
3341 &require_file_with_conf_line ($config_header_line,
3342 $FOREIGN, $ch_sans_dir);
3344 # Header defined and in this directory.
3346 if (-f $one_name . '.top')
3348 push (@files, "${cn_sans_dir}.top");
3350 if (-f $one_name . '.bot')
3352 push (@files, "${cn_sans_dir}.bot");
3355 &push_dist_common (@files);
3357 # For now, acconfig.h can only appear in the top srcdir.
3358 if (-f 'acconfig.h')
3360 if ($relative_dir eq '.')
3362 push (@files, 'acconfig.h');
3366 # Strange quoting because this gets fed through
3368 push (@files, '$(top_srcdir)/acconfig.h');
3372 local ($stamp_name) = 'stamp-h';
3373 $stamp_name .= "${hdr_index}" if scalar (@config_headers) > 1;
3375 local ($xform) = '';
3377 $xform = &transform ('CONFIGURE_AC' => $configure_ac,
3378 'FILES' => join (' ', @files),
3379 'CONFIG_HEADER' => $cn_sans_dir,
3380 'CONFIG_HEADER_IN' => $ch_sans_dir,
3381 'CONFIG_HEADER_FULL' => $one_fullname,
3382 'STAMP' => "$stamp_dir$stamp_name");
3384 local ($out_dir) = &dirname ($ch_sans_dir);
3385 $xform .= &transform ('SRC_STAMP' => "${out_dir}/${stamp_name}");
3386 $output_rules .= &file_contents ('remake-hdr', $xform);
3388 &create ("${relative_dir}/${out_dir}/${stamp_name}.in");
3389 &require_file_with_conf_line ($config_header_line, $FOREIGN,
3390 "${out_dir}/${stamp_name}.in");
3392 $distclean_config .= ' ' if $distclean_config;
3393 $distclean_config .= $cn_sans_dir;
3397 if ($distclean_config)
3400 &file_contents ('clean-hdr',
3401 &transform ('FILES' => $distclean_config));
3404 # Set location of mkinstalldirs.
3405 if ($config_aux_dir ne '.' && $config_aux_dir ne '')
3407 &define_variable ('mkinstalldirs', ('$(SHELL) ' . $config_aux_dir
3408 . '/mkinstalldirs'));
3412 &define_variable ('mkinstalldirs',
3413 '$(SHELL) $(top_srcdir)/mkinstalldirs');
3416 &am_line_error ('CONFIG_HEADER',
3417 "\`CONFIG_HEADER' is an anachronism; now determined from \`$configure_ac'")
3418 if &variable_defined ('CONFIG_HEADER');
3421 local ($config_header) = '';
3422 foreach $one_name (@config_names)
3424 # Generate CONFIG_HEADER define.
3426 if ($relative_dir eq &dirname ($one_name))
3428 $one_hdr = &basename ($one_name);
3432 $one_hdr = "${top_builddir}/${one_name}";
3435 $config_header .= ' ' if $config_header;
3436 $config_header .= $one_hdr;
3440 &define_variable ("CONFIG_HEADER", $config_header);
3443 # Now look for other files in this directory which must be remade
3444 # by config.status, and generate rules for them.
3445 local (@actual_other_files) = ();
3446 local ($file, $local);
3447 local (@inputs, @rewritten_inputs, $single);
3448 local ($need_rewritten, $lfile);
3449 foreach $lfile (@other_input_files)
3451 if ($lfile =~ /^([^:]*):(.*)$/)
3453 # This is the ":" syntax of AC_OUTPUT.
3455 $local = &basename ($file);
3456 @inputs = split (':', $2);
3457 @rewritten_inputs = &rewrite_inputs_into_dependencies (1, @inputs);
3458 $need_rewritten = 1;
3464 $local = &basename ($file);
3465 @inputs = ($local . '.in');
3467 &rewrite_inputs_into_dependencies (1, $file . '.in');
3468 $need_rewritten = 0;
3471 # Make sure the dist directory for each input file is created.
3472 # We only have to do this at the topmost level though. This
3473 # is a bit ugly but it easier than spreading out the logic,
3474 # especially in cases like AC_OUTPUT(foo/out:bar/in), where
3475 # there is no Makefile in bar/.
3476 if ($relative_dir eq '.')
3480 $dist_dirs{&dirname ($_)} = 1;
3484 # Skip files not in this directory.
3485 next unless &dirname ($file) eq $relative_dir;
3487 # Skip any file that is an automake input.
3488 next if -f $file . '.am';
3490 # Some users have been tempted to put `stamp-h' in the
3491 # AC_OUTPUT line. This won't do the right thing, so we
3492 # explicitly fail here.
3493 if ($local eq 'stamp-h')
3495 # FIXME: allow real filename.
3496 &am_conf_error ($configure_ac, $ac_output_line,
3497 'stamp-h should not appear in AC_OUTPUT');
3501 $output_rules .= ($local . ': '
3502 . '$(top_builddir)/config.status '
3503 . join (' ', @rewritten_inputs) . "\n"
3505 . 'cd $(top_builddir) && CONFIG_FILES='
3506 . ($relative_dir eq '.' ? '' : '$(subdir)/')
3507 . '$@' . ($need_rewritten
3508 ? (':' . join (':', @inputs))
3510 . ' CONFIG_HEADERS= CONFIG_LINKS= CONFIG_COMMANDS= $(SHELL) ./config.status'
3512 push (@actual_other_files, $local);
3514 # Require all input files.
3515 &require_file_with_conf_line ($ac_output_line, $FOREIGN,
3516 &rewrite_inputs_into_dependencies (0, @inputs));
3519 # These files get removed by "make clean".
3520 &define_pretty_variable ('CONFIG_CLEAN_FILES', '', @actual_other_files);
3527 @r = &am_install_var ('-defaultdist', 'header', 'HEADERS', 'include',
3528 'oldinclude', 'pkginclude',
3532 next unless /\.(.*)$/;
3533 &saw_extension ($1);
3539 return if ! $seen_gettext || $relative_dir ne '.';
3541 if (! &variable_defined ('SUBDIRS'))
3544 ("AM_GNU_GETTEXT used but SUBDIRS not defined");
3548 &require_file_with_conf_line ($ac_gettext_line, $GNU, 'ABOUT-NLS');
3550 if (&variable_defined ('SUBDIRS'))
3554 "AM_GNU_GETTEXT in \`$configure_ac' but \`po' not in SUBDIRS")
3555 if $contents{'SUBDIRS'} !~ /\bpo\b/;
3558 "AM_GNU_GETTEXT in \`$configure_ac' but \`intl' not in SUBDIRS")
3559 if $contents{'SUBDIRS'} !~ /\bintl\b/;
3562 # Ensure that each language in ALL_LINGUAS has a .po file, and
3563 # each po file is mentioned in ALL_LINGUAS.
3566 local (%linguas) = ();
3567 grep ($linguas{$_} = 1, split (' ', $all_linguas));
3574 &am_line_error ($all_linguas_line,
3575 ("po/$_.po exists but \`$_' not in \`ALL_LINGUAS'"))
3579 foreach (keys %linguas)
3581 &am_line_error ($all_linguas_line,
3582 "$_ in \`ALL_LINGUAS' but po/$_.po does not exist")
3588 &am_error ("AM_GNU_GETTEXT in \`$configure_ac' but \`ALL_LINGUAS' not defined");
3592 # Handle footer elements.
3595 if ($contents{'SOURCES'})
3597 # NOTE don't use define_pretty_variable here, because
3598 # $contents{...} is already defined.
3599 $output_vars .= 'SOURCES = ' . $contents{'SOURCES'} . "\n";
3601 if ($contents{'OBJECTS'})
3603 # NOTE don't use define_pretty_variable here, because
3604 # $contents{...} is already defined.
3605 $output_vars .= 'OBJECTS = ' . $contents{'OBJECTS'} . "\n";
3607 if ($contents{'SOURCES'} || $contents{'OBJECTS'})
3609 $output_vars .= "\n";
3612 if (&target_defined ('.SUFFIXES'))
3614 &am_line_error ('.SUFFIXES',
3615 "use variable \`SUFFIXES', not target \`.SUFFIXES'");
3618 # Note: AIX 4.1 /bin/make will fail if any suffix rule appears
3619 # before .SUFFIXES. So we make sure that .SUFFIXES appears before
3620 # anything else, by sticking it right after the default: target.
3621 $output_header .= ".SUFFIXES:\n";
3622 if (@suffixes || &variable_defined ('SUFFIXES'))
3624 # Make sure suffixes has unique elements. Sort them to ensure
3625 # the output remains consistent. However, $(SUFFIXES) is
3626 # always at the start of the list, unsorted. This is done
3627 # because make will choose rules depending on the ordering of
3628 # suffixes, and this lets the user have some control. Push
3629 # actual suffixes, and not $(SUFFIXES). Some versions of make
3630 # do not like variable substitutions on the .SUFFIXES line.
3632 local (@user_suffixes) = (&variable_defined ('SUFFIXES')
3633 ? &variable_value_as_list ('SUFFIXES', '')
3636 grep ($suffixes{$_} = 1, @suffixes);
3637 delete @suffixes{@user_suffixes};
3639 $output_header .= (".SUFFIXES: "
3640 . join (' ', @user_suffixes, sort keys %suffixes)
3643 $output_trailer .= &file_contents ('footer');
3646 # Deal with installdirs target.
3647 sub handle_installdirs
3649 # GNU Makefile standards recommend this.
3650 if ($recursive_install)
3652 # We create a separate `-am' target so that the -recursive
3653 # rule will work correctly.
3654 $output_rules .= ("installdirs: installdirs-recursive\n"
3655 . "installdirs-am:\n");
3656 &depend ('.PHONY', 'installdirs-am');
3660 $output_rules .= "installdirs:\n";
3662 &depend ('.PHONY', 'installdirs');
3665 &pretty_print_rule ("\t" . '$(mkinstalldirs) ', "\t\t",
3668 $output_rules .= "\n";
3671 # There are several targets which need to be merged. This is because
3672 # their complete definition is compiled from many parts. Note that we
3673 # avoid double colon rules, otherwise we'd use them instead.
3674 sub handle_merge_targets
3676 local ($makefile) = @_;
3678 # There are a few install-related variables that you should not define.
3680 foreach $var ('PRE_INSTALL', 'POST_INSTALL', 'NORMAL_INSTALL')
3682 if (&variable_defined ($var))
3684 &am_line_error ($var, "\`$var' should not be defined");
3688 # Put this at the beginning for the sake of non-GNU makes. This
3689 # is still wrong if these makes can run parallel jobs. But it is
3691 unshift (@all, &basename ($makefile));
3694 foreach $one_name (@config_names)
3696 push (@all, &basename ($one_name))
3697 if &dirname ($one_name) eq $relative_dir;
3700 &do_one_merge_target ('info', @info);
3701 &do_one_merge_target ('dvi', @dvi);
3702 &do_check_merge_target;
3703 &do_one_merge_target ('installcheck', @installcheck);
3705 if (defined $options{'no-installinfo'})
3707 &do_one_merge_target ('install-info', '');
3709 elsif (&target_defined ('install-info-local'))
3711 &am_line_error ('install-info-local',
3712 "\`install-info-local' target defined but \`no-installinfo' option not in use");
3716 foreach $utarg ('uninstall-data-local', 'uninstall-data-hook',
3717 'uninstall-exec-local', 'uninstall-exec-hook')
3719 if (&target_defined ($utarg))
3722 ($x = $utarg) =~ s/(data|exec)-//;
3723 &am_line_error ($utarg, "use \`$x', not \`$utarg'");
3727 if (&target_defined ('install-local'))
3729 &am_line_error ('install-local',
3730 "use \`install-data-local' or \`install-exec-local', not \`install-local'");
3733 if (@all || &variable_defined ('BUILT_SOURCES'))
3736 local ($local_headers) = '';
3737 $local_headers = '$(BUILT_SOURCES)'
3738 if &variable_defined ('BUILT_SOURCES');
3739 foreach $one_name (@config_names)
3741 if (&dirname ($one_name) eq $relative_dir)
3743 $local_headers .= ' ' if $local_headers;
3744 $local_headers .= &basename ($one_name);
3749 # This is kind of a hack, but I couldn't see a better way
3750 # to handle it. In this particular case, we need to make
3751 # sure config.h is built before we recurse. We can't do
3752 # this by changing the order of dependencies to the "all"
3753 # because that breaks when using parallel makes. Instead
3754 # we handle things explicitly.
3755 $output_rules .= ("all-recursive-am: ${local_headers}"
3757 . '$(MAKE) $(AM_MAKEFLAGS)'
3760 $all_target = 'all-recursive-am';
3761 &depend ('.PHONY', 'all-recursive-am');
3765 if (&variable_defined('lib_LTLIBRARIES') &&
3766 &variable_defined('bin_PROGRAMS'))
3768 $output_rules .= "install-binPROGRAMS: install-libLTLIBRARIES\n\n";
3770 # Print definitions users can use.
3771 &do_one_merge_target ('install-exec', @install_exec);
3772 $output_rules .= "\n";
3774 &do_one_merge_target ('install-data', @install_data);
3775 $output_rules .= "\n";
3777 &do_one_merge_target ('install', 'all-am');
3778 &do_one_merge_target ('uninstall', @uninstall);
3780 &do_one_merge_target ('all', @all);
3782 # Generate the new 'install-strip' target. We can't just set
3783 # INSTALL_PROGRAM because that might be a relative path.
3784 $output_rules .= ("install-strip:\n\t"
3785 . '$(MAKE) $(AM_MAKEFLAGS) INSTALL_STRIP_FLAG=-s install'
3787 &depend ('.PHONY', 'install-strip');
3790 # Helper for handle_merge_targets. Note that handle_merge_targets
3791 # relies on the fact that this doesn't add an extra \n at the end.
3792 sub do_one_merge_target
3794 local ($name, @values) = @_;
3796 if (&target_defined ($name . '-local'))
3798 # User defined local form of target. So include it.
3799 push (@values, $name . '-local');
3800 &depend ('.PHONY', $name . '-local');
3803 &pretty_print_rule ($name . "-am:", "\t\t", @values);
3804 if ($name eq 'install')
3806 # Special-case `install-am' to run install-exec-am and
3807 # install-data-am after all-am is built.
3808 &pretty_print_rule ("\t\@\$(MAKE) \$(AM_MAKEFLAGS)", "\t ",
3809 'install-exec-am', 'install-data-am');
3811 elsif ($name eq 'install-exec' && &target_defined ('install-exec-hook'))
3813 $output_rules .= ("\t\@\$(NORMAL_INSTALL)\n"
3814 . "\t" . '$(MAKE) $(AM_MAKEFLAGS) install-exec-hook'
3817 elsif ($name eq 'install-data' && &target_defined ('install-data-hook'))
3819 $output_rules .= ("\t\@\$(NORMAL_INSTALL)\n"
3820 . "\t" . '$(MAKE) $(AM_MAKEFLAGS) install-data-hook'
3824 local ($lname) = $name . ($recursive_install ? '-recursive' : '-am');
3825 local ($tname) = $name;
3826 # To understand this special case, see handle_merge_targets.
3829 $tname = 'all-redirect';
3830 $lname = $all_target if $recursive_install;
3831 &depend ('.PHONY', 'all-redirect');
3832 $output_all = "all: all-redirect\n";
3834 &pretty_print_rule ($tname . ":", "\t\t", $lname);
3835 &depend ('.PHONY', $name . '-am', $name);
3838 # Handle check merge target specially.
3839 sub do_check_merge_target
3841 if (&target_defined ('check-local'))
3843 # User defined local form of target. So include it.
3844 push (@check_tests, 'check-local');
3845 &depend ('.PHONY', 'check-local');
3848 # In --cygnus mode, check doesn't depend on all.
3851 # Just run the local check rules.
3852 &pretty_print_rule ('check-am:', "\t\t", @check);
3856 # The check target must depend on the local equivalent of
3857 # `all', to ensure all the primary targets are built. Then it
3858 # must build the local check rules.
3859 $output_rules .= "check-am: all-am\n";
3860 &pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ",
3864 &pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ",
3868 &depend ('.PHONY', 'check', 'check-am');
3869 $output_rules .= ("check: "
3870 . ($recursive_install ? 'check-recursive' : 'check-am')
3874 # Handle all 'clean' targets.
3880 # Don't include `MAINTAINER'; it is handled specially below.
3881 foreach $name ('MOSTLY', '', 'DIST')
3883 if (! &variable_defined ($name . 'CLEANFILES'))
3885 $xform .= 's/^' . $name . 'CLEAN.*$//;';
3889 $xform .= 's/^' . $name . 'CLEAN//;';
3893 # Built sources are automatically removed by maintainer-clean.
3894 push (@maintainer_clean_files, '\$(BUILT_SOURCES)')
3895 if &variable_defined ('BUILT_SOURCES');
3896 push (@maintainer_clean_files, '\$(MAINTAINERCLEANFILES)')
3897 if &variable_defined ('MAINTAINERCLEANFILES');
3898 if (! @maintainer_clean_files)
3900 $xform .= 's/^MAINTAINERCLEAN.*$//;';
3904 $xform .= ('s/^MAINTAINERCLEAN//;'
3905 # Join with no space to avoid spurious `test -z'
3906 # success at runtime.
3907 . 's,\@MCFILES\@,' . join ('', @maintainer_clean_files)
3909 # A space is required in the join here.
3910 . 's,\@MFILES\@,' . join (' ', @maintainer_clean_files)
3913 if ($recursive_install)
3915 $xform .= 's/^NSUBDIRS.*$//;';
3919 $xform .= 's/^NSUBDIRS//;';
3922 $output_rules .= &file_contents ('clean', $xform);
3924 foreach ('clean', 'distclean', 'mostlyclean', 'maintainer-clean')
3926 &depend ("$_-am", "$_-local")
3927 if &target_defined ("$_-local");
3930 # We special-case config.status here. If we do it as part of the
3931 # normal clean processing for this directory, then it might be
3932 # removed before some subdir is cleaned. However, that subdir's
3933 # Makefile depends on config.status.
3934 if ($relative_dir eq '.')
3936 $actions{'distclean'} .= "\t-rm -f config.status\n";
3937 $actions{'maintainer-clean'} .= "\t-rm -f config.status\n";
3942 # &depend ($CATEGORY, @DEPENDENDEES)
3943 # ----------------------------------
3944 # The target $CATEGORY depends on @DEPENDENDEES.
3947 my ($category, @dependendees) = @_;
3949 push (@{$dependencies{$category}}, @dependendees);
3954 # &target_cmp ($A, $B)
3955 # --------------------
3956 # Subroutine for &handle_factored_dependencies to let `.PHONY' be last.
3969 # &handle_factored_dependencies ()
3970 # --------------------------------
3971 # Handle .PHONY target.
3972 sub handle_factored_dependencies
3974 foreach (sort target_cmp keys %dependencies)
3976 &pretty_print_rule ("$_:", "\t",
3977 sort @{$dependencies{$_}});
3978 $output_rules .= $actions{$_};
3979 $output_rules .= "\n";
3984 # &handle_tests_dejagnu ()
3985 # ------------------------
3986 sub handle_tests_dejagnu
3988 push (@check_tests, 'check-DEJAGNU');
3993 $xform = 's/^CYGNUS//;';
3997 $xform = 's/^CYGNUS.*$//;';
3999 $output_rules .= &file_contents ('dejagnu', $xform);
4001 # In Cygnus mode, these are found in the build tree.
4002 # Otherwise they are looked for in $PATH.
4003 &define_program_variable ('EXPECT', 'build', 'expect', 'expect');
4004 &define_program_variable ('RUNTEST', 'src', 'dejagnu', 'runtest');
4006 # Only create site.exp rule if user hasn't already written
4008 if (! &target_defined ('site.exp'))
4010 # Note that in the rule we don't directly generate
4011 # site.exp to avoid the possibility of a corrupted
4012 # site.exp if make is interrupted. Jim Meyering has some
4013 # useful text on this topic.
4014 $output_rules .= ("site.exp: Makefile\n"
4015 . "\t\@echo 'Making a new site.exp file...'\n"
4016 . "\t\@test ! -f site.bak || rm -f site.bak\n"
4017 . "\t\@echo '## these variables are automatically generated by make ##' > \$\@-t\n"
4018 . "\t\@echo '# Do not edit here. If you wish to override these values' >> \$\@-t\n"
4019 . "\t\@echo '# edit the last section' >> \$\@-t\n"
4020 . "\t\@echo 'set tool \$(DEJATOOL)' >> \$\@-t\n"
4021 . "\t\@echo 'set srcdir \$(srcdir)' >> \$\@-t\n"
4022 . "\t\@echo 'set objdir' \`pwd\` >> \$\@-t\n");
4024 # Extra stuff for AC_CANONICAL_*
4025 local (@whatlist) = ();
4026 if ($seen_canonical)
4028 push (@whatlist, 'host');
4031 # Extra stuff only for AC_CANONICAL_SYSTEM.
4032 if ($seen_canonical == $AC_CANONICAL_SYSTEM)
4034 push (@whatlist, 'target', 'build');
4038 foreach $c1 (@whatlist)
4040 foreach $c2 ('alias', 'triplet')
4042 $output_rules .= "\t\@echo 'set ${c1}_${c2} \$(${c1}_${c2})' >> \$\@-t\n";
4046 $output_rules .= ("\t\@echo '## All variables above are generated by configure. Do Not Edit ##' >> \$\@-t\n"
4047 . "\t\@test ! -f site.exp || sed '1,/^## All variables above are.*##/ d' site.exp >> \$\@-t\n"
4048 . "\t\@test ! -f site.exp || mv site.exp site.bak\n"
4049 . "\t\@mv \$\@-t site.exp\n");
4054 # Handle TESTS variable and other checks.
4057 if (defined $options{'dejagnu'})
4059 &handle_tests_dejagnu;
4064 foreach $c ('DEJATOOL', 'RUNTEST', 'RUNTESTFLAGS')
4066 if (&variable_defined ($c))
4068 &am_line_error ($c, "\`$c' defined but \`dejagnu' not in \`AUTOMAKE_OPTIONS'");
4073 if (&variable_defined ('TESTS'))
4075 push (@check_tests, 'check-TESTS');
4077 # Note: Solaris 2.7 seems to expand TESTS using VPATH. That's
4078 # why we also try `dir='
4079 $output_rules .= &file_contents ('check');
4083 # Handle Emacs Lisp.
4084 sub handle_emacs_lisp
4086 local (@elfiles) = &am_install_var ('-candist', 'lisp', 'LISP',
4092 &define_configure_variable ('lispdir');
4093 &define_configure_variable ('EMACS');
4094 $output_rules .= (".el.elc:\n"
4095 . "\t\@echo 'WARNING: Warnings can be ignored. :-)'\n"
4096 . "\tif test \$(EMACS) != no; then \\\n"
4097 . "\t EMACS=\$(EMACS) \$(SHELL) \$(srcdir)/elisp-comp \$<; \\\n"
4099 push (@suffixes, '.el', '.elc');
4101 # Generate .elc files.
4102 grep ($_ .= 'c', @elfiles);
4103 &define_pretty_variable ('ELCFILES', '', @elfiles);
4105 $output_rules .= &file_contents ('lisp-clean');
4107 push (@all, '$(ELCFILES)');
4110 if (&variable_defined ('lisp_LISP'))
4112 $varname = 'lisp_LISP';
4113 &am_error ("\`lisp_LISP' defined but \`AM_PATH_LISPDIR' not in \`$configure_ac'")
4118 $varname = 'noinst_LISP';
4121 &require_file_with_line ($varname, $FOREIGN, 'elisp-comp');
4128 local (@pyfiles) = &am_install_var ('-defaultdist', 'python', 'PYTHON',
4129 'python', 'noinst');
4130 return if ! @pyfiles;
4132 # Found some python.
4133 &define_configure_variable ('pythondir');
4134 &define_configure_variable ('PYTHON');
4136 $output_rules .= &file_contents ('python-clean');
4138 &am_error ("\`python_PYTHON' defined but \`AM_CHECK_PYTHON' not in \`$configure_ac'")
4139 if ! $seen_pythondir && &variable_defined ('python_PYTHON');
4141 if ($config_aux_dir eq '.' || $config_aux_dir eq '')
4143 &define_variable ('py_compile', '$(top_srcdir)/py-compile');
4147 &define_variable ('py_compile', $config_aux_dir . '/py-compile');
4154 local (@sourcelist) = &am_install_var ('-candist', '-clean',
4156 'java', 'noinst', 'check');
4157 return if ! @sourcelist;
4159 &define_variable ('JAVAC', 'javac');
4160 &define_variable ('JAVACFLAGS', '');
4161 &define_variable ('CLASSPATH_ENV',
4162 'CLASSPATH=$(JAVAROOT):$(srcdir)/$(JAVAROOT):$$CLASSPATH');
4163 &define_variable ('JAVAROOT', '$(top_builddir)');
4165 local (%valid) = &am_primary_prefixes ('JAVA', 1,
4166 'java', 'noinst', 'check');
4168 local ($dir, $curs);
4169 foreach $curs (keys %valid)
4171 if (! &variable_defined ($curs . '_JAVA') || $curs eq 'EXTRA')
4178 &am_line_error ($curs . '_JAVA',
4179 "multiple _JAVA primaries in use");
4184 $output_rules .= ('class' . $dir . '.stamp: $(' . $dir . '_JAVA)' . "\n"
4185 . "\t" . '$(CLASSPATH_ENV) $(JAVAC) -d $(JAVAROOT) '
4186 . '$(JAVACFLAGS) $?' . "\n"
4187 . "\t" . 'echo timestamp > class' . $dir . '.stamp'
4189 push (@all, 'class' . $dir . '.stamp');
4190 &push_dist_common ('$(' . $dir . '_JAVA)');
4193 # Handle some of the minor options.
4194 sub handle_minor_options
4196 if (defined $options{'readme-alpha'})
4198 if ($relative_dir eq '.')
4200 if ($package_version !~ /^$GNITS_VERSION_PATTERN$/)
4202 # FIXME: allow real filename.
4203 &am_conf_line_error ($configure_ac,
4204 $package_version_line,
4205 "version \`$package_version' doesn't follow Gnits standards");
4207 elsif (defined $1 && -f 'README-alpha')
4209 # This means we have an alpha release. See
4210 # GNITS_VERSION_PATTERN for details.
4211 &require_file ($FOREIGN, 'README-alpha');
4217 ################################################################
4219 # &scan_autoconf_config_files ($CONFIG-FILES)
4220 # -------------------------------------------
4221 # Study $CONFIG-FILES which is the first argument to AC_CONFIG_FILES
4223 sub scan_autoconf_config_files
4225 # Look at potential Makefile.am's.
4228 # Must skip empty string for Perl 4.
4229 next if $_ eq "\\" || $_ eq '';
4231 # Handle $local:$input syntax. Note that we ignore
4232 # every input file past the first, though we keep
4233 # those around for later.
4234 local ($local, $input, @rest) = split (/:/);
4241 # FIXME: should be error if .in is missing.
4242 $input =~ s/\.in$//;
4245 if (-f $input . '.am')
4247 # We have a file that automake should generate.
4248 push (@make_input_list, $input);
4249 $make_list{$input} = join (':', ($local, @rest));
4253 # We have a file that automake should cause to be
4254 # rebuilt, but shouldn't generate itself.
4255 push (@other_input_files, $_);
4261 # &scan_autoconf_traces ($FILENAME)
4262 # ---------------------------------
4263 # FIXME: For the time being, we don't care about the FILENAME.
4264 sub scan_autoconf_traces
4266 local ($filename) = @_;
4269 local ($traces) = "$ENV{amtraces} ";
4271 $traces .= ' -t AC_CONFIG_FILES';
4272 $traces .= ' -t AC_LIBSOURCE';
4273 $traces .= ' -t AC_SUBST';
4275 open (TRACES, "$traces |")
4276 || die "automake: couldn't open \`$traces': $!\n";
4277 print "automake: reading $traces\n" if $verbose;
4282 local ($file, $line, $macro, @args) = split /:/;
4283 local ($here) = "$file:$line";
4285 # Alphabetical ordering please.
4286 if ($macro eq 'AC_CONFIG_FILES')
4288 # Look at potential Makefile.am's.
4289 &scan_autoconf_config_files ($args[0]);
4291 elsif ($macro eq 'AC_LIBSOURCE')
4293 local ($source) = "$args[0].c";
4294 # We should actually also `close' the sources: getopt.c
4295 # wants getopt.h etc. But actually it should be done in the
4296 # macro itself, i.e., we have to first fix Autoconf to extend
4297 # _AC_LIBOBJ_DECL and use it the in various macros.
4298 if (!defined $libsources{$source})
4300 print STDERR "traces: discovered $source\n";
4301 $libsources{$source} = $here;
4304 elsif ($macro eq 'AC_SUBST')
4306 if (!defined $configure_vars{$args[0]})
4308 print STDERR "traces: discovered AC_SUBST($args[0])\n";
4309 $configure_vars{$args[0]} = $here;
4315 || die "automake: close: $traces: $!\n";
4319 # &scan_one_autoconf_file ($FILENAME)
4320 # -----------------------------------
4321 # Scan one file for interesting things. Subroutine of
4322 # &scan_autoconf_files.
4323 sub scan_one_autoconf_file
4325 local ($filename) = @_;
4328 open (CONFIGURE, $filename)
4329 || die "automake: couldn't open \`$filename': $!\n";
4330 print "automake: reading $filename\n" if $verbose;
4334 # Remove comments from current line.
4338 # Skip macro definitions. Otherwise we might be confused into
4339 # thinking that a macro that was only defined was actually
4343 # Follow includes. This is a weirdness commonly in use at
4344 # Cygnus and hopefully nowhere else.
4345 if (/sinclude\((.*)\)/ && -f $1)
4347 &scan_one_autoconf_file ($1);
4350 # Populate libobjs array.
4351 if (/AC_FUNC_ALLOCA/)
4353 $libsources{'alloca.c'} = 1;
4355 elsif (/AC_FUNC_GETLOADAVG/)
4357 $libsources{'getloadavg.c'} = 1;
4359 elsif (/AC_FUNC_MEMCMP/)
4361 $libsources{'memcmp.c'} = 1;
4363 elsif (/AC_STRUCT_ST_BLOCKS/)
4365 $libsources{'fileblocks.c'} = 1;
4367 elsif (/A[CM]_REPLACE_GNU_GETOPT/)
4369 $libsources{'getopt.c'} = 1;
4370 $libsources{'getopt1.c'} = 1;
4372 elsif (/AM_FUNC_STRTOD/)
4374 $libsources{'strtod.c'} = 1;
4376 elsif (/AM_WITH_REGEX/)
4378 $libsources{'rx.c'} = 1;
4379 $libsources{'rx.h'} = 1;
4380 $libsources{'regex.c'} = 1;
4381 $libsources{'regex.h'} = 1;
4383 elsif (/AC_FUNC_MKTIME/)
4385 $libsources{'mktime.c'} = 1;
4387 elsif (/AM_FUNC_ERROR_AT_LINE/)
4389 $libsources{'error.c'} = 1;
4390 $libsources{'error.h'} = 1;
4392 elsif (/AM_FUNC_OBSTACK/)
4394 $libsources{'obstack.c'} = 1;
4395 $libsources{'obstack.h'} = 1;
4397 elsif (/LIBOBJS="(.*)\s+\$LIBOBJS"/
4398 || /LIBOBJS="\$LIBOBJS\s+(.*)"/)
4400 foreach $libobj_iter (split (' ', $1))
4402 if ($libobj_iter =~ /^(.*)\.o(bj)?$/
4403 || $libobj_iter =~ /^(.*)\.\$ac_objext$/
4404 || $libobj_iter =~ /^(.*)\.\$\{ac_objext\}$/)
4406 $libsources{$1 . '.c'} = 1;
4410 elsif (/AC_LIBOBJ\(([^)]+)\)/)
4412 $libsources{"$1.c"} = 1;
4415 if (! $in_ac_replace && s/AC_REPLACE_FUNCS\s*\(\[?//)
4421 $in_ac_replace = 0 if s/[\]\)].*$//;
4422 # Remove trailing backslash.
4426 # Need to skip empty elements for Perl 4.
4428 $libsources{$_ . '.c'} = 1;
4432 if (/$obsolete_rx/o)
4435 if ($obsolete_macros{$1} ne '')
4437 $hint = '; ' . $obsolete_macros{$1};
4439 &am_conf_line_error ($filename, $., "\`$1' is obsolete$hint");
4442 # Process the AC_OUTPUT and AC_CONFIG_FILES macros.
4443 if (! $in_ac_output && s/AC_(OUTPUT|CONFIG_FILES)\s*\(\[?//)
4446 $ac_output_line = $.;
4450 local ($closing) = 0;
4457 # Look at potential Makefile.am's.
4458 &scan_autoconf_config_files ($_);
4460 if ($closing && @make_input_list == 0 && @other_input_files == 0)
4462 &am_conf_line_error ($filename, $ac_output_line,
4463 "No files mentioned in \`AC_OUTPUT'");
4468 if (/$AC_CONFIG_AUX_DIR_PATTERN/o)
4470 @config_aux_path = $1;
4473 # Check for ansi2knr.
4474 $am_c_prototypes = 1 if /AM_C_PROTOTYPES/;
4476 # Check for exe extension stuff.
4480 $configure_vars{'EXEEXT'} = $filename . ':' . $.;
4486 $configure_vars{'OBJEXT'} = $filename . ':' . $.;
4489 # Check for `-c -o' code.
4490 $seen_cc_c_o = 1 if /AM_PROG_CC_C_O/;
4492 # Check for NLS support.
4493 if (/AM_GNU_GETTEXT/)
4496 $ac_gettext_line = $.;
4499 # Look for ALL_LINGUAS.
4500 if (/ALL_LINGUAS="(.*)"$/ || /ALL_LINGUAS=(.*)$/)
4504 $all_linguas_line = $.;
4507 # Handle configuration headers. A config header of `[$1]'
4508 # means we are actually scanning AM_CONFIG_HEADER from
4510 if (/A([CM])_CONFIG_HEADERS?\s*\((.*)\)/
4514 ($filename, $., "\`automake requires \`AM_CONFIG_HEADER', not \`AC_CONFIG_HEADER'")
4517 $config_header_line = $.;
4519 foreach $one_hdr (split (' ', $2))
4521 push (@config_fullnames, $one_hdr);
4522 if ($one_hdr =~ /^([^:]+):(.+)$/)
4524 push (@config_names, $1);
4525 push (@config_headers, $2);
4529 push (@config_names, $one_hdr);
4530 push (@config_headers, $one_hdr . '.in');
4535 # Handle AC_CANONICAL_*. Always allow upgrading to
4536 # AC_CANONICAL_SYSTEM, but never downgrading.
4537 $seen_canonical = $AC_CANONICAL_HOST
4538 if ! $seen_canonical
4539 && (/AC_CANONICAL_HOST/ || /AC_CHECK_TOOL/);
4540 $seen_canonical = $AC_CANONICAL_SYSTEM if /AC_CANONICAL_SYSTEM/;
4542 $seen_path_xtra = 1 if /AC_PATH_XTRA/;
4544 # This macro handles several different things.
4545 if (/$AM_INIT_AUTOMAKE_PATTERN/o)
4549 $seen_prog_install = 1;
4550 ($package_version = $1) =~ s/$AM_PACKAGE_VERSION_PATTERN/$1/o;
4551 $package_version_line = $.;
4552 $seen_init_automake = 1;
4555 # Some things required by Automake.
4556 $seen_make_set = 1 if /AC_PROG_MAKE_SET/;
4557 $seen_arg_prog = 1 if /AC_ARG_PROGRAM/;
4561 $configure_vars{'LEX'} = $filename . ':' . $.;
4562 $seen_decl_yytext = 1;
4564 if (/AC_DECL_YYTEXT/ && $filename =~ /configure\.(ac|in)$/)
4566 &am_conf_line_warning ($filename, $., "\`AC_DECL_YYTEXT' is covered by \`AM_PROG_LEX'");
4568 if (/AC_PROG_LEX/ && $filename =~ /configure\.(ac|in)$/)
4570 &am_conf_line_warning ($filename, $., "automake requires \`AM_PROG_LEX', not \`AC_PROG_LEX'");
4573 if (/AC_PROG_(F77|YACC|RANLIB|CC|CXXCPP|CXX|LEX|AWK|CPP|LN_S)/)
4575 $configure_vars{$1} = $filename . ':' . $.;
4577 if (/$AC_CHECK_PATTERN/o)
4579 $configure_vars{$3} = $filename . ':' . $.;
4581 if (/$AM_MISSING_PATTERN/o
4585 && $1 ne 'AUTOHEADER')
4587 $configure_vars{$1} = $filename . ':' . $.;
4590 # Explicitly avoid ANSI2KNR -- we AC_SUBST that in protos.m4,
4591 # but later define it elsewhere. This is pretty hacky. We
4592 # also explicitly avoid INSTALL_SCRIPT and some other
4593 # variables because they are defined in header-vars.am.
4595 if (/$AC_SUBST_PATTERN/o
4597 && $1 ne 'INSTALL_SCRIPT'
4598 && $1 ne 'INSTALL_DATA')
4600 $configure_vars{$1} = $filename . ':' . $.;
4603 $seen_decl_yytext = 1 if /AC_DECL_YYTEXT/;
4604 if (/AM_MAINTAINER_MODE/)
4606 $seen_maint_mode = 1;
4607 $configure_cond{'MAINTAINER_MODE'} = 1;
4610 $seen_prog_install = 1 if /AC_PROG_INSTALL/;
4611 $seen_lispdir = 1 if /AM_PATH_LISPDIR/;
4612 $seen_pythondir = 1 if /AM_PATH_PYTHON/;
4614 if (/A(C|M)_PROG_LIBTOOL/)
4616 # We're not ready for this yet. People still use a
4617 # libtool with no AC_PROG_LIBTOOL. Once that is the
4618 # dominant version we can reenable this code -- but next
4619 # time by mentioning the macro in %obsolete_macros, both
4620 # here and in aclocal.in.
4622 # if (/AM_PROG_LIBTOOL/)
4624 # &am_conf_line_warning ($filename, $., "\`AM_PROG_LIBTOOL' is obsolete, use \`AC_PROG_LIBTOOL' instead");
4628 $configure_vars{'LIBTOOL'} = $filename . ':' . $.;
4629 $configure_vars{'RANLIB'} = $filename . ':' . $.;
4630 $configure_vars{'CC'} = $filename . ':' . $.;
4631 # AC_PROG_LIBTOOL runs AC_CANONICAL_HOST. Make sure we
4632 # never downgrade (if we've seen AC_CANONICAL_SYSTEM).
4633 $seen_canonical = $AC_CANONICAL_HOST if ! $seen_canonical;
4636 $seen_multilib = 1 if (/AM_ENABLE_MULTILIB/);
4638 if (/$AM_CONDITIONAL_PATTERN/o)
4640 $configure_cond{$1} = 1;
4643 # Check for Fortran 77 intrinsic and run-time libraries.
4644 if (/AC_F77_LIBRARY_LDFLAGS/)
4646 $configure_vars{'FLIBS'} = $filename . ':' . $.;
4654 # &scan_autoconf_files ()
4655 # -----------------------
4656 # Check whether we use `configure.ac' or `configure.in'.
4657 # Scan it (and possibly `aclocal.m4') for interesting things.
4658 # We must scan aclocal.m4 because there might be AC_SUBSTs and such there.
4659 sub scan_autoconf_files
4661 # Reinitialize libsources here. This isn't really necessary,
4662 # since we currently assume there is only one configure.ac. But
4663 # that won't always be the case.
4666 local ($in_ac_output, $in_ac_replace) = (0, 0);
4667 local (%make_list, @make_input_list);
4668 local ($libobj_iter);
4670 warn "automake: both \`configure.ac' and \`configure.in' present:"
4671 . " ignoring \`configure.in'\n"
4672 if -f 'configure.ac' && -f 'configure.in';
4673 $configure_ac = 'configure.in'
4674 if -f 'configure.in';
4675 $configure_ac = 'configure.ac'
4676 if -f 'configure.ac';
4677 die "automake: \`configure.ac' or \`configure.in' is required\n"
4680 &scan_one_autoconf_file ($configure_ac);
4681 &scan_one_autoconf_file ('aclocal.m4')
4684 if (defined $ENV{'amtraces'})
4686 warn 'automake: Autoconf traces is an experimental feature';
4687 warn 'automake: use at your own risks';
4689 &scan_autoconf_traces ($configure_ac);
4692 # Set input and output files if not specified by user.
4695 @input_files = @make_input_list;
4696 %output_files = %make_list;
4699 @configure_input_files = @make_input_list;
4701 &am_conf_error ("\`AM_INIT_AUTOMAKE' must be used")
4702 if ! $seen_init_automake;
4704 # Always require AC_PROG_MAKE_SET. We might randomly use $(MAKE)
4705 # for our own reasons.
4706 &am_conf_error ("\`AC_PROG_MAKE_SET' must be used")
4707 if ! $seen_make_set;
4709 # Look for some files we need. Always check for these. This
4710 # check must be done for every run, even those where we are only
4711 # looking at a subdir Makefile. We must set relative_dir so that
4712 # the file-finding machinery works.
4713 local ($relative_dir) = '.';
4714 &require_config_file ($FOREIGN, 'install-sh', 'mkinstalldirs', 'missing');
4715 &am_error ("\`install.sh' is an anachronism; use \`install-sh' instead")
4716 if -f $config_aux_path[0] . '/install.sh';
4718 &require_config_file ($FOREIGN, 'py-compile')
4721 # Preserve dist_common for later.
4722 %configure_dist_common = %dist_common;
4725 ################################################################
4727 # Set up for Cygnus mode.
4730 return unless $cygnus_mode;
4732 &set_strictness ('foreign');
4733 $options{'no-installinfo'} = 1;
4734 $options{'no-dependencies'} = 1;
4735 $use_dependencies = 0;
4737 if (! $seen_maint_mode)
4739 &am_conf_error ("\`AM_MAINTAINER_MODE' required when --cygnus specified");
4744 &am_conf_error ("\`AC_EXEEXT' required when --cygnus specified");
4748 # Do any extra checking for GNU standards.
4749 sub check_gnu_standards
4751 if ($relative_dir eq '.')
4753 # In top level (or only) directory.
4754 &require_file ($GNU, 'INSTALL', 'NEWS', 'README', 'COPYING',
4755 'AUTHORS', 'ChangeLog');
4758 if ($strictness >= $GNU)
4760 if (defined $options{'no-installman'})
4762 &am_line_error ('AUTOMAKE_OPTIONS',
4763 "option \`no-installman' disallowed by GNU standards");
4766 if (defined $options{'no-installinfo'})
4768 &am_line_error ('AUTOMAKE_OPTIONS',
4769 "option \`no-installinfo' disallowed by GNU standards");
4774 # Do any extra checking for GNITS standards.
4775 sub check_gnits_standards
4777 if ($relative_dir eq '.')
4779 # In top level (or only) directory.
4780 &require_file ($GNITS, 'THANKS');
4784 ################################################################
4786 # Functions to handle files of each language.
4788 # Each `lang_X_rewrite' function follows a simple formula:
4789 # * Args are the directory, base name and extension of the file.
4790 # * Return value is 1 if file is to be dealt with, 0 otherwise.
4791 # Much of the actual processing is handled in handle_single_transform_list.
4792 # These functions exist so that auxiliary information can be recorded
4793 # for a later cleanup pass. Note that the calls to these functions
4794 # are computed, so don't bother searching for their precise names
4797 # This is just a convenience function that can be used to determine
4798 # when a subdir object should be used.
4801 return defined $options{'subdir-objects'} ? $LANG_SUBDIR : $LANG_PROCESS;
4804 # Rewrite a single C source file.
4807 local ($directory, $base, $ext) = @_;
4809 if (defined $options{'ansi2knr'} && $base =~ /_$/)
4811 # FIXME: include line number in error.
4812 &am_error ("C source file \`$base.c' would be deleted by ansi2knr rules");
4815 local ($r) = $LANG_PROCESS;
4816 if (defined $options{'subdir-objects'})
4819 $base = $directory . '/' . $base;
4823 # Only give error once.
4825 # FIXME: line number.
4826 &am_error ("C objects in subdir but \`AM_PROG_CC_C_O' not in \`$configure_ac'");
4829 &require_file ($FOREIGN, 'compile')
4830 if $relative_dir eq '.';
4833 $de_ansi_files{$base} = 1;
4837 # Rewrite a single C++ source file.
4838 sub lang_cxx_rewrite
4840 return &lang_sub_obj;
4843 # Rewrite a single header file.
4844 sub lang_header_rewrite
4846 # Header files are simply ignored.
4847 return $LANG_IGNORE;
4850 # Rewrite a single yacc file.
4851 sub lang_yacc_rewrite
4853 local ($directory, $base, $ext) = @_;
4855 local ($r) = &lang_c_rewrite ($directory, $base, $ext);
4857 if ($r == $LANG_SUBDIR)
4859 $pfx = $directory . '/';
4861 $yacc_sources{$pfx . $base . '.' . $ext} = 1;
4863 &saw_extension ('c');
4865 &push_dist_common ($pfx . $base . '.' . $ext);
4869 # Rewrite a single yacc++ file.
4870 sub lang_yaccxx_rewrite
4872 local ($directory, $base, $ext) = @_;
4874 local ($r) = $LANG_PROCESS;
4876 if (defined $options{'subdir-objects'})
4878 $pfx = $directory . '/';
4881 $yacc_sources{$pfx . $base . '.' . $ext} = 1;
4883 &saw_extension ($ext);
4885 &push_dist_common ($pfx . $base . '.' . $ext);
4889 # Rewrite a single lex file.
4890 sub lang_lex_rewrite
4892 local ($directory, $base, $ext) = @_;
4894 local ($r) = &lang_c_rewrite ($directory, $base, $ext);
4896 if ($r == $LANG_SUBDIR)
4898 $pfx = $directory . '/';
4900 $lex_sources{$pfx . $base . '.' . $ext} = 1;
4902 &saw_extension ('c');
4904 &push_dist_common ($pfx . $base . '.' . $ext);
4908 # Rewrite a single lex++ file.
4909 sub lang_lexxx_rewrite
4911 local ($directory, $base, $ext) = @_;
4913 local ($r) = $LANG_PROCESS;
4915 if (defined $options{'subdir-objects'})
4917 $pfx = $directory . '/';
4920 $lex_sources{$pfx . $base . '.' . $ext} = 1;
4922 &saw_extension ($ext);
4924 &push_dist_common ($pfx . $base . '.' . $ext);
4928 # Rewrite a single assembly file.
4929 sub lang_asm_rewrite
4931 return &lang_sub_obj;
4934 # Rewrite a single Fortran 77 file.
4935 sub lang_f77_rewrite
4937 return $LANG_PROCESS;
4940 # Rewrite a single preprocessed Fortran 77 file.
4941 sub lang_ppf77_rewrite
4943 return $LANG_PROCESS;
4946 # Rewrite a single ratfor file.
4947 sub lang_ratfor_rewrite
4949 return $LANG_PROCESS;
4952 # Rewrite a single Objective C file.
4953 sub lang_objc_rewrite
4955 return &lang_sub_obj;
4958 # Rewrite a single Java file.
4959 sub lang_java_rewrite
4961 return $LANG_SUBDIR;
4964 # The lang_X_finish functions are called after all source file
4965 # processing is done. Each should handle defining rules for the
4966 # language, etc. A finish function is only called if a source file of
4967 # the appropriate type has been seen.
4971 # Push all libobjs files onto de_ansi_files. We actually only
4972 # push files which exist in the current directory, and which are
4973 # genuine source files.
4975 foreach $file (keys %libsources)
4977 if ($file =~ /^(.*)\.[cly]$/ && -f "$relative_dir/$file")
4979 $de_ansi_files{$1} = 1;
4983 if (defined $options{'ansi2knr'} && keys %de_ansi_files)
4985 # Make all _.c files depend on their corresponding .c files.
4986 local ($base, @objects);
4987 foreach $base (sort keys %de_ansi_files)
4989 # Each _.c file must depend on ansi2knr; otherwise it
4990 # might be used in a parallel build before it is built.
4991 # We need to support files in the srcdir and in the build
4992 # dir (because these files might be auto-generated. But
4993 # we can't use $< -- some makes only define $< during a
4995 $output_rules .= ($base . "_.c: $base.c \$(ANSI2KNR)\n\t"
4996 . '$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) '
4997 . '`if test -f $(srcdir)/' . $base . '.c'
4998 . '; then echo $(srcdir)/' . $base . '.c'
4999 . '; else echo ' . $base . '.c; fi` '
5000 . "| sed 's/^# \\([0-9]\\)/#line \\1/' "
5001 . '| $(ANSI2KNR) > ' . $base . "_.c\n");
5002 push (@objects, $base . '_'
5003 . ($seen_objext ? '.$(OBJEXT)' : '.o'));
5004 push (@objects, $base . '_.lo') if $seen_libtool;
5007 # Make all _.o (and _.lo) files depend on ansi2knr.
5008 # Use a sneaky little hack to make it print nicely.
5009 &pretty_print_rule ('', '', @objects, ':', '$(ANSI2KNR)');
5012 if (! defined $configure_vars{'CC'})
5014 # FIXME: line number.
5015 &am_error ("C source seen but \`CC' not defined in \`$configure_ac'");
5021 local ($ltcompile, $ltlink) = &libtool_compiler;
5023 &define_variable ('CXXLD', '$(CXX)');
5024 &define_variable ('CXXLINK', $ltlink . '$(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@');
5026 if (! defined $configure_vars{'CXX'})
5028 &am_error ("C++ source seen but \`CXX' not defined in \`$configure_ac'");
5032 sub lang_header_finish
5037 # This is a helper for both lex and yacc.
5038 sub yacc_lex_finish_helper
5040 return if defined $language_scratch{'lex-yacc-done'};
5041 $language_scratch{'lex-yacc-done'} = 1;
5043 # If there is more than one distinct yacc (resp lex) source file
5044 # in a given directory, then the `ylwrap' program is required to
5045 # allow parallel builds to work correctly. FIXME: for now, no
5047 &require_config_file ($FOREIGN, 'ylwrap');
5048 if ($config_aux_dir ne '.' && $config_aux_dir ne '')
5050 &define_variable ('YLWRAP', $config_aux_dir . "/ylwrap");
5054 &define_variable ('YLWRAP', '$(srcdir)/ylwrap');
5058 sub lang_yacc_finish
5060 return if defined $language_scratch{'yacc-done'};
5061 $language_scratch{'yacc-done'} = 1;
5063 local ($file, $base, $hname, $cname);
5064 local (%seen_suffix) = ();
5065 local (@yacc_files) = sort keys %yacc_sources;
5066 local ($yacc_count) = scalar (@yacc_files);
5067 foreach $file (@yacc_files)
5070 &output_yacc_build_rule ($1, $yacc_count > 1)
5071 if ! defined $seen_suffix{$1};
5072 $seen_suffix{$1} = 1;
5074 $file =~ /^(.*)\.(y|yy|y\+\+|yxx|ypp)$/;
5076 $hname = 'h'; # Always use `.h' for header file.
5077 ($cname = $2) =~ tr/y/c/;
5079 if ((&variable_defined ('AM_YFLAGS')
5080 && &variable_value ('AM_YFLAGS') =~ /(^|\s)-d(\s|$)/)
5081 || (&variable_defined ('YFLAGS')
5082 && &variable_value ('YFLAGS') =~ /(^|\s)-d(\s|$)/)) {
5083 # Now generate rule to make the header file. This should only
5084 # be generated if `yacc -d' specified.
5085 $output_rules .= "${base}.${hname}: ${base}.${cname}\n";
5087 # If the files are built in the build directory, then we want
5088 # to remove them with `make clean'. If they are in srcdir
5089 # they shouldn't be touched. However, we can't determine this
5090 # statically, and the GNU rules say that yacc/lex output files
5091 # should be removed by maintainer-clean. So that's what we
5093 push (@maintainer_clean_files, "${base}.${hname}");
5095 &push_dist_common ("${base}.${hname}");
5097 push (@maintainer_clean_files, "${base}.${cname}");
5099 $output_rules .= "\n";
5101 if (! defined $configure_vars{'YACC'})
5103 &am_error ("yacc source seen but \`YACC' not defined in \`$configure_ac'");
5105 if (&variable_defined ('YACCFLAGS'))
5107 &am_line_error ('YACCFLAGS',
5108 "\`YACCFLAGS' obsolete; use \`YFLAGS' instead");
5111 if ($yacc_count > 1)
5113 &yacc_lex_finish_helper;
5117 sub lang_yaccxx_finish
5124 return if defined $language_scratch{'lex-done'};
5125 $language_scratch{'lex-done'} = 1;
5127 local (%seen_suffix) = ();
5128 local ($file, $cname);
5129 local ($lex_count) = scalar (keys %lex_sources);
5130 foreach $file (sort keys %lex_sources)
5133 &output_lex_build_rule ($1, $lex_count > 1)
5134 if (! defined $seen_suffix{$1});
5135 $seen_suffix{$1} = 1;
5137 # If the files are built in the build directory, then we want
5138 # to remove them with `make clean'. If they are in srcdir
5139 # they shouldn't be touched. However, we can't determine this
5140 # statically, and the GNU rules say that yacc/lex output files
5141 # should be removed by maintainer-clean. So that's what we
5143 $file =~ /^(.*)\.(l|ll|l\+\+|lxx|lpp)$/;
5144 ($cname = $2) =~ tr/l/c/;
5145 push (@maintainer_clean_files, "${1}.${cname}");
5148 if (! defined $configure_vars{'LEX'})
5150 &am_error ("lex source seen but \`LEX' not defined in \`$configure_ac'");
5152 if (! $seen_decl_yytext)
5154 &am_error ("lex source seen but \`AC_DECL_YYTEXT' not in \`$configure_ac'");
5159 &yacc_lex_finish_helper;
5163 sub lang_lexxx_finish
5170 # We need the C code for assembly.
5176 # FIXME: this function can be called more than once. We should
5177 # arrange for it to only do anything the first time through.
5179 local ($ltcompile, $ltlink) = &libtool_compiler;
5181 &define_variable ('F77LD', '$(F77)');
5182 &define_variable ('F77LINK', $ltlink . '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@');
5184 if (! defined $configure_vars{'F77'})
5186 &am_error ("Fortran 77 source seen but \`F77' not defined in \`$configure_ac'");
5190 # Preprocessed Fortran 77
5192 # The current support for preprocessing Fortran 77 just involves passing
5193 # `$(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS)' as additional flags
5194 # to the Fortran 77 compiler, since this is how GNU Make does it; see
5195 # the `GNU Make Manual, Edition 0.51 for `make' Version 3.76 Beta'
5196 # (specifically, from info file `(make)Catalogue of Rules').
5198 # A better approach would be to write an Autoconf test
5199 # (i.e. AC_PROG_FPP) for a Fortran 77 preprocessor, because not all
5200 # Fortran 77 compilers know how to do preprocessing. The Autoconf macro
5201 # AC_PROG_FPP should test the Fortran 77 compiler first for
5202 # preprocessing capabilities, and then fall back on cpp (if cpp were
5204 sub lang_ppf77_finish
5208 # We also handle the case of preprocessing `.F' files into `.f'
5210 $output_rules .= (".F.f:\n"
5211 . "\t\$(F77COMPILE) -F \$<\n");
5214 sub lang_ratfor_finish
5218 # We also handle the case of preprocessing `.r' files into `.f'
5220 $output_rules .= (".r.f:\n"
5221 . "\t\$(RCOMPILE) -F \$<\n");
5224 sub lang_objc_finish
5226 local ($ltcompile, $ltlink) = &libtool_compiler;
5228 &define_variable ('OBJCLD', '$(OBJC)');
5229 &define_variable ('OBJCLINK', $ltlink . '$(OBJCLD) $(AM_OBJCFLAGS) $(OBJCFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@');
5231 if (! defined $configure_vars{'OBJC'})
5233 &am_error ("Objective C source seen but \`OBJC' not defined in \`$configure_ac'");
5237 sub lang_java_finish
5239 local ($ltcompile, $ltlink) = &libtool_compiler;
5241 &define_variable ('GCJLD', '$(GCJ)');
5242 &define_variable ('GCJLINK', $ltlink . '$(GCJLD) $(AM_GCJFLAGS) $(GCJFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@');
5244 if (! defined $configure_vars{'GCJ'})
5246 &am_error ("Java source seen but \`GCJ' not defined in \`$configure_ac'");
5250 # A helper which computes a sorted list of all extensions for LANG.
5255 foreach $key (sort keys %extension_seen)
5257 push (@r, '.' . $key) if $extension_map{$key} eq $lang;
5262 # A helper which decides whether libtool is needed. Returns prefix
5263 # for compiler and linker.
5264 sub libtool_compiler
5266 local ($ltcompile, $ltlink) = ('', '');
5269 &define_configure_variable ("LIBTOOL");
5270 $ltcompile = '$(LIBTOOL) --mode=compile ';
5271 $ltlink = '$(LIBTOOL) --mode=link ';
5273 return ($ltcompile, $ltlink);
5276 # Given a hash table of linker names, pick the name that has the most
5277 # precedence. This is lame, but something has to have global
5278 # knowledge in order to eliminate the conflict. Add more linkers as
5282 local (%linkers) = @_;
5285 if defined $linkers{'GCJLINK'};
5287 if defined $linkers{'CXXLINK'};
5289 if defined $linkers{'F77LINK'};
5291 if defined $linkers{'OBJCLINK'};
5295 # Called to indicate that an extension was used.
5299 $extension_seen{$ext} = 1;
5302 # Called to ask whether source files have been seen . If HEADERS is 1,
5303 # headers can be included.
5306 local ($headers) = @_;
5314 local (@exts) = &lang_extensions ('header');
5318 return scalar keys %extension_seen > $headers;
5321 # Register a single language. LANGUAGE is the name of the language.
5322 # Each OPTION is either of the form NAME=VALUE, or is a file extension
5324 sub register_language
5326 local ($language, @options) = @_;
5329 $language_map{$language . '-ansi-p'} = 0;
5330 $language_map{$language . '-linker'} = '';
5331 $language_map{$language . '-autodep'} = 'no';
5332 $language_map{$language . '-derived-autodep'} = 'no';
5335 foreach $iter (@options)
5337 if ($iter =~ /^(.*)=(.*)$/)
5339 $language_map{$language . '-' . $1} = $2;
5341 elsif (defined $extension_map{$iter})
5343 &prog_error ("duplicate extension $iter");
5347 $extension_map{$iter} = $language;
5352 # This function is used to find a path from a user-specified suffix to
5353 # `o' or to some other suffix we recognize internally, eg `cc'.
5356 local ($source_ext) = @_;
5358 # FIXME: hard-coding `o' is a mistake. Doing something
5359 # intelligent is harder.
5360 while ($extension_map{$source_ext} eq ''
5361 && $source_ext ne 'o'
5362 && defined $suffix_rules{$source_ext})
5364 $source_ext = $suffix_rules{$source_ext};
5371 ################################################################
5373 # Pretty-print something. HEAD is what should be printed at the
5374 # beginning of the first line, FILL is what should be printed at the
5375 # beginning of every subsequent line.
5376 sub pretty_print_internal
5378 local ($head, $fill, @values) = @_;
5380 local ($column) = length ($head);
5381 local ($result) = $head;
5383 # Fill length is number of characters. However, each Tab
5384 # character counts for eight. So we count the number of Tabs and
5386 local ($fill_length) = length ($fill);
5387 $fill_length += 7 * ($fill =~ tr/\t/\t/d);
5389 local ($bol) = ($head eq '');
5392 # "71" because we also print a space.
5393 if ($column + length ($_) > 71)
5395 $result .= " \\\n" . $fill;
5396 $column = $fill_length;
5400 $result .= ' ' unless $bol;
5402 $column += length ($_) + 1;
5410 # Pretty-print something and append to output_vars.
5413 $output_vars .= &pretty_print_internal (@_);
5416 # Pretty-print something and append to output_rules.
5417 sub pretty_print_rule
5419 $output_rules .= &pretty_print_internal (@_);
5423 ################################################################
5425 # See if a target exists.
5428 local ($target) = @_;
5429 return defined $targets{$target};
5432 # See if two conditionals are the same.
5433 sub conditional_same
5435 local ($cond1, $cond2) = @_;
5437 return (&conditional_true_when ($cond1, $cond2)
5438 && &conditional_true_when ($cond2, $cond1));
5441 # See if a conditional is true. Both arguments are conditional
5442 # strings. This returns true if the first conditional is true when
5443 # the second conditional is true.
5444 sub conditional_true_when
5446 local ($cond, $when) = @_;
5448 # Check the easy case first.
5454 # Check each component of $cond, which looks @COND1@@COND2@.
5455 foreach $comp (split ('@', $cond))
5457 # The way we split will give null strings between each
5461 if (index ($when, '@' . $comp . '@') == -1)
5470 # Check for an ambiguous conditional. This is called when a variable
5471 # or target is being defined conditionally. If we already know about
5472 # a definition that is true under the same conditions, then we have an
5474 sub check_ambiguous_conditional
5476 local ($var_name, $cond) = @_;
5477 local (@cond_vals) = split (' ', $conditional{$var_name});
5480 local ($vcond) = shift (@cond_vals);
5482 if (&conditional_true_when ($vcond, $cond)
5483 || &conditional_true_when ($cond, $vcond))
5485 &am_line_error ($var_name,
5486 "$var_name multiply defined in condition");
5491 # See if a variable exists. The first argument is the variable name,
5492 # and the optional second argument is the condition which we should
5493 # check. If no condition is given, we currently return true if the
5494 # variable is defined under any condition.
5495 sub variable_defined
5497 local ($var, $cond) = @_;
5498 if (defined $targets{$var})
5500 &am_line_error ($var, "\`$var' is target; expected variable");
5503 elsif (defined $contents{$var})
5505 if ($cond && $conditional{$var})
5507 # We have been asked to check for a particular condition,
5508 # and the variable is defined conditionally. We need to
5509 # look through the conditions under which the variable is
5510 # defined, and see if any of them match the conditional we
5511 # have been asked to check.
5512 local (@cond_vars) = split (' ', $conditional{$var});
5515 if (&conditional_same ($cond, shift (@cond_vars)))
5517 # Even a conditional examination is good enough
5518 # for us. FIXME: really should maintain examined
5519 # status on a per-condition basis.
5520 $content_seen{$var} = 1;
5526 # The variable is not defined for the given condition.
5530 $content_seen{$var} = 1;
5536 # Mark a variable as examined.
5537 sub examine_variable
5540 &variable_defined ($var);
5543 # Quote a value in order to put it in $conditional. We need to quote
5544 # spaces, and we need to handle null strings, so that we can later
5545 # retrieve values by splitting on space.
5549 $val =~ tr/ \t\n/\001\003\004/;
5550 $val = "\002" if $val eq '';
5554 # Unquote a value in $conditional.
5555 sub unquote_cond_val
5558 $val =~ tr/\001\003\004/ \t\n/;
5563 # Return the set of conditions for which a variable is defined.
5565 # If the variable is not defined conditionally, and is not defined in
5566 # terms of any variables which are defined conditionally, then this
5567 # returns the empty list.
5569 # If the variable is defined conditionally, but is not defined in
5570 # terms of any variables which are defined conditionally, then this
5571 # returns the list of conditions for which the variable is defined.
5573 # If the variable is defined in terms of any variables which are
5574 # defined conditionally, then this returns a full set of permutations
5575 # of the subvariable conditions. For example, if the variable is
5576 # defined in terms of a variable which is defined for @COND_TRUE@,
5577 # then this returns both @COND_TRUE@ and @COND_FALSE@. This is
5578 # because we will need to define the variable under both conditions.
5580 sub variable_conditions
5588 foreach $cond (&variable_conditions_sub ($var, '', ()))
5590 $uniqify{$cond} = 1;
5593 @uniq_list = sort keys %uniqify;
5594 # Note we cannot just do `return sort keys %uniqify', because this
5595 # function is sometimes used in a scalar context.
5599 # A subroutine of variable_conditions. We only return conditions
5600 # which are true for all the conditions in @PARENT_CONDS.
5601 sub variable_conditions_sub
5603 local ($var, $parent, @parent_conds) = @_;
5604 local (@new_conds) = ();
5606 if (defined $vars_scanned{$var})
5608 &am_line_error ($parent, "variable \`$var' recursively defined");
5611 $vars_scanned{$var} = 1;
5613 if (! $conditional{$var})
5615 foreach (split (' ', $contents{$var}))
5617 # If a comment seen, just leave.
5620 # Handle variable substitutions.
5621 if (/^\$\{(.*)\}$/ || /^\$\((.*)\)$/)
5624 &variable_conditions_sub ($1, $var, @parent_conds));
5628 # Now we want to return all permutations of the subvariable
5630 local (%allconds, $item);
5631 foreach $item (@new_conds)
5633 foreach (split ('@', $item))
5637 $allconds{$_ . '_TRUE'} = 1;
5641 # Unset our entry in vars_scanned. We only care about recursive
5643 delete $vars_scanned{$var};
5645 return &variable_conditions_permutations (sort keys %allconds);
5648 local (@this_conds) = ();
5649 local (@condvals) = split (' ', $conditional{$var});
5652 local ($cond) = shift (@condvals);
5653 local ($val) = &unquote_cond_val (shift (@condvals));
5658 local ($parent_cond);
5659 foreach $parent_cond (@parent_conds)
5661 if (! &conditional_true_when ($parent_cond, $cond))
5671 push (@this_conds, $cond);
5673 push (@parent_conds, $cond);
5674 local (@subvar_conds) = ();
5675 foreach (split (' ', $val))
5677 # If a comment seen, just leave.
5680 # Handle variable substitutions.
5681 if (/^\$\{(.*)\}$/ || /^\$\((.*)\)$/)
5683 push (@subvar_conds,
5684 &variable_conditions_sub ($1, $var, @parent_conds));
5687 pop (@parent_conds);
5689 # If there are no conditional subvariables, then we want to
5690 # return this condition. Otherwise, we want to return the
5691 # permutations of the subvariables.
5692 if (! @subvar_conds)
5694 push (@new_conds, $cond);
5698 push (@new_conds, &variable_conditions_reduce (@subvar_conds));
5702 # Unset our entry in vars_scanned. We only care about recursive
5704 delete $vars_scanned{$var};
5709 # If we are being called on behalf of another variable, we need to
5710 # return all possible permutations of the conditions. We have
5711 # already handled everything in @this_conds along with their
5712 # subvariables. We now need to add any permutations that are not
5715 foreach $this_cond (@this_conds)
5718 &variable_conditions_permutations (split('@', $this_cond));
5720 foreach $perm (@perms)
5724 foreach $scan (@this_conds)
5726 if (&conditional_true_when ($perm, $scan)
5727 || &conditional_true_when ($scan, $perm))
5738 local ($parent_cond);
5739 foreach $parent_cond (@parent_conds)
5741 if (! &conditional_true_when ($parent_cond, $perm))
5751 # This permutation was not already handled, and is valid
5753 push (@new_conds, $perm);
5760 # Subroutine for variable_conditions_sort
5761 sub variable_conditions_cmp
5767 return (length ($as) <=> length ($bs)
5771 # Sort a list of conditionals so that only the exclusive ones are
5772 # retained. For example, if both @COND1_TRUE@@COND2_TRUE@ and
5773 # @COND1_TRUE@ are in the list, discard the latter.
5774 sub variable_conditions_reduce
5776 local (@conds) = @_;
5779 foreach $cond (sort variable_conditions_cmp @conds)
5783 foreach $scan (@ret)
5785 if (&conditional_true_when ($cond, $scan))
5798 # Return a list of permutations of a conditional string.
5799 sub variable_conditions_permutations
5801 local (@comps) = @_;
5804 local ($comp) = shift (@comps);
5805 return &variable_conditions_permutations (@comps)
5807 local ($neg) = $comp;
5808 $neg =~ s/TRUE$/TRUEO/;
5809 $neg =~ s/FALSE$/TRUE/;
5810 $neg =~ s/TRUEO$/FALSE/;
5813 foreach $sub (&variable_conditions_permutations (@comps))
5815 push (@ret, '@' . $comp . '@' . $sub);
5816 push (@ret, '@' . $neg . '@' . $sub);
5820 push (@ret, '@' . $comp . '@');
5821 push (@ret, '@' . $neg . '@');
5826 # Warn if a variable is conditionally defined. This is called if we
5827 # are using the value of a variable.
5828 sub variable_conditionally_defined
5830 local ($var, $parent) = @_;
5831 if ($conditional{$var})
5835 &am_line_error ($parent,
5836 "warning: automake does not support conditional definition of $var in $parent");
5840 &am_line_error ($parent,
5841 "warning: automake does not support $var being defined conditionally")
5846 # Get the value of a variable. This just returns $contents, but warns
5847 # if the variable is conditionally defined.
5851 &variable_conditionally_defined ($var);
5852 return $contents{$var};
5855 # Convert a variable value to a list, split as whitespace. This will
5856 # recursively follow $(...) and ${...} inclusions. It preserves @...@
5857 # substitutions. If COND is 'all', then all values under all
5858 # conditions should be returned; if COND is a particular condition
5859 # (all conditions are surrounded by @...@) then only the value for
5860 # that condition should be returned; otherwise, warn if VAR is
5861 # conditionally defined. SCANNED is a global hash listing whose keys
5862 # are all the variables already scanned; it is an error to rescan a
5866 local ($var, $val, $cond) = @_;
5870 $val =~ s/\\(\n|$)/ /g;
5872 foreach (split (' ', $val))
5874 # If a comment seen, just leave.
5877 # Handle variable substitutions.
5878 if (/^\$\{([^}]*)\}$/ || /^\$\(([^)]*)\)$/)
5880 local ($varname) = $1;
5882 # If the user uses a losing variable name, just ignore it.
5883 # This isn't ideal, but people have requested it.
5884 next if ($varname =~ /\@.*\@/);
5888 if ($varname =~ /^([^:]*):([^=]*)=(.*)$/)
5892 ($from = $2) =~ s/(\W)/\\$1/g;
5896 @temp_list = &variable_value_as_list_worker ($1, $cond, $var);
5898 # Now rewrite the value if appropriate.
5901 grep (s/$from$/$to/, @temp_list);
5904 push (@result, @temp_list);
5915 # Return contents of variable as list, split as whitespace. This will
5916 # recursively follow $(...) and ${...} inclusions. It preserves @...@
5917 # substitutions. If COND is 'all', then all values under all
5918 # conditions should be returned; if COND is a particular condition
5919 # (all conditions are surrounded by @...@) then only the value for
5920 # that condition should be returned; otherwise, warn if VAR is
5921 # conditionally defined. If PARENT is specified, it is the name of
5922 # the including variable; this is only used for error reports.
5923 sub variable_value_as_list_worker
5925 local ($var, $cond, $parent) = @_;
5928 if (defined $targets{$var})
5930 &am_line_error ($var, "\`$var' is target; expected variable");
5932 elsif (! defined $contents{$var} && ! defined $am_var_defs{$var})
5934 &am_line_error ($parent, "variable \`$var' not defined");
5936 elsif (defined $vars_scanned{$var})
5938 # `vars_scanned' is a global we use to keep track of which
5939 # variables we've already examined.
5940 &am_line_error ($parent, "variable \`$var' recursively defined");
5942 elsif ($cond eq 'all' && $conditional{$var})
5944 $vars_scanned{$var} = 1;
5945 local (@condvals) = split (' ', $conditional{$var});
5949 local ($val) = &unquote_cond_val (shift (@condvals));
5950 push (@result, &value_to_list ($var, $val, $cond));
5953 elsif ($cond && $conditional{$var})
5955 $vars_scanned{$var} = 1;
5956 local (@condvals) = split (' ', $conditional{$var});
5960 local ($vcond) = shift (@condvals);
5961 local ($val) = &unquote_cond_val (shift (@condvals));
5962 if (&conditional_true_when ($vcond, $cond))
5964 # Warn if we have an ambiguity. It's hard to know how
5965 # to handle this case correctly.
5966 &variable_conditionally_defined ($var, $parent)
5969 push (@result, &value_to_list ($var, $val, $cond));
5973 elsif (defined $am_var_defs{$var})
5975 $vars_scanned{$var} = 1;
5976 &variable_conditionally_defined ($var, $parent);
5977 $content_seen{$var} = 1;
5978 push (@result, &value_to_list ($var, $am_var_defs{$var}, $cond));
5982 $vars_scanned{$var} = 1;
5983 &variable_conditionally_defined ($var, $parent);
5984 $content_seen{$var} = 1;
5985 push (@result, &value_to_list ($var, $contents{$var}, $cond));
5988 # Unset our entry in vars_scanned. We only care about recursive
5990 delete $vars_scanned{$var};
5995 # This is just a wrapper for variable_value_as_list_worker that
5996 # initializes the global hash `vars_scanned'. This hash is used to
5997 # avoid infinite recursion.
5998 sub variable_value_as_list
6000 local ($var, $cond, $parent) = @_;
6002 return &variable_value_as_list_worker ($var, $cond, $parent);
6006 # define_variable ($VAR, $VALUE)
6007 # ------------------------------
6008 # Define a new variable VAR to VALUE, but only if not already defined.
6011 local ($var, $value) = @_;
6013 if (! defined $contents{$var})
6015 $output_vars .= $var . ' = ' . $value . "\n";
6016 $contents{$var} = $value;
6017 $content_seen{$var} = 1;
6019 elsif ($var_was_plus_eq{$var})
6021 &am_line_error ($var, "internally generated variable \`$var' was set with \`+='");
6025 # Like define_variable, but the value is a list, and the variable may
6026 # be defined conditionally. The second argument is the conditional
6027 # under which the value should be defined; this should be the empty
6028 # string to define the variable unconditionally. The third argument
6029 # is a list holding the values to use for the variable. The value is
6030 # pretty printed in the output file.
6031 sub define_pretty_variable
6033 local ($var, $cond, @value) = @_;
6034 if (! defined $contents{$var}
6035 || ($cond && ! &variable_defined ($var, $cond)))
6037 $contents{$var} = join (' ', @value);
6040 if ($conditional{$var})
6042 $conditional{$var} .= ' ';
6046 $conditional{$var} = '';
6048 $conditional{$var} .= ($cond
6050 . "e_cond_val ($contents{$var}));
6052 &pretty_print ($cond . $var . ' = ', $cond, @value);
6053 $content_seen{$var} = 1;
6057 # Like define_variable, but define a variable to be the configure
6058 # substitution by the same name.
6059 sub define_configure_variable
6062 local ($value) = '@' . $var . '@';
6063 &define_variable ($var, $value);
6066 # Define a compiler variable. We also handle defining the `LT'
6067 # version of the command when using libtool.
6068 sub define_compiler_variable
6070 local ($var, $ltcompile, $value) = @_;
6071 local ($name) = $var;
6072 &define_variable ($name, $value);
6073 &define_variable ('LT' . $name, $ltcompile . $value)
6077 # Define a variable that represents a program to run. If in Cygnus
6078 # mode, the program is searched for in the build (or source) tree.
6079 # Otherwise no searching is done at all. Arguments are:
6080 # * VAR Name of variable to define
6081 # * WHATDIR Either `src' or `build', depending on where program should
6082 # be found. (runtest is in srcdir!)
6083 # * SUBDIR Subdir of top-level dir
6084 # * PROGRAM Name of program
6085 # * OVERRIDE If specified, the name of the program to use when not in
6086 # Cygnus mode. Defaults to PROGRAM.
6087 sub define_program_variable
6089 local ($var, $whatdir, $subdir, $program, $override) = @_;
6093 $override = $program;
6098 local ($full) = ('$(top_' . $whatdir . 'dir)/../'
6099 . $subdir . '/' . $program);
6100 &define_variable ($var, ('`if test -f ' . $full
6101 . '; then echo ' . $full . '; else echo '
6102 . $program . '; fi`'));
6106 &define_variable ($var, $override);
6111 ################################################################
6113 # Read Makefile.am and set up %contents. Simultaneously copy lines
6114 # from Makefile.am into $output_trailer or $output_vars as
6115 # appropriate. NOTE we put rules in the trailer section. We want
6116 # user rules to come after our generated stuff.
6119 local ($amfile) = @_;
6122 open (AM_FILE, $amfile) || die "automake: couldn't open \`$amfile': $!\n";
6123 print "automake: reading $amfile\n" if $verbose;
6125 local ($saw_bk) = 0;
6126 local ($was_rule) = 0;
6127 local ($spacing) = '';
6128 local ($comment) = '';
6129 local ($last_var_name) = '';
6132 # We save the conditional stack on entry, and then check to make
6133 # sure it is the same on exit. This lets us conditonally include
6135 local (@saved_cond_stack) = @conditional_stack;
6139 if (/$IGNORE_PATTERN/o)
6141 # Merely delete comments beginning with two hashes.
6143 elsif (/$WHITE_PATTERN/o)
6145 # Stick a single white line before the incoming macro or rule.
6149 elsif (/$COMMENT_PATTERN/o)
6151 # Stick comments before the incoming macro or rule. Make
6152 # sure a blank line preceeds first block of comments.
6153 $spacing = "\n" unless $blank;
6155 $comment .= $spacing . $_;
6164 $output_vars .= $comment . "\n";
6168 local ($is_ok_macro);
6172 unless substr ($_, -1, 1) eq "\n";
6174 # Don't look at MAINTAINER_MODE_TRUE here. That shouldn't be
6175 # used by users. @MAINT@ is an anachronism now.
6176 $_ =~ s/\@MAINT\@//g
6177 unless $seen_maint_mode;
6179 if (/$IGNORE_PATTERN/o)
6181 # Merely delete comments beginning with two hashes.
6183 elsif (/$WHITE_PATTERN/o)
6185 # Stick a single white line before the incoming macro or rule.
6187 &am_line_error ($., "blank line following trailing backslash")
6190 elsif (/$COMMENT_PATTERN/o)
6192 # Stick comments before the incoming macro or rule.
6193 $comment .= $spacing . $_;
6195 &am_line_error ($., "comment following trailing backslash")
6202 $output_trailer .= join ('', @conditional_stack) . $_;
6208 $contents{$last_var_name} .= ' '
6209 unless $contents{$last_var_name} =~ /\s$/;
6210 $contents{$last_var_name} .= $_;
6211 if (@conditional_stack)
6213 $conditional{$last_var_name} .= "e_cond_val ($_);
6217 elsif (/$IF_PATTERN/o)
6219 &am_line_error ($., "$1 does not appear in AM_CONDITIONAL")
6220 if (! $configure_cond{$1});
6221 push (@conditional_stack, "\@" . $1 . "_TRUE\@");
6223 elsif (/$ELSE_PATTERN/o)
6225 if (! @conditional_stack)
6227 &am_line_error ($., "else without if");
6229 elsif ($conditional_stack[$#conditional_stack] =~ /_FALSE\@$/)
6231 &am_line_error ($., "else after else");
6235 $conditional_stack[$#conditional_stack]
6236 =~ s/_TRUE\@$/_FALSE\@/;
6239 elsif (/$ENDIF_PATTERN/o)
6241 if (! @conditional_stack)
6243 &am_line_error ($., "endif without if");
6247 pop @conditional_stack;
6250 elsif (/$RULE_PATTERN/o)
6254 if (defined $contents{$1}
6255 && (@conditional_stack
6256 ? ! defined $conditional{$1}
6257 : defined $conditional{$1}))
6260 "$1 defined both conditionally and unconditionally");
6262 # Value here doesn't matter; for targets we only note
6266 local ($cond_string) = join ('', @conditional_stack);
6267 if (@conditional_stack)
6269 if ($conditional{$1})
6271 &check_ambiguous_conditional ($1, $cond_string);
6272 $conditional{$1} .= ' ';
6276 $conditional{$1} = '';
6278 $conditional{$1} .= $cond_string . ' 1';
6280 $content_lines{$1} = $.;
6281 $output_trailer .= $comment . $spacing . $cond_string . $_;
6282 $comment = $spacing = '';
6285 # Check the rule for being a suffix rule. If so, store in
6288 local ($source_suffix);
6289 local ($object_suffix);
6291 if (($source_suffix, $object_suffix) = ($1 =~ $SUFFIX_RULE_PATTERN))
6293 $suffix_rules{$source_suffix} = $object_suffix;
6294 print "Sources ending in .$source_suffix become .$object_suffix\n" if $verbose;
6295 $source_suffix_pattern = "(" . join ('|', keys %suffix_rules) . ")";
6298 # FIXME: make sure both suffixes are in SUFFIXES? Or set
6299 # SUFFIXES from suffix_rules?
6301 elsif (($is_ok_macro = /$MACRO_PATTERN/o)
6302 || /$BOGUS_MACRO_PATTERN/o)
6304 # Found a macro definition.
6306 $last_var_name = $1;
6307 if (defined $contents{$1}
6308 && (@conditional_stack
6309 ? ! defined $conditional{$1}
6310 : defined $conditional{$1}))
6313 "$1 defined both conditionally and unconditionally");
6316 if ($3 ne '' && substr ($3, -1) eq "\\")
6318 # We preserve the `\' because otherwise the long lines
6319 # that are generated will be truncated by broken
6329 if (! defined $contents{$last_var_name})
6331 # The first assignment to a macro sets the line
6332 # number. Ideally I suppose we would associate line
6333 # numbers with random bits of text.
6334 $content_lines{$last_var_name} = $.;
6336 # If first assignment, set `+=' indicator.
6337 $var_was_plus_eq{$last_var_name} =
6339 && ! defined $am_var_defs{$last_var_name});
6344 if (! defined $contents{$last_var_name}
6345 && defined $am_var_defs{$last_var_name})
6347 $contents{$last_var_name} = $am_var_defs{$last_var_name};
6349 if (substr ($contents{$last_var_name}, -1) eq "\n")
6351 # Insert a backslash before a trailing newline.
6352 $contents{$last_var_name}
6353 = substr ($contents{$last_var_name}, 0, -1) . "\\\n";
6355 $contents{$last_var_name} .= ' ' . $value;
6359 $contents{$last_var_name} = $value;
6361 local ($cond_string) = join ('', @conditional_stack);
6362 if (@conditional_stack)
6366 if ($conditional{$last_var_name})
6370 # If we're adding to the conditional, and it
6371 # exists, then we might want to simply replace
6372 # the old value with the new one.
6373 local (@new_vals, @cond_vals);
6374 @cond_vals = split (' ', $conditional{$last_var_name});
6377 local ($vcond) = shift (@cond_vals);
6378 push (@new_vals, $vcond);
6379 if (&conditional_same ($vcond, $cond_string))
6382 $val = (&unquote_cond_val (shift (@cond_vals))
6384 push (@new_vals, "e_cond_val ($val));
6388 push (@new_vals, shift (@cond_vals));
6393 $conditional{$last_var_name}
6394 = join (' ', @new_vals);
6400 &check_ambiguous_conditional ($last_var_name,
6402 $conditional{$last_var_name} .= ' ';
6408 $conditional{$last_var_name} = '';
6409 $val = $contents{$last_var_name};
6413 $conditional{$last_var_name} .= ($cond_string
6415 . "e_cond_val ($val));
6419 # FIXME: this doesn't always work correctly; it will group
6420 # all comments for a given variable, no matter where
6422 $am_vars{$last_var_name} = $comment . $spacing;
6423 $def_type{$last_var_name} = ($type eq ':') ? ':' : '';
6424 push (@var_list, $last_var_name);
6425 $comment = $spacing = '';
6429 &am_line_error ($., "bad macro name \`$last_var_name'")
6432 elsif (/$INCLUDE_PATTERN/o)
6436 if ($path =~ s/^\$\(top_srcdir\)\///)
6438 push (@include_stack, "\$\(top_srcdir\)/$path");
6442 $path =~ s/\$\(srcdir\)\///;
6443 push (@include_stack, "\$\(srcdir\)/$path");
6444 $path = $relative_dir . "/" . $path;
6446 &read_am_file ($path);
6450 # This isn't an error; it is probably a continued rule.
6451 # In fact, this is what we assume.
6453 $output_trailer .= ($comment . $spacing
6454 . join ('', @conditional_stack) . $_);
6455 $comment = $spacing = '';
6462 $output_trailer .= $comment;
6464 if (join (' ', @saved_cond_stack) ne join (' ', @conditional_stack))
6466 if (@conditional_stack)
6468 &am_error ("unterminated conditionals: @conditional_stack");
6472 # FIXME: better error message here.
6473 &am_error ("conditionals not nested in include file");
6479 # define_standard_variables ()
6480 # ----------------------------
6481 # A helper for read_main_am_file which initializes configure variables
6482 # and variables from header-vars.am. This is a subr so we can call it
6484 sub define_standard_variables
6486 # Compute relative location of the top object directory.
6487 local (@topdir) = ();
6488 foreach (split (/\//, $relative_dir))
6490 next if $_ eq '.' || $_ eq '';
6497 push (@topdir, '..');
6500 @topdir = ('.') if ! @topdir;
6502 $top_builddir = join ('/', @topdir);
6504 &file_contents ('header-vars',
6505 &transform ('top_builddir' => $top_builddir));
6507 # Generate some useful variables when AC_CANONICAL_* used. FIXME:
6508 # this should use generic %configure_vars method.
6509 if ($seen_canonical)
6511 local ($curs, %vars);
6512 $vars{'host_alias'} = 'host_alias';
6513 $vars{'host_triplet'} = 'host';
6514 if ($seen_canonical == $AC_CANONICAL_SYSTEM)
6516 $vars{'build_alias'} = 'build_alias';
6517 $vars{'build_triplet'} = 'build';
6518 $vars{'target_alias'} = 'target_alias';
6519 $vars{'target_triplet'} = 'target';
6521 foreach $curs (sort keys %vars)
6523 $output_vars .= "$curs = \@$vars{$curs}\@\n";
6524 $contents{$curs} = "\@$vars{$curs}\@";
6529 foreach $curs (sort keys %configure_vars)
6531 &define_configure_variable ($curs);
6535 # Read main am file.
6536 sub read_main_am_file
6538 local ($amfile) = @_;
6540 # The keys here are variables we want to dump at the end of this
6541 # function. The values are corresponding comments.
6542 local (%am_vars) = ();
6543 local (@var_list) = ();
6544 local (%def_type) = ();
6546 # This supports the strange variable tricks we are about to play.
6547 &prog_error ("variable defined before read_main_am_file")
6548 if scalar keys %contents > 0;
6550 # We want to predefine as many variables as possible. This lets
6551 # the user set them with `+=' in Makefile.am. However, we don't
6552 # want these initial definitions to end up in the output quite
6553 # yet. So we adopt a hack: read the `.am' file twice, throwing
6554 # away the output the first time. We also squirrel away a list of
6555 # all the variables defined by the .am file so that we know which
6556 # ones to remove from the content list.
6559 &define_standard_variables;
6560 local (%saved_contents) = %contents;
6562 # Read user file, but discard text of variable assignments we just
6565 &read_am_file ($amfile);
6567 # Now dump the variables that were defined. We do it in the same
6568 # order in which they were defined (skipping duplicates).
6570 foreach $curs (@var_list)
6572 next if $done{$curs};
6575 $output_vars .= $am_vars{$curs};
6576 if ($conditional{$curs})
6578 local (@cond_vals) = split (' ', $conditional{$curs});
6581 local ($vcond) = shift (@cond_vals);
6582 local ($val) = &unquote_cond_val (shift (@cond_vals));
6583 $output_vars .= ($vcond . $curs . ' '
6584 . $def_type{$curs} . "= ");
6586 foreach $line (split ("\n", $val))
6588 $output_vars .= $vcond . $line . "\n";
6590 $output_vars .= "\n"
6596 $output_vars .= ($curs . ' ' . $def_type{$curs} . '= '
6597 . $contents{$curs} . "\n");
6601 # Generate copyright header for generated Makefile.in.
6602 local ($ov) = $output_vars;
6603 $output_vars = ("# $in_file_name generated automatically by automake "
6604 . $VERSION . " from $am_file_name\n");
6605 $output_vars .= $gen_copyright;
6607 # Now go through and delete all the variables that the user did
6610 foreach $var (keys %saved_contents)
6612 if ($contents{$var} eq $saved_contents{$var})
6614 delete $contents{$var};
6618 # Re-read the standard variables, and this time keep their
6619 # contributions to the output. Then add the user's output to the
6621 &define_standard_variables;
6622 $output_vars .= $ov;
6626 ################################################################
6628 sub initialize_global_constants
6630 # Values for AC_CANONICAL_*
6631 $AC_CANONICAL_HOST = 1;
6632 $AC_CANONICAL_SYSTEM = 2;
6634 # Associative array of standard directory names. Entry is TRUE if
6635 # corresponding directory should be installed during
6636 # 'install-exec' phase.
6654 # Commonly found files we look for and automatically include in
6658 'README', 'THANKS', 'TODO', 'NEWS', 'COPYING', 'COPYING.LIB',
6659 'INSTALL', 'ABOUT-NLS', 'ChangeLog', 'configure.ac',
6660 'configure.in', 'configure', 'config.guess', 'config.sub',
6661 'AUTHORS', 'BACKLOG', 'ABOUT-GNU', 'libversion.in',
6662 'mdate-sh', 'mkinstalldirs', 'install-sh', 'texinfo.tex',
6663 'ansi2knr.c', 'ansi2knr.1', 'elisp-comp',
6664 # ltconfig appears here for compatibility with old versions
6666 'ylwrap', 'acinclude.m4', @libtoolize_files, @libtoolize_sometimes,
6667 'missing', 'depcomp', 'compile', 'py-compile'
6670 # Commonly used files we auto-include, but only sometimes.
6673 'aclocal.m4', 'acconfig.h', 'config.h.top',
6674 'config.h.bot', 'stamp-h.in', 'stamp-vti'
6678 -a, --add-missing add missing standard files to package
6679 --amdir=DIR directory storing config files
6680 -c, --copy with -a, copy missing files (default is symlink)
6681 --cygnus assume program is part of Cygnus-style tree
6682 --force-missing force update of standard files
6683 --foreign set strictness to foreign
6684 --gnits set strictness to gnits
6685 --gnu set strictness to gnu
6686 --help print this help, then exit
6687 -i, --ignore-deps disable dependency tracking code
6688 --include-deps enable dependency tracking code
6689 --no-force only update Makefile.in's that are out of date
6690 -o DIR, --output-dir=DIR
6691 put generated Makefile.in's into DIR
6692 -v, --verbose verbosely list files processed
6693 --version print version number, then exit\n";
6695 # Copyright on generated Makefile.ins.
6697 # Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000
6698 # Free Software Foundation, Inc.
6699 # This Makefile.in is free software; the Free Software Foundation
6700 # gives unlimited permission to copy and/or distribute it,
6701 # with or without modifications, as long as this notice is preserved.
6703 # This program is distributed in the hope that it will be useful,
6704 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
6705 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
6706 # PARTICULAR PURPOSE.
6709 # This complex find command will try to avoid changing the modes of
6710 # links into the source tree, in case they're hard-linked. It will
6711 # also make directories writable by everybody, because some
6712 # brain-dead tar implementations change ownership and permissions of
6713 # a directory before extracting the files, thus becoming unable to
6715 # Ignore return result from chmod, because it might give an error
6716 # if we chmod a symlink.
6717 # Another nastiness: if the file is unreadable by us, we make it
6718 # readable regardless of the number of links to it. This only
6719 # happens in perverse cases.
6720 # We use $(install_sh) because that is a known-portable way to
6721 # modify the file in place in the source tree.
6722 $dist_header = ' -find $(distdir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \\
6723 ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \\
6724 ! -type d ! -perm -400 -exec chmod a+r {} \; -o \\
6725 ! -type d ! -perm -444 -exec $(SHELL) $(install_sh) -c -m a+r {} {} \; \\
6726 || chmod -R a+r $(distdir)
6728 $dist{'dist-bzip2'} = ("\t"
6729 . '$(AMTAR) chof - $(distdir) | bzip2 -9 -c > $(distdir).tar.bz2'
6731 $dist{'dist-tarZ'} = ("\t"
6732 . '$(AMTAR) chof - $(distdir) | compress -c > $(distdir).tar.Z'
6734 $dist{'dist-shar'} = ("\t"
6735 . 'shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c > $(distdir).shar.gz'
6737 $dist{'dist-zip'} = ("\t" . '-rm -f $(distdir).zip' . "\n" .
6738 "\t" . 'zip -rq $(distdir).zip $(distdir)' . "\n");
6740 # Note that we don't use GNU tar's `-z' option. One reason (but
6741 # not the only reason) is that some versions of tar (e.g., OSF1)
6742 # interpret `-z' differently.
6743 $dist{'dist'} = ("\t"
6744 . '$(AMTAR) chof - $(distdir) | GZIP=$(GZIP_ENV) gzip -c > $(distdir).tar.gz'
6746 $dist_trailer = "\t" . '-chmod -R a+w $(distdir) > /dev/null 2>&1; rm -rf $(distdir)' . "\n";
6749 # (Re)-Initialize per-Makefile.am variables.
6750 sub initialize_per_input
6752 # These two variables are used when generating each Makefile.in.
6753 # They hold the Makefile.in until it is ready to be printed.
6756 $output_trailer = '';
6758 $output_header = '';
6760 # Suffixes found during a run.
6763 # This holds the contents of a Makefile.am, as parsed by
6767 # This holds the names which are targets. These also appear in
6771 # This maps a variable name onto a flag. The flag is true iff the
6772 # variable was first defined with `+='.
6773 %var_was_plus_eq = ();
6775 # This holds definitions of all variables defined in .am files.
6776 # This is used during startup to determine which variables can be
6777 # assigned with `+='.
6780 # For a variable or target which is defined conditionally, this
6781 # holds an array of the conditional values. The array is composed
6782 # of pairs of condition strings (the variables which configure
6783 # will substitute) and values (the value of a target is
6784 # meaningless). For an unconditional variable, this is empty.
6787 # This holds the line numbers at which various elements of
6788 # %contents are defined.
6789 %content_lines = ();
6791 # This holds a 1 if a particular variable was examined.
6794 # This is the conditional stack.
6795 @conditional_stack = ();
6797 # This holds the set of included files.
6798 @include_stack = ();
6800 # This holds the "relative directory" of the current Makefile.in.
6801 # Eg for src/Makefile.in, this is "src".
6804 # This holds a list of files that are included in the
6808 # This holds a list of directories which we must create at `dist'
6809 # time. This is used in some strange scenarios involving weird
6810 # AC_OUTPUT commands.
6813 # List of dependencies for the obvious targets.
6826 # Holds the dependencies of targets which dependencies are factored.
6827 # Typically, `.PHONY' will appear in plenty of *.am files, but must
6828 # be output once. Arguably all pure dependencies could be subject
6829 # to this factorization, but it is not unpleasant to have paragraphs
6830 # in Makefile: keeping related stuff altogether.
6834 'mostlyclean-am' => [],
6835 'maintainer-clean-am' => [],
6836 'distclean-am' => [],
6838 'mostlyclean' => [],
6839 'maintainer-clean' => [],
6843 # Holds the factored actions. Tied to %DEPENDENCIES, i.e., filled
6844 # only when keys exists in %DEPENDENCIES.
6847 # A list of files deleted by `maintainer-clean'.
6848 @maintainer_clean_files = ();
6850 # These are pretty obvious, too. They are used to define the
6851 # SOURCES and OBJECTS variables.
6854 # Sources which go in the distribution.
6857 # This hash maps object file names onto their corresponding source
6858 # file names. This is used to ensure that each object is created
6859 # by a single source file.
6862 # This keeps track of the directories for which we've already
6863 # created `.dirstamp' code.
6864 %directory_map = ();
6866 # These variables track inclusion of various compile-related .am
6867 # files. $included_generic_compile is TRUE if the basic code has
6868 # been included. $included_knr_compile is TRUE if the ansi2knr
6869 # code has been included. $included_libtool_compile is TRUE if
6870 # libtool support has been included.
6871 $included_generic_compile = 0;
6872 $included_knr_compile = 0;
6873 $included_libtool_compile = 0;
6875 # TRUE if install targets should work recursively.
6876 $recursive_install = 0;
6881 # Strictness levels.
6882 $strictness = $default_strictness;
6883 $strictness_name = $default_strictness_name;
6885 # Options from AUTOMAKE_OPTIONS.
6888 # Whether or not dependencies are handled. Can be further changed
6889 # in handle_options.
6890 $use_dependencies = $cmdline_use_dependencies;
6893 $local_maint_charset = $maint_charset;
6895 # All yacc and lex source filenames for this directory. Use
6896 # filenames instead of raw count so that multiple instances are
6897 # counted correctly (eg one yacc file can appear in multiple
6898 # programs without harm).
6902 # This is a list of all targets to run during "make dist".
6905 # Keys in this hash are the basenames of files which must depend
6907 %de_ansi_files = ();
6909 # This maps the source extension of a suffix rule to its
6910 # corresponding output extension.
6913 # This is a regular expression which matches all the known source
6914 # suffix. A source suffix is one that appears in the first
6915 # position of a suffix rule.
6916 $source_suffix_pattern = '';
6918 # This is the name of the recursive `all' target to use.
6919 $all_target = 'all-recursive';
6921 # This keeps track of which extensions we've seen (that we care
6923 %extension_seen = ();
6925 # This is random scratch space for the language finish functions.
6926 # Don't randomly overwrite it; examine other uses of keys first.
6927 %language_scratch = ();
6929 # We keep track of which objects need special (per-executable)
6930 # handling on a per-language basis.
6931 %lang_specific_files = ();
6933 # This is set when `handle_dist' has finished. Once this happens,
6934 # we should no longer push on dist_common.
6935 $handle_dist_run = 0;
6937 # True if we need `LINK' defined. This is a hack.
6942 ################################################################
6945 # &flatten ($STRING)
6946 # ------------------
6947 # Flatten the $STRING and return the result.
6962 # &file_contents ($BASENAME, [$COMMAND])
6963 # --------------------------------------
6964 # Return contents of a file from $am_dir, automatically skipping
6965 # macros or rules which are already known. Runs command on each line
6966 # as it is read; this command can modify $_.
6969 local ($basename, $command) = @_;
6970 local ($file) = $am_dir . '/' . $basename . '.am';
6972 &prog_error ("file_contents: $command")
6973 if $command ne '' && substr ($command, -1) ne ';';
6975 open (FC_FILE, $file)
6976 || die "automake: installation error: cannot open \`$file'\n";
6978 # print "automake: reading $file\n" if $verbose;
6980 # Swallow into $CONTENTS the whole content of the file, after
6981 # having performed the $COMMAND, and removed Automake comments.
6982 local ($contents) = '';
6986 $_ =~ s/\@MAINTAINER_MODE_TRUE\@//g
6987 unless $seen_maint_mode;
6989 $had_chars = length ($_) && $_ ne "\n";
6991 # If the transform caused all the characters to go away, then
6992 # ignore the line. Why do this? Because in Perl 4, a "next"
6993 # inside of an eval doesn't affect a loop outside the eval.
6994 # So we can't pass in a "transform" that uses next. We used
6995 # to do this. "Empty" also means consisting of a single
6997 next if $had_chars && ($_ eq '' || $_ eq "\n");
6999 # Merely delete comments beginning with two hashes.
7000 next if /$IGNORE_PATTERN/o;
7007 # We don't need more than two consecutive new-lines.
7008 $contents =~ s/\n{3,}/\n\n/g;
7010 # A rule has three parts: a list of targets, a list of dependencies,
7011 # and optionally actions.
7013 "^($TARGET_PATTERN(?:(?:\\\\\n|\\s)+$TARGET_PATTERN)*) *:([^=].*|)\$";
7016 # Process each Make `paragraph'.
7018 # A Make `paragraph' is delimited by a new line which is not
7019 # escaped, and not followed by a tab or a comment.
7021 # Frankly, unless you like fighting with Perl (you're a freak!),
7022 # if I were you I would not try some other implementation, it's
7023 # very easy falling either into extremely low RE matching
7024 # (backtracking...), or worse yet: infloop... For instance, (my)
7025 # perl goes loopy if you try to
7027 # $result_rules =~ /^($TARGET_PATTERN *)+: ($TARGET_PATTERN *)+\n\n/sm
7028 local ($result_vars) = '';
7029 local ($result_rules) = '';
7030 local ($comment) = '';
7031 foreach (split (/(?<!\\)\n(?![\t#])/, $contents))
7033 &am_file_error ("$basename.am",
7034 "blank line following trailing backslash:\n$_")
7036 &am_file_error ("$basename.am",
7037 "comment following trailing backslash:\n$_")
7042 # Stick empty line before the incoming macro or rule.
7045 elsif (/$COMMENT_PATTERN/mso)
7047 # Stick comments before the incoming macro or rule.
7050 elsif (/$RULE_PATTERN/mso)
7052 # Separate relationship from optional actions: the first
7053 # `new-line tab" not preceded by backslash (continuation
7055 # I'm quite shoked! It seems that (\\\n|[^\n]) is not the
7056 # same as `([^\n]|\\\n)!!! Don't swap it, it breaks.
7057 my ($relationship, $actions) =
7058 /^((?:\\\n|[^\n])*)(?:\n(\t.*))?$/som;
7060 # Separate targets from dependencies: the first colon.
7061 $relationship =~ /^([^:]+\S+) *: *(.*)$/som;
7062 my ($targets, $dependencies) = ($1, $2);
7063 # Remove the escaped new lines.
7064 # I don't know why, but I have to use a tmp $flat_deps.
7065 my $flat_deps = &flatten ($dependencies);
7066 my @deps = split (' ', $flat_deps);
7068 foreach (split (' ' , $targets))
7070 if (defined $dependencies{$_})
7072 &depend ($_, @deps);
7073 $actions{$_} .= $actions;
7077 # Free lance dependency. Output the rule for all the
7078 # targets instead of one by one.
7079 if (!defined $contents{$targets})
7081 # Some hair to avoid spurious trailing blank
7082 # when there are no dependencies.
7083 $result_rules .= "$comment$separator";
7084 $result_rules .= "$targets:";
7085 $result_rules .= " $dependencies"
7087 $result_rules .= "\n$actions\n";
7089 $comment = $separator = '';
7094 elsif (/$RULE_PATTERN/mso)
7096 $result_rules .= "$comment$separator$_\n"
7097 unless defined $contents{$1};
7098 $comment = $separator = '';
7100 elsif (/$MACRO_PATTERN/mso)
7102 $result_vars .= "$comment$separator$_\n"
7103 unless defined $contents{$1};
7104 $comment = $separator = '';
7105 &prog_error (".am macro \`$1' with trailing backslash at $file:$.")
7107 $am_var_defs{$1} = $3;
7111 # This isn't an error; it is probably some tokens which
7112 # configure is supposed to replace, such as `@SET-MAKE@'.
7113 $result_rules .= "$comment$separator$_\n";
7114 $comment = $separator = '';
7118 return $result_vars . $result_rules . $comment;
7122 # &transform (%PAIRS)
7123 # -------------------
7124 # Create a replacement expression suitable for file_contents
7125 # to replace each key of %PAIRS by its value.
7128 local (%pairs) = @_;
7129 local ($result) = '';
7132 foreach $pattern (sort keys %pairs)
7134 ($quoted = $pairs{$pattern}) =~ s/(\W)/\\$1/g;
7135 $result .= 's,\@' . $pattern . '\@,' . $quoted . ',g;';
7140 # Find all variable prefixes that are used for install directories. A
7141 # prefix `zar' qualifies iff:
7142 # * `zardir' is a variable.
7143 # * `zar_PRIMARY' is a variable.
7144 sub am_primary_prefixes
7146 local ($primary, $can_dist, @prefixes) = @_;
7148 local (%valid, $varname);
7149 grep ($valid{$_} = 0, @prefixes);
7150 $valid{'EXTRA'} = 0;
7151 foreach $varname (keys %contents)
7153 if ($varname =~ /^(nobase_)?(dist_|nodist_)?(.*)_$primary$/)
7155 if (($2 ne '' && ! $can_dist)
7156 || (! defined $valid{$3} && ! &variable_defined ($3 . 'dir')))
7158 # Note that a configure variable is always legitimate.
7159 # It is natural to name such variables after the
7160 # primary, so we explicitly allow it.
7161 if (! defined $configure_vars{$varname})
7163 &am_line_error ($varname, "invalid variable \`$varname'");
7168 # Ensure all extended prefixes are actually used.
7169 $valid{$1 . $2 . $3} = 1;
7177 # Handle `where_HOW' variable magic. Does all lookups, generates
7178 # install code, and possibly generates code to define the primary
7179 # variable. The first argument is the name of the .am file to munge,
7180 # the second argument is the primary variable (eg HEADERS), and all
7181 # subsequent arguments are possible installation locations. Returns
7182 # list of all values of all _HOW targets.
7184 # FIXME: this should be rewritten to be cleaner. It should be broken
7185 # up into multiple functions.
7187 # Usage is: am_install_var (OPTION..., file, HOW, where...)
7192 local ($do_clean) = 0;
7193 local ($do_require) = 1;
7194 local ($can_dist) = 0;
7195 local ($default_dist) = 0;
7198 if (defined $configure_vars{'LIBTOOL'})
7200 # Transform '@LIBTOOL ...@' to '$(LIBTOOL) ...'
7201 $ltxform = 's/\@LIBTOOL([^\@]*)\@/\$(LIBTOOL) $1/;';
7205 # Delete '@LIBTOOL ...@'
7206 $ltxform = 's/\@LIBTOOL([^\@]*)\@//;';
7212 $cygxform = 's/\@EXEEXT\@//g;';
7216 $cygxform = 's/\@EXEEXT\@/\$(EXEEXT)/g;';
7221 if ($args[0] eq '-clean')
7225 elsif ($args[0] eq '-noextra')
7229 elsif ($args[0] eq '-candist')
7233 elsif ($args[0] eq '-defaultdist')
7238 elsif ($args[0] !~ /^-/)
7245 local ($file, $primary, @prefixes) = @args;
7248 local (@result) = ();
7250 # Now that configure substitutions are allowed in where_HOW
7251 # variables, it is an error to actually define the primary. We
7252 # allow `JAVA', as it is customarily used to mean the Java
7253 # interpreter. This is but one of several Java hacks. Similarly,
7254 # `PYTHON' is customarily used to mean the Python interpreter.
7255 &am_line_error ($primary, "\`$primary' is an anachronism")
7256 if &variable_defined ($primary)
7257 && ($primary ne 'JAVA' && $primary ne 'PYTHON');
7260 # Look for misspellings. It is an error to have a variable ending
7261 # in a "reserved" suffix whose prefix is unknown, eg
7262 # "bni_PROGRAMS". However, unusual prefixes are allowed if a
7263 # variable of the same name (with "dir" appended) exists. For
7264 # instance, if the variable "zardir" is defined, then
7265 # "zar_PROGRAMS" becomes valid. This is to provide a little extra
7266 # flexibility in those cases which need it.
7267 local (%valid) = &am_primary_prefixes ($primary, $can_dist, @prefixes);
7269 # If a primary includes a configure substitution, then the EXTRA_
7270 # form is required. Otherwise we can't properly do our job.
7271 local ($require_extra);
7272 local ($warned_about_extra) = 0;
7274 local ($clean_file) = $file . '-clean';
7277 local ($nodir_name);
7278 local ($strip_subdir) = 1;
7279 foreach $X (sort keys %valid)
7281 $one_name = $X . '_' . $primary;
7282 if (&variable_defined ($one_name))
7284 # If subdir prefix should be preserved, do so.
7285 if ($X =~ /^nobase_/)
7291 # If files should be distributed, do so.
7294 if (($default_dist && $one_name !~ /^nodist_/)
7295 || (! $default_dist && $one_name =~ /^dist_/))
7297 &push_dist_common ('$(' . $one_name . ')');
7299 ($nodir_name = $X) =~ s/^(dist|nodist)_//;
7306 # Append actual contents of where_PRIMARY variable to
7309 foreach $rcurs (&variable_value_as_list ($one_name, 'all'))
7311 # Skip configure substitutions. Possibly bogus.
7312 if ($rcurs =~ /^\@.*\@$/)
7316 if (! $warned_about_extra)
7318 $warned_about_extra = 1;
7320 &am_line_error ($one_name,
7321 "\`$one_name' contains configure substitution, but shouldn't");
7325 # Check here to make sure variables defined in
7326 # configure.ac do not imply that EXTRA_PRIMARY
7328 elsif (! defined $configure_vars{$one_name})
7330 $require_extra = $one_name
7337 push (@result, $rcurs);
7340 # A blatant hack: we rewrite each _PROGRAMS primary to
7341 # include EXEEXT when in Cygwin32 mode.
7342 if ($seen_exeext && $primary eq 'PROGRAMS')
7344 local (@conds) = &variable_conditions ($one_name);
7345 local (@one_binlist);
7347 # FIXME: this definitely loses aesthetically; it
7348 # redefines $ONE_NAME. Instead we should arrange for
7349 # variable definitions to be output later, instead of
7355 foreach $rcurs (&variable_value_as_list ($one_name, ''))
7357 if ($rcurs =~ /\./ || $rcurs =~ /^\@.*\@$/)
7359 push (@one_binlist, $rcurs);
7363 push (@one_binlist, $rcurs . '$(EXEEXT)');
7367 delete $contents{$one_name};
7368 &define_pretty_variable ($one_name, '', @one_binlist);
7373 local ($condvals) = '';
7374 foreach $cond (@conds)
7377 local (@condval) = &variable_value_as_list ($one_name,
7379 foreach $rcurs (@condval)
7381 if ($rcurs =~ /\./ || $rcurs =~ /^\@.*\@$/)
7383 push (@one_binlist, $rcurs);
7387 push (@one_binlist, $rcurs . '$(EXEEXT)');
7391 push (@condvals, $cond);
7392 push (@condvals, join (' ', @one_binlist));
7395 delete $contents{$one_name};
7399 $cond = shift (@condvals);
7400 local (@val) = split (' ', shift (@condvals));
7401 &define_pretty_variable ($one_name, $cond, @val);
7406 # "EXTRA" shouldn't be used when generating clean targets,
7407 # all, or install targets.
7410 # We used to warn if EXTRA_FOO was defined uselessly,
7411 # but this was annoying.
7418 &file_contents ($clean_file,
7419 &transform ('DIR' => $X)
7422 &depend ('mostlyclean-am', 'mostlyclean-' . $X . $primary);
7423 &depend ('.PHONY', 'mostlyclean-' . $X . $primary);
7424 &depend ('clean-am', 'clean-' . $X . $primary);
7425 &depend ('.PHONY', 'clean-' . $X . $primary);
7426 &depend ('distclean-am', 'distclean-' . $X . $primary);
7427 &depend ('.PHONY', 'distclean-' . $X . $primary);
7428 &depend ('maintainer-clean-am', 'maintainer-clean-' . $X . $primary);
7429 &depend ('.PHONY', 'maintainer-clean-' . $X . $primary);
7434 push (@check, '$(' . $one_name . ')');
7438 push (@used, '$(' . $one_name . ')');
7440 if ($X eq 'noinst' || $X eq 'check')
7442 # Objects which don't get installed by default.
7446 local ($subdir_xform);
7449 $subdir_xform = 's/^NOBASE.*$//; s/^BASE//;';
7453 $subdir_xform = 's/^BASE.*$//; s/^NOBASE//;';
7457 &file_contents ($file,
7458 &transform ('DIR' => $X,
7459 'NDIR' => $nodir_name)
7464 push (@uninstall, 'uninstall-' . $X . $primary);
7465 &depend ('.PHONY', 'uninstall-' . $X . $primary);
7466 push (@installdirs, '$(DESTDIR)$(' . $X . 'dir)');
7467 if (defined $exec_dir_p{$X} ? $exec_dir_p{$X} : ($X =~ /exec/))
7469 push (@install_exec, 'install-' . $X . $primary);
7470 &depend ('.PHONY', 'install-' . $X . $primary);
7474 push (@install_data, 'install-' . $X . $primary);
7475 &depend ('.PHONY', 'install-' . $X . $primary);
7480 # The JAVA variable is used as the name of the Java interpreter.
7481 # The PYTHON variable is used as the name of the Python interpreter.
7482 if (@used && $primary ne 'JAVA' && $primary ne 'PYTHON')
7485 &define_pretty_variable ($primary, '', @used);
7486 $output_vars .= "\n";
7489 if ($require_extra && ! &variable_defined ('EXTRA_' . $primary))
7491 &am_line_error ($require_extra,
7492 "\`$require_extra' contains configure substitution, but \`EXTRA_$primary' not defined");
7495 # Push here because PRIMARY might be configure time determined.
7496 push (@all, '$(' . $primary . ')')
7497 if @used && $primary ne 'JAVA' && $primary ne 'PYTHON';
7499 # Make the result unique. This lets the user use conditionals in
7500 # a natural way, but still lets us program lazily -- we don't have
7501 # to worry about handling a particular object more than once.
7502 local (%uniquify) = ();
7503 grep ($uniquify{$_} = 1, @result);
7504 return sort keys %uniquify;
7508 ################################################################
7510 # Each key in this hash is the name of a directory holding a
7511 # Makefile.in. These variables are local to `is_make_dir'.
7518 if (! $make_dirs_set)
7520 foreach $iter (@configure_input_files)
7522 $make_dirs{&dirname ($iter)} = 1;
7524 # We also want to notice Makefile.in's.
7525 foreach $iter (@other_input_files)
7527 if ($iter =~ /Makefile\.in$/)
7529 $make_dirs{&dirname ($iter)} = 1;
7534 return defined $make_dirs{$dir};
7537 ################################################################
7539 # This variable is local to the "require file" set of functions.
7540 @require_file_paths = ();
7542 # If a file name appears as a key in this hash, then it has already
7543 # been checked for. This variable is local to the "require file"
7545 %require_file_found = ();
7547 # See if we want to push this file onto dist_common. This function
7548 # encodes the rules for deciding when to do so.
7549 sub maybe_push_required_file
7551 local ($dir, $file, $fullfile) = @_;
7553 # FIXME: Once again, special-case `.'.
7554 if ($dir eq $relative_dir || $dir eq '.')
7556 &push_dist_common ($file);
7558 elsif ($relative_dir eq '.' && ! &is_make_dir ($dir))
7560 # If we are doing the topmost directory, and the file is in a
7561 # subdir which does not have a Makefile, then we distribute it
7563 &push_dist_common ($fullfile);
7567 # Verify that the file must exist in the current directory. Usage:
7568 # require_file (isconfigure, line_number, strictness, file) strictness
7569 # is the strictness level at which this file becomes required. Must
7570 # set require_file_paths before calling this function.
7571 # require_file_paths is set to hold a single directory (the one in
7572 # which the first file was found) before return.
7573 sub require_file_internal
7575 local ($is_configure, $line, $mystrict, @files) = @_;
7576 local ($file, $fullfile);
7577 local ($found_it, $dangling_sym, $errfile, $errdir);
7580 foreach $file (@files)
7582 # If we've already looked for it, we're done.
7583 next if defined $require_file_found{$file};
7584 $require_file_found{$file} = 1;
7588 foreach $dir (@require_file_paths)
7592 $fullfile = $relative_dir . "/" . $file;
7593 $errdir = $relative_dir unless $errdir;
7597 $fullfile = $dir . "/" . $file;
7598 $errdir = $dir unless $errdir;
7601 # Use different name for "error filename". Otherwise on
7602 # an error the bad file will be reported as eg
7603 # `../../install-sh' when using the default
7605 $errfile = $errdir . '/' . $file;
7607 if (-l $fullfile && ! -f readlink ($fullfile))
7612 elsif (-f $fullfile)
7615 &maybe_push_required_file ($dir, $file, $fullfile);
7621 if ($found_it && ! $force_missing)
7623 # Prune the path list.
7624 @require_file_paths = $save_dir;
7628 if ($strictness >= $mystrict)
7630 if ($dangling_sym && ($force_missing || $add_missing))
7635 local ($trailer) = '';
7636 local ($suppress) = 0;
7638 # Only install missing files according to our desired
7640 local ($message) = "required file \`$errfile' not found";
7645 # Maybe run libtoolize.
7646 local @syslist = ('libtoolize', '--automake');
7647 push @syslist, '--copy'
7650 && grep ($_ eq $file, @libtoolize_files)
7651 && system (@syslist))
7653 $message = "installing \`$errfile'";
7655 $trailer = "; cannot run \`libtoolize': $!";
7657 elsif (-f ($am_dir . '/' . $file))
7659 # Install the missing file. Symlink if we
7660 # can, copy if we must. Note: delete the file
7661 # first, in case it is a dangling symlink.
7662 $message = "installing \`$errfile'";
7663 # Windows Perl will hang if we try to delete a
7664 # file that doesn't exist.
7665 unlink ($errfile) if -f $errfile;
7666 if ($symlink_exists && ! $copy_missing)
7668 if (! symlink ($am_dir . '/' . $file, $errfile))
7671 $trailer = "; error while making link: $!";
7674 elsif (system ('cp', $am_dir . '/' . $file, $errfile))
7677 $trailer = "\n error while copying";
7681 &maybe_push_required_file (&dirname ($errfile),
7685 local ($save) = $exit_status;
7688 # FIXME: allow actual file to be specified.
7689 &am_conf_line_error ($configure_ac, $line,
7690 "$message$trailer");
7694 &am_line_error ($line, "$message$trailer");
7696 $exit_status = $save if $suppress;
7702 # Like require_file_with_line, but error messages refer to
7703 # configure.ac, not the current Makefile.am.
7704 sub require_file_with_conf_line
7706 @require_file_paths = '.';
7707 &require_file_internal (1, @_);
7710 sub require_file_with_line
7712 @require_file_paths = '.';
7713 &require_file_internal (0, @_);
7718 @require_file_paths = '.';
7719 &require_file_internal (0, '', @_);
7722 # Require a file that is also required by Autoconf. Looks in
7723 # configuration path, as specified by AC_CONFIG_AUX_DIR.
7724 sub require_config_file
7726 @require_file_paths = @config_aux_path;
7727 &require_file_internal (1, '', @_);
7728 local ($dir) = $require_file_paths[0];
7729 @config_aux_path = @require_file_paths;
7732 $config_aux_dir = '.';
7736 $config_aux_dir = '$(top_srcdir)/' . $dir;
7740 # Assumes that the line number is in Makefile.am.
7741 sub require_conf_file_with_line
7743 @require_file_paths = @config_aux_path;
7744 &require_file_internal (0, @_);
7745 local ($dir) = $require_file_paths[0];
7746 @config_aux_path = @require_file_paths;
7749 $config_aux_dir = '.';
7753 $config_aux_dir = '$(top_srcdir)/' . $dir;
7757 # Assumes that the line number is in configure.ac.
7758 sub require_conf_file_with_conf_line
7760 @require_file_paths = @config_aux_path;
7761 &require_file_internal (1, @_);
7762 local ($dir) = $require_file_paths[0];
7763 @config_aux_path = @require_file_paths;
7766 $config_aux_dir = '.';
7770 $config_aux_dir = '$(top_srcdir)/' . $dir;
7774 ################################################################
7776 # Push a list of files onto dist_common.
7777 sub push_dist_common
7779 local (@files) = @_;
7782 foreach $file (@files)
7784 if (! defined $dist_common{$file})
7786 &prog_error ("push_dist_common run after handle_dist")
7787 if $handle_dist_run;
7788 $dist_common{$file} = 1;
7797 $strictness_name = $_[0];
7798 if ($strictness_name eq 'gnu')
7802 elsif ($strictness_name eq 'gnits')
7804 $strictness = $GNITS;
7806 elsif ($strictness_name eq 'foreign')
7808 $strictness = $FOREIGN;
7812 die "automake: level \`$strictness_name' not recognized\n";
7817 ################################################################
7819 # Return directory name of file.
7825 ($sub = $file) =~ s,/+[^/]+$,,g;
7826 $sub = '.' if $sub eq $file;
7830 # Return file name of a file.
7836 ($sub = $file) =~s,^.*/+,,g;
7840 # Ensure a file exists.
7845 open (TOUCH, ">> $file");
7849 # Glob something. Do this to avoid indentation screwups everywhere we
7850 # want to glob. Gross!
7857 ################################################################
7859 # Print an error message and set exit status.
7862 warn "automake: ${am_file}.am: @_\n";
7867 # am_file_error ($FILE, @ARGS)
7868 # ----------------------------
7871 my ($file, @args) = @_;
7873 warn "$file: @args\n";
7879 local ($symbol, @args) = @_;
7881 if ($symbol && "$symbol" ne '-1')
7883 local ($file) = "${am_file}.am";
7885 if ($symbol =~ /^\d+$/)
7887 # SYMBOL is a line number, so just add the colon.
7888 $file .= ':' . $symbol;
7890 elsif (defined $content_lines{$symbol})
7892 # SYMBOL is a variable defined in Makefile.am, so add the
7893 # line number we saved from there.
7894 $file .= ':' . $content_lines{$symbol};
7896 elsif (defined $configure_vars{$symbol})
7898 # SYMBOL is a variable defined in configure.ac, so add the
7899 # appropriate line number.
7900 $file = $configure_vars{$symbol};
7904 # Couldn't find the line number.
7906 warn $file, ": @args\n";
7915 # Like am_error, but while scanning configure.ac.
7918 # FIXME: can run in subdirs.
7919 warn "automake: $configure_ac: @_\n";
7923 # Error message with line number referring to configure.ac.
7924 sub am_conf_line_error
7926 local ($file, $line, @args) = @_;
7930 warn "$file: $line: @args\n";
7935 &am_conf_error (@args);
7939 # Warning message with line number referring to configure.ac.
7940 # Does not affect exit_status
7941 sub am_conf_line_warning
7943 local ($saved_exit_status) = $exit_status;
7944 &am_conf_line_error (@_);
7945 $exit_status = $saved_exit_status;
7948 # Tell user where our aclocal.m4 is, but only once.
7949 sub keyed_aclocal_warning
7952 warn "automake: macro \`$key' can be generated by \`aclocal'\n";
7955 # Print usage information.
7958 print "Usage: automake [OPTION] ... [Makefile]...\n\n";
7959 print "Generate Makefile.in for autoconf from Makefile.am\n";
7961 print "\nFiles which are automatically distributed, if found:\n";
7962 $~ = "USAGE_FORMAT";
7963 local ($last, $iter, @lcomm);
7965 foreach $iter (sort ((@common_files, @common_sometimes)))
7967 push (@lcomm, $iter) unless $iter eq $last;
7971 local ($one, $two, $three, $four, $i, $max);
7972 $max = int (($#lcomm + 1) / 4);
7974 for ($i = 0; $i < $max; ++$i)
7977 $two = $lcomm[$max + $i];
7978 $three = $lcomm[2 * $max + $i];
7979 $four = $lcomm[3 * $max + $i];
7983 local ($mod) = ($#lcomm + 1) % 4;
7986 $one = $lcomm[$max];
7987 $two = ($mod > 1) ? $lcomm[2 * $max] : '';
7988 $three = ($mod > 2) ? $lcomm[3 * $max] : '';
7989 $four = ($mod > 3) ? $lcomm[4 * $max] : '';
7993 print "\nReport bugs to <bug-automake\@gnu.org>.\n";
7998 format USAGE_FORMAT =
7999 @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<
8000 $one, $two, $three, $four