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). The presence of
398 # AC_CHECK_TOOL also sets this.
399 my $seen_canonical = 0;
401 # TRUE if we've seen AC_PROG_LIBTOOL.
402 my $seen_libtool = 0;
403 my $libtool_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_config_file ($FOREIGN, 'config.guess', 'config.sub')
1193 # We still need Makefile.in here, because sometimes the `dist'
1194 # target doesn't re-run automake.
1195 if ($am_relative_dir eq $relative_dir)
1197 # Only distribute the files if they are in the same subdir as
1198 # the generated makefile.
1199 &push_dist_common ($in_file_name, $am_file_name);
1202 push (@sources, '$(SOURCES)')
1203 if &variable_defined ('SOURCES');
1205 # Must do this after reading .am file. See read_main_am_file to
1206 # understand weird tricks we play there with variables.
1207 &define_variable ('subdir', $relative_dir);
1209 # Check first, because we might modify some state.
1211 &check_gnu_standards;
1212 &check_gnits_standards;
1214 &handle_configure ($output, $makefile, @secondary_inputs);
1217 &handle_ltlibraries;
1221 # This must run first so that the ANSI2KNR definition is generated
1222 # before it is used by the _.c rules. We have to do this because
1223 # a variable which is used in a dependency must be defined before
1224 # the target, or else make won't properly see it.
1226 # This must be run after all the sources are scanned.
1229 # Re-init SOURCES. FIXME: other code shouldn't depend on this
1230 # (but currently does).
1231 macro_define ('SOURCES', 1, '', 'TRUE',
1232 join (' ', @sources), 'internal');
1233 define_pretty_variable ('DIST_SOURCES', '', @dist_sources);
1245 &handle_minor_options;
1248 # This must come after most other rules.
1249 &handle_dist ($makefile);
1252 &do_check_merge_target;
1253 &handle_all ($output);
1256 if (&variable_defined('lib_LTLIBRARIES') &&
1257 &variable_defined('bin_PROGRAMS'))
1259 $output_rules .= "install-binPROGRAMS: install-libLTLIBRARIES\n\n";
1262 &handle_installdirs;
1264 &handle_factored_dependencies;
1268 if (! -d ($output_directory . '/' . $am_relative_dir))
1270 mkdir ($output_directory . '/' . $am_relative_dir, 0755);
1273 my ($out_file) = $output_directory . '/' . $makefile . ".in";
1274 if (! $force_generation && -e $out_file)
1276 my ($am_time) = (stat ($makefile . '.am'))[9];
1277 my ($in_time) = (stat ($out_file))[9];
1278 # FIXME: should cache these times.
1279 my ($conf_time) = (stat ($configure_ac))[9];
1280 # FIXME: how to do unsigned comparison?
1281 if ($am_time < $in_time || $am_time < $conf_time)
1283 # No need to update.
1286 if (-f 'aclocal.m4')
1288 my ($acl_time) = (stat _)[9];
1289 return if ($am_time < $acl_time);
1293 my $gm_file = new Automake::XFile "> $out_file";
1294 verbose "creating ", $makefile, ".in";
1296 print $gm_file $output_vars;
1297 # We make sure that `all:' is the first target.
1298 print $gm_file $output_all;
1299 print $gm_file $output_header;
1300 print $gm_file $output_rules;
1301 print $gm_file $output_trailer;
1304 ################################################################
1306 # A helper which handles the logic of requiring a version number in
1307 # AUTOMAKE_OPTIONS. Return 1 on error, 0 on success.
1308 sub version_check ($$$$)
1310 my ($rmajor, $rminor, $ralpha, $rfork) = ($1, $2, $3, $4);
1312 &prog_error ("version is incorrect: $VERSION")
1313 if $VERSION !~ /(\d+)\.(\d+)([a-z]?)-?([A-Za-z0-9]+)?/;
1315 my ($tmajor, $tminor, $talpha, $tfork) = ($1, $2, $3, $4);
1320 my $rminorminor = 0;
1321 my $tminorminor = 0;
1323 # Some versions were labelled like `1.4-p3a'. This is the same as
1324 # an alpha release labelled `1.4.3a'. However, a version like
1325 # `1.4g' is the same as `1.4.99g'. Yes, this sucks. Moral:
1326 # always listen to the users.
1327 if ($rfork =~ /p([0-9]+)([a-z]?)/)
1330 # `1.4a-p3b' never existed. But we'll accept it anyway.
1331 $ralpha = $ralpha || $2 || '';
1334 if ($tfork =~ /p([0-9]+)([a-z]?)/)
1337 # `1.4a-p3b' never existed. But we'll accept it anyway.
1338 $talpha = $talpha || $2 || '';
1342 $rminorminor = 99 if $ralpha ne '' && $rminorminor == 0;
1343 $tminorminor = 99 if $talpha ne '' && $tminorminor == 0;
1345 # 2.0 is better than 1.0.
1346 # 1.2 is better than 1.1.
1347 # 1.2a is better than 1.2.
1348 # If we require 3.4n-foo then we require something
1349 # >= 3.4n, with the `foo' fork identifier.
1350 # The $r* variables are what the user specified.
1351 # The $t* variables denote automake itself.
1352 if ($rmajor > $tmajor
1353 || ($rmajor == $tmajor && $rminor > $tminor)
1354 || ($rminor == $tminor && $rminor == $tminor
1355 && $rminorminor > $tminorminor)
1356 || ($rminor == $tminor && $rminor == $tminor
1357 && $rminorminor == $tminorminor
1358 && $ralpha gt $talpha)
1359 || ($rfork ne '' && $rfork ne $tfork))
1361 macro_error ('AUTOMAKE_OPTIONS',
1362 "require version $_, but have $VERSION");
1369 # Handle AUTOMAKE_OPTIONS variable. Return 1 on error, 0 otherwise.
1372 if (&variable_defined ('AUTOMAKE_OPTIONS'))
1374 foreach (&variable_value_as_list_recursive ('AUTOMAKE_OPTIONS', ''))
1377 if ($_ eq 'gnits' || $_ eq 'gnu' || $_ eq 'foreign')
1379 &set_strictness ($_);
1381 elsif ($_ eq 'cygnus')
1385 elsif (/^(.*\/)?ansi2knr$/)
1387 # An option like "../lib/ansi2knr" is allowed. With
1388 # no path prefix, we assume the required programs are
1389 # in this directory. We save the actual option for
1391 $options{'ansi2knr'} = $_;
1393 elsif ($_ eq 'no-installman' || $_ eq 'no-installinfo'
1394 || $_ eq 'dist-shar' || $_ eq 'dist-zip'
1395 || $_ eq 'dist-tarZ' || $_ eq 'dist-bzip2'
1396 || $_ eq 'dejagnu' || $_ eq 'no-texinfo.tex'
1397 || $_ eq 'readme-alpha' || $_ eq 'check-news'
1398 || $_ eq 'subdir-objects' || $_ eq 'nostdinc'
1399 || $_ eq 'no-exeext')
1401 # Explicitly recognize these.
1403 elsif ($_ eq 'no-dependencies')
1405 $use_dependencies = 0;
1407 elsif (/(\d+)\.(\d+)([a-z]?)(-[A-Za-z0-9]+)?/)
1409 # Got a version number.
1410 if (version_check ($1, $2, $3, $4))
1417 macro_error ('AUTOMAKE_OPTIONS',
1418 "option `" . $_ . "\' not recognized");
1423 if ($strictness == $GNITS)
1425 $options{'readme-alpha'} = 1;
1426 $options{'check-news'} = 1;
1433 # get_object_extension ($OUT)
1434 # ---------------------------
1435 # Return object extension. Just once, put some code into the output.
1436 # OUT is the name of the output file
1437 sub get_object_extension
1441 # Maybe require libtool library object files.
1442 my $extension = '.$(OBJEXT)';
1443 $extension = '.lo' if ($out =~ /\.la$/);
1445 # Check for automatic de-ANSI-fication.
1446 $extension = '$U' . $extension
1447 if defined $options{'ansi2knr'};
1449 $get_object_extension_was_run = 1;
1455 # Call finish function for each language that was used.
1456 sub handle_languages
1458 if ($use_dependencies)
1460 # Include auto-dep code. Don't include it if DEP_FILES would
1462 if (&saw_sources_p (0) && keys %dep_files)
1464 # Set location of depcomp.
1465 &define_variable ('depcomp', "\$(SHELL) $config_aux_dir/depcomp");
1467 &require_conf_file ("$am_file.am", $FOREIGN, 'depcomp');
1469 my @deplist = sort keys %dep_files;
1471 # We define this as a conditional variable because BSD
1472 # make can't handle backslashes for continuing comments on
1473 # the following line.
1474 define_pretty_variable ('DEP_FILES', 'AMDEP_TRUE', @deplist);
1476 # Generate each `include' individually. Irix 6 make will
1477 # not properly include several files resulting from a
1478 # variable expansion; generating many separate includes
1480 $output_rules .= "\n";
1481 foreach my $iter (@deplist)
1483 $output_rules .= (subst ('AMDEP_TRUE')
1484 . subst ('am__include')
1486 . subst ('am__quote')
1488 . subst ('am__quote')
1492 $output_rules .= &file_contents ('depend');
1497 &define_variable ('depcomp', '');
1502 # Is the c linker needed?
1504 foreach my $ext (sort keys %extension_seen)
1506 next unless $extension_map{$ext};
1508 my $lang = $languages{$extension_map{$ext}};
1510 my $rule_file = $lang->rule_file || 'depend2';
1512 # Get information on $LANG.
1513 my $pfx = $lang->autodep;
1514 my $fpfx = ($pfx eq '') ? 'CC' : $pfx;
1516 my $AMDEP = (($use_dependencies && $lang->autodep ne 'no')
1517 ? 'AMDEP' : 'FALSE');
1519 my %transform = ('EXT' => $ext,
1522 'LIBTOOL' => $seen_libtool,
1524 '-c' => $lang->compile_flag || '',
1526 => (count_files_for_language ($lang->name) > 1));
1528 # Generate the appropriate rules for this extension.
1529 if (($use_dependencies && $lang->autodep ne 'no')
1530 || defined $lang->compile)
1532 # Some C compilers don't support -c -o. Use it only if really
1534 my $output_flag = $lang->output_flag || '';
1537 && $lang->flags eq 'CFLAGS'
1538 && defined $options{'subdir-objects'});
1540 # FIXME: this is a temporary hack to compute a possible
1541 # derived extension. This is not used by depend2.am.
1542 (my $der_ext = $ext) =~ tr/yl/cc/;
1544 # Another yacc/lex hack.
1545 my $destfile = '$*.' . $der_ext;
1548 file_contents ($rule_file,
1552 'DERIVED-EXT' => $der_ext,
1560 'COMPILE' => '$(' . $lang->compiler . ')',
1561 'LTCOMPILE' => '$(LT' . $lang->compiler . ')',
1562 '-o' => $output_flag);
1565 # Now include code for each specially handled object with this
1567 my %seen_files = ();
1568 foreach my $file (@{$lang_specific_files{$lang->name}})
1570 my ($derived, $source, $obj, $myext) = split (' ', $file);
1572 # We might see a given object twice, for instance if it is
1573 # used under different conditions.
1574 next if defined $seen_files{$obj};
1575 $seen_files{$obj} = 1;
1577 my $flags = $lang->flags || '';
1578 my $val = "${derived}_${flags}";
1580 prog_error ("found $lang->name in handle_languages, but compiler not defined")
1581 unless defined $lang->compile;
1583 (my $obj_compile = $lang->compile) =~ s/\(AM_$flags/\($val/;
1584 my $obj_ltcompile = '$(LIBTOOL) --mode=compile ' . $obj_compile;
1586 # We _need_ `-o' for per object rules.
1587 my $output_flag = $lang->output_flag || '-o';
1589 # Generate a transform which will turn suffix targets in
1590 # depend2.am into real targets for the particular objects we
1593 file_contents ($rule_file,
1598 'SOURCE' => $source,
1599 # Use $myext and not `.o' here, in case
1600 # we are actually building a new source
1601 # file -- e.g. via yacc.
1602 'OBJ' => "$obj$myext",
1603 'OBJOBJ' => "$obj.obj",
1604 'LTOBJ' => "$obj.lo",
1606 'COMPILE' => $obj_compile,
1607 'LTCOMPILE' => $obj_ltcompile,
1608 '-o' => $output_flag));
1611 # The rest of the loop is done once per language.
1612 next if defined $done{$lang};
1615 # Load the language dependent Makefile chunks.
1616 my %lang = map { uc ($_) => 0 } keys %languages;
1617 $lang{uc ($lang->name)} = 1;
1618 $output_rules .= file_contents ('lang-compile', %transform, %lang);
1620 # If the source to a program consists entirely of code from a
1621 # `pure' language, for instance C++ for Fortran 77, then we
1622 # don't need the C compiler code. However if we run into
1623 # something unusual then we do generate the C code. There are
1624 # probably corner cases here that do not work properly.
1625 # People linking Java code to Fortran code deserve pain.
1626 $needs_c ||= ! $lang->pure;
1628 define_compiler_variable ($lang)
1629 if ($lang->compile);
1631 define_linker_variable ($lang)
1634 foreach my $var (@{$lang->config_vars})
1636 am_error ($lang->Name
1637 . " source seen but `$var' not defined in"
1638 . " `$configure_ac'")
1639 if !exists $configure_vars{$var};
1642 # The compiler's flag must be a configure variable.
1643 define_configure_variable ($lang->flags)
1644 if defined $lang->flags && $lang->define_flag;
1646 # Call the finisher.
1650 # If the project is entirely C++ or entirely Fortran 77 (i.e., 1
1651 # suffix rule was learned), don't bother with the C stuff. But if
1652 # anything else creeps in, then use it.
1654 if $need_link || scalar keys %suffix_rules > 1;
1658 if (! defined $done{$languages{'c'}})
1660 &define_configure_variable ($languages{'c'}->flags);
1661 &define_compiler_variable ($languages{'c'});
1663 define_linker_variable ($languages{'c'});
1667 # Check to make sure a source defined in LIBOBJS is not explicitly
1668 # mentioned. This is a separate function (as opposed to being inlined
1669 # in handle_source_transform) because it isn't always appropriate to
1671 sub check_libobjs_sources
1673 my ($one_file, $unxformed) = @_;
1675 foreach my $prefix ('', 'EXTRA_', 'dist_', 'nodist_',
1676 'dist_EXTRA_', 'nodist_EXTRA_')
1679 if (&variable_defined ($prefix . $one_file . '_SOURCES'))
1681 @files = &variable_value_as_list_recursive (
1682 ($prefix . $one_file . '_SOURCES'),
1685 elsif ($prefix eq '')
1687 @files = ($unxformed . '.c');
1694 foreach my $file (@files)
1696 if (defined $libsources{$file})
1698 macro_error ($prefix . $one_file . '_SOURCES',
1699 "automatically discovered file `$file' should not be explicitly mentioned");
1707 # handle_single_transform_list ($VAR, $TOPPARENT, $DERIVED, $OBJ, @FILES)
1708 # -----------------------------------------------------------------------
1709 # Does much of the actual work for handle_source_transform.
1711 # $VAR is the name of the variable that the source filenames come from
1712 # $TOPPARENT is the name of the _SOURCES variable which is being processed
1713 # $DERIVED is the name of resulting executable or library
1714 # $OBJ is the object extension (e.g., `$U.lo')
1715 # @FILES is the list of source files to transform
1716 # Result is a list of the names of objects
1717 # %linkers_used will be updated with any linkers needed
1718 sub handle_single_transform_list ($$$$@)
1720 my ($var, $topparent, $derived, $obj, @files) = @_;
1722 my $nonansi_obj = $obj;
1723 $nonansi_obj =~ s/\$U//g;
1725 # Turn sources into objects. We use a while loop like this
1726 # because we might add to @files in the loop.
1727 while (scalar @files > 0)
1731 # Configure substitutions in _SOURCES variables are errors.
1735 "`$var' includes configure substitution `$_', and is referred to from `$topparent': configure substitutions not allowed in _SOURCES variables");
1739 # If the source file is in a subdirectory then the `.o' is put
1740 # into the current directory, unless the subdir-objects option
1743 # Split file name into base and extension.
1744 next if ! /^(?:(.*)\/)?([^\/]*)\.(.*)$/;
1746 my $directory = $1 || '';
1750 # We must generate a rule for the object if it requires its own flags.
1752 my ($linker, $object);
1754 # This records whether we've seen a derived source file (eg,
1756 my $derived_source = 0;
1758 # This holds the `aggregate context' of the file we are
1759 # currently examining. If the file is compiled with
1760 # per-object flags, then it will be the name of the object.
1761 # Otherwise it will be `AM'. This is used by the target hook
1762 # language function.
1763 my $aggregate = 'AM';
1765 $extension = &derive_suffix ($extension);
1767 if ($extension_map{$extension} &&
1768 ($lang = $languages{$extension_map{$extension}}))
1770 # Found the language, so see what it says.
1771 &saw_extension ($extension);
1773 # Note: computed subr call. The language rewrite function
1774 # should return one of the $LANG_* constants. It could
1775 # also return a list whose first value is such a constant
1776 # and whose second value is a new source extension which
1777 # should be applied. This means this particular language
1778 # generates another source file which we must then process
1780 my $subr = 'lang_' . $lang->name . '_rewrite';
1781 my ($r, $source_extension)
1782 = & $subr ($directory, $base, $extension);
1783 # Skip this entry if we were asked not to process it.
1784 next if $r == $LANG_IGNORE;
1786 # Now extract linker and other info.
1787 $linker = $lang->linker;
1790 if (defined $source_extension)
1792 $this_obj_ext = '.' . $source_extension;
1793 $derived_source = 1;
1797 $this_obj_ext = $obj;
1801 $this_obj_ext = $nonansi_obj;
1803 $object = $base . $this_obj_ext;
1805 if (defined $lang->flags
1806 && &variable_defined ($derived . '_' . $lang->flags))
1808 # We have a per-executable flag in effect for this
1809 # object. In this case we rewrite the object's
1810 # name to ensure it is unique. We also require
1811 # the `compile' program to deal with compilers
1812 # where `-c -o' does not work.
1814 # We choose the name `DERIVED_OBJECT' to ensure
1815 # (1) uniqueness, and (2) continuity between
1816 # invocations. However, this will result in a
1817 # name that is too long for losing systems, in
1818 # some situations. So we provide _SHORTNAME to
1821 my $dname = $derived;
1822 if (&variable_defined ($derived . '_SHORTNAME'))
1824 # FIXME: should use the same conditional as
1825 # the _SOURCES variable. But this is really
1826 # silly overkill -- nobody should have
1827 # conditional shortnames.
1828 $dname = &variable_value ($derived . '_SHORTNAME');
1830 $object = $dname . '-' . $object;
1832 &require_conf_file ("$am_file.am", $FOREIGN, 'compile')
1833 if $lang->name eq 'c';
1835 &prog_error ("$lang->name flags defined without compiler")
1836 if ! defined $lang->compile;
1841 # If rewrite said it was ok, put the object into a
1843 if ($r == $LANG_SUBDIR && $directory ne '')
1845 $object = $directory . '/' . $object;
1848 # If doing dependency tracking, then we can't print
1849 # the rule. If we have a subdir object, we need to
1850 # generate an explicit rule. Actually, in any case
1851 # where the object is not in `.' we need a special
1852 # rule. The per-object rules in this case are
1853 # generated later, by handle_languages.
1854 if ($renamed || $directory ne '')
1856 my $obj_sans_ext = substr ($object, 0,
1857 - length ($this_obj_ext));
1858 my $val = ("$full $obj_sans_ext "
1859 # Only use $this_obj_ext in the derived
1860 # source case because in the other case we
1861 # *don't* want $(OBJEXT) to appear here.
1862 . ($derived_source ? $this_obj_ext : '.o'));
1864 # If we renamed the object then we want to use the
1865 # per-executable flag name. But if this is simply a
1866 # subdir build then we still want to use the AM_ flag
1870 $val = "$derived $val";
1871 $aggregate = $derived;
1878 # Each item on this list is a string consisting of
1879 # four space-separated values: the derived flag prefix
1880 # (eg, for `foo_CFLAGS', it is `foo'), the name of the
1881 # source file, the base name of the output file, and
1882 # the extension for the object file.
1883 push (@{$lang_specific_files{$lang->name}}, $val);
1886 elsif ($extension eq 'o')
1888 # This is probably the result of a direct suffix rule.
1889 # In this case we just accept the rewrite. FIXME:
1890 # this fails if we want libtool objects.
1891 $object = $base . '.' . $extension;
1896 # No error message here. Used to have one, but it was
1898 # FIXME: we could potentially do more processing here,
1899 # perhaps treating the new extension as though it were a
1900 # new source extension (as above). This would require
1901 # more restructuring than is appropriate right now.
1905 if (defined $object_map{$object})
1907 if ($object_map{$object} ne $full)
1909 am_error ("object `$object' created by `$full' and `$object_map{$object}'");
1913 # Let the language do some special magic if required.
1914 $lang->target_hook ($aggregate, $object, $full);
1916 if ($derived_source)
1918 &prog_error ("$lang->name has automatic dependency tracking")
1919 if $lang->autodep ne 'no';
1920 # Make sure this new source file is handled next. That will
1921 # make it appear to be at the right place in the list.
1922 unshift (@files, $object);
1924 &push_dist_common ($object);
1928 $linkers_used{$linker} = 1;
1930 push (@result, $object);
1932 if (! defined $object_map{$object})
1935 $object_map{$object} = $full;
1937 # If file is in subdirectory, we need explicit
1939 if ($directory ne '' || $renamed)
1941 push (@dep_list, $full);
1944 # If resulting object is in subdir, we need to make
1945 # sure the subdir exists at build time.
1946 if ($object =~ /\//)
1948 # FIXME: check that $DIRECTORY is somewhere in the
1951 # We don't allow `..' in object file names for
1952 # *any* source, not just Java. For Java it just
1953 # doesn't make sense, but in general it is
1954 # a problem because we can't pick a good name for
1956 if ($object =~ /(\/|^)\.\.\//)
1958 am_error ("`$full' contains `..' component but should not");
1961 # Make sure object is removed by `make mostlyclean'.
1962 $compile_clean_files{$object} = $MOSTLY_CLEAN;
1964 push (@dep_list, &require_build_directory ($directory));
1966 # If we're generating dependencies, we also want
1967 # to make sure that the appropriate subdir of the
1968 # .deps directory is created.
1969 push (@dep_list, &require_build_directory ('$(DEPDIR)/' . $directory))
1970 if ($use_dependencies);
1973 &pretty_print_rule ($object . ':', "\t", @dep_list)
1974 if scalar @dep_list > 0;
1977 # Transform .o or $o file into .P file (for automatic
1979 if ($lang && $lang->autodep ne 'no')
1981 my $depfile = $object;
1982 $depfile =~ s/\.([^.]*)$/.P$1/;
1983 $depfile =~ s/\$\(OBJEXT\)$/o/;
1984 $dep_files{'$(DEPDIR)/' . $depfile} = 1;
1992 # define_objects_from_sources ($VAR, $OBJVAR, $NODEFINE, $ONE_FILE,
1993 # $OBJ, $PARENT, $TOPPARENT)
1994 # ---------------------------------------------------------------------
1995 # Define an _OBJECTS variable for a _SOURCES variable (or subvariable)
1998 # $VAR is the name of the _SOURCES variable
1999 # $OBJVAR is the name of the _OBJECTS
2000 # $NODEFINE is a boolean: if true, $OBJVAR will not be defined (but
2001 # work done to determine the linker will be).
2002 # $ONE_FILE is the canonical (transformed) name of object to build
2003 # $OBJ is the object extension (ie either `.o' or `$o'.
2004 # $PARENT is the variable in which $VAR is used, or $VAR if not applicable.
2005 # $TOPPARENT is the _SOURCES variable being processed.
2007 # Result is a boolean, true if a linker is needed to deal with the objects.
2009 # %linkers_used, %vars_scanned, @substfroms and @substtos should be cleared
2011 # %linkers_used variable will be set to contain the linkers desired.
2012 # %vars_scanned will be used to check for recursive definitions.
2013 # @substfroms and @substtos will be used to keep a stack of variable
2014 # substitutions to be applied.
2016 sub define_objects_from_sources ($$$$$$$)
2018 my ($var, $objvar, $nodefine, $one_file, $obj, $parent, $topparent) = @_;
2020 if (defined $vars_scanned{$var})
2022 macro_error ($var, "variable `$var' recursively defined");
2025 $vars_scanned{$var} = 1;
2027 my $needlinker = "";
2028 foreach my $cond (variable_conditions ($var))
2031 foreach my $val (&variable_value_as_list ($var, $cond, $parent))
2033 if ($val =~ /^\$\{([^}]*)\}$/ || $val =~ /^\$\(([^)]*)\)$/)
2035 # Handle a sub variable
2038 # If the user uses a losing variable name, just ignore it.
2039 # This isn't ideal, but people have requested it.
2040 next if ($subvar =~ /\@.*\@/);
2042 # See if the variable is actually a substitution reference
2045 if ($subvar =~ /$SUBST_REF_PATTERN/o)
2049 ($from = $2) =~ s/(\W)/\\$1/g;
2051 push @substfroms, $from;
2052 push @substtos, $to;
2054 my $subobjvar = subobjname ($subvar);
2055 push (@result, '$('. $subobjvar . ')');
2057 my $temp = define_objects_from_sources ($subvar, $subobjvar,
2058 $nodefine, $one_file,
2059 $obj, $var, $topparent);
2060 $needlinker ||= $temp;
2067 my $substnum=$#substfroms;
2068 while ($substnum >= 0)
2070 $val =~ s/$substfroms[$substnum]$/$substtos[$substnum]/
2071 if defined $substfroms[$substnum];
2076 &handle_single_transform_list ($var, $topparent, $one_file, $obj, $val);
2077 push (@result, @transformed);
2078 $needlinker = "true" if @transformed;
2082 # Define _OBJECTS conditionally.
2083 define_pretty_variable ($objvar, $cond, (@result))
2087 delete $vars_scanned{$var};
2093 # subobjname ($VARNAME)
2094 # ---------------------
2095 # Return a name for an object variable.
2098 # $VARNAME is the name of the variable the object variable is being
2101 # This function also looks at @substfroms and @substtos to determine any
2102 # substitutions to be performed on the object variable.
2104 # The name returned is unique for the combination of $varname and
2105 # substitutions to be performed.
2110 my $substnum=$#substfroms;
2111 while ($substnum >= 0)
2113 if (defined $substfroms[$substnum] &&
2114 ($substfroms[$substnum] || $substtos[$substnum]))
2116 $key .= ":" . $substfroms[$substnum] . "=" . $substtos[$substnum];
2121 my $num = $substnums{$key};
2124 $num = keys(%substnums) + 1;
2125 $substnums{$key} = $num;
2128 return "am__objects_$num";
2132 # Handle SOURCE->OBJECT transform for one program or library.
2134 # canonical (transformed) name of object to build
2135 # actual name of object to build
2136 # object extension (ie either `.o' or `$o'.
2137 # Return result is name of linker variable that must be used.
2138 # Empty return means just use `LINK'.
2139 sub handle_source_transform
2141 # one_file is canonical name. unxformed is given name. obj is
2143 my ($one_file, $unxformed, $obj) = @_;
2147 if (&variable_defined ($one_file . "_OBJECTS"))
2149 macro_error ($one_file . '_OBJECTS',
2150 $one_file . '_OBJECTS', 'should not be defined');
2151 # No point in continuing.
2158 foreach my $prefix ('', 'EXTRA_', 'dist_', 'nodist_',
2159 'dist_EXTRA_', 'nodist_EXTRA_')
2161 my $var = $prefix . $one_file . "_SOURCES";
2163 if !variable_defined ($var);
2165 # We are going to define _OBJECTS variables using the prefix.
2166 # Then we glom them all together. So we can't use the null
2167 # prefix here as we need it later.
2168 my $xpfx = ($prefix eq '') ? 'am_' : $prefix;
2170 # Keep track of which prefixes we saw.
2171 $used_pfx{$xpfx} = 1
2172 unless $prefix =~ /EXTRA_/;
2174 push (@sources, '$(' . $prefix . $one_file . "_SOURCES)");
2175 push (@dist_sources, '$(' . $prefix . $one_file . "_SOURCES)")
2176 unless $prefix =~ /^nodist_/;
2181 my $temp = define_objects_from_sources ($var,
2182 $xpfx . $one_file . '_OBJECTS',
2183 $prefix =~ /EXTRA_/,
2184 $one_file, $obj, $var, $var);
2185 $needlinker ||= $temp;
2189 $linker ||= &resolve_linker (%linkers_used);
2192 my @keys = sort keys %used_pfx;
2193 if (scalar @keys == 0)
2195 &define_variable ($one_file . "_SOURCES", $unxformed . ".c");
2196 push (@sources, $unxformed . '.c');
2197 push (@dist_sources, $unxformed . '.c');
2201 &handle_single_transform_list ($one_file . '_SOURCES',
2202 $one_file . '_SOURCES',
2205 $linker ||= &resolve_linker (%linkers_used);
2206 define_pretty_variable ($one_file . "_OBJECTS", '', @result)
2210 grep ($_ = '$(' . $_ . $one_file . '_OBJECTS)', @keys);
2211 define_pretty_variable ($one_file . '_OBJECTS', '', @keys);
2214 # If we want to use `LINK' we must make sure it is defined.
2224 # handle_lib_objects ($XNAME, $VAR)
2225 # ---------------------------------
2226 # Special-case @ALLOCA@ and @LIBOBJS@ in _LDADD or _LIBADD variables.
2227 # Also, generate _DEPENDENCIES variable if appropriate.
2229 # transformed name of object being built, or empty string if no object
2230 # name of _LDADD/_LIBADD-type variable to examine
2231 # Returns 1 if LIBOBJS seen, 0 otherwise.
2232 sub handle_lib_objects
2234 my ($xname, $var) = @_;
2236 &prog_error ("handle_lib_objects: $var undefined")
2237 if ! &variable_defined ($var);
2240 foreach my $cond (variable_conditions_recursive ($var))
2242 if (&handle_lib_objects_cond ($xname, $var, $cond))
2250 # Subroutine of handle_lib_objects: handle a particular condition.
2251 sub handle_lib_objects_cond
2253 my ($xname, $var, $cond) = @_;
2255 # We recognize certain things that are commonly put in LIBADD or
2259 my $seen_libobjs = 0;
2262 foreach my $lsearch (&variable_value_as_list_recursive ($var, $cond))
2264 # Skip -lfoo and -Ldir; these are explicitly allowed.
2265 next if $lsearch =~ /^-[lL]/;
2266 if (! $flagvar && $lsearch =~ /^-/)
2268 if ($var =~ /^(.*)LDADD$/)
2270 # Skip -dlopen and -dlpreopen; these are explicitly allowed.
2271 next if $lsearch =~ /^-dl(pre)?open$/;
2273 "linker flags such as `$lsearch' belong in `${1}LDFLAGS");
2277 # Only get this error once.
2280 "linker flags such as `$lsearch' belong in `${1}LDFLAGS");
2284 # Assume we have a file of some sort, and push it onto the
2285 # dependency list. Autoconf substitutions are not pushed;
2286 # rarely is a new dependency substituted into (eg) foo_LDADD
2287 # -- but "bad things (eg -lX11) are routinely substituted.
2288 # Note that LIBOBJS and ALLOCA are exceptions to this rule,
2289 # and handled specially below.
2290 push (@dep_list, $lsearch)
2291 unless $lsearch =~ /^\@.*\@$/;
2293 # Automatically handle @LIBOBJS@ and @ALLOCA@. Basically this
2294 # means adding entries to dep_files.
2295 if ($lsearch =~ /^\@(LT)?LIBOBJS\@$/)
2297 my $lt = $1 ? $1 : '';
2298 my $myobjext = ($1 ? 'l' : '') . 'o';
2300 push (@dep_list, $lsearch);
2302 if (! keys %libsources
2303 && ! &variable_defined ($lt . 'LIBOBJS'))
2306 "\@$lt" . "LIBOBJS\@ seen but never set in `$configure_ac'");
2309 foreach my $iter (keys %libsources)
2311 if ($iter =~ /\.([cly])$/)
2313 &saw_extension ($1);
2314 &saw_extension ('c');
2317 if ($iter =~ /\.h$/)
2319 require_file_with_macro ($var, $FOREIGN, $iter);
2321 elsif ($iter ne 'alloca.c')
2323 my $rewrite = $iter;
2324 $rewrite =~ s/\.c$/.P$myobjext/;
2325 $dep_files{'$(DEPDIR)/' . $rewrite} = 1;
2326 ($rewrite = $iter) =~ s/(\W)/\\$1/g;
2327 $rewrite = "^" . $rewrite . "\$";
2328 # Only require the file if it is not a built source.
2329 if (! &variable_defined ('BUILT_SOURCES')
2330 || ! grep (/$rewrite/,
2331 &variable_value_as_list_recursive (
2332 'BUILT_SOURCES', 'all')))
2334 require_file_with_macro ($var, $FOREIGN, $iter);
2339 elsif ($lsearch =~ /^\@(LT)?ALLOCA\@$/)
2341 my $lt = $1 ? $1 : '';
2342 my $myobjext = ($1 ? 'l' : '') . 'o';
2344 push (@dep_list, $lsearch);
2346 "\@$lt" . "ALLOCA\@ seen but `AC_FUNC_ALLOCA' not in `$configure_ac'")
2347 if ! defined $libsources{'alloca.c'};
2348 $dep_files{'$(DEPDIR)/alloca.P' . $myobjext} = 1;
2349 require_file_with_macro ($var, $FOREIGN, 'alloca.c');
2350 &saw_extension ('c');
2354 if ($xname ne '' && ! &variable_defined ($xname . '_DEPENDENCIES', $cond))
2356 define_pretty_variable ($xname . '_DEPENDENCIES', $cond, @dep_list);
2359 return $seen_libobjs;
2362 # Canonicalize the input parameter
2366 $string =~ tr/A-Za-z0-9_\@/_/c;
2370 # Canonicalize a name, and check to make sure the non-canonical name
2371 # is never used. Returns canonical name. Arguments are name and a
2372 # list of suffixes to check for.
2373 sub check_canonical_spelling
2375 my ($name, @suffixes) = @_;
2377 my $xname = &canonicalize ($name);
2378 if ($xname ne $name)
2380 foreach my $xt (@suffixes)
2382 macro_error ("$name$xt",
2383 "invalid variable `$name$xt'; "
2384 . "should be `$xname$xt'")
2385 if &variable_defined ("$name$xt");
2395 # Set up the compile suite.
2396 sub handle_compile ()
2399 unless $get_object_extension_was_run;
2402 my $default_includes = '';
2403 if (! defined $options{'nostdinc'})
2405 $default_includes = ' -I. -I$(srcdir)';
2407 if (&variable_defined ('CONFIG_HEADER'))
2409 foreach my $hdr (split (' ', &variable_value ('CONFIG_HEADER')))
2411 $default_includes .= ' -I' . dirname ($hdr);
2416 my (@mostly_rms, @dist_rms);
2417 foreach my $item (sort keys %compile_clean_files)
2419 if ($compile_clean_files{$item} == $MOSTLY_CLEAN)
2421 push (@mostly_rms, "\t-rm -f $item");
2423 elsif ($compile_clean_files{$item} == $DIST_CLEAN)
2425 push (@dist_rms, "\t-rm -f $item");
2429 &prog_error ("invalid entry in \%compile_clean_files");
2433 my ($coms, $vars, $rules) =
2434 &file_contents_internal (1, "$libdir/am/compile.am",
2435 ('DEFAULT_INCLUDES' => $default_includes,
2436 'MOSTLYRMS' => join ("\n", @mostly_rms),
2437 'DISTRMS' => join ("\n", @dist_rms)));
2438 $output_vars .= $vars;
2439 $output_rules .= "$coms$rules";
2441 # Check for automatic de-ANSI-fication.
2442 if (defined $options{'ansi2knr'})
2444 if (! $am_c_prototypes)
2446 macro_error ('AUTOMAKE_OPTIONS',
2447 "option `ansi2knr' in use but `AM_C_PROTOTYPES' not in `$configure_ac'");
2448 &keyed_aclocal_warning ('AM_C_PROTOTYPES');
2449 # Only give this error once.
2450 $am_c_prototypes = 1;
2453 # topdir is where ansi2knr should be.
2454 if ($options{'ansi2knr'} eq 'ansi2knr')
2456 # Only require ansi2knr files if they should appear in
2458 require_file_with_macro ('AUTOMAKE_OPTIONS', $FOREIGN,
2459 'ansi2knr.c', 'ansi2knr.1');
2461 # ansi2knr needs to be built before subdirs, so unshift it.
2462 unshift (@all, '$(ANSI2KNR)');
2465 my $ansi2knr_dir = '';
2466 $ansi2knr_dir = dirname ($options{'ansi2knr'})
2467 if $options{'ansi2knr'} ne 'ansi2knr';
2469 $output_rules .= &file_contents ('ansi2knr',
2470 ('ANSI2KNR-DIR' => $ansi2knr_dir));
2477 # Handle libtool rules.
2480 return unless $seen_libtool;
2482 # libtool requires some files, but only at top level.
2483 require_conf_file ($libtool_location, $FOREIGN, @libtoolize_files)
2484 if $relative_dir eq '.';
2486 # Output the libtool compilation rules.
2487 $output_rules .= &file_contents ('libtool');
2490 # handle_programs ()
2491 # ------------------
2492 # Handle C programs.
2495 my @proglist = &am_install_var ('progs', 'PROGRAMS',
2496 'bin', 'sbin', 'libexec', 'pkglib',
2498 return if ! @proglist;
2500 my $seen_libobjs = 0;
2501 foreach my $one_file (@proglist)
2503 my $obj = &get_object_extension ($one_file);
2505 # Canonicalize names and check for misspellings.
2506 my $xname = &check_canonical_spelling ($one_file, '_LDADD', '_LDFLAGS',
2507 '_SOURCES', '_OBJECTS',
2510 my $linker = &handle_source_transform ($xname, $one_file, $obj);
2513 if (&variable_defined ($xname . "_LDADD"))
2515 if (&handle_lib_objects ($xname, $xname . '_LDADD'))
2523 # User didn't define prog_LDADD override. So do it.
2524 &define_variable ($xname . '_LDADD', '$(LDADD)');
2526 # This does a bit too much work. But we need it to
2527 # generate _DEPENDENCIES when appropriate.
2528 if (&variable_defined ('LDADD'))
2530 if (&handle_lib_objects ($xname, 'LDADD'))
2535 elsif (! &variable_defined ($xname . '_DEPENDENCIES'))
2537 &define_variable ($xname . '_DEPENDENCIES', '');
2542 if (&variable_defined ($xname . '_LIBADD'))
2544 macro_error ($xname . '_LIBADD',
2545 "use `" . $xname . "_LDADD', not `"
2546 . $xname . "_LIBADD'");
2549 if (! &variable_defined ($xname . '_LDFLAGS'))
2551 # Define the prog_LDFLAGS variable.
2552 &define_variable ($xname . '_LDFLAGS', '');
2555 # Determine program to use for link.
2557 if (&variable_defined ($xname . '_LINK'))
2559 $xlink = $xname . '_LINK';
2563 $xlink = $linker ? $linker : 'LINK';
2566 # If the resulting program lies into a subdirectory,
2567 # make sure this directory will exist.
2568 my $dirstamp = &require_build_directory_maybe ($one_file);
2570 # Don't add $(EXEEXT) if user already did.
2571 my $extension = ($one_file !~ /\$\(EXEEXT\)$/
2575 $output_rules .= &file_contents ('program',
2576 ('PROGRAM' => $one_file,
2577 'XPROGRAM' => $xname,
2579 'DIRSTAMP' => $dirstamp,
2580 'EXEEXT' => $extension));
2583 if (&variable_defined ('LDADD') && &handle_lib_objects ('', 'LDADD'))
2590 foreach my $one_file (@proglist)
2592 my $xname = &canonicalize ($one_file);
2594 if (&variable_defined ($xname . '_LDADD'))
2596 &check_libobjs_sources ($xname, $xname . '_LDADD');
2598 elsif (&variable_defined ('LDADD'))
2600 &check_libobjs_sources ($xname, 'LDADD');
2607 # handle_libraries ()
2608 # -------------------
2610 sub handle_libraries
2612 my @liblist = &am_install_var ('libs', 'LIBRARIES',
2613 'lib', 'pkglib', 'noinst', 'check');
2614 return if ! @liblist;
2616 my %valid = &am_primary_prefixes ('LIBRARIES', 0, 'lib', 'pkglib',
2618 if (! defined $configure_vars{'RANLIB'})
2620 foreach my $key (keys %valid)
2622 if (&variable_defined ($key . '_LIBRARIES'))
2624 macro_error ($key . '_LIBRARIES',
2625 "library used but `RANLIB' not defined in `$configure_ac'");
2626 # Only get this error once. If this is ever printed,
2628 $configure_vars{'RANLIB'} = 'BUG';
2634 my $seen_libobjs = 0;
2635 foreach my $onelib (@liblist)
2637 # Check that the library fits the standard naming convention.
2638 if (basename ($onelib) !~ /^lib.*\.a/)
2640 # FIXME should put line number here. That means mapping
2641 # from library name back to variable name.
2642 &am_error ("`$onelib' is not a standard library name");
2645 my $obj = &get_object_extension ($onelib);
2647 # Canonicalize names and check for misspellings.
2648 my $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_SOURCES',
2649 '_OBJECTS', '_DEPENDENCIES',
2652 if (! &variable_defined ($xlib . '_AR'))
2654 &define_variable ($xlib . '_AR', '$(AR) cru');
2657 if (&variable_defined ($xlib . '_LIBADD'))
2659 if (&handle_lib_objects ($xlib, $xlib . '_LIBADD'))
2666 # Generate support for conditional object inclusion in
2668 &define_variable ($xlib . "_LIBADD", '');
2671 if (&variable_defined ($xlib . '_LDADD'))
2673 macro_error ($xlib . '_LDADD',
2674 "use `" . $xlib . "_LIBADD', not `"
2675 . $xlib . "_LDADD'");
2678 # Make sure we at look at this.
2679 &examine_variable ($xlib . '_DEPENDENCIES');
2681 &handle_source_transform ($xlib, $onelib, $obj);
2683 # If the resulting library lies into a subdirectory,
2684 # make sure this directory will exist.
2685 my $dirstamp = &require_build_directory_maybe ($onelib);
2687 $output_rules .= &file_contents ('library',
2688 ('LIBRARY' => $onelib,
2689 'XLIBRARY' => $xlib,
2690 'DIRSTAMP' => $dirstamp));
2695 foreach my $onelib (@liblist)
2697 my $xlib = &canonicalize ($onelib);
2698 if (&variable_defined ($xlib . '_LIBADD'))
2700 &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
2707 # handle_ltlibraries ()
2708 # ---------------------
2709 # Handle shared libraries.
2710 sub handle_ltlibraries
2712 my @liblist = &am_install_var ('ltlib', 'LTLIBRARIES',
2713 'noinst', 'lib', 'pkglib', 'check');
2714 return if ! @liblist;
2717 my %valid = &am_primary_prefixes ('LTLIBRARIES', 0, 'lib', 'pkglib',
2720 foreach my $key (keys %valid)
2722 if (&variable_defined ($key . '_LTLIBRARIES'))
2726 macro_error ($key . '_LTLIBRARIES',
2727 "library used but `LIBTOOL' not defined in `$configure_ac'");
2728 # Only get this error once. If this is ever printed,
2730 $configure_vars{'LIBTOOL'} = 'BUG';
2734 # Get the installation directory of each library.
2735 for (&variable_value_as_list_recursive ($key . '_LTLIBRARIES', 'all'))
2739 &am_error ("`$_' is already going to be installed in `$instdirs{$_}'");
2743 $instdirs{$_} = $key;
2749 my $seen_libobjs = 0;
2750 foreach my $onelib (@liblist)
2752 my $obj = &get_object_extension ($onelib);
2754 # Canonicalize names and check for misspellings.
2755 my $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_LDFLAGS',
2756 '_SOURCES', '_OBJECTS',
2759 if (! &variable_defined ($xlib . '_LDFLAGS'))
2761 # Define the lib_LDFLAGS variable.
2762 &define_variable ($xlib . '_LDFLAGS', '');
2765 # Check that the library fits the standard naming convention.
2766 my $libname_rx = "^lib.*\.la";
2767 if ((&variable_defined ($xlib . '_LDFLAGS')
2768 && grep (/-module/, &variable_value_as_list_recursive (
2769 $xlib . '_LDFLAGS', 'all')))
2770 || (&variable_defined ('LDFLAGS')
2771 && grep (/-module/, &variable_value_as_list_recursive (
2772 'LDFLAGS', 'all'))))
2774 # Relax name checking for libtool modules.
2775 $libname_rx = "\.la";
2777 if (basename ($onelib) !~ /$libname_rx$/)
2779 # FIXME this should only be a warning for foreign packages
2780 # FIXME should put line number here. That means mapping
2781 # from library name back to variable name.
2782 &am_error ("`$onelib' is not a standard libtool library name");
2785 if (&variable_defined ($xlib . '_LIBADD'))
2787 if (&handle_lib_objects ($xlib, $xlib . '_LIBADD'))
2794 # Generate support for conditional object inclusion in
2796 &define_variable ($xlib . "_LIBADD", '');
2799 if (&variable_defined ($xlib . '_LDADD'))
2801 macro_error ($xlib . '_LDADD',
2802 "use `" . $xlib . "_LIBADD', not `"
2803 . $xlib . "_LDADD'");
2806 # Make sure we at look at this.
2807 &examine_variable ($xlib . '_DEPENDENCIES');
2809 my $linker = &handle_source_transform ($xlib, $onelib, $obj);
2811 # Determine program to use for link.
2813 if (&variable_defined ($xlib . '_LINK'))
2815 $xlink = $xlib . '_LINK';
2819 $xlink = $linker ? $linker : 'LINK';
2823 if ($instdirs{$onelib} eq 'EXTRA'
2824 || $instdirs{$onelib} eq 'noinst'
2825 || $instdirs{$onelib} eq 'check')
2827 # It's an EXTRA_ library, so we can't specify -rpath,
2828 # because we don't know where the library will end up.
2829 # The user probably knows, but generally speaking automake
2830 # doesn't -- and in fact configure could decide
2831 # dynamically between two different locations.
2836 $rpath = ('-rpath $(' . $instdirs{$onelib} . 'dir)');
2839 # If the resulting library lies into a subdirectory,
2840 # make sure this directory will exist.
2841 my $dirstamp = &require_build_directory_maybe ($onelib);
2843 $output_rules .= &file_contents ('ltlibrary',
2844 ('LTLIBRARY' => $onelib,
2845 'XLTLIBRARY' => $xlib,
2848 'DIRSTAMP' => $dirstamp));
2853 foreach my $onelib (@liblist)
2855 my $xlib = &canonicalize ($onelib);
2856 if (&variable_defined ($xlib . '_LIBADD'))
2858 &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
2864 # See if any _SOURCES variable were misspelled. Also, make sure that
2865 # EXTRA_ variables don't contain configure substitutions.
2868 foreach my $varname (keys %var_value)
2870 foreach my $primary ('_SOURCES', '_LIBADD', '_LDADD', '_LDFLAGS',
2873 if ($varname =~ /$primary$/ && ! $content_seen{$varname})
2875 macro_error ($varname,
2876 "invalid unused variable name: `$varname'");
2885 # NOTE we no longer automatically clean SCRIPTS, because it is
2886 # useful to sometimes distribute scripts verbatim. This happens
2887 # eg in Automake itself.
2888 &am_install_var ('-candist', 'scripts', 'SCRIPTS',
2889 'bin', 'sbin', 'libexec', 'pkgdata',
2894 # ($OUTFILE, $VFILE, @CLEAN_FILES)
2895 # &scan_texinfo_file ($FILENAME)
2896 # ------------------------------
2897 # $OUTFILE is the name of the info file produced by $FILENAME.
2898 # $VFILE is the name of the version.texi file used (empty if none).
2899 # @CLEAN_FILES is the list of by products (indexes etc.)
2900 sub scan_texinfo_file
2902 my ($filename) = @_;
2904 # These are always created, no matter whether indexes are used or not.
2905 my @clean_suffixes = ('aux', 'dvi', 'log', 'ps', 'toc',
2906 # grep new.*index texinfo.tex
2907 'cp', 'fn', 'ky', 'vr', 'tp', 'pg');
2909 # There are predefined indexes which don't follow the regular rules.
2910 my %predefined_index =
2913 'c' => 'cps', 'f' => 'fns', 'k' => 'kys',
2914 'v' => 'vrs', 't' => 'tps', 'p' => 'pgs'
2917 # There are commands which include a hidden index command.
2921 'fn' => 'fns', 'un' => 'fns',
2922 'typefn' => 'fns', 'typefun' => 'fns',
2923 'mac' => 'fns', 'spec' => 'fns',
2924 'op' => 'fns', 'typeop' => 'fns',
2925 'method' => 'fns', 'typemethod' => 'fns',
2927 'vr' => 'vrs', 'var' => 'vrs',
2928 'typevr' => 'vrs', 'typevar' => 'vrs',
2931 'ivar' => 'vrs', 'typeivar' => 'vrs',
2936 # Indexes stored into another one. In this case, the *.??s file
2938 my @syncodeindexes = ();
2940 my $texi = new Automake::XFile "< $filename";
2941 verbose "reading $filename";
2943 my ($outfile, $vfile);
2944 while ($_ = $texi->getline)
2946 if (/^\@setfilename +(\S+)/)
2949 if ($outfile =~ /\.(.+)$/ && $1 ne 'info')
2951 file_error ("$filename:$.",
2952 "output `$outfile' has unrecognized extension");
2956 # A "version.texi" file is actually any file whose name
2957 # matches "vers*.texi".
2958 elsif (/^\@include\s+(vers[^.]*\.texi)\s*$/)
2963 # Try to find what are the indexes which are used.
2965 # Creating a new category of index.
2966 elsif (/^\@def(code)?index (\w+)/)
2968 push @clean_suffixes, $2;
2971 # Storing in a predefined index.
2972 elsif (/^\@([cfkvtp])index /)
2974 push @clean_suffixes, $predefined_index{$1};
2976 elsif (/^\@def(\w+) /)
2978 push @clean_suffixes, $hidden_index{$1}
2979 if defined $hidden_index{$1};
2982 # Merging an index into an another.
2983 elsif (/^\@syn(code)?index (\w+) (\w+)/)
2985 push @syncodeindexes, "$2s";
2986 push @clean_suffixes, "$3s";
2993 &am_error ("`$filename' missing \@setfilename");
2997 my $infobase = basename ($filename);
2998 $infobase =~ s/\.te?xi(nfo)?$//;
2999 # FIXME: I don't understand why, but I can't use "$infobase.$_" => 1.
3000 my %clean_files = map { "$infobase" . ".$_" => 1 } @clean_suffixes;
3001 grep { delete $clean_files{"$infobase.$_"} } @syncodeindexes;
3002 return ($outfile, $vfile, (sort keys %clean_files));
3006 # ($DO-SOMETHING, $TEXICLEANS)
3007 # handle_texinfo_helper ()
3009 # Handle all Texinfo source; helper for handle_texinfo
3010 sub handle_texinfo_helper
3012 macro_error ('TEXINFOS',
3013 "`TEXINFOS' is an anachronism; use `info_TEXINFOS'")
3014 if &variable_defined ('TEXINFOS');
3015 return (0, '') if (! &variable_defined ('info_TEXINFOS')
3016 && ! &variable_defined ('html_TEXINFOS'));
3018 if (&variable_defined ('html_TEXINFOS'))
3020 macro_error ('html_TEXINFOS',
3021 "HTML generation not yet supported");
3025 my @texis = &variable_value_as_list_recursive ('info_TEXINFOS', 'all');
3027 my (@info_deps_list, @dvis_list, @texi_deps);
3034 foreach my $info_cursor (@texis)
3036 my $infobase = $info_cursor;
3037 $infobase =~ s/\.(txi|texinfo|texi)$//;
3039 if ($infobase eq $info_cursor)
3041 # FIXME: report line number.
3042 &am_error ("texinfo file `$info_cursor' has unrecognized extension");
3045 $texi_suffixes{$1} = 1;
3047 # If 'version.texi' is referenced by input file, then include
3048 # automatic versioning capability.
3049 my ($out_file, $vtexi, @clean_files) =
3050 &scan_texinfo_file ("$relative_dir/$info_cursor")
3052 push (@texi_cleans, @clean_files);
3056 &am_error ("`$vtexi', included in `$info_cursor', also included in `$versions{$vtexi}'")
3057 if (defined $versions{$vtexi});
3058 $versions{$vtexi} = $info_cursor;
3060 # We number the stamp-vti files. This is doable since the
3061 # actual names don't matter much. We only number starting
3062 # with the second one, so that the common case looks nice.
3063 my $vti = ($done ? $done : 'vti');
3066 # This is ugly, but it is our historical practice.
3067 if ($config_aux_dir_set_in_configure_in)
3069 require_conf_file_with_macro ('info_TEXINFOS', $FOREIGN,
3074 require_file_with_macro ('info_TEXINFOS', $FOREIGN,
3079 if ($config_aux_dir_set_in_configure_in)
3081 $conf_dir = $config_aux_dir;
3082 $conf_dir .= '/' unless $conf_dir =~ /\/$/;
3086 $conf_dir = '$(srcdir)/';
3088 $output_rules .= &file_contents ('texi-vers',
3089 ('TEXI' => $info_cursor,
3092 'MDDIR' => $conf_dir));
3095 # If user specified file_TEXINFOS, then use that as explicit
3098 push (@texi_deps, $info_cursor);
3099 # Prefix with $(srcdir) because some version of make won't
3100 # work if the target has it and the dependency doesn't.
3101 push (@texi_deps, '$(srcdir)/' . $vtexi) if $vtexi;
3103 my $canonical = &canonicalize ($infobase);
3104 if (&variable_defined ($canonical . "_TEXINFOS"))
3106 push (@texi_deps, '$(' . $canonical . '_TEXINFOS)');
3107 &push_dist_common ('$(' . $canonical . '_TEXINFOS)');
3110 $output_rules .= ("\n" . $out_file . ": "
3111 . join (' ', @texi_deps)
3112 . "\n" . $infobase . ".dvi: "
3113 . join (' ', @texi_deps)
3116 push (@info_deps_list, $out_file);
3117 push (@dvis_list, $infobase . '.dvi');
3120 # Handle location of texinfo.tex.
3121 my $need_texi_file = 0;
3125 $texinfodir = '$(top_srcdir)/../texinfo';
3126 &define_variable ('TEXINFO_TEX', "$texinfodir/texinfo.tex");
3128 elsif ($config_aux_dir_set_in_configure_in)
3130 $texinfodir = $config_aux_dir;
3131 &define_variable ('TEXINFO_TEX', "$texinfodir/texinfo.tex");
3132 $need_texi_file = 2; # so that we require_conf_file later
3134 elsif (&variable_defined ('TEXINFO_TEX'))
3136 # The user defined TEXINFO_TEX so assume he knows what he is
3138 $texinfodir = ('$(srcdir)/'
3139 . dirname (&variable_value ('TEXINFO_TEX')));
3143 $texinfodir = '$(srcdir)';
3144 $need_texi_file = 1;
3147 foreach my $txsfx (sort keys %texi_suffixes)
3149 $output_rules .= &file_contents ('texibuild',
3150 ('TEXINFODIR' => $texinfodir,
3151 'SUFFIX' => $txsfx));
3155 my $texiclean = &pretty_print_internal ("", "\t ", @texi_cleans);
3157 push (@dist_targets, 'dist-info');
3159 if (! defined $options{'no-installinfo'})
3161 # Make sure documentation is made and installed first. Use
3162 # $(INFO_DEPS), not 'info', because otherwise recursive makes
3163 # get run twice during "make all".
3164 unshift (@all, '$(INFO_DEPS)');
3167 &define_variable ("INFO_DEPS", join (' ', @info_deps_list));
3168 &define_variable ("DVIS", join (' ', @dvis_list));
3169 # This next isn't strictly needed now -- the places that look here
3170 # could easily be changed to look in info_TEXINFOS. But this is
3171 # probably better, in case noinst_TEXINFOS is ever supported.
3172 &define_variable ("TEXINFOS", &variable_value ('info_TEXINFOS'));
3174 # Do some error checking. Note that this file is not required
3175 # when in Cygnus mode; instead we defined TEXINFO_TEX explicitly
3177 if ($need_texi_file && ! defined $options{'no-texinfo.tex'})
3179 if ($need_texi_file > 1)
3181 require_conf_file_with_macro ('info_TEXINFOS', $FOREIGN,
3186 require_file_with_macro ('info_TEXINFOS', $FOREIGN, 'texinfo.tex');
3190 return (1, $texiclean);
3195 # Handle all Texinfo source.
3198 my ($do_something, $texiclean) = handle_texinfo_helper ();
3199 $output_rules .= &file_contents ('texinfos',
3200 ('TEXICLEAN' => $texiclean,
3201 'LOCAL-TEXIS' => $do_something));
3204 # Handle any man pages.
3205 sub handle_man_pages
3207 macro_error ('MANS', "`MANS' is an anachronism; use `man_MANS'")
3208 if &variable_defined ('MANS');
3210 # Find all the sections in use. We do this by first looking for
3211 # "standard" sections, and then looking for any additional
3212 # sections used in man_MANS.
3213 my (%sections, %vlist);
3214 # We handle nodist_ for uniformity. man pages aren't distributed
3215 # by default so it isn't actually very important.
3216 foreach my $pfx ('', 'dist_', 'nodist_')
3218 # Add more sections as needed.
3219 foreach my $section ('0'..'9', 'n', 'l')
3221 if (&variable_defined ($pfx . 'man' . $section . '_MANS'))
3223 $sections{$section} = 1;
3224 $vlist{'$(' . $pfx . 'man' . $section . '_MANS)'} = 1;
3226 &push_dist_common ('$(' . $pfx . 'man' . $section . '_MANS)')
3231 if (&variable_defined ($pfx . 'man_MANS'))
3233 $vlist{'$(' . $pfx . 'man_MANS)'} = 1;
3234 foreach (&variable_value_as_list_recursive ($pfx . 'man_MANS', 'all'))
3236 # A page like `foo.1c' goes into man1dir.
3237 if (/\.([0-9a-z])([a-z]*)$/)
3243 &push_dist_common ('$(' . $pfx . 'man_MANS)')
3248 return unless %sections;
3250 # Now for each section, generate an install and unintall rule.
3251 # Sort sections so output is deterministic.
3252 foreach my $section (sort keys %sections)
3254 $output_rules .= &file_contents ('mans', ('SECTION' => $section));
3257 $output_vars .= &file_contents ('mans-vars',
3258 ('MANS' => join (' ', sort keys %vlist)));
3260 if (! defined $options{'no-installman'})
3262 push (@all, '$(MANS)');
3266 # Handle DATA variables.
3269 &am_install_var ('-noextra', '-candist', 'data', 'DATA',
3270 'data', 'sysconf', 'sharedstate', 'localstate',
3271 'pkgdata', 'noinst', 'check');
3278 if (&variable_defined ('SUBDIRS'))
3280 $output_rules .= ("tags-recursive:\n"
3281 . "\tlist=\'\$(SUBDIRS)\'; for subdir in \$\$list; do \\\n"
3282 # Never fail here if a subdir fails; it
3284 . "\t test \"\$\$subdir\" = . || (cd \$\$subdir"
3285 . " && \$(MAKE) \$(AM_MAKEFLAGS) tags); \\\n"
3287 push (@tag_deps, 'tags-recursive');
3288 &depend ('.PHONY', 'tags-recursive');
3291 if (&saw_sources_p (1)
3292 || &variable_defined ('ETAGS_ARGS')
3296 foreach my $one_hdr (@config_headers)
3298 if ($relative_dir eq dirname ($one_hdr))
3300 # The config header is in this directory. So require it.
3301 $config .= ' ' if $config;
3302 $config .= basename ($one_hdr);
3305 $output_rules .= &file_contents ('tags',
3306 ('CONFIG' => $config,
3307 'DIRS' => join (' ', @tag_deps)));
3308 &examine_variable ('TAGS_DEPENDENCIES');
3310 elsif (&variable_defined ('TAGS_DEPENDENCIES'))
3312 macro_error ('TAGS_DEPENDENCIES',
3313 "doesn't make sense to define `TAGS_DEPENDENCIES' without sources or `ETAGS_ARGS'");
3317 # Every Makefile must define some sort of TAGS rule.
3318 # Otherwise, it would be possible for a top-level "make TAGS"
3319 # to fail because some subdirectory failed.
3320 $output_rules .= "tags: TAGS\nTAGS:\n\n";
3324 # Handle multilib support.
3327 if ($seen_multilib && $relative_dir eq '.')
3329 $output_rules .= &file_contents ('multilib');
3335 # &for_dist_common ($A, $B)
3336 # -------------------------
3337 # Subroutine for &handle_dist: sort files to dist.
3339 # We put README first because it then becomes easier to make a
3340 # Usenet-compliant shar file (in these, README must be first).
3342 # FIXME: do more ordering of files here.
3355 # handle_dist ($MAKEFILE)
3356 # -----------------------
3357 # Handle 'dist' target.
3360 my ($makefile) = @_;
3362 # `make dist' isn't used in a Cygnus-style tree.
3363 # Omit the rules so that people don't try to use them.
3364 return if $cygnus_mode;
3366 # Look for common files that should be included in distribution.
3367 # If the aux dir is set, and it does not have a Makefile.am, then
3368 # we check for these files there as well.
3371 if ($relative_dir eq '.'
3372 && $config_aux_dir_set_in_configure_in)
3374 ($auxdir = $config_aux_dir) =~ s,^\$\(top_srcdir\)/,,;
3375 if (! &is_make_dir ($auxdir))
3380 foreach my $cfile (@common_files)
3382 if (-f ($relative_dir . "/" . $cfile))
3384 &push_dist_common ($cfile);
3387 # Don't use `elsif' here because a file might meaningfully
3388 # appear in both directories.
3389 if ($check_aux && -f ($auxdir . '/' . $cfile))
3391 &push_dist_common ($auxdir . '/' . $cfile);
3395 # We might copy elements from $configure_dist_common to
3396 # %dist_common if we think we need to. If the file appears in our
3397 # directory, we would have discovered it already, so we don't
3398 # check that. But if the file is in a subdir without a Makefile,
3399 # we want to distribute it here if we are doing `.'. Ugly!
3400 if ($relative_dir eq '.')
3402 foreach my $file (split (' ' , $configure_dist_common))
3404 if (! &is_make_dir (dirname ($file)))
3406 &push_dist_common ($file);
3413 # Files to distributed. Don't use &variable_value_as_list_recursive
3414 # as it recursively expands `$(dist_pkgdata_DATA)' etc.
3415 check_variable_defined_unconditionally ('DIST_COMMON');
3416 my @dist_common = split (' ', variable_value ('DIST_COMMON', 'TRUE'));
3417 @dist_common = uniq (sort for_dist_common (@dist_common));
3418 pretty_print ('DIST_COMMON = ', "\t", @dist_common);
3420 # Now that we've processed DIST_COMMON, disallow further attempts
3422 $handle_dist_run = 1;
3424 # Scan EXTRA_DIST to see if we need to distribute anything from a
3425 # subdir. If so, add it to the list. I didn't want to do this
3426 # originally, but there were so many requests that I finally
3428 if (&variable_defined ('EXTRA_DIST'))
3430 # FIXME: This should be fixed to work with conditionals. That
3431 # will require only making the entries in %dist_dirs under the
3432 # appropriate condition. This is meaningful if the nature of
3433 # the distribution should depend upon the configure options
3435 foreach (&variable_value_as_list_recursive ('EXTRA_DIST', ''))
3438 next unless s,/+[^/]+$,,;
3444 # We have to check DIST_COMMON for extra directories in case the
3445 # user put a source used in AC_OUTPUT into a subdir.
3446 foreach (&variable_value_as_list_recursive ('DIST_COMMON', 'all'))
3449 next unless s,/+[^/]+$,,;
3454 # Rule to check whether a distribution is viable.
3455 my %transform = ('DISTCHECK-HOOK' => &target_defined ('distcheck-hook'),
3456 'GETTEXT' => $seen_gettext);
3458 # Prepend $(distdir) to each directory given.
3459 my %rewritten = map { '$(distdir)/' . "$_" => 1 } keys %dist_dirs;
3460 $transform{'DISTDIRS'} = join (' ', sort keys %rewritten);
3462 # If we have SUBDIRS, create all dist subdirectories and do
3464 if (&variable_defined ('SUBDIRS'))
3466 # If SUBDIRS is conditionally defined, then set DIST_SUBDIRS
3467 # to all possible directories, and use it. If DIST_SUBDIRS is
3468 # defined, just use it.
3469 my $dist_subdir_name;
3470 # Note that we check DIST_SUBDIRS first on purpose. At least
3471 # one project uses so many conditional subdirectories that
3472 # calling variable_conditionally_defined on SUBDIRS will cause
3473 # automake to grow to 150Mb. Sigh.
3474 if (&variable_defined ('DIST_SUBDIRS')
3475 || variable_conditionally_defined ('SUBDIRS'))
3477 $dist_subdir_name = 'DIST_SUBDIRS';
3478 if (! &variable_defined ('DIST_SUBDIRS'))
3480 define_pretty_variable
3481 ('DIST_SUBDIRS', '',
3482 uniq (&variable_value_as_list_recursive ('SUBDIRS', 'all')));
3487 $dist_subdir_name = 'SUBDIRS';
3488 # We always define this because that is what `distclean'
3490 define_pretty_variable ('DIST_SUBDIRS', '', '$(SUBDIRS)');
3493 $transform{'DIST_SUBDIR_NAME'} = $dist_subdir_name;
3496 # If the target `dist-hook' exists, make sure it is run. This
3497 # allows users to do random weird things to the distribution
3498 # before it is packaged up.
3499 push (@dist_targets, 'dist-hook')
3500 if &target_defined ('dist-hook');
3501 $transform{'DIST-TARGETS'} = join(' ', @dist_targets);
3503 # Defining $(DISTDIR).
3504 $transform{'DISTDIR'} = !&variable_defined('distdir');
3505 $transform{'TOP_DISTDIR'} = backname ($relative_dir);
3507 $output_rules .= &file_contents ('distdir', %transform);
3511 # Handle subdirectories.
3515 unless &variable_defined ('SUBDIRS');
3517 # Make sure each directory mentioned in SUBDIRS actually exists.
3518 foreach my $dir (&variable_value_as_list_recursive ('SUBDIRS', 'all'))
3520 # Skip directories substituted by configure.
3521 next if $dir =~ /^\@.*\@$/;
3523 if (! -d $am_relative_dir . '/' . $dir)
3525 macro_error ('SUBDIRS',
3526 "required directory $am_relative_dir/$dir does not exist");
3530 macro_error ('SUBDIRS', "directory should not contain `/'")
3534 $output_rules .= &file_contents ('subdirs');
3535 variable_pretty_output ('RECURSIVE_TARGETS', 'TRUE');
3539 # ($REGEN, @DEPENDENCIES)
3542 # If aclocal.m4 creation is automated, return the list of its dependencies.
3545 my $regen_aclocal = 0;
3548 unless $relative_dir eq '.';
3550 &examine_variable ('CONFIG_STATUS_DEPENDENCIES');
3551 &examine_variable ('CONFIGURE_DEPENDENCIES');
3553 if (-f 'aclocal.m4')
3555 &define_variable ("ACLOCAL_M4", '$(top_srcdir)/aclocal.m4');
3556 &push_dist_common ('aclocal.m4');
3558 my $aclocal = new Automake::XFile "< aclocal.m4";
3559 my $line = $aclocal->getline;
3560 $regen_aclocal = $line =~ 'generated automatically by aclocal';
3565 if (-f 'acinclude.m4')
3568 push @ac_deps, 'acinclude.m4';
3571 if (&variable_defined ('ACLOCAL_M4_SOURCES'))
3573 push (@ac_deps, '$(ACLOCAL_M4_SOURCES)');
3575 elsif (&variable_defined ('ACLOCAL_AMFLAGS'))
3577 # Scan all -I directories for m4 files. These are our
3579 my $examine_next = 0;
3580 foreach my $amdir (&variable_value_as_list_recursive ('ACLOCAL_AMFLAGS', ''))
3585 if ($amdir !~ /^\// && -d $amdir)
3587 foreach my $ac_dep (&my_glob ($amdir . '/*.m4'))
3589 $ac_dep =~ s/^\.\/+//;
3590 push (@ac_deps, $ac_dep)
3591 unless $ac_dep eq "aclocal.m4"
3592 || $ac_dep eq "acinclude.m4";
3596 elsif ($amdir eq '-I')
3603 # Note that it might be possible that aclocal.m4 doesn't exist but
3604 # should be auto-generated. This case probably isn't very
3607 return ($regen_aclocal, @ac_deps);
3610 # Rewrite a list of input files into a form suitable to put on a
3611 # dependency list. The idea is that if an input file has a directory
3612 # part the same as the current directory, then the directory part is
3613 # simply removed. But if the directory part is different, then
3614 # $(top_srcdir) is prepended. Among other things, this is used to
3615 # generate the dependency list for the output files generated by
3616 # AC_OUTPUT. Consider what the dependencies should look like in this
3618 # AC_OUTPUT(src/out:src/in1:lib/in2)
3619 # The first argument, ADD_SRCDIR, is 1 if $(top_srcdir) should be added.
3620 # If 0 then files that require this addition will simply be ignored.
3621 sub rewrite_inputs_into_dependencies
3623 my ($add_srcdir, @inputs) = @_;
3626 foreach my $single (@inputs)
3628 if (dirname ($single) eq $relative_dir)
3630 push (@newinputs, basename ($single));
3634 push (@newinputs, '$(top_srcdir)/' . $single);
3641 # Handle remaking and configure stuff.
3642 # We need the name of the input file, to do proper remaking rules.
3643 sub handle_configure
3645 my ($local, $input, @secondary_inputs) = @_;
3647 my $input_base = basename ($input);
3648 my $local_base = basename ($local);
3650 my $amfile = $input_base . '.am';
3651 # We know we can always add '.in' because it really should be an
3652 # error if the .in was missing originally.
3653 my $infile = '$(srcdir)/' . $input_base . '.in';
3654 my $colon_infile = '';
3655 if ($local ne $input || @secondary_inputs)
3657 $colon_infile = ':' . $input . '.in';
3659 $colon_infile .= ':' . join (':', @secondary_inputs)
3660 if @secondary_inputs;
3662 my @rewritten = &rewrite_inputs_into_dependencies (1, @secondary_inputs);
3664 my ($regen_aclocal_m4, @aclocal_m4_deps) = scan_aclocal_m4 ();
3667 &file_contents ('configure',
3671 => join (' ', @rewritten),
3673 => ((($relative_dir eq '.') ? '$@' : '$(subdir)/$@')
3678 => join (' ', @include_stack),
3682 => $cygnus_mode ? 'cygnus' : $strictness_name,
3684 => $cmdline_use_dependencies ? '' : ' --ignore-deps',
3685 'MAKEFILE-AM-SOURCES'
3686 => "$input$colon_infile",
3688 => $regen_aclocal_m4,
3690 => join (' ', @aclocal_m4_deps)));
3692 if ($relative_dir eq '.')
3694 &push_dist_common ('acconfig.h')
3698 # If we have a configure header, require it.
3699 my @local_fullnames = @config_fullnames;
3700 my @local_names = @config_names;
3702 my $distclean_config = '';
3703 foreach my $one_hdr (@config_headers)
3705 my $one_fullname = shift (@local_fullnames);
3706 my $one_name = shift (@local_names);
3708 my $header_dir = dirname ($one_name);
3710 # If the header is in the current directory we want to build
3711 # the header here. Otherwise, if we're at the topmost
3712 # directory and the header's directory doesn't have a
3713 # Makefile, then we also want to build the header.
3714 if ($relative_dir eq $header_dir
3715 || ($relative_dir eq '.' && ! &is_make_dir ($header_dir)))
3717 my ($cn_sans_dir, $stamp_dir);
3718 if ($relative_dir eq $header_dir)
3720 $cn_sans_dir = basename ($one_name);
3725 $cn_sans_dir = $one_name;
3726 if ($header_dir eq '.')
3732 $stamp_dir = $header_dir . '/';
3736 # Compute relative path from directory holding output
3737 # header to directory holding input header. FIXME:
3738 # doesn't handle case where we have multiple inputs.
3740 if (dirname ($one_hdr) eq $relative_dir)
3742 $ch_sans_dir = basename ($one_hdr);
3746 $ch_sans_dir = backname ($relative_dir) . '/' . $one_hdr;
3749 require_file ($config_header_location, $FOREIGN, $ch_sans_dir);
3751 # Header defined and in this directory.
3753 if (-f $one_name . '.top')
3755 push (@files, "${cn_sans_dir}.top");
3757 if (-f $one_name . '.bot')
3759 push (@files, "${cn_sans_dir}.bot");
3762 &push_dist_common (@files);
3764 # For now, acconfig.h can only appear in the top srcdir.
3765 if (-f 'acconfig.h')
3767 push (@files, '$(top_srcdir)/acconfig.h');
3770 my $stamp_name = 'stamp-h';
3771 $stamp_name .= "${hdr_index}";
3773 my $out_dir = dirname ($ch_sans_dir);
3776 &file_contents ('remake-hdr',
3777 ('FILES' => join (' ', @files),
3778 'CONFIG_HEADER' => $cn_sans_dir,
3779 'CONFIG_HEADER_IN' => $ch_sans_dir,
3780 'CONFIG_HEADER_FULL' => $one_fullname,
3781 'STAMP' => "$stamp_dir$stamp_name",
3782 'SRC_STAMP' => "$out_dir/$stamp_name"));
3784 &create ("${relative_dir}/${out_dir}/${stamp_name}.in");
3785 require_file ($config_header_location, $FOREIGN,
3786 "${out_dir}/${stamp_name}.in");
3788 $distclean_config .= ' ' if $distclean_config;
3789 $distclean_config .= $cn_sans_dir;
3793 if ($distclean_config)
3795 $output_rules .= &file_contents ('clean-hdr',
3796 ('FILES' => $distclean_config));
3799 # Set location of mkinstalldirs.
3800 &define_variable ('mkinstalldirs',
3801 ('$(SHELL) ' . $config_aux_dir . '/mkinstalldirs'));
3803 macro_error ('CONFIG_HEADER',
3804 "`CONFIG_HEADER' is an anachronism; now determined from `$configure_ac'")
3805 if &variable_defined ('CONFIG_HEADER');
3807 my $config_header = '';
3808 foreach my $one_name (@config_names)
3810 # Generate CONFIG_HEADER define.
3812 if ($relative_dir eq dirname ($one_name))
3814 $one_hdr = basename ($one_name);
3818 $one_hdr = "\$(top_builddir)/${one_name}";
3821 $config_header .= ' ' if $config_header;
3822 $config_header .= $one_hdr;
3826 &define_variable ("CONFIG_HEADER", $config_header);
3829 # Now look for other files in this directory which must be remade
3830 # by config.status, and generate rules for them.
3831 my @actual_other_files = ();
3832 foreach my $lfile (@other_input_files)
3835 my (@inputs, @rewritten_inputs);
3836 my ($need_rewritten);
3837 if ($lfile =~ /^([^:]*):(.*)$/)
3839 # This is the ":" syntax of AC_OUTPUT.
3841 $local = basename ($file);
3842 @inputs = split (':', $2);
3843 @rewritten_inputs = &rewrite_inputs_into_dependencies (1, @inputs);
3844 $need_rewritten = 1;
3850 $local = basename ($file);
3851 @inputs = ($file . '.in');
3853 &rewrite_inputs_into_dependencies (1, @inputs);
3854 $need_rewritten = 0;
3857 # Make sure the dist directory for each input file is created.
3858 # We only have to do this at the topmost level though. This
3859 # is a bit ugly but it easier than spreading out the logic,
3860 # especially in cases like AC_OUTPUT(foo/out:bar/in), where
3861 # there is no Makefile in bar/.
3862 if ($relative_dir eq '.')
3866 $dist_dirs{dirname ($_)} = 1;
3870 # We skip any automake input files, as they are handled
3871 # elsewhere. We also skip files that aren't in this
3872 # directory. However, if the file's directory does not have a
3873 # Makefile, and we are currently doing `.', then we create a
3874 # rule to rebuild the file in the subdir.
3875 next if -f $file . '.am';
3876 my $fd = dirname ($file);
3877 if ($fd ne $relative_dir)
3879 if ($relative_dir eq '.' && ! &is_make_dir ($fd))
3889 # Some users have been tempted to put `stamp-h' in the
3890 # AC_OUTPUT line. This won't do the right thing, so we
3891 # explicitly fail here.
3892 if ($local eq 'stamp-h')
3894 # FIXME: allow real filename.
3895 file_error ($ac_config_files_location,
3896 'stamp-h should not appear in AC_OUTPUT');
3900 $output_rules .= ($local . ': '
3901 . '$(top_builddir)/config.status '
3902 . join (' ', @rewritten_inputs) . "\n"
3904 . 'cd $(top_builddir) && CONFIG_FILES='
3905 . ($relative_dir eq '.' ? '' : '$(subdir)/')
3906 . '$@' . ($need_rewritten
3907 ? (':' . join (':', @inputs))
3909 . ' CONFIG_HEADERS= CONFIG_LINKS= $(SHELL) ./config.status'
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 $seen_canonical = $AC_CANONICAL_HOST
4457 if ! $seen_canonical;
4459 elsif ($macro eq 'AC_CANONICAL_SYSTEM')
4461 $seen_canonical = $AC_CANONICAL_SYSTEM;
4463 elsif ($macro eq 'AC_CONFIG_AUX_DIR')
4465 @config_aux_path = $args[1];
4466 $config_aux_dir_set_in_configure_in = 1;
4468 elsif ($macro eq 'AC_CONFIG_FILES')
4470 # Look at potential Makefile.am's.
4471 $ac_config_files_location = $here;
4472 &scan_autoconf_config_files ($args[1]);
4474 elsif ($macro eq 'AC_LIBSOURCE')
4476 # We should actually also `close' the sources: getopt.c
4477 # wants getopt.h etc. But actually it should be done in the
4478 # macro itself, i.e., we have to first fix Autoconf to extend
4479 # _AC_LIBOBJ_DECL and use it the in various macros.
4480 $libsources{$args[1]} = $here;
4482 elsif ($macro =~ /A(C|M)_PROG_LIBTOOL/)
4484 $seen_libtool = $here;
4485 $libtool_location = $here;
4487 elsif ($macro =~ /AC_PROG_LEX/)
4489 $seen_prog_lex = $here;
4491 elsif ($macro eq 'AC_SUBST')
4493 # Just check for alphanumeric in AC_SUBST. If you do
4494 # AC_SUBST(5), then too bad.
4495 $configure_vars{$args[1]} = $here
4496 if $args[1] =~ /^\w+$/;
4498 elsif ($macro eq 'AM_CONDITIONAL')
4500 $configure_cond{$args[1]} = $here;
4502 elsif ($macro eq 'AM_CONFIG_HEADER')
4504 $config_header_location = $here;
4505 foreach my $one_hdr (split (' ', $args[1]))
4507 push (@config_fullnames, $one_hdr);
4508 if ($one_hdr =~ /^([^:]+):(.+)$/)
4510 push (@config_names, $1);
4511 push (@config_headers, $2);
4515 push (@config_names, $one_hdr);
4516 push (@config_headers, $one_hdr . '.in');
4520 elsif ($macro eq 'AM_C_PROTOTYPES')
4522 $am_c_prototypes = $here;
4524 elsif ($macro eq 'AM_GNU_GETTEXT')
4526 $seen_gettext = $here;
4527 $ac_gettext_location = $here;
4529 elsif ($macro eq 'AM_INIT_AUTOMAKE')
4531 $package_version = $args[2];
4532 $package_version_location = $here;
4533 $seen_init_automake = 1;
4535 elsif ($macro eq 'AM_MAINTAINER_MODE')
4537 $seen_maint_mode = $here;
4539 elsif ($macro eq 'AM_PATH_LISPDIR')
4541 $am_lispdir_location = $here;
4543 elsif ($macro eq 'AM_PATH_PYTHON')
4545 $pythondir_location = $here;
4547 elsif ($macro eq 'AM_PROG_CC_C_O')
4549 $seen_cc_c_o = $here;
4555 # &scan_one_autoconf_file ($FILENAME)
4556 # -----------------------------------
4557 # Scan one file for interesting things. Subroutine of
4558 # &scan_autoconf_files.
4559 sub scan_one_autoconf_file
4561 my ($filename) = @_;
4563 # Some macros already provide the right traces to enable generic
4564 # code and specific arguments, instead of dedicated code. But
4565 # currently we don't handle traces. Rewrite these dedicated
4566 # macros handling into the generic macro invocation, and let our
4567 # generic case handle them.
4571 'AC_FUNC_ALLOCA' => 'AC_LIBSOURCES([alloca.c])',
4572 'AC_FUNC_GETLOADAVG' => 'AC_LIBSOURCES([getloadavg.c])',
4573 'AC_FUNC_MEMCMP' => 'AC_LIBSOURCES([memcmp.c])',
4574 'AC_STRUCT_ST_BLOCKS' => 'AC_LIBSOURCES([fileblocks.c])',
4575 'A[CM]_REPLACE_GNU_GETOPT' => 'AC_LIBSOURCES([getopt.c, getopt1.c])',
4576 'A[CM]_FUNC_STRTOD' => 'AC_LIBSOURCES([strtod.c])',
4577 'AM_WITH_REGEX' => 'AC_LIBSOURCES([rx.c, rx.h, regex.c, regex.h])',
4578 'AC_FUNC_MKTIME' => 'AC_LIBSOURCES([mktime.c])',
4579 'A[CM]_FUNC_ERROR_AT_LINE' => 'AC_LIBSOURCES([error.c, error.h])',
4580 'A[CM]_FUNC_OBSTACK' => 'AC_LIBSOURCES([obstack.c, obstack.h])',
4583 my $configfh = new Automake::XFile ("< $filename");
4584 verbose "reading $filename";
4586 my ($in_ac_output, $in_ac_replace) = (0, 0);
4587 while ($_ = $configfh->getline)
4589 # Remove comments from current line.
4593 # Skip macro definitions. Otherwise we might be confused into
4594 # thinking that a macro that was only defined was actually
4598 # Follow includes. This is a weirdness commonly in use at
4599 # Cygnus and hopefully nowhere else.
4600 if (/sinclude\((.*)\)/ && -f $1)
4602 # $_ being local, if we don't preserve it, when coming
4603 # back we will have $_ undefined, which is bad for the
4604 # the rest of this routine.
4605 my $underscore = $_;
4606 &scan_one_autoconf_file ($1);
4610 for my $generalize (keys %generalize)
4612 s/$generalize/$generalize{$generalize}/g;
4616 my $here = "$filename:$.";
4618 # Populate libobjs array.
4619 if (/LIBOBJS="(.*)\s+\$LIBOBJS"/
4620 || /LIBOBJS="\$LIBOBJS\s+(.*)"/)
4622 foreach my $libobj_iter (split (' ', $1))
4624 if ($libobj_iter =~ /^(.*)\.o(bj)?$/
4625 || $libobj_iter =~ /^(.*)\.\$ac_objext$/
4626 || $libobj_iter =~ /^(.*)\.\$\{ac_objext\}$/)
4628 $libsources{$1 . '.c'} = $here;
4632 elsif (/AC_LIBOBJ\(([^)]+)\)/)
4634 $libsources{"$1.c"} = $here;
4636 elsif (/AC_LIBSOURCE\(([^)]+)\)/)
4638 $libsources{&unquote_m4_arg ($1)} = $here;
4640 elsif (/AC_LIBSOURCES\(([^)]+)\)/)
4642 foreach my $lc_iter (split (/[, ]+/, &unquote_m4_arg ($1)))
4644 $libsources{$lc_iter} = $here;
4648 if (! $in_ac_replace && s/AC_REPLACE_FUNCS\s*\(\[?//)
4654 $in_ac_replace = 0 if s/[\]\)].*$//;
4655 # Remove trailing backslash.
4659 # Need to skip empty elements for Perl 4.
4661 $libsources{$_ . '.c'} = $here;
4665 if (/$obsolete_rx/o)
4668 if ($obsolete_macros{$1} ne '')
4670 $hint = '; ' . $obsolete_macros{$1};
4672 file_error ($here, "`$1' is obsolete$hint");
4675 # Process the AC_OUTPUT and AC_CONFIG_FILES macros.
4676 if (! $in_ac_output && s/(AC_(OUTPUT|CONFIG_FILES))\s*\(\[?//)
4679 $ac_config_files_location = $here;
4690 # Look at potential Makefile.am's.
4691 &scan_autoconf_config_files ($_);
4694 && scalar keys %make_list == 0
4695 && @other_input_files == 0)
4697 file_error ($ac_config_files_location,
4698 "no files mentioned in `$in_ac_output'");
4703 if (/$AC_CONFIG_AUX_DIR_PATTERN/o)
4705 @config_aux_path = &unquote_m4_arg ($1);
4706 $config_aux_dir_set_in_configure_in = $here;
4709 # Check for ansi2knr.
4710 $am_c_prototypes = $here if /AM_C_PROTOTYPES/;
4712 # Check for `-c -o' code.
4713 $seen_cc_c_o = $here if /AM_PROG_CC_C_O/;
4715 # Check for NLS support.
4716 if (/AM_GNU_GETTEXT/)
4718 $seen_gettext = $here;
4719 $ac_gettext_location = $here;
4722 # Handle configuration headers. A config header of `[$1]'
4723 # means we are actually scanning AM_CONFIG_HEADER from
4725 if (/A([CM])_CONFIG_HEADERS?\s*\((.*)\)/
4729 "`automake requires `AM_CONFIG_HEADER', not `AC_CONFIG_HEADER'")
4732 $config_header_location = $here;
4733 foreach my $one_hdr (split (' ', &unquote_m4_arg ($2)))
4735 push (@config_fullnames, $one_hdr);
4736 if ($one_hdr =~ /^([^:]+):(.+)$/)
4738 push (@config_names, $1);
4739 push (@config_headers, $2);
4743 push (@config_names, $one_hdr);
4744 push (@config_headers, $one_hdr . '.in');
4749 # Handle AC_CANONICAL_*. Always allow upgrading to
4750 # AC_CANONICAL_SYSTEM, but never downgrading.
4751 $seen_canonical = $AC_CANONICAL_HOST
4752 if ! $seen_canonical
4753 && (/AC_CANONICAL_HOST/ || /AC_CHECK_TOOL/);
4754 $seen_canonical = $AC_CANONICAL_SYSTEM if /AC_CANONICAL_SYSTEM/;
4756 # If using X, include some extra variable definitions. NOTE
4757 # we don't want to force these into CFLAGS or anything,
4758 # because not all programs will necessarily use X.
4761 foreach my $var ('X_CFLAGS', 'X_LIBS', 'X_EXTRA_LIBS',
4764 $configure_vars{$var} = $here;
4768 # This macro handles several different things.
4769 if (/$AM_INIT_AUTOMAKE_PATTERN/o)
4771 ($package_version = $1) =~ s/$AM_PACKAGE_VERSION_PATTERN/$1/o;
4772 $package_version_location = $here;
4773 $seen_init_automake = $here;
4778 $configure_vars{'LEX'} = $here;
4779 $seen_prog_lex = $here;
4781 if (/AC_PROG_LEX/ && $filename =~ /configure\.(ac|in)$/)
4783 $configure_vars{'LEX'} = $here;
4784 $seen_prog_lex = $here;
4785 file_warning ($here,
4786 "automake requires `AM_PROG_LEX', not `AC_PROG_LEX'");
4789 if (/AC_PROG_(F77|YACC|RANLIB|CC|CXXCPP|CXX|LEX|AWK|CPP|LN_S)/)
4791 $configure_vars{$1} = $here;
4793 if (/$AC_CHECK_PATTERN/o)
4795 $configure_vars{$3} = $here;
4797 if (/$AM_MISSING_PATTERN/o
4801 && $1 ne 'AUTOHEADER'
4802 # AM_INIT_AUTOMAKE is AM_MISSING_PROG'ing MAKEINFO. But
4803 # we handle it elsewhere.
4804 && $1 ne 'MAKEINFO')
4806 $configure_vars{$1} = $here;
4809 # Explicitly avoid ANSI2KNR -- we AC_SUBST that in protos.m4,
4810 # but later define it elsewhere. This is pretty hacky. We
4811 # also explicitly avoid INSTALL_SCRIPT and some other
4812 # variables because they are defined in header-vars.am.
4813 # AMDEPBACKSLASH might be subst'd by `\', which certainly would
4814 # not be appreciated by Make.
4815 if (/$AC_SUBST_PATTERN/o
4817 && $1 ne 'INSTALL_SCRIPT'
4818 && $1 ne 'INSTALL_DATA'
4819 && $1 ne 'AMDEPBACKSLASH')
4821 $configure_vars{$1} = $here;
4824 if (/AM_MAINTAINER_MODE/)
4826 $seen_maint_mode = $here;
4827 $configure_cond{'MAINTAINER_MODE'} = $here;
4830 $am_lispdir_location = $here if /AM_PATH_LISPDIR/;
4832 if (/AM_PATH_PYTHON/)
4834 $pythondir_location = $here;
4835 $configure_vars{'pythondir'} = $here;
4836 $configure_vars{'PYTHON'} = $here;
4839 if (/A(C|M)_PROG_LIBTOOL/)
4841 # We're not ready for this yet. People still use a
4842 # libtool with no AC_PROG_LIBTOOL. Once that is the
4843 # dominant version we can reenable this code -- but next
4844 # time by mentioning the macro in %obsolete_macros, both
4845 # here and in aclocal.in.
4847 # if (/AM_PROG_LIBTOOL/)
4849 # file_warning ($here, "`AM_PROG_LIBTOOL' is obsolete, use `AC_PROG_LIBTOOL' instead");
4851 $seen_libtool = $here;
4852 $libtool_location = $here;
4853 $configure_vars{'LIBTOOL'} = $here;
4854 $configure_vars{'RANLIB'} = $here;
4855 $configure_vars{'CC'} = $here;
4856 # AC_PROG_LIBTOOL runs AC_CANONICAL_HOST. Make sure we
4857 # never downgrade (if we've seen AC_CANONICAL_SYSTEM).
4858 $seen_canonical = $AC_CANONICAL_HOST if ! $seen_canonical;
4861 $seen_multilib = $here if (/AM_ENABLE_MULTILIB/);
4863 if (/$AM_CONDITIONAL_PATTERN/o)
4865 $configure_cond{$1} = $here;
4868 # Check for Fortran 77 intrinsic and run-time libraries.
4869 if (/AC_F77_LIBRARY_LDFLAGS/)
4871 $configure_vars{'FLIBS'} = $here;
4877 # &scan_autoconf_files ()
4878 # -----------------------
4879 # Check whether we use `configure.ac' or `configure.in'.
4880 # Scan it (and possibly `aclocal.m4') for interesting things.
4881 # We must scan aclocal.m4 because there might be AC_SUBSTs and such there.
4882 sub scan_autoconf_files
4884 # Reinitialize libsources here. This isn't really necessary,
4885 # since we currently assume there is only one configure.ac. But
4886 # that won't always be the case.
4889 $configure_ac = find_configure_ac;
4890 die "$me: `configure.ac' or `configure.in' is required\n"
4893 if (defined $ENV{'amtraces'})
4895 print STDERR "$me: Autoconf traces is an experimental feature\n";
4896 print STDERR "$me: use at your own risks\n";
4898 scan_autoconf_traces ($configure_ac);
4902 scan_one_autoconf_file ($configure_ac);
4903 scan_one_autoconf_file ('aclocal.m4')
4907 # Set input and output files if not specified by user.
4910 @input_files = sort keys %make_list;
4911 %output_files = %make_list;
4914 @configure_input_files = sort keys %make_list;
4916 conf_error ("`AM_INIT_AUTOMAKE' must be used")
4917 if ! $seen_init_automake;
4919 # Look for some files we need. Always check for these. This
4920 # check must be done for every run, even those where we are only
4921 # looking at a subdir Makefile. We must set relative_dir so that
4922 # the file-finding machinery works.
4923 # FIXME: Is this broken because it needs dynamic scopes.
4924 # My tests seems to show it's not the case.
4925 $relative_dir = '.';
4926 &require_config_file ($FOREIGN, 'install-sh', 'mkinstalldirs', 'missing');
4927 &am_error ("`install.sh' is an anachronism; use `install-sh' instead")
4928 if -f $config_aux_path[0] . '/install.sh';
4930 &require_config_file ($FOREIGN, 'py-compile')
4931 if $pythondir_location;
4933 # Preserve dist_common for later.
4934 $configure_dist_common = variable_value ('DIST_COMMON', 'TRUE') || '';
4937 ################################################################
4939 # Set up for Cygnus mode.
4942 return unless $cygnus_mode;
4944 &set_strictness ('foreign');
4945 $options{'no-installinfo'} = 1;
4946 $options{'no-dependencies'} = 1;
4947 $use_dependencies = 0;
4949 conf_error ("`AM_MAINTAINER_MODE' required when --cygnus specified")
4950 if !$seen_maint_mode;
4953 # Do any extra checking for GNU standards.
4954 sub check_gnu_standards
4956 if ($relative_dir eq '.')
4958 # In top level (or only) directory.
4960 $GNU, 'INSTALL', 'NEWS', 'README', 'COPYING',
4961 'AUTHORS', 'ChangeLog');
4964 if ($strictness >= $GNU
4965 && defined $options{'no-installman'})
4967 macro_error ('AUTOMAKE_OPTIONS',
4968 "option `no-installman' disallowed by GNU standards");
4971 if ($strictness >= $GNU
4972 && defined $options{'no-installinfo'})
4974 macro_error ('AUTOMAKE_OPTIONS',
4975 "option `no-installinfo' disallowed by GNU standards");
4979 # Do any extra checking for GNITS standards.
4980 sub check_gnits_standards
4982 if ($relative_dir eq '.')
4984 # In top level (or only) directory.
4985 require_file ('', $GNITS, 'THANKS');
4989 ################################################################
4991 # Functions to handle files of each language.
4993 # Each `lang_X_rewrite($DIRECTORY, $BASE, $EXT)' function follows a
4994 # simple formula: Return value is $LANG_SUBDIR if the resulting object
4995 # file should be in a subdir if the source file is, $LANG_PROCESS if
4996 # file is to be dealt with, $LANG_IGNORE otherwise.
4998 # Much of the actual processing is handled in
4999 # handle_single_transform_list. These functions exist so that
5000 # auxiliary information can be recorded for a later cleanup pass.
5001 # Note that the calls to these functions are computed, so don't bother
5002 # searching for their precise names in the source.
5004 # This is just a convenience function that can be used to determine
5005 # when a subdir object should be used.
5008 return defined $options{'subdir-objects'} ? $LANG_SUBDIR : $LANG_PROCESS;
5011 # Rewrite a single C source file.
5014 my ($directory, $base, $ext) = @_;
5016 if (defined $options{'ansi2knr'} && $base =~ /_$/)
5018 # FIXME: include line number in error.
5019 am_error ("C source file `$base.c' would be deleted by ansi2knr rules");
5022 my $r = $LANG_PROCESS;
5023 if (defined $options{'subdir-objects'})
5026 $base = $directory . '/' . $base;
5030 # Only give error once.
5032 # FIXME: line number.
5033 am_error ("C objects in subdir but `AM_PROG_CC_C_O' not in `$configure_ac'");
5036 require_conf_file ("$am_file.am", $FOREIGN, 'compile');
5039 $de_ansi_files{$base} = 1;
5043 # Rewrite a single C++ source file.
5044 sub lang_cxx_rewrite
5046 return &lang_sub_obj;
5049 # Rewrite a single header file.
5050 sub lang_header_rewrite
5052 # Header files are simply ignored.
5053 return $LANG_IGNORE;
5056 # Rewrite a single yacc file.
5057 sub lang_yacc_rewrite
5059 my ($directory, $base, $ext) = @_;
5061 my $r = &lang_sub_obj;
5062 (my $newext = $ext) =~ tr/y/c/;
5063 return ($r, $newext);
5066 # Rewrite a single yacc++ file.
5067 sub lang_yaccxx_rewrite
5069 my ($directory, $base, $ext) = @_;
5071 my $r = &lang_sub_obj;
5072 (my $newext = $ext) =~ tr/y/c/;
5073 return ($r, $newext);
5076 # Rewrite a single lex file.
5077 sub lang_lex_rewrite
5079 my ($directory, $base, $ext) = @_;
5081 my $r = &lang_sub_obj;
5082 (my $newext = $ext) =~ tr/l/c/;
5083 return ($r, $newext);
5086 # Rewrite a single lex++ file.
5087 sub lang_lexxx_rewrite
5089 my ($directory, $base, $ext) = @_;
5091 my $r = &lang_sub_obj;
5092 (my $newext = $ext) =~ tr/l/c/;
5093 return ($r, $newext);
5096 # Rewrite a single assembly file.
5097 sub lang_asm_rewrite
5099 return &lang_sub_obj;
5102 # Rewrite a single Fortran 77 file.
5103 sub lang_f77_rewrite
5105 return $LANG_PROCESS;
5108 # Rewrite a single preprocessed Fortran 77 file.
5109 sub lang_ppf77_rewrite
5111 return $LANG_PROCESS;
5114 # Rewrite a single ratfor file.
5115 sub lang_ratfor_rewrite
5117 return $LANG_PROCESS;
5120 # Rewrite a single Objective C file.
5121 sub lang_objc_rewrite
5123 return &lang_sub_obj;
5126 # Rewrite a single Java file.
5127 sub lang_java_rewrite
5129 return $LANG_SUBDIR;
5132 # The lang_X_finish functions are called after all source file
5133 # processing is done. Each should handle defining rules for the
5134 # language, etc. A finish function is only called if a source file of
5135 # the appropriate type has been seen.
5139 # Push all libobjs files onto de_ansi_files. We actually only
5140 # push files which exist in the current directory, and which are
5141 # genuine source files.
5142 foreach my $file (keys %libsources)
5144 if ($file =~ /^(.*)\.[cly]$/ && -f "$relative_dir/$file")
5146 $de_ansi_files{$1} = 1;
5150 if (defined $options{'ansi2knr'} && keys %de_ansi_files)
5152 # Make all _.c files depend on their corresponding .c files.
5154 foreach my $base (sort keys %de_ansi_files)
5156 # Each _.c file must depend on ansi2knr; otherwise it
5157 # might be used in a parallel build before it is built.
5158 # We need to support files in the srcdir and in the build
5159 # dir (because these files might be auto-generated. But
5160 # we can't use $< -- some makes only define $< during a
5162 $output_rules .= ($base . "_.c: $base.c \$(ANSI2KNR)\n\t"
5163 . '$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) '
5164 . '`if test -f $(srcdir)/' . $base . '.c'
5165 . '; then echo $(srcdir)/' . $base . '.c'
5166 . '; else echo ' . $base . '.c; fi` '
5167 . "| sed 's/^# \\([0-9]\\)/#line \\1/' "
5168 . '| $(ANSI2KNR) > ' . $base . "_.c"
5169 # If ansi2knr fails then we shouldn't
5170 # create the _.c file
5171 . " || rm -f ${base}_.c\n");
5172 push (@objects, $base . '_.$(OBJEXT)');
5173 push (@objects, $base . '_.lo')
5177 # Make all _.o (and _.lo) files depend on ansi2knr.
5178 # Use a sneaky little hack to make it print nicely.
5179 &pretty_print_rule ('', '', @objects, ':', '$(ANSI2KNR)');
5183 # This is a yacc helper which is called whenever we have decided to
5184 # compile a yacc file.
5185 sub lang_yacc_target_hook
5187 my ($self, $aggregate, $output, $input) = @_;
5189 my $flag = $aggregate . "_YFLAGS";
5190 if ((&variable_defined ($flag)
5191 && &variable_value ($flag) =~ /$DASH_D_PATTERN/o)
5192 || (&variable_defined ('YFLAGS')
5193 && &variable_value ('YFLAGS') =~ /$DASH_D_PATTERN/o))
5195 (my $output_base = $output) =~ s/\..*$//;
5196 my $header = $output_base . '.h';
5198 # Found a `-d' that applies to the compilation of this file.
5199 # Add a dependency for the generated header file, and arrange
5200 # for that file to be included in the distribution.
5201 # FIXME: this fails for `nodist_*_SOURCES'.
5202 $output_rules .= "${header}: $output\n";
5203 &push_dist_common ($header);
5204 # If the files are built in the build directory, then we want
5205 # to remove them with `make clean'. If they are in srcdir
5206 # they shouldn't be touched. However, we can't determine this
5207 # statically, and the GNU rules say that yacc/lex output files
5208 # should be removed by maintainer-clean. So that's what we
5210 push (@maintainer_clean_files, $header);
5214 # This is a helper for both lex and yacc.
5215 sub yacc_lex_finish_helper
5217 return if defined $language_scratch{'lex-yacc-done'};
5218 $language_scratch{'lex-yacc-done'} = 1;
5220 # If there is more than one distinct yacc (resp lex) source file
5221 # in a given directory, then the `ylwrap' program is required to
5222 # allow parallel builds to work correctly. FIXME: for now, no
5224 &require_config_file ($FOREIGN, 'ylwrap');
5225 if ($config_aux_dir_set_in_configure_in)
5227 &define_variable ('YLWRAP', $config_aux_dir . "/ylwrap");
5231 &define_variable ('YLWRAP', '$(top_srcdir)/ylwrap');
5235 sub lang_yacc_finish
5237 return if defined $language_scratch{'yacc-done'};
5238 $language_scratch{'yacc-done'} = 1;
5240 if (&variable_defined ('YACCFLAGS'))
5242 macro_error ('YACCFLAGS',
5243 "`YACCFLAGS' obsolete; use `YFLAGS' instead");
5246 if (count_files_for_language ('yacc') > 1)
5248 &yacc_lex_finish_helper;
5255 return if defined $language_scratch{'lex-done'};
5256 $language_scratch{'lex-done'} = 1;
5258 if (! $seen_prog_lex)
5260 &am_error ("lex source seen but `AM_PROG_LEX' not in `$configure_ac'");
5263 if (count_files_for_language ('lex') > 1)
5265 &yacc_lex_finish_helper;
5270 # Given a hash table of linker names, pick the name that has the most
5271 # precedence. This is lame, but something has to have global
5272 # knowledge in order to eliminate the conflict. Add more linkers as
5279 if defined $linkers{'GCJLINK'};
5281 if defined $linkers{'CXXLINK'};
5283 if defined $linkers{'F77LINK'};
5285 if defined $linkers{'OBJCLINK'};
5289 # Called to indicate that an extension was used.
5293 if (! defined $extension_seen{$ext})
5295 $extension_seen{$ext} = 1;
5299 ++$extension_seen{$ext};
5303 # Return the number of files seen for a given language. Knows about
5304 # special cases we care about. FIXME: this is hideous. We need
5305 # something that involves real language objects. For instance yacc
5306 # and yaccxx could both derive from a common yacc class which would
5307 # know about the strange ylwrap requirement. (Or better yet we could
5308 # just not support legacy yacc!)
5309 sub count_files_for_language
5314 if ($name eq 'yacc' || $name eq 'yaccxx')
5316 @names = ('yacc', 'yaccxx');
5318 elsif ($name eq 'lex' || $name eq 'lexxx')
5320 @names = ('lex', 'lexxx');
5328 foreach $name (@names)
5330 my $lang = $languages{$name};
5331 foreach my $ext (@{$lang->extensions})
5333 $r += $extension_seen{$ext}
5334 if defined $extension_seen{$ext};
5341 # Called to ask whether source files have been seen . If HEADERS is 1,
5342 # headers can be included.
5347 # count all the sources
5349 foreach my $val (values %extension_seen)
5356 $count -= count_files_for_language ('header');
5363 # register_language (%ATTRIBUTE)
5364 # ------------------------------
5365 # Register a single language.
5366 # Each %ATTRIBUTE is of the form ATTRIBUTE => VALUE.
5367 sub register_language (%)
5373 unless defined $option{'ansi'};
5374 $option{'autodep'} = 'no'
5375 unless defined $option{'autodep'};
5376 $option{'linker'} = ''
5377 unless defined $option{'linker'};
5378 $option{'define_flag'} = 1
5379 unless defined $option{'define_flag'};
5381 my $lang = new Language (%option);
5384 grep ($extension_map{$_} = $lang->name, @{$lang->extensions});
5385 $languages{$lang->name} = $lang;
5388 # This function is used to find a path from a user-specified suffix to
5389 # `o' or to some other suffix we recognize internally, eg `cc'.
5392 my ($source_ext) = @_;
5394 # FIXME: hard-coding `o' is a mistake. Doing something
5395 # intelligent is harder.
5396 while (! $extension_map{$source_ext}
5397 && $source_ext ne 'o'
5398 && defined $suffix_rules{$source_ext})
5400 $source_ext = $suffix_rules{$source_ext};
5407 ################################################################
5409 # Pretty-print something. HEAD is what should be printed at the
5410 # beginning of the first line, FILL is what should be printed at the
5411 # beginning of every subsequent line.
5412 sub pretty_print_internal
5414 my ($head, $fill, @values) = @_;
5416 my $column = length ($head);
5419 # Fill length is number of characters. However, each Tab
5420 # character counts for eight. So we count the number of Tabs and
5422 my $fill_length = length ($fill);
5423 $fill_length += 7 * ($fill =~ tr/\t/\t/d);
5427 # "71" because we also print a space.
5428 if ($column + length ($_) > 71)
5430 $result .= " \\\n" . $fill;
5431 $column = $fill_length;
5433 $result .= ' ' if $result =~ /\S\z/;
5435 $column += length ($_) + 1;
5442 # Pretty-print something and append to output_vars.
5445 $output_vars .= &pretty_print_internal (@_);
5448 # Pretty-print something and append to output_rules.
5449 sub pretty_print_rule
5451 $output_rules .= &pretty_print_internal (@_);
5455 ################################################################
5459 # &conditional_string(@COND-STACK)
5460 # --------------------------------
5461 # Build a string which denotes the conditional in @COND-STACK. Some
5462 # simplifications are done: `TRUE' entries are elided, and any `FALSE'
5463 # entry results in a return of `FALSE'.
5464 sub conditional_string
5468 if (grep (/^FALSE$/, @stack))
5474 return join (' ', uniq sort grep (!/^TRUE$/, @stack));
5480 # &conditional_true_when ($COND, $WHEN)
5481 # -------------------------------------
5482 # See if a conditional is true. Both arguments are conditional
5483 # strings. This returns true if the first conditional is true when
5484 # the second conditional is true.
5485 # For instance with $COND = `BAR FOO', and $WHEN = `BAR BAZ FOO',
5486 # obviously return 1, and 0 when, for instance, $WHEN = `FOO'.
5487 sub conditional_true_when ($$)
5489 my ($cond, $when) = @_;
5491 # Make a hash holding all the values from $WHEN.
5492 my %cond_vals = map { $_ => 1 } split (' ', $when);
5494 # Check each component of $cond, which looks `COND1 COND2'.
5495 foreach my $comp (split (' ', $cond))
5497 # TRUE is always true.
5498 next if $comp eq 'TRUE';
5499 return 0 if ! defined $cond_vals{$comp};
5507 # &conditional_is_redundant ($COND, @WHENS)
5508 # ----------------------------------------
5509 # Determine whether $COND is redundant with respect to @WHENS.
5511 # Returns true if $COND is true for any of the conditions in @WHENS.
5513 # If there are no @WHENS, then behave as if @WHENS contained a single empty
5515 sub conditional_is_redundant ($@)
5517 my ($cond, @whens) = @_;
5521 return 1 if conditional_true_when ($cond, "");
5525 foreach my $when (@whens)
5527 return 1 if conditional_true_when ($cond, $when);
5536 # condition_negate ($COND)
5537 # ------------------------
5538 sub condition_negate ($)
5542 $cond =~ s/TRUE$/TRUEO/;
5543 $cond =~ s/FALSE$/TRUE/;
5544 $cond =~ s/TRUEO$/FALSE/;
5550 # Compare condition names.
5551 # Issue them in alphabetical order, foo_TRUE before foo_FALSE.
5554 # Be careful we might be comparing `' or `#'.
5555 $a =~ /^(.*)_(TRUE|FALSE)$/;
5556 my ($aname, $abool) = ($1 || '', $2 || '');
5557 $b =~ /^(.*)_(TRUE|FALSE)$/;
5558 my ($bname, $bbool) = ($1 || '', $2 || '');
5559 return ($aname cmp $bname
5560 # Don't bother with IFs, given that TRUE is after FALSE
5561 # just cmp in the reverse order.
5562 || $bbool cmp $abool
5568 # &make_condition (@CONDITIONS)
5569 # -----------------------------
5570 # Transform a list of conditions (themselves can be an internal list
5571 # of conditions, e.g., @CONDITIONS = ('cond1 cond2', 'cond3')) into a
5572 # Make conditional (a pattern for AC_SUBST).
5573 # Correctly returns the empty string when there are no conditions.
5576 my $res = conditional_string (@_);
5578 # There are no conditions.
5584 elsif ($res eq 'FALSE')
5591 $res = '@' . $res . '@';
5600 ## ------------------------------ ##
5601 ## Handling the condition stack. ##
5602 ## ------------------------------ ##
5606 # cond_stack_if ($NEGATE, $COND, $WHERE)
5607 # --------------------------------------
5608 sub cond_stack_if ($$$)
5610 my ($negate, $cond, $where) = @_;
5612 file_error ($where, "$cond does not appear in AM_CONDITIONAL")
5613 if ! $configure_cond{$cond} && $cond !~ /^TRUE|FALSE$/;
5615 $cond = "${cond}_TRUE"
5616 unless $cond =~ /^TRUE|FALSE$/;
5617 $cond = condition_negate ($cond)
5620 push (@cond_stack, $cond);
5622 return conditional_string (@cond_stack);
5627 # cond_stack_else ($NEGATE, $COND, $WHERE)
5628 # ----------------------------------------
5629 sub cond_stack_else ($$$)
5631 my ($negate, $cond, $where) = @_;
5635 file_error ($where, "else without if");
5639 $cond_stack[$#cond_stack] = condition_negate ($cond_stack[$#cond_stack]);
5641 # If $COND is given, check against it.
5644 $cond = "${cond}_TRUE"
5645 unless $cond =~ /^TRUE|FALSE$/;
5646 $cond = condition_negate ($cond)
5650 "else reminder ($negate$cond) incompatible with "
5651 . "current conditional: $cond_stack[$#cond_stack]")
5652 if $cond_stack[$#cond_stack] ne $cond;
5655 return conditional_string (@cond_stack);
5660 # cond_stack_endif ($NEGATE, $COND, $WHERE)
5661 # -----------------------------------------
5662 sub cond_stack_endif ($$$)
5664 my ($negate, $cond, $where) = @_;
5669 file_error ($where, "endif without if: $negate$cond");
5674 # If $COND is given, check against it.
5677 $cond = "${cond}_TRUE"
5678 unless $cond =~ /^TRUE|FALSE$/;
5679 $cond = condition_negate ($cond)
5683 "endif reminder ($negate$cond) incompatible with "
5684 . "current conditional: $cond_stack[$#cond_stack]")
5685 if $cond_stack[$#cond_stack] ne $cond;
5690 return conditional_string (@cond_stack);
5697 ## ------------------------ ##
5698 ## Handling the variables. ##
5699 ## ------------------------ ##
5702 # check_ambiguous_conditional ($VAR, $COND)
5703 # -----------------------------------------
5704 # Check for an ambiguous conditional. This is called when a variable
5705 # is being defined conditionally. If we already know about a
5706 # definition that is true under the same conditions, then we have an
5708 sub check_ambiguous_conditional ($$)
5710 my ($var, $cond) = @_;
5711 foreach my $vcond (keys %{$var_value{$var}})
5714 if ($vcond eq $cond)
5716 $message = "$var multiply defined in condition $cond";
5718 elsif (&conditional_true_when ($vcond, $cond))
5720 $message = ("$var was already defined in condition $vcond, "
5721 . "which implies condition $cond");
5723 elsif (&conditional_true_when ($cond, $vcond))
5725 $message = ("$var was already defined in condition $vcond, "
5726 . "which is implied by condition $cond");
5730 macro_error ($var, $message);
5737 # ¯o_define($VAR, $VAR_IS_AM, $TYPE, $COND, $VALUE, $WHERE)
5738 # -------------------------------------------------------------
5739 # The $VAR can go from Automake to user, but not the converse.
5740 sub macro_define ($$$$$$)
5742 my ($var, $var_is_am, $type, $cond, $value, $where) = @_;
5744 file_error ($where, "bad macro name `$var'")
5745 if $var !~ /$MACRO_PATTERN/o;
5749 # An Automake variable must be consistently defined with the same
5750 # sign by Automake. A user variable must be set by either `=' or
5751 # `:=', and later promoted to `+='.
5754 if (defined $var_type{$var} && $var_type{$var} ne $type)
5757 ("$var was set with `$var_type{$var}=' "
5758 . "and is now set with `$type='"));
5763 if (!defined $var_type{$var} && $type eq '+')
5765 macro_error ($var, "$var must be set with `=' before using `+='");
5768 $var_type{$var} = $type;
5770 # When adding, since we rewrite, don't try to preserve the
5771 # Automake continuation backslashes.
5773 if $type eq '+' && $var_is_am;
5775 # Differentiate the first assignment (including with `+=').
5776 if ($type eq '+' && defined $var_value{$var}{$cond})
5778 if (substr ($var_value{$var}{$cond}, -1) eq "\n")
5780 # Insert a backslash before a trailing newline.
5781 $var_value{$var}{$cond} =
5782 substr ($var_value{$var}{$cond}, 0, -1) . "\\\n";
5784 elsif ($var_value{$var}{$cond})
5786 # Insert a separator.
5787 $var_value{$var}{$cond} .= ' ';
5789 $var_value{$var}{$cond} .= $value;
5793 # The first assignment to a macro sets its location. Ideally I
5794 # suppose we would associate line numbers with random bits of text.
5795 # FIXME: We sometimes redefine some variables, but we want to keep
5796 # the original location. More subs are needed to handle
5797 # properly variables. Once this done, remove this hack.
5798 $var_location{$var} = $where
5799 unless defined $var_location{$var};
5801 # If Automake tries to override a value specified by the user,
5802 # just don't let it do.
5803 if (defined $var_value{$var}{$cond} && !$var_is_am{$var} && $var_is_am)
5807 print STDERR "$me: refusing to override the user definition of:\n";
5809 print STDERR "$me: with `$cond' => `$value'\n";
5814 # There must be no previous value unless the user is redefining
5815 # an Automake variable or an AC_SUBST variable.
5816 check_ambiguous_conditional ($var, $cond)
5817 unless ($var_is_am{$var} && !$var_is_am
5818 || exists $configure_vars{$var});
5820 $var_value{$var}{$cond} = $value;
5824 # An Automake variable can be given to the user, but not the converse.
5825 if (! defined $var_is_am{$var} || !$var_is_am)
5827 $var_is_am{$var} = $var_is_am;
5832 # &variable_delete ($VAR, [@CONDS])
5833 # ---------------------------------
5834 # Forget about $VAR under the conditions @CONDS, or completely if
5836 sub variable_delete ($@)
5838 my ($var, @conds) = @_;
5842 delete $var_value{$var};
5843 delete $var_location{$var};
5844 delete $var_is_am{$var};
5845 delete $var_comment{$var};
5846 delete $var_type{$var};
5850 foreach my $cond (@conds)
5852 delete $var_value{$var}{$cond};
5858 # ¯o_dump ($VAR)
5859 # ------------------
5864 if (!exists $var_value{$var})
5866 print STDERR " $var does not exist\n";
5870 my $var_is_am = $var_is_am{$var} ? "Automake" : "User";
5871 my $where = (defined $var_location{$var}
5872 ? $var_location{$var} : "undefined");
5873 print STDERR "$var_comment{$var}"
5874 if defined $var_comment{$var};
5875 print STDERR " $var ($var_is_am, where = $where) $var_type{$var}=\n";
5876 print STDERR " {\n";
5877 foreach my $vcond (sort by_condition keys %{$var_value{$var}})
5879 print STDERR " $vcond => $var_value{$var}{$vcond}\n";
5881 print STDERR " }\n";
5892 print STDERR "%var_value =\n";
5894 foreach my $var (sort (keys %var_value))
5903 # &variable_defined ($VAR, [$COND])
5904 # ---------------------------------
5905 # See if a variable exists. $VAR is the variable name, and $COND is
5906 # the condition which we should check. If no condition is given, we
5907 # currently return true if the variable is defined under any
5909 sub variable_defined ($$)
5911 my ($var, $cond) = @_;
5913 # Unfortunately we can't just check for $var_value{VAR}{COND}
5914 # as this would make perl create $condition{VAR}, which we
5916 if (!exists $var_value{$var})
5918 if (defined $targets{$var})
5920 macro_error ($var, "`$var' is a target; expected a variable")
5922 # The variable is not defined
5926 if ($cond && !exists $var_value{$var}{$cond})
5928 # The variable is not defined for the given condition.
5932 # Even a var_value examination is good enough for us. FIXME:
5933 # really should maintain examined status on a per-condition basis.
5934 $content_seen{$var} = 1;
5938 # Mark a variable as examined.
5939 sub examine_variable
5942 &variable_defined ($var);
5945 # Return the set of conditions for which a variable is defined.
5947 # If the variable is not defined conditionally, and is not defined in
5948 # terms of any variables which are defined conditionally, then this
5949 # returns the empty list.
5951 # If the variable is defined conditionally, but is not defined in
5952 # terms of any variables which are defined conditionally, then this
5953 # returns the list of conditions for which the variable is defined.
5955 # If the variable is defined in terms of any variables which are
5956 # defined conditionally, then this returns a full set of permutations
5957 # of the subvariable conditions. For example, if the variable is
5958 # defined in terms of a variable which is defined for COND_TRUE,
5959 # then this returns both COND_TRUE and COND_FALSE. This is
5960 # because we will need to define the variable under both conditions.
5962 sub variable_conditions_recursive ($)
5968 my @new_conds = variable_conditions_recursive_sub ($var, '');
5969 # Now we want to return all permutations of the subvariable
5972 foreach my $item (@new_conds)
5974 foreach (split (' ', $item))
5976 s/^(.*)_(TRUE|FALSE)$/$1_TRUE/;
5980 @new_conds = variable_conditions_permutations (sort keys %allconds);
5983 foreach my $cond (@new_conds)
5985 my $reduce = variable_conditions_reduce (split (' ', $cond));
5987 if $reduce eq 'FALSE';
5988 $uniqify{$cond} = 1;
5991 # Note we cannot just do `return sort keys %uniqify', because this
5992 # function is sometimes used in a scalar context.
5993 my @uniq_list = sort by_condition keys %uniqify;
5998 # variable_conditions ($VAR)
5999 # --------------------------
6000 # Get the list of conditions that a variable is defined with, without
6001 # recursing through the conditions of any subvariables.
6002 # Argument is $VAR: the variable to get the conditions of.
6003 # Returns the list of conditions.
6004 sub variable_conditions ($)
6007 my @conds = keys %{$var_value{$var}};
6008 return sort by_condition @conds;
6013 # &variable_conditionally_defined ($VAR)
6014 # --------------------------------------
6015 sub variable_conditionally_defined ($)
6018 foreach my $cond (variable_conditions_recursive ($var))
6021 unless $cond =~ /^TRUE|FALSE$/;
6028 # &variable_conditions_recursive_sub ($VAR, $PARENT)
6029 # -------------------------------------------------------
6030 # A subroutine of variable_conditions_recursive. This returns all the
6031 # conditions of $VAR, including those of any sub-variables.
6032 sub variable_conditions_recursive_sub
6034 my ($var, $parent) = @_;
6037 if (defined $vars_scanned{$var})
6039 macro_error ($parent, "variable `$var' recursively defined");
6042 $vars_scanned{$var} = 1;
6044 my @this_conds = ();
6045 # Examine every condition under which $VAR is defined.
6046 foreach my $vcond (keys %{$var_value{$var}})
6048 push (@this_conds, $vcond);
6050 # If $VAR references some other variable, then compute the
6051 # conditions for that subvariable.
6052 my @subvar_conds = ();
6053 foreach (split (' ', $var_value{$var}{$vcond}))
6055 # If a comment seen, just leave.
6058 # Handle variable substitutions.
6059 if (/^\$\{(.*)\}$/ || /^\$\((.*)\)$/)
6062 if ($varname =~ /$SUBST_REF_PATTERN/o)
6068 # Here we compute all the conditions under which the
6069 # subvariable is defined. Then we go through and add
6071 my @svc = variable_conditions_recursive_sub ($varname, $var);
6072 foreach my $item (@svc)
6074 my $val = conditional_string ($vcond, split (' ', $item));
6076 push (@subvar_conds, $val);
6081 # If there are no conditional subvariables, then we want to
6082 # return this condition. Otherwise, we want to return the
6083 # permutations of the subvariables, taking into account the
6084 # conditions of $VAR.
6085 if (! @subvar_conds)
6087 push (@new_conds, $vcond);
6091 push (@new_conds, variable_conditions_reduce (@subvar_conds));
6095 # Unset our entry in vars_scanned. We only care about recursive
6097 delete $vars_scanned{$var};
6099 # If we are being called on behalf of another variable, we need to
6100 # return all possible permutations of the conditions. We have
6101 # already handled everything in @this_conds along with their
6102 # subvariables. We now need to add any permutations that are not
6104 foreach my $this_cond (@this_conds)
6107 variable_conditions_permutations (split (' ', $this_cond));
6108 foreach my $perm (@perms)
6111 foreach my $scan (@this_conds)
6113 if (&conditional_true_when ($perm, $scan)
6114 || &conditional_true_when ($scan, $perm))
6122 # This permutation was not already handled, and is valid
6124 push (@new_conds, $perm);
6132 # Filter a list of conditionals so that only the exclusive ones are
6133 # retained. For example, if both `COND1_TRUE COND2_TRUE' and
6134 # `COND1_TRUE' are in the list, discard the latter.
6135 # If the list is empty, return TRUE
6136 sub variable_conditions_reduce
6143 $cond = shift(@conds);
6145 # FALSE is absorbent.
6146 if ($cond eq 'FALSE')
6150 elsif (!conditional_is_redundant ($cond, @ret, @conds))
6156 return "TRUE" if @ret == 0;
6161 # invert_conditions (@CONDS)
6162 # --------------------------
6163 # Invert a list of conditionals. Returns a set of conditionals which
6164 # are never true for any of the input conditionals, and when taken
6165 # together with the input conditionals cover all possible cases.
6167 # For example: invert_conditions("A_TRUE B_TRUE", "A_FALSE B_FALSE") will
6168 # return ("A_FALSE B_TRUE", "A_TRUE B_FALSE")
6169 sub invert_conditions
6174 foreach my $cond (@conds)
6176 foreach my $perm (variable_conditions_permutations (split(' ', $cond)))
6178 push @notconds, $perm
6179 if ! conditional_is_redundant ($perm, @conds);
6182 return variable_conditions_reduce (@notconds);
6185 # Return a list of permutations of a conditional string.
6186 sub variable_conditions_permutations
6191 my $comp = shift (@comps);
6192 return variable_conditions_permutations (@comps)
6194 my $neg = condition_negate ($comp);
6197 foreach my $sub (variable_conditions_permutations (@comps))
6199 push (@ret, "$comp $sub");
6200 push (@ret, "$neg $sub");
6212 # &check_variable_defined_unconditionally($VAR, $PARENT)
6213 # ------------------------------------------------------
6214 # Warn if a variable is conditionally defined. This is called if we
6215 # are using the value of a variable.
6216 sub check_variable_defined_unconditionally ($$)
6218 my ($var, $parent) = @_;
6219 foreach my $cond (keys %{$var_value{$var}})
6222 if $cond =~ /^TRUE|FALSE$/;
6226 macro_error ($parent,
6227 "warning: automake does not support conditional definition of $var in $parent");
6231 macro_error ($parent,
6232 "warning: automake does not support $var being defined conditionally");
6238 # Get the TRUE value of a variable, warn if the variable is
6239 # conditionally defined.
6243 &check_variable_defined_unconditionally ($var);
6244 return $var_value{$var}{'TRUE'};
6249 # &value_to_list ($VAR, $VAL, $COND)
6250 # ----------------------------------
6251 # Convert a variable value to a list, split as whitespace. This will
6252 # recursively follow $(...) and ${...} inclusions. It preserves @...@
6255 # If COND is 'all', then all values under all conditions should be
6256 # returned; if COND is a particular condition (all conditions are
6257 # surrounded by @...@) then only the value for that condition should
6258 # be returned; otherwise, warn if VAR is conditionally defined.
6259 # SCANNED is a global hash listing whose keys are all the variables
6260 # already scanned; it is an error to rescan a variable.
6263 my ($var, $val, $cond) = @_;
6267 $val =~ s/\\(\n|$)/ /g;
6269 foreach (split (' ', $val))
6271 # If a comment seen, just leave.
6274 # Handle variable substitutions.
6275 if (/^\$\{([^}]*)\}$/ || /^\$\(([^)]*)\)$/)
6279 # If the user uses a losing variable name, just ignore it.
6280 # This isn't ideal, but people have requested it.
6281 next if ($varname =~ /\@.*\@/);
6285 if ($varname =~ /$SUBST_REF_PATTERN/o)
6289 ($from = $2) =~ s/(\W)/\\$1/g;
6293 @temp_list = &variable_value_as_list_recursive_worker ($1, $cond, $var);
6295 # Now rewrite the value if appropriate.
6298 grep (s/$from$/$to/, @temp_list);
6301 push (@result, @temp_list);
6313 # variable_value_as_list ($VAR, $COND, $PARENT)
6314 # ---------------------------------------------
6315 # Get the value of a variable given a specified condition. without
6316 # recursing through any subvariables.
6318 # $VAR is the variable
6319 # $COND is the condition. If this is not given, the value for the
6320 # "TRUE" condition will be returned.
6321 # $PARENT is the variable in which the variable is used: this is used
6322 # only for error messages.
6323 # Returns the list of conditions.
6324 # For example, if A is defined as "foo $(B) bar", and B is defined as
6325 # "baz", this will return ("foo", "$(B)", "bar")
6326 sub variable_value_as_list
6328 my ($var, $cond, $parent) = @_;
6332 if (! defined $var_value{$var})
6334 if (defined $targets{$var})
6336 macro_error ($var, "`$var' is a target; expected a variable");
6340 macro_error ($parent, "variable `$var' not defined");
6344 # Get value for given condition
6347 foreach my $vcond (keys %{$var_value{$var}})
6349 my $val = $var_value{$var}{$vcond};
6351 if (&conditional_true_when ($vcond, $cond))
6353 # Unless variable is not defined conditionally, there should only
6354 # be one value of $vcond true when $cond.
6355 &check_variable_defined_unconditionally ($var, $parent)
6360 $val =~ s/\\(\n|$)/ /g;
6362 foreach (split (' ', $val))
6364 # If a comment seen, just leave.
6375 # Return contents of variable as list, split as whitespace. This will
6376 # recursively follow $(...) and ${...} inclusions. It preserves @...@
6377 # substitutions. If COND is 'all', then all values under all
6378 # conditions should be returned; if COND is a particular condition
6379 # (all conditions are surrounded by @...@) then only the value for
6380 # that condition should be returned; otherwise, warn if VAR is
6381 # conditionally defined. If PARENT is specified, it is the name of
6382 # the including variable; this is only used for error reports.
6383 sub variable_value_as_list_recursive_worker
6385 my ($var, $cond, $parent) = @_;
6388 if (! defined $var_value{$var})
6390 if (defined $targets{$var})
6392 macro_error ($var, "`$var' is a target; expected a variable");
6396 macro_error ($parent, "variable `$var' not defined");
6399 elsif (defined $vars_scanned{$var})
6401 # `vars_scanned' is a global we use to keep track of which
6402 # variables we've already examined.
6403 macro_error ($parent, "variable `$var' recursively defined");
6405 elsif ($cond eq 'all')
6407 $vars_scanned{$var} = 1;
6408 foreach my $vcond (keys %{$var_value{$var}})
6410 my $val = $var_value{$var}{$vcond};
6411 push (@result, &value_to_list ($var, $val, $cond));
6417 $vars_scanned{$var} = 1;
6419 foreach my $vcond (keys %{$var_value{$var}})
6421 my $val = $var_value{$var}{$vcond};
6422 if (&conditional_true_when ($vcond, $cond))
6424 # Warn if we have an ambiguity. It's hard to know how
6425 # to handle this case correctly.
6426 &check_variable_defined_unconditionally ($var, $parent)
6429 push (@result, &value_to_list ($var, $val, $cond));
6434 # Unset our entry in vars_scanned. We only care about recursive
6436 delete $vars_scanned{$var};
6442 # &variable_output ($VAR, [@CONDS])
6443 # ---------------------------------
6444 # Output all the values of $VAR is @COND is not specified, else only
6445 # that corresponding to @COND.
6446 sub variable_output ($@)
6448 my ($var, @conds) = @_;
6450 @conds = keys %{$var_value{$var}}
6453 $output_vars .= $var_comment{$var}
6454 if defined $var_comment{$var};
6456 foreach my $cond (sort by_condition @conds)
6458 my $val = $var_value{$var}{$cond};
6459 my $equals = $var_type{$var} eq ':' ? ':=' : '=';
6460 my $output_var = "$var $equals $val";
6461 $output_var =~ s/^/make_condition ($cond)/meg;
6462 $output_vars .= $output_var . "\n";
6467 # &variable_pretty_output ($VAR, [@CONDS])
6468 # ----------------------------------------
6469 # Likewise, but pretty, i.e., we *split* the values at spaces. Use only
6470 # with variables holding filenames.
6471 sub variable_pretty_output ($@)
6473 my ($var, @conds) = @_;
6475 @conds = keys %{$var_value{$var}}
6478 $output_vars .= $var_comment{$var}
6479 if defined $var_comment{$var};
6481 foreach my $cond (sort by_condition @conds)
6483 my $val = $var_value{$var}{$cond};
6484 my $equals = $var_type{$var} eq ':' ? ':=' : '=';
6485 my $make_condition = make_condition ($cond);
6486 $output_vars .= pretty_print_internal ("$make_condition$var $equals",
6487 "$make_condition\t",
6488 split (' ' , $val));
6493 # This is just a wrapper for variable_value_as_list_recursive_worker that
6494 # initializes the global hash `vars_scanned'. This hash is used to
6495 # avoid infinite recursion.
6496 sub variable_value_as_list_recursive
6498 my ($var, $cond, $parent) = @_;
6500 return &variable_value_as_list_recursive_worker ($var, $cond, $parent);
6504 # Like define_variable, but the value is a list, and the variable may
6505 # be defined conditionally. The second argument is the conditional
6506 # under which the value should be defined; this should be the empty
6507 # string to define the variable unconditionally. The third argument
6508 # is a list holding the values to use for the variable. The value is
6509 # pretty printed in the output file.
6510 sub define_pretty_variable
6512 my ($var, $cond, @value) = @_;
6514 # Beware that an empty $cond has a different semantics for
6515 # macro_define and variable_pretty_output.
6518 if (! &variable_defined ($var, $cond))
6520 macro_define ($var, 1, '', $cond, join (' ', @value), undef);
6521 variable_pretty_output ($var, $cond || 'TRUE');
6522 $content_seen{$var} = 1;
6527 # define_variable ($VAR, $VALUE)
6528 # ------------------------------
6529 # Define a new user variable VAR to VALUE, but only if not already defined.
6532 my ($var, $value) = @_;
6534 define_pretty_variable ($var, 'TRUE', $value);
6538 # Like define_variable, but define a variable to be the configure
6539 # substitution by the same name.
6540 sub define_configure_variable
6543 my $value = '@' . $var . '@';
6544 &define_variable ($var, $value);
6548 # define_compiler_variable ($LANG)
6549 # --------------------------------
6550 # Define a compiler variable. We also handle defining the `LT'
6551 # version of the command when using libtool.
6552 sub define_compiler_variable ($)
6556 my ($var, $value) = ($lang->compiler, $lang->compile);
6557 &define_variable ($var, $value);
6558 &define_variable ("LT$var", "\$(LIBTOOL) --mode=compile $value")
6563 # define_linker_variable ($LANG)
6564 # ------------------------------
6565 # Define linker variables.
6566 sub define_linker_variable ($)
6570 my ($var, $value) = ($lang->lder, $lang->ld);
6572 &define_variable ($lang->lder, $lang->ld);
6573 # CCLINK = $(CCLD) blah blah...
6574 &define_variable ($lang->linker,
6575 (($seen_libtool ? '$(LIBTOOL) --mode=link ' : '')
6579 ################################################################
6581 ## ---------------- ##
6582 ## Handling rules. ##
6583 ## ---------------- ##
6586 # rule_define ($TARGET, $IS_AM, $COND, $WHERE)
6587 # --------------------------------------------
6588 # Define a new rule. $TARGET is the rule name. $IS_AM is a boolean
6589 # which is true if the new rule is defined by the user. $COND is the
6590 # condition under which the rule is defined. $WHERE is where the rule
6591 # is defined (file name or line number). Returns true if it is ok to
6592 # define the rule, false otherwise.
6593 sub rule_define ($$$$)
6595 my ($target, $rule_is_am, $cond, $where) = @_;
6597 # For now `foo:' will override `foo$(EXEEXT):'. This is temporary,
6598 # though, so we emit a warning.
6599 (my $noexe = $target) =~ s,\$\(EXEEXT\)$,,;
6600 if ($noexe ne $target && defined $targets{$noexe})
6602 # The no-exeext option enables this feature.
6603 if (! defined $options{'no-exeext'})
6605 macro_error ($noexe,
6606 "deprecated feature: `$noexe' overrides `$noexe\$(EXEEXT)'\nchange your target to read `$noexe\$(EXEEXT)'");
6612 if (defined $targets{$target}
6614 ? ! defined $target_conditional{$target}
6615 : defined $target_conditional{$target}))
6617 target_error ($target,
6618 "$target defined both conditionally and unconditionally");
6621 # Value here doesn't matter; for targets we only note existence.
6622 $targets{$target} = $where;
6625 if ($target_conditional{$target})
6627 &check_ambiguous_conditional ($target, $cond);
6629 $target_conditional{$target}{$cond} = $where;
6633 # Check the rule for being a suffix rule. If so, store in a hash.
6635 if ((my ($source_suffix, $object_suffix)) = ($target =~ $SUFFIX_RULE_PATTERN))
6637 $suffix_rules{$source_suffix} = $object_suffix;
6638 verbose "Sources ending in .$source_suffix become .$object_suffix";
6639 # Set SUFFIXES from suffix_rules.
6640 push @suffixes, ".$source_suffix", ".$object_suffix";
6647 # See if a target exists.
6651 return defined $targets{$target};
6655 ################################################################
6657 # &read_am_file ($AMFILE)
6658 # -----------------------
6659 # Read Makefile.am and set up %contents. Simultaneously copy lines
6660 # from Makefile.am into $output_trailer or $output_vars as
6661 # appropriate. NOTE we put rules in the trailer section. We want
6662 # user rules to come after our generated stuff.
6663 sub read_am_file ($)
6667 my $am_file = new Automake::XFile ("< $amfile");
6668 verbose "reading $amfile";
6674 while ($_ = $am_file->getline)
6676 if (/$IGNORE_PATTERN/o)
6678 # Merely delete comments beginning with two hashes.
6680 elsif (/$WHITE_PATTERN/o)
6682 # Stick a single white line before the incoming macro or rule.
6686 elsif (/$COMMENT_PATTERN/o)
6688 # Stick comments before the incoming macro or rule. Make
6689 # sure a blank line preceeds first block of comments.
6690 $spacing = "\n" unless $blank;
6692 $comment .= $spacing . $_;
6701 $output_vars .= $comment . "\n";
6705 # We save the conditional stack on entry, and then check to make
6706 # sure it is the same on exit. This lets us conditonally include
6708 my @saved_cond_stack = @cond_stack;
6709 my $cond = conditional_string (@cond_stack);
6713 my $last_var_name = '';
6714 my $last_var_type = '';
6715 my $last_var_value = '';
6716 # FIXME: shouldn't use $_ in this loop; it is too big.
6719 my $here = "$amfile:$.";
6722 unless substr ($_, -1, 1) eq "\n";
6724 # Don't look at MAINTAINER_MODE_TRUE here. That shouldn't be
6725 # used by users. @MAINT@ is an anachronism now.
6726 $_ =~ s/\@MAINT\@//g
6727 unless $seen_maint_mode;
6729 my $new_saw_bk = /\\$/ && ! /$COMMENT_PATTERN/o;
6731 if (/$IGNORE_PATTERN/o)
6733 # Merely delete comments beginning with two hashes.
6735 elsif (/$WHITE_PATTERN/o)
6737 # Stick a single white line before the incoming macro or rule.
6739 file_error ($here, "blank line following trailing backslash")
6742 elsif (/$COMMENT_PATTERN/o)
6744 # Stick comments before the incoming macro or rule.
6745 $comment .= $spacing . $_;
6747 file_error ($here, "comment following trailing backslash")
6754 $output_trailer .= &make_condition (@cond_stack);
6755 $output_trailer .= $_;
6759 $last_var_value .= ' '
6760 unless $last_var_value =~ /\s$/;
6761 $last_var_value .= $_;
6765 $var_comment{$last_var_name} .= "$spacing"
6766 if (!defined $var_comment{$last_var_name}
6767 || substr ($var_comment{$last_var_name}, -1) ne "\n");
6768 $var_comment{$last_var_name} .= "$comment";
6769 $comment = $spacing = '';
6770 macro_define ($last_var_name, 0,
6771 $last_var_type, $cond,
6772 $last_var_value, $here)
6773 if $cond ne 'FALSE';
6774 push (@var_list, $last_var_name);
6779 elsif (/$IF_PATTERN/o)
6781 $cond = cond_stack_if ($1, $2, $here);
6783 elsif (/$ELSE_PATTERN/o)
6785 $cond = cond_stack_else ($1, $2, $here);
6787 elsif (/$ENDIF_PATTERN/o)
6789 $cond = cond_stack_endif ($1, $2, $here);
6792 elsif (/$RULE_PATTERN/o)
6797 rule_define ($1, 0, $cond, $here);
6799 $output_trailer .= $comment . $spacing;
6800 $output_trailer .= &make_condition (@cond_stack);
6801 $output_trailer .= $_;
6802 $comment = $spacing = '';
6804 elsif (/$ASSIGNMENT_PATTERN/o)
6806 # Found a macro definition.
6808 $last_var_name = $1;
6809 $last_var_type = $2;
6810 $last_var_value = $3;
6811 if ($3 ne '' && substr ($3, -1) eq "\\")
6813 # We preserve the `\' because otherwise the long lines
6814 # that are generated will be truncated by broken
6816 $last_var_value = $3 . "\n";
6821 # FIXME: this doesn't always work correctly; it will
6822 # group all comments for a given variable, no matter
6824 # Accumulating variables must not be output.
6825 $var_comment{$last_var_name} .= "$spacing"
6826 if (!defined $var_comment{$last_var_name}
6827 || substr ($var_comment{$last_var_name}, -1) ne "\n");
6828 $var_comment{$last_var_name} .= "$comment";
6829 $comment = $spacing = '';
6831 macro_define ($last_var_name, 0,
6832 $last_var_type, $cond,
6833 $last_var_value, $here)
6834 if $cond ne 'FALSE';
6835 push (@var_list, $last_var_name);
6838 elsif (/$INCLUDE_PATTERN/o)
6842 if ($path =~ s/^\$\(top_srcdir\)\///)
6844 push (@include_stack, "\$\(top_srcdir\)/$path");
6848 $path =~ s/\$\(srcdir\)\///;
6849 push (@include_stack, "\$\(srcdir\)/$path");
6850 $path = $relative_dir . "/" . $path;
6852 &read_am_file ($path);
6856 # This isn't an error; it is probably a continued rule.
6857 # In fact, this is what we assume.
6859 $output_trailer .= $comment . $spacing;
6860 $output_trailer .= &make_condition (@cond_stack);
6861 $output_trailer .= $_;
6862 $comment = $spacing = '';
6863 file_error ($here, "`#' comment at start of rule is unportable")
6864 if $_ =~ /^\t\s*\#/;
6867 $saw_bk = $new_saw_bk;
6868 $_ = $am_file->getline;
6871 $output_trailer .= $comment;
6873 if (join (' ', @saved_cond_stack) ne join (' ', @cond_stack))
6877 &am_error ("unterminated conditionals: @cond_stack");
6881 # FIXME: better error message here.
6882 &am_error ("conditionals not nested in include file");
6888 # define_standard_variables ()
6889 # ----------------------------
6890 # A helper for read_main_am_file which initializes configure variables
6891 # and variables from header-vars.am. This is a subr so we can call it
6893 sub define_standard_variables
6895 my $saved_output_vars = $output_vars;
6896 my ($comments, undef, $rules) =
6897 file_contents_internal (1, "$libdir/am/header-vars.am");
6899 # This will output the definitions in $output_vars, which we don't
6901 foreach my $var (sort keys %configure_vars)
6903 &define_configure_variable ($var);
6904 push (@var_list, $var);
6907 # ... hence, we restore $output_vars.
6908 $output_vars = $saved_output_vars . $comments . $rules;
6911 # Read main am file.
6912 sub read_main_am_file
6916 # This supports the strange variable tricks we are about to play.
6917 if (scalar keys %var_value > 0)
6920 &prog_error ("variable defined before read_main_am_file");
6923 # Generate copyright header for generated Makefile.in.
6924 # We do discard the output of predefined variables, handled below.
6925 $output_vars = ("# $in_file_name generated by automake "
6926 . $VERSION . " from $am_file_name.\n");
6927 $output_vars .= '# ' . subst ('configure_input') . "\n";
6928 $output_vars .= $gen_copyright;
6930 # We want to predefine as many variables as possible. This lets
6931 # the user set them with `+=' in Makefile.am. However, we don't
6932 # want these initial definitions to end up in the output quite
6933 # yet. So we just load them, but output them later.
6934 &define_standard_variables;
6936 # Read user file, which might override some of our values.
6937 &read_am_file ($amfile);
6939 # Ouput all the Automake variables. If the user changed one, then
6940 # it is now marked as owned by the user.
6941 foreach my $var (uniq @var_list)
6943 # Don't process user variables.
6944 variable_output ($var)
6945 unless !$var_is_am{$var};
6948 # Now dump the user variables that were defined. We do it in the same
6949 # order in which they were defined (skipping duplicates).
6950 foreach my $var (uniq @var_list)
6952 # Don't process Automake variables.
6953 variable_output ($var)
6954 unless $var_is_am{$var};
6958 ################################################################
6961 # &flatten ($STRING)
6962 # ------------------
6963 # Flatten the $STRING and return the result.
6978 # &make_paragraphs ($MAKEFILE, [%TRANSFORM])
6979 # ------------------------------------------
6980 # Load a $MAKEFILE, apply the %TRANSFORM, and return it as a list of
6982 sub make_paragraphs ($%)
6984 my ($file, %transform) = @_;
6986 # Complete %transform with global options and make it a Perl
6989 "s/$IGNORE_PATTERN//gm;"
6990 . transform (%transform,
6992 'CYGNUS' => $cygnus_mode,
6994 => $seen_maint_mode ? subst ('MAINTAINER_MODE_TRUE') : '',
6996 'SHAR' => $options{'dist-shar'} || 0,
6997 'BZIP2' => $options{'dist-bzip2'} || 0,
6998 'ZIP' => $options{'dist-zip'} || 0,
6999 'COMPRESS' => $options{'dist-tarZ'} || 0,
7001 'INSTALL-INFO' => !$options{'no-installinfo'},
7002 'INSTALL-MAN' => !$options{'no-installman'},
7003 'CK-NEWS' => $options{'check-news'} || 0,
7005 'SUBDIRS' => &variable_defined ('SUBDIRS'),
7006 'TOPDIR' => backname ($relative_dir),
7007 'TOPDIR_P' => $relative_dir eq '.',
7008 'CONFIGURE-AC' => $configure_ac,
7010 'BUILD' => $seen_canonical == $AC_CANONICAL_SYSTEM,
7011 'HOST' => $seen_canonical,
7012 'TARGET' => $seen_canonical == $AC_CANONICAL_SYSTEM,
7014 'LIBTOOL' => defined $configure_vars{'LIBTOOL'})
7015 # We don't need more than two consecutive new-lines.
7016 . 's/\n{3,}/\n\n/g';
7018 # Swallow the file and apply the COMMAND.
7019 my $fc_file = new Automake::XFile "< $file";
7021 verbose "reading $file";
7022 my $saved_dollar_slash = $/;
7024 $_ = $fc_file->getline;
7025 $/ = $saved_dollar_slash;
7030 # Split at unescaped new lines.
7031 my @lines = split (/(?<!\\)\n/, $content);
7034 while (defined ($_ = shift @lines))
7036 my $paragraph = "$_";
7037 # If we are a rule, eat as long as we start with a tab.
7038 if (/$RULE_PATTERN/smo)
7040 while (defined ($_ = shift @lines) && $_ =~ /^\t/)
7042 $paragraph .= "\n$_";
7044 unshift (@lines, $_);
7047 # If we are a comments, eat as much comments as you can.
7048 elsif (/$COMMENT_PATTERN/smo)
7050 while (defined ($_ = shift @lines)
7051 && $_ =~ /$COMMENT_PATTERN/smo)
7053 $paragraph .= "\n$_";
7055 unshift (@lines, $_);
7058 push @res, $paragraph;
7067 # ($COMMENT, $VARIABLES, $RULES)
7068 # &file_contents_internal ($IS_AM, $FILE, [%TRANSFORM])
7069 # -----------------------------------------------------
7070 # Return contents of a file from $libdir/am, automatically skipping
7071 # macros or rules which are already known. $IS_AM iff the caller is
7072 # reading an Automake file (as opposed to the user's Makefile.am).
7073 sub file_contents_internal ($$%)
7075 my ($is_am, $file, %transform) = @_;
7077 my $result_vars = '';
7078 my $result_rules = '';
7082 # We save the conditional stack on entry, and then check to make
7083 # sure it is the same on exit. This lets us conditonally include
7085 my @saved_cond_stack = @cond_stack;
7086 my $cond = conditional_string (@cond_stack);
7088 foreach (make_paragraphs ($file, %transform))
7091 file_error ($file, "blank line following trailing backslash:\n$_")
7093 file_error ($file, "comment following trailing backslash:\n$_")
7098 # Stick empty line before the incoming macro or rule.
7101 elsif (/$COMMENT_PATTERN/mso)
7103 # Stick comments before the incoming macro or rule.
7107 # Handle inclusion of other files.
7108 elsif (/$INCLUDE_PATTERN/o)
7110 if ($cond ne 'FALSE')
7112 my $file = ($is_am ? "$libdir/am/" : '') . $1;
7114 my ($com, $vars, $rules)
7115 = file_contents_internal ($is_am, $file, %transform);
7117 $result_vars .= $vars;
7118 $result_rules .= $rules;
7122 # Handling the conditionals.
7123 elsif (/$IF_PATTERN/o)
7125 $cond = cond_stack_if ($1, $2, $file);
7127 elsif (/$ELSE_PATTERN/o)
7129 $cond = cond_stack_else ($1, $2, $file);
7131 elsif (/$ENDIF_PATTERN/o)
7133 $cond = cond_stack_endif ($1, $2, $file);
7137 elsif (/$RULE_PATTERN/mso)
7139 # Separate relationship from optional actions: the first
7140 # `new-line tab" not preceded by backslash (continuation
7142 # I'm quite shoked! It seems that (\\\n|[^\n]) is not the
7143 # same as `([^\n]|\\\n)!!! Don't swap it, it breaks.
7145 /^((?:\\\n|[^\n])*)(?:\n(\t.*))?$/som;
7146 my ($relationship, $actions) = ($1, $2 || '');
7148 # Separate targets from dependencies: the first colon.
7149 $relationship =~ /^([^:]+\S+) *: *(.*)$/som;
7150 my ($targets, $dependencies) = ($1, $2);
7151 # Remove the escaped new lines.
7152 # I don't know why, but I have to use a tmp $flat_deps.
7153 my $flat_deps = &flatten ($dependencies);
7154 my @deps = split (' ', $flat_deps);
7156 foreach (split (' ' , $targets))
7158 # FIXME: We are not robust to people defining several targets
7159 # at once, only some of them being in %dependencies.
7161 # Output only if not in FALSE.
7162 if (defined $dependencies{$_}
7163 && $cond ne 'FALSE')
7165 &depend ($_, @deps);
7166 $actions{$_} .= $actions;
7170 # Free-lance dependency. Output the rule for all the
7171 # targets instead of one by one.
7173 # Work out all the conditions for which the target hasn't
7175 my @undefined_conds;
7176 if (defined $target_conditional{$targets})
7178 my @defined_conds = keys %{$target_conditional{$targets}};
7179 @undefined_conds = invert_conditions(@defined_conds);
7183 if (defined $targets{$targets})
7185 # No conditions for which target hasn't been defined
7186 @undefined_conds = ();
7190 # Target hasn't been defined for any conditions
7191 @undefined_conds = ("");
7195 if ($cond ne 'FALSE')
7198 for $undefined_cond (@undefined_conds)
7200 my $condparagraph = $paragraph;
7201 $condparagraph =~ s/^/make_condition (@cond_stack, $undefined_cond)/gme;
7202 $result_rules .= "$spacing$comment$condparagraph\n"
7203 if rule_define ($targets, $is_am,
7204 "$cond $undefined_cond", $file);
7207 $comment = $spacing = '';
7213 elsif (/$ASSIGNMENT_PATTERN/mso)
7215 my ($var, $type, $val) = ($1, $2, $3);
7216 file_error ($file, "macro `$var' with trailing backslash")
7219 # Accumulating variables must not be output.
7220 $var_comment{$var} .= "$spacing"
7221 if (!defined $var_comment{$var}
7222 || substr ($var_comment{$var}, -1) ne "\n");
7223 $var_comment{$var} .= "$comment";
7224 macro_define ($var, $is_am, $type, $cond, $val, $file)
7225 if $cond ne 'FALSE';
7226 push (@var_list, $var);
7228 # If the user has set some variables we were in charge
7229 # of (which is detected by the first reading of
7230 # `header-vars.am'), we must not output them.
7231 $result_vars .= "$spacing$comment$_\n"
7232 if $type ne '+' && $var_is_am{$var} && $cond ne 'FALSE';
7234 $comment = $spacing = '';
7238 # This isn't an error; it is probably some tokens which
7239 # configure is supposed to replace, such as `@SET-MAKE@',
7240 # or some part of a rule cut by an if/endif.
7241 if ($cond ne 'FALSE')
7243 s/^/make_condition (@cond_stack)/gme;
7244 $result_rules .= "$spacing$comment$_\n";
7246 $comment = $spacing = '';
7250 if (join (' ', @saved_cond_stack) ne join (' ', @cond_stack))
7254 &am_error ("unterminated conditionals: @cond_stack");
7258 # FIXME: better error message here.
7259 &am_error ("conditionals not nested in include file");
7263 return ($comment, $result_vars, $result_rules);
7268 # &file_contents ($BASENAME, [%TRANSFORM])
7269 # ----------------------------------------
7270 # Return contents of a file from $libdir/am, automatically skipping
7271 # macros or rules which are already known.
7272 sub file_contents ($%)
7274 my ($basename, %transform) = @_;
7275 my ($comments, $variables, $rules) =
7276 file_contents_internal (1, "$libdir/am/$basename.am", %transform);
7277 return "$comments$variables$rules";
7282 # &transform (%PAIRS)
7283 # -------------------
7284 # Foreach ($TOKEN, $VAL) in %PAIRS produce a replacement expression suitable
7285 # for file_contents which:
7286 # - replaces @$TOKEN@ with $VALUE,
7287 # - enables/disables ?$TOKEN?.
7293 while (my ($token, $val) = each %pairs)
7295 $result .= "s/\Q%$token%\E/\Q$val\E/gm;";
7298 $result .= "s/\Q?$token?\E//gm;s/^.*\Q?!$token?\E.*\\n//gm;";
7299 $result .= "s/\Q%?$token%\E/TRUE/gm;";
7303 $result .= "s/\Q?!$token?\E//gm;s/^.*\Q?$token?\E.*\\n//gm;";
7304 $result .= "s/\Q%?$token%\E/FALSE/gm;";
7312 # Find all variable prefixes that are used for install directories. A
7313 # prefix `zar' qualifies iff:
7314 # * `zardir' is a variable.
7315 # * `zar_PRIMARY' is a variable.
7316 sub am_primary_prefixes
7318 my ($primary, $can_dist, @prefixes) = @_;
7320 my %valid = map { $_ => 0 } @prefixes;
7321 $valid{'EXTRA'} = 0;
7322 foreach my $varname (keys %var_value)
7324 # Automake is allowed to define variables that look like they
7325 # are magic variables, such as INSTALL_DATA.
7327 if $var_is_am{$varname};
7329 if ($varname =~ /^(nobase_)?(dist_|nodist_)?(.*)_$primary$/)
7331 my ($base, $dist, $X) = ($1 || '', $2 || '', $3 || '');
7332 if ($dist ne '' && ! $can_dist)
7334 # Note that a configure variable is always legitimate.
7335 # It is natural to name such variables after the
7336 # primary, so we explicitly allow it.
7337 if (! defined $configure_vars{$varname})
7339 line_error ($varname,
7340 "invalid variable `$varname': `dist' is forbidden");
7343 elsif (! defined $valid{$X} && ! &variable_defined ("${X}dir"))
7345 # Note that a configure variable is always legitimate.
7346 # It is natural to name such variables after the
7347 # primary, so we explicitly allow it.
7348 if (! defined $configure_vars{$varname})
7350 line_error ($varname,
7351 "invalid variable `$varname'");
7356 # Ensure all extended prefixes are actually used.
7357 $valid{"$base$dist$X"} = 1;
7365 # Handle `where_HOW' variable magic. Does all lookups, generates
7366 # install code, and possibly generates code to define the primary
7367 # variable. The first argument is the name of the .am file to munge,
7368 # the second argument is the primary variable (eg HEADERS), and all
7369 # subsequent arguments are possible installation locations. Returns
7370 # list of all values of all _HOW targets.
7372 # FIXME: this should be rewritten to be cleaner. It should be broken
7373 # up into multiple functions.
7375 # Usage is: am_install_var (OPTION..., file, HOW, where...)
7382 my $default_dist = 0;
7385 if ($args[0] eq '-noextra')
7389 elsif ($args[0] eq '-candist')
7393 elsif ($args[0] eq '-defaultdist')
7398 elsif ($args[0] !~ /^-/)
7405 my ($file, $primary, @prefixes) = @args;
7407 # Now that configure substitutions are allowed in where_HOW
7408 # variables, it is an error to actually define the primary. We
7409 # allow `JAVA', as it is customarily used to mean the Java
7410 # interpreter. This is but one of several Java hacks. Similarly,
7411 # `PYTHON' is customarily used to mean the Python interpreter.
7412 macro_error ($primary, "`$primary' is an anachronism")
7413 if &variable_defined ($primary)
7414 && ($primary ne 'JAVA' && $primary ne 'PYTHON');
7417 # Look for misspellings. It is an error to have a variable ending
7418 # in a "reserved" suffix whose prefix is unknown, eg
7419 # "bni_PROGRAMS". However, unusual prefixes are allowed if a
7420 # variable of the same name (with "dir" appended) exists. For
7421 # instance, if the variable "zardir" is defined, then
7422 # "zar_PROGRAMS" becomes valid. This is to provide a little extra
7423 # flexibility in those cases which need it.
7424 my %valid = &am_primary_prefixes ($primary, $can_dist, @prefixes);
7426 # If a primary includes a configure substitution, then the EXTRA_
7427 # form is required. Otherwise we can't properly do our job.
7429 my $warned_about_extra = 0;
7434 # True if the iteration is the first one. Used for instance to
7435 # output parts of the associated file only once.
7437 foreach my $X (sort keys %valid)
7439 my $nodir_name = $X;
7440 my $one_name = $X . '_' . $primary;
7442 unless (&variable_defined ($one_name));
7444 my $strip_subdir = 1;
7445 # If subdir prefix should be preserved, do so.
7446 if ($nodir_name =~ /^nobase_/)
7449 $nodir_name =~ s/^nobase_//;
7452 # If files should be distributed, do so.
7456 $dist_p = (($default_dist && $nodir_name !~ /^nodist_/)
7457 || (! $default_dist && $nodir_name =~ /^dist_/));
7458 $nodir_name =~ s/^(dist|nodist)_//;
7461 # Append actual contents of where_PRIMARY variable to
7463 foreach my $rcurs (&variable_value_as_list_recursive ($one_name, 'all'))
7465 # Skip configure substitutions. Possibly bogus.
7466 if ($rcurs =~ /^\@.*\@$/)
7468 if ($nodir_name eq 'EXTRA')
7470 if (! $warned_about_extra)
7472 $warned_about_extra = 1;
7473 macro_error ($one_name,
7474 "`$one_name' contains configure substitution, but shouldn't");
7477 # Check here to make sure variables defined in
7478 # configure.ac do not imply that EXTRA_PRIMARY
7480 elsif (! defined $configure_vars{$one_name})
7482 $require_extra = $one_name
7489 push (@result, $rcurs);
7492 # A blatant hack: we rewrite each _PROGRAMS primary to include
7494 if ($primary eq 'PROGRAMS')
7496 my @conds = variable_conditions_recursive ($one_name);
7499 foreach my $cond (@conds)
7501 my @one_binlist = ();
7502 my @condval = &variable_value_as_list_recursive ($one_name,
7504 foreach my $rcurs (@condval)
7506 # Skip autoconf substs. Also skip if the user
7507 # already applied $(EXEEXT).
7508 if ($rcurs =~ /^\@.*\@$/ || $rcurs =~ /\$\(EXEEXT\)$/)
7510 push (@one_binlist, $rcurs);
7514 push (@one_binlist, $rcurs . '$(EXEEXT)');
7518 push (@condvals, $cond);
7519 push (@condvals, join (' ', @one_binlist));
7522 variable_delete ($one_name);
7525 my $cond = shift (@condvals);
7526 my @val = split (' ', shift (@condvals));
7527 define_pretty_variable ($one_name, $cond, @val);
7531 # "EXTRA" shouldn't be used when generating clean targets,
7532 # all, or install targets.
7533 if ($nodir_name eq 'EXTRA')
7535 # We used to warn if EXTRA_FOO was defined uselessly,
7536 # but this was annoying.
7540 if ($nodir_name eq 'check')
7542 push (@check, '$(' . $one_name . ')');
7546 push (@used, '$(' . $one_name . ')');
7549 # Is this to be installed?
7550 my $install_p = $nodir_name ne 'noinst' && $nodir_name ne 'check';
7552 # If so, with install-exec? (or install-data?).
7553 my $exec_p = (defined $exec_dir_p {$nodir_name}
7554 ? $exec_dir_p {$nodir_name}
7555 : ($nodir_name =~ /exec/));
7557 # Singular form of $PRIMARY.
7558 (my $one_primary = $primary) =~ s/S$//;
7559 $output_rules .= &file_contents ($file,
7562 'PRIMARY' => $primary,
7563 'ONE_PRIMARY' => $one_primary,
7565 'NDIR' => $nodir_name,
7566 'BASE' => $strip_subdir,
7569 'INSTALL' => $install_p,
7570 'DIST' => $dist_p));
7575 # The JAVA variable is used as the name of the Java interpreter.
7576 # The PYTHON variable is used as the name of the Python interpreter.
7577 if (@used && $primary ne 'JAVA' && $primary ne 'PYTHON')
7580 define_pretty_variable ($primary, '', @used);
7581 $output_vars .= "\n";
7584 if ($require_extra && ! &variable_defined ('EXTRA_' . $primary))
7586 macro_error ($require_extra,
7587 "`$require_extra' contains configure substitution, but `EXTRA_$primary' not defined");
7590 # Push here because PRIMARY might be configure time determined.
7591 push (@all, '$(' . $primary . ')')
7592 if @used && $primary ne 'JAVA' && $primary ne 'PYTHON';
7594 # Make the result unique. This lets the user use conditionals in
7595 # a natural way, but still lets us program lazily -- we don't have
7596 # to worry about handling a particular object more than once.
7597 return uniq (sort @result);
7601 ################################################################
7603 # Each key in this hash is the name of a directory holding a
7604 # Makefile.in. These variables are local to `is_make_dir'.
7606 my $make_dirs_set = 0;
7611 if (! $make_dirs_set)
7613 foreach my $iter (@configure_input_files)
7615 $make_dirs{dirname ($iter)} = 1;
7617 # We also want to notice Makefile.in's.
7618 foreach my $iter (@other_input_files)
7620 if ($iter =~ /Makefile\.in$/)
7622 $make_dirs{dirname ($iter)} = 1;
7627 return defined $make_dirs{$dir};
7630 ################################################################
7632 # This variable is local to the "require file" set of functions.
7633 my @require_file_paths = ();
7635 # If a file name appears as a key in this hash, then it has already
7636 # been checked for. This variable is local to the "require file"
7638 %require_file_found = ();
7640 # See if we want to push this file onto dist_common. This function
7641 # encodes the rules for deciding when to do so.
7642 sub maybe_push_required_file
7644 my ($dir, $file, $fullfile) = @_;
7646 if ($dir eq $relative_dir)
7648 &push_dist_common ($file);
7650 elsif ($relative_dir eq '.' && ! &is_make_dir ($dir))
7652 # If we are doing the topmost directory, and the file is in a
7653 # subdir which does not have a Makefile, then we distribute it
7655 &push_dist_common ($fullfile);
7660 # &require_file_internal ($WHERE, $MYSTRICT, @FILES)
7661 # --------------------------------------------------
7662 # Verify that the file must exist in the current directory.
7663 # $MYSTRICT is the strictness level at which this file becomes required.
7665 # Must set require_file_paths before calling this function.
7666 # require_file_paths is set to hold a single directory (the one in
7667 # which the first file was found) before return.
7668 sub require_file_internal ($$@)
7670 my ($where, $mystrict, @files) = @_;
7672 foreach my $file (@files)
7680 my $dangling_sym = 0;
7681 foreach my $dir (@require_file_paths)
7683 $fullfile = $dir . "/" . $file;
7684 $errdir = $dir unless $errdir;
7686 # Use different name for "error filename". Otherwise on
7687 # an error the bad file will be reported as eg
7688 # `../../install-sh' when using the default
7690 $errfile = $errdir . '/' . $file;
7692 if (-l $fullfile && ! -f $fullfile)
7697 elsif (-f $fullfile)
7700 &maybe_push_required_file ($dir, $file, $fullfile);
7706 # `--force-missing' only has an effect if `--add-missing' is
7708 if ($found_it && (! $add_missing || ! $force_missing))
7710 # Prune the path list.
7711 @require_file_paths = $save_dir;
7715 # If we've already looked for it, we're done. You might
7716 # wonder why we don't do this before searching for the
7717 # file. If we do that, then something like
7718 # AC_OUTPUT(subdir/foo foo) will fail to put foo.in into
7722 next if defined $require_file_found{$file};
7723 $require_file_found{$file} = 1;
7726 if ($strictness >= $mystrict)
7728 if ($dangling_sym && $add_missing)
7736 # Only install missing files according to our desired
7738 my $message = "required file `$errfile' not found";
7743 # Maybe run libtoolize.
7744 my @syslist = ('libtoolize', '--automake');
7745 push @syslist, '--copy'
7748 && grep ($_ eq $file, @libtoolize_files)
7749 && system (@syslist))
7751 $message = "installing `$errfile'";
7753 $trailer = "; cannot run `libtoolize': $!";
7755 elsif (-f ("$libdir/$file"))
7757 # Install the missing file. Symlink if we
7758 # can, copy if we must. Note: delete the file
7759 # first, in case it is a dangling symlink.
7760 $message = "installing `$errfile'";
7761 # Windows Perl will hang if we try to delete a
7762 # file that doesn't exist.
7763 unlink ($errfile) if -f $errfile;
7764 if ($symlink_exists && ! $copy_missing)
7766 if (! symlink ("$libdir/$file", $errfile))
7769 $trailer = "; error while making link: $!";
7772 elsif (system ('cp', "$libdir/$file", $errfile))
7775 $trailer = "\n error while copying";
7779 &maybe_push_required_file (dirname ($errfile),
7782 # Prune the path list.
7783 @require_file_paths = &dirname ($errfile);
7786 # If --force-missing was specified, and we have
7787 # actually found the file, then do nothing.
7789 if $found_it && $force_missing;
7793 file_warning ($where, "$message$trailer");
7797 file_error ($where, "$message$trailer");
7804 # &require_file ($WHERE, $MYSTRICT, @FILES)
7805 # -----------------------------------------
7806 sub require_file ($$@)
7808 my ($where, $mystrict, @files) = @_;
7809 @require_file_paths = $relative_dir;
7810 require_file_internal ($where, $mystrict, @files);
7813 # &require_file_with_macro ($MACRO, $MYSTRICT, @FILES)
7814 # ----------------------------------------------------
7815 sub require_file_with_macro ($$@)
7817 my ($macro, $mystrict, @files) = @_;
7818 require_file ($var_location{$macro}, $mystrict, @files);
7822 # &require_conf_file ($WHERE, $MYSTRICT, @FILES)
7823 # ----------------------------------------------
7824 # Looks in configuration path, as specified by AC_CONFIG_AUX_DIR.
7825 sub require_conf_file ($$@)
7827 my ($where, $mystrict, @files) = @_;
7828 @require_file_paths = @config_aux_path;
7829 require_file_internal ($where, $mystrict, @files);
7830 my $dir = $require_file_paths[0];
7831 @config_aux_path = @require_file_paths;
7832 # Avoid unsightly '/.'s.
7833 $config_aux_dir = '$(top_srcdir)' . ($dir eq '.' ? "" : "/$dir");
7837 # &require_config_file ($MYSTRICT, @FILES)
7838 # ----------------------------------------
7839 # Require a file that is also required by Autoconf. Looks in
7840 # configuration path, as specified by AC_CONFIG_AUX_DIR.
7841 sub require_config_file ($@)
7843 my ($mystrict, @files) = @_;
7844 require_conf_file ($configure_ac, $mystrict, @files);
7847 # &require_conf_file_with_macro ($MACRO, $MYSTRICT, @FILES)
7848 # ---------------------------------------------------------
7849 sub require_conf_file_with_macro ($$@)
7851 my ($macro, $mystrict, @files) = @_;
7852 require_conf_file ($var_location{$macro}, $mystrict, @files);
7855 ################################################################
7857 # &require_build_directory ($DIRECTORY)
7858 # ------------------------------------
7859 # Emit rules to create $DIRECTORY if needed, and return
7860 # the file that any target requiring this directory should be made
7862 sub require_build_directory ($)
7864 my $directory = shift;
7865 my $dirstamp = "$directory/.dirstamp";
7867 # Don't emit the rule twice.
7868 if (! defined $directory_map{$directory})
7870 $directory_map{$directory} = 1;
7872 # Directory must be removed by `make distclean'.
7873 $compile_clean_files{$dirstamp} = $DIST_CLEAN;
7875 $output_rules .= ("$dirstamp:\n"
7876 . "\t\@\$(mkinstalldirs) $directory\n"
7877 . "\t\@: > $dirstamp\n");
7883 # &require_build_directory_maybe ($FILE)
7884 # --------------------------------------
7885 # If $FILE lies in a subdirectory, emit a rule to create this
7886 # directory and return the file that $FILE should be made
7887 # dependent upon. Otherwise, just return the empty string.
7888 sub require_build_directory_maybe ($)
7891 my $directory = dirname ($file);
7893 if ($directory ne '.')
7895 return &require_build_directory ($directory);
7903 ################################################################
7905 # Push a list of files onto dist_common.
7906 sub push_dist_common
7908 &prog_error ("push_dist_common run after handle_dist")
7909 if $handle_dist_run;
7910 macro_define ('DIST_COMMON', 1, '+', '', join (' ', @_), '');
7917 $strictness_name = $_[0];
7918 if ($strictness_name eq 'gnu')
7922 elsif ($strictness_name eq 'gnits')
7924 $strictness = $GNITS;
7926 elsif ($strictness_name eq 'foreign')
7928 $strictness = $FOREIGN;
7932 die "$me: level `$strictness_name' not recognized\n";
7937 ################################################################
7939 # Ensure a file exists.
7945 my $touch = new IO::File (">> $file");
7949 # Glob something. Do this to avoid indentation screwups everywhere we
7950 # want to glob. Gross!
7957 # Remove one level of brackets and strip leading spaces,
7958 # as does m4 to function arguments.
7964 my @letters = split //;
7973 next if $depth == 1;
7978 next if $depth == 0;
7979 # don't count orphan right brackets
7980 $depth = 0 if $depth < 0;
7984 return join '', @result;
7987 ################################################################
7989 # print_error ($LEADER, @ARGS)
7990 # -------------------------------
7991 # Do the work of printing the error message. Join @ARGS with spaces,
7992 # then split at newlines and add $LEADER to each line. Uses `warn' to
7993 # print message. Set exit status.
7996 my ($leader, @args) = @_;
7997 my $text = join (' ', @args);
7998 @args = split ("\n", $text);
7999 $text = $leader . join ("\n" . $leader, @args) . "\n";
8005 # Print an error message and set exit status.
8008 print_error ("$me: ${am_file}.am: ", @_);
8012 # &file_error ($FILE, @ARGS)
8013 # --------------------------
8016 my ($file, @args) = @_;
8017 print_error ("$file: ", @args);
8021 # ¯o_error ($MACRO, @ARGS)
8022 # ----------------------------
8023 # Report an error, @ARGS, about $MACRO.
8024 sub macro_error ($@)
8026 my ($macro, @args) = @_;
8027 file_error ($var_location{$macro}, @args);
8031 # &target_error ($TARGET, @ARGS)
8032 # ------------------------------
8033 # Report an error, @ARGS, about the rule $TARGET.
8034 sub target_error ($@)
8036 my ($target, @args) = @_;
8037 file_error ($targets{$target}, @args);
8041 # &line_error ($SYMBOL or $LINE, @ARGS)
8042 # -------------------------------------
8043 # Report an error about $SYMBOL. The error message is composed of the
8044 # @ARGS, and try to find the location of the error of $SYMBOL.
8047 my ($symbol, @args) = @_;
8049 if ($symbol && "$symbol" ne '-1')
8051 if ($symbol =~ /^\d+$/)
8053 # SYMBOL is a line number, then it must be a Makefile.am.
8054 file_error ("${am_file}.am:$symbol", @args);
8056 elsif (defined $configure_vars{$symbol})
8058 # SYMBOL is a variable defined in configure.ac, so add the
8059 # appropriate line number.
8060 file_error ($configure_vars{$symbol}, @args);
8062 elsif (defined $var_location{$symbol})
8064 croak "use macro_error for macro: $symbol\n";
8066 elsif (defined $targets{$symbol})
8068 croak "use target_error for macros: $symbol\n";
8072 # Couldn't find the line number.
8073 file_error ("${am_file}.am", @args);
8082 # Like am_error, but while scanning configure.ac.
8085 # FIXME: can run in subdirs.
8086 print_error ("$me: $configure_ac: ", @_);
8089 # &file_warning ($FILE, @ARGS)
8090 # ----------------------------
8091 # Warning message with line number referring to configure.ac.
8092 # Does not affect exit_status
8093 sub file_warning ($@)
8095 my ($file, @args) = @_;
8097 my $saved_exit_status = $exit_status;
8098 my $sig = $SIG{'__WARN__'};
8099 $SIG{'__WARN__'} = 'DEFAULT';
8100 file_error ($file, @args);
8101 $exit_status = $saved_exit_status;
8102 $SIG{'__WARN__'} = $sig;
8105 # Tell user where our aclocal.m4 is, but only once.
8106 sub keyed_aclocal_warning ($)
8109 warn "$me: macro `$key' can be generated by `aclocal'\n";
8112 # Print usage information.
8116 Usage: $0 [OPTION] ... [Makefile]...
8118 Generate Makefile.in for configure from Makefile.am.
8121 --help print this help, then exit
8122 --version print version number, then exit
8123 -v, --verbose verbosely list files processed
8124 -o, --output-dir=DIR put generated Makefile.in's into DIR
8125 --no-force only update Makefile.in's that are out of date
8127 Dependency tracking:
8128 -i, --ignore-deps disable dependency tracking code
8129 --include-deps enable dependency tracking code
8132 --cygnus assume program is part of Cygnus-style tree
8133 --foreign set strictness to foreign
8134 --gnits set strictness to gnits
8135 --gnu set strictness to gnu
8138 -a, --add-missing add missing standard files to package
8139 --libdir=DIR directory storing library files
8140 -c, --copy with -a, copy missing files (default is symlink)
8141 -f, --force-missing force update of standard files
8146 foreach my $iter (sort ((@common_files, @common_sometimes)))
8148 push (@lcomm, $iter) unless $iter eq $last;
8153 print "\nFiles which are automatically distributed, if found:\n";
8154 format USAGE_FORMAT =
8155 @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<
8156 $four[0], $four[1], $four[2], $four[3]
8158 $~ = "USAGE_FORMAT";
8161 my $rows = int(@lcomm / $cols);
8162 my $rest = @lcomm % $cols;
8173 for (my $y = 0; $y < $rows; $y++)
8175 @four = ("", "", "", "");
8176 for (my $x = 0; $x < $cols; $x++)
8178 last if $y + 1 == $rows && $x == $rest;
8180 my $idx = (($x > $rest)
8181 ? ($rows * $rest + ($rows - 1) * ($x - $rest))
8185 $four[$x] = $lcomm[$idx];
8190 print "\nReport bugs to <bug-automake\@gnu.org>.\n";
8197 # Print version information
8201 automake (GNU $PACKAGE) $VERSION
8202 Written by Tom Tromey <tromey\@cygnus.com>.
8204 Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
8205 Free Software Foundation, Inc.
8206 This is free software; see the source for copying conditions. There is NO
8207 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.