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>.
34 my $prefix = "@prefix@";
35 my $perllibdir = $ENV{'perllibdir'} || "@datadir@/@PACKAGE@";
36 unshift @INC, "$perllibdir";
40 struct (# Short name of the language (c, f77...).
42 # Nice name of the language (C, Fortran 77...).
45 # List of configure variables which must be defined.
49 # `pure' is `1' or `'. A `pure' language is one where, if
50 # all the files in a directory are of that language, then we
51 # do not require the C compiler or any code to call it.
56 # Name of the compiling variable (COMPILE).
58 # Content of the compiling variable.
60 # Flag to require compilation without linking (-c).
61 'compile_flag' => "\$",
64 # Should the flag be defined as a configure variable.
65 # Defaults to true. FIXME: this should go away once
66 # we move to autoconf tracing.
67 'define_flag' => "\$",
69 # The file to use when generating rules for this language.
70 # The default is 'depend2'.
73 # Name of the linking variable (LINK).
75 # Content of the linking variable.
78 # Name of the linker variable (LD).
80 # Content of the linker variable ($(CC)).
83 # Flag to specify the output file (-o).
84 'output_flag' => "\$",
87 # This is a subroutine which is called whenever we finally
88 # determine the context in which a source file will be
90 '_target_hook' => "\$");
96 if (defined $self->_finish)
102 sub target_hook ($$$$)
105 if (defined $self->_target_hook)
107 &{$self->_target_hook} (@_);
114 use strict 'vars', 'subs';
118 my $me = basename ($0);
125 # Parameters set by configure. Not to be changed. NOTE: assign
126 # VERSION as string so that eg version 0.30 will print correctly.
127 my $VERSION = "@VERSION@";
128 my $PACKAGE = "@PACKAGE@";
129 my $prefix = "@prefix@";
130 my $libdir = "@datadir@/@PACKAGE@";
133 my $IGNORE_PATTERN = '^\s*##([^#\n].*)?\n';
134 my $WHITE_PATTERN = '^\s*$';
135 my $COMMENT_PATTERN = '^#';
136 my $TARGET_PATTERN='[$a-zA-Z_.@][-.a-zA-Z0-9_(){}/$+@]*';
137 # A rule has three parts: a list of targets, a list of dependencies,
138 # and optionally actions.
140 "^($TARGET_PATTERN(?:(?:\\\\\n|\\s)+$TARGET_PATTERN)*) *:([^=].*|)\$";
142 my $SUFFIX_RULE_PATTERN = '^\.([a-zA-Z0-9+]+)\.([a-zA-Z0-9+]+)$';
143 # Only recognize leading spaces, not leading tabs. If we recognize
144 # leading tabs here then we need to make the reader smarter, because
145 # otherwise it will think rules like `foo=bar; \' are errors.
146 my $MACRO_PATTERN = '^[A-Za-z0-9_@]+$';
147 my $ASSIGNMENT_PATTERN = '^ *([^ \t=:+]*)\s*([:+]?)=\s*(.*)$';
148 # This pattern recognizes a Gnits version id and sets $1 if the
149 # release is an alpha release. We also allow a suffix which can be
150 # used to extend the version number with a "fork" identifier.
151 my $GNITS_VERSION_PATTERN = '\d+\.\d+([a-z]|\.\d+)?(-[A-Za-z0-9]+)?';
152 my $IF_PATTERN = '^if\s+(!?)\s*([A-Za-z][A-Za-z0-9_]*)\s*(?:#.*)?$';
153 my $ELSE_PATTERN = '^else(?:\s+(!?)\s*([A-Za-z][A-Za-z0-9_]*))?\s*(?:#.*)?$';
154 my $ENDIF_PATTERN = '^endif(?:\s+(!?)\s*([A-Za-z][A-Za-z0-9_]*))?\s*(?:#.*)?$';
155 my $PATH_PATTERN='(\w|[/.-])+';
156 # This will pass through anything not of the prescribed form.
157 my $INCLUDE_PATTERN = ('^include\s+'
158 . '((\$\(top_srcdir\)/' . $PATH_PATTERN . ')'
159 . '|(\$\(srcdir\)/' . $PATH_PATTERN . ')'
160 . '|([^/\$]' . $PATH_PATTERN. '))\s*(#.*)?$');
162 # Some regular expressions. One reason to put them here is that it
163 # makes indentation work better in Emacs.
164 my $AC_CONFIG_AUX_DIR_PATTERN = 'AC_CONFIG_AUX_DIR\(([^)]+)\)';
165 my $AM_INIT_AUTOMAKE_PATTERN = 'AM_INIT_AUTOMAKE\([^,]*,([^,)]+)[,)]';
166 my $AM_PACKAGE_VERSION_PATTERN = '^\s*\[?([^]\s]+)\]?\s*$';
168 # This handles substitution references like ${foo:.a=.b}.
169 my $SUBST_REF_PATTERN = "^([^:]*):([^=]*)=(.*)\$";
171 # Note that there is no AC_PATH_TOOL. But we don't really care.
172 my $AC_CHECK_PATTERN = 'AC_(CHECK|PATH)_(PROG|PROGS|TOOL)\(\[?(\w+)';
173 my $AM_MISSING_PATTERN = 'AM_MISSING_PROG\(\[?(\w+)';
174 # Just check for alphanumeric in AC_SUBST. If you do AC_SUBST(5),
176 my $AC_SUBST_PATTERN = 'AC_SUBST\(\[?(\w+)';
177 my $AM_CONDITIONAL_PATTERN = 'AM_CONDITIONAL\(\[?(\w+)';
178 # Match `-d' as a command-line argument in a string.
179 my $DASH_D_PATTERN = "(^|\\s)-d(\\s|\$)";
181 # Constants to define the "strictness" level.
186 # Values for AC_CANONICAL_*
187 my $AC_CANONICAL_HOST = 1;
188 my $AC_CANONICAL_SYSTEM = 2;
190 # Values indicating when something should be cleaned. Right now we
191 # only need to handle `mostly'- and `dist'-clean; add more as
193 my $MOSTLY_CLEAN = 0;
196 # Files installed by libtoolize.
197 my @libtoolize_files = ('ltmain.sh', 'config.guess', 'config.sub');
198 # ltconfig appears here for compatibility with old versions of libtool.
199 my @libtoolize_sometimes = ('ltconfig', 'ltcf-c.sh', 'ltcf-cxx.sh',
202 # Commonly found files we look for and automatically include in
206 'README', 'THANKS', 'TODO', 'NEWS', 'COPYING', 'COPYING.LIB',
207 'INSTALL', 'ABOUT-NLS', 'ChangeLog', 'configure.ac',
208 'configure.in', 'configure', 'config.guess', 'config.sub',
209 'AUTHORS', 'BACKLOG', 'ABOUT-GNU', 'libversion.in',
210 'mdate-sh', 'mkinstalldirs', 'install-sh', 'texinfo.tex',
211 'ansi2knr.c', 'ansi2knr.1', 'elisp-comp',
212 # ltconfig appears here for compatibility with old versions
214 'ylwrap', 'acinclude.m4', @libtoolize_files, @libtoolize_sometimes,
215 'missing', 'depcomp', 'compile', 'py-compile'
218 # Commonly used files we auto-include, but only sometimes.
219 my @common_sometimes =
221 'aclocal.m4', 'acconfig.h', 'config.h.top',
222 'config.h.bot', 'stamp-h.in', 'stamp-vti'
225 # Copyright on generated Makefile.ins.
226 my $gen_copyright = "\
227 # Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
228 # Free Software Foundation, Inc.
229 # This Makefile.in is free software; the Free Software Foundation
230 # gives unlimited permission to copy and/or distribute it,
231 # with or without modifications, as long as this notice is preserved.
233 # This program is distributed in the hope that it will be useful,
234 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
235 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
236 # PARTICULAR PURPOSE.
239 # These constants are returned by lang_*_rewrite functions.
240 # LANG_SUBDIR means that the resulting object file should be in a
241 # subdir if the source file is. In this case the file name cannot
242 # have `..' components.
244 my $LANG_PROCESS = 1;
247 # Directories installed during 'install-exec' phase.
266 # Map from obsolete macros to hints for new macros.
267 # If you change this, change the corresponding list in aclocal.in.
268 # FIXME: should just put this into a single file.
269 my %obsolete_macros =
271 'AC_FEATURE_CTYPE' => "use `AC_HEADER_STDC'",
272 'AC_FEATURE_ERRNO' => "add `strerror' to `AC_REPLACE_FUNCS(...)'",
273 'AC_FEATURE_EXIT' => '',
274 'AC_SYSTEM_HEADER' => '',
276 # Note that we do not handle this one, because it is still run
277 # from AM_CONFIG_HEADER. So we deal with it specially in
278 # &scan_autoconf_files.
279 # 'AC_CONFIG_HEADER' => "use `AM_CONFIG_HEADER'",
281 'fp_C_PROTOTYPES' => "use `AM_C_PROTOTYPES'",
282 'fp_PROG_CC_STDC' => "use `AM_PROG_CC_STDC'",
283 'fp_PROG_INSTALL' => "use `AC_PROG_INSTALL'",
284 'fp_WITH_DMALLOC' => "use `AM_WITH_DMALLOC'",
285 'fp_WITH_REGEX' => "use `AM_WITH_REGEX'",
286 'gm_PROG_LIBTOOL' => "use `AM_PROG_LIBTOOL'",
287 'jm_MAINTAINER_MODE' => "use `AM_MAINTAINER_MODE'",
288 'md_TYPE_PTRDIFF_T' => "use `AM_TYPE_PTRDIFF_T'",
289 'ud_PATH_LISPDIR' => "use `AM_PATH_LISPDIR'",
290 'ud_GNU_GETTEXT' => "use `AM_GNU_GETTEXT'",
292 # Now part of autoconf proper, under a different name.
293 'AM_FUNC_FNMATCH' => "use `AC_FUNC_FNMATCH'",
294 'fp_FUNC_FNMATCH' => "use `AC_FUNC_FNMATCH'",
295 'AM_SANITY_CHECK_CC' => "automatically done by `AC_PROG_CC'",
296 'AM_PROG_INSTALL' => "use `AC_PROG_INSTALL'",
297 'AM_EXEEXT' => "use `AC_EXEEXT'",
298 'AM_CYGWIN32' => "use `AC_CYGWIN'",
299 'AM_MINGW32' => "use `AC_MINGW32'",
300 'AM_FUNC_MKTIME' => "use `AC_FUNC_MKTIME'",
302 # These aren't quite obsolete.
306 # Regexp to match the above macros.
307 my $obsolete_rx = '\b(' . join ('|', keys %obsolete_macros) . ')\b';
311 ## ---------------------------------- ##
312 ## Variables related to the options. ##
313 ## ---------------------------------- ##
315 # TRUE if we should always generate Makefile.in.
316 my $force_generation = 1;
318 # Strictness level as set on command line.
319 my $default_strictness = $GNU;
321 # Name of strictness level, as set on command line.
322 my $default_strictness_name = 'gnu';
324 # This is TRUE if automatic dependency generation code should be
325 # included in generated Makefile.in.
326 my $cmdline_use_dependencies = 1;
328 # TRUE if in verbose mode.
331 # This holds our (eventual) exit status. We don't actually exit until
332 # we have processed all input files.
335 # From the Perl manual.
336 my $symlink_exists = (eval 'symlink ("", "");', $@ eq '');
338 # TRUE if missing standard files should be installed.
341 # TRUE if we should copy missing files; otherwise symlink if possible.
342 my $copy_missing = 0;
344 # TRUE if we should always update files that we know about.
345 my $force_missing = 0;
348 ## ---------------------------------------- ##
349 ## Variables filled during files scanning. ##
350 ## ---------------------------------------- ##
352 # Name of the top autoconf input: `configure.ac' or `configure.in'.
353 my $configure_ac = '';
355 # Files found by scanning configure.ac for LIBOBJS.
358 # True if AM_C_PROTOTYPES appears in configure.ac.
359 my $am_c_prototypes = 0;
361 # Names used in AC_CONFIG_HEADER call. @config_fullnames holds the
362 # name which appears in AC_CONFIG_HEADER, colon and all.
363 # @config_names holds the file names. @config_headers holds the '.in'
364 # files. Ordinarily these are similar, but they can be different if
365 # the weird "NAME:FILE" syntax is used.
366 my @config_fullnames = ();
367 my @config_names = ();
368 my @config_headers = ();
369 # Line number at which AC_CONFIG_HEADER appears in configure.ac.
370 my $config_header_line = 0;
372 # Directory where output files go. Actually, output files are
373 # relative to this directory.
374 my $output_directory = '.';
376 # List of Makefile.am's to process, and their corresponding outputs.
377 my @input_files = ();
378 my %output_files = ();
380 # Complete list of Makefile.am's that exist.
381 my @configure_input_files = ();
383 # List of files in AC_OUTPUT without Makefile.am, and their outputs.
384 my @other_input_files = ();
385 # Line number at which AC_OUTPUT seen.
386 my $ac_output_line = 0;
388 # List of directories to search for configure-required files. This
389 # can be set by AC_CONFIG_AUX_DIR.
390 my @config_aux_path = ('.', '..', '../..');
391 my $config_aux_dir = '';
392 my $config_aux_dir_set_in_configure_in = 0;
394 # Whether AM_GNU_GETTEXT has been seen in configure.ac.
395 my $seen_gettext = 0;
396 # Line number at which AM_GNU_GETTEXT seen.
397 my $ac_gettext_line = 0;
399 # TRUE if AC_DECL_YYTEXT was seen.
400 my $seen_decl_yytext = 0;
402 # TRUE if we've seen AC_CANONICAL_(HOST|SYSTEM). The presence of
403 # AC_CHECK_TOOL also sets this.
404 my $seen_canonical = 0;
406 # TRUE if we've seen AC_PROG_LIBTOOL.
407 my $seen_libtool = 0;
408 my $libtool_line = 0;
410 # TRUE if we've seen AM_MAINTAINER_MODE.
411 my $seen_maint_mode = 0;
413 # Actual version we've seen.
414 my $package_version = '';
416 # Line number where we saw version definition.
417 my $package_version_line = 0;
419 # TRUE if we've seen AM_PATH_LISPDIR.
420 my $seen_lispdir = 0;
422 # TRUE if we've seen AM_PATH_PYTHON.
423 my $seen_pythondir = 0;
425 # TRUE if we've seen AC_OBJEXT.
428 # TRUE if we've seen AC_ENABLE_MULTILIB.
429 my $seen_multilib = 0;
431 # TRUE if we've seen AM_PROG_CC_C_O
434 # TRUE if we've seen AM_INIT_AUTOMAKE.
435 my $seen_init_automake = 0;
437 # Hash table of discovered configure substitutions. Keys are names,
438 # values are `FILE:LINE' strings which are used by error message
440 my %configure_vars = ();
442 # This is used to keep track of which variable definitions we are
443 # scanning. It is only used in certain limited ways, but it has to be
444 # global. It is declared just for documentation purposes.
445 my %vars_scanned = ();
447 # TRUE if --cygnus seen.
450 # Hash table of AM_CONDITIONAL variables seen in configure.
451 my %configure_cond = ();
453 # This maps extensions onto language names.
454 my %extension_map = ();
456 # List of the DIST_COMMON files we discovered while reading
458 my $configure_dist_common = '';
460 # This maps languages names onto objects.
463 # List of targets we must always output.
464 # FIXME: Complete, and remove falsely required targets.
465 my %required_targets =
476 # FIXME: Not required, temporary hacks.
477 # Well, actually they are sort of required: the -recursive
478 # targets will run them anyway...
481 'install-data-am' => 1,
482 'install-exec-am' => 1,
483 'installcheck-am' => 1,
491 ################################################################
493 ## ------------------------------------------ ##
494 ## Variables reset by &initialize_per_input. ##
495 ## ------------------------------------------ ##
497 # Basename and relative dir of the input file.
501 # Same but wrt Makefile.in.
505 # These two variables are used when generating each Makefile.in.
506 # They hold the Makefile.in until it is ready to be printed.
513 # Suffixes found during a run.
516 # Handling the variables.
519 # - $var_value{$VAR}{$COND} is its value associated to $COND,
520 # - $var_line{$VAR} is where it has been defined,
521 # - $var_comment{$VAR} are the comments associated to it.
522 # - $var_type{$VAR} is how it has been defined (`', `+', or `:'),
523 # - $var_is_am{$VAR} is true if the variable is owned by Automake.
530 # This holds a 1 if a particular variable was examined.
533 # This holds the names which are targets. These also appear in
537 # Same as %VAR_VALUE, but for targets.
538 my %target_conditional;
540 # This is the conditional stack.
543 # This holds the set of included files.
546 # This holds a list of directories which we must create at `dist'
547 # time. This is used in some strange scenarios involving weird
548 # AC_OUTPUT commands.
551 # List of dependencies for the obvious targets.
556 # Holds the dependencies of targets which dependencies are factored.
557 # Typically, `.PHONY' will appear in plenty of *.am files, but must
558 # be output once. Arguably all pure dependencies could be subject
559 # to this factorization, but it is not unpleasant to have paragraphs
560 # in Makefile: keeping related stuff altogether.
563 # Holds the factored actions. Tied to %DEPENDENCIES, i.e., filled
564 # only when keys exists in %DEPENDENCIES.
567 # A list of files deleted by `maintainer-clean'.
568 my @maintainer_clean_files;
570 # Keys in this hash table are object files or other files in
571 # subdirectories which need to be removed. This only holds files
572 # which are created by compilations. The value in the hash indicates
573 # when the file should be removed.
574 my %compile_clean_files;
576 # Value of `$(SOURCES)', used by tags.am.
578 # Sources which go in the distribution.
581 # This hash maps object file names onto their corresponding source
582 # file names. This is used to ensure that each object is created
583 # by a single source file.
586 # This keeps track of the directories for which we've already
587 # created `.dirstamp' code.
597 # Options from AUTOMAKE_OPTIONS.
600 # Whether or not dependencies are handled. Can be further changed
602 my $use_dependencies;
604 # This is a list of all targets to run during "make dist".
607 # Keys in this hash are the basenames of files which must depend
611 # This maps the source extension of a suffix rule to its
612 # corresponding output extension.
615 # This is the name of the redirect `all' target to use.
618 # This keeps track of which extensions we've seen (that we care
622 # This is random scratch space for the language finish functions.
623 # Don't randomly overwrite it; examine other uses of keys first.
624 my %language_scratch;
626 # We keep track of which objects need special (per-executable)
627 # handling on a per-language basis.
628 my %lang_specific_files;
630 # This is set when `handle_dist' has finished. Once this happens,
631 # we should no longer push on dist_common.
634 # Used to store a set of linkers needed to generate the sources currently
635 # under consideration.
638 # True if we need `LINK' defined. This is a hack.
641 # This is the list of such variables to output.
642 # FIXME: Might be useless actually.
645 # Was get_object_extension run?
646 # FIXME: This is a hack. a better switch should be found.
647 my $get_object_extension_was_run;
649 # Contains a stack of `from' parts of variable substitutions currently in
653 # Contains a stack of `to' parts of variable substitutions currently in
657 # Associates a variable name, together with a list of substitutions to be
658 # performed on it, with a number. Used to provide unique names for generated
662 ## --------------------------------- ##
663 ## Forward subroutine declarations. ##
664 ## --------------------------------- ##
665 sub register_language (%);
666 sub file_contents_internal ($$%);
667 sub define_objects_from_sources ($$$$$$$);
670 # &initialize_per_input ()
671 # ------------------------
672 # (Re)-Initialize per-Makefile.am variables.
673 sub initialize_per_input ()
676 $am_relative_dir = '';
683 $output_trailer = '';
699 %target_conditional = ();
707 $am_relative_dir = '';
723 # Installing/uninstalling.
724 'install-data-am' => [],
725 'install-exec-am' => [],
726 'uninstall-am' => [],
729 'uninstall-man' => [],
731 'install-info' => [],
732 'install-info-am' => [],
733 'uninstall-info' => [],
735 'installcheck-am' => [],
739 'mostlyclean-am' => [],
740 'maintainer-clean-am' => [],
741 'distclean-am' => [],
744 'maintainer-clean' => [],
755 @maintainer_clean_files = ();
766 $strictness = $default_strictness;
767 $strictness_name = $default_strictness_name;
771 $use_dependencies = $cmdline_use_dependencies;
781 %extension_seen = ();
783 %language_scratch = ();
785 %lang_specific_files = ();
787 $handle_dist_run = 0;
793 $get_object_extension_was_run = 0;
795 %compile_clean_files = ();
799 ################################################################
801 # Initialize our list of languages that are internally supported.
804 register_language ('name' => 'c',
806 'config_vars' => ['CC'],
810 'compiler' => 'COMPILE',
811 'compile' => '$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)',
815 'link' => '$(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
816 'compile_flag' => '-c',
817 'extensions' => ['c'],
818 '_finish' => \&lang_c_finish);
821 register_language ('name' => 'cxx',
823 'config_vars' => ['CXX'],
824 'linker' => 'CXXLINK',
825 'link' => '$(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
827 'flags' => 'CXXFLAGS',
828 'compile' => '$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)',
829 'compiler' => 'CXXCOMPILE',
830 'compile_flag' => '-c',
831 'output_flag' => '-o',
835 'extensions' => ['c++', 'cc', 'cpp', 'cxx', 'C']);
838 register_language ('name' => 'objc',
839 'Name' => 'Objective C',
840 'config_vars' => ['OBJC'],
841 'linker' => 'OBJCLINK',,
842 'link' => '$(OBJCLD) $(AM_OBJCFLAGS) $(OBJCFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
844 'flags' => 'OBJCFLAGS',
845 'compile' => '$(OBJC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_OBJCFLAGS) $(OBJCFLAGS)',
846 'compiler' => 'OBJCCOMPILE',
847 'compile_flag' => '-c',
848 'output_flag' => '-o',
852 'extensions' => ['m']);
855 register_language ('name' => 'header',
857 'extensions' => ['h', 'H', 'hxx', 'h++', 'hh', 'hpp', 'inc'],
859 '_finish' => sub { });
862 register_language ('name' => 'yacc',
864 'config_vars' => ['YACC'],
867 'compile' => '$(YACC) $(YFLAGS) $(AM_YFLAGS)',
868 'compiler' => 'YACCCOMPILE',
869 'extensions' => ['y'],
870 'rule_file' => 'yacc',
871 '_finish' => \&lang_yacc_finish,
872 '_target_hook' => \&lang_yacc_target_hook);
873 register_language ('name' => 'yaccxx',
874 'Name' => 'Yacc (C++)',
875 'config_vars' => ['YACC'],
876 'rule_file' => 'yacc',
879 'compiler' => 'YACCCOMPILE',
880 'compile' => '$(YACC) $(YFLAGS) $(AM_YFLAGS)',
881 'extensions' => ['y++', 'yy', 'yxx', 'ypp'],
882 '_finish' => \&lang_yacc_finish,
883 '_target_hook' => \&lang_yacc_target_hook);
886 register_language ('name' => 'lex',
888 'config_vars' => ['LEX'],
889 'rule_file' => 'lex',
892 'compile' => '$(LEX) $(LFLAGS) $(AM_LFLAGS)',
893 'compiler' => 'LEXCOMPILE',
894 'extensions' => ['l'],
895 '_finish' => \&lang_lex_finish);
896 register_language ('name' => 'lexxx',
897 'Name' => 'Lex (C++)',
898 'config_vars' => ['LEX'],
899 'rule_file' => 'lex',
902 'compile' => '$(LEX) $(LFLAGS) $(AM_LFLAGS)',
903 'compiler' => 'LEXCOMPILE',
904 'extensions' => ['l++', 'll', 'lxx', 'lpp'],
905 '_finish' => \&lang_lex_finish);
908 register_language ('name' => 'asm',
909 'Name' => 'Assembler',
910 'config_vars' => ['AS', 'ASFLAGS'],
912 'flags' => 'ASFLAGS',
913 # Users can set AM_ASFLAGS to includes DEFS, INCLUDES,
914 # or anything else required. They can also set AS.
915 'compile' => '$(AS) $(AM_ASFLAGS) $(ASFLAGS)',
916 'compiler' => 'ASCOMPILE',
917 'compile_flag' => '-c',
918 'extensions' => ['s', 'S'],
920 # With assembly we still use the C linker.
921 '_finish' => \&lang_c_finish);
924 register_language ('name' => 'f77',
925 'Name' => 'Fortran 77',
926 'linker' => 'F77LINK',
927 'link' => '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
929 'compile' => '$(F77) $(AM_FFLAGS) $(FFLAGS)',
930 'compiler' => 'F77COMPILE',
931 'compile_flag' => '-c',
932 'output_flag' => '-o',
936 'extensions' => ['f', 'for', 'f90']);
938 # Preprocessed Fortran 77
940 # The current support for preprocessing Fortran 77 just involves
941 # passing `$(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS)
942 # $(CPPFLAGS)' as additional flags to the Fortran 77 compiler, since
943 # this is how GNU Make does it; see the `GNU Make Manual, Edition 0.51
944 # for `make' Version 3.76 Beta' (specifically, from info file
945 # `(make)Catalogue of Rules').
947 # A better approach would be to write an Autoconf test
948 # (i.e. AC_PROG_FPP) for a Fortran 77 preprocessor, because not all
949 # Fortran 77 compilers know how to do preprocessing. The Autoconf
950 # macro AC_PROG_FPP should test the Fortran 77 compiler first for
951 # preprocessing capabilities, and then fall back on cpp (if cpp were
953 register_language ('name' => 'ppf77',
954 'Name' => 'Preprocessed Fortran 77',
955 'config_vars' => ['F77'],
956 'linker' => 'F77LINK',
957 'link' => '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
961 'compiler' => 'PPF77COMPILE',
962 'compile' => '$(F77) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FFLAGS) $(FFLAGS)',
963 'compile_flag' => '-c',
964 'output_flag' => '-o',
966 'extensions' => ['F']);
969 register_language ('name' => 'ratfor',
971 'config_vars' => ['F77'],
972 'linker' => 'F77LINK',
973 'link' => '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
978 'compile' => '$(F77) $(AM_FFLAGS) $(FFLAGS) $(AM_RFLAGS) $(RFLAGS)',
979 'compiler' => 'RCOMPILE',
980 'compile_flag' => '-c',
981 'output_flag' => '-o',
983 'extensions' => ['r']);
986 register_language ('name' => 'java',
988 'config_vars' => ['GCJ'],
989 'linker' => 'GCJLINK',
990 'link' => '$(GCJLD) $(AM_GCJFLAGS) $(GCJFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
992 'flags' => 'GCJFLAGS',
993 'compile' => '$(GCJ) $(AM_GCJFLAGS) $(GCJFLAGS)',
994 'compiler' => 'GCJCOMPILE',
995 'compile_flag' => '-c',
996 'output_flag' => '-o',
1000 'extensions' => ['java', 'class', 'zip', 'jar']);
1002 ################################################################
1004 # Parse command line.
1007 # Do configure.ac scan only once.
1008 &scan_autoconf_files;
1010 die "$me: no `Makefile.am' found or specified\n"
1013 # Now do all the work on each file.
1014 # This guy must be local otherwise it's private to the loop.
1015 use vars '$am_file';
1017 foreach $am_file (@input_files)
1019 if (! -f ($am_file . '.am'))
1021 &am_error ("`" . $am_file . ".am' does not exist");
1025 &generate_makefile ($output_files{$am_file}, $am_file);
1031 # FIXME: This should be `my'ed next to its subs.
1032 use vars '%require_file_found';
1034 ################################################################
1036 # prog_error (@PRINT-ME)
1037 # ----------------------
1038 # Signal a programming error, display PRINT-ME, and exit 1.
1041 print STDERR "$me: programming error: @_\n";
1049 # Return LIST with no duplicates.
1054 foreach my $item (@_)
1056 if (! defined $seen{$item})
1067 # Return a configure-style substitution using the indicated text.
1068 # We do this to avoid having the substitutions directly in automake.in;
1069 # when we do that they are sometimes removed and this causes confusion
1074 return '@' . $text . '@';
1077 ################################################################
1081 # &backname ($REL-DIR)
1082 # --------------------
1083 # If I `cd $REL-DIR', then to come back, I should `cd $BACKPATH'.
1084 # For instance `src/foo' => `../..'.
1085 # Works with non strictly increasing paths, i.e., `src/../lib' => `..'.
1090 foreach (split (/\//, $file))
1092 next if $_ eq '.' || $_ eq '';
1102 return join ('/', @res) || '.';
1105 ################################################################
1107 # Parse command line.
1108 sub parse_arguments ()
1111 &set_strictness ('gnu');
1114 Getopt::Long::config ("bundling");
1115 Getopt::Long::GetOptions
1117 'version' => \&version,
1119 'libdir:s' => \$libdir,
1120 'gnu' => sub { &set_strictness ('gnu'); },
1121 'gnits' => sub { &set_strictness ('gnits'); },
1122 'cygnus' => \$cygnus_mode,
1123 'foreign' => sub { &set_strictness ('foreign'); },
1124 'include-deps' => sub { $cmdline_use_dependencies = 1; },
1125 'i|ignore-deps' => sub { $cmdline_use_dependencies = 0; },
1126 'no-force' => sub { $force_generation = 0; },
1127 'f|force-missing'=> \$force_missing,
1128 'o|output-dir:s' => \$output_directory,
1129 'a|add-missing' => \$add_missing,
1130 'c|copy' => \$copy_missing,
1131 'v|verbose' => \$verbose,
1132 'Werror' => sub { $SIG{"__WARN__"} = sub { die $_[0] } },
1133 'Wno-error' => sub { $SIG{"__WARN__"} = 'DEFAULT' }
1137 foreach my $arg (@ARGV)
1139 # Handle $local:$input syntax. Note that we only examine the
1140 # first ":" file to see if it is automake input; the rest are
1141 # just taken verbatim. We still keep all the files around for
1142 # dependency checking, however.
1143 my ($local, $input, @rest) = split (/:/, $arg);
1150 # Strip .in; later on .am is tacked on. That is how the
1151 # automake input file is found. Maybe not the best way, but
1152 # it is easy to explain.
1154 or die "$me: invalid input file name `$arg'\n.";
1156 push (@input_files, $input);
1157 $output_files{$input} = join (':', ($local, @rest));
1160 # Take global strictness from whatever we currently have set.
1161 $default_strictness = $strictness;
1162 $default_strictness_name = $strictness_name;
1165 ################################################################
1167 # Generate a Makefile.in given the name of the corresponding Makefile and
1168 # the name of the file output by config.status.
1169 sub generate_makefile
1171 my ($output, $makefile) = @_;
1173 # Reset all the Makefile.am related variables.
1174 &initialize_per_input;
1176 # Name of input file ("Makefile.am") and output file
1177 # ("Makefile.in"). These have no directory components.
1178 $am_file_name = basename ($makefile) . '.am';
1179 $in_file_name = basename ($makefile) . '.in';
1181 # $OUTPUT is encoded. If it contains a ":" then the first element
1182 # is the real output file, and all remaining elements are input
1183 # files. We don't scan or otherwise deal with these input file,
1184 # other than to mark them as dependencies. See
1185 # &scan_autoconf_files for details.
1186 my (@secondary_inputs);
1187 ($output, @secondary_inputs) = split (/:/, $output);
1189 $relative_dir = dirname ($output);
1190 $am_relative_dir = dirname ($makefile);
1192 &read_main_am_file ($makefile . '.am');
1193 if (&handle_options)
1195 # Fatal error. Just return, so we can continue with next file.
1199 # There are a few install-related variables that you should not define.
1200 foreach my $var ('PRE_INSTALL', 'POST_INSTALL', 'NORMAL_INSTALL')
1202 if (&variable_defined ($var) && !$var_is_am{$var})
1204 &am_line_error ($var, "`$var' should not be defined");
1210 # At the toplevel directory, we might need config.guess, config.sub
1211 # or libtool scripts (ltconfig and ltmain.sh).
1212 if ($relative_dir eq '.')
1214 # AC_CANONICAL_HOST and AC_CANONICAL_SYSTEM need config.guess and
1216 &require_config_file ($FOREIGN, 'config.guess', 'config.sub')
1220 # We still need Makefile.in here, because sometimes the `dist'
1221 # target doesn't re-run automake.
1222 if ($am_relative_dir eq $relative_dir)
1224 # Only distribute the files if they are in the same subdir as
1225 # the generated makefile.
1226 &push_dist_common ($in_file_name, $am_file_name);
1229 push (@sources, '$(SOURCES)')
1230 if &variable_defined ('SOURCES');
1232 # Must do this after reading .am file. See read_main_am_file to
1233 # understand weird tricks we play there with variables.
1234 &define_variable ('subdir', $relative_dir);
1236 # Check first, because we might modify some state.
1238 &check_gnu_standards;
1239 &check_gnits_standards;
1241 &handle_configure ($output, $makefile, @secondary_inputs);
1244 &handle_ltlibraries;
1248 # This must run first so that the ANSI2KNR definition is generated
1249 # before it is used by the _.c rules. We have to do this because
1250 # a variable which is used in a dependency must be defined before
1251 # the target, or else make won't properly see it.
1253 # This must be run after all the sources are scanned.
1256 # Re-init SOURCES. FIXME: other code shouldn't depend on this
1257 # (but currently does).
1258 macro_define ('SOURCES', 1, '', 'TRUE',
1259 join (' ', @sources), 'internal');
1260 &define_pretty_variable ('DIST_SOURCES', '', @dist_sources);
1272 &handle_minor_options;
1275 # This must come after most other rules.
1276 &handle_dist ($makefile);
1279 &do_check_merge_target;
1280 &handle_all ($output);
1283 if (&variable_defined('lib_LTLIBRARIES') &&
1284 &variable_defined('bin_PROGRAMS'))
1286 $output_rules .= "install-binPROGRAMS: install-libLTLIBRARIES\n\n";
1289 &handle_installdirs;
1291 &handle_factored_dependencies;
1295 if (! -d ($output_directory . '/' . $am_relative_dir))
1297 mkdir ($output_directory . '/' . $am_relative_dir, 0755);
1300 my ($out_file) = $output_directory . '/' . $makefile . ".in";
1301 if (! $force_generation && -e $out_file)
1303 my ($am_time) = (stat ($makefile . '.am'))[9];
1304 my ($in_time) = (stat ($out_file))[9];
1305 # FIXME: should cache these times.
1306 my ($conf_time) = (stat ($configure_ac))[9];
1307 # FIXME: how to do unsigned comparison?
1308 if ($am_time < $in_time || $am_time < $conf_time)
1310 # No need to update.
1313 if (-f 'aclocal.m4')
1315 my ($acl_time) = (stat _)[9];
1316 return if ($am_time < $acl_time);
1320 my $gm_file = new IO::File "> $out_file";
1323 warn "$me: ${am_file}.in: cannot write: $!\n";
1327 print "$me: creating ", $makefile, ".in\n" if $verbose;
1329 # In case we're running under MSWindows, don't write with CRLF
1330 # (as it causes problems for the dependency-file extraction in
1331 # AM_OUTPUT_DEPENDENCY_COMMANDS).
1334 print $gm_file $output_vars;
1335 # We make sure that `all:' is the first target.
1336 print $gm_file $output_all;
1337 print $gm_file $output_header;
1338 print $gm_file $output_rules;
1339 print $gm_file $output_trailer;
1341 if (! $gm_file->close)
1343 warn "$me: $am_file.in: cannot close: $!\n";
1349 ################################################################
1351 # A helper which handles the logic of requiring a version number in
1352 # AUTOMAKE_OPTIONS. Return 1 on error, 0 on success.
1353 sub version_check ($$$$)
1355 my ($rmajor, $rminor, $ralpha, $rfork) = ($1, $2, $3, $4);
1357 &prog_error ("version is incorrect: $VERSION")
1358 if $VERSION !~ /(\d+)\.(\d+)([a-z]?)-?([A-Za-z0-9]+)?/;
1360 my ($tmajor, $tminor, $talpha, $tfork) = ($1, $2, $3, $4);
1365 my $rminorminor = 0;
1366 my $tminorminor = 0;
1368 # Some versions were labelled like `1.4-p3a'. This is the same as
1369 # an alpha release labelled `1.4.3a'. However, a version like
1370 # `1.4g' is the same as `1.4.99g'. Yes, this sucks. Moral:
1371 # always listen to the users.
1372 if ($rfork =~ /p([0-9]+)([a-z]?)/)
1375 # `1.4a-p3b' never existed. But we'll accept it anyway.
1376 $ralpha = $ralpha || $2 || '';
1379 if ($tfork =~ /p([0-9]+)([a-z]?)/)
1382 # `1.4a-p3b' never existed. But we'll accept it anyway.
1383 $talpha = $talpha || $2 || '';
1387 $rminorminor = 99 if $ralpha ne '' && $rminorminor == 0;
1388 $tminorminor = 99 if $talpha ne '' && $tminorminor == 0;
1390 # 2.0 is better than 1.0.
1391 # 1.2 is better than 1.1.
1392 # 1.2a is better than 1.2.
1393 # If we require 3.4n-foo then we require something
1394 # >= 3.4n, with the `foo' fork identifier.
1395 # The $r* variables are what the user specified.
1396 # The $t* variables denote automake itself.
1397 if ($rmajor > $tmajor
1398 || ($rmajor == $tmajor && $rminor > $tminor)
1399 || ($rminor == $tminor && $rminor == $tminor
1400 && $rminorminor > $tminorminor)
1401 || ($rminor == $tminor && $rminor == $tminor
1402 && $rminorminor == $tminorminor
1403 && $ralpha gt $talpha)
1404 || ($rfork ne '' && $rfork ne $tfork))
1406 &am_line_error ('AUTOMAKE_OPTIONS',
1407 "require version $_, but have $VERSION");
1414 # Handle AUTOMAKE_OPTIONS variable. Return 1 on error, 0 otherwise.
1417 if (&variable_defined ('AUTOMAKE_OPTIONS'))
1419 foreach (&variable_value_as_list_recursive ('AUTOMAKE_OPTIONS', ''))
1422 if ($_ eq 'gnits' || $_ eq 'gnu' || $_ eq 'foreign')
1424 &set_strictness ($_);
1426 elsif ($_ eq 'cygnus')
1432 # An option like "../lib/ansi2knr" is allowed. With
1433 # no path prefix, we assume the required programs are
1434 # in this directory. We save the actual option for
1436 $options{'ansi2knr'} = $_;
1438 elsif ($_ eq 'no-installman' || $_ eq 'no-installinfo'
1439 || $_ eq 'dist-shar' || $_ eq 'dist-zip'
1440 || $_ eq 'dist-tarZ' || $_ eq 'dist-bzip2'
1441 || $_ eq 'dejagnu' || $_ eq 'no-texinfo.tex'
1442 || $_ eq 'readme-alpha' || $_ eq 'check-news'
1443 || $_ eq 'subdir-objects' || $_ eq 'nostdinc'
1444 || $_ eq 'no-exeext')
1446 # Explicitly recognize these.
1448 elsif ($_ eq 'no-dependencies')
1450 $use_dependencies = 0;
1452 elsif (/(\d+)\.(\d+)([a-z]?)(-[A-Za-z0-9]+)?/)
1454 # Got a version number.
1455 if (version_check ($1, $2, $3, $4))
1462 &am_line_error ('AUTOMAKE_OPTIONS',
1463 "option `" . $_ . "\' not recognized");
1468 if ($strictness == $GNITS)
1470 $options{'readme-alpha'} = 1;
1471 $options{'check-news'} = 1;
1478 # get_object_extension ($OUT)
1479 # ---------------------------
1480 # Return object extension. Just once, put some code into the output.
1481 # OUT is the name of the output file
1482 sub get_object_extension
1486 # Maybe require libtool library object files.
1487 my $extension = '.$(OBJEXT)';
1488 $extension = '.lo' if ($out =~ /\.la$/);
1490 # Check for automatic de-ANSI-fication.
1491 $extension = '$U' . $extension
1492 if defined $options{'ansi2knr'};
1494 $get_object_extension_was_run = 1;
1500 # Call finish function for each language that was used.
1501 sub handle_languages
1503 if ($use_dependencies)
1505 # Include auto-dep code. Don't include it if DEP_FILES would
1507 if (&saw_sources_p (0) && keys %dep_files)
1509 # Set location of depcomp.
1510 &define_variable ('depcomp', "\$(SHELL) $config_aux_dir/depcomp");
1512 &require_config_file ($FOREIGN, 'depcomp');
1514 my @deplist = sort keys %dep_files;
1516 # We define this as a conditional variable because BSD
1517 # make can't handle backslashes for continuing comments on
1518 # the following line.
1519 &define_pretty_variable ('DEP_FILES', 'AMDEP_TRUE', @deplist);
1521 # Generate each `include' individually. Irix 6 make will
1522 # not properly include several files resulting from a
1523 # variable expansion; generating many separate includes
1525 $output_rules .= "\n";
1526 foreach my $iter (@deplist)
1528 $output_rules .= (subst ('AMDEP_TRUE')
1529 . subst ('am__include')
1531 . subst ('am__quote')
1533 . subst ('am__quote')
1537 $output_rules .= &file_contents ('depend');
1542 &define_variable ('depcomp', '');
1547 # Is the c linker needed?
1549 foreach my $ext (sort keys %extension_seen)
1551 next unless $extension_map{$ext};
1553 my $lang = $languages{$extension_map{$ext}};
1555 my $rule_file = $lang->rule_file || 'depend2';
1557 # Get information on $LANG.
1558 my $pfx = $lang->autodep;
1559 my $fpfx = ($pfx eq '') ? 'CC' : $pfx;
1561 my $AMDEP = (($use_dependencies && $lang->autodep ne 'no')
1562 ? 'AMDEP' : 'FALSE');
1564 my %transform = ('EXT' => $ext,
1567 'LIBTOOL' => $seen_libtool,
1569 '-c' => $lang->compile_flag || '',
1571 => (count_files_for_language ($lang->name) > 1));
1573 # Generate the appropriate rules for this extension.
1574 if (($use_dependencies && $lang->autodep ne 'no')
1575 || defined $lang->compile)
1577 # Some C compilers don't support -c -o. Use it only if really
1579 my $output_flag = $lang->output_flag || '';
1582 && $lang->flags eq 'CFLAGS'
1583 && defined $options{'subdir-objects'});
1585 # FIXME: this is a temporary hack to compute a possible
1586 # derived extension. This is not used by depend2.am.
1587 (my $der_ext = $ext) =~ tr/yl/cc/;
1589 # Another yacc/lex hack.
1590 my $destfile = '$*.' . $der_ext;
1593 file_contents ($rule_file,
1597 'DERIVED-EXT' => $der_ext,
1605 'COMPILE' => '$(' . $lang->compiler . ')',
1606 'LTCOMPILE' => '$(LT' . $lang->compiler . ')',
1607 '-o' => $output_flag);
1610 # Now include code for each specially handled object with this
1612 my %seen_files = ();
1613 foreach my $file (@{$lang_specific_files{$lang->name}})
1615 my ($derived, $source, $obj, $myext) = split (' ', $file);
1617 # We might see a given object twice, for instance if it is
1618 # used under different conditions.
1619 next if defined $seen_files{$obj};
1620 $seen_files{$obj} = 1;
1622 my $flags = $lang->flags || '';
1623 my $val = "${derived}_${flags}";
1625 &prog_error ("found $lang->name in handle_languages, but compiler not defined")
1626 unless defined $lang->compile;
1628 (my $obj_compile = $lang->compile) =~ s/\(AM_$flags/\($val/;
1629 my $obj_ltcompile = '$(LIBTOOL) --mode=compile ' . $obj_compile;
1631 # We _need_ `-o' for per object rules.
1632 my $output_flag = $lang->output_flag || '-o';
1634 # Generate a transform which will turn suffix targets in
1635 # depend2.am into real targets for the particular objects we
1638 file_contents ($rule_file,
1643 'SOURCE' => $source,
1644 # Use $myext and not `.o' here, in case
1645 # we are actually building a new source
1646 # file -- e.g. via yacc.
1647 'OBJ' => "$obj$myext",
1648 'OBJOBJ' => "$obj.obj",
1649 'LTOBJ' => "$obj.lo",
1651 'COMPILE' => $obj_compile,
1652 'LTCOMPILE' => $obj_ltcompile,
1653 '-o' => $output_flag));
1656 # The rest of the loop is done once per language.
1657 next if defined $done{$lang};
1660 # Load the language dependent Makefile chunks.
1661 my %lang = map { uc ($_) => 0 } keys %languages;
1662 $lang{uc ($lang->name)} = 1;
1663 $output_rules .= file_contents ('lang-compile', %transform, %lang);
1665 # If the source to a program consists entirely of code from a
1666 # `pure' language, for instance C++ for Fortran 77, then we
1667 # don't need the C compiler code. However if we run into
1668 # something unusual then we do generate the C code. There are
1669 # probably corner cases here that do not work properly.
1670 # People linking Java code to Fortran code deserve pain.
1671 $needs_c ||= ! $lang->pure;
1673 define_compiler_variable ($lang)
1674 if ($lang->compile);
1676 define_linker_variable ($lang)
1679 foreach my $var (@{$lang->config_vars})
1681 am_error ($lang->Name
1682 . " source seen but `$var' not defined in"
1683 . " `$configure_ac'")
1684 if !exists $configure_vars{$var};
1687 # The compiler's flag must be a configure variable.
1688 define_configure_variable ($lang->flags)
1689 if defined $lang->flags && $lang->define_flag;
1691 # Call the finisher.
1695 # If the project is entirely C++ or entirely Fortran 77 (i.e., 1
1696 # suffix rule was learned), don't bother with the C stuff. But if
1697 # anything else creeps in, then use it.
1699 if $need_link || scalar keys %suffix_rules > 1;
1703 if (! defined $done{$languages{'c'}})
1705 &define_configure_variable ($languages{'c'}->flags);
1706 &define_compiler_variable ($languages{'c'});
1708 define_linker_variable ($languages{'c'});
1712 # Check to make sure a source defined in LIBOBJS is not explicitly
1713 # mentioned. This is a separate function (as opposed to being inlined
1714 # in handle_source_transform) because it isn't always appropriate to
1716 sub check_libobjs_sources
1718 my ($one_file, $unxformed) = @_;
1720 foreach my $prefix ('', 'EXTRA_', 'dist_', 'nodist_',
1721 'dist_EXTRA_', 'nodist_EXTRA_')
1724 if (&variable_defined ($prefix . $one_file . '_SOURCES'))
1726 @files = &variable_value_as_list_recursive (
1727 ($prefix . $one_file . '_SOURCES'),
1730 elsif ($prefix eq '')
1732 @files = ($unxformed . '.c');
1739 foreach my $file (@files)
1741 if (defined $libsources{$file})
1743 &am_line_error ($prefix . $one_file . '_SOURCES',
1744 "automatically discovered file `$file' should not be explicitly mentioned");
1752 # handle_single_transform_list ($VAR, $TOPPARENT, $DERIVED, $OBJ, @FILES)
1753 # -----------------------------------------------------------------------
1754 # Does much of the actual work for handle_source_transform.
1756 # $VAR is the name of the variable that the source filenames come from
1757 # $TOPPARENT is the name of the _SOURCES variable which is being processed
1758 # $DERIVED is the name of resulting executable or library
1759 # $OBJ is the object extension (e.g., `$U.lo')
1760 # @FILES is the list of source files to transform
1761 # Result is a list of the names of objects
1762 # %linkers_used will be updated with any linkers needed
1763 sub handle_single_transform_list ($$$$@)
1765 my ($var, $topparent, $derived, $obj, @files) = @_;
1767 my $nonansi_obj = $obj;
1768 $nonansi_obj =~ s/\$U//g;
1770 # Turn sources into objects. We use a while loop like this
1771 # because we might add to @files in the loop.
1772 while (scalar @files > 0)
1776 # Configure substitutions in _SOURCES variables are errors.
1779 &am_line_error ($var, "`$var' includes configure substitution `$_', and is referred to from `$topparent': configure substitutions not allowed in _SOURCES variables");
1783 # If the source file is in a subdirectory then the `.o' is put
1784 # into the current directory, unless the subdir-objects option
1787 # Split file name into base and extension.
1788 next if ! /^(?:(.*)\/)?([^\/]*)\.(.*)$/;
1790 my $directory = $1 || '';
1794 # We must generate a rule for the object if it requires its own flags.
1796 my ($linker, $object);
1798 # This records whether we've seen a derived source file (eg,
1800 my $derived_source = 0;
1802 # This holds the `aggregate context' of the file we are
1803 # currently examining. If the file is compiled with
1804 # per-object flags, then it will be the name of the object.
1805 # Otherwise it will be `AM'. This is used by the target hook
1806 # language function.
1807 my $aggregate = 'AM';
1809 $extension = &derive_suffix ($extension);
1811 if ($extension_map{$extension} &&
1812 ($lang = $languages{$extension_map{$extension}}))
1814 # Found the language, so see what it says.
1815 &saw_extension ($extension);
1817 # Note: computed subr call. The language rewrite function
1818 # should return one of the $LANG_* constants. It could
1819 # also return a list whose first value is such a constant
1820 # and whose second value is a new source extension which
1821 # should be applied. This means this particular language
1822 # generates another source file which we must then process
1824 my $subr = 'lang_' . $lang->name . '_rewrite';
1825 my ($r, $source_extension)
1826 = & $subr ($directory, $base, $extension);
1827 # Skip this entry if we were asked not to process it.
1828 next if $r == $LANG_IGNORE;
1830 # Now extract linker and other info.
1831 $linker = $lang->linker;
1834 if (defined $source_extension)
1836 $this_obj_ext = '.' . $source_extension;
1837 $derived_source = 1;
1841 $this_obj_ext = $obj;
1845 $this_obj_ext = $nonansi_obj;
1847 $object = $base . $this_obj_ext;
1849 if (defined $lang->flags
1850 && &variable_defined ($derived . '_' . $lang->flags))
1852 # We have a per-executable flag in effect for this
1853 # object. In this case we rewrite the object's
1854 # name to ensure it is unique. We also require
1855 # the `compile' program to deal with compilers
1856 # where `-c -o' does not work.
1858 # We choose the name `DERIVED_OBJECT' to ensure
1859 # (1) uniqueness, and (2) continuity between
1860 # invocations. However, this will result in a
1861 # name that is too long for losing systems, in
1862 # some situations. So we provide _SHORTNAME to
1865 my $dname = $derived;
1866 if (&variable_defined ($derived . '_SHORTNAME'))
1868 # FIXME: should use the same conditional as
1869 # the _SOURCES variable. But this is really
1870 # silly overkill -- nobody should have
1871 # conditional shortnames.
1872 $dname = &variable_value ($derived . '_SHORTNAME');
1874 $object = $dname . '-' . $object;
1876 &require_config_file ($FOREIGN, 'compile')
1877 if $lang->name eq 'c';
1879 &prog_error ("$lang->name flags defined without compiler")
1880 if ! defined $lang->compile;
1885 # If rewrite said it was ok, put the object into a
1887 if ($r == $LANG_SUBDIR && $directory ne '')
1889 $object = $directory . '/' . $object;
1892 # If doing dependency tracking, then we can't print
1893 # the rule. If we have a subdir object, we need to
1894 # generate an explicit rule. Actually, in any case
1895 # where the object is not in `.' we need a special
1896 # rule. The per-object rules in this case are
1897 # generated later, by handle_languages.
1898 if ($renamed || $directory ne '')
1900 my $obj_sans_ext = substr ($object, 0,
1901 - length ($this_obj_ext));
1902 my $val = ("$full $obj_sans_ext "
1903 # Only use $this_obj_ext in the derived
1904 # source case because in the other case we
1905 # *don't* want $(OBJEXT) to appear here.
1906 . ($derived_source ? $this_obj_ext : '.o'));
1908 # If we renamed the object then we want to use the
1909 # per-executable flag name. But if this is simply a
1910 # subdir build then we still want to use the AM_ flag
1914 $val = "$derived $val";
1915 $aggregate = $derived;
1922 # Each item on this list is a string consisting of
1923 # four space-separated values: the derived flag prefix
1924 # (eg, for `foo_CFLAGS', it is `foo'), the name of the
1925 # source file, the base name of the output file, and
1926 # the extension for the object file.
1927 push (@{$lang_specific_files{$lang->name}}, $val);
1930 elsif ($extension eq 'o')
1932 # This is probably the result of a direct suffix rule.
1933 # In this case we just accept the rewrite. FIXME:
1934 # this fails if we want libtool objects.
1935 $object = $base . '.' . $extension;
1940 # No error message here. Used to have one, but it was
1942 # FIXME: we could potentially do more processing here,
1943 # perhaps treating the new extension as though it were a
1944 # new source extension (as above). This would require
1945 # more restructuring than is appropriate right now.
1949 if (defined $object_map{$object})
1951 if ($object_map{$object} ne $full)
1953 &am_error ("object `$object' created by `$full' and `$object_map{$object}'");
1957 # Let the language do some special magic if required.
1958 $lang->target_hook ($aggregate, $object, $full);
1960 if ($derived_source)
1962 &prog_error ("$lang->name has automatic dependency tracking")
1963 if $lang->autodep ne 'no';
1964 # Make sure this new source file is handled next. That will
1965 # make it appear to be at the right place in the list.
1966 unshift (@files, $object);
1968 &push_dist_common ($object);
1972 $linkers_used{$linker} = 1;
1974 push (@result, $object);
1976 if (! defined $object_map{$object})
1979 $object_map{$object} = $full;
1981 # If file is in subdirectory, we need explicit
1983 if ($directory ne '' || $renamed)
1985 push (@dep_list, $full);
1988 # If resulting object is in subdir, we need to make
1989 # sure the subdir exists at build time.
1990 if ($object =~ /\//)
1992 # FIXME: check that $DIRECTORY is somewhere in the
1995 # We don't allow `..' in object file names for
1996 # *any* source, not just Java. For Java it just
1997 # doesn't make sense, but in general it is
1998 # a problem because we can't pick a good name for
2000 if ($object =~ /(\/|^)\.\.\//)
2002 &am_error ("`$full' contains `..' component but should not");
2005 # Make sure object is removed by `make mostlyclean'.
2006 $compile_clean_files{$object} = $MOSTLY_CLEAN;
2008 push (@dep_list, &require_build_directory ($directory));
2010 # If we're generating dependencies, we also want
2011 # to make sure that the appropriate subdir of the
2012 # .deps directory is created.
2013 push (@dep_list, &require_build_directory ('$(DEPDIR)/' . $directory))
2014 if ($use_dependencies);
2017 &pretty_print_rule ($object . ':', "\t", @dep_list)
2018 if scalar @dep_list > 0;
2021 # Transform .o or $o file into .P file (for automatic
2023 if ($lang && $lang->autodep ne 'no')
2025 my $depfile = $object;
2026 $depfile =~ s/\.([^.]*)$/.P$1/;
2027 $depfile =~ s/\$\(OBJEXT\)$/o/;
2028 $dep_files{'$(DEPDIR)/' . $depfile} = 1;
2036 # define_objects_from_sources ($VAR, $OBJVAR, $NODEFINE, $ONE_FILE,
2037 # $OBJ, $PARENT, $TOPPARENT)
2038 # ---------------------------------------------------------------------
2039 # Define an _OBJECTS variable for a _SOURCES variable (or subvariable)
2042 # $VAR is the name of the _SOURCES variable
2043 # $OBJVAR is the name of the _OBJECTS
2044 # $NODEFINE is a boolean: if true, $OBJVAR will not be defined (but
2045 # work done to determine the linker will be).
2046 # $ONE_FILE is the canonical (transformed) name of object to build
2047 # $OBJ is the object extension (ie either `.o' or `$o'.
2048 # $PARENT is the variable in which $VAR is used, or $VAR if not applicable.
2049 # $TOPPARENT is the _SOURCES variable being processed.
2051 # Result is a boolean, true if a linker is needed to deal with the objects.
2053 # %linkers_used, %vars_scanned, @substfroms and @substtos should be cleared
2055 # %linkers_used variable will be set to contain the linkers desired.
2056 # %vars_scanned will be used to check for recursive definitions.
2057 # @substfroms and @substtos will be used to keep a stack of variable
2058 # substitutions to be applied.
2060 sub define_objects_from_sources ($$$$$$$)
2062 my ($var, $objvar, $nodefine, $one_file, $obj, $parent, $topparent) = @_;
2064 if (defined $vars_scanned{$var})
2066 &am_line_error ($var, "variable `$var' recursively defined");
2069 $vars_scanned{$var} = 1;
2071 my $needlinker = "";
2072 foreach my $cond (&variable_conditions ($var))
2075 foreach my $val (&variable_value_as_list ($var, $cond, $parent))
2077 if ($val =~ /^\$\{([^}]*)\}$/ || $val =~ /^\$\(([^)]*)\)$/)
2079 # Handle a sub variable
2082 # If the user uses a losing variable name, just ignore it.
2083 # This isn't ideal, but people have requested it.
2084 next if ($subvar =~ /\@.*\@/);
2086 # See if the variable is actually a substitution reference
2089 if ($subvar =~ /$SUBST_REF_PATTERN/o)
2093 ($from = $2) =~ s/(\W)/\\$1/g;
2095 push @substfroms, $from;
2096 push @substtos, $to;
2098 my $subobjvar = &subobjname($subvar);
2099 push (@result, '$('. $subobjvar . ')');
2101 my $temp = define_objects_from_sources ($subvar, $subobjvar,
2102 $nodefine, $one_file,
2103 $obj, $var, $topparent);
2104 $needlinker ||= $temp;
2111 my $substnum=$#substfroms;
2112 while ($substnum >= 0)
2114 $val =~ s/$substfroms[$substnum]$/$substtos[$substnum]/
2115 if defined $substfroms[$substnum];
2120 &handle_single_transform_list ($var, $topparent, $one_file, $obj, $val);
2121 push (@result, @transformed);
2122 $needlinker = "true" if @transformed;
2126 # Define _OBJECTS conditionally.
2127 &define_pretty_variable ($objvar, $cond, (@result))
2131 delete $vars_scanned{$var};
2136 # subobjname ($VARNAME)
2137 # ---------------------------------------------------------------------
2138 # Return a name for an object variable.
2141 # $VARNAME is the name of the variable the object variable is being
2144 # This function also looks at @substfroms and @substtos to determine any
2145 # substitutions to be performed on the object variable.
2147 # The name returned is unique for the combination of $varname and
2148 # substitutions to be performed.
2153 my $substnum=$#substfroms;
2154 while ($substnum >= 0)
2156 if (defined $substfroms[$substnum] &&
2157 ($substfroms[$substnum] || $substtos[$substnum]))
2159 $key .= ":" . $substfroms[$substnum] . "=" . $substtos[$substnum];
2164 my $num = $substnums{$key};
2167 $num = keys(%substnums) + 1;
2168 $substnums{$key} = $num;
2171 return "am__objects_$num";
2175 # Handle SOURCE->OBJECT transform for one program or library.
2177 # canonical (transformed) name of object to build
2178 # actual name of object to build
2179 # object extension (ie either `.o' or `$o'.
2180 # Return result is name of linker variable that must be used.
2181 # Empty return means just use `LINK'.
2182 sub handle_source_transform
2184 # one_file is canonical name. unxformed is given name. obj is
2186 my ($one_file, $unxformed, $obj) = @_;
2190 if (&variable_defined ($one_file . "_OBJECTS"))
2192 &am_line_error ($one_file . '_OBJECTS',
2193 $one_file . '_OBJECTS', 'should not be defined');
2194 # No point in continuing.
2201 foreach my $prefix ('', 'EXTRA_', 'dist_', 'nodist_',
2202 'dist_EXTRA_', 'nodist_EXTRA_')
2204 my $var = $prefix . $one_file . "_SOURCES";
2206 if !variable_defined ($var);
2208 # We are going to define _OBJECTS variables using the prefix.
2209 # Then we glom them all together. So we can't use the null
2210 # prefix here as we need it later.
2211 my $xpfx = ($prefix eq '') ? 'am_' : $prefix;
2213 # Keep track of which prefixes we saw.
2214 $used_pfx{$xpfx} = 1
2215 unless $prefix =~ /EXTRA_/;
2217 push (@sources, '$(' . $prefix . $one_file . "_SOURCES)");
2218 push (@dist_sources, '$(' . $prefix . $one_file . "_SOURCES)")
2219 unless $prefix =~ /^nodist_/;
2224 my $temp = define_objects_from_sources ($var,
2225 $xpfx . $one_file . '_OBJECTS',
2226 $prefix =~ /EXTRA_/,
2227 $one_file, $obj, $var, $var);
2228 $needlinker ||= $temp;
2232 $linker ||= &resolve_linker (%linkers_used);
2235 my @keys = sort keys %used_pfx;
2236 if (scalar @keys == 0)
2238 &define_variable ($one_file . "_SOURCES", $unxformed . ".c");
2239 push (@sources, $unxformed . '.c');
2240 push (@dist_sources, $unxformed . '.c');
2244 &handle_single_transform_list ($one_file . '_SOURCES',
2245 $one_file . '_SOURCES',
2248 $linker ||= &resolve_linker (%linkers_used);
2249 &define_pretty_variable ($one_file . "_OBJECTS", '', @result)
2253 grep ($_ = '$(' . $_ . $one_file . '_OBJECTS)', @keys);
2254 &define_pretty_variable ($one_file . '_OBJECTS', '', @keys);
2257 # If we want to use `LINK' we must make sure it is defined.
2267 # handle_lib_objects ($XNAME, $VAR)
2268 # ---------------------------------
2269 # Special-case @ALLOCA@ and @LIBOBJS@ in _LDADD or _LIBADD variables.
2270 # Also, generate _DEPENDENCIES variable if appropriate.
2272 # transformed name of object being built, or empty string if no object
2273 # name of _LDADD/_LIBADD-type variable to examine
2274 # Returns 1 if LIBOBJS seen, 0 otherwise.
2275 sub handle_lib_objects
2277 my ($xname, $var) = @_;
2279 &prog_error ("handle_lib_objects: $var undefined")
2280 if ! &variable_defined ($var);
2283 foreach my $cond (&variable_conditions_recursive ($var))
2285 if (&handle_lib_objects_cond ($xname, $var, $cond))
2293 # Subroutine of handle_lib_objects: handle a particular condition.
2294 sub handle_lib_objects_cond
2296 my ($xname, $var, $cond) = @_;
2298 # We recognize certain things that are commonly put in LIBADD or
2302 my $seen_libobjs = 0;
2305 foreach my $lsearch (&variable_value_as_list_recursive ($var, $cond))
2307 # Skip -lfoo and -Ldir; these are explicitly allowed.
2308 next if $lsearch =~ /^-[lL]/;
2309 if (! $flagvar && $lsearch =~ /^-/)
2311 if ($var =~ /^(.*)LDADD$/)
2313 # Skip -dlopen and -dlpreopen; these are explicitly allowed.
2314 next if $lsearch =~ /^-dl(pre)?open$/;
2315 &am_line_error ($var, "linker flags such as `$lsearch' belong in `${1}LDFLAGS");
2319 # Only get this error once.
2321 &am_line_error ($var, "linker flags such as `$lsearch' belong in `${1}LDFLAGS");
2325 # Assume we have a file of some sort, and push it onto the
2326 # dependency list. Autoconf substitutions are not pushed;
2327 # rarely is a new dependency substituted into (eg) foo_LDADD
2328 # -- but "bad things (eg -lX11) are routinely substituted.
2329 # Note that LIBOBJS and ALLOCA are exceptions to this rule,
2330 # and handled specially below.
2331 push (@dep_list, $lsearch)
2332 unless $lsearch =~ /^\@.*\@$/;
2334 # Automatically handle @LIBOBJS@ and @ALLOCA@. Basically this
2335 # means adding entries to dep_files.
2336 if ($lsearch =~ /^\@(LT)?LIBOBJS\@$/)
2338 my $lt = $1 ? $1 : '';
2339 my $myobjext = ($1 ? 'l' : '') . 'o';
2341 push (@dep_list, $lsearch);
2343 if (! keys %libsources
2344 && ! &variable_defined ($lt . 'LIBOBJS'))
2346 &am_line_error ($var, "\@$lt" . "LIBOBJS\@ seen but never set in `$configure_ac'");
2349 foreach my $iter (keys %libsources)
2351 if ($iter =~ /\.([cly])$/)
2353 &saw_extension ($1);
2354 &saw_extension ('c');
2357 if ($iter =~ /\.h$/)
2359 &require_file_with_line ($var, $FOREIGN, $iter);
2361 elsif ($iter ne 'alloca.c')
2363 my $rewrite = $iter;
2364 $rewrite =~ s/\.c$/.P$myobjext/;
2365 $dep_files{'$(DEPDIR)/' . $rewrite} = 1;
2366 ($rewrite = $iter) =~ s/(\W)/\\$1/g;
2367 $rewrite = "^" . $rewrite . "\$";
2368 # Only require the file if it is not a built source.
2369 if (! &variable_defined ('BUILT_SOURCES')
2370 || ! grep (/$rewrite/,
2371 &variable_value_as_list_recursive (
2372 'BUILT_SOURCES', 'all')))
2374 &require_file_with_line ($var, $FOREIGN, $iter);
2379 elsif ($lsearch =~ /^\@(LT)?ALLOCA\@$/)
2381 my $lt = $1 ? $1 : '';
2382 my $myobjext = ($1 ? 'l' : '') . 'o';
2384 push (@dep_list, $lsearch);
2385 &am_line_error ($var,
2386 "\@$lt" . "ALLOCA\@ seen but `AC_FUNC_ALLOCA' not in `$configure_ac'")
2387 if ! defined $libsources{'alloca.c'};
2388 $dep_files{'$(DEPDIR)/alloca.P' . $myobjext} = 1;
2389 &require_file_with_line ($var, $FOREIGN, 'alloca.c');
2390 &saw_extension ('c');
2394 if ($xname ne '' && ! &variable_defined ($xname . '_DEPENDENCIES', $cond))
2396 &define_pretty_variable ($xname . '_DEPENDENCIES', $cond, @dep_list);
2399 return $seen_libobjs;
2402 # Canonicalize the input parameter
2406 $string =~ tr/A-Za-z0-9_\@/_/c;
2410 # Canonicalize a name, and check to make sure the non-canonical name
2411 # is never used. Returns canonical name. Arguments are name and a
2412 # list of suffixes to check for.
2413 sub check_canonical_spelling
2415 my ($name, @suffixes) = @_;
2417 my $xname = &canonicalize ($name);
2418 if ($xname ne $name)
2420 foreach my $xt (@suffixes)
2422 &am_line_error ("$name$xt",
2423 "invalid variable `$name$xt'; "
2424 . "should be `$xname$xt'")
2425 if &variable_defined ("$name$xt");
2435 # Set up the compile suite.
2436 sub handle_compile ()
2439 unless $get_object_extension_was_run;
2442 my $default_includes = '';
2443 if (! defined $options{'nostdinc'})
2445 $default_includes = ' -I. -I$(srcdir)';
2447 if (&variable_defined ('CONFIG_HEADER'))
2449 foreach my $hdr (split (' ', &variable_value ('CONFIG_HEADER')))
2451 $default_includes .= ' -I' . dirname ($hdr);
2456 my (@mostly_rms, @dist_rms);
2457 foreach my $item (sort keys %compile_clean_files)
2459 if ($compile_clean_files{$item} == $MOSTLY_CLEAN)
2461 push (@mostly_rms, "\t-rm -f $item");
2463 elsif ($compile_clean_files{$item} == $DIST_CLEAN)
2465 push (@dist_rms, "\t-rm -f $item");
2469 &prog_error ("invalid entry in \%compile_clean_files");
2473 my ($coms, $vars, $rules) =
2474 &file_contents_internal (1, "$libdir/am/compile.am",
2475 ('DEFAULT_INCLUDES' => $default_includes,
2476 'MOSTLYRMS' => join ("\n", @mostly_rms),
2477 'DISTRMS' => join ("\n", @dist_rms)));
2478 $output_vars .= $vars;
2479 $output_rules .= "$coms$rules";
2481 # Check for automatic de-ANSI-fication.
2482 if (defined $options{'ansi2knr'})
2484 if (! $am_c_prototypes)
2486 &am_line_error ('AUTOMAKE_OPTIONS',
2487 "option `ansi2knr' in use but `AM_C_PROTOTYPES' not in `$configure_ac'");
2488 &keyed_aclocal_warning ('AM_C_PROTOTYPES');
2489 # Only give this error once.
2490 $am_c_prototypes = 1;
2493 # topdir is where ansi2knr should be.
2494 if ($options{'ansi2knr'} eq 'ansi2knr')
2496 # Only require ansi2knr files if they should appear in
2498 &require_file_with_line ('AUTOMAKE_OPTIONS', $FOREIGN,
2499 'ansi2knr.c', 'ansi2knr.1');
2501 # ansi2knr needs to be built before subdirs, so unshift it.
2502 unshift (@all, '$(ANSI2KNR)');
2505 my $ansi2knr_dir = '';
2506 $ansi2knr_dir = dirname ($options{'ansi2knr'})
2507 if $options{'ansi2knr'} ne 'ansi2knr';
2509 $output_rules .= &file_contents ('ansi2knr',
2510 ('ANSI2KNR-DIR' => $ansi2knr_dir));
2517 # Handle libtool rules.
2520 return unless $seen_libtool;
2522 # libtool requires some files, but only at top level.
2523 &require_conf_file_with_conf_line ($libtool_line, $FOREIGN,
2525 if $relative_dir eq '.';
2527 # Output the libtool compilation rules.
2528 $output_rules .= &file_contents ('libtool');
2531 # handle_programs ()
2532 # ------------------
2533 # Handle C programs.
2536 my @proglist = &am_install_var ('progs', 'PROGRAMS',
2537 'bin', 'sbin', 'libexec', 'pkglib',
2539 return if ! @proglist;
2541 my $seen_libobjs = 0;
2542 foreach my $one_file (@proglist)
2544 my $obj = &get_object_extension ($one_file);
2546 # Canonicalize names and check for misspellings.
2547 my $xname = &check_canonical_spelling ($one_file, '_LDADD', '_LDFLAGS',
2548 '_SOURCES', '_OBJECTS',
2551 my $linker = &handle_source_transform ($xname, $one_file, $obj);
2554 if (&variable_defined ($xname . "_LDADD"))
2556 if (&handle_lib_objects ($xname, $xname . '_LDADD'))
2564 # User didn't define prog_LDADD override. So do it.
2565 &define_variable ($xname . '_LDADD', '$(LDADD)');
2567 # This does a bit too much work. But we need it to
2568 # generate _DEPENDENCIES when appropriate.
2569 if (&variable_defined ('LDADD'))
2571 if (&handle_lib_objects ($xname, 'LDADD'))
2576 elsif (! &variable_defined ($xname . '_DEPENDENCIES'))
2578 &define_variable ($xname . '_DEPENDENCIES', '');
2583 if (&variable_defined ($xname . '_LIBADD'))
2585 &am_line_error ($xname . '_LIBADD',
2586 "use `" . $xname . "_LDADD', not `"
2587 . $xname . "_LIBADD'");
2590 if (! &variable_defined ($xname . '_LDFLAGS'))
2592 # Define the prog_LDFLAGS variable.
2593 &define_variable ($xname . '_LDFLAGS', '');
2596 # Determine program to use for link.
2598 if (&variable_defined ($xname . '_LINK'))
2600 $xlink = $xname . '_LINK';
2604 $xlink = $linker ? $linker : 'LINK';
2607 # If the resulting program lies into a subdirectory,
2608 # make sure this directory will exist.
2609 my $dirstamp = &require_build_directory_maybe ($one_file);
2611 # Don't add $(EXEEXT) if user already did.
2612 my $extension = ($one_file !~ /\$\(EXEEXT\)$/
2616 $output_rules .= &file_contents ('program',
2617 ('PROGRAM' => $one_file,
2618 'XPROGRAM' => $xname,
2620 'DIRSTAMP' => $dirstamp,
2621 'EXEEXT' => $extension));
2624 if (&variable_defined ('LDADD') && &handle_lib_objects ('', 'LDADD'))
2631 foreach my $one_file (@proglist)
2633 my $xname = &canonicalize ($one_file);
2635 if (&variable_defined ($xname . '_LDADD'))
2637 &check_libobjs_sources ($xname, $xname . '_LDADD');
2639 elsif (&variable_defined ('LDADD'))
2641 &check_libobjs_sources ($xname, 'LDADD');
2648 # handle_libraries ()
2649 # -------------------
2651 sub handle_libraries
2653 my @liblist = &am_install_var ('libs', 'LIBRARIES',
2654 'lib', 'pkglib', 'noinst', 'check');
2655 return if ! @liblist;
2657 my %valid = &am_primary_prefixes ('LIBRARIES', 0, 'lib', 'pkglib',
2659 if (! defined $configure_vars{'RANLIB'})
2661 foreach my $key (keys %valid)
2663 if (&variable_defined ($key . '_LIBRARIES'))
2665 &am_line_error ($key . '_LIBRARIES', "library used but `RANLIB' not defined in `$configure_ac'");
2666 # Only get this error once. If this is ever printed,
2668 $configure_vars{'RANLIB'} = 'BUG';
2674 my $seen_libobjs = 0;
2675 foreach my $onelib (@liblist)
2677 # Check that the library fits the standard naming convention.
2678 if (basename ($onelib) !~ /^lib.*\.a/)
2680 # FIXME should put line number here. That means mapping
2681 # from library name back to variable name.
2682 &am_error ("`$onelib' is not a standard library name");
2685 my $obj = &get_object_extension ($onelib);
2687 # Canonicalize names and check for misspellings.
2688 my $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_SOURCES',
2689 '_OBJECTS', '_DEPENDENCIES',
2692 if (! &variable_defined ($xlib . '_AR'))
2694 &define_variable ($xlib . '_AR', '$(AR) cru');
2697 if (&variable_defined ($xlib . '_LIBADD'))
2699 if (&handle_lib_objects ($xlib, $xlib . '_LIBADD'))
2706 # Generate support for conditional object inclusion in
2708 &define_variable ($xlib . "_LIBADD", '');
2711 if (&variable_defined ($xlib . '_LDADD'))
2713 &am_line_error ($xlib . '_LDADD',
2714 "use `" . $xlib . "_LIBADD', not `"
2715 . $xlib . "_LDADD'");
2718 # Make sure we at look at this.
2719 &examine_variable ($xlib . '_DEPENDENCIES');
2721 &handle_source_transform ($xlib, $onelib, $obj);
2723 # If the resulting library lies into a subdirectory,
2724 # make sure this directory will exist.
2725 my $dirstamp = &require_build_directory_maybe ($onelib);
2727 $output_rules .= &file_contents ('library',
2728 ('LIBRARY' => $onelib,
2729 'XLIBRARY' => $xlib,
2730 'DIRSTAMP' => $dirstamp));
2735 foreach my $onelib (@liblist)
2737 my $xlib = &canonicalize ($onelib);
2738 if (&variable_defined ($xlib . '_LIBADD'))
2740 &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
2747 # handle_ltlibraries ()
2748 # ---------------------
2749 # Handle shared libraries.
2750 sub handle_ltlibraries
2752 my @liblist = &am_install_var ('ltlib', 'LTLIBRARIES',
2753 'noinst', 'lib', 'pkglib', 'check');
2754 return if ! @liblist;
2757 my %valid = &am_primary_prefixes ('LTLIBRARIES', 0, 'lib', 'pkglib',
2760 foreach my $key (keys %valid)
2762 if (&variable_defined ($key . '_LTLIBRARIES'))
2766 &am_line_error ($key . '_LTLIBRARIES', "library used but `LIBTOOL' not defined in `$configure_ac'");
2767 # Only get this error once. If this is ever printed,
2769 $configure_vars{'LIBTOOL'} = 'BUG';
2773 # Get the installation directory of each library.
2774 for (&variable_value_as_list_recursive ($key . '_LTLIBRARIES', 'all'))
2778 &am_error ("`$_' is already going to be installed in `$instdirs{$_}'");
2782 $instdirs{$_} = $key;
2788 my $seen_libobjs = 0;
2789 foreach my $onelib (@liblist)
2791 my $obj = &get_object_extension ($onelib);
2793 # Canonicalize names and check for misspellings.
2794 my $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_LDFLAGS',
2795 '_SOURCES', '_OBJECTS',
2798 if (! &variable_defined ($xlib . '_LDFLAGS'))
2800 # Define the lib_LDFLAGS variable.
2801 &define_variable ($xlib . '_LDFLAGS', '');
2804 # Check that the library fits the standard naming convention.
2805 my $libname_rx = "^lib.*\.la";
2806 if ((&variable_defined ($xlib . '_LDFLAGS')
2807 && grep (/-module/, &variable_value_as_list_recursive (
2808 $xlib . '_LDFLAGS', 'all')))
2809 || (&variable_defined ('LDFLAGS')
2810 && grep (/-module/, &variable_value_as_list_recursive (
2811 'LDFLAGS', 'all'))))
2813 # Relax name checking for libtool modules.
2814 $libname_rx = "\.la";
2816 if (basename ($onelib) !~ /$libname_rx$/)
2818 # FIXME this should only be a warning for foreign packages
2819 # FIXME should put line number here. That means mapping
2820 # from library name back to variable name.
2821 &am_error ("`$onelib' is not a standard libtool library name");
2824 if (&variable_defined ($xlib . '_LIBADD'))
2826 if (&handle_lib_objects ($xlib, $xlib . '_LIBADD'))
2833 # Generate support for conditional object inclusion in
2835 &define_variable ($xlib . "_LIBADD", '');
2838 if (&variable_defined ($xlib . '_LDADD'))
2840 &am_line_error ($xlib . '_LDADD',
2841 "use `" . $xlib . "_LIBADD', not `"
2842 . $xlib . "_LDADD'");
2845 # Make sure we at look at this.
2846 &examine_variable ($xlib . '_DEPENDENCIES');
2848 my $linker = &handle_source_transform ($xlib, $onelib, $obj);
2850 # Determine program to use for link.
2852 if (&variable_defined ($xlib . '_LINK'))
2854 $xlink = $xlib . '_LINK';
2858 $xlink = $linker ? $linker : 'LINK';
2862 if ($instdirs{$onelib} eq 'EXTRA'
2863 || $instdirs{$onelib} eq 'noinst'
2864 || $instdirs{$onelib} eq 'check')
2866 # It's an EXTRA_ library, so we can't specify -rpath,
2867 # because we don't know where the library will end up.
2868 # The user probably knows, but generally speaking automake
2869 # doesn't -- and in fact configure could decide
2870 # dynamically between two different locations.
2875 $rpath = ('-rpath $(' . $instdirs{$onelib} . 'dir)');
2878 # If the resulting library lies into a subdirectory,
2879 # make sure this directory will exist.
2880 my $dirstamp = &require_build_directory_maybe ($onelib);
2882 $output_rules .= &file_contents ('ltlibrary',
2883 ('LTLIBRARY' => $onelib,
2884 'XLTLIBRARY' => $xlib,
2887 'DIRSTAMP' => $dirstamp));
2892 foreach my $onelib (@liblist)
2894 my $xlib = &canonicalize ($onelib);
2895 if (&variable_defined ($xlib . '_LIBADD'))
2897 &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
2903 # See if any _SOURCES variable were misspelled. Also, make sure that
2904 # EXTRA_ variables don't contain configure substitutions.
2907 foreach my $varname (keys %var_value)
2909 foreach my $primary ('_SOURCES', '_LIBADD', '_LDADD', '_LDFLAGS',
2912 if ($varname =~ /$primary$/ && ! $content_seen{$varname})
2914 &am_line_error ($varname,
2915 "invalid unused variable name: `$varname'");
2924 # NOTE we no longer automatically clean SCRIPTS, because it is
2925 # useful to sometimes distribute scripts verbatim. This happens
2926 # eg in Automake itself.
2927 &am_install_var ('-candist', 'scripts', 'SCRIPTS',
2928 'bin', 'sbin', 'libexec', 'pkgdata',
2933 # ($OUTFILE, $VFILE, @CLEAN_FILES)
2934 # &scan_texinfo_file ($FILENAME)
2935 # ------------------------------
2936 # $OUTFILE is the name of the info file produced by $FILENAME.
2937 # $VFILE is the name of the version.texi file used (empty if none).
2938 # @CLEAN_FILES is the list of by products (indexes etc.)
2939 sub scan_texinfo_file
2941 my ($filename) = @_;
2943 # These are always created, no matter whether indexes are used or not.
2944 my @clean_suffixes = ('aux', 'dvi', 'log', 'ps', 'toc',
2945 # grep new.*index texinfo.tex
2946 'cp', 'fn', 'ky', 'vr', 'tp', 'pg');
2948 # There are predefined indexes which don't follow the regular rules.
2949 my %predefined_index =
2952 'c' => 'cps', 'f' => 'fns', 'k' => 'kys',
2953 'v' => 'vrs', 't' => 'tps', 'p' => 'pgs'
2956 # There are commands which include a hidden index command.
2960 'fn' => 'fns', 'un' => 'fns',
2961 'typefn' => 'fns', 'typefun' => 'fns',
2962 'mac' => 'fns', 'spec' => 'fns',
2963 'op' => 'fns', 'typeop' => 'fns',
2964 'method' => 'fns', 'typemethod' => 'fns',
2966 'vr' => 'vrs', 'var' => 'vrs',
2967 'typevr' => 'vrs', 'typevar' => 'vrs',
2970 'ivar' => 'vrs', 'typeivar' => 'vrs',
2975 # Indexes stored into another one. In this case, the *.??s file
2977 my @syncodeindexes = ();
2979 my $texi = new IO::File ("< $filename");
2982 &am_error ("couldn't open `$filename': $!");
2985 print "$me: reading $filename\n" if $verbose;
2987 my ($outfile, $vfile);
2988 while ($_ = $texi->getline)
2990 if (/^\@setfilename +(\S+)/)
2993 if ($outfile =~ /\.(.+)$/ && $1 ne 'info')
2995 &am_file_error ($filename, "$.: ",
2996 "output `$outfile' has unrecognized extension");
3000 # A "version.texi" file is actually any file whose name
3001 # matches "vers*.texi".
3002 elsif (/^\@include\s+(vers[^.]*\.texi)\s*$/)
3007 # Try to find what are the indexes which are used.
3009 # Creating a new category of index.
3010 elsif (/^\@def(code)?index (\w+)/)
3012 push @clean_suffixes, $2;
3015 # Storing in a predefined index.
3016 elsif (/^\@([cfkvtp])index /)
3018 push @clean_suffixes, $predefined_index{$1};
3020 elsif (/^\@def(\w+) /)
3022 push @clean_suffixes, $hidden_index{$1}
3023 if defined $hidden_index{$1};
3026 # Merging an index into an another.
3027 elsif (/^\@syn(code)?index (\w+) (\w+)/)
3029 push @syncodeindexes, "$2s";
3030 push @clean_suffixes, "$3s";
3038 &am_error ("`$filename' missing \@setfilename");
3042 my $infobase = basename ($filename);
3043 $infobase =~ s/\.te?xi(nfo)?$//;
3044 # FIXME: I don't understand why, but I can't use "$infobase.$_" => 1.
3045 my %clean_files = map { "$infobase" . ".$_" => 1 } @clean_suffixes;
3046 grep { delete $clean_files{"$infobase.$_"} } @syncodeindexes;
3047 return ($outfile, $vfile, (sort keys %clean_files));
3051 # ($DO-SOMETHING, $TEXICLEANS)
3052 # handle_texinfo_helper ()
3054 # Handle all Texinfo source; helper for handle_texinfo
3055 sub handle_texinfo_helper
3057 &am_line_error ('TEXINFOS',
3058 "`TEXINFOS' is an anachronism; use `info_TEXINFOS'")
3059 if &variable_defined ('TEXINFOS');
3060 return (0, '') if (! &variable_defined ('info_TEXINFOS')
3061 && ! &variable_defined ('html_TEXINFOS'));
3063 if (&variable_defined ('html_TEXINFOS'))
3065 &am_line_error ('html_TEXINFOS',
3066 "HTML generation not yet supported");
3070 my @texis = &variable_value_as_list_recursive ('info_TEXINFOS', 'all');
3072 my (@info_deps_list, @dvis_list, @texi_deps);
3079 foreach my $info_cursor (@texis)
3081 my $infobase = $info_cursor;
3082 $infobase =~ s/\.(txi|texinfo|texi)$//;
3084 if ($infobase eq $info_cursor)
3086 # FIXME: report line number.
3087 &am_error ("texinfo file `$info_cursor' has unrecognized extension");
3090 $texi_suffixes{$1} = 1;
3092 # If 'version.texi' is referenced by input file, then include
3093 # automatic versioning capability.
3094 my ($out_file, $vtexi, @clean_files) =
3095 &scan_texinfo_file ("$relative_dir/$info_cursor")
3097 push (@texi_cleans, @clean_files);
3101 &am_error ("`$vtexi', included in `$info_cursor', also included in `$versions{$vtexi}'")
3102 if (defined $versions{$vtexi});
3103 $versions{$vtexi} = $info_cursor;
3105 # We number the stamp-vti files. This is doable since the
3106 # actual names don't matter much. We only number starting
3107 # with the second one, so that the common case looks nice.
3108 my $vti = ($done ? $done : 'vti');
3111 # This is ugly, but it is our historical practice.
3112 if ($config_aux_dir_set_in_configure_in)
3114 &require_conf_file_with_line ('info_TEXINFOS', $FOREIGN,
3119 &require_file_with_line ('info_TEXINFOS', $FOREIGN,
3124 if ($config_aux_dir_set_in_configure_in)
3126 $conf_dir = $config_aux_dir;
3127 $conf_dir .= '/' unless $conf_dir =~ /\/$/;
3131 $conf_dir = '$(srcdir)/';
3133 $output_rules .= &file_contents ('texi-vers',
3134 ('TEXI' => $info_cursor,
3137 'MDDIR' => $conf_dir));
3140 # If user specified file_TEXINFOS, then use that as explicit
3143 push (@texi_deps, $info_cursor);
3144 # Prefix with $(srcdir) because some version of make won't
3145 # work if the target has it and the dependency doesn't.
3146 push (@texi_deps, '$(srcdir)/' . $vtexi) if $vtexi;
3148 my $canonical = &canonicalize ($infobase);
3149 if (&variable_defined ($canonical . "_TEXINFOS"))
3151 push (@texi_deps, '$(' . $canonical . '_TEXINFOS)');
3152 &push_dist_common ('$(' . $canonical . '_TEXINFOS)');
3155 $output_rules .= ("\n" . $out_file . ": "
3156 . join (' ', @texi_deps)
3157 . "\n" . $infobase . ".dvi: "
3158 . join (' ', @texi_deps)
3161 push (@info_deps_list, $out_file);
3162 push (@dvis_list, $infobase . '.dvi');
3165 # Handle location of texinfo.tex.
3166 my $need_texi_file = 0;
3170 $texinfodir = '$(top_srcdir)/../texinfo';
3171 &define_variable ('TEXINFO_TEX', "$texinfodir/texinfo.tex");
3173 elsif ($config_aux_dir_set_in_configure_in)
3175 $texinfodir = $config_aux_dir;
3176 &define_variable ('TEXINFO_TEX', "$texinfodir/texinfo.tex");
3177 $need_texi_file = 2; # so that we require_conf_file later
3179 elsif (&variable_defined ('TEXINFO_TEX'))
3181 # The user defined TEXINFO_TEX so assume he knows what he is
3183 $texinfodir = ('$(srcdir)/'
3184 . dirname (&variable_value ('TEXINFO_TEX')));
3188 $texinfodir = '$(srcdir)';
3189 $need_texi_file = 1;
3192 foreach my $txsfx (sort keys %texi_suffixes)
3194 $output_rules .= &file_contents ('texibuild',
3195 ('TEXINFODIR' => $texinfodir,
3196 'SUFFIX' => $txsfx));
3200 my $texiclean = &pretty_print_internal ("", "\t ", @texi_cleans);
3202 push (@dist_targets, 'dist-info');
3204 if (! defined $options{'no-installinfo'})
3206 # Make sure documentation is made and installed first. Use
3207 # $(INFO_DEPS), not 'info', because otherwise recursive makes
3208 # get run twice during "make all".
3209 unshift (@all, '$(INFO_DEPS)');
3212 &define_variable ("INFO_DEPS", join (' ', @info_deps_list));
3213 &define_variable ("DVIS", join (' ', @dvis_list));
3214 # This next isn't strictly needed now -- the places that look here
3215 # could easily be changed to look in info_TEXINFOS. But this is
3216 # probably better, in case noinst_TEXINFOS is ever supported.
3217 &define_variable ("TEXINFOS", &variable_value ('info_TEXINFOS'));
3219 # Do some error checking. Note that this file is not required
3220 # when in Cygnus mode; instead we defined TEXINFO_TEX explicitly
3222 if ($need_texi_file && ! defined $options{'no-texinfo.tex'})
3224 if ($need_texi_file > 1)
3226 &require_conf_file_with_line ('info_TEXINFOS', $FOREIGN,
3231 &require_file_with_line ('info_TEXINFOS', $FOREIGN, 'texinfo.tex');
3235 return (1, $texiclean);
3240 # Handle all Texinfo source.
3243 my ($do_something, $texiclean) = handle_texinfo_helper ();
3244 $output_rules .= &file_contents ('texinfos',
3245 ('TEXICLEAN' => $texiclean,
3246 'LOCAL-TEXIS' => $do_something));
3249 # Handle any man pages.
3250 sub handle_man_pages
3252 &am_line_error ('MANS', "`MANS' is an anachronism; use `man_MANS'")
3253 if &variable_defined ('MANS');
3255 # Find all the sections in use. We do this by first looking for
3256 # "standard" sections, and then looking for any additional
3257 # sections used in man_MANS.
3258 my (%sections, %vlist);
3259 # We handle nodist_ for uniformity. man pages aren't distributed
3260 # by default so it isn't actually very important.
3261 foreach my $pfx ('', 'dist_', 'nodist_')
3263 # Add more sections as needed.
3264 foreach my $section ('0'..'9', 'n', 'l')
3266 if (&variable_defined ($pfx . 'man' . $section . '_MANS'))
3268 $sections{$section} = 1;
3269 $vlist{'$(' . $pfx . 'man' . $section . '_MANS)'} = 1;
3271 &push_dist_common ('$(' . $pfx . 'man' . $section . '_MANS)')
3276 if (&variable_defined ($pfx . 'man_MANS'))
3278 $vlist{'$(' . $pfx . 'man_MANS)'} = 1;
3279 foreach (&variable_value_as_list_recursive ($pfx . 'man_MANS', 'all'))
3281 # A page like `foo.1c' goes into man1dir.
3282 if (/\.([0-9a-z])([a-z]*)$/)
3288 &push_dist_common ('$(' . $pfx . 'man_MANS)')
3293 return unless %sections;
3295 # Now for each section, generate an install and unintall rule.
3296 # Sort sections so output is deterministic.
3297 foreach my $section (sort keys %sections)
3299 $output_rules .= &file_contents ('mans', ('SECTION' => $section));
3302 $output_vars .= &file_contents ('mans-vars',
3303 ('MANS' => join (' ', sort keys %vlist)));
3305 if (! defined $options{'no-installman'})
3307 push (@all, '$(MANS)');
3311 # Handle DATA variables.
3314 &am_install_var ('-noextra', '-candist', 'data', 'DATA',
3315 'data', 'sysconf', 'sharedstate', 'localstate',
3316 'pkgdata', 'noinst', 'check');
3323 if (&variable_defined ('SUBDIRS'))
3325 $output_rules .= ("tags-recursive:\n"
3326 . "\tlist=\'\$(SUBDIRS)\'; for subdir in \$\$list; do \\\n"
3327 # Never fail here if a subdir fails; it
3329 . "\t test \"\$\$subdir\" = . || (cd \$\$subdir"
3330 . " && \$(MAKE) \$(AM_MAKEFLAGS) tags); \\\n"
3332 push (@tag_deps, 'tags-recursive');
3333 &depend ('.PHONY', 'tags-recursive');
3336 if (&saw_sources_p (1)
3337 || &variable_defined ('ETAGS_ARGS')
3341 foreach my $one_hdr (@config_headers)
3343 if ($relative_dir eq dirname ($one_hdr))
3345 # The config header is in this directory. So require it.
3346 $config .= ' ' if $config;
3347 $config .= basename ($one_hdr);
3350 $output_rules .= &file_contents ('tags',
3351 ('CONFIG' => $config,
3352 'DIRS' => join (' ', @tag_deps)));
3353 &examine_variable ('TAGS_DEPENDENCIES');
3355 elsif (&variable_defined ('TAGS_DEPENDENCIES'))
3357 &am_line_error ('TAGS_DEPENDENCIES',
3358 "doesn't make sense to define `TAGS_DEPENDENCIES' without sources or `ETAGS_ARGS'");
3362 # Every Makefile must define some sort of TAGS rule.
3363 # Otherwise, it would be possible for a top-level "make TAGS"
3364 # to fail because some subdirectory failed.
3365 $output_rules .= "tags: TAGS\nTAGS:\n\n";
3369 # Handle multilib support.
3372 if ($seen_multilib && $relative_dir eq '.')
3374 $output_rules .= &file_contents ('multilib');
3380 # &for_dist_common ($A, $B)
3381 # -------------------------
3382 # Subroutine for &handle_dist: sort files to dist.
3384 # We put README first because it then becomes easier to make a
3385 # Usenet-compliant shar file (in these, README must be first).
3387 # FIXME: do more ordering of files here.
3400 # handle_dist ($MAKEFILE)
3401 # -----------------------
3402 # Handle 'dist' target.
3405 my ($makefile) = @_;
3407 # `make dist' isn't used in a Cygnus-style tree.
3408 # Omit the rules so that people don't try to use them.
3409 return if $cygnus_mode;
3411 # Look for common files that should be included in distribution.
3412 # If the aux dir is set, and it does not have a Makefile.am, then
3413 # we check for these files there as well.
3416 if ($relative_dir eq '.'
3417 && $config_aux_dir_set_in_configure_in)
3419 ($auxdir = $config_aux_dir) =~ s,^\$\(top_srcdir\)/,,;
3420 if (! &is_make_dir ($auxdir))
3425 foreach my $cfile (@common_files)
3427 if (-f ($relative_dir . "/" . $cfile))
3429 &push_dist_common ($cfile);
3432 # Don't use `elsif' here because a file might meaningfully
3433 # appear in both directories.
3434 if ($check_aux && -f ($auxdir . '/' . $cfile))
3436 &push_dist_common ($auxdir . '/' . $cfile);
3440 # We might copy elements from $configure_dist_common to
3441 # %dist_common if we think we need to. If the file appears in our
3442 # directory, we would have discovered it already, so we don't
3443 # check that. But if the file is in a subdir without a Makefile,
3444 # we want to distribute it here if we are doing `.'. Ugly!
3445 if ($relative_dir eq '.')
3447 foreach my $file (split (' ' , $configure_dist_common))
3449 if (! &is_make_dir (dirname ($file)))
3451 &push_dist_common ($file);
3458 # Files to distributed. Don't use &variable_value_as_list_recursive
3459 # as it recursively expands `$(dist_pkgdata_DATA)' etc.
3460 check_variable_defined_unconditionally ('DIST_COMMON');
3461 my @dist_common = split (' ', variable_value ('DIST_COMMON', 'TRUE'));
3462 @dist_common = uniq (sort for_dist_common (@dist_common));
3463 pretty_print ('DIST_COMMON = ', "\t", @dist_common);
3465 # Now that we've processed DIST_COMMON, disallow further attempts
3467 $handle_dist_run = 1;
3469 # Scan EXTRA_DIST to see if we need to distribute anything from a
3470 # subdir. If so, add it to the list. I didn't want to do this
3471 # originally, but there were so many requests that I finally
3473 if (&variable_defined ('EXTRA_DIST'))
3475 # FIXME: This should be fixed to work with conditionals. That
3476 # will require only making the entries in %dist_dirs under the
3477 # appropriate condition. This is meaningful if the nature of
3478 # the distribution should depend upon the configure options
3480 foreach (&variable_value_as_list_recursive ('EXTRA_DIST', ''))
3483 next unless s,/+[^/]+$,,;
3489 # We have to check DIST_COMMON for extra directories in case the
3490 # user put a source used in AC_OUTPUT into a subdir.
3491 foreach (&variable_value_as_list_recursive ('DIST_COMMON', 'all'))
3494 next unless s,/+[^/]+$,,;
3499 # Rule to check whether a distribution is viable.
3500 my %transform = ('DISTCHECK-HOOK' => &target_defined ('distcheck-hook'),
3501 'GETTEXT' => $seen_gettext);
3503 # Prepend $(distdir) to each directory given.
3504 my %rewritten = map { '$(distdir)/' . "$_" => 1 } keys %dist_dirs;
3505 $transform{'DISTDIRS'} = join (' ', sort keys %rewritten);
3507 # If we have SUBDIRS, create all dist subdirectories and do
3509 if (&variable_defined ('SUBDIRS'))
3511 # If SUBDIRS is conditionally defined, then set DIST_SUBDIRS
3512 # to all possible directories, and use it. If DIST_SUBDIRS is
3513 # defined, just use it.
3514 my $dist_subdir_name;
3515 # Note that we check DIST_SUBDIRS first on purpose. At least
3516 # one project uses so many conditional subdirectories that
3517 # calling variable_conditionally_defined on SUBDIRS will cause
3518 # automake to grow to 150Mb. Sigh.
3519 if (&variable_defined ('DIST_SUBDIRS')
3520 || variable_conditionally_defined ('SUBDIRS'))
3522 $dist_subdir_name = 'DIST_SUBDIRS';
3523 if (! &variable_defined ('DIST_SUBDIRS'))
3525 &define_pretty_variable
3526 ('DIST_SUBDIRS', '',
3527 uniq (&variable_value_as_list_recursive ('SUBDIRS', 'all')));
3532 $dist_subdir_name = 'SUBDIRS';
3533 # We always define this because that is what `distclean'
3535 &define_pretty_variable ('DIST_SUBDIRS', '', '$(SUBDIRS)');
3538 $transform{'DIST_SUBDIR_NAME'} = $dist_subdir_name;
3541 # If the target `dist-hook' exists, make sure it is run. This
3542 # allows users to do random weird things to the distribution
3543 # before it is packaged up.
3544 push (@dist_targets, 'dist-hook')
3545 if &target_defined ('dist-hook');
3546 $transform{'DIST-TARGETS'} = join(' ', @dist_targets);
3548 # Defining $(DISTDIR).
3549 $transform{'DISTDIR'} = !&variable_defined('distdir');
3550 $transform{'TOP_DISTDIR'} = backname ($relative_dir);
3552 $output_rules .= &file_contents ('distdir', %transform);
3556 # Handle subdirectories.
3560 unless &variable_defined ('SUBDIRS');
3562 # Make sure each directory mentioned in SUBDIRS actually exists.
3563 foreach my $dir (&variable_value_as_list_recursive ('SUBDIRS', 'all'))
3565 # Skip directories substituted by configure.
3566 next if $dir =~ /^\@.*\@$/;
3568 if (! -d $am_relative_dir . '/' . $dir)
3570 &am_line_error ('SUBDIRS',
3571 "required directory $am_relative_dir/$dir does not exist");
3575 &am_line_error ('SUBDIRS', "directory should not contain `/'")
3579 $output_rules .= &file_contents ('subdirs');
3580 variable_pretty_output ('RECURSIVE_TARGETS', 'TRUE');
3584 # ($REGEN, @DEPENDENCIES)
3587 # If aclocal.m4 creation is automated, return the list of its dependencies.
3590 my $regen_aclocal = 0;
3593 unless $relative_dir eq '.';
3595 &examine_variable ('CONFIG_STATUS_DEPENDENCIES');
3596 &examine_variable ('CONFIGURE_DEPENDENCIES');
3598 if (-f 'aclocal.m4')
3600 &define_variable ("ACLOCAL_M4", '$(top_srcdir)/aclocal.m4');
3601 &push_dist_common ('aclocal.m4');
3603 my $aclocal = new IO::File ("< aclocal.m4");
3606 my $line = $aclocal->getline;
3609 if ($line =~ 'generated automatically by aclocal')
3618 if (-f 'acinclude.m4')
3621 push @ac_deps, 'acinclude.m4';
3624 if (&variable_defined ('ACLOCAL_M4_SOURCES'))
3626 push (@ac_deps, '$(ACLOCAL_M4_SOURCES)');
3628 elsif (&variable_defined ('ACLOCAL_AMFLAGS'))
3630 # Scan all -I directories for m4 files. These are our
3632 my $examine_next = 0;
3633 foreach my $amdir (&variable_value_as_list_recursive ('ACLOCAL_AMFLAGS', ''))
3638 if ($amdir !~ /^\// && -d $amdir)
3640 foreach my $ac_dep (&my_glob ($amdir . '/*.m4'))
3642 $ac_dep =~ s/^\.\/+//;
3643 push (@ac_deps, $ac_dep)
3644 unless $ac_dep eq "aclocal.m4"
3645 || $ac_dep eq "acinclude.m4";
3649 elsif ($amdir eq '-I')
3656 # Note that it might be possible that aclocal.m4 doesn't exist but
3657 # should be auto-generated. This case probably isn't very
3660 return ($regen_aclocal, @ac_deps);
3663 # Rewrite a list of input files into a form suitable to put on a
3664 # dependency list. The idea is that if an input file has a directory
3665 # part the same as the current directory, then the directory part is
3666 # simply removed. But if the directory part is different, then
3667 # $(top_srcdir) is prepended. Among other things, this is used to
3668 # generate the dependency list for the output files generated by
3669 # AC_OUTPUT. Consider what the dependencies should look like in this
3671 # AC_OUTPUT(src/out:src/in1:lib/in2)
3672 # The first argument, ADD_SRCDIR, is 1 if $(top_srcdir) should be added.
3673 # If 0 then files that require this addition will simply be ignored.
3674 sub rewrite_inputs_into_dependencies
3676 my ($add_srcdir, @inputs) = @_;
3679 foreach my $single (@inputs)
3681 if (dirname ($single) eq $relative_dir)
3683 push (@newinputs, basename ($single));
3687 push (@newinputs, '$(top_srcdir)/' . $single);
3694 # Handle remaking and configure stuff.
3695 # We need the name of the input file, to do proper remaking rules.
3696 sub handle_configure
3698 my ($local, $input, @secondary_inputs) = @_;
3700 my $input_base = basename ($input);
3701 my $local_base = basename ($local);
3703 my $amfile = $input_base . '.am';
3704 # We know we can always add '.in' because it really should be an
3705 # error if the .in was missing originally.
3706 my $infile = '$(srcdir)/' . $input_base . '.in';
3707 my $colon_infile = '';
3708 if ($local ne $input || @secondary_inputs)
3710 $colon_infile = ':' . $input . '.in';
3712 $colon_infile .= ':' . join (':', @secondary_inputs)
3713 if @secondary_inputs;
3715 my @rewritten = &rewrite_inputs_into_dependencies (1, @secondary_inputs);
3717 my ($regen_aclocal_m4, @aclocal_m4_deps) = scan_aclocal_m4 ();
3720 &file_contents ('configure',
3724 => join (' ', @rewritten),
3726 => ((($relative_dir eq '.') ? '$@' : '$(subdir)/$@')
3731 => join (' ', @include_stack),
3735 => $cygnus_mode ? 'cygnus' : $strictness_name,
3737 => $cmdline_use_dependencies ? '' : ' --ignore-deps',
3738 'MAKEFILE-AM-SOURCES'
3739 => "$input$colon_infile",
3741 => $regen_aclocal_m4,
3743 => join (' ', @aclocal_m4_deps)));
3745 if ($relative_dir eq '.')
3747 &push_dist_common ('acconfig.h')
3751 # If we have a configure header, require it.
3752 my @local_fullnames = @config_fullnames;
3753 my @local_names = @config_names;
3755 my $distclean_config = '';
3756 foreach my $one_hdr (@config_headers)
3758 my $one_fullname = shift (@local_fullnames);
3759 my $one_name = shift (@local_names);
3761 my $header_dir = dirname ($one_name);
3763 # If the header is in the current directory we want to build
3764 # the header here. Otherwise, if we're at the topmost
3765 # directory and the header's directory doesn't have a
3766 # Makefile, then we also want to build the header.
3767 if ($relative_dir eq $header_dir
3768 || ($relative_dir eq '.' && ! &is_make_dir ($header_dir)))
3770 my ($cn_sans_dir, $stamp_dir);
3771 if ($relative_dir eq $header_dir)
3773 $cn_sans_dir = basename ($one_name);
3778 $cn_sans_dir = $one_name;
3779 if ($header_dir eq '.')
3785 $stamp_dir = $header_dir . '/';
3789 # Compute relative path from directory holding output
3790 # header to directory holding input header. FIXME:
3791 # doesn't handle case where we have multiple inputs.
3793 if (dirname ($one_hdr) eq $relative_dir)
3795 $ch_sans_dir = basename ($one_hdr);
3799 $ch_sans_dir = backname ($relative_dir) . '/' . $one_hdr;
3802 &require_file_with_conf_line ($config_header_line,
3803 $FOREIGN, $ch_sans_dir);
3805 # Header defined and in this directory.
3807 if (-f $one_name . '.top')
3809 push (@files, "${cn_sans_dir}.top");
3811 if (-f $one_name . '.bot')
3813 push (@files, "${cn_sans_dir}.bot");
3816 &push_dist_common (@files);
3818 # For now, acconfig.h can only appear in the top srcdir.
3819 if (-f 'acconfig.h')
3821 push (@files, '$(top_srcdir)/acconfig.h');
3824 my $stamp_name = 'stamp-h';
3825 $stamp_name .= "${hdr_index}" if scalar (@config_headers) > 1;
3827 my $out_dir = dirname ($ch_sans_dir);
3830 &file_contents ('remake-hdr',
3831 ('FILES' => join (' ', @files),
3832 'CONFIG_HEADER' => $cn_sans_dir,
3833 'CONFIG_HEADER_IN' => $ch_sans_dir,
3834 'CONFIG_HEADER_FULL' => $one_fullname,
3835 'STAMP' => "$stamp_dir$stamp_name",
3836 'SRC_STAMP' => "$out_dir/$stamp_name"));
3838 &create ("${relative_dir}/${out_dir}/${stamp_name}.in");
3839 &require_file_with_conf_line ($config_header_line, $FOREIGN,
3840 "${out_dir}/${stamp_name}.in");
3842 $distclean_config .= ' ' if $distclean_config;
3843 $distclean_config .= $cn_sans_dir;
3847 if ($distclean_config)
3849 $output_rules .= &file_contents ('clean-hdr',
3850 ('FILES' => $distclean_config));
3853 # Set location of mkinstalldirs.
3854 &define_variable ('mkinstalldirs',
3855 ('$(SHELL) ' . $config_aux_dir . '/mkinstalldirs'));
3857 &am_line_error ('CONFIG_HEADER',
3858 "`CONFIG_HEADER' is an anachronism; now determined from `$configure_ac'")
3859 if &variable_defined ('CONFIG_HEADER');
3861 my $config_header = '';
3862 foreach my $one_name (@config_names)
3864 # Generate CONFIG_HEADER define.
3866 if ($relative_dir eq dirname ($one_name))
3868 $one_hdr = basename ($one_name);
3872 $one_hdr = "\$(top_builddir)/${one_name}";
3875 $config_header .= ' ' if $config_header;
3876 $config_header .= $one_hdr;
3880 &define_variable ("CONFIG_HEADER", $config_header);
3883 # Now look for other files in this directory which must be remade
3884 # by config.status, and generate rules for them.
3885 my @actual_other_files = ();
3886 foreach my $lfile (@other_input_files)
3889 my (@inputs, @rewritten_inputs);
3890 my ($need_rewritten);
3891 if ($lfile =~ /^([^:]*):(.*)$/)
3893 # This is the ":" syntax of AC_OUTPUT.
3895 $local = basename ($file);
3896 @inputs = split (':', $2);
3897 @rewritten_inputs = &rewrite_inputs_into_dependencies (1, @inputs);
3898 $need_rewritten = 1;
3904 $local = basename ($file);
3905 @inputs = ($file . '.in');
3907 &rewrite_inputs_into_dependencies (1, @inputs);
3908 $need_rewritten = 0;
3911 # Make sure the dist directory for each input file is created.
3912 # We only have to do this at the topmost level though. This
3913 # is a bit ugly but it easier than spreading out the logic,
3914 # especially in cases like AC_OUTPUT(foo/out:bar/in), where
3915 # there is no Makefile in bar/.
3916 if ($relative_dir eq '.')
3920 $dist_dirs{dirname ($_)} = 1;
3924 # We skip any automake input files, as they are handled
3925 # elsewhere. We also skip files that aren't in this
3926 # directory. However, if the file's directory does not have a
3927 # Makefile, and we are currently doing `.', then we create a
3928 # rule to rebuild the file in the subdir.
3929 next if -f $file . '.am';
3930 my $fd = dirname ($file);
3931 if ($fd ne $relative_dir)
3933 if ($relative_dir eq '.' && ! &is_make_dir ($fd))
3943 # Some users have been tempted to put `stamp-h' in the
3944 # AC_OUTPUT line. This won't do the right thing, so we
3945 # explicitly fail here.
3946 if ($local eq 'stamp-h')
3948 # FIXME: allow real filename.
3949 &am_conf_error ($configure_ac, $ac_output_line,
3950 'stamp-h should not appear in AC_OUTPUT');
3954 $output_rules .= ($local . ': '
3955 . '$(top_builddir)/config.status '
3956 . join (' ', @rewritten_inputs) . "\n"
3958 . 'cd $(top_builddir) && CONFIG_FILES='
3959 . ($relative_dir eq '.' ? '' : '$(subdir)/')
3960 . '$@' . ($need_rewritten
3961 ? (':' . join (':', @inputs))
3963 . ' CONFIG_HEADERS= CONFIG_LINKS= $(SHELL) ./config.status'
3965 push (@actual_other_files, $local);
3967 # Require all input files.
3968 &require_file_with_conf_line ($ac_output_line, $FOREIGN,
3969 &rewrite_inputs_into_dependencies (0, @inputs));
3972 # These files get removed by "make clean".
3973 &define_pretty_variable ('CONFIG_CLEAN_FILES', '', @actual_other_files);
3979 my @r = &am_install_var ('-defaultdist', 'header', 'HEADERS', 'include',
3980 'oldinclude', 'pkginclude',
3984 next unless /\.(.*)$/;
3985 &saw_extension ($1);
3991 return if ! $seen_gettext || $relative_dir ne '.';
3993 if (! &variable_defined ('SUBDIRS'))
3996 ("AM_GNU_GETTEXT used but SUBDIRS not defined");
4000 my @subdirs = &variable_value_as_list_recursive ('SUBDIRS', 'all');
4001 &am_line_error ('SUBDIRS',
4002 "AM_GNU_GETTEXT used but `po' not in SUBDIRS")
4003 if ! grep ('po', @subdirs);
4004 &am_line_error ('SUBDIRS',
4005 "AM_GNU_GETTEXT used but `intl' not in SUBDIRS")
4006 if ! grep ('intl', @subdirs);
4008 &require_file_with_conf_line ($ac_gettext_line, $GNU, 'ABOUT-NLS');
4011 # Handle footer elements.
4014 # NOTE don't use define_pretty_variable here, because
4015 # $contents{...} is already defined.
4016 $output_vars .= 'SOURCES = ' . variable_value ('SOURCES') . "\n\n"
4017 if variable_value ('SOURCES');
4020 &am_line_error ('.SUFFIXES',
4021 "use variable `SUFFIXES', not target `.SUFFIXES'")
4022 if target_defined ('.SUFFIXES');
4024 # Note: AIX 4.1 /bin/make will fail if any suffix rule appears
4025 # before .SUFFIXES. So we make sure that .SUFFIXES appears before
4026 # anything else, by sticking it right after the default: target.
4027 $output_header .= ".SUFFIXES:\n";
4028 if (@suffixes || &variable_defined ('SUFFIXES'))
4030 # Make sure suffixes has unique elements. Sort them to ensure
4031 # the output remains consistent. However, $(SUFFIXES) is
4032 # always at the start of the list, unsorted. This is done
4033 # because make will choose rules depending on the ordering of
4034 # suffixes, and this lets the user have some control. Push
4035 # actual suffixes, and not $(SUFFIXES). Some versions of make
4036 # do not like variable substitutions on the .SUFFIXES line.
4037 my @user_suffixes = (&variable_defined ('SUFFIXES')
4038 ? &variable_value_as_list_recursive ('SUFFIXES', '')
4041 my %suffixes = map { $_ => 1 } @suffixes;
4042 delete @suffixes{@user_suffixes};
4044 $output_header .= (".SUFFIXES: "
4045 . join (' ', @user_suffixes, sort keys %suffixes)
4049 $output_trailer .= file_contents ('footer');
4052 # Deal with installdirs target.
4053 sub handle_installdirs ()
4056 &file_contents ('install',
4058 => variable_value ('_am_installdirs') || ''));
4062 # Deal with all and all-am.
4065 my ($makefile) = @_;
4069 # Put this at the beginning for the sake of non-GNU makes. This
4070 # is still wrong if these makes can run parallel jobs. But it is
4072 unshift (@all, basename ($makefile));
4074 foreach my $one_name (@config_names)
4076 push (@all, basename ($one_name))
4077 if dirname ($one_name) eq $relative_dir;
4080 # Install `all' hooks.
4081 if (&target_defined ("all-local"))
4083 push (@all, "all-local");
4084 &depend ('.PHONY', "all-local");
4087 &pretty_print_rule ("all-am:", "\t\t", @all);
4088 &depend ('.PHONY', 'all-am', 'all');
4093 my @local_headers = ();
4094 push @local_headers, '$(BUILT_SOURCES)'
4095 if &variable_defined ('BUILT_SOURCES');
4096 foreach my $one_name (@config_names)
4098 push @local_headers, basename ($one_name)
4099 if dirname ($one_name) eq $relative_dir;
4104 # We need to make sure config.h is built before we recurse.
4105 # We also want to make sure that built sources are built
4106 # before any ordinary `all' targets are run. We can't do this
4107 # by changing the order of dependencies to the "all" because
4108 # that breaks when using parallel makes. Instead we handle
4109 # things explicitly.
4110 $output_all .= ("all: " . join (' ', @local_headers)
4112 . '$(MAKE) $(AM_MAKEFLAGS) '
4113 . (&variable_defined ('SUBDIRS')
4114 ? 'all-recursive' : 'all-am')
4119 $output_all .= "all: " . (&variable_defined ('SUBDIRS')
4120 ? 'all-recursive' : 'all-am') . "\n\n";
4125 # Handle check merge target specially.
4126 sub do_check_merge_target
4128 if (&target_defined ('check-local'))
4130 # User defined local form of target. So include it.
4131 push (@check_tests, 'check-local');
4132 &depend ('.PHONY', 'check-local');
4135 # In --cygnus mode, check doesn't depend on all.
4138 # Just run the local check rules.
4139 &pretty_print_rule ('check-am:', "\t\t", @check);
4143 # The check target must depend on the local equivalent of
4144 # `all', to ensure all the primary targets are built. Then it
4145 # must build the local check rules.
4146 $output_rules .= "check-am: all-am\n";
4147 &pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ",
4151 &pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ",
4155 &depend ('.PHONY', 'check', 'check-am');
4156 $output_rules .= ("check: "
4157 . (&variable_defined ('SUBDIRS')
4158 ? 'check-recursive' : 'check-am')
4162 # Handle all 'clean' targets.
4167 # Don't include `MAINTAINER'; it is handled specially below.
4168 foreach my $name ('MOSTLY', '', 'DIST')
4170 $transform{"${name}CLEAN"} = &variable_defined ("${name}CLEANFILES");
4173 # Built sources are automatically removed by maintainer-clean.
4174 push (@maintainer_clean_files, '$(BUILT_SOURCES)')
4175 if &variable_defined ('BUILT_SOURCES');
4176 push (@maintainer_clean_files, '$(MAINTAINERCLEANFILES)')
4177 if &variable_defined ('MAINTAINERCLEANFILES');
4179 $output_rules .= &file_contents ('clean',
4182 # Join with no space to avoid
4183 # spurious `test -z' success at
4185 => join ('', @maintainer_clean_files),
4187 # A space is required in the join here.
4188 => join (' ', @maintainer_clean_files)));
4192 # &depend ($CATEGORY, @DEPENDENDEES)
4193 # ----------------------------------
4194 # The target $CATEGORY depends on @DEPENDENDEES.
4197 my ($category, @dependendees) = @_;
4199 push (@{$dependencies{$category}}, @dependendees);
4204 # &target_cmp ($A, $B)
4205 # --------------------
4206 # Subroutine for &handle_factored_dependencies to let `.PHONY' be last.
4219 # &handle_factored_dependencies ()
4220 # --------------------------------
4221 # Handle everything related to gathered targets.
4222 sub handle_factored_dependencies
4225 foreach my $utarg ('uninstall-data-local', 'uninstall-data-hook',
4226 'uninstall-exec-local', 'uninstall-exec-hook')
4228 if (&target_defined ($utarg))
4231 $x =~ s/(data|exec)-//;
4232 &am_line_error ($utarg, "use `$x', not `$utarg'");
4236 if (&target_defined ('install-local'))
4238 &am_line_error ('install-local',
4239 "use `install-data-local' or `install-exec-local', "
4240 . "not `install-local'");
4243 if (!defined $options{'no-installinfo'}
4244 && &target_defined ('install-info-local'))
4246 &am_line_error ('install-info-local',
4247 "`install-info-local' target defined but "
4248 . "`no-installinfo' option not in use");
4251 # Install the -local hooks.
4252 foreach (keys %dependencies)
4254 # Hooks are installed on the -am targets.
4256 if (&target_defined ("$_-local"))
4258 depend ("$_-am", "$_-local");
4259 &depend ('.PHONY', "$_-local");
4263 # Install the -hook hooks.
4264 # FIXME: Why not be as liberal as we are with -local hooks?
4265 foreach ('install-exec', 'install-data')
4267 if (&target_defined ("$_-hook"))
4269 $actions{"$_-am"} .=
4270 ("\t\@\$(NORMAL_INSTALL)\n"
4271 . "\t" . '$(MAKE) $(AM_MAKEFLAGS) ' . "$_-hook\n");
4275 # All the required targets are phony.
4276 depend ('.PHONY', keys %required_targets);
4278 # Actually output gathered targets.
4279 foreach (sort target_cmp keys %dependencies)
4281 # If there is nothing about this guy, skip it.
4283 unless (@{$dependencies{$_}}
4285 || $required_targets{$_});
4286 &pretty_print_rule ("$_:", "\t",
4287 uniq (sort @{$dependencies{$_}}));
4288 $output_rules .= $actions{$_}
4289 if defined $actions{$_};
4290 $output_rules .= "\n";
4295 # &handle_tests_dejagnu ()
4296 # ------------------------
4297 sub handle_tests_dejagnu
4299 push (@check_tests, 'check-DEJAGNU');
4300 $output_rules .= file_contents ('dejagnu');
4304 # Handle TESTS variable and other checks.
4307 if (defined $options{'dejagnu'})
4309 &handle_tests_dejagnu;
4313 foreach my $c ('DEJATOOL', 'RUNTEST', 'RUNTESTFLAGS')
4316 "`$c' defined but `dejagnu' not in `AUTOMAKE_OPTIONS'")
4317 if &variable_defined ($c);
4321 if (&variable_defined ('TESTS'))
4323 push (@check_tests, 'check-TESTS');
4324 $output_rules .= &file_contents ('check');
4328 # Handle Emacs Lisp.
4329 sub handle_emacs_lisp
4331 my @elfiles = &am_install_var ('-candist', 'lisp', 'LISP',
4334 return if ! @elfiles;
4336 # Generate .elc files.
4337 my @elcfiles = map { $_ . 'c' } @elfiles;
4338 &define_pretty_variable ('ELCFILES', '', @elcfiles);
4340 push (@all, '$(ELCFILES)');
4342 &am_error ("`lisp_LISP' defined but `AM_PATH_LISPDIR' not in `$configure_ac'")
4343 if ! $seen_lispdir && &variable_defined ('lisp_LISP');
4345 &require_file_with_conf_line ('AM_PATH_LISPDIR', $FOREIGN, 'elisp-comp');
4351 my @pyfiles = &am_install_var ('-defaultdist', 'python', 'PYTHON',
4352 'python', 'noinst');
4353 return if ! @pyfiles;
4355 # Found some python.
4356 &am_error ("`python_PYTHON' defined but `AM_PATH_PYTHON' not in `$configure_ac'")
4357 if ! $seen_pythondir && &variable_defined ('python_PYTHON');
4359 &require_file_with_conf_line ('AM_PATH_PYTHON', $FOREIGN, 'py-compile');
4360 &define_variable ('py_compile', $config_aux_dir . '/py-compile');
4366 my @sourcelist = &am_install_var ('-candist',
4368 'java', 'noinst', 'check');
4369 return if ! @sourcelist;
4371 my %valid = &am_primary_prefixes ('JAVA', 1,
4372 'java', 'noinst', 'check');
4375 foreach my $curs (keys %valid)
4377 if (! &variable_defined ($curs . '_JAVA') || $curs eq 'EXTRA')
4384 &am_line_error ($curs . '_JAVA',
4385 "multiple _JAVA primaries in use");
4390 push (@all, 'class' . $dir . '.stamp');
4394 # Handle some of the minor options.
4395 sub handle_minor_options
4397 if (defined $options{'readme-alpha'})
4399 if ($relative_dir eq '.')
4401 if ($package_version !~ /^$GNITS_VERSION_PATTERN$/)
4403 # FIXME: allow real filename.
4404 &am_conf_line_error ($configure_ac,
4405 $package_version_line,
4406 "version `$package_version' doesn't follow Gnits standards");
4408 elsif (defined $1 && -f 'README-alpha')
4410 # This means we have an alpha release. See
4411 # GNITS_VERSION_PATTERN for details.
4412 &require_file ($FOREIGN, 'README-alpha');
4418 ################################################################
4422 # &scan_autoconf_config_files ($CONFIG-FILES)
4423 # -------------------------------------------
4424 # Study $CONFIG-FILES which is the first argument to AC_CONFIG_FILES
4426 sub scan_autoconf_config_files
4428 my ($config_files) = @_;
4429 # Look at potential Makefile.am's.
4430 foreach (split ' ', $config_files)
4432 # Must skip empty string for Perl 4.
4433 next if $_ eq "\\" || $_ eq '';
4435 # Handle $local:$input syntax. Note that we ignore
4436 # every input file past the first, though we keep
4437 # those around for later.
4438 my ($local, $input, @rest) = split (/:/);
4445 # FIXME: should be error if .in is missing.
4446 $input =~ s/\.in$//;
4449 if (-f $input . '.am')
4451 # We have a file that automake should generate.
4452 $make_list{$input} = join (':', ($local, @rest));
4456 # We have a file that automake should cause to be
4457 # rebuilt, but shouldn't generate itself.
4458 push (@other_input_files, $_);
4464 # &scan_autoconf_traces ($FILENAME)
4465 # ---------------------------------
4466 # FIXME: For the time being, we don't care about the FILENAME.
4467 sub scan_autoconf_traces
4469 my ($filename) = @_;
4471 my $traces = "$ENV{amtraces} ";
4473 $traces .= ' -t AC_CONFIG_FILES';
4474 $traces .= ' -t AC_LIBSOURCE';
4475 $traces .= ' -t AC_SUBST';
4477 my $tracefh = new IO::File ("$traces |");
4480 die "$me: couldn't open `$traces': $!\n";
4482 print "$me: reading $traces\n" if $verbose;
4484 while ($_ = $tracefh->getline)
4487 my ($file, $line, $macro, @args) = split /:/;
4488 my $here = "$file:$line";
4490 # Alphabetical ordering please.
4491 if ($macro eq 'AC_CONFIG_FILES')
4493 # Look at potential Makefile.am's.
4494 &scan_autoconf_config_files ($args[0]);
4496 elsif ($macro eq 'AC_LIBSOURCE')
4498 my $source = "$args[0].c";
4499 # We should actually also `close' the sources: getopt.c
4500 # wants getopt.h etc. But actually it should be done in the
4501 # macro itself, i.e., we have to first fix Autoconf to extend
4502 # _AC_LIBOBJ_DECL and use it the in various macros.
4503 if (!defined $libsources{$source})
4505 print STDERR "traces: discovered $source\n";
4506 $libsources{$source} = $here;
4509 elsif ($macro eq 'AC_SUBST')
4511 if (!defined $configure_vars{$args[0]})
4513 print STDERR "traces: discovered AC_SUBST($args[0])\n";
4514 $configure_vars{$args[0]} = $here;
4520 || die "$me: close: $traces: $!\n";
4524 # &scan_one_autoconf_file ($FILENAME)
4525 # -----------------------------------
4526 # Scan one file for interesting things. Subroutine of
4527 # &scan_autoconf_files.
4528 sub scan_one_autoconf_file
4530 my ($filename) = @_;
4532 my $configfh = new IO::File ("< $filename");
4535 die "$me: couldn't open `$filename': $!\n";
4537 print "$me: reading $filename\n" if $verbose;
4539 my ($in_ac_output, $in_ac_replace) = (0, 0);
4540 while ($_ = $configfh->getline)
4542 # Remove comments from current line.
4546 # Skip macro definitions. Otherwise we might be confused into
4547 # thinking that a macro that was only defined was actually
4551 # Follow includes. This is a weirdness commonly in use at
4552 # Cygnus and hopefully nowhere else.
4553 if (/sinclude\((.*)\)/ && -f $1)
4555 # $_ being local, if we don't preserve it, when coming
4556 # back we will have $_ undefined, which is bad for the
4557 # the rest of this routine.
4558 my $underscore = $_;
4559 &scan_one_autoconf_file ($1);
4563 # Populate libobjs array.
4564 if (/AC_FUNC_ALLOCA/)
4566 $libsources{'alloca.c'} = 1;
4568 elsif (/AC_FUNC_GETLOADAVG/)
4570 $libsources{'getloadavg.c'} = 1;
4572 elsif (/AC_FUNC_MEMCMP/)
4574 $libsources{'memcmp.c'} = 1;
4576 elsif (/AC_STRUCT_ST_BLOCKS/)
4578 $libsources{'fileblocks.c'} = 1;
4580 elsif (/A[CM]_REPLACE_GNU_GETOPT/)
4582 $libsources{'getopt.c'} = 1;
4583 $libsources{'getopt1.c'} = 1;
4585 elsif (/AM_FUNC_STRTOD/)
4587 $libsources{'strtod.c'} = 1;
4589 elsif (/AM_WITH_REGEX/)
4591 $libsources{'rx.c'} = 1;
4592 $libsources{'rx.h'} = 1;
4593 $libsources{'regex.c'} = 1;
4594 $libsources{'regex.h'} = 1;
4596 elsif (/AC_FUNC_MKTIME/)
4598 $libsources{'mktime.c'} = 1;
4600 elsif (/AM_FUNC_ERROR_AT_LINE/)
4602 $libsources{'error.c'} = 1;
4603 $libsources{'error.h'} = 1;
4605 elsif (/AM_FUNC_OBSTACK/)
4607 $libsources{'obstack.c'} = 1;
4608 $libsources{'obstack.h'} = 1;
4610 elsif (/LIBOBJS="(.*)\s+\$LIBOBJS"/
4611 || /LIBOBJS="\$LIBOBJS\s+(.*)"/)
4613 foreach my $libobj_iter (split (' ', $1))
4615 if ($libobj_iter =~ /^(.*)\.o(bj)?$/
4616 || $libobj_iter =~ /^(.*)\.\$ac_objext$/
4617 || $libobj_iter =~ /^(.*)\.\$\{ac_objext\}$/)
4619 $libsources{$1 . '.c'} = 1;
4623 elsif (/AC_LIBOBJ\(([^)]+)\)/)
4625 $libsources{"$1.c"} = 1;
4627 elsif (/AC_LIBSOURCE\(([^)]+)\)/)
4629 $libsources{&unquote_m4_arg ($1)} = 1;
4631 elsif (/AC_LIBSOURCES\(([^)]+)\)/)
4633 foreach my $lc_iter (split (/[, ]+/, &unquote_m4_arg ($1)))
4635 $libsources{$lc_iter} = 1;
4639 if (! $in_ac_replace && s/AC_REPLACE_FUNCS\s*\(\[?//)
4645 $in_ac_replace = 0 if s/[\]\)].*$//;
4646 # Remove trailing backslash.
4650 # Need to skip empty elements for Perl 4.
4652 $libsources{$_ . '.c'} = 1;
4656 if (/$obsolete_rx/o)
4659 if ($obsolete_macros{$1} ne '')
4661 $hint = '; ' . $obsolete_macros{$1};
4663 &am_conf_line_error ($filename, $., "`$1' is obsolete$hint");
4666 # Process the AC_OUTPUT and AC_CONFIG_FILES macros.
4667 if (! $in_ac_output && s/AC_(OUTPUT|CONFIG_FILES)\s*\(\[?//)
4670 $ac_output_line = $.;
4681 # Look at potential Makefile.am's.
4682 &scan_autoconf_config_files ($_);
4685 && scalar keys %make_list == 0
4686 && @other_input_files == 0)
4688 &am_conf_line_error ($filename, $ac_output_line,
4689 "No files mentioned in `AC_OUTPUT'");
4694 if (/$AC_CONFIG_AUX_DIR_PATTERN/o)
4696 @config_aux_path = &unquote_m4_arg ($1);
4697 $config_aux_dir_set_in_configure_in = 1;
4700 # Check for ansi2knr.
4701 $am_c_prototypes = 1 if /AM_C_PROTOTYPES/;
4706 $configure_vars{'OBJEXT'} = $filename . ':' . $.;
4709 # Check for `-c -o' code.
4710 $seen_cc_c_o = 1 if /AM_PROG_CC_C_O/;
4712 # Check for NLS support.
4713 if (/AM_GNU_GETTEXT/)
4716 $ac_gettext_line = $.;
4719 # Handle configuration headers. A config header of `[$1]'
4720 # means we are actually scanning AM_CONFIG_HEADER from
4722 if (/A([CM])_CONFIG_HEADERS?\s*\((.*)\)/
4726 ($filename, $., "`automake requires `AM_CONFIG_HEADER', not `AC_CONFIG_HEADER'")
4729 $config_header_line = $.;
4730 foreach my $one_hdr (split (' ', &unquote_m4_arg ($2)))
4732 push (@config_fullnames, $one_hdr);
4733 if ($one_hdr =~ /^([^:]+):(.+)$/)
4735 push (@config_names, $1);
4736 push (@config_headers, $2);
4740 push (@config_names, $one_hdr);
4741 push (@config_headers, $one_hdr . '.in');
4746 # Handle AC_CANONICAL_*. Always allow upgrading to
4747 # AC_CANONICAL_SYSTEM, but never downgrading.
4748 $seen_canonical = $AC_CANONICAL_HOST
4749 if ! $seen_canonical
4750 && (/AC_CANONICAL_HOST/ || /AC_CHECK_TOOL/);
4751 $seen_canonical = $AC_CANONICAL_SYSTEM if /AC_CANONICAL_SYSTEM/;
4753 # If using X, include some extra variable definitions. NOTE
4754 # we don't want to force these into CFLAGS or anything,
4755 # because not all programs will necessarily use X.
4758 foreach my $var ('X_CFLAGS', 'X_LIBS', 'X_EXTRA_LIBS',
4761 $configure_vars{$var} = $filename . ':' . $.
4765 # This macro handles several different things.
4766 if (/$AM_INIT_AUTOMAKE_PATTERN/o)
4768 ($package_version = $1) =~ s/$AM_PACKAGE_VERSION_PATTERN/$1/o;
4769 $package_version_line = $.;
4770 $seen_init_automake = 1;
4775 $configure_vars{'LEX'} = $filename . ':' . $.;
4776 $seen_decl_yytext = 1;
4778 if (/AC_DECL_YYTEXT/ && $filename =~ /configure\.(ac|in)$/)
4780 &am_conf_line_warning ($filename, $., "`AC_DECL_YYTEXT' is covered by `AM_PROG_LEX'");
4782 if (/AC_PROG_LEX/ && $filename =~ /configure\.(ac|in)$/)
4784 &am_conf_line_warning ($filename, $., "automake requires `AM_PROG_LEX', not `AC_PROG_LEX'");
4787 if (/AC_PROG_(F77|YACC|RANLIB|CC|CXXCPP|CXX|LEX|AWK|CPP|LN_S)/)
4789 $configure_vars{$1} = $filename . ':' . $.;
4791 if (/$AC_CHECK_PATTERN/o)
4793 $configure_vars{$3} = $filename . ':' . $.;
4795 if (/$AM_MISSING_PATTERN/o
4799 && $1 ne 'AUTOHEADER'
4800 # AM_INIT_AUTOMAKE is AM_MISSING_PROG'ing MAKEINFO. But
4801 # we handle it elsewhere.
4802 && $1 ne 'MAKEINFO')
4804 $configure_vars{$1} = $filename . ':' . $.;
4807 # Explicitly avoid ANSI2KNR -- we AC_SUBST that in protos.m4,
4808 # but later define it elsewhere. This is pretty hacky. We
4809 # also explicitly avoid INSTALL_SCRIPT and some other
4810 # variables because they are defined in header-vars.am.
4812 if (/$AC_SUBST_PATTERN/o
4814 && $1 ne 'INSTALL_SCRIPT'
4815 && $1 ne 'INSTALL_DATA')
4817 $configure_vars{$1} = $filename . ':' . $.;
4820 $seen_decl_yytext = 1 if /AC_DECL_YYTEXT/;
4821 if (/AM_MAINTAINER_MODE/)
4823 $seen_maint_mode = 1;
4824 $configure_cond{'MAINTAINER_MODE'} = 1;
4827 $seen_lispdir = 1 if /AM_PATH_LISPDIR/;
4829 if (/AM_PATH_PYTHON/)
4831 $seen_pythondir = 1;
4832 $configure_vars{'pythondir'} = $filename . ':' . $.;
4833 $configure_vars{'PYTHON'} = $filename . ':' . $.;
4836 if (/A(C|M)_PROG_LIBTOOL/)
4838 # We're not ready for this yet. People still use a
4839 # libtool with no AC_PROG_LIBTOOL. Once that is the
4840 # dominant version we can reenable this code -- but next
4841 # time by mentioning the macro in %obsolete_macros, both
4842 # here and in aclocal.in.
4844 # if (/AM_PROG_LIBTOOL/)
4846 # &am_conf_line_warning ($filename, $., "`AM_PROG_LIBTOOL' is obsolete, use `AC_PROG_LIBTOOL' instead");
4850 $configure_vars{'LIBTOOL'} = $filename . ':' . $.;
4851 $configure_vars{'RANLIB'} = $filename . ':' . $.;
4852 $configure_vars{'CC'} = $filename . ':' . $.;
4853 # AC_PROG_LIBTOOL runs AC_CANONICAL_HOST. Make sure we
4854 # never downgrade (if we've seen AC_CANONICAL_SYSTEM).
4855 $seen_canonical = $AC_CANONICAL_HOST if ! $seen_canonical;
4858 $seen_multilib = 1 if (/AM_ENABLE_MULTILIB/);
4860 if (/$AM_CONDITIONAL_PATTERN/o)
4862 $configure_cond{$1} = 1;
4865 # Check for Fortran 77 intrinsic and run-time libraries.
4866 if (/AC_F77_LIBRARY_LDFLAGS/)
4868 $configure_vars{'FLIBS'} = $filename . ':' . $.;
4876 # &scan_autoconf_files ()
4877 # -----------------------
4878 # Check whether we use `configure.ac' or `configure.in'.
4879 # Scan it (and possibly `aclocal.m4') for interesting things.
4880 # We must scan aclocal.m4 because there might be AC_SUBSTs and such there.
4881 sub scan_autoconf_files
4883 # Reinitialize libsources here. This isn't really necessary,
4884 # since we currently assume there is only one configure.ac. But
4885 # that won't always be the case.
4888 warn "$me: both `configure.ac' and `configure.in' present:"
4889 . " ignoring `configure.in'\n"
4890 if -f 'configure.ac' && -f 'configure.in';
4891 $configure_ac = 'configure.in'
4892 if -f 'configure.in';
4893 $configure_ac = 'configure.ac'
4894 if -f 'configure.ac';
4895 die "$me: `configure.ac' or `configure.in' is required\n"
4898 &scan_one_autoconf_file ($configure_ac);
4899 &scan_one_autoconf_file ('aclocal.m4')
4902 if (defined $ENV{'amtraces'})
4904 warn '$me: Autoconf traces is an experimental feature';
4905 warn '$me: use at your own risks';
4907 &scan_autoconf_traces ($configure_ac);
4910 # Set input and output files if not specified by user.
4913 @input_files = sort keys %make_list;
4914 %output_files = %make_list;
4917 @configure_input_files = sort keys %make_list;
4919 &am_conf_error ("`AM_INIT_AUTOMAKE' must be used")
4920 if ! $seen_init_automake;
4922 # Look for some files we need. Always check for these. This
4923 # check must be done for every run, even those where we are only
4924 # looking at a subdir Makefile. We must set relative_dir so that
4925 # the file-finding machinery works.
4926 # FIXME: Is this broken because it needs dynamic scopes.
4927 # My tests seems to show it's not the case.
4928 $relative_dir = '.';
4929 &require_config_file ($FOREIGN, 'install-sh', 'mkinstalldirs', 'missing');
4930 &am_error ("`install.sh' is an anachronism; use `install-sh' instead")
4931 if -f $config_aux_path[0] . '/install.sh';
4933 &require_config_file ($FOREIGN, 'py-compile')
4936 # Preserve dist_common for later.
4937 $configure_dist_common = variable_value ('DIST_COMMON', 'TRUE') || '';
4940 ################################################################
4942 # Set up for Cygnus mode.
4945 return unless $cygnus_mode;
4947 &set_strictness ('foreign');
4948 $options{'no-installinfo'} = 1;
4949 $options{'no-dependencies'} = 1;
4950 $use_dependencies = 0;
4952 if (! $seen_maint_mode)
4954 &am_conf_error ("`AM_MAINTAINER_MODE' required when --cygnus specified");
4958 # Do any extra checking for GNU standards.
4959 sub check_gnu_standards
4961 if ($relative_dir eq '.')
4963 # In top level (or only) directory.
4964 &require_file ($GNU, 'INSTALL', 'NEWS', 'README', 'COPYING',
4965 'AUTHORS', 'ChangeLog');
4968 if ($strictness >= $GNU
4969 && defined $options{'no-installman'})
4971 &am_line_error ('AUTOMAKE_OPTIONS',
4972 "option `no-installman' disallowed by GNU standards");
4975 if ($strictness >= $GNU
4976 && defined $options{'no-installinfo'})
4978 &am_line_error ('AUTOMAKE_OPTIONS',
4979 "option `no-installinfo' disallowed by GNU standards");
4983 # Do any extra checking for GNITS standards.
4984 sub check_gnits_standards
4986 if ($relative_dir eq '.')
4988 # In top level (or only) directory.
4989 &require_file ($GNITS, 'THANKS');
4993 ################################################################
4995 # Functions to handle files of each language.
4997 # Each `lang_X_rewrite($DIRECTORY, $BASE, $EXT)' function follows a
4998 # simple formula: Return value is $LANG_SUBDIR if the resulting object
4999 # file should be in a subdir if the source file is, $LANG_PROCESS if
5000 # file is to be dealt with, $LANG_IGNORE otherwise.
5002 # Much of the actual processing is handled in
5003 # handle_single_transform_list. These functions exist so that
5004 # auxiliary information can be recorded for a later cleanup pass.
5005 # Note that the calls to these functions are computed, so don't bother
5006 # searching for their precise names in the source.
5008 # This is just a convenience function that can be used to determine
5009 # when a subdir object should be used.
5012 return defined $options{'subdir-objects'} ? $LANG_SUBDIR : $LANG_PROCESS;
5015 # Rewrite a single C source file.
5018 my ($directory, $base, $ext) = @_;
5020 if (defined $options{'ansi2knr'} && $base =~ /_$/)
5022 # FIXME: include line number in error.
5023 &am_error ("C source file `$base.c' would be deleted by ansi2knr rules");
5026 my $r = $LANG_PROCESS;
5027 if (defined $options{'subdir-objects'})
5030 $base = $directory . '/' . $base;
5034 # Only give error once.
5036 # FIXME: line number.
5037 &am_error ("C objects in subdir but `AM_PROG_CC_C_O' not in `$configure_ac'");
5040 &require_config_file ($FOREIGN, 'compile');
5043 $de_ansi_files{$base} = 1;
5047 # Rewrite a single C++ source file.
5048 sub lang_cxx_rewrite
5050 return &lang_sub_obj;
5053 # Rewrite a single header file.
5054 sub lang_header_rewrite
5056 # Header files are simply ignored.
5057 return $LANG_IGNORE;
5060 # Rewrite a single yacc file.
5061 sub lang_yacc_rewrite
5063 my ($directory, $base, $ext) = @_;
5065 my $r = &lang_sub_obj;
5066 (my $newext = $ext) =~ tr/y/c/;
5067 return ($r, $newext);
5070 # Rewrite a single yacc++ file.
5071 sub lang_yaccxx_rewrite
5073 my ($directory, $base, $ext) = @_;
5075 my $r = &lang_sub_obj;
5076 (my $newext = $ext) =~ tr/y/c/;
5077 return ($r, $newext);
5080 # Rewrite a single lex file.
5081 sub lang_lex_rewrite
5083 my ($directory, $base, $ext) = @_;
5085 my $r = &lang_sub_obj;
5086 (my $newext = $ext) =~ tr/l/c/;
5087 return ($r, $newext);
5090 # Rewrite a single lex++ file.
5091 sub lang_lexxx_rewrite
5093 my ($directory, $base, $ext) = @_;
5095 my $r = &lang_sub_obj;
5096 (my $newext = $ext) =~ tr/l/c/;
5097 return ($r, $newext);
5100 # Rewrite a single assembly file.
5101 sub lang_asm_rewrite
5103 return &lang_sub_obj;
5106 # Rewrite a single Fortran 77 file.
5107 sub lang_f77_rewrite
5109 return $LANG_PROCESS;
5112 # Rewrite a single preprocessed Fortran 77 file.
5113 sub lang_ppf77_rewrite
5115 return $LANG_PROCESS;
5118 # Rewrite a single ratfor file.
5119 sub lang_ratfor_rewrite
5121 return $LANG_PROCESS;
5124 # Rewrite a single Objective C file.
5125 sub lang_objc_rewrite
5127 return &lang_sub_obj;
5130 # Rewrite a single Java file.
5131 sub lang_java_rewrite
5133 return $LANG_SUBDIR;
5136 # The lang_X_finish functions are called after all source file
5137 # processing is done. Each should handle defining rules for the
5138 # language, etc. A finish function is only called if a source file of
5139 # the appropriate type has been seen.
5143 # Push all libobjs files onto de_ansi_files. We actually only
5144 # push files which exist in the current directory, and which are
5145 # genuine source files.
5146 foreach my $file (keys %libsources)
5148 if ($file =~ /^(.*)\.[cly]$/ && -f "$relative_dir/$file")
5150 $de_ansi_files{$1} = 1;
5154 if (defined $options{'ansi2knr'} && keys %de_ansi_files)
5156 # Make all _.c files depend on their corresponding .c files.
5158 foreach my $base (sort keys %de_ansi_files)
5160 # Each _.c file must depend on ansi2knr; otherwise it
5161 # might be used in a parallel build before it is built.
5162 # We need to support files in the srcdir and in the build
5163 # dir (because these files might be auto-generated. But
5164 # we can't use $< -- some makes only define $< during a
5166 $output_rules .= ($base . "_.c: $base.c \$(ANSI2KNR)\n\t"
5167 . '$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) '
5168 . '`if test -f $(srcdir)/' . $base . '.c'
5169 . '; then echo $(srcdir)/' . $base . '.c'
5170 . '; else echo ' . $base . '.c; fi` '
5171 . "| sed 's/^# \\([0-9]\\)/#line \\1/' "
5172 . '| $(ANSI2KNR) > ' . $base . "_.c"
5173 # If ansi2knr fails then we shouldn't
5174 # create the _.c file
5175 . " || rm -f ${base}_.c\n");
5176 push (@objects, $base . '_.$(OBJEXT)');
5177 push (@objects, $base . '_.lo')
5181 # Make all _.o (and _.lo) files depend on ansi2knr.
5182 # Use a sneaky little hack to make it print nicely.
5183 &pretty_print_rule ('', '', @objects, ':', '$(ANSI2KNR)');
5187 # This is a yacc helper which is called whenever we have decided to
5188 # compile a yacc file.
5189 sub lang_yacc_target_hook
5191 my ($self, $aggregate, $output, $input) = @_;
5193 my $flag = $aggregate . "_YFLAGS";
5194 if ((&variable_defined ($flag)
5195 && &variable_value ($flag) =~ /$DASH_D_PATTERN/o)
5196 || (&variable_defined ('YFLAGS')
5197 && &variable_value ('YFLAGS') =~ /$DASH_D_PATTERN/o))
5199 (my $output_base = $output) =~ s/\..*$//;
5200 my $header = $output_base . '.h';
5202 # Found a `-d' that applies to the compilation of this file.
5203 # Add a dependency for the generated header file, and arrange
5204 # for that file to be included in the distribution.
5205 # FIXME: this fails for `nodist_*_SOURCES'.
5206 $output_rules .= "${header}: $output\n";
5207 &push_dist_common ($header);
5208 # If the files are built in the build directory, then we want
5209 # to remove them with `make clean'. If they are in srcdir
5210 # they shouldn't be touched. However, we can't determine this
5211 # statically, and the GNU rules say that yacc/lex output files
5212 # should be removed by maintainer-clean. So that's what we
5214 push (@maintainer_clean_files, $header);
5218 # This is a helper for both lex and yacc.
5219 sub yacc_lex_finish_helper
5221 return if defined $language_scratch{'lex-yacc-done'};
5222 $language_scratch{'lex-yacc-done'} = 1;
5224 # If there is more than one distinct yacc (resp lex) source file
5225 # in a given directory, then the `ylwrap' program is required to
5226 # allow parallel builds to work correctly. FIXME: for now, no
5228 &require_config_file ($FOREIGN, 'ylwrap');
5229 if ($config_aux_dir_set_in_configure_in)
5231 &define_variable ('YLWRAP', $config_aux_dir . "/ylwrap");
5235 &define_variable ('YLWRAP', '$(top_srcdir)/ylwrap');
5239 sub lang_yacc_finish
5241 return if defined $language_scratch{'yacc-done'};
5242 $language_scratch{'yacc-done'} = 1;
5244 if (&variable_defined ('YACCFLAGS'))
5246 &am_line_error ('YACCFLAGS',
5247 "`YACCFLAGS' obsolete; use `YFLAGS' instead");
5250 if (count_files_for_language ('yacc') > 1)
5252 &yacc_lex_finish_helper;
5259 return if defined $language_scratch{'lex-done'};
5260 $language_scratch{'lex-done'} = 1;
5262 if (! $seen_decl_yytext)
5264 &am_error ("lex source seen but `AC_DECL_YYTEXT' not in `$configure_ac'");
5267 if (count_files_for_language ('lex') > 1)
5269 &yacc_lex_finish_helper;
5274 # Given a hash table of linker names, pick the name that has the most
5275 # precedence. This is lame, but something has to have global
5276 # knowledge in order to eliminate the conflict. Add more linkers as
5283 if defined $linkers{'GCJLINK'};
5285 if defined $linkers{'CXXLINK'};
5287 if defined $linkers{'F77LINK'};
5289 if defined $linkers{'OBJCLINK'};
5293 # Called to indicate that an extension was used.
5297 if (! defined $extension_seen{$ext})
5299 $extension_seen{$ext} = 1;
5303 ++$extension_seen{$ext};
5307 # Return the number of files seen for a given language. Knows about
5308 # special cases we care about. FIXME: this is hideous. We need
5309 # something that involves real language objects. For instance yacc
5310 # and yaccxx could both derive from a common yacc class which would
5311 # know about the strange ylwrap requirement. (Or better yet we could
5312 # just not support legacy yacc!)
5313 sub count_files_for_language
5318 if ($name eq 'yacc' || $name eq 'yaccxx')
5320 @names = ('yacc', 'yaccxx');
5322 elsif ($name eq 'lex' || $name eq 'lexxx')
5324 @names = ('lex', 'lexxx');
5332 foreach $name (@names)
5334 my $lang = $languages{$name};
5335 foreach my $ext (@{$lang->extensions})
5337 $r += $extension_seen{$ext}
5338 if defined $extension_seen{$ext};
5345 # Called to ask whether source files have been seen . If HEADERS is 1,
5346 # headers can be included.
5351 # count all the sources
5353 foreach my $val (values %extension_seen)
5360 $count -= count_files_for_language ('header');
5367 # register_language (%ATTRIBUTE)
5368 # ------------------------------
5369 # Register a single language.
5370 # Each %ATTRIBUTE is of the form ATTRIBUTE => VALUE.
5371 sub register_language (%)
5377 unless defined $option{'ansi'};
5378 $option{'autodep'} = 'no'
5379 unless defined $option{'autodep'};
5380 $option{'linker'} = ''
5381 unless defined $option{'linker'};
5382 $option{'define_flag'} = 1
5383 unless defined $option{'define_flag'};
5385 my $lang = new Language (%option);
5388 grep ($extension_map{$_} = $lang->name, @{$lang->extensions});
5389 $languages{$lang->name} = $lang;
5392 # This function is used to find a path from a user-specified suffix to
5393 # `o' or to some other suffix we recognize internally, eg `cc'.
5396 my ($source_ext) = @_;
5398 # FIXME: hard-coding `o' is a mistake. Doing something
5399 # intelligent is harder.
5400 while (! $extension_map{$source_ext}
5401 && $source_ext ne 'o'
5402 && defined $suffix_rules{$source_ext})
5404 $source_ext = $suffix_rules{$source_ext};
5411 ################################################################
5413 # Pretty-print something. HEAD is what should be printed at the
5414 # beginning of the first line, FILL is what should be printed at the
5415 # beginning of every subsequent line.
5416 sub pretty_print_internal
5418 my ($head, $fill, @values) = @_;
5420 my $column = length ($head);
5423 # Fill length is number of characters. However, each Tab
5424 # character counts for eight. So we count the number of Tabs and
5426 my $fill_length = length ($fill);
5427 $fill_length += 7 * ($fill =~ tr/\t/\t/d);
5431 # "71" because we also print a space.
5432 if ($column + length ($_) > 71)
5434 $result .= " \\\n" . $fill;
5435 $column = $fill_length;
5437 $result .= ' ' if $result =~ /\S\z/;
5439 $column += length ($_) + 1;
5446 # Pretty-print something and append to output_vars.
5449 $output_vars .= &pretty_print_internal (@_);
5452 # Pretty-print something and append to output_rules.
5453 sub pretty_print_rule
5455 $output_rules .= &pretty_print_internal (@_);
5459 ################################################################
5463 # &conditional_string(@COND-STACK)
5464 # --------------------------------
5465 # Build a string which denotes the conditional in @COND-STACK. Some
5466 # simplifications are done: `TRUE' entries are elided, and any `FALSE'
5467 # entry results in a return of `FALSE'.
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 # Make a hash holding all the values from $WHEN.
5496 my %cond_vals = map { $_ => 1 } split (' ', $when);
5498 # Check each component of $cond, which looks `COND1 COND2'.
5499 foreach my $comp (split (' ', $cond))
5501 # TRUE is always true.
5502 next if $comp eq 'TRUE';
5503 return 0 if ! defined $cond_vals{$comp};
5511 # &conditional_is_redundant ($COND, @WHENS)
5512 # ----------------------------------------
5513 # Determine whether $COND is redundant with respect to @WHENS.
5515 # Returns true if $COND is true for any of the conditions in @WHENS.
5517 # If there are no @WHENS, then behave as if @WHENS contained a single empty
5519 sub conditional_is_redundant ($@)
5521 my ($cond, @whens) = @_;
5525 return 1 if conditional_true_when ($cond, "");
5529 foreach my $when (@whens)
5531 return 1 if conditional_true_when ($cond, $when);
5540 # condition_negate ($COND)
5541 # ------------------------
5542 sub condition_negate ($)
5546 $cond =~ s/TRUE$/TRUEO/;
5547 $cond =~ s/FALSE$/TRUE/;
5548 $cond =~ s/TRUEO$/FALSE/;
5554 # Compare condition names.
5555 # Issue them in alphabetical order, foo_TRUE before foo_FALSE.
5558 # Be careful we might be comparing `' or `#'.
5559 $a =~ /^(.*)_(TRUE|FALSE)$/;
5560 my ($aname, $abool) = ($1 || '', $2 || '');
5561 $b =~ /^(.*)_(TRUE|FALSE)$/;
5562 my ($bname, $bbool) = ($1 || '', $2 || '');
5563 return ($aname cmp $bname
5564 # Don't bother with IFs, given that TRUE is after FALSE
5565 # just cmp in the reverse order.
5566 || $bbool cmp $abool
5572 # &make_condition (@CONDITIONS)
5573 # -----------------------------
5574 # Transform a list of conditions (themselves can be an internal list
5575 # of conditions, e.g., @CONDITIONS = ('cond1 cond2', 'cond3')) into a
5576 # Make conditional (a pattern for AC_SUBST).
5577 # Correctly returns the empty string when there are no conditions.
5580 my $res = conditional_string (@_);
5582 # There are no conditions.
5588 elsif ($res eq 'FALSE')
5595 $res = '@' . $res . '@';
5604 ## ------------------------------ ##
5605 ## Handling the condition stack. ##
5606 ## ------------------------------ ##
5610 # cond_stack_if ($NEGATE, $COND, $WHERE)
5611 # --------------------------------------
5612 sub cond_stack_if ($$$)
5614 my ($negate, $cond, $where) = @_;
5616 &am_file_error ($where, "$cond does not appear in AM_CONDITIONAL")
5617 if ! $configure_cond{$cond} && $cond !~ /^TRUE|FALSE$/;
5619 $cond = "${cond}_TRUE"
5620 unless $cond =~ /^TRUE|FALSE$/;
5621 $cond = condition_negate ($cond)
5624 push (@cond_stack, $cond);
5626 return conditional_string (@cond_stack);
5631 # cond_stack_else ($NEGATE, $COND, $WHERE)
5632 # ----------------------------------------
5633 sub cond_stack_else ($$$)
5635 my ($negate, $cond, $where) = @_;
5639 &am_file_error ($where, "else without if");
5643 $cond_stack[$#cond_stack] = condition_negate ($cond_stack[$#cond_stack]);
5645 # If $COND is given, check against it.
5648 $cond = "${cond}_TRUE"
5649 unless $cond =~ /^TRUE|FALSE$/;
5650 $cond = condition_negate ($cond)
5653 &am_file_error ($where,
5654 "else reminder ($negate$cond) incompatible with "
5655 . "current conditional: $cond_stack[$#cond_stack]")
5656 if $cond_stack[$#cond_stack] ne $cond;
5659 return conditional_string (@cond_stack);
5664 # cond_stack_endif ($NEGATE, $COND, $WHERE)
5665 # -----------------------------------------
5666 sub cond_stack_endif ($$$)
5668 my ($negate, $cond, $where) = @_;
5673 &am_file_error ($where, "endif without if: $negate$cond");
5678 # If $COND is given, check against it.
5681 $cond = "${cond}_TRUE"
5682 unless $cond =~ /^TRUE|FALSE$/;
5683 $cond = condition_negate ($cond)
5686 &am_file_error ($where,
5687 "endif reminder ($negate$cond) incompatible with "
5688 . "current conditional: $cond_stack[$#cond_stack]")
5689 if $cond_stack[$#cond_stack] ne $cond;
5694 return conditional_string (@cond_stack);
5701 ## ------------------------ ##
5702 ## Handling the variables. ##
5703 ## ------------------------ ##
5706 # check_ambiguous_conditional ($VAR, $COND)
5707 # -----------------------------------------
5708 # Check for an ambiguous conditional. This is called when a variable
5709 # is being defined conditionally. If we already know about a
5710 # definition that is true under the same conditions, then we have an
5712 sub check_ambiguous_conditional ($$)
5714 my ($var, $cond) = @_;
5715 foreach my $vcond (keys %{$var_value{$var}})
5718 if ($vcond eq $cond)
5720 $message = "$var multiply defined in condition $cond";
5722 elsif (&conditional_true_when ($vcond, $cond))
5724 $message = ("$var was already defined in condition $vcond, "
5725 . "which implies condition $cond");
5727 elsif (&conditional_true_when ($cond, $vcond))
5729 $message = ("$var was already defined in condition $vcond, "
5730 . "which is implied by condition $cond");
5734 &am_line_error ($var, $message);
5741 # ¯o_define($VAR, $VAR_IS_AM, $TYPE, $COND, $VALUE, $WHERE)
5742 # -------------------------------------------------------------
5743 # The $VAR can go from Automake to user, but not the converse.
5744 sub macro_define ($$$$$$)
5746 my ($var, $var_is_am, $type, $cond, $value, $where) = @_;
5748 am_file_error ($where, "bad macro name `$var'")
5749 if $var !~ /$MACRO_PATTERN/o;
5753 # An Automake variable must be consistently defined with the same
5754 # sign by Automake. A user variable must be set by either `=' or
5755 # `:=', and later promoted to `+='.
5758 if (defined $var_type{$var} && $var_type{$var} ne $type)
5760 am_line_error ($var,
5761 ("$var was set with `$var_type{$var}=' "
5762 . "and is now set with `$type='"));
5767 if (!defined $var_type{$var} && $type eq '+')
5769 am_line_error ($var, "$var must be set with `=' before using `+='");
5772 $var_type{$var} = $type;
5774 # When adding, since we rewrite, don't try to preserve the
5775 # Automake continuation backslashes.
5777 if $type eq '+' && $var_is_am;
5779 # Differentiate the first assignment (including with `+=').
5780 if ($type eq '+' && defined $var_value{$var}{$cond})
5782 if (substr ($var_value{$var}{$cond}, -1) eq "\n")
5784 # Insert a backslash before a trailing newline.
5785 $var_value{$var}{$cond} =
5786 substr ($var_value{$var}{$cond}, 0, -1) . "\\\n";
5788 elsif ($var_value{$var}{$cond})
5790 # Insert a separator.
5791 $var_value{$var}{$cond} .= ' ';
5793 $var_value{$var}{$cond} .= $value;
5797 # The first assignment to a macro sets the line number. Ideally I
5798 # suppose we would associate line numbers with random bits of text.
5799 # FIXME: We sometimes redefine some variables, but we want to keep
5800 # the original location. More subs are needed to handle
5801 # properly variables. Once this done, remove this hack.
5802 $var_line{$var} = $where
5803 unless defined $var_line{$var};
5805 # If Automake tries to override a value specified by the user,
5806 # just don't let it do.
5807 if (defined $var_value{$var}{$cond} && !$var_is_am{$var} && $var_is_am)
5811 print STDERR "$me: refusing to override the user definition of:\n";
5813 print STDERR "$me: with `$cond' => `$value'\n";
5818 # There must be no previous value unless the user is redefining
5819 # an Automake variable or an AC_SUBST variable.
5820 check_ambiguous_conditional ($var, $cond)
5821 unless ($var_is_am{$var} && !$var_is_am
5822 || exists $configure_vars{$var});
5824 $var_value{$var}{$cond} = $value;
5828 # An Automake variable can be given to the user, but not the converse.
5829 if (! defined $var_is_am{$var} || !$var_is_am)
5831 $var_is_am{$var} = $var_is_am;
5836 # &variable_delete ($VAR, [@CONDS])
5837 # ---------------------------------
5838 # Forget about $VAR under the conditions @CONDS, or completely if
5840 sub variable_delete ($@)
5842 my ($var, @conds) = @_;
5846 delete $var_value{$var};
5847 delete $var_line{$var};
5848 delete $var_is_am{$var};
5849 delete $var_comment{$var};
5850 delete $var_type{$var};
5854 foreach my $cond (@conds)
5856 delete $var_value{$var}{$cond};
5862 # ¯o_dump ($VAR)
5863 # ------------------
5868 if (!exists $var_value{$var})
5870 print STDERR " $var does not exist\n";
5874 my $var_is_am = $var_is_am{$var} ? "Automake" : "User";
5875 my $where = (defined $var_line{$var}
5876 ? $var_line{$var} : "undefined");
5877 print STDERR "$var_comment{$var}"
5878 if defined $var_comment{$var};
5879 print STDERR " $var ($var_is_am, where = $where) $var_type{$var}=\n";
5880 print STDERR " {\n";
5881 foreach my $vcond (sort by_condition keys %{$var_value{$var}})
5883 print STDERR " $vcond => $var_value{$var}{$vcond}\n";
5885 print STDERR " }\n";
5896 print STDERR "%var_value =\n";
5898 foreach my $var (sort (keys %var_value))
5907 # &variable_defined ($VAR, [$COND])
5908 # ---------------------------------
5909 # See if a variable exists. $VAR is the variable name, and $COND is
5910 # the condition which we should check. If no condition is given, we
5911 # currently return true if the variable is defined under any
5913 sub variable_defined ($$)
5915 my ($var, $cond) = @_;
5917 # Unfortunately we can't just check for $var_value{VAR}{COND}
5918 # as this would make perl create $condition{VAR}, which we
5920 if (!exists $var_value{$var})
5922 if (defined $targets{$var})
5924 &am_line_error ($var, "`$var' is a target; expected a variable")
5926 # The variable is not defined
5930 if ($cond && !exists $var_value{$var}{$cond})
5932 # The variable is not defined for the given condition.
5936 # Even a var_value examination is good enough for us. FIXME:
5937 # really should maintain examined status on a per-condition basis.
5938 $content_seen{$var} = 1;
5942 # Mark a variable as examined.
5943 sub examine_variable
5946 &variable_defined ($var);
5949 # Return the set of conditions for which a variable is defined.
5951 # If the variable is not defined conditionally, and is not defined in
5952 # terms of any variables which are defined conditionally, then this
5953 # returns the empty list.
5955 # If the variable is defined conditionally, but is not defined in
5956 # terms of any variables which are defined conditionally, then this
5957 # returns the list of conditions for which the variable is defined.
5959 # If the variable is defined in terms of any variables which are
5960 # defined conditionally, then this returns a full set of permutations
5961 # of the subvariable conditions. For example, if the variable is
5962 # defined in terms of a variable which is defined for COND_TRUE,
5963 # then this returns both COND_TRUE and COND_FALSE. This is
5964 # because we will need to define the variable under both conditions.
5966 sub variable_conditions_recursive ($)
5974 my @new_conds = &variable_conditions_recursive_sub ($var, '');
5975 # Now we want to return all permutations of the subvariable
5978 foreach my $item (@new_conds)
5980 foreach (split (' ', $item))
5982 s/^(.*)_(TRUE|FALSE)$/$1_TRUE/;
5986 @new_conds = &variable_conditions_permutations (sort keys %allconds);
5988 foreach my $cond (@new_conds)
5990 my $reduce = &variable_conditions_reduce (split (' ', $cond));
5992 if $reduce eq 'FALSE';
5993 $uniqify{$cond} = 1;
5996 @uniq_list = sort by_condition keys %uniqify;
5997 # Note we cannot just do `return sort keys %uniqify', because this
5998 # function is sometimes used in a scalar context.
6003 # variable_conditions ($VAR)
6004 # ---------------------------------------
6005 # Get the list of conditions that a variable is defined with, without
6006 # recursing through the conditions of any subvariables.
6007 # Argument is $VAR: the variable to get the conditions of.
6008 # Returns the list of conditions.
6009 sub variable_conditions ($)
6012 my @conds = keys %{$var_value{$var}};
6018 # &variable_conditionally_defined ($VAR)
6019 # --------------------------------------
6020 sub variable_conditionally_defined ($)
6023 foreach my $cond (variable_conditions_recursive ($var))
6026 unless $cond =~ /^TRUE|FALSE$/;
6033 # &variable_conditions_recursive_sub ($VAR, $PARENT)
6034 # -------------------------------------------------------
6035 # A subroutine of variable_conditions_recursive. This returns all the
6036 # conditions of $VAR, including those of any sub-variables.
6037 sub variable_conditions_recursive_sub
6039 my ($var, $parent) = @_;
6042 if (defined $vars_scanned{$var})
6044 &am_line_error ($parent, "variable `$var' recursively defined");
6047 $vars_scanned{$var} = 1;
6049 my @this_conds = ();
6050 # Examine every condition under which $VAR is defined.
6051 foreach my $vcond (keys %{$var_value{$var}})
6053 push (@this_conds, $vcond);
6055 # If $VAR references some other variable, then compute the
6056 # conditions for that subvariable.
6057 my @subvar_conds = ();
6058 foreach (split (' ', $var_value{$var}{$vcond}))
6060 # If a comment seen, just leave.
6063 # Handle variable substitutions.
6064 if (/^\$\{(.*)\}$/ || /^\$\((.*)\)$/)
6067 if ($varname =~ /$SUBST_REF_PATTERN/o)
6073 # Here we compute all the conditions under which the
6074 # subvariable is defined. Then we go through and add
6076 my @svc = &variable_conditions_recursive_sub ($varname, $var);
6077 foreach my $item (@svc)
6079 my $val = conditional_string ($vcond, split (' ', $item));
6081 push (@subvar_conds, $val);
6086 # If there are no conditional subvariables, then we want to
6087 # return this condition. Otherwise, we want to return the
6088 # permutations of the subvariables, taking into account the
6089 # conditions of $VAR.
6090 if (! @subvar_conds)
6092 push (@new_conds, $vcond);
6096 push (@new_conds, &variable_conditions_reduce (@subvar_conds));
6100 # Unset our entry in vars_scanned. We only care about recursive
6102 delete $vars_scanned{$var};
6104 # If we are being called on behalf of another variable, we need to
6105 # return all possible permutations of the conditions. We have
6106 # already handled everything in @this_conds along with their
6107 # subvariables. We now need to add any permutations that are not
6109 foreach my $this_cond (@this_conds)
6112 &variable_conditions_permutations (split(' ', $this_cond));
6113 foreach my $perm (@perms)
6116 foreach my $scan (@this_conds)
6118 if (&conditional_true_when ($perm, $scan)
6119 || &conditional_true_when ($scan, $perm))
6127 # This permutation was not already handled, and is valid
6129 push (@new_conds, $perm);
6137 # Filter a list of conditionals so that only the exclusive ones are
6138 # retained. For example, if both `COND1_TRUE COND2_TRUE' and
6139 # `COND1_TRUE' are in the list, discard the latter.
6140 # If the list is empty, return TRUE
6141 sub variable_conditions_reduce
6148 $cond = shift(@conds);
6150 # FALSE is absorbent.
6151 if ($cond eq 'FALSE')
6155 elsif (!conditional_is_redundant ($cond, @ret, @conds))
6161 return "TRUE" if @ret == 0;
6166 # invert_conditions (@CONDS)
6167 # --------------------------
6168 # Invert a list of conditionals. Returns a set of conditionals which
6169 # are never true for any of the input conditionals, and when taken
6170 # together with the input conditionals cover all possible cases.
6172 # For example: invert_conditions("A_TRUE B_TRUE", "A_FALSE B_FALSE") will
6173 # return ("A_FALSE B_TRUE", "A_TRUE B_FALSE")
6174 sub invert_conditions
6179 foreach my $cond (@conds)
6181 foreach my $perm (variable_conditions_permutations (split(' ', $cond)))
6183 push @notconds, $perm
6184 if ! conditional_is_redundant ($perm, @conds);
6187 return variable_conditions_reduce (@notconds);
6190 # Return a list of permutations of a conditional string.
6191 sub variable_conditions_permutations
6196 my $comp = shift (@comps);
6197 return &variable_conditions_permutations (@comps)
6199 my $neg = condition_negate ($comp);
6202 foreach my $sub (&variable_conditions_permutations (@comps))
6204 push (@ret, "$comp $sub");
6205 push (@ret, "$neg $sub");
6217 # &check_variable_defined_unconditionally($VAR, $PARENT)
6218 # ------------------------------------------------------
6219 # Warn if a variable is conditionally defined. This is called if we
6220 # are using the value of a variable.
6221 sub check_variable_defined_unconditionally ($$)
6223 my ($var, $parent) = @_;
6224 foreach my $cond (keys %{$var_value{$var}})
6227 if $cond =~ /^TRUE|FALSE$/;
6231 &am_line_error ($parent,
6232 "warning: automake does not support conditional definition of $var in $parent");
6236 &am_line_error ($parent,
6237 "warning: automake does not support $var being defined conditionally");
6243 # Get the TRUE value of a variable, warn if the variable is
6244 # conditionally defined.
6248 &check_variable_defined_unconditionally ($var);
6249 return $var_value{$var}{'TRUE'};
6254 # &value_to_list ($VAR, $VAL, $COND)
6255 # ----------------------------------
6256 # Convert a variable value to a list, split as whitespace. This will
6257 # recursively follow $(...) and ${...} inclusions. It preserves @...@
6260 # If COND is 'all', then all values under all conditions should be
6261 # returned; if COND is a particular condition (all conditions are
6262 # surrounded by @...@) then only the value for that condition should
6263 # be returned; otherwise, warn if VAR is conditionally defined.
6264 # SCANNED is a global hash listing whose keys are all the variables
6265 # already scanned; it is an error to rescan a variable.
6268 my ($var, $val, $cond) = @_;
6272 $val =~ s/\\(\n|$)/ /g;
6274 foreach (split (' ', $val))
6276 # If a comment seen, just leave.
6279 # Handle variable substitutions.
6280 if (/^\$\{([^}]*)\}$/ || /^\$\(([^)]*)\)$/)
6284 # If the user uses a losing variable name, just ignore it.
6285 # This isn't ideal, but people have requested it.
6286 next if ($varname =~ /\@.*\@/);
6290 if ($varname =~ /$SUBST_REF_PATTERN/o)
6294 ($from = $2) =~ s/(\W)/\\$1/g;
6298 @temp_list = &variable_value_as_list_recursive_worker ($1, $cond, $var);
6300 # Now rewrite the value if appropriate.
6303 grep (s/$from$/$to/, @temp_list);
6306 push (@result, @temp_list);
6318 # variable_value_as_list ($VAR, $COND, $PARENT)
6319 # ---------------------------------------------
6320 # Get the value of a variable given a specified condition. without
6321 # recursing through any subvariables.
6323 # $VAR is the variable
6324 # $COND is the condition. If this is not given, the value for the
6325 # "TRUE" condition will be returned.
6326 # $PARENT is the variable in which the variable is used: this is used
6327 # only for error messages.
6328 # Returns the list of conditions.
6329 # For example, if A is defined as "foo $(B) bar", and B is defined as
6330 # "baz", this will return ("foo", "$(B)", "bar")
6331 sub variable_value_as_list
6333 my ($var, $cond, $parent) = @_;
6337 if (! defined $var_value{$var})
6339 if (defined $targets{$var})
6341 &am_line_error ($var, "`$var' is a target; expected a variable");
6345 &am_line_error ($parent, "variable `$var' not defined");
6349 # Get value for given condition
6352 foreach my $vcond (keys %{$var_value{$var}})
6354 my $val = $var_value{$var}{$vcond};
6356 if (&conditional_true_when ($vcond, $cond))
6358 # Unless variable is not defined conditionally, there should only
6359 # be one value of $vcond true when $cond.
6360 &check_variable_defined_unconditionally ($var, $parent)
6365 $val =~ s/\\(\n|$)/ /g;
6367 foreach (split (' ', $val))
6369 # If a comment seen, just leave.
6380 # Return contents of variable as list, split as whitespace. This will
6381 # recursively follow $(...) and ${...} inclusions. It preserves @...@
6382 # substitutions. If COND is 'all', then all values under all
6383 # conditions should be returned; if COND is a particular condition
6384 # (all conditions are surrounded by @...@) then only the value for
6385 # that condition should be returned; otherwise, warn if VAR is
6386 # conditionally defined. If PARENT is specified, it is the name of
6387 # the including variable; this is only used for error reports.
6388 sub variable_value_as_list_recursive_worker
6390 my ($var, $cond, $parent) = @_;
6393 if (! defined $var_value{$var})
6395 if (defined $targets{$var})
6397 &am_line_error ($var, "`$var' is a target; expected a variable");
6401 &am_line_error ($parent, "variable `$var' not defined");
6404 elsif (defined $vars_scanned{$var})
6406 # `vars_scanned' is a global we use to keep track of which
6407 # variables we've already examined.
6408 &am_line_error ($parent, "variable `$var' recursively defined");
6410 elsif ($cond eq 'all')
6412 $vars_scanned{$var} = 1;
6413 foreach my $vcond (keys %{$var_value{$var}})
6415 my $val = $var_value{$var}{$vcond};
6416 push (@result, &value_to_list ($var, $val, $cond));
6422 $vars_scanned{$var} = 1;
6424 foreach my $vcond (keys %{$var_value{$var}})
6426 my $val = $var_value{$var}{$vcond};
6427 if (&conditional_true_when ($vcond, $cond))
6429 # Warn if we have an ambiguity. It's hard to know how
6430 # to handle this case correctly.
6431 &check_variable_defined_unconditionally ($var, $parent)
6434 push (@result, &value_to_list ($var, $val, $cond));
6439 # Unset our entry in vars_scanned. We only care about recursive
6441 delete $vars_scanned{$var};
6447 # &variable_output ($VAR, [@CONDS])
6448 # ---------------------------------
6449 # Output all the values of $VAR is @COND is not specified, else only
6450 # that corresponding to @COND.
6451 sub variable_output ($@)
6453 my ($var, @conds) = @_;
6455 @conds = sort by_condition keys %{$var_value{$var}}
6458 $output_vars .= $var_comment{$var}
6459 if defined $var_comment{$var};
6461 foreach my $cond (@conds)
6463 my $val = $var_value{$var}{$cond};
6464 my $equals = $var_type{$var} eq ':' ? ':=' : '=';
6465 my $output_var = "$var $equals $val";
6466 $output_var =~ s/^/make_condition ($cond)/meg;
6467 $output_vars .= $output_var . "\n";
6472 # &variable_pretty_output ($VAR, [@CONDS])
6473 # ----------------------------------------
6474 # Likewise, but pretty, i.e., we *split* the values at spaces. Use only
6475 # with variables holding filenames.
6476 sub variable_pretty_output ($@)
6478 my ($var, @conds) = @_;
6480 @conds = sort by_condition keys %{$var_value{$var}}
6483 $output_vars .= $var_comment{$var}
6484 if defined $var_comment{$var};
6486 foreach my $cond (@conds)
6488 my $val = $var_value{$var}{$cond};
6489 my $equals = $var_type{$var} eq ':' ? ':=' : '=';
6490 my $make_condition = make_condition ($cond);
6491 $output_vars .= pretty_print_internal ("$make_condition$var $equals",
6492 "$make_condition\t",
6493 split (' ' , $val));
6498 # This is just a wrapper for variable_value_as_list_recursive_worker that
6499 # initializes the global hash `vars_scanned'. This hash is used to
6500 # avoid infinite recursion.
6501 sub variable_value_as_list_recursive
6503 my ($var, $cond, $parent) = @_;
6505 return &variable_value_as_list_recursive_worker ($var, $cond, $parent);
6509 # Like define_variable, but the value is a list, and the variable may
6510 # be defined conditionally. The second argument is the conditional
6511 # under which the value should be defined; this should be the empty
6512 # string to define the variable unconditionally. The third argument
6513 # is a list holding the values to use for the variable. The value is
6514 # pretty printed in the output file.
6515 sub define_pretty_variable
6517 my ($var, $cond, @value) = @_;
6519 # Beware that an empty $cond has a different semantics for
6520 # macro_define and variable_pretty_output.
6523 if (! &variable_defined ($var, $cond))
6525 macro_define ($var, 1, '', $cond, join (' ', @value), undef);
6526 variable_pretty_output ($var, $cond || 'TRUE');
6527 $content_seen{$var} = 1;
6532 # define_variable ($VAR, $VALUE)
6533 # ------------------------------
6534 # Define a new user variable VAR to VALUE, but only if not already defined.
6537 my ($var, $value) = @_;
6539 define_pretty_variable ($var, 'TRUE', $value);
6543 # Like define_variable, but define a variable to be the configure
6544 # substitution by the same name.
6545 sub define_configure_variable
6548 my $value = '@' . $var . '@';
6549 &define_variable ($var, $value);
6553 # define_compiler_variable ($LANG)
6554 # --------------------------------
6555 # Define a compiler variable. We also handle defining the `LT'
6556 # version of the command when using libtool.
6557 sub define_compiler_variable ($)
6561 my ($var, $value) = ($lang->compiler, $lang->compile);
6562 &define_variable ($var, $value);
6563 &define_variable ("LT$var", "\$(LIBTOOL) --mode=compile $value")
6568 # define_linker_variable ($LANG)
6569 # ------------------------------
6570 # Define linker variables.
6571 sub define_linker_variable ($)
6575 my ($var, $value) = ($lang->lder, $lang->ld);
6577 &define_variable ($lang->lder, $lang->ld);
6578 # CCLINK = $(CCLD) blah blah...
6579 &define_variable ($lang->linker,
6580 (($seen_libtool ? '$(LIBTOOL) --mode=link ' : '')
6584 ################################################################
6586 ## ---------------- ##
6587 ## Handling rules. ##
6588 ## ---------------- ##
6591 # rule_define ($TARGET, $IS_AM, $COND, $WHERE)
6592 # --------------------------------------------
6593 # Define a new rule. $TARGET is the rule name. $IS_AM is a boolean
6594 # which is true if the new rule is defined by the user. $COND is the
6595 # condition under which the rule is defined. $WHERE is where the rule
6596 # is defined (file name or line number). Returns true if it is ok to
6597 # define the rule, false otherwise.
6598 sub rule_define ($$$$)
6600 my ($target, $rule_is_am, $cond, $where) = @_;
6602 # For now `foo:' will override `foo$(EXEEXT):'. This is temporary,
6603 # though, so we emit a warning.
6604 (my $noexe = $target) =~ s,\$\(EXEEXT\)$,,;
6605 if ($noexe ne $target && defined $targets{$noexe})
6607 # The no-exeext option enables this feature.
6608 if (! defined $options{'no-exeext'})
6610 &am_line_error ($noexe,
6611 "deprecated feature: `$noexe' overrides `$noexe\$(EXEEXT)'\nchange your target to read `$noexe\$(EXEEXT)'");
6617 if (defined $targets{$target}
6619 ? ! defined $target_conditional{$target}
6620 : defined $target_conditional{$target}))
6622 &am_line_error ($target,
6623 "$target defined both conditionally and unconditionally");
6626 # Value here doesn't matter; for targets we only note existence.
6627 $targets{$target} = $where;
6630 if ($target_conditional{$target})
6632 &check_ambiguous_conditional ($target, $cond);
6634 $target_conditional{$target}{$cond} = $where;
6638 # Check the rule for being a suffix rule. If so, store in a hash.
6640 if ((my ($source_suffix, $object_suffix)) = ($target =~ $SUFFIX_RULE_PATTERN))
6642 $suffix_rules{$source_suffix} = $object_suffix;
6643 print "Sources ending in .$source_suffix become .$object_suffix\n"
6645 # Set SUFFIXES from suffix_rules.
6646 push @suffixes, ".$source_suffix", ".$object_suffix";
6653 # See if a target exists.
6657 return defined $targets{$target};
6661 ################################################################
6663 # Read Makefile.am and set up %contents. Simultaneously copy lines
6664 # from Makefile.am into $output_trailer or $output_vars as
6665 # appropriate. NOTE we put rules in the trailer section. We want
6666 # user rules to come after our generated stuff.
6671 my $am_file = new IO::File ("< $amfile");
6674 die "$me: couldn't open `$amfile': $!\n";
6676 print "$me: reading $amfile\n" if $verbose;
6682 while ($_ = $am_file->getline)
6684 if (/$IGNORE_PATTERN/o)
6686 # Merely delete comments beginning with two hashes.
6688 elsif (/$WHITE_PATTERN/o)
6690 # Stick a single white line before the incoming macro or rule.
6694 elsif (/$COMMENT_PATTERN/o)
6696 # Stick comments before the incoming macro or rule. Make
6697 # sure a blank line preceeds first block of comments.
6698 $spacing = "\n" unless $blank;
6700 $comment .= $spacing . $_;
6709 $output_vars .= $comment . "\n";
6713 # We save the conditional stack on entry, and then check to make
6714 # sure it is the same on exit. This lets us conditonally include
6716 my @saved_cond_stack = @cond_stack;
6717 my $cond = conditional_string (@cond_stack);
6721 my $last_var_name = '';
6722 my $last_var_type = '';
6723 my $last_var_value = '';
6724 # FIXME: shouldn't use $_ in this loop; it is too big.
6728 unless substr ($_, -1, 1) eq "\n";
6730 # Don't look at MAINTAINER_MODE_TRUE here. That shouldn't be
6731 # used by users. @MAINT@ is an anachronism now.
6732 $_ =~ s/\@MAINT\@//g
6733 unless $seen_maint_mode;
6735 my $new_saw_bk = /\\$/ && ! /$COMMENT_PATTERN/o;
6737 if (/$IGNORE_PATTERN/o)
6739 # Merely delete comments beginning with two hashes.
6741 elsif (/$WHITE_PATTERN/o)
6743 # Stick a single white line before the incoming macro or rule.
6745 &am_line_error ($., "blank line following trailing backslash")
6748 elsif (/$COMMENT_PATTERN/o)
6750 # Stick comments before the incoming macro or rule.
6751 $comment .= $spacing . $_;
6753 &am_line_error ($., "comment following trailing backslash")
6760 $output_trailer .= &make_condition (@cond_stack);
6761 $output_trailer .= $_;
6765 $last_var_value .= ' '
6766 unless $last_var_value =~ /\s$/;
6767 $last_var_value .= $_;
6771 $var_comment{$last_var_name} .= "$spacing"
6772 if (!defined $var_comment{$last_var_name}
6773 || substr ($var_comment{$last_var_name}, -1) ne "\n");
6774 $var_comment{$last_var_name} .= "$comment";
6775 $comment = $spacing = '';
6776 macro_define ($last_var_name, 0,
6777 $last_var_type, $cond,
6778 $last_var_value, $.)
6779 if $cond ne 'FALSE';
6780 push (@var_list, $last_var_name);
6785 elsif (/$IF_PATTERN/o)
6787 $cond = cond_stack_if ($1, $2, "$amfile:$.");
6789 elsif (/$ELSE_PATTERN/o)
6791 $cond = cond_stack_else ($1, $2, "$amfile:$.");
6793 elsif (/$ENDIF_PATTERN/o)
6795 $cond = cond_stack_endif ($1, $2, "$amfile:$.");
6798 elsif (/$RULE_PATTERN/o)
6803 rule_define ($1, 0, $cond, $.);
6806 $output_trailer .= $comment . $spacing;
6807 $output_trailer .= &make_condition (@cond_stack);
6808 $output_trailer .= $_;
6809 $comment = $spacing = '';
6811 elsif (/$ASSIGNMENT_PATTERN/o)
6813 # Found a macro definition.
6815 $last_var_name = $1;
6816 $last_var_type = $2;
6817 $last_var_value = $3;
6818 if ($3 ne '' && substr ($3, -1) eq "\\")
6820 # We preserve the `\' because otherwise the long lines
6821 # that are generated will be truncated by broken
6823 $last_var_value = $3 . "\n";
6828 # FIXME: this doesn't always work correctly; it will
6829 # group all comments for a given variable, no matter
6831 # Accumulating variables must not be output.
6832 $var_comment{$last_var_name} .= "$spacing"
6833 if (!defined $var_comment{$last_var_name}
6834 || substr ($var_comment{$last_var_name}, -1) ne "\n");
6835 $var_comment{$last_var_name} .= "$comment";
6836 $comment = $spacing = '';
6838 macro_define ($last_var_name, 0,
6839 $last_var_type, $cond,
6840 $last_var_value, $.)
6841 if $cond ne 'FALSE';
6842 push (@var_list, $last_var_name);
6845 elsif (/$INCLUDE_PATTERN/o)
6849 if ($path =~ s/^\$\(top_srcdir\)\///)
6851 push (@include_stack, "\$\(top_srcdir\)/$path");
6855 $path =~ s/\$\(srcdir\)\///;
6856 push (@include_stack, "\$\(srcdir\)/$path");
6857 $path = $relative_dir . "/" . $path;
6859 &read_am_file ($path);
6863 # This isn't an error; it is probably a continued rule.
6864 # In fact, this is what we assume.
6866 $output_trailer .= $comment . $spacing;
6867 $output_trailer .= &make_condition (@cond_stack);
6868 $output_trailer .= $_;
6869 $comment = $spacing = '';
6870 &am_line_error ($., "`#' comment at start of rule is unportable")
6871 if $_ =~ /^\t\s*\#/;
6874 $saw_bk = $new_saw_bk;
6875 $_ = $am_file->getline;
6878 $output_trailer .= $comment;
6880 if (join (' ', @saved_cond_stack) ne join (' ', @cond_stack))
6884 &am_error ("unterminated conditionals: @cond_stack");
6888 # FIXME: better error message here.
6889 &am_error ("conditionals not nested in include file");
6895 # define_standard_variables ()
6896 # ----------------------------
6897 # A helper for read_main_am_file which initializes configure variables
6898 # and variables from header-vars.am. This is a subr so we can call it
6900 sub define_standard_variables
6902 my $saved_output_vars = $output_vars;
6903 my ($comments, undef, $rules) =
6904 file_contents_internal (1, "$libdir/am/header-vars.am");
6906 # This will output the definitions in $output_vars, which we don't
6908 foreach my $var (sort keys %configure_vars)
6910 &define_configure_variable ($var);
6911 push (@var_list, $var);
6914 # ... hence, we restore $output_vars.
6915 $output_vars = $saved_output_vars . $comments . $rules;
6918 # Read main am file.
6919 sub read_main_am_file
6923 # This supports the strange variable tricks we are about to play.
6924 if (scalar keys %var_value > 0)
6927 &prog_error ("variable defined before read_main_am_file");
6930 # Generate copyright header for generated Makefile.in.
6931 # We do discard the output of predefined variables, handled below.
6932 $output_vars = ("# $in_file_name generated automatically by automake "
6933 . $VERSION . " from $am_file_name.\n");
6934 $output_vars .= $gen_copyright;
6936 # We want to predefine as many variables as possible. This lets
6937 # the user set them with `+=' in Makefile.am. However, we don't
6938 # want these initial definitions to end up in the output quite
6939 # yet. So we just load them, but output them later.
6940 &define_standard_variables;
6942 # Read user file, which might override some of our values.
6943 &read_am_file ($amfile);
6945 # Ouput all the Automake variables. If the user changed one, then
6946 # it is now marked as owned by the user.
6947 foreach my $var (uniq @var_list)
6949 # Don't process user variables.
6950 variable_output ($var)
6951 unless !$var_is_am{$var};
6954 # Now dump the user variables that were defined. We do it in the same
6955 # order in which they were defined (skipping duplicates).
6956 foreach my $var (uniq @var_list)
6958 # Don't process Automake variables.
6959 variable_output ($var)
6960 unless $var_is_am{$var};
6964 ################################################################
6967 # &flatten ($STRING)
6968 # ------------------
6969 # Flatten the $STRING and return the result.
6984 # &make_paragraphs ($MAKEFILE, [%TRANSFORM])
6985 # ------------------------------------------
6986 # Load a $MAKEFILE, apply the %TRANSFORM, and return it as a list of
6988 sub make_paragraphs ($%)
6990 my ($file, %transform) = @_;
6992 # Complete %transform with global options and make it a Perl
6995 "s/$IGNORE_PATTERN//gm;"
6996 . transform (%transform,
6998 'CYGNUS' => $cygnus_mode,
7000 => $seen_maint_mode ? subst ('MAINTAINER_MODE_TRUE') : '',
7002 'SHAR' => $options{'dist-shar'} || 0,
7003 'BZIP2' => $options{'dist-bzip2'} || 0,
7004 'ZIP' => $options{'dist-zip'} || 0,
7005 'COMPRESS' => $options{'dist-tarZ'} || 0,
7007 'INSTALL-INFO' => !$options{'no-installinfo'},
7008 'INSTALL-MAN' => !$options{'no-installman'},
7009 'CK-NEWS' => $options{'check-news'} || 0,
7011 'SUBDIRS' => &variable_defined ('SUBDIRS'),
7012 'TOPDIR' => backname ($relative_dir),
7013 'TOPDIR_P' => $relative_dir eq '.',
7014 'CONFIGURE-AC' => $configure_ac,
7016 'BUILD' => $seen_canonical == $AC_CANONICAL_SYSTEM,
7017 'HOST' => $seen_canonical,
7018 'TARGET' => $seen_canonical == $AC_CANONICAL_SYSTEM,
7020 'LIBTOOL' => defined $configure_vars{'LIBTOOL'})
7021 # We don't need more than two consecutive new-lines.
7022 . 's/\n{3,}/\n\n/g';
7024 # Swallow the file and apply the COMMAND.
7025 my $fc_file = new IO::File ("< $file");
7028 die "$me: installation error: cannot open `$file'\n";
7031 print "$me: reading $file\n"
7033 my $saved_dollar_slash = $/;
7035 $_ = $fc_file->getline;
7036 $/ = $saved_dollar_slash;
7041 # Split at unescaped new lines.
7042 my @lines = split (/(?<!\\)\n/, $content);
7045 while (defined ($_ = shift @lines))
7047 my $paragraph = "$_";
7048 # If we are a rule, eat as long as we start with a tab.
7049 if (/$RULE_PATTERN/smo)
7051 while (defined ($_ = shift @lines) && $_ =~ /^\t/)
7053 $paragraph .= "\n$_";
7055 unshift (@lines, $_);
7058 # If we are a comments, eat as much comments as you can.
7059 elsif (/$COMMENT_PATTERN/smo)
7061 while (defined ($_ = shift @lines)
7062 && $_ =~ /$COMMENT_PATTERN/smo)
7064 $paragraph .= "\n$_";
7066 unshift (@lines, $_);
7069 push @res, $paragraph;
7078 # ($COMMENT, $VARIABLES, $RULES)
7079 # &file_contents_internal ($IS_AM, $FILE, [%TRANSFORM])
7080 # -----------------------------------------------------
7081 # Return contents of a file from $libdir/am, automatically skipping
7082 # macros or rules which are already known. $IS_AM iff the caller is
7083 # reading an Automake file (as opposed to the user's Makefile.am).
7084 sub file_contents_internal ($$%)
7086 my ($is_am, $file, %transform) = @_;
7088 my $result_vars = '';
7089 my $result_rules = '';
7093 # We save the conditional stack on entry, and then check to make
7094 # sure it is the same on exit. This lets us conditonally include
7096 my @saved_cond_stack = @cond_stack;
7097 my $cond = conditional_string (@cond_stack);
7099 foreach (make_paragraphs ($file, %transform))
7102 &am_file_error ($file, "blank line following trailing backslash:\n$_")
7104 &am_file_error ($file, "comment following trailing backslash:\n$_")
7109 # Stick empty line before the incoming macro or rule.
7112 elsif (/$COMMENT_PATTERN/mso)
7114 # Stick comments before the incoming macro or rule.
7118 # Handle inclusion of other files.
7119 elsif (/$INCLUDE_PATTERN/o)
7121 if ($cond ne 'FALSE')
7123 my $file = ($is_am ? "$libdir/am/" : '') . $1;
7125 my ($com, $vars, $rules)
7126 = file_contents_internal ($is_am, $file, %transform);
7128 $result_vars .= $vars;
7129 $result_rules .= $rules;
7133 # Handling the conditionals.
7134 elsif (/$IF_PATTERN/o)
7136 $cond = cond_stack_if ($1, $2, $file);
7138 elsif (/$ELSE_PATTERN/o)
7140 $cond = cond_stack_else ($1, $2, $file);
7142 elsif (/$ENDIF_PATTERN/o)
7144 $cond = cond_stack_endif ($1, $2, $file);
7148 elsif (/$RULE_PATTERN/mso)
7150 # Separate relationship from optional actions: the first
7151 # `new-line tab" not preceded by backslash (continuation
7153 # I'm quite shoked! It seems that (\\\n|[^\n]) is not the
7154 # same as `([^\n]|\\\n)!!! Don't swap it, it breaks.
7156 /^((?:\\\n|[^\n])*)(?:\n(\t.*))?$/som;
7157 my ($relationship, $actions) = ($1, $2 || '');
7159 # Separate targets from dependencies: the first colon.
7160 $relationship =~ /^([^:]+\S+) *: *(.*)$/som;
7161 my ($targets, $dependencies) = ($1, $2);
7162 # Remove the escaped new lines.
7163 # I don't know why, but I have to use a tmp $flat_deps.
7164 my $flat_deps = &flatten ($dependencies);
7165 my @deps = split (' ', $flat_deps);
7167 foreach (split (' ' , $targets))
7169 # FIXME: We are not robust to people defining several targets
7170 # at once, only some of them being in %dependencies.
7172 # Output only if not in FALSE.
7173 if (defined $dependencies{$_}
7174 && $cond ne 'FALSE')
7176 &depend ($_, @deps);
7177 $actions{$_} .= $actions;
7181 # Free-lance dependency. Output the rule for all the
7182 # targets instead of one by one.
7184 # Work out all the conditions for which the target hasn't
7186 my @undefined_conds;
7187 if (defined $target_conditional{$targets})
7189 my @defined_conds = keys %{$target_conditional{$targets}};
7190 @undefined_conds = invert_conditions(@defined_conds);
7194 if (defined $targets{$targets})
7196 # No conditions for which target hasn't been defined
7197 @undefined_conds = ();
7201 # Target hasn't been defined for any conditions
7202 @undefined_conds = ("");
7206 if ($cond ne 'FALSE')
7209 for $undefined_cond (@undefined_conds)
7211 my $condparagraph = $paragraph;
7212 $condparagraph =~ s/^/make_condition (@cond_stack, $undefined_cond)/gme;
7213 $result_rules .= "$spacing$comment$condparagraph\n"
7214 if rule_define ($targets, $is_am,
7215 "$cond $undefined_cond", $file);
7218 $comment = $spacing = '';
7224 elsif (/$ASSIGNMENT_PATTERN/mso)
7226 my ($var, $type, $val) = ($1, $2, $3);
7227 &am_file_error ($file, "macro `$var' with trailing backslash")
7230 # Accumulating variables must not be output.
7231 $var_comment{$var} .= "$spacing"
7232 if (!defined $var_comment{$var}
7233 || substr ($var_comment{$var}, -1) ne "\n");
7234 $var_comment{$var} .= "$comment";
7235 macro_define ($var, $is_am, $type, $cond, $val, $file)
7236 if $cond ne 'FALSE';
7237 push (@var_list, $var);
7239 # If the user has set some variables we were in charge
7240 # of (which is detected by the first reading of
7241 # `header-vars.am'), we must not output them.
7242 $result_vars .= "$spacing$comment$_\n"
7243 if $type ne '+' && $var_is_am{$var} && $cond ne 'FALSE';
7245 $comment = $spacing = '';
7249 # This isn't an error; it is probably some tokens which
7250 # configure is supposed to replace, such as `@SET-MAKE@',
7251 # or some part of a rule cut by an if/endif.
7252 if ($cond ne 'FALSE')
7254 s/^/make_condition (@cond_stack)/gme;
7255 $result_rules .= "$spacing$comment$_\n";
7257 $comment = $spacing = '';
7261 if (join (' ', @saved_cond_stack) ne join (' ', @cond_stack))
7265 &am_error ("unterminated conditionals: @cond_stack");
7269 # FIXME: better error message here.
7270 &am_error ("conditionals not nested in include file");
7274 return ($comment, $result_vars, $result_rules);
7279 # &file_contents ($BASENAME, [%TRANSFORM])
7280 # ----------------------------------------
7281 # Return contents of a file from $libdir/am, automatically skipping
7282 # macros or rules which are already known.
7283 sub file_contents ($%)
7285 my ($basename, %transform) = @_;
7286 my ($comments, $variables, $rules) =
7287 file_contents_internal (1, "$libdir/am/$basename.am", %transform);
7288 return "$comments$variables$rules";
7293 # &transform (%PAIRS)
7294 # -------------------
7295 # Foreach ($TOKEN, $VAL) in %PAIRS produce a replacement expression suitable
7296 # for file_contents which:
7297 # - replaces @$TOKEN@ with $VALUE,
7298 # - enables/disables ?$TOKEN?.
7304 while (my ($token, $val) = each %pairs)
7306 $result .= "s/\Q%$token%\E/\Q$val\E/gm;";
7309 $result .= "s/\Q?$token?\E//gm;s/^.*\Q?!$token?\E.*\\n//gm;";
7310 $result .= "s/\Q%?$token%\E/TRUE/gm;";
7314 $result .= "s/\Q?!$token?\E//gm;s/^.*\Q?$token?\E.*\\n//gm;";
7315 $result .= "s/\Q%?$token%\E/FALSE/gm;";
7323 # Find all variable prefixes that are used for install directories. A
7324 # prefix `zar' qualifies iff:
7325 # * `zardir' is a variable.
7326 # * `zar_PRIMARY' is a variable.
7327 sub am_primary_prefixes
7329 my ($primary, $can_dist, @prefixes) = @_;
7331 my %valid = map { $_ => 0 } @prefixes;
7332 $valid{'EXTRA'} = 0;
7333 foreach my $varname (keys %var_value)
7335 # Automake is allowed to define variables that look like they
7336 # are magic variables, such as INSTALL_DATA.
7338 if $var_is_am{$varname};
7340 if ($varname =~ /^(nobase_)?(dist_|nodist_)?(.*)_$primary$/)
7342 my ($base, $dist, $X) = ($1 || '', $2 || '', $3 || '');
7343 if ($dist ne '' && ! $can_dist)
7345 # Note that a configure variable is always legitimate.
7346 # It is natural to name such variables after the
7347 # primary, so we explicitly allow it.
7348 if (! defined $configure_vars{$varname})
7350 &am_line_error ($varname,
7351 "invalid variable `$varname': `dist' is forbidden");
7354 elsif (! defined $valid{$X} && ! &variable_defined ("${X}dir"))
7356 # Note that a configure variable is always legitimate.
7357 # It is natural to name such variables after the
7358 # primary, so we explicitly allow it.
7359 if (! defined $configure_vars{$varname})
7361 &am_line_error ($varname,
7362 "invalid variable `$varname'");
7367 # Ensure all extended prefixes are actually used.
7368 $valid{"$base$dist$X"} = 1;
7376 # Handle `where_HOW' variable magic. Does all lookups, generates
7377 # install code, and possibly generates code to define the primary
7378 # variable. The first argument is the name of the .am file to munge,
7379 # the second argument is the primary variable (eg HEADERS), and all
7380 # subsequent arguments are possible installation locations. Returns
7381 # list of all values of all _HOW targets.
7383 # FIXME: this should be rewritten to be cleaner. It should be broken
7384 # up into multiple functions.
7386 # Usage is: am_install_var (OPTION..., file, HOW, where...)
7393 my $default_dist = 0;
7396 if ($args[0] eq '-noextra')
7400 elsif ($args[0] eq '-candist')
7404 elsif ($args[0] eq '-defaultdist')
7409 elsif ($args[0] !~ /^-/)
7416 my ($file, $primary, @prefixes) = @args;
7418 # Now that configure substitutions are allowed in where_HOW
7419 # variables, it is an error to actually define the primary. We
7420 # allow `JAVA', as it is customarily used to mean the Java
7421 # interpreter. This is but one of several Java hacks. Similarly,
7422 # `PYTHON' is customarily used to mean the Python interpreter.
7423 &am_line_error ($primary, "`$primary' is an anachronism")
7424 if &variable_defined ($primary)
7425 && ($primary ne 'JAVA' && $primary ne 'PYTHON');
7428 # Look for misspellings. It is an error to have a variable ending
7429 # in a "reserved" suffix whose prefix is unknown, eg
7430 # "bni_PROGRAMS". However, unusual prefixes are allowed if a
7431 # variable of the same name (with "dir" appended) exists. For
7432 # instance, if the variable "zardir" is defined, then
7433 # "zar_PROGRAMS" becomes valid. This is to provide a little extra
7434 # flexibility in those cases which need it.
7435 my %valid = &am_primary_prefixes ($primary, $can_dist, @prefixes);
7437 # If a primary includes a configure substitution, then the EXTRA_
7438 # form is required. Otherwise we can't properly do our job.
7440 my $warned_about_extra = 0;
7445 # True if the iteration is the first one. Used for instance to
7446 # output parts of the associated file only once.
7448 foreach my $X (sort keys %valid)
7450 my $one_name = $X . '_' . $primary;
7452 unless (&variable_defined ($one_name));
7454 my $strip_subdir = 1;
7455 # If subdir prefix should be preserved, do so.
7456 if ($X =~ /^nobase_/)
7462 my $nodir_name = $X;
7463 # If files should be distributed, do so.
7467 $dist_p = (($default_dist && $one_name !~ /^nodist_/)
7468 || (! $default_dist && $one_name =~ /^dist_/));
7469 $nodir_name =~ s/^(dist|nodist)_//;
7472 # Append actual contents of where_PRIMARY variable to
7474 foreach my $rcurs (&variable_value_as_list_recursive ($one_name, 'all'))
7476 # Skip configure substitutions. Possibly bogus.
7477 if ($rcurs =~ /^\@.*\@$/)
7481 if (! $warned_about_extra)
7483 $warned_about_extra = 1;
7484 &am_line_error ($one_name,
7485 "`$one_name' contains configure substitution, but shouldn't");
7488 # Check here to make sure variables defined in
7489 # configure.ac do not imply that EXTRA_PRIMARY
7491 elsif (! defined $configure_vars{$one_name})
7493 $require_extra = $one_name
7500 push (@result, $rcurs);
7503 # A blatant hack: we rewrite each _PROGRAMS primary to include
7505 if ($primary eq 'PROGRAMS')
7507 my @conds = &variable_conditions_recursive ($one_name);
7510 foreach my $cond (@conds)
7512 my @one_binlist = ();
7513 my @condval = &variable_value_as_list_recursive ($one_name,
7515 foreach my $rcurs (@condval)
7517 # Skip autoconf substs. Also skip if the user
7518 # already applied $(EXEEXT).
7519 if ($rcurs =~ /^\@.*\@$/ || $rcurs =~ /\$\(EXEEXT\)$/)
7521 push (@one_binlist, $rcurs);
7525 push (@one_binlist, $rcurs . '$(EXEEXT)');
7529 push (@condvals, $cond);
7530 push (@condvals, join (' ', @one_binlist));
7533 variable_delete ($one_name);
7536 my $cond = shift (@condvals);
7537 my @val = split (' ', shift (@condvals));
7538 &define_pretty_variable ($one_name, $cond, @val);
7542 # "EXTRA" shouldn't be used when generating clean targets,
7543 # all, or install targets.
7546 # We used to warn if EXTRA_FOO was defined uselessly,
7547 # but this was annoying.
7553 push (@check, '$(' . $one_name . ')');
7557 push (@used, '$(' . $one_name . ')');
7560 # Is this to be installed?
7561 my $install_p = $X ne 'noinst' && $X ne 'check';
7563 # If so, with install-exec? (or install-data?).
7564 my $exec_p = (defined $exec_dir_p {$X}
7568 # Singular form of $PRIMARY.
7569 (my $one_primary = $primary) =~ s/S$//;
7570 $output_rules .= &file_contents ($file,
7573 'PRIMARY' => $primary,
7574 'ONE_PRIMARY' => $one_primary,
7576 'NDIR' => $nodir_name,
7577 'BASE' => $strip_subdir,
7580 'INSTALL' => $install_p,
7581 'DIST' => $dist_p));
7586 # The JAVA variable is used as the name of the Java interpreter.
7587 # The PYTHON variable is used as the name of the Python interpreter.
7588 if (@used && $primary ne 'JAVA' && $primary ne 'PYTHON')
7591 &define_pretty_variable ($primary, '', @used);
7592 $output_vars .= "\n";
7595 if ($require_extra && ! &variable_defined ('EXTRA_' . $primary))
7597 &am_line_error ($require_extra,
7598 "`$require_extra' contains configure substitution, but `EXTRA_$primary' not defined");
7601 # Push here because PRIMARY might be configure time determined.
7602 push (@all, '$(' . $primary . ')')
7603 if @used && $primary ne 'JAVA' && $primary ne 'PYTHON';
7605 # Make the result unique. This lets the user use conditionals in
7606 # a natural way, but still lets us program lazily -- we don't have
7607 # to worry about handling a particular object more than once.
7608 return uniq (sort @result);
7612 ################################################################
7614 # Each key in this hash is the name of a directory holding a
7615 # Makefile.in. These variables are local to `is_make_dir'.
7617 my $make_dirs_set = 0;
7622 if (! $make_dirs_set)
7624 foreach my $iter (@configure_input_files)
7626 $make_dirs{dirname ($iter)} = 1;
7628 # We also want to notice Makefile.in's.
7629 foreach my $iter (@other_input_files)
7631 if ($iter =~ /Makefile\.in$/)
7633 $make_dirs{dirname ($iter)} = 1;
7638 return defined $make_dirs{$dir};
7641 ################################################################
7643 # This variable is local to the "require file" set of functions.
7644 my @require_file_paths = ();
7646 # If a file name appears as a key in this hash, then it has already
7647 # been checked for. This variable is local to the "require file"
7649 %require_file_found = ();
7651 # See if we want to push this file onto dist_common. This function
7652 # encodes the rules for deciding when to do so.
7653 sub maybe_push_required_file
7655 my ($dir, $file, $fullfile) = @_;
7657 if ($dir eq $relative_dir)
7659 &push_dist_common ($file);
7661 elsif ($relative_dir eq '.' && ! &is_make_dir ($dir))
7663 # If we are doing the topmost directory, and the file is in a
7664 # subdir which does not have a Makefile, then we distribute it
7666 &push_dist_common ($fullfile);
7671 # &require_file_internal ($IS_CONFIGURE, $LINE, $MYSTRICT, @FILES)
7672 # ----------------------------------------------------------------
7673 # Verify that the file must exist in the current directory.
7674 # $MYSTRICT is the strictness level at which this file becomes required.
7676 # Must set require_file_paths before calling this function.
7677 # require_file_paths is set to hold a single directory (the one in
7678 # which the first file was found) before return.
7679 sub require_file_internal
7681 my ($is_configure, $line, $mystrict, @files) = @_;
7683 foreach my $file (@files)
7691 my $dangling_sym = 0;
7692 foreach my $dir (@require_file_paths)
7694 $fullfile = $dir . "/" . $file;
7695 $errdir = $dir unless $errdir;
7697 # Use different name for "error filename". Otherwise on
7698 # an error the bad file will be reported as eg
7699 # `../../install-sh' when using the default
7701 $errfile = $errdir . '/' . $file;
7703 if (-l $fullfile && ! -f $fullfile)
7708 elsif (-f $fullfile)
7711 &maybe_push_required_file ($dir, $file, $fullfile);
7717 # `--force-missing' only has an effect if `--add-missing' is
7719 if ($found_it && (! $add_missing || ! $force_missing))
7721 # Prune the path list.
7722 @require_file_paths = $save_dir;
7726 # If we've already looked for it, we're done. You might
7727 # wonder why we don't do this before searching for the
7728 # file. If we do that, then something like
7729 # AC_OUTPUT(subdir/foo foo) will fail to put foo.in into
7733 next if defined $require_file_found{$file};
7734 $require_file_found{$file} = 1;
7737 if ($strictness >= $mystrict)
7739 if ($dangling_sym && $add_missing)
7747 # Only install missing files according to our desired
7749 my $message = "required file `$errfile' not found";
7754 # Maybe run libtoolize.
7755 my @syslist = ('libtoolize', '--automake');
7756 push @syslist, '--copy'
7759 && grep ($_ eq $file, @libtoolize_files)
7760 && system (@syslist))
7762 $message = "installing `$errfile'";
7764 $trailer = "; cannot run `libtoolize': $!";
7766 elsif (-f ("$libdir/$file"))
7768 # Install the missing file. Symlink if we
7769 # can, copy if we must. Note: delete the file
7770 # first, in case it is a dangling symlink.
7771 $message = "installing `$errfile'";
7772 # Windows Perl will hang if we try to delete a
7773 # file that doesn't exist.
7774 unlink ($errfile) if -f $errfile;
7775 if ($symlink_exists && ! $copy_missing)
7777 if (! symlink ("$libdir/$file", $errfile))
7780 $trailer = "; error while making link: $!";
7783 elsif (system ('cp', "$libdir/$file", $errfile))
7786 $trailer = "\n error while copying";
7790 &maybe_push_required_file (dirname ($errfile),
7793 # Prune the path list.
7794 @require_file_paths = &dirname ($errfile);
7797 # If --force-missing was specified, and we have
7798 # actually found the file, then do nothing.
7800 if $found_it && $force_missing;
7806 # FIXME: allow actual file to be specified.
7807 &am_conf_line_warning ($configure_ac, $line,
7808 "$message$trailer");
7812 &am_line_warning ($line, "$message$trailer");
7819 # FIXME: allow actual file to be specified.
7820 &am_conf_line_error ($configure_ac, $line,
7821 "$message$trailer");
7825 &am_line_error ($line, "$message$trailer");
7833 # Like require_file_with_line, but error messages refer to
7834 # configure.ac, not the current Makefile.am.
7835 sub require_file_with_conf_line
7837 @require_file_paths = $relative_dir;
7838 &require_file_internal (1, @_);
7841 sub require_file_with_line
7843 @require_file_paths = $relative_dir;
7844 &require_file_internal (0, @_);
7849 @require_file_paths = $relative_dir;
7850 &require_file_internal (0, '', @_);
7853 # Require a file that is also required by Autoconf. Looks in
7854 # configuration path, as specified by AC_CONFIG_AUX_DIR.
7855 sub require_config_file
7857 @require_file_paths = @config_aux_path;
7858 &require_file_internal (1, '', @_);
7859 my $dir = $require_file_paths[0];
7860 @config_aux_path = @require_file_paths;
7861 # Avoid unsightly '/.'s.
7862 $config_aux_dir = '$(top_srcdir)' . ($dir eq '.' ? "" : "/$dir");
7865 # Assumes that the line number is in Makefile.am.
7866 sub require_conf_file_with_line
7868 @require_file_paths = @config_aux_path;
7869 &require_file_internal (0, @_);
7870 my $dir = $require_file_paths[0];
7871 @config_aux_path = @require_file_paths;
7872 # Avoid unsightly '/.'s.
7873 $config_aux_dir = '$(top_srcdir)' . ($dir eq '.' ? "" : "/$dir");
7876 # Assumes that the line number is in configure.ac.
7877 sub require_conf_file_with_conf_line
7879 @require_file_paths = @config_aux_path;
7880 &require_file_internal (1, @_);
7881 my $dir = $require_file_paths[0];
7882 @config_aux_path = @require_file_paths;
7883 # avoid unsightly '/.'s.
7884 $config_aux_dir = '$(top_srcdir)' . ($dir eq '.' ? "" : "/$dir");
7887 ################################################################
7889 # &require_build_directory ($DIRECTORY)
7890 # ------------------------------------
7891 # Emit rules to create $DIRECTORY if needed, and return
7892 # the file that any target requiring this directory should be made
7894 sub require_build_directory ($)
7896 my $directory = shift;
7897 my $dirstamp = "$directory/.dirstamp";
7899 # Don't emit the rule twice.
7900 if (! defined $directory_map{$directory})
7902 $directory_map{$directory} = 1;
7904 # Directory must be removed by `make distclean'.
7905 $compile_clean_files{$dirstamp} = $DIST_CLEAN;
7907 $output_rules .= ("$dirstamp:\n"
7908 . "\t\@\$(mkinstalldirs) $directory\n"
7909 . "\t\@: > $dirstamp\n");
7915 # &require_build_directory_maybe ($FILE)
7916 # --------------------------------------
7917 # If $FILE lies in a subdirectory, emit a rule to create this
7918 # directory and return the file that $FILE should be made
7919 # dependent upon. Otherwise, just return the empty string.
7920 sub require_build_directory_maybe ($)
7923 my $directory = dirname ($file);
7925 if ($directory ne '.')
7927 return &require_build_directory ($directory);
7935 ################################################################
7937 # Push a list of files onto dist_common.
7938 sub push_dist_common
7940 &prog_error ("push_dist_common run after handle_dist")
7941 if $handle_dist_run;
7942 macro_define ('DIST_COMMON', 1, '+', '', join (' ', @_), '');
7949 $strictness_name = $_[0];
7950 if ($strictness_name eq 'gnu')
7954 elsif ($strictness_name eq 'gnits')
7956 $strictness = $GNITS;
7958 elsif ($strictness_name eq 'foreign')
7960 $strictness = $FOREIGN;
7964 die "$me: level `$strictness_name' not recognized\n";
7969 ################################################################
7971 # Ensure a file exists.
7976 my $touch = new IO::File (">> $file");
7980 # Glob something. Do this to avoid indentation screwups everywhere we
7981 # want to glob. Gross!
7988 # Remove one level of brackets and strip leading spaces,
7989 # as does m4 to function arguments.
7995 my @letters = split //;
8004 next if $depth == 1;
8009 next if $depth == 0;
8010 # don't count orphan right brackets
8011 $depth = 0 if $depth < 0;
8015 return join '', @result;
8018 ################################################################
8020 # am_print_error ($LEADER, @ARGS)
8021 # -------------------------------
8022 # Do the work of printing the error message. Join @ARGS with spaces,
8023 # then split at newlines and add $LEADER to each line. Uses `warn' to
8027 my ($leader, @args) = @_;
8028 my $text = join (' ', @args);
8029 @args = split ("\n", $text);
8030 $text = $leader . join ("\n" . $leader, @args) . "\n";
8034 # Print an error message and set exit status.
8037 am_print_error ("$me: ${am_file}.am: ", @_);
8041 # am_file_error ($FILE, @ARGS)
8042 # ----------------------------
8045 my ($file, @args) = @_;
8047 am_print_error ("$file: ", @args);
8053 my ($symbol, @args) = @_;
8055 if ($symbol && "$symbol" ne '-1')
8057 my $file = "${am_file}.am";
8059 if ($symbol =~ /^\d+$/)
8061 # SYMBOL is a line number, so just add the colon.
8062 $file .= ':' . $symbol;
8064 elsif (defined $var_line{$symbol})
8066 # SYMBOL is a variable defined in Makefile.am, so add the
8067 # line number we saved from there.
8068 $file .= ':' . $var_line{$symbol};
8070 elsif (defined $configure_vars{$symbol})
8072 # SYMBOL is a variable defined in configure.ac, so add the
8073 # appropriate line number.
8074 $file = $configure_vars{$symbol};
8078 # Couldn't find the line number.
8081 am_print_error ("$file: ", @args);
8090 # Like am_error, but while scanning configure.ac.
8093 # FIXME: can run in subdirs.
8094 am_print_error ("$me: $configure_ac: ", @_);
8098 # Error message with line number referring to configure.ac.
8099 sub am_conf_line_error
8101 my ($file, $line, @args) = @_;
8105 am_print_error ("$file: $line: ", @args);
8110 &am_conf_error (@args);
8114 # Warning message with line number referring to configure.ac.
8115 # Does not affect exit_status
8116 sub am_conf_line_warning
8118 my $saved_exit_status = $exit_status;
8119 my $sig = $SIG{'__WARN__'};
8120 $SIG{'__WARN__'} = 'DEFAULT';
8121 am_conf_line_error (@_);
8122 $exit_status = $saved_exit_status;
8123 $SIG{'__WARN__'} = $sig;
8126 # Like am_line_error, but doesn't affect exit status.
8129 my $saved_exit_status = $exit_status;
8130 my $sig = $SIG{'__WARN__'};
8131 $SIG{'__WARN__'} = 'DEFAULT';
8133 $exit_status = $saved_exit_status;
8134 $SIG{'__WARN__'} = $sig;
8137 # Tell user where our aclocal.m4 is, but only once.
8138 sub keyed_aclocal_warning
8141 warn "$me: macro `$key' can be generated by `aclocal'\n";
8144 # Print usage information.
8148 Usage: $0 [OPTION] ... [Makefile]...
8150 Generate Makefile.in for configure from Makefile.am.
8153 --help print this help, then exit
8154 --version print version number, then exit
8155 -v, --verbose verbosely list files processed
8156 -o, --output-dir=DIR put generated Makefile.in's into DIR
8157 --no-force only update Makefile.in's that are out of date
8159 Dependency tracking:
8160 -i, --ignore-deps disable dependency tracking code
8161 --include-deps enable dependency tracking code
8164 --cygnus assume program is part of Cygnus-style tree
8165 --foreign set strictness to foreign
8166 --gnits set strictness to gnits
8167 --gnu set strictness to gnu
8170 -a, --add-missing add missing standard files to package
8171 --libdir=DIR directory storing library files
8172 -c, --copy with -a, copy missing files (default is symlink)
8173 -f, --force-missing force update of standard files
8178 foreach my $iter (sort ((@common_files, @common_sometimes)))
8180 push (@lcomm, $iter) unless $iter eq $last;
8185 print "\nFiles which are automatically distributed, if found:\n";
8186 format USAGE_FORMAT =
8187 @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<
8188 $four[0], $four[1], $four[2], $four[3]
8190 $~ = "USAGE_FORMAT";
8193 my $rows = int(@lcomm / $cols);
8194 my $rest = @lcomm % $cols;
8205 for (my $y = 0; $y < $rows; $y++)
8207 @four = ("", "", "", "");
8208 for (my $x = 0; $x < $cols; $x++)
8210 last if $y + 1 == $rows && $x == $rest;
8212 my $idx = (($x > $rest)
8213 ? ($rows * $rest + ($rows - 1) * ($x - $rest))
8217 $four[$x] = $lcomm[$idx];
8222 print "\nReport bugs to <bug-automake\@gnu.org>.\n";
8229 # Print version information
8233 automake (GNU $PACKAGE) $VERSION
8234 Written by Tom Tromey <tromey\@cygnus.com>.
8236 Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
8237 Free Software Foundation, Inc.
8238 This is free software; see the source for copying conditions. There is NO
8239 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.