5 eval 'exec @PERL@ -S $0 ${1+"$@"}'
8 # automake - create Makefile.in from Makefile.am
9 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999 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@";
38 $IGNORE_PATTERN = "^##([^#].*)?\$";
39 $WHITE_PATTERN = "^[ \t]*\$";
40 $COMMENT_PATTERN = "^#";
41 $RULE_PATTERN = "^([\$a-zA-Z_.][-.a-zA-Z0-9_(){}/\$]*) *:([^=].*|)\$";
42 $SUFFIX_RULE_PATTERN = "^\\.([a-zA-Z]+)\\.([a-zA-Z]+)\$";
43 $MACRO_PATTERN = "^([A-Za-z][A-Za-z0-9_]*)[ \t]*([:+]?)=[ \t]*(.*)\$";
44 $BOGUS_MACRO_PATTERN = "^([^ \t]*)[ \t]*([:+]?)=[ \t]*(.*)\$";
45 $GNITS_VERSION_PATTERN = "[0-9]+\\.[0-9]+([a-z]|\\.[0-9]+)?";
46 $IF_PATTERN = "^if[ \t]+\([A-Za-z][A-Za-z0-9_]*\)[ \t]*\(#.*\)?\$";
47 $ELSE_PATTERN = "^else[ \t]*\(#.*\)?\$";
48 $ENDIF_PATTERN = "^endif[ \t]*\(#.*\)?\$";
49 $PATH_PATTERN='(\\w|/|\\.)+';
50 # This will pass through anything not of the prescribed form.
51 $INCLUDE_PATTERN = "^include[ \t]+((\\\$\\\(top_srcdir\\\)/${PATH_PATTERN})|(\\\$\\\(srcdir\\\)/${PATH_PATTERN})|([^/\\\$]${PATH_PATTERN}))[ \t]*(#.*)?\$";
53 # Some regular expressions. One reason to put them here is that it
54 # makes indentation work better in Emacs.
55 $AC_CONFIG_AUX_DIR_PATTERN = "AC_CONFIG_AUX_DIR\\(([^)]+)\\)";
56 $AM_INIT_AUTOMAKE_PATTERN = "AM_INIT_AUTOMAKE\\([^,]*,([^,)]+)[,)]";
57 $AM_PACKAGE_VERSION_PATTERN = "^\\s*\\[?([^]\\s]+)\\]?\\s*\$";
58 # Note that there is no AC_PATH_TOOL. But we don't really care.
59 $AC_CHECK_PATTERN = "AC_(CHECK|PATH)_(PROG|PROGS|TOOL)\\(\\[?(\\w+)";
60 $AM_MISSING_PATTERN = "AM_MISSING_PROG\\(\\[?(\\w+)";
61 # Just check for alphanumeric in AC_SUBST. If you do AC_SUBST(5),
63 $AC_SUBST_PATTERN = "AC_SUBST\\(\\[?(\\w+)";
64 $AM_CONDITIONAL_PATTERN = "AM_CONDITIONAL\\((\\w+)";
66 # Constants to define the "strictness" level.
73 # Variables global to entire run.
75 # TRUE if we should always generate Makefile.in.
76 $force_generation = 1;
78 # Strictness level as set on command line.
79 $default_strictness = $GNU;
81 # Name of strictness level, as set on command line.
82 $default_strictness_name = 'gnu';
84 # This is TRUE if GNU make specific automatic dependency generation
85 # code should be included in generated Makefile.in.
86 $cmdline_use_dependencies = 1;
88 # This is the name of a dependency makefile bit (usually for inclusion in a
89 # SMakefile or similar); empty if not set.
92 # TRUE if in verbose mode.
95 # This holds our (eventual) exit status. We don't actually exit until
96 # we have processed all input files.
99 # From the Perl manual.
100 $symlink_exists = (eval 'symlink ("", "");', $@ eq '');
102 # TRUE if missing standard files should be installed.
105 # TRUE if we should copy missing files; otherwise symlink if possible.
108 # Files found by scanning configure.in for LIBOBJS.
111 # True if AM_C_PROTOTYPES appears in configure.in.
112 $am_c_prototypes = 0;
114 # Names used in AC_CONFIG_HEADER call. @config_fullnames holds the
115 # name which appears in AC_CONFIG_HEADER, colon and all.
116 # @config_names holds the file names. @config_headers holds the '.in'
117 # files. Ordinarily these are similar, but they can be different if
118 # the weird "NAME:FILE" syntax is used.
119 @config_fullnames = ();
121 @config_headers = ();
122 # Line number at which AC_CONFIG_HEADER appears in configure.in.
123 $config_header_line = 0;
125 # Directory where output files go. Actually, output files are
126 # relative to this directory.
127 $output_directory = '.';
129 # Relative location of top build directory.
132 # Absolute location of top build directory.
133 $build_directory = '';
135 # Name of srcdir as given in build directory's Makefile. For
139 # List of Makefile.am's to process, and their corresponding outputs.
143 # List of files in AC_OUTPUT without Makefile.am, and their outputs.
144 @other_input_files = ();
145 # Line number at which AC_OUTPUT seen.
148 # List of directories to search for configure-required files. This
149 # can be set by AC_CONFIG_AUX_DIR.
150 @config_aux_path = ('.', '..', '../..');
151 $config_aux_dir = '';
153 # Whether AC_PROG_MAKE_SET has been seen in configure.in.
156 # Whether AM_GNU_GETTEXT has been seen in configure.in.
158 # Line number at which AM_GNU_GETTEXT seen.
159 $ac_gettext_line = 0;
161 # Whether ALL_LINGUAS has been seen.
165 # Line number at which it appears.
166 $all_linguas_line = 0;
168 # 1 if AC_PROG_INSTALL seen.
169 $seen_prog_install = 0;
171 # Whether AC_PATH_XTRA has been seen in configure.in.
174 # TRUE if AC_DECL_YYTEXT was seen.
175 $seen_decl_yytext = 0;
177 # TRUE if we've seen AC_CANONICAL_(HOST|SYSTEM). The presence of
178 # AC_CHECK_TOOL also sets this.
181 # TRUE if we've seen AC_ARG_PROGRAM.
184 # TRUE if we've seen AC_PROG_LIBTOOL.
188 # Files installed by libtoolize.
189 @libtoolize_files = ('ltconfig', 'ltmain.sh', 'config.guess', 'config.sub');
191 # TRUE if we've seen AM_MAINTAINER_MODE.
192 $seen_maint_mode = 0;
194 # TRUE if we've seen PACKAGE and VERSION.
198 # Actual version we've seen.
199 $package_version = '';
201 # Line number where we saw version definition.
202 $package_version_line = 0;
204 # TRUE if we've seen AM_PATH_LISPDIR.
207 # TRUE if we've seen AC_EXEEXT.
210 # TRUE if we've seen AC_OBJEXT.
213 # TRUE if we've seen AC_ENABLE_MULTILIB.
216 # Hash table of discovered configure substitutions. Keys are names,
217 # values are `FILE:LINE' strings which are used by error message
219 %configure_vars = ();
221 # This is used to keep track of which variable definitions we are
222 # scanning. It is only used in certain limited ways, but it has to be
223 # global. It is declared just for documentation purposes.
226 # Charsets used by maintainer and in distribution. MAINT_CHARSET is
227 # handled in a funny way: if seen in the top-level Makefile.am, it is
228 # used for every directory which does not specify a different value.
229 # The rationale here is that some directories (eg gettext) might be
230 # distributions of other packages, and thus require their own charset
231 # info. However, the DIST_CHARSET must be the same for the entire
232 # package; it can only be set at top-level.
233 # FIXME: this yields bugs when rebuilding. What to do? Always
234 # read (and sometimes discard) top-level Makefile.am?
236 $dist_charset = 'utf8'; # recode doesn't support this yet.
238 # Name of input file ("Makefile.in") and output file ("Makefile.am").
239 # These have no directory components.
243 # TRUE if --cygnus seen.
246 # Keys of this hash are names of dependency files to ignore.
247 %omit_dependencies = ();
249 # Hash table of AM_CONDITIONAL variables seen in configure.
250 %configure_cond = ();
252 # Map from obsolete macros to hints for new macros.
253 # If you change this, change the corresponding list in aclocal.in.
254 # FIXME: should just put this into a single file.
257 'AC_FEATURE_CTYPE', "use \`AC_HEADER_STDC'",
258 'AC_FEATURE_ERRNO', "add \`strerror' to \`AC_REPLACE_FUNCS(...)'",
259 'AC_FEATURE_EXIT', '',
260 'AC_SYSTEM_HEADER', '',
262 # Note that we do not handle this one, because it is still run
263 # from AM_CONFIG_HEADER. So we deal with it specially in
265 # 'AC_CONFIG_HEADER', "use \`AM_CONFIG_HEADER'",
267 'fp_C_PROTOTYPES', "use \`AM_C_PROTOTYPES'",
268 'fp_PROG_CC_STDC', "use \`AM_PROG_CC_STDC'",
269 'fp_PROG_INSTALL', "use \`AC_PROG_INSTALL'",
270 'fp_WITH_DMALLOC', "use \`AM_WITH_DMALLOC'",
271 'fp_WITH_REGEX', "use \`AM_WITH_REGEX'",
272 'gm_PROG_LIBTOOL', "use \`AM_PROG_LIBTOOL'",
273 'jm_MAINTAINER_MODE', "use \`AM_MAINTAINER_MODE'",
274 'md_TYPE_PTRDIFF_T', "use \`AM_TYPE_PTRDIFF_T'",
275 'ud_PATH_LISPDIR', "use \`AM_PATH_LISPDIR'",
276 'ud_GNU_GETTEXT', "use \`AM_GNU_GETTEXT'",
278 # Now part of autoconf proper, under a different name.
279 'AM_FUNC_FNMATCH', "use \`AC_FUNC_FNMATCH'",
280 'fp_FUNC_FNMATCH', "use \`AC_FUNC_FNMATCH'",
281 'AM_SANITY_CHECK_CC', "automatically done by \`AC_PROG_CC'",
282 'AM_PROG_INSTALL', "use \`AC_PROG_INSTALL'",
283 'AM_EXEEXT', "use \`AC_EXEEXT'",
284 'AM_CYGWIN32', "use \`AC_CYGWIN32'",
285 'AM_MINGW32', "use \`AC_MINGW32'",
287 # These aren't quite obsolete.
291 # Regexp to match the above macros.
292 $obsolete_rx = '(' . join ('|', keys %obsolete_macros) . ')';
294 # This maps extensions onto language names.
297 # This maps languages names onto properties.
302 # Initialize global constants and our list of languages that are
303 # internally supported.
304 &initialize_global_constants;
306 ®ister_language ('c', '', 1,
308 ®ister_language ('cxx', 'CXXLINK', 0,
309 'c++', 'cc', 'cpp', 'cxx', 'C');
310 ®ister_language ('objc', 'OBJCLINK', 0,
312 ®ister_language ('header', '', 0,
313 'h', 'H', 'hxx', 'h++', 'hh', 'hpp', 'inc');
314 ®ister_language ('yacc', '', 1,
316 ®ister_language ('yaccxx', 'CXXLINK', 0,
317 'y++', 'yy', 'yxx', 'ypp');
318 ®ister_language ('lex', '', 1,
320 ®ister_language ('lexxx', 'CXXLINK', 0,
321 'l++', 'll', 'lxx', 'lpp');
322 ®ister_language ('asm', '', 0,
324 ®ister_language ('f77', 'F77LINK', 0,
326 ®ister_language ('ppf77', 'F77LINK', 0,
328 ®ister_language ('ratfor', 'F77LINK', 0,
332 # Parse command line.
333 &parse_arguments (@ARGV);
335 # Do configure.in scan only once.
338 die "automake: no \`Makefile.am' found or specified\n"
341 # If --generate-deps was given, we don't do anything else
345 die "automake: Must specify --include-deps (or -i) when generating\n"
346 if $use_dependencies;
347 die "automake: Must provide --build-dir when generating\n"
348 if ! $build_directory;
349 die "automake: Must provide --srcdir-name when generating\n"
352 open (GDEP, ">$output_directory/.dep_segment")
353 || die "automake: Could not open `$output_directory/.dep_segment': $!\n";
355 &handle_dependencies;
356 print GDEP $output_rules;
362 # Now do all the work on each file.
363 foreach $am_file (@input_files)
365 if (! -f ($am_file . '.am'))
367 &am_error ("\`" . $am_file . ".am' does not exist");
371 &generate_makefile ($output_files{$am_file}, $am_file);
375 &am_conf_error ("AC_PROG_INSTALL must be used in configure.in")
376 if (! $seen_prog_install);
381 ################################################################
383 # Parse command line.
386 local (@arglist) = @_;
389 &set_strictness ('gnu');
393 if ($arglist[0] eq "--version")
395 print "automake (GNU $PACKAGE) $VERSION\n\n";
396 print "Copyright (C) 1999 Free Software Foundation, Inc.\n";
397 print "This is free software; see the source for copying conditions. There is NO\n";
398 print "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n";
399 print "Written by Tom Tromey <tromey\@cygnus.com>\n";
403 elsif ($arglist[0] eq "--help")
407 elsif ($arglist[0] =~ /^--amdir=(.+)$/)
411 elsif ($arglist[0] eq '--amdir')
413 &require_argument (@arglist);
415 $am_dir = $arglist[0];
417 elsif ($arglist[0] =~ /^--build-dir=(.+)$/)
420 $build_directory = $1 . '/';
422 elsif ($arglist[0] eq '--build-dir')
424 &require_argument (@arglist);
427 $build_directory = $arglist[0] . '/';
429 elsif ($arglist[0] =~ /^--srcdir-name=(.+)$/)
433 elsif ($arglist[0] eq '--srcdir-name')
435 &require_argument (@arglist);
437 $srcdir_name = $arglist[0];
439 elsif ($arglist[0] eq '--gnu')
441 &set_strictness ('gnu');
443 elsif ($arglist[0] eq '--gnits')
445 &set_strictness ('gnits');
447 elsif ($arglist[0] eq '--cygnus')
451 elsif ($arglist[0] eq '--foreign')
453 &set_strictness ('foreign');
455 elsif ($arglist[0] eq '--include-deps' || $arglist[0] eq '-i')
457 $cmdline_use_dependencies = 0;
459 elsif ($arglist[0] eq '--generate-deps')
463 elsif ($arglist[0] eq '--no-force')
465 $force_generation = 0;
467 elsif ($arglist[0] =~ /^--output-dir=(.*)$/)
469 # Set output directory.
470 $output_directory = $1;
472 elsif ($arglist[0] eq '--output-dir' || $arglist[0] eq '-o')
474 &require_argument (@arglist);
476 $output_directory = $arglist[0];
478 elsif ($arglist[0] eq '--add-missing' || $arglist[0] eq '-a')
482 elsif ($arglist[0] eq '--copy' || $arglist[0] eq '-c')
486 elsif ($arglist[0] eq '--verbose' || $arglist[0] eq '-v')
490 elsif ($arglist[0] eq '--')
492 # Stop option processing.
494 push (@input_files, @arglist);
497 elsif ($arglist[0] =~ /^-/)
499 die "automake: unrecognized option -- \`$arglist[0]'\nTry \`automake --help' for more information.\n";
503 # Handle $local:$input syntax. Note that we only examine
504 # the first ":" file to see if it is automake input; the
505 # rest are just taken verbatim. We still keep all the
506 # files around for dependency checking, however.
507 local ($local, $input, @rest) = split (/:/, $arglist[0]);
514 # Strip .in; later on .am is tacked on. That is how
515 # the automake input file is found. Maybe not the
516 # best way, but it is easy to explain. FIXME: should
517 # be error if .in is missing.
520 push (@input_files, $input);
521 $output_files{$input} = join (':', ($local, @rest));
527 # Take global strictness from whatever we currently have set.
528 $default_strictness = $strictness;
529 $default_strictness_name = $strictness_name;
532 # Ensure argument exists, or die.
535 local ($arg, @arglist) = @_;
536 die "automake: no argument given for option \`$arg'\n"
540 ################################################################
542 # Generate a Makefile.in given the name of the corresponding Makefile and
543 # the name of the file output by config.status.
544 sub generate_makefile
546 local ($output, $makefile) = @_;
548 ($am_file_name = $makefile) =~ s/^.*\///;
549 $in_file_name = $am_file_name . '.in';
550 $am_file_name .= '.am';
552 # $OUTPUT is encoded. If it contains a ":" then the first element
553 # is the real output file, and all remaining elements are input
554 # files. We don't scan or otherwise deal with these input file,
555 # other than to mark them as dependencies. See scan_configure for
557 local (@secondary_inputs);
558 ($output, @secondary_inputs) = split (/:/, $output);
560 &initialize_per_input;
561 $relative_dir = &dirname ($output);
562 $am_relative_dir = &dirname ($makefile);
564 # At the toplevel directory, we might need config.guess, config.sub
565 # or libtool scripts (ltconfig and ltmain.sh).
566 if ($relative_dir eq '.')
568 # libtool requires some files.
569 &require_conf_file_with_conf_line ($libtool_line, $FOREIGN,
573 # AC_CANONICAL_HOST and AC_CANONICAL_SYSTEM need config.guess and
575 &require_config_file ($FOREIGN, 'config.guess', 'config.sub')
579 # We still need Makefile.in here, because sometimes the `dist'
580 # target doesn't re-run automake.
581 if ($am_relative_dir eq $relative_dir)
583 # Only distribute the files if they are in the same subdir as
584 # the generated makefile.
585 &push_dist_common ($in_file_name, $am_file_name);
587 push (@sources, '$(SOURCES)')
588 if &variable_defined ('SOURCES');
589 push (@objects, '$(OBJECTS)')
590 if &variable_defined ('OBJECTS');
592 &read_main_am_file ($makefile . '.am');
595 # Fatal error. Just return, so we can continue with next file.
599 # Check first, because we might modify some state.
601 &check_gnu_standards;
602 &check_gnits_standards;
604 &handle_configure ($output, $makefile, @secondary_inputs);
611 &handle_built_sources;
613 # This must be run after all the sources are scanned.
616 # Re-init SOURCES and OBJECTS. FIXME: other code shouldn't depend
617 # on this (but currently does).
618 $contents{'SOURCES'} = join (' ', @sources);
619 $contents{'OBJECTS'} = join (' ', @objects);
630 &handle_minor_options;
631 &handle_dist ($makefile);
632 &handle_dependencies;
635 &handle_merge_targets ($output);
642 if (! -d ($output_directory . '/' . $am_relative_dir))
644 mkdir ($output_directory . '/' . $am_relative_dir, 0755);
647 local ($out_file) = $output_directory . '/' . $makefile . ".in";
648 if (! $force_generation && -e $out_file)
650 local ($am_time) = (stat ($makefile . '.am'))[9];
651 local ($in_time) = (stat ($out_file))[9];
652 # FIXME: should cache these times.
653 local ($conf_time) = (stat ('configure.in'))[9];
654 # FIXME: how to do unsigned comparison?
655 if ($am_time < $in_time || $am_time < $conf_time)
662 local ($acl_time) = (stat _)[9];
663 return if ($am_time < $acl_time);
667 if (! open (GM_FILE, "> " . $out_file))
669 warn "automake: ${am_file}.in: cannot write: $!\n";
673 print "automake: creating ", $makefile, ".in\n" if $verbose;
675 print GM_FILE $output_vars;
676 # We make sure that `all:' is the first target.
677 print GM_FILE $output_all;
678 print GM_FILE $output_header;
679 print GM_FILE $output_rules;
680 print GM_FILE $output_trailer;
685 ################################################################
687 # Handle AUTOMAKE_OPTIONS variable. Return 1 on error, 0 otherwise.
690 if (&variable_defined ('AUTOMAKE_OPTIONS'))
692 foreach (&variable_value_as_list ('AUTOMAKE_OPTIONS', ''))
695 if ($_ eq 'gnits' || $_ eq 'gnu' || $_ eq 'foreign')
697 &set_strictness ($_);
699 elsif ($_ eq 'cygnus')
705 # An option like "../lib/ansi2knr" is allowed. With
706 # no path prefix, we assume the required programs are
707 # in this directory. We save the actual option for
709 $options{'ansi2knr'} = $_;
711 elsif ($_ eq 'no-installman' || $_ eq 'no-installinfo'
712 || $_ eq 'dist-shar' || $_ eq 'dist-zip'
713 || $_ eq 'dist-tarZ' || $_ eq 'dist-bzip2'
714 || $_ eq 'dejagnu' || $_ eq 'no-texinfo.tex'
715 || $_ eq 'readme-alpha' || $_ eq 'check-news')
717 # Explicitly recognize these.
719 elsif ($_ eq 'no-dependencies')
721 $use_dependencies = 0;
723 elsif (/([0-9]+)\.([0-9]+)([a-z])?/)
725 # Got a version number.
727 local ($rmajor, $rminor, $ralpha) = ($1, $2, $3);
729 if ($VERSION !~ /([0-9]+)\.([0-9]+)([a-z])?/)
732 "automake: programming error: version is incorrect\n";
735 local ($tmajor, $tminor, $talpha) = ($1, $2, $3);
737 # 2.0 is better than 1.0.
738 # 1.2 is better than 1.1.
739 # 1.2a is better than 1.2.
740 if ($rmajor > $tmajor
741 || ($rmajor == $tmajor && $rminor > $tminor)
742 || ($rminor == $tminor && $rminor == $tminor
743 && $ralpha gt $talpha))
745 &am_line_error ('AUTOMAKE_OPTIONS',
746 "require version $_, only have $VERSION");
752 &am_line_error ('AUTOMAKE_OPTIONS',
753 "option \`" . $_ . "\' not recognized");
758 if ($strictness == $GNITS)
760 $options{'readme-alpha'} = 1;
761 $options{'check-news'} = 1;
767 # Return object extension. Just once, put some code into the output.
768 # Argument is the name of the output file
769 sub get_object_extension
773 # Maybe require libtool library object files.
774 local ($extension) = '.o';
775 $extension = '.$(OBJEXT)' if $seen_objext;
776 $extension = '.lo' if ($out =~ /\.la$/);
778 if (! $included_generic_compile)
782 if (&variable_defined ('CONFIG_HEADER'))
785 foreach $one_hdr (split (' ', &variable_value ('CONFIG_HEADER')))
788 ($var = &dirname ($one_hdr)) =~ s/(\W)/\\$1/g;
789 $xform .= ' ' if $xform;
790 $xform .= '-I' . $var;
793 $xform = 's/\@CONFIG_INCLUDE_SPEC\@/' . $xform . '/go;';
794 $output_vars .= &file_contents_with_transform ($xform,
797 $xform = (($use_dependencies
798 ? 's/^NOTDEPEND.*$//;'
800 . ($seen_objext ? 's/^OBJEXT//;' : 's/^OBJEXT.*$//;'));
801 $output_rules .= &file_contents_with_transform ($xform, 'compile');
803 &push_phony_cleaners ('compile');
805 # If using X, include some extra variable definitions. NOTE
806 # we don't want to force these into CFLAGS or anything,
807 # because not all programs will necessarily use X.
811 foreach $var ('X_CFLAGS', 'X_LIBS', 'X_EXTRA_LIBS', 'X_PRE_LIBS')
813 &define_configure_variable ($var);
817 push (@suffixes, '.c', '.o', '.S', '.s');
818 push (@suffixes, '.obj') if $seen_objext;
819 push (@clean, 'compile');
821 $included_generic_compile = 1;
824 if ($seen_libtool && ! $included_libtool_compile)
826 # Output the libtool compilation rules.
828 &file_contents_with_transform
829 ($use_dependencies ? 's/^NOTDEPEND.*$//;' : 's/^NOTDEPEND//;',
832 &push_phony_cleaners ('libtool');
834 push (@suffixes, '.lo');
835 push (@clean, 'libtool');
837 $included_libtool_compile = 1;
840 # Check for automatic de-ANSI-fication.
841 if (defined $options{'ansi2knr'})
843 $extension = '$U' . $extension;
844 if (! $included_knr_compile)
846 if (! $am_c_prototypes)
848 &am_line_error ('AUTOMAKE_OPTIONS',
849 "option \`ansi2knr' in use but \`AM_C_PROTOTYPES' not in configure.in");
850 &keyed_aclocal_warning ('AM_C_PROTOTYPES');
851 # Only give this error once.
852 $am_c_prototypes = 1;
855 # Only require ansi2knr files if they should appear in
857 if ($options{'ansi2knr'} eq 'ansi2knr')
859 &require_file_with_line ('AUTOMAKE_OPTIONS', $FOREIGN,
860 'ansi2knr.c', 'ansi2knr.1');
861 $output_rules .= &file_contents ('kr-extra');
862 push (@clean, 'krextra');
863 &push_phony_cleaners ('krextra');
866 # Generate rules to build ansi2knr. If it is in some
867 # other directory, then generate dependencies but have the
868 # rule just run elsewhere.
869 $objext = $seen_objext ? ".$(OBJEXT)" : ".o";
870 $output_rules .= ($options{'ansi2knr'} . ': '
871 . $options{'ansi2knr'} . $objext . "\n");
872 if ($options{'ansi2knr'} eq 'ansi2knr')
874 $output_rules .= ("\t\$(LINK) ansi2knr" . $objext
876 . "ansi2knr" . $objext
877 . ": \$(CONFIG_HEADER)\n\n");
881 $output_rules .= ("\tcd " . &dirname ($options{'ansi2knr'})
882 . " && \$(MAKE) \$(AM_MAKEFLAGS) "
884 # This is required for non-GNU makes.
885 $output_rules .= ($options{'ansi2knr'} . $objext . ":\n");
886 $output_rules .= ("\tcd " . &dirname ($options{'ansi2knr'})
887 . " && \$(MAKE) \$(AM_MAKEFLAGS)"
888 . " ansi2knr" . $objext . "\n\n");
891 # Make sure ansi2knr can be found: if no path specified,
893 if ($options{'ansi2knr'} eq 'ansi2knr')
895 # Substitution from AM_C_PROTOTYPES. This makes it be
896 # built only when necessary.
897 &define_configure_variable ('ANSI2KNR');
898 # ansi2knr needs to be built before subdirs, so unshift it.
899 unshift (@all, '$(ANSI2KNR)');
903 # Found in another directory.
904 &define_variable ("ANSI2KNR", $options{'ansi2knr'});
907 $output_rules .= &file_contents ('clean-kr');
910 &push_phony_cleaners ('kr');
912 $included_knr_compile = 1;
919 # Call finish function for each language that was used.
922 local ($ext, $name, $lang, %done);
924 foreach $ext (sort keys %extension_seen)
926 $lang = $extension_map{$ext};
927 next if defined $done{$lang};
929 $non_c = 0 if $lang !~ /(objc|cxx|f77|ratfor)$/;
931 # Compute the function name of the finisher and then call it.
932 $name = 'lang_' . $lang . '_finish';
936 # If the project is entirely C++ or entirely Fortran 77, don't
937 # bother with the C stuff. But if anything else creeps in, then use
939 if (! $non_c || scalar keys %suffix_rules > 0)
941 local ($ltcompile, $ltlink) = &libtool_compiler;
943 &define_configure_variable ('CFLAGS');
944 &define_compiler_variable ('COMPILE', $ltcompile,
945 '$(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)');
946 &define_variable ('CCLD', '$(CC)');
947 &define_variable ('LINK', $ltlink . '$(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@');
951 # Output a rule to build from a YACC source. The output from YACC is
952 # compiled with C or C++, depending on the extension of the YACC file.
953 sub output_yacc_build_rule
955 local ($yacc_suffix, $use_ylwrap, $c_suffix) = @_;
958 ($suffix = $yacc_suffix) =~ tr/y/c/;
959 push (@suffixes, $yacc_suffix, $suffix);
961 # Generate rule for c/c++.
962 $output_rules .= "$yacc_suffix$suffix:\n\t";
966 $output_rules .= ('$(SHELL) $(YLWRAP)'
967 . ' "$(YACC)" $< y.tab.c $*' . $suffix
968 . ' y.tab.h $*.h -- $(AM_YFLAGS) $(YFLAGS)');
972 $output_rules .= ('$(YACC) $(AM_YFLAGS) $(YFLAGS) $< && mv y.tab.c $*'
974 . "\tif test -f y.tab.h; then \\\n"
975 . "\tif cmp -s y.tab.h \$*.h; then rm -f y.tab.h; else mv y.tab.h \$*.h; fi; \\\n"
978 $output_rules .= "\n";
981 sub output_lex_build_rule
983 local ($lex_suffix, $use_ylwrap) = @_;
986 ($c_suffix = $lex_suffix) =~ tr/l/c/;
987 push (@suffixes, $lex_suffix);
988 &define_configure_variable ('LEX_OUTPUT_ROOT');
989 &define_configure_variable ('LEXLIB');
990 $output_rules .= "$lex_suffix$c_suffix:\n\t";
994 # Is the $@ correct here? If so, why not use it in the ylwrap
995 # build rule for yacc above?
996 $output_rules .= '$(SHELL) $(YLWRAP)'
997 . ' "$(LEX)" $< $(LEX_OUTPUT_ROOT).c $@ -- $(AM_LFLAGS) $(LFLAGS)';
1001 $output_rules .= '$(LEX) $(AM_LFLAGS) $(LFLAGS) $< && mv $(LEX_OUTPUT_ROOT).c $@';
1003 $output_rules .= "\n";
1007 # Check to make sure a source defined in LIBOBJS is not explicitly
1008 # mentioned. This is a separate function (as opposed to being inlined
1009 # in handle_source_transform) because it isn't always appropriate to
1011 sub check_libobjs_sources
1013 local ($one_file, $unxformed) = @_;
1015 local ($prefix, $file, @files);
1016 foreach $prefix ('', 'EXTRA_')
1018 if (&variable_defined ($prefix . $one_file . '_SOURCES'))
1020 @files = &variable_value_as_list (($prefix
1021 . $one_file . '_SOURCES'),
1024 elsif ($prefix eq '')
1026 @files = ($unxformed . '.c');
1033 foreach $file (@files)
1035 if (defined $libsources{$file})
1037 &am_line_error ($prefix . $one_file . '_SOURCES',
1038 "automatically discovered file \`$file' should not be explicitly mentioned");
1044 # Does much of the actual work for handle_source_transform.
1046 # object extension (e.g., `$U.lo')
1047 # list of source files to transform
1049 # first element is name of linker to use (empty string for default linker)
1050 # remaining elements are names of objects
1051 sub handle_single_transform_list
1053 local ($obj, @files) = @_;
1054 local (@result) = ();
1055 local ($nonansi_obj) = $obj;
1056 $nonansi_obj =~ s/_//g;
1057 local (%linkers_used) = ();
1060 # Turn sources into objects.
1063 # Skip things that look like configure substitutions.
1066 # If the source file is in a subdirectory then the `.o' is
1067 # put into the current directory.
1069 # Split file name into base and extension.
1070 local ($full, $directory, $base, $extension, $linker, $object);
1071 next if ! /^((.*)\/)?([^\/]*)\.(.*)$/;
1077 local ($lang) = $extension_map{$extension};
1080 &saw_extension ($extension);
1081 # Found the language, so see what it says.
1082 local ($subr) = 'lang_' . $lang . '_rewrite';
1083 # Note: computed subr call.
1084 local ($r) = & $subr ($base, $extension);
1085 # Skip this entry if we were asked not to process it.
1088 # Now extract linker and other info.
1089 $linker = $language_map{$lang . '-linker'};
1091 if ($language_map{$lang . '-ansi-p'})
1093 $object = $base . $obj;
1097 $object = $base . $nonansi_obj;
1100 elsif ($extension =~ /^$source_suffix_pattern$/)
1102 # We just rewrite it. Maybe we should do more.
1103 $object = $base . '.' . $suffix_rules{$extension};
1108 # No error message here. Used to have one, but it was
1113 $linkers_used{$linker} = 1;
1115 push (@result, $object);
1117 if (defined $object_map{$object})
1119 if ($object_map{$object} ne $full)
1121 &am_error ("object \`$object' created by \`$full' and \`$object_map{$object}'");
1126 $object_map{$object} = $full;
1127 if ($directory ne '')
1129 # If file is in subdirectory, we need explicit dependency.
1130 &pretty_print_rule ($object . ':', "\t", $full);
1134 # Transform .o or $o file into .P file (for automatic
1136 $dep_files{'.deps/' . $base . '.P'} = 1;
1140 return (&resolve_linker (%linkers_used), @result);
1143 # Handle SOURCE->OBJECT transform for one program or library.
1145 # canonical (transformed) name of object to build
1146 # actual name of object to build
1147 # object extension (ie either `.o' or `$o'.
1148 # Return result is name of linker variable that must be used.
1149 # Empty return means just use `LINK'.
1150 sub handle_source_transform
1152 # one_file is canonical name. unxformed is given name. obj is
1154 local ($one_file, $unxformed, $obj) = @_;
1156 local ($linker) = '';
1158 if (&variable_defined ($one_file . "_OBJECTS"))
1160 &am_line_error ($one_file . '_OBJECTS',
1161 $one_file . '_OBJECTS', 'should not be defined');
1162 # No point in continuing.
1166 local (@files, @result, $prefix, $temp);
1167 foreach $prefix ('', 'EXTRA_')
1170 local ($var) = $prefix . $one_file . "_SOURCES";
1171 if (&variable_defined ($var))
1173 push (@sources, '$(' . $prefix . $one_file . "_SOURCES)");
1174 push (@objects, '$(' . $prefix . $one_file . "_OBJECTS)")
1175 unless $prefix eq 'EXTRA_';
1176 local (@conds) = &variable_conditions ($var);
1179 @files = &variable_value_as_list ($var, '');
1184 foreach $cond (@conds)
1186 @files = &variable_value_as_list ($var, $cond);
1187 ($temp, @result) = &handle_single_transform_list ($obj,
1189 $linker = $temp if $linker eq '';
1191 # Define _OBJECTS conditionally.
1192 &define_pretty_variable ($one_file . '_OBJECTS', $cond,
1194 unless $prefix eq 'EXTRA_';
1200 elsif ($prefix eq '')
1202 &define_variable ($one_file . "_SOURCES", $unxformed . ".c");
1203 push (@sources, $unxformed . '.c');
1204 push (@objects, $unxformed . $obj);
1205 push (@files, $unxformed . '.c');
1208 ($temp, @result) = &handle_single_transform_list ($obj, @files);
1209 $linker = $temp if $linker eq '';
1210 &define_pretty_variable ($one_file . "_OBJECTS", '', @result)
1211 unless $prefix eq 'EXTRA_';
1217 # Handle the BUILT_SOURCES variable.
1218 sub handle_built_sources
1220 return unless &variable_defined ('BUILT_SOURCES');
1222 local (@sources) = &variable_value_as_list ('BUILT_SOURCES', 'all');
1224 foreach $s (@sources)
1228 # FIXME: is this really the right thing to do?
1229 &am_line_error ('BUILT_SOURCES',
1230 "\`BUILT_SOURCES' should not contain a configure substitution");
1235 # We don't care about the return value of this function. We just
1236 # want to make sure to update %dep_files with the contents of
1238 &handle_single_transform_list (".o", @sources);
1241 # Special-case @ALLOCA@ and @LIBOBJS@ in _LDADD or _LIBADD variables.
1242 # Also, generate _DEPENDENCIES variable if appropriate.
1244 # transformed name of object being built, or empty string if no object
1245 # name of _LDADD/_LIBADD-type variable to examine
1246 # boolean (lex_seen) which is true if a lex source file was seen in this
1247 # object. valid only for LDADDs, not LIBADDs.
1248 # Returns 1 if LIBOBJS seen, 0 otherwise.
1249 sub handle_lib_objects
1251 local ($xname, $var, $lex_seen) = @_;
1254 die "automake: programming error 1 in handle_lib_objects\n"
1255 if ! &variable_defined ($var);
1257 die "automake: programming error 2 in handle_lib_objects\n"
1258 if $lex_seen && $var =~ /LIBADD/;
1260 local (@conds) = &variable_conditions ($var);
1263 $ret = &handle_lib_objects_cond ($xname, $var, $lex_seen, '');
1269 foreach $cond (@conds)
1271 if (&handle_lib_objects_cond ($xname, $var, $lex_seen, $cond))
1281 # Subroutine of handle_lib_objects: handle a particular condition.
1282 sub handle_lib_objects_cond
1284 local ($xname, $var, $lex_seen, $cond) = @_;
1286 # We recognize certain things that are commonly put in LIBADD or
1289 local (@dep_list) = ();
1291 local ($seen_libobjs) = 0;
1292 local ($flagvar) = 0;
1294 foreach $lsearch (&variable_value_as_list ($var, $cond))
1296 # Skip -lfoo and -Ldir; these are explicitly allowed.
1297 next if $lsearch =~ /^-[lL]/;
1298 if (! $flagvar && $lsearch =~ /^-/)
1300 if ($var =~ /^(.*)LDADD$/)
1302 # Skip -dlopen and -dlpreopen; these are explicitly allowed.
1303 next if $lsearch =~ /^-dl(pre)?open$/;
1304 &am_line_error ($var, "linker flags such as \`$lsearch' belong in \`${1}LDFLAGS");
1308 # Only get this error once.
1310 &am_line_error ($var, "you cannot use linker flags such as \`$lsearch' in \`$var'");
1314 # Assume we have a file of some sort, and push it onto the
1315 # dependency list. Autoconf substitutions are not pushed;
1316 # rarely is a new dependency substituted into (eg) foo_LDADD
1317 # -- but "bad things (eg -lX11) are routinely substituted.
1318 # Note that LIBOBJS and ALLOCA are exceptions to this rule,
1319 # and handled specially below.
1320 push (@dep_list, $lsearch)
1321 unless $lsearch =~ /^\@.*\@$/;
1323 # Automatically handle @LIBOBJS@ and @ALLOCA@. Basically this
1324 # means adding entries to dep_files.
1325 if ($lsearch =~ /^\@(LT)?LIBOBJS\@$/)
1327 push (@dep_list, $lsearch);
1329 if (! keys %libsources)
1331 &am_line_error ($var, "\@$1" . "LIBOBJS\@ seen but never set in \`configure.in'");
1334 local ($iter, $rewrite);
1335 foreach $iter (keys %libsources)
1337 if ($iter =~ /\.([cly])$/)
1339 &saw_extension ($1);
1340 &saw_extension ('c');
1343 if ($iter =~ /\.h$/)
1345 &require_file_with_line ($var, $FOREIGN, $iter);
1347 elsif ($iter ne 'alloca.c')
1349 ($rewrite = $iter) =~ s/\.c$/.P/;
1350 $dep_files{'.deps/' . $rewrite} = 1;
1351 &require_file_with_line ($var, $FOREIGN, $iter);
1355 elsif ($lsearch =~ /^\@(LT)?ALLOCA\@$/)
1357 push (@dep_list, $lsearch);
1358 &am_line_error ($var,
1359 "\@$1" . "ALLOCA\@ seen but \`AC_FUNC_ALLOCA' not in \`configure.in'")
1360 if ! defined $libsources{'alloca.c'};
1361 $dep_files{'.deps/alloca.P'} = 1;
1362 &require_file_with_line ($var, $FOREIGN, 'alloca.c');
1363 &saw_extension ('c');
1367 if ($xname ne '' && ! &variable_defined ($xname . '_DEPENDENCIES', $cond))
1369 &define_pretty_variable ($xname . '_DEPENDENCIES', $cond, @dep_list);
1372 return $seen_libobjs;
1375 # Canonicalize a name, and check to make sure the non-canonical name
1376 # is never used. Returns canonical name. Arguments are name and a
1377 # list of suffixes to check for.
1378 sub check_canonical_spelling
1380 local ($name, @suffixes) = @_;
1381 local ($xname, $xt);
1383 ($xname = $name) =~ tr/A-Za-z0-9_/_/c;
1384 if ($xname ne $name)
1387 foreach $xt (@suffixes)
1389 &am_line_error ($name . $xt,
1390 "invalid variable \`" . $name . $xt
1391 . "'; should be \`" . $xname . $xt . "'")
1392 if &variable_defined ($name . $xt);
1399 # Handle C programs.
1402 local (@proglist) = &am_install_var ('-clean',
1403 'progs', 'PROGRAMS',
1404 'bin', 'sbin', 'libexec', 'pkglib',
1406 return if ! @proglist;
1408 # If a program is installed, this is required. We only want this
1409 # error to appear once.
1410 &am_conf_error ("AC_ARG_PROGRAM must be used in configure.in")
1411 unless $seen_arg_prog;
1414 local ($one_file, $xname, $munge);
1416 local ($seen_libobjs) = 0;
1417 foreach $one_file (@proglist)
1419 local ($obj) = &get_object_extension ($one_file);
1421 # Canonicalize names and check for misspellings.
1422 $xname = &check_canonical_spelling ($one_file, '_LDADD', '_LDFLAGS',
1423 '_SOURCES', '_OBJECTS',
1426 # FIXME: Using a trick to figure out if any lex sources appear
1427 # in our program; should use some cleaner method.
1428 local ($lex_num) = scalar (keys %lex_sources);
1429 local ($linker) = &handle_source_transform ($xname, $one_file, $obj);
1430 local ($lex_file_seen) = (scalar (keys %lex_sources) > $lex_num);
1433 if (&variable_defined ($xname . "_LDADD"))
1435 if (&handle_lib_objects ($xname, $xname . '_LDADD',
1445 # User didn't define prog_LDADD override. So do it.
1446 &define_variable ($xname . '_LDADD', '$(LDADD)');
1448 # This does a bit too much work. But we need it to
1449 # generate _DEPENDENCIES when appropriate.
1450 if (&variable_defined ('LDADD'))
1452 if (&handle_lib_objects ($xname, 'LDADD', $lex_file_seen))
1458 elsif (! &variable_defined ($xname . '_DEPENDENCIES'))
1460 &define_variable ($xname . '_DEPENDENCIES', '');
1465 if (&variable_defined ($xname . '_LIBADD'))
1467 &am_line_error ($xname . '_LIBADD',
1468 "use \`" . $xname . "_LDADD', not \`"
1469 . $xname . "_LIBADD'");
1472 if (! &variable_defined ($xname . '_LDFLAGS'))
1474 # Define the prog_LDFLAGS variable.
1475 &define_variable ($xname . '_LDFLAGS', '');
1478 # Determine program to use for link.
1480 if (&variable_defined ($xname . '_LINK'))
1482 $xlink = $xname . '_LINK';
1486 $xlink = $linker ? $linker : 'LINK';
1490 if ($seen_exeext && $one_file !~ /\./)
1492 $xexe = 's/\@EXEEXT\@/\$(EXEEXT)/g;';
1496 $xexe = 's/\@EXEEXT\@//g;';
1500 &file_contents_with_transform
1501 ('s/\@PROGRAM\@/' . $one_file . '/go;'
1502 . 's/\@XPROGRAM\@/' . $xname . '/go;'
1503 . 's/\@XLINK\@/' . $xlink . '/go;'
1508 if (&variable_defined ('LDADD') && &handle_lib_objects ('', 'LDADD', 0))
1515 foreach $one_file (@proglist)
1517 # Canonicalize names.
1518 ($xname = $one_file) =~ tr/A-Za-z0-9_/_/c;
1520 if (&variable_defined ($xname . '_LDADD'))
1522 &check_libobjs_sources ($xname, $xname . '_LDADD');
1524 elsif (&variable_defined ('LDADD'))
1526 &check_libobjs_sources ($xname, 'LDADD');
1534 sub handle_libraries
1536 local (@liblist) = &am_install_var ('-clean',
1537 'libs', 'LIBRARIES',
1538 'lib', 'pkglib', 'noinst', 'check');
1539 return if ! @liblist;
1541 local (%valid) = &am_primary_prefixes ('LIBRARIES', 0, 'lib', 'pkglib',
1543 if (! defined $configure_vars{'RANLIB'})
1546 foreach $key (keys %valid)
1548 if (&variable_defined ($key . '_LIBRARIES'))
1550 &am_line_error ($key . '_LIBRARIES', "library used but \`RANLIB' not defined in \`configure.in'");
1551 # Only get this error once. If this is ever printed,
1553 $configure_vars{'RANLIB'} = 'BUG';
1562 local ($seen_libobjs) = 0;
1563 foreach $onelib (@liblist)
1565 # Check that the library fits the standard naming convention.
1566 if ($onelib !~ /^lib.*\.a$/)
1568 # FIXME should put line number here. That means mapping
1569 # from library name back to variable name.
1570 &am_error ("\`$onelib' is not a standard library name");
1573 local ($obj) = &get_object_extension ($onelib);
1575 # Canonicalize names and check for misspellings.
1576 $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_SOURCES',
1577 '_OBJECTS', '_DEPENDENCIES');
1579 if (&variable_defined ($xlib . '_LIBADD'))
1581 if (&handle_lib_objects ($xlib, $xlib . '_LIBADD', 0))
1588 # Generate support for conditional object inclusion in
1590 &define_variable ($xlib . "_LIBADD", '');
1593 if (&variable_defined ($xlib . '_LDADD'))
1595 &am_line_error ($xlib . '_LDADD',
1596 "use \`" . $xlib . "_LIBADD', not \`"
1597 . $xlib . "_LDADD'");
1600 # Make sure we at look at this.
1601 &examine_variable ($xlib . '_DEPENDENCIES');
1603 &handle_source_transform ($xlib, $onelib, $obj);
1606 &file_contents_with_transform ('s/\@LIBRARY\@/' . $onelib . '/go;'
1614 foreach $onelib (@liblist)
1616 # Canonicalize names.
1617 ($xlib = $onelib) =~ tr/A-Za-z0-9_/_/c;
1618 if (&variable_defined ($xlib . '_LIBADD'))
1620 &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
1625 &define_variable ('AR', 'ar');
1626 &define_configure_variable ('RANLIB');
1629 # Handle shared libraries.
1630 sub handle_ltlibraries
1632 local (@liblist) = &am_install_var ('-clean',
1633 'ltlib', 'LTLIBRARIES',
1634 'noinst', 'lib', 'pkglib');
1635 return if ! @liblist;
1638 local (%valid) = &am_primary_prefixes ('LTLIBRARIES', 0, 'lib', 'pkglib',
1642 foreach $key (keys %valid)
1644 if (&variable_defined ($key . '_LTLIBRARIES'))
1648 &am_line_error ($key . '_LTLIBRARIES', "library used but \`LIBTOOL' not defined in \`configure.in'");
1649 # Only get this error once. If this is ever printed,
1651 $configure_vars{'LIBTOOL'} = 'BUG';
1655 # Get the installation directory of each library.
1656 for (&variable_value_as_list ($key . '_LTLIBRARIES', 'all'))
1660 &am_error ("\`$_' is already going to be installed in \`$instdirs{$_}'");
1664 $instdirs{$_} = $key;
1673 local ($seen_libobjs) = 0;
1674 foreach $onelib (@liblist)
1676 local ($obj) = &get_object_extension ($onelib);
1678 # Canonicalize names and check for misspellings.
1679 $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_LDFLAGS',
1680 '_SOURCES', '_OBJECTS',
1683 if (! &variable_defined ($xlib . '_LDFLAGS'))
1685 # Define the lib_LDFLAGS variable.
1686 &define_variable ($xlib . '_LDFLAGS', '');
1689 # Check that the library fits the standard naming convention.
1690 $libname_rx = "^lib.*\.la";
1691 if (&variable_value ($xlib . '_LDFLAGS') =~ /-module/)
1693 # Relax name checking for libtool modules.
1694 $libname_rx = "\.la";
1696 if ($onelib !~ /$libname_rx$/)
1698 # FIXME this should only be a warning for foreign packages
1699 # FIXME should put line number here. That means mapping
1700 # from library name back to variable name.
1701 &am_error ("\`$onelib' is not a standard libtool library name");
1704 if (&variable_defined ($xlib . '_LIBADD'))
1706 if (&handle_lib_objects ($xlib, $xlib . '_LIBADD', 0))
1713 # Generate support for conditional object inclusion in
1715 &define_variable ($xlib . "_LIBADD", '');
1718 if (&variable_defined ($xlib . '_LDADD'))
1720 &am_line_error ($xlib . '_LDADD',
1721 "use \`" . $xlib . "_LIBADD', not \`"
1722 . $xlib . "_LDADD'");
1725 # Make sure we at look at this.
1726 &examine_variable ($xlib . '_DEPENDENCIES');
1728 local ($linker) = &handle_source_transform ($xlib, $onelib, $obj);
1730 # Determine program to use for link.
1732 if (&variable_defined ($xlib . '_LINK'))
1734 $xlink = $xlib . '_LINK';
1738 $xlink = $linker ? $linker : 'LINK';
1742 if ($instdirs{$onelib} eq 'EXTRA' || $instdirs{$onelib} eq 'noinst')
1744 # It's an EXTRA_ library, so we can't specify -rpath,
1745 # because we don't know where the library will end up.
1746 # The user probably knows, but generally speaking automake
1747 # doesn't -- and in fact configure could decide
1748 # dynamically between two different locations.
1749 $rpath = 's/\@RPATH\@//go;';
1753 $rpath = ('s/\@RPATH\@/-rpath \$(' . $instdirs{$onelib}
1758 &file_contents_with_transform ('s/\@LTLIBRARY\@/'
1760 . 's/\@XLTLIBRARY\@/'
1763 . 's/\@XLINK\@/' . $xlink . '/go;',
1769 foreach $onelib (@liblist)
1771 # Canonicalize names.
1772 ($xlib = $onelib) =~ tr/A-Za-z0-9_/_/c;
1773 if (&variable_defined ($xlib . '_LIBADD'))
1775 &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
1781 # See if any _SOURCES variable were misspelled. Also, make sure that
1782 # EXTRA_ variables don't contain configure substitutions.
1785 local ($varname, $primary);
1786 foreach $varname (keys %contents)
1788 foreach $primary ('_SOURCES', '_LIBADD', '_LDADD', '_LDFLAGS',
1791 if ($varname =~ /$primary$/ && ! $content_seen{$varname})
1793 &am_line_error ($varname,
1794 "invalid unused variable name: \`$varname'");
1803 # NOTE we no longer automatically clean SCRIPTS, because it is
1804 # useful to sometimes distribute scripts verbatim. This happens
1805 # eg in Automake itself.
1806 &am_install_var ('-candist', 'scripts', 'SCRIPTS',
1807 'bin', 'sbin', 'libexec', 'pkgdata',
1810 local ($scripts_installed) = 0;
1811 # Set $scripts_installed if appropriate. Make sure we only find
1812 # scripts which are actually installed -- this is why we can't
1813 # simply use the return value of am_install_var.
1814 local (%valid) = &am_primary_prefixes ('SCRIPTS', 1, 'bin', 'sbin',
1815 'libexec', 'pkgdata',
1818 foreach $key (keys %valid)
1820 if ($key ne 'noinst'
1822 && &variable_defined ($key . '_SCRIPTS'))
1824 $scripts_installed = 1;
1825 # push (@check_tests, 'check-' . $key . 'SCRIPTS');
1829 if ($scripts_installed)
1831 # If a program is installed, this is required. We only want this
1832 # error to appear once.
1833 &am_conf_error ("AC_ARG_PROGRAM must be used in configure.in")
1834 unless $seen_arg_prog;
1839 # Search a file for a "version.texi" Texinfo include. Return the name
1840 # of the include file if found, or the empty string if not. A
1841 # "version.texi" file is actually any file whose name matches
1843 sub scan_texinfo_file
1845 local ($filename) = @_;
1847 if (! open (TEXI, $filename))
1849 &am_error ("couldn't open \`$filename': $!");
1852 print "automake: reading $filename\n" if $verbose;
1854 local ($vfile, $outfile);
1857 if (/^\@setfilename +(\S+)/)
1863 if (/^\@include\s+(vers[^.]*\.texi)\s*$/)
1865 # Found version.texi include.
1872 return ($outfile, $vfile);
1875 # Handle all Texinfo source.
1878 &am_line_error ('TEXINFOS',
1879 "\`TEXINFOS' is an anachronism; use \`info_TEXINFOS'")
1880 if &variable_defined ('TEXINFOS');
1881 return if (! &variable_defined ('info_TEXINFOS')
1882 && ! &variable_defined ('html_TEXINFOS'));
1884 if (&variable_defined ('html_TEXINFOS'))
1886 &am_line_error ('html_TEXINFOS',
1887 "HTML generation not yet supported");
1891 local (@texis) = &variable_value_as_list ('info_TEXINFOS', 'all');
1893 local (@info_deps_list, @dvis_list, @texi_deps);
1894 local ($infobase, $info_cursor);
1898 local ($tc_cursor, @texi_cleans);
1901 foreach $info_cursor (@texis)
1903 # FIXME: This is mildly hacky, since it recognizes "txinfo".
1904 # I don't feel like making it right.
1905 ($infobase = $info_cursor) =~ s/\.te?xi(nfo)?$//;
1907 # If 'version.texi' is referenced by input file, then include
1908 # automatic versioning capability.
1909 local ($out_file, $vtexi) = &scan_texinfo_file ($relative_dir
1910 . "/" . $info_cursor);
1912 if ($out_file eq '')
1914 &am_error ("\`$info_cursor' missing \@setfilename");
1918 if ($out_file =~ /\.(.+)$/ && $1 ne 'info')
1920 # FIXME should report line number in input file.
1921 &am_error ("output of \`$info_cursor', \`$out_file', has unrecognized extension");
1927 &am_error ("\`$vtexi', included in \`$info_cursor', also included in \`$versions{$vtexi}'")
1928 if (defined $versions{$vtexi});
1929 $versions{$vtexi} = $info_cursor;
1931 # We number the stamp-vti files. This is doable since the
1932 # actual names don't matter much. We only number starting
1933 # with the second one, so that the common case looks nice.
1934 $vti = 'vti' . ($done ? $done : '');
1935 &push_dist_common ($vtexi, 'stamp-' . $vti);
1936 push (@clean, $vti);
1938 # Only require once.
1939 &require_conf_file_with_line ('info_TEXINFOS', $FOREIGN,
1944 local ($conf_pat, $conf_dir);
1945 if ($config_aux_dir eq '.' || $config_aux_dir eq '')
1947 $conf_dir = '$(srcdir)/';
1951 $conf_dir = $config_aux_dir;
1952 $conf_dir .= '/' unless $conf_dir =~ /\/$/;
1954 ($conf_pat = $conf_dir) =~ s/(\W)/\\$1/g;
1956 &file_contents_with_transform
1957 ('s/\@TEXI\@/' . $info_cursor . '/g; '
1958 . 's/\@VTI\@/' . $vti . '/g; '
1959 . 's/\@VTEXI\@/' . $vtexi . '/g;'
1960 . 's,\@MDDIR\@,' . $conf_pat . ',g;',
1963 &push_phony_cleaners ($vti);
1966 # If user specified file_TEXINFOS, then use that as explicit
1969 push (@texi_deps, $info_cursor);
1970 push (@texi_deps, $vtexi) if $vtexi;
1972 # Canonicalize name first.
1973 ($canonical = $infobase) =~ tr/A-Za-z0-9_/_/c;
1974 if (&variable_defined ($canonical . "_TEXINFOS"))
1976 push (@texi_deps, '$(' . $canonical . '_TEXINFOS)');
1977 &push_dist_common ('$(' . $canonical . '_TEXINFOS)');
1980 $output_rules .= ("\n" . $out_file . ": "
1981 . join (' ', @texi_deps)
1982 . "\n" . $infobase . ".dvi: "
1983 . join (' ', @texi_deps)
1986 push (@info_deps_list, $out_file);
1987 push (@dvis_list, $infobase . '.dvi');
1989 # Generate list of things to clean for this target. We do
1990 # this explicitly because otherwise too many things could be
1991 # removed. In particular the ".log" extension might
1992 # reasonably be used in other contexts by the user.
1993 foreach $tc_cursor ('aux', 'cp', 'cps', 'dvi', 'fn', 'fns', 'pgs',
1994 'ky', 'kys', 'ps', 'log', 'pg', 'toc', 'tp', 'tps',
1995 'vr', 'vrs', 'op', 'tr', 'cv', 'cn')
1997 push (@texi_cleans, $infobase . '.' . $tc_cursor);
2001 # Find these programs wherever they may lie. Yes, this has
2002 # intimate knowledge of the structure of the texinfo distribution.
2003 &define_program_variable ('MAKEINFO', 'build', 'texinfo/makeinfo',
2005 # Circumlocution to avoid accidental
2006 # configure substitution.
2008 &define_program_variable ('TEXI2DVI', 'src', 'texinfo/util',
2011 # Set transform for including texinfos.am. First, handle --cygnus
2016 $xform = 's/^NOTCYGNUS.*$//; s/^CYGNUS//;';
2020 $xform = 's/^CYGNUS.*$//; s/^NOTCYGNUS//;';
2023 # Handle location of texinfo.tex.
2024 local ($need_texi_file) = 0;
2025 local ($texinfo_tex);
2028 $texinfo_tex = '$(top_srcdir)/../texinfo/texinfo.tex';
2029 &define_variable ('TEXINFO_TEX', $texinfo_tex);
2032 elsif ($config_aux_dir ne '.' && $config_aux_dir ne '')
2034 $texinfo_tex = $config_aux_dir . '/texinfo.tex';
2035 &define_variable ('TEXINFO_TEX', $texinfo_tex);
2037 elsif (&variable_defined ('TEXINFO_TEX'))
2039 # The user defined TEXINFO_TEX so assume he knows what he is
2041 $texinfo_tex = ('$(srcdir)/'
2042 . &dirname (&variable_value ('TEXINFO_TEX')));
2047 $need_texi_file = 1;
2050 ($xxform = $texinfo_tex) =~ s/\/texinfo\.tex$//;
2051 $xxform =~ s/(\W)/\\$1/g;
2052 $xform .= ' s/\@TEXINFODIR\@/' . $xxform . '/g;';
2054 $output_rules .= &file_contents_with_transform ($xform, 'texinfos');
2055 push (@phony, 'install-info-am', 'uninstall-info');
2056 push (@dist_targets, 'dist-info');
2058 # How to clean. The funny name is due to --cygnus influence; in
2059 # Cygnus mode, `clean-info' is a target that users can use.
2060 $output_rules .= "\nmostlyclean-aminfo:\n";
2061 &pretty_print_rule ("\t-rm -f", "\t ", @texi_cleans);
2062 $output_rules .= ("\nclean-aminfo:\n\ndistclean-aminfo:\n\n"
2063 . "maintainer-clean-aminfo:\n\t"
2064 # Eww. But how else can we find all the output
2065 # files from makeinfo?
2066 . ($cygnus_mode ? '' : 'cd $(srcdir) && ')
2067 . 'for i in $(INFO_DEPS); do' . " \\\n"
2068 . "\t" . ' rm -f $$i;' . " \\\n"
2069 . "\t" . ' if test "`echo $$i-[0-9]*`" != "$$i-[0-9]*"; then' . " \\\n"
2070 . "\t" . ' rm -f $$i-[0-9]*;' . " \\\n"
2071 . "\t" . ' fi;' . " \\\n"
2073 &push_phony_cleaners ('aminfo');
2076 $output_rules .= "clean-info: mostlyclean-aminfo\n";
2079 push (@suffixes, '.texi', '.texinfo', '.txi', '.info', '.dvi', '.ps');
2081 if (! defined $options{'no-installinfo'})
2083 push (@uninstall, 'uninstall-info');
2084 push (@installdirs, '$(DESTDIR)$(infodir)');
2085 unshift (@install_data, 'install-info-am');
2087 # Make sure documentation is made and installed first. Use
2088 # $(INFO_DEPS), not 'info', because otherwise recursive makes
2089 # get run twice during "make all".
2090 unshift (@all, '$(INFO_DEPS)');
2092 push (@clean, 'aminfo');
2093 push (@info, '$(INFO_DEPS)');
2094 push (@dvi, '$(DVIS)');
2096 &define_variable ("INFO_DEPS", join (' ', @info_deps_list));
2097 &define_variable ("DVIS", join (' ', @dvis_list));
2098 # This next isn't strictly needed now -- the places that look here
2099 # could easily be changed to look in info_TEXINFOS. But this is
2100 # probably better, in case noinst_TEXINFOS is ever supported.
2101 &define_variable ("TEXINFOS", &variable_value ('info_TEXINFOS'));
2103 # Do some error checking. Note that this file is not required
2104 # when in Cygnus mode; instead we defined TEXINFO_TEX explicitly
2106 &require_file_with_line ('info_TEXINFOS', $FOREIGN, 'texinfo.tex')
2107 if $need_texi_file && ! defined $options{'no-texinfo.tex'};
2110 # Handle any man pages.
2111 sub handle_man_pages
2113 &am_line_error ('MANS', "\`MANS' is an anachronism; use \`man_MANS'")
2114 if &variable_defined ('MANS');
2115 return if ! &variable_defined ('man_MANS');
2117 # Find all the sections in use. We do this by first looking for
2118 # "standard" sections, and then looking for any additional
2119 # sections used in man_MANS.
2120 local ($sect, %sections, %vlist);
2121 # Add more sections as needed.
2122 foreach $sect ('0'..'9', 'n', 'l')
2124 if (&variable_defined ('man' . $sect . '_MANS'))
2126 $sections{$sect} = 1;
2127 $vlist{'$(man' . $sect . '_MANS)'} = 1;
2131 if (&variable_defined ('man_MANS'))
2133 $vlist{'$(man_MANS)'} = 1;
2134 foreach (&variable_value_as_list ('man_MANS', 'all'))
2136 # A page like `foo.1c' goes into man1dir.
2137 if (/\.([0-9a-z])([a-z]*)$/)
2145 # Now for each section, generate an install and unintall rule.
2146 # Sort sections so output is deterministic.
2148 foreach $sect (sort keys %sections)
2150 &define_variable ('man' . $sect . 'dir', '$(mandir)/man' . $sect);
2151 push (@installdirs, '$(DESTDIR)$(mandir)/man' . $sect)
2152 unless defined $options{'no-installman'};
2153 $output_rules .= &file_contents_with_transform ('s/\@SECTION\@/'
2156 push (@phony, 'install-man' . $sect, 'uninstall-man' . $sect);
2157 push (@namelist, 'install-man' . $sect);
2160 # We don't really need this, but we use it in case we ever want to
2161 # support noinst_MANS.
2162 &define_variable ("MANS", join (' ', sort keys %vlist));
2164 # Generate list of install dirs.
2165 $output_rules .= ("install-man: \$(MANS)\n"
2166 . "\t\@\$(NORMAL_INSTALL)\n");
2167 &pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ", @namelist);
2168 push (@phony, 'install-man');
2170 $output_rules .= "uninstall-man:\n\t\@\$(NORMAL_UNINSTALL)\n";
2171 grep ($_ = 'un' . $_, @namelist);
2172 &pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ", @namelist);
2173 push (@phony, 'uninstall-man');
2175 $output_vars .= &file_contents ('mans-vars');
2177 if (! defined $options{'no-installman'})
2179 push (@install_data, 'install-man');
2180 push (@uninstall, 'uninstall-man');
2181 push (@all, '$(MANS)');
2185 # Handle DATA variables.
2188 &am_install_var ('-noextra', '-defaultdist', 'data', 'DATA',
2189 'data', 'sysconf', 'sharedstate', 'localstate',
2190 'pkgdata', 'noinst', 'check');
2196 push (@phony, 'tags');
2197 local (@tag_deps) = ();
2198 if (&variable_defined ('SUBDIRS'))
2200 $output_rules .= ("tags-recursive:\n"
2201 . "\tlist=\'\$(SUBDIRS)\'; for subdir in \$\$list; do \\\n"
2202 # Never fail here if a subdir fails; it
2204 . "\t test \"\$\$subdir\" = . || (cd \$\$subdir"
2205 . " && \$(MAKE) \$(AM_MAKEFLAGS) tags); \\\n"
2207 push (@tag_deps, 'tags-recursive');
2208 push (@phony, 'tags-recursive');
2211 if (&saw_sources_p (1)
2212 || &variable_defined ('ETAGS_ARGS')
2215 local ($xform) = '';
2217 foreach $one_hdr (@config_headers)
2219 if ($relative_dir eq &dirname ($one_hdr))
2221 # The config header is in this directory. So require it.
2223 ($var = &basename ($one_hdr)) =~ s/(\W)/\\$1/g;
2224 $xform .= ' ' if $xform;
2228 $xform = ('s/\@CONFIG\@/' . $xform . '/;'
2229 . 's/\@DIRS\@/' . join (' ', @tag_deps) . '/;');
2231 if (&variable_defined ('SUBDIRS'))
2233 $xform .= 's/^SUBDIRS//;';
2237 $xform .= 's/^SUBDIRS.*$//;';
2240 $output_rules .= &file_contents_with_transform ($xform, 'tags');
2241 $output_rules .= &file_contents ('tags-clean');
2242 push (@clean, 'tags');
2243 &push_phony_cleaners ('tags');
2244 &examine_variable ('TAGS_DEPENDENCIES');
2246 elsif (&variable_defined ('TAGS_DEPENDENCIES'))
2248 &am_line_error ('TAGS_DEPENDENCIES',
2249 "doesn't make sense to define \`TAGS_DEPENDENCIES' without sources or \`ETAGS_ARGS'");
2253 # Every Makefile must define some sort of TAGS rule.
2254 # Otherwise, it would be possible for a top-level "make TAGS"
2255 # to fail because some subdirectory failed.
2256 $output_rules .= "tags: TAGS\nTAGS:\n\n";
2260 # Handle multilib support.
2263 return unless $seen_multilib;
2265 $output_rules .= &file_contents ('multilib.am');
2266 &push_phony_cleaners ('multi');
2267 push (@phony, 'all-multi', 'install-multi');
2270 # Worker for handle_dist.
2271 sub handle_dist_worker
2273 local ($makefile) = @_;
2275 $output_rules .= 'distdir: $(DISTFILES)' . "\n";
2277 # Initialization; only at top level.
2278 if ($relative_dir eq '.')
2280 if (defined $options{'check-news'})
2282 # For Gnits users, this is pretty handy. Look at 15 lines
2283 # in case some explanatory text is desirable.
2284 $output_rules .= ' @if sed 15q $(srcdir)/NEWS | fgrep -e "$(VERSION)" > /dev/null; then :; else \\
2285 echo "NEWS not updated; not releasing" 1>&2; \\
2292 # Create dist directory.
2293 $output_rules .= ("\t-rm -rf \$(distdir)\n"
2294 . "\tmkdir \$(distdir)\n"
2295 . "\t-chmod 777 \$(distdir)\n");
2298 # Only run automake in `dist' target if --include-deps and
2299 # `no-dependencies' not specified. That way the recipient of a
2300 # distribution can run "make dist" and not need Automake. You
2301 # might be wondering why we run automake once for each directory
2302 # we distribute, instead of running it once at the top level. The
2303 # answer is that we want to run automake after the dependencies
2304 # have been generated. This occurs when "make" is run in the
2305 # subdir. So automake must be run after make has updated the
2306 # Makefile, which means that it must run once per directory.
2307 if ($use_dependencies)
2311 # There are several directories we need to know about
2312 # when rebuilding the Makefile.ins. They are:
2313 # here - The absolute path to our topmost build directory.
2314 # top_distdir - The absolute path to the top of our dist
2316 # distdir - The path to our sub-part of the dist hierarchy.
2317 # If this directory is the topmost directory, we set
2318 # top_distdir from distdir; that lets us pass in distdir
2319 # from an enclosing package.
2320 "\t" . 'here=`cd $(top_builddir) && pwd`; ' . "\\\n"
2321 . "\t" . 'top_distdir=`cd $('
2322 . (($relative_dir eq '.') ? 'distdir' : 'top_distdir')
2323 . ') && pwd`; ' . "\\\n"
2324 . "\t" . 'distdir=`cd $(distdir) && pwd`; ' . "\\\n"
2325 . "\tcd \$(top_srcdir) \\\n"
2326 . "\t && \$(AUTOMAKE) --include-deps --build-dir=\$\$here --srcdir-name=\$(top_srcdir) --output-dir=\$\$top_distdir "
2327 # Set strictness of output.
2328 . ($cygnus_mode ? '--cygnus' : ('--' . $strictness_name))
2329 . ($cmdline_use_dependencies ? '' : ' --include-deps')
2330 . " " . $makefile . "\n"
2334 # Scan EXTRA_DIST to see if we need to distribute anything from a
2335 # subdir. If so, add it to the list. I didn't want to do this
2336 # originally, but there were so many requests that I finally
2339 if (&variable_defined ('EXTRA_DIST'))
2341 # FIXME: This should be fixed to work with conditionals. That
2342 # will require only making the entries in @dist_dirs under the
2343 # appropriate condition. This is meaningful if the nature of
2344 # the distribution should depend upon the configure options
2346 foreach (&variable_value_as_list ('EXTRA_DIST', ''))
2349 next unless s,/+[^/]+$,,;
2350 push (@dist_dirs, $_)
2356 # Prepend $(distdir) to each directory given. Doing it via a
2357 # hash lets us ensure that each directory is used only once.
2359 grep ($dhash{'$(distdir)/' . $_} = 1, @dist_dirs);
2360 $output_rules .= "\t";
2361 &pretty_print_rule ('$(mkinstalldirs)', "\t ", sort keys %dhash);
2364 # In loop, test for file existence because sometimes a file gets
2365 # included in DISTFILES twice. For example this happens when a
2366 # single source file is used in building more than one program.
2367 # Also, there are situations in which "ln" can fail. For instance
2368 # a file to distribute could actually be a cross-filesystem
2369 # symlink -- this can easily happen if "gettextize" was run on the
2371 $output_rules .= "\t\@for file in \$(DISTFILES); do \\\n";
2374 $output_rules .= "\t if test -f \$\$file; then d=.; else d=\$(srcdir); fi; \\\n";
2378 $output_rules .= "\t d=\$(srcdir); \\\n";
2380 $output_rules .= ("\t if test -d \$\$d/\$\$file; then \\\n"
2381 . "\t cp -pr \$\$d/\$\$file \$(distdir)/\$\$file; \\\n"
2383 . "\t test -f \$(distdir)/\$\$file \\\n"
2384 . "\t || ln \$\$d/\$\$file \$(distdir)/\$\$file 2> /dev/null \\\n"
2385 . "\t || cp -p \$\$d/\$\$file \$(distdir)/\$\$file || :; \\\n"
2389 # If we have SUBDIRS, create all dist subdirectories and do
2391 if (&variable_defined ('SUBDIRS'))
2393 # If SUBDIRS is conditionally defined, then set DIST_SUBDIRS
2394 # to all possible directories, and use it. If DIST_SUBDIRS is
2395 # defined, just use it.
2396 local ($dist_subdir_name);
2397 if (&variable_conditions ('SUBDIRS')
2398 || &variable_defined ('DIST_SUBDIRS'))
2400 $dist_subdir_name = 'DIST_SUBDIRS';
2401 if (! &variable_defined ('DIST_SUBDIRS'))
2403 &define_pretty_variable ('DIST_SUBDIRS', '',
2404 &variable_value_as_list ('SUBDIRS',
2410 $dist_subdir_name = 'SUBDIRS';
2413 # Test for directory existence here because previous automake
2414 # invocation might have created some directories. Note that
2415 # we explicitly set distdir for the subdir make; that lets us
2416 # mix-n-match many automake-using packages into one large
2417 # package, and have "dist" at the top level do the right
2418 # thing. If we're in the topmost directory, then we use
2419 # `distdir' instead of `top_distdir'; this lets us work
2420 # correctly with an enclosing package.
2422 ("\t" . 'for subdir in $(' . $dist_subdir_name . '); do ' . "\\\n"
2423 . "\t" . ' if test "$$subdir" = .; then :; else ' . "\\\n"
2424 . "\t" . ' test -d $(distdir)/$$subdir ' . "\\\n"
2425 . "\t" . ' || mkdir $(distdir)/$$subdir ' . "\\\n"
2426 . "\t" . ' || exit 1; ' . "\\\n"
2427 . "\t" . ' chmod 777 $(distdir)/$$subdir; ' . "\\\n"
2428 . "\t" . ' (cd $$subdir'
2429 . ' && $(MAKE) $(AM_MAKEFLAGS) top_distdir=../$('
2430 . (($relative_dir eq '.') ? 'distdir' : 'top_distdir')
2431 . ') distdir=../$(distdir)/$$subdir distdir) ' . "\\\n"
2432 . "\t" . ' || exit 1; ' . "\\\n"
2433 . "\t" . ' fi; ' . "\\\n"
2437 # If the target `dist-hook' exists, make sure it is run. This
2438 # allows users to do random weird things to the distribution
2439 # before it is packaged up.
2440 push (@dist_targets, 'dist-hook') if &target_defined ('dist-hook');
2443 foreach $targ (@dist_targets)
2445 # We must explicitly set distdir and top_distdir for these
2447 $output_rules .= ("\t\$(MAKE) \$(AM_MAKEFLAGS)"
2448 . " top_distdir=\"\$(top_distdir)\""
2449 . " distdir=\"\$(distdir)\" $targ\n");
2452 push (@phony, 'distdir');
2455 # Handle 'dist' target.
2458 local ($makefile) = @_;
2460 # Set up maint_charset.
2461 $local_maint_charset = &variable_value ('MAINT_CHARSET')
2462 if &variable_defined ('MAINT_CHARSET');
2463 $maint_charset = $local_maint_charset
2464 if $relative_dir eq '.';
2466 if (&variable_defined ('DIST_CHARSET'))
2468 &am_line_error ('DIST_CHARSET',
2469 "DIST_CHARSET defined but no MAINT_CHARSET defined")
2470 if ! $local_maint_charset;
2471 if ($relative_dir eq '.')
2473 $dist_charset = &variable_value ('DIST_CHARSET')
2477 &am_line_error ('DIST_CHARSET',
2478 "DIST_CHARSET can only be defined at top level");
2482 # Look for common files that should be included in distribution.
2484 foreach $cfile (@common_files)
2486 if (-f ($relative_dir . "/" . $cfile))
2488 &push_dist_common ($cfile);
2492 # Always require configure.in and configure at top level, even if
2493 # they don't exist. This is especially important for configure,
2494 # since it won't be created until autoconf is run -- which might
2495 # be after automake is run.
2496 &push_dist_common ('configure.in', 'configure')
2497 if $relative_dir eq '.';
2499 # Keys of %dist_common are names of files to distributed. We put
2500 # README first because it then becomes easier to make a
2501 # Usenet-compliant shar file (in these, README must be first).
2502 # FIXME: do more ordering of files here.
2504 if (defined $dist_common{'README'})
2506 push (@coms, 'README');
2507 delete $dist_common{'README'};
2509 push (@coms, sort keys %dist_common);
2511 &define_pretty_variable ("DIST_COMMON", '', @coms);
2512 $output_vars .= "\n";
2515 $output_vars .= &file_contents ('dist-vars') . "\n";
2516 &define_variable ('GZIP_ENV', '--best');
2518 # Put these things in rules section so it is easier for whoever
2519 # reads Makefile.in.
2520 if (! &variable_defined ('distdir'))
2522 if ($relative_dir eq '.')
2524 $output_rules .= "\n" . 'distdir = $(PACKAGE)-$(VERSION)' . "\n";
2528 $output_rules .= ("\n"
2529 . 'distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)'
2533 if ($relative_dir eq '.')
2535 $output_rules .= "top_distdir = \$(distdir)\n\n";
2539 $output_rules .= "\nsubdir = " . $relative_dir . "\n\n";
2542 # Generate 'dist' target, and maybe other dist targets.
2543 if ($relative_dir eq '.')
2545 # Rule to check whether a distribution is viable.
2546 $output_rules .= ('# This target untars the dist file and tries a VPATH configuration. Then
2547 # it guarantees that the distribution is self-contained by making another
2551 GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(TAR) xf -
2552 mkdir $(distdir)/=build
2553 mkdir $(distdir)/=inst
2554 dc_install_base=`cd $(distdir)/=inst && pwd`; \\'
2555 . (&target_defined ('distcheck-hook')
2556 ? ("\n\t\$(MAKE) \$(AM_MAKEFLAGS)"
2557 . " distcheck-hook; \\")
2560 cd $(distdir)/=build \\
2563 . ($seen_gettext ? '--with-included-gettext ' : '')
2564 . '--srcdir=.. --prefix=$$dc_install_base \\
2565 && $(MAKE) $(AM_MAKEFLAGS) \\
2566 && $(MAKE) $(AM_MAKEFLAGS) dvi \\
2567 && $(MAKE) $(AM_MAKEFLAGS) check \\
2568 && $(MAKE) $(AM_MAKEFLAGS) install \\
2569 && $(MAKE) $(AM_MAKEFLAGS) installcheck \\
2570 && $(MAKE) $(AM_MAKEFLAGS) dist
2572 @banner="$(distdir).tar.gz is ready for distribution"; \\
2573 dashes=`echo "$$banner" | sed s/./=/g`; \\
2579 local ($dist_all) = ('dist-all: distdir' . "\n"
2582 foreach $curs ('dist', 'dist-shar', 'dist-zip', 'dist-tarZ',
2585 if (defined $options{$curs} || $curs eq 'dist')
2587 $output_rules .= ($curs . ': distdir' . "\n"
2591 $dist_all .= $dist{$curs};
2594 $output_rules .= $dist_all . $dist_trailer;
2597 # Generate distdir target.
2598 &handle_dist_worker ($makefile);
2601 # Scan a single dependency file and rewrite the dependencies as
2602 # appropriate. Essentially this means:
2603 # * Clean out absolute dependencies which are not desirable.
2604 # * Rewrite other dependencies to be relative to $(top_srcdir).
2605 sub scan_dependency_file
2607 local ($depfile) = @_;
2609 if (! open (DEP_FILE, $depfile))
2611 &am_error ("couldn't open \`$depfile': $!");
2614 print "automake: reading $depfile\n" if $verbose;
2616 # Sometimes it is necessary to omit some dependencies.
2617 local (%omit) = %omit_dependencies;
2618 if (&variable_defined ('OMIT_DEPENDENCIES'))
2620 # FIXME: Doesn't work with conditionals. I'm not sure if this
2622 grep ($omit{$_} = 1,
2623 &variable_value_as_list ('OMIT_DEPENDENCIES', ''));
2626 local ($first_line) = 1;
2627 local ($last_line) = 0;
2628 local ($target, @dependencies);
2629 local ($one_dep, $xform);
2632 local ($srcdir_rx, $fixup_rx);
2633 ($fixup_rx = $srcdir_name . '/' . $relative_dir . '/')
2635 ($srcdir_rx = $srcdir_name . '/') =~ s/(\W)/\\$1/g;
2637 local ($rewrite_builddir) = (($top_builddir eq '.')
2639 : $top_builddir . '/');
2644 next if (/$WHITE_PATTERN/o);
2648 # No trailing "\" means this should be the last line of
2649 # the first target. We can have multiple targets due to
2650 # the "deleted header file" fix. For the generated
2651 # Makefile we simply skip these fake targets.
2657 if (! /^([^:]+:)(.+)$/)
2660 &am_error ("\`$depfile' has incorrect format");
2666 # Make sure to strip the .P file from the target.
2667 ($target = $1) =~ s, *\.deps/[^.]+\.P,,;
2672 foreach $one_dep (split (' ', $_))
2674 ($just_file = $one_dep) =~ s,^.*/,,;
2675 next if defined $omit{$just_file};
2677 if ($one_dep =~ /^$fixup_rx/)
2679 # The dependency points to the current directory in
2681 ($xform = $one_dep) =~ s/^$fixup_rx//;
2682 push (@dependencies, $xform);
2684 elsif ($one_dep =~ /^$srcdir_rx/)
2686 # The dependency is in some other directory in the package.
2687 ($xform = $one_dep) =~ s/^$srcdir_rx/$rewrite_builddir/;
2688 push (@dependencies, $xform);
2690 elsif ($one_dep =~ /^\// || $one_dep =~ /^[A-Za-z]:\\/)
2692 # Absolute path; ignore.
2696 # Anything else is assumed to be correct.
2697 push (@dependencies, $one_dep);
2702 &pretty_print_rule ($target, "\t", @dependencies);
2707 # Handle auto-dependency code.
2708 sub handle_dependencies
2710 # Make sure this variable is always marked as used.
2711 &examine_variable ('OMIT_DEPENDENCIES');
2713 if ($use_dependencies)
2715 # Include GNU-make-specific auto-dep code. Don't include it
2716 # if DEP_FILES would be empty.
2717 if (&saw_sources_p (0) && keys %dep_files)
2719 &define_pretty_variable ('DEP_FILES', '', sort keys %dep_files);
2720 $output_rules .= &file_contents ('depend');
2721 push (@clean, 'depend');
2722 &push_phony_cleaners ('depend');
2723 # FIXME: this should use another property of the language
2724 # instead of being hard-coded.
2726 &file_contents_with_transform ('s/\@EXT\@/.c/g;'
2730 foreach $ext (&lang_extensions ('objc'))
2733 &file_contents_with_transform ('s/\@EXT\@/' . $ext . '/g;'
2734 . 's/\@PFX\@/OBJC/g;',
2737 foreach $ext (&lang_extensions ('cxx'))
2740 &file_contents_with_transform ('s/\@EXT\@/' . $ext .'/g;'
2741 . 's/\@PFX\@/CXX/g;',
2746 elsif ($build_directory ne '')
2748 # Include any auto-generated deps that are present. Note that
2749 # $build_directory ends in a "/".
2750 if (-d ($build_directory . $relative_dir . "/.deps"))
2754 foreach $depfile (&my_glob ($build_directory
2755 . $relative_dir . "/.deps/*.P"))
2757 &scan_dependency_file ($depfile);
2760 $output_rules .= "\n";
2765 # Handle subdirectories.
2768 return if ! &variable_defined ('SUBDIRS');
2770 # Make sure each directory mentioned in SUBDIRS actually exists.
2772 foreach $dir (&variable_value_as_list ('SUBDIRS', 'all'))
2774 # Skip directories substituted by configure.
2775 next if $dir =~ /^\@.*\@$/;
2777 if (! -d $am_relative_dir . '/' . $dir)
2779 &am_line_error ('SUBDIRS',
2780 "required directory $am_relative_dir/$dir does not exist");
2784 &am_line_error ('SUBDIRS', "directory should not contain \`/'")
2788 local ($xform) = ('s/\@INSTALLINFO\@/' .
2789 (defined $options{'no-installinfo'}
2790 ? 'install-info-recursive'
2793 $output_rules .= &file_contents_with_transform ($xform, 'subdirs');
2795 # Push a bunch of phony targets.
2797 foreach $phonies ('-data', '-exec', 'dirs')
2799 push (@phony, 'install' . $phonies . '-recursive');
2800 push (@phony, 'uninstall' . $phonies . '-recursive');
2802 foreach $phonies ('all', 'check', 'installcheck', 'info', 'dvi')
2804 push (@phony, $phonies . '-recursive');
2806 &push_phony_cleaners ('recursive');
2808 $recursive_install = 1;
2811 # Handle aclocal.m4.
2812 sub handle_aclocal_m4
2814 local ($regen_aclocal) = 0;
2815 if (-f 'aclocal.m4')
2817 &define_variable ("ACLOCAL_M4", '$(top_srcdir)/aclocal.m4');
2818 &push_dist_common ('aclocal.m4');
2820 if (open (ACLOCAL, '< aclocal.m4'))
2826 if ($line =~ 'generated automatically by aclocal')
2833 local ($acinclude) = 0;
2834 if (-f 'acinclude.m4')
2840 # Note that it might be possible that aclocal.m4 doesn't exist but
2841 # should be auto-generated. This case probably isn't very
2845 local (@ac_deps) = (
2847 ? "\@MAINTAINER_MODE_TRUE\@"
2850 ($acinclude ? ' acinclude.m4' : '')
2853 # Scan all -I directories for m4 files. These are our
2855 if (&variable_defined ('ACLOCAL_AMFLAGS'))
2857 local ($examine_next, $amdir) = 0;
2858 foreach $amdir (&variable_value_as_list ('ACLOCAL_AMFLAGS', ''))
2863 if ($amdir !~ /^\// && -d $amdir)
2865 push (@ac_deps, &my_glob ($amdir . '/*.m4'));
2868 elsif ($amdir eq '-I')
2875 &pretty_print_rule ("\$(ACLOCAL_M4):", "\t\t", @ac_deps);
2877 $output_rules .= ("\t"
2878 . 'cd $(srcdir) && $(ACLOCAL)'
2879 . (&variable_defined ('ACLOCAL_AMFLAGS')
2880 ? ' $(ACLOCAL_AMFLAGS)' : '')
2885 # Rewrite a list of input files into a form suitable to put on a
2886 # dependency list. The idea is that if an input file has a directory
2887 # part the same as the current directory, then the directory part is
2888 # simply removed. But if the directory part is different, then
2889 # $(top_srcdir) is prepended. Among other things, this is used to
2890 # generate the dependency list for the output files generated by
2891 # AC_OUTPUT. Consider what the dependencies should look like in this
2893 # AC_OUTPUT(src/out:src/in1:lib/in2)
2894 # The first argument, ADD_SRCDIR, is 1 if $(top_srcdir) should be added.
2895 # If 0 then files that require this addition will simply be ignored.
2896 sub rewrite_inputs_into_dependencies
2898 local ($add_srcdir, @inputs) = @_;
2899 local ($single, @newinputs);
2901 foreach $single (@inputs)
2903 if (&dirname ($single) eq $relative_dir)
2905 push (@newinputs, &basename ($single));
2909 push (@newinputs, '$(top_srcdir)/' . $single);
2916 # Handle remaking and configure stuff.
2917 # We need the name of the input file, to do proper remaking rules.
2918 sub handle_configure
2920 local ($local, $input, @secondary_inputs) = @_;
2922 # If SUBDIRS defined, require AC_PROG_MAKE_SET.
2923 &am_line_error ('SUBDIRS', "AC_PROG_MAKE_SET must be used in configure.in")
2924 if &variable_defined ('SUBDIRS') && ! $seen_make_set;
2926 local ($top_reldir);
2928 local ($input_base) = &basename ($input);
2929 local ($local_base) = &basename ($local);
2931 local ($amfile) = $input_base . '.am';
2932 # We know we can always add '.in' because it really should be an
2933 # error if the .in was missing originally.
2934 local ($infile) = '$(srcdir)/' . $input_base . '.in';
2935 local ($colon_infile);
2936 if ($local ne $input || @secondary_inputs)
2938 $colon_infile = ':' . $input . '.in';
2940 $colon_infile .= ':' . join (':', @secondary_inputs)
2941 if @secondary_inputs;
2943 local (@rewritten) = &rewrite_inputs_into_dependencies (1,
2946 # This rule remakes the Makefile.in. Note use of
2947 # @MAINTAINER_MODE_TRUE@ forces us to abandon pretty-printing.
2949 $output_rules .= ($infile
2950 # NOTE perl 5.003 (with -w) gives a
2951 # uninitialized value error on the next line.
2954 . ($seen_maint_mode ? "\@MAINTAINER_MODE_TRUE\@ " : '')
2956 . '$(top_srcdir)/configure.in $(ACLOCAL_M4)'
2957 . ' ' . join (' ', @include_stack)
2959 . "\tcd \$(top_srcdir) && \$(AUTOMAKE) "
2960 . ($cygnus_mode ? '--cygnus' : ('--' . $strictness_name))
2961 . ($cmdline_use_dependencies ? '' : ' --include-deps')
2962 . ' ' . $input . $colon_infile . "\n\n");
2964 # This rule remakes the Makefile.
2965 $output_rules .= ($local_base
2966 # NOTE: bogus uninit value error on next line;
2967 # see comment above.
2970 . join (' ', @rewritten)
2971 . ' $(top_builddir)/config.status'
2972 # NOTE: Makefile only depends on BUILT_SOURCES
2973 # when dependencies are being computed. This is
2974 # a workaround for an obscure bug with
2975 # AC_LINK_FILES. Anyway, when dependencies are
2976 # turned off, this shouldn't matter.
2977 . ($use_dependencies ? ' $(BUILT_SOURCES)' : '')
2979 . "\tcd \$(top_builddir) \\\n"
2980 . "\t && CONFIG_FILES="
2981 . (($relative_dir eq '.') ? '$@' : '$(subdir)/$@')
2983 . ' CONFIG_HEADERS= $(SHELL) ./config.status'
2986 if ($relative_dir ne '.')
2989 $top_reldir = '../';
2994 $output_rules .= &file_contents ('remake');
2995 &examine_variable ('CONFIG_STATUS_DEPENDENCIES');
2996 &examine_variable ('CONFIGURE_DEPENDENCIES');
3000 # Make it easy to see if there is a Makefile.am in a given
3002 local (%make_dirs, $iter);
3003 foreach $iter (@input_files)
3005 $make_dirs{&dirname ($iter)} = 1;
3007 # We also want to notice Makefile.in's.
3008 foreach $iter (@other_input_files)
3010 if ($iter =~ /Makefile\.in$/)
3012 $make_dirs{&dirname ($iter)} = 1;
3016 # If we have a configure header, require it.
3018 local (@local_fullnames) = @config_fullnames;
3019 local (@local_names) = @config_names;
3020 local ($hdr_index) = 0;
3021 local ($distclean_config) = '';
3022 foreach $one_hdr (@config_headers)
3024 local ($one_fullname) = shift (@local_fullnames);
3025 local ($one_name) = shift (@local_names);
3027 local ($header_dir) = &dirname ($one_name);
3029 # If the header is in the current directory we want to build
3030 # the header here. Otherwise, if we're at the topmost
3031 # directory and the header's directory doesn't have a
3032 # Makefile, then we also want to build the header.
3033 if ($relative_dir eq $header_dir
3034 || ($relative_dir eq '.' && ! defined $make_dirs{$header_dir}))
3036 local ($ch_sans_dir, $cn_sans_dir, $stamp_dir);
3037 if ($relative_dir eq $header_dir)
3039 $cn_sans_dir = &basename ($one_name);
3044 $cn_sans_dir = $one_name;
3045 if ($header_dir eq '.')
3051 $stamp_dir = $header_dir . '/';
3055 # Compute relative path from directory holding output
3056 # header to directory holding input header. FIXME:
3057 # doesn't handle case where we have multiple inputs.
3058 if (&dirname ($one_hdr) eq $relative_dir)
3060 $ch_sans_dir = &basename ($one_hdr);
3064 local (@rel_out_path);
3065 # FIXME this chunk of code should be its own sub.
3066 # It is used elsewhere.
3067 foreach (split (/\//, $relative_dir))
3069 next if $_ eq '' || $_ eq '.';
3072 # FIXME: actually this is an error.
3077 push (@rel_out_path, '..');
3082 $ch_sans_dir = join ('/', @rel_out_path) . '/' . $one_hdr;
3086 $ch_sans_dir = $one_hdr;
3090 &require_file_with_conf_line ($config_header_line,
3091 $FOREIGN, $ch_sans_dir);
3093 # Header defined and in this directory.
3095 if (-f $relative_dir . '/acconfig.h')
3097 push (@files, 'acconfig.h');
3099 if (-f $one_name . '.top')
3101 push (@files, "${cn_sans_dir}.top");
3103 if (-f $one_name . '.bot')
3105 push (@files, "${cn_sans_dir}.bot");
3108 &push_dist_common (@files);
3110 local ($stamp_name) = 'stamp-h';
3111 $stamp_name .= "${hdr_index}" if scalar (@config_headers) > 1;
3113 local ($xform) = '';
3115 $xform = 's,\@FILES\@,' . join (' ', @files) . ',;';
3116 $xform .= 's,\@CONFIG_HEADER\@,' . "${cn_sans_dir}" . ',;';
3117 $xform .= 's,\@CONFIG_HEADER_IN\@,' . "${ch_sans_dir}" . ',;';
3118 $xform .= 's,\@CONFIG_HEADER_FULL\@,' . "${one_fullname}" . ',;';
3119 $xform .= 's,\@STAMP\@,' . "${stamp_dir}${stamp_name}" . ',;';
3121 $output_rules .= &file_contents_with_transform ($xform,
3124 local ($out_dir) = &dirname ($ch_sans_dir);
3125 &create ("${relative_dir}/${out_dir}/${stamp_name}.in");
3126 &require_file_with_conf_line ($config_header_line, $FOREIGN,
3127 "${out_dir}/${stamp_name}.in");
3129 $distclean_config .= ' ' if $distclean_config;
3130 $distclean_config .= $cn_sans_dir;
3134 if ($distclean_config)
3136 $output_rules .= &file_contents_with_transform ('s,\@FILES\@,'
3140 push (@clean, 'hdr');
3141 &push_phony_cleaners ('hdr');
3144 # Set location of mkinstalldirs.
3145 if ($config_aux_dir ne '.' && $config_aux_dir ne '')
3147 &define_variable ('mkinstalldirs', ('$(SHELL) ' . $config_aux_dir
3148 . '/mkinstalldirs'));
3152 &define_variable ('mkinstalldirs',
3153 '$(SHELL) $(top_srcdir)/mkinstalldirs');
3156 &am_line_error ('CONFIG_HEADER',
3157 "\`CONFIG_HEADER' is an anachronism; now determined from \`configure.in'")
3158 if &variable_defined ('CONFIG_HEADER');
3161 local ($config_header) = '';
3162 foreach $one_name (@config_names)
3164 # Generate CONFIG_HEADER define.
3166 if ($relative_dir eq &dirname ($one_name))
3168 $one_hdr = &basename ($one_name);
3172 $one_hdr = "${top_builddir}/${one_name}";
3175 $config_header .= ' ' if $config_header;
3176 $config_header .= $one_hdr;
3180 &define_variable ("CONFIG_HEADER", $config_header);
3183 # Now look for other files in this directory which must be remade
3184 # by config.status, and generate rules for them.
3185 local (@actual_other_files) = ();
3186 local ($file, $local);
3187 local (@inputs, @rewritten_inputs, $single);
3188 local ($need_rewritten);
3189 foreach $file (@other_input_files)
3191 if ($file =~ /^([^:]*):(.*)$/)
3193 # This is the ":" syntax of AC_OUTPUT.
3195 $local = &basename ($file);
3196 @inputs = split (':', $2);
3197 @rewritten_inputs = &rewrite_inputs_into_dependencies (1, @inputs);
3198 $need_rewritten = 1;
3203 $local = &basename ($file);
3204 @inputs = ($local . '.in');
3206 &rewrite_inputs_into_dependencies (1, $file . '.in');
3207 $need_rewritten = 0;
3210 # Skip files not in this directory.
3211 next unless &dirname ($file) eq $relative_dir;
3213 # Skip any file that is an automake input.
3214 next if -f $file . '.am';
3216 # Some users have been tempted to put `stamp-h' in the
3217 # AC_OUTPUT line. This won't do the right thing, so we
3218 # explicitly fail here.
3219 if ($local eq 'stamp-h')
3221 # FIXME: allow real filename.
3222 &am_conf_error ('configure.in', $ac_output_line,
3223 'stamp-h should not appear in AC_OUTPUT');
3227 $output_rules .= ($local . ': '
3228 . '$(top_builddir)/config.status '
3229 . join (' ', @rewritten_inputs) . "\n"
3231 . 'cd $(top_builddir) && CONFIG_FILES='
3232 . ($relative_dir eq '.' ? '' : '$(subdir)/')
3233 . '$@' . ($need_rewritten
3234 ? (':' . join (':', @inputs))
3236 . ' CONFIG_HEADERS= $(SHELL) ./config.status'
3238 &push_dist_common (@inputs);
3239 push (@actual_other_files, $local);
3241 # Require all input files.
3242 &require_file_with_conf_line ($ac_output_line, $FOREIGN,
3243 &rewrite_inputs_into_dependencies (0, @inputs));
3246 # These files get removed by "make clean".
3247 &define_pretty_variable ('CONFIG_CLEAN_FILES', '', @actual_other_files);
3254 @r = &am_install_var ('-defaultdist', 'header', 'HEADERS', 'include',
3255 'oldinclude', 'pkginclude',
3259 next unless /\.(.*)$/;
3260 &saw_extension ($1);
3266 return if ! $seen_gettext || $relative_dir ne '.';
3268 if (! &variable_defined ('SUBDIRS'))
3271 ("AM_GNU_GETTEXT in configure.in but SUBDIRS not defined");
3275 &require_file_with_conf_line ($ac_gettext_line, $GNU, 'ABOUT-NLS');
3277 if (&variable_defined ('SUBDIRS'))
3281 "AM_GNU_GETTEXT in configure.in but \`po' not in SUBDIRS")
3282 if $contents{'SUBDIRS'} !~ /\bpo\b/;
3285 "AM_GNU_GETTEXT in configure.in but \`intl' not in SUBDIRS")
3286 if $contents{'SUBDIRS'} !~ /\bintl\b/;
3289 # Ensure that each language in ALL_LINGUAS has a .po file, and
3290 # each po file is mentioned in ALL_LINGUAS.
3293 local (%linguas) = ();
3294 grep ($linguas{$_} = 1, split (' ', $all_linguas));
3301 &am_line_error ($all_linguas_line,
3302 ("po/$_.po exists but \`$_' not in \`ALL_LINGUAS'"))
3306 foreach (keys %linguas)
3308 &am_line_error ($all_linguas_line,
3309 "$_ in \`ALL_LINGUAS' but po/$_.po does not exist")
3315 &am_error ("AM_GNU_GETTEXT in configure.in but \`ALL_LINGUAS' not defined");
3319 # Handle footer elements.
3322 if ($contents{'SOURCES'})
3324 # NOTE don't use define_pretty_variable here, because
3325 # $contents{...} is already defined.
3326 $output_vars .= 'SOURCES = ' . $contents{'SOURCES'} . "\n";
3328 if ($contents{'OBJECTS'})
3330 # NOTE don't use define_pretty_variable here, because
3331 # $contents{...} is already defined.
3332 $output_vars .= 'OBJECTS = ' . $contents{'OBJECTS'} . "\n";
3334 if ($contents{'SOURCES'} || $contents{'OBJECTS'})
3336 $output_vars .= "\n";
3339 if (&variable_defined ('SUFFIXES'))
3341 # Push actual suffixes, and not $(SUFFIXES). Some versions of
3342 # make do not like variable substitutions on the .SUFFIXES
3344 push (@suffixes, &variable_value_as_list ('SUFFIXES', ''));
3346 if (&target_defined ('.SUFFIXES'))
3348 &am_line_error ('.SUFFIXES',
3349 "use variable \`SUFFIXES', not target \`.SUFFIXES'");
3352 # Note: AIX 4.1 /bin/make will fail if any suffix rule appears
3353 # before .SUFFIXES. So we make sure that .SUFFIXES appears before
3354 # anything else, by sticking it right after the default: target.
3355 $output_header .= ".SUFFIXES:\n";
3359 # Make sure suffixes has unique elements. Sort them to ensure
3360 # the output remains consistent.
3363 grep ($suffixes{$_} = 1, @suffixes);
3365 $output_header .= (".SUFFIXES: "
3366 . join (' ', sort keys %suffixes)
3369 $output_trailer .= &file_contents ('footer');
3372 # Deal with installdirs target.
3373 sub handle_installdirs
3375 # GNU Makefile standards recommend this.
3376 if ($recursive_install)
3378 # We create a separate `-am' target so that the -recursive
3379 # rule will work correctly.
3380 $output_rules .= ("installdirs: installdirs-recursive\n"
3381 . "installdirs-am:\n");
3382 push (@phony, 'installdirs-am');
3386 $output_rules .= "installdirs:\n";
3388 push (@phony, 'installdirs');
3391 &pretty_print_rule ("\t" . '$(mkinstalldirs) ', "\t\t",
3394 $output_rules .= "\n";
3397 # There are several targets which need to be merged. This is because
3398 # their complete definition is compiled from many parts. Note that we
3399 # avoid double colon rules, otherwise we'd use them instead.
3400 sub handle_merge_targets
3402 local ($makefile) = @_;
3404 # There are a few install-related variables that you should not define.
3406 foreach $var ('PRE_INSTALL', 'POST_INSTALL', 'NORMAL_INSTALL')
3408 if (&variable_defined ($var))
3410 &am_line_error ($var, "\`$var' should not be defined");
3414 # Put this at the beginning for the sake of non-GNU makes. This
3415 # is still wrong if these makes can run parallel jobs. But it is
3417 unshift (@all, &basename ($makefile));
3420 foreach $one_name (@config_names)
3422 push (@all, &basename ($one_name))
3423 if &dirname ($one_name) eq $relative_dir;
3426 &do_one_merge_target ('info', @info);
3427 &do_one_merge_target ('dvi', @dvi);
3428 &do_check_merge_target;
3429 &do_one_merge_target ('installcheck', @installcheck);
3431 if (defined $options{'no-installinfo'})
3433 &do_one_merge_target ('install-info', '');
3435 elsif (&target_defined ('install-info-local'))
3437 &am_line_error ('install-info-local',
3438 "\`install-info-local' target defined but \`no-installinfo' option not in use");
3442 foreach $utarg ('uninstall-data-local', 'uninstall-data-hook',
3443 'uninstall-exec-local', 'uninstall-exec-hook')
3445 if (&target_defined ($utarg))
3448 ($x = $utarg) =~ s/(data|exec)-//;
3449 &am_line_error ($utarg, "use \`$x', not \`$utarg'");
3453 if (&target_defined ('install-local'))
3455 &am_line_error ('install-local',
3456 "use \`install-data-local' or \`install-exec-local', not \`install-local'");
3462 local ($local_headers) = '';
3463 foreach $one_name (@config_names)
3465 if (&dirname ($one_name) eq $relative_dir)
3467 $local_headers .= ' ' if $local_headers;
3468 $local_headers .= &basename ($one_name);
3473 # This is kind of a hack, but I couldn't see a better way
3474 # to handle it. In this particular case, we need to make
3475 # sure config.h is built before we recurse. We can't do
3476 # this by changing the order of dependencies to the "all"
3477 # because that breaks when using parallel makes. Instead
3478 # we handle things explicitly.
3479 $output_rules .= ("all-recursive-am: ${local_headers}"
3481 . '$(MAKE) $(AM_MAKEFLAGS)'
3484 $all_target = 'all-recursive-am';
3485 push (@phony, 'all-recursive-am');
3489 # Print definitions users can use.
3490 &do_one_merge_target ('install-exec', @install_exec);
3491 $output_rules .= "\n";
3493 &do_one_merge_target ('install-data', @install_data);
3494 $output_rules .= "\n";
3496 &do_one_merge_target ('install', 'all-am');
3497 &do_one_merge_target ('uninstall', @uninstall);
3499 &do_one_merge_target ('all', @all);
3501 # Generate the new 'install-strip' target. We can't just set
3502 # INSTALL_PROGRAM because that might be a relative path.
3503 $output_rules .= ("install-strip:\n\t"
3504 . '$(MAKE) $(AM_MAKEFLAGS) INSTALL_STRIP_FLAG=-s install'
3506 push (@phony, 'install-strip');
3509 # Helper for handle_merge_targets. Note that handle_merge_targets
3510 # relies on the fact that this doesn't add an extra \n at the end.
3511 sub do_one_merge_target
3513 local ($name, @values) = @_;
3515 if (&target_defined ($name . '-local'))
3517 # User defined local form of target. So include it.
3518 push (@values, $name . '-local');
3519 push (@phony, $name . '-local');
3522 &pretty_print_rule ($name . "-am:", "\t\t", @values);
3523 if ($name eq 'install')
3525 # Special-case `install-am' to run install-exec-am and
3526 # install-data-am after all-am is built.
3527 &pretty_print_rule ("\t\@\$(MAKE) \$(AM_MAKEFLAGS)", "\t ",
3528 'install-exec-am', 'install-data-am');
3530 elsif ($name eq 'install-exec' && &target_defined ('install-exec-hook'))
3532 $output_rules .= ("\t\@\$(NORMAL_INSTALL)\n"
3533 . "\t" . '$(MAKE) $(AM_MAKEFLAGS) install-exec-hook'
3536 elsif ($name eq 'install-data' && &target_defined ('install-data-hook'))
3538 $output_rules .= ("\t\@\$(NORMAL_INSTALL)\n"
3539 . "\t" . '$(MAKE) $(AM_MAKEFLAGS) install-data-hook'
3543 local ($lname) = $name . ($recursive_install ? '-recursive' : '-am');
3544 local ($tname) = $name;
3545 # To understand this special case, see handle_merge_targets.
3548 $tname = 'all-redirect';
3549 $lname = $all_target if $recursive_install;
3550 push (@phony, 'all-redirect');
3551 $output_all = "all: all-redirect\n";
3553 &pretty_print_rule ($tname . ":", "\t\t", $lname);
3554 push (@phony, $name . '-am', $name);
3557 # Handle check merge target specially.
3558 sub do_check_merge_target
3560 if (&target_defined ('check-local'))
3562 # User defined local form of target. So include it.
3563 push (@check_tests, 'check-local');
3564 push (@phony, 'check-local');
3567 # In --cygnus mode, check doesn't depend on all.
3570 # Just run the local check rules.
3571 &pretty_print_rule ('check-am:', "\t\t", @check);
3575 # The check target must depend on the local equivalent of
3576 # `all', to ensure all the primary targets are built. Then it
3577 # must build the local check rules.
3578 $output_rules .= "check-am: all-am\n";
3579 &pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ",
3583 &pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ",
3587 push (@phony, 'check', 'check-am');
3588 $output_rules .= ("check: "
3589 . ($recursive_install ? 'check-recursive' : 'check-am')
3593 # Handle all 'clean' targets.
3596 local ($xform) = '';
3599 # Don't include `MAINTAINER'; it is handled specially below.
3600 foreach $name ('MOSTLY', '', 'DIST')
3602 if (! &variable_defined ($name . 'CLEANFILES'))
3604 $xform .= 's/^' . $name . 'CLEAN.*$//;';
3608 $xform .= 's/^' . $name . 'CLEAN//;';
3612 # Built sources are automatically removed by maintainer-clean.
3613 push (@maintainer_clean_files, '\$(BUILT_SOURCES)')
3614 if &variable_defined ('BUILT_SOURCES');
3615 push (@maintainer_clean_files, '\$(MAINTAINERCLEANFILES)')
3616 if &variable_defined ('MAINTAINERCLEANFILES');
3617 if (! @maintainer_clean_files)
3619 $xform .= 's/^MAINTAINERCLEAN.*$//;';
3623 $xform .= ('s/^MAINTAINERCLEAN//;'
3624 # Join with no space to avoid spurious `test -z'
3625 # success at runtime.
3626 . 's,\@MCFILES\@,' . join ('', @maintainer_clean_files)
3628 # A space is required in the join here.
3629 . 's,\@MFILES\@,' . join (' ', @maintainer_clean_files)
3633 $output_rules .= &file_contents_with_transform ($xform, 'clean');
3635 push (@clean, 'generic');
3636 &push_phony_cleaners ('generic');
3638 &do_one_clean_target ('clean', 'mostly', '', @clean);
3639 &do_one_clean_target ('clean', '', 'mostly', @clean);
3640 &do_one_clean_target ('clean', 'dist', '', @clean);
3641 &do_one_clean_target ('clean', 'maintainer-', 'dist', @clean);
3643 push (@phony, 'clean', 'mostlyclean', 'distclean', 'maintainer-clean');
3646 # Helper for handle_clean.
3647 sub do_one_clean_target
3649 local ($target, $name, $last_name, @deps) = @_;
3651 # Change each dependency `BLARG' into `clean-BLARG'.
3652 grep (($_ = $name . 'clean-' . $_) && 0, @deps);
3654 # Push the previous clean target. There is no previous clean
3655 # target if we're doing mostlyclean.
3656 push (@deps, $last_name . $target . '-am')
3657 unless $name eq 'mostly';
3659 # If a -local version of the rule is given, add it to the list.
3660 if (&target_defined ($name . $target . '-local'))
3662 push (@deps, $name . $target . '-local');
3665 # Print the target and the dependencies.
3666 &pretty_print_rule ($name . $target . "-am: ", "\t\t", @deps);
3668 # FIXME: shouldn't we really print these messages before running
3670 if ($name . $target eq 'maintainer-clean')
3672 # Print a special warning.
3674 ("\t\@echo \"This command is intended for maintainers to use;\"\n"
3675 . "\t\@echo \"it deletes files that may require special "
3676 . "tools to rebuild.\"\n");
3678 elsif ($name . $target eq 'distclean')
3680 $output_rules .= "\t-rm -f libtool\n" if $seen_libtool;
3682 $output_rules .= "\n";
3684 # Now generate the actual clean target.
3685 $output_rules .= ($name . $target . ": " . $name . $target
3686 . ($recursive_install ? '-recursive' : '-am')
3689 # We special-case config.status here. If we do it as part of the
3690 # normal clean processing for this directory, then it might be
3691 # removed before some subdir is cleaned. However, that subdir's
3692 # Makefile depends on config.status.
3693 if (($name . $target eq 'maintainer-clean'
3694 || $name . $target eq 'distclean')
3695 && $relative_dir eq '.')
3697 $output_rules .= "\t-rm -f config.status\n";
3699 $output_rules .= "\n";
3702 # Handle .PHONY target.
3705 &pretty_print_rule ('.PHONY:', "", @phony);
3706 $output_rules .= "\n";
3709 # Handle TESTS variable and other checks.
3712 if (defined $options{'dejagnu'})
3714 push (@check_tests, 'check-DEJAGNU');
3715 push (@phony, 'check-DEJAGNU');
3720 $xform = 's/^CYGNUS//;';
3724 $xform = 's/^CYGNUS.*$//;';
3726 $output_rules .= &file_contents_with_transform ($xform, 'dejagnu');
3728 # In Cygnus mode, these are found in the build tree.
3729 # Otherwise they are looked for in $PATH.
3730 &define_program_variable ('EXPECT', 'build', 'expect', 'expect');
3731 &define_program_variable ('RUNTEST', 'src', 'dejagnu', 'runtest');
3733 # Only create site.exp rule if user hasn't already written
3735 if (! &target_defined ('site.exp'))
3737 # Note that in the rule we don't directly generate
3738 # site.exp to avoid the possibility of a corrupted
3739 # site.exp if make is interrupted. Jim Meyering has some
3740 # useful text on this topic.
3741 $output_rules .= ("site.exp: Makefile\n"
3742 . "\t\@echo 'Making a new site.exp file...'\n"
3743 . "\t\@test ! -f site.bak || rm -f site.bak\n"
3744 . "\t\@echo '## these variables are automatically generated by make ##' > \$\@-t\n"
3745 . "\t\@echo '# Do not edit here. If you wish to override these values' >> \$\@-t\n"
3746 . "\t\@echo '# edit the last section' >> \$\@-t\n"
3747 . "\t\@echo 'set tool \$(DEJATOOL)' >> \$\@-t\n"
3748 . "\t\@echo 'set srcdir \$(srcdir)' >> \$\@-t\n"
3749 . "\t\@echo 'set objdir' \`pwd\` >> \$\@-t\n");
3751 # Extra stuff for AC_CANONICAL_*
3752 local (@whatlist) = ();
3753 if ($seen_canonical)
3755 push (@whatlist, 'host');
3758 # Extra stuff only for AC_CANONICAL_SYSTEM.
3759 if ($seen_canonical == $AC_CANONICAL_SYSTEM)
3761 push (@whatlist, 'target', 'build');
3765 foreach $c1 (@whatlist)
3767 foreach $c2 ('alias', 'triplet')
3769 $output_rules .= "\t\@echo 'set ${c1}_${c2} \$(${c1}_${c2})' >> \$\@-t\n";
3773 $output_rules .= ("\t\@echo '## All variables above are generated by configure. Do Not Edit ##' >> \$\@-t\n"
3774 . "\t\@test ! -f site.exp || sed '1,/^## All variables above are.*##/ d' site.exp >> \$\@-t\n"
3775 . "\t\@test ! -f site.exp || mv site.exp site.bak\n"
3776 . "\t\@mv \$\@-t site.exp\n");
3782 foreach $c ('DEJATOOL', 'RUNTEST', 'RUNTESTFLAGS')
3784 if (&variable_defined ($c))
3786 &am_line_error ($c, "\`$c' defined but \`dejagnu' not in \`AUTOMAKE_OPTIONS'");
3791 if (&variable_defined ('TESTS'))
3793 push (@check_tests, 'check-TESTS');
3794 push (@phony, 'check-TESTS');
3796 # Note: Solaris 2.7 seems to expand TESTS using VPATH. That's
3797 # why we choose `dir=' and not `dir=.'
3798 $output_rules .= 'check-TESTS: $(TESTS)
3799 @failed=0; all=0; \\
3800 srcdir=$(srcdir); export srcdir; \\
3801 for tst in $(TESTS); do \\
3802 if test -f $$tst; then dir=; \\
3803 else dir="$(srcdir)/"; fi; \\
3804 if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \\
3805 all=`expr $$all + 1`; \\
3806 echo "PASS: $$tst"; \\
3807 elif test $$? -ne 77; then \\
3808 all=`expr $$all + 1`; \\
3809 failed=`expr $$failed + 1`; \\
3810 echo "FAIL: $$tst"; \\
3813 if test "$$failed" -eq 0; then \\
3814 banner="All $$all tests passed"; \\
3816 banner="$$failed of $$all tests failed"; \\
3818 dashes=`echo "$$banner" | sed s/./=/g`; \\
3822 test "$$failed" -eq 0
3827 # Handle Emacs Lisp.
3828 sub handle_emacs_lisp
3830 local (@elfiles) = &am_install_var ('-candist', 'lisp', 'LISP',
3836 &define_configure_variable ('lispdir');
3837 &define_configure_variable ('EMACS');
3838 $output_rules .= (".el.elc:\n"
3839 . "\t\@echo 'WARNING: Warnings can be ignored. :-)'\n"
3840 . "\tif test \$(EMACS) != no; then \\\n"
3841 . "\t EMACS=\$(EMACS) \$(SHELL) \$(srcdir)/elisp-comp \$<; \\\n"
3843 push (@suffixes, '.el', '.elc');
3845 # Generate .elc files.
3846 grep ($_ .= 'c', @elfiles);
3847 &define_pretty_variable ('ELCFILES', '', @elfiles);
3849 $output_rules .= &file_contents ('lisp-clean');
3850 push (@clean, 'lisp');
3851 &push_phony_cleaners ('lisp');
3853 push (@all, '$(ELCFILES)');
3856 if (&variable_defined ('lisp_LISP'))
3858 $varname = 'lisp_LISP';
3859 &am_error ("\`lisp_LISP' defined but \`AM_PATH_LISPDIR' not in \`configure.in'")
3864 $varname = 'noinst_LISP';
3867 &require_file_with_line ($varname, $FOREIGN, 'elisp-comp');
3874 local (@sourcelist) = &am_install_var ('-candist', '-clean',
3876 'java', 'noinst', 'check');
3877 return if ! @sourcelist;
3879 &define_variable ('JAVAC', 'javac');
3880 &define_variable ('JAVACFLAGS', '');
3881 &define_variable ('CLASSPATH_ENV',
3882 'CLASSPATH=$(JAVAROOT):$(srcdir)/$(JAVAROOT):$$CLASSPATH');
3883 &define_variable ('JAVAROOT', '$(top_builddir)');
3885 local (%valid) = &am_primary_prefixes ('JAVA', 1,
3886 'java', 'noinst', 'check');
3888 local ($dir, $curs);
3889 foreach $curs (keys %valid)
3891 if (! &variable_defined ($curs . '_JAVA') || $curs eq 'noinst'
3892 || $curs eq 'EXTRA')
3899 &am_line_error ($curs . '_JAVA',
3900 "multiple _JAVA primaries in use");
3905 $output_rules .= ('class' . $dir . '.stamp: $(' . $dir . '_JAVA)' . "\n"
3906 . "\t" . '$(CLASSPATH_ENV) $(JAVAC) -d $(JAVAROOT) '
3907 . '$(JAVACFLAGS) $?' . "\n"
3908 . "\t" . 'echo timestamp > class' . $dir . '.stamp'
3910 push (@all, 'class' . $dir . '.stamp');
3911 &push_dist_common ('$(' . $dir . '_JAVA)');
3914 # Handle some of the minor options.
3915 sub handle_minor_options
3917 if (defined $options{'readme-alpha'})
3919 if ($relative_dir eq '.')
3921 if ($package_version !~ /^$GNITS_VERSION_PATTERN$/)
3923 # FIXME: allow real filename.
3924 &am_conf_line_error ('configure.in',
3925 $package_version_line,
3926 "version \`$package_version' doesn't follow Gnits standards");
3928 elsif (defined $1 && -f 'README-alpha')
3930 # This means we have an alpha release. See
3931 # GNITS_VERSION_PATTERN for details.
3932 &require_file ($FOREIGN, 'README-alpha');
3938 ################################################################
3940 # Scan one file for interesting things. Subroutine of scan_configure.
3941 sub scan_one_configure_file
3943 local ($filename) = @_;
3946 open (CONFIGURE, $filename)
3947 || die "automake: couldn't open \`$filename': $!\n";
3948 print "automake: reading $filename\n" if $verbose;
3952 # Remove comments from current line.
3956 # Skip macro definitions. Otherwise we might be confused into
3957 # thinking that a macro that was only defined was actually
3961 # Follow includes. This is a weirdness commonly in use at
3962 # Cygnus and hopefully nowhere else.
3963 if (/sinclude\((.*)\)/ && -f $1)
3965 &scan_one_configure_file ($1);
3968 # Populate libobjs array.
3969 if (/AC_FUNC_ALLOCA/)
3971 $libsources{'alloca.c'} = 1;
3973 elsif (/AC_FUNC_GETLOADAVG/)
3975 $libsources{'getloadavg.c'} = 1;
3977 elsif (/AC_FUNC_MEMCMP/)
3979 $libsources{'memcmp.c'} = 1;
3981 elsif (/AC_STRUCT_ST_BLOCKS/)
3983 $libsources{'fileblocks.c'} = 1;
3985 elsif (/A[CM]_REPLACE_GNU_GETOPT/)
3987 $libsources{'getopt.c'} = 1;
3988 $libsources{'getopt1.c'} = 1;
3990 elsif (/AM_FUNC_STRTOD/)
3992 $libsources{'strtod.c'} = 1;
3994 elsif (/AM_WITH_REGEX/)
3996 $libsources{'rx.c'} = 1;
3997 $libsources{'rx.h'} = 1;
3998 $libsources{'regex.c'} = 1;
3999 $libsources{'regex.h'} = 1;
4000 $omit_dependencies{'rx.h'} = 1;
4001 $omit_dependencies{'regex.h'} = 1;
4003 elsif (/AM_FUNC_MKTIME/)
4005 $libsources{'mktime.c'} = 1;
4007 elsif (/AM_FUNC_ERROR_AT_LINE/)
4009 $libsources{'error.c'} = 1;
4010 $libsources{'error.h'} = 1;
4012 elsif (/AM_FUNC_OBSTACK/)
4014 $libsources{'obstack.c'} = 1;
4015 $libsources{'obstack.h'} = 1;
4017 elsif (/LIBOBJS="(.*)\s+\$LIBOBJS"/
4018 || /LIBOBJS="\$LIBOBJS\s+(.*)"/)
4020 foreach $libobj_iter (split (' ', $1))
4022 if ($libobj_iter =~ /^(.*)\.o(bj)?$/
4023 || $libobj_iter =~ /^(.*)\.\$ac_objext$/
4024 || $libobj_iter =~ /^(.*)\.\$\{ac_objext\}$/)
4026 $libsources{$1 . '.c'} = 1;
4031 if (! $in_ac_replace && s/AC_REPLACE_FUNCS\s*\(\[?//)
4037 $in_ac_replace = 0 if s/[\]\)].*$//;
4038 # Remove trailing backslash.
4042 # Need to skip empty elements for Perl 4.
4044 $libsources{$_ . '.c'} = 1;
4048 if (/$obsolete_rx/o)
4051 if ($obsolete_macros{$1} ne '')
4053 $hint = '; ' . $obsolete_macros{$1};
4055 &am_conf_line_error ($filename, $., "\`$1' is obsolete$hint");
4058 # Process the AC_OUTPUT macro.
4059 if (! $in_ac_output && s/AC_OUTPUT\s*\(\[?//)
4062 $ac_output_line = $.;
4066 local ($closing) = 0;
4073 # Look at potential Makefile.am's.
4076 # Must skip empty string for Perl 4.
4077 next if $_ eq "\\" || $_ eq '';
4079 # Handle $local:$input syntax. Note that we ignore
4080 # every input file past the first, though we keep
4081 # those around for later.
4082 local ($local, $input, @rest) = split (/:/);
4089 # FIXME: should be error if .in is missing.
4090 $input =~ s/\.in$//;
4093 if (-f $input . '.am')
4095 # We have a file that automake should generate.
4096 push (@make_input_list, $input);
4097 $make_list{$input} = join (':', ($local, @rest));
4101 # We have a file that automake should cause to be
4102 # rebuilt, but shouldn't generate itself.
4103 push (@other_input_files, $_);
4107 if ($closing && @make_input_list == 0 && @other_input_files == 0)
4109 &am_conf_line_error ($filename, $ac_output_line,
4110 "No files mentioned in \`AC_OUTPUT'");
4115 if (/$AC_CONFIG_AUX_DIR_PATTERN/o)
4117 @config_aux_path = $1;
4120 # Check for ansi2knr.
4121 $am_c_prototypes = 1 if /AM_C_PROTOTYPES/;
4123 # Check for exe extension stuff.
4127 $configure_vars{'EXEEXT'} = $filename . ':' . $.;
4133 $configure_vars{'OBJEXT'} = $filename . ':' . $.;
4136 # Check for NLS support.
4137 if (/AM_GNU_GETTEXT/)
4140 $ac_gettext_line = $.;
4141 $omit_dependencies{'libintl.h'} = 1;
4144 # Look for ALL_LINGUAS.
4145 if (/ALL_LINGUAS="(.*)"$/ || /ALL_LINGUAS=(.*)$/)
4149 $all_linguas_line = $.;
4152 # Handle configuration headers. A config header of `[$1]'
4153 # means we are actually scanning AM_CONFIG_HEADER from
4155 if (/A([CM])_CONFIG_HEADER\s*\((.*)\)/
4159 ($filename, $., "\`automake requires \`AM_CONFIG_HEADER', not \`AC_CONFIG_HEADER'")
4162 $config_header_line = $.;
4164 foreach $one_hdr (split (' ', $2))
4166 push (@config_fullnames, $one_hdr);
4167 if ($one_hdr =~ /^([^:]+):(.+)$/)
4169 push (@config_names, $1);
4170 push (@config_headers, $2);
4174 push (@config_names, $one_hdr);
4175 push (@config_headers, $one_hdr . '.in');
4180 # Handle AC_CANONICAL_*. Always allow upgrading to
4181 # AC_CANONICAL_SYSTEM, but never downgrading.
4182 $seen_canonical = $AC_CANONICAL_HOST
4183 if ! $seen_canonical
4184 && (/AC_CANONICAL_HOST/ || /AC_CHECK_TOOL/);
4185 $seen_canonical = $AC_CANONICAL_SYSTEM if /AC_CANONICAL_SYSTEM/;
4187 $seen_path_xtra = 1 if /AC_PATH_XTRA/;
4189 # This macro handles several different things.
4190 if (/$AM_INIT_AUTOMAKE_PATTERN/o)
4196 $seen_prog_install = 1;
4197 ($package_version = $1) =~ s/$AM_PACKAGE_VERSION_PATTERN/$1/o;
4198 $package_version_line = $.;
4201 # This is like AM_INIT_AUTOMAKE, but doesn't actually set the
4202 # package and version number. (This might change in the
4203 # future). Yes, I'm not above hacking Automake so it works
4204 # well with other GNU tools -- that is actually the point.
4205 if (/AM_INIT_GUILE_MODULE/)
4211 $seen_prog_install = 1;
4212 @config_aux_path = ('..');
4215 # Some things required by Automake.
4216 $seen_make_set = 1 if /AC_PROG_MAKE_SET/;
4217 $seen_arg_prog = 1 if /AC_ARG_PROGRAM/;
4221 $configure_vars{'LEX'} = $filename . ':' . $.;
4222 $seen_decl_yytext = 1;
4224 if (/AC_DECL_YYTEXT/ && $filename =~ /configure\.in$/)
4226 &am_conf_line_warning ($filename, $., "\`AC_DECL_YYTEXT' is covered by \`AM_PROG_LEX'");
4228 if (/AC_PROG_LEX/ && $filename =~ /configure\.in$/)
4230 &am_conf_line_warning ($filename, $., "automake requires \`AM_PROG_LEX', not \`AC_PROG_LEX'");
4233 if (/AC_PROG_(F77|YACC|RANLIB|CC|CXXCPP|CXX|LEX|AWK|CPP|LN_S)/)
4235 $configure_vars{$1} = $filename . ':' . $.;
4237 if (/$AC_CHECK_PATTERN/o)
4239 $configure_vars{$3} = $filename . ':' . $.;
4241 if (/$AM_MISSING_PATTERN/o
4245 && $1 ne 'AUTOHEADER')
4247 $configure_vars{$1} = $filename . ':' . $.;
4250 # Explicitly avoid ANSI2KNR -- we AC_SUBST that in protos.m4,
4251 # but later define it elsewhere. This is pretty hacky. We
4252 # also explicitly avoid INSTALL_SCRIPT and some other
4253 # variables because they are defined in header-vars.am.
4255 if (/$AC_SUBST_PATTERN/o
4257 && $1 ne 'INSTALL_SCRIPT'
4258 && $1 ne 'INSTALL_DATA')
4260 $configure_vars{$1} = $filename . ':' . $.;
4263 $seen_decl_yytext = 1 if /AC_DECL_YYTEXT/;
4264 if (/AM_MAINTAINER_MODE/)
4266 $seen_maint_mode = 1;
4267 $configure_cond{'MAINTAINER_MODE'} = 1;
4269 $seen_package = 1 if /PACKAGE=/;
4271 # Skip VERSION of [$2]; that is from AM_INIT_AUTOMAKE.
4272 if (/\bVERSION=(\S+)/ && $1 ne '[$2]')
4275 $package_version = $1;
4276 $package_version_line = $.;
4283 $seen_prog_install = 1 if /AC_PROG_INSTALL/;
4284 $seen_lispdir = 1 if /AM_PATH_LISPDIR/;
4286 if (/A(C|M)_PROG_LIBTOOL/)
4288 if (/AM_PROG_LIBTOOL/)
4290 &am_conf_line_warning ($filename, $., "\`AM_PROG_LIBTOOL' is obsolete, use \`AC_PROG_LIBTOOL' instead");
4294 $configure_vars{'LIBTOOL'} = $filename . ':' . $.;
4295 $configure_vars{'RANLIB'} = $filename . ':' . $.;
4296 $configure_vars{'CC'} = $filename . ':' . $.;
4297 # AC_PROG_LIBTOOL runs AC_CANONICAL_HOST. Make sure we
4298 # never downgrade (if we've seen AC_CANONICAL_SYSTEM).
4299 $seen_canonical = $AC_CANONICAL_HOST if ! $seen_canonical;
4302 $seen_multilib = 1 if (/AM_ENABLE_MULTILIB/);
4304 if (/$AM_CONDITIONAL_PATTERN/o)
4306 $configure_cond{$1} = 1;
4309 # Check for Fortran 77 intrinsic and run-time libraries.
4310 if (/AC_F77_LIBRARY_LDFLAGS/)
4312 $configure_vars{'FLIBS'} = $filename . ':' . $.;
4319 # Scan configure.in and aclocal.m4 for interesting things. We must
4320 # scan aclocal.m4 because there might be AC_SUBSTs and such there.
4323 # Reinitialize libsources here. This isn't really necessary,
4324 # since we currently assume there is only one configure.in. But
4325 # that won't always be the case.
4328 local ($in_ac_output, $in_ac_replace) = (0, 0);
4329 local (%make_list, @make_input_list);
4330 local ($libobj_iter);
4332 &scan_one_configure_file ('configure.in');
4333 &scan_one_configure_file ('aclocal.m4')
4336 # Set input and output files if not specified by user.
4339 @input_files = @make_input_list;
4340 %output_files = %make_list;
4343 &am_conf_error ("\`PACKAGE' not defined in configure.in")
4345 &am_conf_error ("\`VERSION' not defined in configure.in")
4348 # Look for some files we need. Always check for these. This
4349 # check must be done for every run, even those where we are only
4350 # looking at a subdir Makefile. We must set relative_dir so that
4351 # the file-finding machinery works.
4352 local ($relative_dir) = '.';
4353 &require_config_file ($FOREIGN, 'install-sh', 'mkinstalldirs', 'missing');
4354 &am_error ("\`install.sh' is an anachronism; use \`install-sh' instead")
4355 if -f $config_aux_path[0] . '/install.sh';
4358 ################################################################
4360 # Set up for Cygnus mode.
4363 return unless $cygnus_mode;
4365 &set_strictness ('foreign');
4366 $options{'no-installinfo'} = 1;
4367 $options{'no-dependencies'} = 1;
4368 $use_dependencies = 0;
4370 if (! $seen_maint_mode)
4372 &am_conf_error ("\`AM_MAINTAINER_MODE' required when --cygnus specified");
4377 &am_conf_error ("\`AC_EXEEXT' required when --cygnus specified");
4381 # Do any extra checking for GNU standards.
4382 sub check_gnu_standards
4384 if ($relative_dir eq '.')
4386 # In top level (or only) directory.
4387 &require_file ($GNU, 'INSTALL', 'NEWS', 'README', 'COPYING',
4388 'AUTHORS', 'ChangeLog');
4391 if ($strictness >= $GNU)
4393 if (defined $options{'no-installman'})
4395 &am_line_error ('AUTOMAKE_OPTIONS',
4396 "option \`no-installman' disallowed by GNU standards");
4399 if (defined $options{'no-installinfo'})
4401 &am_line_error ('AUTOMAKE_OPTIONS',
4402 "option \`no-installinfo' disallowed by GNU standards");
4407 # Do any extra checking for GNITS standards.
4408 sub check_gnits_standards
4410 if ($strictness >= $GNITS)
4412 if (-f $relative_dir . '/COPYING.LIB')
4414 &am_error ("\`${relative_dir}/COPYING.LIB' disallowed by Gnits standards");
4418 if ($relative_dir eq '.')
4420 # In top level (or only) directory.
4421 &require_file ($GNITS, 'THANKS');
4425 ################################################################
4427 # Functions to handle files of each language.
4429 # Each `lang_X_rewrite' function follows a simple formula:
4430 # * Args are the base name and extension of the file.
4431 # * Return value is 1 if file is to be dealt with, 0 otherwise.
4432 # Much of the actual processing is handled in handle_single_transform_list.
4433 # These functions exist so that auxiliary information can be recorded
4434 # for a later cleanup pass. Note that the calls to these functions
4435 # are computed, so don't bother searching for their precise names
4438 # Rewrite a single C source file.
4441 local ($base, $ext) = @_;
4443 if (defined $options{'ansi2knr'} && $base =~ /_$/)
4445 # FIXME: include line number in error.
4446 &am_error ("C source file \`$base.c' would be deleted by ansi2knr rules");
4449 $de_ansi_files{$base} = 1;
4453 # Rewrite a single C++ source file.
4454 sub lang_cxx_rewrite
4459 # Rewrite a single header file.
4460 sub lang_header_rewrite
4462 # Header files are simply ignored.
4466 # Rewrite a single yacc file.
4467 sub lang_yacc_rewrite
4469 local ($base, $ext) = @_;
4471 &lang_c_rewrite ($base, $ext);
4472 $yacc_sources{$base . '.' . $ext} = 1;
4474 &saw_extension ('c');
4475 &push_dist_common ($base . '.' . $ext);
4479 # Rewrite a single yacc++ file.
4480 sub lang_yaccxx_rewrite
4482 local ($base, $ext) = @_;
4484 $yacc_sources{$base . '.' . $ext} = 1;
4486 &saw_extension ($ext);
4487 &push_dist_common ($base . '.' . $ext);
4491 # Rewrite a single lex file.
4492 sub lang_lex_rewrite
4494 local ($base, $ext) = @_;
4496 &lang_c_rewrite ($base, $ext);
4497 $lex_sources{$base . '.' . $ext} = 1;
4499 &saw_extension ('c');
4500 &push_dist_common ($base . '.' . $ext);
4504 # Rewrite a single lex++ file.
4505 sub lang_lexxx_rewrite
4507 local ($base, $ext) = @_;
4509 $lex_sources{$base . '.' . $ext} = 1;
4511 &saw_extension ($ext);
4512 &push_dist_common ($base . '.' . $ext);
4516 # Rewrite a single assembly file.
4517 sub lang_asm_rewrite
4522 # Rewrite a single Fortran 77 file.
4523 sub lang_f77_rewrite
4528 # Rewrite a single preprocessed Fortran 77 file.
4529 sub lang_ppf77_rewrite
4534 # Rewrite a single ratfor file.
4535 sub lang_ratfor_rewrite
4540 # Rewrite a single Objective C file.
4541 sub lang_objc_rewrite
4546 # The lang_X_finish functions are called after all source file
4547 # processing is done. Each should handle defining rules for the
4548 # language, etc. A finish function is only called if a source file of
4549 # the appropriate type has been seen.
4553 # Push all libobjs files onto de_ansi_files. We actually only
4554 # push files which exist in the current directory, and which are
4555 # genuine source files.
4557 foreach $file (keys %libsources)
4559 if ($file =~ /^(.*)\.[cly]$/ && -f "$relative_dir/$file")
4561 $de_ansi_files{$1} = 1;
4565 if (defined $options{'ansi2knr'} && keys %de_ansi_files)
4567 # Make all _.c files depend on their corresponding .c files.
4568 local ($base, @objects);
4569 foreach $base (sort keys %de_ansi_files)
4571 # Each _.c file must depend on ansi2knr; otherwise it
4572 # might be used in a parallel build before it is built.
4573 # We need to support files in the srcdir and in the build
4574 # dir (because these files might be auto-generated. But
4575 # we can't use $< -- some makes only define $< during a
4577 $output_rules .= ($base . "_.c: $base.c \$(ANSI2KNR)\n\t"
4578 . '$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) '
4579 . '`if test -f $(srcdir)/' . $base . '.c'
4580 . '; then echo $(srcdir)/' . $base . '.c'
4581 . '; else echo ' . $base . '.c; fi` '
4582 . "| sed 's/^# \\([0-9]\\)/#line \\1/' "
4583 . '| $(ANSI2KNR) > ' . $base . "_.c\n");
4584 push (@objects, $base . '_'
4585 . ($seen_objext ? '.$(OBJEXT)' : '.o'));
4586 push (@objects, $base . '_.lo') if $seen_libtool;
4589 # Make all _.o (and _.lo) files depend on ansi2knr.
4590 # Use a sneaky little hack to make it print nicely.
4591 &pretty_print_rule ('', '', @objects, ':', '$(ANSI2KNR)');
4594 if (! defined $configure_vars{'CC'})
4596 # FIXME: line number.
4597 &am_error ("C source seen but \`CC' not defined in \`configure.in'");
4603 local (@cxx_list) = &lang_extensions ('cxx');
4604 local ($cxx_count) = scalar @cxx_list;
4607 push (@suffixes, @cxx_list);
4609 local ($ltcompile, $ltlink) = &libtool_compiler;
4611 &define_configure_variable ("CXXFLAGS");
4612 &define_compiler_variable ('CXXCOMPILE', $ltcompile, '$(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)');
4614 &define_variable ('CXXLD', '$(CXX)');
4615 &define_variable ('CXXLINK', $ltlink . '$(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@');
4618 foreach $ext (@cxx_list)
4620 $output_rules .= ("$ext.o:\n"
4621 . "\t\$(CXXCOMPILE) -c \$<\n");
4622 # FIXME: Using cygpath should be somehow conditional.
4623 $output_rules .= ("$ext.obj:\n"
4624 . "\t\$(CXXCOMPILE) -c `cygpath -w \$<`\n")
4626 $output_rules .= ("$ext.lo:\n"
4627 . "\t\$(LTCXXCOMPILE) -c \$<\n")
4631 if (! defined $configure_vars{'CXX'})
4633 &am_error ("C++ source seen but \`CXX' not defined in \`configure.in'");
4638 sub lang_header_finish
4643 # This is a helper for both lex and yacc.
4644 sub yacc_lex_finish_helper
4646 return if defined $language_scratch{'lex-yacc-done'};
4647 $language_scratch{'lex-yacc-done'} = 1;
4649 # If there is more than one distinct yacc (resp lex) source file
4650 # in a given directory, then the `ylwrap' program is required to
4651 # allow parallel builds to work correctly. FIXME: for now, no
4653 &require_config_file ($FOREIGN, 'ylwrap');
4654 if ($config_aux_dir ne '.' && $config_aux_dir ne '')
4656 &define_variable ('YLWRAP', $config_aux_dir . "/ylwrap");
4660 &define_variable ('YLWRAP', '$(srcdir)/ylwrap');
4664 sub lang_yacc_finish
4666 return if defined $language_scratch{'yacc-done'};
4667 $language_scratch{'yacc-done'} = 1;
4669 local ($file, $base, $hname, $cname);
4670 local (%seen_suffix) = ();
4671 local (@yacc_files) = sort keys %yacc_sources;
4672 local ($yacc_count) = scalar (@yacc_files);
4673 foreach $file (@yacc_files)
4676 &output_yacc_build_rule ($1, $yacc_count > 1)
4677 if ! defined $seen_suffix{$1};
4678 $seen_suffix{$1} = 1;
4680 # Now generate rule to make the header file. This should only
4681 # be generated if `yacc -d' specified. But right now there is
4682 # no way to determine that. FIXME: examine AM_YFLAGS?
4683 $file =~ /^(.*)\.(y|yy|y\+\+|yxx|ypp)$/;
4685 $hname = '.h'; # Always use `.h' for header file.
4686 ($cname = $2) =~ tr/y/c/;
4687 $output_rules .= "${base}.${hname}: ${base}.${cname}\n";
4689 # If the files are built in the build directory, then we want
4690 # to remove them with `make clean'. If they are in srcdir
4691 # they shouldn't be touched. However, we can't determine this
4692 # statically, and the GNU rules say that yacc/lex output files
4693 # should be removed by maintainer-clean. So that's what we
4695 push (@maintainer_clean_files, "${base}.${hname}", "${base}.${cname}");
4697 $output_rules .= "\n";
4699 if (! defined $configure_vars{'YACC'})
4701 &am_error ("yacc source seen but \`YACC' not defined in \`configure.in'");
4703 if (&variable_defined ('YACCFLAGS'))
4705 &am_line_error ('YACCFLAGS',
4706 "\`YACCFLAGS' obsolete; use \`YFLAGS' instead");
4709 if ($yacc_count > 1)
4711 &yacc_lex_finish_helper;
4715 sub lang_yaccxx_finish
4722 return if defined $language_scratch{'lex-done'};
4723 $language_scratch{'lex-done'} = 1;
4725 local (%seen_suffix) = ();
4726 local ($file, $cname);
4727 local ($lex_count) = scalar (keys %lex_sources);
4728 foreach $file (sort keys %lex_sources)
4731 &output_lex_build_rule ($1, $lex_count > 1)
4732 if (! defined $seen_suffix{$1});
4733 $seen_suffix{$1} = 1;
4735 # If the files are built in the build directory, then we want
4736 # to remove them with `make clean'. If they are in srcdir
4737 # they shouldn't be touched. However, we can't determine this
4738 # statically, and the GNU rules say that yacc/lex output files
4739 # should be removed by maintainer-clean. So that's what we
4741 $file =~ /^(.*)\.(l|ll|l\+\+|lxx|lpp)$/;
4742 ($cname = $2) =~ tr/l/c/;
4743 push (@maintainer_clean_files, "${1}.${cname}");
4746 if (! defined $configure_vars{'LEX'})
4748 &am_error ("lex source seen but \`LEX' not defined in \`configure.in'");
4750 if (! $seen_decl_yytext)
4752 &am_error ("lex source seen but \`AC_DECL_YYTEXT' not in \`configure.in'");
4757 &yacc_lex_finish_helper;
4761 sub lang_lexxx_finish
4774 local (@f77_list) = &lang_extensions ('f77');
4775 local ($f77_count) = scalar @f77_list;
4778 push (@suffixes, @f77_list);
4780 local ($ltcompile, $ltlink) = &libtool_compiler;
4782 &define_configure_variable ('FFLAGS');
4783 &define_compiler_variable ('F77COMPILE', $ltcompile,
4784 '$(F77) $(AM_FFLAGS) $(FFLAGS)');
4786 &define_variable ('F77LD', '$(F77)');
4787 &define_variable ('F77LINK', $ltlink . '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@');
4790 foreach $ext (@f77_list)
4792 $output_rules .= ("$ext.o:\n"
4793 . "\t\$(F77COMPILE) -c \$<\n");
4794 # FIXME: Using cygpath should be somehow conditional.
4795 $output_rules .= ("$ext.obj:\n"
4796 . "\t\$(F77COMPILE) -c `cygpath -w \$<`\n")
4798 $output_rules .= ("$ext.lo:\n"
4799 . "\t\$(LTF77COMPILE) -c \$<\n")
4803 if (! defined $configure_vars{'F77'})
4805 &am_error ("Fortran 77 source seen but \`F77' not defined in \`configure.in'");
4810 # Preprocessed Fortran 77
4812 # The current support for preprocessing Fortran 77 just involves passing
4813 # `$(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS)' as additional flags
4814 # to the Fortran 77 compiler, since this is how GNU Make does it; see
4815 # the `GNU Make Manual, Edition 0.51 for `make' Version 3.76 Beta'
4816 # (specifically, from info file `(make)Catalogue of Rules').
4818 # A better approach would be to write an Autoconf test
4819 # (i.e. AC_PROG_FPP) for a Fortran 77 preprocessor, because not all
4820 # Fortran 77 compilers know how to do preprocessing. The Autoconf macro
4821 # AC_PROG_FPP should test the Fortran 77 compiler first for
4822 # preprocessing capabilities, and then fall back on cpp (if cpp were
4824 sub lang_ppf77_finish
4827 last unless $extension_seen{$ext};
4830 push (@suffixes, $ext);
4832 local ($ltcompile, $ltlink) = &libtool_compiler;
4834 &define_configure_variable ('FFLAGS');
4835 &define_compiler_variable ('F77COMPILE', $ltcompile,
4836 '$(F77) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FFLAGS) $(FFLAGS)');
4838 &define_variable ('F77LD', '$(F77)');
4839 &define_variable ('F77LINK', $ltlink . '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@');
4841 $output_rules .= ("$ext.o:\n"
4842 . "\t\$(F77COMPILE) -c \$<\n");
4843 # FIXME: Using cygpath should be somehow conditional.
4844 $output_rules .= ("$ext.obj:\n"
4845 . "\t\$(F77COMPILE) -c `cygpath -w \$<`\n")
4847 $output_rules .= ("$ext.lo:\n"
4848 . "\t\$(LTF77COMPILE) -c \$<\n")
4851 # We also handle the case of preprocessing `.F' files into `.f'
4853 $output_rules .= ("$ext.f:\n"
4854 . "\t\$(F77COMPILE) -F \$<\n");
4856 if (! defined $configure_vars{'F77'})
4858 &am_error ("Fortran 77 source seen but \`F77' not defined in \`configure.in'");
4862 sub lang_ratfor_finish
4865 last unless $extension_seen{$ext};
4867 push (@suffixes, $ext);
4869 local ($ltcompile, $ltlink) = &libtool_compiler;
4871 &define_configure_variable ('FFLAGS');
4872 &define_configure_variable ('RFLAGS');
4873 &define_variable ('RCOMPILE', $ltcompile,
4874 '$(F77) $(AM_FFLAGS) $(FFLAGS) $(AM_RFLAGS) $(RFLAGS)');
4876 &define_variable ('F77LD', '$(F77)');
4877 &define_variable ('F77LINK', $ltlink . '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_RFLAGS) $(RFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@');
4879 $output_rules .= ("$ext.o:\n"
4880 . "\t\$(RCOMPILE) -c \$<\n");
4881 # FIXME: Using cygpath should be somehow conditional.
4882 $output_rules .= ("$ext.obj:\n"
4883 . "\t\$(RCOMPILE) -c `cygpath -w \$<`\n")
4885 $output_rules .= ("$ext.lo:\n"
4886 . "\t\$(LTRCOMPILE) -c \$<\n")
4889 # We also handle the case of preprocessing `.r' files into `.f'
4891 $output_rules .= ("$ext.f:\n"
4892 . "\t\$(RCOMPILE) -F \$<\n");
4894 if (! defined $configure_vars{'F77'})
4896 &am_error ("Ratfor source seen but \`F77' not defined in \`configure.in'");
4900 sub lang_objc_finish
4902 push (@suffixes, '.m');
4904 local ($ltcompile, $ltlink) = &libtool_compiler;
4906 &define_configure_variable ("OBJCFLAGS");
4907 &define_compiler_variable ('OBJCCOMPILE', $ltcompile,
4908 '$(OBJC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_OBJCFLAGS) $(OBJCFLAGS)');
4910 &define_variable ('OBJCLD', '$(OBJC)');
4911 &define_variable ('OBJCLINK', $ltlink . '$(OBJCLD) $(AM_OBJCFLAGS) $(OBJCFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@');
4913 $output_rules .= (".m.o:\n"
4914 . "\t\$(OBJCCOMPILE) -c \$<\n");
4915 # FIXME: Using cygpath should be somehow conditional.
4916 $output_rules .= (".m.obj:\n"
4917 . "\t\$(OBJCCOMPILE) -c `cygpath -w \$<`\n")
4919 $output_rules .= (".m.lo:\n"
4920 . "\t\$(LTOBJCCOMPILE) -c \$<\n")
4923 if (! defined $configure_vars{'OBJC'})
4925 &am_error ("Objective C source seen but \`OBJC' not defined in \`configure.in'");
4929 # A helper which computes a sorted list of all extensions for LANG.
4934 foreach $key (sort keys %extension_seen)
4936 push (@r, '.' . $key) if $extension_map{$key} eq $lang;
4941 # A helper which decides whether libtool is needed. Returns prefix
4942 # for compiler and linker.
4943 sub libtool_compiler
4945 local ($ltcompile, $ltlink) = ('', '');
4948 &define_configure_variable ("LIBTOOL");
4949 $ltcompile = '$(LIBTOOL) --mode=compile ';
4950 $ltlink = '$(LIBTOOL) --mode=link ';
4952 return ($ltcompile, $ltlink);
4955 # Given a hash table of linker names, pick the name that has the most
4956 # precedence. This is lame, but something has to have global
4957 # knowledge in order to eliminate the conflict. Add more linkers as
4961 local (%linkers) = @_;
4964 if defined $linkers{'CXXLINK'};
4966 if defined $linkers{'F77LINK'};
4968 if defined $linkers{'OBJCLINK'};
4972 # Called to indicate that an extension was used.
4976 $extension_seen{$ext} = 1;
4979 # Called to ask whether source files have been seen . If HEADERS is 1,
4980 # headers can be included.
4983 local ($headers) = @_;
4991 local (@exts) = &lang_extensions ('header');
4995 return scalar keys %extension_seen > $headers;
4998 # Register a single language. If LINKER is the empty string, it means
4999 # to use the C linker. DEANSI_P should only be 1 for languages where
5000 # de-ansi-fication makes sense (i.e., C). EXTENSIONS is a list of
5001 # file extensions to match (no `.' included).
5002 sub register_language
5004 local ($language, $linker, $deansi_p, @extensions) = @_;
5007 foreach $iter (@extensions)
5009 if (defined $extension_map{$iter})
5012 "automake: programming error: duplicate extension $iter\n";
5015 $extension_map{$iter} = $language;
5018 $language_map{$language . '-ansi-p'} = $deansi_p;
5019 $language_map{$language . '-linker'} = $linker;
5023 ################################################################
5025 # Pretty-print something. HEAD is what should be printed at the
5026 # beginning of the first line, FILL is what should be printed at the
5027 # beginning of every subsequent line.
5028 sub pretty_print_internal
5030 local ($head, $fill, @values) = @_;
5032 local ($column) = length ($head);
5033 local ($result) = $head;
5035 # Fill length is number of characters. However, each Tab
5036 # character counts for eight. So we count the number of Tabs and
5038 local ($fill_length) = length ($fill);
5039 $fill_length += 7 * ($fill =~ tr/\t/\t/d);
5041 local ($bol) = ($head eq '');
5044 # "71" because we also print a space.
5045 if ($column + length ($_) > 71)
5047 $result .= " \\\n" . $fill;
5048 $column = $fill_length;
5052 $result .= ' ' unless ($bol);
5054 $column += length ($_) + 1;
5062 # Pretty-print something and append to output_vars.
5065 $output_vars .= &pretty_print_internal (@_);
5068 # Pretty-print something and append to output_rules.
5069 sub pretty_print_rule
5071 $output_rules .= &pretty_print_internal (@_);
5075 ################################################################
5077 # See if a target exists.
5080 local ($target) = @_;
5081 return defined $targets{$target};
5084 # See if two conditionals are the same.
5085 sub conditional_same
5087 local ($cond1, $cond2) = @_;
5089 return (&conditional_true_when ($cond1, $cond2)
5090 && &conditional_true_when ($cond2, $cond1));
5093 # See if a conditional is true. Both arguments are conditional
5094 # strings. This returns true if the first conditional is true when
5095 # the second conditional is true.
5096 sub conditional_true_when
5098 local ($cond, $when) = @_;
5100 # Check the easy case first.
5106 # Check each component of $cond, which looks @COND1@@COND2@.
5107 foreach $comp (split ('@', $cond))
5109 # The way we split will give null strings between each
5113 if (index ($when, '@' . $comp . '@') == -1)
5122 # Check for an ambiguous conditional. This is called when a variable
5123 # or target is being defined conditionally. If we already know about
5124 # a definition that is true under the same conditions, then we have an
5126 sub check_ambiguous_conditional
5128 local ($var_name, $cond) = @_;
5129 local (@cond_vals) = split (' ', $conditional{$var_name});
5132 local ($vcond) = shift (@cond_vals);
5134 if (&conditional_true_when ($vcond, $cond)
5135 || &conditional_true_when ($cond, $vcond))
5137 &am_line_error ($var_name,
5138 "$var_name multiply defined in condition");
5143 # See if a variable exists. The first argument is the variable name,
5144 # and the optional second argument is the condition which we should
5145 # check. If no condition is given, we currently return true if the
5146 # variable is defined under any condition.
5147 sub variable_defined
5149 local ($var, $cond) = @_;
5150 if (defined $targets{$var})
5152 &am_line_error ($var, "\`$var' is target; expected variable");
5155 elsif (defined $contents{$var})
5157 if ($cond && $conditional{$var})
5159 # We have been asked to check for a particular condition,
5160 # and the variable is defined conditionally. We need to
5161 # look through the conditions under which the variable is
5162 # defined, and see if any of them match the conditional we
5163 # have been asked to check.
5164 local (@cond_vars) = split (' ', $conditional{$var});
5167 if (&conditional_same ($cond, shift (@cond_vars)))
5169 # Even a conditional examination is good enough
5170 # for us. FIXME: really should maintain examined
5171 # status on a per-condition basis.
5172 $content_seen{$var} = 1;
5178 # The variable is not defined for the given condition.
5182 $content_seen{$var} = 1;
5188 # Mark a variable as examined.
5189 sub examine_variable
5192 &variable_defined ($var);
5195 # Quote a value in order to put it in $conditional. We need to quote
5196 # spaces, and we need to handle null strings, so that we can later
5197 # retrieve values by splitting on space.
5202 $val =~ s/\t/\003/g;
5203 $val = "\002" if $val eq '';
5207 # Unquote a value in $conditional.
5208 sub unquote_cond_val
5212 $val =~ s/\003/\t/g;
5217 # Return the set of conditions for which a variable is defined.
5219 # If the variable is not defined conditionally, and is not defined in
5220 # terms of any variables which are defined conditionally, then this
5221 # returns the empty list.
5223 # If the variable is defined conditionally, but is not defined in
5224 # terms of any variables which are defined conditionally, then this
5225 # returns the list of conditions for which the variable is defined.
5227 # If the variable is defined in terms of any variables which are
5228 # defined conditionally, then this returns a full set of permutations
5229 # of the subvariable conditions. For example, if the variable is
5230 # defined in terms of a variable which is defined for @COND_TRUE@,
5231 # then this returns both @COND_TRUE@ and @COND_FALSE@. This is
5232 # because we will need to define the variable under both conditions.
5234 sub variable_conditions
5242 foreach $cond (&variable_conditions_sub ($var, '', ()))
5244 $uniqify{$cond} = 1;
5247 @uniq_list = sort keys %uniqify;
5248 # Note we cannot just do `return sort keys %uniqify', because this
5249 # function is sometimes used in a scalar context.
5253 # A subroutine of variable_conditions. We only return conditions
5254 # which are true for all the conditions in @PARENT_CONDS.
5255 sub variable_conditions_sub
5257 local ($var, $parent, @parent_conds) = @_;
5258 local (@new_conds) = ();
5260 if (defined $vars_scanned{$var})
5262 &am_line_error ($parent, "variable \`$var' recursively defined");
5265 $vars_scanned{$var} = 1;
5267 if (! $conditional{$var})
5269 foreach (split (' ', $contents{$var}))
5271 # If a comment seen, just leave.
5274 # Handle variable substitutions.
5275 if (/^\$\{(.*)\}$/ || /^\$\((.*)\)$/)
5278 &variable_conditions_sub ($1, $var, @parent_conds));
5282 # Now we want to return all permutations of the subvariable
5284 local (%allconds, $item);
5285 foreach $item (@new_conds)
5287 foreach (split ('@', $item))
5291 $allconds{$_ . '_TRUE'} = 1;
5295 # Unset our entry in vars_scanned. We only care about recursive
5297 delete $vars_scanned{$var};
5299 return &variable_conditions_permutations (sort keys %allconds);
5302 local (@this_conds) = ();
5303 local (@condvals) = split (' ', $conditional{$var});
5306 local ($cond) = shift (@condvals);
5307 local ($val) = &unquote_cond_val (shift (@condvals));
5312 local ($parent_cond);
5313 foreach $parent_cond (@parent_conds)
5315 if (! &conditional_true_when ($parent_cond, $cond))
5325 push (@this_conds, $cond);
5327 push (@parent_conds, $cond);
5328 local (@subvar_conds) = ();
5329 foreach (split (' ', $val))
5331 # If a comment seen, just leave.
5334 # Handle variable substitutions.
5335 if (/^\$\{(.*)\}$/ || /^\$\((.*)\)$/)
5337 push (@subvar_conds,
5338 &variable_conditions_sub ($1, $var, @parent_conds));
5341 pop (@parent_conds);
5343 # If there are no conditional subvariables, then we want to
5344 # return this condition. Otherwise, we want to return the
5345 # permutations of the subvariables.
5346 if (! @subvar_conds)
5348 push (@new_conds, $cond);
5352 push (@new_conds, &variable_conditions_reduce (@subvar_conds));
5356 # Unset our entry in vars_scanned. We only care about recursive
5358 delete $vars_scanned{$var};
5363 # If we are being called on behalf of another variable, we need to
5364 # return all possible permutations of the conditions. We have
5365 # already handled everything in @this_conds along with their
5366 # subvariables. We now need to add any permutations that are not
5369 foreach $this_cond (@this_conds)
5372 &variable_conditions_permutations (split('@', $this_cond));
5374 foreach $perm (@perms)
5378 foreach $scan (@this_conds)
5380 if (&conditional_true_when ($perm, $scan)
5381 || &conditional_true_when ($scan, $perm))
5392 local ($parent_cond);
5393 foreach $parent_cond (@parent_conds)
5395 if (! &conditional_true_when ($parent_cond, $perm))
5405 # This permutation was not already handled, and is valid
5407 push (@new_conds, $perm);
5414 # Subroutine for variable_conditions_sort
5415 sub variable_conditions_cmp
5421 return (length ($as) <=> length ($bs)
5425 # Sort a list of conditionals so that only the exclusive ones are
5426 # retained. For example, if both @COND1_TRUE@@COND2_TRUE@ and
5427 # @COND1_TRUE@ are in the list, discard the latter.
5428 sub variable_conditions_reduce
5430 local (@conds) = @_;
5433 foreach $cond (sort variable_conditions_cmp @conds)
5437 foreach $scan (@ret)
5439 if (&conditional_true_when ($cond, $scan))
5452 # Return a list of permutations of a conditional string.
5453 sub variable_conditions_permutations
5455 local (@comps) = @_;
5458 local ($comp) = shift (@comps);
5459 return &variable_conditions_permutations (@comps)
5461 local ($neg) = $comp;
5462 $neg =~ s/TRUE$/TRUEO/;
5463 $neg =~ s/FALSE$/TRUE/;
5464 $neg =~ s/TRUEO$/FALSE/;
5467 foreach $sub (&variable_conditions_permutations (@comps))
5469 push (@ret, '@' . $comp . '@' . $sub);
5470 push (@ret, '@' . $neg . '@' . $sub);
5474 push (@ret, '@' . $comp . '@');
5475 push (@ret, '@' . $neg . '@');
5480 # Warn if a variable is conditionally defined. This is called if we
5481 # are using the value of a variable.
5482 sub variable_conditionally_defined
5484 local ($var, $parent) = @_;
5485 if ($conditional{$var})
5489 &am_line_error ($parent,
5490 "warning: automake does not support conditional definition of $var in $parent");
5494 &am_line_error ($parent,
5495 "warning: automake does not support $var being defined conditionally")
5500 # Get the value of a variable. This just returns $contents, but warns
5501 # if the variable is conditionally defined.
5505 &variable_conditionally_defined ($var);
5506 return $contents{$var};
5509 # Convert a variable value to a list, split as whitespace. This will
5510 # recursively follow $(...) and ${...} inclusions. It preserves @...@
5511 # substitutions. If COND is 'all', then all values under all
5512 # conditions should be returned; if COND is a particular condition
5513 # (all conditions are surrounded by @...@) then only the value for
5514 # that condition should be returned; otherwise, warn if VAR is
5515 # conditionally defined. SCANNED is a global hash listing whose keys
5516 # are all the variables already scanned; it is an error to rescan a
5520 local ($var, $val, $cond) = @_;
5523 foreach (split (' ', $val))
5525 # If a comment seen, just leave.
5528 # Handle variable substitutions.
5529 if (/^\$\{([^}]*)\}$/ || /^\$\(([^)]*)\)$/)
5531 local ($varname) = $1;
5533 # If the user uses a losing variable name, just ignore it.
5534 # This isn't ideal, but people have requested it.
5535 next if ($varname =~ /\@.*\@/);
5539 if ($varname =~ /^([^:]*):([^=]*)=(.*)$/)
5543 ($from = $2) =~ s/(\W)/\\$1/g;
5547 @temp_list = &variable_value_as_list_worker ($1, $cond, $var);
5549 # Now rewrite the value if appropriate.
5552 grep (s/$from$/$to/, @temp_list);
5555 push (@result, @temp_list);
5566 # Return contents of variable as list, split as whitespace. This will
5567 # recursively follow $(...) and ${...} inclusions. It preserves @...@
5568 # substitutions. If COND is 'all', then all values under all
5569 # conditions should be returned; if COND is a particular condition
5570 # (all conditions are surrounded by @...@) then only the value for
5571 # that condition should be returned; otherwise, warn if VAR is
5572 # conditionally defined. If PARENT is specified, it is the name of
5573 # the including variable; this is only used for error reports.
5574 sub variable_value_as_list_worker
5576 local ($var, $cond, $parent) = @_;
5579 if (defined $targets{$var})
5581 &am_line_error ($var, "\`$var' is target; expected variable");
5583 elsif (! defined $contents{$var})
5585 &am_line_error ($parent, "variable \`$var' not defined");
5587 elsif (defined $vars_scanned{$var})
5589 # `vars_scanned' is a global we use to keep track of which
5590 # variables we've already examined.
5591 &am_line_error ($parent, "variable \`$var' recursively defined");
5593 elsif ($cond eq 'all' && $conditional{$var})
5595 $vars_scanned{$var} = 1;
5596 local (@condvals) = split (' ', $conditional{$var});
5600 local ($val) = &unquote_cond_val (shift (@condvals));
5601 push (@result, &value_to_list ($var, $val, $cond));
5604 elsif ($cond && $conditional{$var})
5606 $vars_scanned{$var} = 1;
5607 local (@condvals) = split (' ', $conditional{$var});
5611 local ($vcond) = shift (@condvals);
5612 local ($val) = &unquote_cond_val (shift (@condvals));
5613 if (&conditional_true_when ($vcond, $cond))
5615 # Warn if we have an ambiguity. It's hard to know how
5616 # to handle this case correctly.
5617 &variable_conditionally_defined ($var, $parent)
5620 push (@result, &value_to_list ($var, $val, $cond));
5626 $vars_scanned{$var} = 1;
5627 &variable_conditionally_defined ($var, $parent);
5628 $content_seen{$var} = 1;
5629 push (@result, &value_to_list ($var, $contents{$var}, $cond));
5632 # Unset our entry in vars_scanned. We only care about recursive
5634 delete $vars_scanned{$var};
5639 # This is just a wrapper for variable_value_as_list_worker that
5640 # initializes the global hash `vars_scanned'. This hash is used to
5641 # avoid infinite recursion.
5642 sub variable_value_as_list
5644 local ($var, $cond, $parent) = @_;
5646 return &variable_value_as_list_worker ($var, $cond, $parent);
5649 # Define a new variable, but only if not already defined.
5652 local ($var, $value) = @_;
5654 if (! defined $contents{$var})
5656 $output_vars .= $var . ' = ' . $value . "\n";
5657 $contents{$var} = $value;
5658 $content_seen{$var} = 1;
5660 elsif ($var_was_plus_eq{$var})
5662 &am_line_error ($var, "internally generated variable \`$var' was set with \`+='");
5666 # Like define_variable, but the value is a list, and the variable may
5667 # be defined conditionally. The second argument is the conditional
5668 # under which the value should be defined; this should be the empty
5669 # string to define the variable unconditionally. The third argument
5670 # is a list holding the values to use for the variable. The value is
5671 # pretty printed in the output file.
5672 sub define_pretty_variable
5674 local ($var, $cond, @value) = @_;
5675 if (! defined $contents{$var}
5676 || ($cond && ! &variable_defined ($var, $cond)))
5678 $contents{$var} = join (' ', @value);
5681 if ($conditional{$var})
5683 $conditional{$var} .= ' ';
5687 $conditional{$var} = '';
5689 $conditional{$var} .= ($cond
5691 . "e_cond_val ($contents{$var}));
5693 &pretty_print ($cond . $var . ' = ', $cond, @value);
5694 $content_seen{$var} = 1;
5698 # Like define_variable, but define a variable to be the configure
5699 # substitution by the same name.
5700 sub define_configure_variable
5703 local ($value) = '@' . $var . '@';
5704 &define_variable ($var, $value);
5707 # Define a compiler variable. We also handle defining the `LT'
5708 # version of the command when using libtool.
5709 sub define_compiler_variable
5711 local ($var, $ltcompile, $value) = @_;
5712 local ($name) = $var;
5713 &define_variable ($name, $value);
5714 &define_variable ('LT' . $name, $ltcompile . $value)
5718 # Define a variable that represents a program to run. If in Cygnus
5719 # mode, the program is searched for in the build (or source) tree.
5720 # Otherwise no searching is done at all. Arguments are:
5721 # * VAR Name of variable to define
5722 # * WHATDIR Either `src' or `build', depending on where program should
5723 # be found. (runtest is in srcdir!)
5724 # * SUBDIR Subdir of top-level dir
5725 # * PROGRAM Name of program
5726 # * OVERRIDE If specified, the name of the program to use when not in
5727 # Cygnus mode. Defaults to PROGRAM.
5728 sub define_program_variable
5730 local ($var, $whatdir, $subdir, $program, $override) = @_;
5734 $override = $program;
5739 local ($full) = ('$(top_' . $whatdir . 'dir)/../'
5740 . $subdir . '/' . $program);
5741 &define_variable ($var, ('`if test -f ' . $full
5742 . '; then echo ' . $full . '; else echo '
5743 . $program . '; fi`'));
5747 &define_variable ($var, $override);
5752 ################################################################
5754 # Read Makefile.am and set up %contents. Simultaneously copy lines
5755 # from Makefile.am into $output_trailer or $output_vars as
5756 # appropriate. NOTE we put rules in the trailer section. We want
5757 # user rules to come after our generated stuff.
5760 local ($amfile) = @_;
5763 open (AM_FILE, $amfile) || die "automake: couldn't open \`$amfile': $!\n";
5764 print "automake: reading $amfile\n" if $verbose;
5766 local ($saw_bk) = 0;
5767 local ($was_rule) = 0;
5768 local ($spacing) = '';
5769 local ($comment) = '';
5770 local ($last_var_name) = '';
5775 if (/$IGNORE_PATTERN/o)
5777 # Merely delete comments beginning with two hashes.
5779 elsif (/$WHITE_PATTERN/o)
5781 # Stick a single white line before the incoming macro or rule.
5785 elsif (/$COMMENT_PATTERN/o)
5787 # Stick comments before the incoming macro or rule. Make
5788 # sure a blank line preceeds first block of comments.
5789 $spacing = "\n" unless $blank;
5791 $comment .= $spacing . $_;
5800 $output_vars .= $comment . "\n";
5804 local ($is_ok_macro);
5808 unless substr ($_, -1, 1) eq "\n";
5810 # Don't look at MAINTAINER_MODE_TRUE here. That shouldn't be
5811 # used by users. @MAINT@ is an anachronism now.
5812 $_ =~ s/\@MAINT\@//g
5813 unless $seen_maint_mode;
5815 if (/$IGNORE_PATTERN/o)
5817 # Merely delete comments beginning with two hashes.
5819 elsif (/$WHITE_PATTERN/o)
5821 # Stick a single white line before the incoming macro or rule.
5823 &am_line_error ($., "blank line following trailing backslash")
5826 elsif (/$COMMENT_PATTERN/o)
5828 # Stick comments before the incoming macro or rule.
5829 $comment .= $spacing . $_;
5831 &am_line_error ($., "comment following trailing backslash")
5838 $output_trailer .= join ('', @conditional_stack) . $_;
5844 # Chop newline and backslash if this line is
5845 # continued. ensure trailing whitespace exists.
5848 $contents{$last_var_name} .= ' '
5849 unless $contents{$last_var_name} =~ /\s$/;
5850 $contents{$last_var_name} .= $_;
5851 if (@conditional_stack)
5853 $conditional{$last_var_name} .= "e_cond_val ($_);
5857 elsif (/$IF_PATTERN/o)
5859 &am_line_error ($., "$1 does not appear in AM_CONDITIONAL")
5860 if (! $configure_cond{$1});
5861 push (@conditional_stack, "\@" . $1 . "_TRUE\@");
5863 elsif (/$ELSE_PATTERN/o)
5865 if (! @conditional_stack)
5867 &am_line_error ($., "else without if");
5869 elsif ($conditional_stack[$#conditional_stack] =~ /_FALSE\@$/)
5871 &am_line_error ($., "else after else");
5875 $conditional_stack[$#conditional_stack]
5876 =~ s/_TRUE\@$/_FALSE\@/;
5879 elsif (/$ENDIF_PATTERN/o)
5881 if (! @conditional_stack)
5883 &am_line_error ($., "endif without if");
5887 pop @conditional_stack;
5890 elsif (/$RULE_PATTERN/o)
5894 if (defined $contents{$1}
5895 && (@conditional_stack
5896 ? ! defined $conditional{$1}
5897 : defined $conditional{$1}))
5900 "$1 defined both conditionally and unconditionally");
5902 # Value here doesn't matter; for targets we only note
5906 local ($cond_string) = join ('', @conditional_stack);
5907 if (@conditional_stack)
5909 if ($conditional{$1})
5911 &check_ambiguous_conditional ($1, $cond_string);
5912 $conditional{$1} .= ' ';
5916 $conditional{$1} = '';
5918 $conditional{$1} .= $cond_string . ' 1';
5920 $content_lines{$1} = $.;
5921 $output_trailer .= $comment . $spacing . $cond_string . $_;
5922 $comment = $spacing = '';
5925 # Check the rule for being a suffix rule. If so, store in
5928 local ($source_suffix);
5929 local ($object_suffix);
5931 if (($source_suffix, $object_suffix) = ($1 =~ $SUFFIX_RULE_PATTERN))
5933 $suffix_rules{$source_suffix} = $object_suffix;
5934 print "Sources ending in .$source_suffix become .$object_suffix\n" if $verbose;
5935 $source_suffix_pattern = "(" . join('|', keys %suffix_rules) . ")";
5938 # FIXME: make sure both suffixes are in SUFFIXES? Or set
5939 # SUFFIXES from suffix_rules?
5941 elsif (($is_ok_macro = /$MACRO_PATTERN/o)
5942 || /$BOGUS_MACRO_PATTERN/o)
5944 # Found a macro definition.
5946 $last_var_name = $1;
5947 if (defined $contents{$1}
5948 && (@conditional_stack
5949 ? ! defined $conditional{$1}
5950 : defined $conditional{$1}))
5953 "$1 defined both conditionally and unconditionally");
5956 if ($3 ne '' && substr ($3, -1) eq "\\")
5958 $value = substr ($3, 0, length ($3) - 1);
5966 if (! defined $contents{$last_var_name})
5968 # The first assignment to a macro sets the line
5969 # number. Ideally I suppose we would associate line
5970 # numbers with random bits of text.
5971 $content_lines{$last_var_name} = $.;
5973 # If first assignment, set `+=' indicator.
5974 $var_was_plus_eq{$last_var_name} =
5976 && ! defined $am_var_defs{$last_var_name});
5981 if (! defined $contents{$last_var_name}
5982 && defined $am_var_defs{$last_var_name})
5984 $contents{$last_var_name} = $am_var_defs{$last_var_name};
5986 $contents{$last_var_name} .= ' ' . $value;
5990 $contents{$last_var_name} = $value;
5992 local ($cond_string) = join ('', @conditional_stack);
5993 if (@conditional_stack)
5997 if ($conditional{$last_var_name})
6001 # If we're adding to the conditional, and it
6002 # exists, then we might want to simply replace
6003 # the old value with the new one.
6004 local (@new_vals, @cond_vals);
6005 @cond_vals = split (' ', $conditional{$last_var_name});
6008 local ($vcond) = shift (@cond_vals);
6009 push (@new_vals, $vcond);
6010 if (&conditional_same ($vcond, $cond_string))
6013 $val = (&unquote_cond_val (shift (@cond_vals))
6015 push (@new_vals, "e_cond_val ($val));
6019 push (@new_vals, shift (@cond_vals));
6024 $conditional{$last_var_name}
6025 = join (' ', @new_vals);
6031 &check_ambiguous_conditional ($last_var_name,
6033 $conditional{$last_var_name} .= ' ';
6039 $conditional{$last_var_name} = '';
6040 $val = $contents{$last_var_name};
6044 $conditional{$last_var_name} .= ($cond_string
6046 . "e_cond_val ($val));
6050 # FIXME: this doesn't always work correctly; it will group
6051 # all comments for a given variable, no matter where
6053 $am_vars{$last_var_name} = $comment . $spacing;
6054 $def_type{$last_var_name} = ($type eq ':') ? ':' : '';
6055 push (@var_list, $last_var_name);
6056 $comment = $spacing = '';
6060 &am_line_error ($., "bad macro name \`$last_var_name'")
6063 elsif (/$INCLUDE_PATTERN/o)
6067 if ($path =~ s/^\$\(top_srcdir\)\///)
6069 push (@include_stack, "\$\(top_srcdir\)/$path");
6073 $path =~ s/\$\(srcdir\)\///;
6074 push (@include_stack, "\$\(srcdir\)/$path");
6075 $path = $relative_dir . "/" . $path;
6077 &read_am_file ($path);
6081 # This isn't an error; it is probably a continued rule.
6082 # In fact, this is what we assume.
6084 $output_trailer .= ($comment . $spacing
6085 . join ('', @conditional_stack) . $_);
6086 $comment = $spacing = '';
6093 $output_trailer .= $comment;
6095 &am_error ("unterminated conditionals: " . join (' ', @conditional_stack))
6096 if (@conditional_stack);
6099 # A helper for read_main_am_file which initializes configure variables
6100 # and variables from header-vars.am. This is a subr so we can call it
6102 sub define_standard_variables
6104 # Compute relative location of the top object directory.
6105 local (@topdir) = ();
6106 foreach (split (/\//, $relative_dir))
6108 next if $_ eq '.' || $_ eq '';
6115 push (@topdir, '..');
6118 @topdir = ('.') if ! @topdir;
6120 $top_builddir = join ('/', @topdir);
6122 ($build_rx = $top_builddir) =~ s/(\W)/\\$1/g;
6123 $output_vars .= &file_contents_with_transform
6124 ('s/\@top_builddir\@/' . $build_rx . '/g;',
6127 # Generate some useful variables when AC_CANONICAL_* used. FIXME:
6128 # this should use generic %configure_vars method.
6129 if ($seen_canonical)
6131 local ($curs, %vars);
6132 $vars{'host_alias'} = 'host_alias';
6133 $vars{'host_triplet'} = 'host';
6134 if ($seen_canonical == $AC_CANONICAL_SYSTEM)
6136 $vars{'build_alias'} = 'build_alias';
6137 $vars{'build_triplet'} = 'build';
6138 $vars{'target_alias'} = 'target_alias';
6139 $vars{'target_triplet'} = 'target';
6141 foreach $curs (sort keys %vars)
6143 $output_vars .= "$curs = \@$vars{$curs}\@\n";
6144 $contents{$curs} = "\@$vars{$curs}\@";
6149 foreach $curs (sort keys %configure_vars)
6151 &define_configure_variable ($curs);
6155 # Read main am file.
6156 sub read_main_am_file
6158 local ($amfile) = @_;
6160 # The keys here are variables we want to dump at the end of this
6161 # function. The values are corresponding comments.
6162 local (%am_vars) = ();
6163 local (@var_list) = ();
6164 local (%def_type) = ();
6166 # We want to predefine as many variables as possible. This lets
6167 # the user set them with `+=' in Makefile.am. However, we don't
6168 # want these initial definitions to end up in the output quite
6169 # yet. So we adopt a hack: read the `.am' file twice, throwing
6170 # away the output the first time. We also squirrel away a list of
6171 # all the variables defined by the .am file so that we know which
6172 # ones to remove from the content list.
6175 &define_standard_variables;
6176 local (%saved_contents) = %contents;
6178 # Read user file, but discard text of variable assignments we just
6181 &read_am_file ($amfile);
6183 # Now dump the variables that were defined. We do it in the same
6184 # order in which they were defined (skipping duplicates).
6186 foreach $curs (@var_list)
6188 next if $done{$curs};
6191 $output_vars .= $am_vars{$curs};
6192 if ($conditional{$curs})
6194 local (@cond_vals) = split (' ', $conditional{$curs});
6197 local ($vcond) = shift (@cond_vals);
6198 local ($val) = &unquote_cond_val (shift (@cond_vals));
6199 $output_vars .= ($vcond . $curs
6200 . ' ' . $def_type{$curs} . '= '
6206 $output_vars .= ($curs . ' ' . $def_type{$curs} . '= '
6207 . $contents{$curs} . "\n");
6211 # Generate copyright header for generated Makefile.in.
6212 local ($ov) = $output_vars;
6213 $output_vars = ("# $in_file_name generated automatically by automake "
6214 . $VERSION . " from $am_file_name\n");
6215 $output_vars .= $gen_copyright;
6217 # Now go through and delete all the variables that the user did
6220 foreach $var (keys %saved_contents)
6222 if ($contents{$var} eq $saved_contents{$var})
6224 delete $contents{$var};
6228 # Re-read the standard variables, and this time keep their
6229 # contributions to the output. Then add the user's output to the
6231 &define_standard_variables;
6232 $output_vars .= $ov;
6236 ################################################################
6238 sub initialize_global_constants
6240 # Values for AC_CANONICAL_*
6241 $AC_CANONICAL_HOST = 1;
6242 $AC_CANONICAL_SYSTEM = 2;
6244 # Associative array of standard directory names. Entry is TRUE if
6245 # corresponding directory should be installed during
6246 # 'install-exec' phase.
6264 # Commonly found files we look for and automatically include in
6268 "README", "THANKS", "TODO", "NEWS", "COPYING", "COPYING.LIB",
6269 "INSTALL", "ABOUT-NLS", "ChangeLog", "configure", "configure.in",
6270 "config.guess", "config.sub", "AUTHORS", "BACKLOG", "ABOUT-GNU",
6271 "libversion.in", "mdate-sh", "mkinstalldirs", "install-sh",
6272 'texinfo.tex', "ansi2knr.c", "ansi2knr.1", 'elisp-comp',
6273 'ylwrap', 'acinclude.m4', @libtoolize_files,
6277 # Commonly used files we auto-include, but only sometimes.
6280 "aclocal.m4", "acconfig.h", "config.h.top",
6281 "config.h.bot", "stamp-h.in", 'stamp-vti'
6285 -a, --add-missing add missing standard files to package
6286 --amdir=DIR directory storing config files
6287 --build-dir=DIR directory where build being done (for dependencies)
6288 -c, --copy with -a, copy missing files (default is symlink)
6289 --cygnus assume program is part of Cygnus-style tree
6290 --foreign set strictness to foreign
6291 --gnits set strictness to gnits
6292 --gnu set strictness to gnu
6293 --help print this help, then exit
6294 -i, --include-deps include generated dependencies in Makefile.in
6295 --no-force only update Makefile.in's that are out of date
6296 -o DIR, --output-dir=DIR
6297 put generated Makefile.in's into DIR
6298 --srcdir-name=DIR name used for srcdir (for dependencies)
6299 -v, --verbose verbosely list files processed
6300 --version print version number, then exit\n";
6302 # Copyright on generated Makefile.ins.
6304 # Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
6305 # This Makefile.in is free software; the Free Software Foundation
6306 # gives unlimited permission to copy and/or distribute it,
6307 # with or without modifications, as long as this notice is preserved.
6309 # This program is distributed in the hope that it will be useful,
6310 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
6311 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
6312 # PARTICULAR PURPOSE.
6315 # Ignore return result from chmod, because it might give an error
6316 # if we chmod a symlink.
6317 $dist_header = "\t" . '-chmod -R a+r $(distdir)' . "\n";
6318 $dist{'dist-bzip2'} = ("\t"
6319 . '$(TAR) ch$(AMTARFLAGS)f - $(distdir) | bzip --best -c > $(distdir).bz2'
6321 $dist{'dist-tarZ'} = ("\t"
6322 . '$(TAR) ch$(AMTARFLAGS)f - $(distdir) | compress -c > $(distdir).tar.Z'
6324 $dist{'dist-shar'} = ("\t"
6325 . 'shar $(distdir) | gzip > $(distdir).shar.gz'
6327 $dist{'dist-zip'} = "\t" . 'zip -rq $(distdir).zip $(distdir)' . "\n";
6328 $dist{'dist'} = ("\t"
6329 . 'tar ch$(AMTARFLAGS)f - $(distdir) | GZIP=$(GZIP_ENV) gzip -c > $(distdir).tar.gz'
6331 $dist_trailer = "\t" . '-rm -rf $(distdir)' . "\n";
6334 # (Re)-Initialize per-Makefile.am variables.
6335 sub initialize_per_input
6337 # These two variables are used when generating each Makefile.in.
6338 # They hold the Makefile.in until it is ready to be printed.
6341 $output_trailer = '';
6343 $output_header = '';
6345 # Suffixes found during a run.
6348 # This holds the contents of a Makefile.am, as parsed by
6352 # This holds the names which are targets. These also appear in
6356 # This maps a variable name onto a flag. The flag is true iff the
6357 # variable was first defined with `+='.
6358 %var_was_plus_eq = ();
6360 # This holds definitions of all variables defined in .am files.
6361 # This is used during startup to determine which variables can be
6362 # assigned with `+='.
6365 # For a variable or target which is defined conditionally, this
6366 # holds an array of the conditional values. The array is composed
6367 # of pairs of condition strings (the variables which configure
6368 # will substitute) and values (the value of a target is
6369 # meaningless). For an unconditional variable, this is empty.
6372 # This holds the line numbers at which various elements of
6373 # %contents are defined.
6374 %content_lines = ();
6376 # This holds a 1 if a particular variable was examined.
6379 # This is the conditional stack.
6380 @conditional_stack = ();
6382 # This holds the set of included files.
6383 @include_stack = ();
6385 # This holds the "relative directory" of the current Makefile.in.
6386 # Eg for src/Makefile.in, this is "src".
6389 # This holds a list of files that are included in the
6393 # List of dependencies for the obvious targets.
6409 # A list of files deleted by `maintainer-clean'.
6410 @maintainer_clean_files = ();
6412 # These are pretty obvious, too. They are used to define the
6413 # SOURCES and OBJECTS variables.
6417 # This hash maps object file names onto their corresopnding source
6418 # file names. This is used to ensure that each object is created
6419 # by a single source file.
6422 # These variables track inclusion of various compile-related .am
6423 # files. $included_generic_compile is TRUE if the basic code has
6424 # been included. $included_knr_compile is TRUE if the ansi2knr
6425 # code has been included. $included_libtool_compile is TRUE if
6426 # libtool support has been included.
6427 $included_generic_compile = 0;
6428 $included_knr_compile = 0;
6429 $included_libtool_compile = 0;
6431 # TRUE if install targets should work recursively.
6432 $recursive_install = 0;
6437 # Strictness levels.
6438 $strictness = $default_strictness;
6439 $strictness_name = $default_strictness_name;
6441 # Options from AUTOMAKE_OPTIONS.
6444 # Whether or not dependencies are handled. Can be further changed
6445 # in handle_options.
6446 $use_dependencies = $cmdline_use_dependencies;
6449 $local_maint_charset = $maint_charset;
6451 # All yacc and lex source filenames for this directory. Use
6452 # filenames instead of raw count so that multiple instances are
6453 # counted correctly (eg one yacc file can appear in multiple
6454 # programs without harm).
6458 # This is a list of all targets to run during "make dist".
6461 # Keys in this hash are the basenames of files which must depend
6463 %de_ansi_files = ();
6465 # This maps the source extension of a suffix rule to its
6466 # corresponding output extension.
6469 # This is the name of the recursive `all' target to use.
6470 $all_target = 'all-recursive';
6472 # This keeps track of which extensions we've seen (that we care
6474 %extension_seen = ();
6476 # This is random scratch space for the language finish functions.
6477 # Don't randomly overwrite it; examine other uses of keys first.
6478 %language_scratch = ();
6482 ################################################################
6484 # Return contents of a file from $am_dir, automatically skipping
6485 # macros or rules which are already known. Runs command on each line
6486 # as it is read; this command can modify $_.
6487 sub file_contents_with_transform
6489 local ($command, $basename) = @_;
6490 local ($file) = $am_dir . '/' . $basename . '.am';
6492 if ($command ne '' && substr ($command, -1) ne ';')
6494 die "automake: programming error in file_contents_with_transform: $command\n";
6497 open (FC_FILE, $file)
6498 || die "automake: installation error: cannot open \`$file'\n";
6500 # print "automake: reading $file\n" if $verbose;
6502 local ($was_rule) = 0;
6503 local ($result_vars) = '';
6504 local ($result_rules) = '';
6505 local ($comment) = '';
6506 local ($spacing) = "\n";
6507 local ($skipping) = 0;
6512 $_ =~ s/\@MAINTAINER_MODE_TRUE\@//g
6513 unless $seen_maint_mode;
6515 $had_chars = length ($_) && $_ ne "\n";
6517 # If the transform caused all the characters to go away, then
6518 # ignore the line. Why do this? Because in Perl 4, a "next"
6519 # inside of an eval doesn't affect a loop outside the eval.
6520 # So we can't pass in a "transform" that uses next. We used
6521 # to do this. "Empty" also means consisting of a single
6523 next if $had_chars && ($_ eq '' || $_ eq "\n");
6525 if (/$IGNORE_PATTERN/o)
6527 # Merely delete comments beginning with two hashes.
6529 elsif (/$WHITE_PATTERN/o)
6531 # Stick a single white line before the incoming macro or rule.
6533 &am_line_error ($., "blank line following trailing backslash")
6536 elsif (/$COMMENT_PATTERN/o)
6538 # Stick comments before the incoming macro or rule.
6539 $comment .= $spacing . $_;
6541 &am_line_error ($., "comment following trailing backslash")
6548 $result_rules .= $_ if ! $skipping;
6552 $result_vars .= $_ if ! $skipping;
6556 elsif (/$RULE_PATTERN/o)
6560 $skipping = defined $contents{$1};
6561 $result_rules .= $comment . $spacing . $_ if ! $skipping;
6562 $comment = $spacing = '';
6565 elsif (/$MACRO_PATTERN/o)
6567 # Found a variable reference.
6569 $skipping = defined $contents{$1};
6570 $result_vars .= $comment . $spacing . $_ if ! $skipping;
6571 $comment = $spacing = '';
6573 print STDERR "automake: programming error: .am macro \`$1' with trailing backslash\n"
6575 $am_var_defs{$1} = $3;
6579 # This isn't an error; it is probably a continued rule.
6580 # In fact, this is what we assume.
6582 $result_rules .= $comment . $spacing . $_ if ! $skipping;
6583 $comment = $spacing = '';
6589 return $result_vars . $result_rules . $comment;
6592 # Like file_contents_with_transform, but no transform.
6595 return &file_contents_with_transform ('', @_);
6598 # Find all variable prefixes that are used for install directories. A
6599 # prefix `zar' qualifies iff:
6600 # * `zardir' is a variable.
6601 # * `zar_PRIMARY' is a variable.
6602 sub am_primary_prefixes
6604 local ($primary, $can_dist, @prefixes) = @_;
6606 local (%valid, $varname);
6607 grep ($valid{$_} = 0, @prefixes);
6608 $valid{'EXTRA'} = 0;
6609 foreach $varname (keys %contents)
6611 if ($varname =~ /^(dist_|nodist_)?(.*)_$primary$/)
6613 if (($1 ne '' && ! $can_dist)
6614 || (! defined $valid{$2}
6615 && ! &variable_defined ($2 . 'dir')
6616 # Note that a configure variable is always
6617 # legitimate. It is natural to name such
6618 # variables after the primary, so we explicitly
6620 && ! defined $configure_vars{$varname}))
6622 &am_line_error ($varname, "invalid variable \`$varname'");
6626 # Ensure all extended prefixes are actually used.
6627 $valid{$1 . $2} = 1;
6635 # Handle `where_HOW' variable magic. Does all lookups, generates
6636 # install code, and possibly generates code to define the primary
6637 # variable. The first argument is the name of the .am file to munge,
6638 # the second argument is the primary variable (eg HEADERS), and all
6639 # subsequent arguments are possible installation locations. Returns
6640 # list of all values of all _HOW targets.
6642 # FIXME: this should be rewritten to be cleaner. It should be broken
6643 # up into multiple functions.
6645 # Usage is: am_install_var (OPTION..., file, HOW, where...)
6650 local ($do_clean) = 0;
6651 local ($do_require) = 1;
6652 local ($can_dist) = 0;
6653 local ($default_dist) = 0;
6656 if (defined $configure_vars{'LIBTOOL'})
6658 # Transform '@LIBTOOL ...@' to '$(LIBTOOL) ...'
6659 $ltxform = 's/\@LIBTOOL([^\@]*)\@/\$(LIBTOOL) $1/;';
6663 # Delete '@LIBTOOL ...@'
6664 $ltxform = 's/\@LIBTOOL([^\@]*)\@//;';
6670 $cygxform = 's/\@EXEEXT\@//g;';
6674 $cygxform = 's/\@EXEEXT\@/\$(EXEEXT)/g;';
6679 if ($args[0] eq '-clean')
6683 elsif ($args[0] eq '-noextra')
6687 elsif ($args[0] eq '-candist')
6691 elsif ($args[0] eq '-defaultdist')
6696 elsif ($args[0] !~ /^-/)
6703 local ($file, $primary, @prefixes) = @args;
6706 local (@result) = ();
6708 # Now that configure substitutions are allowed in where_HOW
6709 # variables, it is an error to actually define the primary. We
6710 # allow `JAVA', as it is customarily used to mean the Java
6711 # interpreter. This is but one of several Java hacks.
6712 &am_line_error ($primary, "\`$primary' is an anachronism")
6713 if &variable_defined ($primary) && $primary ne 'JAVA';
6716 # Look for misspellings. It is an error to have a variable ending
6717 # in a "reserved" suffix whose prefix is unknown, eg
6718 # "bni_PROGRAMS". However, unusual prefixes are allowed if a
6719 # variable of the same name (with "dir" appended) exists. For
6720 # instance, if the variable "zardir" is defined, then
6721 # "zar_PROGRAMS" becomes valid. This is to provide a little extra
6722 # flexibility in those cases which need it.
6723 local (%valid) = &am_primary_prefixes ($primary, $can_dist, @prefixes);
6725 # If a primary includes a configure substitution, then the EXTRA_
6726 # form is required. Otherwise we can't properly do our job.
6727 local ($require_extra);
6728 local ($warned_about_extra) = 0;
6730 local ($clean_file) = $file . '-clean';
6733 local ($nodir_name);
6734 foreach $X (sort keys %valid)
6736 $one_name = $X . '_' . $primary;
6737 if (&variable_defined ($one_name))
6739 # If files should be distributed, do so.
6742 if (($default_dist && $one_name !~ /^nodist_/)
6743 || (! $default_dist && $one_name =~ /^dist_/))
6745 &push_dist_common ('$(' . $one_name . ')');
6747 ($nodir_name = $X) =~ s/^(dist|nodist)_//;
6754 # Append actual contents of where_PRIMARY variable to
6757 foreach $rcurs (&variable_value_as_list ($one_name, 'all'))
6759 # Skip configure substitutions. Possibly bogus.
6760 if ($rcurs =~ /^\@.*\@$/)
6764 if (! $warned_about_extra)
6766 $warned_about_extra = 1;
6768 &am_line_error ($one_name,
6769 "\`$one_name' contains configure substitution, but shouldn't");
6773 # Check here to make sure variables defined in
6774 # configure.in do not imply that EXTRA_PRIMARY
6776 elsif (! defined $configure_vars{$one_name})
6778 $require_extra = $one_name
6785 push (@result, $rcurs);
6788 # "EXTRA" shouldn't be used when generating clean targets,
6789 # all, or install targets.
6792 # We used to warn if EXTRA_FOO was defined uselessly,
6793 # but this was annoying.
6797 # A blatant hack: we rewrite each _PROGRAMS primary to
6798 # include EXEEXT when in Cygwin32 mode.
6799 if ($seen_exeext && $primary eq 'PROGRAMS')
6801 local (@conds) = &variable_conditions ($one_name);
6802 local (@one_binlist);
6804 # FIXME: this definitely loses aesthetically; it
6805 # redefines $ONE_NAME. Instead we should arrange for
6806 # variable definitions to be output later, instead of
6812 foreach $rcurs (&variable_value_as_list ($one_name, ''))
6814 if ($rcurs =~ /\./ || $rcurs =~ /^\@.*\@$/)
6816 push (@one_binlist, $rcurs);
6820 push (@one_binlist, $rcurs . '$(EXEEXT)');
6824 delete $contents{$one_name};
6825 &define_pretty_variable ($one_name, '', @one_binlist);
6830 local ($condvals) = '';
6831 foreach $cond (@conds)
6834 local (@condval) = &variable_value_as_list ($one_name,
6836 foreach $rcurs (@condval)
6838 if ($rcurs =~ /\./ || $rcurs =~ /^\@.*\@$/)
6840 push (@one_binlist, $rcurs);
6844 push (@one_binlist, $rcurs . '$(EXEEXT)');
6848 push (@condvals, $cond);
6849 push (@condvals, join (' ', @one_binlist));
6852 delete $contents{$one_name};
6856 $cond = shift (@condvals);
6857 local (@val) = split (' ', shift (@condvals));
6858 &define_pretty_variable ($one_name, $cond, @val);
6866 &file_contents_with_transform ('s/\@DIR\@/' . $X . '/go;'
6870 push (@clean, $X . $primary);
6871 &push_phony_cleaners ($X . $primary);
6876 push (@check, '$(' . $one_name . ')');
6880 push (@used, '$(' . $one_name . ')');
6882 if ($X eq 'noinst' || $X eq 'check')
6884 # Objects which don't get installed by default.
6889 &file_contents_with_transform ('s/\@DIR\@/' . $X . '/g;'
6890 . 's/\@NDIR\@/' . $nodir_name . '/go;'
6891 . $ltxform . $cygxform,
6894 push (@uninstall, 'uninstall-' . $X . $primary);
6895 push (@phony, 'uninstall-' . $X . $primary);
6896 push (@installdirs, '$(DESTDIR)$(' . $X . 'dir)');
6897 if (defined $exec_dir_p{$X} ? $exec_dir_p{$X} : ($X =~ /exec/))
6899 push (@install_exec, 'install-' . $X . $primary);
6900 push (@phony, 'install-' . $X . $primary);
6904 push (@install_data, 'install-' . $X . $primary);
6905 push (@phony, 'install-' . $X . $primary);
6910 # The JAVA variable is used as the name of the Java interpreter.
6911 if (@used && $primary ne 'JAVA')
6914 &define_pretty_variable ($primary, '', @used);
6915 $output_vars .= "\n";
6918 if ($require_extra && ! &variable_defined ('EXTRA_' . $primary))
6920 &am_line_error ($require_extra,
6921 "\`$require_extra' contains configure substitution, but \`EXTRA_$primary' not defined");
6924 # Push here because PRIMARY might be configure time determined.
6925 push (@all, '$(' . $primary . ')')
6926 if @used && $primary ne 'JAVA';
6932 ################################################################
6934 # This variable is local to the "require file" set of functions.
6935 @require_file_paths = ();
6937 # Verify that the file must exist in the current directory. Usage:
6938 # require_file (isconfigure, line_number, strictness, file) strictness
6939 # is the strictness level at which this file becomes required. Must
6940 # set require_file_paths before calling this function.
6941 # require_file_paths is set to hold a single directory (the one in
6942 # which the first file was found) before return.
6943 sub require_file_internal
6945 local ($is_configure, $line, $mystrict, @files) = @_;
6946 local ($file, $fullfile);
6947 local ($found_it, $errfile, $errdir);
6950 foreach $file (@files)
6953 foreach $dir (@require_file_paths)
6957 $fullfile = $relative_dir . "/" . $file;
6958 $errdir = $relative_dir unless $errdir;
6962 $fullfile = $dir . "/" . $file;
6963 $errdir = $dir unless $errdir;
6966 # Use different name for "error filename". Otherwise on
6967 # an error the bad file will be reported as eg
6968 # `../../install-sh' when using the default
6970 $errfile = $errdir . '/' . $file;
6975 # FIXME: Once again, special-case `.'.
6976 &push_dist_common ($file)
6977 if $dir eq $relative_dir || $dir eq '.';
6985 # Prune the path list.
6986 @require_file_paths = $save_dir;
6990 if ($strictness >= $mystrict)
6992 local ($trailer) = '';
6993 local ($suppress) = 0;
6995 # Only install missing files according to our desired
6997 local ($message) = "required file \`$errfile' not found";
7002 # Maybe run libtoolize.
7004 && grep ($_ eq $file, @libtoolize_files)
7005 && system ('libtoolize', '--automake'))
7007 $message = "installing \`$errfile'";
7009 $trailer = "; cannot run \`libtoolize': $!";
7011 elsif (-f ($am_dir . '/' . $file))
7013 # Install the missing file. Symlink if we
7014 # can, copy if we must. Note: delete the file
7015 # first, in case it is a dangling symlink.
7016 $message = "installing \`$errfile'";
7017 # Windows Perl will hang if we try to delete a
7018 # file that doesn't exist.
7019 unlink ($errfile) if -f $errfile;
7020 if ($symlink_exists && ! $copy_missing)
7022 if (! symlink ($am_dir . '/' . $file, $errfile))
7025 $trailer = "; error while making link: $!\n";
7028 elsif (system ('cp', $am_dir . '/' . $file, $errfile))
7031 $trailer = "\n error while copying\n";
7036 local ($save) = $exit_status;
7039 # FIXME: allow actual file to be specified.
7040 &am_conf_line_error ('configure.in', $line,
7041 "$message$trailer");
7045 &am_line_error ($line, "$message$trailer");
7047 $exit_status = $save if $suppress;
7053 # Like require_file_with_line, but error messages refer to
7054 # configure.in, not the current Makefile.am.
7055 sub require_file_with_conf_line
7057 @require_file_paths = '.';
7058 &require_file_internal (1, @_);
7061 sub require_file_with_line
7063 @require_file_paths = '.';
7064 &require_file_internal (0, @_);
7069 @require_file_paths = '.';
7070 &require_file_internal (0, '', @_);
7073 # Require a file that is also required by Autoconf. Looks in
7074 # configuration path, as specified by AC_CONFIG_AUX_DIR.
7075 sub require_config_file
7077 @require_file_paths = @config_aux_path;
7078 &require_file_internal (1, '', @_);
7079 local ($dir) = $require_file_paths[0];
7080 @config_aux_path = @require_file_paths;
7083 $config_aux_dir = '.';
7087 $config_aux_dir = '$(top_srcdir)/' . $dir;
7091 # Assumes that the line number is in Makefile.am.
7092 sub require_conf_file_with_line
7094 @require_file_paths = @config_aux_path;
7095 &require_file_internal (0, @_);
7096 local ($dir) = $require_file_paths[0];
7097 @config_aux_path = @require_file_paths;
7100 $config_aux_dir = '.';
7104 $config_aux_dir = '$(top_srcdir)/' . $dir;
7108 # Assumes that the line number is in Makefile.am.
7109 sub require_conf_file_with_conf_line
7111 @require_file_paths = @config_aux_path;
7112 &require_file_internal (1, @_);
7113 local ($dir) = $require_file_paths[0];
7114 @config_aux_path = @require_file_paths;
7117 $config_aux_dir = '.';
7121 $config_aux_dir = '$(top_srcdir)/' . $dir;
7125 ################################################################
7127 # Push a list of files onto dist_common.
7128 sub push_dist_common
7130 local (@files) = @_;
7133 foreach $file (@files)
7135 $dist_common{$file} = 1;
7139 # Push a list of clean targets onto phony.
7140 sub push_phony_cleaners
7144 foreach $target ('mostly', 'dist', '', 'maintainer-')
7146 push (@phony, $target . 'clean-' . $base);
7153 $strictness_name = $_[0];
7154 if ($strictness_name eq 'gnu')
7158 elsif ($strictness_name eq 'gnits')
7160 $strictness = $GNITS;
7162 elsif ($strictness_name eq 'foreign')
7164 $strictness = $FOREIGN;
7168 die "automake: level \`$strictness_name' not recognized\n";
7173 ################################################################
7175 # Return directory name of file.
7181 ($sub = $file) =~ s,/+[^/]+$,,g;
7182 $sub = '.' if $sub eq $file;
7186 # Return file name of a file.
7192 ($sub = $file) =~s,^.*/+,,g;
7196 # Ensure a file exists.
7201 open (TOUCH, ">> $file");
7205 # Glob something. Do this to avoid indentation screwups everywhere we
7206 # want to glob. Gross!
7213 ################################################################
7215 # Print an error message and set exit status.
7218 warn "automake: ${am_file}.am: ", join (' ', @_), "\n";
7224 local ($symbol, @args) = @_;
7226 if ($symbol && "$symbol" ne '-1')
7228 local ($file) = "${am_file}.am";
7230 if ($symbol =~ /^\d+$/)
7232 # SYMBOL is a line number, so just add the colon.
7233 $file .= ':' . $symbol;
7235 elsif (defined $content_lines{$symbol})
7237 # SYMBOL is a variable defined in Makefile.am, so add the
7238 # line number we saved from there.
7239 $file .= ':' . $content_lines{$symbol};
7241 elsif (defined $configure_vars{$symbol})
7243 # SYMBOL is a variable defined in configure.in, so add the
7244 # appropriate line number.
7245 $file = $configure_vars{$symbol};
7249 # Couldn't find the line number.
7251 warn $file, ": ", join (' ', @args), "\n";
7260 # Like am_error, but while scanning configure.in.
7263 # FIXME: can run in subdirs.
7264 warn "automake: configure.in: ", join (' ', @_), "\n";
7268 # Error message with line number referring to configure.in.
7269 sub am_conf_line_error
7271 local ($file, $line, @args) = @_;
7275 warn "$file: $line: ", join (' ', @args), "\n";
7280 &am_conf_error (@args);
7284 # Warning message with line number referring to configure.in.
7285 # Does not affect exit_status
7286 sub am_conf_line_warning
7288 local ($saved_exit_status) = $exit_status;
7289 &am_conf_line_error (@_);
7290 $exit_status = $saved_exit_status;
7293 # Tell user where our aclocal.m4 is, but only once.
7294 sub keyed_aclocal_warning
7297 warn "automake: macro \`$key' can be generated by \`aclocal'\n";
7300 # Print usage information.
7303 print "Usage: automake [OPTION] ... [Makefile]...\n\n";
7304 print "Generate Makefile.in for autoconf from Makefile.am\n";
7306 print "\nFiles which are automatically distributed, if found:\n";
7307 $~ = "USAGE_FORMAT";
7308 local ($last, $iter, @lcomm);
7310 foreach $iter (sort ((@common_files, @common_sometimes)))
7312 push (@lcomm, $iter) unless $iter eq $last;
7316 local ($one, $two, $three, $four, $i, $max);
7317 $max = int (($#lcomm + 1) / 4);
7319 for ($i = 0; $i < $max; ++$i)
7322 $two = $lcomm[$max + $i];
7323 $three = $lcomm[2 * $max + $i];
7324 $four = $lcomm[3 * $max + $i];
7328 local ($mod) = ($#lcomm + 1) % 4;
7331 $one = $lcomm[$max];
7332 $two = ($mod > 1) ? $lcomm[2 * $max] : '';
7333 $three = ($mod > 2) ? $lcomm[3 * $max] : '';
7334 $four = ($mod > 3) ? $lcomm[4 * $max] : '';
7338 print "\nReport bugs to <bug-automake\@gnu.org>.\n";
7343 format USAGE_FORMAT =
7344 @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<
7345 $one, $two, $three, $four