5 eval 'exec @PERL@ -S $0 ${1+"$@"}'
8 # automake - create Makefile.in from Makefile.am
9 # Copyright (C) 1994, 1995, 1996, 1997, 1998 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@";
39 $IGNORE_PATTERN = "^##([^#].*)?\$";
40 $WHITE_PATTERN = "^[ \t]*\$";
41 $COMMENT_PATTERN = "^#";
42 $RULE_PATTERN = "^([\$a-zA-Z_.][-.a-zA-Z0-9_(){}/\$]*) *:([^=].*|)\$";
43 $SUFFIX_RULE_PATTERN = "^\\.([a-zA-Z]+)\\.([a-zA-Z]+)\$";
44 $MACRO_PATTERN = "^([A-Za-z][A-Za-z0-9_]*)[ \t]*:?=[ \t]*(.*)\$";
45 $BOGUS_MACRO_PATTERN = "^([^ \t]*)[ \t]*:?=[ \t]*(.*)\$";
46 $GNITS_VERSION_PATTERN = "[0-9]+\\.[0-9]+([a-z]|\\.[0-9]+)?";
47 $IF_PATTERN = "^if[ \t]+\([A-Za-z][A-Za-z0-9_]*\)[ \t]*\(#.*\)?\$";
48 $ELSE_PATTERN = "^else[ \t]*\(#.*\)?\$";
49 $ENDIF_PATTERN = "^endif[ \t]*\(#.*\)?\$";
51 # Some regular expressions. One reason to put them here is that it
52 # makes indentation work better in Emacs.
53 $AC_CONFIG_AUX_DIR_PATTERN = "AC_CONFIG_AUX_DIR\\(([^)]+)\\)";
54 $AM_INIT_AUTOMAKE_PATTERN = "AM_INIT_AUTOMAKE\\([^,]*,([^,)]+)[,)]";
55 $AM_PACKAGE_VERSION_PATTERN = "^\\s*\\[?([^]\\s]+)\\]?\\s*\$";
56 # Note that there is no AC_PATH_TOOL. But we don't really care.
57 $AC_CHECK_PATTERN = "AC_(CHECK|PATH)_(PROG|PROGS|TOOL)\\(\\[?(\\w+)";
58 $AM_MISSING_PATTERN = "AM_MISSING_PROG\\(\\[?(\\w+)";
59 # Just check for alphanumeric in AC_SUBST. If you do AC_SUBST(5),
61 $AC_SUBST_PATTERN = "AC_SUBST\\(\\[?(\\w+)";
62 $AM_CONDITIONAL_PATTERN = "AM_CONDITIONAL\\((\\w+)";
64 # Constants to define the "strictness" level.
71 # Variables global to entire run.
73 # TRUE if we should always generate Makefile.in.
74 $force_generation = 1;
76 # Strictness level as set on command line.
77 $default_strictness = $GNU;
79 # Name of strictness level, as set on command line.
80 $default_strictness_name = 'gnu';
82 # This is TRUE if GNU make specific automatic dependency generation
83 # code should be included in generated Makefile.in.
84 $cmdline_use_dependencies = 1;
86 # This is the name of a dependency makefile bit (usually for inclusion in a
87 # SMakefile or similar); empty if not set.
90 # TRUE if in verbose mode.
93 # This holds our (eventual) exit status. We don't actually exit until
94 # we have processed all input files.
97 # From the Perl manual.
98 $symlink_exists = (eval 'symlink ("", "");', $@ eq '');
100 # TRUE if missing standard files should be installed.
103 # TRUE if we should copy missing files; otherwise symlink if possible.
106 # Files found by scanning configure.in for LIBOBJS.
109 # True if AM_C_PROTOTYPES appears in configure.in.
110 $am_c_prototypes = 0;
112 # Names used in AC_CONFIG_HEADER call. @config_fullnames holds the
113 # name which appears in AC_CONFIG_HEADER, colon and all.
114 # @config_names holds the file names. @config_headers holds the '.in'
115 # files. Ordinarily these are similar, but they can be different if
116 # the weird "NAME:FILE" syntax is used.
117 @config_fullnames = ();
119 @config_headers = ();
120 # Line number at which AC_CONFIG_HEADER appears in configure.in.
121 $config_header_line = 0;
123 # Directory where output files go. Actually, output files are
124 # relative to this directory.
125 $output_directory = '.';
127 # Relative location of top build directory.
130 # Absolute location of top build directory.
131 $build_directory = '';
133 # Name of srcdir as given in build directory's Makefile. For
137 # List of Makefile.am's to process, and their corresponding outputs.
141 # List of files in AC_OUTPUT without Makefile.am, and their outputs.
142 @other_input_files = ();
143 # Line number at which AC_OUTPUT seen.
146 # List of directories to search for configure-required files. This
147 # can be set by AC_CONFIG_AUX_DIR.
148 @config_aux_path = ('.', '..', '../..');
149 $config_aux_dir = '';
151 # Whether AC_PROG_MAKE_SET has been seen in configure.in.
154 # Whether AM_GNU_GETTEXT has been seen in configure.in.
156 # Line number at which AM_GNU_GETTEXT seen.
157 $ac_gettext_line = 0;
159 # Whether ALL_LINGUAS has been seen.
163 # Line number at which it appears.
164 $all_linguas_line = 0;
166 # 1 if AC_PROG_INSTALL seen.
167 $seen_prog_install = 0;
169 # Whether AC_PATH_XTRA has been seen in configure.in.
172 # TRUE if AC_DECL_YYTEXT was seen.
173 $seen_decl_yytext = 0;
175 # TRUE if we've seen AC_CANONICAL_(HOST|SYSTEM). The presence of
176 # AC_CHECK_TOOL also sets this.
179 # TRUE if we've seen AC_ARG_PROGRAM.
182 # TRUE if we've seen AM_PROG_LIBTOOL.
186 # Files installed by libtoolize.
187 @libtoolize_files = ('ltconfig', 'ltmain.sh', 'config.guess', 'config.sub');
189 # TRUE if we've seen AM_MAINTAINER_MODE.
190 $seen_maint_mode = 0;
192 # TRUE if we've seen PACKAGE and VERSION.
196 # Actual version we've seen.
197 $package_version = '';
199 # Line number where we saw version definition.
200 $package_version_line = 0;
202 # TRUE if we've seen AM_PATH_LISPDIR.
205 # TRUE if we've seen AC_EXEEXT.
208 # TRUE if we've seen AC_OBJEXT.
211 # Hash table of discovered configure substitutions. Keys are names,
212 # values are meaningless.
213 %configure_vars = ();
215 # Charsets used by maintainer and in distribution. MAINT_CHARSET is
216 # handled in a funny way: if seen in the top-level Makefile.am, it is
217 # used for every directory which does not specify a different value.
218 # The rationale here is that some directories (eg gettext) might be
219 # distributions of other packages, and thus require their own charset
220 # info. However, the DIST_CHARSET must be the same for the entire
221 # package; it can only be set at top-level.
222 # FIXME: this yields bugs when rebuilding. What to do? Always
223 # read (and sometimes discard) top-level Makefile.am?
225 $dist_charset = 'utf8'; # recode doesn't support this yet.
227 # Name of input file ("Makefile.in") and output file ("Makefile.am").
228 # These have no directory components.
232 # TRUE if --cygnus seen.
235 # Keys of this hash are names of dependency files to ignore.
236 %omit_dependencies = ();
238 # Hash table of AM_CONDITIONAL variables seen in configure.
239 %configure_cond = ();
241 # Map from obsolete macros to hints for new macros.
242 # FIXME complete the list so that there are no `0' hints.
245 'AC_FEATURE_CTYPE', "use \`AC_HEADER_STDC'",
246 'AC_FEATURE_ERRNO', "add \`strerror' to \`AC_REPLACE_FUNCS(...)'",
247 'AC_FEATURE_EXIT', 0,
248 'AC_SYSTEM_HEADER', 0,
250 # Note that we do not handle this one, because it is still run
251 # from AM_CONFIG_HEADER. So we deal with it specially in
253 # 'AC_CONFIG_HEADER', "use \`AM_CONFIG_HEADER'",
255 'fp_C_PROTOTYPES', "use \`AM_C_PROTOTYPES'",
256 'fp_PROG_CC_STDC', "use \`AM_PROG_CC_STDC'",
257 'fp_PROG_INSTALL', "use \`AC_PROG_INSTALL'",
258 'fp_WITH_DMALLOC', "use \`AM_WITH_DMALLOC'",
259 'fp_WITH_REGEX', "use \`AM_WITH_REGEX'",
260 'gm_PROG_LIBTOOL', "use \`AM_PROG_LIBTOOL'",
261 'jm_MAINTAINER_MODE', "use \`AM_MAINTAINER_MODE'",
262 'md_TYPE_PTRDIFF_T', "use \`AM_TYPE_PTRDIFF_T'",
263 'ud_PATH_LISPDIR', "use \`AM_PATH_LISPDIR'",
265 # Now part of autoconf proper, under a different name.
266 'AM_FUNC_FNMATCH', "use \`AC_FUNC_FNMATCH'",
267 'fp_FUNC_FNMATCH', "use \`AC_FUNC_FNMATCH'",
268 'AM_SANITY_CHECK_CC', "automatically done by \`AC_PROG_CC'",
269 'AM_PROG_INSTALL', "use \`AC_PROG_INSTALL'",
270 'AM_EXEEEXT', "use \`AC_EXEEXT'",
271 'AM_CYGWIN32', "use \`AC_CYGWIN32'",
272 'AM_MINGW32', "use \`AC_MINGW32'",
274 # These aren't quite obsolete.
278 # Regexp to match the above macros.
279 $obsolete_rx = '(' . join ('|', keys %obsolete_macros) . ')';
283 &initialize_global_constants;
285 # Parse command line.
286 &parse_arguments (@ARGV);
288 # Do configure.in scan only once.
291 die "automake: no \`Makefile.am' found or specified\n"
294 # If --generate-deps was given, we don't do anything else
298 die "automake: Must specify --include-deps (or -i) when generating\n"
299 if ($use_dependencies);
300 die "automake: Must provide --build-dir when generating\n"
301 if (!$build_directory);
302 die "automake: Must provide --srcdir-name when generating\n"
305 open (GDEP, ">$output_directory/.dep_segment")
306 || die "automake: Could not open `$output_directory/.dep_segment': $!\n";
308 &handle_dependencies;
309 print GDEP $output_rules;
315 # Now do all the work on each file.
316 foreach $am_file (@input_files)
318 if (! -f ($am_file . '.am'))
320 &am_error ("\`" . $am_file . ".am' does not exist");
324 &generate_makefile ($output_files{$am_file}, $am_file);
328 &am_conf_error ("AC_PROG_INSTALL must be used in configure.in")
329 if (! $seen_prog_install);
334 ################################################################
336 # Parse command line.
339 local (@arglist) = @_;
342 &set_strictness ('gnu');
346 if ($arglist[0] eq "--version")
348 print "automake (GNU $PACKAGE) $VERSION\n\n";
349 print "Copyright (C) 1998 Free Software Foundation, Inc.\n";
350 print "This is free software; see the source for copying conditions. There is NO\n";
351 print "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n";
352 print "Written by Tom Tromey <tromey\@cygnus.com>\n";
356 elsif ($arglist[0] eq "--help")
360 elsif ($arglist[0] =~ /^--amdir=(.+)$/)
364 elsif ($arglist[0] eq '--amdir')
366 &require_argument (@arglist);
368 $am_dir = $arglist[0];
370 elsif ($arglist[0] =~ /^--build-dir=(.+)$/)
373 $build_directory = $1 . '/';
375 elsif ($arglist[0] eq '--build-dir')
377 &require_argument (@arglist);
380 $build_directory = $arglist[0] . '/';
382 elsif ($arglist[0] =~ /^--srcdir-name=(.+)$/)
386 elsif ($arglist[0] eq '--srcdir-name')
388 &require_argument (@arglist);
390 $srcdir_name = $arglist[0];
392 elsif ($arglist[0] eq '--gnu')
394 &set_strictness ('gnu');
396 elsif ($arglist[0] eq '--gnits')
398 &set_strictness ('gnits');
400 elsif ($arglist[0] eq '--cygnus')
404 elsif ($arglist[0] eq '--foreign')
406 &set_strictness ('foreign');
408 elsif ($arglist[0] eq '--include-deps' || $arglist[0] eq '-i')
410 $cmdline_use_dependencies = 0;
412 elsif ($arglist[0] eq '--generate-deps')
416 elsif ($arglist[0] eq '--no-force')
418 $force_generation = 0;
420 elsif ($arglist[0] =~ /^--output-dir=(.*)$/)
422 # Set output directory.
423 $output_directory = $1;
425 elsif ($arglist[0] eq '--output-dir' || $arglist[0] eq '-o')
427 &require_argument (@arglist);
429 $output_directory = $arglist[0];
431 elsif ($arglist[0] eq '--add-missing' || $arglist[0] eq '-a')
435 elsif ($arglist[0] eq '--copy' || $arglist[0] eq 'c')
439 elsif ($arglist[0] eq '--verbose' || $arglist[0] eq '-v')
443 elsif ($arglist[0] eq '--')
445 # Stop option processing.
447 push (@input_files, @arglist);
450 elsif ($arglist[0] =~ /^-/)
452 die "automake: unrecognized option -- \`$arglist[0]'\nTry \`automake --help' for more information.\n";
456 # Handle $local:$input syntax. Note that we only examine
457 # the first ":" file to see if it is automake input; the
458 # rest are just taken verbatim. We still keep all the
459 # files around for dependency checking, however.
460 local ($local, $input, @rest) = split (/:/, $arglist[0]);
467 # Strip .in; later on .am is tacked on. That is how
468 # the automake input file is found. Maybe not the
469 # best way, but it is easy to explain. FIXME: should
470 # be error if .in is missing.
473 push (@input_files, $input);
474 $output_files{$input} = join (':', ($local, @rest));
480 # Take global strictness from whatever we currently have set.
481 $default_strictness = $strictness;
482 $default_strictness_name = $strictness_name;
485 # Ensure argument exists, or die.
488 local ($arg, @arglist) = @_;
489 die "automake: no argument given for option \`$arg'\n"
493 ################################################################
495 # Generate a Makefile.in given the name of the corresponding Makefile and
496 # the name of the file output by config.status.
497 sub generate_makefile
499 local ($output, $makefile) = @_;
501 ($am_file_name = $makefile) =~ s/^.*\///;
502 $in_file_name = $am_file_name . '.in';
503 $am_file_name .= '.am';
505 # $OUTPUT is encoded. If it contains a ":" then the first element
506 # is the real output file, and all remaining elements are input
507 # files. We don't scan or otherwise deal with these input file,
508 # other than to mark them as dependencies. See scan_configure for
510 local (@secondary_inputs);
511 ($output, @secondary_inputs) = split (/:/, $output);
513 &initialize_per_input;
514 $relative_dir = &dirname ($output);
515 $am_relative_dir = &dirname ($makefile);
517 # At the toplevel directory, we might need config.guess, config.sub
518 # or libtool scripts (ltconfig and ltmain.sh).
519 if ($relative_dir eq '.')
521 # libtool requires some files.
522 &require_conf_file_with_conf_line ($libtool_line, $FOREIGN,
526 # AC_CANONICAL_HOST and AC_CANONICAL_SYSTEM need config.guess and
528 &require_config_file ($FOREIGN, 'config.guess', 'config.sub')
532 # We still need Makefile.in here, because sometimes the `dist'
533 # target doesn't re-run automake.
534 if ($am_relative_dir eq $relative_dir)
536 # Only distribute the files if they are in the same subdir as
537 # the generated makefile.
538 &push_dist_common ($in_file_name, $am_file_name);
540 push (@sources, '$(SOURCES)')
541 if &variable_defined ('SOURCES');
542 push (@objects, '$(OBJECTS)')
543 if &variable_defined ('OBJECTS');
545 &read_am_file ($makefile . '.am');
548 # Fatal error. Just return, so we can continue with next file.
552 # Check first, because we might modify some state.
554 &check_gnu_standards;
555 &check_gnits_standards;
557 &handle_configure ($output, $makefile, @secondary_inputs);
564 &handle_built_sources;
566 # This must be run after all the sources are scanned.
567 &handle_yacc_lex_cxx;
569 # Re-init SOURCES and OBJECTS. FIXME: other code shouldn't depend
570 # on this (but currently does).
571 $contents{'SOURCES'} = join (' ', @sources);
572 $contents{'OBJECTS'} = join (' ', @objects);
582 &handle_minor_options;
583 &handle_dist ($makefile);
584 &handle_dependencies;
587 &handle_merge_targets ($output);
594 if (! -d ($output_directory . '/' . $am_relative_dir))
596 mkdir ($output_directory . '/' . $am_relative_dir, 0755);
599 local ($out_file) = $output_directory . '/' . $makefile . ".in";
600 if (! $force_generation && -e $out_file)
602 local ($am_time) = (stat ($makefile . '.am'))[9];
603 local ($in_time) = (stat ($out_file))[9];
604 # FIXME: should cache these times.
605 local ($conf_time) = (stat ('configure.in'))[9];
606 # FIXME: how to do unsigned comparison?
607 if ($am_time < $in_time || $am_time < $conf_time)
614 local ($acl_time) = (stat _)[9];
615 return if ($am_time < $acl_time);
619 if (! open (GM_FILE, "> " . $out_file))
621 warn "automake: ${am_file}.in: cannot write: $!\n";
625 print "automake: creating ", $makefile, ".in\n" if $verbose;
627 print GM_FILE $output_vars;
628 # We make sure that `all:' is the first target.
629 print GM_FILE $output_all;
630 print GM_FILE $output_header;
631 print GM_FILE $output_rules;
632 print GM_FILE $output_trailer;
637 ################################################################
639 # Handle AUTOMAKE_OPTIONS variable. Return 1 on error, 0 otherwise.
642 if (&variable_defined ('AUTOMAKE_OPTIONS'))
644 foreach (&variable_value_as_list ('AUTOMAKE_OPTIONS', ''))
647 if ($_ eq 'gnits' || $_ eq 'gnu' || $_ eq 'foreign')
649 &set_strictness ($_);
651 elsif ($_ eq 'cygnus')
657 # An option like "../lib/ansi2knr" is allowed. With
658 # no path prefix, we assume the required programs are
659 # in this directory. We save the actual option for
661 $options{'ansi2knr'} = $_;
663 elsif ($_ eq 'no-installman' || $_ eq 'no-installinfo'
664 || $_ eq 'dist-shar' || $_ eq 'dist-zip'
665 || $_ eq 'dist-tarZ' || $_ eq 'dejagnu'
666 || $_ eq 'no-texinfo.tex'
667 || $_ eq 'readme-alpha' || $_ eq 'check-news')
669 # Explicitly recognize these.
671 elsif ($_ eq 'no-dependencies')
673 $use_dependencies = 0;
675 elsif (/([0-9]+)\.([0-9]+)([a-z])?/)
677 # Got a version number.
679 local ($rmajor, $rminor, $ralpha) = ($1, $2, $3);
681 if ($VERSION !~ /([0-9]+)\.([0-9]+)([a-z])?/)
684 "automake: programming error: version is incorrect\n";
687 local ($tmajor, $tminor, $talpha) = ($1, $2, $3);
689 # 2.0 is better than 1.0.
690 # 1.2 is better than 1.1.
691 # 1.2a is better than 1.2.
692 if ($rmajor > $tmajor
693 || ($rmajor == $tmajor && $rminor > $tminor)
694 || ($rminor == $tminor && $rminor == $tminor
695 && $ralpha gt $talpha))
697 &am_line_error ('AUTOMAKE_OPTIONS',
698 "require version $_, only have $VERSION");
704 &am_line_error ('AUTOMAKE_OPTIONS',
705 "option \`" . $_ . "\' not recognized");
710 if ($strictness == $GNITS)
712 $options{'readme-alpha'} = 1;
713 $options{'check-news'} = 1;
719 # Return object extension. Just once, put some code into the output.
720 # Argument is the name of the output file
721 sub get_object_extension
726 $dir_holds_sources = 1;
728 # Maybe require libtool library object files.
729 local ($extension) = '.o';
730 $extension = '.$(OBJEXT)' if $seen_objext;
731 $extension = '.lo' if ($out =~ /\.la$/);
733 if (! $included_generic_compile)
737 if (&variable_defined ('CONFIG_HEADER'))
740 foreach $one_hdr (split (' ', &variable_value ('CONFIG_HEADER')))
743 ($var = &dirname ($one_hdr)) =~ s/(\W)/\\$1/g;
744 $xform .= ' ' if $xform;
745 $xform .= '-I' . $var;
748 $xform = 's/\@CONFIG_INCLUDE_SPEC\@/' . $xform . '/go;';
749 $output_vars .= &file_contents_with_transform ($xform,
752 $xform = (($use_dependencies
753 ? 's/^NOTDEPEND.*$//;'
755 . ($seen_objext ? 's/^OBJEXT//;' : 's/^OBJEXT.*$//;'));
756 $output_rules .= &file_contents_with_transform ($xform, 'compile');
758 &push_phony_cleaners ('compile');
760 # If using X, include some extra variable definitions. NOTE
761 # we don't want to force these into CFLAGS or anything,
762 # because not all programs will necessarily use X.
766 foreach $var ('X_CFLAGS', 'X_LIBS', 'X_EXTRA_LIBS', 'X_PRE_LIBS')
768 &define_configure_variable ($var);
772 push (@suffixes, '.c', '.o', '.S', '.s');
773 push (@suffixes, '.obj') if $seen_objext;
774 push (@clean, 'compile');
776 $included_generic_compile = 1;
779 if ($seen_libtool && ! $included_libtool_compile)
781 # Output the libtool compilation rules.
783 &file_contents_with_transform
784 ($use_dependencies ? 's/^NOTDEPEND.*$//;' : 's/^NOTDEPEND//;',
787 &push_phony_cleaners ('libtool');
789 push (@suffixes, '.lo');
790 push (@clean, 'libtool');
792 $included_libtool_compile = 1;
795 # Check for automatic de-ANSI-fication.
796 if (defined $options{'ansi2knr'})
798 $extension = '$U' . $extension;
799 if (! $included_knr_compile)
801 if (! $am_c_prototypes)
803 &am_line_error ('AUTOMAKE_OPTIONS',
804 "option \`ansi2knr' in use but \`AM_C_PROTOTYPES' not in configure.in");
805 &keyed_aclocal_warning ('AM_C_PROTOTYPES');
806 # Only give this error once.
807 $am_c_prototypes = 1;
810 # Only require ansi2knr files if they should appear in
812 if ($options{'ansi2knr'} eq 'ansi2knr')
814 &require_file_with_line ('AUTOMAKE_OPTIONS', $FOREIGN,
815 'ansi2knr.c', 'ansi2knr.1');
816 $output_rules .= &file_contents ('kr-extra');
817 push (@clean, 'krextra');
818 &push_phony_cleaners ('krextra');
821 # Generate rules to build ansi2knr. If it is in some
822 # other directory, then generate dependencies but have the
823 # rule just run elsewhere.
824 $objext = $seen_objext ? ".$(OBJEXT)" : ".o";
825 $output_rules .= ($options{'ansi2knr'} . ': '
826 . $options{'ansi2knr'} . $objext . "\n");
827 if ($options{'ansi2knr'} eq 'ansi2knr')
829 $output_rules .= ("\t\$(LINK) ansi2knr" . $objext
831 . "ansi2knr" . $objext
832 . ": \$(CONFIG_HEADER)\n\n");
836 $output_rules .= ("\tcd " . &dirname ($options{'ansi2knr'})
837 . " && \$(MAKE) \$(AM_MAKEFLAGS) "
839 # This is required for non-GNU makes.
840 $output_rules .= ($options{'ansi2knr'} . $objext . ":\n");
841 $output_rules .= ("\tcd " . &dirname ($options{'ansi2knr'})
842 . " && \$(MAKE) \$(AM_MAKEFLAGS)"
843 . " ansi2knr" . $objext . "\n\n");
846 # Make sure ansi2knr can be found: if no path specified,
848 if ($options{'ansi2knr'} eq 'ansi2knr')
850 # Substitution from AM_C_PROTOTYPES. This makes it be
851 # built only when necessary.
852 &define_configure_variable ('ANSI2KNR');
853 # ansi2knr needs to be built before subdirs, so unshift it.
854 unshift (@all, '$(ANSI2KNR)');
858 # Found in another directory.
859 &define_variable ("ANSI2KNR", $options{'ansi2knr'});
862 $output_rules .= &file_contents ('clean-kr');
865 &push_phony_cleaners ('kr');
867 $included_knr_compile = 1;
874 # Handle yacc and lex.
875 sub handle_yacc_lex_cxx
878 # First do yacc and lex.
881 local ($yacc_count) = scalar (keys %yacc_sources);
882 local ($lex_count) = scalar (keys %lex_sources);
886 local ($file, $base, $hname, $cname);
887 local (%seen_suffix) = ();
888 foreach $file (keys %yacc_sources)
891 &output_yacc_build_rule ($1, $yacc_count > 1)
892 if (! defined $seen_suffix{$1});
893 $seen_suffix{$1} = 1;
895 # Now generate rule to make the header file. This should
896 # only be generated if `yacc -d' specified. But right now
897 # there is no way to determine that. FIXME: the
898 # AM_FOOFLAGS idea would suffice here.
899 $file =~ /^(.*)\.(y|yy|y\+\+|yxx)$/;
901 ($hname = $2) =~ tr/y/h/;
902 ($cname = $2) =~ tr/y/c/;
903 $output_rules .= "${base}.${hname}: ${base}.${cname}\n";
905 # If the files are built in the build directory, then we
906 # want to remove them with `make clean'. If they are in
907 # srcdir they shouldn't be touched. However, we can't
908 # determine this statically, and the GNU rules say that
909 # yacc/lex output files should be removed by
910 # maintainer-clean. So that's what we do.
911 push (@maintainer_clean_files, $base . $hname, $base . $cname);
913 $output_rules .= "\n";
915 if (! defined $configure_vars{'YACC'})
917 &am_error ("yacc source seen but \`YACC' not defined in \`configure.in'");
919 if (&variable_defined ('YACCFLAGS'))
921 &am_line_error ('YACCFLAGS',
922 "\`YACCFLAGS' obsolete; use \`YFLAGS' instead");
927 local (%seen_suffix) = ();
928 local ($file, $cname);
929 foreach $file (keys %lex_sources)
932 &output_lex_build_rule ($1, $lex_count > 1)
933 if (! defined $seen_suffix{$1});
934 $seen_suffix{$1} = 1;
936 # If the files are built in the build directory, then we
937 # want to remove them with `make clean'. If they are in
938 # srcdir they shouldn't be touched. However, we can't
939 # determine this statically, and the GNU rules say that
940 # yacc/lex output files should be removed by
941 # maintainer-clean. So that's what we do.
942 $file =~ /^(.*)\.(l|ll|l\+\+|lxx)$/;
943 ($cname = $2) =~ tr/y/c/;
944 push (@maintainer_clean_files, $1 . $cname);
947 if (! defined $configure_vars{'LEX'})
949 &am_error ("lex source seen but \`LEX' not defined in \`configure.in'");
951 if (! $seen_decl_yytext)
953 &am_error ("lex source seen but \`AC_DECL_YYTEXT' not in \`configure.in'");
957 if ($yacc_count > 1 || $lex_count > 1)
959 # If there is more than one distinct yacc (resp lex) source
960 # file in a given directory, then the `ylwrap' program is
961 # required to allow parallel builds to work correctly. FIXME:
962 # for now, no line number.
963 &require_config_file ($FOREIGN, 'ylwrap');
964 if ($config_aux_dir ne '.' && $config_aux_dir ne '')
966 &define_variable ('YLWRAP', $config_aux_dir . "/ylwrap");
970 &define_variable ('YLWRAP', '$(srcdir)/ylwrap');
977 local ($ltcompile, $ltlink) = ('', '');
980 &define_configure_variable ("LIBTOOL");
981 $ltcompile = '$(LIBTOOL) --mode=compile ';
982 $ltlink = '$(LIBTOOL) --mode=link ';
988 local (@cxx_list) = keys %cxx_extensions;
989 local ($cxx_count) = scalar @cxx_list;
992 push (@suffixes, @cxx_list);
994 &define_configure_variable ("CXXFLAGS");
995 &define_variable ('CXXCOMPILE', '$(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)');
996 &define_variable ('LTCXXCOMPILE',
997 $ltcompile . '$(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)')
1000 &define_variable ('CXXLINK', $ltlink . '$(CXX) $(AM_CXXFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@');
1003 foreach $ext (@cxx_list)
1005 $output_rules .= ("$ext.o:\n"
1006 . "\t\$(CXXCOMPILE) -c \$<\n");
1007 # FIXME: Using cygpath should be somehow conditional.
1008 $output_rules .= ("$ext.obj:\n"
1009 . "\t\$(CXXCOMPILE) -c `cygpath -w \$<`\n")
1011 $output_rules .= ("$ext.lo:\n"
1012 . "\t\$(LTCXXCOMPILE) -c \$<\n")
1016 if (! defined $configure_vars{'CXX'})
1018 &am_error ("C++ source seen but \`CXX' not defined in \`configure.in'");
1023 # Handle some ansi2knr cleanup.
1026 # Push all libobjs files onto de_ansi_files. We actually only
1027 # push files which exist in the current directory, and which are
1028 # genuine source files.
1030 foreach $file (keys %libsources)
1032 if ($file =~ /^(.*)\.[cly]$/ && -f "$relative_dir/$file")
1034 $de_ansi_files{$1} = 1;
1038 if (defined $options{'ansi2knr'} && keys %de_ansi_files)
1040 # Make all _.c files depend on their corresponding .c files.
1041 local ($base, @objects);
1042 foreach $base (sort (keys %de_ansi_files))
1044 # Each _.c file must depend on ansi2knr; otherwise it
1045 # might be used in a parallel build before it is built.
1046 # We need to support files in the srcdir and in the build
1047 # dir (because these files might be auto-generated. But
1048 # we can't use $< -- some makes only define $< during a
1050 $output_rules .= ($base . "_.c: $base.c \$(ANSI2KNR)\n\t"
1051 . '$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) '
1052 . '`if test -f $(srcdir)/' . $base . '.c'
1053 . '; then echo $(srcdir)/' . $base . '.c'
1054 . '; else echo ' . $base . '.c; fi` '
1055 . "| sed 's/^# \\([0-9]\\)/#line \\1/' "
1056 . '| $(ANSI2KNR) > ' . $base . "_.c\n");
1057 push (@objects, $base . '_'
1058 . ($seen_objext ? '.$(OBJEXT)' : '.o'));
1059 push (@objects, $base . '_.lo') if $seen_libtool;
1062 # Make all _.o (and _.lo) files depend on ansi2knr.
1063 # Use a sneaky little hack to make it print nicely.
1064 &pretty_print_rule ('', '', @objects, ':', '$(ANSI2KNR)');
1068 # Last, handle some C cleanup.
1070 if ($seen_any_source)
1072 &define_configure_variable ('CFLAGS');
1073 &define_variable ('COMPILE',
1074 '$(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)');
1075 &define_variable ('LTCOMPILE',
1077 '$(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)')
1079 &define_variable ('LINK', $ltlink . '$(CC) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@');
1082 if ($seen_c_source && ! defined $configure_vars{'CC'})
1084 &am_line_error ($seen_c_source,
1085 "C source seen but \`CC' not defined in \`configure.in'");
1090 # Output a rule to build from a YACC source. The output from YACC is
1091 # compiled with C or C++, depending on the extension of the YACC file.
1092 sub output_yacc_build_rule
1094 local ($yacc_suffix, $use_ylwrap, $c_suffix) = @_;
1097 ($suffix = $yacc_suffix) =~ tr/y/c/;
1098 push (@suffixes, $yacc_suffix, $suffix);
1100 # Generate rule for c/c++.
1101 $output_rules .= "$yacc_suffix$suffix:\n\t";
1105 $output_rules .= ('$(SHELL) $(YLWRAP)'
1106 . ' "$(YACC)" $< y.tab.c $*' . $suffix
1107 . ' y.tab.h $*.h -- $(AM_YFLAGS) $(YFLAGS)');
1111 $output_rules .= ('$(YACC) $(AM_YFLAGS) $(YFLAGS) $< && mv y.tab.c $*'
1113 . "\tif test -f y.tab.h; then \\\n"
1114 . "\tif cmp -s y.tab.h \$*.h; then rm -f y.tab.h; else mv y.tab.h \$*.h; fi; \\\n"
1117 $output_rules .= "\n";
1120 sub output_lex_build_rule
1122 local ($lex_suffix, $use_ylwrap) = @_;
1125 ($c_suffix = $lex_suffix) =~ tr/l/c/;
1126 push (@suffixes, $lex_suffix);
1127 &define_configure_variable ('LEX_OUTPUT_ROOT');
1128 &define_configure_variable ('LEXLIB');
1129 $output_rules .= "$lex_suffix$c_suffix:\n\t";
1133 # Is the $@ correct here? If so, why not use it in the ylwrap
1134 # build rule for yacc above?
1135 $output_rules .= '$(SHELL) $(YLWRAP)'
1136 . ' "$(LEX)" $< $(LEX_OUTPUT_ROOT).c $@ -- $(AM_LFLAGS) $(LFLAGS)';
1140 $output_rules .= '$(LEX) $(AM_LFLAGS) $(LFLAGS) $< && mv $(LEX_OUTPUT_ROOT).c $@';
1142 $output_rules .= "\n";
1146 # Check to make sure a source defined in LIBOBJS is not explicitly
1147 # mentioned. This is a separate function (as opposed to being inlined
1148 # in handle_source_transform) because it isn't always appropriate to
1150 sub check_libobjs_sources
1152 local ($one_file, $unxformed) = @_;
1154 local ($prefix, $file, @files);
1155 foreach $prefix ('', 'EXTRA_')
1157 if (&variable_defined ($prefix . $one_file . '_SOURCES'))
1159 @files = &variable_value_as_list (($prefix
1160 . $one_file . '_SOURCES'),
1163 elsif ($prefix eq '')
1165 @files = ($unxformed . '.c');
1172 foreach $file (@files)
1174 if (defined $libsources{$file})
1176 &am_line_error ($prefix . $one_file . '_SOURCES',
1177 "automatically discovered file \`$file' should not be explicitly mentioned");
1183 # Does much of the actual work for handle_source_transform.
1185 # pattern matching object extension (e.g., .o)
1186 # list of source files to transform
1188 # first element is name of linker to use (empty string for default linker)
1189 # remaining elements are names of `.o's
1190 sub handle_single_transform_list
1192 local ($objpat, @files) = @_;
1193 local ($linker) = '';
1194 local (@result) = ();
1195 local ($nonansi_obj) = $obj;
1196 $nonansi_obj =~ s/_//g;
1199 # Turn sources into objects.
1202 # Skip header files, including C++-ish ones. The list
1203 # of C++ header extensions comes from Emacs 19.32
1210 # Skip things that look like configure substitutions.
1213 # Include appropriate file for lex or yacc source in
1214 # distribution. If the extension is the regular '.y' or
1215 # '.l', we assume C compilation, and the generated file
1216 # has exension .c. Otherwise, we compile with C++, and
1217 # make the following association: (yy -> cc, y++ -> c++,
1218 # yxx -> cxx), similarly for .ll, etc.
1219 if (/^(.*)\.(y|yy|y\+\+|yxx)$/)
1224 &push_dist_common ("$1.$ext");
1225 $yacc_sources{$_} = 1;
1227 elsif (/^(.*)\.(l|ll|l\+\+|lxx)$/)
1232 &push_dist_common ("$1.$ext");
1233 $lex_sources{$_} = 1;
1236 # Strip any directory prefix.
1237 $_ = &basename ($_);
1239 local ($is_cxx) = 0;
1240 # Transform source files into .o files. List of C++
1241 # extensions comes from Emacs 19.34 etags.
1242 if (s/\.(c\+\+|cc|cpp|cxx|C)$/$nonansi_obj/)
1244 $cxx_extensions{'.' . $1} = 1;
1245 $linker = 'CXXLINK';
1248 elsif (s/\.(yy|y\+\+|yxx|ll|l\+\+|lxx)$/$nonansi_obj/)
1250 # Compiling lex or yacc with C++
1253 $cxx_extensions{".$ext"} = 1;
1254 $linker = 'CXXLINK';
1256 elsif (s/\.([Ff]|f90|for)$/$nonansi_obj/)
1258 # FORTRAN support. FIXME: not finished.
1260 elsif (s/\.[sS]$/$nonansi_obj/)
1262 # .s is assembly. Just rewrite it. FIXME: not finished.
1264 elsif (defined ($options{'ansi2knr'}) && s/_\.[cly]$/_.c/)
1266 # FIXME include line number in error.
1267 &am_error ("C source file \`$_' would be deleted by ansi2knr rules");
1269 elsif (s/\.[cly]$//)
1271 # .c is C. .l is lex. .y is yacc.
1273 # Note: first we rewrite (eg) foo.c to foo and push
1274 # the file onto the list of deansified files. Then we add
1275 # $obj, which can either be `_.o', or simply `.o' if
1276 # deansification is not required.
1277 $de_ansi_files{$_} = 1;
1281 elsif (/\.$source_suffix_pattern$/)
1283 # We just rewrite it. Maybe we should do more.
1284 s//.$suffix_rules{$1}/;
1285 $objpat = "\\." . $suffix_rules{$1};
1289 # No error message here. Used to have one, but it was
1294 $seen_any_source = 1 unless $is_cxx;
1297 # Transform .o or $o file into .P file (for automatic
1300 $dep_files{'.deps/' . $_} = 1;
1304 return ($linker, @result);
1307 # Handle SOURCE->OBJECT transform for one program or library.
1309 # canonical (transformed) name of object to build
1310 # actual name of object to build
1311 # object extension (ie either `.o' or `$o'.
1312 # Return result is name of linker variable that must be used.
1313 # Empty return means just use `LINK'.
1314 sub handle_source_transform
1316 # one_file is canonical name. unxformed is given name. obj is
1318 local ($one_file, $unxformed, $obj) = @_;
1319 local ($objpat) = $obj;
1320 $objpat =~ s/(\W)/\\$1/g;
1321 # Handle explicit `.o' as well as whatever we're passed.
1322 $objpat = '(' . $objpat . "|\\.o)";
1324 local ($linker) = '';
1326 if (&variable_defined ($one_file . "_OBJECTS"))
1328 &am_line_error ($one_file . '_OBJECTS',
1329 $one_file . '_OBJECTS', 'should not be defined');
1330 # No point in continuing.
1334 local (@files, @result, $prefix, $temp);
1335 foreach $prefix ('', 'EXTRA_')
1338 local ($var) = $prefix . $one_file . "_SOURCES";
1339 if (&variable_defined ($var))
1341 push (@sources, '$(' . $prefix . $one_file . "_SOURCES)");
1342 push (@objects, '$(' . $prefix . $one_file . "_OBJECTS)")
1343 unless $prefix eq 'EXTRA_';
1344 local (@conds) = &variable_conditions ($var);
1347 @files = &variable_value_as_list ($var, '');
1352 foreach $cond (@conds)
1354 @files = &variable_value_as_list ($var, $cond);
1355 ($temp, @result) = &handle_single_transform_list ($objpat,
1357 $linker = $temp if $linker eq '';
1359 # Define _OBJECTS conditionally.
1360 &define_pretty_variable ($one_file . '_OBJECTS', $cond,
1362 unless $prefix eq 'EXTRA_';
1368 elsif ($prefix eq '')
1370 &define_variable ($one_file . "_SOURCES", $unxformed . ".c");
1371 push (@sources, $unxformed . '.c');
1372 push (@objects, $unxformed . $obj);
1373 push (@files, $unxformed . '.c');
1376 ($temp, @result) = &handle_single_transform_list ($objpat, @files);
1377 $linker = $temp if $linker eq '';
1378 &define_pretty_variable ($one_file . "_OBJECTS", '', @result)
1379 unless $prefix eq 'EXTRA_';
1385 # Handle the BUILT_SOURCES variable.
1386 sub handle_built_sources
1388 return unless &variable_defined ('BUILT_SOURCES');
1390 local (@sources) = &variable_value_as_list ('BUILT_SOURCES', 'all');
1392 foreach $s (@sources)
1396 # FIXME: is this really the right thing to do?
1397 &am_line_error ('BUILT_SOURCES',
1398 "\`BUILT_SOURCES' should not contain a configure substitution");
1403 # We don't care about the return value of this function. We just
1404 # want to make sure to update %dep_files with the contents of
1406 &handle_single_transform_list ("\\.o", @sources);
1409 # Special-case @ALLOCA@ and @LIBOBJS@ in _LDADD or _LIBADD variables.
1410 # Also, generate _DEPENDENCIES variable if appropriate.
1412 # transformed name of object being built, or empty string if no object
1413 # name of _LDADD/_LIBADD-type variable to examine
1414 # boolean (lex_seen) which is true if a lex source file was seen in this
1415 # object. valid only for LDADDs, not LIBADDs.
1416 # Returns 1 if LIBOBJS seen, 0 otherwise.
1417 sub handle_lib_objects
1419 local ($xname, $var, $lex_seen) = @_;
1422 die "automake: programming error 1 in handle_lib_objects\n"
1423 if ! &variable_defined ($var);
1425 die "automake: programming error 2 in handle_lib_objects\n"
1426 if $lex_seen && $var =~ /LIBADD/;
1428 local (@conds) = &variable_conditions ($var);
1431 $ret = &handle_lib_objects_cond ($xname, $var, $lex_seen, '');
1437 foreach $cond (@conds)
1439 if (&handle_lib_objects_cond ($xname, $var, $lex_seen, $cond))
1449 # Subroutine of handle_lib_objects: handle a particular condition.
1450 sub handle_lib_objects_cond
1452 local ($xname, $var, $lex_seen, $cond) = @_;
1454 # We recognize certain things that are commonly put in LIBADD or
1457 local (@dep_list) = ();
1459 local ($seen_libobjs) = 0;
1460 local ($flagvar) = 0;
1462 foreach $lsearch (&variable_value_as_list ($var, $cond))
1464 # Skip -lfoo and -Ldir; these are explicitly allowed.
1465 next if $lsearch =~ /^-[lL]/;
1466 if (! $flagvar && $lsearch =~ /^-/)
1468 if ($var =~ /^(.*)LDADD$/)
1470 &am_line_error ($var, "linker flags such as \`$lsearch' belong in \`${1}LDFLAGS");
1474 # Only get this error once.
1476 &am_line_error ($var, "you cannot use linker flags such as \`$lsearch' in \`$var'");
1480 # Assume we have a file of some sort, and push it onto the
1481 # dependency list. Autoconf substitutions are not pushed;
1482 # rarely is a new dependency substituted into (eg) foo_LDADD
1483 # -- but "bad things (eg -lX11) are routinely substituted.
1484 # Note that LIBOBJS and ALLOCA are exceptions to this rule,
1485 # and handled specially below.
1486 push (@dep_list, $lsearch)
1487 unless $lsearch =~ /^\@.*\@$/;
1489 # Automatically handle @LIBOBJS@ and @ALLOCA@. Basically this
1490 # means adding entries to dep_files.
1491 if ($lsearch =~ /^\@(LT)?LIBOBJS\@$/)
1493 push (@dep_list, $lsearch);
1495 if (! keys %libsources)
1497 &am_line_error ($var, "\@$1" . "LIBOBJS\@ seen but never set in \`configure.in'");
1500 local ($iter, $rewrite);
1501 foreach $iter (keys %libsources)
1503 if ($iter =~ /\.[cly]$/)
1505 $seen_c_source = $var;
1506 $seen_any_source = 1;
1509 if ($iter =~ /\.h$/)
1511 &require_file_with_line ($var, $FOREIGN, $iter);
1513 elsif ($iter ne 'alloca.c')
1515 ($rewrite = $iter) =~ s/\.c$/.P/;
1516 $dep_files{'.deps/' . $rewrite} = 1;
1517 &require_file_with_line ($var, $FOREIGN, $iter);
1521 elsif ($lsearch =~ /^\@(LT)?ALLOCA\@$/)
1523 push (@dep_list, $lsearch);
1524 &am_line_error ($var,
1525 "\@$1" . "ALLOCA\@ seen but \`AC_FUNC_ALLOCA' not in \`configure.in'")
1526 if ! defined $libsources{'alloca.c'};
1527 $dep_files{'.deps/alloca.P'} = 1;
1528 &require_file_with_line ($var, $FOREIGN, 'alloca.c');
1529 $seen_c_source = $var;
1530 $seen_any_source = 1;
1534 if ($xname ne '' && ! &variable_defined ($xname . '_DEPENDENCIES', $cond))
1536 &define_pretty_variable ($xname . '_DEPENDENCIES', $cond, @dep_list);
1539 return $seen_libobjs;
1542 # Canonicalize a name, and check to make sure the non-canonical name
1543 # is never used. Returns canonical name. Arguments are name and a
1544 # list of suffixes to check for.
1545 sub check_canonical_spelling
1547 local ($name, @suffixes) = @_;
1548 local ($xname, $xt);
1550 ($xname = $name) =~ tr/A-Za-z0-9_/_/c;
1551 if ($xname ne $name)
1554 foreach $xt (@suffixes)
1556 &am_line_error ($name . $xt,
1557 "invalid variable \`" . $name . $xt
1558 . "'; should be \`" . $xname . $xt . "'")
1559 if &variable_defined ($name . $xt);
1566 # Handle C programs.
1569 local (@proglist) = &am_install_var ('-clean',
1570 'progs', 'PROGRAMS',
1571 'bin', 'sbin', 'libexec', 'pkglib',
1573 return if ! @proglist;
1575 # If a program is installed, this is required. We only want this
1576 # error to appear once.
1577 &am_conf_error ("AC_ARG_PROGRAM must be used in configure.in")
1578 unless $seen_arg_prog;
1581 local ($one_file, $xname, $munge);
1583 local ($seen_libobjs) = 0;
1584 foreach $one_file (@proglist)
1586 local ($obj) = &get_object_extension ($one_file);
1588 # Canonicalize names and check for misspellings.
1589 $xname = &check_canonical_spelling ($one_file, '_LDADD', '_LDFLAGS',
1590 '_SOURCES', '_OBJECTS',
1593 # FIXME: Using a trick to figure out if any lex sources appear
1594 # in our program; should use some cleaner method.
1595 local ($lex_num) = scalar (keys %lex_sources);
1596 local ($linker) = &handle_source_transform ($xname, $one_file, $obj);
1597 local ($lex_file_seen) = (scalar (keys %lex_sources) > $lex_num);
1600 if (&variable_defined ($xname . "_LDADD"))
1602 if (&handle_lib_objects ($xname, $xname . '_LDADD',
1612 # User didn't define prog_LDADD override. So do it.
1613 &define_variable ($xname . '_LDADD', '$(LDADD)');
1615 # This does a bit too much work. But we need it to
1616 # generate _DEPENDENCIES when appropriate.
1617 if (&variable_defined ('LDADD'))
1619 if (&handle_lib_objects ($xname, 'LDADD', $lex_file_seen))
1625 elsif (! &variable_defined ($xname . '_DEPENDENCIES'))
1627 &define_variable ($xname . '_DEPENDENCIES', '');
1632 if (&variable_defined ($xname . '_LIBADD'))
1634 &am_line_error ($xname . '_LIBADD',
1635 "use \`" . $xname . "_LDADD', not \`"
1636 . $xname . "_LIBADD'");
1639 if (! &variable_defined ($xname . '_LDFLAGS'))
1641 # Define the prog_LDFLAGS variable.
1642 &define_variable ($xname . '_LDFLAGS', '');
1645 # Determine program to use for link.
1647 if (&variable_defined ($xname . '_LINK'))
1649 $xlink = $xname . '_LINK';
1653 $xlink = $linker ? $linker : 'LINK';
1657 if ($seen_exeext && $one_file !~ /\./)
1659 $xexe = 's/\@EXEEXT\@/\$(EXEEXT)/g;';
1663 $xexe = 's/\@EXEEXT\@//g;';
1667 &file_contents_with_transform
1668 ('s/\@PROGRAM\@/' . $one_file . '/go;'
1669 . 's/\@XPROGRAM\@/' . $xname . '/go;'
1670 . 's/\@XLINK\@/' . $xlink . '/go;'
1675 if (&variable_defined ('LDADD') && &handle_lib_objects ('', 'LDADD', 0))
1682 foreach $one_file (@proglist)
1684 # Canonicalize names.
1685 ($xname = $one_file) =~ tr/A-Za-z0-9_/_/c;
1687 if (&variable_defined ($xname . '_LDADD'))
1689 &check_libobjs_sources ($xname, $xname . '_LDADD');
1691 elsif (&variable_defined ('LDADD'))
1693 &check_libobjs_sources ($xname, 'LDADD');
1701 sub handle_libraries
1703 local (@liblist) = &am_install_var ('-clean',
1704 'libs', 'LIBRARIES',
1705 'lib', 'pkglib', 'noinst', 'check');
1706 return if ! @liblist;
1708 local (%valid) = &am_primary_prefixes ('LIBRARIES', 'lib', 'pkglib',
1710 if (! defined $configure_vars{'RANLIB'})
1713 foreach $key (keys %valid)
1715 if (&variable_defined ($key . '_LIBRARIES'))
1717 &am_line_error ($key . '_LIBRARIES', "library used but \`RANLIB' not defined in \`configure.in'");
1718 # Only get this error once.
1719 $configure_vars{'RANLIB'} = 1;
1728 local ($seen_libobjs) = 0;
1729 foreach $onelib (@liblist)
1731 # Check that the library fits the standard naming convention.
1732 if ($onelib !~ /^lib.*\.a$/)
1734 # FIXME should put line number here. That means mapping
1735 # from library name back to variable name.
1736 &am_error ("\`$onelib' is not a standard library name");
1739 local ($obj) = &get_object_extension ($onelib);
1741 # Canonicalize names and check for misspellings.
1742 $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_SOURCES',
1743 '_OBJECTS', '_DEPENDENCIES');
1745 if (&variable_defined ($xlib . '_LIBADD'))
1747 if (&handle_lib_objects ($xlib, $xlib . '_LIBADD', 0))
1754 # Generate support for conditional object inclusion in
1756 &define_variable ($xlib . "_LIBADD", '');
1759 if (&variable_defined ($xlib . '_LDADD'))
1761 &am_line_error ($xlib . '_LDADD',
1762 "use \`" . $xlib . "_LIBADD', not \`"
1763 . $xlib . "_LDADD'");
1766 # Make sure we at look at this.
1767 &examine_variable ($xlib . '_DEPENDENCIES');
1769 &handle_source_transform ($xlib, $onelib, $obj);
1772 &file_contents_with_transform ('s/\@LIBRARY\@/' . $onelib . '/go;'
1780 foreach $onelib (@liblist)
1782 # Canonicalize names.
1783 ($xlib = $onelib) =~ tr/A-Za-z0-9_/_/c;
1784 if (&variable_defined ($xlib . '_LIBADD'))
1786 &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
1791 &define_variable ('AR', 'ar');
1792 &define_configure_variable ('RANLIB');
1795 # Handle shared libraries.
1796 sub handle_ltlibraries
1798 local (@liblist) = &am_install_var ('-clean',
1799 'ltlib', 'LTLIBRARIES',
1801 return if ! @liblist;
1804 local (%valid) = &am_primary_prefixes ('LTLIBRARIES', 'lib', 'pkglib');
1807 foreach $key (keys %valid)
1809 if (&variable_defined ($key . '_LTLIBRARIES'))
1813 &am_line_error ($key . '_LTLIBRARIES', "library used but \`LIBTOOL' not defined in \`configure.in'");
1814 # Only get this error once.
1815 $configure_vars{'LIBTOOL'} = 1;
1819 # Get the installation directory of each library.
1820 for (&variable_value_as_list ($key . '_LTLIBRARIES', 'all'))
1824 &am_error ("\`$_' is already going to be installed in \`$instdirs{$_}'");
1828 $instdirs{$_} = $key;
1837 local ($seen_libobjs) = 0;
1838 foreach $onelib (@liblist)
1840 # Check that the library fits the standard naming convention.
1841 if ($onelib !~ /^lib.*\.la$/)
1843 # FIXME this should only be a warning for foreign packages
1844 # FIXME should put line number here. That means mapping
1845 # from library name back to variable name.
1846 &am_error ("\`$onelib' is not a standard libtool library name");
1849 local ($obj) = &get_object_extension ($onelib);
1851 # Canonicalize names and check for misspellings.
1852 $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_LDFLAGS',
1853 '_SOURCES', '_OBJECTS',
1856 if (! &variable_defined ($xlib . '_LDFLAGS'))
1858 # Define the lib_LDFLAGS variable.
1859 &define_variable ($xlib . '_LDFLAGS', '');
1862 if (&variable_defined ($xlib . '_LIBADD'))
1864 if (&handle_lib_objects ($xlib, $xlib . '_LIBADD', 0))
1871 # Generate support for conditional object inclusion in
1873 &define_variable ($xlib . "_LIBADD", '');
1876 if (&variable_defined ($xlib . '_LDADD'))
1878 &am_line_error ($xlib . '_LDADD',
1879 "use \`" . $xlib . "_LIBADD', not \`"
1880 . $xlib . "_LDADD'");
1883 # Make sure we at look at this.
1884 &examine_variable ($xlib . '_DEPENDENCIES');
1886 local ($linker) = &handle_source_transform ($xlib, $onelib, $obj);
1888 # Determine program to use for link.
1890 if (&variable_defined ($xlib . '_LINK'))
1892 $xlink = $xlib . '_LINK';
1896 $xlink = $linker ? $linker : 'LINK';
1900 if ($instdirs{$onelib} eq 'EXTRA')
1902 # It's an EXTRA_ library, so we can't specify -rpath,
1903 # because we don't know where the library will end up.
1904 # The user probably knows, but generally speaking automake
1905 # doesn't -- and in fact configure could decide
1906 # dynamically between two different locations.
1907 $rpath = 's/\@RPATH\@//go;';
1911 $rpath = ('s/\@RPATH\@/-rpath \$(' . $instdirs{$onelib}
1916 &file_contents_with_transform ('s/\@LTLIBRARY\@/'
1918 . 's/\@XLTLIBRARY\@/'
1921 . 's/\@XLINK\@/' . $xlink . '/go;',
1927 foreach $onelib (@liblist)
1929 # Canonicalize names.
1930 ($xlib = $onelib) =~ tr/A-Za-z0-9_/_/c;
1931 if (&variable_defined ($xlib . '_LIBADD'))
1933 &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
1939 # See if any _SOURCES variable were misspelled. Also, make sure that
1940 # EXTRA_ variables don't contain configure substitutions.
1943 local ($varname, $primary);
1944 foreach $varname (keys %contents)
1946 foreach $primary ('_SOURCES', '_LIBADD', '_LDADD', '_LDFLAGS',
1949 if ($varname =~ /$primary$/ && ! $content_seen{$varname})
1951 &am_line_error ($varname,
1952 "invalid unused variable name: \`$varname'");
1961 # NOTE we no longer automatically clean SCRIPTS, because it is
1962 # useful to sometimes distribute scripts verbatim. This happens
1963 # eg in Automake itself.
1964 &am_install_var ('scripts', 'SCRIPTS',
1965 'bin', 'sbin', 'libexec', 'pkgdata',
1968 local ($scripts_installed) = 0;
1969 # Set $scripts_installed if appropriate. Make sure we only find
1970 # scripts which are actually installed -- this is why we can't
1971 # simply use the return value of am_install_var.
1972 local (%valid) = &am_primary_prefixes ('SCRIPTS', 'bin', 'sbin',
1973 'libexec', 'pkgdata',
1976 foreach $key (keys %valid)
1978 if ($key ne 'noinst'
1980 && &variable_defined ($key . '_SCRIPTS'))
1982 $scripts_installed = 1;
1983 # push (@check_tests, 'check-' . $key . 'SCRIPTS');
1987 if ($scripts_installed)
1989 # If a program is installed, this is required. We only want this
1990 # error to appear once.
1991 &am_conf_error ("AC_ARG_PROGRAM must be used in configure.in")
1992 unless $seen_arg_prog;
1997 # Search a file for a "version.texi" Texinfo include. Return the name
1998 # of the include file if found, or the empty string if not. A
1999 # "version.texi" file is actually any file whose name matches
2001 sub scan_texinfo_file
2003 local ($filename) = @_;
2005 if (! open (TEXI, $filename))
2007 &am_error ("couldn't open \`$filename': $!");
2010 print "automake: reading $filename\n" if $verbose;
2012 local ($vfile, $outfile);
2015 if (/^\@setfilename +(\S+)/)
2021 if (/^\@include\s+(vers[^.]*\.texi)\s*$/)
2023 # Found version.texi include.
2030 return ($outfile, $vfile);
2033 # Handle all Texinfo source.
2036 &am_line_error ('TEXINFOS',
2037 "\`TEXINFOS' is an anachronism; use \`info_TEXINFOS'")
2038 if &variable_defined ('TEXINFOS');
2039 return if (! &variable_defined ('info_TEXINFOS')
2040 && ! &variable_defined ('html_TEXINFOS'));
2042 local (@texis) = &variable_value_as_list ('info_TEXINFOS', 'all');
2044 local (@info_deps_list, @dvis_list, @texi_deps);
2045 local ($infobase, $info_cursor);
2049 local ($tc_cursor, @texi_cleans);
2052 foreach $info_cursor (@texis)
2054 # FIXME: This is mildly hacky, since it recognizes "txinfo".
2055 # I don't feel like making it right.
2056 ($infobase = $info_cursor) =~ s/\.te?xi(nfo)?$//;
2058 # If 'version.texi' is referenced by input file, then include
2059 # automatic versioning capability.
2060 local ($out_file, $vtexi) = &scan_texinfo_file ($relative_dir
2061 . "/" . $info_cursor);
2063 if ($out_file eq '')
2065 &am_error ("\`$info_cursor' missing \@setfilename");
2069 if ($out_file =~ /\.(.+)$/ && $1 ne 'info')
2071 # FIXME should report line number in input file.
2072 &am_error ("output of \`$info_cursor', \`$out_file', has unrecognized extension");
2078 &am_error ("\`$vtexi', included in \`$info_cursor', also included in \`$versions{$vtexi}'")
2079 if (defined $versions{$vtexi});
2080 $versions{$vtexi} = $info_cursor;
2082 # We number the stamp-vti files. This is doable since the
2083 # actual names don't matter much. We only number starting
2084 # with the second one, so that the common case looks nice.
2085 $vti = 'vti' . ($done ? $done : '');
2086 &push_dist_common ($vtexi, 'stamp-' . $vti);
2087 push (@clean, $vti);
2089 # Only require once.
2090 &require_conf_file_with_line ('info_TEXINFOS', $FOREIGN,
2096 ($conf_pat = $config_aux_dir) =~ s/(\W)/\\$1/g;
2098 &file_contents_with_transform
2099 ('s/\@TEXI\@/' . $info_cursor . '/g; '
2100 . 's/\@VTI\@/' . $vti . '/g; '
2101 . 's/\@VTEXI\@/' . $vtexi . '/g;'
2102 . 's,\@MDDIR\@,' . $conf_pat . ',g;',
2105 &push_phony_cleaners ($vti);
2108 # If user specified file_TEXINFOS, then use that as explicit
2111 push (@texi_deps, $info_cursor);
2112 push (@texi_deps, $vtexi) if $vtexi;
2114 # Canonicalize name first.
2115 ($canonical = $infobase) =~ tr/A-Za-z0-9_/_/c;
2116 if (&variable_defined ($canonical . "_TEXINFOS"))
2118 push (@texi_deps, '$(' . $canonical . '_TEXINFOS)');
2119 &push_dist_common ('$(' . $canonical . '_TEXINFOS)');
2122 $output_rules .= ("\n" . $out_file . ": "
2123 . join (' ', @texi_deps)
2124 . "\n" . $infobase . ".dvi: "
2125 . join (' ', @texi_deps)
2128 push (@info_deps_list, $out_file);
2129 push (@dvis_list, $infobase . '.dvi');
2131 # Generate list of things to clean for this target. We do
2132 # this explicitly because otherwise too many things could be
2133 # removed. In particular the ".log" extension might
2134 # reasonably be used in other contexts by the user.
2135 foreach $tc_cursor ('aux', 'cp', 'cps', 'dvi', 'fn', 'fns',
2136 'ky', 'kys', 'ps', 'log', 'pg', 'toc', 'tp', 'tps',
2137 'vr', 'vrs', 'op', 'tr', 'cv', 'cn')
2139 push (@texi_cleans, $infobase . '.' . $tc_cursor);
2143 # Find these programs wherever they may lie. Yes, this has
2144 # intimate knowledge of the structure of the texinfo distribution.
2145 &define_program_variable ('MAKEINFO', 'build', 'texinfo/makeinfo',
2147 # Circumlocution to avoid accidental
2148 # configure substitution.
2150 &define_program_variable ('TEXI2DVI', 'src', 'texinfo/util',
2153 # Set transform for including texinfos.am. First, handle --cygnus
2158 $xform = 's/^NOTCYGNUS.*$//; s/^CYGNUS//;';
2162 $xform = 's/^CYGNUS.*$//; s/^NOTCYGNUS//;';
2165 # Handle location of texinfo.tex.
2166 local ($need_texi_file) = 0;
2169 &define_variable ('TEXINFO_TEX',
2170 '$(top_srcdir)/../texinfo/texinfo.tex');
2172 elsif ($config_aux_dir ne '.' && $config_aux_dir ne '')
2174 &define_variable ('TEXINFO_TEX', $config_aux_dir . '/texinfo.tex');
2176 elsif (&variable_defined ('TEXINFO_TEX'))
2178 # The user defined TEXINFO_TEX so assume he knows what he is
2183 $need_texi_file = 1;
2185 local ($xxform) = &dirname (&variable_value ('TEXINFO_TEX'));
2186 $xxform =~ s/(\W)/\\$1/g;
2187 $xform .= ' s/\@TEXINFODIR\@/' . $xxform . '/g;';
2189 $output_rules .= &file_contents_with_transform ($xform, 'texinfos');
2190 push (@phony, 'install-info-am', 'uninstall-info');
2191 push (@dist_targets, 'dist-info');
2193 # How to clean. The funny name is due to --cygnus influence; in
2194 # Cygnus mode, `clean-info' is a target that users can use.
2195 $output_rules .= "\nmostlyclean-aminfo:\n";
2196 &pretty_print_rule ("\t-rm -f", "\t ", @texi_cleans);
2197 $output_rules .= ("\nclean-aminfo:\n\ndistclean-aminfo:\n\n"
2198 . "maintainer-clean-aminfo:\n\t"
2199 # Eww. But how else can we find all the output
2200 # files from makeinfo?
2201 . 'for i in $(INFO_DEPS); do' . " \\\n"
2202 . "\t" . ' rm -f $$i;' . " \\\n"
2203 . "\t" . ' if test "`echo $$i-[0-9]*`" != "$$i-[0-9]*"; then' . " \\\n"
2204 . "\t" . ' rm -f $$i-[0-9]*;' . " \\\n"
2205 . "\t" . ' fi;' . " \\\n"
2207 &push_phony_cleaners ('aminfo');
2210 $output_rules .= "clean-info: mostlyclean-aminfo\n";
2213 push (@suffixes, '.texi', '.texinfo', '.txi', '.info', '.dvi', '.ps');
2215 if (! defined $options{'no-installinfo'})
2217 push (@uninstall, 'uninstall-info');
2218 push (@installdirs, '$(DESTDIR)$(infodir)');
2219 unshift (@install_data, 'install-info-am');
2221 # Make sure documentation is made and installed first. Use
2222 # $(INFO_DEPS), not 'info', because otherwise recursive makes
2223 # get run twice during "make all".
2224 unshift (@all, '$(INFO_DEPS)');
2226 push (@clean, 'aminfo');
2227 push (@info, '$(INFO_DEPS)');
2228 push (@dvi, '$(DVIS)');
2230 &define_variable ("INFO_DEPS", join (' ', @info_deps_list));
2231 &define_variable ("DVIS", join (' ', @dvis_list));
2232 # This next isn't strictly needed now -- the places that look here
2233 # could easily be changed to look in info_TEXINFOS. But this is
2234 # probably better, in case noinst_TEXINFOS is ever supported.
2235 &define_variable ("TEXINFOS", &variable_value ('info_TEXINFOS'));
2237 # Do some error checking. Note that this file is not required
2238 # when in Cygnus mode; instead we defined TEXINFO_TEX explicitly
2240 &require_file_with_line ('info_TEXINFOS', $FOREIGN, 'texinfo.tex')
2241 if $need_texi_file && ! defined $options{'no-texinfo.tex'};
2244 # Handle any man pages.
2245 sub handle_man_pages
2247 &am_line_error ('MANS', "\`MANS' is an anachronism; use \`man_MANS'")
2248 if &variable_defined ('MANS');
2249 return if ! &variable_defined ('man_MANS');
2251 # Find all the sections in use. We do this by first looking for
2252 # "standard" sections, and then looking for any additional
2253 # sections used in man_MANS.
2254 local ($sect, %sections, %vlist);
2255 # Add more sections as needed.
2256 foreach $sect ('0'..'9', 'n', 'l')
2258 if (&variable_defined ('man' . $sect . '_MANS'))
2260 $sections{$sect} = 1;
2261 $vlist{'$(man' . $sect . '_MANS)'} = 1;
2265 if (&variable_defined ('man_MANS'))
2267 $vlist{'$(man_MANS)'} = 1;
2268 foreach (&variable_value_as_list ('man_MANS', 'all'))
2270 # A page like `foo.1c' goes into man1dir.
2271 if (/\.([0-9a-z])([a-z]*)$/)
2279 # Now for each section, generate an install and unintall rule.
2280 # Sort sections so output is deterministic.
2282 foreach $sect (sort keys %sections)
2284 &define_variable ('man' . $sect . 'dir', '$(mandir)/man' . $sect);
2285 push (@installdirs, '$(DESTDIR)$(mandir)/man' . $sect)
2286 unless defined $options{'no-installman'};
2287 $output_rules .= &file_contents_with_transform ('s/\@SECTION\@/'
2290 push (@phony, 'install-man' . $sect, 'uninstall-man' . $sect);
2291 push (@namelist, 'install-man' . $sect);
2294 # We don't really need this, but we use it in case we ever want to
2295 # support noinst_MANS.
2296 &define_variable ("MANS", join (' ', sort keys %vlist));
2298 # Generate list of install dirs.
2299 $output_rules .= ("install-man: \$(MANS)\n"
2300 . "\t\@\$(NORMAL_INSTALL)\n");
2301 &pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ", @namelist);
2302 push (@phony, 'install-man');
2304 $output_rules .= "uninstall-man:\n\t\@\$(NORMAL_UNINSTALL)\n";
2305 grep ($_ = 'un' . $_, @namelist);
2306 &pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ", @namelist);
2307 push (@phony, 'uninstall-man');
2309 $output_vars .= &file_contents ('mans-vars');
2311 if (! defined $options{'no-installman'})
2313 push (@install_data, 'install-man');
2314 push (@uninstall, 'uninstall-man');
2315 push (@all, '$(MANS)');
2319 # Handle DATA variables.
2322 &am_install_var ('data', 'DATA', 'data', 'sysconf',
2323 'sharedstate', 'localstate', 'pkgdata',
2330 push (@phony, 'tags');
2331 local (@tag_deps) = ();
2332 if (&variable_defined ('SUBDIRS'))
2334 $output_rules .= ("tags-recursive:\n"
2335 . "\tlist=\'\$(SUBDIRS)\'; for subdir in \$\$list; do \\\n"
2336 # Never fail here if a subdir fails; it
2338 . "\t test \"\$\$subdir\" = . || (cd \$\$subdir"
2339 . " && \$(MAKE) \$(AM_MAKEFLAGS) tags); \\\n"
2341 push (@tag_deps, 'tags-recursive');
2342 push (@phony, 'tags-recursive');
2345 if ($dir_holds_sources
2346 || $dir_holds_headers
2347 || &variable_defined ('ETAGS_ARGS')
2350 local ($xform) = '';
2352 foreach $one_hdr (@config_headers)
2354 if ($relative_dir eq &dirname ($one_hdr))
2356 # The config header is in this directory. So require it.
2358 ($var = &basename ($one_hdr)) =~ s/(\W)/\\$1/g;
2359 $xform .= ' ' if $xform;
2363 $xform = ('s/\@CONFIG\@/' . $xform . '/;'
2364 . 's/\@DIRS\@/' . join (' ', @tag_deps) . '/;');
2366 if (&variable_defined ('SUBDIRS'))
2368 $xform .= 's/^SUBDIRS//;';
2372 $xform .= 's/^SUBDIRS.*$//;';
2375 $output_rules .= &file_contents_with_transform ($xform, 'tags');
2376 $output_rules .= &file_contents ('tags-clean');
2377 push (@clean, 'tags');
2378 &push_phony_cleaners ('tags');
2379 &examine_variable ('TAGS_DEPENDENCIES');
2381 elsif (&variable_defined ('TAGS_DEPENDENCIES'))
2383 &am_line_error ('TAGS_DEPENDENCIES',
2384 "doesn't make sense to define \`TAGS_DEPENDENCIES' without sources or \`ETAGS_ARGS'");
2388 # Every Makefile must define some sort of TAGS rule.
2389 # Otherwise, it would be possible for a top-level "make TAGS"
2390 # to fail because some subdirectory failed.
2391 $output_rules .= "tags: TAGS\nTAGS:\n\n";
2395 # Worker for handle_dist.
2396 sub handle_dist_worker
2398 local ($makefile) = @_;
2400 $output_rules .= 'distdir: $(DISTFILES)' . "\n";
2402 # Initialization; only at top level.
2403 if ($relative_dir eq '.')
2405 if (defined $options{'check-news'})
2407 # For Gnits users, this is pretty handy. Look at 15 lines
2408 # in case some explanatory text is desirable.
2409 $output_rules .= ' @if sed 15q $(srcdir)/NEWS | fgrep -e "$(VERSION)" > /dev/null; then :; else \\
2410 echo "NEWS not updated; not releasing" 1>&2; \\
2417 # Create dist directory.
2418 $output_rules .= ("\t-rm -rf \$(distdir)\n"
2419 . "\tmkdir \$(distdir)\n"
2420 . "\t-chmod 777 \$(distdir)\n");
2423 # Only run automake in `dist' target if --include-deps and
2424 # `no-dependencies' not specified. That way the recipient of a
2425 # distribution can run "make dist" and not need Automake. You
2426 # might be wondering why we run automake once for each directory
2427 # we distribute, instead of running it once at the top level. The
2428 # answer is that we want to run automake after the dependencies
2429 # have been generated. This occurs when "make" is run in the
2430 # subdir. So automake must be run after make has updated the
2431 # Makefile, which means that it must run once per directory.
2432 if ($use_dependencies)
2436 # There are several directories we need to know about
2437 # when rebuilding the Makefile.ins. They are:
2438 # here - The absolute path to our topmost build directory.
2439 # top_distdir - The absolute path to the top of our dist
2441 # distdir - The path to our sub-part of the dist hierarchy.
2442 # If this directory is the topmost directory, we set
2443 # top_distdir from distdir; that lets us pass in distdir
2444 # from an enclosing package.
2445 "\t" . 'here=`cd $(top_builddir) && pwd`; ' . "\\\n"
2446 . "\t" . 'top_distdir=`cd $('
2447 . (($relative_dir eq '.') ? 'distdir' : 'top_distdir')
2448 . ') && pwd`; ' . "\\\n"
2449 . "\t" . 'distdir=`cd $(distdir) && pwd`; ' . "\\\n"
2450 . "\tcd \$(top_srcdir) \\\n"
2451 . "\t && \$(AUTOMAKE) --include-deps --build-dir=\$\$here --srcdir-name=\$(top_srcdir) --output-dir=\$\$top_distdir "
2452 # Set strictness of output.
2453 . ($cygnus_mode ? '--cygnus' : ('--' . $strictness_name))
2454 . ($cmdline_use_dependencies ? '' : ' --include-deps')
2455 . " " . $makefile . "\n"
2459 # Scan EXTRA_DIST to see if we need to distribute anything from a
2460 # subdir. If so, add it to the list. I didn't want to do this
2461 # originally, but there were so many requests that I finally
2464 if (&variable_defined ('EXTRA_DIST'))
2466 # FIXME: This should be fixed to work with conditionals. That
2467 # will require only making the entries in @dist_dirs under the
2468 # appropriate condition. This is meaningful if the nature of
2469 # the distribution should depend upon the configure options
2471 foreach (&variable_value_as_list ('EXTRA_DIST', ''))
2474 next unless s,/+[^/]+$,,;
2475 push (@dist_dirs, $_)
2481 # Prepend $(distdir) to each directory given. Doing it via a
2482 # hash lets us ensure that each directory is used only once.
2484 grep ($dhash{'$(distdir)/' . $_} = 1, @dist_dirs);
2485 $output_rules .= "\t";
2486 &pretty_print_rule ('$(mkinstalldirs)', "\t ", sort keys %dhash);
2489 # In loop, test for file existence because sometimes a file gets
2490 # included in DISTFILES twice. For example this happens when a
2491 # single source file is used in building more than one program.
2492 # Also, there are situations in which "ln" can fail. For instance
2493 # a file to distribute could actually be a cross-filesystem
2494 # symlink -- this can easily happen if "gettextize" was run on the
2496 $output_rules .= "\t\@for file in \$(DISTFILES); do \\\n";
2499 $output_rules .= "\t if test -f \$\$file; then d=.; else d=\$(srcdir); fi; \\\n";
2503 $output_rules .= "\t d=\$(srcdir); \\\n";
2505 $output_rules .= ("\t if test -d \$\$d/\$\$file; then \\\n"
2506 . "\t cp -pr \$\$/\$\$file \$(distdir)/\$\$file; \\\n"
2508 . "\t test -f \$(distdir)/\$\$file \\\n"
2509 . "\t || ln \$\$d/\$\$file \$(distdir)/\$\$file 2> /dev/null \\\n"
2510 . "\t || cp -p \$\$d/\$\$file \$(distdir)/\$\$file; \\\n"
2514 # If we have SUBDIRS, create all dist subdirectories and do
2516 if (&variable_defined ('SUBDIRS'))
2518 # If SUBDIRS is conditionally defined, then set DIST_SUBDIRS
2519 # to all possible directories, and use it. If DIST_SUBDIRS is
2520 # defined, just use it.
2521 local ($dist_subdir_name);
2522 if (&variable_conditions ('SUBDIRS')
2523 || &variable_defined ('DIST_SUBDIRS'))
2525 $dist_subdir_name = 'DIST_SUBDIRS';
2526 if (! &variable_defined ('DIST_SUBDIRS'))
2528 &define_pretty_variable ('DIST_SUBDIRS', '',
2529 &variable_value_as_list ('SUBDIRS',
2535 $dist_subdir_name = 'SUBDIRS';
2538 # Test for directory existence here because previous automake
2539 # invocation might have created some directories. Note that
2540 # we explicitly set distdir for the subdir make; that lets us
2541 # mix-n-match many automake-using packages into one large
2542 # package, and have "dist" at the top level do the right
2543 # thing. If we're in the topmost directory, then we use
2544 # `distdir' instead of `top_distdir'; this lets us work
2545 # correctly with an enclosing package.
2547 ("\t" . 'for subdir in $(' . $dist_subdir_name . '); do ' . "\\\n"
2548 . "\t" . ' if test "$$srcdir" = .; then :; else ' . "\\\n"
2549 . "\t" . ' test -d $(distdir)/$$subdir ' . "\\\n"
2550 . "\t" . ' || mkdir $(distdir)/$$subdir ' . "\\\n"
2551 . "\t" . ' || exit 1; ' . "\\\n"
2552 . "\t" . ' chmod 777 $(distdir)/$$subdir; ' . "\\\n"
2553 . "\t" . ' (cd $$subdir'
2554 . ' && $(MAKE) $(AM_MAKEFLAGS) top_distdir=../$('
2555 . (($relative_dir eq '.') ? 'distdir' : 'top_distdir')
2556 . ') distdir=../$(distdir)/$$subdir distdir) ' . "\\\n"
2557 . "\t" . ' || exit 1; ' . "\\\n"
2558 . "\t" . ' fi; ' . "\\\n"
2562 # If the target `dist-hook' exists, make sure it is run. This
2563 # allows users to do random weird things to the distribution
2564 # before it is packaged up.
2565 push (@dist_targets, 'dist-hook') if &target_defined ('dist-hook');
2568 foreach $targ (@dist_targets)
2570 # We must explicitly set distdir and top_distdir for these
2572 $output_rules .= ("\t\$(MAKE) \$(AM_MAKEFLAGS)"
2573 . " top_distdir=\"\$(top_distdir)\""
2574 . " distdir=\"\$(distdir)\" $targ\n");
2577 push (@phony, 'distdir');
2580 # Handle 'dist' target.
2583 local ($makefile) = @_;
2585 # Set up maint_charset.
2586 $local_maint_charset = &variable_value ('MAINT_CHARSET')
2587 if &variable_defined ('MAINT_CHARSET');
2588 $maint_charset = $local_maint_charset
2589 if $relative_dir eq '.';
2591 if (&variable_defined ('DIST_CHARSET'))
2593 &am_line_error ('DIST_CHARSET',
2594 "DIST_CHARSET defined but no MAINT_CHARSET defined")
2595 if ! $local_maint_charset;
2596 if ($relative_dir eq '.')
2598 $dist_charset = &variable_value ('DIST_CHARSET')
2602 &am_line_error ('DIST_CHARSET',
2603 "DIST_CHARSET can only be defined at top level");
2607 # Look for common files that should be included in distribution.
2609 foreach $cfile (@common_files)
2611 if (-f ($relative_dir . "/" . $cfile))
2613 &push_dist_common ($cfile);
2617 # Keys of %dist_common are names of files to distributed. We put
2618 # README first because it then becomes easier to make a
2619 # Usenet-compliant shar file (in these, README must be first).
2620 # FIXME: do more ordering of files here.
2622 if (defined $dist_common{'README'})
2624 push (@coms, 'README');
2625 delete $dist_common{'README'};
2627 push (@coms, sort keys %dist_common);
2629 &define_pretty_variable ("DIST_COMMON", '', @coms);
2630 $output_vars .= "\n";
2633 $output_vars .= &file_contents ('dist-vars') . "\n";
2634 &define_variable ('TAR', $TAR);
2635 &define_variable ('GZIP', '--best');
2637 # Put these things in rules section so it is easier for whoever
2638 # reads Makefile.in.
2639 if (! &variable_defined ('distdir'))
2641 if ($relative_dir eq '.')
2643 $output_rules .= "\n" . 'distdir = $(PACKAGE)-$(VERSION)' . "\n";
2647 $output_rules .= ("\n"
2648 . 'distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)'
2652 if ($relative_dir eq '.')
2654 $output_rules .= "top_distdir = \$(distdir)\n\n";
2658 $output_rules .= "\nsubdir = " . $relative_dir . "\n\n";
2661 # Generate 'dist' target, and maybe dist-shar / dist-zip / dist-tarZ.
2662 if ($relative_dir eq '.')
2664 # Rule to check whether a distribution is viable.
2665 $output_rules .= ('# This target untars the dist file and tries a VPATH configuration. Then
2666 # it guarantees that the distribution is self-contained by making another
2670 GZIP=$(GZIP) $(TAR) zxf $(distdir).tar.gz
2671 mkdir $(distdir)/=build
2672 mkdir $(distdir)/=inst
2673 dc_install_base=`cd $(distdir)/=inst && pwd`; \\'
2674 . (&target_defined ('distcheck-hook')
2675 ? ("\t\$(MAKE) \$(AM_MAKEFLAGS)"
2676 . " distcheck-hook")
2679 cd $(distdir)/=build \\
2682 . ($seen_gettext ? '--with-included-gettext ' : '')
2683 . '--srcdir=.. --prefix=$$dc_install_base \\
2684 && $(MAKE) $(AM_MAKEFLAGS) \\
2685 && $(MAKE) $(AM_MAKEFLAGS) dvi \\
2686 && $(MAKE) $(AM_MAKEFLAGS) check \\
2687 && $(MAKE) $(AM_MAKEFLAGS) install \\
2688 && $(MAKE) $(AM_MAKEFLAGS) installcheck \\
2689 && $(MAKE) $(AM_MAKEFLAGS) dist
2691 @echo "========================"; \\
2692 echo "$(distdir).tar.gz is ready for distribution"; \\
2693 echo "========================"
2696 local ($dist_all) = ('dist-all: distdir' . "\n"
2699 foreach $curs ('dist', 'dist-shar', 'dist-zip', 'dist-tarZ')
2701 if (defined $options{$curs} || $curs eq 'dist')
2703 $output_rules .= ($curs . ': distdir' . "\n"
2707 $dist_all .= $dist{$curs};
2710 $output_rules .= $dist_all . $dist_trailer;
2713 # Generate distdir target.
2714 &handle_dist_worker ($makefile);
2717 # Scan a single dependency file and rewrite the dependencies as
2718 # appropriate. Essentially this means:
2719 # * Clean out absolute dependencies which are not desirable.
2720 # * Rewrite other dependencies to be relative to $(top_srcdir).
2721 sub scan_dependency_file
2723 local ($depfile) = @_;
2725 if (! open (DEP_FILE, $depfile))
2727 &am_error ("couldn't open \`$depfile': $!");
2730 print "automake: reading $depfile\n" if $verbose;
2732 # Sometimes it is necessary to omit some dependencies.
2733 local (%omit) = %omit_dependencies;
2734 if (&variable_defined ('OMIT_DEPENDENCIES'))
2736 # FIXME: Doesn't work with conditionals. I'm not sure if this
2738 grep ($omit{$_} = 1,
2739 &variable_value_as_list ('OMIT_DEPENDENCIES', ''));
2742 local ($first_line) = 1;
2743 local ($last_line) = 0;
2744 local ($target, @dependencies);
2745 local ($one_dep, $xform);
2748 local ($srcdir_rx, $fixup_rx);
2749 ($fixup_rx = $srcdir_name . '/' . $relative_dir . '/')
2751 ($srcdir_rx = $srcdir_name . '/') =~ s/(\W)/\\$1/g;
2753 local ($rewrite_builddir) = (($top_builddir eq '.')
2755 : $top_builddir . '/');
2761 # If LAST_LINE set then we've already seen what we thought
2762 # was the last line.
2765 next if (/$WHITE_PATTERN/o);
2769 # No trailing "\" means this should be the last line.
2775 if (! /^([^:]+:)(.+)$/)
2778 &am_error ("\`$depfile' has incorrect format");
2784 # Make sure to strip the .P file from the target.
2785 ($target = $1) =~ s, *\.deps/[^.]+\.P,,;
2790 foreach $one_dep (split (' ', $_))
2792 ($just_file = $one_dep) =~ s,^.*/,,;
2793 next if defined $omit{$just_file};
2795 if ($one_dep =~ /^$fixup_rx/)
2797 # The dependency points to the current directory in
2799 ($xform = $one_dep) =~ s/^$fixup_rx//;
2800 push (@dependencies, $xform);
2802 elsif ($one_dep =~ /^$srcdir_rx/)
2804 # The dependency is in some other directory in the package.
2805 ($xform = $one_dep) =~ s/^$srcdir_rx/$rewrite_builddir/;
2806 push (@dependencies, $xform);
2808 elsif ($one_dep =~ /^\// || $one_dep =~ /^[A-Za-z]:\\/)
2810 # Absolute path; ignore.
2814 # Anything else is assumed to be correct.
2815 push (@dependencies, $one_dep);
2820 &pretty_print_rule ($target, "\t", @dependencies);
2825 # Handle auto-dependency code.
2826 sub handle_dependencies
2828 # Make sure this variable is always marked as used.
2829 &examine_variable ('OMIT_DEPENDENCIES');
2831 if ($use_dependencies)
2833 # Include GNU-make-specific auto-dep code. Don't include it
2834 # if DEP_FILES would be empty.
2835 if ($dir_holds_sources && keys %dep_files)
2837 &define_pretty_variable ('DEP_FILES', '', sort keys %dep_files);
2838 $output_rules .= &file_contents ('depend');
2839 push (@clean, 'depend');
2840 &push_phony_cleaners ('depend');
2842 &file_contents_with_transform ('s/\@EXT\@/.c/g;'
2846 foreach $ext (sort keys %cxx_extensions)
2849 &file_contents_with_transform ('s/\@EXT\@/' . $ext .'/g;'
2850 . 's/\@PFX\@/CXX/g;',
2855 elsif ($build_directory ne '')
2857 # Include any auto-generated deps that are present. Note that
2858 # $build_directory ends in a "/".
2859 if (-d ($build_directory . $relative_dir . "/.deps"))
2863 foreach $depfile (&my_glob ($build_directory
2864 . $relative_dir . "/.deps/*.P"))
2866 &scan_dependency_file ($depfile);
2869 $output_rules .= "\n";
2874 # Handle subdirectories.
2877 return if ! &variable_defined ('SUBDIRS');
2879 # Make sure each directory mentioned in SUBDIRS actually exists.
2881 foreach $dir (&variable_value_as_list ('SUBDIRS', 'all'))
2883 # Skip directories substituted by configure.
2884 next if $dir =~ /^\@.*\@$/;
2886 if (! -d $am_relative_dir . '/' . $dir)
2888 &am_line_error ('SUBDIRS',
2889 "required directory $am_relative_dir/$dir does not exist");
2893 &am_line_error ('SUBDIRS', "directory should not contain \`/'")
2897 local ($xform) = ('s/\@INSTALLINFO\@/' .
2898 (defined $options{'no-installinfo'}
2899 ? 'install-info-recursive'
2902 $output_rules .= &file_contents_with_transform ($xform, 'subdirs');
2904 # Push a bunch of phony targets.
2906 foreach $phonies ('-data', '-exec', 'dirs')
2908 push (@phony, 'install' . $phonies . '-recursive');
2909 push (@phony, 'uninstall' . $phonies . '-recursive');
2911 foreach $phonies ('all', 'check', 'installcheck', 'info', 'dvi')
2913 push (@phony, $phonies . '-recursive');
2915 &push_phony_cleaners ('recursive');
2917 $recursive_install = 1;
2920 # Handle aclocal.m4.
2921 sub handle_aclocal_m4
2923 local ($regen_aclocal) = 0;
2924 if (-f 'aclocal.m4')
2926 &define_variable ("ACLOCAL_M4", '$(top_srcdir)/aclocal.m4');
2927 &push_dist_common ('aclocal.m4');
2929 if (open (ACLOCAL, '< aclocal.m4'))
2935 if ($line =~ 'generated automatically by aclocal')
2942 local ($acinclude) = 0;
2943 if (-f 'acinclude.m4')
2949 # Note that it might be possible that aclocal.m4 doesn't exist but
2950 # should be auto-generated. This case probably isn't very
2954 local (@ac_deps) = (
2955 ($seen_maint_mode ? "\@MAINT\@" : "") ,
2957 ($acinclude ? ' acinclude.m4' : '')
2960 # Scan all -I directories for m4 files. These are our
2962 if (&variable_defined ('ACLOCAL_AMFLAGS'))
2964 local ($examine_next, $amdir) = 0;
2965 foreach $amdir (&variable_value_as_list ('ACLOCAL_AMFLAGS', ''))
2970 if ($amdir !~ /^\// && -d $amdir)
2972 push (@ac_deps, &my_glob ($amdir . '/*.m4'));
2975 elsif ($amdir eq '-I')
2982 &pretty_print_rule ("\$(ACLOCAL_M4):", "\t\t", @ac_deps);
2984 $output_rules .= ("\t"
2985 . 'cd $(srcdir) && $(ACLOCAL)'
2986 . (&variable_defined ('ACLOCAL_AMFLAGS')
2987 ? ' $(ACLOCAL_AMFLAGS)' : '')
2992 # Rewrite a list of input files into a form suitable to put on a
2993 # dependency list. The idea is that if an input file has a directory
2994 # part the same as the current directory, then the directory part is
2995 # simply removed. But if the directory part is different, then
2996 # $(top_srcdir) is prepended. Among other things, this is used to
2997 # generate the dependency list for the output files generated by
2998 # AC_OUTPUT. Consider what the dependencies should look like in this
3000 # AC_OUTPUT(src/out:src/in1:lib/in2)
3001 # The first argument, ADD_SRCDIR, is 1 if $(top_srcdir) should be added.
3002 # If 0 then files that require this addition will simply be ignored.
3003 sub rewrite_inputs_into_dependencies
3005 local ($add_srcdir, @inputs) = @_;
3006 local ($single, @newinputs);
3008 foreach $single (@inputs)
3010 if (&dirname ($single) eq $relative_dir)
3012 push (@newinputs, &basename ($single));
3016 push (@newinputs, '$(top_srcdir)/' . $single);
3023 # Handle remaking and configure stuff.
3024 # We need the name of the input file, to do proper remaking rules.
3025 sub handle_configure
3027 local ($local, $input, @secondary_inputs) = @_;
3029 # If SUBDIRS defined, require AC_PROG_MAKE_SET.
3030 &am_line_error ('SUBDIRS', "AC_PROG_MAKE_SET must be used in configure.in")
3031 if &variable_defined ('SUBDIRS') && ! $seen_make_set;
3033 local ($top_reldir);
3035 local ($input_base) = &basename ($input);
3036 local ($local_base) = &basename ($local);
3038 local ($amfile) = $input_base . '.am';
3039 # We know we can always add '.in' because it really should be an
3040 # error if the .in was missing originally.
3041 local ($infile) = '$(srcdir)/' . $input_base . '.in';
3042 local ($colon_infile);
3043 if ($local ne $input || @secondary_inputs)
3045 $colon_infile = ':' . $input . '.in';
3047 $colon_infile .= ':' . join (':', @secondary_inputs)
3048 if @secondary_inputs;
3050 local (@rewritten) = &rewrite_inputs_into_dependencies (1,
3052 # This rule remakes the Makefile.in. Note use of @MAINT@ forces
3053 # us to abandon pretty-printing. Sigh.
3054 $output_rules .= ($infile
3055 # NOTE perl 5.003 (with -w) gives a
3056 # uninitialized value error on the next line.
3059 . ($seen_maint_mode ? '@MAINT@ ' : '')
3061 . '$(top_srcdir)/configure.in $(ACLOCAL_M4)' . "\n"
3062 . "\tcd \$(top_srcdir) && \$(AUTOMAKE) "
3063 . ($cygnus_mode ? '--cygnus' : ('--' . $strictness_name))
3064 . ($cmdline_use_dependencies ? '' : ' --include-deps')
3065 . ' ' . $input . $colon_infile . "\n\n");
3067 # This rule remakes the Makefile.
3068 $output_rules .= ($local_base
3069 # NOTE: bogus uninit value error on next line;
3070 # see comment above.
3073 . join (' ', @rewritten)
3074 . ' $(top_builddir)/config.status'
3075 # NOTE: Makefile only depends on BUILT_SOURCES
3076 # when dependencies are being computed. This is
3077 # a workaround for an obscure bug with
3078 # AC_LINK_FILES. Anyway, when dependencies are
3079 # turned off, this shouldn't matter.
3080 . ($use_dependencies ? ' $(BUILT_SOURCES)' : '')
3082 . "\tcd \$(top_builddir) \\\n"
3083 . "\t && CONFIG_FILES="
3084 . (($relative_dir eq '.') ? '$@' : '$(subdir)/$@')
3086 . ' CONFIG_HEADERS= $(SHELL) ./config.status'
3089 if ($relative_dir ne '.')
3092 $top_reldir = '../';
3097 $output_rules .= &file_contents ('remake');
3098 &examine_variable ('CONFIG_STATUS_DEPENDENCIES');
3099 &examine_variable ('CONFIGURE_DEPENDENCIES');
3103 # If we have a configure header, require it.
3105 local (@local_fullnames) = @config_fullnames;
3106 local (@local_names) = @config_names;
3107 local ($hdr_index) = 0;
3108 local ($distclean_config) = '';
3109 foreach $one_hdr (@config_headers)
3111 local ($one_fullname) = shift (@local_fullnames);
3112 local ($one_name) = shift (@local_names);
3114 if ($relative_dir eq &dirname ($one_hdr))
3116 local ($ch_sans_dir) = &basename ($one_hdr);
3117 local ($cn_sans_dir) = &basename ($one_name);
3119 &require_file_with_conf_line ($config_header_line,
3120 $FOREIGN, $ch_sans_dir);
3122 # Header defined and in this directory.
3124 if (-f $relative_dir . '/acconfig.h')
3126 push (@files, 'acconfig.h');
3128 if (-f $one_name . '.top')
3130 push (@files, "${cn_sans_dir}.top");
3132 if (-f $one_name . '.bot')
3134 push (@files, "${cn_sans_dir}.bot");
3137 &push_dist_common (@files);
3139 local ($stamp_name) = 'stamp-h';
3140 $stamp_name .= "${hdr_index}" if scalar (@config_headers) > 1;
3142 local ($xform) = '';
3144 $xform = 's,\@FILES\@,' . join (' ', @files) . ',;';
3145 $xform .= 's,\@CONFIG_HEADER\@,' . "${cn_sans_dir}" . ',;';
3146 $xform .= 's,\@CONFIG_HEADER_IN\@,' . "${ch_sans_dir}" . ',;';
3147 $xform .= 's,\@CONFIG_HEADER_FULL\@,' . "${one_fullname}" . ',;';
3148 $xform .= 's,\@STAMP\@,' . "${stamp_name}" . ',;';
3150 $output_rules .= &file_contents_with_transform ($xform,
3153 &touch ($relative_dir . "/${stamp_name}.in");
3154 &require_file_with_conf_line ($config_header_line, $FOREIGN,
3155 "${stamp_name}.in");
3157 $distclean_config .= ' ' if $distclean_config;
3158 $distclean_config .= $cn_sans_dir;
3162 if ($distclean_config)
3164 $output_rules .= &file_contents_with_transform ('s,\@FILES\@,'
3168 push (@clean, 'hdr');
3169 &push_phony_cleaners ('hdr');
3172 # Set location of mkinstalldirs.
3173 if ($config_aux_dir ne '.' && $config_aux_dir ne '')
3175 &define_variable ('mkinstalldirs', ('$(SHELL) ' . $config_aux_dir
3176 . '/mkinstalldirs'));
3180 &define_variable ('mkinstalldirs',
3181 '$(SHELL) $(top_srcdir)/mkinstalldirs');
3184 &am_line_error ('CONFIG_HEADER',
3185 "\`CONFIG_HEADER' is an anachronism; now determined from \`configure.in'")
3186 if &variable_defined ('CONFIG_HEADER');
3189 local ($config_header) = '';
3190 foreach $one_name (@config_names)
3192 # Generate CONFIG_HEADER define.
3194 if ($relative_dir eq &dirname ($one_name))
3196 $one_hdr = &basename ($one_name);
3200 $one_hdr = "${top_builddir}/${one_name}";
3203 $config_header .= ' ' if $config_header;
3204 $config_header .= $one_hdr;
3208 &define_variable ("CONFIG_HEADER", $config_header);
3211 # Now look for other files in this directory which must be remade
3212 # by config.status, and generate rules for them.
3213 local (@actual_other_files) = ();
3214 local ($file, $local);
3215 local (@inputs, @rewritten_inputs, $single);
3216 local ($need_rewritten);
3217 foreach $file (@other_input_files)
3219 if ($file =~ /^([^:]*):(.*)$/)
3221 # This is the ":" syntax of AC_OUTPUT.
3223 $local = &basename ($file);
3224 @inputs = split (':', $2);
3225 @rewritten_inputs = &rewrite_inputs_into_dependencies (1, @inputs);
3226 $need_rewritten = 1;
3231 $local = &basename ($file);
3232 @inputs = ($local . '.in');
3234 &rewrite_inputs_into_dependencies (1, $file . '.in');
3235 $need_rewritten = 0;
3238 # Skip files not in this directory.
3239 next unless &dirname ($file) eq $relative_dir;
3241 # Skip any file that is an automake input.
3242 next if -f $file . '.am';
3244 # Some users have been tempted to put `stamp-h' in the
3245 # AC_OUTPUT line. This won't do the right thing, so we
3246 # explicitly fail here.
3247 if ($local eq 'stamp-h')
3249 # FIXME: allow real filename.
3250 &am_conf_error ('configure.in', $ac_output_line,
3251 'stamp-h should not appear in AC_OUTPUT');
3255 $output_rules .= ($local . ': '
3256 . '$(top_builddir)/config.status '
3257 . join (' ', @rewritten_inputs) . "\n"
3259 . 'cd $(top_builddir) && CONFIG_FILES='
3260 . ($relative_dir eq '.' ? '' : '$(subdir)/')
3261 . '$@' . ($need_rewritten
3262 ? (':' . join (':', @inputs))
3264 . ' CONFIG_HEADERS= $(SHELL) ./config.status'
3266 push (@actual_other_files, $local);
3268 # Require all input files.
3269 &require_file_with_conf_line ($ac_output_line, $FOREIGN,
3270 &rewrite_inputs_into_dependencies (0, @inputs));
3273 # These files get removed by "make clean".
3274 &define_pretty_variable ('CONFIG_CLEAN_FILES', '', @actual_other_files);
3280 $dir_holds_headers = &am_install_var ('header', 'HEADERS', 'include',
3281 'oldinclude', 'pkginclude',
3287 return if ! $seen_gettext || $relative_dir ne '.';
3289 if (! &variable_defined ('SUBDIRS'))
3292 ("AM_GNU_GETTEXT in configure.in but SUBDIRS not defined");
3296 &require_file_with_conf_line ($ac_gettext_line, $FOREIGN, 'ABOUT-NLS')
3299 if (&variable_defined ('SUBDIRS'))
3303 "AM_GNU_GETTEXT in configure.in but \`po' not in SUBDIRS")
3304 if $contents{'SUBDIRS'} !~ /\bpo\b/;
3307 "AM_GNU_GETTEXT in configure.in but \`intl' not in SUBDIRS")
3308 if $contents{'SUBDIRS'} !~ /\bintl\b/;
3311 # Ensure that each language in ALL_LINGUAS has a .po file, and
3312 # each po file is mentioned in ALL_LINGUAS.
3315 local (%linguas) = ();
3316 grep ($linguas{$_} = 1, split (' ', $all_linguas));
3323 &am_line_error ($all_linguas_line,
3324 ("po/$_.po exists but \`$_' not in \`ALL_LINGUAS'"))
3328 foreach (keys %linguas)
3330 &am_line_error ($all_linguas_line,
3331 "$_ in \`ALL_LINGUAS' but po/$_.po does not exist")
3337 &am_error ("AM_GNU_GETTEXT in configure.in but \`ALL_LINGUAS' not defined");
3341 # Handle footer elements.
3344 if ($contents{'SOURCES'})
3346 # NOTE don't use define_pretty_variable here, because
3347 # $contents{...} is already defined.
3348 $output_vars .= 'SOURCES = ' . $contents{'SOURCES'} . "\n";
3350 if ($contents{'OBJECTS'})
3352 # NOTE don't use define_pretty_variable here, because
3353 # $contents{...} is already defined.
3354 $output_vars .= 'OBJECTS = ' . $contents{'OBJECTS'} . "\n";
3356 if ($contents{'SOURCES'} || $contents{'OBJECTS'})
3358 $output_vars .= "\n";
3361 if (&variable_defined ('SUFFIXES'))
3363 # Push actual suffixes, and not $(SUFFIXES). Some versions of
3364 # make do not like variable substitutions on the .SUFFIXES
3366 push (@suffixes, &variable_value_as_list ('SUFFIXES', ''));
3368 if (&target_defined ('.SUFFIXES'))
3370 &am_line_error ('.SUFFIXES',
3371 "use variable \`SUFFIXES', not target \`.SUFFIXES'");
3374 # Note: AIX 4.1 /bin/make will fail if any suffix rule appears
3375 # before .SUFFIXES. So we make sure that .SUFFIXES appears before
3376 # anything else, by sticking it right after the default: target.
3377 $output_header .= ".SUFFIXES:\n";
3381 # Make sure suffixes has unique elements. Sort them to ensure
3382 # the output remains consistent.
3385 grep ($suffixes{$_} = 1, @suffixes);
3387 $output_header .= (".SUFFIXES: "
3388 . join (' ', sort keys %suffixes)
3391 $output_trailer .= &file_contents ('footer');
3394 # Deal with installdirs target.
3395 sub handle_installdirs
3397 # GNU Makefile standards recommend this.
3398 if ($recursive_install)
3400 # We create a separate `-am' target so that the -recursive
3401 # rule will work correctly.
3402 $output_rules .= ("installdirs: installdirs-recursive\n"
3403 . "installdirs-am:\n");
3404 push (@phony, 'installdirs-am');
3408 $output_rules .= "installdirs:\n";
3410 push (@phony, 'installdirs');
3413 &pretty_print_rule ("\t" . '$(mkinstalldirs) ', "\t\t",
3416 $output_rules .= "\n";
3419 # There are several targets which need to be merged. This is because
3420 # their complete definition is compiled from many parts. Note that we
3421 # avoid double colon rules, otherwise we'd use them instead.
3422 sub handle_merge_targets
3424 local ($makefile) = @_;
3426 # There are a few install-related variables that you should not define.
3428 foreach $var ('PRE_INSTALL', 'POST_INSTALL', 'NORMAL_INSTALL')
3430 if (&variable_defined ($var))
3432 &am_line_error ($var, "\`$var' should not be defined");
3436 # Put this at the beginning for the sake of non-GNU makes. This
3437 # is still wrong if these makes can run parallel jobs. But it is
3439 unshift (@all, &basename ($makefile));
3442 foreach $one_name (@config_names)
3444 push (@all, &basename ($one_name))
3445 if &dirname ($one_name) eq $relative_dir;
3448 &do_one_merge_target ('info', @info);
3449 &do_one_merge_target ('dvi', @dvi);
3450 &do_check_merge_target;
3451 &do_one_merge_target ('installcheck', @installcheck);
3453 if (defined $options{'no-installinfo'})
3455 &do_one_merge_target ('install-info', '');
3457 elsif (&target_defined ('install-info-local'))
3459 &am_line_error ('install-info-local',
3460 "\`install-info-local' target defined but \`no-installinfo' option not in use");
3463 # Handle the various install targets specially. We do this so
3464 # that (eg) "make install-exec" will run "install-exec-recursive"
3465 # if required, but "make install" won't run it twice. Step one is
3466 # to see if the user specified local versions of any of the
3467 # targets we handle. "all" is treated as one of these since
3468 # "install" can run it.
3469 push (@install_exec, 'install-exec-local')
3470 if &target_defined ('install-exec-local');
3471 push (@install_data, 'install-data-local')
3472 if &target_defined ('install-data-local');
3473 push (@uninstall, 'uninstall-local')
3474 if &target_defined ('uninstall-local');
3476 foreach $utarg ('uninstall-data-local', 'uninstall-data-hook',
3477 'uninstall-exec-local', 'uninstall-exec-hook')
3479 if (&target_defined ($utarg))
3482 ($x = $utarg) =~ s/(data|exec)-//;
3483 &am_line_error ($utarg, "use \`$x', not \`$utarg'");
3486 push (@all, 'all-local')
3487 if &target_defined ('all-local');
3489 if (&target_defined ('install-local'))
3491 &am_line_error ('install-local',
3492 "use \`install-data-local' or \`install-exec-local', not \`install-local'");
3498 local ($local_headers) = '';
3499 foreach $one_name (@config_names)
3501 if (&dirname ($one_name) eq $relative_dir)
3503 $local_headers .= ' ' if $local_headers;
3504 $local_headers .= &basename ($one_name);
3509 # This is kind of a hack, but I couldn't see a better way
3510 # to handle it. In this particular case, we need to make
3511 # sure config.h is built before we recurse. We can't do
3512 # this by changing the order of dependencies to the "all"
3513 # because that breaks when using parallel makes. Instead
3514 # we handle things explicitly.
3515 $output_rules .= ("all-recursive-am: ${local_headers}"
3517 . '$(MAKE) $(AM_MAKEFLAGS)'
3520 $all_target = 'all-recursive-am';
3521 push (@phony, 'all-recursive-am');
3525 # Print definitions users can use.
3526 &do_one_merge_target ('install-exec', @install_exec);
3527 if (&target_defined ('install-exec-hook'))
3529 $output_rules .= ("\t\@\$(NORMAL_INSTALL)\n"
3530 . "\t" . '$(MAKE) $(AM_MAKEFLAGS) install-exec-hook'
3533 $output_rules .= "\n";
3534 push (@install, 'install-exec-am');
3536 &do_one_merge_target ('install-data', @install_data);
3537 if (defined $contents{'install-data-hook'})
3539 $output_rules .= ("\t\@\$(NORMAL_INSTALL)\n"
3540 . "\t" . '$(MAKE) $(AM_MAKEFLAGS) install-data-hook'
3543 $output_rules .= "\n";
3544 push (@install, 'install-data-am');
3546 &do_one_merge_target ('install', @install);
3547 &do_one_merge_target ('uninstall', @uninstall);
3549 &do_one_merge_target ('all', @all);
3551 # Generate the new 'install-strip' target. Must set
3552 # INSTALL_SCRIPT to avoid stripping scripts.
3553 $output_rules .= ("install-strip:\n\t"
3554 . '$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM=\'$(INSTALL_PROGRAM) -s\' INSTALL_SCRIPT=\'$(INSTALL_PROGRAM)\' install'
3558 # Helper for handle_merge_targets. Note that handle_merge_targets
3559 # relies on the fact that this doesn't add an extra \n at the end.
3560 sub do_one_merge_target
3562 local ($name, @values) = @_;
3564 if (&target_defined ($name . '-local'))
3566 # User defined local form of target. So include it.
3567 push (@values, $name . '-local');
3568 push (@phony, $name . '-local');
3571 &pretty_print_rule ($name . "-am:", "\t\t", @values);
3572 local ($lname) = $name . ($recursive_install ? '-recursive' : '-am');
3573 local ($tname) = $name;
3574 # To understand this special case, see handle_merge_targets.
3577 $tname = 'all-redirect';
3578 $lname = $all_target if $recursive_install;
3579 push (@phony, 'all-redirect');
3580 $output_all = "all: all-redirect\n";
3582 &pretty_print_rule ($tname . ":", "\t\t", $lname);
3583 push (@phony, $name . '-am', $name);
3586 # Handle check merge target specially.
3587 sub do_check_merge_target
3589 if (&target_defined ('check-local'))
3591 # User defined local form of target. So include it.
3592 push (@check_tests, 'check-local');
3593 push (@phony, 'check-local');
3596 # In --cygnus mode, check doesn't depend on all.
3599 # Just run the local check rules.
3600 &pretty_print_rule ('check-am:', "\t\t", @check);
3604 # The check target must depend on the local equivalent of
3605 # `all', to ensure all the primary targets are built. Then it
3606 # must build the local check rules.
3607 $output_rules .= "check-am: all-am\n";
3608 &pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ",
3612 &pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ",
3616 push (@phony, 'check', 'check-am');
3617 $output_rules .= ("check: "
3618 . ($recursive_install ? 'check-recursive' : 'check-am')
3622 # Handle all 'clean' targets.
3625 local ($xform) = '';
3628 # Don't include `MAINTAINER'; it is handled specially below.
3629 foreach $name ('MOSTLY', '', 'DIST')
3631 if (! &variable_defined ($name . 'CLEANFILES'))
3633 $xform .= 's/^' . $name . 'CLEAN.*$//;';
3637 $xform .= 's/^' . $name . 'CLEAN//;';
3641 # Built sources are automatically removed by maintainer-clean.
3642 push (@maintainer_clean_files, '\$(BUILT_SOURCES)')
3643 if &variable_defined ('BUILT_SOURCES');
3644 push (@maintainer_clean_files, '\$(MAINTAINERCLEANFILES)')
3645 if &variable_defined ('MAINTAINERCLEANFILES');
3646 if (! @maintainer_clean_files)
3648 $xform .= 's/^MAINTAINERCLEAN.*$//;';
3652 $xform .= ('s/^MAINTAINERCLEAN//;'
3653 # Join with no space to avoid spurious `test -z'
3654 # success at runtime.
3655 . 's,\@MCFILES\@,' . join ('', @maintainer_clean_files)
3657 # A space is required in the join here.
3658 . 's,\@MFILES\@,' . join (' ', @maintainer_clean_files)
3662 $output_rules .= &file_contents_with_transform ($xform, 'clean');
3664 push (@clean, 'generic');
3665 &push_phony_cleaners ('generic');
3667 &do_one_clean_target ('clean', 'mostly', '', @clean);
3668 &do_one_clean_target ('clean', '', 'mostly', @clean);
3669 &do_one_clean_target ('clean', 'dist', '', @clean);
3670 &do_one_clean_target ('clean', 'maintainer-', 'dist', @clean);
3672 push (@phony, 'clean', 'mostlyclean', 'distclean', 'maintainer-clean');
3675 # Helper for handle_clean.
3676 sub do_one_clean_target
3678 local ($target, $name, $last_name, @deps) = @_;
3680 # Change each dependency `BLARG' into `clean-BLARG'.
3681 grep (($_ = $name . 'clean-' . $_) && 0, @deps);
3683 # Push the previous clean target.
3684 push (@deps, $last_name . $target . '-am');
3686 # If a -local version of the rule is given, add it to the list.
3687 if (&target_defined ($name . $target . '-local'))
3689 push (@deps, $name . $target . '-local');
3692 # Print the target and the dependencies.
3693 &pretty_print_rule ($name . $target . "-am: ", "\t\t", @deps);
3695 # FIXME: shouldn't we really print these messages before running
3697 if ($name . $target eq 'maintainer-clean')
3699 # Print a special warning.
3701 ("\t\@echo \"This command is intended for maintainers to use;\"\n"
3702 . "\t\@echo \"it deletes files that may require special "
3703 . "tools to rebuild.\"\n");
3705 $output_rules .= "\t-rm -f config.status\n"
3706 if $relative_dir eq '.';
3708 elsif ($name . $target eq 'distclean')
3710 $output_rules .= "\t-rm -f config.status\n";
3711 $output_rules .= "\t-rm -f libtool\n" if $seen_libtool;
3713 $output_rules .= "\n";
3714 $output_rules .= ($name . $target . ": " . $name . $target
3715 . ($recursive_install ? '-recursive' : '-am')
3719 # Handle .PHONY target.
3722 &pretty_print_rule ('.PHONY:', "", @phony);
3723 $output_rules .= "\n";
3726 # Handle TESTS variable and other checks.
3729 if (defined $options{'dejagnu'})
3731 push (@check_tests, 'check-DEJAGNU');
3732 push (@phony, 'check-DEJAGNU');
3737 $xform = 's/^CYGNUS//;';
3741 $xform = 's/^CYGNUS.*$//;';
3743 $output_rules .= &file_contents_with_transform ($xform, 'dejagnu');
3745 # In Cygnus mode, these are found in the build tree.
3746 # Otherwise they are looked for in $PATH.
3747 &define_program_variable ('EXPECT', 'build', 'expect', 'expect');
3748 &define_program_variable ('RUNTEST', 'src', 'dejagnu', 'runtest');
3750 # Only create site.exp rule if user hasn't already written
3752 if (! &target_defined ('site.exp'))
3754 # Note that in the rule we don't directly generate
3755 # site.exp to avoid the possibility of a corrupted
3756 # site.exp if make is interrupted. Jim Meyering has some
3757 # useful text on this topic.
3758 $output_rules .= ("site.exp: Makefile\n"
3759 . "\t\@echo 'Making a new site.exp file...'\n"
3760 . "\t-\@rm -f site.bak\n"
3761 . "\t\@echo '## these variables are automatically generated by make ##' > \$\@-t\n"
3762 . "\t\@echo '# Do not edit here. If you wish to override these values' >> \$\@-t\n"
3763 . "\t\@echo '# edit the last section' >> \$\@-t\n"
3764 . "\t\@echo 'set tool \$(DEJATOOL)' >> \$\@-t\n"
3765 . "\t\@echo 'set srcdir \$(srcdir)' >> \$\@-t\n"
3766 . "\t\@echo 'set objdir' \`pwd\` >> \$\@-t\n");
3768 # Extra stuff for AC_CANONICAL_*
3769 local (@whatlist) = ();
3770 if ($seen_canonical)
3772 push (@whatlist, 'host');
3775 # Extra stuff only for AC_CANONICAL_SYSTEM.
3776 if ($seen_canonical == $AC_CANONICAL_SYSTEM)
3778 push (@whatlist, 'target', 'build');
3782 foreach $c1 (@whatlist)
3784 foreach $c2 ('alias', 'triplet')
3786 $output_rules .= "\t\@echo 'set ${c1}_${c2} \$(${c1}_${c2})' >> \$\@-t\n";
3790 $output_rules .= ("\t\@echo '## All variables above are generated by configure. Do Not Edit ##' >> \$\@-t\n"
3791 . "\t-\@sed '1,/^## All variables above are.*##/ d' site.bak >> \$\@-t\n"
3792 . "\t-\@mv site.exp site.bak\n"
3793 . "\t\@mv \$\@-t site.exp\n");
3799 foreach $c ('DEJATOOL', 'RUNTEST', 'RUNTESTFLAGS')
3801 if (&variable_defined ($c))
3803 &am_line_error ($c, "\`$c' defined but \`dejagnu' not in \`AUTOMAKE_OPTIONS'");
3808 if (&variable_defined ('TESTS'))
3810 push (@check_tests, 'check-TESTS');
3811 push (@phony, 'check-TESTS');
3813 $output_rules .= 'check-TESTS: $(TESTS)
3814 @failed=0; all=0; \\
3815 srcdir=$(srcdir); export srcdir; \\
3816 for tst in $(TESTS); do \\
3817 if test -f $$tst; then dir=.; \\
3818 else dir="$(srcdir)"; fi; \\
3819 if $(TESTS_ENVIRONMENT) $$dir/$$tst; then \\
3820 all=`expr $$all + 1`; \\
3821 echo "PASS: $$tst"; \\
3822 elif test $$? -ne 77; then \\
3823 all=`expr $$all + 1`; \\
3824 failed=`expr $$failed + 1`; \\
3825 echo "FAIL: $$tst"; \\
3828 if test "$$failed" -eq 0; then \\
3829 banner="All $$all tests passed"; \\
3831 banner="$$failed of $$all tests failed"; \\
3833 dashes=`echo "$$banner" | sed s/./=/g`; \\
3837 test "$$failed" -eq 0
3842 # Handle Emacs Lisp.
3843 sub handle_emacs_lisp
3845 local (@elfiles) = &am_install_var ('lisp', 'LISP', 'lisp', 'noinst');
3850 &define_configure_variable ('lispdir');
3851 &define_configure_variable ('EMACS');
3852 $output_rules .= (".el.elc:\n"
3853 . "\t\@echo 'WARNING: Warnings can be ignored. :-)'\n"
3854 . "\tif test \$(EMACS) != no; then \\\n"
3855 . "\t EMACS=\$(EMACS) \$(SHELL) \$(srcdir)/elisp-comp \$<; \\\n"
3857 push (@suffixes, '.el', '.elc');
3859 # Generate .elc files.
3860 grep ($_ .= 'c', @elfiles);
3861 &define_pretty_variable ('ELCFILES', '', @elfiles);
3863 $output_rules .= &file_contents ('lisp-clean');
3864 push (@clean, 'lisp');
3865 &push_phony_cleaners ('lisp');
3867 push (@all, '$(ELCFILES)');
3870 if (&variable_defined ('lisp_LISP'))
3872 $varname = 'lisp_LISP';
3873 &am_error ("\`lisp_LISP' defined but \`AM_PATH_LISPDIR' not in \`configure.in'")
3878 $varname = 'noinst_LISP';
3881 &require_file_with_line ($varname, $FOREIGN, 'elisp-comp');
3888 local (@sourcelist) = &am_install_var ('-clean', 'java', 'JAVA',
3889 'java', 'noinst', 'check');
3890 return if ! @sourcelist;
3892 &define_variable ('JAVAC', 'javac');
3893 &define_variable ('JAVACFLAGS', '');
3894 &define_variable ('CLASSPATH_ENV',
3895 'CLASSPATH=$(JAVAROOT):$(srcdir)/$(JAVAROOT):$$CLASSPATH');
3896 &define_variable ('JAVAROOT', '$(top_builddir)');
3898 local (%valid) = &am_primary_prefixes ('JAVA', 'java', 'noinst', 'check');
3900 local ($dir, $curs);
3901 foreach $curs (keys %valid)
3903 if (! &variable_defined ($curs . '_JAVA') || $curs eq 'noinst'
3904 || $curs eq 'EXTRA')
3911 print STDERR "got $curs\n";
3912 &am_line_error ($curs . '_JAVA',
3913 "multiple _JAVA primaries in use");
3918 $output_rules .= ('class' . $dir . '.stamp: $(' . $dir . '_JAVA)' . "\n"
3919 . "\t" . '$(CLASSPATH_ENV) $(JAVAC) -d $(JAVAROOT) '
3920 . '$(JAVACFLAGS) $?' . "\n"
3921 . "\t" . 'echo timestamp > class' . $dir . '.stamp'
3923 push (@all, 'class' . $dir . '.stamp');
3924 &push_dist_common ('$(' . $dir . '_JAVA)');
3927 # Handle some of the minor options.
3928 sub handle_minor_options
3930 if (defined $options{'readme-alpha'})
3932 if ($relative_dir eq '.')
3934 if ($package_version !~ /^$GNITS_VERSION_PATTERN$/)
3936 # FIXME: allow real filename.
3937 &am_conf_line_error ('configure.in',
3938 $package_version_line,
3939 "version \`$package_version' doesn't follow Gnits standards");
3941 elsif (defined $1 && -f 'README-alpha')
3943 # This means we have an alpha release. See
3944 # GNITS_VERSION_PATTERN for details.
3945 &require_file ($FOREIGN, 'README-alpha');
3951 ################################################################
3953 # Scan one file for interesting things. Subroutine of scan_configure.
3954 sub scan_one_configure_file
3956 local ($filename) = @_;
3959 open (CONFIGURE, $filename)
3960 || die "automake: couldn't open \`$filename': $!\n";
3961 print "automake: reading $filename\n" if $verbose;
3965 # Remove comments from current line.
3969 # Skip macro definitions. Otherwise we might be confused into
3970 # thinking that a macro that was only defined was actually
3974 # Follow includes. This is a weirdness commonly in use at
3975 # Cygnus and hopefully nowhere else.
3976 if (/sinclude\((.*)\)/ && -f $1)
3978 &scan_one_configure_file ($1);
3981 # Populate libobjs array.
3982 if (/AC_FUNC_ALLOCA/)
3984 $libsources{'alloca.c'} = 1;
3986 elsif (/AC_FUNC_GETLOADAVG/)
3988 $libsources{'getloadavg.c'} = 1;
3990 elsif (/AC_FUNC_MEMCMP/)
3992 $libsources{'memcmp.c'} = 1;
3994 elsif (/AC_STRUCT_ST_BLOCKS/)
3996 $libsources{'fileblocks.c'} = 1;
3998 elsif (/A[CM]_REPLACE_GNU_GETOPT/)
4000 $libsources{'getopt.c'} = 1;
4001 $libsources{'getopt1.c'} = 1;
4003 elsif (/AM_FUNC_STRTOD/)
4005 $libsources{'strtod.c'} = 1;
4007 elsif (/AM_WITH_REGEX/)
4009 $libsources{'rx.c'} = 1;
4010 $libsources{'rx.h'} = 1;
4011 $libsources{'regex.c'} = 1;
4012 $libsources{'regex.h'} = 1;
4013 $omit_dependencies{'rx.h'} = 1;
4014 $omit_dependencies{'regex.h'} = 1;
4016 elsif (/AM_FUNC_MKTIME/)
4018 $libsources{'mktime.c'} = 1;
4020 elsif (/AM_FUNC_ERROR_AT_LINE/)
4022 $libsources{'error.c'} = 1;
4023 $libsources{'error.h'} = 1;
4025 elsif (/AM_FUNC_OBSTACK/)
4027 $libsources{'obstack.c'} = 1;
4028 $libsources{'obstack.h'} = 1;
4030 elsif (/LIBOBJS="(.*)\s+\$LIBOBJS"/
4031 || /LIBOBJS="\$LIBOBJS\s+(.*)"/)
4033 foreach $libobj_iter (split (' ', $1))
4035 if ($libobj_iter =~ /^(.*)\.o(bj)?$/)
4037 $libsources{$1 . '.c'} = 1;
4042 if (! $in_ac_replace && s/AC_REPLACE_FUNCS\s*\(\[?//)
4048 $in_ac_replace = 0 if s/[\]\)].*$//;
4049 # Remove trailing backslash.
4053 # Need to skip empty elements for Perl 4.
4055 $libsources{$_ . '.c'} = 1;
4059 if (/$obsolete_rx/o)
4062 if ($obsolete_macros{$1})
4064 $hint = '; ' . $obsolete_macros{$1};
4066 &am_conf_line_error ($filename, $., "\`$1' is obsolete$hint");
4069 # Process the AC_OUTPUT macro.
4070 if (! $in_ac_output && s/AC_OUTPUT\s*\(\[?//)
4073 $ac_output_line = $.;
4077 local ($closing) = 0;
4084 # Look at potential Makefile.am's.
4087 # Must skip empty string for Perl 4.
4088 next if $_ eq "\\" || $_ eq '';
4090 # Handle $local:$input syntax. Note that we ignore
4091 # every input file past the first, though we keep
4092 # those around for later.
4093 local ($local, $input, @rest) = split (/:/);
4100 # FIXME: should be error if .in is missing.
4101 $input =~ s/\.in$//;
4104 if (-f $input . '.am')
4106 # We have a file that automake should generate.
4107 push (@make_input_list, $input);
4108 $make_list{$input} = join (':', ($local, @rest));
4112 # We have a file that automake should cause to be
4113 # rebuilt, but shouldn't generate itself.
4114 push (@other_input_files, $_);
4118 if ($closing && @make_input_list == 0 && @other_input_files == 0)
4120 &am_conf_line_error ($filename, $ac_output_line,
4121 "No files mentioned in \`AC_OUTPUT'");
4126 if (/$AC_CONFIG_AUX_DIR_PATTERN/o)
4128 @config_aux_path = $1;
4131 # Check for ansi2knr.
4132 $am_c_prototypes = 1 if /AM_C_PROTOTYPES/;
4134 # Check for exe extension stuff.
4138 $configure_vars{'EXEEXT'} = 1;
4144 $configure_vars{'OBJEXT'} = 1;
4147 # Check for NLS support.
4148 if (/AM_GNU_GETTEXT/)
4151 $ac_gettext_line = $.;
4152 $omit_dependencies{'libintl.h'} = 1;
4155 # Look for ALL_LINGUAS.
4156 if (/ALL_LINGUAS="(.*)"$/ || /ALL_LINGUAS=(.*)$/)
4160 $all_linguas_line = $.;
4163 # Handle configuration headers. A config header of `[$1]'
4164 # means we are actually scanning AM_CONFIG_HEADER from
4166 if (/A([CM])_CONFIG_HEADER\s*\((.*)\)/
4171 "\`AC_CONFIG_HEADER' is obsolete; use \`AM_CONFIG_HEADER'")
4174 $config_header_line = $.;
4176 foreach $one_hdr (split (' ', $2))
4178 push (@config_fullnames, $one_hdr);
4179 if ($one_hdr =~ /^([^:]+):(.+)$/)
4181 push (@config_names, $1);
4182 push (@config_headers, $2);
4186 push (@config_names, $one_hdr);
4187 push (@config_headers, $one_hdr . '.in');
4192 # Handle AC_CANONICAL_*. Always allow upgrading to
4193 # AC_CANONICAL_SYSTEM, but never downgrading.
4194 $seen_canonical = $AC_CANONICAL_HOST
4195 if ! $seen_canonical
4196 && (/AC_CANONICAL_HOST/ || /AC_CHECK_TOOL/);
4197 $seen_canonical = $AC_CANONICAL_SYSTEM if /AC_CANONICAL_SYSTEM/;
4199 $seen_path_xtra = 1 if /AC_PATH_XTRA/;
4201 # This macro handles several different things.
4202 if (/$AM_INIT_AUTOMAKE_PATTERN/o)
4208 $seen_prog_install = 1;
4209 ($package_version = $1) =~ s/$AM_PACKAGE_VERSION_PATTERN/$1/o;
4210 $package_version_line = $.;
4213 # This is like AM_INIT_AUTOMAKE, but doesn't actually set the
4214 # package and version number. (This might change in the
4215 # future). Yes, I'm not above hacking Automake so it works
4216 # well with other GNU tools -- that is actually the point.
4217 if (/AM_INIT_GUILE_MODULE/)
4223 $seen_prog_install = 1;
4224 @config_aux_path = ('..');
4227 # Some things required by Automake.
4228 $seen_make_set = 1 if /AC_PROG_MAKE_SET/;
4229 $seen_arg_prog = 1 if /AC_ARG_PROGRAM/;
4233 $configure_vars{'LEX'} = 1;
4234 $seen_decl_yytext = 1;
4236 if (/AC_DECL_YYTEXT/ && $filename =~ /configure\.in$/)
4238 &am_conf_line_warning ($filename, $.,
4239 "\`AC_DECL_YYTEXT' is obsolete; use \`AM_PROG_LEX'");
4241 if (/AC_PROG_LEX/ && $filename =~ /configure\.in$/)
4243 &am_conf_line_warning ($filename, $.,
4244 "\`AC_PROG_LEX' is obsolete; use \`AM_PROG_LEX'");
4247 if (/AC_PROG_(YACC|RANLIB|CC|CXXCPP|CXX|LEX|AWK|CPP|LN_S)/)
4249 $configure_vars{$1} = 1;
4251 if (/$AC_CHECK_PATTERN/o)
4253 $configure_vars{$3} = 1;
4255 if (/$AM_MISSING_PATTERN/o
4259 && $1 ne 'AUTOHEADER')
4261 $configure_vars{$1} = 1;
4264 # Explicitly avoid ANSI2KNR -- we AC_SUBST that in protos.m4,
4265 # but later define it elsewhere. This is pretty hacky. We
4266 # also explicitly avoid INSTALL_SCRIPT and some other
4267 # variables because they are defined in header-vars.am.
4269 if (/$AC_SUBST_PATTERN/o
4271 && $1 ne 'INSTALL_SCRIPT'
4272 && $1 ne 'INSTALL_DATA')
4274 $configure_vars{$1} = 1;
4277 $seen_decl_yytext = 1 if /AC_DECL_YYTEXT/;
4278 $seen_maint_mode = 1 if /AM_MAINTAINER_MODE/;
4279 $seen_package = 1 if /PACKAGE=/;
4281 # Skip VERSION of [$2]; that is from AM_INIT_AUTOMAKE.
4282 if (/\bVERSION=(\S+)/ && $1 ne '[$2]')
4285 $package_version = $1;
4286 $package_version_line = $.;
4293 $seen_prog_install = 1 if /AC_PROG_INSTALL/;
4294 $seen_lispdir = 1 if /AM_PATH_LISPDIR/;
4296 if (/AM_PROG_LIBTOOL/)
4300 $configure_vars{'LIBTOOL'} = 1;
4301 $configure_vars{'RANLIB'} = 1;
4302 $configure_vars{'CC'} = 1;
4303 # AM_PROG_LIBTOOL runs AC_CANONICAL_HOST. Make sure we
4304 # never downgrade (if we've seen AC_CANONICAL_SYSTEM).
4305 $seen_canonical = $AC_CANONICAL_HOST if ! $seen_canonical;
4308 if (/$AM_CONDITIONAL_PATTERN/o)
4310 $configure_cond{$1} = 1;
4317 # Scan configure.in and aclocal.m4 for interesting things. We must
4318 # scan aclocal.m4 because there might be AC_SUBSTs and such there.
4321 # Reinitialize libsources here. This isn't really necessary,
4322 # since we currently assume there is only one configure.in. But
4323 # that won't always be the case.
4326 local ($in_ac_output, $in_ac_replace) = (0, 0);
4327 local (%make_list, @make_input_list);
4328 local ($libobj_iter);
4330 &scan_one_configure_file ('configure.in');
4331 &scan_one_configure_file ('aclocal.m4')
4334 # Set input and output files if not specified by user.
4337 @input_files = @make_input_list;
4338 %output_files = %make_list;
4341 &am_conf_error ("\`PACKAGE' not defined in configure.in")
4343 &am_conf_error ("\`VERSION' not defined in configure.in")
4346 # Look for some files we need. Always check for these. This
4347 # check must be done for every run, even those where we are only
4348 # looking at a subdir Makefile. We must set relative_dir so that
4349 # the file-finding machinery works.
4350 local ($relative_dir) = '.';
4351 &require_config_file ($FOREIGN, 'install-sh', 'mkinstalldirs', 'missing');
4352 &am_error ("\`install.sh' is an anachronism; use \`install-sh' instead")
4353 if -f $config_aux_path[0] . '/install.sh';
4356 ################################################################
4358 # Set up for Cygnus mode.
4361 return unless $cygnus_mode;
4363 &set_strictness ('foreign');
4364 $options{'no-installinfo'} = 1;
4365 $options{'no-dependencies'} = 1;
4366 $use_dependencies = 0;
4368 if (! $seen_maint_mode)
4370 &am_conf_error ("\`AM_MAINTAINER_MODE' required when --cygnus specified");
4375 &am_conf_error ("\`AC_EXEEXT' required when --cygnus specified");
4379 # Do any extra checking for GNU standards.
4380 sub check_gnu_standards
4382 if ($relative_dir eq '.')
4384 # In top level (or only) directory.
4385 &require_file ($GNU, 'INSTALL', 'NEWS', 'README', 'COPYING',
4386 'AUTHORS', 'ChangeLog');
4389 if ($strictness >= $GNU)
4391 if (defined $options{'no-installman'})
4393 &am_line_error ('AUTOMAKE_OPTIONS',
4394 "option \`no-installman' disallowed by GNU standards");
4397 if (defined $options{'no-installinfo'})
4399 &am_line_error ('AUTOMAKE_OPTIONS',
4400 "option \`no-installinfo' disallowed by GNU standards");
4405 # Do any extra checking for GNITS standards.
4406 sub check_gnits_standards
4408 if ($strictness >= $GNITS)
4410 if (-f $relative_dir . '/COPYING.LIB')
4412 &am_error ("\`${relative_dir}/COPYING.LIB' disallowed by Gnits standards");
4416 if ($relative_dir eq '.')
4418 # In top level (or only) directory.
4419 &require_file ($GNITS, 'THANKS');
4423 ################################################################
4425 # Pretty-print something. HEAD is what should be printed at the
4426 # beginning of the first line, FILL is what should be printed at the
4427 # beginning of every subsequent line.
4428 sub pretty_print_internal
4430 local ($head, $fill, @values) = @_;
4432 local ($column) = length ($head);
4433 local ($result) = $head;
4435 # Fill length is number of characters. However, each Tab
4436 # character counts for eight. So we count the number of Tabs and
4438 local ($fill_length) = length ($fill);
4439 $fill_length += 7 * ($fill =~ tr/\t/\t/d);
4441 local ($bol) = ($head eq '');
4444 # "71" because we also print a space.
4445 if ($column + length ($_) > 71)
4447 $result .= " \\\n" . $fill;
4448 $column = $fill_length;
4452 $result .= ' ' unless ($bol);
4454 $column += length ($_) + 1;
4462 # Pretty-print something and append to output_vars.
4465 $output_vars .= &pretty_print_internal (@_);
4468 # Pretty-print something and append to output_rules.
4469 sub pretty_print_rule
4471 $output_rules .= &pretty_print_internal (@_);
4475 ################################################################
4477 # See if a target exists.
4480 local ($target) = @_;
4481 return defined $targets{$target};
4484 # See if two conditionals are the same.
4485 sub conditional_same
4487 local ($cond1, $cond2) = @_;
4489 return (&conditional_true_when ($cond1, $cond2)
4490 && &conditional_true_when ($cond2, $cond1));
4493 # See if a conditional is true. Both arguments are conditional
4494 # strings. This returns true if the first conditional is true when
4495 # the second conditional is true.
4496 sub conditional_true_when
4498 local ($cond, $when) = @_;
4500 # Check the easy case first.
4506 # Check each component of $cond, which looks @COND1@@COND2@.
4507 foreach $comp (split ('@', $cond))
4509 # The way we split will give null strings between each
4513 if (index ($when, '@' . $comp . '@') == -1)
4522 # Check for an ambiguous conditional. This is called when a variable
4523 # or target is being defined conditionally. If we already know about
4524 # a definition that is true under the same conditions, then we have an
4526 sub check_ambiguous_conditional
4528 local ($var_name, $cond) = @_;
4529 local (@cond_vals) = split (' ', $conditional{$var_name});
4532 local ($vcond) = shift (@cond_vals);
4534 if (&conditional_true_when ($vcond, $cond)
4535 || &conditional_true_when ($cond, $vcond))
4537 &am_line_error ($var_name,
4538 "$var_name multiply defined in condition");
4543 # See if a variable exists. The first argument is the variable name,
4544 # and the optional second argument is the condition which we should
4545 # check. If no condition is given, we currently return true if the
4546 # variable is defined under any condition.
4547 sub variable_defined
4549 local ($var, $cond) = @_;
4550 if (defined $targets{$var})
4552 &am_line_error ($var, "\`$var' is target; expected variable");
4555 elsif (defined $contents{$var})
4557 if ($cond && $conditional{$var})
4559 # We have been asked to check for a particular condition,
4560 # and the variable is defined conditionally. We need to
4561 # look through the conditions under which the variable is
4562 # defined, and see if any of them match the conditional we
4563 # have been asked to check.
4564 local (@cond_vars) = split (' ', $conditional{$var});
4567 if (&conditional_same ($cond, shift (@cond_vars)))
4569 # Even a conditional examination is good enough
4570 # for us. FIXME: really should maintain examined
4571 # status on a per-condition basis.
4572 $content_seen{$var} = 1;
4578 # The variable is not defined for the given condition.
4582 $content_seen{$var} = 1;
4588 # Mark a variable as examined.
4589 sub examine_variable
4592 &variable_defined ($var);
4595 # Quote a value in order to put it in $conditional. We need to quote
4596 # spaces, and we need to handle null strings, so that we can later
4597 # retrieve values by splitting on space.
4602 $val =~ s/\t/\003/g;
4603 $val = '\002' if $val eq '';
4607 # Unquote a value in $conditional.
4608 sub unquote_cond_val
4612 $val =~ s/\003/\t/g;
4613 $val = '' if $val eq '\002';
4617 # Return the set of conditions for which a variable is defined.
4619 # If the variable is not defined conditionally, and is not defined in
4620 # terms of any variables which are defined conditionally, then this
4621 # returns the empty list.
4623 # If the variable is defined conditionally, but is not defined in
4624 # terms of any variables which are defined conditionally, then this
4625 # returns the list of conditions for which the variable is defined.
4627 # If the variable is defined in terms of any variables which are
4628 # defined conditionally, then this returns a full set of permutations
4629 # of the subvariable conditions. For example, if the variable is
4630 # defined in terms of a variable which is defined for @COND_TRUE@,
4631 # then this returns both @COND_TRUE@ and @COND_FALSE@. This is
4632 # because we will need to define the variable under both conditions.
4634 sub variable_conditions
4641 foreach $cond (&variable_conditions_sub ($var, '', ()))
4643 $uniqify{$cond} = 1;
4646 return keys %uniqify;
4649 # A subroutine of variable_conditions. We only return conditions
4650 # which are true for all the conditions in @PARENT_CONDS.
4651 sub variable_conditions_sub
4653 local ($var, $parent, @parent_conds) = @_;
4654 local (@new_conds) = ();
4656 if (defined $vars_scanned{$var})
4658 &am_line_error ($parent, "variable \`$var' recursively defined");
4661 $vars_scanned{$var} = 1;
4663 if (! $conditional{$var})
4665 foreach (split (' ', $contents{$var}))
4667 # If a comment seen, just leave.
4670 # Handle variable substitutions.
4671 if (/^\$\{(.*)\}$/ || /^\$\((.*)\)$/)
4674 &variable_conditions_sub ($1, $var, @parent_conds));
4678 # Now we want to return all permutations of the subvariable
4680 local (%allconds, $item);
4681 foreach $item (@new_conds)
4683 foreach (split ('@', $item))
4687 $allconds{$_ . '_TRUE'} = 1;
4691 return &variable_conditions_permutations (keys %allconds);
4694 local (@this_conds) = ();
4695 local (@condvals) = split (' ', $conditional{$var});
4698 local ($cond) = shift (@condvals);
4699 local ($val) = &unquote_cond_val (shift (@condvals));
4704 local ($parent_cond);
4705 foreach $parent_cond (@parent_conds)
4707 if (! &conditional_true_when ($parent_cond, $cond))
4717 push (@this_conds, $cond);
4719 push (@parent_conds, $cond);
4720 local (@subvar_conds) = ();
4721 foreach (split (' ', $val))
4723 # If a comment seen, just leave.
4726 # Handle variable substitutions.
4727 if (/^\$\{(.*)\}$/ || /^\$\((.*)\)$/)
4729 push (@subvar_conds,
4730 &variable_conditions_sub ($1, $var, @parent_conds));
4733 pop (@parent_conds);
4735 # If there are no conditional subvariables, then we want to
4736 # return this condition. Otherwise, we want to return the
4737 # permutations of the subvariables.
4738 if (! @subvar_conds)
4740 push (@new_conds, $cond);
4744 push (@new_conds, &variable_conditions_reduce (@subvar_conds));
4751 # If we are being called on behalf of another variable, we need to
4752 # return all possible permutations of the conditions. We have
4753 # already handled everything in @this_conds along with their
4754 # subvariables. We now need to add any permutations that are not
4757 foreach $this_cond (@this_conds)
4760 &variable_conditions_permutations (split('@', $this_cond));
4762 foreach $perm (@perms)
4766 foreach $scan (@this_conds)
4768 if (&conditional_true_when ($perm, $scan)
4769 || &conditional_true_when ($scan, $perm))
4780 local ($parent_cond);
4781 foreach $parent_cond (@parent_conds)
4783 if (! &conditional_true_when ($parent_cond, $perm))
4793 # This permutation was not already handled, and is valid
4795 push (@new_conds, $perm);
4802 # Subroutine for variable_conditions_sort
4803 sub variable_conditions_cmp
4809 return (length ($as) <=> length ($bs)
4813 # Sort a list of conditionals so that only the exclusive ones are
4814 # retained. For example, if both @COND1_TRUE@@COND2_TRUE@ and
4815 # @COND1_TRUE@ are in the list, discard the latter.
4816 sub variable_conditions_reduce
4818 local (@conds) = @_;
4821 foreach $cond (sort variable_conditions_cmp @conds)
4825 foreach $scan (@ret)
4827 if (&conditional_true_when ($cond, $scan))
4840 # Return a list of permutations of a conditional string.
4841 sub variable_conditions_permutations
4843 local (@comps) = @_;
4846 local ($comp) = shift (@comps);
4847 return &variable_conditions_permutations (@comps)
4849 local ($neg) = $comp;
4850 $neg =~ s/TRUE$/TRUEO/;
4851 $neg =~ s/FALSE$/TRUE/;
4852 $neg =~ s/TRUEO$/FALSE/;
4855 foreach $sub (&variable_conditions_permutations (@comps))
4857 push (@ret, '@' . $comp . '@' . $sub);
4858 push (@ret, '@' . $neg . '@' . $sub);
4862 push (@ret, '@' . $comp . '@');
4863 push (@ret, '@' . $neg . '@');
4868 # Warn if a variable is conditionally defined. This is called if we
4869 # are using the value of a variable.
4870 sub variable_conditionally_defined
4872 local ($var, $parent) = @_;
4873 if ($conditional{$var})
4877 &am_line_error ($parent,
4878 "warning: automake does not support conditional definition of $var in $parent");
4882 &am_line_error ($parent,
4883 "warning: automake does not support $var being defined conditionally")
4888 # Get the value of a variable. This just returns $contents, but warns
4889 # if the variable is conditionally defined.
4893 &variable_conditionally_defined ($var);
4894 return $contents{$var};
4897 # Convert a variable value to a list, split as whitespace. This will
4898 # recursively follow $(...) and ${...} inclusions. It preserves @...@
4899 # substitutions. If COND is 'all', then all values under all
4900 # conditions should be returned; if COND is a particular condition
4901 # (all conditions are surrounded by @...@) then only the value for
4902 # that condition should be returned; otherwise, warn if VAR is
4903 # conditionally defined. SCANNED is a global hash listing whose keys
4904 # are all the variables already scanned; it is an error to rescan a
4908 local ($var, $val, $cond) = @_;
4911 foreach (split (' ', $val))
4913 # If a comment seen, just leave.
4916 # Handle variable substitutions.
4917 if (/^\$\{([^}]*)\}$/ || /^\$\(([^)]*)\)$/)
4919 local ($varname) = $1;
4921 # If the user uses a losing variable name, just ignore it.
4922 # This isn't ideal, but people have requested it.
4923 next if ($varname =~ /\@.*\@/);
4927 if ($varname =~ /^([^:]*):([^=]*)=(.*)$/)
4931 ($from = $2) =~ s/(\W)/\\$1/g;
4935 @temp_list = &variable_value_as_list_worker ($1, $cond, $var);
4937 # Now rewrite the value if appropriate.
4940 grep (s/$from$/$to/, @temp_list);
4943 push (@result, @temp_list);
4954 # Return contents of variable as list, split as whitespace. This will
4955 # recursively follow $(...) and ${...} inclusions. It preserves @...@
4956 # substitutions. If COND is 'all', then all values under all
4957 # conditions should be returned; if COND is a particular condition
4958 # (all conditions are surrounded by @...@) then only the value for
4959 # that condition should be returned; otherwise, warn if VAR is
4960 # conditionally defined. If PARENT is specified, it is the name of
4961 # the including variable; this is only used for error reports.
4962 sub variable_value_as_list_worker
4964 local ($var, $cond, $parent) = @_;
4967 if (defined $targets{$var})
4969 &am_line_error ($var, "\`$var' is target; expected variable");
4971 elsif (! defined $contents{$var})
4973 &am_line_error ($parent, "variable \`$var' not defined");
4975 elsif (defined $vars_scanned{$var})
4977 # `vars_scanned' is a global we use to keep track of which
4978 # variables we've already examined.
4979 &am_line_error ($parent, "variable \`$var' recursively defined");
4981 elsif ($cond eq 'all' && $conditional{$var})
4983 $vars_scanned{$var} = 1;
4984 local (@condvals) = split (' ', $conditional{$var});
4988 local ($val) = &unquote_cond_val (shift (@condvals));
4989 push (@result, &value_to_list ($var, $val, $cond));
4992 elsif ($cond && $conditional{$var})
4994 $vars_scanned{$var} = 1;
4995 local (@condvals) = split (' ', $conditional{$var});
4999 local ($vcond) = shift (@condvals);
5000 local ($val) = &unquote_cond_val (shift (@condvals));
5001 if (&conditional_true_when ($vcond, $cond))
5003 # Warn if we have an ambiguity. It's hard to know how
5004 # to handle this case correctly.
5005 &variable_conditionally_defined ($var, $parent)
5008 push (@result, &value_to_list ($var, $val, $cond));
5014 $vars_scanned{$var} = 1;
5015 &variable_conditionally_defined ($var, $parent);
5016 $content_seen{$var} = 1;
5017 push (@result, &value_to_list ($var, $contents{$var}, $cond));
5023 # This is just a wrapper for variable_value_as_list_worker that
5024 # initializes the global hash `vars_scanned'. This hash is used to
5025 # avoid infinite recursion.
5026 sub variable_value_as_list
5028 local ($var, $cond, $parent) = @_;
5030 return &variable_value_as_list_worker ($var, $cond, $parent);
5033 # Define a new variable, but only if not already defined.
5036 local ($var, $value) = @_;
5038 if (! defined $contents{$var})
5040 $output_vars .= $var . ' = ' . $value . "\n";
5041 $contents{$var} = $value;
5042 $content_seen{$var} = 1;
5046 # Like define_variable, but the value is a list, and the variable may
5047 # be defined conditionally. The second argument is the conditional
5048 # under which the value should be defined; this should be the empty
5049 # string to define the variable unconditionally. The third argument
5050 # is a list holding the values to use for the variable. The value is
5051 # pretty printed in the output file.
5052 sub define_pretty_variable
5054 local ($var, $cond, @value) = @_;
5055 if (! defined $contents{$var}
5056 || ($cond && ! &variable_defined ($var, $cond)))
5058 $contents{$var} = join (' ', @value);
5061 if ($conditional{$var})
5063 $conditional{$var} .= ' ';
5067 $conditional{$var} = '';
5069 $conditional{$var} .= ($cond
5071 . "e_cond_val ($contents{$var}));
5073 &pretty_print ($cond . $var . ' = ', $cond, @value);
5074 $content_seen{$var} = 1;
5078 # Like define_variable, but define a variable to be the configure
5079 # substitution by the same name.
5080 sub define_configure_variable
5083 local ($value) = '@' . $var . '@';
5084 &define_variable ($var, $value);
5087 # Define a variable that represents a program to run. If in Cygnus
5088 # mode, the program is searched for in the build (or source) tree.
5089 # Otherwise no searching is done at all. Arguments are:
5090 # * VAR Name of variable to define
5091 # * WHATDIR Either `src' or `build', depending on where program should
5092 # be found. (runtest is in srcdir!)
5093 # * SUBDIR Subdir of top-level dir
5094 # * PROGRAM Name of program
5095 # * OVERRIDE If specified, the name of the program to use when not in
5096 # Cygnus mode. Defaults to PROGRAM.
5097 sub define_program_variable
5099 local ($var, $whatdir, $subdir, $program, $override) = @_;
5103 $override = $program;
5108 local ($full) = ('$(top_' . $whatdir . 'dir)/../'
5109 . $subdir . '/' . $program);
5110 &define_variable ($var, ('`if test -f ' . $full
5111 . '; then echo ' . $full . '; else echo '
5112 . $program . '; fi`'));
5116 &define_variable ($var, $override);
5121 ################################################################
5123 # Read Makefile.am and set up %contents. Simultaneously copy lines
5124 # from Makefile.am into $output_trailer or $output_vars as
5125 # appropriate. NOTE we put rules in the trailer section. We want
5126 # user rules to come after our generated stuff.
5129 local ($amfile) = @_;
5131 open (AM_FILE, $amfile) || die "automake: couldn't open \`$amfile': $!\n";
5132 print "automake: reading $amfile\n" if $verbose;
5134 $output_vars = ("# $in_file_name generated automatically by automake "
5135 . $VERSION . " from $am_file_name\n");
5137 # Generate copyright for generated Makefile.in.
5138 $output_vars .= $gen_copyright;
5140 local ($saw_bk) = 0;
5141 local ($was_rule) = 0;
5142 local ($spacing) = '';
5143 local ($comment) = '';
5144 local ($last_var_name) = '';
5149 if (/$IGNORE_PATTERN/o)
5151 # Merely delete comments beginning with two hashes.
5153 elsif (/$WHITE_PATTERN/o)
5155 # Stick a single white line before the incoming macro or rule.
5159 elsif (/$COMMENT_PATTERN/o)
5161 # Stick comments before the incoming macro or rule. Make
5162 # sure a blank line preceeds first block of comments.
5163 $spacing = "\n" unless $blank;
5165 $comment .= $spacing . $_;
5174 $output_vars .= $comment . "\n";
5177 local ($am_vars) = '';
5179 local ($is_ok_macro);
5183 unless substr ($_, -1, 1) eq "\n";
5185 $_ =~ s/\@MAINT\@//g
5186 unless $seen_maint_mode;
5188 if (/$IGNORE_PATTERN/o)
5190 # Merely delete comments beginning with two hashes.
5192 elsif (/$WHITE_PATTERN/o)
5194 # Stick a single white line before the incoming macro or rule.
5196 &am_line_error ($., "blank line following trailing backslash")
5199 elsif (/$COMMENT_PATTERN/o)
5201 # Stick comments before the incoming macro or rule.
5202 $comment .= $spacing . $_;
5204 &am_line_error ($., "comment following trailing backslash")
5211 $output_trailer .= join ('', @conditional_stack) . $_;
5216 $am_vars .= join ('', @conditional_stack) . $_;
5218 # Chop newline and backslash if this line is
5219 # continued. ensure trailing whitespace exists.
5222 $contents{$last_var_name} .= ' '
5223 unless $contents{$last_var_name} =~ /\s$/;
5224 $contents{$last_var_name} .= $_;
5225 if (@conditional_stack)
5227 $conditional{$last_var_name} .= "e_cond_val ($_);
5231 elsif (/$IF_PATTERN/o)
5233 &am_line_error ($., "$1 does not appear in AM_CONDITIONAL")
5234 if (! $configure_cond{$1});
5235 push (@conditional_stack, "\@" . $1 . "_TRUE\@");
5237 elsif (/$ELSE_PATTERN/o)
5239 if (! @conditional_stack)
5241 &am_line_error ($., "else without if");
5243 elsif ($conditional_stack[$#conditional_stack] =~ /_FALSE\@$/)
5245 &am_line_error ($., "else after else");
5249 $conditional_stack[$#conditional_stack]
5250 =~ s/_TRUE\@$/_FALSE\@/;
5253 elsif (/$ENDIF_PATTERN/o)
5255 if (! @conditional_stack)
5257 &am_line_error ($., "endif without if");
5261 pop @conditional_stack;
5264 elsif (/$RULE_PATTERN/o)
5268 if (defined $contents{$1}
5269 && (@conditional_stack
5270 ? ! defined $conditional{$1}
5271 : defined $conditional{$1}))
5274 "$1 defined both conditionally and unconditionally");
5276 # Value here doesn't matter; for targets we only note
5280 local ($cond_string) = join ('', @conditional_stack);
5281 if (@conditional_stack)
5283 if ($conditional{$1})
5285 &check_ambiguous_conditional ($1, $cond_string);
5286 $conditional{$1} .= ' ';
5290 $conditional{$1} = '';
5292 $conditional{$1} .= $cond_string . ' 1';
5294 $content_lines{$1} = $.;
5295 $output_trailer .= $comment . $spacing . $cond_string . $_;
5296 $comment = $spacing = '';
5299 # Check the rule for being a suffix rule. If so, store in
5302 local ($source_suffix);
5303 local ($object_suffix);
5305 if (($source_suffix, $object_suffix) = ($1 =~ $SUFFIX_RULE_PATTERN))
5307 $suffix_rules{$source_suffix} = $object_suffix;
5308 print "Sources ending in .$source_suffix become .$object_suffix\n" if $verbose;
5309 $source_suffix_pattern = "(" . join('|', keys %suffix_rules) . ")";
5312 # FIXME: make sure both suffixes are in SUFFIXES? Or set
5313 # SUFFIXES from suffix_rules?
5315 elsif (($is_ok_macro = /$MACRO_PATTERN/o)
5316 || /$BOGUS_MACRO_PATTERN/o)
5318 # Found a macro definition.
5320 $last_var_name = $1;
5321 if (defined $contents{$1}
5322 && (@conditional_stack
5323 ? ! defined $conditional{$1}
5324 : defined $conditional{$1}))
5327 "$1 defined both conditionally and unconditionally");
5329 if ($2 ne '' && substr ($2, -1) eq "\\")
5331 $contents{$last_var_name} = substr ($2, 0, length ($2) - 1);
5335 $contents{$last_var_name} = $2;
5337 local ($cond_string) = join ('', @conditional_stack);
5338 if (@conditional_stack)
5340 if ($conditional{$last_var_name})
5342 &check_ambiguous_conditional ($last_var_name,
5344 $conditional{$last_var_name} .= ' ';
5348 $conditional{$last_var_name} = '';
5350 local ($val) = $contents{$last_var_name};
5351 $conditional{$last_var_name} .= ($cond_string
5353 . "e_cond_val ($val));
5355 $content_lines{$last_var_name} = $.;
5356 $am_vars .= $comment . $spacing . $cond_string . $_;
5357 $comment = $spacing = '';
5361 &am_line_error ($., "bad macro name \`$last_var_name'")
5366 # This isn't an error; it is probably a continued rule.
5367 # In fact, this is what we assume.
5369 $output_trailer .= ($comment . $spacing
5370 . join ('', @conditional_stack) . $_);
5371 $comment = $spacing = '';
5378 $output_trailer .= $comment;
5380 &am_error ("unterminated conditionals: " . join (' ', @conditional_stack))
5381 if (@conditional_stack);
5383 # Compute relative location of the top object directory.
5384 local (@topdir) = ();
5385 foreach (split (/\//, $relative_dir))
5387 next if $_ eq '.' || $_ eq '';
5394 push (@topdir, '..');
5397 @topdir = ('.') if ! @topdir;
5399 $top_builddir = join ('/', @topdir);
5401 ($build_rx = $top_builddir) =~ s/(\W)/\\$1/g;
5402 $output_vars .= &file_contents_with_transform
5403 ('s/\@top_builddir\@/' . $build_rx . '/g;',
5406 # Generate some useful variables when AC_CANONICAL_* used. FIXME:
5407 # this should use generic %configure_vars method.
5408 if ($seen_canonical)
5410 local ($curs, %vars);
5411 $vars{'host_alias'} = 'host_alias';
5412 $vars{'host_triplet'} = 'host';
5413 if ($seen_canonical == $AC_CANONICAL_SYSTEM)
5415 $vars{'build_alias'} = 'build_alias';
5416 $vars{'build_triplet'} = 'build';
5417 $vars{'target_alias'} = 'target_alias';
5418 $vars{'target_triplet'} = 'target';
5420 foreach $curs (sort keys %vars)
5422 $output_vars .= "$curs = \@$vars{$curs}\@\n";
5423 $contents{$curs} = "\@$vars{$curs}\@";
5428 foreach $curs (sort keys %configure_vars)
5430 &define_configure_variable ($curs);
5433 $output_vars .= $am_vars;
5436 ################################################################
5438 sub initialize_global_constants
5440 # Values for AC_CANONICAL_*
5441 $AC_CANONICAL_HOST = 1;
5442 $AC_CANONICAL_SYSTEM = 2;
5444 # Associative array of standard directory names. Entry is TRUE if
5445 # corresponding directory should be installed during
5446 # 'install-exec' phase.
5464 # Commonly found files we look for and automatically include in
5468 "README", "THANKS", "TODO", "NEWS", "COPYING", "COPYING.LIB",
5469 "INSTALL", "ABOUT-NLS", "ChangeLog", "configure", "configure.in",
5470 "config.guess", "config.sub", "AUTHORS", "BACKLOG", "ABOUT-GNU",
5471 "libversion.in", "mdate-sh", "mkinstalldirs", "install-sh",
5472 'texinfo.tex', "ansi2knr.c", "ansi2knr.1", 'elisp-comp',
5473 'ylwrap', 'acinclude.m4', @libtoolize_files,
5477 # Commonly used files we auto-include, but only sometimes.
5480 "aclocal.m4", "acconfig.h", "config.h.top",
5481 "config.h.bot", "stamp-h.in", 'stamp-vti'
5485 -a, --add-missing add missing standard files to package
5486 --amdir=DIR directory storing config files
5487 --build-dir=DIR directory where build being done (for dependencies)
5488 -c, --copy with -a, copy missing files (default is symlink)
5489 --cygnus assume program is part of Cygnus-style tree
5490 --foreign set strictness to foreign
5491 --gnits set strictness to gnits
5492 --gnu set strictness to gnu
5493 --help print this help, then exit
5494 -i, --include-deps include generated dependencies in Makefile.in
5495 --no-force only update Makefile.in's that are out of date
5496 -o DIR, --output-dir=DIR
5497 put generated Makefile.in's into DIR
5498 --srcdir-name=DIR name used for srcdir (for dependencies)
5499 -v, --verbose verbosely list files processed
5500 --version print version number, then exit\n";
5502 # Copyright on generated Makefile.ins.
5504 # Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
5505 # This Makefile.in is free software; the Free Software Foundation
5506 # gives unlimited permission to copy and/or distribute it,
5507 # with or without modifications, as long as this notice is preserved.
5509 # This program is distributed in the hope that it will be useful,
5510 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
5511 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
5512 # PARTICULAR PURPOSE.
5515 # Ignore return result from chmod, because it might give an error
5516 # if we chmod a symlink.
5517 $dist_header = "\t" . '-chmod -R a+r $(distdir)' . "\n";
5518 $dist{'dist-tarZ'} = ("\t"
5519 . '$(TAR) chf - $(distdir) | compress -c > $(distdir).tar.Z'
5521 $dist{'dist-shar'} = ("\t"
5522 . 'shar $(distdir) | gzip > $(distdir).shar.gz'
5524 $dist{'dist-zip'} = "\t" . 'zip -rq $(distdir).zip $(distdir)' . "\n";
5525 $dist{'dist'} = "\t" . 'GZIP=$(GZIP) $(TAR) chozf $(distdir).tar.gz $(distdir)' . "\n";
5526 $dist_trailer = "\t" . '-rm -rf $(distdir)' . "\n";
5529 # (Re)-Initialize per-Makefile.am variables.
5530 sub initialize_per_input
5532 # These two variables are used when generating each Makefile.in.
5533 # They hold the Makefile.in until it is ready to be printed.
5536 $output_trailer = '';
5538 $output_header = '';
5540 # Suffixes found during a run.
5543 # This holds the contents of a Makefile.am, as parsed by
5547 # This holds the names which are targets. These also appear in
5551 # For a variable or target which is defined conditionally, this
5552 # holds an array of the conditional values. The array is composed
5553 # of pairs of condition strings (the variables which configure
5554 # will substitute) and values (the value of a target is
5555 # meaningless). For an unconditional variable, this is empty.
5558 # This holds the line numbers at which various elements of
5559 # %contents are defined.
5560 %content_lines = ();
5562 # This holds a 1 if a particular variable was examined.
5565 # This is the conditional stack.
5566 @conditional_stack = ();
5568 # This holds the "relative directory" of the current Makefile.in.
5569 # Eg for src/Makefile.in, this is "src".
5572 # This holds a list of files that are included in the
5576 # List of dependencies for the obvious targets.
5592 # A list of files deleted by `maintainer-clean'.
5593 @maintainer_clean_files = ();
5595 # These are pretty obvious, too. They are used to define the
5596 # SOURCES and OBJECTS variables.
5600 # TRUE if current directory holds any C source files.
5601 $dir_holds_sources = 0;
5603 # These variables track inclusion of various compile-related .am
5604 # files. $included_generic_compile is TRUE if the basic code has
5605 # been included. $included_knr_compile is TRUE if the ansi2knr
5606 # code has been included. $included_libtool_compile is TRUE if
5607 # libtool support has been included.
5608 $included_generic_compile = 0;
5609 $included_knr_compile = 0;
5610 $included_libtool_compile = 0;
5612 # TRUE if current directory holds any headers.
5613 $dir_holds_headers = 0;
5615 # TRUE if install targets should work recursively.
5616 $recursive_install = 0;
5621 # Strictness levels.
5622 $strictness = $default_strictness;
5623 $strictness_name = $default_strictness_name;
5625 # Options from AUTOMAKE_OPTIONS.
5628 # Whether or not dependencies are handled. Can be further changed
5629 # in handle_options.
5630 $use_dependencies = $cmdline_use_dependencies;
5633 $local_maint_charset = $maint_charset;
5635 # All yacc and lex source filenames for this directory. Use
5636 # filenames instead of raw count so that multiple instances are
5637 # counted correctly (eg one yacc file can appear in multiple
5638 # programs without harm).
5642 # C++ source extensions we've seen.
5643 %cxx_extensions = ();
5645 # TRUE if we've seen any non-C++ sources. This actually holds a
5646 # line number or the name of a symbol corresponding to a line
5647 # number where the C sources were seen. If it is -1 then it means
5648 # we couldn't (easily) figure out which line of the Makefile.am
5649 # mentioned the sources.
5652 # TRUE if we've seen any sources at all.
5653 $seen_any_source = 0;
5655 # This is a list of all targets to run during "make dist".
5658 # Keys in this hash are the basenames of files which must depend
5660 %de_ansi_files = ();
5662 # This maps the source extension of a suffix rule to its
5663 # corresponding output extension.
5666 # This is the name of the recursive `all' target to use.
5667 $all_target = 'all-recursive';
5671 ################################################################
5673 # Return contents of a file from $am_dir, automatically skipping
5674 # macros or rules which are already known. Runs command on each line
5675 # as it is read; this command can modify $_.
5676 sub file_contents_with_transform
5678 local ($command, $basename) = @_;
5679 local ($file) = $am_dir . '/' . $basename . '.am';
5681 if ($command ne '' && substr ($command, -1) ne ';')
5683 die "automake: programming error in file_contents_with_transform: $command\n";
5686 open (FC_FILE, $file)
5687 || die "automake: installation error: cannot open \`$file'\n";
5689 # print "automake: reading $file\n" if $verbose;
5691 local ($was_rule) = 0;
5692 local ($result_vars) = '';
5693 local ($result_rules) = '';
5694 local ($comment) = '';
5695 local ($spacing) = "\n";
5696 local ($skipping) = 0;
5701 $_ =~ s/\@MAINT\@//g
5702 unless $seen_maint_mode;
5704 $had_chars = length ($_) && $_ ne "\n";
5706 # If the transform caused all the characters to go away, then
5707 # ignore the line. Why do this? Because in Perl 4, a "next"
5708 # inside of an eval doesn't affect a loop outside the eval.
5709 # So we can't pass in a "transform" that uses next. We used
5710 # to do this. "Empty" also means consisting of a single
5712 next if $had_chars && ($_ eq '' || $_ eq "\n");
5714 if (/$IGNORE_PATTERN/o)
5716 # Merely delete comments beginning with two hashes.
5718 elsif (/$WHITE_PATTERN/o)
5720 # Stick a single white line before the incoming macro or rule.
5722 &am_line_error ($., "blank line following trailing backslash")
5725 elsif (/$COMMENT_PATTERN/o)
5727 # Stick comments before the incoming macro or rule.
5728 $comment .= $spacing . $_;
5730 &am_line_error ($., "comment following trailing backslash")
5737 $result_rules .= $_ if ! $skipping;
5741 $result_vars .= $_ if ! $skipping;
5745 elsif (/$RULE_PATTERN/o)
5749 $skipping = defined $contents{$1};
5750 $result_rules .= $comment . $spacing . $_ if ! $skipping;
5751 $comment = $spacing = '';
5754 elsif (/$MACRO_PATTERN/o)
5756 # Found a variable reference.
5758 $skipping = defined $contents{$1};
5759 $result_vars .= $comment . $spacing . $_ if ! $skipping;
5760 $comment = $spacing = '';
5765 # This isn't an error; it is probably a continued rule.
5766 # In fact, this is what we assume.
5768 $result_rules .= $comment . $spacing . $_ if ! $skipping;
5769 $comment = $spacing = '';
5775 return $result_vars . $result_rules . $comment;
5778 # Like file_contents_with_transform, but no transform.
5781 return &file_contents_with_transform ('', @_);
5784 # Find all variable prefixes that are used for install directories. A
5785 # prefix `zar' qualifies iff:
5786 # * `zardir' is a variable.
5787 # * `zar_PRIMARY' is a variable.
5788 sub am_primary_prefixes
5790 local ($primary, @prefixes) = @_;
5792 local (%valid, $varname);
5793 grep ($valid{$_} = 0, @prefixes);
5794 $valid{'EXTRA'} = 0;
5795 foreach $varname (keys %contents)
5797 if ($varname =~ /^(.*)_$primary$/)
5799 if (! defined $valid{$1}
5800 && ! &variable_defined ($1 . 'dir')
5801 # Note that a configure variable is always legitimate.
5802 # It is natural to name such variables after the
5803 # primary, so we explicitly allow it.
5804 && ! defined $configure_vars{$varname})
5806 &am_line_error ($varname, "invalid variable \`$varname'");
5810 # Ensure all extended prefixes are actually used.
5819 # Handle `where_HOW' variable magic. Does all lookups, generates
5820 # install code, and possibly generates code to define the primary
5821 # variable. The first argument is the name of the .am file to munge,
5822 # the second argument is the primary variable (eg HEADERS), and all
5823 # subsequent arguments are possible installation locations. Returns
5824 # list of all values of all _HOW targets.
5826 # FIXME: this should be rewritten to be cleaner. It should be broken
5827 # up into multiple functions.
5829 # Usage is: am_install_var (OPTION..., file, HOW, where...)
5834 local ($do_clean) = 0;
5837 if (defined $configure_vars{'LIBTOOL'})
5839 # Transform '@LIBTOOL ...@' to '$(LIBTOOL) ...'
5840 $ltxform = 's/\@LIBTOOL([^\@]*)\@/\$(LIBTOOL) $1/;';
5844 # Delete '@LIBTOOL ...@'
5845 $ltxform = 's/\@LIBTOOL([^\@]*)\@//;';
5851 $cygxform = 's/\@EXEEXT\@//g;';
5855 $cygxform = 's/\@EXEEXT\@/\$(EXEEXT)/g;';
5860 if ($args[0] eq '-clean')
5864 elsif ($args[0] !~ /^-/)
5870 local ($file, $primary, @prefixes) = @args;
5873 local (@result) = ();
5875 # Now that configure substitutions are allowed in where_HOW
5876 # variables, it is an error to actually define the primary. We
5877 # allow `JAVA', as it is customarily used to mean the Java
5878 # interpreter. This is but one of several Java hacks.
5879 &am_line_error ($primary, "\`$primary' is an anachronism")
5880 if &variable_defined ($primary) && $primary ne 'JAVA';
5883 # Look for misspellings. It is an error to have a variable ending
5884 # in a "reserved" suffix whose prefix is unknown, eg
5885 # "bni_PROGRAMS". However, unusual prefixes are allowed if a
5886 # variable of the same name (with "dir" appended) exists. For
5887 # instance, if the variable "zardir" is defined, then
5888 # "zar_PROGRAMS" becomes valid. This is to provide a little extra
5889 # flexibility in those cases which need it. Perhaps it should be
5890 # disallowed in the Gnits case? The problem is, sometimes it is
5891 # useful to put things in a subdir of eg pkgdatadir, perhaps even
5893 local (%valid) = &am_primary_prefixes ($primary, @prefixes);
5895 # If a primary includes a configure substitution, then the EXTRA_
5896 # form is required. Otherwise we can't properly do our job.
5897 local ($require_extra);
5898 local ($warned_about_extra) = 0;
5900 local ($clean_file) = $file . '-clean';
5903 foreach $X (sort keys %valid)
5905 $one_name = $X . '_' . $primary;
5906 if (&variable_defined ($one_name))
5908 # Append actual contents of where_PRIMARY variable to
5911 foreach $rcurs (&variable_value_as_list ($one_name, 'all'))
5913 # Skip configure substitutions. Possibly bogus.
5914 if ($rcurs =~ /^\@.*\@$/)
5918 if (! $warned_about_extra)
5920 $warned_about_extra = 1;
5921 &am_line_error ($one_name,
5922 "\`$one_name' contains configure substitution, but shouldn't");
5925 # Check here to make sure variables defined in
5926 # configure.in do not imply that EXTRA_PRIMARY
5928 elsif (! defined $configure_vars{$one_name})
5930 $require_extra = $one_name;
5936 push (@result, $rcurs);
5939 # "EXTRA" shouldn't be used when generating clean targets,
5940 # all, or install targets.
5941 next if $X eq 'EXTRA';
5943 # A blatant hack: we rewrite each _PROGRAMS primary to
5944 # include EXEEXT when in Cygwin32 mode.
5945 if ($seen_exeext && $primary eq 'PROGRAMS')
5947 local (@conds) = &variable_conditions ($one_name);
5948 local (@one_binlist);
5950 # FIXME: this definitely loses aesthetically; it
5951 # redefines $ONE_NAME. Instead we should arrange for
5952 # variable definitions to be output later, instead of
5958 foreach $rcurs (&variable_value_as_list ($one_name, ''))
5960 if ($rcurs =~ /\./ || $rcurs =~ /^\@.*\@$/)
5962 push (@one_binlist, $rcurs);
5966 push (@one_binlist, $rcurs . '$(EXEEXT)');
5970 delete $contents{$one_name};
5971 &define_pretty_variable ($one_name, '', @one_binlist);
5976 local ($condvals) = '';
5977 foreach $cond (@conds)
5980 local (@condval) = &variable_value_as_list ($one_name,
5982 foreach $rcurs (@condval)
5984 if ($rcurs =~ /\./ || $rcurs =~ /^\@.*\@$/)
5986 push (@one_binlist, $rcurs);
5990 push (@one_binlist, $rcurs . '$(EXEEXT)');
5994 push (@condvals, $cond);
5995 push (@condvals, join (' ', @one_binlist));
5998 delete $contents{$one_name};
6002 $cond = shift (@condvals);
6003 local (@val) = split (' ', shift (@condvals));
6004 &define_pretty_variable ($one_name, $cond, @val);
6012 &file_contents_with_transform ('s/\@DIR\@/' . $X . '/go;'
6016 push (@clean, $X . $primary);
6017 &push_phony_cleaners ($X . $primary);
6022 push (@check, '$(' . $one_name . ')');
6026 push (@used, '$(' . $one_name . ')');
6028 if ($X eq 'noinst' || $X eq 'check')
6030 # Objects which don't get installed by default.
6035 &file_contents_with_transform ('s/\@DIR\@/' . $X . '/g;'
6036 . $ltxform . $cygxform,
6039 push (@uninstall, 'uninstall-' . $X . $primary);
6040 push (@phony, 'uninstall-' . $X . $primary);
6041 push (@installdirs, '$(DESTDIR)$(' . $X . 'dir)');
6042 if (defined $exec_dir_p{$X} ? $exec_dir_p{$X} : ($X =~ /exec/))
6044 push (@install_exec, 'install-' . $X . $primary);
6045 push (@phony, 'install-' . $X . $primary);
6049 push (@install_data, 'install-' . $X . $primary);
6050 push (@phony, 'install-' . $X . $primary);
6055 # The JAVA variable is used as the name of the Java interpreter.
6056 if (@used && $primary ne 'JAVA')
6059 &define_pretty_variable ($primary, '', @used);
6060 $output_vars .= "\n";
6063 if ($require_extra && ! &variable_defined ('EXTRA_' . $primary))
6065 &am_line_error ($require_extra,
6066 "\`$require_extra' contains configure substitution, but \`EXTRA_$primary' not defined");
6069 # Push here because PRIMARY might be configure time determined.
6070 push (@all, '$(' . $primary . ')')
6071 if @used && $primary ne 'JAVA';
6077 ################################################################
6079 # This variable is local to the "require file" set of functions.
6080 @require_file_paths = ();
6082 # Verify that the file must exist in the current directory. Usage:
6083 # require_file (isconfigure, line_number, strictness, file) strictness
6084 # is the strictness level at which this file becomes required. Must
6085 # set require_file_paths before calling this function.
6086 # require_file_paths is set to hold a single directory (the one in
6087 # which the first file was found) before return.
6088 sub require_file_internal
6090 local ($is_configure, $line, $mystrict, @files) = @_;
6091 local ($file, $fullfile);
6092 local ($found_it, $errfile, $errdir);
6095 foreach $file (@files)
6098 foreach $dir (@require_file_paths)
6102 $fullfile = $relative_dir . "/" . $file;
6103 $errdir = $relative_dir unless $errdir;
6107 $fullfile = $dir . "/" . $file;
6108 $errdir = $dir unless $errdir;
6111 # Use different name for "error filename". Otherwise on
6112 # an error the bad file will be reported as eg
6113 # `../../install-sh' when using the default
6115 $errfile = $errdir . '/' . $file;
6120 # FIXME: Once again, special-case `.'.
6121 &push_dist_common ($file)
6122 if $dir eq $relative_dir || $dir eq '.';
6130 # Prune the path list.
6131 @require_file_paths = $save_dir;
6135 if ($strictness >= $mystrict)
6137 local ($trailer) = '';
6138 local ($suppress) = 0;
6140 # Only install missing files according to our desired
6142 local ($message) = "required file \`$errfile' not found";
6147 # Maybe run libtoolize.
6149 && grep ($_ eq $file, @libtoolize_files)
6150 && system ('libtoolize', '--automake'))
6152 $message = "installing \`$errfile'";
6154 $trailer = "; cannot run \`libtoolize': $!";
6156 elsif (-f ($am_dir . '/' . $file))
6158 # Install the missing file. Symlink if we
6159 # can, copy if we must. Note: delete the file
6160 # first, in case it is a dangling symlink.
6161 $message = "installing \`$errfile'";
6163 if ($symlink_exists && ! $copy_missing)
6165 if (! symlink ($am_dir . '/' . $file, $errfile))
6168 $trailer = "; error while making link: $!\n";
6171 elsif (! system ('cp', $am_dir . '/' . $file, $errfile))
6174 $trailer = "\n error while copying\n";
6179 local ($save) = $exit_status;
6182 # FIXME: allow actual file to be specified.
6183 &am_conf_line_error ('configure.in', $line,
6184 "$message$trailer");
6188 &am_line_error ($line, "$message$trailer");
6190 $exit_status = $save if $suppress;
6196 # Like require_file_with_line, but error messages refer to
6197 # configure.in, not the current Makefile.am.
6198 sub require_file_with_conf_line
6200 @require_file_paths = '.';
6201 &require_file_internal (1, @_);
6204 sub require_file_with_line
6206 @require_file_paths = '.';
6207 &require_file_internal (0, @_);
6212 @require_file_paths = '.';
6213 &require_file_internal (0, '', @_);
6216 # Require a file that is also required by Autoconf. Looks in
6217 # configuration path, as specified by AC_CONFIG_AUX_DIR.
6218 sub require_config_file
6220 @require_file_paths = @config_aux_path;
6221 &require_file_internal (1, '', @_);
6222 local ($dir) = $require_file_paths[0];
6223 @config_aux_path = @require_file_paths;
6226 $config_aux_dir = '.';
6230 $config_aux_dir = '$(top_srcdir)/' . $dir;
6234 # Assumes that the line number is in Makefile.am.
6235 sub require_conf_file_with_line
6237 @require_file_paths = @config_aux_path;
6238 &require_file_internal (0, @_);
6239 local ($dir) = $require_file_paths[0];
6240 @config_aux_path = @require_file_paths;
6243 $config_aux_dir = '.';
6247 $config_aux_dir = '$(top_srcdir)/' . $dir;
6251 # Assumes that the line number is in Makefile.am.
6252 sub require_conf_file_with_conf_line
6254 @require_file_paths = @config_aux_path;
6255 &require_file_internal (1, @_);
6256 local ($dir) = $require_file_paths[0];
6257 @config_aux_path = @require_file_paths;
6260 $config_aux_dir = '.';
6264 $config_aux_dir = '$(top_srcdir)/' . $dir;
6268 ################################################################
6270 # Push a list of files onto dist_common.
6271 sub push_dist_common
6273 local (@files) = @_;
6276 foreach $file (@files)
6278 $dist_common{$file} = 1;
6282 # Push a list of clean targets onto phony.
6283 sub push_phony_cleaners
6287 foreach $target ('mostly', 'dist', '', 'maintainer-')
6289 push (@phony, $target . 'clean-' . $base);
6296 $strictness_name = $_[0];
6297 if ($strictness_name eq 'gnu')
6301 elsif ($strictness_name eq 'gnits')
6303 $strictness = $GNITS;
6305 elsif ($strictness_name eq 'foreign')
6307 $strictness = $FOREIGN;
6311 die "automake: level \`$strictness_name' not recognized\n";
6316 ################################################################
6318 # Return directory name of file.
6324 ($sub = $file) =~ s,/+[^/]+$,,g;
6325 $sub = '.' if $sub eq $file;
6329 # Return file name of a file.
6335 ($sub = $file) =~s,^.*/+,,g;
6344 open (TOUCH, ">> $file");
6348 # Glob something. Do this to avoid indentation screwups everywhere we
6349 # want to glob. Gross!
6356 ################################################################
6358 # Print an error message and set exit status.
6361 warn "automake: ${am_file}.am: ", join (' ', @_), "\n";
6367 local ($symbol, @args) = @_;
6369 if ($symbol && "$symbol" ne '-1')
6371 # If SYMBOL not already a line number, look it up in Makefile.am.
6372 if ($symbol =~ /^\d+$/)
6376 elsif (defined $content_lines{$symbol})
6378 $symbol = $content_lines{$symbol} . ': ';
6382 # A single space, to provide nice separation.
6385 warn "${am_file}.am:", $symbol, join (' ', @args), "\n";
6394 # Like am_error, but while scanning configure.in.
6397 # FIXME: can run in subdirs.
6398 warn "automake: configure.in: ", join (' ', @_), "\n";
6402 # Error message with line number referring to configure.in.
6403 sub am_conf_line_error
6405 local ($file, $line, @args) = @_;
6409 warn "$file: $line: ", join (' ', @args), "\n";
6414 &am_conf_error (@args);
6418 # Warning message with line number referring to configure.in.
6419 # Does not affect exit_status
6420 sub am_conf_line_warning
6422 local ($saved_exit_status) = $exit_status;
6423 &am_conf_line_error (@_);
6424 $exit_status = $saved_exit_status;
6427 # Tell user where our aclocal.m4 is, but only once.
6428 sub keyed_aclocal_warning
6431 warn "automake: macro \`$key' can be generated by \`aclocal'\n";
6434 # Print usage information.
6437 print "Usage: automake [OPTION] ... [Makefile]...\n\n";
6438 print "Generate Makefile.in for autoconf from Makefile.am\n";
6440 print "\nFiles which are automatically distributed, if found:\n";
6441 $~ = "USAGE_FORMAT";
6442 local (@lcomm) = sort ((@common_files, @common_sometimes));
6443 local ($one, $two, $three, $four);
6446 $one = shift @lcomm;
6447 $two = @lcomm ? shift @lcomm : '';
6448 $three = @lcomm ? shift @lcomm : '';
6449 $four = @lcomm ? shift @lcomm : '';
6453 print "\nReport bugs to <bug-automake\@gnu.org>.\n";
6458 format USAGE_FORMAT =
6459 @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<
6460 $one, $two, $three, $four