5 eval 'exec @PERL@ -S $0 ${1+"$@"}'
8 # automake - create Makefile.in from Makefile.am
9 # Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
10 # Free Software Foundation, Inc.
12 # This program is free software; you can redistribute it and/or modify
13 # it under the terms of the GNU General Public License as published by
14 # the Free Software Foundation; either version 2, or (at your option)
17 # This program is distributed in the hope that it will be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # GNU General Public License for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, write to the Free Software
24 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
27 # Originally written by David Mackenzie <djm@gnu.ai.mit.edu>.
28 # Perl reimplementation by Tom Tromey <tromey@cygnus.com>.
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;
809 # get_object_extension ($OUT)
810 # ---------------------------
811 # Return object extension. Just once, put some code into the output.
812 # OUT is the name of the output file
813 sub get_object_extension
817 # Maybe require libtool library object files.
818 local ($extension) = '.o';
819 $extension = '.$(OBJEXT)' if $seen_objext;
820 $extension = '.lo' if ($out =~ /\.la$/);
822 if (! $included_generic_compile)
825 local ($default_include) = '';
826 if (! defined $options{'nostdinc'})
828 $default_include = ' -I. -I$(srcdir)';
830 if (&variable_defined ('CONFIG_HEADER'))
833 foreach $one_hdr (split (' ',
834 &variable_value ('CONFIG_HEADER')))
836 $default_include .= ' -I' . &dirname ($one_hdr);
840 local ($xform) = &transform ('DEFAULT_INCLUDES' => $default_include);
841 $output_vars .= &file_contents_with_transform ($xform,
844 $xform = $seen_objext ? 's/^OBJEXT//;' : 's/^OBJEXT.*$//;';
845 $output_rules .= &file_contents_with_transform ($xform, 'compile');
847 &push_phony_cleaners ('compile');
849 # If using X, include some extra variable definitions. NOTE
850 # we don't want to force these into CFLAGS or anything,
851 # because not all programs will necessarily use X.
855 foreach $var ('X_CFLAGS', 'X_LIBS', 'X_EXTRA_LIBS', 'X_PRE_LIBS')
857 &define_configure_variable ($var);
861 push (@suffixes, '.c', '.o');
862 push (@suffixes, '.obj') if $seen_objext;
863 push (@clean, 'compile');
865 $included_generic_compile = 1;
868 if ($seen_libtool && ! $included_libtool_compile)
870 # Output the libtool compilation rules.
871 $output_rules .= &file_contents ('libtool');
873 &push_phony_cleaners ('libtool');
875 push (@suffixes, '.lo');
876 push (@clean, 'libtool');
878 $included_libtool_compile = 1;
881 # Check for automatic de-ANSI-fication.
882 if (defined $options{'ansi2knr'})
884 $extension = '$U' . $extension;
885 if (! $included_knr_compile)
887 if (! $am_c_prototypes)
889 &am_line_error ('AUTOMAKE_OPTIONS',
890 "option \`ansi2knr' in use but \`AM_C_PROTOTYPES' not in \`$configure_ac'");
891 &keyed_aclocal_warning ('AM_C_PROTOTYPES');
892 # Only give this error once.
893 $am_c_prototypes = 1;
896 # Only require ansi2knr files if they should appear in
898 if ($options{'ansi2knr'} eq 'ansi2knr')
900 &require_file_with_line ('AUTOMAKE_OPTIONS', $FOREIGN,
901 'ansi2knr.c', 'ansi2knr.1');
902 $output_rules .= &file_contents ('kr-extra');
903 push (@clean, 'krextra');
904 &push_phony_cleaners ('krextra');
907 # Generate rules to build ansi2knr. If it is in some
908 # other directory, then generate dependencies but have the
909 # rule just run elsewhere.
910 $objext = $seen_objext ? ".\$(OBJEXT)" : ".o";
911 $output_rules .= ($options{'ansi2knr'} . ': '
912 . $options{'ansi2knr'} . $objext . "\n");
913 if ($options{'ansi2knr'} eq 'ansi2knr')
915 $output_rules .= ("\t\$(LINK) ansi2knr" . $objext
917 . "ansi2knr" . $objext
918 . ": \$(CONFIG_HEADER)\n\n");
922 $output_rules .= ("\tcd " . &dirname ($options{'ansi2knr'})
923 . " && \$(MAKE) \$(AM_MAKEFLAGS) "
925 # This is required for non-GNU makes.
926 $output_rules .= ($options{'ansi2knr'} . $objext . ":\n");
927 $output_rules .= ("\tcd " . &dirname ($options{'ansi2knr'})
928 . " && \$(MAKE) \$(AM_MAKEFLAGS)"
929 . " ansi2knr" . $objext . "\n\n");
932 # Make sure ansi2knr can be found: if no path specified,
934 if ($options{'ansi2knr'} eq 'ansi2knr')
936 # Substitution from AM_C_PROTOTYPES. This makes it be
937 # built only when necessary.
938 &define_configure_variable ('ANSI2KNR');
939 # ansi2knr needs to be built before subdirs, so unshift it.
940 unshift (@all, '$(ANSI2KNR)');
944 # Found in another directory.
945 &define_variable ("ANSI2KNR", $options{'ansi2knr'});
948 $output_rules .= &file_contents ('clean-kr');
951 &push_phony_cleaners ('kr');
953 $included_knr_compile = 1;
960 # Call finish function for each language that was used.
963 local ($ltcompile, $ltlink) = &libtool_compiler;
965 local ($ext, $name, $lang, %done);
967 foreach $ext (sort keys %extension_seen)
969 $lang = $extension_map{$ext};
971 # Generate the appropriate rules for this extension. If
972 # dependency tracking was requested, and this extension
973 # supports it, then we don't generate the rule here.
976 if ($use_dependencies && $language_map{$lang . '-autodep'} ne 'no')
978 # Don't generate the rule, but still generate the variables.
979 if (defined $language_map{$lang . '-compile'})
981 $comp = $language_map{$lang . '-compile'};
984 elsif (defined $language_map{$lang . '-compile'})
986 $comp = $language_map{$lang . '-compile'};
988 local ($outarg) = $language_map{$lang . '-output-arg'};
989 if ($language_map{$lang . '-flags'} eq 'CFLAGS')
991 # C compilers don't always support -c -o.
992 if (defined $options{'subdir-objects'})
998 local ($full) = ("\t\$("
999 . $language_map{$lang . '-compiler-name'}
1002 $output_rules .= (".$ext.o:\n"
1005 # FIXME: Using cygpath should be somehow conditional.
1006 $output_rules .= (".$ext.obj:\n"
1008 . " \`cygpath -w \$<\`\n")
1010 $output_rules .= (".$ext.lo:\n"
1012 . $language_map{$lang . '-compiler-name'}
1014 . $language_map{$lang . '-output-arg'}
1015 # We can always use -c -o with libtool.
1016 . ($language_map{$lang . '-flags'} eq 'CFLAGS'
1022 push (@suffixes, '.' . $ext);
1024 # The rest of the loop is done once per language.
1025 next if defined $done{$lang};
1028 $non_c = 0 if $lang !~ /(objc|cxx|f77|ratfor)$/;
1032 &define_compiler_variable ($language_map{$lang . '-compiler-name'},
1035 # The compiler's flag must be a configure variable.
1036 if (defined $language_map{$lang . '-flags'})
1038 &define_configure_variable ($language_map{$lang . '-flags'});
1041 # Compute the function name of the finisher and then call it.
1042 $name = 'lang_' . $lang . '_finish';
1046 # If the project is entirely C++ or entirely Fortran 77, don't
1047 # bother with the C stuff. But if anything else creeps in, then use
1049 if ($need_link || ! $non_c || scalar keys %suffix_rules > 0)
1051 if (! defined $done{'c'})
1053 &define_configure_variable ($language_map{'c-flags'});
1054 &define_compiler_variable ($language_map{'c-compiler-name'},
1056 $language_map{'c-compile'});
1058 &define_variable ('CCLD', '$(CC)');
1059 &define_variable ('LINK', $ltlink . '$(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@');
1063 # Output a rule to build from a YACC source. The output from YACC is
1064 # compiled with C or C++, depending on the extension of the YACC file.
1065 sub output_yacc_build_rule
1067 local ($yacc_suffix, $use_ylwrap, $c_suffix) = @_;
1070 ($suffix = $yacc_suffix) =~ tr/y/c/;
1071 push (@suffixes, $yacc_suffix, $suffix);
1073 # Generate rule for c/c++.
1074 $output_rules .= "$yacc_suffix$suffix:\n\t";
1078 $output_rules .= ('$(SHELL) $(YLWRAP)'
1079 . ' "$(YACC)" $< y.tab.c $*' . $suffix
1080 . ' y.tab.h $*.h -- $(AM_YFLAGS) $(YFLAGS)');
1084 $output_rules .= ('$(YACC) $(AM_YFLAGS) $(YFLAGS) $< && mv y.tab.c $*'
1086 . "\tif test -f y.tab.h; then \\\n"
1087 . "\tif cmp -s y.tab.h \$*.h; then rm -f y.tab.h; else mv y.tab.h \$*.h; fi; \\\n"
1090 $output_rules .= "\n";
1093 sub output_lex_build_rule
1095 local ($lex_suffix, $use_ylwrap) = @_;
1098 ($c_suffix = $lex_suffix) =~ tr/l/c/;
1099 push (@suffixes, $lex_suffix);
1100 &define_configure_variable ('LEX_OUTPUT_ROOT');
1101 &define_configure_variable ('LEXLIB');
1102 $output_rules .= "$lex_suffix$c_suffix:\n\t";
1106 # Is the $@ correct here? If so, why not use it in the ylwrap
1107 # build rule for yacc above?
1108 $output_rules .= '$(SHELL) $(YLWRAP)'
1109 . ' "$(LEX)" $< $(LEX_OUTPUT_ROOT).c $@ -- $(AM_LFLAGS) $(LFLAGS)';
1113 $output_rules .= '$(LEX) $(AM_LFLAGS) $(LFLAGS) $< && mv $(LEX_OUTPUT_ROOT).c $@';
1115 $output_rules .= "\n";
1119 # Check to make sure a source defined in LIBOBJS is not explicitly
1120 # mentioned. This is a separate function (as opposed to being inlined
1121 # in handle_source_transform) because it isn't always appropriate to
1123 sub check_libobjs_sources
1125 local ($one_file, $unxformed) = @_;
1127 local ($prefix, $file, @files);
1128 foreach $prefix ('', 'EXTRA_', 'dist_', 'nodist_',
1129 'dist_EXTRA_', 'nodist_EXTRA_')
1131 if (&variable_defined ($prefix . $one_file . '_SOURCES'))
1133 @files = &variable_value_as_list (($prefix
1134 . $one_file . '_SOURCES'),
1137 elsif ($prefix eq '')
1139 @files = ($unxformed . '.c');
1146 foreach $file (@files)
1148 if (defined $libsources{$file})
1150 &am_line_error ($prefix . $one_file . '_SOURCES',
1151 "automatically discovered file \`$file' should not be explicitly mentioned");
1157 # Does much of the actual work for handle_source_transform.
1159 # name of resulting executable or library ("derived")
1160 # object extension (e.g., `$U.lo')
1161 # list of source files to transform
1163 # first element is name of linker to use (empty string for default linker)
1164 # remaining elements are names of objects
1165 sub handle_single_transform_list
1167 local ($var, $derived, $obj, @files) = @_;
1168 local (@result) = ();
1169 local ($nonansi_obj) = $obj;
1170 $nonansi_obj =~ s/\$U//g;
1171 local (%linkers_used) = ();
1174 # Turn sources into objects.
1177 # Configure substitutions in _SOURCES variables are errors.
1180 &am_line_error ($var, "$var includes configure substitution \`$_'");
1184 # If the source file is in a subdirectory then the `.o' is
1185 # put into the current directory.
1187 # Split file name into base and extension.
1188 local ($full, $directory, $base, $extension, $linker, $object);
1189 next if ! /^((.*)\/)?([^\/]*)\.(.*)$/;
1195 local ($xbase) = $base;
1197 # We must generate a rule for the object if it requires
1200 local ($renamed) = 0;
1202 $extension = &derive_suffix ($extension);
1203 local ($lang) = $extension_map{$extension};
1206 &saw_extension ($extension);
1207 # Found the language, so see what it says.
1208 local ($subr) = 'lang_' . $lang . '_rewrite';
1209 # Note: computed subr call.
1210 local ($r) = & $subr ($directory, $base, $extension);
1211 # Skip this entry if we were asked not to process it.
1212 next if $r == $LANG_IGNORE;
1214 # Now extract linker and other info.
1215 $linker = $language_map{$lang . '-linker'};
1217 local ($this_obj_ext);
1218 if ($language_map{$lang . '-ansi-p'})
1220 $object = $base . $obj;
1221 $this_obj_ext = $obj;
1225 $object = $base . $nonansi_obj;
1226 $this_obj_ext = $nonansi_obj;
1229 if ($language_map{$lang . '-flags'} ne ''
1230 && &variable_defined ($derived . '_'
1231 . $language_map{$lang . '-flags'}))
1233 # We have a per-executable flag in effect for this
1234 # object. In this case we rewrite the object's
1235 # name to ensure it is unique. We also require
1236 # the `compile' program to deal with compilers
1237 # where `-c -o' does not work.
1239 # We choose the name `DERIVED-OBJECT' to ensure
1240 # (1) uniqueness, and (2) continuity between
1241 # invocations. However, this will result in a
1242 # name that is too long for losing systems, in
1243 # some situations. So we provide _SHORTNAME to
1246 local ($dname) = $derived;
1247 if (&variable_defined ($derived . '_SHORTNAME'))
1249 # FIXME: should use the same conditional as
1250 # the _SOURCES variable. But this is really
1251 # silly overkill -- nobody should have
1252 # conditional shortnames.
1253 $dname = &variable_value ($derived . '_SHORTNAME');
1255 $object = $dname . '-' . $object;
1257 &require_file ($FOREIGN, 'compile')
1260 if (! defined $language_map{$lang . '-compile'})
1262 print STDERR "automake: programming error: $lang flags defined without compiler\n";
1265 # Compute the rule to compile this object.
1266 local ($flag) = $language_map{$lang . '-flags'};
1267 local ($val) = "(${derived}_${flag}";
1268 ($rule = $language_map{$lang . '-compile'}) =~
1271 $rule .= ' ' . $language_map{$lang . '-output-arg'};
1272 # For C we have to add the -o, because the
1273 # standard rule doesn't include it.
1274 if ($language_map{$lang . '-flags'} eq 'CFLAGS')
1282 # If rewrite said it was ok, put the object into a
1284 if ($r == $LANG_SUBDIR && $directory ne '')
1286 $object = $directory . '/' . $object;
1287 $xbase = $directory . '/' . $base;
1290 # If doing dependency tracking, then we can't print
1291 # the rule. If we have a subdir object, we need to
1292 # generate an explicit rule. Actually, in any case
1293 # where the object is not in `.' we need a special
1294 # rule. The per-object rules in this case are
1295 # generated later, by add_depend2.
1296 if (($use_dependencies
1298 && $language_map{$lang . '-autodep'} ne 'no')
1299 || $directory ne '')
1302 local ($obj_sans_ext) = substr ($object, 0,
1303 - length ($this_obj_ext));
1304 $lang_specific_files{$lang} .= (' ' . $derived
1306 . ' ' . $obj_sans_ext);
1309 elsif ($extension eq 'o')
1311 # This is probably the result of a direct suffix rule.
1312 # In this case we just accept the rewrite. FIXME:
1313 # this fails if we want libtool objects.
1314 $object = $base . '.' . $extension;
1319 # No error message here. Used to have one, but it was
1324 $linkers_used{$linker} = 1;
1326 push (@result, $object);
1328 if (defined $object_map{$object})
1330 if ($object_map{$object} ne $full)
1332 &am_error ("object \`$object' created by \`$full' and \`$object_map{$object}'");
1337 local (@dep_list) = ();
1338 $object_map{$object} = $full;
1340 # If file is in subdirectory, we need explicit
1342 if ($directory ne '' || $renamed)
1344 push (@dep_list, $full);
1347 # If resulting object is in subdir, we need to make
1348 # sure the subdir exists at build time.
1349 if ($object =~ /\//)
1351 # FIXME: check that $DIRECTORY is somewhere in the
1354 # We don't allow `..' in object file names for
1355 # *any* source, not just Java. For Java it just
1356 # doesn't make sense, but in general it is
1357 # a problem because we can't pick a good name for
1359 if ($object =~ /(\/|^)\.\.\//)
1361 &am_error ("\`$full' contains \`..' component but should not");
1364 push (@dep_list, $directory . '/.dirstamp');
1366 # If we're generating dependencies, we also want
1367 # to make sure that the appropriate subdir of the
1368 # .deps directory is created.
1369 if ($use_dependencies)
1371 push (@dep_list, '.deps/' . $directory . '/.dirstamp');
1374 if (! defined $directory_map{$directory})
1376 $directory_map{$directory} = 1;
1377 $output_rules .= ($directory . "/.dirstamp:\n"
1378 . "\t\@\$(mkinstalldirs) $directory\n"
1379 . "\t\@: > $directory/.dirstamp\n");
1380 if ($use_dependencies)
1382 $output_rules .= ('.deps/' . $directory
1384 . "\t\@\$(mkinstalldirs) .deps/$directory\n"
1385 . "\t\@: > .deps/$directory/.dirstamp\n");
1390 &pretty_print_rule ($object . ':', "\t", @dep_list)
1391 if scalar @dep_list > 0 || $rule ne '';
1393 # Print the rule if we have one.
1396 # Turn `$@' into name of our object file.
1398 ($xform = $object) =~ s,/,\\/,g;
1399 $rule =~ s/\$\@/$xform/;
1401 # We cannot use $< here since this is an explicit
1402 # rule and not all makes handle that.
1403 $rule .= " \`test -f $full || echo '\$(srcdir)/'\`$full";
1405 # FIXME: handle .lo and .obj as well.
1406 $output_rules .= "\t" . $rule . "\n";
1410 # Transform .o or $o file into .P file (for automatic
1413 && ($language_map{$lang . '-autodep'} ne 'no'
1414 || $language_map{$lang . '-derived-autodep'} eq 'yes'))
1416 local ($depfile) = $object;
1417 $depfile =~ s/\.([^.]*)$/.P$1/;
1418 $depfile =~ s/\$\(OBJEXT\)$/o/ if $seen_objext;
1419 $dep_files{'$(DEPDIR)/' . $depfile} = 1;
1424 return (&resolve_linker (%linkers_used), @result);
1427 # Handle SOURCE->OBJECT transform for one program or library.
1429 # canonical (transformed) name of object to build
1430 # actual name of object to build
1431 # object extension (ie either `.o' or `$o'.
1432 # Return result is name of linker variable that must be used.
1433 # Empty return means just use `LINK'.
1434 sub handle_source_transform
1436 # one_file is canonical name. unxformed is given name. obj is
1438 local ($one_file, $unxformed, $obj) = @_;
1440 local ($linker) = '';
1442 if (&variable_defined ($one_file . "_OBJECTS"))
1444 &am_line_error ($one_file . '_OBJECTS',
1445 $one_file . '_OBJECTS', 'should not be defined');
1446 # No point in continuing.
1450 local (@files, @result, $prefix, $temp, $xpfx);
1451 local (%used_pfx) = ();
1452 foreach $prefix ('', 'EXTRA_', 'dist_', 'nodist_',
1453 'dist_EXTRA_', 'nodist_EXTRA_')
1455 # We are going to define _OBJECTS variables using the prefix.
1456 # Then we glom them all together. So we can't use the null
1457 # prefix here as we need it later.
1458 $xpfx = ($prefix eq '') ? 'am_' : $prefix;
1461 local ($var) = $prefix . $one_file . "_SOURCES";
1462 if (&variable_defined ($var))
1464 # Keep track of which prefixes we saw.
1465 $used_pfx{$xpfx} = 1
1466 unless $prefix =~ /EXTRA_/;
1468 push (@sources, '$(' . $prefix . $one_file . "_SOURCES)");
1469 push (@objects, '$(' . $xpfx . $one_file . "_OBJECTS)")
1470 unless $prefix =~ /EXTRA_/;
1471 push (@dist_sources, '$(' . $prefix . $one_file . "_SOURCES)")
1472 unless $prefix =~ /^nodist_/;
1473 local (@conds) = &variable_conditions ($var);
1476 @files = &variable_value_as_list ($var, '');
1481 foreach $cond (@conds)
1483 @files = &variable_value_as_list ($var, $cond);
1485 &handle_single_transform_list ($var, $one_file, $obj,
1487 $linker = $temp if $linker eq '';
1489 # Define _OBJECTS conditionally.
1490 &define_pretty_variable ($xpfx . $one_file . '_OBJECTS',
1492 unless $prefix =~ /EXTRA_/;
1499 # Avoid defining needless variables.
1500 next if (scalar @files == 0);
1502 ($temp, @result) = &handle_single_transform_list ($var, $one_file,
1504 $linker = $temp if $linker eq '';
1505 &define_pretty_variable ($xpfx . $one_file . "_OBJECTS", '', @result)
1506 unless $prefix =~ /EXTRA_/;
1509 local (@keys) = sort keys %used_pfx;
1510 if (scalar @keys == 0)
1512 &define_variable ($one_file . "_SOURCES", $unxformed . ".c");
1513 push (@sources, $unxformed . '.c');
1514 push (@dist_sources, $unxformed . '.c');
1515 push (@objects, $unxformed . $obj);
1516 push (@files, $unxformed . '.c');
1518 ($temp, @result) = &handle_single_transform_list ($one_file . '_SOURCES',
1521 $linker = $temp if $linker eq '';
1522 &define_pretty_variable ($one_file . "_OBJECTS", '', @result)
1526 grep ($_ = '$(' . $_ . $one_file . '_OBJECTS)', @keys);
1527 &define_pretty_variable ($one_file . '_OBJECTS', '', @keys);
1530 # If we want to use `LINK' we must make sure it is defined.
1540 # handle_lib_objects ()
1541 # ---------------------
1542 # Special-case @ALLOCA@ and @LIBOBJS@ in _LDADD or _LIBADD variables.
1543 # Also, generate _DEPENDENCIES variable if appropriate.
1545 # transformed name of object being built, or empty string if no object
1546 # name of _LDADD/_LIBADD-type variable to examine
1547 # boolean (lex_seen) which is true if a lex source file was seen in this
1548 # object. valid only for LDADDs, not LIBADDs.
1549 # Returns 1 if LIBOBJS seen, 0 otherwise.
1550 sub handle_lib_objects
1552 local ($xname, $var, $lex_seen) = @_;
1555 die "automake: programming error 1 in handle_lib_objects\n"
1556 if ! &variable_defined ($var);
1558 die "automake: programming error 2 in handle_lib_objects\n"
1559 if $lex_seen && $var =~ /LIBADD/;
1561 local (@conds) = &variable_conditions ($var);
1564 $ret = &handle_lib_objects_cond ($xname, $var, $lex_seen, '');
1570 foreach $cond (@conds)
1572 if (&handle_lib_objects_cond ($xname, $var, $lex_seen, $cond))
1582 # Subroutine of handle_lib_objects: handle a particular condition.
1583 sub handle_lib_objects_cond
1585 local ($xname, $var, $lex_seen, $cond) = @_;
1587 # We recognize certain things that are commonly put in LIBADD or
1590 local (@dep_list) = ();
1592 local ($seen_libobjs) = 0;
1593 local ($flagvar) = 0;
1595 foreach $lsearch (&variable_value_as_list ($var, $cond))
1597 # Skip -lfoo and -Ldir; these are explicitly allowed.
1598 next if $lsearch =~ /^-[lL]/;
1599 if (! $flagvar && $lsearch =~ /^-/)
1601 if ($var =~ /^(.*)LDADD$/)
1603 # Skip -dlopen and -dlpreopen; these are explicitly allowed.
1604 next if $lsearch =~ /^-dl(pre)?open$/;
1605 &am_line_error ($var, "linker flags such as \`$lsearch' belong in \`${1}LDFLAGS");
1609 # Only get this error once.
1611 &am_line_error ($var, "linker flags such as \`$lsearch' belong in \`${1}LDFLAGS");
1615 # Assume we have a file of some sort, and push it onto the
1616 # dependency list. Autoconf substitutions are not pushed;
1617 # rarely is a new dependency substituted into (eg) foo_LDADD
1618 # -- but "bad things (eg -lX11) are routinely substituted.
1619 # Note that LIBOBJS and ALLOCA are exceptions to this rule,
1620 # and handled specially below.
1621 push (@dep_list, $lsearch)
1622 unless $lsearch =~ /^\@.*\@$/;
1624 # Automatically handle @LIBOBJS@ and @ALLOCA@. Basically this
1625 # means adding entries to dep_files.
1626 if ($lsearch =~ /^\@(LT)?LIBOBJS\@$/)
1628 local ($myobjext) = ($1 ? 'l' : '') . 'o';
1630 push (@dep_list, $lsearch);
1632 if (! keys %libsources
1633 && ! &variable_defined ($1 . 'LIBOBJS'))
1635 &am_line_error ($var, "\@$1" . "LIBOBJS\@ seen but never set in \`$configure_ac'");
1638 local ($iter, $rewrite);
1639 foreach $iter (keys %libsources)
1641 if ($iter =~ /\.([cly])$/)
1643 &saw_extension ($1);
1644 &saw_extension ('c');
1647 if ($iter =~ /\.h$/)
1649 &require_file_with_line ($var, $FOREIGN, $iter);
1651 elsif ($iter ne 'alloca.c')
1653 ($rewrite = $iter) =~ s/\.c$/.P$myobjext/;
1654 $dep_files{'$(DEPDIR)/' . $rewrite} = 1;
1655 ($rewrite = $iter) =~ s/(\W)/\\$1/g;
1656 $rewrite = "^" . $rewrite . "\$";
1657 # Only require the file if it is not a built source.
1658 if (! &variable_defined ('BUILT_SOURCES')
1659 || ! grep (/$rewrite/,
1660 &variable_value_as_list ('BUILT_SOURCES',
1663 &require_file_with_line ($var, $FOREIGN, $iter);
1668 elsif ($lsearch =~ /^\@(LT)?ALLOCA\@$/)
1670 local ($myobjext) = ($1 ? 'l' : '') . 'o';
1672 push (@dep_list, $lsearch);
1673 &am_line_error ($var,
1674 "\@$1" . "ALLOCA\@ seen but \`AC_FUNC_ALLOCA' not in \`$configure_ac'")
1675 if ! defined $libsources{'alloca.c'};
1676 $dep_files{'$(DEPDIR)/alloca.P' . $myobjext} = 1;
1677 &require_file_with_line ($var, $FOREIGN, 'alloca.c');
1678 &saw_extension ('c');
1682 if ($xname ne '' && ! &variable_defined ($xname . '_DEPENDENCIES', $cond))
1684 &define_pretty_variable ($xname . '_DEPENDENCIES', $cond, @dep_list);
1687 return $seen_libobjs;
1690 # Canonicalize a name, and check to make sure the non-canonical name
1691 # is never used. Returns canonical name. Arguments are name and a
1692 # list of suffixes to check for.
1693 sub check_canonical_spelling
1695 local ($name, @suffixes) = @_;
1696 local ($xname, $xt);
1698 ($xname = $name) =~ tr/A-Za-z0-9_/_/c;
1699 if ($xname ne $name)
1702 foreach $xt (@suffixes)
1704 &am_line_error ($name . $xt,
1705 "invalid variable \`" . $name . $xt
1706 . "'; should be \`" . $xname . $xt . "'")
1707 if &variable_defined ($name . $xt);
1715 # handle_programs ()
1716 # ------------------
1717 # Handle C programs.
1720 local (@proglist) = &am_install_var ('-clean',
1721 'progs', 'PROGRAMS',
1722 'bin', 'sbin', 'libexec', 'pkglib',
1724 return if ! @proglist;
1726 # If a program is installed, this is required. We only want this
1727 # error to appear once.
1728 &am_conf_error ("AC_ARG_PROGRAM must be used")
1729 unless $seen_arg_prog;
1732 local ($one_file, $xname, $munge);
1734 local ($seen_libobjs) = 0;
1735 foreach $one_file (@proglist)
1737 local ($obj) = &get_object_extension ($one_file);
1739 # Canonicalize names and check for misspellings.
1740 $xname = &check_canonical_spelling ($one_file, '_LDADD', '_LDFLAGS',
1741 '_SOURCES', '_OBJECTS',
1744 # FIXME: Using a trick to figure out if any lex sources appear
1745 # in our program; should use some cleaner method.
1746 local ($lex_num) = scalar (keys %lex_sources);
1747 local ($linker) = &handle_source_transform ($xname, $one_file, $obj);
1748 local ($lex_file_seen) = (scalar (keys %lex_sources) > $lex_num);
1751 if (&variable_defined ($xname . "_LDADD"))
1753 if (&handle_lib_objects ($xname, $xname . '_LDADD',
1763 # User didn't define prog_LDADD override. So do it.
1764 &define_variable ($xname . '_LDADD', '$(LDADD)');
1766 # This does a bit too much work. But we need it to
1767 # generate _DEPENDENCIES when appropriate.
1768 if (&variable_defined ('LDADD'))
1770 if (&handle_lib_objects ($xname, 'LDADD', $lex_file_seen))
1776 elsif (! &variable_defined ($xname . '_DEPENDENCIES'))
1778 &define_variable ($xname . '_DEPENDENCIES', '');
1783 if (&variable_defined ($xname . '_LIBADD'))
1785 &am_line_error ($xname . '_LIBADD',
1786 "use \`" . $xname . "_LDADD', not \`"
1787 . $xname . "_LIBADD'");
1790 if (! &variable_defined ($xname . '_LDFLAGS'))
1792 # Define the prog_LDFLAGS variable.
1793 &define_variable ($xname . '_LDFLAGS', '');
1796 # Determine program to use for link.
1798 if (&variable_defined ($xname . '_LINK'))
1800 $xlink = $xname . '_LINK';
1804 $xlink = $linker ? $linker : 'LINK';
1807 local ($exeext) = '';
1808 if ($seen_exeext && $one_file !~ /\./)
1810 $exeext = '$(EXEEXT)';
1814 &file_contents_with_transform
1815 (&transform ('EXEEXT' => $exeext,
1816 'PROGRAM' => $one_file,
1817 'XPROGRAM' => $xname,
1822 if (&variable_defined ('LDADD') && &handle_lib_objects ('', 'LDADD', 0))
1829 foreach $one_file (@proglist)
1831 # Canonicalize names.
1832 ($xname = $one_file) =~ tr/A-Za-z0-9_/_/c;
1834 if (&variable_defined ($xname . '_LDADD'))
1836 &check_libobjs_sources ($xname, $xname . '_LDADD');
1838 elsif (&variable_defined ('LDADD'))
1840 &check_libobjs_sources ($xname, 'LDADD');
1847 # handle_libraries ()
1848 # -------------------
1850 sub handle_libraries
1852 local (@liblist) = &am_install_var ('-clean',
1853 'libs', 'LIBRARIES',
1854 'lib', 'pkglib', 'noinst', 'check');
1855 return if ! @liblist;
1857 local (%valid) = &am_primary_prefixes ('LIBRARIES', 0, 'lib', 'pkglib',
1859 if (! defined $configure_vars{'RANLIB'})
1862 foreach $key (keys %valid)
1864 if (&variable_defined ($key . '_LIBRARIES'))
1866 &am_line_error ($key . '_LIBRARIES', "library used but \`RANLIB' not defined in \`$configure_ac'");
1867 # Only get this error once. If this is ever printed,
1869 $configure_vars{'RANLIB'} = 'BUG';
1878 local ($seen_libobjs) = 0;
1879 foreach $onelib (@liblist)
1881 # Check that the library fits the standard naming convention.
1882 if ($onelib !~ /^lib.*\.a$/)
1884 # FIXME should put line number here. That means mapping
1885 # from library name back to variable name.
1886 &am_error ("\`$onelib' is not a standard library name");
1889 local ($obj) = &get_object_extension ($onelib);
1891 # Canonicalize names and check for misspellings.
1892 $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_SOURCES',
1893 '_OBJECTS', '_DEPENDENCIES', '_AR');
1895 if (! &variable_defined ($xlib . '_AR'))
1897 &define_variable ($xlib . '_AR', '$(AR) cru');
1900 if (&variable_defined ($xlib . '_LIBADD'))
1902 if (&handle_lib_objects ($xlib, $xlib . '_LIBADD', 0))
1909 # Generate support for conditional object inclusion in
1911 &define_variable ($xlib . "_LIBADD", '');
1914 if (&variable_defined ($xlib . '_LDADD'))
1916 &am_line_error ($xlib . '_LDADD',
1917 "use \`" . $xlib . "_LIBADD', not \`"
1918 . $xlib . "_LDADD'");
1921 # Make sure we at look at this.
1922 &examine_variable ($xlib . '_DEPENDENCIES');
1924 &handle_source_transform ($xlib, $onelib, $obj);
1927 &file_contents_with_transform
1928 (&transform ('LIBRARY' => $onelib,
1929 'XLIBRARY' => $xlib),
1935 foreach $onelib (@liblist)
1937 # Canonicalize names.
1938 ($xlib = $onelib) =~ tr/A-Za-z0-9_/_/c;
1939 if (&variable_defined ($xlib . '_LIBADD'))
1941 &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
1946 &define_variable ('AR', 'ar');
1947 &define_configure_variable ('RANLIB');
1951 # handle_ltlibraries ()
1952 # ---------------------
1953 # Handle shared libraries.
1954 sub handle_ltlibraries
1956 local (@liblist) = &am_install_var ('-clean',
1957 'ltlib', 'LTLIBRARIES',
1958 'noinst', 'lib', 'pkglib', 'check');
1959 return if ! @liblist;
1962 local (%valid) = &am_primary_prefixes ('LTLIBRARIES', 0, 'lib', 'pkglib',
1966 foreach $key (keys %valid)
1968 if (&variable_defined ($key . '_LTLIBRARIES'))
1972 &am_line_error ($key . '_LTLIBRARIES', "library used but \`LIBTOOL' not defined in \`$configure_ac'");
1973 # Only get this error once. If this is ever printed,
1975 $configure_vars{'LIBTOOL'} = 'BUG';
1979 # Get the installation directory of each library.
1980 for (&variable_value_as_list ($key . '_LTLIBRARIES', 'all'))
1984 &am_error ("\`$_' is already going to be installed in \`$instdirs{$_}'");
1988 $instdirs{$_} = $key;
1997 local ($seen_libobjs) = 0;
1998 foreach $onelib (@liblist)
2000 local ($obj) = &get_object_extension ($onelib);
2002 # Canonicalize names and check for misspellings.
2003 $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_LDFLAGS',
2004 '_SOURCES', '_OBJECTS',
2007 if (! &variable_defined ($xlib . '_LDFLAGS'))
2009 # Define the lib_LDFLAGS variable.
2010 &define_variable ($xlib . '_LDFLAGS', '');
2013 # Check that the library fits the standard naming convention.
2014 $libname_rx = "^lib.*\.la";
2015 if ((&variable_defined ($xlib . '_LDFLAGS')
2016 && grep (/-module/, &variable_value_as_list ($xlib . '_LDFLAGS',
2018 || (&variable_defined ('LDFLAGS')
2019 && grep (/-module/, &variable_value_as_list ('LDFLAGS',
2022 # Relax name checking for libtool modules.
2023 $libname_rx = "\.la";
2025 if ($onelib !~ /$libname_rx$/)
2027 # FIXME this should only be a warning for foreign packages
2028 # FIXME should put line number here. That means mapping
2029 # from library name back to variable name.
2030 &am_error ("\`$onelib' is not a standard libtool library name");
2033 if (&variable_defined ($xlib . '_LIBADD'))
2035 if (&handle_lib_objects ($xlib, $xlib . '_LIBADD', 0))
2042 # Generate support for conditional object inclusion in
2044 &define_variable ($xlib . "_LIBADD", '');
2047 if (&variable_defined ($xlib . '_LDADD'))
2049 &am_line_error ($xlib . '_LDADD',
2050 "use \`" . $xlib . "_LIBADD', not \`"
2051 . $xlib . "_LDADD'");
2054 # Make sure we at look at this.
2055 &examine_variable ($xlib . '_DEPENDENCIES');
2057 local ($linker) = &handle_source_transform ($xlib, $onelib, $obj);
2059 # Determine program to use for link.
2061 if (&variable_defined ($xlib . '_LINK'))
2063 $xlink = $xlib . '_LINK';
2067 $xlink = $linker ? $linker : 'LINK';
2071 if ($instdirs{$onelib} eq 'EXTRA'
2072 || $instdirs{$onelib} eq 'noinst'
2073 || $instdirs{$onelib} eq 'check')
2075 # It's an EXTRA_ library, so we can't specify -rpath,
2076 # because we don't know where the library will end up.
2077 # The user probably knows, but generally speaking automake
2078 # doesn't -- and in fact configure could decide
2079 # dynamically between two different locations.
2084 $rpath = ('-rpath $(' . $instdirs{$onelib} . 'dir)');
2088 &file_contents_with_transform
2089 (&transform ('LTLIBRARY' => $onelib,
2090 'XLTLIBRARY' => $xlib,
2098 foreach $onelib (@liblist)
2100 # Canonicalize names.
2101 ($xlib = $onelib) =~ tr/A-Za-z0-9_/_/c;
2102 if (&variable_defined ($xlib . '_LIBADD'))
2104 &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
2110 # See if any _SOURCES variable were misspelled. Also, make sure that
2111 # EXTRA_ variables don't contain configure substitutions.
2114 local ($varname, $primary);
2115 foreach $varname (keys %contents)
2117 foreach $primary ('_SOURCES', '_LIBADD', '_LDADD', '_LDFLAGS',
2120 if ($varname =~ /$primary$/ && ! $content_seen{$varname})
2122 &am_line_error ($varname,
2123 "invalid unused variable name: \`$varname'");
2132 # NOTE we no longer automatically clean SCRIPTS, because it is
2133 # useful to sometimes distribute scripts verbatim. This happens
2134 # eg in Automake itself.
2135 &am_install_var ('-candist', 'scripts', 'SCRIPTS',
2136 'bin', 'sbin', 'libexec', 'pkgdata',
2139 local ($scripts_installed) = 0;
2140 # Set $scripts_installed if appropriate. Make sure we only find
2141 # scripts which are actually installed -- this is why we can't
2142 # simply use the return value of am_install_var.
2143 local (%valid) = &am_primary_prefixes ('SCRIPTS', 1, 'bin', 'sbin',
2144 'libexec', 'pkgdata',
2147 foreach $key (keys %valid)
2149 if ($key ne 'noinst'
2151 && &variable_defined ($key . '_SCRIPTS'))
2153 $scripts_installed = 1;
2154 # push (@check_tests, 'check-' . $key . 'SCRIPTS');
2158 if ($scripts_installed)
2160 # If a program is installed, this is required. We only want this
2161 # error to appear once.
2162 &am_conf_error ("AC_ARG_PROGRAM must be used")
2163 unless $seen_arg_prog;
2168 # Search a file for a "version.texi" Texinfo include. Return the name
2169 # of the include file if found, or the empty string if not. A
2170 # "version.texi" file is actually any file whose name matches
2172 sub scan_texinfo_file
2174 local ($filename) = @_;
2176 if (! open (TEXI, $filename))
2178 &am_error ("couldn't open \`$filename': $!");
2181 print "automake: reading $filename\n" if $verbose;
2183 local ($vfile, $outfile);
2186 if (/^\@setfilename +(\S+)/)
2192 if (/^\@include\s+(vers[^.]*\.texi)\s*$/)
2194 # Found version.texi include.
2201 return ($outfile, $vfile);
2207 # Handle all Texinfo source.
2210 &am_line_error ('TEXINFOS',
2211 "\`TEXINFOS' is an anachronism; use \`info_TEXINFOS'")
2212 if &variable_defined ('TEXINFOS');
2213 return if (! &variable_defined ('info_TEXINFOS')
2214 && ! &variable_defined ('html_TEXINFOS'));
2216 if (&variable_defined ('html_TEXINFOS'))
2218 &am_line_error ('html_TEXINFOS',
2219 "HTML generation not yet supported");
2223 local (@texis) = &variable_value_as_list ('info_TEXINFOS', 'all');
2225 local (@info_deps_list, @dvis_list, @texi_deps);
2226 local ($infobase, $info_cursor);
2230 local ($tc_cursor, @texi_cleans);
2233 foreach $info_cursor (@texis)
2235 # FIXME: This is mildly hacky, since it recognizes "txinfo".
2236 # I don't feel like making it right.
2237 ($infobase = $info_cursor) =~ s/\.te?xi(nfo)?$//;
2239 # If 'version.texi' is referenced by input file, then include
2240 # automatic versioning capability.
2241 local ($out_file, $vtexi) = &scan_texinfo_file ($relative_dir
2242 . "/" . $info_cursor);
2244 if ($out_file eq '')
2246 &am_error ("\`$info_cursor' missing \@setfilename");
2250 if ($out_file =~ /\.(.+)$/ && $1 ne 'info')
2252 # FIXME should report line number in input file.
2253 &am_error ("output of \`$info_cursor', \`$out_file', has unrecognized extension");
2259 &am_error ("\`$vtexi', included in \`$info_cursor', also included in \`$versions{$vtexi}'")
2260 if (defined $versions{$vtexi});
2261 $versions{$vtexi} = $info_cursor;
2263 # We number the stamp-vti files. This is doable since the
2264 # actual names don't matter much. We only number starting
2265 # with the second one, so that the common case looks nice.
2266 $vti = ($done ? $done : 'vti');
2269 &push_dist_common ($vtexi, 'stamp-' . $vti);
2270 push (@clean, $vti);
2272 &require_conf_file_with_line ('info_TEXINFOS', $FOREIGN,
2276 if ($config_aux_dir eq '.' || $config_aux_dir eq '')
2278 $conf_dir = '$(srcdir)/';
2282 $conf_dir = $config_aux_dir;
2283 $conf_dir .= '/' unless $conf_dir =~ /\/$/;
2286 &file_contents_with_transform
2287 (&transform ('TEXI' => $info_cursor,
2290 'MDDIR' => $conf_dir,
2291 'CONFIGURE_AC' => $configure_ac),
2294 &push_phony_cleaners ($vti);
2297 # If user specified file_TEXINFOS, then use that as explicit
2300 push (@texi_deps, $info_cursor);
2301 # Prefix with $(srcdir) because some version of make won't
2302 # work if the target has it and the dependency doesn't.
2303 push (@texi_deps, '$(srcdir)/' . $vtexi) if $vtexi;
2305 # Canonicalize name first.
2306 ($canonical = $infobase) =~ tr/A-Za-z0-9_/_/c;
2307 if (&variable_defined ($canonical . "_TEXINFOS"))
2309 push (@texi_deps, '$(' . $canonical . '_TEXINFOS)');
2310 &push_dist_common ('$(' . $canonical . '_TEXINFOS)');
2313 $output_rules .= ("\n" . $out_file . ": "
2314 . join (' ', @texi_deps)
2315 . "\n" . $infobase . ".dvi: "
2316 . join (' ', @texi_deps)
2319 push (@info_deps_list, $out_file);
2320 push (@dvis_list, $infobase . '.dvi');
2322 # Generate list of things to clean for this target. We do
2323 # this explicitly because otherwise too many things could be
2324 # removed. In particular the ".log" extension might
2325 # reasonably be used in other contexts by the user.
2326 # FIXME: this is really out of control.
2327 foreach $tc_cursor ('aux', 'cp', 'cps', 'dvi', 'fn', 'fns', 'pgs',
2328 'ky', 'kys', 'ps', 'log', 'pg', 'toc', 'tp', 'tps',
2329 'vr', 'vrs', 'op', 'tr', 'cv', 'cn', 'cm', 'ov')
2331 push (@texi_cleans, $infobase . '.' . $tc_cursor);
2335 # Find these programs wherever they may lie. Yes, this has
2336 # intimate knowledge of the structure of the texinfo distribution.
2337 &define_program_variable ('MAKEINFO', 'build', 'texinfo/makeinfo',
2339 # Circumlocution to avoid accidental
2340 # configure substitution.
2342 &define_program_variable ('TEXI2DVI', 'src', 'texinfo/util',
2345 # Set transform for including texinfos.am. First, handle --cygnus
2350 $xform = 's/^NOTCYGNUS.*$//; s/^CYGNUS//;';
2354 $xform = 's/^CYGNUS.*$//; s/^NOTCYGNUS//;';
2357 # Handle location of texinfo.tex.
2358 local ($need_texi_file) = 0;
2359 local ($texinfodir);
2362 $texinfodir = '$(top_srcdir)/../texinfo';
2363 &define_variable ('TEXINFO_TEX', "$texinfodir/texinfo.tex");
2366 elsif ($config_aux_dir ne '.' && $config_aux_dir ne '')
2368 $texinfodir = $config_aux_dir;
2369 &define_variable ('TEXINFO_TEX', "$texinfodir/texinfo.tex");
2370 $need_texi_file = 2; # so that we require_conf_file later
2372 elsif (&variable_defined ('TEXINFO_TEX'))
2374 # The user defined TEXINFO_TEX so assume he knows what he is
2376 $texinfodir = ('$(srcdir)/'
2377 . &dirname (&variable_value ('TEXINFO_TEX')));
2381 $texinfodir = '$(srcdir)';
2382 $need_texi_file = 1;
2384 $xform .= &transform ('TEXINFODIR' => $texinfodir);
2386 $output_rules .= &file_contents_with_transform ($xform, 'texinfos');
2387 push (@phony, 'install-info-am', 'uninstall-info');
2388 push (@dist_targets, 'dist-info');
2390 # How to clean. The funny name is due to --cygnus influence; in
2391 # Cygnus mode, `clean-info' is a target that users can use.
2392 $output_rules .= "\nmostlyclean-aminfo:\n";
2393 &pretty_print_rule ("\t-rm -f", "\t ", @texi_cleans);
2394 $output_rules .= ("\nclean-aminfo:\n\ndistclean-aminfo:\n\n"
2395 . "maintainer-clean-aminfo:\n\t"
2396 # Eww. But how else can we find all the output
2397 # files from makeinfo?
2398 . ($cygnus_mode ? '' : 'cd $(srcdir) && ')
2399 . 'for i in $(INFO_DEPS); do' . " \\\n"
2400 . "\t" . ' rm -f $$i;' . " \\\n"
2401 . "\t" . ' if test "`echo $$i-[0-9]*`" != "$$i-[0-9]*"; then' . " \\\n"
2402 . "\t" . ' rm -f $$i-[0-9]*;' . " \\\n"
2403 . "\t" . ' fi;' . " \\\n"
2405 &push_phony_cleaners ('aminfo');
2408 $output_rules .= "clean-info: mostlyclean-aminfo\n";
2411 push (@suffixes, '.texi', '.texinfo', '.txi', '.info', '.dvi', '.ps');
2413 if (! defined $options{'no-installinfo'})
2415 push (@uninstall, 'uninstall-info');
2416 push (@installdirs, '$(DESTDIR)$(infodir)');
2417 unshift (@install_data, 'install-info-am');
2419 # Make sure documentation is made and installed first. Use
2420 # $(INFO_DEPS), not 'info', because otherwise recursive makes
2421 # get run twice during "make all".
2422 unshift (@all, '$(INFO_DEPS)');
2424 push (@clean, 'aminfo');
2425 push (@info, '$(INFO_DEPS)');
2426 push (@dvi, '$(DVIS)');
2428 &define_variable ("INFO_DEPS", join (' ', @info_deps_list));
2429 &define_variable ("DVIS", join (' ', @dvis_list));
2430 # This next isn't strictly needed now -- the places that look here
2431 # could easily be changed to look in info_TEXINFOS. But this is
2432 # probably better, in case noinst_TEXINFOS is ever supported.
2433 &define_variable ("TEXINFOS", &variable_value ('info_TEXINFOS'));
2435 # Do some error checking. Note that this file is not required
2436 # when in Cygnus mode; instead we defined TEXINFO_TEX explicitly
2438 if ($need_texi_file && ! defined $options{'no-texinfo.tex'})
2440 if ($need_texi_file > 1)
2442 &require_conf_file_with_line ('info_TEXINFOS', $FOREIGN,
2447 &require_file_with_line ('info_TEXINFOS', $FOREIGN, 'texinfo.tex');
2452 # Handle any man pages.
2453 sub handle_man_pages
2455 &am_line_error ('MANS', "\`MANS' is an anachronism; use \`man_MANS'")
2456 if &variable_defined ('MANS');
2458 # Find all the sections in use. We do this by first looking for
2459 # "standard" sections, and then looking for any additional
2460 # sections used in man_MANS.
2461 local ($sect, %sections, %vlist);
2463 # Add more sections as needed.
2464 foreach $sect ('0'..'9', 'n', 'l')
2466 if (&variable_defined ('man' . $sect . '_MANS'))
2468 $sections{$sect} = 1;
2469 $vlist{'$(man' . $sect . '_MANS)'} = 1;
2474 if (&variable_defined ('man_MANS'))
2476 $vlist{'$(man_MANS)'} = 1;
2477 foreach (&variable_value_as_list ('man_MANS', 'all'))
2479 # A page like `foo.1c' goes into man1dir.
2480 if (/\.([0-9a-z])([a-z]*)$/)
2488 return unless $found;
2490 # Now for each section, generate an install and unintall rule.
2491 # Sort sections so output is deterministic.
2493 foreach $sect (sort keys %sections)
2495 &define_variable ('man' . $sect . 'dir', '$(mandir)/man' . $sect);
2496 push (@installdirs, '$(DESTDIR)$(mandir)/man' . $sect)
2497 unless defined $options{'no-installman'};
2498 $output_rules .= &file_contents_with_transform ('s/\@SECTION\@/'
2501 push (@phony, 'install-man' . $sect, 'uninstall-man' . $sect);
2502 push (@namelist, 'install-man' . $sect);
2505 # We don't really need this, but we use it in case we ever want to
2506 # support noinst_MANS.
2507 &define_variable ("MANS", join (' ', sort keys %vlist));
2509 # Generate list of install dirs.
2510 $output_rules .= ("install-man: \$(MANS)\n"
2511 . "\t\@\$(NORMAL_INSTALL)\n");
2512 &pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ", @namelist);
2513 push (@phony, 'install-man');
2515 $output_rules .= "uninstall-man:\n\t\@\$(NORMAL_UNINSTALL)\n";
2516 grep ($_ = 'un' . $_, @namelist);
2517 &pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ", @namelist);
2518 push (@phony, 'uninstall-man');
2520 $output_vars .= &file_contents ('mans-vars');
2522 if (! defined $options{'no-installman'})
2524 push (@install_data, 'install-man');
2525 push (@uninstall, 'uninstall-man');
2526 push (@all, '$(MANS)');
2530 # Handle DATA variables.
2533 &am_install_var ('-noextra', '-candist', 'data', 'DATA',
2534 'data', 'sysconf', 'sharedstate', 'localstate',
2535 'pkgdata', 'noinst', 'check');
2541 push (@phony, 'tags');
2542 local (@tag_deps) = ();
2543 if (&variable_defined ('SUBDIRS'))
2545 $output_rules .= ("tags-recursive:\n"
2546 . "\tlist=\'\$(SUBDIRS)\'; for subdir in \$\$list; do \\\n"
2547 # Never fail here if a subdir fails; it
2549 . "\t test \"\$\$subdir\" = . || (cd \$\$subdir"
2550 . " && \$(MAKE) \$(AM_MAKEFLAGS) tags); \\\n"
2552 push (@tag_deps, 'tags-recursive');
2553 push (@phony, 'tags-recursive');
2556 if (&saw_sources_p (1)
2557 || &variable_defined ('ETAGS_ARGS')
2560 local ($xform) = '';
2562 foreach $one_hdr (@config_headers)
2564 if ($relative_dir eq &dirname ($one_hdr))
2566 # The config header is in this directory. So require it.
2568 ($var = &basename ($one_hdr)) =~ s/(\W)/\\$1/g;
2569 $xform .= ' ' if $xform;
2573 $xform = ('s/\@CONFIG\@/' . $xform . '/;'
2574 . 's/\@DIRS\@/' . join (' ', @tag_deps) . '/;');
2576 if (&variable_defined ('SUBDIRS'))
2578 $xform .= 's/^SUBDIRS//;';
2582 $xform .= 's/^SUBDIRS.*$//;';
2585 $output_rules .= &file_contents_with_transform ($xform, 'tags');
2586 $output_rules .= &file_contents ('tags-clean');
2587 push (@clean, 'tags');
2588 &push_phony_cleaners ('tags');
2589 &examine_variable ('TAGS_DEPENDENCIES');
2591 elsif (&variable_defined ('TAGS_DEPENDENCIES'))
2593 &am_line_error ('TAGS_DEPENDENCIES',
2594 "doesn't make sense to define \`TAGS_DEPENDENCIES' without sources or \`ETAGS_ARGS'");
2598 # Every Makefile must define some sort of TAGS rule.
2599 # Otherwise, it would be possible for a top-level "make TAGS"
2600 # to fail because some subdirectory failed.
2601 $output_rules .= "tags: TAGS\nTAGS:\n\n";
2605 # Handle multilib support.
2608 return unless $seen_multilib;
2610 $output_rules .= &file_contents ('multilib');
2611 &push_phony_cleaners ('multi');
2612 push (@phony, 'all-multi', 'install-multi');
2615 # Worker for handle_dist.
2616 sub handle_dist_worker
2618 local ($makefile) = @_;
2620 $output_rules .= 'distdir: $(DISTFILES)' . "\n";
2622 # Initialization; only at top level.
2623 if ($relative_dir eq '.')
2625 if (defined $options{'check-news'})
2627 # For Gnits users, this is pretty handy. Look at 15 lines
2628 # in case some explanatory text is desirable.
2629 $output_rules .= ' @if sed 15q $(srcdir)/NEWS | fgrep -e "$(VERSION)" > /dev/null; then :; else \\
2630 echo "NEWS not updated; not releasing" 1>&2; \\
2637 # Create dist directory.
2638 $output_rules .= ("\t-chmod -R a+w \$(distdir) > /dev/null 2>&1; rm -rf \$(distdir)\n"
2639 . "\tmkdir \$(distdir)\n");
2642 # Scan EXTRA_DIST to see if we need to distribute anything from a
2643 # subdir. If so, add it to the list. I didn't want to do this
2644 # originally, but there were so many requests that I finally
2647 if (&variable_defined ('EXTRA_DIST'))
2649 # FIXME: This should be fixed to work with conditionals. That
2650 # will require only making the entries in @dist_dirs under the
2651 # appropriate condition. This is meaningful if the nature of
2652 # the distribution should depend upon the configure options
2654 foreach (&variable_value_as_list ('EXTRA_DIST', ''))
2657 next unless s,/+[^/]+$,,;
2658 push (@dist_dirs, $_)
2663 # We have to check DIST_COMMON for extra directories in case the
2664 # user put a source used in AC_OUTPUT into a subdir.
2665 foreach (&variable_value_as_list ('DIST_COMMON', 'all'))
2668 next unless s,/+[^/]+$,,;
2669 push (@dist_dirs, $_)
2675 # Prepend $(distdir) to each directory given. Doing it via a
2676 # hash lets us ensure that each directory is used only once.
2678 grep ($dhash{'$(distdir)/' . $_} = 1, @dist_dirs);
2679 $output_rules .= "\t";
2680 &pretty_print_rule ('$(mkinstalldirs)', "\t ", sort keys %dhash);
2683 # In loop, test for file existence because sometimes a file gets
2684 # included in DISTFILES twice. For example this happens when a
2685 # single source file is used in building more than one program.
2686 # Also, there are situations in which "ln" can fail. For instance
2687 # a file to distribute could actually be a cross-filesystem
2688 # symlink -- this can easily happen if "gettextize" was run on the
2690 $output_rules .= "\t\@for file in \$(DISTFILES); do \\\n";
2693 $output_rules .= "\t if test -f \$\$file; then d=.; else d=\$(srcdir); fi; \\\n";
2697 $output_rules .= "\t d=\$(srcdir); \\\n";
2699 $output_rules .= ("\t if test -d \$\$d/\$\$file; then \\\n"
2700 # Don't mention $$file in destination argument,
2701 # since this fails if destination directory
2702 # already exists. Also, use `-R' and not `-r'.
2703 # `-r' is almost always incorrect.
2704 . "\t cp -pR \$\$d/\$\$file \$(distdir) \\\n"
2705 . "\t || exit 1; \\\n"
2707 . "\t test -f \$(distdir)/\$\$file \\\n"
2708 . "\t || cp -p \$\$d/\$\$file \$(distdir)/\$\$file \\\n"
2709 . "\t || exit 1; \\\n"
2713 # If we have SUBDIRS, create all dist subdirectories and do
2715 if (&variable_defined ('SUBDIRS'))
2717 # If SUBDIRS is conditionally defined, then set DIST_SUBDIRS
2718 # to all possible directories, and use it. If DIST_SUBDIRS is
2719 # defined, just use it.
2720 local ($dist_subdir_name);
2721 if (&variable_conditions ('SUBDIRS')
2722 || &variable_defined ('DIST_SUBDIRS'))
2724 $dist_subdir_name = 'DIST_SUBDIRS';
2725 if (! &variable_defined ('DIST_SUBDIRS'))
2727 local (@full_list) = &variable_value_as_list ('SUBDIRS',
2729 local (@ds_list, %uniq, $iter);
2730 foreach $iter (@full_list)
2732 if (! defined $uniq{$iter})
2735 push (@ds_list, $iter);
2738 &define_pretty_variable ('DIST_SUBDIRS', '', @ds_list);
2743 $dist_subdir_name = 'SUBDIRS';
2744 # We always define this because that is what `distclean'
2746 &define_pretty_variable ('DIST_SUBDIRS', '', '$(SUBDIRS)');
2749 # Test for directory existence here because previous automake
2750 # invocation might have created some directories. Note that
2751 # we explicitly set distdir for the subdir make; that lets us
2752 # mix-n-match many automake-using packages into one large
2753 # package, and have "dist" at the top level do the right
2754 # thing. If we're in the topmost directory, then we use
2755 # `distdir' instead of `top_distdir'; this lets us work
2756 # correctly with an enclosing package.
2758 ("\t" . 'for subdir in $(' . $dist_subdir_name . '); do ' . "\\\n"
2759 . "\t" . ' if test "$$subdir" = .; then :; else ' . "\\\n"
2760 . "\t" . ' test -d $(distdir)/$$subdir ' . "\\\n"
2761 . "\t" . ' || mkdir $(distdir)/$$subdir ' . "\\\n"
2762 . "\t" . ' || exit 1; ' . "\\\n"
2763 . "\t" . ' (cd $$subdir'
2764 . ' && $(MAKE) $(AM_MAKEFLAGS) top_distdir=../$('
2765 . (($relative_dir eq '.') ? 'distdir' : 'top_distdir')
2766 . ') distdir=../$(distdir)/$$subdir distdir) ' . "\\\n"
2767 . "\t" . ' || exit 1; ' . "\\\n"
2768 . "\t" . ' fi; ' . "\\\n"
2772 # If the target `dist-hook' exists, make sure it is run. This
2773 # allows users to do random weird things to the distribution
2774 # before it is packaged up.
2775 push (@dist_targets, 'dist-hook') if &target_defined ('dist-hook');
2778 foreach $targ (@dist_targets)
2780 # We must explicitly set distdir and top_distdir for these
2782 $output_rules .= ("\t\$(MAKE) \$(AM_MAKEFLAGS)"
2783 . " top_distdir=\"\$(top_distdir)\""
2784 . " distdir=\"\$(distdir)\" $targ\n");
2787 push (@phony, 'distdir');
2790 # Handle 'dist' target.
2793 local ($makefile) = @_;
2795 # Set up maint_charset.
2796 $local_maint_charset = &variable_value ('MAINT_CHARSET')
2797 if &variable_defined ('MAINT_CHARSET');
2798 $maint_charset = $local_maint_charset
2799 if $relative_dir eq '.';
2801 if (&variable_defined ('DIST_CHARSET'))
2803 &am_line_error ('DIST_CHARSET',
2804 "DIST_CHARSET defined but no MAINT_CHARSET defined")
2805 if ! $local_maint_charset;
2806 if ($relative_dir eq '.')
2808 $dist_charset = &variable_value ('DIST_CHARSET')
2812 &am_line_error ('DIST_CHARSET',
2813 "DIST_CHARSET can only be defined at top level");
2817 # Look for common files that should be included in distribution.
2819 foreach $cfile (@common_files)
2821 if (-f ($relative_dir . "/" . $cfile))
2823 &push_dist_common ($cfile);
2827 # Always require configure.ac and configure at top level, even if
2828 # they don't exist. This is especially important for configure,
2829 # since it won't be created until autoconf is run -- which might
2830 # be after automake is run.
2831 &push_dist_common ($configure_ac, 'configure')
2832 if $relative_dir eq '.';
2834 # We might copy elements from %configure_dist_common to
2835 # %dist_common if we think we need to. If the file appears in our
2836 # directory, we would have discovered it already, so we don't
2837 # check that. But if the file is in a subdir without a Makefile,
2838 # we want to distribute it here if we are doing `.'. Ugly!
2839 if ($relative_dir eq '.')
2842 foreach $iter (keys %configure_dist_common)
2844 if (! &is_make_dir (&dirname ($iter)))
2846 &push_dist_common ($iter);
2851 # Keys of %dist_common are names of files to distributed. We put
2852 # README first because it then becomes easier to make a
2853 # Usenet-compliant shar file (in these, README must be first).
2854 # FIXME: do more ordering of files here.
2856 if (defined $dist_common{'README'})
2858 push (@coms, 'README');
2859 delete $dist_common{'README'};
2861 push (@coms, sort keys %dist_common);
2863 # Now that we've processed %dist_common, disallow further attempts
2865 $handle_dist_run = 1;
2867 &define_pretty_variable ("DIST_COMMON", '', @coms);
2868 $output_vars .= "\n";
2871 $output_vars .= &file_contents ('dist-vars') . "\n";
2872 &define_variable ('GZIP_ENV', '--best');
2874 # Put these things in rules section so it is easier for whoever
2875 # reads Makefile.in.
2876 if (! &variable_defined ('distdir'))
2878 if ($relative_dir eq '.')
2880 $output_rules .= "\n" . 'distdir = $(PACKAGE)-$(VERSION)' . "\n";
2884 $output_rules .= ("\n"
2885 . 'distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)'
2889 if ($relative_dir eq '.')
2891 $output_rules .= "top_distdir = \$(distdir)\n";
2893 $output_rules .= "\n";
2895 # Generate 'dist' target, and maybe other dist targets.
2896 if ($relative_dir eq '.')
2898 # Rule to check whether a distribution is viable.
2899 local ($xform) = '';
2901 if (&target_defined ('distcheck-hook'))
2903 $xform .= 's/^DISTHOOK//;';
2907 $xform .= 's/^DISTHOOK.*$//;';
2911 $xform .= 's/^GETTEXT//;';
2915 $xform .= 's/^GETTEXT.*$//;';
2918 $output_rules .= &file_contents_with_transform ($xform, 'dist');
2920 local ($dist_all) = ('dist-all: distdir' . "\n"
2923 foreach $curs ('dist', 'dist-shar', 'dist-zip', 'dist-tarZ',
2926 if (defined $options{$curs} || $curs eq 'dist')
2928 $output_rules .= ($curs . ': distdir' . "\n"
2932 $dist_all .= $dist{$curs};
2935 $output_rules .= $dist_all . $dist_trailer;
2938 # Generate distdir target.
2939 &handle_dist_worker ($makefile);
2942 # A subroutine of handle_dependencies. This function includes
2943 # `depend2' with appropriate transformations.
2948 # First include code for ordinary objects.
2949 local ($key) = $lang . '-autodep';
2950 local ($xform, $ext);
2952 local ($pfx) = $language_map{$key};
2953 local ($fpfx) = ($pfx eq '') ? 'CC' : $pfx;
2954 $xform = ('s/\@PFX\@/' . $pfx . '/g;'
2955 . 's/\@FPFX\@/' . $fpfx . '/g;'
2956 . ($seen_objext ? 's/^OBJEXT//;' : 's/^OBJEXT.*$//;')
2957 . ($seen_libtool ? 's/^LIBTOOL//;' : 's/^LIBTOOL.*$//;'));
2959 # This function can be called even when we don't want dependency
2960 # tracking. This happens when we need an explicit rule for some
2961 # target. In this case we don't want to include the generic code.
2962 if ($use_dependencies)
2964 local ($xform1) = ($xform
2965 . 's/\@BASE\@/\$\*/g;'
2966 . 's/\@SOURCE\@/\$\</g;'
2967 . 's/\@(LT|OBJ)?OBJ\@/\$\@/g;');
2969 foreach $ext (&lang_extensions ($lang))
2971 $output_rules .= (&file_contents_with_transform ('s/\@EXT\@/'
2979 # Now include code for each specially handled object with this
2981 local (@list) = grep ($_ ne '', split (' ', $lang_specific_files{$lang}));
2982 local ($max) = scalar @list;
2984 local ($derived, $source, $obj);
2986 # If dependency tracking is disabled, we just elide the code.
2987 if (! $use_dependencies)
2989 $xform .= 's/\@AMDEP\@.*$//;';
2994 $derived = $list[$i];
2995 ($source = $list[$i + 1]) =~ s,([/\$]),\\$1,g;
2996 ($obj = $list[$i + 2]) =~ s,([/\$]),\\$1,g;
2999 local ($flag) = $language_map{$lang . '-flags'};
3000 local ($val) = "(${derived}_${flag}";
3001 ($rule = $language_map{$lang . '-compile'}) =~
3004 $rule =~ s,([/\$]),\\$1,g;
3006 # Generate a transform which will turn suffix targets in
3007 # depend2.am into real targets for the particular objects we
3010 &file_contents_with_transform ($xform
3011 . 's/\$\(' . $pfx . 'COMPILE\)/'
3013 . 's/\$\(LT' . $pfx . 'COMPILE\)/'
3014 . '\$(LIBTOOL) --mode=compile '
3016 # Generate rule for `.o'.
3018 . $obj . '.o: ' . $source
3020 # Maybe generate rule for `.lo'.
3021 # Might be eliminated by
3023 . 's/^\@EXT\@\.lo:/'
3024 . $obj . '.lo: ' . $source
3026 # Maybe generate rule for `.obj'.
3027 # Might be eliminated by
3029 . 's/^\@EXT\@\.obj:/'
3030 . $obj . '.obj: ' . $source
3032 # Handle source and obj
3034 . 's/\@OBJ\@/' . $obj . '.o/g;'
3035 . 's/\@OBJOBJ\@/' . $obj . '.obj/g;'
3036 . 's/\@LTOBJ\@/' . $obj . '.lo/g;'
3037 . 's/\@BASE\@/' . $obj . '/g;'
3038 . 's/\@SOURCE\@/' . $source . '/g;',
3043 # Handle auto-dependency code.
3044 sub handle_dependencies
3046 if ($use_dependencies)
3048 # Include auto-dep code. Don't include it if DEP_FILES would
3050 if (&saw_sources_p (0) && keys %dep_files)
3052 local ($config_aux_dir_specified) = ($config_aux_dir ne '.'
3053 && $config_aux_dir ne '');
3055 # Set $require_file_found{'depcomp'} if the depcomp file exists,
3056 # before calling require_config_file on `depcomp'. This makes
3057 # require_file_internal skip its buggy existence test that would
3058 # make automake fail (with `required file `lib/depcomp' not found')
3059 # when AC_CONFIG_AUX_DIR is not set. See tests/subdir4.test.
3060 local ($depcomp_dir) = ($config_aux_dir_specified ? $config_aux_dir
3062 $require_file_found{'depcomp'} = 1 if -f "$depcomp_dir/depcomp";
3064 # Set location of depcomp.
3065 local ($prefix) = ($config_aux_dir_specified ? $config_aux_dir
3068 &define_variable ('depcomp', "\$(SHELL) $prefix/depcomp");
3070 &require_config_file ($FOREIGN, 'depcomp');
3073 local (@deplist) = sort keys %dep_files;
3075 &define_pretty_variable ('DEP_FILES', '', ("\@AMDEP\@", @deplist));
3077 # Generate each `include' individually. Irix 6 make will
3078 # not properly include several files resulting from a
3079 # variable expansion; generating many separate includes
3081 $output_rules .= "\n";
3082 foreach $iter (@deplist)
3084 $output_rules .= "\@AMDEP\@" . 'include ' . $iter . "\n";
3087 $output_rules .= &file_contents ('depend');
3088 push (@clean, 'depend');
3089 &push_phony_cleaners ('depend');
3094 &define_variable ('depcomp', '');
3097 local ($key, $lang, $ext, $xform);
3098 foreach $key (sort keys %language_map)
3100 next unless $key =~ /^(.*)-autodep$/;
3101 next if $language_map{$key} eq 'no';
3106 # Handle subdirectories.
3109 return if ! &variable_defined ('SUBDIRS');
3111 # Make sure each directory mentioned in SUBDIRS actually exists.
3113 foreach $dir (&variable_value_as_list ('SUBDIRS', 'all'))
3115 # Skip directories substituted by configure.
3116 next if $dir =~ /^\@.*\@$/;
3118 if (! -d $am_relative_dir . '/' . $dir)
3120 &am_line_error ('SUBDIRS',
3121 "required directory $am_relative_dir/$dir does not exist");
3125 &am_line_error ('SUBDIRS', "directory should not contain \`/'")
3129 local ($xform) = ('s/\@INSTALLINFO\@/' .
3130 (defined $options{'no-installinfo'}
3131 ? 'install-info-recursive'
3134 $output_rules .= &file_contents_with_transform ($xform, 'subdirs');
3136 # Push a bunch of phony targets.
3138 foreach $phonies ('', '-data', '-exec', 'dirs')
3140 push (@phony, 'install' . $phonies . '-recursive');
3141 push (@phony, 'uninstall' . $phonies . '-recursive');
3143 foreach $phonies ('all', 'check', 'installcheck', 'info', 'dvi')
3145 push (@phony, $phonies . '-recursive');
3147 &push_phony_cleaners ('recursive');
3149 $recursive_install = 1;
3152 # Handle aclocal.m4.
3153 sub handle_aclocal_m4
3155 local ($regen_aclocal) = 0;
3156 if (-f 'aclocal.m4')
3158 &define_variable ("ACLOCAL_M4", '$(top_srcdir)/aclocal.m4');
3159 &push_dist_common ('aclocal.m4');
3161 if (open (ACLOCAL, '< aclocal.m4'))
3167 if ($line =~ 'generated automatically by aclocal')
3174 local ($acinclude) = 0;
3175 if (-f 'acinclude.m4')
3181 # Note that it might be possible that aclocal.m4 doesn't exist but
3182 # should be auto-generated. This case probably isn't very
3186 local (@ac_deps) = (
3188 ? "\@MAINTAINER_MODE_TRUE\@"
3191 ($acinclude ? ' acinclude.m4' : '')
3194 if (&variable_defined ('ACLOCAL_M4_SOURCES'))
3196 push (@ac_deps, "\$(ACLOCAL_M4_SOURCES)");
3198 elsif (&variable_defined ('ACLOCAL_AMFLAGS'))
3200 # Scan all -I directories for m4 files. These are our
3202 local ($examine_next, $amdir) = 0;
3203 foreach $amdir (&variable_value_as_list ('ACLOCAL_AMFLAGS', ''))
3208 if ($amdir !~ /^\// && -d $amdir)
3210 foreach $ac_dep (&my_glob ($amdir . '/*.m4'))
3212 $ac_dep =~ s/^\.\/*//;
3213 push (@ac_deps, $ac_dep)
3214 unless $ac_dep eq "aclocal.m4"
3215 || $ac_dep eq "acinclude.m4";
3219 elsif ($amdir eq '-I')
3226 &pretty_print_rule ("\$(ACLOCAL_M4):", "\t\t", @ac_deps);
3228 $output_rules .= ("\t"
3229 . 'cd $(srcdir) && $(ACLOCAL)'
3230 . (&variable_defined ('ACLOCAL_AMFLAGS')
3231 ? ' $(ACLOCAL_AMFLAGS)' : '')
3236 # Rewrite a list of input files into a form suitable to put on a
3237 # dependency list. The idea is that if an input file has a directory
3238 # part the same as the current directory, then the directory part is
3239 # simply removed. But if the directory part is different, then
3240 # $(top_srcdir) is prepended. Among other things, this is used to
3241 # generate the dependency list for the output files generated by
3242 # AC_OUTPUT. Consider what the dependencies should look like in this
3244 # AC_OUTPUT(src/out:src/in1:lib/in2)
3245 # The first argument, ADD_SRCDIR, is 1 if $(top_srcdir) should be added.
3246 # If 0 then files that require this addition will simply be ignored.
3247 sub rewrite_inputs_into_dependencies
3249 local ($add_srcdir, @inputs) = @_;
3250 local ($single, @newinputs);
3252 foreach $single (@inputs)
3254 if (&dirname ($single) eq $relative_dir)
3256 push (@newinputs, &basename ($single));
3260 push (@newinputs, '$(top_srcdir)/' . $single);
3267 # Handle remaking and configure stuff.
3268 # We need the name of the input file, to do proper remaking rules.
3269 sub handle_configure
3271 local ($local, $input, @secondary_inputs) = @_;
3273 local ($top_reldir);
3275 local ($input_base) = &basename ($input);
3276 local ($local_base) = &basename ($local);
3278 local ($amfile) = $input_base . '.am';
3279 # We know we can always add '.in' because it really should be an
3280 # error if the .in was missing originally.
3281 local ($infile) = '$(srcdir)/' . $input_base . '.in';
3282 local ($colon_infile);
3283 if ($local ne $input || @secondary_inputs)
3285 $colon_infile = ':' . $input . '.in';
3287 $colon_infile .= ':' . join (':', @secondary_inputs)
3288 if @secondary_inputs;
3290 local (@rewritten) = &rewrite_inputs_into_dependencies (1,
3293 # This rule remakes the Makefile.in. Note use of
3294 # @MAINTAINER_MODE_TRUE@ forces us to abandon pretty-printing.
3296 $output_rules .= ($infile
3297 # NOTE perl 5.003 (with -w) gives a
3298 # uninitialized value error on the next line.
3301 . ($seen_maint_mode ? "\@MAINTAINER_MODE_TRUE\@ " : '')
3303 . '$(top_srcdir)/' . $configure_ac .' $(ACLOCAL_M4)'
3304 . ' ' . join (' ', @include_stack)
3306 . "\tcd \$(top_srcdir) && \$(AUTOMAKE) "
3307 . ($cygnus_mode ? '--cygnus' : ('--' . $strictness_name))
3308 . ($cmdline_use_dependencies ? '' : ' --ignore-deps')
3309 . ' ' . $input . $colon_infile . "\n\n");
3311 # This rule remakes the Makefile.
3312 $output_rules .= ($local_base
3313 # NOTE: bogus uninit value error on next line;
3314 # see comment above.
3317 . join (' ', @rewritten)
3318 . ' $(top_builddir)/config.status'
3320 . "\tcd \$(top_builddir) \\\n"
3321 . "\t && CONFIG_FILES="
3322 . (($relative_dir eq '.') ? '$@' : '$(subdir)/$@')
3324 . ' CONFIG_HEADERS= $(SHELL) ./config.status'
3327 if ($relative_dir ne '.')
3330 $top_reldir = '../';
3334 local ($xform) = &transform ('CONFIGURE_AC' => $configure_ac);
3336 $output_rules .= &file_contents_with_transform ($xform,
3338 &examine_variable ('CONFIG_STATUS_DEPENDENCIES');
3339 &examine_variable ('CONFIGURE_DEPENDENCIES');
3342 &push_dist_common ('acconfig.h')
3346 # If we have a configure header, require it.
3348 local (@local_fullnames) = @config_fullnames;
3349 local (@local_names) = @config_names;
3350 local ($hdr_index) = 0;
3351 local ($distclean_config) = '';
3352 foreach $one_hdr (@config_headers)
3354 local ($one_fullname) = shift (@local_fullnames);
3355 local ($one_name) = shift (@local_names);
3357 local ($header_dir) = &dirname ($one_name);
3359 # If the header is in the current directory we want to build
3360 # the header here. Otherwise, if we're at the topmost
3361 # directory and the header's directory doesn't have a
3362 # Makefile, then we also want to build the header.
3363 if ($relative_dir eq $header_dir
3364 || ($relative_dir eq '.' && ! &is_make_dir ($header_dir)))
3366 local ($ch_sans_dir, $cn_sans_dir, $stamp_dir);
3367 if ($relative_dir eq $header_dir)
3369 $cn_sans_dir = &basename ($one_name);
3374 $cn_sans_dir = $one_name;
3375 if ($header_dir eq '.')
3381 $stamp_dir = $header_dir . '/';
3385 # Compute relative path from directory holding output
3386 # header to directory holding input header. FIXME:
3387 # doesn't handle case where we have multiple inputs.
3388 if (&dirname ($one_hdr) eq $relative_dir)
3390 $ch_sans_dir = &basename ($one_hdr);
3394 local (@rel_out_path);
3395 # FIXME this chunk of code should be its own sub.
3396 # It is used elsewhere.
3397 foreach (split (/\//, $relative_dir))
3399 next if $_ eq '' || $_ eq '.';
3402 # FIXME: actually this is an error.
3407 push (@rel_out_path, '..');
3412 $ch_sans_dir = join ('/', @rel_out_path) . '/' . $one_hdr;
3416 $ch_sans_dir = $one_hdr;
3420 &require_file_with_conf_line ($config_header_line,
3421 $FOREIGN, $ch_sans_dir);
3423 # Header defined and in this directory.
3425 if (-f $one_name . '.top')
3427 push (@files, "${cn_sans_dir}.top");
3429 if (-f $one_name . '.bot')
3431 push (@files, "${cn_sans_dir}.bot");
3434 &push_dist_common (@files);
3436 # For now, acconfig.h can only appear in the top srcdir.
3437 if (-f 'acconfig.h')
3439 if ($relative_dir eq '.')
3441 push (@files, 'acconfig.h');
3445 # Strange quoting because this gets fed through
3447 push (@files, '\$(top_srcdir)/acconfig.h');
3451 local ($stamp_name) = 'stamp-h';
3452 $stamp_name .= "${hdr_index}" if scalar (@config_headers) > 1;
3454 local ($xform) = '';
3456 $xform = &transform ('CONFIGURE_AC' => $configure_ac,
3457 'FILES' => join (' ', @files),
3458 'CONFIG_HEADER' => $cn_sans_dir,
3459 'CONFIG_HEADER_IN' => $ch_sans_dir,
3460 'CONFIG_HEADER_FULL' => $one_fullname,
3461 'STAMP' => "$stamp_dir$stamp_name");
3463 local ($out_dir) = &dirname ($ch_sans_dir);
3464 $xform .= &transform ('SRC_STAMP' => "${out_dir}/${stamp_name}");
3465 $output_rules .= &file_contents_with_transform ($xform,
3468 &create ("${relative_dir}/${out_dir}/${stamp_name}.in");
3469 &require_file_with_conf_line ($config_header_line, $FOREIGN,
3470 "${out_dir}/${stamp_name}.in");
3472 $distclean_config .= ' ' if $distclean_config;
3473 $distclean_config .= $cn_sans_dir;
3477 if ($distclean_config)
3479 $output_rules .= &file_contents_with_transform ('s,\@FILES\@,'
3483 push (@clean, 'hdr');
3484 &push_phony_cleaners ('hdr');
3487 # Set location of mkinstalldirs.
3488 if ($config_aux_dir ne '.' && $config_aux_dir ne '')
3490 &define_variable ('mkinstalldirs', ('$(SHELL) ' . $config_aux_dir
3491 . '/mkinstalldirs'));
3495 &define_variable ('mkinstalldirs',
3496 '$(SHELL) $(top_srcdir)/mkinstalldirs');
3499 &am_line_error ('CONFIG_HEADER',
3500 "\`CONFIG_HEADER' is an anachronism; now determined from \`$configure_ac'")
3501 if &variable_defined ('CONFIG_HEADER');
3504 local ($config_header) = '';
3505 foreach $one_name (@config_names)
3507 # Generate CONFIG_HEADER define.
3509 if ($relative_dir eq &dirname ($one_name))
3511 $one_hdr = &basename ($one_name);
3515 $one_hdr = "${top_builddir}/${one_name}";
3518 $config_header .= ' ' if $config_header;
3519 $config_header .= $one_hdr;
3523 &define_variable ("CONFIG_HEADER", $config_header);
3526 # Now look for other files in this directory which must be remade
3527 # by config.status, and generate rules for them.
3528 local (@actual_other_files) = ();
3529 local ($file, $local);
3530 local (@inputs, @rewritten_inputs, $single);
3531 local ($need_rewritten);
3532 foreach $file (@other_input_files)
3534 if ($file =~ /^([^:]*):(.*)$/)
3536 # This is the ":" syntax of AC_OUTPUT.
3538 $local = &basename ($file);
3539 @inputs = split (':', $2);
3540 @rewritten_inputs = &rewrite_inputs_into_dependencies (1, @inputs);
3541 $need_rewritten = 1;
3546 $local = &basename ($file);
3547 @inputs = ($local . '.in');
3549 &rewrite_inputs_into_dependencies (1, $file . '.in');
3550 $need_rewritten = 0;
3553 # Skip files not in this directory.
3554 next unless &dirname ($file) eq $relative_dir;
3556 # Skip any file that is an automake input.
3557 next if -f $file . '.am';
3559 # Some users have been tempted to put `stamp-h' in the
3560 # AC_OUTPUT line. This won't do the right thing, so we
3561 # explicitly fail here.
3562 if ($local eq 'stamp-h')
3564 # FIXME: allow real filename.
3565 &am_conf_error ($configure_ac, $ac_output_line,
3566 'stamp-h should not appear in AC_OUTPUT');
3570 $output_rules .= ($local . ': '
3571 . '$(top_builddir)/config.status '
3572 . join (' ', @rewritten_inputs) . "\n"
3574 . 'cd $(top_builddir) && CONFIG_FILES='
3575 . ($relative_dir eq '.' ? '' : '$(subdir)/')
3576 . '$@' . ($need_rewritten
3577 ? (':' . join (':', @inputs))
3579 . ' CONFIG_HEADERS= $(SHELL) ./config.status'
3581 &push_dist_common (@inputs);
3582 push (@actual_other_files, $local);
3584 # Require all input files.
3585 &require_file_with_conf_line ($ac_output_line, $FOREIGN,
3586 &rewrite_inputs_into_dependencies (0, @inputs));
3589 # These files get removed by "make clean".
3590 &define_pretty_variable ('CONFIG_CLEAN_FILES', '', @actual_other_files);
3597 @r = &am_install_var ('-defaultdist', 'header', 'HEADERS', 'include',
3598 'oldinclude', 'pkginclude',
3602 next unless /\.(.*)$/;
3603 &saw_extension ($1);
3609 return if ! $seen_gettext || $relative_dir ne '.';
3611 if (! &variable_defined ('SUBDIRS'))
3614 ("AM_GNU_GETTEXT used but SUBDIRS not defined");
3618 &require_file_with_conf_line ($ac_gettext_line, $GNU, 'ABOUT-NLS');
3620 if (&variable_defined ('SUBDIRS'))
3624 "AM_GNU_GETTEXT in \`$configure_ac' but \`po' not in SUBDIRS")
3625 if $contents{'SUBDIRS'} !~ /\bpo\b/;
3628 "AM_GNU_GETTEXT in \`$configure_ac' but \`intl' not in SUBDIRS")
3629 if $contents{'SUBDIRS'} !~ /\bintl\b/;
3632 # Ensure that each language in ALL_LINGUAS has a .po file, and
3633 # each po file is mentioned in ALL_LINGUAS.
3636 local (%linguas) = ();
3637 grep ($linguas{$_} = 1, split (' ', $all_linguas));
3644 &am_line_error ($all_linguas_line,
3645 ("po/$_.po exists but \`$_' not in \`ALL_LINGUAS'"))
3649 foreach (keys %linguas)
3651 &am_line_error ($all_linguas_line,
3652 "$_ in \`ALL_LINGUAS' but po/$_.po does not exist")
3658 &am_error ("AM_GNU_GETTEXT in \`$configure_ac' but \`ALL_LINGUAS' not defined");
3662 # Handle footer elements.
3665 if ($contents{'SOURCES'})
3667 # NOTE don't use define_pretty_variable here, because
3668 # $contents{...} is already defined.
3669 $output_vars .= 'SOURCES = ' . $contents{'SOURCES'} . "\n";
3671 if ($contents{'OBJECTS'})
3673 # NOTE don't use define_pretty_variable here, because
3674 # $contents{...} is already defined.
3675 $output_vars .= 'OBJECTS = ' . $contents{'OBJECTS'} . "\n";
3677 if ($contents{'SOURCES'} || $contents{'OBJECTS'})
3679 $output_vars .= "\n";
3682 if (&target_defined ('.SUFFIXES'))
3684 &am_line_error ('.SUFFIXES',
3685 "use variable \`SUFFIXES', not target \`.SUFFIXES'");
3688 # Note: AIX 4.1 /bin/make will fail if any suffix rule appears
3689 # before .SUFFIXES. So we make sure that .SUFFIXES appears before
3690 # anything else, by sticking it right after the default: target.
3691 $output_header .= ".SUFFIXES:\n";
3692 if (@suffixes || &variable_defined ('SUFFIXES'))
3694 # Make sure suffixes has unique elements. Sort them to ensure
3695 # the output remains consistent. However, $(SUFFIXES) is
3696 # always at the start of the list, unsorted. This is done
3697 # because make will choose rules depending on the ordering of
3698 # suffixes, and this lets the user have some control. Push
3699 # actual suffixes, and not $(SUFFIXES). Some versions of make
3700 # do not like variable substitutions on the .SUFFIXES line.
3702 local (@user_suffixes) = (&variable_defined ('SUFFIXES')
3703 ? &variable_value_as_list ('SUFFIXES', '')
3706 grep ($suffixes{$_} = 1, @suffixes);
3707 delete @suffixes{@user_suffixes};
3709 $output_header .= (".SUFFIXES: "
3710 . join (' ', @user_suffixes, sort keys %suffixes)
3713 $output_trailer .= &file_contents ('footer');
3716 # Deal with installdirs target.
3717 sub handle_installdirs
3719 # GNU Makefile standards recommend this.
3720 if ($recursive_install)
3722 # We create a separate `-am' target so that the -recursive
3723 # rule will work correctly.
3724 $output_rules .= ("installdirs: installdirs-recursive\n"
3725 . "installdirs-am:\n");
3726 push (@phony, 'installdirs-am');
3730 $output_rules .= "installdirs:\n";
3732 push (@phony, 'installdirs');
3735 &pretty_print_rule ("\t" . '$(mkinstalldirs) ', "\t\t",
3738 $output_rules .= "\n";
3741 # There are several targets which need to be merged. This is because
3742 # their complete definition is compiled from many parts. Note that we
3743 # avoid double colon rules, otherwise we'd use them instead.
3744 sub handle_merge_targets
3746 local ($makefile) = @_;
3748 # There are a few install-related variables that you should not define.
3750 foreach $var ('PRE_INSTALL', 'POST_INSTALL', 'NORMAL_INSTALL')
3752 if (&variable_defined ($var))
3754 &am_line_error ($var, "\`$var' should not be defined");
3758 # Put this at the beginning for the sake of non-GNU makes. This
3759 # is still wrong if these makes can run parallel jobs. But it is
3761 unshift (@all, &basename ($makefile));
3764 foreach $one_name (@config_names)
3766 push (@all, &basename ($one_name))
3767 if &dirname ($one_name) eq $relative_dir;
3770 &do_one_merge_target ('info', @info);
3771 &do_one_merge_target ('dvi', @dvi);
3772 &do_check_merge_target;
3773 &do_one_merge_target ('installcheck', @installcheck);
3775 if (defined $options{'no-installinfo'})
3777 &do_one_merge_target ('install-info', '');
3779 elsif (&target_defined ('install-info-local'))
3781 &am_line_error ('install-info-local',
3782 "\`install-info-local' target defined but \`no-installinfo' option not in use");
3786 foreach $utarg ('uninstall-data-local', 'uninstall-data-hook',
3787 'uninstall-exec-local', 'uninstall-exec-hook')
3789 if (&target_defined ($utarg))
3792 ($x = $utarg) =~ s/(data|exec)-//;
3793 &am_line_error ($utarg, "use \`$x', not \`$utarg'");
3797 if (&target_defined ('install-local'))
3799 &am_line_error ('install-local',
3800 "use \`install-data-local' or \`install-exec-local', not \`install-local'");
3803 if (@all || &variable_defined ('BUILT_SOURCES'))
3806 local ($local_headers) = '';
3807 $local_headers = '$(BUILT_SOURCES)'
3808 if &variable_defined ('BUILT_SOURCES');
3809 foreach $one_name (@config_names)
3811 if (&dirname ($one_name) eq $relative_dir)
3813 $local_headers .= ' ' if $local_headers;
3814 $local_headers .= &basename ($one_name);
3819 # This is kind of a hack, but I couldn't see a better way
3820 # to handle it. In this particular case, we need to make
3821 # sure config.h is built before we recurse. We can't do
3822 # this by changing the order of dependencies to the "all"
3823 # because that breaks when using parallel makes. Instead
3824 # we handle things explicitly.
3825 $output_rules .= ("all-recursive-am: ${local_headers}"
3827 . '$(MAKE) $(AM_MAKEFLAGS)'
3830 $all_target = 'all-recursive-am';
3831 push (@phony, 'all-recursive-am');
3835 if (&variable_defined('lib_LTLIBRARIES') &&
3836 &variable_defined('bin_PROGRAMS'))
3838 $output_rules .= "install-binPROGRAMS: install-libLTLIBRARIES\n\n";
3840 # Print definitions users can use.
3841 &do_one_merge_target ('install-exec', @install_exec);
3842 $output_rules .= "\n";
3844 &do_one_merge_target ('install-data', @install_data);
3845 $output_rules .= "\n";
3847 &do_one_merge_target ('install', 'all-am');
3848 &do_one_merge_target ('uninstall', @uninstall);
3850 &do_one_merge_target ('all', @all);
3852 # Generate the new 'install-strip' target. We can't just set
3853 # INSTALL_PROGRAM because that might be a relative path.
3854 $output_rules .= ("install-strip:\n\t"
3855 . '$(MAKE) $(AM_MAKEFLAGS) INSTALL_STRIP_FLAG=-s install'
3857 push (@phony, 'install-strip');
3860 # Helper for handle_merge_targets. Note that handle_merge_targets
3861 # relies on the fact that this doesn't add an extra \n at the end.
3862 sub do_one_merge_target
3864 local ($name, @values) = @_;
3866 if (&target_defined ($name . '-local'))
3868 # User defined local form of target. So include it.
3869 push (@values, $name . '-local');
3870 push (@phony, $name . '-local');
3873 &pretty_print_rule ($name . "-am:", "\t\t", @values);
3874 if ($name eq 'install')
3876 # Special-case `install-am' to run install-exec-am and
3877 # install-data-am after all-am is built.
3878 &pretty_print_rule ("\t\@\$(MAKE) \$(AM_MAKEFLAGS)", "\t ",
3879 'install-exec-am', 'install-data-am');
3881 elsif ($name eq 'install-exec' && &target_defined ('install-exec-hook'))
3883 $output_rules .= ("\t\@\$(NORMAL_INSTALL)\n"
3884 . "\t" . '$(MAKE) $(AM_MAKEFLAGS) install-exec-hook'
3887 elsif ($name eq 'install-data' && &target_defined ('install-data-hook'))
3889 $output_rules .= ("\t\@\$(NORMAL_INSTALL)\n"
3890 . "\t" . '$(MAKE) $(AM_MAKEFLAGS) install-data-hook'
3894 local ($lname) = $name . ($recursive_install ? '-recursive' : '-am');
3895 local ($tname) = $name;
3896 # To understand this special case, see handle_merge_targets.
3899 $tname = 'all-redirect';
3900 $lname = $all_target if $recursive_install;
3901 push (@phony, 'all-redirect');
3902 $output_all = "all: all-redirect\n";
3904 &pretty_print_rule ($tname . ":", "\t\t", $lname);
3905 push (@phony, $name . '-am', $name);
3908 # Handle check merge target specially.
3909 sub do_check_merge_target
3911 if (&target_defined ('check-local'))
3913 # User defined local form of target. So include it.
3914 push (@check_tests, 'check-local');
3915 push (@phony, 'check-local');
3918 # In --cygnus mode, check doesn't depend on all.
3921 # Just run the local check rules.
3922 &pretty_print_rule ('check-am:', "\t\t", @check);
3926 # The check target must depend on the local equivalent of
3927 # `all', to ensure all the primary targets are built. Then it
3928 # must build the local check rules.
3929 $output_rules .= "check-am: all-am\n";
3930 &pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ",
3934 &pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ",
3938 push (@phony, 'check', 'check-am');
3939 $output_rules .= ("check: "
3940 . ($recursive_install ? 'check-recursive' : 'check-am')
3944 # Handle all 'clean' targets.
3947 local ($xform) = '';
3950 # Don't include `MAINTAINER'; it is handled specially below.
3951 foreach $name ('MOSTLY', '', 'DIST')
3953 if (! &variable_defined ($name . 'CLEANFILES'))
3955 $xform .= 's/^' . $name . 'CLEAN.*$//;';
3959 $xform .= 's/^' . $name . 'CLEAN//;';
3963 # Built sources are automatically removed by maintainer-clean.
3964 push (@maintainer_clean_files, '\$(BUILT_SOURCES)')
3965 if &variable_defined ('BUILT_SOURCES');
3966 push (@maintainer_clean_files, '\$(MAINTAINERCLEANFILES)')
3967 if &variable_defined ('MAINTAINERCLEANFILES');
3968 if (! @maintainer_clean_files)
3970 $xform .= 's/^MAINTAINERCLEAN.*$//;';
3974 $xform .= ('s/^MAINTAINERCLEAN//;'
3975 # Join with no space to avoid spurious `test -z'
3976 # success at runtime.
3977 . 's,\@MCFILES\@,' . join ('', @maintainer_clean_files)
3979 # A space is required in the join here.
3980 . 's,\@MFILES\@,' . join (' ', @maintainer_clean_files)
3984 $output_rules .= &file_contents_with_transform ($xform, 'clean');
3986 push (@clean, 'generic');
3987 &push_phony_cleaners ('generic');
3989 &do_one_clean_target ('clean', 'mostly', '', @clean);
3990 &do_one_clean_target ('clean', '', 'mostly', @clean);
3991 &do_one_clean_target ('clean', 'dist', '', @clean);
3992 &do_one_clean_target ('clean', 'maintainer-', 'dist', @clean);
3994 push (@phony, 'clean', 'mostlyclean', 'distclean', 'maintainer-clean');
3997 # Helper for handle_clean.
3998 sub do_one_clean_target
4000 local ($target, $name, $last_name, @deps) = @_;
4002 # Change each dependency `BLARG' into `clean-BLARG'.
4003 grep (($_ = $name . 'clean-' . $_) && 0, @deps);
4005 # Push the previous clean target. There is no previous clean
4006 # target if we're doing mostlyclean.
4007 push (@deps, $last_name . $target . '-am')
4008 unless $name eq 'mostly';
4010 # If a -local version of the rule is given, add it to the list.
4011 if (&target_defined ($name . $target . '-local'))
4013 push (@deps, $name . $target . '-local');
4016 # Print the target and the dependencies.
4017 &pretty_print_rule ($name . $target . "-am: ", "\t\t", @deps);
4019 # FIXME: shouldn't we really print these messages before running
4021 if ($name . $target eq 'maintainer-clean')
4023 # Print a special warning.
4025 ("\t\@echo \"This command is intended for maintainers to use;\"\n"
4026 . "\t\@echo \"it deletes files that may require special "
4027 . "tools to rebuild.\"\n");
4029 elsif ($name . $target eq 'distclean')
4031 $output_rules .= "\t-rm -f libtool\n" if $seen_libtool;
4033 $output_rules .= "\n";
4035 # Now generate the actual clean target.
4036 $output_rules .= ($name . $target . ": " . $name . $target
4037 . ($recursive_install ? '-recursive' : '-am')
4040 # We special-case config.status here. If we do it as part of the
4041 # normal clean processing for this directory, then it might be
4042 # removed before some subdir is cleaned. However, that subdir's
4043 # Makefile depends on config.status.
4044 if (($name . $target eq 'maintainer-clean'
4045 || $name . $target eq 'distclean')
4046 && $relative_dir eq '.')
4048 $output_rules .= "\t-rm -f config.status\n";
4050 $output_rules .= "\n";
4053 # Handle .PHONY target.
4056 &pretty_print_rule ('.PHONY:', "", @phony);
4057 $output_rules .= "\n";
4060 # Handle TESTS variable and other checks.
4063 if (defined $options{'dejagnu'})
4065 push (@check_tests, 'check-DEJAGNU');
4066 push (@phony, 'check-DEJAGNU');
4071 $xform = 's/^CYGNUS//;';
4075 $xform = 's/^CYGNUS.*$//;';
4077 $output_rules .= &file_contents_with_transform ($xform, 'dejagnu');
4079 # In Cygnus mode, these are found in the build tree.
4080 # Otherwise they are looked for in $PATH.
4081 &define_program_variable ('EXPECT', 'build', 'expect', 'expect');
4082 &define_program_variable ('RUNTEST', 'src', 'dejagnu', 'runtest');
4084 # Only create site.exp rule if user hasn't already written
4086 if (! &target_defined ('site.exp'))
4088 # Note that in the rule we don't directly generate
4089 # site.exp to avoid the possibility of a corrupted
4090 # site.exp if make is interrupted. Jim Meyering has some
4091 # useful text on this topic.
4092 $output_rules .= ("site.exp: Makefile\n"
4093 . "\t\@echo 'Making a new site.exp file...'\n"
4094 . "\t\@test ! -f site.bak || rm -f site.bak\n"
4095 . "\t\@echo '## these variables are automatically generated by make ##' > \$\@-t\n"
4096 . "\t\@echo '# Do not edit here. If you wish to override these values' >> \$\@-t\n"
4097 . "\t\@echo '# edit the last section' >> \$\@-t\n"
4098 . "\t\@echo 'set tool \$(DEJATOOL)' >> \$\@-t\n"
4099 . "\t\@echo 'set srcdir \$(srcdir)' >> \$\@-t\n"
4100 . "\t\@echo 'set objdir' \`pwd\` >> \$\@-t\n");
4102 # Extra stuff for AC_CANONICAL_*
4103 local (@whatlist) = ();
4104 if ($seen_canonical)
4106 push (@whatlist, 'host');
4109 # Extra stuff only for AC_CANONICAL_SYSTEM.
4110 if ($seen_canonical == $AC_CANONICAL_SYSTEM)
4112 push (@whatlist, 'target', 'build');
4116 foreach $c1 (@whatlist)
4118 foreach $c2 ('alias', 'triplet')
4120 $output_rules .= "\t\@echo 'set ${c1}_${c2} \$(${c1}_${c2})' >> \$\@-t\n";
4124 $output_rules .= ("\t\@echo '## All variables above are generated by configure. Do Not Edit ##' >> \$\@-t\n"
4125 . "\t\@test ! -f site.exp || sed '1,/^## All variables above are.*##/ d' site.exp >> \$\@-t\n"
4126 . "\t\@test ! -f site.exp || mv site.exp site.bak\n"
4127 . "\t\@mv \$\@-t site.exp\n");
4133 foreach $c ('DEJATOOL', 'RUNTEST', 'RUNTESTFLAGS')
4135 if (&variable_defined ($c))
4137 &am_line_error ($c, "\`$c' defined but \`dejagnu' not in \`AUTOMAKE_OPTIONS'");
4142 if (&variable_defined ('TESTS'))
4144 push (@check_tests, 'check-TESTS');
4145 push (@phony, 'check-TESTS');
4147 # Note: Solaris 2.7 seems to expand TESTS using VPATH. That's
4148 # why we also try `dir='
4149 $output_rules .= 'check-TESTS: $(TESTS)
4150 @failed=0; all=0; xfail=0; xpass=0; \\
4151 srcdir=$(srcdir); export srcdir; \\
4152 list=' . "'\$(TESTS)'; \\" . '
4153 if test -n "$$list"; then \\
4154 for tst in $$list; do \\
4155 if test -f ./$$tst; then dir=./; \\
4156 elif test -f $$tst; then dir=; \\
4157 else dir="$(srcdir)/"; fi; \\
4158 if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \\
4159 all=`expr $$all + 1`; \\
4160 case " $(XFAIL_TESTS) " in \\
4162 xpass=`expr $$xpass + 1`; \\
4163 failed=`expr $$failed + 1`; \\
4164 echo "XPASS: $$tst"; \\
4167 echo "PASS: $$tst"; \\
4170 elif test $$? -ne 77; then \\
4171 all=`expr $$all + 1`; \\
4172 case " $(XFAIL_TESTS) " in \\
4174 xfail=`expr $$xfail + 1`; \\
4175 echo "XFAIL: $$tst"; \\
4178 failed=`expr $$failed + 1`; \\
4179 echo "FAIL: $$tst"; \\
4184 if test "$$failed" -eq 0; then \\
4185 if test "$$xfail" -eq 0; then \\
4186 banner="All $$all tests passed"; \\
4188 banner="All $$all tests behaved as expected ($$xfail expected failures)"; \\
4191 if test "$$xpass" -eq 0; then \\
4192 banner="$$failed of $$all tests failed"; \\
4194 banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \\
4197 dashes=`echo "$$banner" | sed s/./=/g`; \\
4201 test "$$failed" -eq 0; \\
4207 # Handle Emacs Lisp.
4208 sub handle_emacs_lisp
4210 local (@elfiles) = &am_install_var ('-candist', 'lisp', 'LISP',
4216 &define_configure_variable ('lispdir');
4217 &define_configure_variable ('EMACS');
4218 $output_rules .= (".el.elc:\n"
4219 . "\t\@echo 'WARNING: Warnings can be ignored. :-)'\n"
4220 . "\tif test \$(EMACS) != no; then \\\n"
4221 . "\t EMACS=\$(EMACS) \$(SHELL) \$(srcdir)/elisp-comp \$<; \\\n"
4223 push (@suffixes, '.el', '.elc');
4225 # Generate .elc files.
4226 grep ($_ .= 'c', @elfiles);
4227 &define_pretty_variable ('ELCFILES', '', @elfiles);
4229 $output_rules .= &file_contents ('lisp-clean');
4230 push (@clean, 'lisp');
4231 &push_phony_cleaners ('lisp');
4233 push (@all, '$(ELCFILES)');
4236 if (&variable_defined ('lisp_LISP'))
4238 $varname = 'lisp_LISP';
4239 &am_error ("\`lisp_LISP' defined but \`AM_PATH_LISPDIR' not in \`$configure_ac'")
4244 $varname = 'noinst_LISP';
4247 &require_file_with_line ($varname, $FOREIGN, 'elisp-comp');
4254 local (@pyfiles) = &am_install_var ('-defaultdist', 'python', 'PYTHON',
4255 'python', 'noinst');
4256 return if ! @pyfiles;
4258 # Found some python.
4259 &define_configure_variable ('pythondir');
4260 &define_configure_variable ('PYTHON');
4262 $output_rules .= &file_contents ('python-clean');
4263 push (@clean, 'python');
4265 &am_error ("\`python_PYTHON' defined but \`AM_CHECK_PYTHON' not in \`$configure_ac'")
4266 if ! $seen_pythondir && &variable_defined ('python_PYTHON');
4268 if ($config_aux_dir eq '.' || $config_aux_dir eq '')
4270 &define_variable ('py_compile', '$(top_srcdir)/py-compile');
4274 &define_variable ('py_compile', $config_aux_dir . '/py-compile');
4281 local (@sourcelist) = &am_install_var ('-candist', '-clean',
4283 'java', 'noinst', 'check');
4284 return if ! @sourcelist;
4286 &define_variable ('JAVAC', 'javac');
4287 &define_variable ('JAVACFLAGS', '');
4288 &define_variable ('CLASSPATH_ENV',
4289 'CLASSPATH=$(JAVAROOT):$(srcdir)/$(JAVAROOT):$$CLASSPATH');
4290 &define_variable ('JAVAROOT', '$(top_builddir)');
4292 local (%valid) = &am_primary_prefixes ('JAVA', 1,
4293 'java', 'noinst', 'check');
4295 local ($dir, $curs);
4296 foreach $curs (keys %valid)
4298 if (! &variable_defined ($curs . '_JAVA') || $curs eq 'EXTRA')
4305 &am_line_error ($curs . '_JAVA',
4306 "multiple _JAVA primaries in use");
4311 $output_rules .= ('class' . $dir . '.stamp: $(' . $dir . '_JAVA)' . "\n"
4312 . "\t" . '$(CLASSPATH_ENV) $(JAVAC) -d $(JAVAROOT) '
4313 . '$(JAVACFLAGS) $?' . "\n"
4314 . "\t" . 'echo timestamp > class' . $dir . '.stamp'
4316 push (@all, 'class' . $dir . '.stamp');
4317 &push_dist_common ('$(' . $dir . '_JAVA)');
4320 # Handle some of the minor options.
4321 sub handle_minor_options
4323 if (defined $options{'readme-alpha'})
4325 if ($relative_dir eq '.')
4327 if ($package_version !~ /^$GNITS_VERSION_PATTERN$/)
4329 # FIXME: allow real filename.
4330 &am_conf_line_error ($configure_ac,
4331 $package_version_line,
4332 "version \`$package_version' doesn't follow Gnits standards");
4334 elsif (defined $1 && -f 'README-alpha')
4336 # This means we have an alpha release. See
4337 # GNITS_VERSION_PATTERN for details.
4338 &require_file ($FOREIGN, 'README-alpha');
4344 ################################################################
4346 # &scan_one_autoconf_file ($FILENAME)
4347 # -----------------------------------
4348 # Scan one file for interesting things. Subroutine of
4349 # &scan_autoconf_files.
4350 sub scan_one_autoconf_file
4352 local ($filename) = @_;
4355 open (CONFIGURE, $filename)
4356 || die "automake: couldn't open \`$filename': $!\n";
4357 print "automake: reading $filename\n" if $verbose;
4361 # Remove comments from current line.
4365 # Skip macro definitions. Otherwise we might be confused into
4366 # thinking that a macro that was only defined was actually
4370 # Follow includes. This is a weirdness commonly in use at
4371 # Cygnus and hopefully nowhere else.
4372 if (/sinclude\((.*)\)/ && -f $1)
4374 &scan_one_autoconf_file ($1);
4377 # Populate libobjs array.
4378 if (/AC_FUNC_ALLOCA/)
4380 $libsources{'alloca.c'} = 1;
4382 elsif (/AC_FUNC_GETLOADAVG/)
4384 $libsources{'getloadavg.c'} = 1;
4386 elsif (/AC_FUNC_MEMCMP/)
4388 $libsources{'memcmp.c'} = 1;
4390 elsif (/AC_STRUCT_ST_BLOCKS/)
4392 $libsources{'fileblocks.c'} = 1;
4394 elsif (/A[CM]_REPLACE_GNU_GETOPT/)
4396 $libsources{'getopt.c'} = 1;
4397 $libsources{'getopt1.c'} = 1;
4399 elsif (/AM_FUNC_STRTOD/)
4401 $libsources{'strtod.c'} = 1;
4403 elsif (/AM_WITH_REGEX/)
4405 $libsources{'rx.c'} = 1;
4406 $libsources{'rx.h'} = 1;
4407 $libsources{'regex.c'} = 1;
4408 $libsources{'regex.h'} = 1;
4409 $omit_dependencies{'rx.h'} = 1;
4410 $omit_dependencies{'regex.h'} = 1;
4412 elsif (/AC_FUNC_MKTIME/)
4414 $libsources{'mktime.c'} = 1;
4416 elsif (/AM_FUNC_ERROR_AT_LINE/)
4418 $libsources{'error.c'} = 1;
4419 $libsources{'error.h'} = 1;
4421 elsif (/AM_FUNC_OBSTACK/)
4423 $libsources{'obstack.c'} = 1;
4424 $libsources{'obstack.h'} = 1;
4426 elsif (/LIBOBJS="(.*)\s+\$LIBOBJS"/
4427 || /LIBOBJS="\$LIBOBJS\s+(.*)"/)
4429 foreach $libobj_iter (split (' ', $1))
4431 if ($libobj_iter =~ /^(.*)\.o(bj)?$/
4432 || $libobj_iter =~ /^(.*)\.\$ac_objext$/
4433 || $libobj_iter =~ /^(.*)\.\$\{ac_objext\}$/)
4435 $libsources{$1 . '.c'} = 1;
4439 elsif (/AC_LIBOBJ\(([^)]+)\)/)
4441 $libsources{"$1.c"} = 1;
4444 if (! $in_ac_replace && s/AC_REPLACE_FUNCS\s*\(\[?//)
4450 $in_ac_replace = 0 if s/[\]\)].*$//;
4451 # Remove trailing backslash.
4455 # Need to skip empty elements for Perl 4.
4457 $libsources{$_ . '.c'} = 1;
4461 if (/$obsolete_rx/o)
4464 if ($obsolete_macros{$1} ne '')
4466 $hint = '; ' . $obsolete_macros{$1};
4468 &am_conf_line_error ($filename, $., "\`$1' is obsolete$hint");
4471 # Process the AC_OUTPUT and AC_CONFIG_FILES macros.
4472 if (! $in_ac_output && s/AC_(OUTPUT|CONFIG_FILES)\s*\(\[?//)
4475 $ac_output_line = $.;
4479 local ($closing) = 0;
4486 # Look at potential Makefile.am's.
4489 # Must skip empty string for Perl 4.
4490 next if $_ eq "\\" || $_ eq '';
4492 # Handle $local:$input syntax. Note that we ignore
4493 # every input file past the first, though we keep
4494 # those around for later.
4495 local ($local, $input, @rest) = split (/:/);
4502 # FIXME: should be error if .in is missing.
4503 $input =~ s/\.in$//;
4506 if (-f $input . '.am')
4508 # We have a file that automake should generate.
4509 push (@make_input_list, $input);
4510 $make_list{$input} = join (':', ($local, @rest));
4514 # We have a file that automake should cause to be
4515 # rebuilt, but shouldn't generate itself.
4516 push (@other_input_files, $_);
4520 if ($closing && @make_input_list == 0 && @other_input_files == 0)
4522 &am_conf_line_error ($filename, $ac_output_line,
4523 "No files mentioned in \`AC_OUTPUT'");
4528 if (/$AC_CONFIG_AUX_DIR_PATTERN/o)
4530 @config_aux_path = $1;
4533 # Check for ansi2knr.
4534 $am_c_prototypes = 1 if /AM_C_PROTOTYPES/;
4536 # Check for exe extension stuff.
4540 $configure_vars{'EXEEXT'} = $filename . ':' . $.;
4546 $configure_vars{'OBJEXT'} = $filename . ':' . $.;
4549 # Check for `-c -o' code.
4550 $seen_cc_c_o = 1 if /AM_PROG_CC_C_O/;
4552 # Check for NLS support.
4553 if (/AM_GNU_GETTEXT/)
4556 $ac_gettext_line = $.;
4557 $omit_dependencies{'libintl.h'} = 1;
4560 # Look for ALL_LINGUAS.
4561 if (/ALL_LINGUAS="(.*)"$/ || /ALL_LINGUAS=(.*)$/)
4565 $all_linguas_line = $.;
4568 # Handle configuration headers. A config header of `[$1]'
4569 # means we are actually scanning AM_CONFIG_HEADER from
4571 if (/A([CM])_CONFIG_HEADERS?\s*\((.*)\)/
4575 ($filename, $., "\`automake requires \`AM_CONFIG_HEADER', not \`AC_CONFIG_HEADER'")
4578 $config_header_line = $.;
4580 foreach $one_hdr (split (' ', $2))
4582 push (@config_fullnames, $one_hdr);
4583 if ($one_hdr =~ /^([^:]+):(.+)$/)
4585 push (@config_names, $1);
4586 push (@config_headers, $2);
4590 push (@config_names, $one_hdr);
4591 push (@config_headers, $one_hdr . '.in');
4596 # Handle AC_CANONICAL_*. Always allow upgrading to
4597 # AC_CANONICAL_SYSTEM, but never downgrading.
4598 $seen_canonical = $AC_CANONICAL_HOST
4599 if ! $seen_canonical
4600 && (/AC_CANONICAL_HOST/ || /AC_CHECK_TOOL/);
4601 $seen_canonical = $AC_CANONICAL_SYSTEM if /AC_CANONICAL_SYSTEM/;
4603 $seen_path_xtra = 1 if /AC_PATH_XTRA/;
4605 # This macro handles several different things.
4606 if (/$AM_INIT_AUTOMAKE_PATTERN/o)
4610 $seen_prog_install = 1;
4611 ($package_version = $1) =~ s/$AM_PACKAGE_VERSION_PATTERN/$1/o;
4612 $package_version_line = $.;
4613 $seen_init_automake = 1;
4616 # Some things required by Automake.
4617 $seen_make_set = 1 if /AC_PROG_MAKE_SET/;
4618 $seen_arg_prog = 1 if /AC_ARG_PROGRAM/;
4622 $configure_vars{'LEX'} = $filename . ':' . $.;
4623 $seen_decl_yytext = 1;
4625 if (/AC_DECL_YYTEXT/ && $filename =~ /configure\.in$/)
4627 &am_conf_line_warning ($filename, $., "\`AC_DECL_YYTEXT' is covered by \`AM_PROG_LEX'");
4629 if (/AC_PROG_LEX/ && $filename =~ /configure\.in$/)
4631 &am_conf_line_warning ($filename, $., "automake requires \`AM_PROG_LEX', not \`AC_PROG_LEX'");
4634 if (/AC_PROG_(F77|YACC|RANLIB|CC|CXXCPP|CXX|LEX|AWK|CPP|LN_S)/)
4636 $configure_vars{$1} = $filename . ':' . $.;
4638 if (/$AC_CHECK_PATTERN/o)
4640 $configure_vars{$3} = $filename . ':' . $.;
4642 if (/$AM_MISSING_PATTERN/o
4646 && $1 ne 'AUTOHEADER')
4648 $configure_vars{$1} = $filename . ':' . $.;
4651 # Explicitly avoid ANSI2KNR -- we AC_SUBST that in protos.m4,
4652 # but later define it elsewhere. This is pretty hacky. We
4653 # also explicitly avoid INSTALL_SCRIPT and some other
4654 # variables because they are defined in header-vars.am.
4656 if (/$AC_SUBST_PATTERN/o
4658 && $1 ne 'INSTALL_SCRIPT'
4659 && $1 ne 'INSTALL_DATA')
4661 $configure_vars{$1} = $filename . ':' . $.;
4664 $seen_decl_yytext = 1 if /AC_DECL_YYTEXT/;
4665 if (/AM_MAINTAINER_MODE/)
4667 $seen_maint_mode = 1;
4668 $configure_cond{'MAINTAINER_MODE'} = 1;
4671 $seen_prog_install = 1 if /AC_PROG_INSTALL/;
4672 $seen_lispdir = 1 if /AM_PATH_LISPDIR/;
4673 $seen_pythondir = 1 if /AM_PATH_PYTHON/;
4675 if (/A(C|M)_PROG_LIBTOOL/)
4677 if (/AM_PROG_LIBTOOL/)
4679 &am_conf_line_warning ($filename, $., "\`AM_PROG_LIBTOOL' is obsolete, use \`AC_PROG_LIBTOOL' instead");
4683 $configure_vars{'LIBTOOL'} = $filename . ':' . $.;
4684 $configure_vars{'RANLIB'} = $filename . ':' . $.;
4685 $configure_vars{'CC'} = $filename . ':' . $.;
4686 # AC_PROG_LIBTOOL runs AC_CANONICAL_HOST. Make sure we
4687 # never downgrade (if we've seen AC_CANONICAL_SYSTEM).
4688 $seen_canonical = $AC_CANONICAL_HOST if ! $seen_canonical;
4691 $seen_multilib = 1 if (/AM_ENABLE_MULTILIB/);
4693 if (/$AM_CONDITIONAL_PATTERN/o)
4695 $configure_cond{$1} = 1;
4698 # Check for Fortran 77 intrinsic and run-time libraries.
4699 if (/AC_F77_LIBRARY_LDFLAGS/)
4701 $configure_vars{'FLIBS'} = $filename . ':' . $.;
4708 # &scan_autoconf_files ()
4709 # -----------------------
4710 # Check whether we use `configure.ac' or `configure.in'.
4711 # Scan it (and possibly `aclocal.m4') for interesting things.
4712 # We must scan aclocal.m4 because there might be AC_SUBSTs and such there.
4713 sub scan_autoconf_files
4715 # Reinitialize libsources here. This isn't really necessary,
4716 # since we currently assume there is only one configure.ac. But
4717 # that won't always be the case.
4720 local ($in_ac_output, $in_ac_replace) = (0, 0);
4721 local (%make_list, @make_input_list);
4722 local ($libobj_iter);
4724 warn "automake: both \`configure.ac' and \`configure.in' present:"
4725 . " ignoring \`configure.in'\n"
4726 if -f 'configure.ac' && -f 'configure.in';
4727 $configure_ac = 'configure.in'
4728 if -f 'configure.in';
4729 $configure_ac = 'configure.ac'
4730 if -f 'configure.ac';
4731 die "automake: \`configure.ac' or \`configure.in' is required\n"
4734 &scan_one_autoconf_file ($configure_ac);
4735 &scan_one_autoconf_file ('aclocal.m4')
4738 # Set input and output files if not specified by user.
4741 @input_files = @make_input_list;
4742 %output_files = %make_list;
4745 @configure_input_files = @make_input_list;
4747 &am_conf_error ("\`AM_INIT_AUTOMAKE' must be used")
4748 if ! $seen_init_automake;
4750 # Always require AC_PROG_MAKE_SET. We might randomly use $(MAKE)
4751 # for our own reasons.
4752 &am_conf_error ("\`AC_PROG_MAKE_SET' must be used")
4753 if ! $seen_make_set;
4755 # Look for some files we need. Always check for these. This
4756 # check must be done for every run, even those where we are only
4757 # looking at a subdir Makefile. We must set relative_dir so that
4758 # the file-finding machinery works.
4759 local ($relative_dir) = '.';
4760 &require_config_file ($FOREIGN, 'install-sh', 'mkinstalldirs', 'missing');
4761 &am_error ("\`install.sh' is an anachronism; use \`install-sh' instead")
4762 if -f $config_aux_path[0] . '/install.sh';
4764 &require_config_file ($FOREIGN, 'py-compile')
4767 # Preserve dist_common for later.
4768 %configure_dist_common = %dist_common;
4771 ################################################################
4773 # Set up for Cygnus mode.
4776 return unless $cygnus_mode;
4778 &set_strictness ('foreign');
4779 $options{'no-installinfo'} = 1;
4780 $options{'no-dependencies'} = 1;
4781 $use_dependencies = 0;
4783 if (! $seen_maint_mode)
4785 &am_conf_error ("\`AM_MAINTAINER_MODE' required when --cygnus specified");
4790 &am_conf_error ("\`AC_EXEEXT' required when --cygnus specified");
4794 # Do any extra checking for GNU standards.
4795 sub check_gnu_standards
4797 if ($relative_dir eq '.')
4799 # In top level (or only) directory.
4800 &require_file ($GNU, 'INSTALL', 'NEWS', 'README', 'COPYING',
4801 'AUTHORS', 'ChangeLog');
4804 if ($strictness >= $GNU)
4806 if (defined $options{'no-installman'})
4808 &am_line_error ('AUTOMAKE_OPTIONS',
4809 "option \`no-installman' disallowed by GNU standards");
4812 if (defined $options{'no-installinfo'})
4814 &am_line_error ('AUTOMAKE_OPTIONS',
4815 "option \`no-installinfo' disallowed by GNU standards");
4820 # Do any extra checking for GNITS standards.
4821 sub check_gnits_standards
4823 if ($relative_dir eq '.')
4825 # In top level (or only) directory.
4826 &require_file ($GNITS, 'THANKS');
4830 ################################################################
4832 # Functions to handle files of each language.
4834 # Each `lang_X_rewrite' function follows a simple formula:
4835 # * Args are the directory, base name and extension of the file.
4836 # * Return value is 1 if file is to be dealt with, 0 otherwise.
4837 # Much of the actual processing is handled in handle_single_transform_list.
4838 # These functions exist so that auxiliary information can be recorded
4839 # for a later cleanup pass. Note that the calls to these functions
4840 # are computed, so don't bother searching for their precise names
4843 # This is just a convenience function that can be used to determine
4844 # when a subdir object should be used.
4847 return defined $options{'subdir-objects'} ? $LANG_SUBDIR : $LANG_PROCESS;
4850 # Rewrite a single C source file.
4853 local ($directory, $base, $ext) = @_;
4855 if (defined $options{'ansi2knr'} && $base =~ /_$/)
4857 # FIXME: include line number in error.
4858 &am_error ("C source file \`$base.c' would be deleted by ansi2knr rules");
4861 local ($r) = $LANG_PROCESS;
4862 if (defined $options{'subdir-objects'})
4865 $base = $directory . '/' . $base;
4869 # Only give error once.
4871 # FIXME: line number.
4872 &am_error ("C objects in subdir but \`AM_PROG_CC_C_O' not in \`$configure_ac'");
4875 &require_file ($FOREIGN, 'compile')
4876 if $relative_dir eq '.';
4879 $de_ansi_files{$base} = 1;
4883 # Rewrite a single C++ source file.
4884 sub lang_cxx_rewrite
4886 return &lang_sub_obj;
4889 # Rewrite a single header file.
4890 sub lang_header_rewrite
4892 # Header files are simply ignored.
4893 return $LANG_IGNORE;
4896 # Rewrite a single yacc file.
4897 sub lang_yacc_rewrite
4899 local ($directory, $base, $ext) = @_;
4901 local ($r) = &lang_c_rewrite ($directory, $base, $ext);
4903 if ($r == $LANG_SUBDIR)
4905 $pfx = $directory . '/';
4907 $yacc_sources{$pfx . $base . '.' . $ext} = 1;
4909 &saw_extension ('c');
4911 &push_dist_common ($pfx . $base . '.' . $ext);
4915 # Rewrite a single yacc++ file.
4916 sub lang_yaccxx_rewrite
4918 local ($directory, $base, $ext) = @_;
4920 local ($r) = $LANG_PROCESS;
4922 if (defined $options{'subdir-objects'})
4924 $pfx = $directory . '/';
4927 $yacc_sources{$pfx . $base . '.' . $ext} = 1;
4929 &saw_extension ($ext);
4931 &push_dist_common ($pfx . $base . '.' . $ext);
4935 # Rewrite a single lex file.
4936 sub lang_lex_rewrite
4938 local ($directory, $base, $ext) = @_;
4940 local ($r) = &lang_c_rewrite ($directory, $base, $ext);
4942 if ($r == $LANG_SUBDIR)
4944 $pfx = $directory . '/';
4946 $lex_sources{$pfx . $base . '.' . $ext} = 1;
4948 &saw_extension ('c');
4950 &push_dist_common ($pfx . $base . '.' . $ext);
4954 # Rewrite a single lex++ file.
4955 sub lang_lexxx_rewrite
4957 local ($directory, $base, $ext) = @_;
4959 local ($r) = $LANG_PROCESS;
4961 if (defined $options{'subdir-objects'})
4963 $pfx = $directory . '/';
4966 $lex_sources{$pfx . $base . '.' . $ext} = 1;
4968 &saw_extension ($ext);
4970 &push_dist_common ($pfx . $base . '.' . $ext);
4974 # Rewrite a single assembly file.
4975 sub lang_asm_rewrite
4977 return &lang_sub_obj;
4980 # Rewrite a single Fortran 77 file.
4981 sub lang_f77_rewrite
4983 return $LANG_PROCESS;
4986 # Rewrite a single preprocessed Fortran 77 file.
4987 sub lang_ppf77_rewrite
4989 return $LANG_PROCESS;
4992 # Rewrite a single ratfor file.
4993 sub lang_ratfor_rewrite
4995 return $LANG_PROCESS;
4998 # Rewrite a single Objective C file.
4999 sub lang_objc_rewrite
5001 return &lang_sub_obj;
5004 # Rewrite a single Java file.
5005 sub lang_java_rewrite
5007 return $LANG_SUBDIR;
5010 # The lang_X_finish functions are called after all source file
5011 # processing is done. Each should handle defining rules for the
5012 # language, etc. A finish function is only called if a source file of
5013 # the appropriate type has been seen.
5017 # Push all libobjs files onto de_ansi_files. We actually only
5018 # push files which exist in the current directory, and which are
5019 # genuine source files.
5021 foreach $file (keys %libsources)
5023 if ($file =~ /^(.*)\.[cly]$/ && -f "$relative_dir/$file")
5025 $de_ansi_files{$1} = 1;
5029 if (defined $options{'ansi2knr'} && keys %de_ansi_files)
5031 # Make all _.c files depend on their corresponding .c files.
5032 local ($base, @objects);
5033 foreach $base (sort keys %de_ansi_files)
5035 # Each _.c file must depend on ansi2knr; otherwise it
5036 # might be used in a parallel build before it is built.
5037 # We need to support files in the srcdir and in the build
5038 # dir (because these files might be auto-generated. But
5039 # we can't use $< -- some makes only define $< during a
5041 $output_rules .= ($base . "_.c: $base.c \$(ANSI2KNR)\n\t"
5042 . '$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) '
5043 . '`if test -f $(srcdir)/' . $base . '.c'
5044 . '; then echo $(srcdir)/' . $base . '.c'
5045 . '; else echo ' . $base . '.c; fi` '
5046 . "| sed 's/^# \\([0-9]\\)/#line \\1/' "
5047 . '| $(ANSI2KNR) > ' . $base . "_.c\n");
5048 push (@objects, $base . '_'
5049 . ($seen_objext ? '.$(OBJEXT)' : '.o'));
5050 push (@objects, $base . '_.lo') if $seen_libtool;
5053 # Make all _.o (and _.lo) files depend on ansi2knr.
5054 # Use a sneaky little hack to make it print nicely.
5055 &pretty_print_rule ('', '', @objects, ':', '$(ANSI2KNR)');
5058 if (! defined $configure_vars{'CC'})
5060 # FIXME: line number.
5061 &am_error ("C source seen but \`CC' not defined in \`$configure_ac'");
5067 local ($ltcompile, $ltlink) = &libtool_compiler;
5069 &define_variable ('CXXLD', '$(CXX)');
5070 &define_variable ('CXXLINK', $ltlink . '$(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@');
5072 if (! defined $configure_vars{'CXX'})
5074 &am_error ("C++ source seen but \`CXX' not defined in \`$configure_ac'");
5078 sub lang_header_finish
5083 # This is a helper for both lex and yacc.
5084 sub yacc_lex_finish_helper
5086 return if defined $language_scratch{'lex-yacc-done'};
5087 $language_scratch{'lex-yacc-done'} = 1;
5089 # If there is more than one distinct yacc (resp lex) source file
5090 # in a given directory, then the `ylwrap' program is required to
5091 # allow parallel builds to work correctly. FIXME: for now, no
5093 &require_config_file ($FOREIGN, 'ylwrap');
5094 if ($config_aux_dir ne '.' && $config_aux_dir ne '')
5096 &define_variable ('YLWRAP', $config_aux_dir . "/ylwrap");
5100 &define_variable ('YLWRAP', '$(srcdir)/ylwrap');
5104 sub lang_yacc_finish
5106 return if defined $language_scratch{'yacc-done'};
5107 $language_scratch{'yacc-done'} = 1;
5109 local ($file, $base, $hname, $cname);
5110 local (%seen_suffix) = ();
5111 local (@yacc_files) = sort keys %yacc_sources;
5112 local ($yacc_count) = scalar (@yacc_files);
5113 foreach $file (@yacc_files)
5116 &output_yacc_build_rule ($1, $yacc_count > 1)
5117 if ! defined $seen_suffix{$1};
5118 $seen_suffix{$1} = 1;
5120 $file =~ /^(.*)\.(y|yy|y\+\+|yxx|ypp)$/;
5122 $hname = 'h'; # Always use `.h' for header file.
5123 ($cname = $2) =~ tr/y/c/;
5125 if ((&variable_defined ('AM_YFLAGS')
5126 && &variable_value ('AM_YFLAGS') =~ /(^|\s)-d(\s|$)/)
5127 || (&variable_defined ('YFLAGS')
5128 && &variable_value ('YFLAGS') =~ /(^|\s)-d(\s|$)/)) {
5129 # Now generate rule to make the header file. This should only
5130 # be generated if `yacc -d' specified.
5131 $output_rules .= "${base}.${hname}: ${base}.${cname}\n";
5133 # If the files are built in the build directory, then we want
5134 # to remove them with `make clean'. If they are in srcdir
5135 # they shouldn't be touched. However, we can't determine this
5136 # statically, and the GNU rules say that yacc/lex output files
5137 # should be removed by maintainer-clean. So that's what we
5139 push (@maintainer_clean_files, "${base}.${hname}");
5141 &push_dist_common ("${base}.${hname}");
5143 push (@maintainer_clean_files, "${base}.${cname}");
5145 $output_rules .= "\n";
5147 if (! defined $configure_vars{'YACC'})
5149 &am_error ("yacc source seen but \`YACC' not defined in \`$configure_ac'");
5151 if (&variable_defined ('YACCFLAGS'))
5153 &am_line_error ('YACCFLAGS',
5154 "\`YACCFLAGS' obsolete; use \`YFLAGS' instead");
5157 if ($yacc_count > 1)
5159 &yacc_lex_finish_helper;
5163 sub lang_yaccxx_finish
5170 return if defined $language_scratch{'lex-done'};
5171 $language_scratch{'lex-done'} = 1;
5173 local (%seen_suffix) = ();
5174 local ($file, $cname);
5175 local ($lex_count) = scalar (keys %lex_sources);
5176 foreach $file (sort keys %lex_sources)
5179 &output_lex_build_rule ($1, $lex_count > 1)
5180 if (! defined $seen_suffix{$1});
5181 $seen_suffix{$1} = 1;
5183 # If the files are built in the build directory, then we want
5184 # to remove them with `make clean'. If they are in srcdir
5185 # they shouldn't be touched. However, we can't determine this
5186 # statically, and the GNU rules say that yacc/lex output files
5187 # should be removed by maintainer-clean. So that's what we
5189 $file =~ /^(.*)\.(l|ll|l\+\+|lxx|lpp)$/;
5190 ($cname = $2) =~ tr/l/c/;
5191 push (@maintainer_clean_files, "${1}.${cname}");
5194 if (! defined $configure_vars{'LEX'})
5196 &am_error ("lex source seen but \`LEX' not defined in \`$configure_ac'");
5198 if (! $seen_decl_yytext)
5200 &am_error ("lex source seen but \`AC_DECL_YYTEXT' not in \`$configure_ac'");
5205 &yacc_lex_finish_helper;
5209 sub lang_lexxx_finish
5216 # We need the C code for assembly.
5222 # FIXME: this function can be called more than once. We should
5223 # arrange for it to only do anything the first time through.
5225 local ($ltcompile, $ltlink) = &libtool_compiler;
5227 &define_variable ('F77LD', '$(F77)');
5228 &define_variable ('F77LINK', $ltlink . '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@');
5230 if (! defined $configure_vars{'F77'})
5232 &am_error ("Fortran 77 source seen but \`F77' not defined in \`$configure_ac'");
5236 # Preprocessed Fortran 77
5238 # The current support for preprocessing Fortran 77 just involves passing
5239 # `$(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS)' as additional flags
5240 # to the Fortran 77 compiler, since this is how GNU Make does it; see
5241 # the `GNU Make Manual, Edition 0.51 for `make' Version 3.76 Beta'
5242 # (specifically, from info file `(make)Catalogue of Rules').
5244 # A better approach would be to write an Autoconf test
5245 # (i.e. AC_PROG_FPP) for a Fortran 77 preprocessor, because not all
5246 # Fortran 77 compilers know how to do preprocessing. The Autoconf macro
5247 # AC_PROG_FPP should test the Fortran 77 compiler first for
5248 # preprocessing capabilities, and then fall back on cpp (if cpp were
5250 sub lang_ppf77_finish
5254 # We also handle the case of preprocessing `.F' files into `.f'
5256 $output_rules .= (".F.f:\n"
5257 . "\t\$(F77COMPILE) -F \$<\n");
5260 sub lang_ratfor_finish
5264 # We also handle the case of preprocessing `.r' files into `.f'
5266 $output_rules .= (".r.f:\n"
5267 . "\t\$(RCOMPILE) -F \$<\n");
5270 sub lang_objc_finish
5272 local ($ltcompile, $ltlink) = &libtool_compiler;
5274 &define_variable ('OBJCLD', '$(OBJC)');
5275 &define_variable ('OBJCLINK', $ltlink . '$(OBJCLD) $(AM_OBJCFLAGS) $(OBJCFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@');
5277 if (! defined $configure_vars{'OBJC'})
5279 &am_error ("Objective C source seen but \`OBJC' not defined in \`$configure_ac'");
5283 sub lang_java_finish
5285 local ($ltcompile, $ltlink) = &libtool_compiler;
5287 &define_variable ('GCJLD', '$(GCJ)');
5288 &define_variable ('GCJLINK', $ltlink . '$(GCJLD) $(AM_GCJFLAGS) $(GCJFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@');
5290 if (! defined $configure_vars{'GCJ'})
5292 &am_error ("Java source seen but \`GCJ' not defined in \`$configure_ac'");
5296 # A helper which computes a sorted list of all extensions for LANG.
5301 foreach $key (sort keys %extension_seen)
5303 push (@r, '.' . $key) if $extension_map{$key} eq $lang;
5308 # A helper which decides whether libtool is needed. Returns prefix
5309 # for compiler and linker.
5310 sub libtool_compiler
5312 local ($ltcompile, $ltlink) = ('', '');
5315 &define_configure_variable ("LIBTOOL");
5316 $ltcompile = '$(LIBTOOL) --mode=compile ';
5317 $ltlink = '$(LIBTOOL) --mode=link ';
5319 return ($ltcompile, $ltlink);
5322 # Given a hash table of linker names, pick the name that has the most
5323 # precedence. This is lame, but something has to have global
5324 # knowledge in order to eliminate the conflict. Add more linkers as
5328 local (%linkers) = @_;
5331 if defined $linkers{'GCJLINK'};
5333 if defined $linkers{'CXXLINK'};
5335 if defined $linkers{'F77LINK'};
5337 if defined $linkers{'OBJCLINK'};
5341 # Called to indicate that an extension was used.
5345 $extension_seen{$ext} = 1;
5348 # Called to ask whether source files have been seen . If HEADERS is 1,
5349 # headers can be included.
5352 local ($headers) = @_;
5360 local (@exts) = &lang_extensions ('header');
5364 return scalar keys %extension_seen > $headers;
5367 # Register a single language. LANGUAGE is the name of the language.
5368 # Each OPTION is either of the form NAME=VALUE, or is a file extension
5370 sub register_language
5372 local ($language, @options) = @_;
5375 $language_map{$language . '-ansi-p'} = 0;
5376 $language_map{$language . '-linker'} = '';
5377 $language_map{$language . '-autodep'} = 'no';
5378 $language_map{$language . '-derived-autodep'} = 'no';
5381 foreach $iter (@options)
5383 if ($iter =~ /^(.*)=(.*)$/)
5385 $language_map{$language . '-' . $1} = $2;
5387 elsif (defined $extension_map{$iter})
5390 "automake: programming error: duplicate extension $iter\n";
5395 $extension_map{$iter} = $language;
5400 # This function is used to find a path from a user-specified suffix to
5401 # `o' or to some other suffix we recognize internally, eg `cc'.
5404 local ($source_ext) = @_;
5406 # FIXME: hard-coding `o' is a mistake. Doing something
5407 # intelligent is harder.
5408 while ($extension_map{$source_ext} eq ''
5409 && $source_ext ne 'o'
5410 && defined $suffix_rules{$source_ext})
5412 $source_ext = $suffix_rules{$source_ext};
5419 ################################################################
5421 # Pretty-print something. HEAD is what should be printed at the
5422 # beginning of the first line, FILL is what should be printed at the
5423 # beginning of every subsequent line.
5424 sub pretty_print_internal
5426 local ($head, $fill, @values) = @_;
5428 local ($column) = length ($head);
5429 local ($result) = $head;
5431 # Fill length is number of characters. However, each Tab
5432 # character counts for eight. So we count the number of Tabs and
5434 local ($fill_length) = length ($fill);
5435 $fill_length += 7 * ($fill =~ tr/\t/\t/d);
5437 local ($bol) = ($head eq '');
5440 # "71" because we also print a space.
5441 if ($column + length ($_) > 71)
5443 $result .= " \\\n" . $fill;
5444 $column = $fill_length;
5448 $result .= ' ' unless ($bol);
5450 $column += length ($_) + 1;
5458 # Pretty-print something and append to output_vars.
5461 $output_vars .= &pretty_print_internal (@_);
5464 # Pretty-print something and append to output_rules.
5465 sub pretty_print_rule
5467 $output_rules .= &pretty_print_internal (@_);
5471 ################################################################
5473 # See if a target exists.
5476 local ($target) = @_;
5477 return defined $targets{$target};
5480 # See if two conditionals are the same.
5481 sub conditional_same
5483 local ($cond1, $cond2) = @_;
5485 return (&conditional_true_when ($cond1, $cond2)
5486 && &conditional_true_when ($cond2, $cond1));
5489 # See if a conditional is true. Both arguments are conditional
5490 # strings. This returns true if the first conditional is true when
5491 # the second conditional is true.
5492 sub conditional_true_when
5494 local ($cond, $when) = @_;
5496 # Check the easy case first.
5502 # Check each component of $cond, which looks @COND1@@COND2@.
5503 foreach $comp (split ('@', $cond))
5505 # The way we split will give null strings between each
5509 if (index ($when, '@' . $comp . '@') == -1)
5518 # Check for an ambiguous conditional. This is called when a variable
5519 # or target is being defined conditionally. If we already know about
5520 # a definition that is true under the same conditions, then we have an
5522 sub check_ambiguous_conditional
5524 local ($var_name, $cond) = @_;
5525 local (@cond_vals) = split (' ', $conditional{$var_name});
5528 local ($vcond) = shift (@cond_vals);
5530 if (&conditional_true_when ($vcond, $cond)
5531 || &conditional_true_when ($cond, $vcond))
5533 &am_line_error ($var_name,
5534 "$var_name multiply defined in condition");
5539 # See if a variable exists. The first argument is the variable name,
5540 # and the optional second argument is the condition which we should
5541 # check. If no condition is given, we currently return true if the
5542 # variable is defined under any condition.
5543 sub variable_defined
5545 local ($var, $cond) = @_;
5546 if (defined $targets{$var})
5548 &am_line_error ($var, "\`$var' is target; expected variable");
5551 elsif (defined $contents{$var})
5553 if ($cond && $conditional{$var})
5555 # We have been asked to check for a particular condition,
5556 # and the variable is defined conditionally. We need to
5557 # look through the conditions under which the variable is
5558 # defined, and see if any of them match the conditional we
5559 # have been asked to check.
5560 local (@cond_vars) = split (' ', $conditional{$var});
5563 if (&conditional_same ($cond, shift (@cond_vars)))
5565 # Even a conditional examination is good enough
5566 # for us. FIXME: really should maintain examined
5567 # status on a per-condition basis.
5568 $content_seen{$var} = 1;
5574 # The variable is not defined for the given condition.
5578 $content_seen{$var} = 1;
5584 # Mark a variable as examined.
5585 sub examine_variable
5588 &variable_defined ($var);
5591 # Quote a value in order to put it in $conditional. We need to quote
5592 # spaces, and we need to handle null strings, so that we can later
5593 # retrieve values by splitting on space.
5597 $val =~ tr/ \t\n/\001\003\004/;
5598 $val = "\002" if $val eq '';
5602 # Unquote a value in $conditional.
5603 sub unquote_cond_val
5606 $val =~ tr/\001\003\004/ \t\n/;
5611 # Return the set of conditions for which a variable is defined.
5613 # If the variable is not defined conditionally, and is not defined in
5614 # terms of any variables which are defined conditionally, then this
5615 # returns the empty list.
5617 # If the variable is defined conditionally, but is not defined in
5618 # terms of any variables which are defined conditionally, then this
5619 # returns the list of conditions for which the variable is defined.
5621 # If the variable is defined in terms of any variables which are
5622 # defined conditionally, then this returns a full set of permutations
5623 # of the subvariable conditions. For example, if the variable is
5624 # defined in terms of a variable which is defined for @COND_TRUE@,
5625 # then this returns both @COND_TRUE@ and @COND_FALSE@. This is
5626 # because we will need to define the variable under both conditions.
5628 sub variable_conditions
5636 foreach $cond (&variable_conditions_sub ($var, '', ()))
5638 $uniqify{$cond} = 1;
5641 @uniq_list = sort keys %uniqify;
5642 # Note we cannot just do `return sort keys %uniqify', because this
5643 # function is sometimes used in a scalar context.
5647 # A subroutine of variable_conditions. We only return conditions
5648 # which are true for all the conditions in @PARENT_CONDS.
5649 sub variable_conditions_sub
5651 local ($var, $parent, @parent_conds) = @_;
5652 local (@new_conds) = ();
5654 if (defined $vars_scanned{$var})
5656 &am_line_error ($parent, "variable \`$var' recursively defined");
5659 $vars_scanned{$var} = 1;
5661 if (! $conditional{$var})
5663 foreach (split (' ', $contents{$var}))
5665 # If a comment seen, just leave.
5668 # Handle variable substitutions.
5669 if (/^\$\{(.*)\}$/ || /^\$\((.*)\)$/)
5672 &variable_conditions_sub ($1, $var, @parent_conds));
5676 # Now we want to return all permutations of the subvariable
5678 local (%allconds, $item);
5679 foreach $item (@new_conds)
5681 foreach (split ('@', $item))
5685 $allconds{$_ . '_TRUE'} = 1;
5689 # Unset our entry in vars_scanned. We only care about recursive
5691 delete $vars_scanned{$var};
5693 return &variable_conditions_permutations (sort keys %allconds);
5696 local (@this_conds) = ();
5697 local (@condvals) = split (' ', $conditional{$var});
5700 local ($cond) = shift (@condvals);
5701 local ($val) = &unquote_cond_val (shift (@condvals));
5706 local ($parent_cond);
5707 foreach $parent_cond (@parent_conds)
5709 if (! &conditional_true_when ($parent_cond, $cond))
5719 push (@this_conds, $cond);
5721 push (@parent_conds, $cond);
5722 local (@subvar_conds) = ();
5723 foreach (split (' ', $val))
5725 # If a comment seen, just leave.
5728 # Handle variable substitutions.
5729 if (/^\$\{(.*)\}$/ || /^\$\((.*)\)$/)
5731 push (@subvar_conds,
5732 &variable_conditions_sub ($1, $var, @parent_conds));
5735 pop (@parent_conds);
5737 # If there are no conditional subvariables, then we want to
5738 # return this condition. Otherwise, we want to return the
5739 # permutations of the subvariables.
5740 if (! @subvar_conds)
5742 push (@new_conds, $cond);
5746 push (@new_conds, &variable_conditions_reduce (@subvar_conds));
5750 # Unset our entry in vars_scanned. We only care about recursive
5752 delete $vars_scanned{$var};
5757 # If we are being called on behalf of another variable, we need to
5758 # return all possible permutations of the conditions. We have
5759 # already handled everything in @this_conds along with their
5760 # subvariables. We now need to add any permutations that are not
5763 foreach $this_cond (@this_conds)
5766 &variable_conditions_permutations (split('@', $this_cond));
5768 foreach $perm (@perms)
5772 foreach $scan (@this_conds)
5774 if (&conditional_true_when ($perm, $scan)
5775 || &conditional_true_when ($scan, $perm))
5786 local ($parent_cond);
5787 foreach $parent_cond (@parent_conds)
5789 if (! &conditional_true_when ($parent_cond, $perm))
5799 # This permutation was not already handled, and is valid
5801 push (@new_conds, $perm);
5808 # Subroutine for variable_conditions_sort
5809 sub variable_conditions_cmp
5815 return (length ($as) <=> length ($bs)
5819 # Sort a list of conditionals so that only the exclusive ones are
5820 # retained. For example, if both @COND1_TRUE@@COND2_TRUE@ and
5821 # @COND1_TRUE@ are in the list, discard the latter.
5822 sub variable_conditions_reduce
5824 local (@conds) = @_;
5827 foreach $cond (sort variable_conditions_cmp @conds)
5831 foreach $scan (@ret)
5833 if (&conditional_true_when ($cond, $scan))
5846 # Return a list of permutations of a conditional string.
5847 sub variable_conditions_permutations
5849 local (@comps) = @_;
5852 local ($comp) = shift (@comps);
5853 return &variable_conditions_permutations (@comps)
5855 local ($neg) = $comp;
5856 $neg =~ s/TRUE$/TRUEO/;
5857 $neg =~ s/FALSE$/TRUE/;
5858 $neg =~ s/TRUEO$/FALSE/;
5861 foreach $sub (&variable_conditions_permutations (@comps))
5863 push (@ret, '@' . $comp . '@' . $sub);
5864 push (@ret, '@' . $neg . '@' . $sub);
5868 push (@ret, '@' . $comp . '@');
5869 push (@ret, '@' . $neg . '@');
5874 # Warn if a variable is conditionally defined. This is called if we
5875 # are using the value of a variable.
5876 sub variable_conditionally_defined
5878 local ($var, $parent) = @_;
5879 if ($conditional{$var})
5883 &am_line_error ($parent,
5884 "warning: automake does not support conditional definition of $var in $parent");
5888 &am_line_error ($parent,
5889 "warning: automake does not support $var being defined conditionally")
5894 # Get the value of a variable. This just returns $contents, but warns
5895 # if the variable is conditionally defined.
5899 &variable_conditionally_defined ($var);
5900 return $contents{$var};
5903 # Convert a variable value to a list, split as whitespace. This will
5904 # recursively follow $(...) and ${...} inclusions. It preserves @...@
5905 # substitutions. If COND is 'all', then all values under all
5906 # conditions should be returned; if COND is a particular condition
5907 # (all conditions are surrounded by @...@) then only the value for
5908 # that condition should be returned; otherwise, warn if VAR is
5909 # conditionally defined. SCANNED is a global hash listing whose keys
5910 # are all the variables already scanned; it is an error to rescan a
5914 local ($var, $val, $cond) = @_;
5918 $val =~ s/\\(\n|$)/ /g;
5920 foreach (split (' ', $val))
5922 # If a comment seen, just leave.
5925 # Handle variable substitutions.
5926 if (/^\$\{([^}]*)\}$/ || /^\$\(([^)]*)\)$/)
5928 local ($varname) = $1;
5930 # If the user uses a losing variable name, just ignore it.
5931 # This isn't ideal, but people have requested it.
5932 next if ($varname =~ /\@.*\@/);
5936 if ($varname =~ /^([^:]*):([^=]*)=(.*)$/)
5940 ($from = $2) =~ s/(\W)/\\$1/g;
5944 @temp_list = &variable_value_as_list_worker ($1, $cond, $var);
5946 # Now rewrite the value if appropriate.
5949 grep (s/$from$/$to/, @temp_list);
5952 push (@result, @temp_list);
5963 # Return contents of variable as list, split as whitespace. This will
5964 # recursively follow $(...) and ${...} inclusions. It preserves @...@
5965 # substitutions. If COND is 'all', then all values under all
5966 # conditions should be returned; if COND is a particular condition
5967 # (all conditions are surrounded by @...@) then only the value for
5968 # that condition should be returned; otherwise, warn if VAR is
5969 # conditionally defined. If PARENT is specified, it is the name of
5970 # the including variable; this is only used for error reports.
5971 sub variable_value_as_list_worker
5973 local ($var, $cond, $parent) = @_;
5976 if (defined $targets{$var})
5978 &am_line_error ($var, "\`$var' is target; expected variable");
5980 elsif (! defined $contents{$var} && ! defined $am_var_defs{$var})
5982 &am_line_error ($parent, "variable \`$var' not defined");
5984 elsif (defined $vars_scanned{$var})
5986 # `vars_scanned' is a global we use to keep track of which
5987 # variables we've already examined.
5988 &am_line_error ($parent, "variable \`$var' recursively defined");
5990 elsif ($cond eq 'all' && $conditional{$var})
5992 $vars_scanned{$var} = 1;
5993 local (@condvals) = split (' ', $conditional{$var});
5997 local ($val) = &unquote_cond_val (shift (@condvals));
5998 push (@result, &value_to_list ($var, $val, $cond));
6001 elsif ($cond && $conditional{$var})
6003 $vars_scanned{$var} = 1;
6004 local (@condvals) = split (' ', $conditional{$var});
6008 local ($vcond) = shift (@condvals);
6009 local ($val) = &unquote_cond_val (shift (@condvals));
6010 if (&conditional_true_when ($vcond, $cond))
6012 # Warn if we have an ambiguity. It's hard to know how
6013 # to handle this case correctly.
6014 &variable_conditionally_defined ($var, $parent)
6017 push (@result, &value_to_list ($var, $val, $cond));
6021 elsif (defined $am_var_defs{$var})
6023 $vars_scanned{$var} = 1;
6024 &variable_conditionally_defined ($var, $parent);
6025 $content_seen{$var} = 1;
6026 push (@result, &value_to_list ($var, $am_var_defs{$var}, $cond));
6030 $vars_scanned{$var} = 1;
6031 &variable_conditionally_defined ($var, $parent);
6032 $content_seen{$var} = 1;
6033 push (@result, &value_to_list ($var, $contents{$var}, $cond));
6036 # Unset our entry in vars_scanned. We only care about recursive
6038 delete $vars_scanned{$var};
6043 # This is just a wrapper for variable_value_as_list_worker that
6044 # initializes the global hash `vars_scanned'. This hash is used to
6045 # avoid infinite recursion.
6046 sub variable_value_as_list
6048 local ($var, $cond, $parent) = @_;
6050 return &variable_value_as_list_worker ($var, $cond, $parent);
6054 # define_variable ($VAR, $VALUE)
6055 # ------------------------------
6056 # Define a new variable VAR to VALUE, but only if not already defined.
6059 local ($var, $value) = @_;
6061 if (! defined $contents{$var})
6063 $output_vars .= $var . ' = ' . $value . "\n";
6064 $contents{$var} = $value;
6065 $content_seen{$var} = 1;
6067 elsif ($var_was_plus_eq{$var})
6069 &am_line_error ($var, "internally generated variable \`$var' was set with \`+='");
6073 # Like define_variable, but the value is a list, and the variable may
6074 # be defined conditionally. The second argument is the conditional
6075 # under which the value should be defined; this should be the empty
6076 # string to define the variable unconditionally. The third argument
6077 # is a list holding the values to use for the variable. The value is
6078 # pretty printed in the output file.
6079 sub define_pretty_variable
6081 local ($var, $cond, @value) = @_;
6082 if (! defined $contents{$var}
6083 || ($cond && ! &variable_defined ($var, $cond)))
6085 $contents{$var} = join (' ', @value);
6088 if ($conditional{$var})
6090 $conditional{$var} .= ' ';
6094 $conditional{$var} = '';
6096 $conditional{$var} .= ($cond
6098 . "e_cond_val ($contents{$var}));
6100 &pretty_print ($cond . $var . ' = ', $cond, @value);
6101 $content_seen{$var} = 1;
6105 # Like define_variable, but define a variable to be the configure
6106 # substitution by the same name.
6107 sub define_configure_variable
6110 local ($value) = '@' . $var . '@';
6111 &define_variable ($var, $value);
6114 # Define a compiler variable. We also handle defining the `LT'
6115 # version of the command when using libtool.
6116 sub define_compiler_variable
6118 local ($var, $ltcompile, $value) = @_;
6119 local ($name) = $var;
6120 &define_variable ($name, $value);
6121 &define_variable ('LT' . $name, $ltcompile . $value)
6125 # Define a variable that represents a program to run. If in Cygnus
6126 # mode, the program is searched for in the build (or source) tree.
6127 # Otherwise no searching is done at all. Arguments are:
6128 # * VAR Name of variable to define
6129 # * WHATDIR Either `src' or `build', depending on where program should
6130 # be found. (runtest is in srcdir!)
6131 # * SUBDIR Subdir of top-level dir
6132 # * PROGRAM Name of program
6133 # * OVERRIDE If specified, the name of the program to use when not in
6134 # Cygnus mode. Defaults to PROGRAM.
6135 sub define_program_variable
6137 local ($var, $whatdir, $subdir, $program, $override) = @_;
6141 $override = $program;
6146 local ($full) = ('$(top_' . $whatdir . 'dir)/../'
6147 . $subdir . '/' . $program);
6148 &define_variable ($var, ('`if test -f ' . $full
6149 . '; then echo ' . $full . '; else echo '
6150 . $program . '; fi`'));
6154 &define_variable ($var, $override);
6159 ################################################################
6161 # Read Makefile.am and set up %contents. Simultaneously copy lines
6162 # from Makefile.am into $output_trailer or $output_vars as
6163 # appropriate. NOTE we put rules in the trailer section. We want
6164 # user rules to come after our generated stuff.
6167 local ($amfile) = @_;
6170 open (AM_FILE, $amfile) || die "automake: couldn't open \`$amfile': $!\n";
6171 print "automake: reading $amfile\n" if $verbose;
6173 local ($saw_bk) = 0;
6174 local ($was_rule) = 0;
6175 local ($spacing) = '';
6176 local ($comment) = '';
6177 local ($last_var_name) = '';
6180 # We save the conditional stack on entry, and then check to make
6181 # sure it is the same on exit. This lets us conditonally include
6183 local (@saved_cond_stack) = @conditional_stack;
6187 if (/$IGNORE_PATTERN/o)
6189 # Merely delete comments beginning with two hashes.
6191 elsif (/$WHITE_PATTERN/o)
6193 # Stick a single white line before the incoming macro or rule.
6197 elsif (/$COMMENT_PATTERN/o)
6199 # Stick comments before the incoming macro or rule. Make
6200 # sure a blank line preceeds first block of comments.
6201 $spacing = "\n" unless $blank;
6203 $comment .= $spacing . $_;
6212 $output_vars .= $comment . "\n";
6216 local ($is_ok_macro);
6220 unless substr ($_, -1, 1) eq "\n";
6222 # Don't look at MAINTAINER_MODE_TRUE here. That shouldn't be
6223 # used by users. @MAINT@ is an anachronism now.
6224 $_ =~ s/\@MAINT\@//g
6225 unless $seen_maint_mode;
6227 if (/$IGNORE_PATTERN/o)
6229 # Merely delete comments beginning with two hashes.
6231 elsif (/$WHITE_PATTERN/o)
6233 # Stick a single white line before the incoming macro or rule.
6235 &am_line_error ($., "blank line following trailing backslash")
6238 elsif (/$COMMENT_PATTERN/o)
6240 # Stick comments before the incoming macro or rule.
6241 $comment .= $spacing . $_;
6243 &am_line_error ($., "comment following trailing backslash")
6250 $output_trailer .= join ('', @conditional_stack) . $_;
6256 $contents{$last_var_name} .= ' '
6257 unless $contents{$last_var_name} =~ /\s$/;
6258 $contents{$last_var_name} .= $_;
6259 if (@conditional_stack)
6261 $conditional{$last_var_name} .= "e_cond_val ($_);
6265 elsif (/$IF_PATTERN/o)
6267 &am_line_error ($., "$1 does not appear in AM_CONDITIONAL")
6268 if (! $configure_cond{$1});
6269 push (@conditional_stack, "\@" . $1 . "_TRUE\@");
6271 elsif (/$ELSE_PATTERN/o)
6273 if (! @conditional_stack)
6275 &am_line_error ($., "else without if");
6277 elsif ($conditional_stack[$#conditional_stack] =~ /_FALSE\@$/)
6279 &am_line_error ($., "else after else");
6283 $conditional_stack[$#conditional_stack]
6284 =~ s/_TRUE\@$/_FALSE\@/;
6287 elsif (/$ENDIF_PATTERN/o)
6289 if (! @conditional_stack)
6291 &am_line_error ($., "endif without if");
6295 pop @conditional_stack;
6298 elsif (/$RULE_PATTERN/o)
6302 if (defined $contents{$1}
6303 && (@conditional_stack
6304 ? ! defined $conditional{$1}
6305 : defined $conditional{$1}))
6308 "$1 defined both conditionally and unconditionally");
6310 # Value here doesn't matter; for targets we only note
6314 local ($cond_string) = join ('', @conditional_stack);
6315 if (@conditional_stack)
6317 if ($conditional{$1})
6319 &check_ambiguous_conditional ($1, $cond_string);
6320 $conditional{$1} .= ' ';
6324 $conditional{$1} = '';
6326 $conditional{$1} .= $cond_string . ' 1';
6328 $content_lines{$1} = $.;
6329 $output_trailer .= $comment . $spacing . $cond_string . $_;
6330 $comment = $spacing = '';
6333 # Check the rule for being a suffix rule. If so, store in
6336 local ($source_suffix);
6337 local ($object_suffix);
6339 if (($source_suffix, $object_suffix) = ($1 =~ $SUFFIX_RULE_PATTERN))
6341 $suffix_rules{$source_suffix} = $object_suffix;
6342 print "Sources ending in .$source_suffix become .$object_suffix\n" if $verbose;
6343 $source_suffix_pattern = "(" . join ('|', keys %suffix_rules) . ")";
6346 # FIXME: make sure both suffixes are in SUFFIXES? Or set
6347 # SUFFIXES from suffix_rules?
6349 elsif (($is_ok_macro = /$MACRO_PATTERN/o)
6350 || /$BOGUS_MACRO_PATTERN/o)
6352 # Found a macro definition.
6354 $last_var_name = $1;
6355 if (defined $contents{$1}
6356 && (@conditional_stack
6357 ? ! defined $conditional{$1}
6358 : defined $conditional{$1}))
6361 "$1 defined both conditionally and unconditionally");
6364 if ($3 ne '' && substr ($3, -1) eq "\\")
6366 # We preserve the `\' because otherwise the long lines
6367 # that are generated will be truncated by broken
6377 if (! defined $contents{$last_var_name})
6379 # The first assignment to a macro sets the line
6380 # number. Ideally I suppose we would associate line
6381 # numbers with random bits of text.
6382 $content_lines{$last_var_name} = $.;
6384 # If first assignment, set `+=' indicator.
6385 $var_was_plus_eq{$last_var_name} =
6387 && ! defined $am_var_defs{$last_var_name});
6392 if (! defined $contents{$last_var_name}
6393 && defined $am_var_defs{$last_var_name})
6395 $contents{$last_var_name} = $am_var_defs{$last_var_name};
6397 if (substr ($contents{$last_var_name}, -1) eq "\n")
6399 # Insert a backslash before a trailing newline.
6400 $contents{$last_var_name}
6401 = substr ($contents{$last_var_name}, 0, -1) . "\\\n";
6403 $contents{$last_var_name} .= ' ' . $value;
6407 $contents{$last_var_name} = $value;
6409 local ($cond_string) = join ('', @conditional_stack);
6410 if (@conditional_stack)
6414 if ($conditional{$last_var_name})
6418 # If we're adding to the conditional, and it
6419 # exists, then we might want to simply replace
6420 # the old value with the new one.
6421 local (@new_vals, @cond_vals);
6422 @cond_vals = split (' ', $conditional{$last_var_name});
6425 local ($vcond) = shift (@cond_vals);
6426 push (@new_vals, $vcond);
6427 if (&conditional_same ($vcond, $cond_string))
6430 $val = (&unquote_cond_val (shift (@cond_vals))
6432 push (@new_vals, "e_cond_val ($val));
6436 push (@new_vals, shift (@cond_vals));
6441 $conditional{$last_var_name}
6442 = join (' ', @new_vals);
6448 &check_ambiguous_conditional ($last_var_name,
6450 $conditional{$last_var_name} .= ' ';
6456 $conditional{$last_var_name} = '';
6457 $val = $contents{$last_var_name};
6461 $conditional{$last_var_name} .= ($cond_string
6463 . "e_cond_val ($val));
6467 # FIXME: this doesn't always work correctly; it will group
6468 # all comments for a given variable, no matter where
6470 $am_vars{$last_var_name} = $comment . $spacing;
6471 $def_type{$last_var_name} = ($type eq ':') ? ':' : '';
6472 push (@var_list, $last_var_name);
6473 $comment = $spacing = '';
6477 &am_line_error ($., "bad macro name \`$last_var_name'")
6480 elsif (/$INCLUDE_PATTERN/o)
6484 if ($path =~ s/^\$\(top_srcdir\)\///)
6486 push (@include_stack, "\$\(top_srcdir\)/$path");
6490 $path =~ s/\$\(srcdir\)\///;
6491 push (@include_stack, "\$\(srcdir\)/$path");
6492 $path = $relative_dir . "/" . $path;
6494 &read_am_file ($path);
6498 # This isn't an error; it is probably a continued rule.
6499 # In fact, this is what we assume.
6501 $output_trailer .= ($comment . $spacing
6502 . join ('', @conditional_stack) . $_);
6503 $comment = $spacing = '';
6510 $output_trailer .= $comment;
6512 if (join (' ', @saved_cond_stack) ne join (' ', @conditional_stack))
6514 if (@conditional_stack)
6516 &am_error ("unterminated conditionals: " . join (' ', @conditional_stack));
6520 # FIXME: better error message here.
6521 &am_error ("conditionals not nested in include file");
6526 # A helper for read_main_am_file which initializes configure variables
6527 # and variables from header-vars.am. This is a subr so we can call it
6529 sub define_standard_variables
6531 # Compute relative location of the top object directory.
6532 local (@topdir) = ();
6533 foreach (split (/\//, $relative_dir))
6535 next if $_ eq '.' || $_ eq '';
6542 push (@topdir, '..');
6545 @topdir = ('.') if ! @topdir;
6547 $top_builddir = join ('/', @topdir);
6549 ($build_rx = $top_builddir) =~ s/(\W)/\\$1/g;
6550 $output_vars .= &file_contents_with_transform
6551 ('s/\@top_builddir\@/' . $build_rx . '/g;',
6554 # Generate some useful variables when AC_CANONICAL_* used. FIXME:
6555 # this should use generic %configure_vars method.
6556 if ($seen_canonical)
6558 local ($curs, %vars);
6559 $vars{'host_alias'} = 'host_alias';
6560 $vars{'host_triplet'} = 'host';
6561 if ($seen_canonical == $AC_CANONICAL_SYSTEM)
6563 $vars{'build_alias'} = 'build_alias';
6564 $vars{'build_triplet'} = 'build';
6565 $vars{'target_alias'} = 'target_alias';
6566 $vars{'target_triplet'} = 'target';
6568 foreach $curs (sort keys %vars)
6570 $output_vars .= "$curs = \@$vars{$curs}\@\n";
6571 $contents{$curs} = "\@$vars{$curs}\@";
6576 foreach $curs (sort keys %configure_vars)
6578 &define_configure_variable ($curs);
6582 # Read main am file.
6583 sub read_main_am_file
6585 local ($amfile) = @_;
6587 # The keys here are variables we want to dump at the end of this
6588 # function. The values are corresponding comments.
6589 local (%am_vars) = ();
6590 local (@var_list) = ();
6591 local (%def_type) = ();
6593 # This supports the strange variable tricks we are about to play.
6594 if (scalar keys %contents > 0)
6596 print STDERR "automake: programming error: variable defined before read_main_am_file\n";
6600 # We want to predefine as many variables as possible. This lets
6601 # the user set them with `+=' in Makefile.am. However, we don't
6602 # want these initial definitions to end up in the output quite
6603 # yet. So we adopt a hack: read the `.am' file twice, throwing
6604 # away the output the first time. We also squirrel away a list of
6605 # all the variables defined by the .am file so that we know which
6606 # ones to remove from the content list.
6609 &define_standard_variables;
6610 local (%saved_contents) = %contents;
6612 # Read user file, but discard text of variable assignments we just
6615 &read_am_file ($amfile);
6617 # Now dump the variables that were defined. We do it in the same
6618 # order in which they were defined (skipping duplicates).
6620 foreach $curs (@var_list)
6622 next if $done{$curs};
6625 $output_vars .= $am_vars{$curs};
6626 if ($conditional{$curs})
6628 local (@cond_vals) = split (' ', $conditional{$curs});
6631 local ($vcond) = shift (@cond_vals);
6632 local ($val) = &unquote_cond_val (shift (@cond_vals));
6633 $output_vars .= ($vcond . $curs . ' '
6634 . $def_type{$curs} . "= ");
6636 foreach $line (split ("\n", $val))
6638 $output_vars .= $vcond . $line . "\n";
6640 $output_vars .= "\n"
6646 $output_vars .= ($curs . ' ' . $def_type{$curs} . '= '
6647 . $contents{$curs} . "\n");
6651 # Generate copyright header for generated Makefile.in.
6652 local ($ov) = $output_vars;
6653 $output_vars = ("# $in_file_name generated automatically by automake "
6654 . $VERSION . " from $am_file_name\n");
6655 $output_vars .= $gen_copyright;
6657 # Now go through and delete all the variables that the user did
6660 foreach $var (keys %saved_contents)
6662 if ($contents{$var} eq $saved_contents{$var})
6664 delete $contents{$var};
6668 # Re-read the standard variables, and this time keep their
6669 # contributions to the output. Then add the user's output to the
6671 &define_standard_variables;
6672 $output_vars .= $ov;
6676 ################################################################
6678 sub initialize_global_constants
6680 # Values for AC_CANONICAL_*
6681 $AC_CANONICAL_HOST = 1;
6682 $AC_CANONICAL_SYSTEM = 2;
6684 # Associative array of standard directory names. Entry is TRUE if
6685 # corresponding directory should be installed during
6686 # 'install-exec' phase.
6704 # Commonly found files we look for and automatically include in
6708 'README', 'THANKS', 'TODO', 'NEWS', 'COPYING', 'COPYING.LIB',
6709 'INSTALL', 'ABOUT-NLS', 'ChangeLog', 'configure.ac',
6710 'configure.in', 'configure', 'config.guess', 'config.sub',
6711 'AUTHORS', 'BACKLOG', 'ABOUT-GNU', 'libversion.in',
6712 'mdate-sh', 'mkinstalldirs', 'install-sh', 'texinfo.tex',
6713 'ansi2knr.c', 'ansi2knr.1', 'elisp-comp',
6714 # ltconfig appears here for compatibility with old versions
6716 'ylwrap', 'acinclude.m4', @libtoolize_files, @libtoolize_sometimes,
6717 'missing', 'depcomp', 'compile', 'py-compile'
6720 # Commonly used files we auto-include, but only sometimes.
6723 'aclocal.m4', 'acconfig.h', 'config.h.top',
6724 'config.h.bot', 'stamp-h.in', 'stamp-vti'
6728 -a, --add-missing add missing standard files to package
6729 --amdir=DIR directory storing config files
6730 -c, --copy with -a, copy missing files (default is symlink)
6731 --cygnus assume program is part of Cygnus-style tree
6732 --force-missing force update of standard files
6733 --foreign set strictness to foreign
6734 --gnits set strictness to gnits
6735 --gnu set strictness to gnu
6736 --help print this help, then exit
6737 -i, --ignore-deps disable dependency tracking code
6738 --include-deps enable dependency tracking code
6739 --no-force only update Makefile.in's that are out of date
6740 -o DIR, --output-dir=DIR
6741 put generated Makefile.in's into DIR
6742 -v, --verbose verbosely list files processed
6743 --version print version number, then exit\n";
6745 # Copyright on generated Makefile.ins.
6747 # Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000
6748 # Free Software Foundation, Inc.
6749 # This Makefile.in is free software; the Free Software Foundation
6750 # gives unlimited permission to copy and/or distribute it,
6751 # with or without modifications, as long as this notice is preserved.
6753 # This program is distributed in the hope that it will be useful,
6754 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
6755 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
6756 # PARTICULAR PURPOSE.
6759 # This complex find command will try to avoid changing the modes of
6760 # links into the source tree, in case they're hard-linked. It will
6761 # also make directories writable by everybody, because some
6762 # brain-dead tar implementations change ownership and permissions of
6763 # a directory before extracting the files, thus becoming unable to
6765 # Ignore return result from chmod, because it might give an error
6766 # if we chmod a symlink.
6767 # Another nastiness: if the file is unreadable by us, we make it
6768 # readable regardless of the number of links to it. This only
6769 # happens in perverse cases.
6770 # We use $(install_sh) because that is a known-portable way to
6771 # modify the file in place in the source tree.
6772 $dist_header = ' -find $(distdir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \\
6773 ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \\
6774 ! -type d ! -perm -400 -exec chmod a+r {} \; -o \\
6775 ! -type d ! -perm -444 -exec $(SHELL) $(install_sh) -c -m a+r {} {} \; \\
6776 || chmod -R a+r $(distdir)
6778 $dist{'dist-bzip2'} = ("\t"
6779 . '$(AMTAR) chof - $(distdir) | bzip2 -9 -c > $(distdir).tar.bz2'
6781 $dist{'dist-tarZ'} = ("\t"
6782 . '$(AMTAR) chof - $(distdir) | compress -c > $(distdir).tar.Z'
6784 $dist{'dist-shar'} = ("\t"
6785 . 'shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c > $(distdir).shar.gz'
6787 $dist{'dist-zip'} = ("\t" . '-rm -f $(distdir).zip' . "\n" .
6788 "\t" . 'zip -rq $(distdir).zip $(distdir)' . "\n");
6790 # Note that we don't use GNU tar's `-z' option. One reason (but
6791 # not the only reason) is that some versions of tar (e.g., OSF1)
6792 # interpret `-z' differently.
6793 $dist{'dist'} = ("\t"
6794 . '$(AMTAR) chof - $(distdir) | GZIP=$(GZIP_ENV) gzip -c > $(distdir).tar.gz'
6796 $dist_trailer = "\t" . '-chmod -R a+w $(distdir) > /dev/null 2>&1; rm -rf $(distdir)' . "\n";
6799 # (Re)-Initialize per-Makefile.am variables.
6800 sub initialize_per_input
6802 # These two variables are used when generating each Makefile.in.
6803 # They hold the Makefile.in until it is ready to be printed.
6806 $output_trailer = '';
6808 $output_header = '';
6810 # Suffixes found during a run.
6813 # This holds the contents of a Makefile.am, as parsed by
6817 # This holds the names which are targets. These also appear in
6821 # This maps a variable name onto a flag. The flag is true iff the
6822 # variable was first defined with `+='.
6823 %var_was_plus_eq = ();
6825 # This holds definitions of all variables defined in .am files.
6826 # This is used during startup to determine which variables can be
6827 # assigned with `+='.
6830 # For a variable or target which is defined conditionally, this
6831 # holds an array of the conditional values. The array is composed
6832 # of pairs of condition strings (the variables which configure
6833 # will substitute) and values (the value of a target is
6834 # meaningless). For an unconditional variable, this is empty.
6837 # This holds the line numbers at which various elements of
6838 # %contents are defined.
6839 %content_lines = ();
6841 # This holds a 1 if a particular variable was examined.
6844 # This is the conditional stack.
6845 @conditional_stack = ();
6847 # This holds the set of included files.
6848 @include_stack = ();
6850 # This holds the "relative directory" of the current Makefile.in.
6851 # Eg for src/Makefile.in, this is "src".
6854 # This holds a list of files that are included in the
6858 # List of dependencies for the obvious targets.
6874 # A list of files deleted by `maintainer-clean'.
6875 @maintainer_clean_files = ();
6877 # These are pretty obvious, too. They are used to define the
6878 # SOURCES and OBJECTS variables.
6881 # Sources which go in the distribution.
6884 # This hash maps object file names onto their corresponding source
6885 # file names. This is used to ensure that each object is created
6886 # by a single source file.
6889 # This keeps track of the directories for which we've already
6890 # created `.dirstamp' code.
6891 %directory_map = ();
6893 # These variables track inclusion of various compile-related .am
6894 # files. $included_generic_compile is TRUE if the basic code has
6895 # been included. $included_knr_compile is TRUE if the ansi2knr
6896 # code has been included. $included_libtool_compile is TRUE if
6897 # libtool support has been included.
6898 $included_generic_compile = 0;
6899 $included_knr_compile = 0;
6900 $included_libtool_compile = 0;
6902 # TRUE if install targets should work recursively.
6903 $recursive_install = 0;
6908 # Strictness levels.
6909 $strictness = $default_strictness;
6910 $strictness_name = $default_strictness_name;
6912 # Options from AUTOMAKE_OPTIONS.
6915 # Whether or not dependencies are handled. Can be further changed
6916 # in handle_options.
6917 $use_dependencies = $cmdline_use_dependencies;
6920 $local_maint_charset = $maint_charset;
6922 # All yacc and lex source filenames for this directory. Use
6923 # filenames instead of raw count so that multiple instances are
6924 # counted correctly (eg one yacc file can appear in multiple
6925 # programs without harm).
6929 # This is a list of all targets to run during "make dist".
6932 # Keys in this hash are the basenames of files which must depend
6934 %de_ansi_files = ();
6936 # This maps the source extension of a suffix rule to its
6937 # corresponding output extension.
6940 # This is a regular expression which matches all the known source
6941 # suffix. A source suffix is one that appears in the first
6942 # position of a suffix rule.
6943 $source_suffix_pattern = '';
6945 # This is the name of the recursive `all' target to use.
6946 $all_target = 'all-recursive';
6948 # This keeps track of which extensions we've seen (that we care
6950 %extension_seen = ();
6952 # This is random scratch space for the language finish functions.
6953 # Don't randomly overwrite it; examine other uses of keys first.
6954 %language_scratch = ();
6956 # We keep track of which objects need special (per-executable)
6957 # handling on a per-language basis.
6958 %lang_specific_files = ();
6960 # This is set when `handle_dist' has finished. Once this happens,
6961 # we should no longer push on dist_common.
6962 $handle_dist_run = 0;
6964 # True if we need `LINK' defined. This is a hack.
6969 ################################################################
6971 # Return contents of a file from $am_dir, automatically skipping
6972 # macros or rules which are already known. Runs command on each line
6973 # as it is read; this command can modify $_.
6974 sub file_contents_with_transform
6976 local ($command, $basename) = @_;
6977 local ($file) = $am_dir . '/' . $basename . '.am';
6979 if ($command ne '' && substr ($command, -1) ne ';')
6981 die "automake: programming error in file_contents_with_transform: $command\n";
6984 open (FC_FILE, $file)
6985 || die "automake: installation error: cannot open \`$file'\n";
6987 # print "automake: reading $file\n" if $verbose;
6989 local ($was_rule) = 0;
6990 local ($result_vars) = '';
6991 local ($result_rules) = '';
6992 local ($comment) = '';
6993 local ($spacing) = "\n";
6994 local ($skipping) = 0;
6999 $_ =~ s/\@MAINTAINER_MODE_TRUE\@//g
7000 unless $seen_maint_mode;
7002 $had_chars = length ($_) && $_ ne "\n";
7004 # If the transform caused all the characters to go away, then
7005 # ignore the line. Why do this? Because in Perl 4, a "next"
7006 # inside of an eval doesn't affect a loop outside the eval.
7007 # So we can't pass in a "transform" that uses next. We used
7008 # to do this. "Empty" also means consisting of a single
7010 next if $had_chars && ($_ eq '' || $_ eq "\n");
7012 if (/$IGNORE_PATTERN/o)
7014 # Merely delete comments beginning with two hashes.
7016 elsif (/$WHITE_PATTERN/o)
7018 # Stick a single white line before the incoming macro or rule.
7020 &am_line_error ($., "blank line following trailing backslash")
7023 elsif (/$COMMENT_PATTERN/o)
7025 # Stick comments before the incoming macro or rule.
7026 $comment .= $spacing . $_;
7028 &am_line_error ($., "comment following trailing backslash")
7035 $result_rules .= $_ if ! $skipping;
7039 $result_vars .= $_ if ! $skipping;
7043 elsif (/$RULE_PATTERN/o)
7047 $skipping = defined $contents{$1};
7048 $result_rules .= $comment . $spacing . $_ if ! $skipping;
7049 $comment = $spacing = '';
7052 elsif (/$MACRO_PATTERN/o)
7054 # Found a variable reference.
7056 $skipping = defined $contents{$1};
7057 $result_vars .= $comment . $spacing . $_ if ! $skipping;
7058 $comment = $spacing = '';
7060 print STDERR "automake: programming error: .am macro \`$1' with trailing backslash at $file:$.\n"
7062 $am_var_defs{$1} = $3;
7066 # This isn't an error; it is probably a continued rule.
7067 # In fact, this is what we assume.
7069 $result_rules .= $comment . $spacing . $_ if ! $skipping;
7070 $comment = $spacing = '';
7076 return $result_vars . $result_rules . $comment;
7079 # Like file_contents_with_transform, but no transform.
7082 return &file_contents_with_transform ('', @_);
7085 # &transform (%PAIRS)
7086 # -------------------
7087 # Create a replacement expression suitable for file_contents_with_transform
7088 # to replace each key of %PAIRS by its value.
7091 local (%pairs) = @_;
7092 local ($result) = '';
7095 foreach $pattern (sort keys %pairs)
7097 ($quoted = $pairs{$pattern}) =~ s/(\W)/\\$1/g;
7098 $result .= 's,\@' . $pattern . '\@,' . $quoted . ',g;';
7103 # Find all variable prefixes that are used for install directories. A
7104 # prefix `zar' qualifies iff:
7105 # * `zardir' is a variable.
7106 # * `zar_PRIMARY' is a variable.
7107 sub am_primary_prefixes
7109 local ($primary, $can_dist, @prefixes) = @_;
7111 local (%valid, $varname);
7112 grep ($valid{$_} = 0, @prefixes);
7113 $valid{'EXTRA'} = 0;
7114 foreach $varname (keys %contents)
7116 if ($varname =~ /^(nobase_)?(dist_|nodist_)?(.*)_$primary$/)
7118 if (($2 ne '' && ! $can_dist)
7119 || (! defined $valid{$3} && ! &variable_defined ($3 . 'dir')))
7121 # Note that a configure variable is always legitimate.
7122 # It is natural to name such variables after the
7123 # primary, so we explicitly allow it.
7124 if (! defined $configure_vars{$varname})
7126 &am_line_error ($varname, "invalid variable \`$varname'");
7131 # Ensure all extended prefixes are actually used.
7132 $valid{$1 . $2 . $3} = 1;
7140 # Handle `where_HOW' variable magic. Does all lookups, generates
7141 # install code, and possibly generates code to define the primary
7142 # variable. The first argument is the name of the .am file to munge,
7143 # the second argument is the primary variable (eg HEADERS), and all
7144 # subsequent arguments are possible installation locations. Returns
7145 # list of all values of all _HOW targets.
7147 # FIXME: this should be rewritten to be cleaner. It should be broken
7148 # up into multiple functions.
7150 # Usage is: am_install_var (OPTION..., file, HOW, where...)
7155 local ($do_clean) = 0;
7156 local ($do_require) = 1;
7157 local ($can_dist) = 0;
7158 local ($default_dist) = 0;
7161 if (defined $configure_vars{'LIBTOOL'})
7163 # Transform '@LIBTOOL ...@' to '$(LIBTOOL) ...'
7164 $ltxform = 's/\@LIBTOOL([^\@]*)\@/\$(LIBTOOL) $1/;';
7168 # Delete '@LIBTOOL ...@'
7169 $ltxform = 's/\@LIBTOOL([^\@]*)\@//;';
7175 $cygxform = 's/\@EXEEXT\@//g;';
7179 $cygxform = 's/\@EXEEXT\@/\$(EXEEXT)/g;';
7184 if ($args[0] eq '-clean')
7188 elsif ($args[0] eq '-noextra')
7192 elsif ($args[0] eq '-candist')
7196 elsif ($args[0] eq '-defaultdist')
7201 elsif ($args[0] !~ /^-/)
7208 local ($file, $primary, @prefixes) = @args;
7211 local (@result) = ();
7213 # Now that configure substitutions are allowed in where_HOW
7214 # variables, it is an error to actually define the primary. We
7215 # allow `JAVA', as it is customarily used to mean the Java
7216 # interpreter. This is but one of several Java hacks. Similarly,
7217 # `PYTHON' is customarily used to mean the Python interpreter.
7218 &am_line_error ($primary, "\`$primary' is an anachronism")
7219 if &variable_defined ($primary)
7220 && ($primary ne 'JAVA' && $primary ne 'PYTHON');
7223 # Look for misspellings. It is an error to have a variable ending
7224 # in a "reserved" suffix whose prefix is unknown, eg
7225 # "bni_PROGRAMS". However, unusual prefixes are allowed if a
7226 # variable of the same name (with "dir" appended) exists. For
7227 # instance, if the variable "zardir" is defined, then
7228 # "zar_PROGRAMS" becomes valid. This is to provide a little extra
7229 # flexibility in those cases which need it.
7230 local (%valid) = &am_primary_prefixes ($primary, $can_dist, @prefixes);
7232 # If a primary includes a configure substitution, then the EXTRA_
7233 # form is required. Otherwise we can't properly do our job.
7234 local ($require_extra);
7235 local ($warned_about_extra) = 0;
7237 local ($clean_file) = $file . '-clean';
7240 local ($nodir_name);
7241 local ($strip_subdir) = 1;
7242 foreach $X (sort keys %valid)
7244 $one_name = $X . '_' . $primary;
7245 if (&variable_defined ($one_name))
7247 # If subdir prefix should be preserved, do so.
7248 if ($X =~ /^nobase_/)
7254 # If files should be distributed, do so.
7257 if (($default_dist && $one_name !~ /^nodist_/)
7258 || (! $default_dist && $one_name =~ /^dist_/))
7260 &push_dist_common ('$(' . $one_name . ')');
7262 ($nodir_name = $X) =~ s/^(dist|nodist)_//;
7269 # Append actual contents of where_PRIMARY variable to
7272 foreach $rcurs (&variable_value_as_list ($one_name, 'all'))
7274 # Skip configure substitutions. Possibly bogus.
7275 if ($rcurs =~ /^\@.*\@$/)
7279 if (! $warned_about_extra)
7281 $warned_about_extra = 1;
7283 &am_line_error ($one_name,
7284 "\`$one_name' contains configure substitution, but shouldn't");
7288 # Check here to make sure variables defined in
7289 # configure.ac do not imply that EXTRA_PRIMARY
7291 elsif (! defined $configure_vars{$one_name})
7293 $require_extra = $one_name
7300 push (@result, $rcurs);
7303 # A blatant hack: we rewrite each _PROGRAMS primary to
7304 # include EXEEXT when in Cygwin32 mode.
7305 if ($seen_exeext && $primary eq 'PROGRAMS')
7307 local (@conds) = &variable_conditions ($one_name);
7308 local (@one_binlist);
7310 # FIXME: this definitely loses aesthetically; it
7311 # redefines $ONE_NAME. Instead we should arrange for
7312 # variable definitions to be output later, instead of
7318 foreach $rcurs (&variable_value_as_list ($one_name, ''))
7320 if ($rcurs =~ /\./ || $rcurs =~ /^\@.*\@$/)
7322 push (@one_binlist, $rcurs);
7326 push (@one_binlist, $rcurs . '$(EXEEXT)');
7330 delete $contents{$one_name};
7331 &define_pretty_variable ($one_name, '', @one_binlist);
7336 local ($condvals) = '';
7337 foreach $cond (@conds)
7340 local (@condval) = &variable_value_as_list ($one_name,
7342 foreach $rcurs (@condval)
7344 if ($rcurs =~ /\./ || $rcurs =~ /^\@.*\@$/)
7346 push (@one_binlist, $rcurs);
7350 push (@one_binlist, $rcurs . '$(EXEEXT)');
7354 push (@condvals, $cond);
7355 push (@condvals, join (' ', @one_binlist));
7358 delete $contents{$one_name};
7362 $cond = shift (@condvals);
7363 local (@val) = split (' ', shift (@condvals));
7364 &define_pretty_variable ($one_name, $cond, @val);
7369 # "EXTRA" shouldn't be used when generating clean targets,
7370 # all, or install targets.
7373 # We used to warn if EXTRA_FOO was defined uselessly,
7374 # but this was annoying.
7381 &file_contents_with_transform ('s/\@DIR\@/' . $X . '/go;'
7385 push (@clean, $X . $primary);
7386 &push_phony_cleaners ($X . $primary);
7391 push (@check, '$(' . $one_name . ')');
7395 push (@used, '$(' . $one_name . ')');
7397 if ($X eq 'noinst' || $X eq 'check')
7399 # Objects which don't get installed by default.
7403 local ($subdir_xform);
7406 $subdir_xform = 's/^NOBASE.*$//; s/^BASE//;';
7410 $subdir_xform = 's/^BASE.*$//; s/^NOBASE//;';
7414 &file_contents_with_transform ('s/\@DIR\@/' . $X . '/g;'
7415 . 's/\@NDIR\@/' . $nodir_name . '/go;'
7416 . $ltxform . $cygxform
7420 push (@uninstall, 'uninstall-' . $X . $primary);
7421 push (@phony, 'uninstall-' . $X . $primary);
7422 push (@installdirs, '$(DESTDIR)$(' . $X . 'dir)');
7423 if (defined $exec_dir_p{$X} ? $exec_dir_p{$X} : ($X =~ /exec/))
7425 push (@install_exec, 'install-' . $X . $primary);
7426 push (@phony, 'install-' . $X . $primary);
7430 push (@install_data, 'install-' . $X . $primary);
7431 push (@phony, 'install-' . $X . $primary);
7436 # The JAVA variable is used as the name of the Java interpreter.
7437 # The PYTHON variable is used as the name of the Python interpreter.
7438 if (@used && $primary ne 'JAVA' && $primary ne 'PYTHON')
7441 &define_pretty_variable ($primary, '', @used);
7442 $output_vars .= "\n";
7445 if ($require_extra && ! &variable_defined ('EXTRA_' . $primary))
7447 &am_line_error ($require_extra,
7448 "\`$require_extra' contains configure substitution, but \`EXTRA_$primary' not defined");
7451 # Push here because PRIMARY might be configure time determined.
7452 push (@all, '$(' . $primary . ')')
7453 if @used && $primary ne 'JAVA' && $primary ne 'PYTHON';
7455 # Make the result unique. This lets the user use conditionals in
7456 # a natural way, but still lets us program lazily -- we don't have
7457 # to worry about handling a particular object more than once.
7458 local (%uniquify) = ();
7459 grep ($uniquify{$_} = 1, @result);
7460 return sort keys %uniquify;
7464 ################################################################
7466 # Each key in this hash is the name of a directory holding a
7467 # Makefile.in. These variables are local to `is_make_dir'.
7474 if (! $make_dirs_set)
7476 foreach $iter (@configure_input_files)
7478 $make_dirs{&dirname ($iter)} = 1;
7480 # We also want to notice Makefile.in's.
7481 foreach $iter (@other_input_files)
7483 if ($iter =~ /Makefile\.in$/)
7485 $make_dirs{&dirname ($iter)} = 1;
7490 return defined $make_dirs{$dir};
7493 ################################################################
7495 # This variable is local to the "require file" set of functions.
7496 @require_file_paths = ();
7498 # If a file name appears as a key in this hash, then it has already
7499 # been checked for. This variable is local to the "require file"
7501 %require_file_found = ();
7503 # See if we want to push this file onto dist_common. This function
7504 # encodes the rules for deciding when to do so.
7505 sub maybe_push_required_file
7507 local ($dir, $file, $fullfile) = @_;
7509 # FIXME: Once again, special-case `.'.
7510 if ($dir eq $relative_dir || $dir eq '.')
7512 &push_dist_common ($file);
7514 elsif ($relative_dir eq '.' && ! &is_make_dir ($dir))
7516 # If we are doing the topmost directory, and the file is in a
7517 # subdir which does not have a Makefile, then we distribute it
7519 &push_dist_common ($fullfile);
7523 # Verify that the file must exist in the current directory. Usage:
7524 # require_file (isconfigure, line_number, strictness, file) strictness
7525 # is the strictness level at which this file becomes required. Must
7526 # set require_file_paths before calling this function.
7527 # require_file_paths is set to hold a single directory (the one in
7528 # which the first file was found) before return.
7529 sub require_file_internal
7531 local ($is_configure, $line, $mystrict, @files) = @_;
7532 local ($file, $fullfile);
7533 local ($found_it, $dangling_sym, $errfile, $errdir);
7536 foreach $file (@files)
7538 # If we've already looked for it, we're done.
7539 next if defined $require_file_found{$file};
7540 $require_file_found{$file} = 1;
7544 foreach $dir (@require_file_paths)
7548 $fullfile = $relative_dir . "/" . $file;
7549 $errdir = $relative_dir unless $errdir;
7553 $fullfile = $dir . "/" . $file;
7554 $errdir = $dir unless $errdir;
7557 # Use different name for "error filename". Otherwise on
7558 # an error the bad file will be reported as eg
7559 # `../../install-sh' when using the default
7561 $errfile = $errdir . '/' . $file;
7563 if (-l $fullfile && ! -f readlink ($fullfile))
7568 elsif (-f $fullfile)
7571 &maybe_push_required_file ($dir, $file, $fullfile);
7577 if ($found_it && ! $force_missing)
7579 # Prune the path list.
7580 @require_file_paths = $save_dir;
7584 if ($strictness >= $mystrict)
7586 if ($dangling_sym && ($force_missing || $add_missing))
7591 local ($trailer) = '';
7592 local ($suppress) = 0;
7594 # Only install missing files according to our desired
7596 local ($message) = "required file \`$errfile' not found";
7601 # Maybe run libtoolize.
7602 local @syslist = ('libtoolize', '--automake');
7603 push @syslist, '--copy'
7606 && grep ($_ eq $file, @libtoolize_files)
7607 && system (@syslist))
7609 $message = "installing \`$errfile'";
7611 $trailer = "; cannot run \`libtoolize': $!";
7613 elsif (-f ($am_dir . '/' . $file))
7615 # Install the missing file. Symlink if we
7616 # can, copy if we must. Note: delete the file
7617 # first, in case it is a dangling symlink.
7618 $message = "installing \`$errfile'";
7619 # Windows Perl will hang if we try to delete a
7620 # file that doesn't exist.
7621 unlink ($errfile) if -f $errfile;
7622 if ($symlink_exists && ! $copy_missing)
7624 if (! symlink ($am_dir . '/' . $file, $errfile))
7627 $trailer = "; error while making link: $!";
7630 elsif (system ('cp', $am_dir . '/' . $file, $errfile))
7633 $trailer = "\n error while copying";
7637 &maybe_push_required_file (&dirname ($errfile),
7641 local ($save) = $exit_status;
7644 # FIXME: allow actual file to be specified.
7645 &am_conf_line_error ($configure_ac, $line,
7646 "$message$trailer");
7650 &am_line_error ($line, "$message$trailer");
7652 $exit_status = $save if $suppress;
7658 # Like require_file_with_line, but error messages refer to
7659 # configure.ac, not the current Makefile.am.
7660 sub require_file_with_conf_line
7662 @require_file_paths = '.';
7663 &require_file_internal (1, @_);
7666 sub require_file_with_line
7668 @require_file_paths = '.';
7669 &require_file_internal (0, @_);
7674 @require_file_paths = '.';
7675 &require_file_internal (0, '', @_);
7678 # Require a file that is also required by Autoconf. Looks in
7679 # configuration path, as specified by AC_CONFIG_AUX_DIR.
7680 sub require_config_file
7682 @require_file_paths = @config_aux_path;
7683 &require_file_internal (1, '', @_);
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 Makefile.am.
7697 sub require_conf_file_with_line
7699 @require_file_paths = @config_aux_path;
7700 &require_file_internal (0, @_);
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 # Assumes that the line number is in configure.ac.
7714 sub require_conf_file_with_conf_line
7716 @require_file_paths = @config_aux_path;
7717 &require_file_internal (1, @_);
7718 local ($dir) = $require_file_paths[0];
7719 @config_aux_path = @require_file_paths;
7722 $config_aux_dir = '.';
7726 $config_aux_dir = '$(top_srcdir)/' . $dir;
7730 ################################################################
7732 # Push a list of files onto dist_common.
7733 sub push_dist_common
7735 local (@files) = @_;
7738 foreach $file (@files)
7740 if (! defined $dist_common{$file})
7742 if ($handle_dist_run)
7745 "automake: programming error: push_dist_common run after handle_dist\n";
7748 $dist_common{$file} = 1;
7753 # Push a list of clean targets onto phony.
7754 sub push_phony_cleaners
7758 foreach $target ('mostly', 'dist', '', 'maintainer-')
7760 push (@phony, $target . 'clean-' . $base);
7767 $strictness_name = $_[0];
7768 if ($strictness_name eq 'gnu')
7772 elsif ($strictness_name eq 'gnits')
7774 $strictness = $GNITS;
7776 elsif ($strictness_name eq 'foreign')
7778 $strictness = $FOREIGN;
7782 die "automake: level \`$strictness_name' not recognized\n";
7787 ################################################################
7789 # Return directory name of file.
7795 ($sub = $file) =~ s,/+[^/]+$,,g;
7796 $sub = '.' if $sub eq $file;
7800 # Return file name of a file.
7806 ($sub = $file) =~s,^.*/+,,g;
7810 # Ensure a file exists.
7815 open (TOUCH, ">> $file");
7819 # Glob something. Do this to avoid indentation screwups everywhere we
7820 # want to glob. Gross!
7827 ################################################################
7829 # Print an error message and set exit status.
7832 warn "automake: ${am_file}.am: ", join (' ', @_), "\n";
7838 local ($symbol, @args) = @_;
7840 if ($symbol && "$symbol" ne '-1')
7842 local ($file) = "${am_file}.am";
7844 if ($symbol =~ /^\d+$/)
7846 # SYMBOL is a line number, so just add the colon.
7847 $file .= ':' . $symbol;
7849 elsif (defined $content_lines{$symbol})
7851 # SYMBOL is a variable defined in Makefile.am, so add the
7852 # line number we saved from there.
7853 $file .= ':' . $content_lines{$symbol};
7855 elsif (defined $configure_vars{$symbol})
7857 # SYMBOL is a variable defined in configure.ac, so add the
7858 # appropriate line number.
7859 $file = $configure_vars{$symbol};
7863 # Couldn't find the line number.
7865 warn $file, ": ", join (' ', @args), "\n";
7874 # Like am_error, but while scanning configure.ac.
7877 # FIXME: can run in subdirs.
7878 warn "automake: $configure_ac: ", join (' ', @_), "\n";
7882 # Error message with line number referring to configure.ac.
7883 sub am_conf_line_error
7885 local ($file, $line, @args) = @_;
7889 warn "$file: $line: ", join (' ', @args), "\n";
7894 &am_conf_error (@args);
7898 # Warning message with line number referring to configure.ac.
7899 # Does not affect exit_status
7900 sub am_conf_line_warning
7902 local ($saved_exit_status) = $exit_status;
7903 &am_conf_line_error (@_);
7904 $exit_status = $saved_exit_status;
7907 # Tell user where our aclocal.m4 is, but only once.
7908 sub keyed_aclocal_warning
7911 warn "automake: macro \`$key' can be generated by \`aclocal'\n";
7914 # Print usage information.
7917 print "Usage: automake [OPTION] ... [Makefile]...\n\n";
7918 print "Generate Makefile.in for autoconf from Makefile.am\n";
7920 print "\nFiles which are automatically distributed, if found:\n";
7921 $~ = "USAGE_FORMAT";
7922 local ($last, $iter, @lcomm);
7924 foreach $iter (sort ((@common_files, @common_sometimes)))
7926 push (@lcomm, $iter) unless $iter eq $last;
7930 local ($one, $two, $three, $four, $i, $max);
7931 $max = int (($#lcomm + 1) / 4);
7933 for ($i = 0; $i < $max; ++$i)
7936 $two = $lcomm[$max + $i];
7937 $three = $lcomm[2 * $max + $i];
7938 $four = $lcomm[3 * $max + $i];
7942 local ($mod) = ($#lcomm + 1) % 4;
7945 $one = $lcomm[$max];
7946 $two = ($mod > 1) ? $lcomm[2 * $max] : '';
7947 $three = ($mod > 2) ? $lcomm[3 * $max] : '';
7948 $four = ($mod > 3) ? $lcomm[4 * $max] : '';
7952 print "\nReport bugs to <bug-automake\@gnu.org>.\n";
7957 format USAGE_FORMAT =
7958 @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<
7959 $one, $two, $three, $four