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.
71 # These constants are returned by lang_*_rewrite functions.
72 # LANG_SUBDIR means that the resulting object file should be in a
73 # subdir if the source file is. In this case the file name cannot
74 # have `..' components.
81 # Variables global to entire run.
83 # TRUE if we should always generate Makefile.in.
84 $force_generation = 1;
86 # Strictness level as set on command line.
87 $default_strictness = $GNU;
89 # Name of strictness level, as set on command line.
90 $default_strictness_name = 'gnu';
92 # This is TRUE if GNU make specific automatic dependency generation
93 # code should be included in generated Makefile.in.
94 $cmdline_use_dependencies = 1;
96 # This is the name of a dependency makefile bit (usually for inclusion in a
97 # SMakefile or similar); empty if not set.
100 # TRUE if in verbose mode.
103 # This holds our (eventual) exit status. We don't actually exit until
104 # we have processed all input files.
107 # From the Perl manual.
108 $symlink_exists = (eval 'symlink ("", "");', $@ eq '');
110 # TRUE if missing standard files should be installed.
113 # TRUE if we should copy missing files; otherwise symlink if possible.
116 # Files found by scanning configure.in for LIBOBJS.
119 # True if AM_C_PROTOTYPES appears in configure.in.
120 $am_c_prototypes = 0;
122 # Names used in AC_CONFIG_HEADER call. @config_fullnames holds the
123 # name which appears in AC_CONFIG_HEADER, colon and all.
124 # @config_names holds the file names. @config_headers holds the '.in'
125 # files. Ordinarily these are similar, but they can be different if
126 # the weird "NAME:FILE" syntax is used.
127 @config_fullnames = ();
129 @config_headers = ();
130 # Line number at which AC_CONFIG_HEADER appears in configure.in.
131 $config_header_line = 0;
133 # Directory where output files go. Actually, output files are
134 # relative to this directory.
135 $output_directory = '.';
137 # Relative location of top build directory.
140 # Absolute location of top build directory.
141 $build_directory = '';
143 # Name of srcdir as given in build directory's Makefile. For
147 # List of Makefile.am's to process, and their corresponding outputs.
151 # List of files in AC_OUTPUT without Makefile.am, and their outputs.
152 @other_input_files = ();
153 # Line number at which AC_OUTPUT seen.
156 # List of directories to search for configure-required files. This
157 # can be set by AC_CONFIG_AUX_DIR.
158 @config_aux_path = ('.', '..', '../..');
159 $config_aux_dir = '';
161 # Whether AC_PROG_MAKE_SET has been seen in configure.in.
164 # Whether AM_GNU_GETTEXT has been seen in configure.in.
166 # Line number at which AM_GNU_GETTEXT seen.
167 $ac_gettext_line = 0;
169 # Whether ALL_LINGUAS has been seen.
173 # Line number at which it appears.
174 $all_linguas_line = 0;
176 # 1 if AC_PROG_INSTALL seen.
177 $seen_prog_install = 0;
179 # Whether AC_PATH_XTRA has been seen in configure.in.
182 # TRUE if AC_DECL_YYTEXT was seen.
183 $seen_decl_yytext = 0;
185 # TRUE if we've seen AC_CANONICAL_(HOST|SYSTEM). The presence of
186 # AC_CHECK_TOOL also sets this.
189 # TRUE if we've seen AC_ARG_PROGRAM.
192 # TRUE if we've seen AC_PROG_LIBTOOL.
196 # Files installed by libtoolize.
197 @libtoolize_files = ('ltconfig', 'ltmain.sh', 'config.guess', 'config.sub');
199 # TRUE if we've seen AM_MAINTAINER_MODE.
200 $seen_maint_mode = 0;
202 # TRUE if we've seen PACKAGE and VERSION.
206 # Actual version we've seen.
207 $package_version = '';
209 # Line number where we saw version definition.
210 $package_version_line = 0;
212 # TRUE if we've seen AM_PATH_LISPDIR.
215 # TRUE if we've seen AC_EXEEXT.
218 # TRUE if we've seen AC_OBJEXT.
221 # TRUE if we've seen AC_ENABLE_MULTILIB.
224 # Hash table of discovered configure substitutions. Keys are names,
225 # values are `FILE:LINE' strings which are used by error message
227 %configure_vars = ();
229 # This is used to keep track of which variable definitions we are
230 # scanning. It is only used in certain limited ways, but it has to be
231 # global. It is declared just for documentation purposes.
234 # Charsets used by maintainer and in distribution. MAINT_CHARSET is
235 # handled in a funny way: if seen in the top-level Makefile.am, it is
236 # used for every directory which does not specify a different value.
237 # The rationale here is that some directories (eg gettext) might be
238 # distributions of other packages, and thus require their own charset
239 # info. However, the DIST_CHARSET must be the same for the entire
240 # package; it can only be set at top-level.
241 # FIXME: this yields bugs when rebuilding. What to do? Always
242 # read (and sometimes discard) top-level Makefile.am?
244 $dist_charset = 'utf8'; # recode doesn't support this yet.
246 # Name of input file ("Makefile.in") and output file ("Makefile.am").
247 # These have no directory components.
251 # TRUE if --cygnus seen.
254 # Keys of this hash are names of dependency files to ignore.
255 %omit_dependencies = ();
257 # Hash table of AM_CONDITIONAL variables seen in configure.
258 %configure_cond = ();
260 # Map from obsolete macros to hints for new macros.
261 # If you change this, change the corresponding list in aclocal.in.
262 # FIXME: should just put this into a single file.
265 'AC_FEATURE_CTYPE', "use \`AC_HEADER_STDC'",
266 'AC_FEATURE_ERRNO', "add \`strerror' to \`AC_REPLACE_FUNCS(...)'",
267 'AC_FEATURE_EXIT', '',
268 'AC_SYSTEM_HEADER', '',
270 # Note that we do not handle this one, because it is still run
271 # from AM_CONFIG_HEADER. So we deal with it specially in
273 # 'AC_CONFIG_HEADER', "use \`AM_CONFIG_HEADER'",
275 'fp_C_PROTOTYPES', "use \`AM_C_PROTOTYPES'",
276 'fp_PROG_CC_STDC', "use \`AM_PROG_CC_STDC'",
277 'fp_PROG_INSTALL', "use \`AC_PROG_INSTALL'",
278 'fp_WITH_DMALLOC', "use \`AM_WITH_DMALLOC'",
279 'fp_WITH_REGEX', "use \`AM_WITH_REGEX'",
280 'gm_PROG_LIBTOOL', "use \`AM_PROG_LIBTOOL'",
281 'jm_MAINTAINER_MODE', "use \`AM_MAINTAINER_MODE'",
282 'md_TYPE_PTRDIFF_T', "use \`AM_TYPE_PTRDIFF_T'",
283 'ud_PATH_LISPDIR', "use \`AM_PATH_LISPDIR'",
284 'ud_GNU_GETTEXT', "use \`AM_GNU_GETTEXT'",
286 # Now part of autoconf proper, under a different name.
287 'AM_FUNC_FNMATCH', "use \`AC_FUNC_FNMATCH'",
288 'fp_FUNC_FNMATCH', "use \`AC_FUNC_FNMATCH'",
289 'AM_SANITY_CHECK_CC', "automatically done by \`AC_PROG_CC'",
290 'AM_PROG_INSTALL', "use \`AC_PROG_INSTALL'",
291 'AM_EXEEXT', "use \`AC_EXEEXT'",
292 'AM_CYGWIN32', "use \`AC_CYGWIN32'",
293 'AM_MINGW32', "use \`AC_MINGW32'",
295 # These aren't quite obsolete.
299 # Regexp to match the above macros.
300 $obsolete_rx = '(' . join ('|', keys %obsolete_macros) . ')';
302 # This maps extensions onto language names.
305 # This maps languages names onto properties.
310 # Initialize global constants and our list of languages that are
311 # internally supported.
312 &initialize_global_constants;
314 ®ister_language ('c', 'ansi-p=1', 'autodep=',
316 ®ister_language ('cxx', 'linker=CXXLINK', 'autodep=CXX',
317 'c++', 'cc', 'cpp', 'cxx', 'C');
318 ®ister_language ('objc', 'linker=OBJCLINK', 'autodep=OBJC',
320 ®ister_language ('header',
321 'h', 'H', 'hxx', 'h++', 'hh', 'hpp', 'inc');
322 ®ister_language ('yacc', 'ansi-p=1',
324 ®ister_language ('yaccxx', 'linker=CXXLINK',
325 'y++', 'yy', 'yxx', 'ypp');
326 ®ister_language ('lex', 'ansi-p=1',
328 ®ister_language ('lexxx', 'linker=CXXLINK',
329 'l++', 'll', 'lxx', 'lpp');
330 ®ister_language ('asm',
332 ®ister_language ('f77', 'linker=F77LINK',
334 ®ister_language ('ppf77', 'linker=F77LINK',
336 ®ister_language ('ratfor', 'linker=F77LINK',
338 ®ister_language ('java', 'linker=GCJLINK', 'autodep=GCJ',
342 # Parse command line.
343 &parse_arguments (@ARGV);
345 # Do configure.in scan only once.
348 die "automake: no \`Makefile.am' found or specified\n"
351 # If --generate-deps was given, we don't do anything else
355 die "automake: Must specify --include-deps (or -i) when generating\n"
356 if $use_dependencies;
357 die "automake: Must provide --build-dir when generating\n"
358 if ! $build_directory;
359 die "automake: Must provide --srcdir-name when generating\n"
362 open (GDEP, ">$output_directory/.dep_segment")
363 || die "automake: Could not open `$output_directory/.dep_segment': $!\n";
365 &handle_dependencies;
366 print GDEP $output_rules;
372 # Now do all the work on each file.
373 foreach $am_file (@input_files)
375 if (! -f ($am_file . '.am'))
377 &am_error ("\`" . $am_file . ".am' does not exist");
381 &generate_makefile ($output_files{$am_file}, $am_file);
385 &am_conf_error ("AC_PROG_INSTALL must be used in configure.in")
386 if (! $seen_prog_install);
391 ################################################################
393 # Parse command line.
396 local (@arglist) = @_;
399 &set_strictness ('gnu');
403 if ($arglist[0] eq "--version")
405 print "automake (GNU $PACKAGE) $VERSION\n\n";
406 print "Copyright (C) 1999 Free Software Foundation, Inc.\n";
407 print "This is free software; see the source for copying conditions. There is NO\n";
408 print "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n";
409 print "Written by Tom Tromey <tromey\@cygnus.com>\n";
413 elsif ($arglist[0] eq "--help")
417 elsif ($arglist[0] =~ /^--amdir=(.+)$/)
421 elsif ($arglist[0] eq '--amdir')
423 &require_argument (@arglist);
425 $am_dir = $arglist[0];
427 elsif ($arglist[0] =~ /^--build-dir=(.+)$/)
430 $build_directory = $1 . '/';
432 elsif ($arglist[0] eq '--build-dir')
434 &require_argument (@arglist);
437 $build_directory = $arglist[0] . '/';
439 elsif ($arglist[0] =~ /^--srcdir-name=(.+)$/)
443 elsif ($arglist[0] eq '--srcdir-name')
445 &require_argument (@arglist);
447 $srcdir_name = $arglist[0];
449 elsif ($arglist[0] eq '--gnu')
451 &set_strictness ('gnu');
453 elsif ($arglist[0] eq '--gnits')
455 &set_strictness ('gnits');
457 elsif ($arglist[0] eq '--cygnus')
461 elsif ($arglist[0] eq '--foreign')
463 &set_strictness ('foreign');
465 elsif ($arglist[0] eq '--include-deps' || $arglist[0] eq '-i')
467 $cmdline_use_dependencies = 0;
469 elsif ($arglist[0] eq '--generate-deps')
473 elsif ($arglist[0] eq '--no-force')
475 $force_generation = 0;
477 elsif ($arglist[0] =~ /^--output-dir=(.*)$/)
479 # Set output directory.
480 $output_directory = $1;
482 elsif ($arglist[0] eq '--output-dir' || $arglist[0] eq '-o')
484 &require_argument (@arglist);
486 $output_directory = $arglist[0];
488 elsif ($arglist[0] eq '--add-missing' || $arglist[0] eq '-a')
492 elsif ($arglist[0] eq '--copy' || $arglist[0] eq '-c')
496 elsif ($arglist[0] eq '--verbose' || $arglist[0] eq '-v')
500 elsif ($arglist[0] eq '--')
502 # Stop option processing.
504 push (@input_files, @arglist);
507 elsif ($arglist[0] =~ /^-/)
509 die "automake: unrecognized option -- \`$arglist[0]'\nTry \`automake --help' for more information.\n";
513 # Handle $local:$input syntax. Note that we only examine
514 # the first ":" file to see if it is automake input; the
515 # rest are just taken verbatim. We still keep all the
516 # files around for dependency checking, however.
517 local ($local, $input, @rest) = split (/:/, $arglist[0]);
524 # Strip .in; later on .am is tacked on. That is how
525 # the automake input file is found. Maybe not the
526 # best way, but it is easy to explain. FIXME: should
527 # be error if .in is missing.
530 push (@input_files, $input);
531 $output_files{$input} = join (':', ($local, @rest));
537 # Take global strictness from whatever we currently have set.
538 $default_strictness = $strictness;
539 $default_strictness_name = $strictness_name;
542 # Ensure argument exists, or die.
545 local ($arg, @arglist) = @_;
546 die "automake: no argument given for option \`$arg'\n"
550 ################################################################
552 # Generate a Makefile.in given the name of the corresponding Makefile and
553 # the name of the file output by config.status.
554 sub generate_makefile
556 local ($output, $makefile) = @_;
558 ($am_file_name = $makefile) =~ s/^.*\///;
559 $in_file_name = $am_file_name . '.in';
560 $am_file_name .= '.am';
562 # $OUTPUT is encoded. If it contains a ":" then the first element
563 # is the real output file, and all remaining elements are input
564 # files. We don't scan or otherwise deal with these input file,
565 # other than to mark them as dependencies. See scan_configure for
567 local (@secondary_inputs);
568 ($output, @secondary_inputs) = split (/:/, $output);
570 &initialize_per_input;
571 $relative_dir = &dirname ($output);
572 $am_relative_dir = &dirname ($makefile);
574 # At the toplevel directory, we might need config.guess, config.sub
575 # or libtool scripts (ltconfig and ltmain.sh).
576 if ($relative_dir eq '.')
578 # libtool requires some files.
579 &require_conf_file_with_conf_line ($libtool_line, $FOREIGN,
583 # AC_CANONICAL_HOST and AC_CANONICAL_SYSTEM need config.guess and
585 &require_config_file ($FOREIGN, 'config.guess', 'config.sub')
589 # We still need Makefile.in here, because sometimes the `dist'
590 # target doesn't re-run automake.
591 if ($am_relative_dir eq $relative_dir)
593 # Only distribute the files if they are in the same subdir as
594 # the generated makefile.
595 &push_dist_common ($in_file_name, $am_file_name);
597 push (@sources, '$(SOURCES)')
598 if &variable_defined ('SOURCES');
599 push (@objects, '$(OBJECTS)')
600 if &variable_defined ('OBJECTS');
602 &read_main_am_file ($makefile . '.am');
605 # Fatal error. Just return, so we can continue with next file.
609 # Check first, because we might modify some state.
611 &check_gnu_standards;
612 &check_gnits_standards;
614 &handle_configure ($output, $makefile, @secondary_inputs);
621 &handle_built_sources;
623 # This must be run after all the sources are scanned.
626 # Re-init SOURCES and OBJECTS. FIXME: other code shouldn't depend
627 # on this (but currently does).
628 $contents{'SOURCES'} = join (' ', @sources);
629 $contents{'OBJECTS'} = join (' ', @objects);
630 &define_pretty_variable ('DIST_SOURCES', '', @dist_sources);
641 &handle_minor_options;
642 &handle_dist ($makefile);
643 &handle_dependencies;
646 &handle_merge_targets ($output);
653 if (! -d ($output_directory . '/' . $am_relative_dir))
655 mkdir ($output_directory . '/' . $am_relative_dir, 0755);
658 local ($out_file) = $output_directory . '/' . $makefile . ".in";
659 if (! $force_generation && -e $out_file)
661 local ($am_time) = (stat ($makefile . '.am'))[9];
662 local ($in_time) = (stat ($out_file))[9];
663 # FIXME: should cache these times.
664 local ($conf_time) = (stat ('configure.in'))[9];
665 # FIXME: how to do unsigned comparison?
666 if ($am_time < $in_time || $am_time < $conf_time)
673 local ($acl_time) = (stat _)[9];
674 return if ($am_time < $acl_time);
678 if (! open (GM_FILE, "> " . $out_file))
680 warn "automake: ${am_file}.in: cannot write: $!\n";
684 print "automake: creating ", $makefile, ".in\n" if $verbose;
686 print GM_FILE $output_vars;
687 # We make sure that `all:' is the first target.
688 print GM_FILE $output_all;
689 print GM_FILE $output_header;
690 print GM_FILE $output_rules;
691 print GM_FILE $output_trailer;
696 ################################################################
698 # Handle AUTOMAKE_OPTIONS variable. Return 1 on error, 0 otherwise.
701 if (&variable_defined ('AUTOMAKE_OPTIONS'))
703 foreach (&variable_value_as_list ('AUTOMAKE_OPTIONS', ''))
706 if ($_ eq 'gnits' || $_ eq 'gnu' || $_ eq 'foreign')
708 &set_strictness ($_);
710 elsif ($_ eq 'cygnus')
716 # An option like "../lib/ansi2knr" is allowed. With
717 # no path prefix, we assume the required programs are
718 # in this directory. We save the actual option for
720 $options{'ansi2knr'} = $_;
722 elsif ($_ eq 'no-installman' || $_ eq 'no-installinfo'
723 || $_ eq 'dist-shar' || $_ eq 'dist-zip'
724 || $_ eq 'dist-tarZ' || $_ eq 'dist-bzip2'
725 || $_ eq 'dejagnu' || $_ eq 'no-texinfo.tex'
726 || $_ eq 'readme-alpha' || $_ eq 'check-news')
728 # Explicitly recognize these.
730 elsif ($_ eq 'no-dependencies')
732 $use_dependencies = 0;
734 elsif (/([0-9]+)\.([0-9]+)([a-z])?/)
736 # Got a version number.
738 local ($rmajor, $rminor, $ralpha) = ($1, $2, $3);
740 if ($VERSION !~ /([0-9]+)\.([0-9]+)([a-z])?/)
743 "automake: programming error: version is incorrect\n";
746 local ($tmajor, $tminor, $talpha) = ($1, $2, $3);
748 # 2.0 is better than 1.0.
749 # 1.2 is better than 1.1.
750 # 1.2a is better than 1.2.
751 if ($rmajor > $tmajor
752 || ($rmajor == $tmajor && $rminor > $tminor)
753 || ($rminor == $tminor && $rminor == $tminor
754 && $ralpha gt $talpha))
756 &am_line_error ('AUTOMAKE_OPTIONS',
757 "require version $_, only have $VERSION");
763 &am_line_error ('AUTOMAKE_OPTIONS',
764 "option \`" . $_ . "\' not recognized");
769 if ($strictness == $GNITS)
771 $options{'readme-alpha'} = 1;
772 $options{'check-news'} = 1;
778 # Return object extension. Just once, put some code into the output.
779 # Argument is the name of the output file
780 sub get_object_extension
784 # Maybe require libtool library object files.
785 local ($extension) = '.o';
786 $extension = '.$(OBJEXT)' if $seen_objext;
787 $extension = '.lo' if ($out =~ /\.la$/);
789 if (! $included_generic_compile)
793 if (&variable_defined ('CONFIG_HEADER'))
796 foreach $one_hdr (split (' ', &variable_value ('CONFIG_HEADER')))
799 ($var = &dirname ($one_hdr)) =~ s/(\W)/\\$1/g;
800 $xform .= ' ' if $xform;
801 $xform .= '-I' . $var;
804 $xform = 's/\@CONFIG_INCLUDE_SPEC\@/' . $xform . '/go;';
805 $output_vars .= &file_contents_with_transform ($xform,
808 $xform = (($use_dependencies
809 ? 's/^NOTDEPEND.*$//;'
811 . ($seen_objext ? 's/^OBJEXT//;' : 's/^OBJEXT.*$//;'));
812 $output_rules .= &file_contents_with_transform ($xform, 'compile');
814 &push_phony_cleaners ('compile');
816 # If using X, include some extra variable definitions. NOTE
817 # we don't want to force these into CFLAGS or anything,
818 # because not all programs will necessarily use X.
822 foreach $var ('X_CFLAGS', 'X_LIBS', 'X_EXTRA_LIBS', 'X_PRE_LIBS')
824 &define_configure_variable ($var);
828 push (@suffixes, '.c', '.o', '.S', '.s');
829 push (@suffixes, '.obj') if $seen_objext;
830 push (@clean, 'compile');
832 $included_generic_compile = 1;
835 if ($seen_libtool && ! $included_libtool_compile)
837 # Output the libtool compilation rules.
839 &file_contents_with_transform
840 ($use_dependencies ? 's/^NOTDEPEND.*$//;' : 's/^NOTDEPEND//;',
843 &push_phony_cleaners ('libtool');
845 push (@suffixes, '.lo');
846 push (@clean, 'libtool');
848 $included_libtool_compile = 1;
851 # Check for automatic de-ANSI-fication.
852 if (defined $options{'ansi2knr'})
854 $extension = '$U' . $extension;
855 if (! $included_knr_compile)
857 if (! $am_c_prototypes)
859 &am_line_error ('AUTOMAKE_OPTIONS',
860 "option \`ansi2knr' in use but \`AM_C_PROTOTYPES' not in configure.in");
861 &keyed_aclocal_warning ('AM_C_PROTOTYPES');
862 # Only give this error once.
863 $am_c_prototypes = 1;
866 # Only require ansi2knr files if they should appear in
868 if ($options{'ansi2knr'} eq 'ansi2knr')
870 &require_file_with_line ('AUTOMAKE_OPTIONS', $FOREIGN,
871 'ansi2knr.c', 'ansi2knr.1');
872 $output_rules .= &file_contents ('kr-extra');
873 push (@clean, 'krextra');
874 &push_phony_cleaners ('krextra');
877 # Generate rules to build ansi2knr. If it is in some
878 # other directory, then generate dependencies but have the
879 # rule just run elsewhere.
880 $objext = $seen_objext ? ".$(OBJEXT)" : ".o";
881 $output_rules .= ($options{'ansi2knr'} . ': '
882 . $options{'ansi2knr'} . $objext . "\n");
883 if ($options{'ansi2knr'} eq 'ansi2knr')
885 $output_rules .= ("\t\$(LINK) ansi2knr" . $objext
887 . "ansi2knr" . $objext
888 . ": \$(CONFIG_HEADER)\n\n");
892 $output_rules .= ("\tcd " . &dirname ($options{'ansi2knr'})
893 . " && \$(MAKE) \$(AM_MAKEFLAGS) "
895 # This is required for non-GNU makes.
896 $output_rules .= ($options{'ansi2knr'} . $objext . ":\n");
897 $output_rules .= ("\tcd " . &dirname ($options{'ansi2knr'})
898 . " && \$(MAKE) \$(AM_MAKEFLAGS)"
899 . " ansi2knr" . $objext . "\n\n");
902 # Make sure ansi2knr can be found: if no path specified,
904 if ($options{'ansi2knr'} eq 'ansi2knr')
906 # Substitution from AM_C_PROTOTYPES. This makes it be
907 # built only when necessary.
908 &define_configure_variable ('ANSI2KNR');
909 # ansi2knr needs to be built before subdirs, so unshift it.
910 unshift (@all, '$(ANSI2KNR)');
914 # Found in another directory.
915 &define_variable ("ANSI2KNR", $options{'ansi2knr'});
918 $output_rules .= &file_contents ('clean-kr');
921 &push_phony_cleaners ('kr');
923 $included_knr_compile = 1;
930 # Call finish function for each language that was used.
933 local ($ext, $name, $lang, %done);
935 foreach $ext (sort keys %extension_seen)
937 $lang = $extension_map{$ext};
938 next if defined $done{$lang};
940 $non_c = 0 if $lang !~ /(objc|cxx|f77|ratfor)$/;
942 # Compute the function name of the finisher and then call it.
943 $name = 'lang_' . $lang . '_finish';
947 # If the project is entirely C++ or entirely Fortran 77, don't
948 # bother with the C stuff. But if anything else creeps in, then use
950 if (! $non_c || scalar keys %suffix_rules > 0)
952 local ($ltcompile, $ltlink) = &libtool_compiler;
954 &define_configure_variable ('CFLAGS');
955 &define_compiler_variable ('COMPILE', $ltcompile,
956 '$(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)');
957 &define_variable ('CCLD', '$(CC)');
958 &define_variable ('LINK', $ltlink . '$(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@');
962 # Output a rule to build from a YACC source. The output from YACC is
963 # compiled with C or C++, depending on the extension of the YACC file.
964 sub output_yacc_build_rule
966 local ($yacc_suffix, $use_ylwrap, $c_suffix) = @_;
969 ($suffix = $yacc_suffix) =~ tr/y/c/;
970 push (@suffixes, $yacc_suffix, $suffix);
972 # Generate rule for c/c++.
973 $output_rules .= "$yacc_suffix$suffix:\n\t";
977 $output_rules .= ('$(SHELL) $(YLWRAP)'
978 . ' "$(YACC)" $< y.tab.c $*' . $suffix
979 . ' y.tab.h $*.h -- $(AM_YFLAGS) $(YFLAGS)');
983 $output_rules .= ('$(YACC) $(AM_YFLAGS) $(YFLAGS) $< && mv y.tab.c $*'
985 . "\tif test -f y.tab.h; then \\\n"
986 . "\tif cmp -s y.tab.h \$*.h; then rm -f y.tab.h; else mv y.tab.h \$*.h; fi; \\\n"
989 $output_rules .= "\n";
992 sub output_lex_build_rule
994 local ($lex_suffix, $use_ylwrap) = @_;
997 ($c_suffix = $lex_suffix) =~ tr/l/c/;
998 push (@suffixes, $lex_suffix);
999 &define_configure_variable ('LEX_OUTPUT_ROOT');
1000 &define_configure_variable ('LEXLIB');
1001 $output_rules .= "$lex_suffix$c_suffix:\n\t";
1005 # Is the $@ correct here? If so, why not use it in the ylwrap
1006 # build rule for yacc above?
1007 $output_rules .= '$(SHELL) $(YLWRAP)'
1008 . ' "$(LEX)" $< $(LEX_OUTPUT_ROOT).c $@ -- $(AM_LFLAGS) $(LFLAGS)';
1012 $output_rules .= '$(LEX) $(AM_LFLAGS) $(LFLAGS) $< && mv $(LEX_OUTPUT_ROOT).c $@';
1014 $output_rules .= "\n";
1018 # Check to make sure a source defined in LIBOBJS is not explicitly
1019 # mentioned. This is a separate function (as opposed to being inlined
1020 # in handle_source_transform) because it isn't always appropriate to
1022 sub check_libobjs_sources
1024 local ($one_file, $unxformed) = @_;
1026 local ($prefix, $file, @files);
1027 foreach $prefix ('', 'EXTRA_', 'dist_', 'nodist_',
1028 'dist_EXTRA_', 'nodist_EXTRA_')
1030 if (&variable_defined ($prefix . $one_file . '_SOURCES'))
1032 @files = &variable_value_as_list (($prefix
1033 . $one_file . '_SOURCES'),
1036 elsif ($prefix eq '')
1038 @files = ($unxformed . '.c');
1045 foreach $file (@files)
1047 if (defined $libsources{$file})
1049 &am_line_error ($prefix . $one_file . '_SOURCES',
1050 "automatically discovered file \`$file' should not be explicitly mentioned");
1056 # Does much of the actual work for handle_source_transform.
1058 # object extension (e.g., `$U.lo')
1059 # list of source files to transform
1061 # first element is name of linker to use (empty string for default linker)
1062 # remaining elements are names of objects
1063 sub handle_single_transform_list
1065 local ($obj, @files) = @_;
1066 local (@result) = ();
1067 local ($nonansi_obj) = $obj;
1068 $nonansi_obj =~ s/_//g;
1069 local (%linkers_used) = ();
1072 # Turn sources into objects.
1075 # Skip things that look like configure substitutions.
1078 # If the source file is in a subdirectory then the `.o' is
1079 # put into the current directory.
1081 # Split file name into base and extension.
1082 local ($full, $directory, $base, $extension, $linker, $object);
1083 next if ! /^((.*)\/)?([^\/]*)\.(.*)$/;
1089 local ($lang) = $extension_map{$extension};
1092 &saw_extension ($extension);
1093 # Found the language, so see what it says.
1094 local ($subr) = 'lang_' . $lang . '_rewrite';
1095 # Note: computed subr call.
1096 local ($r) = & $subr ($base, $extension);
1097 # Skip this entry if we were asked not to process it.
1098 next if $r == $LANG_IGNORE;
1100 # Now extract linker and other info.
1101 $linker = $language_map{$lang . '-linker'};
1103 if ($language_map{$lang . '-ansi-p'})
1105 $object = $base . $obj;
1109 $object = $base . $nonansi_obj;
1112 # If rewrite said it was ok, put the object into a
1114 if ($r == $LANG_SUBDIR && $directory ne '')
1116 $object = $directory . '/' . $object;
1119 elsif ($extension =~ /^$source_suffix_pattern$/)
1121 # We just rewrite it. Maybe we should do more.
1122 $object = $base . '.' . $suffix_rules{$extension};
1127 # No error message here. Used to have one, but it was
1132 $linkers_used{$linker} = 1;
1134 push (@result, $object);
1136 if (defined $object_map{$object})
1138 if ($object_map{$object} ne $full)
1140 &am_error ("object \`$object' created by \`$full' and \`$object_map{$object}'");
1145 local (@dep_list) = ();
1146 $object_map{$object} = $full;
1148 # If file is in subdirectory, we need explicit
1150 if ($directory ne '')
1152 push (@dep_list, $full);
1155 # If resulting object is in subdir, we need to make
1156 # sure the subdir exists at build time.
1157 if ($object =~ /\//)
1159 push (@dep_list, $directory . '/.dirstamp');
1160 $output_rules .= ($directory . "/.dirstamp:\n"
1161 . "\t\@\$(mkinstalldirs) $directory\n"
1162 . "\t\@: > $directory/.dirstamp\n");
1165 &pretty_print_rule ($object . ':', "\t", @dep_list);
1168 # Transform .o or $o file into .P file (for automatic
1170 # FIXME: LANG_SUBDIR.
1171 $dep_files{'.deps/' . $base . '.P'} = 1;
1175 return (&resolve_linker (%linkers_used), @result);
1178 # Handle SOURCE->OBJECT transform for one program or library.
1180 # canonical (transformed) name of object to build
1181 # actual name of object to build
1182 # object extension (ie either `.o' or `$o'.
1183 # Return result is name of linker variable that must be used.
1184 # Empty return means just use `LINK'.
1185 sub handle_source_transform
1187 # one_file is canonical name. unxformed is given name. obj is
1189 local ($one_file, $unxformed, $obj) = @_;
1191 local ($linker) = '';
1193 if (&variable_defined ($one_file . "_OBJECTS"))
1195 &am_line_error ($one_file . '_OBJECTS',
1196 $one_file . '_OBJECTS', 'should not be defined');
1197 # No point in continuing.
1201 local (@files, @result, $prefix, $temp, $xpfx);
1202 local (%used_pfx) = ();
1203 foreach $prefix ('', 'EXTRA_', 'dist_', 'nodist_',
1204 'dist_EXTRA_', 'nodist_EXTRA_')
1206 # We are going to define _OBJECTS variables using the prefix.
1207 # Then we glom them all together. So we can't use the null
1208 # prefix here as we need it later.
1209 $xpfx = ($prefix eq '') ? 'am_' : $prefix;
1212 local ($var) = $prefix . $one_file . "_SOURCES";
1213 if (&variable_defined ($var))
1215 push (@sources, '$(' . $prefix . $one_file . "_SOURCES)");
1216 push (@objects, '$(' . $xpfx . $one_file . "_OBJECTS)")
1217 unless $prefix =~ /EXTRA_/;
1218 push (@dist_sources, '$(' . $prefix . $one_file . "_SOURCES)")
1219 unless $prefix =~ /^nodist_/;
1220 local (@conds) = &variable_conditions ($var);
1223 @files = &variable_value_as_list ($var, '');
1228 foreach $cond (@conds)
1230 @files = &variable_value_as_list ($var, $cond);
1231 ($temp, @result) = &handle_single_transform_list ($obj,
1233 $linker = $temp if $linker eq '';
1235 # Define _OBJECTS conditionally.
1236 &define_pretty_variable ($xpfx . $one_file . '_OBJECTS',
1238 unless $prefix =~ /EXTRA_/;
1241 # Keep track of which prefixes we saw.
1242 $used_pfx{$xpfx} = 1
1243 unless $prefix =~ /EXTRA_/;
1249 # Avoid defining needless variables.
1250 next if (scalar @files == 0);
1252 # Keep track of which prefixes we saw.
1253 $used_pfx{$xpfx} = 1
1254 unless $prefix =~ /EXTRA_/;
1256 ($temp, @result) = &handle_single_transform_list ($obj, @files);
1257 $linker = $temp if $linker eq '';
1258 &define_pretty_variable ($xpfx . $one_file . "_OBJECTS", '', @result)
1259 unless $prefix =~ /EXTRA_/;
1262 local (@keys) = sort keys %used_pfx;
1263 if (scalar @keys == 0)
1265 &define_variable ($one_file . "_SOURCES", $unxformed . ".c");
1266 push (@sources, $unxformed . '.c');
1267 push (@dist_sources, $unxformed . '.c');
1268 push (@objects, $unxformed . $obj);
1269 push (@files, $unxformed . '.c');
1271 ($temp, @result) = &handle_single_transform_list ($obj, @files);
1272 $linker = $temp if $linker eq '';
1273 &define_pretty_variable ($one_file . "_OBJECTS", '', @result)
1277 grep ($_ = '$(' . $_ . $one_file . '_OBJECTS)', @keys);
1278 &define_pretty_variable ($one_file . '_OBJECTS', '', @keys);
1284 # Handle the BUILT_SOURCES variable.
1285 sub handle_built_sources
1287 return unless &variable_defined ('BUILT_SOURCES');
1289 local (@sources) = &variable_value_as_list ('BUILT_SOURCES', 'all');
1291 foreach $s (@sources)
1295 # FIXME: is this really the right thing to do?
1296 &am_line_error ('BUILT_SOURCES',
1297 "\`BUILT_SOURCES' should not contain a configure substitution");
1302 # We don't care about the return value of this function. We just
1303 # want to make sure to update %dep_files with the contents of
1305 &handle_single_transform_list (".o", @sources);
1308 # Special-case @ALLOCA@ and @LIBOBJS@ in _LDADD or _LIBADD variables.
1309 # Also, generate _DEPENDENCIES variable if appropriate.
1311 # transformed name of object being built, or empty string if no object
1312 # name of _LDADD/_LIBADD-type variable to examine
1313 # boolean (lex_seen) which is true if a lex source file was seen in this
1314 # object. valid only for LDADDs, not LIBADDs.
1315 # Returns 1 if LIBOBJS seen, 0 otherwise.
1316 sub handle_lib_objects
1318 local ($xname, $var, $lex_seen) = @_;
1321 die "automake: programming error 1 in handle_lib_objects\n"
1322 if ! &variable_defined ($var);
1324 die "automake: programming error 2 in handle_lib_objects\n"
1325 if $lex_seen && $var =~ /LIBADD/;
1327 local (@conds) = &variable_conditions ($var);
1330 $ret = &handle_lib_objects_cond ($xname, $var, $lex_seen, '');
1336 foreach $cond (@conds)
1338 if (&handle_lib_objects_cond ($xname, $var, $lex_seen, $cond))
1348 # Subroutine of handle_lib_objects: handle a particular condition.
1349 sub handle_lib_objects_cond
1351 local ($xname, $var, $lex_seen, $cond) = @_;
1353 # We recognize certain things that are commonly put in LIBADD or
1356 local (@dep_list) = ();
1358 local ($seen_libobjs) = 0;
1359 local ($flagvar) = 0;
1361 foreach $lsearch (&variable_value_as_list ($var, $cond))
1363 # Skip -lfoo and -Ldir; these are explicitly allowed.
1364 next if $lsearch =~ /^-[lL]/;
1365 if (! $flagvar && $lsearch =~ /^-/)
1367 if ($var =~ /^(.*)LDADD$/)
1369 # Skip -dlopen and -dlpreopen; these are explicitly allowed.
1370 next if $lsearch =~ /^-dl(pre)?open$/;
1371 &am_line_error ($var, "linker flags such as \`$lsearch' belong in \`${1}LDFLAGS");
1375 # Only get this error once.
1377 &am_line_error ($var, "you cannot use linker flags such as \`$lsearch' in \`$var'");
1381 # Assume we have a file of some sort, and push it onto the
1382 # dependency list. Autoconf substitutions are not pushed;
1383 # rarely is a new dependency substituted into (eg) foo_LDADD
1384 # -- but "bad things (eg -lX11) are routinely substituted.
1385 # Note that LIBOBJS and ALLOCA are exceptions to this rule,
1386 # and handled specially below.
1387 push (@dep_list, $lsearch)
1388 unless $lsearch =~ /^\@.*\@$/;
1390 # Automatically handle @LIBOBJS@ and @ALLOCA@. Basically this
1391 # means adding entries to dep_files.
1392 if ($lsearch =~ /^\@(LT)?LIBOBJS\@$/)
1394 push (@dep_list, $lsearch);
1396 if (! keys %libsources)
1398 &am_line_error ($var, "\@$1" . "LIBOBJS\@ seen but never set in \`configure.in'");
1401 local ($iter, $rewrite);
1402 foreach $iter (keys %libsources)
1404 if ($iter =~ /\.([cly])$/)
1406 &saw_extension ($1);
1407 &saw_extension ('c');
1410 if ($iter =~ /\.h$/)
1412 &require_file_with_line ($var, $FOREIGN, $iter);
1414 elsif ($iter ne 'alloca.c')
1416 ($rewrite = $iter) =~ s/\.c$/.P/;
1417 $dep_files{'.deps/' . $rewrite} = 1;
1418 &require_file_with_line ($var, $FOREIGN, $iter);
1422 elsif ($lsearch =~ /^\@(LT)?ALLOCA\@$/)
1424 push (@dep_list, $lsearch);
1425 &am_line_error ($var,
1426 "\@$1" . "ALLOCA\@ seen but \`AC_FUNC_ALLOCA' not in \`configure.in'")
1427 if ! defined $libsources{'alloca.c'};
1428 $dep_files{'.deps/alloca.P'} = 1;
1429 &require_file_with_line ($var, $FOREIGN, 'alloca.c');
1430 &saw_extension ('c');
1434 if ($xname ne '' && ! &variable_defined ($xname . '_DEPENDENCIES', $cond))
1436 &define_pretty_variable ($xname . '_DEPENDENCIES', $cond, @dep_list);
1439 return $seen_libobjs;
1442 # Canonicalize a name, and check to make sure the non-canonical name
1443 # is never used. Returns canonical name. Arguments are name and a
1444 # list of suffixes to check for.
1445 sub check_canonical_spelling
1447 local ($name, @suffixes) = @_;
1448 local ($xname, $xt);
1450 ($xname = $name) =~ tr/A-Za-z0-9_/_/c;
1451 if ($xname ne $name)
1454 foreach $xt (@suffixes)
1456 &am_line_error ($name . $xt,
1457 "invalid variable \`" . $name . $xt
1458 . "'; should be \`" . $xname . $xt . "'")
1459 if &variable_defined ($name . $xt);
1466 # Handle C programs.
1469 local (@proglist) = &am_install_var ('-clean',
1470 'progs', 'PROGRAMS',
1471 'bin', 'sbin', 'libexec', 'pkglib',
1473 return if ! @proglist;
1475 # If a program is installed, this is required. We only want this
1476 # error to appear once.
1477 &am_conf_error ("AC_ARG_PROGRAM must be used in configure.in")
1478 unless $seen_arg_prog;
1481 local ($one_file, $xname, $munge);
1483 local ($seen_libobjs) = 0;
1484 foreach $one_file (@proglist)
1486 local ($obj) = &get_object_extension ($one_file);
1488 # Canonicalize names and check for misspellings.
1489 $xname = &check_canonical_spelling ($one_file, '_LDADD', '_LDFLAGS',
1490 '_SOURCES', '_OBJECTS',
1493 # FIXME: Using a trick to figure out if any lex sources appear
1494 # in our program; should use some cleaner method.
1495 local ($lex_num) = scalar (keys %lex_sources);
1496 local ($linker) = &handle_source_transform ($xname, $one_file, $obj);
1497 local ($lex_file_seen) = (scalar (keys %lex_sources) > $lex_num);
1500 if (&variable_defined ($xname . "_LDADD"))
1502 if (&handle_lib_objects ($xname, $xname . '_LDADD',
1512 # User didn't define prog_LDADD override. So do it.
1513 &define_variable ($xname . '_LDADD', '$(LDADD)');
1515 # This does a bit too much work. But we need it to
1516 # generate _DEPENDENCIES when appropriate.
1517 if (&variable_defined ('LDADD'))
1519 if (&handle_lib_objects ($xname, 'LDADD', $lex_file_seen))
1525 elsif (! &variable_defined ($xname . '_DEPENDENCIES'))
1527 &define_variable ($xname . '_DEPENDENCIES', '');
1532 if (&variable_defined ($xname . '_LIBADD'))
1534 &am_line_error ($xname . '_LIBADD',
1535 "use \`" . $xname . "_LDADD', not \`"
1536 . $xname . "_LIBADD'");
1539 if (! &variable_defined ($xname . '_LDFLAGS'))
1541 # Define the prog_LDFLAGS variable.
1542 &define_variable ($xname . '_LDFLAGS', '');
1545 # Determine program to use for link.
1547 if (&variable_defined ($xname . '_LINK'))
1549 $xlink = $xname . '_LINK';
1553 $xlink = $linker ? $linker : 'LINK';
1557 if ($seen_exeext && $one_file !~ /\./)
1559 $xexe = 's/\@EXEEXT\@/\$(EXEEXT)/g;';
1563 $xexe = 's/\@EXEEXT\@//g;';
1567 &file_contents_with_transform
1568 ('s/\@PROGRAM\@/' . $one_file . '/go;'
1569 . 's/\@XPROGRAM\@/' . $xname . '/go;'
1570 . 's/\@XLINK\@/' . $xlink . '/go;'
1575 if (&variable_defined ('LDADD') && &handle_lib_objects ('', 'LDADD', 0))
1582 foreach $one_file (@proglist)
1584 # Canonicalize names.
1585 ($xname = $one_file) =~ tr/A-Za-z0-9_/_/c;
1587 if (&variable_defined ($xname . '_LDADD'))
1589 &check_libobjs_sources ($xname, $xname . '_LDADD');
1591 elsif (&variable_defined ('LDADD'))
1593 &check_libobjs_sources ($xname, 'LDADD');
1601 sub handle_libraries
1603 local (@liblist) = &am_install_var ('-clean',
1604 'libs', 'LIBRARIES',
1605 'lib', 'pkglib', 'noinst', 'check');
1606 return if ! @liblist;
1608 local (%valid) = &am_primary_prefixes ('LIBRARIES', 0, 'lib', 'pkglib',
1610 if (! defined $configure_vars{'RANLIB'})
1613 foreach $key (keys %valid)
1615 if (&variable_defined ($key . '_LIBRARIES'))
1617 &am_line_error ($key . '_LIBRARIES', "library used but \`RANLIB' not defined in \`configure.in'");
1618 # Only get this error once. If this is ever printed,
1620 $configure_vars{'RANLIB'} = 'BUG';
1629 local ($seen_libobjs) = 0;
1630 foreach $onelib (@liblist)
1632 # Check that the library fits the standard naming convention.
1633 if ($onelib !~ /^lib.*\.a$/)
1635 # FIXME should put line number here. That means mapping
1636 # from library name back to variable name.
1637 &am_error ("\`$onelib' is not a standard library name");
1640 local ($obj) = &get_object_extension ($onelib);
1642 # Canonicalize names and check for misspellings.
1643 $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_SOURCES',
1644 '_OBJECTS', '_DEPENDENCIES');
1646 if (&variable_defined ($xlib . '_LIBADD'))
1648 if (&handle_lib_objects ($xlib, $xlib . '_LIBADD', 0))
1655 # Generate support for conditional object inclusion in
1657 &define_variable ($xlib . "_LIBADD", '');
1660 if (&variable_defined ($xlib . '_LDADD'))
1662 &am_line_error ($xlib . '_LDADD',
1663 "use \`" . $xlib . "_LIBADD', not \`"
1664 . $xlib . "_LDADD'");
1667 # Make sure we at look at this.
1668 &examine_variable ($xlib . '_DEPENDENCIES');
1670 &handle_source_transform ($xlib, $onelib, $obj);
1673 &file_contents_with_transform ('s/\@LIBRARY\@/' . $onelib . '/go;'
1681 foreach $onelib (@liblist)
1683 # Canonicalize names.
1684 ($xlib = $onelib) =~ tr/A-Za-z0-9_/_/c;
1685 if (&variable_defined ($xlib . '_LIBADD'))
1687 &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
1692 &define_variable ('AR', 'ar');
1693 &define_configure_variable ('RANLIB');
1696 # Handle shared libraries.
1697 sub handle_ltlibraries
1699 local (@liblist) = &am_install_var ('-clean',
1700 'ltlib', 'LTLIBRARIES',
1701 'noinst', 'lib', 'pkglib');
1702 return if ! @liblist;
1705 local (%valid) = &am_primary_prefixes ('LTLIBRARIES', 0, 'lib', 'pkglib',
1709 foreach $key (keys %valid)
1711 if (&variable_defined ($key . '_LTLIBRARIES'))
1715 &am_line_error ($key . '_LTLIBRARIES', "library used but \`LIBTOOL' not defined in \`configure.in'");
1716 # Only get this error once. If this is ever printed,
1718 $configure_vars{'LIBTOOL'} = 'BUG';
1722 # Get the installation directory of each library.
1723 for (&variable_value_as_list ($key . '_LTLIBRARIES', 'all'))
1727 &am_error ("\`$_' is already going to be installed in \`$instdirs{$_}'");
1731 $instdirs{$_} = $key;
1740 local ($seen_libobjs) = 0;
1741 foreach $onelib (@liblist)
1743 local ($obj) = &get_object_extension ($onelib);
1745 # Canonicalize names and check for misspellings.
1746 $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_LDFLAGS',
1747 '_SOURCES', '_OBJECTS',
1750 if (! &variable_defined ($xlib . '_LDFLAGS'))
1752 # Define the lib_LDFLAGS variable.
1753 &define_variable ($xlib . '_LDFLAGS', '');
1756 # Check that the library fits the standard naming convention.
1757 $libname_rx = "^lib.*\.la";
1758 if (&variable_value ($xlib . '_LDFLAGS') =~ /-module/)
1760 # Relax name checking for libtool modules.
1761 $libname_rx = "\.la";
1763 if ($onelib !~ /$libname_rx$/)
1765 # FIXME this should only be a warning for foreign packages
1766 # FIXME should put line number here. That means mapping
1767 # from library name back to variable name.
1768 &am_error ("\`$onelib' is not a standard libtool library name");
1771 if (&variable_defined ($xlib . '_LIBADD'))
1773 if (&handle_lib_objects ($xlib, $xlib . '_LIBADD', 0))
1780 # Generate support for conditional object inclusion in
1782 &define_variable ($xlib . "_LIBADD", '');
1785 if (&variable_defined ($xlib . '_LDADD'))
1787 &am_line_error ($xlib . '_LDADD',
1788 "use \`" . $xlib . "_LIBADD', not \`"
1789 . $xlib . "_LDADD'");
1792 # Make sure we at look at this.
1793 &examine_variable ($xlib . '_DEPENDENCIES');
1795 local ($linker) = &handle_source_transform ($xlib, $onelib, $obj);
1797 # Determine program to use for link.
1799 if (&variable_defined ($xlib . '_LINK'))
1801 $xlink = $xlib . '_LINK';
1805 $xlink = $linker ? $linker : 'LINK';
1809 if ($instdirs{$onelib} eq 'EXTRA' || $instdirs{$onelib} eq 'noinst')
1811 # It's an EXTRA_ library, so we can't specify -rpath,
1812 # because we don't know where the library will end up.
1813 # The user probably knows, but generally speaking automake
1814 # doesn't -- and in fact configure could decide
1815 # dynamically between two different locations.
1816 $rpath = 's/\@RPATH\@//go;';
1820 $rpath = ('s/\@RPATH\@/-rpath \$(' . $instdirs{$onelib}
1825 &file_contents_with_transform ('s/\@LTLIBRARY\@/'
1827 . 's/\@XLTLIBRARY\@/'
1830 . 's/\@XLINK\@/' . $xlink . '/go;',
1836 foreach $onelib (@liblist)
1838 # Canonicalize names.
1839 ($xlib = $onelib) =~ tr/A-Za-z0-9_/_/c;
1840 if (&variable_defined ($xlib . '_LIBADD'))
1842 &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
1848 # See if any _SOURCES variable were misspelled. Also, make sure that
1849 # EXTRA_ variables don't contain configure substitutions.
1852 local ($varname, $primary);
1853 foreach $varname (keys %contents)
1855 foreach $primary ('_SOURCES', '_LIBADD', '_LDADD', '_LDFLAGS',
1858 if ($varname =~ /$primary$/ && ! $content_seen{$varname})
1860 &am_line_error ($varname,
1861 "invalid unused variable name: \`$varname'");
1870 # NOTE we no longer automatically clean SCRIPTS, because it is
1871 # useful to sometimes distribute scripts verbatim. This happens
1872 # eg in Automake itself.
1873 &am_install_var ('-candist', 'scripts', 'SCRIPTS',
1874 'bin', 'sbin', 'libexec', 'pkgdata',
1877 local ($scripts_installed) = 0;
1878 # Set $scripts_installed if appropriate. Make sure we only find
1879 # scripts which are actually installed -- this is why we can't
1880 # simply use the return value of am_install_var.
1881 local (%valid) = &am_primary_prefixes ('SCRIPTS', 1, 'bin', 'sbin',
1882 'libexec', 'pkgdata',
1885 foreach $key (keys %valid)
1887 if ($key ne 'noinst'
1889 && &variable_defined ($key . '_SCRIPTS'))
1891 $scripts_installed = 1;
1892 # push (@check_tests, 'check-' . $key . 'SCRIPTS');
1896 if ($scripts_installed)
1898 # If a program is installed, this is required. We only want this
1899 # error to appear once.
1900 &am_conf_error ("AC_ARG_PROGRAM must be used in configure.in")
1901 unless $seen_arg_prog;
1906 # Search a file for a "version.texi" Texinfo include. Return the name
1907 # of the include file if found, or the empty string if not. A
1908 # "version.texi" file is actually any file whose name matches
1910 sub scan_texinfo_file
1912 local ($filename) = @_;
1914 if (! open (TEXI, $filename))
1916 &am_error ("couldn't open \`$filename': $!");
1919 print "automake: reading $filename\n" if $verbose;
1921 local ($vfile, $outfile);
1924 if (/^\@setfilename +(\S+)/)
1930 if (/^\@include\s+(vers[^.]*\.texi)\s*$/)
1932 # Found version.texi include.
1939 return ($outfile, $vfile);
1942 # Handle all Texinfo source.
1945 &am_line_error ('TEXINFOS',
1946 "\`TEXINFOS' is an anachronism; use \`info_TEXINFOS'")
1947 if &variable_defined ('TEXINFOS');
1948 return if (! &variable_defined ('info_TEXINFOS')
1949 && ! &variable_defined ('html_TEXINFOS'));
1951 if (&variable_defined ('html_TEXINFOS'))
1953 &am_line_error ('html_TEXINFOS',
1954 "HTML generation not yet supported");
1958 local (@texis) = &variable_value_as_list ('info_TEXINFOS', 'all');
1960 local (@info_deps_list, @dvis_list, @texi_deps);
1961 local ($infobase, $info_cursor);
1965 local ($tc_cursor, @texi_cleans);
1968 foreach $info_cursor (@texis)
1970 # FIXME: This is mildly hacky, since it recognizes "txinfo".
1971 # I don't feel like making it right.
1972 ($infobase = $info_cursor) =~ s/\.te?xi(nfo)?$//;
1974 # If 'version.texi' is referenced by input file, then include
1975 # automatic versioning capability.
1976 local ($out_file, $vtexi) = &scan_texinfo_file ($relative_dir
1977 . "/" . $info_cursor);
1979 if ($out_file eq '')
1981 &am_error ("\`$info_cursor' missing \@setfilename");
1985 if ($out_file =~ /\.(.+)$/ && $1 ne 'info')
1987 # FIXME should report line number in input file.
1988 &am_error ("output of \`$info_cursor', \`$out_file', has unrecognized extension");
1994 &am_error ("\`$vtexi', included in \`$info_cursor', also included in \`$versions{$vtexi}'")
1995 if (defined $versions{$vtexi});
1996 $versions{$vtexi} = $info_cursor;
1998 # We number the stamp-vti files. This is doable since the
1999 # actual names don't matter much. We only number starting
2000 # with the second one, so that the common case looks nice.
2001 $vti = 'vti' . ($done ? $done : '');
2002 &push_dist_common ($vtexi, 'stamp-' . $vti);
2003 push (@clean, $vti);
2005 # Only require once.
2006 &require_conf_file_with_line ('info_TEXINFOS', $FOREIGN,
2011 local ($conf_pat, $conf_dir);
2012 if ($config_aux_dir eq '.' || $config_aux_dir eq '')
2014 $conf_dir = '$(srcdir)/';
2018 $conf_dir = $config_aux_dir;
2019 $conf_dir .= '/' unless $conf_dir =~ /\/$/;
2021 ($conf_pat = $conf_dir) =~ s/(\W)/\\$1/g;
2023 &file_contents_with_transform
2024 ('s/\@TEXI\@/' . $info_cursor . '/g; '
2025 . 's/\@VTI\@/' . $vti . '/g; '
2026 . 's/\@VTEXI\@/' . $vtexi . '/g;'
2027 . 's,\@MDDIR\@,' . $conf_pat . ',g;',
2030 &push_phony_cleaners ($vti);
2033 # If user specified file_TEXINFOS, then use that as explicit
2036 push (@texi_deps, $info_cursor);
2037 push (@texi_deps, $vtexi) if $vtexi;
2039 # Canonicalize name first.
2040 ($canonical = $infobase) =~ tr/A-Za-z0-9_/_/c;
2041 if (&variable_defined ($canonical . "_TEXINFOS"))
2043 push (@texi_deps, '$(' . $canonical . '_TEXINFOS)');
2044 &push_dist_common ('$(' . $canonical . '_TEXINFOS)');
2047 $output_rules .= ("\n" . $out_file . ": "
2048 . join (' ', @texi_deps)
2049 . "\n" . $infobase . ".dvi: "
2050 . join (' ', @texi_deps)
2053 push (@info_deps_list, $out_file);
2054 push (@dvis_list, $infobase . '.dvi');
2056 # Generate list of things to clean for this target. We do
2057 # this explicitly because otherwise too many things could be
2058 # removed. In particular the ".log" extension might
2059 # reasonably be used in other contexts by the user.
2060 foreach $tc_cursor ('aux', 'cp', 'cps', 'dvi', 'fn', 'fns', 'pgs',
2061 'ky', 'kys', 'ps', 'log', 'pg', 'toc', 'tp', 'tps',
2062 'vr', 'vrs', 'op', 'tr', 'cv', 'cn')
2064 push (@texi_cleans, $infobase . '.' . $tc_cursor);
2068 # Find these programs wherever they may lie. Yes, this has
2069 # intimate knowledge of the structure of the texinfo distribution.
2070 &define_program_variable ('MAKEINFO', 'build', 'texinfo/makeinfo',
2072 # Circumlocution to avoid accidental
2073 # configure substitution.
2075 &define_program_variable ('TEXI2DVI', 'src', 'texinfo/util',
2078 # Set transform for including texinfos.am. First, handle --cygnus
2083 $xform = 's/^NOTCYGNUS.*$//; s/^CYGNUS//;';
2087 $xform = 's/^CYGNUS.*$//; s/^NOTCYGNUS//;';
2090 # Handle location of texinfo.tex.
2091 local ($need_texi_file) = 0;
2092 local ($texinfo_tex);
2095 $texinfo_tex = '$(top_srcdir)/../texinfo/texinfo.tex';
2096 &define_variable ('TEXINFO_TEX', $texinfo_tex);
2099 elsif ($config_aux_dir ne '.' && $config_aux_dir ne '')
2101 $texinfo_tex = $config_aux_dir . '/texinfo.tex';
2102 &define_variable ('TEXINFO_TEX', $texinfo_tex);
2103 $need_texi_file = 2; # so that we require_conf_file later
2105 elsif (&variable_defined ('TEXINFO_TEX'))
2107 # The user defined TEXINFO_TEX so assume he knows what he is
2109 $texinfo_tex = ('$(srcdir)/'
2110 . &dirname (&variable_value ('TEXINFO_TEX')));
2114 $texinfo_tex = '$(srcdir)/texinfo.tex';
2115 $need_texi_file = 1;
2118 ($xxform = $texinfo_tex) =~ s/\/texinfo\.tex$//;
2119 $xxform =~ s/(\W)/\\$1/g;
2120 $xform .= ' s/\@TEXINFODIR\@/' . $xxform . '/g;';
2122 $output_rules .= &file_contents_with_transform ($xform, 'texinfos');
2123 push (@phony, 'install-info-am', 'uninstall-info');
2124 push (@dist_targets, 'dist-info');
2126 # How to clean. The funny name is due to --cygnus influence; in
2127 # Cygnus mode, `clean-info' is a target that users can use.
2128 $output_rules .= "\nmostlyclean-aminfo:\n";
2129 &pretty_print_rule ("\t-rm -f", "\t ", @texi_cleans);
2130 $output_rules .= ("\nclean-aminfo:\n\ndistclean-aminfo:\n\n"
2131 . "maintainer-clean-aminfo:\n\t"
2132 # Eww. But how else can we find all the output
2133 # files from makeinfo?
2134 . ($cygnus_mode ? '' : 'cd $(srcdir) && ')
2135 . 'for i in $(INFO_DEPS); do' . " \\\n"
2136 . "\t" . ' rm -f $$i;' . " \\\n"
2137 . "\t" . ' if test "`echo $$i-[0-9]*`" != "$$i-[0-9]*"; then' . " \\\n"
2138 . "\t" . ' rm -f $$i-[0-9]*;' . " \\\n"
2139 . "\t" . ' fi;' . " \\\n"
2141 &push_phony_cleaners ('aminfo');
2144 $output_rules .= "clean-info: mostlyclean-aminfo\n";
2147 push (@suffixes, '.texi', '.texinfo', '.txi', '.info', '.dvi', '.ps');
2149 if (! defined $options{'no-installinfo'})
2151 push (@uninstall, 'uninstall-info');
2152 push (@installdirs, '$(DESTDIR)$(infodir)');
2153 unshift (@install_data, 'install-info-am');
2155 # Make sure documentation is made and installed first. Use
2156 # $(INFO_DEPS), not 'info', because otherwise recursive makes
2157 # get run twice during "make all".
2158 unshift (@all, '$(INFO_DEPS)');
2160 push (@clean, 'aminfo');
2161 push (@info, '$(INFO_DEPS)');
2162 push (@dvi, '$(DVIS)');
2164 &define_variable ("INFO_DEPS", join (' ', @info_deps_list));
2165 &define_variable ("DVIS", join (' ', @dvis_list));
2166 # This next isn't strictly needed now -- the places that look here
2167 # could easily be changed to look in info_TEXINFOS. But this is
2168 # probably better, in case noinst_TEXINFOS is ever supported.
2169 &define_variable ("TEXINFOS", &variable_value ('info_TEXINFOS'));
2171 # Do some error checking. Note that this file is not required
2172 # when in Cygnus mode; instead we defined TEXINFO_TEX explicitly
2174 if ($need_texi_file && ! defined $options{'no-texinfo.tex'})
2176 if ($need_texi_file > 1)
2178 &require_conf_file_with_line ('info_TEXINFOS', $FOREIGN,
2183 &require_file_with_line ('info_TEXINFOS', $FOREIGN, 'texinfo.tex');
2188 # Handle any man pages.
2189 sub handle_man_pages
2191 &am_line_error ('MANS', "\`MANS' is an anachronism; use \`man_MANS'")
2192 if &variable_defined ('MANS');
2193 return if ! &variable_defined ('man_MANS');
2195 # Find all the sections in use. We do this by first looking for
2196 # "standard" sections, and then looking for any additional
2197 # sections used in man_MANS.
2198 local ($sect, %sections, %vlist);
2199 # Add more sections as needed.
2200 foreach $sect ('0'..'9', 'n', 'l')
2202 if (&variable_defined ('man' . $sect . '_MANS'))
2204 $sections{$sect} = 1;
2205 $vlist{'$(man' . $sect . '_MANS)'} = 1;
2209 if (&variable_defined ('man_MANS'))
2211 $vlist{'$(man_MANS)'} = 1;
2212 foreach (&variable_value_as_list ('man_MANS', 'all'))
2214 # A page like `foo.1c' goes into man1dir.
2215 if (/\.([0-9a-z])([a-z]*)$/)
2223 # Now for each section, generate an install and unintall rule.
2224 # Sort sections so output is deterministic.
2226 foreach $sect (sort keys %sections)
2228 &define_variable ('man' . $sect . 'dir', '$(mandir)/man' . $sect);
2229 push (@installdirs, '$(DESTDIR)$(mandir)/man' . $sect)
2230 unless defined $options{'no-installman'};
2231 $output_rules .= &file_contents_with_transform ('s/\@SECTION\@/'
2234 push (@phony, 'install-man' . $sect, 'uninstall-man' . $sect);
2235 push (@namelist, 'install-man' . $sect);
2238 # We don't really need this, but we use it in case we ever want to
2239 # support noinst_MANS.
2240 &define_variable ("MANS", join (' ', sort keys %vlist));
2242 # Generate list of install dirs.
2243 $output_rules .= ("install-man: \$(MANS)\n"
2244 . "\t\@\$(NORMAL_INSTALL)\n");
2245 &pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ", @namelist);
2246 push (@phony, 'install-man');
2248 $output_rules .= "uninstall-man:\n\t\@\$(NORMAL_UNINSTALL)\n";
2249 grep ($_ = 'un' . $_, @namelist);
2250 &pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ", @namelist);
2251 push (@phony, 'uninstall-man');
2253 $output_vars .= &file_contents ('mans-vars');
2255 if (! defined $options{'no-installman'})
2257 push (@install_data, 'install-man');
2258 push (@uninstall, 'uninstall-man');
2259 push (@all, '$(MANS)');
2263 # Handle DATA variables.
2266 &am_install_var ('-noextra', '-defaultdist', 'data', 'DATA',
2267 'data', 'sysconf', 'sharedstate', 'localstate',
2268 'pkgdata', 'noinst', 'check');
2274 push (@phony, 'tags');
2275 local (@tag_deps) = ();
2276 if (&variable_defined ('SUBDIRS'))
2278 $output_rules .= ("tags-recursive:\n"
2279 . "\tlist=\'\$(SUBDIRS)\'; for subdir in \$\$list; do \\\n"
2280 # Never fail here if a subdir fails; it
2282 . "\t test \"\$\$subdir\" = . || (cd \$\$subdir"
2283 . " && \$(MAKE) \$(AM_MAKEFLAGS) tags); \\\n"
2285 push (@tag_deps, 'tags-recursive');
2286 push (@phony, 'tags-recursive');
2289 if (&saw_sources_p (1)
2290 || &variable_defined ('ETAGS_ARGS')
2293 local ($xform) = '';
2295 foreach $one_hdr (@config_headers)
2297 if ($relative_dir eq &dirname ($one_hdr))
2299 # The config header is in this directory. So require it.
2301 ($var = &basename ($one_hdr)) =~ s/(\W)/\\$1/g;
2302 $xform .= ' ' if $xform;
2306 $xform = ('s/\@CONFIG\@/' . $xform . '/;'
2307 . 's/\@DIRS\@/' . join (' ', @tag_deps) . '/;');
2309 if (&variable_defined ('SUBDIRS'))
2311 $xform .= 's/^SUBDIRS//;';
2315 $xform .= 's/^SUBDIRS.*$//;';
2318 $output_rules .= &file_contents_with_transform ($xform, 'tags');
2319 $output_rules .= &file_contents ('tags-clean');
2320 push (@clean, 'tags');
2321 &push_phony_cleaners ('tags');
2322 &examine_variable ('TAGS_DEPENDENCIES');
2324 elsif (&variable_defined ('TAGS_DEPENDENCIES'))
2326 &am_line_error ('TAGS_DEPENDENCIES',
2327 "doesn't make sense to define \`TAGS_DEPENDENCIES' without sources or \`ETAGS_ARGS'");
2331 # Every Makefile must define some sort of TAGS rule.
2332 # Otherwise, it would be possible for a top-level "make TAGS"
2333 # to fail because some subdirectory failed.
2334 $output_rules .= "tags: TAGS\nTAGS:\n\n";
2338 # Handle multilib support.
2341 return unless $seen_multilib;
2343 $output_rules .= &file_contents ('multilib.am');
2344 &push_phony_cleaners ('multi');
2345 push (@phony, 'all-multi', 'install-multi');
2348 # Worker for handle_dist.
2349 sub handle_dist_worker
2351 local ($makefile) = @_;
2353 $output_rules .= 'distdir: $(DISTFILES)' . "\n";
2355 # Initialization; only at top level.
2356 if ($relative_dir eq '.')
2358 if (defined $options{'check-news'})
2360 # For Gnits users, this is pretty handy. Look at 15 lines
2361 # in case some explanatory text is desirable.
2362 $output_rules .= ' @if sed 15q $(srcdir)/NEWS | fgrep -e "$(VERSION)" > /dev/null; then :; else \\
2363 echo "NEWS not updated; not releasing" 1>&2; \\
2370 # Create dist directory.
2371 $output_rules .= ("\t-rm -rf \$(distdir)\n"
2372 . "\tmkdir \$(distdir)\n"
2373 . "\t-chmod 777 \$(distdir)\n");
2376 # Only run automake in `dist' target if --include-deps and
2377 # `no-dependencies' not specified. That way the recipient of a
2378 # distribution can run "make dist" and not need Automake. You
2379 # might be wondering why we run automake once for each directory
2380 # we distribute, instead of running it once at the top level. The
2381 # answer is that we want to run automake after the dependencies
2382 # have been generated. This occurs when "make" is run in the
2383 # subdir. So automake must be run after make has updated the
2384 # Makefile, which means that it must run once per directory.
2385 if ($use_dependencies)
2389 # There are several directories we need to know about
2390 # when rebuilding the Makefile.ins. They are:
2391 # here - The absolute path to our topmost build directory.
2392 # top_distdir - The absolute path to the top of our dist
2394 # distdir - The path to our sub-part of the dist hierarchy.
2395 # If this directory is the topmost directory, we set
2396 # top_distdir from distdir; that lets us pass in distdir
2397 # from an enclosing package.
2398 "\t" . 'here=`cd $(top_builddir) && pwd`; ' . "\\\n"
2399 . "\t" . 'top_distdir=`cd $('
2400 . (($relative_dir eq '.') ? 'distdir' : 'top_distdir')
2401 . ') && pwd`; ' . "\\\n"
2402 . "\t" . 'distdir=`cd $(distdir) && pwd`; ' . "\\\n"
2403 . "\tcd \$(top_srcdir) \\\n"
2404 . "\t && \$(AUTOMAKE) --include-deps --build-dir=\$\$here --srcdir-name=\$(top_srcdir) --output-dir=\$\$top_distdir "
2405 # Set strictness of output.
2406 . ($cygnus_mode ? '--cygnus' : ('--' . $strictness_name))
2407 . ($cmdline_use_dependencies ? '' : ' --include-deps')
2408 . " " . $makefile . "\n"
2412 # Scan EXTRA_DIST to see if we need to distribute anything from a
2413 # subdir. If so, add it to the list. I didn't want to do this
2414 # originally, but there were so many requests that I finally
2417 if (&variable_defined ('EXTRA_DIST'))
2419 # FIXME: This should be fixed to work with conditionals. That
2420 # will require only making the entries in @dist_dirs under the
2421 # appropriate condition. This is meaningful if the nature of
2422 # the distribution should depend upon the configure options
2424 foreach (&variable_value_as_list ('EXTRA_DIST', ''))
2427 next unless s,/+[^/]+$,,;
2428 push (@dist_dirs, $_)
2434 # Prepend $(distdir) to each directory given. Doing it via a
2435 # hash lets us ensure that each directory is used only once.
2437 grep ($dhash{'$(distdir)/' . $_} = 1, @dist_dirs);
2438 $output_rules .= "\t";
2439 &pretty_print_rule ('$(mkinstalldirs)', "\t ", sort keys %dhash);
2442 # In loop, test for file existence because sometimes a file gets
2443 # included in DISTFILES twice. For example this happens when a
2444 # single source file is used in building more than one program.
2445 # Also, there are situations in which "ln" can fail. For instance
2446 # a file to distribute could actually be a cross-filesystem
2447 # symlink -- this can easily happen if "gettextize" was run on the
2449 $output_rules .= "\t\@for file in \$(DISTFILES); do \\\n";
2452 $output_rules .= "\t if test -f \$\$file; then d=.; else d=\$(srcdir); fi; \\\n";
2456 $output_rules .= "\t d=\$(srcdir); \\\n";
2458 $output_rules .= ("\t if test -d \$\$d/\$\$file; then \\\n"
2459 . "\t cp -pr \$\$d/\$\$file \$(distdir)/\$\$file; \\\n"
2461 . "\t test -f \$(distdir)/\$\$file \\\n"
2462 . "\t || ln \$\$d/\$\$file \$(distdir)/\$\$file 2> /dev/null \\\n"
2463 . "\t || cp -p \$\$d/\$\$file \$(distdir)/\$\$file || :; \\\n"
2467 # If we have SUBDIRS, create all dist subdirectories and do
2469 if (&variable_defined ('SUBDIRS'))
2471 # If SUBDIRS is conditionally defined, then set DIST_SUBDIRS
2472 # to all possible directories, and use it. If DIST_SUBDIRS is
2473 # defined, just use it.
2474 local ($dist_subdir_name);
2475 if (&variable_conditions ('SUBDIRS')
2476 || &variable_defined ('DIST_SUBDIRS'))
2478 $dist_subdir_name = 'DIST_SUBDIRS';
2479 if (! &variable_defined ('DIST_SUBDIRS'))
2481 &define_pretty_variable ('DIST_SUBDIRS', '',
2482 &variable_value_as_list ('SUBDIRS',
2488 $dist_subdir_name = 'SUBDIRS';
2491 # Test for directory existence here because previous automake
2492 # invocation might have created some directories. Note that
2493 # we explicitly set distdir for the subdir make; that lets us
2494 # mix-n-match many automake-using packages into one large
2495 # package, and have "dist" at the top level do the right
2496 # thing. If we're in the topmost directory, then we use
2497 # `distdir' instead of `top_distdir'; this lets us work
2498 # correctly with an enclosing package.
2500 ("\t" . 'for subdir in $(' . $dist_subdir_name . '); do ' . "\\\n"
2501 . "\t" . ' if test "$$subdir" = .; then :; else ' . "\\\n"
2502 . "\t" . ' test -d $(distdir)/$$subdir ' . "\\\n"
2503 . "\t" . ' || mkdir $(distdir)/$$subdir ' . "\\\n"
2504 . "\t" . ' || exit 1; ' . "\\\n"
2505 . "\t" . ' chmod 777 $(distdir)/$$subdir; ' . "\\\n"
2506 . "\t" . ' (cd $$subdir'
2507 . ' && $(MAKE) $(AM_MAKEFLAGS) top_distdir=../$('
2508 . (($relative_dir eq '.') ? 'distdir' : 'top_distdir')
2509 . ') distdir=../$(distdir)/$$subdir distdir) ' . "\\\n"
2510 . "\t" . ' || exit 1; ' . "\\\n"
2511 . "\t" . ' fi; ' . "\\\n"
2515 # If the target `dist-hook' exists, make sure it is run. This
2516 # allows users to do random weird things to the distribution
2517 # before it is packaged up.
2518 push (@dist_targets, 'dist-hook') if &target_defined ('dist-hook');
2521 foreach $targ (@dist_targets)
2523 # We must explicitly set distdir and top_distdir for these
2525 $output_rules .= ("\t\$(MAKE) \$(AM_MAKEFLAGS)"
2526 . " top_distdir=\"\$(top_distdir)\""
2527 . " distdir=\"\$(distdir)\" $targ\n");
2530 push (@phony, 'distdir');
2533 # Handle 'dist' target.
2536 local ($makefile) = @_;
2538 # Set up maint_charset.
2539 $local_maint_charset = &variable_value ('MAINT_CHARSET')
2540 if &variable_defined ('MAINT_CHARSET');
2541 $maint_charset = $local_maint_charset
2542 if $relative_dir eq '.';
2544 if (&variable_defined ('DIST_CHARSET'))
2546 &am_line_error ('DIST_CHARSET',
2547 "DIST_CHARSET defined but no MAINT_CHARSET defined")
2548 if ! $local_maint_charset;
2549 if ($relative_dir eq '.')
2551 $dist_charset = &variable_value ('DIST_CHARSET')
2555 &am_line_error ('DIST_CHARSET',
2556 "DIST_CHARSET can only be defined at top level");
2560 # Look for common files that should be included in distribution.
2562 foreach $cfile (@common_files)
2564 if (-f ($relative_dir . "/" . $cfile))
2566 &push_dist_common ($cfile);
2570 # Always require configure.in and configure at top level, even if
2571 # they don't exist. This is especially important for configure,
2572 # since it won't be created until autoconf is run -- which might
2573 # be after automake is run.
2574 &push_dist_common ('configure.in', 'configure')
2575 if $relative_dir eq '.';
2577 # Keys of %dist_common are names of files to distributed. We put
2578 # README first because it then becomes easier to make a
2579 # Usenet-compliant shar file (in these, README must be first).
2580 # FIXME: do more ordering of files here.
2582 if (defined $dist_common{'README'})
2584 push (@coms, 'README');
2585 delete $dist_common{'README'};
2587 push (@coms, sort keys %dist_common);
2589 &define_pretty_variable ("DIST_COMMON", '', @coms);
2590 $output_vars .= "\n";
2593 $output_vars .= &file_contents ('dist-vars') . "\n";
2594 &define_variable ('GZIP_ENV', '--best');
2596 # Put these things in rules section so it is easier for whoever
2597 # reads Makefile.in.
2598 if (! &variable_defined ('distdir'))
2600 if ($relative_dir eq '.')
2602 $output_rules .= "\n" . 'distdir = $(PACKAGE)-$(VERSION)' . "\n";
2606 $output_rules .= ("\n"
2607 . 'distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)'
2611 if ($relative_dir eq '.')
2613 $output_rules .= "top_distdir = \$(distdir)\n\n";
2617 $output_rules .= "\nsubdir = " . $relative_dir . "\n\n";
2620 # Generate 'dist' target, and maybe other dist targets.
2621 if ($relative_dir eq '.')
2623 # Rule to check whether a distribution is viable.
2624 $output_rules .= ('# This target untars the dist file and tries a VPATH configuration. Then
2625 # it guarantees that the distribution is self-contained by making another
2629 GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(TAR) xf -
2630 mkdir $(distdir)/=build
2631 mkdir $(distdir)/=inst
2632 dc_install_base=`cd $(distdir)/=inst && pwd`; \\'
2633 . (&target_defined ('distcheck-hook')
2634 ? ("\n\t\$(MAKE) \$(AM_MAKEFLAGS)"
2635 . " distcheck-hook; \\")
2638 cd $(distdir)/=build \\
2641 . ($seen_gettext ? '--with-included-gettext ' : '')
2642 . '--srcdir=.. --prefix=$$dc_install_base \\
2643 && $(MAKE) $(AM_MAKEFLAGS) \\
2644 && $(MAKE) $(AM_MAKEFLAGS) dvi \\
2645 && $(MAKE) $(AM_MAKEFLAGS) check \\
2646 && $(MAKE) $(AM_MAKEFLAGS) install \\
2647 && $(MAKE) $(AM_MAKEFLAGS) installcheck \\
2648 && $(MAKE) $(AM_MAKEFLAGS) dist
2650 @banner="$(distdir).tar.gz is ready for distribution"; \\
2651 dashes=`echo "$$banner" | sed s/./=/g`; \\
2657 local ($dist_all) = ('dist-all: distdir' . "\n"
2660 foreach $curs ('dist', 'dist-shar', 'dist-zip', 'dist-tarZ',
2663 if (defined $options{$curs} || $curs eq 'dist')
2665 $output_rules .= ($curs . ': distdir' . "\n"
2669 $dist_all .= $dist{$curs};
2672 $output_rules .= $dist_all . $dist_trailer;
2675 # Generate distdir target.
2676 &handle_dist_worker ($makefile);
2679 # Scan a single dependency file and rewrite the dependencies as
2680 # appropriate. Essentially this means:
2681 # * Clean out absolute dependencies which are not desirable.
2682 # * Rewrite other dependencies to be relative to $(top_srcdir).
2683 sub scan_dependency_file
2685 local ($depfile) = @_;
2687 if (! open (DEP_FILE, $depfile))
2689 &am_error ("couldn't open \`$depfile': $!");
2692 print "automake: reading $depfile\n" if $verbose;
2694 # Sometimes it is necessary to omit some dependencies.
2695 local (%omit) = %omit_dependencies;
2696 if (&variable_defined ('OMIT_DEPENDENCIES'))
2698 # FIXME: Doesn't work with conditionals. I'm not sure if this
2700 grep ($omit{$_} = 1,
2701 &variable_value_as_list ('OMIT_DEPENDENCIES', ''));
2704 local ($first_line) = 1;
2705 local ($last_line) = 0;
2706 local ($target, @dependencies);
2707 local ($one_dep, $xform);
2710 local ($srcdir_rx, $fixup_rx);
2711 ($fixup_rx = $srcdir_name . '/' . $relative_dir . '/')
2713 ($srcdir_rx = $srcdir_name . '/') =~ s/(\W)/\\$1/g;
2715 local ($rewrite_builddir) = (($top_builddir eq '.')
2717 : $top_builddir . '/');
2722 next if (/$WHITE_PATTERN/o);
2726 # No trailing "\" means this should be the last line of
2727 # the first target. We can have multiple targets due to
2728 # the "deleted header file" fix. For the generated
2729 # Makefile we simply skip these fake targets.
2735 if (! /^([^:]+:)(.+)$/)
2738 &am_error ("\`$depfile' has incorrect format");
2744 # Make sure to strip the .P file from the target.
2745 ($target = $1) =~ s, *\.deps/[^.]+\.P,,;
2750 foreach $one_dep (split (' ', $_))
2752 ($just_file = $one_dep) =~ s,^.*/,,;
2753 next if defined $omit{$just_file};
2755 if ($one_dep =~ /^$fixup_rx/)
2757 # The dependency points to the current directory in
2759 ($xform = $one_dep) =~ s/^$fixup_rx//;
2760 push (@dependencies, $xform);
2762 elsif ($one_dep =~ /^$srcdir_rx/)
2764 # The dependency is in some other directory in the package.
2765 ($xform = $one_dep) =~ s/^$srcdir_rx/$rewrite_builddir/;
2766 push (@dependencies, $xform);
2768 elsif ($one_dep =~ /^\// || $one_dep =~ /^[A-Za-z]:\\/)
2770 # Absolute path; ignore.
2774 # Anything else is assumed to be correct.
2775 push (@dependencies, $one_dep);
2780 &pretty_print_rule ($target, "\t", @dependencies);
2785 # Handle auto-dependency code.
2786 sub handle_dependencies
2788 # Make sure this variable is always marked as used.
2789 &examine_variable ('OMIT_DEPENDENCIES');
2791 if ($use_dependencies)
2793 # Include GNU-make-specific auto-dep code. Don't include it
2794 # if DEP_FILES would be empty.
2795 if (&saw_sources_p (0) && keys %dep_files)
2797 &define_pretty_variable ('DEP_FILES', '', sort keys %dep_files);
2798 $output_rules .= &file_contents ('depend');
2799 push (@clean, 'depend');
2800 &push_phony_cleaners ('depend');
2802 local ($key, $lang, $ext, $xform);
2803 foreach $key (sort keys %language_map)
2805 next unless $key =~ /^(.*)-autodep$/;
2806 next if $language_map{$key} eq 'no';
2809 $xform = 's/\@PFX\@/' . $language_map{$key} . '/g;';
2810 foreach $ext (&lang_extensions ($lang))
2813 &file_contents_with_transform ('s/\@EXT\@/'
2821 elsif ($build_directory ne '')
2823 # Include any auto-generated deps that are present. Note that
2824 # $build_directory ends in a "/".
2825 if (-d ($build_directory . $relative_dir . "/.deps"))
2829 foreach $depfile (&my_glob ($build_directory
2830 . $relative_dir . "/.deps/*.P"))
2832 &scan_dependency_file ($depfile);
2835 $output_rules .= "\n";
2840 # Handle subdirectories.
2843 return if ! &variable_defined ('SUBDIRS');
2845 # Make sure each directory mentioned in SUBDIRS actually exists.
2847 foreach $dir (&variable_value_as_list ('SUBDIRS', 'all'))
2849 # Skip directories substituted by configure.
2850 next if $dir =~ /^\@.*\@$/;
2852 if (! -d $am_relative_dir . '/' . $dir)
2854 &am_line_error ('SUBDIRS',
2855 "required directory $am_relative_dir/$dir does not exist");
2859 &am_line_error ('SUBDIRS', "directory should not contain \`/'")
2863 local ($xform) = ('s/\@INSTALLINFO\@/' .
2864 (defined $options{'no-installinfo'}
2865 ? 'install-info-recursive'
2868 $output_rules .= &file_contents_with_transform ($xform, 'subdirs');
2870 # Push a bunch of phony targets.
2872 foreach $phonies ('-data', '-exec', 'dirs')
2874 push (@phony, 'install' . $phonies . '-recursive');
2875 push (@phony, 'uninstall' . $phonies . '-recursive');
2877 foreach $phonies ('all', 'check', 'installcheck', 'info', 'dvi')
2879 push (@phony, $phonies . '-recursive');
2881 &push_phony_cleaners ('recursive');
2883 $recursive_install = 1;
2886 # Handle aclocal.m4.
2887 sub handle_aclocal_m4
2889 local ($regen_aclocal) = 0;
2890 if (-f 'aclocal.m4')
2892 &define_variable ("ACLOCAL_M4", '$(top_srcdir)/aclocal.m4');
2893 &push_dist_common ('aclocal.m4');
2895 if (open (ACLOCAL, '< aclocal.m4'))
2901 if ($line =~ 'generated automatically by aclocal')
2908 local ($acinclude) = 0;
2909 if (-f 'acinclude.m4')
2915 # Note that it might be possible that aclocal.m4 doesn't exist but
2916 # should be auto-generated. This case probably isn't very
2920 local (@ac_deps) = (
2922 ? "\@MAINTAINER_MODE_TRUE\@"
2925 ($acinclude ? ' acinclude.m4' : '')
2928 # Scan all -I directories for m4 files. These are our
2930 if (&variable_defined ('ACLOCAL_AMFLAGS'))
2932 local ($examine_next, $amdir) = 0;
2933 foreach $amdir (&variable_value_as_list ('ACLOCAL_AMFLAGS', ''))
2938 if ($amdir !~ /^\// && -d $amdir)
2940 push (@ac_deps, &my_glob ($amdir . '/*.m4'));
2943 elsif ($amdir eq '-I')
2950 &pretty_print_rule ("\$(ACLOCAL_M4):", "\t\t", @ac_deps);
2952 $output_rules .= ("\t"
2953 . 'cd $(srcdir) && $(ACLOCAL)'
2954 . (&variable_defined ('ACLOCAL_AMFLAGS')
2955 ? ' $(ACLOCAL_AMFLAGS)' : '')
2960 # Rewrite a list of input files into a form suitable to put on a
2961 # dependency list. The idea is that if an input file has a directory
2962 # part the same as the current directory, then the directory part is
2963 # simply removed. But if the directory part is different, then
2964 # $(top_srcdir) is prepended. Among other things, this is used to
2965 # generate the dependency list for the output files generated by
2966 # AC_OUTPUT. Consider what the dependencies should look like in this
2968 # AC_OUTPUT(src/out:src/in1:lib/in2)
2969 # The first argument, ADD_SRCDIR, is 1 if $(top_srcdir) should be added.
2970 # If 0 then files that require this addition will simply be ignored.
2971 sub rewrite_inputs_into_dependencies
2973 local ($add_srcdir, @inputs) = @_;
2974 local ($single, @newinputs);
2976 foreach $single (@inputs)
2978 if (&dirname ($single) eq $relative_dir)
2980 push (@newinputs, &basename ($single));
2984 push (@newinputs, '$(top_srcdir)/' . $single);
2991 # Handle remaking and configure stuff.
2992 # We need the name of the input file, to do proper remaking rules.
2993 sub handle_configure
2995 local ($local, $input, @secondary_inputs) = @_;
2997 # If SUBDIRS defined, require AC_PROG_MAKE_SET.
2998 &am_line_error ('SUBDIRS', "AC_PROG_MAKE_SET must be used in configure.in")
2999 if &variable_defined ('SUBDIRS') && ! $seen_make_set;
3001 local ($top_reldir);
3003 local ($input_base) = &basename ($input);
3004 local ($local_base) = &basename ($local);
3006 local ($amfile) = $input_base . '.am';
3007 # We know we can always add '.in' because it really should be an
3008 # error if the .in was missing originally.
3009 local ($infile) = '$(srcdir)/' . $input_base . '.in';
3010 local ($colon_infile);
3011 if ($local ne $input || @secondary_inputs)
3013 $colon_infile = ':' . $input . '.in';
3015 $colon_infile .= ':' . join (':', @secondary_inputs)
3016 if @secondary_inputs;
3018 local (@rewritten) = &rewrite_inputs_into_dependencies (1,
3021 # This rule remakes the Makefile.in. Note use of
3022 # @MAINTAINER_MODE_TRUE@ forces us to abandon pretty-printing.
3024 $output_rules .= ($infile
3025 # NOTE perl 5.003 (with -w) gives a
3026 # uninitialized value error on the next line.
3029 . ($seen_maint_mode ? "\@MAINTAINER_MODE_TRUE\@ " : '')
3031 . '$(top_srcdir)/configure.in $(ACLOCAL_M4)'
3032 . ' ' . join (' ', @include_stack)
3034 . "\tcd \$(top_srcdir) && \$(AUTOMAKE) "
3035 . ($cygnus_mode ? '--cygnus' : ('--' . $strictness_name))
3036 . ($cmdline_use_dependencies ? '' : ' --include-deps')
3037 . ' ' . $input . $colon_infile . "\n\n");
3039 # This rule remakes the Makefile.
3040 $output_rules .= ($local_base
3041 # NOTE: bogus uninit value error on next line;
3042 # see comment above.
3045 . join (' ', @rewritten)
3046 . ' $(top_builddir)/config.status'
3047 # NOTE: Makefile only depends on BUILT_SOURCES
3048 # when dependencies are being computed. This is
3049 # a workaround for an obscure bug with
3050 # AC_LINK_FILES. Anyway, when dependencies are
3051 # turned off, this shouldn't matter.
3052 . ($use_dependencies ? ' $(BUILT_SOURCES)' : '')
3054 . "\tcd \$(top_builddir) \\\n"
3055 . "\t && CONFIG_FILES="
3056 . (($relative_dir eq '.') ? '$@' : '$(subdir)/$@')
3058 . ' CONFIG_HEADERS= $(SHELL) ./config.status'
3061 if ($relative_dir ne '.')
3064 $top_reldir = '../';
3069 $output_rules .= &file_contents ('remake');
3070 &examine_variable ('CONFIG_STATUS_DEPENDENCIES');
3071 &examine_variable ('CONFIGURE_DEPENDENCIES');
3075 # Make it easy to see if there is a Makefile.am in a given
3077 local (%make_dirs, $iter);
3078 foreach $iter (@input_files)
3080 $make_dirs{&dirname ($iter)} = 1;
3082 # We also want to notice Makefile.in's.
3083 foreach $iter (@other_input_files)
3085 if ($iter =~ /Makefile\.in$/)
3087 $make_dirs{&dirname ($iter)} = 1;
3091 # If we have a configure header, require it.
3093 local (@local_fullnames) = @config_fullnames;
3094 local (@local_names) = @config_names;
3095 local ($hdr_index) = 0;
3096 local ($distclean_config) = '';
3097 foreach $one_hdr (@config_headers)
3099 local ($one_fullname) = shift (@local_fullnames);
3100 local ($one_name) = shift (@local_names);
3102 local ($header_dir) = &dirname ($one_name);
3104 # If the header is in the current directory we want to build
3105 # the header here. Otherwise, if we're at the topmost
3106 # directory and the header's directory doesn't have a
3107 # Makefile, then we also want to build the header.
3108 if ($relative_dir eq $header_dir
3109 || ($relative_dir eq '.' && ! defined $make_dirs{$header_dir}))
3111 local ($ch_sans_dir, $cn_sans_dir, $stamp_dir);
3112 if ($relative_dir eq $header_dir)
3114 $cn_sans_dir = &basename ($one_name);
3119 $cn_sans_dir = $one_name;
3120 if ($header_dir eq '.')
3126 $stamp_dir = $header_dir . '/';
3130 # Compute relative path from directory holding output
3131 # header to directory holding input header. FIXME:
3132 # doesn't handle case where we have multiple inputs.
3133 if (&dirname ($one_hdr) eq $relative_dir)
3135 $ch_sans_dir = &basename ($one_hdr);
3139 local (@rel_out_path);
3140 # FIXME this chunk of code should be its own sub.
3141 # It is used elsewhere.
3142 foreach (split (/\//, $relative_dir))
3144 next if $_ eq '' || $_ eq '.';
3147 # FIXME: actually this is an error.
3152 push (@rel_out_path, '..');
3157 $ch_sans_dir = join ('/', @rel_out_path) . '/' . $one_hdr;
3161 $ch_sans_dir = $one_hdr;
3165 &require_file_with_conf_line ($config_header_line,
3166 $FOREIGN, $ch_sans_dir);
3168 # Header defined and in this directory.
3170 if (-f $relative_dir . '/acconfig.h')
3172 push (@files, 'acconfig.h');
3174 if (-f $one_name . '.top')
3176 push (@files, "${cn_sans_dir}.top");
3178 if (-f $one_name . '.bot')
3180 push (@files, "${cn_sans_dir}.bot");
3183 &push_dist_common (@files);
3185 local ($stamp_name) = 'stamp-h';
3186 $stamp_name .= "${hdr_index}" if scalar (@config_headers) > 1;
3188 local ($xform) = '';
3190 $xform = 's,\@FILES\@,' . join (' ', @files) . ',;';
3191 $xform .= 's,\@CONFIG_HEADER\@,' . "${cn_sans_dir}" . ',;';
3192 $xform .= 's,\@CONFIG_HEADER_IN\@,' . "${ch_sans_dir}" . ',;';
3193 $xform .= 's,\@CONFIG_HEADER_FULL\@,' . "${one_fullname}" . ',;';
3194 $xform .= 's,\@STAMP\@,' . "${stamp_dir}${stamp_name}" . ',g;';
3196 $output_rules .= &file_contents_with_transform ($xform,
3199 local ($out_dir) = &dirname ($ch_sans_dir);
3200 &create ("${relative_dir}/${out_dir}/${stamp_name}.in");
3201 &require_file_with_conf_line ($config_header_line, $FOREIGN,
3202 "${out_dir}/${stamp_name}.in");
3204 $distclean_config .= ' ' if $distclean_config;
3205 $distclean_config .= $cn_sans_dir;
3209 if ($distclean_config)
3211 $output_rules .= &file_contents_with_transform ('s,\@FILES\@,'
3215 push (@clean, 'hdr');
3216 &push_phony_cleaners ('hdr');
3219 # Set location of mkinstalldirs.
3220 if ($config_aux_dir ne '.' && $config_aux_dir ne '')
3222 &define_variable ('mkinstalldirs', ('$(SHELL) ' . $config_aux_dir
3223 . '/mkinstalldirs'));
3227 &define_variable ('mkinstalldirs',
3228 '$(SHELL) $(top_srcdir)/mkinstalldirs');
3231 &am_line_error ('CONFIG_HEADER',
3232 "\`CONFIG_HEADER' is an anachronism; now determined from \`configure.in'")
3233 if &variable_defined ('CONFIG_HEADER');
3236 local ($config_header) = '';
3237 foreach $one_name (@config_names)
3239 # Generate CONFIG_HEADER define.
3241 if ($relative_dir eq &dirname ($one_name))
3243 $one_hdr = &basename ($one_name);
3247 $one_hdr = "${top_builddir}/${one_name}";
3250 $config_header .= ' ' if $config_header;
3251 $config_header .= $one_hdr;
3255 &define_variable ("CONFIG_HEADER", $config_header);
3258 # Now look for other files in this directory which must be remade
3259 # by config.status, and generate rules for them.
3260 local (@actual_other_files) = ();
3261 local ($file, $local);
3262 local (@inputs, @rewritten_inputs, $single);
3263 local ($need_rewritten);
3264 foreach $file (@other_input_files)
3266 if ($file =~ /^([^:]*):(.*)$/)
3268 # This is the ":" syntax of AC_OUTPUT.
3270 $local = &basename ($file);
3271 @inputs = split (':', $2);
3272 @rewritten_inputs = &rewrite_inputs_into_dependencies (1, @inputs);
3273 $need_rewritten = 1;
3278 $local = &basename ($file);
3279 @inputs = ($local . '.in');
3281 &rewrite_inputs_into_dependencies (1, $file . '.in');
3282 $need_rewritten = 0;
3285 # Skip files not in this directory.
3286 next unless &dirname ($file) eq $relative_dir;
3288 # Skip any file that is an automake input.
3289 next if -f $file . '.am';
3291 # Some users have been tempted to put `stamp-h' in the
3292 # AC_OUTPUT line. This won't do the right thing, so we
3293 # explicitly fail here.
3294 if ($local eq 'stamp-h')
3296 # FIXME: allow real filename.
3297 &am_conf_error ('configure.in', $ac_output_line,
3298 'stamp-h should not appear in AC_OUTPUT');
3302 $output_rules .= ($local . ': '
3303 . '$(top_builddir)/config.status '
3304 . join (' ', @rewritten_inputs) . "\n"
3306 . 'cd $(top_builddir) && CONFIG_FILES='
3307 . ($relative_dir eq '.' ? '' : '$(subdir)/')
3308 . '$@' . ($need_rewritten
3309 ? (':' . join (':', @inputs))
3311 . ' CONFIG_HEADERS= $(SHELL) ./config.status'
3313 &push_dist_common (@inputs);
3314 push (@actual_other_files, $local);
3316 # Require all input files.
3317 &require_file_with_conf_line ($ac_output_line, $FOREIGN,
3318 &rewrite_inputs_into_dependencies (0, @inputs));
3321 # These files get removed by "make clean".
3322 &define_pretty_variable ('CONFIG_CLEAN_FILES', '', @actual_other_files);
3329 @r = &am_install_var ('-defaultdist', 'header', 'HEADERS', 'include',
3330 'oldinclude', 'pkginclude',
3334 next unless /\.(.*)$/;
3335 &saw_extension ($1);
3341 return if ! $seen_gettext || $relative_dir ne '.';
3343 if (! &variable_defined ('SUBDIRS'))
3346 ("AM_GNU_GETTEXT in configure.in but SUBDIRS not defined");
3350 &require_file_with_conf_line ($ac_gettext_line, $GNU, 'ABOUT-NLS');
3352 if (&variable_defined ('SUBDIRS'))
3356 "AM_GNU_GETTEXT in configure.in but \`po' not in SUBDIRS")
3357 if $contents{'SUBDIRS'} !~ /\bpo\b/;
3360 "AM_GNU_GETTEXT in configure.in but \`intl' not in SUBDIRS")
3361 if $contents{'SUBDIRS'} !~ /\bintl\b/;
3364 # Ensure that each language in ALL_LINGUAS has a .po file, and
3365 # each po file is mentioned in ALL_LINGUAS.
3368 local (%linguas) = ();
3369 grep ($linguas{$_} = 1, split (' ', $all_linguas));
3376 &am_line_error ($all_linguas_line,
3377 ("po/$_.po exists but \`$_' not in \`ALL_LINGUAS'"))
3381 foreach (keys %linguas)
3383 &am_line_error ($all_linguas_line,
3384 "$_ in \`ALL_LINGUAS' but po/$_.po does not exist")
3390 &am_error ("AM_GNU_GETTEXT in configure.in but \`ALL_LINGUAS' not defined");
3394 # Handle footer elements.
3397 if ($contents{'SOURCES'})
3399 # NOTE don't use define_pretty_variable here, because
3400 # $contents{...} is already defined.
3401 $output_vars .= 'SOURCES = ' . $contents{'SOURCES'} . "\n";
3403 if ($contents{'OBJECTS'})
3405 # NOTE don't use define_pretty_variable here, because
3406 # $contents{...} is already defined.
3407 $output_vars .= 'OBJECTS = ' . $contents{'OBJECTS'} . "\n";
3409 if ($contents{'SOURCES'} || $contents{'OBJECTS'})
3411 $output_vars .= "\n";
3414 if (&variable_defined ('SUFFIXES'))
3416 # Push actual suffixes, and not $(SUFFIXES). Some versions of
3417 # make do not like variable substitutions on the .SUFFIXES
3419 push (@suffixes, &variable_value_as_list ('SUFFIXES', ''));
3421 if (&target_defined ('.SUFFIXES'))
3423 &am_line_error ('.SUFFIXES',
3424 "use variable \`SUFFIXES', not target \`.SUFFIXES'");
3427 # Note: AIX 4.1 /bin/make will fail if any suffix rule appears
3428 # before .SUFFIXES. So we make sure that .SUFFIXES appears before
3429 # anything else, by sticking it right after the default: target.
3430 $output_header .= ".SUFFIXES:\n";
3434 # Make sure suffixes has unique elements. Sort them to ensure
3435 # the output remains consistent.
3438 grep ($suffixes{$_} = 1, @suffixes);
3440 $output_header .= (".SUFFIXES: "
3441 . join (' ', sort keys %suffixes)
3444 $output_trailer .= &file_contents ('footer');
3447 # Deal with installdirs target.
3448 sub handle_installdirs
3450 # GNU Makefile standards recommend this.
3451 if ($recursive_install)
3453 # We create a separate `-am' target so that the -recursive
3454 # rule will work correctly.
3455 $output_rules .= ("installdirs: installdirs-recursive\n"
3456 . "installdirs-am:\n");
3457 push (@phony, 'installdirs-am');
3461 $output_rules .= "installdirs:\n";
3463 push (@phony, 'installdirs');
3466 &pretty_print_rule ("\t" . '$(mkinstalldirs) ', "\t\t",
3469 $output_rules .= "\n";
3472 # There are several targets which need to be merged. This is because
3473 # their complete definition is compiled from many parts. Note that we
3474 # avoid double colon rules, otherwise we'd use them instead.
3475 sub handle_merge_targets
3477 local ($makefile) = @_;
3479 # There are a few install-related variables that you should not define.
3481 foreach $var ('PRE_INSTALL', 'POST_INSTALL', 'NORMAL_INSTALL')
3483 if (&variable_defined ($var))
3485 &am_line_error ($var, "\`$var' should not be defined");
3489 # Put this at the beginning for the sake of non-GNU makes. This
3490 # is still wrong if these makes can run parallel jobs. But it is
3492 unshift (@all, &basename ($makefile));
3495 foreach $one_name (@config_names)
3497 push (@all, &basename ($one_name))
3498 if &dirname ($one_name) eq $relative_dir;
3501 &do_one_merge_target ('info', @info);
3502 &do_one_merge_target ('dvi', @dvi);
3503 &do_check_merge_target;
3504 &do_one_merge_target ('installcheck', @installcheck);
3506 if (defined $options{'no-installinfo'})
3508 &do_one_merge_target ('install-info', '');
3510 elsif (&target_defined ('install-info-local'))
3512 &am_line_error ('install-info-local',
3513 "\`install-info-local' target defined but \`no-installinfo' option not in use");
3517 foreach $utarg ('uninstall-data-local', 'uninstall-data-hook',
3518 'uninstall-exec-local', 'uninstall-exec-hook')
3520 if (&target_defined ($utarg))
3523 ($x = $utarg) =~ s/(data|exec)-//;
3524 &am_line_error ($utarg, "use \`$x', not \`$utarg'");
3528 if (&target_defined ('install-local'))
3530 &am_line_error ('install-local',
3531 "use \`install-data-local' or \`install-exec-local', not \`install-local'");
3537 local ($local_headers) = '';
3538 foreach $one_name (@config_names)
3540 if (&dirname ($one_name) eq $relative_dir)
3542 $local_headers .= ' ' if $local_headers;
3543 $local_headers .= &basename ($one_name);
3548 # This is kind of a hack, but I couldn't see a better way
3549 # to handle it. In this particular case, we need to make
3550 # sure config.h is built before we recurse. We can't do
3551 # this by changing the order of dependencies to the "all"
3552 # because that breaks when using parallel makes. Instead
3553 # we handle things explicitly.
3554 $output_rules .= ("all-recursive-am: ${local_headers}"
3556 . '$(MAKE) $(AM_MAKEFLAGS)'
3559 $all_target = 'all-recursive-am';
3560 push (@phony, 'all-recursive-am');
3564 # Print definitions users can use.
3565 &do_one_merge_target ('install-exec', @install_exec);
3566 $output_rules .= "\n";
3568 &do_one_merge_target ('install-data', @install_data);
3569 $output_rules .= "\n";
3571 &do_one_merge_target ('install', 'all-am');
3572 &do_one_merge_target ('uninstall', @uninstall);
3574 &do_one_merge_target ('all', @all);
3576 # Generate the new 'install-strip' target. We can't just set
3577 # INSTALL_PROGRAM because that might be a relative path.
3578 $output_rules .= ("install-strip:\n\t"
3579 . '$(MAKE) $(AM_MAKEFLAGS) INSTALL_STRIP_FLAG=-s install'
3581 push (@phony, 'install-strip');
3584 # Helper for handle_merge_targets. Note that handle_merge_targets
3585 # relies on the fact that this doesn't add an extra \n at the end.
3586 sub do_one_merge_target
3588 local ($name, @values) = @_;
3590 if (&target_defined ($name . '-local'))
3592 # User defined local form of target. So include it.
3593 push (@values, $name . '-local');
3594 push (@phony, $name . '-local');
3597 &pretty_print_rule ($name . "-am:", "\t\t", @values);
3598 if ($name eq 'install')
3600 # Special-case `install-am' to run install-exec-am and
3601 # install-data-am after all-am is built.
3602 &pretty_print_rule ("\t\@\$(MAKE) \$(AM_MAKEFLAGS)", "\t ",
3603 'install-exec-am', 'install-data-am');
3605 elsif ($name eq 'install-exec' && &target_defined ('install-exec-hook'))
3607 $output_rules .= ("\t\@\$(NORMAL_INSTALL)\n"
3608 . "\t" . '$(MAKE) $(AM_MAKEFLAGS) install-exec-hook'
3611 elsif ($name eq 'install-data' && &target_defined ('install-data-hook'))
3613 $output_rules .= ("\t\@\$(NORMAL_INSTALL)\n"
3614 . "\t" . '$(MAKE) $(AM_MAKEFLAGS) install-data-hook'
3618 local ($lname) = $name . ($recursive_install ? '-recursive' : '-am');
3619 local ($tname) = $name;
3620 # To understand this special case, see handle_merge_targets.
3623 $tname = 'all-redirect';
3624 $lname = $all_target if $recursive_install;
3625 push (@phony, 'all-redirect');
3626 $output_all = "all: all-redirect\n";
3628 &pretty_print_rule ($tname . ":", "\t\t", $lname);
3629 push (@phony, $name . '-am', $name);
3632 # Handle check merge target specially.
3633 sub do_check_merge_target
3635 if (&target_defined ('check-local'))
3637 # User defined local form of target. So include it.
3638 push (@check_tests, 'check-local');
3639 push (@phony, 'check-local');
3642 # In --cygnus mode, check doesn't depend on all.
3645 # Just run the local check rules.
3646 &pretty_print_rule ('check-am:', "\t\t", @check);
3650 # The check target must depend on the local equivalent of
3651 # `all', to ensure all the primary targets are built. Then it
3652 # must build the local check rules.
3653 $output_rules .= "check-am: all-am\n";
3654 &pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ",
3658 &pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ",
3662 push (@phony, 'check', 'check-am');
3663 $output_rules .= ("check: "
3664 . ($recursive_install ? 'check-recursive' : 'check-am')
3668 # Handle all 'clean' targets.
3671 local ($xform) = '';
3674 # Don't include `MAINTAINER'; it is handled specially below.
3675 foreach $name ('MOSTLY', '', 'DIST')
3677 if (! &variable_defined ($name . 'CLEANFILES'))
3679 $xform .= 's/^' . $name . 'CLEAN.*$//;';
3683 $xform .= 's/^' . $name . 'CLEAN//;';
3687 # Built sources are automatically removed by maintainer-clean.
3688 push (@maintainer_clean_files, '\$(BUILT_SOURCES)')
3689 if &variable_defined ('BUILT_SOURCES');
3690 push (@maintainer_clean_files, '\$(MAINTAINERCLEANFILES)')
3691 if &variable_defined ('MAINTAINERCLEANFILES');
3692 if (! @maintainer_clean_files)
3694 $xform .= 's/^MAINTAINERCLEAN.*$//;';
3698 $xform .= ('s/^MAINTAINERCLEAN//;'
3699 # Join with no space to avoid spurious `test -z'
3700 # success at runtime.
3701 . 's,\@MCFILES\@,' . join ('', @maintainer_clean_files)
3703 # A space is required in the join here.
3704 . 's,\@MFILES\@,' . join (' ', @maintainer_clean_files)
3708 $output_rules .= &file_contents_with_transform ($xform, 'clean');
3710 push (@clean, 'generic');
3711 &push_phony_cleaners ('generic');
3713 &do_one_clean_target ('clean', 'mostly', '', @clean);
3714 &do_one_clean_target ('clean', '', 'mostly', @clean);
3715 &do_one_clean_target ('clean', 'dist', '', @clean);
3716 &do_one_clean_target ('clean', 'maintainer-', 'dist', @clean);
3718 push (@phony, 'clean', 'mostlyclean', 'distclean', 'maintainer-clean');
3721 # Helper for handle_clean.
3722 sub do_one_clean_target
3724 local ($target, $name, $last_name, @deps) = @_;
3726 # Change each dependency `BLARG' into `clean-BLARG'.
3727 grep (($_ = $name . 'clean-' . $_) && 0, @deps);
3729 # Push the previous clean target. There is no previous clean
3730 # target if we're doing mostlyclean.
3731 push (@deps, $last_name . $target . '-am')
3732 unless $name eq 'mostly';
3734 # If a -local version of the rule is given, add it to the list.
3735 if (&target_defined ($name . $target . '-local'))
3737 push (@deps, $name . $target . '-local');
3740 # Print the target and the dependencies.
3741 &pretty_print_rule ($name . $target . "-am: ", "\t\t", @deps);
3743 # FIXME: shouldn't we really print these messages before running
3745 if ($name . $target eq 'maintainer-clean')
3747 # Print a special warning.
3749 ("\t\@echo \"This command is intended for maintainers to use;\"\n"
3750 . "\t\@echo \"it deletes files that may require special "
3751 . "tools to rebuild.\"\n");
3753 elsif ($name . $target eq 'distclean')
3755 $output_rules .= "\t-rm -f libtool\n" if $seen_libtool;
3757 $output_rules .= "\n";
3759 # Now generate the actual clean target.
3760 $output_rules .= ($name . $target . ": " . $name . $target
3761 . ($recursive_install ? '-recursive' : '-am')
3764 # We special-case config.status here. If we do it as part of the
3765 # normal clean processing for this directory, then it might be
3766 # removed before some subdir is cleaned. However, that subdir's
3767 # Makefile depends on config.status.
3768 if (($name . $target eq 'maintainer-clean'
3769 || $name . $target eq 'distclean')
3770 && $relative_dir eq '.')
3772 $output_rules .= "\t-rm -f config.status\n";
3774 $output_rules .= "\n";
3777 # Handle .PHONY target.
3780 &pretty_print_rule ('.PHONY:', "", @phony);
3781 $output_rules .= "\n";
3784 # Handle TESTS variable and other checks.
3787 if (defined $options{'dejagnu'})
3789 push (@check_tests, 'check-DEJAGNU');
3790 push (@phony, 'check-DEJAGNU');
3795 $xform = 's/^CYGNUS//;';
3799 $xform = 's/^CYGNUS.*$//;';
3801 $output_rules .= &file_contents_with_transform ($xform, 'dejagnu');
3803 # In Cygnus mode, these are found in the build tree.
3804 # Otherwise they are looked for in $PATH.
3805 &define_program_variable ('EXPECT', 'build', 'expect', 'expect');
3806 &define_program_variable ('RUNTEST', 'src', 'dejagnu', 'runtest');
3808 # Only create site.exp rule if user hasn't already written
3810 if (! &target_defined ('site.exp'))
3812 # Note that in the rule we don't directly generate
3813 # site.exp to avoid the possibility of a corrupted
3814 # site.exp if make is interrupted. Jim Meyering has some
3815 # useful text on this topic.
3816 $output_rules .= ("site.exp: Makefile\n"
3817 . "\t\@echo 'Making a new site.exp file...'\n"
3818 . "\t\@test ! -f site.bak || rm -f site.bak\n"
3819 . "\t\@echo '## these variables are automatically generated by make ##' > \$\@-t\n"
3820 . "\t\@echo '# Do not edit here. If you wish to override these values' >> \$\@-t\n"
3821 . "\t\@echo '# edit the last section' >> \$\@-t\n"
3822 . "\t\@echo 'set tool \$(DEJATOOL)' >> \$\@-t\n"
3823 . "\t\@echo 'set srcdir \$(srcdir)' >> \$\@-t\n"
3824 . "\t\@echo 'set objdir' \`pwd\` >> \$\@-t\n");
3826 # Extra stuff for AC_CANONICAL_*
3827 local (@whatlist) = ();
3828 if ($seen_canonical)
3830 push (@whatlist, 'host');
3833 # Extra stuff only for AC_CANONICAL_SYSTEM.
3834 if ($seen_canonical == $AC_CANONICAL_SYSTEM)
3836 push (@whatlist, 'target', 'build');
3840 foreach $c1 (@whatlist)
3842 foreach $c2 ('alias', 'triplet')
3844 $output_rules .= "\t\@echo 'set ${c1}_${c2} \$(${c1}_${c2})' >> \$\@-t\n";
3848 $output_rules .= ("\t\@echo '## All variables above are generated by configure. Do Not Edit ##' >> \$\@-t\n"
3849 . "\t\@test ! -f site.exp || sed '1,/^## All variables above are.*##/ d' site.exp >> \$\@-t\n"
3850 . "\t\@test ! -f site.exp || mv site.exp site.bak\n"
3851 . "\t\@mv \$\@-t site.exp\n");
3857 foreach $c ('DEJATOOL', 'RUNTEST', 'RUNTESTFLAGS')
3859 if (&variable_defined ($c))
3861 &am_line_error ($c, "\`$c' defined but \`dejagnu' not in \`AUTOMAKE_OPTIONS'");
3866 if (&variable_defined ('TESTS'))
3868 push (@check_tests, 'check-TESTS');
3869 push (@phony, 'check-TESTS');
3871 # Note: Solaris 2.7 seems to expand TESTS using VPATH. That's
3872 # why we also try `dir='
3873 $output_rules .= 'check-TESTS: $(TESTS)
3874 @failed=0; all=0; xfail=0; xpass=0; \\
3875 srcdir=$(srcdir); export srcdir; \\
3876 for tst in $(TESTS); do \\
3877 if test -f ./$$tst; then dir=./; \\
3878 elif test -f $$tst; then dir=; \\
3879 else dir="$(srcdir)/"; fi; \\
3880 if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \\
3881 all=`expr $$all + 1`; \\
3882 case " $(XFAIL_TESTS) " in \\
3884 xpass=`expr $$xpass + 1`; \\
3885 failed=`expr $$failed + 1`; \\
3886 echo "XPASS: $$tst"; \\
3889 echo "PASS: $$tst"; \\
3892 elif test $$? -ne 77; then \\
3893 all=`expr $$all + 1`; \\
3894 case " $(XFAIL_TESTS) " in \\
3896 xfail=`expr $$xfail + 1`; \\
3897 echo "XFAIL: $$tst"; \\
3900 failed=`expr $$failed + 1`; \\
3901 echo "FAIL: $$tst"; \\
3906 if test "$$failed" -eq 0; then \\
3907 if test "$$xfail" -eq 0; then \\
3908 banner="All $$all tests passed"; \\
3910 banner="All $$all tests behaved as expected ($$xfail expected failures)"; \\
3913 if test "$$xpass" -eq 0; then \\
3914 banner="$$failed of $$all tests failed"; \\
3916 banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \\
3919 dashes=`echo "$$banner" | sed s/./=/g`; \\
3923 test "$$failed" -eq 0
3928 # Handle Emacs Lisp.
3929 sub handle_emacs_lisp
3931 local (@elfiles) = &am_install_var ('-candist', 'lisp', 'LISP',
3937 &define_configure_variable ('lispdir');
3938 &define_configure_variable ('EMACS');
3939 $output_rules .= (".el.elc:\n"
3940 . "\t\@echo 'WARNING: Warnings can be ignored. :-)'\n"
3941 . "\tif test \$(EMACS) != no; then \\\n"
3942 . "\t EMACS=\$(EMACS) \$(SHELL) \$(srcdir)/elisp-comp \$<; \\\n"
3944 push (@suffixes, '.el', '.elc');
3946 # Generate .elc files.
3947 grep ($_ .= 'c', @elfiles);
3948 &define_pretty_variable ('ELCFILES', '', @elfiles);
3950 $output_rules .= &file_contents ('lisp-clean');
3951 push (@clean, 'lisp');
3952 &push_phony_cleaners ('lisp');
3954 push (@all, '$(ELCFILES)');
3957 if (&variable_defined ('lisp_LISP'))
3959 $varname = 'lisp_LISP';
3960 &am_error ("\`lisp_LISP' defined but \`AM_PATH_LISPDIR' not in \`configure.in'")
3965 $varname = 'noinst_LISP';
3968 &require_file_with_line ($varname, $FOREIGN, 'elisp-comp');
3975 local (@sourcelist) = &am_install_var ('-candist', '-clean',
3977 'java', 'noinst', 'check');
3978 return if ! @sourcelist;
3980 &define_variable ('JAVAC', 'javac');
3981 &define_variable ('JAVACFLAGS', '');
3982 &define_variable ('CLASSPATH_ENV',
3983 'CLASSPATH=$(JAVAROOT):$(srcdir)/$(JAVAROOT):$$CLASSPATH');
3984 &define_variable ('JAVAROOT', '$(top_builddir)');
3986 local (%valid) = &am_primary_prefixes ('JAVA', 1,
3987 'java', 'noinst', 'check');
3989 local ($dir, $curs);
3990 foreach $curs (keys %valid)
3992 if (! &variable_defined ($curs . '_JAVA') || $curs eq 'noinst'
3993 || $curs eq 'EXTRA')
4000 &am_line_error ($curs . '_JAVA',
4001 "multiple _JAVA primaries in use");
4006 $output_rules .= ('class' . $dir . '.stamp: $(' . $dir . '_JAVA)' . "\n"
4007 . "\t" . '$(CLASSPATH_ENV) $(JAVAC) -d $(JAVAROOT) '
4008 . '$(JAVACFLAGS) $?' . "\n"
4009 . "\t" . 'echo timestamp > class' . $dir . '.stamp'
4011 push (@all, 'class' . $dir . '.stamp');
4012 &push_dist_common ('$(' . $dir . '_JAVA)');
4015 # Handle some of the minor options.
4016 sub handle_minor_options
4018 if (defined $options{'readme-alpha'})
4020 if ($relative_dir eq '.')
4022 if ($package_version !~ /^$GNITS_VERSION_PATTERN$/)
4024 # FIXME: allow real filename.
4025 &am_conf_line_error ('configure.in',
4026 $package_version_line,
4027 "version \`$package_version' doesn't follow Gnits standards");
4029 elsif (defined $1 && -f 'README-alpha')
4031 # This means we have an alpha release. See
4032 # GNITS_VERSION_PATTERN for details.
4033 &require_file ($FOREIGN, 'README-alpha');
4039 ################################################################
4041 # Scan one file for interesting things. Subroutine of scan_configure.
4042 sub scan_one_configure_file
4044 local ($filename) = @_;
4047 open (CONFIGURE, $filename)
4048 || die "automake: couldn't open \`$filename': $!\n";
4049 print "automake: reading $filename\n" if $verbose;
4053 # Remove comments from current line.
4057 # Skip macro definitions. Otherwise we might be confused into
4058 # thinking that a macro that was only defined was actually
4062 # Follow includes. This is a weirdness commonly in use at
4063 # Cygnus and hopefully nowhere else.
4064 if (/sinclude\((.*)\)/ && -f $1)
4066 &scan_one_configure_file ($1);
4069 # Populate libobjs array.
4070 if (/AC_FUNC_ALLOCA/)
4072 $libsources{'alloca.c'} = 1;
4074 elsif (/AC_FUNC_GETLOADAVG/)
4076 $libsources{'getloadavg.c'} = 1;
4078 elsif (/AC_FUNC_MEMCMP/)
4080 $libsources{'memcmp.c'} = 1;
4082 elsif (/AC_STRUCT_ST_BLOCKS/)
4084 $libsources{'fileblocks.c'} = 1;
4086 elsif (/A[CM]_REPLACE_GNU_GETOPT/)
4088 $libsources{'getopt.c'} = 1;
4089 $libsources{'getopt1.c'} = 1;
4091 elsif (/AM_FUNC_STRTOD/)
4093 $libsources{'strtod.c'} = 1;
4095 elsif (/AM_WITH_REGEX/)
4097 $libsources{'rx.c'} = 1;
4098 $libsources{'rx.h'} = 1;
4099 $libsources{'regex.c'} = 1;
4100 $libsources{'regex.h'} = 1;
4101 $omit_dependencies{'rx.h'} = 1;
4102 $omit_dependencies{'regex.h'} = 1;
4104 elsif (/AM_FUNC_MKTIME/)
4106 $libsources{'mktime.c'} = 1;
4108 elsif (/AM_FUNC_ERROR_AT_LINE/)
4110 $libsources{'error.c'} = 1;
4111 $libsources{'error.h'} = 1;
4113 elsif (/AM_FUNC_OBSTACK/)
4115 $libsources{'obstack.c'} = 1;
4116 $libsources{'obstack.h'} = 1;
4118 elsif (/LIBOBJS="(.*)\s+\$LIBOBJS"/
4119 || /LIBOBJS="\$LIBOBJS\s+(.*)"/)
4121 foreach $libobj_iter (split (' ', $1))
4123 if ($libobj_iter =~ /^(.*)\.o(bj)?$/
4124 || $libobj_iter =~ /^(.*)\.\$ac_objext$/
4125 || $libobj_iter =~ /^(.*)\.\$\{ac_objext\}$/)
4127 $libsources{$1 . '.c'} = 1;
4132 if (! $in_ac_replace && s/AC_REPLACE_FUNCS\s*\(\[?//)
4138 $in_ac_replace = 0 if s/[\]\)].*$//;
4139 # Remove trailing backslash.
4143 # Need to skip empty elements for Perl 4.
4145 $libsources{$_ . '.c'} = 1;
4149 if (/$obsolete_rx/o)
4152 if ($obsolete_macros{$1} ne '')
4154 $hint = '; ' . $obsolete_macros{$1};
4156 &am_conf_line_error ($filename, $., "\`$1' is obsolete$hint");
4159 # Process the AC_OUTPUT macro.
4160 if (! $in_ac_output && s/AC_OUTPUT\s*\(\[?//)
4163 $ac_output_line = $.;
4167 local ($closing) = 0;
4174 # Look at potential Makefile.am's.
4177 # Must skip empty string for Perl 4.
4178 next if $_ eq "\\" || $_ eq '';
4180 # Handle $local:$input syntax. Note that we ignore
4181 # every input file past the first, though we keep
4182 # those around for later.
4183 local ($local, $input, @rest) = split (/:/);
4190 # FIXME: should be error if .in is missing.
4191 $input =~ s/\.in$//;
4194 if (-f $input . '.am')
4196 # We have a file that automake should generate.
4197 push (@make_input_list, $input);
4198 $make_list{$input} = join (':', ($local, @rest));
4202 # We have a file that automake should cause to be
4203 # rebuilt, but shouldn't generate itself.
4204 push (@other_input_files, $_);
4208 if ($closing && @make_input_list == 0 && @other_input_files == 0)
4210 &am_conf_line_error ($filename, $ac_output_line,
4211 "No files mentioned in \`AC_OUTPUT'");
4216 if (/$AC_CONFIG_AUX_DIR_PATTERN/o)
4218 @config_aux_path = $1;
4221 # Check for ansi2knr.
4222 $am_c_prototypes = 1 if /AM_C_PROTOTYPES/;
4224 # Check for exe extension stuff.
4228 $configure_vars{'EXEEXT'} = $filename . ':' . $.;
4234 $configure_vars{'OBJEXT'} = $filename . ':' . $.;
4237 # Check for NLS support.
4238 if (/AM_GNU_GETTEXT/)
4241 $ac_gettext_line = $.;
4242 $omit_dependencies{'libintl.h'} = 1;
4245 # Look for ALL_LINGUAS.
4246 if (/ALL_LINGUAS="(.*)"$/ || /ALL_LINGUAS=(.*)$/)
4250 $all_linguas_line = $.;
4253 # Handle configuration headers. A config header of `[$1]'
4254 # means we are actually scanning AM_CONFIG_HEADER from
4256 if (/A([CM])_CONFIG_HEADER\s*\((.*)\)/
4260 ($filename, $., "\`automake requires \`AM_CONFIG_HEADER', not \`AC_CONFIG_HEADER'")
4263 $config_header_line = $.;
4265 foreach $one_hdr (split (' ', $2))
4267 push (@config_fullnames, $one_hdr);
4268 if ($one_hdr =~ /^([^:]+):(.+)$/)
4270 push (@config_names, $1);
4271 push (@config_headers, $2);
4275 push (@config_names, $one_hdr);
4276 push (@config_headers, $one_hdr . '.in');
4281 # Handle AC_CANONICAL_*. Always allow upgrading to
4282 # AC_CANONICAL_SYSTEM, but never downgrading.
4283 $seen_canonical = $AC_CANONICAL_HOST
4284 if ! $seen_canonical
4285 && (/AC_CANONICAL_HOST/ || /AC_CHECK_TOOL/);
4286 $seen_canonical = $AC_CANONICAL_SYSTEM if /AC_CANONICAL_SYSTEM/;
4288 $seen_path_xtra = 1 if /AC_PATH_XTRA/;
4290 # This macro handles several different things.
4291 if (/$AM_INIT_AUTOMAKE_PATTERN/o)
4297 $seen_prog_install = 1;
4298 ($package_version = $1) =~ s/$AM_PACKAGE_VERSION_PATTERN/$1/o;
4299 $package_version_line = $.;
4302 # This is like AM_INIT_AUTOMAKE, but doesn't actually set the
4303 # package and version number. (This might change in the
4304 # future). Yes, I'm not above hacking Automake so it works
4305 # well with other GNU tools -- that is actually the point.
4306 if (/AM_INIT_GUILE_MODULE/)
4312 $seen_prog_install = 1;
4313 @config_aux_path = ('..');
4316 # Some things required by Automake.
4317 $seen_make_set = 1 if /AC_PROG_MAKE_SET/;
4318 $seen_arg_prog = 1 if /AC_ARG_PROGRAM/;
4322 $configure_vars{'LEX'} = $filename . ':' . $.;
4323 $seen_decl_yytext = 1;
4325 if (/AC_DECL_YYTEXT/ && $filename =~ /configure\.in$/)
4327 &am_conf_line_warning ($filename, $., "\`AC_DECL_YYTEXT' is covered by \`AM_PROG_LEX'");
4329 if (/AC_PROG_LEX/ && $filename =~ /configure\.in$/)
4331 &am_conf_line_warning ($filename, $., "automake requires \`AM_PROG_LEX', not \`AC_PROG_LEX'");
4334 if (/AC_PROG_(F77|YACC|RANLIB|CC|CXXCPP|CXX|LEX|AWK|CPP|LN_S)/)
4336 $configure_vars{$1} = $filename . ':' . $.;
4338 if (/$AC_CHECK_PATTERN/o)
4340 $configure_vars{$3} = $filename . ':' . $.;
4342 if (/$AM_MISSING_PATTERN/o
4346 && $1 ne 'AUTOHEADER')
4348 $configure_vars{$1} = $filename . ':' . $.;
4351 # Explicitly avoid ANSI2KNR -- we AC_SUBST that in protos.m4,
4352 # but later define it elsewhere. This is pretty hacky. We
4353 # also explicitly avoid INSTALL_SCRIPT and some other
4354 # variables because they are defined in header-vars.am.
4356 if (/$AC_SUBST_PATTERN/o
4358 && $1 ne 'INSTALL_SCRIPT'
4359 && $1 ne 'INSTALL_DATA')
4361 $configure_vars{$1} = $filename . ':' . $.;
4364 $seen_decl_yytext = 1 if /AC_DECL_YYTEXT/;
4365 if (/AM_MAINTAINER_MODE/)
4367 $seen_maint_mode = 1;
4368 $configure_cond{'MAINTAINER_MODE'} = 1;
4370 $seen_package = 1 if /PACKAGE=/;
4372 # Skip VERSION of [$2]; that is from AM_INIT_AUTOMAKE.
4373 if (/\bVERSION=(\S+)/ && $1 ne '[$2]')
4376 $package_version = $1;
4377 $package_version_line = $.;
4384 $seen_prog_install = 1 if /AC_PROG_INSTALL/;
4385 $seen_lispdir = 1 if /AM_PATH_LISPDIR/;
4387 if (/A(C|M)_PROG_LIBTOOL/)
4389 if (/AM_PROG_LIBTOOL/)
4391 &am_conf_line_warning ($filename, $., "\`AM_PROG_LIBTOOL' is obsolete, use \`AC_PROG_LIBTOOL' instead");
4395 $configure_vars{'LIBTOOL'} = $filename . ':' . $.;
4396 $configure_vars{'RANLIB'} = $filename . ':' . $.;
4397 $configure_vars{'CC'} = $filename . ':' . $.;
4398 # AC_PROG_LIBTOOL runs AC_CANONICAL_HOST. Make sure we
4399 # never downgrade (if we've seen AC_CANONICAL_SYSTEM).
4400 $seen_canonical = $AC_CANONICAL_HOST if ! $seen_canonical;
4403 $seen_multilib = 1 if (/AM_ENABLE_MULTILIB/);
4405 if (/$AM_CONDITIONAL_PATTERN/o)
4407 $configure_cond{$1} = 1;
4410 # Check for Fortran 77 intrinsic and run-time libraries.
4411 if (/AC_F77_LIBRARY_LDFLAGS/)
4413 $configure_vars{'FLIBS'} = $filename . ':' . $.;
4420 # Scan configure.in and aclocal.m4 for interesting things. We must
4421 # scan aclocal.m4 because there might be AC_SUBSTs and such there.
4424 # Reinitialize libsources here. This isn't really necessary,
4425 # since we currently assume there is only one configure.in. But
4426 # that won't always be the case.
4429 local ($in_ac_output, $in_ac_replace) = (0, 0);
4430 local (%make_list, @make_input_list);
4431 local ($libobj_iter);
4433 &scan_one_configure_file ('configure.in');
4434 &scan_one_configure_file ('aclocal.m4')
4437 # Set input and output files if not specified by user.
4440 @input_files = @make_input_list;
4441 %output_files = %make_list;
4444 &am_conf_error ("\`PACKAGE' not defined in configure.in")
4446 &am_conf_error ("\`VERSION' not defined in configure.in")
4449 # Look for some files we need. Always check for these. This
4450 # check must be done for every run, even those where we are only
4451 # looking at a subdir Makefile. We must set relative_dir so that
4452 # the file-finding machinery works.
4453 local ($relative_dir) = '.';
4454 &require_config_file ($FOREIGN, 'install-sh', 'mkinstalldirs', 'missing');
4455 &am_error ("\`install.sh' is an anachronism; use \`install-sh' instead")
4456 if -f $config_aux_path[0] . '/install.sh';
4459 ################################################################
4461 # Set up for Cygnus mode.
4464 return unless $cygnus_mode;
4466 &set_strictness ('foreign');
4467 $options{'no-installinfo'} = 1;
4468 $options{'no-dependencies'} = 1;
4469 $use_dependencies = 0;
4471 if (! $seen_maint_mode)
4473 &am_conf_error ("\`AM_MAINTAINER_MODE' required when --cygnus specified");
4478 &am_conf_error ("\`AC_EXEEXT' required when --cygnus specified");
4482 # Do any extra checking for GNU standards.
4483 sub check_gnu_standards
4485 if ($relative_dir eq '.')
4487 # In top level (or only) directory.
4488 &require_file ($GNU, 'INSTALL', 'NEWS', 'README', 'COPYING',
4489 'AUTHORS', 'ChangeLog');
4492 if ($strictness >= $GNU)
4494 if (defined $options{'no-installman'})
4496 &am_line_error ('AUTOMAKE_OPTIONS',
4497 "option \`no-installman' disallowed by GNU standards");
4500 if (defined $options{'no-installinfo'})
4502 &am_line_error ('AUTOMAKE_OPTIONS',
4503 "option \`no-installinfo' disallowed by GNU standards");
4508 # Do any extra checking for GNITS standards.
4509 sub check_gnits_standards
4511 if ($strictness >= $GNITS)
4513 if (-f $relative_dir . '/COPYING.LIB')
4515 &am_error ("\`${relative_dir}/COPYING.LIB' disallowed by Gnits standards");
4519 if ($relative_dir eq '.')
4521 # In top level (or only) directory.
4522 &require_file ($GNITS, 'THANKS');
4526 ################################################################
4528 # Functions to handle files of each language.
4530 # Each `lang_X_rewrite' function follows a simple formula:
4531 # * Args are the base name and extension of the file.
4532 # * Return value is 1 if file is to be dealt with, 0 otherwise.
4533 # Much of the actual processing is handled in handle_single_transform_list.
4534 # These functions exist so that auxiliary information can be recorded
4535 # for a later cleanup pass. Note that the calls to these functions
4536 # are computed, so don't bother searching for their precise names
4539 # Rewrite a single C source file.
4542 local ($base, $ext) = @_;
4544 if (defined $options{'ansi2knr'} && $base =~ /_$/)
4546 # FIXME: include line number in error.
4547 &am_error ("C source file \`$base.c' would be deleted by ansi2knr rules");
4550 $de_ansi_files{$base} = 1;
4551 return $LANG_PROCESS;
4554 # Rewrite a single C++ source file.
4555 sub lang_cxx_rewrite
4557 return $LANG_PROCESS;
4560 # Rewrite a single header file.
4561 sub lang_header_rewrite
4563 # Header files are simply ignored.
4564 return $LANG_IGNORE;
4567 # Rewrite a single yacc file.
4568 sub lang_yacc_rewrite
4570 local ($base, $ext) = @_;
4572 &lang_c_rewrite ($base, $ext);
4573 $yacc_sources{$base . '.' . $ext} = 1;
4575 &saw_extension ('c');
4576 &push_dist_common ($base . '.' . $ext);
4577 return $LANG_PROCESS;
4580 # Rewrite a single yacc++ file.
4581 sub lang_yaccxx_rewrite
4583 local ($base, $ext) = @_;
4585 $yacc_sources{$base . '.' . $ext} = 1;
4587 &saw_extension ($ext);
4588 &push_dist_common ($base . '.' . $ext);
4589 return $LANG_PROCESS;
4592 # Rewrite a single lex file.
4593 sub lang_lex_rewrite
4595 local ($base, $ext) = @_;
4597 &lang_c_rewrite ($base, $ext);
4598 $lex_sources{$base . '.' . $ext} = 1;
4600 &saw_extension ('c');
4601 &push_dist_common ($base . '.' . $ext);
4602 return $LANG_PROCESS;
4605 # Rewrite a single lex++ file.
4606 sub lang_lexxx_rewrite
4608 local ($base, $ext) = @_;
4610 $lex_sources{$base . '.' . $ext} = 1;
4612 &saw_extension ($ext);
4613 &push_dist_common ($base . '.' . $ext);
4614 return $LANG_PROCESS;
4617 # Rewrite a single assembly file.
4618 sub lang_asm_rewrite
4620 return $LANG_PROCESS;
4623 # Rewrite a single Fortran 77 file.
4624 sub lang_f77_rewrite
4626 return $LANG_PROCESS;
4629 # Rewrite a single preprocessed Fortran 77 file.
4630 sub lang_ppf77_rewrite
4632 return $LANG_PROCESS;
4635 # Rewrite a single ratfor file.
4636 sub lang_ratfor_rewrite
4638 return $LANG_PROCESS;
4641 # Rewrite a single Objective C file.
4642 sub lang_objc_rewrite
4644 return $LANG_PROCESS;
4647 # Rewrite a single Java file.
4648 sub lang_java_rewrite
4650 return $LANG_SUBDIR;
4653 # The lang_X_finish functions are called after all source file
4654 # processing is done. Each should handle defining rules for the
4655 # language, etc. A finish function is only called if a source file of
4656 # the appropriate type has been seen.
4660 # Push all libobjs files onto de_ansi_files. We actually only
4661 # push files which exist in the current directory, and which are
4662 # genuine source files.
4664 foreach $file (keys %libsources)
4666 if ($file =~ /^(.*)\.[cly]$/ && -f "$relative_dir/$file")
4668 $de_ansi_files{$1} = 1;
4672 if (defined $options{'ansi2knr'} && keys %de_ansi_files)
4674 # Make all _.c files depend on their corresponding .c files.
4675 local ($base, @objects);
4676 foreach $base (sort keys %de_ansi_files)
4678 # Each _.c file must depend on ansi2knr; otherwise it
4679 # might be used in a parallel build before it is built.
4680 # We need to support files in the srcdir and in the build
4681 # dir (because these files might be auto-generated. But
4682 # we can't use $< -- some makes only define $< during a
4684 $output_rules .= ($base . "_.c: $base.c \$(ANSI2KNR)\n\t"
4685 . '$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) '
4686 . '`if test -f $(srcdir)/' . $base . '.c'
4687 . '; then echo $(srcdir)/' . $base . '.c'
4688 . '; else echo ' . $base . '.c; fi` '
4689 . "| sed 's/^# \\([0-9]\\)/#line \\1/' "
4690 . '| $(ANSI2KNR) > ' . $base . "_.c\n");
4691 push (@objects, $base . '_'
4692 . ($seen_objext ? '.$(OBJEXT)' : '.o'));
4693 push (@objects, $base . '_.lo') if $seen_libtool;
4696 # Make all _.o (and _.lo) files depend on ansi2knr.
4697 # Use a sneaky little hack to make it print nicely.
4698 &pretty_print_rule ('', '', @objects, ':', '$(ANSI2KNR)');
4701 if (! defined $configure_vars{'CC'})
4703 # FIXME: line number.
4704 &am_error ("C source seen but \`CC' not defined in \`configure.in'");
4710 local (@cxx_list) = &lang_extensions ('cxx');
4711 local ($cxx_count) = scalar @cxx_list;
4714 push (@suffixes, @cxx_list);
4716 local ($ltcompile, $ltlink) = &libtool_compiler;
4718 &define_configure_variable ("CXXFLAGS");
4719 &define_compiler_variable ('CXXCOMPILE', $ltcompile, '$(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)');
4721 &define_variable ('CXXLD', '$(CXX)');
4722 &define_variable ('CXXLINK', $ltlink . '$(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@');
4725 foreach $ext (@cxx_list)
4727 $output_rules .= ("$ext.o:\n"
4728 . "\t\$(CXXCOMPILE) -c \$<\n");
4729 # FIXME: Using cygpath should be somehow conditional.
4730 $output_rules .= ("$ext.obj:\n"
4731 . "\t\$(CXXCOMPILE) -c `cygpath -w \$<`\n")
4733 $output_rules .= ("$ext.lo:\n"
4734 . "\t\$(LTCXXCOMPILE) -c \$<\n")
4738 if (! defined $configure_vars{'CXX'})
4740 &am_error ("C++ source seen but \`CXX' not defined in \`configure.in'");
4745 sub lang_header_finish
4750 # This is a helper for both lex and yacc.
4751 sub yacc_lex_finish_helper
4753 return if defined $language_scratch{'lex-yacc-done'};
4754 $language_scratch{'lex-yacc-done'} = 1;
4756 # If there is more than one distinct yacc (resp lex) source file
4757 # in a given directory, then the `ylwrap' program is required to
4758 # allow parallel builds to work correctly. FIXME: for now, no
4760 &require_config_file ($FOREIGN, 'ylwrap');
4761 if ($config_aux_dir ne '.' && $config_aux_dir ne '')
4763 &define_variable ('YLWRAP', $config_aux_dir . "/ylwrap");
4767 &define_variable ('YLWRAP', '$(srcdir)/ylwrap');
4771 sub lang_yacc_finish
4773 return if defined $language_scratch{'yacc-done'};
4774 $language_scratch{'yacc-done'} = 1;
4776 local ($file, $base, $hname, $cname);
4777 local (%seen_suffix) = ();
4778 local (@yacc_files) = sort keys %yacc_sources;
4779 local ($yacc_count) = scalar (@yacc_files);
4780 foreach $file (@yacc_files)
4783 &output_yacc_build_rule ($1, $yacc_count > 1)
4784 if ! defined $seen_suffix{$1};
4785 $seen_suffix{$1} = 1;
4787 $file =~ /^(.*)\.(y|yy|y\+\+|yxx|ypp)$/;
4789 $hname = 'h'; # Always use `.h' for header file.
4790 ($cname = $2) =~ tr/y/c/;
4792 if ((&variable_defined ('AM_YFLAGS')
4793 && &variable_value ('AM_YFLAGS') =~ /(^|\s)-d(\s|$)/)
4794 || (&variable_defined ('YFLAGS')
4795 && &variable_value ('YFLAGS') =~ /(^|\s)-d(\s|$)/)) {
4796 # Now generate rule to make the header file. This should only
4797 # be generated if `yacc -d' specified.
4798 $output_rules .= "${base}.${hname}: ${base}.${cname}\n";
4800 # If the files are built in the build directory, then we want
4801 # to remove them with `make clean'. If they are in srcdir
4802 # they shouldn't be touched. However, we can't determine this
4803 # statically, and the GNU rules say that yacc/lex output files
4804 # should be removed by maintainer-clean. So that's what we
4806 push (@maintainer_clean_files, "${base}.${hname}");
4808 push_dist_common ("${base}.${hname}");
4810 push (@maintainer_clean_files, "${base}.${cname}");
4812 $output_rules .= "\n";
4814 if (! defined $configure_vars{'YACC'})
4816 &am_error ("yacc source seen but \`YACC' not defined in \`configure.in'");
4818 if (&variable_defined ('YACCFLAGS'))
4820 &am_line_error ('YACCFLAGS',
4821 "\`YACCFLAGS' obsolete; use \`YFLAGS' instead");
4824 if ($yacc_count > 1)
4826 &yacc_lex_finish_helper;
4830 sub lang_yaccxx_finish
4837 return if defined $language_scratch{'lex-done'};
4838 $language_scratch{'lex-done'} = 1;
4840 local (%seen_suffix) = ();
4841 local ($file, $cname);
4842 local ($lex_count) = scalar (keys %lex_sources);
4843 foreach $file (sort keys %lex_sources)
4846 &output_lex_build_rule ($1, $lex_count > 1)
4847 if (! defined $seen_suffix{$1});
4848 $seen_suffix{$1} = 1;
4850 # If the files are built in the build directory, then we want
4851 # to remove them with `make clean'. If they are in srcdir
4852 # they shouldn't be touched. However, we can't determine this
4853 # statically, and the GNU rules say that yacc/lex output files
4854 # should be removed by maintainer-clean. So that's what we
4856 $file =~ /^(.*)\.(l|ll|l\+\+|lxx|lpp)$/;
4857 ($cname = $2) =~ tr/l/c/;
4858 push (@maintainer_clean_files, "${1}.${cname}");
4861 if (! defined $configure_vars{'LEX'})
4863 &am_error ("lex source seen but \`LEX' not defined in \`configure.in'");
4865 if (! $seen_decl_yytext)
4867 &am_error ("lex source seen but \`AC_DECL_YYTEXT' not in \`configure.in'");
4872 &yacc_lex_finish_helper;
4876 sub lang_lexxx_finish
4889 local (@f77_list) = &lang_extensions ('f77');
4890 local ($f77_count) = scalar @f77_list;
4893 push (@suffixes, @f77_list);
4895 local ($ltcompile, $ltlink) = &libtool_compiler;
4897 &define_configure_variable ('FFLAGS');
4898 &define_compiler_variable ('F77COMPILE', $ltcompile,
4899 '$(F77) $(AM_FFLAGS) $(FFLAGS)');
4901 &define_variable ('F77LD', '$(F77)');
4902 &define_variable ('F77LINK', $ltlink . '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@');
4905 foreach $ext (@f77_list)
4907 $output_rules .= ("$ext.o:\n"
4908 . "\t\$(F77COMPILE) -c \$<\n");
4909 # FIXME: Using cygpath should be somehow conditional.
4910 $output_rules .= ("$ext.obj:\n"
4911 . "\t\$(F77COMPILE) -c `cygpath -w \$<`\n")
4913 $output_rules .= ("$ext.lo:\n"
4914 . "\t\$(LTF77COMPILE) -c \$<\n")
4918 if (! defined $configure_vars{'F77'})
4920 &am_error ("Fortran 77 source seen but \`F77' not defined in \`configure.in'");
4925 # Preprocessed Fortran 77
4927 # The current support for preprocessing Fortran 77 just involves passing
4928 # `$(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS)' as additional flags
4929 # to the Fortran 77 compiler, since this is how GNU Make does it; see
4930 # the `GNU Make Manual, Edition 0.51 for `make' Version 3.76 Beta'
4931 # (specifically, from info file `(make)Catalogue of Rules').
4933 # A better approach would be to write an Autoconf test
4934 # (i.e. AC_PROG_FPP) for a Fortran 77 preprocessor, because not all
4935 # Fortran 77 compilers know how to do preprocessing. The Autoconf macro
4936 # AC_PROG_FPP should test the Fortran 77 compiler first for
4937 # preprocessing capabilities, and then fall back on cpp (if cpp were
4939 sub lang_ppf77_finish
4942 last unless $extension_seen{$ext};
4945 push (@suffixes, $ext);
4947 local ($ltcompile, $ltlink) = &libtool_compiler;
4949 &define_configure_variable ('FFLAGS');
4950 &define_compiler_variable ('F77COMPILE', $ltcompile,
4951 '$(F77) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FFLAGS) $(FFLAGS)');
4953 &define_variable ('F77LD', '$(F77)');
4954 &define_variable ('F77LINK', $ltlink . '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@');
4956 $output_rules .= ("$ext.o:\n"
4957 . "\t\$(F77COMPILE) -c \$<\n");
4958 # FIXME: Using cygpath should be somehow conditional.
4959 $output_rules .= ("$ext.obj:\n"
4960 . "\t\$(F77COMPILE) -c `cygpath -w \$<`\n")
4962 $output_rules .= ("$ext.lo:\n"
4963 . "\t\$(LTF77COMPILE) -c \$<\n")
4966 # We also handle the case of preprocessing `.F' files into `.f'
4968 $output_rules .= ("$ext.f:\n"
4969 . "\t\$(F77COMPILE) -F \$<\n");
4971 if (! defined $configure_vars{'F77'})
4973 &am_error ("Fortran 77 source seen but \`F77' not defined in \`configure.in'");
4977 sub lang_ratfor_finish
4980 last unless $extension_seen{$ext};
4982 push (@suffixes, $ext);
4984 local ($ltcompile, $ltlink) = &libtool_compiler;
4986 &define_configure_variable ('FFLAGS');
4987 &define_configure_variable ('RFLAGS');
4988 &define_variable ('RCOMPILE', $ltcompile,
4989 '$(F77) $(AM_FFLAGS) $(FFLAGS) $(AM_RFLAGS) $(RFLAGS)');
4991 &define_variable ('F77LD', '$(F77)');
4992 &define_variable ('F77LINK', $ltlink . '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_RFLAGS) $(RFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@');
4994 $output_rules .= ("$ext.o:\n"
4995 . "\t\$(RCOMPILE) -c \$<\n");
4996 # FIXME: Using cygpath should be somehow conditional.
4997 $output_rules .= ("$ext.obj:\n"
4998 . "\t\$(RCOMPILE) -c `cygpath -w \$<`\n")
5000 $output_rules .= ("$ext.lo:\n"
5001 . "\t\$(LTRCOMPILE) -c \$<\n")
5004 # We also handle the case of preprocessing `.r' files into `.f'
5006 $output_rules .= ("$ext.f:\n"
5007 . "\t\$(RCOMPILE) -F \$<\n");
5009 if (! defined $configure_vars{'F77'})
5011 &am_error ("Ratfor source seen but \`F77' not defined in \`configure.in'");
5015 sub lang_objc_finish
5017 push (@suffixes, '.m');
5019 local ($ltcompile, $ltlink) = &libtool_compiler;
5021 &define_configure_variable ("OBJCFLAGS");
5022 &define_compiler_variable ('OBJCCOMPILE', $ltcompile,
5023 '$(OBJC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_OBJCFLAGS) $(OBJCFLAGS)');
5025 &define_variable ('OBJCLD', '$(OBJC)');
5026 &define_variable ('OBJCLINK', $ltlink . '$(OBJCLD) $(AM_OBJCFLAGS) $(OBJCFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@');
5028 $output_rules .= (".m.o:\n"
5029 . "\t\$(OBJCCOMPILE) -c \$<\n");
5030 # FIXME: Using cygpath should be somehow conditional.
5031 $output_rules .= (".m.obj:\n"
5032 . "\t\$(OBJCCOMPILE) -c `cygpath -w \$<`\n")
5034 $output_rules .= (".m.lo:\n"
5035 . "\t\$(LTOBJCCOMPILE) -c \$<\n")
5038 if (! defined $configure_vars{'OBJC'})
5040 &am_error ("Objective C source seen but \`OBJC' not defined in \`configure.in'");
5044 sub lang_java_finish
5046 push (@suffixes, '.java');
5048 local ($ltcompile, $ltlink) = &libtool_compiler;
5050 &define_configure_variable ("GCJFLAGS");
5051 &define_compiler_variable ('GCJCOMPILE', $ltcompile,
5052 '$(GCJ) $(DEFS) $(INCLUDES) $(AM_GCJFLAGS) $(GCJFLAGS)');
5054 &define_variable ('GCJLD', '$(GCJ)');
5055 &define_variable ('GCJLINK', $ltlink . '$(GCJLD) $(AM_GCJFLAGS) $(GCJFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@');
5057 $output_rules .= (".java.o:\n"
5058 . "\t\$(GCJCOMPILE) -c \$<\n");
5059 # FIXME: Using cygpath should be somehow conditional.
5060 $output_rules .= (".java.obj:\n"
5061 . "\t\$(GCJCOMPILE) -c `cygpath -w \$<`\n")
5063 $output_rules .= (".java.lo:\n"
5064 . "\t\$(LTGCJCOMPILE) -c \$<\n")
5067 if (! defined $configure_vars{'GCJ'})
5069 &am_error ("Java source seen but \`GCJ' not defined in \`configure.in'");
5073 # A helper which computes a sorted list of all extensions for LANG.
5078 foreach $key (sort keys %extension_seen)
5080 push (@r, '.' . $key) if $extension_map{$key} eq $lang;
5085 # A helper which decides whether libtool is needed. Returns prefix
5086 # for compiler and linker.
5087 sub libtool_compiler
5089 local ($ltcompile, $ltlink) = ('', '');
5092 &define_configure_variable ("LIBTOOL");
5093 $ltcompile = '$(LIBTOOL) --mode=compile ';
5094 $ltlink = '$(LIBTOOL) --mode=link ';
5096 return ($ltcompile, $ltlink);
5099 # Given a hash table of linker names, pick the name that has the most
5100 # precedence. This is lame, but something has to have global
5101 # knowledge in order to eliminate the conflict. Add more linkers as
5105 local (%linkers) = @_;
5108 if defined $linkers{'GCJLINK'};
5110 if defined $linkers{'CXXLINK'};
5112 if defined $linkers{'F77LINK'};
5114 if defined $linkers{'OBJCLINK'};
5118 # Called to indicate that an extension was used.
5122 $extension_seen{$ext} = 1;
5125 # Called to ask whether source files have been seen . If HEADERS is 1,
5126 # headers can be included.
5129 local ($headers) = @_;
5137 local (@exts) = &lang_extensions ('header');
5141 return scalar keys %extension_seen > $headers;
5144 # Register a single language. LANGUAGE is the name of the language.
5145 # Each OPTION is either of the form NAME=VALUE, or is a file extension
5147 sub register_language
5149 local ($language, @options) = @_;
5152 $language_map{$language . '-ansi-p'} = 0;
5153 $language_map{$language . '-linker'} = '';
5154 $language_map{$language . '-autodep'} = 'no';
5157 foreach $iter (@options)
5159 if ($iter =~ /^(.*)=(.*)$/)
5161 $language_map{$language . '-' . $1} = $2;
5163 elsif (defined $extension_map{$iter})
5166 "automake: programming error: duplicate extension $iter\n";
5171 $extension_map{$iter} = $language;
5177 ################################################################
5179 # Pretty-print something. HEAD is what should be printed at the
5180 # beginning of the first line, FILL is what should be printed at the
5181 # beginning of every subsequent line.
5182 sub pretty_print_internal
5184 local ($head, $fill, @values) = @_;
5186 local ($column) = length ($head);
5187 local ($result) = $head;
5189 # Fill length is number of characters. However, each Tab
5190 # character counts for eight. So we count the number of Tabs and
5192 local ($fill_length) = length ($fill);
5193 $fill_length += 7 * ($fill =~ tr/\t/\t/d);
5195 local ($bol) = ($head eq '');
5198 # "71" because we also print a space.
5199 if ($column + length ($_) > 71)
5201 $result .= " \\\n" . $fill;
5202 $column = $fill_length;
5206 $result .= ' ' unless ($bol);
5208 $column += length ($_) + 1;
5216 # Pretty-print something and append to output_vars.
5219 $output_vars .= &pretty_print_internal (@_);
5222 # Pretty-print something and append to output_rules.
5223 sub pretty_print_rule
5225 $output_rules .= &pretty_print_internal (@_);
5229 ################################################################
5231 # See if a target exists.
5234 local ($target) = @_;
5235 return defined $targets{$target};
5238 # See if two conditionals are the same.
5239 sub conditional_same
5241 local ($cond1, $cond2) = @_;
5243 return (&conditional_true_when ($cond1, $cond2)
5244 && &conditional_true_when ($cond2, $cond1));
5247 # See if a conditional is true. Both arguments are conditional
5248 # strings. This returns true if the first conditional is true when
5249 # the second conditional is true.
5250 sub conditional_true_when
5252 local ($cond, $when) = @_;
5254 # Check the easy case first.
5260 # Check each component of $cond, which looks @COND1@@COND2@.
5261 foreach $comp (split ('@', $cond))
5263 # The way we split will give null strings between each
5267 if (index ($when, '@' . $comp . '@') == -1)
5276 # Check for an ambiguous conditional. This is called when a variable
5277 # or target is being defined conditionally. If we already know about
5278 # a definition that is true under the same conditions, then we have an
5280 sub check_ambiguous_conditional
5282 local ($var_name, $cond) = @_;
5283 local (@cond_vals) = split (' ', $conditional{$var_name});
5286 local ($vcond) = shift (@cond_vals);
5288 if (&conditional_true_when ($vcond, $cond)
5289 || &conditional_true_when ($cond, $vcond))
5291 &am_line_error ($var_name,
5292 "$var_name multiply defined in condition");
5297 # See if a variable exists. The first argument is the variable name,
5298 # and the optional second argument is the condition which we should
5299 # check. If no condition is given, we currently return true if the
5300 # variable is defined under any condition.
5301 sub variable_defined
5303 local ($var, $cond) = @_;
5304 if (defined $targets{$var})
5306 &am_line_error ($var, "\`$var' is target; expected variable");
5309 elsif (defined $contents{$var})
5311 if ($cond && $conditional{$var})
5313 # We have been asked to check for a particular condition,
5314 # and the variable is defined conditionally. We need to
5315 # look through the conditions under which the variable is
5316 # defined, and see if any of them match the conditional we
5317 # have been asked to check.
5318 local (@cond_vars) = split (' ', $conditional{$var});
5321 if (&conditional_same ($cond, shift (@cond_vars)))
5323 # Even a conditional examination is good enough
5324 # for us. FIXME: really should maintain examined
5325 # status on a per-condition basis.
5326 $content_seen{$var} = 1;
5332 # The variable is not defined for the given condition.
5336 $content_seen{$var} = 1;
5342 # Mark a variable as examined.
5343 sub examine_variable
5346 &variable_defined ($var);
5349 # Quote a value in order to put it in $conditional. We need to quote
5350 # spaces, and we need to handle null strings, so that we can later
5351 # retrieve values by splitting on space.
5355 $val =~ tr/ \t\n/\001\003\004/;
5356 $val = "\002" if $val eq '';
5360 # Unquote a value in $conditional.
5361 sub unquote_cond_val
5364 $val =~ tr/\001\003\004/ \t\n/;
5369 # Return the set of conditions for which a variable is defined.
5371 # If the variable is not defined conditionally, and is not defined in
5372 # terms of any variables which are defined conditionally, then this
5373 # returns the empty list.
5375 # If the variable is defined conditionally, but is not defined in
5376 # terms of any variables which are defined conditionally, then this
5377 # returns the list of conditions for which the variable is defined.
5379 # If the variable is defined in terms of any variables which are
5380 # defined conditionally, then this returns a full set of permutations
5381 # of the subvariable conditions. For example, if the variable is
5382 # defined in terms of a variable which is defined for @COND_TRUE@,
5383 # then this returns both @COND_TRUE@ and @COND_FALSE@. This is
5384 # because we will need to define the variable under both conditions.
5386 sub variable_conditions
5394 foreach $cond (&variable_conditions_sub ($var, '', ()))
5396 $uniqify{$cond} = 1;
5399 @uniq_list = sort keys %uniqify;
5400 # Note we cannot just do `return sort keys %uniqify', because this
5401 # function is sometimes used in a scalar context.
5405 # A subroutine of variable_conditions. We only return conditions
5406 # which are true for all the conditions in @PARENT_CONDS.
5407 sub variable_conditions_sub
5409 local ($var, $parent, @parent_conds) = @_;
5410 local (@new_conds) = ();
5412 if (defined $vars_scanned{$var})
5414 &am_line_error ($parent, "variable \`$var' recursively defined");
5417 $vars_scanned{$var} = 1;
5419 if (! $conditional{$var})
5421 foreach (split (' ', $contents{$var}))
5423 # If a comment seen, just leave.
5426 # Handle variable substitutions.
5427 if (/^\$\{(.*)\}$/ || /^\$\((.*)\)$/)
5430 &variable_conditions_sub ($1, $var, @parent_conds));
5434 # Now we want to return all permutations of the subvariable
5436 local (%allconds, $item);
5437 foreach $item (@new_conds)
5439 foreach (split ('@', $item))
5443 $allconds{$_ . '_TRUE'} = 1;
5447 # Unset our entry in vars_scanned. We only care about recursive
5449 delete $vars_scanned{$var};
5451 return &variable_conditions_permutations (sort keys %allconds);
5454 local (@this_conds) = ();
5455 local (@condvals) = split (' ', $conditional{$var});
5458 local ($cond) = shift (@condvals);
5459 local ($val) = &unquote_cond_val (shift (@condvals));
5464 local ($parent_cond);
5465 foreach $parent_cond (@parent_conds)
5467 if (! &conditional_true_when ($parent_cond, $cond))
5477 push (@this_conds, $cond);
5479 push (@parent_conds, $cond);
5480 local (@subvar_conds) = ();
5481 foreach (split (' ', $val))
5483 # If a comment seen, just leave.
5486 # Handle variable substitutions.
5487 if (/^\$\{(.*)\}$/ || /^\$\((.*)\)$/)
5489 push (@subvar_conds,
5490 &variable_conditions_sub ($1, $var, @parent_conds));
5493 pop (@parent_conds);
5495 # If there are no conditional subvariables, then we want to
5496 # return this condition. Otherwise, we want to return the
5497 # permutations of the subvariables.
5498 if (! @subvar_conds)
5500 push (@new_conds, $cond);
5504 push (@new_conds, &variable_conditions_reduce (@subvar_conds));
5508 # Unset our entry in vars_scanned. We only care about recursive
5510 delete $vars_scanned{$var};
5515 # If we are being called on behalf of another variable, we need to
5516 # return all possible permutations of the conditions. We have
5517 # already handled everything in @this_conds along with their
5518 # subvariables. We now need to add any permutations that are not
5521 foreach $this_cond (@this_conds)
5524 &variable_conditions_permutations (split('@', $this_cond));
5526 foreach $perm (@perms)
5530 foreach $scan (@this_conds)
5532 if (&conditional_true_when ($perm, $scan)
5533 || &conditional_true_when ($scan, $perm))
5544 local ($parent_cond);
5545 foreach $parent_cond (@parent_conds)
5547 if (! &conditional_true_when ($parent_cond, $perm))
5557 # This permutation was not already handled, and is valid
5559 push (@new_conds, $perm);
5566 # Subroutine for variable_conditions_sort
5567 sub variable_conditions_cmp
5573 return (length ($as) <=> length ($bs)
5577 # Sort a list of conditionals so that only the exclusive ones are
5578 # retained. For example, if both @COND1_TRUE@@COND2_TRUE@ and
5579 # @COND1_TRUE@ are in the list, discard the latter.
5580 sub variable_conditions_reduce
5582 local (@conds) = @_;
5585 foreach $cond (sort variable_conditions_cmp @conds)
5589 foreach $scan (@ret)
5591 if (&conditional_true_when ($cond, $scan))
5604 # Return a list of permutations of a conditional string.
5605 sub variable_conditions_permutations
5607 local (@comps) = @_;
5610 local ($comp) = shift (@comps);
5611 return &variable_conditions_permutations (@comps)
5613 local ($neg) = $comp;
5614 $neg =~ s/TRUE$/TRUEO/;
5615 $neg =~ s/FALSE$/TRUE/;
5616 $neg =~ s/TRUEO$/FALSE/;
5619 foreach $sub (&variable_conditions_permutations (@comps))
5621 push (@ret, '@' . $comp . '@' . $sub);
5622 push (@ret, '@' . $neg . '@' . $sub);
5626 push (@ret, '@' . $comp . '@');
5627 push (@ret, '@' . $neg . '@');
5632 # Warn if a variable is conditionally defined. This is called if we
5633 # are using the value of a variable.
5634 sub variable_conditionally_defined
5636 local ($var, $parent) = @_;
5637 if ($conditional{$var})
5641 &am_line_error ($parent,
5642 "warning: automake does not support conditional definition of $var in $parent");
5646 &am_line_error ($parent,
5647 "warning: automake does not support $var being defined conditionally")
5652 # Get the value of a variable. This just returns $contents, but warns
5653 # if the variable is conditionally defined.
5657 &variable_conditionally_defined ($var);
5658 return $contents{$var};
5661 # Convert a variable value to a list, split as whitespace. This will
5662 # recursively follow $(...) and ${...} inclusions. It preserves @...@
5663 # substitutions. If COND is 'all', then all values under all
5664 # conditions should be returned; if COND is a particular condition
5665 # (all conditions are surrounded by @...@) then only the value for
5666 # that condition should be returned; otherwise, warn if VAR is
5667 # conditionally defined. SCANNED is a global hash listing whose keys
5668 # are all the variables already scanned; it is an error to rescan a
5672 local ($var, $val, $cond) = @_;
5676 $val =~ s/\\(\n|$)/ /g;
5678 foreach (split (' ', $val))
5680 # If a comment seen, just leave.
5683 # Handle variable substitutions.
5684 if (/^\$\{([^}]*)\}$/ || /^\$\(([^)]*)\)$/)
5686 local ($varname) = $1;
5688 # If the user uses a losing variable name, just ignore it.
5689 # This isn't ideal, but people have requested it.
5690 next if ($varname =~ /\@.*\@/);
5694 if ($varname =~ /^([^:]*):([^=]*)=(.*)$/)
5698 ($from = $2) =~ s/(\W)/\\$1/g;
5702 @temp_list = &variable_value_as_list_worker ($1, $cond, $var);
5704 # Now rewrite the value if appropriate.
5707 grep (s/$from$/$to/, @temp_list);
5710 push (@result, @temp_list);
5721 # Return contents of variable as list, split as whitespace. This will
5722 # recursively follow $(...) and ${...} inclusions. It preserves @...@
5723 # substitutions. If COND is 'all', then all values under all
5724 # conditions should be returned; if COND is a particular condition
5725 # (all conditions are surrounded by @...@) then only the value for
5726 # that condition should be returned; otherwise, warn if VAR is
5727 # conditionally defined. If PARENT is specified, it is the name of
5728 # the including variable; this is only used for error reports.
5729 sub variable_value_as_list_worker
5731 local ($var, $cond, $parent) = @_;
5734 if (defined $targets{$var})
5736 &am_line_error ($var, "\`$var' is target; expected variable");
5738 elsif (! defined $contents{$var})
5740 &am_line_error ($parent, "variable \`$var' not defined");
5742 elsif (defined $vars_scanned{$var})
5744 # `vars_scanned' is a global we use to keep track of which
5745 # variables we've already examined.
5746 &am_line_error ($parent, "variable \`$var' recursively defined");
5748 elsif ($cond eq 'all' && $conditional{$var})
5750 $vars_scanned{$var} = 1;
5751 local (@condvals) = split (' ', $conditional{$var});
5755 local ($val) = &unquote_cond_val (shift (@condvals));
5756 push (@result, &value_to_list ($var, $val, $cond));
5759 elsif ($cond && $conditional{$var})
5761 $vars_scanned{$var} = 1;
5762 local (@condvals) = split (' ', $conditional{$var});
5766 local ($vcond) = shift (@condvals);
5767 local ($val) = &unquote_cond_val (shift (@condvals));
5768 if (&conditional_true_when ($vcond, $cond))
5770 # Warn if we have an ambiguity. It's hard to know how
5771 # to handle this case correctly.
5772 &variable_conditionally_defined ($var, $parent)
5775 push (@result, &value_to_list ($var, $val, $cond));
5781 $vars_scanned{$var} = 1;
5782 &variable_conditionally_defined ($var, $parent);
5783 $content_seen{$var} = 1;
5784 push (@result, &value_to_list ($var, $contents{$var}, $cond));
5787 # Unset our entry in vars_scanned. We only care about recursive
5789 delete $vars_scanned{$var};
5794 # This is just a wrapper for variable_value_as_list_worker that
5795 # initializes the global hash `vars_scanned'. This hash is used to
5796 # avoid infinite recursion.
5797 sub variable_value_as_list
5799 local ($var, $cond, $parent) = @_;
5801 return &variable_value_as_list_worker ($var, $cond, $parent);
5804 # Define a new variable, but only if not already defined.
5807 local ($var, $value) = @_;
5809 if (! defined $contents{$var})
5811 $output_vars .= $var . ' = ' . $value . "\n";
5812 $contents{$var} = $value;
5813 $content_seen{$var} = 1;
5815 elsif ($var_was_plus_eq{$var})
5817 &am_line_error ($var, "internally generated variable \`$var' was set with \`+='");
5821 # Like define_variable, but the value is a list, and the variable may
5822 # be defined conditionally. The second argument is the conditional
5823 # under which the value should be defined; this should be the empty
5824 # string to define the variable unconditionally. The third argument
5825 # is a list holding the values to use for the variable. The value is
5826 # pretty printed in the output file.
5827 sub define_pretty_variable
5829 local ($var, $cond, @value) = @_;
5830 if (! defined $contents{$var}
5831 || ($cond && ! &variable_defined ($var, $cond)))
5833 $contents{$var} = join (' ', @value);
5836 if ($conditional{$var})
5838 $conditional{$var} .= ' ';
5842 $conditional{$var} = '';
5844 $conditional{$var} .= ($cond
5846 . "e_cond_val ($contents{$var}));
5848 &pretty_print ($cond . $var . ' = ', $cond, @value);
5849 $content_seen{$var} = 1;
5853 # Like define_variable, but define a variable to be the configure
5854 # substitution by the same name.
5855 sub define_configure_variable
5858 local ($value) = '@' . $var . '@';
5859 &define_variable ($var, $value);
5862 # Define a compiler variable. We also handle defining the `LT'
5863 # version of the command when using libtool.
5864 sub define_compiler_variable
5866 local ($var, $ltcompile, $value) = @_;
5867 local ($name) = $var;
5868 &define_variable ($name, $value);
5869 &define_variable ('LT' . $name, $ltcompile . $value)
5873 # Define a variable that represents a program to run. If in Cygnus
5874 # mode, the program is searched for in the build (or source) tree.
5875 # Otherwise no searching is done at all. Arguments are:
5876 # * VAR Name of variable to define
5877 # * WHATDIR Either `src' or `build', depending on where program should
5878 # be found. (runtest is in srcdir!)
5879 # * SUBDIR Subdir of top-level dir
5880 # * PROGRAM Name of program
5881 # * OVERRIDE If specified, the name of the program to use when not in
5882 # Cygnus mode. Defaults to PROGRAM.
5883 sub define_program_variable
5885 local ($var, $whatdir, $subdir, $program, $override) = @_;
5889 $override = $program;
5894 local ($full) = ('$(top_' . $whatdir . 'dir)/../'
5895 . $subdir . '/' . $program);
5896 &define_variable ($var, ('`if test -f ' . $full
5897 . '; then echo ' . $full . '; else echo '
5898 . $program . '; fi`'));
5902 &define_variable ($var, $override);
5907 ################################################################
5909 # Read Makefile.am and set up %contents. Simultaneously copy lines
5910 # from Makefile.am into $output_trailer or $output_vars as
5911 # appropriate. NOTE we put rules in the trailer section. We want
5912 # user rules to come after our generated stuff.
5915 local ($amfile) = @_;
5918 open (AM_FILE, $amfile) || die "automake: couldn't open \`$amfile': $!\n";
5919 print "automake: reading $amfile\n" if $verbose;
5921 local ($saw_bk) = 0;
5922 local ($was_rule) = 0;
5923 local ($spacing) = '';
5924 local ($comment) = '';
5925 local ($last_var_name) = '';
5930 if (/$IGNORE_PATTERN/o)
5932 # Merely delete comments beginning with two hashes.
5934 elsif (/$WHITE_PATTERN/o)
5936 # Stick a single white line before the incoming macro or rule.
5940 elsif (/$COMMENT_PATTERN/o)
5942 # Stick comments before the incoming macro or rule. Make
5943 # sure a blank line preceeds first block of comments.
5944 $spacing = "\n" unless $blank;
5946 $comment .= $spacing . $_;
5955 $output_vars .= $comment . "\n";
5959 local ($is_ok_macro);
5963 unless substr ($_, -1, 1) eq "\n";
5965 # Don't look at MAINTAINER_MODE_TRUE here. That shouldn't be
5966 # used by users. @MAINT@ is an anachronism now.
5967 $_ =~ s/\@MAINT\@//g
5968 unless $seen_maint_mode;
5970 if (/$IGNORE_PATTERN/o)
5972 # Merely delete comments beginning with two hashes.
5974 elsif (/$WHITE_PATTERN/o)
5976 # Stick a single white line before the incoming macro or rule.
5978 &am_line_error ($., "blank line following trailing backslash")
5981 elsif (/$COMMENT_PATTERN/o)
5983 # Stick comments before the incoming macro or rule.
5984 $comment .= $spacing . $_;
5986 &am_line_error ($., "comment following trailing backslash")
5993 $output_trailer .= join ('', @conditional_stack) . $_;
5999 $contents{$last_var_name} .= ' '
6000 unless $contents{$last_var_name} =~ /\s$/;
6001 $contents{$last_var_name} .= $_;
6002 if (@conditional_stack)
6004 $conditional{$last_var_name} .= "e_cond_val ($_);
6008 elsif (/$IF_PATTERN/o)
6010 &am_line_error ($., "$1 does not appear in AM_CONDITIONAL")
6011 if (! $configure_cond{$1});
6012 push (@conditional_stack, "\@" . $1 . "_TRUE\@");
6014 elsif (/$ELSE_PATTERN/o)
6016 if (! @conditional_stack)
6018 &am_line_error ($., "else without if");
6020 elsif ($conditional_stack[$#conditional_stack] =~ /_FALSE\@$/)
6022 &am_line_error ($., "else after else");
6026 $conditional_stack[$#conditional_stack]
6027 =~ s/_TRUE\@$/_FALSE\@/;
6030 elsif (/$ENDIF_PATTERN/o)
6032 if (! @conditional_stack)
6034 &am_line_error ($., "endif without if");
6038 pop @conditional_stack;
6041 elsif (/$RULE_PATTERN/o)
6045 if (defined $contents{$1}
6046 && (@conditional_stack
6047 ? ! defined $conditional{$1}
6048 : defined $conditional{$1}))
6051 "$1 defined both conditionally and unconditionally");
6053 # Value here doesn't matter; for targets we only note
6057 local ($cond_string) = join ('', @conditional_stack);
6058 if (@conditional_stack)
6060 if ($conditional{$1})
6062 &check_ambiguous_conditional ($1, $cond_string);
6063 $conditional{$1} .= ' ';
6067 $conditional{$1} = '';
6069 $conditional{$1} .= $cond_string . ' 1';
6071 $content_lines{$1} = $.;
6072 $output_trailer .= $comment . $spacing . $cond_string . $_;
6073 $comment = $spacing = '';
6076 # Check the rule for being a suffix rule. If so, store in
6079 local ($source_suffix);
6080 local ($object_suffix);
6082 if (($source_suffix, $object_suffix) = ($1 =~ $SUFFIX_RULE_PATTERN))
6084 $suffix_rules{$source_suffix} = $object_suffix;
6085 print "Sources ending in .$source_suffix become .$object_suffix\n" if $verbose;
6086 $source_suffix_pattern = "(" . join('|', keys %suffix_rules) . ")";
6089 # FIXME: make sure both suffixes are in SUFFIXES? Or set
6090 # SUFFIXES from suffix_rules?
6092 elsif (($is_ok_macro = /$MACRO_PATTERN/o)
6093 || /$BOGUS_MACRO_PATTERN/o)
6095 # Found a macro definition.
6097 $last_var_name = $1;
6098 if (defined $contents{$1}
6099 && (@conditional_stack
6100 ? ! defined $conditional{$1}
6101 : defined $conditional{$1}))
6104 "$1 defined both conditionally and unconditionally");
6107 if ($3 ne '' && substr ($3, -1) eq "\\")
6109 # We preserve the `\' because otherwise the long lines
6110 # that are generated will be truncated by broken
6120 if (! defined $contents{$last_var_name})
6122 # The first assignment to a macro sets the line
6123 # number. Ideally I suppose we would associate line
6124 # numbers with random bits of text.
6125 $content_lines{$last_var_name} = $.;
6127 # If first assignment, set `+=' indicator.
6128 $var_was_plus_eq{$last_var_name} =
6130 && ! defined $am_var_defs{$last_var_name});
6135 if (! defined $contents{$last_var_name}
6136 && defined $am_var_defs{$last_var_name})
6138 $contents{$last_var_name} = $am_var_defs{$last_var_name};
6140 $contents{$last_var_name} .= ' ' . $value;
6144 $contents{$last_var_name} = $value;
6146 local ($cond_string) = join ('', @conditional_stack);
6147 if (@conditional_stack)
6151 if ($conditional{$last_var_name})
6155 # If we're adding to the conditional, and it
6156 # exists, then we might want to simply replace
6157 # the old value with the new one.
6158 local (@new_vals, @cond_vals);
6159 @cond_vals = split (' ', $conditional{$last_var_name});
6162 local ($vcond) = shift (@cond_vals);
6163 push (@new_vals, $vcond);
6164 if (&conditional_same ($vcond, $cond_string))
6167 $val = (&unquote_cond_val (shift (@cond_vals))
6169 push (@new_vals, "e_cond_val ($val));
6173 push (@new_vals, shift (@cond_vals));
6178 $conditional{$last_var_name}
6179 = join (' ', @new_vals);
6185 &check_ambiguous_conditional ($last_var_name,
6187 $conditional{$last_var_name} .= ' ';
6193 $conditional{$last_var_name} = '';
6194 $val = $contents{$last_var_name};
6198 $conditional{$last_var_name} .= ($cond_string
6200 . "e_cond_val ($val));
6204 # FIXME: this doesn't always work correctly; it will group
6205 # all comments for a given variable, no matter where
6207 $am_vars{$last_var_name} = $comment . $spacing;
6208 $def_type{$last_var_name} = ($type eq ':') ? ':' : '';
6209 push (@var_list, $last_var_name);
6210 $comment = $spacing = '';
6214 &am_line_error ($., "bad macro name \`$last_var_name'")
6217 elsif (/$INCLUDE_PATTERN/o)
6221 if ($path =~ s/^\$\(top_srcdir\)\///)
6223 push (@include_stack, "\$\(top_srcdir\)/$path");
6227 $path =~ s/\$\(srcdir\)\///;
6228 push (@include_stack, "\$\(srcdir\)/$path");
6229 $path = $relative_dir . "/" . $path;
6231 &read_am_file ($path);
6235 # This isn't an error; it is probably a continued rule.
6236 # In fact, this is what we assume.
6238 $output_trailer .= ($comment . $spacing
6239 . join ('', @conditional_stack) . $_);
6240 $comment = $spacing = '';
6247 $output_trailer .= $comment;
6249 &am_error ("unterminated conditionals: " . join (' ', @conditional_stack))
6250 if (@conditional_stack);
6253 # A helper for read_main_am_file which initializes configure variables
6254 # and variables from header-vars.am. This is a subr so we can call it
6256 sub define_standard_variables
6258 # Compute relative location of the top object directory.
6259 local (@topdir) = ();
6260 foreach (split (/\//, $relative_dir))
6262 next if $_ eq '.' || $_ eq '';
6269 push (@topdir, '..');
6272 @topdir = ('.') if ! @topdir;
6274 $top_builddir = join ('/', @topdir);
6276 ($build_rx = $top_builddir) =~ s/(\W)/\\$1/g;
6277 $output_vars .= &file_contents_with_transform
6278 ('s/\@top_builddir\@/' . $build_rx . '/g;',
6281 # Generate some useful variables when AC_CANONICAL_* used. FIXME:
6282 # this should use generic %configure_vars method.
6283 if ($seen_canonical)
6285 local ($curs, %vars);
6286 $vars{'host_alias'} = 'host_alias';
6287 $vars{'host_triplet'} = 'host';
6288 if ($seen_canonical == $AC_CANONICAL_SYSTEM)
6290 $vars{'build_alias'} = 'build_alias';
6291 $vars{'build_triplet'} = 'build';
6292 $vars{'target_alias'} = 'target_alias';
6293 $vars{'target_triplet'} = 'target';
6295 foreach $curs (sort keys %vars)
6297 $output_vars .= "$curs = \@$vars{$curs}\@\n";
6298 $contents{$curs} = "\@$vars{$curs}\@";
6303 foreach $curs (sort keys %configure_vars)
6305 &define_configure_variable ($curs);
6309 # Read main am file.
6310 sub read_main_am_file
6312 local ($amfile) = @_;
6314 # The keys here are variables we want to dump at the end of this
6315 # function. The values are corresponding comments.
6316 local (%am_vars) = ();
6317 local (@var_list) = ();
6318 local (%def_type) = ();
6320 # We want to predefine as many variables as possible. This lets
6321 # the user set them with `+=' in Makefile.am. However, we don't
6322 # want these initial definitions to end up in the output quite
6323 # yet. So we adopt a hack: read the `.am' file twice, throwing
6324 # away the output the first time. We also squirrel away a list of
6325 # all the variables defined by the .am file so that we know which
6326 # ones to remove from the content list.
6329 &define_standard_variables;
6330 local (%saved_contents) = %contents;
6332 # Read user file, but discard text of variable assignments we just
6335 &read_am_file ($amfile);
6337 # Now dump the variables that were defined. We do it in the same
6338 # order in which they were defined (skipping duplicates).
6340 foreach $curs (@var_list)
6342 next if $done{$curs};
6345 $output_vars .= $am_vars{$curs};
6346 if ($conditional{$curs})
6348 local (@cond_vals) = split (' ', $conditional{$curs});
6351 local ($vcond) = shift (@cond_vals);
6352 local ($val) = &unquote_cond_val (shift (@cond_vals));
6353 $output_vars .= ($vcond . $curs . ' '
6354 . $def_type{$curs} . "= \\\n");
6356 foreach $line (split ("\n", $val))
6358 $output_vars .= $vcond . $line . "\n";
6364 $output_vars .= ($curs . ' ' . $def_type{$curs} . '= '
6365 . $contents{$curs} . "\n");
6369 # Generate copyright header for generated Makefile.in.
6370 local ($ov) = $output_vars;
6371 $output_vars = ("# $in_file_name generated automatically by automake "
6372 . $VERSION . " from $am_file_name\n");
6373 $output_vars .= $gen_copyright;
6375 # Now go through and delete all the variables that the user did
6378 foreach $var (keys %saved_contents)
6380 if ($contents{$var} eq $saved_contents{$var})
6382 delete $contents{$var};
6386 # Re-read the standard variables, and this time keep their
6387 # contributions to the output. Then add the user's output to the
6389 &define_standard_variables;
6390 $output_vars .= $ov;
6394 ################################################################
6396 sub initialize_global_constants
6398 # Values for AC_CANONICAL_*
6399 $AC_CANONICAL_HOST = 1;
6400 $AC_CANONICAL_SYSTEM = 2;
6402 # Associative array of standard directory names. Entry is TRUE if
6403 # corresponding directory should be installed during
6404 # 'install-exec' phase.
6422 # Commonly found files we look for and automatically include in
6426 "README", "THANKS", "TODO", "NEWS", "COPYING", "COPYING.LIB",
6427 "INSTALL", "ABOUT-NLS", "ChangeLog", "configure", "configure.in",
6428 "config.guess", "config.sub", "AUTHORS", "BACKLOG", "ABOUT-GNU",
6429 "libversion.in", "mdate-sh", "mkinstalldirs", "install-sh",
6430 'texinfo.tex', "ansi2knr.c", "ansi2knr.1", 'elisp-comp',
6431 'ylwrap', 'acinclude.m4', @libtoolize_files,
6435 # Commonly used files we auto-include, but only sometimes.
6438 "aclocal.m4", "acconfig.h", "config.h.top",
6439 "config.h.bot", "stamp-h.in", 'stamp-vti'
6443 -a, --add-missing add missing standard files to package
6444 --amdir=DIR directory storing config files
6445 --build-dir=DIR directory where build being done (for dependencies)
6446 -c, --copy with -a, copy missing files (default is symlink)
6447 --cygnus assume program is part of Cygnus-style tree
6448 --foreign set strictness to foreign
6449 --gnits set strictness to gnits
6450 --gnu set strictness to gnu
6451 --help print this help, then exit
6452 -i, --include-deps include generated dependencies in Makefile.in
6453 --no-force only update Makefile.in's that are out of date
6454 -o DIR, --output-dir=DIR
6455 put generated Makefile.in's into DIR
6456 --srcdir-name=DIR name used for srcdir (for dependencies)
6457 -v, --verbose verbosely list files processed
6458 --version print version number, then exit\n";
6460 # Copyright on generated Makefile.ins.
6462 # Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
6463 # This Makefile.in is free software; the Free Software Foundation
6464 # gives unlimited permission to copy and/or distribute it,
6465 # with or without modifications, as long as this notice is preserved.
6467 # This program is distributed in the hope that it will be useful,
6468 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
6469 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
6470 # PARTICULAR PURPOSE.
6473 # Ignore return result from chmod, because it might give an error
6474 # if we chmod a symlink.
6475 $dist_header = "\t" . '-chmod -R a+r $(distdir)' . "\n";
6476 $dist{'dist-bzip2'} = ("\t"
6477 . '$(TAR) ch$(AMTARFLAGS)f - $(distdir) | bzip --best -c > $(distdir).bz2'
6479 $dist{'dist-tarZ'} = ("\t"
6480 . '$(TAR) ch$(AMTARFLAGS)f - $(distdir) | compress -c > $(distdir).tar.Z'
6482 $dist{'dist-shar'} = ("\t"
6483 . 'shar $(distdir) | gzip > $(distdir).shar.gz'
6485 $dist{'dist-zip'} = "\t" . 'zip -rq $(distdir).zip $(distdir)' . "\n";
6486 $dist{'dist'} = ("\t"
6487 . 'tar ch$(AMTARFLAGS)f - $(distdir) | GZIP=$(GZIP_ENV) gzip -c > $(distdir).tar.gz'
6489 $dist_trailer = "\t" . '-rm -rf $(distdir)' . "\n";
6492 # (Re)-Initialize per-Makefile.am variables.
6493 sub initialize_per_input
6495 # These two variables are used when generating each Makefile.in.
6496 # They hold the Makefile.in until it is ready to be printed.
6499 $output_trailer = '';
6501 $output_header = '';
6503 # Suffixes found during a run.
6506 # This holds the contents of a Makefile.am, as parsed by
6510 # This holds the names which are targets. These also appear in
6514 # This maps a variable name onto a flag. The flag is true iff the
6515 # variable was first defined with `+='.
6516 %var_was_plus_eq = ();
6518 # This holds definitions of all variables defined in .am files.
6519 # This is used during startup to determine which variables can be
6520 # assigned with `+='.
6523 # For a variable or target which is defined conditionally, this
6524 # holds an array of the conditional values. The array is composed
6525 # of pairs of condition strings (the variables which configure
6526 # will substitute) and values (the value of a target is
6527 # meaningless). For an unconditional variable, this is empty.
6530 # This holds the line numbers at which various elements of
6531 # %contents are defined.
6532 %content_lines = ();
6534 # This holds a 1 if a particular variable was examined.
6537 # This is the conditional stack.
6538 @conditional_stack = ();
6540 # This holds the set of included files.
6541 @include_stack = ();
6543 # This holds the "relative directory" of the current Makefile.in.
6544 # Eg for src/Makefile.in, this is "src".
6547 # This holds a list of files that are included in the
6551 # List of dependencies for the obvious targets.
6567 # A list of files deleted by `maintainer-clean'.
6568 @maintainer_clean_files = ();
6570 # These are pretty obvious, too. They are used to define the
6571 # SOURCES and OBJECTS variables.
6574 # Sources which go in the distribution.
6577 # This hash maps object file names onto their corresponding source
6578 # file names. This is used to ensure that each object is created
6579 # by a single source file.
6582 # These variables track inclusion of various compile-related .am
6583 # files. $included_generic_compile is TRUE if the basic code has
6584 # been included. $included_knr_compile is TRUE if the ansi2knr
6585 # code has been included. $included_libtool_compile is TRUE if
6586 # libtool support has been included.
6587 $included_generic_compile = 0;
6588 $included_knr_compile = 0;
6589 $included_libtool_compile = 0;
6591 # TRUE if install targets should work recursively.
6592 $recursive_install = 0;
6597 # Strictness levels.
6598 $strictness = $default_strictness;
6599 $strictness_name = $default_strictness_name;
6601 # Options from AUTOMAKE_OPTIONS.
6604 # Whether or not dependencies are handled. Can be further changed
6605 # in handle_options.
6606 $use_dependencies = $cmdline_use_dependencies;
6609 $local_maint_charset = $maint_charset;
6611 # All yacc and lex source filenames for this directory. Use
6612 # filenames instead of raw count so that multiple instances are
6613 # counted correctly (eg one yacc file can appear in multiple
6614 # programs without harm).
6618 # This is a list of all targets to run during "make dist".
6621 # Keys in this hash are the basenames of files which must depend
6623 %de_ansi_files = ();
6625 # This maps the source extension of a suffix rule to its
6626 # corresponding output extension.
6629 # This is the name of the recursive `all' target to use.
6630 $all_target = 'all-recursive';
6632 # This keeps track of which extensions we've seen (that we care
6634 %extension_seen = ();
6636 # This is random scratch space for the language finish functions.
6637 # Don't randomly overwrite it; examine other uses of keys first.
6638 %language_scratch = ();
6642 ################################################################
6644 # Return contents of a file from $am_dir, automatically skipping
6645 # macros or rules which are already known. Runs command on each line
6646 # as it is read; this command can modify $_.
6647 sub file_contents_with_transform
6649 local ($command, $basename) = @_;
6650 local ($file) = $am_dir . '/' . $basename . '.am';
6652 if ($command ne '' && substr ($command, -1) ne ';')
6654 die "automake: programming error in file_contents_with_transform: $command\n";
6657 open (FC_FILE, $file)
6658 || die "automake: installation error: cannot open \`$file'\n";
6660 # print "automake: reading $file\n" if $verbose;
6662 local ($was_rule) = 0;
6663 local ($result_vars) = '';
6664 local ($result_rules) = '';
6665 local ($comment) = '';
6666 local ($spacing) = "\n";
6667 local ($skipping) = 0;
6672 $_ =~ s/\@MAINTAINER_MODE_TRUE\@//g
6673 unless $seen_maint_mode;
6675 $had_chars = length ($_) && $_ ne "\n";
6677 # If the transform caused all the characters to go away, then
6678 # ignore the line. Why do this? Because in Perl 4, a "next"
6679 # inside of an eval doesn't affect a loop outside the eval.
6680 # So we can't pass in a "transform" that uses next. We used
6681 # to do this. "Empty" also means consisting of a single
6683 next if $had_chars && ($_ eq '' || $_ eq "\n");
6685 if (/$IGNORE_PATTERN/o)
6687 # Merely delete comments beginning with two hashes.
6689 elsif (/$WHITE_PATTERN/o)
6691 # Stick a single white line before the incoming macro or rule.
6693 &am_line_error ($., "blank line following trailing backslash")
6696 elsif (/$COMMENT_PATTERN/o)
6698 # Stick comments before the incoming macro or rule.
6699 $comment .= $spacing . $_;
6701 &am_line_error ($., "comment following trailing backslash")
6708 $result_rules .= $_ if ! $skipping;
6712 $result_vars .= $_ if ! $skipping;
6716 elsif (/$RULE_PATTERN/o)
6720 $skipping = defined $contents{$1};
6721 $result_rules .= $comment . $spacing . $_ if ! $skipping;
6722 $comment = $spacing = '';
6725 elsif (/$MACRO_PATTERN/o)
6727 # Found a variable reference.
6729 $skipping = defined $contents{$1};
6730 $result_vars .= $comment . $spacing . $_ if ! $skipping;
6731 $comment = $spacing = '';
6733 print STDERR "automake: programming error: .am macro \`$1' with trailing backslash\n"
6735 $am_var_defs{$1} = $3;
6739 # This isn't an error; it is probably a continued rule.
6740 # In fact, this is what we assume.
6742 $result_rules .= $comment . $spacing . $_ if ! $skipping;
6743 $comment = $spacing = '';
6749 return $result_vars . $result_rules . $comment;
6752 # Like file_contents_with_transform, but no transform.
6755 return &file_contents_with_transform ('', @_);
6758 # Find all variable prefixes that are used for install directories. A
6759 # prefix `zar' qualifies iff:
6760 # * `zardir' is a variable.
6761 # * `zar_PRIMARY' is a variable.
6762 sub am_primary_prefixes
6764 local ($primary, $can_dist, @prefixes) = @_;
6766 local (%valid, $varname);
6767 grep ($valid{$_} = 0, @prefixes);
6768 $valid{'EXTRA'} = 0;
6769 foreach $varname (keys %contents)
6771 if ($varname =~ /^(dist_|nodist_)?(.*)_$primary$/)
6773 if (($1 ne '' && ! $can_dist)
6774 || (! defined $valid{$2}
6775 && ! &variable_defined ($2 . 'dir')
6776 # Note that a configure variable is always
6777 # legitimate. It is natural to name such
6778 # variables after the primary, so we explicitly
6780 && ! defined $configure_vars{$varname}))
6782 &am_line_error ($varname, "invalid variable \`$varname'");
6786 # Ensure all extended prefixes are actually used.
6787 $valid{$1 . $2} = 1;
6795 # Handle `where_HOW' variable magic. Does all lookups, generates
6796 # install code, and possibly generates code to define the primary
6797 # variable. The first argument is the name of the .am file to munge,
6798 # the second argument is the primary variable (eg HEADERS), and all
6799 # subsequent arguments are possible installation locations. Returns
6800 # list of all values of all _HOW targets.
6802 # FIXME: this should be rewritten to be cleaner. It should be broken
6803 # up into multiple functions.
6805 # Usage is: am_install_var (OPTION..., file, HOW, where...)
6810 local ($do_clean) = 0;
6811 local ($do_require) = 1;
6812 local ($can_dist) = 0;
6813 local ($default_dist) = 0;
6816 if (defined $configure_vars{'LIBTOOL'})
6818 # Transform '@LIBTOOL ...@' to '$(LIBTOOL) ...'
6819 $ltxform = 's/\@LIBTOOL([^\@]*)\@/\$(LIBTOOL) $1/;';
6823 # Delete '@LIBTOOL ...@'
6824 $ltxform = 's/\@LIBTOOL([^\@]*)\@//;';
6830 $cygxform = 's/\@EXEEXT\@//g;';
6834 $cygxform = 's/\@EXEEXT\@/\$(EXEEXT)/g;';
6839 if ($args[0] eq '-clean')
6843 elsif ($args[0] eq '-noextra')
6847 elsif ($args[0] eq '-candist')
6851 elsif ($args[0] eq '-defaultdist')
6856 elsif ($args[0] !~ /^-/)
6863 local ($file, $primary, @prefixes) = @args;
6866 local (@result) = ();
6868 # Now that configure substitutions are allowed in where_HOW
6869 # variables, it is an error to actually define the primary. We
6870 # allow `JAVA', as it is customarily used to mean the Java
6871 # interpreter. This is but one of several Java hacks.
6872 &am_line_error ($primary, "\`$primary' is an anachronism")
6873 if &variable_defined ($primary) && $primary ne 'JAVA';
6876 # Look for misspellings. It is an error to have a variable ending
6877 # in a "reserved" suffix whose prefix is unknown, eg
6878 # "bni_PROGRAMS". However, unusual prefixes are allowed if a
6879 # variable of the same name (with "dir" appended) exists. For
6880 # instance, if the variable "zardir" is defined, then
6881 # "zar_PROGRAMS" becomes valid. This is to provide a little extra
6882 # flexibility in those cases which need it.
6883 local (%valid) = &am_primary_prefixes ($primary, $can_dist, @prefixes);
6885 # If a primary includes a configure substitution, then the EXTRA_
6886 # form is required. Otherwise we can't properly do our job.
6887 local ($require_extra);
6888 local ($warned_about_extra) = 0;
6890 local ($clean_file) = $file . '-clean';
6893 local ($nodir_name);
6894 foreach $X (sort keys %valid)
6896 $one_name = $X . '_' . $primary;
6897 if (&variable_defined ($one_name))
6899 # If files should be distributed, do so.
6902 if (($default_dist && $one_name !~ /^nodist_/)
6903 || (! $default_dist && $one_name =~ /^dist_/))
6905 &push_dist_common ('$(' . $one_name . ')');
6907 ($nodir_name = $X) =~ s/^(dist|nodist)_//;
6914 # Append actual contents of where_PRIMARY variable to
6917 foreach $rcurs (&variable_value_as_list ($one_name, 'all'))
6919 # Skip configure substitutions. Possibly bogus.
6920 if ($rcurs =~ /^\@.*\@$/)
6924 if (! $warned_about_extra)
6926 $warned_about_extra = 1;
6928 &am_line_error ($one_name,
6929 "\`$one_name' contains configure substitution, but shouldn't");
6933 # Check here to make sure variables defined in
6934 # configure.in do not imply that EXTRA_PRIMARY
6936 elsif (! defined $configure_vars{$one_name})
6938 $require_extra = $one_name
6945 push (@result, $rcurs);
6948 # "EXTRA" shouldn't be used when generating clean targets,
6949 # all, or install targets.
6952 # We used to warn if EXTRA_FOO was defined uselessly,
6953 # but this was annoying.
6957 # A blatant hack: we rewrite each _PROGRAMS primary to
6958 # include EXEEXT when in Cygwin32 mode.
6959 if ($seen_exeext && $primary eq 'PROGRAMS')
6961 local (@conds) = &variable_conditions ($one_name);
6962 local (@one_binlist);
6964 # FIXME: this definitely loses aesthetically; it
6965 # redefines $ONE_NAME. Instead we should arrange for
6966 # variable definitions to be output later, instead of
6972 foreach $rcurs (&variable_value_as_list ($one_name, ''))
6974 if ($rcurs =~ /\./ || $rcurs =~ /^\@.*\@$/)
6976 push (@one_binlist, $rcurs);
6980 push (@one_binlist, $rcurs . '$(EXEEXT)');
6984 delete $contents{$one_name};
6985 &define_pretty_variable ($one_name, '', @one_binlist);
6990 local ($condvals) = '';
6991 foreach $cond (@conds)
6994 local (@condval) = &variable_value_as_list ($one_name,
6996 foreach $rcurs (@condval)
6998 if ($rcurs =~ /\./ || $rcurs =~ /^\@.*\@$/)
7000 push (@one_binlist, $rcurs);
7004 push (@one_binlist, $rcurs . '$(EXEEXT)');
7008 push (@condvals, $cond);
7009 push (@condvals, join (' ', @one_binlist));
7012 delete $contents{$one_name};
7016 $cond = shift (@condvals);
7017 local (@val) = split (' ', shift (@condvals));
7018 &define_pretty_variable ($one_name, $cond, @val);
7026 &file_contents_with_transform ('s/\@DIR\@/' . $X . '/go;'
7030 push (@clean, $X . $primary);
7031 &push_phony_cleaners ($X . $primary);
7036 push (@check, '$(' . $one_name . ')');
7040 push (@used, '$(' . $one_name . ')');
7042 if ($X eq 'noinst' || $X eq 'check')
7044 # Objects which don't get installed by default.
7049 &file_contents_with_transform ('s/\@DIR\@/' . $X . '/g;'
7050 . 's/\@NDIR\@/' . $nodir_name . '/go;'
7051 . $ltxform . $cygxform,
7054 push (@uninstall, 'uninstall-' . $X . $primary);
7055 push (@phony, 'uninstall-' . $X . $primary);
7056 push (@installdirs, '$(DESTDIR)$(' . $X . 'dir)');
7057 if (defined $exec_dir_p{$X} ? $exec_dir_p{$X} : ($X =~ /exec/))
7059 push (@install_exec, 'install-' . $X . $primary);
7060 push (@phony, 'install-' . $X . $primary);
7064 push (@install_data, 'install-' . $X . $primary);
7065 push (@phony, 'install-' . $X . $primary);
7070 # The JAVA variable is used as the name of the Java interpreter.
7071 if (@used && $primary ne 'JAVA')
7074 &define_pretty_variable ($primary, '', @used);
7075 $output_vars .= "\n";
7078 if ($require_extra && ! &variable_defined ('EXTRA_' . $primary))
7080 &am_line_error ($require_extra,
7081 "\`$require_extra' contains configure substitution, but \`EXTRA_$primary' not defined");
7084 # Push here because PRIMARY might be configure time determined.
7085 push (@all, '$(' . $primary . ')')
7086 if @used && $primary ne 'JAVA';
7092 ################################################################
7094 # This variable is local to the "require file" set of functions.
7095 @require_file_paths = ();
7097 # Verify that the file must exist in the current directory. Usage:
7098 # require_file (isconfigure, line_number, strictness, file) strictness
7099 # is the strictness level at which this file becomes required. Must
7100 # set require_file_paths before calling this function.
7101 # require_file_paths is set to hold a single directory (the one in
7102 # which the first file was found) before return.
7103 sub require_file_internal
7105 local ($is_configure, $line, $mystrict, @files) = @_;
7106 local ($file, $fullfile);
7107 local ($found_it, $errfile, $errdir);
7110 foreach $file (@files)
7113 foreach $dir (@require_file_paths)
7117 $fullfile = $relative_dir . "/" . $file;
7118 $errdir = $relative_dir unless $errdir;
7122 $fullfile = $dir . "/" . $file;
7123 $errdir = $dir unless $errdir;
7126 # Use different name for "error filename". Otherwise on
7127 # an error the bad file will be reported as eg
7128 # `../../install-sh' when using the default
7130 $errfile = $errdir . '/' . $file;
7135 # FIXME: Once again, special-case `.'.
7136 &push_dist_common ($file)
7137 if $dir eq $relative_dir || $dir eq '.';
7145 # Prune the path list.
7146 @require_file_paths = $save_dir;
7150 if ($strictness >= $mystrict)
7152 local ($trailer) = '';
7153 local ($suppress) = 0;
7155 # Only install missing files according to our desired
7157 local ($message) = "required file \`$errfile' not found";
7162 # Maybe run libtoolize.
7164 && grep ($_ eq $file, @libtoolize_files)
7165 && system ('libtoolize', '--automake'))
7167 $message = "installing \`$errfile'";
7169 $trailer = "; cannot run \`libtoolize': $!";
7171 elsif (-f ($am_dir . '/' . $file))
7173 # Install the missing file. Symlink if we
7174 # can, copy if we must. Note: delete the file
7175 # first, in case it is a dangling symlink.
7176 $message = "installing \`$errfile'";
7177 # Windows Perl will hang if we try to delete a
7178 # file that doesn't exist.
7179 unlink ($errfile) if -f $errfile;
7180 if ($symlink_exists && ! $copy_missing)
7182 if (! symlink ($am_dir . '/' . $file, $errfile))
7185 $trailer = "; error while making link: $!\n";
7188 elsif (system ('cp', $am_dir . '/' . $file, $errfile))
7191 $trailer = "\n error while copying\n";
7196 local ($save) = $exit_status;
7199 # FIXME: allow actual file to be specified.
7200 &am_conf_line_error ('configure.in', $line,
7201 "$message$trailer");
7205 &am_line_error ($line, "$message$trailer");
7207 $exit_status = $save if $suppress;
7213 # Like require_file_with_line, but error messages refer to
7214 # configure.in, not the current Makefile.am.
7215 sub require_file_with_conf_line
7217 @require_file_paths = '.';
7218 &require_file_internal (1, @_);
7221 sub require_file_with_line
7223 @require_file_paths = '.';
7224 &require_file_internal (0, @_);
7229 @require_file_paths = '.';
7230 &require_file_internal (0, '', @_);
7233 # Require a file that is also required by Autoconf. Looks in
7234 # configuration path, as specified by AC_CONFIG_AUX_DIR.
7235 sub require_config_file
7237 @require_file_paths = @config_aux_path;
7238 &require_file_internal (1, '', @_);
7239 local ($dir) = $require_file_paths[0];
7240 @config_aux_path = @require_file_paths;
7243 $config_aux_dir = '.';
7247 $config_aux_dir = '$(top_srcdir)/' . $dir;
7251 # Assumes that the line number is in Makefile.am.
7252 sub require_conf_file_with_line
7254 @require_file_paths = @config_aux_path;
7255 &require_file_internal (0, @_);
7256 local ($dir) = $require_file_paths[0];
7257 @config_aux_path = @require_file_paths;
7260 $config_aux_dir = '.';
7264 $config_aux_dir = '$(top_srcdir)/' . $dir;
7268 # Assumes that the line number is in configure.in.
7269 sub require_conf_file_with_conf_line
7271 @require_file_paths = @config_aux_path;
7272 &require_file_internal (1, @_);
7273 local ($dir) = $require_file_paths[0];
7274 @config_aux_path = @require_file_paths;
7277 $config_aux_dir = '.';
7281 $config_aux_dir = '$(top_srcdir)/' . $dir;
7285 ################################################################
7287 # Push a list of files onto dist_common.
7288 sub push_dist_common
7290 local (@files) = @_;
7293 foreach $file (@files)
7295 $dist_common{$file} = 1;
7299 # Push a list of clean targets onto phony.
7300 sub push_phony_cleaners
7304 foreach $target ('mostly', 'dist', '', 'maintainer-')
7306 push (@phony, $target . 'clean-' . $base);
7313 $strictness_name = $_[0];
7314 if ($strictness_name eq 'gnu')
7318 elsif ($strictness_name eq 'gnits')
7320 $strictness = $GNITS;
7322 elsif ($strictness_name eq 'foreign')
7324 $strictness = $FOREIGN;
7328 die "automake: level \`$strictness_name' not recognized\n";
7333 ################################################################
7335 # Return directory name of file.
7341 ($sub = $file) =~ s,/+[^/]+$,,g;
7342 $sub = '.' if $sub eq $file;
7346 # Return file name of a file.
7352 ($sub = $file) =~s,^.*/+,,g;
7356 # Ensure a file exists.
7361 open (TOUCH, ">> $file");
7365 # Glob something. Do this to avoid indentation screwups everywhere we
7366 # want to glob. Gross!
7373 ################################################################
7375 # Print an error message and set exit status.
7378 warn "automake: ${am_file}.am: ", join (' ', @_), "\n";
7384 local ($symbol, @args) = @_;
7386 if ($symbol && "$symbol" ne '-1')
7388 local ($file) = "${am_file}.am";
7390 if ($symbol =~ /^\d+$/)
7392 # SYMBOL is a line number, so just add the colon.
7393 $file .= ':' . $symbol;
7395 elsif (defined $content_lines{$symbol})
7397 # SYMBOL is a variable defined in Makefile.am, so add the
7398 # line number we saved from there.
7399 $file .= ':' . $content_lines{$symbol};
7401 elsif (defined $configure_vars{$symbol})
7403 # SYMBOL is a variable defined in configure.in, so add the
7404 # appropriate line number.
7405 $file = $configure_vars{$symbol};
7409 # Couldn't find the line number.
7411 warn $file, ": ", join (' ', @args), "\n";
7420 # Like am_error, but while scanning configure.in.
7423 # FIXME: can run in subdirs.
7424 warn "automake: configure.in: ", join (' ', @_), "\n";
7428 # Error message with line number referring to configure.in.
7429 sub am_conf_line_error
7431 local ($file, $line, @args) = @_;
7435 warn "$file: $line: ", join (' ', @args), "\n";
7440 &am_conf_error (@args);
7444 # Warning message with line number referring to configure.in.
7445 # Does not affect exit_status
7446 sub am_conf_line_warning
7448 local ($saved_exit_status) = $exit_status;
7449 &am_conf_line_error (@_);
7450 $exit_status = $saved_exit_status;
7453 # Tell user where our aclocal.m4 is, but only once.
7454 sub keyed_aclocal_warning
7457 warn "automake: macro \`$key' can be generated by \`aclocal'\n";
7460 # Print usage information.
7463 print "Usage: automake [OPTION] ... [Makefile]...\n\n";
7464 print "Generate Makefile.in for autoconf from Makefile.am\n";
7466 print "\nFiles which are automatically distributed, if found:\n";
7467 $~ = "USAGE_FORMAT";
7468 local ($last, $iter, @lcomm);
7470 foreach $iter (sort ((@common_files, @common_sometimes)))
7472 push (@lcomm, $iter) unless $iter eq $last;
7476 local ($one, $two, $three, $four, $i, $max);
7477 $max = int (($#lcomm + 1) / 4);
7479 for ($i = 0; $i < $max; ++$i)
7482 $two = $lcomm[$max + $i];
7483 $three = $lcomm[2 * $max + $i];
7484 $four = $lcomm[3 * $max + $i];
7488 local ($mod) = ($#lcomm + 1) % 4;
7491 $one = $lcomm[$max];
7492 $two = ($mod > 1) ? $lcomm[2 * $max] : '';
7493 $three = ($mod > 2) ? $lcomm[3 * $max] : '';
7494 $four = ($mod > 3) ? $lcomm[4 * $max] : '';
7498 print "\nReport bugs to <bug-automake\@gnu.org>.\n";
7503 format USAGE_FORMAT =
7504 @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<
7505 $one, $two, $three, $four