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 # TRUE if in verbose mode.
89 # This holds our (eventual) exit status. We don't actually exit until
90 # we have processed all input files.
93 # From the Perl manual.
94 $symlink_exists = (eval 'symlink ("", "");', $@ eq '');
96 # TRUE if missing standard files should be installed.
99 # Files found by scanning configure.in for LIBOBJS.
102 # True if AM_C_PROTOTYPES appears in configure.in.
103 $am_c_prototypes = 0;
105 # Names used in AC_CONFIG_HEADER call. @config_fullnames holds the
106 # name which appears in AC_CONFIG_HEADER, colon and all.
107 # @config_names holds the file names. @config_headers holds the '.in'
108 # files. Ordinarily these are similar, but they can be different if
109 # the weird "NAME:FILE" syntax is used.
110 @config_fullnames = ();
112 @config_headers = ();
113 # Line number at which AC_CONFIG_HEADER appears in configure.in.
114 $config_header_line = 0;
116 # Directory where output files go. Actually, output files are
117 # relative to this directory.
118 $output_directory = '.';
120 # Relative location of top build directory.
123 # Absolute location of top build directory.
124 $build_directory = '';
126 # Name of srcdir as given in build directory's Makefile. For
130 # List of Makefile.am's to process, and their corresponding outputs.
134 # List of files in AC_OUTPUT without Makefile.am, and their outputs.
135 @other_input_files = ();
136 # Line number at which AC_OUTPUT seen.
139 # List of directories to search for configure-required files. This
140 # can be set by AC_CONFIG_AUX_DIR.
141 @config_aux_path = ('.', '..', '../..');
142 $config_aux_dir = '';
144 # Whether AC_PROG_MAKE_SET has been seen in configure.in.
147 # Whether AM_GNU_GETTEXT has been seen in configure.in.
149 # Line number at which AM_GNU_GETTEXT seen.
150 $ac_gettext_line = 0;
152 # Whether ALL_LINGUAS has been seen.
156 # Line number at which it appears.
157 $all_linguas_line = 0;
159 # 1 if AC_PROG_INSTALL seen, 2 if AM_PROG_INSTALL seen.
160 $seen_prog_install = 0;
162 # 1 if any scripts installed, 0 otherwise.
163 $scripts_installed = 0;
165 # Whether AC_PATH_XTRA has been seen in configure.in.
168 # TRUE if AC_DECL_YYTEXT was seen.
169 $seen_decl_yytext = 0;
171 # TRUE if we've seen AC_CANONICAL_(HOST|SYSTEM). The presence of
172 # AC_CHECK_TOOL also sets this.
175 # TRUE if we've seen AC_ARG_PROGRAM.
178 # TRUE if we've seen AM_PROG_LIBTOOL.
182 # Files installed by libtoolize.
183 @libtoolize_files = ('ltconfig', 'ltmain.sh', 'config.guess', 'config.sub');
185 # TRUE if we've seen AM_MAINTAINER_MODE.
186 $seen_maint_mode = 0;
188 # TRUE if we've seen PACKAGE and VERSION.
192 # Actual version we've seen.
193 $package_version = '';
195 # Line number where we saw version definition.
196 $package_version_line = 0;
198 # TRUE if we've seen AM_PATH_LISPDIR.
201 # TRUE if we've seen AM_EXEEXT.
204 # Hash table of discovered configure substitutions. Keys are names,
205 # values are meaningless.
206 %configure_vars = ();
208 # Charsets used by maintainer and in distribution. MAINT_CHARSET is
209 # handled in a funny way: if seen in the top-level Makefile.am, it is
210 # used for every directory which does not specify a different value.
211 # The rationale here is that some directories (eg gettext) might be
212 # distributions of other packages, and thus require their own charset
213 # info. However, the DIST_CHARSET must be the same for the entire
214 # package; it can only be set at top-level.
215 # FIXME: this yields bugs when rebuilding. What to do? Always
216 # read (and sometimes discard) top-level Makefile.am?
218 $dist_charset = 'utf8'; # recode doesn't support this yet.
220 # Name of input file ("Makefile.in") and output file ("Makefile.am").
221 # These have no directory components.
225 # TRUE if --cygnus seen.
228 # Keys of this hash are names of dependency files to ignore.
229 %omit_dependencies = ();
231 # Hash table of AM_CONDITIONAL variables seen in configure.
232 %configure_cond = ();
234 # Map from obsolete macros to hints for new macros.
235 # FIXME complete the list so that there are no `0' hints.
238 'AC_FEATURE_CTYPE', "use \`AC_HEADER_STDC'",
239 'AC_FEATURE_ERRNO', "add \`strerror' to \`AC_REPLACE_FUNCS(...)'",
240 'AC_FEATURE_EXIT', 0,
241 'AC_SYSTEM_HEADER', 0,
243 # Note that we do not handle this one, because it is still run
244 # from AM_CONFIG_HEADER. So we deal with it specially in
246 # 'AC_CONFIG_HEADER', "use \`AM_CONFIG_HEADER'",
248 'fp_C_PROTOTYPES', "use \`AM_C_PROTOTYPES'",
249 'fp_PROG_CC_STDC', "use \`AM_PROG_CC_STDC'",
250 'fp_PROG_INSTALL', "use \`AM_PROG_INSTALL'",
251 'fp_WITH_DMALLOC', "use \`AM_WITH_DMALLOC'",
252 'fp_WITH_REGEX', "use \`AM_WITH_REGEX'",
253 'gm_PROG_LIBTOOL', "use \`AM_PROG_LIBTOOL'",
254 'jm_MAINTAINER_MODE', "use \`AM_MAINTAINER_MODE'",
255 'md_TYPE_PTRDIFF_T', "use \`AM_TYPE_PTRDIFF_T'",
256 'ud_PATH_LISPDIR', "use \`AM_PATH_LISPDIR'",
258 # Now part of autoconf proper, under a different name.
259 'AM_FUNC_FNMATCH', "use \`AC_FUNC_FNMATCH'",
260 'fp_FUNC_FNMATCH', "use \`AC_FUNC_FNMATCH'",
261 'AM_SANITY_CHECK_CC', "automatically done by \`AC_PROG_CC'",
263 # These aren't quite obsolete.
267 # Regexp to match the above macros.
268 $obsolete_rx = '(' . join ('|', keys %obsolete_macros) . ')';
272 &initialize_global_constants;
274 # Parse command line.
275 &parse_arguments (@ARGV);
277 # Do configure.in scan only once.
280 die "automake: no \`Makefile.am' found or specified\n"
283 # Now do all the work on each file.
284 foreach $am_file (@input_files)
286 if (! -f ($am_file . '.am'))
288 &am_error ("\`" . $am_file . ".am' does not exist");
292 &generate_makefile ($output_files{$am_file}, $am_file);
296 if ($seen_prog_install <= $scripts_installed)
298 &am_conf_error (($scripts_installed ? 'AM_PROG_INSTALL' : 'AC_PROG_INSTALL')
299 . " must be used in configure.in");
300 &keyed_aclocal_warning ('AM_PROG_INSTALL')
301 if $scripts_installed;
307 ################################################################
309 # Parse command line.
312 local (@arglist) = @_;
315 &set_strictness ('gnu');
319 if ($arglist[0] eq "--version")
321 print "automake (GNU $PACKAGE) $VERSION\n\n";
322 print "Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.\n";
323 print "This is free software; see the source for copying conditions. There is NO\n";
324 print "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n";
325 print "Written by Tom Tromey <tromey\@cygnus.com>\n";
329 elsif ($arglist[0] eq "--help")
333 elsif ($arglist[0] =~ /^--amdir=(.+)$/)
337 elsif ($arglist[0] eq '--amdir')
339 &require_argument (@arglist);
341 $am_dir = $arglist[0];
343 elsif ($arglist[0] =~ /^--build-dir=(.+)$/)
346 $build_directory = $1 . '/';
348 elsif ($arglist[0] eq '--build-dir')
350 &require_argument (@arglist);
353 $build_directory = $arglist[0] . '/';
355 elsif ($arglist[0] =~ /^--srcdir-name=(.+)$/)
359 elsif ($arglist[0] eq '--srcdir-name')
361 &require_argument (@arglist);
363 $srcdir_name = $arglist[0];
365 elsif ($arglist[0] eq '--gnu')
367 &set_strictness ('gnu');
369 elsif ($arglist[0] eq '--gnits')
371 &set_strictness ('gnits');
373 elsif ($arglist[0] eq '--cygnus')
377 elsif ($arglist[0] eq '--foreign')
379 &set_strictness ('foreign');
381 elsif ($arglist[0] eq '--include-deps' || $arglist[0] eq '-i')
383 $cmdline_use_dependencies = 0;
385 elsif ($arglist[0] eq '--no-force')
387 $force_generation = 0;
389 elsif ($arglist[0] =~ /^--output-dir=(.*)$/)
391 # Set output directory.
392 $output_directory = $1;
394 elsif ($arglist[0] eq '--output-dir' || $arglist[0] eq '-o')
396 &require_argument (@arglist);
398 $output_directory = $arglist[0];
400 elsif ($arglist[0] eq '--add-missing' || $arglist[0] eq '-a')
404 elsif ($arglist[0] eq '--verbose' || $arglist[0] eq '-v')
408 elsif ($arglist[0] eq '--')
410 # Stop option processing.
412 push (@input_files, @arglist);
415 elsif ($arglist[0] =~ /^-/)
417 die "automake: unrecognized option -- \`$arglist[0]'\nTry \`automake --help' for more information.\n";
421 # Handle $local:$input syntax. Note that we only examine
422 # the first ":" file to see if it is automake input; the
423 # rest are just taken verbatim. We still keep all the
424 # files around for dependency checking, however.
425 local ($local, $input, @rest) = split (/:/, $arglist[0]);
432 # Strip .in; later on .am is tacked on. That is how
433 # the automake input file is found. Maybe not the
434 # best way, but it is easy to explain. FIXME: should
435 # be error if .in is missing.
438 push (@input_files, $input);
439 $output_files{$input} = join (':', ($local, @rest));
445 # Take global strictness from whatever we currently have set.
446 $default_strictness = $strictness;
447 $default_strictness_name = $strictness_name;
450 # Ensure argument exists, or die.
453 local ($arg, @arglist) = @_;
454 die "automake: no argument given for option \`$arg'\n"
458 ################################################################
460 # Generate a Makefile.in given the name of the corresponding Makefile and
461 # the name of the file output by config.status.
462 sub generate_makefile
464 local ($output, $makefile) = @_;
466 ($am_file_name = $makefile) =~ s/^.*\///;
467 $in_file_name = $am_file_name . '.in';
468 $am_file_name .= '.am';
470 # $OUTPUT is encoded. If it contains a ":" then the first element
471 # is the real output file, and all remaining elements are input
472 # files. We don't scan or otherwise deal with these input file,
473 # other than to mark them as dependencies. See scan_configure for
475 local (@secondary_inputs);
476 ($output, @secondary_inputs) = split (/:/, $output);
478 &initialize_per_input;
479 $relative_dir = &dirname ($output);
480 $am_relative_dir = &dirname ($makefile);
482 # At the toplevel directory, we might need config.guess, config.sub
483 # or libtool scripts (ltconfig and ltmain.sh).
484 if ($relative_dir eq '.')
486 # libtool requires some files.
487 &require_conf_file_with_conf_line ($libtool_line, $FOREIGN,
491 # AC_CANONICAL_HOST and AC_CANONICAL_SYSTEM need config.guess and
493 &require_config_file ($FOREIGN, 'config.guess', 'config.sub')
497 # We still need Makefile.in here, because sometimes the `dist'
498 # target doesn't re-run automake.
499 if ($am_relative_dir eq $relative_dir)
501 # Only distribute the files if they are in the same subdir as
502 # the generated makefile.
503 &push_dist_common ($in_file_name, $am_file_name);
505 push (@sources, '$(SOURCES)')
506 if &variable_defined ('SOURCES');
507 push (@objects, '$(OBJECTS)')
508 if &variable_defined ('OBJECTS');
510 # This is always the default target. This gives us freedom to do
511 # things in whatever order is convenient. Note that we set up
512 # $output_header here so that we can insert some text just after
513 # the "default" target, but before any other targets. In
514 # particular we want to support the .SUFFIX hack here; this is
515 # documented elsewhere.
516 $output_header = "default: all\n\n";
517 push (@phony, 'default');
519 &read_am_file ($makefile . '.am');
522 # Fatal error. Just return, so we can continue with next file.
526 # Check first, because we might modify some state.
528 &check_gnu_standards;
529 &check_gnits_standards;
531 &handle_configure ($output, $makefile, @secondary_inputs);
538 &handle_built_sources;
540 # This must be run after all the sources are scanned.
541 &handle_yacc_lex_cxx;
543 # Re-init SOURCES and OBJECTS. FIXME: other code shouldn't depend
544 # on this (but currently does).
545 $contents{'SOURCES'} = join (' ', @sources);
546 $contents{'OBJECTS'} = join (' ', @objects);
555 &handle_minor_options;
556 &handle_dist ($makefile);
557 &handle_dependencies;
560 &handle_merge_targets ($makefile);
567 if (! -d ($output_directory . '/' . $am_relative_dir))
569 mkdir ($output_directory . '/' . $am_relative_dir, 0755);
572 local ($out_file) = $output_directory . '/' . $makefile . ".in";
573 if (! $force_generation && -e $out_file)
575 local ($am_time) = (stat ($makefile . '.am'))[9];
576 local ($in_time) = (stat ($out_file))[9];
577 # FIXME: should cache these times.
578 local ($conf_time) = (stat ('configure.in'))[9];
579 # FIXME: how to do unsigned comparison?
580 if ($am_time < $in_time || $am_time < $conf_time)
587 local ($acl_time) = (stat _)[9];
588 return if ($am_time < $acl_time);
592 if (! open (GM_FILE, "> " . $out_file))
594 warn "automake: ${am_file}.in: cannot write: $!\n";
598 print "automake: creating ", $makefile, ".in\n" if $verbose;
600 print GM_FILE $output_vars;
601 print GM_FILE $output_header;
602 print GM_FILE $output_rules;
603 print GM_FILE $output_trailer;
608 ################################################################
610 # Handle AUTOMAKE_OPTIONS variable. Return 1 on error, 0 otherwise.
613 if ($strictness == $GNITS)
615 $options{'readme-alpha'} = 1;
616 $options{'check-news'} = 1;
619 return 0 if ! &variable_defined ('AUTOMAKE_OPTIONS');
621 foreach (&variable_value_as_list ('AUTOMAKE_OPTIONS', ''))
624 if ($_ eq 'gnits' || $_ eq 'gnu' || $_ eq 'foreign')
626 &set_strictness ($_);
628 elsif ($_ eq 'cygnus')
634 # An option like "../lib/ansi2knr" is allowed. With no
635 # path prefix, we assume the required programs are in this
636 # directory. We save the actual option for later.
637 $options{'ansi2knr'} = $_;
639 elsif ($_ eq 'no-installman' || $_ eq 'no-installinfo'
640 || $_ eq 'dist-shar' || $_ eq 'dist-zip'
641 || $_ eq 'dist-tarZ' || $_ eq 'dejagnu'
642 || $_ eq 'no-texinfo.tex'
643 || $_ eq 'readme-alpha' || $_ eq 'check-news')
645 # Explicitly recognize these.
647 elsif ($_ eq 'no-dependencies')
649 $use_dependencies = 0;
651 elsif (/([0-9]+)\.([0-9]+)/)
653 # Got a version number. Note that alpha releases count as
654 # the next higher release. Note also that we assume there
655 # will be a maximum of 100 minor releases for any given
657 local ($rmajor, $rminor) = ($1, $2);
658 if ($VERSION !~ /([0-9]+)\.([0-9]+)([a-z])?/)
661 "automake: programming error: version is incorrect\n";
664 local ($tmajor, $tminor) = ($1, $2);
665 # Handle alpha versions.
666 ++$tminor if defined $3;
668 if ($rmajor > $tmajor || ($rmajor == $tmajor && $rminor > $tminor))
670 &am_line_error ('AUTOMAKE_OPTIONS',
671 "require version $_, only have $VERSION");
677 &am_line_error ('AUTOMAKE_OPTIONS',
678 'option ', $_, 'not recognized');
685 # Return object extension. Just once, put some code into the output.
686 # Argument is the name of the output file
687 sub get_object_extension
692 $dir_holds_sources = 1;
694 # Maybe require libtool library object files.
695 local ($extension) = '.o';
696 $extension = '.lo' if ($out =~ /\.la$/);
698 if (! $included_generic_compile)
702 if (&variable_defined ('CONFIG_HEADER'))
705 foreach $one_hdr (split (' ', &variable_value ('CONFIG_HEADER')))
708 ($var = &dirname ($one_hdr)) =~ s/(\W)/\\$1/g;
709 $xform .= ' ' if $xform;
710 $xform .= '-I' . $var;
713 $xform = 's/\@CONFIG_INCLUDE_SPEC\@/' . $xform . '/go;';
714 $output_vars .= &file_contents_with_transform ($xform,
716 $output_rules .= &file_contents ('compile');
717 &push_phony_cleaners ('compile');
719 # If using X, include some extra variable definitions. NOTE
720 # we don't want to force these into CFLAGS or anything,
721 # because not all programs will necessarily use X.
725 foreach $var ('X_CFLAGS', 'X_LIBS', 'X_EXTRA_LIBS', 'X_PRE_LIBS')
727 &define_configure_variable ($var);
731 push (@suffixes, '.c', '.o', '.S', '.s');
732 push (@clean, 'compile');
734 $included_generic_compile = 1;
737 if ($seen_libtool && ! $included_libtool_compile)
739 # Output the libtool compilation rules.
740 $output_rules .= &file_contents ('libtool');
741 &push_phony_cleaners ('libtool');
743 push (@suffixes, '.lo');
744 push (@clean, 'libtool');
746 $included_libtool_compile = 1;
749 # Check for automatic de-ANSI-fication.
750 if (defined $options{'ansi2knr'})
752 $extension = '$U' . $extension;
753 if (! $included_knr_compile)
755 if (! $am_c_prototypes)
757 &am_line_error ('AUTOMAKE_OPTIONS',
758 "option \`ansi2knr' in use but \`AM_C_PROTOTYPES' not in configure.in");
759 &keyed_aclocal_warning ('AM_C_PROTOTYPES');
760 # Only give this error once.
761 $am_c_prototypes = 1;
764 # Only require ansi2knr files if they should appear in
766 if ($options{'ansi2knr'} eq 'ansi2knr')
768 &require_file_with_line ('AUTOMAKE_OPTIONS', $FOREIGN,
769 'ansi2knr.c', 'ansi2knr.1');
770 $output_rules .= &file_contents ('kr-extra');
771 push (@clean, 'krextra');
772 &push_phony_cleaners ('krextra');
775 # Generate rules to build ansi2knr. If it is in some
776 # other directory, then generate dependencies but have the
777 # rule just run elsewhere.
778 $output_rules .= ($options{'ansi2knr'} . ': '
779 . $options{'ansi2knr'} . ".o\n");
780 if ($options{'ansi2knr'} eq 'ansi2knr')
782 $output_rules .= ("\t\$(LINK) ansi2knr.o \$(LIBS)\n"
783 . "ansi2knr.o: \$(CONFIG_HEADER)\n\n");
787 $output_rules .= ("\tcd " . &dirname ($options{'ansi2knr'})
788 . " && \$(MAKE) ansi2knr\n\n");
791 # Make sure ansi2knr can be found: if no path specified,
793 if ($options{'ansi2knr'} eq 'ansi2knr')
795 # Substitution from AM_C_PROTOTYPES. This makes it be
796 # built only when necessary.
797 &define_configure_variable ('ANSI2KNR');
798 # ansi2knr needs to be built before subdirs, so unshift it.
799 unshift (@all, '$(ANSI2KNR)');
803 # Found in another directory.
804 &define_variable ("ANSI2KNR", $options{'ansi2knr'});
807 $output_rules .= &file_contents ('clean-kr');
810 &push_phony_cleaners ('kr');
812 $included_knr_compile = 1;
819 # Handle yacc and lex.
820 sub handle_yacc_lex_cxx
823 # First do yacc and lex.
826 local ($yacc_count) = scalar (keys %yacc_sources);
827 local ($lex_count) = scalar (keys %lex_sources);
831 local (%seen_suffix) = ();
832 foreach (keys %yacc_sources)
835 &output_yacc_build_rule ($1, $yacc_count > 1)
836 if (! defined $seen_suffix{$1});
837 $seen_suffix{$1} = 1;
840 if (! defined $configure_vars{'YACC'})
842 &am_error ("yacc source seen but \`YACC' not defined in \`configure.in'");
844 if (&variable_defined ('YACCFLAGS'))
846 &am_line_error ('YACCFLAGS',
847 "\`YACCFLAGS' obsolete; use \`YFLAGS' instead");
852 local (%seen_suffix) = ();
853 foreach (keys %lex_sources)
856 &output_lex_build_rule ($1, $lex_count > 1)
857 if (! defined $seen_suffix{$1});
858 $seen_suffix{$1} = 1;
861 if (! defined $configure_vars{'LEX'})
863 &am_error ("lex source seen but \`LEX' not defined in \`configure.in'");
865 if (! $seen_decl_yytext)
867 &am_error ("lex source seen but \`AC_DECL_YYTEXT' not in \`configure.in'");
871 if ($yacc_count > 1 || $lex_count > 1)
873 # If there is more than one distinct yacc (resp lex) source
874 # file in a given directory, then the `ylwrap' program is
875 # required to allow parallel builds to work correctly. FIXME:
876 # for now, no line number.
877 &require_config_file ($FOREIGN, 'ylwrap');
878 if ($config_aux_dir ne '.' && $config_aux_dir ne '')
880 &define_variable ('YLWRAP', $config_aux_dir . "/ylwrap");
884 &define_variable ('YLWRAP', '$(srcdir)/ylwrap');
891 local ($ltcompile, $ltlink) = ('', '');
894 &define_configure_variable ("LIBTOOL");
895 $ltcompile = '$(LIBTOOL) --mode=compile ';
896 $ltlink = '$(LIBTOOL) --mode=link ';
902 local (@cxx_list) = keys %cxx_extensions;
903 local ($cxx_count) = scalar @cxx_list;
906 push (@suffixes, @cxx_list);
908 &define_configure_variable ("CXXFLAGS");
909 &define_variable ('CXXCOMPILE', '$(CXX) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CXXFLAGS)');
910 &define_variable ('LTCXXCOMPILE',
911 $ltcompile . '$(CXX) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CXXFLAGS)')
914 &define_variable ('CXXLINK', $ltlink . '$(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@');
917 foreach $ext (@cxx_list)
919 $output_rules .= ("$ext.o:\n"
920 . "\t\$(CXXCOMPILE) -c \$<\n");
921 $output_rules .= ("$ext.lo:\n"
922 . "\t\$(LTCXXCOMPILE) -c \$<\n")
926 if (! defined $configure_vars{'CXX'})
928 &am_error ("C++ source seen but \`CXX' not defined in \`configure.in'");
933 # Handle some ansi2knr cleanup.
935 if (defined $options{'ansi2knr'} && keys %de_ansi_files)
937 # Make all _.c files depend on their corresponding .c files.
938 local ($base, @objects);
939 foreach $base (sort (keys %de_ansi_files))
941 # Each _.c file must depend on ansi2knr; otherwise it
942 # might be used in a parallel build before it is built.
943 # We need to support files in the srcdir and in the build
944 # dir (because these files might be auto-generated. But
945 # we can't use $< -- some makes only define $< during a
947 $output_rules .= ($base . "_.c: $base.c \$(ANSI2KNR)\n\t"
949 . '`if test -f $(srcdir)/' . $base . '.c'
950 . '; then echo $(srcdir)/' . $base . '.c'
951 . '; else echo ' . $base . '.c; fi` '
953 push (@objects, $base . '_.o');
954 push (@objects, $base . '_.lo') if $seen_libtool;
957 # Make all _.o (and _.lo) files depend on ansi2knr.
958 # Use a sneaky little hack to make it print nicely.
959 &pretty_print_rule ('', '', @objects, ':', '$(ANSI2KNR)');
963 # Last, handle some C cleanup.
965 if ($seen_any_source)
967 &define_configure_variable ('CFLAGS');
968 &define_variable ('COMPILE',
969 '$(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)');
970 &define_variable ('LTCOMPILE',
972 '$(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)')
974 &define_variable ('LINK', $ltlink . '$(CC) $(CFLAGS) $(LDFLAGS) -o $@');
977 if ($seen_c_source && ! defined $configure_vars{'CC'})
979 &am_line_error ($seen_c_source,
980 "C source seen but \`CC' not defined in \`configure.in'");
985 # Output a rule to build from a YACC source. The output from YACC is
986 # compiled with C or C++, depending on the extension of the YACC file.
987 sub output_yacc_build_rule
989 local ($yacc_suffix, $use_ylwrap, $c_suffix) = @_;
991 local ($c_suffix, $suffix);
992 ($c_suffix = $yacc_suffix) =~ tr/y/c/;
993 push (@suffixes, $yacc_suffix, $c_suffix, '.h');
995 # Generate rule for c/c++ and header file. Probably should only
996 # do header if `yacc -d' is run. But how can we determine that?
997 foreach $suffix ($c_suffix, '.h')
999 $output_rules .= "$yacc_suffix$suffix:\n\t";
1003 $output_rules .= ('$(SHELL) $(YLWRAP)'
1004 . ' "$(YACC)" $< y.tab.c $*' . $c_suffix
1005 . ' y.tab.h $*.h -- $(YFLAGS)');
1009 $output_rules .= ('$(YACC) $(YFLAGS) $< && mv y.tab.c $*'
1011 . "\tif test -f y.tab.h; then \\\n"
1012 . "\tif cmp -s y.tab.h \$*.h; then rm -f y.tab.h; else mv y.tab.h \$*.h; fi; \\\n"
1015 $output_rules .= "\n";
1019 sub output_lex_build_rule
1021 local ($lex_suffix, $use_ylwrap) = @_;
1024 ($c_suffix = $lex_suffix) =~ tr/l/c/;
1025 push (@suffixes, $lex_suffix);
1026 &define_configure_variable ('LEX_OUTPUT_ROOT');
1027 &define_configure_variable ('LEXLIB');
1028 $output_rules .= "$lex_suffix$c_suffix:\n\t";
1032 # Is the $@ correct here? If so, why not use it in the ylwrap
1033 # build rule for yacc above?
1034 $output_rules .= '$(SHELL) $(YLWRAP)'
1035 . ' "$(LEX)" $< $(LEX_OUTPUT_ROOT).c $@ -- $(LFLAGS)';
1039 $output_rules .= '$(LEX) $(LFLAGS) $< && mv $(LEX_OUTPUT_ROOT).c $@';
1041 $output_rules .= "\n";
1045 # Check to make sure a source defined in LIBOBJS is not explicitly
1046 # mentioned. This is a separate function (as opposed to being inlined
1047 # in handle_source_transform) because it isn't always appropriate to
1049 sub check_libobjs_sources
1051 local ($one_file, $unxformed) = @_;
1053 local ($prefix, $file, @files);
1054 foreach $prefix ('', 'EXTRA_')
1056 if (&variable_defined ($prefix . $one_file . '_SOURCES'))
1058 @files = &variable_value_as_list (($prefix
1059 . $one_file . '_SOURCES'),
1062 elsif ($prefix eq '')
1064 @files = ($unxformed . '.c');
1071 foreach $file (@files)
1073 if (defined $libsources{$file})
1075 &am_line_error ($prefix . $one_file . '_SOURCES',
1076 "automatically discovered file \`$file' should not be explicitly mentioned");
1082 # Does much of the actual work for handle_source_transform.
1084 # list of source files to transform
1086 # first element is name of linker to use (empty string for default linker)
1087 # remaining elements are names of `.o's
1088 sub handle_single_transform_list
1090 local (@files) = @_;
1091 local ($linker) = '';
1092 local (@result) = ();
1093 local ($nonansi_obj) = $obj;
1094 $nonansi_obj =~ s/_//g;
1097 # Turn sources into objects.
1100 # Skip header files, including C++-ish ones. The list
1101 # of C++ header extensions comes from Emacs 19.32
1108 # Skip things that look like configure substitutions.
1111 # Include appropriate file for lex or yacc source in
1112 # distribution. If the extension is the regular '.y' or
1113 # '.l', we assume C compilation, and the generated file
1114 # has exension .c. Otherwise, we compile with C++, and
1115 # make the following association: (yy -> cc, y++ -> c++,
1116 # yxx -> cxx), similarly for .ll, etc.
1117 if (/^(.*)\.(y|yy|y\+\+|yxx)$/)
1122 &push_dist_common ("$1.$ext");
1123 $yacc_sources{$_} = 1;
1125 elsif (/^(.*)\.(l|ll|l\+\+|lxx)$/)
1130 &push_dist_common ("$1.$ext");
1131 $lex_sources{$_} = 1;
1134 # Strip any directory prefix.
1135 $_ = &basename ($_);
1137 # Transform source files into .o files. List of C++
1138 # extensions comes from Emacs 19.34 etags.
1139 if (s/\.(c\+\+|cc|cpp|cxx|C)$/$nonansi_obj/)
1141 $cxx_extensions{'.' . $1} = 1;
1142 $linker = 'CXXLINK';
1144 elsif (s/\.(yy|y\+\+|yxx|ll|l\+\+|lxx)$/$nonansi_obj/)
1146 # Compiling lex or yacc with C++
1149 $cxx_extensions{".$ext"} = 1;
1150 $linker = 'CXXLINK';
1152 elsif (s/\.([Ff]|f90|for)$/$nonansi_obj/)
1154 # FORTRAN support. FIXME: not finished.
1156 elsif (s/\.[sS]$/$nonansi_obj/)
1158 # .s is assembly. Just rewrite it. FIXME: not finished.
1160 elsif (defined ($options{'ansi2knr'}) && s/_\.[cly]$/_.c/)
1162 # FIXME include line number in error.
1163 &am_error ("C source file \`$_' would be deleted by ansi2knr rules");
1165 elsif (s/\.[cly]$//)
1167 # .c is C. .l is lex. .y is yacc.
1169 # Note: first we rewrite (eg) foo.c to foo and push
1170 # the file onto the list of deansified files. Then we add
1171 # $obj, which can either be `_.o', or simply `.o' if
1172 # deansification is not required.
1173 $de_ansi_files{$_} = 1;
1177 elsif (/\.$source_suffix_pattern$/)
1179 # We just rewrite it. Maybe we should do more.
1180 s//.$suffix_rules{$1}/;
1184 # No error message here. Used to have one, but it was
1189 $seen_any_source = 1;
1192 # Transform .o or $o file into .P file (for automatic
1195 $dep_files{'.deps/' . $_} = 1;
1199 return ($linker, @result);
1202 # Handle SOURCE->OBJECT transform for one program or library.
1204 # canonical (transformed) name of object to build
1205 # actual name of object to build
1206 # object extension (ie either `.o' or `$o'.
1207 # Return result is name of linker variable that must be used.
1208 # Empty return means just use `LINK'.
1209 sub handle_source_transform
1211 # one_file is canonical name. unxformed is given name. obj is
1213 local ($one_file, $unxformed, $obj) = @_;
1214 local ($objpat) = $obj;
1215 $objpat =~ s/(\W)/\\$1/g;
1216 # Handle explicit `.o' as well as whatever we're passed.
1217 $objpat = '(' . $objpat . "|\\.o)";
1219 local ($linker) = '';
1221 if (&variable_defined ($one_file . "_OBJECTS"))
1223 &am_line_error ($one_file . '_OBJECTS',
1224 $one_file . '_OBJECTS', 'should not be defined');
1225 # No point in continuing.
1229 local (@files, @result, $prefix, $temp);
1230 foreach $prefix ('', 'EXTRA_')
1233 local ($var) = $prefix . $one_file . "_SOURCES";
1234 if (&variable_defined ($var))
1236 push (@sources, '$(' . $prefix . $one_file . "_SOURCES)");
1237 push (@objects, '$(' . $prefix . $one_file . "_OBJECTS)")
1238 unless $prefix eq 'EXTRA_';
1239 local (@conds) = &variable_conditions ($var);
1242 @files = &variable_value_as_list ($var, '');
1246 local ($cond, $cond_var_name);
1248 local (@namelist) = ();
1249 foreach $cond (@conds)
1251 @files = &variable_value_as_list ($var, $cond);
1252 ($temp, @result) = &handle_single_transform_list (@files);
1253 $linker = $temp if $linker eq '';
1255 # We have to have a new name for each such
1256 # variable. Then we define the _OBJECTS variable
1257 # as the union of all such variables. Hopefully
1258 # this is the Right Thing.
1259 $cond_var_name = 'cond' . $count . $one_file . '_OBJECTS';
1260 &define_pretty_variable ($cond_var_name, $cond, @result)
1261 unless $prefix eq 'EXTRA_';
1262 push (@namelist, '$(' . $cond_var_name . ')');
1266 &define_pretty_variable ($one_file . '_OBJECTS', '',
1272 elsif ($prefix eq '')
1274 &define_variable ($one_file . "_SOURCES", $unxformed . ".c");
1275 push (@sources, $unxformed . '.c');
1276 push (@objects, $unxformed . $obj);
1277 push (@files, $unxformed . '.c');
1280 ($temp, @result) = &handle_single_transform_list (@files);
1281 $linker = $temp if $linker eq '';
1282 &define_pretty_variable ($one_file . "_OBJECTS", '', @result)
1283 unless $prefix eq 'EXTRA_';
1289 # Handle the BUILT_SOURCES variable.
1290 sub handle_built_sources
1292 return unless &variable_defined ('BUILT_SOURCES');
1294 local (@sources) = &variable_value_as_list ('BUILT_SOURCES', 'all');
1296 foreach $s (@sources)
1300 # FIXME: is this really the right thing to do?
1301 &am_line_error ('BUILT_SOURCES',
1302 "\`BUILT_SOURCES' should not contain a configure substitution");
1307 # We don't care about the return value of this function. We just
1308 # want to make sure to update %dep_files with the contents of
1310 &handle_single_transform_list (@sources);
1313 # Special-case @ALLOCA@ and @LIBOBJS@ in _LDADD or _LIBADD variables.
1314 # Also, generate _DEPENDENCIES variable if appropriate.
1316 # transformed name of object being built, or empty string if no object
1317 # name of _LDADD/_LIBADD-type variable to examine
1318 # boolean (lex_seen) which is true if a lex source file was seen in this
1319 # object. valid only for LDADDs, not LIBADDs.
1320 # Returns 1 if LIBOBJS seen, 0 otherwise.
1321 sub handle_lib_objects
1323 local ($xname, $var, $lex_seen) = @_;
1326 die "automake: programming error 1 in handle_lib_objects\n"
1327 if ! &variable_defined ($var);
1329 die "automake: programming error 2 in handle_lib_objects\n"
1330 if $lex_seen && $var =~ /LIBADD/;
1332 local (@conds) = &variable_conditions ($var);
1335 $ret = &handle_lib_objects_cond ($xname, $var, $lex_seen, '');
1341 foreach $cond (@conds)
1343 if (&handle_lib_objects_cond ($xname, $var, $lex_seen, $cond))
1353 # Subroutine of handle_lib_objects: handle a particular condition.
1354 sub handle_lib_objects_cond
1356 local ($xname, $var, $lex_seen, $cond) = @_;
1358 # We recognize certain things that are commonly put in LIBADD or
1361 local (@dep_list) = ();
1363 local ($seen_libobjs) = 0;
1364 local ($flagvar) = 0;
1366 foreach $lsearch (&variable_value_as_list ($var, $cond))
1368 # Skip -lfoo and -Ldir; these are explicitly allowed.
1369 next if $lsearch =~ /^-[lL]/;
1370 if (! $flagvar && $lsearch =~ /^-/)
1372 if ($var =~ /^(.*)LDADD$/)
1374 &am_line_error ($var, "linker flags such as \`$lsearch' belong in \`${1}LDFLAGS");
1378 # Only get this error once.
1380 &am_line_error ($var, "you cannot use linker flags such as \`$lsearch' in \`$var'");
1384 # Assume we have a file of some sort, and push it onto the
1385 # dependency list. Autoconf substitutions are not pushed;
1386 # rarely is a new dependency substituted into (eg) foo_LDADD
1387 # -- but "bad things (eg -lX11) are routinely substituted.
1388 # Note that LIBOBJS and ALLOCA are exceptions to this rule,
1389 # and handled specially below.
1390 push (@dep_list, $lsearch)
1391 unless $lsearch =~ /^\@.*\@$/;
1393 # Automatically handle @LIBOBJS@ and @ALLOCA@. Basically this
1394 # means adding entries to dep_files.
1395 if ($lsearch =~ /^\@(LT)?LIBOBJS\@$/)
1397 push (@dep_list, $lsearch);
1399 if (! keys %libsources)
1401 &am_line_error ($var, "\@$1" . "LIBOBJS\@ seen but never set in \`configure.in'");
1404 local ($iter, $rewrite);
1405 foreach $iter (keys %libsources)
1407 if ($iter =~ /\.[cly]$/)
1409 $seen_c_source = $var;
1410 $seen_any_source = 1;
1413 if ($iter =~ /\.h$/)
1415 &require_file_with_line ($var, $FOREIGN, $iter);
1417 elsif ($iter ne 'alloca.c')
1419 ($rewrite = $iter) =~ s/\.c$/.P/;
1420 $dep_files{'.deps/' . $rewrite} = 1;
1421 &require_file_with_line ($var, $FOREIGN, $iter);
1425 elsif ($lsearch =~ /^\@(LT)?ALLOCA\@$/)
1427 push (@dep_list, $lsearch);
1428 &am_line_error ($var,
1429 "\@$1" . "ALLOCA\@ seen but \`AC_FUNC_ALLOCA' not in \`configure.in'")
1430 if ! defined $libsources{'alloca.c'};
1431 $dep_files{'.deps/alloca.P'} = 1;
1432 &require_file_with_line ($var, $FOREIGN, 'alloca.c');
1433 $seen_c_source = $var;
1434 $seen_any_source = 1;
1438 if ($xname ne '' && ! &variable_defined ($xname . '_DEPENDENCIES', $cond))
1440 &define_pretty_variable ($xname . '_DEPENDENCIES', $cond, @dep_list);
1443 return $seen_libobjs;
1446 # Canonicalize a name, and check to make sure the non-canonical name
1447 # is never used. Returns canonical name. Arguments are name and a
1448 # list of suffixes to check for.
1449 sub check_canonical_spelling
1451 local ($name, @suffixes) = @_;
1452 local ($xname, $xt);
1454 ($xname = $name) =~ tr/A-Za-z0-9_/_/c;
1455 if ($xname ne $name)
1458 foreach $xt (@suffixes)
1460 &am_line_error ($name . $xt,
1461 "invalid variable \`" . $name . $xt
1462 . "'; should be \`" . $xname . $xt . "'")
1463 if &variable_defined ($name . $xt);
1470 # Handle C programs.
1473 local (@proglist) = &am_install_var ('-clean',
1474 'progs', 'PROGRAMS',
1475 'bin', 'sbin', 'libexec', 'pkglib',
1477 return if ! @proglist;
1479 # If a program is installed, this is required. We only want this
1480 # error to appear once.
1481 &am_conf_error ("AC_ARG_PROGRAM must be used in configure.in")
1482 unless $seen_arg_prog;
1485 local ($one_file, $xname, $munge);
1487 local ($seen_libobjs) = 0;
1488 foreach $one_file (@proglist)
1490 local ($obj) = &get_object_extension ($one_file);
1492 # Canonicalize names and check for misspellings.
1493 $xname = &check_canonical_spelling ($one_file, '_LDADD', '_LDFLAGS',
1494 '_SOURCES', '_OBJECTS',
1497 # FIXME: Using a trick to figure out if any lex sources appear
1498 # in our program; should use some cleaner method.
1499 local ($lex_num) = scalar (keys %lex_sources);
1500 local ($linker) = &handle_source_transform ($xname, $one_file, $obj);
1501 local ($lex_file_seen) = (scalar (keys %lex_sources) > $lex_num);
1504 if (&variable_defined ($xname . "_LDADD"))
1506 if (&handle_lib_objects ($xname, $xname . '_LDADD',
1516 # User didn't define prog_LDADD override. So do it.
1517 &define_variable ($xname . '_LDADD', '$(LDADD)');
1519 # This does a bit too much work. But we need it to
1520 # generate _DEPENDENCIES when appropriate.
1521 if (&variable_defined ('LDADD'))
1523 if (&handle_lib_objects ($xname, 'LDADD', $lex_file_seen))
1529 elsif (! &variable_defined ($xname . '_DEPENDENCIES'))
1531 &define_variable ($xname . '_DEPENDENCIES', '');
1536 if (&variable_defined ($xname . '_LIBADD'))
1538 &am_line_error ($xname . '_LIBADD',
1539 "use \`" . $xname . "_LDADD', not \`"
1540 . $xname . "_LIBADD'");
1543 if (! &variable_defined ($xname . '_LDFLAGS'))
1545 # Define the prog_LDFLAGS variable.
1546 &define_variable ($xname . '_LDFLAGS', '');
1549 # Determine program to use for link.
1551 if (&variable_defined ($xname . '_LINK'))
1553 $xlink = $xname . '_LINK';
1557 $xlink = $linker ? $linker : 'LINK';
1561 if ($seen_exeext && $one_file !~ /\./)
1563 $xexe = 's/\@EXEEXT\@/\$(EXEEXT)/g;';
1567 $xexe = 's/\@EXEEXT\@//g;';
1571 &file_contents_with_transform
1572 ('s/\@PROGRAM\@/' . $one_file . '/go;'
1573 . 's/\@XPROGRAM\@/' . $xname . '/go;'
1574 . 's/\@XLINK\@/' . $xlink . '/go;'
1579 if (&variable_defined ('LDADD') && &handle_lib_objects ('', 'LDADD', 0))
1586 foreach $one_file (@proglist)
1588 # Canonicalize names.
1589 ($xname = $one_file) =~ tr/A-Za-z0-9_/_/c;
1591 if (&variable_defined ($xname . '_LDADD'))
1593 &check_libobjs_sources ($xname, $xname . '_LDADD');
1595 elsif (&variable_defined ('LDADD'))
1597 &check_libobjs_sources ($xname, 'LDADD');
1605 sub handle_libraries
1607 local (@liblist) = &am_install_var ('-clean',
1608 'libs', 'LIBRARIES',
1609 'lib', 'pkglib', 'noinst', 'check');
1610 return if ! @liblist;
1612 local (%valid) = &am_primary_prefixes ('LIBRARIES', 'lib', 'pkglib',
1614 if (! defined $configure_vars{'RANLIB'})
1617 foreach $key (keys %valid)
1619 if (&variable_defined ($key . '_LIBRARIES'))
1621 &am_line_error ($key . '_LIBRARIES', "library used but \`RANLIB' not defined in \`configure.in'");
1622 # Only get this error once.
1623 $configure_vars{'RANLIB'} = 1;
1632 local ($seen_libobjs) = 0;
1633 foreach $onelib (@liblist)
1635 # Check that the library fits the standard naming convention.
1636 if ($onelib !~ /^lib.*\.a$/)
1638 # FIXME should put line number here. That means mapping
1639 # from library name back to variable name.
1640 &am_error ("\`$onelib' is not a standard library name");
1643 local ($obj) = &get_object_extension ($onelib);
1645 # Canonicalize names and check for misspellings.
1646 $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_SOURCES',
1647 '_OBJECTS', '_DEPENDENCIES');
1649 if (&variable_defined ($xlib . '_LIBADD'))
1651 if (&handle_lib_objects ($xlib, $xlib . '_LIBADD', 0))
1658 # Generate support for conditional object inclusion in
1660 &define_variable ($xlib . "_LIBADD", '');
1663 if (&variable_defined ($xlib . '_LDADD'))
1665 &am_line_error ($xlib . '_LDADD',
1666 "use \`" . $xlib . "_LIBADD', not \`"
1667 . $xlib . "_LDADD'");
1670 &handle_source_transform ($xlib, $onelib, $obj);
1673 &file_contents_with_transform ('s/\@LIBRARY\@/' . $onelib . '/go;'
1681 foreach $onelib (@liblist)
1683 # Canonicalize names.
1684 ($xlib = $onelib) =~ tr/A-Za-z0-9_/_/c;
1685 if (&variable_defined ($xlib . '_LIBADD'))
1687 &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
1692 &define_variable ('AR', 'ar');
1693 &define_configure_variable ('RANLIB');
1696 # Handle shared libraries.
1697 sub handle_ltlibraries
1699 local (@liblist) = &am_install_var ('-clean',
1700 'ltlib', 'LTLIBRARIES',
1702 return if ! @liblist;
1705 local (%valid) = &am_primary_prefixes ('LTLIBRARIES', 'lib', 'pkglib');
1708 foreach $key (keys %valid)
1710 if (&variable_defined ($key . '_LTLIBRARIES'))
1714 &am_line_error ($key . '_LTLIBRARIES', "library used but \`LIBTOOL' not defined in \`configure.in'");
1715 # Only get this error once.
1716 $configure_vars{'LIBTOOL'} = 1;
1720 # Get the installation directory of each library.
1721 for (&variable_value_as_list ($key . '_LTLIBRARIES', 'all'))
1725 &am_error ("\`$_' is already going to be installed in \`$instdirs{$_}'");
1729 $instdirs{$_} = $key;
1738 local ($seen_libobjs) = 0;
1739 foreach $onelib (@liblist)
1741 # Check that the library fits the standard naming convention.
1742 if ($onelib !~ /^lib.*\.la$/)
1744 # FIXME this should only be a warning for foreign packages
1745 # FIXME should put line number here. That means mapping
1746 # from library name back to variable name.
1747 &am_error ("\`$onelib' is not a standard libtool library name");
1750 local ($obj) = &get_object_extension ($onelib);
1752 # Canonicalize names and check for misspellings.
1753 $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_LDFLAGS',
1754 '_SOURCES', '_OBJECTS',
1757 if (! &variable_defined ($xlib . '_LDFLAGS'))
1759 # Define the lib_LDFLAGS variable.
1760 &define_variable ($xlib . '_LDFLAGS', '');
1763 if (&variable_defined ($xlib . '_LIBADD'))
1765 if (&handle_lib_objects ($xlib, $xlib . '_LIBADD', 0))
1772 # Generate support for conditional object inclusion in
1774 &define_variable ($xlib . "_LIBADD", '');
1777 if (&variable_defined ($xlib . '_LDADD'))
1779 &am_line_error ($xlib . '_LDADD',
1780 "use \`" . $xlib . "_LIBADD', not \`"
1781 . $xlib . "_LDADD'");
1784 local ($linker) = &handle_source_transform ($xlib, $onelib, $obj);
1786 # Determine program to use for link.
1788 if (&variable_defined ($xlib . '_LINK'))
1790 $xlink = $xlib . '_LINK';
1794 $xlink = $linker ? $linker : 'LINK';
1798 if ($instdirs{$onelib} eq 'EXTRA')
1800 # It's an EXTRA_ library, so we can't specify -rpath.
1802 $rpath = 's/\@RPATH\@//go;';
1806 $rpath = ('s/\@RPATH\@/-rpath \$(' . $instdirs{$onelib}
1811 &file_contents_with_transform ('s/\@LTLIBRARY\@/'
1813 . 's/\@XLTLIBRARY\@/'
1816 . 's/\@XLINK\@/' . $xlink . '/go;',
1822 foreach $onelib (@liblist)
1824 # Canonicalize names.
1825 ($xlib = $onelib) =~ tr/A-Za-z0-9_/_/c;
1826 if (&variable_defined ($xlib . '_LIBADD'))
1828 &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
1834 # See if any _SOURCES variable were misspelled. Also, make sure that
1835 # EXTRA_ variables don't contain configure substitutions.
1838 local ($varname, $primary);
1839 foreach $varname (keys %contents)
1841 foreach $primary ('_SOURCES', '_LIBADD', '_LDADD', '_LDFLAGS',
1844 if ($varname =~ /$primary$/ && ! $content_seen{$varname})
1846 &am_line_error ($varname,
1847 "invalid unused variable name: \`$varname'");
1856 # NOTE we no longer automatically clean SCRIPTS, because it is
1857 # useful to sometimes distribute scripts verbatim. This happens
1858 # eg in Automake itself.
1859 &am_install_var ('scripts', 'SCRIPTS',
1860 'bin', 'sbin', 'libexec', 'pkgdata',
1863 # Set $scripts_installed if appropriate. Make sure we only find
1864 # scripts which are actually installed -- this is why we can't
1865 # simply use the return value of am_install_var.
1866 local (%valid) = &am_primary_prefixes ('SCRIPTS', 'bin', 'sbin',
1867 'libexec', 'pkgdata',
1870 foreach $key (keys %valid)
1872 if ($key ne 'noinst'
1874 && &variable_defined ($key . '_SCRIPTS'))
1876 $scripts_installed = 1;
1877 # push (@check_tests, 'check-' . $key . 'SCRIPTS');
1881 if ($scripts_installed)
1883 # If a program is installed, this is required. We only want this
1884 # error to appear once.
1885 &am_conf_error ("AC_ARG_PROGRAM must be used in configure.in")
1886 unless $seen_arg_prog;
1891 # Search a file for a "version.texi" Texinfo include. Return the name
1892 # of the include file if found, or the empty string if not. A
1893 # "version.texi" file is actually any file whose name matches
1895 sub scan_texinfo_file
1897 local ($filename) = @_;
1899 if (! open (TEXI, $filename))
1901 &am_error ("couldn't open \`$filename': $!");
1904 print "automake: reading $filename\n" if $verbose;
1906 local ($vfile, $outfile);
1909 if (/^\@setfilename +(\S+)/)
1915 if (/^\@include\s+(vers[^.]*\.texi)\s*$/)
1917 # Found version.texi include.
1924 return ($outfile, $vfile);
1927 # Handle all Texinfo source.
1930 &am_line_error ('TEXINFOS',
1931 "\`TEXINFOS' is an anachronism; use \`info_TEXINFOS'")
1932 if &variable_defined ('TEXINFOS');
1933 return if (! &variable_defined ('info_TEXINFOS')
1934 && ! &variable_defined ('html_TEXINFOS'));
1936 local (@texis) = &variable_value_as_list ('info_TEXINFOS', 'all');
1938 local (@info_deps_list, @dvis_list, @texi_deps);
1939 local ($infobase, $info_cursor);
1943 local ($tc_cursor, @texi_cleans);
1946 foreach $info_cursor (@texis)
1948 ($infobase = $info_cursor) =~ s/\.texi(nfo)?$//;
1950 # If 'version.texi' is referenced by input file, then include
1951 # automatic versioning capability.
1952 local ($out_file, $vtexi) = &scan_texinfo_file ($relative_dir
1953 . "/" . $info_cursor);
1955 if ($out_file eq '')
1957 &am_error ("\`$info_cursor' missing \@setfilename");
1961 if ($out_file =~ /\.(.+)$/ && $1 ne 'info')
1963 # FIXME should report line number in input file.
1964 &am_error ("output of \`$info_cursor', \`$out_file', has unrecognized extension");
1970 &am_error ("\`$vtexi', included in \`$info_cursor', also included in \`$versions{$vtexi}'")
1971 if (defined $versions{$vtexi});
1972 $versions{$vtexi} = $info_cursor;
1974 # We number the stamp-vti files. This is doable since the
1975 # actual names don't matter much. We only number starting
1976 # with the second one, so that the common case looks nice.
1977 $vti = 'vti' . ($done ? $done : '');
1978 &push_dist_common ($vtexi, 'stamp-' . $vti);
1979 push (@clean, $vti);
1981 # Only require once.
1982 &require_conf_file_with_line ('info_TEXINFOS', $FOREIGN,
1988 ($conf_pat = $config_aux_dir) =~ s/(\W)/\\$1/g;
1990 &file_contents_with_transform
1991 ('s/\@TEXI\@/' . $info_cursor . '/g; '
1992 . 's/\@VTI\@/' . $vti . '/g; '
1993 . 's/\@VTEXI\@/' . $vtexi . '/g;'
1994 . 's,\@MDDIR\@,' . $conf_pat . ',g;',
1997 &push_phony_cleaners ($vti);
2000 # If user specified file_TEXINFOS, then use that as explicit
2003 push (@texi_deps, $info_cursor);
2004 push (@texi_deps, $vtexi) if $vtexi;
2006 # Canonicalize name first.
2007 ($canonical = $infobase) =~ tr/A-Za-z0-9_/_/c;
2008 if (&variable_defined ($canonical . "_TEXINFOS"))
2010 push (@texi_deps, '$(' . $canonical . '_TEXINFOS)');
2011 &push_dist_common ('$(' . $canonical . '_TEXINFOS)');
2014 $output_rules .= ("\n" . $out_file . ": "
2015 . join (' ', @texi_deps)
2016 . "\n" . $infobase . ".dvi: "
2017 . join (' ', @texi_deps)
2020 push (@info_deps_list, $out_file);
2021 push (@dvis_list, $infobase . '.dvi');
2023 # Generate list of things to clean for this target. We do
2024 # this explicitly because otherwise too many things could be
2025 # removed. In particular the ".log" extension might
2026 # reasonably be used in other contexts by the user.
2027 foreach $tc_cursor ('aux', 'cp', 'cps', 'dvi', 'fn', 'fns',
2028 'ky', 'kys', 'ps', 'log', 'pg', 'toc', 'tp', 'tps',
2029 'vr', 'vrs', 'op', 'tr', 'cv', 'cn')
2031 push (@texi_cleans, $infobase . '.' . $tc_cursor);
2035 # Find these programs wherever they may lie. Yes, this has
2036 # intimate knowledge of the structure of the texinfo distribution.
2037 &define_program_variable ('MAKEINFO', 'build', 'texinfo/makeinfo',
2039 # Circumlocution to avoid accidental
2040 # configure substitution.
2042 &define_program_variable ('TEXI2DVI', 'src', 'texinfo/util',
2045 # Set transform for including texinfos.am. First, handle --cygnus
2050 $xform = 's/^NOTCYGNUS.*$//; s/^CYGNUS//;';
2054 $xform = 's/^CYGNUS.*$//; s/^NOTCYGNUS//;';
2057 # Handle location of texinfo.tex.
2058 local ($need_texi_file) = 0;
2061 &define_variable ('TEXINFO_TEX',
2062 '$(top_srcdir)/../texinfo/texinfo.tex');
2064 elsif ($config_aux_dir ne '.' && $config_aux_dir ne '')
2066 &define_variable ('TEXINFO_TEX', $config_aux_dir . '/texinfo.tex');
2068 elsif (! &variable_defined ('TEXINFO_TEX'))
2070 &define_variable ('TEXINFO_TEX', '$(srcdir)/texinfo.tex');
2074 $need_texi_file = 1;
2076 local ($xxform) = &dirname (&variable_value ('TEXINFO_TEX'));
2077 $xxform =~ s/(\W)/\\$1/g;
2078 $xform .= ' s/\@TEXINFODIR\@/' . $xxform . '/g;';
2080 $output_rules .= &file_contents_with_transform ($xform, 'texinfos');
2081 push (@phony, 'install-info-am', 'uninstall-info');
2082 push (@dist_targets, 'dist-info');
2084 # How to clean. The funny name is due to --cygnus influence; in
2085 # Cygnus mode, `clean-info' is a target that users can use.
2086 $output_rules .= "\nmostlyclean-aminfo:\n";
2087 &pretty_print_rule ("\t-rm -f", "\t ", @texi_cleans);
2088 $output_rules .= ("\nclean-aminfo:\n\ndistclean-aminfo:\n\n"
2089 . "maintainer-clean-aminfo:\n\t"
2090 # Eww. But how else can we find all the output
2091 # files from makeinfo?
2092 . 'for i in $(INFO_DEPS); do' . " \\\n"
2093 . "\t" . ' rm -f $$i;' . " \\\n"
2094 . "\t" . ' if test "`echo $$i-[0-9]*`" != "$$i-[0-9]*"; then' . " \\\n"
2095 . "\t" . ' rm -f $$i-[0-9]*;' . " \\\n"
2096 . "\t" . ' fi;' . " \\\n"
2098 &push_phony_cleaners ('aminfo');
2101 $output_rules .= "clean-info: mostlyclean-aminfo\n";
2104 push (@suffixes, '.texi', '.texinfo', '.info', '.dvi', '.ps');
2106 if (! defined $options{'no-installinfo'})
2108 push (@uninstall, 'uninstall-info');
2109 push (@installdirs, '$(infodir)');
2110 unshift (@install_data, 'install-info-am');
2112 # Make sure documentation is made and installed first. Use
2113 # $(INFO_DEPS), not 'info', because otherwise recursive makes
2114 # get run twice during "make all".
2115 unshift (@all, '$(INFO_DEPS)');
2117 push (@clean, 'aminfo');
2118 push (@info, '$(INFO_DEPS)');
2119 push (@dvi, '$(DVIS)');
2121 &define_variable ("INFO_DEPS", join (' ', @info_deps_list));
2122 &define_variable ("DVIS", join (' ', @dvis_list));
2123 # This next isn't strictly needed now -- the places that look here
2124 # could easily be changed to look in info_TEXINFOS. But this is
2125 # probably better, in case noinst_TEXINFOS is ever supported.
2126 &define_variable ("TEXINFOS", &variable_value ('info_TEXINFOS'));
2128 # Do some error checking. Note that this file is not required
2129 # when in Cygnus mode; instead we defined TEXINFO_TEX explicitly
2131 &require_file_with_line ('info_TEXINFOS', $FOREIGN, 'texinfo.tex')
2132 if $need_texi_file || ! defined $options{'no-texinfo.tex'};
2135 # Handle any man pages.
2136 sub handle_man_pages
2138 &am_line_error ('MANS', "\`MANS' is an anachronism; use \`man_MANS'")
2139 if &variable_defined ('MANS');
2140 return if ! &variable_defined ('man_MANS');
2142 # We generate the manpage install code by hand to avoid the use of
2143 # basename in the generated Makefile.
2144 local (@mans) = &variable_value_as_list ('man_MANS', 'all');
2145 local (%sections, %inames, %mbases, %secmap, %fullsecmap);
2149 # FIXME: statement without effect:
2150 /^(.*)\.([0-9])([a-z]*)$/;
2155 $fullsecmap{$i} = $2 . $3;
2159 # We don't really need this, but we use it in case we ever want to
2160 # support noinst_MANS.
2161 &define_variable ("MANS", &variable_value ('man_MANS'));
2163 # Generate list of install dirs.
2164 $output_rules .= "install-man: \$(MANS)\n";
2165 $output_rules .= "\t\$(NORMAL_INSTALL)\n";
2166 # Sort keys so that output is deterministic.
2167 foreach (sort keys %sections)
2169 push (@installdirs, '$(mandir)/man' . $_)
2170 unless defined $options{'no-installman'};
2171 $output_rules .= ("\t" . '$(mkinstalldirs) $(mandir)/man'
2174 push (@phony, 'install-man');
2176 # Generate install target.
2178 foreach $key (sort keys %inames)
2180 $_ = $install_man_format;
2181 s/\@SECTION\@/$secmap{$key}/g;
2182 s/\@MAN\@/$inames{$key}/g;
2183 s/\@FULLSECT\@/$fullsecmap{$key}/g;
2184 s/\@MANBASE\@/$mbases{$key}/g;
2185 $output_rules .= $_;
2187 $output_rules .= "\n";
2189 $output_rules .= "uninstall-man:\n\t\$(NORMAL_UNINSTALL)\n";
2190 foreach $key (sort keys %inames)
2192 $_ = $uninstall_man_format;
2193 s/\@SECTION\@/$secmap{$key}/g;
2194 s/\@MAN\@/$inames{$key}/g;
2195 s/\@FULLSECT\@/$fullsecmap{$key}/g;
2196 s/\@MANBASE\@/$mbases{$key}/g;
2197 $output_rules .= $_;
2199 $output_rules .= "\n";
2200 push (@phony, 'uninstall-man');
2202 $output_vars .= &file_contents ('mans-vars');
2204 if (! defined $options{'no-installman'})
2206 push (@install_data, 'install-man');
2207 push (@uninstall, 'uninstall-man');
2208 push (@all, '$(MANS)');
2212 # Handle DATA variables.
2215 &am_install_var ('data', 'DATA', 'data', 'sysconf',
2216 'sharedstate', 'localstate', 'pkgdata',
2223 push (@phony, 'tags');
2224 local (@tag_deps) = ();
2225 if (&variable_defined ('SUBDIRS'))
2227 $output_rules .= ("tags-recursive:\n"
2228 . "\tlist=\'\$(SUBDIRS)\'; for subdir in \$\$list; do \\\n"
2229 # Never fail here if a subdir fails; it
2231 . "\t (cd \$\$subdir && \$(MAKE) tags); \\\n"
2233 push (@tag_deps, 'tags-recursive');
2234 push (@phony, 'tags-recursive');
2237 if ($dir_holds_sources
2238 || $dir_holds_headers
2239 || &variable_defined ('ETAGS_ARGS')
2242 local ($xform) = '';
2244 foreach $one_hdr (@config_headers)
2246 if ($relative_dir eq &dirname ($one_hdr))
2248 # The config header is in this directory. So require it.
2250 ($var = &basename ($one_hdr)) =~ s/(\W)/\\$1/g;
2251 $xform .= ' ' if $xform;
2255 $xform = ('s/\@CONFIG\@/' . $xform . '/;'
2256 . 's/\@DIRS\@/' . join (' ', @tag_deps) . '/;');
2258 if (&variable_defined ('SUBDIRS'))
2260 $xform .= 's/^SUBDIRS//;';
2264 $xform .= 's/^SUBDIRS.*$//;';
2267 $output_rules .= &file_contents_with_transform ($xform, 'tags');
2268 $output_rules .= &file_contents ('tags-clean');
2269 push (@clean, 'tags');
2270 &push_phony_cleaners ('tags');
2271 &examine_variable ('TAGS_DEPENDENCIES');
2273 elsif (&variable_defined ('TAGS_DEPENDENCIES'))
2275 &am_line_error ('TAGS_DEPENDENCIES',
2276 "doesn't make sense to define \`TAGS_DEPENDENCIES' without sources or \`ETAGS_ARGS'");
2280 # Every Makefile must define some sort of TAGS rule.
2281 # Otherwise, it would be possible for a top-level "make TAGS"
2282 # to fail because some subdirectory failed.
2283 $output_rules .= "tags: TAGS\nTAGS:\n\n";
2287 # Worker for handle_dist.
2288 sub handle_dist_worker
2290 local ($makefile) = @_;
2292 $output_rules .= 'distdir: $(DISTFILES)' . "\n";
2294 # Initialization; only at top level.
2295 if ($relative_dir eq '.')
2297 if (defined $options{'check-news'})
2299 # For Gnits users, this is pretty handy. Look at 15 lines
2300 # in case some explanatory text is desirable.
2301 $output_rules .= ' @if sed 15q $(srcdir)/NEWS | fgrep -e "$(VERSION)" > /dev/null; then :; else \\
2302 echo "NEWS not updated; not releasing" 1>&2; \\
2309 # Create dist directory.
2310 $output_rules .= ("\t-rm -rf \$(distdir)\n"
2311 . "\tmkdir \$(distdir)\n"
2312 . "\t-chmod 777 \$(distdir)\n");
2315 # Only run automake in `dist' target if --include-deps and
2316 # `no-dependencies' not specified. That way the recipient of a
2317 # distribution can run "make dist" and not need Automake. You
2318 # might be wondering why we run automake once for each directory
2319 # we distribute, instead of running it once at the top level. The
2320 # answer is that we want to run automake after the dependencies
2321 # have been generated. This occurs when "make" is run in the
2322 # subdir. So automake must be run after make has updated the
2323 # Makefile, which means that it must run once per directory.
2324 if ($use_dependencies)
2328 # There are several directories we need to know about
2329 # when rebuilding the Makefile.ins. They are:
2330 # here - The absolute path to our topmost build directory.
2331 # top_distdir - The absolute path to the top of our dist
2333 # distdir - The path to our sub-part of the dist hierarchy.
2334 # If this directory is the topmost directory, we set
2335 # top_distdir from distdir; that lets us pass in distdir
2336 # from an enclosing package.
2337 "\t" . 'here=`cd $(top_builddir) && pwd`; ' . "\\\n"
2338 . "\t" . 'top_distdir=`cd $('
2339 . (($relative_dir eq '.') ? 'distdir' : 'top_distdir')
2340 . ') && pwd`; ' . "\\\n"
2341 . "\t" . 'distdir=`cd $(distdir) && pwd`; ' . "\\\n"
2342 . "\tcd \$(top_srcdir) \\\n"
2343 . "\t && \$(AUTOMAKE) --include-deps --build-dir=\$\$here --srcdir-name=\$(top_srcdir) --output-dir=\$\$top_distdir "
2344 # Set strictness of output.
2345 . ($cygnus_mode ? '--cygnus' : ('--' . $strictness_name))
2346 . ($cmdline_use_dependencies ? '' : ' --include-deps')
2347 . " " . $makefile . "\n"
2351 # Scan EXTRA_DIST to see if we need to distribute anything from a
2352 # subdir. If so, add it to the list. I didn't want to do this
2353 # originally, but there were so many requests that I finally
2356 if (&variable_defined ('EXTRA_DIST'))
2358 # FIXME: This should be fixed to work with conditionals. That
2359 # will require only making the entries in @dist_dirs under the
2360 # appropriate condition. This is meaningful if the nature of
2361 # the distribution should depend upon the configure options
2363 foreach (&variable_value_as_list ('EXTRA_DIST', ''))
2366 next unless s,/+[^/]+$,,;
2367 push (@dist_dirs, $_)
2373 # Prepend $(distdir) to each directory given. Doing it via a
2374 # hash lets us ensure that each directory is used only once.
2376 grep ($dhash{'$(distdir)/' . $_} = 1, @dist_dirs);
2377 $output_rules .= "\t";
2378 &pretty_print_rule ('$(mkinstalldirs)', "\t ", sort keys %dhash);
2381 # In loop, test for file existence because sometimes a file gets
2382 # included in DISTFILES twice. For example this happens when a
2383 # single source file is used in building more than one program.
2384 # Also, there are situations in which "ln" can fail. For instance
2385 # a file to distribute could actually be a cross-filesystem
2386 # symlink -- this can easily happen if "gettextize" was run on the
2388 $output_rules .= "\t\@for file in \$(DISTFILES); do \\\n";
2391 $output_rules .= "\t if test -f \$\$file; then d=.; else d=\$(srcdir); fi; \\\n";
2395 $output_rules .= "\t d=\$(srcdir); \\\n";
2397 $output_rules .= ' test -f $(distdir)/$$file \\
2398 || ln $$d/$$file $(distdir)/$$file 2> /dev/null \\
2399 || cp -p $$d/$$file $(distdir)/$$file; \\
2403 # If we have SUBDIRS, create all dist subdirectories and do
2405 if (&variable_defined ('SUBDIRS'))
2407 # If SUBDIRS is conditionally defined, then set DIST_SUBDIRS
2408 # to all possible directories, and use it.
2409 if (! &variable_conditions ('SUBDIRS'))
2411 $dist_subdir_name = 'SUBDIRS';
2415 $dist_subdir_name = 'DIST_SUBDIRS';
2416 if (! &variable_defined ('DIST_SUBDIRS'))
2418 &define_pretty_variable ('DIST_SUBDIRS', '',
2419 &variable_value_as_list ('SUBDIRS',
2424 # Test for directory existence here because previous automake
2425 # invocation might have created some directories. Note that
2426 # we explicitly set distdir for the subdir make; that lets us
2427 # mix-n-match many automake-using packages into one large
2428 # package, and have "dist" at the top level do the right
2429 # thing. If we're in the topmost directory, then we use
2430 # `distdir' instead of `top_distdir'; this lets us work
2431 # correctly with an enclosing package.
2433 ("\t" . 'for subdir in $(' . $dist_subdir_name . '); do ' . "\\\n"
2434 . "\t" . ' test -d $(distdir)/$$subdir ' . "\\\n"
2435 . "\t" . ' || mkdir $(distdir)/$$subdir ' . "\\\n"
2436 . "\t" . ' || exit 1; ' . "\\\n"
2437 . "\t" . ' chmod 777 $(distdir)/$$subdir; ' . "\\\n"
2438 . "\t" . ' (cd $$subdir && $(MAKE) top_distdir=../$('
2439 . (($relative_dir eq '.') ? 'distdir' : 'top_distdir')
2440 . ') distdir=../$(distdir)/$$subdir distdir) ' . "\\\n"
2441 . "\t" . ' || exit 1; ' . "\\\n"
2445 # If the target `dist-hook' exists, make sure it is run. This
2446 # allows users to do random weird things to the distribution
2447 # before it is packaged up.
2448 push (@dist_targets, 'dist-hook') if defined $contents{'dist-hook'};
2451 foreach $targ (@dist_targets)
2453 # We must explicitly set distdir and top_distdir for these
2455 $output_rules .= "\t\$(MAKE) top_distdir=\"\$(top_distdir)\" distdir=\"\$(distdir)\" $targ\n";
2458 push (@phony, 'distdir');
2461 # Handle 'dist' target.
2464 local ($makefile) = @_;
2466 # Set up maint_charset.
2467 $local_maint_charset = &variable_value ('MAINT_CHARSET')
2468 if &variable_defined ('MAINT_CHARSET');
2469 $maint_charset = $local_maint_charset
2470 if $relative_dir eq '.';
2472 if (&variable_defined ('DIST_CHARSET'))
2474 &am_line_error ('DIST_CHARSET',
2475 "DIST_CHARSET defined but no MAINT_CHARSET defined")
2476 if ! $local_maint_charset;
2477 if ($relative_dir eq '.')
2479 $dist_charset = &variable_value ('DIST_CHARSET')
2483 &am_line_error ('DIST_CHARSET',
2484 "DIST_CHARSET can only be defined at top level");
2488 # Look for common files that should be included in distribution.
2490 foreach $cfile (@common_files)
2492 if (-f ($relative_dir . "/" . $cfile))
2494 &push_dist_common ($cfile);
2498 # Keys of %dist_common are names of files to distributed. We put
2499 # README first because it then becomes easier to make a
2500 # Usenet-compliant shar file (in these, README must be first).
2501 # FIXME: do more ordering of files here.
2503 if (defined $dist_common{'README'})
2505 push (@coms, 'README');
2506 delete $dist_common{'README'};
2508 push (@coms, sort keys %dist_common);
2510 &define_pretty_variable ("DIST_COMMON", '', @coms);
2511 $output_vars .= "\n";
2514 $output_vars .= &file_contents ('dist-vars') . "\n";
2515 &define_variable ('TAR', $TAR);
2516 &define_variable ('GZIP', '--best');
2518 # Put these things in rules section so it is easier for whoever
2519 # reads Makefile.in.
2520 if (! &variable_defined ('distdir'))
2522 if ($relative_dir eq '.')
2524 $output_rules .= "\n" . 'distdir = $(PACKAGE)-$(VERSION)' . "\n";
2528 $output_rules .= ("\n"
2529 . 'distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)'
2533 if ($relative_dir eq '.')
2535 $output_rules .= "top_distdir = \$(distdir)\n\n";
2539 $output_rules .= "\nsubdir = " . $relative_dir . "\n\n";
2542 # Generate 'dist' target, and maybe dist-shar / dist-zip / dist-tarZ.
2543 if ($relative_dir eq '.')
2545 # Rule to check whether a distribution is viable.
2546 $output_rules .= ('# This target untars the dist file and tries a VPATH configuration. Then
2547 # it guarantees that the distribution is self-contained by making another
2551 GZIP=$(GZIP) $(TAR) zxf $(distdir).tar.gz
2552 mkdir $(distdir)/=build
2553 mkdir $(distdir)/=inst
2554 dc_install_base=`cd $(distdir)/=inst && pwd`; \\'
2555 . (defined $contents{'distcheck-hook'}
2556 ? "\t\$(MAKE) distcheck-hook"
2559 cd $(distdir)/=build \\
2562 . ($seen_gettext ? '--with-included-gettext ' : '')
2563 . '--srcdir=.. --prefix=$$dc_install_base \\
2567 && $(MAKE) install \\
2568 && $(MAKE) installcheck \\
2571 @echo "========================"; \\
2572 echo "$(distdir).tar.gz is ready for distribution"; \\
2573 echo "========================"
2576 local ($dist_all) = ('dist-all: distdir' . "\n"
2579 foreach $curs ('dist', 'dist-shar', 'dist-zip', 'dist-tarZ')
2581 if (defined $options{$curs} || $curs eq 'dist')
2583 $output_rules .= ($curs . ': distdir' . "\n"
2587 $dist_all .= $dist{$curs};
2590 $output_rules .= $dist_all . $dist_trailer;
2593 # Generate distdir target.
2594 &handle_dist_worker ($makefile);
2597 # Scan a single dependency file and rewrite the dependencies as
2598 # appropriate. Essentially this means:
2599 # * Clean out absolute dependencies which are not desirable.
2600 # * Rewrite other dependencies to be relative to $(top_srcdir).
2601 sub scan_dependency_file
2603 local ($depfile) = @_;
2605 if (! open (DEP_FILE, $depfile))
2607 &am_error ("couldn't open \`$depfile': $!");
2610 print "automake: reading $depfile\n" if $verbose;
2612 # Sometimes it is necessary to omit some dependencies.
2613 local (%omit) = %omit_dependencies;
2614 if (&variable_defined ('OMIT_DEPENDENCIES'))
2616 # FIXME: Doesn't work with conditionals. I'm not sure if this
2618 grep ($omit{$_} = 1,
2619 &variable_value_as_list ('OMIT_DEPENDENCIES', ''));
2622 local ($first_line) = 1;
2623 local ($last_line) = 0;
2624 local ($target, @dependencies);
2625 local ($one_dep, $xform);
2628 local ($srcdir_rx, $fixup_rx);
2629 ($fixup_rx = $srcdir_name . '/' . $relative_dir . '/')
2631 ($srcdir_rx = $srcdir_name . '/') =~ s/(\W)/\\$1/g;
2633 local ($rewrite_builddir) = (($top_builddir eq '.')
2635 : $top_builddir . '/');
2641 # If LAST_LINE set then we've already seen what we thought
2642 # was the last line.
2645 next if (/$WHITE_PATTERN/o);
2649 # No trailing "\" means this should be the last line.
2655 if (! /^([^:]+:)(.+)$/)
2658 &am_error ("\`$depfile' has incorrect format");
2664 # Make sure to strip the .P file from the target.
2665 ($target = $1) =~ s, *\.deps/[^.]+\.P,,;
2670 foreach $one_dep (split (' ', $_))
2672 ($just_file = $one_dep) =~ s,^.*/,,;
2673 next if defined $omit{$just_file};
2675 if ($one_dep =~ /^$fixup_rx/)
2677 # The dependency points to the current directory in
2679 ($xform = $one_dep) =~ s/^$fixup_rx//;
2680 push (@dependencies, $xform);
2682 elsif ($one_dep =~ /^$srcdir_rx/)
2684 # The dependency is in some other directory in the package.
2685 ($xform = $one_dep) =~ s/^$srcdir_rx/$rewrite_builddir/;
2686 push (@dependencies, $xform);
2688 elsif ($one_dep =~ /^\//)
2690 # Absolute path; ignore.
2694 # Anything else is assumed to be correct.
2695 push (@dependencies, $one_dep);
2700 &pretty_print_rule ($target, "\t", @dependencies);
2705 # Handle auto-dependency code.
2706 sub handle_dependencies
2708 # Make sure this variable is always marked as used.
2709 &examine_variable ('OMIT_DEPENDENCIES');
2711 if ($use_dependencies)
2713 # Include GNU-make-specific auto-dep code. Don't include it
2714 # if DEP_FILES would be empty.
2715 if ($dir_holds_sources && keys %dep_files)
2717 &define_pretty_variable ('DEP_FILES', '', sort keys %dep_files);
2718 $output_rules .= &file_contents ('depend');
2719 push (@clean, 'depend');
2720 &push_phony_cleaners ('depend');
2722 &file_contents_with_transform ('s/\@EXT\@/.c/g;'
2723 . 's/\@MKDEP\@/MKDEP/g;'
2727 local ($need_cxx) = 0;
2728 foreach $ext (sort keys %cxx_extensions)
2731 &file_contents_with_transform ('s/\@EXT\@/' . $ext .'/g;'
2732 . 's/\@MKDEP\@/CXXMKDEP/g;'
2739 &define_variable ('CXXMKDEP', '$(CXX) -M $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CXXFLAGS)');
2743 elsif ($build_directory ne '')
2745 # Include any auto-generated deps that are present. Note that
2746 # $build_directory ends in a "/".
2747 if (-d ($build_directory . $relative_dir . "/.deps")
2748 && -f ($build_directory . $relative_dir . "/.deps/.P"))
2752 foreach $depfile (&my_glob ($build_directory
2753 . $relative_dir . "/.deps/*.P"))
2755 &scan_dependency_file ($depfile);
2758 $output_rules .= "\n";
2763 # Handle subdirectories.
2766 return if ! &variable_defined ('SUBDIRS');
2768 # Make sure each directory mentioned in SUBDIRS actually exists.
2770 foreach $dir (&variable_value_as_list ('SUBDIRS', 'all'))
2772 # Skip directories substituted by configure.
2773 next if $dir =~ /^\@.*\@$/;
2775 if (! -d $am_relative_dir . '/' . $dir)
2777 &am_line_error ('SUBDIRS',
2778 "required directory $am_relative_dir/$dir does not exist");
2782 &am_line_error ('SUBDIRS', "directory should not contain \`/'")
2786 local ($xform) = ('s/\@INSTALLINFO\@/' .
2787 (defined $options{'no-installinfo'}
2788 ? 'install-info-recursive'
2791 $output_rules .= &file_contents_with_transform ($xform, 'subdirs');
2793 # Push a bunch of phony targets.
2795 foreach $phonies ('-data', '-exec', 'dirs')
2797 push (@phony, 'install' . $phonies . '-recursive');
2798 push (@phony, 'uninstall' . $phonies . '-recursive');
2800 foreach $phonies ('all', 'check', 'installcheck', 'info', 'dvi')
2802 push (@phony, $phonies . '-recursive');
2804 &push_phony_cleaners ('recursive');
2806 push (@check_tests, "check-recursive");
2807 push (@installcheck, "installcheck-recursive");
2808 push (@info, "info-recursive");
2809 push (@dvi, "dvi-recursive");
2811 $recursive_install = 1;
2814 # Handle aclocal.m4.
2815 sub handle_aclocal_m4
2817 local ($regen_aclocal) = 0;
2818 if (-f 'aclocal.m4')
2820 &define_variable ("ACLOCAL_M4", '$(top_srcdir)/aclocal.m4');
2821 &push_dist_common ('aclocal.m4');
2823 if (open (ACLOCAL, '< aclocal.m4'))
2829 if ($line =~ 'generated automatically by aclocal')
2836 local ($acinclude) = 0;
2837 if (-f 'acinclude.m4')
2843 # Note that it might be possible that aclocal.m4 doesn't exist but
2844 # should be auto-generated. This case probably isn't very
2848 local (@ac_deps) = (
2849 ($seen_maint_mode ? "\@MAINT\@" : "") ,
2851 ($acinclude ? ' acinclude.m4' : '')
2854 # Scan all -I directories for m4 files. These are our
2856 if (&variable_defined ('ACLOCAL_AMFLAGS'))
2859 foreach $amdir (&variable_value_as_list ('ACLOCAL_AMFLAGS', ''))
2861 if ($amdir =~ s/^-I//
2865 push (@ac_deps, &my_glob ($am_dir . '/*.m4'));
2870 &pretty_print_rule ("\$(ACLOCAL_M4):", "\t\t", @ac_deps);
2872 $output_rules .= ("\t"
2873 . 'cd $(srcdir) && $(ACLOCAL)'
2874 . (&variable_defined ('ACLOCAL_AMFLAGS')
2875 ? ' $(ACLOCAL_AMFLAGS)' : '')
2880 # Rewrite a list of input files into a form suitable to put on a
2881 # dependency list. The idea is that if an input file has a directory
2882 # part the same as the current directory, then the directory part is
2883 # simply removed. But if the directory part is different, then
2884 # $(top_srcdir) is prepended. Among other things, this is used to
2885 # generate the dependency list for the output files generated by
2886 # AC_OUTPUT. Consider what the dependencies should look like in this
2888 # AC_OUTPUT(src/out:src/in1:lib/in2)
2889 sub rewrite_inputs_into_dependencies
2891 local (@inputs) = @_;
2892 local ($single, @newinputs);
2894 foreach $single (@inputs)
2896 if (&dirname ($single) eq $relative_dir)
2898 push (@newinputs, &basename ($single));
2902 push (@newinputs, '$(top_srcdir)/' . $single);
2909 # Handle remaking and configure stuff.
2910 # We need the name of the input file, to do proper remaking rules.
2911 sub handle_configure
2913 local ($local, $input, @secondary_inputs) = @_;
2915 # If SUBDIRS defined, require AC_PROG_MAKE_SET.
2916 &am_line_error ('SUBDIRS', "AC_PROG_MAKE_SET must be used in configure.in")
2917 if &variable_defined ('SUBDIRS') && ! $seen_make_set;
2919 local ($top_reldir);
2921 local ($input_base) = &basename ($input);
2922 local ($local_base) = &basename ($local);
2924 local ($amfile) = $input_base . '.am';
2925 # We know we can always add '.in' because it really should be an
2926 # error if the .in was missing originally.
2927 local ($infile) = '$(srcdir)/' . $input_base . '.in';
2928 local ($colon_infile);
2929 if ($local ne $input)
2931 $colon_infile = ':' . $input . '.in';
2933 $colon_infile .= ':' . join (':', @secondary_inputs)
2934 if @secondary_inputs;
2936 local (@rewritten) = &rewrite_inputs_into_dependencies (@secondary_inputs);
2937 # This rule remakes the Makefile.in. Note use of @MAINT@ forces
2938 # us to abandon pretty-printing. Sigh.
2939 $output_rules .= ($infile
2940 # NOTE perl 5.003 (with -w) gives a
2941 # uninitialized value error on the next line.
2944 . ($seen_maint_mode ? '@MAINT@ ' : '')
2946 . '$(top_srcdir)/configure.in $(ACLOCAL_M4) '
2947 . join (' ', @rewritten) . "\n"
2948 . "\tcd \$(top_srcdir) && \$(AUTOMAKE) "
2949 . ($cygnus_mode ? '--cygnus' : ('--' . $strictness_name))
2950 . ($cmdline_use_dependencies ? '' : ' --include-deps')
2951 . ' ' . $input . $colon_infile . "\n\n");
2953 # This rule remakes the Makefile.
2954 $output_rules .= ($local_base
2955 # NOTE: bogus uninit value error on next line;
2956 # see comment above.
2959 . '$(top_builddir)/config.status'
2960 # NOTE: Makefile only depends on BUILT_SOURCES
2961 # when dependencies are being computed. This is
2962 # a workaround for an obscure bug with
2963 # AC_LINK_FILES. Anyway, when dependencies are
2964 # turned off, this shouldn't matter.
2965 . ($use_dependencies ? ' $(BUILT_SOURCES)' : '')
2967 . "\tcd \$(top_builddir) \\\n"
2968 . "\t && CONFIG_FILES="
2969 . (($relative_dir eq '.') ? '$@' : '$(subdir)/$@')
2971 . ' CONFIG_HEADERS= $(SHELL) ./config.status'
2974 if ($relative_dir ne '.')
2977 $top_reldir = '../';
2982 $output_rules .= &file_contents ('remake');
2983 &examine_variable ('CONFIGURE_DEPENDENCIES');
2987 # If we have a configure header, require it.
2989 local (@local_fullnames) = @config_fullnames;
2990 local (@local_names) = @config_names;
2991 local ($hdr_index) = 0;
2992 local ($distclean_config) = '';
2993 foreach $one_hdr (@config_headers)
2995 local ($one_fullname) = shift (@local_fullnames);
2996 local ($one_name) = shift (@local_names);
2998 if ($relative_dir eq &dirname ($one_hdr))
3000 local ($ch_sans_dir) = &basename ($one_hdr);
3001 local ($cn_sans_dir) = &basename ($one_name);
3003 &require_file_with_conf_line ($config_header_line,
3004 $FOREIGN, $ch_sans_dir);
3006 # Header defined and in this directory.
3008 if (-f $relative_dir . '/acconfig.h')
3010 push (@files, 'acconfig.h');
3012 if (-f $one_name . '.top')
3014 push (@files, "${cn_sans_dir}.top");
3016 if (-f $one_name . '.bot')
3018 push (@files, "${cn_sans_dir}.bot");
3021 &push_dist_common (@files);
3023 local ($stamp_name) = 'stamp-h';
3024 $stamp_name .= "${hdr_index}" if scalar (@config_headers) > 1;
3026 local ($xform) = '';
3028 $xform = 's,\@FILES\@,' . join (' ', @files) . ',;';
3029 $xform .= 's,\@CONFIG_HEADER\@,' . "${cn_sans_dir}" . ',;';
3030 $xform .= 's,\@CONFIG_HEADER_IN\@,' . "${ch_sans_dir}" . ',;';
3031 $xform .= 's,\@CONFIG_HEADER_FULL\@,' . "${one_fullname}" . ',;';
3032 $xform .= 's,\@STAMP\@,' . "${stamp_name}" . ',;';
3034 $output_rules .= &file_contents_with_transform ($xform,
3037 &touch ($relative_dir . "/${stamp_name}.in");
3038 &require_file_with_conf_line ($config_header_line, $FOREIGN,
3039 "${stamp_name}.in");
3041 $distclean_config .= ' ' if $distclean_config;
3042 $distclean_config .= $cn_sans_dir;
3046 if ($distclean_config)
3048 $output_rules .= &file_contents_with_transform ('s,\@FILES\@,'
3052 push (@clean, 'hdr');
3053 &push_phony_cleaners ('hdr');
3056 # Set location of mkinstalldirs.
3057 if ($config_aux_dir ne '.' && $config_aux_dir ne '')
3059 &define_variable ('mkinstalldirs', ('$(SHELL) ' . $config_aux_dir
3060 . '/mkinstalldirs'));
3064 &define_variable ('mkinstalldirs',
3065 '$(SHELL) $(top_srcdir)/mkinstalldirs');
3068 &am_line_error ('CONFIG_HEADER',
3069 "\`CONFIG_HEADER' is an anachronism; now determined from \`configure.in'")
3070 if &variable_defined ('CONFIG_HEADER');
3073 local ($config_header) = '';
3074 foreach $one_name (@config_names)
3076 # Generate CONFIG_HEADER define.
3078 if ($relative_dir eq &dirname ($one_name))
3080 $one_hdr = &basename ($one_name);
3084 $one_hdr = "${top_builddir}/${one_name}";
3087 $config_header .= ' ' if $config_header;
3088 $config_header .= $one_hdr;
3092 &define_variable ("CONFIG_HEADER", $config_header);
3095 # Now look for other files in this directory which must be remade
3096 # by config.status, and generate rules for them.
3097 local (@actual_other_files) = ();
3098 local ($file, $local);
3099 local (@inputs, @rewritten_inputs, $single);
3100 local ($need_rewritten);
3101 foreach $file (@other_input_files)
3103 if ($file =~ /^(.*):(.*)$/)
3105 # This is the ":" syntax of AC_OUTPUT.
3107 $local = &basename ($file);
3108 @inputs = split (':', $2);
3109 @rewritten_inputs = &rewrite_inputs_into_dependencies (@inputs);
3110 $need_rewritten = 1;
3115 $local = &basename ($file);
3116 @inputs = ($local . '.in');
3118 &rewrite_inputs_into_dependencies ($file . '.in');
3119 $need_rewritten = 0;
3122 # Skip files not in this directory.
3123 next unless &dirname ($file) eq $relative_dir;
3125 # Skip any file that is an automake input.
3126 next if -f $file . '.am';
3128 # Some users have been tempted to put `stamp-h' in the
3129 # AC_OUTPUT line. This won't do the right thing, so we
3130 # explicitly fail here.
3131 if ($local eq 'stamp-h')
3133 # FIXME: allow real filename.
3134 &am_conf_error ('configure.in', $ac_output_line,
3135 'stamp-h should not appear in AC_OUTPUT');
3139 $output_rules .= ($local . ': '
3140 . '$(top_builddir)/config.status '
3141 . join (' ', @rewritten_inputs) . "\n"
3143 . 'cd $(top_builddir) && CONFIG_FILES='
3144 . ($relative_dir eq '.' ? '' : '$(subdir)/')
3145 . '$@' . ($need_rewritten
3146 ? (':' . join (':', @rewritten_inputs))
3148 . ' CONFIG_HEADERS= ./config.status'
3150 push (@actual_other_files, $local);
3152 # Require all input files.
3153 &require_file_with_conf_line ($ac_output_line, $FOREIGN,
3157 # These files get removed by "make clean".
3158 &define_pretty_variable ('CONFIG_CLEAN_FILES', '', @actual_other_files);
3164 $dir_holds_headers = &am_install_var ('header', 'HEADERS', 'include',
3165 'oldinclude', 'pkginclude',
3171 return if ! $seen_gettext || $relative_dir ne '.';
3173 if (! &variable_defined ('SUBDIRS'))
3176 ("AM_GNU_GETTEXT in configure.in but SUBDIRS not defined");
3180 &require_file_with_conf_line ($ac_gettext_line, $FOREIGN, 'ABOUT-NLS')
3183 if (&variable_defined ('SUBDIRS'))
3187 "AM_GNU_GETTEXT in configure.in but \`po' not in SUBDIRS")
3188 if $contents{'SUBDIRS'} !~ /\bpo\b/;
3191 "AM_GNU_GETTEXT in configure.in but \`intl' not in SUBDIRS")
3192 if $contents{'SUBDIRS'} !~ /\bintl\b/;
3195 # Ensure that each language in ALL_LINGUAS has a .po file, and
3196 # each po file is mentioned in ALL_LINGUAS.
3199 local (%linguas) = ();
3200 grep ($linguas{$_} = 1, split (' ', $all_linguas));
3207 &am_line_error ($all_linguas_line,
3208 ("po/$_.po exists but \`$_' not in \`ALL_LINGUAS'"))
3212 foreach (keys %linguas)
3214 &am_line_error ($all_linguas_line,
3215 "$_ in \`ALL_LINGUAS' but po/$_.po does not exist")
3221 &am_error ("AM_GNU_GETTEXT in configure.in but \`ALL_LINGUAS' not defined");
3225 # Handle footer elements.
3228 if ($contents{'SOURCES'})
3230 # NOTE don't use define_pretty_variable here, because
3231 # $contents{...} is already defined.
3232 $output_vars .= 'SOURCES = ' . $contents{'SOURCES'} . "\n";
3234 if ($contents{'OBJECTS'})
3236 # NOTE don't use define_pretty_variable here, because
3237 # $contents{...} is already defined.
3238 $output_vars .= 'OBJECTS = ' . $contents{'OBJECTS'} . "\n";
3240 if ($contents{'SOURCES'} || $contents{'OBJECTS'})
3242 $output_vars .= "\n";
3245 if (&variable_defined ('SUFFIXES'))
3247 # Push actual suffixes, and not $(SUFFIXES). Some versions of
3248 # make do not like variable substitutions on the .SUFFIXES
3250 push (@suffixes, &variable_value_as_list ('SUFFIXES', ''));
3252 if (&target_defined ('.SUFFIXES'))
3254 &am_line_error ('.SUFFIXES',
3255 "use variable \`SUFFIXES', not target \`.SUFFIXES'");
3258 # Note: AIX 4.1 /bin/make will fail if any suffix rule appears
3259 # before .SUFFIXES. So we make sure that .SUFFIXES appears before
3260 # anything else, by sticking it right after the default: target.
3261 $output_header .= ".SUFFIXES:\n";
3265 # Make sure suffixes has unique elements. Sort them to ensure
3266 # the output remains consistent.
3269 grep ($suffixes{$_} = 1, @suffixes);
3271 $output_header .= (".SUFFIXES: "
3272 . join (' ', sort keys %suffixes)
3275 $output_trailer .= &file_contents ('footer');
3278 # Deal with installdirs target.
3279 sub handle_installdirs
3281 # GNU Makefile standards recommend this.
3282 $output_rules .= ("installdirs:"
3283 . ($recursive_install
3284 ? " installdirs-recursive\n"
3286 push (@phony, 'installdirs');
3289 &pretty_print_rule ("\t" . '$(mkinstalldirs) ', "\t\t",
3292 $output_rules .= "\n";
3295 # There are several targets which need to be merged. This is because
3296 # their complete definition is compiled from many parts. Note that we
3297 # avoid double colon rules, otherwise we'd use them instead.
3298 sub handle_merge_targets
3300 local ($makefile) = @_;
3302 # There are a few install-related variables that you should not define.
3304 foreach $var ('PRE_INSTALL', 'POST_INSTALL', 'NORMAL_INSTALL')
3306 if (&variable_defined ($var))
3308 &am_line_error ($var, "\`$var' should not be defined");
3312 # Put this at the beginning for the sake of non-GNU makes. This
3313 # is still wrong if these makes can run parallel jobs. But it is
3315 unshift (@all, &basename ($makefile));
3318 foreach $one_name (@config_names)
3320 push (@all, &basename ($one_name))
3321 if &dirname ($one_name) eq $relative_dir;
3324 &do_one_merge_target ('info', @info);
3325 &do_one_merge_target ('dvi', @dvi);
3326 &do_check_merge_target;
3327 &do_one_merge_target ('installcheck', @installcheck);
3329 if (defined $options{'no-installinfo'})
3331 # FIXME: this is kind of a hack; should find another way to
3332 # know that this is required.
3334 if (grep ($_ eq 'install-info-am', @phony))
3336 push (@dirs, 'install-info-am');
3338 if (&variable_defined ('SUBDIRS'))
3340 push (@dirs, 'install-info-recursive');
3342 &do_one_merge_target ('install-info', @dirs);
3345 # Handle the various install targets specially. We do this so
3346 # that (eg) "make install-exec" will run "install-exec-recursive"
3347 # if required, but "make install" won't run it twice. Step one is
3348 # to see if the user specified local versions of any of the
3349 # targets we handle. "all" is treated as one of these since
3350 # "install" can run it.
3351 push (@install_exec, 'install-exec-local')
3352 if defined $contents{'install-exec-local'};
3353 push (@install_data, 'install-data-local')
3354 if defined $contents{'install-data-local'};
3355 push (@uninstall, 'uninstall-local')
3356 if defined $contents{'uninstall-local'};
3358 foreach $utarg ('uninstall-data-local', 'uninstall-data-hook',
3359 'uninstall-exec-local', 'uninstall-exec-hook')
3361 if (defined $contents{$utarg})
3364 ($x = $utarg) =~ s/(data|exec)-//;
3365 &am_line_error ($utarg, "use \`$x', not \`$utarg'");
3368 push (@all, 'all-local')
3369 if defined $contents{'all-local'};
3371 if (defined $contents{'install-local'})
3373 &am_line_error ('install-local',
3374 "use \`install-data' or \`install-exec', not \`install'");
3377 # Step two: if we are doing recursive makes, write out the
3378 # appropriate rules.
3380 if ($recursive_install)
3382 push (@install, 'install-recursive');
3386 local (@hackall) = ();
3388 local ($local_headers) = '';
3389 foreach $one_name (@config_names)
3391 if (&dirname ($one_name) eq $relative_dir)
3393 $local_headers .= ' ' if $local_headers;
3394 $local_headers .= &basename ($one_name);
3400 # This is kind of a hack, but I couldn't see a better
3401 # way to handle it. In this particular case, we need
3402 # to make sure config.h is built before we recurse.
3403 # We can't do this by changing the order of
3404 # dependencies to the "all" because that breaks when
3405 # using parallel makes. Instead we handle things
3407 $output_rules .= ("all-recursive-am: ${local_headers}"
3408 . "\n\t" . '$(MAKE) all-recursive'
3410 push (@hackall, 'all-recursive-am');
3411 push (@phony, 'all-recursive-am');
3415 push (@hackall, 'all-recursive');
3418 $output_rules .= ('all-am: '
3422 push (@all, 'all-am');
3423 push (@phony, 'all-am');
3427 @all = ('all-recursive');
3429 # Must always generate `all-am' target, so it can be
3430 # referred to elsewhere.
3431 $output_rules .= "all-am:\n";
3435 $output_rules .= ('install-exec-am: '
3436 . join (' ', @install_exec)
3438 @install_exec = ('install-exec-recursive', 'install-exec-am');
3439 push (@install, 'install-exec-am');
3440 push (@phony, 'install-exec-am');
3444 @install_exec = ('install-exec-recursive');
3448 $output_rules .= ('install-data-am: '
3449 . join (' ', @install_data)
3451 @install_data = ('install-data-recursive', 'install-data-am');
3452 push (@install, 'install-data-am');
3453 push (@phony, 'install-data-am');
3457 @install_data = ('install-data-recursive');
3461 $output_rules .= ('uninstall-am: '
3462 . join (' ', @uninstall)
3464 @uninstall = ('uninstall-recursive', 'uninstall-am');
3465 push (@phony, 'uninstall-am');
3469 @uninstall = ('uninstall-recursive');
3473 # Step three: print definitions users can use. Code below knows
3474 # that install-exec is done before install-data, beware.
3475 $output_rules .= ("install-exec: "
3476 . join (' ', @install_exec)
3478 $output_rules .= "\t\@\$(NORMAL_INSTALL)\n";
3479 if (defined $contents{'install-exec-hook'})
3481 $output_rules .= "\t" . '$(MAKE) install-exec-hook' . "\n";
3483 $output_rules .= "\n";
3484 push (@install, 'install-exec') if !$recursive_install;
3485 push (@phony, 'install-exec');
3487 $output_rules .= ("install-data: "
3488 . join (' ', @install_data)
3490 $output_rules .= "\t\@\$(NORMAL_INSTALL)\n";
3491 if (defined $contents{'install-data-hook'})
3493 $output_rules .= "\t" . '$(MAKE) install-data-hook' . "\n";
3495 $output_rules .= "\n";
3496 push (@install, 'install-data') if !$recursive_install;
3497 push (@phony, 'install-data');
3499 # If no dependencies for 'install', add 'all'. Why? That way
3500 # "make install" at top level of distclean'd distribution won't
3501 # fail because stuff in 'lib' fails to build.
3502 if (! @install || (scalar (@install) == 2
3503 && $install[0] eq 'install-exec'
3504 && $install[1] eq 'install-data'))
3506 push (@install, 'all');
3508 $output_rules .= ('install: '
3509 . join (' ', @install)
3510 # Use "@:" as empty command so nothing prints.
3514 . join (' ', @uninstall)
3516 push (@phony, 'install', 'uninstall');
3518 $output_rules .= ('all: '
3521 push (@phony, 'all');
3523 # Generate the new 'install-strip' target. Must set
3524 # INSTALL_SCRIPT to avoid stripping scripts.
3525 $output_rules .= ("install-strip:\n\t"
3526 . '$(MAKE) INSTALL_PROGRAM=\'$(INSTALL_PROGRAM) -s\' INSTALL_SCRIPT=\'$(INSTALL_PROGRAM)\' install'
3530 # Helper for handle_merge_targets.
3531 sub do_one_merge_target
3533 local ($name, @values) = @_;
3535 if (defined $contents{$name . '-local'})
3537 # User defined local form of target. So include it.
3538 push (@values, $name . '-local');
3539 push (@phony, $name . '-local');
3542 &pretty_print_rule ($name . ":", "\t\t", @values);
3543 push (@phony, $name);
3546 # Handle check merge target specially.
3547 sub do_check_merge_target
3549 if (defined $contents{'check-local'})
3551 # User defined local form of target. So include it.
3552 push (@check_tests, 'check-local');
3553 push (@phony, 'check-local');
3556 # In --cygnus mode, check doesn't depend on all.
3559 if (! &variable_defined ('SUBDIRS'))
3561 # 'check' must depend on `all', but not when doing
3563 unshift (@check, 'all');
3567 # When subdirs are used, do the `all' build and then do
3568 # all the recursive stuff. Actually use `all-am' because
3569 # it doesn't recurse; we rely on the check target in the
3570 # subdirs to do the required builds there.
3571 unshift (@check, 'all-am');
3575 # The check target must depend on the local equivalent of `all',
3576 # to ensure all the primary targets are built. Also it must
3577 # depend on the test code named in @check.
3578 &pretty_print_rule ('check:', "\t\t", @check);
3580 # Now the check rules must explicitly run anything named in
3581 # @check_tests. This is done via a separate make invocation to
3582 # avoid problems with parallel makes. Every time I write code
3583 # like this I wonder: how could you invent a parallel make and not
3584 # provide any real synchronization facilities?
3585 &pretty_print_rule ("\t\$(MAKE)", "\t ", @check_tests);
3588 # Handle all 'clean' targets.
3591 push (@clean, 'generic');
3592 $output_rules .= &file_contents ('clean');
3593 &push_phony_cleaners ('generic');
3595 local ($target) = $recursive_install ? 'clean-am' : 'clean';
3596 &do_one_clean_target ($target, 'mostly', '', @clean);
3597 &do_one_clean_target ($target, '', 'mostly', @clean);
3598 &do_one_clean_target ($target, 'dist', '', @clean);
3599 &do_one_clean_target ($target, 'maintainer-', 'dist', @clean);
3601 push (@phony, 'clean', 'mostlyclean', 'distclean', 'maintainer-clean');
3604 if ($recursive_install)
3606 # Do -recursive before -am. If you aren't doing a parallel
3607 # make, this can be nicer.
3608 @deps = ('recursive', 'am');
3609 &do_one_clean_target ('', 'mostly', '', @deps);
3610 &do_one_clean_target ('', '', '', @deps);
3611 &do_one_clean_target ('', 'dist', '', @deps);
3612 &do_one_clean_target ('', 'maintainer-', '', @deps);
3616 # Helper for handle_clean.
3617 sub do_one_clean_target
3619 local ($target, $name, $last_name, @deps) = @_;
3621 # Special case: if target not passed, then don't generate
3622 # dependency on next "lower" clean target (eg no
3623 # clean<-mostlyclean derivation). In this case the target is
3624 # implicitly known to be 'clean'.
3625 local ($flag) = $target;
3626 $target = 'clean' if ! $flag;
3628 grep (($_ = $name . 'clean-' . $_) && 0, @deps);
3631 if ($last_name || $name ne 'mostly')
3633 push (@deps, $last_name . $target);
3637 # If a -local version of the rule is given, add it to the list.
3638 if (defined $contents{$name . $target . '-local'})
3640 push (@deps, $name . $target . '-local');
3643 # Print the target and the dependencies.
3644 &pretty_print_rule ($name . $target . ": ", "\t\t", @deps);
3646 # FIXME: shouldn't we really print these messages before running
3648 if ($name . $target eq 'maintainer-clean')
3650 # Print a special warning.
3652 ("\t\@echo \"This command is intended for maintainers to use;\"\n"
3653 . "\t\@echo \"it deletes files that may require special "
3654 . "tools to rebuild.\"\n");
3656 $output_rules .= "\t-rm -f config.status\n"
3657 if $relative_dir eq '.';
3659 elsif ($name . $target eq 'distclean')
3661 $output_rules .= "\t-rm -f config.status\n";
3662 $output_rules .= "\t-rm -f libtool\n" if $seen_libtool;
3664 $output_rules .= "\n";
3667 # Handle .PHONY target.
3670 &pretty_print_rule ('.PHONY:', "", @phony);
3671 $output_rules .= "\n";
3674 # Handle TESTS variable and other checks.
3677 if (defined $options{'dejagnu'})
3679 push (@check_tests, 'check-DEJAGNU');
3680 push (@phony, 'check-DEJAGNU');
3685 $xform = 's/^CYGNUS//;';
3689 $xform = 's/^CYGNUS.*$//;';
3691 $output_rules .= &file_contents_with_transform ($xform, 'dejagnu');
3693 # In Cygnus mode, these are found in the build tree.
3694 # Otherwise they are looked for in $PATH.
3695 &define_program_variable ('EXPECT', 'build', 'expect', 'expect');
3696 &define_program_variable ('RUNTEST', 'src', 'dejagnu', 'runtest');
3698 # Note that in the rule we don't directly generate site.exp to
3699 # avoid the possibility of a corrupted site.exp if make is
3700 # interrupted. Jim Meyering has some useful text on this
3702 $output_rules .= ("site.exp: Makefile\n"
3703 . "\t\@echo 'Making a new site.exp file...'\n"
3704 . "\t-\@rm -f site.bak\n"
3705 . "\t\@echo '## these variables are automatically generated by make ##' > \$\@-t\n"
3706 . "\t\@echo '# Do not edit here. If you wish to override these values' >> \$\@-t\n"
3707 . "\t\@echo '# edit the last section' >> \$\@-t\n"
3708 . "\t\@echo 'set tool \$(DEJATOOL)' >> \$\@-t\n"
3709 . "\t\@echo 'set srcdir \$(srcdir)' >> \$\@-t\n"
3710 . "\t\@echo 'set objdir' \`pwd\` >> \$\@-t\n");
3712 # Extra stuff for AC_CANONICAL_*
3713 local (@whatlist) = ();
3714 if ($seen_canonical)
3716 push (@whatlist, 'host')
3719 # Extra stuff only for AC_CANONICAL_SYSTEM.
3720 if ($seen_canonical == $AC_CANONICAL_SYSTEM)
3722 push (@whatlist, 'target', 'build');
3726 foreach $c1 (@whatlist)
3728 foreach $c2 ('alias', 'triplet')
3730 $output_rules .= "\t\@echo 'set ${c1}_${c2} \$(${c1}_${c2})' >> \$\@-t\n";
3734 $output_rules .= ("\t\@echo '## All variables above are generated by configure. Do Not Edit ##' >> \$\@-t\n"
3735 . "\t-\@sed '1,/^## All variables above are.*##/ d' site.bak >> \$\@-t\n"
3736 . "\t-\@mv site.exp site.bak\n"
3737 . "\t\@mv \$\@-t site.exp\n");
3742 foreach $c ('DEJATOOL', 'RUNTEST', 'RUNTESTFLAGS')
3744 if (&variable_defined ($c))
3746 &am_line_error ($c, "\`$c' defined but \`dejagnu' not in \`AUTOMAKE_OPTIONS'");
3751 if (&variable_defined ('TESTS'))
3753 push (@check_tests, 'check-TESTS');
3754 push (@phony, 'check-TESTS');
3756 $output_rules .= 'check-TESTS: $(TESTS)
3757 @failed=0; all=0; \\
3758 srcdir=$(srcdir); export srcdir; \\
3759 for tst in $(TESTS); do \\
3760 if test -f $$tst; then dir=.; \\
3761 else dir="$(srcdir)"; fi; \\
3762 if $(TESTS_ENVIRONMENT) $$dir/$$tst; then \\
3763 all=`expr $$all + 1`; \\
3764 echo "PASS: $$tst"; \\
3765 elif test $$? -ne 77; then \\
3766 all=`expr $$all + 1`; \\
3767 failed=`expr $$failed + 1`; \\
3768 echo "FAIL: $$tst"; \\
3771 if test "$$failed" -eq 0; then \\
3772 banner="All $$all tests passed"; \\
3774 banner="$$failed of $$all tests failed"; \\
3776 dashes=`echo "$$banner" | sed s/./=/g`; \\
3780 test "$$failed" -eq 0
3785 # Handle Emacs Lisp.
3786 sub handle_emacs_lisp
3788 local (@elfiles) = &am_install_var ('lisp', 'LISP', 'lisp', 'noinst');
3793 &define_configure_variable ('lispdir');
3794 &define_configure_variable ('EMACS');
3795 $output_rules .= (".el.elc:\n"
3796 . "\t\@echo 'WARNING: Warnings can be ignored. :-)'\n"
3797 . "\tif test \$(EMACS) != no; then \\\n"
3798 . "\t EMACS=\$(EMACS) \$(SHELL) \$(srcdir)/elisp-comp \$<; \\\n"
3800 push (@suffixes, '.el', '.elc');
3802 # Generate .elc files.
3803 grep ($_ .= 'c', @elfiles);
3804 &define_pretty_variable ('ELCFILES', '', @elfiles);
3806 $output_rules .= &file_contents ('lisp-clean');
3807 push (@clean, 'lisp');
3808 &push_phony_cleaners ('lisp');
3810 push (@all, '$(ELCFILES)');
3813 if (&variable_defined ('lisp_LISP'))
3815 $varname = 'lisp_LISP';
3816 &am_error ("\`lisp_LISP' defined but \`AM_PATH_LISPDIR' not in \`configure.in'")
3821 $varname = 'noinst_LISP';
3824 &require_file_with_line ($varname, $FOREIGN, 'elisp-comp');
3828 # Handle some of the minor options.
3829 sub handle_minor_options
3831 if (defined $options{'readme-alpha'})
3833 if ($relative_dir eq '.')
3835 if ($package_version !~ /^$GNITS_VERSION_PATTERN$/)
3837 # FIXME: allow real filename.
3838 &am_conf_line_error ('configure.in',
3839 $package_version_line,
3840 "version \`$package_version' doesn't follow Gnits standards");
3842 elsif (defined $1 && -f 'README-alpha')
3844 # This means we have an alpha release. See
3845 # GNITS_VERSION_PATTERN for details.
3846 &require_file ($FOREIGN, 'README-alpha');
3852 ################################################################
3854 # Scan one file for interesting things. Subroutine of scan_configure.
3855 sub scan_one_configure_file
3857 local ($filename) = @_;
3859 open (CONFIGURE, $filename)
3860 || die "automake: couldn't open \`$filename': $!\n";
3861 print "automake: reading $filename\n" if $verbose;
3865 # Remove comments from current line.
3869 # Skip macro definitions. Otherwise we might be confused into
3870 # thinking that a macro that was only defined was actually
3874 # Populate libobjs array.
3875 if (/AC_FUNC_ALLOCA/)
3877 $libsources{'alloca.c'} = 1;
3879 elsif (/AC_FUNC_GETLOADAVG/)
3881 $libsources{'getloadavg.c'} = 1;
3883 elsif (/AC_FUNC_MEMCMP/)
3885 $libsources{'memcmp.c'} = 1;
3887 elsif (/AC_STRUCT_ST_BLOCKS/)
3889 $libsources{'fileblocks.c'} = 1;
3891 elsif (/A[CM]_REPLACE_GNU_GETOPT/)
3893 $libsources{'getopt.c'} = 1;
3894 $libsources{'getopt1.c'} = 1;
3896 elsif (/AM_FUNC_STRTOD/)
3898 $libsources{'strtod.c'} = 1;
3900 elsif (/AM_WITH_REGEX/)
3902 $libsources{'rx.c'} = 1;
3903 $libsources{'rx.h'} = 1;
3904 $libsources{'regex.c'} = 1;
3905 $libsources{'regex.h'} = 1;
3906 $omit_dependencies{'rx.h'} = 1;
3907 $omit_dependencies{'regex.h'} = 1;
3909 elsif (/AM_FUNC_MKTIME/)
3911 $libsources{'mktime.c'} = 1;
3913 elsif (/AM_FUNC_ERROR_AT_LINE/)
3915 $libsources{'error.c'} = 1;
3916 $libsources{'error.h'} = 1;
3918 elsif (/AM_FUNC_OBSTACK/)
3920 $libsources{'obstack.c'} = 1;
3921 $libsources{'obstack.h'} = 1;
3923 elsif (/LIBOBJS="(.*)\s+\$LIBOBJS"/
3924 || /LIBOBJS="\$LIBOBJS\s+(.*)"/)
3926 foreach $libobj_iter (split (' ', $1))
3928 if ($libobj_iter =~ /^(.*)\.o$/)
3930 $libsources{$1 . '.c'} = 1;
3935 if (! $in_ac_replace && s/AC_REPLACE_FUNCS\s*\(\[?//)
3941 $in_ac_replace = 0 if s/[\]\)].*$//;
3942 # Remove trailing backslash.
3946 # Need to skip empty elements for Perl 4.
3948 $libsources{$_ . '.c'} = 1;
3952 if (/$obsolete_rx/o)
3955 if ($obsolete_macros{$1})
3957 $hint = '; ' . $obsolete_macros{$1};
3959 &am_conf_line_error ($filename, $., "\`$1' is obsolete$hint");
3962 # Process the AC_OUTPUT macro.
3963 if (! $in_ac_output && s/AC_OUTPUT\s*\(\[?//)
3966 $ac_output_line = $.;
3970 local ($closing) = 0;
3977 # Look at potential Makefile.am's.
3980 # Must skip empty string for Perl 4.
3981 next if $_ eq "\\" || $_ eq '';
3983 # Handle $local:$input syntax. Note that we ignore
3984 # every input file past the first, though we keep
3985 # those around for later.
3986 local ($local, $input, @rest) = split (/:/);
3993 # FIXME: should be error if .in is missing.
3994 $input =~ s/\.in$//;
3997 if (-f $input . '.am')
3999 # We have a file that automake should generate.
4000 push (@make_input_list, $input);
4001 $make_list{$input} = join (':', ($local, @rest));
4005 # We have a file that automake should cause to be
4006 # rebuilt, but shouldn't generate itself.
4007 push (@other_input_files, $_);
4011 if ($closing && @make_input_list == 0 && @other_input_files == 0)
4013 &am_conf_line_error ($filename, $ac_output_line,
4014 "No files mentioned in \`AC_OUTPUT'");
4019 if (/$AC_CONFIG_AUX_DIR_PATTERN/o)
4021 @config_aux_path = $1;
4024 # Check for ansi2knr.
4025 $am_c_prototypes = 1 if /AM_C_PROTOTYPES/;
4027 # Check for exe extension stuff.
4031 $configure_vars{'EXEEXT'} = 1;
4034 # Check for NLS support.
4035 if (/AM_GNU_GETTEXT/)
4038 $ac_gettext_line = $.;
4039 $omit_dependencies{'libintl.h'} = 1;
4042 # Look for ALL_LINGUAS.
4043 if (/ALL_LINGUAS="(.*)"$/ || /ALL_LINGUAS=(.*)$/)
4047 $all_linguas_line = $.;
4050 # Handle configuration headers. A config header of `[$1]'
4051 # means we are actually scanning AM_CONFIG_HEADER from
4053 if (/A([CM])_CONFIG_HEADER\s*\((.*)\)/
4058 "\`AC_CONFIG_HEADER' is obsolete; use \`AM_CONFIG_HEADER'")
4061 $config_header_line = $.;
4063 foreach $one_hdr (split (' ', $2))
4065 push (@config_fullnames, $one_hdr);
4066 if ($one_hdr =~ /^([^:]+):(.+)$/)
4068 push (@config_names, $1);
4069 push (@config_headers, $2);
4073 push (@config_names, $one_hdr);
4074 push (@config_headers, $one_hdr . '.in');
4079 # Handle AC_CANONICAL_*. Always allow upgrading to
4080 # AC_CANONICAL_SYSTEM, but never downgrading.
4081 $seen_canonical = $AC_CANONICAL_HOST
4082 if ! $seen_canonical
4083 && (/AC_CANONICAL_HOST/ || /AC_CHECK_TOOL/);
4084 $seen_canonical = $AC_CANONICAL_SYSTEM if /AC_CANONICAL_SYSTEM/;
4086 $seen_path_xtra = 1 if /AC_PATH_XTRA/;
4088 # This macro handles several different things.
4089 if (/$AM_INIT_AUTOMAKE_PATTERN/o)
4095 $seen_prog_install = 2;
4096 ($package_version = $1) =~ s/$AM_PACKAGE_VERSION_PATTERN/$1/o;
4097 $package_version_line = $.;
4100 # This is like AM_INIT_AUTOMAKE, but doesn't actually set the
4101 # package and version number. (This might change in the
4102 # future). Yes, I'm not above hacking Automake so it works
4103 # well with other GNU tools -- that is actually the point.
4104 if (/AM_INIT_GUILE_MODULE/)
4110 $seen_prog_install = 2;
4111 @config_aux_path = ('..');
4114 # Some things required by Automake.
4115 $seen_make_set = 1 if /AC_PROG_MAKE_SET/;
4116 $seen_arg_prog = 1 if /AC_ARG_PROGRAM/;
4118 if (/AC_PROG_(YACC|RANLIB|CC|CXX|LEX|AWK|CPP|CXXCPP|LN_S)/)
4120 $configure_vars{$1} = 1;
4122 if (/$AC_CHECK_PATTERN/o)
4124 $configure_vars{$3} = 1;
4126 if (/$AM_MISSING_PATTERN/o
4130 && $1 ne 'AUTOHEADER')
4132 $configure_vars{$1} = 1;
4135 # Explicitly avoid ANSI2KNR -- we AC_SUBST that in protos.m4,
4136 # but later define it elsewhere. This is pretty hacky. We
4137 # also explicitly avoid INSTALL_SCRIPT and some other
4138 # variables because they are defined in header-vars.am.
4140 if (/$AC_SUBST_PATTERN/o
4142 && $1 ne 'INSTALL_SCRIPT')
4144 $configure_vars{$1} = 1;
4147 $seen_decl_yytext = 1 if /AC_DECL_YYTEXT/;
4148 $seen_maint_mode = 1 if /AM_MAINTAINER_MODE/;
4149 $seen_package = 1 if /PACKAGE=/;
4151 # Skip VERSION of [$2]; that is from AM_INIT_AUTOMAKE.
4152 if (/\bVERSION=(\S+)/ && $1 ne '[$2]')
4155 $package_version = $1;
4156 $package_version_line = $.;
4163 # Weird conditionals here because it is always allowed to
4164 # upgrade to AM_PROG_INSTALL but never to downgrade to
4166 $seen_prog_install = 1 if ! $seen_prog_install && /AC_PROG_INSTALL/;
4167 $seen_prog_install = 2 if /AM_PROG_INSTALL/;
4169 $seen_lispdir = 1 if /AM_PATH_LISPDIR/;
4171 if (/AM_PROG_LIBTOOL/)
4175 $configure_vars{'LIBTOOL'} = 1;
4176 $configure_vars{'RANLIB'} = 1;
4177 $configure_vars{'CC'} = 1;
4178 # AM_PROG_LIBTOOL runs AC_CANONICAL_HOST. Make sure we
4179 # never downgrade (if we've seen AC_CANONICAL_SYSTEM).
4180 $seen_canonical = $AC_CANONICAL_HOST if ! $seen_canonical;
4183 if (/$AM_CONDITIONAL_PATTERN/o)
4185 $configure_cond{$1} = 1;
4192 # Scan configure.in and aclocal.m4 for interesting things. We must
4193 # scan aclocal.m4 because there might be AC_SUBSTs and such there.
4196 # Reinitialize libsources here. This isn't really necessary,
4197 # since we currently assume there is only one configure.in. But
4198 # that won't always be the case.
4201 local ($in_ac_output, $in_ac_replace) = (0, 0);
4202 local (%make_list, @make_input_list);
4203 local ($libobj_iter);
4205 &scan_one_configure_file ('configure.in');
4206 &scan_one_configure_file ('aclocal.m4')
4209 # Set input and output files if not specified by user.
4212 @input_files = @make_input_list;
4213 %output_files = %make_list;
4216 &am_conf_error ("\`PACKAGE' not defined in configure.in")
4218 &am_conf_error ("\`VERSION' not defined in configure.in")
4221 # Look for some files we need. Always check for these. This
4222 # check must be done for every run, even those where we are only
4223 # looking at a subdir Makefile. We must set relative_dir so that
4224 # the file-finding machinery works.
4225 local ($relative_dir) = '.';
4226 &require_config_file ($FOREIGN, 'install-sh', 'mkinstalldirs', 'missing');
4227 &am_error ("\`install.sh' is an anachronism; use \`install-sh' instead")
4228 if -f $config_aux_path[0] . '/install.sh';
4231 ################################################################
4233 # Set up for Cygnus mode.
4236 return unless $cygnus_mode;
4238 &set_strictness ('foreign');
4239 $options{'no-installinfo'} = 1;
4240 $options{'no-dependencies'} = 1;
4241 $use_dependencies = 0;
4243 if (! $seen_maint_mode)
4245 &am_conf_error ("\`AM_MAINTAINER_MODE' required when --cygnus specified");
4250 &am_conf_error ("\`AM_EXEEXT' required when --cygnus specified");
4254 # Do any extra checking for GNU standards.
4255 sub check_gnu_standards
4257 if ($relative_dir eq '.')
4259 # In top level (or only) directory.
4260 &require_file ($GNU, 'INSTALL', 'NEWS', 'README', 'COPYING',
4261 'AUTHORS', 'ChangeLog');
4264 if ($strictness >= $GNU)
4266 if (defined $options{'no-installman'})
4268 &am_line_error ('AUTOMAKE_OPTIONS',
4269 "option \`no-installman' disallowed by GNU standards");
4272 if (defined $options{'no-installinfo'})
4274 &am_line_error ('AUTOMAKE_OPTIONS',
4275 "option \`no-installinfo' disallowed by GNU standards");
4280 # Do any extra checking for GNITS standards.
4281 sub check_gnits_standards
4283 if ($strictness >= $GNITS)
4285 if (-f $relative_dir . '/COPYING.LIB')
4287 &am_error ("\`${relative_dir}/COPYING.LIB' disallowed by Gnits standards");
4291 if ($relative_dir eq '.')
4293 # In top level (or only) directory.
4294 &require_file ($GNITS, 'THANKS');
4298 ################################################################
4300 # Pretty-print something. HEAD is what should be printed at the
4301 # beginning of the first line, FILL is what should be printed at the
4302 # beginning of every subsequent line.
4303 sub pretty_print_internal
4305 local ($head, $fill, @values) = @_;
4307 local ($column) = length ($head);
4308 local ($result) = $head;
4310 # Fill length is number of characters. However, each Tab
4311 # character counts for eight. So we count the number of Tabs and
4313 local ($fill_length) = length ($fill);
4314 $fill_length += 7 * ($fill =~ tr/\t/\t/d);
4316 local ($bol) = ($head eq '');
4319 # "71" because we also print a space.
4320 if ($column + length ($_) > 71)
4322 $result .= " \\\n" . $fill;
4323 $column = $fill_length;
4327 $result .= ' ' unless ($bol);
4329 $column += length ($_) + 1;
4337 # Pretty-print something and append to output_vars.
4340 $output_vars .= &pretty_print_internal (@_);
4343 # Pretty-print something and append to output_rules.
4344 sub pretty_print_rule
4346 $output_rules .= &pretty_print_internal (@_);
4350 ################################################################
4352 # See if a target exists.
4355 local ($target) = @_;
4356 return defined $targets{$target};
4359 # See if two conditionals are the same.
4360 sub conditional_same
4362 local ($cond1, $cond2) = @_;
4364 return (&conditional_true_when ($cond1, $cond2)
4365 && &conditional_true_when ($cond2, $cond1));
4368 # See if a conditional is true. Both arguments are conditional
4369 # strings. This returns true if the first conditional is true when
4370 # the second conditional is true.
4371 sub conditional_true_when
4373 local ($cond, $when) = @_;
4375 # Check the easy case first.
4381 # Check each component of $cond, which looks @COND1@@COND2@.
4382 foreach $comp (split ('@', $cond))
4384 # The way we split will give null strings between each
4388 if (index ($when, '@' . $comp . '@') == -1)
4397 # Check for an ambiguous conditional. This is called when a variable
4398 # or target is being defined conditionally. If we already know about
4399 # a definition that is true under the same conditions, then we have an
4401 sub check_ambiguous_conditional
4403 local ($var_name, $cond) = @_;
4404 local (@cond_vals) = split (' ', $conditional{$var_name});
4407 local ($vcond) = shift (@cond_vals);
4409 if (&conditional_true_when ($vcond, $cond)
4410 || &conditional_true_when ($cond, $vcond))
4412 &am_line_error ($var_name,
4413 "$var_name multiply defined in condition");
4418 # See if a variable exists. The first argument is the variable name,
4419 # and the optional second argument is the condition which we should
4420 # check. If no condition is given, we currently return true if the
4421 # variable is defined under any condition.
4422 sub variable_defined
4424 local ($var, $cond) = @_;
4425 if (defined $targets{$var})
4427 &am_line_error ($var, "\`$var' is target; expected variable");
4430 elsif (defined $contents{$var})
4432 if ($cond && $conditional{$var})
4434 # We have been asked to check for a particular condition,
4435 # and the variable is defined conditionally. We need to
4436 # look through the conditions under which the variable is
4437 # defined, and see if any of them match the conditional we
4438 # have been asked to check.
4439 local (@cond_vars) = split (' ', $conditional{$var});
4442 if (&conditional_same ($cond, shift (@cond_vars)))
4444 # Even a conditional examination is good enough
4445 # for us. FIXME: really should maintain examined
4446 # status on a per-condition basis.
4447 $content_seen{$var} = 1;
4453 # The variable is not defined for the given condition.
4457 $content_seen{$var} = 1;
4463 # Mark a variable as examined.
4464 sub examine_variable
4467 &variable_defined ($var);
4470 # Quote a value in order to put it in $conditional. We need to quote
4471 # spaces, and we need to handle null strings, so that we can later
4472 # retrieve values by splitting on space.
4477 $val = '\002' if $val eq '';
4481 # Unquote a value in $conditional.
4482 sub unquote_cond_val
4486 $val = '' if $val eq '\002';
4490 # Return the set of conditions for which a variable is defined.
4492 # If the variable is not defined conditionally, and is not defined in
4493 # terms of any variables which are defined conditionally, then this
4494 # returns the empty list.
4496 # If the variable is defined conditionally, but is not defined in
4497 # terms of any variables which are defined conditionally, then this
4498 # returns the list of conditions for which the variable is defined.
4500 # If the variable is defined in terms of any variables which are
4501 # defined conditionally, then this returns a full set of permutations
4502 # of the subvariable conditions. For example, if the variable is
4503 # defined in terms of a variable which is defined for @COND_TRUE@,
4504 # then this returns both @COND_TRUE@ and @COND_FALSE@. This is
4505 # because we will need to define the variable under both conditions.
4507 sub variable_conditions
4513 foreach $cond (&variable_conditions_sub ($var, '', ()))
4515 $uniqify{$cond} = 1;
4518 return keys %uniqify;
4521 # A subroutine of variable_conditions. We only return conditions
4522 # which are true for all the conditions in @PARENT_CONDS.
4523 sub variable_conditions_sub
4525 local ($var, $parent, @parent_conds) = @_;
4526 local (@new_conds) = ();
4528 if (! $conditional{$var})
4530 foreach (split (' ', $contents{$var}))
4532 # If a comment seen, just leave.
4535 # Handle variable substitutions.
4536 if (/^\$\{(.*)\}$/ || /^\$\((.*)\)$/)
4539 &variable_conditions_sub ($1, $var, @parent_conds));
4543 return &variable_conditions_reduce (@new_conds);
4546 local (@this_conds) = ();
4547 local (@condvals) = split (' ', $conditional{$var});
4550 local ($cond) = shift (@condvals);
4551 local ($val) = &unquote_cond_val (shift (@condvals));
4556 local ($parent_cond);
4557 foreach $parent_cond (@parent_conds)
4559 if (! &conditional_true_when ($parent_cond, $cond))
4569 push (@this_conds, $cond);
4571 push (@parent_conds, $cond);
4572 local (@subvar_conds) = ();
4573 foreach (split (' ', $val))
4575 # If a comment seen, just leave.
4578 # Handle variable substitutions.
4579 if (/^\$\{(.*)\}$/ || /^\$\((.*)\)$/)
4581 push (@subvar_conds,
4582 &variable_conditions_sub ($1, $var, @parent_conds));
4585 pop (@parent_conds);
4587 # If there are no conditional subvariables, then we want to
4588 # return this condition. Otherwise, we want to return the
4589 # permutations of the subvariables.
4590 if (! @subvar_conds)
4592 push (@new_conds, $cond);
4596 push (@new_conds, &variable_conditions_reduce (@subvar_conds));
4603 # If we are being called on behalf of another variable, we need to
4604 # return all possible permutations of the conditions. We have
4605 # already handled everything in @this_conds along with their
4606 # subvariables. We now need to add any permutations that are not
4609 foreach $this_cond (@this_conds)
4612 &variable_conditions_permutations (split('@', $this_cond));
4614 foreach $perm (@perms)
4618 foreach $scan (@this_conds)
4620 if (&conditional_true_when ($perm, $scan)
4621 || &conditional_true_when ($scan, $perm))
4632 local ($parent_cond);
4633 foreach $parent_cond (@parent_conds)
4635 if (! &conditional_true_when ($parent_cond, $perm))
4645 # This permutation was not already handled, and is valid
4647 push (@new_conds, $perm);
4654 # Subroutine for variable_conditions_sort
4655 sub variable_conditions_cmp
4661 return (length ($as) <=> length ($bs)
4665 # Sort a list of conditionals so that only the exclusive ones are
4666 # retained. For example, if both @COND1_TRUE@@COND2_TRUE@ and
4667 # @COND1_TRUE@ are in the list, discard the latter.
4668 sub variable_conditions_reduce
4670 local (@conds) = @_;
4673 foreach $cond (sort variable_conditions_cmp @conds)
4677 foreach $scan (@ret)
4679 if (&conditional_true_when ($cond, $scan))
4692 # Return a list of permutations of a conditional string.
4693 sub variable_conditions_permutations
4695 local (@comps) = @_;
4698 local ($comp) = shift (@comps);
4699 return &variable_conditions_permutations (@comps)
4701 local ($neg) = $comp;
4702 $neg =~ s/TRUE$/TRUEO/;
4703 $neg =~ s/FALSE$/TRUE/;
4704 $neg =~ s/TRUEO$/FALSE/;
4707 foreach $sub (&variable_conditions_permutations (@comps))
4709 push (@ret, '@' . $comp . '@' . $sub);
4710 push (@ret, '@' . $neg . '@' . $sub);
4714 push (@ret, '@' . $comp . '@');
4715 push (@ret, '@' . $neg . '@');
4720 # Warn if a variable is conditionally defined. This is called if we
4721 # are using the value of a variable.
4722 sub variable_conditionally_defined
4724 local ($var, $parent) = @_;
4725 if ($conditional{$var})
4729 &am_line_error ($parent,
4730 "warning: automake does not support conditional definition of $var in $parent");
4734 &am_line_error ($parent,
4735 "warning: automake does not support $var being defined conditionally")
4740 # Get the value of a variable. This just returns $contents, but warns
4741 # if the variable is conditionally defined.
4745 &variable_conditionally_defined ($var);
4746 return $contents{$var};
4749 # Convert a variable value to a list, split as whitespace. This will
4750 # recursively follow $(...) and ${...} inclusions. It preserves @...@
4751 # substitutions. If COND is 'all', then all values under all
4752 # conditions should be returned; if COND is a particular condition
4753 # (all conditions are surrounded by @...@) then only the value for
4754 # that condition should be returned; otherwise, warn if VAR is
4755 # conditionally defined.
4758 local ($var, $val, $cond) = @_;
4761 foreach (split (' ', $val))
4763 # If a comment seen, just leave.
4766 # Handle variable substitutions.
4767 if (/^\$\{([^}]*)\}$/ || /^\$\(([^)]*)\)$/)
4769 local ($varname) = $1;
4771 # If the user uses a losing variable name, just ignore it.
4772 # This isn't ideal, but people have requested it.
4773 next if ($varname =~ /\@.*\@/);
4777 if ($varname =~ /^([^:]*):([^=]*)=(.*)$/)
4781 ($from = $2) =~ s/(\W)/\\$1/g;
4785 @temp_list = &variable_value_as_list ($1, $cond, $var);
4787 # Now rewrite the value if appropriate.
4790 grep (s/$from$/$to/, @temp_list);
4793 push (@result, @temp_list);
4804 # Return contents of variable as list, split as whitespace. This will
4805 # recursively follow $(...) and ${...} inclusions. It preserves @...@
4806 # substitutions. If COND is 'all', then all values under all
4807 # conditions should be returned; if COND is a particular condition
4808 # (all conditions are surrounded by @...@) then only the value for
4809 # that condition should be returned; otherwise, warn if VAR is
4810 # conditionally defined. If PARENT is specified, it is the name of
4811 # the including variable; this is only used for error reports.
4812 sub variable_value_as_list
4814 local ($var, $cond, $parent) = @_;
4817 if (defined $targets{$var})
4819 &am_line_error ($var, "\`$var' is target; expected variable");
4821 elsif (! defined $contents{$var})
4823 &am_line_error ($parent, "variable \`$var' not defined");
4825 elsif ($cond eq 'all' && $conditional{$var})
4827 local (@condvals) = split (' ', $conditional{$var});
4831 local ($val) = &unquote_cond_val (shift (@condvals));
4832 push (@result, &value_to_list ($var, $val, $cond));
4835 elsif ($cond && $conditional{$var})
4837 local (@condvals) = split (' ', $conditional{$var});
4841 local ($vcond) = shift (@condvals);
4842 local ($val) = &unquote_cond_val (shift (@condvals));
4843 if (&conditional_true_when ($vcond, $cond))
4845 # Warn if we have an ambiguity. It's hard to know how
4846 # to handle this case correctly.
4847 &variable_conditionally_defined ($var, $parent)
4850 push (@result, &value_to_list ($var, $val, $cond));
4856 &variable_conditionally_defined ($var, $parent);
4857 $content_seen{$var} = 1;
4858 push (@result, &value_to_list ($var, $contents{$var}, $cond));
4864 # Define a new variable, but only if not already defined.
4867 local ($var, $value) = @_;
4869 if (! defined $contents{$var})
4871 $output_vars .= $var . ' = ' . $value . "\n";
4872 $contents{$var} = $value;
4873 $content_seen{$var} = 1;
4877 # Like define_variable, but the value is a list, and the variable may
4878 # be defined conditionally. The second argument is the conditional
4879 # under which the value should be defined; this should be the empty
4880 # string to define the variable unconditionally. The third argument
4881 # is a list holding the values to use for the variable. The value is
4882 # pretty printed in the output file.
4883 sub define_pretty_variable
4885 local ($var, $cond, @value) = @_;
4886 if (! defined $contents{$var}
4887 || ($cond && ! &variable_defined ($var, $cond)))
4889 $contents{$var} = join (' ', @value);
4892 if ($conditional{$var})
4894 $conditional{$var} .= ' ';
4898 $conditional{$var} = '';
4900 $conditional{$var} .= ($cond
4902 . "e_cond_val ($contents{$var}));
4904 &pretty_print ($cond . $var . ' = ', $cond, @value);
4905 $content_seen{$var} = 1;
4909 # Like define_variable, but define a variable to be the configure
4910 # substitution by the same name.
4911 sub define_configure_variable
4914 local ($value) = '@' . $var . '@';
4915 &define_variable ($var, $value);
4918 # Define a variable that represents a program to run. If in Cygnus
4919 # mode, the program is searched for in the build (or source) tree.
4920 # Otherwise no searching is done at all. Arguments are:
4921 # * VAR Name of variable to define
4922 # * WHATDIR Either `src' or `build', depending on where program should
4923 # be found. (runtest is in srcdir!)
4924 # * SUBDIR Subdir of top-level dir
4925 # * PROGRAM Name of program
4926 # * OVERRIDE If specified, the name of the program to use when not in
4927 # Cygnus mode. Defaults to PROGRAM.
4928 sub define_program_variable
4930 local ($var, $whatdir, $subdir, $program, $override) = @_;
4934 $override = $program;
4939 local ($full) = ('$(top_' . $whatdir . 'dir)/../'
4940 . $subdir . '/' . $program);
4941 &define_variable ($var, ('`if test -f ' . $full
4942 . '; then echo ' . $full . '; else echo '
4943 . $program . '; fi`'));
4947 &define_variable ($var, $override);
4952 ################################################################
4954 # Read Makefile.am and set up %contents. Simultaneously copy lines
4955 # from Makefile.am into $output_trailer or $output_vars as
4956 # appropriate. NOTE we put rules in the trailer section. We want
4957 # user rules to come after our generated stuff.
4960 local ($amfile) = @_;
4962 open (AM_FILE, $amfile) || die "automake: couldn't open \`$amfile': $!\n";
4963 print "automake: reading $amfile\n" if $verbose;
4965 $output_vars = ("# $in_file_name generated automatically by automake "
4966 . $VERSION . " from $am_file_name\n");
4968 # Generate copyright for generated Makefile.in.
4969 $output_vars .= $gen_copyright;
4971 local ($saw_bk) = 0;
4972 local ($was_rule) = 0;
4973 local ($spacing) = '';
4974 local ($comment) = '';
4975 local ($last_var_name) = '';
4980 if (/$IGNORE_PATTERN/o)
4982 # Merely delete comments beginning with two hashes.
4984 elsif (/$WHITE_PATTERN/o)
4986 # Stick a single white line before the incoming macro or rule.
4990 elsif (/$COMMENT_PATTERN/o)
4992 # Stick comments before the incoming macro or rule. Make
4993 # sure a blank line preceeds first block of comments.
4994 $spacing = "\n" unless $blank;
4996 $comment .= $spacing . $_;
5005 $output_vars .= $comment . "\n";
5008 local ($am_vars) = '';
5010 local ($is_ok_macro);
5014 unless substr ($_, -1, 1) eq "\n";
5016 $_ =~ s/\@MAINT\@//g
5017 unless $seen_maint_mode;
5019 if (/$IGNORE_PATTERN/o)
5021 # Merely delete comments beginning with two hashes.
5023 elsif (/$WHITE_PATTERN/o)
5025 # Stick a single white line before the incoming macro or rule.
5028 elsif (/$COMMENT_PATTERN/o)
5030 # Stick comments before the incoming macro or rule.
5031 $comment .= $spacing . $_;
5038 $output_trailer .= join ('', @conditional_stack) . $_;
5043 $am_vars .= join ('', @conditional_stack) . $_;
5045 # Chop newline and backslash if this line is
5046 # continued. FIXME: maybe ensure trailing whitespace
5050 $contents{$last_var_name} .= $_;
5051 if (@conditional_stack)
5053 $conditional{$last_var_name} .= "e_cond_val ($_);
5057 elsif (/$IF_PATTERN/o)
5059 &am_line_error ($., "$1 does not appear in AM_CONDITIONAL")
5060 if (! $configure_cond{$1});
5061 push (@conditional_stack, "\@" . $1 . "_TRUE\@");
5063 elsif (/$ELSE_PATTERN/o)
5065 if (! @conditional_stack)
5067 &am_line_error ($., "else without if");
5069 elsif ($conditional_stack[$#conditional_stack] =~ /_FALSE\@$/)
5071 &am_line_error ($., "else after else");
5075 $conditional_stack[$#conditional_stack]
5076 =~ s/_TRUE\@$/_FALSE\@/;
5079 elsif (/$ENDIF_PATTERN/o)
5081 if (! @conditional_stack)
5083 &am_line_error ($., "endif without if");
5087 pop @conditional_stack;
5090 elsif (/$RULE_PATTERN/o)
5094 if (defined $contents{$1}
5095 && (@conditional_stack
5096 ? ! defined $conditional{$1}
5097 : defined $conditional{$1}))
5100 "$1 defined both conditionally and unconditionally");
5102 # Value here doesn't matter; for targets we only note
5106 local ($cond_string) = join ('', @conditional_stack);
5107 if (@conditional_stack)
5109 if ($conditional{$1})
5111 &check_ambiguous_conditional ($1, $cond_string);
5112 $conditional{$1} .= ' ';
5116 $conditional{$1} = '';
5118 $conditional{$1} .= $cond_string . ' 1';
5120 $content_lines{$1} = $.;
5121 $output_trailer .= $comment . $spacing . $cond_string . $_;
5122 $comment = $spacing = '';
5125 # Check the rule for being a suffix rule. If so, store in
5128 local ($source_suffix);
5129 local ($object_suffix);
5131 if (($source_suffix, $object_suffix) = ($1 =~ $SUFFIX_RULE_PATTERN))
5133 $suffix_rules{$source_suffix} = $object_suffix;
5134 print "Sources ending in .$source_suffix become .$object_suffix\n" if $verbose;
5135 $source_suffix_pattern = "(" . join('|', keys %suffix_rules) . ")";
5138 # FIXME: make sure both suffixes are in SUFFIXES? Or set
5139 # SUFFIXES from suffix_rules?
5141 elsif (($is_ok_macro = /$MACRO_PATTERN/o)
5142 || /$BOGUS_MACRO_PATTERN/o)
5144 # Found a macro definition.
5146 $last_var_name = $1;
5147 if (defined $contents{$1}
5148 && (@conditional_stack
5149 ? ! defined $conditional{$1}
5150 : defined $conditional{$1}))
5153 "$1 defined both conditionally and unconditionally");
5155 if ($2 ne '' && substr ($2, -1) eq "\\")
5157 $contents{$last_var_name} = substr ($2, 0, length ($2) - 1);
5161 $contents{$last_var_name} = $2;
5163 local ($cond_string) = join ('', @conditional_stack);
5164 if (@conditional_stack)
5166 if ($conditional{$last_var_name})
5168 &check_ambiguous_conditional ($last_var_name,
5170 $conditional{$last_var_name} .= ' ';
5174 $conditional{$last_var_name} = '';
5176 local ($val) = $contents{$last_var_name};
5177 $conditional{$last_var_name} .= ($cond_string
5179 . "e_cond_val ($val));
5181 $content_lines{$last_var_name} = $.;
5182 $am_vars .= $comment . $spacing . $cond_string . $_;
5183 $comment = $spacing = '';
5187 &am_line_error ($., "bad macro name \`$last_var_name'")
5192 # This isn't an error; it is probably a continued rule.
5193 # In fact, this is what we assume.
5195 $output_trailer .= ($comment . $spacing
5196 . join ('', @conditional_stack) . $_);
5197 $comment = $spacing = '';
5204 $output_trailer .= $comment;
5206 &am_error ("unterminated conditionals: " . join (' ', @conditional_stack))
5207 if (@conditional_stack);
5209 # Compute relative location of the top object directory.
5210 local (@topdir) = ();
5211 foreach (split (/\//, $relative_dir))
5213 next if $_ eq '.' || $_ eq '';
5220 push (@topdir, '..');
5223 @topdir = ('.') if ! @topdir;
5225 $top_builddir = join ('/', @topdir);
5227 ($build_rx = $top_builddir) =~ s/(\W)/\\$1/g;
5228 $output_vars .= &file_contents_with_transform
5229 ('s/\@top_builddir\@/' . $build_rx . '/g;',
5232 # Generate some useful variables when AC_CANONICAL_* used. FIXME:
5233 # this should use generic %configure_vars method.
5234 if ($seen_canonical)
5236 local ($curs, %vars);
5237 $vars{'host_alias'} = 'host_alias';
5238 $vars{'host_triplet'} = 'host';
5239 if ($seen_canonical == $AC_CANONICAL_SYSTEM)
5241 $vars{'build_alias'} = 'build_alias';
5242 $vars{'build_triplet'} = 'build';
5243 $vars{'target_alias'} = 'target_alias';
5244 $vars{'target_triplet'} = 'target';
5246 foreach $curs (sort keys %vars)
5248 $output_vars .= "$curs = \@$vars{$curs}\@\n";
5249 $contents{$curs} = "\@$vars{$curs}\@";
5254 foreach $curs (sort keys %configure_vars)
5256 &define_configure_variable ($curs);
5259 $output_vars .= $am_vars;
5262 ################################################################
5264 sub initialize_global_constants
5266 # Values for AC_CANONICAL_*
5267 $AC_CANONICAL_HOST = 1;
5268 $AC_CANONICAL_SYSTEM = 2;
5270 # Associative array of standard directory names. Entry is TRUE if
5271 # corresponding directory should be installed during
5272 # 'install-exec' phase.
5290 # Helper text for dealing with man pages.
5291 $install_man_format =
5292 ' @sect=@SECTION@; \\
5293 inst=`echo "@MANBASE@" | sed \'$(transform)\'`.@FULLSECT@; \\
5294 if test -f $(srcdir)/@MAN@; then file=$(srcdir)/@MAN@; \\
5295 else file=@MAN@; fi; \\
5296 echo " $(INSTALL_DATA) $$file $(mandir)/man$$sect/$$inst"; \\
5297 $(INSTALL_DATA) $$file $(mandir)/man$$sect/$$inst
5300 $uninstall_man_format =
5301 ' -inst=`echo "@MANBASE@" | sed \'$(transform)\'`.@FULLSECT@; \\
5302 rm -f $(mandir)/man@SECTION@/$$inst
5305 # Commonly found files we look for and automatically include in
5309 "README", "THANKS", "TODO", "NEWS", "COPYING", "COPYING.LIB",
5310 "INSTALL", "ABOUT-NLS", "ChangeLog", "configure", "configure.in",
5311 "config.guess", "config.sub", "AUTHORS", "BACKLOG", "ABOUT-GNU",
5312 "libversion.in", "mdate-sh", "mkinstalldirs", "install-sh",
5313 'texinfo.tex', "ansi2knr.c", "ansi2knr.1", 'elisp-comp',
5314 'ylwrap', 'acinclude.m4', @libtoolize_files,
5318 # Commonly used files we auto-include, but only sometimes.
5321 "aclocal.m4", "acconfig.h", "config.h.top",
5322 "config.h.bot", "stamp-h.in", 'stamp-vti'
5326 -a, --add-missing add missing standard files to package
5327 --amdir=DIR directory storing config files
5328 --build-dir=DIR directory where build being done (for dependencies)
5329 --cygnus assume program is part of Cygnus-style tree
5330 --foreign set strictness to foreign
5331 --gnits set strictness to gnits
5332 --gnu set strictness to gnu
5333 --help print this help, then exit
5334 -i, --include-deps include generated dependencies in Makefile.in
5335 --no-force only update Makefile.in's that are out of date
5336 -o DIR, --output-dir=DIR
5337 put generated Makefile.in's into DIR
5338 --srcdir-name=DIR name used for srcdir (for dependencies)
5339 -v, --verbose verbosely list files processed
5340 --version print version number, then exit\n";
5342 # Copyright on generated Makefile.ins.
5344 # Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
5345 # This Makefile.in is free software; the Free Software Foundation
5346 # gives unlimited permission to copy and/or distribute it,
5347 # with or without modifications, as long as this notice is preserved.
5349 # This program is distributed in the hope that it will be useful,
5350 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
5351 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
5352 # PARTICULAR PURPOSE.
5355 # Ignore return result from chmod, because it might give an error
5356 # if we chmod a symlink.
5357 $dist_header = "\t" . '-chmod -R a+r $(distdir)' . "\n";
5358 $dist{'dist-tarZ'} = ("\t"
5359 . '$(TAR) chf - $(distdir) | compress -c > $(distdir).tar.Z'
5361 $dist{'dist-shar'} = ("\t"
5362 . 'shar $(distdir) | gzip > $(distdir).shar.gz'
5364 $dist{'dist-zip'} = "\t" . 'zip -rq $(distdir).zip $(distdir)' . "\n";
5365 $dist{'dist'} = "\t" . 'GZIP=$(GZIP) $(TAR) chozf $(distdir).tar.gz $(distdir)' . "\n";
5366 $dist_trailer = "\t" . '-rm -rf $(distdir)' . "\n";
5369 # (Re)-Initialize per-Makefile.am variables.
5370 sub initialize_per_input
5372 # These two variables are used when generating each Makefile.in.
5373 # They hold the Makefile.in until it is ready to be printed.
5376 $output_trailer = '';
5377 $output_header = '';
5379 # Suffixes found during a run.
5382 # This holds the contents of a Makefile.am, as parsed by
5386 # This holds the names which are targets. These also appear in
5390 # For a variable or target which is defined conditionally, this
5391 # holds an array of the conditional values. The array is composed
5392 # of pairs of condition strings (the variables which configure
5393 # will substitute) and values (the value of a target is
5394 # meaningless). For an unconditional variable, this is empty.
5397 # This holds the line numbers at which various elements of
5398 # %contents are defined.
5399 %content_lines = ();
5401 # This holds a 1 if a particular variable was examined.
5404 # This is the conditional stack.
5405 @conditional_stack = ();
5407 # This holds the "relative directory" of the current Makefile.in.
5408 # Eg for src/Makefile.in, this is "src".
5411 # This holds a list of files that are included in the
5415 # List of dependencies for the obvious targets.
5431 # These are pretty obvious, too. They are used to define the
5432 # SOURCES and OBJECTS variables.
5436 # TRUE if current directory holds any C source files.
5437 $dir_holds_sources = 0;
5439 # These variables track inclusion of various compile-related .am
5440 # files. $included_generic_compile is TRUE if the basic code has
5441 # been included. $included_knr_compile is TRUE if the ansi2knr
5442 # code has been included. $included_libtool_compile is TRUE if
5443 # libtool support has been included.
5444 $included_generic_compile = 0;
5445 $included_knr_compile = 0;
5446 $included_libtool_compile = 0;
5448 # TRUE if current directory holds any headers.
5449 $dir_holds_headers = 0;
5451 # TRUE if install targets should work recursively.
5452 $recursive_install = 0;
5457 # Strictness levels.
5458 $strictness = $default_strictness;
5459 $strictness_name = $default_strictness_name;
5461 # Options from AUTOMAKE_OPTIONS.
5464 # Whether or not dependencies are handled. Can be further changed
5465 # in handle_options.
5466 $use_dependencies = $cmdline_use_dependencies;
5469 $local_maint_charset = $maint_charset;
5471 # All yacc and lex source filenames for this directory. Use
5472 # filenames instead of raw count so that multiple instances are
5473 # counted correctly (eg one yacc file can appear in multiple
5474 # programs without harm).
5478 # C++ source extensions we've seen.
5479 %cxx_extensions = ();
5481 # TRUE if we've seen any non-C++ sources. This actually holds a
5482 # line number or the name of a symbol corresponding to a line
5483 # number where the C sources were seen. If it is -1 then it means
5484 # we couldn't (easily) figure out which line of the Makefile.am
5485 # mentioned the sources.
5488 # TRUE if we've seen any sources at all.
5489 $seen_any_source = 0;
5491 # This is a list of all targets to run during "make dist".
5494 # Keys in this hash are the basenames of files which must depend
5496 %de_ansi_files = ();
5498 # This maps the source extension of a suffix rule to its
5499 # corresponding output extension.
5504 ################################################################
5506 # Return contents of a file from $am_dir, automatically skipping
5507 # macros or rules which are already known. Runs command on each line
5508 # as it is read; this command can modify $_.
5509 sub file_contents_with_transform
5511 local ($command, $basename) = @_;
5512 local ($file) = $am_dir . '/' . $basename . '.am';
5514 if ($command ne '' && substr ($command, -1) ne ';')
5516 die "automake: programming error in file_contents_with_transform\n";
5519 open (FC_FILE, $file)
5520 || die "automake: installation error: cannot open \`$file'\n";
5522 # print "automake: reading $file\n" if $verbose;
5524 local ($was_rule) = 0;
5525 local ($result_vars) = '';
5526 local ($result_rules) = '';
5527 local ($comment) = '';
5528 local ($spacing) = "\n";
5529 local ($skipping) = 0;
5534 $_ =~ s/\@MAINT\@//g
5535 unless $seen_maint_mode;
5537 $had_chars = length ($_) && $_ ne "\n";
5539 # If the transform caused all the characters to go away, then
5540 # ignore the line. Why do this? Because in Perl 4, a "next"
5541 # inside of an eval doesn't affect a loop outside the eval.
5542 # So we can't pass in a "transform" that uses next. We used
5543 # to do this. "Empty" also means consisting of a single
5545 next if $had_chars && ($_ eq '' || $_ eq "\n");
5547 if (/$IGNORE_PATTERN/o)
5549 # Merely delete comments beginning with two hashes.
5551 elsif (/$WHITE_PATTERN/o)
5553 # Stick a single white line before the incoming macro or rule.
5556 elsif (/$COMMENT_PATTERN/o)
5558 # Stick comments before the incoming macro or rule.
5559 $comment .= $spacing . $_;
5566 $result_rules .= $_ if ! $skipping;
5570 $result_vars .= $_ if ! $skipping;
5574 elsif (/$RULE_PATTERN/o)
5578 $skipping = defined $contents{$1};
5579 $result_rules .= $comment . $spacing . $_ if ! $skipping;
5580 $comment = $spacing = '';
5583 elsif (/$MACRO_PATTERN/o)
5585 # Found a variable reference.
5587 $skipping = defined $contents{$1};
5588 $result_vars .= $comment . $spacing . $_ if ! $skipping;
5589 $comment = $spacing = '';
5594 # This isn't an error; it is probably a continued rule.
5595 # In fact, this is what we assume.
5597 $result_rules .= $comment . $spacing . $_ if ! $skipping;
5598 $comment = $spacing = '';
5604 return $result_vars . $result_rules . $comment;
5607 # Like file_contents_with_transform, but no transform.
5610 return &file_contents_with_transform ('', @_);
5613 # Find all variable prefixes that are used for install directories. A
5614 # prefix `zar' qualifies iff:
5615 # * `zardir' is a variable.
5616 # * `zar_PRIMARY' is a variable.
5617 sub am_primary_prefixes
5619 local ($primary, @prefixes) = @_;
5621 local (%valid, $varname);
5622 grep ($valid{$_} = 0, @prefixes);
5623 $valid{'EXTRA'} = 0;
5624 foreach $varname (keys %contents)
5626 if ($varname =~ /^(.*)_$primary$/)
5628 if (! defined $valid{$1}
5629 && ! &variable_defined ($1 . 'dir')
5630 # Note that a configure variable is always legitimate.
5631 # It is natural to name such variables after the
5632 # primary, so we explicitly allow it.
5633 && ! defined $configure_vars{$varname})
5635 &am_line_error ($varname, "invalid variable \`$varname'");
5639 # Ensure all extended prefixes are actually used.
5648 # Handle `where_HOW' variable magic. Does all lookups, generates
5649 # install code, and possibly generates code to define the primary
5650 # variable. The first argument is the name of the .am file to munge,
5651 # the second argument is the primary variable (eg HEADERS), and all
5652 # subsequent arguments are possible installation locations. Returns
5653 # list of all values of all _HOW targets.
5655 # FIXME: this should be rewritten to be cleaner. It should be broken
5656 # up into multiple functions.
5658 # Usage is: am_install_var (OPTION..., file, HOW, where...)
5663 local ($do_clean) = 0;
5666 if (defined $configure_vars{'LIBTOOL'})
5668 # Transform '@LIBTOOL ...@' to '$(LIBTOOL) ...'
5669 $ltxform = 's/\@LIBTOOL([^\@]*)\@/\$(LIBTOOL) $1/;';
5673 # Delete '@LIBTOOL ...@'
5674 $ltxform = 's/\@LIBTOOL([^\@]*)\@//;';
5680 $cygxform = 's/\@EXEEXT\@//g;';
5684 $cygxform = 's/\@EXEEXT\@/\$(EXEEXT)/g;';
5689 if ($args[0] eq '-clean')
5693 elsif ($args[0] !~ /^-/)
5699 local ($file, $primary, @prefixes) = @args;
5702 local (@result) = ();
5704 # Now that configure substitutions are allowed in where_HOW
5705 # variables, it is an error to actually define the primary.
5706 &am_line_error ($primary, "\`$primary' is an anachronism")
5707 if &variable_defined ($primary);
5710 # Look for misspellings. It is an error to have a variable ending
5711 # in a "reserved" suffix whose prefix is unknown, eg
5712 # "bni_PROGRAMS". However, unusual prefixes are allowed if a
5713 # variable of the same name (with "dir" appended) exists. For
5714 # instance, if the variable "zardir" is defined, then
5715 # "zar_PROGRAMS" becomes valid. This is to provide a little extra
5716 # flexibility in those cases which need it. Perhaps it should be
5717 # disallowed in the Gnits case? The problem is, sometimes it is
5718 # useful to put things in a subdir of eg pkgdatadir, perhaps even
5720 local (%valid) = &am_primary_prefixes ($primary, @prefixes);
5722 # If a primary includes a configure substitution, then the EXTRA_
5723 # form is required. Otherwise we can't properly do our job.
5724 local ($require_extra);
5725 local ($warned_about_extra) = 0;
5727 local ($clean_file) = $file . '-clean';
5730 foreach $X (sort keys %valid)
5732 $one_name = $X . '_' . $primary;
5733 if (&variable_defined ($one_name))
5735 # Append actual contents of where_PRIMARY variable to
5738 foreach $rcurs (&variable_value_as_list ($one_name, 'all'))
5740 # Skip configure substitutions. Possibly bogus.
5741 if ($rcurs =~ /^\@.*\@$/)
5745 if (! $warned_about_extra)
5747 $warned_about_extra = 1;
5748 &am_line_error ($one_name,
5749 "\`$one_name' contains configure substitution, but shouldn't");
5752 # Check here to make sure variables defined in
5753 # configure.in do not imply that EXTRA_PRIMARY
5755 elsif (! defined $configure_vars{$one_name})
5757 $require_extra = $one_name;
5763 push (@result, $rcurs);
5766 # "EXTRA" shouldn't be used when generating clean targets,
5767 # all, or install targets.
5768 next if $X eq 'EXTRA';
5770 # A blatant hack: we rewrite each _PROGRAMS primary to
5771 # include EXEEXT when in Cygwin32 mode.
5772 if ($seen_exeext && $primary eq 'PROGRAMS')
5774 local (@conds) = &variable_conditions ($one_name);
5775 local (@one_binlist);
5777 # FIXME: this definitely loses aesthetically; it
5778 # redefines $ONE_NAME. Instead we should arrange for
5779 # variable definitions to be output later, instead of
5785 foreach $rcurs (&variable_value_as_list ($one_name, ''))
5787 if ($rcurs =~ /\./ || $rcurs =~ /^\@.*\@$/)
5789 push (@one_binlist, $rcurs);
5793 push (@one_binlist, $rcurs . '$(EXEEXT)');
5797 delete $contents{$one_name};
5798 &define_pretty_variable ($one_name, '', @one_binlist);
5803 local ($condvals) = '';
5804 foreach $cond (@conds)
5807 local (@condval) = &variable_value_as_list ($one_name,
5809 foreach $rcurs (@condval)
5811 if ($rcurs =~ /\./ || $rcurs =~ /^\@.*\@$/)
5813 push (@one_binlist, $rcurs);
5817 push (@one_binlist, $rcurs . '$(EXEEXT)');
5821 push (@condvals, $cond);
5822 push (@condvals, join (' ', @one_binlist));
5825 delete $contents{$one_name};
5829 $cond = shift (@condvals);
5830 local (@val) = split (' ', shift (@condvals));
5831 &define_pretty_variable ($one_name, $cond, @val);
5839 &file_contents_with_transform ('s/\@DIR\@/' . $X . '/go;'
5843 push (@clean, $X . $primary);
5844 &push_phony_cleaners ($X . $primary);
5849 push (@check, '$(' . $one_name . ')');
5853 push (@used, '$(' . $one_name . ')');
5855 if ($X eq 'noinst' || $X eq 'check')
5857 # Objects which don't get installed by default.
5862 &file_contents_with_transform ('s/\@DIR\@/' . $X . '/g;'
5863 . $ltxform . $cygxform,
5866 push (@uninstall, 'uninstall-' . $X . $primary);
5867 push (@phony, 'uninstall-' . $X . $primary);
5868 push (@installdirs, '$(' . $X . 'dir)');
5869 if (defined $exec_dir_p{$X} ? $exec_dir_p{$X} : ($X =~ /exec/))
5871 push (@install_exec, 'install-' . $X . $primary);
5872 push (@phony, 'install-' . $X . $primary);
5876 push (@install_data, 'install-' . $X . $primary);
5877 push (@phony, 'install-' . $X . $primary);
5885 &define_pretty_variable ($primary, '', @used);
5886 $output_vars .= "\n";
5889 if ($require_extra && ! &variable_defined ('EXTRA_' . $primary))
5891 &am_line_error ($require_extra,
5892 "\`$require_extra' contains configure substitution, but \`EXTRA_$primary' not defined");
5895 # Push here because PRIMARY might be configure time determined.
5896 push (@all, '$(' . $primary . ')')
5903 ################################################################
5905 # This variable is local to the "require file" set of functions.
5906 @require_file_paths = ();
5908 # Verify that the file must exist in the current directory. Usage:
5909 # require_file (isconfigure, line_number, strictness, file) strictness
5910 # is the strictness level at which this file becomes required. Must
5911 # set require_file_paths before calling this function.
5912 # require_file_paths is set to hold a single directory (the one in
5913 # which the first file was found) before return.
5914 sub require_file_internal
5916 local ($is_configure, $line, $mystrict, @files) = @_;
5917 local ($file, $fullfile);
5918 local ($found_it, $errfile, $errdir);
5921 foreach $file (@files)
5924 foreach $dir (@require_file_paths)
5928 $fullfile = $relative_dir . "/" . $file;
5929 $errdir = $relative_dir unless $errdir;
5933 $fullfile = $dir . "/" . $file;
5934 $errdir = $dir unless $errdir;
5937 # Use different name for "error filename". Otherwise on
5938 # an error the bad file will be reported as eg
5939 # `../../install-sh' when using the default
5941 $errfile = $errdir . '/' . $file;
5946 # FIXME: Once again, special-case `.'.
5947 &push_dist_common ($file)
5948 if $dir eq $relative_dir || $dir eq '.';
5956 # Prune the path list.
5957 @require_file_paths = $save_dir;
5961 if ($strictness >= $mystrict)
5963 local ($trailer) = '';
5964 local ($suppress) = 0;
5966 # Only install missing files according to our desired
5968 local ($message) = "required file \`$errfile' not found";
5973 # Maybe run libtoolize.
5975 && grep ($_ eq $file, @libtoolize_files)
5976 && system ('libtoolize', '--automake'))
5978 $message = "installing \`$errfile'";
5980 $trailer = "; cannot run \`libtoolize': $!";
5982 elsif (-f ($am_dir . '/' . $file))
5984 # Install the missing file. Symlink if we
5985 # can, copy if we must. Note: delete the file
5986 # first, in case it is a dangling symlink.
5987 $message = "installing \`$errfile'";
5989 if ($symlink_exists)
5991 if (! symlink ($am_dir . '/' . $file, $errfile))
5994 $trailer = "; error while making link: $!\n";
5997 elsif (! system ('cp', $am_dir . '/' . $file, $errfile))
6000 $trailer = "\n error while making link\n";
6005 local ($save) = $exit_status;
6008 # FIXME: allow actual file to be specified.
6009 &am_conf_line_error ('configure.in', $line,
6010 "$message$trailer");
6014 &am_line_error ($line, "$message$trailer");
6016 $exit_status = $save if $suppress;
6022 # Like require_file_with_line, but error messages refer to
6023 # configure.in, not the current Makefile.am.
6024 sub require_file_with_conf_line
6026 @require_file_paths = '.';
6027 &require_file_internal (1, @_);
6030 sub require_file_with_line
6032 @require_file_paths = '.';
6033 &require_file_internal (0, @_);
6038 @require_file_paths = '.';
6039 &require_file_internal (0, '', @_);
6042 # Require a file that is also required by Autoconf. Looks in
6043 # configuration path, as specified by AC_CONFIG_AUX_DIR.
6044 sub require_config_file
6046 @require_file_paths = @config_aux_path;
6047 &require_file_internal (1, '', @_);
6048 local ($dir) = $require_file_paths[0];
6049 @config_aux_path = @require_file_paths;
6052 $config_aux_dir = '.';
6056 $config_aux_dir = '$(top_srcdir)/' . $dir;
6060 # Assumes that the line number is in Makefile.am.
6061 sub require_conf_file_with_line
6063 @require_file_paths = @config_aux_path;
6064 &require_file_internal (0, @_);
6065 local ($dir) = $require_file_paths[0];
6066 @config_aux_path = @require_file_paths;
6069 $config_aux_dir = '.';
6073 $config_aux_dir = '$(top_srcdir)/' . $dir;
6077 # Assumes that the line number is in Makefile.am.
6078 sub require_conf_file_with_conf_line
6080 @require_file_paths = @config_aux_path;
6081 &require_file_internal (1, @_);
6082 local ($dir) = $require_file_paths[0];
6083 @config_aux_path = @require_file_paths;
6086 $config_aux_dir = '.';
6090 $config_aux_dir = '$(top_srcdir)/' . $dir;
6094 ################################################################
6096 # Push a list of files onto dist_common.
6097 sub push_dist_common
6099 local (@files) = @_;
6102 foreach $file (@files)
6104 $dist_common{$file} = 1;
6108 # Push a list of clean targets onto phony.
6109 sub push_phony_cleaners
6113 foreach $target ('mostly', 'dist', '', 'maintainer-')
6115 push (@phony, $target . 'clean-' . $base);
6122 $strictness_name = $_[0];
6123 if ($strictness_name eq 'gnu')
6127 elsif ($strictness_name eq 'gnits')
6129 $strictness = $GNITS;
6131 elsif ($strictness_name eq 'foreign')
6133 $strictness = $FOREIGN;
6137 die "automake: level \`$strictness_name' not recognized\n";
6142 ################################################################
6144 # Return directory name of file.
6150 ($sub = $file) =~ s,/+[^/]+$,,g;
6151 $sub = '.' if $sub eq $file;
6155 # Return file name of a file.
6161 ($sub = $file) =~s,^.*/+,,g;
6170 open (TOUCH, ">> $file");
6174 # Glob something. Do this to avoid indentation screwups everywhere we
6175 # want to glob. Gross!
6182 ################################################################
6184 # Print an error message and set exit status.
6187 warn "automake: ${am_file}.am: ", join (' ', @_), "\n";
6193 local ($symbol, @args) = @_;
6195 if ($symbol && "$symbol" ne '-1')
6197 # If SYMBOL not already a line number, look it up in Makefile.am.
6198 if ($symbol =~ /^\d+$/)
6202 elsif (defined $content_lines{$symbol})
6204 $symbol = $content_lines{$symbol} . ': ';
6208 # A single space, to provide nice separation.
6211 warn "${am_file}.am:", $symbol, join (' ', @args), "\n";
6220 # Like am_error, but while scanning configure.in.
6223 # FIXME: can run in subdirs.
6224 warn "automake: configure.in: ", join (' ', @_), "\n";
6228 # Error message with line number referring to configure.in.
6229 sub am_conf_line_error
6231 local ($file, $line, @args) = @_;
6235 warn "$file: $line: ", join (' ', @args), "\n";
6240 &am_conf_error (@args);
6244 # Tell user where our aclocal.m4 is, but only once.
6245 sub keyed_aclocal_warning
6248 warn "automake: macro \`$key' can be generated by \`aclocal'\n";
6251 # Print usage information.
6254 print "Usage: automake [OPTION] ... [Makefile]...\n\n";
6255 print "Generate Makefile.in for autoconf from Makefile.am\n";
6257 print "\nFiles which are automatically distributed, if found:\n";
6258 $~ = "USAGE_FORMAT";
6259 local (@lcomm) = sort ((@common_files, @common_sometimes));
6260 local ($one, $two, $three, $four);
6263 $one = shift @lcomm;
6264 $two = @lcomm ? shift @lcomm : '';
6265 $three = @lcomm ? shift @lcomm : '';
6266 $four = @lcomm ? shift @lcomm : '';
6270 print "\nReport bugs to <automake-bugs\@gnu.ai.mit.edu>.\n";
6275 format USAGE_FORMAT =
6276 @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<
6277 $one, $two, $three, $four