5 eval 'exec @PERL@ -S $0 ${1+"$@"}'
8 # automake - create Makefile.in from Makefile.am
9 # Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000
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>.
31 # Parameters set by configure. Not to be changed. NOTE: assign
32 # VERSION as string so that eg version 0.30 will print correctly.
33 $VERSION = "@VERSION@";
34 $PACKAGE = "@PACKAGE@";
36 $am_dir = "@datadir@/@PACKAGE@";
39 $IGNORE_PATTERN = "^##([^#].*)?\$";
40 $WHITE_PATTERN = "^[ \t]*\$";
41 $COMMENT_PATTERN = "^#";
42 $RULE_PATTERN = "^([\$a-zA-Z_.][-.a-zA-Z0-9_(){}/\$]*) *:([^=].*|)\$";
43 $SUFFIX_RULE_PATTERN = "^\\.([a-zA-Z0-9]+)\\.([a-zA-Z0-9]+)\$";
44 # Only recognize leading spaces, not leading tabs. If we recognize
45 # leading tabs here then we need to make the reader smarter, because
46 # otherwise it will think rules like `foo=bar; \' are errors.
47 $MACRO_PATTERN = "^ *([A-Za-z0-9_]+)[ \t]*([:+]?)=[ \t]*(.*)\$";
48 $BOGUS_MACRO_PATTERN = "^ *([^ \t]*)[ \t]*([:+]?)=[ \t]*(.*)\$";
49 $GNITS_VERSION_PATTERN = "[0-9]+\\.[0-9]+([a-z]|\\.[0-9]+)?";
50 $IF_PATTERN = "^if[ \t]+\([A-Za-z][A-Za-z0-9_]*\)[ \t]*\(#.*\)?\$";
51 $ELSE_PATTERN = "^else[ \t]*\(#.*\)?\$";
52 $ENDIF_PATTERN = "^endif[ \t]*\(#.*\)?\$";
53 $PATH_PATTERN='(\\w|[/.-])+';
54 # This will pass through anything not of the prescribed form.
55 $INCLUDE_PATTERN = "^include[ \t]+((\\\$\\\(top_srcdir\\\)/${PATH_PATTERN})|(\\\$\\\(srcdir\\\)/${PATH_PATTERN})|([^/\\\$]${PATH_PATTERN}))[ \t]*(#.*)?\$";
57 # Some regular expressions. One reason to put them here is that it
58 # makes indentation work better in Emacs.
59 $AC_CONFIG_AUX_DIR_PATTERN = "AC_CONFIG_AUX_DIR\\(([^)]+)\\)";
60 $AM_INIT_AUTOMAKE_PATTERN = "AM_INIT_AUTOMAKE\\([^,]*,([^,)]+)[,)]";
61 $AM_PACKAGE_VERSION_PATTERN = "^\\s*\\[?([^]\\s]+)\\]?\\s*\$";
62 # Note that there is no AC_PATH_TOOL. But we don't really care.
63 $AC_CHECK_PATTERN = "AC_(CHECK|PATH)_(PROG|PROGS|TOOL)\\(\\[?(\\w+)";
64 $AM_MISSING_PATTERN = "AM_MISSING_PROG\\(\\[?(\\w+)";
65 # Just check for alphanumeric in AC_SUBST. If you do AC_SUBST(5),
67 $AC_SUBST_PATTERN = "AC_SUBST\\(\\[?(\\w+)";
68 $AM_CONDITIONAL_PATTERN = "AM_CONDITIONAL\\((\\w+)";
70 # Constants to define the "strictness" level.
75 # These constants are returned by lang_*_rewrite functions.
76 # LANG_SUBDIR means that the resulting object file should be in a
77 # subdir if the source file is. In this case the file name cannot
78 # have `..' components.
85 # Variables global to entire run.
87 # Variables related to the options.
89 # TRUE if we should always generate Makefile.in.
90 $force_generation = 1;
92 # Strictness level as set on command line.
93 $default_strictness = $GNU;
95 # Name of strictness level, as set on command line.
96 $default_strictness_name = 'gnu';
98 # This is TRUE if automatic dependency generation code should be
99 # included in generated Makefile.in.
100 $cmdline_use_dependencies = 1;
102 # TRUE if in verbose mode.
105 # This holds our (eventual) exit status. We don't actually exit until
106 # we have processed all input files.
109 # From the Perl manual.
110 $symlink_exists = (eval 'symlink ("", "");', $@ eq '');
112 # TRUE if missing standard files should be installed.
115 # TRUE if we should copy missing files; otherwise symlink if possible.
118 # TRUE if we should always update files that we know about.
122 # Variables filled during files scanning.
124 # Name of the top autoconf input: `configure.ac' or `configure.in'.
127 # Files found by scanning configure.ac for LIBOBJS.
130 # True if AM_C_PROTOTYPES appears in configure.ac.
131 $am_c_prototypes = 0;
133 # Names used in AC_CONFIG_HEADER call. @config_fullnames holds the
134 # name which appears in AC_CONFIG_HEADER, colon and all.
135 # @config_names holds the file names. @config_headers holds the '.in'
136 # files. Ordinarily these are similar, but they can be different if
137 # the weird "NAME:FILE" syntax is used.
138 @config_fullnames = ();
140 @config_headers = ();
141 # Line number at which AC_CONFIG_HEADER appears in configure.ac.
142 $config_header_line = 0;
144 # Directory where output files go. Actually, output files are
145 # relative to this directory.
146 $output_directory = '.';
148 # Relative location of top build directory.
151 # List of Makefile.am's to process, and their corresponding outputs.
155 # Complete list of Makefile.am's that exist.
156 @configure_input_files = ();
158 # List of files in AC_OUTPUT without Makefile.am, and their outputs.
159 @other_input_files = ();
160 # Line number at which AC_OUTPUT seen.
163 # List of directories to search for configure-required files. This
164 # can be set by AC_CONFIG_AUX_DIR.
165 @config_aux_path = ('.', '..', '../..');
166 $config_aux_dir = '';
168 # Whether AC_PROG_MAKE_SET has been seen in configure.ac.
171 # Whether AM_GNU_GETTEXT has been seen in configure.ac.
173 # Line number at which AM_GNU_GETTEXT seen.
174 $ac_gettext_line = 0;
176 # Whether ALL_LINGUAS has been seen.
180 # Line number at which it appears.
181 $all_linguas_line = 0;
183 # 1 if AC_PROG_INSTALL seen.
184 $seen_prog_install = 0;
186 # Whether AC_PATH_XTRA has been seen in configure.ac.
189 # TRUE if AC_DECL_YYTEXT was seen.
190 $seen_decl_yytext = 0;
192 # TRUE if we've seen AC_CANONICAL_(HOST|SYSTEM). The presence of
193 # AC_CHECK_TOOL also sets this.
196 # TRUE if we've seen AC_ARG_PROGRAM.
199 # TRUE if we've seen AC_PROG_LIBTOOL.
203 # Files installed by libtoolize.
204 @libtoolize_files = ('ltmain.sh', 'config.guess', 'config.sub');
205 # ltconfig appears here for compatibility with old versions of libtool.
206 @libtoolize_sometimes = ('ltconfig', 'ltcf-c.sh', 'ltcf-cxx.sh',
209 # TRUE if we've seen AM_MAINTAINER_MODE.
210 $seen_maint_mode = 0;
212 # Actual version we've seen.
213 $package_version = '';
215 # Line number where we saw version definition.
216 $package_version_line = 0;
218 # TRUE if we've seen AM_PATH_LISPDIR.
221 # TRUE if we've seen AM_CHECK_PYTHON.
224 # TRUE if we've seen AC_EXEEXT.
227 # TRUE if we've seen AC_OBJEXT.
230 # TRUE if we've seen AC_ENABLE_MULTILIB.
233 # TRUE if we've seen AM_PROG_CC_C_O
236 # TRUE if we've seen AM_INIT_AUTOMAKE.
237 $seen_init_automake = 0;
239 # Hash table of discovered configure substitutions. Keys are names,
240 # values are `FILE:LINE' strings which are used by error message
242 %configure_vars = ();
244 # This is used to keep track of which variable definitions we are
245 # scanning. It is only used in certain limited ways, but it has to be
246 # global. It is declared just for documentation purposes.
249 # Charsets used by maintainer and in distribution. MAINT_CHARSET is
250 # handled in a funny way: if seen in the top-level Makefile.am, it is
251 # used for every directory which does not specify a different value.
252 # The rationale here is that some directories (eg gettext) might be
253 # distributions of other packages, and thus require their own charset
254 # info. However, the DIST_CHARSET must be the same for the entire
255 # package; it can only be set at top-level.
256 # FIXME: this yields bugs when rebuilding. What to do? Always
257 # read (and sometimes discard) top-level Makefile.am?
259 $dist_charset = 'utf8'; # recode doesn't support this yet.
261 # Name of input file ("Makefile.in") and output file ("Makefile.am").
262 # These have no directory components.
266 # TRUE if --cygnus seen.
269 # Hash table of AM_CONDITIONAL variables seen in configure.
270 %configure_cond = ();
272 # Map from obsolete macros to hints for new macros.
273 # If you change this, change the corresponding list in aclocal.in.
274 # FIXME: should just put this into a single file.
277 'AC_FEATURE_CTYPE', "use \`AC_HEADER_STDC'",
278 'AC_FEATURE_ERRNO', "add \`strerror' to \`AC_REPLACE_FUNCS(...)'",
279 'AC_FEATURE_EXIT', '',
280 'AC_SYSTEM_HEADER', '',
282 # Note that we do not handle this one, because it is still run
283 # from AM_CONFIG_HEADER. So we deal with it specially in
284 # &scan_autoconf_files.
285 # 'AC_CONFIG_HEADER', "use \`AM_CONFIG_HEADER'",
287 'fp_C_PROTOTYPES', "use \`AM_C_PROTOTYPES'",
288 'fp_PROG_CC_STDC', "use \`AM_PROG_CC_STDC'",
289 'fp_PROG_INSTALL', "use \`AC_PROG_INSTALL'",
290 'fp_WITH_DMALLOC', "use \`AM_WITH_DMALLOC'",
291 'fp_WITH_REGEX', "use \`AM_WITH_REGEX'",
292 'gm_PROG_LIBTOOL', "use \`AM_PROG_LIBTOOL'",
293 'jm_MAINTAINER_MODE', "use \`AM_MAINTAINER_MODE'",
294 'md_TYPE_PTRDIFF_T', "use \`AM_TYPE_PTRDIFF_T'",
295 'ud_PATH_LISPDIR', "use \`AM_PATH_LISPDIR'",
296 'ud_GNU_GETTEXT', "use \`AM_GNU_GETTEXT'",
298 # Now part of autoconf proper, under a different name.
299 'AM_FUNC_FNMATCH', "use \`AC_FUNC_FNMATCH'",
300 'fp_FUNC_FNMATCH', "use \`AC_FUNC_FNMATCH'",
301 'AM_SANITY_CHECK_CC', "automatically done by \`AC_PROG_CC'",
302 'AM_PROG_INSTALL', "use \`AC_PROG_INSTALL'",
303 'AM_EXEEXT', "use \`AC_EXEEXT'",
304 'AM_CYGWIN32', "use \`AC_CYGWIN'",
305 'AM_MINGW32', "use \`AC_MINGW32'",
306 'AM_FUNC_MKTIME', "use \`AC_FUNC_MKTIME'",
308 # These aren't quite obsolete.
312 # Regexp to match the above macros.
313 $obsolete_rx = '(\b' . join ('\b|\b', keys %obsolete_macros) . '\b)';
315 # This maps extensions onto language names.
318 # This maps languages names onto properties.
321 # This holds all the files that would go in `dist_common' which we
322 # discovered while scanning configure.ac. We might distribute these
323 # in the top-level Makefile.in.
324 %configure_dist_common = ();
328 # Initialize global constants and our list of languages that are
329 # internally supported.
330 &initialize_global_constants;
332 ®ister_language ('c', 'ansi-p=1', 'autodep=', 'flags=CFLAGS',
333 'compile=$(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)',
334 'compiler-name=COMPILE',
337 ®ister_language ('cxx', 'linker=CXXLINK', 'autodep=CXX', 'flags=CXXFLAGS',
338 'compile=$(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)',
339 'compiler-name=CXXCOMPILE',
340 'output-arg=-c -o $@',
341 'c++', 'cc', 'cpp', 'cxx', 'C');
342 ®ister_language ('objc', 'linker=OBJCLINK', 'autodep=OBJC',
344 'compile=$(OBJC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_OBJCFLAGS) $(OBJCFLAGS)',
345 'compiler-name=OBJCCOMPILE',
346 'output-arg=-c -o $@',
348 ®ister_language ('header',
349 'h', 'H', 'hxx', 'h++', 'hh', 'hpp', 'inc');
351 # For now, yacc and lex can't be handled on a per-exe basis.
352 ®ister_language ('yacc', 'ansi-p=1', 'derived-autodep=yes',
354 ®ister_language ('yaccxx', 'linker=CXXLINK', 'derived-autodep=yes',
355 'y++', 'yy', 'yxx', 'ypp');
356 ®ister_language ('lex', 'ansi-p=1', 'derived-autodep=yes',
358 ®ister_language ('lexxx', 'linker=CXXLINK', 'derived-autodep=yes',
359 'l++', 'll', 'lxx', 'lpp');
361 ®ister_language ('asm',
362 'flags=CFLAGS', # FIXME: asmflags?
363 'compile=$(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)', # FIXME: a different compiler?
364 'compiler-name=COMPILE',
368 ®ister_language ('f77', 'linker=F77LINK', 'flags=FFLAGS',
369 'compile=$(F77) $(AM_FFLAGS) $(FFLAGS)',
370 'compiler-name=F77COMPILE',
371 'output-arg=-c -o $@',
373 ®ister_language ('ppf77', 'linker=F77LINK', 'flags=FFLAGS',
374 'compile=$(F77) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FFLAGS) $(FFLAGS)',
375 'compiler-name=PPF77COMPILE',
376 'output-arg=-c -o $@',
378 ®ister_language ('ratfor', 'linker=F77LINK',
379 'flags=RFLAGS', # FIXME also FFLAGS.
380 'compile=$(F77) $(AM_FFLAGS) $(FFLAGS) $(AM_RFLAGS) $(RFLAGS)',
381 'compiler-name=RCOMPILE',
382 'output-arg=-c -o $@',
384 # FIXME: for now we can't do dependency tracking for Java.
386 ®ister_language ('java', 'linker=GCJLINK', 'flags=GCJFLAGS',
387 'compile=$(GCJ) $(DEFS) $(INCLUDES) $(AM_GCJFLAGS) $(GCJFLAGS)',
388 'compiler-name=GCJCOMPILE',
389 'output-arg=-c -o $@',
390 'java', 'class', 'zip', 'jar');
393 # Parse command line.
394 &parse_arguments (@ARGV);
396 # Do configure.ac scan only once.
397 &scan_autoconf_files;
399 die "automake: no \`Makefile.am' found or specified\n"
402 # Now do all the work on each file.
403 foreach $am_file (@input_files)
405 if (! -f ($am_file . '.am'))
407 &am_error ("\`" . $am_file . ".am' does not exist");
411 &generate_makefile ($output_files{$am_file}, $am_file);
415 &am_conf_error ("AC_PROG_INSTALL must be used")
416 if (! $seen_prog_install);
421 ################################################################
423 # Parse command line.
426 local (@arglist) = @_;
429 &set_strictness ('gnu');
433 if ($arglist[0] eq "--version")
435 print "automake (GNU $PACKAGE) $VERSION\n\n";
436 print "Copyright 2000 Free Software Foundation, Inc.\n";
437 print "This is free software; see the source for copying conditions. There is NO\n";
438 print "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n";
439 print "Written by Tom Tromey <tromey\@cygnus.com>\n";
443 elsif ($arglist[0] eq "--help")
447 elsif ($arglist[0] =~ /^--amdir=(.+)$/)
451 elsif ($arglist[0] eq '--amdir')
453 &require_argument (@arglist);
455 $am_dir = $arglist[0];
457 elsif ($arglist[0] eq '--gnu')
459 &set_strictness ('gnu');
461 elsif ($arglist[0] eq '--gnits')
463 &set_strictness ('gnits');
465 elsif ($arglist[0] eq '--cygnus')
469 elsif ($arglist[0] eq '--foreign')
471 &set_strictness ('foreign');
473 elsif ($arglist[0] eq '--include-deps')
475 $cmdline_use_dependencies = 1;
477 elsif ($arglist[0] eq '--ignore-deps' || $arglist[0] eq '-i')
479 $cmdline_use_dependencies = 0;
481 elsif ($arglist[0] eq '--no-force')
483 $force_generation = 0;
485 elsif ($arglist[0] eq '--force-missing')
489 elsif ($arglist[0] =~ /^--output-dir=(.*)$/)
491 # Set output directory.
492 $output_directory = $1;
494 elsif ($arglist[0] eq '--output-dir' || $arglist[0] eq '-o')
496 &require_argument (@arglist);
498 $output_directory = $arglist[0];
500 elsif ($arglist[0] eq '--add-missing' || $arglist[0] eq '-a')
504 elsif ($arglist[0] eq '--copy' || $arglist[0] eq '-c')
508 elsif ($arglist[0] eq '--verbose' || $arglist[0] eq '-v')
512 elsif ($arglist[0] eq '--')
514 # Stop option processing.
516 push (@input_files, @arglist);
519 elsif ($arglist[0] =~ /^-/)
521 die "automake: unrecognized option -- \`$arglist[0]'\nTry \`automake --help' for more information.\n";
525 # Handle $local:$input syntax. Note that we only examine
526 # the first ":" file to see if it is automake input; the
527 # rest are just taken verbatim. We still keep all the
528 # files around for dependency checking, however.
529 local ($local, $input, @rest) = split (/:/, $arglist[0]);
536 # Strip .in; later on .am is tacked on. That is how
537 # the automake input file is found. Maybe not the
538 # best way, but it is easy to explain. FIXME: should
539 # be error if .in is missing.
542 push (@input_files, $input);
543 $output_files{$input} = join (':', ($local, @rest));
549 # Take global strictness from whatever we currently have set.
550 $default_strictness = $strictness;
551 $default_strictness_name = $strictness_name;
554 # Ensure argument exists, or die.
557 local ($arg, @arglist) = @_;
558 die "automake: no argument given for option \`$arg'\n"
562 ################################################################
564 # Generate a Makefile.in given the name of the corresponding Makefile and
565 # the name of the file output by config.status.
566 sub generate_makefile
568 local ($output, $makefile) = @_;
570 ($am_file_name = $makefile) =~ s/^.*\///;
571 $in_file_name = $am_file_name . '.in';
572 $am_file_name .= '.am';
574 # $OUTPUT is encoded. If it contains a ":" then the first element
575 # is the real output file, and all remaining elements are input
576 # files. We don't scan or otherwise deal with these input file,
577 # other than to mark them as dependencies. See
578 # &scan_autoconf_files for details.
579 local (@secondary_inputs);
580 ($output, @secondary_inputs) = split (/:/, $output);
582 &initialize_per_input;
583 $relative_dir = &dirname ($output);
584 $am_relative_dir = &dirname ($makefile);
586 # At the toplevel directory, we might need config.guess, config.sub
587 # or libtool scripts (ltconfig and ltmain.sh).
588 if ($relative_dir eq '.')
590 # libtool requires some files.
591 &require_conf_file_with_conf_line ($libtool_line, $FOREIGN,
595 # AC_CANONICAL_HOST and AC_CANONICAL_SYSTEM need config.guess and
597 &require_config_file ($FOREIGN, 'config.guess', 'config.sub')
601 # We still need Makefile.in here, because sometimes the `dist'
602 # target doesn't re-run automake.
603 if ($am_relative_dir eq $relative_dir)
605 # Only distribute the files if they are in the same subdir as
606 # the generated makefile.
607 &push_dist_common ($in_file_name, $am_file_name);
610 push (@sources, '$(SOURCES)')
611 if &variable_defined ('SOURCES');
612 push (@objects, '$(OBJECTS)')
613 if &variable_defined ('OBJECTS');
615 &read_main_am_file ($makefile . '.am');
618 # Fatal error. Just return, so we can continue with next file.
622 # Must do this after reading .am file. See read_main_am_file to
623 # understand weird tricks we play there with variables.
624 &define_variable ('subdir', $relative_dir);
626 # Check first, because we might modify some state.
628 &check_gnu_standards;
629 &check_gnits_standards;
631 &handle_configure ($output, $makefile, @secondary_inputs);
638 # This must be run after all the sources are scanned.
641 # Re-init SOURCES and OBJECTS. FIXME: other code shouldn't depend
642 # on this (but currently does).
643 $contents{'SOURCES'} = join (' ', @sources);
644 $contents{'OBJECTS'} = join (' ', @objects);
645 &define_pretty_variable ('DIST_SOURCES', '', @dist_sources);
657 &handle_minor_options;
658 &handle_dependencies;
661 # This must come after most other rules.
662 &handle_dist ($makefile);
665 &handle_merge_targets ($output);
672 if (! -d ($output_directory . '/' . $am_relative_dir))
674 mkdir ($output_directory . '/' . $am_relative_dir, 0755);
677 local ($out_file) = $output_directory . '/' . $makefile . ".in";
678 if (! $force_generation && -e $out_file)
680 local ($am_time) = (stat ($makefile . '.am'))[9];
681 local ($in_time) = (stat ($out_file))[9];
682 # FIXME: should cache these times.
683 local ($conf_time) = (stat ($configure_ac))[9];
684 # FIXME: how to do unsigned comparison?
685 if ($am_time < $in_time || $am_time < $conf_time)
692 local ($acl_time) = (stat _)[9];
693 return if ($am_time < $acl_time);
697 if (! open (GM_FILE, "> " . $out_file))
699 warn "automake: ${am_file}.in: cannot write: $!\n";
703 print "automake: creating ", $makefile, ".in\n" if $verbose;
705 # In case we're running under MSWindows, don't write with CRLF
706 # (as it causes problems for the dependency-file extraction in
707 # AM_OUTPUT_DEPENDENCY_COMMANDS).
710 print GM_FILE $output_vars;
711 # We make sure that `all:' is the first target.
712 print GM_FILE $output_all;
713 print GM_FILE $output_header;
714 print GM_FILE $output_rules;
715 print GM_FILE $output_trailer;
717 if (! close (GM_FILE))
719 warn "automake: $am_file.in: cannot close: $!\n";
725 ################################################################
727 # Handle AUTOMAKE_OPTIONS variable. Return 1 on error, 0 otherwise.
730 if (&variable_defined ('AUTOMAKE_OPTIONS'))
732 foreach (&variable_value_as_list ('AUTOMAKE_OPTIONS', ''))
735 if ($_ eq 'gnits' || $_ eq 'gnu' || $_ eq 'foreign')
737 &set_strictness ($_);
739 elsif ($_ eq 'cygnus')
745 # An option like "../lib/ansi2knr" is allowed. With
746 # no path prefix, we assume the required programs are
747 # in this directory. We save the actual option for
749 $options{'ansi2knr'} = $_;
751 elsif ($_ eq 'no-installman' || $_ eq 'no-installinfo'
752 || $_ eq 'dist-shar' || $_ eq 'dist-zip'
753 || $_ eq 'dist-tarZ' || $_ eq 'dist-bzip2'
754 || $_ eq 'dejagnu' || $_ eq 'no-texinfo.tex'
755 || $_ eq 'readme-alpha' || $_ eq 'check-news'
756 || $_ eq 'subdir-objects' || $_ eq 'nostdinc')
758 # Explicitly recognize these.
760 elsif ($_ eq 'no-dependencies')
762 $use_dependencies = 0;
764 elsif (/([0-9]+)\.([0-9]+)([a-z])?/)
766 # Got a version number.
768 local ($rmajor, $rminor, $ralpha) = ($1, $2, $3);
770 if ($VERSION !~ /([0-9]+)\.([0-9]+)([a-z])?/)
773 "automake: programming error: version is incorrect\n";
776 local ($tmajor, $tminor, $talpha) = ($1, $2, $3);
778 # 2.0 is better than 1.0.
779 # 1.2 is better than 1.1.
780 # 1.2a is better than 1.2.
781 if ($rmajor > $tmajor
782 || ($rmajor == $tmajor && $rminor > $tminor)
783 || ($rminor == $tminor && $rminor == $tminor
784 && $ralpha gt $talpha))
786 &am_line_error ('AUTOMAKE_OPTIONS',
787 "require version $_, only have $VERSION");
793 &am_line_error ('AUTOMAKE_OPTIONS',
794 "option \`" . $_ . "\' not recognized");
799 if ($strictness == $GNITS)
801 $options{'readme-alpha'} = 1;
802 $options{'check-news'} = 1;
808 # Return object extension. Just once, put some code into the output.
809 # Argument is the name of the output file
810 sub get_object_extension
814 # Maybe require libtool library object files.
815 local ($extension) = '.o';
816 $extension = '.$(OBJEXT)' if $seen_objext;
817 $extension = '.lo' if ($out =~ /\.la$/);
819 if (! $included_generic_compile)
823 if (! defined $options{'nostdinc'})
825 $xform = ' -I. -I\$(srcdir)';
827 if (&variable_defined ('CONFIG_HEADER'))
830 foreach $one_hdr (split (' ',
831 &variable_value ('CONFIG_HEADER')))
834 ($var = &dirname ($one_hdr)) =~ s/(\W)/\\$1/g;
835 $xform .= ' -I' . $var;
839 $xform = 's/\@DEFAULT_INCLUDES\@/' . $xform . '/go;';
840 $output_vars .= &file_contents_with_transform ($xform,
843 $xform = $seen_objext ? 's/^OBJEXT//;' : 's/^OBJEXT.*$//;';
844 $output_rules .= &file_contents_with_transform ($xform, 'compile');
846 &push_phony_cleaners ('compile');
848 # If using X, include some extra variable definitions. NOTE
849 # we don't want to force these into CFLAGS or anything,
850 # because not all programs will necessarily use X.
854 foreach $var ('X_CFLAGS', 'X_LIBS', 'X_EXTRA_LIBS', 'X_PRE_LIBS')
856 &define_configure_variable ($var);
860 push (@suffixes, '.c', '.o');
861 push (@suffixes, '.obj') if $seen_objext;
862 push (@clean, 'compile');
864 $included_generic_compile = 1;
867 if ($seen_libtool && ! $included_libtool_compile)
869 # Output the libtool compilation rules.
870 $output_rules .= &file_contents ('libtool');
872 &push_phony_cleaners ('libtool');
874 push (@suffixes, '.lo');
875 push (@clean, 'libtool');
877 $included_libtool_compile = 1;
880 # Check for automatic de-ANSI-fication.
881 if (defined $options{'ansi2knr'})
883 $extension = '$U' . $extension;
884 if (! $included_knr_compile)
886 if (! $am_c_prototypes)
888 &am_line_error ('AUTOMAKE_OPTIONS',
889 "option \`ansi2knr' in use but \`AM_C_PROTOTYPES' not in \`$configure_ac'");
890 &keyed_aclocal_warning ('AM_C_PROTOTYPES');
891 # Only give this error once.
892 $am_c_prototypes = 1;
895 # Only require ansi2knr files if they should appear in
897 if ($options{'ansi2knr'} eq 'ansi2knr')
899 &require_file_with_line ('AUTOMAKE_OPTIONS', $FOREIGN,
900 'ansi2knr.c', 'ansi2knr.1');
901 $output_rules .= &file_contents ('kr-extra');
902 push (@clean, 'krextra');
903 &push_phony_cleaners ('krextra');
906 # Generate rules to build ansi2knr. If it is in some
907 # other directory, then generate dependencies but have the
908 # rule just run elsewhere.
909 $objext = $seen_objext ? ".\$(OBJEXT)" : ".o";
910 $output_rules .= ($options{'ansi2knr'} . ': '
911 . $options{'ansi2knr'} . $objext . "\n");
912 if ($options{'ansi2knr'} eq 'ansi2knr')
914 $output_rules .= ("\t\$(LINK) ansi2knr" . $objext
916 . "ansi2knr" . $objext
917 . ": \$(CONFIG_HEADER)\n\n");
921 $output_rules .= ("\tcd " . &dirname ($options{'ansi2knr'})
922 . " && \$(MAKE) \$(AM_MAKEFLAGS) "
924 # This is required for non-GNU makes.
925 $output_rules .= ($options{'ansi2knr'} . $objext . ":\n");
926 $output_rules .= ("\tcd " . &dirname ($options{'ansi2knr'})
927 . " && \$(MAKE) \$(AM_MAKEFLAGS)"
928 . " ansi2knr" . $objext . "\n\n");
931 # Make sure ansi2knr can be found: if no path specified,
933 if ($options{'ansi2knr'} eq 'ansi2knr')
935 # Substitution from AM_C_PROTOTYPES. This makes it be
936 # built only when necessary.
937 &define_configure_variable ('ANSI2KNR');
938 # ansi2knr needs to be built before subdirs, so unshift it.
939 unshift (@all, '$(ANSI2KNR)');
943 # Found in another directory.
944 &define_variable ("ANSI2KNR", $options{'ansi2knr'});
947 $output_rules .= &file_contents ('clean-kr');
950 &push_phony_cleaners ('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");
1156 # Does much of the actual work for handle_source_transform.
1158 # name of resulting executable or library ("derived")
1159 # object extension (e.g., `$U.lo')
1160 # list of source files to transform
1162 # first element is name of linker to use (empty string for default linker)
1163 # remaining elements are names of objects
1164 sub handle_single_transform_list
1166 local ($var, $derived, $obj, @files) = @_;
1167 local (@result) = ();
1168 local ($nonansi_obj) = $obj;
1169 $nonansi_obj =~ s/\$U//g;
1170 local (%linkers_used) = ();
1173 # Turn sources into objects.
1176 # Configure substitutions in _SOURCES variables are errors.
1179 &am_line_error ($var, "$var includes configure substitution \`$_'");
1183 # If the source file is in a subdirectory then the `.o' is
1184 # put into the current directory.
1186 # Split file name into base and extension.
1187 local ($full, $directory, $base, $extension, $linker, $object);
1188 next if ! /^((.*)\/)?([^\/]*)\.(.*)$/;
1194 local ($xbase) = $base;
1196 # We must generate a rule for the object if it requires
1199 local ($renamed) = 0;
1201 $extension = &derive_suffix ($extension);
1202 local ($lang) = $extension_map{$extension};
1205 &saw_extension ($extension);
1206 # Found the language, so see what it says.
1207 local ($subr) = 'lang_' . $lang . '_rewrite';
1208 # Note: computed subr call.
1209 local ($r) = & $subr ($directory, $base, $extension);
1210 # Skip this entry if we were asked not to process it.
1211 next if $r == $LANG_IGNORE;
1213 # Now extract linker and other info.
1214 $linker = $language_map{$lang . '-linker'};
1216 local ($this_obj_ext);
1217 if ($language_map{$lang . '-ansi-p'})
1219 $object = $base . $obj;
1220 $this_obj_ext = $obj;
1224 $object = $base . $nonansi_obj;
1225 $this_obj_ext = $nonansi_obj;
1228 if ($language_map{$lang . '-flags'} ne ''
1229 && &variable_defined ($derived . '_'
1230 . $language_map{$lang . '-flags'}))
1232 # We have a per-executable flag in effect for this
1233 # object. In this case we rewrite the object's
1234 # name to ensure it is unique. We also require
1235 # the `compile' program to deal with compilers
1236 # where `-c -o' does not work.
1238 # We choose the name `DERIVED-OBJECT' to ensure
1239 # (1) uniqueness, and (2) continuity between
1240 # invocations. However, this will result in a
1241 # name that is too long for losing systems, in
1242 # some situations. So we provide _SHORTNAME to
1245 local ($dname) = $derived;
1246 if (&variable_defined ($derived . '_SHORTNAME'))
1248 # FIXME: should use the same conditional as
1249 # the _SOURCES variable. But this is really
1250 # silly overkill -- nobody should have
1251 # conditional shortnames.
1252 $dname = &variable_value ($derived . '_SHORTNAME');
1254 $object = $dname . '-' . $object;
1256 &require_file ($FOREIGN, 'compile')
1259 if (! defined $language_map{$lang . '-compile'})
1261 print STDERR "automake: programming error: $lang flags defined without compiler\n";
1264 # Compute the rule to compile this object.
1265 local ($flag) = $language_map{$lang . '-flags'};
1266 local ($val) = "(${derived}_${flag}";
1267 ($rule = $language_map{$lang . '-compile'}) =~
1270 $rule .= ' ' . $language_map{$lang . '-output-arg'};
1271 # For C we have to add the -o, because the
1272 # standard rule doesn't include it.
1273 if ($language_map{$lang . '-flags'} eq 'CFLAGS')
1281 # If rewrite said it was ok, put the object into a
1283 if ($r == $LANG_SUBDIR && $directory ne '')
1285 $object = $directory . '/' . $object;
1286 $xbase = $directory . '/' . $base;
1289 # If doing dependency tracking, then we can't print
1290 # the rule. If we have a subdir object, we need to
1291 # generate an explicit rule. Actually, in any case
1292 # where the object is not in `.' we need a special
1293 # rule. The per-object rules in this case are
1294 # generated later, by add_depend2.
1295 if (($use_dependencies
1297 && $language_map{$lang . '-autodep'} ne 'no')
1298 || $directory ne '')
1301 local ($obj_sans_ext) = substr ($object, 0,
1302 - length ($this_obj_ext));
1303 $lang_specific_files{$lang} .= (' ' . $derived
1305 . ' ' . $obj_sans_ext);
1308 elsif ($extension eq 'o')
1310 # This is probably the result of a direct suffix rule.
1311 # In this case we just accept the rewrite. FIXME:
1312 # this fails if we want libtool objects.
1313 $object = $base . '.' . $extension;
1318 # No error message here. Used to have one, but it was
1323 $linkers_used{$linker} = 1;
1325 push (@result, $object);
1327 if (defined $object_map{$object})
1329 if ($object_map{$object} ne $full)
1331 &am_error ("object \`$object' created by \`$full' and \`$object_map{$object}'");
1336 local (@dep_list) = ();
1337 $object_map{$object} = $full;
1339 # If file is in subdirectory, we need explicit
1341 if ($directory ne '' || $renamed)
1343 push (@dep_list, $full);
1346 # If resulting object is in subdir, we need to make
1347 # sure the subdir exists at build time.
1348 if ($object =~ /\//)
1350 # FIXME: check that $DIRECTORY is somewhere in the
1353 # We don't allow `..' in object file names for
1354 # *any* source, not just Java. For Java it just
1355 # doesn't make sense, but in general it is
1356 # a problem because we can't pick a good name for
1358 if ($object =~ /(\/|^)\.\.\//)
1360 &am_error ("\`$full' contains \`..' component but should not");
1363 push (@dep_list, $directory . '/.dirstamp');
1365 # If we're generating dependencies, we also want
1366 # to make sure that the appropriate subdir of the
1367 # .deps directory is created.
1368 if ($use_dependencies)
1370 push (@dep_list, '.deps/' . $directory . '/.dirstamp');
1373 if (! defined $directory_map{$directory})
1375 $directory_map{$directory} = 1;
1376 $output_rules .= ($directory . "/.dirstamp:\n"
1377 . "\t\@\$(mkinstalldirs) $directory\n"
1378 . "\t\@: > $directory/.dirstamp\n");
1379 if ($use_dependencies)
1381 $output_rules .= ('.deps/' . $directory
1383 . "\t\@\$(mkinstalldirs) .deps/$directory\n"
1384 . "\t\@: > .deps/$directory/.dirstamp\n");
1389 &pretty_print_rule ($object . ':', "\t", @dep_list)
1390 if scalar @dep_list > 0 || $rule ne '';
1392 # Print the rule if we have one.
1395 # Turn `$@' into name of our object file.
1397 ($xform = $object) =~ s,/,\\/,g;
1398 $rule =~ s/\$\@/$xform/;
1400 # We cannot use $< here since this is an explicit
1401 # rule and not all makes handle that.
1402 $rule .= " \`test -f $full || echo '\$(srcdir)/'\`$full";
1404 # FIXME: handle .lo and .obj as well.
1405 $output_rules .= "\t" . $rule . "\n";
1409 # Transform .o or $o file into .P file (for automatic
1412 && ($language_map{$lang . '-autodep'} ne 'no'
1413 || $language_map{$lang . '-derived-autodep'} eq 'yes'))
1415 local ($depfile) = $object;
1416 $depfile =~ s/\.([^.]*)$/.P$1/;
1417 $depfile =~ s/\$\(OBJEXT\)$/o/ if $seen_objext;
1418 $dep_files{'$(DEPDIR)/' . $depfile} = 1;
1423 return (&resolve_linker (%linkers_used), @result);
1426 # Handle SOURCE->OBJECT transform for one program or library.
1428 # canonical (transformed) name of object to build
1429 # actual name of object to build
1430 # object extension (ie either `.o' or `$o'.
1431 # Return result is name of linker variable that must be used.
1432 # Empty return means just use `LINK'.
1433 sub handle_source_transform
1435 # one_file is canonical name. unxformed is given name. obj is
1437 local ($one_file, $unxformed, $obj) = @_;
1439 local ($linker) = '';
1441 if (&variable_defined ($one_file . "_OBJECTS"))
1443 &am_line_error ($one_file . '_OBJECTS',
1444 $one_file . '_OBJECTS', 'should not be defined');
1445 # No point in continuing.
1449 local (@files, @result, $prefix, $temp, $xpfx);
1450 local (%used_pfx) = ();
1451 foreach $prefix ('', 'EXTRA_', 'dist_', 'nodist_',
1452 'dist_EXTRA_', 'nodist_EXTRA_')
1454 # We are going to define _OBJECTS variables using the prefix.
1455 # Then we glom them all together. So we can't use the null
1456 # prefix here as we need it later.
1457 $xpfx = ($prefix eq '') ? 'am_' : $prefix;
1460 local ($var) = $prefix . $one_file . "_SOURCES";
1461 if (&variable_defined ($var))
1463 # Keep track of which prefixes we saw.
1464 $used_pfx{$xpfx} = 1
1465 unless $prefix =~ /EXTRA_/;
1467 push (@sources, '$(' . $prefix . $one_file . "_SOURCES)");
1468 push (@objects, '$(' . $xpfx . $one_file . "_OBJECTS)")
1469 unless $prefix =~ /EXTRA_/;
1470 push (@dist_sources, '$(' . $prefix . $one_file . "_SOURCES)")
1471 unless $prefix =~ /^nodist_/;
1472 local (@conds) = &variable_conditions ($var);
1475 @files = &variable_value_as_list ($var, '');
1480 foreach $cond (@conds)
1482 @files = &variable_value_as_list ($var, $cond);
1484 &handle_single_transform_list ($var, $one_file, $obj,
1486 $linker = $temp if $linker eq '';
1488 # Define _OBJECTS conditionally.
1489 &define_pretty_variable ($xpfx . $one_file . '_OBJECTS',
1491 unless $prefix =~ /EXTRA_/;
1498 # Avoid defining needless variables.
1499 next if (scalar @files == 0);
1501 ($temp, @result) = &handle_single_transform_list ($var, $one_file,
1503 $linker = $temp if $linker eq '';
1504 &define_pretty_variable ($xpfx . $one_file . "_OBJECTS", '', @result)
1505 unless $prefix =~ /EXTRA_/;
1508 local (@keys) = sort keys %used_pfx;
1509 if (scalar @keys == 0)
1511 &define_variable ($one_file . "_SOURCES", $unxformed . ".c");
1512 push (@sources, $unxformed . '.c');
1513 push (@dist_sources, $unxformed . '.c');
1514 push (@objects, $unxformed . $obj);
1515 push (@files, $unxformed . '.c');
1517 ($temp, @result) = &handle_single_transform_list ($one_file . '_SOURCES',
1520 $linker = $temp if $linker eq '';
1521 &define_pretty_variable ($one_file . "_OBJECTS", '', @result)
1525 grep ($_ = '$(' . $_ . $one_file . '_OBJECTS)', @keys);
1526 &define_pretty_variable ($one_file . '_OBJECTS', '', @keys);
1529 # If we want to use `LINK' we must make sure it is defined.
1538 # Special-case @ALLOCA@ and @LIBOBJS@ in _LDADD or _LIBADD variables.
1539 # Also, generate _DEPENDENCIES variable if appropriate.
1541 # transformed name of object being built, or empty string if no object
1542 # name of _LDADD/_LIBADD-type variable to examine
1543 # boolean (lex_seen) which is true if a lex source file was seen in this
1544 # object. valid only for LDADDs, not LIBADDs.
1545 # Returns 1 if LIBOBJS seen, 0 otherwise.
1546 sub handle_lib_objects
1548 local ($xname, $var, $lex_seen) = @_;
1551 die "automake: programming error 1 in handle_lib_objects\n"
1552 if ! &variable_defined ($var);
1554 die "automake: programming error 2 in handle_lib_objects\n"
1555 if $lex_seen && $var =~ /LIBADD/;
1557 local (@conds) = &variable_conditions ($var);
1560 $ret = &handle_lib_objects_cond ($xname, $var, $lex_seen, '');
1566 foreach $cond (@conds)
1568 if (&handle_lib_objects_cond ($xname, $var, $lex_seen, $cond))
1578 # Subroutine of handle_lib_objects: handle a particular condition.
1579 sub handle_lib_objects_cond
1581 local ($xname, $var, $lex_seen, $cond) = @_;
1583 # We recognize certain things that are commonly put in LIBADD or
1586 local (@dep_list) = ();
1588 local ($seen_libobjs) = 0;
1589 local ($flagvar) = 0;
1591 foreach $lsearch (&variable_value_as_list ($var, $cond))
1593 # Skip -lfoo and -Ldir; these are explicitly allowed.
1594 next if $lsearch =~ /^-[lL]/;
1595 if (! $flagvar && $lsearch =~ /^-/)
1597 if ($var =~ /^(.*)LDADD$/)
1599 # Skip -dlopen and -dlpreopen; these are explicitly allowed.
1600 next if $lsearch =~ /^-dl(pre)?open$/;
1601 &am_line_error ($var, "linker flags such as \`$lsearch' belong in \`${1}LDFLAGS");
1605 # Only get this error once.
1607 &am_line_error ($var, "linker flags such as \`$lsearch' belong in \`${1}LDFLAGS");
1611 # Assume we have a file of some sort, and push it onto the
1612 # dependency list. Autoconf substitutions are not pushed;
1613 # rarely is a new dependency substituted into (eg) foo_LDADD
1614 # -- but "bad things (eg -lX11) are routinely substituted.
1615 # Note that LIBOBJS and ALLOCA are exceptions to this rule,
1616 # and handled specially below.
1617 push (@dep_list, $lsearch)
1618 unless $lsearch =~ /^\@.*\@$/;
1620 # Automatically handle @LIBOBJS@ and @ALLOCA@. Basically this
1621 # means adding entries to dep_files.
1622 if ($lsearch =~ /^\@(LT)?LIBOBJS\@$/)
1624 local ($myobjext) = ($1 ? 'l' : '') . 'o';
1626 push (@dep_list, $lsearch);
1628 if (! keys %libsources
1629 && ! &variable_defined ($1 . 'LIBOBJS'))
1631 &am_line_error ($var, "\@$1" . "LIBOBJS\@ seen but never set in \`$configure_ac'");
1634 local ($iter, $rewrite);
1635 foreach $iter (keys %libsources)
1637 if ($iter =~ /\.([cly])$/)
1639 &saw_extension ($1);
1640 &saw_extension ('c');
1643 if ($iter =~ /\.h$/)
1645 &require_file_with_line ($var, $FOREIGN, $iter);
1647 elsif ($iter ne 'alloca.c')
1649 ($rewrite = $iter) =~ s/\.c$/.P$myobjext/;
1650 $dep_files{'$(DEPDIR)/' . $rewrite} = 1;
1651 ($rewrite = $iter) =~ s/(\W)/\\$1/g;
1652 $rewrite = "^" . $rewrite . "\$";
1653 # Only require the file if it is not a built source.
1654 if (! &variable_defined ('BUILT_SOURCES')
1655 || ! grep (/$rewrite/,
1656 &variable_value_as_list ('BUILT_SOURCES',
1659 &require_file_with_line ($var, $FOREIGN, $iter);
1664 elsif ($lsearch =~ /^\@(LT)?ALLOCA\@$/)
1666 local ($myobjext) = ($1 ? 'l' : '') . 'o';
1668 push (@dep_list, $lsearch);
1669 &am_line_error ($var,
1670 "\@$1" . "ALLOCA\@ seen but \`AC_FUNC_ALLOCA' not in \`$configure_ac'")
1671 if ! defined $libsources{'alloca.c'};
1672 $dep_files{'$(DEPDIR)/alloca.P' . $myobjext} = 1;
1673 &require_file_with_line ($var, $FOREIGN, 'alloca.c');
1674 &saw_extension ('c');
1678 if ($xname ne '' && ! &variable_defined ($xname . '_DEPENDENCIES', $cond))
1680 &define_pretty_variable ($xname . '_DEPENDENCIES', $cond, @dep_list);
1683 return $seen_libobjs;
1686 # Canonicalize a name, and check to make sure the non-canonical name
1687 # is never used. Returns canonical name. Arguments are name and a
1688 # list of suffixes to check for.
1689 sub check_canonical_spelling
1691 local ($name, @suffixes) = @_;
1692 local ($xname, $xt);
1694 ($xname = $name) =~ tr/A-Za-z0-9_/_/c;
1695 if ($xname ne $name)
1698 foreach $xt (@suffixes)
1700 &am_line_error ($name . $xt,
1701 "invalid variable \`" . $name . $xt
1702 . "'; should be \`" . $xname . $xt . "'")
1703 if &variable_defined ($name . $xt);
1710 # Handle C programs.
1713 local (@proglist) = &am_install_var ('-clean',
1714 'progs', 'PROGRAMS',
1715 'bin', 'sbin', 'libexec', 'pkglib',
1717 return if ! @proglist;
1719 # If a program is installed, this is required. We only want this
1720 # error to appear once.
1721 &am_conf_error ("AC_ARG_PROGRAM must be used")
1722 unless $seen_arg_prog;
1725 local ($one_file, $xname, $munge);
1727 local ($seen_libobjs) = 0;
1728 foreach $one_file (@proglist)
1730 local ($obj) = &get_object_extension ($one_file);
1732 # Canonicalize names and check for misspellings.
1733 $xname = &check_canonical_spelling ($one_file, '_LDADD', '_LDFLAGS',
1734 '_SOURCES', '_OBJECTS',
1737 # FIXME: Using a trick to figure out if any lex sources appear
1738 # in our program; should use some cleaner method.
1739 local ($lex_num) = scalar (keys %lex_sources);
1740 local ($linker) = &handle_source_transform ($xname, $one_file, $obj);
1741 local ($lex_file_seen) = (scalar (keys %lex_sources) > $lex_num);
1744 if (&variable_defined ($xname . "_LDADD"))
1746 if (&handle_lib_objects ($xname, $xname . '_LDADD',
1756 # User didn't define prog_LDADD override. So do it.
1757 &define_variable ($xname . '_LDADD', '$(LDADD)');
1759 # This does a bit too much work. But we need it to
1760 # generate _DEPENDENCIES when appropriate.
1761 if (&variable_defined ('LDADD'))
1763 if (&handle_lib_objects ($xname, 'LDADD', $lex_file_seen))
1769 elsif (! &variable_defined ($xname . '_DEPENDENCIES'))
1771 &define_variable ($xname . '_DEPENDENCIES', '');
1776 if (&variable_defined ($xname . '_LIBADD'))
1778 &am_line_error ($xname . '_LIBADD',
1779 "use \`" . $xname . "_LDADD', not \`"
1780 . $xname . "_LIBADD'");
1783 if (! &variable_defined ($xname . '_LDFLAGS'))
1785 # Define the prog_LDFLAGS variable.
1786 &define_variable ($xname . '_LDFLAGS', '');
1789 # Determine program to use for link.
1791 if (&variable_defined ($xname . '_LINK'))
1793 $xlink = $xname . '_LINK';
1797 $xlink = $linker ? $linker : 'LINK';
1801 if ($seen_exeext && $one_file !~ /\./)
1803 $xexe = 's/\@EXEEXT\@/\$(EXEEXT)/g;';
1807 $xexe = 's/\@EXEEXT\@//g;';
1811 &file_contents_with_transform
1812 ('s/\@PROGRAM\@/' . $one_file . '/go;'
1813 . 's/\@XPROGRAM\@/' . $xname . '/go;'
1814 . 's/\@XLINK\@/' . $xlink . '/go;'
1819 if (&variable_defined ('LDADD') && &handle_lib_objects ('', 'LDADD', 0))
1826 foreach $one_file (@proglist)
1828 # Canonicalize names.
1829 ($xname = $one_file) =~ tr/A-Za-z0-9_/_/c;
1831 if (&variable_defined ($xname . '_LDADD'))
1833 &check_libobjs_sources ($xname, $xname . '_LDADD');
1835 elsif (&variable_defined ('LDADD'))
1837 &check_libobjs_sources ($xname, 'LDADD');
1845 sub handle_libraries
1847 local (@liblist) = &am_install_var ('-clean',
1848 'libs', 'LIBRARIES',
1849 'lib', 'pkglib', 'noinst', 'check');
1850 return if ! @liblist;
1852 local (%valid) = &am_primary_prefixes ('LIBRARIES', 0, 'lib', 'pkglib',
1854 if (! defined $configure_vars{'RANLIB'})
1857 foreach $key (keys %valid)
1859 if (&variable_defined ($key . '_LIBRARIES'))
1861 &am_line_error ($key . '_LIBRARIES', "library used but \`RANLIB' not defined in \`$configure_am'");
1862 # Only get this error once. If this is ever printed,
1864 $configure_vars{'RANLIB'} = 'BUG';
1873 local ($seen_libobjs) = 0;
1874 foreach $onelib (@liblist)
1876 # Check that the library fits the standard naming convention.
1877 if ($onelib !~ /^lib.*\.a$/)
1879 # FIXME should put line number here. That means mapping
1880 # from library name back to variable name.
1881 &am_error ("\`$onelib' is not a standard library name");
1884 local ($obj) = &get_object_extension ($onelib);
1886 # Canonicalize names and check for misspellings.
1887 $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_SOURCES',
1888 '_OBJECTS', '_DEPENDENCIES', '_AR');
1890 if (! &variable_defined ($xlib . '_AR'))
1892 &define_variable ($xlib . '_AR', '$(AR) cru');
1895 if (&variable_defined ($xlib . '_LIBADD'))
1897 if (&handle_lib_objects ($xlib, $xlib . '_LIBADD', 0))
1904 # Generate support for conditional object inclusion in
1906 &define_variable ($xlib . "_LIBADD", '');
1909 if (&variable_defined ($xlib . '_LDADD'))
1911 &am_line_error ($xlib . '_LDADD',
1912 "use \`" . $xlib . "_LIBADD', not \`"
1913 . $xlib . "_LDADD'");
1916 # Make sure we at look at this.
1917 &examine_variable ($xlib . '_DEPENDENCIES');
1919 &handle_source_transform ($xlib, $onelib, $obj);
1922 &file_contents_with_transform ('s/\@LIBRARY\@/' . $onelib . '/go;'
1930 foreach $onelib (@liblist)
1932 # Canonicalize names.
1933 ($xlib = $onelib) =~ tr/A-Za-z0-9_/_/c;
1934 if (&variable_defined ($xlib . '_LIBADD'))
1936 &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
1941 &define_variable ('AR', 'ar');
1942 &define_configure_variable ('RANLIB');
1945 # Handle shared libraries.
1946 sub handle_ltlibraries
1948 local (@liblist) = &am_install_var ('-clean',
1949 'ltlib', 'LTLIBRARIES',
1950 'noinst', 'lib', 'pkglib', 'check');
1951 return if ! @liblist;
1954 local (%valid) = &am_primary_prefixes ('LTLIBRARIES', 0, 'lib', 'pkglib',
1958 foreach $key (keys %valid)
1960 if (&variable_defined ($key . '_LTLIBRARIES'))
1964 &am_line_error ($key . '_LTLIBRARIES', "library used but \`LIBTOOL' not defined in \`$configure_ac'");
1965 # Only get this error once. If this is ever printed,
1967 $configure_vars{'LIBTOOL'} = 'BUG';
1971 # Get the installation directory of each library.
1972 for (&variable_value_as_list ($key . '_LTLIBRARIES', 'all'))
1976 &am_error ("\`$_' is already going to be installed in \`$instdirs{$_}'");
1980 $instdirs{$_} = $key;
1989 local ($seen_libobjs) = 0;
1990 foreach $onelib (@liblist)
1992 local ($obj) = &get_object_extension ($onelib);
1994 # Canonicalize names and check for misspellings.
1995 $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_LDFLAGS',
1996 '_SOURCES', '_OBJECTS',
1999 if (! &variable_defined ($xlib . '_LDFLAGS'))
2001 # Define the lib_LDFLAGS variable.
2002 &define_variable ($xlib . '_LDFLAGS', '');
2005 # Check that the library fits the standard naming convention.
2006 $libname_rx = "^lib.*\.la";
2007 if ((&variable_defined ($xlib . '_LDFLAGS')
2008 && grep (/-module/, &variable_value_as_list ($xlib . '_LDFLAGS',
2010 || (&variable_defined ('LDFLAGS')
2011 && grep (/-module/, &variable_value_as_list ('LDFLAGS',
2014 # Relax name checking for libtool modules.
2015 $libname_rx = "\.la";
2017 if ($onelib !~ /$libname_rx$/)
2019 # FIXME this should only be a warning for foreign packages
2020 # FIXME should put line number here. That means mapping
2021 # from library name back to variable name.
2022 &am_error ("\`$onelib' is not a standard libtool library name");
2025 if (&variable_defined ($xlib . '_LIBADD'))
2027 if (&handle_lib_objects ($xlib, $xlib . '_LIBADD', 0))
2034 # Generate support for conditional object inclusion in
2036 &define_variable ($xlib . "_LIBADD", '');
2039 if (&variable_defined ($xlib . '_LDADD'))
2041 &am_line_error ($xlib . '_LDADD',
2042 "use \`" . $xlib . "_LIBADD', not \`"
2043 . $xlib . "_LDADD'");
2046 # Make sure we at look at this.
2047 &examine_variable ($xlib . '_DEPENDENCIES');
2049 local ($linker) = &handle_source_transform ($xlib, $onelib, $obj);
2051 # Determine program to use for link.
2053 if (&variable_defined ($xlib . '_LINK'))
2055 $xlink = $xlib . '_LINK';
2059 $xlink = $linker ? $linker : 'LINK';
2063 if ($instdirs{$onelib} eq 'EXTRA'
2064 || $instdirs{$onelib} eq 'noinst'
2065 || $instdirs{$onelib} eq 'check')
2067 # It's an EXTRA_ library, so we can't specify -rpath,
2068 # because we don't know where the library will end up.
2069 # The user probably knows, but generally speaking automake
2070 # doesn't -- and in fact configure could decide
2071 # dynamically between two different locations.
2072 $rpath = 's/\@RPATH\@//go;';
2076 $rpath = ('s/\@RPATH\@/-rpath \$(' . $instdirs{$onelib}
2081 &file_contents_with_transform ('s/\@LTLIBRARY\@/'
2083 . 's/\@XLTLIBRARY\@/'
2086 . 's/\@XLINK\@/' . $xlink . '/go;',
2092 foreach $onelib (@liblist)
2094 # Canonicalize names.
2095 ($xlib = $onelib) =~ tr/A-Za-z0-9_/_/c;
2096 if (&variable_defined ($xlib . '_LIBADD'))
2098 &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
2104 # See if any _SOURCES variable were misspelled. Also, make sure that
2105 # EXTRA_ variables don't contain configure substitutions.
2108 local ($varname, $primary);
2109 foreach $varname (keys %contents)
2111 foreach $primary ('_SOURCES', '_LIBADD', '_LDADD', '_LDFLAGS',
2114 if ($varname =~ /$primary$/ && ! $content_seen{$varname})
2116 &am_line_error ($varname,
2117 "invalid unused variable name: \`$varname'");
2126 # NOTE we no longer automatically clean SCRIPTS, because it is
2127 # useful to sometimes distribute scripts verbatim. This happens
2128 # eg in Automake itself.
2129 &am_install_var ('-candist', 'scripts', 'SCRIPTS',
2130 'bin', 'sbin', 'libexec', 'pkgdata',
2133 local ($scripts_installed) = 0;
2134 # Set $scripts_installed if appropriate. Make sure we only find
2135 # scripts which are actually installed -- this is why we can't
2136 # simply use the return value of am_install_var.
2137 local (%valid) = &am_primary_prefixes ('SCRIPTS', 1, 'bin', 'sbin',
2138 'libexec', 'pkgdata',
2141 foreach $key (keys %valid)
2143 if ($key ne 'noinst'
2145 && &variable_defined ($key . '_SCRIPTS'))
2147 $scripts_installed = 1;
2148 # push (@check_tests, 'check-' . $key . 'SCRIPTS');
2152 if ($scripts_installed)
2154 # If a program is installed, this is required. We only want this
2155 # error to appear once.
2156 &am_conf_error ("AC_ARG_PROGRAM must be used")
2157 unless $seen_arg_prog;
2162 # Search a file for a "version.texi" Texinfo include. Return the name
2163 # of the include file if found, or the empty string if not. A
2164 # "version.texi" file is actually any file whose name matches
2166 sub scan_texinfo_file
2168 local ($filename) = @_;
2170 if (! open (TEXI, $filename))
2172 &am_error ("couldn't open \`$filename': $!");
2175 print "automake: reading $filename\n" if $verbose;
2177 local ($vfile, $outfile);
2180 if (/^\@setfilename +(\S+)/)
2186 if (/^\@include\s+(vers[^.]*\.texi)\s*$/)
2188 # Found version.texi include.
2195 return ($outfile, $vfile);
2198 # Handle all Texinfo source.
2201 &am_line_error ('TEXINFOS',
2202 "\`TEXINFOS' is an anachronism; use \`info_TEXINFOS'")
2203 if &variable_defined ('TEXINFOS');
2204 return if (! &variable_defined ('info_TEXINFOS')
2205 && ! &variable_defined ('html_TEXINFOS'));
2207 if (&variable_defined ('html_TEXINFOS'))
2209 &am_line_error ('html_TEXINFOS',
2210 "HTML generation not yet supported");
2214 local (@texis) = &variable_value_as_list ('info_TEXINFOS', 'all');
2216 local (@info_deps_list, @dvis_list, @texi_deps);
2217 local ($infobase, $info_cursor);
2221 local ($tc_cursor, @texi_cleans);
2224 foreach $info_cursor (@texis)
2226 # FIXME: This is mildly hacky, since it recognizes "txinfo".
2227 # I don't feel like making it right.
2228 ($infobase = $info_cursor) =~ s/\.te?xi(nfo)?$//;
2230 # If 'version.texi' is referenced by input file, then include
2231 # automatic versioning capability.
2232 local ($out_file, $vtexi) = &scan_texinfo_file ($relative_dir
2233 . "/" . $info_cursor);
2235 if ($out_file eq '')
2237 &am_error ("\`$info_cursor' missing \@setfilename");
2241 if ($out_file =~ /\.(.+)$/ && $1 ne 'info')
2243 # FIXME should report line number in input file.
2244 &am_error ("output of \`$info_cursor', \`$out_file', has unrecognized extension");
2250 &am_error ("\`$vtexi', included in \`$info_cursor', also included in \`$versions{$vtexi}'")
2251 if (defined $versions{$vtexi});
2252 $versions{$vtexi} = $info_cursor;
2254 # We number the stamp-vti files. This is doable since the
2255 # actual names don't matter much. We only number starting
2256 # with the second one, so that the common case looks nice.
2257 $vti = ($done ? $done : 'vti');
2260 &push_dist_common ($vtexi, 'stamp-' . $vti);
2261 push (@clean, $vti);
2263 &require_conf_file_with_line ('info_TEXINFOS', $FOREIGN,
2266 local ($conf_pat, $conf_dir);
2267 if ($config_aux_dir eq '.' || $config_aux_dir eq '')
2269 $conf_dir = '$(srcdir)/';
2273 $conf_dir = $config_aux_dir;
2274 $conf_dir .= '/' unless $conf_dir =~ /\/$/;
2276 ($conf_pat = $conf_dir) =~ s/(\W)/\\$1/g;
2278 &file_contents_with_transform
2279 (&transform ('TEXI' => $info_cursor,
2282 'MDDIR' => $conf_pat,
2283 'CONFIGURE_AC' => $configure_ac),
2286 &push_phony_cleaners ($vti);
2289 # If user specified file_TEXINFOS, then use that as explicit
2292 push (@texi_deps, $info_cursor);
2293 # Prefix with $(srcdir) because some version of make won't
2294 # work if the target has it and the dependency doesn't.
2295 push (@texi_deps, '$(srcdir)/' . $vtexi) if $vtexi;
2297 # Canonicalize name first.
2298 ($canonical = $infobase) =~ tr/A-Za-z0-9_/_/c;
2299 if (&variable_defined ($canonical . "_TEXINFOS"))
2301 push (@texi_deps, '$(' . $canonical . '_TEXINFOS)');
2302 &push_dist_common ('$(' . $canonical . '_TEXINFOS)');
2305 $output_rules .= ("\n" . $out_file . ": "
2306 . join (' ', @texi_deps)
2307 . "\n" . $infobase . ".dvi: "
2308 . join (' ', @texi_deps)
2311 push (@info_deps_list, $out_file);
2312 push (@dvis_list, $infobase . '.dvi');
2314 # Generate list of things to clean for this target. We do
2315 # this explicitly because otherwise too many things could be
2316 # removed. In particular the ".log" extension might
2317 # reasonably be used in other contexts by the user.
2318 # FIXME: this is really out of control.
2319 foreach $tc_cursor ('aux', 'cp', 'cps', 'dvi', 'fn', 'fns', 'pgs',
2320 'ky', 'kys', 'ps', 'log', 'pg', 'toc', 'tp', 'tps',
2321 'vr', 'vrs', 'op', 'tr', 'cv', 'cn', 'cm', 'ov')
2323 push (@texi_cleans, $infobase . '.' . $tc_cursor);
2327 # Find these programs wherever they may lie. Yes, this has
2328 # intimate knowledge of the structure of the texinfo distribution.
2329 &define_program_variable ('MAKEINFO', 'build', 'texinfo/makeinfo',
2331 # Circumlocution to avoid accidental
2332 # configure substitution.
2334 &define_program_variable ('TEXI2DVI', 'src', 'texinfo/util',
2337 # Set transform for including texinfos.am. First, handle --cygnus
2342 $xform = 's/^NOTCYGNUS.*$//; s/^CYGNUS//;';
2346 $xform = 's/^CYGNUS.*$//; s/^NOTCYGNUS//;';
2349 # Handle location of texinfo.tex.
2350 local ($need_texi_file) = 0;
2351 local ($texinfo_tex);
2354 $texinfo_tex = '$(top_srcdir)/../texinfo/texinfo.tex';
2355 &define_variable ('TEXINFO_TEX', $texinfo_tex);
2358 elsif ($config_aux_dir ne '.' && $config_aux_dir ne '')
2360 $texinfo_tex = $config_aux_dir . '/texinfo.tex';
2361 &define_variable ('TEXINFO_TEX', $texinfo_tex);
2362 $need_texi_file = 2; # so that we require_conf_file later
2364 elsif (&variable_defined ('TEXINFO_TEX'))
2366 # The user defined TEXINFO_TEX so assume he knows what he is
2368 $texinfo_tex = ('$(srcdir)/'
2369 . &dirname (&variable_value ('TEXINFO_TEX')));
2373 $texinfo_tex = '$(srcdir)/texinfo.tex';
2374 $need_texi_file = 1;
2377 ($xxform = $texinfo_tex) =~ s/\/texinfo\.tex$//;
2378 $xxform =~ s/(\W)/\\$1/g;
2379 $xform .= ' s/\@TEXINFODIR\@/' . $xxform . '/g;';
2381 $output_rules .= &file_contents_with_transform ($xform, 'texinfos');
2382 push (@phony, 'install-info-am', 'uninstall-info');
2383 push (@dist_targets, 'dist-info');
2385 # How to clean. The funny name is due to --cygnus influence; in
2386 # Cygnus mode, `clean-info' is a target that users can use.
2387 $output_rules .= "\nmostlyclean-aminfo:\n";
2388 &pretty_print_rule ("\t-rm -f", "\t ", @texi_cleans);
2389 $output_rules .= ("\nclean-aminfo:\n\ndistclean-aminfo:\n\n"
2390 . "maintainer-clean-aminfo:\n\t"
2391 # Eww. But how else can we find all the output
2392 # files from makeinfo?
2393 . ($cygnus_mode ? '' : 'cd $(srcdir) && ')
2394 . 'for i in $(INFO_DEPS); do' . " \\\n"
2395 . "\t" . ' rm -f $$i;' . " \\\n"
2396 . "\t" . ' if test "`echo $$i-[0-9]*`" != "$$i-[0-9]*"; then' . " \\\n"
2397 . "\t" . ' rm -f $$i-[0-9]*;' . " \\\n"
2398 . "\t" . ' fi;' . " \\\n"
2400 &push_phony_cleaners ('aminfo');
2403 $output_rules .= "clean-info: mostlyclean-aminfo\n";
2406 push (@suffixes, '.texi', '.texinfo', '.txi', '.info', '.dvi', '.ps');
2408 if (! defined $options{'no-installinfo'})
2410 push (@uninstall, 'uninstall-info');
2411 push (@installdirs, '$(DESTDIR)$(infodir)');
2412 unshift (@install_data, 'install-info-am');
2414 # Make sure documentation is made and installed first. Use
2415 # $(INFO_DEPS), not 'info', because otherwise recursive makes
2416 # get run twice during "make all".
2417 unshift (@all, '$(INFO_DEPS)');
2419 push (@clean, 'aminfo');
2420 push (@info, '$(INFO_DEPS)');
2421 push (@dvi, '$(DVIS)');
2423 &define_variable ("INFO_DEPS", join (' ', @info_deps_list));
2424 &define_variable ("DVIS", join (' ', @dvis_list));
2425 # This next isn't strictly needed now -- the places that look here
2426 # could easily be changed to look in info_TEXINFOS. But this is
2427 # probably better, in case noinst_TEXINFOS is ever supported.
2428 &define_variable ("TEXINFOS", &variable_value ('info_TEXINFOS'));
2430 # Do some error checking. Note that this file is not required
2431 # when in Cygnus mode; instead we defined TEXINFO_TEX explicitly
2433 if ($need_texi_file && ! defined $options{'no-texinfo.tex'})
2435 if ($need_texi_file > 1)
2437 &require_conf_file_with_line ('info_TEXINFOS', $FOREIGN,
2442 &require_file_with_line ('info_TEXINFOS', $FOREIGN, 'texinfo.tex');
2447 # Handle any man pages.
2448 sub handle_man_pages
2450 &am_line_error ('MANS', "\`MANS' is an anachronism; use \`man_MANS'")
2451 if &variable_defined ('MANS');
2453 # Find all the sections in use. We do this by first looking for
2454 # "standard" sections, and then looking for any additional
2455 # sections used in man_MANS.
2456 local ($sect, %sections, %vlist);
2458 # Add more sections as needed.
2459 foreach $sect ('0'..'9', 'n', 'l')
2461 if (&variable_defined ('man' . $sect . '_MANS'))
2463 $sections{$sect} = 1;
2464 $vlist{'$(man' . $sect . '_MANS)'} = 1;
2469 if (&variable_defined ('man_MANS'))
2471 $vlist{'$(man_MANS)'} = 1;
2472 foreach (&variable_value_as_list ('man_MANS', 'all'))
2474 # A page like `foo.1c' goes into man1dir.
2475 if (/\.([0-9a-z])([a-z]*)$/)
2483 return unless $found;
2485 # Now for each section, generate an install and unintall rule.
2486 # Sort sections so output is deterministic.
2488 foreach $sect (sort keys %sections)
2490 &define_variable ('man' . $sect . 'dir', '$(mandir)/man' . $sect);
2491 push (@installdirs, '$(DESTDIR)$(mandir)/man' . $sect)
2492 unless defined $options{'no-installman'};
2493 $output_rules .= &file_contents_with_transform ('s/\@SECTION\@/'
2496 push (@phony, 'install-man' . $sect, 'uninstall-man' . $sect);
2497 push (@namelist, 'install-man' . $sect);
2500 # We don't really need this, but we use it in case we ever want to
2501 # support noinst_MANS.
2502 &define_variable ("MANS", join (' ', sort keys %vlist));
2504 # Generate list of install dirs.
2505 $output_rules .= ("install-man: \$(MANS)\n"
2506 . "\t\@\$(NORMAL_INSTALL)\n");
2507 &pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ", @namelist);
2508 push (@phony, 'install-man');
2510 $output_rules .= "uninstall-man:\n\t\@\$(NORMAL_UNINSTALL)\n";
2511 grep ($_ = 'un' . $_, @namelist);
2512 &pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ", @namelist);
2513 push (@phony, 'uninstall-man');
2515 $output_vars .= &file_contents ('mans-vars');
2517 if (! defined $options{'no-installman'})
2519 push (@install_data, 'install-man');
2520 push (@uninstall, 'uninstall-man');
2521 push (@all, '$(MANS)');
2525 # Handle DATA variables.
2528 &am_install_var ('-noextra', '-candist', 'data', 'DATA',
2529 'data', 'sysconf', 'sharedstate', 'localstate',
2530 'pkgdata', 'noinst', 'check');
2536 push (@phony, 'tags');
2537 local (@tag_deps) = ();
2538 if (&variable_defined ('SUBDIRS'))
2540 $output_rules .= ("tags-recursive:\n"
2541 . "\tlist=\'\$(SUBDIRS)\'; for subdir in \$\$list; do \\\n"
2542 # Never fail here if a subdir fails; it
2544 . "\t test \"\$\$subdir\" = . || (cd \$\$subdir"
2545 . " && \$(MAKE) \$(AM_MAKEFLAGS) tags); \\\n"
2547 push (@tag_deps, 'tags-recursive');
2548 push (@phony, 'tags-recursive');
2551 if (&saw_sources_p (1)
2552 || &variable_defined ('ETAGS_ARGS')
2555 local ($xform) = '';
2557 foreach $one_hdr (@config_headers)
2559 if ($relative_dir eq &dirname ($one_hdr))
2561 # The config header is in this directory. So require it.
2563 ($var = &basename ($one_hdr)) =~ s/(\W)/\\$1/g;
2564 $xform .= ' ' if $xform;
2568 $xform = ('s/\@CONFIG\@/' . $xform . '/;'
2569 . 's/\@DIRS\@/' . join (' ', @tag_deps) . '/;');
2571 if (&variable_defined ('SUBDIRS'))
2573 $xform .= 's/^SUBDIRS//;';
2577 $xform .= 's/^SUBDIRS.*$//;';
2580 $output_rules .= &file_contents_with_transform ($xform, 'tags');
2581 $output_rules .= &file_contents ('tags-clean');
2582 push (@clean, 'tags');
2583 &push_phony_cleaners ('tags');
2584 &examine_variable ('TAGS_DEPENDENCIES');
2586 elsif (&variable_defined ('TAGS_DEPENDENCIES'))
2588 &am_line_error ('TAGS_DEPENDENCIES',
2589 "doesn't make sense to define \`TAGS_DEPENDENCIES' without sources or \`ETAGS_ARGS'");
2593 # Every Makefile must define some sort of TAGS rule.
2594 # Otherwise, it would be possible for a top-level "make TAGS"
2595 # to fail because some subdirectory failed.
2596 $output_rules .= "tags: TAGS\nTAGS:\n\n";
2600 # Handle multilib support.
2603 return unless $seen_multilib;
2605 $output_rules .= &file_contents ('multilib');
2606 &push_phony_cleaners ('multi');
2607 push (@phony, 'all-multi', 'install-multi');
2610 # Worker for handle_dist.
2611 sub handle_dist_worker
2613 local ($makefile) = @_;
2615 $output_rules .= 'distdir: $(DISTFILES)' . "\n";
2617 # Initialization; only at top level.
2618 if ($relative_dir eq '.')
2620 if (defined $options{'check-news'})
2622 # For Gnits users, this is pretty handy. Look at 15 lines
2623 # in case some explanatory text is desirable.
2624 $output_rules .= ' @if sed 15q $(srcdir)/NEWS | fgrep -e "$(VERSION)" > /dev/null; then :; else \\
2625 echo "NEWS not updated; not releasing" 1>&2; \\
2632 # Create dist directory.
2633 $output_rules .= ("\t-chmod -R a+w \$(distdir) > /dev/null 2>&1; rm -rf \$(distdir)\n"
2634 . "\tmkdir \$(distdir)\n");
2637 # Scan EXTRA_DIST to see if we need to distribute anything from a
2638 # subdir. If so, add it to the list. I didn't want to do this
2639 # originally, but there were so many requests that I finally
2642 if (&variable_defined ('EXTRA_DIST'))
2644 # FIXME: This should be fixed to work with conditionals. That
2645 # will require only making the entries in @dist_dirs under the
2646 # appropriate condition. This is meaningful if the nature of
2647 # the distribution should depend upon the configure options
2649 foreach (&variable_value_as_list ('EXTRA_DIST', ''))
2652 next unless s,/+[^/]+$,,;
2653 push (@dist_dirs, $_)
2658 # We have to check DIST_COMMON for extra directories in case the
2659 # user put a source used in AC_OUTPUT into a subdir.
2660 foreach (&variable_value_as_list ('DIST_COMMON', 'all'))
2663 next unless s,/+[^/]+$,,;
2664 push (@dist_dirs, $_)
2670 # Prepend $(distdir) to each directory given. Doing it via a
2671 # hash lets us ensure that each directory is used only once.
2673 grep ($dhash{'$(distdir)/' . $_} = 1, @dist_dirs);
2674 $output_rules .= "\t";
2675 &pretty_print_rule ('$(mkinstalldirs)', "\t ", sort keys %dhash);
2678 # In loop, test for file existence because sometimes a file gets
2679 # included in DISTFILES twice. For example this happens when a
2680 # single source file is used in building more than one program.
2681 # Also, there are situations in which "ln" can fail. For instance
2682 # a file to distribute could actually be a cross-filesystem
2683 # symlink -- this can easily happen if "gettextize" was run on the
2685 $output_rules .= "\t\@for file in \$(DISTFILES); do \\\n";
2688 $output_rules .= "\t if test -f \$\$file; then d=.; else d=\$(srcdir); fi; \\\n";
2692 $output_rules .= "\t d=\$(srcdir); \\\n";
2694 $output_rules .= ("\t if test -d \$\$d/\$\$file; then \\\n"
2695 # Don't mention $$file in destination argument,
2696 # since this fails if destination directory
2697 # already exists. Also, use `-R' and not `-r'.
2698 # `-r' is almost always incorrect.
2699 . "\t cp -pR \$\$d/\$\$file \$(distdir) \\\n"
2700 . "\t || exit 1; \\\n"
2702 . "\t test -f \$(distdir)/\$\$file \\\n"
2703 . "\t || cp -p \$\$d/\$\$file \$(distdir)/\$\$file \\\n"
2704 . "\t || exit 1; \\\n"
2708 # If we have SUBDIRS, create all dist subdirectories and do
2710 if (&variable_defined ('SUBDIRS'))
2712 # If SUBDIRS is conditionally defined, then set DIST_SUBDIRS
2713 # to all possible directories, and use it. If DIST_SUBDIRS is
2714 # defined, just use it.
2715 local ($dist_subdir_name);
2716 if (&variable_conditions ('SUBDIRS')
2717 || &variable_defined ('DIST_SUBDIRS'))
2719 $dist_subdir_name = 'DIST_SUBDIRS';
2720 if (! &variable_defined ('DIST_SUBDIRS'))
2722 local (@full_list) = &variable_value_as_list ('SUBDIRS',
2724 local (@ds_list, %uniq, $iter);
2725 foreach $iter (@full_list)
2727 if (! defined $uniq{$iter})
2730 push (@ds_list, $iter);
2733 &define_pretty_variable ('DIST_SUBDIRS', '', @ds_list);
2738 $dist_subdir_name = 'SUBDIRS';
2739 # We always define this because that is what `distclean'
2741 &define_pretty_variable ('DIST_SUBDIRS', '', '$(SUBDIRS)');
2744 # Test for directory existence here because previous automake
2745 # invocation might have created some directories. Note that
2746 # we explicitly set distdir for the subdir make; that lets us
2747 # mix-n-match many automake-using packages into one large
2748 # package, and have "dist" at the top level do the right
2749 # thing. If we're in the topmost directory, then we use
2750 # `distdir' instead of `top_distdir'; this lets us work
2751 # correctly with an enclosing package.
2753 ("\t" . 'for subdir in $(' . $dist_subdir_name . '); do ' . "\\\n"
2754 . "\t" . ' if test "$$subdir" = .; then :; else ' . "\\\n"
2755 . "\t" . ' test -d $(distdir)/$$subdir ' . "\\\n"
2756 . "\t" . ' || mkdir $(distdir)/$$subdir ' . "\\\n"
2757 . "\t" . ' || exit 1; ' . "\\\n"
2758 . "\t" . ' (cd $$subdir'
2759 . ' && $(MAKE) $(AM_MAKEFLAGS) top_distdir=../$('
2760 . (($relative_dir eq '.') ? 'distdir' : 'top_distdir')
2761 . ') distdir=../$(distdir)/$$subdir distdir) ' . "\\\n"
2762 . "\t" . ' || exit 1; ' . "\\\n"
2763 . "\t" . ' fi; ' . "\\\n"
2767 # If the target `dist-hook' exists, make sure it is run. This
2768 # allows users to do random weird things to the distribution
2769 # before it is packaged up.
2770 push (@dist_targets, 'dist-hook') if &target_defined ('dist-hook');
2773 foreach $targ (@dist_targets)
2775 # We must explicitly set distdir and top_distdir for these
2777 $output_rules .= ("\t\$(MAKE) \$(AM_MAKEFLAGS)"
2778 . " top_distdir=\"\$(top_distdir)\""
2779 . " distdir=\"\$(distdir)\" $targ\n");
2782 push (@phony, 'distdir');
2785 # Handle 'dist' target.
2788 local ($makefile) = @_;
2790 # Set up maint_charset.
2791 $local_maint_charset = &variable_value ('MAINT_CHARSET')
2792 if &variable_defined ('MAINT_CHARSET');
2793 $maint_charset = $local_maint_charset
2794 if $relative_dir eq '.';
2796 if (&variable_defined ('DIST_CHARSET'))
2798 &am_line_error ('DIST_CHARSET',
2799 "DIST_CHARSET defined but no MAINT_CHARSET defined")
2800 if ! $local_maint_charset;
2801 if ($relative_dir eq '.')
2803 $dist_charset = &variable_value ('DIST_CHARSET')
2807 &am_line_error ('DIST_CHARSET',
2808 "DIST_CHARSET can only be defined at top level");
2812 # Look for common files that should be included in distribution.
2814 foreach $cfile (@common_files)
2816 if (-f ($relative_dir . "/" . $cfile))
2818 &push_dist_common ($cfile);
2822 # Always require configure.ac and configure at top level, even if
2823 # they don't exist. This is especially important for configure,
2824 # since it won't be created until autoconf is run -- which might
2825 # be after automake is run.
2826 &push_dist_common ($configure_ac, 'configure')
2827 if $relative_dir eq '.';
2829 # We might copy elements from %configure_dist_common to
2830 # %dist_common if we think we need to. If the file appears in our
2831 # directory, we would have discovered it already, so we don't
2832 # check that. But if the file is in a subdir without a Makefile,
2833 # we want to distribute it here if we are doing `.'. Ugly!
2834 if ($relative_dir eq '.')
2837 foreach $iter (keys %configure_dist_common)
2839 if (! &is_make_dir (&dirname ($iter)))
2841 &push_dist_common ($iter);
2846 # Keys of %dist_common are names of files to distributed. We put
2847 # README first because it then becomes easier to make a
2848 # Usenet-compliant shar file (in these, README must be first).
2849 # FIXME: do more ordering of files here.
2851 if (defined $dist_common{'README'})
2853 push (@coms, 'README');
2854 delete $dist_common{'README'};
2856 push (@coms, sort keys %dist_common);
2858 # Now that we've processed %dist_common, disallow further attempts
2860 $handle_dist_run = 1;
2862 &define_pretty_variable ("DIST_COMMON", '', @coms);
2863 $output_vars .= "\n";
2866 $output_vars .= &file_contents ('dist-vars') . "\n";
2867 &define_variable ('GZIP_ENV', '--best');
2869 # Put these things in rules section so it is easier for whoever
2870 # reads Makefile.in.
2871 if (! &variable_defined ('distdir'))
2873 if ($relative_dir eq '.')
2875 $output_rules .= "\n" . 'distdir = $(PACKAGE)-$(VERSION)' . "\n";
2879 $output_rules .= ("\n"
2880 . 'distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)'
2884 if ($relative_dir eq '.')
2886 $output_rules .= "top_distdir = \$(distdir)\n";
2888 $output_rules .= "\n";
2890 # Generate 'dist' target, and maybe other dist targets.
2891 if ($relative_dir eq '.')
2893 # Rule to check whether a distribution is viable.
2894 local ($xform) = '';
2896 if (&target_defined ('distcheck-hook'))
2898 $xform .= 's/^DISTHOOK//;';
2902 $xform .= 's/^DISTHOOK.*$//;';
2906 $xform .= 's/^GETTEXT//;';
2910 $xform .= 's/^GETTEXT.*$//;';
2913 $output_rules .= &file_contents_with_transform ($xform, 'dist');
2915 local ($dist_all) = ('dist-all: distdir' . "\n"
2918 foreach $curs ('dist', 'dist-shar', 'dist-zip', 'dist-tarZ',
2921 if (defined $options{$curs} || $curs eq 'dist')
2923 $output_rules .= ($curs . ': distdir' . "\n"
2927 $dist_all .= $dist{$curs};
2930 $output_rules .= $dist_all . $dist_trailer;
2933 # Generate distdir target.
2934 &handle_dist_worker ($makefile);
2937 # A subroutine of handle_dependencies. This function includes
2938 # `depend2' with appropriate transformations.
2943 # First include code for ordinary objects.
2944 local ($key) = $lang . '-autodep';
2945 local ($xform, $ext);
2947 local ($pfx) = $language_map{$key};
2948 local ($fpfx) = ($pfx eq '') ? 'CC' : $pfx;
2949 $xform = ('s/\@PFX\@/' . $pfx . '/g;'
2950 . 's/\@FPFX\@/' . $fpfx . '/g;'
2951 . ($seen_objext ? 's/^OBJEXT//;' : 's/^OBJEXT.*$//;')
2952 . ($seen_libtool ? 's/^LIBTOOL//;' : 's/^LIBTOOL.*$//;'));
2954 # This function can be called even when we don't want dependency
2955 # tracking. This happens when we need an explicit rule for some
2956 # target. In this case we don't want to include the generic code.
2957 if ($use_dependencies)
2959 local ($xform1) = ($xform
2960 . 's/\@BASE\@/\$\*/g;'
2961 . 's/\@SOURCE\@/\$\</g;'
2962 . 's/\@(LT|OBJ)?OBJ\@/\$\@/g;');
2964 foreach $ext (&lang_extensions ($lang))
2966 $output_rules .= (&file_contents_with_transform ('s/\@EXT\@/'
2974 # Now include code for each specially handled object with this
2976 local (@list) = grep ($_ ne '', split (' ', $lang_specific_files{$lang}));
2977 local ($max) = scalar @list;
2979 local ($derived, $source, $obj);
2981 # If dependency tracking is disabled, we just elide the code.
2982 if (! $use_dependencies)
2984 $xform .= 's/\@AMDEP\@.*$//;';
2989 $derived = $list[$i];
2990 ($source = $list[$i + 1]) =~ s,([/\$]),\\$1,g;
2991 ($obj = $list[$i + 2]) =~ s,([/\$]),\\$1,g;
2994 local ($flag) = $language_map{$lang . '-flags'};
2995 local ($val) = "(${derived}_${flag}";
2996 ($rule = $language_map{$lang . '-compile'}) =~
2999 $rule =~ s,([/\$]),\\$1,g;
3001 # Generate a transform which will turn suffix targets in
3002 # depend2.am into real targets for the particular objects we
3005 &file_contents_with_transform ($xform
3006 . 's/\$\(' . $pfx . 'COMPILE\)/'
3008 . 's/\$\(LT' . $pfx . 'COMPILE\)/'
3009 . '\$(LIBTOOL) --mode=compile '
3011 # Generate rule for `.o'.
3013 . $obj . '.o: ' . $source
3015 # Maybe generate rule for `.lo'.
3016 # Might be eliminated by
3018 . 's/^\@EXT\@\.lo:/'
3019 . $obj . '.lo: ' . $source
3021 # Maybe generate rule for `.obj'.
3022 # Might be eliminated by
3024 . 's/^\@EXT\@\.obj:/'
3025 . $obj . '.obj: ' . $source
3027 # Handle source and obj
3029 . 's/\@OBJ\@/' . $obj . '.o/g;'
3030 . 's/\@OBJOBJ\@/' . $obj . '.obj/g;'
3031 . 's/\@LTOBJ\@/' . $obj . '.lo/g;'
3032 . 's/\@BASE\@/' . $obj . '/g;'
3033 . 's/\@SOURCE\@/' . $source . '/g;',
3038 # Handle auto-dependency code.
3039 sub handle_dependencies
3041 if ($use_dependencies)
3043 # Include auto-dep code. Don't include it if DEP_FILES would
3045 if (&saw_sources_p (0) && keys %dep_files)
3047 local ($config_aux_dir_specified) = ($config_aux_dir ne '.'
3048 && $config_aux_dir ne '');
3050 # Set $require_file_found{'depcomp'} if the depcomp file exists,
3051 # before calling require_config_file on `depcomp'. This makes
3052 # require_file_internal skip its buggy existence test that would
3053 # make automake fail (with `required file `lib/depcomp' not found')
3054 # when AC_CONFIG_AUX_DIR is not set. See tests/subdir4.test.
3055 local ($depcomp_dir) = ($config_aux_dir_specified ? $config_aux_dir
3057 $require_file_found{'depcomp'} = 1 if -f "$depcomp_dir/depcomp";
3059 # Set location of depcomp.
3060 local ($prefix) = ($config_aux_dir_specified ? $config_aux_dir
3063 &define_variable ('depcomp', "\$(SHELL) $prefix/depcomp");
3065 &require_config_file ($FOREIGN, 'depcomp');
3068 local (@deplist) = sort keys %dep_files;
3070 &define_pretty_variable ('DEP_FILES', '', ("\@AMDEP\@", @deplist));
3072 # Generate each `include' individually. Irix 6 make will
3073 # not properly include several files resulting from a
3074 # variable expansion; generating many separate includes
3076 $output_rules .= "\n";
3077 foreach $iter (@deplist)
3079 $output_rules .= "\@AMDEP\@" . 'include ' . $iter . "\n";
3082 $output_rules .= &file_contents ('depend');
3083 push (@clean, 'depend');
3084 &push_phony_cleaners ('depend');
3089 &define_variable ('depcomp', '');
3092 local ($key, $lang, $ext, $xform);
3093 foreach $key (sort keys %language_map)
3095 next unless $key =~ /^(.*)-autodep$/;
3096 next if $language_map{$key} eq 'no';
3101 # Handle subdirectories.
3104 return if ! &variable_defined ('SUBDIRS');
3106 # Make sure each directory mentioned in SUBDIRS actually exists.
3108 foreach $dir (&variable_value_as_list ('SUBDIRS', 'all'))
3110 # Skip directories substituted by configure.
3111 next if $dir =~ /^\@.*\@$/;
3113 if (! -d $am_relative_dir . '/' . $dir)
3115 &am_line_error ('SUBDIRS',
3116 "required directory $am_relative_dir/$dir does not exist");
3120 &am_line_error ('SUBDIRS', "directory should not contain \`/'")
3124 local ($xform) = ('s/\@INSTALLINFO\@/' .
3125 (defined $options{'no-installinfo'}
3126 ? 'install-info-recursive'
3129 $output_rules .= &file_contents_with_transform ($xform, 'subdirs');
3131 # Push a bunch of phony targets.
3133 foreach $phonies ('', '-data', '-exec', 'dirs')
3135 push (@phony, 'install' . $phonies . '-recursive');
3136 push (@phony, 'uninstall' . $phonies . '-recursive');
3138 foreach $phonies ('all', 'check', 'installcheck', 'info', 'dvi')
3140 push (@phony, $phonies . '-recursive');
3142 &push_phony_cleaners ('recursive');
3144 $recursive_install = 1;
3147 # Handle aclocal.m4.
3148 sub handle_aclocal_m4
3150 local ($regen_aclocal) = 0;
3151 if (-f 'aclocal.m4')
3153 &define_variable ("ACLOCAL_M4", '$(top_srcdir)/aclocal.m4');
3154 &push_dist_common ('aclocal.m4');
3156 if (open (ACLOCAL, '< aclocal.m4'))
3162 if ($line =~ 'generated automatically by aclocal')
3169 local ($acinclude) = 0;
3170 if (-f 'acinclude.m4')
3176 # Note that it might be possible that aclocal.m4 doesn't exist but
3177 # should be auto-generated. This case probably isn't very
3181 local (@ac_deps) = (
3183 ? "\@MAINTAINER_MODE_TRUE\@"
3186 ($acinclude ? ' acinclude.m4' : '')
3189 if (&variable_defined ('ACLOCAL_M4_SOURCES'))
3191 push (@ac_deps, "\$(ACLOCAL_M4_SOURCES)");
3193 elsif (&variable_defined ('ACLOCAL_AMFLAGS'))
3195 # Scan all -I directories for m4 files. These are our
3197 local ($examine_next, $amdir) = 0;
3198 foreach $amdir (&variable_value_as_list ('ACLOCAL_AMFLAGS', ''))
3203 if ($amdir !~ /^\// && -d $amdir)
3205 foreach $ac_dep (&my_glob ($amdir . '/*.m4'))
3207 $ac_dep =~ s/^\.\/*//;
3208 push (@ac_deps, $ac_dep)
3209 unless $ac_dep eq "aclocal.m4"
3210 || $ac_dep eq "acinclude.m4";
3214 elsif ($amdir eq '-I')
3221 &pretty_print_rule ("\$(ACLOCAL_M4):", "\t\t", @ac_deps);
3223 $output_rules .= ("\t"
3224 . 'cd $(srcdir) && $(ACLOCAL)'
3225 . (&variable_defined ('ACLOCAL_AMFLAGS')
3226 ? ' $(ACLOCAL_AMFLAGS)' : '')
3231 # Rewrite a list of input files into a form suitable to put on a
3232 # dependency list. The idea is that if an input file has a directory
3233 # part the same as the current directory, then the directory part is
3234 # simply removed. But if the directory part is different, then
3235 # $(top_srcdir) is prepended. Among other things, this is used to
3236 # generate the dependency list for the output files generated by
3237 # AC_OUTPUT. Consider what the dependencies should look like in this
3239 # AC_OUTPUT(src/out:src/in1:lib/in2)
3240 # The first argument, ADD_SRCDIR, is 1 if $(top_srcdir) should be added.
3241 # If 0 then files that require this addition will simply be ignored.
3242 sub rewrite_inputs_into_dependencies
3244 local ($add_srcdir, @inputs) = @_;
3245 local ($single, @newinputs);
3247 foreach $single (@inputs)
3249 if (&dirname ($single) eq $relative_dir)
3251 push (@newinputs, &basename ($single));
3255 push (@newinputs, '$(top_srcdir)/' . $single);
3262 # Handle remaking and configure stuff.
3263 # We need the name of the input file, to do proper remaking rules.
3264 sub handle_configure
3266 local ($local, $input, @secondary_inputs) = @_;
3268 local ($top_reldir);
3270 local ($input_base) = &basename ($input);
3271 local ($local_base) = &basename ($local);
3273 local ($amfile) = $input_base . '.am';
3274 # We know we can always add '.in' because it really should be an
3275 # error if the .in was missing originally.
3276 local ($infile) = '$(srcdir)/' . $input_base . '.in';
3277 local ($colon_infile);
3278 if ($local ne $input || @secondary_inputs)
3280 $colon_infile = ':' . $input . '.in';
3282 $colon_infile .= ':' . join (':', @secondary_inputs)
3283 if @secondary_inputs;
3285 local (@rewritten) = &rewrite_inputs_into_dependencies (1,
3288 # This rule remakes the Makefile.in. Note use of
3289 # @MAINTAINER_MODE_TRUE@ forces us to abandon pretty-printing.
3291 $output_rules .= ($infile
3292 # NOTE perl 5.003 (with -w) gives a
3293 # uninitialized value error on the next line.
3296 . ($seen_maint_mode ? "\@MAINTAINER_MODE_TRUE\@ " : '')
3298 . '$(top_srcdir)/' . $configure_ac .' $(ACLOCAL_M4)'
3299 . ' ' . join (' ', @include_stack)
3301 . "\tcd \$(top_srcdir) && \$(AUTOMAKE) "
3302 . ($cygnus_mode ? '--cygnus' : ('--' . $strictness_name))
3303 . ($cmdline_use_dependencies ? '' : ' --ignore-deps')
3304 . ' ' . $input . $colon_infile . "\n\n");
3306 # This rule remakes the Makefile.
3307 $output_rules .= ($local_base
3308 # NOTE: bogus uninit value error on next line;
3309 # see comment above.
3312 . join (' ', @rewritten)
3313 . ' $(top_builddir)/config.status'
3315 . "\tcd \$(top_builddir) \\\n"
3316 . "\t && CONFIG_FILES="
3317 . (($relative_dir eq '.') ? '$@' : '$(subdir)/$@')
3319 . ' CONFIG_HEADERS= $(SHELL) ./config.status'
3322 if ($relative_dir ne '.')
3325 $top_reldir = '../';
3329 local ($xform) = &transform ('CONFIGURE_AC' => $configure_ac);
3331 $output_rules .= &file_contents_with_transform ($xform,
3333 &examine_variable ('CONFIG_STATUS_DEPENDENCIES');
3334 &examine_variable ('CONFIGURE_DEPENDENCIES');
3337 &push_dist_common ('acconfig.h')
3341 # If we have a configure header, require it.
3343 local (@local_fullnames) = @config_fullnames;
3344 local (@local_names) = @config_names;
3345 local ($hdr_index) = 0;
3346 local ($distclean_config) = '';
3347 foreach $one_hdr (@config_headers)
3349 local ($one_fullname) = shift (@local_fullnames);
3350 local ($one_name) = shift (@local_names);
3352 local ($header_dir) = &dirname ($one_name);
3354 # If the header is in the current directory we want to build
3355 # the header here. Otherwise, if we're at the topmost
3356 # directory and the header's directory doesn't have a
3357 # Makefile, then we also want to build the header.
3358 if ($relative_dir eq $header_dir
3359 || ($relative_dir eq '.' && ! &is_make_dir ($header_dir)))
3361 local ($ch_sans_dir, $cn_sans_dir, $stamp_dir);
3362 if ($relative_dir eq $header_dir)
3364 $cn_sans_dir = &basename ($one_name);
3369 $cn_sans_dir = $one_name;
3370 if ($header_dir eq '.')
3376 $stamp_dir = $header_dir . '/';
3380 # Compute relative path from directory holding output
3381 # header to directory holding input header. FIXME:
3382 # doesn't handle case where we have multiple inputs.
3383 if (&dirname ($one_hdr) eq $relative_dir)
3385 $ch_sans_dir = &basename ($one_hdr);
3389 local (@rel_out_path);
3390 # FIXME this chunk of code should be its own sub.
3391 # It is used elsewhere.
3392 foreach (split (/\//, $relative_dir))
3394 next if $_ eq '' || $_ eq '.';
3397 # FIXME: actually this is an error.
3402 push (@rel_out_path, '..');
3407 $ch_sans_dir = join ('/', @rel_out_path) . '/' . $one_hdr;
3411 $ch_sans_dir = $one_hdr;
3415 &require_file_with_conf_line ($config_header_line,
3416 $FOREIGN, $ch_sans_dir);
3418 # Header defined and in this directory.
3420 if (-f $one_name . '.top')
3422 push (@files, "${cn_sans_dir}.top");
3424 if (-f $one_name . '.bot')
3426 push (@files, "${cn_sans_dir}.bot");
3429 &push_dist_common (@files);
3431 # For now, acconfig.h can only appear in the top srcdir.
3432 if (-f 'acconfig.h')
3434 if ($relative_dir eq '.')
3436 push (@files, 'acconfig.h');
3440 # Strange quoting because this gets fed through
3442 push (@files, '\$(top_srcdir)/acconfig.h');
3446 local ($stamp_name) = 'stamp-h';
3447 $stamp_name .= "${hdr_index}" if scalar (@config_headers) > 1;
3449 local ($xform) = '';
3451 $xform = &transform ('CONFIGURE_AC' => $configure_ac,
3452 'FILES' => join (' ', @files),
3453 'CONFIG_HEADER' => $cn_sans_dir,
3454 'CONFIG_HEADER_IN' => $ch_sans_dir,
3455 'CONFIG_HEADER_FULL' => $one_fullname,
3456 'STAMP' => "$stamp_dir$stamp_name");
3458 local ($out_dir) = &dirname ($ch_sans_dir);
3459 $xform .= &transform ('SRC_STAMP' => "${out_dir}/${stamp_name}");
3460 $output_rules .= &file_contents_with_transform ($xform,
3463 &create ("${relative_dir}/${out_dir}/${stamp_name}.in");
3464 &require_file_with_conf_line ($config_header_line, $FOREIGN,
3465 "${out_dir}/${stamp_name}.in");
3467 $distclean_config .= ' ' if $distclean_config;
3468 $distclean_config .= $cn_sans_dir;
3472 if ($distclean_config)
3474 $output_rules .= &file_contents_with_transform ('s,\@FILES\@,'
3478 push (@clean, 'hdr');
3479 &push_phony_cleaners ('hdr');
3482 # Set location of mkinstalldirs.
3483 if ($config_aux_dir ne '.' && $config_aux_dir ne '')
3485 &define_variable ('mkinstalldirs', ('$(SHELL) ' . $config_aux_dir
3486 . '/mkinstalldirs'));
3490 &define_variable ('mkinstalldirs',
3491 '$(SHELL) $(top_srcdir)/mkinstalldirs');
3494 &am_line_error ('CONFIG_HEADER',
3495 "\`CONFIG_HEADER' is an anachronism; now determined from \`$configure_ac'")
3496 if &variable_defined ('CONFIG_HEADER');
3499 local ($config_header) = '';
3500 foreach $one_name (@config_names)
3502 # Generate CONFIG_HEADER define.
3504 if ($relative_dir eq &dirname ($one_name))
3506 $one_hdr = &basename ($one_name);
3510 $one_hdr = "${top_builddir}/${one_name}";
3513 $config_header .= ' ' if $config_header;
3514 $config_header .= $one_hdr;
3518 &define_variable ("CONFIG_HEADER", $config_header);
3521 # Now look for other files in this directory which must be remade
3522 # by config.status, and generate rules for them.
3523 local (@actual_other_files) = ();
3524 local ($file, $local);
3525 local (@inputs, @rewritten_inputs, $single);
3526 local ($need_rewritten);
3527 foreach $file (@other_input_files)
3529 if ($file =~ /^([^:]*):(.*)$/)
3531 # This is the ":" syntax of AC_OUTPUT.
3533 $local = &basename ($file);
3534 @inputs = split (':', $2);
3535 @rewritten_inputs = &rewrite_inputs_into_dependencies (1, @inputs);
3536 $need_rewritten = 1;
3541 $local = &basename ($file);
3542 @inputs = ($local . '.in');
3544 &rewrite_inputs_into_dependencies (1, $file . '.in');
3545 $need_rewritten = 0;
3548 # Skip files not in this directory.
3549 next unless &dirname ($file) eq $relative_dir;
3551 # Skip any file that is an automake input.
3552 next if -f $file . '.am';
3554 # Some users have been tempted to put `stamp-h' in the
3555 # AC_OUTPUT line. This won't do the right thing, so we
3556 # explicitly fail here.
3557 if ($local eq 'stamp-h')
3559 # FIXME: allow real filename.
3560 &am_conf_error ($configure_ac, $ac_output_line,
3561 'stamp-h should not appear in AC_OUTPUT');
3565 $output_rules .= ($local . ': '
3566 . '$(top_builddir)/config.status '
3567 . join (' ', @rewritten_inputs) . "\n"
3569 . 'cd $(top_builddir) && CONFIG_FILES='
3570 . ($relative_dir eq '.' ? '' : '$(subdir)/')
3571 . '$@' . ($need_rewritten
3572 ? (':' . join (':', @inputs))
3574 . ' CONFIG_HEADERS= $(SHELL) ./config.status'
3576 &push_dist_common (@inputs);
3577 push (@actual_other_files, $local);
3579 # Require all input files.
3580 &require_file_with_conf_line ($ac_output_line, $FOREIGN,
3581 &rewrite_inputs_into_dependencies (0, @inputs));
3584 # These files get removed by "make clean".
3585 &define_pretty_variable ('CONFIG_CLEAN_FILES', '', @actual_other_files);
3592 @r = &am_install_var ('-defaultdist', 'header', 'HEADERS', 'include',
3593 'oldinclude', 'pkginclude',
3597 next unless /\.(.*)$/;
3598 &saw_extension ($1);
3604 return if ! $seen_gettext || $relative_dir ne '.';
3606 if (! &variable_defined ('SUBDIRS'))
3609 ("AM_GNU_GETTEXT used but SUBDIRS not defined");
3613 &require_file_with_conf_line ($ac_gettext_line, $GNU, 'ABOUT-NLS');
3615 if (&variable_defined ('SUBDIRS'))
3619 "AM_GNU_GETTEXT in \`$configure_ac' but \`po' not in SUBDIRS")
3620 if $contents{'SUBDIRS'} !~ /\bpo\b/;
3623 "AM_GNU_GETTEXT in \`$configure_ac' but \`intl' not in SUBDIRS")
3624 if $contents{'SUBDIRS'} !~ /\bintl\b/;
3627 # Ensure that each language in ALL_LINGUAS has a .po file, and
3628 # each po file is mentioned in ALL_LINGUAS.
3631 local (%linguas) = ();
3632 grep ($linguas{$_} = 1, split (' ', $all_linguas));
3639 &am_line_error ($all_linguas_line,
3640 ("po/$_.po exists but \`$_' not in \`ALL_LINGUAS'"))
3644 foreach (keys %linguas)
3646 &am_line_error ($all_linguas_line,
3647 "$_ in \`ALL_LINGUAS' but po/$_.po does not exist")
3653 &am_error ("AM_GNU_GETTEXT in \`$configure_ac' but \`ALL_LINGUAS' not defined");
3657 # Handle footer elements.
3660 if ($contents{'SOURCES'})
3662 # NOTE don't use define_pretty_variable here, because
3663 # $contents{...} is already defined.
3664 $output_vars .= 'SOURCES = ' . $contents{'SOURCES'} . "\n";
3666 if ($contents{'OBJECTS'})
3668 # NOTE don't use define_pretty_variable here, because
3669 # $contents{...} is already defined.
3670 $output_vars .= 'OBJECTS = ' . $contents{'OBJECTS'} . "\n";
3672 if ($contents{'SOURCES'} || $contents{'OBJECTS'})
3674 $output_vars .= "\n";
3677 if (&target_defined ('.SUFFIXES'))
3679 &am_line_error ('.SUFFIXES',
3680 "use variable \`SUFFIXES', not target \`.SUFFIXES'");
3683 # Note: AIX 4.1 /bin/make will fail if any suffix rule appears
3684 # before .SUFFIXES. So we make sure that .SUFFIXES appears before
3685 # anything else, by sticking it right after the default: target.
3686 $output_header .= ".SUFFIXES:\n";
3687 if (@suffixes || &variable_defined ('SUFFIXES'))
3689 # Make sure suffixes has unique elements. Sort them to ensure
3690 # the output remains consistent. However, $(SUFFIXES) is
3691 # always at the start of the list, unsorted. This is done
3692 # because make will choose rules depending on the ordering of
3693 # suffixes, and this lets the user have some control. Push
3694 # actual suffixes, and not $(SUFFIXES). Some versions of make
3695 # do not like variable substitutions on the .SUFFIXES line.
3697 local (@user_suffixes) = (&variable_defined ('SUFFIXES')
3698 ? &variable_value_as_list ('SUFFIXES', '')
3701 grep ($suffixes{$_} = 1, @suffixes);
3702 delete @suffixes{@user_suffixes};
3704 $output_header .= (".SUFFIXES: "
3705 . join (' ', @user_suffixes, sort keys %suffixes)
3708 $output_trailer .= &file_contents ('footer');
3711 # Deal with installdirs target.
3712 sub handle_installdirs
3714 # GNU Makefile standards recommend this.
3715 if ($recursive_install)
3717 # We create a separate `-am' target so that the -recursive
3718 # rule will work correctly.
3719 $output_rules .= ("installdirs: installdirs-recursive\n"
3720 . "installdirs-am:\n");
3721 push (@phony, 'installdirs-am');
3725 $output_rules .= "installdirs:\n";
3727 push (@phony, 'installdirs');
3730 &pretty_print_rule ("\t" . '$(mkinstalldirs) ', "\t\t",
3733 $output_rules .= "\n";
3736 # There are several targets which need to be merged. This is because
3737 # their complete definition is compiled from many parts. Note that we
3738 # avoid double colon rules, otherwise we'd use them instead.
3739 sub handle_merge_targets
3741 local ($makefile) = @_;
3743 # There are a few install-related variables that you should not define.
3745 foreach $var ('PRE_INSTALL', 'POST_INSTALL', 'NORMAL_INSTALL')
3747 if (&variable_defined ($var))
3749 &am_line_error ($var, "\`$var' should not be defined");
3753 # Put this at the beginning for the sake of non-GNU makes. This
3754 # is still wrong if these makes can run parallel jobs. But it is
3756 unshift (@all, &basename ($makefile));
3759 foreach $one_name (@config_names)
3761 push (@all, &basename ($one_name))
3762 if &dirname ($one_name) eq $relative_dir;
3765 &do_one_merge_target ('info', @info);
3766 &do_one_merge_target ('dvi', @dvi);
3767 &do_check_merge_target;
3768 &do_one_merge_target ('installcheck', @installcheck);
3770 if (defined $options{'no-installinfo'})
3772 &do_one_merge_target ('install-info', '');
3774 elsif (&target_defined ('install-info-local'))
3776 &am_line_error ('install-info-local',
3777 "\`install-info-local' target defined but \`no-installinfo' option not in use");
3781 foreach $utarg ('uninstall-data-local', 'uninstall-data-hook',
3782 'uninstall-exec-local', 'uninstall-exec-hook')
3784 if (&target_defined ($utarg))
3787 ($x = $utarg) =~ s/(data|exec)-//;
3788 &am_line_error ($utarg, "use \`$x', not \`$utarg'");
3792 if (&target_defined ('install-local'))
3794 &am_line_error ('install-local',
3795 "use \`install-data-local' or \`install-exec-local', not \`install-local'");
3798 if (@all || &variable_defined ('BUILT_SOURCES'))
3801 local ($local_headers) = '';
3802 $local_headers = '$(BUILT_SOURCES)'
3803 if &variable_defined ('BUILT_SOURCES');
3804 foreach $one_name (@config_names)
3806 if (&dirname ($one_name) eq $relative_dir)
3808 $local_headers .= ' ' if $local_headers;
3809 $local_headers .= &basename ($one_name);
3814 # This is kind of a hack, but I couldn't see a better way
3815 # to handle it. In this particular case, we need to make
3816 # sure config.h is built before we recurse. We can't do
3817 # this by changing the order of dependencies to the "all"
3818 # because that breaks when using parallel makes. Instead
3819 # we handle things explicitly.
3820 $output_rules .= ("all-recursive-am: ${local_headers}"
3822 . '$(MAKE) $(AM_MAKEFLAGS)'
3825 $all_target = 'all-recursive-am';
3826 push (@phony, 'all-recursive-am');
3830 if (&variable_defined('lib_LTLIBRARIES') &&
3831 &variable_defined('bin_PROGRAMS'))
3833 $output_rules .= "install-binPROGRAMS: install-libLTLIBRARIES\n\n";
3835 # Print definitions users can use.
3836 &do_one_merge_target ('install-exec', @install_exec);
3837 $output_rules .= "\n";
3839 &do_one_merge_target ('install-data', @install_data);
3840 $output_rules .= "\n";
3842 &do_one_merge_target ('install', 'all-am');
3843 &do_one_merge_target ('uninstall', @uninstall);
3845 &do_one_merge_target ('all', @all);
3847 # Generate the new 'install-strip' target. We can't just set
3848 # INSTALL_PROGRAM because that might be a relative path.
3849 $output_rules .= ("install-strip:\n\t"
3850 . '$(MAKE) $(AM_MAKEFLAGS) INSTALL_STRIP_FLAG=-s install'
3852 push (@phony, 'install-strip');
3855 # Helper for handle_merge_targets. Note that handle_merge_targets
3856 # relies on the fact that this doesn't add an extra \n at the end.
3857 sub do_one_merge_target
3859 local ($name, @values) = @_;
3861 if (&target_defined ($name . '-local'))
3863 # User defined local form of target. So include it.
3864 push (@values, $name . '-local');
3865 push (@phony, $name . '-local');
3868 &pretty_print_rule ($name . "-am:", "\t\t", @values);
3869 if ($name eq 'install')
3871 # Special-case `install-am' to run install-exec-am and
3872 # install-data-am after all-am is built.
3873 &pretty_print_rule ("\t\@\$(MAKE) \$(AM_MAKEFLAGS)", "\t ",
3874 'install-exec-am', 'install-data-am');
3876 elsif ($name eq 'install-exec' && &target_defined ('install-exec-hook'))
3878 $output_rules .= ("\t\@\$(NORMAL_INSTALL)\n"
3879 . "\t" . '$(MAKE) $(AM_MAKEFLAGS) install-exec-hook'
3882 elsif ($name eq 'install-data' && &target_defined ('install-data-hook'))
3884 $output_rules .= ("\t\@\$(NORMAL_INSTALL)\n"
3885 . "\t" . '$(MAKE) $(AM_MAKEFLAGS) install-data-hook'
3889 local ($lname) = $name . ($recursive_install ? '-recursive' : '-am');
3890 local ($tname) = $name;
3891 # To understand this special case, see handle_merge_targets.
3894 $tname = 'all-redirect';
3895 $lname = $all_target if $recursive_install;
3896 push (@phony, 'all-redirect');
3897 $output_all = "all: all-redirect\n";
3899 &pretty_print_rule ($tname . ":", "\t\t", $lname);
3900 push (@phony, $name . '-am', $name);
3903 # Handle check merge target specially.
3904 sub do_check_merge_target
3906 if (&target_defined ('check-local'))
3908 # User defined local form of target. So include it.
3909 push (@check_tests, 'check-local');
3910 push (@phony, 'check-local');
3913 # In --cygnus mode, check doesn't depend on all.
3916 # Just run the local check rules.
3917 &pretty_print_rule ('check-am:', "\t\t", @check);
3921 # The check target must depend on the local equivalent of
3922 # `all', to ensure all the primary targets are built. Then it
3923 # must build the local check rules.
3924 $output_rules .= "check-am: all-am\n";
3925 &pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ",
3929 &pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ",
3933 push (@phony, 'check', 'check-am');
3934 $output_rules .= ("check: "
3935 . ($recursive_install ? 'check-recursive' : 'check-am')
3939 # Handle all 'clean' targets.
3942 local ($xform) = '';
3945 # Don't include `MAINTAINER'; it is handled specially below.
3946 foreach $name ('MOSTLY', '', 'DIST')
3948 if (! &variable_defined ($name . 'CLEANFILES'))
3950 $xform .= 's/^' . $name . 'CLEAN.*$//;';
3954 $xform .= 's/^' . $name . 'CLEAN//;';
3958 # Built sources are automatically removed by maintainer-clean.
3959 push (@maintainer_clean_files, '\$(BUILT_SOURCES)')
3960 if &variable_defined ('BUILT_SOURCES');
3961 push (@maintainer_clean_files, '\$(MAINTAINERCLEANFILES)')
3962 if &variable_defined ('MAINTAINERCLEANFILES');
3963 if (! @maintainer_clean_files)
3965 $xform .= 's/^MAINTAINERCLEAN.*$//;';
3969 $xform .= ('s/^MAINTAINERCLEAN//;'
3970 # Join with no space to avoid spurious `test -z'
3971 # success at runtime.
3972 . 's,\@MCFILES\@,' . join ('', @maintainer_clean_files)
3974 # A space is required in the join here.
3975 . 's,\@MFILES\@,' . join (' ', @maintainer_clean_files)
3979 $output_rules .= &file_contents_with_transform ($xform, 'clean');
3981 push (@clean, 'generic');
3982 &push_phony_cleaners ('generic');
3984 &do_one_clean_target ('clean', 'mostly', '', @clean);
3985 &do_one_clean_target ('clean', '', 'mostly', @clean);
3986 &do_one_clean_target ('clean', 'dist', '', @clean);
3987 &do_one_clean_target ('clean', 'maintainer-', 'dist', @clean);
3989 push (@phony, 'clean', 'mostlyclean', 'distclean', 'maintainer-clean');
3992 # Helper for handle_clean.
3993 sub do_one_clean_target
3995 local ($target, $name, $last_name, @deps) = @_;
3997 # Change each dependency `BLARG' into `clean-BLARG'.
3998 grep (($_ = $name . 'clean-' . $_) && 0, @deps);
4000 # Push the previous clean target. There is no previous clean
4001 # target if we're doing mostlyclean.
4002 push (@deps, $last_name . $target . '-am')
4003 unless $name eq 'mostly';
4005 # If a -local version of the rule is given, add it to the list.
4006 if (&target_defined ($name . $target . '-local'))
4008 push (@deps, $name . $target . '-local');
4011 # Print the target and the dependencies.
4012 &pretty_print_rule ($name . $target . "-am: ", "\t\t", @deps);
4014 # FIXME: shouldn't we really print these messages before running
4016 if ($name . $target eq 'maintainer-clean')
4018 # Print a special warning.
4020 ("\t\@echo \"This command is intended for maintainers to use;\"\n"
4021 . "\t\@echo \"it deletes files that may require special "
4022 . "tools to rebuild.\"\n");
4024 elsif ($name . $target eq 'distclean')
4026 $output_rules .= "\t-rm -f libtool\n" if $seen_libtool;
4028 $output_rules .= "\n";
4030 # Now generate the actual clean target.
4031 $output_rules .= ($name . $target . ": " . $name . $target
4032 . ($recursive_install ? '-recursive' : '-am')
4035 # We special-case config.status here. If we do it as part of the
4036 # normal clean processing for this directory, then it might be
4037 # removed before some subdir is cleaned. However, that subdir's
4038 # Makefile depends on config.status.
4039 if (($name . $target eq 'maintainer-clean'
4040 || $name . $target eq 'distclean')
4041 && $relative_dir eq '.')
4043 $output_rules .= "\t-rm -f config.status\n";
4045 $output_rules .= "\n";
4048 # Handle .PHONY target.
4051 &pretty_print_rule ('.PHONY:', "", @phony);
4052 $output_rules .= "\n";
4055 # Handle TESTS variable and other checks.
4058 if (defined $options{'dejagnu'})
4060 push (@check_tests, 'check-DEJAGNU');
4061 push (@phony, 'check-DEJAGNU');
4066 $xform = 's/^CYGNUS//;';
4070 $xform = 's/^CYGNUS.*$//;';
4072 $output_rules .= &file_contents_with_transform ($xform, 'dejagnu');
4074 # In Cygnus mode, these are found in the build tree.
4075 # Otherwise they are looked for in $PATH.
4076 &define_program_variable ('EXPECT', 'build', 'expect', 'expect');
4077 &define_program_variable ('RUNTEST', 'src', 'dejagnu', 'runtest');
4079 # Only create site.exp rule if user hasn't already written
4081 if (! &target_defined ('site.exp'))
4083 # Note that in the rule we don't directly generate
4084 # site.exp to avoid the possibility of a corrupted
4085 # site.exp if make is interrupted. Jim Meyering has some
4086 # useful text on this topic.
4087 $output_rules .= ("site.exp: Makefile\n"
4088 . "\t\@echo 'Making a new site.exp file...'\n"
4089 . "\t\@test ! -f site.bak || rm -f site.bak\n"
4090 . "\t\@echo '## these variables are automatically generated by make ##' > \$\@-t\n"
4091 . "\t\@echo '# Do not edit here. If you wish to override these values' >> \$\@-t\n"
4092 . "\t\@echo '# edit the last section' >> \$\@-t\n"
4093 . "\t\@echo 'set tool \$(DEJATOOL)' >> \$\@-t\n"
4094 . "\t\@echo 'set srcdir \$(srcdir)' >> \$\@-t\n"
4095 . "\t\@echo 'set objdir' \`pwd\` >> \$\@-t\n");
4097 # Extra stuff for AC_CANONICAL_*
4098 local (@whatlist) = ();
4099 if ($seen_canonical)
4101 push (@whatlist, 'host');
4104 # Extra stuff only for AC_CANONICAL_SYSTEM.
4105 if ($seen_canonical == $AC_CANONICAL_SYSTEM)
4107 push (@whatlist, 'target', 'build');
4111 foreach $c1 (@whatlist)
4113 foreach $c2 ('alias', 'triplet')
4115 $output_rules .= "\t\@echo 'set ${c1}_${c2} \$(${c1}_${c2})' >> \$\@-t\n";
4119 $output_rules .= ("\t\@echo '## All variables above are generated by configure. Do Not Edit ##' >> \$\@-t\n"
4120 . "\t\@test ! -f site.exp || sed '1,/^## All variables above are.*##/ d' site.exp >> \$\@-t\n"
4121 . "\t\@test ! -f site.exp || mv site.exp site.bak\n"
4122 . "\t\@mv \$\@-t site.exp\n");
4128 foreach $c ('DEJATOOL', 'RUNTEST', 'RUNTESTFLAGS')
4130 if (&variable_defined ($c))
4132 &am_line_error ($c, "\`$c' defined but \`dejagnu' not in \`AUTOMAKE_OPTIONS'");
4137 if (&variable_defined ('TESTS'))
4139 push (@check_tests, 'check-TESTS');
4140 push (@phony, 'check-TESTS');
4142 # Note: Solaris 2.7 seems to expand TESTS using VPATH. That's
4143 # why we also try `dir='
4144 $output_rules .= 'check-TESTS: $(TESTS)
4145 @failed=0; all=0; xfail=0; xpass=0; \\
4146 srcdir=$(srcdir); export srcdir; \\
4147 list=' . "'\$(TESTS)'; \\" . '
4148 if test -n "$$list"; then \\
4149 for tst in $$list; do \\
4150 if test -f ./$$tst; then dir=./; \\
4151 elif test -f $$tst; then dir=; \\
4152 else dir="$(srcdir)/"; fi; \\
4153 if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \\
4154 all=`expr $$all + 1`; \\
4155 case " $(XFAIL_TESTS) " in \\
4157 xpass=`expr $$xpass + 1`; \\
4158 failed=`expr $$failed + 1`; \\
4159 echo "XPASS: $$tst"; \\
4162 echo "PASS: $$tst"; \\
4165 elif test $$? -ne 77; then \\
4166 all=`expr $$all + 1`; \\
4167 case " $(XFAIL_TESTS) " in \\
4169 xfail=`expr $$xfail + 1`; \\
4170 echo "XFAIL: $$tst"; \\
4173 failed=`expr $$failed + 1`; \\
4174 echo "FAIL: $$tst"; \\
4179 if test "$$failed" -eq 0; then \\
4180 if test "$$xfail" -eq 0; then \\
4181 banner="All $$all tests passed"; \\
4183 banner="All $$all tests behaved as expected ($$xfail expected failures)"; \\
4186 if test "$$xpass" -eq 0; then \\
4187 banner="$$failed of $$all tests failed"; \\
4189 banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \\
4192 dashes=`echo "$$banner" | sed s/./=/g`; \\
4196 test "$$failed" -eq 0; \\
4202 # Handle Emacs Lisp.
4203 sub handle_emacs_lisp
4205 local (@elfiles) = &am_install_var ('-candist', 'lisp', 'LISP',
4211 &define_configure_variable ('lispdir');
4212 &define_configure_variable ('EMACS');
4213 $output_rules .= (".el.elc:\n"
4214 . "\t\@echo 'WARNING: Warnings can be ignored. :-)'\n"
4215 . "\tif test \$(EMACS) != no; then \\\n"
4216 . "\t EMACS=\$(EMACS) \$(SHELL) \$(srcdir)/elisp-comp \$<; \\\n"
4218 push (@suffixes, '.el', '.elc');
4220 # Generate .elc files.
4221 grep ($_ .= 'c', @elfiles);
4222 &define_pretty_variable ('ELCFILES', '', @elfiles);
4224 $output_rules .= &file_contents ('lisp-clean');
4225 push (@clean, 'lisp');
4226 &push_phony_cleaners ('lisp');
4228 push (@all, '$(ELCFILES)');
4231 if (&variable_defined ('lisp_LISP'))
4233 $varname = 'lisp_LISP';
4234 &am_error ("\`lisp_LISP' defined but \`AM_PATH_LISPDIR' not in \`$configure_ac'")
4239 $varname = 'noinst_LISP';
4242 &require_file_with_line ($varname, $FOREIGN, 'elisp-comp');
4249 local (@pyfiles) = &am_install_var ('-defaultdist', 'python', 'PYTHON',
4250 'python', 'noinst');
4251 return if ! @pyfiles;
4253 # Found some python.
4254 &define_configure_variable ('pythondir');
4255 &define_configure_variable ('PYTHON');
4257 $output_rules .= &file_contents ('python-clean');
4258 push (@clean, 'python');
4260 &am_error ("\`python_PYTHON' defined but \`AM_CHECK_PYTHON' not in \`$configure_ac'")
4261 if ! $seen_pythondir && &variable_defined ('python_PYTHON');
4263 if ($config_aux_dir eq '.' || $config_aux_dir eq '')
4265 &define_variable ('py_compile', '$(top_srcdir)/py-compile');
4269 &define_variable ('py_compile', $config_aux_dir . '/py-compile');
4276 local (@sourcelist) = &am_install_var ('-candist', '-clean',
4278 'java', 'noinst', 'check');
4279 return if ! @sourcelist;
4281 &define_variable ('JAVAC', 'javac');
4282 &define_variable ('JAVACFLAGS', '');
4283 &define_variable ('CLASSPATH_ENV',
4284 'CLASSPATH=$(JAVAROOT):$(srcdir)/$(JAVAROOT):$$CLASSPATH');
4285 &define_variable ('JAVAROOT', '$(top_builddir)');
4287 local (%valid) = &am_primary_prefixes ('JAVA', 1,
4288 'java', 'noinst', 'check');
4290 local ($dir, $curs);
4291 foreach $curs (keys %valid)
4293 if (! &variable_defined ($curs . '_JAVA') || $curs eq 'EXTRA')
4300 &am_line_error ($curs . '_JAVA',
4301 "multiple _JAVA primaries in use");
4306 $output_rules .= ('class' . $dir . '.stamp: $(' . $dir . '_JAVA)' . "\n"
4307 . "\t" . '$(CLASSPATH_ENV) $(JAVAC) -d $(JAVAROOT) '
4308 . '$(JAVACFLAGS) $?' . "\n"
4309 . "\t" . 'echo timestamp > class' . $dir . '.stamp'
4311 push (@all, 'class' . $dir . '.stamp');
4312 &push_dist_common ('$(' . $dir . '_JAVA)');
4315 # Handle some of the minor options.
4316 sub handle_minor_options
4318 if (defined $options{'readme-alpha'})
4320 if ($relative_dir eq '.')
4322 if ($package_version !~ /^$GNITS_VERSION_PATTERN$/)
4324 # FIXME: allow real filename.
4325 &am_conf_line_error ($configure_ac,
4326 $package_version_line,
4327 "version \`$package_version' doesn't follow Gnits standards");
4329 elsif (defined $1 && -f 'README-alpha')
4331 # This means we have an alpha release. See
4332 # GNITS_VERSION_PATTERN for details.
4333 &require_file ($FOREIGN, 'README-alpha');
4339 ################################################################
4341 # &scan_one_autoconf_file ($FILENAME)
4342 # -----------------------------------
4343 # Scan one file for interesting things. Subroutine of
4344 # &scan_autoconf_files.
4345 sub scan_one_autoconf_file
4347 local ($filename) = @_;
4350 open (CONFIGURE, $filename)
4351 || die "automake: couldn't open \`$filename': $!\n";
4352 print "automake: reading $filename\n" if $verbose;
4356 # Remove comments from current line.
4360 # Skip macro definitions. Otherwise we might be confused into
4361 # thinking that a macro that was only defined was actually
4365 # Follow includes. This is a weirdness commonly in use at
4366 # Cygnus and hopefully nowhere else.
4367 if (/sinclude\((.*)\)/ && -f $1)
4369 &scan_one_autoconf_file ($1);
4372 # Populate libobjs array.
4373 if (/AC_FUNC_ALLOCA/)
4375 $libsources{'alloca.c'} = 1;
4377 elsif (/AC_FUNC_GETLOADAVG/)
4379 $libsources{'getloadavg.c'} = 1;
4381 elsif (/AC_FUNC_MEMCMP/)
4383 $libsources{'memcmp.c'} = 1;
4385 elsif (/AC_STRUCT_ST_BLOCKS/)
4387 $libsources{'fileblocks.c'} = 1;
4389 elsif (/A[CM]_REPLACE_GNU_GETOPT/)
4391 $libsources{'getopt.c'} = 1;
4392 $libsources{'getopt1.c'} = 1;
4394 elsif (/AM_FUNC_STRTOD/)
4396 $libsources{'strtod.c'} = 1;
4398 elsif (/AM_WITH_REGEX/)
4400 $libsources{'rx.c'} = 1;
4401 $libsources{'rx.h'} = 1;
4402 $libsources{'regex.c'} = 1;
4403 $libsources{'regex.h'} = 1;
4404 $omit_dependencies{'rx.h'} = 1;
4405 $omit_dependencies{'regex.h'} = 1;
4407 elsif (/AC_FUNC_MKTIME/)
4409 $libsources{'mktime.c'} = 1;
4411 elsif (/AM_FUNC_ERROR_AT_LINE/)
4413 $libsources{'error.c'} = 1;
4414 $libsources{'error.h'} = 1;
4416 elsif (/AM_FUNC_OBSTACK/)
4418 $libsources{'obstack.c'} = 1;
4419 $libsources{'obstack.h'} = 1;
4421 elsif (/LIBOBJS="(.*)\s+\$LIBOBJS"/
4422 || /LIBOBJS="\$LIBOBJS\s+(.*)"/)
4424 foreach $libobj_iter (split (' ', $1))
4426 if ($libobj_iter =~ /^(.*)\.o(bj)?$/
4427 || $libobj_iter =~ /^(.*)\.\$ac_objext$/
4428 || $libobj_iter =~ /^(.*)\.\$\{ac_objext\}$/)
4430 $libsources{$1 . '.c'} = 1;
4434 elsif (/AC_LIBOBJ\(([^)]+)\)/)
4436 $libsources{"$1.c"} = 1;
4439 if (! $in_ac_replace && s/AC_REPLACE_FUNCS\s*\(\[?//)
4445 $in_ac_replace = 0 if s/[\]\)].*$//;
4446 # Remove trailing backslash.
4450 # Need to skip empty elements for Perl 4.
4452 $libsources{$_ . '.c'} = 1;
4456 if (/$obsolete_rx/o)
4459 if ($obsolete_macros{$1} ne '')
4461 $hint = '; ' . $obsolete_macros{$1};
4463 &am_conf_line_error ($filename, $., "\`$1' is obsolete$hint");
4466 # Process the AC_OUTPUT and AC_CONFIG_FILES macros.
4467 if (! $in_ac_output && s/AC_(OUTPUT|CONFIG_FILES)\s*\(\[?//)
4470 $ac_output_line = $.;
4474 local ($closing) = 0;
4481 # Look at potential Makefile.am's.
4484 # Must skip empty string for Perl 4.
4485 next if $_ eq "\\" || $_ eq '';
4487 # Handle $local:$input syntax. Note that we ignore
4488 # every input file past the first, though we keep
4489 # those around for later.
4490 local ($local, $input, @rest) = split (/:/);
4497 # FIXME: should be error if .in is missing.
4498 $input =~ s/\.in$//;
4501 if (-f $input . '.am')
4503 # We have a file that automake should generate.
4504 push (@make_input_list, $input);
4505 $make_list{$input} = join (':', ($local, @rest));
4509 # We have a file that automake should cause to be
4510 # rebuilt, but shouldn't generate itself.
4511 push (@other_input_files, $_);
4515 if ($closing && @make_input_list == 0 && @other_input_files == 0)
4517 &am_conf_line_error ($filename, $ac_output_line,
4518 "No files mentioned in \`AC_OUTPUT'");
4523 if (/$AC_CONFIG_AUX_DIR_PATTERN/o)
4525 @config_aux_path = $1;
4528 # Check for ansi2knr.
4529 $am_c_prototypes = 1 if /AM_C_PROTOTYPES/;
4531 # Check for exe extension stuff.
4535 $configure_vars{'EXEEXT'} = $filename . ':' . $.;
4541 $configure_vars{'OBJEXT'} = $filename . ':' . $.;
4544 # Check for `-c -o' code.
4545 $seen_cc_c_o = 1 if /AM_PROG_CC_C_O/;
4547 # Check for NLS support.
4548 if (/AM_GNU_GETTEXT/)
4551 $ac_gettext_line = $.;
4552 $omit_dependencies{'libintl.h'} = 1;
4555 # Look for ALL_LINGUAS.
4556 if (/ALL_LINGUAS="(.*)"$/ || /ALL_LINGUAS=(.*)$/)
4560 $all_linguas_line = $.;
4563 # Handle configuration headers. A config header of `[$1]'
4564 # means we are actually scanning AM_CONFIG_HEADER from
4566 if (/A([CM])_CONFIG_HEADERS?\s*\((.*)\)/
4570 ($filename, $., "\`automake requires \`AM_CONFIG_HEADER', not \`AC_CONFIG_HEADER'")
4573 $config_header_line = $.;
4575 foreach $one_hdr (split (' ', $2))
4577 push (@config_fullnames, $one_hdr);
4578 if ($one_hdr =~ /^([^:]+):(.+)$/)
4580 push (@config_names, $1);
4581 push (@config_headers, $2);
4585 push (@config_names, $one_hdr);
4586 push (@config_headers, $one_hdr . '.in');
4591 # Handle AC_CANONICAL_*. Always allow upgrading to
4592 # AC_CANONICAL_SYSTEM, but never downgrading.
4593 $seen_canonical = $AC_CANONICAL_HOST
4594 if ! $seen_canonical
4595 && (/AC_CANONICAL_HOST/ || /AC_CHECK_TOOL/);
4596 $seen_canonical = $AC_CANONICAL_SYSTEM if /AC_CANONICAL_SYSTEM/;
4598 $seen_path_xtra = 1 if /AC_PATH_XTRA/;
4600 # This macro handles several different things.
4601 if (/$AM_INIT_AUTOMAKE_PATTERN/o)
4605 $seen_prog_install = 1;
4606 ($package_version = $1) =~ s/$AM_PACKAGE_VERSION_PATTERN/$1/o;
4607 $package_version_line = $.;
4608 $seen_init_automake = 1;
4611 # Some things required by Automake.
4612 $seen_make_set = 1 if /AC_PROG_MAKE_SET/;
4613 $seen_arg_prog = 1 if /AC_ARG_PROGRAM/;
4617 $configure_vars{'LEX'} = $filename . ':' . $.;
4618 $seen_decl_yytext = 1;
4620 if (/AC_DECL_YYTEXT/ && $filename =~ /configure\.in$/)
4622 &am_conf_line_warning ($filename, $., "\`AC_DECL_YYTEXT' is covered by \`AM_PROG_LEX'");
4624 if (/AC_PROG_LEX/ && $filename =~ /configure\.in$/)
4626 &am_conf_line_warning ($filename, $., "automake requires \`AM_PROG_LEX', not \`AC_PROG_LEX'");
4629 if (/AC_PROG_(F77|YACC|RANLIB|CC|CXXCPP|CXX|LEX|AWK|CPP|LN_S)/)
4631 $configure_vars{$1} = $filename . ':' . $.;
4633 if (/$AC_CHECK_PATTERN/o)
4635 $configure_vars{$3} = $filename . ':' . $.;
4637 if (/$AM_MISSING_PATTERN/o
4641 && $1 ne 'AUTOHEADER')
4643 $configure_vars{$1} = $filename . ':' . $.;
4646 # Explicitly avoid ANSI2KNR -- we AC_SUBST that in protos.m4,
4647 # but later define it elsewhere. This is pretty hacky. We
4648 # also explicitly avoid INSTALL_SCRIPT and some other
4649 # variables because they are defined in header-vars.am.
4651 if (/$AC_SUBST_PATTERN/o
4653 && $1 ne 'INSTALL_SCRIPT'
4654 && $1 ne 'INSTALL_DATA')
4656 $configure_vars{$1} = $filename . ':' . $.;
4659 $seen_decl_yytext = 1 if /AC_DECL_YYTEXT/;
4660 if (/AM_MAINTAINER_MODE/)
4662 $seen_maint_mode = 1;
4663 $configure_cond{'MAINTAINER_MODE'} = 1;
4666 $seen_prog_install = 1 if /AC_PROG_INSTALL/;
4667 $seen_lispdir = 1 if /AM_PATH_LISPDIR/;
4668 $seen_pythondir = 1 if /AM_PATH_PYTHON/;
4670 if (/A(C|M)_PROG_LIBTOOL/)
4672 if (/AM_PROG_LIBTOOL/)
4674 &am_conf_line_warning ($filename, $., "\`AM_PROG_LIBTOOL' is obsolete, use \`AC_PROG_LIBTOOL' instead");
4678 $configure_vars{'LIBTOOL'} = $filename . ':' . $.;
4679 $configure_vars{'RANLIB'} = $filename . ':' . $.;
4680 $configure_vars{'CC'} = $filename . ':' . $.;
4681 # AC_PROG_LIBTOOL runs AC_CANONICAL_HOST. Make sure we
4682 # never downgrade (if we've seen AC_CANONICAL_SYSTEM).
4683 $seen_canonical = $AC_CANONICAL_HOST if ! $seen_canonical;
4686 $seen_multilib = 1 if (/AM_ENABLE_MULTILIB/);
4688 if (/$AM_CONDITIONAL_PATTERN/o)
4690 $configure_cond{$1} = 1;
4693 # Check for Fortran 77 intrinsic and run-time libraries.
4694 if (/AC_F77_LIBRARY_LDFLAGS/)
4696 $configure_vars{'FLIBS'} = $filename . ':' . $.;
4703 # &scan_autoconf_files ()
4704 # -----------------------
4705 # Check whether we use `configure.ac' or `configure.in'.
4706 # Scan it (and possibly `aclocal.m4') for interesting things.
4707 # We must scan aclocal.m4 because there might be AC_SUBSTs and such there.
4708 sub scan_autoconf_files
4710 # Reinitialize libsources here. This isn't really necessary,
4711 # since we currently assume there is only one configure.ac. But
4712 # that won't always be the case.
4715 local ($in_ac_output, $in_ac_replace) = (0, 0);
4716 local (%make_list, @make_input_list);
4717 local ($libobj_iter);
4719 warn "automake: both \`configure.ac' and \`configure.in' present:"
4720 . " ignoring \`configure.in'\n"
4721 if -f 'configure.ac' && -f 'configure.in';
4722 $configure_ac = 'configure.in'
4723 if -f 'configure.in';
4724 $configure_ac = 'configure.ac'
4725 if -f 'configure.ac';
4726 die "automake: \`configure.ac' or \`configure.in' is required\n"
4729 &scan_one_autoconf_file ($configure_ac);
4730 &scan_one_autoconf_file ('aclocal.m4')
4733 # Set input and output files if not specified by user.
4736 @input_files = @make_input_list;
4737 %output_files = %make_list;
4740 @configure_input_files = @make_input_list;
4742 &am_conf_error ("\`AM_INIT_AUTOMAKE' must be used")
4743 if ! $seen_init_automake;
4745 # Always require AC_PROG_MAKE_SET. We might randomly use $(MAKE)
4746 # for our own reasons.
4747 &am_conf_error ("\`AC_PROG_MAKE_SET' must be used")
4748 if ! $seen_make_set;
4750 # Look for some files we need. Always check for these. This
4751 # check must be done for every run, even those where we are only
4752 # looking at a subdir Makefile. We must set relative_dir so that
4753 # the file-finding machinery works.
4754 local ($relative_dir) = '.';
4755 &require_config_file ($FOREIGN, 'install-sh', 'mkinstalldirs', 'missing');
4756 &am_error ("\`install.sh' is an anachronism; use \`install-sh' instead")
4757 if -f $config_aux_path[0] . '/install.sh';
4759 &require_config_file ($FOREIGN, 'py-compile')
4762 # Preserve dist_common for later.
4763 %configure_dist_common = %dist_common;
4766 ################################################################
4768 # Set up for Cygnus mode.
4771 return unless $cygnus_mode;
4773 &set_strictness ('foreign');
4774 $options{'no-installinfo'} = 1;
4775 $options{'no-dependencies'} = 1;
4776 $use_dependencies = 0;
4778 if (! $seen_maint_mode)
4780 &am_conf_error ("\`AM_MAINTAINER_MODE' required when --cygnus specified");
4785 &am_conf_error ("\`AC_EXEEXT' required when --cygnus specified");
4789 # Do any extra checking for GNU standards.
4790 sub check_gnu_standards
4792 if ($relative_dir eq '.')
4794 # In top level (or only) directory.
4795 &require_file ($GNU, 'INSTALL', 'NEWS', 'README', 'COPYING',
4796 'AUTHORS', 'ChangeLog');
4799 if ($strictness >= $GNU)
4801 if (defined $options{'no-installman'})
4803 &am_line_error ('AUTOMAKE_OPTIONS',
4804 "option \`no-installman' disallowed by GNU standards");
4807 if (defined $options{'no-installinfo'})
4809 &am_line_error ('AUTOMAKE_OPTIONS',
4810 "option \`no-installinfo' disallowed by GNU standards");
4815 # Do any extra checking for GNITS standards.
4816 sub check_gnits_standards
4818 if ($relative_dir eq '.')
4820 # In top level (or only) directory.
4821 &require_file ($GNITS, 'THANKS');
4825 ################################################################
4827 # Functions to handle files of each language.
4829 # Each `lang_X_rewrite' function follows a simple formula:
4830 # * Args are the directory, base name and extension of the file.
4831 # * Return value is 1 if file is to be dealt with, 0 otherwise.
4832 # Much of the actual processing is handled in handle_single_transform_list.
4833 # These functions exist so that auxiliary information can be recorded
4834 # for a later cleanup pass. Note that the calls to these functions
4835 # are computed, so don't bother searching for their precise names
4838 # This is just a convenience function that can be used to determine
4839 # when a subdir object should be used.
4842 return defined $options{'subdir-objects'} ? $LANG_SUBDIR : $LANG_PROCESS;
4845 # Rewrite a single C source file.
4848 local ($directory, $base, $ext) = @_;
4850 if (defined $options{'ansi2knr'} && $base =~ /_$/)
4852 # FIXME: include line number in error.
4853 &am_error ("C source file \`$base.c' would be deleted by ansi2knr rules");
4856 local ($r) = $LANG_PROCESS;
4857 if (defined $options{'subdir-objects'})
4860 $base = $directory . '/' . $base;
4864 # Only give error once.
4866 # FIXME: line number.
4867 &am_error ("C objects in subdir but \`AM_PROG_CC_C_O' not in \`$configure_ac'");
4870 &require_file ($FOREIGN, 'compile')
4871 if $relative_dir eq '.';
4874 $de_ansi_files{$base} = 1;
4878 # Rewrite a single C++ source file.
4879 sub lang_cxx_rewrite
4881 return &lang_sub_obj;
4884 # Rewrite a single header file.
4885 sub lang_header_rewrite
4887 # Header files are simply ignored.
4888 return $LANG_IGNORE;
4891 # Rewrite a single yacc file.
4892 sub lang_yacc_rewrite
4894 local ($directory, $base, $ext) = @_;
4896 local ($r) = &lang_c_rewrite ($directory, $base, $ext);
4898 if ($r == $LANG_SUBDIR)
4900 $pfx = $directory . '/';
4902 $yacc_sources{$pfx . $base . '.' . $ext} = 1;
4904 &saw_extension ('c');
4906 &push_dist_common ($pfx . $base . '.' . $ext);
4910 # Rewrite a single yacc++ file.
4911 sub lang_yaccxx_rewrite
4913 local ($directory, $base, $ext) = @_;
4915 local ($r) = $LANG_PROCESS;
4917 if (defined $options{'subdir-objects'})
4919 $pfx = $directory . '/';
4922 $yacc_sources{$pfx . $base . '.' . $ext} = 1;
4924 &saw_extension ($ext);
4926 &push_dist_common ($pfx . $base . '.' . $ext);
4930 # Rewrite a single lex file.
4931 sub lang_lex_rewrite
4933 local ($directory, $base, $ext) = @_;
4935 local ($r) = &lang_c_rewrite ($directory, $base, $ext);
4937 if ($r == $LANG_SUBDIR)
4939 $pfx = $directory . '/';
4941 $lex_sources{$pfx . $base . '.' . $ext} = 1;
4943 &saw_extension ('c');
4945 &push_dist_common ($pfx . $base . '.' . $ext);
4949 # Rewrite a single lex++ file.
4950 sub lang_lexxx_rewrite
4952 local ($directory, $base, $ext) = @_;
4954 local ($r) = $LANG_PROCESS;
4956 if (defined $options{'subdir-objects'})
4958 $pfx = $directory . '/';
4961 $lex_sources{$pfx . $base . '.' . $ext} = 1;
4963 &saw_extension ($ext);
4965 &push_dist_common ($pfx . $base . '.' . $ext);
4969 # Rewrite a single assembly file.
4970 sub lang_asm_rewrite
4972 return &lang_sub_obj;
4975 # Rewrite a single Fortran 77 file.
4976 sub lang_f77_rewrite
4978 return $LANG_PROCESS;
4981 # Rewrite a single preprocessed Fortran 77 file.
4982 sub lang_ppf77_rewrite
4984 return $LANG_PROCESS;
4987 # Rewrite a single ratfor file.
4988 sub lang_ratfor_rewrite
4990 return $LANG_PROCESS;
4993 # Rewrite a single Objective C file.
4994 sub lang_objc_rewrite
4996 return &lang_sub_obj;
4999 # Rewrite a single Java file.
5000 sub lang_java_rewrite
5002 return $LANG_SUBDIR;
5005 # The lang_X_finish functions are called after all source file
5006 # processing is done. Each should handle defining rules for the
5007 # language, etc. A finish function is only called if a source file of
5008 # the appropriate type has been seen.
5012 # Push all libobjs files onto de_ansi_files. We actually only
5013 # push files which exist in the current directory, and which are
5014 # genuine source files.
5016 foreach $file (keys %libsources)
5018 if ($file =~ /^(.*)\.[cly]$/ && -f "$relative_dir/$file")
5020 $de_ansi_files{$1} = 1;
5024 if (defined $options{'ansi2knr'} && keys %de_ansi_files)
5026 # Make all _.c files depend on their corresponding .c files.
5027 local ($base, @objects);
5028 foreach $base (sort keys %de_ansi_files)
5030 # Each _.c file must depend on ansi2knr; otherwise it
5031 # might be used in a parallel build before it is built.
5032 # We need to support files in the srcdir and in the build
5033 # dir (because these files might be auto-generated. But
5034 # we can't use $< -- some makes only define $< during a
5036 $output_rules .= ($base . "_.c: $base.c \$(ANSI2KNR)\n\t"
5037 . '$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) '
5038 . '`if test -f $(srcdir)/' . $base . '.c'
5039 . '; then echo $(srcdir)/' . $base . '.c'
5040 . '; else echo ' . $base . '.c; fi` '
5041 . "| sed 's/^# \\([0-9]\\)/#line \\1/' "
5042 . '| $(ANSI2KNR) > ' . $base . "_.c\n");
5043 push (@objects, $base . '_'
5044 . ($seen_objext ? '.$(OBJEXT)' : '.o'));
5045 push (@objects, $base . '_.lo') if $seen_libtool;
5048 # Make all _.o (and _.lo) files depend on ansi2knr.
5049 # Use a sneaky little hack to make it print nicely.
5050 &pretty_print_rule ('', '', @objects, ':', '$(ANSI2KNR)');
5053 if (! defined $configure_vars{'CC'})
5055 # FIXME: line number.
5056 &am_error ("C source seen but \`CC' not defined in \`$configure_ac'");
5062 local ($ltcompile, $ltlink) = &libtool_compiler;
5064 &define_variable ('CXXLD', '$(CXX)');
5065 &define_variable ('CXXLINK', $ltlink . '$(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@');
5067 if (! defined $configure_vars{'CXX'})
5069 &am_error ("C++ source seen but \`CXX' not defined in \`$configure_ac'");
5073 sub lang_header_finish
5078 # This is a helper for both lex and yacc.
5079 sub yacc_lex_finish_helper
5081 return if defined $language_scratch{'lex-yacc-done'};
5082 $language_scratch{'lex-yacc-done'} = 1;
5084 # If there is more than one distinct yacc (resp lex) source file
5085 # in a given directory, then the `ylwrap' program is required to
5086 # allow parallel builds to work correctly. FIXME: for now, no
5088 &require_config_file ($FOREIGN, 'ylwrap');
5089 if ($config_aux_dir ne '.' && $config_aux_dir ne '')
5091 &define_variable ('YLWRAP', $config_aux_dir . "/ylwrap");
5095 &define_variable ('YLWRAP', '$(srcdir)/ylwrap');
5099 sub lang_yacc_finish
5101 return if defined $language_scratch{'yacc-done'};
5102 $language_scratch{'yacc-done'} = 1;
5104 local ($file, $base, $hname, $cname);
5105 local (%seen_suffix) = ();
5106 local (@yacc_files) = sort keys %yacc_sources;
5107 local ($yacc_count) = scalar (@yacc_files);
5108 foreach $file (@yacc_files)
5111 &output_yacc_build_rule ($1, $yacc_count > 1)
5112 if ! defined $seen_suffix{$1};
5113 $seen_suffix{$1} = 1;
5115 $file =~ /^(.*)\.(y|yy|y\+\+|yxx|ypp)$/;
5117 $hname = 'h'; # Always use `.h' for header file.
5118 ($cname = $2) =~ tr/y/c/;
5120 if ((&variable_defined ('AM_YFLAGS')
5121 && &variable_value ('AM_YFLAGS') =~ /(^|\s)-d(\s|$)/)
5122 || (&variable_defined ('YFLAGS')
5123 && &variable_value ('YFLAGS') =~ /(^|\s)-d(\s|$)/)) {
5124 # Now generate rule to make the header file. This should only
5125 # be generated if `yacc -d' specified.
5126 $output_rules .= "${base}.${hname}: ${base}.${cname}\n";
5128 # If the files are built in the build directory, then we want
5129 # to remove them with `make clean'. If they are in srcdir
5130 # they shouldn't be touched. However, we can't determine this
5131 # statically, and the GNU rules say that yacc/lex output files
5132 # should be removed by maintainer-clean. So that's what we
5134 push (@maintainer_clean_files, "${base}.${hname}");
5136 &push_dist_common ("${base}.${hname}");
5138 push (@maintainer_clean_files, "${base}.${cname}");
5140 $output_rules .= "\n";
5142 if (! defined $configure_vars{'YACC'})
5144 &am_error ("yacc source seen but \`YACC' not defined in \`$configure_ac'");
5146 if (&variable_defined ('YACCFLAGS'))
5148 &am_line_error ('YACCFLAGS',
5149 "\`YACCFLAGS' obsolete; use \`YFLAGS' instead");
5152 if ($yacc_count > 1)
5154 &yacc_lex_finish_helper;
5158 sub lang_yaccxx_finish
5165 return if defined $language_scratch{'lex-done'};
5166 $language_scratch{'lex-done'} = 1;
5168 local (%seen_suffix) = ();
5169 local ($file, $cname);
5170 local ($lex_count) = scalar (keys %lex_sources);
5171 foreach $file (sort keys %lex_sources)
5174 &output_lex_build_rule ($1, $lex_count > 1)
5175 if (! defined $seen_suffix{$1});
5176 $seen_suffix{$1} = 1;
5178 # If the files are built in the build directory, then we want
5179 # to remove them with `make clean'. If they are in srcdir
5180 # they shouldn't be touched. However, we can't determine this
5181 # statically, and the GNU rules say that yacc/lex output files
5182 # should be removed by maintainer-clean. So that's what we
5184 $file =~ /^(.*)\.(l|ll|l\+\+|lxx|lpp)$/;
5185 ($cname = $2) =~ tr/l/c/;
5186 push (@maintainer_clean_files, "${1}.${cname}");
5189 if (! defined $configure_vars{'LEX'})
5191 &am_error ("lex source seen but \`LEX' not defined in \`$configure_ac'");
5193 if (! $seen_decl_yytext)
5195 &am_error ("lex source seen but \`AC_DECL_YYTEXT' not in \`$configure_ac'");
5200 &yacc_lex_finish_helper;
5204 sub lang_lexxx_finish
5211 # We need the C code for assembly.
5217 # FIXME: this function can be called more than once. We should
5218 # arrange for it to only do anything the first time through.
5220 local ($ltcompile, $ltlink) = &libtool_compiler;
5222 &define_variable ('F77LD', '$(F77)');
5223 &define_variable ('F77LINK', $ltlink . '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@');
5225 if (! defined $configure_vars{'F77'})
5227 &am_error ("Fortran 77 source seen but \`F77' not defined in \`$configure_ac'");
5231 # Preprocessed Fortran 77
5233 # The current support for preprocessing Fortran 77 just involves passing
5234 # `$(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS)' as additional flags
5235 # to the Fortran 77 compiler, since this is how GNU Make does it; see
5236 # the `GNU Make Manual, Edition 0.51 for `make' Version 3.76 Beta'
5237 # (specifically, from info file `(make)Catalogue of Rules').
5239 # A better approach would be to write an Autoconf test
5240 # (i.e. AC_PROG_FPP) for a Fortran 77 preprocessor, because not all
5241 # Fortran 77 compilers know how to do preprocessing. The Autoconf macro
5242 # AC_PROG_FPP should test the Fortran 77 compiler first for
5243 # preprocessing capabilities, and then fall back on cpp (if cpp were
5245 sub lang_ppf77_finish
5249 # We also handle the case of preprocessing `.F' files into `.f'
5251 $output_rules .= (".F.f:\n"
5252 . "\t\$(F77COMPILE) -F \$<\n");
5255 sub lang_ratfor_finish
5259 # We also handle the case of preprocessing `.r' files into `.f'
5261 $output_rules .= (".r.f:\n"
5262 . "\t\$(RCOMPILE) -F \$<\n");
5265 sub lang_objc_finish
5267 local ($ltcompile, $ltlink) = &libtool_compiler;
5269 &define_variable ('OBJCLD', '$(OBJC)');
5270 &define_variable ('OBJCLINK', $ltlink . '$(OBJCLD) $(AM_OBJCFLAGS) $(OBJCFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@');
5272 if (! defined $configure_vars{'OBJC'})
5274 &am_error ("Objective C source seen but \`OBJC' not defined in \`$configure_ac'");
5278 sub lang_java_finish
5280 local ($ltcompile, $ltlink) = &libtool_compiler;
5282 &define_variable ('GCJLD', '$(GCJ)');
5283 &define_variable ('GCJLINK', $ltlink . '$(GCJLD) $(AM_GCJFLAGS) $(GCJFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@');
5285 if (! defined $configure_vars{'GCJ'})
5287 &am_error ("Java source seen but \`GCJ' not defined in \`$configure_ac'");
5291 # A helper which computes a sorted list of all extensions for LANG.
5296 foreach $key (sort keys %extension_seen)
5298 push (@r, '.' . $key) if $extension_map{$key} eq $lang;
5303 # A helper which decides whether libtool is needed. Returns prefix
5304 # for compiler and linker.
5305 sub libtool_compiler
5307 local ($ltcompile, $ltlink) = ('', '');
5310 &define_configure_variable ("LIBTOOL");
5311 $ltcompile = '$(LIBTOOL) --mode=compile ';
5312 $ltlink = '$(LIBTOOL) --mode=link ';
5314 return ($ltcompile, $ltlink);
5317 # Given a hash table of linker names, pick the name that has the most
5318 # precedence. This is lame, but something has to have global
5319 # knowledge in order to eliminate the conflict. Add more linkers as
5323 local (%linkers) = @_;
5326 if defined $linkers{'GCJLINK'};
5328 if defined $linkers{'CXXLINK'};
5330 if defined $linkers{'F77LINK'};
5332 if defined $linkers{'OBJCLINK'};
5336 # Called to indicate that an extension was used.
5340 $extension_seen{$ext} = 1;
5343 # Called to ask whether source files have been seen . If HEADERS is 1,
5344 # headers can be included.
5347 local ($headers) = @_;
5355 local (@exts) = &lang_extensions ('header');
5359 return scalar keys %extension_seen > $headers;
5362 # Register a single language. LANGUAGE is the name of the language.
5363 # Each OPTION is either of the form NAME=VALUE, or is a file extension
5365 sub register_language
5367 local ($language, @options) = @_;
5370 $language_map{$language . '-ansi-p'} = 0;
5371 $language_map{$language . '-linker'} = '';
5372 $language_map{$language . '-autodep'} = 'no';
5373 $language_map{$language . '-derived-autodep'} = 'no';
5376 foreach $iter (@options)
5378 if ($iter =~ /^(.*)=(.*)$/)
5380 $language_map{$language . '-' . $1} = $2;
5382 elsif (defined $extension_map{$iter})
5385 "automake: programming error: duplicate extension $iter\n";
5390 $extension_map{$iter} = $language;
5395 # This function is used to find a path from a user-specified suffix to
5396 # `o' or to some other suffix we recognize internally, eg `cc'.
5399 local ($source_ext) = @_;
5401 # FIXME: hard-coding `o' is a mistake. Doing something
5402 # intelligent is harder.
5403 while ($extension_map{$source_ext} eq ''
5404 && $source_ext ne 'o'
5405 && defined $suffix_rules{$source_ext})
5407 $source_ext = $suffix_rules{$source_ext};
5414 ################################################################
5416 # Pretty-print something. HEAD is what should be printed at the
5417 # beginning of the first line, FILL is what should be printed at the
5418 # beginning of every subsequent line.
5419 sub pretty_print_internal
5421 local ($head, $fill, @values) = @_;
5423 local ($column) = length ($head);
5424 local ($result) = $head;
5426 # Fill length is number of characters. However, each Tab
5427 # character counts for eight. So we count the number of Tabs and
5429 local ($fill_length) = length ($fill);
5430 $fill_length += 7 * ($fill =~ tr/\t/\t/d);
5432 local ($bol) = ($head eq '');
5435 # "71" because we also print a space.
5436 if ($column + length ($_) > 71)
5438 $result .= " \\\n" . $fill;
5439 $column = $fill_length;
5443 $result .= ' ' unless ($bol);
5445 $column += length ($_) + 1;
5453 # Pretty-print something and append to output_vars.
5456 $output_vars .= &pretty_print_internal (@_);
5459 # Pretty-print something and append to output_rules.
5460 sub pretty_print_rule
5462 $output_rules .= &pretty_print_internal (@_);
5466 ################################################################
5468 # See if a target exists.
5471 local ($target) = @_;
5472 return defined $targets{$target};
5475 # See if two conditionals are the same.
5476 sub conditional_same
5478 local ($cond1, $cond2) = @_;
5480 return (&conditional_true_when ($cond1, $cond2)
5481 && &conditional_true_when ($cond2, $cond1));
5484 # See if a conditional is true. Both arguments are conditional
5485 # strings. This returns true if the first conditional is true when
5486 # the second conditional is true.
5487 sub conditional_true_when
5489 local ($cond, $when) = @_;
5491 # Check the easy case first.
5497 # Check each component of $cond, which looks @COND1@@COND2@.
5498 foreach $comp (split ('@', $cond))
5500 # The way we split will give null strings between each
5504 if (index ($when, '@' . $comp . '@') == -1)
5513 # Check for an ambiguous conditional. This is called when a variable
5514 # or target is being defined conditionally. If we already know about
5515 # a definition that is true under the same conditions, then we have an
5517 sub check_ambiguous_conditional
5519 local ($var_name, $cond) = @_;
5520 local (@cond_vals) = split (' ', $conditional{$var_name});
5523 local ($vcond) = shift (@cond_vals);
5525 if (&conditional_true_when ($vcond, $cond)
5526 || &conditional_true_when ($cond, $vcond))
5528 &am_line_error ($var_name,
5529 "$var_name multiply defined in condition");
5534 # See if a variable exists. The first argument is the variable name,
5535 # and the optional second argument is the condition which we should
5536 # check. If no condition is given, we currently return true if the
5537 # variable is defined under any condition.
5538 sub variable_defined
5540 local ($var, $cond) = @_;
5541 if (defined $targets{$var})
5543 &am_line_error ($var, "\`$var' is target; expected variable");
5546 elsif (defined $contents{$var})
5548 if ($cond && $conditional{$var})
5550 # We have been asked to check for a particular condition,
5551 # and the variable is defined conditionally. We need to
5552 # look through the conditions under which the variable is
5553 # defined, and see if any of them match the conditional we
5554 # have been asked to check.
5555 local (@cond_vars) = split (' ', $conditional{$var});
5558 if (&conditional_same ($cond, shift (@cond_vars)))
5560 # Even a conditional examination is good enough
5561 # for us. FIXME: really should maintain examined
5562 # status on a per-condition basis.
5563 $content_seen{$var} = 1;
5569 # The variable is not defined for the given condition.
5573 $content_seen{$var} = 1;
5579 # Mark a variable as examined.
5580 sub examine_variable
5583 &variable_defined ($var);
5586 # Quote a value in order to put it in $conditional. We need to quote
5587 # spaces, and we need to handle null strings, so that we can later
5588 # retrieve values by splitting on space.
5592 $val =~ tr/ \t\n/\001\003\004/;
5593 $val = "\002" if $val eq '';
5597 # Unquote a value in $conditional.
5598 sub unquote_cond_val
5601 $val =~ tr/\001\003\004/ \t\n/;
5606 # Return the set of conditions for which a variable is defined.
5608 # If the variable is not defined conditionally, and is not defined in
5609 # terms of any variables which are defined conditionally, then this
5610 # returns the empty list.
5612 # If the variable is defined conditionally, but is not defined in
5613 # terms of any variables which are defined conditionally, then this
5614 # returns the list of conditions for which the variable is defined.
5616 # If the variable is defined in terms of any variables which are
5617 # defined conditionally, then this returns a full set of permutations
5618 # of the subvariable conditions. For example, if the variable is
5619 # defined in terms of a variable which is defined for @COND_TRUE@,
5620 # then this returns both @COND_TRUE@ and @COND_FALSE@. This is
5621 # because we will need to define the variable under both conditions.
5623 sub variable_conditions
5631 foreach $cond (&variable_conditions_sub ($var, '', ()))
5633 $uniqify{$cond} = 1;
5636 @uniq_list = sort keys %uniqify;
5637 # Note we cannot just do `return sort keys %uniqify', because this
5638 # function is sometimes used in a scalar context.
5642 # A subroutine of variable_conditions. We only return conditions
5643 # which are true for all the conditions in @PARENT_CONDS.
5644 sub variable_conditions_sub
5646 local ($var, $parent, @parent_conds) = @_;
5647 local (@new_conds) = ();
5649 if (defined $vars_scanned{$var})
5651 &am_line_error ($parent, "variable \`$var' recursively defined");
5654 $vars_scanned{$var} = 1;
5656 if (! $conditional{$var})
5658 foreach (split (' ', $contents{$var}))
5660 # If a comment seen, just leave.
5663 # Handle variable substitutions.
5664 if (/^\$\{(.*)\}$/ || /^\$\((.*)\)$/)
5667 &variable_conditions_sub ($1, $var, @parent_conds));
5671 # Now we want to return all permutations of the subvariable
5673 local (%allconds, $item);
5674 foreach $item (@new_conds)
5676 foreach (split ('@', $item))
5680 $allconds{$_ . '_TRUE'} = 1;
5684 # Unset our entry in vars_scanned. We only care about recursive
5686 delete $vars_scanned{$var};
5688 return &variable_conditions_permutations (sort keys %allconds);
5691 local (@this_conds) = ();
5692 local (@condvals) = split (' ', $conditional{$var});
5695 local ($cond) = shift (@condvals);
5696 local ($val) = &unquote_cond_val (shift (@condvals));
5701 local ($parent_cond);
5702 foreach $parent_cond (@parent_conds)
5704 if (! &conditional_true_when ($parent_cond, $cond))
5714 push (@this_conds, $cond);
5716 push (@parent_conds, $cond);
5717 local (@subvar_conds) = ();
5718 foreach (split (' ', $val))
5720 # If a comment seen, just leave.
5723 # Handle variable substitutions.
5724 if (/^\$\{(.*)\}$/ || /^\$\((.*)\)$/)
5726 push (@subvar_conds,
5727 &variable_conditions_sub ($1, $var, @parent_conds));
5730 pop (@parent_conds);
5732 # If there are no conditional subvariables, then we want to
5733 # return this condition. Otherwise, we want to return the
5734 # permutations of the subvariables.
5735 if (! @subvar_conds)
5737 push (@new_conds, $cond);
5741 push (@new_conds, &variable_conditions_reduce (@subvar_conds));
5745 # Unset our entry in vars_scanned. We only care about recursive
5747 delete $vars_scanned{$var};
5752 # If we are being called on behalf of another variable, we need to
5753 # return all possible permutations of the conditions. We have
5754 # already handled everything in @this_conds along with their
5755 # subvariables. We now need to add any permutations that are not
5758 foreach $this_cond (@this_conds)
5761 &variable_conditions_permutations (split('@', $this_cond));
5763 foreach $perm (@perms)
5767 foreach $scan (@this_conds)
5769 if (&conditional_true_when ($perm, $scan)
5770 || &conditional_true_when ($scan, $perm))
5781 local ($parent_cond);
5782 foreach $parent_cond (@parent_conds)
5784 if (! &conditional_true_when ($parent_cond, $perm))
5794 # This permutation was not already handled, and is valid
5796 push (@new_conds, $perm);
5803 # Subroutine for variable_conditions_sort
5804 sub variable_conditions_cmp
5810 return (length ($as) <=> length ($bs)
5814 # Sort a list of conditionals so that only the exclusive ones are
5815 # retained. For example, if both @COND1_TRUE@@COND2_TRUE@ and
5816 # @COND1_TRUE@ are in the list, discard the latter.
5817 sub variable_conditions_reduce
5819 local (@conds) = @_;
5822 foreach $cond (sort variable_conditions_cmp @conds)
5826 foreach $scan (@ret)
5828 if (&conditional_true_when ($cond, $scan))
5841 # Return a list of permutations of a conditional string.
5842 sub variable_conditions_permutations
5844 local (@comps) = @_;
5847 local ($comp) = shift (@comps);
5848 return &variable_conditions_permutations (@comps)
5850 local ($neg) = $comp;
5851 $neg =~ s/TRUE$/TRUEO/;
5852 $neg =~ s/FALSE$/TRUE/;
5853 $neg =~ s/TRUEO$/FALSE/;
5856 foreach $sub (&variable_conditions_permutations (@comps))
5858 push (@ret, '@' . $comp . '@' . $sub);
5859 push (@ret, '@' . $neg . '@' . $sub);
5863 push (@ret, '@' . $comp . '@');
5864 push (@ret, '@' . $neg . '@');
5869 # Warn if a variable is conditionally defined. This is called if we
5870 # are using the value of a variable.
5871 sub variable_conditionally_defined
5873 local ($var, $parent) = @_;
5874 if ($conditional{$var})
5878 &am_line_error ($parent,
5879 "warning: automake does not support conditional definition of $var in $parent");
5883 &am_line_error ($parent,
5884 "warning: automake does not support $var being defined conditionally")
5889 # Get the value of a variable. This just returns $contents, but warns
5890 # if the variable is conditionally defined.
5894 &variable_conditionally_defined ($var);
5895 return $contents{$var};
5898 # Convert a variable value to a list, split as whitespace. This will
5899 # recursively follow $(...) and ${...} inclusions. It preserves @...@
5900 # substitutions. If COND is 'all', then all values under all
5901 # conditions should be returned; if COND is a particular condition
5902 # (all conditions are surrounded by @...@) then only the value for
5903 # that condition should be returned; otherwise, warn if VAR is
5904 # conditionally defined. SCANNED is a global hash listing whose keys
5905 # are all the variables already scanned; it is an error to rescan a
5909 local ($var, $val, $cond) = @_;
5913 $val =~ s/\\(\n|$)/ /g;
5915 foreach (split (' ', $val))
5917 # If a comment seen, just leave.
5920 # Handle variable substitutions.
5921 if (/^\$\{([^}]*)\}$/ || /^\$\(([^)]*)\)$/)
5923 local ($varname) = $1;
5925 # If the user uses a losing variable name, just ignore it.
5926 # This isn't ideal, but people have requested it.
5927 next if ($varname =~ /\@.*\@/);
5931 if ($varname =~ /^([^:]*):([^=]*)=(.*)$/)
5935 ($from = $2) =~ s/(\W)/\\$1/g;
5939 @temp_list = &variable_value_as_list_worker ($1, $cond, $var);
5941 # Now rewrite the value if appropriate.
5944 grep (s/$from$/$to/, @temp_list);
5947 push (@result, @temp_list);
5958 # Return contents of variable as list, split as whitespace. This will
5959 # recursively follow $(...) and ${...} inclusions. It preserves @...@
5960 # substitutions. If COND is 'all', then all values under all
5961 # conditions should be returned; if COND is a particular condition
5962 # (all conditions are surrounded by @...@) then only the value for
5963 # that condition should be returned; otherwise, warn if VAR is
5964 # conditionally defined. If PARENT is specified, it is the name of
5965 # the including variable; this is only used for error reports.
5966 sub variable_value_as_list_worker
5968 local ($var, $cond, $parent) = @_;
5971 if (defined $targets{$var})
5973 &am_line_error ($var, "\`$var' is target; expected variable");
5975 elsif (! defined $contents{$var})
5977 &am_line_error ($parent, "variable \`$var' not defined");
5979 elsif (defined $vars_scanned{$var})
5981 # `vars_scanned' is a global we use to keep track of which
5982 # variables we've already examined.
5983 &am_line_error ($parent, "variable \`$var' recursively defined");
5985 elsif ($cond eq 'all' && $conditional{$var})
5987 $vars_scanned{$var} = 1;
5988 local (@condvals) = split (' ', $conditional{$var});
5992 local ($val) = &unquote_cond_val (shift (@condvals));
5993 push (@result, &value_to_list ($var, $val, $cond));
5996 elsif ($cond && $conditional{$var})
5998 $vars_scanned{$var} = 1;
5999 local (@condvals) = split (' ', $conditional{$var});
6003 local ($vcond) = shift (@condvals);
6004 local ($val) = &unquote_cond_val (shift (@condvals));
6005 if (&conditional_true_when ($vcond, $cond))
6007 # Warn if we have an ambiguity. It's hard to know how
6008 # to handle this case correctly.
6009 &variable_conditionally_defined ($var, $parent)
6012 push (@result, &value_to_list ($var, $val, $cond));
6018 $vars_scanned{$var} = 1;
6019 &variable_conditionally_defined ($var, $parent);
6020 $content_seen{$var} = 1;
6021 push (@result, &value_to_list ($var, $contents{$var}, $cond));
6024 # Unset our entry in vars_scanned. We only care about recursive
6026 delete $vars_scanned{$var};
6031 # This is just a wrapper for variable_value_as_list_worker that
6032 # initializes the global hash `vars_scanned'. This hash is used to
6033 # avoid infinite recursion.
6034 sub variable_value_as_list
6036 local ($var, $cond, $parent) = @_;
6038 return &variable_value_as_list_worker ($var, $cond, $parent);
6041 # Define a new variable, but only if not already defined.
6044 local ($var, $value) = @_;
6046 if (! defined $contents{$var})
6048 $output_vars .= $var . ' = ' . $value . "\n";
6049 $contents{$var} = $value;
6050 $content_seen{$var} = 1;
6052 elsif ($var_was_plus_eq{$var})
6054 &am_line_error ($var, "internally generated variable \`$var' was set with \`+='");
6058 # Like define_variable, but the value is a list, and the variable may
6059 # be defined conditionally. The second argument is the conditional
6060 # under which the value should be defined; this should be the empty
6061 # string to define the variable unconditionally. The third argument
6062 # is a list holding the values to use for the variable. The value is
6063 # pretty printed in the output file.
6064 sub define_pretty_variable
6066 local ($var, $cond, @value) = @_;
6067 if (! defined $contents{$var}
6068 || ($cond && ! &variable_defined ($var, $cond)))
6070 $contents{$var} = join (' ', @value);
6073 if ($conditional{$var})
6075 $conditional{$var} .= ' ';
6079 $conditional{$var} = '';
6081 $conditional{$var} .= ($cond
6083 . "e_cond_val ($contents{$var}));
6085 &pretty_print ($cond . $var . ' = ', $cond, @value);
6086 $content_seen{$var} = 1;
6090 # Like define_variable, but define a variable to be the configure
6091 # substitution by the same name.
6092 sub define_configure_variable
6095 local ($value) = '@' . $var . '@';
6096 &define_variable ($var, $value);
6099 # Define a compiler variable. We also handle defining the `LT'
6100 # version of the command when using libtool.
6101 sub define_compiler_variable
6103 local ($var, $ltcompile, $value) = @_;
6104 local ($name) = $var;
6105 &define_variable ($name, $value);
6106 &define_variable ('LT' . $name, $ltcompile . $value)
6110 # Define a variable that represents a program to run. If in Cygnus
6111 # mode, the program is searched for in the build (or source) tree.
6112 # Otherwise no searching is done at all. Arguments are:
6113 # * VAR Name of variable to define
6114 # * WHATDIR Either `src' or `build', depending on where program should
6115 # be found. (runtest is in srcdir!)
6116 # * SUBDIR Subdir of top-level dir
6117 # * PROGRAM Name of program
6118 # * OVERRIDE If specified, the name of the program to use when not in
6119 # Cygnus mode. Defaults to PROGRAM.
6120 sub define_program_variable
6122 local ($var, $whatdir, $subdir, $program, $override) = @_;
6126 $override = $program;
6131 local ($full) = ('$(top_' . $whatdir . 'dir)/../'
6132 . $subdir . '/' . $program);
6133 &define_variable ($var, ('`if test -f ' . $full
6134 . '; then echo ' . $full . '; else echo '
6135 . $program . '; fi`'));
6139 &define_variable ($var, $override);
6144 ################################################################
6146 # Read Makefile.am and set up %contents. Simultaneously copy lines
6147 # from Makefile.am into $output_trailer or $output_vars as
6148 # appropriate. NOTE we put rules in the trailer section. We want
6149 # user rules to come after our generated stuff.
6152 local ($amfile) = @_;
6155 open (AM_FILE, $amfile) || die "automake: couldn't open \`$amfile': $!\n";
6156 print "automake: reading $amfile\n" if $verbose;
6158 local ($saw_bk) = 0;
6159 local ($was_rule) = 0;
6160 local ($spacing) = '';
6161 local ($comment) = '';
6162 local ($last_var_name) = '';
6165 # We save the conditional stack on entry, and then check to make
6166 # sure it is the same on exit. This lets us conditonally include
6168 local (@saved_cond_stack) = @conditional_stack;
6172 if (/$IGNORE_PATTERN/o)
6174 # Merely delete comments beginning with two hashes.
6176 elsif (/$WHITE_PATTERN/o)
6178 # Stick a single white line before the incoming macro or rule.
6182 elsif (/$COMMENT_PATTERN/o)
6184 # Stick comments before the incoming macro or rule. Make
6185 # sure a blank line preceeds first block of comments.
6186 $spacing = "\n" unless $blank;
6188 $comment .= $spacing . $_;
6197 $output_vars .= $comment . "\n";
6201 local ($is_ok_macro);
6205 unless substr ($_, -1, 1) eq "\n";
6207 # Don't look at MAINTAINER_MODE_TRUE here. That shouldn't be
6208 # used by users. @MAINT@ is an anachronism now.
6209 $_ =~ s/\@MAINT\@//g
6210 unless $seen_maint_mode;
6212 if (/$IGNORE_PATTERN/o)
6214 # Merely delete comments beginning with two hashes.
6216 elsif (/$WHITE_PATTERN/o)
6218 # Stick a single white line before the incoming macro or rule.
6220 &am_line_error ($., "blank line following trailing backslash")
6223 elsif (/$COMMENT_PATTERN/o)
6225 # Stick comments before the incoming macro or rule.
6226 $comment .= $spacing . $_;
6228 &am_line_error ($., "comment following trailing backslash")
6235 $output_trailer .= join ('', @conditional_stack) . $_;
6241 $contents{$last_var_name} .= ' '
6242 unless $contents{$last_var_name} =~ /\s$/;
6243 $contents{$last_var_name} .= $_;
6244 if (@conditional_stack)
6246 $conditional{$last_var_name} .= "e_cond_val ($_);
6250 elsif (/$IF_PATTERN/o)
6252 &am_line_error ($., "$1 does not appear in AM_CONDITIONAL")
6253 if (! $configure_cond{$1});
6254 push (@conditional_stack, "\@" . $1 . "_TRUE\@");
6256 elsif (/$ELSE_PATTERN/o)
6258 if (! @conditional_stack)
6260 &am_line_error ($., "else without if");
6262 elsif ($conditional_stack[$#conditional_stack] =~ /_FALSE\@$/)
6264 &am_line_error ($., "else after else");
6268 $conditional_stack[$#conditional_stack]
6269 =~ s/_TRUE\@$/_FALSE\@/;
6272 elsif (/$ENDIF_PATTERN/o)
6274 if (! @conditional_stack)
6276 &am_line_error ($., "endif without if");
6280 pop @conditional_stack;
6283 elsif (/$RULE_PATTERN/o)
6287 if (defined $contents{$1}
6288 && (@conditional_stack
6289 ? ! defined $conditional{$1}
6290 : defined $conditional{$1}))
6293 "$1 defined both conditionally and unconditionally");
6295 # Value here doesn't matter; for targets we only note
6299 local ($cond_string) = join ('', @conditional_stack);
6300 if (@conditional_stack)
6302 if ($conditional{$1})
6304 &check_ambiguous_conditional ($1, $cond_string);
6305 $conditional{$1} .= ' ';
6309 $conditional{$1} = '';
6311 $conditional{$1} .= $cond_string . ' 1';
6313 $content_lines{$1} = $.;
6314 $output_trailer .= $comment . $spacing . $cond_string . $_;
6315 $comment = $spacing = '';
6318 # Check the rule for being a suffix rule. If so, store in
6321 local ($source_suffix);
6322 local ($object_suffix);
6324 if (($source_suffix, $object_suffix) = ($1 =~ $SUFFIX_RULE_PATTERN))
6326 $suffix_rules{$source_suffix} = $object_suffix;
6327 print "Sources ending in .$source_suffix become .$object_suffix\n" if $verbose;
6328 $source_suffix_pattern = "(" . join ('|', keys %suffix_rules) . ")";
6331 # FIXME: make sure both suffixes are in SUFFIXES? Or set
6332 # SUFFIXES from suffix_rules?
6334 elsif (($is_ok_macro = /$MACRO_PATTERN/o)
6335 || /$BOGUS_MACRO_PATTERN/o)
6337 # Found a macro definition.
6339 $last_var_name = $1;
6340 if (defined $contents{$1}
6341 && (@conditional_stack
6342 ? ! defined $conditional{$1}
6343 : defined $conditional{$1}))
6346 "$1 defined both conditionally and unconditionally");
6349 if ($3 ne '' && substr ($3, -1) eq "\\")
6351 # We preserve the `\' because otherwise the long lines
6352 # that are generated will be truncated by broken
6362 if (! defined $contents{$last_var_name})
6364 # The first assignment to a macro sets the line
6365 # number. Ideally I suppose we would associate line
6366 # numbers with random bits of text.
6367 $content_lines{$last_var_name} = $.;
6369 # If first assignment, set `+=' indicator.
6370 $var_was_plus_eq{$last_var_name} =
6372 && ! defined $am_var_defs{$last_var_name});
6377 if (! defined $contents{$last_var_name}
6378 && defined $am_var_defs{$last_var_name})
6380 $contents{$last_var_name} = $am_var_defs{$last_var_name};
6382 if (substr ($contents{$last_var_name}, -1) eq "\n")
6384 # Insert a backslash before a trailing newline.
6385 $contents{$last_var_name}
6386 = substr ($contents{$last_var_name}, 0, -1) . "\\\n";
6388 $contents{$last_var_name} .= ' ' . $value;
6392 $contents{$last_var_name} = $value;
6394 local ($cond_string) = join ('', @conditional_stack);
6395 if (@conditional_stack)
6399 if ($conditional{$last_var_name})
6403 # If we're adding to the conditional, and it
6404 # exists, then we might want to simply replace
6405 # the old value with the new one.
6406 local (@new_vals, @cond_vals);
6407 @cond_vals = split (' ', $conditional{$last_var_name});
6410 local ($vcond) = shift (@cond_vals);
6411 push (@new_vals, $vcond);
6412 if (&conditional_same ($vcond, $cond_string))
6415 $val = (&unquote_cond_val (shift (@cond_vals))
6417 push (@new_vals, "e_cond_val ($val));
6421 push (@new_vals, shift (@cond_vals));
6426 $conditional{$last_var_name}
6427 = join (' ', @new_vals);
6433 &check_ambiguous_conditional ($last_var_name,
6435 $conditional{$last_var_name} .= ' ';
6441 $conditional{$last_var_name} = '';
6442 $val = $contents{$last_var_name};
6446 $conditional{$last_var_name} .= ($cond_string
6448 . "e_cond_val ($val));
6452 # FIXME: this doesn't always work correctly; it will group
6453 # all comments for a given variable, no matter where
6455 $am_vars{$last_var_name} = $comment . $spacing;
6456 $def_type{$last_var_name} = ($type eq ':') ? ':' : '';
6457 push (@var_list, $last_var_name);
6458 $comment = $spacing = '';
6462 &am_line_error ($., "bad macro name \`$last_var_name'")
6465 elsif (/$INCLUDE_PATTERN/o)
6469 if ($path =~ s/^\$\(top_srcdir\)\///)
6471 push (@include_stack, "\$\(top_srcdir\)/$path");
6475 $path =~ s/\$\(srcdir\)\///;
6476 push (@include_stack, "\$\(srcdir\)/$path");
6477 $path = $relative_dir . "/" . $path;
6479 &read_am_file ($path);
6483 # This isn't an error; it is probably a continued rule.
6484 # In fact, this is what we assume.
6486 $output_trailer .= ($comment . $spacing
6487 . join ('', @conditional_stack) . $_);
6488 $comment = $spacing = '';
6495 $output_trailer .= $comment;
6497 if (join (' ', @saved_cond_stack) ne join (' ', @conditional_stack))
6499 if (@conditional_stack)
6501 &am_error ("unterminated conditionals: " . join (' ', @conditional_stack));
6505 # FIXME: better error message here.
6506 &am_error ("conditionals not nested in include file");
6511 # A helper for read_main_am_file which initializes configure variables
6512 # and variables from header-vars.am. This is a subr so we can call it
6514 sub define_standard_variables
6516 # Compute relative location of the top object directory.
6517 local (@topdir) = ();
6518 foreach (split (/\//, $relative_dir))
6520 next if $_ eq '.' || $_ eq '';
6527 push (@topdir, '..');
6530 @topdir = ('.') if ! @topdir;
6532 $top_builddir = join ('/', @topdir);
6534 ($build_rx = $top_builddir) =~ s/(\W)/\\$1/g;
6535 $output_vars .= &file_contents_with_transform
6536 ('s/\@top_builddir\@/' . $build_rx . '/g;',
6539 # Generate some useful variables when AC_CANONICAL_* used. FIXME:
6540 # this should use generic %configure_vars method.
6541 if ($seen_canonical)
6543 local ($curs, %vars);
6544 $vars{'host_alias'} = 'host_alias';
6545 $vars{'host_triplet'} = 'host';
6546 if ($seen_canonical == $AC_CANONICAL_SYSTEM)
6548 $vars{'build_alias'} = 'build_alias';
6549 $vars{'build_triplet'} = 'build';
6550 $vars{'target_alias'} = 'target_alias';
6551 $vars{'target_triplet'} = 'target';
6553 foreach $curs (sort keys %vars)
6555 $output_vars .= "$curs = \@$vars{$curs}\@\n";
6556 $contents{$curs} = "\@$vars{$curs}\@";
6561 foreach $curs (sort keys %configure_vars)
6563 &define_configure_variable ($curs);
6567 # Read main am file.
6568 sub read_main_am_file
6570 local ($amfile) = @_;
6572 # The keys here are variables we want to dump at the end of this
6573 # function. The values are corresponding comments.
6574 local (%am_vars) = ();
6575 local (@var_list) = ();
6576 local (%def_type) = ();
6578 # This supports the strange variable tricks we are about to play.
6579 if (scalar keys %contents > 0)
6581 print STDERR "automake: programming error: variable defined before read_main_am_file\n";
6585 # We want to predefine as many variables as possible. This lets
6586 # the user set them with `+=' in Makefile.am. However, we don't
6587 # want these initial definitions to end up in the output quite
6588 # yet. So we adopt a hack: read the `.am' file twice, throwing
6589 # away the output the first time. We also squirrel away a list of
6590 # all the variables defined by the .am file so that we know which
6591 # ones to remove from the content list.
6594 &define_standard_variables;
6595 local (%saved_contents) = %contents;
6597 # Read user file, but discard text of variable assignments we just
6600 &read_am_file ($amfile);
6602 # Now dump the variables that were defined. We do it in the same
6603 # order in which they were defined (skipping duplicates).
6605 foreach $curs (@var_list)
6607 next if $done{$curs};
6610 $output_vars .= $am_vars{$curs};
6611 if ($conditional{$curs})
6613 local (@cond_vals) = split (' ', $conditional{$curs});
6616 local ($vcond) = shift (@cond_vals);
6617 local ($val) = &unquote_cond_val (shift (@cond_vals));
6618 $output_vars .= ($vcond . $curs . ' '
6619 . $def_type{$curs} . "= ");
6621 foreach $line (split ("\n", $val))
6623 $output_vars .= $vcond . $line . "\n";
6625 $output_vars .= "\n"
6631 $output_vars .= ($curs . ' ' . $def_type{$curs} . '= '
6632 . $contents{$curs} . "\n");
6636 # Generate copyright header for generated Makefile.in.
6637 local ($ov) = $output_vars;
6638 $output_vars = ("# $in_file_name generated automatically by automake "
6639 . $VERSION . " from $am_file_name\n");
6640 $output_vars .= $gen_copyright;
6642 # Now go through and delete all the variables that the user did
6645 foreach $var (keys %saved_contents)
6647 if ($contents{$var} eq $saved_contents{$var})
6649 delete $contents{$var};
6653 # Re-read the standard variables, and this time keep their
6654 # contributions to the output. Then add the user's output to the
6656 &define_standard_variables;
6657 $output_vars .= $ov;
6661 ################################################################
6663 sub initialize_global_constants
6665 # Values for AC_CANONICAL_*
6666 $AC_CANONICAL_HOST = 1;
6667 $AC_CANONICAL_SYSTEM = 2;
6669 # Associative array of standard directory names. Entry is TRUE if
6670 # corresponding directory should be installed during
6671 # 'install-exec' phase.
6689 # Commonly found files we look for and automatically include in
6693 'README', 'THANKS', 'TODO', 'NEWS', 'COPYING', 'COPYING.LIB',
6694 'INSTALL', 'ABOUT-NLS', 'ChangeLog', 'configure.ac',
6695 'configure.in', 'configure', 'config.guess', 'config.sub',
6696 'AUTHORS', 'BACKLOG', 'ABOUT-GNU', 'libversion.in',
6697 'mdate-sh', 'mkinstalldirs', 'install-sh', 'texinfo.tex',
6698 'ansi2knr.c', 'ansi2knr.1', 'elisp-comp',
6699 # ltconfig appears here for compatibility with old versions
6701 'ylwrap', 'acinclude.m4', @libtoolize_files, @libtoolize_sometimes,
6702 'missing', 'depcomp', 'compile', 'py-compile'
6705 # Commonly used files we auto-include, but only sometimes.
6708 'aclocal.m4', 'acconfig.h', 'config.h.top',
6709 'config.h.bot', 'stamp-h.in', 'stamp-vti'
6713 -a, --add-missing add missing standard files to package
6714 --amdir=DIR directory storing config files
6715 -c, --copy with -a, copy missing files (default is symlink)
6716 --cygnus assume program is part of Cygnus-style tree
6717 --force-missing force update of standard files
6718 --foreign set strictness to foreign
6719 --gnits set strictness to gnits
6720 --gnu set strictness to gnu
6721 --help print this help, then exit
6722 -i, --ignore-deps disable dependency tracking code
6723 --include-deps enable dependency tracking code
6724 --no-force only update Makefile.in's that are out of date
6725 -o DIR, --output-dir=DIR
6726 put generated Makefile.in's into DIR
6727 -v, --verbose verbosely list files processed
6728 --version print version number, then exit\n";
6730 # Copyright on generated Makefile.ins.
6732 # Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000
6733 # Free Software Foundation, Inc.
6734 # This Makefile.in is free software; the Free Software Foundation
6735 # gives unlimited permission to copy and/or distribute it,
6736 # with or without modifications, as long as this notice is preserved.
6738 # This program is distributed in the hope that it will be useful,
6739 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
6740 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
6741 # PARTICULAR PURPOSE.
6744 # This complex find command will try to avoid changing the modes of
6745 # links into the source tree, in case they're hard-linked. It will
6746 # also make directories writable by everybody, because some
6747 # brain-dead tar implementations change ownership and permissions of
6748 # a directory before extracting the files, thus becoming unable to
6750 # Ignore return result from chmod, because it might give an error
6751 # if we chmod a symlink.
6752 # Another nastiness: if the file is unreadable by us, we make it
6753 # readable regardless of the number of links to it. This only
6754 # happens in perverse cases.
6755 # We use $(install_sh) because that is a known-portable way to
6756 # modify the file in place in the source tree.
6757 $dist_header = ' -find $(distdir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \\
6758 ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \\
6759 ! -type d ! -perm -400 -exec chmod a+r {} \; -o \\
6760 ! -type d ! -perm -444 -exec $(SHELL) $(install_sh) -c -m a+r {} {} \; \\
6761 || chmod -R a+r $(distdir)
6763 $dist{'dist-bzip2'} = ("\t"
6764 . '$(AMTAR) chof - $(distdir) | bzip2 -9 -c > $(distdir).tar.bz2'
6766 $dist{'dist-tarZ'} = ("\t"
6767 . '$(AMTAR) chof - $(distdir) | compress -c > $(distdir).tar.Z'
6769 $dist{'dist-shar'} = ("\t"
6770 . 'shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c > $(distdir).shar.gz'
6772 $dist{'dist-zip'} = ("\t" . '-rm -f $(distdir).zip' . "\n" .
6773 "\t" . 'zip -rq $(distdir).zip $(distdir)' . "\n");
6775 # Note that we don't use GNU tar's `-z' option. One reason (but
6776 # not the only reason) is that some versions of tar (e.g., OSF1)
6777 # interpret `-z' differently.
6778 $dist{'dist'} = ("\t"
6779 . '$(AMTAR) chof - $(distdir) | GZIP=$(GZIP_ENV) gzip -c > $(distdir).tar.gz'
6781 $dist_trailer = "\t" . '-chmod -R a+w $(distdir) > /dev/null 2>&1; rm -rf $(distdir)' . "\n";
6784 # (Re)-Initialize per-Makefile.am variables.
6785 sub initialize_per_input
6787 # These two variables are used when generating each Makefile.in.
6788 # They hold the Makefile.in until it is ready to be printed.
6791 $output_trailer = '';
6793 $output_header = '';
6795 # Suffixes found during a run.
6798 # This holds the contents of a Makefile.am, as parsed by
6802 # This holds the names which are targets. These also appear in
6806 # This maps a variable name onto a flag. The flag is true iff the
6807 # variable was first defined with `+='.
6808 %var_was_plus_eq = ();
6810 # This holds definitions of all variables defined in .am files.
6811 # This is used during startup to determine which variables can be
6812 # assigned with `+='.
6815 # For a variable or target which is defined conditionally, this
6816 # holds an array of the conditional values. The array is composed
6817 # of pairs of condition strings (the variables which configure
6818 # will substitute) and values (the value of a target is
6819 # meaningless). For an unconditional variable, this is empty.
6822 # This holds the line numbers at which various elements of
6823 # %contents are defined.
6824 %content_lines = ();
6826 # This holds a 1 if a particular variable was examined.
6829 # This is the conditional stack.
6830 @conditional_stack = ();
6832 # This holds the set of included files.
6833 @include_stack = ();
6835 # This holds the "relative directory" of the current Makefile.in.
6836 # Eg for src/Makefile.in, this is "src".
6839 # This holds a list of files that are included in the
6843 # List of dependencies for the obvious targets.
6859 # A list of files deleted by `maintainer-clean'.
6860 @maintainer_clean_files = ();
6862 # These are pretty obvious, too. They are used to define the
6863 # SOURCES and OBJECTS variables.
6866 # Sources which go in the distribution.
6869 # This hash maps object file names onto their corresponding source
6870 # file names. This is used to ensure that each object is created
6871 # by a single source file.
6874 # This keeps track of the directories for which we've already
6875 # created `.dirstamp' code.
6876 %directory_map = ();
6878 # These variables track inclusion of various compile-related .am
6879 # files. $included_generic_compile is TRUE if the basic code has
6880 # been included. $included_knr_compile is TRUE if the ansi2knr
6881 # code has been included. $included_libtool_compile is TRUE if
6882 # libtool support has been included.
6883 $included_generic_compile = 0;
6884 $included_knr_compile = 0;
6885 $included_libtool_compile = 0;
6887 # TRUE if install targets should work recursively.
6888 $recursive_install = 0;
6893 # Strictness levels.
6894 $strictness = $default_strictness;
6895 $strictness_name = $default_strictness_name;
6897 # Options from AUTOMAKE_OPTIONS.
6900 # Whether or not dependencies are handled. Can be further changed
6901 # in handle_options.
6902 $use_dependencies = $cmdline_use_dependencies;
6905 $local_maint_charset = $maint_charset;
6907 # All yacc and lex source filenames for this directory. Use
6908 # filenames instead of raw count so that multiple instances are
6909 # counted correctly (eg one yacc file can appear in multiple
6910 # programs without harm).
6914 # This is a list of all targets to run during "make dist".
6917 # Keys in this hash are the basenames of files which must depend
6919 %de_ansi_files = ();
6921 # This maps the source extension of a suffix rule to its
6922 # corresponding output extension.
6925 # This is a regular expression which matches all the known source
6926 # suffix. A source suffix is one that appears in the first
6927 # position of a suffix rule.
6928 $source_suffix_pattern = '';
6930 # This is the name of the recursive `all' target to use.
6931 $all_target = 'all-recursive';
6933 # This keeps track of which extensions we've seen (that we care
6935 %extension_seen = ();
6937 # This is random scratch space for the language finish functions.
6938 # Don't randomly overwrite it; examine other uses of keys first.
6939 %language_scratch = ();
6941 # We keep track of which objects need special (per-executable)
6942 # handling on a per-language basis.
6943 %lang_specific_files = ();
6945 # This is set when `handle_dist' has finished. Once this happens,
6946 # we should no longer push on dist_common.
6947 $handle_dist_run = 0;
6949 # True if we need `LINK' defined. This is a hack.
6954 ################################################################
6956 # Return contents of a file from $am_dir, automatically skipping
6957 # macros or rules which are already known. Runs command on each line
6958 # as it is read; this command can modify $_.
6959 sub file_contents_with_transform
6961 local ($command, $basename) = @_;
6962 local ($file) = $am_dir . '/' . $basename . '.am';
6964 if ($command ne '' && substr ($command, -1) ne ';')
6966 die "automake: programming error in file_contents_with_transform: $command\n";
6969 open (FC_FILE, $file)
6970 || die "automake: installation error: cannot open \`$file'\n";
6972 # print "automake: reading $file\n" if $verbose;
6974 local ($was_rule) = 0;
6975 local ($result_vars) = '';
6976 local ($result_rules) = '';
6977 local ($comment) = '';
6978 local ($spacing) = "\n";
6979 local ($skipping) = 0;
6984 $_ =~ s/\@MAINTAINER_MODE_TRUE\@//g
6985 unless $seen_maint_mode;
6987 $had_chars = length ($_) && $_ ne "\n";
6989 # If the transform caused all the characters to go away, then
6990 # ignore the line. Why do this? Because in Perl 4, a "next"
6991 # inside of an eval doesn't affect a loop outside the eval.
6992 # So we can't pass in a "transform" that uses next. We used
6993 # to do this. "Empty" also means consisting of a single
6995 next if $had_chars && ($_ eq '' || $_ eq "\n");
6997 if (/$IGNORE_PATTERN/o)
6999 # Merely delete comments beginning with two hashes.
7001 elsif (/$WHITE_PATTERN/o)
7003 # Stick a single white line before the incoming macro or rule.
7005 &am_line_error ($., "blank line following trailing backslash")
7008 elsif (/$COMMENT_PATTERN/o)
7010 # Stick comments before the incoming macro or rule.
7011 $comment .= $spacing . $_;
7013 &am_line_error ($., "comment following trailing backslash")
7020 $result_rules .= $_ if ! $skipping;
7024 $result_vars .= $_ if ! $skipping;
7028 elsif (/$RULE_PATTERN/o)
7032 $skipping = defined $contents{$1};
7033 $result_rules .= $comment . $spacing . $_ if ! $skipping;
7034 $comment = $spacing = '';
7037 elsif (/$MACRO_PATTERN/o)
7039 # Found a variable reference.
7041 $skipping = defined $contents{$1};
7042 $result_vars .= $comment . $spacing . $_ if ! $skipping;
7043 $comment = $spacing = '';
7045 print STDERR "automake: programming error: .am macro \`$1' with trailing backslash at $file:$.\n"
7047 $am_var_defs{$1} = $3;
7051 # This isn't an error; it is probably a continued rule.
7052 # In fact, this is what we assume.
7054 $result_rules .= $comment . $spacing . $_ if ! $skipping;
7055 $comment = $spacing = '';
7061 return $result_vars . $result_rules . $comment;
7064 # Like file_contents_with_transform, but no transform.
7067 return &file_contents_with_transform ('', @_);
7070 # &transform (%PAIRS)
7071 # -------------------
7072 # Create a replacement expression suitable for file_contents_with_transform
7073 # to replace each key of %PAIRS by its value.
7076 local (%pairs) = @_;
7077 local ($result) = '';
7079 foreach $pattern (sort keys %pairs)
7081 $result .= 's,\@' . $pattern . '\@,' . $pairs{$pattern} . ',g;';
7086 # Find all variable prefixes that are used for install directories. A
7087 # prefix `zar' qualifies iff:
7088 # * `zardir' is a variable.
7089 # * `zar_PRIMARY' is a variable.
7090 sub am_primary_prefixes
7092 local ($primary, $can_dist, @prefixes) = @_;
7094 local (%valid, $varname);
7095 grep ($valid{$_} = 0, @prefixes);
7096 $valid{'EXTRA'} = 0;
7097 foreach $varname (keys %contents)
7099 if ($varname =~ /^(nobase_)?(dist_|nodist_)?(.*)_$primary$/)
7101 if (($2 ne '' && ! $can_dist)
7102 || (! defined $valid{$3} && ! &variable_defined ($3 . 'dir')))
7104 # Note that a configure variable is always legitimate.
7105 # It is natural to name such variables after the
7106 # primary, so we explicitly allow it.
7107 if (! defined $configure_vars{$varname})
7109 &am_line_error ($varname, "invalid variable \`$varname'");
7114 # Ensure all extended prefixes are actually used.
7115 $valid{$1 . $2 . $3} = 1;
7123 # Handle `where_HOW' variable magic. Does all lookups, generates
7124 # install code, and possibly generates code to define the primary
7125 # variable. The first argument is the name of the .am file to munge,
7126 # the second argument is the primary variable (eg HEADERS), and all
7127 # subsequent arguments are possible installation locations. Returns
7128 # list of all values of all _HOW targets.
7130 # FIXME: this should be rewritten to be cleaner. It should be broken
7131 # up into multiple functions.
7133 # Usage is: am_install_var (OPTION..., file, HOW, where...)
7138 local ($do_clean) = 0;
7139 local ($do_require) = 1;
7140 local ($can_dist) = 0;
7141 local ($default_dist) = 0;
7144 if (defined $configure_vars{'LIBTOOL'})
7146 # Transform '@LIBTOOL ...@' to '$(LIBTOOL) ...'
7147 $ltxform = 's/\@LIBTOOL([^\@]*)\@/\$(LIBTOOL) $1/;';
7151 # Delete '@LIBTOOL ...@'
7152 $ltxform = 's/\@LIBTOOL([^\@]*)\@//;';
7158 $cygxform = 's/\@EXEEXT\@//g;';
7162 $cygxform = 's/\@EXEEXT\@/\$(EXEEXT)/g;';
7167 if ($args[0] eq '-clean')
7171 elsif ($args[0] eq '-noextra')
7175 elsif ($args[0] eq '-candist')
7179 elsif ($args[0] eq '-defaultdist')
7184 elsif ($args[0] !~ /^-/)
7191 local ($file, $primary, @prefixes) = @args;
7194 local (@result) = ();
7196 # Now that configure substitutions are allowed in where_HOW
7197 # variables, it is an error to actually define the primary. We
7198 # allow `JAVA', as it is customarily used to mean the Java
7199 # interpreter. This is but one of several Java hacks. Similarly,
7200 # `PYTHON' is customarily used to mean the Python interpreter.
7201 &am_line_error ($primary, "\`$primary' is an anachronism")
7202 if &variable_defined ($primary)
7203 && ($primary ne 'JAVA' && $primary ne 'PYTHON');
7206 # Look for misspellings. It is an error to have a variable ending
7207 # in a "reserved" suffix whose prefix is unknown, eg
7208 # "bni_PROGRAMS". However, unusual prefixes are allowed if a
7209 # variable of the same name (with "dir" appended) exists. For
7210 # instance, if the variable "zardir" is defined, then
7211 # "zar_PROGRAMS" becomes valid. This is to provide a little extra
7212 # flexibility in those cases which need it.
7213 local (%valid) = &am_primary_prefixes ($primary, $can_dist, @prefixes);
7215 # If a primary includes a configure substitution, then the EXTRA_
7216 # form is required. Otherwise we can't properly do our job.
7217 local ($require_extra);
7218 local ($warned_about_extra) = 0;
7220 local ($clean_file) = $file . '-clean';
7223 local ($nodir_name);
7224 local ($strip_subdir) = 1;
7225 foreach $X (sort keys %valid)
7227 $one_name = $X . '_' . $primary;
7228 if (&variable_defined ($one_name))
7230 # If subdir prefix should be preserved, do so.
7231 if ($X =~ /^nobase_/)
7237 # If files should be distributed, do so.
7240 if (($default_dist && $one_name !~ /^nodist_/)
7241 || (! $default_dist && $one_name =~ /^dist_/))
7243 &push_dist_common ('$(' . $one_name . ')');
7245 ($nodir_name = $X) =~ s/^(dist|nodist)_//;
7252 # Append actual contents of where_PRIMARY variable to
7255 foreach $rcurs (&variable_value_as_list ($one_name, 'all'))
7257 # Skip configure substitutions. Possibly bogus.
7258 if ($rcurs =~ /^\@.*\@$/)
7262 if (! $warned_about_extra)
7264 $warned_about_extra = 1;
7266 &am_line_error ($one_name,
7267 "\`$one_name' contains configure substitution, but shouldn't");
7271 # Check here to make sure variables defined in
7272 # configure.ac do not imply that EXTRA_PRIMARY
7274 elsif (! defined $configure_vars{$one_name})
7276 $require_extra = $one_name
7283 push (@result, $rcurs);
7286 # A blatant hack: we rewrite each _PROGRAMS primary to
7287 # include EXEEXT when in Cygwin32 mode.
7288 if ($seen_exeext && $primary eq 'PROGRAMS')
7290 local (@conds) = &variable_conditions ($one_name);
7291 local (@one_binlist);
7293 # FIXME: this definitely loses aesthetically; it
7294 # redefines $ONE_NAME. Instead we should arrange for
7295 # variable definitions to be output later, instead of
7301 foreach $rcurs (&variable_value_as_list ($one_name, ''))
7303 if ($rcurs =~ /\./ || $rcurs =~ /^\@.*\@$/)
7305 push (@one_binlist, $rcurs);
7309 push (@one_binlist, $rcurs . '$(EXEEXT)');
7313 delete $contents{$one_name};
7314 &define_pretty_variable ($one_name, '', @one_binlist);
7319 local ($condvals) = '';
7320 foreach $cond (@conds)
7323 local (@condval) = &variable_value_as_list ($one_name,
7325 foreach $rcurs (@condval)
7327 if ($rcurs =~ /\./ || $rcurs =~ /^\@.*\@$/)
7329 push (@one_binlist, $rcurs);
7333 push (@one_binlist, $rcurs . '$(EXEEXT)');
7337 push (@condvals, $cond);
7338 push (@condvals, join (' ', @one_binlist));
7341 delete $contents{$one_name};
7345 $cond = shift (@condvals);
7346 local (@val) = split (' ', shift (@condvals));
7347 &define_pretty_variable ($one_name, $cond, @val);
7352 # "EXTRA" shouldn't be used when generating clean targets,
7353 # all, or install targets.
7356 # We used to warn if EXTRA_FOO was defined uselessly,
7357 # but this was annoying.
7364 &file_contents_with_transform ('s/\@DIR\@/' . $X . '/go;'
7368 push (@clean, $X . $primary);
7369 &push_phony_cleaners ($X . $primary);
7374 push (@check, '$(' . $one_name . ')');
7378 push (@used, '$(' . $one_name . ')');
7380 if ($X eq 'noinst' || $X eq 'check')
7382 # Objects which don't get installed by default.
7386 local ($subdir_xform);
7389 $subdir_xform = 's/^NOBASE.*$//; s/^BASE//;';
7393 $subdir_xform = 's/^BASE.*$//; s/^NOBASE//;';
7397 &file_contents_with_transform ('s/\@DIR\@/' . $X . '/g;'
7398 . 's/\@NDIR\@/' . $nodir_name . '/go;'
7399 . $ltxform . $cygxform
7403 push (@uninstall, 'uninstall-' . $X . $primary);
7404 push (@phony, 'uninstall-' . $X . $primary);
7405 push (@installdirs, '$(DESTDIR)$(' . $X . 'dir)');
7406 if (defined $exec_dir_p{$X} ? $exec_dir_p{$X} : ($X =~ /exec/))
7408 push (@install_exec, 'install-' . $X . $primary);
7409 push (@phony, 'install-' . $X . $primary);
7413 push (@install_data, 'install-' . $X . $primary);
7414 push (@phony, 'install-' . $X . $primary);
7419 # The JAVA variable is used as the name of the Java interpreter.
7420 # The PYTHON variable is used as the name of the Python interpreter.
7421 if (@used && $primary ne 'JAVA' && $primary ne 'PYTHON')
7424 &define_pretty_variable ($primary, '', @used);
7425 $output_vars .= "\n";
7428 if ($require_extra && ! &variable_defined ('EXTRA_' . $primary))
7430 &am_line_error ($require_extra,
7431 "\`$require_extra' contains configure substitution, but \`EXTRA_$primary' not defined");
7434 # Push here because PRIMARY might be configure time determined.
7435 push (@all, '$(' . $primary . ')')
7436 if @used && $primary ne 'JAVA' && $primary ne 'PYTHON';
7438 # Make the result unique. This lets the user use conditionals in
7439 # a natural way, but still lets us program lazily -- we don't have
7440 # to worry about handling a particular object more than once.
7441 local (%uniquify) = ();
7442 grep ($uniquify{$_} = 1, @result);
7443 return sort keys %uniquify;
7447 ################################################################
7449 # Each key in this hash is the name of a directory holding a
7450 # Makefile.in. These variables are local to `is_make_dir'.
7457 if (! $make_dirs_set)
7459 foreach $iter (@configure_input_files)
7461 $make_dirs{&dirname ($iter)} = 1;
7463 # We also want to notice Makefile.in's.
7464 foreach $iter (@other_input_files)
7466 if ($iter =~ /Makefile\.in$/)
7468 $make_dirs{&dirname ($iter)} = 1;
7473 return defined $make_dirs{$dir};
7476 ################################################################
7478 # This variable is local to the "require file" set of functions.
7479 @require_file_paths = ();
7481 # If a file name appears as a key in this hash, then it has already
7482 # been checked for. This variable is local to the "require file"
7484 %require_file_found = ();
7486 # See if we want to push this file onto dist_common. This function
7487 # encodes the rules for deciding when to do so.
7488 sub maybe_push_required_file
7490 local ($dir, $file, $fullfile) = @_;
7492 # FIXME: Once again, special-case `.'.
7493 if ($dir eq $relative_dir || $dir eq '.')
7495 &push_dist_common ($file);
7497 elsif ($relative_dir eq '.' && ! &is_make_dir ($dir))
7499 # If we are doing the topmost directory, and the file is in a
7500 # subdir which does not have a Makefile, then we distribute it
7502 &push_dist_common ($fullfile);
7506 # Verify that the file must exist in the current directory. Usage:
7507 # require_file (isconfigure, line_number, strictness, file) strictness
7508 # is the strictness level at which this file becomes required. Must
7509 # set require_file_paths before calling this function.
7510 # require_file_paths is set to hold a single directory (the one in
7511 # which the first file was found) before return.
7512 sub require_file_internal
7514 local ($is_configure, $line, $mystrict, @files) = @_;
7515 local ($file, $fullfile);
7516 local ($found_it, $dangling_sym, $errfile, $errdir);
7519 foreach $file (@files)
7521 # If we've already looked for it, we're done.
7522 next if defined $require_file_found{$file};
7523 $require_file_found{$file} = 1;
7527 foreach $dir (@require_file_paths)
7531 $fullfile = $relative_dir . "/" . $file;
7532 $errdir = $relative_dir unless $errdir;
7536 $fullfile = $dir . "/" . $file;
7537 $errdir = $dir unless $errdir;
7540 # Use different name for "error filename". Otherwise on
7541 # an error the bad file will be reported as eg
7542 # `../../install-sh' when using the default
7544 $errfile = $errdir . '/' . $file;
7546 if (-l $fullfile && ! -f readlink ($fullfile))
7551 elsif (-f $fullfile)
7554 &maybe_push_required_file ($dir, $file, $fullfile);
7560 if ($found_it && ! $force_missing)
7562 # Prune the path list.
7563 @require_file_paths = $save_dir;
7567 if ($strictness >= $mystrict)
7569 if ($dangling_sym && ($force_missing || $add_missing))
7574 local ($trailer) = '';
7575 local ($suppress) = 0;
7577 # Only install missing files according to our desired
7579 local ($message) = "required file \`$errfile' not found";
7584 # Maybe run libtoolize.
7585 local @syslist = ('libtoolize', '--automake');
7586 push @syslist, '--copy'
7589 && grep ($_ eq $file, @libtoolize_files)
7590 && system (@syslist))
7592 $message = "installing \`$errfile'";
7594 $trailer = "; cannot run \`libtoolize': $!";
7596 elsif (-f ($am_dir . '/' . $file))
7598 # Install the missing file. Symlink if we
7599 # can, copy if we must. Note: delete the file
7600 # first, in case it is a dangling symlink.
7601 $message = "installing \`$errfile'";
7602 # Windows Perl will hang if we try to delete a
7603 # file that doesn't exist.
7604 unlink ($errfile) if -f $errfile;
7605 if ($symlink_exists && ! $copy_missing)
7607 if (! symlink ($am_dir . '/' . $file, $errfile))
7610 $trailer = "; error while making link: $!";
7613 elsif (system ('cp', $am_dir . '/' . $file, $errfile))
7616 $trailer = "\n error while copying";
7620 &maybe_push_required_file (&dirname ($errfile),
7624 local ($save) = $exit_status;
7627 # FIXME: allow actual file to be specified.
7628 &am_conf_line_error ($configure_ac, $line,
7629 "$message$trailer");
7633 &am_line_error ($line, "$message$trailer");
7635 $exit_status = $save if $suppress;
7641 # Like require_file_with_line, but error messages refer to
7642 # configure.ac, not the current Makefile.am.
7643 sub require_file_with_conf_line
7645 @require_file_paths = '.';
7646 &require_file_internal (1, @_);
7649 sub require_file_with_line
7651 @require_file_paths = '.';
7652 &require_file_internal (0, @_);
7657 @require_file_paths = '.';
7658 &require_file_internal (0, '', @_);
7661 # Require a file that is also required by Autoconf. Looks in
7662 # configuration path, as specified by AC_CONFIG_AUX_DIR.
7663 sub require_config_file
7665 @require_file_paths = @config_aux_path;
7666 &require_file_internal (1, '', @_);
7667 local ($dir) = $require_file_paths[0];
7668 @config_aux_path = @require_file_paths;
7671 $config_aux_dir = '.';
7675 $config_aux_dir = '$(top_srcdir)/' . $dir;
7679 # Assumes that the line number is in Makefile.am.
7680 sub require_conf_file_with_line
7682 @require_file_paths = @config_aux_path;
7683 &require_file_internal (0, @_);
7684 local ($dir) = $require_file_paths[0];
7685 @config_aux_path = @require_file_paths;
7688 $config_aux_dir = '.';
7692 $config_aux_dir = '$(top_srcdir)/' . $dir;
7696 # Assumes that the line number is in configure.ac.
7697 sub require_conf_file_with_conf_line
7699 @require_file_paths = @config_aux_path;
7700 &require_file_internal (1, @_);
7701 local ($dir) = $require_file_paths[0];
7702 @config_aux_path = @require_file_paths;
7705 $config_aux_dir = '.';
7709 $config_aux_dir = '$(top_srcdir)/' . $dir;
7713 ################################################################
7715 # Push a list of files onto dist_common.
7716 sub push_dist_common
7718 local (@files) = @_;
7721 foreach $file (@files)
7723 if (! defined $dist_common{$file})
7725 if ($handle_dist_run)
7728 "automake: programming error: push_dist_common run after handle_dist\n";
7731 $dist_common{$file} = 1;
7736 # Push a list of clean targets onto phony.
7737 sub push_phony_cleaners
7741 foreach $target ('mostly', 'dist', '', 'maintainer-')
7743 push (@phony, $target . 'clean-' . $base);
7750 $strictness_name = $_[0];
7751 if ($strictness_name eq 'gnu')
7755 elsif ($strictness_name eq 'gnits')
7757 $strictness = $GNITS;
7759 elsif ($strictness_name eq 'foreign')
7761 $strictness = $FOREIGN;
7765 die "automake: level \`$strictness_name' not recognized\n";
7770 ################################################################
7772 # Return directory name of file.
7778 ($sub = $file) =~ s,/+[^/]+$,,g;
7779 $sub = '.' if $sub eq $file;
7783 # Return file name of a file.
7789 ($sub = $file) =~s,^.*/+,,g;
7793 # Ensure a file exists.
7798 open (TOUCH, ">> $file");
7802 # Glob something. Do this to avoid indentation screwups everywhere we
7803 # want to glob. Gross!
7810 ################################################################
7812 # Print an error message and set exit status.
7815 warn "automake: ${am_file}.am: ", join (' ', @_), "\n";
7821 local ($symbol, @args) = @_;
7823 if ($symbol && "$symbol" ne '-1')
7825 local ($file) = "${am_file}.am";
7827 if ($symbol =~ /^\d+$/)
7829 # SYMBOL is a line number, so just add the colon.
7830 $file .= ':' . $symbol;
7832 elsif (defined $content_lines{$symbol})
7834 # SYMBOL is a variable defined in Makefile.am, so add the
7835 # line number we saved from there.
7836 $file .= ':' . $content_lines{$symbol};
7838 elsif (defined $configure_vars{$symbol})
7840 # SYMBOL is a variable defined in configure.ac, so add the
7841 # appropriate line number.
7842 $file = $configure_vars{$symbol};
7846 # Couldn't find the line number.
7848 warn $file, ": ", join (' ', @args), "\n";
7857 # Like am_error, but while scanning configure.ac.
7860 # FIXME: can run in subdirs.
7861 warn "automake: $configure_ac: ", join (' ', @_), "\n";
7865 # Error message with line number referring to configure.ac.
7866 sub am_conf_line_error
7868 local ($file, $line, @args) = @_;
7872 warn "$file: $line: ", join (' ', @args), "\n";
7877 &am_conf_error (@args);
7881 # Warning message with line number referring to configure.ac.
7882 # Does not affect exit_status
7883 sub am_conf_line_warning
7885 local ($saved_exit_status) = $exit_status;
7886 &am_conf_line_error (@_);
7887 $exit_status = $saved_exit_status;
7890 # Tell user where our aclocal.m4 is, but only once.
7891 sub keyed_aclocal_warning
7894 warn "automake: macro \`$key' can be generated by \`aclocal'\n";
7897 # Print usage information.
7900 print "Usage: automake [OPTION] ... [Makefile]...\n\n";
7901 print "Generate Makefile.in for autoconf from Makefile.am\n";
7903 print "\nFiles which are automatically distributed, if found:\n";
7904 $~ = "USAGE_FORMAT";
7905 local ($last, $iter, @lcomm);
7907 foreach $iter (sort ((@common_files, @common_sometimes)))
7909 push (@lcomm, $iter) unless $iter eq $last;
7913 local ($one, $two, $three, $four, $i, $max);
7914 $max = int (($#lcomm + 1) / 4);
7916 for ($i = 0; $i < $max; ++$i)
7919 $two = $lcomm[$max + $i];
7920 $three = $lcomm[2 * $max + $i];
7921 $four = $lcomm[3 * $max + $i];
7925 local ($mod) = ($#lcomm + 1) % 4;
7928 $one = $lcomm[$max];
7929 $two = ($mod > 1) ? $lcomm[2 * $max] : '';
7930 $three = ($mod > 2) ? $lcomm[3 * $max] : '';
7931 $four = ($mod > 3) ? $lcomm[4 * $max] : '';
7935 print "\nReport bugs to <bug-automake\@gnu.org>.\n";
7940 format USAGE_FORMAT =
7941 @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<
7942 $one, $two, $three, $four