5 eval 'exec @PERL@ -S $0 ${1+"$@"}'
8 # automake - create Makefile.in from Makefile.am
9 # Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
11 # This program is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by
13 # the Free Software Foundation; either version 2, or (at your option)
16 # This program is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write to the Free Software
23 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
26 # Originally written by David Mackenzie <djm@gnu.ai.mit.edu>.
27 # Perl reimplementation by Tom Tromey <tromey@cygnus.com>.
30 # Parameters set by configure. Not to be changed. NOTE: assign
31 # VERSION as string so that eg version 0.30 will print correctly.
32 $VERSION = "@VERSION@";
33 $PACKAGE = "@PACKAGE@";
35 $am_dir = "@datadir@/@PACKAGE@";
39 $IGNORE_PATTERN = "^##([^#].*)?\$";
40 $WHITE_PATTERN = "^[ \t]*\$";
41 $COMMENT_PATTERN = "^#";
42 $RULE_PATTERN = "^([\$a-zA-Z_.][-.a-zA-Z0-9_(){}/\$]*) *:([^=].*|)\$";
43 $SUFFIX_RULE_PATTERN = "^\\.([a-zA-Z]+)\\.([a-zA-Z]+)\$";
44 $MACRO_PATTERN = "^([A-Za-z][A-Za-z0-9_]*)[ \t]*:?=[ \t]*(.*)\$";
45 $BOGUS_MACRO_PATTERN = "^([^ \t]*)[ \t]*:?=[ \t]*(.*)\$";
46 $GNITS_VERSION_PATTERN = "[0-9]+\\.[0-9]+([a-z]|\\.[0-9]+)?";
47 $IF_PATTERN = "^if[ \t]+\([A-Za-z][A-Za-z0-9_]*\)[ \t]*\(#.*\)?\$";
48 $ELSE_PATTERN = "^else[ \t]*\(#.*\)?\$";
49 $ENDIF_PATTERN = "^endif[ \t]*\(#.*\)?\$";
51 # Some regular expressions. One reason to put them here is that it
52 # makes indentation work better in Emacs.
53 $AC_CONFIG_AUX_DIR_PATTERN = "AC_CONFIG_AUX_DIR\\(([^)]+)\\)";
54 $AM_INIT_AUTOMAKE_PATTERN = "AM_INIT_AUTOMAKE\\([^,]*,([^,)]+)[,)]";
55 $AM_PACKAGE_VERSION_PATTERN = "^\\s*\\[?([^]\\s]+)\\]?\\s*\$";
56 # Note that there is no AC_PATH_TOOL. But we don't really care.
57 $AC_CHECK_PATTERN = "AC_(CHECK|PATH)_(PROG|PROGS|TOOL)\\(\\[?(\\w+)";
58 $AM_MISSING_PATTERN = "AM_MISSING_PROG\\(\\[?(\\w+)";
59 # Just check for alphanumeric in AC_SUBST. If you do AC_SUBST(5),
61 $AC_SUBST_PATTERN = "AC_SUBST\\(\\[?(\\w+)";
62 $AM_CONDITIONAL_PATTERN = "AM_CONDITIONAL\\((\\w+)";
64 # Constants to define the "strictness" level.
71 # Variables global to entire run.
73 # TRUE if we should always generate Makefile.in.
74 $force_generation = 1;
76 # Strictness level as set on command line.
77 $default_strictness = $GNU;
79 # Name of strictness level, as set on command line.
80 $default_strictness_name = 'gnu';
82 # This is TRUE if GNU make specific automatic dependency generation
83 # code should be included in generated Makefile.in.
84 $cmdline_use_dependencies = 1;
86 # TRUE if in verbose mode.
89 # This holds our (eventual) exit status. We don't actually exit until
90 # we have processed all input files.
93 # From the Perl manual.
94 $symlink_exists = (eval 'symlink ("", "");', $@ eq '');
96 # TRUE if missing standard files should be installed.
99 # Files found by scanning configure.in for LIBOBJS.
102 # True if AM_C_PROTOTYPES appears in configure.in.
103 $am_c_prototypes = 0;
105 # Names used in AC_CONFIG_HEADER call. @config_fullnames holds the
106 # name which appears in AC_CONFIG_HEADER, colon and all.
107 # @config_names holds the file names. @config_headers holds the '.in'
108 # files. Ordinarily these are similar, but they can be different if
109 # the weird "NAME:FILE" syntax is used.
110 @config_fullnames = ();
112 @config_headers = ();
113 # Line number at which AC_CONFIG_HEADER appears in configure.in.
114 $config_header_line = 0;
116 # Directory where output files go. Actually, output files are
117 # relative to this directory.
118 $output_directory = '.';
120 # Relative location of top build directory.
123 # Absolute location of top build directory.
124 $build_directory = '';
126 # Name of srcdir as given in build directory's Makefile. For
130 # List of Makefile.am's to process, and their corresponding outputs.
134 # List of files in AC_OUTPUT without Makefile.am, and their outputs.
135 @other_input_files = ();
136 # Line number at which AC_OUTPUT seen.
139 # List of directories to search for configure-required files. This
140 # can be set by AC_CONFIG_AUX_DIR.
141 @config_aux_path = ('.', '..', '../..');
142 $config_aux_dir = '';
144 # Whether AC_PROG_MAKE_SET has been seen in configure.in.
147 # Whether AM_GNU_GETTEXT has been seen in configure.in.
149 # Line number at which AM_GNU_GETTEXT seen.
150 $ac_gettext_line = 0;
152 # Whether ALL_LINGUAS has been seen.
156 # Line number at which it appears.
157 $all_linguas_line = 0;
159 # 1 if AC_PROG_INSTALL seen, 2 if AM_PROG_INSTALL seen.
160 $seen_prog_install = 0;
162 # 1 if any scripts installed, 0 otherwise.
163 $scripts_installed = 0;
165 # Whether AC_PATH_XTRA has been seen in configure.in.
168 # TRUE if AC_DECL_YYTEXT was seen.
169 $seen_decl_yytext = 0;
171 # TRUE if we've seen AC_CANONICAL_(HOST|SYSTEM). The presence of
172 # AC_CHECK_TOOL also sets this.
175 # TRUE if we've seen AC_ARG_PROGRAM.
178 # TRUE if we've seen AM_PROG_LIBTOOL.
182 # Files installed by libtoolize.
183 @libtoolize_files = ('ltconfig', 'ltmain.sh', 'config.guess', 'config.sub');
185 # TRUE if we've seen AM_MAINTAINER_MODE.
186 $seen_maint_mode = 0;
188 # TRUE if we've seen PACKAGE and VERSION.
192 # Actual version we've seen.
193 $package_version = '';
195 # Line number where we saw version definition.
196 $package_version_line = 0;
198 # TRUE if we've seen AM_PATH_LISPDIR.
201 # TRUE if we've seen AM_EXEEXT.
204 # Hash table of discovered configure substitutions. Keys are names,
205 # values are meaningless.
206 %configure_vars = ();
208 # Charsets used by maintainer and in distribution. MAINT_CHARSET is
209 # handled in a funny way: if seen in the top-level Makefile.am, it is
210 # used for every directory which does not specify a different value.
211 # The rationale here is that some directories (eg gettext) might be
212 # distributions of other packages, and thus require their own charset
213 # info. However, the DIST_CHARSET must be the same for the entire
214 # package; it can only be set at top-level.
215 # FIXME: this yields bugs when rebuilding. What to do? Always
216 # read (and sometimes discard) top-level Makefile.am?
218 $dist_charset = 'utf8'; # recode doesn't support this yet.
220 # Name of input file ("Makefile.in") and output file ("Makefile.am").
221 # These have no directory components.
225 # TRUE if --cygnus seen.
228 # Keys of this hash are names of dependency files to ignore.
229 %omit_dependencies = ();
231 # Hash table of AM_CONDITIONAL variables seen in configure.
232 %configure_cond = ();
234 # Map from obsolete macros to hints for new macros.
235 # FIXME complete the list so that there are no `0' hints.
238 'AC_FEATURE_CTYPE', "use \`AC_HEADER_STDC'",
239 'AC_FEATURE_ERRNO', "add \`strerror' to \`AC_REPLACE_FUNCS(...)'",
240 'AC_FEATURE_EXIT', 0,
241 'AC_SYSTEM_HEADER', 0,
243 # Note that we do not handle this one, because it is still run
244 # from AM_CONFIG_HEADER. So we deal with it specially in
246 # 'AC_CONFIG_HEADER', "use \`AM_CONFIG_HEADER'",
248 'fp_C_PROTOTYPES', "use \`AM_C_PROTOTYPES'",
249 'fp_PROG_CC_STDC', "use \`AM_PROG_CC_STDC'",
250 'fp_PROG_INSTALL', "use \`AM_PROG_INSTALL'",
251 'fp_WITH_DMALLOC', "use \`AM_WITH_DMALLOC'",
252 'fp_WITH_REGEX', "use \`AM_WITH_REGEX'",
253 'gm_PROG_LIBTOOL', "use \`AM_PROG_LIBTOOL'",
254 'jm_MAINTAINER_MODE', "use \`AM_MAINTAINER_MODE'",
255 'md_TYPE_PTRDIFF_T', "use \`AM_TYPE_PTRDIFF_T'",
256 'ud_PATH_LISPDIR', "use \`AM_PATH_LISPDIR'",
258 # Now part of autoconf proper, under a different name.
259 'AM_FUNC_FNMATCH', "use \`AC_FUNC_FNMATCH'",
260 'fp_FUNC_FNMATCH', "use \`AC_FUNC_FNMATCH'",
261 'AM_SANITY_CHECK_CC', "automatically done by \`AC_PROG_CC'",
263 # These aren't quite obsolete.
267 # Regexp to match the above macros.
268 $obsolete_rx = '(' . join ('|', keys %obsolete_macros) . ')';
272 &initialize_global_constants;
274 # Parse command line.
275 &parse_arguments (@ARGV);
277 # Do configure.in scan only once.
280 die "automake: no \`Makefile.am' found or specified\n"
283 # Now do all the work on each file.
284 foreach $am_file (@input_files)
286 if (! -f ($am_file . '.am'))
288 &am_error ("\`" . $am_file . ".am' does not exist");
292 &generate_makefile ($output_files{$am_file}, $am_file);
296 if ($seen_prog_install <= $scripts_installed)
298 &am_conf_error (($scripts_installed ? 'AM_PROG_INSTALL' : 'AC_PROG_INSTALL')
299 . " must be used in configure.in");
300 &keyed_aclocal_warning ('AM_PROG_INSTALL')
301 if $scripts_installed;
307 ################################################################
309 # Parse command line.
312 local (@arglist) = @_;
315 &set_strictness ('gnu');
319 if ($arglist[0] eq "--version")
321 print "automake (GNU $PACKAGE) $VERSION\n\n";
322 print "Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.\n";
323 print "This is free software; see the source for copying conditions. There is NO\n";
324 print "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n";
325 print "Written by Tom Tromey <tromey\@cygnus.com>\n";
329 elsif ($arglist[0] eq "--help")
333 elsif ($arglist[0] =~ /^--amdir=(.+)$/)
337 elsif ($arglist[0] eq '--amdir')
339 &require_argument (@arglist);
341 $am_dir = $arglist[0];
343 elsif ($arglist[0] =~ /^--build-dir=(.+)$/)
346 $build_directory = $1 . '/';
348 elsif ($arglist[0] eq '--build-dir')
350 &require_argument (@arglist);
353 $build_directory = $arglist[0] . '/';
355 elsif ($arglist[0] =~ /^--srcdir-name=(.+)$/)
359 elsif ($arglist[0] eq '--srcdir-name')
361 &require_argument (@arglist);
363 $srcdir_name = $arglist[0];
365 elsif ($arglist[0] eq '--gnu')
367 &set_strictness ('gnu');
369 elsif ($arglist[0] eq '--gnits')
371 &set_strictness ('gnits');
373 elsif ($arglist[0] eq '--cygnus')
377 elsif ($arglist[0] eq '--foreign')
379 &set_strictness ('foreign');
381 elsif ($arglist[0] eq '--include-deps' || $arglist[0] eq '-i')
383 $cmdline_use_dependencies = 0;
385 elsif ($arglist[0] eq '--no-force')
387 $force_generation = 0;
389 elsif ($arglist[0] =~ /^--output-dir=(.*)$/)
391 # Set output directory.
392 $output_directory = $1;
394 elsif ($arglist[0] eq '--output-dir' || $arglist[0] eq '-o')
396 &require_argument (@arglist);
398 $output_directory = $arglist[0];
400 elsif ($arglist[0] eq '--add-missing' || $arglist[0] eq '-a')
404 elsif ($arglist[0] eq '--verbose' || $arglist[0] eq '-v')
408 elsif ($arglist[0] eq '--')
410 # Stop option processing.
412 push (@input_files, @arglist);
415 elsif ($arglist[0] =~ /^-/)
417 die "automake: unrecognized option -- \`$arglist[0]'\nTry \`automake --help' for more information.\n";
421 # Handle $local:$input syntax. Note that we only examine
422 # the first ":" file to see if it is automake input; the
423 # rest are just taken verbatim. We still keep all the
424 # files around for dependency checking, however.
425 local ($local, $input, @rest) = split (/:/, $arglist[0]);
432 # Strip .in; later on .am is tacked on. That is how
433 # the automake input file is found. Maybe not the
434 # best way, but it is easy to explain. FIXME: should
435 # be error if .in is missing.
438 push (@input_files, $input);
439 $output_files{$input} = join (':', ($local, @rest));
445 # Take global strictness from whatever we currently have set.
446 $default_strictness = $strictness;
447 $default_strictness_name = $strictness_name;
450 # Ensure argument exists, or die.
453 local ($arg, @arglist) = @_;
454 die "automake: no argument given for option \`$arg'\n"
458 ################################################################
460 # Generate a Makefile.in given the name of the corresponding Makefile and
461 # the name of the file output by config.status.
462 sub generate_makefile
464 local ($output, $makefile) = @_;
466 ($am_file_name = $makefile) =~ s/^.*\///;
467 $in_file_name = $am_file_name . '.in';
468 $am_file_name .= '.am';
470 # $OUTPUT is encoded. If it contains a ":" then the first element
471 # is the real output file, and all remaining elements are input
472 # files. We don't scan or otherwise deal with these input file,
473 # other than to mark them as dependencies. See scan_configure for
475 local (@secondary_inputs);
476 ($output, @secondary_inputs) = split (/:/, $output);
478 &initialize_per_input;
479 $relative_dir = &dirname ($output);
480 $am_relative_dir = &dirname ($makefile);
482 # At the toplevel directory, we might need config.guess, config.sub
483 # or libtool scripts (ltconfig and ltmain.sh).
484 if ($relative_dir eq '.')
486 # libtool requires some files.
487 &require_conf_file_with_conf_line ($libtool_line, $FOREIGN,
491 # AC_CANONICAL_HOST and AC_CANONICAL_SYSTEM need config.guess and
493 &require_config_file ($FOREIGN, 'config.guess', 'config.sub')
497 # We still need Makefile.in here, because sometimes the `dist'
498 # target doesn't re-run automake.
499 if ($am_relative_dir eq $relative_dir)
501 # Only distribute the files if they are in the same subdir as
502 # the generated makefile.
503 &push_dist_common ($in_file_name, $am_file_name);
505 push (@sources, '$(SOURCES)')
506 if &variable_defined ('SOURCES');
507 push (@objects, '$(OBJECTS)')
508 if &variable_defined ('OBJECTS');
510 # This is always the default target. This gives us freedom to do
511 # things in whatever order is convenient. Note that we set up
512 # $output_header here so that we can insert some text just after
513 # the "default" target, but before any other targets. In
514 # particular we want to support the .SUFFIX hack here; this is
515 # documented elsewhere.
516 $output_header = "default: all\n\n";
517 push (@phony, 'default');
519 &read_am_file ($makefile . '.am');
522 # Fatal error. Just return, so we can continue with next file.
526 # Check first, because we might modify some state.
528 &check_gnu_standards;
529 &check_gnits_standards;
531 &handle_configure ($output, $makefile, @secondary_inputs);
538 &handle_built_sources;
540 # This must be run after all the sources are scanned.
541 &handle_yacc_lex_cxx;
543 # Re-init SOURCES and OBJECTS. FIXME: other code shouldn't depend
544 # on this (but currently does).
545 $contents{'SOURCES'} = join (' ', @sources);
546 $contents{'OBJECTS'} = join (' ', @objects);
555 &handle_minor_options;
556 &handle_dist ($makefile);
557 &handle_dependencies;
560 &handle_merge_targets ($makefile);
567 if (! -d ($output_directory . '/' . $am_relative_dir))
569 mkdir ($output_directory . '/' . $am_relative_dir, 0755);
572 local ($out_file) = $output_directory . '/' . $makefile . ".in";
573 if (! $force_generation && -e $out_file)
575 local ($am_time) = (stat ($makefile . '.am'))[9];
576 local ($in_time) = (stat ($out_file))[9];
577 # FIXME: should cache these times.
578 local ($conf_time) = (stat ('configure.in'))[9];
579 # FIXME: how to do unsigned comparison?
580 if ($am_time < $in_time || $am_time < $conf_time)
587 local ($acl_time) = (stat _)[9];
588 return if ($am_time < $acl_time);
592 if (! open (GM_FILE, "> " . $out_file))
594 warn "automake: ${am_file}.in: cannot write: $!\n";
598 print "automake: creating ", $makefile, ".in\n" if $verbose;
600 print GM_FILE $output_vars;
601 print GM_FILE $output_header;
602 print GM_FILE $output_rules;
603 print GM_FILE $output_trailer;
608 ################################################################
610 # Handle AUTOMAKE_OPTIONS variable. Return 1 on error, 0 otherwise.
613 if (&variable_defined ('AUTOMAKE_OPTIONS'))
615 foreach (&variable_value_as_list ('AUTOMAKE_OPTIONS', ''))
618 if ($_ eq 'gnits' || $_ eq 'gnu' || $_ eq 'foreign')
620 &set_strictness ($_);
622 elsif ($_ eq 'cygnus')
628 # An option like "../lib/ansi2knr" is allowed. With
629 # no path prefix, we assume the required programs are
630 # in this directory. We save the actual option for
632 $options{'ansi2knr'} = $_;
634 elsif ($_ eq 'no-installman' || $_ eq 'no-installinfo'
635 || $_ eq 'dist-shar' || $_ eq 'dist-zip'
636 || $_ eq 'dist-tarZ' || $_ eq 'dejagnu'
637 || $_ eq 'no-texinfo.tex'
638 || $_ eq 'readme-alpha' || $_ eq 'check-news')
640 # Explicitly recognize these.
642 elsif ($_ eq 'no-dependencies')
644 $use_dependencies = 0;
646 elsif (/([0-9]+)\.([0-9]+)/)
648 # Got a version number. Note that alpha releases
649 # count as the next higher release. Note also that we
650 # assume there will be a maximum of 100 minor releases
651 # for any given major release.
653 local ($rmajor, $rminor) = ($1, $2);
654 if ($VERSION !~ /([0-9]+)\.([0-9]+)([a-z])?/)
657 "automake: programming error: version is incorrect\n";
660 local ($tmajor, $tminor) = ($1, $2);
661 # Handle alpha versions.
662 ++$tminor if defined $3;
664 if ($rmajor > $tmajor
665 || ($rmajor == $tmajor && $rminor > $tminor))
667 &am_line_error ('AUTOMAKE_OPTIONS',
668 "require version $_, only have $VERSION");
674 &am_line_error ('AUTOMAKE_OPTIONS',
675 'option ', $_, 'not recognized');
680 if ($strictness == $GNITS)
682 $options{'readme-alpha'} = 1;
683 $options{'check-news'} = 1;
689 # Return object extension. Just once, put some code into the output.
690 # Argument is the name of the output file
691 sub get_object_extension
696 $dir_holds_sources = 1;
698 # Maybe require libtool library object files.
699 local ($extension) = '.o';
700 $extension = '.lo' if ($out =~ /\.la$/);
702 if (! $included_generic_compile)
706 if (&variable_defined ('CONFIG_HEADER'))
709 foreach $one_hdr (split (' ', &variable_value ('CONFIG_HEADER')))
712 ($var = &dirname ($one_hdr)) =~ s/(\W)/\\$1/g;
713 $xform .= ' ' if $xform;
714 $xform .= '-I' . $var;
717 $xform = 's/\@CONFIG_INCLUDE_SPEC\@/' . $xform . '/go;';
718 $output_vars .= &file_contents_with_transform ($xform,
720 $output_rules .= &file_contents ('compile');
721 &push_phony_cleaners ('compile');
723 # If using X, include some extra variable definitions. NOTE
724 # we don't want to force these into CFLAGS or anything,
725 # because not all programs will necessarily use X.
729 foreach $var ('X_CFLAGS', 'X_LIBS', 'X_EXTRA_LIBS', 'X_PRE_LIBS')
731 &define_configure_variable ($var);
735 push (@suffixes, '.c', '.o', '.S', '.s');
736 push (@clean, 'compile');
738 $included_generic_compile = 1;
741 if ($seen_libtool && ! $included_libtool_compile)
743 # Output the libtool compilation rules.
744 $output_rules .= &file_contents ('libtool');
745 &push_phony_cleaners ('libtool');
747 push (@suffixes, '.lo');
748 push (@clean, 'libtool');
750 $included_libtool_compile = 1;
753 # Check for automatic de-ANSI-fication.
754 if (defined $options{'ansi2knr'})
756 $extension = '$U' . $extension;
757 if (! $included_knr_compile)
759 if (! $am_c_prototypes)
761 &am_line_error ('AUTOMAKE_OPTIONS',
762 "option \`ansi2knr' in use but \`AM_C_PROTOTYPES' not in configure.in");
763 &keyed_aclocal_warning ('AM_C_PROTOTYPES');
764 # Only give this error once.
765 $am_c_prototypes = 1;
768 # Only require ansi2knr files if they should appear in
770 if ($options{'ansi2knr'} eq 'ansi2knr')
772 &require_file_with_line ('AUTOMAKE_OPTIONS', $FOREIGN,
773 'ansi2knr.c', 'ansi2knr.1');
774 $output_rules .= &file_contents ('kr-extra');
775 push (@clean, 'krextra');
776 &push_phony_cleaners ('krextra');
779 # Generate rules to build ansi2knr. If it is in some
780 # other directory, then generate dependencies but have the
781 # rule just run elsewhere.
782 $output_rules .= ($options{'ansi2knr'} . ': '
783 . $options{'ansi2knr'} . ".o\n");
784 if ($options{'ansi2knr'} eq 'ansi2knr')
786 $output_rules .= ("\t\$(LINK) ansi2knr.o \$(LIBS)\n"
787 . "ansi2knr.o: \$(CONFIG_HEADER)\n\n");
791 $output_rules .= ("\tcd " . &dirname ($options{'ansi2knr'})
792 . " && \$(MAKE) ansi2knr\n\n");
795 # Make sure ansi2knr can be found: if no path specified,
797 if ($options{'ansi2knr'} eq 'ansi2knr')
799 # Substitution from AM_C_PROTOTYPES. This makes it be
800 # built only when necessary.
801 &define_configure_variable ('ANSI2KNR');
802 # ansi2knr needs to be built before subdirs, so unshift it.
803 unshift (@all, '$(ANSI2KNR)');
807 # Found in another directory.
808 &define_variable ("ANSI2KNR", $options{'ansi2knr'});
811 $output_rules .= &file_contents ('clean-kr');
814 &push_phony_cleaners ('kr');
816 $included_knr_compile = 1;
823 # Handle yacc and lex.
824 sub handle_yacc_lex_cxx
827 # First do yacc and lex.
830 local ($yacc_count) = scalar (keys %yacc_sources);
831 local ($lex_count) = scalar (keys %lex_sources);
835 local (%seen_suffix) = ();
836 foreach (keys %yacc_sources)
839 &output_yacc_build_rule ($1, $yacc_count > 1)
840 if (! defined $seen_suffix{$1});
841 $seen_suffix{$1} = 1;
844 if (! defined $configure_vars{'YACC'})
846 &am_error ("yacc source seen but \`YACC' not defined in \`configure.in'");
848 if (&variable_defined ('YACCFLAGS'))
850 &am_line_error ('YACCFLAGS',
851 "\`YACCFLAGS' obsolete; use \`YFLAGS' instead");
856 local (%seen_suffix) = ();
857 foreach (keys %lex_sources)
860 &output_lex_build_rule ($1, $lex_count > 1)
861 if (! defined $seen_suffix{$1});
862 $seen_suffix{$1} = 1;
865 if (! defined $configure_vars{'LEX'})
867 &am_error ("lex source seen but \`LEX' not defined in \`configure.in'");
869 if (! $seen_decl_yytext)
871 &am_error ("lex source seen but \`AC_DECL_YYTEXT' not in \`configure.in'");
875 if ($yacc_count > 1 || $lex_count > 1)
877 # If there is more than one distinct yacc (resp lex) source
878 # file in a given directory, then the `ylwrap' program is
879 # required to allow parallel builds to work correctly. FIXME:
880 # for now, no line number.
881 &require_config_file ($FOREIGN, 'ylwrap');
882 if ($config_aux_dir ne '.' && $config_aux_dir ne '')
884 &define_variable ('YLWRAP', $config_aux_dir . "/ylwrap");
888 &define_variable ('YLWRAP', '$(srcdir)/ylwrap');
895 local ($ltcompile, $ltlink) = ('', '');
898 &define_configure_variable ("LIBTOOL");
899 $ltcompile = '$(LIBTOOL) --mode=compile ';
900 $ltlink = '$(LIBTOOL) --mode=link ';
906 local (@cxx_list) = keys %cxx_extensions;
907 local ($cxx_count) = scalar @cxx_list;
910 push (@suffixes, @cxx_list);
912 &define_configure_variable ("CXXFLAGS");
913 &define_variable ('CXXCOMPILE', '$(CXX) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CXXFLAGS)');
914 &define_variable ('LTCXXCOMPILE',
915 $ltcompile . '$(CXX) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CXXFLAGS)')
918 &define_variable ('CXXLINK', $ltlink . '$(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@');
921 foreach $ext (@cxx_list)
923 $output_rules .= ("$ext.o:\n"
924 . "\t\$(CXXCOMPILE) -c \$<\n");
925 $output_rules .= ("$ext.lo:\n"
926 . "\t\$(LTCXXCOMPILE) -c \$<\n")
930 if (! defined $configure_vars{'CXX'})
932 &am_error ("C++ source seen but \`CXX' not defined in \`configure.in'");
937 # Handle some ansi2knr cleanup.
939 if (defined $options{'ansi2knr'} && keys %de_ansi_files)
941 # Make all _.c files depend on their corresponding .c files.
942 local ($base, @objects);
943 foreach $base (sort (keys %de_ansi_files))
945 # Each _.c file must depend on ansi2knr; otherwise it
946 # might be used in a parallel build before it is built.
947 # We need to support files in the srcdir and in the build
948 # dir (because these files might be auto-generated. But
949 # we can't use $< -- some makes only define $< during a
951 $output_rules .= ($base . "_.c: $base.c \$(ANSI2KNR)\n\t"
953 . '`if test -f $(srcdir)/' . $base . '.c'
954 . '; then echo $(srcdir)/' . $base . '.c'
955 . '; else echo ' . $base . '.c; fi` '
957 push (@objects, $base . '_.o');
958 push (@objects, $base . '_.lo') if $seen_libtool;
961 # Make all _.o (and _.lo) files depend on ansi2knr.
962 # Use a sneaky little hack to make it print nicely.
963 &pretty_print_rule ('', '', @objects, ':', '$(ANSI2KNR)');
967 # Last, handle some C cleanup.
969 if ($seen_any_source)
971 &define_configure_variable ('CFLAGS');
972 &define_variable ('COMPILE',
973 '$(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)');
974 &define_variable ('LTCOMPILE',
976 '$(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)')
978 &define_variable ('LINK', $ltlink . '$(CC) $(CFLAGS) $(LDFLAGS) -o $@');
981 if ($seen_c_source && ! defined $configure_vars{'CC'})
983 &am_line_error ($seen_c_source,
984 "C source seen but \`CC' not defined in \`configure.in'");
989 # Output a rule to build from a YACC source. The output from YACC is
990 # compiled with C or C++, depending on the extension of the YACC file.
991 sub output_yacc_build_rule
993 local ($yacc_suffix, $use_ylwrap, $c_suffix) = @_;
995 local ($c_suffix, $suffix);
996 ($c_suffix = $yacc_suffix) =~ tr/y/c/;
997 push (@suffixes, $yacc_suffix, $c_suffix, '.h');
999 # Generate rule for c/c++ and header file. Probably should only
1000 # do header if `yacc -d' is run. But how can we determine that?
1001 foreach $suffix ($c_suffix, '.h')
1003 $output_rules .= "$yacc_suffix$suffix:\n\t";
1007 $output_rules .= ('$(SHELL) $(YLWRAP)'
1008 . ' "$(YACC)" $< y.tab.c $*' . $c_suffix
1009 . ' y.tab.h $*.h -- $(YFLAGS)');
1013 $output_rules .= ('$(YACC) $(YFLAGS) $< && mv y.tab.c $*'
1015 . "\tif test -f y.tab.h; then \\\n"
1016 . "\tif cmp -s y.tab.h \$*.h; then rm -f y.tab.h; else mv y.tab.h \$*.h; fi; \\\n"
1019 $output_rules .= "\n";
1023 sub output_lex_build_rule
1025 local ($lex_suffix, $use_ylwrap) = @_;
1028 ($c_suffix = $lex_suffix) =~ tr/l/c/;
1029 push (@suffixes, $lex_suffix);
1030 &define_configure_variable ('LEX_OUTPUT_ROOT');
1031 &define_configure_variable ('LEXLIB');
1032 $output_rules .= "$lex_suffix$c_suffix:\n\t";
1036 # Is the $@ correct here? If so, why not use it in the ylwrap
1037 # build rule for yacc above?
1038 $output_rules .= '$(SHELL) $(YLWRAP)'
1039 . ' "$(LEX)" $< $(LEX_OUTPUT_ROOT).c $@ -- $(LFLAGS)';
1043 $output_rules .= '$(LEX) $(LFLAGS) $< && mv $(LEX_OUTPUT_ROOT).c $@';
1045 $output_rules .= "\n";
1049 # Check to make sure a source defined in LIBOBJS is not explicitly
1050 # mentioned. This is a separate function (as opposed to being inlined
1051 # in handle_source_transform) because it isn't always appropriate to
1053 sub check_libobjs_sources
1055 local ($one_file, $unxformed) = @_;
1057 local ($prefix, $file, @files);
1058 foreach $prefix ('', 'EXTRA_')
1060 if (&variable_defined ($prefix . $one_file . '_SOURCES'))
1062 @files = &variable_value_as_list (($prefix
1063 . $one_file . '_SOURCES'),
1066 elsif ($prefix eq '')
1068 @files = ($unxformed . '.c');
1075 foreach $file (@files)
1077 if (defined $libsources{$file})
1079 &am_line_error ($prefix . $one_file . '_SOURCES',
1080 "automatically discovered file \`$file' should not be explicitly mentioned");
1086 # Does much of the actual work for handle_source_transform.
1088 # list of source files to transform
1090 # first element is name of linker to use (empty string for default linker)
1091 # remaining elements are names of `.o's
1092 sub handle_single_transform_list
1094 local (@files) = @_;
1095 local ($linker) = '';
1096 local (@result) = ();
1097 local ($nonansi_obj) = $obj;
1098 $nonansi_obj =~ s/_//g;
1101 # Turn sources into objects.
1104 # Skip header files, including C++-ish ones. The list
1105 # of C++ header extensions comes from Emacs 19.32
1112 # Skip things that look like configure substitutions.
1115 # Include appropriate file for lex or yacc source in
1116 # distribution. If the extension is the regular '.y' or
1117 # '.l', we assume C compilation, and the generated file
1118 # has exension .c. Otherwise, we compile with C++, and
1119 # make the following association: (yy -> cc, y++ -> c++,
1120 # yxx -> cxx), similarly for .ll, etc.
1121 if (/^(.*)\.(y|yy|y\+\+|yxx)$/)
1126 &push_dist_common ("$1.$ext");
1127 $yacc_sources{$_} = 1;
1129 elsif (/^(.*)\.(l|ll|l\+\+|lxx)$/)
1134 &push_dist_common ("$1.$ext");
1135 $lex_sources{$_} = 1;
1138 # Strip any directory prefix.
1139 $_ = &basename ($_);
1141 local ($is_cxx) = 0;
1142 # Transform source files into .o files. List of C++
1143 # extensions comes from Emacs 19.34 etags.
1144 if (s/\.(c\+\+|cc|cpp|cxx|C)$/$nonansi_obj/)
1146 $cxx_extensions{'.' . $1} = 1;
1147 $linker = 'CXXLINK';
1150 elsif (s/\.(yy|y\+\+|yxx|ll|l\+\+|lxx)$/$nonansi_obj/)
1152 # Compiling lex or yacc with C++
1155 $cxx_extensions{".$ext"} = 1;
1156 $linker = 'CXXLINK';
1158 elsif (s/\.([Ff]|f90|for)$/$nonansi_obj/)
1160 # FORTRAN support. FIXME: not finished.
1162 elsif (s/\.[sS]$/$nonansi_obj/)
1164 # .s is assembly. Just rewrite it. FIXME: not finished.
1166 elsif (defined ($options{'ansi2knr'}) && s/_\.[cly]$/_.c/)
1168 # FIXME include line number in error.
1169 &am_error ("C source file \`$_' would be deleted by ansi2knr rules");
1171 elsif (s/\.[cly]$//)
1173 # .c is C. .l is lex. .y is yacc.
1175 # Note: first we rewrite (eg) foo.c to foo and push
1176 # the file onto the list of deansified files. Then we add
1177 # $obj, which can either be `_.o', or simply `.o' if
1178 # deansification is not required.
1179 $de_ansi_files{$_} = 1;
1183 elsif (/\.$source_suffix_pattern$/)
1185 # We just rewrite it. Maybe we should do more.
1186 s//.$suffix_rules{$1}/;
1190 # No error message here. Used to have one, but it was
1195 $seen_any_source = 1 unless $is_cxx;
1198 # Transform .o or $o file into .P file (for automatic
1201 $dep_files{'.deps/' . $_} = 1;
1205 return ($linker, @result);
1208 # Handle SOURCE->OBJECT transform for one program or library.
1210 # canonical (transformed) name of object to build
1211 # actual name of object to build
1212 # object extension (ie either `.o' or `$o'.
1213 # Return result is name of linker variable that must be used.
1214 # Empty return means just use `LINK'.
1215 sub handle_source_transform
1217 # one_file is canonical name. unxformed is given name. obj is
1219 local ($one_file, $unxformed, $obj) = @_;
1220 local ($objpat) = $obj;
1221 $objpat =~ s/(\W)/\\$1/g;
1222 # Handle explicit `.o' as well as whatever we're passed.
1223 $objpat = '(' . $objpat . "|\\.o)";
1225 local ($linker) = '';
1227 if (&variable_defined ($one_file . "_OBJECTS"))
1229 &am_line_error ($one_file . '_OBJECTS',
1230 $one_file . '_OBJECTS', 'should not be defined');
1231 # No point in continuing.
1235 local (@files, @result, $prefix, $temp);
1236 foreach $prefix ('', 'EXTRA_')
1239 local ($var) = $prefix . $one_file . "_SOURCES";
1240 if (&variable_defined ($var))
1242 push (@sources, '$(' . $prefix . $one_file . "_SOURCES)");
1243 push (@objects, '$(' . $prefix . $one_file . "_OBJECTS)")
1244 unless $prefix eq 'EXTRA_';
1245 local (@conds) = &variable_conditions ($var);
1248 @files = &variable_value_as_list ($var, '');
1252 local ($cond, $cond_var_name);
1254 local (@namelist) = ();
1255 foreach $cond (@conds)
1257 @files = &variable_value_as_list ($var, $cond);
1258 ($temp, @result) = &handle_single_transform_list (@files);
1259 $linker = $temp if $linker eq '';
1261 # We have to have a new name for each such
1262 # variable. Then we define the _OBJECTS variable
1263 # as the union of all such variables. Hopefully
1264 # this is the Right Thing.
1265 $cond_var_name = 'cond' . $count . $one_file . '_OBJECTS';
1266 &define_pretty_variable ($cond_var_name, $cond, @result)
1267 unless $prefix eq 'EXTRA_';
1268 push (@namelist, '$(' . $cond_var_name . ')');
1272 &define_pretty_variable ($one_file . '_OBJECTS', '',
1278 elsif ($prefix eq '')
1280 &define_variable ($one_file . "_SOURCES", $unxformed . ".c");
1281 push (@sources, $unxformed . '.c');
1282 push (@objects, $unxformed . $obj);
1283 push (@files, $unxformed . '.c');
1286 ($temp, @result) = &handle_single_transform_list (@files);
1287 $linker = $temp if $linker eq '';
1288 &define_pretty_variable ($one_file . "_OBJECTS", '', @result)
1289 unless $prefix eq 'EXTRA_';
1295 # Handle the BUILT_SOURCES variable.
1296 sub handle_built_sources
1298 return unless &variable_defined ('BUILT_SOURCES');
1300 local (@sources) = &variable_value_as_list ('BUILT_SOURCES', 'all');
1302 foreach $s (@sources)
1306 # FIXME: is this really the right thing to do?
1307 &am_line_error ('BUILT_SOURCES',
1308 "\`BUILT_SOURCES' should not contain a configure substitution");
1313 # We don't care about the return value of this function. We just
1314 # want to make sure to update %dep_files with the contents of
1316 &handle_single_transform_list (@sources);
1319 # Special-case @ALLOCA@ and @LIBOBJS@ in _LDADD or _LIBADD variables.
1320 # Also, generate _DEPENDENCIES variable if appropriate.
1322 # transformed name of object being built, or empty string if no object
1323 # name of _LDADD/_LIBADD-type variable to examine
1324 # boolean (lex_seen) which is true if a lex source file was seen in this
1325 # object. valid only for LDADDs, not LIBADDs.
1326 # Returns 1 if LIBOBJS seen, 0 otherwise.
1327 sub handle_lib_objects
1329 local ($xname, $var, $lex_seen) = @_;
1332 die "automake: programming error 1 in handle_lib_objects\n"
1333 if ! &variable_defined ($var);
1335 die "automake: programming error 2 in handle_lib_objects\n"
1336 if $lex_seen && $var =~ /LIBADD/;
1338 local (@conds) = &variable_conditions ($var);
1341 $ret = &handle_lib_objects_cond ($xname, $var, $lex_seen, '');
1347 foreach $cond (@conds)
1349 if (&handle_lib_objects_cond ($xname, $var, $lex_seen, $cond))
1359 # Subroutine of handle_lib_objects: handle a particular condition.
1360 sub handle_lib_objects_cond
1362 local ($xname, $var, $lex_seen, $cond) = @_;
1364 # We recognize certain things that are commonly put in LIBADD or
1367 local (@dep_list) = ();
1369 local ($seen_libobjs) = 0;
1370 local ($flagvar) = 0;
1372 foreach $lsearch (&variable_value_as_list ($var, $cond))
1374 # Skip -lfoo and -Ldir; these are explicitly allowed.
1375 next if $lsearch =~ /^-[lL]/;
1376 if (! $flagvar && $lsearch =~ /^-/)
1378 if ($var =~ /^(.*)LDADD$/)
1380 &am_line_error ($var, "linker flags such as \`$lsearch' belong in \`${1}LDFLAGS");
1384 # Only get this error once.
1386 &am_line_error ($var, "you cannot use linker flags such as \`$lsearch' in \`$var'");
1390 # Assume we have a file of some sort, and push it onto the
1391 # dependency list. Autoconf substitutions are not pushed;
1392 # rarely is a new dependency substituted into (eg) foo_LDADD
1393 # -- but "bad things (eg -lX11) are routinely substituted.
1394 # Note that LIBOBJS and ALLOCA are exceptions to this rule,
1395 # and handled specially below.
1396 push (@dep_list, $lsearch)
1397 unless $lsearch =~ /^\@.*\@$/;
1399 # Automatically handle @LIBOBJS@ and @ALLOCA@. Basically this
1400 # means adding entries to dep_files.
1401 if ($lsearch =~ /^\@(LT)?LIBOBJS\@$/)
1403 push (@dep_list, $lsearch);
1405 if (! keys %libsources)
1407 &am_line_error ($var, "\@$1" . "LIBOBJS\@ seen but never set in \`configure.in'");
1410 local ($iter, $rewrite);
1411 foreach $iter (keys %libsources)
1413 if ($iter =~ /\.[cly]$/)
1415 $seen_c_source = $var;
1416 $seen_any_source = 1;
1419 if ($iter =~ /\.h$/)
1421 &require_file_with_line ($var, $FOREIGN, $iter);
1423 elsif ($iter ne 'alloca.c')
1425 ($rewrite = $iter) =~ s/\.c$/.P/;
1426 $dep_files{'.deps/' . $rewrite} = 1;
1427 &require_file_with_line ($var, $FOREIGN, $iter);
1431 elsif ($lsearch =~ /^\@(LT)?ALLOCA\@$/)
1433 push (@dep_list, $lsearch);
1434 &am_line_error ($var,
1435 "\@$1" . "ALLOCA\@ seen but \`AC_FUNC_ALLOCA' not in \`configure.in'")
1436 if ! defined $libsources{'alloca.c'};
1437 $dep_files{'.deps/alloca.P'} = 1;
1438 &require_file_with_line ($var, $FOREIGN, 'alloca.c');
1439 $seen_c_source = $var;
1440 $seen_any_source = 1;
1444 if ($xname ne '' && ! &variable_defined ($xname . '_DEPENDENCIES', $cond))
1446 &define_pretty_variable ($xname . '_DEPENDENCIES', $cond, @dep_list);
1449 return $seen_libobjs;
1452 # Canonicalize a name, and check to make sure the non-canonical name
1453 # is never used. Returns canonical name. Arguments are name and a
1454 # list of suffixes to check for.
1455 sub check_canonical_spelling
1457 local ($name, @suffixes) = @_;
1458 local ($xname, $xt);
1460 ($xname = $name) =~ tr/A-Za-z0-9_/_/c;
1461 if ($xname ne $name)
1464 foreach $xt (@suffixes)
1466 &am_line_error ($name . $xt,
1467 "invalid variable \`" . $name . $xt
1468 . "'; should be \`" . $xname . $xt . "'")
1469 if &variable_defined ($name . $xt);
1476 # Handle C programs.
1479 local (@proglist) = &am_install_var ('-clean',
1480 'progs', 'PROGRAMS',
1481 'bin', 'sbin', 'libexec', 'pkglib',
1483 return if ! @proglist;
1485 # If a program is installed, this is required. We only want this
1486 # error to appear once.
1487 &am_conf_error ("AC_ARG_PROGRAM must be used in configure.in")
1488 unless $seen_arg_prog;
1491 local ($one_file, $xname, $munge);
1493 local ($seen_libobjs) = 0;
1494 foreach $one_file (@proglist)
1496 local ($obj) = &get_object_extension ($one_file);
1498 # Canonicalize names and check for misspellings.
1499 $xname = &check_canonical_spelling ($one_file, '_LDADD', '_LDFLAGS',
1500 '_SOURCES', '_OBJECTS',
1503 # FIXME: Using a trick to figure out if any lex sources appear
1504 # in our program; should use some cleaner method.
1505 local ($lex_num) = scalar (keys %lex_sources);
1506 local ($linker) = &handle_source_transform ($xname, $one_file, $obj);
1507 local ($lex_file_seen) = (scalar (keys %lex_sources) > $lex_num);
1510 if (&variable_defined ($xname . "_LDADD"))
1512 if (&handle_lib_objects ($xname, $xname . '_LDADD',
1522 # User didn't define prog_LDADD override. So do it.
1523 &define_variable ($xname . '_LDADD', '$(LDADD)');
1525 # This does a bit too much work. But we need it to
1526 # generate _DEPENDENCIES when appropriate.
1527 if (&variable_defined ('LDADD'))
1529 if (&handle_lib_objects ($xname, 'LDADD', $lex_file_seen))
1535 elsif (! &variable_defined ($xname . '_DEPENDENCIES'))
1537 &define_variable ($xname . '_DEPENDENCIES', '');
1542 if (&variable_defined ($xname . '_LIBADD'))
1544 &am_line_error ($xname . '_LIBADD',
1545 "use \`" . $xname . "_LDADD', not \`"
1546 . $xname . "_LIBADD'");
1549 if (! &variable_defined ($xname . '_LDFLAGS'))
1551 # Define the prog_LDFLAGS variable.
1552 &define_variable ($xname . '_LDFLAGS', '');
1555 # Determine program to use for link.
1557 if (&variable_defined ($xname . '_LINK'))
1559 $xlink = $xname . '_LINK';
1563 $xlink = $linker ? $linker : 'LINK';
1567 if ($seen_exeext && $one_file !~ /\./)
1569 $xexe = 's/\@EXEEXT\@/\$(EXEEXT)/g;';
1573 $xexe = 's/\@EXEEXT\@//g;';
1577 &file_contents_with_transform
1578 ('s/\@PROGRAM\@/' . $one_file . '/go;'
1579 . 's/\@XPROGRAM\@/' . $xname . '/go;'
1580 . 's/\@XLINK\@/' . $xlink . '/go;'
1585 if (&variable_defined ('LDADD') && &handle_lib_objects ('', 'LDADD', 0))
1592 foreach $one_file (@proglist)
1594 # Canonicalize names.
1595 ($xname = $one_file) =~ tr/A-Za-z0-9_/_/c;
1597 if (&variable_defined ($xname . '_LDADD'))
1599 &check_libobjs_sources ($xname, $xname . '_LDADD');
1601 elsif (&variable_defined ('LDADD'))
1603 &check_libobjs_sources ($xname, 'LDADD');
1611 sub handle_libraries
1613 local (@liblist) = &am_install_var ('-clean',
1614 'libs', 'LIBRARIES',
1615 'lib', 'pkglib', 'noinst', 'check');
1616 return if ! @liblist;
1618 local (%valid) = &am_primary_prefixes ('LIBRARIES', 'lib', 'pkglib',
1620 if (! defined $configure_vars{'RANLIB'})
1623 foreach $key (keys %valid)
1625 if (&variable_defined ($key . '_LIBRARIES'))
1627 &am_line_error ($key . '_LIBRARIES', "library used but \`RANLIB' not defined in \`configure.in'");
1628 # Only get this error once.
1629 $configure_vars{'RANLIB'} = 1;
1638 local ($seen_libobjs) = 0;
1639 foreach $onelib (@liblist)
1641 # Check that the library fits the standard naming convention.
1642 if ($onelib !~ /^lib.*\.a$/)
1644 # FIXME should put line number here. That means mapping
1645 # from library name back to variable name.
1646 &am_error ("\`$onelib' is not a standard library name");
1649 local ($obj) = &get_object_extension ($onelib);
1651 # Canonicalize names and check for misspellings.
1652 $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_SOURCES',
1653 '_OBJECTS', '_DEPENDENCIES');
1655 if (&variable_defined ($xlib . '_LIBADD'))
1657 if (&handle_lib_objects ($xlib, $xlib . '_LIBADD', 0))
1664 # Generate support for conditional object inclusion in
1666 &define_variable ($xlib . "_LIBADD", '');
1669 if (&variable_defined ($xlib . '_LDADD'))
1671 &am_line_error ($xlib . '_LDADD',
1672 "use \`" . $xlib . "_LIBADD', not \`"
1673 . $xlib . "_LDADD'");
1676 &handle_source_transform ($xlib, $onelib, $obj);
1679 &file_contents_with_transform ('s/\@LIBRARY\@/' . $onelib . '/go;'
1687 foreach $onelib (@liblist)
1689 # Canonicalize names.
1690 ($xlib = $onelib) =~ tr/A-Za-z0-9_/_/c;
1691 if (&variable_defined ($xlib . '_LIBADD'))
1693 &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
1698 &define_variable ('AR', 'ar');
1699 &define_configure_variable ('RANLIB');
1702 # Handle shared libraries.
1703 sub handle_ltlibraries
1705 local (@liblist) = &am_install_var ('-clean',
1706 'ltlib', 'LTLIBRARIES',
1708 return if ! @liblist;
1711 local (%valid) = &am_primary_prefixes ('LTLIBRARIES', 'lib', 'pkglib');
1714 foreach $key (keys %valid)
1716 if (&variable_defined ($key . '_LTLIBRARIES'))
1720 &am_line_error ($key . '_LTLIBRARIES', "library used but \`LIBTOOL' not defined in \`configure.in'");
1721 # Only get this error once.
1722 $configure_vars{'LIBTOOL'} = 1;
1726 # Get the installation directory of each library.
1727 for (&variable_value_as_list ($key . '_LTLIBRARIES', 'all'))
1731 &am_error ("\`$_' is already going to be installed in \`$instdirs{$_}'");
1735 $instdirs{$_} = $key;
1744 local ($seen_libobjs) = 0;
1745 foreach $onelib (@liblist)
1747 # Check that the library fits the standard naming convention.
1748 if ($onelib !~ /^lib.*\.la$/)
1750 # FIXME this should only be a warning for foreign packages
1751 # FIXME should put line number here. That means mapping
1752 # from library name back to variable name.
1753 &am_error ("\`$onelib' is not a standard libtool library name");
1756 local ($obj) = &get_object_extension ($onelib);
1758 # Canonicalize names and check for misspellings.
1759 $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_LDFLAGS',
1760 '_SOURCES', '_OBJECTS',
1763 if (! &variable_defined ($xlib . '_LDFLAGS'))
1765 # Define the lib_LDFLAGS variable.
1766 &define_variable ($xlib . '_LDFLAGS', '');
1769 if (&variable_defined ($xlib . '_LIBADD'))
1771 if (&handle_lib_objects ($xlib, $xlib . '_LIBADD', 0))
1778 # Generate support for conditional object inclusion in
1780 &define_variable ($xlib . "_LIBADD", '');
1783 if (&variable_defined ($xlib . '_LDADD'))
1785 &am_line_error ($xlib . '_LDADD',
1786 "use \`" . $xlib . "_LIBADD', not \`"
1787 . $xlib . "_LDADD'");
1790 local ($linker) = &handle_source_transform ($xlib, $onelib, $obj);
1792 # Determine program to use for link.
1794 if (&variable_defined ($xlib . '_LINK'))
1796 $xlink = $xlib . '_LINK';
1800 $xlink = $linker ? $linker : 'LINK';
1804 if ($instdirs{$onelib} eq 'EXTRA')
1806 # It's an EXTRA_ library, so we can't specify -rpath.
1808 $rpath = 's/\@RPATH\@//go;';
1812 $rpath = ('s/\@RPATH\@/-rpath \$(' . $instdirs{$onelib}
1817 &file_contents_with_transform ('s/\@LTLIBRARY\@/'
1819 . 's/\@XLTLIBRARY\@/'
1822 . 's/\@XLINK\@/' . $xlink . '/go;',
1828 foreach $onelib (@liblist)
1830 # Canonicalize names.
1831 ($xlib = $onelib) =~ tr/A-Za-z0-9_/_/c;
1832 if (&variable_defined ($xlib . '_LIBADD'))
1834 &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
1840 # See if any _SOURCES variable were misspelled. Also, make sure that
1841 # EXTRA_ variables don't contain configure substitutions.
1844 local ($varname, $primary);
1845 foreach $varname (keys %contents)
1847 foreach $primary ('_SOURCES', '_LIBADD', '_LDADD', '_LDFLAGS',
1850 if ($varname =~ /$primary$/ && ! $content_seen{$varname})
1852 &am_line_error ($varname,
1853 "invalid unused variable name: \`$varname'");
1862 # NOTE we no longer automatically clean SCRIPTS, because it is
1863 # useful to sometimes distribute scripts verbatim. This happens
1864 # eg in Automake itself.
1865 &am_install_var ('scripts', 'SCRIPTS',
1866 'bin', 'sbin', 'libexec', 'pkgdata',
1869 # Set $scripts_installed if appropriate. Make sure we only find
1870 # scripts which are actually installed -- this is why we can't
1871 # simply use the return value of am_install_var.
1872 local (%valid) = &am_primary_prefixes ('SCRIPTS', 'bin', 'sbin',
1873 'libexec', 'pkgdata',
1876 foreach $key (keys %valid)
1878 if ($key ne 'noinst'
1880 && &variable_defined ($key . '_SCRIPTS'))
1882 $scripts_installed = 1;
1883 # push (@check_tests, 'check-' . $key . 'SCRIPTS');
1887 if ($scripts_installed)
1889 # If a program is installed, this is required. We only want this
1890 # error to appear once.
1891 &am_conf_error ("AC_ARG_PROGRAM must be used in configure.in")
1892 unless $seen_arg_prog;
1897 # Search a file for a "version.texi" Texinfo include. Return the name
1898 # of the include file if found, or the empty string if not. A
1899 # "version.texi" file is actually any file whose name matches
1901 sub scan_texinfo_file
1903 local ($filename) = @_;
1905 if (! open (TEXI, $filename))
1907 &am_error ("couldn't open \`$filename': $!");
1910 print "automake: reading $filename\n" if $verbose;
1912 local ($vfile, $outfile);
1915 if (/^\@setfilename +(\S+)/)
1921 if (/^\@include\s+(vers[^.]*\.texi)\s*$/)
1923 # Found version.texi include.
1930 return ($outfile, $vfile);
1933 # Handle all Texinfo source.
1936 &am_line_error ('TEXINFOS',
1937 "\`TEXINFOS' is an anachronism; use \`info_TEXINFOS'")
1938 if &variable_defined ('TEXINFOS');
1939 return if (! &variable_defined ('info_TEXINFOS')
1940 && ! &variable_defined ('html_TEXINFOS'));
1942 local (@texis) = &variable_value_as_list ('info_TEXINFOS', 'all');
1944 local (@info_deps_list, @dvis_list, @texi_deps);
1945 local ($infobase, $info_cursor);
1949 local ($tc_cursor, @texi_cleans);
1952 foreach $info_cursor (@texis)
1954 ($infobase = $info_cursor) =~ s/\.texi(nfo)?$//;
1956 # If 'version.texi' is referenced by input file, then include
1957 # automatic versioning capability.
1958 local ($out_file, $vtexi) = &scan_texinfo_file ($relative_dir
1959 . "/" . $info_cursor);
1961 if ($out_file eq '')
1963 &am_error ("\`$info_cursor' missing \@setfilename");
1967 if ($out_file =~ /\.(.+)$/ && $1 ne 'info')
1969 # FIXME should report line number in input file.
1970 &am_error ("output of \`$info_cursor', \`$out_file', has unrecognized extension");
1976 &am_error ("\`$vtexi', included in \`$info_cursor', also included in \`$versions{$vtexi}'")
1977 if (defined $versions{$vtexi});
1978 $versions{$vtexi} = $info_cursor;
1980 # We number the stamp-vti files. This is doable since the
1981 # actual names don't matter much. We only number starting
1982 # with the second one, so that the common case looks nice.
1983 $vti = 'vti' . ($done ? $done : '');
1984 &push_dist_common ($vtexi, 'stamp-' . $vti);
1985 push (@clean, $vti);
1987 # Only require once.
1988 &require_conf_file_with_line ('info_TEXINFOS', $FOREIGN,
1994 ($conf_pat = $config_aux_dir) =~ s/(\W)/\\$1/g;
1996 &file_contents_with_transform
1997 ('s/\@TEXI\@/' . $info_cursor . '/g; '
1998 . 's/\@VTI\@/' . $vti . '/g; '
1999 . 's/\@VTEXI\@/' . $vtexi . '/g;'
2000 . 's,\@MDDIR\@,' . $conf_pat . ',g;',
2003 &push_phony_cleaners ($vti);
2006 # If user specified file_TEXINFOS, then use that as explicit
2009 push (@texi_deps, $info_cursor);
2010 push (@texi_deps, $vtexi) if $vtexi;
2012 # Canonicalize name first.
2013 ($canonical = $infobase) =~ tr/A-Za-z0-9_/_/c;
2014 if (&variable_defined ($canonical . "_TEXINFOS"))
2016 push (@texi_deps, '$(' . $canonical . '_TEXINFOS)');
2017 &push_dist_common ('$(' . $canonical . '_TEXINFOS)');
2020 $output_rules .= ("\n" . $out_file . ": "
2021 . join (' ', @texi_deps)
2022 . "\n" . $infobase . ".dvi: "
2023 . join (' ', @texi_deps)
2026 push (@info_deps_list, $out_file);
2027 push (@dvis_list, $infobase . '.dvi');
2029 # Generate list of things to clean for this target. We do
2030 # this explicitly because otherwise too many things could be
2031 # removed. In particular the ".log" extension might
2032 # reasonably be used in other contexts by the user.
2033 foreach $tc_cursor ('aux', 'cp', 'cps', 'dvi', 'fn', 'fns',
2034 'ky', 'kys', 'ps', 'log', 'pg', 'toc', 'tp', 'tps',
2035 'vr', 'vrs', 'op', 'tr', 'cv', 'cn')
2037 push (@texi_cleans, $infobase . '.' . $tc_cursor);
2041 # Find these programs wherever they may lie. Yes, this has
2042 # intimate knowledge of the structure of the texinfo distribution.
2043 &define_program_variable ('MAKEINFO', 'build', 'texinfo/makeinfo',
2045 # Circumlocution to avoid accidental
2046 # configure substitution.
2048 &define_program_variable ('TEXI2DVI', 'src', 'texinfo/util',
2051 # Set transform for including texinfos.am. First, handle --cygnus
2056 $xform = 's/^NOTCYGNUS.*$//; s/^CYGNUS//;';
2060 $xform = 's/^CYGNUS.*$//; s/^NOTCYGNUS//;';
2063 # Handle location of texinfo.tex.
2064 local ($need_texi_file) = 0;
2067 &define_variable ('TEXINFO_TEX',
2068 '$(top_srcdir)/../texinfo/texinfo.tex');
2070 elsif ($config_aux_dir ne '.' && $config_aux_dir ne '')
2072 &define_variable ('TEXINFO_TEX', $config_aux_dir . '/texinfo.tex');
2074 elsif (! &variable_defined ('TEXINFO_TEX'))
2076 &define_variable ('TEXINFO_TEX', '$(srcdir)/texinfo.tex');
2080 $need_texi_file = 1;
2082 local ($xxform) = &dirname (&variable_value ('TEXINFO_TEX'));
2083 $xxform =~ s/(\W)/\\$1/g;
2084 $xform .= ' s/\@TEXINFODIR\@/' . $xxform . '/g;';
2086 $output_rules .= &file_contents_with_transform ($xform, 'texinfos');
2087 push (@phony, 'install-info-am', 'uninstall-info');
2088 push (@dist_targets, 'dist-info');
2090 # How to clean. The funny name is due to --cygnus influence; in
2091 # Cygnus mode, `clean-info' is a target that users can use.
2092 $output_rules .= "\nmostlyclean-aminfo:\n";
2093 &pretty_print_rule ("\t-rm -f", "\t ", @texi_cleans);
2094 $output_rules .= ("\nclean-aminfo:\n\ndistclean-aminfo:\n\n"
2095 . "maintainer-clean-aminfo:\n\t"
2096 # Eww. But how else can we find all the output
2097 # files from makeinfo?
2098 . 'for i in $(INFO_DEPS); do' . " \\\n"
2099 . "\t" . ' rm -f $$i;' . " \\\n"
2100 . "\t" . ' if test "`echo $$i-[0-9]*`" != "$$i-[0-9]*"; then' . " \\\n"
2101 . "\t" . ' rm -f $$i-[0-9]*;' . " \\\n"
2102 . "\t" . ' fi;' . " \\\n"
2104 &push_phony_cleaners ('aminfo');
2107 $output_rules .= "clean-info: mostlyclean-aminfo\n";
2110 push (@suffixes, '.texi', '.texinfo', '.info', '.dvi', '.ps');
2112 if (! defined $options{'no-installinfo'})
2114 push (@uninstall, 'uninstall-info');
2115 push (@installdirs, '$(infodir)');
2116 unshift (@install_data, 'install-info-am');
2118 # Make sure documentation is made and installed first. Use
2119 # $(INFO_DEPS), not 'info', because otherwise recursive makes
2120 # get run twice during "make all".
2121 unshift (@all, '$(INFO_DEPS)');
2123 push (@clean, 'aminfo');
2124 push (@info, '$(INFO_DEPS)');
2125 push (@dvi, '$(DVIS)');
2127 &define_variable ("INFO_DEPS", join (' ', @info_deps_list));
2128 &define_variable ("DVIS", join (' ', @dvis_list));
2129 # This next isn't strictly needed now -- the places that look here
2130 # could easily be changed to look in info_TEXINFOS. But this is
2131 # probably better, in case noinst_TEXINFOS is ever supported.
2132 &define_variable ("TEXINFOS", &variable_value ('info_TEXINFOS'));
2134 # Do some error checking. Note that this file is not required
2135 # when in Cygnus mode; instead we defined TEXINFO_TEX explicitly
2137 &require_file_with_line ('info_TEXINFOS', $FOREIGN, 'texinfo.tex')
2138 if $need_texi_file || ! defined $options{'no-texinfo.tex'};
2141 # Handle any man pages.
2142 sub handle_man_pages
2144 &am_line_error ('MANS', "\`MANS' is an anachronism; use \`man_MANS'")
2145 if &variable_defined ('MANS');
2146 return if ! &variable_defined ('man_MANS');
2148 # We generate the manpage install code by hand to avoid the use of
2149 # basename in the generated Makefile.
2150 local (@mans) = &variable_value_as_list ('man_MANS', 'all');
2151 local (%sections, %inames, %mbases, %secmap, %fullsecmap);
2155 # FIXME: statement without effect:
2156 /^(.*)\.([0-9])([a-z]*)$/;
2161 $fullsecmap{$i} = $2 . $3;
2165 # We don't really need this, but we use it in case we ever want to
2166 # support noinst_MANS.
2167 &define_variable ("MANS", &variable_value ('man_MANS'));
2169 # Generate list of install dirs.
2170 $output_rules .= "install-man: \$(MANS)\n";
2171 $output_rules .= "\t\$(NORMAL_INSTALL)\n";
2172 # Sort keys so that output is deterministic.
2173 foreach (sort keys %sections)
2175 push (@installdirs, '$(mandir)/man' . $_)
2176 unless defined $options{'no-installman'};
2177 $output_rules .= ("\t" . '$(mkinstalldirs) $(mandir)/man'
2180 push (@phony, 'install-man');
2182 # Generate install target.
2184 foreach $key (sort keys %inames)
2186 $_ = $install_man_format;
2187 s/\@SECTION\@/$secmap{$key}/g;
2188 s/\@MAN\@/$inames{$key}/g;
2189 s/\@FULLSECT\@/$fullsecmap{$key}/g;
2190 s/\@MANBASE\@/$mbases{$key}/g;
2191 $output_rules .= $_;
2193 $output_rules .= "\n";
2195 $output_rules .= "uninstall-man:\n\t\$(NORMAL_UNINSTALL)\n";
2196 foreach $key (sort keys %inames)
2198 $_ = $uninstall_man_format;
2199 s/\@SECTION\@/$secmap{$key}/g;
2200 s/\@MAN\@/$inames{$key}/g;
2201 s/\@FULLSECT\@/$fullsecmap{$key}/g;
2202 s/\@MANBASE\@/$mbases{$key}/g;
2203 $output_rules .= $_;
2205 $output_rules .= "\n";
2206 push (@phony, 'uninstall-man');
2208 $output_vars .= &file_contents ('mans-vars');
2210 if (! defined $options{'no-installman'})
2212 push (@install_data, 'install-man');
2213 push (@uninstall, 'uninstall-man');
2214 push (@all, '$(MANS)');
2218 # Handle DATA variables.
2221 &am_install_var ('data', 'DATA', 'data', 'sysconf',
2222 'sharedstate', 'localstate', 'pkgdata',
2229 push (@phony, 'tags');
2230 local (@tag_deps) = ();
2231 if (&variable_defined ('SUBDIRS'))
2233 $output_rules .= ("tags-recursive:\n"
2234 . "\tlist=\'\$(SUBDIRS)\'; for subdir in \$\$list; do \\\n"
2235 # Never fail here if a subdir fails; it
2237 . "\t (cd \$\$subdir && \$(MAKE) tags); \\\n"
2239 push (@tag_deps, 'tags-recursive');
2240 push (@phony, 'tags-recursive');
2243 if ($dir_holds_sources
2244 || $dir_holds_headers
2245 || &variable_defined ('ETAGS_ARGS')
2248 local ($xform) = '';
2250 foreach $one_hdr (@config_headers)
2252 if ($relative_dir eq &dirname ($one_hdr))
2254 # The config header is in this directory. So require it.
2256 ($var = &basename ($one_hdr)) =~ s/(\W)/\\$1/g;
2257 $xform .= ' ' if $xform;
2261 $xform = ('s/\@CONFIG\@/' . $xform . '/;'
2262 . 's/\@DIRS\@/' . join (' ', @tag_deps) . '/;');
2264 if (&variable_defined ('SUBDIRS'))
2266 $xform .= 's/^SUBDIRS//;';
2270 $xform .= 's/^SUBDIRS.*$//;';
2273 $output_rules .= &file_contents_with_transform ($xform, 'tags');
2274 $output_rules .= &file_contents ('tags-clean');
2275 push (@clean, 'tags');
2276 &push_phony_cleaners ('tags');
2277 &examine_variable ('TAGS_DEPENDENCIES');
2279 elsif (&variable_defined ('TAGS_DEPENDENCIES'))
2281 &am_line_error ('TAGS_DEPENDENCIES',
2282 "doesn't make sense to define \`TAGS_DEPENDENCIES' without sources or \`ETAGS_ARGS'");
2286 # Every Makefile must define some sort of TAGS rule.
2287 # Otherwise, it would be possible for a top-level "make TAGS"
2288 # to fail because some subdirectory failed.
2289 $output_rules .= "tags: TAGS\nTAGS:\n\n";
2293 # Worker for handle_dist.
2294 sub handle_dist_worker
2296 local ($makefile) = @_;
2298 $output_rules .= 'distdir: $(DISTFILES)' . "\n";
2300 # Initialization; only at top level.
2301 if ($relative_dir eq '.')
2303 if (defined $options{'check-news'})
2305 # For Gnits users, this is pretty handy. Look at 15 lines
2306 # in case some explanatory text is desirable.
2307 $output_rules .= ' @if sed 15q $(srcdir)/NEWS | fgrep -e "$(VERSION)" > /dev/null; then :; else \\
2308 echo "NEWS not updated; not releasing" 1>&2; \\
2315 # Create dist directory.
2316 $output_rules .= ("\t-rm -rf \$(distdir)\n"
2317 . "\tmkdir \$(distdir)\n"
2318 . "\t-chmod 777 \$(distdir)\n");
2321 # Only run automake in `dist' target if --include-deps and
2322 # `no-dependencies' not specified. That way the recipient of a
2323 # distribution can run "make dist" and not need Automake. You
2324 # might be wondering why we run automake once for each directory
2325 # we distribute, instead of running it once at the top level. The
2326 # answer is that we want to run automake after the dependencies
2327 # have been generated. This occurs when "make" is run in the
2328 # subdir. So automake must be run after make has updated the
2329 # Makefile, which means that it must run once per directory.
2330 if ($use_dependencies)
2334 # There are several directories we need to know about
2335 # when rebuilding the Makefile.ins. They are:
2336 # here - The absolute path to our topmost build directory.
2337 # top_distdir - The absolute path to the top of our dist
2339 # distdir - The path to our sub-part of the dist hierarchy.
2340 # If this directory is the topmost directory, we set
2341 # top_distdir from distdir; that lets us pass in distdir
2342 # from an enclosing package.
2343 "\t" . 'here=`cd $(top_builddir) && pwd`; ' . "\\\n"
2344 . "\t" . 'top_distdir=`cd $('
2345 . (($relative_dir eq '.') ? 'distdir' : 'top_distdir')
2346 . ') && pwd`; ' . "\\\n"
2347 . "\t" . 'distdir=`cd $(distdir) && pwd`; ' . "\\\n"
2348 . "\tcd \$(top_srcdir) \\\n"
2349 . "\t && \$(AUTOMAKE) --include-deps --build-dir=\$\$here --srcdir-name=\$(top_srcdir) --output-dir=\$\$top_distdir "
2350 # Set strictness of output.
2351 . ($cygnus_mode ? '--cygnus' : ('--' . $strictness_name))
2352 . ($cmdline_use_dependencies ? '' : ' --include-deps')
2353 . " " . $makefile . "\n"
2357 # Scan EXTRA_DIST to see if we need to distribute anything from a
2358 # subdir. If so, add it to the list. I didn't want to do this
2359 # originally, but there were so many requests that I finally
2362 if (&variable_defined ('EXTRA_DIST'))
2364 # FIXME: This should be fixed to work with conditionals. That
2365 # will require only making the entries in @dist_dirs under the
2366 # appropriate condition. This is meaningful if the nature of
2367 # the distribution should depend upon the configure options
2369 foreach (&variable_value_as_list ('EXTRA_DIST', ''))
2372 next unless s,/+[^/]+$,,;
2373 push (@dist_dirs, $_)
2379 # Prepend $(distdir) to each directory given. Doing it via a
2380 # hash lets us ensure that each directory is used only once.
2382 grep ($dhash{'$(distdir)/' . $_} = 1, @dist_dirs);
2383 $output_rules .= "\t";
2384 &pretty_print_rule ('$(mkinstalldirs)', "\t ", sort keys %dhash);
2387 # In loop, test for file existence because sometimes a file gets
2388 # included in DISTFILES twice. For example this happens when a
2389 # single source file is used in building more than one program.
2390 # Also, there are situations in which "ln" can fail. For instance
2391 # a file to distribute could actually be a cross-filesystem
2392 # symlink -- this can easily happen if "gettextize" was run on the
2394 $output_rules .= "\t\@for file in \$(DISTFILES); do \\\n";
2397 $output_rules .= "\t if test -f \$\$file; then d=.; else d=\$(srcdir); fi; \\\n";
2401 $output_rules .= "\t d=\$(srcdir); \\\n";
2403 $output_rules .= ' test -f $(distdir)/$$file \\
2404 || ln $$d/$$file $(distdir)/$$file 2> /dev/null \\
2405 || cp -p $$d/$$file $(distdir)/$$file; \\
2409 # If we have SUBDIRS, create all dist subdirectories and do
2411 if (&variable_defined ('SUBDIRS'))
2413 # If SUBDIRS is conditionally defined, then set DIST_SUBDIRS
2414 # to all possible directories, and use it.
2415 if (! &variable_conditions ('SUBDIRS'))
2417 $dist_subdir_name = 'SUBDIRS';
2421 $dist_subdir_name = 'DIST_SUBDIRS';
2422 if (! &variable_defined ('DIST_SUBDIRS'))
2424 &define_pretty_variable ('DIST_SUBDIRS', '',
2425 &variable_value_as_list ('SUBDIRS',
2430 # Test for directory existence here because previous automake
2431 # invocation might have created some directories. Note that
2432 # we explicitly set distdir for the subdir make; that lets us
2433 # mix-n-match many automake-using packages into one large
2434 # package, and have "dist" at the top level do the right
2435 # thing. If we're in the topmost directory, then we use
2436 # `distdir' instead of `top_distdir'; this lets us work
2437 # correctly with an enclosing package.
2439 ("\t" . 'for subdir in $(' . $dist_subdir_name . '); do ' . "\\\n"
2440 . "\t" . ' test -d $(distdir)/$$subdir ' . "\\\n"
2441 . "\t" . ' || mkdir $(distdir)/$$subdir ' . "\\\n"
2442 . "\t" . ' || exit 1; ' . "\\\n"
2443 . "\t" . ' chmod 777 $(distdir)/$$subdir; ' . "\\\n"
2444 . "\t" . ' (cd $$subdir && $(MAKE) top_distdir=../$('
2445 . (($relative_dir eq '.') ? 'distdir' : 'top_distdir')
2446 . ') distdir=../$(distdir)/$$subdir distdir) ' . "\\\n"
2447 . "\t" . ' || exit 1; ' . "\\\n"
2451 # If the target `dist-hook' exists, make sure it is run. This
2452 # allows users to do random weird things to the distribution
2453 # before it is packaged up.
2454 push (@dist_targets, 'dist-hook') if defined $contents{'dist-hook'};
2457 foreach $targ (@dist_targets)
2459 # We must explicitly set distdir and top_distdir for these
2461 $output_rules .= "\t\$(MAKE) top_distdir=\"\$(top_distdir)\" distdir=\"\$(distdir)\" $targ\n";
2464 push (@phony, 'distdir');
2467 # Handle 'dist' target.
2470 local ($makefile) = @_;
2472 # Set up maint_charset.
2473 $local_maint_charset = &variable_value ('MAINT_CHARSET')
2474 if &variable_defined ('MAINT_CHARSET');
2475 $maint_charset = $local_maint_charset
2476 if $relative_dir eq '.';
2478 if (&variable_defined ('DIST_CHARSET'))
2480 &am_line_error ('DIST_CHARSET',
2481 "DIST_CHARSET defined but no MAINT_CHARSET defined")
2482 if ! $local_maint_charset;
2483 if ($relative_dir eq '.')
2485 $dist_charset = &variable_value ('DIST_CHARSET')
2489 &am_line_error ('DIST_CHARSET',
2490 "DIST_CHARSET can only be defined at top level");
2494 # Look for common files that should be included in distribution.
2496 foreach $cfile (@common_files)
2498 if (-f ($relative_dir . "/" . $cfile))
2500 &push_dist_common ($cfile);
2504 # Keys of %dist_common are names of files to distributed. We put
2505 # README first because it then becomes easier to make a
2506 # Usenet-compliant shar file (in these, README must be first).
2507 # FIXME: do more ordering of files here.
2509 if (defined $dist_common{'README'})
2511 push (@coms, 'README');
2512 delete $dist_common{'README'};
2514 push (@coms, sort keys %dist_common);
2516 &define_pretty_variable ("DIST_COMMON", '', @coms);
2517 $output_vars .= "\n";
2520 $output_vars .= &file_contents ('dist-vars') . "\n";
2521 &define_variable ('TAR', $TAR);
2522 &define_variable ('GZIP', '--best');
2524 # Put these things in rules section so it is easier for whoever
2525 # reads Makefile.in.
2526 if (! &variable_defined ('distdir'))
2528 if ($relative_dir eq '.')
2530 $output_rules .= "\n" . 'distdir = $(PACKAGE)-$(VERSION)' . "\n";
2534 $output_rules .= ("\n"
2535 . 'distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)'
2539 if ($relative_dir eq '.')
2541 $output_rules .= "top_distdir = \$(distdir)\n\n";
2545 $output_rules .= "\nsubdir = " . $relative_dir . "\n\n";
2548 # Generate 'dist' target, and maybe dist-shar / dist-zip / dist-tarZ.
2549 if ($relative_dir eq '.')
2551 # Rule to check whether a distribution is viable.
2552 $output_rules .= ('# This target untars the dist file and tries a VPATH configuration. Then
2553 # it guarantees that the distribution is self-contained by making another
2557 GZIP=$(GZIP) $(TAR) zxf $(distdir).tar.gz
2558 mkdir $(distdir)/=build
2559 mkdir $(distdir)/=inst
2560 dc_install_base=`cd $(distdir)/=inst && pwd`; \\'
2561 . (defined $contents{'distcheck-hook'}
2562 ? "\t\$(MAKE) distcheck-hook"
2565 cd $(distdir)/=build \\
2568 . ($seen_gettext ? '--with-included-gettext ' : '')
2569 . '--srcdir=.. --prefix=$$dc_install_base \\
2573 && $(MAKE) install \\
2574 && $(MAKE) installcheck \\
2577 @echo "========================"; \\
2578 echo "$(distdir).tar.gz is ready for distribution"; \\
2579 echo "========================"
2582 local ($dist_all) = ('dist-all: distdir' . "\n"
2585 foreach $curs ('dist', 'dist-shar', 'dist-zip', 'dist-tarZ')
2587 if (defined $options{$curs} || $curs eq 'dist')
2589 $output_rules .= ($curs . ': distdir' . "\n"
2593 $dist_all .= $dist{$curs};
2596 $output_rules .= $dist_all . $dist_trailer;
2599 # Generate distdir target.
2600 &handle_dist_worker ($makefile);
2603 # Scan a single dependency file and rewrite the dependencies as
2604 # appropriate. Essentially this means:
2605 # * Clean out absolute dependencies which are not desirable.
2606 # * Rewrite other dependencies to be relative to $(top_srcdir).
2607 sub scan_dependency_file
2609 local ($depfile) = @_;
2611 if (! open (DEP_FILE, $depfile))
2613 &am_error ("couldn't open \`$depfile': $!");
2616 print "automake: reading $depfile\n" if $verbose;
2618 # Sometimes it is necessary to omit some dependencies.
2619 local (%omit) = %omit_dependencies;
2620 if (&variable_defined ('OMIT_DEPENDENCIES'))
2622 # FIXME: Doesn't work with conditionals. I'm not sure if this
2624 grep ($omit{$_} = 1,
2625 &variable_value_as_list ('OMIT_DEPENDENCIES', ''));
2628 local ($first_line) = 1;
2629 local ($last_line) = 0;
2630 local ($target, @dependencies);
2631 local ($one_dep, $xform);
2634 local ($srcdir_rx, $fixup_rx);
2635 ($fixup_rx = $srcdir_name . '/' . $relative_dir . '/')
2637 ($srcdir_rx = $srcdir_name . '/') =~ s/(\W)/\\$1/g;
2639 local ($rewrite_builddir) = (($top_builddir eq '.')
2641 : $top_builddir . '/');
2647 # If LAST_LINE set then we've already seen what we thought
2648 # was the last line.
2651 next if (/$WHITE_PATTERN/o);
2655 # No trailing "\" means this should be the last line.
2661 if (! /^([^:]+:)(.+)$/)
2664 &am_error ("\`$depfile' has incorrect format");
2670 # Make sure to strip the .P file from the target.
2671 ($target = $1) =~ s, *\.deps/[^.]+\.P,,;
2676 foreach $one_dep (split (' ', $_))
2678 ($just_file = $one_dep) =~ s,^.*/,,;
2679 next if defined $omit{$just_file};
2681 if ($one_dep =~ /^$fixup_rx/)
2683 # The dependency points to the current directory in
2685 ($xform = $one_dep) =~ s/^$fixup_rx//;
2686 push (@dependencies, $xform);
2688 elsif ($one_dep =~ /^$srcdir_rx/)
2690 # The dependency is in some other directory in the package.
2691 ($xform = $one_dep) =~ s/^$srcdir_rx/$rewrite_builddir/;
2692 push (@dependencies, $xform);
2694 elsif ($one_dep =~ /^\//)
2696 # Absolute path; ignore.
2700 # Anything else is assumed to be correct.
2701 push (@dependencies, $one_dep);
2706 &pretty_print_rule ($target, "\t", @dependencies);
2711 # Handle auto-dependency code.
2712 sub handle_dependencies
2714 # Make sure this variable is always marked as used.
2715 &examine_variable ('OMIT_DEPENDENCIES');
2717 if ($use_dependencies)
2719 # Include GNU-make-specific auto-dep code. Don't include it
2720 # if DEP_FILES would be empty.
2721 if ($dir_holds_sources && keys %dep_files)
2723 &define_pretty_variable ('DEP_FILES', '', sort keys %dep_files);
2724 $output_rules .= &file_contents ('depend');
2725 push (@clean, 'depend');
2726 &push_phony_cleaners ('depend');
2728 &file_contents_with_transform ('s/\@EXT\@/.c/g;'
2729 . 's/\@MKDEP\@/MKDEP/g;'
2733 local ($need_cxx) = 0;
2734 foreach $ext (sort keys %cxx_extensions)
2737 &file_contents_with_transform ('s/\@EXT\@/' . $ext .'/g;'
2738 . 's/\@MKDEP\@/CXXMKDEP/g;'
2745 &define_variable ('CXXMKDEP', '$(CXX) -M $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CXXFLAGS)');
2749 elsif ($build_directory ne '')
2751 # Include any auto-generated deps that are present. Note that
2752 # $build_directory ends in a "/".
2753 if (-d ($build_directory . $relative_dir . "/.deps")
2754 && -f ($build_directory . $relative_dir . "/.deps/.P"))
2758 foreach $depfile (&my_glob ($build_directory
2759 . $relative_dir . "/.deps/*.P"))
2761 &scan_dependency_file ($depfile);
2764 $output_rules .= "\n";
2769 # Handle subdirectories.
2772 return if ! &variable_defined ('SUBDIRS');
2774 # Make sure each directory mentioned in SUBDIRS actually exists.
2776 foreach $dir (&variable_value_as_list ('SUBDIRS', 'all'))
2778 # Skip directories substituted by configure.
2779 next if $dir =~ /^\@.*\@$/;
2781 if (! -d $am_relative_dir . '/' . $dir)
2783 &am_line_error ('SUBDIRS',
2784 "required directory $am_relative_dir/$dir does not exist");
2788 &am_line_error ('SUBDIRS', "directory should not contain \`/'")
2792 local ($xform) = ('s/\@INSTALLINFO\@/' .
2793 (defined $options{'no-installinfo'}
2794 ? 'install-info-recursive'
2797 $output_rules .= &file_contents_with_transform ($xform, 'subdirs');
2799 # Push a bunch of phony targets.
2801 foreach $phonies ('-data', '-exec', 'dirs')
2803 push (@phony, 'install' . $phonies . '-recursive');
2804 push (@phony, 'uninstall' . $phonies . '-recursive');
2806 foreach $phonies ('all', 'check', 'installcheck', 'info', 'dvi')
2808 push (@phony, $phonies . '-recursive');
2810 &push_phony_cleaners ('recursive');
2812 push (@check_tests, "check-recursive");
2813 push (@installcheck, "installcheck-recursive");
2814 push (@info, "info-recursive");
2815 push (@dvi, "dvi-recursive");
2817 $recursive_install = 1;
2820 # Handle aclocal.m4.
2821 sub handle_aclocal_m4
2823 local ($regen_aclocal) = 0;
2824 if (-f 'aclocal.m4')
2826 &define_variable ("ACLOCAL_M4", '$(top_srcdir)/aclocal.m4');
2827 &push_dist_common ('aclocal.m4');
2829 if (open (ACLOCAL, '< aclocal.m4'))
2835 if ($line =~ 'generated automatically by aclocal')
2842 local ($acinclude) = 0;
2843 if (-f 'acinclude.m4')
2849 # Note that it might be possible that aclocal.m4 doesn't exist but
2850 # should be auto-generated. This case probably isn't very
2854 local (@ac_deps) = (
2855 ($seen_maint_mode ? "\@MAINT\@" : "") ,
2857 ($acinclude ? ' acinclude.m4' : '')
2860 # Scan all -I directories for m4 files. These are our
2862 if (&variable_defined ('ACLOCAL_AMFLAGS'))
2865 foreach $amdir (&variable_value_as_list ('ACLOCAL_AMFLAGS', ''))
2867 if ($amdir =~ s/^-I//
2871 push (@ac_deps, &my_glob ($am_dir . '/*.m4'));
2876 &pretty_print_rule ("\$(ACLOCAL_M4):", "\t\t", @ac_deps);
2878 $output_rules .= ("\t"
2879 . 'cd $(srcdir) && $(ACLOCAL)'
2880 . (&variable_defined ('ACLOCAL_AMFLAGS')
2881 ? ' $(ACLOCAL_AMFLAGS)' : '')
2886 # Rewrite a list of input files into a form suitable to put on a
2887 # dependency list. The idea is that if an input file has a directory
2888 # part the same as the current directory, then the directory part is
2889 # simply removed. But if the directory part is different, then
2890 # $(top_srcdir) is prepended. Among other things, this is used to
2891 # generate the dependency list for the output files generated by
2892 # AC_OUTPUT. Consider what the dependencies should look like in this
2894 # AC_OUTPUT(src/out:src/in1:lib/in2)
2895 sub rewrite_inputs_into_dependencies
2897 local (@inputs) = @_;
2898 local ($single, @newinputs);
2900 foreach $single (@inputs)
2902 if (&dirname ($single) eq $relative_dir)
2904 push (@newinputs, &basename ($single));
2908 push (@newinputs, '$(top_srcdir)/' . $single);
2915 # Handle remaking and configure stuff.
2916 # We need the name of the input file, to do proper remaking rules.
2917 sub handle_configure
2919 local ($local, $input, @secondary_inputs) = @_;
2921 # If SUBDIRS defined, require AC_PROG_MAKE_SET.
2922 &am_line_error ('SUBDIRS', "AC_PROG_MAKE_SET must be used in configure.in")
2923 if &variable_defined ('SUBDIRS') && ! $seen_make_set;
2925 local ($top_reldir);
2927 local ($input_base) = &basename ($input);
2928 local ($local_base) = &basename ($local);
2930 local ($amfile) = $input_base . '.am';
2931 # We know we can always add '.in' because it really should be an
2932 # error if the .in was missing originally.
2933 local ($infile) = '$(srcdir)/' . $input_base . '.in';
2934 local ($colon_infile);
2935 if ($local ne $input)
2937 $colon_infile = ':' . $input . '.in';
2939 $colon_infile .= ':' . join (':', @secondary_inputs)
2940 if @secondary_inputs;
2942 local (@rewritten) = &rewrite_inputs_into_dependencies (@secondary_inputs);
2943 # This rule remakes the Makefile.in. Note use of @MAINT@ forces
2944 # us to abandon pretty-printing. Sigh.
2945 $output_rules .= ($infile
2946 # NOTE perl 5.003 (with -w) gives a
2947 # uninitialized value error on the next line.
2950 . ($seen_maint_mode ? '@MAINT@ ' : '')
2952 . '$(top_srcdir)/configure.in $(ACLOCAL_M4) '
2953 . join (' ', @rewritten) . "\n"
2954 . "\tcd \$(top_srcdir) && \$(AUTOMAKE) "
2955 . ($cygnus_mode ? '--cygnus' : ('--' . $strictness_name))
2956 . ($cmdline_use_dependencies ? '' : ' --include-deps')
2957 . ' ' . $input . $colon_infile . "\n\n");
2959 # This rule remakes the Makefile.
2960 $output_rules .= ($local_base
2961 # NOTE: bogus uninit value error on next line;
2962 # see comment above.
2965 . '$(top_builddir)/config.status'
2966 # NOTE: Makefile only depends on BUILT_SOURCES
2967 # when dependencies are being computed. This is
2968 # a workaround for an obscure bug with
2969 # AC_LINK_FILES. Anyway, when dependencies are
2970 # turned off, this shouldn't matter.
2971 . ($use_dependencies ? ' $(BUILT_SOURCES)' : '')
2973 . "\tcd \$(top_builddir) \\\n"
2974 . "\t && CONFIG_FILES="
2975 . (($relative_dir eq '.') ? '$@' : '$(subdir)/$@')
2977 . ' CONFIG_HEADERS= $(SHELL) ./config.status'
2980 if ($relative_dir ne '.')
2983 $top_reldir = '../';
2988 $output_rules .= &file_contents ('remake');
2989 &examine_variable ('CONFIGURE_DEPENDENCIES');
2993 # If we have a configure header, require it.
2995 local (@local_fullnames) = @config_fullnames;
2996 local (@local_names) = @config_names;
2997 local ($hdr_index) = 0;
2998 local ($distclean_config) = '';
2999 foreach $one_hdr (@config_headers)
3001 local ($one_fullname) = shift (@local_fullnames);
3002 local ($one_name) = shift (@local_names);
3004 if ($relative_dir eq &dirname ($one_hdr))
3006 local ($ch_sans_dir) = &basename ($one_hdr);
3007 local ($cn_sans_dir) = &basename ($one_name);
3009 &require_file_with_conf_line ($config_header_line,
3010 $FOREIGN, $ch_sans_dir);
3012 # Header defined and in this directory.
3014 if (-f $relative_dir . '/acconfig.h')
3016 push (@files, 'acconfig.h');
3018 if (-f $one_name . '.top')
3020 push (@files, "${cn_sans_dir}.top");
3022 if (-f $one_name . '.bot')
3024 push (@files, "${cn_sans_dir}.bot");
3027 &push_dist_common (@files);
3029 local ($stamp_name) = 'stamp-h';
3030 $stamp_name .= "${hdr_index}" if scalar (@config_headers) > 1;
3032 local ($xform) = '';
3034 $xform = 's,\@FILES\@,' . join (' ', @files) . ',;';
3035 $xform .= 's,\@CONFIG_HEADER\@,' . "${cn_sans_dir}" . ',;';
3036 $xform .= 's,\@CONFIG_HEADER_IN\@,' . "${ch_sans_dir}" . ',;';
3037 $xform .= 's,\@CONFIG_HEADER_FULL\@,' . "${one_fullname}" . ',;';
3038 $xform .= 's,\@STAMP\@,' . "${stamp_name}" . ',;';
3040 $output_rules .= &file_contents_with_transform ($xform,
3043 &touch ($relative_dir . "/${stamp_name}.in");
3044 &require_file_with_conf_line ($config_header_line, $FOREIGN,
3045 "${stamp_name}.in");
3047 $distclean_config .= ' ' if $distclean_config;
3048 $distclean_config .= $cn_sans_dir;
3052 if ($distclean_config)
3054 $output_rules .= &file_contents_with_transform ('s,\@FILES\@,'
3058 push (@clean, 'hdr');
3059 &push_phony_cleaners ('hdr');
3062 # Set location of mkinstalldirs.
3063 if ($config_aux_dir ne '.' && $config_aux_dir ne '')
3065 &define_variable ('mkinstalldirs', ('$(SHELL) ' . $config_aux_dir
3066 . '/mkinstalldirs'));
3070 &define_variable ('mkinstalldirs',
3071 '$(SHELL) $(top_srcdir)/mkinstalldirs');
3074 &am_line_error ('CONFIG_HEADER',
3075 "\`CONFIG_HEADER' is an anachronism; now determined from \`configure.in'")
3076 if &variable_defined ('CONFIG_HEADER');
3079 local ($config_header) = '';
3080 foreach $one_name (@config_names)
3082 # Generate CONFIG_HEADER define.
3084 if ($relative_dir eq &dirname ($one_name))
3086 $one_hdr = &basename ($one_name);
3090 $one_hdr = "${top_builddir}/${one_name}";
3093 $config_header .= ' ' if $config_header;
3094 $config_header .= $one_hdr;
3098 &define_variable ("CONFIG_HEADER", $config_header);
3101 # Now look for other files in this directory which must be remade
3102 # by config.status, and generate rules for them.
3103 local (@actual_other_files) = ();
3104 local ($file, $local);
3105 local (@inputs, @rewritten_inputs, $single);
3106 local ($need_rewritten);
3107 foreach $file (@other_input_files)
3109 if ($file =~ /^(.*):(.*)$/)
3111 # This is the ":" syntax of AC_OUTPUT.
3113 $local = &basename ($file);
3114 @inputs = split (':', $2);
3115 @rewritten_inputs = &rewrite_inputs_into_dependencies (@inputs);
3116 $need_rewritten = 1;
3121 $local = &basename ($file);
3122 @inputs = ($local . '.in');
3124 &rewrite_inputs_into_dependencies ($file . '.in');
3125 $need_rewritten = 0;
3128 # Skip files not in this directory.
3129 next unless &dirname ($file) eq $relative_dir;
3131 # Skip any file that is an automake input.
3132 next if -f $file . '.am';
3134 # Some users have been tempted to put `stamp-h' in the
3135 # AC_OUTPUT line. This won't do the right thing, so we
3136 # explicitly fail here.
3137 if ($local eq 'stamp-h')
3139 # FIXME: allow real filename.
3140 &am_conf_error ('configure.in', $ac_output_line,
3141 'stamp-h should not appear in AC_OUTPUT');
3145 $output_rules .= ($local . ': '
3146 . '$(top_builddir)/config.status '
3147 . join (' ', @rewritten_inputs) . "\n"
3149 . 'cd $(top_builddir) && CONFIG_FILES='
3150 . ($relative_dir eq '.' ? '' : '$(subdir)/')
3151 . '$@' . ($need_rewritten
3152 ? (':' . join (':', @rewritten_inputs))
3154 . ' CONFIG_HEADERS= ./config.status'
3156 push (@actual_other_files, $local);
3158 # Require all input files.
3159 &require_file_with_conf_line ($ac_output_line, $FOREIGN,
3163 # These files get removed by "make clean".
3164 &define_pretty_variable ('CONFIG_CLEAN_FILES', '', @actual_other_files);
3170 $dir_holds_headers = &am_install_var ('header', 'HEADERS', 'include',
3171 'oldinclude', 'pkginclude',
3177 return if ! $seen_gettext || $relative_dir ne '.';
3179 if (! &variable_defined ('SUBDIRS'))
3182 ("AM_GNU_GETTEXT in configure.in but SUBDIRS not defined");
3186 &require_file_with_conf_line ($ac_gettext_line, $FOREIGN, 'ABOUT-NLS')
3189 if (&variable_defined ('SUBDIRS'))
3193 "AM_GNU_GETTEXT in configure.in but \`po' not in SUBDIRS")
3194 if $contents{'SUBDIRS'} !~ /\bpo\b/;
3197 "AM_GNU_GETTEXT in configure.in but \`intl' not in SUBDIRS")
3198 if $contents{'SUBDIRS'} !~ /\bintl\b/;
3201 # Ensure that each language in ALL_LINGUAS has a .po file, and
3202 # each po file is mentioned in ALL_LINGUAS.
3205 local (%linguas) = ();
3206 grep ($linguas{$_} = 1, split (' ', $all_linguas));
3213 &am_line_error ($all_linguas_line,
3214 ("po/$_.po exists but \`$_' not in \`ALL_LINGUAS'"))
3218 foreach (keys %linguas)
3220 &am_line_error ($all_linguas_line,
3221 "$_ in \`ALL_LINGUAS' but po/$_.po does not exist")
3227 &am_error ("AM_GNU_GETTEXT in configure.in but \`ALL_LINGUAS' not defined");
3231 # Handle footer elements.
3234 if ($contents{'SOURCES'})
3236 # NOTE don't use define_pretty_variable here, because
3237 # $contents{...} is already defined.
3238 $output_vars .= 'SOURCES = ' . $contents{'SOURCES'} . "\n";
3240 if ($contents{'OBJECTS'})
3242 # NOTE don't use define_pretty_variable here, because
3243 # $contents{...} is already defined.
3244 $output_vars .= 'OBJECTS = ' . $contents{'OBJECTS'} . "\n";
3246 if ($contents{'SOURCES'} || $contents{'OBJECTS'})
3248 $output_vars .= "\n";
3251 if (&variable_defined ('SUFFIXES'))
3253 # Push actual suffixes, and not $(SUFFIXES). Some versions of
3254 # make do not like variable substitutions on the .SUFFIXES
3256 push (@suffixes, &variable_value_as_list ('SUFFIXES', ''));
3258 if (&target_defined ('.SUFFIXES'))
3260 &am_line_error ('.SUFFIXES',
3261 "use variable \`SUFFIXES', not target \`.SUFFIXES'");
3264 # Note: AIX 4.1 /bin/make will fail if any suffix rule appears
3265 # before .SUFFIXES. So we make sure that .SUFFIXES appears before
3266 # anything else, by sticking it right after the default: target.
3267 $output_header .= ".SUFFIXES:\n";
3271 # Make sure suffixes has unique elements. Sort them to ensure
3272 # the output remains consistent.
3275 grep ($suffixes{$_} = 1, @suffixes);
3277 $output_header .= (".SUFFIXES: "
3278 . join (' ', sort keys %suffixes)
3281 $output_trailer .= &file_contents ('footer');
3284 # Deal with installdirs target.
3285 sub handle_installdirs
3287 # GNU Makefile standards recommend this.
3288 $output_rules .= ("installdirs:"
3289 . ($recursive_install
3290 ? " installdirs-recursive\n"
3292 push (@phony, 'installdirs');
3295 &pretty_print_rule ("\t" . '$(mkinstalldirs) ', "\t\t",
3298 $output_rules .= "\n";
3301 # There are several targets which need to be merged. This is because
3302 # their complete definition is compiled from many parts. Note that we
3303 # avoid double colon rules, otherwise we'd use them instead.
3304 sub handle_merge_targets
3306 local ($makefile) = @_;
3308 # There are a few install-related variables that you should not define.
3310 foreach $var ('PRE_INSTALL', 'POST_INSTALL', 'NORMAL_INSTALL')
3312 if (&variable_defined ($var))
3314 &am_line_error ($var, "\`$var' should not be defined");
3318 # Put this at the beginning for the sake of non-GNU makes. This
3319 # is still wrong if these makes can run parallel jobs. But it is
3321 unshift (@all, &basename ($makefile));
3324 foreach $one_name (@config_names)
3326 push (@all, &basename ($one_name))
3327 if &dirname ($one_name) eq $relative_dir;
3330 &do_one_merge_target ('info', @info);
3331 &do_one_merge_target ('dvi', @dvi);
3332 &do_check_merge_target;
3333 &do_one_merge_target ('installcheck', @installcheck);
3335 if (defined $options{'no-installinfo'})
3337 # FIXME: this is kind of a hack; should find another way to
3338 # know that this is required.
3340 if (grep ($_ eq 'install-info-am', @phony))
3342 push (@dirs, 'install-info-am');
3344 if (&variable_defined ('SUBDIRS'))
3346 push (@dirs, 'install-info-recursive');
3348 &do_one_merge_target ('install-info', @dirs);
3351 # Handle the various install targets specially. We do this so
3352 # that (eg) "make install-exec" will run "install-exec-recursive"
3353 # if required, but "make install" won't run it twice. Step one is
3354 # to see if the user specified local versions of any of the
3355 # targets we handle. "all" is treated as one of these since
3356 # "install" can run it.
3357 push (@install_exec, 'install-exec-local')
3358 if defined $contents{'install-exec-local'};
3359 push (@install_data, 'install-data-local')
3360 if defined $contents{'install-data-local'};
3361 push (@uninstall, 'uninstall-local')
3362 if defined $contents{'uninstall-local'};
3364 foreach $utarg ('uninstall-data-local', 'uninstall-data-hook',
3365 'uninstall-exec-local', 'uninstall-exec-hook')
3367 if (defined $contents{$utarg})
3370 ($x = $utarg) =~ s/(data|exec)-//;
3371 &am_line_error ($utarg, "use \`$x', not \`$utarg'");
3374 push (@all, 'all-local')
3375 if defined $contents{'all-local'};
3377 if (defined $contents{'install-local'})
3379 &am_line_error ('install-local',
3380 "use \`install-data' or \`install-exec', not \`install'");
3383 # Step two: if we are doing recursive makes, write out the
3384 # appropriate rules.
3386 if ($recursive_install)
3388 push (@install, 'install-recursive');
3392 local (@hackall) = ();
3394 local ($local_headers) = '';
3395 foreach $one_name (@config_names)
3397 if (&dirname ($one_name) eq $relative_dir)
3399 $local_headers .= ' ' if $local_headers;
3400 $local_headers .= &basename ($one_name);
3406 # This is kind of a hack, but I couldn't see a better
3407 # way to handle it. In this particular case, we need
3408 # to make sure config.h is built before we recurse.
3409 # We can't do this by changing the order of
3410 # dependencies to the "all" because that breaks when
3411 # using parallel makes. Instead we handle things
3413 $output_rules .= ("all-recursive-am: ${local_headers}"
3414 . "\n\t" . '$(MAKE) all-recursive'
3416 push (@hackall, 'all-recursive-am');
3417 push (@phony, 'all-recursive-am');
3421 push (@hackall, 'all-recursive');
3424 $output_rules .= ('all-am: '
3428 push (@all, 'all-am');
3429 push (@phony, 'all-am');
3433 @all = ('all-recursive');
3435 # Must always generate `all-am' target, so it can be
3436 # referred to elsewhere.
3437 $output_rules .= "all-am:\n";
3441 $output_rules .= ('install-exec-am: '
3442 . join (' ', @install_exec)
3444 @install_exec = ('install-exec-recursive', 'install-exec-am');
3445 push (@install, 'install-exec-am');
3446 push (@phony, 'install-exec-am');
3450 @install_exec = ('install-exec-recursive');
3454 $output_rules .= ('install-data-am: '
3455 . join (' ', @install_data)
3457 @install_data = ('install-data-recursive', 'install-data-am');
3458 push (@install, 'install-data-am');
3459 push (@phony, 'install-data-am');
3463 @install_data = ('install-data-recursive');
3467 $output_rules .= ('uninstall-am: '
3468 . join (' ', @uninstall)
3470 @uninstall = ('uninstall-recursive', 'uninstall-am');
3471 push (@phony, 'uninstall-am');
3475 @uninstall = ('uninstall-recursive');
3479 # Step three: print definitions users can use. Code below knows
3480 # that install-exec is done before install-data, beware.
3481 $output_rules .= ("install-exec: "
3482 . join (' ', @install_exec)
3484 $output_rules .= "\t\@\$(NORMAL_INSTALL)\n";
3485 if (defined $contents{'install-exec-hook'})
3487 $output_rules .= "\t" . '$(MAKE) install-exec-hook' . "\n";
3489 $output_rules .= "\n";
3490 push (@install, 'install-exec') if !$recursive_install;
3491 push (@phony, 'install-exec');
3493 $output_rules .= ("install-data: "
3494 . join (' ', @install_data)
3496 $output_rules .= "\t\@\$(NORMAL_INSTALL)\n";
3497 if (defined $contents{'install-data-hook'})
3499 $output_rules .= "\t" . '$(MAKE) install-data-hook' . "\n";
3501 $output_rules .= "\n";
3502 push (@install, 'install-data') if !$recursive_install;
3503 push (@phony, 'install-data');
3505 # If no dependencies for 'install', add 'all'. Why? That way
3506 # "make install" at top level of distclean'd distribution won't
3507 # fail because stuff in 'lib' fails to build.
3508 if (! @install || (scalar (@install) == 2
3509 && $install[0] eq 'install-exec'
3510 && $install[1] eq 'install-data'))
3512 push (@install, 'all');
3514 $output_rules .= ('install: '
3515 . join (' ', @install)
3516 # Use "@:" as empty command so nothing prints.
3520 . join (' ', @uninstall)
3522 push (@phony, 'install', 'uninstall');
3524 $output_rules .= ('all: '
3527 push (@phony, 'all');
3529 # Generate the new 'install-strip' target. Must set
3530 # INSTALL_SCRIPT to avoid stripping scripts.
3531 $output_rules .= ("install-strip:\n\t"
3532 . '$(MAKE) INSTALL_PROGRAM=\'$(INSTALL_PROGRAM) -s\' INSTALL_SCRIPT=\'$(INSTALL_PROGRAM)\' install'
3536 # Helper for handle_merge_targets.
3537 sub do_one_merge_target
3539 local ($name, @values) = @_;
3541 if (defined $contents{$name . '-local'})
3543 # User defined local form of target. So include it.
3544 push (@values, $name . '-local');
3545 push (@phony, $name . '-local');
3548 &pretty_print_rule ($name . ":", "\t\t", @values);
3549 push (@phony, $name);
3552 # Handle check merge target specially.
3553 sub do_check_merge_target
3555 if (defined $contents{'check-local'})
3557 # User defined local form of target. So include it.
3558 push (@check_tests, 'check-local');
3559 push (@phony, 'check-local');
3562 # In --cygnus mode, check doesn't depend on all.
3565 if (! &variable_defined ('SUBDIRS'))
3567 # 'check' must depend on `all', but not when doing
3569 unshift (@check, 'all');
3573 # When subdirs are used, do the `all' build and then do
3574 # all the recursive stuff. Actually use `all-am' because
3575 # it doesn't recurse; we rely on the check target in the
3576 # subdirs to do the required builds there.
3577 unshift (@check, 'all-am');
3581 # The check target must depend on the local equivalent of `all',
3582 # to ensure all the primary targets are built. Also it must
3583 # depend on the test code named in @check.
3584 &pretty_print_rule ('check:', "\t\t", @check);
3586 # Now the check rules must explicitly run anything named in
3587 # @check_tests. This is done via a separate make invocation to
3588 # avoid problems with parallel makes. Every time I write code
3589 # like this I wonder: how could you invent a parallel make and not
3590 # provide any real synchronization facilities?
3591 &pretty_print_rule ("\t\$(MAKE)", "\t ", @check_tests);
3594 # Handle all 'clean' targets.
3597 push (@clean, 'generic');
3598 $output_rules .= &file_contents ('clean');
3599 &push_phony_cleaners ('generic');
3601 local ($target) = $recursive_install ? 'clean-am' : 'clean';
3602 &do_one_clean_target ($target, 'mostly', '', @clean);
3603 &do_one_clean_target ($target, '', 'mostly', @clean);
3604 &do_one_clean_target ($target, 'dist', '', @clean);
3605 &do_one_clean_target ($target, 'maintainer-', 'dist', @clean);
3607 push (@phony, 'clean', 'mostlyclean', 'distclean', 'maintainer-clean');
3610 if ($recursive_install)
3612 # Do -recursive before -am. If you aren't doing a parallel
3613 # make, this can be nicer.
3614 @deps = ('recursive', 'am');
3615 &do_one_clean_target ('', 'mostly', '', @deps);
3616 &do_one_clean_target ('', '', '', @deps);
3617 &do_one_clean_target ('', 'dist', '', @deps);
3618 &do_one_clean_target ('', 'maintainer-', '', @deps);
3622 # Helper for handle_clean.
3623 sub do_one_clean_target
3625 local ($target, $name, $last_name, @deps) = @_;
3627 # Special case: if target not passed, then don't generate
3628 # dependency on next "lower" clean target (eg no
3629 # clean<-mostlyclean derivation). In this case the target is
3630 # implicitly known to be 'clean'.
3631 local ($flag) = $target;
3632 $target = 'clean' if ! $flag;
3634 grep (($_ = $name . 'clean-' . $_) && 0, @deps);
3637 if ($last_name || $name ne 'mostly')
3639 push (@deps, $last_name . $target);
3643 # If a -local version of the rule is given, add it to the list.
3644 if (defined $contents{$name . $target . '-local'})
3646 push (@deps, $name . $target . '-local');
3649 # Print the target and the dependencies.
3650 &pretty_print_rule ($name . $target . ": ", "\t\t", @deps);
3652 # FIXME: shouldn't we really print these messages before running
3654 if ($name . $target eq 'maintainer-clean')
3656 # Print a special warning.
3658 ("\t\@echo \"This command is intended for maintainers to use;\"\n"
3659 . "\t\@echo \"it deletes files that may require special "
3660 . "tools to rebuild.\"\n");
3662 $output_rules .= "\t-rm -f config.status\n"
3663 if $relative_dir eq '.';
3665 elsif ($name . $target eq 'distclean')
3667 $output_rules .= "\t-rm -f config.status\n";
3668 $output_rules .= "\t-rm -f libtool\n" if $seen_libtool;
3670 $output_rules .= "\n";
3673 # Handle .PHONY target.
3676 &pretty_print_rule ('.PHONY:', "", @phony);
3677 $output_rules .= "\n";
3680 # Handle TESTS variable and other checks.
3683 if (defined $options{'dejagnu'})
3685 push (@check_tests, 'check-DEJAGNU');
3686 push (@phony, 'check-DEJAGNU');
3691 $xform = 's/^CYGNUS//;';
3695 $xform = 's/^CYGNUS.*$//;';
3697 $output_rules .= &file_contents_with_transform ($xform, 'dejagnu');
3699 # In Cygnus mode, these are found in the build tree.
3700 # Otherwise they are looked for in $PATH.
3701 &define_program_variable ('EXPECT', 'build', 'expect', 'expect');
3702 &define_program_variable ('RUNTEST', 'src', 'dejagnu', 'runtest');
3704 # Note that in the rule we don't directly generate site.exp to
3705 # avoid the possibility of a corrupted site.exp if make is
3706 # interrupted. Jim Meyering has some useful text on this
3708 $output_rules .= ("site.exp: Makefile\n"
3709 . "\t\@echo 'Making a new site.exp file...'\n"
3710 . "\t-\@rm -f site.bak\n"
3711 . "\t\@echo '## these variables are automatically generated by make ##' > \$\@-t\n"
3712 . "\t\@echo '# Do not edit here. If you wish to override these values' >> \$\@-t\n"
3713 . "\t\@echo '# edit the last section' >> \$\@-t\n"
3714 . "\t\@echo 'set tool \$(DEJATOOL)' >> \$\@-t\n"
3715 . "\t\@echo 'set srcdir \$(srcdir)' >> \$\@-t\n"
3716 . "\t\@echo 'set objdir' \`pwd\` >> \$\@-t\n");
3718 # Extra stuff for AC_CANONICAL_*
3719 local (@whatlist) = ();
3720 if ($seen_canonical)
3722 push (@whatlist, 'host')
3725 # Extra stuff only for AC_CANONICAL_SYSTEM.
3726 if ($seen_canonical == $AC_CANONICAL_SYSTEM)
3728 push (@whatlist, 'target', 'build');
3732 foreach $c1 (@whatlist)
3734 foreach $c2 ('alias', 'triplet')
3736 $output_rules .= "\t\@echo 'set ${c1}_${c2} \$(${c1}_${c2})' >> \$\@-t\n";
3740 $output_rules .= ("\t\@echo '## All variables above are generated by configure. Do Not Edit ##' >> \$\@-t\n"
3741 . "\t-\@sed '1,/^## All variables above are.*##/ d' site.bak >> \$\@-t\n"
3742 . "\t-\@mv site.exp site.bak\n"
3743 . "\t\@mv \$\@-t site.exp\n");
3748 foreach $c ('DEJATOOL', 'RUNTEST', 'RUNTESTFLAGS')
3750 if (&variable_defined ($c))
3752 &am_line_error ($c, "\`$c' defined but \`dejagnu' not in \`AUTOMAKE_OPTIONS'");
3757 if (&variable_defined ('TESTS'))
3759 push (@check_tests, 'check-TESTS');
3760 push (@phony, 'check-TESTS');
3762 $output_rules .= 'check-TESTS: $(TESTS)
3763 @failed=0; all=0; \\
3764 srcdir=$(srcdir); export srcdir; \\
3765 for tst in $(TESTS); do \\
3766 if test -f $$tst; then dir=.; \\
3767 else dir="$(srcdir)"; fi; \\
3768 if $(TESTS_ENVIRONMENT) $$dir/$$tst; then \\
3769 all=`expr $$all + 1`; \\
3770 echo "PASS: $$tst"; \\
3771 elif test $$? -ne 77; then \\
3772 all=`expr $$all + 1`; \\
3773 failed=`expr $$failed + 1`; \\
3774 echo "FAIL: $$tst"; \\
3777 if test "$$failed" -eq 0; then \\
3778 banner="All $$all tests passed"; \\
3780 banner="$$failed of $$all tests failed"; \\
3782 dashes=`echo "$$banner" | sed s/./=/g`; \\
3786 test "$$failed" -eq 0
3791 # Handle Emacs Lisp.
3792 sub handle_emacs_lisp
3794 local (@elfiles) = &am_install_var ('lisp', 'LISP', 'lisp', 'noinst');
3799 &define_configure_variable ('lispdir');
3800 &define_configure_variable ('EMACS');
3801 $output_rules .= (".el.elc:\n"
3802 . "\t\@echo 'WARNING: Warnings can be ignored. :-)'\n"
3803 . "\tif test \$(EMACS) != no; then \\\n"
3804 . "\t EMACS=\$(EMACS) \$(SHELL) \$(srcdir)/elisp-comp \$<; \\\n"
3806 push (@suffixes, '.el', '.elc');
3808 # Generate .elc files.
3809 grep ($_ .= 'c', @elfiles);
3810 &define_pretty_variable ('ELCFILES', '', @elfiles);
3812 $output_rules .= &file_contents ('lisp-clean');
3813 push (@clean, 'lisp');
3814 &push_phony_cleaners ('lisp');
3816 push (@all, '$(ELCFILES)');
3819 if (&variable_defined ('lisp_LISP'))
3821 $varname = 'lisp_LISP';
3822 &am_error ("\`lisp_LISP' defined but \`AM_PATH_LISPDIR' not in \`configure.in'")
3827 $varname = 'noinst_LISP';
3830 &require_file_with_line ($varname, $FOREIGN, 'elisp-comp');
3834 # Handle some of the minor options.
3835 sub handle_minor_options
3837 if (defined $options{'readme-alpha'})
3839 if ($relative_dir eq '.')
3841 if ($package_version !~ /^$GNITS_VERSION_PATTERN$/)
3843 # FIXME: allow real filename.
3844 &am_conf_line_error ('configure.in',
3845 $package_version_line,
3846 "version \`$package_version' doesn't follow Gnits standards");
3848 elsif (defined $1 && -f 'README-alpha')
3850 # This means we have an alpha release. See
3851 # GNITS_VERSION_PATTERN for details.
3852 &require_file ($FOREIGN, 'README-alpha');
3858 ################################################################
3860 # Scan one file for interesting things. Subroutine of scan_configure.
3861 sub scan_one_configure_file
3863 local ($filename) = @_;
3865 open (CONFIGURE, $filename)
3866 || die "automake: couldn't open \`$filename': $!\n";
3867 print "automake: reading $filename\n" if $verbose;
3871 # Remove comments from current line.
3875 # Skip macro definitions. Otherwise we might be confused into
3876 # thinking that a macro that was only defined was actually
3880 # Populate libobjs array.
3881 if (/AC_FUNC_ALLOCA/)
3883 $libsources{'alloca.c'} = 1;
3885 elsif (/AC_FUNC_GETLOADAVG/)
3887 $libsources{'getloadavg.c'} = 1;
3889 elsif (/AC_FUNC_MEMCMP/)
3891 $libsources{'memcmp.c'} = 1;
3893 elsif (/AC_STRUCT_ST_BLOCKS/)
3895 $libsources{'fileblocks.c'} = 1;
3897 elsif (/A[CM]_REPLACE_GNU_GETOPT/)
3899 $libsources{'getopt.c'} = 1;
3900 $libsources{'getopt1.c'} = 1;
3902 elsif (/AM_FUNC_STRTOD/)
3904 $libsources{'strtod.c'} = 1;
3906 elsif (/AM_WITH_REGEX/)
3908 $libsources{'rx.c'} = 1;
3909 $libsources{'rx.h'} = 1;
3910 $libsources{'regex.c'} = 1;
3911 $libsources{'regex.h'} = 1;
3912 $omit_dependencies{'rx.h'} = 1;
3913 $omit_dependencies{'regex.h'} = 1;
3915 elsif (/AM_FUNC_MKTIME/)
3917 $libsources{'mktime.c'} = 1;
3919 elsif (/AM_FUNC_ERROR_AT_LINE/)
3921 $libsources{'error.c'} = 1;
3922 $libsources{'error.h'} = 1;
3924 elsif (/AM_FUNC_OBSTACK/)
3926 $libsources{'obstack.c'} = 1;
3927 $libsources{'obstack.h'} = 1;
3929 elsif (/LIBOBJS="(.*)\s+\$LIBOBJS"/
3930 || /LIBOBJS="\$LIBOBJS\s+(.*)"/)
3932 foreach $libobj_iter (split (' ', $1))
3934 if ($libobj_iter =~ /^(.*)\.o$/)
3936 $libsources{$1 . '.c'} = 1;
3941 if (! $in_ac_replace && s/AC_REPLACE_FUNCS\s*\(\[?//)
3947 $in_ac_replace = 0 if s/[\]\)].*$//;
3948 # Remove trailing backslash.
3952 # Need to skip empty elements for Perl 4.
3954 $libsources{$_ . '.c'} = 1;
3958 if (/$obsolete_rx/o)
3961 if ($obsolete_macros{$1})
3963 $hint = '; ' . $obsolete_macros{$1};
3965 &am_conf_line_error ($filename, $., "\`$1' is obsolete$hint");
3968 # Process the AC_OUTPUT macro.
3969 if (! $in_ac_output && s/AC_OUTPUT\s*\(\[?//)
3972 $ac_output_line = $.;
3976 local ($closing) = 0;
3983 # Look at potential Makefile.am's.
3986 # Must skip empty string for Perl 4.
3987 next if $_ eq "\\" || $_ eq '';
3989 # Handle $local:$input syntax. Note that we ignore
3990 # every input file past the first, though we keep
3991 # those around for later.
3992 local ($local, $input, @rest) = split (/:/);
3999 # FIXME: should be error if .in is missing.
4000 $input =~ s/\.in$//;
4003 if (-f $input . '.am')
4005 # We have a file that automake should generate.
4006 push (@make_input_list, $input);
4007 $make_list{$input} = join (':', ($local, @rest));
4011 # We have a file that automake should cause to be
4012 # rebuilt, but shouldn't generate itself.
4013 push (@other_input_files, $_);
4017 if ($closing && @make_input_list == 0 && @other_input_files == 0)
4019 &am_conf_line_error ($filename, $ac_output_line,
4020 "No files mentioned in \`AC_OUTPUT'");
4025 if (/$AC_CONFIG_AUX_DIR_PATTERN/o)
4027 @config_aux_path = $1;
4030 # Check for ansi2knr.
4031 $am_c_prototypes = 1 if /AM_C_PROTOTYPES/;
4033 # Check for exe extension stuff.
4037 $configure_vars{'EXEEXT'} = 1;
4040 # Check for NLS support.
4041 if (/AM_GNU_GETTEXT/)
4044 $ac_gettext_line = $.;
4045 $omit_dependencies{'libintl.h'} = 1;
4048 # Look for ALL_LINGUAS.
4049 if (/ALL_LINGUAS="(.*)"$/ || /ALL_LINGUAS=(.*)$/)
4053 $all_linguas_line = $.;
4056 # Handle configuration headers. A config header of `[$1]'
4057 # means we are actually scanning AM_CONFIG_HEADER from
4059 if (/A([CM])_CONFIG_HEADER\s*\((.*)\)/
4064 "\`AC_CONFIG_HEADER' is obsolete; use \`AM_CONFIG_HEADER'")
4067 $config_header_line = $.;
4069 foreach $one_hdr (split (' ', $2))
4071 push (@config_fullnames, $one_hdr);
4072 if ($one_hdr =~ /^([^:]+):(.+)$/)
4074 push (@config_names, $1);
4075 push (@config_headers, $2);
4079 push (@config_names, $one_hdr);
4080 push (@config_headers, $one_hdr . '.in');
4085 # Handle AC_CANONICAL_*. Always allow upgrading to
4086 # AC_CANONICAL_SYSTEM, but never downgrading.
4087 $seen_canonical = $AC_CANONICAL_HOST
4088 if ! $seen_canonical
4089 && (/AC_CANONICAL_HOST/ || /AC_CHECK_TOOL/);
4090 $seen_canonical = $AC_CANONICAL_SYSTEM if /AC_CANONICAL_SYSTEM/;
4092 $seen_path_xtra = 1 if /AC_PATH_XTRA/;
4094 # This macro handles several different things.
4095 if (/$AM_INIT_AUTOMAKE_PATTERN/o)
4101 $seen_prog_install = 2;
4102 ($package_version = $1) =~ s/$AM_PACKAGE_VERSION_PATTERN/$1/o;
4103 $package_version_line = $.;
4106 # This is like AM_INIT_AUTOMAKE, but doesn't actually set the
4107 # package and version number. (This might change in the
4108 # future). Yes, I'm not above hacking Automake so it works
4109 # well with other GNU tools -- that is actually the point.
4110 if (/AM_INIT_GUILE_MODULE/)
4116 $seen_prog_install = 2;
4117 @config_aux_path = ('..');
4120 # Some things required by Automake.
4121 $seen_make_set = 1 if /AC_PROG_MAKE_SET/;
4122 $seen_arg_prog = 1 if /AC_ARG_PROGRAM/;
4124 if (/AC_PROG_(YACC|RANLIB|CC|CXXCPP|CXX|LEX|AWK|CPP|LN_S)/)
4126 $configure_vars{$1} = 1;
4128 if (/$AC_CHECK_PATTERN/o)
4130 $configure_vars{$3} = 1;
4132 if (/$AM_MISSING_PATTERN/o
4136 && $1 ne 'AUTOHEADER')
4138 $configure_vars{$1} = 1;
4141 # Explicitly avoid ANSI2KNR -- we AC_SUBST that in protos.m4,
4142 # but later define it elsewhere. This is pretty hacky. We
4143 # also explicitly avoid INSTALL_SCRIPT and some other
4144 # variables because they are defined in header-vars.am.
4146 if (/$AC_SUBST_PATTERN/o
4148 && $1 ne 'INSTALL_SCRIPT')
4150 $configure_vars{$1} = 1;
4153 $seen_decl_yytext = 1 if /AC_DECL_YYTEXT/;
4154 $seen_maint_mode = 1 if /AM_MAINTAINER_MODE/;
4155 $seen_package = 1 if /PACKAGE=/;
4157 # Skip VERSION of [$2]; that is from AM_INIT_AUTOMAKE.
4158 if (/\bVERSION=(\S+)/ && $1 ne '[$2]')
4161 $package_version = $1;
4162 $package_version_line = $.;
4169 # Weird conditionals here because it is always allowed to
4170 # upgrade to AM_PROG_INSTALL but never to downgrade to
4172 $seen_prog_install = 1 if ! $seen_prog_install && /AC_PROG_INSTALL/;
4173 $seen_prog_install = 2 if /AM_PROG_INSTALL/;
4175 $seen_lispdir = 1 if /AM_PATH_LISPDIR/;
4177 if (/AM_PROG_LIBTOOL/)
4181 $configure_vars{'LIBTOOL'} = 1;
4182 $configure_vars{'RANLIB'} = 1;
4183 $configure_vars{'CC'} = 1;
4184 # AM_PROG_LIBTOOL runs AC_CANONICAL_HOST. Make sure we
4185 # never downgrade (if we've seen AC_CANONICAL_SYSTEM).
4186 $seen_canonical = $AC_CANONICAL_HOST if ! $seen_canonical;
4189 if (/$AM_CONDITIONAL_PATTERN/o)
4191 $configure_cond{$1} = 1;
4198 # Scan configure.in and aclocal.m4 for interesting things. We must
4199 # scan aclocal.m4 because there might be AC_SUBSTs and such there.
4202 # Reinitialize libsources here. This isn't really necessary,
4203 # since we currently assume there is only one configure.in. But
4204 # that won't always be the case.
4207 local ($in_ac_output, $in_ac_replace) = (0, 0);
4208 local (%make_list, @make_input_list);
4209 local ($libobj_iter);
4211 &scan_one_configure_file ('configure.in');
4212 &scan_one_configure_file ('aclocal.m4')
4215 # Set input and output files if not specified by user.
4218 @input_files = @make_input_list;
4219 %output_files = %make_list;
4222 &am_conf_error ("\`PACKAGE' not defined in configure.in")
4224 &am_conf_error ("\`VERSION' not defined in configure.in")
4227 # Look for some files we need. Always check for these. This
4228 # check must be done for every run, even those where we are only
4229 # looking at a subdir Makefile. We must set relative_dir so that
4230 # the file-finding machinery works.
4231 local ($relative_dir) = '.';
4232 &require_config_file ($FOREIGN, 'install-sh', 'mkinstalldirs', 'missing');
4233 &am_error ("\`install.sh' is an anachronism; use \`install-sh' instead")
4234 if -f $config_aux_path[0] . '/install.sh';
4237 ################################################################
4239 # Set up for Cygnus mode.
4242 return unless $cygnus_mode;
4244 &set_strictness ('foreign');
4245 $options{'no-installinfo'} = 1;
4246 $options{'no-dependencies'} = 1;
4247 $use_dependencies = 0;
4249 if (! $seen_maint_mode)
4251 &am_conf_error ("\`AM_MAINTAINER_MODE' required when --cygnus specified");
4256 &am_conf_error ("\`AM_EXEEXT' required when --cygnus specified");
4260 # Do any extra checking for GNU standards.
4261 sub check_gnu_standards
4263 if ($relative_dir eq '.')
4265 # In top level (or only) directory.
4266 &require_file ($GNU, 'INSTALL', 'NEWS', 'README', 'COPYING',
4267 'AUTHORS', 'ChangeLog');
4270 if ($strictness >= $GNU)
4272 if (defined $options{'no-installman'})
4274 &am_line_error ('AUTOMAKE_OPTIONS',
4275 "option \`no-installman' disallowed by GNU standards");
4278 if (defined $options{'no-installinfo'})
4280 &am_line_error ('AUTOMAKE_OPTIONS',
4281 "option \`no-installinfo' disallowed by GNU standards");
4286 # Do any extra checking for GNITS standards.
4287 sub check_gnits_standards
4289 if ($strictness >= $GNITS)
4291 if (-f $relative_dir . '/COPYING.LIB')
4293 &am_error ("\`${relative_dir}/COPYING.LIB' disallowed by Gnits standards");
4297 if ($relative_dir eq '.')
4299 # In top level (or only) directory.
4300 &require_file ($GNITS, 'THANKS');
4304 ################################################################
4306 # Pretty-print something. HEAD is what should be printed at the
4307 # beginning of the first line, FILL is what should be printed at the
4308 # beginning of every subsequent line.
4309 sub pretty_print_internal
4311 local ($head, $fill, @values) = @_;
4313 local ($column) = length ($head);
4314 local ($result) = $head;
4316 # Fill length is number of characters. However, each Tab
4317 # character counts for eight. So we count the number of Tabs and
4319 local ($fill_length) = length ($fill);
4320 $fill_length += 7 * ($fill =~ tr/\t/\t/d);
4322 local ($bol) = ($head eq '');
4325 # "71" because we also print a space.
4326 if ($column + length ($_) > 71)
4328 $result .= " \\\n" . $fill;
4329 $column = $fill_length;
4333 $result .= ' ' unless ($bol);
4335 $column += length ($_) + 1;
4343 # Pretty-print something and append to output_vars.
4346 $output_vars .= &pretty_print_internal (@_);
4349 # Pretty-print something and append to output_rules.
4350 sub pretty_print_rule
4352 $output_rules .= &pretty_print_internal (@_);
4356 ################################################################
4358 # See if a target exists.
4361 local ($target) = @_;
4362 return defined $targets{$target};
4365 # See if two conditionals are the same.
4366 sub conditional_same
4368 local ($cond1, $cond2) = @_;
4370 return (&conditional_true_when ($cond1, $cond2)
4371 && &conditional_true_when ($cond2, $cond1));
4374 # See if a conditional is true. Both arguments are conditional
4375 # strings. This returns true if the first conditional is true when
4376 # the second conditional is true.
4377 sub conditional_true_when
4379 local ($cond, $when) = @_;
4381 # Check the easy case first.
4387 # Check each component of $cond, which looks @COND1@@COND2@.
4388 foreach $comp (split ('@', $cond))
4390 # The way we split will give null strings between each
4394 if (index ($when, '@' . $comp . '@') == -1)
4403 # Check for an ambiguous conditional. This is called when a variable
4404 # or target is being defined conditionally. If we already know about
4405 # a definition that is true under the same conditions, then we have an
4407 sub check_ambiguous_conditional
4409 local ($var_name, $cond) = @_;
4410 local (@cond_vals) = split (' ', $conditional{$var_name});
4413 local ($vcond) = shift (@cond_vals);
4415 if (&conditional_true_when ($vcond, $cond)
4416 || &conditional_true_when ($cond, $vcond))
4418 &am_line_error ($var_name,
4419 "$var_name multiply defined in condition");
4424 # See if a variable exists. The first argument is the variable name,
4425 # and the optional second argument is the condition which we should
4426 # check. If no condition is given, we currently return true if the
4427 # variable is defined under any condition.
4428 sub variable_defined
4430 local ($var, $cond) = @_;
4431 if (defined $targets{$var})
4433 &am_line_error ($var, "\`$var' is target; expected variable");
4436 elsif (defined $contents{$var})
4438 if ($cond && $conditional{$var})
4440 # We have been asked to check for a particular condition,
4441 # and the variable is defined conditionally. We need to
4442 # look through the conditions under which the variable is
4443 # defined, and see if any of them match the conditional we
4444 # have been asked to check.
4445 local (@cond_vars) = split (' ', $conditional{$var});
4448 if (&conditional_same ($cond, shift (@cond_vars)))
4450 # Even a conditional examination is good enough
4451 # for us. FIXME: really should maintain examined
4452 # status on a per-condition basis.
4453 $content_seen{$var} = 1;
4459 # The variable is not defined for the given condition.
4463 $content_seen{$var} = 1;
4469 # Mark a variable as examined.
4470 sub examine_variable
4473 &variable_defined ($var);
4476 # Quote a value in order to put it in $conditional. We need to quote
4477 # spaces, and we need to handle null strings, so that we can later
4478 # retrieve values by splitting on space.
4483 $val = '\002' if $val eq '';
4487 # Unquote a value in $conditional.
4488 sub unquote_cond_val
4492 $val = '' if $val eq '\002';
4496 # Return the set of conditions for which a variable is defined.
4498 # If the variable is not defined conditionally, and is not defined in
4499 # terms of any variables which are defined conditionally, then this
4500 # returns the empty list.
4502 # If the variable is defined conditionally, but is not defined in
4503 # terms of any variables which are defined conditionally, then this
4504 # returns the list of conditions for which the variable is defined.
4506 # If the variable is defined in terms of any variables which are
4507 # defined conditionally, then this returns a full set of permutations
4508 # of the subvariable conditions. For example, if the variable is
4509 # defined in terms of a variable which is defined for @COND_TRUE@,
4510 # then this returns both @COND_TRUE@ and @COND_FALSE@. This is
4511 # because we will need to define the variable under both conditions.
4513 sub variable_conditions
4519 foreach $cond (&variable_conditions_sub ($var, '', ()))
4521 $uniqify{$cond} = 1;
4524 return keys %uniqify;
4527 # A subroutine of variable_conditions. We only return conditions
4528 # which are true for all the conditions in @PARENT_CONDS.
4529 sub variable_conditions_sub
4531 local ($var, $parent, @parent_conds) = @_;
4532 local (@new_conds) = ();
4534 if (! $conditional{$var})
4536 foreach (split (' ', $contents{$var}))
4538 # If a comment seen, just leave.
4541 # Handle variable substitutions.
4542 if (/^\$\{(.*)\}$/ || /^\$\((.*)\)$/)
4545 &variable_conditions_sub ($1, $var, @parent_conds));
4549 return &variable_conditions_reduce (@new_conds);
4552 local (@this_conds) = ();
4553 local (@condvals) = split (' ', $conditional{$var});
4556 local ($cond) = shift (@condvals);
4557 local ($val) = &unquote_cond_val (shift (@condvals));
4562 local ($parent_cond);
4563 foreach $parent_cond (@parent_conds)
4565 if (! &conditional_true_when ($parent_cond, $cond))
4575 push (@this_conds, $cond);
4577 push (@parent_conds, $cond);
4578 local (@subvar_conds) = ();
4579 foreach (split (' ', $val))
4581 # If a comment seen, just leave.
4584 # Handle variable substitutions.
4585 if (/^\$\{(.*)\}$/ || /^\$\((.*)\)$/)
4587 push (@subvar_conds,
4588 &variable_conditions_sub ($1, $var, @parent_conds));
4591 pop (@parent_conds);
4593 # If there are no conditional subvariables, then we want to
4594 # return this condition. Otherwise, we want to return the
4595 # permutations of the subvariables.
4596 if (! @subvar_conds)
4598 push (@new_conds, $cond);
4602 push (@new_conds, &variable_conditions_reduce (@subvar_conds));
4609 # If we are being called on behalf of another variable, we need to
4610 # return all possible permutations of the conditions. We have
4611 # already handled everything in @this_conds along with their
4612 # subvariables. We now need to add any permutations that are not
4615 foreach $this_cond (@this_conds)
4618 &variable_conditions_permutations (split('@', $this_cond));
4620 foreach $perm (@perms)
4624 foreach $scan (@this_conds)
4626 if (&conditional_true_when ($perm, $scan)
4627 || &conditional_true_when ($scan, $perm))
4638 local ($parent_cond);
4639 foreach $parent_cond (@parent_conds)
4641 if (! &conditional_true_when ($parent_cond, $perm))
4651 # This permutation was not already handled, and is valid
4653 push (@new_conds, $perm);
4660 # Subroutine for variable_conditions_sort
4661 sub variable_conditions_cmp
4667 return (length ($as) <=> length ($bs)
4671 # Sort a list of conditionals so that only the exclusive ones are
4672 # retained. For example, if both @COND1_TRUE@@COND2_TRUE@ and
4673 # @COND1_TRUE@ are in the list, discard the latter.
4674 sub variable_conditions_reduce
4676 local (@conds) = @_;
4679 foreach $cond (sort variable_conditions_cmp @conds)
4683 foreach $scan (@ret)
4685 if (&conditional_true_when ($cond, $scan))
4698 # Return a list of permutations of a conditional string.
4699 sub variable_conditions_permutations
4701 local (@comps) = @_;
4704 local ($comp) = shift (@comps);
4705 return &variable_conditions_permutations (@comps)
4707 local ($neg) = $comp;
4708 $neg =~ s/TRUE$/TRUEO/;
4709 $neg =~ s/FALSE$/TRUE/;
4710 $neg =~ s/TRUEO$/FALSE/;
4713 foreach $sub (&variable_conditions_permutations (@comps))
4715 push (@ret, '@' . $comp . '@' . $sub);
4716 push (@ret, '@' . $neg . '@' . $sub);
4720 push (@ret, '@' . $comp . '@');
4721 push (@ret, '@' . $neg . '@');
4726 # Warn if a variable is conditionally defined. This is called if we
4727 # are using the value of a variable.
4728 sub variable_conditionally_defined
4730 local ($var, $parent) = @_;
4731 if ($conditional{$var})
4735 &am_line_error ($parent,
4736 "warning: automake does not support conditional definition of $var in $parent");
4740 &am_line_error ($parent,
4741 "warning: automake does not support $var being defined conditionally")
4746 # Get the value of a variable. This just returns $contents, but warns
4747 # if the variable is conditionally defined.
4751 &variable_conditionally_defined ($var);
4752 return $contents{$var};
4755 # Convert a variable value to a list, split as whitespace. This will
4756 # recursively follow $(...) and ${...} inclusions. It preserves @...@
4757 # substitutions. If COND is 'all', then all values under all
4758 # conditions should be returned; if COND is a particular condition
4759 # (all conditions are surrounded by @...@) then only the value for
4760 # that condition should be returned; otherwise, warn if VAR is
4761 # conditionally defined.
4764 local ($var, $val, $cond) = @_;
4767 foreach (split (' ', $val))
4769 # If a comment seen, just leave.
4772 # Handle variable substitutions.
4773 if (/^\$\{([^}]*)\}$/ || /^\$\(([^)]*)\)$/)
4775 local ($varname) = $1;
4777 # If the user uses a losing variable name, just ignore it.
4778 # This isn't ideal, but people have requested it.
4779 next if ($varname =~ /\@.*\@/);
4783 if ($varname =~ /^([^:]*):([^=]*)=(.*)$/)
4787 ($from = $2) =~ s/(\W)/\\$1/g;
4791 @temp_list = &variable_value_as_list ($1, $cond, $var);
4793 # Now rewrite the value if appropriate.
4796 grep (s/$from$/$to/, @temp_list);
4799 push (@result, @temp_list);
4810 # Return contents of variable as list, split as whitespace. This will
4811 # recursively follow $(...) and ${...} inclusions. It preserves @...@
4812 # substitutions. If COND is 'all', then all values under all
4813 # conditions should be returned; if COND is a particular condition
4814 # (all conditions are surrounded by @...@) then only the value for
4815 # that condition should be returned; otherwise, warn if VAR is
4816 # conditionally defined. If PARENT is specified, it is the name of
4817 # the including variable; this is only used for error reports.
4818 sub variable_value_as_list
4820 local ($var, $cond, $parent) = @_;
4823 if (defined $targets{$var})
4825 &am_line_error ($var, "\`$var' is target; expected variable");
4827 elsif (! defined $contents{$var})
4829 &am_line_error ($parent, "variable \`$var' not defined");
4831 elsif ($cond eq 'all' && $conditional{$var})
4833 local (@condvals) = split (' ', $conditional{$var});
4837 local ($val) = &unquote_cond_val (shift (@condvals));
4838 push (@result, &value_to_list ($var, $val, $cond));
4841 elsif ($cond && $conditional{$var})
4843 local (@condvals) = split (' ', $conditional{$var});
4847 local ($vcond) = shift (@condvals);
4848 local ($val) = &unquote_cond_val (shift (@condvals));
4849 if (&conditional_true_when ($vcond, $cond))
4851 # Warn if we have an ambiguity. It's hard to know how
4852 # to handle this case correctly.
4853 &variable_conditionally_defined ($var, $parent)
4856 push (@result, &value_to_list ($var, $val, $cond));
4862 &variable_conditionally_defined ($var, $parent);
4863 $content_seen{$var} = 1;
4864 push (@result, &value_to_list ($var, $contents{$var}, $cond));
4870 # Define a new variable, but only if not already defined.
4873 local ($var, $value) = @_;
4875 if (! defined $contents{$var})
4877 $output_vars .= $var . ' = ' . $value . "\n";
4878 $contents{$var} = $value;
4879 $content_seen{$var} = 1;
4883 # Like define_variable, but the value is a list, and the variable may
4884 # be defined conditionally. The second argument is the conditional
4885 # under which the value should be defined; this should be the empty
4886 # string to define the variable unconditionally. The third argument
4887 # is a list holding the values to use for the variable. The value is
4888 # pretty printed in the output file.
4889 sub define_pretty_variable
4891 local ($var, $cond, @value) = @_;
4892 if (! defined $contents{$var}
4893 || ($cond && ! &variable_defined ($var, $cond)))
4895 $contents{$var} = join (' ', @value);
4898 if ($conditional{$var})
4900 $conditional{$var} .= ' ';
4904 $conditional{$var} = '';
4906 $conditional{$var} .= ($cond
4908 . "e_cond_val ($contents{$var}));
4910 &pretty_print ($cond . $var . ' = ', $cond, @value);
4911 $content_seen{$var} = 1;
4915 # Like define_variable, but define a variable to be the configure
4916 # substitution by the same name.
4917 sub define_configure_variable
4920 local ($value) = '@' . $var . '@';
4921 &define_variable ($var, $value);
4924 # Define a variable that represents a program to run. If in Cygnus
4925 # mode, the program is searched for in the build (or source) tree.
4926 # Otherwise no searching is done at all. Arguments are:
4927 # * VAR Name of variable to define
4928 # * WHATDIR Either `src' or `build', depending on where program should
4929 # be found. (runtest is in srcdir!)
4930 # * SUBDIR Subdir of top-level dir
4931 # * PROGRAM Name of program
4932 # * OVERRIDE If specified, the name of the program to use when not in
4933 # Cygnus mode. Defaults to PROGRAM.
4934 sub define_program_variable
4936 local ($var, $whatdir, $subdir, $program, $override) = @_;
4940 $override = $program;
4945 local ($full) = ('$(top_' . $whatdir . 'dir)/../'
4946 . $subdir . '/' . $program);
4947 &define_variable ($var, ('`if test -f ' . $full
4948 . '; then echo ' . $full . '; else echo '
4949 . $program . '; fi`'));
4953 &define_variable ($var, $override);
4958 ################################################################
4960 # Read Makefile.am and set up %contents. Simultaneously copy lines
4961 # from Makefile.am into $output_trailer or $output_vars as
4962 # appropriate. NOTE we put rules in the trailer section. We want
4963 # user rules to come after our generated stuff.
4966 local ($amfile) = @_;
4968 open (AM_FILE, $amfile) || die "automake: couldn't open \`$amfile': $!\n";
4969 print "automake: reading $amfile\n" if $verbose;
4971 $output_vars = ("# $in_file_name generated automatically by automake "
4972 . $VERSION . " from $am_file_name\n");
4974 # Generate copyright for generated Makefile.in.
4975 $output_vars .= $gen_copyright;
4977 local ($saw_bk) = 0;
4978 local ($was_rule) = 0;
4979 local ($spacing) = '';
4980 local ($comment) = '';
4981 local ($last_var_name) = '';
4986 if (/$IGNORE_PATTERN/o)
4988 # Merely delete comments beginning with two hashes.
4990 elsif (/$WHITE_PATTERN/o)
4992 # Stick a single white line before the incoming macro or rule.
4996 elsif (/$COMMENT_PATTERN/o)
4998 # Stick comments before the incoming macro or rule. Make
4999 # sure a blank line preceeds first block of comments.
5000 $spacing = "\n" unless $blank;
5002 $comment .= $spacing . $_;
5011 $output_vars .= $comment . "\n";
5014 local ($am_vars) = '';
5016 local ($is_ok_macro);
5020 unless substr ($_, -1, 1) eq "\n";
5022 $_ =~ s/\@MAINT\@//g
5023 unless $seen_maint_mode;
5025 if (/$IGNORE_PATTERN/o)
5027 # Merely delete comments beginning with two hashes.
5029 elsif (/$WHITE_PATTERN/o)
5031 # Stick a single white line before the incoming macro or rule.
5034 elsif (/$COMMENT_PATTERN/o)
5036 # Stick comments before the incoming macro or rule.
5037 $comment .= $spacing . $_;
5044 $output_trailer .= join ('', @conditional_stack) . $_;
5049 $am_vars .= join ('', @conditional_stack) . $_;
5051 # Chop newline and backslash if this line is
5052 # continued. FIXME: maybe ensure trailing whitespace
5056 $contents{$last_var_name} .= $_;
5057 if (@conditional_stack)
5059 $conditional{$last_var_name} .= "e_cond_val ($_);
5063 elsif (/$IF_PATTERN/o)
5065 &am_line_error ($., "$1 does not appear in AM_CONDITIONAL")
5066 if (! $configure_cond{$1});
5067 push (@conditional_stack, "\@" . $1 . "_TRUE\@");
5069 elsif (/$ELSE_PATTERN/o)
5071 if (! @conditional_stack)
5073 &am_line_error ($., "else without if");
5075 elsif ($conditional_stack[$#conditional_stack] =~ /_FALSE\@$/)
5077 &am_line_error ($., "else after else");
5081 $conditional_stack[$#conditional_stack]
5082 =~ s/_TRUE\@$/_FALSE\@/;
5085 elsif (/$ENDIF_PATTERN/o)
5087 if (! @conditional_stack)
5089 &am_line_error ($., "endif without if");
5093 pop @conditional_stack;
5096 elsif (/$RULE_PATTERN/o)
5100 if (defined $contents{$1}
5101 && (@conditional_stack
5102 ? ! defined $conditional{$1}
5103 : defined $conditional{$1}))
5106 "$1 defined both conditionally and unconditionally");
5108 # Value here doesn't matter; for targets we only note
5112 local ($cond_string) = join ('', @conditional_stack);
5113 if (@conditional_stack)
5115 if ($conditional{$1})
5117 &check_ambiguous_conditional ($1, $cond_string);
5118 $conditional{$1} .= ' ';
5122 $conditional{$1} = '';
5124 $conditional{$1} .= $cond_string . ' 1';
5126 $content_lines{$1} = $.;
5127 $output_trailer .= $comment . $spacing . $cond_string . $_;
5128 $comment = $spacing = '';
5131 # Check the rule for being a suffix rule. If so, store in
5134 local ($source_suffix);
5135 local ($object_suffix);
5137 if (($source_suffix, $object_suffix) = ($1 =~ $SUFFIX_RULE_PATTERN))
5139 $suffix_rules{$source_suffix} = $object_suffix;
5140 print "Sources ending in .$source_suffix become .$object_suffix\n" if $verbose;
5141 $source_suffix_pattern = "(" . join('|', keys %suffix_rules) . ")";
5144 # FIXME: make sure both suffixes are in SUFFIXES? Or set
5145 # SUFFIXES from suffix_rules?
5147 elsif (($is_ok_macro = /$MACRO_PATTERN/o)
5148 || /$BOGUS_MACRO_PATTERN/o)
5150 # Found a macro definition.
5152 $last_var_name = $1;
5153 if (defined $contents{$1}
5154 && (@conditional_stack
5155 ? ! defined $conditional{$1}
5156 : defined $conditional{$1}))
5159 "$1 defined both conditionally and unconditionally");
5161 if ($2 ne '' && substr ($2, -1) eq "\\")
5163 $contents{$last_var_name} = substr ($2, 0, length ($2) - 1);
5167 $contents{$last_var_name} = $2;
5169 local ($cond_string) = join ('', @conditional_stack);
5170 if (@conditional_stack)
5172 if ($conditional{$last_var_name})
5174 &check_ambiguous_conditional ($last_var_name,
5176 $conditional{$last_var_name} .= ' ';
5180 $conditional{$last_var_name} = '';
5182 local ($val) = $contents{$last_var_name};
5183 $conditional{$last_var_name} .= ($cond_string
5185 . "e_cond_val ($val));
5187 $content_lines{$last_var_name} = $.;
5188 $am_vars .= $comment . $spacing . $cond_string . $_;
5189 $comment = $spacing = '';
5193 &am_line_error ($., "bad macro name \`$last_var_name'")
5198 # This isn't an error; it is probably a continued rule.
5199 # In fact, this is what we assume.
5201 $output_trailer .= ($comment . $spacing
5202 . join ('', @conditional_stack) . $_);
5203 $comment = $spacing = '';
5210 $output_trailer .= $comment;
5212 &am_error ("unterminated conditionals: " . join (' ', @conditional_stack))
5213 if (@conditional_stack);
5215 # Compute relative location of the top object directory.
5216 local (@topdir) = ();
5217 foreach (split (/\//, $relative_dir))
5219 next if $_ eq '.' || $_ eq '';
5226 push (@topdir, '..');
5229 @topdir = ('.') if ! @topdir;
5231 $top_builddir = join ('/', @topdir);
5233 ($build_rx = $top_builddir) =~ s/(\W)/\\$1/g;
5234 $output_vars .= &file_contents_with_transform
5235 ('s/\@top_builddir\@/' . $build_rx . '/g;',
5238 # Generate some useful variables when AC_CANONICAL_* used. FIXME:
5239 # this should use generic %configure_vars method.
5240 if ($seen_canonical)
5242 local ($curs, %vars);
5243 $vars{'host_alias'} = 'host_alias';
5244 $vars{'host_triplet'} = 'host';
5245 if ($seen_canonical == $AC_CANONICAL_SYSTEM)
5247 $vars{'build_alias'} = 'build_alias';
5248 $vars{'build_triplet'} = 'build';
5249 $vars{'target_alias'} = 'target_alias';
5250 $vars{'target_triplet'} = 'target';
5252 foreach $curs (sort keys %vars)
5254 $output_vars .= "$curs = \@$vars{$curs}\@\n";
5255 $contents{$curs} = "\@$vars{$curs}\@";
5260 foreach $curs (sort keys %configure_vars)
5262 &define_configure_variable ($curs);
5265 $output_vars .= $am_vars;
5268 ################################################################
5270 sub initialize_global_constants
5272 # Values for AC_CANONICAL_*
5273 $AC_CANONICAL_HOST = 1;
5274 $AC_CANONICAL_SYSTEM = 2;
5276 # Associative array of standard directory names. Entry is TRUE if
5277 # corresponding directory should be installed during
5278 # 'install-exec' phase.
5296 # Helper text for dealing with man pages.
5297 $install_man_format =
5298 ' @sect=@SECTION@; \\
5299 inst=`echo "@MANBASE@" | sed \'$(transform)\'`.@FULLSECT@; \\
5300 if test -f $(srcdir)/@MAN@; then file=$(srcdir)/@MAN@; \\
5301 else file=@MAN@; fi; \\
5302 echo " $(INSTALL_DATA) $$file $(mandir)/man$$sect/$$inst"; \\
5303 $(INSTALL_DATA) $$file $(mandir)/man$$sect/$$inst
5306 $uninstall_man_format =
5307 ' -inst=`echo "@MANBASE@" | sed \'$(transform)\'`.@FULLSECT@; \\
5308 rm -f $(mandir)/man@SECTION@/$$inst
5311 # Commonly found files we look for and automatically include in
5315 "README", "THANKS", "TODO", "NEWS", "COPYING", "COPYING.LIB",
5316 "INSTALL", "ABOUT-NLS", "ChangeLog", "configure", "configure.in",
5317 "config.guess", "config.sub", "AUTHORS", "BACKLOG", "ABOUT-GNU",
5318 "libversion.in", "mdate-sh", "mkinstalldirs", "install-sh",
5319 'texinfo.tex', "ansi2knr.c", "ansi2knr.1", 'elisp-comp',
5320 'ylwrap', 'acinclude.m4', @libtoolize_files,
5324 # Commonly used files we auto-include, but only sometimes.
5327 "aclocal.m4", "acconfig.h", "config.h.top",
5328 "config.h.bot", "stamp-h.in", 'stamp-vti'
5332 -a, --add-missing add missing standard files to package
5333 --amdir=DIR directory storing config files
5334 --build-dir=DIR directory where build being done (for dependencies)
5335 --cygnus assume program is part of Cygnus-style tree
5336 --foreign set strictness to foreign
5337 --gnits set strictness to gnits
5338 --gnu set strictness to gnu
5339 --help print this help, then exit
5340 -i, --include-deps include generated dependencies in Makefile.in
5341 --no-force only update Makefile.in's that are out of date
5342 -o DIR, --output-dir=DIR
5343 put generated Makefile.in's into DIR
5344 --srcdir-name=DIR name used for srcdir (for dependencies)
5345 -v, --verbose verbosely list files processed
5346 --version print version number, then exit\n";
5348 # Copyright on generated Makefile.ins.
5350 # Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
5351 # This Makefile.in is free software; the Free Software Foundation
5352 # gives unlimited permission to copy and/or distribute it,
5353 # with or without modifications, as long as this notice is preserved.
5355 # This program is distributed in the hope that it will be useful,
5356 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
5357 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
5358 # PARTICULAR PURPOSE.
5361 # Ignore return result from chmod, because it might give an error
5362 # if we chmod a symlink.
5363 $dist_header = "\t" . '-chmod -R a+r $(distdir)' . "\n";
5364 $dist{'dist-tarZ'} = ("\t"
5365 . '$(TAR) chf - $(distdir) | compress -c > $(distdir).tar.Z'
5367 $dist{'dist-shar'} = ("\t"
5368 . 'shar $(distdir) | gzip > $(distdir).shar.gz'
5370 $dist{'dist-zip'} = "\t" . 'zip -rq $(distdir).zip $(distdir)' . "\n";
5371 $dist{'dist'} = "\t" . 'GZIP=$(GZIP) $(TAR) chozf $(distdir).tar.gz $(distdir)' . "\n";
5372 $dist_trailer = "\t" . '-rm -rf $(distdir)' . "\n";
5375 # (Re)-Initialize per-Makefile.am variables.
5376 sub initialize_per_input
5378 # These two variables are used when generating each Makefile.in.
5379 # They hold the Makefile.in until it is ready to be printed.
5382 $output_trailer = '';
5383 $output_header = '';
5385 # Suffixes found during a run.
5388 # This holds the contents of a Makefile.am, as parsed by
5392 # This holds the names which are targets. These also appear in
5396 # For a variable or target which is defined conditionally, this
5397 # holds an array of the conditional values. The array is composed
5398 # of pairs of condition strings (the variables which configure
5399 # will substitute) and values (the value of a target is
5400 # meaningless). For an unconditional variable, this is empty.
5403 # This holds the line numbers at which various elements of
5404 # %contents are defined.
5405 %content_lines = ();
5407 # This holds a 1 if a particular variable was examined.
5410 # This is the conditional stack.
5411 @conditional_stack = ();
5413 # This holds the "relative directory" of the current Makefile.in.
5414 # Eg for src/Makefile.in, this is "src".
5417 # This holds a list of files that are included in the
5421 # List of dependencies for the obvious targets.
5437 # These are pretty obvious, too. They are used to define the
5438 # SOURCES and OBJECTS variables.
5442 # TRUE if current directory holds any C source files.
5443 $dir_holds_sources = 0;
5445 # These variables track inclusion of various compile-related .am
5446 # files. $included_generic_compile is TRUE if the basic code has
5447 # been included. $included_knr_compile is TRUE if the ansi2knr
5448 # code has been included. $included_libtool_compile is TRUE if
5449 # libtool support has been included.
5450 $included_generic_compile = 0;
5451 $included_knr_compile = 0;
5452 $included_libtool_compile = 0;
5454 # TRUE if current directory holds any headers.
5455 $dir_holds_headers = 0;
5457 # TRUE if install targets should work recursively.
5458 $recursive_install = 0;
5463 # Strictness levels.
5464 $strictness = $default_strictness;
5465 $strictness_name = $default_strictness_name;
5467 # Options from AUTOMAKE_OPTIONS.
5470 # Whether or not dependencies are handled. Can be further changed
5471 # in handle_options.
5472 $use_dependencies = $cmdline_use_dependencies;
5475 $local_maint_charset = $maint_charset;
5477 # All yacc and lex source filenames for this directory. Use
5478 # filenames instead of raw count so that multiple instances are
5479 # counted correctly (eg one yacc file can appear in multiple
5480 # programs without harm).
5484 # C++ source extensions we've seen.
5485 %cxx_extensions = ();
5487 # TRUE if we've seen any non-C++ sources. This actually holds a
5488 # line number or the name of a symbol corresponding to a line
5489 # number where the C sources were seen. If it is -1 then it means
5490 # we couldn't (easily) figure out which line of the Makefile.am
5491 # mentioned the sources.
5494 # TRUE if we've seen any sources at all.
5495 $seen_any_source = 0;
5497 # This is a list of all targets to run during "make dist".
5500 # Keys in this hash are the basenames of files which must depend
5502 %de_ansi_files = ();
5504 # This maps the source extension of a suffix rule to its
5505 # corresponding output extension.
5510 ################################################################
5512 # Return contents of a file from $am_dir, automatically skipping
5513 # macros or rules which are already known. Runs command on each line
5514 # as it is read; this command can modify $_.
5515 sub file_contents_with_transform
5517 local ($command, $basename) = @_;
5518 local ($file) = $am_dir . '/' . $basename . '.am';
5520 if ($command ne '' && substr ($command, -1) ne ';')
5522 die "automake: programming error in file_contents_with_transform\n";
5525 open (FC_FILE, $file)
5526 || die "automake: installation error: cannot open \`$file'\n";
5528 # print "automake: reading $file\n" if $verbose;
5530 local ($was_rule) = 0;
5531 local ($result_vars) = '';
5532 local ($result_rules) = '';
5533 local ($comment) = '';
5534 local ($spacing) = "\n";
5535 local ($skipping) = 0;
5540 $_ =~ s/\@MAINT\@//g
5541 unless $seen_maint_mode;
5543 $had_chars = length ($_) && $_ ne "\n";
5545 # If the transform caused all the characters to go away, then
5546 # ignore the line. Why do this? Because in Perl 4, a "next"
5547 # inside of an eval doesn't affect a loop outside the eval.
5548 # So we can't pass in a "transform" that uses next. We used
5549 # to do this. "Empty" also means consisting of a single
5551 next if $had_chars && ($_ eq '' || $_ eq "\n");
5553 if (/$IGNORE_PATTERN/o)
5555 # Merely delete comments beginning with two hashes.
5557 elsif (/$WHITE_PATTERN/o)
5559 # Stick a single white line before the incoming macro or rule.
5562 elsif (/$COMMENT_PATTERN/o)
5564 # Stick comments before the incoming macro or rule.
5565 $comment .= $spacing . $_;
5572 $result_rules .= $_ if ! $skipping;
5576 $result_vars .= $_ if ! $skipping;
5580 elsif (/$RULE_PATTERN/o)
5584 $skipping = defined $contents{$1};
5585 $result_rules .= $comment . $spacing . $_ if ! $skipping;
5586 $comment = $spacing = '';
5589 elsif (/$MACRO_PATTERN/o)
5591 # Found a variable reference.
5593 $skipping = defined $contents{$1};
5594 $result_vars .= $comment . $spacing . $_ if ! $skipping;
5595 $comment = $spacing = '';
5600 # This isn't an error; it is probably a continued rule.
5601 # In fact, this is what we assume.
5603 $result_rules .= $comment . $spacing . $_ if ! $skipping;
5604 $comment = $spacing = '';
5610 return $result_vars . $result_rules . $comment;
5613 # Like file_contents_with_transform, but no transform.
5616 return &file_contents_with_transform ('', @_);
5619 # Find all variable prefixes that are used for install directories. A
5620 # prefix `zar' qualifies iff:
5621 # * `zardir' is a variable.
5622 # * `zar_PRIMARY' is a variable.
5623 sub am_primary_prefixes
5625 local ($primary, @prefixes) = @_;
5627 local (%valid, $varname);
5628 grep ($valid{$_} = 0, @prefixes);
5629 $valid{'EXTRA'} = 0;
5630 foreach $varname (keys %contents)
5632 if ($varname =~ /^(.*)_$primary$/)
5634 if (! defined $valid{$1}
5635 && ! &variable_defined ($1 . 'dir')
5636 # Note that a configure variable is always legitimate.
5637 # It is natural to name such variables after the
5638 # primary, so we explicitly allow it.
5639 && ! defined $configure_vars{$varname})
5641 &am_line_error ($varname, "invalid variable \`$varname'");
5645 # Ensure all extended prefixes are actually used.
5654 # Handle `where_HOW' variable magic. Does all lookups, generates
5655 # install code, and possibly generates code to define the primary
5656 # variable. The first argument is the name of the .am file to munge,
5657 # the second argument is the primary variable (eg HEADERS), and all
5658 # subsequent arguments are possible installation locations. Returns
5659 # list of all values of all _HOW targets.
5661 # FIXME: this should be rewritten to be cleaner. It should be broken
5662 # up into multiple functions.
5664 # Usage is: am_install_var (OPTION..., file, HOW, where...)
5669 local ($do_clean) = 0;
5672 if (defined $configure_vars{'LIBTOOL'})
5674 # Transform '@LIBTOOL ...@' to '$(LIBTOOL) ...'
5675 $ltxform = 's/\@LIBTOOL([^\@]*)\@/\$(LIBTOOL) $1/;';
5679 # Delete '@LIBTOOL ...@'
5680 $ltxform = 's/\@LIBTOOL([^\@]*)\@//;';
5686 $cygxform = 's/\@EXEEXT\@//g;';
5690 $cygxform = 's/\@EXEEXT\@/\$(EXEEXT)/g;';
5695 if ($args[0] eq '-clean')
5699 elsif ($args[0] !~ /^-/)
5705 local ($file, $primary, @prefixes) = @args;
5708 local (@result) = ();
5710 # Now that configure substitutions are allowed in where_HOW
5711 # variables, it is an error to actually define the primary.
5712 &am_line_error ($primary, "\`$primary' is an anachronism")
5713 if &variable_defined ($primary);
5716 # Look for misspellings. It is an error to have a variable ending
5717 # in a "reserved" suffix whose prefix is unknown, eg
5718 # "bni_PROGRAMS". However, unusual prefixes are allowed if a
5719 # variable of the same name (with "dir" appended) exists. For
5720 # instance, if the variable "zardir" is defined, then
5721 # "zar_PROGRAMS" becomes valid. This is to provide a little extra
5722 # flexibility in those cases which need it. Perhaps it should be
5723 # disallowed in the Gnits case? The problem is, sometimes it is
5724 # useful to put things in a subdir of eg pkgdatadir, perhaps even
5726 local (%valid) = &am_primary_prefixes ($primary, @prefixes);
5728 # If a primary includes a configure substitution, then the EXTRA_
5729 # form is required. Otherwise we can't properly do our job.
5730 local ($require_extra);
5731 local ($warned_about_extra) = 0;
5733 local ($clean_file) = $file . '-clean';
5736 foreach $X (sort keys %valid)
5738 $one_name = $X . '_' . $primary;
5739 if (&variable_defined ($one_name))
5741 # Append actual contents of where_PRIMARY variable to
5744 foreach $rcurs (&variable_value_as_list ($one_name, 'all'))
5746 # Skip configure substitutions. Possibly bogus.
5747 if ($rcurs =~ /^\@.*\@$/)
5751 if (! $warned_about_extra)
5753 $warned_about_extra = 1;
5754 &am_line_error ($one_name,
5755 "\`$one_name' contains configure substitution, but shouldn't");
5758 # Check here to make sure variables defined in
5759 # configure.in do not imply that EXTRA_PRIMARY
5761 elsif (! defined $configure_vars{$one_name})
5763 $require_extra = $one_name;
5769 push (@result, $rcurs);
5772 # "EXTRA" shouldn't be used when generating clean targets,
5773 # all, or install targets.
5774 next if $X eq 'EXTRA';
5776 # A blatant hack: we rewrite each _PROGRAMS primary to
5777 # include EXEEXT when in Cygwin32 mode.
5778 if ($seen_exeext && $primary eq 'PROGRAMS')
5780 local (@conds) = &variable_conditions ($one_name);
5781 local (@one_binlist);
5783 # FIXME: this definitely loses aesthetically; it
5784 # redefines $ONE_NAME. Instead we should arrange for
5785 # variable definitions to be output later, instead of
5791 foreach $rcurs (&variable_value_as_list ($one_name, ''))
5793 if ($rcurs =~ /\./ || $rcurs =~ /^\@.*\@$/)
5795 push (@one_binlist, $rcurs);
5799 push (@one_binlist, $rcurs . '$(EXEEXT)');
5803 delete $contents{$one_name};
5804 &define_pretty_variable ($one_name, '', @one_binlist);
5809 local ($condvals) = '';
5810 foreach $cond (@conds)
5813 local (@condval) = &variable_value_as_list ($one_name,
5815 foreach $rcurs (@condval)
5817 if ($rcurs =~ /\./ || $rcurs =~ /^\@.*\@$/)
5819 push (@one_binlist, $rcurs);
5823 push (@one_binlist, $rcurs . '$(EXEEXT)');
5827 push (@condvals, $cond);
5828 push (@condvals, join (' ', @one_binlist));
5831 delete $contents{$one_name};
5835 $cond = shift (@condvals);
5836 local (@val) = split (' ', shift (@condvals));
5837 &define_pretty_variable ($one_name, $cond, @val);
5845 &file_contents_with_transform ('s/\@DIR\@/' . $X . '/go;'
5849 push (@clean, $X . $primary);
5850 &push_phony_cleaners ($X . $primary);
5855 push (@check, '$(' . $one_name . ')');
5859 push (@used, '$(' . $one_name . ')');
5861 if ($X eq 'noinst' || $X eq 'check')
5863 # Objects which don't get installed by default.
5868 &file_contents_with_transform ('s/\@DIR\@/' . $X . '/g;'
5869 . $ltxform . $cygxform,
5872 push (@uninstall, 'uninstall-' . $X . $primary);
5873 push (@phony, 'uninstall-' . $X . $primary);
5874 push (@installdirs, '$(' . $X . 'dir)');
5875 if (defined $exec_dir_p{$X} ? $exec_dir_p{$X} : ($X =~ /exec/))
5877 push (@install_exec, 'install-' . $X . $primary);
5878 push (@phony, 'install-' . $X . $primary);
5882 push (@install_data, 'install-' . $X . $primary);
5883 push (@phony, 'install-' . $X . $primary);
5891 &define_pretty_variable ($primary, '', @used);
5892 $output_vars .= "\n";
5895 if ($require_extra && ! &variable_defined ('EXTRA_' . $primary))
5897 &am_line_error ($require_extra,
5898 "\`$require_extra' contains configure substitution, but \`EXTRA_$primary' not defined");
5901 # Push here because PRIMARY might be configure time determined.
5902 push (@all, '$(' . $primary . ')')
5909 ################################################################
5911 # This variable is local to the "require file" set of functions.
5912 @require_file_paths = ();
5914 # Verify that the file must exist in the current directory. Usage:
5915 # require_file (isconfigure, line_number, strictness, file) strictness
5916 # is the strictness level at which this file becomes required. Must
5917 # set require_file_paths before calling this function.
5918 # require_file_paths is set to hold a single directory (the one in
5919 # which the first file was found) before return.
5920 sub require_file_internal
5922 local ($is_configure, $line, $mystrict, @files) = @_;
5923 local ($file, $fullfile);
5924 local ($found_it, $errfile, $errdir);
5927 foreach $file (@files)
5930 foreach $dir (@require_file_paths)
5934 $fullfile = $relative_dir . "/" . $file;
5935 $errdir = $relative_dir unless $errdir;
5939 $fullfile = $dir . "/" . $file;
5940 $errdir = $dir unless $errdir;
5943 # Use different name for "error filename". Otherwise on
5944 # an error the bad file will be reported as eg
5945 # `../../install-sh' when using the default
5947 $errfile = $errdir . '/' . $file;
5952 # FIXME: Once again, special-case `.'.
5953 &push_dist_common ($file)
5954 if $dir eq $relative_dir || $dir eq '.';
5962 # Prune the path list.
5963 @require_file_paths = $save_dir;
5967 if ($strictness >= $mystrict)
5969 local ($trailer) = '';
5970 local ($suppress) = 0;
5972 # Only install missing files according to our desired
5974 local ($message) = "required file \`$errfile' not found";
5979 # Maybe run libtoolize.
5981 && grep ($_ eq $file, @libtoolize_files)
5982 && system ('libtoolize', '--automake'))
5984 $message = "installing \`$errfile'";
5986 $trailer = "; cannot run \`libtoolize': $!";
5988 elsif (-f ($am_dir . '/' . $file))
5990 # Install the missing file. Symlink if we
5991 # can, copy if we must. Note: delete the file
5992 # first, in case it is a dangling symlink.
5993 $message = "installing \`$errfile'";
5995 if ($symlink_exists)
5997 if (! symlink ($am_dir . '/' . $file, $errfile))
6000 $trailer = "; error while making link: $!\n";
6003 elsif (! system ('cp', $am_dir . '/' . $file, $errfile))
6006 $trailer = "\n error while making link\n";
6011 local ($save) = $exit_status;
6014 # FIXME: allow actual file to be specified.
6015 &am_conf_line_error ('configure.in', $line,
6016 "$message$trailer");
6020 &am_line_error ($line, "$message$trailer");
6022 $exit_status = $save if $suppress;
6028 # Like require_file_with_line, but error messages refer to
6029 # configure.in, not the current Makefile.am.
6030 sub require_file_with_conf_line
6032 @require_file_paths = '.';
6033 &require_file_internal (1, @_);
6036 sub require_file_with_line
6038 @require_file_paths = '.';
6039 &require_file_internal (0, @_);
6044 @require_file_paths = '.';
6045 &require_file_internal (0, '', @_);
6048 # Require a file that is also required by Autoconf. Looks in
6049 # configuration path, as specified by AC_CONFIG_AUX_DIR.
6050 sub require_config_file
6052 @require_file_paths = @config_aux_path;
6053 &require_file_internal (1, '', @_);
6054 local ($dir) = $require_file_paths[0];
6055 @config_aux_path = @require_file_paths;
6058 $config_aux_dir = '.';
6062 $config_aux_dir = '$(top_srcdir)/' . $dir;
6066 # Assumes that the line number is in Makefile.am.
6067 sub require_conf_file_with_line
6069 @require_file_paths = @config_aux_path;
6070 &require_file_internal (0, @_);
6071 local ($dir) = $require_file_paths[0];
6072 @config_aux_path = @require_file_paths;
6075 $config_aux_dir = '.';
6079 $config_aux_dir = '$(top_srcdir)/' . $dir;
6083 # Assumes that the line number is in Makefile.am.
6084 sub require_conf_file_with_conf_line
6086 @require_file_paths = @config_aux_path;
6087 &require_file_internal (1, @_);
6088 local ($dir) = $require_file_paths[0];
6089 @config_aux_path = @require_file_paths;
6092 $config_aux_dir = '.';
6096 $config_aux_dir = '$(top_srcdir)/' . $dir;
6100 ################################################################
6102 # Push a list of files onto dist_common.
6103 sub push_dist_common
6105 local (@files) = @_;
6108 foreach $file (@files)
6110 $dist_common{$file} = 1;
6114 # Push a list of clean targets onto phony.
6115 sub push_phony_cleaners
6119 foreach $target ('mostly', 'dist', '', 'maintainer-')
6121 push (@phony, $target . 'clean-' . $base);
6128 $strictness_name = $_[0];
6129 if ($strictness_name eq 'gnu')
6133 elsif ($strictness_name eq 'gnits')
6135 $strictness = $GNITS;
6137 elsif ($strictness_name eq 'foreign')
6139 $strictness = $FOREIGN;
6143 die "automake: level \`$strictness_name' not recognized\n";
6148 ################################################################
6150 # Return directory name of file.
6156 ($sub = $file) =~ s,/+[^/]+$,,g;
6157 $sub = '.' if $sub eq $file;
6161 # Return file name of a file.
6167 ($sub = $file) =~s,^.*/+,,g;
6176 open (TOUCH, ">> $file");
6180 # Glob something. Do this to avoid indentation screwups everywhere we
6181 # want to glob. Gross!
6188 ################################################################
6190 # Print an error message and set exit status.
6193 warn "automake: ${am_file}.am: ", join (' ', @_), "\n";
6199 local ($symbol, @args) = @_;
6201 if ($symbol && "$symbol" ne '-1')
6203 # If SYMBOL not already a line number, look it up in Makefile.am.
6204 if ($symbol =~ /^\d+$/)
6208 elsif (defined $content_lines{$symbol})
6210 $symbol = $content_lines{$symbol} . ': ';
6214 # A single space, to provide nice separation.
6217 warn "${am_file}.am:", $symbol, join (' ', @args), "\n";
6226 # Like am_error, but while scanning configure.in.
6229 # FIXME: can run in subdirs.
6230 warn "automake: configure.in: ", join (' ', @_), "\n";
6234 # Error message with line number referring to configure.in.
6235 sub am_conf_line_error
6237 local ($file, $line, @args) = @_;
6241 warn "$file: $line: ", join (' ', @args), "\n";
6246 &am_conf_error (@args);
6250 # Tell user where our aclocal.m4 is, but only once.
6251 sub keyed_aclocal_warning
6254 warn "automake: macro \`$key' can be generated by \`aclocal'\n";
6257 # Print usage information.
6260 print "Usage: automake [OPTION] ... [Makefile]...\n\n";
6261 print "Generate Makefile.in for autoconf from Makefile.am\n";
6263 print "\nFiles which are automatically distributed, if found:\n";
6264 $~ = "USAGE_FORMAT";
6265 local (@lcomm) = sort ((@common_files, @common_sometimes));
6266 local ($one, $two, $three, $four);
6269 $one = shift @lcomm;
6270 $two = @lcomm ? shift @lcomm : '';
6271 $three = @lcomm ? shift @lcomm : '';
6272 $four = @lcomm ? shift @lcomm : '';
6276 print "\nReport bugs to <automake-bugs\@gnu.org>.\n";
6281 format USAGE_FORMAT =
6282 @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<
6283 $one, $two, $three, $four