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';
115 use Automake::General;
124 # Parameters set by configure. Not to be changed. NOTE: assign
125 # VERSION as string so that eg version 0.30 will print correctly.
126 my $VERSION = "@VERSION@";
127 my $PACKAGE = "@PACKAGE@";
128 my $prefix = "@prefix@";
129 my $libdir = "@datadir@/@PACKAGE@";
132 my $IGNORE_PATTERN = '^\s*##([^#\n].*)?\n';
133 my $WHITE_PATTERN = '^\s*$';
134 my $COMMENT_PATTERN = '^#';
135 my $TARGET_PATTERN='[$a-zA-Z_.@][-.a-zA-Z0-9_(){}/$+@]*';
136 # A rule has three parts: a list of targets, a list of dependencies,
137 # and optionally actions.
139 "^($TARGET_PATTERN(?:(?:\\\\\n|\\s)+$TARGET_PATTERN)*) *:([^=].*|)\$";
141 my $SUFFIX_RULE_PATTERN = '^\.([a-zA-Z0-9+]+)\.([a-zA-Z0-9+]+)$';
142 # Only recognize leading spaces, not leading tabs. If we recognize
143 # leading tabs here then we need to make the reader smarter, because
144 # otherwise it will think rules like `foo=bar; \' are errors.
145 my $MACRO_PATTERN = '^[A-Za-z0-9_@]+$';
146 my $ASSIGNMENT_PATTERN = '^ *([^ \t=:+]*)\s*([:+]?)=\s*(.*)$';
147 # This pattern recognizes a Gnits version id and sets $1 if the
148 # release is an alpha release. We also allow a suffix which can be
149 # used to extend the version number with a "fork" identifier.
150 my $GNITS_VERSION_PATTERN = '\d+\.\d+([a-z]|\.\d+)?(-[A-Za-z0-9]+)?';
151 my $IF_PATTERN = '^if\s+(!?)\s*([A-Za-z][A-Za-z0-9_]*)\s*(?:#.*)?$';
152 my $ELSE_PATTERN = '^else(?:\s+(!?)\s*([A-Za-z][A-Za-z0-9_]*))?\s*(?:#.*)?$';
153 my $ENDIF_PATTERN = '^endif(?:\s+(!?)\s*([A-Za-z][A-Za-z0-9_]*))?\s*(?:#.*)?$';
154 my $PATH_PATTERN='(\w|[/.-])+';
155 # This will pass through anything not of the prescribed form.
156 my $INCLUDE_PATTERN = ('^include\s+'
157 . '((\$\(top_srcdir\)/' . $PATH_PATTERN . ')'
158 . '|(\$\(srcdir\)/' . $PATH_PATTERN . ')'
159 . '|([^/\$]' . $PATH_PATTERN. '))\s*(#.*)?$');
161 # Some regular expressions. One reason to put them here is that it
162 # makes indentation work better in Emacs.
163 my $AC_CONFIG_AUX_DIR_PATTERN = 'AC_CONFIG_AUX_DIR\(([^)]+)\)';
164 my $AM_INIT_AUTOMAKE_PATTERN = 'AM_INIT_AUTOMAKE\([^,]*,([^,)]+)[,)]';
165 my $AM_PACKAGE_VERSION_PATTERN = '^\s*\[?([^]\s]+)\]?\s*$';
167 # This handles substitution references like ${foo:.a=.b}.
168 my $SUBST_REF_PATTERN = "^([^:]*):([^=]*)=(.*)\$";
170 # Note that there is no AC_PATH_TOOL. But we don't really care.
171 my $AC_CHECK_PATTERN = 'AC_(CHECK|PATH)_(PROG|PROGS|TOOL)\(\[?(\w+)';
172 my $AM_MISSING_PATTERN = 'AM_MISSING_PROG\(\[?(\w+)';
173 # Just check for alphanumeric in AC_SUBST. If you do AC_SUBST(5),
175 my $AC_SUBST_PATTERN = 'AC_SUBST\(\[?(\w+)';
176 my $AM_CONDITIONAL_PATTERN = 'AM_CONDITIONAL\(\[?(\w+)';
177 # Match `-d' as a command-line argument in a string.
178 my $DASH_D_PATTERN = "(^|\\s)-d(\\s|\$)";
180 # Constants to define the "strictness" level.
185 # Values for AC_CANONICAL_*
186 my $AC_CANONICAL_HOST = 1;
187 my $AC_CANONICAL_SYSTEM = 2;
189 # Values indicating when something should be cleaned. Right now we
190 # only need to handle `mostly'- and `dist'-clean; add more as
192 my $MOSTLY_CLEAN = 0;
195 # Files installed by libtoolize.
196 my @libtoolize_files = ('ltmain.sh', 'config.guess', 'config.sub');
197 # ltconfig appears here for compatibility with old versions of libtool.
198 my @libtoolize_sometimes = ('ltconfig', 'ltcf-c.sh', 'ltcf-cxx.sh',
201 # Commonly found files we look for and automatically include in
205 'README', 'THANKS', 'TODO', 'NEWS', 'COPYING', 'COPYING.LIB',
206 'INSTALL', 'ABOUT-NLS', 'ChangeLog', 'configure.ac',
207 'configure.in', 'configure', 'config.guess', 'config.sub',
208 'AUTHORS', 'BACKLOG', 'ABOUT-GNU', 'libversion.in',
209 'mdate-sh', 'mkinstalldirs', 'install-sh', 'texinfo.tex',
210 'ansi2knr.c', 'ansi2knr.1', 'elisp-comp',
211 # ltconfig appears here for compatibility with old versions
213 'ylwrap', 'acinclude.m4', @libtoolize_files, @libtoolize_sometimes,
214 'missing', 'depcomp', 'compile', 'py-compile'
217 # Commonly used files we auto-include, but only sometimes.
218 my @common_sometimes =
220 'aclocal.m4', 'acconfig.h', 'config.h.top',
221 'config.h.bot', 'stamp-h.in', 'stamp-vti'
224 # Copyright on generated Makefile.ins.
225 my $gen_copyright = "\
226 # Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
227 # Free Software Foundation, Inc.
228 # This Makefile.in is free software; the Free Software Foundation
229 # gives unlimited permission to copy and/or distribute it,
230 # with or without modifications, as long as this notice is preserved.
232 # This program is distributed in the hope that it will be useful,
233 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
234 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
235 # PARTICULAR PURPOSE.
238 # These constants are returned by lang_*_rewrite functions.
239 # LANG_SUBDIR means that the resulting object file should be in a
240 # subdir if the source file is. In this case the file name cannot
241 # have `..' components.
243 my $LANG_PROCESS = 1;
246 # Directories installed during 'install-exec' phase.
265 # Map from obsolete macros to hints for new macros.
266 # If you change this, change the corresponding list in aclocal.in.
267 # FIXME: should just put this into a single file.
268 my %obsolete_macros =
270 'AC_FEATURE_CTYPE' => "use `AC_HEADER_STDC'",
271 'AC_FEATURE_ERRNO' => "add `strerror' to `AC_REPLACE_FUNCS(...)'",
272 'AC_FEATURE_EXIT' => '',
273 'AC_SYSTEM_HEADER' => '',
275 # Note that we do not handle this one, because it is still run
276 # from AM_CONFIG_HEADER. So we deal with it specially in
277 # &scan_autoconf_files.
278 # 'AC_CONFIG_HEADER' => "use `AM_CONFIG_HEADER'",
280 'fp_C_PROTOTYPES' => "use `AM_C_PROTOTYPES'",
281 'fp_PROG_CC_STDC' => "use `AM_PROG_CC_STDC'",
282 'fp_PROG_INSTALL' => "use `AC_PROG_INSTALL'",
283 'fp_WITH_DMALLOC' => "use `AM_WITH_DMALLOC'",
284 'fp_WITH_REGEX' => "use `AM_WITH_REGEX'",
285 'gm_PROG_LIBTOOL' => "use `AM_PROG_LIBTOOL'",
286 'jm_MAINTAINER_MODE' => "use `AM_MAINTAINER_MODE'",
287 'md_TYPE_PTRDIFF_T' => "add `ptrdiff_t' to `AC_CHECK_TYPES(...)'",
288 'ud_PATH_LISPDIR' => "use `AM_PATH_LISPDIR'",
289 'ud_GNU_GETTEXT' => "use `AM_GNU_GETTEXT'",
291 # Now part of autoconf proper, under a different name.
292 'fp_FUNC_FNMATCH' => "use `AC_FUNC_FNMATCH'",
293 'AM_SANITY_CHECK_CC' => "automatically done by `AC_PROG_CC'",
294 'AM_PROG_INSTALL' => "use `AC_PROG_INSTALL'",
295 'AM_EXEEXT' => "automatically done by `AC_PROG_(CC|CXX|F77)'",
296 'AM_CYGWIN32' => "use `AC_CYGWIN'",
297 'AM_MINGW32' => "use `AC_MINGW32'",
298 'AM_FUNC_MKTIME' => "use `AC_FUNC_MKTIME'",
301 # Regexp to match the above macros.
302 my $obsolete_rx = '\b(' . join ('|', keys %obsolete_macros) . ')\b';
306 ## ---------------------------------- ##
307 ## Variables related to the options. ##
308 ## ---------------------------------- ##
310 # TRUE if we should always generate Makefile.in.
311 my $force_generation = 1;
313 # Strictness level as set on command line.
314 my $default_strictness = $GNU;
316 # Name of strictness level, as set on command line.
317 my $default_strictness_name = 'gnu';
319 # This is TRUE if automatic dependency generation code should be
320 # included in generated Makefile.in.
321 my $cmdline_use_dependencies = 1;
323 # TRUE if in verbose mode.
326 # This holds our (eventual) exit status. We don't actually exit until
327 # we have processed all input files.
330 # From the Perl manual.
331 my $symlink_exists = (eval 'symlink ("", "");', $@ eq '');
333 # TRUE if missing standard files should be installed.
336 # TRUE if we should copy missing files; otherwise symlink if possible.
337 my $copy_missing = 0;
339 # TRUE if we should always update files that we know about.
340 my $force_missing = 0;
343 ## ---------------------------------------- ##
344 ## Variables filled during files scanning. ##
345 ## ---------------------------------------- ##
347 # Name of the top autoconf input: `configure.ac' or `configure.in'.
348 my $configure_ac = '';
350 # Files found by scanning configure.ac for LIBOBJS.
353 # True if AM_C_PROTOTYPES appears in configure.ac.
354 my $am_c_prototypes = 0;
356 # Names used in AC_CONFIG_HEADER call. @config_fullnames holds the
357 # name which appears in AC_CONFIG_HEADER, colon and all.
358 # @config_names holds the file names. @config_headers holds the '.in'
359 # files. Ordinarily these are similar, but they can be different if
360 # the weird "NAME:FILE" syntax is used.
361 my @config_fullnames = ();
362 my @config_names = ();
363 my @config_headers = ();
364 # Line number at which AC_CONFIG_HEADER appears in configure.ac.
365 my $config_header_line = 0;
367 # Directory where output files go. Actually, output files are
368 # relative to this directory.
369 my $output_directory = '.';
371 # List of Makefile.am's to process, and their corresponding outputs.
372 my @input_files = ();
373 my %output_files = ();
375 # Complete list of Makefile.am's that exist.
376 my @configure_input_files = ();
378 # List of files in AC_OUTPUT without Makefile.am, and their outputs.
379 my @other_input_files = ();
380 # Line number at which AC_OUTPUT seen.
381 my $ac_output_line = 0;
383 # List of directories to search for configure-required files. This
384 # can be set by AC_CONFIG_AUX_DIR.
385 my @config_aux_path = ('.', '..', '../..');
386 my $config_aux_dir = '';
387 my $config_aux_dir_set_in_configure_in = 0;
389 # Whether AM_GNU_GETTEXT has been seen in configure.ac.
390 my $seen_gettext = 0;
391 # Line number at which AM_GNU_GETTEXT seen.
392 my $ac_gettext_line = 0;
394 # TRUE if AC_DECL_YYTEXT was seen.
395 my $seen_decl_yytext = 0;
397 # TRUE if we've seen AC_CANONICAL_(HOST|SYSTEM). The presence of
398 # AC_CHECK_TOOL also sets this.
399 my $seen_canonical = 0;
401 # TRUE if we've seen AC_PROG_LIBTOOL.
402 my $seen_libtool = 0;
403 my $libtool_line = 0;
405 # TRUE if we've seen AM_MAINTAINER_MODE.
406 my $seen_maint_mode = 0;
408 # Actual version we've seen.
409 my $package_version = '';
411 # Line number where we saw version definition.
412 my $package_version_line = 0;
414 # TRUE if we've seen AM_PATH_LISPDIR.
415 my $seen_lispdir = 0;
417 # TRUE if we've seen AM_PATH_PYTHON.
418 my $seen_pythondir = 0;
420 # TRUE if we've seen AC_ENABLE_MULTILIB.
421 my $seen_multilib = 0;
423 # TRUE if we've seen AM_PROG_CC_C_O
426 # TRUE if we've seen AM_INIT_AUTOMAKE.
427 my $seen_init_automake = 0;
429 # Hash table of discovered configure substitutions. Keys are names,
430 # values are `FILE:LINE' strings which are used by error message
432 my %configure_vars = ();
434 # This is used to keep track of which variable definitions we are
435 # scanning. It is only used in certain limited ways, but it has to be
436 # global. It is declared just for documentation purposes.
437 my %vars_scanned = ();
439 # TRUE if --cygnus seen.
442 # Hash table of AM_CONDITIONAL variables seen in configure.
443 my %configure_cond = ();
445 # This maps extensions onto language names.
446 my %extension_map = ();
448 # List of the DIST_COMMON files we discovered while reading
450 my $configure_dist_common = '';
452 # This maps languages names onto objects.
455 # List of targets we must always output.
456 # FIXME: Complete, and remove falsely required targets.
457 my %required_targets =
468 # FIXME: Not required, temporary hacks.
469 # Well, actually they are sort of required: the -recursive
470 # targets will run them anyway...
473 'install-data-am' => 1,
474 'install-exec-am' => 1,
475 'installcheck-am' => 1,
483 ################################################################
485 ## ------------------------------------------ ##
486 ## Variables reset by &initialize_per_input. ##
487 ## ------------------------------------------ ##
489 # Basename and relative dir of the input file.
493 # Same but wrt Makefile.in.
497 # These two variables are used when generating each Makefile.in.
498 # They hold the Makefile.in until it is ready to be printed.
505 # Suffixes found during a run.
508 # Handling the variables.
511 # - $var_value{$VAR}{$COND} is its value associated to $COND,
512 # - $var_line{$VAR} is where it has been defined,
513 # - $var_comment{$VAR} are the comments associated to it.
514 # - $var_type{$VAR} is how it has been defined (`', `+', or `:'),
515 # - $var_is_am{$VAR} is true if the variable is owned by Automake.
522 # This holds a 1 if a particular variable was examined.
525 # This holds the names which are targets. These also appear in
529 # Same as %VAR_VALUE, but for targets.
530 my %target_conditional;
532 # This is the conditional stack.
535 # This holds the set of included files.
538 # This holds a list of directories which we must create at `dist'
539 # time. This is used in some strange scenarios involving weird
540 # AC_OUTPUT commands.
543 # List of dependencies for the obvious targets.
548 # Holds the dependencies of targets which dependencies are factored.
549 # Typically, `.PHONY' will appear in plenty of *.am files, but must
550 # be output once. Arguably all pure dependencies could be subject
551 # to this factorization, but it is not unpleasant to have paragraphs
552 # in Makefile: keeping related stuff altogether.
555 # Holds the factored actions. Tied to %DEPENDENCIES, i.e., filled
556 # only when keys exists in %DEPENDENCIES.
559 # A list of files deleted by `maintainer-clean'.
560 my @maintainer_clean_files;
562 # Keys in this hash table are object files or other files in
563 # subdirectories which need to be removed. This only holds files
564 # which are created by compilations. The value in the hash indicates
565 # when the file should be removed.
566 my %compile_clean_files;
568 # Value of `$(SOURCES)', used by tags.am.
570 # Sources which go in the distribution.
573 # This hash maps object file names onto their corresponding source
574 # file names. This is used to ensure that each object is created
575 # by a single source file.
578 # This keeps track of the directories for which we've already
579 # created `.dirstamp' code.
589 # Options from AUTOMAKE_OPTIONS.
592 # Whether or not dependencies are handled. Can be further changed
594 my $use_dependencies;
596 # This is a list of all targets to run during "make dist".
599 # Keys in this hash are the basenames of files which must depend
603 # This maps the source extension of a suffix rule to its
604 # corresponding output extension.
607 # This is the name of the redirect `all' target to use.
610 # This keeps track of which extensions we've seen (that we care
614 # This is random scratch space for the language finish functions.
615 # Don't randomly overwrite it; examine other uses of keys first.
616 my %language_scratch;
618 # We keep track of which objects need special (per-executable)
619 # handling on a per-language basis.
620 my %lang_specific_files;
622 # This is set when `handle_dist' has finished. Once this happens,
623 # we should no longer push on dist_common.
626 # Used to store a set of linkers needed to generate the sources currently
627 # under consideration.
630 # True if we need `LINK' defined. This is a hack.
633 # This is the list of such variables to output.
634 # FIXME: Might be useless actually.
637 # Was get_object_extension run?
638 # FIXME: This is a hack. a better switch should be found.
639 my $get_object_extension_was_run;
641 # Contains a stack of `from' parts of variable substitutions currently in
645 # Contains a stack of `to' parts of variable substitutions currently in
649 # Associates a variable name, together with a list of substitutions to be
650 # performed on it, with a number. Used to provide unique names for generated
654 ## --------------------------------- ##
655 ## Forward subroutine declarations. ##
656 ## --------------------------------- ##
657 sub register_language (%);
658 sub file_contents_internal ($$%);
659 sub define_objects_from_sources ($$$$$$$);
662 # &initialize_per_input ()
663 # ------------------------
664 # (Re)-Initialize per-Makefile.am variables.
665 sub initialize_per_input ()
668 $am_relative_dir = '';
675 $output_trailer = '';
691 %target_conditional = ();
699 $am_relative_dir = '';
715 # Installing/uninstalling.
716 'install-data-am' => [],
717 'install-exec-am' => [],
718 'uninstall-am' => [],
721 'uninstall-man' => [],
723 'install-info' => [],
724 'install-info-am' => [],
725 'uninstall-info' => [],
727 'installcheck-am' => [],
731 'mostlyclean-am' => [],
732 'maintainer-clean-am' => [],
733 'distclean-am' => [],
736 'maintainer-clean' => [],
747 @maintainer_clean_files = ();
758 $strictness = $default_strictness;
759 $strictness_name = $default_strictness_name;
763 $use_dependencies = $cmdline_use_dependencies;
773 %extension_seen = ();
775 %language_scratch = ();
777 %lang_specific_files = ();
779 $handle_dist_run = 0;
785 $get_object_extension_was_run = 0;
787 %compile_clean_files = ();
791 ################################################################
793 # Initialize our list of languages that are internally supported.
796 register_language ('name' => 'c',
798 'config_vars' => ['CC'],
802 'compiler' => 'COMPILE',
803 'compile' => '$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)',
807 'link' => '$(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
808 'compile_flag' => '-c',
809 'extensions' => ['c'],
810 '_finish' => \&lang_c_finish);
813 register_language ('name' => 'cxx',
815 'config_vars' => ['CXX'],
816 'linker' => 'CXXLINK',
817 'link' => '$(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
819 'flags' => 'CXXFLAGS',
820 'compile' => '$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)',
821 'compiler' => 'CXXCOMPILE',
822 'compile_flag' => '-c',
823 'output_flag' => '-o',
827 'extensions' => ['c++', 'cc', 'cpp', 'cxx', 'C']);
830 register_language ('name' => 'objc',
831 'Name' => 'Objective C',
832 'config_vars' => ['OBJC'],
833 'linker' => 'OBJCLINK',,
834 'link' => '$(OBJCLD) $(AM_OBJCFLAGS) $(OBJCFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
836 'flags' => 'OBJCFLAGS',
837 'compile' => '$(OBJC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_OBJCFLAGS) $(OBJCFLAGS)',
838 'compiler' => 'OBJCCOMPILE',
839 'compile_flag' => '-c',
840 'output_flag' => '-o',
844 'extensions' => ['m']);
847 register_language ('name' => 'header',
849 'extensions' => ['h', 'H', 'hxx', 'h++', 'hh', 'hpp', 'inc'],
851 '_finish' => sub { });
854 register_language ('name' => 'yacc',
856 'config_vars' => ['YACC'],
859 'compile' => '$(YACC) $(YFLAGS) $(AM_YFLAGS)',
860 'compiler' => 'YACCCOMPILE',
861 'extensions' => ['y'],
862 'rule_file' => 'yacc',
863 '_finish' => \&lang_yacc_finish,
864 '_target_hook' => \&lang_yacc_target_hook);
865 register_language ('name' => 'yaccxx',
866 'Name' => 'Yacc (C++)',
867 'config_vars' => ['YACC'],
868 'rule_file' => 'yacc',
871 'compiler' => 'YACCCOMPILE',
872 'compile' => '$(YACC) $(YFLAGS) $(AM_YFLAGS)',
873 'extensions' => ['y++', 'yy', 'yxx', 'ypp'],
874 '_finish' => \&lang_yacc_finish,
875 '_target_hook' => \&lang_yacc_target_hook);
878 register_language ('name' => 'lex',
880 'config_vars' => ['LEX'],
881 'rule_file' => 'lex',
884 'compile' => '$(LEX) $(LFLAGS) $(AM_LFLAGS)',
885 'compiler' => 'LEXCOMPILE',
886 'extensions' => ['l'],
887 '_finish' => \&lang_lex_finish);
888 register_language ('name' => 'lexxx',
889 'Name' => 'Lex (C++)',
890 'config_vars' => ['LEX'],
891 'rule_file' => 'lex',
894 'compile' => '$(LEX) $(LFLAGS) $(AM_LFLAGS)',
895 'compiler' => 'LEXCOMPILE',
896 'extensions' => ['l++', 'll', 'lxx', 'lpp'],
897 '_finish' => \&lang_lex_finish);
900 register_language ('name' => 'asm',
901 'Name' => 'Assembler',
902 'config_vars' => ['AS', 'ASFLAGS'],
904 'flags' => 'ASFLAGS',
905 # Users can set AM_ASFLAGS to includes DEFS, INCLUDES,
906 # or anything else required. They can also set AS.
907 'compile' => '$(AS) $(AM_ASFLAGS) $(ASFLAGS)',
908 'compiler' => 'ASCOMPILE',
909 'compile_flag' => '-c',
910 'extensions' => ['s', 'S'],
912 # With assembly we still use the C linker.
913 '_finish' => \&lang_c_finish);
916 register_language ('name' => 'f77',
917 'Name' => 'Fortran 77',
918 'linker' => 'F77LINK',
919 'link' => '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
921 'compile' => '$(F77) $(AM_FFLAGS) $(FFLAGS)',
922 'compiler' => 'F77COMPILE',
923 'compile_flag' => '-c',
924 'output_flag' => '-o',
928 'extensions' => ['f', 'for', 'f90']);
930 # Preprocessed Fortran 77
932 # The current support for preprocessing Fortran 77 just involves
933 # passing `$(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS)
934 # $(CPPFLAGS)' as additional flags to the Fortran 77 compiler, since
935 # this is how GNU Make does it; see the `GNU Make Manual, Edition 0.51
936 # for `make' Version 3.76 Beta' (specifically, from info file
937 # `(make)Catalogue of Rules').
939 # A better approach would be to write an Autoconf test
940 # (i.e. AC_PROG_FPP) for a Fortran 77 preprocessor, because not all
941 # Fortran 77 compilers know how to do preprocessing. The Autoconf
942 # macro AC_PROG_FPP should test the Fortran 77 compiler first for
943 # preprocessing capabilities, and then fall back on cpp (if cpp were
945 register_language ('name' => 'ppf77',
946 'Name' => 'Preprocessed Fortran 77',
947 'config_vars' => ['F77'],
948 'linker' => 'F77LINK',
949 'link' => '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
953 'compiler' => 'PPF77COMPILE',
954 'compile' => '$(F77) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FFLAGS) $(FFLAGS)',
955 'compile_flag' => '-c',
956 'output_flag' => '-o',
958 'extensions' => ['F']);
961 register_language ('name' => 'ratfor',
963 'config_vars' => ['F77'],
964 'linker' => 'F77LINK',
965 'link' => '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
970 'compile' => '$(F77) $(AM_FFLAGS) $(FFLAGS) $(AM_RFLAGS) $(RFLAGS)',
971 'compiler' => 'RCOMPILE',
972 'compile_flag' => '-c',
973 'output_flag' => '-o',
975 'extensions' => ['r']);
978 register_language ('name' => 'java',
980 'config_vars' => ['GCJ'],
981 'linker' => 'GCJLINK',
982 'link' => '$(GCJLD) $(AM_GCJFLAGS) $(GCJFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
984 'flags' => 'GCJFLAGS',
985 'compile' => '$(GCJ) $(AM_GCJFLAGS) $(GCJFLAGS)',
986 'compiler' => 'GCJCOMPILE',
987 'compile_flag' => '-c',
988 'output_flag' => '-o',
992 'extensions' => ['java', 'class', 'zip', 'jar']);
994 ################################################################
996 # Parse command line.
999 # Do configure.ac scan only once.
1000 &scan_autoconf_files;
1002 die "$me: no `Makefile.am' found or specified\n"
1005 # Now do all the work on each file.
1006 # This guy must be local otherwise it's private to the loop.
1007 use vars '$am_file';
1009 foreach $am_file (@input_files)
1011 if (! -f ($am_file . '.am'))
1013 &am_error ("`" . $am_file . ".am' does not exist");
1017 &generate_makefile ($output_files{$am_file}, $am_file);
1023 # FIXME: This should be `my'ed next to its subs.
1024 use vars '%require_file_found';
1026 ################################################################
1028 # prog_error (@PRINT-ME)
1029 # ----------------------
1030 # Signal a programming error, display PRINT-ME, and exit 1.
1033 print STDERR "$me: programming error: @_\n";
1040 # Return a configure-style substitution using the indicated text.
1041 # We do this to avoid having the substitutions directly in automake.in;
1042 # when we do that they are sometimes removed and this causes confusion
1047 return '@' . $text . '@';
1050 ################################################################
1054 # &backname ($REL-DIR)
1055 # --------------------
1056 # If I `cd $REL-DIR', then to come back, I should `cd $BACKPATH'.
1057 # For instance `src/foo' => `../..'.
1058 # Works with non strictly increasing paths, i.e., `src/../lib' => `..'.
1063 foreach (split (/\//, $file))
1065 next if $_ eq '.' || $_ eq '';
1075 return join ('/', @res) || '.';
1078 ################################################################
1080 # Parse command line.
1081 sub parse_arguments ()
1084 &set_strictness ('gnu');
1087 Getopt::Long::config ("bundling");
1088 Getopt::Long::GetOptions
1090 'version' => \&version,
1092 'libdir:s' => \$libdir,
1093 'gnu' => sub { &set_strictness ('gnu'); },
1094 'gnits' => sub { &set_strictness ('gnits'); },
1095 'cygnus' => \$cygnus_mode,
1096 'foreign' => sub { &set_strictness ('foreign'); },
1097 'include-deps' => sub { $cmdline_use_dependencies = 1; },
1098 'i|ignore-deps' => sub { $cmdline_use_dependencies = 0; },
1099 'no-force' => sub { $force_generation = 0; },
1100 'f|force-missing'=> \$force_missing,
1101 'o|output-dir:s' => \$output_directory,
1102 'a|add-missing' => \$add_missing,
1103 'c|copy' => \$copy_missing,
1104 'v|verbose' => \$verbose,
1105 'Werror' => sub { $SIG{"__WARN__"} = sub { die $_[0] } },
1106 'Wno-error' => sub { $SIG{"__WARN__"} = 'DEFAULT' }
1110 foreach my $arg (@ARGV)
1112 # Handle $local:$input syntax. Note that we only examine the
1113 # first ":" file to see if it is automake input; the rest are
1114 # just taken verbatim. We still keep all the files around for
1115 # dependency checking, however.
1116 my ($local, $input, @rest) = split (/:/, $arg);
1123 # Strip .in; later on .am is tacked on. That is how the
1124 # automake input file is found. Maybe not the best way, but
1125 # it is easy to explain.
1127 or die "$me: invalid input file name `$arg'\n.";
1129 push (@input_files, $input);
1130 $output_files{$input} = join (':', ($local, @rest));
1133 # Take global strictness from whatever we currently have set.
1134 $default_strictness = $strictness;
1135 $default_strictness_name = $strictness_name;
1138 ################################################################
1140 # Generate a Makefile.in given the name of the corresponding Makefile and
1141 # the name of the file output by config.status.
1142 sub generate_makefile
1144 my ($output, $makefile) = @_;
1146 # Reset all the Makefile.am related variables.
1147 &initialize_per_input;
1149 # Name of input file ("Makefile.am") and output file
1150 # ("Makefile.in"). These have no directory components.
1151 $am_file_name = basename ($makefile) . '.am';
1152 $in_file_name = basename ($makefile) . '.in';
1154 # $OUTPUT is encoded. If it contains a ":" then the first element
1155 # is the real output file, and all remaining elements are input
1156 # files. We don't scan or otherwise deal with these input file,
1157 # other than to mark them as dependencies. See
1158 # &scan_autoconf_files for details.
1159 my (@secondary_inputs);
1160 ($output, @secondary_inputs) = split (/:/, $output);
1162 $relative_dir = dirname ($output);
1163 $am_relative_dir = dirname ($makefile);
1165 &read_main_am_file ($makefile . '.am');
1166 if (&handle_options)
1168 # Fatal error. Just return, so we can continue with next file.
1172 # There are a few install-related variables that you should not define.
1173 foreach my $var ('PRE_INSTALL', 'POST_INSTALL', 'NORMAL_INSTALL')
1175 if (&variable_defined ($var) && !$var_is_am{$var})
1177 &am_line_error ($var, "`$var' should not be defined");
1183 # At the toplevel directory, we might need config.guess, config.sub
1184 # or libtool scripts (ltconfig and ltmain.sh).
1185 if ($relative_dir eq '.')
1187 # AC_CANONICAL_HOST and AC_CANONICAL_SYSTEM need config.guess and
1189 &require_config_file ($FOREIGN, 'config.guess', 'config.sub')
1193 # We still need Makefile.in here, because sometimes the `dist'
1194 # target doesn't re-run automake.
1195 if ($am_relative_dir eq $relative_dir)
1197 # Only distribute the files if they are in the same subdir as
1198 # the generated makefile.
1199 &push_dist_common ($in_file_name, $am_file_name);
1202 push (@sources, '$(SOURCES)')
1203 if &variable_defined ('SOURCES');
1205 # Must do this after reading .am file. See read_main_am_file to
1206 # understand weird tricks we play there with variables.
1207 &define_variable ('subdir', $relative_dir);
1209 # Check first, because we might modify some state.
1211 &check_gnu_standards;
1212 &check_gnits_standards;
1214 &handle_configure ($output, $makefile, @secondary_inputs);
1217 &handle_ltlibraries;
1221 # This must run first so that the ANSI2KNR definition is generated
1222 # before it is used by the _.c rules. We have to do this because
1223 # a variable which is used in a dependency must be defined before
1224 # the target, or else make won't properly see it.
1226 # This must be run after all the sources are scanned.
1229 # Re-init SOURCES. FIXME: other code shouldn't depend on this
1230 # (but currently does).
1231 macro_define ('SOURCES', 1, '', 'TRUE',
1232 join (' ', @sources), 'internal');
1233 define_pretty_variable ('DIST_SOURCES', '', @dist_sources);
1245 &handle_minor_options;
1248 # This must come after most other rules.
1249 &handle_dist ($makefile);
1252 &do_check_merge_target;
1253 &handle_all ($output);
1256 if (&variable_defined('lib_LTLIBRARIES') &&
1257 &variable_defined('bin_PROGRAMS'))
1259 $output_rules .= "install-binPROGRAMS: install-libLTLIBRARIES\n\n";
1262 &handle_installdirs;
1264 &handle_factored_dependencies;
1268 if (! -d ($output_directory . '/' . $am_relative_dir))
1270 mkdir ($output_directory . '/' . $am_relative_dir, 0755);
1273 my ($out_file) = $output_directory . '/' . $makefile . ".in";
1274 if (! $force_generation && -e $out_file)
1276 my ($am_time) = (stat ($makefile . '.am'))[9];
1277 my ($in_time) = (stat ($out_file))[9];
1278 # FIXME: should cache these times.
1279 my ($conf_time) = (stat ($configure_ac))[9];
1280 # FIXME: how to do unsigned comparison?
1281 if ($am_time < $in_time || $am_time < $conf_time)
1283 # No need to update.
1286 if (-f 'aclocal.m4')
1288 my ($acl_time) = (stat _)[9];
1289 return if ($am_time < $acl_time);
1293 my $gm_file = new IO::File "> $out_file";
1296 warn "$me: ${am_file}.in: cannot write: $!\n";
1300 print "$me: creating ", $makefile, ".in\n" if $verbose;
1302 # In case we're running under MSWindows, don't write with CRLF
1303 # (as it causes problems for the dependency-file extraction in
1304 # AM_OUTPUT_DEPENDENCY_COMMANDS).
1307 print $gm_file $output_vars;
1308 # We make sure that `all:' is the first target.
1309 print $gm_file $output_all;
1310 print $gm_file $output_header;
1311 print $gm_file $output_rules;
1312 print $gm_file $output_trailer;
1314 if (! $gm_file->close)
1316 warn "$me: $am_file.in: cannot close: $!\n";
1322 ################################################################
1324 # A helper which handles the logic of requiring a version number in
1325 # AUTOMAKE_OPTIONS. Return 1 on error, 0 on success.
1326 sub version_check ($$$$)
1328 my ($rmajor, $rminor, $ralpha, $rfork) = ($1, $2, $3, $4);
1330 &prog_error ("version is incorrect: $VERSION")
1331 if $VERSION !~ /(\d+)\.(\d+)([a-z]?)-?([A-Za-z0-9]+)?/;
1333 my ($tmajor, $tminor, $talpha, $tfork) = ($1, $2, $3, $4);
1338 my $rminorminor = 0;
1339 my $tminorminor = 0;
1341 # Some versions were labelled like `1.4-p3a'. This is the same as
1342 # an alpha release labelled `1.4.3a'. However, a version like
1343 # `1.4g' is the same as `1.4.99g'. Yes, this sucks. Moral:
1344 # always listen to the users.
1345 if ($rfork =~ /p([0-9]+)([a-z]?)/)
1348 # `1.4a-p3b' never existed. But we'll accept it anyway.
1349 $ralpha = $ralpha || $2 || '';
1352 if ($tfork =~ /p([0-9]+)([a-z]?)/)
1355 # `1.4a-p3b' never existed. But we'll accept it anyway.
1356 $talpha = $talpha || $2 || '';
1360 $rminorminor = 99 if $ralpha ne '' && $rminorminor == 0;
1361 $tminorminor = 99 if $talpha ne '' && $tminorminor == 0;
1363 # 2.0 is better than 1.0.
1364 # 1.2 is better than 1.1.
1365 # 1.2a is better than 1.2.
1366 # If we require 3.4n-foo then we require something
1367 # >= 3.4n, with the `foo' fork identifier.
1368 # The $r* variables are what the user specified.
1369 # The $t* variables denote automake itself.
1370 if ($rmajor > $tmajor
1371 || ($rmajor == $tmajor && $rminor > $tminor)
1372 || ($rminor == $tminor && $rminor == $tminor
1373 && $rminorminor > $tminorminor)
1374 || ($rminor == $tminor && $rminor == $tminor
1375 && $rminorminor == $tminorminor
1376 && $ralpha gt $talpha)
1377 || ($rfork ne '' && $rfork ne $tfork))
1379 &am_line_error ('AUTOMAKE_OPTIONS',
1380 "require version $_, but have $VERSION");
1387 # Handle AUTOMAKE_OPTIONS variable. Return 1 on error, 0 otherwise.
1390 if (&variable_defined ('AUTOMAKE_OPTIONS'))
1392 foreach (&variable_value_as_list_recursive ('AUTOMAKE_OPTIONS', ''))
1395 if ($_ eq 'gnits' || $_ eq 'gnu' || $_ eq 'foreign')
1397 &set_strictness ($_);
1399 elsif ($_ eq 'cygnus')
1403 elsif (/^(.*\/)?ansi2knr$/)
1405 # An option like "../lib/ansi2knr" is allowed. With
1406 # no path prefix, we assume the required programs are
1407 # in this directory. We save the actual option for
1409 $options{'ansi2knr'} = $_;
1411 elsif ($_ eq 'no-installman' || $_ eq 'no-installinfo'
1412 || $_ eq 'dist-shar' || $_ eq 'dist-zip'
1413 || $_ eq 'dist-tarZ' || $_ eq 'dist-bzip2'
1414 || $_ eq 'dejagnu' || $_ eq 'no-texinfo.tex'
1415 || $_ eq 'readme-alpha' || $_ eq 'check-news'
1416 || $_ eq 'subdir-objects' || $_ eq 'nostdinc'
1417 || $_ eq 'no-exeext')
1419 # Explicitly recognize these.
1421 elsif ($_ eq 'no-dependencies')
1423 $use_dependencies = 0;
1425 elsif (/(\d+)\.(\d+)([a-z]?)(-[A-Za-z0-9]+)?/)
1427 # Got a version number.
1428 if (version_check ($1, $2, $3, $4))
1435 &am_line_error ('AUTOMAKE_OPTIONS',
1436 "option `" . $_ . "\' not recognized");
1441 if ($strictness == $GNITS)
1443 $options{'readme-alpha'} = 1;
1444 $options{'check-news'} = 1;
1451 # get_object_extension ($OUT)
1452 # ---------------------------
1453 # Return object extension. Just once, put some code into the output.
1454 # OUT is the name of the output file
1455 sub get_object_extension
1459 # Maybe require libtool library object files.
1460 my $extension = '.$(OBJEXT)';
1461 $extension = '.lo' if ($out =~ /\.la$/);
1463 # Check for automatic de-ANSI-fication.
1464 $extension = '$U' . $extension
1465 if defined $options{'ansi2knr'};
1467 $get_object_extension_was_run = 1;
1473 # Call finish function for each language that was used.
1474 sub handle_languages
1476 if ($use_dependencies)
1478 # Include auto-dep code. Don't include it if DEP_FILES would
1480 if (&saw_sources_p (0) && keys %dep_files)
1482 # Set location of depcomp.
1483 &define_variable ('depcomp', "\$(SHELL) $config_aux_dir/depcomp");
1485 &require_conf_file ($FOREIGN, 'depcomp');
1487 my @deplist = sort keys %dep_files;
1489 # We define this as a conditional variable because BSD
1490 # make can't handle backslashes for continuing comments on
1491 # the following line.
1492 define_pretty_variable ('DEP_FILES', 'AMDEP_TRUE', @deplist);
1494 # Generate each `include' individually. Irix 6 make will
1495 # not properly include several files resulting from a
1496 # variable expansion; generating many separate includes
1498 $output_rules .= "\n";
1499 foreach my $iter (@deplist)
1501 $output_rules .= (subst ('AMDEP_TRUE')
1502 . subst ('am__include')
1504 . subst ('am__quote')
1506 . subst ('am__quote')
1510 $output_rules .= &file_contents ('depend');
1515 &define_variable ('depcomp', '');
1520 # Is the c linker needed?
1522 foreach my $ext (sort keys %extension_seen)
1524 next unless $extension_map{$ext};
1526 my $lang = $languages{$extension_map{$ext}};
1528 my $rule_file = $lang->rule_file || 'depend2';
1530 # Get information on $LANG.
1531 my $pfx = $lang->autodep;
1532 my $fpfx = ($pfx eq '') ? 'CC' : $pfx;
1534 my $AMDEP = (($use_dependencies && $lang->autodep ne 'no')
1535 ? 'AMDEP' : 'FALSE');
1537 my %transform = ('EXT' => $ext,
1540 'LIBTOOL' => $seen_libtool,
1542 '-c' => $lang->compile_flag || '',
1544 => (count_files_for_language ($lang->name) > 1));
1546 # Generate the appropriate rules for this extension.
1547 if (($use_dependencies && $lang->autodep ne 'no')
1548 || defined $lang->compile)
1550 # Some C compilers don't support -c -o. Use it only if really
1552 my $output_flag = $lang->output_flag || '';
1555 && $lang->flags eq 'CFLAGS'
1556 && defined $options{'subdir-objects'});
1558 # FIXME: this is a temporary hack to compute a possible
1559 # derived extension. This is not used by depend2.am.
1560 (my $der_ext = $ext) =~ tr/yl/cc/;
1562 # Another yacc/lex hack.
1563 my $destfile = '$*.' . $der_ext;
1566 file_contents ($rule_file,
1570 'DERIVED-EXT' => $der_ext,
1578 'COMPILE' => '$(' . $lang->compiler . ')',
1579 'LTCOMPILE' => '$(LT' . $lang->compiler . ')',
1580 '-o' => $output_flag);
1583 # Now include code for each specially handled object with this
1585 my %seen_files = ();
1586 foreach my $file (@{$lang_specific_files{$lang->name}})
1588 my ($derived, $source, $obj, $myext) = split (' ', $file);
1590 # We might see a given object twice, for instance if it is
1591 # used under different conditions.
1592 next if defined $seen_files{$obj};
1593 $seen_files{$obj} = 1;
1595 my $flags = $lang->flags || '';
1596 my $val = "${derived}_${flags}";
1598 &prog_error ("found $lang->name in handle_languages, but compiler not defined")
1599 unless defined $lang->compile;
1601 (my $obj_compile = $lang->compile) =~ s/\(AM_$flags/\($val/;
1602 my $obj_ltcompile = '$(LIBTOOL) --mode=compile ' . $obj_compile;
1604 # We _need_ `-o' for per object rules.
1605 my $output_flag = $lang->output_flag || '-o';
1607 # Generate a transform which will turn suffix targets in
1608 # depend2.am into real targets for the particular objects we
1611 file_contents ($rule_file,
1616 'SOURCE' => $source,
1617 # Use $myext and not `.o' here, in case
1618 # we are actually building a new source
1619 # file -- e.g. via yacc.
1620 'OBJ' => "$obj$myext",
1621 'OBJOBJ' => "$obj.obj",
1622 'LTOBJ' => "$obj.lo",
1624 'COMPILE' => $obj_compile,
1625 'LTCOMPILE' => $obj_ltcompile,
1626 '-o' => $output_flag));
1629 # The rest of the loop is done once per language.
1630 next if defined $done{$lang};
1633 # Load the language dependent Makefile chunks.
1634 my %lang = map { uc ($_) => 0 } keys %languages;
1635 $lang{uc ($lang->name)} = 1;
1636 $output_rules .= file_contents ('lang-compile', %transform, %lang);
1638 # If the source to a program consists entirely of code from a
1639 # `pure' language, for instance C++ for Fortran 77, then we
1640 # don't need the C compiler code. However if we run into
1641 # something unusual then we do generate the C code. There are
1642 # probably corner cases here that do not work properly.
1643 # People linking Java code to Fortran code deserve pain.
1644 $needs_c ||= ! $lang->pure;
1646 define_compiler_variable ($lang)
1647 if ($lang->compile);
1649 define_linker_variable ($lang)
1652 foreach my $var (@{$lang->config_vars})
1654 am_error ($lang->Name
1655 . " source seen but `$var' not defined in"
1656 . " `$configure_ac'")
1657 if !exists $configure_vars{$var};
1660 # The compiler's flag must be a configure variable.
1661 define_configure_variable ($lang->flags)
1662 if defined $lang->flags && $lang->define_flag;
1664 # Call the finisher.
1668 # If the project is entirely C++ or entirely Fortran 77 (i.e., 1
1669 # suffix rule was learned), don't bother with the C stuff. But if
1670 # anything else creeps in, then use it.
1672 if $need_link || scalar keys %suffix_rules > 1;
1676 if (! defined $done{$languages{'c'}})
1678 &define_configure_variable ($languages{'c'}->flags);
1679 &define_compiler_variable ($languages{'c'});
1681 define_linker_variable ($languages{'c'});
1685 # Check to make sure a source defined in LIBOBJS is not explicitly
1686 # mentioned. This is a separate function (as opposed to being inlined
1687 # in handle_source_transform) because it isn't always appropriate to
1689 sub check_libobjs_sources
1691 my ($one_file, $unxformed) = @_;
1693 foreach my $prefix ('', 'EXTRA_', 'dist_', 'nodist_',
1694 'dist_EXTRA_', 'nodist_EXTRA_')
1697 if (&variable_defined ($prefix . $one_file . '_SOURCES'))
1699 @files = &variable_value_as_list_recursive (
1700 ($prefix . $one_file . '_SOURCES'),
1703 elsif ($prefix eq '')
1705 @files = ($unxformed . '.c');
1712 foreach my $file (@files)
1714 if (defined $libsources{$file})
1716 &am_line_error ($prefix . $one_file . '_SOURCES',
1717 "automatically discovered file `$file' should not be explicitly mentioned");
1725 # handle_single_transform_list ($VAR, $TOPPARENT, $DERIVED, $OBJ, @FILES)
1726 # -----------------------------------------------------------------------
1727 # Does much of the actual work for handle_source_transform.
1729 # $VAR is the name of the variable that the source filenames come from
1730 # $TOPPARENT is the name of the _SOURCES variable which is being processed
1731 # $DERIVED is the name of resulting executable or library
1732 # $OBJ is the object extension (e.g., `$U.lo')
1733 # @FILES is the list of source files to transform
1734 # Result is a list of the names of objects
1735 # %linkers_used will be updated with any linkers needed
1736 sub handle_single_transform_list ($$$$@)
1738 my ($var, $topparent, $derived, $obj, @files) = @_;
1740 my $nonansi_obj = $obj;
1741 $nonansi_obj =~ s/\$U//g;
1743 # Turn sources into objects. We use a while loop like this
1744 # because we might add to @files in the loop.
1745 while (scalar @files > 0)
1749 # Configure substitutions in _SOURCES variables are errors.
1752 &am_line_error ($var, "`$var' includes configure substitution `$_', and is referred to from `$topparent': configure substitutions not allowed in _SOURCES variables");
1756 # If the source file is in a subdirectory then the `.o' is put
1757 # into the current directory, unless the subdir-objects option
1760 # Split file name into base and extension.
1761 next if ! /^(?:(.*)\/)?([^\/]*)\.(.*)$/;
1763 my $directory = $1 || '';
1767 # We must generate a rule for the object if it requires its own flags.
1769 my ($linker, $object);
1771 # This records whether we've seen a derived source file (eg,
1773 my $derived_source = 0;
1775 # This holds the `aggregate context' of the file we are
1776 # currently examining. If the file is compiled with
1777 # per-object flags, then it will be the name of the object.
1778 # Otherwise it will be `AM'. This is used by the target hook
1779 # language function.
1780 my $aggregate = 'AM';
1782 $extension = &derive_suffix ($extension);
1784 if ($extension_map{$extension} &&
1785 ($lang = $languages{$extension_map{$extension}}))
1787 # Found the language, so see what it says.
1788 &saw_extension ($extension);
1790 # Note: computed subr call. The language rewrite function
1791 # should return one of the $LANG_* constants. It could
1792 # also return a list whose first value is such a constant
1793 # and whose second value is a new source extension which
1794 # should be applied. This means this particular language
1795 # generates another source file which we must then process
1797 my $subr = 'lang_' . $lang->name . '_rewrite';
1798 my ($r, $source_extension)
1799 = & $subr ($directory, $base, $extension);
1800 # Skip this entry if we were asked not to process it.
1801 next if $r == $LANG_IGNORE;
1803 # Now extract linker and other info.
1804 $linker = $lang->linker;
1807 if (defined $source_extension)
1809 $this_obj_ext = '.' . $source_extension;
1810 $derived_source = 1;
1814 $this_obj_ext = $obj;
1818 $this_obj_ext = $nonansi_obj;
1820 $object = $base . $this_obj_ext;
1822 if (defined $lang->flags
1823 && &variable_defined ($derived . '_' . $lang->flags))
1825 # We have a per-executable flag in effect for this
1826 # object. In this case we rewrite the object's
1827 # name to ensure it is unique. We also require
1828 # the `compile' program to deal with compilers
1829 # where `-c -o' does not work.
1831 # We choose the name `DERIVED_OBJECT' to ensure
1832 # (1) uniqueness, and (2) continuity between
1833 # invocations. However, this will result in a
1834 # name that is too long for losing systems, in
1835 # some situations. So we provide _SHORTNAME to
1838 my $dname = $derived;
1839 if (&variable_defined ($derived . '_SHORTNAME'))
1841 # FIXME: should use the same conditional as
1842 # the _SOURCES variable. But this is really
1843 # silly overkill -- nobody should have
1844 # conditional shortnames.
1845 $dname = &variable_value ($derived . '_SHORTNAME');
1847 $object = $dname . '-' . $object;
1849 &require_conf_file ($FOREIGN, 'compile')
1850 if $lang->name eq 'c';
1852 &prog_error ("$lang->name flags defined without compiler")
1853 if ! defined $lang->compile;
1858 # If rewrite said it was ok, put the object into a
1860 if ($r == $LANG_SUBDIR && $directory ne '')
1862 $object = $directory . '/' . $object;
1865 # If doing dependency tracking, then we can't print
1866 # the rule. If we have a subdir object, we need to
1867 # generate an explicit rule. Actually, in any case
1868 # where the object is not in `.' we need a special
1869 # rule. The per-object rules in this case are
1870 # generated later, by handle_languages.
1871 if ($renamed || $directory ne '')
1873 my $obj_sans_ext = substr ($object, 0,
1874 - length ($this_obj_ext));
1875 my $val = ("$full $obj_sans_ext "
1876 # Only use $this_obj_ext in the derived
1877 # source case because in the other case we
1878 # *don't* want $(OBJEXT) to appear here.
1879 . ($derived_source ? $this_obj_ext : '.o'));
1881 # If we renamed the object then we want to use the
1882 # per-executable flag name. But if this is simply a
1883 # subdir build then we still want to use the AM_ flag
1887 $val = "$derived $val";
1888 $aggregate = $derived;
1895 # Each item on this list is a string consisting of
1896 # four space-separated values: the derived flag prefix
1897 # (eg, for `foo_CFLAGS', it is `foo'), the name of the
1898 # source file, the base name of the output file, and
1899 # the extension for the object file.
1900 push (@{$lang_specific_files{$lang->name}}, $val);
1903 elsif ($extension eq 'o')
1905 # This is probably the result of a direct suffix rule.
1906 # In this case we just accept the rewrite. FIXME:
1907 # this fails if we want libtool objects.
1908 $object = $base . '.' . $extension;
1913 # No error message here. Used to have one, but it was
1915 # FIXME: we could potentially do more processing here,
1916 # perhaps treating the new extension as though it were a
1917 # new source extension (as above). This would require
1918 # more restructuring than is appropriate right now.
1922 if (defined $object_map{$object})
1924 if ($object_map{$object} ne $full)
1926 &am_error ("object `$object' created by `$full' and `$object_map{$object}'");
1930 # Let the language do some special magic if required.
1931 $lang->target_hook ($aggregate, $object, $full);
1933 if ($derived_source)
1935 &prog_error ("$lang->name has automatic dependency tracking")
1936 if $lang->autodep ne 'no';
1937 # Make sure this new source file is handled next. That will
1938 # make it appear to be at the right place in the list.
1939 unshift (@files, $object);
1941 &push_dist_common ($object);
1945 $linkers_used{$linker} = 1;
1947 push (@result, $object);
1949 if (! defined $object_map{$object})
1952 $object_map{$object} = $full;
1954 # If file is in subdirectory, we need explicit
1956 if ($directory ne '' || $renamed)
1958 push (@dep_list, $full);
1961 # If resulting object is in subdir, we need to make
1962 # sure the subdir exists at build time.
1963 if ($object =~ /\//)
1965 # FIXME: check that $DIRECTORY is somewhere in the
1968 # We don't allow `..' in object file names for
1969 # *any* source, not just Java. For Java it just
1970 # doesn't make sense, but in general it is
1971 # a problem because we can't pick a good name for
1973 if ($object =~ /(\/|^)\.\.\//)
1975 &am_error ("`$full' contains `..' component but should not");
1978 # Make sure object is removed by `make mostlyclean'.
1979 $compile_clean_files{$object} = $MOSTLY_CLEAN;
1981 push (@dep_list, &require_build_directory ($directory));
1983 # If we're generating dependencies, we also want
1984 # to make sure that the appropriate subdir of the
1985 # .deps directory is created.
1986 push (@dep_list, &require_build_directory ('$(DEPDIR)/' . $directory))
1987 if ($use_dependencies);
1990 &pretty_print_rule ($object . ':', "\t", @dep_list)
1991 if scalar @dep_list > 0;
1994 # Transform .o or $o file into .P file (for automatic
1996 if ($lang && $lang->autodep ne 'no')
1998 my $depfile = $object;
1999 $depfile =~ s/\.([^.]*)$/.P$1/;
2000 $depfile =~ s/\$\(OBJEXT\)$/o/;
2001 $dep_files{'$(DEPDIR)/' . $depfile} = 1;
2009 # define_objects_from_sources ($VAR, $OBJVAR, $NODEFINE, $ONE_FILE,
2010 # $OBJ, $PARENT, $TOPPARENT)
2011 # ---------------------------------------------------------------------
2012 # Define an _OBJECTS variable for a _SOURCES variable (or subvariable)
2015 # $VAR is the name of the _SOURCES variable
2016 # $OBJVAR is the name of the _OBJECTS
2017 # $NODEFINE is a boolean: if true, $OBJVAR will not be defined (but
2018 # work done to determine the linker will be).
2019 # $ONE_FILE is the canonical (transformed) name of object to build
2020 # $OBJ is the object extension (ie either `.o' or `$o'.
2021 # $PARENT is the variable in which $VAR is used, or $VAR if not applicable.
2022 # $TOPPARENT is the _SOURCES variable being processed.
2024 # Result is a boolean, true if a linker is needed to deal with the objects.
2026 # %linkers_used, %vars_scanned, @substfroms and @substtos should be cleared
2028 # %linkers_used variable will be set to contain the linkers desired.
2029 # %vars_scanned will be used to check for recursive definitions.
2030 # @substfroms and @substtos will be used to keep a stack of variable
2031 # substitutions to be applied.
2033 sub define_objects_from_sources ($$$$$$$)
2035 my ($var, $objvar, $nodefine, $one_file, $obj, $parent, $topparent) = @_;
2037 if (defined $vars_scanned{$var})
2039 &am_line_error ($var, "variable `$var' recursively defined");
2042 $vars_scanned{$var} = 1;
2044 my $needlinker = "";
2045 foreach my $cond (variable_conditions ($var))
2048 foreach my $val (&variable_value_as_list ($var, $cond, $parent))
2050 if ($val =~ /^\$\{([^}]*)\}$/ || $val =~ /^\$\(([^)]*)\)$/)
2052 # Handle a sub variable
2055 # If the user uses a losing variable name, just ignore it.
2056 # This isn't ideal, but people have requested it.
2057 next if ($subvar =~ /\@.*\@/);
2059 # See if the variable is actually a substitution reference
2062 if ($subvar =~ /$SUBST_REF_PATTERN/o)
2066 ($from = $2) =~ s/(\W)/\\$1/g;
2068 push @substfroms, $from;
2069 push @substtos, $to;
2071 my $subobjvar = subobjname ($subvar);
2072 push (@result, '$('. $subobjvar . ')');
2074 my $temp = define_objects_from_sources ($subvar, $subobjvar,
2075 $nodefine, $one_file,
2076 $obj, $var, $topparent);
2077 $needlinker ||= $temp;
2084 my $substnum=$#substfroms;
2085 while ($substnum >= 0)
2087 $val =~ s/$substfroms[$substnum]$/$substtos[$substnum]/
2088 if defined $substfroms[$substnum];
2093 &handle_single_transform_list ($var, $topparent, $one_file, $obj, $val);
2094 push (@result, @transformed);
2095 $needlinker = "true" if @transformed;
2099 # Define _OBJECTS conditionally.
2100 define_pretty_variable ($objvar, $cond, (@result))
2104 delete $vars_scanned{$var};
2110 # subobjname ($VARNAME)
2111 # ---------------------
2112 # Return a name for an object variable.
2115 # $VARNAME is the name of the variable the object variable is being
2118 # This function also looks at @substfroms and @substtos to determine any
2119 # substitutions to be performed on the object variable.
2121 # The name returned is unique for the combination of $varname and
2122 # substitutions to be performed.
2127 my $substnum=$#substfroms;
2128 while ($substnum >= 0)
2130 if (defined $substfroms[$substnum] &&
2131 ($substfroms[$substnum] || $substtos[$substnum]))
2133 $key .= ":" . $substfroms[$substnum] . "=" . $substtos[$substnum];
2138 my $num = $substnums{$key};
2141 $num = keys(%substnums) + 1;
2142 $substnums{$key} = $num;
2145 return "am__objects_$num";
2149 # Handle SOURCE->OBJECT transform for one program or library.
2151 # canonical (transformed) name of object to build
2152 # actual name of object to build
2153 # object extension (ie either `.o' or `$o'.
2154 # Return result is name of linker variable that must be used.
2155 # Empty return means just use `LINK'.
2156 sub handle_source_transform
2158 # one_file is canonical name. unxformed is given name. obj is
2160 my ($one_file, $unxformed, $obj) = @_;
2164 if (&variable_defined ($one_file . "_OBJECTS"))
2166 &am_line_error ($one_file . '_OBJECTS',
2167 $one_file . '_OBJECTS', 'should not be defined');
2168 # No point in continuing.
2175 foreach my $prefix ('', 'EXTRA_', 'dist_', 'nodist_',
2176 'dist_EXTRA_', 'nodist_EXTRA_')
2178 my $var = $prefix . $one_file . "_SOURCES";
2180 if !variable_defined ($var);
2182 # We are going to define _OBJECTS variables using the prefix.
2183 # Then we glom them all together. So we can't use the null
2184 # prefix here as we need it later.
2185 my $xpfx = ($prefix eq '') ? 'am_' : $prefix;
2187 # Keep track of which prefixes we saw.
2188 $used_pfx{$xpfx} = 1
2189 unless $prefix =~ /EXTRA_/;
2191 push (@sources, '$(' . $prefix . $one_file . "_SOURCES)");
2192 push (@dist_sources, '$(' . $prefix . $one_file . "_SOURCES)")
2193 unless $prefix =~ /^nodist_/;
2198 my $temp = define_objects_from_sources ($var,
2199 $xpfx . $one_file . '_OBJECTS',
2200 $prefix =~ /EXTRA_/,
2201 $one_file, $obj, $var, $var);
2202 $needlinker ||= $temp;
2206 $linker ||= &resolve_linker (%linkers_used);
2209 my @keys = sort keys %used_pfx;
2210 if (scalar @keys == 0)
2212 &define_variable ($one_file . "_SOURCES", $unxformed . ".c");
2213 push (@sources, $unxformed . '.c');
2214 push (@dist_sources, $unxformed . '.c');
2218 &handle_single_transform_list ($one_file . '_SOURCES',
2219 $one_file . '_SOURCES',
2222 $linker ||= &resolve_linker (%linkers_used);
2223 define_pretty_variable ($one_file . "_OBJECTS", '', @result)
2227 grep ($_ = '$(' . $_ . $one_file . '_OBJECTS)', @keys);
2228 define_pretty_variable ($one_file . '_OBJECTS', '', @keys);
2231 # If we want to use `LINK' we must make sure it is defined.
2241 # handle_lib_objects ($XNAME, $VAR)
2242 # ---------------------------------
2243 # Special-case @ALLOCA@ and @LIBOBJS@ in _LDADD or _LIBADD variables.
2244 # Also, generate _DEPENDENCIES variable if appropriate.
2246 # transformed name of object being built, or empty string if no object
2247 # name of _LDADD/_LIBADD-type variable to examine
2248 # Returns 1 if LIBOBJS seen, 0 otherwise.
2249 sub handle_lib_objects
2251 my ($xname, $var) = @_;
2253 &prog_error ("handle_lib_objects: $var undefined")
2254 if ! &variable_defined ($var);
2257 foreach my $cond (variable_conditions_recursive ($var))
2259 if (&handle_lib_objects_cond ($xname, $var, $cond))
2267 # Subroutine of handle_lib_objects: handle a particular condition.
2268 sub handle_lib_objects_cond
2270 my ($xname, $var, $cond) = @_;
2272 # We recognize certain things that are commonly put in LIBADD or
2276 my $seen_libobjs = 0;
2279 foreach my $lsearch (&variable_value_as_list_recursive ($var, $cond))
2281 # Skip -lfoo and -Ldir; these are explicitly allowed.
2282 next if $lsearch =~ /^-[lL]/;
2283 if (! $flagvar && $lsearch =~ /^-/)
2285 if ($var =~ /^(.*)LDADD$/)
2287 # Skip -dlopen and -dlpreopen; these are explicitly allowed.
2288 next if $lsearch =~ /^-dl(pre)?open$/;
2289 &am_line_error ($var, "linker flags such as `$lsearch' belong in `${1}LDFLAGS");
2293 # Only get this error once.
2295 &am_line_error ($var, "linker flags such as `$lsearch' belong in `${1}LDFLAGS");
2299 # Assume we have a file of some sort, and push it onto the
2300 # dependency list. Autoconf substitutions are not pushed;
2301 # rarely is a new dependency substituted into (eg) foo_LDADD
2302 # -- but "bad things (eg -lX11) are routinely substituted.
2303 # Note that LIBOBJS and ALLOCA are exceptions to this rule,
2304 # and handled specially below.
2305 push (@dep_list, $lsearch)
2306 unless $lsearch =~ /^\@.*\@$/;
2308 # Automatically handle @LIBOBJS@ and @ALLOCA@. Basically this
2309 # means adding entries to dep_files.
2310 if ($lsearch =~ /^\@(LT)?LIBOBJS\@$/)
2312 my $lt = $1 ? $1 : '';
2313 my $myobjext = ($1 ? 'l' : '') . 'o';
2315 push (@dep_list, $lsearch);
2317 if (! keys %libsources
2318 && ! &variable_defined ($lt . 'LIBOBJS'))
2320 &am_line_error ($var, "\@$lt" . "LIBOBJS\@ seen but never set in `$configure_ac'");
2323 foreach my $iter (keys %libsources)
2325 if ($iter =~ /\.([cly])$/)
2327 &saw_extension ($1);
2328 &saw_extension ('c');
2331 if ($iter =~ /\.h$/)
2333 &require_file_with_line ($var, $FOREIGN, $iter);
2335 elsif ($iter ne 'alloca.c')
2337 my $rewrite = $iter;
2338 $rewrite =~ s/\.c$/.P$myobjext/;
2339 $dep_files{'$(DEPDIR)/' . $rewrite} = 1;
2340 ($rewrite = $iter) =~ s/(\W)/\\$1/g;
2341 $rewrite = "^" . $rewrite . "\$";
2342 # Only require the file if it is not a built source.
2343 if (! &variable_defined ('BUILT_SOURCES')
2344 || ! grep (/$rewrite/,
2345 &variable_value_as_list_recursive (
2346 'BUILT_SOURCES', 'all')))
2348 &require_file_with_line ($var, $FOREIGN, $iter);
2353 elsif ($lsearch =~ /^\@(LT)?ALLOCA\@$/)
2355 my $lt = $1 ? $1 : '';
2356 my $myobjext = ($1 ? 'l' : '') . 'o';
2358 push (@dep_list, $lsearch);
2359 &am_line_error ($var,
2360 "\@$lt" . "ALLOCA\@ seen but `AC_FUNC_ALLOCA' not in `$configure_ac'")
2361 if ! defined $libsources{'alloca.c'};
2362 $dep_files{'$(DEPDIR)/alloca.P' . $myobjext} = 1;
2363 &require_file_with_line ($var, $FOREIGN, 'alloca.c');
2364 &saw_extension ('c');
2368 if ($xname ne '' && ! &variable_defined ($xname . '_DEPENDENCIES', $cond))
2370 define_pretty_variable ($xname . '_DEPENDENCIES', $cond, @dep_list);
2373 return $seen_libobjs;
2376 # Canonicalize the input parameter
2380 $string =~ tr/A-Za-z0-9_\@/_/c;
2384 # Canonicalize a name, and check to make sure the non-canonical name
2385 # is never used. Returns canonical name. Arguments are name and a
2386 # list of suffixes to check for.
2387 sub check_canonical_spelling
2389 my ($name, @suffixes) = @_;
2391 my $xname = &canonicalize ($name);
2392 if ($xname ne $name)
2394 foreach my $xt (@suffixes)
2396 &am_line_error ("$name$xt",
2397 "invalid variable `$name$xt'; "
2398 . "should be `$xname$xt'")
2399 if &variable_defined ("$name$xt");
2409 # Set up the compile suite.
2410 sub handle_compile ()
2413 unless $get_object_extension_was_run;
2416 my $default_includes = '';
2417 if (! defined $options{'nostdinc'})
2419 $default_includes = ' -I. -I$(srcdir)';
2421 if (&variable_defined ('CONFIG_HEADER'))
2423 foreach my $hdr (split (' ', &variable_value ('CONFIG_HEADER')))
2425 $default_includes .= ' -I' . dirname ($hdr);
2430 my (@mostly_rms, @dist_rms);
2431 foreach my $item (sort keys %compile_clean_files)
2433 if ($compile_clean_files{$item} == $MOSTLY_CLEAN)
2435 push (@mostly_rms, "\t-rm -f $item");
2437 elsif ($compile_clean_files{$item} == $DIST_CLEAN)
2439 push (@dist_rms, "\t-rm -f $item");
2443 &prog_error ("invalid entry in \%compile_clean_files");
2447 my ($coms, $vars, $rules) =
2448 &file_contents_internal (1, "$libdir/am/compile.am",
2449 ('DEFAULT_INCLUDES' => $default_includes,
2450 'MOSTLYRMS' => join ("\n", @mostly_rms),
2451 'DISTRMS' => join ("\n", @dist_rms)));
2452 $output_vars .= $vars;
2453 $output_rules .= "$coms$rules";
2455 # Check for automatic de-ANSI-fication.
2456 if (defined $options{'ansi2knr'})
2458 if (! $am_c_prototypes)
2460 &am_line_error ('AUTOMAKE_OPTIONS',
2461 "option `ansi2knr' in use but `AM_C_PROTOTYPES' not in `$configure_ac'");
2462 &keyed_aclocal_warning ('AM_C_PROTOTYPES');
2463 # Only give this error once.
2464 $am_c_prototypes = 1;
2467 # topdir is where ansi2knr should be.
2468 if ($options{'ansi2knr'} eq 'ansi2knr')
2470 # Only require ansi2knr files if they should appear in
2472 &require_file_with_line ('AUTOMAKE_OPTIONS', $FOREIGN,
2473 'ansi2knr.c', 'ansi2knr.1');
2475 # ansi2knr needs to be built before subdirs, so unshift it.
2476 unshift (@all, '$(ANSI2KNR)');
2479 my $ansi2knr_dir = '';
2480 $ansi2knr_dir = dirname ($options{'ansi2knr'})
2481 if $options{'ansi2knr'} ne 'ansi2knr';
2483 $output_rules .= &file_contents ('ansi2knr',
2484 ('ANSI2KNR-DIR' => $ansi2knr_dir));
2491 # Handle libtool rules.
2494 return unless $seen_libtool;
2496 # libtool requires some files, but only at top level.
2497 &require_conf_file_with_conf_line ($libtool_line, $FOREIGN,
2499 if $relative_dir eq '.';
2501 # Output the libtool compilation rules.
2502 $output_rules .= &file_contents ('libtool');
2505 # handle_programs ()
2506 # ------------------
2507 # Handle C programs.
2510 my @proglist = &am_install_var ('progs', 'PROGRAMS',
2511 'bin', 'sbin', 'libexec', 'pkglib',
2513 return if ! @proglist;
2515 my $seen_libobjs = 0;
2516 foreach my $one_file (@proglist)
2518 my $obj = &get_object_extension ($one_file);
2520 # Canonicalize names and check for misspellings.
2521 my $xname = &check_canonical_spelling ($one_file, '_LDADD', '_LDFLAGS',
2522 '_SOURCES', '_OBJECTS',
2525 my $linker = &handle_source_transform ($xname, $one_file, $obj);
2528 if (&variable_defined ($xname . "_LDADD"))
2530 if (&handle_lib_objects ($xname, $xname . '_LDADD'))
2538 # User didn't define prog_LDADD override. So do it.
2539 &define_variable ($xname . '_LDADD', '$(LDADD)');
2541 # This does a bit too much work. But we need it to
2542 # generate _DEPENDENCIES when appropriate.
2543 if (&variable_defined ('LDADD'))
2545 if (&handle_lib_objects ($xname, 'LDADD'))
2550 elsif (! &variable_defined ($xname . '_DEPENDENCIES'))
2552 &define_variable ($xname . '_DEPENDENCIES', '');
2557 if (&variable_defined ($xname . '_LIBADD'))
2559 &am_line_error ($xname . '_LIBADD',
2560 "use `" . $xname . "_LDADD', not `"
2561 . $xname . "_LIBADD'");
2564 if (! &variable_defined ($xname . '_LDFLAGS'))
2566 # Define the prog_LDFLAGS variable.
2567 &define_variable ($xname . '_LDFLAGS', '');
2570 # Determine program to use for link.
2572 if (&variable_defined ($xname . '_LINK'))
2574 $xlink = $xname . '_LINK';
2578 $xlink = $linker ? $linker : 'LINK';
2581 # If the resulting program lies into a subdirectory,
2582 # make sure this directory will exist.
2583 my $dirstamp = &require_build_directory_maybe ($one_file);
2585 # Don't add $(EXEEXT) if user already did.
2586 my $extension = ($one_file !~ /\$\(EXEEXT\)$/
2590 $output_rules .= &file_contents ('program',
2591 ('PROGRAM' => $one_file,
2592 'XPROGRAM' => $xname,
2594 'DIRSTAMP' => $dirstamp,
2595 'EXEEXT' => $extension));
2598 if (&variable_defined ('LDADD') && &handle_lib_objects ('', 'LDADD'))
2605 foreach my $one_file (@proglist)
2607 my $xname = &canonicalize ($one_file);
2609 if (&variable_defined ($xname . '_LDADD'))
2611 &check_libobjs_sources ($xname, $xname . '_LDADD');
2613 elsif (&variable_defined ('LDADD'))
2615 &check_libobjs_sources ($xname, 'LDADD');
2622 # handle_libraries ()
2623 # -------------------
2625 sub handle_libraries
2627 my @liblist = &am_install_var ('libs', 'LIBRARIES',
2628 'lib', 'pkglib', 'noinst', 'check');
2629 return if ! @liblist;
2631 my %valid = &am_primary_prefixes ('LIBRARIES', 0, 'lib', 'pkglib',
2633 if (! defined $configure_vars{'RANLIB'})
2635 foreach my $key (keys %valid)
2637 if (&variable_defined ($key . '_LIBRARIES'))
2639 &am_line_error ($key . '_LIBRARIES', "library used but `RANLIB' not defined in `$configure_ac'");
2640 # Only get this error once. If this is ever printed,
2642 $configure_vars{'RANLIB'} = 'BUG';
2648 my $seen_libobjs = 0;
2649 foreach my $onelib (@liblist)
2651 # Check that the library fits the standard naming convention.
2652 if (basename ($onelib) !~ /^lib.*\.a/)
2654 # FIXME should put line number here. That means mapping
2655 # from library name back to variable name.
2656 &am_error ("`$onelib' is not a standard library name");
2659 my $obj = &get_object_extension ($onelib);
2661 # Canonicalize names and check for misspellings.
2662 my $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_SOURCES',
2663 '_OBJECTS', '_DEPENDENCIES',
2666 if (! &variable_defined ($xlib . '_AR'))
2668 &define_variable ($xlib . '_AR', '$(AR) cru');
2671 if (&variable_defined ($xlib . '_LIBADD'))
2673 if (&handle_lib_objects ($xlib, $xlib . '_LIBADD'))
2680 # Generate support for conditional object inclusion in
2682 &define_variable ($xlib . "_LIBADD", '');
2685 if (&variable_defined ($xlib . '_LDADD'))
2687 &am_line_error ($xlib . '_LDADD',
2688 "use `" . $xlib . "_LIBADD', not `"
2689 . $xlib . "_LDADD'");
2692 # Make sure we at look at this.
2693 &examine_variable ($xlib . '_DEPENDENCIES');
2695 &handle_source_transform ($xlib, $onelib, $obj);
2697 # If the resulting library lies into a subdirectory,
2698 # make sure this directory will exist.
2699 my $dirstamp = &require_build_directory_maybe ($onelib);
2701 $output_rules .= &file_contents ('library',
2702 ('LIBRARY' => $onelib,
2703 'XLIBRARY' => $xlib,
2704 'DIRSTAMP' => $dirstamp));
2709 foreach my $onelib (@liblist)
2711 my $xlib = &canonicalize ($onelib);
2712 if (&variable_defined ($xlib . '_LIBADD'))
2714 &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
2721 # handle_ltlibraries ()
2722 # ---------------------
2723 # Handle shared libraries.
2724 sub handle_ltlibraries
2726 my @liblist = &am_install_var ('ltlib', 'LTLIBRARIES',
2727 'noinst', 'lib', 'pkglib', 'check');
2728 return if ! @liblist;
2731 my %valid = &am_primary_prefixes ('LTLIBRARIES', 0, 'lib', 'pkglib',
2734 foreach my $key (keys %valid)
2736 if (&variable_defined ($key . '_LTLIBRARIES'))
2740 &am_line_error ($key . '_LTLIBRARIES', "library used but `LIBTOOL' not defined in `$configure_ac'");
2741 # Only get this error once. If this is ever printed,
2743 $configure_vars{'LIBTOOL'} = 'BUG';
2747 # Get the installation directory of each library.
2748 for (&variable_value_as_list_recursive ($key . '_LTLIBRARIES', 'all'))
2752 &am_error ("`$_' is already going to be installed in `$instdirs{$_}'");
2756 $instdirs{$_} = $key;
2762 my $seen_libobjs = 0;
2763 foreach my $onelib (@liblist)
2765 my $obj = &get_object_extension ($onelib);
2767 # Canonicalize names and check for misspellings.
2768 my $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_LDFLAGS',
2769 '_SOURCES', '_OBJECTS',
2772 if (! &variable_defined ($xlib . '_LDFLAGS'))
2774 # Define the lib_LDFLAGS variable.
2775 &define_variable ($xlib . '_LDFLAGS', '');
2778 # Check that the library fits the standard naming convention.
2779 my $libname_rx = "^lib.*\.la";
2780 if ((&variable_defined ($xlib . '_LDFLAGS')
2781 && grep (/-module/, &variable_value_as_list_recursive (
2782 $xlib . '_LDFLAGS', 'all')))
2783 || (&variable_defined ('LDFLAGS')
2784 && grep (/-module/, &variable_value_as_list_recursive (
2785 'LDFLAGS', 'all'))))
2787 # Relax name checking for libtool modules.
2788 $libname_rx = "\.la";
2790 if (basename ($onelib) !~ /$libname_rx$/)
2792 # FIXME this should only be a warning for foreign packages
2793 # FIXME should put line number here. That means mapping
2794 # from library name back to variable name.
2795 &am_error ("`$onelib' is not a standard libtool library name");
2798 if (&variable_defined ($xlib . '_LIBADD'))
2800 if (&handle_lib_objects ($xlib, $xlib . '_LIBADD'))
2807 # Generate support for conditional object inclusion in
2809 &define_variable ($xlib . "_LIBADD", '');
2812 if (&variable_defined ($xlib . '_LDADD'))
2814 &am_line_error ($xlib . '_LDADD',
2815 "use `" . $xlib . "_LIBADD', not `"
2816 . $xlib . "_LDADD'");
2819 # Make sure we at look at this.
2820 &examine_variable ($xlib . '_DEPENDENCIES');
2822 my $linker = &handle_source_transform ($xlib, $onelib, $obj);
2824 # Determine program to use for link.
2826 if (&variable_defined ($xlib . '_LINK'))
2828 $xlink = $xlib . '_LINK';
2832 $xlink = $linker ? $linker : 'LINK';
2836 if ($instdirs{$onelib} eq 'EXTRA'
2837 || $instdirs{$onelib} eq 'noinst'
2838 || $instdirs{$onelib} eq 'check')
2840 # It's an EXTRA_ library, so we can't specify -rpath,
2841 # because we don't know where the library will end up.
2842 # The user probably knows, but generally speaking automake
2843 # doesn't -- and in fact configure could decide
2844 # dynamically between two different locations.
2849 $rpath = ('-rpath $(' . $instdirs{$onelib} . 'dir)');
2852 # If the resulting library lies into a subdirectory,
2853 # make sure this directory will exist.
2854 my $dirstamp = &require_build_directory_maybe ($onelib);
2856 $output_rules .= &file_contents ('ltlibrary',
2857 ('LTLIBRARY' => $onelib,
2858 'XLTLIBRARY' => $xlib,
2861 'DIRSTAMP' => $dirstamp));
2866 foreach my $onelib (@liblist)
2868 my $xlib = &canonicalize ($onelib);
2869 if (&variable_defined ($xlib . '_LIBADD'))
2871 &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
2877 # See if any _SOURCES variable were misspelled. Also, make sure that
2878 # EXTRA_ variables don't contain configure substitutions.
2881 foreach my $varname (keys %var_value)
2883 foreach my $primary ('_SOURCES', '_LIBADD', '_LDADD', '_LDFLAGS',
2886 if ($varname =~ /$primary$/ && ! $content_seen{$varname})
2888 &am_line_error ($varname,
2889 "invalid unused variable name: `$varname'");
2898 # NOTE we no longer automatically clean SCRIPTS, because it is
2899 # useful to sometimes distribute scripts verbatim. This happens
2900 # eg in Automake itself.
2901 &am_install_var ('-candist', 'scripts', 'SCRIPTS',
2902 'bin', 'sbin', 'libexec', 'pkgdata',
2907 # ($OUTFILE, $VFILE, @CLEAN_FILES)
2908 # &scan_texinfo_file ($FILENAME)
2909 # ------------------------------
2910 # $OUTFILE is the name of the info file produced by $FILENAME.
2911 # $VFILE is the name of the version.texi file used (empty if none).
2912 # @CLEAN_FILES is the list of by products (indexes etc.)
2913 sub scan_texinfo_file
2915 my ($filename) = @_;
2917 # These are always created, no matter whether indexes are used or not.
2918 my @clean_suffixes = ('aux', 'dvi', 'log', 'ps', 'toc',
2919 # grep new.*index texinfo.tex
2920 'cp', 'fn', 'ky', 'vr', 'tp', 'pg');
2922 # There are predefined indexes which don't follow the regular rules.
2923 my %predefined_index =
2926 'c' => 'cps', 'f' => 'fns', 'k' => 'kys',
2927 'v' => 'vrs', 't' => 'tps', 'p' => 'pgs'
2930 # There are commands which include a hidden index command.
2934 'fn' => 'fns', 'un' => 'fns',
2935 'typefn' => 'fns', 'typefun' => 'fns',
2936 'mac' => 'fns', 'spec' => 'fns',
2937 'op' => 'fns', 'typeop' => 'fns',
2938 'method' => 'fns', 'typemethod' => 'fns',
2940 'vr' => 'vrs', 'var' => 'vrs',
2941 'typevr' => 'vrs', 'typevar' => 'vrs',
2944 'ivar' => 'vrs', 'typeivar' => 'vrs',
2949 # Indexes stored into another one. In this case, the *.??s file
2951 my @syncodeindexes = ();
2953 my $texi = new IO::File ("< $filename");
2956 &am_error ("couldn't open `$filename': $!");
2959 print "$me: reading $filename\n" if $verbose;
2961 my ($outfile, $vfile);
2962 while ($_ = $texi->getline)
2964 if (/^\@setfilename +(\S+)/)
2967 if ($outfile =~ /\.(.+)$/ && $1 ne 'info')
2969 &am_file_error ($filename, "$.: ",
2970 "output `$outfile' has unrecognized extension");
2974 # A "version.texi" file is actually any file whose name
2975 # matches "vers*.texi".
2976 elsif (/^\@include\s+(vers[^.]*\.texi)\s*$/)
2981 # Try to find what are the indexes which are used.
2983 # Creating a new category of index.
2984 elsif (/^\@def(code)?index (\w+)/)
2986 push @clean_suffixes, $2;
2989 # Storing in a predefined index.
2990 elsif (/^\@([cfkvtp])index /)
2992 push @clean_suffixes, $predefined_index{$1};
2994 elsif (/^\@def(\w+) /)
2996 push @clean_suffixes, $hidden_index{$1}
2997 if defined $hidden_index{$1};
3000 # Merging an index into an another.
3001 elsif (/^\@syn(code)?index (\w+) (\w+)/)
3003 push @syncodeindexes, "$2s";
3004 push @clean_suffixes, "$3s";
3012 &am_error ("`$filename' missing \@setfilename");
3016 my $infobase = basename ($filename);
3017 $infobase =~ s/\.te?xi(nfo)?$//;
3018 # FIXME: I don't understand why, but I can't use "$infobase.$_" => 1.
3019 my %clean_files = map { "$infobase" . ".$_" => 1 } @clean_suffixes;
3020 grep { delete $clean_files{"$infobase.$_"} } @syncodeindexes;
3021 return ($outfile, $vfile, (sort keys %clean_files));
3025 # ($DO-SOMETHING, $TEXICLEANS)
3026 # handle_texinfo_helper ()
3028 # Handle all Texinfo source; helper for handle_texinfo
3029 sub handle_texinfo_helper
3031 &am_line_error ('TEXINFOS',
3032 "`TEXINFOS' is an anachronism; use `info_TEXINFOS'")
3033 if &variable_defined ('TEXINFOS');
3034 return (0, '') if (! &variable_defined ('info_TEXINFOS')
3035 && ! &variable_defined ('html_TEXINFOS'));
3037 if (&variable_defined ('html_TEXINFOS'))
3039 &am_line_error ('html_TEXINFOS',
3040 "HTML generation not yet supported");
3044 my @texis = &variable_value_as_list_recursive ('info_TEXINFOS', 'all');
3046 my (@info_deps_list, @dvis_list, @texi_deps);
3053 foreach my $info_cursor (@texis)
3055 my $infobase = $info_cursor;
3056 $infobase =~ s/\.(txi|texinfo|texi)$//;
3058 if ($infobase eq $info_cursor)
3060 # FIXME: report line number.
3061 &am_error ("texinfo file `$info_cursor' has unrecognized extension");
3064 $texi_suffixes{$1} = 1;
3066 # If 'version.texi' is referenced by input file, then include
3067 # automatic versioning capability.
3068 my ($out_file, $vtexi, @clean_files) =
3069 &scan_texinfo_file ("$relative_dir/$info_cursor")
3071 push (@texi_cleans, @clean_files);
3075 &am_error ("`$vtexi', included in `$info_cursor', also included in `$versions{$vtexi}'")
3076 if (defined $versions{$vtexi});
3077 $versions{$vtexi} = $info_cursor;
3079 # We number the stamp-vti files. This is doable since the
3080 # actual names don't matter much. We only number starting
3081 # with the second one, so that the common case looks nice.
3082 my $vti = ($done ? $done : 'vti');
3085 # This is ugly, but it is our historical practice.
3086 if ($config_aux_dir_set_in_configure_in)
3088 &require_conf_file_with_line ('info_TEXINFOS', $FOREIGN,
3093 &require_file_with_line ('info_TEXINFOS', $FOREIGN,
3098 if ($config_aux_dir_set_in_configure_in)
3100 $conf_dir = $config_aux_dir;
3101 $conf_dir .= '/' unless $conf_dir =~ /\/$/;
3105 $conf_dir = '$(srcdir)/';
3107 $output_rules .= &file_contents ('texi-vers',
3108 ('TEXI' => $info_cursor,
3111 'MDDIR' => $conf_dir));
3114 # If user specified file_TEXINFOS, then use that as explicit
3117 push (@texi_deps, $info_cursor);
3118 # Prefix with $(srcdir) because some version of make won't
3119 # work if the target has it and the dependency doesn't.
3120 push (@texi_deps, '$(srcdir)/' . $vtexi) if $vtexi;
3122 my $canonical = &canonicalize ($infobase);
3123 if (&variable_defined ($canonical . "_TEXINFOS"))
3125 push (@texi_deps, '$(' . $canonical . '_TEXINFOS)');
3126 &push_dist_common ('$(' . $canonical . '_TEXINFOS)');
3129 $output_rules .= ("\n" . $out_file . ": "
3130 . join (' ', @texi_deps)
3131 . "\n" . $infobase . ".dvi: "
3132 . join (' ', @texi_deps)
3135 push (@info_deps_list, $out_file);
3136 push (@dvis_list, $infobase . '.dvi');
3139 # Handle location of texinfo.tex.
3140 my $need_texi_file = 0;
3144 $texinfodir = '$(top_srcdir)/../texinfo';
3145 &define_variable ('TEXINFO_TEX', "$texinfodir/texinfo.tex");
3147 elsif ($config_aux_dir_set_in_configure_in)
3149 $texinfodir = $config_aux_dir;
3150 &define_variable ('TEXINFO_TEX', "$texinfodir/texinfo.tex");
3151 $need_texi_file = 2; # so that we require_conf_file later
3153 elsif (&variable_defined ('TEXINFO_TEX'))
3155 # The user defined TEXINFO_TEX so assume he knows what he is
3157 $texinfodir = ('$(srcdir)/'
3158 . dirname (&variable_value ('TEXINFO_TEX')));
3162 $texinfodir = '$(srcdir)';
3163 $need_texi_file = 1;
3166 foreach my $txsfx (sort keys %texi_suffixes)
3168 $output_rules .= &file_contents ('texibuild',
3169 ('TEXINFODIR' => $texinfodir,
3170 'SUFFIX' => $txsfx));
3174 my $texiclean = &pretty_print_internal ("", "\t ", @texi_cleans);
3176 push (@dist_targets, 'dist-info');
3178 if (! defined $options{'no-installinfo'})
3180 # Make sure documentation is made and installed first. Use
3181 # $(INFO_DEPS), not 'info', because otherwise recursive makes
3182 # get run twice during "make all".
3183 unshift (@all, '$(INFO_DEPS)');
3186 &define_variable ("INFO_DEPS", join (' ', @info_deps_list));
3187 &define_variable ("DVIS", join (' ', @dvis_list));
3188 # This next isn't strictly needed now -- the places that look here
3189 # could easily be changed to look in info_TEXINFOS. But this is
3190 # probably better, in case noinst_TEXINFOS is ever supported.
3191 &define_variable ("TEXINFOS", &variable_value ('info_TEXINFOS'));
3193 # Do some error checking. Note that this file is not required
3194 # when in Cygnus mode; instead we defined TEXINFO_TEX explicitly
3196 if ($need_texi_file && ! defined $options{'no-texinfo.tex'})
3198 if ($need_texi_file > 1)
3200 &require_conf_file_with_line ('info_TEXINFOS', $FOREIGN,
3205 &require_file_with_line ('info_TEXINFOS', $FOREIGN, 'texinfo.tex');
3209 return (1, $texiclean);
3214 # Handle all Texinfo source.
3217 my ($do_something, $texiclean) = handle_texinfo_helper ();
3218 $output_rules .= &file_contents ('texinfos',
3219 ('TEXICLEAN' => $texiclean,
3220 'LOCAL-TEXIS' => $do_something));
3223 # Handle any man pages.
3224 sub handle_man_pages
3226 &am_line_error ('MANS', "`MANS' is an anachronism; use `man_MANS'")
3227 if &variable_defined ('MANS');
3229 # Find all the sections in use. We do this by first looking for
3230 # "standard" sections, and then looking for any additional
3231 # sections used in man_MANS.
3232 my (%sections, %vlist);
3233 # We handle nodist_ for uniformity. man pages aren't distributed
3234 # by default so it isn't actually very important.
3235 foreach my $pfx ('', 'dist_', 'nodist_')
3237 # Add more sections as needed.
3238 foreach my $section ('0'..'9', 'n', 'l')
3240 if (&variable_defined ($pfx . 'man' . $section . '_MANS'))
3242 $sections{$section} = 1;
3243 $vlist{'$(' . $pfx . 'man' . $section . '_MANS)'} = 1;
3245 &push_dist_common ('$(' . $pfx . 'man' . $section . '_MANS)')
3250 if (&variable_defined ($pfx . 'man_MANS'))
3252 $vlist{'$(' . $pfx . 'man_MANS)'} = 1;
3253 foreach (&variable_value_as_list_recursive ($pfx . 'man_MANS', 'all'))
3255 # A page like `foo.1c' goes into man1dir.
3256 if (/\.([0-9a-z])([a-z]*)$/)
3262 &push_dist_common ('$(' . $pfx . 'man_MANS)')
3267 return unless %sections;
3269 # Now for each section, generate an install and unintall rule.
3270 # Sort sections so output is deterministic.
3271 foreach my $section (sort keys %sections)
3273 $output_rules .= &file_contents ('mans', ('SECTION' => $section));
3276 $output_vars .= &file_contents ('mans-vars',
3277 ('MANS' => join (' ', sort keys %vlist)));
3279 if (! defined $options{'no-installman'})
3281 push (@all, '$(MANS)');
3285 # Handle DATA variables.
3288 &am_install_var ('-noextra', '-candist', 'data', 'DATA',
3289 'data', 'sysconf', 'sharedstate', 'localstate',
3290 'pkgdata', 'noinst', 'check');
3297 if (&variable_defined ('SUBDIRS'))
3299 $output_rules .= ("tags-recursive:\n"
3300 . "\tlist=\'\$(SUBDIRS)\'; for subdir in \$\$list; do \\\n"
3301 # Never fail here if a subdir fails; it
3303 . "\t test \"\$\$subdir\" = . || (cd \$\$subdir"
3304 . " && \$(MAKE) \$(AM_MAKEFLAGS) tags); \\\n"
3306 push (@tag_deps, 'tags-recursive');
3307 &depend ('.PHONY', 'tags-recursive');
3310 if (&saw_sources_p (1)
3311 || &variable_defined ('ETAGS_ARGS')
3315 foreach my $one_hdr (@config_headers)
3317 if ($relative_dir eq dirname ($one_hdr))
3319 # The config header is in this directory. So require it.
3320 $config .= ' ' if $config;
3321 $config .= basename ($one_hdr);
3324 $output_rules .= &file_contents ('tags',
3325 ('CONFIG' => $config,
3326 'DIRS' => join (' ', @tag_deps)));
3327 &examine_variable ('TAGS_DEPENDENCIES');
3329 elsif (&variable_defined ('TAGS_DEPENDENCIES'))
3331 &am_line_error ('TAGS_DEPENDENCIES',
3332 "doesn't make sense to define `TAGS_DEPENDENCIES' without sources or `ETAGS_ARGS'");
3336 # Every Makefile must define some sort of TAGS rule.
3337 # Otherwise, it would be possible for a top-level "make TAGS"
3338 # to fail because some subdirectory failed.
3339 $output_rules .= "tags: TAGS\nTAGS:\n\n";
3343 # Handle multilib support.
3346 if ($seen_multilib && $relative_dir eq '.')
3348 $output_rules .= &file_contents ('multilib');
3354 # &for_dist_common ($A, $B)
3355 # -------------------------
3356 # Subroutine for &handle_dist: sort files to dist.
3358 # We put README first because it then becomes easier to make a
3359 # Usenet-compliant shar file (in these, README must be first).
3361 # FIXME: do more ordering of files here.
3374 # handle_dist ($MAKEFILE)
3375 # -----------------------
3376 # Handle 'dist' target.
3379 my ($makefile) = @_;
3381 # `make dist' isn't used in a Cygnus-style tree.
3382 # Omit the rules so that people don't try to use them.
3383 return if $cygnus_mode;
3385 # Look for common files that should be included in distribution.
3386 # If the aux dir is set, and it does not have a Makefile.am, then
3387 # we check for these files there as well.
3390 if ($relative_dir eq '.'
3391 && $config_aux_dir_set_in_configure_in)
3393 ($auxdir = $config_aux_dir) =~ s,^\$\(top_srcdir\)/,,;
3394 if (! &is_make_dir ($auxdir))
3399 foreach my $cfile (@common_files)
3401 if (-f ($relative_dir . "/" . $cfile))
3403 &push_dist_common ($cfile);
3406 # Don't use `elsif' here because a file might meaningfully
3407 # appear in both directories.
3408 if ($check_aux && -f ($auxdir . '/' . $cfile))
3410 &push_dist_common ($auxdir . '/' . $cfile);
3414 # We might copy elements from $configure_dist_common to
3415 # %dist_common if we think we need to. If the file appears in our
3416 # directory, we would have discovered it already, so we don't
3417 # check that. But if the file is in a subdir without a Makefile,
3418 # we want to distribute it here if we are doing `.'. Ugly!
3419 if ($relative_dir eq '.')
3421 foreach my $file (split (' ' , $configure_dist_common))
3423 if (! &is_make_dir (dirname ($file)))
3425 &push_dist_common ($file);
3432 # Files to distributed. Don't use &variable_value_as_list_recursive
3433 # as it recursively expands `$(dist_pkgdata_DATA)' etc.
3434 check_variable_defined_unconditionally ('DIST_COMMON');
3435 my @dist_common = split (' ', variable_value ('DIST_COMMON', 'TRUE'));
3436 @dist_common = uniq (sort for_dist_common (@dist_common));
3437 pretty_print ('DIST_COMMON = ', "\t", @dist_common);
3439 # Now that we've processed DIST_COMMON, disallow further attempts
3441 $handle_dist_run = 1;
3443 # Scan EXTRA_DIST to see if we need to distribute anything from a
3444 # subdir. If so, add it to the list. I didn't want to do this
3445 # originally, but there were so many requests that I finally
3447 if (&variable_defined ('EXTRA_DIST'))
3449 # FIXME: This should be fixed to work with conditionals. That
3450 # will require only making the entries in %dist_dirs under the
3451 # appropriate condition. This is meaningful if the nature of
3452 # the distribution should depend upon the configure options
3454 foreach (&variable_value_as_list_recursive ('EXTRA_DIST', ''))
3457 next unless s,/+[^/]+$,,;
3463 # We have to check DIST_COMMON for extra directories in case the
3464 # user put a source used in AC_OUTPUT into a subdir.
3465 foreach (&variable_value_as_list_recursive ('DIST_COMMON', 'all'))
3468 next unless s,/+[^/]+$,,;
3473 # Rule to check whether a distribution is viable.
3474 my %transform = ('DISTCHECK-HOOK' => &target_defined ('distcheck-hook'),
3475 'GETTEXT' => $seen_gettext);
3477 # Prepend $(distdir) to each directory given.
3478 my %rewritten = map { '$(distdir)/' . "$_" => 1 } keys %dist_dirs;
3479 $transform{'DISTDIRS'} = join (' ', sort keys %rewritten);
3481 # If we have SUBDIRS, create all dist subdirectories and do
3483 if (&variable_defined ('SUBDIRS'))
3485 # If SUBDIRS is conditionally defined, then set DIST_SUBDIRS
3486 # to all possible directories, and use it. If DIST_SUBDIRS is
3487 # defined, just use it.
3488 my $dist_subdir_name;
3489 # Note that we check DIST_SUBDIRS first on purpose. At least
3490 # one project uses so many conditional subdirectories that
3491 # calling variable_conditionally_defined on SUBDIRS will cause
3492 # automake to grow to 150Mb. Sigh.
3493 if (&variable_defined ('DIST_SUBDIRS')
3494 || variable_conditionally_defined ('SUBDIRS'))
3496 $dist_subdir_name = 'DIST_SUBDIRS';
3497 if (! &variable_defined ('DIST_SUBDIRS'))
3499 define_pretty_variable
3500 ('DIST_SUBDIRS', '',
3501 uniq (&variable_value_as_list_recursive ('SUBDIRS', 'all')));
3506 $dist_subdir_name = 'SUBDIRS';
3507 # We always define this because that is what `distclean'
3509 define_pretty_variable ('DIST_SUBDIRS', '', '$(SUBDIRS)');
3512 $transform{'DIST_SUBDIR_NAME'} = $dist_subdir_name;
3515 # If the target `dist-hook' exists, make sure it is run. This
3516 # allows users to do random weird things to the distribution
3517 # before it is packaged up.
3518 push (@dist_targets, 'dist-hook')
3519 if &target_defined ('dist-hook');
3520 $transform{'DIST-TARGETS'} = join(' ', @dist_targets);
3522 # Defining $(DISTDIR).
3523 $transform{'DISTDIR'} = !&variable_defined('distdir');
3524 $transform{'TOP_DISTDIR'} = backname ($relative_dir);
3526 $output_rules .= &file_contents ('distdir', %transform);
3530 # Handle subdirectories.
3534 unless &variable_defined ('SUBDIRS');
3536 # Make sure each directory mentioned in SUBDIRS actually exists.
3537 foreach my $dir (&variable_value_as_list_recursive ('SUBDIRS', 'all'))
3539 # Skip directories substituted by configure.
3540 next if $dir =~ /^\@.*\@$/;
3542 if (! -d $am_relative_dir . '/' . $dir)
3544 &am_line_error ('SUBDIRS',
3545 "required directory $am_relative_dir/$dir does not exist");
3549 &am_line_error ('SUBDIRS', "directory should not contain `/'")
3553 $output_rules .= &file_contents ('subdirs');
3554 variable_pretty_output ('RECURSIVE_TARGETS', 'TRUE');
3558 # ($REGEN, @DEPENDENCIES)
3561 # If aclocal.m4 creation is automated, return the list of its dependencies.
3564 my $regen_aclocal = 0;
3567 unless $relative_dir eq '.';
3569 &examine_variable ('CONFIG_STATUS_DEPENDENCIES');
3570 &examine_variable ('CONFIGURE_DEPENDENCIES');
3572 if (-f 'aclocal.m4')
3574 &define_variable ("ACLOCAL_M4", '$(top_srcdir)/aclocal.m4');
3575 &push_dist_common ('aclocal.m4');
3577 my $aclocal = new IO::File ("< aclocal.m4");
3580 my $line = $aclocal->getline;
3583 if ($line =~ 'generated automatically by aclocal')
3592 if (-f 'acinclude.m4')
3595 push @ac_deps, 'acinclude.m4';
3598 if (&variable_defined ('ACLOCAL_M4_SOURCES'))
3600 push (@ac_deps, '$(ACLOCAL_M4_SOURCES)');
3602 elsif (&variable_defined ('ACLOCAL_AMFLAGS'))
3604 # Scan all -I directories for m4 files. These are our
3606 my $examine_next = 0;
3607 foreach my $amdir (&variable_value_as_list_recursive ('ACLOCAL_AMFLAGS', ''))
3612 if ($amdir !~ /^\// && -d $amdir)
3614 foreach my $ac_dep (&my_glob ($amdir . '/*.m4'))
3616 $ac_dep =~ s/^\.\/+//;
3617 push (@ac_deps, $ac_dep)
3618 unless $ac_dep eq "aclocal.m4"
3619 || $ac_dep eq "acinclude.m4";
3623 elsif ($amdir eq '-I')
3630 # Note that it might be possible that aclocal.m4 doesn't exist but
3631 # should be auto-generated. This case probably isn't very
3634 return ($regen_aclocal, @ac_deps);
3637 # Rewrite a list of input files into a form suitable to put on a
3638 # dependency list. The idea is that if an input file has a directory
3639 # part the same as the current directory, then the directory part is
3640 # simply removed. But if the directory part is different, then
3641 # $(top_srcdir) is prepended. Among other things, this is used to
3642 # generate the dependency list for the output files generated by
3643 # AC_OUTPUT. Consider what the dependencies should look like in this
3645 # AC_OUTPUT(src/out:src/in1:lib/in2)
3646 # The first argument, ADD_SRCDIR, is 1 if $(top_srcdir) should be added.
3647 # If 0 then files that require this addition will simply be ignored.
3648 sub rewrite_inputs_into_dependencies
3650 my ($add_srcdir, @inputs) = @_;
3653 foreach my $single (@inputs)
3655 if (dirname ($single) eq $relative_dir)
3657 push (@newinputs, basename ($single));
3661 push (@newinputs, '$(top_srcdir)/' . $single);
3668 # Handle remaking and configure stuff.
3669 # We need the name of the input file, to do proper remaking rules.
3670 sub handle_configure
3672 my ($local, $input, @secondary_inputs) = @_;
3674 my $input_base = basename ($input);
3675 my $local_base = basename ($local);
3677 my $amfile = $input_base . '.am';
3678 # We know we can always add '.in' because it really should be an
3679 # error if the .in was missing originally.
3680 my $infile = '$(srcdir)/' . $input_base . '.in';
3681 my $colon_infile = '';
3682 if ($local ne $input || @secondary_inputs)
3684 $colon_infile = ':' . $input . '.in';
3686 $colon_infile .= ':' . join (':', @secondary_inputs)
3687 if @secondary_inputs;
3689 my @rewritten = &rewrite_inputs_into_dependencies (1, @secondary_inputs);
3691 my ($regen_aclocal_m4, @aclocal_m4_deps) = scan_aclocal_m4 ();
3694 &file_contents ('configure',
3698 => join (' ', @rewritten),
3700 => ((($relative_dir eq '.') ? '$@' : '$(subdir)/$@')
3705 => join (' ', @include_stack),
3709 => $cygnus_mode ? 'cygnus' : $strictness_name,
3711 => $cmdline_use_dependencies ? '' : ' --ignore-deps',
3712 'MAKEFILE-AM-SOURCES'
3713 => "$input$colon_infile",
3715 => $regen_aclocal_m4,
3717 => join (' ', @aclocal_m4_deps)));
3719 if ($relative_dir eq '.')
3721 &push_dist_common ('acconfig.h')
3725 # If we have a configure header, require it.
3726 my @local_fullnames = @config_fullnames;
3727 my @local_names = @config_names;
3729 my $distclean_config = '';
3730 foreach my $one_hdr (@config_headers)
3732 my $one_fullname = shift (@local_fullnames);
3733 my $one_name = shift (@local_names);
3735 my $header_dir = dirname ($one_name);
3737 # If the header is in the current directory we want to build
3738 # the header here. Otherwise, if we're at the topmost
3739 # directory and the header's directory doesn't have a
3740 # Makefile, then we also want to build the header.
3741 if ($relative_dir eq $header_dir
3742 || ($relative_dir eq '.' && ! &is_make_dir ($header_dir)))
3744 my ($cn_sans_dir, $stamp_dir);
3745 if ($relative_dir eq $header_dir)
3747 $cn_sans_dir = basename ($one_name);
3752 $cn_sans_dir = $one_name;
3753 if ($header_dir eq '.')
3759 $stamp_dir = $header_dir . '/';
3763 # Compute relative path from directory holding output
3764 # header to directory holding input header. FIXME:
3765 # doesn't handle case where we have multiple inputs.
3767 if (dirname ($one_hdr) eq $relative_dir)
3769 $ch_sans_dir = basename ($one_hdr);
3773 $ch_sans_dir = backname ($relative_dir) . '/' . $one_hdr;
3776 &require_file_with_conf_line ($config_header_line,
3777 $FOREIGN, $ch_sans_dir);
3779 # Header defined and in this directory.
3781 if (-f $one_name . '.top')
3783 push (@files, "${cn_sans_dir}.top");
3785 if (-f $one_name . '.bot')
3787 push (@files, "${cn_sans_dir}.bot");
3790 &push_dist_common (@files);
3792 # For now, acconfig.h can only appear in the top srcdir.
3793 if (-f 'acconfig.h')
3795 push (@files, '$(top_srcdir)/acconfig.h');
3798 my $stamp_name = 'stamp-h';
3799 $stamp_name .= "${hdr_index}" if scalar (@config_headers) > 1;
3801 my $out_dir = dirname ($ch_sans_dir);
3804 &file_contents ('remake-hdr',
3805 ('FILES' => join (' ', @files),
3806 'CONFIG_HEADER' => $cn_sans_dir,
3807 'CONFIG_HEADER_IN' => $ch_sans_dir,
3808 'CONFIG_HEADER_FULL' => $one_fullname,
3809 'STAMP' => "$stamp_dir$stamp_name",
3810 'SRC_STAMP' => "$out_dir/$stamp_name"));
3812 &create ("${relative_dir}/${out_dir}/${stamp_name}.in");
3813 &require_file_with_conf_line ($config_header_line, $FOREIGN,
3814 "${out_dir}/${stamp_name}.in");
3816 $distclean_config .= ' ' if $distclean_config;
3817 $distclean_config .= $cn_sans_dir;
3821 if ($distclean_config)
3823 $output_rules .= &file_contents ('clean-hdr',
3824 ('FILES' => $distclean_config));
3827 # Set location of mkinstalldirs.
3828 &define_variable ('mkinstalldirs',
3829 ('$(SHELL) ' . $config_aux_dir . '/mkinstalldirs'));
3831 &am_line_error ('CONFIG_HEADER',
3832 "`CONFIG_HEADER' is an anachronism; now determined from `$configure_ac'")
3833 if &variable_defined ('CONFIG_HEADER');
3835 my $config_header = '';
3836 foreach my $one_name (@config_names)
3838 # Generate CONFIG_HEADER define.
3840 if ($relative_dir eq dirname ($one_name))
3842 $one_hdr = basename ($one_name);
3846 $one_hdr = "\$(top_builddir)/${one_name}";
3849 $config_header .= ' ' if $config_header;
3850 $config_header .= $one_hdr;
3854 &define_variable ("CONFIG_HEADER", $config_header);
3857 # Now look for other files in this directory which must be remade
3858 # by config.status, and generate rules for them.
3859 my @actual_other_files = ();
3860 foreach my $lfile (@other_input_files)
3863 my (@inputs, @rewritten_inputs);
3864 my ($need_rewritten);
3865 if ($lfile =~ /^([^:]*):(.*)$/)
3867 # This is the ":" syntax of AC_OUTPUT.
3869 $local = basename ($file);
3870 @inputs = split (':', $2);
3871 @rewritten_inputs = &rewrite_inputs_into_dependencies (1, @inputs);
3872 $need_rewritten = 1;
3878 $local = basename ($file);
3879 @inputs = ($file . '.in');
3881 &rewrite_inputs_into_dependencies (1, @inputs);
3882 $need_rewritten = 0;
3885 # Make sure the dist directory for each input file is created.
3886 # We only have to do this at the topmost level though. This
3887 # is a bit ugly but it easier than spreading out the logic,
3888 # especially in cases like AC_OUTPUT(foo/out:bar/in), where
3889 # there is no Makefile in bar/.
3890 if ($relative_dir eq '.')
3894 $dist_dirs{dirname ($_)} = 1;
3898 # We skip any automake input files, as they are handled
3899 # elsewhere. We also skip files that aren't in this
3900 # directory. However, if the file's directory does not have a
3901 # Makefile, and we are currently doing `.', then we create a
3902 # rule to rebuild the file in the subdir.
3903 next if -f $file . '.am';
3904 my $fd = dirname ($file);
3905 if ($fd ne $relative_dir)
3907 if ($relative_dir eq '.' && ! &is_make_dir ($fd))
3917 # Some users have been tempted to put `stamp-h' in the
3918 # AC_OUTPUT line. This won't do the right thing, so we
3919 # explicitly fail here.
3920 if ($local eq 'stamp-h')
3922 # FIXME: allow real filename.
3923 &am_conf_error ($configure_ac, $ac_output_line,
3924 'stamp-h should not appear in AC_OUTPUT');
3928 $output_rules .= ($local . ': '
3929 . '$(top_builddir)/config.status '
3930 . join (' ', @rewritten_inputs) . "\n"
3932 . 'cd $(top_builddir) && CONFIG_FILES='
3933 . ($relative_dir eq '.' ? '' : '$(subdir)/')
3934 . '$@' . ($need_rewritten
3935 ? (':' . join (':', @inputs))
3937 . ' CONFIG_HEADERS= CONFIG_LINKS= $(SHELL) ./config.status'
3939 push (@actual_other_files, $local);
3941 # Require all input files.
3942 &require_file_with_conf_line ($ac_output_line, $FOREIGN,
3943 &rewrite_inputs_into_dependencies (0, @inputs));
3946 # These files get removed by "make clean".
3947 define_pretty_variable ('CONFIG_CLEAN_FILES', '', @actual_other_files);
3953 my @r = &am_install_var ('-defaultdist', 'header', 'HEADERS', 'include',
3954 'oldinclude', 'pkginclude',
3958 next unless /\.(.*)$/;
3959 &saw_extension ($1);
3965 return if ! $seen_gettext || $relative_dir ne '.';
3967 if (! &variable_defined ('SUBDIRS'))
3970 ("AM_GNU_GETTEXT used but SUBDIRS not defined");
3974 my @subdirs = &variable_value_as_list_recursive ('SUBDIRS', 'all');
3975 &am_line_error ('SUBDIRS',
3976 "AM_GNU_GETTEXT used but `po' not in SUBDIRS")
3977 if ! grep ('po', @subdirs);
3978 &am_line_error ('SUBDIRS',
3979 "AM_GNU_GETTEXT used but `intl' not in SUBDIRS")
3980 if ! grep ('intl', @subdirs);
3982 &require_file_with_conf_line ($ac_gettext_line, $GNU, 'ABOUT-NLS');
3985 # Handle footer elements.
3988 # NOTE don't use define_pretty_variable here, because
3989 # $contents{...} is already defined.
3990 $output_vars .= 'SOURCES = ' . variable_value ('SOURCES') . "\n\n"
3991 if variable_value ('SOURCES');
3994 &am_line_error ('.SUFFIXES',
3995 "use variable `SUFFIXES', not target `.SUFFIXES'")
3996 if target_defined ('.SUFFIXES');
3998 # Note: AIX 4.1 /bin/make will fail if any suffix rule appears
3999 # before .SUFFIXES. So we make sure that .SUFFIXES appears before
4000 # anything else, by sticking it right after the default: target.
4001 $output_header .= ".SUFFIXES:\n";
4002 if (@suffixes || &variable_defined ('SUFFIXES'))
4004 # Make sure suffixes has unique elements. Sort them to ensure
4005 # the output remains consistent. However, $(SUFFIXES) is
4006 # always at the start of the list, unsorted. This is done
4007 # because make will choose rules depending on the ordering of
4008 # suffixes, and this lets the user have some control. Push
4009 # actual suffixes, and not $(SUFFIXES). Some versions of make
4010 # do not like variable substitutions on the .SUFFIXES line.
4011 my @user_suffixes = (&variable_defined ('SUFFIXES')
4012 ? &variable_value_as_list_recursive ('SUFFIXES', '')
4015 my %suffixes = map { $_ => 1 } @suffixes;
4016 delete @suffixes{@user_suffixes};
4018 $output_header .= (".SUFFIXES: "
4019 . join (' ', @user_suffixes, sort keys %suffixes)
4023 $output_trailer .= file_contents ('footer');
4026 # Deal with installdirs target.
4027 sub handle_installdirs ()
4030 &file_contents ('install',
4032 => variable_value ('_am_installdirs') || ''));
4036 # Deal with all and all-am.
4039 my ($makefile) = @_;
4043 # Put this at the beginning for the sake of non-GNU makes. This
4044 # is still wrong if these makes can run parallel jobs. But it is
4046 unshift (@all, basename ($makefile));
4048 foreach my $one_name (@config_names)
4050 push (@all, basename ($one_name))
4051 if dirname ($one_name) eq $relative_dir;
4054 # Install `all' hooks.
4055 if (&target_defined ("all-local"))
4057 push (@all, "all-local");
4058 &depend ('.PHONY', "all-local");
4061 &pretty_print_rule ("all-am:", "\t\t", @all);
4062 &depend ('.PHONY', 'all-am', 'all');
4067 my @local_headers = ();
4068 push @local_headers, '$(BUILT_SOURCES)'
4069 if &variable_defined ('BUILT_SOURCES');
4070 foreach my $one_name (@config_names)
4072 push @local_headers, basename ($one_name)
4073 if dirname ($one_name) eq $relative_dir;
4078 # We need to make sure config.h is built before we recurse.
4079 # We also want to make sure that built sources are built
4080 # before any ordinary `all' targets are run. We can't do this
4081 # by changing the order of dependencies to the "all" because
4082 # that breaks when using parallel makes. Instead we handle
4083 # things explicitly.
4084 $output_all .= ("all: " . join (' ', @local_headers)
4086 . '$(MAKE) $(AM_MAKEFLAGS) '
4087 . (&variable_defined ('SUBDIRS')
4088 ? 'all-recursive' : 'all-am')
4093 $output_all .= "all: " . (&variable_defined ('SUBDIRS')
4094 ? 'all-recursive' : 'all-am') . "\n\n";
4099 # Handle check merge target specially.
4100 sub do_check_merge_target
4102 if (&target_defined ('check-local'))
4104 # User defined local form of target. So include it.
4105 push (@check_tests, 'check-local');
4106 &depend ('.PHONY', 'check-local');
4109 # In --cygnus mode, check doesn't depend on all.
4112 # Just run the local check rules.
4113 &pretty_print_rule ('check-am:', "\t\t", @check);
4117 # The check target must depend on the local equivalent of
4118 # `all', to ensure all the primary targets are built. Then it
4119 # must build the local check rules.
4120 $output_rules .= "check-am: all-am\n";
4121 &pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ",
4125 &pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ",
4129 &depend ('.PHONY', 'check', 'check-am');
4130 $output_rules .= ("check: "
4131 . (&variable_defined ('SUBDIRS')
4132 ? 'check-recursive' : 'check-am')
4136 # Handle all 'clean' targets.
4141 # Don't include `MAINTAINER'; it is handled specially below.
4142 foreach my $name ('MOSTLY', '', 'DIST')
4144 $transform{"${name}CLEAN"} = &variable_defined ("${name}CLEANFILES");
4147 # Built sources are automatically removed by maintainer-clean.
4148 push (@maintainer_clean_files, '$(BUILT_SOURCES)')
4149 if &variable_defined ('BUILT_SOURCES');
4150 push (@maintainer_clean_files, '$(MAINTAINERCLEANFILES)')
4151 if &variable_defined ('MAINTAINERCLEANFILES');
4153 $output_rules .= &file_contents ('clean',
4156 # Join with no space to avoid
4157 # spurious `test -z' success at
4159 => join ('', @maintainer_clean_files),
4161 # A space is required in the join here.
4162 => join (' ', @maintainer_clean_files)));
4166 # &depend ($CATEGORY, @DEPENDENDEES)
4167 # ----------------------------------
4168 # The target $CATEGORY depends on @DEPENDENDEES.
4171 my ($category, @dependendees) = @_;
4173 push (@{$dependencies{$category}}, @dependendees);
4178 # &target_cmp ($A, $B)
4179 # --------------------
4180 # Subroutine for &handle_factored_dependencies to let `.PHONY' be last.
4193 # &handle_factored_dependencies ()
4194 # --------------------------------
4195 # Handle everything related to gathered targets.
4196 sub handle_factored_dependencies
4199 foreach my $utarg ('uninstall-data-local', 'uninstall-data-hook',
4200 'uninstall-exec-local', 'uninstall-exec-hook')
4202 if (&target_defined ($utarg))
4205 $x =~ s/(data|exec)-//;
4206 &am_line_error ($utarg, "use `$x', not `$utarg'");
4210 if (&target_defined ('install-local'))
4212 &am_line_error ('install-local',
4213 "use `install-data-local' or `install-exec-local', "
4214 . "not `install-local'");
4217 if (!defined $options{'no-installinfo'}
4218 && &target_defined ('install-info-local'))
4220 &am_line_error ('install-info-local',
4221 "`install-info-local' target defined but "
4222 . "`no-installinfo' option not in use");
4225 # Install the -local hooks.
4226 foreach (keys %dependencies)
4228 # Hooks are installed on the -am targets.
4230 if (&target_defined ("$_-local"))
4232 depend ("$_-am", "$_-local");
4233 &depend ('.PHONY', "$_-local");
4237 # Install the -hook hooks.
4238 # FIXME: Why not be as liberal as we are with -local hooks?
4239 foreach ('install-exec', 'install-data')
4241 if (&target_defined ("$_-hook"))
4243 $actions{"$_-am"} .=
4244 ("\t\@\$(NORMAL_INSTALL)\n"
4245 . "\t" . '$(MAKE) $(AM_MAKEFLAGS) ' . "$_-hook\n");
4249 # All the required targets are phony.
4250 depend ('.PHONY', keys %required_targets);
4252 # Actually output gathered targets.
4253 foreach (sort target_cmp keys %dependencies)
4255 # If there is nothing about this guy, skip it.
4257 unless (@{$dependencies{$_}}
4259 || $required_targets{$_});
4260 &pretty_print_rule ("$_:", "\t",
4261 uniq (sort @{$dependencies{$_}}));
4262 $output_rules .= $actions{$_}
4263 if defined $actions{$_};
4264 $output_rules .= "\n";
4269 # &handle_tests_dejagnu ()
4270 # ------------------------
4271 sub handle_tests_dejagnu
4273 push (@check_tests, 'check-DEJAGNU');
4274 $output_rules .= file_contents ('dejagnu');
4278 # Handle TESTS variable and other checks.
4281 if (defined $options{'dejagnu'})
4283 &handle_tests_dejagnu;
4287 foreach my $c ('DEJATOOL', 'RUNTEST', 'RUNTESTFLAGS')
4290 "`$c' defined but `dejagnu' not in `AUTOMAKE_OPTIONS'")
4291 if &variable_defined ($c);
4295 if (&variable_defined ('TESTS'))
4297 push (@check_tests, 'check-TESTS');
4298 $output_rules .= &file_contents ('check');
4302 # Handle Emacs Lisp.
4303 sub handle_emacs_lisp
4305 my @elfiles = &am_install_var ('-candist', 'lisp', 'LISP',
4308 return if ! @elfiles;
4310 # Generate .elc files.
4311 my @elcfiles = map { $_ . 'c' } @elfiles;
4312 define_pretty_variable ('ELCFILES', '', @elcfiles);
4314 push (@all, '$(ELCFILES)');
4316 &am_error ("`lisp_LISP' defined but `AM_PATH_LISPDIR' not in `$configure_ac'")
4317 if ! $seen_lispdir && &variable_defined ('lisp_LISP');
4319 &require_conf_file_with_conf_line ('AM_PATH_LISPDIR',
4320 $FOREIGN, 'elisp-comp');
4321 &define_variable ('elisp_comp', $config_aux_dir . '/elisp-comp');
4327 my @pyfiles = &am_install_var ('-defaultdist', 'python', 'PYTHON',
4328 'python', 'noinst');
4329 return if ! @pyfiles;
4331 # Found some python.
4332 &am_error ("`python_PYTHON' defined but `AM_PATH_PYTHON' not in `$configure_ac'")
4333 if ! $seen_pythondir && &variable_defined ('python_PYTHON');
4335 &require_conf_file_with_conf_line ('AM_PATH_PYTHON',
4336 $FOREIGN, 'py-compile');
4337 &define_variable ('py_compile', $config_aux_dir . '/py-compile');
4343 my @sourcelist = &am_install_var ('-candist',
4345 'java', 'noinst', 'check');
4346 return if ! @sourcelist;
4348 my %valid = &am_primary_prefixes ('JAVA', 1,
4349 'java', 'noinst', 'check');
4352 foreach my $curs (keys %valid)
4354 if (! &variable_defined ($curs . '_JAVA') || $curs eq 'EXTRA')
4361 &am_line_error ($curs . '_JAVA',
4362 "multiple _JAVA primaries in use");
4367 push (@all, 'class' . $dir . '.stamp');
4371 # Handle some of the minor options.
4372 sub handle_minor_options
4374 if (defined $options{'readme-alpha'})
4376 if ($relative_dir eq '.')
4378 if ($package_version !~ /^$GNITS_VERSION_PATTERN$/)
4380 # FIXME: allow real filename.
4381 &am_conf_line_error ($configure_ac,
4382 $package_version_line,
4383 "version `$package_version' doesn't follow Gnits standards");
4385 elsif (defined $1 && -f 'README-alpha')
4387 # This means we have an alpha release. See
4388 # GNITS_VERSION_PATTERN for details.
4389 &require_file ($FOREIGN, 'README-alpha');
4395 ################################################################
4399 # &scan_autoconf_config_files ($CONFIG-FILES)
4400 # -------------------------------------------
4401 # Study $CONFIG-FILES which is the first argument to AC_CONFIG_FILES
4403 sub scan_autoconf_config_files
4405 my ($config_files) = @_;
4406 # Look at potential Makefile.am's.
4407 foreach (split ' ', $config_files)
4409 # Must skip empty string for Perl 4.
4410 next if $_ eq "\\" || $_ eq '';
4412 # Handle $local:$input syntax. Note that we ignore
4413 # every input file past the first, though we keep
4414 # those around for later.
4415 my ($local, $input, @rest) = split (/:/);
4422 # FIXME: should be error if .in is missing.
4423 $input =~ s/\.in$//;
4426 if (-f $input . '.am')
4428 # We have a file that automake should generate.
4429 $make_list{$input} = join (':', ($local, @rest));
4433 # We have a file that automake should cause to be
4434 # rebuilt, but shouldn't generate itself.
4435 push (@other_input_files, $_);
4441 # &scan_autoconf_traces ($FILENAME)
4442 # ---------------------------------
4443 # FIXME: For the time being, we don't care about the FILENAME.
4444 sub scan_autoconf_traces
4446 my ($filename) = @_;
4448 my $traces = "$ENV{amtraces} ";
4450 $traces .= ' -t AC_CONFIG_FILES';
4451 $traces .= ' -t AC_LIBSOURCE';
4452 $traces .= ' -t AC_SUBST';
4454 my $tracefh = new Automake::XFile ("$traces |");
4455 print "$me: reading $traces\n" if $verbose;
4457 while ($_ = $tracefh->getline)
4460 my ($file, $line, $macro, @args) = split /:/;
4461 my $here = "$file:$line";
4463 # Alphabetical ordering please.
4464 if ($macro eq 'AC_CONFIG_FILES')
4466 # Look at potential Makefile.am's.
4467 &scan_autoconf_config_files ($args[0]);
4469 elsif ($macro eq 'AC_LIBSOURCE')
4471 my $source = "$args[0].c";
4472 # We should actually also `close' the sources: getopt.c
4473 # wants getopt.h etc. But actually it should be done in the
4474 # macro itself, i.e., we have to first fix Autoconf to extend
4475 # _AC_LIBOBJ_DECL and use it the in various macros.
4476 if (!defined $libsources{$source})
4478 print STDERR "traces: discovered $source\n";
4479 $libsources{$source} = $here;
4482 elsif ($macro eq 'AC_SUBST')
4484 if (!defined $configure_vars{$args[0]})
4486 print STDERR "traces: discovered AC_SUBST($args[0])\n";
4487 $configure_vars{$args[0]} = $here;
4493 || die "$me: close: $traces: $!\n";
4497 # &scan_one_autoconf_file ($FILENAME)
4498 # -----------------------------------
4499 # Scan one file for interesting things. Subroutine of
4500 # &scan_autoconf_files.
4501 sub scan_one_autoconf_file
4503 my ($filename) = @_;
4505 my $configfh = new Automake::XFile ("< $filename");
4506 print "$me: reading $filename\n" if $verbose;
4508 my ($in_ac_output, $in_ac_replace) = (0, 0);
4509 while ($_ = $configfh->getline)
4511 # Remove comments from current line.
4515 # Skip macro definitions. Otherwise we might be confused into
4516 # thinking that a macro that was only defined was actually
4520 # Follow includes. This is a weirdness commonly in use at
4521 # Cygnus and hopefully nowhere else.
4522 if (/sinclude\((.*)\)/ && -f $1)
4524 # $_ being local, if we don't preserve it, when coming
4525 # back we will have $_ undefined, which is bad for the
4526 # the rest of this routine.
4527 my $underscore = $_;
4528 &scan_one_autoconf_file ($1);
4532 # Populate libobjs array.
4533 if (/AC_FUNC_ALLOCA/)
4535 $libsources{'alloca.c'} = 1;
4537 elsif (/AC_FUNC_GETLOADAVG/)
4539 $libsources{'getloadavg.c'} = 1;
4541 elsif (/AC_FUNC_MEMCMP/)
4543 $libsources{'memcmp.c'} = 1;
4545 elsif (/AC_STRUCT_ST_BLOCKS/)
4547 $libsources{'fileblocks.c'} = 1;
4549 elsif (/A[CM]_REPLACE_GNU_GETOPT/)
4551 $libsources{'getopt.c'} = 1;
4552 $libsources{'getopt1.c'} = 1;
4554 elsif (/A[CM]_FUNC_STRTOD/)
4556 $libsources{'strtod.c'} = 1;
4558 elsif (/AM_WITH_REGEX/)
4560 $libsources{'rx.c'} = 1;
4561 $libsources{'rx.h'} = 1;
4562 $libsources{'regex.c'} = 1;
4563 $libsources{'regex.h'} = 1;
4565 elsif (/AC_FUNC_MKTIME/)
4567 $libsources{'mktime.c'} = 1;
4569 elsif (/A[CM]_FUNC_ERROR_AT_LINE/)
4571 $libsources{'error.c'} = 1;
4572 $libsources{'error.h'} = 1;
4574 elsif (/A[CM]_FUNC_OBSTACK/)
4576 $libsources{'obstack.c'} = 1;
4577 $libsources{'obstack.h'} = 1;
4579 elsif (/LIBOBJS="(.*)\s+\$LIBOBJS"/
4580 || /LIBOBJS="\$LIBOBJS\s+(.*)"/)
4582 foreach my $libobj_iter (split (' ', $1))
4584 if ($libobj_iter =~ /^(.*)\.o(bj)?$/
4585 || $libobj_iter =~ /^(.*)\.\$ac_objext$/
4586 || $libobj_iter =~ /^(.*)\.\$\{ac_objext\}$/)
4588 $libsources{$1 . '.c'} = 1;
4592 elsif (/AC_LIBOBJ\(([^)]+)\)/)
4594 $libsources{"$1.c"} = 1;
4596 elsif (/AC_LIBSOURCE\(([^)]+)\)/)
4598 $libsources{&unquote_m4_arg ($1)} = 1;
4600 elsif (/AC_LIBSOURCES\(([^)]+)\)/)
4602 foreach my $lc_iter (split (/[, ]+/, &unquote_m4_arg ($1)))
4604 $libsources{$lc_iter} = 1;
4608 if (! $in_ac_replace && s/AC_REPLACE_FUNCS\s*\(\[?//)
4614 $in_ac_replace = 0 if s/[\]\)].*$//;
4615 # Remove trailing backslash.
4619 # Need to skip empty elements for Perl 4.
4621 $libsources{$_ . '.c'} = 1;
4625 if (/$obsolete_rx/o)
4628 if ($obsolete_macros{$1} ne '')
4630 $hint = '; ' . $obsolete_macros{$1};
4632 &am_conf_line_error ($filename, $., "`$1' is obsolete$hint");
4635 # Process the AC_OUTPUT and AC_CONFIG_FILES macros.
4636 if (! $in_ac_output && s/AC_(OUTPUT|CONFIG_FILES)\s*\(\[?//)
4639 $ac_output_line = $.;
4650 # Look at potential Makefile.am's.
4651 &scan_autoconf_config_files ($_);
4654 && scalar keys %make_list == 0
4655 && @other_input_files == 0)
4657 &am_conf_line_error ($filename, $ac_output_line,
4658 "No files mentioned in `AC_OUTPUT'");
4663 if (/$AC_CONFIG_AUX_DIR_PATTERN/o)
4665 @config_aux_path = &unquote_m4_arg ($1);
4666 $config_aux_dir_set_in_configure_in = 1;
4669 # Check for ansi2knr.
4670 $am_c_prototypes = 1 if /AM_C_PROTOTYPES/;
4672 # Check for `-c -o' code.
4673 $seen_cc_c_o = 1 if /AM_PROG_CC_C_O/;
4675 # Check for NLS support.
4676 if (/AM_GNU_GETTEXT/)
4679 $ac_gettext_line = $.;
4682 # Handle configuration headers. A config header of `[$1]'
4683 # means we are actually scanning AM_CONFIG_HEADER from
4685 if (/A([CM])_CONFIG_HEADERS?\s*\((.*)\)/
4689 ($filename, $., "`automake requires `AM_CONFIG_HEADER', not `AC_CONFIG_HEADER'")
4692 $config_header_line = $.;
4693 foreach my $one_hdr (split (' ', &unquote_m4_arg ($2)))
4695 push (@config_fullnames, $one_hdr);
4696 if ($one_hdr =~ /^([^:]+):(.+)$/)
4698 push (@config_names, $1);
4699 push (@config_headers, $2);
4703 push (@config_names, $one_hdr);
4704 push (@config_headers, $one_hdr . '.in');
4709 # Handle AC_CANONICAL_*. Always allow upgrading to
4710 # AC_CANONICAL_SYSTEM, but never downgrading.
4711 $seen_canonical = $AC_CANONICAL_HOST
4712 if ! $seen_canonical
4713 && (/AC_CANONICAL_HOST/ || /AC_CHECK_TOOL/);
4714 $seen_canonical = $AC_CANONICAL_SYSTEM if /AC_CANONICAL_SYSTEM/;
4716 # If using X, include some extra variable definitions. NOTE
4717 # we don't want to force these into CFLAGS or anything,
4718 # because not all programs will necessarily use X.
4721 foreach my $var ('X_CFLAGS', 'X_LIBS', 'X_EXTRA_LIBS',
4724 $configure_vars{$var} = $filename . ':' . $.
4728 # This macro handles several different things.
4729 if (/$AM_INIT_AUTOMAKE_PATTERN/o)
4731 ($package_version = $1) =~ s/$AM_PACKAGE_VERSION_PATTERN/$1/o;
4732 $package_version_line = $.;
4733 $seen_init_automake = 1;
4738 $configure_vars{'LEX'} = $filename . ':' . $.;
4739 $seen_decl_yytext = 1;
4741 if (/AC_DECL_YYTEXT/ && $filename =~ /configure\.(ac|in)$/)
4743 &am_conf_line_warning ($filename, $., "`AC_DECL_YYTEXT' is covered by `AM_PROG_LEX'");
4745 if (/AC_PROG_LEX/ && $filename =~ /configure\.(ac|in)$/)
4747 &am_conf_line_warning ($filename, $., "automake requires `AM_PROG_LEX', not `AC_PROG_LEX'");
4750 if (/AC_PROG_(F77|YACC|RANLIB|CC|CXXCPP|CXX|LEX|AWK|CPP|LN_S)/)
4752 $configure_vars{$1} = $filename . ':' . $.;
4754 if (/$AC_CHECK_PATTERN/o)
4756 $configure_vars{$3} = $filename . ':' . $.;
4758 if (/$AM_MISSING_PATTERN/o
4762 && $1 ne 'AUTOHEADER'
4763 # AM_INIT_AUTOMAKE is AM_MISSING_PROG'ing MAKEINFO. But
4764 # we handle it elsewhere.
4765 && $1 ne 'MAKEINFO')
4767 $configure_vars{$1} = $filename . ':' . $.;
4770 # Explicitly avoid ANSI2KNR -- we AC_SUBST that in protos.m4,
4771 # but later define it elsewhere. This is pretty hacky. We
4772 # also explicitly avoid INSTALL_SCRIPT and some other
4773 # variables because they are defined in header-vars.am.
4774 # AMDEPBACKSLASH might be subst'd by `\', which certainly would
4775 # not be appreciated by Make.
4776 if (/$AC_SUBST_PATTERN/o
4778 && $1 ne 'INSTALL_SCRIPT'
4779 && $1 ne 'INSTALL_DATA'
4780 && $1 ne 'AMDEPBACKSLASH')
4782 $configure_vars{$1} = $filename . ':' . $.;
4785 $seen_decl_yytext = 1 if /AC_DECL_YYTEXT/;
4786 if (/AM_MAINTAINER_MODE/)
4788 $seen_maint_mode = 1;
4789 $configure_cond{'MAINTAINER_MODE'} = 1;
4792 $seen_lispdir = 1 if /AM_PATH_LISPDIR/;
4794 if (/AM_PATH_PYTHON/)
4796 $seen_pythondir = 1;
4797 $configure_vars{'pythondir'} = $filename . ':' . $.;
4798 $configure_vars{'PYTHON'} = $filename . ':' . $.;
4801 if (/A(C|M)_PROG_LIBTOOL/)
4803 # We're not ready for this yet. People still use a
4804 # libtool with no AC_PROG_LIBTOOL. Once that is the
4805 # dominant version we can reenable this code -- but next
4806 # time by mentioning the macro in %obsolete_macros, both
4807 # here and in aclocal.in.
4809 # if (/AM_PROG_LIBTOOL/)
4811 # &am_conf_line_warning ($filename, $., "`AM_PROG_LIBTOOL' is obsolete, use `AC_PROG_LIBTOOL' instead");
4815 $configure_vars{'LIBTOOL'} = $filename . ':' . $.;
4816 $configure_vars{'RANLIB'} = $filename . ':' . $.;
4817 $configure_vars{'CC'} = $filename . ':' . $.;
4818 # AC_PROG_LIBTOOL runs AC_CANONICAL_HOST. Make sure we
4819 # never downgrade (if we've seen AC_CANONICAL_SYSTEM).
4820 $seen_canonical = $AC_CANONICAL_HOST if ! $seen_canonical;
4823 $seen_multilib = 1 if (/AM_ENABLE_MULTILIB/);
4825 if (/$AM_CONDITIONAL_PATTERN/o)
4827 $configure_cond{$1} = 1;
4830 # Check for Fortran 77 intrinsic and run-time libraries.
4831 if (/AC_F77_LIBRARY_LDFLAGS/)
4833 $configure_vars{'FLIBS'} = $filename . ':' . $.;
4841 # &scan_autoconf_files ()
4842 # -----------------------
4843 # Check whether we use `configure.ac' or `configure.in'.
4844 # Scan it (and possibly `aclocal.m4') for interesting things.
4845 # We must scan aclocal.m4 because there might be AC_SUBSTs and such there.
4846 sub scan_autoconf_files
4848 # Reinitialize libsources here. This isn't really necessary,
4849 # since we currently assume there is only one configure.ac. But
4850 # that won't always be the case.
4853 $configure_ac = find_configure_ac;
4854 die "$me: `configure.ac' or `configure.in' is required\n"
4857 &scan_one_autoconf_file ($configure_ac);
4858 &scan_one_autoconf_file ('aclocal.m4')
4861 if (defined $ENV{'amtraces'})
4863 warn '$me: Autoconf traces is an experimental feature';
4864 warn '$me: use at your own risks';
4866 &scan_autoconf_traces ($configure_ac);
4869 # Set input and output files if not specified by user.
4872 @input_files = sort keys %make_list;
4873 %output_files = %make_list;
4876 @configure_input_files = sort keys %make_list;
4878 &am_conf_error ("`AM_INIT_AUTOMAKE' must be used")
4879 if ! $seen_init_automake;
4881 # Look for some files we need. Always check for these. This
4882 # check must be done for every run, even those where we are only
4883 # looking at a subdir Makefile. We must set relative_dir so that
4884 # the file-finding machinery works.
4885 # FIXME: Is this broken because it needs dynamic scopes.
4886 # My tests seems to show it's not the case.
4887 $relative_dir = '.';
4888 &require_config_file ($FOREIGN, 'install-sh', 'mkinstalldirs', 'missing');
4889 &am_error ("`install.sh' is an anachronism; use `install-sh' instead")
4890 if -f $config_aux_path[0] . '/install.sh';
4892 &require_config_file ($FOREIGN, 'py-compile')
4895 # Preserve dist_common for later.
4896 $configure_dist_common = variable_value ('DIST_COMMON', 'TRUE') || '';
4899 ################################################################
4901 # Set up for Cygnus mode.
4904 return unless $cygnus_mode;
4906 &set_strictness ('foreign');
4907 $options{'no-installinfo'} = 1;
4908 $options{'no-dependencies'} = 1;
4909 $use_dependencies = 0;
4911 if (! $seen_maint_mode)
4913 &am_conf_error ("`AM_MAINTAINER_MODE' required when --cygnus specified");
4917 # Do any extra checking for GNU standards.
4918 sub check_gnu_standards
4920 if ($relative_dir eq '.')
4922 # In top level (or only) directory.
4923 &require_file ($GNU, 'INSTALL', 'NEWS', 'README', 'COPYING',
4924 'AUTHORS', 'ChangeLog');
4927 if ($strictness >= $GNU
4928 && defined $options{'no-installman'})
4930 &am_line_error ('AUTOMAKE_OPTIONS',
4931 "option `no-installman' disallowed by GNU standards");
4934 if ($strictness >= $GNU
4935 && defined $options{'no-installinfo'})
4937 &am_line_error ('AUTOMAKE_OPTIONS',
4938 "option `no-installinfo' disallowed by GNU standards");
4942 # Do any extra checking for GNITS standards.
4943 sub check_gnits_standards
4945 if ($relative_dir eq '.')
4947 # In top level (or only) directory.
4948 &require_file ($GNITS, 'THANKS');
4952 ################################################################
4954 # Functions to handle files of each language.
4956 # Each `lang_X_rewrite($DIRECTORY, $BASE, $EXT)' function follows a
4957 # simple formula: Return value is $LANG_SUBDIR if the resulting object
4958 # file should be in a subdir if the source file is, $LANG_PROCESS if
4959 # file is to be dealt with, $LANG_IGNORE otherwise.
4961 # Much of the actual processing is handled in
4962 # handle_single_transform_list. These functions exist so that
4963 # auxiliary information can be recorded for a later cleanup pass.
4964 # Note that the calls to these functions are computed, so don't bother
4965 # searching for their precise names in the source.
4967 # This is just a convenience function that can be used to determine
4968 # when a subdir object should be used.
4971 return defined $options{'subdir-objects'} ? $LANG_SUBDIR : $LANG_PROCESS;
4974 # Rewrite a single C source file.
4977 my ($directory, $base, $ext) = @_;
4979 if (defined $options{'ansi2knr'} && $base =~ /_$/)
4981 # FIXME: include line number in error.
4982 &am_error ("C source file `$base.c' would be deleted by ansi2knr rules");
4985 my $r = $LANG_PROCESS;
4986 if (defined $options{'subdir-objects'})
4989 $base = $directory . '/' . $base;
4993 # Only give error once.
4995 # FIXME: line number.
4996 &am_error ("C objects in subdir but `AM_PROG_CC_C_O' not in `$configure_ac'");
4999 &require_conf_file ($FOREIGN, 'compile');
5002 $de_ansi_files{$base} = 1;
5006 # Rewrite a single C++ source file.
5007 sub lang_cxx_rewrite
5009 return &lang_sub_obj;
5012 # Rewrite a single header file.
5013 sub lang_header_rewrite
5015 # Header files are simply ignored.
5016 return $LANG_IGNORE;
5019 # Rewrite a single yacc file.
5020 sub lang_yacc_rewrite
5022 my ($directory, $base, $ext) = @_;
5024 my $r = &lang_sub_obj;
5025 (my $newext = $ext) =~ tr/y/c/;
5026 return ($r, $newext);
5029 # Rewrite a single yacc++ file.
5030 sub lang_yaccxx_rewrite
5032 my ($directory, $base, $ext) = @_;
5034 my $r = &lang_sub_obj;
5035 (my $newext = $ext) =~ tr/y/c/;
5036 return ($r, $newext);
5039 # Rewrite a single lex file.
5040 sub lang_lex_rewrite
5042 my ($directory, $base, $ext) = @_;
5044 my $r = &lang_sub_obj;
5045 (my $newext = $ext) =~ tr/l/c/;
5046 return ($r, $newext);
5049 # Rewrite a single lex++ file.
5050 sub lang_lexxx_rewrite
5052 my ($directory, $base, $ext) = @_;
5054 my $r = &lang_sub_obj;
5055 (my $newext = $ext) =~ tr/l/c/;
5056 return ($r, $newext);
5059 # Rewrite a single assembly file.
5060 sub lang_asm_rewrite
5062 return &lang_sub_obj;
5065 # Rewrite a single Fortran 77 file.
5066 sub lang_f77_rewrite
5068 return $LANG_PROCESS;
5071 # Rewrite a single preprocessed Fortran 77 file.
5072 sub lang_ppf77_rewrite
5074 return $LANG_PROCESS;
5077 # Rewrite a single ratfor file.
5078 sub lang_ratfor_rewrite
5080 return $LANG_PROCESS;
5083 # Rewrite a single Objective C file.
5084 sub lang_objc_rewrite
5086 return &lang_sub_obj;
5089 # Rewrite a single Java file.
5090 sub lang_java_rewrite
5092 return $LANG_SUBDIR;
5095 # The lang_X_finish functions are called after all source file
5096 # processing is done. Each should handle defining rules for the
5097 # language, etc. A finish function is only called if a source file of
5098 # the appropriate type has been seen.
5102 # Push all libobjs files onto de_ansi_files. We actually only
5103 # push files which exist in the current directory, and which are
5104 # genuine source files.
5105 foreach my $file (keys %libsources)
5107 if ($file =~ /^(.*)\.[cly]$/ && -f "$relative_dir/$file")
5109 $de_ansi_files{$1} = 1;
5113 if (defined $options{'ansi2knr'} && keys %de_ansi_files)
5115 # Make all _.c files depend on their corresponding .c files.
5117 foreach my $base (sort keys %de_ansi_files)
5119 # Each _.c file must depend on ansi2knr; otherwise it
5120 # might be used in a parallel build before it is built.
5121 # We need to support files in the srcdir and in the build
5122 # dir (because these files might be auto-generated. But
5123 # we can't use $< -- some makes only define $< during a
5125 $output_rules .= ($base . "_.c: $base.c \$(ANSI2KNR)\n\t"
5126 . '$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) '
5127 . '`if test -f $(srcdir)/' . $base . '.c'
5128 . '; then echo $(srcdir)/' . $base . '.c'
5129 . '; else echo ' . $base . '.c; fi` '
5130 . "| sed 's/^# \\([0-9]\\)/#line \\1/' "
5131 . '| $(ANSI2KNR) > ' . $base . "_.c"
5132 # If ansi2knr fails then we shouldn't
5133 # create the _.c file
5134 . " || rm -f ${base}_.c\n");
5135 push (@objects, $base . '_.$(OBJEXT)');
5136 push (@objects, $base . '_.lo')
5140 # Make all _.o (and _.lo) files depend on ansi2knr.
5141 # Use a sneaky little hack to make it print nicely.
5142 &pretty_print_rule ('', '', @objects, ':', '$(ANSI2KNR)');
5146 # This is a yacc helper which is called whenever we have decided to
5147 # compile a yacc file.
5148 sub lang_yacc_target_hook
5150 my ($self, $aggregate, $output, $input) = @_;
5152 my $flag = $aggregate . "_YFLAGS";
5153 if ((&variable_defined ($flag)
5154 && &variable_value ($flag) =~ /$DASH_D_PATTERN/o)
5155 || (&variable_defined ('YFLAGS')
5156 && &variable_value ('YFLAGS') =~ /$DASH_D_PATTERN/o))
5158 (my $output_base = $output) =~ s/\..*$//;
5159 my $header = $output_base . '.h';
5161 # Found a `-d' that applies to the compilation of this file.
5162 # Add a dependency for the generated header file, and arrange
5163 # for that file to be included in the distribution.
5164 # FIXME: this fails for `nodist_*_SOURCES'.
5165 $output_rules .= "${header}: $output\n";
5166 &push_dist_common ($header);
5167 # If the files are built in the build directory, then we want
5168 # to remove them with `make clean'. If they are in srcdir
5169 # they shouldn't be touched. However, we can't determine this
5170 # statically, and the GNU rules say that yacc/lex output files
5171 # should be removed by maintainer-clean. So that's what we
5173 push (@maintainer_clean_files, $header);
5177 # This is a helper for both lex and yacc.
5178 sub yacc_lex_finish_helper
5180 return if defined $language_scratch{'lex-yacc-done'};
5181 $language_scratch{'lex-yacc-done'} = 1;
5183 # If there is more than one distinct yacc (resp lex) source file
5184 # in a given directory, then the `ylwrap' program is required to
5185 # allow parallel builds to work correctly. FIXME: for now, no
5187 &require_config_file ($FOREIGN, 'ylwrap');
5188 if ($config_aux_dir_set_in_configure_in)
5190 &define_variable ('YLWRAP', $config_aux_dir . "/ylwrap");
5194 &define_variable ('YLWRAP', '$(top_srcdir)/ylwrap');
5198 sub lang_yacc_finish
5200 return if defined $language_scratch{'yacc-done'};
5201 $language_scratch{'yacc-done'} = 1;
5203 if (&variable_defined ('YACCFLAGS'))
5205 &am_line_error ('YACCFLAGS',
5206 "`YACCFLAGS' obsolete; use `YFLAGS' instead");
5209 if (count_files_for_language ('yacc') > 1)
5211 &yacc_lex_finish_helper;
5218 return if defined $language_scratch{'lex-done'};
5219 $language_scratch{'lex-done'} = 1;
5221 if (! $seen_decl_yytext)
5223 &am_error ("lex source seen but `AC_DECL_YYTEXT' not in `$configure_ac'");
5226 if (count_files_for_language ('lex') > 1)
5228 &yacc_lex_finish_helper;
5233 # Given a hash table of linker names, pick the name that has the most
5234 # precedence. This is lame, but something has to have global
5235 # knowledge in order to eliminate the conflict. Add more linkers as
5242 if defined $linkers{'GCJLINK'};
5244 if defined $linkers{'CXXLINK'};
5246 if defined $linkers{'F77LINK'};
5248 if defined $linkers{'OBJCLINK'};
5252 # Called to indicate that an extension was used.
5256 if (! defined $extension_seen{$ext})
5258 $extension_seen{$ext} = 1;
5262 ++$extension_seen{$ext};
5266 # Return the number of files seen for a given language. Knows about
5267 # special cases we care about. FIXME: this is hideous. We need
5268 # something that involves real language objects. For instance yacc
5269 # and yaccxx could both derive from a common yacc class which would
5270 # know about the strange ylwrap requirement. (Or better yet we could
5271 # just not support legacy yacc!)
5272 sub count_files_for_language
5277 if ($name eq 'yacc' || $name eq 'yaccxx')
5279 @names = ('yacc', 'yaccxx');
5281 elsif ($name eq 'lex' || $name eq 'lexxx')
5283 @names = ('lex', 'lexxx');
5291 foreach $name (@names)
5293 my $lang = $languages{$name};
5294 foreach my $ext (@{$lang->extensions})
5296 $r += $extension_seen{$ext}
5297 if defined $extension_seen{$ext};
5304 # Called to ask whether source files have been seen . If HEADERS is 1,
5305 # headers can be included.
5310 # count all the sources
5312 foreach my $val (values %extension_seen)
5319 $count -= count_files_for_language ('header');
5326 # register_language (%ATTRIBUTE)
5327 # ------------------------------
5328 # Register a single language.
5329 # Each %ATTRIBUTE is of the form ATTRIBUTE => VALUE.
5330 sub register_language (%)
5336 unless defined $option{'ansi'};
5337 $option{'autodep'} = 'no'
5338 unless defined $option{'autodep'};
5339 $option{'linker'} = ''
5340 unless defined $option{'linker'};
5341 $option{'define_flag'} = 1
5342 unless defined $option{'define_flag'};
5344 my $lang = new Language (%option);
5347 grep ($extension_map{$_} = $lang->name, @{$lang->extensions});
5348 $languages{$lang->name} = $lang;
5351 # This function is used to find a path from a user-specified suffix to
5352 # `o' or to some other suffix we recognize internally, eg `cc'.
5355 my ($source_ext) = @_;
5357 # FIXME: hard-coding `o' is a mistake. Doing something
5358 # intelligent is harder.
5359 while (! $extension_map{$source_ext}
5360 && $source_ext ne 'o'
5361 && defined $suffix_rules{$source_ext})
5363 $source_ext = $suffix_rules{$source_ext};
5370 ################################################################
5372 # Pretty-print something. HEAD is what should be printed at the
5373 # beginning of the first line, FILL is what should be printed at the
5374 # beginning of every subsequent line.
5375 sub pretty_print_internal
5377 my ($head, $fill, @values) = @_;
5379 my $column = length ($head);
5382 # Fill length is number of characters. However, each Tab
5383 # character counts for eight. So we count the number of Tabs and
5385 my $fill_length = length ($fill);
5386 $fill_length += 7 * ($fill =~ tr/\t/\t/d);
5390 # "71" because we also print a space.
5391 if ($column + length ($_) > 71)
5393 $result .= " \\\n" . $fill;
5394 $column = $fill_length;
5396 $result .= ' ' if $result =~ /\S\z/;
5398 $column += length ($_) + 1;
5405 # Pretty-print something and append to output_vars.
5408 $output_vars .= &pretty_print_internal (@_);
5411 # Pretty-print something and append to output_rules.
5412 sub pretty_print_rule
5414 $output_rules .= &pretty_print_internal (@_);
5418 ################################################################
5422 # &conditional_string(@COND-STACK)
5423 # --------------------------------
5424 # Build a string which denotes the conditional in @COND-STACK. Some
5425 # simplifications are done: `TRUE' entries are elided, and any `FALSE'
5426 # entry results in a return of `FALSE'.
5427 sub conditional_string
5431 if (grep (/^FALSE$/, @stack))
5437 return join (' ', uniq sort grep (!/^TRUE$/, @stack));
5443 # &conditional_true_when ($COND, $WHEN)
5444 # -------------------------------------
5445 # See if a conditional is true. Both arguments are conditional
5446 # strings. This returns true if the first conditional is true when
5447 # the second conditional is true.
5448 # For instance with $COND = `BAR FOO', and $WHEN = `BAR BAZ FOO',
5449 # obviously return 1, and 0 when, for instance, $WHEN = `FOO'.
5450 sub conditional_true_when ($$)
5452 my ($cond, $when) = @_;
5454 # Make a hash holding all the values from $WHEN.
5455 my %cond_vals = map { $_ => 1 } split (' ', $when);
5457 # Check each component of $cond, which looks `COND1 COND2'.
5458 foreach my $comp (split (' ', $cond))
5460 # TRUE is always true.
5461 next if $comp eq 'TRUE';
5462 return 0 if ! defined $cond_vals{$comp};
5470 # &conditional_is_redundant ($COND, @WHENS)
5471 # ----------------------------------------
5472 # Determine whether $COND is redundant with respect to @WHENS.
5474 # Returns true if $COND is true for any of the conditions in @WHENS.
5476 # If there are no @WHENS, then behave as if @WHENS contained a single empty
5478 sub conditional_is_redundant ($@)
5480 my ($cond, @whens) = @_;
5484 return 1 if conditional_true_when ($cond, "");
5488 foreach my $when (@whens)
5490 return 1 if conditional_true_when ($cond, $when);
5499 # condition_negate ($COND)
5500 # ------------------------
5501 sub condition_negate ($)
5505 $cond =~ s/TRUE$/TRUEO/;
5506 $cond =~ s/FALSE$/TRUE/;
5507 $cond =~ s/TRUEO$/FALSE/;
5513 # Compare condition names.
5514 # Issue them in alphabetical order, foo_TRUE before foo_FALSE.
5517 # Be careful we might be comparing `' or `#'.
5518 $a =~ /^(.*)_(TRUE|FALSE)$/;
5519 my ($aname, $abool) = ($1 || '', $2 || '');
5520 $b =~ /^(.*)_(TRUE|FALSE)$/;
5521 my ($bname, $bbool) = ($1 || '', $2 || '');
5522 return ($aname cmp $bname
5523 # Don't bother with IFs, given that TRUE is after FALSE
5524 # just cmp in the reverse order.
5525 || $bbool cmp $abool
5531 # &make_condition (@CONDITIONS)
5532 # -----------------------------
5533 # Transform a list of conditions (themselves can be an internal list
5534 # of conditions, e.g., @CONDITIONS = ('cond1 cond2', 'cond3')) into a
5535 # Make conditional (a pattern for AC_SUBST).
5536 # Correctly returns the empty string when there are no conditions.
5539 my $res = conditional_string (@_);
5541 # There are no conditions.
5547 elsif ($res eq 'FALSE')
5554 $res = '@' . $res . '@';
5563 ## ------------------------------ ##
5564 ## Handling the condition stack. ##
5565 ## ------------------------------ ##
5569 # cond_stack_if ($NEGATE, $COND, $WHERE)
5570 # --------------------------------------
5571 sub cond_stack_if ($$$)
5573 my ($negate, $cond, $where) = @_;
5575 &am_file_error ($where, "$cond does not appear in AM_CONDITIONAL")
5576 if ! $configure_cond{$cond} && $cond !~ /^TRUE|FALSE$/;
5578 $cond = "${cond}_TRUE"
5579 unless $cond =~ /^TRUE|FALSE$/;
5580 $cond = condition_negate ($cond)
5583 push (@cond_stack, $cond);
5585 return conditional_string (@cond_stack);
5590 # cond_stack_else ($NEGATE, $COND, $WHERE)
5591 # ----------------------------------------
5592 sub cond_stack_else ($$$)
5594 my ($negate, $cond, $where) = @_;
5598 &am_file_error ($where, "else without if");
5602 $cond_stack[$#cond_stack] = condition_negate ($cond_stack[$#cond_stack]);
5604 # If $COND is given, check against it.
5607 $cond = "${cond}_TRUE"
5608 unless $cond =~ /^TRUE|FALSE$/;
5609 $cond = condition_negate ($cond)
5612 &am_file_error ($where,
5613 "else reminder ($negate$cond) incompatible with "
5614 . "current conditional: $cond_stack[$#cond_stack]")
5615 if $cond_stack[$#cond_stack] ne $cond;
5618 return conditional_string (@cond_stack);
5623 # cond_stack_endif ($NEGATE, $COND, $WHERE)
5624 # -----------------------------------------
5625 sub cond_stack_endif ($$$)
5627 my ($negate, $cond, $where) = @_;
5632 &am_file_error ($where, "endif without if: $negate$cond");
5637 # If $COND is given, check against it.
5640 $cond = "${cond}_TRUE"
5641 unless $cond =~ /^TRUE|FALSE$/;
5642 $cond = condition_negate ($cond)
5645 &am_file_error ($where,
5646 "endif reminder ($negate$cond) incompatible with "
5647 . "current conditional: $cond_stack[$#cond_stack]")
5648 if $cond_stack[$#cond_stack] ne $cond;
5653 return conditional_string (@cond_stack);
5660 ## ------------------------ ##
5661 ## Handling the variables. ##
5662 ## ------------------------ ##
5665 # check_ambiguous_conditional ($VAR, $COND)
5666 # -----------------------------------------
5667 # Check for an ambiguous conditional. This is called when a variable
5668 # is being defined conditionally. If we already know about a
5669 # definition that is true under the same conditions, then we have an
5671 sub check_ambiguous_conditional ($$)
5673 my ($var, $cond) = @_;
5674 foreach my $vcond (keys %{$var_value{$var}})
5677 if ($vcond eq $cond)
5679 $message = "$var multiply defined in condition $cond";
5681 elsif (&conditional_true_when ($vcond, $cond))
5683 $message = ("$var was already defined in condition $vcond, "
5684 . "which implies condition $cond");
5686 elsif (&conditional_true_when ($cond, $vcond))
5688 $message = ("$var was already defined in condition $vcond, "
5689 . "which is implied by condition $cond");
5693 &am_line_error ($var, $message);
5700 # ¯o_define($VAR, $VAR_IS_AM, $TYPE, $COND, $VALUE, $WHERE)
5701 # -------------------------------------------------------------
5702 # The $VAR can go from Automake to user, but not the converse.
5703 sub macro_define ($$$$$$)
5705 my ($var, $var_is_am, $type, $cond, $value, $where) = @_;
5707 am_file_error ($where, "bad macro name `$var'")
5708 if $var !~ /$MACRO_PATTERN/o;
5712 # An Automake variable must be consistently defined with the same
5713 # sign by Automake. A user variable must be set by either `=' or
5714 # `:=', and later promoted to `+='.
5717 if (defined $var_type{$var} && $var_type{$var} ne $type)
5719 am_line_error ($var,
5720 ("$var was set with `$var_type{$var}=' "
5721 . "and is now set with `$type='"));
5726 if (!defined $var_type{$var} && $type eq '+')
5728 am_line_error ($var, "$var must be set with `=' before using `+='");
5731 $var_type{$var} = $type;
5733 # When adding, since we rewrite, don't try to preserve the
5734 # Automake continuation backslashes.
5736 if $type eq '+' && $var_is_am;
5738 # Differentiate the first assignment (including with `+=').
5739 if ($type eq '+' && defined $var_value{$var}{$cond})
5741 if (substr ($var_value{$var}{$cond}, -1) eq "\n")
5743 # Insert a backslash before a trailing newline.
5744 $var_value{$var}{$cond} =
5745 substr ($var_value{$var}{$cond}, 0, -1) . "\\\n";
5747 elsif ($var_value{$var}{$cond})
5749 # Insert a separator.
5750 $var_value{$var}{$cond} .= ' ';
5752 $var_value{$var}{$cond} .= $value;
5756 # The first assignment to a macro sets the line number. Ideally I
5757 # suppose we would associate line numbers with random bits of text.
5758 # FIXME: We sometimes redefine some variables, but we want to keep
5759 # the original location. More subs are needed to handle
5760 # properly variables. Once this done, remove this hack.
5761 $var_line{$var} = $where
5762 unless defined $var_line{$var};
5764 # If Automake tries to override a value specified by the user,
5765 # just don't let it do.
5766 if (defined $var_value{$var}{$cond} && !$var_is_am{$var} && $var_is_am)
5770 print STDERR "$me: refusing to override the user definition of:\n";
5772 print STDERR "$me: with `$cond' => `$value'\n";
5777 # There must be no previous value unless the user is redefining
5778 # an Automake variable or an AC_SUBST variable.
5779 check_ambiguous_conditional ($var, $cond)
5780 unless ($var_is_am{$var} && !$var_is_am
5781 || exists $configure_vars{$var});
5783 $var_value{$var}{$cond} = $value;
5787 # An Automake variable can be given to the user, but not the converse.
5788 if (! defined $var_is_am{$var} || !$var_is_am)
5790 $var_is_am{$var} = $var_is_am;
5795 # &variable_delete ($VAR, [@CONDS])
5796 # ---------------------------------
5797 # Forget about $VAR under the conditions @CONDS, or completely if
5799 sub variable_delete ($@)
5801 my ($var, @conds) = @_;
5805 delete $var_value{$var};
5806 delete $var_line{$var};
5807 delete $var_is_am{$var};
5808 delete $var_comment{$var};
5809 delete $var_type{$var};
5813 foreach my $cond (@conds)
5815 delete $var_value{$var}{$cond};
5821 # ¯o_dump ($VAR)
5822 # ------------------
5827 if (!exists $var_value{$var})
5829 print STDERR " $var does not exist\n";
5833 my $var_is_am = $var_is_am{$var} ? "Automake" : "User";
5834 my $where = (defined $var_line{$var}
5835 ? $var_line{$var} : "undefined");
5836 print STDERR "$var_comment{$var}"
5837 if defined $var_comment{$var};
5838 print STDERR " $var ($var_is_am, where = $where) $var_type{$var}=\n";
5839 print STDERR " {\n";
5840 foreach my $vcond (sort by_condition keys %{$var_value{$var}})
5842 print STDERR " $vcond => $var_value{$var}{$vcond}\n";
5844 print STDERR " }\n";
5855 print STDERR "%var_value =\n";
5857 foreach my $var (sort (keys %var_value))
5866 # &variable_defined ($VAR, [$COND])
5867 # ---------------------------------
5868 # See if a variable exists. $VAR is the variable name, and $COND is
5869 # the condition which we should check. If no condition is given, we
5870 # currently return true if the variable is defined under any
5872 sub variable_defined ($$)
5874 my ($var, $cond) = @_;
5876 # Unfortunately we can't just check for $var_value{VAR}{COND}
5877 # as this would make perl create $condition{VAR}, which we
5879 if (!exists $var_value{$var})
5881 if (defined $targets{$var})
5883 &am_line_error ($var, "`$var' is a target; expected a variable")
5885 # The variable is not defined
5889 if ($cond && !exists $var_value{$var}{$cond})
5891 # The variable is not defined for the given condition.
5895 # Even a var_value examination is good enough for us. FIXME:
5896 # really should maintain examined status on a per-condition basis.
5897 $content_seen{$var} = 1;
5901 # Mark a variable as examined.
5902 sub examine_variable
5905 &variable_defined ($var);
5908 # Return the set of conditions for which a variable is defined.
5910 # If the variable is not defined conditionally, and is not defined in
5911 # terms of any variables which are defined conditionally, then this
5912 # returns the empty list.
5914 # If the variable is defined conditionally, but is not defined in
5915 # terms of any variables which are defined conditionally, then this
5916 # returns the list of conditions for which the variable is defined.
5918 # If the variable is defined in terms of any variables which are
5919 # defined conditionally, then this returns a full set of permutations
5920 # of the subvariable conditions. For example, if the variable is
5921 # defined in terms of a variable which is defined for COND_TRUE,
5922 # then this returns both COND_TRUE and COND_FALSE. This is
5923 # because we will need to define the variable under both conditions.
5925 sub variable_conditions_recursive ($)
5931 my @new_conds = variable_conditions_recursive_sub ($var, '');
5932 # Now we want to return all permutations of the subvariable
5935 foreach my $item (@new_conds)
5937 foreach (split (' ', $item))
5939 s/^(.*)_(TRUE|FALSE)$/$1_TRUE/;
5943 @new_conds = variable_conditions_permutations (sort keys %allconds);
5946 foreach my $cond (@new_conds)
5948 my $reduce = variable_conditions_reduce (split (' ', $cond));
5950 if $reduce eq 'FALSE';
5951 $uniqify{$cond} = 1;
5954 # Note we cannot just do `return sort keys %uniqify', because this
5955 # function is sometimes used in a scalar context.
5956 my @uniq_list = sort by_condition keys %uniqify;
5961 # variable_conditions ($VAR)
5962 # --------------------------
5963 # Get the list of conditions that a variable is defined with, without
5964 # recursing through the conditions of any subvariables.
5965 # Argument is $VAR: the variable to get the conditions of.
5966 # Returns the list of conditions.
5967 sub variable_conditions ($)
5970 my @conds = keys %{$var_value{$var}};
5971 return sort by_condition @conds;
5976 # &variable_conditionally_defined ($VAR)
5977 # --------------------------------------
5978 sub variable_conditionally_defined ($)
5981 foreach my $cond (variable_conditions_recursive ($var))
5984 unless $cond =~ /^TRUE|FALSE$/;
5991 # &variable_conditions_recursive_sub ($VAR, $PARENT)
5992 # -------------------------------------------------------
5993 # A subroutine of variable_conditions_recursive. This returns all the
5994 # conditions of $VAR, including those of any sub-variables.
5995 sub variable_conditions_recursive_sub
5997 my ($var, $parent) = @_;
6000 if (defined $vars_scanned{$var})
6002 &am_line_error ($parent, "variable `$var' recursively defined");
6005 $vars_scanned{$var} = 1;
6007 my @this_conds = ();
6008 # Examine every condition under which $VAR is defined.
6009 foreach my $vcond (keys %{$var_value{$var}})
6011 push (@this_conds, $vcond);
6013 # If $VAR references some other variable, then compute the
6014 # conditions for that subvariable.
6015 my @subvar_conds = ();
6016 foreach (split (' ', $var_value{$var}{$vcond}))
6018 # If a comment seen, just leave.
6021 # Handle variable substitutions.
6022 if (/^\$\{(.*)\}$/ || /^\$\((.*)\)$/)
6025 if ($varname =~ /$SUBST_REF_PATTERN/o)
6031 # Here we compute all the conditions under which the
6032 # subvariable is defined. Then we go through and add
6034 my @svc = variable_conditions_recursive_sub ($varname, $var);
6035 foreach my $item (@svc)
6037 my $val = conditional_string ($vcond, split (' ', $item));
6039 push (@subvar_conds, $val);
6044 # If there are no conditional subvariables, then we want to
6045 # return this condition. Otherwise, we want to return the
6046 # permutations of the subvariables, taking into account the
6047 # conditions of $VAR.
6048 if (! @subvar_conds)
6050 push (@new_conds, $vcond);
6054 push (@new_conds, variable_conditions_reduce (@subvar_conds));
6058 # Unset our entry in vars_scanned. We only care about recursive
6060 delete $vars_scanned{$var};
6062 # If we are being called on behalf of another variable, we need to
6063 # return all possible permutations of the conditions. We have
6064 # already handled everything in @this_conds along with their
6065 # subvariables. We now need to add any permutations that are not
6067 foreach my $this_cond (@this_conds)
6070 variable_conditions_permutations (split (' ', $this_cond));
6071 foreach my $perm (@perms)
6074 foreach my $scan (@this_conds)
6076 if (&conditional_true_when ($perm, $scan)
6077 || &conditional_true_when ($scan, $perm))
6085 # This permutation was not already handled, and is valid
6087 push (@new_conds, $perm);
6095 # Filter a list of conditionals so that only the exclusive ones are
6096 # retained. For example, if both `COND1_TRUE COND2_TRUE' and
6097 # `COND1_TRUE' are in the list, discard the latter.
6098 # If the list is empty, return TRUE
6099 sub variable_conditions_reduce
6106 $cond = shift(@conds);
6108 # FALSE is absorbent.
6109 if ($cond eq 'FALSE')
6113 elsif (!conditional_is_redundant ($cond, @ret, @conds))
6119 return "TRUE" if @ret == 0;
6124 # invert_conditions (@CONDS)
6125 # --------------------------
6126 # Invert a list of conditionals. Returns a set of conditionals which
6127 # are never true for any of the input conditionals, and when taken
6128 # together with the input conditionals cover all possible cases.
6130 # For example: invert_conditions("A_TRUE B_TRUE", "A_FALSE B_FALSE") will
6131 # return ("A_FALSE B_TRUE", "A_TRUE B_FALSE")
6132 sub invert_conditions
6137 foreach my $cond (@conds)
6139 foreach my $perm (variable_conditions_permutations (split(' ', $cond)))
6141 push @notconds, $perm
6142 if ! conditional_is_redundant ($perm, @conds);
6145 return variable_conditions_reduce (@notconds);
6148 # Return a list of permutations of a conditional string.
6149 sub variable_conditions_permutations
6154 my $comp = shift (@comps);
6155 return variable_conditions_permutations (@comps)
6157 my $neg = condition_negate ($comp);
6160 foreach my $sub (variable_conditions_permutations (@comps))
6162 push (@ret, "$comp $sub");
6163 push (@ret, "$neg $sub");
6175 # &check_variable_defined_unconditionally($VAR, $PARENT)
6176 # ------------------------------------------------------
6177 # Warn if a variable is conditionally defined. This is called if we
6178 # are using the value of a variable.
6179 sub check_variable_defined_unconditionally ($$)
6181 my ($var, $parent) = @_;
6182 foreach my $cond (keys %{$var_value{$var}})
6185 if $cond =~ /^TRUE|FALSE$/;
6189 &am_line_error ($parent,
6190 "warning: automake does not support conditional definition of $var in $parent");
6194 &am_line_error ($parent,
6195 "warning: automake does not support $var being defined conditionally");
6201 # Get the TRUE value of a variable, warn if the variable is
6202 # conditionally defined.
6206 &check_variable_defined_unconditionally ($var);
6207 return $var_value{$var}{'TRUE'};
6212 # &value_to_list ($VAR, $VAL, $COND)
6213 # ----------------------------------
6214 # Convert a variable value to a list, split as whitespace. This will
6215 # recursively follow $(...) and ${...} inclusions. It preserves @...@
6218 # If COND is 'all', then all values under all conditions should be
6219 # returned; if COND is a particular condition (all conditions are
6220 # surrounded by @...@) then only the value for that condition should
6221 # be returned; otherwise, warn if VAR is conditionally defined.
6222 # SCANNED is a global hash listing whose keys are all the variables
6223 # already scanned; it is an error to rescan a variable.
6226 my ($var, $val, $cond) = @_;
6230 $val =~ s/\\(\n|$)/ /g;
6232 foreach (split (' ', $val))
6234 # If a comment seen, just leave.
6237 # Handle variable substitutions.
6238 if (/^\$\{([^}]*)\}$/ || /^\$\(([^)]*)\)$/)
6242 # If the user uses a losing variable name, just ignore it.
6243 # This isn't ideal, but people have requested it.
6244 next if ($varname =~ /\@.*\@/);
6248 if ($varname =~ /$SUBST_REF_PATTERN/o)
6252 ($from = $2) =~ s/(\W)/\\$1/g;
6256 @temp_list = &variable_value_as_list_recursive_worker ($1, $cond, $var);
6258 # Now rewrite the value if appropriate.
6261 grep (s/$from$/$to/, @temp_list);
6264 push (@result, @temp_list);
6276 # variable_value_as_list ($VAR, $COND, $PARENT)
6277 # ---------------------------------------------
6278 # Get the value of a variable given a specified condition. without
6279 # recursing through any subvariables.
6281 # $VAR is the variable
6282 # $COND is the condition. If this is not given, the value for the
6283 # "TRUE" condition will be returned.
6284 # $PARENT is the variable in which the variable is used: this is used
6285 # only for error messages.
6286 # Returns the list of conditions.
6287 # For example, if A is defined as "foo $(B) bar", and B is defined as
6288 # "baz", this will return ("foo", "$(B)", "bar")
6289 sub variable_value_as_list
6291 my ($var, $cond, $parent) = @_;
6295 if (! defined $var_value{$var})
6297 if (defined $targets{$var})
6299 &am_line_error ($var, "`$var' is a target; expected a variable");
6303 &am_line_error ($parent, "variable `$var' not defined");
6307 # Get value for given condition
6310 foreach my $vcond (keys %{$var_value{$var}})
6312 my $val = $var_value{$var}{$vcond};
6314 if (&conditional_true_when ($vcond, $cond))
6316 # Unless variable is not defined conditionally, there should only
6317 # be one value of $vcond true when $cond.
6318 &check_variable_defined_unconditionally ($var, $parent)
6323 $val =~ s/\\(\n|$)/ /g;
6325 foreach (split (' ', $val))
6327 # If a comment seen, just leave.
6338 # Return contents of variable as list, split as whitespace. This will
6339 # recursively follow $(...) and ${...} inclusions. It preserves @...@
6340 # substitutions. If COND is 'all', then all values under all
6341 # conditions should be returned; if COND is a particular condition
6342 # (all conditions are surrounded by @...@) then only the value for
6343 # that condition should be returned; otherwise, warn if VAR is
6344 # conditionally defined. If PARENT is specified, it is the name of
6345 # the including variable; this is only used for error reports.
6346 sub variable_value_as_list_recursive_worker
6348 my ($var, $cond, $parent) = @_;
6351 if (! defined $var_value{$var})
6353 if (defined $targets{$var})
6355 &am_line_error ($var, "`$var' is a target; expected a variable");
6359 &am_line_error ($parent, "variable `$var' not defined");
6362 elsif (defined $vars_scanned{$var})
6364 # `vars_scanned' is a global we use to keep track of which
6365 # variables we've already examined.
6366 &am_line_error ($parent, "variable `$var' recursively defined");
6368 elsif ($cond eq 'all')
6370 $vars_scanned{$var} = 1;
6371 foreach my $vcond (keys %{$var_value{$var}})
6373 my $val = $var_value{$var}{$vcond};
6374 push (@result, &value_to_list ($var, $val, $cond));
6380 $vars_scanned{$var} = 1;
6382 foreach my $vcond (keys %{$var_value{$var}})
6384 my $val = $var_value{$var}{$vcond};
6385 if (&conditional_true_when ($vcond, $cond))
6387 # Warn if we have an ambiguity. It's hard to know how
6388 # to handle this case correctly.
6389 &check_variable_defined_unconditionally ($var, $parent)
6392 push (@result, &value_to_list ($var, $val, $cond));
6397 # Unset our entry in vars_scanned. We only care about recursive
6399 delete $vars_scanned{$var};
6405 # &variable_output ($VAR, [@CONDS])
6406 # ---------------------------------
6407 # Output all the values of $VAR is @COND is not specified, else only
6408 # that corresponding to @COND.
6409 sub variable_output ($@)
6411 my ($var, @conds) = @_;
6413 @conds = keys %{$var_value{$var}}
6416 $output_vars .= $var_comment{$var}
6417 if defined $var_comment{$var};
6419 foreach my $cond (sort by_condition @conds)
6421 my $val = $var_value{$var}{$cond};
6422 my $equals = $var_type{$var} eq ':' ? ':=' : '=';
6423 my $output_var = "$var $equals $val";
6424 $output_var =~ s/^/make_condition ($cond)/meg;
6425 $output_vars .= $output_var . "\n";
6430 # &variable_pretty_output ($VAR, [@CONDS])
6431 # ----------------------------------------
6432 # Likewise, but pretty, i.e., we *split* the values at spaces. Use only
6433 # with variables holding filenames.
6434 sub variable_pretty_output ($@)
6436 my ($var, @conds) = @_;
6438 @conds = keys %{$var_value{$var}}
6441 $output_vars .= $var_comment{$var}
6442 if defined $var_comment{$var};
6444 foreach my $cond (sort by_condition @conds)
6446 my $val = $var_value{$var}{$cond};
6447 my $equals = $var_type{$var} eq ':' ? ':=' : '=';
6448 my $make_condition = make_condition ($cond);
6449 $output_vars .= pretty_print_internal ("$make_condition$var $equals",
6450 "$make_condition\t",
6451 split (' ' , $val));
6456 # This is just a wrapper for variable_value_as_list_recursive_worker that
6457 # initializes the global hash `vars_scanned'. This hash is used to
6458 # avoid infinite recursion.
6459 sub variable_value_as_list_recursive
6461 my ($var, $cond, $parent) = @_;
6463 return &variable_value_as_list_recursive_worker ($var, $cond, $parent);
6467 # Like define_variable, but the value is a list, and the variable may
6468 # be defined conditionally. The second argument is the conditional
6469 # under which the value should be defined; this should be the empty
6470 # string to define the variable unconditionally. The third argument
6471 # is a list holding the values to use for the variable. The value is
6472 # pretty printed in the output file.
6473 sub define_pretty_variable
6475 my ($var, $cond, @value) = @_;
6477 # Beware that an empty $cond has a different semantics for
6478 # macro_define and variable_pretty_output.
6481 if (! &variable_defined ($var, $cond))
6483 macro_define ($var, 1, '', $cond, join (' ', @value), undef);
6484 variable_pretty_output ($var, $cond || 'TRUE');
6485 $content_seen{$var} = 1;
6490 # define_variable ($VAR, $VALUE)
6491 # ------------------------------
6492 # Define a new user variable VAR to VALUE, but only if not already defined.
6495 my ($var, $value) = @_;
6497 define_pretty_variable ($var, 'TRUE', $value);
6501 # Like define_variable, but define a variable to be the configure
6502 # substitution by the same name.
6503 sub define_configure_variable
6506 my $value = '@' . $var . '@';
6507 &define_variable ($var, $value);
6511 # define_compiler_variable ($LANG)
6512 # --------------------------------
6513 # Define a compiler variable. We also handle defining the `LT'
6514 # version of the command when using libtool.
6515 sub define_compiler_variable ($)
6519 my ($var, $value) = ($lang->compiler, $lang->compile);
6520 &define_variable ($var, $value);
6521 &define_variable ("LT$var", "\$(LIBTOOL) --mode=compile $value")
6526 # define_linker_variable ($LANG)
6527 # ------------------------------
6528 # Define linker variables.
6529 sub define_linker_variable ($)
6533 my ($var, $value) = ($lang->lder, $lang->ld);
6535 &define_variable ($lang->lder, $lang->ld);
6536 # CCLINK = $(CCLD) blah blah...
6537 &define_variable ($lang->linker,
6538 (($seen_libtool ? '$(LIBTOOL) --mode=link ' : '')
6542 ################################################################
6544 ## ---------------- ##
6545 ## Handling rules. ##
6546 ## ---------------- ##
6549 # rule_define ($TARGET, $IS_AM, $COND, $WHERE)
6550 # --------------------------------------------
6551 # Define a new rule. $TARGET is the rule name. $IS_AM is a boolean
6552 # which is true if the new rule is defined by the user. $COND is the
6553 # condition under which the rule is defined. $WHERE is where the rule
6554 # is defined (file name or line number). Returns true if it is ok to
6555 # define the rule, false otherwise.
6556 sub rule_define ($$$$)
6558 my ($target, $rule_is_am, $cond, $where) = @_;
6560 # For now `foo:' will override `foo$(EXEEXT):'. This is temporary,
6561 # though, so we emit a warning.
6562 (my $noexe = $target) =~ s,\$\(EXEEXT\)$,,;
6563 if ($noexe ne $target && defined $targets{$noexe})
6565 # The no-exeext option enables this feature.
6566 if (! defined $options{'no-exeext'})
6568 &am_line_error ($noexe,
6569 "deprecated feature: `$noexe' overrides `$noexe\$(EXEEXT)'\nchange your target to read `$noexe\$(EXEEXT)'");
6575 if (defined $targets{$target}
6577 ? ! defined $target_conditional{$target}
6578 : defined $target_conditional{$target}))
6580 &am_line_error ($target,
6581 "$target defined both conditionally and unconditionally");
6584 # Value here doesn't matter; for targets we only note existence.
6585 $targets{$target} = $where;
6588 if ($target_conditional{$target})
6590 &check_ambiguous_conditional ($target, $cond);
6592 $target_conditional{$target}{$cond} = $where;
6596 # Check the rule for being a suffix rule. If so, store in a hash.
6598 if ((my ($source_suffix, $object_suffix)) = ($target =~ $SUFFIX_RULE_PATTERN))
6600 $suffix_rules{$source_suffix} = $object_suffix;
6601 print "Sources ending in .$source_suffix become .$object_suffix\n"
6603 # Set SUFFIXES from suffix_rules.
6604 push @suffixes, ".$source_suffix", ".$object_suffix";
6611 # See if a target exists.
6615 return defined $targets{$target};
6619 ################################################################
6621 # Read Makefile.am and set up %contents. Simultaneously copy lines
6622 # from Makefile.am into $output_trailer or $output_vars as
6623 # appropriate. NOTE we put rules in the trailer section. We want
6624 # user rules to come after our generated stuff.
6629 my $am_file = new Automake::XFile ("< $amfile");
6630 print "$me: reading $amfile\n" if $verbose;
6636 while ($_ = $am_file->getline)
6638 if (/$IGNORE_PATTERN/o)
6640 # Merely delete comments beginning with two hashes.
6642 elsif (/$WHITE_PATTERN/o)
6644 # Stick a single white line before the incoming macro or rule.
6648 elsif (/$COMMENT_PATTERN/o)
6650 # Stick comments before the incoming macro or rule. Make
6651 # sure a blank line preceeds first block of comments.
6652 $spacing = "\n" unless $blank;
6654 $comment .= $spacing . $_;
6663 $output_vars .= $comment . "\n";
6667 # We save the conditional stack on entry, and then check to make
6668 # sure it is the same on exit. This lets us conditonally include
6670 my @saved_cond_stack = @cond_stack;
6671 my $cond = conditional_string (@cond_stack);
6675 my $last_var_name = '';
6676 my $last_var_type = '';
6677 my $last_var_value = '';
6678 # FIXME: shouldn't use $_ in this loop; it is too big.
6682 unless substr ($_, -1, 1) eq "\n";
6684 # Don't look at MAINTAINER_MODE_TRUE here. That shouldn't be
6685 # used by users. @MAINT@ is an anachronism now.
6686 $_ =~ s/\@MAINT\@//g
6687 unless $seen_maint_mode;
6689 my $new_saw_bk = /\\$/ && ! /$COMMENT_PATTERN/o;
6691 if (/$IGNORE_PATTERN/o)
6693 # Merely delete comments beginning with two hashes.
6695 elsif (/$WHITE_PATTERN/o)
6697 # Stick a single white line before the incoming macro or rule.
6699 &am_line_error ($., "blank line following trailing backslash")
6702 elsif (/$COMMENT_PATTERN/o)
6704 # Stick comments before the incoming macro or rule.
6705 $comment .= $spacing . $_;
6707 &am_line_error ($., "comment following trailing backslash")
6714 $output_trailer .= &make_condition (@cond_stack);
6715 $output_trailer .= $_;
6719 $last_var_value .= ' '
6720 unless $last_var_value =~ /\s$/;
6721 $last_var_value .= $_;
6725 $var_comment{$last_var_name} .= "$spacing"
6726 if (!defined $var_comment{$last_var_name}
6727 || substr ($var_comment{$last_var_name}, -1) ne "\n");
6728 $var_comment{$last_var_name} .= "$comment";
6729 $comment = $spacing = '';
6730 macro_define ($last_var_name, 0,
6731 $last_var_type, $cond,
6732 $last_var_value, $.)
6733 if $cond ne 'FALSE';
6734 push (@var_list, $last_var_name);
6739 elsif (/$IF_PATTERN/o)
6741 $cond = cond_stack_if ($1, $2, "$amfile:$.");
6743 elsif (/$ELSE_PATTERN/o)
6745 $cond = cond_stack_else ($1, $2, "$amfile:$.");
6747 elsif (/$ENDIF_PATTERN/o)
6749 $cond = cond_stack_endif ($1, $2, "$amfile:$.");
6752 elsif (/$RULE_PATTERN/o)
6757 rule_define ($1, 0, $cond, $.);
6760 $output_trailer .= $comment . $spacing;
6761 $output_trailer .= &make_condition (@cond_stack);
6762 $output_trailer .= $_;
6763 $comment = $spacing = '';
6765 elsif (/$ASSIGNMENT_PATTERN/o)
6767 # Found a macro definition.
6769 $last_var_name = $1;
6770 $last_var_type = $2;
6771 $last_var_value = $3;
6772 if ($3 ne '' && substr ($3, -1) eq "\\")
6774 # We preserve the `\' because otherwise the long lines
6775 # that are generated will be truncated by broken
6777 $last_var_value = $3 . "\n";
6782 # FIXME: this doesn't always work correctly; it will
6783 # group all comments for a given variable, no matter
6785 # Accumulating variables must not be output.
6786 $var_comment{$last_var_name} .= "$spacing"
6787 if (!defined $var_comment{$last_var_name}
6788 || substr ($var_comment{$last_var_name}, -1) ne "\n");
6789 $var_comment{$last_var_name} .= "$comment";
6790 $comment = $spacing = '';
6792 macro_define ($last_var_name, 0,
6793 $last_var_type, $cond,
6794 $last_var_value, $.)
6795 if $cond ne 'FALSE';
6796 push (@var_list, $last_var_name);
6799 elsif (/$INCLUDE_PATTERN/o)
6803 if ($path =~ s/^\$\(top_srcdir\)\///)
6805 push (@include_stack, "\$\(top_srcdir\)/$path");
6809 $path =~ s/\$\(srcdir\)\///;
6810 push (@include_stack, "\$\(srcdir\)/$path");
6811 $path = $relative_dir . "/" . $path;
6813 &read_am_file ($path);
6817 # This isn't an error; it is probably a continued rule.
6818 # In fact, this is what we assume.
6820 $output_trailer .= $comment . $spacing;
6821 $output_trailer .= &make_condition (@cond_stack);
6822 $output_trailer .= $_;
6823 $comment = $spacing = '';
6824 &am_line_error ($., "`#' comment at start of rule is unportable")
6825 if $_ =~ /^\t\s*\#/;
6828 $saw_bk = $new_saw_bk;
6829 $_ = $am_file->getline;
6832 $output_trailer .= $comment;
6834 if (join (' ', @saved_cond_stack) ne join (' ', @cond_stack))
6838 &am_error ("unterminated conditionals: @cond_stack");
6842 # FIXME: better error message here.
6843 &am_error ("conditionals not nested in include file");
6849 # define_standard_variables ()
6850 # ----------------------------
6851 # A helper for read_main_am_file which initializes configure variables
6852 # and variables from header-vars.am. This is a subr so we can call it
6854 sub define_standard_variables
6856 my $saved_output_vars = $output_vars;
6857 my ($comments, undef, $rules) =
6858 file_contents_internal (1, "$libdir/am/header-vars.am");
6860 # This will output the definitions in $output_vars, which we don't
6862 foreach my $var (sort keys %configure_vars)
6864 &define_configure_variable ($var);
6865 push (@var_list, $var);
6868 # ... hence, we restore $output_vars.
6869 $output_vars = $saved_output_vars . $comments . $rules;
6872 # Read main am file.
6873 sub read_main_am_file
6877 # This supports the strange variable tricks we are about to play.
6878 if (scalar keys %var_value > 0)
6881 &prog_error ("variable defined before read_main_am_file");
6884 # Generate copyright header for generated Makefile.in.
6885 # We do discard the output of predefined variables, handled below.
6886 $output_vars = ("# $in_file_name generated by automake "
6887 . $VERSION . " from $am_file_name.\n");
6888 $output_vars .= '# ' . subst ('configure_input') . "\n";
6889 $output_vars .= $gen_copyright;
6891 # We want to predefine as many variables as possible. This lets
6892 # the user set them with `+=' in Makefile.am. However, we don't
6893 # want these initial definitions to end up in the output quite
6894 # yet. So we just load them, but output them later.
6895 &define_standard_variables;
6897 # Read user file, which might override some of our values.
6898 &read_am_file ($amfile);
6900 # Ouput all the Automake variables. If the user changed one, then
6901 # it is now marked as owned by the user.
6902 foreach my $var (uniq @var_list)
6904 # Don't process user variables.
6905 variable_output ($var)
6906 unless !$var_is_am{$var};
6909 # Now dump the user variables that were defined. We do it in the same
6910 # order in which they were defined (skipping duplicates).
6911 foreach my $var (uniq @var_list)
6913 # Don't process Automake variables.
6914 variable_output ($var)
6915 unless $var_is_am{$var};
6919 ################################################################
6922 # &flatten ($STRING)
6923 # ------------------
6924 # Flatten the $STRING and return the result.
6939 # &make_paragraphs ($MAKEFILE, [%TRANSFORM])
6940 # ------------------------------------------
6941 # Load a $MAKEFILE, apply the %TRANSFORM, and return it as a list of
6943 sub make_paragraphs ($%)
6945 my ($file, %transform) = @_;
6947 # Complete %transform with global options and make it a Perl
6950 "s/$IGNORE_PATTERN//gm;"
6951 . transform (%transform,
6953 'CYGNUS' => $cygnus_mode,
6955 => $seen_maint_mode ? subst ('MAINTAINER_MODE_TRUE') : '',
6957 'SHAR' => $options{'dist-shar'} || 0,
6958 'BZIP2' => $options{'dist-bzip2'} || 0,
6959 'ZIP' => $options{'dist-zip'} || 0,
6960 'COMPRESS' => $options{'dist-tarZ'} || 0,
6962 'INSTALL-INFO' => !$options{'no-installinfo'},
6963 'INSTALL-MAN' => !$options{'no-installman'},
6964 'CK-NEWS' => $options{'check-news'} || 0,
6966 'SUBDIRS' => &variable_defined ('SUBDIRS'),
6967 'TOPDIR' => backname ($relative_dir),
6968 'TOPDIR_P' => $relative_dir eq '.',
6969 'CONFIGURE-AC' => $configure_ac,
6971 'BUILD' => $seen_canonical == $AC_CANONICAL_SYSTEM,
6972 'HOST' => $seen_canonical,
6973 'TARGET' => $seen_canonical == $AC_CANONICAL_SYSTEM,
6975 'LIBTOOL' => defined $configure_vars{'LIBTOOL'})
6976 # We don't need more than two consecutive new-lines.
6977 . 's/\n{3,}/\n\n/g';
6979 # Swallow the file and apply the COMMAND.
6980 my $fc_file = new Automake::XFile ("< $file");
6982 print "$me: reading $file\n"
6984 my $saved_dollar_slash = $/;
6986 $_ = $fc_file->getline;
6987 $/ = $saved_dollar_slash;
6992 # Split at unescaped new lines.
6993 my @lines = split (/(?<!\\)\n/, $content);
6996 while (defined ($_ = shift @lines))
6998 my $paragraph = "$_";
6999 # If we are a rule, eat as long as we start with a tab.
7000 if (/$RULE_PATTERN/smo)
7002 while (defined ($_ = shift @lines) && $_ =~ /^\t/)
7004 $paragraph .= "\n$_";
7006 unshift (@lines, $_);
7009 # If we are a comments, eat as much comments as you can.
7010 elsif (/$COMMENT_PATTERN/smo)
7012 while (defined ($_ = shift @lines)
7013 && $_ =~ /$COMMENT_PATTERN/smo)
7015 $paragraph .= "\n$_";
7017 unshift (@lines, $_);
7020 push @res, $paragraph;
7029 # ($COMMENT, $VARIABLES, $RULES)
7030 # &file_contents_internal ($IS_AM, $FILE, [%TRANSFORM])
7031 # -----------------------------------------------------
7032 # Return contents of a file from $libdir/am, automatically skipping
7033 # macros or rules which are already known. $IS_AM iff the caller is
7034 # reading an Automake file (as opposed to the user's Makefile.am).
7035 sub file_contents_internal ($$%)
7037 my ($is_am, $file, %transform) = @_;
7039 my $result_vars = '';
7040 my $result_rules = '';
7044 # We save the conditional stack on entry, and then check to make
7045 # sure it is the same on exit. This lets us conditonally include
7047 my @saved_cond_stack = @cond_stack;
7048 my $cond = conditional_string (@cond_stack);
7050 foreach (make_paragraphs ($file, %transform))
7053 &am_file_error ($file, "blank line following trailing backslash:\n$_")
7055 &am_file_error ($file, "comment following trailing backslash:\n$_")
7060 # Stick empty line before the incoming macro or rule.
7063 elsif (/$COMMENT_PATTERN/mso)
7065 # Stick comments before the incoming macro or rule.
7069 # Handle inclusion of other files.
7070 elsif (/$INCLUDE_PATTERN/o)
7072 if ($cond ne 'FALSE')
7074 my $file = ($is_am ? "$libdir/am/" : '') . $1;
7076 my ($com, $vars, $rules)
7077 = file_contents_internal ($is_am, $file, %transform);
7079 $result_vars .= $vars;
7080 $result_rules .= $rules;
7084 # Handling the conditionals.
7085 elsif (/$IF_PATTERN/o)
7087 $cond = cond_stack_if ($1, $2, $file);
7089 elsif (/$ELSE_PATTERN/o)
7091 $cond = cond_stack_else ($1, $2, $file);
7093 elsif (/$ENDIF_PATTERN/o)
7095 $cond = cond_stack_endif ($1, $2, $file);
7099 elsif (/$RULE_PATTERN/mso)
7101 # Separate relationship from optional actions: the first
7102 # `new-line tab" not preceded by backslash (continuation
7104 # I'm quite shoked! It seems that (\\\n|[^\n]) is not the
7105 # same as `([^\n]|\\\n)!!! Don't swap it, it breaks.
7107 /^((?:\\\n|[^\n])*)(?:\n(\t.*))?$/som;
7108 my ($relationship, $actions) = ($1, $2 || '');
7110 # Separate targets from dependencies: the first colon.
7111 $relationship =~ /^([^:]+\S+) *: *(.*)$/som;
7112 my ($targets, $dependencies) = ($1, $2);
7113 # Remove the escaped new lines.
7114 # I don't know why, but I have to use a tmp $flat_deps.
7115 my $flat_deps = &flatten ($dependencies);
7116 my @deps = split (' ', $flat_deps);
7118 foreach (split (' ' , $targets))
7120 # FIXME: We are not robust to people defining several targets
7121 # at once, only some of them being in %dependencies.
7123 # Output only if not in FALSE.
7124 if (defined $dependencies{$_}
7125 && $cond ne 'FALSE')
7127 &depend ($_, @deps);
7128 $actions{$_} .= $actions;
7132 # Free-lance dependency. Output the rule for all the
7133 # targets instead of one by one.
7135 # Work out all the conditions for which the target hasn't
7137 my @undefined_conds;
7138 if (defined $target_conditional{$targets})
7140 my @defined_conds = keys %{$target_conditional{$targets}};
7141 @undefined_conds = invert_conditions(@defined_conds);
7145 if (defined $targets{$targets})
7147 # No conditions for which target hasn't been defined
7148 @undefined_conds = ();
7152 # Target hasn't been defined for any conditions
7153 @undefined_conds = ("");
7157 if ($cond ne 'FALSE')
7160 for $undefined_cond (@undefined_conds)
7162 my $condparagraph = $paragraph;
7163 $condparagraph =~ s/^/make_condition (@cond_stack, $undefined_cond)/gme;
7164 $result_rules .= "$spacing$comment$condparagraph\n"
7165 if rule_define ($targets, $is_am,
7166 "$cond $undefined_cond", $file);
7169 $comment = $spacing = '';
7175 elsif (/$ASSIGNMENT_PATTERN/mso)
7177 my ($var, $type, $val) = ($1, $2, $3);
7178 &am_file_error ($file, "macro `$var' with trailing backslash")
7181 # Accumulating variables must not be output.
7182 $var_comment{$var} .= "$spacing"
7183 if (!defined $var_comment{$var}
7184 || substr ($var_comment{$var}, -1) ne "\n");
7185 $var_comment{$var} .= "$comment";
7186 macro_define ($var, $is_am, $type, $cond, $val, $file)
7187 if $cond ne 'FALSE';
7188 push (@var_list, $var);
7190 # If the user has set some variables we were in charge
7191 # of (which is detected by the first reading of
7192 # `header-vars.am'), we must not output them.
7193 $result_vars .= "$spacing$comment$_\n"
7194 if $type ne '+' && $var_is_am{$var} && $cond ne 'FALSE';
7196 $comment = $spacing = '';
7200 # This isn't an error; it is probably some tokens which
7201 # configure is supposed to replace, such as `@SET-MAKE@',
7202 # or some part of a rule cut by an if/endif.
7203 if ($cond ne 'FALSE')
7205 s/^/make_condition (@cond_stack)/gme;
7206 $result_rules .= "$spacing$comment$_\n";
7208 $comment = $spacing = '';
7212 if (join (' ', @saved_cond_stack) ne join (' ', @cond_stack))
7216 &am_error ("unterminated conditionals: @cond_stack");
7220 # FIXME: better error message here.
7221 &am_error ("conditionals not nested in include file");
7225 return ($comment, $result_vars, $result_rules);
7230 # &file_contents ($BASENAME, [%TRANSFORM])
7231 # ----------------------------------------
7232 # Return contents of a file from $libdir/am, automatically skipping
7233 # macros or rules which are already known.
7234 sub file_contents ($%)
7236 my ($basename, %transform) = @_;
7237 my ($comments, $variables, $rules) =
7238 file_contents_internal (1, "$libdir/am/$basename.am", %transform);
7239 return "$comments$variables$rules";
7244 # &transform (%PAIRS)
7245 # -------------------
7246 # Foreach ($TOKEN, $VAL) in %PAIRS produce a replacement expression suitable
7247 # for file_contents which:
7248 # - replaces @$TOKEN@ with $VALUE,
7249 # - enables/disables ?$TOKEN?.
7255 while (my ($token, $val) = each %pairs)
7257 $result .= "s/\Q%$token%\E/\Q$val\E/gm;";
7260 $result .= "s/\Q?$token?\E//gm;s/^.*\Q?!$token?\E.*\\n//gm;";
7261 $result .= "s/\Q%?$token%\E/TRUE/gm;";
7265 $result .= "s/\Q?!$token?\E//gm;s/^.*\Q?$token?\E.*\\n//gm;";
7266 $result .= "s/\Q%?$token%\E/FALSE/gm;";
7274 # Find all variable prefixes that are used for install directories. A
7275 # prefix `zar' qualifies iff:
7276 # * `zardir' is a variable.
7277 # * `zar_PRIMARY' is a variable.
7278 sub am_primary_prefixes
7280 my ($primary, $can_dist, @prefixes) = @_;
7282 my %valid = map { $_ => 0 } @prefixes;
7283 $valid{'EXTRA'} = 0;
7284 foreach my $varname (keys %var_value)
7286 # Automake is allowed to define variables that look like they
7287 # are magic variables, such as INSTALL_DATA.
7289 if $var_is_am{$varname};
7291 if ($varname =~ /^(nobase_)?(dist_|nodist_)?(.*)_$primary$/)
7293 my ($base, $dist, $X) = ($1 || '', $2 || '', $3 || '');
7294 if ($dist ne '' && ! $can_dist)
7296 # Note that a configure variable is always legitimate.
7297 # It is natural to name such variables after the
7298 # primary, so we explicitly allow it.
7299 if (! defined $configure_vars{$varname})
7301 &am_line_error ($varname,
7302 "invalid variable `$varname': `dist' is forbidden");
7305 elsif (! defined $valid{$X} && ! &variable_defined ("${X}dir"))
7307 # Note that a configure variable is always legitimate.
7308 # It is natural to name such variables after the
7309 # primary, so we explicitly allow it.
7310 if (! defined $configure_vars{$varname})
7312 &am_line_error ($varname,
7313 "invalid variable `$varname'");
7318 # Ensure all extended prefixes are actually used.
7319 $valid{"$base$dist$X"} = 1;
7327 # Handle `where_HOW' variable magic. Does all lookups, generates
7328 # install code, and possibly generates code to define the primary
7329 # variable. The first argument is the name of the .am file to munge,
7330 # the second argument is the primary variable (eg HEADERS), and all
7331 # subsequent arguments are possible installation locations. Returns
7332 # list of all values of all _HOW targets.
7334 # FIXME: this should be rewritten to be cleaner. It should be broken
7335 # up into multiple functions.
7337 # Usage is: am_install_var (OPTION..., file, HOW, where...)
7344 my $default_dist = 0;
7347 if ($args[0] eq '-noextra')
7351 elsif ($args[0] eq '-candist')
7355 elsif ($args[0] eq '-defaultdist')
7360 elsif ($args[0] !~ /^-/)
7367 my ($file, $primary, @prefixes) = @args;
7369 # Now that configure substitutions are allowed in where_HOW
7370 # variables, it is an error to actually define the primary. We
7371 # allow `JAVA', as it is customarily used to mean the Java
7372 # interpreter. This is but one of several Java hacks. Similarly,
7373 # `PYTHON' is customarily used to mean the Python interpreter.
7374 &am_line_error ($primary, "`$primary' is an anachronism")
7375 if &variable_defined ($primary)
7376 && ($primary ne 'JAVA' && $primary ne 'PYTHON');
7379 # Look for misspellings. It is an error to have a variable ending
7380 # in a "reserved" suffix whose prefix is unknown, eg
7381 # "bni_PROGRAMS". However, unusual prefixes are allowed if a
7382 # variable of the same name (with "dir" appended) exists. For
7383 # instance, if the variable "zardir" is defined, then
7384 # "zar_PROGRAMS" becomes valid. This is to provide a little extra
7385 # flexibility in those cases which need it.
7386 my %valid = &am_primary_prefixes ($primary, $can_dist, @prefixes);
7388 # If a primary includes a configure substitution, then the EXTRA_
7389 # form is required. Otherwise we can't properly do our job.
7391 my $warned_about_extra = 0;
7396 # True if the iteration is the first one. Used for instance to
7397 # output parts of the associated file only once.
7399 foreach my $X (sort keys %valid)
7401 my $nodir_name = $X;
7402 my $one_name = $X . '_' . $primary;
7404 unless (&variable_defined ($one_name));
7406 my $strip_subdir = 1;
7407 # If subdir prefix should be preserved, do so.
7408 if ($nodir_name =~ /^nobase_/)
7411 $nodir_name =~ s/^nobase_//;
7414 # If files should be distributed, do so.
7418 $dist_p = (($default_dist && $nodir_name !~ /^nodist_/)
7419 || (! $default_dist && $nodir_name =~ /^dist_/));
7420 $nodir_name =~ s/^(dist|nodist)_//;
7423 # Append actual contents of where_PRIMARY variable to
7425 foreach my $rcurs (&variable_value_as_list_recursive ($one_name, 'all'))
7427 # Skip configure substitutions. Possibly bogus.
7428 if ($rcurs =~ /^\@.*\@$/)
7430 if ($nodir_name eq 'EXTRA')
7432 if (! $warned_about_extra)
7434 $warned_about_extra = 1;
7435 &am_line_error ($one_name,
7436 "`$one_name' contains configure substitution, but shouldn't");
7439 # Check here to make sure variables defined in
7440 # configure.ac do not imply that EXTRA_PRIMARY
7442 elsif (! defined $configure_vars{$one_name})
7444 $require_extra = $one_name
7451 push (@result, $rcurs);
7454 # A blatant hack: we rewrite each _PROGRAMS primary to include
7456 if ($primary eq 'PROGRAMS')
7458 my @conds = variable_conditions_recursive ($one_name);
7461 foreach my $cond (@conds)
7463 my @one_binlist = ();
7464 my @condval = &variable_value_as_list_recursive ($one_name,
7466 foreach my $rcurs (@condval)
7468 # Skip autoconf substs. Also skip if the user
7469 # already applied $(EXEEXT).
7470 if ($rcurs =~ /^\@.*\@$/ || $rcurs =~ /\$\(EXEEXT\)$/)
7472 push (@one_binlist, $rcurs);
7476 push (@one_binlist, $rcurs . '$(EXEEXT)');
7480 push (@condvals, $cond);
7481 push (@condvals, join (' ', @one_binlist));
7484 variable_delete ($one_name);
7487 my $cond = shift (@condvals);
7488 my @val = split (' ', shift (@condvals));
7489 define_pretty_variable ($one_name, $cond, @val);
7493 # "EXTRA" shouldn't be used when generating clean targets,
7494 # all, or install targets.
7495 if ($nodir_name eq 'EXTRA')
7497 # We used to warn if EXTRA_FOO was defined uselessly,
7498 # but this was annoying.
7502 if ($nodir_name eq 'check')
7504 push (@check, '$(' . $one_name . ')');
7508 push (@used, '$(' . $one_name . ')');
7511 # Is this to be installed?
7512 my $install_p = $nodir_name ne 'noinst' && $nodir_name ne 'check';
7514 # If so, with install-exec? (or install-data?).
7515 my $exec_p = (defined $exec_dir_p {$nodir_name}
7516 ? $exec_dir_p {$nodir_name}
7517 : ($nodir_name =~ /exec/));
7519 # Singular form of $PRIMARY.
7520 (my $one_primary = $primary) =~ s/S$//;
7521 $output_rules .= &file_contents ($file,
7524 'PRIMARY' => $primary,
7525 'ONE_PRIMARY' => $one_primary,
7527 'NDIR' => $nodir_name,
7528 'BASE' => $strip_subdir,
7531 'INSTALL' => $install_p,
7532 'DIST' => $dist_p));
7537 # The JAVA variable is used as the name of the Java interpreter.
7538 # The PYTHON variable is used as the name of the Python interpreter.
7539 if (@used && $primary ne 'JAVA' && $primary ne 'PYTHON')
7542 define_pretty_variable ($primary, '', @used);
7543 $output_vars .= "\n";
7546 if ($require_extra && ! &variable_defined ('EXTRA_' . $primary))
7548 &am_line_error ($require_extra,
7549 "`$require_extra' contains configure substitution, but `EXTRA_$primary' not defined");
7552 # Push here because PRIMARY might be configure time determined.
7553 push (@all, '$(' . $primary . ')')
7554 if @used && $primary ne 'JAVA' && $primary ne 'PYTHON';
7556 # Make the result unique. This lets the user use conditionals in
7557 # a natural way, but still lets us program lazily -- we don't have
7558 # to worry about handling a particular object more than once.
7559 return uniq (sort @result);
7563 ################################################################
7565 # Each key in this hash is the name of a directory holding a
7566 # Makefile.in. These variables are local to `is_make_dir'.
7568 my $make_dirs_set = 0;
7573 if (! $make_dirs_set)
7575 foreach my $iter (@configure_input_files)
7577 $make_dirs{dirname ($iter)} = 1;
7579 # We also want to notice Makefile.in's.
7580 foreach my $iter (@other_input_files)
7582 if ($iter =~ /Makefile\.in$/)
7584 $make_dirs{dirname ($iter)} = 1;
7589 return defined $make_dirs{$dir};
7592 ################################################################
7594 # This variable is local to the "require file" set of functions.
7595 my @require_file_paths = ();
7597 # If a file name appears as a key in this hash, then it has already
7598 # been checked for. This variable is local to the "require file"
7600 %require_file_found = ();
7602 # See if we want to push this file onto dist_common. This function
7603 # encodes the rules for deciding when to do so.
7604 sub maybe_push_required_file
7606 my ($dir, $file, $fullfile) = @_;
7608 if ($dir eq $relative_dir)
7610 &push_dist_common ($file);
7612 elsif ($relative_dir eq '.' && ! &is_make_dir ($dir))
7614 # If we are doing the topmost directory, and the file is in a
7615 # subdir which does not have a Makefile, then we distribute it
7617 &push_dist_common ($fullfile);
7622 # &require_file_internal ($IS_CONFIGURE, $LINE, $MYSTRICT, @FILES)
7623 # ----------------------------------------------------------------
7624 # Verify that the file must exist in the current directory.
7625 # $MYSTRICT is the strictness level at which this file becomes required.
7627 # Must set require_file_paths before calling this function.
7628 # require_file_paths is set to hold a single directory (the one in
7629 # which the first file was found) before return.
7630 sub require_file_internal
7632 my ($is_configure, $line, $mystrict, @files) = @_;
7634 foreach my $file (@files)
7642 my $dangling_sym = 0;
7643 foreach my $dir (@require_file_paths)
7645 $fullfile = $dir . "/" . $file;
7646 $errdir = $dir unless $errdir;
7648 # Use different name for "error filename". Otherwise on
7649 # an error the bad file will be reported as eg
7650 # `../../install-sh' when using the default
7652 $errfile = $errdir . '/' . $file;
7654 if (-l $fullfile && ! -f $fullfile)
7659 elsif (-f $fullfile)
7662 &maybe_push_required_file ($dir, $file, $fullfile);
7668 # `--force-missing' only has an effect if `--add-missing' is
7670 if ($found_it && (! $add_missing || ! $force_missing))
7672 # Prune the path list.
7673 @require_file_paths = $save_dir;
7677 # If we've already looked for it, we're done. You might
7678 # wonder why we don't do this before searching for the
7679 # file. If we do that, then something like
7680 # AC_OUTPUT(subdir/foo foo) will fail to put foo.in into
7684 next if defined $require_file_found{$file};
7685 $require_file_found{$file} = 1;
7688 if ($strictness >= $mystrict)
7690 if ($dangling_sym && $add_missing)
7698 # Only install missing files according to our desired
7700 my $message = "required file `$errfile' not found";
7705 # Maybe run libtoolize.
7706 my @syslist = ('libtoolize', '--automake');
7707 push @syslist, '--copy'
7710 && grep ($_ eq $file, @libtoolize_files)
7711 && system (@syslist))
7713 $message = "installing `$errfile'";
7715 $trailer = "; cannot run `libtoolize': $!";
7717 elsif (-f ("$libdir/$file"))
7719 # Install the missing file. Symlink if we
7720 # can, copy if we must. Note: delete the file
7721 # first, in case it is a dangling symlink.
7722 $message = "installing `$errfile'";
7723 # Windows Perl will hang if we try to delete a
7724 # file that doesn't exist.
7725 unlink ($errfile) if -f $errfile;
7726 if ($symlink_exists && ! $copy_missing)
7728 if (! symlink ("$libdir/$file", $errfile))
7731 $trailer = "; error while making link: $!";
7734 elsif (system ('cp', "$libdir/$file", $errfile))
7737 $trailer = "\n error while copying";
7741 &maybe_push_required_file (dirname ($errfile),
7744 # Prune the path list.
7745 @require_file_paths = &dirname ($errfile);
7748 # If --force-missing was specified, and we have
7749 # actually found the file, then do nothing.
7751 if $found_it && $force_missing;
7757 # FIXME: allow actual file to be specified.
7758 &am_conf_line_warning ($configure_ac, $line,
7759 "$message$trailer");
7763 &am_line_warning ($line, "$message$trailer");
7770 # FIXME: allow actual file to be specified.
7771 &am_conf_line_error ($configure_ac, $line,
7772 "$message$trailer");
7776 &am_line_error ($line, "$message$trailer");
7784 # Like require_file_with_line, but error messages refer to
7785 # configure.ac, not the current Makefile.am.
7786 sub require_file_with_conf_line
7788 @require_file_paths = $relative_dir;
7789 &require_file_internal (1, @_);
7792 sub require_file_with_line
7794 @require_file_paths = $relative_dir;
7795 &require_file_internal (0, @_);
7800 @require_file_paths = $relative_dir;
7801 &require_file_internal (0, '', @_);
7804 # Require an auxiliary file.
7805 # Looks in configuration path, as specified by AC_CONFIG_AUX_DIR.
7806 sub require_aux_file_with_line
7808 my $from = shift; # 1 for configure.ac, 0 for Makefile.am
7810 @require_file_paths = @config_aux_path;
7811 &require_file_internal ($from, $line, @_);
7812 my $dir = $require_file_paths[0];
7813 # &require_file_internal pruned the file path to the
7814 # exact directory where the file is lying. Update
7815 # @config_aux_path to speed up future uses.
7816 @config_aux_path = @require_file_paths;
7817 # Avoid unsightly '/.'s.
7818 $config_aux_dir = '$(top_srcdir)' . ($dir eq '.' ? "" : "/$dir");
7821 # Assumes that the line number is in Makefile.am.
7822 sub require_conf_file_with_line
7824 &require_aux_file_with_line (0, @_);
7827 # File required from a Makefile.am. No line number available.
7828 sub require_conf_file
7830 &require_conf_file_with_line ('', @_);
7833 # Assumes that the line number is in configure.ac.
7834 sub require_conf_file_with_conf_line
7836 &require_aux_file_with_line (1, @_);
7839 # Require a file that is also required by Autoconf. No line number available.
7840 sub require_config_file
7842 &require_conf_file_with_conf_line ('', @_);
7845 ################################################################
7847 # &require_build_directory ($DIRECTORY)
7848 # ------------------------------------
7849 # Emit rules to create $DIRECTORY if needed, and return
7850 # the file that any target requiring this directory should be made
7852 sub require_build_directory ($)
7854 my $directory = shift;
7855 my $dirstamp = "$directory/.dirstamp";
7857 # Don't emit the rule twice.
7858 if (! defined $directory_map{$directory})
7860 $directory_map{$directory} = 1;
7862 # Directory must be removed by `make distclean'.
7863 $compile_clean_files{$dirstamp} = $DIST_CLEAN;
7865 $output_rules .= ("$dirstamp:\n"
7866 . "\t\@\$(mkinstalldirs) $directory\n"
7867 . "\t\@: > $dirstamp\n");
7873 # &require_build_directory_maybe ($FILE)
7874 # --------------------------------------
7875 # If $FILE lies in a subdirectory, emit a rule to create this
7876 # directory and return the file that $FILE should be made
7877 # dependent upon. Otherwise, just return the empty string.
7878 sub require_build_directory_maybe ($)
7881 my $directory = dirname ($file);
7883 if ($directory ne '.')
7885 return &require_build_directory ($directory);
7893 ################################################################
7895 # Push a list of files onto dist_common.
7896 sub push_dist_common
7898 &prog_error ("push_dist_common run after handle_dist")
7899 if $handle_dist_run;
7900 macro_define ('DIST_COMMON', 1, '+', '', join (' ', @_), '');
7907 $strictness_name = $_[0];
7908 if ($strictness_name eq 'gnu')
7912 elsif ($strictness_name eq 'gnits')
7914 $strictness = $GNITS;
7916 elsif ($strictness_name eq 'foreign')
7918 $strictness = $FOREIGN;
7922 die "$me: level `$strictness_name' not recognized\n";
7927 ################################################################
7929 # Ensure a file exists.
7934 my $touch = new IO::File (">> $file");
7938 # Glob something. Do this to avoid indentation screwups everywhere we
7939 # want to glob. Gross!
7946 # Remove one level of brackets and strip leading spaces,
7947 # as does m4 to function arguments.
7953 my @letters = split //;
7962 next if $depth == 1;
7967 next if $depth == 0;
7968 # don't count orphan right brackets
7969 $depth = 0 if $depth < 0;
7973 return join '', @result;
7976 ################################################################
7978 # am_print_error ($LEADER, @ARGS)
7979 # -------------------------------
7980 # Do the work of printing the error message. Join @ARGS with spaces,
7981 # then split at newlines and add $LEADER to each line. Uses `warn' to
7985 my ($leader, @args) = @_;
7986 my $text = join (' ', @args);
7987 @args = split ("\n", $text);
7988 $text = $leader . join ("\n" . $leader, @args) . "\n";
7992 # Print an error message and set exit status.
7995 am_print_error ("$me: ${am_file}.am: ", @_);
7999 # am_file_error ($FILE, @ARGS)
8000 # ----------------------------
8003 my ($file, @args) = @_;
8005 am_print_error ("$file: ", @args);
8011 my ($symbol, @args) = @_;
8013 if ($symbol && "$symbol" ne '-1')
8015 my $file = "${am_file}.am";
8017 if ($symbol =~ /^\d+$/)
8019 # SYMBOL is a line number, so just add the colon.
8020 $file .= ':' . $symbol;
8022 elsif (defined $var_line{$symbol})
8024 # SYMBOL is a variable defined in Makefile.am, so add the
8025 # line number we saved from there.
8026 $file .= ':' . $var_line{$symbol};
8028 elsif (defined $configure_vars{$symbol})
8030 # SYMBOL is a variable defined in configure.ac, so add the
8031 # appropriate line number.
8032 $file = $configure_vars{$symbol};
8036 # Couldn't find the line number.
8039 am_print_error ("$file: ", @args);
8048 # Like am_error, but while scanning configure.ac.
8051 # FIXME: can run in subdirs.
8052 am_print_error ("$me: $configure_ac: ", @_);
8056 # Error message with line number referring to configure.ac.
8057 sub am_conf_line_error
8059 my ($file, $line, @args) = @_;
8063 am_print_error ("$file: $line: ", @args);
8068 &am_conf_error (@args);
8072 # Warning message with line number referring to configure.ac.
8073 # Does not affect exit_status
8074 sub am_conf_line_warning
8076 my $saved_exit_status = $exit_status;
8077 my $sig = $SIG{'__WARN__'};
8078 $SIG{'__WARN__'} = 'DEFAULT';
8079 am_conf_line_error (@_);
8080 $exit_status = $saved_exit_status;
8081 $SIG{'__WARN__'} = $sig;
8084 # Like am_line_error, but doesn't affect exit status.
8087 my $saved_exit_status = $exit_status;
8088 my $sig = $SIG{'__WARN__'};
8089 $SIG{'__WARN__'} = 'DEFAULT';
8091 $exit_status = $saved_exit_status;
8092 $SIG{'__WARN__'} = $sig;
8095 # Tell user where our aclocal.m4 is, but only once.
8096 sub keyed_aclocal_warning
8099 warn "$me: macro `$key' can be generated by `aclocal'\n";
8102 # Print usage information.
8106 Usage: $0 [OPTION] ... [Makefile]...
8108 Generate Makefile.in for configure from Makefile.am.
8111 --help print this help, then exit
8112 --version print version number, then exit
8113 -v, --verbose verbosely list files processed
8114 -o, --output-dir=DIR put generated Makefile.in's into DIR
8115 --no-force only update Makefile.in's that are out of date
8117 Dependency tracking:
8118 -i, --ignore-deps disable dependency tracking code
8119 --include-deps enable dependency tracking code
8122 --cygnus assume program is part of Cygnus-style tree
8123 --foreign set strictness to foreign
8124 --gnits set strictness to gnits
8125 --gnu set strictness to gnu
8128 -a, --add-missing add missing standard files to package
8129 --libdir=DIR directory storing library files
8130 -c, --copy with -a, copy missing files (default is symlink)
8131 -f, --force-missing force update of standard files
8136 foreach my $iter (sort ((@common_files, @common_sometimes)))
8138 push (@lcomm, $iter) unless $iter eq $last;
8143 print "\nFiles which are automatically distributed, if found:\n";
8144 format USAGE_FORMAT =
8145 @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<
8146 $four[0], $four[1], $four[2], $four[3]
8148 $~ = "USAGE_FORMAT";
8151 my $rows = int(@lcomm / $cols);
8152 my $rest = @lcomm % $cols;
8163 for (my $y = 0; $y < $rows; $y++)
8165 @four = ("", "", "", "");
8166 for (my $x = 0; $x < $cols; $x++)
8168 last if $y + 1 == $rows && $x == $rest;
8170 my $idx = (($x > $rest)
8171 ? ($rows * $rest + ($rows - 1) * ($x - $rest))
8175 $four[$x] = $lcomm[$idx];
8180 print "\nReport bugs to <bug-automake\@gnu.org>.\n";
8187 # Print version information
8191 automake (GNU $PACKAGE) $VERSION
8192 Written by Tom Tromey <tromey\@cygnus.com>.
8194 Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
8195 Free Software Foundation, Inc.
8196 This is free software; see the source for copying conditions. There is NO
8197 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.