5 eval 'exec @PERL@ -S $0 ${1+"$@"}'
8 # automake - create Makefile.in from Makefile.am
9 # Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
10 # Free Software Foundation, Inc.
12 # This program is free software; you can redistribute it and/or modify
13 # it under the terms of the GNU General Public License as published by
14 # the Free Software Foundation; either version 2, or (at your option)
17 # This program is distributed in the hope that it will be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # GNU General Public License for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, write to the Free Software
24 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
27 # Originally written by David Mackenzie <djm@gnu.ai.mit.edu>.
28 # Perl reimplementation by Tom Tromey <tromey@cygnus.com>.
31 use strict 'vars', 'subs';
35 my $me = basename ($0);
42 # Parameters set by configure. Not to be changed. NOTE: assign
43 # VERSION as string so that eg version 0.30 will print correctly.
44 my $VERSION = "@VERSION@";
45 my $PACKAGE = "@PACKAGE@";
46 my $prefix = "@prefix@";
47 my $am_dir = "@datadir@/@PACKAGE@";
50 my $IGNORE_PATTERN = "^##([^#].*)?\$";
51 my $WHITE_PATTERN = "^[ \t]*\$";
52 my $COMMENT_PATTERN = "^#";
53 my $TARGET_PATTERN="[\$a-zA-Z_.][-.a-zA-Z0-9_(){}/\$]*";
54 my $RULE_PATTERN = "^($TARGET_PATTERN) *:([^=].*|)\$";
55 my $SUFFIX_RULE_PATTERN = "^\\.([a-zA-Z0-9]+)\\.([a-zA-Z0-9]+)\$";
56 # Only recognize leading spaces, not leading tabs. If we recognize
57 # leading tabs here then we need to make the reader smarter, because
58 # otherwise it will think rules like `foo=bar; \' are errors.
59 my $MACRO_PATTERN = "^ *([A-Za-z0-9_\@]+)[ \t]*([:+]?)=[ \t]*(.*)\$";
60 my $BOGUS_MACRO_PATTERN = "^ *([^ \t]*)[ \t]*([:+]?)=[ \t]*(.*)\$";
61 my $GNITS_VERSION_PATTERN = "[0-9]+\\.[0-9]+([a-z]|\\.[0-9]+)?";
62 my $IF_PATTERN = "^if[ \t]+([A-Za-z][A-Za-z0-9_]*)[ \t]*(#.*)?\$";
63 my $ELSE_PATTERN = "^else(?:[ \t]+([A-Za-z][A-Za-z0-9_]*))?[ \t]*(#.*)?\$";
64 my $ENDIF_PATTERN = "^endif(?:[ \t]+([A-Za-z][A-Za-z0-9_]*))?[ \t]*(#.*)?\$";
65 my $PATH_PATTERN='(\\w|[/.-])+';
66 # This will pass through anything not of the prescribed form.
67 my $INCLUDE_PATTERN = "^include[ \t]+((\\\$\\\(top_srcdir\\\)/${PATH_PATTERN})|(\\\$\\\(srcdir\\\)/${PATH_PATTERN})|([^/\\\$]${PATH_PATTERN}))[ \t]*(#.*)?\$";
69 # Some regular expressions. One reason to put them here is that it
70 # makes indentation work better in Emacs.
71 my $AC_CONFIG_AUX_DIR_PATTERN = "AC_CONFIG_AUX_DIR\\(([^)]+)\\)";
72 my $AM_INIT_AUTOMAKE_PATTERN = "AM_INIT_AUTOMAKE\\([^,]*,([^,)]+)[,)]";
73 my $AM_PACKAGE_VERSION_PATTERN = "^\\s*\\[?([^]\\s]+)\\]?\\s*\$";
74 # Note that there is no AC_PATH_TOOL. But we don't really care.
75 my $AC_CHECK_PATTERN = "AC_(CHECK|PATH)_(PROG|PROGS|TOOL)\\(\\[?(\\w+)";
76 my $AM_MISSING_PATTERN = "AM_MISSING_PROG\\(\\[?(\\w+)";
77 # Just check for alphanumeric in AC_SUBST. If you do AC_SUBST(5),
79 my $AC_SUBST_PATTERN = "AC_SUBST\\(\\[?(\\w+)";
80 my $AM_CONDITIONAL_PATTERN = "AM_CONDITIONAL\\((\\w+)";
82 # Constants to define the "strictness" level.
87 # Values for AC_CANONICAL_*
88 my $AC_CANONICAL_HOST = 1;
89 my $AC_CANONICAL_SYSTEM = 2;
91 # Files installed by libtoolize.
92 my @libtoolize_files = ('ltmain.sh', 'config.guess', 'config.sub');
93 # ltconfig appears here for compatibility with old versions of libtool.
94 my @libtoolize_sometimes = ('ltconfig', 'ltcf-c.sh', 'ltcf-cxx.sh',
97 # Commonly found files we look for and automatically include in
101 'README', 'THANKS', 'TODO', 'NEWS', 'COPYING', 'COPYING.LIB',
102 'INSTALL', 'ABOUT-NLS', 'ChangeLog', 'configure.ac',
103 'configure.in', 'configure', 'config.guess', 'config.sub',
104 'AUTHORS', 'BACKLOG', 'ABOUT-GNU', 'libversion.in',
105 'mdate-sh', 'mkinstalldirs', 'install-sh', 'texinfo.tex',
106 'ansi2knr.c', 'ansi2knr.1', 'elisp-comp',
107 # ltconfig appears here for compatibility with old versions
109 'ylwrap', 'acinclude.m4', @libtoolize_files, @libtoolize_sometimes,
110 'missing', 'depcomp', 'compile', 'py-compile'
113 # Commonly used files we auto-include, but only sometimes.
114 my @common_sometimes =
116 'aclocal.m4', 'acconfig.h', 'config.h.top',
117 'config.h.bot', 'stamp-h.in', 'stamp-vti'
120 # Copyright on generated Makefile.ins.
121 my $gen_copyright = "\
122 # Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
123 # Free Software Foundation, Inc.
124 # This Makefile.in is free software; the Free Software Foundation
125 # gives unlimited permission to copy and/or distribute it,
126 # with or without modifications, as long as this notice is preserved.
128 # This program is distributed in the hope that it will be useful,
129 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
130 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
131 # PARTICULAR PURPOSE.
134 # These constants are returned by lang_*_rewrite functions.
135 # LANG_SUBDIR means that the resulting object file should be in a
136 # subdir if the source file is. In this case the file name cannot
137 # have `..' components.
139 my $LANG_PROCESS = 1;
142 # Directories installed during 'install-exec' phase.
161 # Map from obsolete macros to hints for new macros.
162 # If you change this, change the corresponding list in aclocal.in.
163 # FIXME: should just put this into a single file.
164 my %obsolete_macros =
166 'AC_FEATURE_CTYPE' => "use `AC_HEADER_STDC'",
167 'AC_FEATURE_ERRNO' => "add `strerror' to `AC_REPLACE_FUNCS(...)'",
168 'AC_FEATURE_EXIT' => '',
169 'AC_SYSTEM_HEADER' => '',
171 # Note that we do not handle this one, because it is still run
172 # from AM_CONFIG_HEADER. So we deal with it specially in
173 # &scan_autoconf_files.
174 # 'AC_CONFIG_HEADER' => "use `AM_CONFIG_HEADER'",
176 'fp_C_PROTOTYPES' => "use `AM_C_PROTOTYPES'",
177 'fp_PROG_CC_STDC' => "use `AM_PROG_CC_STDC'",
178 'fp_PROG_INSTALL' => "use `AC_PROG_INSTALL'",
179 'fp_WITH_DMALLOC' => "use `AM_WITH_DMALLOC'",
180 'fp_WITH_REGEX' => "use `AM_WITH_REGEX'",
181 'gm_PROG_LIBTOOL' => "use `AM_PROG_LIBTOOL'",
182 'jm_MAINTAINER_MODE' => "use `AM_MAINTAINER_MODE'",
183 'md_TYPE_PTRDIFF_T' => "use `AM_TYPE_PTRDIFF_T'",
184 'ud_PATH_LISPDIR' => "use `AM_PATH_LISPDIR'",
185 'ud_GNU_GETTEXT' => "use `AM_GNU_GETTEXT'",
187 # Now part of autoconf proper, under a different name.
188 'AM_FUNC_FNMATCH' => "use `AC_FUNC_FNMATCH'",
189 'fp_FUNC_FNMATCH' => "use `AC_FUNC_FNMATCH'",
190 'AM_SANITY_CHECK_CC' => "automatically done by `AC_PROG_CC'",
191 'AM_PROG_INSTALL' => "use `AC_PROG_INSTALL'",
192 'AM_EXEEXT' => "use `AC_EXEEXT'",
193 'AM_CYGWIN32' => "use `AC_CYGWIN'",
194 'AM_MINGW32' => "use `AC_MINGW32'",
195 'AM_FUNC_MKTIME' => "use `AC_FUNC_MKTIME'",
197 # These aren't quite obsolete.
201 # Regexp to match the above macros.
202 my $obsolete_rx = '(\b' . join ('\b|\b', keys %obsolete_macros) . '\b)';
206 ## ---------------------------------- ##
207 ## Variables related to the options. ##
208 ## ---------------------------------- ##
210 # TRUE if we should always generate Makefile.in.
211 my $force_generation = 1;
213 # Strictness level as set on command line.
214 my $default_strictness = $GNU;
216 # Name of strictness level, as set on command line.
217 my $default_strictness_name = 'gnu';
219 # This is TRUE if automatic dependency generation code should be
220 # included in generated Makefile.in.
221 my $cmdline_use_dependencies = 1;
223 # TRUE if in verbose mode.
226 # This holds our (eventual) exit status. We don't actually exit until
227 # we have processed all input files.
230 # From the Perl manual.
231 my $symlink_exists = (eval 'symlink ("", "");', $@ eq '');
233 # TRUE if missing standard files should be installed.
236 # TRUE if we should copy missing files; otherwise symlink if possible.
237 my $copy_missing = 0;
239 # TRUE if we should always update files that we know about.
240 my $force_missing = 0;
243 ## ---------------------------------------- ##
244 ## Variables filled during files scanning. ##
245 ## ---------------------------------------- ##
247 # Name of the top autoconf input: `configure.ac' or `configure.in'.
248 my $configure_ac = '';
250 # Files found by scanning configure.ac for LIBOBJS.
253 # True if AM_C_PROTOTYPES appears in configure.ac.
254 my $am_c_prototypes = 0;
256 # Names used in AC_CONFIG_HEADER call. @config_fullnames holds the
257 # name which appears in AC_CONFIG_HEADER, colon and all.
258 # @config_names holds the file names. @config_headers holds the '.in'
259 # files. Ordinarily these are similar, but they can be different if
260 # the weird "NAME:FILE" syntax is used.
261 my @config_fullnames = ();
262 my @config_names = ();
263 my @config_headers = ();
264 # Line number at which AC_CONFIG_HEADER appears in configure.ac.
265 my $config_header_line = 0;
267 # Directory where output files go. Actually, output files are
268 # relative to this directory.
269 my $output_directory = '.';
271 # List of Makefile.am's to process, and their corresponding outputs.
272 my @input_files = ();
273 my %output_files = ();
275 # Complete list of Makefile.am's that exist.
276 my @configure_input_files = ();
278 # List of files in AC_OUTPUT without Makefile.am, and their outputs.
279 my @other_input_files = ();
280 # Line number at which AC_OUTPUT seen.
281 my $ac_output_line = 0;
283 # List of directories to search for configure-required files. This
284 # can be set by AC_CONFIG_AUX_DIR.
285 my @config_aux_path = ('.', '..', '../..');
286 my $config_aux_dir = '';
288 # Whether AC_PROG_MAKE_SET has been seen in configure.ac.
289 my $seen_make_set = 0;
291 # Whether AM_GNU_GETTEXT has been seen in configure.ac.
292 my $seen_gettext = 0;
293 # Line number at which AM_GNU_GETTEXT seen.
294 my $ac_gettext_line = 0;
296 # Whether ALL_LINGUAS has been seen.
297 my $seen_linguas = '';
299 my $all_linguas = '';
300 # Line number at which it appears.
301 my $all_linguas_line = 0;
303 # 1 if AC_PROG_INSTALL seen.
304 my $seen_prog_install = 0;
306 # Whether AC_PATH_XTRA has been seen in configure.ac.
307 my $seen_path_xtra = 0;
309 # TRUE if AC_DECL_YYTEXT was seen.
310 my $seen_decl_yytext = 0;
312 # TRUE if we've seen AC_CANONICAL_(HOST|SYSTEM). The presence of
313 # AC_CHECK_TOOL also sets this.
314 my $seen_canonical = 0;
316 # TRUE if we've seen AC_ARG_PROGRAM.
317 my $seen_arg_prog = 0;
319 # TRUE if we've seen AC_PROG_LIBTOOL.
320 my $seen_libtool = 0;
321 my $libtool_line = 0;
323 # TRUE if we've seen AM_MAINTAINER_MODE.
324 my $seen_maint_mode = 0;
326 # Actual version we've seen.
327 my $package_version = '';
329 # Line number where we saw version definition.
330 my $package_version_line = 0;
332 # TRUE if we've seen AM_PATH_LISPDIR.
333 my $seen_lispdir = 0;
335 # TRUE if we've seen AM_CHECK_PYTHON.
336 my $seen_pythondir = 0;
338 # TRUE if we've seen AC_EXEEXT.
341 # TRUE if we've seen AC_OBJEXT.
344 # TRUE if we've seen AC_ENABLE_MULTILIB.
345 my $seen_multilib = 0;
347 # TRUE if we've seen AM_PROG_CC_C_O
350 # TRUE if we've seen AM_INIT_AUTOMAKE.
351 my $seen_init_automake = 0;
353 # Hash table of discovered configure substitutions. Keys are names,
354 # values are `FILE:LINE' strings which are used by error message
356 my %configure_vars = ();
358 # This is used to keep track of which variable definitions we are
359 # scanning. It is only used in certain limited ways, but it has to be
360 # global. It is declared just for documentation purposes.
361 my %vars_scanned = ();
363 # Charsets used by maintainer and in distribution. MAINT_CHARSET is
364 # handled in a funny way: if seen in the top-level Makefile.am, it is
365 # used for every directory which does not specify a different value.
366 # The rationale here is that some directories (eg gettext) might be
367 # distributions of other packages, and thus require their own charset
368 # info. However, the DIST_CHARSET must be the same for the entire
369 # package; it can only be set at top-level.
370 # FIXME: this yields bugs when rebuilding. What to do? Always
371 # read (and sometimes discard) top-level Makefile.am?
372 my $maint_charset = '';
373 my $dist_charset = 'utf8'; # recode doesn't support this yet.
375 # TRUE if --cygnus seen.
378 # Hash table of AM_CONDITIONAL variables seen in configure.
379 my %configure_cond = ();
381 # This maps extensions onto language names.
382 my %extension_map = ();
384 # List of the DIST_COMMON files we discovered while reading
386 my $configure_dist_common = '';
388 # This maps languages names onto properties.
389 my %language_map = ();
391 # List of targets we must always output.
392 # FIXME: Complete, and remove falsely required targets.
393 my %required_targets =
403 # FIXME: Not required, temporary hacks.
404 # Well, actually they are sort of required: the -recursive
405 # targets will run them anyway...
408 'install-data-am' => 1,
409 'install-exec-am' => 1,
410 'installcheck-am' => 1,
417 ################################################################
419 ## ------------------------------------------ ##
420 ## Variables reset by &initialize_per_input. ##
421 ## ------------------------------------------ ##
423 # Basename and relative dir of the input file.
427 # Same but wrt Makefile.in.
431 # These two variables are used when generating each Makefile.in.
432 # They hold the Makefile.in until it is ready to be printed.
439 # Suffixes found during a run.
442 # This maps a variable name onto a flag. The flag is true iff the
443 # variable was first defined with `+='.
446 # Maps a variable name to true iff the variable was defined by Automake.
447 # This is used during startup to determine which variables can be
448 # assigned with `+='.
451 # For a variable or target $ITEM which is defined conditionally,
452 # this holds a hash of the conditional values. The keys of
453 # %CONDITIONAL{$ITEM} are the conditions (the variables which
454 # configure will substitute), and the values, the associated
455 # values (meaningless for targets).
457 # By definition, for an unconditional variable, this is empty.
460 # This holds the line numbers at which various elements of
461 # %conditional are defined.
464 # This holds a 1 if a particular variable was examined.
467 # This holds the names which are targets. These also appear in
471 # Same as %CONDITIONAL, but for targets.
472 my %target_conditional;
474 # This is the conditional stack.
475 my @conditional_stack;
477 # This holds the set of included files.
480 # This holds a list of directories which we must create at `dist'
481 # time. This is used in some strange scenarios involving weird
482 # AC_OUTPUT commands.
485 # List of dependencies for the obvious targets.
490 # Holds the dependencies of targets which dependencies are factored.
491 # Typically, `.PHONY' will appear in plenty of *.am files, but must
492 # be output once. Arguably all pure dependencies could be subject
493 # to this factorization, but it is not unpleasant to have paragraphs
494 # in Makefile: keeping related stuff altogether.
497 # Holds the factored actions. Tied to %DEPENDENCIES, i.e., filled
498 # only when keys exists in %DEPENDENCIES.
501 # A list of files deleted by `maintainer-clean'.
502 my @maintainer_clean_files;
504 # These are pretty obvious, too. They are used to define the
505 # SOURCES and OBJECTS variables.
508 # Sources which go in the distribution.
511 # This hash maps object file names onto their corresponding source
512 # file names. This is used to ensure that each object is created
513 # by a single source file.
516 # This keeps track of the directories for which we've already
517 # created `.dirstamp' code.
520 # These variables track inclusion of various compile-related .am
521 # files. $included_generic_compile is TRUE if the basic code has
522 # been included. $included_knr_compile is TRUE if the ansi2knr
523 # code has been included. $included_libtool_compile is TRUE if
524 # libtool support has been included.
525 my $included_generic_compile;
526 my $included_knr_compile;
527 my $included_libtool_compile;
536 # Options from AUTOMAKE_OPTIONS.
539 # Whether or not dependencies are handled. Can be further changed
541 my $use_dependencies;
544 my $local_maint_charset;
546 # All yacc and lex source filenames for this directory. Use
547 # filenames instead of raw count so that multiple instances are
548 # counted correctly (eg one yacc file can appear in multiple
549 # programs without harm).
553 # This is a list of all targets to run during "make dist".
556 # Keys in this hash are the basenames of files which must depend
560 # This maps the source extension of a suffix rule to its
561 # corresponding output extension.
564 # This is a regular expression which matches all the known source
565 # suffix. A source suffix is one that appears in the first
566 # position of a suffix rule.
567 my $source_suffix_pattern;
569 # This is the name of the redirect `all' target to use.
572 # This keeps track of which extensions we've seen (that we care
576 # This is random scratch space for the language finish functions.
577 # Don't randomly overwrite it; examine other uses of keys first.
578 my %language_scratch;
580 # We keep track of which objects need special (per-executable)
581 # handling on a per-language basis.
582 my %lang_specific_files;
584 # This is set when `handle_dist' has finished. Once this happens,
585 # we should no longer push on dist_common.
588 # True if we need `LINK' defined. This is a hack.
591 # The keys here are variables we want to dump at the end of this
592 # function. The values are corresponding comments.
595 # This is the list of such variables to output.
596 # FIXME: Might be useless actually.
599 # Is $am_var{'foo'} defined with `=', or `+='?
603 # &initialize_per_input ()
604 # ------------------------
605 # (Re)-Initialize per-Makefile.am variables.
606 sub initialize_per_input ()
609 $am_relative_dir = '';
616 $output_trailer = '';
622 %var_was_plus_eq = ();
634 %target_conditional = ();
636 @conditional_stack = ();
642 $am_relative_dir = '';
658 # Installing/uninstalling.
659 'install-data-am' => [],
660 'install-exec-am' => [],
661 'uninstall-am' => [],
664 'uninstall-man' => [],
666 'install-info' => [],
667 'install-info-am' => [],
668 'uninstall-info' => [],
670 'installcheck-am' => [],
674 'mostlyclean-am' => [],
675 'maintainer-clean-am' => [],
676 'distclean-am' => [],
679 'maintainer-clean' => [],
690 @maintainer_clean_files = ();
700 $included_generic_compile = 0;
701 $included_knr_compile = 0;
702 $included_libtool_compile = 0;
706 $strictness = $default_strictness;
707 $strictness_name = $default_strictness_name;
711 $use_dependencies = $cmdline_use_dependencies;
713 $local_maint_charset = $maint_charset;
724 $source_suffix_pattern = '';
728 %extension_seen = ();
730 %language_scratch = ();
732 %lang_specific_files = ();
734 $handle_dist_run = 0;
744 ################################################################
746 # Initialize our list of languages that are internally supported.
747 ®ister_language ('c', 'ansi-p=1', 'autodep=', 'flags=CFLAGS',
748 'compile=$(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)',
749 'compiler-name=COMPILE',
752 ®ister_language ('cxx', 'linker=CXXLINK', 'autodep=CXX', 'flags=CXXFLAGS',
753 'compile=$(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)',
754 'compiler-name=CXXCOMPILE',
755 'output-arg=-c -o $@',
757 'c++', 'cc', 'cpp', 'cxx', 'C');
758 ®ister_language ('objc', 'linker=OBJCLINK', 'autodep=OBJC',
760 'compile=$(OBJC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_OBJCFLAGS) $(OBJCFLAGS)',
761 'compiler-name=OBJCCOMPILE',
762 'output-arg=-c -o $@',
765 ®ister_language ('header',
766 'h', 'H', 'hxx', 'h++', 'hh', 'hpp', 'inc');
768 # For now, yacc and lex can't be handled on a per-exe basis.
769 ®ister_language ('yacc', 'ansi-p=1', 'derived-autodep=yes',
771 ®ister_language ('yaccxx', 'linker=CXXLINK', 'derived-autodep=yes',
772 'y++', 'yy', 'yxx', 'ypp');
773 ®ister_language ('lex', 'ansi-p=1', 'derived-autodep=yes',
775 ®ister_language ('lexxx', 'linker=CXXLINK', 'derived-autodep=yes',
776 'l++', 'll', 'lxx', 'lpp');
778 ®ister_language ('asm',
779 'flags=CFLAGS', # FIXME: asmflags?
780 'compile=$(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)', # FIXME: a different compiler?
781 'compiler-name=COMPILE',
785 ®ister_language ('f77', 'linker=F77LINK', 'flags=FFLAGS',
786 'compile=$(F77) $(AM_FFLAGS) $(FFLAGS)',
787 'compiler-name=F77COMPILE',
788 'output-arg=-c -o $@',
791 ®ister_language ('ppf77', 'linker=F77LINK', 'flags=FFLAGS',
792 'compile=$(F77) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FFLAGS) $(FFLAGS)',
793 'compiler-name=PPF77COMPILE',
794 'output-arg=-c -o $@',
797 ®ister_language ('ratfor', 'linker=F77LINK',
798 'flags=RFLAGS', # FIXME also FFLAGS.
799 'compile=$(F77) $(AM_FFLAGS) $(FFLAGS) $(AM_RFLAGS) $(RFLAGS)',
800 'compiler-name=RCOMPILE',
801 'output-arg=-c -o $@',
804 # FIXME: for now we can't do dependency tracking for Java.
806 ®ister_language ('java', 'linker=GCJLINK', 'flags=GCJFLAGS',
807 'compile=$(GCJ) $(DEFS) $(INCLUDES) $(AM_GCJFLAGS) $(GCJFLAGS)',
808 'compiler-name=GCJCOMPILE',
809 'output-arg=-c -o $@',
811 'java', 'class', 'zip', 'jar');
813 ################################################################
815 # Parse command line.
818 # Do configure.ac scan only once.
819 &scan_autoconf_files;
821 die "$me: no `Makefile.am' found or specified\n"
824 # Now do all the work on each file.
825 # This guy must be local otherwise it's private to the loop.
828 foreach $am_file (@input_files)
830 if (! -f ($am_file . '.am'))
832 &am_error ("`" . $am_file . ".am' does not exist");
836 &generate_makefile ($output_files{$am_file}, $am_file);
842 # FIXME: This should be `my'ed next to its subs.
843 use vars '%require_file_found';
845 ################################################################
847 # prog_error (@PRINT-ME)
848 # ----------------------
849 # Signal a programming error, display PRINT-ME, and exit 1.
852 print STDERR "$me: programming error: @_\n";
860 # Return LIST with no duplicates.
865 foreach my $item (@_)
867 if (! defined $seen{$item})
877 ################################################################
881 # &backname ($REL-DIR)
882 # --------------------
883 # If I `cd $REL-DIR', then to come back, I should `cd $BACKPATH'.
884 # For instance `src/foo' => `../..'.
885 # Works with non strictly increasing paths, i.e., `src/../lib' => `..'.
890 foreach (split (/\//, $file))
892 next if $_ eq '.' || $_ eq '';
902 return join ('/', @res) || '.';
905 ################################################################
907 # Parse command line.
908 sub parse_arguments ()
911 &set_strictness ('gnu');
914 Getopt::Long::config ("bundling");
915 Getopt::Long::GetOptions
917 'version' => \&version,
919 'amdir:s' => \$am_dir,
920 'gnu' => sub { &set_strictness ('gnu'); },
921 'gnits' => sub { &set_strictness ('gnits'); },
922 'cygnus' => \$cygnus_mode,
923 'foreign' => sub { &set_strictness ('foreign'); },
924 'include-deps' => sub { $cmdline_use_dependencies = 1; },
925 'i|ignore-deps' => sub { $cmdline_use_dependencies = 0; },
926 'no-force' => sub { $force_generation = 0; },
927 'f|force-missing'=> \$force_missing,
928 'o|output-dir:s' => \$output_directory,
929 'a|add-missing' => \$add_missing,
930 'c|copy' => \$copy_missing,
931 'v|verbose' => \$verbose,
932 'Werror' => sub { $SIG{"__WARN__"} = sub { die $_[0] } },
933 'Wno-error' => sub { $SIG{"__WARN__"} = 'DEFAULT' }
937 foreach my $arg (@ARGV)
939 # Handle $local:$input syntax. Note that we only examine the
940 # first ":" file to see if it is automake input; the rest are
941 # just taken verbatim. We still keep all the files around for
942 # dependency checking, however.
943 my ($local, $input, @rest) = split (/:/, $arg);
950 # Strip .in; later on .am is tacked on. That is how the
951 # automake input file is found. Maybe not the best way, but
952 # it is easy to explain.
954 or die "$me: invalid input file name `$arg'\n.";
956 push (@input_files, $input);
957 $output_files{$input} = join (':', ($local, @rest));
960 # Take global strictness from whatever we currently have set.
961 $default_strictness = $strictness;
962 $default_strictness_name = $strictness_name;
965 ################################################################
967 # Generate a Makefile.in given the name of the corresponding Makefile and
968 # the name of the file output by config.status.
969 sub generate_makefile
971 my ($output, $makefile) = @_;
973 # Reset all the Makefile.am related variables.
974 &initialize_per_input;
976 # Name of input file ("Makefile.am") and output file
977 # ("Makefile.in"). These have no directory components.
978 $am_file_name = basename ($makefile) . '.am';
979 $in_file_name = basename ($makefile) . '.in';
981 # $OUTPUT is encoded. If it contains a ":" then the first element
982 # is the real output file, and all remaining elements are input
983 # files. We don't scan or otherwise deal with these input file,
984 # other than to mark them as dependencies. See
985 # &scan_autoconf_files for details.
986 my (@secondary_inputs);
987 ($output, @secondary_inputs) = split (/:/, $output);
989 $relative_dir = dirname ($output);
990 $am_relative_dir = dirname ($makefile);
992 &read_main_am_file ($makefile . '.am');
995 # Fatal error. Just return, so we can continue with next file.
999 # There are a few install-related variables that you should not define.
1000 foreach my $var ('PRE_INSTALL', 'POST_INSTALL', 'NORMAL_INSTALL')
1002 if (&variable_defined ($var))
1004 &am_line_error ($var, "`$var' should not be defined");
1008 # At the toplevel directory, we might need config.guess, config.sub
1009 # or libtool scripts (ltconfig and ltmain.sh).
1010 if ($relative_dir eq '.')
1012 # libtool requires some files.
1013 &require_conf_file_with_conf_line ($libtool_line, $FOREIGN,
1017 # AC_CANONICAL_HOST and AC_CANONICAL_SYSTEM need config.guess and
1019 &require_config_file ($FOREIGN, 'config.guess', 'config.sub')
1023 # We still need Makefile.in here, because sometimes the `dist'
1024 # target doesn't re-run automake.
1025 if ($am_relative_dir eq $relative_dir)
1027 # Only distribute the files if they are in the same subdir as
1028 # the generated makefile.
1029 &push_dist_common ($in_file_name, $am_file_name);
1032 push (@sources, '$(SOURCES)')
1033 if &variable_defined ('SOURCES');
1034 push (@objects, '$(OBJECTS)')
1035 if &variable_defined ('OBJECTS');
1037 # If OBJEXT/EXEEXT were not set in configure.in, do it, it
1038 # simplifies our task, and anyway starting with Autoconf 2.50, it
1039 # will always be defined, and this code will be dead.
1040 $output_vars .= "EXEEXT =\n"
1041 unless $seen_exeext;
1042 $output_vars .= "OBJEXT = o\n"
1043 unless $seen_objext;
1045 # Must do this after reading .am file. See read_main_am_file to
1046 # understand weird tricks we play there with variables.
1047 &define_variable ('subdir', $relative_dir);
1049 # Check first, because we might modify some state.
1051 &check_gnu_standards;
1052 &check_gnits_standards;
1054 &handle_configure ($output, $makefile, @secondary_inputs);
1057 &handle_ltlibraries;
1061 # This must be run after all the sources are scanned.
1064 # Re-init SOURCES and OBJECTS. FIXME: other code shouldn't depend
1065 # on this (but currently does).
1066 macro_define ('SOURCES', 1, '', 'TRUE',
1067 join (' ', @sources), 'internal');
1068 macro_define ('OBJECTS', 1, '', 'TRUE',
1069 join (' ', @objects), 'internal');
1070 &define_pretty_variable ('DIST_SOURCES', '', @dist_sources);
1082 &handle_minor_options;
1083 &handle_dependencies;
1086 # This must come after most other rules.
1087 &handle_dist ($makefile);
1090 &do_check_merge_target;
1091 &handle_all ($output);
1094 if (&variable_defined('lib_LTLIBRARIES') &&
1095 &variable_defined('bin_PROGRAMS'))
1097 $output_rules .= "install-binPROGRAMS: install-libLTLIBRARIES\n\n";
1100 &handle_installdirs;
1102 &handle_factored_dependencies;
1106 if (! -d ($output_directory . '/' . $am_relative_dir))
1108 mkdir ($output_directory . '/' . $am_relative_dir, 0755);
1111 my ($out_file) = $output_directory . '/' . $makefile . ".in";
1112 if (! $force_generation && -e $out_file)
1114 my ($am_time) = (stat ($makefile . '.am'))[9];
1115 my ($in_time) = (stat ($out_file))[9];
1116 # FIXME: should cache these times.
1117 my ($conf_time) = (stat ($configure_ac))[9];
1118 # FIXME: how to do unsigned comparison?
1119 if ($am_time < $in_time || $am_time < $conf_time)
1121 # No need to update.
1124 if (-f 'aclocal.m4')
1126 my ($acl_time) = (stat _)[9];
1127 return if ($am_time < $acl_time);
1131 my $gm_file = new IO::File "> $out_file";
1134 warn "$me: ${am_file}.in: cannot write: $!\n";
1138 print "$me: creating ", $makefile, ".in\n" if $verbose;
1140 # In case we're running under MSWindows, don't write with CRLF
1141 # (as it causes problems for the dependency-file extraction in
1142 # AM_OUTPUT_DEPENDENCY_COMMANDS).
1145 print $gm_file $output_vars;
1146 # We make sure that `all:' is the first target.
1147 print $gm_file $output_all;
1148 print $gm_file $output_header;
1149 print $gm_file $output_rules;
1150 print $gm_file $output_trailer;
1152 if (! $gm_file->close)
1154 warn "$me: $am_file.in: cannot close: $!\n";
1160 ################################################################
1162 # Handle AUTOMAKE_OPTIONS variable. Return 1 on error, 0 otherwise.
1165 if (&variable_defined ('AUTOMAKE_OPTIONS'))
1167 foreach (&variable_value_as_list ('AUTOMAKE_OPTIONS', ''))
1170 if ($_ eq 'gnits' || $_ eq 'gnu' || $_ eq 'foreign')
1172 &set_strictness ($_);
1174 elsif ($_ eq 'cygnus')
1180 # An option like "../lib/ansi2knr" is allowed. With
1181 # no path prefix, we assume the required programs are
1182 # in this directory. We save the actual option for
1184 $options{'ansi2knr'} = $_;
1186 elsif ($_ eq 'no-installman' || $_ eq 'no-installinfo'
1187 || $_ eq 'dist-shar' || $_ eq 'dist-zip'
1188 || $_ eq 'dist-tarZ' || $_ eq 'dist-bzip2'
1189 || $_ eq 'dejagnu' || $_ eq 'no-texinfo.tex'
1190 || $_ eq 'readme-alpha' || $_ eq 'check-news'
1191 || $_ eq 'subdir-objects' || $_ eq 'nostdinc')
1193 # Explicitly recognize these.
1195 elsif ($_ eq 'no-dependencies')
1197 $use_dependencies = 0;
1199 elsif (/([0-9]+)\.([0-9]+)([a-z]?)/)
1201 # Got a version number.
1203 my ($rmajor, $rminor, $ralpha) = ($1, $2, $3);
1205 &prog_error ("version is incorrect: $VERSION")
1206 if $VERSION !~ /([0-9]+)\.([0-9]+)([a-z]?)/;
1208 my ($tmajor, $tminor, $talpha) = ($1, $2, $3);
1210 # 2.0 is better than 1.0.
1211 # 1.2 is better than 1.1.
1212 # 1.2a is better than 1.2.
1213 if ($rmajor > $tmajor
1214 || ($rmajor == $tmajor && $rminor > $tminor)
1215 || ($rminor == $tminor && $rminor == $tminor
1216 && $ralpha gt $talpha))
1218 &am_line_error ('AUTOMAKE_OPTIONS',
1219 "require version $_, only have $VERSION");
1225 &am_line_error ('AUTOMAKE_OPTIONS',
1226 "option `" . $_ . "\' not recognized");
1231 if ($strictness == $GNITS)
1233 $options{'readme-alpha'} = 1;
1234 $options{'check-news'} = 1;
1241 # get_object_extension ($OUT)
1242 # ---------------------------
1243 # Return object extension. Just once, put some code into the output.
1244 # OUT is the name of the output file
1245 sub get_object_extension
1249 # Maybe require libtool library object files.
1250 my $extension = '.$(OBJEXT)';
1251 $extension = '.lo' if ($out =~ /\.la$/);
1253 if (! $included_generic_compile)
1256 my $default_includes = '';
1257 if (! defined $options{'nostdinc'})
1259 $default_includes = ' -I. -I$(srcdir)';
1261 if (&variable_defined ('CONFIG_HEADER'))
1263 foreach my $hdr (split (' ', &variable_value ('CONFIG_HEADER')))
1265 $default_includes .= ' -I' . dirname ($hdr);
1270 my ($coms, $vars, $rules) =
1271 &file_contents_internal ('compile',
1272 ('DEFAULT_INCLUDES' => $default_includes));
1273 $output_vars .= $vars;
1274 $output_rules .= "$coms$rules";
1276 # If using X, include some extra variable definitions. NOTE
1277 # we don't want to force these into CFLAGS or anything,
1278 # because not all programs will necessarily use X.
1279 if ($seen_path_xtra)
1281 foreach my $var ('X_CFLAGS',
1282 'X_LIBS', 'X_EXTRA_LIBS', 'X_PRE_LIBS')
1284 &define_configure_variable ($var);
1288 push (@suffixes, '.c', '.o', '.obj');
1290 $included_generic_compile = 1;
1293 if ($seen_libtool && ! $included_libtool_compile)
1295 # Output the libtool compilation rules.
1296 $output_rules .= &file_contents ('libtool');
1298 push (@suffixes, '.lo');
1300 $included_libtool_compile = 1;
1303 # Check for automatic de-ANSI-fication.
1304 if (defined $options{'ansi2knr'})
1306 $extension = '$U' . $extension;
1307 if (! $included_knr_compile)
1309 if (! $am_c_prototypes)
1311 &am_line_error ('AUTOMAKE_OPTIONS',
1312 "option `ansi2knr' in use but `AM_C_PROTOTYPES' not in `$configure_ac'");
1313 &keyed_aclocal_warning ('AM_C_PROTOTYPES');
1314 # Only give this error once.
1315 $am_c_prototypes = 1;
1318 # Only require ansi2knr files if they should appear in
1320 if ($options{'ansi2knr'} eq 'ansi2knr')
1322 &require_file_with_line ('AUTOMAKE_OPTIONS', $FOREIGN,
1323 'ansi2knr.c', 'ansi2knr.1');
1326 # Make sure ansi2knr can be found: if no path specified,
1328 if ($options{'ansi2knr'} eq 'ansi2knr')
1330 # Substitution from AM_C_PROTOTYPES. This makes it be
1331 # built only when necessary.
1332 &define_configure_variable ('ANSI2KNR');
1333 # ansi2knr needs to be built before subdirs, so unshift it.
1334 unshift (@all, '$(ANSI2KNR)');
1338 # Found in another directory.
1339 &define_variable ("ANSI2KNR", $options{'ansi2knr'});
1342 my $ansi2knr_dir = '';
1343 $ansi2knr_dir = dirname ($options{'ansi2knr'})
1344 if $options{'ansi2knr'} ne 'ansi2knr';
1346 $output_rules .= &file_contents ('ansi2knr',
1347 ('ANSI2KNR-DIR' => $ansi2knr_dir));
1349 $included_knr_compile = 1;
1356 # Call finish function for each language that was used.
1357 sub finish_languages
1359 my ($ltcompile, $ltlink) = &libtool_compiler;
1363 foreach my $ext (sort keys %extension_seen)
1365 my $lang = $extension_map{$ext};
1367 # Generate the appropriate rules for this extension. If
1368 # dependency tracking was requested, and this extension
1369 # supports it, then we don't generate the rule here.
1372 if ($use_dependencies && $language_map{"$lang-autodep"} ne 'no')
1374 # Don't generate the rule, but still generate the variables.
1375 if (exists $language_map{"$lang-compile"})
1377 $comp = $language_map{"$lang-compile"};
1380 elsif (exists $language_map{"$lang-compile"})
1382 $comp = $language_map{"$lang-compile"};
1384 my $outarg = $language_map{"$lang-output-arg"};
1385 if ($language_map{"$lang-flags"} eq 'CFLAGS')
1387 # C compilers don't always support -c -o.
1388 if (defined $options{'subdir-objects'})
1390 $outarg .= ' -o $@';
1395 . $language_map{"$lang-compiler-name"}
1398 $output_rules .= (".$ext.o:\n"
1401 # FIXME: Using cygpath should be somehow conditional.
1402 $output_rules .= (".$ext.obj:\n"
1404 . " `cygpath -w \$<`\n");
1405 $output_rules .= (".$ext.lo:\n"
1407 . $language_map{"$lang-compiler-name"}
1409 . $language_map{"$lang-output-arg"}
1410 # We can always use -c -o with libtool.
1411 . ($language_map{"$lang-flags"} eq 'CFLAGS'
1417 push (@suffixes, '.' . $ext);
1419 # The rest of the loop is done once per language.
1420 next if defined $done{$lang};
1423 # If the source to a program consists entirely of code from a
1424 # `pure' language, for instance C++ for Fortran 77, then we
1425 # don't need the C compiler code. However if we run into
1426 # something unusual then we do generate the C code. There are
1427 # probably corner cases here that do not work properly.
1428 # People linking Java code to Fortran code deserve pain.
1430 if $language_map{"$lang-pure"} eq 'no';
1434 &define_compiler_variable ($language_map{"$lang-compiler-name"},
1437 # The compiler's flag must be a configure variable.
1438 if (exists $language_map{"$lang-flags"})
1440 &define_configure_variable ($language_map{"$lang-flags"});
1443 # Compute the function name of the finisher and then call it.
1444 my $name = 'lang_' . $lang . '_finish';
1448 # If the project is entirely C++ or entirely Fortran 77, don't
1449 # bother with the C stuff. But if anything else creeps in, then use
1451 if ($need_link || ! $non_c || scalar keys %suffix_rules > 0)
1453 if (! defined $done{'c'})
1455 &define_configure_variable ($language_map{'c-flags'});
1456 &define_compiler_variable ($language_map{'c-compiler-name'},
1458 $language_map{'c-compile'});
1460 &define_variable ('CCLD', '$(CC)');
1461 &define_variable ('LINK',
1462 $ltlink . '$(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@');
1466 # Output a rule to build from a YACC source. The output from YACC is
1467 # compiled with C or C++, depending on the extension of the YACC file.
1468 sub output_yacc_build_rule
1470 my ($yacc_suffix, $use_ylwrap) = @_;
1472 (my $c_suffix = $yacc_suffix) =~ tr/y/c/;
1474 # Generate rule for c/c++.
1475 $output_rules .= &file_contents ('yacc',
1476 ('YLWRAP' => $use_ylwrap,
1477 'YACC_SUFFIX' => $yacc_suffix,
1478 'C_SUFFIX' => $c_suffix));
1481 sub output_lex_build_rule
1483 my ($lex_suffix, $use_ylwrap) = @_;
1485 (my $c_suffix = $lex_suffix) =~ tr/l/c/;
1487 $output_rules .= &file_contents ('lex',
1488 ('YLWRAP' => $use_ylwrap,
1489 'LEX_SUFFIX' => $lex_suffix,
1490 'C_SUFFIX' => $c_suffix));
1494 # Check to make sure a source defined in LIBOBJS is not explicitly
1495 # mentioned. This is a separate function (as opposed to being inlined
1496 # in handle_source_transform) because it isn't always appropriate to
1498 sub check_libobjs_sources
1500 my ($one_file, $unxformed) = @_;
1502 foreach my $prefix ('', 'EXTRA_', 'dist_', 'nodist_',
1503 'dist_EXTRA_', 'nodist_EXTRA_')
1506 if (&variable_defined ($prefix . $one_file . '_SOURCES'))
1508 @files = &variable_value_as_list (($prefix
1509 . $one_file . '_SOURCES'),
1512 elsif ($prefix eq '')
1514 @files = ($unxformed . '.c');
1521 foreach my $file (@files)
1523 if (defined $libsources{$file})
1525 &am_line_error ($prefix . $one_file . '_SOURCES',
1526 "automatically discovered file `$file' should not be explicitly mentioned");
1533 # ($LINKER, @OBJECTS)
1534 # handle_single_transform_list ($VAR, $DERIVED, $OBJ, @FILES)
1535 # -----------------------------------------------------------
1536 # Does much of the actual work for handle_source_transform.
1538 # $DERIVED is the name of resulting executable or library
1539 # $OBJ is the object extension (e.g., `$U.lo')
1540 # @FILES is the list of source files to transform
1542 # $LINKER is name of linker to use (empty string for default linker)
1543 # @OBJECTS are names of objects
1544 sub handle_single_transform_list ($$$@)
1546 my ($var, $derived, $obj, @files) = @_;
1548 my $nonansi_obj = $obj;
1549 $nonansi_obj =~ s/\$U//g;
1550 my %linkers_used = ();
1552 # Turn sources into objects.
1555 # Configure substitutions in _SOURCES variables are errors.
1558 &am_line_error ($var, "$var includes configure substitution `$_'");
1562 # If the source file is in a subdirectory then the `.o' is
1563 # put into the current directory.
1565 # Split file name into base and extension.
1566 next if ! /^(?:(.*)\/)?([^\/]*)\.(.*)$/;
1568 my $directory = $1 || '';
1574 # We must generate a rule for the object if it requires
1578 my ($linker, $object);
1580 $extension = &derive_suffix ($extension);
1581 my $lang = $extension_map{$extension};
1584 &saw_extension ($extension);
1585 # Found the language, so see what it says.
1586 my $subr = 'lang_' . $lang . '_rewrite';
1587 # Note: computed subr call.
1588 my $r = & $subr ($directory, $base, $extension);
1589 # Skip this entry if we were asked not to process it.
1590 next if $r == $LANG_IGNORE;
1592 # Now extract linker and other info.
1593 $linker = $language_map{"$lang-linker"};
1596 if ($language_map{"$lang-ansi-p"})
1598 $object = $base . $obj;
1599 $this_obj_ext = $obj;
1603 $object = $base . $nonansi_obj;
1604 $this_obj_ext = $nonansi_obj;
1607 if (exists $language_map{"$lang-flags"}
1608 && &variable_defined ($derived . '_'
1609 . $language_map{"$lang-flags"}))
1611 # We have a per-executable flag in effect for this
1612 # object. In this case we rewrite the object's
1613 # name to ensure it is unique. We also require
1614 # the `compile' program to deal with compilers
1615 # where `-c -o' does not work.
1617 # We choose the name `DERIVED-OBJECT' to ensure
1618 # (1) uniqueness, and (2) continuity between
1619 # invocations. However, this will result in a
1620 # name that is too long for losing systems, in
1621 # some situations. So we provide _SHORTNAME to
1624 my $dname = $derived;
1625 if (&variable_defined ($derived . '_SHORTNAME'))
1627 # FIXME: should use the same conditional as
1628 # the _SOURCES variable. But this is really
1629 # silly overkill -- nobody should have
1630 # conditional shortnames.
1631 $dname = &variable_value ($derived . '_SHORTNAME');
1633 $object = $dname . '-' . $object;
1635 &require_file ($FOREIGN, 'compile')
1638 &prog_error ("$lang flags defined without compiler")
1639 if ! defined $language_map{"$lang-compile"};
1641 # Compute the rule to compile this object.
1642 my $flag = $language_map{"$lang-flags"};
1643 my $val = "(${derived}_${flag}";
1644 ($rule = $language_map{"$lang-compile"}) =~
1647 $rule .= ' ' . $language_map{"$lang-output-arg"};
1648 # For C we have to add the -o, because the
1649 # standard rule doesn't include it.
1650 if ($language_map{"$lang-flags"} eq 'CFLAGS')
1658 # If rewrite said it was ok, put the object into a
1660 if ($r == $LANG_SUBDIR && $directory ne '')
1662 $object = $directory . '/' . $object;
1663 $xbase = $directory . '/' . $base;
1666 # If doing dependency tracking, then we can't print
1667 # the rule. If we have a subdir object, we need to
1668 # generate an explicit rule. Actually, in any case
1669 # where the object is not in `.' we need a special
1670 # rule. The per-object rules in this case are
1671 # generated later, by add_depend2.
1672 if (($use_dependencies
1674 && $language_map{"$lang-autodep"} ne 'no')
1675 || $directory ne '')
1678 my $obj_sans_ext = substr ($object, 0,
1679 - length ($this_obj_ext));
1680 push (@{$lang_specific_files{$lang}},
1681 "$derived $full $obj_sans_ext");
1684 elsif ($extension eq 'o')
1686 # This is probably the result of a direct suffix rule.
1687 # In this case we just accept the rewrite. FIXME:
1688 # this fails if we want libtool objects.
1689 $object = $base . '.' . $extension;
1694 # No error message here. Used to have one, but it was
1699 $linkers_used{$linker} = 1;
1701 push (@result, $object);
1703 if (defined $object_map{$object})
1705 if ($object_map{$object} ne $full)
1707 &am_error ("object `$object' created by `$full' and `$object_map{$object}'");
1713 $object_map{$object} = $full;
1715 # If file is in subdirectory, we need explicit
1717 if ($directory ne '' || $renamed)
1719 push (@dep_list, $full);
1722 # If resulting object is in subdir, we need to make
1723 # sure the subdir exists at build time.
1724 if ($object =~ /\//)
1726 # FIXME: check that $DIRECTORY is somewhere in the
1729 # We don't allow `..' in object file names for
1730 # *any* source, not just Java. For Java it just
1731 # doesn't make sense, but in general it is
1732 # a problem because we can't pick a good name for
1734 if ($object =~ /(\/|^)\.\.\//)
1736 &am_error ("`$full' contains `..' component but should not");
1739 push (@dep_list, $directory . '/.dirstamp');
1741 # If we're generating dependencies, we also want
1742 # to make sure that the appropriate subdir of the
1743 # .deps directory is created.
1744 if ($use_dependencies)
1746 push (@dep_list, '.deps/' . $directory . '/.dirstamp');
1749 if (! defined $directory_map{$directory})
1751 $directory_map{$directory} = 1;
1752 $output_rules .= ($directory . "/.dirstamp:\n"
1753 . "\t\@\$(mkinstalldirs) $directory\n"
1754 . "\t\@: > $directory/.dirstamp\n");
1755 if ($use_dependencies)
1757 $output_rules .= ('.deps/' . $directory
1759 . "\t\@\$(mkinstalldirs) .deps/$directory\n"
1760 . "\t\@: > .deps/$directory/.dirstamp\n");
1765 &pretty_print_rule ($object . ':', "\t", @dep_list)
1766 if scalar @dep_list > 0 || $rule ne '';
1768 # Print the rule if we have one.
1771 # Turn `$@' into name of our object file.
1772 my $xform = $object;
1773 $xform =~ s,/,\\/,g;
1774 $rule =~ s/\$\@/$xform/;
1776 # We cannot use $< here since this is an explicit
1777 # rule and not all makes handle that.
1778 $rule .= " `test -f $full || echo '\$(srcdir)/'`$full";
1780 # FIXME: handle .lo and .obj as well.
1781 $output_rules .= "\t" . $rule . "\n";
1785 # Transform .o or $o file into .P file (for automatic
1788 && ($language_map{"$lang-autodep"} ne 'no'
1789 || $language_map{"$lang-derived-autodep"} eq 'yes'))
1791 my $depfile = $object;
1792 $depfile =~ s/\.([^.]*)$/.P$1/;
1793 $depfile =~ s/\$\(OBJEXT\)$/o/;
1794 $dep_files{'$(DEPDIR)/' . $depfile} = 1;
1798 return (&resolve_linker (%linkers_used), @result);
1803 # Handle SOURCE->OBJECT transform for one program or library.
1805 # canonical (transformed) name of object to build
1806 # actual name of object to build
1807 # object extension (ie either `.o' or `$o'.
1808 # Return result is name of linker variable that must be used.
1809 # Empty return means just use `LINK'.
1810 sub handle_source_transform
1812 # one_file is canonical name. unxformed is given name. obj is
1814 my ($one_file, $unxformed, $obj) = @_;
1818 if (&variable_defined ($one_file . "_OBJECTS"))
1820 &am_line_error ($one_file . '_OBJECTS',
1821 $one_file . '_OBJECTS', 'should not be defined');
1822 # No point in continuing.
1827 foreach my $prefix ('', 'EXTRA_', 'dist_', 'nodist_',
1828 'dist_EXTRA_', 'nodist_EXTRA_')
1830 my $var = $prefix . $one_file . "_SOURCES";
1832 if !variable_defined ($var);
1834 # We are going to define _OBJECTS variables using the prefix.
1835 # Then we glom them all together. So we can't use the null
1836 # prefix here as we need it later.
1837 my $xpfx = ($prefix eq '') ? 'am_' : $prefix;
1839 # Keep track of which prefixes we saw.
1840 $used_pfx{$xpfx} = 1
1841 unless $prefix =~ /EXTRA_/;
1843 push (@sources, '$(' . $prefix . $one_file . "_SOURCES)");
1844 push (@objects, '$(' . $xpfx . $one_file . "_OBJECTS)")
1845 unless $prefix =~ /EXTRA_/;
1846 push (@dist_sources, '$(' . $prefix . $one_file . "_SOURCES)")
1847 unless $prefix =~ /^nodist_/;
1848 foreach my $cond (variable_conditions ($var))
1850 my @files = &variable_value_as_list ($var, $cond);
1851 my ($temp, @result) =
1852 &handle_single_transform_list ($var, $one_file, $obj,
1854 # If there are no files to compile, don't require a linker (yet).
1858 # Define _OBJECTS conditionally.
1859 &define_pretty_variable ($xpfx . $one_file . '_OBJECTS',
1861 unless $prefix =~ /EXTRA_/;
1865 my @keys = sort keys %used_pfx;
1866 if (scalar @keys == 0)
1868 &define_variable ($one_file . "_SOURCES", $unxformed . ".c");
1869 push (@sources, $unxformed . '.c');
1870 push (@dist_sources, $unxformed . '.c');
1871 push (@objects, $unxformed . $obj);
1873 my ($temp, @result) =
1874 &handle_single_transform_list ($one_file . '_SOURCES',
1877 $linker = $temp if $linker eq '';
1878 &define_pretty_variable ($one_file . "_OBJECTS", '', @result)
1882 grep ($_ = '$(' . $_ . $one_file . '_OBJECTS)', @keys);
1883 &define_pretty_variable ($one_file . '_OBJECTS', '', @keys);
1886 # If we want to use `LINK' we must make sure it is defined.
1896 # handle_lib_objects ()
1897 # ---------------------
1898 # Special-case @ALLOCA@ and @LIBOBJS@ in _LDADD or _LIBADD variables.
1899 # Also, generate _DEPENDENCIES variable if appropriate.
1901 # transformed name of object being built, or empty string if no object
1902 # name of _LDADD/_LIBADD-type variable to examine
1903 # boolean (lex_seen) which is true if a lex source file was seen in this
1904 # object. valid only for LDADDs, not LIBADDs.
1905 # Returns 1 if LIBOBJS seen, 0 otherwise.
1906 sub handle_lib_objects
1908 my ($xname, $var, $lex_seen) = @_;
1911 &prog_error ("handle_lib_objects: $var undefined")
1912 if ! &variable_defined ($var);
1914 &prog_error ("handle_lib_objects: lex_seen and $var =~ /LIBADD/")
1915 if $lex_seen && $var =~ /LIBADD/;
1917 my @conds = &variable_conditions ($var);
1920 $ret = &handle_lib_objects_cond ($xname, $var, $lex_seen, '');
1925 foreach my $cond (@conds)
1927 if (&handle_lib_objects_cond ($xname, $var, $lex_seen, $cond))
1937 # Subroutine of handle_lib_objects: handle a particular condition.
1938 sub handle_lib_objects_cond
1940 my ($xname, $var, $lex_seen, $cond) = @_;
1942 # We recognize certain things that are commonly put in LIBADD or
1946 my $seen_libobjs = 0;
1949 foreach my $lsearch (&variable_value_as_list ($var, $cond))
1951 # Skip -lfoo and -Ldir; these are explicitly allowed.
1952 next if $lsearch =~ /^-[lL]/;
1953 if (! $flagvar && $lsearch =~ /^-/)
1955 if ($var =~ /^(.*)LDADD$/)
1957 # Skip -dlopen and -dlpreopen; these are explicitly allowed.
1958 next if $lsearch =~ /^-dl(pre)?open$/;
1959 &am_line_error ($var, "linker flags such as `$lsearch' belong in `${1}LDFLAGS");
1963 # Only get this error once.
1965 &am_line_error ($var, "linker flags such as `$lsearch' belong in `${1}LDFLAGS");
1969 # Assume we have a file of some sort, and push it onto the
1970 # dependency list. Autoconf substitutions are not pushed;
1971 # rarely is a new dependency substituted into (eg) foo_LDADD
1972 # -- but "bad things (eg -lX11) are routinely substituted.
1973 # Note that LIBOBJS and ALLOCA are exceptions to this rule,
1974 # and handled specially below.
1975 push (@dep_list, $lsearch)
1976 unless $lsearch =~ /^\@.*\@$/;
1978 # Automatically handle @LIBOBJS@ and @ALLOCA@. Basically this
1979 # means adding entries to dep_files.
1980 if ($lsearch =~ /^\@(LT)?LIBOBJS\@$/)
1982 my $myobjext = ($1 ? 'l' : '') . 'o';
1984 push (@dep_list, $lsearch);
1986 if (! keys %libsources
1987 && ! &variable_defined ($1 . 'LIBOBJS'))
1989 &am_line_error ($var, "\@$1" . "LIBOBJS\@ seen but never set in `$configure_ac'");
1992 foreach my $iter (keys %libsources)
1994 if ($iter =~ /\.([cly])$/)
1996 &saw_extension ($1);
1997 &saw_extension ('c');
2000 if ($iter =~ /\.h$/)
2002 &require_file_with_line ($var, $FOREIGN, $iter);
2004 elsif ($iter ne 'alloca.c')
2006 my $rewrite = $iter;
2007 $rewrite =~ s/\.c$/.P$myobjext/;
2008 $dep_files{'$(DEPDIR)/' . $rewrite} = 1;
2009 ($rewrite = $iter) =~ s/(\W)/\\$1/g;
2010 $rewrite = "^" . $rewrite . "\$";
2011 # Only require the file if it is not a built source.
2012 if (! &variable_defined ('BUILT_SOURCES')
2013 || ! grep (/$rewrite/,
2014 &variable_value_as_list ('BUILT_SOURCES',
2017 &require_file_with_line ($var, $FOREIGN, $iter);
2022 elsif ($lsearch =~ /^\@(LT)?ALLOCA\@$/)
2024 my $myobjext = ($1 ? 'l' : '') . 'o';
2026 push (@dep_list, $lsearch);
2027 &am_line_error ($var,
2028 "\@$1" . "ALLOCA\@ seen but `AC_FUNC_ALLOCA' not in `$configure_ac'")
2029 if ! defined $libsources{'alloca.c'};
2030 $dep_files{'$(DEPDIR)/alloca.P' . $myobjext} = 1;
2031 &require_file_with_line ($var, $FOREIGN, 'alloca.c');
2032 &saw_extension ('c');
2036 if ($xname ne '' && ! &variable_defined ($xname . '_DEPENDENCIES', $cond))
2038 &define_pretty_variable ($xname . '_DEPENDENCIES', $cond, @dep_list);
2041 return $seen_libobjs;
2044 # Canonicalize the input parameter
2048 $string =~ tr/A-Za-z0-9_\@/_/c;
2052 # Canonicalize a name, and check to make sure the non-canonical name
2053 # is never used. Returns canonical name. Arguments are name and a
2054 # list of suffixes to check for.
2055 sub check_canonical_spelling
2057 my ($name, @suffixes) = @_;
2059 my $xname = &canonicalize ($name);
2060 if ($xname ne $name)
2062 foreach my $xt (@suffixes)
2064 &am_line_error ($name . $xt,
2065 "invalid variable `" . $name . $xt
2066 . "'; should be `" . $xname . $xt . "'")
2067 if &variable_defined ($name . $xt);
2075 # handle_programs ()
2076 # ------------------
2077 # Handle C programs.
2080 my @proglist = &am_install_var ('progs', 'PROGRAMS',
2081 'bin', 'sbin', 'libexec', 'pkglib',
2083 return if ! @proglist;
2085 # If a program is installed, this is required. We only want this
2086 # error to appear once.
2087 &am_conf_error ("AC_ARG_PROGRAM must be used")
2088 unless $seen_arg_prog;
2091 my $seen_libobjs = 0;
2092 foreach my $one_file (@proglist)
2094 my $obj = &get_object_extension ($one_file);
2096 # Canonicalize names and check for misspellings.
2097 my $xname = &check_canonical_spelling ($one_file, '_LDADD', '_LDFLAGS',
2098 '_SOURCES', '_OBJECTS',
2101 # FIXME: Using a trick to figure out if any lex sources appear
2102 # in our program; should use some cleaner method.
2103 my $lex_num = scalar (keys %lex_sources);
2104 my $linker = &handle_source_transform ($xname, $one_file, $obj);
2105 my $lex_file_seen = (scalar (keys %lex_sources) > $lex_num);
2108 if (&variable_defined ($xname . "_LDADD"))
2110 if (&handle_lib_objects ($xname, $xname . '_LDADD',
2120 # User didn't define prog_LDADD override. So do it.
2121 &define_variable ($xname . '_LDADD', '$(LDADD)');
2123 # This does a bit too much work. But we need it to
2124 # generate _DEPENDENCIES when appropriate.
2125 if (&variable_defined ('LDADD'))
2127 if (&handle_lib_objects ($xname, 'LDADD', $lex_file_seen))
2133 elsif (! &variable_defined ($xname . '_DEPENDENCIES'))
2135 &define_variable ($xname . '_DEPENDENCIES', '');
2140 if (&variable_defined ($xname . '_LIBADD'))
2142 &am_line_error ($xname . '_LIBADD',
2143 "use `" . $xname . "_LDADD', not `"
2144 . $xname . "_LIBADD'");
2147 if (! &variable_defined ($xname . '_LDFLAGS'))
2149 # Define the prog_LDFLAGS variable.
2150 &define_variable ($xname . '_LDFLAGS', '');
2153 # Determine program to use for link.
2155 if (&variable_defined ($xname . '_LINK'))
2157 $xlink = $xname . '_LINK';
2161 $xlink = $linker ? $linker : 'LINK';
2164 $output_rules .= &file_contents ('program',
2165 ('PROGRAM' => $one_file,
2166 'XPROGRAM' => $xname,
2167 'XLINK' => $xlink));
2170 if (&variable_defined ('LDADD') && &handle_lib_objects ('', 'LDADD', 0))
2177 foreach my $one_file (@proglist)
2179 my $xname = &canonicalize ($one_file);
2181 if (&variable_defined ($xname . '_LDADD'))
2183 &check_libobjs_sources ($xname, $xname . '_LDADD');
2185 elsif (&variable_defined ('LDADD'))
2187 &check_libobjs_sources ($xname, 'LDADD');
2194 # handle_libraries ()
2195 # -------------------
2197 sub handle_libraries
2199 my @liblist = &am_install_var ('libs', 'LIBRARIES',
2200 'lib', 'pkglib', 'noinst', 'check');
2201 return if ! @liblist;
2203 my %valid = &am_primary_prefixes ('LIBRARIES', 0, 'lib', 'pkglib',
2205 if (! defined $configure_vars{'RANLIB'})
2207 foreach my $key (keys %valid)
2209 if (&variable_defined ($key . '_LIBRARIES'))
2211 &am_line_error ($key . '_LIBRARIES', "library used but `RANLIB' not defined in `$configure_ac'");
2212 # Only get this error once. If this is ever printed,
2214 $configure_vars{'RANLIB'} = 'BUG';
2220 my $seen_libobjs = 0;
2221 foreach my $onelib (@liblist)
2223 # Check that the library fits the standard naming convention.
2224 if ($onelib !~ /^lib.*\.a$/)
2226 # FIXME should put line number here. That means mapping
2227 # from library name back to variable name.
2228 &am_error ("`$onelib' is not a standard library name");
2231 my $obj = &get_object_extension ($onelib);
2233 # Canonicalize names and check for misspellings.
2234 my $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_SOURCES',
2235 '_OBJECTS', '_DEPENDENCIES',
2238 if (! &variable_defined ($xlib . '_AR'))
2240 &define_variable ($xlib . '_AR', '$(AR) cru');
2243 if (&variable_defined ($xlib . '_LIBADD'))
2245 if (&handle_lib_objects ($xlib, $xlib . '_LIBADD', 0))
2252 # Generate support for conditional object inclusion in
2254 &define_variable ($xlib . "_LIBADD", '');
2257 if (&variable_defined ($xlib . '_LDADD'))
2259 &am_line_error ($xlib . '_LDADD',
2260 "use `" . $xlib . "_LIBADD', not `"
2261 . $xlib . "_LDADD'");
2264 # Make sure we at look at this.
2265 &examine_variable ($xlib . '_DEPENDENCIES');
2267 &handle_source_transform ($xlib, $onelib, $obj);
2269 $output_rules .= &file_contents ('library',
2270 ('LIBRARY' => $onelib,
2271 'XLIBRARY' => $xlib));
2276 foreach my $onelib (@liblist)
2278 my $xlib = &canonicalize ($onelib);
2279 if (&variable_defined ($xlib . '_LIBADD'))
2281 &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
2286 &define_variable ('AR', 'ar');
2287 &define_configure_variable ('RANLIB');
2291 # handle_ltlibraries ()
2292 # ---------------------
2293 # Handle shared libraries.
2294 sub handle_ltlibraries
2296 my @liblist = &am_install_var ('ltlib', 'LTLIBRARIES',
2297 'noinst', 'lib', 'pkglib', 'check');
2298 return if ! @liblist;
2301 my %valid = &am_primary_prefixes ('LTLIBRARIES', 0, 'lib', 'pkglib',
2304 foreach my $key (keys %valid)
2306 if (&variable_defined ($key . '_LTLIBRARIES'))
2310 &am_line_error ($key . '_LTLIBRARIES', "library used but `LIBTOOL' not defined in `$configure_ac'");
2311 # Only get this error once. If this is ever printed,
2313 $configure_vars{'LIBTOOL'} = 'BUG';
2317 # Get the installation directory of each library.
2318 for (&variable_value_as_list ($key . '_LTLIBRARIES', 'all'))
2322 &am_error ("`$_' is already going to be installed in `$instdirs{$_}'");
2326 $instdirs{$_} = $key;
2332 my $seen_libobjs = 0;
2333 foreach my $onelib (@liblist)
2335 my $obj = &get_object_extension ($onelib);
2337 # Canonicalize names and check for misspellings.
2338 my $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_LDFLAGS',
2339 '_SOURCES', '_OBJECTS',
2342 if (! &variable_defined ($xlib . '_LDFLAGS'))
2344 # Define the lib_LDFLAGS variable.
2345 &define_variable ($xlib . '_LDFLAGS', '');
2348 # Check that the library fits the standard naming convention.
2349 my $libname_rx = "^lib.*\.la";
2350 if ((&variable_defined ($xlib . '_LDFLAGS')
2351 && grep (/-module/, &variable_value_as_list ($xlib . '_LDFLAGS',
2353 || (&variable_defined ('LDFLAGS')
2354 && grep (/-module/, &variable_value_as_list ('LDFLAGS',
2357 # Relax name checking for libtool modules.
2358 $libname_rx = "\.la";
2360 if ($onelib !~ /$libname_rx$/)
2362 # FIXME this should only be a warning for foreign packages
2363 # FIXME should put line number here. That means mapping
2364 # from library name back to variable name.
2365 &am_error ("`$onelib' is not a standard libtool library name");
2368 if (&variable_defined ($xlib . '_LIBADD'))
2370 if (&handle_lib_objects ($xlib, $xlib . '_LIBADD', 0))
2377 # Generate support for conditional object inclusion in
2379 &define_variable ($xlib . "_LIBADD", '');
2382 if (&variable_defined ($xlib . '_LDADD'))
2384 &am_line_error ($xlib . '_LDADD',
2385 "use `" . $xlib . "_LIBADD', not `"
2386 . $xlib . "_LDADD'");
2389 # Make sure we at look at this.
2390 &examine_variable ($xlib . '_DEPENDENCIES');
2392 my $linker = &handle_source_transform ($xlib, $onelib, $obj);
2394 # Determine program to use for link.
2396 if (&variable_defined ($xlib . '_LINK'))
2398 $xlink = $xlib . '_LINK';
2402 $xlink = $linker ? $linker : 'LINK';
2406 if ($instdirs{$onelib} eq 'EXTRA'
2407 || $instdirs{$onelib} eq 'noinst'
2408 || $instdirs{$onelib} eq 'check')
2410 # It's an EXTRA_ library, so we can't specify -rpath,
2411 # because we don't know where the library will end up.
2412 # The user probably knows, but generally speaking automake
2413 # doesn't -- and in fact configure could decide
2414 # dynamically between two different locations.
2419 $rpath = ('-rpath $(' . $instdirs{$onelib} . 'dir)');
2422 $output_rules .= &file_contents ('ltlibrary',
2423 ('LTLIBRARY' => $onelib,
2424 'XLTLIBRARY' => $xlib,
2426 'XLINK' => $xlink));
2431 foreach my $onelib (@liblist)
2433 my $xlib = &canonicalize ($onelib);
2434 if (&variable_defined ($xlib . '_LIBADD'))
2436 &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
2442 # See if any _SOURCES variable were misspelled. Also, make sure that
2443 # EXTRA_ variables don't contain configure substitutions.
2446 foreach my $varname (keys %conditional)
2448 foreach my $primary ('_SOURCES', '_LIBADD', '_LDADD', '_LDFLAGS',
2451 if ($varname =~ /$primary$/ && ! $content_seen{$varname})
2453 &am_line_error ($varname,
2454 "invalid unused variable name: `$varname'");
2463 # NOTE we no longer automatically clean SCRIPTS, because it is
2464 # useful to sometimes distribute scripts verbatim. This happens
2465 # eg in Automake itself.
2466 &am_install_var ('-candist', 'scripts', 'SCRIPTS',
2467 'bin', 'sbin', 'libexec', 'pkgdata',
2470 my $scripts_installed = 0;
2471 # Set $scripts_installed if appropriate. Make sure we only find
2472 # scripts which are actually installed -- this is why we can't
2473 # simply use the return value of am_install_var.
2474 my %valid = &am_primary_prefixes ('SCRIPTS', 1, 'bin', 'sbin',
2475 'libexec', 'pkgdata',
2477 foreach my $key (keys %valid)
2479 if ($key ne 'noinst'
2481 && &variable_defined ($key . '_SCRIPTS'))
2483 $scripts_installed = 1;
2484 # push (@check_tests, 'check-' . $key . 'SCRIPTS');
2488 if ($scripts_installed)
2490 # If a program is installed, this is required. We only want this
2491 # error to appear once.
2492 &am_conf_error ("AC_ARG_PROGRAM must be used")
2493 unless $seen_arg_prog;
2499 # ($OUTFILE, $VFILE, @CLEAN_FILES)
2500 # &scan_texinfo_file ($FILENAME)
2501 # ------------------------------
2502 # $OUTFILE is the name of the info file produced by $FILENAME.
2503 # $VFILE is the name of the version.texi file used (empty if none).
2504 # @CLEAN_FILES is the list of by products (indexes etc.)
2505 sub scan_texinfo_file
2507 my ($filename) = @_;
2508 my @clean_suffixes = ('aux', 'dvi', 'log', 'ps', 'toc',
2509 # grep new.*index texinfo.tex
2510 'cp', 'fn', 'ky', 'vr', 'tp', 'pg');
2512 my $texi = new IO::File ("< $filename");
2515 &am_error ("couldn't open `$filename': $!");
2518 print "$me: reading $filename\n" if $verbose;
2520 my ($outfile, $vfile);
2521 while ($_ = $texi->getline)
2523 if (/^\@setfilename +(\S+)/)
2526 if ($outfile =~ /\.(.+)$/ && $1 ne 'info')
2528 &am_file_error ($filename, "$.: ",
2529 "output `$outfile' has unrecognized extension");
2533 # A "version.texi" file is actually any file whose name
2534 # matches "vers*.texi".
2535 elsif (/^\@include\s+(vers[^.]*\.texi)\s*$/)
2539 elsif (/^\@defcodeindex (\w*)/)
2541 push @clean_suffixes, $1;
2543 elsif (/^\@syncodeindex \w+ (\w*)/)
2545 push @clean_suffixes, "$1s";
2552 &am_error ("`$filename' missing \@setfilename");
2556 my $infobase = basename ($filename);
2557 $infobase =~ s/\.te?xi(nfo)?$//;
2559 grep { $clean_files{"$infobase.$_"} = 1 } @clean_suffixes;
2560 return ($outfile, $vfile, (sort keys %clean_files));
2566 # Handle all Texinfo source.
2569 &am_line_error ('TEXINFOS',
2570 "`TEXINFOS' is an anachronism; use `info_TEXINFOS'")
2571 if &variable_defined ('TEXINFOS');
2572 return if (! &variable_defined ('info_TEXINFOS')
2573 && ! &variable_defined ('html_TEXINFOS'));
2575 if (&variable_defined ('html_TEXINFOS'))
2577 &am_line_error ('html_TEXINFOS',
2578 "HTML generation not yet supported");
2582 my @texis = &variable_value_as_list ('info_TEXINFOS', 'all');
2584 my (@info_deps_list, @dvis_list, @texi_deps);
2591 foreach my $info_cursor (@texis)
2593 my $infobase = $info_cursor;
2594 $infobase =~ s/\.(txi|texinfo|texi)$//;
2596 if ($infobase eq $info_cursor)
2598 # FIXME: report line number.
2599 &am_error ("texinfo file `$info_cursor' has unrecognized extension");
2602 $texi_suffixes{$1} = 1;
2604 # If 'version.texi' is referenced by input file, then include
2605 # automatic versioning capability.
2606 my ($out_file, $vtexi, @clean_files) =
2607 &scan_texinfo_file ("$relative_dir/$info_cursor")
2609 push (@texi_cleans, @clean_files);
2613 &am_error ("`$vtexi', included in `$info_cursor', also included in `$versions{$vtexi}'")
2614 if (defined $versions{$vtexi});
2615 $versions{$vtexi} = $info_cursor;
2617 # We number the stamp-vti files. This is doable since the
2618 # actual names don't matter much. We only number starting
2619 # with the second one, so that the common case looks nice.
2620 my $vti = ($done ? $done : 'vti');
2623 &require_conf_file_with_line ('info_TEXINFOS', $FOREIGN,
2627 if ($config_aux_dir eq '.' || $config_aux_dir eq '')
2629 $conf_dir = '$(srcdir)/';
2633 $conf_dir = $config_aux_dir;
2634 $conf_dir .= '/' unless $conf_dir =~ /\/$/;
2636 $output_rules .= &file_contents ('texi-vers',
2637 ('TEXI' => $info_cursor,
2640 'MDDIR' => $conf_dir));
2643 # If user specified file_TEXINFOS, then use that as explicit
2646 push (@texi_deps, $info_cursor);
2647 # Prefix with $(srcdir) because some version of make won't
2648 # work if the target has it and the dependency doesn't.
2649 push (@texi_deps, '$(srcdir)/' . $vtexi) if $vtexi;
2651 my $canonical = &canonicalize ($infobase);
2652 if (&variable_defined ($canonical . "_TEXINFOS"))
2654 push (@texi_deps, '$(' . $canonical . '_TEXINFOS)');
2655 &push_dist_common ('$(' . $canonical . '_TEXINFOS)');
2658 $output_rules .= ("\n" . $out_file . ": "
2659 . join (' ', @texi_deps)
2660 . "\n" . $infobase . ".dvi: "
2661 . join (' ', @texi_deps)
2664 push (@info_deps_list, $out_file);
2665 push (@dvis_list, $infobase . '.dvi');
2668 # Find these programs wherever they may lie. Yes, this has
2669 # intimate knowledge of the structure of the texinfo distribution.
2670 &define_program_variable ('MAKEINFO', 'build', 'texinfo/makeinfo',
2672 # Circumlocution to avoid accidental
2673 # configure substitution.
2675 &define_program_variable ('TEXI2DVI', 'src', 'texinfo/util',
2678 # Handle location of texinfo.tex.
2679 my $need_texi_file = 0;
2683 $texinfodir = '$(top_srcdir)/../texinfo';
2684 &define_variable ('TEXINFO_TEX', "$texinfodir/texinfo.tex");
2687 elsif ($config_aux_dir ne '.' && $config_aux_dir ne '')
2689 $texinfodir = $config_aux_dir;
2690 &define_variable ('TEXINFO_TEX', "$texinfodir/texinfo.tex");
2691 $need_texi_file = 2; # so that we require_conf_file later
2693 elsif (&variable_defined ('TEXINFO_TEX'))
2695 # The user defined TEXINFO_TEX so assume he knows what he is
2697 $texinfodir = ('$(srcdir)/'
2698 . dirname (&variable_value ('TEXINFO_TEX')));
2702 $texinfodir = '$(srcdir)';
2703 $need_texi_file = 1;
2706 foreach my $txsfx (sort keys %texi_suffixes)
2708 $output_rules .= &file_contents ('texibuild',
2709 ('TEXINFODIR' => $texinfodir,
2710 'SUFFIX' => $txsfx));
2713 my $texiclean = &pretty_print_internal ("", "\t ", @texi_cleans);
2714 $output_rules .= &file_contents ('texinfos',
2715 ('TEXICLEAN' => $texiclean));
2717 push (@dist_targets, 'dist-info');
2718 push (@suffixes, '.texi', '.texinfo', '.txi', '.info', '.dvi', '.ps');
2720 if (! defined $options{'no-installinfo'})
2722 # Make sure documentation is made and installed first. Use
2723 # $(INFO_DEPS), not 'info', because otherwise recursive makes
2724 # get run twice during "make all".
2725 unshift (@all, '$(INFO_DEPS)');
2728 &define_variable ("INFO_DEPS", join (' ', @info_deps_list));
2729 &define_variable ("DVIS", join (' ', @dvis_list));
2730 # This next isn't strictly needed now -- the places that look here
2731 # could easily be changed to look in info_TEXINFOS. But this is
2732 # probably better, in case noinst_TEXINFOS is ever supported.
2733 &define_variable ("TEXINFOS", &variable_value ('info_TEXINFOS'));
2735 # Do some error checking. Note that this file is not required
2736 # when in Cygnus mode; instead we defined TEXINFO_TEX explicitly
2738 if ($need_texi_file && ! defined $options{'no-texinfo.tex'})
2740 if ($need_texi_file > 1)
2742 &require_conf_file_with_line ('info_TEXINFOS', $FOREIGN,
2747 &require_file_with_line ('info_TEXINFOS', $FOREIGN, 'texinfo.tex');
2752 # Handle any man pages.
2753 sub handle_man_pages
2755 &am_line_error ('MANS', "`MANS' is an anachronism; use `man_MANS'")
2756 if &variable_defined ('MANS');
2758 # Find all the sections in use. We do this by first looking for
2759 # "standard" sections, and then looking for any additional
2760 # sections used in man_MANS.
2761 my (%sections, %vlist);
2762 # Add more sections as needed.
2763 foreach my $sect ('0'..'9', 'n', 'l')
2765 if (&variable_defined ('man' . $sect . '_MANS'))
2767 $sections{$sect} = 1;
2768 $vlist{'$(man' . $sect . '_MANS)'} = 1;
2772 if (&variable_defined ('man_MANS'))
2774 $vlist{'$(man_MANS)'} = 1;
2775 foreach (&variable_value_as_list ('man_MANS', 'all'))
2777 # A page like `foo.1c' goes into man1dir.
2778 if (/\.([0-9a-z])([a-z]*)$/)
2785 return unless %sections;
2787 # Now for each section, generate an install and unintall rule.
2788 # Sort sections so output is deterministic.
2789 foreach my $sect (sort keys %sections)
2791 &define_variable ('man' . $sect . 'dir', '$(mandir)/man' . $sect);
2792 $output_rules .= &file_contents ('mans',
2793 ('SECTION', $sect));
2796 # We don't really need this, but we use it in case we ever want to
2797 # support noinst_MANS.
2798 &define_variable ("MANS", join (' ', sort keys %vlist));
2800 $output_vars .= &file_contents ('mans-vars');
2802 if (! defined $options{'no-installman'})
2804 push (@all, '$(MANS)');
2808 # Handle DATA variables.
2811 &am_install_var ('-noextra', '-candist', 'data', 'DATA',
2812 'data', 'sysconf', 'sharedstate', 'localstate',
2813 'pkgdata', 'noinst', 'check');
2820 if (&variable_defined ('SUBDIRS'))
2822 $output_rules .= ("tags-recursive:\n"
2823 . "\tlist=\'\$(SUBDIRS)\'; for subdir in \$\$list; do \\\n"
2824 # Never fail here if a subdir fails; it
2826 . "\t test \"\$\$subdir\" = . || (cd \$\$subdir"
2827 . " && \$(MAKE) \$(AM_MAKEFLAGS) tags); \\\n"
2829 push (@tag_deps, 'tags-recursive');
2830 &depend ('.PHONY', 'tags-recursive');
2833 if (&saw_sources_p (1)
2834 || &variable_defined ('ETAGS_ARGS')
2838 foreach my $one_hdr (@config_headers)
2840 if ($relative_dir eq dirname ($one_hdr))
2842 # The config header is in this directory. So require it.
2843 $config .= ' ' if $config;
2844 $config .= basename ($one_hdr);
2847 $output_rules .= &file_contents ('tags',
2848 ('CONFIG' => $config,
2849 'DIRS' => join (' ', @tag_deps)));
2850 &examine_variable ('TAGS_DEPENDENCIES');
2852 elsif (&variable_defined ('TAGS_DEPENDENCIES'))
2854 &am_line_error ('TAGS_DEPENDENCIES',
2855 "doesn't make sense to define `TAGS_DEPENDENCIES' without sources or `ETAGS_ARGS'");
2859 # Every Makefile must define some sort of TAGS rule.
2860 # Otherwise, it would be possible for a top-level "make TAGS"
2861 # to fail because some subdirectory failed.
2862 $output_rules .= "tags: TAGS\nTAGS:\n\n";
2866 # Handle multilib support.
2869 return unless $seen_multilib;
2871 $output_rules .= &file_contents ('multilib');
2876 # &for_dist_common ($A, $B)
2877 # -------------------------
2878 # Subroutine for &handle_dist: sort files to dist.
2880 # We put README first because it then becomes easier to make a
2881 # Usenet-compliant shar file (in these, README must be first).
2883 # FIXME: do more ordering of files here.
2896 # handle_dist ($MAKEFILE)
2897 # -----------------------
2898 # Handle 'dist' target.
2901 my ($makefile) = @_;
2903 # `make dist' isn't used in a Cygnus-style tree.
2904 # Omit the rules so that people don't try to use them.
2905 return if $cygnus_mode;
2907 # Set up maint_charset.
2908 $local_maint_charset = &variable_value ('MAINT_CHARSET')
2909 if &variable_defined ('MAINT_CHARSET');
2910 $maint_charset = $local_maint_charset
2911 if $relative_dir eq '.';
2913 if (&variable_defined ('DIST_CHARSET'))
2915 &am_line_error ('DIST_CHARSET',
2916 "DIST_CHARSET defined but no MAINT_CHARSET defined")
2917 if ! $local_maint_charset;
2918 if ($relative_dir eq '.')
2920 $dist_charset = &variable_value ('DIST_CHARSET')
2924 &am_line_error ('DIST_CHARSET',
2925 "DIST_CHARSET can only be defined at top level");
2929 # Look for common files that should be included in distribution.
2930 foreach my $cfile (@common_files)
2932 if (-f ($relative_dir . "/" . $cfile))
2934 &push_dist_common ($cfile);
2938 # We might copy elements from $configure_dist_common to
2939 # %dist_common if we think we need to. If the file appears in our
2940 # directory, we would have discovered it already, so we don't
2941 # check that. But if the file is in a subdir without a Makefile,
2942 # we want to distribute it here if we are doing `.'. Ugly!
2943 if ($relative_dir eq '.')
2945 foreach my $file (split (' ' , $configure_dist_common))
2947 if (! &is_make_dir (dirname ($file)))
2949 &push_dist_common ($file);
2956 # Files to distributed. Don't use &variable_value_as_list
2957 # as it recursively expands `$(dist_pkgdata_DATA)' etc.
2958 check_variable_defined_unconditionally ('DIST_COMMON');
2959 my @dist_common = split (' ', variable_value ('DIST_COMMON', 'TRUE'));
2960 @dist_common = uniq (sort for_dist_common (@dist_common));
2961 pretty_print ('DIST_COMMON = ', "\t", @dist_common);
2963 # Now that we've processed DIST_COMMON, disallow further attempts
2965 $handle_dist_run = 1;
2967 # Scan EXTRA_DIST to see if we need to distribute anything from a
2968 # subdir. If so, add it to the list. I didn't want to do this
2969 # originally, but there were so many requests that I finally
2971 if (&variable_defined ('EXTRA_DIST'))
2973 # FIXME: This should be fixed to work with conditionals. That
2974 # will require only making the entries in %dist_dirs under the
2975 # appropriate condition. This is meaningful if the nature of
2976 # the distribution should depend upon the configure options
2978 foreach (&variable_value_as_list ('EXTRA_DIST', ''))
2981 next unless s,/+[^/]+$,,;
2987 # We have to check DIST_COMMON for extra directories in case the
2988 # user put a source used in AC_OUTPUT into a subdir.
2989 foreach (&variable_value_as_list ('DIST_COMMON', 'all'))
2992 next unless s,/+[^/]+$,,;
2997 # Rule to check whether a distribution is viable.
2998 my %transform = ('DISTCHECK-HOOK' => &target_defined ('distcheck-hook'),
2999 'GETTEXT' => $seen_gettext);
3001 # Prepend $(distdir) to each directory given.
3003 grep ($rewritten{'$(distdir)/' . $_} = 1, keys %dist_dirs);
3004 $transform{'DISTDIRS'} = join (' ', sort keys %rewritten);
3006 # If we have SUBDIRS, create all dist subdirectories and do
3008 if (&variable_defined ('SUBDIRS'))
3010 # If SUBDIRS is conditionally defined, then set DIST_SUBDIRS
3011 # to all possible directories, and use it. If DIST_SUBDIRS is
3012 # defined, just use it.
3013 my $dist_subdir_name;
3014 if (variable_conditionally_defined ('SUBDIRS')
3015 || &variable_defined ('DIST_SUBDIRS'))
3017 $dist_subdir_name = 'DIST_SUBDIRS';
3018 if (! &variable_defined ('DIST_SUBDIRS'))
3020 &define_pretty_variable
3021 ('DIST_SUBDIRS', '',
3022 uniq (&variable_value_as_list ('SUBDIRS', 'all')));
3027 $dist_subdir_name = 'SUBDIRS';
3028 # We always define this because that is what `distclean'
3030 &define_pretty_variable ('DIST_SUBDIRS', '', '$(SUBDIRS)');
3033 $transform{'DIST_SUBDIR_NAME'} = $dist_subdir_name;
3036 # If the target `dist-hook' exists, make sure it is run. This
3037 # allows users to do random weird things to the distribution
3038 # before it is packaged up.
3039 push (@dist_targets, 'dist-hook')
3040 if &target_defined ('dist-hook');
3041 $transform{'DIST-TARGETS'} = join(' ', @dist_targets);
3043 # Defining $(DISTDIR).
3044 $transform{'DISTDIR'} = !&variable_defined('distdir');
3045 $transform{'TOP_DISTDIR'} = backname ($relative_dir);
3047 $output_rules .= &file_contents ('distdir', %transform);
3051 # add_depend2 ($LANG)
3052 # -------------------
3053 # A subroutine of handle_dependencies. This function includes
3054 # `depend2' with appropriate transformations.
3059 # Get information on $LANG.
3060 my $pfx = $language_map{"$lang-autodep"};
3061 my $fpfx = ($pfx eq '') ? 'CC' : $pfx;
3062 my $flag = $language_map{"$lang-flags"} || '';
3064 # First include code for ordinary objects.
3065 my %transform = ('PFX' => $pfx,
3067 'LIBTOOL' => $seen_libtool,
3068 'AMDEP' => $use_dependencies);
3070 # This function can be called even when we don't want dependency
3071 # tracking. This happens when we need an explicit rule for some
3072 # target. In this case we don't want to include the generic code.
3073 if ($use_dependencies)
3075 my $compile = '$(' . $pfx . 'COMPILE)';
3076 my $ltcompile = '$(LT' . $pfx . 'COMPILE)';
3077 my %transform = (%transform,
3084 'COMPILE' => $compile,
3085 'LTCOMPILE' => $ltcompile);
3087 foreach my $ext (&lang_extensions ($lang))
3089 $output_rules .= (&file_contents ('depend2',
3096 # Now include code for each specially handled object with this
3098 my %seen_files = ();
3099 foreach my $file (@{$lang_specific_files{$lang}})
3101 my ($derived, $source, $obj) = split (' ', $file);
3103 # We might see a given object twice, for instance if it is
3104 # used under different conditions.
3105 next if defined $seen_files{$obj};
3106 $seen_files{$obj} = 1;
3108 my $val = "${derived}_${flag}";
3110 my $obj_compile = $language_map{"$lang-compile"};
3111 $obj_compile =~ s/\(AM_$flag/\($val/;
3112 my $obj_ltcompile = '$(LIBTOOL) --mode=compile ' . $obj_compile;
3114 # Generate a transform which will turn suffix targets in
3115 # depend2.am into real targets for the particular objects we
3117 $output_rules .= &file_contents ('depend2',
3121 'SOURCE' => $source,
3123 'OBJOBJ' => "$obj.obj",
3124 'LTOBJ' => "$obj.lo",
3125 'COMPILE' => $obj_compile,
3126 'LTCOMPILE' => $obj_ltcompile))
3130 # Handle auto-dependency code.
3131 sub handle_dependencies
3133 if ($use_dependencies)
3135 # Include auto-dep code. Don't include it if DEP_FILES would
3137 if (&saw_sources_p (0) && keys %dep_files)
3139 my $config_aux_dir_specified = ($config_aux_dir ne '.'
3140 && $config_aux_dir ne '');
3142 # Set $require_file_found{'depcomp'} if the depcomp file exists,
3143 # before calling require_config_file on `depcomp'. This makes
3144 # require_file_internal skip its buggy existence test that would
3145 # make automake fail (with `required file `lib/depcomp' not found')
3146 # when AC_CONFIG_AUX_DIR is not set. See tests/subdir4.test.
3147 my $depcomp_dir = ($config_aux_dir_specified ? $config_aux_dir
3149 $require_file_found{'depcomp'} = 1 if -f "$depcomp_dir/depcomp";
3151 # Set location of depcomp.
3152 my $prefix = ($config_aux_dir_specified ? $config_aux_dir
3155 &define_variable ('depcomp', "\$(SHELL) $prefix/depcomp");
3157 &require_config_file ($FOREIGN, 'depcomp');
3159 my @deplist = sort keys %dep_files;
3161 # We define this as a conditional variable because BSD
3162 # make can't handle backslashes for continuing comments on
3163 # the following line.
3164 &define_pretty_variable ('DEP_FILES', 'AMDEP', @deplist);
3166 # Generate each `include' individually. Irix 6 make will
3167 # not properly include several files resulting from a
3168 # variable expansion; generating many separate includes
3170 $output_rules .= "\n";
3171 foreach my $iter (@deplist)
3173 $output_rules .= "\@AMDEP\@\@_am_include\@ " . $iter . "\n";
3176 $output_rules .= &file_contents ('depend');
3181 &define_variable ('depcomp', '');
3184 foreach my $key (sort keys %language_map)
3186 next unless $key =~ /^(.*)-autodep$/;
3187 next if $language_map{$key} eq 'no';
3192 # Handle subdirectories.
3196 unless &variable_defined ('SUBDIRS');
3198 # Make sure each directory mentioned in SUBDIRS actually exists.
3199 foreach my $dir (&variable_value_as_list ('SUBDIRS', 'all'))
3201 # Skip directories substituted by configure.
3202 next if $dir =~ /^\@.*\@$/;
3204 if (! -d $am_relative_dir . '/' . $dir)
3206 &am_line_error ('SUBDIRS',
3207 "required directory $am_relative_dir/$dir does not exist");
3211 &am_line_error ('SUBDIRS', "directory should not contain `/'")
3215 $output_rules .= &file_contents ('subdirs');
3222 # If aclocal.m4 creation is automated, return the list of its dependencies.
3225 my $regen_aclocal = 0;
3226 if (-f 'aclocal.m4')
3228 &define_variable ("ACLOCAL_M4", '$(top_srcdir)/aclocal.m4');
3229 &push_dist_common ('aclocal.m4');
3231 my $aclocal = new IO::File ("< aclocal.m4");
3234 my $line = $aclocal->getline;
3237 if ($line =~ 'generated automatically by aclocal')
3245 if (-f 'acinclude.m4')
3252 unless $regen_aclocal;
3254 # Note that it might be possible that aclocal.m4 doesn't exist but
3255 # should be auto-generated. This case probably isn't very
3257 my @ac_deps = ($acinclude ? ' acinclude.m4' : '');
3259 if (&variable_defined ('ACLOCAL_M4_SOURCES'))
3261 push (@ac_deps, '$(ACLOCAL_M4_SOURCES)');
3263 elsif (&variable_defined ('ACLOCAL_AMFLAGS'))
3265 # Scan all -I directories for m4 files. These are our
3267 my $examine_next = 0;
3268 foreach my $amdir (&variable_value_as_list ('ACLOCAL_AMFLAGS', ''))
3273 if ($amdir !~ /^\// && -d $amdir)
3275 foreach my $ac_dep (&my_glob ($amdir . '/*.m4'))
3277 $ac_dep =~ s/^\.\/+//;
3278 push (@ac_deps, $ac_dep)
3279 unless $ac_dep eq "aclocal.m4"
3280 || $ac_dep eq "acinclude.m4";
3284 elsif ($amdir eq '-I')
3293 # Rewrite a list of input files into a form suitable to put on a
3294 # dependency list. The idea is that if an input file has a directory
3295 # part the same as the current directory, then the directory part is
3296 # simply removed. But if the directory part is different, then
3297 # $(top_srcdir) is prepended. Among other things, this is used to
3298 # generate the dependency list for the output files generated by
3299 # AC_OUTPUT. Consider what the dependencies should look like in this
3301 # AC_OUTPUT(src/out:src/in1:lib/in2)
3302 # The first argument, ADD_SRCDIR, is 1 if $(top_srcdir) should be added.
3303 # If 0 then files that require this addition will simply be ignored.
3304 sub rewrite_inputs_into_dependencies
3306 my ($add_srcdir, @inputs) = @_;
3309 foreach my $single (@inputs)
3311 if (dirname ($single) eq $relative_dir)
3313 push (@newinputs, basename ($single));
3317 push (@newinputs, '$(top_srcdir)/' . $single);
3324 # Handle remaking and configure stuff.
3325 # We need the name of the input file, to do proper remaking rules.
3326 sub handle_configure
3328 my ($local, $input, @secondary_inputs) = @_;
3330 my $input_base = basename ($input);
3331 my $local_base = basename ($local);
3333 my $amfile = $input_base . '.am';
3334 # We know we can always add '.in' because it really should be an
3335 # error if the .in was missing originally.
3336 my $infile = '$(srcdir)/' . $input_base . '.in';
3337 my $colon_infile = '';
3338 if ($local ne $input || @secondary_inputs)
3340 $colon_infile = ':' . $input . '.in';
3342 $colon_infile .= ':' . join (':', @secondary_inputs)
3343 if @secondary_inputs;
3345 my @rewritten = &rewrite_inputs_into_dependencies (1, @secondary_inputs);
3347 my @aclocal_m4_deps;
3348 if ($relative_dir eq '.')
3350 @aclocal_m4_deps = &scan_aclocal_m4 ();
3351 &examine_variable ('CONFIG_STATUS_DEPENDENCIES');
3352 &examine_variable ('CONFIGURE_DEPENDENCIES');
3357 &file_contents ('configure',
3361 => join (' ', @rewritten),
3363 => ((($relative_dir eq '.') ? '$@' : '$(subdir)/$@')
3368 => join (' ', @include_stack),
3372 => $cygnus_mode ? 'cygnus' : $strictness_name,
3374 => $cmdline_use_dependencies ? '' : ' --ignore-deps',
3375 'MAKEFILE-AM-SOURCES'
3376 => "$input$colon_infile",
3378 => join (' ', @aclocal_m4_deps)));
3380 if ($relative_dir eq '.')
3382 &push_dist_common ('acconfig.h')
3386 # If we have a configure header, require it.
3387 my @local_fullnames = @config_fullnames;
3388 my @local_names = @config_names;
3390 my $distclean_config = '';
3391 foreach my $one_hdr (@config_headers)
3393 my $one_fullname = shift (@local_fullnames);
3394 my $one_name = shift (@local_names);
3396 my $header_dir = dirname ($one_name);
3398 # If the header is in the current directory we want to build
3399 # the header here. Otherwise, if we're at the topmost
3400 # directory and the header's directory doesn't have a
3401 # Makefile, then we also want to build the header.
3402 if ($relative_dir eq $header_dir
3403 || ($relative_dir eq '.' && ! &is_make_dir ($header_dir)))
3405 my ($cn_sans_dir, $stamp_dir);
3406 if ($relative_dir eq $header_dir)
3408 $cn_sans_dir = basename ($one_name);
3413 $cn_sans_dir = $one_name;
3414 if ($header_dir eq '.')
3420 $stamp_dir = $header_dir . '/';
3424 # Compute relative path from directory holding output
3425 # header to directory holding input header. FIXME:
3426 # doesn't handle case where we have multiple inputs.
3428 if (dirname ($one_hdr) eq $relative_dir)
3430 $ch_sans_dir = basename ($one_hdr);
3434 $ch_sans_dir = backname ($relative_dir) . '/' . $one_hdr;
3437 &require_file_with_conf_line ($config_header_line,
3438 $FOREIGN, $ch_sans_dir);
3440 # Header defined and in this directory.
3442 if (-f $one_name . '.top')
3444 push (@files, "${cn_sans_dir}.top");
3446 if (-f $one_name . '.bot')
3448 push (@files, "${cn_sans_dir}.bot");
3451 &push_dist_common (@files);
3453 # For now, acconfig.h can only appear in the top srcdir.
3454 if (-f 'acconfig.h')
3456 if ($relative_dir eq '.')
3458 push (@files, 'acconfig.h');
3462 push (@files, '$(top_srcdir)/acconfig.h');
3466 my $stamp_name = 'stamp-h';
3467 $stamp_name .= "${hdr_index}" if scalar (@config_headers) > 1;
3469 my $out_dir = dirname ($ch_sans_dir);
3472 &file_contents ('remake-hdr',
3473 ('FILES' => join (' ', @files),
3474 'CONFIG_HEADER' => $cn_sans_dir,
3475 'CONFIG_HEADER_IN' => $ch_sans_dir,
3476 'CONFIG_HEADER_FULL' => $one_fullname,
3477 'STAMP' => "$stamp_dir$stamp_name",
3478 'SRC_STAMP' => "$out_dir/$stamp_name"));
3480 &create ("${relative_dir}/${out_dir}/${stamp_name}.in");
3481 &require_file_with_conf_line ($config_header_line, $FOREIGN,
3482 "${out_dir}/${stamp_name}.in");
3484 $distclean_config .= ' ' if $distclean_config;
3485 $distclean_config .= $cn_sans_dir;
3489 if ($distclean_config)
3491 $output_rules .= &file_contents ('clean-hdr',
3492 ('FILES' => $distclean_config));
3495 # Set location of mkinstalldirs.
3496 if ($config_aux_dir ne '.' && $config_aux_dir ne '')
3498 &define_variable ('mkinstalldirs', ('$(SHELL) ' . $config_aux_dir
3499 . '/mkinstalldirs'));
3503 &define_variable ('mkinstalldirs',
3504 '$(SHELL) $(top_srcdir)/mkinstalldirs');
3507 &am_line_error ('CONFIG_HEADER',
3508 "`CONFIG_HEADER' is an anachronism; now determined from `$configure_ac'")
3509 if &variable_defined ('CONFIG_HEADER');
3511 my $config_header = '';
3512 foreach my $one_name (@config_names)
3514 # Generate CONFIG_HEADER define.
3516 if ($relative_dir eq dirname ($one_name))
3518 $one_hdr = basename ($one_name);
3522 $one_hdr = "\$(top_builddir)/${one_name}";
3525 $config_header .= ' ' if $config_header;
3526 $config_header .= $one_hdr;
3530 &define_variable ("CONFIG_HEADER", $config_header);
3533 # Now look for other files in this directory which must be remade
3534 # by config.status, and generate rules for them.
3535 my @actual_other_files = ();
3536 foreach my $lfile (@other_input_files)
3539 my (@inputs, @rewritten_inputs);
3540 my ($need_rewritten);
3541 if ($lfile =~ /^([^:]*):(.*)$/)
3543 # This is the ":" syntax of AC_OUTPUT.
3545 $local = basename ($file);
3546 @inputs = split (':', $2);
3547 @rewritten_inputs = &rewrite_inputs_into_dependencies (1, @inputs);
3548 $need_rewritten = 1;
3554 $local = basename ($file);
3555 @inputs = ($file . '.in');
3557 &rewrite_inputs_into_dependencies (1, @inputs);
3558 $need_rewritten = 0;
3561 # Make sure the dist directory for each input file is created.
3562 # We only have to do this at the topmost level though. This
3563 # is a bit ugly but it easier than spreading out the logic,
3564 # especially in cases like AC_OUTPUT(foo/out:bar/in), where
3565 # there is no Makefile in bar/.
3566 if ($relative_dir eq '.')
3570 $dist_dirs{dirname ($_)} = 1;
3574 # We skip any automake input files, as they are handled
3575 # elsewhere. We also skip files that aren't in this
3576 # directory. However, if the file's directory does not have a
3577 # Makefile, and we are currently doing `.', then we create a
3578 # rule to rebuild the file in the subdir.
3579 next if -f $file . '.am';
3580 my $fd = dirname ($file);
3581 if ($fd ne $relative_dir)
3583 if ($relative_dir eq '.' && ! &is_make_dir ($fd))
3593 # Some users have been tempted to put `stamp-h' in the
3594 # AC_OUTPUT line. This won't do the right thing, so we
3595 # explicitly fail here.
3596 if ($local eq 'stamp-h')
3598 # FIXME: allow real filename.
3599 &am_conf_error ($configure_ac, $ac_output_line,
3600 'stamp-h should not appear in AC_OUTPUT');
3604 $output_rules .= ($local . ': '
3605 . '$(top_builddir)/config.status '
3606 . join (' ', @rewritten_inputs) . "\n"
3608 . 'cd $(top_builddir) && CONFIG_FILES='
3609 . ($relative_dir eq '.' ? '' : '$(subdir)/')
3610 . '$@' . ($need_rewritten
3611 ? (':' . join (':', @inputs))
3613 . ' CONFIG_HEADERS= CONFIG_LINKS= $(SHELL) ./config.status'
3615 push (@actual_other_files, $local);
3617 # Require all input files.
3618 &require_file_with_conf_line ($ac_output_line, $FOREIGN,
3619 &rewrite_inputs_into_dependencies (0, @inputs));
3622 # These files get removed by "make clean".
3623 &define_pretty_variable ('CONFIG_CLEAN_FILES', '', @actual_other_files);
3629 my @r = &am_install_var ('-defaultdist', 'header', 'HEADERS', 'include',
3630 'oldinclude', 'pkginclude',
3634 next unless /\.(.*)$/;
3635 &saw_extension ($1);
3641 return if ! $seen_gettext || $relative_dir ne '.';
3643 if (! &variable_defined ('SUBDIRS'))
3646 ("AM_GNU_GETTEXT used but SUBDIRS not defined");
3650 my @subdirs = &variable_value_as_list ('SUBDIRS', 'all');
3651 &am_line_error ('SUBDIRS',
3652 "AM_GNU_GETTEXT used but `po' not in SUBDIRS")
3653 if ! grep ('po', @subdirs);
3654 &am_line_error ('SUBDIRS',
3655 "AM_GNU_GETTEXT used but `intl' not in SUBDIRS")
3656 if ! grep ('intl', @subdirs);
3658 &require_file_with_conf_line ($ac_gettext_line, $GNU, 'ABOUT-NLS');
3660 # Ensure that each language in ALL_LINGUAS has a .po file, and
3661 # each po file is mentioned in ALL_LINGUAS.
3665 grep ($linguas{$_} = 1, split (' ', $all_linguas));
3672 &am_line_error ($all_linguas_line,
3673 ("po/$_.po exists but `$_' not in `ALL_LINGUAS'"))
3677 foreach (keys %linguas)
3679 &am_line_error ($all_linguas_line,
3680 "$_ in `ALL_LINGUAS' but po/$_.po does not exist")
3686 &am_error ("AM_GNU_GETTEXT in `$configure_ac' but `ALL_LINGUAS' not defined");
3690 # Handle footer elements.
3693 if (variable_value ('SOURCES'))
3695 # NOTE don't use define_pretty_variable here, because
3696 # $contents{...} is already defined.
3697 $output_vars .= 'SOURCES = ' . variable_value ('SOURCES') . "\n";
3699 if (variable_value ('OBJECTS'))
3701 # NOTE don't use define_pretty_variable here, because
3702 # $contents{...} is already defined.
3703 $output_vars .= 'OBJECTS = ' . variable_value ('OBJECTS') . "\n";
3705 if (variable_value ('SOURCES') || variable_value ('OBJECTS'))
3707 $output_vars .= "\n";
3710 if (&target_defined ('.SUFFIXES'))
3712 &am_line_error ('.SUFFIXES',
3713 "use variable `SUFFIXES', not target `.SUFFIXES'");
3716 # Note: AIX 4.1 /bin/make will fail if any suffix rule appears
3717 # before .SUFFIXES. So we make sure that .SUFFIXES appears before
3718 # anything else, by sticking it right after the default: target.
3719 $output_header .= ".SUFFIXES:\n";
3720 if (@suffixes || &variable_defined ('SUFFIXES'))
3722 # Make sure suffixes has unique elements. Sort them to ensure
3723 # the output remains consistent. However, $(SUFFIXES) is
3724 # always at the start of the list, unsorted. This is done
3725 # because make will choose rules depending on the ordering of
3726 # suffixes, and this lets the user have some control. Push
3727 # actual suffixes, and not $(SUFFIXES). Some versions of make
3728 # do not like variable substitutions on the .SUFFIXES line.
3729 my @user_suffixes = (&variable_defined ('SUFFIXES')
3730 ? &variable_value_as_list ('SUFFIXES', '')
3734 grep ($suffixes{$_} = 1, @suffixes);
3735 delete @suffixes{@user_suffixes};
3737 $output_header .= (".SUFFIXES: "
3738 . join (' ', @user_suffixes, sort keys %suffixes)
3741 $output_trailer .= &file_contents ('footer');
3744 # Deal with installdirs target.
3745 sub handle_installdirs ()
3748 &file_contents ('install',
3750 => variable_value ('_am_installdirs') || ''));
3754 # Deal with all and all-am.
3757 my ($makefile) = @_;
3761 # Put this at the beginning for the sake of non-GNU makes. This
3762 # is still wrong if these makes can run parallel jobs. But it is
3764 unshift (@all, basename ($makefile));
3766 foreach my $one_name (@config_names)
3768 push (@all, basename ($one_name))
3769 if dirname ($one_name) eq $relative_dir;
3772 # Install `all' hooks.
3773 if (&target_defined ("all-local"))
3775 push (@all, "all-local");
3776 &depend ('.PHONY', "all-local");
3779 &pretty_print_rule ("all-am:", "\t\t", @all);
3780 &depend ('.PHONY', 'all-am', 'all');
3785 my @local_headers = ();
3786 push @local_headers, '$(BUILT_SOURCES)'
3787 if &variable_defined ('BUILT_SOURCES');
3788 foreach my $one_name (@config_names)
3790 push @local_headers, basename ($one_name)
3791 if dirname ($one_name) eq $relative_dir;
3796 # We need to make sure config.h is built before we recurse.
3797 # We also want to make sure that built sources are built
3798 # before any ordinary `all' targets are run. We can't do this
3799 # by changing the order of dependencies to the "all" because
3800 # that breaks when using parallel makes. Instead we handle
3801 # things explicitly.
3802 $output_all .= ("all: " . join (' ', @local_headers)
3804 . '$(MAKE) $(AM_MAKEFLAGS) '
3805 . (&variable_defined ('SUBDIRS')
3806 ? 'all-recursive' : 'all-am')
3811 $output_all .= "all: " . (&variable_defined ('SUBDIRS')
3812 ? 'all-recursive' : 'all-am') . "\n\n";
3817 # Handle check merge target specially.
3818 sub do_check_merge_target
3820 if (&target_defined ('check-local'))
3822 # User defined local form of target. So include it.
3823 push (@check_tests, 'check-local');
3824 &depend ('.PHONY', 'check-local');
3827 # In --cygnus mode, check doesn't depend on all.
3830 # Just run the local check rules.
3831 &pretty_print_rule ('check-am:', "\t\t", @check);
3835 # The check target must depend on the local equivalent of
3836 # `all', to ensure all the primary targets are built. Then it
3837 # must build the local check rules.
3838 $output_rules .= "check-am: all-am\n";
3839 &pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ",
3843 &pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ",
3847 &depend ('.PHONY', 'check', 'check-am');
3848 $output_rules .= ("check: "
3849 . (&variable_defined ('SUBDIRS')
3850 ? 'check-recursive' : 'check-am')
3854 # Handle all 'clean' targets.
3859 # Don't include `MAINTAINER'; it is handled specially below.
3860 foreach my $name ('MOSTLY', '', 'DIST')
3862 $transform{"${name}CLEAN"} = &variable_defined ("${name}CLEANFILES");
3865 # Built sources are automatically removed by maintainer-clean.
3866 push (@maintainer_clean_files, '$(BUILT_SOURCES)')
3867 if &variable_defined ('BUILT_SOURCES');
3868 push (@maintainer_clean_files, '$(MAINTAINERCLEANFILES)')
3869 if &variable_defined ('MAINTAINERCLEANFILES');
3871 $output_rules .= &file_contents ('clean',
3874 # Join with no space to avoid
3875 # spurious `test -z' success at
3877 => join ('', @maintainer_clean_files),
3879 # A space is required in the join here.
3880 => join (' ', @maintainer_clean_files)));
3884 # &depend ($CATEGORY, @DEPENDENDEES)
3885 # ----------------------------------
3886 # The target $CATEGORY depends on @DEPENDENDEES.
3889 my ($category, @dependendees) = @_;
3891 push (@{$dependencies{$category}}, @dependendees);
3896 # &target_cmp ($A, $B)
3897 # --------------------
3898 # Subroutine for &handle_factored_dependencies to let `.PHONY' be last.
3911 # &handle_factored_dependencies ()
3912 # --------------------------------
3913 # Handle everything related to gathered targets.
3914 sub handle_factored_dependencies
3917 foreach my $utarg ('uninstall-data-local', 'uninstall-data-hook',
3918 'uninstall-exec-local', 'uninstall-exec-hook')
3920 if (&target_defined ($utarg))
3923 $x =~ s/(data|exec)-//;
3924 &am_line_error ($utarg, "use `$x', not `$utarg'");
3928 if (&target_defined ('install-local'))
3930 &am_line_error ('install-local',
3931 "use `install-data-local' or `install-exec-local', "
3932 . "not `install-local'");
3935 if (!defined $options{'no-installinfo'}
3936 && &target_defined ('install-info-local'))
3938 &am_line_error ('install-info-local',
3939 "`install-info-local' target defined but "
3940 . "`no-installinfo' option not in use");
3943 # Install the -local hooks.
3944 foreach (keys %dependencies)
3946 # Hooks are installed on the -am targets.
3948 if (&target_defined ("$_-local"))
3950 depend ("$_-am", "$_-local");
3951 &depend ('.PHONY', "$_-local");
3955 # Install the -hook hooks.
3956 # FIXME: Why not be as liberal as we are with -local hooks?
3957 foreach ('install-exec', 'install-data')
3959 if (&target_defined ("$_-hook"))
3961 $actions{"$_-am"} .=
3962 ("\t\@\$(NORMAL_INSTALL)\n"
3963 . "\t" . '$(MAKE) $(AM_MAKEFLAGS) ' . "$_-hook\n");
3967 # All the required targets are phony.
3968 grep { &depend ('.PHONY', $_) } keys %required_targets;
3970 # Actually output gathered targets.
3971 foreach (sort target_cmp keys %dependencies)
3973 # If there is nothing about this guy, skip it.
3975 unless (@{$dependencies{$_}}
3977 || $required_targets{$_});
3978 &pretty_print_rule ("$_:", "\t",
3979 uniq (sort @{$dependencies{$_}}));
3980 $output_rules .= $actions{$_}
3981 if defined $actions{$_};
3982 $output_rules .= "\n";
3987 # &handle_tests_dejagnu ()
3988 # ------------------------
3989 sub handle_tests_dejagnu
3991 push (@check_tests, 'check-DEJAGNU');
3993 # In Cygnus mode, these are found in the build tree.
3994 # Otherwise they are looked for in $PATH.
3995 &define_program_variable ('EXPECT', 'build', 'expect', 'expect');
3996 &define_program_variable ('RUNTEST', 'src', 'dejagnu', 'runtest');
3998 # Only create site.exp rule if user hasn't already written
4001 &file_contents ('dejagnu',
4002 ('SITE-EXP' => ! &target_defined ('site.exp'),
4003 'BUILD' => $seen_canonical == $AC_CANONICAL_SYSTEM,
4004 'HOST' => $seen_canonical,
4005 'TARGET' => $seen_canonical == $AC_CANONICAL_SYSTEM));
4009 # Handle TESTS variable and other checks.
4012 if (defined $options{'dejagnu'})
4014 &handle_tests_dejagnu;
4018 foreach my $c ('DEJATOOL', 'RUNTEST', 'RUNTESTFLAGS')
4021 "`$c' defined but `dejagnu' not in `AUTOMAKE_OPTIONS'")
4022 if &variable_defined ($c);
4026 if (&variable_defined ('TESTS'))
4028 push (@check_tests, 'check-TESTS');
4029 $output_rules .= &file_contents ('check');
4033 # Handle Emacs Lisp.
4034 sub handle_emacs_lisp
4036 my @elfiles = &am_install_var ('-candist', 'lisp', 'LISP',
4042 &define_configure_variable ('lispdir');
4043 &define_configure_variable ('EMACS');
4044 $output_rules .= (".el.elc:\n"
4045 . "\t\@echo 'WARNING: Warnings can be ignored. :-)'\n"
4046 . "\tif test \$(EMACS) != no; then \\\n"
4047 . "\t EMACS=\$(EMACS) \$(SHELL) \$(srcdir)/elisp-comp \$<; \\\n"
4049 push (@suffixes, '.el', '.elc');
4051 # Generate .elc files.
4052 grep ($_ .= 'c', @elfiles);
4053 &define_pretty_variable ('ELCFILES', '', @elfiles);
4055 push (@all, '$(ELCFILES)');
4058 if (&variable_defined ('lisp_LISP'))
4060 $varname = 'lisp_LISP';
4061 &am_error ("`lisp_LISP' defined but `AM_PATH_LISPDIR' not in `$configure_ac'")
4066 $varname = 'noinst_LISP';
4069 &require_file_with_line ($varname, $FOREIGN, 'elisp-comp');
4076 my @pyfiles = &am_install_var ('-defaultdist', 'python', 'PYTHON',
4077 'python', 'noinst');
4078 return if ! @pyfiles;
4080 # Found some python.
4081 &define_configure_variable ('pythondir');
4082 &define_configure_variable ('PYTHON');
4084 &am_error ("`python_PYTHON' defined but `AM_CHECK_PYTHON' not in `$configure_ac'")
4085 if ! $seen_pythondir && &variable_defined ('python_PYTHON');
4087 if ($config_aux_dir eq '.' || $config_aux_dir eq '')
4089 &define_variable ('py_compile', '$(top_srcdir)/py-compile');
4093 &define_variable ('py_compile', $config_aux_dir . '/py-compile');
4100 my @sourcelist = &am_install_var ('-candist',
4102 'java', 'noinst', 'check');
4103 return if ! @sourcelist;
4105 &define_variable ('JAVAC', 'javac');
4106 &define_variable ('JAVACFLAGS', '');
4107 &define_variable ('CLASSPATH_ENV',
4108 'CLASSPATH=$(JAVAROOT):$(srcdir)/$(JAVAROOT):$$CLASSPATH');
4109 &define_variable ('JAVAROOT', '$(top_builddir)');
4111 my %valid = &am_primary_prefixes ('JAVA', 1,
4112 'java', 'noinst', 'check');
4115 foreach my $curs (keys %valid)
4117 if (! &variable_defined ($curs . '_JAVA') || $curs eq 'EXTRA')
4124 &am_line_error ($curs . '_JAVA',
4125 "multiple _JAVA primaries in use");
4130 $output_rules .= ('class' . $dir . '.stamp: $(' . $dir . '_JAVA)' . "\n"
4131 . "\t" . '$(CLASSPATH_ENV) $(JAVAC) -d $(JAVAROOT) '
4132 . '$(JAVACFLAGS) $?' . "\n"
4133 . "\t" . 'echo timestamp > class' . $dir . '.stamp'
4135 push (@all, 'class' . $dir . '.stamp');
4136 &push_dist_common ('$(' . $dir . '_JAVA)');
4139 # Handle some of the minor options.
4140 sub handle_minor_options
4142 if (defined $options{'readme-alpha'})
4144 if ($relative_dir eq '.')
4146 if ($package_version !~ /^$GNITS_VERSION_PATTERN$/)
4148 # FIXME: allow real filename.
4149 &am_conf_line_error ($configure_ac,
4150 $package_version_line,
4151 "version `$package_version' doesn't follow Gnits standards");
4153 elsif (defined $1 && -f 'README-alpha')
4155 # This means we have an alpha release. See
4156 # GNITS_VERSION_PATTERN for details.
4157 &require_file ($FOREIGN, 'README-alpha');
4163 ################################################################
4166 my @make_input_list;
4167 # &scan_autoconf_config_files ($CONFIG-FILES)
4168 # -------------------------------------------
4169 # Study $CONFIG-FILES which is the first argument to AC_CONFIG_FILES
4171 sub scan_autoconf_config_files
4173 my ($config_files) = @_;
4174 # Look at potential Makefile.am's.
4175 foreach (split ' ', $config_files)
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 my ($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, $_);
4210 # &scan_autoconf_traces ($FILENAME)
4211 # ---------------------------------
4212 # FIXME: For the time being, we don't care about the FILENAME.
4213 sub scan_autoconf_traces
4215 my ($filename) = @_;
4217 my $traces = "$ENV{amtraces} ";
4219 $traces .= ' -t AC_CONFIG_FILES';
4220 $traces .= ' -t AC_LIBSOURCE';
4221 $traces .= ' -t AC_SUBST';
4223 my $tracefh = new IO::File ("$traces |");
4226 die "$me: couldn't open `$traces': $!\n";
4228 print "$me: reading $traces\n" if $verbose;
4230 while ($_ = $tracefh->getline)
4233 my ($file, $line, $macro, @args) = split /:/;
4234 my $here = "$file:$line";
4236 # Alphabetical ordering please.
4237 if ($macro eq 'AC_CONFIG_FILES')
4239 # Look at potential Makefile.am's.
4240 &scan_autoconf_config_files ($args[0]);
4242 elsif ($macro eq 'AC_LIBSOURCE')
4244 my $source = "$args[0].c";
4245 # We should actually also `close' the sources: getopt.c
4246 # wants getopt.h etc. But actually it should be done in the
4247 # macro itself, i.e., we have to first fix Autoconf to extend
4248 # _AC_LIBOBJ_DECL and use it the in various macros.
4249 if (!defined $libsources{$source})
4251 print STDERR "traces: discovered $source\n";
4252 $libsources{$source} = $here;
4255 elsif ($macro eq 'AC_SUBST')
4257 if (!defined $configure_vars{$args[0]})
4259 print STDERR "traces: discovered AC_SUBST($args[0])\n";
4260 $configure_vars{$args[0]} = $here;
4266 || die "$me: close: $traces: $!\n";
4270 # &scan_one_autoconf_file ($FILENAME)
4271 # -----------------------------------
4272 # Scan one file for interesting things. Subroutine of
4273 # &scan_autoconf_files.
4274 sub scan_one_autoconf_file
4276 my ($filename) = @_;
4278 my $configfh = new IO::File ("< $filename");
4281 die "$me: couldn't open `$filename': $!\n";
4283 print "$me: reading $filename\n" if $verbose;
4285 my ($in_ac_output, $in_ac_replace) = (0, 0);
4286 while ($_ = $configfh->getline)
4288 # Remove comments from current line.
4292 # Skip macro definitions. Otherwise we might be confused into
4293 # thinking that a macro that was only defined was actually
4297 # Follow includes. This is a weirdness commonly in use at
4298 # Cygnus and hopefully nowhere else.
4299 if (/sinclude\((.*)\)/ && -f $1)
4301 # $_ being local, if we don't preserve it, when coming
4302 # back we will have $_ undefined, which is bad for the
4303 # the rest of this routine.
4304 my $underscore = $_;
4305 &scan_one_autoconf_file ($1);
4309 # Populate libobjs array.
4310 if (/AC_FUNC_ALLOCA/)
4312 $libsources{'alloca.c'} = 1;
4314 elsif (/AC_FUNC_GETLOADAVG/)
4316 $libsources{'getloadavg.c'} = 1;
4318 elsif (/AC_FUNC_MEMCMP/)
4320 $libsources{'memcmp.c'} = 1;
4322 elsif (/AC_STRUCT_ST_BLOCKS/)
4324 $libsources{'fileblocks.c'} = 1;
4326 elsif (/A[CM]_REPLACE_GNU_GETOPT/)
4328 $libsources{'getopt.c'} = 1;
4329 $libsources{'getopt1.c'} = 1;
4331 elsif (/AM_FUNC_STRTOD/)
4333 $libsources{'strtod.c'} = 1;
4335 elsif (/AM_WITH_REGEX/)
4337 $libsources{'rx.c'} = 1;
4338 $libsources{'rx.h'} = 1;
4339 $libsources{'regex.c'} = 1;
4340 $libsources{'regex.h'} = 1;
4342 elsif (/AC_FUNC_MKTIME/)
4344 $libsources{'mktime.c'} = 1;
4346 elsif (/AM_FUNC_ERROR_AT_LINE/)
4348 $libsources{'error.c'} = 1;
4349 $libsources{'error.h'} = 1;
4351 elsif (/AM_FUNC_OBSTACK/)
4353 $libsources{'obstack.c'} = 1;
4354 $libsources{'obstack.h'} = 1;
4356 elsif (/LIBOBJS="(.*)\s+\$LIBOBJS"/
4357 || /LIBOBJS="\$LIBOBJS\s+(.*)"/)
4359 foreach my $libobj_iter (split (' ', $1))
4361 if ($libobj_iter =~ /^(.*)\.o(bj)?$/
4362 || $libobj_iter =~ /^(.*)\.\$ac_objext$/
4363 || $libobj_iter =~ /^(.*)\.\$\{ac_objext\}$/)
4365 $libsources{$1 . '.c'} = 1;
4369 elsif (/AC_LIBOBJ\(([^)]+)\)/)
4371 $libsources{"$1.c"} = 1;
4374 if (! $in_ac_replace && s/AC_REPLACE_FUNCS\s*\(\[?//)
4380 $in_ac_replace = 0 if s/[\]\)].*$//;
4381 # Remove trailing backslash.
4385 # Need to skip empty elements for Perl 4.
4387 $libsources{$_ . '.c'} = 1;
4391 if (/$obsolete_rx/o)
4394 if ($obsolete_macros{$1} ne '')
4396 $hint = '; ' . $obsolete_macros{$1};
4398 &am_conf_line_error ($filename, $., "`$1' is obsolete$hint");
4401 # Process the AC_OUTPUT and AC_CONFIG_FILES macros.
4402 if (! $in_ac_output && s/AC_(OUTPUT|CONFIG_FILES)\s*\(\[?//)
4405 $ac_output_line = $.;
4416 # Look at potential Makefile.am's.
4417 &scan_autoconf_config_files ($_);
4419 if ($closing && @make_input_list == 0 && @other_input_files == 0)
4421 &am_conf_line_error ($filename, $ac_output_line,
4422 "No files mentioned in `AC_OUTPUT'");
4427 if (/$AC_CONFIG_AUX_DIR_PATTERN/o)
4429 @config_aux_path = &unquote_m4_arg ($1);
4432 # Check for ansi2knr.
4433 $am_c_prototypes = 1 if /AM_C_PROTOTYPES/;
4435 # Check for exe extension stuff.
4439 $configure_vars{'EXEEXT'} = $filename . ':' . $.;
4445 $configure_vars{'OBJEXT'} = $filename . ':' . $.;
4448 # Check for `-c -o' code.
4449 $seen_cc_c_o = 1 if /AM_PROG_CC_C_O/;
4451 # Check for NLS support.
4452 if (/AM_GNU_GETTEXT/)
4455 $ac_gettext_line = $.;
4458 # Look for ALL_LINGUAS.
4459 if (/ALL_LINGUAS="(.*)"$/ || /ALL_LINGUAS=(.*)$/)
4463 $all_linguas_line = $.;
4466 # Handle configuration headers. A config header of `[$1]'
4467 # means we are actually scanning AM_CONFIG_HEADER from
4469 if (/A([CM])_CONFIG_HEADERS?\s*\((.*)\)/
4473 ($filename, $., "`automake requires `AM_CONFIG_HEADER', not `AC_CONFIG_HEADER'")
4476 $config_header_line = $.;
4477 foreach my $one_hdr (split (' ', &unquote_m4_arg ($2)))
4479 push (@config_fullnames, $one_hdr);
4480 if ($one_hdr =~ /^([^:]+):(.+)$/)
4482 push (@config_names, $1);
4483 push (@config_headers, $2);
4487 push (@config_names, $one_hdr);
4488 push (@config_headers, $one_hdr . '.in');
4493 # Handle AC_CANONICAL_*. Always allow upgrading to
4494 # AC_CANONICAL_SYSTEM, but never downgrading.
4495 $seen_canonical = $AC_CANONICAL_HOST
4496 if ! $seen_canonical
4497 && (/AC_CANONICAL_HOST/ || /AC_CHECK_TOOL/);
4498 $seen_canonical = $AC_CANONICAL_SYSTEM if /AC_CANONICAL_SYSTEM/;
4500 $seen_path_xtra = 1 if /AC_PATH_XTRA/;
4502 # This macro handles several different things.
4503 if (/$AM_INIT_AUTOMAKE_PATTERN/o)
4507 $seen_prog_install = 1;
4508 ($package_version = $1) =~ s/$AM_PACKAGE_VERSION_PATTERN/$1/o;
4509 $package_version_line = $.;
4510 $seen_init_automake = 1;
4513 # Some things required by Automake.
4514 $seen_make_set = 1 if /AC_PROG_MAKE_SET/;
4515 $seen_arg_prog = 1 if /AC_ARG_PROGRAM/;
4519 $configure_vars{'LEX'} = $filename . ':' . $.;
4520 $seen_decl_yytext = 1;
4522 if (/AC_DECL_YYTEXT/ && $filename =~ /configure\.(ac|in)$/)
4524 &am_conf_line_warning ($filename, $., "`AC_DECL_YYTEXT' is covered by `AM_PROG_LEX'");
4526 if (/AC_PROG_LEX/ && $filename =~ /configure\.(ac|in)$/)
4528 &am_conf_line_warning ($filename, $., "automake requires `AM_PROG_LEX', not `AC_PROG_LEX'");
4531 if (/AC_PROG_(F77|YACC|RANLIB|CC|CXXCPP|CXX|LEX|AWK|CPP|LN_S)/)
4533 $configure_vars{$1} = $filename . ':' . $.;
4535 if (/$AC_CHECK_PATTERN/o)
4537 $configure_vars{$3} = $filename . ':' . $.;
4539 if (/$AM_MISSING_PATTERN/o
4543 && $1 ne 'AUTOHEADER')
4545 $configure_vars{$1} = $filename . ':' . $.;
4548 # Explicitly avoid ANSI2KNR -- we AC_SUBST that in protos.m4,
4549 # but later define it elsewhere. This is pretty hacky. We
4550 # also explicitly avoid INSTALL_SCRIPT and some other
4551 # variables because they are defined in header-vars.am.
4553 if (/$AC_SUBST_PATTERN/o
4555 && $1 ne 'INSTALL_SCRIPT'
4556 && $1 ne 'INSTALL_DATA')
4558 $configure_vars{$1} = $filename . ':' . $.;
4561 $seen_decl_yytext = 1 if /AC_DECL_YYTEXT/;
4562 if (/AM_MAINTAINER_MODE/)
4564 $seen_maint_mode = 1;
4565 $configure_cond{'MAINTAINER_MODE'} = 1;
4568 $seen_prog_install = 1 if /AC_PROG_INSTALL/;
4569 $seen_lispdir = 1 if /AM_PATH_LISPDIR/;
4570 $seen_pythondir = 1 if /AM_PATH_PYTHON/;
4572 if (/A(C|M)_PROG_LIBTOOL/)
4574 # We're not ready for this yet. People still use a
4575 # libtool with no AC_PROG_LIBTOOL. Once that is the
4576 # dominant version we can reenable this code -- but next
4577 # time by mentioning the macro in %obsolete_macros, both
4578 # here and in aclocal.in.
4580 # if (/AM_PROG_LIBTOOL/)
4582 # &am_conf_line_warning ($filename, $., "`AM_PROG_LIBTOOL' is obsolete, use `AC_PROG_LIBTOOL' instead");
4586 $configure_vars{'LIBTOOL'} = $filename . ':' . $.;
4587 $configure_vars{'RANLIB'} = $filename . ':' . $.;
4588 $configure_vars{'CC'} = $filename . ':' . $.;
4589 # AC_PROG_LIBTOOL runs AC_CANONICAL_HOST. Make sure we
4590 # never downgrade (if we've seen AC_CANONICAL_SYSTEM).
4591 $seen_canonical = $AC_CANONICAL_HOST if ! $seen_canonical;
4594 $seen_multilib = 1 if (/AM_ENABLE_MULTILIB/);
4596 if (/$AM_CONDITIONAL_PATTERN/o)
4598 $configure_cond{$1} = 1;
4601 # Check for Fortran 77 intrinsic and run-time libraries.
4602 if (/AC_F77_LIBRARY_LDFLAGS/)
4604 $configure_vars{'FLIBS'} = $filename . ':' . $.;
4612 # &scan_autoconf_files ()
4613 # -----------------------
4614 # Check whether we use `configure.ac' or `configure.in'.
4615 # Scan it (and possibly `aclocal.m4') for interesting things.
4616 # We must scan aclocal.m4 because there might be AC_SUBSTs and such there.
4617 sub scan_autoconf_files
4619 # Reinitialize libsources here. This isn't really necessary,
4620 # since we currently assume there is only one configure.ac. But
4621 # that won't always be the case.
4624 warn "$me: both `configure.ac' and `configure.in' present:"
4625 . " ignoring `configure.in'\n"
4626 if -f 'configure.ac' && -f 'configure.in';
4627 $configure_ac = 'configure.in'
4628 if -f 'configure.in';
4629 $configure_ac = 'configure.ac'
4630 if -f 'configure.ac';
4631 die "$me: `configure.ac' or `configure.in' is required\n"
4634 &scan_one_autoconf_file ($configure_ac);
4635 &scan_one_autoconf_file ('aclocal.m4')
4638 if (defined $ENV{'amtraces'})
4640 warn '$me: Autoconf traces is an experimental feature';
4641 warn '$me: use at your own risks';
4643 &scan_autoconf_traces ($configure_ac);
4646 # Set input and output files if not specified by user.
4649 @input_files = @make_input_list;
4650 %output_files = %make_list;
4653 @configure_input_files = @make_input_list;
4655 &am_conf_error ("`AM_INIT_AUTOMAKE' must be used")
4656 if ! $seen_init_automake;
4658 # Always require AC_PROG_MAKE_SET. We might randomly use $(MAKE)
4659 # for our own reasons.
4660 &am_conf_error ("`AC_PROG_MAKE_SET' must be used")
4661 if ! $seen_make_set;
4663 &am_conf_error ("`AC_PROG_INSTALL' must be used")
4664 if ! $seen_prog_install;
4666 # Look for some files we need. Always check for these. This
4667 # check must be done for every run, even those where we are only
4668 # looking at a subdir Makefile. We must set relative_dir so that
4669 # the file-finding machinery works.
4670 # FIXME: Is this broken because it needs dynamic scopes.
4671 # My tests seems to show it's not the case.
4672 $relative_dir = '.';
4673 &require_config_file ($FOREIGN, 'install-sh', 'mkinstalldirs', 'missing');
4674 &am_error ("`install.sh' is an anachronism; use `install-sh' instead")
4675 if -f $config_aux_path[0] . '/install.sh';
4677 &require_config_file ($FOREIGN, 'py-compile')
4680 # Preserve dist_common for later.
4681 $configure_dist_common = variable_value ('DIST_COMMON', 'TRUE');
4684 ################################################################
4686 # Set up for Cygnus mode.
4689 return unless $cygnus_mode;
4691 &set_strictness ('foreign');
4692 $options{'no-installinfo'} = 1;
4693 $options{'no-dependencies'} = 1;
4694 $use_dependencies = 0;
4696 if (! $seen_maint_mode)
4698 &am_conf_error ("`AM_MAINTAINER_MODE' required when --cygnus specified");
4702 # Do any extra checking for GNU standards.
4703 sub check_gnu_standards
4705 if ($relative_dir eq '.')
4707 # In top level (or only) directory.
4708 &require_file ($GNU, 'INSTALL', 'NEWS', 'README', 'COPYING',
4709 'AUTHORS', 'ChangeLog');
4712 if ($strictness >= $GNU
4713 && defined $options{'no-installman'})
4715 &am_line_error ('AUTOMAKE_OPTIONS',
4716 "option `no-installman' disallowed by GNU standards");
4719 if ($strictness >= $GNU
4720 && defined $options{'no-installinfo'})
4722 &am_line_error ('AUTOMAKE_OPTIONS',
4723 "option `no-installinfo' disallowed by GNU standards");
4727 # Do any extra checking for GNITS standards.
4728 sub check_gnits_standards
4730 if ($relative_dir eq '.')
4732 # In top level (or only) directory.
4733 &require_file ($GNITS, 'THANKS');
4737 ################################################################
4739 # Functions to handle files of each language.
4741 # Each `lang_X_rewrite' function follows a simple formula:
4742 # * Args are the directory, base name and extension of the file.
4743 # * Return value is 1 if file is to be dealt with, 0 otherwise.
4744 # Much of the actual processing is handled in handle_single_transform_list.
4745 # These functions exist so that auxiliary information can be recorded
4746 # for a later cleanup pass. Note that the calls to these functions
4747 # are computed, so don't bother searching for their precise names
4750 # This is just a convenience function that can be used to determine
4751 # when a subdir object should be used.
4754 return defined $options{'subdir-objects'} ? $LANG_SUBDIR : $LANG_PROCESS;
4757 # Rewrite a single C source file.
4760 my ($directory, $base, $ext) = @_;
4762 if (defined $options{'ansi2knr'} && $base =~ /_$/)
4764 # FIXME: include line number in error.
4765 &am_error ("C source file `$base.c' would be deleted by ansi2knr rules");
4768 my $r = $LANG_PROCESS;
4769 if (defined $options{'subdir-objects'})
4772 $base = $directory . '/' . $base;
4776 # Only give error once.
4778 # FIXME: line number.
4779 &am_error ("C objects in subdir but `AM_PROG_CC_C_O' not in `$configure_ac'");
4782 &require_file ($FOREIGN, 'compile')
4783 if $relative_dir eq '.';
4786 $de_ansi_files{$base} = 1;
4790 # Rewrite a single C++ source file.
4791 sub lang_cxx_rewrite
4793 return &lang_sub_obj;
4796 # Rewrite a single header file.
4797 sub lang_header_rewrite
4799 # Header files are simply ignored.
4800 return $LANG_IGNORE;
4803 # Rewrite a single yacc file.
4804 sub lang_yacc_rewrite
4806 my ($directory, $base, $ext) = @_;
4808 my $r = &lang_c_rewrite ($directory, $base, $ext);
4810 if ($r == $LANG_SUBDIR)
4812 $pfx = $directory . '/';
4814 $yacc_sources{$pfx . $base . '.' . $ext} = 1;
4816 &saw_extension ('c');
4818 &push_dist_common ($pfx . $base . '.' . $ext);
4822 # Rewrite a single yacc++ file.
4823 sub lang_yaccxx_rewrite
4825 my ($directory, $base, $ext) = @_;
4827 my $r = $LANG_PROCESS;
4829 if (defined $options{'subdir-objects'})
4831 $pfx = $directory . '/';
4834 $yacc_sources{$pfx . $base . '.' . $ext} = 1;
4836 &saw_extension ($ext);
4838 &push_dist_common ($pfx . $base . '.' . $ext);
4842 # Rewrite a single lex file.
4843 sub lang_lex_rewrite
4845 my ($directory, $base, $ext) = @_;
4847 my $r = &lang_c_rewrite ($directory, $base, $ext);
4849 if ($r == $LANG_SUBDIR)
4851 $pfx = $directory . '/';
4853 $lex_sources{$pfx . $base . '.' . $ext} = 1;
4855 &saw_extension ('c');
4857 &push_dist_common ($pfx . $base . '.' . $ext);
4861 # Rewrite a single lex++ file.
4862 sub lang_lexxx_rewrite
4864 my ($directory, $base, $ext) = @_;
4866 my $r = $LANG_PROCESS;
4868 if (defined $options{'subdir-objects'})
4870 $pfx = $directory . '/';
4873 $lex_sources{$pfx . $base . '.' . $ext} = 1;
4875 &saw_extension ($ext);
4877 &push_dist_common ($pfx . $base . '.' . $ext);
4881 # Rewrite a single assembly file.
4882 sub lang_asm_rewrite
4884 return &lang_sub_obj;
4887 # Rewrite a single Fortran 77 file.
4888 sub lang_f77_rewrite
4890 return $LANG_PROCESS;
4893 # Rewrite a single preprocessed Fortran 77 file.
4894 sub lang_ppf77_rewrite
4896 return $LANG_PROCESS;
4899 # Rewrite a single ratfor file.
4900 sub lang_ratfor_rewrite
4902 return $LANG_PROCESS;
4905 # Rewrite a single Objective C file.
4906 sub lang_objc_rewrite
4908 return &lang_sub_obj;
4911 # Rewrite a single Java file.
4912 sub lang_java_rewrite
4914 return $LANG_SUBDIR;
4917 # The lang_X_finish functions are called after all source file
4918 # processing is done. Each should handle defining rules for the
4919 # language, etc. A finish function is only called if a source file of
4920 # the appropriate type has been seen.
4924 # Push all libobjs files onto de_ansi_files. We actually only
4925 # push files which exist in the current directory, and which are
4926 # genuine source files.
4927 foreach my $file (keys %libsources)
4929 if ($file =~ /^(.*)\.[cly]$/ && -f "$relative_dir/$file")
4931 $de_ansi_files{$1} = 1;
4935 if (defined $options{'ansi2knr'} && keys %de_ansi_files)
4937 # Make all _.c files depend on their corresponding .c files.
4939 foreach my $base (sort keys %de_ansi_files)
4941 # Each _.c file must depend on ansi2knr; otherwise it
4942 # might be used in a parallel build before it is built.
4943 # We need to support files in the srcdir and in the build
4944 # dir (because these files might be auto-generated. But
4945 # we can't use $< -- some makes only define $< during a
4947 $output_rules .= ($base . "_.c: $base.c \$(ANSI2KNR)\n\t"
4948 . '$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) '
4949 . '`if test -f $(srcdir)/' . $base . '.c'
4950 . '; then echo $(srcdir)/' . $base . '.c'
4951 . '; else echo ' . $base . '.c; fi` '
4952 . "| sed 's/^# \\([0-9]\\)/#line \\1/' "
4953 . '| $(ANSI2KNR) > ' . $base . "_.c\n");
4954 push (@objects, $base . '_.$(OBJEXT)');
4955 push (@objects, $base . '_.lo')
4959 # Make all _.o (and _.lo) files depend on ansi2knr.
4960 # Use a sneaky little hack to make it print nicely.
4961 &pretty_print_rule ('', '', @objects, ':', '$(ANSI2KNR)');
4964 if (! defined $configure_vars{'CC'})
4966 # FIXME: line number.
4967 &am_error ("C source seen but `CC' not defined in `$configure_ac'");
4973 my ($ltcompile, $ltlink) = &libtool_compiler;
4975 &define_variable ('CXXLD', '$(CXX)');
4976 &define_variable ('CXXLINK', $ltlink . '$(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@');
4978 if (! defined $configure_vars{'CXX'})
4980 &am_error ("C++ source seen but `CXX' not defined in `$configure_ac'");
4984 sub lang_header_finish
4989 # This is a helper for both lex and yacc.
4990 sub yacc_lex_finish_helper
4992 return if defined $language_scratch{'lex-yacc-done'};
4993 $language_scratch{'lex-yacc-done'} = 1;
4995 # If there is more than one distinct yacc (resp lex) source file
4996 # in a given directory, then the `ylwrap' program is required to
4997 # allow parallel builds to work correctly. FIXME: for now, no
4999 &require_config_file ($FOREIGN, 'ylwrap');
5000 if ($config_aux_dir ne '.' && $config_aux_dir ne '')
5002 &define_variable ('YLWRAP', $config_aux_dir . "/ylwrap");
5006 &define_variable ('YLWRAP', '$(srcdir)/ylwrap');
5010 sub lang_yacc_finish
5012 return if defined $language_scratch{'yacc-done'};
5013 $language_scratch{'yacc-done'} = 1;
5015 my %seen_suffix = ();
5016 my @yacc_files = sort keys %yacc_sources;
5017 my $yacc_count = scalar (@yacc_files);
5018 foreach my $file (@yacc_files)
5021 &output_yacc_build_rule ($1, $yacc_count > 1)
5022 if ! defined $seen_suffix{$1};
5023 $seen_suffix{$1} = 1;
5025 $file =~ /^(.*)\.(y|yy|y\+\+|yxx|ypp)$/;
5027 my $hname = 'h'; # Always use `.h' for header file.
5031 if ((&variable_defined ('AM_YFLAGS')
5032 && &variable_value ('AM_YFLAGS') =~ /(^|\s)-d(\s|$)/)
5033 || (&variable_defined ('YFLAGS')
5034 && &variable_value ('YFLAGS') =~ /(^|\s)-d(\s|$)/)) {
5035 # Now generate rule to make the header file. This should only
5036 # be generated if `yacc -d' specified.
5037 $output_rules .= "${base}.${hname}: ${base}.${cname}\n";
5039 # If the files are built in the build directory, then we want
5040 # to remove them with `make clean'. If they are in srcdir
5041 # they shouldn't be touched. However, we can't determine this
5042 # statically, and the GNU rules say that yacc/lex output files
5043 # should be removed by maintainer-clean. So that's what we
5045 push (@maintainer_clean_files, "${base}.${hname}");
5047 &push_dist_common ("${base}.${hname}");
5049 push (@maintainer_clean_files, "${base}.${cname}");
5051 $output_rules .= "\n";
5053 if (! defined $configure_vars{'YACC'})
5055 &am_error ("yacc source seen but `YACC' not defined in `$configure_ac'");
5057 if (&variable_defined ('YACCFLAGS'))
5059 &am_line_error ('YACCFLAGS',
5060 "`YACCFLAGS' obsolete; use `YFLAGS' instead");
5063 if ($yacc_count > 1)
5065 &yacc_lex_finish_helper;
5069 sub lang_yaccxx_finish
5076 return if defined $language_scratch{'lex-done'};
5077 $language_scratch{'lex-done'} = 1;
5079 my %seen_suffix = ();
5080 my $lex_count = scalar (keys %lex_sources);
5081 foreach my $file (sort keys %lex_sources)
5084 &output_lex_build_rule ($1, $lex_count > 1)
5085 if (! defined $seen_suffix{$1});
5086 $seen_suffix{$1} = 1;
5088 # If the files are built in the build directory, then we want
5089 # to remove them with `make clean'. If they are in srcdir
5090 # they shouldn't be touched. However, we can't determine this
5091 # statically, and the GNU rules say that yacc/lex output files
5092 # should be removed by maintainer-clean. So that's what we
5094 $file =~ /^(.*)\.(l|ll|l\+\+|lxx|lpp)$/;
5096 ($cname = $2) =~ tr/l/c/;
5097 push (@maintainer_clean_files, "${1}.${cname}");
5100 if (! defined $configure_vars{'LEX'})
5102 &am_error ("lex source seen but `LEX' not defined in `$configure_ac'");
5104 if (! $seen_decl_yytext)
5106 &am_error ("lex source seen but `AC_DECL_YYTEXT' not in `$configure_ac'");
5111 &yacc_lex_finish_helper;
5115 sub lang_lexxx_finish
5122 # We need the C code for assembly.
5128 # FIXME: this function can be called more than once. We should
5129 # arrange for it to only do anything the first time through.
5131 my ($ltcompile, $ltlink) = &libtool_compiler;
5133 &define_variable ('F77LD', '$(F77)');
5134 &define_variable ('F77LINK',
5135 $ltlink . '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@');
5137 if (! defined $configure_vars{'F77'})
5139 &am_error ("Fortran 77 source seen but `F77' not defined in `$configure_ac'");
5143 # Preprocessed Fortran 77
5145 # The current support for preprocessing Fortran 77 just involves passing
5146 # `$(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS)' as additional flags
5147 # to the Fortran 77 compiler, since this is how GNU Make does it; see
5148 # the `GNU Make Manual, Edition 0.51 for `make' Version 3.76 Beta'
5149 # (specifically, from info file `(make)Catalogue of Rules').
5151 # A better approach would be to write an Autoconf test
5152 # (i.e. AC_PROG_FPP) for a Fortran 77 preprocessor, because not all
5153 # Fortran 77 compilers know how to do preprocessing. The Autoconf macro
5154 # AC_PROG_FPP should test the Fortran 77 compiler first for
5155 # preprocessing capabilities, and then fall back on cpp (if cpp were
5157 sub lang_ppf77_finish
5161 # We also handle the case of preprocessing `.F' files into `.f'
5163 $output_rules .= (".F.f:\n"
5164 . "\t\$(F77COMPILE) -F \$<\n");
5167 sub lang_ratfor_finish
5171 # We also handle the case of preprocessing `.r' files into `.f'
5173 $output_rules .= (".r.f:\n"
5174 . "\t\$(RCOMPILE) -F \$<\n");
5177 sub lang_objc_finish
5179 my ($ltcompile, $ltlink) = &libtool_compiler;
5181 &define_variable ('OBJCLD', '$(OBJC)');
5182 &define_variable ('OBJCLINK', $ltlink . '$(OBJCLD) $(AM_OBJCFLAGS) $(OBJCFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@');
5184 if (! defined $configure_vars{'OBJC'})
5186 &am_error ("Objective C source seen but `OBJC' not defined in `$configure_ac'");
5190 sub lang_java_finish
5192 my ($ltcompile, $ltlink) = &libtool_compiler;
5194 &define_variable ('GCJLD', '$(GCJ)');
5195 &define_variable ('GCJLINK',
5196 $ltlink . '$(GCJLD) $(AM_GCJFLAGS) $(GCJFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@');
5198 if (! defined $configure_vars{'GCJ'})
5200 &am_error ("Java source seen but `GCJ' not defined in `$configure_ac'");
5204 # A helper which computes a sorted list of all extensions for LANG.
5209 foreach my $key (sort keys %extension_seen)
5211 push (@r, '.' . $key) if $extension_map{$key} eq $lang;
5216 # A helper which decides whether libtool is needed. Returns prefix
5217 # for compiler and linker.
5218 sub libtool_compiler
5220 my ($ltcompile, $ltlink) = ('', '');
5223 &define_configure_variable ("LIBTOOL");
5224 $ltcompile = '$(LIBTOOL) --mode=compile ';
5225 $ltlink = '$(LIBTOOL) --mode=link ';
5227 return ($ltcompile, $ltlink);
5230 # Given a hash table of linker names, pick the name that has the most
5231 # precedence. This is lame, but something has to have global
5232 # knowledge in order to eliminate the conflict. Add more linkers as
5239 if defined $linkers{'GCJLINK'};
5241 if defined $linkers{'CXXLINK'};
5243 if defined $linkers{'F77LINK'};
5245 if defined $linkers{'OBJCLINK'};
5249 # Called to indicate that an extension was used.
5253 $extension_seen{$ext} = 1;
5256 # Called to ask whether source files have been seen . If HEADERS is 1,
5257 # headers can be included.
5268 my @exts = &lang_extensions ('header');
5272 return scalar keys %extension_seen > $headers;
5275 # Register a single language. LANGUAGE is the name of the language.
5276 # Each OPTION is either of the form NAME=VALUE, or is a file extension
5278 sub register_language
5280 my ($lang, @options) = @_;
5283 $language_map{"$lang-ansi-p"} = 0;
5284 $language_map{"$lang-autodep"} = 'no';
5285 $language_map{"$lang-derived-autodep"} = 'no';
5286 $language_map{"$lang-linker"} = '';
5288 # `-pure' is `yes' or `no'. A `pure' language is one where, if
5289 # all the files in a directory are of that language, then we do
5290 # not require the C compiler or any code to call it.
5291 $language_map{"$lang-pure"} = 'no';
5293 foreach my $iter (@options)
5295 if ($iter =~ /^(.*)=(.*)$/)
5297 $language_map{"$lang-$1"} = $2;
5299 elsif (defined $extension_map{$iter})
5301 &prog_error ("duplicate extension $iter");
5305 $extension_map{$iter} = $lang;
5310 # This function is used to find a path from a user-specified suffix to
5311 # `o' or to some other suffix we recognize internally, eg `cc'.
5314 my ($source_ext) = @_;
5316 # FIXME: hard-coding `o' is a mistake. Doing something
5317 # intelligent is harder.
5318 while ($extension_map{$source_ext} eq ''
5319 && $source_ext ne 'o'
5320 && defined $suffix_rules{$source_ext})
5322 $source_ext = $suffix_rules{$source_ext};
5329 ################################################################
5331 # Pretty-print something. HEAD is what should be printed at the
5332 # beginning of the first line, FILL is what should be printed at the
5333 # beginning of every subsequent line.
5334 sub pretty_print_internal
5336 my ($head, $fill, @values) = @_;
5338 my $column = length ($head);
5341 # Fill length is number of characters. However, each Tab
5342 # character counts for eight. So we count the number of Tabs and
5344 my $fill_length = length ($fill);
5345 $fill_length += 7 * ($fill =~ tr/\t/\t/d);
5349 # "71" because we also print a space.
5350 if ($column + length ($_) > 71)
5352 $result .= " \\\n" . $fill;
5353 $column = $fill_length;
5355 $result .= ' ' if $result =~ /\S\z/;
5357 $column += length ($_) + 1;
5364 # Pretty-print something and append to output_vars.
5367 $output_vars .= &pretty_print_internal (@_);
5370 # Pretty-print something and append to output_rules.
5371 sub pretty_print_rule
5373 $output_rules .= &pretty_print_internal (@_);
5377 ################################################################
5379 # See if a target exists.
5383 return defined $targets{$target};
5387 # &make_condition (@CONDITIONS)
5388 # -----------------------------
5389 # Transform a list of conditions (themselves can be an internal list
5390 # of conditions, e.g., @CONDITIONS = ('cond1 cond2', 'cond3')) into a
5391 # Make conditional (a pattern for AC_SUBST).
5392 # Correctly returns the empty string when there are no conditions.
5395 my $res = conditional_string (@_);
5397 # There are no conditions.
5403 elsif ($res eq 'FALSE')
5410 $res = '@' . $res . '@';
5418 # &variable_dump ($VAR)
5419 # ---------------------
5420 sub variable_dump ($)
5424 if (!exists $conditional{$var})
5426 print STDERR " $var does not exist\n";
5430 my $var_is_am = $var_is_am{$var} ? "Automake" : "User";
5431 my $where = (defined $content_lines{$var}
5432 ? $content_lines{$var} : "undefined");
5433 my $pluseq = ((defined $var_was_plus_eq{$var} && $var_was_plus_eq{$var})
5435 print STDERR " $var ($var_is_am, where = $where) $pluseq\n";
5436 print STDERR " {\n";
5437 print STDERR "$am_vars{$var}"
5438 if defined $am_vars{$var};
5439 foreach my $vcond (sort by_condition keys %{$conditional{$var}})
5441 print STDERR " $vcond => $conditional{$var}{$vcond}\n";
5443 print STDERR " }\n";
5448 # &variables_dump ()
5449 # ------------------
5450 sub variables_dump ()
5454 print STDERR "%conditional =\n";
5456 foreach my $var (sort (keys %conditional))
5458 variable_dump ($var);
5465 # &conditional_string(@COND-STACK)
5466 # --------------------------------
5468 sub conditional_string
5472 if (grep (/^FALSE$/, @stack))
5478 return join (' ', uniq sort grep (!/^TRUE$/, @stack));
5484 # &conditional_true_when ($COND, $WHEN)
5485 # -------------------------------------
5486 # See if a conditional is true. Both arguments are conditional
5487 # strings. This returns true if the first conditional is true when
5488 # the second conditional is true.
5489 # For instance with $COND = `BAR FOO', and $WHEN = `BAR BAZ FOO',
5490 # obviously return 1, and 0 when, for instance, $WHEN = `FOO'.
5491 sub conditional_true_when ($$)
5493 my ($cond, $when) = @_;
5495 # Check each component of $cond, which looks `COND1 COND2'.
5496 foreach my $comp (split (' ', $cond))
5498 if (index ($when, $comp) == -1)
5509 # &conditionals_true_when (@CONDS, @WHENS)
5510 # ----------------------------------------
5511 # Same as above, but true if all the @CONDS are true when *ALL*
5512 # the @WHENS are sufficient.
5514 # If there are no @CONDS, then return true, of course. *BUT*, even if there
5515 # are @CONDS but @WHENS is empty, return true. This is counter intuitive,
5516 # and against all the rules of logic, but is needed by the current code.
5517 # FIXME: Do something saner when the logic of conditionals is understood.
5518 sub conditionals_true_when (@@)
5520 my (@conds, @whens) = @_;
5522 foreach my $cond (@conds)
5524 foreach my $when (@whens)
5527 unless conditional_true_when ($cond, $when);
5535 sub condition_negate ($)
5539 $cond =~ s/TRUE$/TRUEO/;
5540 $cond =~ s/FALSE$/TRUE/;
5541 $cond =~ s/TRUEO$/FALSE/;
5547 # Check for an ambiguous conditional. This is called when a variable
5548 # or target is being defined conditionally. If we already know about
5549 # a definition that is true under the same conditions, then we have an
5551 sub check_ambiguous_conditional ($$)
5553 my ($var, $cond) = @_;
5554 foreach my $vcond (keys %{$conditional{$var}})
5557 if ($vcond eq $cond)
5559 $message = "$var multiply defined in condition $cond";
5561 elsif (&conditional_true_when ($vcond, $cond))
5563 $message = "$var was already defined in condition $vcond, which implies condition $cond";
5565 elsif (&conditional_true_when ($cond, $vcond))
5567 $message = "$var was already defined in condition $vcond, which is implied by condition $cond";
5571 &am_line_error ($var, $message);
5572 variable_dump ($var);
5579 ## ------------------------ ##
5580 ## Handling the variables. ##
5581 ## ------------------------ ##
5584 # ¯o_define($VAR, $VAR_IS_AM, $TYPE, $COND, $VALUE, $WHERE)
5585 # ----------------------------------------------------------------
5586 # The $VAR can go from Automake to user, but not the converse.
5587 sub macro_define ($$$$$$)
5589 my ($var, $var_is_am, $type, $cond, $value, $where) = @_;
5593 # A variable which was `+=' must not be `='.
5594 if (defined $var_was_plus_eq{$var})
5596 if ($var_was_plus_eq{$var} && $type ne '+')
5598 am_line_error ($var,
5599 ("$var was set with `+=' "
5600 . "and is now set with `$type='"));
5605 $var_was_plus_eq{$var} = $type eq '+' && ! $var_is_am{$var};
5608 # Differentiate the first assignment (including with `+=').
5609 if ($type eq '+' && defined $conditional{$var}{$cond})
5611 if (substr ($conditional{$var}{$cond}, -1) eq "\n")
5613 # Insert a backslash before a trailing newline.
5614 $conditional{$var}{$cond} =
5615 substr ($conditional{$var}{$cond}, 0, -1) . "\\\n";
5617 elsif ($conditional{$var}{$cond})
5619 # Insert a separator.
5620 $conditional{$var}{$cond} .= ' ';
5622 $conditional{$var}{$cond} .= $value;
5626 # The first assignment to a macro sets the line number. Ideally I
5627 # suppose we would associate line numbers with random bits of text.
5628 # FIXME: We sometimes redefine some variables, but we want to keep
5629 # the original location. More subs are needed to handle
5630 # properly variables. Once this done, remove this hack.
5631 $content_lines{$var} = $where
5632 unless defined $content_lines{$var};
5634 # There must be no previous value unless the user is redefining
5635 # an Automake variable or an AC_SUBST variable.
5636 check_ambiguous_conditional ($var, $cond)
5637 unless ($var_is_am{$var} && !$var_is_am
5638 || exists $configure_vars{$var});
5640 $conditional{$var}{$cond} = $value;
5643 # An Automake variable can be given to the user, but not the converse.
5644 if (! defined $var_is_am{$var} || !$var_is_am)
5646 $var_is_am{$var} = $var_is_am;
5649 $def_type{$var} = ($type eq ':') ? ':' : '';
5653 # &variable_delete ($VAR)
5654 # -----------------------
5655 # Forget about a variable.
5656 sub variable_delete ($)
5660 delete $content_lines{$var};
5661 delete $conditional{$var};
5662 delete $var_is_am{$var};
5663 delete $def_type{$var};
5668 # &variable_defined ($VAR, [$COND])
5669 # ---------------------------------
5670 # See if a variable exists, and is a user variable. $VAR is the
5671 # variable name, and $COND is the condition which we should check. If
5672 # no condition is given, we currently return true if the variable is
5673 # defined under any condition.
5674 sub variable_defined ($$)
5676 my ($var, $cond) = @_;
5678 # Unfortunately we can't just check for $conditional{VAR}{COND}
5679 # as this would make perl create $condition{VAR}, which we
5681 if (!exists $conditional{$var})
5683 if (defined $targets{$var})
5685 &am_line_error ($var, "`$var' is a target; expected a variable")
5687 # The variable is not defined
5691 if ($var_is_am{$var}
5692 || ($cond && !exists $conditional{$var}{$cond}))
5694 # The variable is not defined for the given condition.
5698 # Even a conditional examination is good enough for us. FIXME:
5699 # really should maintain examined status on a per-condition basis.
5700 $content_seen{$var} = 1;
5704 # Mark a variable as examined.
5705 sub examine_variable
5708 &variable_defined ($var);
5711 # Return the set of conditions for which a variable is defined.
5713 # If the variable is not defined conditionally, and is not defined in
5714 # terms of any variables which are defined conditionally, then this
5715 # returns the empty list.
5717 # If the variable is defined conditionally, but is not defined in
5718 # terms of any variables which are defined conditionally, then this
5719 # returns the list of conditions for which the variable is defined.
5721 # If the variable is defined in terms of any variables which are
5722 # defined conditionally, then this returns a full set of permutations
5723 # of the subvariable conditions. For example, if the variable is
5724 # defined in terms of a variable which is defined for COND_TRUE,
5725 # then this returns both COND_TRUE and COND_FALSE. This is
5726 # because we will need to define the variable under both conditions.
5728 sub variable_conditions ($)
5735 foreach my $cond (&variable_conditions_sub ($var, '', ()))
5738 if $cond eq 'FALSE';
5739 $uniqify{$cond} = 1;
5742 @uniq_list = sort by_condition keys %uniqify;
5743 # Note we cannot just do `return sort keys %uniqify', because this
5744 # function is sometimes used in a scalar context.
5750 # &variable_conditionally_defined ($VAR)
5751 # --------------------------------------
5752 sub variable_conditionally_defined ($)
5755 foreach my $cond (variable_conditions ($var))
5758 unless $cond =~ /^TRUE|FALSE$/;
5765 # &variable_conditions_sub ($VAR, $PARENT, @PARENT_CONDS)
5766 # -------------------------------------------------------
5767 # A subroutine of variable_conditions. We only return conditions
5768 # which are true for all the conditions in @PARENT_CONDS.
5769 sub variable_conditions_sub
5771 my ($var, $parent, @parent_conds) = @_;
5774 if (defined $vars_scanned{$var})
5776 &am_line_error ($parent, "variable `$var' recursively defined");
5779 $vars_scanned{$var} = 1;
5781 my @this_conds = ();
5782 foreach my $vcond (keys %{$conditional{$var}})
5785 if ! conditionals_true_when ((@parent_conds), ($vcond));
5787 push (@this_conds, $vcond);
5789 push (@parent_conds, $vcond);
5790 my @subvar_conds = ();
5791 foreach (split (' ', $conditional{$var}{$vcond}))
5793 # If a comment seen, just leave.
5796 # Handle variable substitutions.
5797 if (/^\$\{(.*)\}$/ || /^\$\((.*)\)$/)
5799 push (@subvar_conds,
5800 &variable_conditions_sub ($1, $var, @parent_conds));
5803 pop (@parent_conds);
5805 # If there are no conditional subvariables, then we want to
5806 # return this condition. Otherwise, we want to return the
5807 # permutations of the subvariables.
5808 if (! @subvar_conds)
5810 push (@new_conds, $vcond);
5814 push (@new_conds, &variable_conditions_reduce (@subvar_conds));
5818 # Unset our entry in vars_scanned. We only care about recursive
5820 delete $vars_scanned{$var};
5822 # If there are no parents, then this call is the top level call.
5825 # Now we want to return all permutations of the subvariable
5828 foreach my $item (@new_conds)
5830 foreach (split (' ', $item))
5832 s/^(.*)_(TRUE|FALSE)$/$1_TRUE/;
5836 return &variable_conditions_permutations (sort keys %allconds);
5839 # If we are being called on behalf of another variable, we need to
5840 # return all possible permutations of the conditions. We have
5841 # already handled everything in @this_conds along with their
5842 # subvariables. We now need to add any permutations that are not
5844 foreach my $this_cond (@this_conds)
5847 &variable_conditions_permutations (split(' ', $this_cond));
5848 foreach my $perm (@perms)
5851 foreach my $scan (@this_conds)
5853 if (&conditional_true_when ($perm, $scan)
5854 || &conditional_true_when ($scan, $perm))
5863 if ! conditionals_true_when ((@parent_conds), ($perm));
5865 # This permutation was not already handled, and is valid
5867 push (@new_conds, $perm);
5875 # Compare condition names.
5876 # Issue them in alphabetical order, foo_TRUE before foo_FALSE.
5879 # Be careful we might be comparing `' or `#'.
5880 $a =~ /^(.*)_(TRUE|FALSE)$/;
5881 my ($aname, $abool) = ($1 || '', $2 || '');
5882 $b =~ /^(.*)_(TRUE|FALSE)$/;
5883 my ($bname, $bbool) = ($1 || '', $2 || '');
5884 return ($aname cmp $bname
5885 # Don't bother with IFs, given that TRUE is after FALSE
5886 # just cmp in the reverse order.
5887 || $bbool cmp $abool
5893 # Filter a list of conditionals so that only the exclusive ones are
5894 # retained. For example, if both `COND1_TRUE COND2_TRUE' and
5895 # `COND1_TRUE' are in the list, discard the latter.
5896 sub variable_conditions_reduce
5900 foreach my $cond (@conds)
5902 # FALSE is absorbent.
5903 if ($cond eq 'FALSE')
5907 elsif (conditionals_true_when (($cond), (@ret)))
5916 # Return a list of permutations of a conditional string.
5917 sub variable_conditions_permutations
5922 my $comp = shift (@comps);
5923 return &variable_conditions_permutations (@comps)
5925 my $neg = condition_negate ($comp);
5928 foreach my $sub (&variable_conditions_permutations (@comps))
5930 push (@ret, "$comp $sub");
5931 push (@ret, "$neg $sub");
5943 # &check_variable_defined_unconditionally($VAR, $PARENT)
5944 # ------------------------------------------------------
5945 # Warn if a variable is conditionally defined. This is called if we
5946 # are using the value of a variable.
5947 sub check_variable_defined_unconditionally ($$)
5949 my ($var, $parent) = @_;
5950 foreach my $cond (keys %{$conditional{$var}})
5953 if $cond =~ /^TRUE|FALSE$/;
5957 &am_line_error ($parent,
5958 "warning: automake does not support conditional definition of $var in $parent");
5962 &am_line_error ($parent,
5963 "warning: automake does not support $var being defined conditionally");
5964 variable_dump ($var);
5971 # Get the TRUE value of a variable, warn if the variable is
5972 # conditionally defined.
5976 &check_variable_defined_unconditionally ($var);
5977 return $conditional{$var}{'TRUE'};
5982 # &value_to_list ($VAR, $VAL, $COND)
5983 # ----------------------------------
5984 # Convert a variable value to a list, split as whitespace. This will
5985 # recursively follow $(...) and ${...} inclusions. It preserves @...@
5988 # If COND is 'all', then all values under all conditions should be
5989 # returned; if COND is a particular condition (all conditions are
5990 # surrounded by @...@) then only the value for that condition should
5991 # be returned; otherwise, warn if VAR is conditionally defined.
5992 # SCANNED is a global hash listing whose keys are all the variables
5993 # already scanned; it is an error to rescan a variable.
5996 my ($var, $val, $cond) = @_;
6000 $val =~ s/\\(\n|$)/ /g;
6002 foreach (split (' ', $val))
6004 # If a comment seen, just leave.
6007 # Handle variable substitutions.
6008 if (/^\$\{([^}]*)\}$/ || /^\$\(([^)]*)\)$/)
6012 # If the user uses a losing variable name, just ignore it.
6013 # This isn't ideal, but people have requested it.
6014 next if ($varname =~ /\@.*\@/);
6018 if ($varname =~ /^([^:]*):([^=]*)=(.*)$/)
6022 ($from = $2) =~ s/(\W)/\\$1/g;
6026 @temp_list = &variable_value_as_list_worker ($1, $cond, $var);
6028 # Now rewrite the value if appropriate.
6031 grep (s/$from$/$to/, @temp_list);
6034 push (@result, @temp_list);
6045 # Return contents of variable as list, split as whitespace. This will
6046 # recursively follow $(...) and ${...} inclusions. It preserves @...@
6047 # substitutions. If COND is 'all', then all values under all
6048 # conditions should be returned; if COND is a particular condition
6049 # (all conditions are surrounded by @...@) then only the value for
6050 # that condition should be returned; otherwise, warn if VAR is
6051 # conditionally defined. If PARENT is specified, it is the name of
6052 # the including variable; this is only used for error reports.
6053 sub variable_value_as_list_worker
6055 my ($var, $cond, $parent) = @_;
6058 if (! defined $conditional{$var})
6060 if (defined $targets{$var})
6062 &am_line_error ($var, "`$var' is a target; expected a variable");
6066 &am_line_error ($parent, "variable `$var' not defined");
6069 elsif (defined $vars_scanned{$var})
6071 # `vars_scanned' is a global we use to keep track of which
6072 # variables we've already examined.
6073 &am_line_error ($parent, "variable `$var' recursively defined");
6075 elsif ($cond eq 'all')
6077 $vars_scanned{$var} = 1;
6078 foreach my $vcond (keys %{$conditional{$var}})
6080 my $val = $conditional{$var}{$vcond};
6081 push (@result, &value_to_list ($var, $val, $cond));
6087 $vars_scanned{$var} = 1;
6089 foreach my $vcond (keys %{$conditional{$var}})
6091 my $val = $conditional{$var}{$vcond};
6092 if (&conditional_true_when ($vcond, $cond))
6094 # Warn if we have an ambiguity. It's hard to know how
6095 # to handle this case correctly.
6096 &check_variable_defined_unconditionally ($var, $parent)
6099 push (@result, &value_to_list ($var, $val, $cond));
6104 # Unset our entry in vars_scanned. We only care about recursive
6106 delete $vars_scanned{$var};
6112 # &variable_output ($VAR)
6113 # -----------------------
6114 sub variable_output ($)
6118 $output_vars .= $am_vars{$var}
6119 if defined $am_vars{$var};
6121 foreach my $cond (sort by_condition keys %{$conditional{$var}})
6123 my $val = $conditional{$var}{$cond};
6124 my $output_var = ($var . ' '
6125 . $def_type{$var} . "= "
6127 $output_var =~ s/^/&make_condition ($cond)/meg;
6128 $output_vars .= $output_var . "\n";
6133 # This is just a wrapper for variable_value_as_list_worker that
6134 # initializes the global hash `vars_scanned'. This hash is used to
6135 # avoid infinite recursion.
6136 sub variable_value_as_list
6138 my ($var, $cond, $parent) = @_;
6140 return &variable_value_as_list_worker ($var, $cond, $parent);
6144 # Like define_variable, but the value is a list, and the variable may
6145 # be defined conditionally. The second argument is the conditional
6146 # under which the value should be defined; this should be the empty
6147 # string to define the variable unconditionally. The third argument
6148 # is a list holding the values to use for the variable. The value is
6149 # pretty printed in the output file.
6150 sub define_pretty_variable
6152 my ($var, $cond, @value) = @_;
6154 if (! &variable_defined ($var, $cond))
6156 macro_define ($var, 0, '', $cond, join (' ', @value), undef);
6157 my $make_condition = &make_condition ($cond);
6158 &pretty_print ($make_condition . $var . ' =',
6159 $make_condition, @value);
6160 $content_seen{$var} = 1;
6162 elsif ($var_was_plus_eq{$var})
6164 &am_line_error ($var,
6165 "internally generated variable `$var' was set with `+='");
6170 # define_variable ($VAR, $VALUE)
6171 # ------------------------------
6172 # Define a new user variable VAR to VALUE, but only if not already defined.
6175 my ($var, $value) = @_;
6177 define_pretty_variable ($var, 'TRUE', $value);
6181 # Like define_variable, but define a variable to be the configure
6182 # substitution by the same name.
6183 sub define_configure_variable
6186 my $value = '@' . $var . '@';
6187 &define_variable ($var, $value);
6190 # Define a compiler variable. We also handle defining the `LT'
6191 # version of the command when using libtool.
6192 sub define_compiler_variable
6194 my ($var, $ltcompile, $value) = @_;
6196 &define_variable ($name, $value);
6197 &define_variable ('LT' . $name, $ltcompile . $value)
6201 # Define a variable that represents a program to run. If in Cygnus
6202 # mode, the program is searched for in the build (or source) tree.
6203 # Otherwise no searching is done at all. Arguments are:
6204 # * VAR Name of variable to define
6205 # * WHATDIR Either `src' or `build', depending on where program should
6206 # be found. (runtest is in srcdir!)
6207 # * SUBDIR Subdir of top-level dir
6208 # * PROGRAM Name of program
6209 # * OVERRIDE If specified, the name of the program to use when not in
6210 # Cygnus mode. Defaults to PROGRAM.
6211 sub define_program_variable
6213 my ($var, $whatdir, $subdir, $program, $override) = @_;
6217 $override = $program;
6222 my $full = ('$(top_' . $whatdir . 'dir)/../'
6223 . $subdir . '/' . $program);
6224 &define_variable ($var, ('`if test -f ' . $full
6225 . '; then echo ' . $full . '; else echo '
6226 . $program . '; fi`'));
6230 &define_variable ($var, $override);
6235 ################################################################
6237 ## ---------------- ##
6238 ## Handling rules. ##
6239 ## ---------------- ##
6241 sub rule_define ($$$$)
6243 my ($target, $rule_is_am, $cond, $where) = @_;
6245 if (defined $targets{$target}
6247 ? ! defined $target_conditional{$target}
6248 : defined $target_conditional{$target}))
6250 &am_line_error ($target,
6251 "$target defined both conditionally and unconditionally");
6254 # Value here doesn't matter; for targets we only note existence.
6255 $targets{$target} = $where;
6258 if ($target_conditional{$target})
6260 &check_ambiguous_conditional ($target, $cond);
6262 $target_conditional{$target}{$cond} = $where;
6266 # Check the rule for being a suffix rule. If so, store in a hash.
6270 if (($source_suffix, $object_suffix) = ($1 =~ $SUFFIX_RULE_PATTERN))
6272 $suffix_rules{$source_suffix} = $object_suffix;
6273 print "Sources ending in .$source_suffix become .$object_suffix\n"
6275 $source_suffix_pattern = "(" . join ('|', keys %suffix_rules) . ")";
6278 # FIXME: make sure both suffixes are in SUFFIXES? Or set SUFFIXES from
6282 ################################################################
6284 # Read Makefile.am and set up %contents. Simultaneously copy lines
6285 # from Makefile.am into $output_trailer or $output_vars as
6286 # appropriate. NOTE we put rules in the trailer section. We want
6287 # user rules to come after our generated stuff.
6292 my $am_file = new IO::File ("< $amfile");
6295 die "$me: couldn't open `$amfile': $!\n";
6297 print "$me: reading $amfile\n" if $verbose;
6303 while ($_ = $am_file->getline)
6305 if (/$IGNORE_PATTERN/o)
6307 # Merely delete comments beginning with two hashes.
6309 elsif (/$WHITE_PATTERN/o)
6311 # Stick a single white line before the incoming macro or rule.
6315 elsif (/$COMMENT_PATTERN/o)
6317 # Stick comments before the incoming macro or rule. Make
6318 # sure a blank line preceeds first block of comments.
6319 $spacing = "\n" unless $blank;
6321 $comment .= $spacing . $_;
6330 $output_vars .= $comment . "\n";
6334 # We save the conditional stack on entry, and then check to make
6335 # sure it is the same on exit. This lets us conditonally include
6337 my @saved_cond_stack = @conditional_stack;
6338 my $cond = conditional_string (@conditional_stack);
6343 my $last_var_name = '';
6344 my $last_var_type = '';
6345 my $last_var_value = '';
6349 unless substr ($_, -1, 1) eq "\n";
6351 # Don't look at MAINTAINER_MODE_TRUE here. That shouldn't be
6352 # used by users. @MAINT@ is an anachronism now.
6353 $_ =~ s/\@MAINT\@//g
6354 unless $seen_maint_mode;
6356 if (/$IGNORE_PATTERN/o)
6358 # Merely delete comments beginning with two hashes.
6360 elsif (/$WHITE_PATTERN/o)
6362 # Stick a single white line before the incoming macro or rule.
6364 &am_line_error ($., "blank line following trailing backslash")
6367 elsif (/$COMMENT_PATTERN/o)
6369 # Stick comments before the incoming macro or rule.
6370 $comment .= $spacing . $_;
6372 &am_line_error ($., "comment following trailing backslash")
6379 $output_trailer .= &make_condition (@conditional_stack);
6380 $output_trailer .= $_;
6384 $last_var_value .= ' '
6385 unless $last_var_value =~ /\s$/;
6386 $last_var_value .= $_;
6390 $am_vars{$last_var_name} = $comment . $spacing;
6391 $comment = $spacing = '';
6392 macro_define ($last_var_name, 0,
6393 $last_var_type, $cond,
6394 $last_var_value, $.);
6395 push (@var_list, $last_var_name);
6399 elsif (/$IF_PATTERN/o)
6402 &am_line_error ($., "$new_cond does not appear in AM_CONDITIONAL")
6403 if ! $configure_cond{$new_cond} && $new_cond !~ /^TRUE|FALSE$/;
6404 push (@conditional_stack,
6405 (($new_cond =~ /^TRUE|FALSE$/)
6406 ? "$new_cond" : "${new_cond}_TRUE"));
6407 $cond = conditional_string (@conditional_stack);
6409 elsif (/$ELSE_PATTERN/o)
6411 if (! @conditional_stack)
6413 &am_line_error ($., "else without if");
6415 elsif ($conditional_stack[$#conditional_stack] =~ /_FALSE$/)
6417 &am_line_error ($., "else after else");
6421 $conditional_stack[$#conditional_stack]
6422 = condition_negate ($conditional_stack[$#conditional_stack]);
6423 $cond = conditional_string (@conditional_stack);
6426 elsif (/$ENDIF_PATTERN/o)
6428 if (! @conditional_stack)
6430 &am_line_error ($., "endif without if");
6434 pop @conditional_stack;
6435 $cond = conditional_string (@conditional_stack);
6438 elsif (/$RULE_PATTERN/o)
6443 rule_define ($1, 0, $cond, $.);
6445 $content_lines{$1} = $.;
6446 $output_trailer .= $comment . $spacing;
6447 $output_trailer .= &make_condition (@conditional_stack);
6448 $output_trailer .= $_;
6449 $comment = $spacing = '';
6451 elsif (($is_ok_macro = /$MACRO_PATTERN/o)
6452 || /$BOGUS_MACRO_PATTERN/o)
6455 &am_line_error ($., "bad macro name `$last_var_name'")
6458 # Found a macro definition.
6460 $last_var_name = $1;
6461 $last_var_type = $2;
6462 $last_var_value = $3;
6463 if ($3 ne '' && substr ($3, -1) eq "\\")
6465 # We preserve the `\' because otherwise the long lines
6466 # that are generated will be truncated by broken
6468 $last_var_value = $3 . "\n";
6473 # FIXME: this doesn't always work correctly; it will
6474 # group all comments for a given variable, no matter
6476 $am_vars{$last_var_name} = $comment . $spacing;
6477 $comment = $spacing = '';
6479 macro_define ($last_var_name, 0,
6480 $last_var_type, $cond,
6481 $last_var_value, $.);
6482 push (@var_list, $last_var_name);
6485 elsif (/$INCLUDE_PATTERN/o)
6489 if ($path =~ s/^\$\(top_srcdir\)\///)
6491 push (@include_stack, "\$\(top_srcdir\)/$path");
6495 $path =~ s/\$\(srcdir\)\///;
6496 push (@include_stack, "\$\(srcdir\)/$path");
6497 $path = $relative_dir . "/" . $path;
6499 &read_am_file ($path);
6503 # This isn't an error; it is probably a continued rule.
6504 # In fact, this is what we assume.
6506 $output_trailer .= $comment . $spacing;
6507 $output_trailer .= &make_condition (@conditional_stack);
6508 $output_trailer .= $_;
6509 $comment = $spacing = '';
6513 $_ = $am_file->getline;
6516 $output_trailer .= $comment;
6518 if (join (' ', @saved_cond_stack) ne join (' ', @conditional_stack))
6520 if (@conditional_stack)
6522 &am_error ("unterminated conditionals: @conditional_stack");
6526 # FIXME: better error message here.
6527 &am_error ("conditionals not nested in include file");
6533 # define_standard_variables ()
6534 # ----------------------------
6535 # A helper for read_main_am_file which initializes configure variables
6536 # and variables from header-vars.am. This is a subr so we can call it
6538 sub define_standard_variables
6540 my $saved_output_vars = $output_vars;
6541 my ($comments, $variables, $rules) =
6542 &file_contents_internal ('header-vars',
6543 ('BUILD' => $seen_canonical == $AC_CANONICAL_SYSTEM,
6544 'HOST' => $seen_canonical,
6545 'TARGET' => $seen_canonical == $AC_CANONICAL_SYSTEM,
6546 'top_builddir' => backname ($relative_dir)));
6548 # This will output the definitions in $output_vars, which we don't
6550 foreach my $var (sort keys %configure_vars)
6552 &define_configure_variable ($var);
6553 push (@var_list, $var);
6556 # ... hence, we restore $output_vars.
6557 $output_vars = $saved_output_vars . $comments . $rules;
6560 # Read main am file.
6561 sub read_main_am_file
6565 # This supports the strange variable tricks we are about to play.
6566 if (scalar keys %conditional > 0)
6569 &prog_error ("variable defined before read_main_am_file");
6572 # Generate copyright header for generated Makefile.in.
6573 # We do discard the output of predefined variables, handled below.
6574 $output_vars = ("# $in_file_name generated automatically by automake "
6575 . $VERSION . " from $am_file_name.\n");
6576 $output_vars .= $gen_copyright;
6578 # We want to predefine as many variables as possible. This lets
6579 # the user set them with `+=' in Makefile.am. However, we don't
6580 # want these initial definitions to end up in the output quite
6581 # yet. So we just load them, but output them later.
6582 &define_standard_variables;
6584 # Read user file, which might override some of our values.
6585 &read_am_file ($amfile);
6587 # Ouput all the Automake variables. If the user changed one, then
6588 # it is now marked as owned by the user.
6589 foreach my $var (uniq @var_list)
6591 # Don't process user variables.
6592 variable_output ($var)
6593 unless !$var_is_am{$var};
6596 # Now dump the user variables that were defined. We do it in the same
6597 # order in which they were defined (skipping duplicates).
6598 foreach my $var (uniq @var_list)
6600 # Don't process Automake variables.
6601 variable_output ($var)
6602 unless $var_is_am{$var};
6606 ################################################################
6609 # &flatten ($STRING)
6610 # ------------------
6611 # Flatten the $STRING and return the result.
6626 # &make_paragraphs ($MAKEFILE, [%TRANSFORM])
6627 # ------------------------------------------
6628 # Load a $MAKEFILE, apply the %TRANSFORM, and return it as a list of
6630 sub make_paragraphs ($%)
6632 my ($file, %transform) = @_;
6634 # Complete %transform with global options and make it a Perl
6637 # We don't use IGNORE_PATTERN because it contains $ which
6638 # prevents us from matching the end of line.
6639 "s/##([^#\n].*)?\\n//gmo;"
6640 . &transform (%transform,
6642 'CYGNUS' => $cygnus_mode,
6644 => $seen_maint_mode ? '@MAINTAINER_MODE_TRUE@' : '',
6646 'SHAR' => $options{'dist-shar'} || 0,
6647 'BZIP2' => $options{'dist-bzip2'} || 0,
6648 'ZIP' => $options{'dist-zip'} || 0,
6649 'COMPRESS' => $options{'dist-tarZ'} || 0,
6651 'INSTALL-INFO' => !$options{'no-installinfo'},
6652 'INSTALL-MAN' => !$options{'no-installman'},
6653 'CK-NEWS' => $options{'check-news'} || 0,
6655 'SUBDIRS' => &variable_defined ('SUBDIRS'),
6656 'TOPDIR' => backname ($relative_dir),
6657 'TOPDIR_P' => $relative_dir eq '.',
6658 'CONFIGURE-AC' => $configure_ac,
6660 'LIBTOOL' => defined $configure_vars{'LIBTOOL'})
6661 # We don't need more than two consecutive new-lines.
6662 . 's/\n{3,}/\n\n/g';
6664 # Swallow the file and apply the COMMAND.
6665 my $fc_file = new IO::File ("< $file");
6668 die "$me: installation error: cannot open `$file'\n";
6671 print "$me: reading $file\n"
6673 my $saved_dollar_slash = $/;
6675 $_ = $fc_file->getline;
6676 $/ = $saved_dollar_slash;
6681 # A rule has three parts: a list of targets, a list of dependencies,
6682 # and optionally actions.
6684 "^($TARGET_PATTERN(?:(?:\\\\\n|\\s)+$TARGET_PATTERN)*) *:([^=].*|)\$";
6687 # Split at unescaped new lines.
6688 my @lines = split (/(?<!\\)\n/, $content);
6691 while (defined ($_ = shift @lines))
6693 my $paragraph = "$_";
6694 # If we are a rule, eat as long as we start with a tab.
6695 if (/$RULE_PATTERN/smo)
6697 while (defined ($_ = shift @lines) && $_ =~ /^\t/)
6699 $paragraph .= "\n$_";
6701 unshift (@lines, $_);
6704 # If we are a comments, eat as much comments as you can.
6705 elsif (/$COMMENT_PATTERN/smo)
6707 while (defined ($_ = shift @lines)
6708 && $_ =~ /$COMMENT_PATTERN/smo)
6710 $paragraph .= "\n$_";
6712 unshift (@lines, $_);
6715 push @res, $paragraph;
6724 # ($COMMENT, $VARIABLES, $RULES)
6725 # &file_contents_internal ($BASENAME, [%TRANSFORM])
6726 # -------------------------------------------------
6727 # Return contents of a file from $am_dir, automatically skipping
6728 # macros or rules which are already known.
6729 sub file_contents_internal ($%)
6731 my ($basename, %transform) = @_;
6732 my $file = $am_dir . '/' . $basename . '.am';
6734 # A rule has three parts: a list of targets, a list of dependencies,
6735 # and optionally actions.
6737 "^($TARGET_PATTERN(?:(?:\\\\\n|\\s)+$TARGET_PATTERN)*) *:([^=].*|)\$";
6739 my $result_vars = '';
6740 my $result_rules = '';
6743 my @cond_stack = ();
6746 foreach (make_paragraphs ($file, %transform))
6749 &am_file_error ("$basename.am",
6750 "blank line following trailing backslash:\n$_")
6752 &am_file_error ("$basename.am",
6753 "comment following trailing backslash:\n$_")
6758 # Stick empty line before the incoming macro or rule.
6761 elsif (/$COMMENT_PATTERN/mso)
6763 # Stick comments before the incoming macro or rule.
6767 # Handling the conditionals.
6768 elsif (/$IF_PATTERN/o)
6771 &am_line_error ($., "$new_cond does not appear in AM_CONDITIONAL")
6772 if ! $configure_cond{$new_cond} && $new_cond !~ /^TRUE|FALSE$/;
6774 ($new_cond =~ /^TRUE|FALSE$/) ? "$new_cond" : "${new_cond}_TRUE");
6775 $cond = conditional_string (@cond_stack);
6777 elsif (/$ELSE_PATTERN/o)
6781 &am_error ("else without if");
6783 elsif ($cond_stack[$#cond_stack] =~ /_FALSE$/)
6785 &am_error ("else after else");
6789 $cond_stack[$#cond_stack] =
6790 condition_negate ($cond_stack[$#cond_stack]);
6791 $cond = conditional_string (@cond_stack);
6794 elsif (/$ENDIF_PATTERN/o)
6798 &am_error ("endif without if");
6803 $cond = conditional_string (@cond_stack);
6808 elsif (/$RULE_PATTERN/mso)
6810 # Separate relationship from optional actions: the first
6811 # `new-line tab" not preceded by backslash (continuation
6813 # I'm quite shoked! It seems that (\\\n|[^\n]) is not the
6814 # same as `([^\n]|\\\n)!!! Don't swap it, it breaks.
6816 /^((?:\\\n|[^\n])*)(?:\n(\t.*))?$/som;
6817 my ($relationship, $actions) = ($1, $2 || '');
6819 # Separate targets from dependencies: the first colon.
6820 $relationship =~ /^([^:]+\S+) *: *(.*)$/som;
6821 my ($targets, $dependencies) = ($1, $2);
6822 # Remove the escaped new lines.
6823 # I don't know why, but I have to use a tmp $flat_deps.
6824 my $flat_deps = &flatten ($dependencies);
6825 my @deps = split (' ', $flat_deps);
6827 foreach (split (' ' , $targets))
6829 # FIXME: We are not robust to people defining several targets
6830 # at once, only some of them being in %dependencies.
6832 # Output only if not in FALSE.
6833 if (defined $dependencies{$_}
6834 && $cond ne 'FALSE')
6836 &depend ($_, @deps);
6837 $actions{$_} .= $actions;
6841 # Free lance dependency. Output the rule for all the
6842 # targets instead of one by one.
6843 if (!defined $targets{$targets}
6844 && $cond ne 'FALSE')
6846 $result_rules .= "$separator$comment$paragraph\n";
6847 rule_define ($targets, 1, $cond, $.);
6849 $comment = $separator = '';
6854 elsif (/$MACRO_PATTERN/mso)
6856 my ($var, $type, $val) = ($1, $2, $3);
6857 &prog_error ("$file:$.: macro `$var' with trailing backslash")
6860 # Accumulating variables must not be output.
6861 $am_vars{$var} .= "$separator$comment";
6862 macro_define ($var, 1, $type, $cond, $val, $.);
6863 push (@var_list, $var);
6865 # If the user has set some variables we were in charge
6866 # of (which is detected by the first reading of
6867 # `header-vars.am'), we must not output them.
6868 $result_vars .= "$separator$comment$_\n"
6869 if $type ne '+' && $var_is_am{$var} && $cond ne 'FALSE';
6871 $comment = $separator = '';
6875 # This isn't an error; it is probably some tokens which
6876 # configure is supposed to replace, such as `@SET-MAKE@',
6877 # or some part of a rule cut by an if/endif.
6878 if ($cond ne 'FALSE')
6880 $result_rules .= "$separator$comment$_\n";
6882 $comment = $separator = '';
6886 return ($comment, $result_vars, $result_rules);
6891 # &file_contents ($BASENAME, [%TRANSFORM])
6892 # ----------------------------------------
6893 # Return contents of a file from $am_dir, automatically skipping
6894 # macros or rules which are already known.
6895 sub file_contents ($%)
6897 my ($basename, %transform) = @_;
6898 my ($comments, $variables, $rules) = file_contents_internal ($basename,
6900 return "$comments$variables$rules";
6905 # &transform (%PAIRS)
6906 # -------------------
6907 # Foreach ($TOKEN, $VAL) in %PAIRS produce a replacement expression suitable
6908 # for file_contents which:
6909 # - replaces @$TOKEN@ with $VALUE,
6910 # - enables/disables ?$TOKEN?.
6916 while (my ($token, $val) = each %pairs)
6918 $result .= "s/\Q%$token%\E/\Q$val\E/gm;";
6921 $result .= "s/\Q?$token?\E//gm;s/^.*\Q?!$token?\E.*\\n//gm;";
6922 $result .= "s/\Q%?$token%\E/TRUE/gm;s/\Q%!$token%\E/FALSE/gm;";
6926 $result .= "s/\Q?!$token?\E//gm;s/^.*\Q?$token?\E.*\\n//gm;";
6927 $result .= "s/\Q%?$token%\E/FALSE/gm;s/\Q%!$token%\E/TRUE/gm;";
6935 # Find all variable prefixes that are used for install directories. A
6936 # prefix `zar' qualifies iff:
6937 # * `zardir' is a variable.
6938 # * `zar_PRIMARY' is a variable.
6939 sub am_primary_prefixes
6941 my ($primary, $can_dist, @prefixes) = @_;
6944 grep ($valid{$_} = 0, @prefixes);
6945 $valid{'EXTRA'} = 0;
6946 foreach my $varname (keys %conditional)
6948 # Automake is allowed to define variables that look like they
6949 # are magic variables, such as INSTALL_DATA.
6951 if $var_is_am{$varname};
6953 if ($varname =~ /^(nobase_)?(dist_|nodist_)?(.*)_$primary$/)
6955 my ($base, $dist, $X) = ($1 || '', $2 || '', $3 || '');
6956 if ($dist ne '' && ! $can_dist)
6958 # Note that a configure variable is always legitimate.
6959 # It is natural to name such variables after the
6960 # primary, so we explicitly allow it.
6961 if (! defined $configure_vars{$varname})
6963 &am_line_error ($varname,
6964 "invalid variable `$varname': `dist' is forbidden");
6967 elsif (! defined $valid{$X} && ! &variable_defined ("${X}dir"))
6969 # Note that a configure variable is always legitimate.
6970 # It is natural to name such variables after the
6971 # primary, so we explicitly allow it.
6972 if (! defined $configure_vars{$varname})
6974 &am_line_error ($varname,
6975 "invalid variable `$varname'");
6980 # Ensure all extended prefixes are actually used.
6981 $valid{"$base$dist$X"} = 1;
6989 # Handle `where_HOW' variable magic. Does all lookups, generates
6990 # install code, and possibly generates code to define the primary
6991 # variable. The first argument is the name of the .am file to munge,
6992 # the second argument is the primary variable (eg HEADERS), and all
6993 # subsequent arguments are possible installation locations. Returns
6994 # list of all values of all _HOW targets.
6996 # FIXME: this should be rewritten to be cleaner. It should be broken
6997 # up into multiple functions.
6999 # Usage is: am_install_var (OPTION..., file, HOW, where...)
7006 my $default_dist = 0;
7009 if ($args[0] eq '-noextra')
7013 elsif ($args[0] eq '-candist')
7017 elsif ($args[0] eq '-defaultdist')
7022 elsif ($args[0] !~ /^-/)
7029 my ($file, $primary, @prefixes) = @args;
7031 # Now that configure substitutions are allowed in where_HOW
7032 # variables, it is an error to actually define the primary. We
7033 # allow `JAVA', as it is customarily used to mean the Java
7034 # interpreter. This is but one of several Java hacks. Similarly,
7035 # `PYTHON' is customarily used to mean the Python interpreter.
7036 &am_line_error ($primary, "`$primary' is an anachronism")
7037 if &variable_defined ($primary)
7038 && ($primary ne 'JAVA' && $primary ne 'PYTHON');
7041 # Look for misspellings. It is an error to have a variable ending
7042 # in a "reserved" suffix whose prefix is unknown, eg
7043 # "bni_PROGRAMS". However, unusual prefixes are allowed if a
7044 # variable of the same name (with "dir" appended) exists. For
7045 # instance, if the variable "zardir" is defined, then
7046 # "zar_PROGRAMS" becomes valid. This is to provide a little extra
7047 # flexibility in those cases which need it.
7048 my %valid = &am_primary_prefixes ($primary, $can_dist, @prefixes);
7050 # If a primary includes a configure substitution, then the EXTRA_
7051 # form is required. Otherwise we can't properly do our job.
7053 my $warned_about_extra = 0;
7058 foreach my $X (sort keys %valid)
7060 my $one_name = $X . '_' . $primary;
7061 if (&variable_defined ($one_name))
7063 my $strip_subdir = 1;
7064 # If subdir prefix should be preserved, do so.
7065 if ($X =~ /^nobase_/)
7072 # If files should be distributed, do so.
7075 if (($default_dist && $one_name !~ /^nodist_/)
7076 || (! $default_dist && $one_name =~ /^dist_/))
7078 &push_dist_common ('$(' . $one_name . ')');
7080 ($nodir_name = $X) =~ s/^(dist|nodist)_//;
7087 # Append actual contents of where_PRIMARY variable to
7089 foreach my $rcurs (&variable_value_as_list ($one_name, 'all'))
7091 # Skip configure substitutions. Possibly bogus.
7092 if ($rcurs =~ /^\@.*\@$/)
7096 if (! $warned_about_extra)
7098 $warned_about_extra = 1;
7099 &am_line_error ($one_name,
7100 "`$one_name' contains configure substitution, but shouldn't");
7103 # Check here to make sure variables defined in
7104 # configure.ac do not imply that EXTRA_PRIMARY
7106 elsif (! defined $configure_vars{$one_name})
7108 $require_extra = $one_name
7115 push (@result, $rcurs);
7118 # A blatant hack: we rewrite each _PROGRAMS primary to
7119 # include EXEEXT when in Cygwin32 mode.
7120 if ($primary eq 'PROGRAMS')
7122 my @conds = &variable_conditions ($one_name);
7125 foreach my $cond (@conds)
7127 my @one_binlist = ();
7128 my @condval = &variable_value_as_list ($one_name,
7130 foreach my $rcurs (@condval)
7132 if ($rcurs =~ /\./ || $rcurs =~ /^\@.*\@$/)
7134 push (@one_binlist, $rcurs);
7138 push (@one_binlist, $rcurs . '$(EXEEXT)');
7142 push (@condvals, $cond);
7143 push (@condvals, join (' ', @one_binlist));
7146 variable_delete ($one_name);
7149 my $cond = shift (@condvals);
7150 my @val = split (' ', shift (@condvals));
7151 &define_pretty_variable ($one_name, $cond, @val);
7155 # "EXTRA" shouldn't be used when generating clean targets,
7156 # all, or install targets.
7159 # We used to warn if EXTRA_FOO was defined uselessly,
7160 # but this was annoying.
7166 push (@check, '$(' . $one_name . ')');
7170 push (@used, '$(' . $one_name . ')');
7173 # Is this to be installed?
7174 my $install_p = $X ne 'noinst' && $X ne 'check';
7176 # If so, with install-exec? (or install-data?).
7177 my $exec_p = (defined $exec_dir_p {$X}
7181 $output_rules .= &file_contents ($file,
7183 'NDIR' => $nodir_name,
7184 'BASE' => $strip_subdir,
7187 'INSTALL' => $install_p));
7191 # The JAVA variable is used as the name of the Java interpreter.
7192 # The PYTHON variable is used as the name of the Python interpreter.
7193 if (@used && $primary ne 'JAVA' && $primary ne 'PYTHON')
7196 &define_pretty_variable ($primary, '', @used);
7197 $output_vars .= "\n";
7200 if ($require_extra && ! &variable_defined ('EXTRA_' . $primary))
7202 &am_line_error ($require_extra,
7203 "`$require_extra' contains configure substitution, but `EXTRA_$primary' not defined");
7206 # Push here because PRIMARY might be configure time determined.
7207 push (@all, '$(' . $primary . ')')
7208 if @used && $primary ne 'JAVA' && $primary ne 'PYTHON';
7210 # Make the result unique. This lets the user use conditionals in
7211 # a natural way, but still lets us program lazily -- we don't have
7212 # to worry about handling a particular object more than once.
7213 return uniq (sort @result);
7217 ################################################################
7219 # Each key in this hash is the name of a directory holding a
7220 # Makefile.in. These variables are local to `is_make_dir'.
7222 my $make_dirs_set = 0;
7227 if (! $make_dirs_set)
7229 foreach my $iter (@configure_input_files)
7231 $make_dirs{dirname ($iter)} = 1;
7233 # We also want to notice Makefile.in's.
7234 foreach my $iter (@other_input_files)
7236 if ($iter =~ /Makefile\.in$/)
7238 $make_dirs{dirname ($iter)} = 1;
7243 return defined $make_dirs{$dir};
7246 ################################################################
7248 # This variable is local to the "require file" set of functions.
7249 my @require_file_paths = ();
7251 # If a file name appears as a key in this hash, then it has already
7252 # been checked for. This variable is local to the "require file"
7254 %require_file_found = ();
7256 # See if we want to push this file onto dist_common. This function
7257 # encodes the rules for deciding when to do so.
7258 sub maybe_push_required_file
7260 my ($dir, $file, $fullfile) = @_;
7262 # FIXME: Once again, special-case `.'.
7263 if ($dir eq $relative_dir || $dir eq '.')
7265 &push_dist_common ($file);
7267 elsif ($relative_dir eq '.' && ! &is_make_dir ($dir))
7269 # If we are doing the topmost directory, and the file is in a
7270 # subdir which does not have a Makefile, then we distribute it
7272 &push_dist_common ($fullfile);
7277 # &require_file_internal ($IS_CONFIGURE, $LINE, $MYSTRICT, @FILES)
7278 # ----------------------------------------------------------------
7279 # Verify that the file must exist in the current directory.
7280 # $MYSTRICT is the strictness level at which this file becomes required.
7282 # Must set require_file_paths before calling this function.
7283 # require_file_paths is set to hold a single directory (the one in
7284 # which the first file was found) before return.
7285 sub require_file_internal
7287 my ($is_configure, $line, $mystrict, @files) = @_;
7289 foreach my $file (@files)
7296 # If we've already looked for it, we're done.
7297 next if defined $require_file_found{$file};
7298 $require_file_found{$file} = 1;
7301 my $dangling_sym = 0;
7302 foreach my $dir (@require_file_paths)
7306 $fullfile = $relative_dir . "/" . $file;
7307 $errdir = $relative_dir unless $errdir;
7311 $fullfile = $dir . "/" . $file;
7312 $errdir = $dir unless $errdir;
7315 # Use different name for "error filename". Otherwise on
7316 # an error the bad file will be reported as eg
7317 # `../../install-sh' when using the default
7319 $errfile = $errdir . '/' . $file;
7321 if (-l $fullfile && ! -f readlink ($fullfile))
7326 elsif (-f $fullfile)
7329 &maybe_push_required_file ($dir, $file, $fullfile);
7335 if ($found_it && ! $force_missing)
7337 # Prune the path list.
7338 @require_file_paths = $save_dir;
7342 if ($strictness >= $mystrict)
7344 if ($dangling_sym && ($force_missing || $add_missing))
7352 # Only install missing files according to our desired
7354 my $message = "required file `$errfile' not found";
7359 # Maybe run libtoolize.
7360 my @syslist = ('libtoolize', '--automake');
7361 push @syslist, '--copy'
7364 && grep ($_ eq $file, @libtoolize_files)
7365 && system (@syslist))
7367 $message = "installing `$errfile'";
7369 $trailer = "; cannot run `libtoolize': $!";
7371 elsif (-f ($am_dir . '/' . $file))
7373 # Install the missing file. Symlink if we
7374 # can, copy if we must. Note: delete the file
7375 # first, in case it is a dangling symlink.
7376 $message = "installing `$errfile'";
7377 # Windows Perl will hang if we try to delete a
7378 # file that doesn't exist.
7379 unlink ($errfile) if -f $errfile;
7380 if ($symlink_exists && ! $copy_missing)
7382 if (! symlink ($am_dir . '/' . $file, $errfile))
7385 $trailer = "; error while making link: $!";
7388 elsif (system ('cp', $am_dir . '/' . $file, $errfile))
7391 $trailer = "\n error while copying";
7395 &maybe_push_required_file (dirname ($errfile),
7399 my $save = $exit_status;
7402 # FIXME: allow actual file to be specified.
7403 &am_conf_line_error ($configure_ac, $line,
7404 "$message$trailer");
7408 &am_line_error ($line, "$message$trailer");
7410 $exit_status = $save if $suppress;
7416 # Like require_file_with_line, but error messages refer to
7417 # configure.ac, not the current Makefile.am.
7418 sub require_file_with_conf_line
7420 @require_file_paths = '.';
7421 &require_file_internal (1, @_);
7424 sub require_file_with_line
7426 @require_file_paths = '.';
7427 &require_file_internal (0, @_);
7432 @require_file_paths = '.';
7433 &require_file_internal (0, '', @_);
7436 # Require a file that is also required by Autoconf. Looks in
7437 # configuration path, as specified by AC_CONFIG_AUX_DIR.
7438 sub require_config_file
7440 @require_file_paths = @config_aux_path;
7441 &require_file_internal (1, '', @_);
7442 my $dir = $require_file_paths[0];
7443 @config_aux_path = @require_file_paths;
7446 $config_aux_dir = '.';
7450 $config_aux_dir = '$(top_srcdir)/' . $dir;
7454 # Assumes that the line number is in Makefile.am.
7455 sub require_conf_file_with_line
7457 @require_file_paths = @config_aux_path;
7458 &require_file_internal (0, @_);
7459 my $dir = $require_file_paths[0];
7460 @config_aux_path = @require_file_paths;
7463 $config_aux_dir = '.';
7467 $config_aux_dir = '$(top_srcdir)/' . $dir;
7471 # Assumes that the line number is in configure.ac.
7472 sub require_conf_file_with_conf_line
7474 @require_file_paths = @config_aux_path;
7475 &require_file_internal (1, @_);
7476 my $dir = $require_file_paths[0];
7477 @config_aux_path = @require_file_paths;
7480 $config_aux_dir = '.';
7484 $config_aux_dir = '$(top_srcdir)/' . $dir;
7488 ################################################################
7490 # Push a list of files onto dist_common.
7491 sub push_dist_common
7493 &prog_error ("push_dist_common run after handle_dist")
7494 if $handle_dist_run;
7495 macro_define ('DIST_COMMON', 1, '+', '', join (' ', @_), '');
7502 $strictness_name = $_[0];
7503 if ($strictness_name eq 'gnu')
7507 elsif ($strictness_name eq 'gnits')
7509 $strictness = $GNITS;
7511 elsif ($strictness_name eq 'foreign')
7513 $strictness = $FOREIGN;
7517 die "$me: level `$strictness_name' not recognized\n";
7522 ################################################################
7524 # Ensure a file exists.
7529 my $touch = new IO::File (">> $file");
7533 # Glob something. Do this to avoid indentation screwups everywhere we
7534 # want to glob. Gross!
7541 # Remove one level of brackets and strip leading spaces,
7542 # as does m4 to function arguments.
7548 my @letters = split //;
7557 next if $depth == 1;
7562 next if $depth == 0;
7563 # don't count orphan right brackets
7564 $depth = 0 if $depth < 0;
7568 return join '', @result;
7571 ################################################################
7573 # Print an error message and set exit status.
7576 warn "$me: ${am_file}.am: @_\n";
7581 # am_file_error ($FILE, @ARGS)
7582 # ----------------------------
7585 my ($file, @args) = @_;
7587 warn "$file: @args\n";
7593 my ($symbol, @args) = @_;
7595 if ($symbol && "$symbol" ne '-1')
7597 my $file = "${am_file}.am";
7599 if ($symbol =~ /^\d+$/)
7601 # SYMBOL is a line number, so just add the colon.
7602 $file .= ':' . $symbol;
7604 elsif (defined $content_lines{$symbol})
7606 # SYMBOL is a variable defined in Makefile.am, so add the
7607 # line number we saved from there.
7608 $file .= ':' . $content_lines{$symbol};
7610 elsif (defined $configure_vars{$symbol})
7612 # SYMBOL is a variable defined in configure.ac, so add the
7613 # appropriate line number.
7614 $file = $configure_vars{$symbol};
7618 # Couldn't find the line number.
7620 warn $file, ": @args\n";
7629 # Like am_error, but while scanning configure.ac.
7632 # FIXME: can run in subdirs.
7633 warn "$me: $configure_ac: @_\n";
7637 # Error message with line number referring to configure.ac.
7638 sub am_conf_line_error
7640 my ($file, $line, @args) = @_;
7644 warn "$file: $line: @args\n";
7649 &am_conf_error (@args);
7653 # Warning message with line number referring to configure.ac.
7654 # Does not affect exit_status
7655 sub am_conf_line_warning
7657 my $saved_exit_status = $exit_status;
7658 &am_conf_line_error (@_);
7659 $exit_status = $saved_exit_status;
7662 # Tell user where our aclocal.m4 is, but only once.
7663 sub keyed_aclocal_warning
7666 warn "$me: macro `$key' can be generated by `aclocal'\n";
7669 # Print usage information.
7673 Usage: $0 [OPTION] ... [Makefile]...
7675 Generate Makefile.in for configure from Makefile.am.
7678 --help print this help, then exit
7679 --version print version number, then exit
7680 -v, --verbose verbosely list files processed
7681 -o, --output-dir=DIR put generated Makefile.in's into DIR
7682 --no-force only update Makefile.in's that are out of date
7684 Dependency tracking:
7685 -i, --ignore-deps disable dependency tracking code
7686 --include-deps enable dependency tracking code
7689 --cygnus assume program is part of Cygnus-style tree
7690 --foreign set strictness to foreign
7691 --gnits set strictness to gnits
7692 --gnu set strictness to gnu
7695 -a, --add-missing add missing standard files to package
7696 --amdir=DIR directory storing config files
7697 -c, --copy with -a, copy missing files (default is symlink)
7698 -f, --force-missing force update of standard files
7703 foreach my $iter (sort ((@common_files, @common_sometimes)))
7705 push (@lcomm, $iter) unless $iter eq $last;
7709 my ($one, $two, $three, $four, $max);
7710 print "\nFiles which are automatically distributed, if found:\n";
7711 format USAGE_FORMAT =
7712 @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<
7713 $one, $two, $three, $four
7715 $~ = "USAGE_FORMAT";
7716 $max = int (($#lcomm + 1) / 4);
7718 for (my $i = 0; $i < $max; ++$i)
7721 $two = $lcomm[$max + $i];
7722 $three = $lcomm[2 * $max + $i];
7723 $four = $lcomm[3 * $max + $i];
7727 my $mod = ($#lcomm + 1) % 4;
7730 $one = $lcomm[$max];
7731 $two = ($mod > 1) ? $lcomm[2 * $max] : '';
7732 $three = ($mod > 2) ? $lcomm[3 * $max] : '';
7733 $four = ($mod > 3) ? $lcomm[4 * $max] : '';
7737 print "\nReport bugs to <bug-automake\@gnu.org>.\n";
7744 # Print version information
7748 automake (GNU $PACKAGE) $VERSION
7749 Written by Tom Tromey <tromey\@cygnus.com>.
7751 Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
7752 Free Software Foundation, Inc.
7753 This is free software; see the source for copying conditions. There is NO
7754 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.