5 eval 'exec @PERL@ -S $0 ${1+"$@"}'
8 # automake - create Makefile.in from Makefile.am
9 # Copyright (C) 1994, 1995, 1996, 1997 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 $MACRO_PATTERN = "^([A-Za-z][A-Za-z0-9_]*)[ \t]*:?=[ \t]*(.*)\$";
44 $BOGUS_MACRO_PATTERN = "^([^ \t]*)[ \t]*:?=[ \t]*(.*)\$";
45 $GNITS_VERSION_PATTERN = "[0-9]+\\.[0-9]+([a-z]|\\.[0-9]+)?";
46 $IF_PATTERN = "^if[ \t]+\([A-Za-z][A-Za-z0-9_]*\)[ \t]*\(#.*\)?\$";
47 $ELSE_PATTERN = "^else[ \t]*\(#.*\)?\$";
48 $ENDIF_PATTERN = "^endif[ \t]*\(#.*\)?\$";
50 # Some regular expressions. One reason to put them here is that it
51 # makes indentation work better in Emacs.
52 $AC_CONFIG_AUX_DIR_PATTERN = "AC_CONFIG_AUX_DIR\\(([^)]+)\\)";
53 $AM_INIT_AUTOMAKE_PATTERN = "AM_INIT_AUTOMAKE\\([^,]*,([^,)]+)[,)]";
54 $AM_PACKAGE_VERSION_PATTERN = "^\\s*\\[?([^]\\s]+)\\]?\\s*\$";
55 # Note that there is no AC_PATH_TOOL. But we don't really care.
56 $AC_CHECK_PATTERN = "AC_(CHECK|PATH)_(PROG|PROGS|TOOL)\\(\\[?(\\w+)";
57 $AM_MISSING_PATTERN = "AM_MISSING_PROG\\(\\[?(\\w+)";
58 # Just check for alphanumeric in AC_SUBST. If you do AC_SUBST(5),
60 $AC_SUBST_PATTERN = "AC_SUBST\\(\\[?(\\w+)";
61 $AM_CONDITIONAL_PATTERN = "AM_CONDITIONAL\\((\\w+)";
63 # Constants to define the "strictness" level.
70 # Variables global to entire run.
72 # TRUE if we should always generate Makefile.in.
73 $force_generation = 1;
75 # Strictness level as set on command line.
76 $default_strictness = $GNU;
78 # Name of strictness level, as set on command line.
79 $default_strictness_name = 'gnu';
81 # This is TRUE if GNU make specific automatic dependency generation
82 # code should be included in generated Makefile.in.
83 $cmdline_use_dependencies = 1;
85 # TRUE if in verbose mode.
88 # This holds our (eventual) exit status. We don't actually exit until
89 # we have processed all input files.
92 # From the Perl manual.
93 $symlink_exists = (eval 'symlink ("", "");', $@ eq '');
95 # TRUE if missing standard files should be installed.
98 # Files found by scanning configure.in for LIBOBJS.
101 # True if AM_C_PROTOTYPES appears in configure.in.
102 $am_c_prototypes = 0;
104 # Names used in AC_CONFIG_HEADER call. @config_fullnames holds the
105 # name which appears in AC_CONFIG_HEADER, colon and all.
106 # @config_names holds the file names. @config_headers holds the '.in'
107 # files. Ordinarily these are similar, but they can be different if
108 # the weird "NAME:FILE" syntax is used.
109 @config_fullnames = ();
111 @config_headers = ();
112 # Line number at which AC_CONFIG_HEADER appears in configure.in.
113 $config_header_line = 0;
115 # Directory where output files go. Actually, output files are
116 # relative to this directory.
117 $output_directory = '.';
119 # Relative location of top build directory.
122 # Absolute location of top build directory.
123 $build_directory = '';
125 # Name of srcdir as given in build directory's Makefile. For
129 # List of Makefile.am's to process, and their corresponding outputs.
133 # List of files in AC_OUTPUT without Makefile.am, and their outputs.
134 @other_input_files = ();
135 # Line number at which AC_OUTPUT seen.
138 # List of directories to search for configure-required files. This
139 # can be set by AC_CONFIG_AUX_DIR.
140 @config_aux_path = ('.', '..', '../..');
141 $config_aux_dir = '';
143 # Whether AC_PROG_MAKE_SET has been seen in configure.in.
146 # Whether AM_GNU_GETTEXT has been seen in configure.in.
148 # Line number at which AM_GNU_GETTEXT seen.
149 $ac_gettext_line = 0;
151 # Whether ALL_LINGUAS has been seen.
155 # Line number at which it appears.
156 $all_linguas_line = 0;
158 # 1 if AC_PROG_INSTALL seen, 2 if AM_PROG_INSTALL seen.
159 $seen_prog_install = 0;
161 # 1 if any scripts installed, 0 otherwise.
162 $scripts_installed = 0;
164 # Whether AC_PATH_XTRA has been seen in configure.in.
167 # TRUE if AC_DECL_YYTEXT was seen.
168 $seen_decl_yytext = 0;
170 # TRUE if we've seen AC_CANONICAL_(HOST|SYSTEM). The presence of
171 # AC_CHECK_TOOL also sets this.
174 # TRUE if we've seen AC_ARG_PROGRAM.
177 # TRUE if we've seen AM_PROG_LIBTOOL.
181 # Files installed by libtoolize.
182 @libtoolize_files = ('ltconfig', 'ltmain.sh', 'config.guess', 'config.sub');
184 # TRUE if we've seen AM_MAINTAINER_MODE.
185 $seen_maint_mode = 0;
187 # TRUE if we've seen PACKAGE and VERSION.
191 # Actual version we've seen.
192 $package_version = '';
194 # Line number where we saw version definition.
195 $package_version_line = 0;
197 # TRUE if we've seen AM_PATH_LISPDIR.
200 # TRUE if we've seen AM_EXEEXT.
203 # Hash table of discovered configure substitutions. Keys are names,
204 # values are meaningless.
205 %configure_vars = ();
207 # Charsets used by maintainer and in distribution. MAINT_CHARSET is
208 # handled in a funny way: if seen in the top-level Makefile.am, it is
209 # used for every directory which does not specify a different value.
210 # The rationale here is that some directories (eg gettext) might be
211 # distributions of other packages, and thus require their own charset
212 # info. However, the DIST_CHARSET must be the same for the entire
213 # package; it can only be set at top-level.
214 # FIXME: this yields bugs when rebuilding. What to do? Always
215 # read (and sometimes discard) top-level Makefile.am?
217 $dist_charset = 'utf8'; # recode doesn't support this yet.
219 # Name of input file ("Makefile.in") and output file ("Makefile.am").
220 # These have no directory components.
224 # TRUE if --cygnus seen.
227 # Keys of this hash are names of dependency files to ignore.
228 %omit_dependencies = ();
230 # Hash table of AM_CONDITIONAL variables seen in configure.
231 %configure_cond = ();
233 # Map from obsolete macros to hints for new macros.
234 # FIXME complete the list so that there are no `0' hints.
237 'AC_FEATURE_CTYPE', "use \`AC_HEADER_STDC'",
238 'AC_FEATURE_ERRNO', "add \`strerror' to \`AC_REPLACE_FUNCS(...)'",
239 'AC_FEATURE_EXIT', 0,
240 'AC_SYSTEM_HEADER', 0,
242 # Note that we do not handle this one, because it is still run
243 # from AM_CONFIG_HEADER. So we deal with it specially in
245 # 'AC_CONFIG_HEADER', "use \`AM_CONFIG_HEADER'",
247 'fp_C_PROTOTYPES', "use \`AM_C_PROTOTYPES'",
248 'fp_PROG_CC_STDC', "use \`AM_PROG_CC_STDC'",
249 'fp_PROG_INSTALL', "use \`AM_PROG_INSTALL'",
250 'fp_WITH_DMALLOC', "use \`AM_WITH_DMALLOC'",
251 'fp_WITH_REGEX', "use \`AM_WITH_REGEX'",
252 'gm_PROG_LIBTOOL', "use \`AM_PROG_LIBTOOL'",
253 'jm_MAINTAINER_MODE', "use \`AM_MAINTAINER_MODE'",
254 'md_TYPE_PTRDIFF_T', "use \`AM_TYPE_PTRDIFF_T'",
255 'ud_PATH_LISPDIR', "use \`AM_PATH_LISPDIR'",
257 # Now part of autoconf proper, under a different name.
258 'AM_FUNC_FNMATCH', "use \`AC_FUNC_FNMATCH'",
259 'fp_FUNC_FNMATCH', "use \`AC_FUNC_FNMATCH'",
260 'AM_SANITY_CHECK_CC', "automatically done by \`AC_PROG_CC'",
262 # These aren't quite obsolete.
266 # Regexp to match the above macros.
267 $obsolete_rx = '(' . join ('|', keys %obsolete_macros) . ')';
271 &initialize_global_constants;
273 # Parse command line.
274 &parse_arguments (@ARGV);
276 # Do configure.in scan only once.
279 die "automake: no \`Makefile.am' found or specified\n"
282 # Now do all the work on each file.
283 foreach $am_file (@input_files)
285 if (! -f ($am_file . '.am'))
287 &am_error ("\`" . $am_file . ".am' does not exist");
291 &generate_makefile ($output_files{$am_file}, $am_file);
295 if ($seen_prog_install <= $scripts_installed)
297 &am_conf_error (($scripts_installed ? 'AM_PROG_INSTALL' : 'AC_PROG_INSTALL')
298 . " must be used in configure.in");
299 &keyed_aclocal_warning ('AM_PROG_INSTALL')
300 if $scripts_installed;
306 ################################################################
308 # Parse command line.
311 local (@arglist) = @_;
314 &set_strictness ('gnu');
318 if ($arglist[0] eq "--version")
320 print "automake (GNU $PACKAGE) $VERSION\n\n";
321 print "Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.\n";
322 print "This is free software; see the source for copying conditions. There is NO\n";
323 print "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n";
324 print "Written by Tom Tromey <tromey\@cygnus.com>\n";
328 elsif ($arglist[0] eq "--help")
332 elsif ($arglist[0] =~ /^--amdir=(.+)$/)
336 elsif ($arglist[0] eq '--amdir')
338 &require_argument (@arglist);
340 $am_dir = $arglist[0];
342 elsif ($arglist[0] =~ /^--build-dir=(.+)$/)
345 $build_directory = $1 . '/';
347 elsif ($arglist[0] eq '--build-dir')
349 &require_argument (@arglist);
352 $build_directory = $arglist[0] . '/';
354 elsif ($arglist[0] =~ /^--srcdir-name=(.+)$/)
358 elsif ($arglist[0] eq '--srcdir-name')
360 &require_argument (@arglist);
362 $srcdir_name = $arglist[0];
364 elsif ($arglist[0] eq '--gnu')
366 &set_strictness ('gnu');
368 elsif ($arglist[0] eq '--gnits')
370 &set_strictness ('gnits');
372 elsif ($arglist[0] eq '--cygnus')
376 elsif ($arglist[0] eq '--foreign')
378 &set_strictness ('foreign');
380 elsif ($arglist[0] eq '--include-deps' || $arglist[0] eq '-i')
382 $cmdline_use_dependencies = 0;
384 elsif ($arglist[0] eq '--no-force')
386 $force_generation = 0;
388 elsif ($arglist[0] =~ /^--output-dir=(.*)$/)
390 # Set output directory.
391 $output_directory = $1;
393 elsif ($arglist[0] eq '--output-dir' || $arglist[0] eq '-o')
395 &require_argument (@arglist);
397 $output_directory = $arglist[0];
399 elsif ($arglist[0] eq '--add-missing' || $arglist[0] eq '-a')
403 elsif ($arglist[0] eq '--verbose' || $arglist[0] eq '-v')
407 elsif ($arglist[0] eq '--')
409 # Stop option processing.
411 push (@input_files, @arglist);
414 elsif ($arglist[0] =~ /^-/)
416 die "automake: unrecognized option -- \`$arglist[0]'\nTry \`automake --help' for more information.\n";
420 # Handle $local:$input syntax. Note that we only examine
421 # the first ":" file to see if it is automake input; the
422 # rest are just taken verbatim. We still keep all the
423 # files around for dependency checking, however.
424 local ($local, $input, @rest) = split (/:/, $arglist[0]);
431 # Strip .in; later on .am is tacked on. That is how
432 # the automake input file is found. Maybe not the
433 # best way, but it is easy to explain. FIXME: should
434 # be error if .in is missing.
437 push (@input_files, $input);
438 $output_files{$input} = join (':', ($local, @rest));
444 # Take global strictness from whatever we currently have set.
445 $default_strictness = $strictness;
446 $default_strictness_name = $strictness_name;
449 # Ensure argument exists, or die.
452 local ($arg, @arglist) = @_;
453 die "automake: no argument given for option \`$arg'\n"
457 ################################################################
459 # Generate a Makefile.in given the name of the corresponding Makefile and
460 # the name of the file output by config.status.
461 sub generate_makefile
463 local ($output, $makefile) = @_;
465 ($am_file_name = $makefile) =~ s/^.*\///;
466 $in_file_name = $am_file_name . '.in';
467 $am_file_name .= '.am';
469 # $OUTPUT is encoded. If it contains a ":" then the first element
470 # is the real output file, and all remaining elements are input
471 # files. We don't scan or otherwise deal with these input file,
472 # other than to mark them as dependencies. See scan_configure for
474 local (@secondary_inputs);
475 ($output, @secondary_inputs) = split (/:/, $output);
477 &initialize_per_input;
478 $relative_dir = &dirname ($output);
479 $am_relative_dir = &dirname ($makefile);
481 # At the toplevel directory, we might need config.guess, config.sub
482 # or libtool scripts (ltconfig and ltmain.sh).
483 if ($relative_dir eq '.')
485 # libtool requires some files.
486 &require_conf_file_with_conf_line ($libtool_line, $FOREIGN,
490 # AC_CANONICAL_HOST and AC_CANONICAL_SYSTEM need config.guess and
492 &require_config_file ($FOREIGN, 'config.guess', 'config.sub')
496 # We still need Makefile.in here, because sometimes the `dist'
497 # target doesn't re-run automake.
498 if ($am_relative_dir eq $relative_dir)
500 # Only distribute the files if they are in the same subdir as
501 # the generated makefile.
502 &push_dist_common ($in_file_name, $am_file_name);
504 push (@sources, '$(SOURCES)')
505 if &variable_defined ('SOURCES');
506 push (@objects, '$(OBJECTS)')
507 if &variable_defined ('OBJECTS');
509 # This is always the default target. This gives us freedom to do
510 # things in whatever order is convenient. Note that we set up
511 # $output_header here so that we can insert some text just after
512 # the "default" target, but before any other targets. In
513 # particular we want to support the .SUFFIX hack here; this is
514 # documented elsewhere.
515 $output_header = "default: all\n\n";
516 push (@phony, 'default');
518 &read_am_file ($makefile . '.am');
521 # Fatal error. Just return, so we can continue with next file.
525 # Check first, because we might modify some state.
527 &check_gnu_standards;
528 &check_gnits_standards;
530 &handle_configure ($output, $makefile, @secondary_inputs);
537 &handle_built_sources;
539 # This must be run after all the sources are scanned.
540 &handle_yacc_lex_cxx;
542 # Re-init SOURCES and OBJECTS. FIXME: other code shouldn't depend
543 # on this (but currently does).
544 $contents{'SOURCES'} = join (' ', @sources);
545 $contents{'OBJECTS'} = join (' ', @objects);
554 &handle_dist ($makefile);
555 &handle_dependencies;
558 &handle_merge_targets ($makefile);
565 if (! -d ($output_directory . '/' . $am_relative_dir))
567 mkdir ($output_directory . '/' . $am_relative_dir, 0755);
570 local ($out_file) = $output_directory . '/' . $makefile . ".in";
571 if (! $force_generation && -e $out_file)
573 local ($am_time) = (stat ($makefile . '.am'))[9];
574 local ($in_time) = (stat ($out_file))[9];
575 # FIXME: should cache these times.
576 local ($conf_time) = (stat ('configure.in'))[9];
577 # FIXME: how to do unsigned comparison?
578 if ($am_time < $in_time || $am_time < $conf_time)
585 local ($acl_time) = (stat _)[9];
586 return if ($am_time < $acl_time);
590 if (! open (GM_FILE, "> " . $out_file))
592 warn "automake: ${am_file}.in: cannot write: $!\n";
596 print "automake: creating ", $makefile, ".in\n" if $verbose;
598 print GM_FILE $output_vars;
599 print GM_FILE $output_header;
600 print GM_FILE $output_rules;
601 print GM_FILE $output_trailer;
606 ################################################################
608 # Handle AUTOMAKE_OPTIONS variable. Return 1 on error, 0 otherwise.
611 return 0 if ! &variable_defined ('AUTOMAKE_OPTIONS');
613 foreach (&variable_value_as_list ('AUTOMAKE_OPTIONS', ''))
616 if ($_ eq 'gnits' || $_ eq 'gnu' || $_ eq 'foreign')
618 &set_strictness ($_);
622 # An option like "../lib/ansi2knr" is allowed. With no
623 # path prefix, we assume the required programs are in this
624 # directory. We save the actual option for later.
625 $options{'ansi2knr'} = $_;
627 elsif ($_ eq 'no-installman' || $_ eq 'no-installinfo'
628 || $_ eq 'dist-shar' || $_ eq 'dist-zip'
629 || $_ eq 'dist-tarZ' || $_ eq 'dejagnu'
630 || $_ eq 'no-texinfo.tex')
632 # Explicitly recognize these.
634 elsif ($_ eq 'no-dependencies')
636 $use_dependencies = 0;
638 elsif (/([0-9]+)\.([0-9]+)/)
640 # Got a version number. Note that alpha releases count as
641 # the next higher release. Note also that we assume there
642 # will be a maximum of 100 minor releases for any given
644 local ($rmajor, $rminor) = ($1, $2);
645 if ($VERSION !~ /([0-9]+)\.([0-9]+)([a-z])?/)
648 "automake: programming error: version is incorrect\n";
651 local ($tmajor, $tminor) = ($1, $2);
652 # Handle alpha versions.
653 ++$tminor if defined $3;
655 if ($rmajor > $tmajor || ($rmajor == $tmajor && $rminor > $tminor))
657 &am_line_error ('AUTOMAKE_OPTIONS',
658 "require version $_, only have $VERSION");
664 &am_line_error ('AUTOMAKE_OPTIONS',
665 'option ', $_, 'not recognized');
672 # Return object extension. Just once, put some code into the output.
673 # Argument is the name of the output file
674 sub get_object_extension
679 $dir_holds_sources = 1;
681 # Maybe require libtool library object files.
682 local ($extension) = '.o';
683 $extension = '.lo' if ($out =~ /\.la$/);
685 if (! $included_generic_compile)
689 if (&variable_defined ('CONFIG_HEADER'))
692 foreach $one_hdr (split (' ', &variable_value ('CONFIG_HEADER')))
695 ($var = &dirname ($one_hdr)) =~ s/(\W)/\\$1/g;
696 $xform .= ' ' if $xform;
697 $xform .= '-I' . $var;
700 $xform = 's/\@CONFIG_INCLUDE_SPEC\@/' . $xform . '/go;';
701 $output_vars .= &file_contents_with_transform ($xform,
703 $output_rules .= &file_contents ('compile');
704 &push_phony_cleaners ('compile');
706 # If using X, include some extra variable definitions. NOTE
707 # we don't want to force these into CFLAGS or anything,
708 # because not all programs will necessarily use X.
712 foreach $var ('X_CFLAGS', 'X_LIBS', 'X_EXTRA_LIBS', 'X_PRE_LIBS')
714 &define_configure_variable ($var);
718 push (@suffixes, '.c', '.o');
719 push (@clean, 'compile');
721 $included_generic_compile = 1;
724 if ($seen_libtool && ! $included_libtool_compile)
726 # Output the libtool compilation rules.
727 $output_rules .= &file_contents ('libtool');
728 &push_phony_cleaners ('libtool');
730 push (@suffixes, '.lo');
731 push (@clean, 'libtool');
733 $included_libtool_compile = 1;
736 # Check for automatic de-ANSI-fication.
737 if (defined $options{'ansi2knr'})
739 $extension = '$U' . $extension;
740 if (! $included_knr_compile)
742 if (! $am_c_prototypes)
744 &am_line_error ('AUTOMAKE_OPTIONS',
745 "option \`ansi2knr' in use but \`AM_C_PROTOTYPES' not in configure.in");
746 &keyed_aclocal_warning ('AM_C_PROTOTYPES');
747 # Only give this error once.
748 $am_c_prototypes = 1;
751 # Only require ansi2knr files if they should appear in
753 if ($options{'ansi2knr'} eq 'ansi2knr')
755 &require_file_with_line ('AUTOMAKE_OPTIONS', $FOREIGN,
756 'ansi2knr.c', 'ansi2knr.1');
757 $output_rules .= &file_contents ('kr-extra');
758 push (@clean, 'krextra');
759 &push_phony_cleaners ('krextra');
762 # Generate rules to build ansi2knr. If it is in some
763 # other directory, then generate dependencies but have the
764 # rule just run elsewhere.
765 $output_rules .= ($options{'ansi2knr'} . ': '
766 . $options{'ansi2knr'} . ".o\n");
767 if ($options{'ansi2knr'} eq 'ansi2knr')
769 $output_rules .= ("\t\$(LINK) ansi2knr.o \$(LIBS)\n"
770 . "ansi2knr.o: \$(CONFIG_HEADER)\n\n");
774 $output_rules .= ("\tcd " . &dirname ($options{'ansi2knr'})
775 . " && \$(MAKE) ansi2knr\n\n");
778 # Make sure ansi2knr can be found: if no path specified,
780 if ($options{'ansi2knr'} eq 'ansi2knr')
782 # Substitution from AM_C_PROTOTYPES. This makes it be
783 # built only when necessary.
784 &define_configure_variable ('ANSI2KNR');
785 # ansi2knr needs to be built before subdirs, so unshift it.
786 unshift (@all, '$(ANSI2KNR)');
790 # Found in another directory.
791 &define_variable ("ANSI2KNR", $options{'ansi2knr'});
794 $output_rules .= &file_contents ('clean-kr');
797 &push_phony_cleaners ('kr');
799 $included_knr_compile = 1;
806 # Handle yacc and lex.
807 sub handle_yacc_lex_cxx
810 # First do yacc and lex.
813 local ($yacc_count) = scalar (keys %yacc_sources);
814 local ($lex_count) = scalar (keys %lex_sources);
818 local (%seen_suffix) = ();
819 foreach (keys %yacc_sources)
822 &output_yacc_build_rule ($1, $yacc_count > 1)
823 if (! defined $seen_suffix{$1});
824 $seen_suffix{$1} = 1;
827 if (! defined $configure_vars{'YACC'})
829 &am_error ("yacc source seen but \`YACC' not defined in \`configure.in'");
834 local (%seen_suffix) = ();
835 foreach (keys %lex_sources)
838 &output_lex_build_rule ($1, $lex_count > 1)
839 if (! defined $seen_suffix{$1});
840 $seen_suffix{$1} = 1;
843 if (! defined $configure_vars{'LEX'})
845 &am_error ("lex source seen but \`LEX' not defined in \`configure.in'");
847 if (! $seen_decl_yytext)
849 &am_error ("lex source seen but \`AC_DECL_YYTEXT' not in \`configure.in'");
853 if ($yacc_count > 1 || $lex_count > 1)
855 # If there is more than one distinct yacc (resp lex) source
856 # file in a given directory, then the `ylwrap' program is
857 # required to allow parallel builds to work correctly. FIXME:
858 # for now, no line number.
859 &require_config_file ($FOREIGN, 'ylwrap');
860 if ($config_aux_dir ne '.' && $config_aux_dir ne '')
862 &define_variable ('YLWRAP', $config_aux_dir . "/ylwrap");
866 &define_variable ('YLWRAP', '$(srcdir)/ylwrap');
873 local ($ltcompile, $ltlink) = ('', '');
876 &define_configure_variable ("LIBTOOL");
877 $ltcompile = '$(LIBTOOL) --mode=compile ';
878 $ltlink = '$(LIBTOOL) --mode=link ';
884 local (@cxx_list) = keys %cxx_extensions;
885 local ($cxx_count) = scalar @cxx_list;
888 push (@suffixes, @cxx_list);
890 &define_configure_variable ("CXXFLAGS");
891 &define_variable ('CXXCOMPILE', '$(CXX) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CXXFLAGS)');
892 &define_variable ('LTCXXCOMPILE',
893 $ltcompile . '$(CXX) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CXXFLAGS)')
896 &define_variable ('CXXLINK', $ltlink . '$(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@');
899 foreach $ext (@cxx_list)
901 $output_rules .= ("$ext.o:\n"
902 . "\t\$(CXXCOMPILE) -c \$<\n");
903 $output_rules .= ("$ext.lo:\n"
904 . "\t\$(LTCXXCOMPILE) -c \$<\n")
908 if (! defined $configure_vars{'CXX'})
910 &am_error ("C++ source seen but \`CXX' not defined in \`configure.in'");
915 # Handle some ansi2knr cleanup.
917 if (defined $options{'ansi2knr'} && keys %de_ansi_files)
919 # Make all _.c files depend on their corresponding .c files.
920 local ($base, @objects);
921 foreach $base (sort (keys %de_ansi_files))
923 # Each _.c file must depend on ansi2knr; otherwise it
924 # might be used in a parallel build before it is built.
925 $output_rules .= $base . "_.c: $base.c $(ANSI2KNR)\n\t"
926 . '$(ANSI2KNR) ' . $base . '.c ' . $base . "_.c\n";
927 push (@objects, $base . '_.o');
928 push (@objects, $base . '_.lo') if $seen_libtool;
931 # Make all _.o (and _.lo) files depend on ansi2knr.
932 # Use a sneaky little hack to make it print nicely.
933 &pretty_print_rule ('', '', @objects, ':', '$(ANSI2KNR)');
937 # Last, handle some C cleanup.
941 &define_configure_variable ('CFLAGS');
942 &define_variable ('COMPILE',
943 '$(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)');
944 &define_variable ('LTCOMPILE',
946 '$(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)')
948 &define_variable ('LINK', $ltlink . '$(CC) $(CFLAGS) $(LDFLAGS) -o $@');
950 if (! defined $configure_vars{'CC'})
952 &am_line_error ($seen_c_source,
953 "C source seen but \`CC' not defined in \`configure.in'");
959 # Output a rule to build from a YACC source. The output from YACC is
960 # compiled with C or C++, depending on the extension of the YACC file.
961 sub output_yacc_build_rule
963 local ($yacc_suffix, $use_ylwrap, $c_suffix) = @_;
965 local ($c_suffix, $suffix);
966 ($c_suffix = $yacc_suffix) =~ tr/y/c/;
967 push (@suffixes, $yacc_suffix, $c_suffix, '.h');
969 # Generate rule for c/c++ and header file. Probably should only
970 # do header if `yacc -d' is run. But how can we determine that?
971 foreach $suffix ($c_suffix, '.h')
973 $output_rules .= "$yacc_suffix$suffix:\n\t";
977 $output_rules .= ('$(SHELL) $(YLWRAP)'
978 . ' "$(YACC)" $< y.tab.c $*' . $c_suffix
979 . ' y.tab.h $*.h -- $(YACCFLAGS)');
983 $output_rules .= ('$(YACC) $(YACCFLAGS) $< && mv y.tab.c $@' . "\n"
984 . "\tif test -f y.tab.h; then \\\n"
985 . "\tif cmp -s y.tab.h \$*.h; then rm -f y.tab.h; else mv y.tab.h \$*.h; fi; \\\n"
988 $output_rules .= "\n";
992 sub output_lex_build_rule
994 local ($lex_suffix, $use_ylwrap) = @_;
997 ($c_suffix = $lex_suffix) =~ tr/l/c/;
998 push (@suffixes, $lex_suffix);
999 &define_configure_variable ('LEX_OUTPUT_ROOT');
1000 &define_configure_variable ('LEXLIB');
1001 $output_rules .= "$lex_suffix$c_suffix:\n\t";
1005 # Is the $@ correct here? If so, why not use it in the ylwrap
1006 # build rule for yacc above?
1007 $output_rules .= '$(SHELL) $(YLWRAP)'
1008 . ' "$(LEX)" $< $(LEX_OUTPUT_ROOT).c $@ -- $(LFLAGS)';
1012 $output_rules .= '$(LEX) $(LFLAGS) $< && mv $(LEX_OUTPUT_ROOT).c $@';
1014 $output_rules .= "\n";
1018 # Check to make sure a source defined in LIBOBJS is not explicitly
1019 # mentioned. This is a separate function (as opposed to being inlined
1020 # in handle_source_transform) because it isn't always appropriate to
1022 sub check_libobjs_sources
1024 local ($one_file, $unxformed) = @_;
1026 local ($prefix, $file, @files);
1027 foreach $prefix ('', 'EXTRA_')
1029 if (&variable_defined ($prefix . $one_file . '_SOURCES'))
1031 @files = &variable_value_as_list (($prefix
1032 . $one_file . '_SOURCES'),
1035 elsif ($prefix eq '')
1037 @files = ($unxformed . '.c');
1044 foreach $file (@files)
1046 if (defined $libsources{$file})
1048 &am_line_error ($prefix . $one_file . '_SOURCES',
1049 "automatically discovered file \`$file' should not be explicitly mentioned");
1055 # Does much of the actual work for handle_source_transform.
1057 # list of source files to transform
1059 # first element is name of linker to use (empty string for default linker)
1060 # remaining elements are names of `.o's
1061 sub handle_single_transform_list
1063 local (@files) = @_;
1064 local ($linker) = '';
1065 local (@result) = ();
1066 local ($nonansi_obj) = $obj;
1067 $nonansi_obj =~ s/_//g;
1068 if (length (@files))
1070 # Turn sources into objects.
1073 # Skip header files, including C++-ish ones. The list
1074 # of C++ header extensions comes from Emacs 19.32
1081 # Skip things that look like configure substitutions.
1084 # Include appropriate file for lex or yacc source in
1085 # distribution. If the extension is the regular '.y' or
1086 # '.l', we assume C compilation, and the generated file
1087 # has exension .c. Otherwise, we compile with C++, and
1088 # make the following association: (yy -> cc, y++ -> c++,
1089 # yxx -> cxx), similarly for .ll, etc.
1090 if (/^(.*)\.(y|yy|y\+\+|yxx)$/)
1095 &push_dist_common ("$1.$ext");
1096 $yacc_sources{$_} = 1;
1098 elsif (/^(.*)\.(l|ll|l\+\+|lxx)$/)
1103 &push_dist_common ("$1.$ext");
1104 $lex_sources{$_} = 1;
1107 # Strip any directory prefix.
1108 $_ = &basename ($_);
1110 # Transform source files into .o files. List of C++
1111 # extensions comes from Emacs 19.34 etags.
1112 if (s/\.(c\+\+|cc|cpp|cxx|C)$/$nonansi_obj/)
1114 $cxx_extensions{'.' . $1} = 1;
1115 $linker = 'CXXLINK';
1117 elsif (s/\.(yy|y\+\+|yxx|ll|l\+\+|lxx)$/$nonansi_obj/)
1119 # Compiling lex or yacc with C++
1122 $cxx_extensions{".$ext"} = 1;
1123 $linker = 'CXXLINK';
1125 elsif (s/\.([Ff]\\|f90\\|for)$/$nonansi_obj/)
1127 # FORTRAN support. FIXME: not finished.
1129 elsif (s/\.[sS]$/$nonansi_obj/)
1131 # .s is assembly. Just rewrite it. FIXME: not finished.
1133 elsif (defined ($options{'ansi2knr'}) && s/_\.[cly]$/_.c/)
1135 # FIXME include line number in error.
1136 &am_error ("C source file \`$_' would be deleted by ansi2knr rules");
1138 elsif (s/\.[cly]$//)
1140 # .c is C. .l is lex. .y is yacc.
1142 # Note: first we rewrite (eg) foo.c to foo and push
1143 # the file onto the list of deansified files. Then we add
1144 # $obj, which can either be `_.o', or simply `.o' if
1145 # deansification is not required.
1146 $de_ansi_files{$_} = 1;
1152 # No error message here. Used to have one, but it was
1159 # Transform .o or $o file into .P file (for automatic
1162 $dep_files{'.deps/' . $_} = 1;
1166 return ($linker, @result);
1169 # Handle SOURCE->OBJECT transform for one program or library.
1171 # canonical (transformed) name of object to build
1172 # actual name of object to build
1173 # object extension (ie either `.o' or `$o'.
1174 # Return result is name of linker variable that must be used.
1175 # Empty return means just use `LINK'.
1176 sub handle_source_transform
1178 # one_file is canonical name. unxformed is given name. obj is
1180 local ($one_file, $unxformed, $obj) = @_;
1181 local ($objpat) = $obj;
1182 $objpat =~ s/(\W)/\\$1/g;
1183 # Handle explicit `.o' as well as whatever we're passed.
1184 $objpat = '(' . $objpat . "|\\.o)";
1186 local ($linker) = '';
1188 if (&variable_defined ($one_file . "_OBJECTS"))
1190 &am_line_error ($one_file . '_OBJECTS',
1191 $one_file . '_OBJECTS', 'should not be defined');
1192 # No point in continuing.
1196 local (@files, @result, $prefix, $temp);
1197 foreach $prefix ('', 'EXTRA_')
1200 local ($var) = $prefix . $one_file . "_SOURCES";
1201 if (&variable_defined ($var))
1203 push (@sources, '$(' . $prefix . $one_file . "_SOURCES)");
1204 push (@objects, '$(' . $prefix . $one_file . "_OBJECTS)")
1205 unless $prefix eq 'EXTRA_';
1206 local (@conds) = &variable_conditions ($var);
1209 @files = &variable_value_as_list ($var, '');
1214 foreach $cond (@conds)
1216 @files = &variable_value_as_list ($var, $cond);
1217 ($temp, @result) = &handle_single_transform_list (@files);
1218 $linker = $temp if $linker eq '';
1219 &define_pretty_variable ($one_file . "_OBJECTS", $cond,
1221 unless $prefix eq 'EXTRA_';
1227 elsif ($prefix eq '')
1229 &define_variable ($one_file . "_SOURCES", $unxformed . ".c");
1230 push (@sources, $unxformed . '.c');
1231 push (@objects, $unxformed . $obj);
1232 push (@files, $unxformed . '.c');
1235 ($temp, @result) = &handle_single_transform_list (@files);
1236 $linker = $temp if $linker eq '';
1237 &define_pretty_variable ($one_file . "_OBJECTS", '', @result)
1238 unless $prefix eq 'EXTRA_';
1244 # Handle the BUILT_SOURCES variable.
1245 sub handle_built_sources
1247 return unless &variable_defined ('BUILT_SOURCES');
1249 local (@sources) = &variable_value_as_list ('BUILT_SOURCES', 'all');
1251 foreach $s (@sources)
1255 # FIXME: is this really the right thing to do?
1256 &am_line_error ('BUILT_SOURCES',
1257 "\`BUILT_SOURCES' should not contain a configure substitution");
1262 # We don't care about the return value of this function. We just
1263 # want to make sure to update %dep_files with the contents of
1265 &handle_single_transform_list (@sources);
1268 # Special-case @ALLOCA@ and @LIBOBJS@ in _LDADD or _LIBADD variables.
1269 # Also, generate _DEPENDENCIES variable if appropriate.
1271 # transformed name of object being built, or empty string if no object
1272 # name of _LDADD/_LIBADD-type variable to examine
1273 # boolean (lex_seen) which is true if a lex source file was seen in this
1274 # object. valid only for LDADDs, not LIBADDs. If set, LEXLIB
1276 # Returns 1 if LIBOBJS seen, 0 otherwise.
1277 sub handle_lib_objects
1279 local ($xname, $var, $lex_seen) = @_;
1282 die "automake: programming error 1 in handle_lib_objects\n"
1283 if ! &variable_defined ($var);
1285 die "automake: programming error 2 in handle_lib_objects\n"
1286 if $lex_seen && $var =~ /LIBADD/;
1288 local (@conds) = &variable_conditions ($var);
1291 $ret = &handle_lib_objects_cond ($xname, $var, $lex_seen, '');
1297 foreach $cond (@conds)
1299 if (&handle_lib_objects_cond ($xname, $var, $lex_seen, $cond))
1309 # Subroutine of handle_lib_objects: handle a particular condition.
1310 sub handle_lib_objects_cond
1312 local ($xname, $var, $lex_seen, $cond) = @_;
1314 # We recognize certain things that are commonly put in LIBADD or
1317 local (@dep_list) = ();
1319 # If no lex source seen, just assume this is ok.
1320 local ($lex_ok) = $lex_seen ? 0 : 1;
1322 local ($seen_libobjs) = 0;
1323 local ($flagvar) = 0;
1325 foreach $lsearch (&variable_value_as_list ($var, $cond))
1327 # Skip -lfoo and -Ldir; these are explicitly allowed.
1328 next if $lsearch =~ /^-[lL]/;
1329 if (! $flagvar && $lsearch =~ /^-/)
1331 if ($var =~ /^(.*)LDADD$/)
1333 &am_line_error ($var, "linker flags such as \`$lsearch' belong in \`${1}LDFLAGS");
1337 # Only get this error once.
1339 &am_line_error ($var, "you cannot use linker flags such as \`$lsearch' in \`$var'");
1343 # Assume we have a file of some sort, and push it onto the
1344 # dependency list. Autoconf substitutions are not pushed;
1345 # rarely is a new dependency substituted into (eg) foo_LDADD
1346 # -- but "bad things (eg -lX11) are routinely substituted.
1347 # Note that LIBOBJS and ALLOCA are exceptions to this rule,
1348 # and handled specially below.
1349 push (@dep_list, $lsearch)
1350 unless $lsearch =~ /^\@.*\@$/;
1352 # Automatically handle @LIBOBJS@ and @ALLOCA@. Basically this
1353 # means adding entries to dep_files.
1354 if ($lsearch =~ /^\@(LT)?LIBOBJS\@$/)
1356 push (@dep_list, $lsearch);
1358 if (! keys %libsources)
1360 &am_line_error ($var, "\@$1" . "LIBOBJS\@ seen but never set in \`configure.in'");
1363 local ($iter, $rewrite);
1364 foreach $iter (keys %libsources)
1366 if ($iter =~ /\.[cly]$/)
1368 $seen_c_source = $var;
1371 if ($iter =~ /\.h$/)
1373 &require_file_with_line ($var, $FOREIGN, $iter);
1375 elsif ($iter ne 'alloca.c')
1377 ($rewrite = $iter) =~ s/\.c$/.P/;
1378 $dep_files{'.deps/' . $rewrite} = 1;
1379 &require_file_with_line ($var, $FOREIGN, $iter);
1383 elsif ($lsearch =~ /^\@(LT)?ALLOCA\@$/)
1385 push (@dep_list, $lsearch);
1386 &am_line_error ($var,
1387 "\@$1" . "ALLOCA\@ seen but \`AC_FUNC_ALLOCA' not in \`configure.in'")
1388 if ! defined $libsources{'alloca.c'};
1389 $dep_files{'.deps/alloca.P'} = 1;
1390 &require_file_with_line ($var, $FOREIGN, 'alloca.c');
1391 $seen_c_source = $var;
1393 elsif ($lsearch eq '@LEXLIB@')
1395 # FIXME: variable_value_as_list requires us to force
1396 # @LEXLIB@ here, where we'd really prefer $(LEXLIB).
1397 # Nasty -- this will have to wait until many cleanups are
1405 &am_line_error ($var, 'lex source file used without @LEXLIB@');
1408 if ($xname ne '' && ! &variable_defined ($xname . '_DEPENDENCIES', $cond))
1410 &define_pretty_variable ($xname . '_DEPENDENCIES', $cond, @dep_list);
1413 return $seen_libobjs;
1416 # Canonicalize a name, and check to make sure the non-canonical name
1417 # is never used. Returns canonical name. Arguments are name and a
1418 # list of suffixes to check for.
1419 sub check_canonical_spelling
1421 local ($name, @suffixes) = @_;
1422 local ($xname, $xt);
1424 ($xname = $name) =~ tr/A-Za-z0-9_/_/c;
1425 if ($xname ne $name)
1428 foreach $xt (@suffixes)
1430 &am_line_error ($name . $xt,
1431 "invalid variable \`" . $name . $xt
1432 . "'; should be \`" . $xname . $xt . "'")
1433 if &variable_defined ($name . $xt);
1440 # Handle C programs.
1443 local (@proglist) = &am_install_var ('-clean',
1444 'progs', 'PROGRAMS',
1445 'bin', 'sbin', 'libexec', 'pkglib',
1447 return if ! @proglist;
1449 # If a program is installed, this is required. We only want this
1450 # error to appear once.
1451 &am_conf_error ("AC_ARG_PROGRAM must be used in configure.in")
1452 unless $seen_arg_prog;
1455 local ($one_file, $xname, $munge);
1457 local ($seen_libobjs) = 0;
1458 foreach $one_file (@proglist)
1460 local ($obj) = &get_object_extension ($one_file);
1462 # Canonicalize names and check for misspellings.
1463 $xname = &check_canonical_spelling ($one_file, '_LDADD', '_LDFLAGS',
1464 '_SOURCES', '_OBJECTS',
1467 # FIXME: Using a trick to figure out if any lex sources appear
1468 # in our program; should use some cleaner method.
1469 local ($lex_num) = scalar (keys %lex_sources);
1470 local ($linker) = &handle_source_transform ($xname, $one_file, $obj);
1471 local ($lex_file_seen) = (scalar (keys %lex_sources) > $lex_num);
1474 if (&variable_defined ($xname . "_LDADD"))
1476 if (&handle_lib_objects ($xname, $xname . '_LDADD',
1486 # User didn't define prog_LDADD override. So do it.
1487 &define_variable ($xname . '_LDADD', '$(LDADD)');
1489 # This does a bit too much work. But we need it to
1490 # generate _DEPENDENCIES when appropriate.
1491 if (&variable_defined ('LDADD'))
1493 if (&handle_lib_objects ($xname, 'LDADD', $lex_file_seen))
1502 if (&variable_defined ($xname . '_LIBADD'))
1504 &am_line_error ($xname . '_LIBADD',
1505 "use \`" . $xname . "_LDADD', not \`"
1506 . $xname . "_LIBADD'");
1509 if (! &variable_defined ($xname . '_LDFLAGS'))
1511 # Define the prog_LDFLAGS variable.
1512 &define_variable ($xname . '_LDFLAGS', '');
1517 &am_line_error ($xname . $xt,
1518 'lex source file used without @LEXLIB@');
1521 # Determine program to use for link.
1523 if (&variable_defined ($xname . '_LINK'))
1525 $xlink = $xname . '_LINK';
1529 $xlink = $linker ? $linker : 'LINK';
1533 if ($seen_exeext && $one_file !~ /\./)
1535 $xexe = 's/\@EXEEXT\@/\$(EXEEXT)/g;';
1539 $xexe = 's/\@EXEEXT\@//g;';
1543 &file_contents_with_transform
1544 ('s/\@PROGRAM\@/' . $one_file . '/go;'
1545 . 's/\@XPROGRAM\@/' . $xname . '/go;'
1546 . 's/\@XLINK\@/' . $xlink . '/go;'
1551 if (&variable_defined ('LDADD') && &handle_lib_objects ('', 'LDADD', 0))
1558 foreach $one_file (@proglist)
1560 # Canonicalize names.
1561 ($xname = $one_file) =~ tr/A-Za-z0-9_/_/c;
1563 if (&variable_defined ($xname . '_LDADD'))
1565 &check_libobjs_sources ($xname, $xname . '_LDADD');
1567 elsif (&variable_defined ('LDADD'))
1569 &check_libobjs_sources ($xname, 'LDADD');
1577 sub handle_libraries
1579 local (@liblist) = &am_install_var ('-clean',
1580 'libs', 'LIBRARIES',
1581 'lib', 'pkglib', 'noinst', 'check');
1582 return if ! @liblist;
1584 local (%valid) = &am_primary_prefixes ('LIBRARIES', 'lib', 'pkglib',
1586 if (! defined $configure_vars{'RANLIB'})
1589 foreach $key (keys %valid)
1591 if (&variable_defined ($key . '_LIBRARIES'))
1593 &am_line_error ($key . '_LIBRARIES', "library used but \`RANLIB' not defined in \`configure.in'");
1594 # Only get this error once.
1595 $configure_vars{'RANLIB'} = 1;
1604 local ($seen_libobjs) = 0;
1605 foreach $onelib (@liblist)
1607 # Check that the library fits the standard naming convention.
1608 if ($onelib !~ /^lib.*\.a$/)
1610 # FIXME this should only be a warning for foreign packages
1611 # FIXME should put line number here. That means mapping
1612 # from library name back to variable name.
1613 &am_error ("\`$onelib' is not a standard library name");
1616 local ($obj) = &get_object_extension ($onelib);
1618 # Canonicalize names and check for misspellings.
1619 $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_SOURCES',
1620 '_OBJECTS', '_DEPENDENCIES');
1622 if (&variable_defined ($xlib . '_LIBADD'))
1624 if (&handle_lib_objects ($xlib, $xlib . '_LIBADD', 0))
1631 # Generate support for conditional object inclusion in
1633 &define_variable ($xlib . "_LIBADD", '');
1636 if (&variable_defined ($xlib . '_LDADD'))
1638 &am_line_error ($xlib . '_LDADD',
1639 "use \`" . $xlib . "_LIBADD', not \`"
1640 . $xlib . "_LDADD'");
1643 &handle_source_transform ($xlib, $onelib, $obj);
1646 &file_contents_with_transform ('s/\@LIBRARY\@/' . $onelib . '/go;'
1654 foreach $onelib (@liblist)
1656 # Canonicalize names.
1657 ($xlib = $onelib) =~ tr/A-Za-z0-9_/_/c;
1658 if (&variable_defined ($xlib . '_LIBADD'))
1660 &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
1665 &define_variable ('AR', 'ar');
1666 &define_configure_variable ('RANLIB');
1669 # Handle shared libraries.
1670 sub handle_ltlibraries
1672 local (@liblist) = &am_install_var ('-clean',
1673 'ltlib', 'LTLIBRARIES',
1675 return if ! @liblist;
1678 local (%valid) = &am_primary_prefixes ('LTLIBRARIES', 'lib', 'pkglib');
1681 foreach $key (keys %valid)
1683 if (&variable_defined ($key . '_LTLIBRARIES'))
1687 &am_line_error ($key . '_LTLIBRARIES', "library used but \`LIBTOOL' not defined in \`configure.in'");
1688 # Only get this error once.
1689 $configure_vars{'LIBTOOL'} = 1;
1693 # Get the installation directory of each library.
1694 for (&variable_value_as_list ($key . '_LTLIBRARIES', 'all'))
1698 &am_error ("\`$_' is already going to be installed in \`$instdirs{$_}'");
1702 $instdirs{$_} = $key;
1711 local ($seen_libobjs) = 0;
1712 foreach $onelib (@liblist)
1714 # Check that the library fits the standard naming convention.
1715 if ($onelib !~ /^lib.*\.la$/)
1717 # FIXME this should only be a warning for foreign packages
1718 # FIXME should put line number here. That means mapping
1719 # from library name back to variable name.
1720 &am_error ("\`$onelib' is not a standard libtool library name");
1723 local ($obj) = &get_object_extension ($onelib);
1725 # Canonicalize names and check for misspellings.
1726 $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_LDFLAGS',
1727 '_SOURCES', '_OBJECTS',
1730 if (! &variable_defined ($xlib . '_LDFLAGS'))
1732 # Define the lib_LDFLAGS variable.
1733 &define_variable ($xlib . '_LDFLAGS', '');
1736 if (&variable_defined ($xlib . '_LIBADD'))
1738 if (&handle_lib_objects ($xlib, $xlib . '_LIBADD', 0))
1745 # Generate support for conditional object inclusion in
1747 &define_variable ($xlib . "_LIBADD", '');
1750 if (&variable_defined ($xlib . '_LDADD'))
1752 &am_line_error ($xlib . '_LDADD',
1753 "use \`" . $xlib . "_LIBADD', not \`"
1754 . $xlib . "_LDADD'");
1757 local ($linker) = &handle_source_transform ($xlib, $onelib, $obj);
1759 # Determine program to use for link.
1761 if (&variable_defined ($xlib . '_LINK'))
1763 $xlink = $xlib . '_LINK';
1767 $xlink = $linker ? $linker : 'LINK';
1771 if ($instdirs{$onelib} eq 'EXTRA')
1773 # It's an EXTRA_ library, so we can't specify -rpath.
1775 $rpath = 's/\@RPATH\@//go;';
1779 $rpath = ('s/\@RPATH\@/-rpath \$(' . $instdirs{$onelib}
1784 &file_contents_with_transform ('s/\@LTLIBRARY\@/'
1786 . 's/\@XLTLIBRARY\@/'
1789 . 's/\@XLINK\@/' . $xlink . '/go;',
1795 foreach $onelib (@liblist)
1797 # Canonicalize names.
1798 ($xlib = $onelib) =~ tr/A-Za-z0-9_/_/c;
1799 if (&variable_defined ($xlib . '_LIBADD'))
1801 &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
1807 # See if any _SOURCES variable were misspelled. Also, make sure that
1808 # EXTRA_ variables don't contain configure substitutions.
1811 local ($varname, $primary);
1812 foreach $varname (keys %contents)
1814 foreach $primary ('_SOURCES', '_LIBADD', '_LDADD', '_LDFLAGS',
1817 if ($varname =~ /$primary$/ && ! $content_seen{$varname})
1819 &am_line_error ($varname,
1820 "invalid unused variable name: \`$varname'");
1829 # NOTE we no longer automatically clean SCRIPTS, because it is
1830 # useful to sometimes distribute scripts verbatim. This happens
1831 # eg in Automake itself.
1832 &am_install_var ('scripts', 'SCRIPTS',
1833 'bin', 'sbin', 'libexec', 'pkgdata',
1836 # Set $scripts_installed if appropriate. Make sure we only find
1837 # scripts which are actually installed -- this is why we can't
1838 # simply use the return value of am_install_var.
1839 local (%valid) = &am_primary_prefixes ('SCRIPTS', 'bin', 'sbin',
1840 'libexec', 'pkgdata',
1843 foreach $key (keys %valid)
1845 if ($key ne 'noinst'
1847 && &variable_defined ($key . '_SCRIPTS'))
1849 $scripts_installed = 1;
1850 # push (@check_tests, 'check-' . $key . 'SCRIPTS');
1854 if ($scripts_installed)
1856 # If a program is installed, this is required. We only want this
1857 # error to appear once.
1858 &am_conf_error ("AC_ARG_PROGRAM must be used in configure.in")
1859 unless $seen_arg_prog;
1864 # Search a file for a "version.texi" Texinfo include. Return the name
1865 # of the include file if found, or the empty string if not. A
1866 # "version.texi" file is actually any file whose name matches
1868 sub scan_texinfo_file
1870 local ($filename) = @_;
1872 if (! open (TEXI, $filename))
1874 &am_error ("couldn't open \`$filename': $!");
1877 print "automake: reading $filename\n" if $verbose;
1879 local ($vfile, $outfile);
1882 if (/^\@setfilename +(\S+)/)
1888 if (/^\@include\s+(vers[^.]*\.texi)\s*$/)
1890 # Found version.texi include.
1897 return ($outfile, $vfile);
1900 # Handle all Texinfo source.
1903 &am_line_error ('TEXINFOS',
1904 "\`TEXINFOS' is an anachronism; use \`info_TEXINFOS'")
1905 if &variable_defined ('TEXINFOS');
1906 return if (! &variable_defined ('info_TEXINFOS')
1907 && ! &variable_defined ('html_TEXINFOS'));
1909 local (@texis) = &variable_value_as_list ('info_TEXINFOS', 'all');
1911 local (@info_deps_list, @dvis_list, @texi_deps);
1912 local ($infobase, $info_cursor);
1916 local ($tc_cursor, @texi_cleans);
1919 foreach $info_cursor (@texis)
1921 ($infobase = $info_cursor) =~ s/\.texi(nfo)?$//;
1923 # If 'version.texi' is referenced by input file, then include
1924 # automatic versioning capability.
1925 local ($out_file, $vtexi) = &scan_texinfo_file ($relative_dir
1926 . "/" . $info_cursor);
1928 if ($out_file eq '')
1930 &am_error ("\`$info_cursor' missing \@setfilename");
1934 if ($out_file =~ /\.(.+)$/ && $1 ne 'info')
1936 # FIXME should report line number in input file.
1937 &am_error ("output of \`$info_cursor', \`$out_file', has unrecognized extension");
1943 &am_error ("\`$vtexi', included in \`$info_cursor', also included in \`$versions{$vtexi}'")
1944 if (defined $versions{$vtexi});
1945 $versions{$vtexi} = $info_cursor;
1947 # We number the stamp-vti files. This is doable since the
1948 # actual names don't matter much. We only number starting
1949 # with the second one, so that the common case looks nice.
1950 $vti = 'vti' . ($done ? $done : '');
1951 &push_dist_common ($vtexi, 'stamp-' . $vti);
1952 push (@clean, $vti);
1954 # Only require once.
1955 &require_conf_file_with_line ('info_TEXINFOS', $FOREIGN,
1961 ($conf_pat = $config_aux_dir) =~ s/(\W)/\\$1/g;
1963 &file_contents_with_transform
1964 ('s/\@TEXI\@/' . $info_cursor . '/g; '
1965 . 's/\@VTI\@/' . $vti . '/g; '
1966 . 's/\@VTEXI\@/' . $vtexi . '/g;'
1967 . 's,\@MDDIR\@,' . $conf_pat . ',g;',
1970 &push_phony_cleaners ($vti);
1973 # If user specified file_TEXINFOS, then use that as explicit
1976 push (@texi_deps, $info_cursor);
1977 push (@texi_deps, $vtexi) if $vtexi;
1979 # Canonicalize name first.
1980 ($canonical = $infobase) =~ tr/A-Za-z0-9_/_/c;
1981 if (&variable_defined ($canonical . "_TEXINFOS"))
1983 push (@texi_deps, '$(' . $canonical . '_TEXINFOS)');
1984 &push_dist_common ('$(' . $canonical . '_TEXINFOS)');
1987 $output_rules .= ("\n" . $out_file . ": "
1988 . join (' ', @texi_deps)
1989 . "\n" . $infobase . ".dvi: "
1990 . join (' ', @texi_deps)
1993 push (@info_deps_list, $out_file);
1994 push (@dvis_list, $infobase . '.dvi');
1996 # Generate list of things to clean for this target. We do
1997 # this explicitly because otherwise too many things could be
1998 # removed. In particular the ".log" extension might
1999 # reasonably be used in other contexts by the user.
2000 foreach $tc_cursor ('aux', 'cp', 'cps', 'dvi', 'fn', 'fns',
2001 'ky', 'log', 'pg', 'toc', 'tp', 'tps',
2002 'vr', 'vrs', 'op', 'tr', 'cv', 'cn')
2004 push (@texi_cleans, $infobase . '.' . $tc_cursor);
2008 # Find these programs wherever they may lie. Yes, this has
2009 # intimate knowledge of the structure of the texinfo distribution.
2010 &define_program_variable ('MAKEINFO', 'build', 'texinfo/makeinfo',
2012 # Circumlocution to avoid accidental
2013 # configure substitution.
2015 &define_program_variable ('TEXI2DVI', 'src', 'texinfo/util',
2018 # Set transform for including texinfos.am. First, handle --cygnus
2023 $xform = 's/^NOTCYGNUS.*$//; s/^CYGNUS//;';
2027 $xform = 's/^CYGNUS.*$//; s/^NOTCYGNUS//;';
2030 # Handle location of texinfo.tex.
2033 &define_variable ('TEXINFO_TEX',
2034 '$(top_srcdir)/../texinfo/texinfo.tex');
2036 elsif ($config_aux_dir ne '.' && $config_aux_dir ne '')
2038 &define_variable ('TEXINFO_TEX', $config_aux_dir . '/texinfo.tex');
2040 elsif (! &variable_defined ('TEXINFO_TEX'))
2042 &define_variable ('TEXINFO_TEX', '$(srcdir)/texinfo.tex');
2044 local ($xxform) = &dirname (&variable_value ('TEXINFO_TEX'));
2045 $xxform =~ s/(\W)/\\$1/g;
2046 $xform .= ' s/\@TEXINFODIR\@/' . $xxform . '/g;';
2048 $output_rules .= &file_contents_with_transform ($xform, 'texinfos');
2049 push (@phony, 'install-info-am', 'uninstall-info');
2050 push (@dist_targets, 'dist-info');
2052 # How to clean. The funny name is due to --cygnus influence; in
2053 # Cygnus mode, `clean-info' is a target that users can use.
2054 $output_rules .= "\nmostlyclean-aminfo:\n";
2055 &pretty_print_rule ("\trm -f", "\t ", @texi_cleans);
2056 $output_rules .= ("\nclean-aminfo:\n\ndistclean-aminfo:\n\n"
2057 . "maintainer-clean-aminfo:\n\t"
2058 # Eww. But how else can we find all the output
2059 # files from makeinfo?
2060 . 'for i in $(INFO_DEPS); do' . " \\\n"
2061 . "\t" . ' rm -f $$i;' . " \\\n"
2062 . "\t" . ' if test "`echo $$i-[0-9]*`" != "$$i-[0-9]*"; then' . " \\\n"
2063 . "\t" . ' rm -f $$i-[0-9]*;' . " \\\n"
2064 . "\t" . ' fi;' . " \\\n"
2066 &push_phony_cleaners ('aminfo');
2069 $output_rules .= "clean-info: mostlyclean-aminfo\n";
2072 push (@suffixes, '.texi', '.texinfo', '.info', '.dvi', '.ps');
2074 if (! defined $options{'no-installinfo'})
2076 push (@uninstall, 'uninstall-info');
2077 push (@installdirs, '$(infodir)');
2078 unshift (@install_data, 'install-info-am');
2080 # Make sure documentation is made and installed first. Use
2081 # $(INFO_DEPS), not 'info', because otherwise recursive makes
2082 # get run twice during "make all".
2083 unshift (@all, '$(INFO_DEPS)');
2085 push (@clean, 'aminfo');
2086 push (@info, '$(INFO_DEPS)');
2087 push (@dvi, '$(DVIS)');
2089 &define_variable ("INFO_DEPS", join (' ', @info_deps_list));
2090 &define_variable ("DVIS", join (' ', @dvis_list));
2091 # This next isn't strictly needed now -- the places that look here
2092 # could easily be changed to look in info_TEXINFOS. But this is
2093 # probably better, in case noinst_TEXINFOS is ever supported.
2094 &define_variable ("TEXINFOS", &variable_value ('info_TEXINFOS'));
2096 # Do some error checking. Note that this file is not required
2097 # when in Cygnus mode; instead we defined TEXINFO_TEX explicitly
2099 &require_file_with_line ('info_TEXINFOS', $FOREIGN, 'texinfo.tex')
2100 unless (defined $options{'no-texinfo.tex'}
2101 || &variable_defined ('TEXINFO_TEX'));
2104 # Handle any man pages.
2105 sub handle_man_pages
2107 &am_line_error ('MANS', "\`MANS' is an anachronism; use \`man_MANS'")
2108 if &variable_defined ('MANS');
2109 return if ! &variable_defined ('man_MANS');
2111 # We generate the manpage install code by hand to avoid the use of
2112 # basename in the generated Makefile.
2113 local (@mans) = &variable_value_as_list ('man_MANS', 'all');
2114 local (%sections, %inames, %mbases, %secmap, %fullsecmap);
2118 # FIXME: statement without effect:
2119 /^(.*)\.([0-9])([a-z]*)$/;
2124 $fullsecmap{$i} = $2 . $3;
2128 # We don't really need this, but we use it in case we ever want to
2129 # support noinst_MANS.
2130 &define_variable ("MANS", &variable_value ('man_MANS'));
2132 # Generate list of install dirs.
2133 $output_rules .= "install-man: \$(MANS)\n";
2134 $output_rules .= "\t\$(NORMAL_INSTALL)\n";
2135 # Sort keys so that output is deterministic.
2136 foreach (sort keys %sections)
2138 push (@installdirs, '$(mandir)/man' . $_)
2139 unless defined $options{'no-installman'};
2140 $output_rules .= ("\t" . '$(mkinstalldirs) $(mandir)/man'
2143 push (@phony, 'install-man');
2145 # Generate install target.
2147 foreach $key (sort keys %inames)
2149 $_ = $install_man_format;
2150 s/\@SECTION\@/$secmap{$key}/g;
2151 s/\@MAN\@/$inames{$key}/g;
2152 s/\@FULLSECT\@/$fullsecmap{$key}/g;
2153 s/\@MANBASE\@/$mbases{$key}/g;
2154 $output_rules .= $_;
2156 $output_rules .= "\n";
2158 $output_rules .= "uninstall-man:\n\t\$(NORMAL_UNINSTALL)\n";
2159 foreach $key (sort keys %inames)
2161 $_ = $uninstall_man_format;
2162 s/\@SECTION\@/$secmap{$key}/g;
2163 s/\@MAN\@/$inames{$key}/g;
2164 s/\@FULLSECT\@/$fullsecmap{$key}/g;
2165 s/\@MANBASE\@/$mbases{$key}/g;
2166 $output_rules .= $_;
2168 $output_rules .= "\n";
2169 push (@phony, 'uninstall-man');
2171 $output_vars .= &file_contents ('mans-vars');
2173 if (! defined $options{'no-installman'})
2175 push (@install_data, 'install-man');
2176 push (@uninstall, 'uninstall-man');
2177 push (@all, '$(MANS)');
2181 # Handle DATA variables.
2184 &am_install_var ('data', 'DATA', 'data', 'sysconf',
2185 'sharedstate', 'localstate', 'pkgdata',
2192 push (@phony, 'tags');
2193 local (@tag_deps) = ();
2194 if (&variable_defined ('SUBDIRS'))
2196 $output_rules .= ("tags-recursive:\n"
2197 . "\tlist=\'\$(SUBDIRS)\'; for subdir in \$\$list; do \\\n"
2198 # Never fail here if a subdir fails; it
2200 . "\t (cd \$\$subdir && \$(MAKE) tags); \\\n"
2202 push (@tag_deps, 'tags-recursive');
2203 push (@phony, 'tags-recursive');
2206 if ($dir_holds_sources
2207 || $dir_holds_headers
2208 || &variable_defined ('ETAGS_ARGS')
2211 local ($xform) = '';
2213 foreach $one_hdr (@config_headers)
2215 if ($relative_dir eq &dirname ($one_hdr))
2217 # The config header is in this directory. So require it.
2219 ($var = &basename ($one_hdr)) =~ s/(\W)/\\$1/g;
2220 $xform .= ' ' if $xform;
2224 $xform = ('s/\@CONFIG\@/' . $xform . '/;'
2225 . 's/\@DIRS\@/' . join (' ', @tag_deps) . '/;');
2227 if (&variable_defined ('SUBDIRS'))
2229 $xform .= 's/^SUBDIRS//;';
2233 $xform .= 's/^SUBDIRS.*$//;';
2236 $output_rules .= &file_contents_with_transform ($xform, 'tags');
2237 $output_rules .= &file_contents ('tags-clean');
2238 push (@clean, 'tags');
2239 &push_phony_cleaners ('tags');
2240 &examine_variable ('TAGS_DEPENDENCIES');
2242 elsif (&variable_defined ('TAGS_DEPENDENCIES'))
2244 &am_line_error ('TAGS_DEPENDENCIES',
2245 "doesn't make sense to define \`TAGS_DEPENDENCIES' without sources or \`ETAGS_ARGS'");
2249 # Every Makefile must define some sort of TAGS rule.
2250 # Otherwise, it would be possible for a top-level "make TAGS"
2251 # to fail because some subdirectory failed.
2252 $output_rules .= "tags: TAGS\nTAGS:\n\n";
2256 # Worker for handle_dist.
2257 sub handle_dist_worker
2259 local ($makefile) = @_;
2261 $output_rules .= 'distdir: $(DISTFILES)' . "\n";
2263 # Initialization; only at top level.
2264 if ($relative_dir eq '.')
2266 if ($strictness >= $GNITS)
2268 # For Gnits users, this is pretty handy. Look at 15 lines
2269 # in case some explanatory text is desirable.
2270 $output_rules .= ' @if sed 15q $(srcdir)/NEWS | fgrep -e "$(VERSION)" > /dev/null; then :; else \\
2271 echo "NEWS not updated; not releasing" 1>&2; \\
2278 # Create dist directory.
2279 $output_rules .= ("\trm -rf \$(distdir)\n"
2280 . "\tmkdir \$(distdir)\n"
2281 . "\t-chmod 777 \$(distdir)\n");
2284 # Only run automake in `dist' target if --include-deps and
2285 # `no-dependencies' not specified. That way the recipient of a
2286 # distribution can run "make dist" and not need Automake. You
2287 # might be wondering why we run automake once for each directory
2288 # we distribute, instead of running it once at the top level. The
2289 # answer is that we want to run automake after the dependencies
2290 # have been generated. This occurs when "make" is run in the
2291 # subdir. So automake must be run after make has updated the
2292 # Makefile, which means that it must run once per directory.
2293 if ($use_dependencies)
2297 # We need an absolute path for --output-dir. Thus the
2299 "\t" . 'here=`cd $(top_builddir) && pwd`; ' . "\\\n"
2300 . "\t" . 'top_distdir=`cd $(top_distdir) && pwd`; ' . "\\\n"
2301 . "\tcd \$(top_srcdir) \\\n"
2302 . "\t && \$(AUTOMAKE) --include-deps --build-dir=\$\$here --srcdir-name=\$(top_srcdir) --output-dir=\$\$top_distdir "
2303 # Set strictness of output.
2304 . ($cygnus_mode ? '--cygnus' : ('--' . $strictness_name))
2305 . ($cmdline_use_dependencies ? '' : ' --include-deps')
2306 . " " . $makefile . "\n"
2310 # Scan EXTRA_DIST to see if we need to distribute anything from a
2311 # subdir. If so, add it to the list. I didn't want to do this
2312 # originally, but there were so many requests that I finally
2315 if (&variable_defined ('EXTRA_DIST'))
2317 # FIXME: This should be fixed to work with conditionals. That
2318 # will require only making the entries in @dist_dirs under the
2319 # appropriate condition. This is meaningful if the nature of
2320 # the distribution should depend upon the configure options
2322 foreach (&variable_value_as_list ('EXTRA_DIST', ''))
2325 next unless s,/+[^/]+$,,;
2326 push (@dist_dirs, $_)
2332 # Prepend $(distdir) to each directory given. Doing it via a
2333 # hash lets us ensure that each directory is used only once.
2335 grep ($dhash{'$(distdir)/' . $_} = 1, @dist_dirs);
2336 $output_rules .= "\t";
2337 &pretty_print_rule ('$(mkinstalldirs)', "\t ", sort keys %dhash);
2340 # In loop, test for file existence because sometimes a file gets
2341 # included in DISTFILES twice. For example this happens when a
2342 # single source file is used in building more than one program.
2343 # Also, there are situations in which "ln" can fail. For instance
2344 # a file to distribute could actually be a cross-filesystem
2345 # symlink -- this can easily happen if "gettextize" was run on the
2347 $output_rules .= "\t\@for file in \$(DISTFILES); do \\\n";
2350 $output_rules .= "\t if test -f \$\$file; then d=.; else d=\$(srcdir); fi; \\\n";
2354 $output_rules .= "\t d=\$(srcdir); \\\n";
2356 $output_rules .= ' test -f $(distdir)/$$file \\
2357 || ln $$d/$$file $(distdir)/$$file 2> /dev/null \\
2358 || cp -p $$d/$$file $(distdir)/$$file; \\
2362 # If we have SUBDIRS, create all dist subdirectories and do
2364 if (&variable_defined ('SUBDIRS'))
2366 # If SUBDIRS is conditionally defined, then set DIST_SUBDIRS
2367 # to all possible directories, and use it.
2368 if (! &variable_conditions ('SUBDIRS'))
2370 $dist_subdir_name = 'SUBDIRS';
2374 $dist_subdir_name = 'DIST_SUBDIRS';
2375 if (! &variable_defined ('DIST_SUBDIRS'))
2377 &define_pretty_variable ('DIST_SUBDIRS', '',
2378 &variable_value_as_list ('SUBDIRS',
2383 # Test for directory existence here because previous automake
2384 # invocation might have created some directories. Note that
2385 # we explicitly set distdir for the subdir make; that lets us
2386 # mix-n-match many automake-using packages into one large
2387 # package, and have "dist" at the top level do the right
2389 $output_rules .= ' for subdir in $(' . $dist_subdir_name . '); do \\
2390 test -d $(distdir)/$$subdir \\
2391 || mkdir $(distdir)/$$subdir \\
2393 chmod 777 $(distdir)/$$subdir; \\
2394 (cd $$subdir && $(MAKE) top_distdir=../$(top_distdir) distdir=../$(distdir)/$$subdir distdir) \\
2400 # If the target `dist-hook' exists, make sure it is run. This
2401 # allows users to do random weird things to the distribution
2402 # before it is packaged up.
2403 push (@dist_targets, 'dist-hook') if defined $contents{'dist-hook'};
2406 foreach $targ (@dist_targets)
2408 # We must explicitly set distdir and top_distdir for these
2410 $output_rules .= "\t\$(MAKE) top_distdir=\"\$(top_distdir)\" distdir=\"\$(distdir)\" $targ\n";
2413 push (@phony, 'distdir');
2416 # Handle 'dist' target.
2419 local ($makefile) = @_;
2421 # Set up maint_charset.
2422 $local_maint_charset = &variable_value ('MAINT_CHARSET')
2423 if &variable_defined ('MAINT_CHARSET');
2424 $maint_charset = $local_maint_charset
2425 if $relative_dir eq '.';
2427 if (&variable_defined ('DIST_CHARSET'))
2429 &am_line_error ('DIST_CHARSET',
2430 "DIST_CHARSET defined but no MAINT_CHARSET defined")
2431 if ! $local_maint_charset;
2432 if ($relative_dir eq '.')
2434 $dist_charset = &variable_value ('DIST_CHARSET')
2438 &am_line_error ('DIST_CHARSET',
2439 "DIST_CHARSET can only be defined at top level");
2443 # Look for common files that should be included in distribution.
2445 foreach $cfile (@common_files)
2447 if (-f ($relative_dir . "/" . $cfile))
2449 &push_dist_common ($cfile);
2453 # Keys of %dist_common are names of files to distributed. We put
2454 # README first because it then becomes easier to make a
2455 # Usenet-compliant shar file (in these, README must be first).
2456 # FIXME: do more ordering of files here.
2458 if (defined $dist_common{'README'})
2460 push (@coms, 'README');
2461 delete $dist_common{'README'};
2463 push (@coms, sort keys %dist_common);
2465 &define_pretty_variable ("DIST_COMMON", '', @coms);
2466 $output_vars .= "\n";
2469 $output_vars .= &file_contents ('dist-vars') . "\n";
2470 &define_variable ('TAR', $TAR);
2471 &define_variable ('GZIP', '--best');
2473 # Put these things in rules section so it is easier for whoever
2474 # reads Makefile.in.
2475 if (! &variable_defined ('distdir'))
2477 if ($relative_dir eq '.')
2479 $output_rules .= "\n" . 'distdir = $(PACKAGE)-$(VERSION)' . "\n";
2483 $output_rules .= ("\n"
2484 . 'distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)'
2488 if ($relative_dir eq '.')
2490 $output_rules .= "top_distdir = \$(distdir)\n\n";
2494 $output_rules .= "\nsubdir = " . $relative_dir . "\n\n";
2497 # Generate 'dist' target, and maybe dist-shar / dist-zip / dist-tarZ.
2498 if ($relative_dir eq '.')
2500 # Rule to check whether a distribution is viable.
2501 $output_rules .= ('# This target untars the dist file and tries a VPATH configuration. Then
2502 # it guarantees that the distribution is self-contained by making another
2506 GZIP=$(GZIP) $(TAR) zxf $(distdir).tar.gz
2507 mkdir $(distdir)/=build
2508 mkdir $(distdir)/=inst
2509 dc_install_base=`cd $(distdir)/=inst && pwd`; \\'
2510 . (defined $contents{'distcheck-hook'}
2511 ? "\t\$(MAKE) distcheck-hook"
2514 cd $(distdir)/=build \\
2517 . ($seen_gettext ? '--with-included-gettext ' : '')
2518 . '--srcdir=.. --prefix=$$dc_install_base \\
2522 && $(MAKE) install \\
2523 && $(MAKE) installcheck \\
2526 @echo "========================"; \\
2527 echo "$(distdir).tar.gz is ready for distribution"; \\
2528 echo "========================"
2531 local ($dist_all) = ('dist-all: distdir' . "\n"
2534 foreach $curs ('dist', 'dist-shar', 'dist-zip', 'dist-tarZ')
2536 if (defined $options{$curs} || $curs eq 'dist')
2538 $output_rules .= ($curs . ': distdir' . "\n"
2542 $dist_all .= $dist{$curs};
2545 $output_rules .= $dist_all . $dist_trailer;
2548 # Generate distdir target.
2549 &handle_dist_worker ($makefile);
2552 # Scan a single dependency file and rewrite the dependencies as
2553 # appropriate. Essentially this means:
2554 # * Clean out absolute dependencies which are not desirable.
2555 # * Rewrite other dependencies to be relative to $(top_srcdir).
2556 sub scan_dependency_file
2558 local ($depfile) = @_;
2560 if (! open (DEP_FILE, $depfile))
2562 &am_error ("couldn't open \`$depfile': $!");
2565 print "automake: reading $depfile\n" if $verbose;
2567 # Sometimes it is necessary to omit some dependencies.
2568 local (%omit) = %omit_dependencies;
2569 if (&variable_defined ('OMIT_DEPENDENCIES'))
2571 # FIXME: Doesn't work with conditionals. I'm not sure if this
2573 grep ($omit{$_} = 1,
2574 &variable_value_as_list ('OMIT_DEPENDENCIES', ''));
2577 local ($first_line) = 1;
2578 local ($last_line) = 0;
2579 local ($target, @dependencies);
2580 local ($one_dep, $xform);
2583 local ($srcdir_rx, $fixup_rx);
2584 ($fixup_rx = $srcdir_name . '/' . $relative_dir . '/')
2586 ($srcdir_rx = $srcdir_name . '/') =~ s/(\W)/\\$1/g;
2588 local ($rewrite_builddir) = (($top_builddir eq '.')
2590 : $top_builddir . '/');
2596 # If LAST_LINE set then we've already seen what we thought
2597 # was the last line.
2600 next if (/$WHITE_PATTERN/o);
2604 # No trailing "\" means this should be the last line.
2610 if (! /^([^:]+:)(.+)$/)
2613 &am_error ("\`$depfile' has incorrect format");
2619 # Make sure to strip the .P file from the target.
2620 ($target = $1) =~ s, *\.deps/[^.]+\.P,,;
2625 foreach $one_dep (split (' ', $_))
2627 ($just_file = $one_dep) =~ s,^.*/,,;
2628 next if defined $omit{$just_file};
2630 if ($one_dep =~ /^$fixup_rx/)
2632 # The dependency points to the current directory in
2634 ($xform = $one_dep) =~ s/^$fixup_rx//;
2635 push (@dependencies, $xform);
2637 elsif ($one_dep =~ /^$srcdir_rx/)
2639 # The dependency is in some other directory in the package.
2640 ($xform = $one_dep) =~ s/^$srcdir_rx/$rewrite_builddir/;
2641 push (@dependencies, $xform);
2643 elsif ($one_dep =~ /^\//)
2645 # Absolute path; ignore.
2649 # Anything else is assumed to be correct.
2650 push (@dependencies, $one_dep);
2655 &pretty_print_rule ($target, "\t", @dependencies);
2660 # Handle auto-dependency code.
2661 sub handle_dependencies
2663 # Make sure this variable is always marked as used.
2664 &examine_variable ('OMIT_DEPENDENCIES');
2666 if ($use_dependencies)
2668 # Include GNU-make-specific auto-dep code. Don't include it
2669 # if DEP_FILES would be empty.
2670 if ($dir_holds_sources && keys %dep_files)
2672 &define_pretty_variable ('DEP_FILES', '', sort keys %dep_files);
2673 $output_rules .= &file_contents ('depend');
2674 push (@clean, 'depend');
2675 &push_phony_cleaners ('depend');
2677 &file_contents_with_transform ('s/\@EXT\@/.c/g;'
2678 . 's/\@MKDEP\@/MKDEP/g;'
2682 local ($need_cxx) = 0;
2683 foreach $ext (sort keys %cxx_extensions)
2686 &file_contents_with_transform ('s/\@EXT\@/' . $ext .'/g;'
2687 . 's/\@MKDEP\@/CXXMKDEP/g;'
2694 &define_variable ('CXXMKDEP', '$(CXX) -M $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CXXFLAGS)');
2698 elsif ($build_directory ne '')
2700 # Include any auto-generated deps that are present. Note that
2701 # $build_directory ends in a "/".
2702 if (-d ($build_directory . $relative_dir . "/.deps")
2703 && -f ($build_directory . $relative_dir . "/.deps/.P"))
2707 foreach $depfile (&my_glob ($build_directory
2708 . $relative_dir . "/.deps/*.P"))
2710 &scan_dependency_file ($depfile);
2713 $output_rules .= "\n";
2718 # Handle subdirectories.
2721 return if ! &variable_defined ('SUBDIRS');
2723 # Make sure each directory mentioned in SUBDIRS actually exists.
2725 foreach $dir (&variable_value_as_list ('SUBDIRS', 'all'))
2727 # Skip directories substituted by configure.
2728 next if $dir =~ /^\@.*\@$/;
2730 if (! -d $am_relative_dir . '/' . $dir)
2732 &am_line_error ('SUBDIRS',
2733 "required directory $am_relative_dir/$dir does not exist");
2737 &am_line_error ('SUBDIRS', "directory should not contain \`/'")
2741 local ($xform) = ('s/\@INSTALLINFO\@/' .
2742 (defined $options{'no-installinfo'}
2743 ? 'install-info-recursive'
2746 $output_rules .= &file_contents_with_transform ($xform, 'subdirs');
2748 # Push a bunch of phony targets.
2750 foreach $phonies ('-data', '-exec', 'dirs')
2752 push (@phony, 'install' . $phonies . '-recursive');
2753 push (@phony, 'uninstall' . $phonies . '-recursive');
2755 foreach $phonies ('all', 'check', 'installcheck', 'info', 'dvi')
2757 push (@phony, $phonies . '-recursive');
2759 &push_phony_cleaners ('recursive');
2761 push (@check_tests, "check-recursive");
2762 push (@installcheck, "installcheck-recursive");
2763 push (@info, "info-recursive");
2764 push (@dvi, "dvi-recursive");
2766 $recursive_install = 1;
2769 # Handle aclocal.m4.
2770 sub handle_aclocal_m4
2772 local ($regen_aclocal) = 0;
2773 if (-f 'aclocal.m4')
2775 &define_variable ("ACLOCAL_M4", '$(top_srcdir)/aclocal.m4');
2776 &push_dist_common ('aclocal.m4');
2778 if (open (ACLOCAL, '< aclocal.m4'))
2784 if ($line =~ 'generated automatically by aclocal')
2791 local ($acinclude) = 0;
2792 if (-f 'acinclude.m4')
2798 # Note that it might be possible that aclocal.m4 doesn't exist but
2799 # should be auto-generated. This case probably isn't very
2803 local (@ac_deps) = (
2804 ($seen_maint_mode ? "\@MAINT\@" : "") ,
2806 ($acinclude ? ' acinclude.m4' : '')
2809 # Scan all -I directories for m4 files. These are our
2811 if (&variable_defined ('ACLOCAL_AMFLAGS'))
2814 foreach $amdir (&variable_value_as_list ('ACLOCAL_AMFLAGS', ''))
2816 if ($amdir =~ s/^-I//
2820 push (@ac_deps, &my_glob ($am_dir . '/*.m4'));
2825 &pretty_print_rule ("\$(ACLOCAL_M4):", "\t\t", @ac_deps);
2827 $output_rules .= ("\t"
2828 . 'cd $(srcdir) && $(ACLOCAL)'
2829 . (&variable_defined ('ACLOCAL_AMFLAGS')
2830 ? ' $(ACLOCAL_AMFLAGS)' : '')
2835 # Rewrite a list of input files into a form suitable to put on a
2836 # dependency list. The idea is that if an input file has a directory
2837 # part the same as the current directory, then the directory part is
2838 # simply removed. But if the directory part is different, then
2839 # $(top_srcdir) is prepended. Among other things, this is used to
2840 # generate the dependency list for the output files generated by
2841 # AC_OUTPUT. Consider what the dependencies should look like in this
2843 # AC_OUTPUT(src/out:src/in1:lib/in2)
2844 sub rewrite_inputs_into_dependencies
2846 local (@inputs) = @_;
2847 local ($single, @newinputs);
2849 foreach $single (@inputs)
2851 if (&dirname ($single) eq $relative_dir)
2853 push (@newinputs, &basename ($single));
2857 push (@newinputs, '$(top_srcdir)/' . $single);
2864 # Handle remaking and configure stuff.
2865 # We need the name of the input file, to do proper remaking rules.
2866 sub handle_configure
2868 local ($local, $input, @secondary_inputs) = @_;
2870 # If SUBDIRS defined, require AC_PROG_MAKE_SET.
2871 &am_line_error ('SUBDIRS', "AC_PROG_MAKE_SET must be used in configure.in")
2872 if &variable_defined ('SUBDIRS') && ! $seen_make_set;
2874 local ($top_reldir);
2876 local ($input_base) = &basename ($input);
2877 local ($local_base) = &basename ($local);
2879 local ($amfile) = $input_base . '.am';
2880 # We know we can always add '.in' because it really should be an
2881 # error if the .in was missing originally.
2882 local ($infile) = '$(srcdir)/' . $input_base . '.in';
2883 local ($colon_infile);
2884 if ($local ne $input)
2886 $colon_infile = ':' . $input . '.in';
2888 $colon_infile .= ':' . join (':', @secondary_inputs)
2889 if @secondary_inputs;
2891 local (@rewritten) = &rewrite_inputs_into_dependencies (@secondary_inputs);
2892 # This rule remakes the Makefile.in. Note use of @MAINT@ forces
2893 # us to abandon pretty-printing. Sigh.
2894 $output_rules .= ($infile
2895 # NOTE perl 5.003 (with -w) gives a
2896 # uninitialized value error on the next line.
2899 . ($seen_maint_mode ? '@MAINT@ ' : '')
2901 . '$(top_srcdir)/configure.in $(ACLOCAL_M4) '
2902 . join (' ', @rewritten) . "\n"
2903 . "\tcd \$(top_srcdir) && \$(AUTOMAKE) "
2904 . ($cygnus_mode ? '--cygnus' : ('--' . $strictness_name))
2905 . ($cmdline_use_dependencies ? '' : ' --include-deps')
2906 . ' ' . $input . $colon_infile . "\n\n");
2908 # This rule remakes the Makefile.
2909 $output_rules .= ($local_base
2910 # NOTE: bogus uninit value error on next line;
2911 # see comment above.
2914 . '$(top_builddir)/config.status'
2915 # NOTE: Makefile only depends on BUILT_SOURCES
2916 # when dependencies are being computed. This is
2917 # a workaround for an obscure bug with
2918 # AC_LINK_FILES. Anyway, when dependencies are
2919 # turned off, this shouldn't matter.
2920 . ($use_dependencies ? ' $(BUILT_SOURCES)' : '')
2922 . "\tcd \$(top_builddir) \\\n"
2923 . "\t && CONFIG_FILES="
2924 . (($relative_dir eq '.') ? '$@' : '$(subdir)/$@')
2926 . ' CONFIG_HEADERS= $(SHELL) ./config.status'
2929 if ($relative_dir ne '.')
2932 $top_reldir = '../';
2937 $output_rules .= &file_contents ('remake');
2938 &examine_variable ('CONFIGURE_DEPENDENCIES');
2942 # If we have a configure header, require it.
2944 local (@local_fullnames) = @config_fullnames;
2945 local (@local_names) = @config_names;
2946 local ($hdr_index) = 0;
2947 local ($distclean_config) = '';
2948 foreach $one_hdr (@config_headers)
2950 local ($one_fullname) = shift (@local_fullnames);
2951 local ($one_name) = shift (@local_names);
2953 if ($relative_dir eq &dirname ($one_hdr))
2955 local ($ch_sans_dir) = &basename ($one_hdr);
2956 local ($cn_sans_dir) = &basename ($one_name);
2958 &require_file_with_conf_line ($config_header_line,
2959 $FOREIGN, $ch_sans_dir);
2961 # Header defined and in this directory.
2963 if (-f $relative_dir . '/acconfig.h')
2965 push (@files, 'acconfig.h');
2967 if (-f $one_name . '.top')
2969 push (@files, "${cn_sans_dir}.top");
2971 if (-f $one_name . '.bot')
2973 push (@files, "${cn_sans_dir}.bot");
2976 &push_dist_common (@files);
2978 local ($stamp_name) = 'stamp-h';
2979 $stamp_name .= "${hdr_index}" if scalar (@config_headers) > 1;
2981 local ($xform) = '';
2983 $xform = 's,\@FILES\@,' . join (' ', @files) . ',;';
2984 $xform .= 's,\@CONFIG_HEADER\@,' . "${cn_sans_dir}" . ',;';
2985 $xform .= 's,\@CONFIG_HEADER_IN\@,' . "${ch_sans_dir}" . ',;';
2986 $xform .= 's,\@CONFIG_HEADER_FULL\@,' . "${one_fullname}" . ',;';
2987 $xform .= 's,\@STAMP\@,' . "${stamp_name}" . ',;';
2989 $output_rules .= &file_contents_with_transform ($xform,
2992 &touch ($relative_dir . "/${stamp_name}.in");
2993 &require_file_with_conf_line ($config_header_line, $FOREIGN,
2994 "${stamp_name}.in");
2996 $distclean_config .= ' ' if $distclean_config;
2997 $distclean_config .= $cn_sans_dir;
3001 if ($distclean_config)
3003 $output_rules .= &file_contents_with_transform ('s,\@FILES\@,'
3007 push (@clean, 'hdr');
3008 &push_phony_cleaners ('hdr');
3011 # Set location of mkinstalldirs.
3012 if ($config_aux_dir ne '.' && $config_aux_dir ne '')
3014 &define_variable ('mkinstalldirs', ('$(SHELL) ' . $config_aux_dir
3015 . '/mkinstalldirs'));
3019 &define_variable ('mkinstalldirs',
3020 '$(SHELL) $(top_srcdir)/mkinstalldirs');
3023 &am_line_error ('CONFIG_HEADER',
3024 "\`CONFIG_HEADER' is an anachronism; now determined from \`configure.in'")
3025 if &variable_defined ('CONFIG_HEADER');
3028 local ($config_header) = '';
3029 foreach $one_name (@config_names)
3031 # Generate CONFIG_HEADER define.
3033 if ($relative_dir eq &dirname ($one_name))
3035 $one_hdr = &basename ($one_name);
3039 $one_hdr = "${top_builddir}/${one_name}";
3042 $config_header .= ' ' if $config_header;
3043 $config_header .= $one_hdr;
3047 &define_variable ("CONFIG_HEADER", $config_header);
3050 # Now look for other files in this directory which must be remade
3051 # by config.status, and generate rules for them.
3052 local (@actual_other_files) = ();
3053 local ($file, $local);
3054 local (@inputs, @rewritten_inputs, $single);
3055 local ($need_rewritten);
3056 foreach $file (@other_input_files)
3058 if ($file =~ /^(.*):(.*)$/)
3060 # This is the ":" syntax of AC_OUTPUT.
3062 $local = &basename ($file);
3063 @inputs = split (':', $2);
3064 @rewritten_inputs = &rewrite_inputs_into_dependencies (@inputs);
3065 $need_rewritten = 1;
3070 $local = &basename ($file);
3071 @inputs = ($local . '.in');
3073 &rewrite_inputs_into_dependencies ($file . '.in');
3074 $need_rewritten = 0;
3077 # Skip files not in this directory.
3078 next unless &dirname ($file) eq $relative_dir;
3080 # Skip any file that is an automake input.
3081 next if -f $file . '.am';
3083 # Some users have been tempted to put `stamp-h' in the
3084 # AC_OUTPUT line. This won't do the right thing, so we
3085 # explicitly fail here.
3086 if ($local eq 'stamp-h')
3088 # FIXME: allow real filename.
3089 &am_conf_error ('configure.in', $ac_output_line,
3090 'stamp-h should not appear in AC_OUTPUT');
3094 $output_rules .= ($local . ': '
3095 . '$(top_builddir)/config.status '
3096 . join (' ', @rewritten_inputs) . "\n"
3098 . 'cd $(top_builddir) && CONFIG_FILES='
3099 . ($relative_dir eq '.' ? '' : '$(subdir)/')
3100 . '$@' . ($need_rewritten
3101 ? (':' . join (':', @rewritten_inputs))
3103 . ' CONFIG_HEADERS= ./config.status'
3105 push (@actual_other_files, $local);
3107 # Require all input files.
3108 &require_file_with_conf_line ($ac_output_line, $FOREIGN,
3112 # These files get removed by "make clean".
3113 &define_pretty_variable ('CONFIG_CLEAN_FILES', '', @actual_other_files);
3119 $dir_holds_headers = &am_install_var ('header', 'HEADERS', 'include',
3120 'oldinclude', 'pkginclude',
3126 return if ! $seen_gettext || $relative_dir ne '.';
3128 if (! &variable_defined ('SUBDIRS'))
3131 ("AM_GNU_GETTEXT in configure.in but SUBDIRS not defined");
3135 &require_file_with_conf_line ($ac_gettext_line, $FOREIGN, 'ABOUT-NLS')
3138 if (&variable_defined ('SUBDIRS'))
3142 "AM_GNU_GETTEXT in configure.in but \`po' not in SUBDIRS")
3143 if $contents{'SUBDIRS'} !~ /\bpo\b/;
3146 "AM_GNU_GETTEXT in configure.in but \`intl' not in SUBDIRS")
3147 if $contents{'SUBDIRS'} !~ /\bintl\b/;
3150 # Ensure that each language in ALL_LINGUAS has a .po file, and
3151 # each po file is mentioned in ALL_LINGUAS.
3154 local (%linguas) = ();
3155 grep ($linguas{$_} = 1, split (' ', $all_linguas));
3162 &am_line_error ($all_linguas_line,
3163 ("po/$_.po exists but \`$_' not in \`ALL_LINGUAS'"))
3167 foreach (keys %linguas)
3169 &am_line_error ($all_linguas_line,
3170 "$_ in \`ALL_LINGUAS' but po/$_.po does not exist")
3176 &am_error ("AM_GNU_GETTEXT in configure.in but \`ALL_LINGUAS' not defined");
3180 # Handle footer elements.
3183 if ($contents{'SOURCES'})
3185 # NOTE don't use define_pretty_variable here, because
3186 # $contents{...} is already defined.
3187 $output_vars .= 'SOURCES = ' . $contents{'SOURCES'} . "\n";
3189 if ($contents{'OBJECTS'})
3191 # NOTE don't use define_pretty_variable here, because
3192 # $contents{...} is already defined.
3193 $output_vars .= 'OBJECTS = ' . $contents{'OBJECTS'} . "\n";
3195 if ($contents{'SOURCES'} || $contents{'OBJECTS'})
3197 $output_vars .= "\n";
3200 if (&variable_defined ('SUFFIXES'))
3202 # Push actual suffixes, and not $(SUFFIXES). Some versions of
3203 # make do not like variable substitutions on the .SUFFIXES
3205 push (@suffixes, &variable_value_as_list ('SUFFIXES', ''));
3207 if (&target_defined ('.SUFFIXES'))
3209 &am_line_error ('.SUFFIXES',
3210 "use variable \`SUFFIXES', not target \`.SUFFIXES'");
3213 # Note: AIX 4.1 /bin/make will fail if any suffix rule appears
3214 # before .SUFFIXES. So we make sure that .SUFFIXES appears before
3215 # anything else, by sticking it right after the default: target.
3216 $output_header .= ".SUFFIXES:\n";
3220 # Make sure suffixes has unique elements. Sort them to ensure
3221 # the output remains consistent.
3224 grep ($suffixes{$_} = 1, @suffixes);
3226 $output_header .= (".SUFFIXES: "
3227 . join (' ', sort keys %suffixes)
3230 $output_trailer .= &file_contents ('footer');
3233 # Deal with installdirs target.
3234 sub handle_installdirs
3236 # GNU Makefile standards recommend this.
3237 $output_rules .= ("installdirs:"
3238 . ($recursive_install
3239 ? " installdirs-recursive\n"
3241 push (@phony, 'installdirs');
3244 &pretty_print_rule ("\t" . '$(mkinstalldirs) ', "\t\t",
3247 $output_rules .= "\n";
3250 # There are several targets which need to be merged. This is because
3251 # their complete definition is compiled from many parts. Note that we
3252 # avoid double colon rules, otherwise we'd use them instead.
3253 sub handle_merge_targets
3255 local ($makefile) = @_;
3257 # There are a few install-related variables that you should not define.
3259 foreach $var ('PRE_INSTALL', 'POST_INSTALL', 'NORMAL_INSTALL')
3261 if (&variable_defined ($var))
3263 &am_line_error ($var, "\`$var' should not be defined");
3267 # Put this at the beginning for the sake of non-GNU makes. This
3268 # is still wrong if these makes can run parallel jobs. But it is
3270 unshift (@all, &basename ($makefile));
3273 foreach $one_name (@config_names)
3275 push (@all, &basename ($one_name))
3276 if &dirname ($one_name) eq $relative_dir;
3279 &do_one_merge_target ('info', @info);
3280 &do_one_merge_target ('dvi', @dvi);
3281 &do_check_merge_target;
3282 &do_one_merge_target ('installcheck', @installcheck);
3284 if (defined $options{'no-installinfo'})
3286 # FIXME: this is kind of a hack; should find another way to
3287 # know that this is required.
3289 if (grep ($_ eq 'install-info-am', @phony))
3291 push (@dirs, 'install-info-am');
3293 if (&variable_defined ('SUBDIRS'))
3295 push (@dirs, 'install-info-recursive');
3297 &do_one_merge_target ('install-info', @dirs);
3300 # Handle the various install targets specially. We do this so
3301 # that (eg) "make install-exec" will run "install-exec-recursive"
3302 # if required, but "make install" won't run it twice. Step one is
3303 # to see if the user specified local versions of any of the
3304 # targets we handle. "all" is treated as one of these since
3305 # "install" can run it.
3306 push (@install_exec, 'install-exec-local')
3307 if defined $contents{'install-exec-local'};
3308 push (@install_data, 'install-data-local')
3309 if defined $contents{'install-data-local'};
3310 push (@uninstall, 'uninstall-local')
3311 if defined $contents{'uninstall-local'};
3313 foreach $utarg ('uninstall-data-local', 'uninstall-data-hook',
3314 'uninstall-exec-local', 'uninstall-exec-hook')
3316 if (defined $contents{$utarg})
3319 ($x = $utarg) =~ s/(data|exec)-//;
3320 &am_line_error ($utarg, "use \`$x', not \`$utarg'");
3323 push (@all, 'all-local')
3324 if defined $contents{'all-local'};
3326 if (defined $contents{'install-local'})
3328 &am_line_error ('install-local',
3329 "use \`install-data' or \`install-exec', not \`install'");
3332 # Step two: if we are doing recursive makes, write out the
3333 # appropriate rules.
3335 if ($recursive_install)
3337 push (@install, 'install-recursive');
3341 local (@hackall) = ();
3343 local ($local_headers) = '';
3344 foreach $one_name (@config_names)
3346 if (&dirname ($one_name) eq $relative_dir)
3348 $local_headers .= ' ' if $local_headers;
3349 $local_headers .= &basename ($one_name);
3355 # This is kind of a hack, but I couldn't see a better
3356 # way to handle it. In this particular case, we need
3357 # to make sure config.h is built before we recurse.
3358 # We can't do this by changing the order of
3359 # dependencies to the "all" because that breaks when
3360 # using parallel makes. Instead we handle things
3362 $output_rules .= ("all-recursive-am: ${local_headers}"
3363 . "\n\t" . '$(MAKE) all-recursive'
3365 push (@hackall, 'all-recursive-am');
3366 push (@phony, 'all-recursive-am');
3370 push (@hackall, 'all-recursive');
3373 $output_rules .= ('all-am: '
3377 push (@all, 'all-am');
3378 push (@phony, 'all-am');
3382 @all = ('all-recursive');
3384 # Must always generate `all-am' target, so it can be
3385 # referred to elsewhere.
3386 $output_rules .= "all-am:\n";
3390 $output_rules .= ('install-exec-am: '
3391 . join (' ', @install_exec)
3393 @install_exec = ('install-exec-recursive', 'install-exec-am');
3394 push (@install, 'install-exec-am');
3395 push (@phony, 'install-exec-am');
3399 @install_exec = ('install-exec-recursive');
3403 $output_rules .= ('install-data-am: '
3404 . join (' ', @install_data)
3406 @install_data = ('install-data-recursive', 'install-data-am');
3407 push (@install, 'install-data-am');
3408 push (@phony, 'install-data-am');
3412 @install_data = ('install-data-recursive');
3416 $output_rules .= ('uninstall-am: '
3417 . join (' ', @uninstall)
3419 @uninstall = ('uninstall-recursive', 'uninstall-am');
3420 push (@phony, 'uninstall-am');
3424 @uninstall = ('uninstall-recursive');
3428 # Step three: print definitions users can use. Code below knows
3429 # that install-exec is done before install-data, beware.
3430 $output_rules .= ("install-exec: "
3431 . join (' ', @install_exec)
3433 $output_rules .= "\t\@\$(NORMAL_INSTALL)\n";
3434 if (defined $contents{'install-exec-hook'})
3436 $output_rules .= "\t" . '$(MAKE) install-exec-hook' . "\n";
3438 $output_rules .= "\n";
3439 push (@install, 'install-exec') if !$recursive_install;
3440 push (@phony, 'install-exec');
3442 $output_rules .= ("install-data: "
3443 . join (' ', @install_data)
3445 $output_rules .= "\t\@\$(NORMAL_INSTALL)\n";
3446 if (defined $contents{'install-data-hook'})
3448 $output_rules .= "\t" . '$(MAKE) install-data-hook' . "\n";
3450 $output_rules .= "\n";
3451 push (@install, 'install-data') if !$recursive_install;
3452 push (@phony, 'install-data');
3454 # If no dependencies for 'install', add 'all'. Why? That way
3455 # "make install" at top level of distclean'd distribution won't
3456 # fail because stuff in 'lib' fails to build.
3457 if (! @install || (scalar (@install) == 2
3458 && $install[0] eq 'install-exec'
3459 && $install[1] eq 'install-data'))
3461 push (@install, 'all');
3463 $output_rules .= ('install: '
3464 . join (' ', @install)
3465 # Use "@:" as empty command so nothing prints.
3469 . join (' ', @uninstall)
3471 push (@phony, 'install', 'uninstall');
3473 $output_rules .= ('all: '
3476 push (@phony, 'all');
3478 # Generate the new 'install-strip' target. Must set
3479 # INSTALL_SCRIPT to avoid stripping scripts.
3480 $output_rules .= ("install-strip:\n\t"
3481 . '$(MAKE) INSTALL_PROGRAM=\'$(INSTALL_PROGRAM) -s\' INSTALL_SCRIPT=\'$(INSTALL_PROGRAM)\' install'
3485 # Helper for handle_merge_targets.
3486 sub do_one_merge_target
3488 local ($name, @values) = @_;
3490 if (defined $contents{$name . '-local'})
3492 # User defined local form of target. So include it.
3493 push (@values, $name . '-local');
3494 push (@phony, $name . '-local');
3497 &pretty_print_rule ($name . ":", "\t\t", @values);
3498 push (@phony, $name);
3501 # Handle check merge target specially.
3502 sub do_check_merge_target
3504 if (defined $contents{'check-local'})
3506 # User defined local form of target. So include it.
3507 push (@check_tests, 'check-local');
3508 push (@phony, 'check-local');
3511 # In --cygnus mode, check doesn't depend on all.
3514 if (! &variable_defined ('SUBDIRS'))
3516 # 'check' must depend on `all', but not when doing
3518 unshift (@check, 'all');
3522 # When subdirs are used, do the `all' build and then do
3523 # all the recursive stuff. Actually use `all-am' because
3524 # it doesn't recurse; we rely on the check target in the
3525 # subdirs to do the required builds there.
3526 unshift (@check, 'all-am');
3530 # The check target must depend on the local equivalent of `all',
3531 # to ensure all the primary targets are built. Also it must
3532 # depend on the test code named in @check.
3533 &pretty_print_rule ('check:', "\t\t", @check);
3535 # Now the check rules must explicitly run anything named in
3536 # @check_tests. This is done via a separate make invocation to
3537 # avoid problems with parallel makes. Every time I write code
3538 # like this I wonder: how could you invent a parallel make and not
3539 # provide any real synchronization facilities?
3540 &pretty_print_rule ("\t\$(MAKE)", "\t ", @check_tests);
3543 # Handle all 'clean' targets.
3546 push (@clean, 'generic');
3547 $output_rules .= &file_contents ('clean');
3548 &push_phony_cleaners ('generic');
3550 local ($target) = $recursive_install ? 'clean-am' : 'clean';
3551 &do_one_clean_target ($target, 'mostly', '', @clean);
3552 &do_one_clean_target ($target, '', 'mostly', @clean);
3553 &do_one_clean_target ($target, 'dist', '', @clean);
3554 &do_one_clean_target ($target, 'maintainer-', 'dist', @clean);
3556 push (@phony, 'clean', 'mostlyclean', 'distclean', 'maintainer-clean');
3559 if ($recursive_install)
3561 # Do -recursive before -am. If you aren't doing a parallel
3562 # make, this can be nicer.
3563 @deps = ('recursive', 'am');
3564 &do_one_clean_target ('', 'mostly', '', @deps);
3565 &do_one_clean_target ('', '', '', @deps);
3566 &do_one_clean_target ('', 'dist', '', @deps);
3567 &do_one_clean_target ('', 'maintainer-', '', @deps);
3571 # Helper for handle_clean.
3572 sub do_one_clean_target
3574 local ($target, $name, $last_name, @deps) = @_;
3576 # Special case: if target not passed, then don't generate
3577 # dependency on next "lower" clean target (eg no
3578 # clean<-mostlyclean derivation). In this case the target is
3579 # implicitly known to be 'clean'.
3580 local ($flag) = $target;
3581 $target = 'clean' if ! $flag;
3583 grep (($_ = $name . 'clean-' . $_) && 0, @deps);
3586 if ($last_name || $name ne 'mostly')
3588 push (@deps, $last_name . $target);
3592 # If a -local version of the rule is given, add it to the list.
3593 if (defined $contents{$name . $target . '-local'})
3595 push (@deps, $name . $target . '-local');
3598 # Print the target and the dependencies.
3599 &pretty_print_rule ($name . $target . ": ", "\t\t", @deps);
3601 # FIXME: shouldn't we really print these messages before running
3603 if ($name . $target eq 'maintainer-clean')
3605 # Print a special warning.
3607 ("\t\@echo \"This command is intended for maintainers to use;\"\n"
3608 . "\t\@echo \"it deletes files that may require special "
3609 . "tools to rebuild.\"\n");
3611 $output_rules .= "\trm -f config.status\n"
3612 if $relative_dir eq '.';
3614 elsif ($name . $target eq 'distclean')
3616 $output_rules .= "\trm -f config.status\n";
3617 $output_rules .= "\trm -f libtool\n" if $seen_libtool;
3619 $output_rules .= "\n";
3622 # Handle .PHONY target.
3625 &pretty_print_rule ('.PHONY:', "", @phony);
3626 $output_rules .= "\n";
3629 # Handle TESTS variable and other checks.
3632 if (defined $options{'dejagnu'})
3634 push (@check_tests, 'check-DEJAGNU');
3635 push (@phony, 'check-DEJAGNU');
3640 $xform = 's/^CYGNUS//;';
3644 $xform = 's/^CYGNUS.*$//;';
3646 $output_rules .= &file_contents_with_transform ($xform, 'dejagnu');
3648 # In Cygnus mode, these are found in the build tree.
3649 # Otherwise they are looked for in $PATH.
3650 &define_program_variable ('EXPECT', 'build', 'expect', 'expect');
3651 &define_program_variable ('RUNTEST', 'src', 'dejagnu', 'runtest');
3653 # Note that in the rule we don't directly generate site.exp to
3654 # avoid the possibility of a corrupted site.exp if make is
3655 # interrupted. Jim Meyering has some useful text on this
3657 $output_rules .= ("site.exp: Makefile\n"
3658 . "\t\@echo 'Making a new site.exp file...'\n"
3659 . "\t-\@rm -f site.bak\n"
3660 . "\t\@echo '## these variables are automatically generated by make ##' > \$\@-t\n"
3661 . "\t\@echo '# Do not edit here. If you wish to override these values' >> \$\@-t\n"
3662 . "\t\@echo '# edit the last section' >> \$\@-t\n"
3663 . "\t\@echo 'set tool \$(DEJATOOL)' >> \$\@-t\n"
3664 . "\t\@echo 'set srcdir \$(srcdir)' >> \$\@-t\n"
3665 . "\t\@echo 'set objdir' \`pwd\` >> \$\@-t\n");
3667 # Extra stuff for AC_CANONICAL_*
3668 local (@whatlist) = ();
3669 if ($seen_canonical)
3671 push (@whatlist, 'host')
3674 # Extra stuff only for AC_CANONICAL_SYSTEM.
3675 if ($seen_canonical == $AC_CANONICAL_SYSTEM)
3677 push (@whatlist, 'target', 'build');
3681 foreach $c1 (@whatlist)
3683 foreach $c2 ('alias', 'triplet')
3685 $output_rules .= "\t\@echo 'set ${c1}_${c2} \$(${c1}_${c2})' >> \$\@-t\n";
3689 $output_rules .= ("\t\@echo '## All variables above are generated by configure. Do Not Edit ##' >> \$\@-t\n"
3690 . "\t-\@sed '1,/^## All variables above are.*##/ d' site.bak >> \$\@-t\n"
3691 . "\t-\@mv site.exp site.bak\n"
3692 . "\t\@mv \$\@-t site.exp\n");
3697 foreach $c ('DEJATOOL', 'RUNTEST', 'RUNTESTFLAGS')
3699 if (&variable_defined ($c))
3701 &am_line_error ($c, "\`$c' defined but \`dejagnu' not in \`AUTOMAKE_OPTIONS'");
3706 if (&variable_defined ('TESTS'))
3708 push (@check_tests, 'check-TESTS');
3709 push (@phony, 'check-TESTS');
3711 $output_rules .= 'check-TESTS: $(TESTS)
3712 @failed=0; all=0; \\
3713 srcdir=$(srcdir); export srcdir; \\
3714 for tst in $(TESTS); do \\
3715 if test -f $$tst; then dir=.; \\
3716 else dir="$(srcdir)"; fi; \\
3717 if $(TESTS_ENVIRONMENT) $$dir/$$tst; then \\
3718 all=`expr $$all + 1`; \\
3719 echo "PASS: $$tst"; \\
3720 elif test $$? -ne 77; then \\
3721 all=`expr $$all + 1`; \\
3722 failed=`expr $$failed + 1`; \\
3723 echo "FAIL: $$tst"; \\
3726 if test "$$failed" -eq 0; then \\
3727 banner="All $$all tests passed"; \\
3729 banner="$$failed of $$all tests failed"; \\
3731 dashes=`echo "$$banner" | sed s/./=/g`; \\
3735 test "$$failed" -eq 0
3740 # Handle Emacs Lisp.
3741 sub handle_emacs_lisp
3743 local (@elfiles) = &am_install_var ('lisp', 'LISP', 'lisp', 'noinst');
3748 &define_configure_variable ('lispdir');
3749 &define_configure_variable ('EMACS');
3750 $output_rules .= (".el.elc:\n"
3751 . "\t\@echo 'WARNING: Warnings can be ignored. :-)'\n"
3752 . "\tif test \$(EMACS) != no; then \\\n"
3753 . "\t EMACS=\$(EMACS) \$(SHELL) \$(srcdir)/elisp-comp \$<; \\\n"
3755 push (@suffixes, '.el', '.elc');
3757 # Generate .elc files.
3758 grep ($_ .= 'c', @elfiles);
3759 &define_pretty_variable ('ELCFILES', '', @elfiles);
3761 $output_rules .= &file_contents ('lisp-clean');
3762 push (@clean, 'lisp');
3763 &push_phony_cleaners ('lisp');
3765 push (@all, '$(ELCFILES)');
3768 if (&variable_defined ('lisp_LISP'))
3770 $varname = 'lisp_LISP';
3771 &am_error ("\`lisp_LISP' defined but \`AM_PATH_LISPDIR' not in \`configure.in'")
3776 $varname = 'noinst_LISP';
3779 &require_file_with_line ($varname, $FOREIGN, 'elisp-comp');
3783 ################################################################
3785 # Scan one file for interesting things. Subroutine of scan_configure.
3786 sub scan_one_configure_file
3788 local ($filename) = @_;
3790 open (CONFIGURE, $filename)
3791 || die "automake: couldn't open \`$filename': $!\n";
3792 print "automake: reading $filename\n" if $verbose;
3796 # Remove comments from current line.
3800 # Skip macro definitions. Otherwise we might be confused into
3801 # thinking that a macro that was only defined was actually
3805 # Populate libobjs array.
3806 if (/AC_FUNC_ALLOCA/)
3808 $libsources{'alloca.c'} = 1;
3810 elsif (/AC_FUNC_GETLOADAVG/)
3812 $libsources{'getloadavg.c'} = 1;
3814 elsif (/AC_FUNC_MEMCMP/)
3816 $libsources{'memcmp.c'} = 1;
3818 elsif (/AC_STRUCT_ST_BLOCKS/)
3820 $libsources{'fileblocks.c'} = 1;
3822 elsif (/A[CM]_REPLACE_GNU_GETOPT/)
3824 $libsources{'getopt.c'} = 1;
3825 $libsources{'getopt1.c'} = 1;
3827 elsif (/AM_FUNC_STRTOD/)
3829 $libsources{'strtod.c'} = 1;
3831 elsif (/AM_WITH_REGEX/)
3833 $libsources{'rx.c'} = 1;
3834 $libsources{'rx.h'} = 1;
3835 $libsources{'regex.c'} = 1;
3836 $libsources{'regex.h'} = 1;
3837 $omit_dependencies{'rx.h'} = 1;
3838 $omit_dependencies{'regex.h'} = 1;
3840 elsif (/AM_FUNC_MKTIME/)
3842 $libsources{'mktime.c'} = 1;
3844 elsif (/AM_FUNC_ERROR_AT_LINE/)
3846 $libsources{'error.c'} = 1;
3847 $libsources{'error.h'} = 1;
3849 elsif (/AM_FUNC_OBSTACK/)
3851 $libsources{'obstack.c'} = 1;
3852 $libsources{'obstack.h'} = 1;
3854 elsif (/LIBOBJS="(.*)\s+\$LIBOBJS"/
3855 || /LIBOBJS="\$LIBOBJS\s+(.*)"/)
3857 foreach $libobj_iter (split (' ', $1))
3859 if ($libobj_iter =~ /^(.*)\.o$/)
3861 $libsources{$1 . '.c'} = 1;
3866 if (! $in_ac_replace && s/AC_REPLACE_FUNCS\s*\(\[?//)
3872 $in_ac_replace = 0 if s/[\]\)].*$//;
3873 # Remove trailing backslash.
3877 # Need to skip empty elements for Perl 4.
3879 $libsources{$_ . '.c'} = 1;
3883 if (/$obsolete_rx/o)
3886 if ($obsolete_macros{$1})
3888 $hint = '; ' . $obsolete_macros{$1};
3890 &am_conf_line_error ($filename, $., "\`$1' is obsolete$hint");
3893 # Process the AC_OUTPUT macro.
3894 if (! $in_ac_output && s/AC_OUTPUT\s*\(\[?//)
3897 $ac_output_line = $.;
3901 $in_ac_output = 0 if s/[\]\),].*$//;
3903 # Look at potential Makefile.am's.
3908 # Handle $local:$input syntax. Note that we ignore
3909 # every input file past the first, though we keep
3910 # those around for later.
3911 local ($local, $input, @rest) = split (/:/);
3918 # FIXME: should be error if .in is missing.
3919 $input =~ s/\.in$//;
3922 if (-f $input . '.am')
3924 # We have a file that automake should generate.
3925 push (@make_input_list, $input);
3926 $make_list{$input} = join (':', ($local, @rest));
3930 # We have a file that automake should cause to be
3931 # rebuilt, but shouldn't generate itself.
3932 push (@other_input_files, $_);
3937 if (/$AC_CONFIG_AUX_DIR_PATTERN/o)
3939 @config_aux_path = $1;
3942 # Check for ansi2knr.
3943 $am_c_prototypes = 1 if /AM_C_PROTOTYPES/;
3945 # Check for exe extension stuff.
3949 $configure_vars{'EXEEXT'} = 1;
3952 # Check for NLS support.
3953 if (/AM_GNU_GETTEXT/)
3956 $ac_gettext_line = $.;
3957 $omit_dependencies{'libintl.h'} = 1;
3960 # Look for ALL_LINGUAS.
3961 if (/ALL_LINGUAS="(.*)"$/ || /ALL_LINGUAS=(.*)$/)
3965 $all_linguas_line = $.;
3968 # Handle configuration headers. A config header of `[$1]'
3969 # means we are actually scanning AM_CONFIG_HEADER from
3971 if (/A([CM])_CONFIG_HEADER\s*\((.*)\)/
3976 "\`AC_CONFIG_HEADER' is obsolete; use \`AM_CONFIG_HEADER'")
3979 $config_header_line = $.;
3981 foreach $one_hdr (split (' ', $2))
3983 push (@config_fullnames, $one_hdr);
3984 if ($one_hdr =~ /^([^:]+):(.+)$/)
3986 push (@config_names, $1);
3987 push (@config_headers, $2);
3991 push (@config_names, $one_hdr);
3992 push (@config_headers, $one_hdr . '.in');
3997 # Handle AC_CANONICAL_*. Always allow upgrading to
3998 # AC_CANONICAL_SYSTEM, but never downgrading.
3999 $seen_canonical = $AC_CANONICAL_HOST
4000 if ! $seen_canonical
4001 && (/AC_CANONICAL_HOST/ || /AC_CHECK_TOOL/);
4002 $seen_canonical = $AC_CANONICAL_SYSTEM if /AC_CANONICAL_SYSTEM/;
4004 $seen_path_xtra = 1 if /AC_PATH_XTRA/;
4006 # This macro handles several different things.
4007 if (/$AM_INIT_AUTOMAKE_PATTERN/o)
4013 $seen_prog_install = 2;
4014 ($package_version = $1) =~ s/$AM_PACKAGE_VERSION_PATTERN/$1/o;
4015 $package_version_line = $.;
4018 # This is like AM_INIT_AUTOMAKE, but doesn't actually set the
4019 # package and version number. (This might change in the
4020 # future). Yes, I'm not above hacking Automake so it works
4021 # well with other GNU tools -- that is actually the point.
4022 if (/AM_INIT_GUILE_MODULE/)
4028 $seen_prog_install = 2;
4029 @config_aux_path = ('..');
4032 # Some things required by Automake.
4033 $seen_make_set = 1 if /AC_PROG_MAKE_SET/;
4034 $seen_arg_prog = 1 if /AC_ARG_PROGRAM/;
4036 if (/AC_PROG_(YACC|RANLIB|CC|CXX|LEX|AWK|CPP|CXXCPP|LN_S)/)
4038 $configure_vars{$1} = 1;
4040 if (/$AC_CHECK_PATTERN/o)
4042 $configure_vars{$3} = 1;
4044 if (/$AM_MISSING_PATTERN/o
4048 && $1 ne 'AUTOHEADER')
4050 $configure_vars{$1} = 1;
4053 # Explicitly avoid ANSI2KNR -- we AC_SUBST that in protos.m4,
4054 # but later define it elsewhere. This is pretty hacky. We
4055 # also explicitly avoid INSTALL_SCRIPT and some other
4056 # variables because they are defined in header-vars.am.
4058 if (/$AC_SUBST_PATTERN/o
4060 && $1 ne 'INSTALL_SCRIPT')
4062 $configure_vars{$1} = 1;
4065 $seen_decl_yytext = 1 if /AC_DECL_YYTEXT/;
4066 $seen_maint_mode = 1 if /AM_MAINTAINER_MODE/;
4067 $seen_package = 1 if /PACKAGE=/;
4069 # Skip VERSION of [$2]; that is from AM_INIT_AUTOMAKE.
4070 if (/\bVERSION=(\S+)/ && $1 ne '[$2]')
4073 $package_version = $1;
4074 $package_version_line = $.;
4081 # Weird conditionals here because it is always allowed to
4082 # upgrade to AM_PROG_INSTALL but never to downgrade to
4084 $seen_prog_install = 1 if ! $seen_prog_install && /AC_PROG_INSTALL/;
4085 $seen_prog_install = 2 if /AM_PROG_INSTALL/;
4087 $seen_lispdir = 1 if /AM_PATH_LISPDIR/;
4089 if (/AM_PROG_LIBTOOL/)
4093 $configure_vars{'LIBTOOL'} = 1;
4094 $configure_vars{'RANLIB'} = 1;
4095 $configure_vars{'CC'} = 1;
4096 # AM_PROG_LIBTOOL runs AC_CANONICAL_HOST. Make sure we
4097 # never downgrade (if we've seen AC_CANONICAL_SYSTEM).
4098 $seen_canonical = $AC_CANONICAL_HOST if ! $seen_canonical;
4101 if (/$AM_CONDITIONAL_PATTERN/o)
4103 $configure_cond{$1} = 1;
4110 # Scan configure.in and aclocal.m4 for interesting things. We must
4111 # scan aclocal.m4 because there might be AC_SUBSTs and such there.
4114 # Reinitialize libsources here. This isn't really necessary,
4115 # since we currently assume there is only one configure.in. But
4116 # that won't always be the case.
4119 local ($in_ac_output, $in_ac_replace) = (0, 0);
4120 local (%make_list, @make_input_list);
4121 local ($libobj_iter);
4123 &scan_one_configure_file ('configure.in');
4124 &scan_one_configure_file ('aclocal.m4')
4127 # Set input and output files if not specified by user.
4130 @input_files = @make_input_list;
4131 %output_files = %make_list;
4134 &am_conf_error ("\`PACKAGE' not defined in configure.in")
4136 &am_conf_error ("\`VERSION' not defined in configure.in")
4139 # Look for some files we need. Always check for these. This
4140 # check must be done for every run, even those where we are only
4141 # looking at a subdir Makefile. We must set relative_dir so that
4142 # the file-finding machinery works.
4143 local ($relative_dir) = '.';
4144 &require_config_file ($FOREIGN, 'install-sh', 'mkinstalldirs', 'missing');
4145 &am_error ("\`install.sh' is an anachronism; use \`install-sh' instead")
4146 if -f $config_aux_path[0] . '/install.sh';
4149 ################################################################
4151 # Set up for Cygnus mode.
4154 return unless $cygnus_mode;
4156 &set_strictness ('foreign');
4157 $options{'no-installinfo'} = 1;
4158 $options{'no-dependencies'} = 1;
4159 $use_dependencies = 0;
4161 if (! $seen_maint_mode)
4163 &am_conf_error ("\`AM_MAINTAINER_MODE' required when --cygnus specified");
4168 &am_conf_error ("\`AM_EXEEXT' required when --cygnus specified");
4172 # Do any extra checking for GNU standards.
4173 sub check_gnu_standards
4175 if ($relative_dir eq '.')
4177 # In top level (or only) directory.
4178 &require_file ($GNU, 'INSTALL', 'NEWS', 'README', 'COPYING',
4179 'AUTHORS', 'ChangeLog');
4182 if ($strictness >= $GNU)
4184 if (defined $options{'no-installman'})
4186 &am_line_error ('AUTOMAKE_OPTIONS',
4187 "option \`no-installman' disallowed by GNU standards");
4190 if (defined $options{'no-installinfo'})
4192 &am_line_error ('AUTOMAKE_OPTIONS',
4193 "option \`no-installinfo' disallowed by GNU standards");
4198 # Do any extra checking for GNITS standards.
4199 sub check_gnits_standards
4201 if ($strictness >= $GNITS)
4203 if (-f $relative_dir . '/COPYING.LIB')
4205 &am_error ("\`${relative_dir}/COPYING.LIB' disallowed by Gnits standards");
4208 if ($relative_dir eq '.')
4210 if ($package_version !~ /^$GNITS_VERSION_PATTERN$/)
4212 # FIXME: allow real filename.
4213 &am_conf_line_error ('configure.in',
4214 $package_version_line,
4215 "version \`$package_version' doesn't follow Gnits standards");
4217 elsif (defined $1 && -f 'README-alpha')
4219 # This means we have an alpha release. See
4220 # GNITS_VERSION_PATTERN for details.
4221 &require_file ($GNITS, 'README-alpha');
4226 if ($relative_dir eq '.')
4228 # In top level (or only) directory.
4229 &require_file ($GNITS, 'THANKS');
4233 ################################################################
4235 # Pretty-print something. HEAD is what should be printed at the
4236 # beginning of the first line, FILL is what should be printed at the
4237 # beginning of every subsequent line.
4238 sub pretty_print_internal
4240 local ($head, $fill, @values) = @_;
4242 local ($column) = length ($head);
4243 local ($result) = $head;
4245 # Fill length is number of characters. However, each Tab
4246 # character counts for eight. So we count the number of Tabs and
4248 local ($fill_length) = length ($fill);
4249 $fill_length += 7 * ($fill =~ tr/\t/\t/d);
4251 local ($bol) = ($head eq '');
4254 # "71" because we also print a space.
4255 if ($column + length ($_) > 71)
4257 $result .= " \\\n" . $fill;
4258 $column = $fill_length;
4262 $result .= ' ' unless ($bol);
4264 $column += length ($_) + 1;
4272 # Pretty-print something and append to output_vars.
4275 $output_vars .= &pretty_print_internal (@_);
4278 # Pretty-print something and append to output_rules.
4279 sub pretty_print_rule
4281 $output_rules .= &pretty_print_internal (@_);
4285 ################################################################
4287 # See if a target exists.
4290 local ($target) = @_;
4291 return defined $targets{$target};
4294 # See if two conditionals are the same.
4295 sub conditional_same
4297 local ($cond1, $cond2) = @_;
4299 return (&conditional_true_when ($cond1, $cond2)
4300 && &conditional_true_when ($cond2, $cond1));
4303 # See if a conditional is true. Both arguments are conditional
4304 # strings. This returns true if the first conditional is true when
4305 # the second conditional is true.
4306 sub conditional_true_when
4308 local ($cond, $when) = @_;
4310 # Check the easy case first.
4316 # Check each component of $cond, which looks @COND1@@COND2@.
4317 foreach $comp (split ('@', $cond))
4319 # The way we split will give null strings between each
4323 if (index ($when, '@' . $comp . '@') == -1)
4332 # Check for an ambiguous conditional. This is called when a variable
4333 # or target is being defined conditionally. If we already know about
4334 # a definition that is true under the same conditions, then we have an
4336 sub check_ambiguous_conditional
4338 local ($var_name, $cond) = @_;
4339 local (@cond_vals) = split (' ', $conditional{$var_name});
4342 local ($vcond) = shift (@cond_vals);
4344 if (&conditional_true_when ($vcond, $cond)
4345 || &conditional_true_when ($cond, $vcond))
4347 &am_line_error ($var_name,
4348 "$var_name multiply defined in condition");
4353 # See if a variable exists. The first argument is the variable name,
4354 # and the optional second argument is the condition which we should
4355 # check. If no condition is given, we currently return true if the
4356 # variable is defined under any condition.
4357 sub variable_defined
4359 local ($var, $cond) = @_;
4360 if (defined $targets{$var})
4362 &am_line_error ($var, "\`$var' is target; expected variable");
4365 elsif (defined $contents{$var})
4367 if ($cond && $conditional{$var})
4369 # We have been asked to check for a particular condition,
4370 # and the variable is defined conditionally. We need to
4371 # look through the conditions under which the variable is
4372 # defined, and see if any of them match the conditional we
4373 # have been asked to check.
4374 local (@cond_vars) = split (' ', $conditional{$var});
4377 if (&conditional_same ($cond, shift (@cond_vars)))
4379 # Even a conditional examination is good enough
4380 # for us. FIXME: really should maintain examined
4381 # status on a per-condition basis.
4382 $content_seen{$var} = 1;
4388 # The variable is not defined for the given condition.
4392 $content_seen{$var} = 1;
4398 # Mark a variable as examined.
4399 sub examine_variable
4402 &variable_defined ($var);
4405 # Quote a value in order to put it in $conditional. We need to quote
4406 # spaces, and we need to handle null strings, so that we can later
4407 # retrieve values by splitting on space.
4412 $val = '\002' if $val eq '';
4416 # Unquote a value in $conditional.
4417 sub unquote_cond_val
4421 $val = '' if $val eq '\002';
4425 # Return the set of conditions for which a variable is defined.
4427 # If the variable is not defined conditionally, and is not defined in
4428 # terms of any variables which are defined conditionally, then this
4429 # returns the empty list.
4431 # If the variable is defined conditionally, but is not defined in
4432 # terms of any variables which are defined conditionally, then this
4433 # returns the list of conditions for which the variable is defined.
4435 # If the variable is defined in terms of any variables which are
4436 # defined conditionally, then this returns a full set of permutations
4437 # of the subvariable conditions. For example, if the variable is
4438 # defined in terms of a variable which is defined for @COND_TRUE@,
4439 # then this returns both @COND_TRUE@ and @COND_FALSE@. This is
4440 # because we will need to define the variable under both conditions.
4442 sub variable_conditions
4448 foreach $cond (&variable_conditions_sub ($var, '', ()))
4450 $uniqify{$cond} = 1;
4453 return keys %uniqify;
4456 # A subroutine of variable_conditions. We only return conditions
4457 # which are true for all the conditions in @PARENT_CONDS.
4458 sub variable_conditions_sub
4460 local ($var, $parent, @parent_conds) = @_;
4461 local (@new_conds) = ();
4463 if (! $conditional{$var})
4465 foreach (split (' ', $contents{$var}))
4467 # If a comment seen, just leave.
4470 # Handle variable substitutions.
4471 if (/^\$\{(.*)\}$/ || /^\$\((.*)\)$/)
4474 &variable_conditions_sub ($1, $var, @parent_conds));
4478 return &variable_conditions_reduce (@new_conds);
4481 local (@this_conds) = ();
4482 local (@condvals) = split (' ', $conditional{$var});
4485 local ($cond) = shift (@condvals);
4486 local ($val) = &unquote_cond_val (shift (@condvals));
4491 local ($parent_cond);
4492 foreach $parent_cond (@parent_conds)
4494 if (! &conditional_true_when ($parent_cond, $cond))
4504 push (@this_conds, $cond);
4506 push (@parent_conds, $cond);
4507 local (@subvar_conds) = ();
4508 foreach (split (' ', $val))
4510 # If a comment seen, just leave.
4513 # Handle variable substitutions.
4514 if (/^\$\{(.*)\}$/ || /^\$\((.*)\)$/)
4516 push (@subvar_conds,
4517 &variable_conditions_sub ($1, $var, @parent_conds));
4520 pop (@parent_conds);
4522 # If there are no conditional subvariables, then we want to
4523 # return this condition. Otherwise, we want to return the
4524 # permutations of the subvariables.
4525 if (! @subvar_conds)
4527 push (@new_conds, $cond);
4531 push (@new_conds, &variable_conditions_reduce (@subvar_conds));
4538 # If we are being called on behalf of another variable, we need to
4539 # return all possible permutations of the conditions. We have
4540 # already handled everything in @this_conds along with their
4541 # subvariables. We now need to add any permutations that are not
4544 foreach $this_cond (@this_conds)
4547 &variable_conditions_permutations (split('@', $this_cond));
4549 foreach $perm (@perms)
4553 foreach $scan (@this_conds)
4555 if (&conditional_true_when ($perm, $scan)
4556 || &conditional_true_when ($scan, $perm))
4567 local ($parent_cond);
4568 foreach $parent_cond (@parent_conds)
4570 if (! &conditional_true_when ($parent_cond, $perm))
4580 # This permutation was not already handled, and is valid
4582 push (@new_conds, $perm);
4589 # Subroutine for variable_conditions_sort
4590 sub variable_conditions_cmp
4596 return (length ($as) <=> length ($bs)
4600 # Sort a list of conditionals so that only the exclusive ones are
4601 # retained. For example, if both @COND1_TRUE@@COND2_TRUE@ and
4602 # @COND1_TRUE@ are in the list, discard the latter.
4603 sub variable_conditions_reduce
4605 local (@conds) = @_;
4608 foreach $cond (sort variable_conditions_cmp @conds)
4612 foreach $scan (@ret)
4614 if (&conditional_true_when ($cond, $scan))
4627 # Return a list of permutations of a conditional string.
4628 sub variable_conditions_permutations
4630 local (@comps) = @_;
4633 local ($comp) = shift (@comps);
4634 return &variable_conditions_permutations (@comps)
4636 local ($neg) = $comp;
4637 $neg =~ s/TRUE$/TRUEO/;
4638 $neg =~ s/FALSE$/TRUE/;
4639 $neg =~ s/TRUEO$/FALSE/;
4642 foreach $sub (&variable_conditions_permutations (@comps))
4644 push (@ret, '@' . $comp . '@' . $sub);
4645 push (@ret, '@' . $neg . '@' . $sub);
4649 push (@ret, '@' . $comp . '@');
4650 push (@ret, '@' . $neg . '@');
4655 # Warn if a variable is conditionally defined. This is called if we
4656 # are using the value of a variable.
4657 sub variable_conditionally_defined
4659 local ($var, $parent) = @_;
4660 if ($conditional{$var})
4664 &am_line_error ($parent,
4665 "warning: automake does not support conditional definition of $var in $parent");
4669 &am_line_error ($parent,
4670 "warning: automake does not support $var being defined conditionally")
4675 # Get the value of a variable. This just returns $contents, but warns
4676 # if the variable is conditionally defined.
4680 &variable_conditionally_defined ($var);
4681 return $contents{$var};
4684 # Convert a variable value to a list, split as whitespace. This will
4685 # recursively follow $(...) and ${...} inclusions. It preserves @...@
4686 # substitutions. If COND is 'all', then all values under all
4687 # conditions should be returned; if COND is a particular condition
4688 # (all conditions are surrounded by @...@) then only the value for
4689 # that condition should be returned; otherwise, warn if VAR is
4690 # conditionally defined.
4693 local ($var, $val, $cond) = @_;
4696 foreach (split (' ', $val))
4698 # If a comment seen, just leave.
4701 # Handle variable substitutions.
4702 if (/^\$\{([^}]*)\}$/ || /^\$\(([^)]*)\)$/)
4704 local ($varname) = $1;
4706 # If the user uses a losing variable name, just ignore it.
4707 # This isn't ideal, but people have requested it.
4708 next if ($varname =~ /\@.*\@/);
4712 if ($varname =~ /^([^:]*):([^=]*)=(.*)$/)
4716 ($from = $2) =~ s/(\W)/\\$1/g;
4720 @temp_list = &variable_value_as_list ($1, $cond, $var);
4722 # Now rewrite the value if appropriate.
4725 grep (s/$from$/$to/, @temp_list);
4728 push (@result, @temp_list);
4739 # Return contents of variable as list, split as whitespace. This will
4740 # recursively follow $(...) and ${...} inclusions. It preserves @...@
4741 # substitutions. If COND is 'all', then all values under all
4742 # conditions should be returned; if COND is a particular condition
4743 # (all conditions are surrounded by @...@) then only the value for
4744 # that condition should be returned; otherwise, warn if VAR is
4745 # conditionally defined. If PARENT is specified, it is the name of
4746 # the including variable; this is only used for error reports.
4747 sub variable_value_as_list
4749 local ($var, $cond, $parent) = @_;
4752 if (defined $targets{$var})
4754 &am_line_error ($var, "\`$var' is target; expected variable");
4756 elsif (! defined $contents{$var})
4758 &am_line_error ($parent, "variable \`$var' not defined");
4760 elsif ($cond eq 'all' && $conditional{$var})
4762 local (@condvals) = split (' ', $conditional{$var});
4766 local ($val) = &unquote_cond_val (shift (@condvals));
4767 push (@result, &value_to_list ($var, $val, $cond));
4770 elsif ($cond && $conditional{$var})
4772 local (@condvals) = split (' ', $conditional{$var});
4776 local ($vcond) = shift (@condvals);
4777 local ($val) = &unquote_cond_val (shift (@condvals));
4778 if (&conditional_true_when ($vcond, $cond))
4780 # Warn if we have an ambiguity. It's hard to know how
4781 # to handle this case correctly.
4782 &variable_conditionally_defined ($var, $parent)
4785 push (@result, &value_to_list ($var, $val, $cond));
4791 &variable_conditionally_defined ($var, $parent);
4792 $content_seen{$var} = 1;
4793 push (@result, &value_to_list ($var, $contents{$var}, $cond));
4799 # Define a new variable, but only if not already defined.
4802 local ($var, $value) = @_;
4804 if (! defined $contents{$var})
4806 $output_vars .= $var . ' = ' . $value . "\n";
4807 $contents{$var} = $value;
4808 $content_seen{$var} = 1;
4812 # Like define_variable, but the value is a list, and the variable may
4813 # be defined conditionally. The second argument is the conditional
4814 # under which the value should be defined; this should be the empty
4815 # string to define the variable unconditionally. The third argument
4816 # is a list holding the values to use for the variable. The value is
4817 # pretty printed in the output file.
4818 sub define_pretty_variable
4820 local ($var, $cond, @value) = @_;
4821 if (! defined $contents{$var}
4822 || ($cond && ! &variable_defined ($var, $cond)))
4824 $contents{$var} = join (' ', @value);
4827 if ($conditional{$var})
4829 $conditional{$var} .= ' ';
4833 $conditional{$var} = '';
4835 $conditional{$var} .= ($cond
4837 . "e_cond_val ($contents{$var}));
4839 &pretty_print ($cond . $var . ' = ', $cond, @value);
4840 $content_seen{$var} = 1;
4844 # Like define_variable, but define a variable to be the configure
4845 # substitution by the same name.
4846 sub define_configure_variable
4849 local ($value) = '@' . $var . '@';
4850 &define_variable ($var, $value);
4853 # Define a variable that represents a program to run. If in Cygnus
4854 # mode, the program is searched for in the build (or source) tree.
4855 # Otherwise no searching is done at all. Arguments are:
4856 # * VAR Name of variable to define
4857 # * WHATDIR Either `src' or `build', depending on where program should
4858 # be found. (runtest is in srcdir!)
4859 # * SUBDIR Subdir of top-level dir
4860 # * PROGRAM Name of program
4861 # * OVERRIDE If specified, the name of the program to use when not in
4862 # Cygnus mode. Defaults to PROGRAM.
4863 sub define_program_variable
4865 local ($var, $whatdir, $subdir, $program, $override) = @_;
4869 $override = $program;
4874 local ($full) = ('$(top_' . $whatdir . 'dir)/../'
4875 . $subdir . '/' . $program);
4876 &define_variable ($var, ('`if test -f ' . $full
4877 . '; then echo ' . $full . '; else echo '
4878 . $program . '; fi`'));
4882 &define_variable ($var, $override);
4887 ################################################################
4889 # Read Makefile.am and set up %contents. Simultaneously copy lines
4890 # from Makefile.am into $output_trailer or $output_vars as
4891 # appropriate. NOTE we put rules in the trailer section. We want
4892 # user rules to come after our generated stuff.
4895 local ($amfile) = @_;
4897 open (AM_FILE, $amfile) || die "automake: couldn't open \`$amfile': $!\n";
4898 print "automake: reading $amfile\n" if $verbose;
4900 $output_vars = ("# $in_file_name generated automatically by automake "
4901 . $VERSION . " from $am_file_name\n");
4903 # Generate copyright for generated Makefile.in.
4904 $output_vars .= $gen_copyright;
4906 local ($saw_bk) = 0;
4907 local ($was_rule) = 0;
4908 local ($spacing) = '';
4909 local ($comment) = '';
4910 local ($last_var_name) = '';
4915 if (/$IGNORE_PATTERN/o)
4917 # Merely delete comments beginning with two hashes.
4919 elsif (/$WHITE_PATTERN/o)
4921 # Stick a single white line before the incoming macro or rule.
4925 elsif (/$COMMENT_PATTERN/o)
4927 # Stick comments before the incoming macro or rule. Make
4928 # sure a blank line preceeds first block of comments.
4929 $spacing = "\n" unless $blank;
4931 $comment .= $spacing . $_;
4940 $output_vars .= $comment . "\n";
4943 local ($am_vars) = '';
4945 local ($is_ok_macro);
4949 unless substr ($_, -1, 1) eq "\n";
4951 $_ =~ s/\@MAINT\@//g
4952 unless $seen_maint_mode;
4954 if (/$IGNORE_PATTERN/o)
4956 # Merely delete comments beginning with two hashes.
4958 elsif (/$WHITE_PATTERN/o)
4960 # Stick a single white line before the incoming macro or rule.
4963 elsif (/$COMMENT_PATTERN/o)
4965 # Stick comments before the incoming macro or rule.
4966 $comment .= $spacing . $_;
4973 $output_trailer .= join ('', @conditional_stack) . $_;
4978 $am_vars .= join ('', @conditional_stack) . $_;
4980 # Chop newline and backslash if this line is
4981 # continued. FIXME: maybe ensure trailing whitespace
4985 $contents{$last_var_name} .= $_;
4986 if (@conditional_stack)
4988 $conditional{$last_var_name} .= "e_cond_val ($_);
4992 elsif (/$IF_PATTERN/o)
4994 &am_line_error ($., "$1 does not appear in AM_CONDITIONAL")
4995 if (! $configure_cond{$1});
4996 push (@conditional_stack, "\@" . $1 . "_TRUE\@");
4998 elsif (/$ELSE_PATTERN/o)
5000 if (! @conditional_stack)
5002 &am_line_error ($., "else without if");
5004 elsif ($conditional_stack[$#conditional_stack] =~ /_FALSE\@$/)
5006 &am_line_error ($., "else after else");
5010 $conditional_stack[$#conditional_stack]
5011 =~ s/_TRUE\@$/_FALSE\@/;
5014 elsif (/$ENDIF_PATTERN/o)
5016 if (! @conditional_stack)
5018 &am_line_error ($., "endif without if");
5022 pop @conditional_stack;
5025 elsif (/$RULE_PATTERN/o)
5029 if (defined $contents{$1}
5030 && (@conditional_stack
5031 ? ! defined $conditional{$1}
5032 : defined $conditional{$1}))
5035 "$1 defined both conditionally and unconditionally");
5037 # Value here doesn't matter; for targets we only note
5041 local ($cond_string) = join ('', @conditional_stack);
5042 if (@conditional_stack)
5044 if ($conditional{$1})
5046 &check_ambiguous_conditional ($1, $cond_string);
5047 $conditional{$1} .= ' ';
5051 $conditional{$1} = '';
5053 $conditional{$1} .= $cond_string . ' 1';
5055 $content_lines{$1} = $.;
5056 $output_trailer .= $comment . $spacing . $cond_string . $_;
5057 $comment = $spacing = '';
5060 elsif (($is_ok_macro = /$MACRO_PATTERN/o)
5061 || /$BOGUS_MACRO_PATTERN/o)
5063 # Found a macro definition.
5065 $last_var_name = $1;
5066 if (defined $contents{$1}
5067 && (@conditional_stack
5068 ? ! defined $conditional{$1}
5069 : defined $conditional{$1}))
5072 "$1 defined both conditionally and unconditionally");
5074 if ($2 ne '' && substr ($2, -1) eq "\\")
5076 $contents{$last_var_name} = substr ($2, 0, length ($2) - 1);
5080 $contents{$last_var_name} = $2;
5082 local ($cond_string) = join ('', @conditional_stack);
5083 if (@conditional_stack)
5085 if ($conditional{$last_var_name})
5087 &check_ambiguous_conditional ($last_var_name,
5089 $conditional{$last_var_name} .= ' ';
5093 $conditional{$last_var_name} = '';
5095 local ($val) = $contents{$last_var_name};
5096 $conditional{$last_var_name} .= ($cond_string
5098 . "e_cond_val ($val));
5100 $content_lines{$last_var_name} = $.;
5101 $am_vars .= $comment . $spacing . $cond_string . $_;
5102 $comment = $spacing = '';
5106 &am_line_error ($., "bad macro name \`$last_var_name'")
5111 # This isn't an error; it is probably a continued rule.
5112 # In fact, this is what we assume.
5114 $output_trailer .= ($comment . $spacing
5115 . join ('', @conditional_stack) . $_);
5116 $comment = $spacing = '';
5123 $output_trailer .= $comment;
5125 &am_error ("unterminated conditionals: " . join (' ', @conditional_stack))
5126 if (@conditional_stack);
5128 # Compute relative location of the top object directory.
5129 local (@topdir) = ();
5130 foreach (split (/\//, $relative_dir))
5132 next if $_ eq '.' || $_ eq '';
5139 push (@topdir, '..');
5142 @topdir = ('.') if ! @topdir;
5144 $top_builddir = join ('/', @topdir);
5146 ($build_rx = $top_builddir) =~ s/(\W)/\\$1/g;
5147 $output_vars .= &file_contents_with_transform
5148 ('s/\@top_builddir\@/' . $build_rx . '/g;',
5151 # Generate some useful variables when AC_CANONICAL_* used. FIXME:
5152 # this should use generic %configure_vars method.
5153 if ($seen_canonical)
5155 local ($curs, %vars);
5156 $vars{'host_alias'} = 'host_alias';
5157 $vars{'host_triplet'} = 'host';
5158 if ($seen_canonical == $AC_CANONICAL_SYSTEM)
5160 $vars{'build_alias'} = 'build_alias';
5161 $vars{'build_triplet'} = 'build';
5162 $vars{'target_alias'} = 'target_alias';
5163 $vars{'target_triplet'} = 'target';
5165 foreach $curs (sort keys %vars)
5167 $output_vars .= "$curs = \@$vars{$curs}\@\n";
5168 $contents{$curs} = "\@$vars{$curs}\@";
5173 foreach $curs (sort keys %configure_vars)
5175 &define_configure_variable ($curs);
5178 $output_vars .= $am_vars;
5181 ################################################################
5183 sub initialize_global_constants
5185 # Values for AC_CANONICAL_*
5186 $AC_CANONICAL_HOST = 1;
5187 $AC_CANONICAL_SYSTEM = 2;
5189 # Associative array of standard directory names. Entry is TRUE if
5190 # corresponding directory should be installed during
5191 # 'install-exec' phase.
5209 # Helper text for dealing with man pages.
5210 $install_man_format =
5211 ' @sect=@SECTION@; \\
5212 inst=`echo "@MANBASE@" | sed \'$(transform)\'`.@FULLSECT@; \\
5213 if test -f $(srcdir)/@MAN@; then file=$(srcdir)/@MAN@; \\
5214 else file=@MAN@; fi; \\
5215 echo " $(INSTALL_DATA) $$file $(mandir)/man$$sect/$$inst"; \\
5216 $(INSTALL_DATA) $$file $(mandir)/man$$sect/$$inst
5219 $uninstall_man_format =
5220 ' inst=`echo "@MANBASE@" | sed \'$(transform)\'`.@FULLSECT@; \\
5221 rm -f $(mandir)/man@SECTION@/$$inst
5224 # Commonly found files we look for and automatically include in
5228 "README", "THANKS", "TODO", "NEWS", "COPYING", "COPYING.LIB",
5229 "INSTALL", "ABOUT-NLS", "ChangeLog", "configure", "configure.in",
5230 "config.guess", "config.sub", "AUTHORS", "BACKLOG", "ABOUT-GNU",
5231 "libversion.in", "mdate-sh", "mkinstalldirs", "install-sh",
5232 'texinfo.tex', "ansi2knr.c", "ansi2knr.1", 'elisp-comp',
5233 'ylwrap', 'acinclude.m4', @libtoolize_files,
5237 # Commonly used files we auto-include, but only sometimes.
5240 "aclocal.m4", "acconfig.h", "config.h.top",
5241 "config.h.bot", "stamp-h.in", 'stamp-vti'
5245 -a, --add-missing add missing standard files to package
5246 --amdir=DIR directory storing config files
5247 --build-dir=DIR directory where build being done (for dependencies)
5248 --cygnus assume program is part of Cygnus-style tree
5249 --foreign set strictness to foreign
5250 --gnits set strictness to gnits
5251 --gnu set strictness to gnu
5252 --help print this help, then exit
5253 -i, --include-deps include generated dependencies in Makefile.in
5254 --no-force only update Makefile.in's that are out of date
5255 -o DIR, --output-dir=DIR
5256 put generated Makefile.in's into DIR
5257 --srcdir-name=DIR name used for srcdir (for dependencies)
5258 -v, --verbose verbosely list files processed
5259 --version print version number, then exit\n";
5261 # Copyright on generated Makefile.ins.
5263 # Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
5264 # This Makefile.in is free software; the Free Software Foundation
5265 # gives unlimited permission to copy and/or distribute it,
5266 # with or without modifications, as long as this notice is preserved.
5269 # Ignore return result from chmod, because it might give an error
5270 # if we chmod a symlink.
5271 $dist_header = "\t" . '-chmod -R a+r $(distdir)' . "\n";
5272 $dist{'dist-tarZ'} = ("\t"
5273 . '$(TAR) chf - $(distdir) | compress -c > $(distdir).tar.Z'
5275 $dist{'dist-shar'} = ("\t"
5276 . 'shar $(distdir) | gzip > $(distdir).shar.gz'
5278 $dist{'dist-zip'} = "\t" . 'zip -rq $(distdir).zip $(distdir)' . "\n";
5279 $dist{'dist'} = "\t" . 'GZIP=$(GZIP) $(TAR) chozf $(distdir).tar.gz $(distdir)' . "\n";
5280 $dist_trailer = "\t" . 'rm -rf $(distdir)' . "\n";
5283 # (Re)-Initialize per-Makefile.am variables.
5284 sub initialize_per_input
5286 # These two variables are used when generating each Makefile.in.
5287 # They hold the Makefile.in until it is ready to be printed.
5290 $output_trailer = '';
5291 $output_header = '';
5293 # Suffixes found during a run.
5296 # This holds the contents of a Makefile.am, as parsed by
5300 # This holds the names which are targets. These also appear in
5304 # For a variable or target which is defined conditionally, this
5305 # holds an array of the conditional values. The array is composed
5306 # of pairs of condition strings (the variables which configure
5307 # will substitute) and values (the value of a target is
5308 # meaningless). For an unconditional variable, this is empty.
5311 # This holds the line numbers at which various elements of
5312 # %contents are defined.
5313 %content_lines = ();
5315 # This holds a 1 if a particular variable was examined.
5318 # This is the conditional stack.
5319 @conditional_stack = ();
5321 # This holds the "relative directory" of the current Makefile.in.
5322 # Eg for src/Makefile.in, this is "src".
5325 # This holds a list of files that are included in the
5329 # List of dependencies for the obvious targets.
5345 # These are pretty obvious, too. They are used to define the
5346 # SOURCES and OBJECTS variables.
5350 # TRUE if current directory holds any C source files.
5351 $dir_holds_sources = 0;
5353 # These variables track inclusion of various compile-related .am
5354 # files. $included_generic_compile is TRUE if the basic code has
5355 # been included. $included_knr_compile is TRUE if the ansi2knr
5356 # code has been included. $included_libtool_compile is TRUE if
5357 # libtool support has been included.
5358 $included_generic_compile = 0;
5359 $included_knr_compile = 0;
5360 $included_libtool_compile = 0;
5362 # TRUE if current directory holds any headers.
5363 $dir_holds_headers = 0;
5365 # TRUE if install targets should work recursively.
5366 $recursive_install = 0;
5371 # Strictness levels.
5372 $strictness = $default_strictness;
5373 $strictness_name = $default_strictness_name;
5375 # Options from AUTOMAKE_OPTIONS.
5378 # Whether or not dependencies are handled. Can be further changed
5379 # in handle_options.
5380 $use_dependencies = $cmdline_use_dependencies;
5383 $local_maint_charset = $maint_charset;
5385 # All yacc and lex source filenames for this directory. Use
5386 # filenames instead of raw count so that multiple instances are
5387 # counted correctly (eg one yacc file can appear in multiple
5388 # programs without harm).
5392 # C++ source extensions we've seen.
5393 %cxx_extensions = ();
5395 # TRUE if we've seen any non-C++ sources. This actually holds a
5396 # line number or the name of a symbol corresponding to a line
5397 # number where the C sources were seen. If it is -1 then it means
5398 # we couldn't (easily) figure out which line of the Makefile.am
5399 # mentioned the sources.
5402 # This is a list of all targets to run during "make dist".
5405 # Keys in this hash are the basenames of files which must depend
5407 %de_ansi_files = ();
5411 ################################################################
5413 # Return contents of a file from $am_dir, automatically skipping
5414 # macros or rules which are already known. Runs command on each line
5415 # as it is read; this command can modify $_.
5416 sub file_contents_with_transform
5418 local ($command, $basename) = @_;
5419 local ($file) = $am_dir . '/' . $basename . '.am';
5421 if ($command ne '' && substr ($command, -1) ne ';')
5423 die "automake: programming error in file_contents_with_transform\n";
5426 open (FC_FILE, $file)
5427 || die "automake: installation error: cannot open \`$file'\n";
5429 # print "automake: reading $file\n" if $verbose;
5431 local ($was_rule) = 0;
5432 local ($result_vars) = '';
5433 local ($result_rules) = '';
5434 local ($comment) = '';
5435 local ($spacing) = "\n";
5436 local ($skipping) = 0;
5441 $_ =~ s/\@MAINT\@//g
5442 unless $seen_maint_mode;
5444 $had_chars = length ($_) && $_ ne "\n";
5446 # If the transform caused all the characters to go away, then
5447 # ignore the line. Why do this? Because in Perl 4, a "next"
5448 # inside of an eval doesn't affect a loop outside the eval.
5449 # So we can't pass in a "transform" that uses next. We used
5450 # to do this. "Empty" also means consisting of a single
5452 next if $had_chars && ($_ eq '' || $_ eq "\n");
5454 if (/$IGNORE_PATTERN/o)
5456 # Merely delete comments beginning with two hashes.
5458 elsif (/$WHITE_PATTERN/o)
5460 # Stick a single white line before the incoming macro or rule.
5463 elsif (/$COMMENT_PATTERN/o)
5465 # Stick comments before the incoming macro or rule.
5466 $comment .= $spacing . $_;
5473 $result_rules .= $_ if ! $skipping;
5477 $result_vars .= $_ if ! $skipping;
5481 elsif (/$RULE_PATTERN/o)
5485 $skipping = defined $contents{$1};
5486 $result_rules .= $comment . $spacing . $_ if ! $skipping;
5487 $comment = $spacing = '';
5490 elsif (/$MACRO_PATTERN/o)
5492 # Found a variable reference.
5494 $skipping = defined $contents{$1};
5495 $result_vars .= $comment . $spacing . $_ if ! $skipping;
5496 $comment = $spacing = '';
5501 # This isn't an error; it is probably a continued rule.
5502 # In fact, this is what we assume.
5504 $result_rules .= $comment . $spacing . $_ if ! $skipping;
5505 $comment = $spacing = '';
5511 return $result_vars . $result_rules . $comment;
5514 # Like file_contents_with_transform, but no transform.
5517 return &file_contents_with_transform ('', @_);
5520 # Find all variable prefixes that are used for install directories. A
5521 # prefix `zar' qualifies iff:
5522 # * `zardir' is a variable.
5523 # * `zar_PRIMARY' is a variable.
5524 sub am_primary_prefixes
5526 local ($primary, @prefixes) = @_;
5528 local (%valid, $varname);
5529 grep ($valid{$_} = 0, @prefixes);
5530 $valid{'EXTRA'} = 0;
5531 foreach $varname (keys %contents)
5533 if ($varname =~ /^(.*)_$primary$/)
5535 if (! defined $valid{$1}
5536 && ! &variable_defined ($1 . 'dir')
5537 # Note that a configure variable is always legitimate.
5538 # It is natural to name such variables after the
5539 # primary, so we explicitly allow it.
5540 && ! defined $configure_vars{$varname})
5542 &am_line_error ($varname, "invalid variable \`$varname'");
5546 # Ensure all extended prefixes are actually used.
5555 # Handle `where_HOW' variable magic. Does all lookups, generates
5556 # install code, and possibly generates code to define the primary
5557 # variable. The first argument is the name of the .am file to munge,
5558 # the second argument is the primary variable (eg HEADERS), and all
5559 # subsequent arguments are possible installation locations. Returns
5560 # list of all values of all _HOW targets.
5562 # FIXME: this should be rewritten to be cleaner. It should be broken
5563 # up into multiple functions.
5565 # Usage is: am_install_var (OPTION..., file, HOW, where...)
5570 local ($do_clean) = 0;
5573 if (defined $configure_vars{'LIBTOOL'})
5575 # Transform '@LIBTOOL ...@' to '$(LIBTOOL) ...'
5576 $ltxform = 's/\@LIBTOOL([^\@]*)\@/\$(LIBTOOL) $1/;';
5580 # Delete '@LIBTOOL ...@'
5581 $ltxform = 's/\@LIBTOOL([^\@]*)\@//;';
5587 $cygxform = 's/\@EXEEXT\@//g;';
5591 $cygxform = 's/\@EXEEXT\@/\$(EXEEXT)/g;';
5596 if ($args[0] eq '-clean')
5600 elsif ($args[0] !~ /^-/)
5606 local ($file, $primary, @prefixes) = @args;
5609 local (@result) = ();
5611 # Now that configure substitutions are allowed in where_HOW
5612 # variables, it is an error to actually define the primary.
5613 &am_line_error ($primary, "\`$primary' is an anachronism")
5614 if &variable_defined ($primary);
5617 # Look for misspellings. It is an error to have a variable ending
5618 # in a "reserved" suffix whose prefix is unknown, eg
5619 # "bni_PROGRAMS". However, unusual prefixes are allowed if a
5620 # variable of the same name (with "dir" appended) exists. For
5621 # instance, if the variable "zardir" is defined, then
5622 # "zar_PROGRAMS" becomes valid. This is to provide a little extra
5623 # flexibility in those cases which need it. Perhaps it should be
5624 # disallowed in the Gnits case? The problem is, sometimes it is
5625 # useful to put things in a subdir of eg pkgdatadir, perhaps even
5627 local (%valid) = &am_primary_prefixes ($primary, @prefixes);
5629 # If a primary includes a configure substitution, then the EXTRA_
5630 # form is required. Otherwise we can't properly do our job.
5631 local ($require_extra);
5632 local ($warned_about_extra) = 0;
5634 local ($clean_file) = $file . '-clean';
5637 foreach $X (sort keys %valid)
5639 $one_name = $X . '_' . $primary;
5640 if (&variable_defined ($one_name))
5642 # Append actual contents of where_PRIMARY variable to
5645 foreach $rcurs (&variable_value_as_list ($one_name, 'all'))
5647 # Skip configure substitutions. Possibly bogus.
5648 if ($rcurs =~ /^\@.*\@$/)
5652 if (! $warned_about_extra)
5654 $warned_about_extra = 1;
5655 &am_line_error ($one_name,
5656 "\`$one_name' contains configure substitution, but shouldn't");
5659 # Check here to make sure variables defined in
5660 # configure.in do not imply that EXTRA_PRIMARY
5662 elsif (! defined $configure_vars{$one_name})
5664 $require_extra = $one_name;
5670 push (@result, $rcurs);
5673 # "EXTRA" shouldn't be used when generating clean targets,
5674 # all, or install targets.
5675 next if $X eq 'EXTRA';
5677 # A blatant hack: we rewrite each _PROGRAMS primary to
5678 # include EXEEXT when in Cygwin32 mode.
5679 if ($seen_exeext && $primary eq 'PROGRAMS')
5681 local (@conds) = &variable_conditions ($one_name);
5682 local (@one_binlist);
5684 # FIXME: this definitely loses aesthetically; it
5685 # redefines $ONE_NAME. Instead we should arrange for
5686 # variable definitions to be output later, instead of
5692 foreach $rcurs (&variable_value_as_list ($one_name, ''))
5694 if ($rcurs =~ /\./ || $rcurs =~ /^\@.*\@$/)
5696 push (@one_binlist, $rcurs);
5700 push (@one_binlist, $rcurs . '$(EXEEXT)');
5704 delete $contents{$one_name};
5705 &define_pretty_variable ($one_name, '', @one_binlist);
5710 local ($condvals) = '';
5711 foreach $cond (@conds)
5714 local (@condval) = &variable_value_as_list ($one_name,
5716 foreach $rcurs (@condval)
5718 if ($rcurs =~ /\./ || $rcurs =~ /^\@.*\@$/)
5720 push (@one_binlist, $rcurs);
5724 push (@one_binlist, $rcurs . '$(EXEEXT)');
5728 push (@condvals, $cond);
5729 push (@condvals, join (' ', @one_binlist));
5732 delete $contents{$one_name};
5736 $cond = shift (@condvals);
5737 local (@val) = split (' ', shift (@condvals));
5738 &define_pretty_variable ($one_name, $cond, @val);
5746 &file_contents_with_transform ('s/\@DIR\@/' . $X . '/go;'
5750 push (@clean, $X . $primary);
5751 &push_phony_cleaners ($X . $primary);
5756 push (@check, '$(' . $one_name . ')');
5760 push (@used, '$(' . $one_name . ')');
5762 if ($X eq 'noinst' || $X eq 'check')
5764 # Objects which don't get installed by default.
5769 &file_contents_with_transform ('s/\@DIR\@/' . $X . '/g;'
5770 . $ltxform . $cygxform,
5773 push (@uninstall, 'uninstall-' . $X . $primary);
5774 push (@phony, 'uninstall-' . $X . $primary);
5775 push (@installdirs, '$(' . $X . 'dir)');
5776 if (defined $exec_dir_p{$X} ? $exec_dir_p{$X} : ($X =~ /exec/))
5778 push (@install_exec, 'install-' . $X . $primary);
5779 push (@phony, 'install-' . $X . $primary);
5783 push (@install_data, 'install-' . $X . $primary);
5784 push (@phony, 'install-' . $X . $primary);
5792 &define_pretty_variable ($primary, '', @used);
5793 $output_vars .= "\n";
5796 if ($require_extra && ! &variable_defined ('EXTRA_' . $primary))
5798 &am_line_error ($require_extra,
5799 "\`$require_extra' contains configure substitution, but \`EXTRA_$primary' not defined");
5802 # Push here because PRIMARY might be configure time determined.
5803 push (@all, '$(' . $primary . ')')
5810 ################################################################
5812 # This variable is local to the "require file" set of functions.
5813 @require_file_paths = ();
5815 # Verify that the file must exist in the current directory. Usage:
5816 # require_file (isconfigure, line_number, strictness, file) strictness
5817 # is the strictness level at which this file becomes required. Must
5818 # set require_file_paths before calling this function.
5819 # require_file_paths is set to hold a single directory (the one in
5820 # which the first file was found) before return.
5821 sub require_file_internal
5823 local ($is_configure, $line, $mystrict, @files) = @_;
5824 local ($file, $fullfile);
5825 local ($found_it, $errfile, $errdir);
5828 foreach $file (@files)
5831 foreach $dir (@require_file_paths)
5835 $fullfile = $relative_dir . "/" . $file;
5836 $errdir = $relative_dir unless $errdir;
5840 $fullfile = $dir . "/" . $file;
5841 $errdir = $dir unless $errdir;
5844 # Use different name for "error filename". Otherwise on
5845 # an error the bad file will be reported as eg
5846 # `../../install-sh' when using the default
5848 $errfile = $errdir . '/' . $file;
5853 # FIXME: Once again, special-case `.'.
5854 &push_dist_common ($file)
5855 if $dir eq $relative_dir || $dir eq '.';
5863 # Prune the path list.
5864 @require_file_paths = $save_dir;
5868 if ($strictness >= $mystrict)
5870 local ($trailer) = '';
5871 local ($suppress) = 0;
5873 # Only install missing files according to our desired
5875 local ($message) = "required file \`$errfile' not found";
5880 # Maybe run libtoolize.
5882 && grep ($_ eq $file, @libtoolize_files)
5883 && system ('libtoolize', '--automake'))
5885 $message = "installing \`$errfile'";
5887 $trailer = "; cannot run \`libtoolize': $!";
5889 elsif (-f ($am_dir . '/' . $file))
5891 # Install the missing file. Symlink if we
5892 # can, copy if we must. Note: delete the file
5893 # first, in case it is a dangling symlink.
5894 $message = "installing \`$errfile'";
5896 if ($symlink_exists)
5898 if (! symlink ($am_dir . '/' . $file, $errfile))
5901 $trailer = "; error while making link: $!\n";
5904 elsif (! system ('cp', $am_dir . '/' . $file, $errfile))
5907 $trailer = "\n error while making link\n";
5912 local ($save) = $exit_status;
5915 # FIXME: allow actual file to be specified.
5916 &am_conf_line_error ('configure.in', $line,
5917 "$message$trailer");
5921 &am_line_error ($line, "$message$trailer");
5923 $exit_status = $save if $suppress;
5929 # Like require_file_with_line, but error messages refer to
5930 # configure.in, not the current Makefile.am.
5931 sub require_file_with_conf_line
5933 @require_file_paths = '.';
5934 &require_file_internal (1, @_);
5937 sub require_file_with_line
5939 @require_file_paths = '.';
5940 &require_file_internal (0, @_);
5945 @require_file_paths = '.';
5946 &require_file_internal (0, '', @_);
5949 # Require a file that is also required by Autoconf. Looks in
5950 # configuration path, as specified by AC_CONFIG_AUX_DIR.
5951 sub require_config_file
5953 @require_file_paths = @config_aux_path;
5954 &require_file_internal (1, '', @_);
5955 local ($dir) = $require_file_paths[0];
5956 @config_aux_path = @require_file_paths;
5959 $config_aux_dir = '.';
5963 $config_aux_dir = '$(top_srcdir)/' . $dir;
5967 # Assumes that the line number is in Makefile.am.
5968 sub require_conf_file_with_line
5970 @require_file_paths = @config_aux_path;
5971 &require_file_internal (0, @_);
5972 local ($dir) = $require_file_paths[0];
5973 @config_aux_path = @require_file_paths;
5976 $config_aux_dir = '.';
5980 $config_aux_dir = '$(top_srcdir)/' . $dir;
5984 # Assumes that the line number is in Makefile.am.
5985 sub require_conf_file_with_conf_line
5987 @require_file_paths = @config_aux_path;
5988 &require_file_internal (1, @_);
5989 local ($dir) = $require_file_paths[0];
5990 @config_aux_path = @require_file_paths;
5993 $config_aux_dir = '.';
5997 $config_aux_dir = '$(top_srcdir)/' . $dir;
6001 ################################################################
6003 # Push a list of files onto dist_common.
6004 sub push_dist_common
6006 local (@files) = @_;
6009 foreach $file (@files)
6011 $dist_common{$file} = 1;
6015 # Push a list of clean targets onto phony.
6016 sub push_phony_cleaners
6020 foreach $target ('mostly', 'dist', '', 'maintainer-')
6022 push (@phony, $target . 'clean-' . $base);
6029 $strictness_name = $_[0];
6030 if ($strictness_name eq 'gnu')
6034 elsif ($strictness_name eq 'gnits')
6036 $strictness = $GNITS;
6038 elsif ($strictness_name eq 'foreign')
6040 $strictness = $FOREIGN;
6044 die "automake: level \`$strictness_name' not recognized\n";
6049 ################################################################
6051 # Return directory name of file.
6057 ($sub = $file) =~ s,/+[^/]+$,,g;
6058 $sub = '.' if $sub eq $file;
6062 # Return file name of a file.
6068 ($sub = $file) =~s,^.*/+,,g;
6077 open (TOUCH, ">> $file");
6081 # Glob something. Do this to avoid indentation screwups everywhere we
6082 # want to glob. Gross!
6089 ################################################################
6091 # Print an error message and set exit status.
6094 warn "automake: ${am_file}.am: ", join (' ', @_), "\n";
6100 local ($symbol, @args) = @_;
6102 if ($symbol && "$symbol" ne '-1')
6104 # If SYMBOL not already a line number, look it up in Makefile.am.
6105 if ($symbol =~ /^\d+$/)
6109 elsif (defined $content_lines{$symbol})
6111 $symbol = $content_lines{$symbol} . ': ';
6115 # A single space, to provide nice separation.
6118 warn "${am_file}.am:", $symbol, join (' ', @args), "\n";
6127 # Like am_error, but while scanning configure.in.
6130 # FIXME: can run in subdirs.
6131 warn "automake: configure.in: ", join (' ', @_), "\n";
6135 # Error message with line number referring to configure.in.
6136 sub am_conf_line_error
6138 local ($file, $line, @args) = @_;
6142 warn "$file: $line: ", join (' ', @args), "\n";
6147 &am_conf_error (@args);
6151 # Tell user where our aclocal.m4 is, but only once.
6152 sub keyed_aclocal_warning
6155 warn "automake: macro \`$key' can be generated by \`aclocal'\n";
6158 # Print usage information.
6161 print "Usage: automake [OPTION] ... [Makefile]...\n\n";
6162 print "Generate Makefile.in for autoconf from Makefile.am\n";
6164 print "\nFiles which are automatically distributed, if found:\n";
6165 $~ = "USAGE_FORMAT";
6166 local (@lcomm) = sort ((@common_files, @common_sometimes));
6167 local ($one, $two, $three, $four);
6170 $one = shift @lcomm;
6171 $two = @lcomm ? shift @lcomm : '';
6172 $three = @lcomm ? shift @lcomm : '';
6173 $four = @lcomm ? shift @lcomm : '';
6177 print "\nReport bugs to <automake-bugs\@gnu.ai.mit.edu>.\n";
6182 format USAGE_FORMAT =
6183 @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<
6184 $one, $two, $three, $four