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_CYGWIN32.
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: how to do unsigned comparison?
576 if ($am_time < $in_time)
583 if (! open (GM_FILE, "> " . $out_file))
585 warn "automake: ${am_file}.in: cannot write: $!\n";
589 print "automake: creating ", $makefile, ".in\n" if $verbose;
591 print GM_FILE $output_vars;
592 print GM_FILE $output_header;
593 print GM_FILE $output_rules;
594 print GM_FILE $output_trailer;
599 ################################################################
601 # Handle AUTOMAKE_OPTIONS variable. Return 1 on error, 0 otherwise.
604 return 0 if ! &variable_defined ('AUTOMAKE_OPTIONS');
606 foreach (&variable_value_as_list ('AUTOMAKE_OPTIONS', ''))
609 if ($_ eq 'gnits' || $_ eq 'gnu' || $_ eq 'foreign')
611 &set_strictness ($_);
615 # An option like "../lib/ansi2knr" is allowed. With no
616 # path prefix, we assume the required programs are in this
617 # directory. We save the actual option for later.
618 $options{'ansi2knr'} = $_;
620 elsif ($_ eq 'no-installman' || $_ eq 'no-installinfo'
621 || $_ eq 'dist-shar' || $_ eq 'dist-zip'
622 || $_ eq 'dist-tarZ' || $_ eq 'dejagnu'
623 || $_ eq 'no-texinfo.tex')
625 # Explicitly recognize these.
627 elsif ($_ eq 'no-dependencies')
629 $use_dependencies = 0;
631 elsif (/([0-9]+)\.([0-9]+)/)
633 # Got a version number. Note that alpha releases count as
634 # the next higher release. Note also that we assume there
635 # will be a maximum of 100 minor releases for any given
637 local ($rmajor, $rminor) = ($1, $2);
638 if ($VERSION !~ /([0-9]+)\.([0-9]+)([a-z])?/)
641 "automake: programming error: version is incorrect\n";
644 local ($tmajor, $tminor) = ($1, $2);
645 # Handle alpha versions.
646 ++$tminor if defined $3;
648 if ($rmajor > $tmajor || ($rmajor == $tmajor && $rminor > $tminor))
650 &am_line_error ('AUTOMAKE_OPTIONS',
651 "require version $_, only have $VERSION");
657 &am_line_error ('AUTOMAKE_OPTIONS',
658 'option ', $_, 'not recognized');
665 # Return object extension. Just once, put some code into the output.
666 # Argument is the name of the output file
667 sub get_object_extension
672 $dir_holds_sources = 1;
674 # Maybe require libtool library object files.
675 local ($l, $extension) = ('', 'o');
676 $l = 'l' if ($out =~ /^lib.*\.la$/);
678 if (! $included_generic_compile)
682 if (&variable_defined ('CONFIG_HEADER'))
685 foreach $one_hdr (split (' ', &variable_value ('CONFIG_HEADER')))
688 ($var = &dirname ($one_hdr)) =~ s/(\W)/\\$1/g;
689 $xform .= ' ' if $xform;
690 $xform .= '-I' . $var;
693 $xform = 's/\@CONFIG_INCLUDE_SPEC\@/' . $xform . '/go;';
694 $output_vars .= &file_contents_with_transform ($xform,
696 $output_rules .= &file_contents ('compile');
697 &push_phony_cleaners ('compile');
699 # If using X, include some extra variable definitions. NOTE
700 # we don't want to force these into CFLAGS or anything,
701 # because not all programs will necessarily use X.
705 foreach $var ('X_CFLAGS', 'X_LIBS', 'X_EXTRA_LIBS', 'X_PRE_LIBS')
707 &define_configure_variable ($var);
711 push (@suffixes, '.c', '.o');
712 push (@clean, 'compile');
714 $included_generic_compile = 1;
717 if ($seen_libtool && ! $included_libtool_compile)
719 # Output the libtool compilation rules.
720 $output_rules .= &file_contents ('libtool');
721 &push_phony_cleaners ('libtool');
723 push (@suffixes, '.lo');
724 push (@clean, 'libtool');
726 $included_libtool_compile = 1;
729 # Check for automatic de-ANSI-fication.
730 if (defined $options{'ansi2knr'})
733 if (! $included_knr_compile)
735 if (! $am_c_prototypes)
737 &am_line_error ('AUTOMAKE_OPTIONS',
738 "option \`ansi2knr' in use but \`AM_C_PROTOTYPES' not in configure.in");
739 &keyed_aclocal_warning ('AM_C_PROTOTYPES');
740 # Only give this error once.
741 $am_c_prototypes = 1;
744 push (@suffixes, '._c', '._o');
745 push (@suffixes, '.l_o') if $seen_libtool;
747 # Only require ansi2knr files if they should appear in
749 if ($options{'ansi2knr'} eq 'ansi2knr')
751 &require_file_with_line ('AUTOMAKE_OPTIONS', $FOREIGN,
752 'ansi2knr.c', 'ansi2knr.1');
753 $output_rules .= &file_contents ('kr-extra');
754 push (@clean, 'krextra');
755 &push_phony_cleaners ('krextra');
758 # Generate rules to build ansi2knr. If it is in some
759 # other directory, then generate dependencies but have the
760 # rule just run elsewhere.
761 $output_rules .= ($options{'ansi2knr'} . ': '
762 . $options{'ansi2knr'} . ".o\n");
763 if ($options{'ansi2knr'} eq 'ansi2knr')
765 $output_rules .= ("\t\$(LINK) ansi2knr.o \$(LIBS)\n"
766 . "ansi2knr.o: \$(CONFIG_HEADER)\n\n");
770 $output_rules .= ("\tcd " . &dirname ($options{'ansi2knr'})
771 . " && \$(MAKE) ansi2knr\n\n");
774 &define_variable ('o', "\@U\@o");
776 # Make sure ansi2knr can be found: if no path specified,
778 if ($options{'ansi2knr'} eq 'ansi2knr')
780 # Substitution from AM_C_PROTOTYPES. This makes it be
781 # built only when necessary.
782 &define_configure_variable ('ANSI2KNR');
783 # ansi2knr needs to be built before subdirs, so unshift it.
784 unshift (@all, '$(ANSI2KNR)');
788 # Found in another directory.
789 &define_variable ("ANSI2KNR", $options{'ansi2knr'});
792 $output_rules .= &file_contents ('compile-kr');
793 $output_rules .= &file_contents ('clean-kr');
796 &push_phony_cleaners ('kr');
798 $included_knr_compile = 1;
802 return '.' . $l . $extension;
805 # Handle yacc and lex.
806 sub handle_yacc_lex_cxx
809 # First do yacc and lex.
812 local ($yacc_count) = scalar (keys %yacc_sources);
813 local ($lex_count) = scalar (keys %lex_sources);
817 local (%seen_suffix) = ();
818 foreach (keys %yacc_sources)
821 &output_yacc_build_rule ($1, $yacc_count > 1)
822 if (! defined $seen_suffix{$1});
823 $seen_suffix{$1} = 1;
826 if (! defined $configure_vars{'YACC'})
828 &am_error ("yacc source seen but \`YACC' not defined in \`configure.in'");
833 local (%seen_suffix) = ();
834 foreach (keys %lex_sources)
837 &output_lex_build_rule ($1, $lex_count > 1)
838 if (! defined $seen_suffix{$1});
839 $seen_suffix{$1} = 1;
842 if (! defined $configure_vars{'LEX'})
844 &am_error ("lex source seen but \`LEX' not defined in \`configure.in'");
846 if (! $seen_decl_yytext)
848 &am_error ("lex source seen but \`AC_DECL_YYTEXT' not in \`configure.in'");
852 if ($yacc_count > 1 || $lex_count > 1)
854 # If there is more than one distinct yacc (resp lex) source
855 # file in a given directory, then the `ylwrap' program is
856 # required to allow parallel builds to work correctly. FIXME:
857 # for now, no line number.
858 &require_config_file ($FOREIGN, 'ylwrap');
859 if ($config_aux_dir ne '.' && $config_aux_dir ne '')
861 &define_variable ('YLWRAP', $config_aux_dir . "/ylwrap");
865 &define_variable ('YLWRAP', '$(srcdir)/ylwrap');
872 local ($ltcompile, $ltlink) = ('', '');
875 &define_configure_variable ("LIBTOOL");
876 $ltcompile = '$(LIBTOOL) --mode=compile ';
877 $ltlink = '$(LIBTOOL) --mode=link ';
883 local (@cxx_list) = keys %cxx_extensions;
884 local ($cxx_count) = scalar @cxx_list;
887 push (@suffixes, @cxx_list);
889 &define_configure_variable ("CXXFLAGS");
890 &define_variable ('CXXCOMPILE', '$(CXX) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CXXFLAGS)');
891 &define_variable ('LTCXXCOMPILE',
892 $ltcompile . '$(CXX) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CXXFLAGS)')
895 &define_variable ('CXXLINK', $ltlink . '$(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@');
898 foreach $ext (@cxx_list)
900 $output_rules .= ("$ext.o:\n"
901 . "\t\$(CXXCOMPILE) -c \$<\n");
902 $output_rules .= ("$ext.lo:\n"
903 . "\t\$(LTCXXCOMPILE) -c \$<\n")
907 if (! defined $configure_vars{'CXX'})
909 &am_error ("C++ source seen but \`CXX' not defined in \`configure.in'");
914 # Handle some ansi2knr cleanup.
916 if (defined $options{'ansi2knr'} && keys %de_ansi_objects)
918 # Make all ._o files depend on ansi2knr. Use a sneaky little
919 # hack to make it print nicely.
920 &pretty_print_rule ('', '', ((sort keys %de_ansi_objects),
921 ':', '$(ANSI2KNR)'));
922 # The ._c files also depend on ansi2knr. We need both because
923 # some makes don't apply transitivity through implicit rules.
924 local (%de_ansi_sources, $x);
925 foreach $x (keys %de_ansi_objects)
928 $de_ansi_sources{$x} = 1;
930 &pretty_print_rule ('', '', ((sort keys %de_ansi_sources),
931 ':', '$(ANSI2KNR)'));
935 # Last, handle some C cleanup.
939 &define_configure_variable ('CFLAGS');
940 &define_variable ('COMPILE',
941 '$(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)');
942 &define_variable ('LTCOMPILE',
944 '$(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)')
946 &define_variable ('LINK', $ltlink . '$(CC) $(CFLAGS) $(LDFLAGS) -o $@');
948 if (! defined $configure_vars{'CC'})
950 &am_line_error ($seen_c_source,
951 "C source seen but \`CC' not defined in \`configure.in'");
957 # Output a rule to build from a YACC source. The output from YACC is
958 # compiled with C or C++, depending on the extension of the YACC file.
959 sub output_yacc_build_rule
961 local ($yacc_suffix, $use_ylwrap, $c_suffix) = @_;
963 local ($c_suffix, $suffix);
964 ($c_suffix = $yacc_suffix) =~ tr/y/c/;
965 push (@suffixes, $yacc_suffix, $c_suffix, '.h');
967 # Generate rule for c/c++ and header file. Probably should only
968 # do header if `yacc -d' is run.
969 foreach $suffix ($c_suffix, '.h')
971 $output_rules .= "$yacc_suffix$suffix:\n\t";
975 $output_rules .= ('$(SHELL) $(YLWRAP)'
976 . ' "$(YACC)" $< y.tab.c $*' . $suffix
977 . ' y.tab.h $*.h -- $(YFLAGS)');
981 $output_rules .= ('$(YACC) $(YFLAGS) $< && mv y.tab.c $@' . "\n"
982 . "\tif test -f y.tab.h; then \\\n"
983 . "\tif cmp -s y.tab.h \$*.h; then rm -f y.tab.h; else mv y.tab.h \$*.h; fi; \\\n"
986 $output_rules .= "\n";
990 sub output_lex_build_rule
992 local ($lex_suffix, $use_ylwrap) = @_;
995 ($c_suffix = $lex_suffix) =~ tr/l/c/;
996 push (@suffixes, $lex_suffix);
997 &define_configure_variable ('LEX_OUTPUT_ROOT');
998 &define_configure_variable ('LEXLIB');
999 $output_rules .= "$lex_suffix$c_suffix:\n\t";
1003 # Is the $@ correct here? If so, why not use it in the ylwrap
1004 # build rule for yacc above?
1005 $output_rules .= '$(SHELL) $(YLWRAP)'
1006 . ' "$(LEX)" $< $(LEX_OUTPUT_ROOT).c $@ -- $(LFLAGS)';
1010 $output_rules .= '$(LEX) $(LFLAGS) $< && mv $(LEX_OUTPUT_ROOT).c $@';
1012 $output_rules .= "\n";
1016 # Check to make sure a source defined in LIBOBJS is not explicitly
1017 # mentioned. This is a separate function (as opposed to being inlined
1018 # in handle_source_transform) because it isn't always appropriate to
1020 sub check_libobjs_sources
1022 local ($one_file, $unxformed) = @_;
1024 local ($prefix, $file, @files);
1025 foreach $prefix ('', 'EXTRA_')
1027 if (&variable_defined ($prefix . $one_file . '_SOURCES'))
1029 @files = &variable_value_as_list (($prefix
1030 . $one_file . '_SOURCES'),
1033 elsif ($prefix eq '')
1035 @files = ($unxformed . '.c');
1042 foreach $file (@files)
1044 if (defined $libsources{$file})
1046 &am_line_error ($prefix . $one_file . '_SOURCES',
1047 "automatically discovered file \`$file' should not be explicitly mentioned");
1053 # Does much of the actual work for handle_source_transform.
1055 # list of source files to transform
1057 # first element is name of linker to use (empty string for default linker)
1058 # remaining elements are names of `.o's
1059 sub handle_single_transform_list
1061 local (@files) = @_;
1062 local ($linker) = '';
1063 local (@result) = ();
1064 local ($nonansi_obj) = $obj;
1065 $nonansi_obj =~ s/_//g;
1066 if (length (@files))
1068 # Turn sources into objects.
1071 # Skip header files, including C++-ish ones. The list
1072 # of C++ header extensions comes from Emacs 19.32
1079 # Skip things that look like configure substitutions.
1082 # Include appropriate file for lex or yacc source in
1083 # distribution. If the extension is the regular '.y' or
1084 # '.l', we assume C compilation, and the generated file
1085 # has exension .c. Otherwise, we compile with C++, and
1086 # make the following association: (yy -> cc, y++ -> c++,
1087 # yxx -> cxx), similarly for .ll, etc.
1088 if (/^(.*)\.(y|yy|y\+\+|yxx)$/)
1093 &push_dist_common ("$1.$ext");
1094 $yacc_sources{$_} = 1;
1096 elsif (/^(.*)\.(l|ll|l\+\+|lxx)$/)
1101 &push_dist_common ("$1.$ext");
1102 $lex_sources{$_} = 1;
1105 # Strip any directory prefix.
1106 $_ = &basename ($_);
1108 # Transform source files into .o files. List of C++
1109 # extensions comes from Emacs 19.34 etags.
1110 if (s/\.(c\+\+|cc|cpp|cxx|C)$/$nonansi_obj/)
1112 $cxx_extensions{'.' . $1} = 1;
1113 $linker = 'CXXLINK';
1115 elsif (s/\.(yy|y\+\+|yxx|ll|l\+\+|lxx)$/$nonansi_obj/)
1117 # Compiling lex or yacc with C++
1120 $cxx_extensions{".$ext"} = 1;
1121 $linker = 'CXXLINK';
1123 elsif (s/\.([Ff]\\|f90\\|for)$/$nonansi_obj/)
1125 # FORTRAN support. FIXME: not finished.
1127 elsif (s/\.[sS]$/$nonansi_obj/)
1129 # .s is assembly. Just rewrite it. FIXME: not finished.
1131 elsif (s/\.[cly]$/._o/)
1133 # .c is C. .l is lex. .y is yacc.
1135 # Note: first we rewrite (eg) foo.c to foo._o and push
1136 # the file onto the list of objects that require
1137 # ansi2knr. Then we rewrite ._o to $obj; $obj can be
1138 # simply `.o' if deansification is not really
1140 $de_ansi_objects{$_} = 1;
1142 $seen_c_source = -1 unless $seen_c_source;
1146 # No error message here. Used to have one, but it was
1153 # Transform .o or $o file into .P file (for automatic
1156 $dep_files{'.deps/' . $_} = 1;
1160 return ($linker, @result);
1163 # Handle SOURCE->OBJECT transform for one program or library.
1165 # canonical (transformed) name of object to build
1166 # actual name of object to build
1167 # object extension (ie either `.o' or `$o'.
1168 # Return result is name of linker variable that must be used.
1169 # Empty return means just use `LINK'.
1170 sub handle_source_transform
1172 # one_file is canonical name. unxformed is given name. obj is
1174 local ($one_file, $unxformed, $obj) = @_;
1175 local ($objpat) = $obj;
1176 $objpat =~ s/(\W)/\\$1/g;
1177 # Handle explicit `.o' as well as whatever we're passed.
1178 $objpat = '(' . $objpat . "|\\.o)";
1180 local ($linker) = '';
1182 if (&variable_defined ($one_file . "_OBJECTS"))
1184 &am_line_error ($one_file . '_OBJECTS',
1185 $one_file . '_OBJECTS', 'should not be defined');
1186 # No point in continuing.
1190 local (@files, @result, $prefix, $temp);
1191 foreach $prefix ('', 'EXTRA_')
1194 local ($var) = $prefix . $one_file . "_SOURCES";
1195 if (&variable_defined ($var))
1197 push (@sources, '$(' . $prefix . $one_file . "_SOURCES)");
1198 push (@objects, '$(' . $prefix . $one_file . "_OBJECTS)")
1199 unless $prefix eq 'EXTRA_';
1200 local (@conds) = &variable_conditions ($var);
1203 @files = &variable_value_as_list ($var, '');
1208 foreach $cond (@conds)
1210 @files = &variable_value_as_list ($var, $cond);
1211 ($temp, @result) = &handle_single_transform_list (@files);
1212 $linker = $temp if $linker eq '';
1213 &define_pretty_variable ($one_file . "_OBJECTS", $cond,
1215 unless $prefix eq 'EXTRA_';
1221 elsif ($prefix eq '')
1223 &define_variable ($one_file . "_SOURCES", $unxformed . ".c");
1224 push (@sources, $unxformed . '.c');
1225 push (@objects, $unxformed . $obj);
1226 push (@files, $unxformed . '.c');
1229 ($temp, @result) = &handle_single_transform_list (@files);
1230 $linker = $temp if $linker eq '';
1231 &define_pretty_variable ($one_file . "_OBJECTS", '', @result)
1232 unless $prefix eq 'EXTRA_';
1238 # Handle the BUILT_SOURCES variable.
1239 sub handle_built_sources
1241 return unless &variable_defined ('BUILT_SOURCES');
1242 push (@all, '$(BUILT_SOURCES)');
1244 local (@sources) = &variable_value_as_list ('BUILT_SOURCES', 'all');
1246 foreach $s (@sources)
1250 # FIXME: is this really the right thing to do?
1251 &am_line_error ('BUILT_SOURCES', "\`BUILT_SOURCES' should not contain a configure substitution");
1256 # We don't care about the return value of this function. We just
1257 # want to make sure to update %dep_files with the contents of
1259 &handle_single_transform_list (@sources);
1262 # Special-case @ALLOCA@ and @LIBOBJS@ in _LDADD or _LIBADD variables.
1263 # Also, generate _DEPENDENCIES variable if appropriate.
1265 # transformed name of object being built, or empty string if no object
1266 # name of _LDADD/_LIBADD-type variable to examine
1267 # boolean (lex_seen) which is true if a lex source file was seen in this
1268 # object. valid only for LDADDs, not LIBADDs. If set, LEXLIB
1270 # Returns 1 if LIBOBJS seen, 0 otherwise.
1271 sub handle_lib_objects
1273 local ($xname, $var, $lex_seen) = @_;
1276 die "automake: programming error 1 in handle_lib_objects\n"
1277 if ! &variable_defined ($var);
1279 die "automake: programming error 2 in handle_lib_objects\n"
1280 if $lex_seen && $var =~ /LIBADD/;
1282 local (@conds) = &variable_conditions ($var);
1285 $ret = &handle_lib_objects_cond ($xname, $var, $lex_seen, '');
1291 foreach $cond (@conds)
1293 if (&handle_lib_objects_cond ($xname, $var, $lex_seen, $cond))
1303 # Subroutine of handle_lib_objects: handle a particular condition.
1304 sub handle_lib_objects_cond
1306 local ($xname, $var, $lex_seen, $cond) = @_;
1308 # We recognize certain things that are commonly put in LIBADD or
1311 local (@dep_list) = ();
1313 # If no lex source seen, just assume this is ok.
1314 local ($lex_ok) = $lex_seen ? 0 : 1;
1316 local ($seen_libobjs) = 0;
1317 local ($flagvar) = 0;
1319 foreach $lsearch (&variable_value_as_list ($var, $cond))
1321 # Skip -lfoo and -Ldir; these are explicitly allowed.
1322 next if $lsearch =~ /^-[lL]/;
1323 if (! $flagvar && $lsearch =~ /^-/)
1325 if ($var =~ /^(.*)LDADD$/)
1327 &am_line_error ($var, "linker flags such as \`$lsearch' belong in \`${1}LDFLAGS");
1331 # Only get this error once.
1333 &am_line_error ($var, "you cannot use linker flags such as \`$lsearch' in \`$var'");
1337 # Assume we have a file of some sort, and push it onto the
1338 # dependency list. Autoconf substitutions are not pushed;
1339 # rarely is a new dependency substituted into (eg) foo_LDADD
1340 # -- but "bad things (eg -lX11) are routinely substituted.
1341 # Note that LIBOBJS and ALLOCA are exceptions to this rule,
1342 # and handled specially below.
1343 push (@dep_list, $lsearch)
1344 unless $lsearch =~ /^\@.*\@$/;
1346 # Automatically handle @LIBOBJS@ and @ALLOCA@. Basically this
1347 # means adding entries to dep_files.
1348 if ($lsearch =~ /^\@(LT)?LIBOBJS\@$/)
1350 push (@dep_list, $lsearch);
1352 if (! keys %libsources)
1354 &am_line_error ($var, "\@$1" . "LIBOBJS\@ seen but never set in \`configure.in'");
1357 local ($iter, $rewrite);
1358 foreach $iter (keys %libsources)
1360 if ($iter =~ /\.[cly]$/)
1362 $seen_c_source = $var;
1365 if ($iter =~ /\.h$/)
1367 &require_file_with_line ($var, $FOREIGN, $iter);
1369 elsif ($iter ne 'alloca.c')
1371 ($rewrite = $iter) =~ s/\.c$/.P/;
1372 $dep_files{'.deps/' . $rewrite} = 1;
1373 &require_file_with_line ($var, $FOREIGN, $iter);
1377 elsif ($lsearch =~ /^\@(LT)?ALLOCA\@$/)
1379 push (@dep_list, $lsearch);
1380 &am_line_error ($var,
1381 "\@$1" . "ALLOCA\@ seen but \`AC_FUNC_ALLOCA' not in \`configure.in'")
1382 if ! defined $libsources{'alloca.c'};
1383 $dep_files{'.deps/alloca.P'} = 1;
1384 &require_file_with_line ($var, $FOREIGN, 'alloca.c');
1385 $seen_c_source = $var;
1387 elsif ($lsearch eq '@LEXLIB@')
1389 # FIXME: variable_value_as_list requires us to force
1390 # @LEXLIB@ here, where we'd really prefer $(LEXLIB).
1391 # Nasty -- this will have to wait until many cleanups are
1399 &am_line_error ($var, 'lex source file used without @LEXLIB@');
1402 if ($xname ne '' && ! &variable_defined ($xname . '_DEPENDENCIES', $cond))
1404 &define_pretty_variable ($xname . '_DEPENDENCIES', $cond, @dep_list);
1407 return $seen_libobjs;
1410 # Canonicalize a name, and check to make sure the non-canonical name
1411 # is never used. Returns canonical name. Arguments are name and a
1412 # list of suffixes to check for.
1413 sub check_canonical_spelling
1415 local ($name, @suffixes) = @_;
1416 local ($xname, $xt);
1418 ($xname = $name) =~ tr/A-Za-z0-9_/_/c;
1419 if ($xname ne $name)
1422 foreach $xt (@suffixes)
1424 &am_line_error ($name . $xt,
1425 "invalid variable \`" . $name . $xt
1426 . "'; should be \`" . $xname . $xt . "'")
1427 if &variable_defined ($name . $xt);
1434 # Handle C programs.
1437 local (@proglist) = &am_install_var ('-clean',
1438 'progs', 'PROGRAMS',
1439 'bin', 'sbin', 'libexec', 'pkglib',
1441 return if ! @proglist;
1443 # If a program is installed, this is required. We only want this
1444 # error to appear once.
1445 &am_conf_error ("AC_ARG_PROGRAM must be used in configure.in")
1446 unless $seen_arg_prog;
1449 local ($one_file, $xname, $munge);
1451 local ($seen_libobjs) = 0;
1452 foreach $one_file (@proglist)
1454 local ($obj) = &get_object_extension ($one_file);
1456 # Canonicalize names and check for misspellings.
1457 $xname = &check_canonical_spelling ($one_file, '_LDADD', '_LDFLAGS',
1458 '_SOURCES', '_OBJECTS',
1461 # FIXME: Using a trick to figure out if any lex sources appear
1462 # in our program; should use some cleaner method.
1463 local ($lex_num) = scalar (keys %lex_sources);
1464 local ($linker) = &handle_source_transform ($xname, $one_file, $obj);
1465 local ($lex_file_seen) = (scalar (keys %lex_sources) > $lex_num);
1468 if (&variable_defined ($xname . "_LDADD"))
1470 if (&handle_lib_objects ($xname, $xname . '_LDADD',
1480 # User didn't define prog_LDADD override. So do it.
1481 &define_variable ($xname . '_LDADD', '$(LDADD)');
1483 # This does a bit too much work. But we need it to
1484 # generate _DEPENDENCIES when appropriate.
1485 if (&variable_defined ('LDADD'))
1487 if (&handle_lib_objects ($xname, 'LDADD', $lex_file_seen))
1496 if (&variable_defined ($xname . '_LIBADD'))
1498 &am_line_error ($xname . '_LIBADD',
1499 "use \`" . $xname . "_LDADD', not \`"
1500 . $xname . "_LIBADD'");
1503 if (! &variable_defined ($xname . '_LDFLAGS'))
1505 # Define the prog_LDFLAGS variable.
1506 &define_variable ($xname . '_LDFLAGS', '');
1511 &am_line_error ($xname . $xt,
1512 'lex source file used without @LEXLIB@');
1515 # Determine program to use for link.
1517 if (&variable_defined ($xname . '_LINK'))
1519 $xlink = $xname . '_LINK';
1523 $xlink = $linker ? $linker : 'LINK';
1527 if (! $seen_cygwin32)
1529 $cygxform = 's/^CYGWIN.*$//; s/^NOTCYGWIN//;';
1533 $cygxform = 's/^NOTCYGWIN.*$//; s/^CYGWIN//;';
1537 &file_contents_with_transform
1538 ('s/\@PROGRAM\@/' . $one_file . '/go;'
1539 . 's/\@XPROGRAM\@/' . $xname . '/go;'
1540 . 's/\@XLINK\@/' . $xlink . '/go;'
1545 if (&variable_defined ('LDADD') && &handle_lib_objects ('', 'LDADD', 0))
1552 foreach $one_file (@proglist)
1554 # Canonicalize names.
1555 ($xname = $one_file) =~ tr/A-Za-z0-9_/_/c;
1557 if (&variable_defined ($xname . '_LDADD'))
1559 &check_libobjs_sources ($xname, $xname . '_LDADD');
1561 elsif (&variable_defined ('LDADD'))
1563 &check_libobjs_sources ($xname, 'LDADD');
1571 sub handle_libraries
1573 local (@liblist) = &am_install_var ('-clean',
1574 'libs', 'LIBRARIES',
1575 'lib', 'pkglib', 'noinst', 'check');
1576 return if ! @liblist;
1578 local (%valid) = &am_primary_prefixes ('LIBRARIES', 'lib', 'pkglib',
1580 if (! defined $configure_vars{'RANLIB'})
1583 foreach $key (keys %valid)
1585 if (&variable_defined ($key . '_LIBRARIES'))
1587 &am_line_error ($key . '_LIBRARIES', "library used but \`RANLIB' not defined in \`configure.in'");
1588 # Only get this error once.
1589 $configure_vars{'RANLIB'} = 1;
1598 local ($seen_libobjs) = 0;
1599 foreach $onelib (@liblist)
1601 # Check that the library fits the standard naming convention.
1602 if ($onelib !~ /^lib.*\.a$/)
1604 # FIXME this should only be a warning for foreign packages
1605 # FIXME should put line number here. That means mapping
1606 # from library name back to variable name.
1607 &am_error ("\`$onelib' is not a standard library name");
1610 local ($obj) = &get_object_extension ($onelib);
1612 # Canonicalize names and check for misspellings.
1613 $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_SOURCES',
1614 '_OBJECTS', '_DEPENDENCIES');
1616 if (&variable_defined ($xlib . '_LIBADD'))
1618 if (&handle_lib_objects ($xlib, $xlib . '_LIBADD', 0))
1625 # Generate support for conditional object inclusion in
1627 &define_variable ($xlib . "_LIBADD", '');
1630 if (&variable_defined ($xlib . '_LDADD'))
1632 &am_line_error ($xlib . '_LDADD',
1633 "use \`" . $xlib . "_LIBADD', not \`"
1634 . $xlib . "_LDADD'");
1637 &handle_source_transform ($xlib, $onelib, $obj);
1640 &file_contents_with_transform ('s/\@LIBRARY\@/' . $onelib . '/go;'
1648 foreach $onelib (@liblist)
1650 # Canonicalize names.
1651 ($xlib = $onelib) =~ tr/A-Za-z0-9_/_/c;
1652 if (&variable_defined ($xlib . '_LIBADD'))
1654 &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
1659 &define_variable ('AR', 'ar');
1660 &define_configure_variable ('RANLIB');
1663 # Handle shared libraries.
1664 sub handle_ltlibraries
1666 local (@liblist) = &am_install_var ('-clean',
1667 'ltlib', 'LTLIBRARIES',
1669 return if ! @liblist;
1672 local (%valid) = &am_primary_prefixes ('LTLIBRARIES', 'lib', 'pkglib');
1675 foreach $key (keys %valid)
1677 if (&variable_defined ($key . '_LTLIBRARIES'))
1681 &am_line_error ($key . '_LTLIBRARIES', "library used but \`LIBTOOL' not defined in \`configure.in'");
1682 # Only get this error once.
1683 $configure_vars{'LIBTOOL'} = 1;
1687 # Get the installation directory of each library.
1688 for (&variable_value_as_list ($key . '_LTLIBRARIES', 'all'))
1692 &am_error ("\`$_' is already going to be installed in \`$instdirs{$_}'");
1696 $instdirs{$_} = $key;
1705 local ($seen_libobjs) = 0;
1706 foreach $onelib (@liblist)
1708 # Check that the library fits the standard naming convention.
1709 if ($onelib !~ /^lib.*\.la$/)
1711 # FIXME this should only be a warning for foreign packages
1712 # FIXME should put line number here. That means mapping
1713 # from library name back to variable name.
1714 &am_error ("\`$onelib' is not a standard libtool library name");
1717 local ($obj) = &get_object_extension ($onelib);
1719 # Canonicalize names and check for misspellings.
1720 $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_LDFLAGS',
1721 '_SOURCES', '_OBJECTS',
1724 if (! &variable_defined ($xlib . '_LDFLAGS'))
1726 # Define the lib_LDFLAGS variable.
1727 &define_variable ($xlib . '_LDFLAGS', '');
1730 if (&variable_defined ($xlib . '_LIBADD'))
1732 if (&handle_lib_objects ($xlib, $xlib . '_LIBADD', 0))
1739 # Generate support for conditional object inclusion in
1741 &define_variable ($xlib . "_LIBADD", '');
1744 if (&variable_defined ($xlib . '_LDADD'))
1746 &am_line_error ($xlib . '_LDADD',
1747 "use \`" . $xlib . "_LIBADD', not \`"
1748 . $xlib . "_LDADD'");
1751 local ($linker) = &handle_source_transform ($xlib, $onelib, $obj);
1753 # Determine program to use for link.
1755 if (&variable_defined ($xlib . '_LINK'))
1757 $xlink = $xlib . '_LINK';
1761 $xlink = $linker ? $linker : 'LINK';
1765 if ($instdirs{$onelib} eq 'EXTRA')
1767 # It's an EXTRA_ library, so we can't specify -rpath.
1769 $rpath = 's/\@RPATH\@//go;';
1773 $rpath = ('s/\@RPATH\@/-rpath \$(' . $instdirs{$onelib}
1778 &file_contents_with_transform ('s/\@LTLIBRARY\@/'
1780 . 's/\@XLTLIBRARY\@/'
1783 . 's/\@XLINK\@/' . $xlink . '/go;',
1789 foreach $onelib (@liblist)
1791 # Canonicalize names.
1792 ($xlib = $onelib) =~ tr/A-Za-z0-9_/_/c;
1793 if (&variable_defined ($xlib . '_LIBADD'))
1795 &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
1801 # See if any _SOURCES variable were misspelled. Also, make sure that
1802 # EXTRA_ variables don't contain configure substitutions.
1805 local ($varname, $primary);
1806 foreach $varname (keys %contents)
1808 foreach $primary ('_SOURCES', '_LIBADD', '_LDADD', '_LDFLAGS', '_DEPENDENCIES')
1810 if ($varname =~ /$primary$/ && ! $content_seen{$varname})
1812 &am_line_error ($varname,
1813 "invalid unused variable name: \`$varname'");
1822 # NOTE we no longer automatically clean SCRIPTS, because it is
1823 # useful to sometimes distribute scripts verbatim. This happens
1824 # eg in Automake itself.
1825 &am_install_var ('scripts', 'SCRIPTS',
1826 'bin', 'sbin', 'libexec', 'pkgdata',
1829 # Set $scripts_installed if appropriate. Make sure we only find
1830 # scripts which are actually installed -- this is why we can't
1831 # simply use the return value of am_install_var.
1832 local (%valid) = &am_primary_prefixes ('SCRIPTS', 'bin', 'sbin',
1833 'libexec', 'pkgdata',
1836 foreach $key (keys %valid)
1838 if ($key ne 'noinst'
1840 && &variable_defined ($key . '_SCRIPTS'))
1842 $scripts_installed = 1;
1843 # push (@check_tests, 'check-' . $key . 'SCRIPTS');
1847 if ($scripts_installed)
1849 # If a program is installed, this is required. We only want this
1850 # error to appear once.
1851 &am_conf_error ("AC_ARG_PROGRAM must be used in configure.in")
1852 unless $seen_arg_prog;
1857 # Search a file for a "version.texi" Texinfo include. Return the name
1858 # of the include file if found, or the empty string if not. A
1859 # "version.texi" file is actually any file whose name matches
1861 sub scan_texinfo_file
1863 local ($filename) = @_;
1865 if (! open (TEXI, $filename))
1867 &am_error ("couldn't open \`$filename': $!");
1870 print "automake: reading $filename\n" if $verbose;
1872 local ($vfile, $outfile);
1875 if (/^\@setfilename +(\S+)/)
1881 if (/^\@include\s+(vers[^.]*\.texi)\s*$/)
1883 # Found version.texi include.
1890 return ($outfile, $vfile);
1893 # Handle all Texinfo source.
1896 &am_line_error ('TEXINFOS',
1897 "\`TEXINFOS' is an anachronism; use \`info_TEXINFOS'")
1898 if &variable_defined ('TEXINFOS');
1899 return if (! &variable_defined ('info_TEXINFOS')
1900 && ! &variable_defined ('html_TEXINFOS'));
1902 local (@texis) = &variable_value_as_list ('info_TEXINFOS', 'all');
1904 local (@info_deps_list, @dvis_list, @texi_deps);
1905 local ($infobase, $info_cursor);
1909 local ($tc_cursor, @texi_cleans);
1912 foreach $info_cursor (@texis)
1914 ($infobase = $info_cursor) =~ s/\.texi(nfo)?$//;
1916 # If 'version.texi' is referenced by input file, then include
1917 # automatic versioning capability.
1918 local ($out_file, $vtexi) = &scan_texinfo_file ($relative_dir
1919 . "/" . $info_cursor);
1921 if ($out_file eq '')
1923 &am_error ("\`$info_cursor' missing \@setfilename");
1927 if ($out_file =~ /\.(.+)$/ && $1 ne 'info')
1929 # FIXME should report line number in input file.
1930 &am_error ("output of \`$info_cursor', \`$out_file', has unrecognized extension");
1936 &am_error ("\`$vtexi', included in \`$info_cursor', also included in \`$versions{$vtexi}'")
1937 if (defined $versions{$vtexi});
1938 $versions{$vtexi} = $info_cursor;
1940 # We number the stamp-vti files. This is doable since the
1941 # actual names don't matter much. We only number starting
1942 # with the second one, so that the common case looks nice.
1943 $vti = 'vti' . ($done ? $done : '');
1944 &push_dist_common ($vtexi, 'stamp-' . $vti);
1945 push (@clean, $vti);
1947 # Only require once.
1948 &require_conf_file_with_line ('info_TEXINFOS', $FOREIGN,
1954 ($conf_pat = $config_aux_dir) =~ s/(\W)/\\$1/g;
1956 &file_contents_with_transform
1957 ('s/\@TEXI\@/' . $info_cursor . '/g; '
1958 . 's/\@VTI\@/' . $vti . '/g; '
1959 . 's/\@VTEXI\@/' . $vtexi . '/g;'
1960 . 's,\@MDDIR\@,' . $conf_pat . ',g;',
1963 &push_phony_cleaners ($vti);
1966 # If user specified file_TEXINFOS, then use that as explicit
1969 push (@texi_deps, $info_cursor);
1970 push (@texi_deps, $vtexi) if $vtexi;
1972 # Canonicalize name first.
1973 ($canonical = $infobase) =~ tr/A-Za-z0-9_/_/c;
1974 if (&variable_defined ($canonical . "_TEXINFOS"))
1976 push (@texi_deps, '$(' . $canonical . '_TEXINFOS)');
1977 &push_dist_common ('$(' . $canonical . '_TEXINFOS)');
1980 $output_rules .= ("\n" . $out_file . ": "
1981 . join (' ', @texi_deps)
1982 . "\n" . $infobase . ".dvi: "
1983 . join (' ', @texi_deps)
1986 push (@info_deps_list, $out_file);
1987 push (@dvis_list, $infobase . '.dvi');
1989 # Generate list of things to clean for this target. We do
1990 # this explicitly because otherwise too many things could be
1991 # removed. In particular the ".log" extension might
1992 # reasonably be used in other contexts by the user.
1993 foreach $tc_cursor ('aux', 'cp', 'cps', 'dvi', 'fn', 'fns',
1994 'ky', 'log', 'pg', 'toc', 'tp', 'tps',
1995 'vr', 'vrs', 'op', 'tr', 'cv')
1997 push (@texi_cleans, $infobase . '.' . $tc_cursor);
2001 # Find these programs wherever they may lie. Yes, this has
2002 # intimate knowledge of the structure of the texinfo distribution.
2003 &define_program_variable ('MAKEINFO', 'build', 'texinfo/makeinfo',
2005 # Circumlocution to avoid accidental
2006 # configure substitution.
2008 &define_program_variable ('TEXI2DVI', 'src', 'texinfo/util',
2011 # Set transform for including texinfos.am. First, handle --cygnus
2016 $xform = 's/^NOTCYGNUS.*$//; s/^CYGNUS//;';
2020 $xform = 's/^CYGNUS.*$//; s/^NOTCYGNUS//;';
2023 # Handle location of texinfo.tex.
2026 &define_variable ('TEXINFO_TEX',
2027 '$(top_srcdir)/../texinfo/texinfo.tex');
2029 elsif (! &variable_defined ('TEXINFO_TEX'))
2031 &define_variable ('TEXINFO_TEX', '$(srcdir)/texinfo.tex');
2033 local ($xxform) = &dirname (&variable_value ('TEXINFO_TEX'));
2034 $xxform =~ s/(\W)/\\$1/g;
2035 $xform .= ' s/\@TEXINFODIR\@/' . $xxform . '/g;';
2037 $output_rules .= &file_contents_with_transform ($xform, 'texinfos');
2038 push (@phony, 'install-info-am', 'uninstall-info');
2039 push (@dist_targets, 'dist-info');
2041 # How to clean. The funny name is due to --cygnus influence; in
2042 # Cygnus mode, `clean-info' is a target that users can use.
2043 $output_rules .= "\nmostlyclean-aminfo:\n";
2044 &pretty_print_rule ("\trm -f", "\t ", @texi_cleans);
2045 $output_rules .= ("\nclean-aminfo:\n\ndistclean-aminfo:\n\n"
2046 . "maintainer-clean-aminfo:\n\t"
2047 . 'for i in $(INFO_DEPS); do rm -f `eval echo $$i*`; done'
2049 &push_phony_cleaners ('aminfo');
2052 $output_rules .= "clean-info: mostlyclean-aminfo\n";
2055 push (@suffixes, '.texi', '.texinfo', '.info', '.dvi', '.ps');
2057 if (! defined $options{'no-installinfo'})
2059 push (@uninstall, 'uninstall-info');
2060 push (@installdirs, '$(infodir)');
2061 unshift (@install_data, 'install-info-am');
2063 # Make sure documentation is made and installed first. Use
2064 # $(INFO_DEPS), not 'info', because otherwise recursive makes
2065 # get run twice during "make all".
2066 unshift (@all, '$(INFO_DEPS)');
2068 push (@clean, 'aminfo');
2069 push (@info, '$(INFO_DEPS)');
2070 push (@dvi, '$(DVIS)');
2072 &define_variable ("INFO_DEPS", join (' ', @info_deps_list));
2073 &define_variable ("DVIS", join (' ', @dvis_list));
2074 # This next isn't strictly needed now -- the places that look here
2075 # could easily be changed to look in info_TEXINFOS. But this is
2076 # probably better, in case noinst_TEXINFOS is ever supported.
2077 &define_variable ("TEXINFOS", &variable_value ('info_TEXINFOS'));
2079 # Do some error checking. Note that this file is not required
2080 # when in Cygnus mode; instead we defined TEXINFO_TEX explicitly
2082 &require_file_with_line ('info_TEXINFOS', $FOREIGN, 'texinfo.tex')
2083 unless (defined $options{'no-texinfo.tex'}
2084 || &variable_defined ('TEXINFO_TEX'));
2087 # Handle any man pages.
2088 sub handle_man_pages
2090 &am_line_error ('MANS', "\`MANS' is an anachronism; use \`man_MANS'")
2091 if &variable_defined ('MANS');
2092 return if ! &variable_defined ('man_MANS');
2094 # We generate the manpage install code by hand to avoid the use of
2095 # basename in the generated Makefile.
2096 local (@mans) = &variable_value_as_list ('man_MANS', 'all');
2097 local (%sections, %inames, %mbases, %secmap, %fullsecmap);
2101 # FIXME: statement without effect:
2102 /^(.*)\.([0-9])([a-z]*)$/;
2107 $fullsecmap{$i} = $2 . $3;
2111 # We don't really need this, but we use it in case we ever want to
2112 # support noinst_MANS.
2113 &define_variable ("MANS", &variable_value ('man_MANS'));
2115 # Generate list of install dirs.
2116 $output_rules .= "install-man: \$(MANS)\n";
2117 $output_rules .= "\t\$(NORMAL_INSTALL)\n";
2118 # Sort keys so that output is deterministic.
2119 foreach (sort keys %sections)
2121 push (@installdirs, '$(mandir)/man' . $_)
2122 unless defined $options{'no-installman'};
2123 $output_rules .= ("\t" . '$(mkinstalldirs) $(mandir)/man'
2126 push (@phony, 'install-man');
2128 # Generate install target.
2130 foreach $key (sort keys %inames)
2132 $_ = $install_man_format;
2133 s/\@SECTION\@/$secmap{$key}/g;
2134 s/\@MAN\@/$inames{$key}/g;
2135 s/\@FULLSECT\@/$fullsecmap{$key}/g;
2136 s/\@MANBASE\@/$mbases{$key}/g;
2137 $output_rules .= $_;
2139 $output_rules .= "\n";
2141 $output_rules .= "uninstall-man:\n\t\$(NORMAL_UNINSTALL)\n";
2142 foreach $key (sort keys %inames)
2144 $_ = $uninstall_man_format;
2145 s/\@SECTION\@/$secmap{$key}/g;
2146 s/\@MAN\@/$inames{$key}/g;
2147 s/\@FULLSECT\@/$fullsecmap{$key}/g;
2148 s/\@MANBASE\@/$mbases{$key}/g;
2149 $output_rules .= $_;
2151 $output_rules .= "\n";
2152 push (@phony, 'uninstall-man');
2154 $output_vars .= &file_contents ('mans-vars');
2156 if (! defined $options{'no-installman'})
2158 push (@install_data, 'install-man');
2159 push (@uninstall, 'uninstall-man');
2160 push (@all, '$(MANS)');
2164 # Handle DATA variables.
2167 &am_install_var ('data', 'DATA', 'data', 'sysconf',
2168 'sharedstate', 'localstate', 'pkgdata',
2175 push (@phony, 'tags');
2176 local (@tag_deps) = ();
2177 if (&variable_defined ('SUBDIRS'))
2179 $output_rules .= ("tags-recursive:\n"
2180 . "\tlist=\'\$(SUBDIRS)\'; for subdir in \$\$list; do \\\n"
2181 # Never fail here if a subdir fails; it
2183 . "\t (cd \$\$subdir && \$(MAKE) tags); \\\n"
2185 push (@tag_deps, 'tags-recursive');
2186 push (@phony, 'tags-recursive');
2189 if ($dir_holds_sources
2190 || $dir_holds_headers
2191 || &variable_defined ('ETAGS_ARGS')
2194 local ($xform) = '';
2196 foreach $one_hdr (@config_headers)
2198 if ($relative_dir eq &dirname ($one_hdr))
2200 # The config header is in this directory. So require it.
2202 ($var = &basename ($one_hdr)) =~ s/(\W)/\\$1/g;
2203 $xform .= ' ' if $xform;
2207 $xform = ('s/\@CONFIG\@/' . $xform . '/;'
2208 . 's/\@DIRS\@/' . join (' ', @tag_deps) . '/;');
2210 if (&variable_defined ('SUBDIRS'))
2212 $xform .= 's/^SUBDIRS//;';
2216 $xform .= 's/^SUBDIRS.*$//;';
2219 $output_rules .= &file_contents_with_transform ($xform, 'tags');
2220 $output_rules .= &file_contents ('tags-clean');
2221 push (@clean, 'tags');
2222 &push_phony_cleaners ('tags');
2223 &examine_variable ('TAGS_DEPENDENCIES');
2225 elsif (&variable_defined ('TAGS_DEPENDENCIES'))
2227 &am_line_error ('TAGS_DEPENDENCIES',
2228 "doesn't make sense to define \`TAGS_DEPENDENCIES' without sources or \`ETAGS_ARGS'");
2232 # Every Makefile must define some sort of TAGS rule.
2233 # Otherwise, it would be possible for a top-level "make TAGS"
2234 # to fail because some subdirectory failed.
2235 $output_rules .= "tags: TAGS\nTAGS:\n\n";
2239 # Worker for handle_dist.
2240 sub handle_dist_worker
2242 local ($makefile) = @_;
2244 $output_rules .= 'distdir: $(DISTFILES)' . "\n";
2246 # Initialization; only at top level.
2247 if ($relative_dir eq '.')
2249 if ($strictness >= $GNITS)
2251 # For Gnits users, this is pretty handy. Look at 15 lines
2252 # in case some explanatory text is desirable.
2253 $output_rules .= ' @if sed 15q $(srcdir)/NEWS | fgrep -e "$(VERSION)" > /dev/null; then :; else \\
2254 echo "NEWS not updated; not releasing" 1>&2; \\
2261 # Create dist directory.
2262 $output_rules .= ("\trm -rf \$(distdir)\n"
2263 . "\tmkdir \$(distdir)\n"
2264 . "\t-chmod 777 \$(distdir)\n");
2267 # Only run automake in `dist' target if --include-deps and
2268 # `no-dependencies' not specified. That way the recipient of a
2269 # distribution can run "make dist" and not need Automake. You
2270 # might be wondering why we run automake once for each directory
2271 # we distribute, instead of running it once at the top level. The
2272 # answer is that we want to run automake after the dependencies
2273 # have been generated. This occurs when "make" is run in the
2274 # subdir. So automake must be run after make has updated the
2275 # Makefile, which means that it must run once per directory.
2276 if ($use_dependencies)
2280 # We need an absolute path for --output-dir. Thus the
2282 "\t" . 'here=`cd $(top_builddir) && pwd`; ' . "\\\n"
2283 . "\t" . 'top_distdir=`cd $(top_distdir) && pwd`; ' . "\\\n"
2284 . "\tcd \$(top_srcdir) \\\n"
2285 . "\t && \$(AUTOMAKE) --include-deps --build-dir=\$\$here --srcdir-name=\$(top_srcdir) --output-dir=\$\$top_distdir "
2286 # Set strictness of output.
2287 . ($cygnus_mode ? '--cygnus' : ('--' . $strictness_name))
2288 . ($cmdline_use_dependencies ? '' : ' --include-deps')
2289 . " " . $makefile . "\n"
2293 # Scan EXTRA_DIST to see if we need to distribute anything from a
2294 # subdir. If so, add it to the list. I didn't want to do this
2295 # originally, but there were so many requests that I finally
2298 if (&variable_defined ('EXTRA_DIST'))
2300 # FIXME: This should be fixed to work with conditionals. That
2301 # will require only making the entries in @dist_dirs under the
2302 # appropriate condition. This is meaningful if the nature of
2303 # the distribution should depend upon the configure options
2305 foreach (&variable_value_as_list ('EXTRA_DIST', ''))
2308 next unless s,/+[^/]+$,,;
2309 push (@dist_dirs, $_)
2315 # Prepend $(distdir) to each directory given. Doing it via a
2316 # hash lets us ensure that each directory is used only once.
2318 grep ($dhash{'$(distdir)/' . $_} = 1, @dist_dirs);
2319 $output_rules .= "\t";
2320 &pretty_print_rule ('$(mkinstalldirs)', "\t ", sort keys %dhash);
2323 # In loop, test for file existence because sometimes a file gets
2324 # included in DISTFILES twice. For example this happens when a
2325 # single source file is used in building more than one program.
2326 # Also, there are situations in which "ln" can fail. For instance
2327 # a file to distribute could actually be a cross-filesystem
2328 # symlink -- this can easily happen if "gettextize" was run on the
2330 $output_rules .= "\t\@for file in \$(DISTFILES); do \\\n";
2333 $output_rules .= "\t if test -f \$\$file; then d=.; else d=\$(srcdir); fi; \\\n";
2337 $output_rules .= "\t d=\$(srcdir); \\\n";
2339 $output_rules .= ' test -f $(distdir)/$$file \\
2340 || ln $$d/$$file $(distdir)/$$file 2> /dev/null \\
2341 || cp -p $$d/$$file $(distdir)/$$file; \\
2345 # If we have SUBDIRS, create all dist subdirectories and do
2347 if (&variable_defined ('SUBDIRS'))
2349 # If SUBDIRS is conditionally defined, then set DIST_SUBDIRS
2350 # to all possible directories, and use it.
2351 if (! &variable_conditions ('SUBDIRS'))
2353 $dist_subdir_name = 'SUBDIRS';
2357 $dist_subdir_name = 'DIST_SUBDIRS';
2358 if (! &variable_defined ('DIST_SUBDIRS'))
2360 &define_pretty_variable ('DIST_SUBDIRS', '',
2361 &variable_value_as_list ('SUBDIRS',
2366 # Test for directory existence here because previous automake
2367 # invocation might have created some directories. Note that
2368 # we explicitly set distdir for the subdir make; that lets us
2369 # mix-n-match many automake-using packages into one large
2370 # package, and have "dist" at the top level do the right
2372 $output_rules .= ' for subdir in $(' . $dist_subdir_name . '); do \\
2373 test -d $(distdir)/$$subdir \\
2374 || mkdir $(distdir)/$$subdir \\
2376 chmod 777 $(distdir)/$$subdir; \\
2377 (cd $$subdir && $(MAKE) top_distdir=../$(top_distdir) distdir=../$(distdir)/$$subdir distdir) \\
2383 # If the target `dist-hook' exists, make sure it is run. This
2384 # allows users to do random weird things to the distribution
2385 # before it is packaged up.
2386 push (@dist_targets, 'dist-hook') if defined $contents{'dist-hook'};
2389 foreach $targ (@dist_targets)
2391 # We must explicitly set distdir and top_distdir for these
2393 $output_rules .= "\t\$(MAKE) top_distdir=\"\$(top_distdir)\" distdir=\"\$(distdir)\" $targ\n";
2396 push (@phony, 'distdir');
2399 # Handle 'dist' target.
2402 local ($makefile) = @_;
2404 # Set up maint_charset.
2405 $local_maint_charset = &variable_value ('MAINT_CHARSET')
2406 if &variable_defined ('MAINT_CHARSET');
2407 $maint_charset = $local_maint_charset
2408 if $relative_dir eq '.';
2410 if (&variable_defined ('DIST_CHARSET'))
2412 &am_line_error ('DIST_CHARSET',
2413 "DIST_CHARSET defined but no MAINT_CHARSET defined")
2414 if ! $local_maint_charset;
2415 if ($relative_dir eq '.')
2417 $dist_charset = &variable_value ('DIST_CHARSET')
2421 &am_line_error ('DIST_CHARSET',
2422 "DIST_CHARSET can only be defined at top level");
2426 # Look for common files that should be included in distribution.
2428 foreach $cfile (@common_files)
2430 if (-f ($relative_dir . "/" . $cfile))
2432 &push_dist_common ($cfile);
2436 # Keys of %dist_common are names of files to distributed. We put
2437 # README first because it then becomes easier to make a
2438 # Usenet-compliant shar file (in these, README must be first).
2439 # FIXME: do more ordering of files here.
2441 if (defined $dist_common{'README'})
2443 push (@coms, 'README');
2444 delete $dist_common{'README'};
2446 push (@coms, sort keys %dist_common);
2448 &define_pretty_variable ("DIST_COMMON", '', @coms);
2449 $output_vars .= "\n";
2452 $output_vars .= &file_contents ('dist-vars') . "\n";
2453 &define_variable ('TAR', $TAR);
2454 &define_variable ('GZIP', '--best');
2456 # Put these things in rules section so it is easier for whoever
2457 # reads Makefile.in.
2458 if (! &variable_defined ('distdir'))
2460 if ($relative_dir eq '.')
2462 $output_rules .= "\n" . 'distdir = $(PACKAGE)-$(VERSION)' . "\n";
2466 $output_rules .= ("\n"
2467 . 'distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)'
2471 if ($relative_dir eq '.')
2473 $output_rules .= "top_distdir = \$(distdir)\n\n";
2477 $output_rules .= "\nsubdir = " . $relative_dir . "\n\n";
2480 # Generate 'dist' target, and maybe dist-shar / dist-zip / dist-tarZ.
2481 if ($relative_dir eq '.')
2483 # Rule to check whether a distribution is viable.
2484 $output_rules .= ('# This target untars the dist file and tries a VPATH configuration. Then
2485 # it guarantees that the distribution is self-contained by making another
2489 GZIP=$(GZIP) $(TAR) zxf $(distdir).tar.gz
2490 mkdir $(distdir)/=build
2491 mkdir $(distdir)/=inst
2492 dc_install_base=`cd $(distdir)/=inst && pwd`; \\'
2493 . (defined $contents{'distcheck-hook'}
2494 ? "\t\$(MAKE) distcheck-hook"
2497 cd $(distdir)/=build \\
2500 . ($seen_gettext ? '--with-included-gettext ' : '')
2501 . '--srcdir=.. --prefix=$$dc_install_base \\
2505 && $(MAKE) install \\
2506 && $(MAKE) installcheck \\
2509 @echo "========================"; \\
2510 echo "$(distdir).tar.gz is ready for distribution"; \\
2511 echo "========================"
2514 local ($dist_all) = ('dist-all: distdir' . "\n"
2517 foreach $curs ('dist', 'dist-shar', 'dist-zip', 'dist-tarZ')
2519 if (defined $options{$curs} || $curs eq 'dist')
2521 $output_rules .= ($curs . ': distdir' . "\n"
2525 $dist_all .= $dist{$curs};
2528 $output_rules .= $dist_all . $dist_trailer;
2531 # Generate distdir target.
2532 &handle_dist_worker ($makefile);
2535 # Scan a single dependency file and rewrite the dependencies as
2536 # appropriate. Essentially this means:
2537 # * Clean out absolute dependencies which are not desirable.
2538 # * Rewrite other dependencies to be relative to $(top_srcdir).
2539 sub scan_dependency_file
2541 local ($depfile) = @_;
2543 if (! open (DEP_FILE, $depfile))
2545 &am_error ("couldn't open \`$depfile': $!");
2548 print "automake: reading $depfile\n" if $verbose;
2550 # Sometimes it is necessary to omit some dependencies.
2551 local (%omit) = %omit_dependencies;
2552 if (&variable_defined ('OMIT_DEPENDENCIES'))
2554 # FIXME: Doesn't work with conditionals. I'm not sure if this
2556 grep ($omit{$_} = 1,
2557 &variable_value_as_list ('OMIT_DEPENDENCIES', ''));
2560 local ($first_line) = 1;
2561 local ($last_line) = 0;
2562 local ($target, @dependencies);
2563 local ($one_dep, $xform);
2566 local ($srcdir_rx, $fixup_rx);
2567 ($fixup_rx = $srcdir_name . '/' . $relative_dir . '/')
2569 ($srcdir_rx = $srcdir_name . '/') =~ s/(\W)/\\$1/g;
2571 local ($rewrite_builddir) = (($top_builddir eq '.')
2573 : $top_builddir . '/');
2579 # If LAST_LINE set then we've already seen what we thought
2580 # was the last line.
2583 next if (/$WHITE_PATTERN/o);
2587 # No trailing "\" means this should be the last line.
2593 if (! /^([^:]+:)(.+)$/)
2596 &am_error ("\`$depfile' has incorrect format");
2602 # Make sure to strip the .P file from the target.
2603 ($target = $1) =~ s, *\.deps/[^.]+\.P,,;
2608 foreach $one_dep (split (' ', $_))
2610 if ($one_dep =~ /^$fixup_rx/)
2612 # The dependency points to the current directory in
2614 ($xform = $one_dep) =~ s/^$fixup_rx//;
2615 push (@dependencies, $xform);
2617 elsif ($one_dep =~ /^$srcdir_rx/)
2619 # The dependency is in some other directory in the package.
2620 ($xform = $one_dep) =~ s/^$srcdir_rx/$rewrite_builddir/;
2621 push (@dependencies, $xform);
2623 elsif ($one_dep =~ /^\//)
2625 # Absolute path; ignore.
2629 # Anything else is assumed to be correct. But first
2630 # make sure it is not on our list of dependencies to
2632 ($just_file = $one_dep) =~ s,^.*/,,;
2633 push (@dependencies, $one_dep)
2634 if ! defined $omit{$just_file};
2639 &pretty_print_rule ($target, "\t", @dependencies);
2644 # Handle auto-dependency code.
2645 sub handle_dependencies
2647 if ($use_dependencies)
2649 # Include GNU-make-specific auto-dep code. Don't include it
2650 # if DEP_FILES would be empty.
2651 if ($dir_holds_sources && keys %dep_files)
2653 &define_pretty_variable ('DEP_FILES', '', sort keys %dep_files);
2654 $output_rules .= &file_contents ('depend');
2655 push (@clean, 'depend');
2656 &push_phony_cleaners ('depend');
2658 &file_contents_with_transform ('s/\@EXT\@/.c/g;'
2659 . 's/\@MKDEP\@/MKDEP/g;'
2663 local ($need_cxx) = 0;
2664 foreach $ext (sort keys %cxx_extensions)
2667 &file_contents_with_transform ('s/\@EXT\@/' . $ext .'/g;'
2668 . 's/\@MKDEP\@/CXXMKDEP/g;'
2675 &define_variable ('CXXMKDEP', '$(CXX) -M $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CXXFLAGS)');
2679 elsif ($build_directory ne '')
2681 # Include any auto-generated deps that are present. Note that
2682 # $build_directory ends in a "/".
2683 if (-d ($build_directory . $relative_dir . "/.deps")
2684 && -f ($build_directory . $relative_dir . "/.deps/.P"))
2688 foreach $depfile (&my_glob ($build_directory
2689 . $relative_dir . "/.deps/*.P"))
2691 &scan_dependency_file ($depfile);
2694 $output_rules .= "\n";
2699 # Handle subdirectories.
2702 return if ! &variable_defined ('SUBDIRS');
2704 # Make sure each directory mentioned in SUBDIRS actually exists.
2706 foreach $dir (&variable_value_as_list ('SUBDIRS', 'all'))
2708 # Skip directories substituted by configure.
2709 next if $dir =~ /^\@.*\@$/;
2711 if (! -d $am_relative_dir . '/' . $dir)
2713 &am_line_error ('SUBDIRS',
2714 "required directory $am_relative_dir/$dir does not exist");
2718 &am_line_error ('SUBDIRS', "directory should not contain \`/'")
2722 local ($xform) = ('s/\@INSTALLINFO\@/' .
2723 (defined $options{'no-installinfo'}
2724 ? 'install-info-recursive'
2727 $output_rules .= &file_contents_with_transform ($xform, 'subdirs');
2729 # Push a bunch of phony targets.
2731 foreach $phonies ('-data', '-exec', 'dirs')
2733 push (@phony, 'install' . $phonies . '-recursive');
2734 push (@phony, 'uninstall' . $phonies . '-recursive');
2736 foreach $phonies ('all', 'check', 'installcheck', 'info', 'dvi')
2738 push (@phony, $phonies . '-recursive');
2740 &push_phony_cleaners ('recursive');
2742 push (@check_tests, "check-recursive");
2743 push (@installcheck, "installcheck-recursive");
2744 push (@info, "info-recursive");
2745 push (@dvi, "dvi-recursive");
2747 $recursive_install = 1;
2750 # Handle aclocal.m4.
2751 sub handle_aclocal_m4
2753 local ($regen_aclocal) = 0;
2754 if (-f 'aclocal.m4')
2756 &define_variable ("ACLOCAL_M4", '$(top_srcdir)/aclocal.m4');
2757 &push_dist_common ('aclocal.m4');
2759 if (open (ACLOCAL, '< aclocal.m4'))
2765 if ($line =~ 'generated automatically by aclocal')
2772 local ($acinclude) = 0;
2773 if (-f 'acinclude.m4')
2779 # Note that it might be possible that aclocal.m4 doesn't exist but
2780 # should be auto-generated. This case probably isn't very
2784 local (@ac_deps) = (
2785 ($seen_maint_mode ? "\@MAINT\@" : "") ,
2787 ($acinclude ? ' acinclude.m4' : '')
2790 # Scan all -I directories for m4 files. These are our
2792 if (&variable_defined ('ACLOCAL_AMFLAGS'))
2795 foreach $amdir (&variable_value_as_list ('ACLOCAL_AMFLAGS', ''))
2797 if ($amdir =~ s/^-I//
2801 push (@ac_deps, &my_glob ($am_dir . '/*.m4'));
2806 &pretty_print_rule ("\$(ACLOCAL_M4):", "\t\t", @ac_deps);
2808 $output_rules .= ("\t"
2809 . 'cd $(srcdir) && $(ACLOCAL)'
2810 . (&variable_defined ('ACLOCAL_AMFLAGS')
2811 ? ' $(ACLOCAL_AMFLAGS)' : '')
2816 # Rewrite a list of input files into a form suitable to put on a
2817 # dependency list. The idea is that if an input file has a directory
2818 # part the same as the current directory, then the directory part is
2819 # simply removed. But if the directory part is different, then
2820 # $(top_srcdir) is prepended. Among other things, this is used to
2821 # generate the dependency list for the output files generated by
2822 # AC_OUTPUT. Consider what the dependencies should look like in this
2824 # AC_OUTPUT(src/out:src/in1:lib/in2)
2825 sub rewrite_inputs_into_dependencies
2827 local (@inputs) = @_;
2828 local ($single, @newinputs);
2830 foreach $single (@inputs)
2832 if (&dirname ($single) eq $relative_dir)
2834 push (@newinputs, &basename ($single));
2838 push (@newinputs, '$(top_srcdir)/' . $single);
2845 # Handle remaking and configure stuff.
2846 # We need the name of the input file, to do proper remaking rules.
2847 sub handle_configure
2849 local ($local, $input, @secondary_inputs) = @_;
2851 # If SUBDIRS defined, require AC_PROG_MAKE_SET.
2852 &am_line_error ('SUBDIRS', "AC_PROG_MAKE_SET must be used in configure.in")
2853 if &variable_defined ('SUBDIRS') && ! $seen_make_set;
2855 local ($top_reldir);
2857 local ($input_base) = &basename ($input);
2858 local ($local_base) = &basename ($local);
2860 local ($amfile) = $input_base . '.am';
2861 # We know we can always add '.in' because it really should be an
2862 # error if the .in was missing originally.
2863 local ($infile) = '$(srcdir)/' . $input_base . '.in';
2864 local ($colon_infile);
2865 if ($local ne $input)
2867 $colon_infile = ':' . $input . '.in';
2869 $colon_infile .= ':' . join (':', @secondary_inputs)
2870 if @secondary_inputs;
2872 local (@rewritten) = &rewrite_inputs_into_dependencies (@secondary_inputs);
2873 # This rule remakes the Makefile.in. Note use of @MAINT@ forces
2874 # us to abandon pretty-printing. Sigh.
2875 $output_rules .= ($infile
2876 # NOTE perl 5.003 (with -w) gives a
2877 # uninitialized value error on the next line.
2880 . ($seen_maint_mode ? '@MAINT@ ' : '')
2882 . '$(top_srcdir)/configure.in $(ACLOCAL_M4) '
2883 . join (' ', @rewritten) . "\n"
2884 . "\tcd \$(top_srcdir) && \$(AUTOMAKE) "
2885 . ($cygnus_mode ? '--cygnus' : ('--' . $strictness_name))
2886 . ($cmdline_use_dependencies ? '' : ' --include-deps')
2887 . ' ' . $input . $colon_infile . "\n\n");
2889 # This rule remakes the Makefile.
2890 $output_rules .= ($local_base
2891 # NOTE: bogus uninit value error on next line;
2892 # see comment above.
2895 . '$(top_builddir)/config.status'
2896 # NOTE: Makefile only depends on BUILT_SOURCES
2897 # when dependencies are being computed. This is
2898 # a workaround for an obscure bug with
2899 # AC_LINK_FILES. Anyway, when dependencies are
2900 # turned off, this shouldn't matter.
2901 . ($use_dependencies ? ' $(BUILT_SOURCES)' : '')
2903 . "\tcd \$(top_builddir) \\\n"
2904 . "\t && CONFIG_FILES="
2905 . (($relative_dir eq '.') ? '$@' : '$(subdir)/$@')
2907 . ' CONFIG_HEADERS= $(SHELL) ./config.status'
2910 if ($relative_dir ne '.')
2913 $top_reldir = '../';
2918 $output_rules .= &file_contents ('remake');
2919 &examine_variable ('CONFIGURE_DEPENDENCIES');
2923 # If we have a configure header, require it.
2925 local (@local_fullnames) = @config_fullnames;
2926 local (@local_names) = @config_names;
2927 local ($hdr_index) = 0;
2928 local ($distclean_config) = '';
2929 foreach $one_hdr (@config_headers)
2931 local ($one_fullname) = shift (@local_fullnames);
2932 local ($one_name) = shift (@local_names);
2934 if ($relative_dir eq &dirname ($one_hdr))
2936 local ($ch_sans_dir) = &basename ($one_hdr);
2937 local ($cn_sans_dir) = &basename ($one_name);
2939 &require_file_with_conf_line ($config_header_line,
2940 $FOREIGN, $ch_sans_dir);
2942 # Header defined and in this directory.
2944 if (-f $relative_dir . '/acconfig.h')
2946 push (@files, 'acconfig.h');
2948 if (-f $one_name . '.top')
2950 push (@files, "${cn_sans_dir}.top");
2952 if (-f $one_name . '.bot')
2954 push (@files, "${cn_sans_dir}.bot");
2957 &push_dist_common (@files);
2959 local ($stamp_name) = 'stamp-h';
2960 $stamp_name .= "${hdr_index}" if scalar (@config_headers) > 1;
2962 local ($xform) = '';
2964 $xform = 's,\@FILES\@,' . join (' ', @files) . ',;';
2965 $xform .= 's,\@CONFIG_HEADER\@,' . "${cn_sans_dir}" . ',;';
2966 $xform .= 's,\@CONFIG_HEADER_IN\@,' . "${ch_sans_dir}" . ',;';
2967 $xform .= 's,\@CONFIG_HEADER_FULL\@,' . "${one_fullname}" . ',;';
2968 $xform .= 's,\@STAMP\@,' . "${stamp_name}" . ',;';
2970 $output_rules .= &file_contents_with_transform ($xform,
2973 &touch ($relative_dir . "/${stamp_name}.in");
2974 &require_file_with_conf_line ($config_header_line, $FOREIGN,
2975 "${stamp_name}.in");
2977 $distclean_config .= ' ' if $distclean_config;
2978 $distclean_config .= $cn_sans_dir;
2982 if ($distclean_config)
2984 $output_rules .= &file_contents_with_transform ('s,\@FILES\@,'
2988 push (@clean, 'hdr');
2989 &push_phony_cleaners ('hdr');
2992 # Set location of mkinstalldirs.
2993 if ($config_aux_dir ne '.' && $config_aux_dir ne '')
2995 &define_variable ('mkinstalldirs', ('$(SHELL) ' . $config_aux_dir
2996 . '/mkinstalldirs'));
3000 &define_variable ('mkinstalldirs',
3001 '$(SHELL) $(top_srcdir)/mkinstalldirs');
3004 &am_line_error ('CONFIG_HEADER',
3005 "\`CONFIG_HEADER' is an anachronism; now determined from \`configure.in'")
3006 if &variable_defined ('CONFIG_HEADER');
3009 local ($config_header) = '';
3010 foreach $one_name (@config_names)
3012 # Generate CONFIG_HEADER define.
3014 if ($relative_dir eq &dirname ($one_name))
3016 $one_hdr = &basename ($one_name);
3020 $one_hdr = "${top_builddir}/${one_name}";
3023 $config_header .= ' ' if $config_header;
3024 $config_header .= $one_hdr;
3028 &define_variable ("CONFIG_HEADER", $config_header);
3031 # Now look for other files in this directory which must be remade
3032 # by config.status, and generate rules for them.
3033 local (@actual_other_files) = ();
3034 local ($file, $local);
3035 local (@inputs, @rewritten_inputs, $single);
3036 foreach $file (@other_input_files)
3038 if ($file =~ /^(.*):(.*)$/)
3040 # This is the ":" syntax of AC_OUTPUT.
3042 $local = &basename ($file);
3043 @inputs = split (':', $2);
3044 @rewritten_inputs = &rewrite_inputs_into_dependencies (@inputs);
3049 $local = &basename ($file);
3050 @inputs = ($local . '.in');
3052 &rewrite_inputs_into_dependencies ($file . '.in');
3055 # Skip files not in this directory.
3056 next unless &dirname ($file) eq $relative_dir;
3058 # Skip any file that is an automake input.
3059 next if -f $file . '.am';
3061 # Some users have been tempted to put `stamp-h' in the
3062 # AC_OUTPUT line. This won't do the right thing, so we
3063 # explicitly fail here.
3064 if ($local eq 'stamp-h')
3066 # FIXME: allow real filename.
3067 &am_conf_error ('configure.in', $ac_output_line,
3068 'stamp-h should not appear in AC_OUTPUT');
3072 $output_rules .= ($local . ': '
3073 . '$(top_builddir)/config.status '
3074 . join (' ', @rewritten_inputs) . "\n"
3076 . 'cd $(top_builddir) && CONFIG_FILES='
3077 . ($relative_dir eq '.' ? '' : '$(subdir)/')
3078 . '$@' . (length (@rewritten_inputs) > 1
3079 ? (':' . join (':', @rewritten_inputs))
3081 . ' CONFIG_HEADERS= ./config.status'
3083 push (@actual_other_files, $local);
3085 # Require all input files.
3086 &require_file_with_conf_line ($ac_output_line, $FOREIGN,
3090 # These files get removed by "make clean".
3091 &define_pretty_variable ('CONFIG_CLEAN_FILES', '', @actual_other_files);
3097 $dir_holds_headers = &am_install_var ('header', 'HEADERS', 'include',
3098 'oldinclude', 'pkginclude',
3104 return if ! $seen_gettext || $relative_dir ne '.';
3106 if (! &variable_defined ('SUBDIRS'))
3109 ("AM_GNU_GETTEXT in configure.in but SUBDIRS not defined");
3113 &require_file_with_conf_line ($ac_gettext_line, $FOREIGN, 'ABOUT-NLS')
3116 if (&variable_defined ('SUBDIRS'))
3120 "AM_GNU_GETTEXT in configure.in but \`po' not in SUBDIRS")
3121 if $contents{'SUBDIRS'} !~ /\bpo\b/;
3124 "AM_GNU_GETTEXT in configure.in but \`intl' not in SUBDIRS")
3125 if $contents{'SUBDIRS'} !~ /\bintl\b/;
3128 # Ensure that each language in ALL_LINGUAS has a .po file, and
3129 # each po file is mentioned in ALL_LINGUAS.
3132 local (%linguas) = ();
3133 grep ($linguas{$_} = 1, split (' ', $all_linguas));
3140 &am_line_error ($all_linguas_line,
3141 ("po/$_.po exists but \`$_' not in \`ALL_LINGUAS'"))
3145 foreach (keys %linguas)
3147 &am_line_error ($all_linguas_line,
3148 "$_ in \`ALL_LINGUAS' but po/$_.po does not exist")
3154 &am_error ("AM_GNU_GETTEXT in configure.in but \`ALL_LINGUAS' not defined");
3158 # Handle footer elements.
3161 if ($contents{'SOURCES'})
3163 # NOTE don't use define_pretty_variable here, because
3164 # $contents{...} is already defined.
3165 $output_vars .= 'SOURCES = ' . $contents{'SOURCES'} . "\n";
3167 if ($contents{'OBJECTS'})
3169 # NOTE don't use define_pretty_variable here, because
3170 # $contents{...} is already defined.
3171 $output_vars .= 'OBJECTS = ' . $contents{'OBJECTS'} . "\n";
3173 if ($contents{'SOURCES'} || $contents{'OBJECTS'})
3175 $output_vars .= "\n";
3178 if (&variable_defined ('SUFFIXES'))
3180 # Push actual suffixes, and not $(SUFFIXES). Some versions of
3181 # make do not like variable substitutions on the .SUFFIXES
3183 push (@suffixes, &variable_value_as_list ('SUFFIXES', ''));
3185 if (&target_defined ('.SUFFIXES'))
3187 &am_line_error ('.SUFFIXES',
3188 "use variable \`SUFFIXES', not target \`.SUFFIXES'");
3191 # Note: AIX 4.1 /bin/make will fail if any suffix rule appears
3192 # before .SUFFIXES. So we make sure that .SUFFIXES appears before
3193 # anything else, by sticking it right after the default: target.
3194 $output_header .= ".SUFFIXES:\n";
3198 # Make sure suffixes has unique elements. Sort them to ensure
3199 # the output remains consistent.
3202 grep ($suffixes{$_} = 1, @suffixes);
3204 $output_header .= (".SUFFIXES: "
3205 . join (' ', sort keys %suffixes)
3208 $output_trailer .= &file_contents ('footer');
3211 # Deal with installdirs target.
3212 sub handle_installdirs
3214 # GNU Makefile standards recommend this.
3215 $output_rules .= ("installdirs:"
3216 . ($recursive_install
3217 ? " installdirs-recursive\n"
3219 push (@phony, 'installdirs');
3222 &pretty_print_rule ("\t" . '$(mkinstalldirs) ', "\t\t",
3225 $output_rules .= "\n";
3228 # There are several targets which need to be merged. This is because
3229 # their complete definition is compiled from many parts. Note that we
3230 # avoid double colon rules, otherwise we'd use them instead.
3231 sub handle_merge_targets
3233 local ($makefile) = @_;
3235 # There are a few install-related variables that you should not define.
3237 foreach $var ('PRE_INSTALL', 'POST_INSTALL', 'NORMAL_INSTALL')
3239 if (&variable_defined ($var))
3241 &am_line_error ($var, "\`$var' should not be defined");
3245 # Put this at the beginning for the sake of non-GNU makes. This
3246 # is still wrong if these makes can run parallel jobs. But it is
3248 unshift (@all, &basename ($makefile));
3251 foreach $one_name (@config_names)
3253 push (@all, &basename ($one_name))
3254 if &dirname ($one_name) eq $relative_dir;
3257 &do_one_merge_target ('info', @info);
3258 &do_one_merge_target ('dvi', @dvi);
3259 &do_check_merge_target;
3260 &do_one_merge_target ('installcheck', @installcheck);
3262 if (defined $options{'no-installinfo'})
3264 # FIXME: this is kind of a hack; should find another way to
3265 # know that this is required.
3267 if (grep ($_ eq 'install-info-am', @phony))
3269 push (@dirs, 'install-info-am');
3271 if (&variable_defined ('SUBDIRS'))
3273 push (@dirs, 'install-info-recursive');
3275 &do_one_merge_target ('install-info', @dirs);
3278 # Handle the various install targets specially. We do this so
3279 # that (eg) "make install-exec" will run "install-exec-recursive"
3280 # if required, but "make install" won't run it twice. Step one is
3281 # to see if the user specified local versions of any of the
3282 # targets we handle. "all" is treated as one of these since
3283 # "install" can run it.
3284 push (@install_exec, 'install-exec-local')
3285 if defined $contents{'install-exec-local'};
3286 push (@install_data, 'install-data-local')
3287 if defined $contents{'install-data-local'};
3288 push (@uninstall, 'uninstall-local')
3289 if defined $contents{'uninstall-local'};
3291 foreach $utarg ('uninstall-data-local', 'uninstall-data-hook',
3292 'uninstall-exec-local', 'uninstall-exec-hook')
3294 if (defined $contents{$utarg})
3297 ($x = $utarg) =~ s/(data|exec)-//;
3298 &am_line_error ($utarg, "use \`$x', not \`$utarg'");
3301 push (@all, 'all-local')
3302 if defined $contents{'all-local'};
3304 if (defined $contents{'install-local'})
3306 &am_line_error ('install-local',
3307 "use \`install-data' or \`install-exec', not \`install'");
3310 # Step two: if we are doing recursive makes, write out the
3311 # appropriate rules.
3313 if ($recursive_install)
3315 push (@install, 'install-recursive');
3319 local (@hackall) = ();
3321 local ($local_headers) = '';
3322 foreach $one_name (@config_names)
3324 if (&dirname ($one_name) eq $relative_dir)
3326 $local_headers .= ' ' if $local_headers;
3327 $local_headers .= &basename ($one_name);
3333 # This is kind of a hack, but I couldn't see a better
3334 # way to handle it. In this particular case, we need
3335 # to make sure config.h is built before we recurse.
3336 # We can't do this by changing the order of
3337 # dependencies to the "all" because that breaks when
3338 # using parallel makes. Instead we handle things
3340 $output_rules .= ("all-recursive-am: ${local_headers}"
3341 . "\n\t" . '$(MAKE) all-recursive'
3343 push (@hackall, 'all-recursive-am');
3344 push (@phony, 'all-recursive-am');
3348 push (@hackall, 'all-recursive');
3351 $output_rules .= ('all-am: '
3355 push (@all, 'all-am');
3356 push (@phony, 'all-am');
3360 @all = ('all-recursive');
3362 # Must always generate `all-am' target, so it can be
3363 # referred to elsewhere.
3364 $output_rules .= "all-am:\n";
3368 $output_rules .= ('install-exec-am: '
3369 . join (' ', @install_exec)
3371 @install_exec = ('install-exec-recursive', 'install-exec-am');
3372 push (@install, 'install-exec-am');
3373 push (@phony, 'install-exec-am');
3377 @install_exec = ('install-exec-recursive');
3381 $output_rules .= ('install-data-am: '
3382 . join (' ', @install_data)
3384 @install_data = ('install-data-recursive', 'install-data-am');
3385 push (@install, 'install-data-am');
3386 push (@phony, 'install-data-am');
3390 @install_data = ('install-data-recursive');
3394 $output_rules .= ('uninstall-am: '
3395 . join (' ', @uninstall)
3397 @uninstall = ('uninstall-recursive', 'uninstall-am');
3398 push (@phony, 'uninstall-am');
3402 @uninstall = ('uninstall-recursive');
3406 # Step three: print definitions users can use. Code below knows
3407 # that install-exec is done before install-data, beware.
3408 $output_rules .= ("install-exec: "
3409 . join (' ', @install_exec)
3411 $output_rules .= "\t\@\$(NORMAL_INSTALL)\n";
3412 if (defined $contents{'install-exec-hook'})
3414 $output_rules .= "\t" . '$(MAKE) install-exec-hook' . "\n";
3416 $output_rules .= "\n";
3417 push (@install, 'install-exec') if !$recursive_install;
3418 push (@phony, 'install-exec');
3420 $output_rules .= ("install-data: "
3421 . join (' ', @install_data)
3423 $output_rules .= "\t\@\$(NORMAL_INSTALL)\n";
3424 if (defined $contents{'install-data-hook'})
3426 $output_rules .= "\t" . '$(MAKE) install-data-hook' . "\n";
3428 $output_rules .= "\n";
3429 push (@install, 'install-data') if !$recursive_install;
3430 push (@phony, 'install-data');
3432 # If no dependencies for 'install', add 'all'. Why? That way
3433 # "make install" at top level of distclean'd distribution won't
3434 # fail because stuff in 'lib' fails to build.
3435 if (! @install || (scalar (@install) == 2
3436 && $install[0] eq 'install-exec'
3437 && $install[1] eq 'install-data'))
3439 push (@install, 'all');
3441 $output_rules .= ('install: '
3442 . join (' ', @install)
3443 # Use "@:" as empty command so nothing prints.
3447 . join (' ', @uninstall)
3449 push (@phony, 'install', 'uninstall');
3451 $output_rules .= ('all: '
3454 push (@phony, 'all');
3456 # Generate the new 'install-strip' target. Must set
3457 # INSTALL_SCRIPT to avoid stripping scripts.
3458 $output_rules .= ("install-strip:\n\t"
3459 . '$(MAKE) INSTALL_PROGRAM=\'$(INSTALL_PROGRAM) -s\' INSTALL_SCRIPT=\'$(INSTALL_PROGRAM)\' install'
3463 # Helper for handle_merge_targets.
3464 sub do_one_merge_target
3466 local ($name, @values) = @_;
3468 if (defined $contents{$name . '-local'})
3470 # User defined local form of target. So include it.
3471 push (@values, $name . '-local');
3472 push (@phony, $name . '-local');
3475 &pretty_print_rule ($name . ":", "\t\t", @values);
3476 push (@phony, $name);
3479 # Handle check merge target specially.
3480 sub do_check_merge_target
3482 if (defined $contents{'check-local'})
3484 # User defined local form of target. So include it.
3485 push (@check_tests, 'check-local');
3486 push (@phony, 'check-local');
3489 if (! &variable_defined ('SUBDIRS'))
3491 # 'check' must depend on `all', but not when doing recursive
3493 unshift (@check, 'all');
3497 # When subdirs are used, do the `all' build and then do all
3498 # the recursive stuff. Actually use `all-am' because it
3499 # doesn't recurse; we rely on the check target in the subdirs
3500 # to do the required builds there.
3501 unshift (@check, 'all-am');
3504 # The check target must depend on the local equivalent of `all',
3505 # to ensure all the primary targets are built. Also it must
3506 # depend on the test code named in @check.
3507 &pretty_print_rule ('check:', "\t\t", @check);
3509 # Now the check rules must explicitly run anything named in
3510 # @check_tests. This is done via a separate make invocation to
3511 # avoid problems with parallel makes. Every time I write code
3512 # like this I wonder: how could you invent a parallel make and not
3513 # provide any real synchronization facilities?
3514 &pretty_print_rule ("\t\$(MAKE)", "\t ", @check_tests);
3517 # Handle all 'clean' targets.
3520 push (@clean, 'generic');
3521 $output_rules .= &file_contents ('clean');
3522 &push_phony_cleaners ('generic');
3524 local ($target) = $recursive_install ? 'clean-am' : 'clean';
3525 &do_one_clean_target ($target, 'mostly', '', @clean);
3526 &do_one_clean_target ($target, '', 'mostly', @clean);
3527 &do_one_clean_target ($target, 'dist', '', @clean);
3528 &do_one_clean_target ($target, 'maintainer-', 'dist', @clean);
3530 push (@phony, 'clean', 'mostlyclean', 'distclean', 'maintainer-clean');
3533 if ($recursive_install)
3535 # Do -recursive before -am. If you aren't doing a parallel
3536 # make, this can be nicer.
3537 @deps = ('recursive', 'am');
3538 &do_one_clean_target ('', 'mostly', '', @deps);
3539 &do_one_clean_target ('', '', '', @deps);
3540 &do_one_clean_target ('', 'dist', '', @deps);
3541 &do_one_clean_target ('', 'maintainer-', '', @deps);
3545 # Helper for handle_clean.
3546 sub do_one_clean_target
3548 local ($target, $name, $last_name, @deps) = @_;
3550 # Special case: if target not passed, then don't generate
3551 # dependency on next "lower" clean target (eg no
3552 # clean<-mostlyclean derivation). In this case the target is
3553 # implicitly known to be 'clean'.
3554 local ($flag) = $target;
3555 $target = 'clean' if ! $flag;
3557 grep (($_ = $name . 'clean-' . $_) && 0, @deps);
3560 if ($last_name || $name ne 'mostly')
3562 push (@deps, $last_name . $target);
3566 # If a -local version of the rule is given, add it to the list.
3567 if (defined $contents{$name . $target . '-local'})
3569 push (@deps, $name . $target . '-local');
3572 # Print the target and the dependencies.
3573 &pretty_print_rule ($name . $target . ": ", "\t\t", @deps);
3575 # FIXME: shouldn't we really print these messages before running
3577 if ($name . $target eq 'maintainer-clean')
3579 # Print a special warning.
3581 ("\t\@echo \"This command is intended for maintainers to use;\"\n"
3582 . "\t\@echo \"it deletes files that may require special "
3583 . "tools to rebuild.\"\n");
3585 $output_rules .= "\trm -f config.status\n"
3586 if $relative_dir eq '.';
3588 elsif ($name . $target eq 'distclean')
3590 $output_rules .= "\trm -f config.status\n";
3591 $output_rules .= "\trm -f libtool\n" if $seen_libtool;
3593 $output_rules .= "\n";
3596 # Handle .PHONY target.
3599 &pretty_print_rule ('.PHONY:', "", @phony);
3600 $output_rules .= "\n";
3603 # Handle TESTS variable and other checks.
3606 if (defined $options{'dejagnu'})
3608 push (@check_tests, 'check-DEJAGNU');
3609 push (@phony, 'check-DEJAGNU');
3614 $xform = 's/^CYGNUS//;';
3618 $xform = 's/^CYGNUS.*$//;';
3620 $output_rules .= &file_contents_with_transform ($xform, 'dejagnu');
3622 # In Cygnus mode, these are found in the build tree.
3623 # Otherwise they are looked for in $PATH.
3624 &define_program_variable ('EXPECT', 'build', 'expect', 'expect');
3625 &define_program_variable ('RUNTEST', 'src', 'dejagnu', 'runtest');
3627 # Note that in the rule we don't directly generate site.exp to
3628 # avoid the possibility of a corrupted site.exp if make is
3629 # interrupted. Jim Meyering has some useful text on this
3631 $output_rules .= ("site.exp: Makefile\n"
3632 . "\t\@echo 'Making a new site.exp file...'\n"
3633 . "\t-\@rm -f site.bak\n"
3634 . "\t\@echo '## these variables are automatically generated by make ##' > \$\@-t\n"
3635 . "\t\@echo '# Do not edit here. If you wish to override these values' >> \$\@-t\n"
3636 . "\t\@echo '# edit the last section' >> \$\@-t\n"
3637 . "\t\@echo 'set tool \$(DEJATOOL)' >> \$\@-t\n"
3638 . "\t\@echo 'set srcdir \$(srcdir)' >> \$\@-t\n"
3639 . "\t\@echo 'set objdir' \`pwd\` >> \$\@-t\n");
3641 # Extra stuff for AC_CANONICAL_*
3642 local (@whatlist) = ();
3643 if ($seen_canonical)
3645 push (@whatlist, 'host')
3648 # Extra stuff only for AC_CANONICAL_SYSTEM.
3649 if ($seen_canonical == $AC_CANONICAL_SYSTEM)
3651 push (@whatlist, 'target', 'build');
3655 foreach $c1 (@whatlist)
3657 foreach $c2 ('alias', 'triplet')
3659 $output_rules .= "\t\@echo 'set ${c1}_${c2} \$(${c1}_${c2})' >> \$\@-t\n";
3663 $output_rules .= ("\t\@echo '## All variables above are generated by configure. Do Not Edit ##' >> \$\@-t\n"
3664 . "\t-\@sed '1,/^## All variables above are.*##/ d' site.bak >> \$\@-t\n"
3665 . "\t-\@mv site.exp site.bak\n"
3666 . "\t\@mv \$\@-t site.exp\n");
3671 foreach $c ('DEJATOOL', 'RUNTEST', 'RUNTESTFLAGS')
3673 if (&variable_defined ($c))
3675 &am_line_error ($c, "\`$c' defined but \`dejagnu' not in \`AUTOMAKE_OPTIONS'");
3680 if (&variable_defined ('TESTS'))
3682 push (@check_tests, 'check-TESTS');
3683 push (@phony, 'check-TESTS');
3685 $output_rules .= 'check-TESTS: $(TESTS)
3686 @failed=0; all=0; \\
3687 srcdir=$(srcdir); export srcdir; \\
3688 for tst in $(TESTS); do \\
3689 all=`expr $$all + 1`; \\
3690 if test -f $$tst; then dir=.; \\
3691 else dir="$(srcdir)"; fi; \\
3692 if $(TESTS_ENVIRONMENT) $$dir/$$tst; then \\
3693 echo "PASS: $$tst"; \\
3695 failed=`expr $$failed + 1`; \\
3696 echo "FAIL: $$tst"; \\
3699 if test "$$failed" -eq 0; then \\
3700 echo "========================"; \\
3701 echo "All $$all tests passed"; \\
3702 echo "========================"; \\
3704 echo "$$failed of $$all tests failed"; \\
3711 # Handle Emacs Lisp.
3712 sub handle_emacs_lisp
3714 local (@elfiles) = &am_install_var ('lisp', 'LISP', 'lisp', 'noinst');
3719 &define_configure_variable ('lispdir');
3720 &define_configure_variable ('EMACS');
3721 $output_rules .= (".el.elc:\n"
3722 . "\t\@echo 'WARNING: Warnings can be ignored. :-)'\n"
3723 . "\tif test \$(EMACS) != no; then \\\n"
3724 . "\t EMACS=\$(EMACS) \$(SHELL) \$(srcdir)/elisp-comp \$<; \\\n"
3726 push (@suffixes, '.el', '.elc');
3728 # Generate .elc files.
3729 grep ($_ .= 'c', @elfiles);
3730 &define_pretty_variable ('ELCFILES', '', @elfiles);
3732 push (@clean, 'lisp');
3733 &push_phony_cleaners ('lisp');
3735 push (@all, '$(ELCFILES)');
3738 if (&variable_defined ('lisp_LISP'))
3740 $varname = 'lisp_LISP';
3741 &am_error ("\`lisp_LISP' defined but \`AM_PATH_LISPDIR' not in \`configure.in'")
3746 $varname = 'noinst_LISP';
3749 &require_file_with_line ($varname, $FOREIGN, 'elisp-comp');
3753 ################################################################
3755 # Scan one file for interesting things. Subroutine of scan_configure.
3756 sub scan_one_configure_file
3758 local ($filename) = @_;
3760 open (CONFIGURE, $filename)
3761 || die "automake: couldn't open \`$filename': $!\n";
3762 print "automake: reading $filename\n" if $verbose;
3766 # Remove comments from current line.
3770 # Skip macro definitions. Otherwise we might be confused into
3771 # thinking that a macro that was only defined was actually
3775 # Populate libobjs array.
3776 if (/AC_FUNC_ALLOCA/)
3778 $libsources{'alloca.c'} = 1;
3780 elsif (/AC_FUNC_GETLOADAVG/)
3782 $libsources{'getloadavg.c'} = 1;
3784 elsif (/AC_FUNC_MEMCMP/)
3786 $libsources{'memcmp.c'} = 1;
3788 elsif (/AC_STRUCT_ST_BLOCKS/)
3790 $libsources{'fileblocks.c'} = 1;
3792 elsif (/A[CM]_REPLACE_GNU_GETOPT/)
3794 $libsources{'getopt.c'} = 1;
3795 $libsources{'getopt1.c'} = 1;
3797 elsif (/AM_FUNC_STRTOD/)
3799 $libsources{'strtod.c'} = 1;
3801 elsif (/AM_WITH_REGEX/)
3803 $libsources{'rx.c'} = 1;
3804 $libsources{'rx.h'} = 1;
3805 $libsources{'regex.c'} = 1;
3806 $libsources{'regex.h'} = 1;
3807 $omit_dependencies{'rx.h'} = 1;
3808 $omit_dependencies{'regex.h'} = 1;
3810 elsif (/AM_FUNC_MKTIME/)
3812 $libsources{'mktime.c'} = 1;
3814 elsif (/AM_FUNC_ERROR_AT_LINE/)
3816 $libsources{'error.c'} = 1;
3817 $libsources{'error.h'} = 1;
3819 elsif (/AM_FUNC_OBSTACK/)
3821 $libsources{'obstack.c'} = 1;
3822 $libsources{'obstack.h'} = 1;
3824 elsif (/LIBOBJS="(.*)\s+\$LIBOBJS"/
3825 || /LIBOBJS="\$LIBOBJS\s+(.*)"/)
3827 foreach $libobj_iter (split (' ', $1))
3829 if ($libobj_iter =~ /^(.*)\.o$/)
3831 $libsources{$1 . '.c'} = 1;
3836 if (! $in_ac_replace && s/AC_REPLACE_FUNCS\s*\(\[?//)
3842 $in_ac_replace = 0 if s/[\]\)].*$//;
3843 # Remove trailing backslash.
3847 # Need to skip empty elements for Perl 4.
3849 $libsources{$_ . '.c'} = 1;
3853 if (/$obsolete_rx/o)
3856 if ($obsolete_macros{$1})
3858 $hint = '; ' . $obsolete_macros{$1};
3860 &am_conf_line_error ($filename, $., "\`$1' is obsolete$hint");
3863 # Process the AC_OUTPUT macro.
3864 if (! $in_ac_output && s/AC_OUTPUT\s*\(\[?//)
3867 $ac_output_line = $.;
3871 $in_ac_output = 0 if s/[\]\),].*$//;
3873 # Look at potential Makefile.am's.
3878 # Handle $local:$input syntax. Note that we ignore
3879 # every input file past the first, though we keep
3880 # those around for later.
3881 local ($local, $input, @rest) = split (/:/);
3888 # FIXME: should be error if .in is missing.
3889 $input =~ s/\.in$//;
3892 if (-f $input . '.am')
3894 # We have a file that automake should generate.
3895 push (@make_input_list, $input);
3896 $make_list{$input} = join (':', ($local, @rest));
3900 # We have a file that automake should cause to be
3901 # rebuilt, but shouldn't generate itself.
3902 push (@other_input_files, $_);
3907 if (/$AC_CONFIG_AUX_DIR_PATTERN/o)
3909 @config_aux_path = $1;
3912 # Check for ansi2knr.
3913 $am_c_prototypes = 1 if /AM_C_PROTOTYPES/;
3915 # Check for Cygwin32.
3919 $configure_vars{'EXEEXT'} = 1;
3922 # Check for NLS support.
3923 if (/AM_GNU_GETTEXT/)
3926 $ac_gettext_line = $.;
3927 $omit_dependencies{'libintl.h'} = 1;
3930 # Look for ALL_LINGUAS.
3931 if (/ALL_LINGUAS="(.*)"$/ || /ALL_LINGUAS=(.*)$/)
3935 $all_linguas_line = $.;
3938 # Handle configuration headers. A config header of `[$1]'
3939 # means we are actually scanning AM_CONFIG_HEADER from
3941 if (/A([CM])_CONFIG_HEADER\s*\((.*)\)/
3946 "\`AC_CONFIG_HEADER' is obsolete; use \`AM_CONFIG_HEADER'")
3949 $config_header_line = $.;
3951 foreach $one_hdr (split (' ', $2))
3953 push (@config_fullnames, $one_hdr);
3954 if ($one_hdr =~ /^([^:]+):(.+)$/)
3956 push (@config_names, $1);
3957 push (@config_headers, $2);
3961 push (@config_names, $one_hdr);
3962 push (@config_headers, $one_hdr . '.in');
3967 # Handle AC_CANONICAL_*. Always allow upgrading to
3968 # AC_CANONICAL_SYSTEM, but never downgrading.
3969 $seen_canonical = $AC_CANONICAL_HOST
3970 if ! $seen_canonical
3971 && (/AC_CANONICAL_HOST/ || /AC_CHECK_TOOL/);
3972 $seen_canonical = $AC_CANONICAL_SYSTEM if /AC_CANONICAL_SYSTEM/;
3974 $seen_path_xtra = 1 if /AC_PATH_XTRA/;
3976 # This macro handles several different things.
3977 if (/$AM_INIT_AUTOMAKE_PATTERN/o)
3983 $seen_prog_install = 2;
3984 ($package_version = $1) =~ s/$AM_PACKAGE_VERSION_PATTERN/$1/o;
3985 $package_version_line = $.;
3988 # This is like AM_INIT_AUTOMAKE, but doesn't actually set the
3989 # package and version number. (This might change in the
3990 # future). Yes, I'm not above hacking Automake so it works
3991 # well with other GNU tools -- that is actually the point.
3992 if (/AM_INIT_GUILE_MODULE/)
3998 $seen_prog_install = 2;
3999 @config_aux_path = ('..');
4002 # Some things required by Automake.
4003 $seen_make_set = 1 if /AC_PROG_MAKE_SET/;
4004 $seen_arg_prog = 1 if /AC_ARG_PROGRAM/;
4006 if (/AC_PROG_(YACC|RANLIB|CC|CXX|LEX|AWK|CPP|CXXCPP|LN_S)/)
4008 $configure_vars{$1} = 1;
4010 if (/$AC_CHECK_PATTERN/o)
4012 $configure_vars{$3} = 1;
4014 if (/$AM_MISSING_PATTERN/o)
4016 $configure_vars{$1} = 1;
4019 # Explicitly avoid ANSI2KNR -- we AC_SUBST that in protos.m4,
4020 # but later define it elsewhere. This is pretty hacky. We
4021 # also explicitly avoid INSTALL_SCRIPT because it is defined
4022 # in header-vars.am. FIXME.
4023 if (/$AC_SUBST_PATTERN/o
4025 && $1 ne 'INSTALL_SCRIPT')
4027 $configure_vars{$1} = 1;
4030 $seen_decl_yytext = 1 if /AC_DECL_YYTEXT/;
4031 $seen_maint_mode = 1 if /AM_MAINTAINER_MODE/;
4032 $seen_package = 1 if /PACKAGE=/;
4034 # Skip VERSION of [$2]; that is from AM_INIT_AUTOMAKE.
4035 if (/\bVERSION=(\S+)/ && $1 ne '[$2]')
4038 $package_version = $1;
4039 $package_version_line = $.;
4046 # Weird conditionals here because it is always allowed to
4047 # upgrade to AM_PROG_INSTALL but never to downgrade to
4049 $seen_prog_install = 1 if ! $seen_prog_install && /AC_PROG_INSTALL/;
4050 $seen_prog_install = 2 if /AM_PROG_INSTALL/;
4052 $seen_lispdir = 1 if /AM_PATH_LISPDIR/;
4054 if (/AM_PROG_LIBTOOL/)
4058 $configure_vars{'LIBTOOL'} = 1;
4059 $configure_vars{'RANLIB'} = 1;
4060 $configure_vars{'CC'} = 1;
4061 # AM_PROG_LIBTOOL runs AC_CANONICAL_HOST. Make sure we
4062 # never downgrade (if we've seen AC_CANONICAL_SYSTEM).
4063 $seen_canonical = $AC_CANONICAL_HOST if ! $seen_canonical;
4066 if (/$AM_CONDITIONAL_PATTERN/o)
4068 $configure_cond{$1} = 1;
4075 # Scan configure.in and aclocal.m4 for interesting things. We must
4076 # scan aclocal.m4 because there might be AC_SUBSTs and such there.
4079 # Reinitialize libsources here. This isn't really necessary,
4080 # since we currently assume there is only one configure.in. But
4081 # that won't always be the case.
4084 local ($in_ac_output, $in_ac_replace) = (0, 0);
4085 local (%make_list, @make_input_list);
4086 local ($libobj_iter);
4088 &scan_one_configure_file ('configure.in');
4089 &scan_one_configure_file ('aclocal.m4')
4092 # Set input and output files if not specified by user.
4095 @input_files = @make_input_list;
4096 %output_files = %make_list;
4099 &am_conf_error ("\`PACKAGE' not defined in configure.in")
4101 &am_conf_error ("\`VERSION' not defined in configure.in")
4104 # Look for some files we need. Always check for these. This
4105 # check must be done for every run, even those where we are only
4106 # looking at a subdir Makefile. We must set relative_dir so that
4107 # the file-finding machinery works.
4108 local ($relative_dir) = '.';
4109 &require_config_file ($FOREIGN, 'install-sh', 'mkinstalldirs', 'missing');
4110 &am_error ("\`install.sh' is an anachronism; use \`install-sh' instead")
4111 if -f $config_aux_path[0] . '/install.sh';
4114 ################################################################
4116 # Set up for Cygnus mode.
4119 return unless $cygnus_mode;
4121 &set_strictness ('foreign');
4122 $options{'no-installinfo'} = 1;
4123 $options{'no-dependencies'} = 1;
4124 $use_dependencies = 0;
4126 if (! $seen_maint_mode)
4128 &am_conf_error ("\`AM_MAINTAINER_MODE' required when --cygnus specified");
4131 if (! $seen_cygwin32)
4133 &am_conf_error ("\`AM_CYGWIN32' required when --cygnus specified");
4137 # Do any extra checking for GNU standards.
4138 sub check_gnu_standards
4140 if ($relative_dir eq '.')
4142 # In top level (or only) directory.
4143 &require_file ($GNU, 'INSTALL', 'NEWS', 'README', 'COPYING',
4144 'AUTHORS', 'ChangeLog');
4147 if ($strictness >= $GNU)
4149 if (defined $options{'no-installman'})
4151 &am_line_error ('AUTOMAKE_OPTIONS',
4152 "option \`no-installman' disallowed by GNU standards");
4155 if (defined $options{'no-installinfo'})
4157 &am_line_error ('AUTOMAKE_OPTIONS',
4158 "option \`no-installinfo' disallowed by GNU standards");
4163 # Do any extra checking for GNITS standards.
4164 sub check_gnits_standards
4166 if ($strictness >= $GNITS)
4168 if (-f $relative_dir . '/COPYING.LIB')
4170 &am_error ("\`${relative_dir}/COPYING.LIB' disallowed by Gnits standards");
4173 if ($relative_dir eq '.')
4175 if ($package_version !~ /^$GNITS_VERSION_PATTERN$/)
4177 # FIXME: allow real filename.
4178 &am_conf_line_error ('configure.in',
4179 $package_version_line,
4180 "version \`$package_version' doesn't follow Gnits standards");
4182 elsif (defined $1 && -f 'README-alpha')
4184 # This means we have an alpha release. See
4185 # GNITS_VERSION_PATTERN for details.
4186 &require_file ($GNITS, 'README-alpha');
4191 if ($relative_dir eq '.')
4193 # In top level (or only) directory.
4194 &require_file ($GNITS, 'THANKS');
4198 ################################################################
4200 # Pretty-print something. HEAD is what should be printed at the
4201 # beginning of the first line, FILL is what should be printed at the
4202 # beginning of every subsequent line.
4203 sub pretty_print_internal
4205 local ($head, $fill, @values) = @_;
4207 local ($column) = length ($head);
4208 local ($result) = $head;
4210 # Fill length is number of characters. However, each Tab
4211 # character counts for eight. So we count the number of Tabs and
4213 local ($fill_length) = length ($fill);
4214 $fill_length += 7 * ($fill =~ tr/\t/\t/d);
4216 local ($bol) = ($head eq '');
4219 # "71" because we also print a space.
4220 if ($column + length ($_) > 71)
4222 $result .= " \\\n" . $fill;
4223 $column = $fill_length;
4227 $result .= ' ' unless ($bol);
4229 $column += length ($_) + 1;
4237 # Pretty-print something and append to output_vars.
4240 $output_vars .= &pretty_print_internal (@_);
4243 # Pretty-print something and append to output_rules.
4244 sub pretty_print_rule
4246 $output_rules .= &pretty_print_internal (@_);
4250 ################################################################
4252 # See if a target exists.
4255 local ($target) = @_;
4256 return defined $targets{$target};
4259 # See if two conditionals are the same.
4260 sub conditional_same
4262 local ($cond1, $cond2) = @_;
4264 return (&conditional_true_when ($cond1, $cond2)
4265 && &conditional_true_when ($cond2, $cond1));
4268 # See if a conditional is true. Both arguments are conditional
4269 # strings. This returns true if the first conditional is true when
4270 # the second conditional is true.
4271 sub conditional_true_when
4273 local ($cond, $when) = @_;
4275 # Check the easy case first.
4281 # Check each component of $cond, which looks @COND1@@COND2@.
4282 foreach $comp (split ('@', $cond))
4284 # The way we split will give null strings between each
4288 if (index ($when, '@' . $comp . '@') == -1)
4297 # Check for an ambiguous conditional. This is called when a variable
4298 # or target is being defined conditionally. If we already know about
4299 # a definition that is true under the same conditions, then we have an
4301 sub check_ambiguous_conditional
4303 local ($var_name, $cond) = @_;
4304 local (@cond_vals) = split (/ /, $conditional{$var_name});
4307 local ($vcond) = shift (@cond_vals);
4309 if (&conditional_true_when ($vcond, $cond)
4310 || &conditional_true_when ($cond, $vcond))
4312 &am_line_error ($var_name,
4313 "$var_name multiply defined in condition");
4318 # See if a variable exists. The first argument is the variable name,
4319 # and the optional second argument is the condition which we should
4320 # check. If no condition is given, we currently return true if the
4321 # variable is defined under any condition.
4322 sub variable_defined
4324 local ($var, $cond) = @_;
4325 if (defined $targets{$var})
4327 &am_line_error ($var, "\`$var' is target; expected variable");
4330 elsif (defined $contents{$var})
4332 if ($cond && $conditional{$var})
4334 # We have been asked to check for a particular condition,
4335 # and the variable is defined conditionally. We need to
4336 # look through the conditions under which the variable is
4337 # defined, and see if any of them match the conditional we
4338 # have been asked to check.
4339 local (@cond_vars) = split (/ /, $conditional{$var});
4342 if (&conditional_same ($cond, shift (@cond_vars)))
4349 # The variable is not defined for the given condition.
4353 $content_seen{$var} = 1;
4359 # Mark a variable as examined.
4360 sub examine_variable
4363 &variable_defined ($var);
4366 # Quote a value in order to put it in $conditional. We need to quote
4367 # spaces, and we need to handle null strings, so that we can later
4368 # retrieve values by splitting on space.
4373 $val = '\002' if $val eq '';
4377 # Unquote a value in $conditional.
4378 sub unquote_cond_val
4382 $val = '' if $val eq '\002';
4386 # Return the set of conditions for which a variable is defined.
4388 # If the variable is not defined conditionally, and is not defined in
4389 # terms of any variables which are defined conditionally, then this
4390 # returns the empty list.
4392 # If the variable is defined conditionally, but is not defined in
4393 # terms of any variables which are defined conditionally, then this
4394 # returns the list of conditions for which the variable is defined.
4396 # If the variable is defined in terms of any variables which are
4397 # defined conditionally, then this returns a full set of permutations
4398 # of the subvariable conditions. For example, if the variable is
4399 # defined in terms of a variable which is defined for @COND_TRUE@,
4400 # then this returns both @COND_TRUE@ and @COND_FALSE@. This is
4401 # because we will need to define the variable under both conditions.
4403 sub variable_conditions
4409 foreach $cond (&variable_conditions_sub ($var, '', ()))
4411 $uniqify{$cond} = 1;
4414 return keys %uniqify;
4417 # A subroutine of variable_conditions. We only return conditions
4418 # which are true for all the conditions in @PARENT_CONDS.
4419 sub variable_conditions_sub
4421 local ($var, $parent, @parent_conds) = @_;
4422 local (@new_conds) = ();
4424 if (! $conditional{$var})
4426 foreach (split (' ', $contents{$var}))
4428 # If a comment seen, just leave.
4431 # Handle variable substitutions.
4432 if (/^\$\{(.*)\}$/ || /^\$\((.*)\)$/)
4435 &variable_conditions_sub ($1, $var, @parent_conds));
4439 return &variable_conditions_reduce (@new_conds);
4442 local (@this_conds) = ();
4443 local (@condvals) = split (/ /, $conditional{$var});
4446 local ($cond) = shift (@condvals);
4447 local ($val) = &unquote_cond_val (shift (@condvals));
4452 local ($parent_cond);
4453 foreach $parent_cond (@parent_conds)
4455 if (! &conditional_true_when ($parent_cond, $cond))
4465 push (@this_conds, $cond);
4467 push (@parent_conds, $cond);
4468 local (@subvar_conds) = ();
4469 foreach (split (' ', $val))
4471 # If a comment seen, just leave.
4474 # Handle variable substitutions.
4475 if (/^\$\{(.*)\}$/ || /^\$\((.*)\)$/)
4477 push (@subvar_conds,
4478 &variable_conditions_sub ($1, $var, @parent_conds));
4481 pop (@parent_conds);
4483 # If there are no conditional subvariables, then we want to
4484 # return this condition. Otherwise, we want to return the
4485 # permutations of the subvariables.
4486 if (! @subvar_conds)
4488 push (@new_conds, $cond);
4492 push (@new_conds, &variable_conditions_reduce (@subvar_conds));
4499 # If we are being called on behalf of another variable, we need to
4500 # return all possible permutations of the conditions. We have
4501 # already handled everything in @this_conds along with their
4502 # subvariables. We now need to add any permutations that are not
4505 foreach $this_cond (@this_conds)
4508 &variable_conditions_permutations (split('@', $this_cond));
4510 foreach $perm (@perms)
4514 foreach $scan (@this_conds)
4516 if (&conditional_true_when ($perm, $scan)
4517 || &conditional_true_when ($scan, $perm))
4528 local ($parent_cond);
4529 foreach $parent_cond (@parent_conds)
4531 if (! &conditional_true_when ($parent_cond, $perm))
4541 # This permutation was not already handled, and is valid
4543 push (@new_conds, $perm);
4550 # Subroutine for variable_conditions_sort
4551 sub variable_conditions_cmp
4557 return (length ($as) <=> length ($bs)
4561 # Sort a list of conditionals so that only the exclusive ones are
4562 # retained. For example, if both @COND1_TRUE@@COND2_TRUE@ and
4563 # @COND1_TRUE@ are in the list, discard the latter.
4564 sub variable_conditions_reduce
4566 local (@conds) = @_;
4569 foreach $cond (sort variable_conditions_cmp @conds)
4573 foreach $scan (@ret)
4575 if (&conditional_true_when ($cond, $scan))
4588 # Return a list of permutations of a conditional string.
4589 sub variable_conditions_permutations
4591 local (@comps) = @_;
4594 local ($comp) = shift (@comps);
4595 return &variable_conditions_permutations (@comps)
4597 local ($neg) = $comp;
4598 $neg =~ s/TRUE$/TRUEO/;
4599 $neg =~ s/FALSE$/TRUE/;
4600 $neg =~ s/TRUEO$/FALSE/;
4603 foreach $sub (&variable_conditions_permutations (@comps))
4605 push (@ret, '@' . $comp . '@' . $sub);
4606 push (@ret, '@' . $neg . '@' . $sub);
4610 push (@ret, '@' . $comp . '@');
4611 push (@ret, '@' . $neg . '@');
4616 # Warn if a variable is conditionally defined. This is called if we
4617 # are using the value of a variable.
4618 sub variable_conditionally_defined
4620 local ($var, $parent) = @_;
4621 if ($conditional{$var})
4625 &am_line_error ($parent,
4626 "warning: automake does not support conditional definition of $var in $parent");
4630 &am_line_error ($parent,
4631 "warning: automake does not support $var being defined conditionally")
4636 # Get the value of a variable. This just returns $contents, but warns
4637 # if the variable is conditionally defined.
4641 &variable_conditionally_defined ($var);
4642 return $contents{$var};
4645 # Convert a variable value to a list, split as whitespace. This will
4646 # recursively follow $(...) and ${...} inclusions. It preserves @...@
4647 # substitutions. If COND is 'all', then all values under all
4648 # conditions should be returned; if COND is a particular condition
4649 # (all conditions are surrounded by @...@) then only the value for
4650 # that condition should be returned; otherwise, warn if VAR is
4651 # conditionally defined.
4654 local ($var, $val, $cond) = @_;
4657 foreach (split (' ', $val))
4659 # If a comment seen, just leave.
4662 # Handle variable substitutions.
4663 if (/^\$\{([^}]*)\}$/ || /^\$\(([^)]*)\)$/)
4665 local ($varname) = $1;
4668 if ($varname =~ /^([^:]*):([^=]*)=(.*)$/)
4672 ($from = $2) =~ s/(\W)/\\$1/g;
4676 @temp_list = &variable_value_as_list ($1, $cond, $var);
4678 # Now rewrite the value if appropriate.
4681 grep (s/$from$/$to/, @temp_list);
4684 push (@result, @temp_list);
4695 # Return contents of variable as list, split as whitespace. This will
4696 # recursively follow $(...) and ${...} inclusions. It preserves @...@
4697 # substitutions. If COND is 'all', then all values under all
4698 # conditions should be returned; if COND is a particular condition
4699 # (all conditions are surrounded by @...@) then only the value for
4700 # that condition should be returned; otherwise, warn if VAR is
4701 # conditionally defined. If PARENT is specified, it is the name of
4702 # the including variable; this is only used for error reports.
4703 sub variable_value_as_list
4705 local ($var, $cond, $parent) = @_;
4708 if (defined $targets{$var})
4710 &am_line_error ($var, "\`$var' is target; expected variable");
4712 elsif (! defined $contents{$var})
4714 &am_line_error ($parent, "variable \`$var' not defined");
4716 elsif ($cond eq 'all' && $conditional{$var})
4718 local (@condvals) = split (/ /, $conditional{$var});
4722 local ($val) = &unquote_cond_val (shift (@condvals));
4723 push (@result, &value_to_list ($var, $val, $cond));
4726 elsif ($cond && $conditional{$var})
4728 local (@condvals) = split (/ /, $conditional{$var});
4732 local ($vcond) = shift (@condvals);
4733 local ($val) = &unquote_cond_val (shift (@condvals));
4734 if (&conditional_true_when ($vcond, $cond))
4736 # Warn if we have an ambiguity. It's hard to know how
4737 # to handle this case correctly.
4738 &variable_conditionally_defined ($var, $parent)
4741 push (@result, &value_to_list ($var, $val, $cond));
4747 &variable_conditionally_defined ($var, $parent);
4748 $content_seen{$var} = 1;
4749 push (@result, &value_to_list ($var, $contents{$var}, $cond));
4755 # Define a new variable, but only if not already defined.
4758 local ($var, $value) = @_;
4760 if (! defined $contents{$var})
4762 $output_vars .= $var . ' = ' . $value . "\n";
4763 $contents{$var} = $value;
4764 $content_seen{$var} = 1;
4768 # Like define_variable, but the value is a list, and the variable may
4769 # be defined conditionally. The second argument is the conditional
4770 # under which the value should be defined; this should be the empty
4771 # string to define the variable unconditionally. The third argument
4772 # is a list holding the values to use for the variable. The value is
4773 # pretty printed in the output file.
4774 sub define_pretty_variable
4776 local ($var, $cond, @value) = @_;
4777 if (! defined $contents{$var}
4778 || ($cond && ! &variable_defined ($var, $cond)))
4780 $contents{$var} = join (' ', @value);
4783 if ($conditional{$var})
4785 $conditional{$var} .= ' ';
4789 $conditional{$var} = '';
4791 $conditional{$var} .= ($cond
4793 . "e_cond_val ($contents{$var}));
4795 &pretty_print ($cond . $var . ' = ', $cond, @value);
4796 $content_seen{$var} = 1;
4800 # Like define_variable, but define a variable to be the configure
4801 # substitution by the same name.
4802 sub define_configure_variable
4805 local ($value) = '@' . $var . '@';
4806 &define_variable ($var, $value);
4809 # Define a variable that represents a program to run. If in Cygnus
4810 # mode, the program is searched for in the build (or source) tree.
4811 # Otherwise no searching is done at all. Arguments are:
4812 # * VAR Name of variable to define
4813 # * WHATDIR Either `src' or `build', depending on where program should
4814 # be found. (runtest is in srcdir!)
4815 # * SUBDIR Subdir of top-level dir
4816 # * PROGRAM Name of program
4817 # * OVERRIDE If specified, the name of the program to use when not in
4818 # Cygnus mode. Defaults to PROGRAM.
4819 sub define_program_variable
4821 local ($var, $whatdir, $subdir, $program, $override) = @_;
4825 $override = $program;
4830 local ($full) = ('$(top_' . $whatdir . 'dir)/../'
4831 . $subdir . '/' . $program);
4832 &define_variable ($var, ('`if test -f ' . $full
4833 . '; then echo ' . $full . '; else echo '
4834 . $program . '; fi`'));
4838 &define_variable ($var, $override);
4843 ################################################################
4845 # Read Makefile.am and set up %contents. Simultaneously copy lines
4846 # from Makefile.am into $output_trailer or $output_vars as
4847 # appropriate. NOTE we put rules in the trailer section. We want
4848 # user rules to come after our generated stuff.
4851 local ($amfile) = @_;
4853 open (AM_FILE, $amfile) || die "automake: couldn't open \`$amfile': $!\n";
4854 print "automake: reading $amfile\n" if $verbose;
4856 $output_vars = ("# $in_file_name generated automatically by automake "
4857 . $VERSION . " from $am_file_name\n");
4859 # Generate copyright for generated Makefile.in.
4860 $output_vars .= $gen_copyright;
4862 local ($saw_bk) = 0;
4863 local ($was_rule) = 0;
4864 local ($spacing) = '';
4865 local ($comment) = '';
4866 local ($last_var_name) = '';
4871 if (/$IGNORE_PATTERN/o)
4873 # Merely delete comments beginning with two hashes.
4875 elsif (/$WHITE_PATTERN/o)
4877 # Stick a single white line before the incoming macro or rule.
4881 elsif (/$COMMENT_PATTERN/o)
4883 # Stick comments before the incoming macro or rule. Make
4884 # sure a blank line preceeds first block of comments.
4885 $spacing = "\n" unless $blank;
4887 $comment .= $spacing . $_;
4896 $output_vars .= $comment . "\n";
4899 local ($am_vars) = '';
4901 local ($is_ok_macro);
4905 unless substr ($_, -1, 1) eq "\n";
4907 $_ =~ s/\@MAINT\@//g
4908 unless $seen_maint_mode;
4910 if (/$IGNORE_PATTERN/o)
4912 # Merely delete comments beginning with two hashes.
4914 elsif (/$WHITE_PATTERN/o)
4916 # Stick a single white line before the incoming macro or rule.
4919 elsif (/$COMMENT_PATTERN/o)
4921 # Stick comments before the incoming macro or rule.
4922 $comment .= $spacing . $_;
4929 $output_trailer .= join ('', @conditional_stack) . $_;
4934 $am_vars .= join ('', @conditional_stack) . $_;
4936 # Chop newline and backslash if this line is
4937 # continued. FIXME: maybe ensure trailing whitespace
4941 $contents{$last_var_name} .= $_;
4942 if (@conditional_stack)
4944 $conditional{$last_var_name} .= "e_cond_val ($_);
4948 elsif (/$IF_PATTERN/o)
4950 &am_line_error ($., "$1 does not appear in AM_CONDITIONAL")
4951 if (! $configure_cond{$1});
4952 push (@conditional_stack, "\@" . $1 . "_TRUE\@");
4954 elsif (/$ELSE_PATTERN/o)
4956 if (! @conditional_stack)
4958 &am_line_error ($., "else without if");
4960 elsif ($conditional_stack[$#conditional_stack] =~ /_FALSE\@$/)
4962 &am_line_error ($., "else after else");
4966 $conditional_stack[$#conditional_stack]
4967 =~ s/_TRUE\@$/_FALSE\@/;
4970 elsif (/$ENDIF_PATTERN/o)
4972 if (! @conditional_stack)
4974 &am_line_error ($., "endif without if");
4978 pop @conditional_stack;
4981 elsif (/$RULE_PATTERN/o)
4985 if (defined $contents{$1}
4986 && (@conditional_stack
4987 ? ! defined $conditional{$1}
4988 : defined $conditional{$1}))
4991 "$1 defined both conditionally and unconditionally");
4993 # Value here doesn't matter; for targets we only note
4997 local ($cond_string) = join ('', @conditional_stack);
4998 if (@conditional_stack)
5000 if ($conditional{$1})
5002 &check_ambiguous_conditional ($1, $cond_string);
5003 $conditional{$1} .= ' ';
5007 $conditional{$1} = '';
5009 $conditional{$1} .= $cond_string . ' 1';
5011 $content_lines{$1} = $.;
5012 $output_trailer .= $comment . $spacing . $cond_string . $_;
5013 $comment = $spacing = '';
5016 elsif (($is_ok_macro = /$MACRO_PATTERN/o)
5017 || /$BOGUS_MACRO_PATTERN/o)
5019 # Found a macro definition.
5021 $last_var_name = $1;
5022 if (defined $contents{$1}
5023 && (@conditional_stack
5024 ? ! defined $conditional{$1}
5025 : defined $conditional{$1}))
5028 "$1 defined both conditionally and unconditionally");
5030 if ($2 ne '' && substr ($2, -1) eq "\\")
5032 $contents{$last_var_name} = substr ($2, 0, length ($2) - 1);
5036 $contents{$last_var_name} = $2;
5038 local ($cond_string) = join ('', @conditional_stack);
5039 if (@conditional_stack)
5041 if ($conditional{$last_var_name})
5043 &check_ambiguous_conditional ($last_var_name,
5045 $conditional{$last_var_name} .= ' ';
5049 $conditional{$last_var_name} = '';
5051 local ($val) = $contents{$last_var_name};
5052 $conditional{$last_var_name} .= ($cond_string
5054 . "e_cond_val ($val));
5056 $content_lines{$last_var_name} = $.;
5057 $am_vars .= $comment . $spacing . $cond_string . $_;
5058 $comment = $spacing = '';
5062 &am_line_error ($., "bad macro name \`$last_var_name'")
5067 # This isn't an error; it is probably a continued rule.
5068 # In fact, this is what we assume.
5070 $output_trailer .= ($comment . $spacing
5071 . join ('', @conditional_stack) . $_);
5072 $comment = $spacing = '';
5079 $output_trailer .= $comment;
5081 &am_error ("unterminated conditionals: " . join (' ', @conditional_stack))
5082 if (@conditional_stack);
5084 # Compute relative location of the top object directory.
5085 local (@topdir) = ();
5086 foreach (split (/\//, $relative_dir))
5088 next if $_ eq '.' || $_ eq '';
5095 push (@topdir, '..');
5098 @topdir = ('.') if ! @topdir;
5100 $top_builddir = join ('/', @topdir);
5102 ($build_rx = $top_builddir) =~ s/(\W)/\\$1/g;
5103 $output_vars .= &file_contents_with_transform
5104 ('s/\@top_builddir\@/' . $build_rx . '/g;',
5107 # Generate some useful variables when AC_CANONICAL_* used. FIXME:
5108 # this should use generic %configure_vars method.
5109 if ($seen_canonical)
5111 local ($curs, %vars);
5112 $vars{'host_alias'} = 'host_alias';
5113 $vars{'host_triplet'} = 'host';
5114 if ($seen_canonical == $AC_CANONICAL_SYSTEM)
5116 $vars{'build_alias'} = 'build_alias';
5117 $vars{'build_triplet'} = 'build';
5118 $vars{'target_alias'} = 'target_alias';
5119 $vars{'target_triplet'} = 'target';
5121 foreach $curs (sort keys %vars)
5123 $output_vars .= "$curs = \@$vars{$curs}\@\n";
5124 $contents{$curs} = "\@$vars{$curs}\@";
5129 foreach $curs (sort keys %configure_vars)
5131 &define_configure_variable ($curs);
5134 $output_vars .= $am_vars;
5137 ################################################################
5139 sub initialize_global_constants
5141 # Values for AC_CANONICAL_*
5142 $AC_CANONICAL_HOST = 1;
5143 $AC_CANONICAL_SYSTEM = 2;
5145 # Associative array of standard directory names. Entry is TRUE if
5146 # corresponding directory should be installed during
5147 # 'install-exec' phase.
5165 # Helper text for dealing with man pages.
5166 $install_man_format =
5167 ' @sect=@SECTION@; \\
5168 inst=`echo "@MANBASE@" | sed \'$(transform)\'`.@FULLSECT@; \\
5169 if test -f $(srcdir)/@MAN@; then file=$(srcdir)/@MAN@; \\
5170 else file=@MAN@; fi; \\
5171 echo " $(INSTALL_DATA) $$file $(mandir)/man$$sect/$$inst"; \\
5172 $(INSTALL_DATA) $$file $(mandir)/man$$sect/$$inst
5175 $uninstall_man_format =
5176 ' inst=`echo "@MANBASE@" | sed \'$(transform)\'`.@FULLSECT@; \\
5177 rm -f $(mandir)/man@SECTION@/$$inst
5180 # Commonly found files we look for and automatically include in
5184 "README", "THANKS", "TODO", "NEWS", "COPYING", "COPYING.LIB",
5185 "INSTALL", "ABOUT-NLS", "ChangeLog", "configure", "configure.in",
5186 "config.guess", "config.sub", "AUTHORS", "BACKLOG", "ABOUT-GNU",
5187 "libversion.in", "mdate-sh", "mkinstalldirs", "install-sh",
5188 'texinfo.tex', "ansi2knr.c", "ansi2knr.1", 'elisp-comp',
5189 'ylwrap', 'acinclude.m4', @libtoolize_files,
5193 # Commonly used files we auto-include, but only sometimes.
5196 "aclocal.m4", "acconfig.h", "config.h.top",
5197 "config.h.bot", "stamp-h.in", 'stamp-vti'
5201 -a, --add-missing add missing standard files to package
5202 --amdir=DIR directory storing config files
5203 --build-dir=DIR directory where build being done (for dependencies)
5204 --cygnus assume program is part of Cygnus-style tree
5205 --foreign set strictness to foreign
5206 --gnits set strictness to gnits
5207 --gnu set strictness to gnu
5208 --help print this help, then exit
5209 -i, --include-deps include generated dependencies in Makefile.in
5210 --no-force only update Makefile.in's that are out of date
5211 -o DIR, --output-dir=DIR
5212 put generated Makefile.in's into DIR
5213 --srcdir-name=DIR name used for srcdir (for dependencies)
5214 -v, --verbose verbosely list files processed
5215 --version print version number, then exit\n";
5217 # Copyright on generated Makefile.ins.
5219 # Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
5220 # This Makefile.in is free software; the Free Software Foundation
5221 # gives unlimited permission to copy, distribute and modify it.
5224 # Ignore return result from chmod, because it might give an error
5225 # if we chmod a symlink.
5226 $dist_header = "\t" . '-chmod -R a+r $(distdir)' . "\n";
5227 $dist{'tarZ'} = ("\t"
5228 . '$(TAR) chf - $(distdir) | compress -c > $(distdir).tar.Z'
5230 $dist{'shar'} = ("\t"
5231 . 'shar $(distdir) | gzip > $(distdir).shar.gz'
5233 $dist{'zip'} = "\t" . 'zip -rq $(distdir).zip $(distdir)' . "\n";
5234 $dist{'dist'} = "\t" . 'GZIP=$(GZIP) $(TAR) chozf $(distdir).tar.gz $(distdir)' . "\n";
5235 $dist_trailer = "\t" . 'rm -rf $(distdir)' . "\n";
5238 # (Re)-Initialize per-Makefile.am variables.
5239 sub initialize_per_input
5241 # These two variables are used when generating each Makefile.in.
5242 # They hold the Makefile.in until it is ready to be printed.
5245 $output_trailer = '';
5246 $output_header = '';
5248 # Suffixes found during a run.
5251 # This holds the contents of a Makefile.am, as parsed by
5255 # This holds the names which are targets. These also appear in
5259 # For a variable or target which is defined conditionally, this
5260 # holds an array of the conditional values. The array is composed
5261 # of pairs of condition strings (the variables which configure
5262 # will substitute) and values (the value of a target is
5263 # meaningless). For an unconditional variable, this is empty.
5266 # This holds the line numbers at which various elements of
5267 # %contents are defined.
5268 %content_lines = ();
5270 # This holds a 1 if a particular variable was examined.
5273 # This is the conditional stack.
5274 @conditional_stack = ();
5276 # This holds the "relative directory" of the current Makefile.in.
5277 # Eg for src/Makefile.in, this is "src".
5280 # This holds a list of files that are included in the
5284 # List of dependencies for the obvious targets.
5300 # These are pretty obvious, too. They are used to define the
5301 # SOURCES and OBJECTS variables.
5305 # TRUE if current directory holds any C source files.
5306 $dir_holds_sources = 0;
5308 # These variables track inclusion of various compile-related .am
5309 # files. $included_generic_compile is TRUE if the basic code has
5310 # been included. $included_knr_compile is TRUE if the ansi2knr
5311 # code has been included. $included_libtool_compile is TRUE if
5312 # libtool support has been included.
5313 $included_generic_compile = 0;
5314 $included_knr_compile = 0;
5315 $included_libtool_compile = 0;
5317 # TRUE if current directory holds any headers.
5318 $dir_holds_headers = 0;
5320 # TRUE if install targets should work recursively.
5321 $recursive_install = 0;
5326 # Strictness levels.
5327 $strictness = $default_strictness;
5328 $strictness_name = $default_strictness_name;
5330 # Options from AUTOMAKE_OPTIONS.
5333 # Whether or not dependencies are handled. Can be further changed
5334 # in handle_options.
5335 $use_dependencies = $cmdline_use_dependencies;
5338 $local_maint_charset = $maint_charset;
5340 # All yacc and lex source filenames for this directory. Use
5341 # filenames instead of raw count so that multiple instances are
5342 # counted correctly (eg one yacc file can appear in multiple
5343 # programs without harm).
5347 # C++ source extensions we've seen.
5348 %cxx_extensions = ();
5350 # TRUE if we've seen any non-C++ sources. This actually holds a
5351 # line number or the name of a symbol corresponding to a line
5352 # number where the C sources were seen. If it is -1 then it means
5353 # we couldn't (easily) figure out which line of the Makefile.am
5354 # mentioned the sources.
5357 # This is a list of all targets to run during "make dist".
5360 # Keys in this hash are the names of ._o files which must depend
5362 %de_ansi_objects = ();
5366 ################################################################
5368 # Return contents of a file from $am_dir, automatically skipping
5369 # macros or rules which are already known. Runs command on each line
5370 # as it is read; this command can modify $_.
5371 sub file_contents_with_transform
5373 local ($command, $basename) = @_;
5374 local ($file) = $am_dir . '/' . $basename . '.am';
5376 if ($command ne '' && substr ($command, -1) ne ';')
5378 die "automake: programming error in file_contents_with_transform\n";
5381 open (FC_FILE, $file)
5382 || die "automake: installation error: cannot open \`$file'\n";
5384 # print "automake: reading $file\n" if $verbose;
5386 local ($was_rule) = 0;
5387 local ($result_vars) = '';
5388 local ($result_rules) = '';
5389 local ($comment) = '';
5390 local ($spacing) = "\n";
5391 local ($skipping) = 0;
5396 $_ =~ s/\@MAINT\@//g
5397 unless $seen_maint_mode;
5399 $had_chars = length ($_) && $_ ne "\n";
5401 # If the transform caused all the characters to go away, then
5402 # ignore the line. Why do this? Because in Perl 4, a "next"
5403 # inside of an eval doesn't affect a loop outside the eval.
5404 # So we can't pass in a "transform" that uses next. We used
5405 # to do this. "Empty" also means consisting of a single
5407 next if $had_chars && ($_ eq '' || $_ eq "\n");
5409 if (/$IGNORE_PATTERN/o)
5411 # Merely delete comments beginning with two hashes.
5413 elsif (/$WHITE_PATTERN/o)
5415 # Stick a single white line before the incoming macro or rule.
5418 elsif (/$COMMENT_PATTERN/o)
5420 # Stick comments before the incoming macro or rule.
5421 $comment .= $spacing . $_;
5428 $result_rules .= $_ if ! $skipping;
5432 $result_vars .= $_ if ! $skipping;
5436 elsif (/$RULE_PATTERN/o)
5440 $skipping = defined $contents{$1};
5441 $result_rules .= $comment . $spacing . $_ if ! $skipping;
5442 $comment = $spacing = '';
5445 elsif (/$MACRO_PATTERN/o)
5447 # Found a variable reference.
5449 $skipping = defined $contents{$1};
5450 $result_vars .= $comment . $spacing . $_ if ! $skipping;
5451 $comment = $spacing = '';
5456 # This isn't an error; it is probably a continued rule.
5457 # In fact, this is what we assume.
5459 $result_rules .= $comment . $spacing . $_ if ! $skipping;
5460 $comment = $spacing = '';
5466 return $result_vars . $result_rules . $comment;
5469 # Like file_contents_with_transform, but no transform.
5472 return &file_contents_with_transform ('', @_);
5475 # Find all variable prefixes that are used for install directories. A
5476 # prefix `zar' qualifies iff:
5477 # * `zardir' is a variable.
5478 # * `zar_PRIMARY' is a variable.
5479 sub am_primary_prefixes
5481 local ($primary, @prefixes) = @_;
5483 local (%valid, $varname);
5484 grep ($valid{$_} = 0, @prefixes);
5485 $valid{'EXTRA'} = 0;
5486 foreach $varname (keys %contents)
5488 if ($varname =~ /^(.*)_$primary$/)
5490 if (! defined $valid{$1}
5491 && ! &variable_defined ($1 . 'dir')
5492 # Note that a configure variable is always legitimate.
5493 # It is natural to name such variables after the
5494 # primary, so we explicitly allow it.
5495 && ! defined $configure_vars{$varname})
5497 &am_line_error ($varname, "invalid variable \"$varname\"");
5501 # Ensure all extended prefixes are actually used.
5510 # Handle `where_HOW' variable magic. Does all lookups, generates
5511 # install code, and possibly generates code to define the primary
5512 # variable. The first argument is the name of the .am file to munge,
5513 # the second argument is the primary variable (eg HEADERS), and all
5514 # subsequent arguments are possible installation locations. Returns
5515 # list of all values of all _HOW targets.
5517 # FIXME: this should be rewritten to be cleaner. It should be broken
5518 # up into multiple functions.
5520 # Usage is: am_install_var (OPTION..., file, HOW, where...)
5525 local ($do_clean) = 0;
5528 if (defined $configure_vars{'LIBTOOL'})
5530 # Transform '@LIBTOOL ...@' to '$(LIBTOOL) ...'
5531 $ltxform = 's/\@LIBTOOL([^\@]*)\@/\$(LIBTOOL) $1/;';
5535 # Delete '@LIBTOOL ...@'
5536 $ltxform = 's/\@LIBTOOL([^\@]*)\@//;';
5540 if (! $seen_cygwin32)
5542 $cygxform = 's/\@EXEEXT\@//g; s/^NOTCYGWIN//; s/^CYGWIN.*$//;';
5546 $cygxform = 's/\@EXEEXT\@/\$(EXEEXT)/g; s/^CYGWIN//; s/^NOTCYGWIN.*$//;';
5551 if ($args[0] eq '-clean')
5555 elsif ($args[0] !~ /^-/)
5561 local ($file, $primary, @prefixes) = @args;
5564 local (@result) = ();
5566 # Now that configure substitutions are allowed in where_HOW
5567 # variables, it is an error to actually define the primary.
5568 &am_line_error ($primary, "\`$primary' is an anachronism")
5569 if &variable_defined ($primary);
5572 # Look for misspellings. It is an error to have a variable ending
5573 # in a "reserved" suffix whose prefix is unknown, eg
5574 # "bni_PROGRAMS". However, unusual prefixes are allowed if a
5575 # variable of the same name (with "dir" appended) exists. For
5576 # instance, if the variable "zardir" is defined, then
5577 # "zar_PROGRAMS" becomes valid. This is to provide a little extra
5578 # flexibility in those cases which need it. Perhaps it should be
5579 # disallowed in the Gnits case? The problem is, sometimes it is
5580 # useful to put things in a subdir of eg pkgdatadir, perhaps even
5582 local (%valid) = &am_primary_prefixes ($primary, @prefixes);
5584 # If a primary includes a configure substitution, then the EXTRA_
5585 # form is required. Otherwise we can't properly do our job.
5586 local ($require_extra);
5587 local ($warned_about_extra) = 0;
5589 local ($clean_file) = $file . '-clean';
5592 foreach $X (sort keys %valid)
5594 $one_name = $X . '_' . $primary;
5595 if (&variable_defined ($one_name))
5597 # Append actual contents of where_PRIMARY variable to
5600 foreach $rcurs (&variable_value_as_list ($one_name, 'all'))
5602 # Skip configure substitutions. Possibly bogus.
5603 if ($rcurs =~ /^\@.*\@$/)
5607 if (! $warned_about_extra)
5609 $warned_about_extra = 1;
5610 &am_line_error ($one_name,
5611 "\`$one_name' contains configure substitution, but shouldn't");
5614 # Check here to make sure variables defined in
5615 # configure.in do not imply that EXTRA_PRIMARY
5617 elsif (! defined $configure_vars{$one_name})
5619 $require_extra = $one_name;
5623 push (@result, $rcurs);
5626 # "EXTRA" shouldn't be used when generating clean targets,
5627 # @all, or install targets.
5628 next if $X eq 'EXTRA';
5633 &file_contents_with_transform ('s/\@DIR\@/' . $X . '/go;'
5637 push (@clean, $X . $primary);
5638 &push_phony_cleaners ($X . $primary);
5643 push (@check, '$(' . $one_name . ')');
5647 push (@used, '$(' . $one_name . ')');
5649 if ($X eq 'noinst' || $X eq 'check')
5651 # Objects which don't get installed by default.
5656 &file_contents_with_transform ('s/\@DIR\@/' . $X . '/g;'
5657 . $ltxform . $cygxform,
5660 push (@uninstall, 'uninstall-' . $X . $primary);
5661 push (@phony, 'uninstall-' . $X . $primary);
5662 push (@installdirs, '$(' . $X . 'dir)');
5663 if (defined $exec_dir_p{$X} ? $exec_dir_p{$X} : ($X =~ /exec/))
5665 push (@install_exec, 'install-' . $X . $primary);
5666 push (@phony, 'install-' . $X . $primary);
5670 push (@install_data, 'install-' . $X . $primary);
5671 push (@phony, 'install-' . $X . $primary);
5679 &define_pretty_variable ($primary, '', @used);
5680 $output_vars .= "\n";
5683 if ($require_extra && ! &variable_defined ('EXTRA_' . $primary))
5685 &am_line_error ($require_extra,
5686 "\`$require_extra' contains configure substitution, but \`EXTRA_$primary' not defined");
5689 # Push here because PRIMARY might be configure time determined.
5690 push (@all, '$(' . $primary . ')')
5697 ################################################################
5699 # This variable is local to the "require file" set of functions.
5700 @require_file_paths = ();
5702 # Verify that the file must exist in the current directory. Usage:
5703 # require_file (isconfigure, line_number, strictness, file) strictness
5704 # is the strictness level at which this file becomes required. Must
5705 # set require_file_paths before calling this function.
5706 # require_file_paths is set to hold a single directory (the one in
5707 # which the first file was found) before return.
5708 sub require_file_internal
5710 local ($is_configure, $line, $mystrict, @files) = @_;
5711 local ($file, $fullfile);
5712 local ($found_it, $errfile, $errdir);
5715 foreach $file (@files)
5718 foreach $dir (@require_file_paths)
5722 $fullfile = $relative_dir . "/" . $file;
5723 $errdir = $relative_dir unless $errdir;
5727 $fullfile = $dir . "/" . $file;
5728 $errdir = $dir unless $errdir;
5731 # Use different name for "error filename". Otherwise on
5732 # an error the bad file will be reported as eg
5733 # `../../install-sh' when using the default
5735 $errfile = $errdir . '/' . $file;
5740 # FIXME: Once again, special-case `.'.
5741 &push_dist_common ($file)
5742 if $dir eq $relative_dir || $dir eq '.';
5750 # Prune the path list.
5751 @require_file_paths = $save_dir;
5755 if ($strictness >= $mystrict)
5757 local ($trailer) = '';
5758 local ($suppress) = 0;
5760 # Only install missing files according to our desired
5764 $trailer = "; installing";
5767 # Maybe run libtoolize.
5769 && grep ($_ eq $file, @libtoolize_files)
5770 && system ('libtoolize', '--automake'))
5773 $trailer .= "; cannot run \`libtoolize': $!";
5775 elsif (-f ($am_dir . '/' . $file))
5777 # Install the missing file. Symlink if we
5778 # can, copy if we must. Note: delete the file
5779 # first, in case it is a dangling symlink.
5781 if ($symlink_exists)
5783 if (! symlink ($am_dir . '/' . $file, $errfile))
5786 $trailer .= "; error while making link: $!\n";
5789 elsif (! system ('cp', $am_dir . '/' . $file, $errfile))
5792 $trailer .= "\n error while making link\n";
5797 local ($save) = $exit_status;
5800 # FIXME: allow actual file to be specified.
5802 ('configure.in', $line,
5803 "required file \"$errfile\" not found$trailer");
5809 "required file \"$errfile\" not found$trailer");
5811 $exit_status = $save if $suppress;
5817 # Like require_file_with_line, but error messages refer to
5818 # configure.in, not the current Makefile.am.
5819 sub require_file_with_conf_line
5821 @require_file_paths = '.';
5822 &require_file_internal (1, @_);
5825 sub require_file_with_line
5827 @require_file_paths = '.';
5828 &require_file_internal (0, @_);
5833 @require_file_paths = '.';
5834 &require_file_internal (0, '', @_);
5837 # Require a file that is also required by Autoconf. Looks in
5838 # configuration path, as specified by AC_CONFIG_AUX_DIR.
5839 sub require_config_file
5841 @require_file_paths = @config_aux_path;
5842 &require_file_internal (1, '', @_);
5843 local ($dir) = $require_file_paths[0];
5844 @config_aux_path = @require_file_paths;
5847 $config_aux_dir = '.';
5851 $config_aux_dir = '$(top_srcdir)/' . $dir;
5855 # Assumes that the line number is in Makefile.am.
5856 sub require_conf_file_with_line
5858 @require_file_paths = @config_aux_path;
5859 &require_file_internal (0, @_);
5860 local ($dir) = $require_file_paths[0];
5861 @config_aux_path = @require_file_paths;
5864 $config_aux_dir = '.';
5868 $config_aux_dir = '$(top_srcdir)/' . $dir;
5872 # Assumes that the line number is in Makefile.am.
5873 sub require_conf_file_with_conf_line
5875 @require_file_paths = @config_aux_path;
5876 &require_file_internal (1, @_);
5877 local ($dir) = $require_file_paths[0];
5878 @config_aux_path = @require_file_paths;
5881 $config_aux_dir = '.';
5885 $config_aux_dir = '$(top_srcdir)/' . $dir;
5889 ################################################################
5891 # Push a list of files onto dist_common.
5892 sub push_dist_common
5894 local (@files) = @_;
5897 foreach $file (@files)
5899 $dist_common{$file} = 1;
5903 # Push a list of clean targets onto phony.
5904 sub push_phony_cleaners
5908 foreach $target ('mostly', 'dist', '', 'maintainer-')
5910 push (@phony, $target . 'clean-' . $base);
5917 $strictness_name = $_[0];
5918 if ($strictness_name eq 'gnu')
5922 elsif ($strictness_name eq 'gnits')
5924 $strictness = $GNITS;
5926 elsif ($strictness_name eq 'foreign')
5928 $strictness = $FOREIGN;
5932 die "automake: level \`$strictness_name' not recognized\n";
5937 ################################################################
5939 # Return directory name of file.
5945 ($sub = $file) =~ s,/+[^/]+$,,g;
5946 $sub = '.' if $sub eq $file;
5950 # Return file name of a file.
5956 ($sub = $file) =~s,^.*/+,,g;
5965 open (TOUCH, ">> $file");
5969 # Glob something. Do this to avoid indentation screwups everywhere we
5970 # want to glob. Gross!
5977 ################################################################
5979 # Print an error message and set exit status.
5982 warn "automake: ${am_file}.am: ", join (' ', @_), "\n";
5988 local ($symbol, @args) = @_;
5990 if ($symbol && "$symbol" ne '-1')
5992 # If SYMBOL not already a line number, look it up in Makefile.am.
5993 if ($symbol =~ /^\d+$/)
5997 elsif (defined $content_lines{$symbol})
5999 $symbol = $content_lines{$symbol} . ': ';
6003 # A single space, to provide nice separation.
6006 warn "${am_file}.am:", $symbol, join (' ', @args), "\n";
6015 # Like am_error, but while scanning configure.in.
6018 # FIXME: can run in subdirs.
6019 warn "automake: configure.in: ", join (' ', @_), "\n";
6023 # Error message with line number referring to configure.in.
6024 sub am_conf_line_error
6026 local ($file, $line, @args) = @_;
6030 warn "$file: $line: ", join (' ', @args), "\n";
6035 &am_conf_error (@args);
6039 # Tell user where our aclocal.m4 is, but only once.
6040 sub keyed_aclocal_warning
6043 warn "automake: macro \`$key' can be generated by \`aclocal'\n";
6046 # Print usage information.
6049 print "Usage: automake [OPTION] ... [Makefile]...\n";
6051 print "\nFiles which are automatically distributed, if found:\n";
6052 $~ = "USAGE_FORMAT";
6053 local (@lcomm) = sort ((@common_files, @common_sometimes));
6054 local ($one, $two, $three, $four);
6057 $one = shift @lcomm;
6058 $two = @lcomm ? shift @lcomm : '';
6059 $three = @lcomm ? shift @lcomm : '';
6060 $four = @lcomm ? shift @lcomm : '';
6064 print "\nReport bugs to <automake-bugs\@gnu.ai.mit.edu>\n";
6069 format USAGE_FORMAT =
6070 @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<
6071 $one, $two, $three, $four