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 # FIXME: what about zip and jar?
345 ®ister_language ('java', 'linker=GCJLINK', 'autodep=GCJ',
349 # Parse command line.
350 &parse_arguments (@ARGV);
352 # Do configure.in scan only once.
355 die "automake: no \`Makefile.am' found or specified\n"
358 # If --generate-deps was given, we don't do anything else
362 die "automake: Must specify --include-deps (or -i) when generating\n"
363 if $use_dependencies;
364 die "automake: Must provide --build-dir when generating\n"
365 if ! $build_directory;
366 die "automake: Must provide --srcdir-name when generating\n"
369 open (GDEP, ">$output_directory/.dep_segment")
370 || die "automake: Could not open `$output_directory/.dep_segment': $!\n";
372 &handle_dependencies;
373 print GDEP $output_rules;
379 # Now do all the work on each file.
380 foreach $am_file (@input_files)
382 if (! -f ($am_file . '.am'))
384 &am_error ("\`" . $am_file . ".am' does not exist");
388 &generate_makefile ($output_files{$am_file}, $am_file);
392 &am_conf_error ("AC_PROG_INSTALL must be used in configure.in")
393 if (! $seen_prog_install);
398 ################################################################
400 # Parse command line.
403 local (@arglist) = @_;
406 &set_strictness ('gnu');
410 if ($arglist[0] eq "--version")
412 print "automake (GNU $PACKAGE) $VERSION\n\n";
413 print "Copyright (C) 1999 Free Software Foundation, Inc.\n";
414 print "This is free software; see the source for copying conditions. There is NO\n";
415 print "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n";
416 print "Written by Tom Tromey <tromey\@cygnus.com>\n";
420 elsif ($arglist[0] eq "--help")
424 elsif ($arglist[0] =~ /^--amdir=(.+)$/)
428 elsif ($arglist[0] eq '--amdir')
430 &require_argument (@arglist);
432 $am_dir = $arglist[0];
434 elsif ($arglist[0] =~ /^--build-dir=(.+)$/)
437 $build_directory = $1 . '/';
439 elsif ($arglist[0] eq '--build-dir')
441 &require_argument (@arglist);
444 $build_directory = $arglist[0] . '/';
446 elsif ($arglist[0] =~ /^--srcdir-name=(.+)$/)
450 elsif ($arglist[0] eq '--srcdir-name')
452 &require_argument (@arglist);
454 $srcdir_name = $arglist[0];
456 elsif ($arglist[0] eq '--gnu')
458 &set_strictness ('gnu');
460 elsif ($arglist[0] eq '--gnits')
462 &set_strictness ('gnits');
464 elsif ($arglist[0] eq '--cygnus')
468 elsif ($arglist[0] eq '--foreign')
470 &set_strictness ('foreign');
472 elsif ($arglist[0] eq '--include-deps' || $arglist[0] eq '-i')
474 $cmdline_use_dependencies = 0;
476 elsif ($arglist[0] eq '--generate-deps')
480 elsif ($arglist[0] eq '--no-force')
482 $force_generation = 0;
484 elsif ($arglist[0] =~ /^--output-dir=(.*)$/)
486 # Set output directory.
487 $output_directory = $1;
489 elsif ($arglist[0] eq '--output-dir' || $arglist[0] eq '-o')
491 &require_argument (@arglist);
493 $output_directory = $arglist[0];
495 elsif ($arglist[0] eq '--add-missing' || $arglist[0] eq '-a')
499 elsif ($arglist[0] eq '--copy' || $arglist[0] eq '-c')
503 elsif ($arglist[0] eq '--verbose' || $arglist[0] eq '-v')
507 elsif ($arglist[0] eq '--')
509 # Stop option processing.
511 push (@input_files, @arglist);
514 elsif ($arglist[0] =~ /^-/)
516 die "automake: unrecognized option -- \`$arglist[0]'\nTry \`automake --help' for more information.\n";
520 # Handle $local:$input syntax. Note that we only examine
521 # the first ":" file to see if it is automake input; the
522 # rest are just taken verbatim. We still keep all the
523 # files around for dependency checking, however.
524 local ($local, $input, @rest) = split (/:/, $arglist[0]);
531 # Strip .in; later on .am is tacked on. That is how
532 # the automake input file is found. Maybe not the
533 # best way, but it is easy to explain. FIXME: should
534 # be error if .in is missing.
537 push (@input_files, $input);
538 $output_files{$input} = join (':', ($local, @rest));
544 # Take global strictness from whatever we currently have set.
545 $default_strictness = $strictness;
546 $default_strictness_name = $strictness_name;
549 # Ensure argument exists, or die.
552 local ($arg, @arglist) = @_;
553 die "automake: no argument given for option \`$arg'\n"
557 ################################################################
559 # Generate a Makefile.in given the name of the corresponding Makefile and
560 # the name of the file output by config.status.
561 sub generate_makefile
563 local ($output, $makefile) = @_;
565 ($am_file_name = $makefile) =~ s/^.*\///;
566 $in_file_name = $am_file_name . '.in';
567 $am_file_name .= '.am';
569 # $OUTPUT is encoded. If it contains a ":" then the first element
570 # is the real output file, and all remaining elements are input
571 # files. We don't scan or otherwise deal with these input file,
572 # other than to mark them as dependencies. See scan_configure for
574 local (@secondary_inputs);
575 ($output, @secondary_inputs) = split (/:/, $output);
577 &initialize_per_input;
578 $relative_dir = &dirname ($output);
579 $am_relative_dir = &dirname ($makefile);
581 # At the toplevel directory, we might need config.guess, config.sub
582 # or libtool scripts (ltconfig and ltmain.sh).
583 if ($relative_dir eq '.')
585 # libtool requires some files.
586 &require_conf_file_with_conf_line ($libtool_line, $FOREIGN,
590 # AC_CANONICAL_HOST and AC_CANONICAL_SYSTEM need config.guess and
592 &require_config_file ($FOREIGN, 'config.guess', 'config.sub')
596 # We still need Makefile.in here, because sometimes the `dist'
597 # target doesn't re-run automake.
598 if ($am_relative_dir eq $relative_dir)
600 # Only distribute the files if they are in the same subdir as
601 # the generated makefile.
602 &push_dist_common ($in_file_name, $am_file_name);
604 push (@sources, '$(SOURCES)')
605 if &variable_defined ('SOURCES');
606 push (@objects, '$(OBJECTS)')
607 if &variable_defined ('OBJECTS');
609 &read_main_am_file ($makefile . '.am');
612 # Fatal error. Just return, so we can continue with next file.
616 # Check first, because we might modify some state.
618 &check_gnu_standards;
619 &check_gnits_standards;
621 &handle_configure ($output, $makefile, @secondary_inputs);
628 &handle_built_sources;
630 # This must be run after all the sources are scanned.
633 # Re-init SOURCES and OBJECTS. FIXME: other code shouldn't depend
634 # on this (but currently does).
635 $contents{'SOURCES'} = join (' ', @sources);
636 $contents{'OBJECTS'} = join (' ', @objects);
637 &define_pretty_variable ('DIST_SOURCES', '', @dist_sources);
648 &handle_minor_options;
649 &handle_dist ($makefile);
650 &handle_dependencies;
653 &handle_merge_targets ($output);
660 if (! -d ($output_directory . '/' . $am_relative_dir))
662 mkdir ($output_directory . '/' . $am_relative_dir, 0755);
665 local ($out_file) = $output_directory . '/' . $makefile . ".in";
666 if (! $force_generation && -e $out_file)
668 local ($am_time) = (stat ($makefile . '.am'))[9];
669 local ($in_time) = (stat ($out_file))[9];
670 # FIXME: should cache these times.
671 local ($conf_time) = (stat ('configure.in'))[9];
672 # FIXME: how to do unsigned comparison?
673 if ($am_time < $in_time || $am_time < $conf_time)
680 local ($acl_time) = (stat _)[9];
681 return if ($am_time < $acl_time);
685 if (! open (GM_FILE, "> " . $out_file))
687 warn "automake: ${am_file}.in: cannot write: $!\n";
691 print "automake: creating ", $makefile, ".in\n" if $verbose;
693 print GM_FILE $output_vars;
694 # We make sure that `all:' is the first target.
695 print GM_FILE $output_all;
696 print GM_FILE $output_header;
697 print GM_FILE $output_rules;
698 print GM_FILE $output_trailer;
703 ################################################################
705 # Handle AUTOMAKE_OPTIONS variable. Return 1 on error, 0 otherwise.
708 if (&variable_defined ('AUTOMAKE_OPTIONS'))
710 foreach (&variable_value_as_list ('AUTOMAKE_OPTIONS', ''))
713 if ($_ eq 'gnits' || $_ eq 'gnu' || $_ eq 'foreign')
715 &set_strictness ($_);
717 elsif ($_ eq 'cygnus')
723 # An option like "../lib/ansi2knr" is allowed. With
724 # no path prefix, we assume the required programs are
725 # in this directory. We save the actual option for
727 $options{'ansi2knr'} = $_;
729 elsif ($_ eq 'no-installman' || $_ eq 'no-installinfo'
730 || $_ eq 'dist-shar' || $_ eq 'dist-zip'
731 || $_ eq 'dist-tarZ' || $_ eq 'dist-bzip2'
732 || $_ eq 'dejagnu' || $_ eq 'no-texinfo.tex'
733 || $_ eq 'readme-alpha' || $_ eq 'check-news'
734 || $_ eq 'subdir-objects')
736 # Explicitly recognize these.
738 elsif ($_ eq 'no-dependencies')
740 $use_dependencies = 0;
742 elsif (/([0-9]+)\.([0-9]+)([a-z])?/)
744 # Got a version number.
746 local ($rmajor, $rminor, $ralpha) = ($1, $2, $3);
748 if ($VERSION !~ /([0-9]+)\.([0-9]+)([a-z])?/)
751 "automake: programming error: version is incorrect\n";
754 local ($tmajor, $tminor, $talpha) = ($1, $2, $3);
756 # 2.0 is better than 1.0.
757 # 1.2 is better than 1.1.
758 # 1.2a is better than 1.2.
759 if ($rmajor > $tmajor
760 || ($rmajor == $tmajor && $rminor > $tminor)
761 || ($rminor == $tminor && $rminor == $tminor
762 && $ralpha gt $talpha))
764 &am_line_error ('AUTOMAKE_OPTIONS',
765 "require version $_, only have $VERSION");
771 &am_line_error ('AUTOMAKE_OPTIONS',
772 "option \`" . $_ . "\' not recognized");
777 if ($strictness == $GNITS)
779 $options{'readme-alpha'} = 1;
780 $options{'check-news'} = 1;
786 # Return object extension. Just once, put some code into the output.
787 # Argument is the name of the output file
788 sub get_object_extension
792 # Maybe require libtool library object files.
793 local ($extension) = '.o';
794 $extension = '.$(OBJEXT)' if $seen_objext;
795 $extension = '.lo' if ($out =~ /\.la$/);
797 if (! $included_generic_compile)
801 if (&variable_defined ('CONFIG_HEADER'))
804 foreach $one_hdr (split (' ', &variable_value ('CONFIG_HEADER')))
807 ($var = &dirname ($one_hdr)) =~ s/(\W)/\\$1/g;
808 $xform .= ' ' if $xform;
809 $xform .= '-I' . $var;
812 $xform = 's/\@CONFIG_INCLUDE_SPEC\@/' . $xform . '/go;';
813 $output_vars .= &file_contents_with_transform ($xform,
816 $xform = (($use_dependencies
817 ? 's/^NOTDEPEND.*$//;'
819 . ($seen_objext ? 's/^OBJEXT//;' : 's/^OBJEXT.*$//;')
821 . (defined $options{'subdir-objects'} ? '-o \$\@' : '')
823 $output_rules .= &file_contents_with_transform ($xform, 'compile');
825 &push_phony_cleaners ('compile');
827 # If using X, include some extra variable definitions. NOTE
828 # we don't want to force these into CFLAGS or anything,
829 # because not all programs will necessarily use X.
833 foreach $var ('X_CFLAGS', 'X_LIBS', 'X_EXTRA_LIBS', 'X_PRE_LIBS')
835 &define_configure_variable ($var);
839 push (@suffixes, '.c', '.o');
840 push (@suffixes, '.obj') if $seen_objext;
841 push (@clean, 'compile');
843 $included_generic_compile = 1;
846 if ($seen_libtool && ! $included_libtool_compile)
848 # Output the libtool compilation rules.
850 &file_contents_with_transform
851 ($use_dependencies ? 's/^NOTDEPEND.*$//;' : 's/^NOTDEPEND//;',
854 &push_phony_cleaners ('libtool');
856 push (@suffixes, '.lo');
857 push (@clean, 'libtool');
859 $included_libtool_compile = 1;
862 # Check for automatic de-ANSI-fication.
863 if (defined $options{'ansi2knr'})
865 $extension = '$U' . $extension;
866 if (! $included_knr_compile)
868 if (! $am_c_prototypes)
870 &am_line_error ('AUTOMAKE_OPTIONS',
871 "option \`ansi2knr' in use but \`AM_C_PROTOTYPES' not in configure.in");
872 &keyed_aclocal_warning ('AM_C_PROTOTYPES');
873 # Only give this error once.
874 $am_c_prototypes = 1;
877 # Only require ansi2knr files if they should appear in
879 if ($options{'ansi2knr'} eq 'ansi2knr')
881 &require_file_with_line ('AUTOMAKE_OPTIONS', $FOREIGN,
882 'ansi2knr.c', 'ansi2knr.1');
883 $output_rules .= &file_contents ('kr-extra');
884 push (@clean, 'krextra');
885 &push_phony_cleaners ('krextra');
888 # Generate rules to build ansi2knr. If it is in some
889 # other directory, then generate dependencies but have the
890 # rule just run elsewhere.
891 $objext = $seen_objext ? ".$(OBJEXT)" : ".o";
892 $output_rules .= ($options{'ansi2knr'} . ': '
893 . $options{'ansi2knr'} . $objext . "\n");
894 if ($options{'ansi2knr'} eq 'ansi2knr')
896 $output_rules .= ("\t\$(LINK) ansi2knr" . $objext
898 . "ansi2knr" . $objext
899 . ": \$(CONFIG_HEADER)\n\n");
903 $output_rules .= ("\tcd " . &dirname ($options{'ansi2knr'})
904 . " && \$(MAKE) \$(AM_MAKEFLAGS) "
906 # This is required for non-GNU makes.
907 $output_rules .= ($options{'ansi2knr'} . $objext . ":\n");
908 $output_rules .= ("\tcd " . &dirname ($options{'ansi2knr'})
909 . " && \$(MAKE) \$(AM_MAKEFLAGS)"
910 . " ansi2knr" . $objext . "\n\n");
913 # Make sure ansi2knr can be found: if no path specified,
915 if ($options{'ansi2knr'} eq 'ansi2knr')
917 # Substitution from AM_C_PROTOTYPES. This makes it be
918 # built only when necessary.
919 &define_configure_variable ('ANSI2KNR');
920 # ansi2knr needs to be built before subdirs, so unshift it.
921 unshift (@all, '$(ANSI2KNR)');
925 # Found in another directory.
926 &define_variable ("ANSI2KNR", $options{'ansi2knr'});
929 $output_rules .= &file_contents ('clean-kr');
932 &push_phony_cleaners ('kr');
934 $included_knr_compile = 1;
941 # Call finish function for each language that was used.
944 local ($ext, $name, $lang, %done);
946 foreach $ext (sort keys %extension_seen)
948 $lang = $extension_map{$ext};
949 next if defined $done{$lang};
951 $non_c = 0 if $lang !~ /(objc|cxx|f77|ratfor)$/;
953 # Compute the function name of the finisher and then call it.
954 $name = 'lang_' . $lang . '_finish';
958 # If the project is entirely C++ or entirely Fortran 77, don't
959 # bother with the C stuff. But if anything else creeps in, then use
961 if (! $non_c || scalar keys %suffix_rules > 0)
963 local ($ltcompile, $ltlink) = &libtool_compiler;
965 &define_configure_variable ('CFLAGS');
966 &define_compiler_variable ('COMPILE', $ltcompile,
967 '$(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)');
968 &define_variable ('CCLD', '$(CC)');
969 &define_variable ('LINK', $ltlink . '$(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@');
973 # Output a rule to build from a YACC source. The output from YACC is
974 # compiled with C or C++, depending on the extension of the YACC file.
975 sub output_yacc_build_rule
977 local ($yacc_suffix, $use_ylwrap, $c_suffix) = @_;
980 ($suffix = $yacc_suffix) =~ tr/y/c/;
981 push (@suffixes, $yacc_suffix, $suffix);
983 # Generate rule for c/c++.
984 $output_rules .= "$yacc_suffix$suffix:\n\t";
988 $output_rules .= ('$(SHELL) $(YLWRAP)'
989 . ' "$(YACC)" $< y.tab.c $*' . $suffix
990 . ' y.tab.h $*.h -- $(AM_YFLAGS) $(YFLAGS)');
994 $output_rules .= ('$(YACC) $(AM_YFLAGS) $(YFLAGS) $< && mv y.tab.c $*'
996 . "\tif test -f y.tab.h; then \\\n"
997 . "\tif cmp -s y.tab.h \$*.h; then rm -f y.tab.h; else mv y.tab.h \$*.h; fi; \\\n"
1000 $output_rules .= "\n";
1003 sub output_lex_build_rule
1005 local ($lex_suffix, $use_ylwrap) = @_;
1008 ($c_suffix = $lex_suffix) =~ tr/l/c/;
1009 push (@suffixes, $lex_suffix);
1010 &define_configure_variable ('LEX_OUTPUT_ROOT');
1011 &define_configure_variable ('LEXLIB');
1012 $output_rules .= "$lex_suffix$c_suffix:\n\t";
1016 # Is the $@ correct here? If so, why not use it in the ylwrap
1017 # build rule for yacc above?
1018 $output_rules .= '$(SHELL) $(YLWRAP)'
1019 . ' "$(LEX)" $< $(LEX_OUTPUT_ROOT).c $@ -- $(AM_LFLAGS) $(LFLAGS)';
1023 $output_rules .= '$(LEX) $(AM_LFLAGS) $(LFLAGS) $< && mv $(LEX_OUTPUT_ROOT).c $@';
1025 $output_rules .= "\n";
1029 # Check to make sure a source defined in LIBOBJS is not explicitly
1030 # mentioned. This is a separate function (as opposed to being inlined
1031 # in handle_source_transform) because it isn't always appropriate to
1033 sub check_libobjs_sources
1035 local ($one_file, $unxformed) = @_;
1037 local ($prefix, $file, @files);
1038 foreach $prefix ('', 'EXTRA_', 'dist_', 'nodist_',
1039 'dist_EXTRA_', 'nodist_EXTRA_')
1041 if (&variable_defined ($prefix . $one_file . '_SOURCES'))
1043 @files = &variable_value_as_list (($prefix
1044 . $one_file . '_SOURCES'),
1047 elsif ($prefix eq '')
1049 @files = ($unxformed . '.c');
1056 foreach $file (@files)
1058 if (defined $libsources{$file})
1060 &am_line_error ($prefix . $one_file . '_SOURCES',
1061 "automatically discovered file \`$file' should not be explicitly mentioned");
1067 # Does much of the actual work for handle_source_transform.
1069 # object extension (e.g., `$U.lo')
1070 # list of source files to transform
1072 # first element is name of linker to use (empty string for default linker)
1073 # remaining elements are names of objects
1074 sub handle_single_transform_list
1076 local ($obj, @files) = @_;
1077 local (@result) = ();
1078 local ($nonansi_obj) = $obj;
1079 $nonansi_obj =~ s/_//g;
1080 local (%linkers_used) = ();
1083 # Turn sources into objects.
1086 # Skip things that look like configure substitutions.
1089 # If the source file is in a subdirectory then the `.o' is
1090 # put into the current directory.
1092 # Split file name into base and extension.
1093 local ($full, $directory, $base, $extension, $linker, $object);
1094 next if ! /^((.*)\/)?([^\/]*)\.(.*)$/;
1100 local ($xbase) = $base;
1102 local ($lang) = $extension_map{$extension};
1105 &saw_extension ($extension);
1106 # Found the language, so see what it says.
1107 local ($subr) = 'lang_' . $lang . '_rewrite';
1108 # Note: computed subr call.
1109 local ($r) = & $subr ($directory, $base, $extension);
1110 # Skip this entry if we were asked not to process it.
1111 next if $r == $LANG_IGNORE;
1113 # Now extract linker and other info.
1114 $linker = $language_map{$lang . '-linker'};
1116 if ($language_map{$lang . '-ansi-p'})
1118 $object = $base . $obj;
1122 $object = $base . $nonansi_obj;
1125 # If rewrite said it was ok, put the object into a
1127 if ($r == $LANG_SUBDIR && $directory ne '')
1129 $object = $directory . '/' . $object;
1130 $xbase = $directory . '/' . $base;
1133 elsif ($extension =~ /^$source_suffix_pattern$/)
1135 # We just rewrite it. Maybe we should do more.
1136 # FIXME: what about subdir handling here?
1137 $object = $base . '.' . $suffix_rules{$extension};
1142 # No error message here. Used to have one, but it was
1147 $linkers_used{$linker} = 1;
1149 push (@result, $object);
1151 if (defined $object_map{$object})
1153 if ($object_map{$object} ne $full)
1155 &am_error ("object \`$object' created by \`$full' and \`$object_map{$object}'");
1160 local (@dep_list) = ();
1161 $object_map{$object} = $full;
1163 # If file is in subdirectory, we need explicit
1165 if ($directory ne '')
1167 push (@dep_list, $full);
1170 # If resulting object is in subdir, we need to make
1171 # sure the subdir exists at build time.
1172 if ($object =~ /\//)
1174 # FIXME: check that $DIRECTORY is somewhere in the
1177 # We don't allow `..' in object file names for
1178 # *any* source, not just Java. For Java it just
1179 # doesn't make sense, but in general it is
1180 # a problem because we can't pick a good name for
1182 if ($object =~ /(\/|^)\.\.\//)
1184 &am_error ("\`$full' contains \`..' component but should not");
1187 push (@dep_list, $directory . '/.dirstamp');
1189 # If we're generating dependencies, we also want
1190 # to make sure that the appropriate subdir of the
1191 # .deps directory is created.
1192 if ($use_dependencies)
1194 push (@dep_list, '.deps/' . $directory . '/.dirstamp');
1197 if (! defined $directory_map{$directory})
1199 $directory_map{$directory} = 1;
1200 $output_rules .= ($directory . "/.dirstamp:\n"
1201 . "\t\@\$(mkinstalldirs) $directory\n"
1202 . "\t\@: > $directory/.dirstamp\n");
1203 if ($use_dependencies)
1205 $output_rules .= ('.deps/' . $directory
1207 . "\t\@\$(mkinstalldirs) .deps/$directory\n"
1208 . "\t\@: > .deps/$directory/.dirstamp\n");
1213 &pretty_print_rule ($object . ':', "\t", @dep_list);
1216 # Transform .o or $o file into .P file (for automatic
1218 $dep_files{'.deps/' . $xbase . '.P'} = 1;
1222 return (&resolve_linker (%linkers_used), @result);
1225 # Handle SOURCE->OBJECT transform for one program or library.
1227 # canonical (transformed) name of object to build
1228 # actual name of object to build
1229 # object extension (ie either `.o' or `$o'.
1230 # Return result is name of linker variable that must be used.
1231 # Empty return means just use `LINK'.
1232 sub handle_source_transform
1234 # one_file is canonical name. unxformed is given name. obj is
1236 local ($one_file, $unxformed, $obj) = @_;
1238 local ($linker) = '';
1240 if (&variable_defined ($one_file . "_OBJECTS"))
1242 &am_line_error ($one_file . '_OBJECTS',
1243 $one_file . '_OBJECTS', 'should not be defined');
1244 # No point in continuing.
1248 local (@files, @result, $prefix, $temp, $xpfx);
1249 local (%used_pfx) = ();
1250 foreach $prefix ('', 'EXTRA_', 'dist_', 'nodist_',
1251 'dist_EXTRA_', 'nodist_EXTRA_')
1253 # We are going to define _OBJECTS variables using the prefix.
1254 # Then we glom them all together. So we can't use the null
1255 # prefix here as we need it later.
1256 $xpfx = ($prefix eq '') ? 'am_' : $prefix;
1259 local ($var) = $prefix . $one_file . "_SOURCES";
1260 if (&variable_defined ($var))
1262 push (@sources, '$(' . $prefix . $one_file . "_SOURCES)");
1263 push (@objects, '$(' . $xpfx . $one_file . "_OBJECTS)")
1264 unless $prefix =~ /EXTRA_/;
1265 push (@dist_sources, '$(' . $prefix . $one_file . "_SOURCES)")
1266 unless $prefix =~ /^nodist_/;
1267 local (@conds) = &variable_conditions ($var);
1270 @files = &variable_value_as_list ($var, '');
1275 foreach $cond (@conds)
1277 @files = &variable_value_as_list ($var, $cond);
1278 ($temp, @result) = &handle_single_transform_list ($obj,
1280 $linker = $temp if $linker eq '';
1282 # Define _OBJECTS conditionally.
1283 &define_pretty_variable ($xpfx . $one_file . '_OBJECTS',
1285 unless $prefix =~ /EXTRA_/;
1288 # Keep track of which prefixes we saw.
1289 $used_pfx{$xpfx} = 1
1290 unless $prefix =~ /EXTRA_/;
1296 # Avoid defining needless variables.
1297 next if (scalar @files == 0);
1299 # Keep track of which prefixes we saw.
1300 $used_pfx{$xpfx} = 1
1301 unless $prefix =~ /EXTRA_/;
1303 ($temp, @result) = &handle_single_transform_list ($obj, @files);
1304 $linker = $temp if $linker eq '';
1305 &define_pretty_variable ($xpfx . $one_file . "_OBJECTS", '', @result)
1306 unless $prefix =~ /EXTRA_/;
1309 local (@keys) = sort keys %used_pfx;
1310 if (scalar @keys == 0)
1312 &define_variable ($one_file . "_SOURCES", $unxformed . ".c");
1313 push (@sources, $unxformed . '.c');
1314 push (@dist_sources, $unxformed . '.c');
1315 push (@objects, $unxformed . $obj);
1316 push (@files, $unxformed . '.c');
1318 ($temp, @result) = &handle_single_transform_list ($obj, @files);
1319 $linker = $temp if $linker eq '';
1320 &define_pretty_variable ($one_file . "_OBJECTS", '', @result)
1324 grep ($_ = '$(' . $_ . $one_file . '_OBJECTS)', @keys);
1325 &define_pretty_variable ($one_file . '_OBJECTS', '', @keys);
1331 # Handle the BUILT_SOURCES variable.
1332 sub handle_built_sources
1334 return unless &variable_defined ('BUILT_SOURCES');
1336 local (@sources) = &variable_value_as_list ('BUILT_SOURCES', 'all');
1338 foreach $s (@sources)
1342 # FIXME: is this really the right thing to do?
1343 &am_line_error ('BUILT_SOURCES',
1344 "\`BUILT_SOURCES' should not contain a configure substitution");
1349 # We don't care about the return value of this function. We just
1350 # want to make sure to update %dep_files with the contents of
1352 &handle_single_transform_list (".o", @sources);
1355 # Special-case @ALLOCA@ and @LIBOBJS@ in _LDADD or _LIBADD variables.
1356 # Also, generate _DEPENDENCIES variable if appropriate.
1358 # transformed name of object being built, or empty string if no object
1359 # name of _LDADD/_LIBADD-type variable to examine
1360 # boolean (lex_seen) which is true if a lex source file was seen in this
1361 # object. valid only for LDADDs, not LIBADDs.
1362 # Returns 1 if LIBOBJS seen, 0 otherwise.
1363 sub handle_lib_objects
1365 local ($xname, $var, $lex_seen) = @_;
1368 die "automake: programming error 1 in handle_lib_objects\n"
1369 if ! &variable_defined ($var);
1371 die "automake: programming error 2 in handle_lib_objects\n"
1372 if $lex_seen && $var =~ /LIBADD/;
1374 local (@conds) = &variable_conditions ($var);
1377 $ret = &handle_lib_objects_cond ($xname, $var, $lex_seen, '');
1383 foreach $cond (@conds)
1385 if (&handle_lib_objects_cond ($xname, $var, $lex_seen, $cond))
1395 # Subroutine of handle_lib_objects: handle a particular condition.
1396 sub handle_lib_objects_cond
1398 local ($xname, $var, $lex_seen, $cond) = @_;
1400 # We recognize certain things that are commonly put in LIBADD or
1403 local (@dep_list) = ();
1405 local ($seen_libobjs) = 0;
1406 local ($flagvar) = 0;
1408 foreach $lsearch (&variable_value_as_list ($var, $cond))
1410 # Skip -lfoo and -Ldir; these are explicitly allowed.
1411 next if $lsearch =~ /^-[lL]/;
1412 if (! $flagvar && $lsearch =~ /^-/)
1414 if ($var =~ /^(.*)LDADD$/)
1416 # Skip -dlopen and -dlpreopen; these are explicitly allowed.
1417 next if $lsearch =~ /^-dl(pre)?open$/;
1418 &am_line_error ($var, "linker flags such as \`$lsearch' belong in \`${1}LDFLAGS");
1422 # Only get this error once.
1424 &am_line_error ($var, "you cannot use linker flags such as \`$lsearch' in \`$var'");
1428 # Assume we have a file of some sort, and push it onto the
1429 # dependency list. Autoconf substitutions are not pushed;
1430 # rarely is a new dependency substituted into (eg) foo_LDADD
1431 # -- but "bad things (eg -lX11) are routinely substituted.
1432 # Note that LIBOBJS and ALLOCA are exceptions to this rule,
1433 # and handled specially below.
1434 push (@dep_list, $lsearch)
1435 unless $lsearch =~ /^\@.*\@$/;
1437 # Automatically handle @LIBOBJS@ and @ALLOCA@. Basically this
1438 # means adding entries to dep_files.
1439 if ($lsearch =~ /^\@(LT)?LIBOBJS\@$/)
1441 push (@dep_list, $lsearch);
1443 if (! keys %libsources)
1445 &am_line_error ($var, "\@$1" . "LIBOBJS\@ seen but never set in \`configure.in'");
1448 local ($iter, $rewrite);
1449 foreach $iter (keys %libsources)
1451 if ($iter =~ /\.([cly])$/)
1453 &saw_extension ($1);
1454 &saw_extension ('c');
1457 if ($iter =~ /\.h$/)
1459 &require_file_with_line ($var, $FOREIGN, $iter);
1461 elsif ($iter ne 'alloca.c')
1463 ($rewrite = $iter) =~ s/\.c$/.P/;
1464 $dep_files{'.deps/' . $rewrite} = 1;
1465 &require_file_with_line ($var, $FOREIGN, $iter)
1466 unless &variable_defined ('BUILT_SOURCES')
1467 && grep ('^' . quotemeta $iter . '$', &variable_value_as_list ('BUILT_SOURCES', 'all'));
1471 elsif ($lsearch =~ /^\@(LT)?ALLOCA\@$/)
1473 push (@dep_list, $lsearch);
1474 &am_line_error ($var,
1475 "\@$1" . "ALLOCA\@ seen but \`AC_FUNC_ALLOCA' not in \`configure.in'")
1476 if ! defined $libsources{'alloca.c'};
1477 $dep_files{'.deps/alloca.P'} = 1;
1478 &require_file_with_line ($var, $FOREIGN, 'alloca.c');
1479 &saw_extension ('c');
1483 if ($xname ne '' && ! &variable_defined ($xname . '_DEPENDENCIES', $cond))
1485 &define_pretty_variable ($xname . '_DEPENDENCIES', $cond, @dep_list);
1488 return $seen_libobjs;
1491 # Canonicalize a name, and check to make sure the non-canonical name
1492 # is never used. Returns canonical name. Arguments are name and a
1493 # list of suffixes to check for.
1494 sub check_canonical_spelling
1496 local ($name, @suffixes) = @_;
1497 local ($xname, $xt);
1499 ($xname = $name) =~ tr/A-Za-z0-9_/_/c;
1500 if ($xname ne $name)
1503 foreach $xt (@suffixes)
1505 &am_line_error ($name . $xt,
1506 "invalid variable \`" . $name . $xt
1507 . "'; should be \`" . $xname . $xt . "'")
1508 if &variable_defined ($name . $xt);
1515 # Handle C programs.
1518 local (@proglist) = &am_install_var ('-clean',
1519 'progs', 'PROGRAMS',
1520 'bin', 'sbin', 'libexec', 'pkglib',
1522 return if ! @proglist;
1524 # If a program is installed, this is required. We only want this
1525 # error to appear once.
1526 &am_conf_error ("AC_ARG_PROGRAM must be used in configure.in")
1527 unless $seen_arg_prog;
1530 local ($one_file, $xname, $munge);
1532 local ($seen_libobjs) = 0;
1533 foreach $one_file (@proglist)
1535 local ($obj) = &get_object_extension ($one_file);
1537 # Canonicalize names and check for misspellings.
1538 $xname = &check_canonical_spelling ($one_file, '_LDADD', '_LDFLAGS',
1539 '_SOURCES', '_OBJECTS',
1542 # FIXME: Using a trick to figure out if any lex sources appear
1543 # in our program; should use some cleaner method.
1544 local ($lex_num) = scalar (keys %lex_sources);
1545 local ($linker) = &handle_source_transform ($xname, $one_file, $obj);
1546 local ($lex_file_seen) = (scalar (keys %lex_sources) > $lex_num);
1549 if (&variable_defined ($xname . "_LDADD"))
1551 if (&handle_lib_objects ($xname, $xname . '_LDADD',
1561 # User didn't define prog_LDADD override. So do it.
1562 &define_variable ($xname . '_LDADD', '$(LDADD)');
1564 # This does a bit too much work. But we need it to
1565 # generate _DEPENDENCIES when appropriate.
1566 if (&variable_defined ('LDADD'))
1568 if (&handle_lib_objects ($xname, 'LDADD', $lex_file_seen))
1574 elsif (! &variable_defined ($xname . '_DEPENDENCIES'))
1576 &define_variable ($xname . '_DEPENDENCIES', '');
1581 if (&variable_defined ($xname . '_LIBADD'))
1583 &am_line_error ($xname . '_LIBADD',
1584 "use \`" . $xname . "_LDADD', not \`"
1585 . $xname . "_LIBADD'");
1588 if (! &variable_defined ($xname . '_LDFLAGS'))
1590 # Define the prog_LDFLAGS variable.
1591 &define_variable ($xname . '_LDFLAGS', '');
1594 # Determine program to use for link.
1596 if (&variable_defined ($xname . '_LINK'))
1598 $xlink = $xname . '_LINK';
1602 $xlink = $linker ? $linker : 'LINK';
1606 if ($seen_exeext && $one_file !~ /\./)
1608 $xexe = 's/\@EXEEXT\@/\$(EXEEXT)/g;';
1612 $xexe = 's/\@EXEEXT\@//g;';
1616 &file_contents_with_transform
1617 ('s/\@PROGRAM\@/' . $one_file . '/go;'
1618 . 's/\@XPROGRAM\@/' . $xname . '/go;'
1619 . 's/\@XLINK\@/' . $xlink . '/go;'
1624 if (&variable_defined ('LDADD') && &handle_lib_objects ('', 'LDADD', 0))
1631 foreach $one_file (@proglist)
1633 # Canonicalize names.
1634 ($xname = $one_file) =~ tr/A-Za-z0-9_/_/c;
1636 if (&variable_defined ($xname . '_LDADD'))
1638 &check_libobjs_sources ($xname, $xname . '_LDADD');
1640 elsif (&variable_defined ('LDADD'))
1642 &check_libobjs_sources ($xname, 'LDADD');
1650 sub handle_libraries
1652 local (@liblist) = &am_install_var ('-clean',
1653 'libs', 'LIBRARIES',
1654 'lib', 'pkglib', 'noinst', 'check');
1655 return if ! @liblist;
1657 local (%valid) = &am_primary_prefixes ('LIBRARIES', 0, 'lib', 'pkglib',
1659 if (! defined $configure_vars{'RANLIB'})
1662 foreach $key (keys %valid)
1664 if (&variable_defined ($key . '_LIBRARIES'))
1666 &am_line_error ($key . '_LIBRARIES', "library used but \`RANLIB' not defined in \`configure.in'");
1667 # Only get this error once. If this is ever printed,
1669 $configure_vars{'RANLIB'} = 'BUG';
1678 local ($seen_libobjs) = 0;
1679 foreach $onelib (@liblist)
1681 # Check that the library fits the standard naming convention.
1682 if ($onelib !~ /^lib.*\.a$/)
1684 # FIXME should put line number here. That means mapping
1685 # from library name back to variable name.
1686 &am_error ("\`$onelib' is not a standard library name");
1689 local ($obj) = &get_object_extension ($onelib);
1691 # Canonicalize names and check for misspellings.
1692 $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_SOURCES',
1693 '_OBJECTS', '_DEPENDENCIES');
1695 if (&variable_defined ($xlib . '_LIBADD'))
1697 if (&handle_lib_objects ($xlib, $xlib . '_LIBADD', 0))
1704 # Generate support for conditional object inclusion in
1706 &define_variable ($xlib . "_LIBADD", '');
1709 if (&variable_defined ($xlib . '_LDADD'))
1711 &am_line_error ($xlib . '_LDADD',
1712 "use \`" . $xlib . "_LIBADD', not \`"
1713 . $xlib . "_LDADD'");
1716 # Make sure we at look at this.
1717 &examine_variable ($xlib . '_DEPENDENCIES');
1719 &handle_source_transform ($xlib, $onelib, $obj);
1722 &file_contents_with_transform ('s/\@LIBRARY\@/' . $onelib . '/go;'
1730 foreach $onelib (@liblist)
1732 # Canonicalize names.
1733 ($xlib = $onelib) =~ tr/A-Za-z0-9_/_/c;
1734 if (&variable_defined ($xlib . '_LIBADD'))
1736 &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
1741 &define_variable ('AR', 'ar');
1742 &define_configure_variable ('RANLIB');
1745 # Handle shared libraries.
1746 sub handle_ltlibraries
1748 local (@liblist) = &am_install_var ('-clean',
1749 'ltlib', 'LTLIBRARIES',
1750 'noinst', 'lib', 'pkglib', 'check');
1751 return if ! @liblist;
1754 local (%valid) = &am_primary_prefixes ('LTLIBRARIES', 0, 'lib', 'pkglib',
1758 foreach $key (keys %valid)
1760 if (&variable_defined ($key . '_LTLIBRARIES'))
1764 &am_line_error ($key . '_LTLIBRARIES', "library used but \`LIBTOOL' not defined in \`configure.in'");
1765 # Only get this error once. If this is ever printed,
1767 $configure_vars{'LIBTOOL'} = 'BUG';
1771 # Get the installation directory of each library.
1772 for (&variable_value_as_list ($key . '_LTLIBRARIES', 'all'))
1776 &am_error ("\`$_' is already going to be installed in \`$instdirs{$_}'");
1780 $instdirs{$_} = $key;
1789 local ($seen_libobjs) = 0;
1790 foreach $onelib (@liblist)
1792 local ($obj) = &get_object_extension ($onelib);
1794 # Canonicalize names and check for misspellings.
1795 $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_LDFLAGS',
1796 '_SOURCES', '_OBJECTS',
1799 if (! &variable_defined ($xlib . '_LDFLAGS'))
1801 # Define the lib_LDFLAGS variable.
1802 &define_variable ($xlib . '_LDFLAGS', '');
1805 # Check that the library fits the standard naming convention.
1806 $libname_rx = "^lib.*\.la";
1807 if (&variable_value ($xlib . '_LDFLAGS') =~ /-module/)
1809 # Relax name checking for libtool modules.
1810 $libname_rx = "\.la";
1812 if ($onelib !~ /$libname_rx$/)
1814 # FIXME this should only be a warning for foreign packages
1815 # FIXME should put line number here. That means mapping
1816 # from library name back to variable name.
1817 &am_error ("\`$onelib' is not a standard libtool library name");
1820 if (&variable_defined ($xlib . '_LIBADD'))
1822 if (&handle_lib_objects ($xlib, $xlib . '_LIBADD', 0))
1829 # Generate support for conditional object inclusion in
1831 &define_variable ($xlib . "_LIBADD", '');
1834 if (&variable_defined ($xlib . '_LDADD'))
1836 &am_line_error ($xlib . '_LDADD',
1837 "use \`" . $xlib . "_LIBADD', not \`"
1838 . $xlib . "_LDADD'");
1841 # Make sure we at look at this.
1842 &examine_variable ($xlib . '_DEPENDENCIES');
1844 local ($linker) = &handle_source_transform ($xlib, $onelib, $obj);
1846 # Determine program to use for link.
1848 if (&variable_defined ($xlib . '_LINK'))
1850 $xlink = $xlib . '_LINK';
1854 $xlink = $linker ? $linker : 'LINK';
1858 if ($instdirs{$onelib} eq 'EXTRA' || $instdirs{$onelib} eq 'noinst')
1860 # It's an EXTRA_ library, so we can't specify -rpath,
1861 # because we don't know where the library will end up.
1862 # The user probably knows, but generally speaking automake
1863 # doesn't -- and in fact configure could decide
1864 # dynamically between two different locations.
1865 $rpath = 's/\@RPATH\@//go;';
1869 $rpath = ('s/\@RPATH\@/-rpath \$(' . $instdirs{$onelib}
1874 &file_contents_with_transform ('s/\@LTLIBRARY\@/'
1876 . 's/\@XLTLIBRARY\@/'
1879 . 's/\@XLINK\@/' . $xlink . '/go;',
1885 foreach $onelib (@liblist)
1887 # Canonicalize names.
1888 ($xlib = $onelib) =~ tr/A-Za-z0-9_/_/c;
1889 if (&variable_defined ($xlib . '_LIBADD'))
1891 &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
1897 # See if any _SOURCES variable were misspelled. Also, make sure that
1898 # EXTRA_ variables don't contain configure substitutions.
1901 local ($varname, $primary);
1902 foreach $varname (keys %contents)
1904 foreach $primary ('_SOURCES', '_LIBADD', '_LDADD', '_LDFLAGS',
1907 if ($varname =~ /$primary$/ && ! $content_seen{$varname})
1909 &am_line_error ($varname,
1910 "invalid unused variable name: \`$varname'");
1919 # NOTE we no longer automatically clean SCRIPTS, because it is
1920 # useful to sometimes distribute scripts verbatim. This happens
1921 # eg in Automake itself.
1922 &am_install_var ('-candist', 'scripts', 'SCRIPTS',
1923 'bin', 'sbin', 'libexec', 'pkgdata',
1926 local ($scripts_installed) = 0;
1927 # Set $scripts_installed if appropriate. Make sure we only find
1928 # scripts which are actually installed -- this is why we can't
1929 # simply use the return value of am_install_var.
1930 local (%valid) = &am_primary_prefixes ('SCRIPTS', 1, 'bin', 'sbin',
1931 'libexec', 'pkgdata',
1934 foreach $key (keys %valid)
1936 if ($key ne 'noinst'
1938 && &variable_defined ($key . '_SCRIPTS'))
1940 $scripts_installed = 1;
1941 # push (@check_tests, 'check-' . $key . 'SCRIPTS');
1945 if ($scripts_installed)
1947 # If a program is installed, this is required. We only want this
1948 # error to appear once.
1949 &am_conf_error ("AC_ARG_PROGRAM must be used in configure.in")
1950 unless $seen_arg_prog;
1955 # Search a file for a "version.texi" Texinfo include. Return the name
1956 # of the include file if found, or the empty string if not. A
1957 # "version.texi" file is actually any file whose name matches
1959 sub scan_texinfo_file
1961 local ($filename) = @_;
1963 if (! open (TEXI, $filename))
1965 &am_error ("couldn't open \`$filename': $!");
1968 print "automake: reading $filename\n" if $verbose;
1970 local ($vfile, $outfile);
1973 if (/^\@setfilename +(\S+)/)
1979 if (/^\@include\s+(vers[^.]*\.texi)\s*$/)
1981 # Found version.texi include.
1988 return ($outfile, $vfile);
1991 # Handle all Texinfo source.
1994 &am_line_error ('TEXINFOS',
1995 "\`TEXINFOS' is an anachronism; use \`info_TEXINFOS'")
1996 if &variable_defined ('TEXINFOS');
1997 return if (! &variable_defined ('info_TEXINFOS')
1998 && ! &variable_defined ('html_TEXINFOS'));
2000 if (&variable_defined ('html_TEXINFOS'))
2002 &am_line_error ('html_TEXINFOS',
2003 "HTML generation not yet supported");
2007 local (@texis) = &variable_value_as_list ('info_TEXINFOS', 'all');
2009 local (@info_deps_list, @dvis_list, @texi_deps);
2010 local ($infobase, $info_cursor);
2014 local ($tc_cursor, @texi_cleans);
2017 foreach $info_cursor (@texis)
2019 # FIXME: This is mildly hacky, since it recognizes "txinfo".
2020 # I don't feel like making it right.
2021 ($infobase = $info_cursor) =~ s/\.te?xi(nfo)?$//;
2023 # If 'version.texi' is referenced by input file, then include
2024 # automatic versioning capability.
2025 local ($out_file, $vtexi) = &scan_texinfo_file ($relative_dir
2026 . "/" . $info_cursor);
2028 if ($out_file eq '')
2030 &am_error ("\`$info_cursor' missing \@setfilename");
2034 if ($out_file =~ /\.(.+)$/ && $1 ne 'info')
2036 # FIXME should report line number in input file.
2037 &am_error ("output of \`$info_cursor', \`$out_file', has unrecognized extension");
2043 &am_error ("\`$vtexi', included in \`$info_cursor', also included in \`$versions{$vtexi}'")
2044 if (defined $versions{$vtexi});
2045 $versions{$vtexi} = $info_cursor;
2047 # We number the stamp-vti files. This is doable since the
2048 # actual names don't matter much. We only number starting
2049 # with the second one, so that the common case looks nice.
2050 $vti = 'vti' . ($done ? $done : '');
2051 &push_dist_common ($vtexi, 'stamp-' . $vti);
2052 push (@clean, $vti);
2054 # Only require once.
2055 &require_conf_file_with_line ('info_TEXINFOS', $FOREIGN,
2060 local ($conf_pat, $conf_dir);
2061 if ($config_aux_dir eq '.' || $config_aux_dir eq '')
2063 $conf_dir = '$(srcdir)/';
2067 $conf_dir = $config_aux_dir;
2068 $conf_dir .= '/' unless $conf_dir =~ /\/$/;
2070 ($conf_pat = $conf_dir) =~ s/(\W)/\\$1/g;
2072 &file_contents_with_transform
2073 ('s/\@TEXI\@/' . $info_cursor . '/g; '
2074 . 's/\@VTI\@/' . $vti . '/g; '
2075 . 's/\@VTEXI\@/' . $vtexi . '/g;'
2076 . 's,\@MDDIR\@,' . $conf_pat . ',g;',
2079 &push_phony_cleaners ($vti);
2082 # If user specified file_TEXINFOS, then use that as explicit
2085 push (@texi_deps, $info_cursor);
2086 push (@texi_deps, $vtexi) if $vtexi;
2088 # Canonicalize name first.
2089 ($canonical = $infobase) =~ tr/A-Za-z0-9_/_/c;
2090 if (&variable_defined ($canonical . "_TEXINFOS"))
2092 push (@texi_deps, '$(' . $canonical . '_TEXINFOS)');
2093 &push_dist_common ('$(' . $canonical . '_TEXINFOS)');
2096 $output_rules .= ("\n" . $out_file . ": "
2097 . join (' ', @texi_deps)
2098 . "\n" . $infobase . ".dvi: "
2099 . join (' ', @texi_deps)
2102 push (@info_deps_list, $out_file);
2103 push (@dvis_list, $infobase . '.dvi');
2105 # Generate list of things to clean for this target. We do
2106 # this explicitly because otherwise too many things could be
2107 # removed. In particular the ".log" extension might
2108 # reasonably be used in other contexts by the user.
2109 foreach $tc_cursor ('aux', 'cp', 'cps', 'dvi', 'fn', 'fns', 'pgs',
2110 'ky', 'kys', 'ps', 'log', 'pg', 'toc', 'tp', 'tps',
2111 'vr', 'vrs', 'op', 'tr', 'cv', 'cn')
2113 push (@texi_cleans, $infobase . '.' . $tc_cursor);
2117 # Find these programs wherever they may lie. Yes, this has
2118 # intimate knowledge of the structure of the texinfo distribution.
2119 &define_program_variable ('MAKEINFO', 'build', 'texinfo/makeinfo',
2121 # Circumlocution to avoid accidental
2122 # configure substitution.
2124 &define_program_variable ('TEXI2DVI', 'src', 'texinfo/util',
2127 # Set transform for including texinfos.am. First, handle --cygnus
2132 $xform = 's/^NOTCYGNUS.*$//; s/^CYGNUS//;';
2136 $xform = 's/^CYGNUS.*$//; s/^NOTCYGNUS//;';
2139 # Handle location of texinfo.tex.
2140 local ($need_texi_file) = 0;
2141 local ($texinfo_tex);
2144 $texinfo_tex = '$(top_srcdir)/../texinfo/texinfo.tex';
2145 &define_variable ('TEXINFO_TEX', $texinfo_tex);
2148 elsif ($config_aux_dir ne '.' && $config_aux_dir ne '')
2150 $texinfo_tex = $config_aux_dir . '/texinfo.tex';
2151 &define_variable ('TEXINFO_TEX', $texinfo_tex);
2152 $need_texi_file = 2; # so that we require_conf_file later
2154 elsif (&variable_defined ('TEXINFO_TEX'))
2156 # The user defined TEXINFO_TEX so assume he knows what he is
2158 $texinfo_tex = ('$(srcdir)/'
2159 . &dirname (&variable_value ('TEXINFO_TEX')));
2163 $texinfo_tex = '$(srcdir)/texinfo.tex';
2164 $need_texi_file = 1;
2167 ($xxform = $texinfo_tex) =~ s/\/texinfo\.tex$//;
2168 $xxform =~ s/(\W)/\\$1/g;
2169 $xform .= ' s/\@TEXINFODIR\@/' . $xxform . '/g;';
2171 $output_rules .= &file_contents_with_transform ($xform, 'texinfos');
2172 push (@phony, 'install-info-am', 'uninstall-info');
2173 push (@dist_targets, 'dist-info');
2175 # How to clean. The funny name is due to --cygnus influence; in
2176 # Cygnus mode, `clean-info' is a target that users can use.
2177 $output_rules .= "\nmostlyclean-aminfo:\n";
2178 &pretty_print_rule ("\t-rm -f", "\t ", @texi_cleans);
2179 $output_rules .= ("\nclean-aminfo:\n\ndistclean-aminfo:\n\n"
2180 . "maintainer-clean-aminfo:\n\t"
2181 # Eww. But how else can we find all the output
2182 # files from makeinfo?
2183 . ($cygnus_mode ? '' : 'cd $(srcdir) && ')
2184 . 'for i in $(INFO_DEPS); do' . " \\\n"
2185 . "\t" . ' rm -f $$i;' . " \\\n"
2186 . "\t" . ' if test "`echo $$i-[0-9]*`" != "$$i-[0-9]*"; then' . " \\\n"
2187 . "\t" . ' rm -f $$i-[0-9]*;' . " \\\n"
2188 . "\t" . ' fi;' . " \\\n"
2190 &push_phony_cleaners ('aminfo');
2193 $output_rules .= "clean-info: mostlyclean-aminfo\n";
2196 push (@suffixes, '.texi', '.texinfo', '.txi', '.info', '.dvi', '.ps');
2198 if (! defined $options{'no-installinfo'})
2200 push (@uninstall, 'uninstall-info');
2201 push (@installdirs, '$(DESTDIR)$(infodir)');
2202 unshift (@install_data, 'install-info-am');
2204 # Make sure documentation is made and installed first. Use
2205 # $(INFO_DEPS), not 'info', because otherwise recursive makes
2206 # get run twice during "make all".
2207 unshift (@all, '$(INFO_DEPS)');
2209 push (@clean, 'aminfo');
2210 push (@info, '$(INFO_DEPS)');
2211 push (@dvi, '$(DVIS)');
2213 &define_variable ("INFO_DEPS", join (' ', @info_deps_list));
2214 &define_variable ("DVIS", join (' ', @dvis_list));
2215 # This next isn't strictly needed now -- the places that look here
2216 # could easily be changed to look in info_TEXINFOS. But this is
2217 # probably better, in case noinst_TEXINFOS is ever supported.
2218 &define_variable ("TEXINFOS", &variable_value ('info_TEXINFOS'));
2220 # Do some error checking. Note that this file is not required
2221 # when in Cygnus mode; instead we defined TEXINFO_TEX explicitly
2223 if ($need_texi_file && ! defined $options{'no-texinfo.tex'})
2225 if ($need_texi_file > 1)
2227 &require_conf_file_with_line ('info_TEXINFOS', $FOREIGN,
2232 &require_file_with_line ('info_TEXINFOS', $FOREIGN, 'texinfo.tex');
2237 # Handle any man pages.
2238 sub handle_man_pages
2240 &am_line_error ('MANS', "\`MANS' is an anachronism; use \`man_MANS'")
2241 if &variable_defined ('MANS');
2242 return if ! &variable_defined ('man_MANS');
2244 # Find all the sections in use. We do this by first looking for
2245 # "standard" sections, and then looking for any additional
2246 # sections used in man_MANS.
2247 local ($sect, %sections, %vlist);
2248 # Add more sections as needed.
2249 foreach $sect ('0'..'9', 'n', 'l')
2251 if (&variable_defined ('man' . $sect . '_MANS'))
2253 $sections{$sect} = 1;
2254 $vlist{'$(man' . $sect . '_MANS)'} = 1;
2258 if (&variable_defined ('man_MANS'))
2260 $vlist{'$(man_MANS)'} = 1;
2261 foreach (&variable_value_as_list ('man_MANS', 'all'))
2263 # A page like `foo.1c' goes into man1dir.
2264 if (/\.([0-9a-z])([a-z]*)$/)
2272 # Now for each section, generate an install and unintall rule.
2273 # Sort sections so output is deterministic.
2275 foreach $sect (sort keys %sections)
2277 &define_variable ('man' . $sect . 'dir', '$(mandir)/man' . $sect);
2278 push (@installdirs, '$(DESTDIR)$(mandir)/man' . $sect)
2279 unless defined $options{'no-installman'};
2280 $output_rules .= &file_contents_with_transform ('s/\@SECTION\@/'
2283 push (@phony, 'install-man' . $sect, 'uninstall-man' . $sect);
2284 push (@namelist, 'install-man' . $sect);
2287 # We don't really need this, but we use it in case we ever want to
2288 # support noinst_MANS.
2289 &define_variable ("MANS", join (' ', sort keys %vlist));
2291 # Generate list of install dirs.
2292 $output_rules .= ("install-man: \$(MANS)\n"
2293 . "\t\@\$(NORMAL_INSTALL)\n");
2294 &pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ", @namelist);
2295 push (@phony, 'install-man');
2297 $output_rules .= "uninstall-man:\n\t\@\$(NORMAL_UNINSTALL)\n";
2298 grep ($_ = 'un' . $_, @namelist);
2299 &pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ", @namelist);
2300 push (@phony, 'uninstall-man');
2302 $output_vars .= &file_contents ('mans-vars');
2304 if (! defined $options{'no-installman'})
2306 push (@install_data, 'install-man');
2307 push (@uninstall, 'uninstall-man');
2308 push (@all, '$(MANS)');
2312 # Handle DATA variables.
2315 &am_install_var ('-noextra', '-defaultdist', 'data', 'DATA',
2316 'data', 'sysconf', 'sharedstate', 'localstate',
2317 'pkgdata', 'noinst', 'check');
2323 push (@phony, 'tags');
2324 local (@tag_deps) = ();
2325 if (&variable_defined ('SUBDIRS'))
2327 $output_rules .= ("tags-recursive:\n"
2328 . "\tlist=\'\$(SUBDIRS)\'; for subdir in \$\$list; do \\\n"
2329 # Never fail here if a subdir fails; it
2331 . "\t test \"\$\$subdir\" = . || (cd \$\$subdir"
2332 . " && \$(MAKE) \$(AM_MAKEFLAGS) tags); \\\n"
2334 push (@tag_deps, 'tags-recursive');
2335 push (@phony, 'tags-recursive');
2338 if (&saw_sources_p (1)
2339 || &variable_defined ('ETAGS_ARGS')
2342 local ($xform) = '';
2344 foreach $one_hdr (@config_headers)
2346 if ($relative_dir eq &dirname ($one_hdr))
2348 # The config header is in this directory. So require it.
2350 ($var = &basename ($one_hdr)) =~ s/(\W)/\\$1/g;
2351 $xform .= ' ' if $xform;
2355 $xform = ('s/\@CONFIG\@/' . $xform . '/;'
2356 . 's/\@DIRS\@/' . join (' ', @tag_deps) . '/;');
2358 if (&variable_defined ('SUBDIRS'))
2360 $xform .= 's/^SUBDIRS//;';
2364 $xform .= 's/^SUBDIRS.*$//;';
2367 $output_rules .= &file_contents_with_transform ($xform, 'tags');
2368 $output_rules .= &file_contents ('tags-clean');
2369 push (@clean, 'tags');
2370 &push_phony_cleaners ('tags');
2371 &examine_variable ('TAGS_DEPENDENCIES');
2373 elsif (&variable_defined ('TAGS_DEPENDENCIES'))
2375 &am_line_error ('TAGS_DEPENDENCIES',
2376 "doesn't make sense to define \`TAGS_DEPENDENCIES' without sources or \`ETAGS_ARGS'");
2380 # Every Makefile must define some sort of TAGS rule.
2381 # Otherwise, it would be possible for a top-level "make TAGS"
2382 # to fail because some subdirectory failed.
2383 $output_rules .= "tags: TAGS\nTAGS:\n\n";
2387 # Handle multilib support.
2390 return unless $seen_multilib;
2392 $output_rules .= &file_contents ('multilib.am');
2393 &push_phony_cleaners ('multi');
2394 push (@phony, 'all-multi', 'install-multi');
2397 # Worker for handle_dist.
2398 sub handle_dist_worker
2400 local ($makefile) = @_;
2402 $output_rules .= 'distdir: $(DISTFILES)' . "\n";
2404 # Initialization; only at top level.
2405 if ($relative_dir eq '.')
2407 if (defined $options{'check-news'})
2409 # For Gnits users, this is pretty handy. Look at 15 lines
2410 # in case some explanatory text is desirable.
2411 $output_rules .= ' @if sed 15q $(srcdir)/NEWS | fgrep -e "$(VERSION)" > /dev/null; then :; else \\
2412 echo "NEWS not updated; not releasing" 1>&2; \\
2419 # Create dist directory.
2420 $output_rules .= ("\t-rm -rf \$(distdir)\n"
2421 . "\tmkdir \$(distdir)\n"
2422 . "\t-chmod 777 \$(distdir)\n");
2425 # Only run automake in `dist' target if --include-deps and
2426 # `no-dependencies' not specified. That way the recipient of a
2427 # distribution can run "make dist" and not need Automake. You
2428 # might be wondering why we run automake once for each directory
2429 # we distribute, instead of running it once at the top level. The
2430 # answer is that we want to run automake after the dependencies
2431 # have been generated. This occurs when "make" is run in the
2432 # subdir. So automake must be run after make has updated the
2433 # Makefile, which means that it must run once per directory.
2434 if ($use_dependencies)
2438 # There are several directories we need to know about
2439 # when rebuilding the Makefile.ins. They are:
2440 # here - The absolute path to our topmost build directory.
2441 # top_distdir - The absolute path to the top of our dist
2443 # distdir - The path to our sub-part of the dist hierarchy.
2444 # If this directory is the topmost directory, we set
2445 # top_distdir from distdir; that lets us pass in distdir
2446 # from an enclosing package.
2447 "\t" . 'here=`cd $(top_builddir) && pwd`; ' . "\\\n"
2448 . "\t" . 'top_distdir=`cd $('
2449 . (($relative_dir eq '.') ? 'distdir' : 'top_distdir')
2450 . ') && pwd`; ' . "\\\n"
2451 . "\t" . 'distdir=`cd $(distdir) && pwd`; ' . "\\\n"
2452 . "\tcd \$(top_srcdir) \\\n"
2453 . "\t && \$(AUTOMAKE) --include-deps --build-dir=\$\$here --srcdir-name=\$(top_srcdir) --output-dir=\$\$top_distdir "
2454 # Set strictness of output.
2455 . ($cygnus_mode ? '--cygnus' : ('--' . $strictness_name))
2456 . ($cmdline_use_dependencies ? '' : ' --include-deps')
2457 . " " . $makefile . "\n"
2461 # Scan EXTRA_DIST to see if we need to distribute anything from a
2462 # subdir. If so, add it to the list. I didn't want to do this
2463 # originally, but there were so many requests that I finally
2466 if (&variable_defined ('EXTRA_DIST'))
2468 # FIXME: This should be fixed to work with conditionals. That
2469 # will require only making the entries in @dist_dirs under the
2470 # appropriate condition. This is meaningful if the nature of
2471 # the distribution should depend upon the configure options
2473 foreach (&variable_value_as_list ('EXTRA_DIST', ''))
2476 next unless s,/+[^/]+$,,;
2477 push (@dist_dirs, $_)
2483 # Prepend $(distdir) to each directory given. Doing it via a
2484 # hash lets us ensure that each directory is used only once.
2486 grep ($dhash{'$(distdir)/' . $_} = 1, @dist_dirs);
2487 $output_rules .= "\t";
2488 &pretty_print_rule ('$(mkinstalldirs)', "\t ", sort keys %dhash);
2491 # In loop, test for file existence because sometimes a file gets
2492 # included in DISTFILES twice. For example this happens when a
2493 # single source file is used in building more than one program.
2494 # Also, there are situations in which "ln" can fail. For instance
2495 # a file to distribute could actually be a cross-filesystem
2496 # symlink -- this can easily happen if "gettextize" was run on the
2498 $output_rules .= "\t\@for file in \$(DISTFILES); do \\\n";
2501 $output_rules .= "\t if test -f \$\$file; then d=.; else d=\$(srcdir); fi; \\\n";
2505 $output_rules .= "\t d=\$(srcdir); \\\n";
2507 $output_rules .= ("\t if test -d \$\$d/\$\$file; then \\\n"
2508 . "\t cp -pr \$\$d/\$\$file \$(distdir)/\$\$file; \\\n"
2510 . "\t test -f \$(distdir)/\$\$file \\\n"
2511 . "\t || ln \$\$d/\$\$file \$(distdir)/\$\$file 2> /dev/null \\\n"
2512 . "\t || cp -p \$\$d/\$\$file \$(distdir)/\$\$file || :; \\\n"
2516 # If we have SUBDIRS, create all dist subdirectories and do
2518 if (&variable_defined ('SUBDIRS'))
2520 # If SUBDIRS is conditionally defined, then set DIST_SUBDIRS
2521 # to all possible directories, and use it. If DIST_SUBDIRS is
2522 # defined, just use it.
2523 local ($dist_subdir_name);
2524 if (&variable_conditions ('SUBDIRS')
2525 || &variable_defined ('DIST_SUBDIRS'))
2527 $dist_subdir_name = 'DIST_SUBDIRS';
2528 if (! &variable_defined ('DIST_SUBDIRS'))
2530 &define_pretty_variable ('DIST_SUBDIRS', '',
2531 &variable_value_as_list ('SUBDIRS',
2537 $dist_subdir_name = 'SUBDIRS';
2540 # Test for directory existence here because previous automake
2541 # invocation might have created some directories. Note that
2542 # we explicitly set distdir for the subdir make; that lets us
2543 # mix-n-match many automake-using packages into one large
2544 # package, and have "dist" at the top level do the right
2545 # thing. If we're in the topmost directory, then we use
2546 # `distdir' instead of `top_distdir'; this lets us work
2547 # correctly with an enclosing package.
2549 ("\t" . 'for subdir in $(' . $dist_subdir_name . '); do ' . "\\\n"
2550 . "\t" . ' if test "$$subdir" = .; then :; else ' . "\\\n"
2551 . "\t" . ' test -d $(distdir)/$$subdir ' . "\\\n"
2552 . "\t" . ' || mkdir $(distdir)/$$subdir ' . "\\\n"
2553 . "\t" . ' || exit 1; ' . "\\\n"
2554 . "\t" . ' chmod 777 $(distdir)/$$subdir; ' . "\\\n"
2555 . "\t" . ' (cd $$subdir'
2556 . ' && $(MAKE) $(AM_MAKEFLAGS) top_distdir=../$('
2557 . (($relative_dir eq '.') ? 'distdir' : 'top_distdir')
2558 . ') distdir=../$(distdir)/$$subdir distdir) ' . "\\\n"
2559 . "\t" . ' || exit 1; ' . "\\\n"
2560 . "\t" . ' fi; ' . "\\\n"
2564 # If the target `dist-hook' exists, make sure it is run. This
2565 # allows users to do random weird things to the distribution
2566 # before it is packaged up.
2567 push (@dist_targets, 'dist-hook') if &target_defined ('dist-hook');
2570 foreach $targ (@dist_targets)
2572 # We must explicitly set distdir and top_distdir for these
2574 $output_rules .= ("\t\$(MAKE) \$(AM_MAKEFLAGS)"
2575 . " top_distdir=\"\$(top_distdir)\""
2576 . " distdir=\"\$(distdir)\" $targ\n");
2579 push (@phony, 'distdir');
2582 # Handle 'dist' target.
2585 local ($makefile) = @_;
2587 # Set up maint_charset.
2588 $local_maint_charset = &variable_value ('MAINT_CHARSET')
2589 if &variable_defined ('MAINT_CHARSET');
2590 $maint_charset = $local_maint_charset
2591 if $relative_dir eq '.';
2593 if (&variable_defined ('DIST_CHARSET'))
2595 &am_line_error ('DIST_CHARSET',
2596 "DIST_CHARSET defined but no MAINT_CHARSET defined")
2597 if ! $local_maint_charset;
2598 if ($relative_dir eq '.')
2600 $dist_charset = &variable_value ('DIST_CHARSET')
2604 &am_line_error ('DIST_CHARSET',
2605 "DIST_CHARSET can only be defined at top level");
2609 # Look for common files that should be included in distribution.
2611 foreach $cfile (@common_files)
2613 if (-f ($relative_dir . "/" . $cfile))
2615 &push_dist_common ($cfile);
2619 # Always require configure.in and configure at top level, even if
2620 # they don't exist. This is especially important for configure,
2621 # since it won't be created until autoconf is run -- which might
2622 # be after automake is run.
2623 &push_dist_common ('configure.in', 'configure')
2624 if $relative_dir eq '.';
2626 # Keys of %dist_common are names of files to distributed. We put
2627 # README first because it then becomes easier to make a
2628 # Usenet-compliant shar file (in these, README must be first).
2629 # FIXME: do more ordering of files here.
2631 if (defined $dist_common{'README'})
2633 push (@coms, 'README');
2634 delete $dist_common{'README'};
2636 push (@coms, sort keys %dist_common);
2638 &define_pretty_variable ("DIST_COMMON", '', @coms);
2639 $output_vars .= "\n";
2642 $output_vars .= &file_contents ('dist-vars') . "\n";
2643 &define_variable ('GZIP_ENV', '--best');
2645 # Put these things in rules section so it is easier for whoever
2646 # reads Makefile.in.
2647 if (! &variable_defined ('distdir'))
2649 if ($relative_dir eq '.')
2651 $output_rules .= "\n" . 'distdir = $(PACKAGE)-$(VERSION)' . "\n";
2655 $output_rules .= ("\n"
2656 . 'distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)'
2660 if ($relative_dir eq '.')
2662 $output_rules .= "top_distdir = \$(distdir)\n\n";
2666 $output_rules .= "\nsubdir = " . $relative_dir . "\n\n";
2669 # Generate 'dist' target, and maybe other dist targets.
2670 if ($relative_dir eq '.')
2672 # Rule to check whether a distribution is viable.
2673 $output_rules .= ('# This target untars the dist file and tries a VPATH configuration. Then
2674 # it guarantees that the distribution is self-contained by making another
2678 GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(AMTAR) xf -
2679 mkdir $(distdir)/=build
2680 mkdir $(distdir)/=inst
2681 dc_install_base=`cd $(distdir)/=inst && pwd`; \\'
2682 . (&target_defined ('distcheck-hook')
2683 ? ("\n\t\$(MAKE) \$(AM_MAKEFLAGS)"
2684 . " distcheck-hook; \\")
2687 cd $(distdir)/=build \\
2690 . ($seen_gettext ? '--with-included-gettext ' : '')
2691 . '--srcdir=.. --prefix=$$dc_install_base \\
2692 && $(MAKE) $(AM_MAKEFLAGS) \\
2693 && $(MAKE) $(AM_MAKEFLAGS) dvi \\
2694 && $(MAKE) $(AM_MAKEFLAGS) check \\
2695 && $(MAKE) $(AM_MAKEFLAGS) install \\
2696 && $(MAKE) $(AM_MAKEFLAGS) installcheck \\
2697 && $(MAKE) $(AM_MAKEFLAGS) dist
2699 @banner="$(distdir).tar.gz is ready for distribution"; \\
2700 dashes=`echo "$$banner" | sed s/./=/g`; \\
2706 local ($dist_all) = ('dist-all: distdir' . "\n"
2709 foreach $curs ('dist', 'dist-shar', 'dist-zip', 'dist-tarZ',
2712 if (defined $options{$curs} || $curs eq 'dist')
2714 $output_rules .= ($curs . ': distdir' . "\n"
2718 $dist_all .= $dist{$curs};
2721 $output_rules .= $dist_all . $dist_trailer;
2724 # Generate distdir target.
2725 &handle_dist_worker ($makefile);
2728 # Scan a single dependency file and rewrite the dependencies as
2729 # appropriate. Essentially this means:
2730 # * Clean out absolute dependencies which are not desirable.
2731 # * Rewrite other dependencies to be relative to $(top_srcdir).
2732 sub scan_dependency_file
2734 local ($depfile) = @_;
2736 if (! open (DEP_FILE, $depfile))
2738 &am_error ("couldn't open \`$depfile': $!");
2741 print "automake: reading $depfile\n" if $verbose;
2743 # Sometimes it is necessary to omit some dependencies.
2744 local (%omit) = %omit_dependencies;
2745 if (&variable_defined ('OMIT_DEPENDENCIES'))
2747 # FIXME: Doesn't work with conditionals. I'm not sure if this
2749 grep ($omit{$_} = 1,
2750 &variable_value_as_list ('OMIT_DEPENDENCIES', ''));
2753 local ($first_line) = 1;
2754 local ($last_line) = 0;
2755 local ($target, @dependencies);
2756 local ($one_dep, $xform);
2759 local ($srcdir_rx, $fixup_rx);
2760 ($fixup_rx = $srcdir_name . '/' . $relative_dir . '/')
2762 ($srcdir_rx = $srcdir_name . '/') =~ s/(\W)/\\$1/g;
2764 local ($rewrite_builddir) = (($top_builddir eq '.')
2766 : $top_builddir . '/');
2771 next if (/$WHITE_PATTERN/o);
2775 # No trailing "\" means this should be the last line of
2776 # the first target. We can have multiple targets due to
2777 # the "deleted header file" fix. For the generated
2778 # Makefile we simply skip these fake targets.
2784 if (! /^([^:]+:)(.+)$/)
2787 &am_error ("\`$depfile' has incorrect format");
2793 # Make sure to strip the .P file from the target.
2794 ($target = $1) =~ s, *\.deps/[^.]+\.P,,;
2799 foreach $one_dep (split (' ', $_))
2801 ($just_file = $one_dep) =~ s,^.*/,,;
2802 next if defined $omit{$just_file};
2804 if ($one_dep =~ /^$fixup_rx/)
2806 # The dependency points to the current directory in
2808 ($xform = $one_dep) =~ s/^$fixup_rx//;
2809 push (@dependencies, $xform);
2811 elsif ($one_dep =~ /^$srcdir_rx/)
2813 # The dependency is in some other directory in the package.
2814 ($xform = $one_dep) =~ s/^$srcdir_rx/$rewrite_builddir/;
2815 push (@dependencies, $xform);
2817 elsif ($one_dep =~ /^\// || $one_dep =~ /^[A-Za-z]:\\/)
2819 # Absolute path; ignore.
2823 # Anything else is assumed to be correct.
2824 push (@dependencies, $one_dep);
2829 &pretty_print_rule ($target, "\t", @dependencies);
2834 # Handle auto-dependency code.
2835 sub handle_dependencies
2837 # Make sure this variable is always marked as used.
2838 &examine_variable ('OMIT_DEPENDENCIES');
2840 if ($use_dependencies)
2842 # Include GNU-make-specific auto-dep code. Don't include it
2843 # if DEP_FILES would be empty.
2844 if (&saw_sources_p (0) && keys %dep_files)
2846 &define_pretty_variable ('DEP_FILES', '', sort keys %dep_files);
2847 $output_rules .= &file_contents ('depend');
2848 push (@clean, 'depend');
2849 &push_phony_cleaners ('depend');
2851 local ($key, $lang, $ext, $xform);
2852 foreach $key (sort keys %language_map)
2854 next unless $key =~ /^(.*)-autodep$/;
2855 next if $language_map{$key} eq 'no';
2858 $xform = 's/\@PFX\@/' . $language_map{$key} . '/g;';
2859 foreach $ext (&lang_extensions ($lang))
2862 &file_contents_with_transform ('s/\@EXT\@/'
2870 elsif ($build_directory ne '')
2872 # Include any auto-generated deps that are present. Note that
2873 # $build_directory ends in a "/".
2874 if (-d ($build_directory . $relative_dir . "/.deps"))
2878 foreach $depfile (&my_glob ($build_directory
2879 . $relative_dir . "/.deps/*.P"))
2881 &scan_dependency_file ($depfile);
2884 $output_rules .= "\n";
2889 # Handle subdirectories.
2892 return if ! &variable_defined ('SUBDIRS');
2894 # Make sure each directory mentioned in SUBDIRS actually exists.
2896 foreach $dir (&variable_value_as_list ('SUBDIRS', 'all'))
2898 # Skip directories substituted by configure.
2899 next if $dir =~ /^\@.*\@$/;
2901 if (! -d $am_relative_dir . '/' . $dir)
2903 &am_line_error ('SUBDIRS',
2904 "required directory $am_relative_dir/$dir does not exist");
2908 &am_line_error ('SUBDIRS', "directory should not contain \`/'")
2912 local ($xform) = ('s/\@INSTALLINFO\@/' .
2913 (defined $options{'no-installinfo'}
2914 ? 'install-info-recursive'
2917 $output_rules .= &file_contents_with_transform ($xform, 'subdirs');
2919 # Push a bunch of phony targets.
2921 foreach $phonies ('', '-data', '-exec', 'dirs')
2923 push (@phony, 'install' . $phonies . '-recursive');
2924 push (@phony, 'uninstall' . $phonies . '-recursive');
2926 foreach $phonies ('all', 'check', 'installcheck', 'info', 'dvi')
2928 push (@phony, $phonies . '-recursive');
2930 &push_phony_cleaners ('recursive');
2932 $recursive_install = 1;
2935 # Handle aclocal.m4.
2936 sub handle_aclocal_m4
2938 local ($regen_aclocal) = 0;
2939 if (-f 'aclocal.m4')
2941 &define_variable ("ACLOCAL_M4", '$(top_srcdir)/aclocal.m4');
2942 &push_dist_common ('aclocal.m4');
2944 if (open (ACLOCAL, '< aclocal.m4'))
2950 if ($line =~ 'generated automatically by aclocal')
2957 local ($acinclude) = 0;
2958 if (-f 'acinclude.m4')
2964 # Note that it might be possible that aclocal.m4 doesn't exist but
2965 # should be auto-generated. This case probably isn't very
2969 local (@ac_deps) = (
2971 ? "\@MAINTAINER_MODE_TRUE\@"
2974 ($acinclude ? ' acinclude.m4' : '')
2977 # Scan all -I directories for m4 files. These are our
2979 if (&variable_defined ('ACLOCAL_AMFLAGS'))
2981 local ($examine_next, $amdir) = 0;
2982 foreach $amdir (&variable_value_as_list ('ACLOCAL_AMFLAGS', ''))
2987 if ($amdir !~ /^\// && -d $amdir)
2989 push (@ac_deps, &my_glob ($amdir . '/*.m4'));
2992 elsif ($amdir eq '-I')
2999 &pretty_print_rule ("\$(ACLOCAL_M4):", "\t\t", @ac_deps);
3001 $output_rules .= ("\t"
3002 . 'cd $(srcdir) && $(ACLOCAL)'
3003 . (&variable_defined ('ACLOCAL_AMFLAGS')
3004 ? ' $(ACLOCAL_AMFLAGS)' : '')
3009 # Rewrite a list of input files into a form suitable to put on a
3010 # dependency list. The idea is that if an input file has a directory
3011 # part the same as the current directory, then the directory part is
3012 # simply removed. But if the directory part is different, then
3013 # $(top_srcdir) is prepended. Among other things, this is used to
3014 # generate the dependency list for the output files generated by
3015 # AC_OUTPUT. Consider what the dependencies should look like in this
3017 # AC_OUTPUT(src/out:src/in1:lib/in2)
3018 # The first argument, ADD_SRCDIR, is 1 if $(top_srcdir) should be added.
3019 # If 0 then files that require this addition will simply be ignored.
3020 sub rewrite_inputs_into_dependencies
3022 local ($add_srcdir, @inputs) = @_;
3023 local ($single, @newinputs);
3025 foreach $single (@inputs)
3027 if (&dirname ($single) eq $relative_dir)
3029 push (@newinputs, &basename ($single));
3033 push (@newinputs, '$(top_srcdir)/' . $single);
3040 # Handle remaking and configure stuff.
3041 # We need the name of the input file, to do proper remaking rules.
3042 sub handle_configure
3044 local ($local, $input, @secondary_inputs) = @_;
3046 # If SUBDIRS defined, require AC_PROG_MAKE_SET.
3047 &am_line_error ('SUBDIRS', "AC_PROG_MAKE_SET must be used in configure.in")
3048 if &variable_defined ('SUBDIRS') && ! $seen_make_set;
3050 local ($top_reldir);
3052 local ($input_base) = &basename ($input);
3053 local ($local_base) = &basename ($local);
3055 local ($amfile) = $input_base . '.am';
3056 # We know we can always add '.in' because it really should be an
3057 # error if the .in was missing originally.
3058 local ($infile) = '$(srcdir)/' . $input_base . '.in';
3059 local ($colon_infile);
3060 if ($local ne $input || @secondary_inputs)
3062 $colon_infile = ':' . $input . '.in';
3064 $colon_infile .= ':' . join (':', @secondary_inputs)
3065 if @secondary_inputs;
3067 local (@rewritten) = &rewrite_inputs_into_dependencies (1,
3070 # This rule remakes the Makefile.in. Note use of
3071 # @MAINTAINER_MODE_TRUE@ forces us to abandon pretty-printing.
3073 $output_rules .= ($infile
3074 # NOTE perl 5.003 (with -w) gives a
3075 # uninitialized value error on the next line.
3078 . ($seen_maint_mode ? "\@MAINTAINER_MODE_TRUE\@ " : '')
3080 . '$(top_srcdir)/configure.in $(ACLOCAL_M4)'
3081 . ' ' . join (' ', @include_stack)
3083 . "\tcd \$(top_srcdir) && \$(AUTOMAKE) "
3084 . ($cygnus_mode ? '--cygnus' : ('--' . $strictness_name))
3085 . ($cmdline_use_dependencies ? '' : ' --include-deps')
3086 . ' ' . $input . $colon_infile . "\n\n");
3088 # This rule remakes the Makefile.
3089 $output_rules .= ($local_base
3090 # NOTE: bogus uninit value error on next line;
3091 # see comment above.
3094 . join (' ', @rewritten)
3095 . ' $(top_builddir)/config.status'
3096 # NOTE: Makefile only depends on BUILT_SOURCES
3097 # when dependencies are being computed. This is
3098 # a workaround for an obscure bug with
3099 # AC_LINK_FILES. Anyway, when dependencies are
3100 # turned off, this shouldn't matter.
3101 . ($use_dependencies ? ' $(BUILT_SOURCES)' : '')
3103 . "\tcd \$(top_builddir) \\\n"
3104 . "\t && CONFIG_FILES="
3105 . (($relative_dir eq '.') ? '$@' : '$(subdir)/$@')
3107 . ' CONFIG_HEADERS= $(SHELL) ./config.status'
3110 if ($relative_dir ne '.')
3113 $top_reldir = '../';
3118 $output_rules .= &file_contents ('remake');
3119 &examine_variable ('CONFIG_STATUS_DEPENDENCIES');
3120 &examine_variable ('CONFIGURE_DEPENDENCIES');
3123 &push_dist_common ('acconfig.h')
3127 # Make it easy to see if there is a Makefile.am in a given
3129 local (%make_dirs, $iter);
3130 foreach $iter (@configure_input_files)
3132 $make_dirs{&dirname ($iter)} = 1;
3134 # We also want to notice Makefile.in's.
3135 foreach $iter (@other_input_files)
3137 if ($iter =~ /Makefile\.in$/)
3139 $make_dirs{&dirname ($iter)} = 1;
3143 # If we have a configure header, require it.
3145 local (@local_fullnames) = @config_fullnames;
3146 local (@local_names) = @config_names;
3147 local ($hdr_index) = 0;
3148 local ($distclean_config) = '';
3149 foreach $one_hdr (@config_headers)
3151 local ($one_fullname) = shift (@local_fullnames);
3152 local ($one_name) = shift (@local_names);
3154 local ($header_dir) = &dirname ($one_name);
3156 # If the header is in the current directory we want to build
3157 # the header here. Otherwise, if we're at the topmost
3158 # directory and the header's directory doesn't have a
3159 # Makefile, then we also want to build the header.
3160 if ($relative_dir eq $header_dir
3161 || ($relative_dir eq '.' && ! defined $make_dirs{$header_dir}))
3163 local ($ch_sans_dir, $cn_sans_dir, $stamp_dir);
3164 if ($relative_dir eq $header_dir)
3166 $cn_sans_dir = &basename ($one_name);
3171 $cn_sans_dir = $one_name;
3172 if ($header_dir eq '.')
3178 $stamp_dir = $header_dir . '/';
3182 # Compute relative path from directory holding output
3183 # header to directory holding input header. FIXME:
3184 # doesn't handle case where we have multiple inputs.
3185 if (&dirname ($one_hdr) eq $relative_dir)
3187 $ch_sans_dir = &basename ($one_hdr);
3191 local (@rel_out_path);
3192 # FIXME this chunk of code should be its own sub.
3193 # It is used elsewhere.
3194 foreach (split (/\//, $relative_dir))
3196 next if $_ eq '' || $_ eq '.';
3199 # FIXME: actually this is an error.
3204 push (@rel_out_path, '..');
3209 $ch_sans_dir = join ('/', @rel_out_path) . '/' . $one_hdr;
3213 $ch_sans_dir = $one_hdr;
3217 &require_file_with_conf_line ($config_header_line,
3218 $FOREIGN, $ch_sans_dir);
3220 # Header defined and in this directory.
3222 if (-f $one_name . '.top')
3224 push (@files, "${cn_sans_dir}.top");
3226 if (-f $one_name . '.bot')
3228 push (@files, "${cn_sans_dir}.bot");
3231 &push_dist_common (@files);
3233 # For now, acconfig.h can only appear in the top srcdir.
3234 if (-f 'acconfig.h')
3236 if ($relative_dir eq '.')
3238 push (@files, 'acconfig.h');
3242 # Strange quoting because this gets fed through
3244 push (@files, '\$(top_srcdir)/acconfig.h');
3248 local ($stamp_name) = 'stamp-h';
3249 $stamp_name .= "${hdr_index}" if scalar (@config_headers) > 1;
3251 local ($xform) = '';
3253 $xform = 's,\@FILES\@,' . join (' ', @files) . ',;';
3254 $xform .= 's,\@CONFIG_HEADER\@,' . "${cn_sans_dir}" . ',;';
3255 $xform .= 's,\@CONFIG_HEADER_IN\@,' . "${ch_sans_dir}" . ',;';
3256 $xform .= 's,\@CONFIG_HEADER_FULL\@,' . "${one_fullname}" . ',;';
3257 $xform .= 's,\@STAMP\@,' . "${stamp_dir}${stamp_name}" . ',g;';
3259 local ($out_dir) = &dirname ($ch_sans_dir);
3260 $xform .= 's,\@SRC_STAMP\@,' . "${out_dir}/${stamp_name}" . ',g;';
3261 $output_rules .= &file_contents_with_transform ($xform,
3264 &create ("${relative_dir}/${out_dir}/${stamp_name}.in");
3265 &require_file_with_conf_line ($config_header_line, $FOREIGN,
3266 "${out_dir}/${stamp_name}.in");
3268 $distclean_config .= ' ' if $distclean_config;
3269 $distclean_config .= $cn_sans_dir;
3273 if ($distclean_config)
3275 $output_rules .= &file_contents_with_transform ('s,\@FILES\@,'
3279 push (@clean, 'hdr');
3280 &push_phony_cleaners ('hdr');
3283 # Set location of mkinstalldirs.
3284 if ($config_aux_dir ne '.' && $config_aux_dir ne '')
3286 &define_variable ('mkinstalldirs', ('$(SHELL) ' . $config_aux_dir
3287 . '/mkinstalldirs'));
3291 &define_variable ('mkinstalldirs',
3292 '$(SHELL) $(top_srcdir)/mkinstalldirs');
3295 &am_line_error ('CONFIG_HEADER',
3296 "\`CONFIG_HEADER' is an anachronism; now determined from \`configure.in'")
3297 if &variable_defined ('CONFIG_HEADER');
3300 local ($config_header) = '';
3301 foreach $one_name (@config_names)
3303 # Generate CONFIG_HEADER define.
3305 if ($relative_dir eq &dirname ($one_name))
3307 $one_hdr = &basename ($one_name);
3311 $one_hdr = "${top_builddir}/${one_name}";
3314 $config_header .= ' ' if $config_header;
3315 $config_header .= $one_hdr;
3319 &define_variable ("CONFIG_HEADER", $config_header);
3322 # Now look for other files in this directory which must be remade
3323 # by config.status, and generate rules for them.
3324 local (@actual_other_files) = ();
3325 local ($file, $local);
3326 local (@inputs, @rewritten_inputs, $single);
3327 local ($need_rewritten);
3328 foreach $file (@other_input_files)
3330 if ($file =~ /^([^:]*):(.*)$/)
3332 # This is the ":" syntax of AC_OUTPUT.
3334 $local = &basename ($file);
3335 @inputs = split (':', $2);
3336 @rewritten_inputs = &rewrite_inputs_into_dependencies (1, @inputs);
3337 $need_rewritten = 1;
3342 $local = &basename ($file);
3343 @inputs = ($local . '.in');
3345 &rewrite_inputs_into_dependencies (1, $file . '.in');
3346 $need_rewritten = 0;
3349 # Skip files not in this directory.
3350 next unless &dirname ($file) eq $relative_dir;
3352 # Skip any file that is an automake input.
3353 next if -f $file . '.am';
3355 # Some users have been tempted to put `stamp-h' in the
3356 # AC_OUTPUT line. This won't do the right thing, so we
3357 # explicitly fail here.
3358 if ($local eq 'stamp-h')
3360 # FIXME: allow real filename.
3361 &am_conf_error ('configure.in', $ac_output_line,
3362 'stamp-h should not appear in AC_OUTPUT');
3366 $output_rules .= ($local . ': '
3367 . '$(top_builddir)/config.status '
3368 . join (' ', @rewritten_inputs) . "\n"
3370 . 'cd $(top_builddir) && CONFIG_FILES='
3371 . ($relative_dir eq '.' ? '' : '$(subdir)/')
3372 . '$@' . ($need_rewritten
3373 ? (':' . join (':', @inputs))
3375 . ' CONFIG_HEADERS= $(SHELL) ./config.status'
3377 &push_dist_common (@inputs);
3378 push (@actual_other_files, $local);
3380 # Require all input files.
3381 &require_file_with_conf_line ($ac_output_line, $FOREIGN,
3382 &rewrite_inputs_into_dependencies (0, @inputs));
3385 # These files get removed by "make clean".
3386 &define_pretty_variable ('CONFIG_CLEAN_FILES', '', @actual_other_files);
3393 @r = &am_install_var ('-defaultdist', 'header', 'HEADERS', 'include',
3394 'oldinclude', 'pkginclude',
3398 next unless /\.(.*)$/;
3399 &saw_extension ($1);
3405 return if ! $seen_gettext || $relative_dir ne '.';
3407 if (! &variable_defined ('SUBDIRS'))
3410 ("AM_GNU_GETTEXT in configure.in but SUBDIRS not defined");
3414 &require_file_with_conf_line ($ac_gettext_line, $GNU, 'ABOUT-NLS');
3416 if (&variable_defined ('SUBDIRS'))
3420 "AM_GNU_GETTEXT in configure.in but \`po' not in SUBDIRS")
3421 if $contents{'SUBDIRS'} !~ /\bpo\b/;
3424 "AM_GNU_GETTEXT in configure.in but \`intl' not in SUBDIRS")
3425 if $contents{'SUBDIRS'} !~ /\bintl\b/;
3428 # Ensure that each language in ALL_LINGUAS has a .po file, and
3429 # each po file is mentioned in ALL_LINGUAS.
3432 local (%linguas) = ();
3433 grep ($linguas{$_} = 1, split (' ', $all_linguas));
3440 &am_line_error ($all_linguas_line,
3441 ("po/$_.po exists but \`$_' not in \`ALL_LINGUAS'"))
3445 foreach (keys %linguas)
3447 &am_line_error ($all_linguas_line,
3448 "$_ in \`ALL_LINGUAS' but po/$_.po does not exist")
3454 &am_error ("AM_GNU_GETTEXT in configure.in but \`ALL_LINGUAS' not defined");
3458 # Handle footer elements.
3461 if ($contents{'SOURCES'})
3463 # NOTE don't use define_pretty_variable here, because
3464 # $contents{...} is already defined.
3465 $output_vars .= 'SOURCES = ' . $contents{'SOURCES'} . "\n";
3467 if ($contents{'OBJECTS'})
3469 # NOTE don't use define_pretty_variable here, because
3470 # $contents{...} is already defined.
3471 $output_vars .= 'OBJECTS = ' . $contents{'OBJECTS'} . "\n";
3473 if ($contents{'SOURCES'} || $contents{'OBJECTS'})
3475 $output_vars .= "\n";
3478 if (&variable_defined ('SUFFIXES'))
3480 # Push actual suffixes, and not $(SUFFIXES). Some versions of
3481 # make do not like variable substitutions on the .SUFFIXES
3483 push (@suffixes, &variable_value_as_list ('SUFFIXES', ''));
3485 if (&target_defined ('.SUFFIXES'))
3487 &am_line_error ('.SUFFIXES',
3488 "use variable \`SUFFIXES', not target \`.SUFFIXES'");
3491 # Note: AIX 4.1 /bin/make will fail if any suffix rule appears
3492 # before .SUFFIXES. So we make sure that .SUFFIXES appears before
3493 # anything else, by sticking it right after the default: target.
3494 $output_header .= ".SUFFIXES:\n";
3498 # Make sure suffixes has unique elements. Sort them to ensure
3499 # the output remains consistent.
3502 grep ($suffixes{$_} = 1, @suffixes);
3504 $output_header .= (".SUFFIXES: "
3505 . join (' ', sort keys %suffixes)
3508 $output_trailer .= &file_contents ('footer');
3511 # Deal with installdirs target.
3512 sub handle_installdirs
3514 # GNU Makefile standards recommend this.
3515 if ($recursive_install)
3517 # We create a separate `-am' target so that the -recursive
3518 # rule will work correctly.
3519 $output_rules .= ("installdirs: installdirs-recursive\n"
3520 . "installdirs-am:\n");
3521 push (@phony, 'installdirs-am');
3525 $output_rules .= "installdirs:\n";
3527 push (@phony, 'installdirs');
3530 &pretty_print_rule ("\t" . '$(mkinstalldirs) ', "\t\t",
3533 $output_rules .= "\n";
3536 # There are several targets which need to be merged. This is because
3537 # their complete definition is compiled from many parts. Note that we
3538 # avoid double colon rules, otherwise we'd use them instead.
3539 sub handle_merge_targets
3541 local ($makefile) = @_;
3543 # There are a few install-related variables that you should not define.
3545 foreach $var ('PRE_INSTALL', 'POST_INSTALL', 'NORMAL_INSTALL')
3547 if (&variable_defined ($var))
3549 &am_line_error ($var, "\`$var' should not be defined");
3553 # Put this at the beginning for the sake of non-GNU makes. This
3554 # is still wrong if these makes can run parallel jobs. But it is
3556 unshift (@all, &basename ($makefile));
3559 foreach $one_name (@config_names)
3561 push (@all, &basename ($one_name))
3562 if &dirname ($one_name) eq $relative_dir;
3565 &do_one_merge_target ('info', @info);
3566 &do_one_merge_target ('dvi', @dvi);
3567 &do_check_merge_target;
3568 &do_one_merge_target ('installcheck', @installcheck);
3570 if (defined $options{'no-installinfo'})
3572 &do_one_merge_target ('install-info', '');
3574 elsif (&target_defined ('install-info-local'))
3576 &am_line_error ('install-info-local',
3577 "\`install-info-local' target defined but \`no-installinfo' option not in use");
3581 foreach $utarg ('uninstall-data-local', 'uninstall-data-hook',
3582 'uninstall-exec-local', 'uninstall-exec-hook')
3584 if (&target_defined ($utarg))
3587 ($x = $utarg) =~ s/(data|exec)-//;
3588 &am_line_error ($utarg, "use \`$x', not \`$utarg'");
3592 if (&target_defined ('install-local'))
3594 &am_line_error ('install-local',
3595 "use \`install-data-local' or \`install-exec-local', not \`install-local'");
3601 local ($local_headers) = '';
3602 foreach $one_name (@config_names)
3604 if (&dirname ($one_name) eq $relative_dir)
3606 $local_headers .= ' ' if $local_headers;
3607 $local_headers .= &basename ($one_name);
3612 # This is kind of a hack, but I couldn't see a better way
3613 # to handle it. In this particular case, we need to make
3614 # sure config.h is built before we recurse. We can't do
3615 # this by changing the order of dependencies to the "all"
3616 # because that breaks when using parallel makes. Instead
3617 # we handle things explicitly.
3618 $output_rules .= ("all-recursive-am: ${local_headers}"
3620 . '$(MAKE) $(AM_MAKEFLAGS)'
3623 $all_target = 'all-recursive-am';
3624 push (@phony, 'all-recursive-am');
3628 # Print definitions users can use.
3629 &do_one_merge_target ('install-exec', @install_exec);
3630 $output_rules .= "\n";
3632 &do_one_merge_target ('install-data', @install_data);
3633 $output_rules .= "\n";
3635 &do_one_merge_target ('install', 'all-am');
3636 &do_one_merge_target ('uninstall', @uninstall);
3638 &do_one_merge_target ('all', @all);
3640 # Generate the new 'install-strip' target. We can't just set
3641 # INSTALL_PROGRAM because that might be a relative path.
3642 $output_rules .= ("install-strip:\n\t"
3643 . '$(MAKE) $(AM_MAKEFLAGS) INSTALL_STRIP_FLAG=-s install'
3645 push (@phony, 'install-strip');
3648 # Helper for handle_merge_targets. Note that handle_merge_targets
3649 # relies on the fact that this doesn't add an extra \n at the end.
3650 sub do_one_merge_target
3652 local ($name, @values) = @_;
3654 if (&target_defined ($name . '-local'))
3656 # User defined local form of target. So include it.
3657 push (@values, $name . '-local');
3658 push (@phony, $name . '-local');
3661 &pretty_print_rule ($name . "-am:", "\t\t", @values);
3662 if ($name eq 'install')
3664 # Special-case `install-am' to run install-exec-am and
3665 # install-data-am after all-am is built.
3666 &pretty_print_rule ("\t\@\$(MAKE) \$(AM_MAKEFLAGS)", "\t ",
3667 'install-exec-am', 'install-data-am');
3669 elsif ($name eq 'install-exec' && &target_defined ('install-exec-hook'))
3671 $output_rules .= ("\t\@\$(NORMAL_INSTALL)\n"
3672 . "\t" . '$(MAKE) $(AM_MAKEFLAGS) install-exec-hook'
3675 elsif ($name eq 'install-data' && &target_defined ('install-data-hook'))
3677 $output_rules .= ("\t\@\$(NORMAL_INSTALL)\n"
3678 . "\t" . '$(MAKE) $(AM_MAKEFLAGS) install-data-hook'
3682 local ($lname) = $name . ($recursive_install ? '-recursive' : '-am');
3683 local ($tname) = $name;
3684 # To understand this special case, see handle_merge_targets.
3687 $tname = 'all-redirect';
3688 $lname = $all_target if $recursive_install;
3689 push (@phony, 'all-redirect');
3690 $output_all = "all: all-redirect\n";
3692 &pretty_print_rule ($tname . ":", "\t\t", $lname);
3693 push (@phony, $name . '-am', $name);
3696 # Handle check merge target specially.
3697 sub do_check_merge_target
3699 if (&target_defined ('check-local'))
3701 # User defined local form of target. So include it.
3702 push (@check_tests, 'check-local');
3703 push (@phony, 'check-local');
3706 # In --cygnus mode, check doesn't depend on all.
3709 # Just run the local check rules.
3710 &pretty_print_rule ('check-am:', "\t\t", @check);
3714 # The check target must depend on the local equivalent of
3715 # `all', to ensure all the primary targets are built. Then it
3716 # must build the local check rules.
3717 $output_rules .= "check-am: all-am\n";
3718 &pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ",
3722 &pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ",
3726 push (@phony, 'check', 'check-am');
3727 $output_rules .= ("check: "
3728 . ($recursive_install ? 'check-recursive' : 'check-am')
3732 # Handle all 'clean' targets.
3735 local ($xform) = '';
3738 # Don't include `MAINTAINER'; it is handled specially below.
3739 foreach $name ('MOSTLY', '', 'DIST')
3741 if (! &variable_defined ($name . 'CLEANFILES'))
3743 $xform .= 's/^' . $name . 'CLEAN.*$//;';
3747 $xform .= 's/^' . $name . 'CLEAN//;';
3751 # Built sources are automatically removed by maintainer-clean.
3752 push (@maintainer_clean_files, '\$(BUILT_SOURCES)')
3753 if &variable_defined ('BUILT_SOURCES');
3754 push (@maintainer_clean_files, '\$(MAINTAINERCLEANFILES)')
3755 if &variable_defined ('MAINTAINERCLEANFILES');
3756 if (! @maintainer_clean_files)
3758 $xform .= 's/^MAINTAINERCLEAN.*$//;';
3762 $xform .= ('s/^MAINTAINERCLEAN//;'
3763 # Join with no space to avoid spurious `test -z'
3764 # success at runtime.
3765 . 's,\@MCFILES\@,' . join ('', @maintainer_clean_files)
3767 # A space is required in the join here.
3768 . 's,\@MFILES\@,' . join (' ', @maintainer_clean_files)
3772 $output_rules .= &file_contents_with_transform ($xform, 'clean');
3774 push (@clean, 'generic');
3775 &push_phony_cleaners ('generic');
3777 &do_one_clean_target ('clean', 'mostly', '', @clean);
3778 &do_one_clean_target ('clean', '', 'mostly', @clean);
3779 &do_one_clean_target ('clean', 'dist', '', @clean);
3780 &do_one_clean_target ('clean', 'maintainer-', 'dist', @clean);
3782 push (@phony, 'clean', 'mostlyclean', 'distclean', 'maintainer-clean');
3785 # Helper for handle_clean.
3786 sub do_one_clean_target
3788 local ($target, $name, $last_name, @deps) = @_;
3790 # Change each dependency `BLARG' into `clean-BLARG'.
3791 grep (($_ = $name . 'clean-' . $_) && 0, @deps);
3793 # Push the previous clean target. There is no previous clean
3794 # target if we're doing mostlyclean.
3795 push (@deps, $last_name . $target . '-am')
3796 unless $name eq 'mostly';
3798 # If a -local version of the rule is given, add it to the list.
3799 if (&target_defined ($name . $target . '-local'))
3801 push (@deps, $name . $target . '-local');
3804 # Print the target and the dependencies.
3805 &pretty_print_rule ($name . $target . "-am: ", "\t\t", @deps);
3807 # FIXME: shouldn't we really print these messages before running
3809 if ($name . $target eq 'maintainer-clean')
3811 # Print a special warning.
3813 ("\t\@echo \"This command is intended for maintainers to use;\"\n"
3814 . "\t\@echo \"it deletes files that may require special "
3815 . "tools to rebuild.\"\n");
3817 elsif ($name . $target eq 'distclean')
3819 $output_rules .= "\t-rm -f libtool\n" if $seen_libtool;
3821 $output_rules .= "\n";
3823 # Now generate the actual clean target.
3824 $output_rules .= ($name . $target . ": " . $name . $target
3825 . ($recursive_install ? '-recursive' : '-am')
3828 # We special-case config.status here. If we do it as part of the
3829 # normal clean processing for this directory, then it might be
3830 # removed before some subdir is cleaned. However, that subdir's
3831 # Makefile depends on config.status.
3832 if (($name . $target eq 'maintainer-clean'
3833 || $name . $target eq 'distclean')
3834 && $relative_dir eq '.')
3836 $output_rules .= "\t-rm -f config.status\n";
3838 $output_rules .= "\n";
3841 # Handle .PHONY target.
3844 &pretty_print_rule ('.PHONY:', "", @phony);
3845 $output_rules .= "\n";
3848 # Handle TESTS variable and other checks.
3851 if (defined $options{'dejagnu'})
3853 push (@check_tests, 'check-DEJAGNU');
3854 push (@phony, 'check-DEJAGNU');
3859 $xform = 's/^CYGNUS//;';
3863 $xform = 's/^CYGNUS.*$//;';
3865 $output_rules .= &file_contents_with_transform ($xform, 'dejagnu');
3867 # In Cygnus mode, these are found in the build tree.
3868 # Otherwise they are looked for in $PATH.
3869 &define_program_variable ('EXPECT', 'build', 'expect', 'expect');
3870 &define_program_variable ('RUNTEST', 'src', 'dejagnu', 'runtest');
3872 # Only create site.exp rule if user hasn't already written
3874 if (! &target_defined ('site.exp'))
3876 # Note that in the rule we don't directly generate
3877 # site.exp to avoid the possibility of a corrupted
3878 # site.exp if make is interrupted. Jim Meyering has some
3879 # useful text on this topic.
3880 $output_rules .= ("site.exp: Makefile\n"
3881 . "\t\@echo 'Making a new site.exp file...'\n"
3882 . "\t\@test ! -f site.bak || rm -f site.bak\n"
3883 . "\t\@echo '## these variables are automatically generated by make ##' > \$\@-t\n"
3884 . "\t\@echo '# Do not edit here. If you wish to override these values' >> \$\@-t\n"
3885 . "\t\@echo '# edit the last section' >> \$\@-t\n"
3886 . "\t\@echo 'set tool \$(DEJATOOL)' >> \$\@-t\n"
3887 . "\t\@echo 'set srcdir \$(srcdir)' >> \$\@-t\n"
3888 . "\t\@echo 'set objdir' \`pwd\` >> \$\@-t\n");
3890 # Extra stuff for AC_CANONICAL_*
3891 local (@whatlist) = ();
3892 if ($seen_canonical)
3894 push (@whatlist, 'host');
3897 # Extra stuff only for AC_CANONICAL_SYSTEM.
3898 if ($seen_canonical == $AC_CANONICAL_SYSTEM)
3900 push (@whatlist, 'target', 'build');
3904 foreach $c1 (@whatlist)
3906 foreach $c2 ('alias', 'triplet')
3908 $output_rules .= "\t\@echo 'set ${c1}_${c2} \$(${c1}_${c2})' >> \$\@-t\n";
3912 $output_rules .= ("\t\@echo '## All variables above are generated by configure. Do Not Edit ##' >> \$\@-t\n"
3913 . "\t\@test ! -f site.exp || sed '1,/^## All variables above are.*##/ d' site.exp >> \$\@-t\n"
3914 . "\t\@test ! -f site.exp || mv site.exp site.bak\n"
3915 . "\t\@mv \$\@-t site.exp\n");
3921 foreach $c ('DEJATOOL', 'RUNTEST', 'RUNTESTFLAGS')
3923 if (&variable_defined ($c))
3925 &am_line_error ($c, "\`$c' defined but \`dejagnu' not in \`AUTOMAKE_OPTIONS'");
3930 if (&variable_defined ('TESTS'))
3932 push (@check_tests, 'check-TESTS');
3933 push (@phony, 'check-TESTS');
3935 # Note: Solaris 2.7 seems to expand TESTS using VPATH. That's
3936 # why we also try `dir='
3937 $output_rules .= 'check-TESTS: $(TESTS)
3938 @failed=0; all=0; xfail=0; xpass=0; \\
3939 srcdir=$(srcdir); export srcdir; \\
3940 for tst in $(TESTS); do \\
3941 if test -f ./$$tst; then dir=./; \\
3942 elif test -f $$tst; then dir=; \\
3943 else dir="$(srcdir)/"; fi; \\
3944 if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \\
3945 all=`expr $$all + 1`; \\
3946 case " $(XFAIL_TESTS) " in \\
3948 xpass=`expr $$xpass + 1`; \\
3949 failed=`expr $$failed + 1`; \\
3950 echo "XPASS: $$tst"; \\
3953 echo "PASS: $$tst"; \\
3956 elif test $$? -ne 77; then \\
3957 all=`expr $$all + 1`; \\
3958 case " $(XFAIL_TESTS) " in \\
3960 xfail=`expr $$xfail + 1`; \\
3961 echo "XFAIL: $$tst"; \\
3964 failed=`expr $$failed + 1`; \\
3965 echo "FAIL: $$tst"; \\
3970 if test "$$failed" -eq 0; then \\
3971 if test "$$xfail" -eq 0; then \\
3972 banner="All $$all tests passed"; \\
3974 banner="All $$all tests behaved as expected ($$xfail expected failures)"; \\
3977 if test "$$xpass" -eq 0; then \\
3978 banner="$$failed of $$all tests failed"; \\
3980 banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \\
3983 dashes=`echo "$$banner" | sed s/./=/g`; \\
3987 test "$$failed" -eq 0
3992 # Handle Emacs Lisp.
3993 sub handle_emacs_lisp
3995 local (@elfiles) = &am_install_var ('-candist', 'lisp', 'LISP',
4001 &define_configure_variable ('lispdir');
4002 &define_configure_variable ('EMACS');
4003 $output_rules .= (".el.elc:\n"
4004 . "\t\@echo 'WARNING: Warnings can be ignored. :-)'\n"
4005 . "\tif test \$(EMACS) != no; then \\\n"
4006 . "\t EMACS=\$(EMACS) \$(SHELL) \$(srcdir)/elisp-comp \$<; \\\n"
4008 push (@suffixes, '.el', '.elc');
4010 # Generate .elc files.
4011 grep ($_ .= 'c', @elfiles);
4012 &define_pretty_variable ('ELCFILES', '', @elfiles);
4014 $output_rules .= &file_contents ('lisp-clean');
4015 push (@clean, 'lisp');
4016 &push_phony_cleaners ('lisp');
4018 push (@all, '$(ELCFILES)');
4021 if (&variable_defined ('lisp_LISP'))
4023 $varname = 'lisp_LISP';
4024 &am_error ("\`lisp_LISP' defined but \`AM_PATH_LISPDIR' not in \`configure.in'")
4029 $varname = 'noinst_LISP';
4032 &require_file_with_line ($varname, $FOREIGN, 'elisp-comp');
4039 local (@sourcelist) = &am_install_var ('-candist', '-clean',
4041 'java', 'noinst', 'check');
4042 return if ! @sourcelist;
4044 &define_variable ('JAVAC', 'javac');
4045 &define_variable ('JAVACFLAGS', '');
4046 &define_variable ('CLASSPATH_ENV',
4047 'CLASSPATH=$(JAVAROOT):$(srcdir)/$(JAVAROOT):$$CLASSPATH');
4048 &define_variable ('JAVAROOT', '$(top_builddir)');
4050 local (%valid) = &am_primary_prefixes ('JAVA', 1,
4051 'java', 'noinst', 'check');
4053 local ($dir, $curs);
4054 foreach $curs (keys %valid)
4056 if (! &variable_defined ($curs . '_JAVA') || $curs eq 'noinst'
4057 || $curs eq 'EXTRA')
4064 &am_line_error ($curs . '_JAVA',
4065 "multiple _JAVA primaries in use");
4070 $output_rules .= ('class' . $dir . '.stamp: $(' . $dir . '_JAVA)' . "\n"
4071 . "\t" . '$(CLASSPATH_ENV) $(JAVAC) -d $(JAVAROOT) '
4072 . '$(JAVACFLAGS) $?' . "\n"
4073 . "\t" . 'echo timestamp > class' . $dir . '.stamp'
4075 push (@all, 'class' . $dir . '.stamp');
4076 &push_dist_common ('$(' . $dir . '_JAVA)');
4079 # Handle some of the minor options.
4080 sub handle_minor_options
4082 if (defined $options{'readme-alpha'})
4084 if ($relative_dir eq '.')
4086 if ($package_version !~ /^$GNITS_VERSION_PATTERN$/)
4088 # FIXME: allow real filename.
4089 &am_conf_line_error ('configure.in',
4090 $package_version_line,
4091 "version \`$package_version' doesn't follow Gnits standards");
4093 elsif (defined $1 && -f 'README-alpha')
4095 # This means we have an alpha release. See
4096 # GNITS_VERSION_PATTERN for details.
4097 &require_file ($FOREIGN, 'README-alpha');
4103 ################################################################
4105 # Scan one file for interesting things. Subroutine of scan_configure.
4106 sub scan_one_configure_file
4108 local ($filename) = @_;
4111 open (CONFIGURE, $filename)
4112 || die "automake: couldn't open \`$filename': $!\n";
4113 print "automake: reading $filename\n" if $verbose;
4117 # Remove comments from current line.
4121 # Skip macro definitions. Otherwise we might be confused into
4122 # thinking that a macro that was only defined was actually
4126 # Follow includes. This is a weirdness commonly in use at
4127 # Cygnus and hopefully nowhere else.
4128 if (/sinclude\((.*)\)/ && -f $1)
4130 &scan_one_configure_file ($1);
4133 # Populate libobjs array.
4134 if (/AC_FUNC_ALLOCA/)
4136 $libsources{'alloca.c'} = 1;
4138 elsif (/AC_FUNC_GETLOADAVG/)
4140 $libsources{'getloadavg.c'} = 1;
4142 elsif (/AC_FUNC_MEMCMP/)
4144 $libsources{'memcmp.c'} = 1;
4146 elsif (/AC_STRUCT_ST_BLOCKS/)
4148 $libsources{'fileblocks.c'} = 1;
4150 elsif (/A[CM]_REPLACE_GNU_GETOPT/)
4152 $libsources{'getopt.c'} = 1;
4153 $libsources{'getopt1.c'} = 1;
4155 elsif (/AM_FUNC_STRTOD/)
4157 $libsources{'strtod.c'} = 1;
4159 elsif (/AM_WITH_REGEX/)
4161 $libsources{'rx.c'} = 1;
4162 $libsources{'rx.h'} = 1;
4163 $libsources{'regex.c'} = 1;
4164 $libsources{'regex.h'} = 1;
4165 $omit_dependencies{'rx.h'} = 1;
4166 $omit_dependencies{'regex.h'} = 1;
4168 elsif (/AM_FUNC_MKTIME/)
4170 $libsources{'mktime.c'} = 1;
4172 elsif (/AM_FUNC_ERROR_AT_LINE/)
4174 $libsources{'error.c'} = 1;
4175 $libsources{'error.h'} = 1;
4177 elsif (/AM_FUNC_OBSTACK/)
4179 $libsources{'obstack.c'} = 1;
4180 $libsources{'obstack.h'} = 1;
4182 elsif (/LIBOBJS="(.*)\s+\$LIBOBJS"/
4183 || /LIBOBJS="\$LIBOBJS\s+(.*)"/)
4185 foreach $libobj_iter (split (' ', $1))
4187 if ($libobj_iter =~ /^(.*)\.o(bj)?$/
4188 || $libobj_iter =~ /^(.*)\.\$ac_objext$/
4189 || $libobj_iter =~ /^(.*)\.\$\{ac_objext\}$/)
4191 $libsources{$1 . '.c'} = 1;
4196 if (! $in_ac_replace && s/AC_REPLACE_FUNCS\s*\(\[?//)
4202 $in_ac_replace = 0 if s/[\]\)].*$//;
4203 # Remove trailing backslash.
4207 # Need to skip empty elements for Perl 4.
4209 $libsources{$_ . '.c'} = 1;
4213 if (/$obsolete_rx/o)
4216 if ($obsolete_macros{$1} ne '')
4218 $hint = '; ' . $obsolete_macros{$1};
4220 &am_conf_line_error ($filename, $., "\`$1' is obsolete$hint");
4223 # Process the AC_OUTPUT macro.
4224 if (! $in_ac_output && s/AC_OUTPUT\s*\(\[?//)
4227 $ac_output_line = $.;
4231 local ($closing) = 0;
4238 # Look at potential Makefile.am's.
4241 # Must skip empty string for Perl 4.
4242 next if $_ eq "\\" || $_ eq '';
4244 # Handle $local:$input syntax. Note that we ignore
4245 # every input file past the first, though we keep
4246 # those around for later.
4247 local ($local, $input, @rest) = split (/:/);
4254 # FIXME: should be error if .in is missing.
4255 $input =~ s/\.in$//;
4258 if (-f $input . '.am')
4260 # We have a file that automake should generate.
4261 push (@make_input_list, $input);
4262 $make_list{$input} = join (':', ($local, @rest));
4266 # We have a file that automake should cause to be
4267 # rebuilt, but shouldn't generate itself.
4268 push (@other_input_files, $_);
4272 if ($closing && @make_input_list == 0 && @other_input_files == 0)
4274 &am_conf_line_error ($filename, $ac_output_line,
4275 "No files mentioned in \`AC_OUTPUT'");
4280 if (/$AC_CONFIG_AUX_DIR_PATTERN/o)
4282 @config_aux_path = $1;
4285 # Check for ansi2knr.
4286 $am_c_prototypes = 1 if /AM_C_PROTOTYPES/;
4288 # Check for exe extension stuff.
4292 $configure_vars{'EXEEXT'} = $filename . ':' . $.;
4298 $configure_vars{'OBJEXT'} = $filename . ':' . $.;
4301 # Check for `-c -o' code.
4302 $seen_cc_c_o = 1 if /AM_PROG_CC_C_O/;
4304 # Check for NLS support.
4305 if (/AM_GNU_GETTEXT/)
4308 $ac_gettext_line = $.;
4309 $omit_dependencies{'libintl.h'} = 1;
4312 # Look for ALL_LINGUAS.
4313 if (/ALL_LINGUAS="(.*)"$/ || /ALL_LINGUAS=(.*)$/)
4317 $all_linguas_line = $.;
4320 # Handle configuration headers. A config header of `[$1]'
4321 # means we are actually scanning AM_CONFIG_HEADER from
4323 if (/A([CM])_CONFIG_HEADER\s*\((.*)\)/
4327 ($filename, $., "\`automake requires \`AM_CONFIG_HEADER', not \`AC_CONFIG_HEADER'")
4330 $config_header_line = $.;
4332 foreach $one_hdr (split (' ', $2))
4334 push (@config_fullnames, $one_hdr);
4335 if ($one_hdr =~ /^([^:]+):(.+)$/)
4337 push (@config_names, $1);
4338 push (@config_headers, $2);
4342 push (@config_names, $one_hdr);
4343 push (@config_headers, $one_hdr . '.in');
4348 # Handle AC_CANONICAL_*. Always allow upgrading to
4349 # AC_CANONICAL_SYSTEM, but never downgrading.
4350 $seen_canonical = $AC_CANONICAL_HOST
4351 if ! $seen_canonical
4352 && (/AC_CANONICAL_HOST/ || /AC_CHECK_TOOL/);
4353 $seen_canonical = $AC_CANONICAL_SYSTEM if /AC_CANONICAL_SYSTEM/;
4355 $seen_path_xtra = 1 if /AC_PATH_XTRA/;
4357 # This macro handles several different things.
4358 if (/$AM_INIT_AUTOMAKE_PATTERN/o)
4364 $seen_prog_install = 1;
4365 ($package_version = $1) =~ s/$AM_PACKAGE_VERSION_PATTERN/$1/o;
4366 $package_version_line = $.;
4369 # This is like AM_INIT_AUTOMAKE, but doesn't actually set the
4370 # package and version number. (This might change in the
4371 # future). Yes, I'm not above hacking Automake so it works
4372 # well with other GNU tools -- that is actually the point.
4373 if (/AM_INIT_GUILE_MODULE/)
4379 $seen_prog_install = 1;
4380 @config_aux_path = ('..');
4383 # Some things required by Automake.
4384 $seen_make_set = 1 if /AC_PROG_MAKE_SET/;
4385 $seen_arg_prog = 1 if /AC_ARG_PROGRAM/;
4389 $configure_vars{'LEX'} = $filename . ':' . $.;
4390 $seen_decl_yytext = 1;
4392 if (/AC_DECL_YYTEXT/ && $filename =~ /configure\.in$/)
4394 &am_conf_line_warning ($filename, $., "\`AC_DECL_YYTEXT' is covered by \`AM_PROG_LEX'");
4396 if (/AC_PROG_LEX/ && $filename =~ /configure\.in$/)
4398 &am_conf_line_warning ($filename, $., "automake requires \`AM_PROG_LEX', not \`AC_PROG_LEX'");
4401 if (/AC_PROG_(F77|YACC|RANLIB|CC|CXXCPP|CXX|LEX|AWK|CPP|LN_S)/)
4403 $configure_vars{$1} = $filename . ':' . $.;
4405 if (/$AC_CHECK_PATTERN/o)
4407 $configure_vars{$3} = $filename . ':' . $.;
4409 if (/$AM_MISSING_PATTERN/o
4413 && $1 ne 'AUTOHEADER')
4415 $configure_vars{$1} = $filename . ':' . $.;
4418 # Explicitly avoid ANSI2KNR -- we AC_SUBST that in protos.m4,
4419 # but later define it elsewhere. This is pretty hacky. We
4420 # also explicitly avoid INSTALL_SCRIPT and some other
4421 # variables because they are defined in header-vars.am.
4423 if (/$AC_SUBST_PATTERN/o
4425 && $1 ne 'INSTALL_SCRIPT'
4426 && $1 ne 'INSTALL_DATA')
4428 $configure_vars{$1} = $filename . ':' . $.;
4431 $seen_decl_yytext = 1 if /AC_DECL_YYTEXT/;
4432 if (/AM_MAINTAINER_MODE/)
4434 $seen_maint_mode = 1;
4435 $configure_cond{'MAINTAINER_MODE'} = 1;
4437 $seen_package = 1 if /PACKAGE=/;
4439 # Skip VERSION of [$2]; that is from AM_INIT_AUTOMAKE.
4440 if (/\bVERSION=(\S+)/ && $1 ne '[$2]')
4443 $package_version = $1;
4444 $package_version_line = $.;
4451 $seen_prog_install = 1 if /AC_PROG_INSTALL/;
4452 $seen_lispdir = 1 if /AM_PATH_LISPDIR/;
4454 if (/A(C|M)_PROG_LIBTOOL/)
4456 if (/AM_PROG_LIBTOOL/)
4458 &am_conf_line_warning ($filename, $., "\`AM_PROG_LIBTOOL' is obsolete, use \`AC_PROG_LIBTOOL' instead");
4462 $configure_vars{'LIBTOOL'} = $filename . ':' . $.;
4463 $configure_vars{'RANLIB'} = $filename . ':' . $.;
4464 $configure_vars{'CC'} = $filename . ':' . $.;
4465 # AC_PROG_LIBTOOL runs AC_CANONICAL_HOST. Make sure we
4466 # never downgrade (if we've seen AC_CANONICAL_SYSTEM).
4467 $seen_canonical = $AC_CANONICAL_HOST if ! $seen_canonical;
4470 $seen_multilib = 1 if (/AM_ENABLE_MULTILIB/);
4472 if (/$AM_CONDITIONAL_PATTERN/o)
4474 $configure_cond{$1} = 1;
4477 # Check for Fortran 77 intrinsic and run-time libraries.
4478 if (/AC_F77_LIBRARY_LDFLAGS/)
4480 $configure_vars{'FLIBS'} = $filename . ':' . $.;
4487 # Scan configure.in and aclocal.m4 for interesting things. We must
4488 # scan aclocal.m4 because there might be AC_SUBSTs and such there.
4491 # Reinitialize libsources here. This isn't really necessary,
4492 # since we currently assume there is only one configure.in. But
4493 # that won't always be the case.
4496 local ($in_ac_output, $in_ac_replace) = (0, 0);
4497 local (%make_list, @make_input_list);
4498 local ($libobj_iter);
4500 &scan_one_configure_file ('configure.in');
4501 &scan_one_configure_file ('aclocal.m4')
4504 # Set input and output files if not specified by user.
4507 @input_files = @make_input_list;
4508 %output_files = %make_list;
4511 @configure_input_files = @make_input_list;
4513 &am_conf_error ("\`PACKAGE' not defined in configure.in")
4515 &am_conf_error ("\`VERSION' not defined in configure.in")
4518 # Look for some files we need. Always check for these. This
4519 # check must be done for every run, even those where we are only
4520 # looking at a subdir Makefile. We must set relative_dir so that
4521 # the file-finding machinery works.
4522 local ($relative_dir) = '.';
4523 &require_config_file ($FOREIGN, 'install-sh', 'mkinstalldirs', 'missing');
4524 &am_error ("\`install.sh' is an anachronism; use \`install-sh' instead")
4525 if -f $config_aux_path[0] . '/install.sh';
4528 ################################################################
4530 # Set up for Cygnus mode.
4533 return unless $cygnus_mode;
4535 &set_strictness ('foreign');
4536 $options{'no-installinfo'} = 1;
4537 $options{'no-dependencies'} = 1;
4538 $use_dependencies = 0;
4540 if (! $seen_maint_mode)
4542 &am_conf_error ("\`AM_MAINTAINER_MODE' required when --cygnus specified");
4547 &am_conf_error ("\`AC_EXEEXT' required when --cygnus specified");
4551 # Do any extra checking for GNU standards.
4552 sub check_gnu_standards
4554 if ($relative_dir eq '.')
4556 # In top level (or only) directory.
4557 &require_file ($GNU, 'INSTALL', 'NEWS', 'README', 'COPYING',
4558 'AUTHORS', 'ChangeLog');
4561 if ($strictness >= $GNU)
4563 if (defined $options{'no-installman'})
4565 &am_line_error ('AUTOMAKE_OPTIONS',
4566 "option \`no-installman' disallowed by GNU standards");
4569 if (defined $options{'no-installinfo'})
4571 &am_line_error ('AUTOMAKE_OPTIONS',
4572 "option \`no-installinfo' disallowed by GNU standards");
4577 # Do any extra checking for GNITS standards.
4578 sub check_gnits_standards
4580 if ($strictness >= $GNITS)
4582 if (-f $relative_dir . '/COPYING.LIB')
4584 &am_error ("\`${relative_dir}/COPYING.LIB' disallowed by Gnits standards");
4588 if ($relative_dir eq '.')
4590 # In top level (or only) directory.
4591 &require_file ($GNITS, 'THANKS');
4595 ################################################################
4597 # Functions to handle files of each language.
4599 # Each `lang_X_rewrite' function follows a simple formula:
4600 # * Args are the directory, base name and extension of the file.
4601 # * Return value is 1 if file is to be dealt with, 0 otherwise.
4602 # Much of the actual processing is handled in handle_single_transform_list.
4603 # These functions exist so that auxiliary information can be recorded
4604 # for a later cleanup pass. Note that the calls to these functions
4605 # are computed, so don't bother searching for their precise names
4608 # This is just a convenience function that can be used to determine
4609 # when a subdir object should be used.
4612 return defined $options{'subdir-objects'} ? $LANG_SUBDIR : $LANG_PROCESS;
4615 # Rewrite a single C source file.
4618 local ($directory, $base, $ext) = @_;
4620 if (defined $options{'ansi2knr'} && $base =~ /_$/)
4622 # FIXME: include line number in error.
4623 &am_error ("C source file \`$base.c' would be deleted by ansi2knr rules");
4626 local ($r) = $LANG_PROCESS;
4627 if (defined $options{'subdir-objects'})
4630 $base = $directory . '/' . $base;
4634 # Only give error once.
4636 # FIXME: line number.
4637 &am_error ("C objects in subdir but \`AM_PROG_CC_C_O' not in \`configure.in'");
4640 &require_file ($FOREIGN, 'compile')
4641 if $relative_dir eq '.';
4644 $de_ansi_files{$base} = 1;
4648 # Rewrite a single C++ source file.
4649 sub lang_cxx_rewrite
4651 return &lang_sub_obj;
4654 # Rewrite a single header file.
4655 sub lang_header_rewrite
4657 # Header files are simply ignored.
4658 return $LANG_IGNORE;
4661 # Rewrite a single yacc file.
4662 sub lang_yacc_rewrite
4664 local ($directory, $base, $ext) = @_;
4666 local ($r) = &lang_c_rewrite ($directory, $base, $ext);
4668 if ($r == $LANG_SUBDIR)
4670 $pfx = $directory . '/';
4672 $yacc_sources{$pfx . $base . '.' . $ext} = 1;
4674 &saw_extension ('c');
4676 &push_dist_common ($pfx . $base . '.' . $ext);
4680 # Rewrite a single yacc++ file.
4681 sub lang_yaccxx_rewrite
4683 local ($directory, $base, $ext) = @_;
4685 local ($r) = $LANG_PROCESS;
4687 if (defined $options{'subdir-objects'})
4689 $pfx = $directory . '/';
4692 $yacc_sources{$pfx . $base . '.' . $ext} = 1;
4694 &saw_extension ($ext);
4696 &push_dist_common ($pfx . $base . '.' . $ext);
4700 # Rewrite a single lex file.
4701 sub lang_lex_rewrite
4703 local ($directory, $base, $ext) = @_;
4705 local ($r) = &lang_c_rewrite ($directory, $base, $ext);
4707 if ($r == $LANG_SUBDIR)
4709 $pfx = $directory . '/';
4711 $lex_sources{$pfx . $base . '.' . $ext} = 1;
4713 &saw_extension ('c');
4715 &push_dist_common ($pfx . $base . '.' . $ext);
4719 # Rewrite a single lex++ file.
4720 sub lang_lexxx_rewrite
4722 local ($directory, $base, $ext) = @_;
4724 local ($r) = $LANG_PROCESS;
4726 if (defined $options{'subdir-objects'})
4728 $pfx = $directory . '/';
4731 $lex_sources{$pfx . $base . '.' . $ext} = 1;
4733 &saw_extension ($ext);
4735 &push_dist_common ($pfx . $base . '.' . $ext);
4739 # Rewrite a single assembly file.
4740 sub lang_asm_rewrite
4742 return &lang_sub_obj;
4745 # Rewrite a single Fortran 77 file.
4746 sub lang_f77_rewrite
4748 return $LANG_PROCESS;
4751 # Rewrite a single preprocessed Fortran 77 file.
4752 sub lang_ppf77_rewrite
4754 return $LANG_PROCESS;
4757 # Rewrite a single ratfor file.
4758 sub lang_ratfor_rewrite
4760 return $LANG_PROCESS;
4763 # Rewrite a single Objective C file.
4764 sub lang_objc_rewrite
4766 return &lang_sub_obj;
4769 # Rewrite a single Java file.
4770 sub lang_java_rewrite
4772 return $LANG_SUBDIR;
4775 # The lang_X_finish functions are called after all source file
4776 # processing is done. Each should handle defining rules for the
4777 # language, etc. A finish function is only called if a source file of
4778 # the appropriate type has been seen.
4782 # Push all libobjs files onto de_ansi_files. We actually only
4783 # push files which exist in the current directory, and which are
4784 # genuine source files.
4786 foreach $file (keys %libsources)
4788 if ($file =~ /^(.*)\.[cly]$/ && -f "$relative_dir/$file")
4790 $de_ansi_files{$1} = 1;
4794 if (defined $options{'ansi2knr'} && keys %de_ansi_files)
4796 # Make all _.c files depend on their corresponding .c files.
4797 local ($base, @objects);
4798 foreach $base (sort keys %de_ansi_files)
4800 # Each _.c file must depend on ansi2knr; otherwise it
4801 # might be used in a parallel build before it is built.
4802 # We need to support files in the srcdir and in the build
4803 # dir (because these files might be auto-generated. But
4804 # we can't use $< -- some makes only define $< during a
4806 $output_rules .= ($base . "_.c: $base.c \$(ANSI2KNR)\n\t"
4807 . '$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) '
4808 . '`if test -f $(srcdir)/' . $base . '.c'
4809 . '; then echo $(srcdir)/' . $base . '.c'
4810 . '; else echo ' . $base . '.c; fi` '
4811 . "| sed 's/^# \\([0-9]\\)/#line \\1/' "
4812 . '| $(ANSI2KNR) > ' . $base . "_.c\n");
4813 push (@objects, $base . '_'
4814 . ($seen_objext ? '.$(OBJEXT)' : '.o'));
4815 push (@objects, $base . '_.lo') if $seen_libtool;
4818 # Make all _.o (and _.lo) files depend on ansi2knr.
4819 # Use a sneaky little hack to make it print nicely.
4820 &pretty_print_rule ('', '', @objects, ':', '$(ANSI2KNR)');
4823 if (! defined $configure_vars{'CC'})
4825 # FIXME: line number.
4826 &am_error ("C source seen but \`CC' not defined in \`configure.in'");
4832 local (@cxx_list) = &lang_extensions ('cxx');
4833 local ($cxx_count) = scalar @cxx_list;
4836 push (@suffixes, @cxx_list);
4838 local ($ltcompile, $ltlink) = &libtool_compiler;
4840 &define_configure_variable ("CXXFLAGS");
4841 &define_compiler_variable ('CXXCOMPILE', $ltcompile, '$(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)');
4843 &define_variable ('CXXLD', '$(CXX)');
4844 &define_variable ('CXXLINK', $ltlink . '$(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@');
4847 foreach $ext (@cxx_list)
4849 # Every known C++ compiler supports both -c and -o.
4850 $output_rules .= ("$ext.o:\n"
4851 . "\t\$(CXXCOMPILE) -c -o \$\@ \$<\n");
4852 # FIXME: Using cygpath should be somehow conditional.
4853 $output_rules .= ("$ext.obj:\n"
4854 . "\t\$(CXXCOMPILE) -c -o \$\@ `cygpath -w \$<`\n")
4856 $output_rules .= ("$ext.lo:\n"
4857 . "\t\$(LTCXXCOMPILE) -c -o \$\@ \$<\n")
4861 if (! defined $configure_vars{'CXX'})
4863 &am_error ("C++ source seen but \`CXX' not defined in \`configure.in'");
4868 sub lang_header_finish
4873 # This is a helper for both lex and yacc.
4874 sub yacc_lex_finish_helper
4876 return if defined $language_scratch{'lex-yacc-done'};
4877 $language_scratch{'lex-yacc-done'} = 1;
4879 # If there is more than one distinct yacc (resp lex) source file
4880 # in a given directory, then the `ylwrap' program is required to
4881 # allow parallel builds to work correctly. FIXME: for now, no
4883 &require_config_file ($FOREIGN, 'ylwrap');
4884 if ($config_aux_dir ne '.' && $config_aux_dir ne '')
4886 &define_variable ('YLWRAP', $config_aux_dir . "/ylwrap");
4890 &define_variable ('YLWRAP', '$(srcdir)/ylwrap');
4894 sub lang_yacc_finish
4896 return if defined $language_scratch{'yacc-done'};
4897 $language_scratch{'yacc-done'} = 1;
4899 local ($file, $base, $hname, $cname);
4900 local (%seen_suffix) = ();
4901 local (@yacc_files) = sort keys %yacc_sources;
4902 local ($yacc_count) = scalar (@yacc_files);
4903 foreach $file (@yacc_files)
4906 &output_yacc_build_rule ($1, $yacc_count > 1)
4907 if ! defined $seen_suffix{$1};
4908 $seen_suffix{$1} = 1;
4910 $file =~ /^(.*)\.(y|yy|y\+\+|yxx|ypp)$/;
4912 $hname = 'h'; # Always use `.h' for header file.
4913 ($cname = $2) =~ tr/y/c/;
4915 if ((&variable_defined ('AM_YFLAGS')
4916 && &variable_value ('AM_YFLAGS') =~ /(^|\s)-d(\s|$)/)
4917 || (&variable_defined ('YFLAGS')
4918 && &variable_value ('YFLAGS') =~ /(^|\s)-d(\s|$)/)) {
4919 # Now generate rule to make the header file. This should only
4920 # be generated if `yacc -d' specified.
4921 $output_rules .= "${base}.${hname}: ${base}.${cname}\n";
4923 # If the files are built in the build directory, then we want
4924 # to remove them with `make clean'. If they are in srcdir
4925 # they shouldn't be touched. However, we can't determine this
4926 # statically, and the GNU rules say that yacc/lex output files
4927 # should be removed by maintainer-clean. So that's what we
4929 push (@maintainer_clean_files, "${base}.${hname}");
4931 &push_dist_common ("${base}.${hname}");
4933 push (@maintainer_clean_files, "${base}.${cname}");
4935 $output_rules .= "\n";
4937 if (! defined $configure_vars{'YACC'})
4939 &am_error ("yacc source seen but \`YACC' not defined in \`configure.in'");
4941 if (&variable_defined ('YACCFLAGS'))
4943 &am_line_error ('YACCFLAGS',
4944 "\`YACCFLAGS' obsolete; use \`YFLAGS' instead");
4947 if ($yacc_count > 1)
4949 &yacc_lex_finish_helper;
4953 sub lang_yaccxx_finish
4960 return if defined $language_scratch{'lex-done'};
4961 $language_scratch{'lex-done'} = 1;
4963 local (%seen_suffix) = ();
4964 local ($file, $cname);
4965 local ($lex_count) = scalar (keys %lex_sources);
4966 foreach $file (sort keys %lex_sources)
4969 &output_lex_build_rule ($1, $lex_count > 1)
4970 if (! defined $seen_suffix{$1});
4971 $seen_suffix{$1} = 1;
4973 # If the files are built in the build directory, then we want
4974 # to remove them with `make clean'. If they are in srcdir
4975 # they shouldn't be touched. However, we can't determine this
4976 # statically, and the GNU rules say that yacc/lex output files
4977 # should be removed by maintainer-clean. So that's what we
4979 $file =~ /^(.*)\.(l|ll|l\+\+|lxx|lpp)$/;
4980 ($cname = $2) =~ tr/l/c/;
4981 push (@maintainer_clean_files, "${1}.${cname}");
4984 if (! defined $configure_vars{'LEX'})
4986 &am_error ("lex source seen but \`LEX' not defined in \`configure.in'");
4988 if (! $seen_decl_yytext)
4990 &am_error ("lex source seen but \`AC_DECL_YYTEXT' not in \`configure.in'");
4995 &yacc_lex_finish_helper;
4999 sub lang_lexxx_finish
5006 # We need the C code for assembly.
5009 # We also need our own rules.
5010 local ($minuso) = '';
5011 if (defined $options{'subdir-objects'})
5015 local (@asm_list) = &lang_extensions ('am');
5017 foreach $ext (@asm_list)
5019 $output_rules .= ("$ext.o:\n"
5020 . "\t\$(COMPILE) -c " . $minuso . "\$<\n");
5021 # FIXME: Using cygpath should be somehow conditional.
5022 $output_rules .= ("$ext.obj:\n"
5023 . "\t\$(COMPILE) -c " . $minuso
5024 . "`cygpath -w \$<`\n")
5026 $output_rules .= ("$ext.lo:\n"
5027 . "\t\$(LTCOMPILE) -c -o \$\@ \$<\n")
5031 push (@suffixes, @asm_list);
5036 local (@f77_list) = &lang_extensions ('f77');
5037 local ($f77_count) = scalar @f77_list;
5040 push (@suffixes, @f77_list);
5042 local ($ltcompile, $ltlink) = &libtool_compiler;
5044 &define_configure_variable ('FFLAGS');
5045 &define_compiler_variable ('F77COMPILE', $ltcompile,
5046 '$(F77) $(AM_FFLAGS) $(FFLAGS)');
5048 &define_variable ('F77LD', '$(F77)');
5049 &define_variable ('F77LINK', $ltlink . '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@');
5052 foreach $ext (@f77_list)
5054 $output_rules .= ("$ext.o:\n"
5055 . "\t\$(F77COMPILE) -c \$<\n");
5056 # FIXME: Using cygpath should be somehow conditional.
5057 $output_rules .= ("$ext.obj:\n"
5058 . "\t\$(F77COMPILE) -c `cygpath -w \$<`\n")
5060 $output_rules .= ("$ext.lo:\n"
5061 . "\t\$(LTF77COMPILE) -c \$<\n")
5065 if (! defined $configure_vars{'F77'})
5067 &am_error ("Fortran 77 source seen but \`F77' not defined in \`configure.in'");
5072 # Preprocessed Fortran 77
5074 # The current support for preprocessing Fortran 77 just involves passing
5075 # `$(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS)' as additional flags
5076 # to the Fortran 77 compiler, since this is how GNU Make does it; see
5077 # the `GNU Make Manual, Edition 0.51 for `make' Version 3.76 Beta'
5078 # (specifically, from info file `(make)Catalogue of Rules').
5080 # A better approach would be to write an Autoconf test
5081 # (i.e. AC_PROG_FPP) for a Fortran 77 preprocessor, because not all
5082 # Fortran 77 compilers know how to do preprocessing. The Autoconf macro
5083 # AC_PROG_FPP should test the Fortran 77 compiler first for
5084 # preprocessing capabilities, and then fall back on cpp (if cpp were
5086 sub lang_ppf77_finish
5089 last unless $extension_seen{$ext};
5092 push (@suffixes, $ext);
5094 local ($ltcompile, $ltlink) = &libtool_compiler;
5096 &define_configure_variable ('FFLAGS');
5097 &define_compiler_variable ('F77COMPILE', $ltcompile,
5098 '$(F77) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FFLAGS) $(FFLAGS)');
5100 &define_variable ('F77LD', '$(F77)');
5101 &define_variable ('F77LINK', $ltlink . '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@');
5103 $output_rules .= ("$ext.o:\n"
5104 . "\t\$(F77COMPILE) -c \$<\n");
5105 # FIXME: Using cygpath should be somehow conditional.
5106 $output_rules .= ("$ext.obj:\n"
5107 . "\t\$(F77COMPILE) -c `cygpath -w \$<`\n")
5109 $output_rules .= ("$ext.lo:\n"
5110 . "\t\$(LTF77COMPILE) -c \$<\n")
5113 # We also handle the case of preprocessing `.F' files into `.f'
5115 $output_rules .= ("$ext.f:\n"
5116 . "\t\$(F77COMPILE) -F \$<\n");
5118 if (! defined $configure_vars{'F77'})
5120 &am_error ("Fortran 77 source seen but \`F77' not defined in \`configure.in'");
5124 sub lang_ratfor_finish
5127 last unless $extension_seen{$ext};
5129 push (@suffixes, $ext);
5131 local ($ltcompile, $ltlink) = &libtool_compiler;
5133 &define_configure_variable ('FFLAGS');
5134 &define_configure_variable ('RFLAGS');
5135 &define_variable ('RCOMPILE', $ltcompile,
5136 '$(F77) $(AM_FFLAGS) $(FFLAGS) $(AM_RFLAGS) $(RFLAGS)');
5138 &define_variable ('F77LD', '$(F77)');
5139 &define_variable ('F77LINK', $ltlink . '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_RFLAGS) $(RFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@');
5141 $output_rules .= ("$ext.o:\n"
5142 . "\t\$(RCOMPILE) -c \$<\n");
5143 # FIXME: Using cygpath should be somehow conditional.
5144 $output_rules .= ("$ext.obj:\n"
5145 . "\t\$(RCOMPILE) -c `cygpath -w \$<`\n")
5147 $output_rules .= ("$ext.lo:\n"
5148 . "\t\$(LTRCOMPILE) -c \$<\n")
5151 # We also handle the case of preprocessing `.r' files into `.f'
5153 $output_rules .= ("$ext.f:\n"
5154 . "\t\$(RCOMPILE) -F \$<\n");
5156 if (! defined $configure_vars{'F77'})
5158 &am_error ("Ratfor source seen but \`F77' not defined in \`configure.in'");
5162 sub lang_objc_finish
5164 push (@suffixes, '.m');
5166 local ($ltcompile, $ltlink) = &libtool_compiler;
5168 &define_configure_variable ("OBJCFLAGS");
5169 &define_compiler_variable ('OBJCCOMPILE', $ltcompile,
5170 '$(OBJC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_OBJCFLAGS) $(OBJCFLAGS)');
5172 &define_variable ('OBJCLD', '$(OBJC)');
5173 &define_variable ('OBJCLINK', $ltlink . '$(OBJCLD) $(AM_OBJCFLAGS) $(OBJCFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@');
5175 # All known ObjC compilers support -c and -o together.
5176 $output_rules .= (".m.o:\n"
5177 . "\t\$(OBJCCOMPILE) -c -o \$\@ \$<\n");
5178 # FIXME: Using cygpath should be somehow conditional.
5179 $output_rules .= (".m.obj:\n"
5180 . "\t\$(OBJCCOMPILE) -c -o \$\@ `cygpath -w \$<`\n")
5182 $output_rules .= (".m.lo:\n"
5183 . "\t\$(LTOBJCCOMPILE) -c -o \$\@ \$<\n")
5186 if (! defined $configure_vars{'OBJC'})
5188 &am_error ("Objective C source seen but \`OBJC' not defined in \`configure.in'");
5192 sub lang_java_finish
5194 local (@java_list) = &lang_extensions ('java');
5195 push (@suffixes, @java_list);
5197 local ($ltcompile, $ltlink) = &libtool_compiler;
5199 &define_configure_variable ("GCJFLAGS");
5200 &define_compiler_variable ('GCJCOMPILE', $ltcompile,
5201 '$(GCJ) $(DEFS) $(INCLUDES) $(AM_GCJFLAGS) $(GCJFLAGS)');
5203 &define_variable ('GCJLD', '$(GCJ)');
5204 &define_variable ('GCJLINK', $ltlink . '$(GCJLD) $(AM_GCJFLAGS) $(GCJFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@');
5207 foreach $ext (@java_list)
5209 # All known Java compilers support -c and -o together.
5210 $output_rules .= (".${ext}.o:\n"
5211 . "\t\$(GCJCOMPILE) -c -o \$\@ \$<\n");
5212 # FIXME: Using cygpath should be somehow conditional.
5213 $output_rules .= (".${ext}.obj:\n"
5214 . "\t\$(GCJCOMPILE) -c -o \$\@ `cygpath -w \$<`\n")
5216 $output_rules .= (".${ext}.lo:\n"
5217 . "\t\$(LTGCJCOMPILE) -c -o \$\@ \$<\n")
5221 if (! defined $configure_vars{'GCJ'})
5223 &am_error ("Java source seen but \`GCJ' not defined in \`configure.in'");
5227 # A helper which computes a sorted list of all extensions for LANG.
5232 foreach $key (sort keys %extension_seen)
5234 push (@r, '.' . $key) if $extension_map{$key} eq $lang;
5239 # A helper which decides whether libtool is needed. Returns prefix
5240 # for compiler and linker.
5241 sub libtool_compiler
5243 local ($ltcompile, $ltlink) = ('', '');
5246 &define_configure_variable ("LIBTOOL");
5247 $ltcompile = '$(LIBTOOL) --mode=compile ';
5248 $ltlink = '$(LIBTOOL) --mode=link ';
5250 return ($ltcompile, $ltlink);
5253 # Given a hash table of linker names, pick the name that has the most
5254 # precedence. This is lame, but something has to have global
5255 # knowledge in order to eliminate the conflict. Add more linkers as
5259 local (%linkers) = @_;
5262 if defined $linkers{'GCJLINK'};
5264 if defined $linkers{'CXXLINK'};
5266 if defined $linkers{'F77LINK'};
5268 if defined $linkers{'OBJCLINK'};
5272 # Called to indicate that an extension was used.
5276 $extension_seen{$ext} = 1;
5279 # Called to ask whether source files have been seen . If HEADERS is 1,
5280 # headers can be included.
5283 local ($headers) = @_;
5291 local (@exts) = &lang_extensions ('header');
5295 return scalar keys %extension_seen > $headers;
5298 # Register a single language. LANGUAGE is the name of the language.
5299 # Each OPTION is either of the form NAME=VALUE, or is a file extension
5301 sub register_language
5303 local ($language, @options) = @_;
5306 $language_map{$language . '-ansi-p'} = 0;
5307 $language_map{$language . '-linker'} = '';
5308 $language_map{$language . '-autodep'} = 'no';
5311 foreach $iter (@options)
5313 if ($iter =~ /^(.*)=(.*)$/)
5315 $language_map{$language . '-' . $1} = $2;
5317 elsif (defined $extension_map{$iter})
5320 "automake: programming error: duplicate extension $iter\n";
5325 $extension_map{$iter} = $language;
5331 ################################################################
5333 # Pretty-print something. HEAD is what should be printed at the
5334 # beginning of the first line, FILL is what should be printed at the
5335 # beginning of every subsequent line.
5336 sub pretty_print_internal
5338 local ($head, $fill, @values) = @_;
5340 local ($column) = length ($head);
5341 local ($result) = $head;
5343 # Fill length is number of characters. However, each Tab
5344 # character counts for eight. So we count the number of Tabs and
5346 local ($fill_length) = length ($fill);
5347 $fill_length += 7 * ($fill =~ tr/\t/\t/d);
5349 local ($bol) = ($head eq '');
5352 # "71" because we also print a space.
5353 if ($column + length ($_) > 71)
5355 $result .= " \\\n" . $fill;
5356 $column = $fill_length;
5360 $result .= ' ' unless ($bol);
5362 $column += length ($_) + 1;
5370 # Pretty-print something and append to output_vars.
5373 $output_vars .= &pretty_print_internal (@_);
5376 # Pretty-print something and append to output_rules.
5377 sub pretty_print_rule
5379 $output_rules .= &pretty_print_internal (@_);
5383 ################################################################
5385 # See if a target exists.
5388 local ($target) = @_;
5389 return defined $targets{$target};
5392 # See if two conditionals are the same.
5393 sub conditional_same
5395 local ($cond1, $cond2) = @_;
5397 return (&conditional_true_when ($cond1, $cond2)
5398 && &conditional_true_when ($cond2, $cond1));
5401 # See if a conditional is true. Both arguments are conditional
5402 # strings. This returns true if the first conditional is true when
5403 # the second conditional is true.
5404 sub conditional_true_when
5406 local ($cond, $when) = @_;
5408 # Check the easy case first.
5414 # Check each component of $cond, which looks @COND1@@COND2@.
5415 foreach $comp (split ('@', $cond))
5417 # The way we split will give null strings between each
5421 if (index ($when, '@' . $comp . '@') == -1)
5430 # Check for an ambiguous conditional. This is called when a variable
5431 # or target is being defined conditionally. If we already know about
5432 # a definition that is true under the same conditions, then we have an
5434 sub check_ambiguous_conditional
5436 local ($var_name, $cond) = @_;
5437 local (@cond_vals) = split (' ', $conditional{$var_name});
5440 local ($vcond) = shift (@cond_vals);
5442 if (&conditional_true_when ($vcond, $cond)
5443 || &conditional_true_when ($cond, $vcond))
5445 &am_line_error ($var_name,
5446 "$var_name multiply defined in condition");
5451 # See if a variable exists. The first argument is the variable name,
5452 # and the optional second argument is the condition which we should
5453 # check. If no condition is given, we currently return true if the
5454 # variable is defined under any condition.
5455 sub variable_defined
5457 local ($var, $cond) = @_;
5458 if (defined $targets{$var})
5460 &am_line_error ($var, "\`$var' is target; expected variable");
5463 elsif (defined $contents{$var})
5465 if ($cond && $conditional{$var})
5467 # We have been asked to check for a particular condition,
5468 # and the variable is defined conditionally. We need to
5469 # look through the conditions under which the variable is
5470 # defined, and see if any of them match the conditional we
5471 # have been asked to check.
5472 local (@cond_vars) = split (' ', $conditional{$var});
5475 if (&conditional_same ($cond, shift (@cond_vars)))
5477 # Even a conditional examination is good enough
5478 # for us. FIXME: really should maintain examined
5479 # status on a per-condition basis.
5480 $content_seen{$var} = 1;
5486 # The variable is not defined for the given condition.
5490 $content_seen{$var} = 1;
5496 # Mark a variable as examined.
5497 sub examine_variable
5500 &variable_defined ($var);
5503 # Quote a value in order to put it in $conditional. We need to quote
5504 # spaces, and we need to handle null strings, so that we can later
5505 # retrieve values by splitting on space.
5509 $val =~ tr/ \t\n/\001\003\004/;
5510 $val = "\002" if $val eq '';
5514 # Unquote a value in $conditional.
5515 sub unquote_cond_val
5518 $val =~ tr/\001\003\004/ \t\n/;
5523 # Return the set of conditions for which a variable is defined.
5525 # If the variable is not defined conditionally, and is not defined in
5526 # terms of any variables which are defined conditionally, then this
5527 # returns the empty list.
5529 # If the variable is defined conditionally, but is not defined in
5530 # terms of any variables which are defined conditionally, then this
5531 # returns the list of conditions for which the variable is defined.
5533 # If the variable is defined in terms of any variables which are
5534 # defined conditionally, then this returns a full set of permutations
5535 # of the subvariable conditions. For example, if the variable is
5536 # defined in terms of a variable which is defined for @COND_TRUE@,
5537 # then this returns both @COND_TRUE@ and @COND_FALSE@. This is
5538 # because we will need to define the variable under both conditions.
5540 sub variable_conditions
5548 foreach $cond (&variable_conditions_sub ($var, '', ()))
5550 $uniqify{$cond} = 1;
5553 @uniq_list = sort keys %uniqify;
5554 # Note we cannot just do `return sort keys %uniqify', because this
5555 # function is sometimes used in a scalar context.
5559 # A subroutine of variable_conditions. We only return conditions
5560 # which are true for all the conditions in @PARENT_CONDS.
5561 sub variable_conditions_sub
5563 local ($var, $parent, @parent_conds) = @_;
5564 local (@new_conds) = ();
5566 if (defined $vars_scanned{$var})
5568 &am_line_error ($parent, "variable \`$var' recursively defined");
5571 $vars_scanned{$var} = 1;
5573 if (! $conditional{$var})
5575 foreach (split (' ', $contents{$var}))
5577 # If a comment seen, just leave.
5580 # Handle variable substitutions.
5581 if (/^\$\{(.*)\}$/ || /^\$\((.*)\)$/)
5584 &variable_conditions_sub ($1, $var, @parent_conds));
5588 # Now we want to return all permutations of the subvariable
5590 local (%allconds, $item);
5591 foreach $item (@new_conds)
5593 foreach (split ('@', $item))
5597 $allconds{$_ . '_TRUE'} = 1;
5601 # Unset our entry in vars_scanned. We only care about recursive
5603 delete $vars_scanned{$var};
5605 return &variable_conditions_permutations (sort keys %allconds);
5608 local (@this_conds) = ();
5609 local (@condvals) = split (' ', $conditional{$var});
5612 local ($cond) = shift (@condvals);
5613 local ($val) = &unquote_cond_val (shift (@condvals));
5618 local ($parent_cond);
5619 foreach $parent_cond (@parent_conds)
5621 if (! &conditional_true_when ($parent_cond, $cond))
5631 push (@this_conds, $cond);
5633 push (@parent_conds, $cond);
5634 local (@subvar_conds) = ();
5635 foreach (split (' ', $val))
5637 # If a comment seen, just leave.
5640 # Handle variable substitutions.
5641 if (/^\$\{(.*)\}$/ || /^\$\((.*)\)$/)
5643 push (@subvar_conds,
5644 &variable_conditions_sub ($1, $var, @parent_conds));
5647 pop (@parent_conds);
5649 # If there are no conditional subvariables, then we want to
5650 # return this condition. Otherwise, we want to return the
5651 # permutations of the subvariables.
5652 if (! @subvar_conds)
5654 push (@new_conds, $cond);
5658 push (@new_conds, &variable_conditions_reduce (@subvar_conds));
5662 # Unset our entry in vars_scanned. We only care about recursive
5664 delete $vars_scanned{$var};
5669 # If we are being called on behalf of another variable, we need to
5670 # return all possible permutations of the conditions. We have
5671 # already handled everything in @this_conds along with their
5672 # subvariables. We now need to add any permutations that are not
5675 foreach $this_cond (@this_conds)
5678 &variable_conditions_permutations (split('@', $this_cond));
5680 foreach $perm (@perms)
5684 foreach $scan (@this_conds)
5686 if (&conditional_true_when ($perm, $scan)
5687 || &conditional_true_when ($scan, $perm))
5698 local ($parent_cond);
5699 foreach $parent_cond (@parent_conds)
5701 if (! &conditional_true_when ($parent_cond, $perm))
5711 # This permutation was not already handled, and is valid
5713 push (@new_conds, $perm);
5720 # Subroutine for variable_conditions_sort
5721 sub variable_conditions_cmp
5727 return (length ($as) <=> length ($bs)
5731 # Sort a list of conditionals so that only the exclusive ones are
5732 # retained. For example, if both @COND1_TRUE@@COND2_TRUE@ and
5733 # @COND1_TRUE@ are in the list, discard the latter.
5734 sub variable_conditions_reduce
5736 local (@conds) = @_;
5739 foreach $cond (sort variable_conditions_cmp @conds)
5743 foreach $scan (@ret)
5745 if (&conditional_true_when ($cond, $scan))
5758 # Return a list of permutations of a conditional string.
5759 sub variable_conditions_permutations
5761 local (@comps) = @_;
5764 local ($comp) = shift (@comps);
5765 return &variable_conditions_permutations (@comps)
5767 local ($neg) = $comp;
5768 $neg =~ s/TRUE$/TRUEO/;
5769 $neg =~ s/FALSE$/TRUE/;
5770 $neg =~ s/TRUEO$/FALSE/;
5773 foreach $sub (&variable_conditions_permutations (@comps))
5775 push (@ret, '@' . $comp . '@' . $sub);
5776 push (@ret, '@' . $neg . '@' . $sub);
5780 push (@ret, '@' . $comp . '@');
5781 push (@ret, '@' . $neg . '@');
5786 # Warn if a variable is conditionally defined. This is called if we
5787 # are using the value of a variable.
5788 sub variable_conditionally_defined
5790 local ($var, $parent) = @_;
5791 if ($conditional{$var})
5795 &am_line_error ($parent,
5796 "warning: automake does not support conditional definition of $var in $parent");
5800 &am_line_error ($parent,
5801 "warning: automake does not support $var being defined conditionally")
5806 # Get the value of a variable. This just returns $contents, but warns
5807 # if the variable is conditionally defined.
5811 &variable_conditionally_defined ($var);
5812 return $contents{$var};
5815 # Convert a variable value to a list, split as whitespace. This will
5816 # recursively follow $(...) and ${...} inclusions. It preserves @...@
5817 # substitutions. If COND is 'all', then all values under all
5818 # conditions should be returned; if COND is a particular condition
5819 # (all conditions are surrounded by @...@) then only the value for
5820 # that condition should be returned; otherwise, warn if VAR is
5821 # conditionally defined. SCANNED is a global hash listing whose keys
5822 # are all the variables already scanned; it is an error to rescan a
5826 local ($var, $val, $cond) = @_;
5830 $val =~ s/\\(\n|$)/ /g;
5832 foreach (split (' ', $val))
5834 # If a comment seen, just leave.
5837 # Handle variable substitutions.
5838 if (/^\$\{([^}]*)\}$/ || /^\$\(([^)]*)\)$/)
5840 local ($varname) = $1;
5842 # If the user uses a losing variable name, just ignore it.
5843 # This isn't ideal, but people have requested it.
5844 next if ($varname =~ /\@.*\@/);
5848 if ($varname =~ /^([^:]*):([^=]*)=(.*)$/)
5852 ($from = $2) =~ s/(\W)/\\$1/g;
5856 @temp_list = &variable_value_as_list_worker ($1, $cond, $var);
5858 # Now rewrite the value if appropriate.
5861 grep (s/$from$/$to/, @temp_list);
5864 push (@result, @temp_list);
5875 # Return contents of variable as list, split as whitespace. This will
5876 # recursively follow $(...) and ${...} inclusions. It preserves @...@
5877 # substitutions. If COND is 'all', then all values under all
5878 # conditions should be returned; if COND is a particular condition
5879 # (all conditions are surrounded by @...@) then only the value for
5880 # that condition should be returned; otherwise, warn if VAR is
5881 # conditionally defined. If PARENT is specified, it is the name of
5882 # the including variable; this is only used for error reports.
5883 sub variable_value_as_list_worker
5885 local ($var, $cond, $parent) = @_;
5888 if (defined $targets{$var})
5890 &am_line_error ($var, "\`$var' is target; expected variable");
5892 elsif (! defined $contents{$var})
5894 &am_line_error ($parent, "variable \`$var' not defined");
5896 elsif (defined $vars_scanned{$var})
5898 # `vars_scanned' is a global we use to keep track of which
5899 # variables we've already examined.
5900 &am_line_error ($parent, "variable \`$var' recursively defined");
5902 elsif ($cond eq 'all' && $conditional{$var})
5904 $vars_scanned{$var} = 1;
5905 local (@condvals) = split (' ', $conditional{$var});
5909 local ($val) = &unquote_cond_val (shift (@condvals));
5910 push (@result, &value_to_list ($var, $val, $cond));
5913 elsif ($cond && $conditional{$var})
5915 $vars_scanned{$var} = 1;
5916 local (@condvals) = split (' ', $conditional{$var});
5920 local ($vcond) = shift (@condvals);
5921 local ($val) = &unquote_cond_val (shift (@condvals));
5922 if (&conditional_true_when ($vcond, $cond))
5924 # Warn if we have an ambiguity. It's hard to know how
5925 # to handle this case correctly.
5926 &variable_conditionally_defined ($var, $parent)
5929 push (@result, &value_to_list ($var, $val, $cond));
5935 $vars_scanned{$var} = 1;
5936 &variable_conditionally_defined ($var, $parent);
5937 $content_seen{$var} = 1;
5938 push (@result, &value_to_list ($var, $contents{$var}, $cond));
5941 # Unset our entry in vars_scanned. We only care about recursive
5943 delete $vars_scanned{$var};
5948 # This is just a wrapper for variable_value_as_list_worker that
5949 # initializes the global hash `vars_scanned'. This hash is used to
5950 # avoid infinite recursion.
5951 sub variable_value_as_list
5953 local ($var, $cond, $parent) = @_;
5955 return &variable_value_as_list_worker ($var, $cond, $parent);
5958 # Define a new variable, but only if not already defined.
5961 local ($var, $value) = @_;
5963 if (! defined $contents{$var})
5965 $output_vars .= $var . ' = ' . $value . "\n";
5966 $contents{$var} = $value;
5967 $content_seen{$var} = 1;
5969 elsif ($var_was_plus_eq{$var})
5971 &am_line_error ($var, "internally generated variable \`$var' was set with \`+='");
5975 # Like define_variable, but the value is a list, and the variable may
5976 # be defined conditionally. The second argument is the conditional
5977 # under which the value should be defined; this should be the empty
5978 # string to define the variable unconditionally. The third argument
5979 # is a list holding the values to use for the variable. The value is
5980 # pretty printed in the output file.
5981 sub define_pretty_variable
5983 local ($var, $cond, @value) = @_;
5984 if (! defined $contents{$var}
5985 || ($cond && ! &variable_defined ($var, $cond)))
5987 $contents{$var} = join (' ', @value);
5990 if ($conditional{$var})
5992 $conditional{$var} .= ' ';
5996 $conditional{$var} = '';
5998 $conditional{$var} .= ($cond
6000 . "e_cond_val ($contents{$var}));
6002 &pretty_print ($cond . $var . ' = ', $cond, @value);
6003 $content_seen{$var} = 1;
6007 # Like define_variable, but define a variable to be the configure
6008 # substitution by the same name.
6009 sub define_configure_variable
6012 local ($value) = '@' . $var . '@';
6013 &define_variable ($var, $value);
6016 # Define a compiler variable. We also handle defining the `LT'
6017 # version of the command when using libtool.
6018 sub define_compiler_variable
6020 local ($var, $ltcompile, $value) = @_;
6021 local ($name) = $var;
6022 &define_variable ($name, $value);
6023 &define_variable ('LT' . $name, $ltcompile . $value)
6027 # Define a variable that represents a program to run. If in Cygnus
6028 # mode, the program is searched for in the build (or source) tree.
6029 # Otherwise no searching is done at all. Arguments are:
6030 # * VAR Name of variable to define
6031 # * WHATDIR Either `src' or `build', depending on where program should
6032 # be found. (runtest is in srcdir!)
6033 # * SUBDIR Subdir of top-level dir
6034 # * PROGRAM Name of program
6035 # * OVERRIDE If specified, the name of the program to use when not in
6036 # Cygnus mode. Defaults to PROGRAM.
6037 sub define_program_variable
6039 local ($var, $whatdir, $subdir, $program, $override) = @_;
6043 $override = $program;
6048 local ($full) = ('$(top_' . $whatdir . 'dir)/../'
6049 . $subdir . '/' . $program);
6050 &define_variable ($var, ('`if test -f ' . $full
6051 . '; then echo ' . $full . '; else echo '
6052 . $program . '; fi`'));
6056 &define_variable ($var, $override);
6061 ################################################################
6063 # Read Makefile.am and set up %contents. Simultaneously copy lines
6064 # from Makefile.am into $output_trailer or $output_vars as
6065 # appropriate. NOTE we put rules in the trailer section. We want
6066 # user rules to come after our generated stuff.
6069 local ($amfile) = @_;
6072 open (AM_FILE, $amfile) || die "automake: couldn't open \`$amfile': $!\n";
6073 print "automake: reading $amfile\n" if $verbose;
6075 local ($saw_bk) = 0;
6076 local ($was_rule) = 0;
6077 local ($spacing) = '';
6078 local ($comment) = '';
6079 local ($last_var_name) = '';
6084 if (/$IGNORE_PATTERN/o)
6086 # Merely delete comments beginning with two hashes.
6088 elsif (/$WHITE_PATTERN/o)
6090 # Stick a single white line before the incoming macro or rule.
6094 elsif (/$COMMENT_PATTERN/o)
6096 # Stick comments before the incoming macro or rule. Make
6097 # sure a blank line preceeds first block of comments.
6098 $spacing = "\n" unless $blank;
6100 $comment .= $spacing . $_;
6109 $output_vars .= $comment . "\n";
6113 local ($is_ok_macro);
6117 unless substr ($_, -1, 1) eq "\n";
6119 # Don't look at MAINTAINER_MODE_TRUE here. That shouldn't be
6120 # used by users. @MAINT@ is an anachronism now.
6121 $_ =~ s/\@MAINT\@//g
6122 unless $seen_maint_mode;
6124 if (/$IGNORE_PATTERN/o)
6126 # Merely delete comments beginning with two hashes.
6128 elsif (/$WHITE_PATTERN/o)
6130 # Stick a single white line before the incoming macro or rule.
6132 &am_line_error ($., "blank line following trailing backslash")
6135 elsif (/$COMMENT_PATTERN/o)
6137 # Stick comments before the incoming macro or rule.
6138 $comment .= $spacing . $_;
6140 &am_line_error ($., "comment following trailing backslash")
6147 $output_trailer .= join ('', @conditional_stack) . $_;
6153 $contents{$last_var_name} .= ' '
6154 unless $contents{$last_var_name} =~ /\s$/;
6155 $contents{$last_var_name} .= $_;
6156 if (@conditional_stack)
6158 $conditional{$last_var_name} .= "e_cond_val ($_);
6162 elsif (/$IF_PATTERN/o)
6164 &am_line_error ($., "$1 does not appear in AM_CONDITIONAL")
6165 if (! $configure_cond{$1});
6166 push (@conditional_stack, "\@" . $1 . "_TRUE\@");
6168 elsif (/$ELSE_PATTERN/o)
6170 if (! @conditional_stack)
6172 &am_line_error ($., "else without if");
6174 elsif ($conditional_stack[$#conditional_stack] =~ /_FALSE\@$/)
6176 &am_line_error ($., "else after else");
6180 $conditional_stack[$#conditional_stack]
6181 =~ s/_TRUE\@$/_FALSE\@/;
6184 elsif (/$ENDIF_PATTERN/o)
6186 if (! @conditional_stack)
6188 &am_line_error ($., "endif without if");
6192 pop @conditional_stack;
6195 elsif (/$RULE_PATTERN/o)
6199 if (defined $contents{$1}
6200 && (@conditional_stack
6201 ? ! defined $conditional{$1}
6202 : defined $conditional{$1}))
6205 "$1 defined both conditionally and unconditionally");
6207 # Value here doesn't matter; for targets we only note
6211 local ($cond_string) = join ('', @conditional_stack);
6212 if (@conditional_stack)
6214 if ($conditional{$1})
6216 &check_ambiguous_conditional ($1, $cond_string);
6217 $conditional{$1} .= ' ';
6221 $conditional{$1} = '';
6223 $conditional{$1} .= $cond_string . ' 1';
6225 $content_lines{$1} = $.;
6226 $output_trailer .= $comment . $spacing . $cond_string . $_;
6227 $comment = $spacing = '';
6230 # Check the rule for being a suffix rule. If so, store in
6233 local ($source_suffix);
6234 local ($object_suffix);
6236 if (($source_suffix, $object_suffix) = ($1 =~ $SUFFIX_RULE_PATTERN))
6238 $suffix_rules{$source_suffix} = $object_suffix;
6239 print "Sources ending in .$source_suffix become .$object_suffix\n" if $verbose;
6240 $source_suffix_pattern = "(" . join('|', keys %suffix_rules) . ")";
6243 # FIXME: make sure both suffixes are in SUFFIXES? Or set
6244 # SUFFIXES from suffix_rules?
6246 elsif (($is_ok_macro = /$MACRO_PATTERN/o)
6247 || /$BOGUS_MACRO_PATTERN/o)
6249 # Found a macro definition.
6251 $last_var_name = $1;
6252 if (defined $contents{$1}
6253 && (@conditional_stack
6254 ? ! defined $conditional{$1}
6255 : defined $conditional{$1}))
6258 "$1 defined both conditionally and unconditionally");
6261 if ($3 ne '' && substr ($3, -1) eq "\\")
6263 # We preserve the `\' because otherwise the long lines
6264 # that are generated will be truncated by broken
6274 if (! defined $contents{$last_var_name})
6276 # The first assignment to a macro sets the line
6277 # number. Ideally I suppose we would associate line
6278 # numbers with random bits of text.
6279 $content_lines{$last_var_name} = $.;
6281 # If first assignment, set `+=' indicator.
6282 $var_was_plus_eq{$last_var_name} =
6284 && ! defined $am_var_defs{$last_var_name});
6289 if (! defined $contents{$last_var_name}
6290 && defined $am_var_defs{$last_var_name})
6292 $contents{$last_var_name} = $am_var_defs{$last_var_name};
6294 $contents{$last_var_name} .= ' ' . $value;
6298 $contents{$last_var_name} = $value;
6300 local ($cond_string) = join ('', @conditional_stack);
6301 if (@conditional_stack)
6305 if ($conditional{$last_var_name})
6309 # If we're adding to the conditional, and it
6310 # exists, then we might want to simply replace
6311 # the old value with the new one.
6312 local (@new_vals, @cond_vals);
6313 @cond_vals = split (' ', $conditional{$last_var_name});
6316 local ($vcond) = shift (@cond_vals);
6317 push (@new_vals, $vcond);
6318 if (&conditional_same ($vcond, $cond_string))
6321 $val = (&unquote_cond_val (shift (@cond_vals))
6323 push (@new_vals, "e_cond_val ($val));
6327 push (@new_vals, shift (@cond_vals));
6332 $conditional{$last_var_name}
6333 = join (' ', @new_vals);
6339 &check_ambiguous_conditional ($last_var_name,
6341 $conditional{$last_var_name} .= ' ';
6347 $conditional{$last_var_name} = '';
6348 $val = $contents{$last_var_name};
6352 $conditional{$last_var_name} .= ($cond_string
6354 . "e_cond_val ($val));
6358 # FIXME: this doesn't always work correctly; it will group
6359 # all comments for a given variable, no matter where
6361 $am_vars{$last_var_name} = $comment . $spacing;
6362 $def_type{$last_var_name} = ($type eq ':') ? ':' : '';
6363 push (@var_list, $last_var_name);
6364 $comment = $spacing = '';
6368 &am_line_error ($., "bad macro name \`$last_var_name'")
6371 elsif (/$INCLUDE_PATTERN/o)
6375 if ($path =~ s/^\$\(top_srcdir\)\///)
6377 push (@include_stack, "\$\(top_srcdir\)/$path");
6381 $path =~ s/\$\(srcdir\)\///;
6382 push (@include_stack, "\$\(srcdir\)/$path");
6383 $path = $relative_dir . "/" . $path;
6385 &read_am_file ($path);
6389 # This isn't an error; it is probably a continued rule.
6390 # In fact, this is what we assume.
6392 $output_trailer .= ($comment . $spacing
6393 . join ('', @conditional_stack) . $_);
6394 $comment = $spacing = '';
6401 $output_trailer .= $comment;
6403 &am_error ("unterminated conditionals: " . join (' ', @conditional_stack))
6404 if (@conditional_stack);
6407 # A helper for read_main_am_file which initializes configure variables
6408 # and variables from header-vars.am. This is a subr so we can call it
6410 sub define_standard_variables
6412 # Compute relative location of the top object directory.
6413 local (@topdir) = ();
6414 foreach (split (/\//, $relative_dir))
6416 next if $_ eq '.' || $_ eq '';
6423 push (@topdir, '..');
6426 @topdir = ('.') if ! @topdir;
6428 $top_builddir = join ('/', @topdir);
6430 ($build_rx = $top_builddir) =~ s/(\W)/\\$1/g;
6431 $output_vars .= &file_contents_with_transform
6432 ('s/\@top_builddir\@/' . $build_rx . '/g;',
6435 # Generate some useful variables when AC_CANONICAL_* used. FIXME:
6436 # this should use generic %configure_vars method.
6437 if ($seen_canonical)
6439 local ($curs, %vars);
6440 $vars{'host_alias'} = 'host_alias';
6441 $vars{'host_triplet'} = 'host';
6442 if ($seen_canonical == $AC_CANONICAL_SYSTEM)
6444 $vars{'build_alias'} = 'build_alias';
6445 $vars{'build_triplet'} = 'build';
6446 $vars{'target_alias'} = 'target_alias';
6447 $vars{'target_triplet'} = 'target';
6449 foreach $curs (sort keys %vars)
6451 $output_vars .= "$curs = \@$vars{$curs}\@\n";
6452 $contents{$curs} = "\@$vars{$curs}\@";
6457 foreach $curs (sort keys %configure_vars)
6459 &define_configure_variable ($curs);
6463 # Read main am file.
6464 sub read_main_am_file
6466 local ($amfile) = @_;
6468 # The keys here are variables we want to dump at the end of this
6469 # function. The values are corresponding comments.
6470 local (%am_vars) = ();
6471 local (@var_list) = ();
6472 local (%def_type) = ();
6474 # We want to predefine as many variables as possible. This lets
6475 # the user set them with `+=' in Makefile.am. However, we don't
6476 # want these initial definitions to end up in the output quite
6477 # yet. So we adopt a hack: read the `.am' file twice, throwing
6478 # away the output the first time. We also squirrel away a list of
6479 # all the variables defined by the .am file so that we know which
6480 # ones to remove from the content list.
6483 &define_standard_variables;
6484 local (%saved_contents) = %contents;
6486 # Read user file, but discard text of variable assignments we just
6489 &read_am_file ($amfile);
6491 # Now dump the variables that were defined. We do it in the same
6492 # order in which they were defined (skipping duplicates).
6494 foreach $curs (@var_list)
6496 next if $done{$curs};
6499 $output_vars .= $am_vars{$curs};
6500 if ($conditional{$curs})
6502 local (@cond_vals) = split (' ', $conditional{$curs});
6505 local ($vcond) = shift (@cond_vals);
6506 local ($val) = &unquote_cond_val (shift (@cond_vals));
6507 $output_vars .= ($vcond . $curs . ' '
6508 . $def_type{$curs} . "= \\\n");
6510 foreach $line (split ("\n", $val))
6512 $output_vars .= $vcond . $line . "\n";
6518 $output_vars .= ($curs . ' ' . $def_type{$curs} . '= '
6519 . $contents{$curs} . "\n");
6523 # Generate copyright header for generated Makefile.in.
6524 local ($ov) = $output_vars;
6525 $output_vars = ("# $in_file_name generated automatically by automake "
6526 . $VERSION . " from $am_file_name\n");
6527 $output_vars .= $gen_copyright;
6529 # Now go through and delete all the variables that the user did
6532 foreach $var (keys %saved_contents)
6534 if ($contents{$var} eq $saved_contents{$var})
6536 delete $contents{$var};
6540 # Re-read the standard variables, and this time keep their
6541 # contributions to the output. Then add the user's output to the
6543 &define_standard_variables;
6544 $output_vars .= $ov;
6548 ################################################################
6550 sub initialize_global_constants
6552 # Values for AC_CANONICAL_*
6553 $AC_CANONICAL_HOST = 1;
6554 $AC_CANONICAL_SYSTEM = 2;
6556 # Associative array of standard directory names. Entry is TRUE if
6557 # corresponding directory should be installed during
6558 # 'install-exec' phase.
6576 # Commonly found files we look for and automatically include in
6580 "README", "THANKS", "TODO", "NEWS", "COPYING", "COPYING.LIB",
6581 "INSTALL", "ABOUT-NLS", "ChangeLog", "configure", "configure.in",
6582 "config.guess", "config.sub", "AUTHORS", "BACKLOG", "ABOUT-GNU",
6583 "libversion.in", "mdate-sh", "mkinstalldirs", "install-sh",
6584 'texinfo.tex', "ansi2knr.c", "ansi2knr.1", 'elisp-comp',
6585 'ylwrap', 'acinclude.m4', @libtoolize_files,
6586 'missing', 'compile'
6589 # Commonly used files we auto-include, but only sometimes.
6592 "aclocal.m4", "acconfig.h", "config.h.top",
6593 "config.h.bot", "stamp-h.in", 'stamp-vti'
6597 -a, --add-missing add missing standard files to package
6598 --amdir=DIR directory storing config files
6599 --build-dir=DIR directory where build being done (for dependencies)
6600 -c, --copy with -a, copy missing files (default is symlink)
6601 --cygnus assume program is part of Cygnus-style tree
6602 --foreign set strictness to foreign
6603 --gnits set strictness to gnits
6604 --gnu set strictness to gnu
6605 --help print this help, then exit
6606 -i, --include-deps include generated dependencies in Makefile.in
6607 --no-force only update Makefile.in's that are out of date
6608 -o DIR, --output-dir=DIR
6609 put generated Makefile.in's into DIR
6610 --srcdir-name=DIR name used for srcdir (for dependencies)
6611 -v, --verbose verbosely list files processed
6612 --version print version number, then exit\n";
6614 # Copyright on generated Makefile.ins.
6616 # Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
6617 # This Makefile.in is free software; the Free Software Foundation
6618 # gives unlimited permission to copy and/or distribute it,
6619 # with or without modifications, as long as this notice is preserved.
6621 # This program is distributed in the hope that it will be useful,
6622 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
6623 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
6624 # PARTICULAR PURPOSE.
6627 # Ignore return result from chmod, because it might give an error
6628 # if we chmod a symlink.
6629 $dist_header = "\t" . '-chmod -R a+r $(distdir)' . "\n";
6630 $dist{'dist-bzip2'} = ("\t"
6631 . '$(AMTAR) ch$(AMTARFLAGS)f - $(distdir) | bzip --best -c > $(distdir).bz2'
6633 $dist{'dist-tarZ'} = ("\t"
6634 . '$(AMTAR) ch$(AMTARFLAGS)f - $(distdir) | compress -c > $(distdir).tar.Z'
6636 $dist{'dist-shar'} = ("\t"
6637 . 'shar $(distdir) | gzip > $(distdir).shar.gz'
6639 $dist{'dist-zip'} = "\t" . 'zip -rq $(distdir).zip $(distdir)' . "\n";
6640 $dist{'dist'} = ("\t"
6641 . '$(AMTAR) ch$(AMTARFLAGS)f - $(distdir) | GZIP=$(GZIP_ENV) gzip -c > $(distdir).tar.gz'
6643 $dist_trailer = "\t" . '-rm -rf $(distdir)' . "\n";
6646 # (Re)-Initialize per-Makefile.am variables.
6647 sub initialize_per_input
6649 # These two variables are used when generating each Makefile.in.
6650 # They hold the Makefile.in until it is ready to be printed.
6653 $output_trailer = '';
6655 $output_header = '';
6657 # Suffixes found during a run.
6660 # This holds the contents of a Makefile.am, as parsed by
6664 # This holds the names which are targets. These also appear in
6668 # This maps a variable name onto a flag. The flag is true iff the
6669 # variable was first defined with `+='.
6670 %var_was_plus_eq = ();
6672 # This holds definitions of all variables defined in .am files.
6673 # This is used during startup to determine which variables can be
6674 # assigned with `+='.
6677 # For a variable or target which is defined conditionally, this
6678 # holds an array of the conditional values. The array is composed
6679 # of pairs of condition strings (the variables which configure
6680 # will substitute) and values (the value of a target is
6681 # meaningless). For an unconditional variable, this is empty.
6684 # This holds the line numbers at which various elements of
6685 # %contents are defined.
6686 %content_lines = ();
6688 # This holds a 1 if a particular variable was examined.
6691 # This is the conditional stack.
6692 @conditional_stack = ();
6694 # This holds the set of included files.
6695 @include_stack = ();
6697 # This holds the "relative directory" of the current Makefile.in.
6698 # Eg for src/Makefile.in, this is "src".
6701 # This holds a list of files that are included in the
6705 # List of dependencies for the obvious targets.
6721 # A list of files deleted by `maintainer-clean'.
6722 @maintainer_clean_files = ();
6724 # These are pretty obvious, too. They are used to define the
6725 # SOURCES and OBJECTS variables.
6728 # Sources which go in the distribution.
6731 # This hash maps object file names onto their corresponding source
6732 # file names. This is used to ensure that each object is created
6733 # by a single source file.
6736 # This keeps track of the directories for which we've already
6737 # created `.dirstamp' code.
6738 %directory_map = ();
6740 # These variables track inclusion of various compile-related .am
6741 # files. $included_generic_compile is TRUE if the basic code has
6742 # been included. $included_knr_compile is TRUE if the ansi2knr
6743 # code has been included. $included_libtool_compile is TRUE if
6744 # libtool support has been included.
6745 $included_generic_compile = 0;
6746 $included_knr_compile = 0;
6747 $included_libtool_compile = 0;
6749 # TRUE if install targets should work recursively.
6750 $recursive_install = 0;
6755 # Strictness levels.
6756 $strictness = $default_strictness;
6757 $strictness_name = $default_strictness_name;
6759 # Options from AUTOMAKE_OPTIONS.
6762 # Whether or not dependencies are handled. Can be further changed
6763 # in handle_options.
6764 $use_dependencies = $cmdline_use_dependencies;
6767 $local_maint_charset = $maint_charset;
6769 # All yacc and lex source filenames for this directory. Use
6770 # filenames instead of raw count so that multiple instances are
6771 # counted correctly (eg one yacc file can appear in multiple
6772 # programs without harm).
6776 # This is a list of all targets to run during "make dist".
6779 # Keys in this hash are the basenames of files which must depend
6781 %de_ansi_files = ();
6783 # This maps the source extension of a suffix rule to its
6784 # corresponding output extension.
6787 # This is the name of the recursive `all' target to use.
6788 $all_target = 'all-recursive';
6790 # This keeps track of which extensions we've seen (that we care
6792 %extension_seen = ();
6794 # This is random scratch space for the language finish functions.
6795 # Don't randomly overwrite it; examine other uses of keys first.
6796 %language_scratch = ();
6800 ################################################################
6802 # Return contents of a file from $am_dir, automatically skipping
6803 # macros or rules which are already known. Runs command on each line
6804 # as it is read; this command can modify $_.
6805 sub file_contents_with_transform
6807 local ($command, $basename) = @_;
6808 local ($file) = $am_dir . '/' . $basename . '.am';
6810 if ($command ne '' && substr ($command, -1) ne ';')
6812 die "automake: programming error in file_contents_with_transform: $command\n";
6815 open (FC_FILE, $file)
6816 || die "automake: installation error: cannot open \`$file'\n";
6818 # print "automake: reading $file\n" if $verbose;
6820 local ($was_rule) = 0;
6821 local ($result_vars) = '';
6822 local ($result_rules) = '';
6823 local ($comment) = '';
6824 local ($spacing) = "\n";
6825 local ($skipping) = 0;
6830 $_ =~ s/\@MAINTAINER_MODE_TRUE\@//g
6831 unless $seen_maint_mode;
6833 $had_chars = length ($_) && $_ ne "\n";
6835 # If the transform caused all the characters to go away, then
6836 # ignore the line. Why do this? Because in Perl 4, a "next"
6837 # inside of an eval doesn't affect a loop outside the eval.
6838 # So we can't pass in a "transform" that uses next. We used
6839 # to do this. "Empty" also means consisting of a single
6841 next if $had_chars && ($_ eq '' || $_ eq "\n");
6843 if (/$IGNORE_PATTERN/o)
6845 # Merely delete comments beginning with two hashes.
6847 elsif (/$WHITE_PATTERN/o)
6849 # Stick a single white line before the incoming macro or rule.
6851 &am_line_error ($., "blank line following trailing backslash")
6854 elsif (/$COMMENT_PATTERN/o)
6856 # Stick comments before the incoming macro or rule.
6857 $comment .= $spacing . $_;
6859 &am_line_error ($., "comment following trailing backslash")
6866 $result_rules .= $_ if ! $skipping;
6870 $result_vars .= $_ if ! $skipping;
6874 elsif (/$RULE_PATTERN/o)
6878 $skipping = defined $contents{$1};
6879 $result_rules .= $comment . $spacing . $_ if ! $skipping;
6880 $comment = $spacing = '';
6883 elsif (/$MACRO_PATTERN/o)
6885 # Found a variable reference.
6887 $skipping = defined $contents{$1};
6888 $result_vars .= $comment . $spacing . $_ if ! $skipping;
6889 $comment = $spacing = '';
6891 print STDERR "automake: programming error: .am macro \`$1' with trailing backslash\n"
6893 $am_var_defs{$1} = $3;
6897 # This isn't an error; it is probably a continued rule.
6898 # In fact, this is what we assume.
6900 $result_rules .= $comment . $spacing . $_ if ! $skipping;
6901 $comment = $spacing = '';
6907 return $result_vars . $result_rules . $comment;
6910 # Like file_contents_with_transform, but no transform.
6913 return &file_contents_with_transform ('', @_);
6916 # Find all variable prefixes that are used for install directories. A
6917 # prefix `zar' qualifies iff:
6918 # * `zardir' is a variable.
6919 # * `zar_PRIMARY' is a variable.
6920 sub am_primary_prefixes
6922 local ($primary, $can_dist, @prefixes) = @_;
6924 local (%valid, $varname);
6925 grep ($valid{$_} = 0, @prefixes);
6926 $valid{'EXTRA'} = 0;
6927 foreach $varname (keys %contents)
6929 if ($varname =~ /^(dist_|nodist_)?(.*)_$primary$/)
6931 if (($1 ne '' && ! $can_dist)
6932 || (! defined $valid{$2}
6933 && ! &variable_defined ($2 . 'dir')
6934 # Note that a configure variable is always
6935 # legitimate. It is natural to name such
6936 # variables after the primary, so we explicitly
6938 && ! defined $configure_vars{$varname}))
6940 &am_line_error ($varname, "invalid variable \`$varname'");
6944 # Ensure all extended prefixes are actually used.
6945 $valid{$1 . $2} = 1;
6953 # Handle `where_HOW' variable magic. Does all lookups, generates
6954 # install code, and possibly generates code to define the primary
6955 # variable. The first argument is the name of the .am file to munge,
6956 # the second argument is the primary variable (eg HEADERS), and all
6957 # subsequent arguments are possible installation locations. Returns
6958 # list of all values of all _HOW targets.
6960 # FIXME: this should be rewritten to be cleaner. It should be broken
6961 # up into multiple functions.
6963 # Usage is: am_install_var (OPTION..., file, HOW, where...)
6968 local ($do_clean) = 0;
6969 local ($do_require) = 1;
6970 local ($can_dist) = 0;
6971 local ($default_dist) = 0;
6974 if (defined $configure_vars{'LIBTOOL'})
6976 # Transform '@LIBTOOL ...@' to '$(LIBTOOL) ...'
6977 $ltxform = 's/\@LIBTOOL([^\@]*)\@/\$(LIBTOOL) $1/;';
6981 # Delete '@LIBTOOL ...@'
6982 $ltxform = 's/\@LIBTOOL([^\@]*)\@//;';
6988 $cygxform = 's/\@EXEEXT\@//g;';
6992 $cygxform = 's/\@EXEEXT\@/\$(EXEEXT)/g;';
6997 if ($args[0] eq '-clean')
7001 elsif ($args[0] eq '-noextra')
7005 elsif ($args[0] eq '-candist')
7009 elsif ($args[0] eq '-defaultdist')
7014 elsif ($args[0] !~ /^-/)
7021 local ($file, $primary, @prefixes) = @args;
7024 local (@result) = ();
7026 # Now that configure substitutions are allowed in where_HOW
7027 # variables, it is an error to actually define the primary. We
7028 # allow `JAVA', as it is customarily used to mean the Java
7029 # interpreter. This is but one of several Java hacks.
7030 &am_line_error ($primary, "\`$primary' is an anachronism")
7031 if &variable_defined ($primary) && $primary ne 'JAVA';
7034 # Look for misspellings. It is an error to have a variable ending
7035 # in a "reserved" suffix whose prefix is unknown, eg
7036 # "bni_PROGRAMS". However, unusual prefixes are allowed if a
7037 # variable of the same name (with "dir" appended) exists. For
7038 # instance, if the variable "zardir" is defined, then
7039 # "zar_PROGRAMS" becomes valid. This is to provide a little extra
7040 # flexibility in those cases which need it.
7041 local (%valid) = &am_primary_prefixes ($primary, $can_dist, @prefixes);
7043 # If a primary includes a configure substitution, then the EXTRA_
7044 # form is required. Otherwise we can't properly do our job.
7045 local ($require_extra);
7046 local ($warned_about_extra) = 0;
7048 local ($clean_file) = $file . '-clean';
7051 local ($nodir_name);
7052 foreach $X (sort keys %valid)
7054 $one_name = $X . '_' . $primary;
7055 if (&variable_defined ($one_name))
7057 # If files should be distributed, do so.
7060 if (($default_dist && $one_name !~ /^nodist_/)
7061 || (! $default_dist && $one_name =~ /^dist_/))
7063 &push_dist_common ('$(' . $one_name . ')');
7065 ($nodir_name = $X) =~ s/^(dist|nodist)_//;
7072 # Append actual contents of where_PRIMARY variable to
7075 foreach $rcurs (&variable_value_as_list ($one_name, 'all'))
7077 # Skip configure substitutions. Possibly bogus.
7078 if ($rcurs =~ /^\@.*\@$/)
7082 if (! $warned_about_extra)
7084 $warned_about_extra = 1;
7086 &am_line_error ($one_name,
7087 "\`$one_name' contains configure substitution, but shouldn't");
7091 # Check here to make sure variables defined in
7092 # configure.in do not imply that EXTRA_PRIMARY
7094 elsif (! defined $configure_vars{$one_name})
7096 $require_extra = $one_name
7103 push (@result, $rcurs);
7106 # "EXTRA" shouldn't be used when generating clean targets,
7107 # all, or install targets.
7110 # We used to warn if EXTRA_FOO was defined uselessly,
7111 # but this was annoying.
7115 # A blatant hack: we rewrite each _PROGRAMS primary to
7116 # include EXEEXT when in Cygwin32 mode.
7117 if ($seen_exeext && $primary eq 'PROGRAMS')
7119 local (@conds) = &variable_conditions ($one_name);
7120 local (@one_binlist);
7122 # FIXME: this definitely loses aesthetically; it
7123 # redefines $ONE_NAME. Instead we should arrange for
7124 # variable definitions to be output later, instead of
7130 foreach $rcurs (&variable_value_as_list ($one_name, ''))
7132 if ($rcurs =~ /\./ || $rcurs =~ /^\@.*\@$/)
7134 push (@one_binlist, $rcurs);
7138 push (@one_binlist, $rcurs . '$(EXEEXT)');
7142 delete $contents{$one_name};
7143 &define_pretty_variable ($one_name, '', @one_binlist);
7148 local ($condvals) = '';
7149 foreach $cond (@conds)
7152 local (@condval) = &variable_value_as_list ($one_name,
7154 foreach $rcurs (@condval)
7156 if ($rcurs =~ /\./ || $rcurs =~ /^\@.*\@$/)
7158 push (@one_binlist, $rcurs);
7162 push (@one_binlist, $rcurs . '$(EXEEXT)');
7166 push (@condvals, $cond);
7167 push (@condvals, join (' ', @one_binlist));
7170 delete $contents{$one_name};
7174 $cond = shift (@condvals);
7175 local (@val) = split (' ', shift (@condvals));
7176 &define_pretty_variable ($one_name, $cond, @val);
7184 &file_contents_with_transform ('s/\@DIR\@/' . $X . '/go;'
7188 push (@clean, $X . $primary);
7189 &push_phony_cleaners ($X . $primary);
7194 push (@check, '$(' . $one_name . ')');
7198 push (@used, '$(' . $one_name . ')');
7200 if ($X eq 'noinst' || $X eq 'check')
7202 # Objects which don't get installed by default.
7207 &file_contents_with_transform ('s/\@DIR\@/' . $X . '/g;'
7208 . 's/\@NDIR\@/' . $nodir_name . '/go;'
7209 . $ltxform . $cygxform,
7212 push (@uninstall, 'uninstall-' . $X . $primary);
7213 push (@phony, 'uninstall-' . $X . $primary);
7214 push (@installdirs, '$(DESTDIR)$(' . $X . 'dir)');
7215 if (defined $exec_dir_p{$X} ? $exec_dir_p{$X} : ($X =~ /exec/))
7217 push (@install_exec, 'install-' . $X . $primary);
7218 push (@phony, 'install-' . $X . $primary);
7222 push (@install_data, 'install-' . $X . $primary);
7223 push (@phony, 'install-' . $X . $primary);
7228 # The JAVA variable is used as the name of the Java interpreter.
7229 if (@used && $primary ne 'JAVA')
7232 &define_pretty_variable ($primary, '', @used);
7233 $output_vars .= "\n";
7236 if ($require_extra && ! &variable_defined ('EXTRA_' . $primary))
7238 &am_line_error ($require_extra,
7239 "\`$require_extra' contains configure substitution, but \`EXTRA_$primary' not defined");
7242 # Push here because PRIMARY might be configure time determined.
7243 push (@all, '$(' . $primary . ')')
7244 if @used && $primary ne 'JAVA';
7246 # Make the result unique. This lets the user use conditionals in
7247 # a natural way, but still lets us program lazily -- we don't have
7248 # to worry about handling a particular object more than once.
7249 local (%uniquify) = ();
7250 grep ($uniquify{$_} = 1, @result);
7251 return sort keys %uniquify;
7255 ################################################################
7257 # This variable is local to the "require file" set of functions.
7258 @require_file_paths = ();
7260 # Verify that the file must exist in the current directory. Usage:
7261 # require_file (isconfigure, line_number, strictness, file) strictness
7262 # is the strictness level at which this file becomes required. Must
7263 # set require_file_paths before calling this function.
7264 # require_file_paths is set to hold a single directory (the one in
7265 # which the first file was found) before return.
7266 sub require_file_internal
7268 local ($is_configure, $line, $mystrict, @files) = @_;
7269 local ($file, $fullfile);
7270 local ($found_it, $errfile, $errdir);
7273 foreach $file (@files)
7276 foreach $dir (@require_file_paths)
7280 $fullfile = $relative_dir . "/" . $file;
7281 $errdir = $relative_dir unless $errdir;
7285 $fullfile = $dir . "/" . $file;
7286 $errdir = $dir unless $errdir;
7289 # Use different name for "error filename". Otherwise on
7290 # an error the bad file will be reported as eg
7291 # `../../install-sh' when using the default
7293 $errfile = $errdir . '/' . $file;
7298 # FIXME: Once again, special-case `.'.
7299 &push_dist_common ($file)
7300 if $dir eq $relative_dir || $dir eq '.';
7308 # Prune the path list.
7309 @require_file_paths = $save_dir;
7313 if ($strictness >= $mystrict)
7315 local ($trailer) = '';
7316 local ($suppress) = 0;
7318 # Only install missing files according to our desired
7320 local ($message) = "required file \`$errfile' not found";
7325 # Maybe run libtoolize.
7327 && grep ($_ eq $file, @libtoolize_files)
7328 && system ('libtoolize', '--automake'))
7330 $message = "installing \`$errfile'";
7332 $trailer = "; cannot run \`libtoolize': $!";
7334 elsif (-f ($am_dir . '/' . $file))
7336 # Install the missing file. Symlink if we
7337 # can, copy if we must. Note: delete the file
7338 # first, in case it is a dangling symlink.
7339 $message = "installing \`$errfile'";
7340 # Windows Perl will hang if we try to delete a
7341 # file that doesn't exist.
7342 unlink ($errfile) if -f $errfile;
7343 if ($symlink_exists && ! $copy_missing)
7345 if (! symlink ($am_dir . '/' . $file, $errfile))
7348 $trailer = "; error while making link: $!\n";
7351 elsif (system ('cp', $am_dir . '/' . $file, $errfile))
7354 $trailer = "\n error while copying\n";
7359 local ($save) = $exit_status;
7362 # FIXME: allow actual file to be specified.
7363 &am_conf_line_error ('configure.in', $line,
7364 "$message$trailer");
7368 &am_line_error ($line, "$message$trailer");
7370 $exit_status = $save if $suppress;
7376 # Like require_file_with_line, but error messages refer to
7377 # configure.in, not the current Makefile.am.
7378 sub require_file_with_conf_line
7380 @require_file_paths = '.';
7381 &require_file_internal (1, @_);
7384 sub require_file_with_line
7386 @require_file_paths = '.';
7387 &require_file_internal (0, @_);
7392 @require_file_paths = '.';
7393 &require_file_internal (0, '', @_);
7396 # Require a file that is also required by Autoconf. Looks in
7397 # configuration path, as specified by AC_CONFIG_AUX_DIR.
7398 sub require_config_file
7400 @require_file_paths = @config_aux_path;
7401 &require_file_internal (1, '', @_);
7402 local ($dir) = $require_file_paths[0];
7403 @config_aux_path = @require_file_paths;
7406 $config_aux_dir = '.';
7410 $config_aux_dir = '$(top_srcdir)/' . $dir;
7414 # Assumes that the line number is in Makefile.am.
7415 sub require_conf_file_with_line
7417 @require_file_paths = @config_aux_path;
7418 &require_file_internal (0, @_);
7419 local ($dir) = $require_file_paths[0];
7420 @config_aux_path = @require_file_paths;
7423 $config_aux_dir = '.';
7427 $config_aux_dir = '$(top_srcdir)/' . $dir;
7431 # Assumes that the line number is in configure.in.
7432 sub require_conf_file_with_conf_line
7434 @require_file_paths = @config_aux_path;
7435 &require_file_internal (1, @_);
7436 local ($dir) = $require_file_paths[0];
7437 @config_aux_path = @require_file_paths;
7440 $config_aux_dir = '.';
7444 $config_aux_dir = '$(top_srcdir)/' . $dir;
7448 ################################################################
7450 # Push a list of files onto dist_common.
7451 sub push_dist_common
7453 local (@files) = @_;
7456 foreach $file (@files)
7458 $dist_common{$file} = 1;
7462 # Push a list of clean targets onto phony.
7463 sub push_phony_cleaners
7467 foreach $target ('mostly', 'dist', '', 'maintainer-')
7469 push (@phony, $target . 'clean-' . $base);
7476 $strictness_name = $_[0];
7477 if ($strictness_name eq 'gnu')
7481 elsif ($strictness_name eq 'gnits')
7483 $strictness = $GNITS;
7485 elsif ($strictness_name eq 'foreign')
7487 $strictness = $FOREIGN;
7491 die "automake: level \`$strictness_name' not recognized\n";
7496 ################################################################
7498 # Return directory name of file.
7504 ($sub = $file) =~ s,/+[^/]+$,,g;
7505 $sub = '.' if $sub eq $file;
7509 # Return file name of a file.
7515 ($sub = $file) =~s,^.*/+,,g;
7519 # Ensure a file exists.
7524 open (TOUCH, ">> $file");
7528 # Glob something. Do this to avoid indentation screwups everywhere we
7529 # want to glob. Gross!
7536 ################################################################
7538 # Print an error message and set exit status.
7541 warn "automake: ${am_file}.am: ", join (' ', @_), "\n";
7547 local ($symbol, @args) = @_;
7549 if ($symbol && "$symbol" ne '-1')
7551 local ($file) = "${am_file}.am";
7553 if ($symbol =~ /^\d+$/)
7555 # SYMBOL is a line number, so just add the colon.
7556 $file .= ':' . $symbol;
7558 elsif (defined $content_lines{$symbol})
7560 # SYMBOL is a variable defined in Makefile.am, so add the
7561 # line number we saved from there.
7562 $file .= ':' . $content_lines{$symbol};
7564 elsif (defined $configure_vars{$symbol})
7566 # SYMBOL is a variable defined in configure.in, so add the
7567 # appropriate line number.
7568 $file = $configure_vars{$symbol};
7572 # Couldn't find the line number.
7574 warn $file, ": ", join (' ', @args), "\n";
7583 # Like am_error, but while scanning configure.in.
7586 # FIXME: can run in subdirs.
7587 warn "automake: configure.in: ", join (' ', @_), "\n";
7591 # Error message with line number referring to configure.in.
7592 sub am_conf_line_error
7594 local ($file, $line, @args) = @_;
7598 warn "$file: $line: ", join (' ', @args), "\n";
7603 &am_conf_error (@args);
7607 # Warning message with line number referring to configure.in.
7608 # Does not affect exit_status
7609 sub am_conf_line_warning
7611 local ($saved_exit_status) = $exit_status;
7612 &am_conf_line_error (@_);
7613 $exit_status = $saved_exit_status;
7616 # Tell user where our aclocal.m4 is, but only once.
7617 sub keyed_aclocal_warning
7620 warn "automake: macro \`$key' can be generated by \`aclocal'\n";
7623 # Print usage information.
7626 print "Usage: automake [OPTION] ... [Makefile]...\n\n";
7627 print "Generate Makefile.in for autoconf from Makefile.am\n";
7629 print "\nFiles which are automatically distributed, if found:\n";
7630 $~ = "USAGE_FORMAT";
7631 local ($last, $iter, @lcomm);
7633 foreach $iter (sort ((@common_files, @common_sometimes)))
7635 push (@lcomm, $iter) unless $iter eq $last;
7639 local ($one, $two, $three, $four, $i, $max);
7640 $max = int (($#lcomm + 1) / 4);
7642 for ($i = 0; $i < $max; ++$i)
7645 $two = $lcomm[$max + $i];
7646 $three = $lcomm[2 * $max + $i];
7647 $four = $lcomm[3 * $max + $i];
7651 local ($mod) = ($#lcomm + 1) % 4;
7654 $one = $lcomm[$max];
7655 $two = ($mod > 1) ? $lcomm[2 * $max] : '';
7656 $three = ($mod > 2) ? $lcomm[3 * $max] : '';
7657 $four = ($mod > 3) ? $lcomm[4 * $max] : '';
7661 print "\nReport bugs to <bug-automake\@gnu.org>.\n";
7666 format USAGE_FORMAT =
7667 @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<
7668 $one, $two, $three, $four