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} (@_);
113 use strict 'vars', 'subs';
114 use Automake::General;
123 # Parameters set by configure. Not to be changed. NOTE: assign
124 # VERSION as string so that eg version 0.30 will print correctly.
125 my $VERSION = "@VERSION@";
126 my $PACKAGE = "@PACKAGE@";
127 my $prefix = "@prefix@";
128 my $libdir = "@datadir@/@PACKAGE@";
131 my $IGNORE_PATTERN = '^\s*##([^#\n].*)?\n';
132 my $WHITE_PATTERN = '^\s*$';
133 my $COMMENT_PATTERN = '^#';
134 my $TARGET_PATTERN='[$a-zA-Z_.@][-.a-zA-Z0-9_(){}/$+@]*';
135 # A rule has three parts: a list of targets, a list of dependencies,
136 # and optionally actions.
138 "^($TARGET_PATTERN(?:(?:\\\\\n|\\s)+$TARGET_PATTERN)*) *:([^=].*|)\$";
140 my $SUFFIX_RULE_PATTERN = '^\.([a-zA-Z0-9+]+)\.([a-zA-Z0-9+]+)$';
141 # Only recognize leading spaces, not leading tabs. If we recognize
142 # leading tabs here then we need to make the reader smarter, because
143 # otherwise it will think rules like `foo=bar; \' are errors.
144 my $MACRO_PATTERN = '^[A-Za-z0-9_@]+$';
145 my $ASSIGNMENT_PATTERN = '^ *([^ \t=:+]*)\s*([:+]?)=\s*(.*)$';
146 # This pattern recognizes a Gnits version id and sets $1 if the
147 # release is an alpha release. We also allow a suffix which can be
148 # used to extend the version number with a "fork" identifier.
149 my $GNITS_VERSION_PATTERN = '\d+\.\d+([a-z]|\.\d+)?(-[A-Za-z0-9]+)?';
150 my $IF_PATTERN = '^if\s+(!?)\s*([A-Za-z][A-Za-z0-9_]*)\s*(?:#.*)?$';
151 my $ELSE_PATTERN = '^else(?:\s+(!?)\s*([A-Za-z][A-Za-z0-9_]*))?\s*(?:#.*)?$';
152 my $ENDIF_PATTERN = '^endif(?:\s+(!?)\s*([A-Za-z][A-Za-z0-9_]*))?\s*(?:#.*)?$';
153 my $PATH_PATTERN='(\w|[/.-])+';
154 # This will pass through anything not of the prescribed form.
155 my $INCLUDE_PATTERN = ('^include\s+'
156 . '((\$\(top_srcdir\)/' . $PATH_PATTERN . ')'
157 . '|(\$\(srcdir\)/' . $PATH_PATTERN . ')'
158 . '|([^/\$]' . $PATH_PATTERN. '))\s*(#.*)?$');
160 # Some regular expressions. One reason to put them here is that it
161 # makes indentation work better in Emacs.
162 my $AC_CONFIG_AUX_DIR_PATTERN = 'AC_CONFIG_AUX_DIR\(([^)]+)\)';
163 my $AM_INIT_AUTOMAKE_PATTERN = 'AM_INIT_AUTOMAKE\([^,]*,([^,)]+)[,)]';
164 my $AM_PACKAGE_VERSION_PATTERN = '^\s*\[?([^]\s]+)\]?\s*$';
166 # This handles substitution references like ${foo:.a=.b}.
167 my $SUBST_REF_PATTERN = "^([^:]*):([^=]*)=(.*)\$";
169 # Note that there is no AC_PATH_TOOL. But we don't really care.
170 my $AC_CHECK_PATTERN = 'AC_(CHECK|PATH)_(PROG|PROGS|TOOL)\(\[?(\w+)';
171 my $AM_MISSING_PATTERN = 'AM_MISSING_PROG\(\[?(\w+)';
172 # Just check for alphanumeric in AC_SUBST. If you do AC_SUBST(5),
174 my $AC_SUBST_PATTERN = 'AC_SUBST\(\[?(\w+)';
175 my $AM_CONDITIONAL_PATTERN = 'AM_CONDITIONAL\(\[?(\w+)';
176 # Match `-d' as a command-line argument in a string.
177 my $DASH_D_PATTERN = "(^|\\s)-d(\\s|\$)";
179 # Constants to define the "strictness" level.
184 # Values for AC_CANONICAL_*
185 my $AC_CANONICAL_HOST = 1;
186 my $AC_CANONICAL_SYSTEM = 2;
188 # Values indicating when something should be cleaned. Right now we
189 # only need to handle `mostly'- and `dist'-clean; add more as
191 my $MOSTLY_CLEAN = 0;
194 # Files installed by libtoolize.
195 my @libtoolize_files = ('ltmain.sh', 'config.guess', 'config.sub');
196 # ltconfig appears here for compatibility with old versions of libtool.
197 my @libtoolize_sometimes = ('ltconfig', 'ltcf-c.sh', 'ltcf-cxx.sh',
200 # Commonly found files we look for and automatically include in
204 'README', 'THANKS', 'TODO', 'NEWS', 'COPYING', 'COPYING.LIB',
205 'INSTALL', 'ABOUT-NLS', 'ChangeLog', 'configure.ac',
206 'configure.in', 'configure', 'config.guess', 'config.sub',
207 'AUTHORS', 'BACKLOG', 'ABOUT-GNU', 'libversion.in',
208 'mdate-sh', 'mkinstalldirs', 'install-sh', 'texinfo.tex',
209 'ansi2knr.c', 'ansi2knr.1', 'elisp-comp',
210 # ltconfig appears here for compatibility with old versions
212 'ylwrap', 'acinclude.m4', @libtoolize_files, @libtoolize_sometimes,
213 'missing', 'depcomp', 'compile', 'py-compile'
216 # Commonly used files we auto-include, but only sometimes.
217 my @common_sometimes =
219 'aclocal.m4', 'acconfig.h', 'config.h.top',
220 'config.h.bot', 'stamp-h.in', 'stamp-vti'
223 # Copyright on generated Makefile.ins.
224 my $gen_copyright = "\
225 # Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
226 # Free Software Foundation, Inc.
227 # This Makefile.in is free software; the Free Software Foundation
228 # gives unlimited permission to copy and/or distribute it,
229 # with or without modifications, as long as this notice is preserved.
231 # This program is distributed in the hope that it will be useful,
232 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
233 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
234 # PARTICULAR PURPOSE.
237 # These constants are returned by lang_*_rewrite functions.
238 # LANG_SUBDIR means that the resulting object file should be in a
239 # subdir if the source file is. In this case the file name cannot
240 # have `..' components.
242 my $LANG_PROCESS = 1;
245 # Directories installed during 'install-exec' phase.
264 # Map from obsolete macros to hints for new macros.
265 # If you change this, change the corresponding list in aclocal.in.
266 # FIXME: should just put this into a single file.
267 my %obsolete_macros =
269 'AC_FEATURE_CTYPE' => "use `AC_HEADER_STDC'",
270 'AC_FEATURE_ERRNO' => "add `strerror' to `AC_REPLACE_FUNCS(...)'",
271 'AC_FEATURE_EXIT' => '',
272 'AC_SYSTEM_HEADER' => '',
274 # Note that we do not handle this one, because it is still run
275 # from AM_CONFIG_HEADER. So we deal with it specially in
276 # &scan_autoconf_files.
277 # 'AC_CONFIG_HEADER' => "use `AM_CONFIG_HEADER'",
279 'fp_C_PROTOTYPES' => "use `AM_C_PROTOTYPES'",
280 'fp_PROG_CC_STDC' => "use `AM_PROG_CC_STDC'",
281 'fp_PROG_INSTALL' => "use `AC_PROG_INSTALL'",
282 'fp_WITH_DMALLOC' => "use `AM_WITH_DMALLOC'",
283 'fp_WITH_REGEX' => "use `AM_WITH_REGEX'",
284 'gm_PROG_LIBTOOL' => "use `AM_PROG_LIBTOOL'",
285 'jm_MAINTAINER_MODE' => "use `AM_MAINTAINER_MODE'",
286 'md_TYPE_PTRDIFF_T' => "add `ptrdiff_t' to `AC_CHECK_TYPES(...)'",
287 'ud_PATH_LISPDIR' => "use `AM_PATH_LISPDIR'",
288 'ud_GNU_GETTEXT' => "use `AM_GNU_GETTEXT'",
290 # Now part of autoconf proper, under a different name.
291 'fp_FUNC_FNMATCH' => "use `AC_FUNC_FNMATCH'",
292 'AM_SANITY_CHECK_CC' => "automatically done by `AC_PROG_CC'",
293 'AM_PROG_INSTALL' => "use `AC_PROG_INSTALL'",
294 'AM_EXEEXT' => "automatically done by `AC_PROG_(CC|CXX|F77)'",
295 'AM_CYGWIN32' => "use `AC_CYGWIN'",
296 'AM_MINGW32' => "use `AC_MINGW32'",
297 'AM_FUNC_MKTIME' => "use `AC_FUNC_MKTIME'",
300 # Regexp to match the above macros.
301 my $obsolete_rx = '\b(' . join ('|', keys %obsolete_macros) . ')\b';
305 ## ---------------------------------- ##
306 ## Variables related to the options. ##
307 ## ---------------------------------- ##
309 # TRUE if we should always generate Makefile.in.
310 my $force_generation = 1;
312 # Strictness level as set on command line.
313 my $default_strictness = $GNU;
315 # Name of strictness level, as set on command line.
316 my $default_strictness_name = 'gnu';
318 # This is TRUE if automatic dependency generation code should be
319 # included in generated Makefile.in.
320 my $cmdline_use_dependencies = 1;
322 # TRUE if in verbose mode.
325 # This holds our (eventual) exit status. We don't actually exit until
326 # we have processed all input files.
329 # From the Perl manual.
330 my $symlink_exists = (eval 'symlink ("", "");', $@ eq '');
332 # TRUE if missing standard files should be installed.
335 # TRUE if we should copy missing files; otherwise symlink if possible.
336 my $copy_missing = 0;
338 # TRUE if we should always update files that we know about.
339 my $force_missing = 0;
342 ## ---------------------------------------- ##
343 ## Variables filled during files scanning. ##
344 ## ---------------------------------------- ##
346 # Name of the top autoconf input: `configure.ac' or `configure.in'.
347 my $configure_ac = '';
349 # Files found by scanning configure.ac for LIBOBJS.
352 # True if AM_C_PROTOTYPES appears in configure.ac.
353 my $am_c_prototypes = 0;
355 # Names used in AC_CONFIG_HEADER call. @config_fullnames holds the
356 # name which appears in AC_CONFIG_HEADER, colon and all.
357 # @config_names holds the file names. @config_headers holds the '.in'
358 # files. Ordinarily these are similar, but they can be different if
359 # the weird "NAME:FILE" syntax is used.
360 my @config_fullnames = ();
361 my @config_names = ();
362 my @config_headers = ();
363 # Where AC_CONFIG_HEADER appears.
364 my $config_header_location;
366 # Directory where output files go. Actually, output files are
367 # relative to this directory.
368 my $output_directory = '.';
370 # List of Makefile.am's to process, and their corresponding outputs.
371 my @input_files = ();
372 my %output_files = ();
374 # Complete list of Makefile.am's that exist.
375 my @configure_input_files = ();
377 # List of files in AC_CONFIG_FILES/AC_OUTPUT without Makefile.am's,
379 my @other_input_files = ();
380 # Where the last AC_CONFIG_FILES/AC_OUTPUT appears.
381 my $ac_config_files_location;
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 # Where AM_GNU_GETTEXT appears.
392 my $ac_gettext_location;
394 # TRUE if AC_PROG_LEX or AM_PROG_LEX were seen.
395 my $seen_prog_lex = 0;
397 # TRUE if we've seen AC_CANONICAL_(HOST|SYSTEM).
398 my $seen_canonical = 0;
399 my $canonical_location;
401 # TRUE if we've seen AC_PROG_LIBTOOL.
402 my $seen_libtool = 0;
403 my $libtool_location;
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 # Where version is defined.
412 my $package_version_location;
414 # Where AM_PATH_LISPDIR appears.
415 my $am_lispdir_location;
417 # Where AM_PATH_PYTHON appears.
418 my $pythondir_location;
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_location{$VAR} is where it was 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 macro_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_conf_file ($canonical_location, $FOREIGN,
1190 'config.guess', 'config.sub')
1194 # We still need Makefile.in here, because sometimes the `dist'
1195 # target doesn't re-run automake.
1196 if ($am_relative_dir eq $relative_dir)
1198 # Only distribute the files if they are in the same subdir as
1199 # the generated makefile.
1200 &push_dist_common ($in_file_name, $am_file_name);
1203 push (@sources, '$(SOURCES)')
1204 if &variable_defined ('SOURCES');
1206 # Must do this after reading .am file. See read_main_am_file to
1207 # understand weird tricks we play there with variables.
1208 &define_variable ('subdir', $relative_dir);
1210 # Check first, because we might modify some state.
1212 &check_gnu_standards;
1213 &check_gnits_standards;
1215 &handle_configure ($output, $makefile, @secondary_inputs);
1218 &handle_ltlibraries;
1222 # This must run first so that the ANSI2KNR definition is generated
1223 # before it is used by the _.c rules. We have to do this because
1224 # a variable which is used in a dependency must be defined before
1225 # the target, or else make won't properly see it.
1227 # This must be run after all the sources are scanned.
1230 # Re-init SOURCES. FIXME: other code shouldn't depend on this
1231 # (but currently does).
1232 macro_define ('SOURCES', 1, '', 'TRUE',
1233 join (' ', @sources), 'internal');
1234 define_pretty_variable ('DIST_SOURCES', '', @dist_sources);
1246 &handle_minor_options;
1249 # This must come after most other rules.
1250 &handle_dist ($makefile);
1253 &do_check_merge_target;
1254 &handle_all ($output);
1257 if (&variable_defined('lib_LTLIBRARIES') &&
1258 &variable_defined('bin_PROGRAMS'))
1260 $output_rules .= "install-binPROGRAMS: install-libLTLIBRARIES\n\n";
1263 &handle_installdirs;
1265 &handle_factored_dependencies;
1269 if (! -d ($output_directory . '/' . $am_relative_dir))
1271 mkdir ($output_directory . '/' . $am_relative_dir, 0755);
1274 my ($out_file) = $output_directory . '/' . $makefile . ".in";
1275 if (! $force_generation && -e $out_file)
1277 my ($am_time) = (stat ($makefile . '.am'))[9];
1278 my ($in_time) = (stat ($out_file))[9];
1279 # FIXME: should cache these times.
1280 my ($conf_time) = (stat ($configure_ac))[9];
1281 # FIXME: how to do unsigned comparison?
1282 if ($am_time < $in_time || $am_time < $conf_time)
1284 # No need to update.
1287 if (-f 'aclocal.m4')
1289 my ($acl_time) = (stat _)[9];
1290 return if ($am_time < $acl_time);
1294 my $gm_file = new Automake::XFile "> $out_file";
1295 verbose "creating ", $makefile, ".in";
1297 print $gm_file $output_vars;
1298 # We make sure that `all:' is the first target.
1299 print $gm_file $output_all;
1300 print $gm_file $output_header;
1301 print $gm_file $output_rules;
1302 print $gm_file $output_trailer;
1305 ################################################################
1307 # A helper which handles the logic of requiring a version number in
1308 # AUTOMAKE_OPTIONS. Return 1 on error, 0 on success.
1309 sub version_check ($$$$)
1311 my ($rmajor, $rminor, $ralpha, $rfork) = ($1, $2, $3, $4);
1313 prog_error ("version is incorrect: $VERSION")
1314 if $VERSION !~ /(\d+)\.(\d+)([a-z]?)-?([A-Za-z0-9]+)?/;
1316 my ($tmajor, $tminor, $talpha, $tfork) = ($1, $2, $3, $4);
1321 my $rminorminor = 0;
1322 my $tminorminor = 0;
1324 # Some versions were labelled like `1.4-p3a'. This is the same as
1325 # an alpha release labelled `1.4.3a'. However, a version like
1326 # `1.4g' is the same as `1.4.99g'. Yes, this sucks. Moral:
1327 # always listen to the users.
1328 if ($rfork =~ /p([0-9]+)([a-z]?)/)
1331 # `1.4a-p3b' never existed. But we'll accept it anyway.
1332 $ralpha = $ralpha || $2 || '';
1335 if ($tfork =~ /p([0-9]+)([a-z]?)/)
1338 # `1.4a-p3b' never existed. But we'll accept it anyway.
1339 $talpha = $talpha || $2 || '';
1343 $rminorminor = 99 if $ralpha ne '' && $rminorminor == 0;
1344 $tminorminor = 99 if $talpha ne '' && $tminorminor == 0;
1346 # 2.0 is better than 1.0.
1347 # 1.2 is better than 1.1.
1348 # 1.2a is better than 1.2.
1349 # If we require 3.4n-foo then we require something
1350 # >= 3.4n, with the `foo' fork identifier.
1351 # The $r* variables are what the user specified.
1352 # The $t* variables denote automake itself.
1353 if ($rmajor > $tmajor
1354 || ($rmajor == $tmajor && $rminor > $tminor)
1355 || ($rminor == $tminor && $rminor == $tminor
1356 && $rminorminor > $tminorminor)
1357 || ($rminor == $tminor && $rminor == $tminor
1358 && $rminorminor == $tminorminor
1359 && $ralpha gt $talpha)
1360 || ($rfork ne '' && $rfork ne $tfork))
1362 macro_error ('AUTOMAKE_OPTIONS',
1363 "require version $_, but have $VERSION");
1370 # Handle AUTOMAKE_OPTIONS variable. Return 1 on error, 0 otherwise.
1373 if (&variable_defined ('AUTOMAKE_OPTIONS'))
1375 foreach (&variable_value_as_list_recursive ('AUTOMAKE_OPTIONS', ''))
1378 if ($_ eq 'gnits' || $_ eq 'gnu' || $_ eq 'foreign')
1380 &set_strictness ($_);
1382 elsif ($_ eq 'cygnus')
1386 elsif (/^(.*\/)?ansi2knr$/)
1388 # An option like "../lib/ansi2knr" is allowed. With
1389 # no path prefix, we assume the required programs are
1390 # in this directory. We save the actual option for
1392 $options{'ansi2knr'} = $_;
1394 elsif ($_ eq 'no-installman' || $_ eq 'no-installinfo'
1395 || $_ eq 'dist-shar' || $_ eq 'dist-zip'
1396 || $_ eq 'dist-tarZ' || $_ eq 'dist-bzip2'
1397 || $_ eq 'dejagnu' || $_ eq 'no-texinfo.tex'
1398 || $_ eq 'readme-alpha' || $_ eq 'check-news'
1399 || $_ eq 'subdir-objects' || $_ eq 'nostdinc'
1400 || $_ eq 'no-exeext')
1402 # Explicitly recognize these.
1404 elsif ($_ eq 'no-dependencies')
1406 $use_dependencies = 0;
1408 elsif (/(\d+)\.(\d+)([a-z]?)(-[A-Za-z0-9]+)?/)
1410 # Got a version number.
1411 if (version_check ($1, $2, $3, $4))
1418 macro_error ('AUTOMAKE_OPTIONS',
1419 "option `" . $_ . "\' not recognized");
1424 if ($strictness == $GNITS)
1426 $options{'readme-alpha'} = 1;
1427 $options{'check-news'} = 1;
1434 # get_object_extension ($OUT)
1435 # ---------------------------
1436 # Return object extension. Just once, put some code into the output.
1437 # OUT is the name of the output file
1438 sub get_object_extension
1442 # Maybe require libtool library object files.
1443 my $extension = '.$(OBJEXT)';
1444 $extension = '.lo' if ($out =~ /\.la$/);
1446 # Check for automatic de-ANSI-fication.
1447 $extension = '$U' . $extension
1448 if defined $options{'ansi2knr'};
1450 $get_object_extension_was_run = 1;
1456 # Call finish function for each language that was used.
1457 sub handle_languages
1459 if ($use_dependencies)
1461 # Include auto-dep code. Don't include it if DEP_FILES would
1463 if (&saw_sources_p (0) && keys %dep_files)
1465 # Set location of depcomp.
1466 &define_variable ('depcomp', "\$(SHELL) $config_aux_dir/depcomp");
1468 require_conf_file ("$am_file.am", $FOREIGN, 'depcomp');
1470 my @deplist = sort keys %dep_files;
1472 # We define this as a conditional variable because BSD
1473 # make can't handle backslashes for continuing comments on
1474 # the following line.
1475 define_pretty_variable ('DEP_FILES', 'AMDEP_TRUE', @deplist);
1477 # Generate each `include' individually. Irix 6 make will
1478 # not properly include several files resulting from a
1479 # variable expansion; generating many separate includes
1481 $output_rules .= "\n";
1482 foreach my $iter (@deplist)
1484 $output_rules .= (subst ('AMDEP_TRUE')
1485 . subst ('am__include')
1487 . subst ('am__quote')
1489 . subst ('am__quote')
1493 $output_rules .= &file_contents ('depend');
1498 &define_variable ('depcomp', '');
1503 # Is the c linker needed?
1505 foreach my $ext (sort keys %extension_seen)
1507 next unless $extension_map{$ext};
1509 my $lang = $languages{$extension_map{$ext}};
1511 my $rule_file = $lang->rule_file || 'depend2';
1513 # Get information on $LANG.
1514 my $pfx = $lang->autodep;
1515 my $fpfx = ($pfx eq '') ? 'CC' : $pfx;
1517 my $AMDEP = (($use_dependencies && $lang->autodep ne 'no')
1518 ? 'AMDEP' : 'FALSE');
1520 my %transform = ('EXT' => $ext,
1523 'LIBTOOL' => $seen_libtool,
1525 '-c' => $lang->compile_flag || '',
1527 => (count_files_for_language ($lang->name) > 1));
1529 # Generate the appropriate rules for this extension.
1530 if (($use_dependencies && $lang->autodep ne 'no')
1531 || defined $lang->compile)
1533 # Some C compilers don't support -c -o. Use it only if really
1535 my $output_flag = $lang->output_flag || '';
1538 && $lang->flags eq 'CFLAGS'
1539 && defined $options{'subdir-objects'});
1541 # FIXME: this is a temporary hack to compute a possible
1542 # derived extension. This is not used by depend2.am.
1543 (my $der_ext = $ext) =~ tr/yl/cc/;
1545 # Another yacc/lex hack.
1546 my $destfile = '$*.' . $der_ext;
1549 file_contents ($rule_file,
1553 'DERIVED-EXT' => $der_ext,
1561 'COMPILE' => '$(' . $lang->compiler . ')',
1562 'LTCOMPILE' => '$(LT' . $lang->compiler . ')',
1563 '-o' => $output_flag);
1566 # Now include code for each specially handled object with this
1568 my %seen_files = ();
1569 foreach my $file (@{$lang_specific_files{$lang->name}})
1571 my ($derived, $source, $obj, $myext) = split (' ', $file);
1573 # We might see a given object twice, for instance if it is
1574 # used under different conditions.
1575 next if defined $seen_files{$obj};
1576 $seen_files{$obj} = 1;
1578 my $flags = $lang->flags || '';
1579 my $val = "${derived}_${flags}";
1581 prog_error ("found $lang->name in handle_languages, but compiler not defined")
1582 unless defined $lang->compile;
1584 (my $obj_compile = $lang->compile) =~ s/\(AM_$flags/\($val/;
1585 my $obj_ltcompile = '$(LIBTOOL) --mode=compile ' . $obj_compile;
1587 # We _need_ `-o' for per object rules.
1588 my $output_flag = $lang->output_flag || '-o';
1590 # Generate a transform which will turn suffix targets in
1591 # depend2.am into real targets for the particular objects we
1594 file_contents ($rule_file,
1599 'SOURCE' => $source,
1600 # Use $myext and not `.o' here, in case
1601 # we are actually building a new source
1602 # file -- e.g. via yacc.
1603 'OBJ' => "$obj$myext",
1604 'OBJOBJ' => "$obj.obj",
1605 'LTOBJ' => "$obj.lo",
1607 'COMPILE' => $obj_compile,
1608 'LTCOMPILE' => $obj_ltcompile,
1609 '-o' => $output_flag));
1612 # The rest of the loop is done once per language.
1613 next if defined $done{$lang};
1616 # Load the language dependent Makefile chunks.
1617 my %lang = map { uc ($_) => 0 } keys %languages;
1618 $lang{uc ($lang->name)} = 1;
1619 $output_rules .= file_contents ('lang-compile', %transform, %lang);
1621 # If the source to a program consists entirely of code from a
1622 # `pure' language, for instance C++ for Fortran 77, then we
1623 # don't need the C compiler code. However if we run into
1624 # something unusual then we do generate the C code. There are
1625 # probably corner cases here that do not work properly.
1626 # People linking Java code to Fortran code deserve pain.
1627 $needs_c ||= ! $lang->pure;
1629 define_compiler_variable ($lang)
1630 if ($lang->compile);
1632 define_linker_variable ($lang)
1635 foreach my $var (@{$lang->config_vars})
1637 am_error ($lang->Name
1638 . " source seen but `$var' not defined in"
1639 . " `$configure_ac'")
1640 if !exists $configure_vars{$var};
1643 # The compiler's flag must be a configure variable.
1644 define_configure_variable ($lang->flags)
1645 if defined $lang->flags && $lang->define_flag;
1647 # Call the finisher.
1651 # If the project is entirely C++ or entirely Fortran 77 (i.e., 1
1652 # suffix rule was learned), don't bother with the C stuff. But if
1653 # anything else creeps in, then use it.
1655 if $need_link || scalar keys %suffix_rules > 1;
1659 if (! defined $done{$languages{'c'}})
1661 &define_configure_variable ($languages{'c'}->flags);
1662 &define_compiler_variable ($languages{'c'});
1664 define_linker_variable ($languages{'c'});
1668 # Check to make sure a source defined in LIBOBJS is not explicitly
1669 # mentioned. This is a separate function (as opposed to being inlined
1670 # in handle_source_transform) because it isn't always appropriate to
1672 sub check_libobjs_sources
1674 my ($one_file, $unxformed) = @_;
1676 foreach my $prefix ('', 'EXTRA_', 'dist_', 'nodist_',
1677 'dist_EXTRA_', 'nodist_EXTRA_')
1680 if (&variable_defined ($prefix . $one_file . '_SOURCES'))
1682 @files = &variable_value_as_list_recursive (
1683 ($prefix . $one_file . '_SOURCES'),
1686 elsif ($prefix eq '')
1688 @files = ($unxformed . '.c');
1695 foreach my $file (@files)
1697 if (defined $libsources{$file})
1699 macro_error ($prefix . $one_file . '_SOURCES',
1700 "automatically discovered file `$file' should not be explicitly mentioned");
1708 # handle_single_transform_list ($VAR, $TOPPARENT, $DERIVED, $OBJ, @FILES)
1709 # -----------------------------------------------------------------------
1710 # Does much of the actual work for handle_source_transform.
1712 # $VAR is the name of the variable that the source filenames come from
1713 # $TOPPARENT is the name of the _SOURCES variable which is being processed
1714 # $DERIVED is the name of resulting executable or library
1715 # $OBJ is the object extension (e.g., `$U.lo')
1716 # @FILES is the list of source files to transform
1717 # Result is a list of the names of objects
1718 # %linkers_used will be updated with any linkers needed
1719 sub handle_single_transform_list ($$$$@)
1721 my ($var, $topparent, $derived, $obj, @files) = @_;
1723 my $nonansi_obj = $obj;
1724 $nonansi_obj =~ s/\$U//g;
1726 # Turn sources into objects. We use a while loop like this
1727 # because we might add to @files in the loop.
1728 while (scalar @files > 0)
1732 # Configure substitutions in _SOURCES variables are errors.
1736 "`$var' includes configure substitution `$_', and is referred to from `$topparent': configure substitutions not allowed in _SOURCES variables");
1740 # If the source file is in a subdirectory then the `.o' is put
1741 # into the current directory, unless the subdir-objects option
1744 # Split file name into base and extension.
1745 next if ! /^(?:(.*)\/)?([^\/]*)\.(.*)$/;
1747 my $directory = $1 || '';
1751 # We must generate a rule for the object if it requires its own flags.
1753 my ($linker, $object);
1755 # This records whether we've seen a derived source file (eg,
1757 my $derived_source = 0;
1759 # This holds the `aggregate context' of the file we are
1760 # currently examining. If the file is compiled with
1761 # per-object flags, then it will be the name of the object.
1762 # Otherwise it will be `AM'. This is used by the target hook
1763 # language function.
1764 my $aggregate = 'AM';
1766 $extension = &derive_suffix ($extension);
1768 if ($extension_map{$extension} &&
1769 ($lang = $languages{$extension_map{$extension}}))
1771 # Found the language, so see what it says.
1772 &saw_extension ($extension);
1774 # Note: computed subr call. The language rewrite function
1775 # should return one of the $LANG_* constants. It could
1776 # also return a list whose first value is such a constant
1777 # and whose second value is a new source extension which
1778 # should be applied. This means this particular language
1779 # generates another source file which we must then process
1781 my $subr = 'lang_' . $lang->name . '_rewrite';
1782 my ($r, $source_extension)
1783 = & $subr ($directory, $base, $extension);
1784 # Skip this entry if we were asked not to process it.
1785 next if $r == $LANG_IGNORE;
1787 # Now extract linker and other info.
1788 $linker = $lang->linker;
1791 if (defined $source_extension)
1793 $this_obj_ext = '.' . $source_extension;
1794 $derived_source = 1;
1798 $this_obj_ext = $obj;
1802 $this_obj_ext = $nonansi_obj;
1804 $object = $base . $this_obj_ext;
1806 if (defined $lang->flags
1807 && &variable_defined ($derived . '_' . $lang->flags))
1809 # We have a per-executable flag in effect for this
1810 # object. In this case we rewrite the object's
1811 # name to ensure it is unique. We also require
1812 # the `compile' program to deal with compilers
1813 # where `-c -o' does not work.
1815 # We choose the name `DERIVED_OBJECT' to ensure
1816 # (1) uniqueness, and (2) continuity between
1817 # invocations. However, this will result in a
1818 # name that is too long for losing systems, in
1819 # some situations. So we provide _SHORTNAME to
1822 my $dname = $derived;
1823 if (&variable_defined ($derived . '_SHORTNAME'))
1825 # FIXME: should use the same conditional as
1826 # the _SOURCES variable. But this is really
1827 # silly overkill -- nobody should have
1828 # conditional shortnames.
1829 $dname = &variable_value ($derived . '_SHORTNAME');
1831 $object = $dname . '-' . $object;
1833 require_conf_file ("$am_file.am", $FOREIGN, 'compile')
1834 if $lang->name eq 'c';
1836 prog_error ("$lang->name flags defined without compiler")
1837 if ! defined $lang->compile;
1842 # If rewrite said it was ok, put the object into a
1844 if ($r == $LANG_SUBDIR && $directory ne '')
1846 $object = $directory . '/' . $object;
1849 # If doing dependency tracking, then we can't print
1850 # the rule. If we have a subdir object, we need to
1851 # generate an explicit rule. Actually, in any case
1852 # where the object is not in `.' we need a special
1853 # rule. The per-object rules in this case are
1854 # generated later, by handle_languages.
1855 if ($renamed || $directory ne '')
1857 my $obj_sans_ext = substr ($object, 0,
1858 - length ($this_obj_ext));
1859 my $val = ("$full $obj_sans_ext "
1860 # Only use $this_obj_ext in the derived
1861 # source case because in the other case we
1862 # *don't* want $(OBJEXT) to appear here.
1863 . ($derived_source ? $this_obj_ext : '.o'));
1865 # If we renamed the object then we want to use the
1866 # per-executable flag name. But if this is simply a
1867 # subdir build then we still want to use the AM_ flag
1871 $val = "$derived $val";
1872 $aggregate = $derived;
1879 # Each item on this list is a string consisting of
1880 # four space-separated values: the derived flag prefix
1881 # (eg, for `foo_CFLAGS', it is `foo'), the name of the
1882 # source file, the base name of the output file, and
1883 # the extension for the object file.
1884 push (@{$lang_specific_files{$lang->name}}, $val);
1887 elsif ($extension eq 'o')
1889 # This is probably the result of a direct suffix rule.
1890 # In this case we just accept the rewrite. FIXME:
1891 # this fails if we want libtool objects.
1892 $object = $base . '.' . $extension;
1897 # No error message here. Used to have one, but it was
1899 # FIXME: we could potentially do more processing here,
1900 # perhaps treating the new extension as though it were a
1901 # new source extension (as above). This would require
1902 # more restructuring than is appropriate right now.
1906 if (defined $object_map{$object})
1908 if ($object_map{$object} ne $full)
1910 am_error ("object `$object' created by `$full' and `$object_map{$object}'");
1914 # Let the language do some special magic if required.
1915 $lang->target_hook ($aggregate, $object, $full);
1917 if ($derived_source)
1919 prog_error ("$lang->name has automatic dependency tracking")
1920 if $lang->autodep ne 'no';
1921 # Make sure this new source file is handled next. That will
1922 # make it appear to be at the right place in the list.
1923 unshift (@files, $object);
1925 &push_dist_common ($object);
1929 $linkers_used{$linker} = 1;
1931 push (@result, $object);
1933 if (! defined $object_map{$object})
1936 $object_map{$object} = $full;
1938 # If file is in subdirectory, we need explicit
1940 if ($directory ne '' || $renamed)
1942 push (@dep_list, $full);
1945 # If resulting object is in subdir, we need to make
1946 # sure the subdir exists at build time.
1947 if ($object =~ /\//)
1949 # FIXME: check that $DIRECTORY is somewhere in the
1952 # We don't allow `..' in object file names for
1953 # *any* source, not just Java. For Java it just
1954 # doesn't make sense, but in general it is
1955 # a problem because we can't pick a good name for
1957 if ($object =~ /(\/|^)\.\.\//)
1959 am_error ("`$full' contains `..' component but should not");
1962 # Make sure object is removed by `make mostlyclean'.
1963 $compile_clean_files{$object} = $MOSTLY_CLEAN;
1965 push (@dep_list, require_build_directory ($directory));
1967 # If we're generating dependencies, we also want
1968 # to make sure that the appropriate subdir of the
1969 # .deps directory is created.
1970 push (@dep_list, require_build_directory ('$(DEPDIR)/' . $directory))
1971 if ($use_dependencies);
1974 &pretty_print_rule ($object . ':', "\t", @dep_list)
1975 if scalar @dep_list > 0;
1978 # Transform .o or $o file into .P file (for automatic
1980 if ($lang && $lang->autodep ne 'no')
1982 my $depfile = $object;
1983 $depfile =~ s/\.([^.]*)$/.P$1/;
1984 $depfile =~ s/\$\(OBJEXT\)$/o/;
1985 $dep_files{'$(DEPDIR)/' . $depfile} = 1;
1993 # define_objects_from_sources ($VAR, $OBJVAR, $NODEFINE, $ONE_FILE,
1994 # $OBJ, $PARENT, $TOPPARENT)
1995 # ---------------------------------------------------------------------
1996 # Define an _OBJECTS variable for a _SOURCES variable (or subvariable)
1999 # $VAR is the name of the _SOURCES variable
2000 # $OBJVAR is the name of the _OBJECTS
2001 # $NODEFINE is a boolean: if true, $OBJVAR will not be defined (but
2002 # work done to determine the linker will be).
2003 # $ONE_FILE is the canonical (transformed) name of object to build
2004 # $OBJ is the object extension (ie either `.o' or `$o'.
2005 # $PARENT is the variable in which $VAR is used, or $VAR if not applicable.
2006 # $TOPPARENT is the _SOURCES variable being processed.
2008 # Result is a boolean, true if a linker is needed to deal with the objects.
2010 # %linkers_used, %vars_scanned, @substfroms and @substtos should be cleared
2012 # %linkers_used variable will be set to contain the linkers desired.
2013 # %vars_scanned will be used to check for recursive definitions.
2014 # @substfroms and @substtos will be used to keep a stack of variable
2015 # substitutions to be applied.
2017 sub define_objects_from_sources ($$$$$$$)
2019 my ($var, $objvar, $nodefine, $one_file, $obj, $parent, $topparent) = @_;
2021 if (defined $vars_scanned{$var})
2023 macro_error ($var, "variable `$var' recursively defined");
2026 $vars_scanned{$var} = 1;
2028 my $needlinker = "";
2029 foreach my $cond (variable_conditions ($var))
2032 foreach my $val (&variable_value_as_list ($var, $cond, $parent))
2034 if ($val =~ /^\$\{([^}]*)\}$/ || $val =~ /^\$\(([^)]*)\)$/)
2036 # Handle a sub variable
2039 # If the user uses a losing variable name, just ignore it.
2040 # This isn't ideal, but people have requested it.
2041 next if ($subvar =~ /\@.*\@/);
2043 # See if the variable is actually a substitution reference
2046 if ($subvar =~ /$SUBST_REF_PATTERN/o)
2050 ($from = $2) =~ s/(\W)/\\$1/g;
2052 push @substfroms, $from;
2053 push @substtos, $to;
2055 my $subobjvar = subobjname ($subvar);
2056 push (@result, '$('. $subobjvar . ')');
2058 my $temp = define_objects_from_sources ($subvar, $subobjvar,
2059 $nodefine, $one_file,
2060 $obj, $var, $topparent);
2061 $needlinker ||= $temp;
2068 my $substnum=$#substfroms;
2069 while ($substnum >= 0)
2071 $val =~ s/$substfroms[$substnum]$/$substtos[$substnum]/
2072 if defined $substfroms[$substnum];
2077 &handle_single_transform_list ($var, $topparent, $one_file, $obj, $val);
2078 push (@result, @transformed);
2079 $needlinker = "true" if @transformed;
2083 # Define _OBJECTS conditionally.
2084 define_pretty_variable ($objvar, $cond, (@result))
2088 delete $vars_scanned{$var};
2094 # subobjname ($VARNAME)
2095 # ---------------------
2096 # Return a name for an object variable.
2099 # $VARNAME is the name of the variable the object variable is being
2102 # This function also looks at @substfroms and @substtos to determine any
2103 # substitutions to be performed on the object variable.
2105 # The name returned is unique for the combination of $varname and
2106 # substitutions to be performed.
2111 my $substnum=$#substfroms;
2112 while ($substnum >= 0)
2114 if (defined $substfroms[$substnum] &&
2115 ($substfroms[$substnum] || $substtos[$substnum]))
2117 $key .= ":" . $substfroms[$substnum] . "=" . $substtos[$substnum];
2122 my $num = $substnums{$key};
2125 $num = keys(%substnums) + 1;
2126 $substnums{$key} = $num;
2129 return "am__objects_$num";
2133 # Handle SOURCE->OBJECT transform for one program or library.
2135 # canonical (transformed) name of object to build
2136 # actual name of object to build
2137 # object extension (ie either `.o' or `$o'.
2138 # Return result is name of linker variable that must be used.
2139 # Empty return means just use `LINK'.
2140 sub handle_source_transform
2142 # one_file is canonical name. unxformed is given name. obj is
2144 my ($one_file, $unxformed, $obj) = @_;
2148 if (&variable_defined ($one_file . "_OBJECTS"))
2150 macro_error ($one_file . '_OBJECTS',
2151 $one_file . '_OBJECTS', 'should not be defined');
2152 # No point in continuing.
2159 foreach my $prefix ('', 'EXTRA_', 'dist_', 'nodist_',
2160 'dist_EXTRA_', 'nodist_EXTRA_')
2162 my $var = $prefix . $one_file . "_SOURCES";
2164 if !variable_defined ($var);
2166 # We are going to define _OBJECTS variables using the prefix.
2167 # Then we glom them all together. So we can't use the null
2168 # prefix here as we need it later.
2169 my $xpfx = ($prefix eq '') ? 'am_' : $prefix;
2171 # Keep track of which prefixes we saw.
2172 $used_pfx{$xpfx} = 1
2173 unless $prefix =~ /EXTRA_/;
2175 push (@sources, '$(' . $prefix . $one_file . "_SOURCES)");
2176 push (@dist_sources, '$(' . $prefix . $one_file . "_SOURCES)")
2177 unless $prefix =~ /^nodist_/;
2182 my $temp = define_objects_from_sources ($var,
2183 $xpfx . $one_file . '_OBJECTS',
2184 $prefix =~ /EXTRA_/,
2185 $one_file, $obj, $var, $var);
2186 $needlinker ||= $temp;
2190 $linker ||= &resolve_linker (%linkers_used);
2193 my @keys = sort keys %used_pfx;
2194 if (scalar @keys == 0)
2196 &define_variable ($one_file . "_SOURCES", $unxformed . ".c");
2197 push (@sources, $unxformed . '.c');
2198 push (@dist_sources, $unxformed . '.c');
2202 &handle_single_transform_list ($one_file . '_SOURCES',
2203 $one_file . '_SOURCES',
2206 $linker ||= &resolve_linker (%linkers_used);
2207 define_pretty_variable ($one_file . "_OBJECTS", '', @result)
2211 grep ($_ = '$(' . $_ . $one_file . '_OBJECTS)', @keys);
2212 define_pretty_variable ($one_file . '_OBJECTS', '', @keys);
2215 # If we want to use `LINK' we must make sure it is defined.
2225 # handle_lib_objects ($XNAME, $VAR)
2226 # ---------------------------------
2227 # Special-case @ALLOCA@ and @LIBOBJS@ in _LDADD or _LIBADD variables.
2228 # Also, generate _DEPENDENCIES variable if appropriate.
2230 # transformed name of object being built, or empty string if no object
2231 # name of _LDADD/_LIBADD-type variable to examine
2232 # Returns 1 if LIBOBJS seen, 0 otherwise.
2233 sub handle_lib_objects
2235 my ($xname, $var) = @_;
2237 prog_error ("handle_lib_objects: $var undefined")
2238 if ! &variable_defined ($var);
2241 foreach my $cond (variable_conditions_recursive ($var))
2243 if (&handle_lib_objects_cond ($xname, $var, $cond))
2251 # Subroutine of handle_lib_objects: handle a particular condition.
2252 sub handle_lib_objects_cond
2254 my ($xname, $var, $cond) = @_;
2256 # We recognize certain things that are commonly put in LIBADD or
2260 my $seen_libobjs = 0;
2263 foreach my $lsearch (&variable_value_as_list_recursive ($var, $cond))
2265 # Skip -lfoo and -Ldir; these are explicitly allowed.
2266 next if $lsearch =~ /^-[lL]/;
2267 if (! $flagvar && $lsearch =~ /^-/)
2269 if ($var =~ /^(.*)LDADD$/)
2271 # Skip -dlopen and -dlpreopen; these are explicitly allowed.
2272 next if $lsearch =~ /^-dl(pre)?open$/;
2274 "linker flags such as `$lsearch' belong in `${1}LDFLAGS");
2278 # Only get this error once.
2281 "linker flags such as `$lsearch' belong in `${1}LDFLAGS");
2285 # Assume we have a file of some sort, and push it onto the
2286 # dependency list. Autoconf substitutions are not pushed;
2287 # rarely is a new dependency substituted into (eg) foo_LDADD
2288 # -- but "bad things (eg -lX11) are routinely substituted.
2289 # Note that LIBOBJS and ALLOCA are exceptions to this rule,
2290 # and handled specially below.
2291 push (@dep_list, $lsearch)
2292 unless $lsearch =~ /^\@.*\@$/;
2294 # Automatically handle @LIBOBJS@ and @ALLOCA@. Basically this
2295 # means adding entries to dep_files.
2296 if ($lsearch =~ /^\@(LT)?LIBOBJS\@$/)
2298 my $lt = $1 ? $1 : '';
2299 my $myobjext = ($1 ? 'l' : '') . 'o';
2301 push (@dep_list, $lsearch);
2303 if (! keys %libsources
2304 && ! &variable_defined ($lt . 'LIBOBJS'))
2307 "\@$lt" . "LIBOBJS\@ seen but never set in `$configure_ac'");
2310 foreach my $iter (keys %libsources)
2312 if ($iter =~ /\.([cly])$/)
2314 &saw_extension ($1);
2315 &saw_extension ('c');
2318 if ($iter =~ /\.h$/)
2320 require_file_with_macro ($var, $FOREIGN, $iter);
2322 elsif ($iter ne 'alloca.c')
2324 my $rewrite = $iter;
2325 $rewrite =~ s/\.c$/.P$myobjext/;
2326 $dep_files{'$(DEPDIR)/' . $rewrite} = 1;
2327 ($rewrite = $iter) =~ s/(\W)/\\$1/g;
2328 $rewrite = "^" . $rewrite . "\$";
2329 # Only require the file if it is not a built source.
2330 if (! &variable_defined ('BUILT_SOURCES')
2331 || ! grep (/$rewrite/,
2332 &variable_value_as_list_recursive (
2333 'BUILT_SOURCES', 'all')))
2335 require_file_with_macro ($var, $FOREIGN, $iter);
2340 elsif ($lsearch =~ /^\@(LT)?ALLOCA\@$/)
2342 my $lt = $1 ? $1 : '';
2343 my $myobjext = ($1 ? 'l' : '') . 'o';
2345 push (@dep_list, $lsearch);
2347 "\@$lt" . "ALLOCA\@ seen but `AC_FUNC_ALLOCA' not in `$configure_ac'")
2348 if ! defined $libsources{'alloca.c'};
2349 $dep_files{'$(DEPDIR)/alloca.P' . $myobjext} = 1;
2350 require_file_with_macro ($var, $FOREIGN, 'alloca.c');
2351 &saw_extension ('c');
2355 if ($xname ne '' && ! &variable_defined ($xname . '_DEPENDENCIES', $cond))
2357 define_pretty_variable ($xname . '_DEPENDENCIES', $cond, @dep_list);
2360 return $seen_libobjs;
2363 # Canonicalize the input parameter
2367 $string =~ tr/A-Za-z0-9_\@/_/c;
2371 # Canonicalize a name, and check to make sure the non-canonical name
2372 # is never used. Returns canonical name. Arguments are name and a
2373 # list of suffixes to check for.
2374 sub check_canonical_spelling
2376 my ($name, @suffixes) = @_;
2378 my $xname = &canonicalize ($name);
2379 if ($xname ne $name)
2381 foreach my $xt (@suffixes)
2383 macro_error ("$name$xt",
2384 "invalid variable `$name$xt'; "
2385 . "should be `$xname$xt'")
2386 if &variable_defined ("$name$xt");
2396 # Set up the compile suite.
2397 sub handle_compile ()
2400 unless $get_object_extension_was_run;
2403 my $default_includes = '';
2404 if (! defined $options{'nostdinc'})
2406 $default_includes = ' -I. -I$(srcdir)';
2408 if (&variable_defined ('CONFIG_HEADER'))
2410 foreach my $hdr (split (' ', &variable_value ('CONFIG_HEADER')))
2412 $default_includes .= ' -I' . dirname ($hdr);
2417 my (@mostly_rms, @dist_rms);
2418 foreach my $item (sort keys %compile_clean_files)
2420 if ($compile_clean_files{$item} == $MOSTLY_CLEAN)
2422 push (@mostly_rms, "\t-rm -f $item");
2424 elsif ($compile_clean_files{$item} == $DIST_CLEAN)
2426 push (@dist_rms, "\t-rm -f $item");
2430 prog_error ("invalid entry in \%compile_clean_files");
2434 my ($coms, $vars, $rules) =
2435 &file_contents_internal (1, "$libdir/am/compile.am",
2436 ('DEFAULT_INCLUDES' => $default_includes,
2437 'MOSTLYRMS' => join ("\n", @mostly_rms),
2438 'DISTRMS' => join ("\n", @dist_rms)));
2439 $output_vars .= $vars;
2440 $output_rules .= "$coms$rules";
2442 # Check for automatic de-ANSI-fication.
2443 if (defined $options{'ansi2knr'})
2445 if (! $am_c_prototypes)
2447 macro_error ('AUTOMAKE_OPTIONS',
2448 "option `ansi2knr' in use but `AM_C_PROTOTYPES' not in `$configure_ac'");
2449 &keyed_aclocal_warning ('AM_C_PROTOTYPES');
2450 # Only give this error once.
2451 $am_c_prototypes = 1;
2454 # topdir is where ansi2knr should be.
2455 if ($options{'ansi2knr'} eq 'ansi2knr')
2457 # Only require ansi2knr files if they should appear in
2459 require_file_with_macro ('AUTOMAKE_OPTIONS', $FOREIGN,
2460 'ansi2knr.c', 'ansi2knr.1');
2462 # ansi2knr needs to be built before subdirs, so unshift it.
2463 unshift (@all, '$(ANSI2KNR)');
2466 my $ansi2knr_dir = '';
2467 $ansi2knr_dir = dirname ($options{'ansi2knr'})
2468 if $options{'ansi2knr'} ne 'ansi2knr';
2470 $output_rules .= &file_contents ('ansi2knr',
2471 ('ANSI2KNR-DIR' => $ansi2knr_dir));
2478 # Handle libtool rules.
2481 return unless $seen_libtool;
2483 # libtool requires some files, but only at top level.
2484 require_conf_file ($libtool_location, $FOREIGN, @libtoolize_files)
2485 if $relative_dir eq '.';
2487 # Output the libtool compilation rules.
2488 $output_rules .= &file_contents ('libtool');
2491 # handle_programs ()
2492 # ------------------
2493 # Handle C programs.
2496 my @proglist = &am_install_var ('progs', 'PROGRAMS',
2497 'bin', 'sbin', 'libexec', 'pkglib',
2499 return if ! @proglist;
2501 my $seen_libobjs = 0;
2502 foreach my $one_file (@proglist)
2504 my $obj = &get_object_extension ($one_file);
2506 # Canonicalize names and check for misspellings.
2507 my $xname = &check_canonical_spelling ($one_file, '_LDADD', '_LDFLAGS',
2508 '_SOURCES', '_OBJECTS',
2511 my $linker = &handle_source_transform ($xname, $one_file, $obj);
2514 if (&variable_defined ($xname . "_LDADD"))
2516 if (&handle_lib_objects ($xname, $xname . '_LDADD'))
2524 # User didn't define prog_LDADD override. So do it.
2525 &define_variable ($xname . '_LDADD', '$(LDADD)');
2527 # This does a bit too much work. But we need it to
2528 # generate _DEPENDENCIES when appropriate.
2529 if (&variable_defined ('LDADD'))
2531 if (&handle_lib_objects ($xname, 'LDADD'))
2536 elsif (! &variable_defined ($xname . '_DEPENDENCIES'))
2538 &define_variable ($xname . '_DEPENDENCIES', '');
2543 if (&variable_defined ($xname . '_LIBADD'))
2545 macro_error ($xname . '_LIBADD',
2546 "use `" . $xname . "_LDADD', not `"
2547 . $xname . "_LIBADD'");
2550 if (! &variable_defined ($xname . '_LDFLAGS'))
2552 # Define the prog_LDFLAGS variable.
2553 &define_variable ($xname . '_LDFLAGS', '');
2556 # Determine program to use for link.
2558 if (&variable_defined ($xname . '_LINK'))
2560 $xlink = $xname . '_LINK';
2564 $xlink = $linker ? $linker : 'LINK';
2567 # If the resulting program lies into a subdirectory,
2568 # make sure this directory will exist.
2569 my $dirstamp = require_build_directory_maybe ($one_file);
2571 # Don't add $(EXEEXT) if user already did.
2572 my $extension = ($one_file !~ /\$\(EXEEXT\)$/
2576 $output_rules .= &file_contents ('program',
2577 ('PROGRAM' => $one_file,
2578 'XPROGRAM' => $xname,
2580 'DIRSTAMP' => $dirstamp,
2581 'EXEEXT' => $extension));
2584 if (&variable_defined ('LDADD') && &handle_lib_objects ('', 'LDADD'))
2591 foreach my $one_file (@proglist)
2593 my $xname = &canonicalize ($one_file);
2595 if (&variable_defined ($xname . '_LDADD'))
2597 &check_libobjs_sources ($xname, $xname . '_LDADD');
2599 elsif (&variable_defined ('LDADD'))
2601 &check_libobjs_sources ($xname, 'LDADD');
2608 # handle_libraries ()
2609 # -------------------
2611 sub handle_libraries
2613 my @liblist = &am_install_var ('libs', 'LIBRARIES',
2614 'lib', 'pkglib', 'noinst', 'check');
2615 return if ! @liblist;
2617 my %valid = &am_primary_prefixes ('LIBRARIES', 0, 'lib', 'pkglib',
2619 if (! defined $configure_vars{'RANLIB'})
2621 foreach my $key (keys %valid)
2623 if (&variable_defined ($key . '_LIBRARIES'))
2625 macro_error ($key . '_LIBRARIES',
2626 "library used but `RANLIB' not defined in `$configure_ac'");
2627 # Only get this error once. If this is ever printed,
2629 $configure_vars{'RANLIB'} = 'BUG';
2635 my $seen_libobjs = 0;
2636 foreach my $onelib (@liblist)
2638 # Check that the library fits the standard naming convention.
2639 if (basename ($onelib) !~ /^lib.*\.a/)
2641 # FIXME should put line number here. That means mapping
2642 # from library name back to variable name.
2643 &am_error ("`$onelib' is not a standard library name");
2646 my $obj = &get_object_extension ($onelib);
2648 # Canonicalize names and check for misspellings.
2649 my $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_SOURCES',
2650 '_OBJECTS', '_DEPENDENCIES',
2653 if (! &variable_defined ($xlib . '_AR'))
2655 &define_variable ($xlib . '_AR', '$(AR) cru');
2658 if (&variable_defined ($xlib . '_LIBADD'))
2660 if (&handle_lib_objects ($xlib, $xlib . '_LIBADD'))
2667 # Generate support for conditional object inclusion in
2669 &define_variable ($xlib . "_LIBADD", '');
2672 if (&variable_defined ($xlib . '_LDADD'))
2674 macro_error ($xlib . '_LDADD',
2675 "use `" . $xlib . "_LIBADD', not `"
2676 . $xlib . "_LDADD'");
2679 # Make sure we at look at this.
2680 &examine_variable ($xlib . '_DEPENDENCIES');
2682 &handle_source_transform ($xlib, $onelib, $obj);
2684 # If the resulting library lies into a subdirectory,
2685 # make sure this directory will exist.
2686 my $dirstamp = require_build_directory_maybe ($onelib);
2688 $output_rules .= &file_contents ('library',
2689 ('LIBRARY' => $onelib,
2690 'XLIBRARY' => $xlib,
2691 'DIRSTAMP' => $dirstamp));
2696 foreach my $onelib (@liblist)
2698 my $xlib = &canonicalize ($onelib);
2699 if (&variable_defined ($xlib . '_LIBADD'))
2701 &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
2708 # handle_ltlibraries ()
2709 # ---------------------
2710 # Handle shared libraries.
2711 sub handle_ltlibraries
2713 my @liblist = &am_install_var ('ltlib', 'LTLIBRARIES',
2714 'noinst', 'lib', 'pkglib', 'check');
2715 return if ! @liblist;
2718 my %valid = &am_primary_prefixes ('LTLIBRARIES', 0, 'lib', 'pkglib',
2721 foreach my $key (keys %valid)
2723 if (&variable_defined ($key . '_LTLIBRARIES'))
2727 macro_error ($key . '_LTLIBRARIES',
2728 "library used but `LIBTOOL' not defined in `$configure_ac'");
2729 # Only get this error once. If this is ever printed,
2731 $configure_vars{'LIBTOOL'} = 'BUG';
2735 # Get the installation directory of each library.
2736 for (&variable_value_as_list_recursive ($key . '_LTLIBRARIES', 'all'))
2740 &am_error ("`$_' is already going to be installed in `$instdirs{$_}'");
2744 $instdirs{$_} = $key;
2750 my $seen_libobjs = 0;
2751 foreach my $onelib (@liblist)
2753 my $obj = &get_object_extension ($onelib);
2755 # Canonicalize names and check for misspellings.
2756 my $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_LDFLAGS',
2757 '_SOURCES', '_OBJECTS',
2760 if (! &variable_defined ($xlib . '_LDFLAGS'))
2762 # Define the lib_LDFLAGS variable.
2763 &define_variable ($xlib . '_LDFLAGS', '');
2766 # Check that the library fits the standard naming convention.
2767 my $libname_rx = "^lib.*\.la";
2768 if ((&variable_defined ($xlib . '_LDFLAGS')
2769 && grep (/-module/, &variable_value_as_list_recursive (
2770 $xlib . '_LDFLAGS', 'all')))
2771 || (&variable_defined ('LDFLAGS')
2772 && grep (/-module/, &variable_value_as_list_recursive (
2773 'LDFLAGS', 'all'))))
2775 # Relax name checking for libtool modules.
2776 $libname_rx = "\.la";
2778 if (basename ($onelib) !~ /$libname_rx$/)
2780 # FIXME this should only be a warning for foreign packages
2781 # FIXME should put line number here. That means mapping
2782 # from library name back to variable name.
2783 &am_error ("`$onelib' is not a standard libtool library name");
2786 if (&variable_defined ($xlib . '_LIBADD'))
2788 if (&handle_lib_objects ($xlib, $xlib . '_LIBADD'))
2795 # Generate support for conditional object inclusion in
2797 &define_variable ($xlib . "_LIBADD", '');
2800 if (&variable_defined ($xlib . '_LDADD'))
2802 macro_error ($xlib . '_LDADD',
2803 "use `" . $xlib . "_LIBADD', not `"
2804 . $xlib . "_LDADD'");
2807 # Make sure we at look at this.
2808 &examine_variable ($xlib . '_DEPENDENCIES');
2810 my $linker = &handle_source_transform ($xlib, $onelib, $obj);
2812 # Determine program to use for link.
2814 if (&variable_defined ($xlib . '_LINK'))
2816 $xlink = $xlib . '_LINK';
2820 $xlink = $linker ? $linker : 'LINK';
2824 if ($instdirs{$onelib} eq 'EXTRA'
2825 || $instdirs{$onelib} eq 'noinst'
2826 || $instdirs{$onelib} eq 'check')
2828 # It's an EXTRA_ library, so we can't specify -rpath,
2829 # because we don't know where the library will end up.
2830 # The user probably knows, but generally speaking automake
2831 # doesn't -- and in fact configure could decide
2832 # dynamically between two different locations.
2837 $rpath = ('-rpath $(' . $instdirs{$onelib} . 'dir)');
2840 # If the resulting library lies into a subdirectory,
2841 # make sure this directory will exist.
2842 my $dirstamp = require_build_directory_maybe ($onelib);
2844 $output_rules .= &file_contents ('ltlibrary',
2845 ('LTLIBRARY' => $onelib,
2846 'XLTLIBRARY' => $xlib,
2849 'DIRSTAMP' => $dirstamp));
2854 foreach my $onelib (@liblist)
2856 my $xlib = &canonicalize ($onelib);
2857 if (&variable_defined ($xlib . '_LIBADD'))
2859 &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
2865 # See if any _SOURCES variable were misspelled. Also, make sure that
2866 # EXTRA_ variables don't contain configure substitutions.
2869 foreach my $varname (keys %var_value)
2871 foreach my $primary ('_SOURCES', '_LIBADD', '_LDADD', '_LDFLAGS',
2874 if ($varname =~ /$primary$/ && ! $content_seen{$varname})
2876 macro_error ($varname,
2877 "invalid unused variable name: `$varname'");
2886 # NOTE we no longer automatically clean SCRIPTS, because it is
2887 # useful to sometimes distribute scripts verbatim. This happens
2888 # eg in Automake itself.
2889 &am_install_var ('-candist', 'scripts', 'SCRIPTS',
2890 'bin', 'sbin', 'libexec', 'pkgdata',
2895 # ($OUTFILE, $VFILE, @CLEAN_FILES)
2896 # &scan_texinfo_file ($FILENAME)
2897 # ------------------------------
2898 # $OUTFILE is the name of the info file produced by $FILENAME.
2899 # $VFILE is the name of the version.texi file used (empty if none).
2900 # @CLEAN_FILES is the list of by products (indexes etc.)
2901 sub scan_texinfo_file
2903 my ($filename) = @_;
2905 # These are always created, no matter whether indexes are used or not.
2906 my @clean_suffixes = ('aux', 'dvi', 'log', 'ps', 'toc',
2907 # grep new.*index texinfo.tex
2908 'cp', 'fn', 'ky', 'vr', 'tp', 'pg');
2910 # There are predefined indexes which don't follow the regular rules.
2911 my %predefined_index =
2914 'c' => 'cps', 'f' => 'fns', 'k' => 'kys',
2915 'v' => 'vrs', 't' => 'tps', 'p' => 'pgs'
2918 # There are commands which include a hidden index command.
2922 'fn' => 'fns', 'un' => 'fns',
2923 'typefn' => 'fns', 'typefun' => 'fns',
2924 'mac' => 'fns', 'spec' => 'fns',
2925 'op' => 'fns', 'typeop' => 'fns',
2926 'method' => 'fns', 'typemethod' => 'fns',
2928 'vr' => 'vrs', 'var' => 'vrs',
2929 'typevr' => 'vrs', 'typevar' => 'vrs',
2932 'ivar' => 'vrs', 'typeivar' => 'vrs',
2937 # Indexes stored into another one. In this case, the *.??s file
2939 my @syncodeindexes = ();
2941 my $texi = new Automake::XFile "< $filename";
2942 verbose "reading $filename";
2944 my ($outfile, $vfile);
2945 while ($_ = $texi->getline)
2947 if (/^\@setfilename +(\S+)/)
2950 if ($outfile =~ /\.(.+)$/ && $1 ne 'info')
2952 file_error ("$filename:$.",
2953 "output `$outfile' has unrecognized extension");
2957 # A "version.texi" file is actually any file whose name
2958 # matches "vers*.texi".
2959 elsif (/^\@include\s+(vers[^.]*\.texi)\s*$/)
2964 # Try to find what are the indexes which are used.
2966 # Creating a new category of index.
2967 elsif (/^\@def(code)?index (\w+)/)
2969 push @clean_suffixes, $2;
2972 # Storing in a predefined index.
2973 elsif (/^\@([cfkvtp])index /)
2975 push @clean_suffixes, $predefined_index{$1};
2977 elsif (/^\@def(\w+) /)
2979 push @clean_suffixes, $hidden_index{$1}
2980 if defined $hidden_index{$1};
2983 # Merging an index into an another.
2984 elsif (/^\@syn(code)?index (\w+) (\w+)/)
2986 push @syncodeindexes, "$2s";
2987 push @clean_suffixes, "$3s";
2994 &am_error ("`$filename' missing \@setfilename");
2998 my $infobase = basename ($filename);
2999 $infobase =~ s/\.te?xi(nfo)?$//;
3000 # FIXME: I don't understand why, but I can't use "$infobase.$_" => 1.
3001 my %clean_files = map { "$infobase" . ".$_" => 1 } @clean_suffixes;
3002 grep { delete $clean_files{"$infobase.$_"} } @syncodeindexes;
3003 return ($outfile, $vfile, (sort keys %clean_files));
3007 # ($DO-SOMETHING, $TEXICLEANS)
3008 # handle_texinfo_helper ()
3010 # Handle all Texinfo source; helper for handle_texinfo
3011 sub handle_texinfo_helper
3013 macro_error ('TEXINFOS',
3014 "`TEXINFOS' is an anachronism; use `info_TEXINFOS'")
3015 if &variable_defined ('TEXINFOS');
3016 return (0, '') if (! &variable_defined ('info_TEXINFOS')
3017 && ! &variable_defined ('html_TEXINFOS'));
3019 if (&variable_defined ('html_TEXINFOS'))
3021 macro_error ('html_TEXINFOS',
3022 "HTML generation not yet supported");
3026 my @texis = &variable_value_as_list_recursive ('info_TEXINFOS', 'all');
3028 my (@info_deps_list, @dvis_list, @texi_deps);
3035 foreach my $info_cursor (@texis)
3037 my $infobase = $info_cursor;
3038 $infobase =~ s/\.(txi|texinfo|texi)$//;
3040 if ($infobase eq $info_cursor)
3042 # FIXME: report line number.
3043 &am_error ("texinfo file `$info_cursor' has unrecognized extension");
3046 $texi_suffixes{$1} = 1;
3048 # If 'version.texi' is referenced by input file, then include
3049 # automatic versioning capability.
3050 my ($out_file, $vtexi, @clean_files) =
3051 &scan_texinfo_file ("$relative_dir/$info_cursor")
3053 push (@texi_cleans, @clean_files);
3057 &am_error ("`$vtexi', included in `$info_cursor', also included in `$versions{$vtexi}'")
3058 if (defined $versions{$vtexi});
3059 $versions{$vtexi} = $info_cursor;
3061 # We number the stamp-vti files. This is doable since the
3062 # actual names don't matter much. We only number starting
3063 # with the second one, so that the common case looks nice.
3064 my $vti = ($done ? $done : 'vti');
3067 # This is ugly, but it is our historical practice.
3068 if ($config_aux_dir_set_in_configure_in)
3070 require_conf_file_with_macro ('info_TEXINFOS', $FOREIGN,
3075 require_file_with_macro ('info_TEXINFOS', $FOREIGN,
3080 if ($config_aux_dir_set_in_configure_in)
3082 $conf_dir = $config_aux_dir;
3083 $conf_dir .= '/' unless $conf_dir =~ /\/$/;
3087 $conf_dir = '$(srcdir)/';
3089 $output_rules .= &file_contents ('texi-vers',
3090 ('TEXI' => $info_cursor,
3093 'MDDIR' => $conf_dir));
3096 # If user specified file_TEXINFOS, then use that as explicit
3099 push (@texi_deps, $info_cursor);
3100 # Prefix with $(srcdir) because some version of make won't
3101 # work if the target has it and the dependency doesn't.
3102 push (@texi_deps, '$(srcdir)/' . $vtexi) if $vtexi;
3104 my $canonical = &canonicalize ($infobase);
3105 if (&variable_defined ($canonical . "_TEXINFOS"))
3107 push (@texi_deps, '$(' . $canonical . '_TEXINFOS)');
3108 &push_dist_common ('$(' . $canonical . '_TEXINFOS)');
3111 $output_rules .= ("\n" . $out_file . ": "
3112 . join (' ', @texi_deps)
3113 . "\n" . $infobase . ".dvi: "
3114 . join (' ', @texi_deps)
3117 push (@info_deps_list, $out_file);
3118 push (@dvis_list, $infobase . '.dvi');
3121 # Handle location of texinfo.tex.
3122 my $need_texi_file = 0;
3126 $texinfodir = '$(top_srcdir)/../texinfo';
3127 &define_variable ('TEXINFO_TEX', "$texinfodir/texinfo.tex");
3129 elsif ($config_aux_dir_set_in_configure_in)
3131 $texinfodir = $config_aux_dir;
3132 &define_variable ('TEXINFO_TEX', "$texinfodir/texinfo.tex");
3133 $need_texi_file = 2; # so that we require_conf_file later
3135 elsif (&variable_defined ('TEXINFO_TEX'))
3137 # The user defined TEXINFO_TEX so assume he knows what he is
3139 $texinfodir = ('$(srcdir)/'
3140 . dirname (&variable_value ('TEXINFO_TEX')));
3144 $texinfodir = '$(srcdir)';
3145 $need_texi_file = 1;
3148 foreach my $txsfx (sort keys %texi_suffixes)
3150 $output_rules .= &file_contents ('texibuild',
3151 ('TEXINFODIR' => $texinfodir,
3152 'SUFFIX' => $txsfx));
3156 my $texiclean = &pretty_print_internal ("", "\t ", @texi_cleans);
3158 push (@dist_targets, 'dist-info');
3160 if (! defined $options{'no-installinfo'})
3162 # Make sure documentation is made and installed first. Use
3163 # $(INFO_DEPS), not 'info', because otherwise recursive makes
3164 # get run twice during "make all".
3165 unshift (@all, '$(INFO_DEPS)');
3168 &define_variable ("INFO_DEPS", join (' ', @info_deps_list));
3169 &define_variable ("DVIS", join (' ', @dvis_list));
3170 # This next isn't strictly needed now -- the places that look here
3171 # could easily be changed to look in info_TEXINFOS. But this is
3172 # probably better, in case noinst_TEXINFOS is ever supported.
3173 &define_variable ("TEXINFOS", &variable_value ('info_TEXINFOS'));
3175 # Do some error checking. Note that this file is not required
3176 # when in Cygnus mode; instead we defined TEXINFO_TEX explicitly
3178 if ($need_texi_file && ! defined $options{'no-texinfo.tex'})
3180 if ($need_texi_file > 1)
3182 require_conf_file_with_macro ('info_TEXINFOS', $FOREIGN,
3187 require_file_with_macro ('info_TEXINFOS', $FOREIGN, 'texinfo.tex');
3191 return (1, $texiclean);
3196 # Handle all Texinfo source.
3199 my ($do_something, $texiclean) = handle_texinfo_helper ();
3200 $output_rules .= &file_contents ('texinfos',
3201 ('TEXICLEAN' => $texiclean,
3202 'LOCAL-TEXIS' => $do_something));
3205 # Handle any man pages.
3206 sub handle_man_pages
3208 macro_error ('MANS', "`MANS' is an anachronism; use `man_MANS'")
3209 if &variable_defined ('MANS');
3211 # Find all the sections in use. We do this by first looking for
3212 # "standard" sections, and then looking for any additional
3213 # sections used in man_MANS.
3214 my (%sections, %vlist);
3215 # We handle nodist_ for uniformity. man pages aren't distributed
3216 # by default so it isn't actually very important.
3217 foreach my $pfx ('', 'dist_', 'nodist_')
3219 # Add more sections as needed.
3220 foreach my $section ('0'..'9', 'n', 'l')
3222 if (&variable_defined ($pfx . 'man' . $section . '_MANS'))
3224 $sections{$section} = 1;
3225 $vlist{'$(' . $pfx . 'man' . $section . '_MANS)'} = 1;
3227 &push_dist_common ('$(' . $pfx . 'man' . $section . '_MANS)')
3232 if (&variable_defined ($pfx . 'man_MANS'))
3234 $vlist{'$(' . $pfx . 'man_MANS)'} = 1;
3235 foreach (&variable_value_as_list_recursive ($pfx . 'man_MANS', 'all'))
3237 # A page like `foo.1c' goes into man1dir.
3238 if (/\.([0-9a-z])([a-z]*)$/)
3244 &push_dist_common ('$(' . $pfx . 'man_MANS)')
3249 return unless %sections;
3251 # Now for each section, generate an install and unintall rule.
3252 # Sort sections so output is deterministic.
3253 foreach my $section (sort keys %sections)
3255 $output_rules .= &file_contents ('mans', ('SECTION' => $section));
3258 $output_vars .= &file_contents ('mans-vars',
3259 ('MANS' => join (' ', sort keys %vlist)));
3261 if (! defined $options{'no-installman'})
3263 push (@all, '$(MANS)');
3267 # Handle DATA variables.
3270 &am_install_var ('-noextra', '-candist', 'data', 'DATA',
3271 'data', 'sysconf', 'sharedstate', 'localstate',
3272 'pkgdata', 'noinst', 'check');
3279 if (&variable_defined ('SUBDIRS'))
3281 $output_rules .= ("tags-recursive:\n"
3282 . "\tlist=\'\$(SUBDIRS)\'; for subdir in \$\$list; do \\\n"
3283 # Never fail here if a subdir fails; it
3285 . "\t test \"\$\$subdir\" = . || (cd \$\$subdir"
3286 . " && \$(MAKE) \$(AM_MAKEFLAGS) tags); \\\n"
3288 push (@tag_deps, 'tags-recursive');
3289 &depend ('.PHONY', 'tags-recursive');
3292 if (&saw_sources_p (1)
3293 || &variable_defined ('ETAGS_ARGS')
3297 foreach my $one_hdr (@config_headers)
3299 if ($relative_dir eq dirname ($one_hdr))
3301 # The config header is in this directory. So require it.
3302 $config .= ' ' if $config;
3303 $config .= basename ($one_hdr);
3306 $output_rules .= &file_contents ('tags',
3307 ('CONFIG' => $config,
3308 'DIRS' => join (' ', @tag_deps)));
3309 &examine_variable ('TAGS_DEPENDENCIES');
3311 elsif (&variable_defined ('TAGS_DEPENDENCIES'))
3313 macro_error ('TAGS_DEPENDENCIES',
3314 "doesn't make sense to define `TAGS_DEPENDENCIES' without sources or `ETAGS_ARGS'");
3318 # Every Makefile must define some sort of TAGS rule.
3319 # Otherwise, it would be possible for a top-level "make TAGS"
3320 # to fail because some subdirectory failed.
3321 $output_rules .= "tags: TAGS\nTAGS:\n\n";
3325 # Handle multilib support.
3328 if ($seen_multilib && $relative_dir eq '.')
3330 $output_rules .= &file_contents ('multilib');
3336 # &for_dist_common ($A, $B)
3337 # -------------------------
3338 # Subroutine for &handle_dist: sort files to dist.
3340 # We put README first because it then becomes easier to make a
3341 # Usenet-compliant shar file (in these, README must be first).
3343 # FIXME: do more ordering of files here.
3356 # handle_dist ($MAKEFILE)
3357 # -----------------------
3358 # Handle 'dist' target.
3361 my ($makefile) = @_;
3363 # `make dist' isn't used in a Cygnus-style tree.
3364 # Omit the rules so that people don't try to use them.
3365 return if $cygnus_mode;
3367 # Look for common files that should be included in distribution.
3368 # If the aux dir is set, and it does not have a Makefile.am, then
3369 # we check for these files there as well.
3372 if ($relative_dir eq '.'
3373 && $config_aux_dir_set_in_configure_in)
3375 ($auxdir = $config_aux_dir) =~ s,^\$\(top_srcdir\)/,,;
3376 if (! &is_make_dir ($auxdir))
3381 foreach my $cfile (@common_files)
3383 if (-f ($relative_dir . "/" . $cfile))
3385 &push_dist_common ($cfile);
3388 # Don't use `elsif' here because a file might meaningfully
3389 # appear in both directories.
3390 if ($check_aux && -f ($auxdir . '/' . $cfile))
3392 &push_dist_common ($auxdir . '/' . $cfile);
3396 # We might copy elements from $configure_dist_common to
3397 # %dist_common if we think we need to. If the file appears in our
3398 # directory, we would have discovered it already, so we don't
3399 # check that. But if the file is in a subdir without a Makefile,
3400 # we want to distribute it here if we are doing `.'. Ugly!
3401 if ($relative_dir eq '.')
3403 foreach my $file (split (' ' , $configure_dist_common))
3405 if (! &is_make_dir (dirname ($file)))
3407 &push_dist_common ($file);
3414 # Files to distributed. Don't use &variable_value_as_list_recursive
3415 # as it recursively expands `$(dist_pkgdata_DATA)' etc.
3416 check_variable_defined_unconditionally ('DIST_COMMON');
3417 my @dist_common = split (' ', variable_value ('DIST_COMMON', 'TRUE'));
3418 @dist_common = uniq (sort for_dist_common (@dist_common));
3419 pretty_print ('DIST_COMMON = ', "\t", @dist_common);
3421 # Now that we've processed DIST_COMMON, disallow further attempts
3423 $handle_dist_run = 1;
3425 # Scan EXTRA_DIST to see if we need to distribute anything from a
3426 # subdir. If so, add it to the list. I didn't want to do this
3427 # originally, but there were so many requests that I finally
3429 if (&variable_defined ('EXTRA_DIST'))
3431 # FIXME: This should be fixed to work with conditionals. That
3432 # will require only making the entries in %dist_dirs under the
3433 # appropriate condition. This is meaningful if the nature of
3434 # the distribution should depend upon the configure options
3436 foreach (&variable_value_as_list_recursive ('EXTRA_DIST', ''))
3439 next unless s,/+[^/]+$,,;
3445 # We have to check DIST_COMMON for extra directories in case the
3446 # user put a source used in AC_OUTPUT into a subdir.
3447 foreach (&variable_value_as_list_recursive ('DIST_COMMON', 'all'))
3450 next unless s,/+[^/]+$,,;
3455 # Rule to check whether a distribution is viable.
3456 my %transform = ('DISTCHECK-HOOK' => &target_defined ('distcheck-hook'),
3457 'GETTEXT' => $seen_gettext);
3459 # Prepend $(distdir) to each directory given.
3460 my %rewritten = map { '$(distdir)/' . "$_" => 1 } keys %dist_dirs;
3461 $transform{'DISTDIRS'} = join (' ', sort keys %rewritten);
3463 # If we have SUBDIRS, create all dist subdirectories and do
3465 if (&variable_defined ('SUBDIRS'))
3467 # If SUBDIRS is conditionally defined, then set DIST_SUBDIRS
3468 # to all possible directories, and use it. If DIST_SUBDIRS is
3469 # defined, just use it.
3470 my $dist_subdir_name;
3471 # Note that we check DIST_SUBDIRS first on purpose. At least
3472 # one project uses so many conditional subdirectories that
3473 # calling variable_conditionally_defined on SUBDIRS will cause
3474 # automake to grow to 150Mb. Sigh.
3475 if (&variable_defined ('DIST_SUBDIRS')
3476 || variable_conditionally_defined ('SUBDIRS'))
3478 $dist_subdir_name = 'DIST_SUBDIRS';
3479 if (! &variable_defined ('DIST_SUBDIRS'))
3481 define_pretty_variable
3482 ('DIST_SUBDIRS', '',
3483 uniq (&variable_value_as_list_recursive ('SUBDIRS', 'all')));
3488 $dist_subdir_name = 'SUBDIRS';
3489 # We always define this because that is what `distclean'
3491 define_pretty_variable ('DIST_SUBDIRS', '', '$(SUBDIRS)');
3494 $transform{'DIST_SUBDIR_NAME'} = $dist_subdir_name;
3497 # If the target `dist-hook' exists, make sure it is run. This
3498 # allows users to do random weird things to the distribution
3499 # before it is packaged up.
3500 push (@dist_targets, 'dist-hook')
3501 if &target_defined ('dist-hook');
3502 $transform{'DIST-TARGETS'} = join(' ', @dist_targets);
3504 # Defining $(DISTDIR).
3505 $transform{'DISTDIR'} = !&variable_defined('distdir');
3506 $transform{'TOP_DISTDIR'} = backname ($relative_dir);
3508 $output_rules .= &file_contents ('distdir', %transform);
3512 # Handle subdirectories.
3516 unless &variable_defined ('SUBDIRS');
3518 # Make sure each directory mentioned in SUBDIRS actually exists.
3519 foreach my $dir (&variable_value_as_list_recursive ('SUBDIRS', 'all'))
3521 # Skip directories substituted by configure.
3522 next if $dir =~ /^\@.*\@$/;
3524 if (! -d $am_relative_dir . '/' . $dir)
3526 macro_error ('SUBDIRS',
3527 "required directory $am_relative_dir/$dir does not exist");
3531 macro_error ('SUBDIRS', "directory should not contain `/'")
3535 $output_rules .= &file_contents ('subdirs');
3536 variable_pretty_output ('RECURSIVE_TARGETS', 'TRUE');
3540 # ($REGEN, @DEPENDENCIES)
3543 # If aclocal.m4 creation is automated, return the list of its dependencies.
3546 my $regen_aclocal = 0;
3549 unless $relative_dir eq '.';
3551 &examine_variable ('CONFIG_STATUS_DEPENDENCIES');
3552 &examine_variable ('CONFIGURE_DEPENDENCIES');
3554 if (-f 'aclocal.m4')
3556 &define_variable ("ACLOCAL_M4", '$(top_srcdir)/aclocal.m4');
3557 &push_dist_common ('aclocal.m4');
3559 my $aclocal = new Automake::XFile "< aclocal.m4";
3560 my $line = $aclocal->getline;
3561 $regen_aclocal = $line =~ 'generated automatically by aclocal';
3566 if (-f 'acinclude.m4')
3569 push @ac_deps, 'acinclude.m4';
3572 if (&variable_defined ('ACLOCAL_M4_SOURCES'))
3574 push (@ac_deps, '$(ACLOCAL_M4_SOURCES)');
3576 elsif (&variable_defined ('ACLOCAL_AMFLAGS'))
3578 # Scan all -I directories for m4 files. These are our
3580 my $examine_next = 0;
3581 foreach my $amdir (&variable_value_as_list_recursive ('ACLOCAL_AMFLAGS', ''))
3586 if ($amdir !~ /^\// && -d $amdir)
3588 foreach my $ac_dep (&my_glob ($amdir . '/*.m4'))
3590 $ac_dep =~ s/^\.\/+//;
3591 push (@ac_deps, $ac_dep)
3592 unless $ac_dep eq "aclocal.m4"
3593 || $ac_dep eq "acinclude.m4";
3597 elsif ($amdir eq '-I')
3604 # Note that it might be possible that aclocal.m4 doesn't exist but
3605 # should be auto-generated. This case probably isn't very
3608 return ($regen_aclocal, @ac_deps);
3613 # &rewrite_inputs_into_dependencies ($ADD_SRCDIR, @INPUTS)
3614 # --------------------------------------------------------
3615 # Rewrite a list of input files into a form suitable to put on a
3616 # dependency list. The idea is that if an input file has a directory
3617 # part the same as the current directory, then the directory part is
3618 # simply removed. But if the directory part is different, then
3619 # $(top_srcdir) is prepended. Among other things, this is used to
3620 # generate the dependency list for the output files generated by
3621 # AC_OUTPUT. Consider what the dependencies should look like in this
3623 # AC_OUTPUT(src/out:src/in1:lib/in2)
3624 # The first argument, ADD_SRCDIR, is 1 if $(top_srcdir) should be added.
3625 # If 0 then files that require this addition will simply be ignored.
3626 sub rewrite_inputs_into_dependencies ($@)
3628 my ($add_srcdir, @inputs) = @_;
3631 foreach my $single (@inputs)
3633 if (dirname ($single) eq $relative_dir)
3635 push (@newinputs, basename ($single));
3639 push (@newinputs, '$(top_srcdir)/' . $single);
3646 # Handle remaking and configure stuff.
3647 # We need the name of the input file, to do proper remaking rules.
3648 sub handle_configure
3650 my ($local, $input, @secondary_inputs) = @_;
3652 my $input_base = basename ($input);
3653 my $local_base = basename ($local);
3655 my $amfile = $input_base . '.am';
3656 # We know we can always add '.in' because it really should be an
3657 # error if the .in was missing originally.
3658 my $infile = '$(srcdir)/' . $input_base . '.in';
3659 my $colon_infile = '';
3660 if ($local ne $input || @secondary_inputs)
3662 $colon_infile = ':' . $input . '.in';
3664 $colon_infile .= ':' . join (':', @secondary_inputs)
3665 if @secondary_inputs;
3667 my @rewritten = rewrite_inputs_into_dependencies (1, @secondary_inputs);
3669 my ($regen_aclocal_m4, @aclocal_m4_deps) = scan_aclocal_m4 ();
3672 &file_contents ('configure',
3676 => join (' ', @rewritten),
3678 => ((($relative_dir eq '.') ? '$@' : '$(subdir)/$@')
3683 => join (' ', @include_stack),
3687 => $cygnus_mode ? 'cygnus' : $strictness_name,
3689 => $cmdline_use_dependencies ? '' : ' --ignore-deps',
3690 'MAKEFILE-AM-SOURCES'
3691 => "$input$colon_infile",
3693 => $regen_aclocal_m4,
3695 => join (' ', @aclocal_m4_deps)));
3697 if ($relative_dir eq '.')
3699 &push_dist_common ('acconfig.h')
3703 # If we have a configure header, require it.
3704 my @local_fullnames = @config_fullnames;
3705 my @local_names = @config_names;
3707 my $distclean_config = '';
3708 foreach my $one_hdr (@config_headers)
3710 my $one_fullname = shift (@local_fullnames);
3711 my $one_name = shift (@local_names);
3713 my $header_dir = dirname ($one_name);
3715 # If the header is in the current directory we want to build
3716 # the header here. Otherwise, if we're at the topmost
3717 # directory and the header's directory doesn't have a
3718 # Makefile, then we also want to build the header.
3719 if ($relative_dir eq $header_dir
3720 || ($relative_dir eq '.' && ! &is_make_dir ($header_dir)))
3722 my ($cn_sans_dir, $stamp_dir);
3723 if ($relative_dir eq $header_dir)
3725 $cn_sans_dir = basename ($one_name);
3730 $cn_sans_dir = $one_name;
3731 if ($header_dir eq '.')
3737 $stamp_dir = $header_dir . '/';
3741 # Compute relative path from directory holding output
3742 # header to directory holding input header. FIXME:
3743 # doesn't handle case where we have multiple inputs.
3745 if (dirname ($one_hdr) eq $relative_dir)
3747 $ch_sans_dir = basename ($one_hdr);
3751 $ch_sans_dir = backname ($relative_dir) . '/' . $one_hdr;
3754 require_file ($config_header_location, $FOREIGN, $ch_sans_dir);
3756 # Header defined and in this directory.
3758 if (-f $one_name . '.top')
3760 push (@files, "${cn_sans_dir}.top");
3762 if (-f $one_name . '.bot')
3764 push (@files, "${cn_sans_dir}.bot");
3767 &push_dist_common (@files);
3769 # For now, acconfig.h can only appear in the top srcdir.
3770 if (-f 'acconfig.h')
3772 push (@files, '$(top_srcdir)/acconfig.h');
3775 my $stamp_name = 'stamp-h';
3776 $stamp_name .= "${hdr_index}";
3778 my $out_dir = dirname ($ch_sans_dir);
3781 &file_contents ('remake-hdr',
3782 ('FILES' => join (' ', @files),
3783 'CONFIG_HEADER' => $cn_sans_dir,
3784 'CONFIG_HEADER_IN' => $ch_sans_dir,
3785 'CONFIG_HEADER_FULL' => $one_name,
3786 'STAMP' => "$stamp_dir$stamp_name",
3787 'SRC_STAMP' => "$out_dir/$stamp_name"));
3789 &create ("${relative_dir}/${out_dir}/${stamp_name}.in");
3790 require_file ($config_header_location, $FOREIGN,
3791 "${out_dir}/${stamp_name}.in");
3793 $distclean_config .= ' ' if $distclean_config;
3794 $distclean_config .= $cn_sans_dir;
3798 if ($distclean_config)
3800 $output_rules .= &file_contents ('clean-hdr',
3801 ('FILES' => $distclean_config));
3804 # Set location of mkinstalldirs.
3805 &define_variable ('mkinstalldirs',
3806 ('$(SHELL) ' . $config_aux_dir . '/mkinstalldirs'));
3808 macro_error ('CONFIG_HEADER',
3809 "`CONFIG_HEADER' is an anachronism; now determined from `$configure_ac'")
3810 if &variable_defined ('CONFIG_HEADER');
3812 my $config_header = '';
3813 foreach my $one_name (@config_names)
3815 # Generate CONFIG_HEADER define.
3817 if ($relative_dir eq dirname ($one_name))
3819 $one_hdr = basename ($one_name);
3823 $one_hdr = "\$(top_builddir)/${one_name}";
3826 $config_header .= ' ' if $config_header;
3827 $config_header .= $one_hdr;
3831 &define_variable ("CONFIG_HEADER", $config_header);
3834 # Now look for other files in this directory which must be remade
3835 # by config.status, and generate rules for them.
3836 my @actual_other_files = ();
3837 foreach my $lfile (@other_input_files)
3841 if ($lfile =~ /^([^:]*):(.*)$/)
3843 # This is the ":" syntax of AC_OUTPUT.
3845 @inputs = split (':', $2);
3851 @inputs = $file . '.in';
3854 # Automake files should not be stored in here, but in %MAKE_LIST.
3855 prog_error ("$lfile in \@other_input_files")
3856 if -f $file . '.am';
3858 my $local = basename ($file);
3860 # Make sure the dist directory for each input file is created.
3861 # We only have to do this at the topmost level though. This
3862 # is a bit ugly but it easier than spreading out the logic,
3863 # especially in cases like AC_OUTPUT(foo/out:bar/in), where
3864 # there is no Makefile in bar/.
3865 if ($relative_dir eq '.')
3869 $dist_dirs{dirname ($_)} = 1;
3873 # We skip files that aren't in this directory. However, if
3874 # the file's directory does not have a Makefile, and we are
3875 # currently doing `.', then we create a rule to rebuild the
3876 # file in the subdir.
3877 my $fd = dirname ($file);
3878 if ($fd ne $relative_dir)
3880 if ($relative_dir eq '.' && ! &is_make_dir ($fd))
3890 # Some users have been tempted to put `stamp-h' in the
3891 # AC_OUTPUT line. This won't do the right thing, so we
3892 # explicitly fail here.
3893 if ($local eq 'stamp-h')
3895 # FIXME: allow real filename.
3896 file_error ($ac_config_files_location,
3897 'stamp-h should not appear in AC_OUTPUT');
3901 my @rewritten_inputs = rewrite_inputs_into_dependencies (1, @inputs);
3902 $output_rules .= ($local . ': '
3903 . '$(top_builddir)/config.status '
3904 . "@rewritten_inputs\n"
3906 . 'cd $(top_builddir) && '
3907 . '$(SHELL) ./config.status '
3908 . ($relative_dir eq '.' ? '' : '$(subdir)/')
3911 push (@actual_other_files, $local);
3913 # Require all input files.
3914 require_file ($ac_config_files_location, $FOREIGN,
3915 rewrite_inputs_into_dependencies (0, @inputs));
3918 # These files get removed by "make clean".
3919 define_pretty_variable ('CONFIG_CLEAN_FILES', '', @actual_other_files);
3925 my @r = &am_install_var ('-defaultdist', 'header', 'HEADERS', 'include',
3926 'oldinclude', 'pkginclude',
3930 next unless /\.(.*)$/;
3931 &saw_extension ($1);
3937 return if ! $seen_gettext || $relative_dir ne '.';
3939 if (! &variable_defined ('SUBDIRS'))
3941 conf_error ("AM_GNU_GETTEXT used but SUBDIRS not defined");
3945 my @subdirs = &variable_value_as_list_recursive ('SUBDIRS', 'all');
3946 macro_error ('SUBDIRS',
3947 "AM_GNU_GETTEXT used but `po' not in SUBDIRS")
3948 if ! grep ('po', @subdirs);
3949 macro_error ('SUBDIRS',
3950 "AM_GNU_GETTEXT used but `intl' not in SUBDIRS")
3951 if ! grep ('intl', @subdirs);
3953 require_file ($ac_gettext_location, $GNU, 'ABOUT-NLS');
3956 # Handle footer elements.
3959 # NOTE don't use define_pretty_variable here, because
3960 # $contents{...} is already defined.
3961 $output_vars .= 'SOURCES = ' . variable_value ('SOURCES') . "\n\n"
3962 if variable_value ('SOURCES');
3965 target_error ('.SUFFIXES',
3966 "use variable `SUFFIXES', not target `.SUFFIXES'")
3967 if target_defined ('.SUFFIXES');
3969 # Note: AIX 4.1 /bin/make will fail if any suffix rule appears
3970 # before .SUFFIXES. So we make sure that .SUFFIXES appears before
3971 # anything else, by sticking it right after the default: target.
3972 $output_header .= ".SUFFIXES:\n";
3973 if (@suffixes || &variable_defined ('SUFFIXES'))
3975 # Make sure suffixes has unique elements. Sort them to ensure
3976 # the output remains consistent. However, $(SUFFIXES) is
3977 # always at the start of the list, unsorted. This is done
3978 # because make will choose rules depending on the ordering of
3979 # suffixes, and this lets the user have some control. Push
3980 # actual suffixes, and not $(SUFFIXES). Some versions of make
3981 # do not like variable substitutions on the .SUFFIXES line.
3982 my @user_suffixes = (&variable_defined ('SUFFIXES')
3983 ? &variable_value_as_list_recursive ('SUFFIXES', '')
3986 my %suffixes = map { $_ => 1 } @suffixes;
3987 delete @suffixes{@user_suffixes};
3989 $output_header .= (".SUFFIXES: "
3990 . join (' ', @user_suffixes, sort keys %suffixes)
3994 $output_trailer .= file_contents ('footer');
3997 # Deal with installdirs target.
3998 sub handle_installdirs ()
4001 &file_contents ('install',
4003 => variable_value ('_am_installdirs') || ''));
4007 # Deal with all and all-am.
4010 my ($makefile) = @_;
4014 # Put this at the beginning for the sake of non-GNU makes. This
4015 # is still wrong if these makes can run parallel jobs. But it is
4017 unshift (@all, basename ($makefile));
4019 foreach my $one_name (@config_names)
4021 push (@all, basename ($one_name))
4022 if dirname ($one_name) eq $relative_dir;
4025 # Install `all' hooks.
4026 if (&target_defined ("all-local"))
4028 push (@all, "all-local");
4029 &depend ('.PHONY', "all-local");
4032 &pretty_print_rule ("all-am:", "\t\t", @all);
4033 &depend ('.PHONY', 'all-am', 'all');
4038 my @local_headers = ();
4039 push @local_headers, '$(BUILT_SOURCES)'
4040 if &variable_defined ('BUILT_SOURCES');
4041 foreach my $one_name (@config_names)
4043 push @local_headers, basename ($one_name)
4044 if dirname ($one_name) eq $relative_dir;
4049 # We need to make sure config.h is built before we recurse.
4050 # We also want to make sure that built sources are built
4051 # before any ordinary `all' targets are run. We can't do this
4052 # by changing the order of dependencies to the "all" because
4053 # that breaks when using parallel makes. Instead we handle
4054 # things explicitly.
4055 $output_all .= ("all: " . join (' ', @local_headers)
4057 . '$(MAKE) $(AM_MAKEFLAGS) '
4058 . (&variable_defined ('SUBDIRS')
4059 ? 'all-recursive' : 'all-am')
4064 $output_all .= "all: " . (&variable_defined ('SUBDIRS')
4065 ? 'all-recursive' : 'all-am') . "\n\n";
4070 # Handle check merge target specially.
4071 sub do_check_merge_target
4073 if (&target_defined ('check-local'))
4075 # User defined local form of target. So include it.
4076 push (@check_tests, 'check-local');
4077 &depend ('.PHONY', 'check-local');
4080 # In --cygnus mode, check doesn't depend on all.
4083 # Just run the local check rules.
4084 &pretty_print_rule ('check-am:', "\t\t", @check);
4088 # The check target must depend on the local equivalent of
4089 # `all', to ensure all the primary targets are built. Then it
4090 # must build the local check rules.
4091 $output_rules .= "check-am: all-am\n";
4092 &pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ",
4096 &pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ",
4100 &depend ('.PHONY', 'check', 'check-am');
4101 $output_rules .= ("check: "
4102 . (&variable_defined ('SUBDIRS')
4103 ? 'check-recursive' : 'check-am')
4107 # Handle all 'clean' targets.
4112 # Don't include `MAINTAINER'; it is handled specially below.
4113 foreach my $name ('MOSTLY', '', 'DIST')
4115 $transform{"${name}CLEAN"} = &variable_defined ("${name}CLEANFILES");
4118 # Built sources are automatically removed by maintainer-clean.
4119 push (@maintainer_clean_files, '$(BUILT_SOURCES)')
4120 if &variable_defined ('BUILT_SOURCES');
4121 push (@maintainer_clean_files, '$(MAINTAINERCLEANFILES)')
4122 if &variable_defined ('MAINTAINERCLEANFILES');
4124 $output_rules .= &file_contents ('clean',
4127 # Join with no space to avoid
4128 # spurious `test -z' success at
4130 => join ('', @maintainer_clean_files),
4132 # A space is required in the join here.
4133 => join (' ', @maintainer_clean_files)));
4137 # &depend ($CATEGORY, @DEPENDENDEES)
4138 # ----------------------------------
4139 # The target $CATEGORY depends on @DEPENDENDEES.
4142 my ($category, @dependendees) = @_;
4144 push (@{$dependencies{$category}}, @dependendees);
4149 # &target_cmp ($A, $B)
4150 # --------------------
4151 # Subroutine for &handle_factored_dependencies to let `.PHONY' be last.
4164 # &handle_factored_dependencies ()
4165 # --------------------------------
4166 # Handle everything related to gathered targets.
4167 sub handle_factored_dependencies
4170 foreach my $utarg ('uninstall-data-local', 'uninstall-data-hook',
4171 'uninstall-exec-local', 'uninstall-exec-hook')
4173 if (&target_defined ($utarg))
4176 $x =~ s/(data|exec)-//;
4177 target_error ($utarg, "use `$x', not `$utarg'");
4181 if (&target_defined ('install-local'))
4183 target_error ('install-local',
4184 "use `install-data-local' or `install-exec-local', "
4185 . "not `install-local'");
4188 if (!defined $options{'no-installinfo'}
4189 && &target_defined ('install-info-local'))
4191 target_error ('install-info-local',
4192 "`install-info-local' target defined but "
4193 . "`no-installinfo' option not in use");
4196 # Install the -local hooks.
4197 foreach (keys %dependencies)
4199 # Hooks are installed on the -am targets.
4201 if (&target_defined ("$_-local"))
4203 depend ("$_-am", "$_-local");
4204 &depend ('.PHONY', "$_-local");
4208 # Install the -hook hooks.
4209 # FIXME: Why not be as liberal as we are with -local hooks?
4210 foreach ('install-exec', 'install-data')
4212 if (&target_defined ("$_-hook"))
4214 $actions{"$_-am"} .=
4215 ("\t\@\$(NORMAL_INSTALL)\n"
4216 . "\t" . '$(MAKE) $(AM_MAKEFLAGS) ' . "$_-hook\n");
4220 # All the required targets are phony.
4221 depend ('.PHONY', keys %required_targets);
4223 # Actually output gathered targets.
4224 foreach (sort target_cmp keys %dependencies)
4226 # If there is nothing about this guy, skip it.
4228 unless (@{$dependencies{$_}}
4230 || $required_targets{$_});
4231 &pretty_print_rule ("$_:", "\t",
4232 uniq (sort @{$dependencies{$_}}));
4233 $output_rules .= $actions{$_}
4234 if defined $actions{$_};
4235 $output_rules .= "\n";
4240 # &handle_tests_dejagnu ()
4241 # ------------------------
4242 sub handle_tests_dejagnu
4244 push (@check_tests, 'check-DEJAGNU');
4245 $output_rules .= file_contents ('dejagnu');
4249 # Handle TESTS variable and other checks.
4252 if (defined $options{'dejagnu'})
4254 &handle_tests_dejagnu;
4258 foreach my $c ('DEJATOOL', 'RUNTEST', 'RUNTESTFLAGS')
4261 "`$c' defined but `dejagnu' not in `AUTOMAKE_OPTIONS'")
4262 if &variable_defined ($c);
4266 if (&variable_defined ('TESTS'))
4268 push (@check_tests, 'check-TESTS');
4269 $output_rules .= &file_contents ('check');
4273 # Handle Emacs Lisp.
4274 sub handle_emacs_lisp
4276 my @elfiles = &am_install_var ('-candist', 'lisp', 'LISP',
4279 return if ! @elfiles;
4281 # Generate .elc files.
4282 my @elcfiles = map { $_ . 'c' } @elfiles;
4283 define_pretty_variable ('ELCFILES', '', @elcfiles);
4285 push (@all, '$(ELCFILES)');
4287 &am_error ("`lisp_LISP' defined but `AM_PATH_LISPDIR' not in `$configure_ac'")
4288 if ! $am_lispdir_location && &variable_defined ('lisp_LISP');
4290 require_conf_file ($am_lispdir_location, $FOREIGN, 'elisp-comp');
4291 &define_variable ('elisp_comp', $config_aux_dir . '/elisp-comp');
4297 my @pyfiles = &am_install_var ('-defaultdist', 'python', 'PYTHON',
4298 'python', 'noinst');
4299 return if ! @pyfiles;
4301 # Found some python.
4302 &am_error ("`python_PYTHON' defined but `AM_PATH_PYTHON' not in `$configure_ac'")
4303 if ! $pythondir_location && &variable_defined ('python_PYTHON');
4305 require_conf_file ($pythondir_location, $FOREIGN, 'py-compile');
4306 &define_variable ('py_compile', $config_aux_dir . '/py-compile');
4312 my @sourcelist = &am_install_var ('-candist',
4314 'java', 'noinst', 'check');
4315 return if ! @sourcelist;
4317 my %valid = &am_primary_prefixes ('JAVA', 1,
4318 'java', 'noinst', 'check');
4321 foreach my $curs (keys %valid)
4323 if (! &variable_defined ($curs . '_JAVA') || $curs eq 'EXTRA')
4330 macro_error ($curs . '_JAVA',
4331 "multiple _JAVA primaries in use");
4336 push (@all, 'class' . $dir . '.stamp');
4340 # Handle some of the minor options.
4341 sub handle_minor_options
4343 if (defined $options{'readme-alpha'})
4345 if ($relative_dir eq '.')
4347 if ($package_version !~ /^$GNITS_VERSION_PATTERN$/)
4349 # FIXME: allow real filename.
4350 file_error ($package_version_location,
4351 "version `$package_version' doesn't follow Gnits standards");
4353 elsif (defined $1 && -f 'README-alpha')
4355 # This means we have an alpha release. See
4356 # GNITS_VERSION_PATTERN for details.
4357 require_file_with_macro ('AUTOMAKE_OPTIONS',
4358 $FOREIGN, 'README-alpha');
4364 ################################################################
4368 # &scan_autoconf_config_files ($CONFIG-FILES)
4369 # -------------------------------------------
4370 # Study $CONFIG-FILES which is the first argument to AC_CONFIG_FILES
4372 sub scan_autoconf_config_files
4374 my ($config_files) = @_;
4375 # Look at potential Makefile.am's.
4376 foreach (split ' ', $config_files)
4378 # Must skip empty string for Perl 4.
4379 next if $_ eq "\\" || $_ eq '';
4381 # Handle $local:$input syntax. Note that we ignore
4382 # every input file past the first, though we keep
4383 # those around for later.
4384 my ($local, $input, @rest) = split (/:/);
4391 # FIXME: should be error if .in is missing.
4392 $input =~ s/\.in$//;
4395 if (-f $input . '.am')
4397 # We have a file that automake should generate.
4398 $make_list{$input} = join (':', ($local, @rest));
4402 # We have a file that automake should cause to be
4403 # rebuilt, but shouldn't generate itself.
4404 push (@other_input_files, $_);
4410 # &scan_autoconf_traces ($FILENAME)
4411 # ---------------------------------
4412 # FIXME: For the time being, we don't care about the FILENAME.
4413 sub scan_autoconf_traces ($)
4415 my ($filename) = @_;
4418 'AC_CANONICAL_HOST',
4419 'AC_CANONICAL_SYSTEM',
4420 'AC_CONFIG_AUX_DIR',
4423 'AC_PROG_LIBTOOL', 'AM_PROG_LIBTOOL',
4431 'AM_MAINTAINER_MODE',
4437 my $traces = "$ENV{amtraces} ";
4439 # Use a separator unlikely to be used, not `:', the default, which
4440 # has a precise meaning for AC_CONFIG_FILES and so on.
4441 $traces .= join (' ',
4442 map { "--trace=$_" . ':\$f:\$l::\$n::\${::}%' } @traced);
4444 my $tracefh = new Automake::XFile ("$traces |");
4445 verbose "reading $traces";
4447 while ($_ = $tracefh->getline)
4450 my ($here, @args) = split /::/;
4451 my $macro = $args[0];
4453 # Alphabetical ordering please.
4454 if ($macro eq 'AC_CANONICAL_HOST')
4456 if (! $seen_canonical)
4458 $seen_canonical = $AC_CANONICAL_HOST;
4459 $canonical_location = $here;
4462 elsif ($macro eq 'AC_CANONICAL_SYSTEM')
4464 $seen_canonical = $AC_CANONICAL_SYSTEM;
4465 $canonical_location = $here;
4467 elsif ($macro eq 'AC_CONFIG_AUX_DIR')
4469 @config_aux_path = $args[1];
4470 $config_aux_dir_set_in_configure_in = 1;
4472 elsif ($macro eq 'AC_CONFIG_FILES')
4474 # Look at potential Makefile.am's.
4475 $ac_config_files_location = $here;
4476 &scan_autoconf_config_files ($args[1]);
4478 elsif ($macro eq 'AC_LIBSOURCE')
4480 # We should actually also `close' the sources: getopt.c
4481 # wants getopt.h etc. But actually it should be done in the
4482 # macro itself, i.e., we have to first fix Autoconf to extend
4483 # _AC_LIBOBJ_DECL and use it the in various macros.
4484 $libsources{$args[1]} = $here;
4486 elsif ($macro =~ /A(C|M)_PROG_LIBTOOL/)
4488 $seen_libtool = $here;
4489 $libtool_location = $here;
4491 elsif ($macro =~ /AC_PROG_LEX/)
4493 $seen_prog_lex = $here;
4495 elsif ($macro eq 'AC_SUBST')
4497 # Just check for alphanumeric in AC_SUBST. If you do
4498 # AC_SUBST(5), then too bad.
4499 $configure_vars{$args[1]} = $here
4500 if $args[1] =~ /^\w+$/;
4502 elsif ($macro eq 'AM_CONDITIONAL')
4504 $configure_cond{$args[1]} = $here;
4506 elsif ($macro eq 'AM_CONFIG_HEADER')
4508 $config_header_location = $here;
4509 foreach my $one_hdr (split (' ', $args[1]))
4511 push (@config_fullnames, $one_hdr);
4512 if ($one_hdr =~ /^([^:]+):(.+)$/)
4514 push (@config_names, $1);
4515 push (@config_headers, $2);
4519 push (@config_names, $one_hdr);
4520 push (@config_headers, $one_hdr . '.in');
4524 elsif ($macro eq 'AM_C_PROTOTYPES')
4526 $am_c_prototypes = $here;
4528 elsif ($macro eq 'AM_GNU_GETTEXT')
4530 $seen_gettext = $here;
4531 $ac_gettext_location = $here;
4533 elsif ($macro eq 'AM_INIT_AUTOMAKE')
4535 $package_version = $args[2];
4536 $package_version_location = $here;
4537 $seen_init_automake = 1;
4539 elsif ($macro eq 'AM_MAINTAINER_MODE')
4541 $seen_maint_mode = $here;
4543 elsif ($macro eq 'AM_PATH_LISPDIR')
4545 $am_lispdir_location = $here;
4547 elsif ($macro eq 'AM_PATH_PYTHON')
4549 $pythondir_location = $here;
4551 elsif ($macro eq 'AM_PROG_CC_C_O')
4553 $seen_cc_c_o = $here;
4559 # &scan_one_autoconf_file ($FILENAME)
4560 # -----------------------------------
4561 # Scan one file for interesting things. Subroutine of
4562 # &scan_autoconf_files.
4563 sub scan_one_autoconf_file
4565 my ($filename) = @_;
4567 # Some macros already provide the right traces to enable generic
4568 # code and specific arguments, instead of dedicated code. But
4569 # currently we don't handle traces. Rewrite these dedicated
4570 # macros handling into the generic macro invocation, and let our
4571 # generic case handle them.
4575 'AC_FUNC_ALLOCA' => 'AC_LIBSOURCES([alloca.c])',
4576 'AC_FUNC_GETLOADAVG' => 'AC_LIBSOURCES([getloadavg.c])',
4577 'AC_FUNC_MEMCMP' => 'AC_LIBSOURCES([memcmp.c])',
4578 'AC_STRUCT_ST_BLOCKS' => 'AC_LIBSOURCES([fileblocks.c])',
4579 'A[CM]_REPLACE_GNU_GETOPT' => 'AC_LIBSOURCES([getopt.c, getopt1.c])',
4580 'A[CM]_FUNC_STRTOD' => 'AC_LIBSOURCES([strtod.c])',
4581 'AM_WITH_REGEX' => 'AC_LIBSOURCES([rx.c, rx.h, regex.c, regex.h])',
4582 'AC_FUNC_MKTIME' => 'AC_LIBSOURCES([mktime.c])',
4583 'A[CM]_FUNC_ERROR_AT_LINE' => 'AC_LIBSOURCES([error.c, error.h])',
4584 'A[CM]_FUNC_OBSTACK' => 'AC_LIBSOURCES([obstack.c, obstack.h])',
4587 my $configfh = new Automake::XFile ("< $filename");
4588 verbose "reading $filename";
4590 my ($in_ac_output, $in_ac_replace) = (0, 0);
4591 while ($_ = $configfh->getline)
4593 # Remove comments from current line.
4597 # Skip macro definitions. Otherwise we might be confused into
4598 # thinking that a macro that was only defined was actually
4602 # Follow includes. This is a weirdness commonly in use at
4603 # Cygnus and hopefully nowhere else.
4604 if (/sinclude\((.*)\)/ && -f $1)
4606 # $_ being local, if we don't preserve it, when coming
4607 # back we will have $_ undefined, which is bad for the
4608 # the rest of this routine.
4609 my $underscore = $_;
4610 &scan_one_autoconf_file ($1);
4614 for my $generalize (keys %generalize)
4616 s/$generalize/$generalize{$generalize}/g;
4620 my $here = "$filename:$.";
4622 # Populate libobjs array.
4623 if (/LIBOBJS="(.*)\s+\$LIBOBJS"/
4624 || /LIBOBJS="\$LIBOBJS\s+(.*)"/)
4626 foreach my $libobj_iter (split (' ', $1))
4628 if ($libobj_iter =~ /^(.*)\.o(bj)?$/
4629 || $libobj_iter =~ /^(.*)\.\$ac_objext$/
4630 || $libobj_iter =~ /^(.*)\.\$\{ac_objext\}$/)
4632 $libsources{$1 . '.c'} = $here;
4636 elsif (/AC_LIBOBJ\(([^)]+)\)/)
4638 $libsources{"$1.c"} = $here;
4640 elsif (/AC_LIBSOURCE\(([^)]+)\)/)
4642 $libsources{&unquote_m4_arg ($1)} = $here;
4644 elsif (/AC_LIBSOURCES\(([^)]+)\)/)
4646 foreach my $lc_iter (split (/[, ]+/, &unquote_m4_arg ($1)))
4648 $libsources{$lc_iter} = $here;
4652 if (! $in_ac_replace && s/AC_REPLACE_FUNCS\s*\(\[?//)
4658 $in_ac_replace = 0 if s/[\]\)].*$//;
4659 # Remove trailing backslash.
4663 # Need to skip empty elements for Perl 4.
4665 $libsources{$_ . '.c'} = $here;
4669 if (/$obsolete_rx/o)
4672 if ($obsolete_macros{$1} ne '')
4674 $hint = '; ' . $obsolete_macros{$1};
4676 file_error ($here, "`$1' is obsolete$hint");
4679 # Process the AC_OUTPUT and AC_CONFIG_FILES macros.
4680 if (! $in_ac_output && s/(AC_(OUTPUT|CONFIG_FILES))\s*\(\[?//)
4683 $ac_config_files_location = $here;
4694 # Look at potential Makefile.am's.
4695 &scan_autoconf_config_files ($_);
4698 && scalar keys %make_list == 0
4699 && @other_input_files == 0)
4701 file_error ($ac_config_files_location,
4702 "no files mentioned in `$in_ac_output'");
4707 if (/$AC_CONFIG_AUX_DIR_PATTERN/o)
4709 @config_aux_path = &unquote_m4_arg ($1);
4710 $config_aux_dir_set_in_configure_in = $here;
4713 # Check for ansi2knr.
4714 $am_c_prototypes = $here if /AM_C_PROTOTYPES/;
4716 # Check for `-c -o' code.
4717 $seen_cc_c_o = $here if /AM_PROG_CC_C_O/;
4719 # Check for NLS support.
4720 if (/AM_GNU_GETTEXT/)
4722 $seen_gettext = $here;
4723 $ac_gettext_location = $here;
4726 # Handle configuration headers. A config header of `[$1]'
4727 # means we are actually scanning AM_CONFIG_HEADER from
4729 if (/A([CM])_CONFIG_HEADERS?\s*\((.*)\)/
4733 "`automake requires `AM_CONFIG_HEADER', not `AC_CONFIG_HEADER'")
4736 $config_header_location = $here;
4737 foreach my $one_hdr (split (' ', &unquote_m4_arg ($2)))
4739 push (@config_fullnames, $one_hdr);
4740 if ($one_hdr =~ /^([^:]+):(.+)$/)
4742 push (@config_names, $1);
4743 push (@config_headers, $2);
4747 push (@config_names, $one_hdr);
4748 push (@config_headers, $one_hdr . '.in');
4753 # Handle AC_CANONICAL_*. Always allow upgrading to
4754 # AC_CANONICAL_SYSTEM, but never downgrading.
4755 if (/AC_CANONICAL_HOST/ || /AC_CHECK_TOOL/)
4757 if (! $seen_canonical)
4759 $seen_canonical = $AC_CANONICAL_HOST;
4760 $canonical_location = $here;
4763 if (/AC_CANONICAL_SYSTEM/)
4765 $seen_canonical = $AC_CANONICAL_SYSTEM;
4766 $canonical_location = $here;
4769 # If using X, include some extra variable definitions. NOTE
4770 # we don't want to force these into CFLAGS or anything,
4771 # because not all programs will necessarily use X.
4774 foreach my $var ('X_CFLAGS', 'X_LIBS', 'X_EXTRA_LIBS',
4777 $configure_vars{$var} = $here;
4781 # This macro handles several different things.
4782 if (/$AM_INIT_AUTOMAKE_PATTERN/o)
4784 ($package_version = $1) =~ s/$AM_PACKAGE_VERSION_PATTERN/$1/o;
4785 $package_version_location = $here;
4786 $seen_init_automake = $here;
4791 $configure_vars{'LEX'} = $here;
4792 $seen_prog_lex = $here;
4794 if (/AC_PROG_LEX/ && $filename =~ /configure\.(ac|in)$/)
4796 $configure_vars{'LEX'} = $here;
4797 $seen_prog_lex = $here;
4798 file_warning ($here,
4799 "automake requires `AM_PROG_LEX', not `AC_PROG_LEX'");
4802 if (/AC_PROG_(F77|YACC|RANLIB|CC|CXXCPP|CXX|LEX|AWK|CPP|LN_S)/)
4804 $configure_vars{$1} = $here;
4806 if (/$AC_CHECK_PATTERN/o)
4808 $configure_vars{$3} = $here;
4810 if (/$AM_MISSING_PATTERN/o
4814 && $1 ne 'AUTOHEADER'
4815 # AM_INIT_AUTOMAKE is AM_MISSING_PROG'ing MAKEINFO. But
4816 # we handle it elsewhere.
4817 && $1 ne 'MAKEINFO')
4819 $configure_vars{$1} = $here;
4822 # Explicitly avoid ANSI2KNR -- we AC_SUBST that in protos.m4,
4823 # but later define it elsewhere. This is pretty hacky. We
4824 # also explicitly avoid INSTALL_SCRIPT and some other
4825 # variables because they are defined in header-vars.am.
4826 # AMDEPBACKSLASH might be subst'd by `\', which certainly would
4827 # not be appreciated by Make.
4828 if (/$AC_SUBST_PATTERN/o
4830 && $1 ne 'INSTALL_SCRIPT'
4831 && $1 ne 'INSTALL_DATA'
4832 && $1 ne 'AMDEPBACKSLASH')
4834 $configure_vars{$1} = $here;
4837 if (/AM_MAINTAINER_MODE/)
4839 $seen_maint_mode = $here;
4840 $configure_cond{'MAINTAINER_MODE'} = $here;
4843 $am_lispdir_location = $here if /AM_PATH_LISPDIR/;
4845 if (/AM_PATH_PYTHON/)
4847 $pythondir_location = $here;
4848 $configure_vars{'pythondir'} = $here;
4849 $configure_vars{'PYTHON'} = $here;
4852 if (/A(C|M)_PROG_LIBTOOL/)
4854 # We're not ready for this yet. People still use a
4855 # libtool with no AC_PROG_LIBTOOL. Once that is the
4856 # dominant version we can reenable this code -- but next
4857 # time by mentioning the macro in %obsolete_macros, both
4858 # here and in aclocal.in.
4860 # if (/AM_PROG_LIBTOOL/)
4862 # file_warning ($here, "`AM_PROG_LIBTOOL' is obsolete, use `AC_PROG_LIBTOOL' instead");
4864 $seen_libtool = $here;
4865 $libtool_location = $here;
4866 $configure_vars{'LIBTOOL'} = $here;
4867 $configure_vars{'RANLIB'} = $here;
4868 $configure_vars{'CC'} = $here;
4869 # AC_PROG_LIBTOOL runs AC_CANONICAL_HOST. Make sure we
4870 # never downgrade (if we've seen AC_CANONICAL_SYSTEM).
4871 $seen_canonical = $AC_CANONICAL_HOST if ! $seen_canonical;
4874 $seen_multilib = $here if (/AM_ENABLE_MULTILIB/);
4876 if (/$AM_CONDITIONAL_PATTERN/o)
4878 $configure_cond{$1} = $here;
4881 # Check for Fortran 77 intrinsic and run-time libraries.
4882 if (/AC_F77_LIBRARY_LDFLAGS/)
4884 $configure_vars{'FLIBS'} = $here;
4890 # &scan_autoconf_files ()
4891 # -----------------------
4892 # Check whether we use `configure.ac' or `configure.in'.
4893 # Scan it (and possibly `aclocal.m4') for interesting things.
4894 # We must scan aclocal.m4 because there might be AC_SUBSTs and such there.
4895 sub scan_autoconf_files
4897 # Reinitialize libsources here. This isn't really necessary,
4898 # since we currently assume there is only one configure.ac. But
4899 # that won't always be the case.
4902 $configure_ac = find_configure_ac;
4903 die "$me: `configure.ac' or `configure.in' is required\n"
4906 if (defined $ENV{'amtraces'})
4908 print STDERR "$me: Autoconf traces is an experimental feature\n";
4909 print STDERR "$me: use at your own risks\n";
4911 scan_autoconf_traces ($configure_ac);
4915 scan_one_autoconf_file ($configure_ac);
4916 scan_one_autoconf_file ('aclocal.m4')
4920 # Set input and output files if not specified by user.
4923 @input_files = sort keys %make_list;
4924 %output_files = %make_list;
4927 @configure_input_files = sort keys %make_list;
4929 conf_error ("`AM_INIT_AUTOMAKE' must be used")
4930 if ! $seen_init_automake;
4932 # Look for some files we need. Always check for these. This
4933 # check must be done for every run, even those where we are only
4934 # looking at a subdir Makefile. We must set relative_dir so that
4935 # the file-finding machinery works.
4936 # FIXME: Is this broken because it needs dynamic scopes.
4937 # My tests seems to show it's not the case.
4938 $relative_dir = '.';
4939 require_conf_file ($configure_ac, $FOREIGN,
4940 'install-sh', 'mkinstalldirs', 'missing');
4941 am_error ("`install.sh' is an anachronism; use `install-sh' instead")
4942 if -f $config_aux_path[0] . '/install.sh';
4944 require_conf_file ($pythondir_location, $FOREIGN, 'py-compile')
4945 if $pythondir_location;
4947 # Preserve dist_common for later.
4948 $configure_dist_common = variable_value ('DIST_COMMON', 'TRUE') || '';
4951 ################################################################
4953 # Set up for Cygnus mode.
4956 return unless $cygnus_mode;
4958 &set_strictness ('foreign');
4959 $options{'no-installinfo'} = 1;
4960 $options{'no-dependencies'} = 1;
4961 $use_dependencies = 0;
4963 conf_error ("`AM_MAINTAINER_MODE' required when --cygnus specified")
4964 if !$seen_maint_mode;
4967 # Do any extra checking for GNU standards.
4968 sub check_gnu_standards
4970 if ($relative_dir eq '.')
4972 # In top level (or only) directory.
4974 $GNU, 'INSTALL', 'NEWS', 'README', 'COPYING',
4975 'AUTHORS', 'ChangeLog');
4978 if ($strictness >= $GNU
4979 && defined $options{'no-installman'})
4981 macro_error ('AUTOMAKE_OPTIONS',
4982 "option `no-installman' disallowed by GNU standards");
4985 if ($strictness >= $GNU
4986 && defined $options{'no-installinfo'})
4988 macro_error ('AUTOMAKE_OPTIONS',
4989 "option `no-installinfo' disallowed by GNU standards");
4993 # Do any extra checking for GNITS standards.
4994 sub check_gnits_standards
4996 if ($relative_dir eq '.')
4998 # In top level (or only) directory.
4999 require_file ('', $GNITS, 'THANKS');
5003 ################################################################
5005 # Functions to handle files of each language.
5007 # Each `lang_X_rewrite($DIRECTORY, $BASE, $EXT)' function follows a
5008 # simple formula: Return value is $LANG_SUBDIR if the resulting object
5009 # file should be in a subdir if the source file is, $LANG_PROCESS if
5010 # file is to be dealt with, $LANG_IGNORE otherwise.
5012 # Much of the actual processing is handled in
5013 # handle_single_transform_list. These functions exist so that
5014 # auxiliary information can be recorded for a later cleanup pass.
5015 # Note that the calls to these functions are computed, so don't bother
5016 # searching for their precise names in the source.
5018 # This is just a convenience function that can be used to determine
5019 # when a subdir object should be used.
5022 return defined $options{'subdir-objects'} ? $LANG_SUBDIR : $LANG_PROCESS;
5025 # Rewrite a single C source file.
5028 my ($directory, $base, $ext) = @_;
5030 if (defined $options{'ansi2knr'} && $base =~ /_$/)
5032 # FIXME: include line number in error.
5033 am_error ("C source file `$base.c' would be deleted by ansi2knr rules");
5036 my $r = $LANG_PROCESS;
5037 if (defined $options{'subdir-objects'})
5040 $base = $directory . '/' . $base;
5044 # Only give error once.
5046 # FIXME: line number.
5047 am_error ("C objects in subdir but `AM_PROG_CC_C_O' not in `$configure_ac'");
5050 require_conf_file ("$am_file.am", $FOREIGN, 'compile');
5053 $de_ansi_files{$base} = 1;
5057 # Rewrite a single C++ source file.
5058 sub lang_cxx_rewrite
5060 return &lang_sub_obj;
5063 # Rewrite a single header file.
5064 sub lang_header_rewrite
5066 # Header files are simply ignored.
5067 return $LANG_IGNORE;
5070 # Rewrite a single yacc file.
5071 sub lang_yacc_rewrite
5073 my ($directory, $base, $ext) = @_;
5075 my $r = &lang_sub_obj;
5076 (my $newext = $ext) =~ tr/y/c/;
5077 return ($r, $newext);
5080 # Rewrite a single yacc++ file.
5081 sub lang_yaccxx_rewrite
5083 my ($directory, $base, $ext) = @_;
5085 my $r = &lang_sub_obj;
5086 (my $newext = $ext) =~ tr/y/c/;
5087 return ($r, $newext);
5090 # Rewrite a single lex file.
5091 sub lang_lex_rewrite
5093 my ($directory, $base, $ext) = @_;
5095 my $r = &lang_sub_obj;
5096 (my $newext = $ext) =~ tr/l/c/;
5097 return ($r, $newext);
5100 # Rewrite a single lex++ file.
5101 sub lang_lexxx_rewrite
5103 my ($directory, $base, $ext) = @_;
5105 my $r = &lang_sub_obj;
5106 (my $newext = $ext) =~ tr/l/c/;
5107 return ($r, $newext);
5110 # Rewrite a single assembly file.
5111 sub lang_asm_rewrite
5113 return &lang_sub_obj;
5116 # Rewrite a single Fortran 77 file.
5117 sub lang_f77_rewrite
5119 return $LANG_PROCESS;
5122 # Rewrite a single preprocessed Fortran 77 file.
5123 sub lang_ppf77_rewrite
5125 return $LANG_PROCESS;
5128 # Rewrite a single ratfor file.
5129 sub lang_ratfor_rewrite
5131 return $LANG_PROCESS;
5134 # Rewrite a single Objective C file.
5135 sub lang_objc_rewrite
5137 return &lang_sub_obj;
5140 # Rewrite a single Java file.
5141 sub lang_java_rewrite
5143 return $LANG_SUBDIR;
5146 # The lang_X_finish functions are called after all source file
5147 # processing is done. Each should handle defining rules for the
5148 # language, etc. A finish function is only called if a source file of
5149 # the appropriate type has been seen.
5153 # Push all libobjs files onto de_ansi_files. We actually only
5154 # push files which exist in the current directory, and which are
5155 # genuine source files.
5156 foreach my $file (keys %libsources)
5158 if ($file =~ /^(.*)\.[cly]$/ && -f "$relative_dir/$file")
5160 $de_ansi_files{$1} = 1;
5164 if (defined $options{'ansi2knr'} && keys %de_ansi_files)
5166 # Make all _.c files depend on their corresponding .c files.
5168 foreach my $base (sort keys %de_ansi_files)
5170 # Each _.c file must depend on ansi2knr; otherwise it
5171 # might be used in a parallel build before it is built.
5172 # We need to support files in the srcdir and in the build
5173 # dir (because these files might be auto-generated. But
5174 # we can't use $< -- some makes only define $< during a
5176 $output_rules .= ($base . "_.c: $base.c \$(ANSI2KNR)\n\t"
5177 . '$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) '
5178 . '`if test -f $(srcdir)/' . $base . '.c'
5179 . '; then echo $(srcdir)/' . $base . '.c'
5180 . '; else echo ' . $base . '.c; fi` '
5181 . "| sed 's/^# \\([0-9]\\)/#line \\1/' "
5182 . '| $(ANSI2KNR) > ' . $base . "_.c"
5183 # If ansi2knr fails then we shouldn't
5184 # create the _.c file
5185 . " || rm -f ${base}_.c\n");
5186 push (@objects, $base . '_.$(OBJEXT)');
5187 push (@objects, $base . '_.lo')
5191 # Make all _.o (and _.lo) files depend on ansi2knr.
5192 # Use a sneaky little hack to make it print nicely.
5193 &pretty_print_rule ('', '', @objects, ':', '$(ANSI2KNR)');
5197 # This is a yacc helper which is called whenever we have decided to
5198 # compile a yacc file.
5199 sub lang_yacc_target_hook
5201 my ($self, $aggregate, $output, $input) = @_;
5203 my $flag = $aggregate . "_YFLAGS";
5204 if ((&variable_defined ($flag)
5205 && &variable_value ($flag) =~ /$DASH_D_PATTERN/o)
5206 || (&variable_defined ('YFLAGS')
5207 && &variable_value ('YFLAGS') =~ /$DASH_D_PATTERN/o))
5209 (my $output_base = $output) =~ s/\..*$//;
5210 my $header = $output_base . '.h';
5212 # Found a `-d' that applies to the compilation of this file.
5213 # Add a dependency for the generated header file, and arrange
5214 # for that file to be included in the distribution.
5215 # FIXME: this fails for `nodist_*_SOURCES'.
5216 $output_rules .= "${header}: $output\n";
5217 &push_dist_common ($header);
5218 # If the files are built in the build directory, then we want
5219 # to remove them with `make clean'. If they are in srcdir
5220 # they shouldn't be touched. However, we can't determine this
5221 # statically, and the GNU rules say that yacc/lex output files
5222 # should be removed by maintainer-clean. So that's what we
5224 push (@maintainer_clean_files, $header);
5228 # This is a helper for both lex and yacc.
5229 sub yacc_lex_finish_helper
5231 return if defined $language_scratch{'lex-yacc-done'};
5232 $language_scratch{'lex-yacc-done'} = 1;
5234 # If there is more than one distinct yacc (resp lex) source file
5235 # in a given directory, then the `ylwrap' program is required to
5236 # allow parallel builds to work correctly. FIXME: for now, no
5238 require_conf_file ($configure_ac, $FOREIGN, 'ylwrap');
5239 if ($config_aux_dir_set_in_configure_in)
5241 &define_variable ('YLWRAP', $config_aux_dir . "/ylwrap");
5245 &define_variable ('YLWRAP', '$(top_srcdir)/ylwrap');
5249 sub lang_yacc_finish
5251 return if defined $language_scratch{'yacc-done'};
5252 $language_scratch{'yacc-done'} = 1;
5254 if (&variable_defined ('YACCFLAGS'))
5256 macro_error ('YACCFLAGS',
5257 "`YACCFLAGS' obsolete; use `YFLAGS' instead");
5260 if (count_files_for_language ('yacc') > 1)
5262 &yacc_lex_finish_helper;
5269 return if defined $language_scratch{'lex-done'};
5270 $language_scratch{'lex-done'} = 1;
5272 if (! $seen_prog_lex)
5274 &am_error ("lex source seen but `AM_PROG_LEX' not in `$configure_ac'");
5277 if (count_files_for_language ('lex') > 1)
5279 &yacc_lex_finish_helper;
5284 # Given a hash table of linker names, pick the name that has the most
5285 # precedence. This is lame, but something has to have global
5286 # knowledge in order to eliminate the conflict. Add more linkers as
5293 if defined $linkers{'GCJLINK'};
5295 if defined $linkers{'CXXLINK'};
5297 if defined $linkers{'F77LINK'};
5299 if defined $linkers{'OBJCLINK'};
5303 # Called to indicate that an extension was used.
5307 if (! defined $extension_seen{$ext})
5309 $extension_seen{$ext} = 1;
5313 ++$extension_seen{$ext};
5317 # Return the number of files seen for a given language. Knows about
5318 # special cases we care about. FIXME: this is hideous. We need
5319 # something that involves real language objects. For instance yacc
5320 # and yaccxx could both derive from a common yacc class which would
5321 # know about the strange ylwrap requirement. (Or better yet we could
5322 # just not support legacy yacc!)
5323 sub count_files_for_language
5328 if ($name eq 'yacc' || $name eq 'yaccxx')
5330 @names = ('yacc', 'yaccxx');
5332 elsif ($name eq 'lex' || $name eq 'lexxx')
5334 @names = ('lex', 'lexxx');
5342 foreach $name (@names)
5344 my $lang = $languages{$name};
5345 foreach my $ext (@{$lang->extensions})
5347 $r += $extension_seen{$ext}
5348 if defined $extension_seen{$ext};
5355 # Called to ask whether source files have been seen . If HEADERS is 1,
5356 # headers can be included.
5361 # count all the sources
5363 foreach my $val (values %extension_seen)
5370 $count -= count_files_for_language ('header');
5377 # register_language (%ATTRIBUTE)
5378 # ------------------------------
5379 # Register a single language.
5380 # Each %ATTRIBUTE is of the form ATTRIBUTE => VALUE.
5381 sub register_language (%)
5387 unless defined $option{'ansi'};
5388 $option{'autodep'} = 'no'
5389 unless defined $option{'autodep'};
5390 $option{'linker'} = ''
5391 unless defined $option{'linker'};
5392 $option{'define_flag'} = 1
5393 unless defined $option{'define_flag'};
5395 my $lang = new Language (%option);
5398 grep ($extension_map{$_} = $lang->name, @{$lang->extensions});
5399 $languages{$lang->name} = $lang;
5402 # This function is used to find a path from a user-specified suffix to
5403 # `o' or to some other suffix we recognize internally, eg `cc'.
5406 my ($source_ext) = @_;
5408 # FIXME: hard-coding `o' is a mistake. Doing something
5409 # intelligent is harder.
5410 while (! $extension_map{$source_ext}
5411 && $source_ext ne 'o'
5412 && defined $suffix_rules{$source_ext})
5414 $source_ext = $suffix_rules{$source_ext};
5421 ################################################################
5423 # Pretty-print something. HEAD is what should be printed at the
5424 # beginning of the first line, FILL is what should be printed at the
5425 # beginning of every subsequent line.
5426 sub pretty_print_internal
5428 my ($head, $fill, @values) = @_;
5430 my $column = length ($head);
5433 # Fill length is number of characters. However, each Tab
5434 # character counts for eight. So we count the number of Tabs and
5436 my $fill_length = length ($fill);
5437 $fill_length += 7 * ($fill =~ tr/\t/\t/d);
5441 # "71" because we also print a space.
5442 if ($column + length ($_) > 71)
5444 $result .= " \\\n" . $fill;
5445 $column = $fill_length;
5447 $result .= ' ' if $result =~ /\S\z/;
5449 $column += length ($_) + 1;
5456 # Pretty-print something and append to output_vars.
5459 $output_vars .= &pretty_print_internal (@_);
5462 # Pretty-print something and append to output_rules.
5463 sub pretty_print_rule
5465 $output_rules .= &pretty_print_internal (@_);
5469 ################################################################
5473 # &conditional_string(@COND-STACK)
5474 # --------------------------------
5475 # Build a string which denotes the conditional in @COND-STACK. Some
5476 # simplifications are done: `TRUE' entries are elided, and any `FALSE'
5477 # entry results in a return of `FALSE'.
5478 sub conditional_string
5482 if (grep (/^FALSE$/, @stack))
5488 return join (' ', uniq sort grep (!/^TRUE$/, @stack));
5494 # &conditional_true_when ($COND, $WHEN)
5495 # -------------------------------------
5496 # See if a conditional is true. Both arguments are conditional
5497 # strings. This returns true if the first conditional is true when
5498 # the second conditional is true.
5499 # For instance with $COND = `BAR FOO', and $WHEN = `BAR BAZ FOO',
5500 # obviously return 1, and 0 when, for instance, $WHEN = `FOO'.
5501 sub conditional_true_when ($$)
5503 my ($cond, $when) = @_;
5505 # Make a hash holding all the values from $WHEN.
5506 my %cond_vals = map { $_ => 1 } split (' ', $when);
5508 # Check each component of $cond, which looks `COND1 COND2'.
5509 foreach my $comp (split (' ', $cond))
5511 # TRUE is always true.
5512 next if $comp eq 'TRUE';
5513 return 0 if ! defined $cond_vals{$comp};
5521 # &conditional_is_redundant ($COND, @WHENS)
5522 # ----------------------------------------
5523 # Determine whether $COND is redundant with respect to @WHENS.
5525 # Returns true if $COND is true for any of the conditions in @WHENS.
5527 # If there are no @WHENS, then behave as if @WHENS contained a single empty
5529 sub conditional_is_redundant ($@)
5531 my ($cond, @whens) = @_;
5535 return 1 if conditional_true_when ($cond, "");
5539 foreach my $when (@whens)
5541 return 1 if conditional_true_when ($cond, $when);
5550 # condition_negate ($COND)
5551 # ------------------------
5552 sub condition_negate ($)
5556 $cond =~ s/TRUE$/TRUEO/;
5557 $cond =~ s/FALSE$/TRUE/;
5558 $cond =~ s/TRUEO$/FALSE/;
5564 # Compare condition names.
5565 # Issue them in alphabetical order, foo_TRUE before foo_FALSE.
5568 # Be careful we might be comparing `' or `#'.
5569 $a =~ /^(.*)_(TRUE|FALSE)$/;
5570 my ($aname, $abool) = ($1 || '', $2 || '');
5571 $b =~ /^(.*)_(TRUE|FALSE)$/;
5572 my ($bname, $bbool) = ($1 || '', $2 || '');
5573 return ($aname cmp $bname
5574 # Don't bother with IFs, given that TRUE is after FALSE
5575 # just cmp in the reverse order.
5576 || $bbool cmp $abool
5582 # &make_condition (@CONDITIONS)
5583 # -----------------------------
5584 # Transform a list of conditions (themselves can be an internal list
5585 # of conditions, e.g., @CONDITIONS = ('cond1 cond2', 'cond3')) into a
5586 # Make conditional (a pattern for AC_SUBST).
5587 # Correctly returns the empty string when there are no conditions.
5590 my $res = conditional_string (@_);
5592 # There are no conditions.
5598 elsif ($res eq 'FALSE')
5605 $res = '@' . $res . '@';
5614 ## ------------------------------ ##
5615 ## Handling the condition stack. ##
5616 ## ------------------------------ ##
5620 # cond_stack_if ($NEGATE, $COND, $WHERE)
5621 # --------------------------------------
5622 sub cond_stack_if ($$$)
5624 my ($negate, $cond, $where) = @_;
5626 file_error ($where, "$cond does not appear in AM_CONDITIONAL")
5627 if ! $configure_cond{$cond} && $cond !~ /^TRUE|FALSE$/;
5629 $cond = "${cond}_TRUE"
5630 unless $cond =~ /^TRUE|FALSE$/;
5631 $cond = condition_negate ($cond)
5634 push (@cond_stack, $cond);
5636 return conditional_string (@cond_stack);
5641 # cond_stack_else ($NEGATE, $COND, $WHERE)
5642 # ----------------------------------------
5643 sub cond_stack_else ($$$)
5645 my ($negate, $cond, $where) = @_;
5649 file_error ($where, "else without if");
5653 $cond_stack[$#cond_stack] = condition_negate ($cond_stack[$#cond_stack]);
5655 # If $COND is given, check against it.
5658 $cond = "${cond}_TRUE"
5659 unless $cond =~ /^TRUE|FALSE$/;
5660 $cond = condition_negate ($cond)
5664 "else reminder ($negate$cond) incompatible with "
5665 . "current conditional: $cond_stack[$#cond_stack]")
5666 if $cond_stack[$#cond_stack] ne $cond;
5669 return conditional_string (@cond_stack);
5674 # cond_stack_endif ($NEGATE, $COND, $WHERE)
5675 # -----------------------------------------
5676 sub cond_stack_endif ($$$)
5678 my ($negate, $cond, $where) = @_;
5683 file_error ($where, "endif without if: $negate$cond");
5688 # If $COND is given, check against it.
5691 $cond = "${cond}_TRUE"
5692 unless $cond =~ /^TRUE|FALSE$/;
5693 $cond = condition_negate ($cond)
5697 "endif reminder ($negate$cond) incompatible with "
5698 . "current conditional: $cond_stack[$#cond_stack]")
5699 if $cond_stack[$#cond_stack] ne $cond;
5704 return conditional_string (@cond_stack);
5711 ## ------------------------ ##
5712 ## Handling the variables. ##
5713 ## ------------------------ ##
5716 # check_ambiguous_conditional ($VAR, $COND)
5717 # -----------------------------------------
5718 # Check for an ambiguous conditional. This is called when a variable
5719 # is being defined conditionally. If we already know about a
5720 # definition that is true under the same conditions, then we have an
5722 sub check_ambiguous_conditional ($$)
5724 my ($var, $cond) = @_;
5725 foreach my $vcond (keys %{$var_value{$var}})
5728 if ($vcond eq $cond)
5730 $message = "$var multiply defined in condition $cond";
5732 elsif (&conditional_true_when ($vcond, $cond))
5734 $message = ("$var was already defined in condition $vcond, "
5735 . "which implies condition $cond");
5737 elsif (&conditional_true_when ($cond, $vcond))
5739 $message = ("$var was already defined in condition $vcond, "
5740 . "which is implied by condition $cond");
5744 macro_error ($var, $message);
5751 # ¯o_define($VAR, $VAR_IS_AM, $TYPE, $COND, $VALUE, $WHERE)
5752 # -------------------------------------------------------------
5753 # The $VAR can go from Automake to user, but not the converse.
5754 sub macro_define ($$$$$$)
5756 my ($var, $var_is_am, $type, $cond, $value, $where) = @_;
5758 file_error ($where, "bad macro name `$var'")
5759 if $var !~ /$MACRO_PATTERN/o;
5763 # An Automake variable must be consistently defined with the same
5764 # sign by Automake. A user variable must be set by either `=' or
5765 # `:=', and later promoted to `+='.
5768 if (defined $var_type{$var} && $var_type{$var} ne $type)
5771 ("$var was set with `$var_type{$var}=' "
5772 . "and is now set with `$type='"));
5777 if (!defined $var_type{$var} && $type eq '+')
5779 macro_error ($var, "$var must be set with `=' before using `+='");
5782 $var_type{$var} = $type;
5784 # When adding, since we rewrite, don't try to preserve the
5785 # Automake continuation backslashes.
5787 if $type eq '+' && $var_is_am;
5789 # Differentiate the first assignment (including with `+=').
5790 if ($type eq '+' && defined $var_value{$var}{$cond})
5792 if (substr ($var_value{$var}{$cond}, -1) eq "\n")
5794 # Insert a backslash before a trailing newline.
5795 $var_value{$var}{$cond} =
5796 substr ($var_value{$var}{$cond}, 0, -1) . "\\\n";
5798 elsif ($var_value{$var}{$cond})
5800 # Insert a separator.
5801 $var_value{$var}{$cond} .= ' ';
5803 $var_value{$var}{$cond} .= $value;
5807 # The first assignment to a macro sets its location. Ideally I
5808 # suppose we would associate line numbers with random bits of text.
5809 # FIXME: We sometimes redefine some variables, but we want to keep
5810 # the original location. More subs are needed to handle
5811 # properly variables. Once this done, remove this hack.
5812 $var_location{$var} = $where
5813 unless defined $var_location{$var};
5815 # If Automake tries to override a value specified by the user,
5816 # just don't let it do.
5817 if (defined $var_value{$var}{$cond} && !$var_is_am{$var} && $var_is_am)
5821 print STDERR "$me: refusing to override the user definition of:\n";
5823 print STDERR "$me: with `$cond' => `$value'\n";
5828 # There must be no previous value unless the user is redefining
5829 # an Automake variable or an AC_SUBST variable.
5830 check_ambiguous_conditional ($var, $cond)
5831 unless ($var_is_am{$var} && !$var_is_am
5832 || exists $configure_vars{$var});
5834 $var_value{$var}{$cond} = $value;
5838 # An Automake variable can be given to the user, but not the converse.
5839 if (! defined $var_is_am{$var} || !$var_is_am)
5841 $var_is_am{$var} = $var_is_am;
5846 # &variable_delete ($VAR, [@CONDS])
5847 # ---------------------------------
5848 # Forget about $VAR under the conditions @CONDS, or completely if
5850 sub variable_delete ($@)
5852 my ($var, @conds) = @_;
5856 delete $var_value{$var};
5857 delete $var_location{$var};
5858 delete $var_is_am{$var};
5859 delete $var_comment{$var};
5860 delete $var_type{$var};
5864 foreach my $cond (@conds)
5866 delete $var_value{$var}{$cond};
5872 # ¯o_dump ($VAR)
5873 # ------------------
5878 if (!exists $var_value{$var})
5880 print STDERR " $var does not exist\n";
5884 my $var_is_am = $var_is_am{$var} ? "Automake" : "User";
5885 my $where = (defined $var_location{$var}
5886 ? $var_location{$var} : "undefined");
5887 print STDERR "$var_comment{$var}"
5888 if defined $var_comment{$var};
5889 print STDERR " $var ($var_is_am, where = $where) $var_type{$var}=\n";
5890 print STDERR " {\n";
5891 foreach my $vcond (sort by_condition keys %{$var_value{$var}})
5893 print STDERR " $vcond => $var_value{$var}{$vcond}\n";
5895 print STDERR " }\n";
5906 print STDERR "%var_value =\n";
5908 foreach my $var (sort (keys %var_value))
5917 # &variable_defined ($VAR, [$COND])
5918 # ---------------------------------
5919 # See if a variable exists. $VAR is the variable name, and $COND is
5920 # the condition which we should check. If no condition is given, we
5921 # currently return true if the variable is defined under any
5923 sub variable_defined ($$)
5925 my ($var, $cond) = @_;
5927 # Unfortunately we can't just check for $var_value{VAR}{COND}
5928 # as this would make perl create $condition{VAR}, which we
5930 if (!exists $var_value{$var})
5932 if (defined $targets{$var})
5934 macro_error ($var, "`$var' is a target; expected a variable")
5936 # The variable is not defined
5940 if ($cond && !exists $var_value{$var}{$cond})
5942 # The variable is not defined for the given condition.
5946 # Even a var_value examination is good enough for us. FIXME:
5947 # really should maintain examined status on a per-condition basis.
5948 $content_seen{$var} = 1;
5952 # Mark a variable as examined.
5953 sub examine_variable
5956 &variable_defined ($var);
5959 # Return the set of conditions for which a variable is defined.
5961 # If the variable is not defined conditionally, and is not defined in
5962 # terms of any variables which are defined conditionally, then this
5963 # returns the empty list.
5965 # If the variable is defined conditionally, but is not defined in
5966 # terms of any variables which are defined conditionally, then this
5967 # returns the list of conditions for which the variable is defined.
5969 # If the variable is defined in terms of any variables which are
5970 # defined conditionally, then this returns a full set of permutations
5971 # of the subvariable conditions. For example, if the variable is
5972 # defined in terms of a variable which is defined for COND_TRUE,
5973 # then this returns both COND_TRUE and COND_FALSE. This is
5974 # because we will need to define the variable under both conditions.
5976 sub variable_conditions_recursive ($)
5982 my @new_conds = variable_conditions_recursive_sub ($var, '');
5983 # Now we want to return all permutations of the subvariable
5986 foreach my $item (@new_conds)
5988 foreach (split (' ', $item))
5990 s/^(.*)_(TRUE|FALSE)$/$1_TRUE/;
5994 @new_conds = variable_conditions_permutations (sort keys %allconds);
5997 foreach my $cond (@new_conds)
5999 my $reduce = variable_conditions_reduce (split (' ', $cond));
6001 if $reduce eq 'FALSE';
6002 $uniqify{$cond} = 1;
6005 # Note we cannot just do `return sort keys %uniqify', because this
6006 # function is sometimes used in a scalar context.
6007 my @uniq_list = sort by_condition keys %uniqify;
6012 # variable_conditions ($VAR)
6013 # --------------------------
6014 # Get the list of conditions that a variable is defined with, without
6015 # recursing through the conditions of any subvariables.
6016 # Argument is $VAR: the variable to get the conditions of.
6017 # Returns the list of conditions.
6018 sub variable_conditions ($)
6021 my @conds = keys %{$var_value{$var}};
6022 return sort by_condition @conds;
6027 # &variable_conditionally_defined ($VAR)
6028 # --------------------------------------
6029 sub variable_conditionally_defined ($)
6032 foreach my $cond (variable_conditions_recursive ($var))
6035 unless $cond =~ /^TRUE|FALSE$/;
6042 # &variable_conditions_recursive_sub ($VAR, $PARENT)
6043 # -------------------------------------------------------
6044 # A subroutine of variable_conditions_recursive. This returns all the
6045 # conditions of $VAR, including those of any sub-variables.
6046 sub variable_conditions_recursive_sub
6048 my ($var, $parent) = @_;
6051 if (defined $vars_scanned{$var})
6053 macro_error ($parent, "variable `$var' recursively defined");
6056 $vars_scanned{$var} = 1;
6058 my @this_conds = ();
6059 # Examine every condition under which $VAR is defined.
6060 foreach my $vcond (keys %{$var_value{$var}})
6062 push (@this_conds, $vcond);
6064 # If $VAR references some other variable, then compute the
6065 # conditions for that subvariable.
6066 my @subvar_conds = ();
6067 foreach (split (' ', $var_value{$var}{$vcond}))
6069 # If a comment seen, just leave.
6072 # Handle variable substitutions.
6073 if (/^\$\{(.*)\}$/ || /^\$\((.*)\)$/)
6076 if ($varname =~ /$SUBST_REF_PATTERN/o)
6082 # Here we compute all the conditions under which the
6083 # subvariable is defined. Then we go through and add
6085 my @svc = variable_conditions_recursive_sub ($varname, $var);
6086 foreach my $item (@svc)
6088 my $val = conditional_string ($vcond, split (' ', $item));
6090 push (@subvar_conds, $val);
6095 # If there are no conditional subvariables, then we want to
6096 # return this condition. Otherwise, we want to return the
6097 # permutations of the subvariables, taking into account the
6098 # conditions of $VAR.
6099 if (! @subvar_conds)
6101 push (@new_conds, $vcond);
6105 push (@new_conds, variable_conditions_reduce (@subvar_conds));
6109 # Unset our entry in vars_scanned. We only care about recursive
6111 delete $vars_scanned{$var};
6113 # If we are being called on behalf of another variable, we need to
6114 # return all possible permutations of the conditions. We have
6115 # already handled everything in @this_conds along with their
6116 # subvariables. We now need to add any permutations that are not
6118 foreach my $this_cond (@this_conds)
6121 variable_conditions_permutations (split (' ', $this_cond));
6122 foreach my $perm (@perms)
6125 foreach my $scan (@this_conds)
6127 if (&conditional_true_when ($perm, $scan)
6128 || &conditional_true_when ($scan, $perm))
6136 # This permutation was not already handled, and is valid
6138 push (@new_conds, $perm);
6146 # Filter a list of conditionals so that only the exclusive ones are
6147 # retained. For example, if both `COND1_TRUE COND2_TRUE' and
6148 # `COND1_TRUE' are in the list, discard the latter.
6149 # If the list is empty, return TRUE
6150 sub variable_conditions_reduce
6157 $cond = shift(@conds);
6159 # FALSE is absorbent.
6160 if ($cond eq 'FALSE')
6164 elsif (!conditional_is_redundant ($cond, @ret, @conds))
6170 return "TRUE" if @ret == 0;
6175 # invert_conditions (@CONDS)
6176 # --------------------------
6177 # Invert a list of conditionals. Returns a set of conditionals which
6178 # are never true for any of the input conditionals, and when taken
6179 # together with the input conditionals cover all possible cases.
6181 # For example: invert_conditions("A_TRUE B_TRUE", "A_FALSE B_FALSE") will
6182 # return ("A_FALSE B_TRUE", "A_TRUE B_FALSE")
6183 sub invert_conditions
6188 foreach my $cond (@conds)
6190 foreach my $perm (variable_conditions_permutations (split(' ', $cond)))
6192 push @notconds, $perm
6193 if ! conditional_is_redundant ($perm, @conds);
6196 return variable_conditions_reduce (@notconds);
6199 # Return a list of permutations of a conditional string.
6200 sub variable_conditions_permutations
6205 my $comp = shift (@comps);
6206 return variable_conditions_permutations (@comps)
6208 my $neg = condition_negate ($comp);
6211 foreach my $sub (variable_conditions_permutations (@comps))
6213 push (@ret, "$comp $sub");
6214 push (@ret, "$neg $sub");
6226 # &check_variable_defined_unconditionally($VAR, $PARENT)
6227 # ------------------------------------------------------
6228 # Warn if a variable is conditionally defined. This is called if we
6229 # are using the value of a variable.
6230 sub check_variable_defined_unconditionally ($$)
6232 my ($var, $parent) = @_;
6233 foreach my $cond (keys %{$var_value{$var}})
6236 if $cond =~ /^TRUE|FALSE$/;
6240 macro_error ($parent,
6241 "warning: automake does not support conditional definition of $var in $parent");
6245 macro_error ($parent,
6246 "warning: automake does not support $var being defined conditionally");
6252 # Get the TRUE value of a variable, warn if the variable is
6253 # conditionally defined.
6257 &check_variable_defined_unconditionally ($var);
6258 return $var_value{$var}{'TRUE'};
6263 # &value_to_list ($VAR, $VAL, $COND)
6264 # ----------------------------------
6265 # Convert a variable value to a list, split as whitespace. This will
6266 # recursively follow $(...) and ${...} inclusions. It preserves @...@
6269 # If COND is 'all', then all values under all conditions should be
6270 # returned; if COND is a particular condition (all conditions are
6271 # surrounded by @...@) then only the value for that condition should
6272 # be returned; otherwise, warn if VAR is conditionally defined.
6273 # SCANNED is a global hash listing whose keys are all the variables
6274 # already scanned; it is an error to rescan a variable.
6277 my ($var, $val, $cond) = @_;
6281 $val =~ s/\\(\n|$)/ /g;
6283 foreach (split (' ', $val))
6285 # If a comment seen, just leave.
6288 # Handle variable substitutions.
6289 if (/^\$\{([^}]*)\}$/ || /^\$\(([^)]*)\)$/)
6293 # If the user uses a losing variable name, just ignore it.
6294 # This isn't ideal, but people have requested it.
6295 next if ($varname =~ /\@.*\@/);
6299 if ($varname =~ /$SUBST_REF_PATTERN/o)
6303 ($from = $2) =~ s/(\W)/\\$1/g;
6307 @temp_list = &variable_value_as_list_recursive_worker ($1, $cond, $var);
6309 # Now rewrite the value if appropriate.
6312 grep (s/$from$/$to/, @temp_list);
6315 push (@result, @temp_list);
6327 # variable_value_as_list ($VAR, $COND, $PARENT)
6328 # ---------------------------------------------
6329 # Get the value of a variable given a specified condition. without
6330 # recursing through any subvariables.
6332 # $VAR is the variable
6333 # $COND is the condition. If this is not given, the value for the
6334 # "TRUE" condition will be returned.
6335 # $PARENT is the variable in which the variable is used: this is used
6336 # only for error messages.
6337 # Returns the list of conditions.
6338 # For example, if A is defined as "foo $(B) bar", and B is defined as
6339 # "baz", this will return ("foo", "$(B)", "bar")
6340 sub variable_value_as_list
6342 my ($var, $cond, $parent) = @_;
6346 if (! defined $var_value{$var})
6348 if (defined $targets{$var})
6350 macro_error ($var, "`$var' is a target; expected a variable");
6354 macro_error ($parent, "variable `$var' not defined");
6358 # Get value for given condition
6361 foreach my $vcond (keys %{$var_value{$var}})
6363 my $val = $var_value{$var}{$vcond};
6365 if (&conditional_true_when ($vcond, $cond))
6367 # Unless variable is not defined conditionally, there should only
6368 # be one value of $vcond true when $cond.
6369 &check_variable_defined_unconditionally ($var, $parent)
6374 $val =~ s/\\(\n|$)/ /g;
6376 foreach (split (' ', $val))
6378 # If a comment seen, just leave.
6389 # Return contents of variable as list, split as whitespace. This will
6390 # recursively follow $(...) and ${...} inclusions. It preserves @...@
6391 # substitutions. If COND is 'all', then all values under all
6392 # conditions should be returned; if COND is a particular condition
6393 # (all conditions are surrounded by @...@) then only the value for
6394 # that condition should be returned; otherwise, warn if VAR is
6395 # conditionally defined. If PARENT is specified, it is the name of
6396 # the including variable; this is only used for error reports.
6397 sub variable_value_as_list_recursive_worker
6399 my ($var, $cond, $parent) = @_;
6402 if (! defined $var_value{$var})
6404 if (defined $targets{$var})
6406 macro_error ($var, "`$var' is a target; expected a variable");
6410 macro_error ($parent, "variable `$var' not defined");
6413 elsif (defined $vars_scanned{$var})
6415 # `vars_scanned' is a global we use to keep track of which
6416 # variables we've already examined.
6417 macro_error ($parent, "variable `$var' recursively defined");
6419 elsif ($cond eq 'all')
6421 $vars_scanned{$var} = 1;
6422 foreach my $vcond (keys %{$var_value{$var}})
6424 my $val = $var_value{$var}{$vcond};
6425 push (@result, &value_to_list ($var, $val, $cond));
6431 $vars_scanned{$var} = 1;
6433 foreach my $vcond (keys %{$var_value{$var}})
6435 my $val = $var_value{$var}{$vcond};
6436 if (&conditional_true_when ($vcond, $cond))
6438 # Warn if we have an ambiguity. It's hard to know how
6439 # to handle this case correctly.
6440 &check_variable_defined_unconditionally ($var, $parent)
6443 push (@result, &value_to_list ($var, $val, $cond));
6448 # Unset our entry in vars_scanned. We only care about recursive
6450 delete $vars_scanned{$var};
6456 # &variable_output ($VAR, [@CONDS])
6457 # ---------------------------------
6458 # Output all the values of $VAR is @COND is not specified, else only
6459 # that corresponding to @COND.
6460 sub variable_output ($@)
6462 my ($var, @conds) = @_;
6464 @conds = keys %{$var_value{$var}}
6467 $output_vars .= $var_comment{$var}
6468 if defined $var_comment{$var};
6470 foreach my $cond (sort by_condition @conds)
6472 my $val = $var_value{$var}{$cond};
6473 my $equals = $var_type{$var} eq ':' ? ':=' : '=';
6474 my $output_var = "$var $equals $val";
6475 $output_var =~ s/^/make_condition ($cond)/meg;
6476 $output_vars .= $output_var . "\n";
6481 # &variable_pretty_output ($VAR, [@CONDS])
6482 # ----------------------------------------
6483 # Likewise, but pretty, i.e., we *split* the values at spaces. Use only
6484 # with variables holding filenames.
6485 sub variable_pretty_output ($@)
6487 my ($var, @conds) = @_;
6489 @conds = keys %{$var_value{$var}}
6492 $output_vars .= $var_comment{$var}
6493 if defined $var_comment{$var};
6495 foreach my $cond (sort by_condition @conds)
6497 my $val = $var_value{$var}{$cond};
6498 my $equals = $var_type{$var} eq ':' ? ':=' : '=';
6499 my $make_condition = make_condition ($cond);
6500 $output_vars .= pretty_print_internal ("$make_condition$var $equals",
6501 "$make_condition\t",
6502 split (' ' , $val));
6507 # This is just a wrapper for variable_value_as_list_recursive_worker that
6508 # initializes the global hash `vars_scanned'. This hash is used to
6509 # avoid infinite recursion.
6510 sub variable_value_as_list_recursive
6512 my ($var, $cond, $parent) = @_;
6514 return &variable_value_as_list_recursive_worker ($var, $cond, $parent);
6518 # Like define_variable, but the value is a list, and the variable may
6519 # be defined conditionally. The second argument is the conditional
6520 # under which the value should be defined; this should be the empty
6521 # string to define the variable unconditionally. The third argument
6522 # is a list holding the values to use for the variable. The value is
6523 # pretty printed in the output file.
6524 sub define_pretty_variable
6526 my ($var, $cond, @value) = @_;
6528 # Beware that an empty $cond has a different semantics for
6529 # macro_define and variable_pretty_output.
6532 if (! &variable_defined ($var, $cond))
6534 macro_define ($var, 1, '', $cond, join (' ', @value), undef);
6535 variable_pretty_output ($var, $cond || 'TRUE');
6536 $content_seen{$var} = 1;
6541 # define_variable ($VAR, $VALUE)
6542 # ------------------------------
6543 # Define a new user variable VAR to VALUE, but only if not already defined.
6546 my ($var, $value) = @_;
6548 define_pretty_variable ($var, 'TRUE', $value);
6552 # Like define_variable, but define a variable to be the configure
6553 # substitution by the same name.
6554 sub define_configure_variable
6557 my $value = '@' . $var . '@';
6558 &define_variable ($var, $value);
6562 # define_compiler_variable ($LANG)
6563 # --------------------------------
6564 # Define a compiler variable. We also handle defining the `LT'
6565 # version of the command when using libtool.
6566 sub define_compiler_variable ($)
6570 my ($var, $value) = ($lang->compiler, $lang->compile);
6571 &define_variable ($var, $value);
6572 &define_variable ("LT$var", "\$(LIBTOOL) --mode=compile $value")
6577 # define_linker_variable ($LANG)
6578 # ------------------------------
6579 # Define linker variables.
6580 sub define_linker_variable ($)
6584 my ($var, $value) = ($lang->lder, $lang->ld);
6586 &define_variable ($lang->lder, $lang->ld);
6587 # CCLINK = $(CCLD) blah blah...
6588 &define_variable ($lang->linker,
6589 (($seen_libtool ? '$(LIBTOOL) --mode=link ' : '')
6593 ################################################################
6595 ## ---------------- ##
6596 ## Handling rules. ##
6597 ## ---------------- ##
6600 # rule_define ($TARGET, $IS_AM, $COND, $WHERE)
6601 # --------------------------------------------
6602 # Define a new rule. $TARGET is the rule name. $IS_AM is a boolean
6603 # which is true if the new rule is defined by the user. $COND is the
6604 # condition under which the rule is defined. $WHERE is where the rule
6605 # is defined (file name or line number). Returns true if it is ok to
6606 # define the rule, false otherwise.
6607 sub rule_define ($$$$)
6609 my ($target, $rule_is_am, $cond, $where) = @_;
6611 # For now `foo:' will override `foo$(EXEEXT):'. This is temporary,
6612 # though, so we emit a warning.
6613 (my $noexe = $target) =~ s,\$\(EXEEXT\)$,,;
6614 if ($noexe ne $target && defined $targets{$noexe})
6616 # The no-exeext option enables this feature.
6617 if (! defined $options{'no-exeext'})
6619 macro_error ($noexe,
6620 "deprecated feature: `$noexe' overrides `$noexe\$(EXEEXT)'\nchange your target to read `$noexe\$(EXEEXT)'");
6626 if (defined $targets{$target}
6628 ? ! defined $target_conditional{$target}
6629 : defined $target_conditional{$target}))
6631 target_error ($target,
6632 "$target defined both conditionally and unconditionally");
6635 # Value here doesn't matter; for targets we only note existence.
6636 $targets{$target} = $where;
6639 if ($target_conditional{$target})
6641 &check_ambiguous_conditional ($target, $cond);
6643 $target_conditional{$target}{$cond} = $where;
6647 # Check the rule for being a suffix rule. If so, store in a hash.
6649 if ((my ($source_suffix, $object_suffix)) = ($target =~ $SUFFIX_RULE_PATTERN))
6651 $suffix_rules{$source_suffix} = $object_suffix;
6652 verbose "Sources ending in .$source_suffix become .$object_suffix";
6653 # Set SUFFIXES from suffix_rules.
6654 push @suffixes, ".$source_suffix", ".$object_suffix";
6661 # See if a target exists.
6665 return defined $targets{$target};
6669 ################################################################
6671 # &read_am_file ($AMFILE)
6672 # -----------------------
6673 # Read Makefile.am and set up %contents. Simultaneously copy lines
6674 # from Makefile.am into $output_trailer or $output_vars as
6675 # appropriate. NOTE we put rules in the trailer section. We want
6676 # user rules to come after our generated stuff.
6677 sub read_am_file ($)
6681 my $am_file = new Automake::XFile ("< $amfile");
6682 verbose "reading $amfile";
6688 while ($_ = $am_file->getline)
6690 if (/$IGNORE_PATTERN/o)
6692 # Merely delete comments beginning with two hashes.
6694 elsif (/$WHITE_PATTERN/o)
6696 # Stick a single white line before the incoming macro or rule.
6700 elsif (/$COMMENT_PATTERN/o)
6702 # Stick comments before the incoming macro or rule. Make
6703 # sure a blank line preceeds first block of comments.
6704 $spacing = "\n" unless $blank;
6706 $comment .= $spacing . $_;
6715 $output_vars .= $comment . "\n";
6719 # We save the conditional stack on entry, and then check to make
6720 # sure it is the same on exit. This lets us conditonally include
6722 my @saved_cond_stack = @cond_stack;
6723 my $cond = conditional_string (@cond_stack);
6727 my $last_var_name = '';
6728 my $last_var_type = '';
6729 my $last_var_value = '';
6730 # FIXME: shouldn't use $_ in this loop; it is too big.
6733 my $here = "$amfile:$.";
6736 unless substr ($_, -1, 1) eq "\n";
6738 # Don't look at MAINTAINER_MODE_TRUE here. That shouldn't be
6739 # used by users. @MAINT@ is an anachronism now.
6740 $_ =~ s/\@MAINT\@//g
6741 unless $seen_maint_mode;
6743 my $new_saw_bk = /\\$/ && ! /$COMMENT_PATTERN/o;
6745 if (/$IGNORE_PATTERN/o)
6747 # Merely delete comments beginning with two hashes.
6749 elsif (/$WHITE_PATTERN/o)
6751 # Stick a single white line before the incoming macro or rule.
6753 file_error ($here, "blank line following trailing backslash")
6756 elsif (/$COMMENT_PATTERN/o)
6758 # Stick comments before the incoming macro or rule.
6759 $comment .= $spacing . $_;
6761 file_error ($here, "comment following trailing backslash")
6768 $output_trailer .= &make_condition (@cond_stack);
6769 $output_trailer .= $_;
6773 $last_var_value .= ' '
6774 unless $last_var_value =~ /\s$/;
6775 $last_var_value .= $_;
6779 $var_comment{$last_var_name} .= "$spacing"
6780 if (!defined $var_comment{$last_var_name}
6781 || substr ($var_comment{$last_var_name}, -1) ne "\n");
6782 $var_comment{$last_var_name} .= "$comment";
6783 $comment = $spacing = '';
6784 macro_define ($last_var_name, 0,
6785 $last_var_type, $cond,
6786 $last_var_value, $here)
6787 if $cond ne 'FALSE';
6788 push (@var_list, $last_var_name);
6793 elsif (/$IF_PATTERN/o)
6795 $cond = cond_stack_if ($1, $2, $here);
6797 elsif (/$ELSE_PATTERN/o)
6799 $cond = cond_stack_else ($1, $2, $here);
6801 elsif (/$ENDIF_PATTERN/o)
6803 $cond = cond_stack_endif ($1, $2, $here);
6806 elsif (/$RULE_PATTERN/o)
6811 rule_define ($1, 0, $cond, $here);
6813 $output_trailer .= $comment . $spacing;
6814 $output_trailer .= &make_condition (@cond_stack);
6815 $output_trailer .= $_;
6816 $comment = $spacing = '';
6818 elsif (/$ASSIGNMENT_PATTERN/o)
6820 # Found a macro definition.
6822 $last_var_name = $1;
6823 $last_var_type = $2;
6824 $last_var_value = $3;
6825 if ($3 ne '' && substr ($3, -1) eq "\\")
6827 # We preserve the `\' because otherwise the long lines
6828 # that are generated will be truncated by broken
6830 $last_var_value = $3 . "\n";
6835 # FIXME: this doesn't always work correctly; it will
6836 # group all comments for a given variable, no matter
6838 # Accumulating variables must not be output.
6839 $var_comment{$last_var_name} .= "$spacing"
6840 if (!defined $var_comment{$last_var_name}
6841 || substr ($var_comment{$last_var_name}, -1) ne "\n");
6842 $var_comment{$last_var_name} .= "$comment";
6843 $comment = $spacing = '';
6845 macro_define ($last_var_name, 0,
6846 $last_var_type, $cond,
6847 $last_var_value, $here)
6848 if $cond ne 'FALSE';
6849 push (@var_list, $last_var_name);
6852 elsif (/$INCLUDE_PATTERN/o)
6856 if ($path =~ s/^\$\(top_srcdir\)\///)
6858 push (@include_stack, "\$\(top_srcdir\)/$path");
6862 $path =~ s/\$\(srcdir\)\///;
6863 push (@include_stack, "\$\(srcdir\)/$path");
6864 $path = $relative_dir . "/" . $path;
6866 &read_am_file ($path);
6870 # This isn't an error; it is probably a continued rule.
6871 # In fact, this is what we assume.
6873 $output_trailer .= $comment . $spacing;
6874 $output_trailer .= &make_condition (@cond_stack);
6875 $output_trailer .= $_;
6876 $comment = $spacing = '';
6877 file_error ($here, "`#' comment at start of rule is unportable")
6878 if $_ =~ /^\t\s*\#/;
6881 $saw_bk = $new_saw_bk;
6882 $_ = $am_file->getline;
6885 $output_trailer .= $comment;
6887 if (join (' ', @saved_cond_stack) ne join (' ', @cond_stack))
6891 &am_error ("unterminated conditionals: @cond_stack");
6895 # FIXME: better error message here.
6896 &am_error ("conditionals not nested in include file");
6902 # define_standard_variables ()
6903 # ----------------------------
6904 # A helper for read_main_am_file which initializes configure variables
6905 # and variables from header-vars.am. This is a subr so we can call it
6907 sub define_standard_variables
6909 my $saved_output_vars = $output_vars;
6910 my ($comments, undef, $rules) =
6911 file_contents_internal (1, "$libdir/am/header-vars.am");
6913 # This will output the definitions in $output_vars, which we don't
6915 foreach my $var (sort keys %configure_vars)
6917 &define_configure_variable ($var);
6918 push (@var_list, $var);
6921 # ... hence, we restore $output_vars.
6922 $output_vars = $saved_output_vars . $comments . $rules;
6925 # Read main am file.
6926 sub read_main_am_file
6930 # This supports the strange variable tricks we are about to play.
6931 if (scalar keys %var_value > 0)
6934 prog_error ("variable defined before read_main_am_file");
6937 # Generate copyright header for generated Makefile.in.
6938 # We do discard the output of predefined variables, handled below.
6939 $output_vars = ("# $in_file_name generated by automake "
6940 . $VERSION . " from $am_file_name.\n");
6941 $output_vars .= '# ' . subst ('configure_input') . "\n";
6942 $output_vars .= $gen_copyright;
6944 # We want to predefine as many variables as possible. This lets
6945 # the user set them with `+=' in Makefile.am. However, we don't
6946 # want these initial definitions to end up in the output quite
6947 # yet. So we just load them, but output them later.
6948 &define_standard_variables;
6950 # Read user file, which might override some of our values.
6951 &read_am_file ($amfile);
6953 # Ouput all the Automake variables. If the user changed one, then
6954 # it is now marked as owned by the user.
6955 foreach my $var (uniq @var_list)
6957 # Don't process user variables.
6958 variable_output ($var)
6959 unless !$var_is_am{$var};
6962 # Now dump the user variables that were defined. We do it in the same
6963 # order in which they were defined (skipping duplicates).
6964 foreach my $var (uniq @var_list)
6966 # Don't process Automake variables.
6967 variable_output ($var)
6968 unless $var_is_am{$var};
6972 ################################################################
6975 # &flatten ($STRING)
6976 # ------------------
6977 # Flatten the $STRING and return the result.
6992 # &make_paragraphs ($MAKEFILE, [%TRANSFORM])
6993 # ------------------------------------------
6994 # Load a $MAKEFILE, apply the %TRANSFORM, and return it as a list of
6996 sub make_paragraphs ($%)
6998 my ($file, %transform) = @_;
7000 # Complete %transform with global options and make it a Perl
7003 "s/$IGNORE_PATTERN//gm;"
7004 . transform (%transform,
7006 'CYGNUS' => $cygnus_mode,
7008 => $seen_maint_mode ? subst ('MAINTAINER_MODE_TRUE') : '',
7010 'SHAR' => $options{'dist-shar'} || 0,
7011 'BZIP2' => $options{'dist-bzip2'} || 0,
7012 'ZIP' => $options{'dist-zip'} || 0,
7013 'COMPRESS' => $options{'dist-tarZ'} || 0,
7015 'INSTALL-INFO' => !$options{'no-installinfo'},
7016 'INSTALL-MAN' => !$options{'no-installman'},
7017 'CK-NEWS' => $options{'check-news'} || 0,
7019 'SUBDIRS' => &variable_defined ('SUBDIRS'),
7020 'TOPDIR' => backname ($relative_dir),
7021 'TOPDIR_P' => $relative_dir eq '.',
7022 'CONFIGURE-AC' => $configure_ac,
7024 'BUILD' => $seen_canonical == $AC_CANONICAL_SYSTEM,
7025 'HOST' => $seen_canonical,
7026 'TARGET' => $seen_canonical == $AC_CANONICAL_SYSTEM,
7028 'LIBTOOL' => defined $configure_vars{'LIBTOOL'})
7029 # We don't need more than two consecutive new-lines.
7030 . 's/\n{3,}/\n\n/g';
7032 # Swallow the file and apply the COMMAND.
7033 my $fc_file = new Automake::XFile "< $file";
7035 verbose "reading $file";
7036 my $saved_dollar_slash = $/;
7038 $_ = $fc_file->getline;
7039 $/ = $saved_dollar_slash;
7044 # Split at unescaped new lines.
7045 my @lines = split (/(?<!\\)\n/, $content);
7048 while (defined ($_ = shift @lines))
7050 my $paragraph = "$_";
7051 # If we are a rule, eat as long as we start with a tab.
7052 if (/$RULE_PATTERN/smo)
7054 while (defined ($_ = shift @lines) && $_ =~ /^\t/)
7056 $paragraph .= "\n$_";
7058 unshift (@lines, $_);
7061 # If we are a comments, eat as much comments as you can.
7062 elsif (/$COMMENT_PATTERN/smo)
7064 while (defined ($_ = shift @lines)
7065 && $_ =~ /$COMMENT_PATTERN/smo)
7067 $paragraph .= "\n$_";
7069 unshift (@lines, $_);
7072 push @res, $paragraph;
7081 # ($COMMENT, $VARIABLES, $RULES)
7082 # &file_contents_internal ($IS_AM, $FILE, [%TRANSFORM])
7083 # -----------------------------------------------------
7084 # Return contents of a file from $libdir/am, automatically skipping
7085 # macros or rules which are already known. $IS_AM iff the caller is
7086 # reading an Automake file (as opposed to the user's Makefile.am).
7087 sub file_contents_internal ($$%)
7089 my ($is_am, $file, %transform) = @_;
7091 my $result_vars = '';
7092 my $result_rules = '';
7096 # We save the conditional stack on entry, and then check to make
7097 # sure it is the same on exit. This lets us conditonally include
7099 my @saved_cond_stack = @cond_stack;
7100 my $cond = conditional_string (@cond_stack);
7102 foreach (make_paragraphs ($file, %transform))
7105 file_error ($file, "blank line following trailing backslash:\n$_")
7107 file_error ($file, "comment following trailing backslash:\n$_")
7112 # Stick empty line before the incoming macro or rule.
7115 elsif (/$COMMENT_PATTERN/mso)
7117 # Stick comments before the incoming macro or rule.
7121 # Handle inclusion of other files.
7122 elsif (/$INCLUDE_PATTERN/o)
7124 if ($cond ne 'FALSE')
7126 my $file = ($is_am ? "$libdir/am/" : '') . $1;
7128 my ($com, $vars, $rules)
7129 = file_contents_internal ($is_am, $file, %transform);
7131 $result_vars .= $vars;
7132 $result_rules .= $rules;
7136 # Handling the conditionals.
7137 elsif (/$IF_PATTERN/o)
7139 $cond = cond_stack_if ($1, $2, $file);
7141 elsif (/$ELSE_PATTERN/o)
7143 $cond = cond_stack_else ($1, $2, $file);
7145 elsif (/$ENDIF_PATTERN/o)
7147 $cond = cond_stack_endif ($1, $2, $file);
7151 elsif (/$RULE_PATTERN/mso)
7153 # Separate relationship from optional actions: the first
7154 # `new-line tab" not preceded by backslash (continuation
7156 # I'm quite shoked! It seems that (\\\n|[^\n]) is not the
7157 # same as `([^\n]|\\\n)!!! Don't swap it, it breaks.
7159 /^((?:\\\n|[^\n])*)(?:\n(\t.*))?$/som;
7160 my ($relationship, $actions) = ($1, $2 || '');
7162 # Separate targets from dependencies: the first colon.
7163 $relationship =~ /^([^:]+\S+) *: *(.*)$/som;
7164 my ($targets, $dependencies) = ($1, $2);
7165 # Remove the escaped new lines.
7166 # I don't know why, but I have to use a tmp $flat_deps.
7167 my $flat_deps = &flatten ($dependencies);
7168 my @deps = split (' ', $flat_deps);
7170 foreach (split (' ' , $targets))
7172 # FIXME: We are not robust to people defining several targets
7173 # at once, only some of them being in %dependencies.
7175 # Output only if not in FALSE.
7176 if (defined $dependencies{$_}
7177 && $cond ne 'FALSE')
7179 &depend ($_, @deps);
7180 $actions{$_} .= $actions;
7184 # Free-lance dependency. Output the rule for all the
7185 # targets instead of one by one.
7187 # Work out all the conditions for which the target hasn't
7189 my @undefined_conds;
7190 if (defined $target_conditional{$targets})
7192 my @defined_conds = keys %{$target_conditional{$targets}};
7193 @undefined_conds = invert_conditions(@defined_conds);
7197 if (defined $targets{$targets})
7199 # No conditions for which target hasn't been defined
7200 @undefined_conds = ();
7204 # Target hasn't been defined for any conditions
7205 @undefined_conds = ("");
7209 if ($cond ne 'FALSE')
7212 for $undefined_cond (@undefined_conds)
7214 my $condparagraph = $paragraph;
7215 $condparagraph =~ s/^/make_condition (@cond_stack, $undefined_cond)/gme;
7216 $result_rules .= "$spacing$comment$condparagraph\n"
7217 if rule_define ($targets, $is_am,
7218 "$cond $undefined_cond", $file);
7221 $comment = $spacing = '';
7227 elsif (/$ASSIGNMENT_PATTERN/mso)
7229 my ($var, $type, $val) = ($1, $2, $3);
7230 file_error ($file, "macro `$var' with trailing backslash")
7233 # Accumulating variables must not be output.
7234 $var_comment{$var} .= "$spacing"
7235 if (!defined $var_comment{$var}
7236 || substr ($var_comment{$var}, -1) ne "\n");
7237 $var_comment{$var} .= "$comment";
7238 macro_define ($var, $is_am, $type, $cond, $val, $file)
7239 if $cond ne 'FALSE';
7240 push (@var_list, $var);
7242 # If the user has set some variables we were in charge
7243 # of (which is detected by the first reading of
7244 # `header-vars.am'), we must not output them.
7245 $result_vars .= "$spacing$comment$_\n"
7246 if $type ne '+' && $var_is_am{$var} && $cond ne 'FALSE';
7248 $comment = $spacing = '';
7252 # This isn't an error; it is probably some tokens which
7253 # configure is supposed to replace, such as `@SET-MAKE@',
7254 # or some part of a rule cut by an if/endif.
7255 if ($cond ne 'FALSE')
7257 s/^/make_condition (@cond_stack)/gme;
7258 $result_rules .= "$spacing$comment$_\n";
7260 $comment = $spacing = '';
7264 if (join (' ', @saved_cond_stack) ne join (' ', @cond_stack))
7268 &am_error ("unterminated conditionals: @cond_stack");
7272 # FIXME: better error message here.
7273 &am_error ("conditionals not nested in include file");
7277 return ($comment, $result_vars, $result_rules);
7282 # &file_contents ($BASENAME, [%TRANSFORM])
7283 # ----------------------------------------
7284 # Return contents of a file from $libdir/am, automatically skipping
7285 # macros or rules which are already known.
7286 sub file_contents ($%)
7288 my ($basename, %transform) = @_;
7289 my ($comments, $variables, $rules) =
7290 file_contents_internal (1, "$libdir/am/$basename.am", %transform);
7291 return "$comments$variables$rules";
7296 # &transform (%PAIRS)
7297 # -------------------
7298 # Foreach ($TOKEN, $VAL) in %PAIRS produce a replacement expression suitable
7299 # for file_contents which:
7300 # - replaces @$TOKEN@ with $VALUE,
7301 # - enables/disables ?$TOKEN?.
7307 while (my ($token, $val) = each %pairs)
7309 $result .= "s/\Q%$token%\E/\Q$val\E/gm;";
7312 $result .= "s/\Q?$token?\E//gm;s/^.*\Q?!$token?\E.*\\n//gm;";
7313 $result .= "s/\Q%?$token%\E/TRUE/gm;";
7317 $result .= "s/\Q?!$token?\E//gm;s/^.*\Q?$token?\E.*\\n//gm;";
7318 $result .= "s/\Q%?$token%\E/FALSE/gm;";
7326 # Find all variable prefixes that are used for install directories. A
7327 # prefix `zar' qualifies iff:
7328 # * `zardir' is a variable.
7329 # * `zar_PRIMARY' is a variable.
7330 sub am_primary_prefixes
7332 my ($primary, $can_dist, @prefixes) = @_;
7334 my %valid = map { $_ => 0 } @prefixes;
7335 $valid{'EXTRA'} = 0;
7336 foreach my $varname (keys %var_value)
7338 # Automake is allowed to define variables that look like they
7339 # are magic variables, such as INSTALL_DATA.
7341 if $var_is_am{$varname};
7343 if ($varname =~ /^(nobase_)?(dist_|nodist_)?(.*)_$primary$/)
7345 my ($base, $dist, $X) = ($1 || '', $2 || '', $3 || '');
7346 if ($dist ne '' && ! $can_dist)
7348 # Note that a configure variable is always legitimate.
7349 # It is natural to name such variables after the
7350 # primary, so we explicitly allow it.
7351 macro_error ($varname,
7352 "invalid variable `$varname': `dist' is forbidden")
7353 if ! exists $configure_vars{$varname};
7355 elsif (! defined $valid{$X} && ! &variable_defined ("${X}dir"))
7357 # Note that a configure variable is always legitimate.
7358 # It is natural to name such variables after the
7359 # primary, so we explicitly allow it.
7360 macro_error ($varname, "invalid variable `$varname'")
7361 if ! exists $configure_vars{$varname};
7365 # Ensure all extended prefixes are actually used.
7366 $valid{"$base$dist$X"} = 1;
7374 # Handle `where_HOW' variable magic. Does all lookups, generates
7375 # install code, and possibly generates code to define the primary
7376 # variable. The first argument is the name of the .am file to munge,
7377 # the second argument is the primary variable (eg HEADERS), and all
7378 # subsequent arguments are possible installation locations. Returns
7379 # list of all values of all _HOW targets.
7381 # FIXME: this should be rewritten to be cleaner. It should be broken
7382 # up into multiple functions.
7384 # Usage is: am_install_var (OPTION..., file, HOW, where...)
7391 my $default_dist = 0;
7394 if ($args[0] eq '-noextra')
7398 elsif ($args[0] eq '-candist')
7402 elsif ($args[0] eq '-defaultdist')
7407 elsif ($args[0] !~ /^-/)
7414 my ($file, $primary, @prefixes) = @args;
7416 # Now that configure substitutions are allowed in where_HOW
7417 # variables, it is an error to actually define the primary. We
7418 # allow `JAVA', as it is customarily used to mean the Java
7419 # interpreter. This is but one of several Java hacks. Similarly,
7420 # `PYTHON' is customarily used to mean the Python interpreter.
7421 macro_error ($primary, "`$primary' is an anachronism")
7422 if &variable_defined ($primary)
7423 && ($primary ne 'JAVA' && $primary ne 'PYTHON');
7426 # Look for misspellings. It is an error to have a variable ending
7427 # in a "reserved" suffix whose prefix is unknown, eg
7428 # "bni_PROGRAMS". However, unusual prefixes are allowed if a
7429 # variable of the same name (with "dir" appended) exists. For
7430 # instance, if the variable "zardir" is defined, then
7431 # "zar_PROGRAMS" becomes valid. This is to provide a little extra
7432 # flexibility in those cases which need it.
7433 my %valid = &am_primary_prefixes ($primary, $can_dist, @prefixes);
7435 # If a primary includes a configure substitution, then the EXTRA_
7436 # form is required. Otherwise we can't properly do our job.
7438 my $warned_about_extra = 0;
7443 # True if the iteration is the first one. Used for instance to
7444 # output parts of the associated file only once.
7446 foreach my $X (sort keys %valid)
7448 my $nodir_name = $X;
7449 my $one_name = $X . '_' . $primary;
7451 unless (&variable_defined ($one_name));
7453 my $strip_subdir = 1;
7454 # If subdir prefix should be preserved, do so.
7455 if ($nodir_name =~ /^nobase_/)
7458 $nodir_name =~ s/^nobase_//;
7461 # If files should be distributed, do so.
7465 $dist_p = (($default_dist && $nodir_name !~ /^nodist_/)
7466 || (! $default_dist && $nodir_name =~ /^dist_/));
7467 $nodir_name =~ s/^(dist|nodist)_//;
7470 # Append actual contents of where_PRIMARY variable to
7472 foreach my $rcurs (&variable_value_as_list_recursive ($one_name, 'all'))
7474 # Skip configure substitutions. Possibly bogus.
7475 if ($rcurs =~ /^\@.*\@$/)
7477 if ($nodir_name eq 'EXTRA')
7479 if (! $warned_about_extra)
7481 $warned_about_extra = 1;
7482 macro_error ($one_name,
7483 "`$one_name' contains configure substitution, but shouldn't");
7486 # Check here to make sure variables defined in
7487 # configure.ac do not imply that EXTRA_PRIMARY
7489 elsif (! defined $configure_vars{$one_name})
7491 $require_extra = $one_name
7498 push (@result, $rcurs);
7501 # A blatant hack: we rewrite each _PROGRAMS primary to include
7503 if ($primary eq 'PROGRAMS')
7505 my @conds = variable_conditions_recursive ($one_name);
7508 foreach my $cond (@conds)
7510 my @one_binlist = ();
7511 my @condval = &variable_value_as_list_recursive ($one_name,
7513 foreach my $rcurs (@condval)
7515 # Skip autoconf substs. Also skip if the user
7516 # already applied $(EXEEXT).
7517 if ($rcurs =~ /^\@.*\@$/ || $rcurs =~ /\$\(EXEEXT\)$/)
7519 push (@one_binlist, $rcurs);
7523 push (@one_binlist, $rcurs . '$(EXEEXT)');
7527 push (@condvals, $cond);
7528 push (@condvals, join (' ', @one_binlist));
7531 variable_delete ($one_name);
7534 my $cond = shift (@condvals);
7535 my @val = split (' ', shift (@condvals));
7536 define_pretty_variable ($one_name, $cond, @val);
7540 # "EXTRA" shouldn't be used when generating clean targets,
7541 # all, or install targets.
7542 if ($nodir_name eq 'EXTRA')
7544 # We used to warn if EXTRA_FOO was defined uselessly,
7545 # but this was annoying.
7549 if ($nodir_name eq 'check')
7551 push (@check, '$(' . $one_name . ')');
7555 push (@used, '$(' . $one_name . ')');
7558 # Is this to be installed?
7559 my $install_p = $nodir_name ne 'noinst' && $nodir_name ne 'check';
7561 # If so, with install-exec? (or install-data?).
7562 my $exec_p = (defined $exec_dir_p {$nodir_name}
7563 ? $exec_dir_p {$nodir_name}
7564 : ($nodir_name =~ /exec/));
7566 # Singular form of $PRIMARY.
7567 (my $one_primary = $primary) =~ s/S$//;
7568 $output_rules .= &file_contents ($file,
7571 'PRIMARY' => $primary,
7572 'ONE_PRIMARY' => $one_primary,
7574 'NDIR' => $nodir_name,
7575 'BASE' => $strip_subdir,
7578 'INSTALL' => $install_p,
7579 'DIST' => $dist_p));
7584 # The JAVA variable is used as the name of the Java interpreter.
7585 # The PYTHON variable is used as the name of the Python interpreter.
7586 if (@used && $primary ne 'JAVA' && $primary ne 'PYTHON')
7589 define_pretty_variable ($primary, '', @used);
7590 $output_vars .= "\n";
7593 if ($require_extra && ! &variable_defined ('EXTRA_' . $primary))
7595 macro_error ($require_extra,
7596 "`$require_extra' contains configure substitution, but `EXTRA_$primary' not defined");
7599 # Push here because PRIMARY might be configure time determined.
7600 push (@all, '$(' . $primary . ')')
7601 if @used && $primary ne 'JAVA' && $primary ne 'PYTHON';
7603 # Make the result unique. This lets the user use conditionals in
7604 # a natural way, but still lets us program lazily -- we don't have
7605 # to worry about handling a particular object more than once.
7606 return uniq (sort @result);
7610 ################################################################
7612 # Each key in this hash is the name of a directory holding a
7613 # Makefile.in. These variables are local to `is_make_dir'.
7615 my $make_dirs_set = 0;
7620 if (! $make_dirs_set)
7622 foreach my $iter (@configure_input_files)
7624 $make_dirs{dirname ($iter)} = 1;
7626 # We also want to notice Makefile.in's.
7627 foreach my $iter (@other_input_files)
7629 if ($iter =~ /Makefile\.in$/)
7631 $make_dirs{dirname ($iter)} = 1;
7636 return defined $make_dirs{$dir};
7639 ################################################################
7641 # This variable is local to the "require file" set of functions.
7642 my @require_file_paths = ();
7644 # If a file name appears as a key in this hash, then it has already
7645 # been checked for. This variable is local to the "require file"
7647 %require_file_found = ();
7649 # See if we want to push this file onto dist_common. This function
7650 # encodes the rules for deciding when to do so.
7651 sub maybe_push_required_file
7653 my ($dir, $file, $fullfile) = @_;
7655 if ($dir eq $relative_dir)
7657 &push_dist_common ($file);
7659 elsif ($relative_dir eq '.' && ! &is_make_dir ($dir))
7661 # If we are doing the topmost directory, and the file is in a
7662 # subdir which does not have a Makefile, then we distribute it
7664 &push_dist_common ($fullfile);
7669 # &require_file_internal ($WHERE, $MYSTRICT, @FILES)
7670 # --------------------------------------------------
7671 # Verify that the file must exist in the current directory.
7672 # $MYSTRICT is the strictness level at which this file becomes required.
7674 # Must set require_file_paths before calling this function.
7675 # require_file_paths is set to hold a single directory (the one in
7676 # which the first file was found) before return.
7677 sub require_file_internal ($$@)
7679 my ($where, $mystrict, @files) = @_;
7681 foreach my $file (@files)
7689 my $dangling_sym = 0;
7690 foreach my $dir (@require_file_paths)
7692 $fullfile = $dir . "/" . $file;
7693 $errdir = $dir unless $errdir;
7695 # Use different name for "error filename". Otherwise on
7696 # an error the bad file will be reported as eg
7697 # `../../install-sh' when using the default
7699 $errfile = $errdir . '/' . $file;
7701 if (-l $fullfile && ! -f $fullfile)
7706 elsif (-f $fullfile)
7709 &maybe_push_required_file ($dir, $file, $fullfile);
7715 # `--force-missing' only has an effect if `--add-missing' is
7717 if ($found_it && (! $add_missing || ! $force_missing))
7719 # Prune the path list.
7720 @require_file_paths = $save_dir;
7724 # If we've already looked for it, we're done. You might
7725 # wonder why we don't do this before searching for the
7726 # file. If we do that, then something like
7727 # AC_OUTPUT(subdir/foo foo) will fail to put foo.in into
7731 next if defined $require_file_found{$file};
7732 $require_file_found{$file} = 1;
7735 if ($strictness >= $mystrict)
7737 if ($dangling_sym && $add_missing)
7745 # Only install missing files according to our desired
7747 my $message = "required file `$errfile' not found";
7752 # Maybe run libtoolize.
7753 my @syslist = ('libtoolize', '--automake');
7754 push @syslist, '--copy'
7757 && grep ($_ eq $file, @libtoolize_files)
7758 && system (@syslist))
7760 $message = "installing `$errfile'";
7762 $trailer = "; cannot run `libtoolize': $!";
7764 elsif (-f ("$libdir/$file"))
7766 # Install the missing file. Symlink if we
7767 # can, copy if we must. Note: delete the file
7768 # first, in case it is a dangling symlink.
7769 $message = "installing `$errfile'";
7770 # Windows Perl will hang if we try to delete a
7771 # file that doesn't exist.
7772 unlink ($errfile) if -f $errfile;
7773 if ($symlink_exists && ! $copy_missing)
7775 if (! symlink ("$libdir/$file", $errfile))
7778 $trailer = "; error while making link: $!";
7781 elsif (system ('cp', "$libdir/$file", $errfile))
7784 $trailer = "\n error while copying";
7788 &maybe_push_required_file (dirname ($errfile),
7791 # Prune the path list.
7792 @require_file_paths = &dirname ($errfile);
7795 # If --force-missing was specified, and we have
7796 # actually found the file, then do nothing.
7798 if $found_it && $force_missing;
7802 file_warning ($where, "$message$trailer");
7806 file_error ($where, "$message$trailer");
7813 # &require_file ($WHERE, $MYSTRICT, @FILES)
7814 # -----------------------------------------
7815 sub require_file ($$@)
7817 my ($where, $mystrict, @files) = @_;
7818 @require_file_paths = $relative_dir;
7819 require_file_internal ($where, $mystrict, @files);
7822 # &require_file_with_macro ($MACRO, $MYSTRICT, @FILES)
7823 # ----------------------------------------------------
7824 sub require_file_with_macro ($$@)
7826 my ($macro, $mystrict, @files) = @_;
7827 require_file ($var_location{$macro}, $mystrict, @files);
7831 # &require_conf_file ($WHERE, $MYSTRICT, @FILES)
7832 # ----------------------------------------------
7833 # Looks in configuration path, as specified by AC_CONFIG_AUX_DIR.
7834 sub require_conf_file ($$@)
7836 my ($where, $mystrict, @files) = @_;
7837 @require_file_paths = @config_aux_path;
7838 require_file_internal ($where, $mystrict, @files);
7839 my $dir = $require_file_paths[0];
7840 @config_aux_path = @require_file_paths;
7841 # Avoid unsightly '/.'s.
7842 $config_aux_dir = '$(top_srcdir)' . ($dir eq '.' ? "" : "/$dir");
7846 # &require_conf_file_with_macro ($MACRO, $MYSTRICT, @FILES)
7847 # ---------------------------------------------------------
7848 sub require_conf_file_with_macro ($$@)
7850 my ($macro, $mystrict, @files) = @_;
7851 require_conf_file ($var_location{$macro}, $mystrict, @files);
7854 ################################################################
7856 # &require_build_directory ($DIRECTORY)
7857 # ------------------------------------
7858 # Emit rules to create $DIRECTORY if needed, and return
7859 # the file that any target requiring this directory should be made
7861 sub require_build_directory ($)
7863 my $directory = shift;
7864 my $dirstamp = "$directory/.dirstamp";
7866 # Don't emit the rule twice.
7867 if (! defined $directory_map{$directory})
7869 $directory_map{$directory} = 1;
7871 # Directory must be removed by `make distclean'.
7872 $compile_clean_files{$dirstamp} = $DIST_CLEAN;
7874 $output_rules .= ("$dirstamp:\n"
7875 . "\t\@\$(mkinstalldirs) $directory\n"
7876 . "\t\@: > $dirstamp\n");
7882 # &require_build_directory_maybe ($FILE)
7883 # --------------------------------------
7884 # If $FILE lies in a subdirectory, emit a rule to create this
7885 # directory and return the file that $FILE should be made
7886 # dependent upon. Otherwise, just return the empty string.
7887 sub require_build_directory_maybe ($)
7890 my $directory = dirname ($file);
7892 if ($directory ne '.')
7894 return require_build_directory ($directory);
7902 ################################################################
7904 # Push a list of files onto dist_common.
7905 sub push_dist_common
7907 prog_error ("push_dist_common run after handle_dist")
7908 if $handle_dist_run;
7909 macro_define ('DIST_COMMON', 1, '+', '', join (' ', @_), '');
7916 $strictness_name = $_[0];
7917 if ($strictness_name eq 'gnu')
7921 elsif ($strictness_name eq 'gnits')
7923 $strictness = $GNITS;
7925 elsif ($strictness_name eq 'foreign')
7927 $strictness = $FOREIGN;
7931 die "$me: level `$strictness_name' not recognized\n";
7936 ################################################################
7938 # Ensure a file exists.
7944 my $touch = new IO::File (">> $file");
7948 # Glob something. Do this to avoid indentation screwups everywhere we
7949 # want to glob. Gross!
7956 # Remove one level of brackets and strip leading spaces,
7957 # as does m4 to function arguments.
7963 my @letters = split //;
7972 next if $depth == 1;
7977 next if $depth == 0;
7978 # don't count orphan right brackets
7979 $depth = 0 if $depth < 0;
7983 return join '', @result;
7986 ################################################################
7988 # print_error ($LEADER, @ARGS)
7989 # ----------------------------
7990 # Do the work of printing the error message. Join @ARGS with spaces,
7991 # then split at newlines and add $LEADER to each line. Uses `warn' to
7992 # print message. Set exit status.
7995 my ($leader, @args) = @_;
7996 my $text = join (' ', @args);
7997 @args = split ("\n", $text);
7998 $text = $leader . join ("\n" . $leader, @args) . "\n";
8004 # Print an error message and set exit status.
8007 print_error ("$me: ${am_file}.am: ", @_);
8011 # &file_error ($FILE, @ARGS)
8012 # --------------------------
8015 my ($file, @args) = @_;
8016 print_error ("$file: ", @args);
8020 # ¯o_error ($MACRO, @ARGS)
8021 # ----------------------------
8022 # Report an error, @ARGS, about $MACRO.
8023 sub macro_error ($@)
8025 my ($macro, @args) = @_;
8026 file_error ($var_location{$macro}, @args);
8030 # &target_error ($TARGET, @ARGS)
8031 # ------------------------------
8032 # Report an error, @ARGS, about the rule $TARGET.
8033 sub target_error ($@)
8035 my ($target, @args) = @_;
8036 file_error ($targets{$target}, @args);
8040 # Like am_error, but while scanning configure.ac.
8043 # FIXME: can run in subdirs.
8044 print_error ("$me: $configure_ac: ", @_);
8047 # &file_warning ($FILE, @ARGS)
8048 # ----------------------------
8049 # Warning message with line number referring to configure.ac.
8050 # Does not affect exit_status
8051 sub file_warning ($@)
8053 my ($file, @args) = @_;
8055 my $saved_exit_status = $exit_status;
8056 my $sig = $SIG{'__WARN__'};
8057 $SIG{'__WARN__'} = 'DEFAULT';
8058 file_error ($file, @args);
8059 $exit_status = $saved_exit_status;
8060 $SIG{'__WARN__'} = $sig;
8063 # Tell user where our aclocal.m4 is, but only once.
8064 sub keyed_aclocal_warning ($)
8067 warn "$me: macro `$key' can be generated by `aclocal'\n";
8070 # Print usage information.
8074 Usage: $0 [OPTION] ... [Makefile]...
8076 Generate Makefile.in for configure from Makefile.am.
8079 --help print this help, then exit
8080 --version print version number, then exit
8081 -v, --verbose verbosely list files processed
8082 -o, --output-dir=DIR put generated Makefile.in's into DIR
8083 --no-force only update Makefile.in's that are out of date
8085 Dependency tracking:
8086 -i, --ignore-deps disable dependency tracking code
8087 --include-deps enable dependency tracking code
8090 --cygnus assume program is part of Cygnus-style tree
8091 --foreign set strictness to foreign
8092 --gnits set strictness to gnits
8093 --gnu set strictness to gnu
8096 -a, --add-missing add missing standard files to package
8097 --libdir=DIR directory storing library files
8098 -c, --copy with -a, copy missing files (default is symlink)
8099 -f, --force-missing force update of standard files
8104 foreach my $iter (sort ((@common_files, @common_sometimes)))
8106 push (@lcomm, $iter) unless $iter eq $last;
8111 print "\nFiles which are automatically distributed, if found:\n";
8112 format USAGE_FORMAT =
8113 @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<
8114 $four[0], $four[1], $four[2], $four[3]
8116 $~ = "USAGE_FORMAT";
8119 my $rows = int(@lcomm / $cols);
8120 my $rest = @lcomm % $cols;
8131 for (my $y = 0; $y < $rows; $y++)
8133 @four = ("", "", "", "");
8134 for (my $x = 0; $x < $cols; $x++)
8136 last if $y + 1 == $rows && $x == $rest;
8138 my $idx = (($x > $rest)
8139 ? ($rows * $rest + ($rows - 1) * ($x - $rest))
8143 $four[$x] = $lcomm[$idx];
8148 print "\nReport bugs to <bug-automake\@gnu.org>.\n";
8155 # Print version information
8159 automake (GNU $PACKAGE) $VERSION
8160 Written by Tom Tromey <tromey\@cygnus.com>.
8162 Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
8163 Free Software Foundation, Inc.
8164 This is free software; see the source for copying conditions. There is NO
8165 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.