5 eval 'exec @PERL@ -S $0 ${1+"$@"}'
8 # automake - create Makefile.in from Makefile.am
9 # Copyright (C) 1994-99, 2000 Free Software Foundation, Inc.
11 # This program is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by
13 # the Free Software Foundation; either version 2, or (at your option)
16 # This program is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write to the Free Software
23 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
26 # Originally written by David Mackenzie <djm@gnu.ai.mit.edu>.
27 # Perl reimplementation by Tom Tromey <tromey@cygnus.com>.
30 # Parameters set by configure. Not to be changed. NOTE: assign
31 # VERSION as string so that eg version 0.30 will print correctly.
32 $VERSION = "@VERSION@";
33 $PACKAGE = "@PACKAGE@";
35 $am_dir = "@datadir@/@PACKAGE@";
38 $IGNORE_PATTERN = "^##([^#].*)?\$";
39 $WHITE_PATTERN = "^[ \t]*\$";
40 $COMMENT_PATTERN = "^#";
41 $RULE_PATTERN = "^([\$a-zA-Z_.][-.a-zA-Z0-9_(){}/\$]*) *:([^=].*|)\$";
42 $SUFFIX_RULE_PATTERN = "^\\.([a-zA-Z0-9]+)\\.([a-zA-Z0-9]+)\$";
43 $MACRO_PATTERN = "^([A-Za-z0-9_]+)[ \t]*([:+]?)=[ \t]*(.*)\$";
44 $BOGUS_MACRO_PATTERN = "^([^ \t]*)[ \t]*([:+]?)=[ \t]*(.*)\$";
45 $GNITS_VERSION_PATTERN = "[0-9]+\\.[0-9]+([a-z]|\\.[0-9]+)?";
46 $IF_PATTERN = "^if[ \t]+\([A-Za-z][A-Za-z0-9_]*\)[ \t]*\(#.*\)?\$";
47 $ELSE_PATTERN = "^else[ \t]*\(#.*\)?\$";
48 $ENDIF_PATTERN = "^endif[ \t]*\(#.*\)?\$";
49 $PATH_PATTERN='(\\w|[/.-])+';
50 # This will pass through anything not of the prescribed form.
51 $INCLUDE_PATTERN = "^include[ \t]+((\\\$\\\(top_srcdir\\\)/${PATH_PATTERN})|(\\\$\\\(srcdir\\\)/${PATH_PATTERN})|([^/\\\$]${PATH_PATTERN}))[ \t]*(#.*)?\$";
53 # Some regular expressions. One reason to put them here is that it
54 # makes indentation work better in Emacs.
55 $AC_CONFIG_AUX_DIR_PATTERN = "AC_CONFIG_AUX_DIR\\(([^)]+)\\)";
56 $AM_INIT_AUTOMAKE_PATTERN = "AM_INIT_AUTOMAKE\\([^,]*,([^,)]+)[,)]";
57 $AM_PACKAGE_VERSION_PATTERN = "^\\s*\\[?([^]\\s]+)\\]?\\s*\$";
58 # Note that there is no AC_PATH_TOOL. But we don't really care.
59 $AC_CHECK_PATTERN = "AC_(CHECK|PATH)_(PROG|PROGS|TOOL)\\(\\[?(\\w+)";
60 $AM_MISSING_PATTERN = "AM_MISSING_PROG\\(\\[?(\\w+)";
61 # Just check for alphanumeric in AC_SUBST. If you do AC_SUBST(5),
63 $AC_SUBST_PATTERN = "AC_SUBST\\(\\[?(\\w+)";
64 $AM_CONDITIONAL_PATTERN = "AM_CONDITIONAL\\((\\w+)";
66 # Constants to define the "strictness" level.
71 # These constants are returned by lang_*_rewrite functions.
72 # LANG_SUBDIR means that the resulting object file should be in a
73 # subdir if the source file is. In this case the file name cannot
74 # have `..' components.
81 # Variables global to entire run.
83 # TRUE if we should always generate Makefile.in.
84 $force_generation = 1;
86 # Strictness level as set on command line.
87 $default_strictness = $GNU;
89 # Name of strictness level, as set on command line.
90 $default_strictness_name = 'gnu';
92 # This is TRUE if automatic dependency generation code should be
93 # included in generated Makefile.in.
94 $cmdline_use_dependencies = 1;
96 # TRUE if in verbose mode.
99 # This holds our (eventual) exit status. We don't actually exit until
100 # we have processed all input files.
103 # From the Perl manual.
104 $symlink_exists = (eval 'symlink ("", "");', $@ eq '');
106 # TRUE if missing standard files should be installed.
109 # TRUE if we should copy missing files; otherwise symlink if possible.
112 # TRUE if we should always update files that we know about.
115 # Files found by scanning configure.in for LIBOBJS.
118 # True if AM_C_PROTOTYPES appears in configure.in.
119 $am_c_prototypes = 0;
121 # Names used in AC_CONFIG_HEADER call. @config_fullnames holds the
122 # name which appears in AC_CONFIG_HEADER, colon and all.
123 # @config_names holds the file names. @config_headers holds the '.in'
124 # files. Ordinarily these are similar, but they can be different if
125 # the weird "NAME:FILE" syntax is used.
126 @config_fullnames = ();
128 @config_headers = ();
129 # Line number at which AC_CONFIG_HEADER appears in configure.in.
130 $config_header_line = 0;
132 # Directory where output files go. Actually, output files are
133 # relative to this directory.
134 $output_directory = '.';
136 # Relative location of top build directory.
139 # List of Makefile.am's to process, and their corresponding outputs.
143 # Complete list of Makefile.am's that exist.
144 @configure_input_files = ();
146 # List of files in AC_OUTPUT without Makefile.am, and their outputs.
147 @other_input_files = ();
148 # Line number at which AC_OUTPUT seen.
151 # List of directories to search for configure-required files. This
152 # can be set by AC_CONFIG_AUX_DIR.
153 @config_aux_path = ('.', '..', '../..');
154 $config_aux_dir = '';
156 # Whether AC_PROG_MAKE_SET has been seen in configure.in.
159 # Whether AM_GNU_GETTEXT has been seen in configure.in.
161 # Line number at which AM_GNU_GETTEXT seen.
162 $ac_gettext_line = 0;
164 # Whether ALL_LINGUAS has been seen.
168 # Line number at which it appears.
169 $all_linguas_line = 0;
171 # 1 if AC_PROG_INSTALL seen.
172 $seen_prog_install = 0;
174 # Whether AC_PATH_XTRA has been seen in configure.in.
177 # TRUE if AC_DECL_YYTEXT was seen.
178 $seen_decl_yytext = 0;
180 # TRUE if we've seen AC_CANONICAL_(HOST|SYSTEM). The presence of
181 # AC_CHECK_TOOL also sets this.
184 # TRUE if we've seen AC_ARG_PROGRAM.
187 # TRUE if we've seen AC_PROG_LIBTOOL.
191 # Files installed by libtoolize.
192 @libtoolize_files = ('ltconfig', 'ltmain.sh', 'config.guess', 'config.sub');
194 # TRUE if we've seen AM_MAINTAINER_MODE.
195 $seen_maint_mode = 0;
197 # TRUE if we've seen PACKAGE and VERSION.
201 # Actual version we've seen.
202 $package_version = '';
204 # Line number where we saw version definition.
205 $package_version_line = 0;
207 # TRUE if we've seen AM_PATH_LISPDIR.
210 # TRUE if we've seen AM_CHECK_PYTHON.
213 # TRUE if we've seen AC_EXEEXT.
216 # TRUE if we've seen AC_OBJEXT.
219 # TRUE if we've seen AC_ENABLE_MULTILIB.
222 # TRUE if we've seen AM_PROG_CC_C_O
225 # TRUE if we've seen AM_INIT_AUTOMAKE.
226 $seen_init_automake = 0;
228 # Hash table of discovered configure substitutions. Keys are names,
229 # values are `FILE:LINE' strings which are used by error message
231 %configure_vars = ();
233 # This is used to keep track of which variable definitions we are
234 # scanning. It is only used in certain limited ways, but it has to be
235 # global. It is declared just for documentation purposes.
238 # Charsets used by maintainer and in distribution. MAINT_CHARSET is
239 # handled in a funny way: if seen in the top-level Makefile.am, it is
240 # used for every directory which does not specify a different value.
241 # The rationale here is that some directories (eg gettext) might be
242 # distributions of other packages, and thus require their own charset
243 # info. However, the DIST_CHARSET must be the same for the entire
244 # package; it can only be set at top-level.
245 # FIXME: this yields bugs when rebuilding. What to do? Always
246 # read (and sometimes discard) top-level Makefile.am?
248 $dist_charset = 'utf8'; # recode doesn't support this yet.
250 # Name of input file ("Makefile.in") and output file ("Makefile.am").
251 # These have no directory components.
255 # TRUE if --cygnus seen.
258 # Hash table of AM_CONDITIONAL variables seen in configure.
259 %configure_cond = ();
261 # Map from obsolete macros to hints for new macros.
262 # If you change this, change the corresponding list in aclocal.in.
263 # FIXME: should just put this into a single file.
266 'AC_FEATURE_CTYPE', "use \`AC_HEADER_STDC'",
267 'AC_FEATURE_ERRNO', "add \`strerror' to \`AC_REPLACE_FUNCS(...)'",
268 'AC_FEATURE_EXIT', '',
269 'AC_SYSTEM_HEADER', '',
271 # Note that we do not handle this one, because it is still run
272 # from AM_CONFIG_HEADER. So we deal with it specially in
274 # 'AC_CONFIG_HEADER', "use \`AM_CONFIG_HEADER'",
276 'fp_C_PROTOTYPES', "use \`AM_C_PROTOTYPES'",
277 'fp_PROG_CC_STDC', "use \`AM_PROG_CC_STDC'",
278 'fp_PROG_INSTALL', "use \`AC_PROG_INSTALL'",
279 'fp_WITH_DMALLOC', "use \`AM_WITH_DMALLOC'",
280 'fp_WITH_REGEX', "use \`AM_WITH_REGEX'",
281 'gm_PROG_LIBTOOL', "use \`AM_PROG_LIBTOOL'",
282 'jm_MAINTAINER_MODE', "use \`AM_MAINTAINER_MODE'",
283 'md_TYPE_PTRDIFF_T', "use \`AM_TYPE_PTRDIFF_T'",
284 'ud_PATH_LISPDIR', "use \`AM_PATH_LISPDIR'",
285 'ud_GNU_GETTEXT', "use \`AM_GNU_GETTEXT'",
287 # Now part of autoconf proper, under a different name.
288 'AM_FUNC_FNMATCH', "use \`AC_FUNC_FNMATCH'",
289 'fp_FUNC_FNMATCH', "use \`AC_FUNC_FNMATCH'",
290 'AM_SANITY_CHECK_CC', "automatically done by \`AC_PROG_CC'",
291 'AM_PROG_INSTALL', "use \`AC_PROG_INSTALL'",
292 'AM_EXEEXT', "use \`AC_EXEEXT'",
293 'AM_CYGWIN32', "use \`AC_CYGWIN'",
294 'AM_MINGW32', "use \`AC_MINGW32'",
295 'AM_FUNC_MKTIME', "use \`AC_FUNC_MKTIME'",
297 # These aren't quite obsolete.
301 # Regexp to match the above macros.
302 $obsolete_rx = '(' . join ('|', keys %obsolete_macros) . ')';
304 # This maps extensions onto language names.
307 # This maps languages names onto properties.
310 # This holds all the files that would go in `dist_common' which we
311 # discovered while scanning configure.in. We might distribute these
312 # in the top-level Makefile.in.
313 %configure_dist_common = ();
317 # Initialize global constants and our list of languages that are
318 # internally supported.
319 &initialize_global_constants;
321 ®ister_language ('c', 'ansi-p=1', 'autodep=', 'flags=CFLAGS',
322 'compile=$(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)',
323 'compiler-name=COMPILE',
326 ®ister_language ('cxx', 'linker=CXXLINK', 'autodep=CXX', 'flags=CXXFLAGS',
327 'compile=$(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)',
328 'compiler-name=CXXCOMPILE',
329 'output-arg=-c -o $@',
330 'c++', 'cc', 'cpp', 'cxx', 'C');
331 ®ister_language ('objc', 'linker=OBJCLINK', 'autodep=OBJC',
333 'compile=$(OBJC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_OBJCFLAGS) $(OBJCFLAGS)',
334 'compiler-name=OBJCCOMPILE',
335 'output-arg=-c -o $@',
337 ®ister_language ('header',
338 'h', 'H', 'hxx', 'h++', 'hh', 'hpp', 'inc');
340 # For now, yacc and lex can't be handled on a per-exe basis.
341 ®ister_language ('yacc', 'ansi-p=1',
343 ®ister_language ('yaccxx', 'linker=CXXLINK',
344 'y++', 'yy', 'yxx', 'ypp');
345 ®ister_language ('lex', 'ansi-p=1',
347 ®ister_language ('lexxx', 'linker=CXXLINK',
348 'l++', 'll', 'lxx', 'lpp');
350 ®ister_language ('asm',
351 'flags=CFLAGS', # FIXME: asmflags?
352 'compile=$(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)', # FIXME: a different compiler?
353 'compiler-name=COMPILE',
357 ®ister_language ('f77', 'linker=F77LINK', 'flags=FFLAGS',
358 'compile=$(F77) $(AM_FFLAGS) $(FFLAGS)',
359 'compiler-name=F77COMPILE',
360 'output-arg=-c -o $@',
362 ®ister_language ('ppf77', 'linker=F77LINK', 'flags=FFLAGS',
363 'compile=$(F77) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FFLAGS) $(FFLAGS)',
364 'compiler-name=PPF77COMPILE',
365 'output-arg=-c -o $@',
367 ®ister_language ('ratfor', 'linker=F77LINK',
368 'flags=RFLAGS', # FIXME also FFLAGS.
369 'compile=$(F77) $(AM_FFLAGS) $(FFLAGS) $(AM_RFLAGS) $(RFLAGS)',
370 'compiler-name=RCOMPILE',
371 'output-arg=-c -o $@',
373 # FIXME: for now we can't do dependency tracking for Java.
375 ®ister_language ('java', 'linker=GCJLINK', 'flags=GCJFLAGS',
376 'compile=$(GCJ) $(DEFS) $(INCLUDES) $(AM_GCJFLAGS) $(GCJFLAGS)',
377 'compiler-name=GCJCOMPILE',
378 'output-arg=-c -o $@',
379 'java', 'class', 'zip', 'jar');
382 # Parse command line.
383 &parse_arguments (@ARGV);
385 # Do configure.in scan only once.
388 die "automake: no \`Makefile.am' found or specified\n"
391 # Now do all the work on each file.
392 foreach $am_file (@input_files)
394 if (! -f ($am_file . '.am'))
396 &am_error ("\`" . $am_file . ".am' does not exist");
400 &generate_makefile ($output_files{$am_file}, $am_file);
404 &am_conf_error ("AC_PROG_INSTALL must be used in configure.in")
405 if (! $seen_prog_install);
410 ################################################################
412 # Parse command line.
415 local (@arglist) = @_;
418 &set_strictness ('gnu');
422 if ($arglist[0] eq "--version")
424 print "automake (GNU $PACKAGE) $VERSION\n\n";
425 print "Copyright (C) 2000 Free Software Foundation, Inc.\n";
426 print "This is free software; see the source for copying conditions. There is NO\n";
427 print "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n";
428 print "Written by Tom Tromey <tromey\@cygnus.com>\n";
432 elsif ($arglist[0] eq "--help")
436 elsif ($arglist[0] =~ /^--amdir=(.+)$/)
440 elsif ($arglist[0] eq '--amdir')
442 &require_argument (@arglist);
444 $am_dir = $arglist[0];
446 elsif ($arglist[0] eq '--gnu')
448 &set_strictness ('gnu');
450 elsif ($arglist[0] eq '--gnits')
452 &set_strictness ('gnits');
454 elsif ($arglist[0] eq '--cygnus')
458 elsif ($arglist[0] eq '--foreign')
460 &set_strictness ('foreign');
462 elsif ($arglist[0] eq '--include-deps')
464 $cmdline_use_dependencies = 1;
466 elsif ($arglist[0] eq '--ignore-deps' || $arglist[0] eq '-i')
468 $cmdline_use_dependencies = 0;
470 elsif ($arglist[0] eq '--no-force')
472 $force_generation = 0;
474 elsif ($arglist[0] eq '--force-missing')
478 elsif ($arglist[0] =~ /^--output-dir=(.*)$/)
480 # Set output directory.
481 $output_directory = $1;
483 elsif ($arglist[0] eq '--output-dir' || $arglist[0] eq '-o')
485 &require_argument (@arglist);
487 $output_directory = $arglist[0];
489 elsif ($arglist[0] eq '--add-missing' || $arglist[0] eq '-a')
493 elsif ($arglist[0] eq '--copy' || $arglist[0] eq '-c')
497 elsif ($arglist[0] eq '--verbose' || $arglist[0] eq '-v')
501 elsif ($arglist[0] eq '--')
503 # Stop option processing.
505 push (@input_files, @arglist);
508 elsif ($arglist[0] =~ /^-/)
510 die "automake: unrecognized option -- \`$arglist[0]'\nTry \`automake --help' for more information.\n";
514 # Handle $local:$input syntax. Note that we only examine
515 # the first ":" file to see if it is automake input; the
516 # rest are just taken verbatim. We still keep all the
517 # files around for dependency checking, however.
518 local ($local, $input, @rest) = split (/:/, $arglist[0]);
525 # Strip .in; later on .am is tacked on. That is how
526 # the automake input file is found. Maybe not the
527 # best way, but it is easy to explain. FIXME: should
528 # be error if .in is missing.
531 push (@input_files, $input);
532 $output_files{$input} = join (':', ($local, @rest));
538 # Take global strictness from whatever we currently have set.
539 $default_strictness = $strictness;
540 $default_strictness_name = $strictness_name;
543 # Ensure argument exists, or die.
546 local ($arg, @arglist) = @_;
547 die "automake: no argument given for option \`$arg'\n"
551 ################################################################
553 # Generate a Makefile.in given the name of the corresponding Makefile and
554 # the name of the file output by config.status.
555 sub generate_makefile
557 local ($output, $makefile) = @_;
559 ($am_file_name = $makefile) =~ s/^.*\///;
560 $in_file_name = $am_file_name . '.in';
561 $am_file_name .= '.am';
563 # $OUTPUT is encoded. If it contains a ":" then the first element
564 # is the real output file, and all remaining elements are input
565 # files. We don't scan or otherwise deal with these input file,
566 # other than to mark them as dependencies. See scan_configure for
568 local (@secondary_inputs);
569 ($output, @secondary_inputs) = split (/:/, $output);
571 &initialize_per_input;
572 $relative_dir = &dirname ($output);
573 $am_relative_dir = &dirname ($makefile);
575 # At the toplevel directory, we might need config.guess, config.sub
576 # or libtool scripts (ltconfig and ltmain.sh).
577 if ($relative_dir eq '.')
579 # libtool requires some files.
580 &require_conf_file_with_conf_line ($libtool_line, $FOREIGN,
584 # AC_CANONICAL_HOST and AC_CANONICAL_SYSTEM need config.guess and
586 &require_config_file ($FOREIGN, 'config.guess', 'config.sub')
590 # We still need Makefile.in here, because sometimes the `dist'
591 # target doesn't re-run automake.
592 if ($am_relative_dir eq $relative_dir)
594 # Only distribute the files if they are in the same subdir as
595 # the generated makefile.
596 &push_dist_common ($in_file_name, $am_file_name);
599 push (@sources, '$(SOURCES)')
600 if &variable_defined ('SOURCES');
601 push (@objects, '$(OBJECTS)')
602 if &variable_defined ('OBJECTS');
604 &read_main_am_file ($makefile . '.am');
607 # Fatal error. Just return, so we can continue with next file.
611 # Must do this after reading .am file. See read_main_am_file to
612 # understand weird tricks we play there with variables.
613 &define_variable ('subdir', $relative_dir);
615 # Check first, because we might modify some state.
617 &check_gnu_standards;
618 &check_gnits_standards;
620 &handle_configure ($output, $makefile, @secondary_inputs);
627 &handle_built_sources;
629 # This must be run after all the sources are scanned.
632 # Re-init SOURCES and OBJECTS. FIXME: other code shouldn't depend
633 # on this (but currently does).
634 $contents{'SOURCES'} = join (' ', @sources);
635 $contents{'OBJECTS'} = join (' ', @objects);
636 &define_pretty_variable ('DIST_SOURCES', '', @dist_sources);
648 &handle_minor_options;
649 &handle_dependencies;
652 # This must come after most other rules.
653 &handle_dist ($makefile);
656 &handle_merge_targets ($output);
663 if (! -d ($output_directory . '/' . $am_relative_dir))
665 mkdir ($output_directory . '/' . $am_relative_dir, 0755);
668 local ($out_file) = $output_directory . '/' . $makefile . ".in";
669 if (! $force_generation && -e $out_file)
671 local ($am_time) = (stat ($makefile . '.am'))[9];
672 local ($in_time) = (stat ($out_file))[9];
673 # FIXME: should cache these times.
674 local ($conf_time) = (stat ('configure.in'))[9];
675 # FIXME: how to do unsigned comparison?
676 if ($am_time < $in_time || $am_time < $conf_time)
683 local ($acl_time) = (stat _)[9];
684 return if ($am_time < $acl_time);
688 if (! open (GM_FILE, "> " . $out_file))
690 warn "automake: ${am_file}.in: cannot write: $!\n";
694 print "automake: creating ", $makefile, ".in\n" if $verbose;
696 print GM_FILE $output_vars;
697 # We make sure that `all:' is the first target.
698 print GM_FILE $output_all;
699 print GM_FILE $output_header;
700 print GM_FILE $output_rules;
701 print GM_FILE $output_trailer;
703 if (! close (GM_FILE))
705 warn "automake: $am_file.in: cannot close: $!\n";
711 ################################################################
713 # Handle AUTOMAKE_OPTIONS variable. Return 1 on error, 0 otherwise.
716 if (&variable_defined ('AUTOMAKE_OPTIONS'))
718 foreach (&variable_value_as_list ('AUTOMAKE_OPTIONS', ''))
721 if ($_ eq 'gnits' || $_ eq 'gnu' || $_ eq 'foreign')
723 &set_strictness ($_);
725 elsif ($_ eq 'cygnus')
731 # An option like "../lib/ansi2knr" is allowed. With
732 # no path prefix, we assume the required programs are
733 # in this directory. We save the actual option for
735 $options{'ansi2knr'} = $_;
737 elsif ($_ eq 'no-installman' || $_ eq 'no-installinfo'
738 || $_ eq 'dist-shar' || $_ eq 'dist-zip'
739 || $_ eq 'dist-tarZ' || $_ eq 'dist-bzip2'
740 || $_ eq 'dejagnu' || $_ eq 'no-texinfo.tex'
741 || $_ eq 'readme-alpha' || $_ eq 'check-news'
742 || $_ eq 'subdir-objects' || $_ eq 'nostdinc')
744 # Explicitly recognize these.
746 elsif ($_ eq 'no-dependencies')
748 $use_dependencies = 0;
750 elsif (/([0-9]+)\.([0-9]+)([a-z])?/)
752 # Got a version number.
754 local ($rmajor, $rminor, $ralpha) = ($1, $2, $3);
756 if ($VERSION !~ /([0-9]+)\.([0-9]+)([a-z])?/)
759 "automake: programming error: version is incorrect\n";
762 local ($tmajor, $tminor, $talpha) = ($1, $2, $3);
764 # 2.0 is better than 1.0.
765 # 1.2 is better than 1.1.
766 # 1.2a is better than 1.2.
767 if ($rmajor > $tmajor
768 || ($rmajor == $tmajor && $rminor > $tminor)
769 || ($rminor == $tminor && $rminor == $tminor
770 && $ralpha gt $talpha))
772 &am_line_error ('AUTOMAKE_OPTIONS',
773 "require version $_, only have $VERSION");
779 &am_line_error ('AUTOMAKE_OPTIONS',
780 "option \`" . $_ . "\' not recognized");
785 if ($strictness == $GNITS)
787 $options{'readme-alpha'} = 1;
788 $options{'check-news'} = 1;
794 # Return object extension. Just once, put some code into the output.
795 # Argument is the name of the output file
796 sub get_object_extension
800 # Maybe require libtool library object files.
801 local ($extension) = '.o';
802 $extension = '.$(OBJEXT)' if $seen_objext;
803 $extension = '.lo' if ($out =~ /\.la$/);
805 if (! $included_generic_compile)
809 if (! defined $options{'nostdinc'})
811 $xform = ' -I. -I\$(srcdir)';
813 if (&variable_defined ('CONFIG_HEADER'))
816 foreach $one_hdr (split (' ',
817 &variable_value ('CONFIG_HEADER')))
820 ($var = &dirname ($one_hdr)) =~ s/(\W)/\\$1/g;
821 $xform .= ' -I' . $var;
825 $xform = 's/\@DEFAULT_INCLUDES\@/' . $xform . '/go;';
826 $output_vars .= &file_contents_with_transform ($xform,
829 $xform = $seen_objext ? 's/^OBJEXT//;' : 's/^OBJEXT.*$//;';
830 $output_rules .= &file_contents_with_transform ($xform, 'compile');
832 &push_phony_cleaners ('compile');
834 # If using X, include some extra variable definitions. NOTE
835 # we don't want to force these into CFLAGS or anything,
836 # because not all programs will necessarily use X.
840 foreach $var ('X_CFLAGS', 'X_LIBS', 'X_EXTRA_LIBS', 'X_PRE_LIBS')
842 &define_configure_variable ($var);
846 push (@suffixes, '.c', '.o');
847 push (@suffixes, '.obj') if $seen_objext;
848 push (@clean, 'compile');
850 $included_generic_compile = 1;
853 if ($seen_libtool && ! $included_libtool_compile)
855 # Output the libtool compilation rules.
856 $output_rules .= &file_contents ('libtool');
858 &push_phony_cleaners ('libtool');
860 push (@suffixes, '.lo');
861 push (@clean, 'libtool');
863 $included_libtool_compile = 1;
866 # Check for automatic de-ANSI-fication.
867 if (defined $options{'ansi2knr'})
869 $extension = '$U' . $extension;
870 if (! $included_knr_compile)
872 if (! $am_c_prototypes)
874 &am_line_error ('AUTOMAKE_OPTIONS',
875 "option \`ansi2knr' in use but \`AM_C_PROTOTYPES' not in configure.in");
876 &keyed_aclocal_warning ('AM_C_PROTOTYPES');
877 # Only give this error once.
878 $am_c_prototypes = 1;
881 # Only require ansi2knr files if they should appear in
883 if ($options{'ansi2knr'} eq 'ansi2knr')
885 &require_file_with_line ('AUTOMAKE_OPTIONS', $FOREIGN,
886 'ansi2knr.c', 'ansi2knr.1');
887 $output_rules .= &file_contents ('kr-extra');
888 push (@clean, 'krextra');
889 &push_phony_cleaners ('krextra');
892 # Generate rules to build ansi2knr. If it is in some
893 # other directory, then generate dependencies but have the
894 # rule just run elsewhere.
895 $objext = $seen_objext ? ".\$(OBJEXT)" : ".o";
896 $output_rules .= ($options{'ansi2knr'} . ': '
897 . $options{'ansi2knr'} . $objext . "\n");
898 if ($options{'ansi2knr'} eq 'ansi2knr')
900 $output_rules .= ("\t\$(LINK) ansi2knr" . $objext
902 . "ansi2knr" . $objext
903 . ": \$(CONFIG_HEADER)\n\n");
907 $output_rules .= ("\tcd " . &dirname ($options{'ansi2knr'})
908 . " && \$(MAKE) \$(AM_MAKEFLAGS) "
910 # This is required for non-GNU makes.
911 $output_rules .= ($options{'ansi2knr'} . $objext . ":\n");
912 $output_rules .= ("\tcd " . &dirname ($options{'ansi2knr'})
913 . " && \$(MAKE) \$(AM_MAKEFLAGS)"
914 . " ansi2knr" . $objext . "\n\n");
917 # Make sure ansi2knr can be found: if no path specified,
919 if ($options{'ansi2knr'} eq 'ansi2knr')
921 # Substitution from AM_C_PROTOTYPES. This makes it be
922 # built only when necessary.
923 &define_configure_variable ('ANSI2KNR');
924 # ansi2knr needs to be built before subdirs, so unshift it.
925 unshift (@all, '$(ANSI2KNR)');
929 # Found in another directory.
930 &define_variable ("ANSI2KNR", $options{'ansi2knr'});
933 $output_rules .= &file_contents ('clean-kr');
936 &push_phony_cleaners ('kr');
938 $included_knr_compile = 1;
945 # Call finish function for each language that was used.
948 local ($ltcompile, $ltlink) = &libtool_compiler;
950 local ($ext, $name, $lang, %done);
952 foreach $ext (sort keys %extension_seen)
954 $lang = $extension_map{$ext};
956 # Generate the appropriate rules for this extension. If
957 # dependency tracking was requested, and this extension
958 # supports it, then we don't generate the rule here.
961 if ($use_dependencies && $language_map{$lang . '-autodep'} ne 'no')
963 # Don't generate the rule, but still generate the variables.
964 if (defined $language_map{$lang . '-compile'})
966 $comp = $language_map{$lang . '-compile'};
969 elsif (defined $language_map{$lang . '-compile'})
971 $comp = $language_map{$lang . '-compile'};
973 local ($outarg) = $language_map{$lang . '-output-arg'};
974 if ($language_map{$lang . '-flags'} eq 'CFLAGS')
976 # C compilers don't always support -c -o.
977 if (defined $options{'subdir-objects'})
983 local ($full) = ("\t\$("
984 . $language_map{$lang . '-compiler-name'}
987 $output_rules .= (".$ext.o:\n"
990 # FIXME: Using cygpath should be somehow conditional.
991 $output_rules .= (".$ext.obj:\n"
993 . " \`cygpath -w \$<\`\n")
995 $output_rules .= (".$ext.lo:\n"
997 . $language_map{$lang . '-compiler-name'}
999 . $language_map{$lang . '-output-arg'}
1000 # We can always use -c -o with libtool.
1001 . ($language_map{$lang . '-flags'} eq 'CFLAGS'
1007 push (@suffixes, '.' . $ext);
1009 # The rest of the loop is done once per language.
1010 next if defined $done{$lang};
1013 $non_c = 0 if $lang !~ /(objc|cxx|f77|ratfor)$/;
1017 &define_compiler_variable ($language_map{$lang . '-compiler-name'},
1020 # The compiler's flag must be a configure variable.
1021 if (defined $language_map{$lang . '-flags'})
1023 &define_configure_variable ($language_map{$lang . '-flags'});
1026 # Compute the function name of the finisher and then call it.
1027 $name = 'lang_' . $lang . '_finish';
1031 # If the project is entirely C++ or entirely Fortran 77, don't
1032 # bother with the C stuff. But if anything else creeps in, then use
1034 if (! $non_c || scalar keys %suffix_rules > 0)
1036 if (! defined $done{'c'})
1038 &define_configure_variable ($language_map{'c-flags'});
1039 &define_compiler_variable ($language_map{'c-compiler-name'},
1041 $language_map{'c-compile'});
1043 &define_variable ('CCLD', '$(CC)');
1044 &define_variable ('LINK', $ltlink . '$(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@');
1048 # Output a rule to build from a YACC source. The output from YACC is
1049 # compiled with C or C++, depending on the extension of the YACC file.
1050 sub output_yacc_build_rule
1052 local ($yacc_suffix, $use_ylwrap, $c_suffix) = @_;
1055 ($suffix = $yacc_suffix) =~ tr/y/c/;
1056 push (@suffixes, $yacc_suffix, $suffix);
1058 # Generate rule for c/c++.
1059 $output_rules .= "$yacc_suffix$suffix:\n\t";
1063 $output_rules .= ('$(SHELL) $(YLWRAP)'
1064 . ' "$(YACC)" $< y.tab.c $*' . $suffix
1065 . ' y.tab.h $*.h -- $(AM_YFLAGS) $(YFLAGS)');
1069 $output_rules .= ('$(YACC) $(AM_YFLAGS) $(YFLAGS) $< && mv y.tab.c $*'
1071 . "\tif test -f y.tab.h; then \\\n"
1072 . "\tif cmp -s y.tab.h \$*.h; then rm -f y.tab.h; else mv y.tab.h \$*.h; fi; \\\n"
1075 $output_rules .= "\n";
1078 sub output_lex_build_rule
1080 local ($lex_suffix, $use_ylwrap) = @_;
1083 ($c_suffix = $lex_suffix) =~ tr/l/c/;
1084 push (@suffixes, $lex_suffix);
1085 &define_configure_variable ('LEX_OUTPUT_ROOT');
1086 &define_configure_variable ('LEXLIB');
1087 $output_rules .= "$lex_suffix$c_suffix:\n\t";
1091 # Is the $@ correct here? If so, why not use it in the ylwrap
1092 # build rule for yacc above?
1093 $output_rules .= '$(SHELL) $(YLWRAP)'
1094 . ' "$(LEX)" $< $(LEX_OUTPUT_ROOT).c $@ -- $(AM_LFLAGS) $(LFLAGS)';
1098 $output_rules .= '$(LEX) $(AM_LFLAGS) $(LFLAGS) $< && mv $(LEX_OUTPUT_ROOT).c $@';
1100 $output_rules .= "\n";
1104 # Check to make sure a source defined in LIBOBJS is not explicitly
1105 # mentioned. This is a separate function (as opposed to being inlined
1106 # in handle_source_transform) because it isn't always appropriate to
1108 sub check_libobjs_sources
1110 local ($one_file, $unxformed) = @_;
1112 local ($prefix, $file, @files);
1113 foreach $prefix ('', 'EXTRA_', 'dist_', 'nodist_',
1114 'dist_EXTRA_', 'nodist_EXTRA_')
1116 if (&variable_defined ($prefix . $one_file . '_SOURCES'))
1118 @files = &variable_value_as_list (($prefix
1119 . $one_file . '_SOURCES'),
1122 elsif ($prefix eq '')
1124 @files = ($unxformed . '.c');
1131 foreach $file (@files)
1133 if (defined $libsources{$file})
1135 &am_line_error ($prefix . $one_file . '_SOURCES',
1136 "automatically discovered file \`$file' should not be explicitly mentioned");
1142 # Does much of the actual work for handle_source_transform.
1144 # name of resulting executable or library ("derived")
1145 # object extension (e.g., `$U.lo')
1146 # list of source files to transform
1148 # first element is name of linker to use (empty string for default linker)
1149 # remaining elements are names of objects
1150 sub handle_single_transform_list
1152 local ($var, $derived, $obj, @files) = @_;
1153 local (@result) = ();
1154 local ($nonansi_obj) = $obj;
1155 $nonansi_obj =~ s/_//g;
1156 local (%linkers_used) = ();
1159 # Turn sources into objects.
1162 # Configure substitutions in _SOURCES variables are errors.
1165 &am_line_error ($var, "$var includes configure substitution \`$_'");
1169 # If the source file is in a subdirectory then the `.o' is
1170 # put into the current directory.
1172 # Split file name into base and extension.
1173 local ($full, $directory, $base, $extension, $linker, $object);
1174 next if ! /^((.*)\/)?([^\/]*)\.(.*)$/;
1180 local ($xbase) = $base;
1182 # We must generate a rule for the object if it requires
1185 local ($renamed) = 0;
1187 $extension = &derive_suffix ($extension);
1188 local ($lang) = $extension_map{$extension};
1191 &saw_extension ($extension);
1192 # Found the language, so see what it says.
1193 local ($subr) = 'lang_' . $lang . '_rewrite';
1194 # Note: computed subr call.
1195 local ($r) = & $subr ($directory, $base, $extension);
1196 # Skip this entry if we were asked not to process it.
1197 next if $r == $LANG_IGNORE;
1199 # Now extract linker and other info.
1200 $linker = $language_map{$lang . '-linker'};
1202 local ($this_obj_ext);
1203 if ($language_map{$lang . '-ansi-p'})
1205 $object = $base . $obj;
1206 $this_obj_ext = $obj;
1210 $object = $base . $nonansi_obj;
1211 $this_obj_ext = $nonansi_obj;
1214 if ($language_map{$lang . '-flags'} ne ''
1215 && &variable_defined ($derived . '_'
1216 . $language_map{$lang . '-flags'}))
1218 # We have a per-executable flag in effect for this
1219 # object. In this case we rewrite the object's
1220 # name to ensure it is unique. We also require
1221 # the `compile' program to deal with compilers
1222 # where `-c -o' does not work.
1224 # We choose the name `DERIVED-OBJECT' to ensure
1225 # (1) uniqueness, and (2) continuity between
1226 # invocations. However, this will result in a
1227 # name that is too long for losing systems, in
1228 # some situations. So we provide _SHORTNAME to
1231 local ($dname) = $derived;
1232 if (&variable_defined ($derived . '_SHORTNAME'))
1234 # FIXME: should use the same conditional as
1235 # the _SOURCES variable. But this is really
1236 # silly overkill -- nobody should have
1237 # conditional shortnames.
1238 $dname = &variable_value ($derived . '_SHORTNAME');
1240 $object = $dname . '-' . $object;
1242 &require_file ($FOREIGN, 'compile')
1245 if (! defined $language_map{$lang . '-compile'})
1247 print STDERR "automake: programming error: $lang flags defined without compiler\n";
1250 # Compute the rule to compile this object.
1251 local ($flag) = $language_map{$lang . '-flags'};
1252 local ($val) = "(${derived}_${flag}";
1253 ($rule = $language_map{$lang . '-compile'}) =~
1256 $rule .= ' ' . $language_map{$lang . '-output-arg'};
1257 # For C we have to add the -o, because the
1258 # standard rule doesn't include it.
1259 if ($language_map{$lang . '-flags'} eq 'CFLAGS')
1267 # If rewrite said it was ok, put the object into a
1269 if ($r == $LANG_SUBDIR && $directory ne '')
1271 $object = $directory . '/' . $object;
1272 $xbase = $directory . '/' . $base;
1275 # If doing dependency tracking, then we can't print
1276 # the rule. Also, if we have a subdir object, we need
1277 # to generate an explicit rule.
1278 if (($use_dependencies
1280 && $language_map{$lang . '-autodep'} ne 'no')
1281 || ($r == $LANG_SUBDIR && $directory ne ''))
1284 local ($obj_sans_ext) = substr ($object, 0,
1285 - length ($this_obj_ext));
1286 $lang_specific_files{$lang} .= (' ' . $derived
1288 . ' ' . $obj_sans_ext);
1291 elsif ($extension eq 'o')
1293 # This is probably the result of a direct suffix rule.
1294 # In this case we just accept the rewrite. FIXME:
1295 # this fails if we want libtool objects.
1296 $object = $base . '.' . $extension;
1301 # No error message here. Used to have one, but it was
1306 $linkers_used{$linker} = 1;
1308 push (@result, $object);
1310 if (defined $object_map{$object})
1312 if ($object_map{$object} ne $full)
1314 &am_error ("object \`$object' created by \`$full' and \`$object_map{$object}'");
1319 local (@dep_list) = ();
1320 $object_map{$object} = $full;
1322 # If file is in subdirectory, we need explicit
1324 if ($directory ne '' || $renamed)
1326 push (@dep_list, $full);
1329 # If resulting object is in subdir, we need to make
1330 # sure the subdir exists at build time.
1331 if ($object =~ /\//)
1333 # FIXME: check that $DIRECTORY is somewhere in the
1336 # We don't allow `..' in object file names for
1337 # *any* source, not just Java. For Java it just
1338 # doesn't make sense, but in general it is
1339 # a problem because we can't pick a good name for
1341 if ($object =~ /(\/|^)\.\.\//)
1343 &am_error ("\`$full' contains \`..' component but should not");
1346 push (@dep_list, $directory . '/.dirstamp');
1348 # If we're generating dependencies, we also want
1349 # to make sure that the appropriate subdir of the
1350 # .deps directory is created.
1351 if ($use_dependencies)
1353 push (@dep_list, '.deps/' . $directory . '/.dirstamp');
1356 if (! defined $directory_map{$directory})
1358 $directory_map{$directory} = 1;
1359 $output_rules .= ($directory . "/.dirstamp:\n"
1360 . "\t\@\$(mkinstalldirs) $directory\n"
1361 . "\t\@: > $directory/.dirstamp\n");
1362 if ($use_dependencies)
1364 $output_rules .= ('.deps/' . $directory
1366 . "\t\@\$(mkinstalldirs) .deps/$directory\n"
1367 . "\t\@: > .deps/$directory/.dirstamp\n");
1372 &pretty_print_rule ($object . ':', "\t", @dep_list)
1373 if scalar @dep_list > 0 || $rule ne '';
1375 # Print the rule if we have one.
1378 # Turn `$@' into name of our object file.
1380 ($xform = $object) =~ s,/,\\/,g;
1381 $rule =~ s/\$\@/$xform/;
1383 # We cannot use $< here since this is an explicit
1384 # rule and not all makes handle that.
1385 $rule .= " \`test -f $full || echo '\$(srcdir)/'\`$full";
1387 # FIXME: handle .lo and .obj as well.
1388 $output_rules .= "\t" . $rule . "\n";
1392 # Transform .o or $o file into .P file (for automatic
1394 local ($depfile) = $object;
1395 $depfile =~ s/\.([^.]*)$/.P$1/;
1396 $depfile =~ s/\$\(OBJEXT\)$/o/ if $seen_objext;
1397 $dep_files{'$(DEPDIR)/' . $depfile} = 1;
1401 return (&resolve_linker (%linkers_used), @result);
1404 # Handle SOURCE->OBJECT transform for one program or library.
1406 # canonical (transformed) name of object to build
1407 # actual name of object to build
1408 # object extension (ie either `.o' or `$o'.
1409 # Return result is name of linker variable that must be used.
1410 # Empty return means just use `LINK'.
1411 sub handle_source_transform
1413 # one_file is canonical name. unxformed is given name. obj is
1415 local ($one_file, $unxformed, $obj) = @_;
1417 local ($linker) = '';
1419 if (&variable_defined ($one_file . "_OBJECTS"))
1421 &am_line_error ($one_file . '_OBJECTS',
1422 $one_file . '_OBJECTS', 'should not be defined');
1423 # No point in continuing.
1427 local (@files, @result, $prefix, $temp, $xpfx);
1428 local (%used_pfx) = ();
1429 foreach $prefix ('', 'EXTRA_', 'dist_', 'nodist_',
1430 'dist_EXTRA_', 'nodist_EXTRA_')
1432 # We are going to define _OBJECTS variables using the prefix.
1433 # Then we glom them all together. So we can't use the null
1434 # prefix here as we need it later.
1435 $xpfx = ($prefix eq '') ? 'am_' : $prefix;
1438 local ($var) = $prefix . $one_file . "_SOURCES";
1439 if (&variable_defined ($var))
1441 # Keep track of which prefixes we saw.
1442 $used_pfx{$xpfx} = 1
1443 unless $prefix =~ /EXTRA_/;
1445 push (@sources, '$(' . $prefix . $one_file . "_SOURCES)");
1446 push (@objects, '$(' . $xpfx . $one_file . "_OBJECTS)")
1447 unless $prefix =~ /EXTRA_/;
1448 push (@dist_sources, '$(' . $prefix . $one_file . "_SOURCES)")
1449 unless $prefix =~ /^nodist_/;
1450 local (@conds) = &variable_conditions ($var);
1453 @files = &variable_value_as_list ($var, '');
1458 foreach $cond (@conds)
1460 @files = &variable_value_as_list ($var, $cond);
1462 &handle_single_transform_list ($var, $one_file, $obj,
1464 $linker = $temp if $linker eq '';
1466 # Define _OBJECTS conditionally.
1467 &define_pretty_variable ($xpfx . $one_file . '_OBJECTS',
1469 unless $prefix =~ /EXTRA_/;
1476 # Avoid defining needless variables.
1477 next if (scalar @files == 0);
1479 ($temp, @result) = &handle_single_transform_list ($var, $one_file,
1481 $linker = $temp if $linker eq '';
1482 &define_pretty_variable ($xpfx . $one_file . "_OBJECTS", '', @result)
1483 unless $prefix =~ /EXTRA_/;
1486 local (@keys) = sort keys %used_pfx;
1487 if (scalar @keys == 0)
1489 &define_variable ($one_file . "_SOURCES", $unxformed . ".c");
1490 push (@sources, $unxformed . '.c');
1491 push (@dist_sources, $unxformed . '.c');
1492 push (@objects, $unxformed . $obj);
1493 push (@files, $unxformed . '.c');
1495 ($temp, @result) = &handle_single_transform_list ($one_file . '_SOURCES',
1498 $linker = $temp if $linker eq '';
1499 &define_pretty_variable ($one_file . "_OBJECTS", '', @result)
1503 grep ($_ = '$(' . $_ . $one_file . '_OBJECTS)', @keys);
1504 &define_pretty_variable ($one_file . '_OBJECTS', '', @keys);
1510 # Handle the BUILT_SOURCES variable.
1511 sub handle_built_sources
1513 return unless &variable_defined ('BUILT_SOURCES');
1515 local (@sources) = &variable_value_as_list ('BUILT_SOURCES', 'all');
1517 foreach $s (@sources)
1521 # FIXME: is this really the right thing to do?
1522 &am_line_error ('BUILT_SOURCES',
1523 "\`BUILT_SOURCES' should not contain a configure substitution");
1529 # Special-case @ALLOCA@ and @LIBOBJS@ in _LDADD or _LIBADD variables.
1530 # Also, generate _DEPENDENCIES variable if appropriate.
1532 # transformed name of object being built, or empty string if no object
1533 # name of _LDADD/_LIBADD-type variable to examine
1534 # boolean (lex_seen) which is true if a lex source file was seen in this
1535 # object. valid only for LDADDs, not LIBADDs.
1536 # Returns 1 if LIBOBJS seen, 0 otherwise.
1537 sub handle_lib_objects
1539 local ($xname, $var, $lex_seen) = @_;
1542 die "automake: programming error 1 in handle_lib_objects\n"
1543 if ! &variable_defined ($var);
1545 die "automake: programming error 2 in handle_lib_objects\n"
1546 if $lex_seen && $var =~ /LIBADD/;
1548 local (@conds) = &variable_conditions ($var);
1551 $ret = &handle_lib_objects_cond ($xname, $var, $lex_seen, '');
1557 foreach $cond (@conds)
1559 if (&handle_lib_objects_cond ($xname, $var, $lex_seen, $cond))
1569 # Subroutine of handle_lib_objects: handle a particular condition.
1570 sub handle_lib_objects_cond
1572 local ($xname, $var, $lex_seen, $cond) = @_;
1574 # We recognize certain things that are commonly put in LIBADD or
1577 local (@dep_list) = ();
1579 local ($seen_libobjs) = 0;
1580 local ($flagvar) = 0;
1582 foreach $lsearch (&variable_value_as_list ($var, $cond))
1584 # Skip -lfoo and -Ldir; these are explicitly allowed.
1585 next if $lsearch =~ /^-[lL]/;
1586 if (! $flagvar && $lsearch =~ /^-/)
1588 if ($var =~ /^(.*)LDADD$/)
1590 # Skip -dlopen and -dlpreopen; these are explicitly allowed.
1591 next if $lsearch =~ /^-dl(pre)?open$/;
1592 &am_line_error ($var, "linker flags such as \`$lsearch' belong in \`${1}LDFLAGS");
1596 # Only get this error once.
1598 &am_line_error ($var, "linker flags such as \`$lsearch' belong in \`${1}LDFLAGS");
1602 # Assume we have a file of some sort, and push it onto the
1603 # dependency list. Autoconf substitutions are not pushed;
1604 # rarely is a new dependency substituted into (eg) foo_LDADD
1605 # -- but "bad things (eg -lX11) are routinely substituted.
1606 # Note that LIBOBJS and ALLOCA are exceptions to this rule,
1607 # and handled specially below.
1608 push (@dep_list, $lsearch)
1609 unless $lsearch =~ /^\@.*\@$/;
1611 # Automatically handle @LIBOBJS@ and @ALLOCA@. Basically this
1612 # means adding entries to dep_files.
1613 if ($lsearch =~ /^\@(LT)?LIBOBJS\@$/)
1615 local ($myobjext) = ($1 ? 'l' : '') . 'o';
1617 push (@dep_list, $lsearch);
1619 if (! keys %libsources
1620 && ! &variable_defined ($1 . 'LIBOBJS'))
1622 &am_line_error ($var, "\@$1" . "LIBOBJS\@ seen but never set in \`configure.in'");
1625 local ($iter, $rewrite);
1626 foreach $iter (keys %libsources)
1628 if ($iter =~ /\.([cly])$/)
1630 &saw_extension ($1);
1631 &saw_extension ('c');
1634 if ($iter =~ /\.h$/)
1636 &require_file_with_line ($var, $FOREIGN, $iter);
1638 elsif ($iter ne 'alloca.c')
1640 ($rewrite = $iter) =~ s/\.c$/.P$myobjext/;
1641 $dep_files{'$(DEPDIR)/' . $rewrite} = 1;
1642 ($rewrite = $iter) =~ s/(\W)/\\$1/g;
1643 $rewrite = "^" . $rewrite . "\$";
1644 # Only require the file if it is not a built source.
1645 if (! &variable_defined ('BUILT_SOURCES')
1646 || ! grep (/$rewrite/,
1647 &variable_value_as_list ('BUILT_SOURCES',
1650 &require_file_with_line ($var, $FOREIGN, $iter);
1655 elsif ($lsearch =~ /^\@(LT)?ALLOCA\@$/)
1657 local ($myobjext) = ($1 ? 'l' : '') . 'o';
1659 push (@dep_list, $lsearch);
1660 &am_line_error ($var,
1661 "\@$1" . "ALLOCA\@ seen but \`AC_FUNC_ALLOCA' not in \`configure.in'")
1662 if ! defined $libsources{'alloca.c'};
1663 $dep_files{'$(DEPDIR)/alloca.P' . $myobjext} = 1;
1664 &require_file_with_line ($var, $FOREIGN, 'alloca.c');
1665 &saw_extension ('c');
1669 if ($xname ne '' && ! &variable_defined ($xname . '_DEPENDENCIES', $cond))
1671 &define_pretty_variable ($xname . '_DEPENDENCIES', $cond, @dep_list);
1674 return $seen_libobjs;
1677 # Canonicalize a name, and check to make sure the non-canonical name
1678 # is never used. Returns canonical name. Arguments are name and a
1679 # list of suffixes to check for.
1680 sub check_canonical_spelling
1682 local ($name, @suffixes) = @_;
1683 local ($xname, $xt);
1685 ($xname = $name) =~ tr/A-Za-z0-9_/_/c;
1686 if ($xname ne $name)
1689 foreach $xt (@suffixes)
1691 &am_line_error ($name . $xt,
1692 "invalid variable \`" . $name . $xt
1693 . "'; should be \`" . $xname . $xt . "'")
1694 if &variable_defined ($name . $xt);
1701 # Handle C programs.
1704 local (@proglist) = &am_install_var ('-clean',
1705 'progs', 'PROGRAMS',
1706 'bin', 'sbin', 'libexec', 'pkglib',
1708 return if ! @proglist;
1710 # If a program is installed, this is required. We only want this
1711 # error to appear once.
1712 &am_conf_error ("AC_ARG_PROGRAM must be used in configure.in")
1713 unless $seen_arg_prog;
1716 local ($one_file, $xname, $munge);
1718 local ($seen_libobjs) = 0;
1719 foreach $one_file (@proglist)
1721 local ($obj) = &get_object_extension ($one_file);
1723 # Canonicalize names and check for misspellings.
1724 $xname = &check_canonical_spelling ($one_file, '_LDADD', '_LDFLAGS',
1725 '_SOURCES', '_OBJECTS',
1728 # FIXME: Using a trick to figure out if any lex sources appear
1729 # in our program; should use some cleaner method.
1730 local ($lex_num) = scalar (keys %lex_sources);
1731 local ($linker) = &handle_source_transform ($xname, $one_file, $obj);
1732 local ($lex_file_seen) = (scalar (keys %lex_sources) > $lex_num);
1735 if (&variable_defined ($xname . "_LDADD"))
1737 if (&handle_lib_objects ($xname, $xname . '_LDADD',
1747 # User didn't define prog_LDADD override. So do it.
1748 &define_variable ($xname . '_LDADD', '$(LDADD)');
1750 # This does a bit too much work. But we need it to
1751 # generate _DEPENDENCIES when appropriate.
1752 if (&variable_defined ('LDADD'))
1754 if (&handle_lib_objects ($xname, 'LDADD', $lex_file_seen))
1760 elsif (! &variable_defined ($xname . '_DEPENDENCIES'))
1762 &define_variable ($xname . '_DEPENDENCIES', '');
1767 if (&variable_defined ($xname . '_LIBADD'))
1769 &am_line_error ($xname . '_LIBADD',
1770 "use \`" . $xname . "_LDADD', not \`"
1771 . $xname . "_LIBADD'");
1774 if (! &variable_defined ($xname . '_LDFLAGS'))
1776 # Define the prog_LDFLAGS variable.
1777 &define_variable ($xname . '_LDFLAGS', '');
1780 # Determine program to use for link.
1782 if (&variable_defined ($xname . '_LINK'))
1784 $xlink = $xname . '_LINK';
1788 $xlink = $linker ? $linker : 'LINK';
1792 if ($seen_exeext && $one_file !~ /\./)
1794 $xexe = 's/\@EXEEXT\@/\$(EXEEXT)/g;';
1798 $xexe = 's/\@EXEEXT\@//g;';
1802 &file_contents_with_transform
1803 ('s/\@PROGRAM\@/' . $one_file . '/go;'
1804 . 's/\@XPROGRAM\@/' . $xname . '/go;'
1805 . 's/\@XLINK\@/' . $xlink . '/go;'
1810 if (&variable_defined ('LDADD') && &handle_lib_objects ('', 'LDADD', 0))
1817 foreach $one_file (@proglist)
1819 # Canonicalize names.
1820 ($xname = $one_file) =~ tr/A-Za-z0-9_/_/c;
1822 if (&variable_defined ($xname . '_LDADD'))
1824 &check_libobjs_sources ($xname, $xname . '_LDADD');
1826 elsif (&variable_defined ('LDADD'))
1828 &check_libobjs_sources ($xname, 'LDADD');
1836 sub handle_libraries
1838 local (@liblist) = &am_install_var ('-clean',
1839 'libs', 'LIBRARIES',
1840 'lib', 'pkglib', 'noinst', 'check');
1841 return if ! @liblist;
1843 local (%valid) = &am_primary_prefixes ('LIBRARIES', 0, 'lib', 'pkglib',
1845 if (! defined $configure_vars{'RANLIB'})
1848 foreach $key (keys %valid)
1850 if (&variable_defined ($key . '_LIBRARIES'))
1852 &am_line_error ($key . '_LIBRARIES', "library used but \`RANLIB' not defined in \`configure.in'");
1853 # Only get this error once. If this is ever printed,
1855 $configure_vars{'RANLIB'} = 'BUG';
1864 local ($seen_libobjs) = 0;
1865 foreach $onelib (@liblist)
1867 # Check that the library fits the standard naming convention.
1868 if ($onelib !~ /^lib.*\.a$/)
1870 # FIXME should put line number here. That means mapping
1871 # from library name back to variable name.
1872 &am_error ("\`$onelib' is not a standard library name");
1875 local ($obj) = &get_object_extension ($onelib);
1877 # Canonicalize names and check for misspellings.
1878 $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_SOURCES',
1879 '_OBJECTS', '_DEPENDENCIES', '_AR');
1881 if (! &variable_defined ($xlib . '_AR'))
1883 &define_variable ($xlib . '_AR', '$(AR) cru');
1886 if (&variable_defined ($xlib . '_LIBADD'))
1888 if (&handle_lib_objects ($xlib, $xlib . '_LIBADD', 0))
1895 # Generate support for conditional object inclusion in
1897 &define_variable ($xlib . "_LIBADD", '');
1900 if (&variable_defined ($xlib . '_LDADD'))
1902 &am_line_error ($xlib . '_LDADD',
1903 "use \`" . $xlib . "_LIBADD', not \`"
1904 . $xlib . "_LDADD'");
1907 # Make sure we at look at this.
1908 &examine_variable ($xlib . '_DEPENDENCIES');
1910 &handle_source_transform ($xlib, $onelib, $obj);
1913 &file_contents_with_transform ('s/\@LIBRARY\@/' . $onelib . '/go;'
1921 foreach $onelib (@liblist)
1923 # Canonicalize names.
1924 ($xlib = $onelib) =~ tr/A-Za-z0-9_/_/c;
1925 if (&variable_defined ($xlib . '_LIBADD'))
1927 &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
1932 &define_variable ('AR', 'ar');
1933 &define_configure_variable ('RANLIB');
1936 # Handle shared libraries.
1937 sub handle_ltlibraries
1939 local (@liblist) = &am_install_var ('-clean',
1940 'ltlib', 'LTLIBRARIES',
1941 'noinst', 'lib', 'pkglib', 'check');
1942 return if ! @liblist;
1945 local (%valid) = &am_primary_prefixes ('LTLIBRARIES', 0, 'lib', 'pkglib',
1949 foreach $key (keys %valid)
1951 if (&variable_defined ($key . '_LTLIBRARIES'))
1955 &am_line_error ($key . '_LTLIBRARIES', "library used but \`LIBTOOL' not defined in \`configure.in'");
1956 # Only get this error once. If this is ever printed,
1958 $configure_vars{'LIBTOOL'} = 'BUG';
1962 # Get the installation directory of each library.
1963 for (&variable_value_as_list ($key . '_LTLIBRARIES', 'all'))
1967 &am_error ("\`$_' is already going to be installed in \`$instdirs{$_}'");
1971 $instdirs{$_} = $key;
1980 local ($seen_libobjs) = 0;
1981 foreach $onelib (@liblist)
1983 local ($obj) = &get_object_extension ($onelib);
1985 # Canonicalize names and check for misspellings.
1986 $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_LDFLAGS',
1987 '_SOURCES', '_OBJECTS',
1990 if (! &variable_defined ($xlib . '_LDFLAGS'))
1992 # Define the lib_LDFLAGS variable.
1993 &define_variable ($xlib . '_LDFLAGS', '');
1996 # Check that the library fits the standard naming convention.
1997 $libname_rx = "^lib.*\.la";
1998 if (&variable_value ($xlib . '_LDFLAGS') =~ /-module/
1999 || &variable_value ('LDFLAGS') =~ /-module/)
2001 # Relax name checking for libtool modules.
2002 $libname_rx = "\.la";
2004 if ($onelib !~ /$libname_rx$/)
2006 # FIXME this should only be a warning for foreign packages
2007 # FIXME should put line number here. That means mapping
2008 # from library name back to variable name.
2009 &am_error ("\`$onelib' is not a standard libtool library name");
2012 if (&variable_defined ($xlib . '_LIBADD'))
2014 if (&handle_lib_objects ($xlib, $xlib . '_LIBADD', 0))
2021 # Generate support for conditional object inclusion in
2023 &define_variable ($xlib . "_LIBADD", '');
2026 if (&variable_defined ($xlib . '_LDADD'))
2028 &am_line_error ($xlib . '_LDADD',
2029 "use \`" . $xlib . "_LIBADD', not \`"
2030 . $xlib . "_LDADD'");
2033 # Make sure we at look at this.
2034 &examine_variable ($xlib . '_DEPENDENCIES');
2036 local ($linker) = &handle_source_transform ($xlib, $onelib, $obj);
2038 # Determine program to use for link.
2040 if (&variable_defined ($xlib . '_LINK'))
2042 $xlink = $xlib . '_LINK';
2046 $xlink = $linker ? $linker : 'LINK';
2050 if ($instdirs{$onelib} eq 'EXTRA' || $instdirs{$onelib} eq 'noinst')
2052 # It's an EXTRA_ library, so we can't specify -rpath,
2053 # because we don't know where the library will end up.
2054 # The user probably knows, but generally speaking automake
2055 # doesn't -- and in fact configure could decide
2056 # dynamically between two different locations.
2057 $rpath = 's/\@RPATH\@//go;';
2061 $rpath = ('s/\@RPATH\@/-rpath \$(' . $instdirs{$onelib}
2066 &file_contents_with_transform ('s/\@LTLIBRARY\@/'
2068 . 's/\@XLTLIBRARY\@/'
2071 . 's/\@XLINK\@/' . $xlink . '/go;',
2077 foreach $onelib (@liblist)
2079 # Canonicalize names.
2080 ($xlib = $onelib) =~ tr/A-Za-z0-9_/_/c;
2081 if (&variable_defined ($xlib . '_LIBADD'))
2083 &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
2089 # See if any _SOURCES variable were misspelled. Also, make sure that
2090 # EXTRA_ variables don't contain configure substitutions.
2093 local ($varname, $primary);
2094 foreach $varname (keys %contents)
2096 foreach $primary ('_SOURCES', '_LIBADD', '_LDADD', '_LDFLAGS',
2099 if ($varname =~ /$primary$/ && ! $content_seen{$varname})
2101 &am_line_error ($varname,
2102 "invalid unused variable name: \`$varname'");
2111 # NOTE we no longer automatically clean SCRIPTS, because it is
2112 # useful to sometimes distribute scripts verbatim. This happens
2113 # eg in Automake itself.
2114 &am_install_var ('-candist', 'scripts', 'SCRIPTS',
2115 'bin', 'sbin', 'libexec', 'pkgdata',
2118 local ($scripts_installed) = 0;
2119 # Set $scripts_installed if appropriate. Make sure we only find
2120 # scripts which are actually installed -- this is why we can't
2121 # simply use the return value of am_install_var.
2122 local (%valid) = &am_primary_prefixes ('SCRIPTS', 1, 'bin', 'sbin',
2123 'libexec', 'pkgdata',
2126 foreach $key (keys %valid)
2128 if ($key ne 'noinst'
2130 && &variable_defined ($key . '_SCRIPTS'))
2132 $scripts_installed = 1;
2133 # push (@check_tests, 'check-' . $key . 'SCRIPTS');
2137 if ($scripts_installed)
2139 # If a program is installed, this is required. We only want this
2140 # error to appear once.
2141 &am_conf_error ("AC_ARG_PROGRAM must be used in configure.in")
2142 unless $seen_arg_prog;
2147 # Search a file for a "version.texi" Texinfo include. Return the name
2148 # of the include file if found, or the empty string if not. A
2149 # "version.texi" file is actually any file whose name matches
2151 sub scan_texinfo_file
2153 local ($filename) = @_;
2155 if (! open (TEXI, $filename))
2157 &am_error ("couldn't open \`$filename': $!");
2160 print "automake: reading $filename\n" if $verbose;
2162 local ($vfile, $outfile);
2165 if (/^\@setfilename +(\S+)/)
2171 if (/^\@include\s+(vers[^.]*\.texi)\s*$/)
2173 # Found version.texi include.
2180 return ($outfile, $vfile);
2183 # Handle all Texinfo source.
2186 &am_line_error ('TEXINFOS',
2187 "\`TEXINFOS' is an anachronism; use \`info_TEXINFOS'")
2188 if &variable_defined ('TEXINFOS');
2189 return if (! &variable_defined ('info_TEXINFOS')
2190 && ! &variable_defined ('html_TEXINFOS'));
2192 if (&variable_defined ('html_TEXINFOS'))
2194 &am_line_error ('html_TEXINFOS',
2195 "HTML generation not yet supported");
2199 local (@texis) = &variable_value_as_list ('info_TEXINFOS', 'all');
2201 local (@info_deps_list, @dvis_list, @texi_deps);
2202 local ($infobase, $info_cursor);
2206 local ($tc_cursor, @texi_cleans);
2209 foreach $info_cursor (@texis)
2211 # FIXME: This is mildly hacky, since it recognizes "txinfo".
2212 # I don't feel like making it right.
2213 ($infobase = $info_cursor) =~ s/\.te?xi(nfo)?$//;
2215 # If 'version.texi' is referenced by input file, then include
2216 # automatic versioning capability.
2217 local ($out_file, $vtexi) = &scan_texinfo_file ($relative_dir
2218 . "/" . $info_cursor);
2220 if ($out_file eq '')
2222 &am_error ("\`$info_cursor' missing \@setfilename");
2226 if ($out_file =~ /\.(.+)$/ && $1 ne 'info')
2228 # FIXME should report line number in input file.
2229 &am_error ("output of \`$info_cursor', \`$out_file', has unrecognized extension");
2235 &am_error ("\`$vtexi', included in \`$info_cursor', also included in \`$versions{$vtexi}'")
2236 if (defined $versions{$vtexi});
2237 $versions{$vtexi} = $info_cursor;
2239 # We number the stamp-vti files. This is doable since the
2240 # actual names don't matter much. We only number starting
2241 # with the second one, so that the common case looks nice.
2242 $vti = ($done ? $done : 'vti');
2245 &push_dist_common ($vtexi, 'stamp-' . $vti);
2246 push (@clean, $vti);
2248 &require_conf_file_with_line ('info_TEXINFOS', $FOREIGN,
2251 local ($conf_pat, $conf_dir);
2252 if ($config_aux_dir eq '.' || $config_aux_dir eq '')
2254 $conf_dir = '$(srcdir)/';
2258 $conf_dir = $config_aux_dir;
2259 $conf_dir .= '/' unless $conf_dir =~ /\/$/;
2261 ($conf_pat = $conf_dir) =~ s/(\W)/\\$1/g;
2263 &file_contents_with_transform
2264 ('s/\@TEXI\@/' . $info_cursor . '/g; '
2265 . 's/\@VTI\@/' . $vti . '/g; '
2266 . 's/\@VTEXI\@/' . $vtexi . '/g;'
2267 . 's,\@MDDIR\@,' . $conf_pat . ',g;',
2270 &push_phony_cleaners ($vti);
2273 # If user specified file_TEXINFOS, then use that as explicit
2276 push (@texi_deps, $info_cursor);
2277 push (@texi_deps, $vtexi) if $vtexi;
2279 # Canonicalize name first.
2280 ($canonical = $infobase) =~ tr/A-Za-z0-9_/_/c;
2281 if (&variable_defined ($canonical . "_TEXINFOS"))
2283 push (@texi_deps, '$(' . $canonical . '_TEXINFOS)');
2284 &push_dist_common ('$(' . $canonical . '_TEXINFOS)');
2287 $output_rules .= ("\n" . $out_file . ": "
2288 . join (' ', @texi_deps)
2289 . "\n" . $infobase . ".dvi: "
2290 . join (' ', @texi_deps)
2293 push (@info_deps_list, $out_file);
2294 push (@dvis_list, $infobase . '.dvi');
2296 # Generate list of things to clean for this target. We do
2297 # this explicitly because otherwise too many things could be
2298 # removed. In particular the ".log" extension might
2299 # reasonably be used in other contexts by the user.
2300 # FIXME: this is really out of control.
2301 foreach $tc_cursor ('aux', 'cp', 'cps', 'dvi', 'fn', 'fns', 'pgs',
2302 'ky', 'kys', 'ps', 'log', 'pg', 'toc', 'tp', 'tps',
2303 'vr', 'vrs', 'op', 'tr', 'cv', 'cn', 'cm', 'ov')
2305 push (@texi_cleans, $infobase . '.' . $tc_cursor);
2309 # Find these programs wherever they may lie. Yes, this has
2310 # intimate knowledge of the structure of the texinfo distribution.
2311 &define_program_variable ('MAKEINFO', 'build', 'texinfo/makeinfo',
2313 # Circumlocution to avoid accidental
2314 # configure substitution.
2316 &define_program_variable ('TEXI2DVI', 'src', 'texinfo/util',
2319 # Set transform for including texinfos.am. First, handle --cygnus
2324 $xform = 's/^NOTCYGNUS.*$//; s/^CYGNUS//;';
2328 $xform = 's/^CYGNUS.*$//; s/^NOTCYGNUS//;';
2331 # Handle location of texinfo.tex.
2332 local ($need_texi_file) = 0;
2333 local ($texinfo_tex);
2336 $texinfo_tex = '$(top_srcdir)/../texinfo/texinfo.tex';
2337 &define_variable ('TEXINFO_TEX', $texinfo_tex);
2340 elsif ($config_aux_dir ne '.' && $config_aux_dir ne '')
2342 $texinfo_tex = $config_aux_dir . '/texinfo.tex';
2343 &define_variable ('TEXINFO_TEX', $texinfo_tex);
2344 $need_texi_file = 2; # so that we require_conf_file later
2346 elsif (&variable_defined ('TEXINFO_TEX'))
2348 # The user defined TEXINFO_TEX so assume he knows what he is
2350 $texinfo_tex = ('$(srcdir)/'
2351 . &dirname (&variable_value ('TEXINFO_TEX')));
2355 $texinfo_tex = '$(srcdir)/texinfo.tex';
2356 $need_texi_file = 1;
2359 ($xxform = $texinfo_tex) =~ s/\/texinfo\.tex$//;
2360 $xxform =~ s/(\W)/\\$1/g;
2361 $xform .= ' s/\@TEXINFODIR\@/' . $xxform . '/g;';
2363 $output_rules .= &file_contents_with_transform ($xform, 'texinfos');
2364 push (@phony, 'install-info-am', 'uninstall-info');
2365 push (@dist_targets, 'dist-info');
2367 # How to clean. The funny name is due to --cygnus influence; in
2368 # Cygnus mode, `clean-info' is a target that users can use.
2369 $output_rules .= "\nmostlyclean-aminfo:\n";
2370 &pretty_print_rule ("\t-rm -f", "\t ", @texi_cleans);
2371 $output_rules .= ("\nclean-aminfo:\n\ndistclean-aminfo:\n\n"
2372 . "maintainer-clean-aminfo:\n\t"
2373 # Eww. But how else can we find all the output
2374 # files from makeinfo?
2375 . ($cygnus_mode ? '' : 'cd $(srcdir) && ')
2376 . 'for i in $(INFO_DEPS); do' . " \\\n"
2377 . "\t" . ' rm -f $$i;' . " \\\n"
2378 . "\t" . ' if test "`echo $$i-[0-9]*`" != "$$i-[0-9]*"; then' . " \\\n"
2379 . "\t" . ' rm -f $$i-[0-9]*;' . " \\\n"
2380 . "\t" . ' fi;' . " \\\n"
2382 &push_phony_cleaners ('aminfo');
2385 $output_rules .= "clean-info: mostlyclean-aminfo\n";
2388 push (@suffixes, '.texi', '.texinfo', '.txi', '.info', '.dvi', '.ps');
2390 if (! defined $options{'no-installinfo'})
2392 push (@uninstall, 'uninstall-info');
2393 push (@installdirs, '$(DESTDIR)$(infodir)');
2394 unshift (@install_data, 'install-info-am');
2396 # Make sure documentation is made and installed first. Use
2397 # $(INFO_DEPS), not 'info', because otherwise recursive makes
2398 # get run twice during "make all".
2399 unshift (@all, '$(INFO_DEPS)');
2401 push (@clean, 'aminfo');
2402 push (@info, '$(INFO_DEPS)');
2403 push (@dvi, '$(DVIS)');
2405 &define_variable ("INFO_DEPS", join (' ', @info_deps_list));
2406 &define_variable ("DVIS", join (' ', @dvis_list));
2407 # This next isn't strictly needed now -- the places that look here
2408 # could easily be changed to look in info_TEXINFOS. But this is
2409 # probably better, in case noinst_TEXINFOS is ever supported.
2410 &define_variable ("TEXINFOS", &variable_value ('info_TEXINFOS'));
2412 # Do some error checking. Note that this file is not required
2413 # when in Cygnus mode; instead we defined TEXINFO_TEX explicitly
2415 if ($need_texi_file && ! defined $options{'no-texinfo.tex'})
2417 if ($need_texi_file > 1)
2419 &require_conf_file_with_line ('info_TEXINFOS', $FOREIGN,
2424 &require_file_with_line ('info_TEXINFOS', $FOREIGN, 'texinfo.tex');
2429 # Handle any man pages.
2430 sub handle_man_pages
2432 &am_line_error ('MANS', "\`MANS' is an anachronism; use \`man_MANS'")
2433 if &variable_defined ('MANS');
2434 return if ! &variable_defined ('man_MANS');
2436 # Find all the sections in use. We do this by first looking for
2437 # "standard" sections, and then looking for any additional
2438 # sections used in man_MANS.
2439 local ($sect, %sections, %vlist);
2440 # Add more sections as needed.
2441 foreach $sect ('0'..'9', 'n', 'l')
2443 if (&variable_defined ('man' . $sect . '_MANS'))
2445 $sections{$sect} = 1;
2446 $vlist{'$(man' . $sect . '_MANS)'} = 1;
2450 if (&variable_defined ('man_MANS'))
2452 $vlist{'$(man_MANS)'} = 1;
2453 foreach (&variable_value_as_list ('man_MANS', 'all'))
2455 # A page like `foo.1c' goes into man1dir.
2456 if (/\.([0-9a-z])([a-z]*)$/)
2464 # Now for each section, generate an install and unintall rule.
2465 # Sort sections so output is deterministic.
2467 foreach $sect (sort keys %sections)
2469 &define_variable ('man' . $sect . 'dir', '$(mandir)/man' . $sect);
2470 push (@installdirs, '$(DESTDIR)$(mandir)/man' . $sect)
2471 unless defined $options{'no-installman'};
2472 $output_rules .= &file_contents_with_transform ('s/\@SECTION\@/'
2475 push (@phony, 'install-man' . $sect, 'uninstall-man' . $sect);
2476 push (@namelist, 'install-man' . $sect);
2479 # We don't really need this, but we use it in case we ever want to
2480 # support noinst_MANS.
2481 &define_variable ("MANS", join (' ', sort keys %vlist));
2483 # Generate list of install dirs.
2484 $output_rules .= ("install-man: \$(MANS)\n"
2485 . "\t\@\$(NORMAL_INSTALL)\n");
2486 &pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ", @namelist);
2487 push (@phony, 'install-man');
2489 $output_rules .= "uninstall-man:\n\t\@\$(NORMAL_UNINSTALL)\n";
2490 grep ($_ = 'un' . $_, @namelist);
2491 &pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ", @namelist);
2492 push (@phony, 'uninstall-man');
2494 $output_vars .= &file_contents ('mans-vars');
2496 if (! defined $options{'no-installman'})
2498 push (@install_data, 'install-man');
2499 push (@uninstall, 'uninstall-man');
2500 push (@all, '$(MANS)');
2504 # Handle DATA variables.
2507 &am_install_var ('-noextra', '-candist', 'data', 'DATA',
2508 'data', 'sysconf', 'sharedstate', 'localstate',
2509 'pkgdata', 'noinst', 'check');
2515 push (@phony, 'tags');
2516 local (@tag_deps) = ();
2517 if (&variable_defined ('SUBDIRS'))
2519 $output_rules .= ("tags-recursive:\n"
2520 . "\tlist=\'\$(SUBDIRS)\'; for subdir in \$\$list; do \\\n"
2521 # Never fail here if a subdir fails; it
2523 . "\t test \"\$\$subdir\" = . || (cd \$\$subdir"
2524 . " && \$(MAKE) \$(AM_MAKEFLAGS) tags); \\\n"
2526 push (@tag_deps, 'tags-recursive');
2527 push (@phony, 'tags-recursive');
2530 if (&saw_sources_p (1)
2531 || &variable_defined ('ETAGS_ARGS')
2534 local ($xform) = '';
2536 foreach $one_hdr (@config_headers)
2538 if ($relative_dir eq &dirname ($one_hdr))
2540 # The config header is in this directory. So require it.
2542 ($var = &basename ($one_hdr)) =~ s/(\W)/\\$1/g;
2543 $xform .= ' ' if $xform;
2547 $xform = ('s/\@CONFIG\@/' . $xform . '/;'
2548 . 's/\@DIRS\@/' . join (' ', @tag_deps) . '/;');
2550 if (&variable_defined ('SUBDIRS'))
2552 $xform .= 's/^SUBDIRS//;';
2556 $xform .= 's/^SUBDIRS.*$//;';
2559 $output_rules .= &file_contents_with_transform ($xform, 'tags');
2560 $output_rules .= &file_contents ('tags-clean');
2561 push (@clean, 'tags');
2562 &push_phony_cleaners ('tags');
2563 &examine_variable ('TAGS_DEPENDENCIES');
2565 elsif (&variable_defined ('TAGS_DEPENDENCIES'))
2567 &am_line_error ('TAGS_DEPENDENCIES',
2568 "doesn't make sense to define \`TAGS_DEPENDENCIES' without sources or \`ETAGS_ARGS'");
2572 # Every Makefile must define some sort of TAGS rule.
2573 # Otherwise, it would be possible for a top-level "make TAGS"
2574 # to fail because some subdirectory failed.
2575 $output_rules .= "tags: TAGS\nTAGS:\n\n";
2579 # Handle multilib support.
2582 return unless $seen_multilib;
2584 $output_rules .= &file_contents ('multilib.am');
2585 &push_phony_cleaners ('multi');
2586 push (@phony, 'all-multi', 'install-multi');
2589 # Worker for handle_dist.
2590 sub handle_dist_worker
2592 local ($makefile) = @_;
2594 $output_rules .= 'distdir: $(DISTFILES)' . "\n";
2596 # Initialization; only at top level.
2597 if ($relative_dir eq '.')
2599 if (defined $options{'check-news'})
2601 # For Gnits users, this is pretty handy. Look at 15 lines
2602 # in case some explanatory text is desirable.
2603 $output_rules .= ' @if sed 15q $(srcdir)/NEWS | fgrep -e "$(VERSION)" > /dev/null; then :; else \\
2604 echo "NEWS not updated; not releasing" 1>&2; \\
2611 # Create dist directory.
2612 $output_rules .= ("\t-chmod -R a+w \$(distdir) > /dev/null 2>&1; rm -rf \$(distdir)\n"
2613 . "\tmkdir \$(distdir)\n");
2616 # Scan EXTRA_DIST to see if we need to distribute anything from a
2617 # subdir. If so, add it to the list. I didn't want to do this
2618 # originally, but there were so many requests that I finally
2621 if (&variable_defined ('EXTRA_DIST'))
2623 # FIXME: This should be fixed to work with conditionals. That
2624 # will require only making the entries in @dist_dirs under the
2625 # appropriate condition. This is meaningful if the nature of
2626 # the distribution should depend upon the configure options
2628 foreach (&variable_value_as_list ('EXTRA_DIST', ''))
2631 next unless s,/+[^/]+$,,;
2632 push (@dist_dirs, $_)
2637 # We have to check DIST_COMMON for extra directories in case the
2638 # user put a source used in AC_OUTPUT into a subdir.
2639 foreach (&variable_value_as_list ('DIST_COMMON', 'all'))
2642 next unless s,/+[^/]+$,,;
2643 push (@dist_dirs, $_)
2649 # Prepend $(distdir) to each directory given. Doing it via a
2650 # hash lets us ensure that each directory is used only once.
2652 grep ($dhash{'$(distdir)/' . $_} = 1, @dist_dirs);
2653 $output_rules .= "\t";
2654 &pretty_print_rule ('$(mkinstalldirs)', "\t ", sort keys %dhash);
2657 # In loop, test for file existence because sometimes a file gets
2658 # included in DISTFILES twice. For example this happens when a
2659 # single source file is used in building more than one program.
2660 # Also, there are situations in which "ln" can fail. For instance
2661 # a file to distribute could actually be a cross-filesystem
2662 # symlink -- this can easily happen if "gettextize" was run on the
2664 $output_rules .= "\t\@for file in \$(DISTFILES); do \\\n";
2667 $output_rules .= "\t if test -f \$\$file; then d=.; else d=\$(srcdir); fi; \\\n";
2671 $output_rules .= "\t d=\$(srcdir); \\\n";
2673 $output_rules .= ("\t if test -d \$\$d/\$\$file; then \\\n"
2674 # Don't mention $$file in destination argument,
2675 # since this fails if destination directory
2676 # already exists. Also, use `-R' and not `-r'.
2677 # `-r' is almost always incorrect.
2678 . "\t cp -pR \$\$d/\$\$file \$(distdir) \\\n"
2679 . "\t || exit 1; \\\n"
2681 . "\t test -f \$(distdir)/\$\$file \\\n"
2682 . "\t || cp -p \$\$d/\$\$file \$(distdir)/\$\$file \\\n"
2683 . "\t || exit 1; \\\n"
2687 # If we have SUBDIRS, create all dist subdirectories and do
2689 if (&variable_defined ('SUBDIRS'))
2691 # If SUBDIRS is conditionally defined, then set DIST_SUBDIRS
2692 # to all possible directories, and use it. If DIST_SUBDIRS is
2693 # defined, just use it.
2694 local ($dist_subdir_name);
2695 if (&variable_conditions ('SUBDIRS')
2696 || &variable_defined ('DIST_SUBDIRS'))
2698 $dist_subdir_name = 'DIST_SUBDIRS';
2699 if (! &variable_defined ('DIST_SUBDIRS'))
2701 local (@full_list) = &variable_value_as_list ('SUBDIRS',
2703 local (@ds_list, %uniq, $iter);
2704 foreach $iter (@full_list)
2706 if (! defined $uniq{$iter})
2709 push (@ds_list, $iter);
2712 &define_pretty_variable ('DIST_SUBDIRS', '', @ds_list);
2717 $dist_subdir_name = 'SUBDIRS';
2720 # Test for directory existence here because previous automake
2721 # invocation might have created some directories. Note that
2722 # we explicitly set distdir for the subdir make; that lets us
2723 # mix-n-match many automake-using packages into one large
2724 # package, and have "dist" at the top level do the right
2725 # thing. If we're in the topmost directory, then we use
2726 # `distdir' instead of `top_distdir'; this lets us work
2727 # correctly with an enclosing package.
2729 ("\t" . 'for subdir in $(' . $dist_subdir_name . '); do ' . "\\\n"
2730 . "\t" . ' if test "$$subdir" = .; then :; else ' . "\\\n"
2731 . "\t" . ' test -d $(distdir)/$$subdir ' . "\\\n"
2732 . "\t" . ' || mkdir $(distdir)/$$subdir ' . "\\\n"
2733 . "\t" . ' || exit 1; ' . "\\\n"
2734 . "\t" . ' (cd $$subdir'
2735 . ' && $(MAKE) $(AM_MAKEFLAGS) top_distdir=../$('
2736 . (($relative_dir eq '.') ? 'distdir' : 'top_distdir')
2737 . ') distdir=../$(distdir)/$$subdir distdir) ' . "\\\n"
2738 . "\t" . ' || exit 1; ' . "\\\n"
2739 . "\t" . ' fi; ' . "\\\n"
2743 # If the target `dist-hook' exists, make sure it is run. This
2744 # allows users to do random weird things to the distribution
2745 # before it is packaged up.
2746 push (@dist_targets, 'dist-hook') if &target_defined ('dist-hook');
2749 foreach $targ (@dist_targets)
2751 # We must explicitly set distdir and top_distdir for these
2753 $output_rules .= ("\t\$(MAKE) \$(AM_MAKEFLAGS)"
2754 . " top_distdir=\"\$(top_distdir)\""
2755 . " distdir=\"\$(distdir)\" $targ\n");
2758 push (@phony, 'distdir');
2761 # Handle 'dist' target.
2764 local ($makefile) = @_;
2766 # Set up maint_charset.
2767 $local_maint_charset = &variable_value ('MAINT_CHARSET')
2768 if &variable_defined ('MAINT_CHARSET');
2769 $maint_charset = $local_maint_charset
2770 if $relative_dir eq '.';
2772 if (&variable_defined ('DIST_CHARSET'))
2774 &am_line_error ('DIST_CHARSET',
2775 "DIST_CHARSET defined but no MAINT_CHARSET defined")
2776 if ! $local_maint_charset;
2777 if ($relative_dir eq '.')
2779 $dist_charset = &variable_value ('DIST_CHARSET')
2783 &am_line_error ('DIST_CHARSET',
2784 "DIST_CHARSET can only be defined at top level");
2788 # Look for common files that should be included in distribution.
2790 foreach $cfile (@common_files)
2792 if (-f ($relative_dir . "/" . $cfile))
2794 &push_dist_common ($cfile);
2798 # Always require configure.in and configure at top level, even if
2799 # they don't exist. This is especially important for configure,
2800 # since it won't be created until autoconf is run -- which might
2801 # be after automake is run.
2802 &push_dist_common ('configure.in', 'configure')
2803 if $relative_dir eq '.';
2805 # We might copy elements from %configure_dist_common to
2806 # %dist_common if we think we need to. If the file appears in our
2807 # directory, we would have discovered it already, so we don't
2808 # check that. But if the file is in a subdir without a Makefile,
2809 # we want to distribute it here if we are doing `.'. Ugly!
2810 if ($relative_dir eq '.')
2813 foreach $iter (keys %configure_dist_common)
2815 if (! &is_make_dir (&dirname ($iter)))
2817 &push_dist_common ($iter);
2822 # Keys of %dist_common are names of files to distributed. We put
2823 # README first because it then becomes easier to make a
2824 # Usenet-compliant shar file (in these, README must be first).
2825 # FIXME: do more ordering of files here.
2827 if (defined $dist_common{'README'})
2829 push (@coms, 'README');
2830 delete $dist_common{'README'};
2832 push (@coms, sort keys %dist_common);
2834 # Now that we've processed %dist_common, disallow further attempts
2836 $handle_dist_run = 1;
2838 &define_pretty_variable ("DIST_COMMON", '', @coms);
2839 $output_vars .= "\n";
2842 $output_vars .= &file_contents ('dist-vars') . "\n";
2843 &define_variable ('GZIP_ENV', '--best');
2845 # Put these things in rules section so it is easier for whoever
2846 # reads Makefile.in.
2847 if (! &variable_defined ('distdir'))
2849 if ($relative_dir eq '.')
2851 $output_rules .= "\n" . 'distdir = $(PACKAGE)-$(VERSION)' . "\n";
2855 $output_rules .= ("\n"
2856 . 'distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)'
2860 if ($relative_dir eq '.')
2862 $output_rules .= "top_distdir = \$(distdir)\n";
2864 $output_rules .= "\n";
2866 # Generate 'dist' target, and maybe other dist targets.
2867 if ($relative_dir eq '.')
2869 # Rule to check whether a distribution is viable.
2870 local ($xform) = '';
2872 if (&target_defined ('distcheck-hook'))
2874 $xform .= 's/^DISTHOOK//;';
2878 $xform .= 's/^DISTHOOK.*$//;';
2882 $xform .= 's/^GETTEXT//;';
2886 $xform .= 's/^GETTEXT.*$//;';
2889 $output_rules .= &file_contents_with_transform ($xform, 'dist');
2891 local ($dist_all) = ('dist-all: distdir' . "\n"
2894 foreach $curs ('dist', 'dist-shar', 'dist-zip', 'dist-tarZ',
2897 if (defined $options{$curs} || $curs eq 'dist')
2899 $output_rules .= ($curs . ': distdir' . "\n"
2903 $dist_all .= $dist{$curs};
2906 $output_rules .= $dist_all . $dist_trailer;
2909 # Generate distdir target.
2910 &handle_dist_worker ($makefile);
2913 # A subroutine of handle_dependencies. This function includes
2914 # `depend2' with appropriate transformations.
2919 # First include code for ordinary objects.
2920 local ($key) = $lang . '-autodep';
2921 local ($xform, $ext);
2923 local ($pfx) = $language_map{$key};
2924 local ($fpfx) = ($pfx eq '') ? 'CC' : $pfx;
2925 $xform = ('s/\@PFX\@/' . $pfx . '/g;'
2926 . 's/\@FPFX\@/' . $fpfx . '/g;'
2927 . ($seen_objext ? 's/^OBJEXT//;' : 's/^OBJEXT.*$//;')
2928 . ($seen_libtool ? 's/^LIBTOOL//;' : 's/^LIBTOOL.*$//;'));
2930 # This function can be called even when we don't want dependency
2931 # tracking. This happens when we need an explicit rule for some
2932 # target. In this case we don't want to include the generic code.
2933 if ($use_dependencies)
2935 local ($xform1) = ($xform
2936 . 's/\@BASE\@/\$\*/g;'
2937 . 's/\@SOURCE\@/\$\</g;'
2938 . 's/\@(LT|OBJ)?OBJ\@/\$\@/g;');
2940 foreach $ext (&lang_extensions ($lang))
2942 $output_rules .= (&file_contents_with_transform ('s/\@EXT\@/'
2950 # Now include code for each specially handled object with this
2952 local (@list) = grep ($_ ne '', split (' ', $lang_specific_files{$lang}));
2953 local ($max) = scalar @list;
2955 local ($derived, $source, $obj);
2957 # If dependency tracking is disabled, we just elide the code.
2958 if (! $use_dependencies)
2960 $xform .= 's/\@AMDEP\@.*$//;';
2965 $derived = $list[$i];
2966 ($source = $list[$i + 1]) =~ s,([/\$]),\\$1,g;
2967 ($obj = $list[$i + 2]) =~ s,([/\$]),\\$1,g;
2970 local ($flag) = $language_map{$lang . '-flags'};
2971 local ($val) = "(${derived}_${flag}";
2972 ($rule = $language_map{$lang . '-compile'}) =~
2975 $rule =~ s,([/\$]),\\$1,g;
2977 # Generate a transform which will turn suffix targets in
2978 # depend2.am into real targets for the particular objects we
2981 &file_contents_with_transform ($xform
2982 . 's/\$\(' . $pfx . 'COMPILE\)/'
2984 . 's/\$\(LT' . $pfx . 'COMPILE\)/'
2985 . '\$(LIBTOOL) --mode=compile '
2987 # Generate rule for `.o'.
2989 . $obj . '.o: ' . $source
2991 # Maybe generate rule for `.lo'.
2992 # Might be eliminated by
2994 . 's/^\@EXT\@\.lo:/'
2995 . $obj . '.lo: ' . $source
2997 # Maybe generate rule for `.obj'.
2998 # Might be eliminated by
3000 . 's/^\@EXT\@\.obj:/'
3001 . $obj . '.obj: ' . $source
3003 # Handle source and obj
3005 . 's/\@OBJ\@/' . $obj . '.o/g;'
3006 . 's/\@OBJOBJ\@/' . $obj . '.obj/g;'
3007 . 's/\@LTOBJ\@/' . $obj . '.lo/g;'
3008 . 's/\@BASE\@/' . $obj . '/g;'
3009 . 's/\@SOURCE\@/' . $source . '/g;',
3014 # Handle auto-dependency code.
3015 sub handle_dependencies
3017 if ($use_dependencies)
3019 # Include auto-dep code. Don't include it if DEP_FILES would
3021 if (&saw_sources_p (0) && keys %dep_files)
3023 &require_config_file ($FOREIGN, 'depcomp');
3025 # Set location of depcomp.
3026 if ($config_aux_dir ne '.' && $config_aux_dir ne '')
3028 &define_variable ('depcomp', ('$(SHELL) ' . $config_aux_dir
3033 &define_variable ('depcomp',
3034 '$(SHELL) $(top_srcdir)/depcomp');
3038 local (@deplist) = sort keys %dep_files;
3040 &define_pretty_variable ('DEP_FILES', '', ("\@AMDEP\@", @deplist));
3042 # Generate each `include' individually. Irix 6 make will
3043 # not properly include several files resulting from a
3044 # variable expansion; generating many separate includes
3046 $output_rules .= "\n";
3047 foreach $iter (@deplist)
3049 $output_rules .= "\@AMDEP\@" . 'include ' . $iter . "\n";
3052 $output_rules .= &file_contents ('depend');
3053 push (@clean, 'depend');
3054 &push_phony_cleaners ('depend');
3059 &define_variable ('depcomp', '');
3062 local ($key, $lang, $ext, $xform);
3063 foreach $key (sort keys %language_map)
3065 next unless $key =~ /^(.*)-autodep$/;
3066 next if $language_map{$key} eq 'no';
3071 # Handle subdirectories.
3074 return if ! &variable_defined ('SUBDIRS');
3076 # Make sure each directory mentioned in SUBDIRS actually exists.
3078 foreach $dir (&variable_value_as_list ('SUBDIRS', 'all'))
3080 # Skip directories substituted by configure.
3081 next if $dir =~ /^\@.*\@$/;
3083 if (! -d $am_relative_dir . '/' . $dir)
3085 &am_line_error ('SUBDIRS',
3086 "required directory $am_relative_dir/$dir does not exist");
3090 &am_line_error ('SUBDIRS', "directory should not contain \`/'")
3094 local ($xform) = ('s/\@INSTALLINFO\@/' .
3095 (defined $options{'no-installinfo'}
3096 ? 'install-info-recursive'
3099 $output_rules .= &file_contents_with_transform ($xform, 'subdirs');
3101 # Push a bunch of phony targets.
3103 foreach $phonies ('', '-data', '-exec', 'dirs')
3105 push (@phony, 'install' . $phonies . '-recursive');
3106 push (@phony, 'uninstall' . $phonies . '-recursive');
3108 foreach $phonies ('all', 'check', 'installcheck', 'info', 'dvi')
3110 push (@phony, $phonies . '-recursive');
3112 &push_phony_cleaners ('recursive');
3114 $recursive_install = 1;
3117 # Handle aclocal.m4.
3118 sub handle_aclocal_m4
3120 local ($regen_aclocal) = 0;
3121 if (-f 'aclocal.m4')
3123 &define_variable ("ACLOCAL_M4", '$(top_srcdir)/aclocal.m4');
3124 &push_dist_common ('aclocal.m4');
3126 if (open (ACLOCAL, '< aclocal.m4'))
3132 if ($line =~ 'generated automatically by aclocal')
3139 local ($acinclude) = 0;
3140 if (-f 'acinclude.m4')
3146 # Note that it might be possible that aclocal.m4 doesn't exist but
3147 # should be auto-generated. This case probably isn't very
3151 local (@ac_deps) = (
3153 ? "\@MAINTAINER_MODE_TRUE\@"
3156 ($acinclude ? ' acinclude.m4' : '')
3159 # Scan all -I directories for m4 files. These are our
3161 if (&variable_defined ('ACLOCAL_AMFLAGS'))
3163 local ($examine_next, $amdir) = 0;
3164 foreach $amdir (&variable_value_as_list ('ACLOCAL_AMFLAGS', ''))
3169 if ($amdir !~ /^\// && -d $amdir)
3171 push (@ac_deps, &my_glob ($amdir . '/*.m4'));
3174 elsif ($amdir eq '-I')
3181 &pretty_print_rule ("\$(ACLOCAL_M4):", "\t\t", @ac_deps);
3183 $output_rules .= ("\t"
3184 . 'cd $(srcdir) && $(ACLOCAL)'
3185 . (&variable_defined ('ACLOCAL_AMFLAGS')
3186 ? ' $(ACLOCAL_AMFLAGS)' : '')
3191 # Rewrite a list of input files into a form suitable to put on a
3192 # dependency list. The idea is that if an input file has a directory
3193 # part the same as the current directory, then the directory part is
3194 # simply removed. But if the directory part is different, then
3195 # $(top_srcdir) is prepended. Among other things, this is used to
3196 # generate the dependency list for the output files generated by
3197 # AC_OUTPUT. Consider what the dependencies should look like in this
3199 # AC_OUTPUT(src/out:src/in1:lib/in2)
3200 # The first argument, ADD_SRCDIR, is 1 if $(top_srcdir) should be added.
3201 # If 0 then files that require this addition will simply be ignored.
3202 sub rewrite_inputs_into_dependencies
3204 local ($add_srcdir, @inputs) = @_;
3205 local ($single, @newinputs);
3207 foreach $single (@inputs)
3209 if (&dirname ($single) eq $relative_dir)
3211 push (@newinputs, &basename ($single));
3215 push (@newinputs, '$(top_srcdir)/' . $single);
3222 # Handle remaking and configure stuff.
3223 # We need the name of the input file, to do proper remaking rules.
3224 sub handle_configure
3226 local ($local, $input, @secondary_inputs) = @_;
3228 local ($top_reldir);
3230 local ($input_base) = &basename ($input);
3231 local ($local_base) = &basename ($local);
3233 local ($amfile) = $input_base . '.am';
3234 # We know we can always add '.in' because it really should be an
3235 # error if the .in was missing originally.
3236 local ($infile) = '$(srcdir)/' . $input_base . '.in';
3237 local ($colon_infile);
3238 if ($local ne $input || @secondary_inputs)
3240 $colon_infile = ':' . $input . '.in';
3242 $colon_infile .= ':' . join (':', @secondary_inputs)
3243 if @secondary_inputs;
3245 local (@rewritten) = &rewrite_inputs_into_dependencies (1,
3248 # This rule remakes the Makefile.in. Note use of
3249 # @MAINTAINER_MODE_TRUE@ forces us to abandon pretty-printing.
3251 $output_rules .= ($infile
3252 # NOTE perl 5.003 (with -w) gives a
3253 # uninitialized value error on the next line.
3256 . ($seen_maint_mode ? "\@MAINTAINER_MODE_TRUE\@ " : '')
3258 . '$(top_srcdir)/configure.in $(ACLOCAL_M4)'
3259 . ' ' . join (' ', @include_stack)
3261 . "\tcd \$(top_srcdir) && \$(AUTOMAKE) "
3262 . ($cygnus_mode ? '--cygnus' : ('--' . $strictness_name))
3263 . ($cmdline_use_dependencies ? '' : ' --ignore-deps')
3264 . ' ' . $input . $colon_infile . "\n\n");
3266 # This rule remakes the Makefile.
3267 $output_rules .= ($local_base
3268 # NOTE: bogus uninit value error on next line;
3269 # see comment above.
3272 . join (' ', @rewritten)
3273 . ' $(top_builddir)/config.status'
3275 . "\tcd \$(top_builddir) \\\n"
3276 . "\t && CONFIG_FILES="
3277 . (($relative_dir eq '.') ? '$@' : '$(subdir)/$@')
3279 . ' CONFIG_HEADERS= $(SHELL) ./config.status'
3282 if ($relative_dir ne '.')
3285 $top_reldir = '../';
3290 $output_rules .= &file_contents ('remake');
3291 &examine_variable ('CONFIG_STATUS_DEPENDENCIES');
3292 &examine_variable ('CONFIGURE_DEPENDENCIES');
3295 &push_dist_common ('acconfig.h')
3299 # If we have a configure header, require it.
3301 local (@local_fullnames) = @config_fullnames;
3302 local (@local_names) = @config_names;
3303 local ($hdr_index) = 0;
3304 local ($distclean_config) = '';
3305 foreach $one_hdr (@config_headers)
3307 local ($one_fullname) = shift (@local_fullnames);
3308 local ($one_name) = shift (@local_names);
3310 local ($header_dir) = &dirname ($one_name);
3312 # If the header is in the current directory we want to build
3313 # the header here. Otherwise, if we're at the topmost
3314 # directory and the header's directory doesn't have a
3315 # Makefile, then we also want to build the header.
3316 if ($relative_dir eq $header_dir
3317 || ($relative_dir eq '.' && ! &is_make_dir ($header_dir)))
3319 local ($ch_sans_dir, $cn_sans_dir, $stamp_dir);
3320 if ($relative_dir eq $header_dir)
3322 $cn_sans_dir = &basename ($one_name);
3327 $cn_sans_dir = $one_name;
3328 if ($header_dir eq '.')
3334 $stamp_dir = $header_dir . '/';
3338 # Compute relative path from directory holding output
3339 # header to directory holding input header. FIXME:
3340 # doesn't handle case where we have multiple inputs.
3341 if (&dirname ($one_hdr) eq $relative_dir)
3343 $ch_sans_dir = &basename ($one_hdr);
3347 local (@rel_out_path);
3348 # FIXME this chunk of code should be its own sub.
3349 # It is used elsewhere.
3350 foreach (split (/\//, $relative_dir))
3352 next if $_ eq '' || $_ eq '.';
3355 # FIXME: actually this is an error.
3360 push (@rel_out_path, '..');
3365 $ch_sans_dir = join ('/', @rel_out_path) . '/' . $one_hdr;
3369 $ch_sans_dir = $one_hdr;
3373 &require_file_with_conf_line ($config_header_line,
3374 $FOREIGN, $ch_sans_dir);
3376 # Header defined and in this directory.
3378 if (-f $one_name . '.top')
3380 push (@files, "${cn_sans_dir}.top");
3382 if (-f $one_name . '.bot')
3384 push (@files, "${cn_sans_dir}.bot");
3387 &push_dist_common (@files);
3389 # For now, acconfig.h can only appear in the top srcdir.
3390 if (-f 'acconfig.h')
3392 if ($relative_dir eq '.')
3394 push (@files, 'acconfig.h');
3398 # Strange quoting because this gets fed through
3400 push (@files, '\$(top_srcdir)/acconfig.h');
3404 local ($stamp_name) = 'stamp-h';
3405 $stamp_name .= "${hdr_index}" if scalar (@config_headers) > 1;
3407 local ($xform) = '';
3409 $xform = 's,\@FILES\@,' . join (' ', @files) . ',;';
3410 $xform .= 's,\@CONFIG_HEADER\@,' . "${cn_sans_dir}" . ',;';
3411 $xform .= 's,\@CONFIG_HEADER_IN\@,' . "${ch_sans_dir}" . ',;';
3412 $xform .= 's,\@CONFIG_HEADER_FULL\@,' . "${one_fullname}" . ',;';
3413 $xform .= 's,\@STAMP\@,' . "${stamp_dir}${stamp_name}" . ',g;';
3415 local ($out_dir) = &dirname ($ch_sans_dir);
3416 $xform .= 's,\@SRC_STAMP\@,' . "${out_dir}/${stamp_name}" . ',g;';
3417 $output_rules .= &file_contents_with_transform ($xform,
3420 &create ("${relative_dir}/${out_dir}/${stamp_name}.in");
3421 &require_file_with_conf_line ($config_header_line, $FOREIGN,
3422 "${out_dir}/${stamp_name}.in");
3424 $distclean_config .= ' ' if $distclean_config;
3425 $distclean_config .= $cn_sans_dir;
3429 if ($distclean_config)
3431 $output_rules .= &file_contents_with_transform ('s,\@FILES\@,'
3435 push (@clean, 'hdr');
3436 &push_phony_cleaners ('hdr');
3439 # Set location of mkinstalldirs.
3440 if ($config_aux_dir ne '.' && $config_aux_dir ne '')
3442 &define_variable ('mkinstalldirs', ('$(SHELL) ' . $config_aux_dir
3443 . '/mkinstalldirs'));
3447 &define_variable ('mkinstalldirs',
3448 '$(SHELL) $(top_srcdir)/mkinstalldirs');
3451 &am_line_error ('CONFIG_HEADER',
3452 "\`CONFIG_HEADER' is an anachronism; now determined from \`configure.in'")
3453 if &variable_defined ('CONFIG_HEADER');
3456 local ($config_header) = '';
3457 foreach $one_name (@config_names)
3459 # Generate CONFIG_HEADER define.
3461 if ($relative_dir eq &dirname ($one_name))
3463 $one_hdr = &basename ($one_name);
3467 $one_hdr = "${top_builddir}/${one_name}";
3470 $config_header .= ' ' if $config_header;
3471 $config_header .= $one_hdr;
3475 &define_variable ("CONFIG_HEADER", $config_header);
3478 # Now look for other files in this directory which must be remade
3479 # by config.status, and generate rules for them.
3480 local (@actual_other_files) = ();
3481 local ($file, $local);
3482 local (@inputs, @rewritten_inputs, $single);
3483 local ($need_rewritten);
3484 foreach $file (@other_input_files)
3486 if ($file =~ /^([^:]*):(.*)$/)
3488 # This is the ":" syntax of AC_OUTPUT.
3490 $local = &basename ($file);
3491 @inputs = split (':', $2);
3492 @rewritten_inputs = &rewrite_inputs_into_dependencies (1, @inputs);
3493 $need_rewritten = 1;
3498 $local = &basename ($file);
3499 @inputs = ($local . '.in');
3501 &rewrite_inputs_into_dependencies (1, $file . '.in');
3502 $need_rewritten = 0;
3505 # Skip files not in this directory.
3506 next unless &dirname ($file) eq $relative_dir;
3508 # Skip any file that is an automake input.
3509 next if -f $file . '.am';
3511 # Some users have been tempted to put `stamp-h' in the
3512 # AC_OUTPUT line. This won't do the right thing, so we
3513 # explicitly fail here.
3514 if ($local eq 'stamp-h')
3516 # FIXME: allow real filename.
3517 &am_conf_error ('configure.in', $ac_output_line,
3518 'stamp-h should not appear in AC_OUTPUT');
3522 $output_rules .= ($local . ': '
3523 . '$(top_builddir)/config.status '
3524 . join (' ', @rewritten_inputs) . "\n"
3526 . 'cd $(top_builddir) && CONFIG_FILES='
3527 . ($relative_dir eq '.' ? '' : '$(subdir)/')
3528 . '$@' . ($need_rewritten
3529 ? (':' . join (':', @inputs))
3531 . ' CONFIG_HEADERS= $(SHELL) ./config.status'
3533 &push_dist_common (@inputs);
3534 push (@actual_other_files, $local);
3536 # Require all input files.
3537 &require_file_with_conf_line ($ac_output_line, $FOREIGN,
3538 &rewrite_inputs_into_dependencies (0, @inputs));
3541 # These files get removed by "make clean".
3542 &define_pretty_variable ('CONFIG_CLEAN_FILES', '', @actual_other_files);
3549 @r = &am_install_var ('-defaultdist', 'header', 'HEADERS', 'include',
3550 'oldinclude', 'pkginclude',
3554 next unless /\.(.*)$/;
3555 &saw_extension ($1);
3561 return if ! $seen_gettext || $relative_dir ne '.';
3563 if (! &variable_defined ('SUBDIRS'))
3566 ("AM_GNU_GETTEXT in configure.in but SUBDIRS not defined");
3570 &require_file_with_conf_line ($ac_gettext_line, $GNU, 'ABOUT-NLS');
3572 if (&variable_defined ('SUBDIRS'))
3576 "AM_GNU_GETTEXT in configure.in but \`po' not in SUBDIRS")
3577 if $contents{'SUBDIRS'} !~ /\bpo\b/;
3580 "AM_GNU_GETTEXT in configure.in but \`intl' not in SUBDIRS")
3581 if $contents{'SUBDIRS'} !~ /\bintl\b/;
3584 # Ensure that each language in ALL_LINGUAS has a .po file, and
3585 # each po file is mentioned in ALL_LINGUAS.
3588 local (%linguas) = ();
3589 grep ($linguas{$_} = 1, split (' ', $all_linguas));
3596 &am_line_error ($all_linguas_line,
3597 ("po/$_.po exists but \`$_' not in \`ALL_LINGUAS'"))
3601 foreach (keys %linguas)
3603 &am_line_error ($all_linguas_line,
3604 "$_ in \`ALL_LINGUAS' but po/$_.po does not exist")
3610 &am_error ("AM_GNU_GETTEXT in configure.in but \`ALL_LINGUAS' not defined");
3614 # Handle footer elements.
3617 if ($contents{'SOURCES'})
3619 # NOTE don't use define_pretty_variable here, because
3620 # $contents{...} is already defined.
3621 $output_vars .= 'SOURCES = ' . $contents{'SOURCES'} . "\n";
3623 if ($contents{'OBJECTS'})
3625 # NOTE don't use define_pretty_variable here, because
3626 # $contents{...} is already defined.
3627 $output_vars .= 'OBJECTS = ' . $contents{'OBJECTS'} . "\n";
3629 if ($contents{'SOURCES'} || $contents{'OBJECTS'})
3631 $output_vars .= "\n";
3634 if (&variable_defined ('SUFFIXES'))
3636 # Push actual suffixes, and not $(SUFFIXES). Some versions of
3637 # make do not like variable substitutions on the .SUFFIXES
3639 push (@suffixes, &variable_value_as_list ('SUFFIXES', ''));
3641 if (&target_defined ('.SUFFIXES'))
3643 &am_line_error ('.SUFFIXES',
3644 "use variable \`SUFFIXES', not target \`.SUFFIXES'");
3647 # Note: AIX 4.1 /bin/make will fail if any suffix rule appears
3648 # before .SUFFIXES. So we make sure that .SUFFIXES appears before
3649 # anything else, by sticking it right after the default: target.
3650 $output_header .= ".SUFFIXES:\n";
3653 # Make sure suffixes has unique elements. Sort them to ensure
3654 # the output remains consistent.
3657 grep ($suffixes{$_} = 1, @suffixes);
3659 $output_header .= (".SUFFIXES: "
3660 . join (' ', sort keys %suffixes)
3663 $output_trailer .= &file_contents ('footer');
3666 # Deal with installdirs target.
3667 sub handle_installdirs
3669 # GNU Makefile standards recommend this.
3670 if ($recursive_install)
3672 # We create a separate `-am' target so that the -recursive
3673 # rule will work correctly.
3674 $output_rules .= ("installdirs: installdirs-recursive\n"
3675 . "installdirs-am:\n");
3676 push (@phony, 'installdirs-am');
3680 $output_rules .= "installdirs:\n";
3682 push (@phony, 'installdirs');
3685 &pretty_print_rule ("\t" . '$(mkinstalldirs) ', "\t\t",
3688 $output_rules .= "\n";
3691 # There are several targets which need to be merged. This is because
3692 # their complete definition is compiled from many parts. Note that we
3693 # avoid double colon rules, otherwise we'd use them instead.
3694 sub handle_merge_targets
3696 local ($makefile) = @_;
3698 # There are a few install-related variables that you should not define.
3700 foreach $var ('PRE_INSTALL', 'POST_INSTALL', 'NORMAL_INSTALL')
3702 if (&variable_defined ($var))
3704 &am_line_error ($var, "\`$var' should not be defined");
3708 # Put this at the beginning for the sake of non-GNU makes. This
3709 # is still wrong if these makes can run parallel jobs. But it is
3711 unshift (@all, &basename ($makefile));
3714 foreach $one_name (@config_names)
3716 push (@all, &basename ($one_name))
3717 if &dirname ($one_name) eq $relative_dir;
3720 &do_one_merge_target ('info', @info);
3721 &do_one_merge_target ('dvi', @dvi);
3722 &do_check_merge_target;
3723 &do_one_merge_target ('installcheck', @installcheck);
3725 if (defined $options{'no-installinfo'})
3727 &do_one_merge_target ('install-info', '');
3729 elsif (&target_defined ('install-info-local'))
3731 &am_line_error ('install-info-local',
3732 "\`install-info-local' target defined but \`no-installinfo' option not in use");
3736 foreach $utarg ('uninstall-data-local', 'uninstall-data-hook',
3737 'uninstall-exec-local', 'uninstall-exec-hook')
3739 if (&target_defined ($utarg))
3742 ($x = $utarg) =~ s/(data|exec)-//;
3743 &am_line_error ($utarg, "use \`$x', not \`$utarg'");
3747 if (&target_defined ('install-local'))
3749 &am_line_error ('install-local',
3750 "use \`install-data-local' or \`install-exec-local', not \`install-local'");
3756 local ($local_headers) = '';
3757 foreach $one_name (@config_names)
3759 if (&dirname ($one_name) eq $relative_dir)
3761 $local_headers .= ' ' if $local_headers;
3762 $local_headers .= &basename ($one_name);
3767 # This is kind of a hack, but I couldn't see a better way
3768 # to handle it. In this particular case, we need to make
3769 # sure config.h is built before we recurse. We can't do
3770 # this by changing the order of dependencies to the "all"
3771 # because that breaks when using parallel makes. Instead
3772 # we handle things explicitly.
3773 $output_rules .= ("all-recursive-am: ${local_headers}"
3775 . '$(MAKE) $(AM_MAKEFLAGS)'
3778 $all_target = 'all-recursive-am';
3779 push (@phony, 'all-recursive-am');
3783 # Print definitions users can use.
3784 &do_one_merge_target ('install-exec', @install_exec);
3785 $output_rules .= "\n";
3787 &do_one_merge_target ('install-data', @install_data);
3788 $output_rules .= "\n";
3790 &do_one_merge_target ('install', 'all-am');
3791 &do_one_merge_target ('uninstall', @uninstall);
3793 &do_one_merge_target ('all', @all);
3795 # Generate the new 'install-strip' target. We can't just set
3796 # INSTALL_PROGRAM because that might be a relative path.
3797 $output_rules .= ("install-strip:\n\t"
3798 . '$(MAKE) $(AM_MAKEFLAGS) INSTALL_STRIP_FLAG=-s install'
3800 push (@phony, 'install-strip');
3803 # Helper for handle_merge_targets. Note that handle_merge_targets
3804 # relies on the fact that this doesn't add an extra \n at the end.
3805 sub do_one_merge_target
3807 local ($name, @values) = @_;
3809 if (&target_defined ($name . '-local'))
3811 # User defined local form of target. So include it.
3812 push (@values, $name . '-local');
3813 push (@phony, $name . '-local');
3816 &pretty_print_rule ($name . "-am:", "\t\t", @values);
3817 if ($name eq 'install')
3819 # Special-case `install-am' to run install-exec-am and
3820 # install-data-am after all-am is built.
3821 &pretty_print_rule ("\t\@\$(MAKE) \$(AM_MAKEFLAGS)", "\t ",
3822 'install-exec-am', 'install-data-am');
3824 elsif ($name eq 'install-exec' && &target_defined ('install-exec-hook'))
3826 $output_rules .= ("\t\@\$(NORMAL_INSTALL)\n"
3827 . "\t" . '$(MAKE) $(AM_MAKEFLAGS) install-exec-hook'
3830 elsif ($name eq 'install-data' && &target_defined ('install-data-hook'))
3832 $output_rules .= ("\t\@\$(NORMAL_INSTALL)\n"
3833 . "\t" . '$(MAKE) $(AM_MAKEFLAGS) install-data-hook'
3837 local ($lname) = $name . ($recursive_install ? '-recursive' : '-am');
3838 local ($tname) = $name;
3839 # To understand this special case, see handle_merge_targets.
3842 $tname = 'all-redirect';
3843 $lname = $all_target if $recursive_install;
3844 push (@phony, 'all-redirect');
3845 $output_all = "all: all-redirect\n";
3847 &pretty_print_rule ($tname . ":", "\t\t", $lname);
3848 push (@phony, $name . '-am', $name);
3851 # Handle check merge target specially.
3852 sub do_check_merge_target
3854 if (&target_defined ('check-local'))
3856 # User defined local form of target. So include it.
3857 push (@check_tests, 'check-local');
3858 push (@phony, 'check-local');
3861 # In --cygnus mode, check doesn't depend on all.
3864 # Just run the local check rules.
3865 &pretty_print_rule ('check-am:', "\t\t", @check);
3869 # The check target must depend on the local equivalent of
3870 # `all', to ensure all the primary targets are built. Then it
3871 # must build the local check rules.
3872 $output_rules .= "check-am: all-am\n";
3873 &pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ",
3877 &pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ",
3881 push (@phony, 'check', 'check-am');
3882 $output_rules .= ("check: "
3883 . ($recursive_install ? 'check-recursive' : 'check-am')
3887 # Handle all 'clean' targets.
3890 local ($xform) = '';
3893 # Don't include `MAINTAINER'; it is handled specially below.
3894 foreach $name ('MOSTLY', '', 'DIST')
3896 if (! &variable_defined ($name . 'CLEANFILES'))
3898 $xform .= 's/^' . $name . 'CLEAN.*$//;';
3902 $xform .= 's/^' . $name . 'CLEAN//;';
3906 # Built sources are automatically removed by maintainer-clean.
3907 push (@maintainer_clean_files, '\$(BUILT_SOURCES)')
3908 if &variable_defined ('BUILT_SOURCES');
3909 push (@maintainer_clean_files, '\$(MAINTAINERCLEANFILES)')
3910 if &variable_defined ('MAINTAINERCLEANFILES');
3911 if (! @maintainer_clean_files)
3913 $xform .= 's/^MAINTAINERCLEAN.*$//;';
3917 $xform .= ('s/^MAINTAINERCLEAN//;'
3918 # Join with no space to avoid spurious `test -z'
3919 # success at runtime.
3920 . 's,\@MCFILES\@,' . join ('', @maintainer_clean_files)
3922 # A space is required in the join here.
3923 . 's,\@MFILES\@,' . join (' ', @maintainer_clean_files)
3927 $output_rules .= &file_contents_with_transform ($xform, 'clean');
3929 push (@clean, 'generic');
3930 &push_phony_cleaners ('generic');
3932 &do_one_clean_target ('clean', 'mostly', '', @clean);
3933 &do_one_clean_target ('clean', '', 'mostly', @clean);
3934 &do_one_clean_target ('clean', 'dist', '', @clean);
3935 &do_one_clean_target ('clean', 'maintainer-', 'dist', @clean);
3937 push (@phony, 'clean', 'mostlyclean', 'distclean', 'maintainer-clean');
3940 # Helper for handle_clean.
3941 sub do_one_clean_target
3943 local ($target, $name, $last_name, @deps) = @_;
3945 # Change each dependency `BLARG' into `clean-BLARG'.
3946 grep (($_ = $name . 'clean-' . $_) && 0, @deps);
3948 # Push the previous clean target. There is no previous clean
3949 # target if we're doing mostlyclean.
3950 push (@deps, $last_name . $target . '-am')
3951 unless $name eq 'mostly';
3953 # If a -local version of the rule is given, add it to the list.
3954 if (&target_defined ($name . $target . '-local'))
3956 push (@deps, $name . $target . '-local');
3959 # Print the target and the dependencies.
3960 &pretty_print_rule ($name . $target . "-am: ", "\t\t", @deps);
3962 # FIXME: shouldn't we really print these messages before running
3964 if ($name . $target eq 'maintainer-clean')
3966 # Print a special warning.
3968 ("\t\@echo \"This command is intended for maintainers to use;\"\n"
3969 . "\t\@echo \"it deletes files that may require special "
3970 . "tools to rebuild.\"\n");
3972 elsif ($name . $target eq 'distclean')
3974 $output_rules .= "\t-rm -f libtool\n" if $seen_libtool;
3976 $output_rules .= "\n";
3978 # Now generate the actual clean target.
3979 $output_rules .= ($name . $target . ": " . $name . $target
3980 . ($recursive_install ? '-recursive' : '-am')
3983 # We special-case config.status here. If we do it as part of the
3984 # normal clean processing for this directory, then it might be
3985 # removed before some subdir is cleaned. However, that subdir's
3986 # Makefile depends on config.status.
3987 if (($name . $target eq 'maintainer-clean'
3988 || $name . $target eq 'distclean')
3989 && $relative_dir eq '.')
3991 $output_rules .= "\t-rm -f config.status\n";
3993 $output_rules .= "\n";
3996 # Handle .PHONY target.
3999 &pretty_print_rule ('.PHONY:', "", @phony);
4000 $output_rules .= "\n";
4003 # Handle TESTS variable and other checks.
4006 if (defined $options{'dejagnu'})
4008 push (@check_tests, 'check-DEJAGNU');
4009 push (@phony, 'check-DEJAGNU');
4014 $xform = 's/^CYGNUS//;';
4018 $xform = 's/^CYGNUS.*$//;';
4020 $output_rules .= &file_contents_with_transform ($xform, 'dejagnu');
4022 # In Cygnus mode, these are found in the build tree.
4023 # Otherwise they are looked for in $PATH.
4024 &define_program_variable ('EXPECT', 'build', 'expect', 'expect');
4025 &define_program_variable ('RUNTEST', 'src', 'dejagnu', 'runtest');
4027 # Only create site.exp rule if user hasn't already written
4029 if (! &target_defined ('site.exp'))
4031 # Note that in the rule we don't directly generate
4032 # site.exp to avoid the possibility of a corrupted
4033 # site.exp if make is interrupted. Jim Meyering has some
4034 # useful text on this topic.
4035 $output_rules .= ("site.exp: Makefile\n"
4036 . "\t\@echo 'Making a new site.exp file...'\n"
4037 . "\t\@test ! -f site.bak || rm -f site.bak\n"
4038 . "\t\@echo '## these variables are automatically generated by make ##' > \$\@-t\n"
4039 . "\t\@echo '# Do not edit here. If you wish to override these values' >> \$\@-t\n"
4040 . "\t\@echo '# edit the last section' >> \$\@-t\n"
4041 . "\t\@echo 'set tool \$(DEJATOOL)' >> \$\@-t\n"
4042 . "\t\@echo 'set srcdir \$(srcdir)' >> \$\@-t\n"
4043 . "\t\@echo 'set objdir' \`pwd\` >> \$\@-t\n");
4045 # Extra stuff for AC_CANONICAL_*
4046 local (@whatlist) = ();
4047 if ($seen_canonical)
4049 push (@whatlist, 'host');
4052 # Extra stuff only for AC_CANONICAL_SYSTEM.
4053 if ($seen_canonical == $AC_CANONICAL_SYSTEM)
4055 push (@whatlist, 'target', 'build');
4059 foreach $c1 (@whatlist)
4061 foreach $c2 ('alias', 'triplet')
4063 $output_rules .= "\t\@echo 'set ${c1}_${c2} \$(${c1}_${c2})' >> \$\@-t\n";
4067 $output_rules .= ("\t\@echo '## All variables above are generated by configure. Do Not Edit ##' >> \$\@-t\n"
4068 . "\t\@test ! -f site.exp || sed '1,/^## All variables above are.*##/ d' site.exp >> \$\@-t\n"
4069 . "\t\@test ! -f site.exp || mv site.exp site.bak\n"
4070 . "\t\@mv \$\@-t site.exp\n");
4076 foreach $c ('DEJATOOL', 'RUNTEST', 'RUNTESTFLAGS')
4078 if (&variable_defined ($c))
4080 &am_line_error ($c, "\`$c' defined but \`dejagnu' not in \`AUTOMAKE_OPTIONS'");
4085 if (&variable_defined ('TESTS'))
4087 push (@check_tests, 'check-TESTS');
4088 push (@phony, 'check-TESTS');
4090 # Note: Solaris 2.7 seems to expand TESTS using VPATH. That's
4091 # why we also try `dir='
4092 $output_rules .= 'check-TESTS: $(TESTS)
4093 @failed=0; all=0; xfail=0; xpass=0; \\
4094 srcdir=$(srcdir); export srcdir; \\
4095 for tst in $(TESTS); do \\
4096 if test -f ./$$tst; then dir=./; \\
4097 elif test -f $$tst; then dir=; \\
4098 else dir="$(srcdir)/"; fi; \\
4099 if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \\
4100 all=`expr $$all + 1`; \\
4101 case " $(XFAIL_TESTS) " in \\
4103 xpass=`expr $$xpass + 1`; \\
4104 failed=`expr $$failed + 1`; \\
4105 echo "XPASS: $$tst"; \\
4108 echo "PASS: $$tst"; \\
4111 elif test $$? -ne 77; then \\
4112 all=`expr $$all + 1`; \\
4113 case " $(XFAIL_TESTS) " in \\
4115 xfail=`expr $$xfail + 1`; \\
4116 echo "XFAIL: $$tst"; \\
4119 failed=`expr $$failed + 1`; \\
4120 echo "FAIL: $$tst"; \\
4125 if test "$$failed" -eq 0; then \\
4126 if test "$$xfail" -eq 0; then \\
4127 banner="All $$all tests passed"; \\
4129 banner="All $$all tests behaved as expected ($$xfail expected failures)"; \\
4132 if test "$$xpass" -eq 0; then \\
4133 banner="$$failed of $$all tests failed"; \\
4135 banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \\
4138 dashes=`echo "$$banner" | sed s/./=/g`; \\
4142 test "$$failed" -eq 0
4147 # Handle Emacs Lisp.
4148 sub handle_emacs_lisp
4150 local (@elfiles) = &am_install_var ('-candist', 'lisp', 'LISP',
4156 &define_configure_variable ('lispdir');
4157 &define_configure_variable ('EMACS');
4158 $output_rules .= (".el.elc:\n"
4159 . "\t\@echo 'WARNING: Warnings can be ignored. :-)'\n"
4160 . "\tif test \$(EMACS) != no; then \\\n"
4161 . "\t EMACS=\$(EMACS) \$(SHELL) \$(srcdir)/elisp-comp \$<; \\\n"
4163 push (@suffixes, '.el', '.elc');
4165 # Generate .elc files.
4166 grep ($_ .= 'c', @elfiles);
4167 &define_pretty_variable ('ELCFILES', '', @elfiles);
4169 $output_rules .= &file_contents ('lisp-clean');
4170 push (@clean, 'lisp');
4171 &push_phony_cleaners ('lisp');
4173 push (@all, '$(ELCFILES)');
4176 if (&variable_defined ('lisp_LISP'))
4178 $varname = 'lisp_LISP';
4179 &am_error ("\`lisp_LISP' defined but \`AM_PATH_LISPDIR' not in \`configure.in'")
4184 $varname = 'noinst_LISP';
4187 &require_file_with_line ($varname, $FOREIGN, 'elisp-comp');
4194 local (@pyfiles) = &am_install_var ('-defaultdist', 'python', 'PYTHON',
4195 'python', 'noinst');
4196 return if ! @pyfiles;
4198 # Found some python.
4199 &define_configure_variable ('pythondir');
4200 &define_configure_variable ('PYTHON');
4202 $output_rules .= &file_contents ('python-clean');
4203 push (@clean, 'python');
4205 &am_error ("\`python_PYTHON' defined but \`AM_CHECK_PYTHON' not in \`configure.in'")
4206 if ! $seen_pythondir && &variable_defined ('python_PYTHON');
4208 if ($config_aux_dir eq '.' || $config_aux_dir eq '')
4210 &define_variable ('py_compile', '$(top_srcdir)/py-compile');
4214 &define_variable ('py_compile', $config_aux_dir . '/py-compile');
4221 local (@sourcelist) = &am_install_var ('-candist', '-clean',
4223 'java', 'noinst', 'check');
4224 return if ! @sourcelist;
4226 &define_variable ('JAVAC', 'javac');
4227 &define_variable ('JAVACFLAGS', '');
4228 &define_variable ('CLASSPATH_ENV',
4229 'CLASSPATH=$(JAVAROOT):$(srcdir)/$(JAVAROOT):$$CLASSPATH');
4230 &define_variable ('JAVAROOT', '$(top_builddir)');
4232 local (%valid) = &am_primary_prefixes ('JAVA', 1,
4233 'java', 'noinst', 'check');
4235 local ($dir, $curs);
4236 foreach $curs (keys %valid)
4238 if (! &variable_defined ($curs . '_JAVA') || $curs eq 'noinst'
4239 || $curs eq 'EXTRA')
4246 &am_line_error ($curs . '_JAVA',
4247 "multiple _JAVA primaries in use");
4252 $output_rules .= ('class' . $dir . '.stamp: $(' . $dir . '_JAVA)' . "\n"
4253 . "\t" . '$(CLASSPATH_ENV) $(JAVAC) -d $(JAVAROOT) '
4254 . '$(JAVACFLAGS) $?' . "\n"
4255 . "\t" . 'echo timestamp > class' . $dir . '.stamp'
4257 push (@all, 'class' . $dir . '.stamp');
4258 &push_dist_common ('$(' . $dir . '_JAVA)');
4261 # Handle some of the minor options.
4262 sub handle_minor_options
4264 if (defined $options{'readme-alpha'})
4266 if ($relative_dir eq '.')
4268 if ($package_version !~ /^$GNITS_VERSION_PATTERN$/)
4270 # FIXME: allow real filename.
4271 &am_conf_line_error ('configure.in',
4272 $package_version_line,
4273 "version \`$package_version' doesn't follow Gnits standards");
4275 elsif (defined $1 && -f 'README-alpha')
4277 # This means we have an alpha release. See
4278 # GNITS_VERSION_PATTERN for details.
4279 &require_file ($FOREIGN, 'README-alpha');
4285 ################################################################
4287 # Scan one file for interesting things. Subroutine of scan_configure.
4288 sub scan_one_configure_file
4290 local ($filename) = @_;
4293 open (CONFIGURE, $filename)
4294 || die "automake: couldn't open \`$filename': $!\n";
4295 print "automake: reading $filename\n" if $verbose;
4299 # Remove comments from current line.
4303 # Skip macro definitions. Otherwise we might be confused into
4304 # thinking that a macro that was only defined was actually
4308 # Follow includes. This is a weirdness commonly in use at
4309 # Cygnus and hopefully nowhere else.
4310 if (/sinclude\((.*)\)/ && -f $1)
4312 &scan_one_configure_file ($1);
4315 # Populate libobjs array.
4316 if (/AC_FUNC_ALLOCA/)
4318 $libsources{'alloca.c'} = 1;
4320 elsif (/AC_FUNC_GETLOADAVG/)
4322 $libsources{'getloadavg.c'} = 1;
4324 elsif (/AC_FUNC_MEMCMP/)
4326 $libsources{'memcmp.c'} = 1;
4328 elsif (/AC_STRUCT_ST_BLOCKS/)
4330 $libsources{'fileblocks.c'} = 1;
4332 elsif (/A[CM]_REPLACE_GNU_GETOPT/)
4334 $libsources{'getopt.c'} = 1;
4335 $libsources{'getopt1.c'} = 1;
4337 elsif (/AM_FUNC_STRTOD/)
4339 $libsources{'strtod.c'} = 1;
4341 elsif (/AM_WITH_REGEX/)
4343 $libsources{'rx.c'} = 1;
4344 $libsources{'rx.h'} = 1;
4345 $libsources{'regex.c'} = 1;
4346 $libsources{'regex.h'} = 1;
4347 $omit_dependencies{'rx.h'} = 1;
4348 $omit_dependencies{'regex.h'} = 1;
4350 elsif (/AC_FUNC_MKTIME/)
4352 $libsources{'mktime.c'} = 1;
4354 elsif (/AM_FUNC_ERROR_AT_LINE/)
4356 $libsources{'error.c'} = 1;
4357 $libsources{'error.h'} = 1;
4359 elsif (/AM_FUNC_OBSTACK/)
4361 $libsources{'obstack.c'} = 1;
4362 $libsources{'obstack.h'} = 1;
4364 elsif (/LIBOBJS="(.*)\s+\$LIBOBJS"/
4365 || /LIBOBJS="\$LIBOBJS\s+(.*)"/)
4367 foreach $libobj_iter (split (' ', $1))
4369 if ($libobj_iter =~ /^(.*)\.o(bj)?$/
4370 || $libobj_iter =~ /^(.*)\.\$ac_objext$/
4371 || $libobj_iter =~ /^(.*)\.\$\{ac_objext\}$/)
4373 $libsources{$1 . '.c'} = 1;
4378 if (! $in_ac_replace && s/AC_REPLACE_FUNCS\s*\(\[?//)
4384 $in_ac_replace = 0 if s/[\]\)].*$//;
4385 # Remove trailing backslash.
4389 # Need to skip empty elements for Perl 4.
4391 $libsources{$_ . '.c'} = 1;
4395 if (/$obsolete_rx/o)
4398 if ($obsolete_macros{$1} ne '')
4400 $hint = '; ' . $obsolete_macros{$1};
4402 &am_conf_line_error ($filename, $., "\`$1' is obsolete$hint");
4405 # Process the AC_OUTPUT macro.
4406 if (! $in_ac_output && s/AC_OUTPUT\s*\(\[?//)
4409 $ac_output_line = $.;
4413 local ($closing) = 0;
4420 # Look at potential Makefile.am's.
4423 # Must skip empty string for Perl 4.
4424 next if $_ eq "\\" || $_ eq '';
4426 # Handle $local:$input syntax. Note that we ignore
4427 # every input file past the first, though we keep
4428 # those around for later.
4429 local ($local, $input, @rest) = split (/:/);
4436 # FIXME: should be error if .in is missing.
4437 $input =~ s/\.in$//;
4440 if (-f $input . '.am')
4442 # We have a file that automake should generate.
4443 push (@make_input_list, $input);
4444 $make_list{$input} = join (':', ($local, @rest));
4448 # We have a file that automake should cause to be
4449 # rebuilt, but shouldn't generate itself.
4450 push (@other_input_files, $_);
4454 if ($closing && @make_input_list == 0 && @other_input_files == 0)
4456 &am_conf_line_error ($filename, $ac_output_line,
4457 "No files mentioned in \`AC_OUTPUT'");
4462 if (/$AC_CONFIG_AUX_DIR_PATTERN/o)
4464 @config_aux_path = $1;
4467 # Check for ansi2knr.
4468 $am_c_prototypes = 1 if /AM_C_PROTOTYPES/;
4470 # Check for exe extension stuff.
4474 $configure_vars{'EXEEXT'} = $filename . ':' . $.;
4480 $configure_vars{'OBJEXT'} = $filename . ':' . $.;
4483 # Check for `-c -o' code.
4484 $seen_cc_c_o = 1 if /AM_PROG_CC_C_O/;
4486 # Check for NLS support.
4487 if (/AM_GNU_GETTEXT/)
4490 $ac_gettext_line = $.;
4491 $omit_dependencies{'libintl.h'} = 1;
4494 # Look for ALL_LINGUAS.
4495 if (/ALL_LINGUAS="(.*)"$/ || /ALL_LINGUAS=(.*)$/)
4499 $all_linguas_line = $.;
4502 # Handle configuration headers. A config header of `[$1]'
4503 # means we are actually scanning AM_CONFIG_HEADER from
4505 if (/A([CM])_CONFIG_HEADER\s*\((.*)\)/
4509 ($filename, $., "\`automake requires \`AM_CONFIG_HEADER', not \`AC_CONFIG_HEADER'")
4512 $config_header_line = $.;
4514 foreach $one_hdr (split (' ', $2))
4516 push (@config_fullnames, $one_hdr);
4517 if ($one_hdr =~ /^([^:]+):(.+)$/)
4519 push (@config_names, $1);
4520 push (@config_headers, $2);
4524 push (@config_names, $one_hdr);
4525 push (@config_headers, $one_hdr . '.in');
4530 # Handle AC_CANONICAL_*. Always allow upgrading to
4531 # AC_CANONICAL_SYSTEM, but never downgrading.
4532 $seen_canonical = $AC_CANONICAL_HOST
4533 if ! $seen_canonical
4534 && (/AC_CANONICAL_HOST/ || /AC_CHECK_TOOL/);
4535 $seen_canonical = $AC_CANONICAL_SYSTEM if /AC_CANONICAL_SYSTEM/;
4537 $seen_path_xtra = 1 if /AC_PATH_XTRA/;
4539 # This macro handles several different things.
4540 if (/$AM_INIT_AUTOMAKE_PATTERN/o)
4546 $seen_prog_install = 1;
4547 ($package_version = $1) =~ s/$AM_PACKAGE_VERSION_PATTERN/$1/o;
4548 $package_version_line = $.;
4549 $seen_init_automake = 1;
4552 # Some things required by Automake.
4553 $seen_make_set = 1 if /AC_PROG_MAKE_SET/;
4554 $seen_arg_prog = 1 if /AC_ARG_PROGRAM/;
4558 $configure_vars{'LEX'} = $filename . ':' . $.;
4559 $seen_decl_yytext = 1;
4561 if (/AC_DECL_YYTEXT/ && $filename =~ /configure\.in$/)
4563 &am_conf_line_warning ($filename, $., "\`AC_DECL_YYTEXT' is covered by \`AM_PROG_LEX'");
4565 if (/AC_PROG_LEX/ && $filename =~ /configure\.in$/)
4567 &am_conf_line_warning ($filename, $., "automake requires \`AM_PROG_LEX', not \`AC_PROG_LEX'");
4570 if (/AC_PROG_(F77|YACC|RANLIB|CC|CXXCPP|CXX|LEX|AWK|CPP|LN_S)/)
4572 $configure_vars{$1} = $filename . ':' . $.;
4574 if (/$AC_CHECK_PATTERN/o)
4576 $configure_vars{$3} = $filename . ':' . $.;
4578 if (/$AM_MISSING_PATTERN/o
4582 && $1 ne 'AUTOHEADER')
4584 $configure_vars{$1} = $filename . ':' . $.;
4587 # Explicitly avoid ANSI2KNR -- we AC_SUBST that in protos.m4,
4588 # but later define it elsewhere. This is pretty hacky. We
4589 # also explicitly avoid INSTALL_SCRIPT and some other
4590 # variables because they are defined in header-vars.am.
4592 if (/$AC_SUBST_PATTERN/o
4594 && $1 ne 'INSTALL_SCRIPT'
4595 && $1 ne 'INSTALL_DATA')
4597 $configure_vars{$1} = $filename . ':' . $.;
4600 $seen_decl_yytext = 1 if /AC_DECL_YYTEXT/;
4601 if (/AM_MAINTAINER_MODE/)
4603 $seen_maint_mode = 1;
4604 $configure_cond{'MAINTAINER_MODE'} = 1;
4606 $seen_package = 1 if /PACKAGE=/;
4608 # Skip VERSION of [$2]; that is from AM_INIT_AUTOMAKE.
4609 if (/\bVERSION=(\S+)/ && $1 ne '[$2]')
4612 $package_version = $1;
4613 $package_version_line = $.;
4620 $seen_prog_install = 1 if /AC_PROG_INSTALL/;
4621 $seen_lispdir = 1 if /AM_PATH_LISPDIR/;
4622 $seen_pythondir = 1 if /AM_PATH_PYTHON/;
4624 if (/A(C|M)_PROG_LIBTOOL/)
4626 if (/AM_PROG_LIBTOOL/)
4628 &am_conf_line_warning ($filename, $., "\`AM_PROG_LIBTOOL' is obsolete, use \`AC_PROG_LIBTOOL' instead");
4632 $configure_vars{'LIBTOOL'} = $filename . ':' . $.;
4633 $configure_vars{'RANLIB'} = $filename . ':' . $.;
4634 $configure_vars{'CC'} = $filename . ':' . $.;
4635 # AC_PROG_LIBTOOL runs AC_CANONICAL_HOST. Make sure we
4636 # never downgrade (if we've seen AC_CANONICAL_SYSTEM).
4637 $seen_canonical = $AC_CANONICAL_HOST if ! $seen_canonical;
4640 $seen_multilib = 1 if (/AM_ENABLE_MULTILIB/);
4642 if (/$AM_CONDITIONAL_PATTERN/o)
4644 $configure_cond{$1} = 1;
4647 # Check for Fortran 77 intrinsic and run-time libraries.
4648 if (/AC_F77_LIBRARY_LDFLAGS/)
4650 $configure_vars{'FLIBS'} = $filename . ':' . $.;
4657 # Scan configure.in and aclocal.m4 for interesting things. We must
4658 # scan aclocal.m4 because there might be AC_SUBSTs and such there.
4661 # Reinitialize libsources here. This isn't really necessary,
4662 # since we currently assume there is only one configure.in. But
4663 # that won't always be the case.
4666 local ($in_ac_output, $in_ac_replace) = (0, 0);
4667 local (%make_list, @make_input_list);
4668 local ($libobj_iter);
4670 &scan_one_configure_file ('configure.in');
4671 &scan_one_configure_file ('aclocal.m4')
4674 # Set input and output files if not specified by user.
4677 @input_files = @make_input_list;
4678 %output_files = %make_list;
4681 @configure_input_files = @make_input_list;
4683 &am_conf_error ("\`AM_INIT_AUTOMAKE' must be used in configure.in")
4684 if ! $seen_init_automake;
4686 &am_conf_error ("\`PACKAGE' not defined in configure.in")
4688 &am_conf_error ("\`VERSION' not defined in configure.in")
4691 # Always require AC_PROG_MAKE_SET. We might randomly use $(MAKE)
4692 # for our own reasons.
4693 &am_conf_error ("\`AC_PROG_MAKE_SET' must be used in configure.in")
4694 if ! $seen_make_set;
4696 # Look for some files we need. Always check for these. This
4697 # check must be done for every run, even those where we are only
4698 # looking at a subdir Makefile. We must set relative_dir so that
4699 # the file-finding machinery works.
4700 local ($relative_dir) = '.';
4701 &require_config_file ($FOREIGN, 'install-sh', 'mkinstalldirs', 'missing');
4702 &am_error ("\`install.sh' is an anachronism; use \`install-sh' instead")
4703 if -f $config_aux_path[0] . '/install.sh';
4705 &require_config_file ($FOREIGN, 'py-compile')
4708 # Preserve dist_common for later.
4709 %configure_dist_common = %dist_common;
4712 ################################################################
4714 # Set up for Cygnus mode.
4717 return unless $cygnus_mode;
4719 &set_strictness ('foreign');
4720 $options{'no-installinfo'} = 1;
4721 $options{'no-dependencies'} = 1;
4722 $use_dependencies = 0;
4724 if (! $seen_maint_mode)
4726 &am_conf_error ("\`AM_MAINTAINER_MODE' required when --cygnus specified");
4731 &am_conf_error ("\`AC_EXEEXT' required when --cygnus specified");
4735 # Do any extra checking for GNU standards.
4736 sub check_gnu_standards
4738 if ($relative_dir eq '.')
4740 # In top level (or only) directory.
4741 &require_file ($GNU, 'INSTALL', 'NEWS', 'README', 'COPYING',
4742 'AUTHORS', 'ChangeLog');
4745 if ($strictness >= $GNU)
4747 if (defined $options{'no-installman'})
4749 &am_line_error ('AUTOMAKE_OPTIONS',
4750 "option \`no-installman' disallowed by GNU standards");
4753 if (defined $options{'no-installinfo'})
4755 &am_line_error ('AUTOMAKE_OPTIONS',
4756 "option \`no-installinfo' disallowed by GNU standards");
4761 # Do any extra checking for GNITS standards.
4762 sub check_gnits_standards
4764 if ($relative_dir eq '.')
4766 # In top level (or only) directory.
4767 &require_file ($GNITS, 'THANKS');
4771 ################################################################
4773 # Functions to handle files of each language.
4775 # Each `lang_X_rewrite' function follows a simple formula:
4776 # * Args are the directory, base name and extension of the file.
4777 # * Return value is 1 if file is to be dealt with, 0 otherwise.
4778 # Much of the actual processing is handled in handle_single_transform_list.
4779 # These functions exist so that auxiliary information can be recorded
4780 # for a later cleanup pass. Note that the calls to these functions
4781 # are computed, so don't bother searching for their precise names
4784 # This is just a convenience function that can be used to determine
4785 # when a subdir object should be used.
4788 return defined $options{'subdir-objects'} ? $LANG_SUBDIR : $LANG_PROCESS;
4791 # Rewrite a single C source file.
4794 local ($directory, $base, $ext) = @_;
4796 if (defined $options{'ansi2knr'} && $base =~ /_$/)
4798 # FIXME: include line number in error.
4799 &am_error ("C source file \`$base.c' would be deleted by ansi2knr rules");
4802 local ($r) = $LANG_PROCESS;
4803 if (defined $options{'subdir-objects'})
4806 $base = $directory . '/' . $base;
4810 # Only give error once.
4812 # FIXME: line number.
4813 &am_error ("C objects in subdir but \`AM_PROG_CC_C_O' not in \`configure.in'");
4816 &require_file ($FOREIGN, 'compile')
4817 if $relative_dir eq '.';
4820 $de_ansi_files{$base} = 1;
4824 # Rewrite a single C++ source file.
4825 sub lang_cxx_rewrite
4827 return &lang_sub_obj;
4830 # Rewrite a single header file.
4831 sub lang_header_rewrite
4833 # Header files are simply ignored.
4834 return $LANG_IGNORE;
4837 # Rewrite a single yacc file.
4838 sub lang_yacc_rewrite
4840 local ($directory, $base, $ext) = @_;
4842 local ($r) = &lang_c_rewrite ($directory, $base, $ext);
4844 if ($r == $LANG_SUBDIR)
4846 $pfx = $directory . '/';
4848 $yacc_sources{$pfx . $base . '.' . $ext} = 1;
4850 &saw_extension ('c');
4852 &push_dist_common ($pfx . $base . '.' . $ext);
4856 # Rewrite a single yacc++ file.
4857 sub lang_yaccxx_rewrite
4859 local ($directory, $base, $ext) = @_;
4861 local ($r) = $LANG_PROCESS;
4863 if (defined $options{'subdir-objects'})
4865 $pfx = $directory . '/';
4868 $yacc_sources{$pfx . $base . '.' . $ext} = 1;
4870 &saw_extension ($ext);
4872 &push_dist_common ($pfx . $base . '.' . $ext);
4876 # Rewrite a single lex file.
4877 sub lang_lex_rewrite
4879 local ($directory, $base, $ext) = @_;
4881 local ($r) = &lang_c_rewrite ($directory, $base, $ext);
4883 if ($r == $LANG_SUBDIR)
4885 $pfx = $directory . '/';
4887 $lex_sources{$pfx . $base . '.' . $ext} = 1;
4889 &saw_extension ('c');
4891 &push_dist_common ($pfx . $base . '.' . $ext);
4895 # Rewrite a single lex++ file.
4896 sub lang_lexxx_rewrite
4898 local ($directory, $base, $ext) = @_;
4900 local ($r) = $LANG_PROCESS;
4902 if (defined $options{'subdir-objects'})
4904 $pfx = $directory . '/';
4907 $lex_sources{$pfx . $base . '.' . $ext} = 1;
4909 &saw_extension ($ext);
4911 &push_dist_common ($pfx . $base . '.' . $ext);
4915 # Rewrite a single assembly file.
4916 sub lang_asm_rewrite
4918 return &lang_sub_obj;
4921 # Rewrite a single Fortran 77 file.
4922 sub lang_f77_rewrite
4924 return $LANG_PROCESS;
4927 # Rewrite a single preprocessed Fortran 77 file.
4928 sub lang_ppf77_rewrite
4930 return $LANG_PROCESS;
4933 # Rewrite a single ratfor file.
4934 sub lang_ratfor_rewrite
4936 return $LANG_PROCESS;
4939 # Rewrite a single Objective C file.
4940 sub lang_objc_rewrite
4942 return &lang_sub_obj;
4945 # Rewrite a single Java file.
4946 sub lang_java_rewrite
4948 return $LANG_SUBDIR;
4951 # The lang_X_finish functions are called after all source file
4952 # processing is done. Each should handle defining rules for the
4953 # language, etc. A finish function is only called if a source file of
4954 # the appropriate type has been seen.
4958 # Push all libobjs files onto de_ansi_files. We actually only
4959 # push files which exist in the current directory, and which are
4960 # genuine source files.
4962 foreach $file (keys %libsources)
4964 if ($file =~ /^(.*)\.[cly]$/ && -f "$relative_dir/$file")
4966 $de_ansi_files{$1} = 1;
4970 if (defined $options{'ansi2knr'} && keys %de_ansi_files)
4972 # Make all _.c files depend on their corresponding .c files.
4973 local ($base, @objects);
4974 foreach $base (sort keys %de_ansi_files)
4976 # Each _.c file must depend on ansi2knr; otherwise it
4977 # might be used in a parallel build before it is built.
4978 # We need to support files in the srcdir and in the build
4979 # dir (because these files might be auto-generated. But
4980 # we can't use $< -- some makes only define $< during a
4982 $output_rules .= ($base . "_.c: $base.c \$(ANSI2KNR)\n\t"
4983 . '$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) '
4984 . '`if test -f $(srcdir)/' . $base . '.c'
4985 . '; then echo $(srcdir)/' . $base . '.c'
4986 . '; else echo ' . $base . '.c; fi` '
4987 . "| sed 's/^# \\([0-9]\\)/#line \\1/' "
4988 . '| $(ANSI2KNR) > ' . $base . "_.c\n");
4989 push (@objects, $base . '_'
4990 . ($seen_objext ? '.$(OBJEXT)' : '.o'));
4991 push (@objects, $base . '_.lo') if $seen_libtool;
4994 # Make all _.o (and _.lo) files depend on ansi2knr.
4995 # Use a sneaky little hack to make it print nicely.
4996 &pretty_print_rule ('', '', @objects, ':', '$(ANSI2KNR)');
4999 if (! defined $configure_vars{'CC'})
5001 # FIXME: line number.
5002 &am_error ("C source seen but \`CC' not defined in \`configure.in'");
5008 local ($ltcompile, $ltlink) = &libtool_compiler;
5010 &define_variable ('CXXLD', '$(CXX)');
5011 &define_variable ('CXXLINK', $ltlink . '$(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@');
5013 if (! defined $configure_vars{'CXX'})
5015 &am_error ("C++ source seen but \`CXX' not defined in \`configure.in'");
5019 sub lang_header_finish
5024 # This is a helper for both lex and yacc.
5025 sub yacc_lex_finish_helper
5027 return if defined $language_scratch{'lex-yacc-done'};
5028 $language_scratch{'lex-yacc-done'} = 1;
5030 # If there is more than one distinct yacc (resp lex) source file
5031 # in a given directory, then the `ylwrap' program is required to
5032 # allow parallel builds to work correctly. FIXME: for now, no
5034 &require_config_file ($FOREIGN, 'ylwrap');
5035 if ($config_aux_dir ne '.' && $config_aux_dir ne '')
5037 &define_variable ('YLWRAP', $config_aux_dir . "/ylwrap");
5041 &define_variable ('YLWRAP', '$(srcdir)/ylwrap');
5045 sub lang_yacc_finish
5047 return if defined $language_scratch{'yacc-done'};
5048 $language_scratch{'yacc-done'} = 1;
5050 local ($file, $base, $hname, $cname);
5051 local (%seen_suffix) = ();
5052 local (@yacc_files) = sort keys %yacc_sources;
5053 local ($yacc_count) = scalar (@yacc_files);
5054 foreach $file (@yacc_files)
5057 &output_yacc_build_rule ($1, $yacc_count > 1)
5058 if ! defined $seen_suffix{$1};
5059 $seen_suffix{$1} = 1;
5061 $file =~ /^(.*)\.(y|yy|y\+\+|yxx|ypp)$/;
5063 $hname = 'h'; # Always use `.h' for header file.
5064 ($cname = $2) =~ tr/y/c/;
5066 if ((&variable_defined ('AM_YFLAGS')
5067 && &variable_value ('AM_YFLAGS') =~ /(^|\s)-d(\s|$)/)
5068 || (&variable_defined ('YFLAGS')
5069 && &variable_value ('YFLAGS') =~ /(^|\s)-d(\s|$)/)) {
5070 # Now generate rule to make the header file. This should only
5071 # be generated if `yacc -d' specified.
5072 $output_rules .= "${base}.${hname}: ${base}.${cname}\n";
5074 # If the files are built in the build directory, then we want
5075 # to remove them with `make clean'. If they are in srcdir
5076 # they shouldn't be touched. However, we can't determine this
5077 # statically, and the GNU rules say that yacc/lex output files
5078 # should be removed by maintainer-clean. So that's what we
5080 push (@maintainer_clean_files, "${base}.${hname}");
5082 &push_dist_common ("${base}.${hname}");
5084 push (@maintainer_clean_files, "${base}.${cname}");
5086 $output_rules .= "\n";
5088 if (! defined $configure_vars{'YACC'})
5090 &am_error ("yacc source seen but \`YACC' not defined in \`configure.in'");
5092 if (&variable_defined ('YACCFLAGS'))
5094 &am_line_error ('YACCFLAGS',
5095 "\`YACCFLAGS' obsolete; use \`YFLAGS' instead");
5098 if ($yacc_count > 1)
5100 &yacc_lex_finish_helper;
5104 sub lang_yaccxx_finish
5111 return if defined $language_scratch{'lex-done'};
5112 $language_scratch{'lex-done'} = 1;
5114 local (%seen_suffix) = ();
5115 local ($file, $cname);
5116 local ($lex_count) = scalar (keys %lex_sources);
5117 foreach $file (sort keys %lex_sources)
5120 &output_lex_build_rule ($1, $lex_count > 1)
5121 if (! defined $seen_suffix{$1});
5122 $seen_suffix{$1} = 1;
5124 # If the files are built in the build directory, then we want
5125 # to remove them with `make clean'. If they are in srcdir
5126 # they shouldn't be touched. However, we can't determine this
5127 # statically, and the GNU rules say that yacc/lex output files
5128 # should be removed by maintainer-clean. So that's what we
5130 $file =~ /^(.*)\.(l|ll|l\+\+|lxx|lpp)$/;
5131 ($cname = $2) =~ tr/l/c/;
5132 push (@maintainer_clean_files, "${1}.${cname}");
5135 if (! defined $configure_vars{'LEX'})
5137 &am_error ("lex source seen but \`LEX' not defined in \`configure.in'");
5139 if (! $seen_decl_yytext)
5141 &am_error ("lex source seen but \`AC_DECL_YYTEXT' not in \`configure.in'");
5146 &yacc_lex_finish_helper;
5150 sub lang_lexxx_finish
5157 # We need the C code for assembly.
5163 # FIXME: this function can be called more than once. We should
5164 # arrange for it to only do anything the first time through.
5166 local ($ltcompile, $ltlink) = &libtool_compiler;
5168 &define_variable ('F77LD', '$(F77)');
5169 &define_variable ('F77LINK', $ltlink . '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@');
5171 if (! defined $configure_vars{'F77'})
5173 &am_error ("Fortran 77 source seen but \`F77' not defined in \`configure.in'");
5177 # Preprocessed Fortran 77
5179 # The current support for preprocessing Fortran 77 just involves passing
5180 # `$(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS)' as additional flags
5181 # to the Fortran 77 compiler, since this is how GNU Make does it; see
5182 # the `GNU Make Manual, Edition 0.51 for `make' Version 3.76 Beta'
5183 # (specifically, from info file `(make)Catalogue of Rules').
5185 # A better approach would be to write an Autoconf test
5186 # (i.e. AC_PROG_FPP) for a Fortran 77 preprocessor, because not all
5187 # Fortran 77 compilers know how to do preprocessing. The Autoconf macro
5188 # AC_PROG_FPP should test the Fortran 77 compiler first for
5189 # preprocessing capabilities, and then fall back on cpp (if cpp were
5191 sub lang_ppf77_finish
5195 # We also handle the case of preprocessing `.F' files into `.f'
5197 $output_rules .= (".F.f:\n"
5198 . "\t\$(F77COMPILE) -F \$<\n");
5201 sub lang_ratfor_finish
5205 # We also handle the case of preprocessing `.r' files into `.f'
5207 $output_rules .= (".r.f:\n"
5208 . "\t\$(RCOMPILE) -F \$<\n");
5211 sub lang_objc_finish
5213 local ($ltcompile, $ltlink) = &libtool_compiler;
5215 &define_variable ('OBJCLD', '$(OBJC)');
5216 &define_variable ('OBJCLINK', $ltlink . '$(OBJCLD) $(AM_OBJCFLAGS) $(OBJCFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@');
5218 if (! defined $configure_vars{'OBJC'})
5220 &am_error ("Objective C source seen but \`OBJC' not defined in \`configure.in'");
5224 sub lang_java_finish
5226 local ($ltcompile, $ltlink) = &libtool_compiler;
5228 &define_variable ('GCJLD', '$(GCJ)');
5229 &define_variable ('GCJLINK', $ltlink . '$(GCJLD) $(AM_GCJFLAGS) $(GCJFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@');
5231 if (! defined $configure_vars{'GCJ'})
5233 &am_error ("Java source seen but \`GCJ' not defined in \`configure.in'");
5237 # A helper which computes a sorted list of all extensions for LANG.
5242 foreach $key (sort keys %extension_seen)
5244 push (@r, '.' . $key) if $extension_map{$key} eq $lang;
5249 # A helper which decides whether libtool is needed. Returns prefix
5250 # for compiler and linker.
5251 sub libtool_compiler
5253 local ($ltcompile, $ltlink) = ('', '');
5256 &define_configure_variable ("LIBTOOL");
5257 $ltcompile = '$(LIBTOOL) --mode=compile ';
5258 $ltlink = '$(LIBTOOL) --mode=link ';
5260 return ($ltcompile, $ltlink);
5263 # Given a hash table of linker names, pick the name that has the most
5264 # precedence. This is lame, but something has to have global
5265 # knowledge in order to eliminate the conflict. Add more linkers as
5269 local (%linkers) = @_;
5272 if defined $linkers{'GCJLINK'};
5274 if defined $linkers{'CXXLINK'};
5276 if defined $linkers{'F77LINK'};
5278 if defined $linkers{'OBJCLINK'};
5282 # Called to indicate that an extension was used.
5286 $extension_seen{$ext} = 1;
5289 # Called to ask whether source files have been seen . If HEADERS is 1,
5290 # headers can be included.
5293 local ($headers) = @_;
5301 local (@exts) = &lang_extensions ('header');
5305 return scalar keys %extension_seen > $headers;
5308 # Register a single language. LANGUAGE is the name of the language.
5309 # Each OPTION is either of the form NAME=VALUE, or is a file extension
5311 sub register_language
5313 local ($language, @options) = @_;
5316 $language_map{$language . '-ansi-p'} = 0;
5317 $language_map{$language . '-linker'} = '';
5318 $language_map{$language . '-autodep'} = 'no';
5321 foreach $iter (@options)
5323 if ($iter =~ /^(.*)=(.*)$/)
5325 $language_map{$language . '-' . $1} = $2;
5327 elsif (defined $extension_map{$iter})
5330 "automake: programming error: duplicate extension $iter\n";
5335 $extension_map{$iter} = $language;
5340 # This function is used to find a path from a user-specified suffix to
5341 # `o' or to some other suffix we recognize internally, eg `cc'.
5344 local ($source_ext) = @_;
5346 # FIXME: hard-coding `o' is a mistake. Doing something
5347 # intelligent is harder.
5348 while ($extension_map{$source_ext} eq ''
5349 && $source_ext ne 'o'
5350 && defined $suffix_rules{$source_ext})
5352 $source_ext = $suffix_rules{$source_ext};
5359 ################################################################
5361 # Pretty-print something. HEAD is what should be printed at the
5362 # beginning of the first line, FILL is what should be printed at the
5363 # beginning of every subsequent line.
5364 sub pretty_print_internal
5366 local ($head, $fill, @values) = @_;
5368 local ($column) = length ($head);
5369 local ($result) = $head;
5371 # Fill length is number of characters. However, each Tab
5372 # character counts for eight. So we count the number of Tabs and
5374 local ($fill_length) = length ($fill);
5375 $fill_length += 7 * ($fill =~ tr/\t/\t/d);
5377 local ($bol) = ($head eq '');
5380 # "71" because we also print a space.
5381 if ($column + length ($_) > 71)
5383 $result .= " \\\n" . $fill;
5384 $column = $fill_length;
5388 $result .= ' ' unless ($bol);
5390 $column += length ($_) + 1;
5398 # Pretty-print something and append to output_vars.
5401 $output_vars .= &pretty_print_internal (@_);
5404 # Pretty-print something and append to output_rules.
5405 sub pretty_print_rule
5407 $output_rules .= &pretty_print_internal (@_);
5411 ################################################################
5413 # See if a target exists.
5416 local ($target) = @_;
5417 return defined $targets{$target};
5420 # See if two conditionals are the same.
5421 sub conditional_same
5423 local ($cond1, $cond2) = @_;
5425 return (&conditional_true_when ($cond1, $cond2)
5426 && &conditional_true_when ($cond2, $cond1));
5429 # See if a conditional is true. Both arguments are conditional
5430 # strings. This returns true if the first conditional is true when
5431 # the second conditional is true.
5432 sub conditional_true_when
5434 local ($cond, $when) = @_;
5436 # Check the easy case first.
5442 # Check each component of $cond, which looks @COND1@@COND2@.
5443 foreach $comp (split ('@', $cond))
5445 # The way we split will give null strings between each
5449 if (index ($when, '@' . $comp . '@') == -1)
5458 # Check for an ambiguous conditional. This is called when a variable
5459 # or target is being defined conditionally. If we already know about
5460 # a definition that is true under the same conditions, then we have an
5462 sub check_ambiguous_conditional
5464 local ($var_name, $cond) = @_;
5465 local (@cond_vals) = split (' ', $conditional{$var_name});
5468 local ($vcond) = shift (@cond_vals);
5470 if (&conditional_true_when ($vcond, $cond)
5471 || &conditional_true_when ($cond, $vcond))
5473 &am_line_error ($var_name,
5474 "$var_name multiply defined in condition");
5479 # See if a variable exists. The first argument is the variable name,
5480 # and the optional second argument is the condition which we should
5481 # check. If no condition is given, we currently return true if the
5482 # variable is defined under any condition.
5483 sub variable_defined
5485 local ($var, $cond) = @_;
5486 if (defined $targets{$var})
5488 &am_line_error ($var, "\`$var' is target; expected variable");
5491 elsif (defined $contents{$var})
5493 if ($cond && $conditional{$var})
5495 # We have been asked to check for a particular condition,
5496 # and the variable is defined conditionally. We need to
5497 # look through the conditions under which the variable is
5498 # defined, and see if any of them match the conditional we
5499 # have been asked to check.
5500 local (@cond_vars) = split (' ', $conditional{$var});
5503 if (&conditional_same ($cond, shift (@cond_vars)))
5505 # Even a conditional examination is good enough
5506 # for us. FIXME: really should maintain examined
5507 # status on a per-condition basis.
5508 $content_seen{$var} = 1;
5514 # The variable is not defined for the given condition.
5518 $content_seen{$var} = 1;
5524 # Mark a variable as examined.
5525 sub examine_variable
5528 &variable_defined ($var);
5531 # Quote a value in order to put it in $conditional. We need to quote
5532 # spaces, and we need to handle null strings, so that we can later
5533 # retrieve values by splitting on space.
5537 $val =~ tr/ \t\n/\001\003\004/;
5538 $val = "\002" if $val eq '';
5542 # Unquote a value in $conditional.
5543 sub unquote_cond_val
5546 $val =~ tr/\001\003\004/ \t\n/;
5551 # Return the set of conditions for which a variable is defined.
5553 # If the variable is not defined conditionally, and is not defined in
5554 # terms of any variables which are defined conditionally, then this
5555 # returns the empty list.
5557 # If the variable is defined conditionally, but is not defined in
5558 # terms of any variables which are defined conditionally, then this
5559 # returns the list of conditions for which the variable is defined.
5561 # If the variable is defined in terms of any variables which are
5562 # defined conditionally, then this returns a full set of permutations
5563 # of the subvariable conditions. For example, if the variable is
5564 # defined in terms of a variable which is defined for @COND_TRUE@,
5565 # then this returns both @COND_TRUE@ and @COND_FALSE@. This is
5566 # because we will need to define the variable under both conditions.
5568 sub variable_conditions
5576 foreach $cond (&variable_conditions_sub ($var, '', ()))
5578 $uniqify{$cond} = 1;
5581 @uniq_list = sort keys %uniqify;
5582 # Note we cannot just do `return sort keys %uniqify', because this
5583 # function is sometimes used in a scalar context.
5587 # A subroutine of variable_conditions. We only return conditions
5588 # which are true for all the conditions in @PARENT_CONDS.
5589 sub variable_conditions_sub
5591 local ($var, $parent, @parent_conds) = @_;
5592 local (@new_conds) = ();
5594 if (defined $vars_scanned{$var})
5596 &am_line_error ($parent, "variable \`$var' recursively defined");
5599 $vars_scanned{$var} = 1;
5601 if (! $conditional{$var})
5603 foreach (split (' ', $contents{$var}))
5605 # If a comment seen, just leave.
5608 # Handle variable substitutions.
5609 if (/^\$\{(.*)\}$/ || /^\$\((.*)\)$/)
5612 &variable_conditions_sub ($1, $var, @parent_conds));
5616 # Now we want to return all permutations of the subvariable
5618 local (%allconds, $item);
5619 foreach $item (@new_conds)
5621 foreach (split ('@', $item))
5625 $allconds{$_ . '_TRUE'} = 1;
5629 # Unset our entry in vars_scanned. We only care about recursive
5631 delete $vars_scanned{$var};
5633 return &variable_conditions_permutations (sort keys %allconds);
5636 local (@this_conds) = ();
5637 local (@condvals) = split (' ', $conditional{$var});
5640 local ($cond) = shift (@condvals);
5641 local ($val) = &unquote_cond_val (shift (@condvals));
5646 local ($parent_cond);
5647 foreach $parent_cond (@parent_conds)
5649 if (! &conditional_true_when ($parent_cond, $cond))
5659 push (@this_conds, $cond);
5661 push (@parent_conds, $cond);
5662 local (@subvar_conds) = ();
5663 foreach (split (' ', $val))
5665 # If a comment seen, just leave.
5668 # Handle variable substitutions.
5669 if (/^\$\{(.*)\}$/ || /^\$\((.*)\)$/)
5671 push (@subvar_conds,
5672 &variable_conditions_sub ($1, $var, @parent_conds));
5675 pop (@parent_conds);
5677 # If there are no conditional subvariables, then we want to
5678 # return this condition. Otherwise, we want to return the
5679 # permutations of the subvariables.
5680 if (! @subvar_conds)
5682 push (@new_conds, $cond);
5686 push (@new_conds, &variable_conditions_reduce (@subvar_conds));
5690 # Unset our entry in vars_scanned. We only care about recursive
5692 delete $vars_scanned{$var};
5697 # If we are being called on behalf of another variable, we need to
5698 # return all possible permutations of the conditions. We have
5699 # already handled everything in @this_conds along with their
5700 # subvariables. We now need to add any permutations that are not
5703 foreach $this_cond (@this_conds)
5706 &variable_conditions_permutations (split('@', $this_cond));
5708 foreach $perm (@perms)
5712 foreach $scan (@this_conds)
5714 if (&conditional_true_when ($perm, $scan)
5715 || &conditional_true_when ($scan, $perm))
5726 local ($parent_cond);
5727 foreach $parent_cond (@parent_conds)
5729 if (! &conditional_true_when ($parent_cond, $perm))
5739 # This permutation was not already handled, and is valid
5741 push (@new_conds, $perm);
5748 # Subroutine for variable_conditions_sort
5749 sub variable_conditions_cmp
5755 return (length ($as) <=> length ($bs)
5759 # Sort a list of conditionals so that only the exclusive ones are
5760 # retained. For example, if both @COND1_TRUE@@COND2_TRUE@ and
5761 # @COND1_TRUE@ are in the list, discard the latter.
5762 sub variable_conditions_reduce
5764 local (@conds) = @_;
5767 foreach $cond (sort variable_conditions_cmp @conds)
5771 foreach $scan (@ret)
5773 if (&conditional_true_when ($cond, $scan))
5786 # Return a list of permutations of a conditional string.
5787 sub variable_conditions_permutations
5789 local (@comps) = @_;
5792 local ($comp) = shift (@comps);
5793 return &variable_conditions_permutations (@comps)
5795 local ($neg) = $comp;
5796 $neg =~ s/TRUE$/TRUEO/;
5797 $neg =~ s/FALSE$/TRUE/;
5798 $neg =~ s/TRUEO$/FALSE/;
5801 foreach $sub (&variable_conditions_permutations (@comps))
5803 push (@ret, '@' . $comp . '@' . $sub);
5804 push (@ret, '@' . $neg . '@' . $sub);
5808 push (@ret, '@' . $comp . '@');
5809 push (@ret, '@' . $neg . '@');
5814 # Warn if a variable is conditionally defined. This is called if we
5815 # are using the value of a variable.
5816 sub variable_conditionally_defined
5818 local ($var, $parent) = @_;
5819 if ($conditional{$var})
5823 &am_line_error ($parent,
5824 "warning: automake does not support conditional definition of $var in $parent");
5828 &am_line_error ($parent,
5829 "warning: automake does not support $var being defined conditionally")
5834 # Get the value of a variable. This just returns $contents, but warns
5835 # if the variable is conditionally defined.
5839 &variable_conditionally_defined ($var);
5840 return $contents{$var};
5843 # Convert a variable value to a list, split as whitespace. This will
5844 # recursively follow $(...) and ${...} inclusions. It preserves @...@
5845 # substitutions. If COND is 'all', then all values under all
5846 # conditions should be returned; if COND is a particular condition
5847 # (all conditions are surrounded by @...@) then only the value for
5848 # that condition should be returned; otherwise, warn if VAR is
5849 # conditionally defined. SCANNED is a global hash listing whose keys
5850 # are all the variables already scanned; it is an error to rescan a
5854 local ($var, $val, $cond) = @_;
5858 $val =~ s/\\(\n|$)/ /g;
5860 foreach (split (' ', $val))
5862 # If a comment seen, just leave.
5865 # Handle variable substitutions.
5866 if (/^\$\{([^}]*)\}$/ || /^\$\(([^)]*)\)$/)
5868 local ($varname) = $1;
5870 # If the user uses a losing variable name, just ignore it.
5871 # This isn't ideal, but people have requested it.
5872 next if ($varname =~ /\@.*\@/);
5876 if ($varname =~ /^([^:]*):([^=]*)=(.*)$/)
5880 ($from = $2) =~ s/(\W)/\\$1/g;
5884 @temp_list = &variable_value_as_list_worker ($1, $cond, $var);
5886 # Now rewrite the value if appropriate.
5889 grep (s/$from$/$to/, @temp_list);
5892 push (@result, @temp_list);
5903 # Return contents of variable as 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. If PARENT is specified, it is the name of
5910 # the including variable; this is only used for error reports.
5911 sub variable_value_as_list_worker
5913 local ($var, $cond, $parent) = @_;
5916 if (defined $targets{$var})
5918 &am_line_error ($var, "\`$var' is target; expected variable");
5920 elsif (! defined $contents{$var})
5922 &am_line_error ($parent, "variable \`$var' not defined");
5924 elsif (defined $vars_scanned{$var})
5926 # `vars_scanned' is a global we use to keep track of which
5927 # variables we've already examined.
5928 &am_line_error ($parent, "variable \`$var' recursively defined");
5930 elsif ($cond eq 'all' && $conditional{$var})
5932 $vars_scanned{$var} = 1;
5933 local (@condvals) = split (' ', $conditional{$var});
5937 local ($val) = &unquote_cond_val (shift (@condvals));
5938 push (@result, &value_to_list ($var, $val, $cond));
5941 elsif ($cond && $conditional{$var})
5943 $vars_scanned{$var} = 1;
5944 local (@condvals) = split (' ', $conditional{$var});
5948 local ($vcond) = shift (@condvals);
5949 local ($val) = &unquote_cond_val (shift (@condvals));
5950 if (&conditional_true_when ($vcond, $cond))
5952 # Warn if we have an ambiguity. It's hard to know how
5953 # to handle this case correctly.
5954 &variable_conditionally_defined ($var, $parent)
5957 push (@result, &value_to_list ($var, $val, $cond));
5963 $vars_scanned{$var} = 1;
5964 &variable_conditionally_defined ($var, $parent);
5965 $content_seen{$var} = 1;
5966 push (@result, &value_to_list ($var, $contents{$var}, $cond));
5969 # Unset our entry in vars_scanned. We only care about recursive
5971 delete $vars_scanned{$var};
5976 # This is just a wrapper for variable_value_as_list_worker that
5977 # initializes the global hash `vars_scanned'. This hash is used to
5978 # avoid infinite recursion.
5979 sub variable_value_as_list
5981 local ($var, $cond, $parent) = @_;
5983 return &variable_value_as_list_worker ($var, $cond, $parent);
5986 # Define a new variable, but only if not already defined.
5989 local ($var, $value) = @_;
5991 if (! defined $contents{$var})
5993 $output_vars .= $var . ' = ' . $value . "\n";
5994 $contents{$var} = $value;
5995 $content_seen{$var} = 1;
5997 elsif ($var_was_plus_eq{$var})
5999 &am_line_error ($var, "internally generated variable \`$var' was set with \`+='");
6003 # Like define_variable, but the value is a list, and the variable may
6004 # be defined conditionally. The second argument is the conditional
6005 # under which the value should be defined; this should be the empty
6006 # string to define the variable unconditionally. The third argument
6007 # is a list holding the values to use for the variable. The value is
6008 # pretty printed in the output file.
6009 sub define_pretty_variable
6011 local ($var, $cond, @value) = @_;
6012 if (! defined $contents{$var}
6013 || ($cond && ! &variable_defined ($var, $cond)))
6015 $contents{$var} = join (' ', @value);
6018 if ($conditional{$var})
6020 $conditional{$var} .= ' ';
6024 $conditional{$var} = '';
6026 $conditional{$var} .= ($cond
6028 . "e_cond_val ($contents{$var}));
6030 &pretty_print ($cond . $var . ' = ', $cond, @value);
6031 $content_seen{$var} = 1;
6035 # Like define_variable, but define a variable to be the configure
6036 # substitution by the same name.
6037 sub define_configure_variable
6040 local ($value) = '@' . $var . '@';
6041 &define_variable ($var, $value);
6044 # Define a compiler variable. We also handle defining the `LT'
6045 # version of the command when using libtool.
6046 sub define_compiler_variable
6048 local ($var, $ltcompile, $value) = @_;
6049 local ($name) = $var;
6050 &define_variable ($name, $value);
6051 &define_variable ('LT' . $name, $ltcompile . $value)
6055 # Define a variable that represents a program to run. If in Cygnus
6056 # mode, the program is searched for in the build (or source) tree.
6057 # Otherwise no searching is done at all. Arguments are:
6058 # * VAR Name of variable to define
6059 # * WHATDIR Either `src' or `build', depending on where program should
6060 # be found. (runtest is in srcdir!)
6061 # * SUBDIR Subdir of top-level dir
6062 # * PROGRAM Name of program
6063 # * OVERRIDE If specified, the name of the program to use when not in
6064 # Cygnus mode. Defaults to PROGRAM.
6065 sub define_program_variable
6067 local ($var, $whatdir, $subdir, $program, $override) = @_;
6071 $override = $program;
6076 local ($full) = ('$(top_' . $whatdir . 'dir)/../'
6077 . $subdir . '/' . $program);
6078 &define_variable ($var, ('`if test -f ' . $full
6079 . '; then echo ' . $full . '; else echo '
6080 . $program . '; fi`'));
6084 &define_variable ($var, $override);
6089 ################################################################
6091 # Read Makefile.am and set up %contents. Simultaneously copy lines
6092 # from Makefile.am into $output_trailer or $output_vars as
6093 # appropriate. NOTE we put rules in the trailer section. We want
6094 # user rules to come after our generated stuff.
6097 local ($amfile) = @_;
6100 open (AM_FILE, $amfile) || die "automake: couldn't open \`$amfile': $!\n";
6101 print "automake: reading $amfile\n" if $verbose;
6103 local ($saw_bk) = 0;
6104 local ($was_rule) = 0;
6105 local ($spacing) = '';
6106 local ($comment) = '';
6107 local ($last_var_name) = '';
6110 # We save the conditional stack on entry, and then check to make
6111 # sure it is the same on exit. This lets us conditonally include
6113 local (@saved_cond_stack) = @conditional_stack;
6117 if (/$IGNORE_PATTERN/o)
6119 # Merely delete comments beginning with two hashes.
6121 elsif (/$WHITE_PATTERN/o)
6123 # Stick a single white line before the incoming macro or rule.
6127 elsif (/$COMMENT_PATTERN/o)
6129 # Stick comments before the incoming macro or rule. Make
6130 # sure a blank line preceeds first block of comments.
6131 $spacing = "\n" unless $blank;
6133 $comment .= $spacing . $_;
6142 $output_vars .= $comment . "\n";
6146 local ($is_ok_macro);
6150 unless substr ($_, -1, 1) eq "\n";
6152 # Don't look at MAINTAINER_MODE_TRUE here. That shouldn't be
6153 # used by users. @MAINT@ is an anachronism now.
6154 $_ =~ s/\@MAINT\@//g
6155 unless $seen_maint_mode;
6157 if (/$IGNORE_PATTERN/o)
6159 # Merely delete comments beginning with two hashes.
6161 elsif (/$WHITE_PATTERN/o)
6163 # Stick a single white line before the incoming macro or rule.
6165 &am_line_error ($., "blank line following trailing backslash")
6168 elsif (/$COMMENT_PATTERN/o)
6170 # Stick comments before the incoming macro or rule.
6171 $comment .= $spacing . $_;
6173 &am_line_error ($., "comment following trailing backslash")
6180 $output_trailer .= join ('', @conditional_stack) . $_;
6186 $contents{$last_var_name} .= ' '
6187 unless $contents{$last_var_name} =~ /\s$/;
6188 $contents{$last_var_name} .= $_;
6189 if (@conditional_stack)
6191 $conditional{$last_var_name} .= "e_cond_val ($_);
6195 elsif (/$IF_PATTERN/o)
6197 &am_line_error ($., "$1 does not appear in AM_CONDITIONAL")
6198 if (! $configure_cond{$1});
6199 push (@conditional_stack, "\@" . $1 . "_TRUE\@");
6201 elsif (/$ELSE_PATTERN/o)
6203 if (! @conditional_stack)
6205 &am_line_error ($., "else without if");
6207 elsif ($conditional_stack[$#conditional_stack] =~ /_FALSE\@$/)
6209 &am_line_error ($., "else after else");
6213 $conditional_stack[$#conditional_stack]
6214 =~ s/_TRUE\@$/_FALSE\@/;
6217 elsif (/$ENDIF_PATTERN/o)
6219 if (! @conditional_stack)
6221 &am_line_error ($., "endif without if");
6225 pop @conditional_stack;
6228 elsif (/$RULE_PATTERN/o)
6232 if (defined $contents{$1}
6233 && (@conditional_stack
6234 ? ! defined $conditional{$1}
6235 : defined $conditional{$1}))
6238 "$1 defined both conditionally and unconditionally");
6240 # Value here doesn't matter; for targets we only note
6244 local ($cond_string) = join ('', @conditional_stack);
6245 if (@conditional_stack)
6247 if ($conditional{$1})
6249 &check_ambiguous_conditional ($1, $cond_string);
6250 $conditional{$1} .= ' ';
6254 $conditional{$1} = '';
6256 $conditional{$1} .= $cond_string . ' 1';
6258 $content_lines{$1} = $.;
6259 $output_trailer .= $comment . $spacing . $cond_string . $_;
6260 $comment = $spacing = '';
6263 # Check the rule for being a suffix rule. If so, store in
6266 local ($source_suffix);
6267 local ($object_suffix);
6269 if (($source_suffix, $object_suffix) = ($1 =~ $SUFFIX_RULE_PATTERN))
6271 $suffix_rules{$source_suffix} = $object_suffix;
6272 print "Sources ending in .$source_suffix become .$object_suffix\n" if $verbose;
6273 $source_suffix_pattern = "(" . join ('|', keys %suffix_rules) . ")";
6276 # FIXME: make sure both suffixes are in SUFFIXES? Or set
6277 # SUFFIXES from suffix_rules?
6279 elsif (($is_ok_macro = /$MACRO_PATTERN/o)
6280 || /$BOGUS_MACRO_PATTERN/o)
6282 # Found a macro definition.
6284 $last_var_name = $1;
6285 if (defined $contents{$1}
6286 && (@conditional_stack
6287 ? ! defined $conditional{$1}
6288 : defined $conditional{$1}))
6291 "$1 defined both conditionally and unconditionally");
6294 if ($3 ne '' && substr ($3, -1) eq "\\")
6296 # We preserve the `\' because otherwise the long lines
6297 # that are generated will be truncated by broken
6307 if (! defined $contents{$last_var_name})
6309 # The first assignment to a macro sets the line
6310 # number. Ideally I suppose we would associate line
6311 # numbers with random bits of text.
6312 $content_lines{$last_var_name} = $.;
6314 # If first assignment, set `+=' indicator.
6315 $var_was_plus_eq{$last_var_name} =
6317 && ! defined $am_var_defs{$last_var_name});
6322 if (! defined $contents{$last_var_name}
6323 && defined $am_var_defs{$last_var_name})
6325 $contents{$last_var_name} = $am_var_defs{$last_var_name};
6327 if (substr ($contents{$last_var_name}, -1) eq "\n")
6329 # Insert a backslash before a trailing newline.
6330 $contents{$last_var_name}
6331 = substr ($contents{$last_var_name}, 0, -1) . "\\\n";
6333 $contents{$last_var_name} .= ' ' . $value;
6337 $contents{$last_var_name} = $value;
6339 local ($cond_string) = join ('', @conditional_stack);
6340 if (@conditional_stack)
6344 if ($conditional{$last_var_name})
6348 # If we're adding to the conditional, and it
6349 # exists, then we might want to simply replace
6350 # the old value with the new one.
6351 local (@new_vals, @cond_vals);
6352 @cond_vals = split (' ', $conditional{$last_var_name});
6355 local ($vcond) = shift (@cond_vals);
6356 push (@new_vals, $vcond);
6357 if (&conditional_same ($vcond, $cond_string))
6360 $val = (&unquote_cond_val (shift (@cond_vals))
6362 push (@new_vals, "e_cond_val ($val));
6366 push (@new_vals, shift (@cond_vals));
6371 $conditional{$last_var_name}
6372 = join (' ', @new_vals);
6378 &check_ambiguous_conditional ($last_var_name,
6380 $conditional{$last_var_name} .= ' ';
6386 $conditional{$last_var_name} = '';
6387 $val = $contents{$last_var_name};
6391 $conditional{$last_var_name} .= ($cond_string
6393 . "e_cond_val ($val));
6397 # FIXME: this doesn't always work correctly; it will group
6398 # all comments for a given variable, no matter where
6400 $am_vars{$last_var_name} = $comment . $spacing;
6401 $def_type{$last_var_name} = ($type eq ':') ? ':' : '';
6402 push (@var_list, $last_var_name);
6403 $comment = $spacing = '';
6407 &am_line_error ($., "bad macro name \`$last_var_name'")
6410 elsif (/$INCLUDE_PATTERN/o)
6414 if ($path =~ s/^\$\(top_srcdir\)\///)
6416 push (@include_stack, "\$\(top_srcdir\)/$path");
6420 $path =~ s/\$\(srcdir\)\///;
6421 push (@include_stack, "\$\(srcdir\)/$path");
6422 $path = $relative_dir . "/" . $path;
6424 &read_am_file ($path);
6428 # This isn't an error; it is probably a continued rule.
6429 # In fact, this is what we assume.
6431 $output_trailer .= ($comment . $spacing
6432 . join ('', @conditional_stack) . $_);
6433 $comment = $spacing = '';
6440 $output_trailer .= $comment;
6442 if (join (' ', @saved_cond_stack) ne join (' ', @conditional_stack))
6444 if (@conditional_stack)
6446 &am_error ("unterminated conditionals: " . join (' ', @conditional_stack));
6450 # FIXME: better error message here.
6451 &am_error ("conditionals not nested in include file");
6456 # A helper for read_main_am_file which initializes configure variables
6457 # and variables from header-vars.am. This is a subr so we can call it
6459 sub define_standard_variables
6461 # Compute relative location of the top object directory.
6462 local (@topdir) = ();
6463 foreach (split (/\//, $relative_dir))
6465 next if $_ eq '.' || $_ eq '';
6472 push (@topdir, '..');
6475 @topdir = ('.') if ! @topdir;
6477 $top_builddir = join ('/', @topdir);
6479 ($build_rx = $top_builddir) =~ s/(\W)/\\$1/g;
6480 $output_vars .= &file_contents_with_transform
6481 ('s/\@top_builddir\@/' . $build_rx . '/g;',
6484 # Generate some useful variables when AC_CANONICAL_* used. FIXME:
6485 # this should use generic %configure_vars method.
6486 if ($seen_canonical)
6488 local ($curs, %vars);
6489 $vars{'host_alias'} = 'host_alias';
6490 $vars{'host_triplet'} = 'host';
6491 if ($seen_canonical == $AC_CANONICAL_SYSTEM)
6493 $vars{'build_alias'} = 'build_alias';
6494 $vars{'build_triplet'} = 'build';
6495 $vars{'target_alias'} = 'target_alias';
6496 $vars{'target_triplet'} = 'target';
6498 foreach $curs (sort keys %vars)
6500 $output_vars .= "$curs = \@$vars{$curs}\@\n";
6501 $contents{$curs} = "\@$vars{$curs}\@";
6506 foreach $curs (sort keys %configure_vars)
6508 &define_configure_variable ($curs);
6512 # Read main am file.
6513 sub read_main_am_file
6515 local ($amfile) = @_;
6517 # The keys here are variables we want to dump at the end of this
6518 # function. The values are corresponding comments.
6519 local (%am_vars) = ();
6520 local (@var_list) = ();
6521 local (%def_type) = ();
6523 # This supports the strange variable tricks we are about to play.
6524 if (scalar keys %contents > 0)
6526 print STDERR "automake: programming error: variable defined before read_main_am_file\n";
6530 # We want to predefine as many variables as possible. This lets
6531 # the user set them with `+=' in Makefile.am. However, we don't
6532 # want these initial definitions to end up in the output quite
6533 # yet. So we adopt a hack: read the `.am' file twice, throwing
6534 # away the output the first time. We also squirrel away a list of
6535 # all the variables defined by the .am file so that we know which
6536 # ones to remove from the content list.
6539 &define_standard_variables;
6540 local (%saved_contents) = %contents;
6542 # Read user file, but discard text of variable assignments we just
6545 &read_am_file ($amfile);
6547 # Now dump the variables that were defined. We do it in the same
6548 # order in which they were defined (skipping duplicates).
6550 foreach $curs (@var_list)
6552 next if $done{$curs};
6555 $output_vars .= $am_vars{$curs};
6556 if ($conditional{$curs})
6558 local (@cond_vals) = split (' ', $conditional{$curs});
6561 local ($vcond) = shift (@cond_vals);
6562 local ($val) = &unquote_cond_val (shift (@cond_vals));
6563 $output_vars .= ($vcond . $curs . ' '
6564 . $def_type{$curs} . "= ");
6566 foreach $line (split ("\n", $val))
6568 $output_vars .= $vcond . $line . "\n";
6570 $output_vars .= "\n"
6576 $output_vars .= ($curs . ' ' . $def_type{$curs} . '= '
6577 . $contents{$curs} . "\n");
6581 # Generate copyright header for generated Makefile.in.
6582 local ($ov) = $output_vars;
6583 $output_vars = ("# $in_file_name generated automatically by automake "
6584 . $VERSION . " from $am_file_name\n");
6585 $output_vars .= $gen_copyright;
6587 # Now go through and delete all the variables that the user did
6590 foreach $var (keys %saved_contents)
6592 if ($contents{$var} eq $saved_contents{$var})
6594 delete $contents{$var};
6598 # Re-read the standard variables, and this time keep their
6599 # contributions to the output. Then add the user's output to the
6601 &define_standard_variables;
6602 $output_vars .= $ov;
6606 ################################################################
6608 sub initialize_global_constants
6610 # Values for AC_CANONICAL_*
6611 $AC_CANONICAL_HOST = 1;
6612 $AC_CANONICAL_SYSTEM = 2;
6614 # Associative array of standard directory names. Entry is TRUE if
6615 # corresponding directory should be installed during
6616 # 'install-exec' phase.
6634 # Commonly found files we look for and automatically include in
6638 "README", "THANKS", "TODO", "NEWS", "COPYING", "COPYING.LIB",
6639 "INSTALL", "ABOUT-NLS", "ChangeLog", "configure", "configure.in",
6640 "config.guess", "config.sub", "AUTHORS", "BACKLOG", "ABOUT-GNU",
6641 "libversion.in", "mdate-sh", "mkinstalldirs", "install-sh",
6642 'texinfo.tex', "ansi2knr.c", "ansi2knr.1", 'elisp-comp',
6643 'ylwrap', 'acinclude.m4', @libtoolize_files,
6644 'missing', 'depcomp', 'compile', 'py-compile'
6647 # Commonly used files we auto-include, but only sometimes.
6650 "aclocal.m4", "acconfig.h", "config.h.top",
6651 "config.h.bot", "stamp-h.in", 'stamp-vti'
6655 -a, --add-missing add missing standard files to package
6656 --amdir=DIR directory storing config files
6657 -c, --copy with -a, copy missing files (default is symlink)
6658 --cygnus assume program is part of Cygnus-style tree
6659 --force-missing force update of standard files
6660 --foreign set strictness to foreign
6661 --gnits set strictness to gnits
6662 --gnu set strictness to gnu
6663 --help print this help, then exit
6664 -i, --ignore-deps disable dependency tracking code
6665 --include-deps enable dependency tracking code
6666 --no-force only update Makefile.in's that are out of date
6667 -o DIR, --output-dir=DIR
6668 put generated Makefile.in's into DIR
6669 -v, --verbose verbosely list files processed
6670 --version print version number, then exit\n";
6672 # Copyright on generated Makefile.ins.
6674 # Copyright (C) 1994, 1995-9, 2000 Free Software Foundation, Inc.
6675 # This Makefile.in is free software; the Free Software Foundation
6676 # gives unlimited permission to copy and/or distribute it,
6677 # with or without modifications, as long as this notice is preserved.
6679 # This program is distributed in the hope that it will be useful,
6680 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
6681 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
6682 # PARTICULAR PURPOSE.
6685 # This complex find command will try to avoid changing the modes of
6686 # links into the source tree, in case they're hard-linked. It will
6687 # also make directories writable by everybody, because some
6688 # brain-dead tar implementations change ownership and permissions of
6689 # a directory before extracting the files, thus becoming unable to
6691 # Ignore return result from chmod, because it might give an error
6692 # if we chmod a symlink.
6693 # Another nastiness: if the file is unreadable by us, we make it
6694 # readable regardless of the number of links to it. This only
6695 # happens in perverse cases.
6696 # We use $(install_sh) because that is a known-portable way to
6697 # modify the file in place in the source tree.
6698 $dist_header = ' -find $(distdir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \\
6699 ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \\
6700 ! -type d ! -perm -400 -exec chmod a+r {} \; -o \\
6701 ! -type d ! -perm -444 -exec $(SHELL) $(install_sh) -c -m a+r {} {} \; \\
6702 || chmod -R a+r $(distdir)
6704 $dist{'dist-bzip2'} = ("\t"
6705 . '$(AMTAR) chof - $(distdir) | bzip2 -9 -c > $(distdir).bz2'
6707 $dist{'dist-tarZ'} = ("\t"
6708 . '$(AMTAR) chof - $(distdir) | compress -c > $(distdir).tar.Z'
6710 $dist{'dist-shar'} = ("\t"
6711 . 'shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c > $(distdir).shar.gz'
6713 $dist{'dist-zip'} = ("\t" . '-rm -f $(distdir).zip' . "\n" .
6714 "\t" . 'zip -rq $(distdir).zip $(distdir)' . "\n");
6716 # Note that we don't use GNU tar's `-z' option. One reason (but
6717 # not the only reason) is that some versions of tar (e.g., OSF1)
6718 # interpret `-z' differently.
6719 $dist{'dist'} = ("\t"
6720 . '$(AMTAR) chof - $(distdir) | GZIP=$(GZIP_ENV) gzip -c > $(distdir).tar.gz'
6722 $dist_trailer = "\t" . '-chmod -R a+w $(distdir) > /dev/null 2>&1; rm -rf $(distdir)' . "\n";
6725 # (Re)-Initialize per-Makefile.am variables.
6726 sub initialize_per_input
6728 # These two variables are used when generating each Makefile.in.
6729 # They hold the Makefile.in until it is ready to be printed.
6732 $output_trailer = '';
6734 $output_header = '';
6736 # Suffixes found during a run.
6739 # This holds the contents of a Makefile.am, as parsed by
6743 # This holds the names which are targets. These also appear in
6747 # This maps a variable name onto a flag. The flag is true iff the
6748 # variable was first defined with `+='.
6749 %var_was_plus_eq = ();
6751 # This holds definitions of all variables defined in .am files.
6752 # This is used during startup to determine which variables can be
6753 # assigned with `+='.
6756 # For a variable or target which is defined conditionally, this
6757 # holds an array of the conditional values. The array is composed
6758 # of pairs of condition strings (the variables which configure
6759 # will substitute) and values (the value of a target is
6760 # meaningless). For an unconditional variable, this is empty.
6763 # This holds the line numbers at which various elements of
6764 # %contents are defined.
6765 %content_lines = ();
6767 # This holds a 1 if a particular variable was examined.
6770 # This is the conditional stack.
6771 @conditional_stack = ();
6773 # This holds the set of included files.
6774 @include_stack = ();
6776 # This holds the "relative directory" of the current Makefile.in.
6777 # Eg for src/Makefile.in, this is "src".
6780 # This holds a list of files that are included in the
6784 # List of dependencies for the obvious targets.
6800 # A list of files deleted by `maintainer-clean'.
6801 @maintainer_clean_files = ();
6803 # These are pretty obvious, too. They are used to define the
6804 # SOURCES and OBJECTS variables.
6807 # Sources which go in the distribution.
6810 # This hash maps object file names onto their corresponding source
6811 # file names. This is used to ensure that each object is created
6812 # by a single source file.
6815 # This keeps track of the directories for which we've already
6816 # created `.dirstamp' code.
6817 %directory_map = ();
6819 # These variables track inclusion of various compile-related .am
6820 # files. $included_generic_compile is TRUE if the basic code has
6821 # been included. $included_knr_compile is TRUE if the ansi2knr
6822 # code has been included. $included_libtool_compile is TRUE if
6823 # libtool support has been included.
6824 $included_generic_compile = 0;
6825 $included_knr_compile = 0;
6826 $included_libtool_compile = 0;
6828 # TRUE if install targets should work recursively.
6829 $recursive_install = 0;
6834 # Strictness levels.
6835 $strictness = $default_strictness;
6836 $strictness_name = $default_strictness_name;
6838 # Options from AUTOMAKE_OPTIONS.
6841 # Whether or not dependencies are handled. Can be further changed
6842 # in handle_options.
6843 $use_dependencies = $cmdline_use_dependencies;
6846 $local_maint_charset = $maint_charset;
6848 # All yacc and lex source filenames for this directory. Use
6849 # filenames instead of raw count so that multiple instances are
6850 # counted correctly (eg one yacc file can appear in multiple
6851 # programs without harm).
6855 # This is a list of all targets to run during "make dist".
6858 # Keys in this hash are the basenames of files which must depend
6860 %de_ansi_files = ();
6862 # This maps the source extension of a suffix rule to its
6863 # corresponding output extension.
6866 # This is a regular expression which matches all the known source
6867 # suffix. A source suffix is one that appears in the first
6868 # position of a suffix rule.
6869 $source_suffix_pattern = '';
6871 # This is the name of the recursive `all' target to use.
6872 $all_target = 'all-recursive';
6874 # This keeps track of which extensions we've seen (that we care
6876 %extension_seen = ();
6878 # This is random scratch space for the language finish functions.
6879 # Don't randomly overwrite it; examine other uses of keys first.
6880 %language_scratch = ();
6882 # We keep track of which objects need special (per-executable)
6883 # handling on a per-language basis.
6884 %lang_specific_files = ();
6886 # This is set when `handle_dist' has finished. Once this happens,
6887 # we should no longer push on dist_common.
6888 $handle_dist_run = 0;
6892 ################################################################
6894 # Return contents of a file from $am_dir, automatically skipping
6895 # macros or rules which are already known. Runs command on each line
6896 # as it is read; this command can modify $_.
6897 sub file_contents_with_transform
6899 local ($command, $basename) = @_;
6900 local ($file) = $am_dir . '/' . $basename . '.am';
6902 if ($command ne '' && substr ($command, -1) ne ';')
6904 die "automake: programming error in file_contents_with_transform: $command\n";
6907 open (FC_FILE, $file)
6908 || die "automake: installation error: cannot open \`$file'\n";
6910 # print "automake: reading $file\n" if $verbose;
6912 local ($was_rule) = 0;
6913 local ($result_vars) = '';
6914 local ($result_rules) = '';
6915 local ($comment) = '';
6916 local ($spacing) = "\n";
6917 local ($skipping) = 0;
6922 $_ =~ s/\@MAINTAINER_MODE_TRUE\@//g
6923 unless $seen_maint_mode;
6925 $had_chars = length ($_) && $_ ne "\n";
6927 # If the transform caused all the characters to go away, then
6928 # ignore the line. Why do this? Because in Perl 4, a "next"
6929 # inside of an eval doesn't affect a loop outside the eval.
6930 # So we can't pass in a "transform" that uses next. We used
6931 # to do this. "Empty" also means consisting of a single
6933 next if $had_chars && ($_ eq '' || $_ eq "\n");
6935 if (/$IGNORE_PATTERN/o)
6937 # Merely delete comments beginning with two hashes.
6939 elsif (/$WHITE_PATTERN/o)
6941 # Stick a single white line before the incoming macro or rule.
6943 &am_line_error ($., "blank line following trailing backslash")
6946 elsif (/$COMMENT_PATTERN/o)
6948 # Stick comments before the incoming macro or rule.
6949 $comment .= $spacing . $_;
6951 &am_line_error ($., "comment following trailing backslash")
6958 $result_rules .= $_ if ! $skipping;
6962 $result_vars .= $_ if ! $skipping;
6966 elsif (/$RULE_PATTERN/o)
6970 $skipping = defined $contents{$1};
6971 $result_rules .= $comment . $spacing . $_ if ! $skipping;
6972 $comment = $spacing = '';
6975 elsif (/$MACRO_PATTERN/o)
6977 # Found a variable reference.
6979 $skipping = defined $contents{$1};
6980 $result_vars .= $comment . $spacing . $_ if ! $skipping;
6981 $comment = $spacing = '';
6983 print STDERR "automake: programming error: .am macro \`$1' with trailing backslash\n"
6985 $am_var_defs{$1} = $3;
6989 # This isn't an error; it is probably a continued rule.
6990 # In fact, this is what we assume.
6992 $result_rules .= $comment . $spacing . $_ if ! $skipping;
6993 $comment = $spacing = '';
6999 return $result_vars . $result_rules . $comment;
7002 # Like file_contents_with_transform, but no transform.
7005 return &file_contents_with_transform ('', @_);
7008 # Find all variable prefixes that are used for install directories. A
7009 # prefix `zar' qualifies iff:
7010 # * `zardir' is a variable.
7011 # * `zar_PRIMARY' is a variable.
7012 sub am_primary_prefixes
7014 local ($primary, $can_dist, @prefixes) = @_;
7016 local (%valid, $varname);
7017 grep ($valid{$_} = 0, @prefixes);
7018 $valid{'EXTRA'} = 0;
7019 foreach $varname (keys %contents)
7021 if ($varname =~ /^(nobase_)?(dist_|nodist_)?(.*)_$primary$/)
7023 if (($2 ne '' && ! $can_dist)
7024 || (! defined $valid{$3}
7025 && ! &variable_defined ($3 . 'dir')
7026 # Note that a configure variable is always
7027 # legitimate. It is natural to name such
7028 # variables after the primary, so we explicitly
7030 && ! defined $configure_vars{$varname}))
7032 &am_line_error ($varname, "invalid variable \`$varname'");
7036 # Ensure all extended prefixes are actually used.
7037 $valid{$1 . $2 . $3} = 1;
7045 # Handle `where_HOW' variable magic. Does all lookups, generates
7046 # install code, and possibly generates code to define the primary
7047 # variable. The first argument is the name of the .am file to munge,
7048 # the second argument is the primary variable (eg HEADERS), and all
7049 # subsequent arguments are possible installation locations. Returns
7050 # list of all values of all _HOW targets.
7052 # FIXME: this should be rewritten to be cleaner. It should be broken
7053 # up into multiple functions.
7055 # Usage is: am_install_var (OPTION..., file, HOW, where...)
7060 local ($do_clean) = 0;
7061 local ($do_require) = 1;
7062 local ($can_dist) = 0;
7063 local ($default_dist) = 0;
7066 if (defined $configure_vars{'LIBTOOL'})
7068 # Transform '@LIBTOOL ...@' to '$(LIBTOOL) ...'
7069 $ltxform = 's/\@LIBTOOL([^\@]*)\@/\$(LIBTOOL) $1/;';
7073 # Delete '@LIBTOOL ...@'
7074 $ltxform = 's/\@LIBTOOL([^\@]*)\@//;';
7080 $cygxform = 's/\@EXEEXT\@//g;';
7084 $cygxform = 's/\@EXEEXT\@/\$(EXEEXT)/g;';
7089 if ($args[0] eq '-clean')
7093 elsif ($args[0] eq '-noextra')
7097 elsif ($args[0] eq '-candist')
7101 elsif ($args[0] eq '-defaultdist')
7106 elsif ($args[0] !~ /^-/)
7113 local ($file, $primary, @prefixes) = @args;
7116 local (@result) = ();
7118 # Now that configure substitutions are allowed in where_HOW
7119 # variables, it is an error to actually define the primary. We
7120 # allow `JAVA', as it is customarily used to mean the Java
7121 # interpreter. This is but one of several Java hacks. Similarly,
7122 # `PYTHON' is customarily used to mean the Python interpreter.
7123 &am_line_error ($primary, "\`$primary' is an anachronism")
7124 if &variable_defined ($primary)
7125 && ($primary ne 'JAVA' && $primary ne 'PYTHON');
7128 # Look for misspellings. It is an error to have a variable ending
7129 # in a "reserved" suffix whose prefix is unknown, eg
7130 # "bni_PROGRAMS". However, unusual prefixes are allowed if a
7131 # variable of the same name (with "dir" appended) exists. For
7132 # instance, if the variable "zardir" is defined, then
7133 # "zar_PROGRAMS" becomes valid. This is to provide a little extra
7134 # flexibility in those cases which need it.
7135 local (%valid) = &am_primary_prefixes ($primary, $can_dist, @prefixes);
7137 # If a primary includes a configure substitution, then the EXTRA_
7138 # form is required. Otherwise we can't properly do our job.
7139 local ($require_extra);
7140 local ($warned_about_extra) = 0;
7142 local ($clean_file) = $file . '-clean';
7145 local ($nodir_name);
7146 local ($strip_subdir) = 1;
7147 foreach $X (sort keys %valid)
7149 $one_name = $X . '_' . $primary;
7150 if (&variable_defined ($one_name))
7152 # If subdir prefix should be preserved, do so.
7153 if ($X =~ /^nobase_/)
7159 # If files should be distributed, do so.
7162 if (($default_dist && $one_name !~ /^nodist_/)
7163 || (! $default_dist && $one_name =~ /^dist_/))
7165 &push_dist_common ('$(' . $one_name . ')');
7167 ($nodir_name = $X) =~ s/^(dist|nodist)_//;
7174 # Append actual contents of where_PRIMARY variable to
7177 foreach $rcurs (&variable_value_as_list ($one_name, 'all'))
7179 # Skip configure substitutions. Possibly bogus.
7180 if ($rcurs =~ /^\@.*\@$/)
7184 if (! $warned_about_extra)
7186 $warned_about_extra = 1;
7188 &am_line_error ($one_name,
7189 "\`$one_name' contains configure substitution, but shouldn't");
7193 # Check here to make sure variables defined in
7194 # configure.in do not imply that EXTRA_PRIMARY
7196 elsif (! defined $configure_vars{$one_name})
7198 $require_extra = $one_name
7205 push (@result, $rcurs);
7208 # "EXTRA" shouldn't be used when generating clean targets,
7209 # all, or install targets.
7212 # We used to warn if EXTRA_FOO was defined uselessly,
7213 # but this was annoying.
7217 # A blatant hack: we rewrite each _PROGRAMS primary to
7218 # include EXEEXT when in Cygwin32 mode.
7219 if ($seen_exeext && $primary eq 'PROGRAMS')
7221 local (@conds) = &variable_conditions ($one_name);
7222 local (@one_binlist);
7224 # FIXME: this definitely loses aesthetically; it
7225 # redefines $ONE_NAME. Instead we should arrange for
7226 # variable definitions to be output later, instead of
7232 foreach $rcurs (&variable_value_as_list ($one_name, ''))
7234 if ($rcurs =~ /\./ || $rcurs =~ /^\@.*\@$/)
7236 push (@one_binlist, $rcurs);
7240 push (@one_binlist, $rcurs . '$(EXEEXT)');
7244 delete $contents{$one_name};
7245 &define_pretty_variable ($one_name, '', @one_binlist);
7250 local ($condvals) = '';
7251 foreach $cond (@conds)
7254 local (@condval) = &variable_value_as_list ($one_name,
7256 foreach $rcurs (@condval)
7258 if ($rcurs =~ /\./ || $rcurs =~ /^\@.*\@$/)
7260 push (@one_binlist, $rcurs);
7264 push (@one_binlist, $rcurs . '$(EXEEXT)');
7268 push (@condvals, $cond);
7269 push (@condvals, join (' ', @one_binlist));
7272 delete $contents{$one_name};
7276 $cond = shift (@condvals);
7277 local (@val) = split (' ', shift (@condvals));
7278 &define_pretty_variable ($one_name, $cond, @val);
7286 &file_contents_with_transform ('s/\@DIR\@/' . $X . '/go;'
7290 push (@clean, $X . $primary);
7291 &push_phony_cleaners ($X . $primary);
7296 push (@check, '$(' . $one_name . ')');
7300 push (@used, '$(' . $one_name . ')');
7302 if ($X eq 'noinst' || $X eq 'check')
7304 # Objects which don't get installed by default.
7308 local ($subdir_xform);
7311 $subdir_xform = 's/^NOBASE.*$//; s/^BASE//;';
7315 $subdir_xform = 's/^BASE.*$//; s/^NOBASE//;';
7319 &file_contents_with_transform ('s/\@DIR\@/' . $X . '/g;'
7320 . 's/\@NDIR\@/' . $nodir_name . '/go;'
7321 . $ltxform . $cygxform
7325 push (@uninstall, 'uninstall-' . $X . $primary);
7326 push (@phony, 'uninstall-' . $X . $primary);
7327 push (@installdirs, '$(DESTDIR)$(' . $X . 'dir)');
7328 if (defined $exec_dir_p{$X} ? $exec_dir_p{$X} : ($X =~ /exec/))
7330 push (@install_exec, 'install-' . $X . $primary);
7331 push (@phony, 'install-' . $X . $primary);
7335 push (@install_data, 'install-' . $X . $primary);
7336 push (@phony, 'install-' . $X . $primary);
7341 # The JAVA variable is used as the name of the Java interpreter.
7342 # The PYTHON variable is used as the name of the Python interpreter.
7343 if (@used && $primary ne 'JAVA' && $primary ne 'PYTHON')
7346 &define_pretty_variable ($primary, '', @used);
7347 $output_vars .= "\n";
7350 if ($require_extra && ! &variable_defined ('EXTRA_' . $primary))
7352 &am_line_error ($require_extra,
7353 "\`$require_extra' contains configure substitution, but \`EXTRA_$primary' not defined");
7356 # Push here because PRIMARY might be configure time determined.
7357 push (@all, '$(' . $primary . ')')
7358 if @used && $primary ne 'JAVA' && $primary ne 'PYTHON';
7360 # Make the result unique. This lets the user use conditionals in
7361 # a natural way, but still lets us program lazily -- we don't have
7362 # to worry about handling a particular object more than once.
7363 local (%uniquify) = ();
7364 grep ($uniquify{$_} = 1, @result);
7365 return sort keys %uniquify;
7369 ################################################################
7371 # Each key in this hash is the name of a directory holding a
7372 # Makefile.in. These variables are local to `is_make_dir'.
7379 if (! $make_dirs_set)
7381 foreach $iter (@configure_input_files)
7383 $make_dirs{&dirname ($iter)} = 1;
7385 # We also want to notice Makefile.in's.
7386 foreach $iter (@other_input_files)
7388 if ($iter =~ /Makefile\.in$/)
7390 $make_dirs{&dirname ($iter)} = 1;
7395 return defined $make_dirs{$dir};
7398 ################################################################
7400 # This variable is local to the "require file" set of functions.
7401 @require_file_paths = ();
7403 # If a file name appears as a key in this hash, then it has already
7404 # been checked for. This variable is local to the "require file"
7406 %require_file_found = ();
7408 # See if we want to push this file onto dist_common. This function
7409 # encodes the rules for deciding when to do so.
7410 sub maybe_push_required_file
7412 local ($dir, $file, $fullfile) = @_;
7414 # FIXME: Once again, special-case `.'.
7415 if ($dir eq $relative_dir || $dir eq '.')
7417 &push_dist_common ($file);
7419 elsif ($relative_dir eq '.' && ! &is_make_dir ($dir))
7421 # If we are doing the topmost directory, and the file is in a
7422 # subdir which does not have a Makefile, then we distribute it
7424 &push_dist_common ($fullfile);
7428 # Verify that the file must exist in the current directory. Usage:
7429 # require_file (isconfigure, line_number, strictness, file) strictness
7430 # is the strictness level at which this file becomes required. Must
7431 # set require_file_paths before calling this function.
7432 # require_file_paths is set to hold a single directory (the one in
7433 # which the first file was found) before return.
7434 sub require_file_internal
7436 local ($is_configure, $line, $mystrict, @files) = @_;
7437 local ($file, $fullfile);
7438 local ($found_it, $dangling_sym, $errfile, $errdir);
7441 foreach $file (@files)
7443 # If we've already looked for it, we're done.
7444 next if defined $require_file_found{$file};
7445 $require_file_found{$file} = 1;
7449 foreach $dir (@require_file_paths)
7453 $fullfile = $relative_dir . "/" . $file;
7454 $errdir = $relative_dir unless $errdir;
7458 $fullfile = $dir . "/" . $file;
7459 $errdir = $dir unless $errdir;
7462 # Use different name for "error filename". Otherwise on
7463 # an error the bad file will be reported as eg
7464 # `../../install-sh' when using the default
7466 $errfile = $errdir . '/' . $file;
7468 if (-l $fullfile && ! -f readlink ($fullfile))
7473 elsif (-f $fullfile)
7476 &maybe_push_required_file ($dir, $file, $fullfile);
7482 if ($found_it && ! $force_missing)
7484 # Prune the path list.
7485 @require_file_paths = $save_dir;
7489 if ($strictness >= $mystrict)
7491 if ($dangling_sym && ($force_missing || $add_missing))
7496 local ($trailer) = '';
7497 local ($suppress) = 0;
7499 # Only install missing files according to our desired
7501 local ($message) = "required file \`$errfile' not found";
7506 # Maybe run libtoolize.
7508 && grep ($_ eq $file, @libtoolize_files)
7509 && system ('libtoolize', '--automake'))
7511 $message = "installing \`$errfile'";
7513 $trailer = "; cannot run \`libtoolize': $!";
7515 elsif (-f ($am_dir . '/' . $file))
7517 # Install the missing file. Symlink if we
7518 # can, copy if we must. Note: delete the file
7519 # first, in case it is a dangling symlink.
7520 $message = "installing \`$errfile'";
7521 # Windows Perl will hang if we try to delete a
7522 # file that doesn't exist.
7523 unlink ($errfile) if -f $errfile;
7524 if ($symlink_exists && ! $copy_missing)
7526 if (! symlink ($am_dir . '/' . $file, $errfile))
7529 $trailer = "; error while making link: $!";
7532 elsif (system ('cp', $am_dir . '/' . $file, $errfile))
7535 $trailer = "\n error while copying";
7539 &maybe_push_required_file (&dirname ($errfile),
7540 $errfile, $errfile);
7543 local ($save) = $exit_status;
7546 # FIXME: allow actual file to be specified.
7547 &am_conf_line_error ('configure.in', $line,
7548 "$message$trailer");
7552 &am_line_error ($line, "$message$trailer");
7554 $exit_status = $save if $suppress;
7560 # Like require_file_with_line, but error messages refer to
7561 # configure.in, not the current Makefile.am.
7562 sub require_file_with_conf_line
7564 @require_file_paths = '.';
7565 &require_file_internal (1, @_);
7568 sub require_file_with_line
7570 @require_file_paths = '.';
7571 &require_file_internal (0, @_);
7576 @require_file_paths = '.';
7577 &require_file_internal (0, '', @_);
7580 # Require a file that is also required by Autoconf. Looks in
7581 # configuration path, as specified by AC_CONFIG_AUX_DIR.
7582 sub require_config_file
7584 @require_file_paths = @config_aux_path;
7585 &require_file_internal (1, '', @_);
7586 local ($dir) = $require_file_paths[0];
7587 @config_aux_path = @require_file_paths;
7590 $config_aux_dir = '.';
7594 $config_aux_dir = '$(top_srcdir)/' . $dir;
7598 # Assumes that the line number is in Makefile.am.
7599 sub require_conf_file_with_line
7601 @require_file_paths = @config_aux_path;
7602 &require_file_internal (0, @_);
7603 local ($dir) = $require_file_paths[0];
7604 @config_aux_path = @require_file_paths;
7607 $config_aux_dir = '.';
7611 $config_aux_dir = '$(top_srcdir)/' . $dir;
7615 # Assumes that the line number is in configure.in.
7616 sub require_conf_file_with_conf_line
7618 @require_file_paths = @config_aux_path;
7619 &require_file_internal (1, @_);
7620 local ($dir) = $require_file_paths[0];
7621 @config_aux_path = @require_file_paths;
7624 $config_aux_dir = '.';
7628 $config_aux_dir = '$(top_srcdir)/' . $dir;
7632 ################################################################
7634 # Push a list of files onto dist_common.
7635 sub push_dist_common
7637 local (@files) = @_;
7640 foreach $file (@files)
7642 if (! defined $dist_common{$file})
7644 if ($handle_dist_run)
7647 "automake: programming error: push_dist_common run after handle_dist\n";
7650 $dist_common{$file} = 1;
7655 # Push a list of clean targets onto phony.
7656 sub push_phony_cleaners
7660 foreach $target ('mostly', 'dist', '', 'maintainer-')
7662 push (@phony, $target . 'clean-' . $base);
7669 $strictness_name = $_[0];
7670 if ($strictness_name eq 'gnu')
7674 elsif ($strictness_name eq 'gnits')
7676 $strictness = $GNITS;
7678 elsif ($strictness_name eq 'foreign')
7680 $strictness = $FOREIGN;
7684 die "automake: level \`$strictness_name' not recognized\n";
7689 ################################################################
7691 # Return directory name of file.
7697 ($sub = $file) =~ s,/+[^/]+$,,g;
7698 $sub = '.' if $sub eq $file;
7702 # Return file name of a file.
7708 ($sub = $file) =~s,^.*/+,,g;
7712 # Ensure a file exists.
7717 open (TOUCH, ">> $file");
7721 # Glob something. Do this to avoid indentation screwups everywhere we
7722 # want to glob. Gross!
7729 ################################################################
7731 # Print an error message and set exit status.
7734 warn "automake: ${am_file}.am: ", join (' ', @_), "\n";
7740 local ($symbol, @args) = @_;
7742 if ($symbol && "$symbol" ne '-1')
7744 local ($file) = "${am_file}.am";
7746 if ($symbol =~ /^\d+$/)
7748 # SYMBOL is a line number, so just add the colon.
7749 $file .= ':' . $symbol;
7751 elsif (defined $content_lines{$symbol})
7753 # SYMBOL is a variable defined in Makefile.am, so add the
7754 # line number we saved from there.
7755 $file .= ':' . $content_lines{$symbol};
7757 elsif (defined $configure_vars{$symbol})
7759 # SYMBOL is a variable defined in configure.in, so add the
7760 # appropriate line number.
7761 $file = $configure_vars{$symbol};
7765 # Couldn't find the line number.
7767 warn $file, ": ", join (' ', @args), "\n";
7776 # Like am_error, but while scanning configure.in.
7779 # FIXME: can run in subdirs.
7780 warn "automake: configure.in: ", join (' ', @_), "\n";
7784 # Error message with line number referring to configure.in.
7785 sub am_conf_line_error
7787 local ($file, $line, @args) = @_;
7791 warn "$file: $line: ", join (' ', @args), "\n";
7796 &am_conf_error (@args);
7800 # Warning message with line number referring to configure.in.
7801 # Does not affect exit_status
7802 sub am_conf_line_warning
7804 local ($saved_exit_status) = $exit_status;
7805 &am_conf_line_error (@_);
7806 $exit_status = $saved_exit_status;
7809 # Tell user where our aclocal.m4 is, but only once.
7810 sub keyed_aclocal_warning
7813 warn "automake: macro \`$key' can be generated by \`aclocal'\n";
7816 # Print usage information.
7819 print "Usage: automake [OPTION] ... [Makefile]...\n\n";
7820 print "Generate Makefile.in for autoconf from Makefile.am\n";
7822 print "\nFiles which are automatically distributed, if found:\n";
7823 $~ = "USAGE_FORMAT";
7824 local ($last, $iter, @lcomm);
7826 foreach $iter (sort ((@common_files, @common_sometimes)))
7828 push (@lcomm, $iter) unless $iter eq $last;
7832 local ($one, $two, $three, $four, $i, $max);
7833 $max = int (($#lcomm + 1) / 4);
7835 for ($i = 0; $i < $max; ++$i)
7838 $two = $lcomm[$max + $i];
7839 $three = $lcomm[2 * $max + $i];
7840 $four = $lcomm[3 * $max + $i];
7844 local ($mod) = ($#lcomm + 1) % 4;
7847 $one = $lcomm[$max];
7848 $two = ($mod > 1) ? $lcomm[2 * $max] : '';
7849 $three = ($mod > 2) ? $lcomm[3 * $max] : '';
7850 $four = ($mod > 3) ? $lcomm[4 * $max] : '';
7854 print "\nReport bugs to <bug-automake\@gnu.org>.\n";
7859 format USAGE_FORMAT =
7860 @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<
7861 $one, $two, $three, $four