5 eval 'exec @PERL@ -S $0 ${1+"$@"}'
8 # automake - create Makefile.in from Makefile.am
9 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999 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-Z]+)\\.([a-zA-Z]+)\$";
43 $MACRO_PATTERN = "^([A-Za-z][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 GNU make specific automatic dependency generation
93 # code should be included in generated Makefile.in.
94 $cmdline_use_dependencies = 1;
96 # This is the name of a dependency makefile bit (usually for inclusion in a
97 # SMakefile or similar); empty if not set.
100 # TRUE if in verbose mode.
103 # This holds our (eventual) exit status. We don't actually exit until
104 # we have processed all input files.
107 # From the Perl manual.
108 $symlink_exists = (eval 'symlink ("", "");', $@ eq '');
110 # TRUE if missing standard files should be installed.
113 # TRUE if we should copy missing files; otherwise symlink if possible.
116 # Files found by scanning configure.in for LIBOBJS.
119 # True if AM_C_PROTOTYPES appears in configure.in.
120 $am_c_prototypes = 0;
122 # Names used in AC_CONFIG_HEADER call. @config_fullnames holds the
123 # name which appears in AC_CONFIG_HEADER, colon and all.
124 # @config_names holds the file names. @config_headers holds the '.in'
125 # files. Ordinarily these are similar, but they can be different if
126 # the weird "NAME:FILE" syntax is used.
127 @config_fullnames = ();
129 @config_headers = ();
130 # Line number at which AC_CONFIG_HEADER appears in configure.in.
131 $config_header_line = 0;
133 # Directory where output files go. Actually, output files are
134 # relative to this directory.
135 $output_directory = '.';
137 # Relative location of top build directory.
140 # Absolute location of top build directory.
141 $build_directory = '';
143 # Name of srcdir as given in build directory's Makefile. For
147 # List of Makefile.am's to process, and their corresponding outputs.
151 # Complete list of Makefile.am's that exist.
152 @configure_input_files = ();
154 # List of files in AC_OUTPUT without Makefile.am, and their outputs.
155 @other_input_files = ();
156 # Line number at which AC_OUTPUT seen.
159 # List of directories to search for configure-required files. This
160 # can be set by AC_CONFIG_AUX_DIR.
161 @config_aux_path = ('.', '..', '../..');
162 $config_aux_dir = '';
164 # Whether AC_PROG_MAKE_SET has been seen in configure.in.
167 # Whether AM_GNU_GETTEXT has been seen in configure.in.
169 # Line number at which AM_GNU_GETTEXT seen.
170 $ac_gettext_line = 0;
172 # Whether ALL_LINGUAS has been seen.
176 # Line number at which it appears.
177 $all_linguas_line = 0;
179 # 1 if AC_PROG_INSTALL seen.
180 $seen_prog_install = 0;
182 # Whether AC_PATH_XTRA has been seen in configure.in.
185 # TRUE if AC_DECL_YYTEXT was seen.
186 $seen_decl_yytext = 0;
188 # TRUE if we've seen AC_CANONICAL_(HOST|SYSTEM). The presence of
189 # AC_CHECK_TOOL also sets this.
192 # TRUE if we've seen AC_ARG_PROGRAM.
195 # TRUE if we've seen AC_PROG_LIBTOOL.
199 # Files installed by libtoolize.
200 @libtoolize_files = ('ltconfig', 'ltmain.sh', 'config.guess', 'config.sub');
202 # TRUE if we've seen AM_MAINTAINER_MODE.
203 $seen_maint_mode = 0;
205 # TRUE if we've seen PACKAGE and VERSION.
209 # Actual version we've seen.
210 $package_version = '';
212 # Line number where we saw version definition.
213 $package_version_line = 0;
215 # TRUE if we've seen AM_PATH_LISPDIR.
218 # TRUE if we've seen AC_EXEEXT.
221 # TRUE if we've seen AC_OBJEXT.
224 # TRUE if we've seen AC_ENABLE_MULTILIB.
227 # TRUE if we've seen AM_PROG_CC_C_O
230 # Hash table of discovered configure substitutions. Keys are names,
231 # values are `FILE:LINE' strings which are used by error message
233 %configure_vars = ();
235 # This is used to keep track of which variable definitions we are
236 # scanning. It is only used in certain limited ways, but it has to be
237 # global. It is declared just for documentation purposes.
240 # Charsets used by maintainer and in distribution. MAINT_CHARSET is
241 # handled in a funny way: if seen in the top-level Makefile.am, it is
242 # used for every directory which does not specify a different value.
243 # The rationale here is that some directories (eg gettext) might be
244 # distributions of other packages, and thus require their own charset
245 # info. However, the DIST_CHARSET must be the same for the entire
246 # package; it can only be set at top-level.
247 # FIXME: this yields bugs when rebuilding. What to do? Always
248 # read (and sometimes discard) top-level Makefile.am?
250 $dist_charset = 'utf8'; # recode doesn't support this yet.
252 # Name of input file ("Makefile.in") and output file ("Makefile.am").
253 # These have no directory components.
257 # TRUE if --cygnus seen.
260 # Keys of this hash are names of dependency files to ignore.
261 %omit_dependencies = ();
263 # Hash table of AM_CONDITIONAL variables seen in configure.
264 %configure_cond = ();
266 # Map from obsolete macros to hints for new macros.
267 # If you change this, change the corresponding list in aclocal.in.
268 # FIXME: should just put this into a single file.
271 'AC_FEATURE_CTYPE', "use \`AC_HEADER_STDC'",
272 'AC_FEATURE_ERRNO', "add \`strerror' to \`AC_REPLACE_FUNCS(...)'",
273 'AC_FEATURE_EXIT', '',
274 'AC_SYSTEM_HEADER', '',
276 # Note that we do not handle this one, because it is still run
277 # from AM_CONFIG_HEADER. So we deal with it specially in
279 # 'AC_CONFIG_HEADER', "use \`AM_CONFIG_HEADER'",
281 'fp_C_PROTOTYPES', "use \`AM_C_PROTOTYPES'",
282 'fp_PROG_CC_STDC', "use \`AM_PROG_CC_STDC'",
283 'fp_PROG_INSTALL', "use \`AC_PROG_INSTALL'",
284 'fp_WITH_DMALLOC', "use \`AM_WITH_DMALLOC'",
285 'fp_WITH_REGEX', "use \`AM_WITH_REGEX'",
286 'gm_PROG_LIBTOOL', "use \`AM_PROG_LIBTOOL'",
287 'jm_MAINTAINER_MODE', "use \`AM_MAINTAINER_MODE'",
288 'md_TYPE_PTRDIFF_T', "use \`AM_TYPE_PTRDIFF_T'",
289 'ud_PATH_LISPDIR', "use \`AM_PATH_LISPDIR'",
290 'ud_GNU_GETTEXT', "use \`AM_GNU_GETTEXT'",
292 # Now part of autoconf proper, under a different name.
293 'AM_FUNC_FNMATCH', "use \`AC_FUNC_FNMATCH'",
294 'fp_FUNC_FNMATCH', "use \`AC_FUNC_FNMATCH'",
295 'AM_SANITY_CHECK_CC', "automatically done by \`AC_PROG_CC'",
296 'AM_PROG_INSTALL', "use \`AC_PROG_INSTALL'",
297 'AM_EXEEXT', "use \`AC_EXEEXT'",
298 'AM_CYGWIN32', "use \`AC_CYGWIN32'",
299 'AM_MINGW32', "use \`AC_MINGW32'",
301 # These aren't quite obsolete.
305 # Regexp to match the above macros.
306 $obsolete_rx = '(' . join ('|', keys %obsolete_macros) . ')';
308 # This maps extensions onto language names.
311 # This maps languages names onto properties.
316 # Initialize global constants and our list of languages that are
317 # internally supported.
318 &initialize_global_constants;
320 ®ister_language ('c', 'ansi-p=1', 'autodep=',
322 ®ister_language ('cxx', 'linker=CXXLINK', 'autodep=CXX',
323 'c++', 'cc', 'cpp', 'cxx', 'C');
324 ®ister_language ('objc', 'linker=OBJCLINK', 'autodep=OBJC',
326 ®ister_language ('header',
327 'h', 'H', 'hxx', 'h++', 'hh', 'hpp', 'inc');
328 ®ister_language ('yacc', 'ansi-p=1',
330 ®ister_language ('yaccxx', 'linker=CXXLINK',
331 'y++', 'yy', 'yxx', 'ypp');
332 ®ister_language ('lex', 'ansi-p=1',
334 ®ister_language ('lexxx', 'linker=CXXLINK',
335 'l++', 'll', 'lxx', 'lpp');
336 ®ister_language ('asm',
338 ®ister_language ('f77', 'linker=F77LINK',
340 ®ister_language ('ppf77', 'linker=F77LINK',
342 ®ister_language ('ratfor', 'linker=F77LINK',
344 ®ister_language ('java', 'linker=GCJLINK', 'autodep=GCJ',
348 # Parse command line.
349 &parse_arguments (@ARGV);
351 # Do configure.in scan only once.
354 die "automake: no \`Makefile.am' found or specified\n"
357 # If --generate-deps was given, we don't do anything else
361 die "automake: Must specify --include-deps (or -i) when generating\n"
362 if $use_dependencies;
363 die "automake: Must provide --build-dir when generating\n"
364 if ! $build_directory;
365 die "automake: Must provide --srcdir-name when generating\n"
368 open (GDEP, ">$output_directory/.dep_segment")
369 || die "automake: Could not open `$output_directory/.dep_segment': $!\n";
371 &handle_dependencies;
372 print GDEP $output_rules;
378 # Now do all the work on each file.
379 foreach $am_file (@input_files)
381 if (! -f ($am_file . '.am'))
383 &am_error ("\`" . $am_file . ".am' does not exist");
387 &generate_makefile ($output_files{$am_file}, $am_file);
391 &am_conf_error ("AC_PROG_INSTALL must be used in configure.in")
392 if (! $seen_prog_install);
397 ################################################################
399 # Parse command line.
402 local (@arglist) = @_;
405 &set_strictness ('gnu');
409 if ($arglist[0] eq "--version")
411 print "automake (GNU $PACKAGE) $VERSION\n\n";
412 print "Copyright (C) 1999 Free Software Foundation, Inc.\n";
413 print "This is free software; see the source for copying conditions. There is NO\n";
414 print "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n";
415 print "Written by Tom Tromey <tromey\@cygnus.com>\n";
419 elsif ($arglist[0] eq "--help")
423 elsif ($arglist[0] =~ /^--amdir=(.+)$/)
427 elsif ($arglist[0] eq '--amdir')
429 &require_argument (@arglist);
431 $am_dir = $arglist[0];
433 elsif ($arglist[0] =~ /^--build-dir=(.+)$/)
436 $build_directory = $1 . '/';
438 elsif ($arglist[0] eq '--build-dir')
440 &require_argument (@arglist);
443 $build_directory = $arglist[0] . '/';
445 elsif ($arglist[0] =~ /^--srcdir-name=(.+)$/)
449 elsif ($arglist[0] eq '--srcdir-name')
451 &require_argument (@arglist);
453 $srcdir_name = $arglist[0];
455 elsif ($arglist[0] eq '--gnu')
457 &set_strictness ('gnu');
459 elsif ($arglist[0] eq '--gnits')
461 &set_strictness ('gnits');
463 elsif ($arglist[0] eq '--cygnus')
467 elsif ($arglist[0] eq '--foreign')
469 &set_strictness ('foreign');
471 elsif ($arglist[0] eq '--include-deps' || $arglist[0] eq '-i')
473 $cmdline_use_dependencies = 0;
475 elsif ($arglist[0] eq '--generate-deps')
479 elsif ($arglist[0] eq '--no-force')
481 $force_generation = 0;
483 elsif ($arglist[0] =~ /^--output-dir=(.*)$/)
485 # Set output directory.
486 $output_directory = $1;
488 elsif ($arglist[0] eq '--output-dir' || $arglist[0] eq '-o')
490 &require_argument (@arglist);
492 $output_directory = $arglist[0];
494 elsif ($arglist[0] eq '--add-missing' || $arglist[0] eq '-a')
498 elsif ($arglist[0] eq '--copy' || $arglist[0] eq '-c')
502 elsif ($arglist[0] eq '--verbose' || $arglist[0] eq '-v')
506 elsif ($arglist[0] eq '--')
508 # Stop option processing.
510 push (@input_files, @arglist);
513 elsif ($arglist[0] =~ /^-/)
515 die "automake: unrecognized option -- \`$arglist[0]'\nTry \`automake --help' for more information.\n";
519 # Handle $local:$input syntax. Note that we only examine
520 # the first ":" file to see if it is automake input; the
521 # rest are just taken verbatim. We still keep all the
522 # files around for dependency checking, however.
523 local ($local, $input, @rest) = split (/:/, $arglist[0]);
530 # Strip .in; later on .am is tacked on. That is how
531 # the automake input file is found. Maybe not the
532 # best way, but it is easy to explain. FIXME: should
533 # be error if .in is missing.
536 push (@input_files, $input);
537 $output_files{$input} = join (':', ($local, @rest));
543 # Take global strictness from whatever we currently have set.
544 $default_strictness = $strictness;
545 $default_strictness_name = $strictness_name;
548 # Ensure argument exists, or die.
551 local ($arg, @arglist) = @_;
552 die "automake: no argument given for option \`$arg'\n"
556 ################################################################
558 # Generate a Makefile.in given the name of the corresponding Makefile and
559 # the name of the file output by config.status.
560 sub generate_makefile
562 local ($output, $makefile) = @_;
564 ($am_file_name = $makefile) =~ s/^.*\///;
565 $in_file_name = $am_file_name . '.in';
566 $am_file_name .= '.am';
568 # $OUTPUT is encoded. If it contains a ":" then the first element
569 # is the real output file, and all remaining elements are input
570 # files. We don't scan or otherwise deal with these input file,
571 # other than to mark them as dependencies. See scan_configure for
573 local (@secondary_inputs);
574 ($output, @secondary_inputs) = split (/:/, $output);
576 &initialize_per_input;
577 $relative_dir = &dirname ($output);
578 $am_relative_dir = &dirname ($makefile);
580 # At the toplevel directory, we might need config.guess, config.sub
581 # or libtool scripts (ltconfig and ltmain.sh).
582 if ($relative_dir eq '.')
584 # libtool requires some files.
585 &require_conf_file_with_conf_line ($libtool_line, $FOREIGN,
589 # AC_CANONICAL_HOST and AC_CANONICAL_SYSTEM need config.guess and
591 &require_config_file ($FOREIGN, 'config.guess', 'config.sub')
595 # We still need Makefile.in here, because sometimes the `dist'
596 # target doesn't re-run automake.
597 if ($am_relative_dir eq $relative_dir)
599 # Only distribute the files if they are in the same subdir as
600 # the generated makefile.
601 &push_dist_common ($in_file_name, $am_file_name);
603 push (@sources, '$(SOURCES)')
604 if &variable_defined ('SOURCES');
605 push (@objects, '$(OBJECTS)')
606 if &variable_defined ('OBJECTS');
608 &read_main_am_file ($makefile . '.am');
611 # Fatal error. Just return, so we can continue with next file.
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);
647 &handle_minor_options;
648 &handle_dist ($makefile);
649 &handle_dependencies;
652 &handle_merge_targets ($output);
659 if (! -d ($output_directory . '/' . $am_relative_dir))
661 mkdir ($output_directory . '/' . $am_relative_dir, 0755);
664 local ($out_file) = $output_directory . '/' . $makefile . ".in";
665 if (! $force_generation && -e $out_file)
667 local ($am_time) = (stat ($makefile . '.am'))[9];
668 local ($in_time) = (stat ($out_file))[9];
669 # FIXME: should cache these times.
670 local ($conf_time) = (stat ('configure.in'))[9];
671 # FIXME: how to do unsigned comparison?
672 if ($am_time < $in_time || $am_time < $conf_time)
679 local ($acl_time) = (stat _)[9];
680 return if ($am_time < $acl_time);
684 if (! open (GM_FILE, "> " . $out_file))
686 warn "automake: ${am_file}.in: cannot write: $!\n";
690 print "automake: creating ", $makefile, ".in\n" if $verbose;
692 print GM_FILE $output_vars;
693 # We make sure that `all:' is the first target.
694 print GM_FILE $output_all;
695 print GM_FILE $output_header;
696 print GM_FILE $output_rules;
697 print GM_FILE $output_trailer;
702 ################################################################
704 # Handle AUTOMAKE_OPTIONS variable. Return 1 on error, 0 otherwise.
707 if (&variable_defined ('AUTOMAKE_OPTIONS'))
709 foreach (&variable_value_as_list ('AUTOMAKE_OPTIONS', ''))
712 if ($_ eq 'gnits' || $_ eq 'gnu' || $_ eq 'foreign')
714 &set_strictness ($_);
716 elsif ($_ eq 'cygnus')
722 # An option like "../lib/ansi2knr" is allowed. With
723 # no path prefix, we assume the required programs are
724 # in this directory. We save the actual option for
726 $options{'ansi2knr'} = $_;
728 elsif ($_ eq 'no-installman' || $_ eq 'no-installinfo'
729 || $_ eq 'dist-shar' || $_ eq 'dist-zip'
730 || $_ eq 'dist-tarZ' || $_ eq 'dist-bzip2'
731 || $_ eq 'dejagnu' || $_ eq 'no-texinfo.tex'
732 || $_ eq 'readme-alpha' || $_ eq 'check-news'
733 || $_ eq 'subdir-objects')
735 # Explicitly recognize these.
737 elsif ($_ eq 'no-dependencies')
739 $use_dependencies = 0;
741 elsif (/([0-9]+)\.([0-9]+)([a-z])?/)
743 # Got a version number.
745 local ($rmajor, $rminor, $ralpha) = ($1, $2, $3);
747 if ($VERSION !~ /([0-9]+)\.([0-9]+)([a-z])?/)
750 "automake: programming error: version is incorrect\n";
753 local ($tmajor, $tminor, $talpha) = ($1, $2, $3);
755 # 2.0 is better than 1.0.
756 # 1.2 is better than 1.1.
757 # 1.2a is better than 1.2.
758 if ($rmajor > $tmajor
759 || ($rmajor == $tmajor && $rminor > $tminor)
760 || ($rminor == $tminor && $rminor == $tminor
761 && $ralpha gt $talpha))
763 &am_line_error ('AUTOMAKE_OPTIONS',
764 "require version $_, only have $VERSION");
770 &am_line_error ('AUTOMAKE_OPTIONS',
771 "option \`" . $_ . "\' not recognized");
776 if ($strictness == $GNITS)
778 $options{'readme-alpha'} = 1;
779 $options{'check-news'} = 1;
785 # Return object extension. Just once, put some code into the output.
786 # Argument is the name of the output file
787 sub get_object_extension
791 # Maybe require libtool library object files.
792 local ($extension) = '.o';
793 $extension = '.$(OBJEXT)' if $seen_objext;
794 $extension = '.lo' if ($out =~ /\.la$/);
796 if (! $included_generic_compile)
800 if (&variable_defined ('CONFIG_HEADER'))
803 foreach $one_hdr (split (' ', &variable_value ('CONFIG_HEADER')))
806 ($var = &dirname ($one_hdr)) =~ s/(\W)/\\$1/g;
807 $xform .= ' ' if $xform;
808 $xform .= '-I' . $var;
811 $xform = 's/\@CONFIG_INCLUDE_SPEC\@/' . $xform . '/go;';
812 $output_vars .= &file_contents_with_transform ($xform,
815 $xform = (($use_dependencies
816 ? 's/^NOTDEPEND.*$//;'
818 . ($seen_objext ? 's/^OBJEXT//;' : 's/^OBJEXT.*$//;')
820 . (defined $options{'subdir-objects'} ? '-o \$\@' : '')
822 $output_rules .= &file_contents_with_transform ($xform, 'compile');
824 &push_phony_cleaners ('compile');
826 # If using X, include some extra variable definitions. NOTE
827 # we don't want to force these into CFLAGS or anything,
828 # because not all programs will necessarily use X.
832 foreach $var ('X_CFLAGS', 'X_LIBS', 'X_EXTRA_LIBS', 'X_PRE_LIBS')
834 &define_configure_variable ($var);
838 push (@suffixes, '.c', '.o');
839 push (@suffixes, '.obj') if $seen_objext;
840 push (@clean, 'compile');
842 $included_generic_compile = 1;
845 if ($seen_libtool && ! $included_libtool_compile)
847 # Output the libtool compilation rules.
849 &file_contents_with_transform
850 ($use_dependencies ? 's/^NOTDEPEND.*$//;' : 's/^NOTDEPEND//;',
853 &push_phony_cleaners ('libtool');
855 push (@suffixes, '.lo');
856 push (@clean, 'libtool');
858 $included_libtool_compile = 1;
861 # Check for automatic de-ANSI-fication.
862 if (defined $options{'ansi2knr'})
864 $extension = '$U' . $extension;
865 if (! $included_knr_compile)
867 if (! $am_c_prototypes)
869 &am_line_error ('AUTOMAKE_OPTIONS',
870 "option \`ansi2knr' in use but \`AM_C_PROTOTYPES' not in configure.in");
871 &keyed_aclocal_warning ('AM_C_PROTOTYPES');
872 # Only give this error once.
873 $am_c_prototypes = 1;
876 # Only require ansi2knr files if they should appear in
878 if ($options{'ansi2knr'} eq 'ansi2knr')
880 &require_file_with_line ('AUTOMAKE_OPTIONS', $FOREIGN,
881 'ansi2knr.c', 'ansi2knr.1');
882 $output_rules .= &file_contents ('kr-extra');
883 push (@clean, 'krextra');
884 &push_phony_cleaners ('krextra');
887 # Generate rules to build ansi2knr. If it is in some
888 # other directory, then generate dependencies but have the
889 # rule just run elsewhere.
890 $objext = $seen_objext ? ".$(OBJEXT)" : ".o";
891 $output_rules .= ($options{'ansi2knr'} . ': '
892 . $options{'ansi2knr'} . $objext . "\n");
893 if ($options{'ansi2knr'} eq 'ansi2knr')
895 $output_rules .= ("\t\$(LINK) ansi2knr" . $objext
897 . "ansi2knr" . $objext
898 . ": \$(CONFIG_HEADER)\n\n");
902 $output_rules .= ("\tcd " . &dirname ($options{'ansi2knr'})
903 . " && \$(MAKE) \$(AM_MAKEFLAGS) "
905 # This is required for non-GNU makes.
906 $output_rules .= ($options{'ansi2knr'} . $objext . ":\n");
907 $output_rules .= ("\tcd " . &dirname ($options{'ansi2knr'})
908 . " && \$(MAKE) \$(AM_MAKEFLAGS)"
909 . " ansi2knr" . $objext . "\n\n");
912 # Make sure ansi2knr can be found: if no path specified,
914 if ($options{'ansi2knr'} eq 'ansi2knr')
916 # Substitution from AM_C_PROTOTYPES. This makes it be
917 # built only when necessary.
918 &define_configure_variable ('ANSI2KNR');
919 # ansi2knr needs to be built before subdirs, so unshift it.
920 unshift (@all, '$(ANSI2KNR)');
924 # Found in another directory.
925 &define_variable ("ANSI2KNR", $options{'ansi2knr'});
928 $output_rules .= &file_contents ('clean-kr');
931 &push_phony_cleaners ('kr');
933 $included_knr_compile = 1;
940 # Call finish function for each language that was used.
943 local ($ext, $name, $lang, %done);
945 foreach $ext (sort keys %extension_seen)
947 $lang = $extension_map{$ext};
948 next if defined $done{$lang};
950 $non_c = 0 if $lang !~ /(objc|cxx|f77|ratfor)$/;
952 # Compute the function name of the finisher and then call it.
953 $name = 'lang_' . $lang . '_finish';
957 # If the project is entirely C++ or entirely Fortran 77, don't
958 # bother with the C stuff. But if anything else creeps in, then use
960 if (! $non_c || scalar keys %suffix_rules > 0)
962 local ($ltcompile, $ltlink) = &libtool_compiler;
964 &define_configure_variable ('CFLAGS');
965 &define_compiler_variable ('COMPILE', $ltcompile,
966 '$(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)');
967 &define_variable ('CCLD', '$(CC)');
968 &define_variable ('LINK', $ltlink . '$(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@');
972 # Output a rule to build from a YACC source. The output from YACC is
973 # compiled with C or C++, depending on the extension of the YACC file.
974 sub output_yacc_build_rule
976 local ($yacc_suffix, $use_ylwrap, $c_suffix) = @_;
979 ($suffix = $yacc_suffix) =~ tr/y/c/;
980 push (@suffixes, $yacc_suffix, $suffix);
982 # Generate rule for c/c++.
983 $output_rules .= "$yacc_suffix$suffix:\n\t";
987 $output_rules .= ('$(SHELL) $(YLWRAP)'
988 . ' "$(YACC)" $< y.tab.c $*' . $suffix
989 . ' y.tab.h $*.h -- $(AM_YFLAGS) $(YFLAGS)');
993 $output_rules .= ('$(YACC) $(AM_YFLAGS) $(YFLAGS) $< && mv y.tab.c $*'
995 . "\tif test -f y.tab.h; then \\\n"
996 . "\tif cmp -s y.tab.h \$*.h; then rm -f y.tab.h; else mv y.tab.h \$*.h; fi; \\\n"
999 $output_rules .= "\n";
1002 sub output_lex_build_rule
1004 local ($lex_suffix, $use_ylwrap) = @_;
1007 ($c_suffix = $lex_suffix) =~ tr/l/c/;
1008 push (@suffixes, $lex_suffix);
1009 &define_configure_variable ('LEX_OUTPUT_ROOT');
1010 &define_configure_variable ('LEXLIB');
1011 $output_rules .= "$lex_suffix$c_suffix:\n\t";
1015 # Is the $@ correct here? If so, why not use it in the ylwrap
1016 # build rule for yacc above?
1017 $output_rules .= '$(SHELL) $(YLWRAP)'
1018 . ' "$(LEX)" $< $(LEX_OUTPUT_ROOT).c $@ -- $(AM_LFLAGS) $(LFLAGS)';
1022 $output_rules .= '$(LEX) $(AM_LFLAGS) $(LFLAGS) $< && mv $(LEX_OUTPUT_ROOT).c $@';
1024 $output_rules .= "\n";
1028 # Check to make sure a source defined in LIBOBJS is not explicitly
1029 # mentioned. This is a separate function (as opposed to being inlined
1030 # in handle_source_transform) because it isn't always appropriate to
1032 sub check_libobjs_sources
1034 local ($one_file, $unxformed) = @_;
1036 local ($prefix, $file, @files);
1037 foreach $prefix ('', 'EXTRA_', 'dist_', 'nodist_',
1038 'dist_EXTRA_', 'nodist_EXTRA_')
1040 if (&variable_defined ($prefix . $one_file . '_SOURCES'))
1042 @files = &variable_value_as_list (($prefix
1043 . $one_file . '_SOURCES'),
1046 elsif ($prefix eq '')
1048 @files = ($unxformed . '.c');
1055 foreach $file (@files)
1057 if (defined $libsources{$file})
1059 &am_line_error ($prefix . $one_file . '_SOURCES',
1060 "automatically discovered file \`$file' should not be explicitly mentioned");
1066 # Does much of the actual work for handle_source_transform.
1068 # object extension (e.g., `$U.lo')
1069 # list of source files to transform
1071 # first element is name of linker to use (empty string for default linker)
1072 # remaining elements are names of objects
1073 sub handle_single_transform_list
1075 local ($obj, @files) = @_;
1076 local (@result) = ();
1077 local ($nonansi_obj) = $obj;
1078 $nonansi_obj =~ s/_//g;
1079 local (%linkers_used) = ();
1082 # Turn sources into objects.
1085 # Skip things that look like configure substitutions.
1088 # If the source file is in a subdirectory then the `.o' is
1089 # put into the current directory.
1091 # Split file name into base and extension.
1092 local ($full, $directory, $base, $extension, $linker, $object);
1093 next if ! /^((.*)\/)?([^\/]*)\.(.*)$/;
1099 local ($xbase) = $base;
1101 local ($lang) = $extension_map{$extension};
1104 &saw_extension ($extension);
1105 # Found the language, so see what it says.
1106 local ($subr) = 'lang_' . $lang . '_rewrite';
1107 # Note: computed subr call.
1108 local ($r) = & $subr ($directory, $base, $extension);
1109 # Skip this entry if we were asked not to process it.
1110 next if $r == $LANG_IGNORE;
1112 # Now extract linker and other info.
1113 $linker = $language_map{$lang . '-linker'};
1115 if ($language_map{$lang . '-ansi-p'})
1117 $object = $base . $obj;
1121 $object = $base . $nonansi_obj;
1124 # If rewrite said it was ok, put the object into a
1126 if ($r == $LANG_SUBDIR && $directory ne '')
1128 $object = $directory . '/' . $object;
1129 $xbase = $directory . '/' . $base;
1132 elsif ($extension =~ /^$source_suffix_pattern$/)
1134 # We just rewrite it. Maybe we should do more.
1135 # FIXME: what about subdir handling here?
1136 $object = $base . '.' . $suffix_rules{$extension};
1141 # No error message here. Used to have one, but it was
1146 $linkers_used{$linker} = 1;
1148 push (@result, $object);
1150 if (defined $object_map{$object})
1152 if ($object_map{$object} ne $full)
1154 &am_error ("object \`$object' created by \`$full' and \`$object_map{$object}'");
1159 local (@dep_list) = ();
1160 $object_map{$object} = $full;
1162 # If file is in subdirectory, we need explicit
1164 if ($directory ne '')
1166 push (@dep_list, $full);
1169 # If resulting object is in subdir, we need to make
1170 # sure the subdir exists at build time.
1171 if ($object =~ /\//)
1173 # FIXME: check that $DIRECTORY is somewhere in the
1176 # We don't allow `..' in object file names for
1177 # *any* source, not just Java. For Java it just
1178 # doesn't make sense, but in general it is
1179 # a problem because we can't pick a good name for
1181 if ($object =~ /(\/|^)\.\.\//)
1183 &am_error ("\`$full' contains \`..' component but should not");
1186 push (@dep_list, $directory . '/.dirstamp');
1188 # If we're generating dependencies, we also want
1189 # to make sure that the appropriate subdir of the
1190 # .deps directory is created.
1191 if ($use_dependencies)
1193 push (@dep_list, '.deps/' . $directory . '/.dirstamp');
1196 if (! defined $directory_map{$directory})
1198 $directory_map{$directory} = 1;
1199 $output_rules .= ($directory . "/.dirstamp:\n"
1200 . "\t\@\$(mkinstalldirs) $directory\n"
1201 . "\t\@: > $directory/.dirstamp\n");
1202 if ($use_dependencies)
1204 $output_rules .= ('.deps/' . $directory
1206 . "\t\@\$(mkinstalldirs) .deps/$directory\n"
1207 . "\t\@: > .deps/$directory/.dirstamp\n");
1212 &pretty_print_rule ($object . ':', "\t", @dep_list);
1215 # Transform .o or $o file into .P file (for automatic
1217 $dep_files{'.deps/' . $xbase . '.P'} = 1;
1221 return (&resolve_linker (%linkers_used), @result);
1224 # Handle SOURCE->OBJECT transform for one program or library.
1226 # canonical (transformed) name of object to build
1227 # actual name of object to build
1228 # object extension (ie either `.o' or `$o'.
1229 # Return result is name of linker variable that must be used.
1230 # Empty return means just use `LINK'.
1231 sub handle_source_transform
1233 # one_file is canonical name. unxformed is given name. obj is
1235 local ($one_file, $unxformed, $obj) = @_;
1237 local ($linker) = '';
1239 if (&variable_defined ($one_file . "_OBJECTS"))
1241 &am_line_error ($one_file . '_OBJECTS',
1242 $one_file . '_OBJECTS', 'should not be defined');
1243 # No point in continuing.
1247 local (@files, @result, $prefix, $temp, $xpfx);
1248 local (%used_pfx) = ();
1249 foreach $prefix ('', 'EXTRA_', 'dist_', 'nodist_',
1250 'dist_EXTRA_', 'nodist_EXTRA_')
1252 # We are going to define _OBJECTS variables using the prefix.
1253 # Then we glom them all together. So we can't use the null
1254 # prefix here as we need it later.
1255 $xpfx = ($prefix eq '') ? 'am_' : $prefix;
1258 local ($var) = $prefix . $one_file . "_SOURCES";
1259 if (&variable_defined ($var))
1261 push (@sources, '$(' . $prefix . $one_file . "_SOURCES)");
1262 push (@objects, '$(' . $xpfx . $one_file . "_OBJECTS)")
1263 unless $prefix =~ /EXTRA_/;
1264 push (@dist_sources, '$(' . $prefix . $one_file . "_SOURCES)")
1265 unless $prefix =~ /^nodist_/;
1266 local (@conds) = &variable_conditions ($var);
1269 @files = &variable_value_as_list ($var, '');
1274 foreach $cond (@conds)
1276 @files = &variable_value_as_list ($var, $cond);
1277 ($temp, @result) = &handle_single_transform_list ($obj,
1279 $linker = $temp if $linker eq '';
1281 # Define _OBJECTS conditionally.
1282 &define_pretty_variable ($xpfx . $one_file . '_OBJECTS',
1284 unless $prefix =~ /EXTRA_/;
1287 # Keep track of which prefixes we saw.
1288 $used_pfx{$xpfx} = 1
1289 unless $prefix =~ /EXTRA_/;
1295 # Avoid defining needless variables.
1296 next if (scalar @files == 0);
1298 # Keep track of which prefixes we saw.
1299 $used_pfx{$xpfx} = 1
1300 unless $prefix =~ /EXTRA_/;
1302 ($temp, @result) = &handle_single_transform_list ($obj, @files);
1303 $linker = $temp if $linker eq '';
1304 &define_pretty_variable ($xpfx . $one_file . "_OBJECTS", '', @result)
1305 unless $prefix =~ /EXTRA_/;
1308 local (@keys) = sort keys %used_pfx;
1309 if (scalar @keys == 0)
1311 &define_variable ($one_file . "_SOURCES", $unxformed . ".c");
1312 push (@sources, $unxformed . '.c');
1313 push (@dist_sources, $unxformed . '.c');
1314 push (@objects, $unxformed . $obj);
1315 push (@files, $unxformed . '.c');
1317 ($temp, @result) = &handle_single_transform_list ($obj, @files);
1318 $linker = $temp if $linker eq '';
1319 &define_pretty_variable ($one_file . "_OBJECTS", '', @result)
1323 grep ($_ = '$(' . $_ . $one_file . '_OBJECTS)', @keys);
1324 &define_pretty_variable ($one_file . '_OBJECTS', '', @keys);
1330 # Handle the BUILT_SOURCES variable.
1331 sub handle_built_sources
1333 return unless &variable_defined ('BUILT_SOURCES');
1335 local (@sources) = &variable_value_as_list ('BUILT_SOURCES', 'all');
1337 foreach $s (@sources)
1341 # FIXME: is this really the right thing to do?
1342 &am_line_error ('BUILT_SOURCES',
1343 "\`BUILT_SOURCES' should not contain a configure substitution");
1348 # We don't care about the return value of this function. We just
1349 # want to make sure to update %dep_files with the contents of
1351 &handle_single_transform_list (".o", @sources);
1354 # Special-case @ALLOCA@ and @LIBOBJS@ in _LDADD or _LIBADD variables.
1355 # Also, generate _DEPENDENCIES variable if appropriate.
1357 # transformed name of object being built, or empty string if no object
1358 # name of _LDADD/_LIBADD-type variable to examine
1359 # boolean (lex_seen) which is true if a lex source file was seen in this
1360 # object. valid only for LDADDs, not LIBADDs.
1361 # Returns 1 if LIBOBJS seen, 0 otherwise.
1362 sub handle_lib_objects
1364 local ($xname, $var, $lex_seen) = @_;
1367 die "automake: programming error 1 in handle_lib_objects\n"
1368 if ! &variable_defined ($var);
1370 die "automake: programming error 2 in handle_lib_objects\n"
1371 if $lex_seen && $var =~ /LIBADD/;
1373 local (@conds) = &variable_conditions ($var);
1376 $ret = &handle_lib_objects_cond ($xname, $var, $lex_seen, '');
1382 foreach $cond (@conds)
1384 if (&handle_lib_objects_cond ($xname, $var, $lex_seen, $cond))
1394 # Subroutine of handle_lib_objects: handle a particular condition.
1395 sub handle_lib_objects_cond
1397 local ($xname, $var, $lex_seen, $cond) = @_;
1399 # We recognize certain things that are commonly put in LIBADD or
1402 local (@dep_list) = ();
1404 local ($seen_libobjs) = 0;
1405 local ($flagvar) = 0;
1407 foreach $lsearch (&variable_value_as_list ($var, $cond))
1409 # Skip -lfoo and -Ldir; these are explicitly allowed.
1410 next if $lsearch =~ /^-[lL]/;
1411 if (! $flagvar && $lsearch =~ /^-/)
1413 if ($var =~ /^(.*)LDADD$/)
1415 # Skip -dlopen and -dlpreopen; these are explicitly allowed.
1416 next if $lsearch =~ /^-dl(pre)?open$/;
1417 &am_line_error ($var, "linker flags such as \`$lsearch' belong in \`${1}LDFLAGS");
1421 # Only get this error once.
1423 &am_line_error ($var, "you cannot use linker flags such as \`$lsearch' in \`$var'");
1427 # Assume we have a file of some sort, and push it onto the
1428 # dependency list. Autoconf substitutions are not pushed;
1429 # rarely is a new dependency substituted into (eg) foo_LDADD
1430 # -- but "bad things (eg -lX11) are routinely substituted.
1431 # Note that LIBOBJS and ALLOCA are exceptions to this rule,
1432 # and handled specially below.
1433 push (@dep_list, $lsearch)
1434 unless $lsearch =~ /^\@.*\@$/;
1436 # Automatically handle @LIBOBJS@ and @ALLOCA@. Basically this
1437 # means adding entries to dep_files.
1438 if ($lsearch =~ /^\@(LT)?LIBOBJS\@$/)
1440 push (@dep_list, $lsearch);
1442 if (! keys %libsources)
1444 &am_line_error ($var, "\@$1" . "LIBOBJS\@ seen but never set in \`configure.in'");
1447 local ($iter, $rewrite);
1448 foreach $iter (keys %libsources)
1450 if ($iter =~ /\.([cly])$/)
1452 &saw_extension ($1);
1453 &saw_extension ('c');
1456 if ($iter =~ /\.h$/)
1458 &require_file_with_line ($var, $FOREIGN, $iter);
1460 elsif ($iter ne 'alloca.c')
1462 ($rewrite = $iter) =~ s/\.c$/.P/;
1463 $dep_files{'.deps/' . $rewrite} = 1;
1464 &require_file_with_line ($var, $FOREIGN, $iter);
1468 elsif ($lsearch =~ /^\@(LT)?ALLOCA\@$/)
1470 push (@dep_list, $lsearch);
1471 &am_line_error ($var,
1472 "\@$1" . "ALLOCA\@ seen but \`AC_FUNC_ALLOCA' not in \`configure.in'")
1473 if ! defined $libsources{'alloca.c'};
1474 $dep_files{'.deps/alloca.P'} = 1;
1475 &require_file_with_line ($var, $FOREIGN, 'alloca.c');
1476 &saw_extension ('c');
1480 if ($xname ne '' && ! &variable_defined ($xname . '_DEPENDENCIES', $cond))
1482 &define_pretty_variable ($xname . '_DEPENDENCIES', $cond, @dep_list);
1485 return $seen_libobjs;
1488 # Canonicalize a name, and check to make sure the non-canonical name
1489 # is never used. Returns canonical name. Arguments are name and a
1490 # list of suffixes to check for.
1491 sub check_canonical_spelling
1493 local ($name, @suffixes) = @_;
1494 local ($xname, $xt);
1496 ($xname = $name) =~ tr/A-Za-z0-9_/_/c;
1497 if ($xname ne $name)
1500 foreach $xt (@suffixes)
1502 &am_line_error ($name . $xt,
1503 "invalid variable \`" . $name . $xt
1504 . "'; should be \`" . $xname . $xt . "'")
1505 if &variable_defined ($name . $xt);
1512 # Handle C programs.
1515 local (@proglist) = &am_install_var ('-clean',
1516 'progs', 'PROGRAMS',
1517 'bin', 'sbin', 'libexec', 'pkglib',
1519 return if ! @proglist;
1521 # If a program is installed, this is required. We only want this
1522 # error to appear once.
1523 &am_conf_error ("AC_ARG_PROGRAM must be used in configure.in")
1524 unless $seen_arg_prog;
1527 local ($one_file, $xname, $munge);
1529 local ($seen_libobjs) = 0;
1530 foreach $one_file (@proglist)
1532 local ($obj) = &get_object_extension ($one_file);
1534 # Canonicalize names and check for misspellings.
1535 $xname = &check_canonical_spelling ($one_file, '_LDADD', '_LDFLAGS',
1536 '_SOURCES', '_OBJECTS',
1539 # FIXME: Using a trick to figure out if any lex sources appear
1540 # in our program; should use some cleaner method.
1541 local ($lex_num) = scalar (keys %lex_sources);
1542 local ($linker) = &handle_source_transform ($xname, $one_file, $obj);
1543 local ($lex_file_seen) = (scalar (keys %lex_sources) > $lex_num);
1546 if (&variable_defined ($xname . "_LDADD"))
1548 if (&handle_lib_objects ($xname, $xname . '_LDADD',
1558 # User didn't define prog_LDADD override. So do it.
1559 &define_variable ($xname . '_LDADD', '$(LDADD)');
1561 # This does a bit too much work. But we need it to
1562 # generate _DEPENDENCIES when appropriate.
1563 if (&variable_defined ('LDADD'))
1565 if (&handle_lib_objects ($xname, 'LDADD', $lex_file_seen))
1571 elsif (! &variable_defined ($xname . '_DEPENDENCIES'))
1573 &define_variable ($xname . '_DEPENDENCIES', '');
1578 if (&variable_defined ($xname . '_LIBADD'))
1580 &am_line_error ($xname . '_LIBADD',
1581 "use \`" . $xname . "_LDADD', not \`"
1582 . $xname . "_LIBADD'");
1585 if (! &variable_defined ($xname . '_LDFLAGS'))
1587 # Define the prog_LDFLAGS variable.
1588 &define_variable ($xname . '_LDFLAGS', '');
1591 # Determine program to use for link.
1593 if (&variable_defined ($xname . '_LINK'))
1595 $xlink = $xname . '_LINK';
1599 $xlink = $linker ? $linker : 'LINK';
1603 if ($seen_exeext && $one_file !~ /\./)
1605 $xexe = 's/\@EXEEXT\@/\$(EXEEXT)/g;';
1609 $xexe = 's/\@EXEEXT\@//g;';
1613 &file_contents_with_transform
1614 ('s/\@PROGRAM\@/' . $one_file . '/go;'
1615 . 's/\@XPROGRAM\@/' . $xname . '/go;'
1616 . 's/\@XLINK\@/' . $xlink . '/go;'
1621 if (&variable_defined ('LDADD') && &handle_lib_objects ('', 'LDADD', 0))
1628 foreach $one_file (@proglist)
1630 # Canonicalize names.
1631 ($xname = $one_file) =~ tr/A-Za-z0-9_/_/c;
1633 if (&variable_defined ($xname . '_LDADD'))
1635 &check_libobjs_sources ($xname, $xname . '_LDADD');
1637 elsif (&variable_defined ('LDADD'))
1639 &check_libobjs_sources ($xname, 'LDADD');
1647 sub handle_libraries
1649 local (@liblist) = &am_install_var ('-clean',
1650 'libs', 'LIBRARIES',
1651 'lib', 'pkglib', 'noinst', 'check');
1652 return if ! @liblist;
1654 local (%valid) = &am_primary_prefixes ('LIBRARIES', 0, 'lib', 'pkglib',
1656 if (! defined $configure_vars{'RANLIB'})
1659 foreach $key (keys %valid)
1661 if (&variable_defined ($key . '_LIBRARIES'))
1663 &am_line_error ($key . '_LIBRARIES', "library used but \`RANLIB' not defined in \`configure.in'");
1664 # Only get this error once. If this is ever printed,
1666 $configure_vars{'RANLIB'} = 'BUG';
1675 local ($seen_libobjs) = 0;
1676 foreach $onelib (@liblist)
1678 # Check that the library fits the standard naming convention.
1679 if ($onelib !~ /^lib.*\.a$/)
1681 # FIXME should put line number here. That means mapping
1682 # from library name back to variable name.
1683 &am_error ("\`$onelib' is not a standard library name");
1686 local ($obj) = &get_object_extension ($onelib);
1688 # Canonicalize names and check for misspellings.
1689 $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_SOURCES',
1690 '_OBJECTS', '_DEPENDENCIES');
1692 if (&variable_defined ($xlib . '_LIBADD'))
1694 if (&handle_lib_objects ($xlib, $xlib . '_LIBADD', 0))
1701 # Generate support for conditional object inclusion in
1703 &define_variable ($xlib . "_LIBADD", '');
1706 if (&variable_defined ($xlib . '_LDADD'))
1708 &am_line_error ($xlib . '_LDADD',
1709 "use \`" . $xlib . "_LIBADD', not \`"
1710 . $xlib . "_LDADD'");
1713 # Make sure we at look at this.
1714 &examine_variable ($xlib . '_DEPENDENCIES');
1716 &handle_source_transform ($xlib, $onelib, $obj);
1719 &file_contents_with_transform ('s/\@LIBRARY\@/' . $onelib . '/go;'
1727 foreach $onelib (@liblist)
1729 # Canonicalize names.
1730 ($xlib = $onelib) =~ tr/A-Za-z0-9_/_/c;
1731 if (&variable_defined ($xlib . '_LIBADD'))
1733 &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
1738 &define_variable ('AR', 'ar');
1739 &define_configure_variable ('RANLIB');
1742 # Handle shared libraries.
1743 sub handle_ltlibraries
1745 local (@liblist) = &am_install_var ('-clean',
1746 'ltlib', 'LTLIBRARIES',
1747 'noinst', 'lib', 'pkglib', 'check');
1748 return if ! @liblist;
1751 local (%valid) = &am_primary_prefixes ('LTLIBRARIES', 0, 'lib', 'pkglib',
1755 foreach $key (keys %valid)
1757 if (&variable_defined ($key . '_LTLIBRARIES'))
1761 &am_line_error ($key . '_LTLIBRARIES', "library used but \`LIBTOOL' not defined in \`configure.in'");
1762 # Only get this error once. If this is ever printed,
1764 $configure_vars{'LIBTOOL'} = 'BUG';
1768 # Get the installation directory of each library.
1769 for (&variable_value_as_list ($key . '_LTLIBRARIES', 'all'))
1773 &am_error ("\`$_' is already going to be installed in \`$instdirs{$_}'");
1777 $instdirs{$_} = $key;
1786 local ($seen_libobjs) = 0;
1787 foreach $onelib (@liblist)
1789 local ($obj) = &get_object_extension ($onelib);
1791 # Canonicalize names and check for misspellings.
1792 $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_LDFLAGS',
1793 '_SOURCES', '_OBJECTS',
1796 if (! &variable_defined ($xlib . '_LDFLAGS'))
1798 # Define the lib_LDFLAGS variable.
1799 &define_variable ($xlib . '_LDFLAGS', '');
1802 # Check that the library fits the standard naming convention.
1803 $libname_rx = "^lib.*\.la";
1804 if (&variable_value ($xlib . '_LDFLAGS') =~ /-module/)
1806 # Relax name checking for libtool modules.
1807 $libname_rx = "\.la";
1809 if ($onelib !~ /$libname_rx$/)
1811 # FIXME this should only be a warning for foreign packages
1812 # FIXME should put line number here. That means mapping
1813 # from library name back to variable name.
1814 &am_error ("\`$onelib' is not a standard libtool library name");
1817 if (&variable_defined ($xlib . '_LIBADD'))
1819 if (&handle_lib_objects ($xlib, $xlib . '_LIBADD', 0))
1826 # Generate support for conditional object inclusion in
1828 &define_variable ($xlib . "_LIBADD", '');
1831 if (&variable_defined ($xlib . '_LDADD'))
1833 &am_line_error ($xlib . '_LDADD',
1834 "use \`" . $xlib . "_LIBADD', not \`"
1835 . $xlib . "_LDADD'");
1838 # Make sure we at look at this.
1839 &examine_variable ($xlib . '_DEPENDENCIES');
1841 local ($linker) = &handle_source_transform ($xlib, $onelib, $obj);
1843 # Determine program to use for link.
1845 if (&variable_defined ($xlib . '_LINK'))
1847 $xlink = $xlib . '_LINK';
1851 $xlink = $linker ? $linker : 'LINK';
1855 if ($instdirs{$onelib} eq 'EXTRA' || $instdirs{$onelib} eq 'noinst')
1857 # It's an EXTRA_ library, so we can't specify -rpath,
1858 # because we don't know where the library will end up.
1859 # The user probably knows, but generally speaking automake
1860 # doesn't -- and in fact configure could decide
1861 # dynamically between two different locations.
1862 $rpath = 's/\@RPATH\@//go;';
1866 $rpath = ('s/\@RPATH\@/-rpath \$(' . $instdirs{$onelib}
1871 &file_contents_with_transform ('s/\@LTLIBRARY\@/'
1873 . 's/\@XLTLIBRARY\@/'
1876 . 's/\@XLINK\@/' . $xlink . '/go;',
1882 foreach $onelib (@liblist)
1884 # Canonicalize names.
1885 ($xlib = $onelib) =~ tr/A-Za-z0-9_/_/c;
1886 if (&variable_defined ($xlib . '_LIBADD'))
1888 &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
1894 # See if any _SOURCES variable were misspelled. Also, make sure that
1895 # EXTRA_ variables don't contain configure substitutions.
1898 local ($varname, $primary);
1899 foreach $varname (keys %contents)
1901 foreach $primary ('_SOURCES', '_LIBADD', '_LDADD', '_LDFLAGS',
1904 if ($varname =~ /$primary$/ && ! $content_seen{$varname})
1906 &am_line_error ($varname,
1907 "invalid unused variable name: \`$varname'");
1916 # NOTE we no longer automatically clean SCRIPTS, because it is
1917 # useful to sometimes distribute scripts verbatim. This happens
1918 # eg in Automake itself.
1919 &am_install_var ('-candist', 'scripts', 'SCRIPTS',
1920 'bin', 'sbin', 'libexec', 'pkgdata',
1923 local ($scripts_installed) = 0;
1924 # Set $scripts_installed if appropriate. Make sure we only find
1925 # scripts which are actually installed -- this is why we can't
1926 # simply use the return value of am_install_var.
1927 local (%valid) = &am_primary_prefixes ('SCRIPTS', 1, 'bin', 'sbin',
1928 'libexec', 'pkgdata',
1931 foreach $key (keys %valid)
1933 if ($key ne 'noinst'
1935 && &variable_defined ($key . '_SCRIPTS'))
1937 $scripts_installed = 1;
1938 # push (@check_tests, 'check-' . $key . 'SCRIPTS');
1942 if ($scripts_installed)
1944 # If a program is installed, this is required. We only want this
1945 # error to appear once.
1946 &am_conf_error ("AC_ARG_PROGRAM must be used in configure.in")
1947 unless $seen_arg_prog;
1952 # Search a file for a "version.texi" Texinfo include. Return the name
1953 # of the include file if found, or the empty string if not. A
1954 # "version.texi" file is actually any file whose name matches
1956 sub scan_texinfo_file
1958 local ($filename) = @_;
1960 if (! open (TEXI, $filename))
1962 &am_error ("couldn't open \`$filename': $!");
1965 print "automake: reading $filename\n" if $verbose;
1967 local ($vfile, $outfile);
1970 if (/^\@setfilename +(\S+)/)
1976 if (/^\@include\s+(vers[^.]*\.texi)\s*$/)
1978 # Found version.texi include.
1985 return ($outfile, $vfile);
1988 # Handle all Texinfo source.
1991 &am_line_error ('TEXINFOS',
1992 "\`TEXINFOS' is an anachronism; use \`info_TEXINFOS'")
1993 if &variable_defined ('TEXINFOS');
1994 return if (! &variable_defined ('info_TEXINFOS')
1995 && ! &variable_defined ('html_TEXINFOS'));
1997 if (&variable_defined ('html_TEXINFOS'))
1999 &am_line_error ('html_TEXINFOS',
2000 "HTML generation not yet supported");
2004 local (@texis) = &variable_value_as_list ('info_TEXINFOS', 'all');
2006 local (@info_deps_list, @dvis_list, @texi_deps);
2007 local ($infobase, $info_cursor);
2011 local ($tc_cursor, @texi_cleans);
2014 foreach $info_cursor (@texis)
2016 # FIXME: This is mildly hacky, since it recognizes "txinfo".
2017 # I don't feel like making it right.
2018 ($infobase = $info_cursor) =~ s/\.te?xi(nfo)?$//;
2020 # If 'version.texi' is referenced by input file, then include
2021 # automatic versioning capability.
2022 local ($out_file, $vtexi) = &scan_texinfo_file ($relative_dir
2023 . "/" . $info_cursor);
2025 if ($out_file eq '')
2027 &am_error ("\`$info_cursor' missing \@setfilename");
2031 if ($out_file =~ /\.(.+)$/ && $1 ne 'info')
2033 # FIXME should report line number in input file.
2034 &am_error ("output of \`$info_cursor', \`$out_file', has unrecognized extension");
2040 &am_error ("\`$vtexi', included in \`$info_cursor', also included in \`$versions{$vtexi}'")
2041 if (defined $versions{$vtexi});
2042 $versions{$vtexi} = $info_cursor;
2044 # We number the stamp-vti files. This is doable since the
2045 # actual names don't matter much. We only number starting
2046 # with the second one, so that the common case looks nice.
2047 $vti = 'vti' . ($done ? $done : '');
2048 &push_dist_common ($vtexi, 'stamp-' . $vti);
2049 push (@clean, $vti);
2051 # Only require once.
2052 &require_conf_file_with_line ('info_TEXINFOS', $FOREIGN,
2057 local ($conf_pat, $conf_dir);
2058 if ($config_aux_dir eq '.' || $config_aux_dir eq '')
2060 $conf_dir = '$(srcdir)/';
2064 $conf_dir = $config_aux_dir;
2065 $conf_dir .= '/' unless $conf_dir =~ /\/$/;
2067 ($conf_pat = $conf_dir) =~ s/(\W)/\\$1/g;
2069 &file_contents_with_transform
2070 ('s/\@TEXI\@/' . $info_cursor . '/g; '
2071 . 's/\@VTI\@/' . $vti . '/g; '
2072 . 's/\@VTEXI\@/' . $vtexi . '/g;'
2073 . 's,\@MDDIR\@,' . $conf_pat . ',g;',
2076 &push_phony_cleaners ($vti);
2079 # If user specified file_TEXINFOS, then use that as explicit
2082 push (@texi_deps, $info_cursor);
2083 push (@texi_deps, $vtexi) if $vtexi;
2085 # Canonicalize name first.
2086 ($canonical = $infobase) =~ tr/A-Za-z0-9_/_/c;
2087 if (&variable_defined ($canonical . "_TEXINFOS"))
2089 push (@texi_deps, '$(' . $canonical . '_TEXINFOS)');
2090 &push_dist_common ('$(' . $canonical . '_TEXINFOS)');
2093 $output_rules .= ("\n" . $out_file . ": "
2094 . join (' ', @texi_deps)
2095 . "\n" . $infobase . ".dvi: "
2096 . join (' ', @texi_deps)
2099 push (@info_deps_list, $out_file);
2100 push (@dvis_list, $infobase . '.dvi');
2102 # Generate list of things to clean for this target. We do
2103 # this explicitly because otherwise too many things could be
2104 # removed. In particular the ".log" extension might
2105 # reasonably be used in other contexts by the user.
2106 foreach $tc_cursor ('aux', 'cp', 'cps', 'dvi', 'fn', 'fns', 'pgs',
2107 'ky', 'kys', 'ps', 'log', 'pg', 'toc', 'tp', 'tps',
2108 'vr', 'vrs', 'op', 'tr', 'cv', 'cn')
2110 push (@texi_cleans, $infobase . '.' . $tc_cursor);
2114 # Find these programs wherever they may lie. Yes, this has
2115 # intimate knowledge of the structure of the texinfo distribution.
2116 &define_program_variable ('MAKEINFO', 'build', 'texinfo/makeinfo',
2118 # Circumlocution to avoid accidental
2119 # configure substitution.
2121 &define_program_variable ('TEXI2DVI', 'src', 'texinfo/util',
2124 # Set transform for including texinfos.am. First, handle --cygnus
2129 $xform = 's/^NOTCYGNUS.*$//; s/^CYGNUS//;';
2133 $xform = 's/^CYGNUS.*$//; s/^NOTCYGNUS//;';
2136 # Handle location of texinfo.tex.
2137 local ($need_texi_file) = 0;
2138 local ($texinfo_tex);
2141 $texinfo_tex = '$(top_srcdir)/../texinfo/texinfo.tex';
2142 &define_variable ('TEXINFO_TEX', $texinfo_tex);
2145 elsif ($config_aux_dir ne '.' && $config_aux_dir ne '')
2147 $texinfo_tex = $config_aux_dir . '/texinfo.tex';
2148 &define_variable ('TEXINFO_TEX', $texinfo_tex);
2149 $need_texi_file = 2; # so that we require_conf_file later
2151 elsif (&variable_defined ('TEXINFO_TEX'))
2153 # The user defined TEXINFO_TEX so assume he knows what he is
2155 $texinfo_tex = ('$(srcdir)/'
2156 . &dirname (&variable_value ('TEXINFO_TEX')));
2160 $texinfo_tex = '$(srcdir)/texinfo.tex';
2161 $need_texi_file = 1;
2164 ($xxform = $texinfo_tex) =~ s/\/texinfo\.tex$//;
2165 $xxform =~ s/(\W)/\\$1/g;
2166 $xform .= ' s/\@TEXINFODIR\@/' . $xxform . '/g;';
2168 $output_rules .= &file_contents_with_transform ($xform, 'texinfos');
2169 push (@phony, 'install-info-am', 'uninstall-info');
2170 push (@dist_targets, 'dist-info');
2172 # How to clean. The funny name is due to --cygnus influence; in
2173 # Cygnus mode, `clean-info' is a target that users can use.
2174 $output_rules .= "\nmostlyclean-aminfo:\n";
2175 &pretty_print_rule ("\t-rm -f", "\t ", @texi_cleans);
2176 $output_rules .= ("\nclean-aminfo:\n\ndistclean-aminfo:\n\n"
2177 . "maintainer-clean-aminfo:\n\t"
2178 # Eww. But how else can we find all the output
2179 # files from makeinfo?
2180 . ($cygnus_mode ? '' : 'cd $(srcdir) && ')
2181 . 'for i in $(INFO_DEPS); do' . " \\\n"
2182 . "\t" . ' rm -f $$i;' . " \\\n"
2183 . "\t" . ' if test "`echo $$i-[0-9]*`" != "$$i-[0-9]*"; then' . " \\\n"
2184 . "\t" . ' rm -f $$i-[0-9]*;' . " \\\n"
2185 . "\t" . ' fi;' . " \\\n"
2187 &push_phony_cleaners ('aminfo');
2190 $output_rules .= "clean-info: mostlyclean-aminfo\n";
2193 push (@suffixes, '.texi', '.texinfo', '.txi', '.info', '.dvi', '.ps');
2195 if (! defined $options{'no-installinfo'})
2197 push (@uninstall, 'uninstall-info');
2198 push (@installdirs, '$(DESTDIR)$(infodir)');
2199 unshift (@install_data, 'install-info-am');
2201 # Make sure documentation is made and installed first. Use
2202 # $(INFO_DEPS), not 'info', because otherwise recursive makes
2203 # get run twice during "make all".
2204 unshift (@all, '$(INFO_DEPS)');
2206 push (@clean, 'aminfo');
2207 push (@info, '$(INFO_DEPS)');
2208 push (@dvi, '$(DVIS)');
2210 &define_variable ("INFO_DEPS", join (' ', @info_deps_list));
2211 &define_variable ("DVIS", join (' ', @dvis_list));
2212 # This next isn't strictly needed now -- the places that look here
2213 # could easily be changed to look in info_TEXINFOS. But this is
2214 # probably better, in case noinst_TEXINFOS is ever supported.
2215 &define_variable ("TEXINFOS", &variable_value ('info_TEXINFOS'));
2217 # Do some error checking. Note that this file is not required
2218 # when in Cygnus mode; instead we defined TEXINFO_TEX explicitly
2220 if ($need_texi_file && ! defined $options{'no-texinfo.tex'})
2222 if ($need_texi_file > 1)
2224 &require_conf_file_with_line ('info_TEXINFOS', $FOREIGN,
2229 &require_file_with_line ('info_TEXINFOS', $FOREIGN, 'texinfo.tex');
2234 # Handle any man pages.
2235 sub handle_man_pages
2237 &am_line_error ('MANS', "\`MANS' is an anachronism; use \`man_MANS'")
2238 if &variable_defined ('MANS');
2239 return if ! &variable_defined ('man_MANS');
2241 # Find all the sections in use. We do this by first looking for
2242 # "standard" sections, and then looking for any additional
2243 # sections used in man_MANS.
2244 local ($sect, %sections, %vlist);
2245 # Add more sections as needed.
2246 foreach $sect ('0'..'9', 'n', 'l')
2248 if (&variable_defined ('man' . $sect . '_MANS'))
2250 $sections{$sect} = 1;
2251 $vlist{'$(man' . $sect . '_MANS)'} = 1;
2255 if (&variable_defined ('man_MANS'))
2257 $vlist{'$(man_MANS)'} = 1;
2258 foreach (&variable_value_as_list ('man_MANS', 'all'))
2260 # A page like `foo.1c' goes into man1dir.
2261 if (/\.([0-9a-z])([a-z]*)$/)
2269 # Now for each section, generate an install and unintall rule.
2270 # Sort sections so output is deterministic.
2272 foreach $sect (sort keys %sections)
2274 &define_variable ('man' . $sect . 'dir', '$(mandir)/man' . $sect);
2275 push (@installdirs, '$(DESTDIR)$(mandir)/man' . $sect)
2276 unless defined $options{'no-installman'};
2277 $output_rules .= &file_contents_with_transform ('s/\@SECTION\@/'
2280 push (@phony, 'install-man' . $sect, 'uninstall-man' . $sect);
2281 push (@namelist, 'install-man' . $sect);
2284 # We don't really need this, but we use it in case we ever want to
2285 # support noinst_MANS.
2286 &define_variable ("MANS", join (' ', sort keys %vlist));
2288 # Generate list of install dirs.
2289 $output_rules .= ("install-man: \$(MANS)\n"
2290 . "\t\@\$(NORMAL_INSTALL)\n");
2291 &pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ", @namelist);
2292 push (@phony, 'install-man');
2294 $output_rules .= "uninstall-man:\n\t\@\$(NORMAL_UNINSTALL)\n";
2295 grep ($_ = 'un' . $_, @namelist);
2296 &pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ", @namelist);
2297 push (@phony, 'uninstall-man');
2299 $output_vars .= &file_contents ('mans-vars');
2301 if (! defined $options{'no-installman'})
2303 push (@install_data, 'install-man');
2304 push (@uninstall, 'uninstall-man');
2305 push (@all, '$(MANS)');
2309 # Handle DATA variables.
2312 &am_install_var ('-noextra', '-defaultdist', 'data', 'DATA',
2313 'data', 'sysconf', 'sharedstate', 'localstate',
2314 'pkgdata', 'noinst', 'check');
2320 push (@phony, 'tags');
2321 local (@tag_deps) = ();
2322 if (&variable_defined ('SUBDIRS'))
2324 $output_rules .= ("tags-recursive:\n"
2325 . "\tlist=\'\$(SUBDIRS)\'; for subdir in \$\$list; do \\\n"
2326 # Never fail here if a subdir fails; it
2328 . "\t test \"\$\$subdir\" = . || (cd \$\$subdir"
2329 . " && \$(MAKE) \$(AM_MAKEFLAGS) tags); \\\n"
2331 push (@tag_deps, 'tags-recursive');
2332 push (@phony, 'tags-recursive');
2335 if (&saw_sources_p (1)
2336 || &variable_defined ('ETAGS_ARGS')
2339 local ($xform) = '';
2341 foreach $one_hdr (@config_headers)
2343 if ($relative_dir eq &dirname ($one_hdr))
2345 # The config header is in this directory. So require it.
2347 ($var = &basename ($one_hdr)) =~ s/(\W)/\\$1/g;
2348 $xform .= ' ' if $xform;
2352 $xform = ('s/\@CONFIG\@/' . $xform . '/;'
2353 . 's/\@DIRS\@/' . join (' ', @tag_deps) . '/;');
2355 if (&variable_defined ('SUBDIRS'))
2357 $xform .= 's/^SUBDIRS//;';
2361 $xform .= 's/^SUBDIRS.*$//;';
2364 $output_rules .= &file_contents_with_transform ($xform, 'tags');
2365 $output_rules .= &file_contents ('tags-clean');
2366 push (@clean, 'tags');
2367 &push_phony_cleaners ('tags');
2368 &examine_variable ('TAGS_DEPENDENCIES');
2370 elsif (&variable_defined ('TAGS_DEPENDENCIES'))
2372 &am_line_error ('TAGS_DEPENDENCIES',
2373 "doesn't make sense to define \`TAGS_DEPENDENCIES' without sources or \`ETAGS_ARGS'");
2377 # Every Makefile must define some sort of TAGS rule.
2378 # Otherwise, it would be possible for a top-level "make TAGS"
2379 # to fail because some subdirectory failed.
2380 $output_rules .= "tags: TAGS\nTAGS:\n\n";
2384 # Handle multilib support.
2387 return unless $seen_multilib;
2389 $output_rules .= &file_contents ('multilib.am');
2390 &push_phony_cleaners ('multi');
2391 push (@phony, 'all-multi', 'install-multi');
2394 # Worker for handle_dist.
2395 sub handle_dist_worker
2397 local ($makefile) = @_;
2399 $output_rules .= 'distdir: $(DISTFILES)' . "\n";
2401 # Initialization; only at top level.
2402 if ($relative_dir eq '.')
2404 if (defined $options{'check-news'})
2406 # For Gnits users, this is pretty handy. Look at 15 lines
2407 # in case some explanatory text is desirable.
2408 $output_rules .= ' @if sed 15q $(srcdir)/NEWS | fgrep -e "$(VERSION)" > /dev/null; then :; else \\
2409 echo "NEWS not updated; not releasing" 1>&2; \\
2416 # Create dist directory.
2417 $output_rules .= ("\t-rm -rf \$(distdir)\n"
2418 . "\tmkdir \$(distdir)\n"
2419 . "\t-chmod 777 \$(distdir)\n");
2422 # Only run automake in `dist' target if --include-deps and
2423 # `no-dependencies' not specified. That way the recipient of a
2424 # distribution can run "make dist" and not need Automake. You
2425 # might be wondering why we run automake once for each directory
2426 # we distribute, instead of running it once at the top level. The
2427 # answer is that we want to run automake after the dependencies
2428 # have been generated. This occurs when "make" is run in the
2429 # subdir. So automake must be run after make has updated the
2430 # Makefile, which means that it must run once per directory.
2431 if ($use_dependencies)
2435 # There are several directories we need to know about
2436 # when rebuilding the Makefile.ins. They are:
2437 # here - The absolute path to our topmost build directory.
2438 # top_distdir - The absolute path to the top of our dist
2440 # distdir - The path to our sub-part of the dist hierarchy.
2441 # If this directory is the topmost directory, we set
2442 # top_distdir from distdir; that lets us pass in distdir
2443 # from an enclosing package.
2444 "\t" . 'here=`cd $(top_builddir) && pwd`; ' . "\\\n"
2445 . "\t" . 'top_distdir=`cd $('
2446 . (($relative_dir eq '.') ? 'distdir' : 'top_distdir')
2447 . ') && pwd`; ' . "\\\n"
2448 . "\t" . 'distdir=`cd $(distdir) && pwd`; ' . "\\\n"
2449 . "\tcd \$(top_srcdir) \\\n"
2450 . "\t && \$(AUTOMAKE) --include-deps --build-dir=\$\$here --srcdir-name=\$(top_srcdir) --output-dir=\$\$top_distdir "
2451 # Set strictness of output.
2452 . ($cygnus_mode ? '--cygnus' : ('--' . $strictness_name))
2453 . ($cmdline_use_dependencies ? '' : ' --include-deps')
2454 . " " . $makefile . "\n"
2458 # Scan EXTRA_DIST to see if we need to distribute anything from a
2459 # subdir. If so, add it to the list. I didn't want to do this
2460 # originally, but there were so many requests that I finally
2463 if (&variable_defined ('EXTRA_DIST'))
2465 # FIXME: This should be fixed to work with conditionals. That
2466 # will require only making the entries in @dist_dirs under the
2467 # appropriate condition. This is meaningful if the nature of
2468 # the distribution should depend upon the configure options
2470 foreach (&variable_value_as_list ('EXTRA_DIST', ''))
2473 next unless s,/+[^/]+$,,;
2474 push (@dist_dirs, $_)
2480 # Prepend $(distdir) to each directory given. Doing it via a
2481 # hash lets us ensure that each directory is used only once.
2483 grep ($dhash{'$(distdir)/' . $_} = 1, @dist_dirs);
2484 $output_rules .= "\t";
2485 &pretty_print_rule ('$(mkinstalldirs)', "\t ", sort keys %dhash);
2488 # In loop, test for file existence because sometimes a file gets
2489 # included in DISTFILES twice. For example this happens when a
2490 # single source file is used in building more than one program.
2491 # Also, there are situations in which "ln" can fail. For instance
2492 # a file to distribute could actually be a cross-filesystem
2493 # symlink -- this can easily happen if "gettextize" was run on the
2495 $output_rules .= "\t\@for file in \$(DISTFILES); do \\\n";
2498 $output_rules .= "\t if test -f \$\$file; then d=.; else d=\$(srcdir); fi; \\\n";
2502 $output_rules .= "\t d=\$(srcdir); \\\n";
2504 $output_rules .= ("\t if test -d \$\$d/\$\$file; then \\\n"
2505 . "\t cp -pr \$\$d/\$\$file \$(distdir)/\$\$file; \\\n"
2507 . "\t test -f \$(distdir)/\$\$file \\\n"
2508 . "\t || ln \$\$d/\$\$file \$(distdir)/\$\$file 2> /dev/null \\\n"
2509 . "\t || cp -p \$\$d/\$\$file \$(distdir)/\$\$file || :; \\\n"
2513 # If we have SUBDIRS, create all dist subdirectories and do
2515 if (&variable_defined ('SUBDIRS'))
2517 # If SUBDIRS is conditionally defined, then set DIST_SUBDIRS
2518 # to all possible directories, and use it. If DIST_SUBDIRS is
2519 # defined, just use it.
2520 local ($dist_subdir_name);
2521 if (&variable_conditions ('SUBDIRS')
2522 || &variable_defined ('DIST_SUBDIRS'))
2524 $dist_subdir_name = 'DIST_SUBDIRS';
2525 if (! &variable_defined ('DIST_SUBDIRS'))
2527 &define_pretty_variable ('DIST_SUBDIRS', '',
2528 &variable_value_as_list ('SUBDIRS',
2534 $dist_subdir_name = 'SUBDIRS';
2537 # Test for directory existence here because previous automake
2538 # invocation might have created some directories. Note that
2539 # we explicitly set distdir for the subdir make; that lets us
2540 # mix-n-match many automake-using packages into one large
2541 # package, and have "dist" at the top level do the right
2542 # thing. If we're in the topmost directory, then we use
2543 # `distdir' instead of `top_distdir'; this lets us work
2544 # correctly with an enclosing package.
2546 ("\t" . 'for subdir in $(' . $dist_subdir_name . '); do ' . "\\\n"
2547 . "\t" . ' if test "$$subdir" = .; then :; else ' . "\\\n"
2548 . "\t" . ' test -d $(distdir)/$$subdir ' . "\\\n"
2549 . "\t" . ' || mkdir $(distdir)/$$subdir ' . "\\\n"
2550 . "\t" . ' || exit 1; ' . "\\\n"
2551 . "\t" . ' chmod 777 $(distdir)/$$subdir; ' . "\\\n"
2552 . "\t" . ' (cd $$subdir'
2553 . ' && $(MAKE) $(AM_MAKEFLAGS) top_distdir=../$('
2554 . (($relative_dir eq '.') ? 'distdir' : 'top_distdir')
2555 . ') distdir=../$(distdir)/$$subdir distdir) ' . "\\\n"
2556 . "\t" . ' || exit 1; ' . "\\\n"
2557 . "\t" . ' fi; ' . "\\\n"
2561 # If the target `dist-hook' exists, make sure it is run. This
2562 # allows users to do random weird things to the distribution
2563 # before it is packaged up.
2564 push (@dist_targets, 'dist-hook') if &target_defined ('dist-hook');
2567 foreach $targ (@dist_targets)
2569 # We must explicitly set distdir and top_distdir for these
2571 $output_rules .= ("\t\$(MAKE) \$(AM_MAKEFLAGS)"
2572 . " top_distdir=\"\$(top_distdir)\""
2573 . " distdir=\"\$(distdir)\" $targ\n");
2576 push (@phony, 'distdir');
2579 # Handle 'dist' target.
2582 local ($makefile) = @_;
2584 # Set up maint_charset.
2585 $local_maint_charset = &variable_value ('MAINT_CHARSET')
2586 if &variable_defined ('MAINT_CHARSET');
2587 $maint_charset = $local_maint_charset
2588 if $relative_dir eq '.';
2590 if (&variable_defined ('DIST_CHARSET'))
2592 &am_line_error ('DIST_CHARSET',
2593 "DIST_CHARSET defined but no MAINT_CHARSET defined")
2594 if ! $local_maint_charset;
2595 if ($relative_dir eq '.')
2597 $dist_charset = &variable_value ('DIST_CHARSET')
2601 &am_line_error ('DIST_CHARSET',
2602 "DIST_CHARSET can only be defined at top level");
2606 # Look for common files that should be included in distribution.
2608 foreach $cfile (@common_files)
2610 if (-f ($relative_dir . "/" . $cfile))
2612 &push_dist_common ($cfile);
2616 # Always require configure.in and configure at top level, even if
2617 # they don't exist. This is especially important for configure,
2618 # since it won't be created until autoconf is run -- which might
2619 # be after automake is run.
2620 &push_dist_common ('configure.in', 'configure')
2621 if $relative_dir eq '.';
2623 # Keys of %dist_common are names of files to distributed. We put
2624 # README first because it then becomes easier to make a
2625 # Usenet-compliant shar file (in these, README must be first).
2626 # FIXME: do more ordering of files here.
2628 if (defined $dist_common{'README'})
2630 push (@coms, 'README');
2631 delete $dist_common{'README'};
2633 push (@coms, sort keys %dist_common);
2635 &define_pretty_variable ("DIST_COMMON", '', @coms);
2636 $output_vars .= "\n";
2639 $output_vars .= &file_contents ('dist-vars') . "\n";
2640 &define_variable ('GZIP_ENV', '--best');
2642 # Put these things in rules section so it is easier for whoever
2643 # reads Makefile.in.
2644 if (! &variable_defined ('distdir'))
2646 if ($relative_dir eq '.')
2648 $output_rules .= "\n" . 'distdir = $(PACKAGE)-$(VERSION)' . "\n";
2652 $output_rules .= ("\n"
2653 . 'distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)'
2657 if ($relative_dir eq '.')
2659 $output_rules .= "top_distdir = \$(distdir)\n\n";
2663 $output_rules .= "\nsubdir = " . $relative_dir . "\n\n";
2666 # Generate 'dist' target, and maybe other dist targets.
2667 if ($relative_dir eq '.')
2669 # Rule to check whether a distribution is viable.
2670 $output_rules .= ('# This target untars the dist file and tries a VPATH configuration. Then
2671 # it guarantees that the distribution is self-contained by making another
2675 GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(AMTAR) xf -
2676 mkdir $(distdir)/=build
2677 mkdir $(distdir)/=inst
2678 dc_install_base=`cd $(distdir)/=inst && pwd`; \\'
2679 . (&target_defined ('distcheck-hook')
2680 ? ("\n\t\$(MAKE) \$(AM_MAKEFLAGS)"
2681 . " distcheck-hook; \\")
2684 cd $(distdir)/=build \\
2687 . ($seen_gettext ? '--with-included-gettext ' : '')
2688 . '--srcdir=.. --prefix=$$dc_install_base \\
2689 && $(MAKE) $(AM_MAKEFLAGS) \\
2690 && $(MAKE) $(AM_MAKEFLAGS) dvi \\
2691 && $(MAKE) $(AM_MAKEFLAGS) check \\
2692 && $(MAKE) $(AM_MAKEFLAGS) install \\
2693 && $(MAKE) $(AM_MAKEFLAGS) installcheck \\
2694 && $(MAKE) $(AM_MAKEFLAGS) dist
2696 @banner="$(distdir).tar.gz is ready for distribution"; \\
2697 dashes=`echo "$$banner" | sed s/./=/g`; \\
2703 local ($dist_all) = ('dist-all: distdir' . "\n"
2706 foreach $curs ('dist', 'dist-shar', 'dist-zip', 'dist-tarZ',
2709 if (defined $options{$curs} || $curs eq 'dist')
2711 $output_rules .= ($curs . ': distdir' . "\n"
2715 $dist_all .= $dist{$curs};
2718 $output_rules .= $dist_all . $dist_trailer;
2721 # Generate distdir target.
2722 &handle_dist_worker ($makefile);
2725 # Scan a single dependency file and rewrite the dependencies as
2726 # appropriate. Essentially this means:
2727 # * Clean out absolute dependencies which are not desirable.
2728 # * Rewrite other dependencies to be relative to $(top_srcdir).
2729 sub scan_dependency_file
2731 local ($depfile) = @_;
2733 if (! open (DEP_FILE, $depfile))
2735 &am_error ("couldn't open \`$depfile': $!");
2738 print "automake: reading $depfile\n" if $verbose;
2740 # Sometimes it is necessary to omit some dependencies.
2741 local (%omit) = %omit_dependencies;
2742 if (&variable_defined ('OMIT_DEPENDENCIES'))
2744 # FIXME: Doesn't work with conditionals. I'm not sure if this
2746 grep ($omit{$_} = 1,
2747 &variable_value_as_list ('OMIT_DEPENDENCIES', ''));
2750 local ($first_line) = 1;
2751 local ($last_line) = 0;
2752 local ($target, @dependencies);
2753 local ($one_dep, $xform);
2756 local ($srcdir_rx, $fixup_rx);
2757 ($fixup_rx = $srcdir_name . '/' . $relative_dir . '/')
2759 ($srcdir_rx = $srcdir_name . '/') =~ s/(\W)/\\$1/g;
2761 local ($rewrite_builddir) = (($top_builddir eq '.')
2763 : $top_builddir . '/');
2768 next if (/$WHITE_PATTERN/o);
2772 # No trailing "\" means this should be the last line of
2773 # the first target. We can have multiple targets due to
2774 # the "deleted header file" fix. For the generated
2775 # Makefile we simply skip these fake targets.
2781 if (! /^([^:]+:)(.+)$/)
2784 &am_error ("\`$depfile' has incorrect format");
2790 # Make sure to strip the .P file from the target.
2791 ($target = $1) =~ s, *\.deps/[^.]+\.P,,;
2796 foreach $one_dep (split (' ', $_))
2798 ($just_file = $one_dep) =~ s,^.*/,,;
2799 next if defined $omit{$just_file};
2801 if ($one_dep =~ /^$fixup_rx/)
2803 # The dependency points to the current directory in
2805 ($xform = $one_dep) =~ s/^$fixup_rx//;
2806 push (@dependencies, $xform);
2808 elsif ($one_dep =~ /^$srcdir_rx/)
2810 # The dependency is in some other directory in the package.
2811 ($xform = $one_dep) =~ s/^$srcdir_rx/$rewrite_builddir/;
2812 push (@dependencies, $xform);
2814 elsif ($one_dep =~ /^\// || $one_dep =~ /^[A-Za-z]:\\/)
2816 # Absolute path; ignore.
2820 # Anything else is assumed to be correct.
2821 push (@dependencies, $one_dep);
2826 &pretty_print_rule ($target, "\t", @dependencies);
2831 # Handle auto-dependency code.
2832 sub handle_dependencies
2834 # Make sure this variable is always marked as used.
2835 &examine_variable ('OMIT_DEPENDENCIES');
2837 if ($use_dependencies)
2839 # Include GNU-make-specific auto-dep code. Don't include it
2840 # if DEP_FILES would be empty.
2841 if (&saw_sources_p (0) && keys %dep_files)
2843 &define_pretty_variable ('DEP_FILES', '', sort keys %dep_files);
2844 $output_rules .= &file_contents ('depend');
2845 push (@clean, 'depend');
2846 &push_phony_cleaners ('depend');
2848 local ($key, $lang, $ext, $xform);
2849 foreach $key (sort keys %language_map)
2851 next unless $key =~ /^(.*)-autodep$/;
2852 next if $language_map{$key} eq 'no';
2855 $xform = 's/\@PFX\@/' . $language_map{$key} . '/g;';
2856 foreach $ext (&lang_extensions ($lang))
2859 &file_contents_with_transform ('s/\@EXT\@/'
2867 elsif ($build_directory ne '')
2869 # Include any auto-generated deps that are present. Note that
2870 # $build_directory ends in a "/".
2871 if (-d ($build_directory . $relative_dir . "/.deps"))
2875 foreach $depfile (&my_glob ($build_directory
2876 . $relative_dir . "/.deps/*.P"))
2878 &scan_dependency_file ($depfile);
2881 $output_rules .= "\n";
2886 # Handle subdirectories.
2889 return if ! &variable_defined ('SUBDIRS');
2891 # Make sure each directory mentioned in SUBDIRS actually exists.
2893 foreach $dir (&variable_value_as_list ('SUBDIRS', 'all'))
2895 # Skip directories substituted by configure.
2896 next if $dir =~ /^\@.*\@$/;
2898 if (! -d $am_relative_dir . '/' . $dir)
2900 &am_line_error ('SUBDIRS',
2901 "required directory $am_relative_dir/$dir does not exist");
2905 &am_line_error ('SUBDIRS', "directory should not contain \`/'")
2909 local ($xform) = ('s/\@INSTALLINFO\@/' .
2910 (defined $options{'no-installinfo'}
2911 ? 'install-info-recursive'
2914 $output_rules .= &file_contents_with_transform ($xform, 'subdirs');
2916 # Push a bunch of phony targets.
2918 foreach $phonies ('-data', '-exec', 'dirs')
2920 push (@phony, 'install' . $phonies . '-recursive');
2921 push (@phony, 'uninstall' . $phonies . '-recursive');
2923 foreach $phonies ('all', 'check', 'installcheck', 'info', 'dvi')
2925 push (@phony, $phonies . '-recursive');
2927 &push_phony_cleaners ('recursive');
2929 $recursive_install = 1;
2932 # Handle aclocal.m4.
2933 sub handle_aclocal_m4
2935 local ($regen_aclocal) = 0;
2936 if (-f 'aclocal.m4')
2938 &define_variable ("ACLOCAL_M4", '$(top_srcdir)/aclocal.m4');
2939 &push_dist_common ('aclocal.m4');
2941 if (open (ACLOCAL, '< aclocal.m4'))
2947 if ($line =~ 'generated automatically by aclocal')
2954 local ($acinclude) = 0;
2955 if (-f 'acinclude.m4')
2961 # Note that it might be possible that aclocal.m4 doesn't exist but
2962 # should be auto-generated. This case probably isn't very
2966 local (@ac_deps) = (
2968 ? "\@MAINTAINER_MODE_TRUE\@"
2971 ($acinclude ? ' acinclude.m4' : '')
2974 # Scan all -I directories for m4 files. These are our
2976 if (&variable_defined ('ACLOCAL_AMFLAGS'))
2978 local ($examine_next, $amdir) = 0;
2979 foreach $amdir (&variable_value_as_list ('ACLOCAL_AMFLAGS', ''))
2984 if ($amdir !~ /^\// && -d $amdir)
2986 push (@ac_deps, &my_glob ($amdir . '/*.m4'));
2989 elsif ($amdir eq '-I')
2996 &pretty_print_rule ("\$(ACLOCAL_M4):", "\t\t", @ac_deps);
2998 $output_rules .= ("\t"
2999 . 'cd $(srcdir) && $(ACLOCAL)'
3000 . (&variable_defined ('ACLOCAL_AMFLAGS')
3001 ? ' $(ACLOCAL_AMFLAGS)' : '')
3006 # Rewrite a list of input files into a form suitable to put on a
3007 # dependency list. The idea is that if an input file has a directory
3008 # part the same as the current directory, then the directory part is
3009 # simply removed. But if the directory part is different, then
3010 # $(top_srcdir) is prepended. Among other things, this is used to
3011 # generate the dependency list for the output files generated by
3012 # AC_OUTPUT. Consider what the dependencies should look like in this
3014 # AC_OUTPUT(src/out:src/in1:lib/in2)
3015 # The first argument, ADD_SRCDIR, is 1 if $(top_srcdir) should be added.
3016 # If 0 then files that require this addition will simply be ignored.
3017 sub rewrite_inputs_into_dependencies
3019 local ($add_srcdir, @inputs) = @_;
3020 local ($single, @newinputs);
3022 foreach $single (@inputs)
3024 if (&dirname ($single) eq $relative_dir)
3026 push (@newinputs, &basename ($single));
3030 push (@newinputs, '$(top_srcdir)/' . $single);
3037 # Handle remaking and configure stuff.
3038 # We need the name of the input file, to do proper remaking rules.
3039 sub handle_configure
3041 local ($local, $input, @secondary_inputs) = @_;
3043 # If SUBDIRS defined, require AC_PROG_MAKE_SET.
3044 &am_line_error ('SUBDIRS', "AC_PROG_MAKE_SET must be used in configure.in")
3045 if &variable_defined ('SUBDIRS') && ! $seen_make_set;
3047 local ($top_reldir);
3049 local ($input_base) = &basename ($input);
3050 local ($local_base) = &basename ($local);
3052 local ($amfile) = $input_base . '.am';
3053 # We know we can always add '.in' because it really should be an
3054 # error if the .in was missing originally.
3055 local ($infile) = '$(srcdir)/' . $input_base . '.in';
3056 local ($colon_infile);
3057 if ($local ne $input || @secondary_inputs)
3059 $colon_infile = ':' . $input . '.in';
3061 $colon_infile .= ':' . join (':', @secondary_inputs)
3062 if @secondary_inputs;
3064 local (@rewritten) = &rewrite_inputs_into_dependencies (1,
3067 # This rule remakes the Makefile.in. Note use of
3068 # @MAINTAINER_MODE_TRUE@ forces us to abandon pretty-printing.
3070 $output_rules .= ($infile
3071 # NOTE perl 5.003 (with -w) gives a
3072 # uninitialized value error on the next line.
3075 . ($seen_maint_mode ? "\@MAINTAINER_MODE_TRUE\@ " : '')
3077 . '$(top_srcdir)/configure.in $(ACLOCAL_M4)'
3078 . ' ' . join (' ', @include_stack)
3080 . "\tcd \$(top_srcdir) && \$(AUTOMAKE) "
3081 . ($cygnus_mode ? '--cygnus' : ('--' . $strictness_name))
3082 . ($cmdline_use_dependencies ? '' : ' --include-deps')
3083 . ' ' . $input . $colon_infile . "\n\n");
3085 # This rule remakes the Makefile.
3086 $output_rules .= ($local_base
3087 # NOTE: bogus uninit value error on next line;
3088 # see comment above.
3091 . join (' ', @rewritten)
3092 . ' $(top_builddir)/config.status'
3093 # NOTE: Makefile only depends on BUILT_SOURCES
3094 # when dependencies are being computed. This is
3095 # a workaround for an obscure bug with
3096 # AC_LINK_FILES. Anyway, when dependencies are
3097 # turned off, this shouldn't matter.
3098 . ($use_dependencies ? ' $(BUILT_SOURCES)' : '')
3100 . "\tcd \$(top_builddir) \\\n"
3101 . "\t && CONFIG_FILES="
3102 . (($relative_dir eq '.') ? '$@' : '$(subdir)/$@')
3104 . ' CONFIG_HEADERS= $(SHELL) ./config.status'
3107 if ($relative_dir ne '.')
3110 $top_reldir = '../';
3115 $output_rules .= &file_contents ('remake');
3116 &examine_variable ('CONFIG_STATUS_DEPENDENCIES');
3117 &examine_variable ('CONFIGURE_DEPENDENCIES');
3120 &push_dist_common ('acconfig.h')
3124 # Make it easy to see if there is a Makefile.am in a given
3126 local (%make_dirs, $iter);
3127 foreach $iter (@configure_input_files)
3129 $make_dirs{&dirname ($iter)} = 1;
3131 # We also want to notice Makefile.in's.
3132 foreach $iter (@other_input_files)
3134 if ($iter =~ /Makefile\.in$/)
3136 $make_dirs{&dirname ($iter)} = 1;
3140 # If we have a configure header, require it.
3142 local (@local_fullnames) = @config_fullnames;
3143 local (@local_names) = @config_names;
3144 local ($hdr_index) = 0;
3145 local ($distclean_config) = '';
3146 foreach $one_hdr (@config_headers)
3148 local ($one_fullname) = shift (@local_fullnames);
3149 local ($one_name) = shift (@local_names);
3151 local ($header_dir) = &dirname ($one_name);
3153 # If the header is in the current directory we want to build
3154 # the header here. Otherwise, if we're at the topmost
3155 # directory and the header's directory doesn't have a
3156 # Makefile, then we also want to build the header.
3157 if ($relative_dir eq $header_dir
3158 || ($relative_dir eq '.' && ! defined $make_dirs{$header_dir}))
3160 local ($ch_sans_dir, $cn_sans_dir, $stamp_dir);
3161 if ($relative_dir eq $header_dir)
3163 $cn_sans_dir = &basename ($one_name);
3168 $cn_sans_dir = $one_name;
3169 if ($header_dir eq '.')
3175 $stamp_dir = $header_dir . '/';
3179 # Compute relative path from directory holding output
3180 # header to directory holding input header. FIXME:
3181 # doesn't handle case where we have multiple inputs.
3182 if (&dirname ($one_hdr) eq $relative_dir)
3184 $ch_sans_dir = &basename ($one_hdr);
3188 local (@rel_out_path);
3189 # FIXME this chunk of code should be its own sub.
3190 # It is used elsewhere.
3191 foreach (split (/\//, $relative_dir))
3193 next if $_ eq '' || $_ eq '.';
3196 # FIXME: actually this is an error.
3201 push (@rel_out_path, '..');
3206 $ch_sans_dir = join ('/', @rel_out_path) . '/' . $one_hdr;
3210 $ch_sans_dir = $one_hdr;
3214 &require_file_with_conf_line ($config_header_line,
3215 $FOREIGN, $ch_sans_dir);
3217 # Header defined and in this directory.
3219 if (-f $one_name . '.top')
3221 push (@files, "${cn_sans_dir}.top");
3223 if (-f $one_name . '.bot')
3225 push (@files, "${cn_sans_dir}.bot");
3228 &push_dist_common (@files);
3230 # For now, acconfig.h can only appear in the top srcdir.
3231 if (-f 'acconfig.h')
3233 if ($relative_dir eq '.')
3235 push (@files, 'acconfig.h');
3239 # Strange quoting because this gets fed through
3241 push (@files, '\$(top_srcdir)/acconfig.h');
3245 local ($stamp_name) = 'stamp-h';
3246 $stamp_name .= "${hdr_index}" if scalar (@config_headers) > 1;
3248 local ($xform) = '';
3250 $xform = 's,\@FILES\@,' . join (' ', @files) . ',;';
3251 $xform .= 's,\@CONFIG_HEADER\@,' . "${cn_sans_dir}" . ',;';
3252 $xform .= 's,\@CONFIG_HEADER_IN\@,' . "${ch_sans_dir}" . ',;';
3253 $xform .= 's,\@CONFIG_HEADER_FULL\@,' . "${one_fullname}" . ',;';
3254 $xform .= 's,\@STAMP\@,' . "${stamp_dir}${stamp_name}" . ',g;';
3256 $output_rules .= &file_contents_with_transform ($xform,
3259 local ($out_dir) = &dirname ($ch_sans_dir);
3260 &create ("${relative_dir}/${out_dir}/${stamp_name}.in");
3261 &require_file_with_conf_line ($config_header_line, $FOREIGN,
3262 "${out_dir}/${stamp_name}.in");
3264 $distclean_config .= ' ' if $distclean_config;
3265 $distclean_config .= $cn_sans_dir;
3269 if ($distclean_config)
3271 $output_rules .= &file_contents_with_transform ('s,\@FILES\@,'
3275 push (@clean, 'hdr');
3276 &push_phony_cleaners ('hdr');
3279 # Set location of mkinstalldirs.
3280 if ($config_aux_dir ne '.' && $config_aux_dir ne '')
3282 &define_variable ('mkinstalldirs', ('$(SHELL) ' . $config_aux_dir
3283 . '/mkinstalldirs'));
3287 &define_variable ('mkinstalldirs',
3288 '$(SHELL) $(top_srcdir)/mkinstalldirs');
3291 &am_line_error ('CONFIG_HEADER',
3292 "\`CONFIG_HEADER' is an anachronism; now determined from \`configure.in'")
3293 if &variable_defined ('CONFIG_HEADER');
3296 local ($config_header) = '';
3297 foreach $one_name (@config_names)
3299 # Generate CONFIG_HEADER define.
3301 if ($relative_dir eq &dirname ($one_name))
3303 $one_hdr = &basename ($one_name);
3307 $one_hdr = "${top_builddir}/${one_name}";
3310 $config_header .= ' ' if $config_header;
3311 $config_header .= $one_hdr;
3315 &define_variable ("CONFIG_HEADER", $config_header);
3318 # Now look for other files in this directory which must be remade
3319 # by config.status, and generate rules for them.
3320 local (@actual_other_files) = ();
3321 local ($file, $local);
3322 local (@inputs, @rewritten_inputs, $single);
3323 local ($need_rewritten);
3324 foreach $file (@other_input_files)
3326 if ($file =~ /^([^:]*):(.*)$/)
3328 # This is the ":" syntax of AC_OUTPUT.
3330 $local = &basename ($file);
3331 @inputs = split (':', $2);
3332 @rewritten_inputs = &rewrite_inputs_into_dependencies (1, @inputs);
3333 $need_rewritten = 1;
3338 $local = &basename ($file);
3339 @inputs = ($local . '.in');
3341 &rewrite_inputs_into_dependencies (1, $file . '.in');
3342 $need_rewritten = 0;
3345 # Skip files not in this directory.
3346 next unless &dirname ($file) eq $relative_dir;
3348 # Skip any file that is an automake input.
3349 next if -f $file . '.am';
3351 # Some users have been tempted to put `stamp-h' in the
3352 # AC_OUTPUT line. This won't do the right thing, so we
3353 # explicitly fail here.
3354 if ($local eq 'stamp-h')
3356 # FIXME: allow real filename.
3357 &am_conf_error ('configure.in', $ac_output_line,
3358 'stamp-h should not appear in AC_OUTPUT');
3362 $output_rules .= ($local . ': '
3363 . '$(top_builddir)/config.status '
3364 . join (' ', @rewritten_inputs) . "\n"
3366 . 'cd $(top_builddir) && CONFIG_FILES='
3367 . ($relative_dir eq '.' ? '' : '$(subdir)/')
3368 . '$@' . ($need_rewritten
3369 ? (':' . join (':', @inputs))
3371 . ' CONFIG_HEADERS= $(SHELL) ./config.status'
3373 &push_dist_common (@inputs);
3374 push (@actual_other_files, $local);
3376 # Require all input files.
3377 &require_file_with_conf_line ($ac_output_line, $FOREIGN,
3378 &rewrite_inputs_into_dependencies (0, @inputs));
3381 # These files get removed by "make clean".
3382 &define_pretty_variable ('CONFIG_CLEAN_FILES', '', @actual_other_files);
3389 @r = &am_install_var ('-defaultdist', 'header', 'HEADERS', 'include',
3390 'oldinclude', 'pkginclude',
3394 next unless /\.(.*)$/;
3395 &saw_extension ($1);
3401 return if ! $seen_gettext || $relative_dir ne '.';
3403 if (! &variable_defined ('SUBDIRS'))
3406 ("AM_GNU_GETTEXT in configure.in but SUBDIRS not defined");
3410 &require_file_with_conf_line ($ac_gettext_line, $GNU, 'ABOUT-NLS');
3412 if (&variable_defined ('SUBDIRS'))
3416 "AM_GNU_GETTEXT in configure.in but \`po' not in SUBDIRS")
3417 if $contents{'SUBDIRS'} !~ /\bpo\b/;
3420 "AM_GNU_GETTEXT in configure.in but \`intl' not in SUBDIRS")
3421 if $contents{'SUBDIRS'} !~ /\bintl\b/;
3424 # Ensure that each language in ALL_LINGUAS has a .po file, and
3425 # each po file is mentioned in ALL_LINGUAS.
3428 local (%linguas) = ();
3429 grep ($linguas{$_} = 1, split (' ', $all_linguas));
3436 &am_line_error ($all_linguas_line,
3437 ("po/$_.po exists but \`$_' not in \`ALL_LINGUAS'"))
3441 foreach (keys %linguas)
3443 &am_line_error ($all_linguas_line,
3444 "$_ in \`ALL_LINGUAS' but po/$_.po does not exist")
3450 &am_error ("AM_GNU_GETTEXT in configure.in but \`ALL_LINGUAS' not defined");
3454 # Handle footer elements.
3457 if ($contents{'SOURCES'})
3459 # NOTE don't use define_pretty_variable here, because
3460 # $contents{...} is already defined.
3461 $output_vars .= 'SOURCES = ' . $contents{'SOURCES'} . "\n";
3463 if ($contents{'OBJECTS'})
3465 # NOTE don't use define_pretty_variable here, because
3466 # $contents{...} is already defined.
3467 $output_vars .= 'OBJECTS = ' . $contents{'OBJECTS'} . "\n";
3469 if ($contents{'SOURCES'} || $contents{'OBJECTS'})
3471 $output_vars .= "\n";
3474 if (&variable_defined ('SUFFIXES'))
3476 # Push actual suffixes, and not $(SUFFIXES). Some versions of
3477 # make do not like variable substitutions on the .SUFFIXES
3479 push (@suffixes, &variable_value_as_list ('SUFFIXES', ''));
3481 if (&target_defined ('.SUFFIXES'))
3483 &am_line_error ('.SUFFIXES',
3484 "use variable \`SUFFIXES', not target \`.SUFFIXES'");
3487 # Note: AIX 4.1 /bin/make will fail if any suffix rule appears
3488 # before .SUFFIXES. So we make sure that .SUFFIXES appears before
3489 # anything else, by sticking it right after the default: target.
3490 $output_header .= ".SUFFIXES:\n";
3494 # Make sure suffixes has unique elements. Sort them to ensure
3495 # the output remains consistent.
3498 grep ($suffixes{$_} = 1, @suffixes);
3500 $output_header .= (".SUFFIXES: "
3501 . join (' ', sort keys %suffixes)
3504 $output_trailer .= &file_contents ('footer');
3507 # Deal with installdirs target.
3508 sub handle_installdirs
3510 # GNU Makefile standards recommend this.
3511 if ($recursive_install)
3513 # We create a separate `-am' target so that the -recursive
3514 # rule will work correctly.
3515 $output_rules .= ("installdirs: installdirs-recursive\n"
3516 . "installdirs-am:\n");
3517 push (@phony, 'installdirs-am');
3521 $output_rules .= "installdirs:\n";
3523 push (@phony, 'installdirs');
3526 &pretty_print_rule ("\t" . '$(mkinstalldirs) ', "\t\t",
3529 $output_rules .= "\n";
3532 # There are several targets which need to be merged. This is because
3533 # their complete definition is compiled from many parts. Note that we
3534 # avoid double colon rules, otherwise we'd use them instead.
3535 sub handle_merge_targets
3537 local ($makefile) = @_;
3539 # There are a few install-related variables that you should not define.
3541 foreach $var ('PRE_INSTALL', 'POST_INSTALL', 'NORMAL_INSTALL')
3543 if (&variable_defined ($var))
3545 &am_line_error ($var, "\`$var' should not be defined");
3549 # Put this at the beginning for the sake of non-GNU makes. This
3550 # is still wrong if these makes can run parallel jobs. But it is
3552 unshift (@all, &basename ($makefile));
3555 foreach $one_name (@config_names)
3557 push (@all, &basename ($one_name))
3558 if &dirname ($one_name) eq $relative_dir;
3561 &do_one_merge_target ('info', @info);
3562 &do_one_merge_target ('dvi', @dvi);
3563 &do_check_merge_target;
3564 &do_one_merge_target ('installcheck', @installcheck);
3566 if (defined $options{'no-installinfo'})
3568 &do_one_merge_target ('install-info', '');
3570 elsif (&target_defined ('install-info-local'))
3572 &am_line_error ('install-info-local',
3573 "\`install-info-local' target defined but \`no-installinfo' option not in use");
3577 foreach $utarg ('uninstall-data-local', 'uninstall-data-hook',
3578 'uninstall-exec-local', 'uninstall-exec-hook')
3580 if (&target_defined ($utarg))
3583 ($x = $utarg) =~ s/(data|exec)-//;
3584 &am_line_error ($utarg, "use \`$x', not \`$utarg'");
3588 if (&target_defined ('install-local'))
3590 &am_line_error ('install-local',
3591 "use \`install-data-local' or \`install-exec-local', not \`install-local'");
3597 local ($local_headers) = '';
3598 foreach $one_name (@config_names)
3600 if (&dirname ($one_name) eq $relative_dir)
3602 $local_headers .= ' ' if $local_headers;
3603 $local_headers .= &basename ($one_name);
3608 # This is kind of a hack, but I couldn't see a better way
3609 # to handle it. In this particular case, we need to make
3610 # sure config.h is built before we recurse. We can't do
3611 # this by changing the order of dependencies to the "all"
3612 # because that breaks when using parallel makes. Instead
3613 # we handle things explicitly.
3614 $output_rules .= ("all-recursive-am: ${local_headers}"
3616 . '$(MAKE) $(AM_MAKEFLAGS)'
3619 $all_target = 'all-recursive-am';
3620 push (@phony, 'all-recursive-am');
3624 # Print definitions users can use.
3625 &do_one_merge_target ('install-exec', @install_exec);
3626 $output_rules .= "\n";
3628 &do_one_merge_target ('install-data', @install_data);
3629 $output_rules .= "\n";
3631 &do_one_merge_target ('install', 'all-am');
3632 &do_one_merge_target ('uninstall', @uninstall);
3634 &do_one_merge_target ('all', @all);
3636 # Generate the new 'install-strip' target. We can't just set
3637 # INSTALL_PROGRAM because that might be a relative path.
3638 $output_rules .= ("install-strip:\n\t"
3639 . '$(MAKE) $(AM_MAKEFLAGS) INSTALL_STRIP_FLAG=-s install'
3641 push (@phony, 'install-strip');
3644 # Helper for handle_merge_targets. Note that handle_merge_targets
3645 # relies on the fact that this doesn't add an extra \n at the end.
3646 sub do_one_merge_target
3648 local ($name, @values) = @_;
3650 if (&target_defined ($name . '-local'))
3652 # User defined local form of target. So include it.
3653 push (@values, $name . '-local');
3654 push (@phony, $name . '-local');
3657 &pretty_print_rule ($name . "-am:", "\t\t", @values);
3658 if ($name eq 'install')
3660 # Special-case `install-am' to run install-exec-am and
3661 # install-data-am after all-am is built.
3662 &pretty_print_rule ("\t\@\$(MAKE) \$(AM_MAKEFLAGS)", "\t ",
3663 'install-exec-am', 'install-data-am');
3665 elsif ($name eq 'install-exec' && &target_defined ('install-exec-hook'))
3667 $output_rules .= ("\t\@\$(NORMAL_INSTALL)\n"
3668 . "\t" . '$(MAKE) $(AM_MAKEFLAGS) install-exec-hook'
3671 elsif ($name eq 'install-data' && &target_defined ('install-data-hook'))
3673 $output_rules .= ("\t\@\$(NORMAL_INSTALL)\n"
3674 . "\t" . '$(MAKE) $(AM_MAKEFLAGS) install-data-hook'
3678 local ($lname) = $name . ($recursive_install ? '-recursive' : '-am');
3679 local ($tname) = $name;
3680 # To understand this special case, see handle_merge_targets.
3683 $tname = 'all-redirect';
3684 $lname = $all_target if $recursive_install;
3685 push (@phony, 'all-redirect');
3686 $output_all = "all: all-redirect\n";
3688 &pretty_print_rule ($tname . ":", "\t\t", $lname);
3689 push (@phony, $name . '-am', $name);
3692 # Handle check merge target specially.
3693 sub do_check_merge_target
3695 if (&target_defined ('check-local'))
3697 # User defined local form of target. So include it.
3698 push (@check_tests, 'check-local');
3699 push (@phony, 'check-local');
3702 # In --cygnus mode, check doesn't depend on all.
3705 # Just run the local check rules.
3706 &pretty_print_rule ('check-am:', "\t\t", @check);
3710 # The check target must depend on the local equivalent of
3711 # `all', to ensure all the primary targets are built. Then it
3712 # must build the local check rules.
3713 $output_rules .= "check-am: all-am\n";
3714 &pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ",
3718 &pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ",
3722 push (@phony, 'check', 'check-am');
3723 $output_rules .= ("check: "
3724 . ($recursive_install ? 'check-recursive' : 'check-am')
3728 # Handle all 'clean' targets.
3731 local ($xform) = '';
3734 # Don't include `MAINTAINER'; it is handled specially below.
3735 foreach $name ('MOSTLY', '', 'DIST')
3737 if (! &variable_defined ($name . 'CLEANFILES'))
3739 $xform .= 's/^' . $name . 'CLEAN.*$//;';
3743 $xform .= 's/^' . $name . 'CLEAN//;';
3747 # Built sources are automatically removed by maintainer-clean.
3748 push (@maintainer_clean_files, '\$(BUILT_SOURCES)')
3749 if &variable_defined ('BUILT_SOURCES');
3750 push (@maintainer_clean_files, '\$(MAINTAINERCLEANFILES)')
3751 if &variable_defined ('MAINTAINERCLEANFILES');
3752 if (! @maintainer_clean_files)
3754 $xform .= 's/^MAINTAINERCLEAN.*$//;';
3758 $xform .= ('s/^MAINTAINERCLEAN//;'
3759 # Join with no space to avoid spurious `test -z'
3760 # success at runtime.
3761 . 's,\@MCFILES\@,' . join ('', @maintainer_clean_files)
3763 # A space is required in the join here.
3764 . 's,\@MFILES\@,' . join (' ', @maintainer_clean_files)
3768 $output_rules .= &file_contents_with_transform ($xform, 'clean');
3770 push (@clean, 'generic');
3771 &push_phony_cleaners ('generic');
3773 &do_one_clean_target ('clean', 'mostly', '', @clean);
3774 &do_one_clean_target ('clean', '', 'mostly', @clean);
3775 &do_one_clean_target ('clean', 'dist', '', @clean);
3776 &do_one_clean_target ('clean', 'maintainer-', 'dist', @clean);
3778 push (@phony, 'clean', 'mostlyclean', 'distclean', 'maintainer-clean');
3781 # Helper for handle_clean.
3782 sub do_one_clean_target
3784 local ($target, $name, $last_name, @deps) = @_;
3786 # Change each dependency `BLARG' into `clean-BLARG'.
3787 grep (($_ = $name . 'clean-' . $_) && 0, @deps);
3789 # Push the previous clean target. There is no previous clean
3790 # target if we're doing mostlyclean.
3791 push (@deps, $last_name . $target . '-am')
3792 unless $name eq 'mostly';
3794 # If a -local version of the rule is given, add it to the list.
3795 if (&target_defined ($name . $target . '-local'))
3797 push (@deps, $name . $target . '-local');
3800 # Print the target and the dependencies.
3801 &pretty_print_rule ($name . $target . "-am: ", "\t\t", @deps);
3803 # FIXME: shouldn't we really print these messages before running
3805 if ($name . $target eq 'maintainer-clean')
3807 # Print a special warning.
3809 ("\t\@echo \"This command is intended for maintainers to use;\"\n"
3810 . "\t\@echo \"it deletes files that may require special "
3811 . "tools to rebuild.\"\n");
3813 elsif ($name . $target eq 'distclean')
3815 $output_rules .= "\t-rm -f libtool\n" if $seen_libtool;
3817 $output_rules .= "\n";
3819 # Now generate the actual clean target.
3820 $output_rules .= ($name . $target . ": " . $name . $target
3821 . ($recursive_install ? '-recursive' : '-am')
3824 # We special-case config.status here. If we do it as part of the
3825 # normal clean processing for this directory, then it might be
3826 # removed before some subdir is cleaned. However, that subdir's
3827 # Makefile depends on config.status.
3828 if (($name . $target eq 'maintainer-clean'
3829 || $name . $target eq 'distclean')
3830 && $relative_dir eq '.')
3832 $output_rules .= "\t-rm -f config.status\n";
3834 $output_rules .= "\n";
3837 # Handle .PHONY target.
3840 &pretty_print_rule ('.PHONY:', "", @phony);
3841 $output_rules .= "\n";
3844 # Handle TESTS variable and other checks.
3847 if (defined $options{'dejagnu'})
3849 push (@check_tests, 'check-DEJAGNU');
3850 push (@phony, 'check-DEJAGNU');
3855 $xform = 's/^CYGNUS//;';
3859 $xform = 's/^CYGNUS.*$//;';
3861 $output_rules .= &file_contents_with_transform ($xform, 'dejagnu');
3863 # In Cygnus mode, these are found in the build tree.
3864 # Otherwise they are looked for in $PATH.
3865 &define_program_variable ('EXPECT', 'build', 'expect', 'expect');
3866 &define_program_variable ('RUNTEST', 'src', 'dejagnu', 'runtest');
3868 # Only create site.exp rule if user hasn't already written
3870 if (! &target_defined ('site.exp'))
3872 # Note that in the rule we don't directly generate
3873 # site.exp to avoid the possibility of a corrupted
3874 # site.exp if make is interrupted. Jim Meyering has some
3875 # useful text on this topic.
3876 $output_rules .= ("site.exp: Makefile\n"
3877 . "\t\@echo 'Making a new site.exp file...'\n"
3878 . "\t\@test ! -f site.bak || rm -f site.bak\n"
3879 . "\t\@echo '## these variables are automatically generated by make ##' > \$\@-t\n"
3880 . "\t\@echo '# Do not edit here. If you wish to override these values' >> \$\@-t\n"
3881 . "\t\@echo '# edit the last section' >> \$\@-t\n"
3882 . "\t\@echo 'set tool \$(DEJATOOL)' >> \$\@-t\n"
3883 . "\t\@echo 'set srcdir \$(srcdir)' >> \$\@-t\n"
3884 . "\t\@echo 'set objdir' \`pwd\` >> \$\@-t\n");
3886 # Extra stuff for AC_CANONICAL_*
3887 local (@whatlist) = ();
3888 if ($seen_canonical)
3890 push (@whatlist, 'host');
3893 # Extra stuff only for AC_CANONICAL_SYSTEM.
3894 if ($seen_canonical == $AC_CANONICAL_SYSTEM)
3896 push (@whatlist, 'target', 'build');
3900 foreach $c1 (@whatlist)
3902 foreach $c2 ('alias', 'triplet')
3904 $output_rules .= "\t\@echo 'set ${c1}_${c2} \$(${c1}_${c2})' >> \$\@-t\n";
3908 $output_rules .= ("\t\@echo '## All variables above are generated by configure. Do Not Edit ##' >> \$\@-t\n"
3909 . "\t\@test ! -f site.exp || sed '1,/^## All variables above are.*##/ d' site.exp >> \$\@-t\n"
3910 . "\t\@test ! -f site.exp || mv site.exp site.bak\n"
3911 . "\t\@mv \$\@-t site.exp\n");
3917 foreach $c ('DEJATOOL', 'RUNTEST', 'RUNTESTFLAGS')
3919 if (&variable_defined ($c))
3921 &am_line_error ($c, "\`$c' defined but \`dejagnu' not in \`AUTOMAKE_OPTIONS'");
3926 if (&variable_defined ('TESTS'))
3928 push (@check_tests, 'check-TESTS');
3929 push (@phony, 'check-TESTS');
3931 # Note: Solaris 2.7 seems to expand TESTS using VPATH. That's
3932 # why we also try `dir='
3933 $output_rules .= 'check-TESTS: $(TESTS)
3934 @failed=0; all=0; xfail=0; xpass=0; \\
3935 srcdir=$(srcdir); export srcdir; \\
3936 for tst in $(TESTS); do \\
3937 if test -f ./$$tst; then dir=./; \\
3938 elif test -f $$tst; then dir=; \\
3939 else dir="$(srcdir)/"; fi; \\
3940 if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \\
3941 all=`expr $$all + 1`; \\
3942 case " $(XFAIL_TESTS) " in \\
3944 xpass=`expr $$xpass + 1`; \\
3945 failed=`expr $$failed + 1`; \\
3946 echo "XPASS: $$tst"; \\
3949 echo "PASS: $$tst"; \\
3952 elif test $$? -ne 77; then \\
3953 all=`expr $$all + 1`; \\
3954 case " $(XFAIL_TESTS) " in \\
3956 xfail=`expr $$xfail + 1`; \\
3957 echo "XFAIL: $$tst"; \\
3960 failed=`expr $$failed + 1`; \\
3961 echo "FAIL: $$tst"; \\
3966 if test "$$failed" -eq 0; then \\
3967 if test "$$xfail" -eq 0; then \\
3968 banner="All $$all tests passed"; \\
3970 banner="All $$all tests behaved as expected ($$xfail expected failures)"; \\
3973 if test "$$xpass" -eq 0; then \\
3974 banner="$$failed of $$all tests failed"; \\
3976 banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \\
3979 dashes=`echo "$$banner" | sed s/./=/g`; \\
3983 test "$$failed" -eq 0
3988 # Handle Emacs Lisp.
3989 sub handle_emacs_lisp
3991 local (@elfiles) = &am_install_var ('-candist', 'lisp', 'LISP',
3997 &define_configure_variable ('lispdir');
3998 &define_configure_variable ('EMACS');
3999 $output_rules .= (".el.elc:\n"
4000 . "\t\@echo 'WARNING: Warnings can be ignored. :-)'\n"
4001 . "\tif test \$(EMACS) != no; then \\\n"
4002 . "\t EMACS=\$(EMACS) \$(SHELL) \$(srcdir)/elisp-comp \$<; \\\n"
4004 push (@suffixes, '.el', '.elc');
4006 # Generate .elc files.
4007 grep ($_ .= 'c', @elfiles);
4008 &define_pretty_variable ('ELCFILES', '', @elfiles);
4010 $output_rules .= &file_contents ('lisp-clean');
4011 push (@clean, 'lisp');
4012 &push_phony_cleaners ('lisp');
4014 push (@all, '$(ELCFILES)');
4017 if (&variable_defined ('lisp_LISP'))
4019 $varname = 'lisp_LISP';
4020 &am_error ("\`lisp_LISP' defined but \`AM_PATH_LISPDIR' not in \`configure.in'")
4025 $varname = 'noinst_LISP';
4028 &require_file_with_line ($varname, $FOREIGN, 'elisp-comp');
4035 local (@sourcelist) = &am_install_var ('-candist', '-clean',
4037 'java', 'noinst', 'check');
4038 return if ! @sourcelist;
4040 &define_variable ('JAVAC', 'javac');
4041 &define_variable ('JAVACFLAGS', '');
4042 &define_variable ('CLASSPATH_ENV',
4043 'CLASSPATH=$(JAVAROOT):$(srcdir)/$(JAVAROOT):$$CLASSPATH');
4044 &define_variable ('JAVAROOT', '$(top_builddir)');
4046 local (%valid) = &am_primary_prefixes ('JAVA', 1,
4047 'java', 'noinst', 'check');
4049 local ($dir, $curs);
4050 foreach $curs (keys %valid)
4052 if (! &variable_defined ($curs . '_JAVA') || $curs eq 'noinst'
4053 || $curs eq 'EXTRA')
4060 &am_line_error ($curs . '_JAVA',
4061 "multiple _JAVA primaries in use");
4066 $output_rules .= ('class' . $dir . '.stamp: $(' . $dir . '_JAVA)' . "\n"
4067 . "\t" . '$(CLASSPATH_ENV) $(JAVAC) -d $(JAVAROOT) '
4068 . '$(JAVACFLAGS) $?' . "\n"
4069 . "\t" . 'echo timestamp > class' . $dir . '.stamp'
4071 push (@all, 'class' . $dir . '.stamp');
4072 &push_dist_common ('$(' . $dir . '_JAVA)');
4075 # Handle some of the minor options.
4076 sub handle_minor_options
4078 if (defined $options{'readme-alpha'})
4080 if ($relative_dir eq '.')
4082 if ($package_version !~ /^$GNITS_VERSION_PATTERN$/)
4084 # FIXME: allow real filename.
4085 &am_conf_line_error ('configure.in',
4086 $package_version_line,
4087 "version \`$package_version' doesn't follow Gnits standards");
4089 elsif (defined $1 && -f 'README-alpha')
4091 # This means we have an alpha release. See
4092 # GNITS_VERSION_PATTERN for details.
4093 &require_file ($FOREIGN, 'README-alpha');
4099 ################################################################
4101 # Scan one file for interesting things. Subroutine of scan_configure.
4102 sub scan_one_configure_file
4104 local ($filename) = @_;
4107 open (CONFIGURE, $filename)
4108 || die "automake: couldn't open \`$filename': $!\n";
4109 print "automake: reading $filename\n" if $verbose;
4113 # Remove comments from current line.
4117 # Skip macro definitions. Otherwise we might be confused into
4118 # thinking that a macro that was only defined was actually
4122 # Follow includes. This is a weirdness commonly in use at
4123 # Cygnus and hopefully nowhere else.
4124 if (/sinclude\((.*)\)/ && -f $1)
4126 &scan_one_configure_file ($1);
4129 # Populate libobjs array.
4130 if (/AC_FUNC_ALLOCA/)
4132 $libsources{'alloca.c'} = 1;
4134 elsif (/AC_FUNC_GETLOADAVG/)
4136 $libsources{'getloadavg.c'} = 1;
4138 elsif (/AC_FUNC_MEMCMP/)
4140 $libsources{'memcmp.c'} = 1;
4142 elsif (/AC_STRUCT_ST_BLOCKS/)
4144 $libsources{'fileblocks.c'} = 1;
4146 elsif (/A[CM]_REPLACE_GNU_GETOPT/)
4148 $libsources{'getopt.c'} = 1;
4149 $libsources{'getopt1.c'} = 1;
4151 elsif (/AM_FUNC_STRTOD/)
4153 $libsources{'strtod.c'} = 1;
4155 elsif (/AM_WITH_REGEX/)
4157 $libsources{'rx.c'} = 1;
4158 $libsources{'rx.h'} = 1;
4159 $libsources{'regex.c'} = 1;
4160 $libsources{'regex.h'} = 1;
4161 $omit_dependencies{'rx.h'} = 1;
4162 $omit_dependencies{'regex.h'} = 1;
4164 elsif (/AM_FUNC_MKTIME/)
4166 $libsources{'mktime.c'} = 1;
4168 elsif (/AM_FUNC_ERROR_AT_LINE/)
4170 $libsources{'error.c'} = 1;
4171 $libsources{'error.h'} = 1;
4173 elsif (/AM_FUNC_OBSTACK/)
4175 $libsources{'obstack.c'} = 1;
4176 $libsources{'obstack.h'} = 1;
4178 elsif (/LIBOBJS="(.*)\s+\$LIBOBJS"/
4179 || /LIBOBJS="\$LIBOBJS\s+(.*)"/)
4181 foreach $libobj_iter (split (' ', $1))
4183 if ($libobj_iter =~ /^(.*)\.o(bj)?$/
4184 || $libobj_iter =~ /^(.*)\.\$ac_objext$/
4185 || $libobj_iter =~ /^(.*)\.\$\{ac_objext\}$/)
4187 $libsources{$1 . '.c'} = 1;
4192 if (! $in_ac_replace && s/AC_REPLACE_FUNCS\s*\(\[?//)
4198 $in_ac_replace = 0 if s/[\]\)].*$//;
4199 # Remove trailing backslash.
4203 # Need to skip empty elements for Perl 4.
4205 $libsources{$_ . '.c'} = 1;
4209 if (/$obsolete_rx/o)
4212 if ($obsolete_macros{$1} ne '')
4214 $hint = '; ' . $obsolete_macros{$1};
4216 &am_conf_line_error ($filename, $., "\`$1' is obsolete$hint");
4219 # Process the AC_OUTPUT macro.
4220 if (! $in_ac_output && s/AC_OUTPUT\s*\(\[?//)
4223 $ac_output_line = $.;
4227 local ($closing) = 0;
4234 # Look at potential Makefile.am's.
4237 # Must skip empty string for Perl 4.
4238 next if $_ eq "\\" || $_ eq '';
4240 # Handle $local:$input syntax. Note that we ignore
4241 # every input file past the first, though we keep
4242 # those around for later.
4243 local ($local, $input, @rest) = split (/:/);
4250 # FIXME: should be error if .in is missing.
4251 $input =~ s/\.in$//;
4254 if (-f $input . '.am')
4256 # We have a file that automake should generate.
4257 push (@make_input_list, $input);
4258 $make_list{$input} = join (':', ($local, @rest));
4262 # We have a file that automake should cause to be
4263 # rebuilt, but shouldn't generate itself.
4264 push (@other_input_files, $_);
4268 if ($closing && @make_input_list == 0 && @other_input_files == 0)
4270 &am_conf_line_error ($filename, $ac_output_line,
4271 "No files mentioned in \`AC_OUTPUT'");
4276 if (/$AC_CONFIG_AUX_DIR_PATTERN/o)
4278 @config_aux_path = $1;
4281 # Check for ansi2knr.
4282 $am_c_prototypes = 1 if /AM_C_PROTOTYPES/;
4284 # Check for exe extension stuff.
4288 $configure_vars{'EXEEXT'} = $filename . ':' . $.;
4294 $configure_vars{'OBJEXT'} = $filename . ':' . $.;
4297 # Check for `-c -o' code.
4298 $seen_cc_c_o = 1 if /AM_PROG_CC_C_O/;
4300 # Check for NLS support.
4301 if (/AM_GNU_GETTEXT/)
4304 $ac_gettext_line = $.;
4305 $omit_dependencies{'libintl.h'} = 1;
4308 # Look for ALL_LINGUAS.
4309 if (/ALL_LINGUAS="(.*)"$/ || /ALL_LINGUAS=(.*)$/)
4313 $all_linguas_line = $.;
4316 # Handle configuration headers. A config header of `[$1]'
4317 # means we are actually scanning AM_CONFIG_HEADER from
4319 if (/A([CM])_CONFIG_HEADER\s*\((.*)\)/
4323 ($filename, $., "\`automake requires \`AM_CONFIG_HEADER', not \`AC_CONFIG_HEADER'")
4326 $config_header_line = $.;
4328 foreach $one_hdr (split (' ', $2))
4330 push (@config_fullnames, $one_hdr);
4331 if ($one_hdr =~ /^([^:]+):(.+)$/)
4333 push (@config_names, $1);
4334 push (@config_headers, $2);
4338 push (@config_names, $one_hdr);
4339 push (@config_headers, $one_hdr . '.in');
4344 # Handle AC_CANONICAL_*. Always allow upgrading to
4345 # AC_CANONICAL_SYSTEM, but never downgrading.
4346 $seen_canonical = $AC_CANONICAL_HOST
4347 if ! $seen_canonical
4348 && (/AC_CANONICAL_HOST/ || /AC_CHECK_TOOL/);
4349 $seen_canonical = $AC_CANONICAL_SYSTEM if /AC_CANONICAL_SYSTEM/;
4351 $seen_path_xtra = 1 if /AC_PATH_XTRA/;
4353 # This macro handles several different things.
4354 if (/$AM_INIT_AUTOMAKE_PATTERN/o)
4360 $seen_prog_install = 1;
4361 ($package_version = $1) =~ s/$AM_PACKAGE_VERSION_PATTERN/$1/o;
4362 $package_version_line = $.;
4365 # This is like AM_INIT_AUTOMAKE, but doesn't actually set the
4366 # package and version number. (This might change in the
4367 # future). Yes, I'm not above hacking Automake so it works
4368 # well with other GNU tools -- that is actually the point.
4369 if (/AM_INIT_GUILE_MODULE/)
4375 $seen_prog_install = 1;
4376 @config_aux_path = ('..');
4379 # Some things required by Automake.
4380 $seen_make_set = 1 if /AC_PROG_MAKE_SET/;
4381 $seen_arg_prog = 1 if /AC_ARG_PROGRAM/;
4385 $configure_vars{'LEX'} = $filename . ':' . $.;
4386 $seen_decl_yytext = 1;
4388 if (/AC_DECL_YYTEXT/ && $filename =~ /configure\.in$/)
4390 &am_conf_line_warning ($filename, $., "\`AC_DECL_YYTEXT' is covered by \`AM_PROG_LEX'");
4392 if (/AC_PROG_LEX/ && $filename =~ /configure\.in$/)
4394 &am_conf_line_warning ($filename, $., "automake requires \`AM_PROG_LEX', not \`AC_PROG_LEX'");
4397 if (/AC_PROG_(F77|YACC|RANLIB|CC|CXXCPP|CXX|LEX|AWK|CPP|LN_S)/)
4399 $configure_vars{$1} = $filename . ':' . $.;
4401 if (/$AC_CHECK_PATTERN/o)
4403 $configure_vars{$3} = $filename . ':' . $.;
4405 if (/$AM_MISSING_PATTERN/o
4409 && $1 ne 'AUTOHEADER')
4411 $configure_vars{$1} = $filename . ':' . $.;
4414 # Explicitly avoid ANSI2KNR -- we AC_SUBST that in protos.m4,
4415 # but later define it elsewhere. This is pretty hacky. We
4416 # also explicitly avoid INSTALL_SCRIPT and some other
4417 # variables because they are defined in header-vars.am.
4419 if (/$AC_SUBST_PATTERN/o
4421 && $1 ne 'INSTALL_SCRIPT'
4422 && $1 ne 'INSTALL_DATA')
4424 $configure_vars{$1} = $filename . ':' . $.;
4427 $seen_decl_yytext = 1 if /AC_DECL_YYTEXT/;
4428 if (/AM_MAINTAINER_MODE/)
4430 $seen_maint_mode = 1;
4431 $configure_cond{'MAINTAINER_MODE'} = 1;
4433 $seen_package = 1 if /PACKAGE=/;
4435 # Skip VERSION of [$2]; that is from AM_INIT_AUTOMAKE.
4436 if (/\bVERSION=(\S+)/ && $1 ne '[$2]')
4439 $package_version = $1;
4440 $package_version_line = $.;
4447 $seen_prog_install = 1 if /AC_PROG_INSTALL/;
4448 $seen_lispdir = 1 if /AM_PATH_LISPDIR/;
4450 if (/A(C|M)_PROG_LIBTOOL/)
4452 if (/AM_PROG_LIBTOOL/)
4454 &am_conf_line_warning ($filename, $., "\`AM_PROG_LIBTOOL' is obsolete, use \`AC_PROG_LIBTOOL' instead");
4458 $configure_vars{'LIBTOOL'} = $filename . ':' . $.;
4459 $configure_vars{'RANLIB'} = $filename . ':' . $.;
4460 $configure_vars{'CC'} = $filename . ':' . $.;
4461 # AC_PROG_LIBTOOL runs AC_CANONICAL_HOST. Make sure we
4462 # never downgrade (if we've seen AC_CANONICAL_SYSTEM).
4463 $seen_canonical = $AC_CANONICAL_HOST if ! $seen_canonical;
4466 $seen_multilib = 1 if (/AM_ENABLE_MULTILIB/);
4468 if (/$AM_CONDITIONAL_PATTERN/o)
4470 $configure_cond{$1} = 1;
4473 # Check for Fortran 77 intrinsic and run-time libraries.
4474 if (/AC_F77_LIBRARY_LDFLAGS/)
4476 $configure_vars{'FLIBS'} = $filename . ':' . $.;
4483 # Scan configure.in and aclocal.m4 for interesting things. We must
4484 # scan aclocal.m4 because there might be AC_SUBSTs and such there.
4487 # Reinitialize libsources here. This isn't really necessary,
4488 # since we currently assume there is only one configure.in. But
4489 # that won't always be the case.
4492 local ($in_ac_output, $in_ac_replace) = (0, 0);
4493 local (%make_list, @make_input_list);
4494 local ($libobj_iter);
4496 &scan_one_configure_file ('configure.in');
4497 &scan_one_configure_file ('aclocal.m4')
4500 # Set input and output files if not specified by user.
4503 @input_files = @make_input_list;
4504 %output_files = %make_list;
4507 @configure_input_files = @make_input_list;
4509 &am_conf_error ("\`PACKAGE' not defined in configure.in")
4511 &am_conf_error ("\`VERSION' not defined in configure.in")
4514 # Look for some files we need. Always check for these. This
4515 # check must be done for every run, even those where we are only
4516 # looking at a subdir Makefile. We must set relative_dir so that
4517 # the file-finding machinery works.
4518 local ($relative_dir) = '.';
4519 &require_config_file ($FOREIGN, 'install-sh', 'mkinstalldirs', 'missing');
4520 &am_error ("\`install.sh' is an anachronism; use \`install-sh' instead")
4521 if -f $config_aux_path[0] . '/install.sh';
4524 ################################################################
4526 # Set up for Cygnus mode.
4529 return unless $cygnus_mode;
4531 &set_strictness ('foreign');
4532 $options{'no-installinfo'} = 1;
4533 $options{'no-dependencies'} = 1;
4534 $use_dependencies = 0;
4536 if (! $seen_maint_mode)
4538 &am_conf_error ("\`AM_MAINTAINER_MODE' required when --cygnus specified");
4543 &am_conf_error ("\`AC_EXEEXT' required when --cygnus specified");
4547 # Do any extra checking for GNU standards.
4548 sub check_gnu_standards
4550 if ($relative_dir eq '.')
4552 # In top level (or only) directory.
4553 &require_file ($GNU, 'INSTALL', 'NEWS', 'README', 'COPYING',
4554 'AUTHORS', 'ChangeLog');
4557 if ($strictness >= $GNU)
4559 if (defined $options{'no-installman'})
4561 &am_line_error ('AUTOMAKE_OPTIONS',
4562 "option \`no-installman' disallowed by GNU standards");
4565 if (defined $options{'no-installinfo'})
4567 &am_line_error ('AUTOMAKE_OPTIONS',
4568 "option \`no-installinfo' disallowed by GNU standards");
4573 # Do any extra checking for GNITS standards.
4574 sub check_gnits_standards
4576 if ($strictness >= $GNITS)
4578 if (-f $relative_dir . '/COPYING.LIB')
4580 &am_error ("\`${relative_dir}/COPYING.LIB' disallowed by Gnits standards");
4584 if ($relative_dir eq '.')
4586 # In top level (or only) directory.
4587 &require_file ($GNITS, 'THANKS');
4591 ################################################################
4593 # Functions to handle files of each language.
4595 # Each `lang_X_rewrite' function follows a simple formula:
4596 # * Args are the directory, base name and extension of the file.
4597 # * Return value is 1 if file is to be dealt with, 0 otherwise.
4598 # Much of the actual processing is handled in handle_single_transform_list.
4599 # These functions exist so that auxiliary information can be recorded
4600 # for a later cleanup pass. Note that the calls to these functions
4601 # are computed, so don't bother searching for their precise names
4604 # This is just a convenience function that can be used to determine
4605 # when a subdir object should be used.
4608 return defined $options{'subdir-objects'} ? $LANG_SUBDIR : $LANG_PROCESS;
4611 # Rewrite a single C source file.
4614 local ($directory, $base, $ext) = @_;
4616 if (defined $options{'ansi2knr'} && $base =~ /_$/)
4618 # FIXME: include line number in error.
4619 &am_error ("C source file \`$base.c' would be deleted by ansi2knr rules");
4622 local ($r) = $LANG_PROCESS;
4623 if (defined $options{'subdir-objects'})
4626 $base = $directory . '/' . $base;
4630 # Only give error once.
4632 # FIXME: line number.
4633 &am_error ("C objects in subdir but \`AM_PROG_CC_C_O' not in \`configure.in'");
4636 &require_file ($FOREIGN, 'compile')
4637 if $relative_dir eq '.';
4640 $de_ansi_files{$base} = 1;
4644 # Rewrite a single C++ source file.
4645 sub lang_cxx_rewrite
4647 return &lang_sub_obj;
4650 # Rewrite a single header file.
4651 sub lang_header_rewrite
4653 # Header files are simply ignored.
4654 return $LANG_IGNORE;
4657 # Rewrite a single yacc file.
4658 sub lang_yacc_rewrite
4660 local ($directory, $base, $ext) = @_;
4662 local ($r) = &lang_c_rewrite ($directory, $base, $ext);
4664 if ($r == $LANG_SUBDIR)
4666 $pfx = $directory . '/';
4668 $yacc_sources{$pfx . $base . '.' . $ext} = 1;
4670 &saw_extension ('c');
4672 &push_dist_common ($pfx . $base . '.' . $ext);
4676 # Rewrite a single yacc++ file.
4677 sub lang_yaccxx_rewrite
4679 local ($directory, $base, $ext) = @_;
4681 local ($r) = $LANG_PROCESS;
4683 if (defined $options{'subdir-objects'})
4685 $pfx = $directory . '/';
4688 $yacc_sources{$pfx . $base . '.' . $ext} = 1;
4690 &saw_extension ($ext);
4692 &push_dist_common ($pfx . $base . '.' . $ext);
4696 # Rewrite a single lex file.
4697 sub lang_lex_rewrite
4699 local ($directory, $base, $ext) = @_;
4701 local ($r) = &lang_c_rewrite ($directory, $base, $ext);
4703 if ($r == $LANG_SUBDIR)
4705 $pfx = $directory . '/';
4707 $lex_sources{$pfx . $base . '.' . $ext} = 1;
4709 &saw_extension ('c');
4711 &push_dist_common ($pfx . $base . '.' . $ext);
4715 # Rewrite a single lex++ file.
4716 sub lang_lexxx_rewrite
4718 local ($directory, $base, $ext) = @_;
4720 local ($r) = $LANG_PROCESS;
4722 if (defined $options{'subdir-objects'})
4724 $pfx = $directory . '/';
4727 $lex_sources{$pfx . $base . '.' . $ext} = 1;
4729 &saw_extension ($ext);
4731 &push_dist_common ($pfx . $base . '.' . $ext);
4735 # Rewrite a single assembly file.
4736 sub lang_asm_rewrite
4738 return &lang_sub_obj;
4741 # Rewrite a single Fortran 77 file.
4742 sub lang_f77_rewrite
4744 return $LANG_PROCESS;
4747 # Rewrite a single preprocessed Fortran 77 file.
4748 sub lang_ppf77_rewrite
4750 return $LANG_PROCESS;
4753 # Rewrite a single ratfor file.
4754 sub lang_ratfor_rewrite
4756 return $LANG_PROCESS;
4759 # Rewrite a single Objective C file.
4760 sub lang_objc_rewrite
4762 return &lang_sub_obj;
4765 # Rewrite a single Java file.
4766 sub lang_java_rewrite
4768 return $LANG_SUBDIR;
4771 # The lang_X_finish functions are called after all source file
4772 # processing is done. Each should handle defining rules for the
4773 # language, etc. A finish function is only called if a source file of
4774 # the appropriate type has been seen.
4778 # Push all libobjs files onto de_ansi_files. We actually only
4779 # push files which exist in the current directory, and which are
4780 # genuine source files.
4782 foreach $file (keys %libsources)
4784 if ($file =~ /^(.*)\.[cly]$/ && -f "$relative_dir/$file")
4786 $de_ansi_files{$1} = 1;
4790 if (defined $options{'ansi2knr'} && keys %de_ansi_files)
4792 # Make all _.c files depend on their corresponding .c files.
4793 local ($base, @objects);
4794 foreach $base (sort keys %de_ansi_files)
4796 # Each _.c file must depend on ansi2knr; otherwise it
4797 # might be used in a parallel build before it is built.
4798 # We need to support files in the srcdir and in the build
4799 # dir (because these files might be auto-generated. But
4800 # we can't use $< -- some makes only define $< during a
4802 $output_rules .= ($base . "_.c: $base.c \$(ANSI2KNR)\n\t"
4803 . '$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) '
4804 . '`if test -f $(srcdir)/' . $base . '.c'
4805 . '; then echo $(srcdir)/' . $base . '.c'
4806 . '; else echo ' . $base . '.c; fi` '
4807 . "| sed 's/^# \\([0-9]\\)/#line \\1/' "
4808 . '| $(ANSI2KNR) > ' . $base . "_.c\n");
4809 push (@objects, $base . '_'
4810 . ($seen_objext ? '.$(OBJEXT)' : '.o'));
4811 push (@objects, $base . '_.lo') if $seen_libtool;
4814 # Make all _.o (and _.lo) files depend on ansi2knr.
4815 # Use a sneaky little hack to make it print nicely.
4816 &pretty_print_rule ('', '', @objects, ':', '$(ANSI2KNR)');
4819 if (! defined $configure_vars{'CC'})
4821 # FIXME: line number.
4822 &am_error ("C source seen but \`CC' not defined in \`configure.in'");
4828 local (@cxx_list) = &lang_extensions ('cxx');
4829 local ($cxx_count) = scalar @cxx_list;
4832 push (@suffixes, @cxx_list);
4834 local ($ltcompile, $ltlink) = &libtool_compiler;
4836 &define_configure_variable ("CXXFLAGS");
4837 &define_compiler_variable ('CXXCOMPILE', $ltcompile, '$(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)');
4839 &define_variable ('CXXLD', '$(CXX)');
4840 &define_variable ('CXXLINK', $ltlink . '$(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@');
4843 foreach $ext (@cxx_list)
4845 # Every known C++ compiler supports both -c and -o.
4846 $output_rules .= ("$ext.o:\n"
4847 . "\t\$(CXXCOMPILE) -c -o \$\@ \$<\n");
4848 # FIXME: Using cygpath should be somehow conditional.
4849 $output_rules .= ("$ext.obj:\n"
4850 . "\t\$(CXXCOMPILE) -c -o \$\@ `cygpath -w \$<`\n")
4852 $output_rules .= ("$ext.lo:\n"
4853 . "\t\$(LTCXXCOMPILE) -c -o \$\@ \$<\n")
4857 if (! defined $configure_vars{'CXX'})
4859 &am_error ("C++ source seen but \`CXX' not defined in \`configure.in'");
4864 sub lang_header_finish
4869 # This is a helper for both lex and yacc.
4870 sub yacc_lex_finish_helper
4872 return if defined $language_scratch{'lex-yacc-done'};
4873 $language_scratch{'lex-yacc-done'} = 1;
4875 # If there is more than one distinct yacc (resp lex) source file
4876 # in a given directory, then the `ylwrap' program is required to
4877 # allow parallel builds to work correctly. FIXME: for now, no
4879 &require_config_file ($FOREIGN, 'ylwrap');
4880 if ($config_aux_dir ne '.' && $config_aux_dir ne '')
4882 &define_variable ('YLWRAP', $config_aux_dir . "/ylwrap");
4886 &define_variable ('YLWRAP', '$(srcdir)/ylwrap');
4890 sub lang_yacc_finish
4892 return if defined $language_scratch{'yacc-done'};
4893 $language_scratch{'yacc-done'} = 1;
4895 local ($file, $base, $hname, $cname);
4896 local (%seen_suffix) = ();
4897 local (@yacc_files) = sort keys %yacc_sources;
4898 local ($yacc_count) = scalar (@yacc_files);
4899 foreach $file (@yacc_files)
4902 &output_yacc_build_rule ($1, $yacc_count > 1)
4903 if ! defined $seen_suffix{$1};
4904 $seen_suffix{$1} = 1;
4906 $file =~ /^(.*)\.(y|yy|y\+\+|yxx|ypp)$/;
4908 $hname = 'h'; # Always use `.h' for header file.
4909 ($cname = $2) =~ tr/y/c/;
4911 if ((&variable_defined ('AM_YFLAGS')
4912 && &variable_value ('AM_YFLAGS') =~ /(^|\s)-d(\s|$)/)
4913 || (&variable_defined ('YFLAGS')
4914 && &variable_value ('YFLAGS') =~ /(^|\s)-d(\s|$)/)) {
4915 # Now generate rule to make the header file. This should only
4916 # be generated if `yacc -d' specified.
4917 $output_rules .= "${base}.${hname}: ${base}.${cname}\n";
4919 # If the files are built in the build directory, then we want
4920 # to remove them with `make clean'. If they are in srcdir
4921 # they shouldn't be touched. However, we can't determine this
4922 # statically, and the GNU rules say that yacc/lex output files
4923 # should be removed by maintainer-clean. So that's what we
4925 push (@maintainer_clean_files, "${base}.${hname}");
4927 &push_dist_common ("${base}.${hname}");
4929 push (@maintainer_clean_files, "${base}.${cname}");
4931 $output_rules .= "\n";
4933 if (! defined $configure_vars{'YACC'})
4935 &am_error ("yacc source seen but \`YACC' not defined in \`configure.in'");
4937 if (&variable_defined ('YACCFLAGS'))
4939 &am_line_error ('YACCFLAGS',
4940 "\`YACCFLAGS' obsolete; use \`YFLAGS' instead");
4943 if ($yacc_count > 1)
4945 &yacc_lex_finish_helper;
4949 sub lang_yaccxx_finish
4956 return if defined $language_scratch{'lex-done'};
4957 $language_scratch{'lex-done'} = 1;
4959 local (%seen_suffix) = ();
4960 local ($file, $cname);
4961 local ($lex_count) = scalar (keys %lex_sources);
4962 foreach $file (sort keys %lex_sources)
4965 &output_lex_build_rule ($1, $lex_count > 1)
4966 if (! defined $seen_suffix{$1});
4967 $seen_suffix{$1} = 1;
4969 # If the files are built in the build directory, then we want
4970 # to remove them with `make clean'. If they are in srcdir
4971 # they shouldn't be touched. However, we can't determine this
4972 # statically, and the GNU rules say that yacc/lex output files
4973 # should be removed by maintainer-clean. So that's what we
4975 $file =~ /^(.*)\.(l|ll|l\+\+|lxx|lpp)$/;
4976 ($cname = $2) =~ tr/l/c/;
4977 push (@maintainer_clean_files, "${1}.${cname}");
4980 if (! defined $configure_vars{'LEX'})
4982 &am_error ("lex source seen but \`LEX' not defined in \`configure.in'");
4984 if (! $seen_decl_yytext)
4986 &am_error ("lex source seen but \`AC_DECL_YYTEXT' not in \`configure.in'");
4991 &yacc_lex_finish_helper;
4995 sub lang_lexxx_finish
5002 # We need the C code for assembly.
5005 # We also need our own rules.
5006 local ($minuso) = '';
5007 if (defined $options{'subdir-objects'})
5011 local (@asm_list) = &lang_extensions ('am');
5013 foreach $ext (@asm_list)
5015 $output_rules .= ("$ext.o:\n"
5016 . "\t\$(COMPILE) -c " . $minuso . "\$<\n");
5017 # FIXME: Using cygpath should be somehow conditional.
5018 $output_rules .= ("$ext.obj:\n"
5019 . "\t\$(COMPILE) -c " . $minuso
5020 . "`cygpath -w \$<`\n")
5022 $output_rules .= ("$ext.lo:\n"
5023 . "\t\$(LTCOMPILE) -c -o \$\@ \$<\n")
5027 push (@suffixes, @asm_list);
5032 local (@f77_list) = &lang_extensions ('f77');
5033 local ($f77_count) = scalar @f77_list;
5036 push (@suffixes, @f77_list);
5038 local ($ltcompile, $ltlink) = &libtool_compiler;
5040 &define_configure_variable ('FFLAGS');
5041 &define_compiler_variable ('F77COMPILE', $ltcompile,
5042 '$(F77) $(AM_FFLAGS) $(FFLAGS)');
5044 &define_variable ('F77LD', '$(F77)');
5045 &define_variable ('F77LINK', $ltlink . '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@');
5048 foreach $ext (@f77_list)
5050 $output_rules .= ("$ext.o:\n"
5051 . "\t\$(F77COMPILE) -c \$<\n");
5052 # FIXME: Using cygpath should be somehow conditional.
5053 $output_rules .= ("$ext.obj:\n"
5054 . "\t\$(F77COMPILE) -c `cygpath -w \$<`\n")
5056 $output_rules .= ("$ext.lo:\n"
5057 . "\t\$(LTF77COMPILE) -c \$<\n")
5061 if (! defined $configure_vars{'F77'})
5063 &am_error ("Fortran 77 source seen but \`F77' not defined in \`configure.in'");
5068 # Preprocessed Fortran 77
5070 # The current support for preprocessing Fortran 77 just involves passing
5071 # `$(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS)' as additional flags
5072 # to the Fortran 77 compiler, since this is how GNU Make does it; see
5073 # the `GNU Make Manual, Edition 0.51 for `make' Version 3.76 Beta'
5074 # (specifically, from info file `(make)Catalogue of Rules').
5076 # A better approach would be to write an Autoconf test
5077 # (i.e. AC_PROG_FPP) for a Fortran 77 preprocessor, because not all
5078 # Fortran 77 compilers know how to do preprocessing. The Autoconf macro
5079 # AC_PROG_FPP should test the Fortran 77 compiler first for
5080 # preprocessing capabilities, and then fall back on cpp (if cpp were
5082 sub lang_ppf77_finish
5085 last unless $extension_seen{$ext};
5088 push (@suffixes, $ext);
5090 local ($ltcompile, $ltlink) = &libtool_compiler;
5092 &define_configure_variable ('FFLAGS');
5093 &define_compiler_variable ('F77COMPILE', $ltcompile,
5094 '$(F77) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FFLAGS) $(FFLAGS)');
5096 &define_variable ('F77LD', '$(F77)');
5097 &define_variable ('F77LINK', $ltlink . '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@');
5099 $output_rules .= ("$ext.o:\n"
5100 . "\t\$(F77COMPILE) -c \$<\n");
5101 # FIXME: Using cygpath should be somehow conditional.
5102 $output_rules .= ("$ext.obj:\n"
5103 . "\t\$(F77COMPILE) -c `cygpath -w \$<`\n")
5105 $output_rules .= ("$ext.lo:\n"
5106 . "\t\$(LTF77COMPILE) -c \$<\n")
5109 # We also handle the case of preprocessing `.F' files into `.f'
5111 $output_rules .= ("$ext.f:\n"
5112 . "\t\$(F77COMPILE) -F \$<\n");
5114 if (! defined $configure_vars{'F77'})
5116 &am_error ("Fortran 77 source seen but \`F77' not defined in \`configure.in'");
5120 sub lang_ratfor_finish
5123 last unless $extension_seen{$ext};
5125 push (@suffixes, $ext);
5127 local ($ltcompile, $ltlink) = &libtool_compiler;
5129 &define_configure_variable ('FFLAGS');
5130 &define_configure_variable ('RFLAGS');
5131 &define_variable ('RCOMPILE', $ltcompile,
5132 '$(F77) $(AM_FFLAGS) $(FFLAGS) $(AM_RFLAGS) $(RFLAGS)');
5134 &define_variable ('F77LD', '$(F77)');
5135 &define_variable ('F77LINK', $ltlink . '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_RFLAGS) $(RFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@');
5137 $output_rules .= ("$ext.o:\n"
5138 . "\t\$(RCOMPILE) -c \$<\n");
5139 # FIXME: Using cygpath should be somehow conditional.
5140 $output_rules .= ("$ext.obj:\n"
5141 . "\t\$(RCOMPILE) -c `cygpath -w \$<`\n")
5143 $output_rules .= ("$ext.lo:\n"
5144 . "\t\$(LTRCOMPILE) -c \$<\n")
5147 # We also handle the case of preprocessing `.r' files into `.f'
5149 $output_rules .= ("$ext.f:\n"
5150 . "\t\$(RCOMPILE) -F \$<\n");
5152 if (! defined $configure_vars{'F77'})
5154 &am_error ("Ratfor source seen but \`F77' not defined in \`configure.in'");
5158 sub lang_objc_finish
5160 push (@suffixes, '.m');
5162 local ($ltcompile, $ltlink) = &libtool_compiler;
5164 &define_configure_variable ("OBJCFLAGS");
5165 &define_compiler_variable ('OBJCCOMPILE', $ltcompile,
5166 '$(OBJC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_OBJCFLAGS) $(OBJCFLAGS)');
5168 &define_variable ('OBJCLD', '$(OBJC)');
5169 &define_variable ('OBJCLINK', $ltlink . '$(OBJCLD) $(AM_OBJCFLAGS) $(OBJCFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@');
5171 # All known ObjC compilers support -c and -o together.
5172 $output_rules .= (".m.o:\n"
5173 . "\t\$(OBJCCOMPILE) -c -o \$\@ \$<\n");
5174 # FIXME: Using cygpath should be somehow conditional.
5175 $output_rules .= (".m.obj:\n"
5176 . "\t\$(OBJCCOMPILE) -c -o \$\@ `cygpath -w \$<`\n")
5178 $output_rules .= (".m.lo:\n"
5179 . "\t\$(LTOBJCCOMPILE) -c -o \$\@ \$<\n")
5182 if (! defined $configure_vars{'OBJC'})
5184 &am_error ("Objective C source seen but \`OBJC' not defined in \`configure.in'");
5188 sub lang_java_finish
5190 push (@suffixes, '.java');
5192 local ($ltcompile, $ltlink) = &libtool_compiler;
5194 &define_configure_variable ("GCJFLAGS");
5195 &define_compiler_variable ('GCJCOMPILE', $ltcompile,
5196 '$(GCJ) $(DEFS) $(INCLUDES) $(AM_GCJFLAGS) $(GCJFLAGS)');
5198 &define_variable ('GCJLD', '$(GCJ)');
5199 &define_variable ('GCJLINK', $ltlink . '$(GCJLD) $(AM_GCJFLAGS) $(GCJFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@');
5201 # All known Java compilers support -c and -o together.
5202 $output_rules .= (".java.o:\n"
5203 . "\t\$(GCJCOMPILE) -c -o \$\@ \$<\n");
5204 # FIXME: Using cygpath should be somehow conditional.
5205 $output_rules .= (".java.obj:\n"
5206 . "\t\$(GCJCOMPILE) -c -o \$\@ `cygpath -w \$<`\n")
5208 $output_rules .= (".java.lo:\n"
5209 . "\t\$(LTGCJCOMPILE) -c -o \$\@ \$<\n")
5212 if (! defined $configure_vars{'GCJ'})
5214 &am_error ("Java source seen but \`GCJ' not defined in \`configure.in'");
5218 # A helper which computes a sorted list of all extensions for LANG.
5223 foreach $key (sort keys %extension_seen)
5225 push (@r, '.' . $key) if $extension_map{$key} eq $lang;
5230 # A helper which decides whether libtool is needed. Returns prefix
5231 # for compiler and linker.
5232 sub libtool_compiler
5234 local ($ltcompile, $ltlink) = ('', '');
5237 &define_configure_variable ("LIBTOOL");
5238 $ltcompile = '$(LIBTOOL) --mode=compile ';
5239 $ltlink = '$(LIBTOOL) --mode=link ';
5241 return ($ltcompile, $ltlink);
5244 # Given a hash table of linker names, pick the name that has the most
5245 # precedence. This is lame, but something has to have global
5246 # knowledge in order to eliminate the conflict. Add more linkers as
5250 local (%linkers) = @_;
5253 if defined $linkers{'GCJLINK'};
5255 if defined $linkers{'CXXLINK'};
5257 if defined $linkers{'F77LINK'};
5259 if defined $linkers{'OBJCLINK'};
5263 # Called to indicate that an extension was used.
5267 $extension_seen{$ext} = 1;
5270 # Called to ask whether source files have been seen . If HEADERS is 1,
5271 # headers can be included.
5274 local ($headers) = @_;
5282 local (@exts) = &lang_extensions ('header');
5286 return scalar keys %extension_seen > $headers;
5289 # Register a single language. LANGUAGE is the name of the language.
5290 # Each OPTION is either of the form NAME=VALUE, or is a file extension
5292 sub register_language
5294 local ($language, @options) = @_;
5297 $language_map{$language . '-ansi-p'} = 0;
5298 $language_map{$language . '-linker'} = '';
5299 $language_map{$language . '-autodep'} = 'no';
5302 foreach $iter (@options)
5304 if ($iter =~ /^(.*)=(.*)$/)
5306 $language_map{$language . '-' . $1} = $2;
5308 elsif (defined $extension_map{$iter})
5311 "automake: programming error: duplicate extension $iter\n";
5316 $extension_map{$iter} = $language;
5322 ################################################################
5324 # Pretty-print something. HEAD is what should be printed at the
5325 # beginning of the first line, FILL is what should be printed at the
5326 # beginning of every subsequent line.
5327 sub pretty_print_internal
5329 local ($head, $fill, @values) = @_;
5331 local ($column) = length ($head);
5332 local ($result) = $head;
5334 # Fill length is number of characters. However, each Tab
5335 # character counts for eight. So we count the number of Tabs and
5337 local ($fill_length) = length ($fill);
5338 $fill_length += 7 * ($fill =~ tr/\t/\t/d);
5340 local ($bol) = ($head eq '');
5343 # "71" because we also print a space.
5344 if ($column + length ($_) > 71)
5346 $result .= " \\\n" . $fill;
5347 $column = $fill_length;
5351 $result .= ' ' unless ($bol);
5353 $column += length ($_) + 1;
5361 # Pretty-print something and append to output_vars.
5364 $output_vars .= &pretty_print_internal (@_);
5367 # Pretty-print something and append to output_rules.
5368 sub pretty_print_rule
5370 $output_rules .= &pretty_print_internal (@_);
5374 ################################################################
5376 # See if a target exists.
5379 local ($target) = @_;
5380 return defined $targets{$target};
5383 # See if two conditionals are the same.
5384 sub conditional_same
5386 local ($cond1, $cond2) = @_;
5388 return (&conditional_true_when ($cond1, $cond2)
5389 && &conditional_true_when ($cond2, $cond1));
5392 # See if a conditional is true. Both arguments are conditional
5393 # strings. This returns true if the first conditional is true when
5394 # the second conditional is true.
5395 sub conditional_true_when
5397 local ($cond, $when) = @_;
5399 # Check the easy case first.
5405 # Check each component of $cond, which looks @COND1@@COND2@.
5406 foreach $comp (split ('@', $cond))
5408 # The way we split will give null strings between each
5412 if (index ($when, '@' . $comp . '@') == -1)
5421 # Check for an ambiguous conditional. This is called when a variable
5422 # or target is being defined conditionally. If we already know about
5423 # a definition that is true under the same conditions, then we have an
5425 sub check_ambiguous_conditional
5427 local ($var_name, $cond) = @_;
5428 local (@cond_vals) = split (' ', $conditional{$var_name});
5431 local ($vcond) = shift (@cond_vals);
5433 if (&conditional_true_when ($vcond, $cond)
5434 || &conditional_true_when ($cond, $vcond))
5436 &am_line_error ($var_name,
5437 "$var_name multiply defined in condition");
5442 # See if a variable exists. The first argument is the variable name,
5443 # and the optional second argument is the condition which we should
5444 # check. If no condition is given, we currently return true if the
5445 # variable is defined under any condition.
5446 sub variable_defined
5448 local ($var, $cond) = @_;
5449 if (defined $targets{$var})
5451 &am_line_error ($var, "\`$var' is target; expected variable");
5454 elsif (defined $contents{$var})
5456 if ($cond && $conditional{$var})
5458 # We have been asked to check for a particular condition,
5459 # and the variable is defined conditionally. We need to
5460 # look through the conditions under which the variable is
5461 # defined, and see if any of them match the conditional we
5462 # have been asked to check.
5463 local (@cond_vars) = split (' ', $conditional{$var});
5466 if (&conditional_same ($cond, shift (@cond_vars)))
5468 # Even a conditional examination is good enough
5469 # for us. FIXME: really should maintain examined
5470 # status on a per-condition basis.
5471 $content_seen{$var} = 1;
5477 # The variable is not defined for the given condition.
5481 $content_seen{$var} = 1;
5487 # Mark a variable as examined.
5488 sub examine_variable
5491 &variable_defined ($var);
5494 # Quote a value in order to put it in $conditional. We need to quote
5495 # spaces, and we need to handle null strings, so that we can later
5496 # retrieve values by splitting on space.
5500 $val =~ tr/ \t\n/\001\003\004/;
5501 $val = "\002" if $val eq '';
5505 # Unquote a value in $conditional.
5506 sub unquote_cond_val
5509 $val =~ tr/\001\003\004/ \t\n/;
5514 # Return the set of conditions for which a variable is defined.
5516 # If the variable is not defined conditionally, and is not defined in
5517 # terms of any variables which are defined conditionally, then this
5518 # returns the empty list.
5520 # If the variable is defined conditionally, but is not defined in
5521 # terms of any variables which are defined conditionally, then this
5522 # returns the list of conditions for which the variable is defined.
5524 # If the variable is defined in terms of any variables which are
5525 # defined conditionally, then this returns a full set of permutations
5526 # of the subvariable conditions. For example, if the variable is
5527 # defined in terms of a variable which is defined for @COND_TRUE@,
5528 # then this returns both @COND_TRUE@ and @COND_FALSE@. This is
5529 # because we will need to define the variable under both conditions.
5531 sub variable_conditions
5539 foreach $cond (&variable_conditions_sub ($var, '', ()))
5541 $uniqify{$cond} = 1;
5544 @uniq_list = sort keys %uniqify;
5545 # Note we cannot just do `return sort keys %uniqify', because this
5546 # function is sometimes used in a scalar context.
5550 # A subroutine of variable_conditions. We only return conditions
5551 # which are true for all the conditions in @PARENT_CONDS.
5552 sub variable_conditions_sub
5554 local ($var, $parent, @parent_conds) = @_;
5555 local (@new_conds) = ();
5557 if (defined $vars_scanned{$var})
5559 &am_line_error ($parent, "variable \`$var' recursively defined");
5562 $vars_scanned{$var} = 1;
5564 if (! $conditional{$var})
5566 foreach (split (' ', $contents{$var}))
5568 # If a comment seen, just leave.
5571 # Handle variable substitutions.
5572 if (/^\$\{(.*)\}$/ || /^\$\((.*)\)$/)
5575 &variable_conditions_sub ($1, $var, @parent_conds));
5579 # Now we want to return all permutations of the subvariable
5581 local (%allconds, $item);
5582 foreach $item (@new_conds)
5584 foreach (split ('@', $item))
5588 $allconds{$_ . '_TRUE'} = 1;
5592 # Unset our entry in vars_scanned. We only care about recursive
5594 delete $vars_scanned{$var};
5596 return &variable_conditions_permutations (sort keys %allconds);
5599 local (@this_conds) = ();
5600 local (@condvals) = split (' ', $conditional{$var});
5603 local ($cond) = shift (@condvals);
5604 local ($val) = &unquote_cond_val (shift (@condvals));
5609 local ($parent_cond);
5610 foreach $parent_cond (@parent_conds)
5612 if (! &conditional_true_when ($parent_cond, $cond))
5622 push (@this_conds, $cond);
5624 push (@parent_conds, $cond);
5625 local (@subvar_conds) = ();
5626 foreach (split (' ', $val))
5628 # If a comment seen, just leave.
5631 # Handle variable substitutions.
5632 if (/^\$\{(.*)\}$/ || /^\$\((.*)\)$/)
5634 push (@subvar_conds,
5635 &variable_conditions_sub ($1, $var, @parent_conds));
5638 pop (@parent_conds);
5640 # If there are no conditional subvariables, then we want to
5641 # return this condition. Otherwise, we want to return the
5642 # permutations of the subvariables.
5643 if (! @subvar_conds)
5645 push (@new_conds, $cond);
5649 push (@new_conds, &variable_conditions_reduce (@subvar_conds));
5653 # Unset our entry in vars_scanned. We only care about recursive
5655 delete $vars_scanned{$var};
5660 # If we are being called on behalf of another variable, we need to
5661 # return all possible permutations of the conditions. We have
5662 # already handled everything in @this_conds along with their
5663 # subvariables. We now need to add any permutations that are not
5666 foreach $this_cond (@this_conds)
5669 &variable_conditions_permutations (split('@', $this_cond));
5671 foreach $perm (@perms)
5675 foreach $scan (@this_conds)
5677 if (&conditional_true_when ($perm, $scan)
5678 || &conditional_true_when ($scan, $perm))
5689 local ($parent_cond);
5690 foreach $parent_cond (@parent_conds)
5692 if (! &conditional_true_when ($parent_cond, $perm))
5702 # This permutation was not already handled, and is valid
5704 push (@new_conds, $perm);
5711 # Subroutine for variable_conditions_sort
5712 sub variable_conditions_cmp
5718 return (length ($as) <=> length ($bs)
5722 # Sort a list of conditionals so that only the exclusive ones are
5723 # retained. For example, if both @COND1_TRUE@@COND2_TRUE@ and
5724 # @COND1_TRUE@ are in the list, discard the latter.
5725 sub variable_conditions_reduce
5727 local (@conds) = @_;
5730 foreach $cond (sort variable_conditions_cmp @conds)
5734 foreach $scan (@ret)
5736 if (&conditional_true_when ($cond, $scan))
5749 # Return a list of permutations of a conditional string.
5750 sub variable_conditions_permutations
5752 local (@comps) = @_;
5755 local ($comp) = shift (@comps);
5756 return &variable_conditions_permutations (@comps)
5758 local ($neg) = $comp;
5759 $neg =~ s/TRUE$/TRUEO/;
5760 $neg =~ s/FALSE$/TRUE/;
5761 $neg =~ s/TRUEO$/FALSE/;
5764 foreach $sub (&variable_conditions_permutations (@comps))
5766 push (@ret, '@' . $comp . '@' . $sub);
5767 push (@ret, '@' . $neg . '@' . $sub);
5771 push (@ret, '@' . $comp . '@');
5772 push (@ret, '@' . $neg . '@');
5777 # Warn if a variable is conditionally defined. This is called if we
5778 # are using the value of a variable.
5779 sub variable_conditionally_defined
5781 local ($var, $parent) = @_;
5782 if ($conditional{$var})
5786 &am_line_error ($parent,
5787 "warning: automake does not support conditional definition of $var in $parent");
5791 &am_line_error ($parent,
5792 "warning: automake does not support $var being defined conditionally")
5797 # Get the value of a variable. This just returns $contents, but warns
5798 # if the variable is conditionally defined.
5802 &variable_conditionally_defined ($var);
5803 return $contents{$var};
5806 # Convert a variable value to a list, split as whitespace. This will
5807 # recursively follow $(...) and ${...} inclusions. It preserves @...@
5808 # substitutions. If COND is 'all', then all values under all
5809 # conditions should be returned; if COND is a particular condition
5810 # (all conditions are surrounded by @...@) then only the value for
5811 # that condition should be returned; otherwise, warn if VAR is
5812 # conditionally defined. SCANNED is a global hash listing whose keys
5813 # are all the variables already scanned; it is an error to rescan a
5817 local ($var, $val, $cond) = @_;
5821 $val =~ s/\\(\n|$)/ /g;
5823 foreach (split (' ', $val))
5825 # If a comment seen, just leave.
5828 # Handle variable substitutions.
5829 if (/^\$\{([^}]*)\}$/ || /^\$\(([^)]*)\)$/)
5831 local ($varname) = $1;
5833 # If the user uses a losing variable name, just ignore it.
5834 # This isn't ideal, but people have requested it.
5835 next if ($varname =~ /\@.*\@/);
5839 if ($varname =~ /^([^:]*):([^=]*)=(.*)$/)
5843 ($from = $2) =~ s/(\W)/\\$1/g;
5847 @temp_list = &variable_value_as_list_worker ($1, $cond, $var);
5849 # Now rewrite the value if appropriate.
5852 grep (s/$from$/$to/, @temp_list);
5855 push (@result, @temp_list);
5866 # Return contents of variable as list, split as whitespace. This will
5867 # recursively follow $(...) and ${...} inclusions. It preserves @...@
5868 # substitutions. If COND is 'all', then all values under all
5869 # conditions should be returned; if COND is a particular condition
5870 # (all conditions are surrounded by @...@) then only the value for
5871 # that condition should be returned; otherwise, warn if VAR is
5872 # conditionally defined. If PARENT is specified, it is the name of
5873 # the including variable; this is only used for error reports.
5874 sub variable_value_as_list_worker
5876 local ($var, $cond, $parent) = @_;
5879 if (defined $targets{$var})
5881 &am_line_error ($var, "\`$var' is target; expected variable");
5883 elsif (! defined $contents{$var})
5885 &am_line_error ($parent, "variable \`$var' not defined");
5887 elsif (defined $vars_scanned{$var})
5889 # `vars_scanned' is a global we use to keep track of which
5890 # variables we've already examined.
5891 &am_line_error ($parent, "variable \`$var' recursively defined");
5893 elsif ($cond eq 'all' && $conditional{$var})
5895 $vars_scanned{$var} = 1;
5896 local (@condvals) = split (' ', $conditional{$var});
5900 local ($val) = &unquote_cond_val (shift (@condvals));
5901 push (@result, &value_to_list ($var, $val, $cond));
5904 elsif ($cond && $conditional{$var})
5906 $vars_scanned{$var} = 1;
5907 local (@condvals) = split (' ', $conditional{$var});
5911 local ($vcond) = shift (@condvals);
5912 local ($val) = &unquote_cond_val (shift (@condvals));
5913 if (&conditional_true_when ($vcond, $cond))
5915 # Warn if we have an ambiguity. It's hard to know how
5916 # to handle this case correctly.
5917 &variable_conditionally_defined ($var, $parent)
5920 push (@result, &value_to_list ($var, $val, $cond));
5926 $vars_scanned{$var} = 1;
5927 &variable_conditionally_defined ($var, $parent);
5928 $content_seen{$var} = 1;
5929 push (@result, &value_to_list ($var, $contents{$var}, $cond));
5932 # Unset our entry in vars_scanned. We only care about recursive
5934 delete $vars_scanned{$var};
5939 # This is just a wrapper for variable_value_as_list_worker that
5940 # initializes the global hash `vars_scanned'. This hash is used to
5941 # avoid infinite recursion.
5942 sub variable_value_as_list
5944 local ($var, $cond, $parent) = @_;
5946 return &variable_value_as_list_worker ($var, $cond, $parent);
5949 # Define a new variable, but only if not already defined.
5952 local ($var, $value) = @_;
5954 if (! defined $contents{$var})
5956 $output_vars .= $var . ' = ' . $value . "\n";
5957 $contents{$var} = $value;
5958 $content_seen{$var} = 1;
5960 elsif ($var_was_plus_eq{$var})
5962 &am_line_error ($var, "internally generated variable \`$var' was set with \`+='");
5966 # Like define_variable, but the value is a list, and the variable may
5967 # be defined conditionally. The second argument is the conditional
5968 # under which the value should be defined; this should be the empty
5969 # string to define the variable unconditionally. The third argument
5970 # is a list holding the values to use for the variable. The value is
5971 # pretty printed in the output file.
5972 sub define_pretty_variable
5974 local ($var, $cond, @value) = @_;
5975 if (! defined $contents{$var}
5976 || ($cond && ! &variable_defined ($var, $cond)))
5978 $contents{$var} = join (' ', @value);
5981 if ($conditional{$var})
5983 $conditional{$var} .= ' ';
5987 $conditional{$var} = '';
5989 $conditional{$var} .= ($cond
5991 . "e_cond_val ($contents{$var}));
5993 &pretty_print ($cond . $var . ' = ', $cond, @value);
5994 $content_seen{$var} = 1;
5998 # Like define_variable, but define a variable to be the configure
5999 # substitution by the same name.
6000 sub define_configure_variable
6003 local ($value) = '@' . $var . '@';
6004 &define_variable ($var, $value);
6007 # Define a compiler variable. We also handle defining the `LT'
6008 # version of the command when using libtool.
6009 sub define_compiler_variable
6011 local ($var, $ltcompile, $value) = @_;
6012 local ($name) = $var;
6013 &define_variable ($name, $value);
6014 &define_variable ('LT' . $name, $ltcompile . $value)
6018 # Define a variable that represents a program to run. If in Cygnus
6019 # mode, the program is searched for in the build (or source) tree.
6020 # Otherwise no searching is done at all. Arguments are:
6021 # * VAR Name of variable to define
6022 # * WHATDIR Either `src' or `build', depending on where program should
6023 # be found. (runtest is in srcdir!)
6024 # * SUBDIR Subdir of top-level dir
6025 # * PROGRAM Name of program
6026 # * OVERRIDE If specified, the name of the program to use when not in
6027 # Cygnus mode. Defaults to PROGRAM.
6028 sub define_program_variable
6030 local ($var, $whatdir, $subdir, $program, $override) = @_;
6034 $override = $program;
6039 local ($full) = ('$(top_' . $whatdir . 'dir)/../'
6040 . $subdir . '/' . $program);
6041 &define_variable ($var, ('`if test -f ' . $full
6042 . '; then echo ' . $full . '; else echo '
6043 . $program . '; fi`'));
6047 &define_variable ($var, $override);
6052 ################################################################
6054 # Read Makefile.am and set up %contents. Simultaneously copy lines
6055 # from Makefile.am into $output_trailer or $output_vars as
6056 # appropriate. NOTE we put rules in the trailer section. We want
6057 # user rules to come after our generated stuff.
6060 local ($amfile) = @_;
6063 open (AM_FILE, $amfile) || die "automake: couldn't open \`$amfile': $!\n";
6064 print "automake: reading $amfile\n" if $verbose;
6066 local ($saw_bk) = 0;
6067 local ($was_rule) = 0;
6068 local ($spacing) = '';
6069 local ($comment) = '';
6070 local ($last_var_name) = '';
6075 if (/$IGNORE_PATTERN/o)
6077 # Merely delete comments beginning with two hashes.
6079 elsif (/$WHITE_PATTERN/o)
6081 # Stick a single white line before the incoming macro or rule.
6085 elsif (/$COMMENT_PATTERN/o)
6087 # Stick comments before the incoming macro or rule. Make
6088 # sure a blank line preceeds first block of comments.
6089 $spacing = "\n" unless $blank;
6091 $comment .= $spacing . $_;
6100 $output_vars .= $comment . "\n";
6104 local ($is_ok_macro);
6108 unless substr ($_, -1, 1) eq "\n";
6110 # Don't look at MAINTAINER_MODE_TRUE here. That shouldn't be
6111 # used by users. @MAINT@ is an anachronism now.
6112 $_ =~ s/\@MAINT\@//g
6113 unless $seen_maint_mode;
6115 if (/$IGNORE_PATTERN/o)
6117 # Merely delete comments beginning with two hashes.
6119 elsif (/$WHITE_PATTERN/o)
6121 # Stick a single white line before the incoming macro or rule.
6123 &am_line_error ($., "blank line following trailing backslash")
6126 elsif (/$COMMENT_PATTERN/o)
6128 # Stick comments before the incoming macro or rule.
6129 $comment .= $spacing . $_;
6131 &am_line_error ($., "comment following trailing backslash")
6138 $output_trailer .= join ('', @conditional_stack) . $_;
6144 $contents{$last_var_name} .= ' '
6145 unless $contents{$last_var_name} =~ /\s$/;
6146 $contents{$last_var_name} .= $_;
6147 if (@conditional_stack)
6149 $conditional{$last_var_name} .= "e_cond_val ($_);
6153 elsif (/$IF_PATTERN/o)
6155 &am_line_error ($., "$1 does not appear in AM_CONDITIONAL")
6156 if (! $configure_cond{$1});
6157 push (@conditional_stack, "\@" . $1 . "_TRUE\@");
6159 elsif (/$ELSE_PATTERN/o)
6161 if (! @conditional_stack)
6163 &am_line_error ($., "else without if");
6165 elsif ($conditional_stack[$#conditional_stack] =~ /_FALSE\@$/)
6167 &am_line_error ($., "else after else");
6171 $conditional_stack[$#conditional_stack]
6172 =~ s/_TRUE\@$/_FALSE\@/;
6175 elsif (/$ENDIF_PATTERN/o)
6177 if (! @conditional_stack)
6179 &am_line_error ($., "endif without if");
6183 pop @conditional_stack;
6186 elsif (/$RULE_PATTERN/o)
6190 if (defined $contents{$1}
6191 && (@conditional_stack
6192 ? ! defined $conditional{$1}
6193 : defined $conditional{$1}))
6196 "$1 defined both conditionally and unconditionally");
6198 # Value here doesn't matter; for targets we only note
6202 local ($cond_string) = join ('', @conditional_stack);
6203 if (@conditional_stack)
6205 if ($conditional{$1})
6207 &check_ambiguous_conditional ($1, $cond_string);
6208 $conditional{$1} .= ' ';
6212 $conditional{$1} = '';
6214 $conditional{$1} .= $cond_string . ' 1';
6216 $content_lines{$1} = $.;
6217 $output_trailer .= $comment . $spacing . $cond_string . $_;
6218 $comment = $spacing = '';
6221 # Check the rule for being a suffix rule. If so, store in
6224 local ($source_suffix);
6225 local ($object_suffix);
6227 if (($source_suffix, $object_suffix) = ($1 =~ $SUFFIX_RULE_PATTERN))
6229 $suffix_rules{$source_suffix} = $object_suffix;
6230 print "Sources ending in .$source_suffix become .$object_suffix\n" if $verbose;
6231 $source_suffix_pattern = "(" . join('|', keys %suffix_rules) . ")";
6234 # FIXME: make sure both suffixes are in SUFFIXES? Or set
6235 # SUFFIXES from suffix_rules?
6237 elsif (($is_ok_macro = /$MACRO_PATTERN/o)
6238 || /$BOGUS_MACRO_PATTERN/o)
6240 # Found a macro definition.
6242 $last_var_name = $1;
6243 if (defined $contents{$1}
6244 && (@conditional_stack
6245 ? ! defined $conditional{$1}
6246 : defined $conditional{$1}))
6249 "$1 defined both conditionally and unconditionally");
6252 if ($3 ne '' && substr ($3, -1) eq "\\")
6254 # We preserve the `\' because otherwise the long lines
6255 # that are generated will be truncated by broken
6265 if (! defined $contents{$last_var_name})
6267 # The first assignment to a macro sets the line
6268 # number. Ideally I suppose we would associate line
6269 # numbers with random bits of text.
6270 $content_lines{$last_var_name} = $.;
6272 # If first assignment, set `+=' indicator.
6273 $var_was_plus_eq{$last_var_name} =
6275 && ! defined $am_var_defs{$last_var_name});
6280 if (! defined $contents{$last_var_name}
6281 && defined $am_var_defs{$last_var_name})
6283 $contents{$last_var_name} = $am_var_defs{$last_var_name};
6285 $contents{$last_var_name} .= ' ' . $value;
6289 $contents{$last_var_name} = $value;
6291 local ($cond_string) = join ('', @conditional_stack);
6292 if (@conditional_stack)
6296 if ($conditional{$last_var_name})
6300 # If we're adding to the conditional, and it
6301 # exists, then we might want to simply replace
6302 # the old value with the new one.
6303 local (@new_vals, @cond_vals);
6304 @cond_vals = split (' ', $conditional{$last_var_name});
6307 local ($vcond) = shift (@cond_vals);
6308 push (@new_vals, $vcond);
6309 if (&conditional_same ($vcond, $cond_string))
6312 $val = (&unquote_cond_val (shift (@cond_vals))
6314 push (@new_vals, "e_cond_val ($val));
6318 push (@new_vals, shift (@cond_vals));
6323 $conditional{$last_var_name}
6324 = join (' ', @new_vals);
6330 &check_ambiguous_conditional ($last_var_name,
6332 $conditional{$last_var_name} .= ' ';
6338 $conditional{$last_var_name} = '';
6339 $val = $contents{$last_var_name};
6343 $conditional{$last_var_name} .= ($cond_string
6345 . "e_cond_val ($val));
6349 # FIXME: this doesn't always work correctly; it will group
6350 # all comments for a given variable, no matter where
6352 $am_vars{$last_var_name} = $comment . $spacing;
6353 $def_type{$last_var_name} = ($type eq ':') ? ':' : '';
6354 push (@var_list, $last_var_name);
6355 $comment = $spacing = '';
6359 &am_line_error ($., "bad macro name \`$last_var_name'")
6362 elsif (/$INCLUDE_PATTERN/o)
6366 if ($path =~ s/^\$\(top_srcdir\)\///)
6368 push (@include_stack, "\$\(top_srcdir\)/$path");
6372 $path =~ s/\$\(srcdir\)\///;
6373 push (@include_stack, "\$\(srcdir\)/$path");
6374 $path = $relative_dir . "/" . $path;
6376 &read_am_file ($path);
6380 # This isn't an error; it is probably a continued rule.
6381 # In fact, this is what we assume.
6383 $output_trailer .= ($comment . $spacing
6384 . join ('', @conditional_stack) . $_);
6385 $comment = $spacing = '';
6392 $output_trailer .= $comment;
6394 &am_error ("unterminated conditionals: " . join (' ', @conditional_stack))
6395 if (@conditional_stack);
6398 # A helper for read_main_am_file which initializes configure variables
6399 # and variables from header-vars.am. This is a subr so we can call it
6401 sub define_standard_variables
6403 # Compute relative location of the top object directory.
6404 local (@topdir) = ();
6405 foreach (split (/\//, $relative_dir))
6407 next if $_ eq '.' || $_ eq '';
6414 push (@topdir, '..');
6417 @topdir = ('.') if ! @topdir;
6419 $top_builddir = join ('/', @topdir);
6421 ($build_rx = $top_builddir) =~ s/(\W)/\\$1/g;
6422 $output_vars .= &file_contents_with_transform
6423 ('s/\@top_builddir\@/' . $build_rx . '/g;',
6426 # Generate some useful variables when AC_CANONICAL_* used. FIXME:
6427 # this should use generic %configure_vars method.
6428 if ($seen_canonical)
6430 local ($curs, %vars);
6431 $vars{'host_alias'} = 'host_alias';
6432 $vars{'host_triplet'} = 'host';
6433 if ($seen_canonical == $AC_CANONICAL_SYSTEM)
6435 $vars{'build_alias'} = 'build_alias';
6436 $vars{'build_triplet'} = 'build';
6437 $vars{'target_alias'} = 'target_alias';
6438 $vars{'target_triplet'} = 'target';
6440 foreach $curs (sort keys %vars)
6442 $output_vars .= "$curs = \@$vars{$curs}\@\n";
6443 $contents{$curs} = "\@$vars{$curs}\@";
6448 foreach $curs (sort keys %configure_vars)
6450 &define_configure_variable ($curs);
6454 # Read main am file.
6455 sub read_main_am_file
6457 local ($amfile) = @_;
6459 # The keys here are variables we want to dump at the end of this
6460 # function. The values are corresponding comments.
6461 local (%am_vars) = ();
6462 local (@var_list) = ();
6463 local (%def_type) = ();
6465 # We want to predefine as many variables as possible. This lets
6466 # the user set them with `+=' in Makefile.am. However, we don't
6467 # want these initial definitions to end up in the output quite
6468 # yet. So we adopt a hack: read the `.am' file twice, throwing
6469 # away the output the first time. We also squirrel away a list of
6470 # all the variables defined by the .am file so that we know which
6471 # ones to remove from the content list.
6474 &define_standard_variables;
6475 local (%saved_contents) = %contents;
6477 # Read user file, but discard text of variable assignments we just
6480 &read_am_file ($amfile);
6482 # Now dump the variables that were defined. We do it in the same
6483 # order in which they were defined (skipping duplicates).
6485 foreach $curs (@var_list)
6487 next if $done{$curs};
6490 $output_vars .= $am_vars{$curs};
6491 if ($conditional{$curs})
6493 local (@cond_vals) = split (' ', $conditional{$curs});
6496 local ($vcond) = shift (@cond_vals);
6497 local ($val) = &unquote_cond_val (shift (@cond_vals));
6498 $output_vars .= ($vcond . $curs . ' '
6499 . $def_type{$curs} . "= \\\n");
6501 foreach $line (split ("\n", $val))
6503 $output_vars .= $vcond . $line . "\n";
6509 $output_vars .= ($curs . ' ' . $def_type{$curs} . '= '
6510 . $contents{$curs} . "\n");
6514 # Generate copyright header for generated Makefile.in.
6515 local ($ov) = $output_vars;
6516 $output_vars = ("# $in_file_name generated automatically by automake "
6517 . $VERSION . " from $am_file_name\n");
6518 $output_vars .= $gen_copyright;
6520 # Now go through and delete all the variables that the user did
6523 foreach $var (keys %saved_contents)
6525 if ($contents{$var} eq $saved_contents{$var})
6527 delete $contents{$var};
6531 # Re-read the standard variables, and this time keep their
6532 # contributions to the output. Then add the user's output to the
6534 &define_standard_variables;
6535 $output_vars .= $ov;
6539 ################################################################
6541 sub initialize_global_constants
6543 # Values for AC_CANONICAL_*
6544 $AC_CANONICAL_HOST = 1;
6545 $AC_CANONICAL_SYSTEM = 2;
6547 # Associative array of standard directory names. Entry is TRUE if
6548 # corresponding directory should be installed during
6549 # 'install-exec' phase.
6567 # Commonly found files we look for and automatically include in
6571 "README", "THANKS", "TODO", "NEWS", "COPYING", "COPYING.LIB",
6572 "INSTALL", "ABOUT-NLS", "ChangeLog", "configure", "configure.in",
6573 "config.guess", "config.sub", "AUTHORS", "BACKLOG", "ABOUT-GNU",
6574 "libversion.in", "mdate-sh", "mkinstalldirs", "install-sh",
6575 'texinfo.tex', "ansi2knr.c", "ansi2knr.1", 'elisp-comp',
6576 'ylwrap', 'acinclude.m4', @libtoolize_files,
6577 'missing', 'compile'
6580 # Commonly used files we auto-include, but only sometimes.
6583 "aclocal.m4", "acconfig.h", "config.h.top",
6584 "config.h.bot", "stamp-h.in", 'stamp-vti'
6588 -a, --add-missing add missing standard files to package
6589 --amdir=DIR directory storing config files
6590 --build-dir=DIR directory where build being done (for dependencies)
6591 -c, --copy with -a, copy missing files (default is symlink)
6592 --cygnus assume program is part of Cygnus-style tree
6593 --foreign set strictness to foreign
6594 --gnits set strictness to gnits
6595 --gnu set strictness to gnu
6596 --help print this help, then exit
6597 -i, --include-deps include generated dependencies in Makefile.in
6598 --no-force only update Makefile.in's that are out of date
6599 -o DIR, --output-dir=DIR
6600 put generated Makefile.in's into DIR
6601 --srcdir-name=DIR name used for srcdir (for dependencies)
6602 -v, --verbose verbosely list files processed
6603 --version print version number, then exit\n";
6605 # Copyright on generated Makefile.ins.
6607 # Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
6608 # This Makefile.in is free software; the Free Software Foundation
6609 # gives unlimited permission to copy and/or distribute it,
6610 # with or without modifications, as long as this notice is preserved.
6612 # This program is distributed in the hope that it will be useful,
6613 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
6614 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
6615 # PARTICULAR PURPOSE.
6618 # Ignore return result from chmod, because it might give an error
6619 # if we chmod a symlink.
6620 $dist_header = "\t" . '-chmod -R a+r $(distdir)' . "\n";
6621 $dist{'dist-bzip2'} = ("\t"
6622 . '$(AMTAR) ch$(AMTARFLAGS)f - $(distdir) | bzip --best -c > $(distdir).bz2'
6624 $dist{'dist-tarZ'} = ("\t"
6625 . '$(AMTAR) ch$(AMTARFLAGS)f - $(distdir) | compress -c > $(distdir).tar.Z'
6627 $dist{'dist-shar'} = ("\t"
6628 . 'shar $(distdir) | gzip > $(distdir).shar.gz'
6630 $dist{'dist-zip'} = "\t" . 'zip -rq $(distdir).zip $(distdir)' . "\n";
6631 $dist{'dist'} = ("\t"
6632 . '$(AMTAR) ch$(AMTARFLAGS)f - $(distdir) | GZIP=$(GZIP_ENV) gzip -c > $(distdir).tar.gz'
6634 $dist_trailer = "\t" . '-rm -rf $(distdir)' . "\n";
6637 # (Re)-Initialize per-Makefile.am variables.
6638 sub initialize_per_input
6640 # These two variables are used when generating each Makefile.in.
6641 # They hold the Makefile.in until it is ready to be printed.
6644 $output_trailer = '';
6646 $output_header = '';
6648 # Suffixes found during a run.
6651 # This holds the contents of a Makefile.am, as parsed by
6655 # This holds the names which are targets. These also appear in
6659 # This maps a variable name onto a flag. The flag is true iff the
6660 # variable was first defined with `+='.
6661 %var_was_plus_eq = ();
6663 # This holds definitions of all variables defined in .am files.
6664 # This is used during startup to determine which variables can be
6665 # assigned with `+='.
6668 # For a variable or target which is defined conditionally, this
6669 # holds an array of the conditional values. The array is composed
6670 # of pairs of condition strings (the variables which configure
6671 # will substitute) and values (the value of a target is
6672 # meaningless). For an unconditional variable, this is empty.
6675 # This holds the line numbers at which various elements of
6676 # %contents are defined.
6677 %content_lines = ();
6679 # This holds a 1 if a particular variable was examined.
6682 # This is the conditional stack.
6683 @conditional_stack = ();
6685 # This holds the set of included files.
6686 @include_stack = ();
6688 # This holds the "relative directory" of the current Makefile.in.
6689 # Eg for src/Makefile.in, this is "src".
6692 # This holds a list of files that are included in the
6696 # List of dependencies for the obvious targets.
6712 # A list of files deleted by `maintainer-clean'.
6713 @maintainer_clean_files = ();
6715 # These are pretty obvious, too. They are used to define the
6716 # SOURCES and OBJECTS variables.
6719 # Sources which go in the distribution.
6722 # This hash maps object file names onto their corresponding source
6723 # file names. This is used to ensure that each object is created
6724 # by a single source file.
6727 # This keeps track of the directories for which we've already
6728 # created `.dirstamp' code.
6729 %directory_map = ();
6731 # These variables track inclusion of various compile-related .am
6732 # files. $included_generic_compile is TRUE if the basic code has
6733 # been included. $included_knr_compile is TRUE if the ansi2knr
6734 # code has been included. $included_libtool_compile is TRUE if
6735 # libtool support has been included.
6736 $included_generic_compile = 0;
6737 $included_knr_compile = 0;
6738 $included_libtool_compile = 0;
6740 # TRUE if install targets should work recursively.
6741 $recursive_install = 0;
6746 # Strictness levels.
6747 $strictness = $default_strictness;
6748 $strictness_name = $default_strictness_name;
6750 # Options from AUTOMAKE_OPTIONS.
6753 # Whether or not dependencies are handled. Can be further changed
6754 # in handle_options.
6755 $use_dependencies = $cmdline_use_dependencies;
6758 $local_maint_charset = $maint_charset;
6760 # All yacc and lex source filenames for this directory. Use
6761 # filenames instead of raw count so that multiple instances are
6762 # counted correctly (eg one yacc file can appear in multiple
6763 # programs without harm).
6767 # This is a list of all targets to run during "make dist".
6770 # Keys in this hash are the basenames of files which must depend
6772 %de_ansi_files = ();
6774 # This maps the source extension of a suffix rule to its
6775 # corresponding output extension.
6778 # This is the name of the recursive `all' target to use.
6779 $all_target = 'all-recursive';
6781 # This keeps track of which extensions we've seen (that we care
6783 %extension_seen = ();
6785 # This is random scratch space for the language finish functions.
6786 # Don't randomly overwrite it; examine other uses of keys first.
6787 %language_scratch = ();
6791 ################################################################
6793 # Return contents of a file from $am_dir, automatically skipping
6794 # macros or rules which are already known. Runs command on each line
6795 # as it is read; this command can modify $_.
6796 sub file_contents_with_transform
6798 local ($command, $basename) = @_;
6799 local ($file) = $am_dir . '/' . $basename . '.am';
6801 if ($command ne '' && substr ($command, -1) ne ';')
6803 die "automake: programming error in file_contents_with_transform: $command\n";
6806 open (FC_FILE, $file)
6807 || die "automake: installation error: cannot open \`$file'\n";
6809 # print "automake: reading $file\n" if $verbose;
6811 local ($was_rule) = 0;
6812 local ($result_vars) = '';
6813 local ($result_rules) = '';
6814 local ($comment) = '';
6815 local ($spacing) = "\n";
6816 local ($skipping) = 0;
6821 $_ =~ s/\@MAINTAINER_MODE_TRUE\@//g
6822 unless $seen_maint_mode;
6824 $had_chars = length ($_) && $_ ne "\n";
6826 # If the transform caused all the characters to go away, then
6827 # ignore the line. Why do this? Because in Perl 4, a "next"
6828 # inside of an eval doesn't affect a loop outside the eval.
6829 # So we can't pass in a "transform" that uses next. We used
6830 # to do this. "Empty" also means consisting of a single
6832 next if $had_chars && ($_ eq '' || $_ eq "\n");
6834 if (/$IGNORE_PATTERN/o)
6836 # Merely delete comments beginning with two hashes.
6838 elsif (/$WHITE_PATTERN/o)
6840 # Stick a single white line before the incoming macro or rule.
6842 &am_line_error ($., "blank line following trailing backslash")
6845 elsif (/$COMMENT_PATTERN/o)
6847 # Stick comments before the incoming macro or rule.
6848 $comment .= $spacing . $_;
6850 &am_line_error ($., "comment following trailing backslash")
6857 $result_rules .= $_ if ! $skipping;
6861 $result_vars .= $_ if ! $skipping;
6865 elsif (/$RULE_PATTERN/o)
6869 $skipping = defined $contents{$1};
6870 $result_rules .= $comment . $spacing . $_ if ! $skipping;
6871 $comment = $spacing = '';
6874 elsif (/$MACRO_PATTERN/o)
6876 # Found a variable reference.
6878 $skipping = defined $contents{$1};
6879 $result_vars .= $comment . $spacing . $_ if ! $skipping;
6880 $comment = $spacing = '';
6882 print STDERR "automake: programming error: .am macro \`$1' with trailing backslash\n"
6884 $am_var_defs{$1} = $3;
6888 # This isn't an error; it is probably a continued rule.
6889 # In fact, this is what we assume.
6891 $result_rules .= $comment . $spacing . $_ if ! $skipping;
6892 $comment = $spacing = '';
6898 return $result_vars . $result_rules . $comment;
6901 # Like file_contents_with_transform, but no transform.
6904 return &file_contents_with_transform ('', @_);
6907 # Find all variable prefixes that are used for install directories. A
6908 # prefix `zar' qualifies iff:
6909 # * `zardir' is a variable.
6910 # * `zar_PRIMARY' is a variable.
6911 sub am_primary_prefixes
6913 local ($primary, $can_dist, @prefixes) = @_;
6915 local (%valid, $varname);
6916 grep ($valid{$_} = 0, @prefixes);
6917 $valid{'EXTRA'} = 0;
6918 foreach $varname (keys %contents)
6920 if ($varname =~ /^(dist_|nodist_)?(.*)_$primary$/)
6922 if (($1 ne '' && ! $can_dist)
6923 || (! defined $valid{$2}
6924 && ! &variable_defined ($2 . 'dir')
6925 # Note that a configure variable is always
6926 # legitimate. It is natural to name such
6927 # variables after the primary, so we explicitly
6929 && ! defined $configure_vars{$varname}))
6931 &am_line_error ($varname, "invalid variable \`$varname'");
6935 # Ensure all extended prefixes are actually used.
6936 $valid{$1 . $2} = 1;
6944 # Handle `where_HOW' variable magic. Does all lookups, generates
6945 # install code, and possibly generates code to define the primary
6946 # variable. The first argument is the name of the .am file to munge,
6947 # the second argument is the primary variable (eg HEADERS), and all
6948 # subsequent arguments are possible installation locations. Returns
6949 # list of all values of all _HOW targets.
6951 # FIXME: this should be rewritten to be cleaner. It should be broken
6952 # up into multiple functions.
6954 # Usage is: am_install_var (OPTION..., file, HOW, where...)
6959 local ($do_clean) = 0;
6960 local ($do_require) = 1;
6961 local ($can_dist) = 0;
6962 local ($default_dist) = 0;
6965 if (defined $configure_vars{'LIBTOOL'})
6967 # Transform '@LIBTOOL ...@' to '$(LIBTOOL) ...'
6968 $ltxform = 's/\@LIBTOOL([^\@]*)\@/\$(LIBTOOL) $1/;';
6972 # Delete '@LIBTOOL ...@'
6973 $ltxform = 's/\@LIBTOOL([^\@]*)\@//;';
6979 $cygxform = 's/\@EXEEXT\@//g;';
6983 $cygxform = 's/\@EXEEXT\@/\$(EXEEXT)/g;';
6988 if ($args[0] eq '-clean')
6992 elsif ($args[0] eq '-noextra')
6996 elsif ($args[0] eq '-candist')
7000 elsif ($args[0] eq '-defaultdist')
7005 elsif ($args[0] !~ /^-/)
7012 local ($file, $primary, @prefixes) = @args;
7015 local (@result) = ();
7017 # Now that configure substitutions are allowed in where_HOW
7018 # variables, it is an error to actually define the primary. We
7019 # allow `JAVA', as it is customarily used to mean the Java
7020 # interpreter. This is but one of several Java hacks.
7021 &am_line_error ($primary, "\`$primary' is an anachronism")
7022 if &variable_defined ($primary) && $primary ne 'JAVA';
7025 # Look for misspellings. It is an error to have a variable ending
7026 # in a "reserved" suffix whose prefix is unknown, eg
7027 # "bni_PROGRAMS". However, unusual prefixes are allowed if a
7028 # variable of the same name (with "dir" appended) exists. For
7029 # instance, if the variable "zardir" is defined, then
7030 # "zar_PROGRAMS" becomes valid. This is to provide a little extra
7031 # flexibility in those cases which need it.
7032 local (%valid) = &am_primary_prefixes ($primary, $can_dist, @prefixes);
7034 # If a primary includes a configure substitution, then the EXTRA_
7035 # form is required. Otherwise we can't properly do our job.
7036 local ($require_extra);
7037 local ($warned_about_extra) = 0;
7039 local ($clean_file) = $file . '-clean';
7042 local ($nodir_name);
7043 foreach $X (sort keys %valid)
7045 $one_name = $X . '_' . $primary;
7046 if (&variable_defined ($one_name))
7048 # If files should be distributed, do so.
7051 if (($default_dist && $one_name !~ /^nodist_/)
7052 || (! $default_dist && $one_name =~ /^dist_/))
7054 &push_dist_common ('$(' . $one_name . ')');
7056 ($nodir_name = $X) =~ s/^(dist|nodist)_//;
7063 # Append actual contents of where_PRIMARY variable to
7066 foreach $rcurs (&variable_value_as_list ($one_name, 'all'))
7068 # Skip configure substitutions. Possibly bogus.
7069 if ($rcurs =~ /^\@.*\@$/)
7073 if (! $warned_about_extra)
7075 $warned_about_extra = 1;
7077 &am_line_error ($one_name,
7078 "\`$one_name' contains configure substitution, but shouldn't");
7082 # Check here to make sure variables defined in
7083 # configure.in do not imply that EXTRA_PRIMARY
7085 elsif (! defined $configure_vars{$one_name})
7087 $require_extra = $one_name
7094 push (@result, $rcurs);
7097 # "EXTRA" shouldn't be used when generating clean targets,
7098 # all, or install targets.
7101 # We used to warn if EXTRA_FOO was defined uselessly,
7102 # but this was annoying.
7106 # A blatant hack: we rewrite each _PROGRAMS primary to
7107 # include EXEEXT when in Cygwin32 mode.
7108 if ($seen_exeext && $primary eq 'PROGRAMS')
7110 local (@conds) = &variable_conditions ($one_name);
7111 local (@one_binlist);
7113 # FIXME: this definitely loses aesthetically; it
7114 # redefines $ONE_NAME. Instead we should arrange for
7115 # variable definitions to be output later, instead of
7121 foreach $rcurs (&variable_value_as_list ($one_name, ''))
7123 if ($rcurs =~ /\./ || $rcurs =~ /^\@.*\@$/)
7125 push (@one_binlist, $rcurs);
7129 push (@one_binlist, $rcurs . '$(EXEEXT)');
7133 delete $contents{$one_name};
7134 &define_pretty_variable ($one_name, '', @one_binlist);
7139 local ($condvals) = '';
7140 foreach $cond (@conds)
7143 local (@condval) = &variable_value_as_list ($one_name,
7145 foreach $rcurs (@condval)
7147 if ($rcurs =~ /\./ || $rcurs =~ /^\@.*\@$/)
7149 push (@one_binlist, $rcurs);
7153 push (@one_binlist, $rcurs . '$(EXEEXT)');
7157 push (@condvals, $cond);
7158 push (@condvals, join (' ', @one_binlist));
7161 delete $contents{$one_name};
7165 $cond = shift (@condvals);
7166 local (@val) = split (' ', shift (@condvals));
7167 &define_pretty_variable ($one_name, $cond, @val);
7175 &file_contents_with_transform ('s/\@DIR\@/' . $X . '/go;'
7179 push (@clean, $X . $primary);
7180 &push_phony_cleaners ($X . $primary);
7185 push (@check, '$(' . $one_name . ')');
7189 push (@used, '$(' . $one_name . ')');
7191 if ($X eq 'noinst' || $X eq 'check')
7193 # Objects which don't get installed by default.
7198 &file_contents_with_transform ('s/\@DIR\@/' . $X . '/g;'
7199 . 's/\@NDIR\@/' . $nodir_name . '/go;'
7200 . $ltxform . $cygxform,
7203 push (@uninstall, 'uninstall-' . $X . $primary);
7204 push (@phony, 'uninstall-' . $X . $primary);
7205 push (@installdirs, '$(DESTDIR)$(' . $X . 'dir)');
7206 if (defined $exec_dir_p{$X} ? $exec_dir_p{$X} : ($X =~ /exec/))
7208 push (@install_exec, 'install-' . $X . $primary);
7209 push (@phony, 'install-' . $X . $primary);
7213 push (@install_data, 'install-' . $X . $primary);
7214 push (@phony, 'install-' . $X . $primary);
7219 # The JAVA variable is used as the name of the Java interpreter.
7220 if (@used && $primary ne 'JAVA')
7223 &define_pretty_variable ($primary, '', @used);
7224 $output_vars .= "\n";
7227 if ($require_extra && ! &variable_defined ('EXTRA_' . $primary))
7229 &am_line_error ($require_extra,
7230 "\`$require_extra' contains configure substitution, but \`EXTRA_$primary' not defined");
7233 # Push here because PRIMARY might be configure time determined.
7234 push (@all, '$(' . $primary . ')')
7235 if @used && $primary ne 'JAVA';
7237 # Make the result unique. This lets the user use conditionals in
7238 # a natural way, but still lets us program lazily -- we don't have
7239 # to worry about handling a particular object more than once.
7240 local (%uniquify) = ();
7241 grep ($uniquify{$_} = 1, @result);
7242 return sort keys %uniquify;
7246 ################################################################
7248 # This variable is local to the "require file" set of functions.
7249 @require_file_paths = ();
7251 # Verify that the file must exist in the current directory. Usage:
7252 # require_file (isconfigure, line_number, strictness, file) strictness
7253 # is the strictness level at which this file becomes required. Must
7254 # set require_file_paths before calling this function.
7255 # require_file_paths is set to hold a single directory (the one in
7256 # which the first file was found) before return.
7257 sub require_file_internal
7259 local ($is_configure, $line, $mystrict, @files) = @_;
7260 local ($file, $fullfile);
7261 local ($found_it, $errfile, $errdir);
7264 foreach $file (@files)
7267 foreach $dir (@require_file_paths)
7271 $fullfile = $relative_dir . "/" . $file;
7272 $errdir = $relative_dir unless $errdir;
7276 $fullfile = $dir . "/" . $file;
7277 $errdir = $dir unless $errdir;
7280 # Use different name for "error filename". Otherwise on
7281 # an error the bad file will be reported as eg
7282 # `../../install-sh' when using the default
7284 $errfile = $errdir . '/' . $file;
7289 # FIXME: Once again, special-case `.'.
7290 &push_dist_common ($file)
7291 if $dir eq $relative_dir || $dir eq '.';
7299 # Prune the path list.
7300 @require_file_paths = $save_dir;
7304 if ($strictness >= $mystrict)
7306 local ($trailer) = '';
7307 local ($suppress) = 0;
7309 # Only install missing files according to our desired
7311 local ($message) = "required file \`$errfile' not found";
7316 # Maybe run libtoolize.
7318 && grep ($_ eq $file, @libtoolize_files)
7319 && system ('libtoolize', '--automake'))
7321 $message = "installing \`$errfile'";
7323 $trailer = "; cannot run \`libtoolize': $!";
7325 elsif (-f ($am_dir . '/' . $file))
7327 # Install the missing file. Symlink if we
7328 # can, copy if we must. Note: delete the file
7329 # first, in case it is a dangling symlink.
7330 $message = "installing \`$errfile'";
7331 # Windows Perl will hang if we try to delete a
7332 # file that doesn't exist.
7333 unlink ($errfile) if -f $errfile;
7334 if ($symlink_exists && ! $copy_missing)
7336 if (! symlink ($am_dir . '/' . $file, $errfile))
7339 $trailer = "; error while making link: $!\n";
7342 elsif (system ('cp', $am_dir . '/' . $file, $errfile))
7345 $trailer = "\n error while copying\n";
7350 local ($save) = $exit_status;
7353 # FIXME: allow actual file to be specified.
7354 &am_conf_line_error ('configure.in', $line,
7355 "$message$trailer");
7359 &am_line_error ($line, "$message$trailer");
7361 $exit_status = $save if $suppress;
7367 # Like require_file_with_line, but error messages refer to
7368 # configure.in, not the current Makefile.am.
7369 sub require_file_with_conf_line
7371 @require_file_paths = '.';
7372 &require_file_internal (1, @_);
7375 sub require_file_with_line
7377 @require_file_paths = '.';
7378 &require_file_internal (0, @_);
7383 @require_file_paths = '.';
7384 &require_file_internal (0, '', @_);
7387 # Require a file that is also required by Autoconf. Looks in
7388 # configuration path, as specified by AC_CONFIG_AUX_DIR.
7389 sub require_config_file
7391 @require_file_paths = @config_aux_path;
7392 &require_file_internal (1, '', @_);
7393 local ($dir) = $require_file_paths[0];
7394 @config_aux_path = @require_file_paths;
7397 $config_aux_dir = '.';
7401 $config_aux_dir = '$(top_srcdir)/' . $dir;
7405 # Assumes that the line number is in Makefile.am.
7406 sub require_conf_file_with_line
7408 @require_file_paths = @config_aux_path;
7409 &require_file_internal (0, @_);
7410 local ($dir) = $require_file_paths[0];
7411 @config_aux_path = @require_file_paths;
7414 $config_aux_dir = '.';
7418 $config_aux_dir = '$(top_srcdir)/' . $dir;
7422 # Assumes that the line number is in configure.in.
7423 sub require_conf_file_with_conf_line
7425 @require_file_paths = @config_aux_path;
7426 &require_file_internal (1, @_);
7427 local ($dir) = $require_file_paths[0];
7428 @config_aux_path = @require_file_paths;
7431 $config_aux_dir = '.';
7435 $config_aux_dir = '$(top_srcdir)/' . $dir;
7439 ################################################################
7441 # Push a list of files onto dist_common.
7442 sub push_dist_common
7444 local (@files) = @_;
7447 foreach $file (@files)
7449 $dist_common{$file} = 1;
7453 # Push a list of clean targets onto phony.
7454 sub push_phony_cleaners
7458 foreach $target ('mostly', 'dist', '', 'maintainer-')
7460 push (@phony, $target . 'clean-' . $base);
7467 $strictness_name = $_[0];
7468 if ($strictness_name eq 'gnu')
7472 elsif ($strictness_name eq 'gnits')
7474 $strictness = $GNITS;
7476 elsif ($strictness_name eq 'foreign')
7478 $strictness = $FOREIGN;
7482 die "automake: level \`$strictness_name' not recognized\n";
7487 ################################################################
7489 # Return directory name of file.
7495 ($sub = $file) =~ s,/+[^/]+$,,g;
7496 $sub = '.' if $sub eq $file;
7500 # Return file name of a file.
7506 ($sub = $file) =~s,^.*/+,,g;
7510 # Ensure a file exists.
7515 open (TOUCH, ">> $file");
7519 # Glob something. Do this to avoid indentation screwups everywhere we
7520 # want to glob. Gross!
7527 ################################################################
7529 # Print an error message and set exit status.
7532 warn "automake: ${am_file}.am: ", join (' ', @_), "\n";
7538 local ($symbol, @args) = @_;
7540 if ($symbol && "$symbol" ne '-1')
7542 local ($file) = "${am_file}.am";
7544 if ($symbol =~ /^\d+$/)
7546 # SYMBOL is a line number, so just add the colon.
7547 $file .= ':' . $symbol;
7549 elsif (defined $content_lines{$symbol})
7551 # SYMBOL is a variable defined in Makefile.am, so add the
7552 # line number we saved from there.
7553 $file .= ':' . $content_lines{$symbol};
7555 elsif (defined $configure_vars{$symbol})
7557 # SYMBOL is a variable defined in configure.in, so add the
7558 # appropriate line number.
7559 $file = $configure_vars{$symbol};
7563 # Couldn't find the line number.
7565 warn $file, ": ", join (' ', @args), "\n";
7574 # Like am_error, but while scanning configure.in.
7577 # FIXME: can run in subdirs.
7578 warn "automake: configure.in: ", join (' ', @_), "\n";
7582 # Error message with line number referring to configure.in.
7583 sub am_conf_line_error
7585 local ($file, $line, @args) = @_;
7589 warn "$file: $line: ", join (' ', @args), "\n";
7594 &am_conf_error (@args);
7598 # Warning message with line number referring to configure.in.
7599 # Does not affect exit_status
7600 sub am_conf_line_warning
7602 local ($saved_exit_status) = $exit_status;
7603 &am_conf_line_error (@_);
7604 $exit_status = $saved_exit_status;
7607 # Tell user where our aclocal.m4 is, but only once.
7608 sub keyed_aclocal_warning
7611 warn "automake: macro \`$key' can be generated by \`aclocal'\n";
7614 # Print usage information.
7617 print "Usage: automake [OPTION] ... [Makefile]...\n\n";
7618 print "Generate Makefile.in for autoconf from Makefile.am\n";
7620 print "\nFiles which are automatically distributed, if found:\n";
7621 $~ = "USAGE_FORMAT";
7622 local ($last, $iter, @lcomm);
7624 foreach $iter (sort ((@common_files, @common_sometimes)))
7626 push (@lcomm, $iter) unless $iter eq $last;
7630 local ($one, $two, $three, $four, $i, $max);
7631 $max = int (($#lcomm + 1) / 4);
7633 for ($i = 0; $i < $max; ++$i)
7636 $two = $lcomm[$max + $i];
7637 $three = $lcomm[2 * $max + $i];
7638 $four = $lcomm[3 * $max + $i];
7642 local ($mod) = ($#lcomm + 1) % 4;
7645 $one = $lcomm[$max];
7646 $two = ($mod > 1) ? $lcomm[2 * $max] : '';
7647 $three = ($mod > 2) ? $lcomm[3 * $max] : '';
7648 $four = ($mod > 3) ? $lcomm[4 * $max] : '';
7652 print "\nReport bugs to <bug-automake\@gnu.org>.\n";
7657 format USAGE_FORMAT =
7658 @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<
7659 $one, $two, $three, $four