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;
124 # Parameters set by configure. Not to be changed. NOTE: assign
125 # VERSION as string so that eg version 0.30 will print correctly.
126 my $VERSION = "@VERSION@";
127 my $PACKAGE = "@PACKAGE@";
128 my $prefix = "@prefix@";
129 my $libdir = "@datadir@/@PACKAGE@";
132 my $IGNORE_PATTERN = '^\s*##([^#\n].*)?\n';
133 my $WHITE_PATTERN = '^\s*$';
134 my $COMMENT_PATTERN = '^#';
135 my $TARGET_PATTERN='[$a-zA-Z_.@][-.a-zA-Z0-9_(){}/$+@]*';
136 # A rule has three parts: a list of targets, a list of dependencies,
137 # and optionally actions.
139 "^($TARGET_PATTERN(?:(?:\\\\\n|\\s)+$TARGET_PATTERN)*) *:([^=].*|)\$";
141 my $SUFFIX_RULE_PATTERN = '^\.([a-zA-Z0-9+]+)\.([a-zA-Z0-9+]+)$';
142 # Only recognize leading spaces, not leading tabs. If we recognize
143 # leading tabs here then we need to make the reader smarter, because
144 # otherwise it will think rules like `foo=bar; \' are errors.
145 my $MACRO_PATTERN = '^[A-Za-z0-9_@]+$';
146 my $ASSIGNMENT_PATTERN = '^ *([^ \t=:+]*)\s*([:+]?)=\s*(.*)$';
147 # This pattern recognizes a Gnits version id and sets $1 if the
148 # release is an alpha release. We also allow a suffix which can be
149 # used to extend the version number with a "fork" identifier.
150 my $GNITS_VERSION_PATTERN = '\d+\.\d+([a-z]|\.\d+)?(-[A-Za-z0-9]+)?';
151 my $IF_PATTERN = '^if\s+(!?)\s*([A-Za-z][A-Za-z0-9_]*)\s*(?:#.*)?$';
152 my $ELSE_PATTERN = '^else(?:\s+(!?)\s*([A-Za-z][A-Za-z0-9_]*))?\s*(?:#.*)?$';
153 my $ENDIF_PATTERN = '^endif(?:\s+(!?)\s*([A-Za-z][A-Za-z0-9_]*))?\s*(?:#.*)?$';
154 my $PATH_PATTERN='(\w|[/.-])+';
155 # This will pass through anything not of the prescribed form.
156 my $INCLUDE_PATTERN = ('^include\s+'
157 . '((\$\(top_srcdir\)/' . $PATH_PATTERN . ')'
158 . '|(\$\(srcdir\)/' . $PATH_PATTERN . ')'
159 . '|([^/\$]' . $PATH_PATTERN. '))\s*(#.*)?$');
161 # Some regular expressions. One reason to put them here is that it
162 # makes indentation work better in Emacs.
163 my $AC_CONFIG_AUX_DIR_PATTERN = 'AC_CONFIG_AUX_DIR\(([^)]+)\)';
164 my $AM_INIT_AUTOMAKE_PATTERN = 'AM_INIT_AUTOMAKE\([^,]*,([^,)]+)[,)]';
165 my $AM_PACKAGE_VERSION_PATTERN = '^\s*\[?([^]\s]+)\]?\s*$';
167 # This handles substitution references like ${foo:.a=.b}.
168 my $SUBST_REF_PATTERN = "^([^:]*):([^=]*)=(.*)\$";
170 # Note that there is no AC_PATH_TOOL. But we don't really care.
171 my $AC_CHECK_PATTERN = 'AC_(CHECK|PATH)_(PROG|PROGS|TOOL)\(\[?(\w+)';
172 my $AM_MISSING_PATTERN = 'AM_MISSING_PROG\(\[?(\w+)';
173 # Just check for alphanumeric in AC_SUBST. If you do AC_SUBST(5),
175 my $AC_SUBST_PATTERN = 'AC_SUBST\(\[?(\w+)';
176 my $AM_CONDITIONAL_PATTERN = 'AM_CONDITIONAL\(\[?(\w+)';
177 # Match `-d' as a command-line argument in a string.
178 my $DASH_D_PATTERN = "(^|\\s)-d(\\s|\$)";
180 # Constants to define the "strictness" level.
185 # Values for AC_CANONICAL_*
186 my $AC_CANONICAL_HOST = 1;
187 my $AC_CANONICAL_SYSTEM = 2;
189 # Values indicating when something should be cleaned. Right now we
190 # only need to handle `mostly'- and `dist'-clean; add more as
192 my $MOSTLY_CLEAN = 0;
195 # Files installed by libtoolize.
196 my @libtoolize_files = ('ltmain.sh', 'config.guess', 'config.sub');
197 # ltconfig appears here for compatibility with old versions of libtool.
198 my @libtoolize_sometimes = ('ltconfig', 'ltcf-c.sh', 'ltcf-cxx.sh',
201 # Commonly found files we look for and automatically include in
205 'README', 'THANKS', 'TODO', 'NEWS', 'COPYING', 'COPYING.LIB',
206 'INSTALL', 'ABOUT-NLS', 'ChangeLog', 'configure.ac',
207 'configure.in', 'configure', 'config.guess', 'config.sub',
208 'AUTHORS', 'BACKLOG', 'ABOUT-GNU', 'libversion.in',
209 'mdate-sh', 'mkinstalldirs', 'install-sh', 'texinfo.tex',
210 'ansi2knr.c', 'ansi2knr.1', 'elisp-comp',
211 # ltconfig appears here for compatibility with old versions
213 'ylwrap', 'acinclude.m4', @libtoolize_files, @libtoolize_sometimes,
214 'missing', 'depcomp', 'compile', 'py-compile'
217 # Commonly used files we auto-include, but only sometimes.
218 my @common_sometimes =
220 'aclocal.m4', 'acconfig.h', 'config.h.top',
221 'config.h.bot', 'stamp-h.in', 'stamp-vti'
224 # Copyright on generated Makefile.ins.
225 my $gen_copyright = "\
226 # Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
227 # Free Software Foundation, Inc.
228 # This Makefile.in is free software; the Free Software Foundation
229 # gives unlimited permission to copy and/or distribute it,
230 # with or without modifications, as long as this notice is preserved.
232 # This program is distributed in the hope that it will be useful,
233 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
234 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
235 # PARTICULAR PURPOSE.
238 # These constants are returned by lang_*_rewrite functions.
239 # LANG_SUBDIR means that the resulting object file should be in a
240 # subdir if the source file is. In this case the file name cannot
241 # have `..' components.
243 my $LANG_PROCESS = 1;
246 # Directories installed during 'install-exec' phase.
265 # Map from obsolete macros to hints for new macros.
266 # If you change this, change the corresponding list in aclocal.in.
267 # FIXME: should just put this into a single file.
268 my %obsolete_macros =
270 'AC_FEATURE_CTYPE' => "use `AC_HEADER_STDC'",
271 'AC_FEATURE_ERRNO' => "add `strerror' to `AC_REPLACE_FUNCS(...)'",
272 'AC_FEATURE_EXIT' => '',
273 'AC_SYSTEM_HEADER' => '',
275 # Note that we do not handle this one, because it is still run
276 # from AM_CONFIG_HEADER. So we deal with it specially in
277 # &scan_autoconf_files.
278 # 'AC_CONFIG_HEADER' => "use `AM_CONFIG_HEADER'",
280 'fp_C_PROTOTYPES' => "use `AM_C_PROTOTYPES'",
281 'fp_PROG_CC_STDC' => "use `AM_PROG_CC_STDC'",
282 'fp_PROG_INSTALL' => "use `AC_PROG_INSTALL'",
283 'fp_WITH_DMALLOC' => "use `AM_WITH_DMALLOC'",
284 'fp_WITH_REGEX' => "use `AM_WITH_REGEX'",
285 'gm_PROG_LIBTOOL' => "use `AM_PROG_LIBTOOL'",
286 'jm_MAINTAINER_MODE' => "use `AM_MAINTAINER_MODE'",
287 'md_TYPE_PTRDIFF_T' => "add `ptrdiff_t' to `AC_CHECK_TYPES(...)'",
288 'ud_PATH_LISPDIR' => "use `AM_PATH_LISPDIR'",
289 'ud_GNU_GETTEXT' => "use `AM_GNU_GETTEXT'",
291 # Now part of autoconf proper, under a different name.
292 'fp_FUNC_FNMATCH' => "use `AC_FUNC_FNMATCH'",
293 'AM_SANITY_CHECK_CC' => "automatically done by `AC_PROG_CC'",
294 'AM_PROG_INSTALL' => "use `AC_PROG_INSTALL'",
295 'AM_EXEEXT' => "automatically done by `AC_PROG_(CC|CXX|F77)'",
296 'AM_CYGWIN32' => "use `AC_CYGWIN'",
297 'AM_MINGW32' => "use `AC_MINGW32'",
298 'AM_FUNC_MKTIME' => "use `AC_FUNC_MKTIME'",
301 # Regexp to match the above macros.
302 my $obsolete_rx = '\b(' . join ('|', keys %obsolete_macros) . ')\b';
306 ## ---------------------------------- ##
307 ## Variables related to the options. ##
308 ## ---------------------------------- ##
310 # TRUE if we should always generate Makefile.in.
311 my $force_generation = 1;
313 # Strictness level as set on command line.
314 my $default_strictness = $GNU;
316 # Name of strictness level, as set on command line.
317 my $default_strictness_name = 'gnu';
319 # This is TRUE if automatic dependency generation code should be
320 # included in generated Makefile.in.
321 my $cmdline_use_dependencies = 1;
323 # TRUE if in verbose mode.
326 # This holds our (eventual) exit status. We don't actually exit until
327 # we have processed all input files.
330 # From the Perl manual.
331 my $symlink_exists = (eval 'symlink ("", "");', $@ eq '');
333 # TRUE if missing standard files should be installed.
336 # TRUE if we should copy missing files; otherwise symlink if possible.
337 my $copy_missing = 0;
339 # TRUE if we should always update files that we know about.
340 my $force_missing = 0;
343 ## ---------------------------------------- ##
344 ## Variables filled during files scanning. ##
345 ## ---------------------------------------- ##
347 # Name of the top autoconf input: `configure.ac' or `configure.in'.
348 my $configure_ac = '';
350 # Files found by scanning configure.ac for LIBOBJS.
353 # True if AM_C_PROTOTYPES appears in configure.ac.
354 my $am_c_prototypes = 0;
356 # Names used in AC_CONFIG_HEADER call. @config_fullnames holds the
357 # name which appears in AC_CONFIG_HEADER, colon and all.
358 # @config_names holds the file names. @config_headers holds the '.in'
359 # files. Ordinarily these are similar, but they can be different if
360 # the weird "NAME:FILE" syntax is used.
361 my @config_fullnames = ();
362 my @config_names = ();
363 my @config_headers = ();
364 # Where AC_CONFIG_HEADER appears.
365 my $config_header_location;
367 # Directory where output files go. Actually, output files are
368 # relative to this directory.
369 my $output_directory = '.';
371 # List of Makefile.am's to process, and their corresponding outputs.
372 my @input_files = ();
373 my %output_files = ();
375 # Complete list of Makefile.am's that exist.
376 my @configure_input_files = ();
378 # List of files in AC_OUTPUT without Makefile.am, and their outputs.
379 my @other_input_files = ();
380 # Where AC_OUTPUT appears.
381 my $ac_output_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_line = 0;
405 # TRUE if we've seen AM_MAINTAINER_MODE.
406 my $seen_maint_mode = 0;
408 # Actual version we've seen.
409 my $package_version = '';
411 # Where version is defined.
412 my $package_version_location;
414 # TRUE if we've seen AM_PATH_LISPDIR.
415 my $seen_lispdir = 0;
417 # TRUE if we've seen AM_PATH_PYTHON.
418 my $seen_pythondir = 0;
420 # TRUE if we've seen AC_ENABLE_MULTILIB.
421 my $seen_multilib = 0;
423 # TRUE if we've seen AM_PROG_CC_C_O
426 # TRUE if we've seen AM_INIT_AUTOMAKE.
427 my $seen_init_automake = 0;
429 # Hash table of discovered configure substitutions. Keys are names,
430 # values are `FILE:LINE' strings which are used by error message
432 my %configure_vars = ();
434 # This is used to keep track of which variable definitions we are
435 # scanning. It is only used in certain limited ways, but it has to be
436 # global. It is declared just for documentation purposes.
437 my %vars_scanned = ();
439 # TRUE if --cygnus seen.
442 # Hash table of AM_CONDITIONAL variables seen in configure.
443 my %configure_cond = ();
445 # This maps extensions onto language names.
446 my %extension_map = ();
448 # List of the DIST_COMMON files we discovered while reading
450 my $configure_dist_common = '';
452 # This maps languages names onto objects.
455 # List of targets we must always output.
456 # FIXME: Complete, and remove falsely required targets.
457 my %required_targets =
468 # FIXME: Not required, temporary hacks.
469 # Well, actually they are sort of required: the -recursive
470 # targets will run them anyway...
473 'install-data-am' => 1,
474 'install-exec-am' => 1,
475 'installcheck-am' => 1,
483 ################################################################
485 ## ------------------------------------------ ##
486 ## Variables reset by &initialize_per_input. ##
487 ## ------------------------------------------ ##
489 # Basename and relative dir of the input file.
493 # Same but wrt Makefile.in.
497 # These two variables are used when generating each Makefile.in.
498 # They hold the Makefile.in until it is ready to be printed.
505 # Suffixes found during a run.
508 # Handling the variables.
511 # - $var_value{$VAR}{$COND} is its value associated to $COND,
512 # - $var_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 am_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 IO::File "> $out_file";
1296 warn "$me: ${am_file}.in: cannot write: $!\n";
1300 print "$me: creating ", $makefile, ".in\n" if $verbose;
1302 # In case we're running under MSWindows, don't write with CRLF
1303 # (as it causes problems for the dependency-file extraction in
1304 # AM_OUTPUT_DEPENDENCY_COMMANDS).
1307 print $gm_file $output_vars;
1308 # We make sure that `all:' is the first target.
1309 print $gm_file $output_all;
1310 print $gm_file $output_header;
1311 print $gm_file $output_rules;
1312 print $gm_file $output_trailer;
1314 if (! $gm_file->close)
1316 warn "$me: $am_file.in: cannot close: $!\n";
1322 ################################################################
1324 # A helper which handles the logic of requiring a version number in
1325 # AUTOMAKE_OPTIONS. Return 1 on error, 0 on success.
1326 sub version_check ($$$$)
1328 my ($rmajor, $rminor, $ralpha, $rfork) = ($1, $2, $3, $4);
1330 &prog_error ("version is incorrect: $VERSION")
1331 if $VERSION !~ /(\d+)\.(\d+)([a-z]?)-?([A-Za-z0-9]+)?/;
1333 my ($tmajor, $tminor, $talpha, $tfork) = ($1, $2, $3, $4);
1338 my $rminorminor = 0;
1339 my $tminorminor = 0;
1341 # Some versions were labelled like `1.4-p3a'. This is the same as
1342 # an alpha release labelled `1.4.3a'. However, a version like
1343 # `1.4g' is the same as `1.4.99g'. Yes, this sucks. Moral:
1344 # always listen to the users.
1345 if ($rfork =~ /p([0-9]+)([a-z]?)/)
1348 # `1.4a-p3b' never existed. But we'll accept it anyway.
1349 $ralpha = $ralpha || $2 || '';
1352 if ($tfork =~ /p([0-9]+)([a-z]?)/)
1355 # `1.4a-p3b' never existed. But we'll accept it anyway.
1356 $talpha = $talpha || $2 || '';
1360 $rminorminor = 99 if $ralpha ne '' && $rminorminor == 0;
1361 $tminorminor = 99 if $talpha ne '' && $tminorminor == 0;
1363 # 2.0 is better than 1.0.
1364 # 1.2 is better than 1.1.
1365 # 1.2a is better than 1.2.
1366 # If we require 3.4n-foo then we require something
1367 # >= 3.4n, with the `foo' fork identifier.
1368 # The $r* variables are what the user specified.
1369 # The $t* variables denote automake itself.
1370 if ($rmajor > $tmajor
1371 || ($rmajor == $tmajor && $rminor > $tminor)
1372 || ($rminor == $tminor && $rminor == $tminor
1373 && $rminorminor > $tminorminor)
1374 || ($rminor == $tminor && $rminor == $tminor
1375 && $rminorminor == $tminorminor
1376 && $ralpha gt $talpha)
1377 || ($rfork ne '' && $rfork ne $tfork))
1379 am_macro_error ('AUTOMAKE_OPTIONS',
1380 "require version $_, but have $VERSION");
1387 # Handle AUTOMAKE_OPTIONS variable. Return 1 on error, 0 otherwise.
1390 if (&variable_defined ('AUTOMAKE_OPTIONS'))
1392 foreach (&variable_value_as_list_recursive ('AUTOMAKE_OPTIONS', ''))
1395 if ($_ eq 'gnits' || $_ eq 'gnu' || $_ eq 'foreign')
1397 &set_strictness ($_);
1399 elsif ($_ eq 'cygnus')
1403 elsif (/^(.*\/)?ansi2knr$/)
1405 # An option like "../lib/ansi2knr" is allowed. With
1406 # no path prefix, we assume the required programs are
1407 # in this directory. We save the actual option for
1409 $options{'ansi2knr'} = $_;
1411 elsif ($_ eq 'no-installman' || $_ eq 'no-installinfo'
1412 || $_ eq 'dist-shar' || $_ eq 'dist-zip'
1413 || $_ eq 'dist-tarZ' || $_ eq 'dist-bzip2'
1414 || $_ eq 'dejagnu' || $_ eq 'no-texinfo.tex'
1415 || $_ eq 'readme-alpha' || $_ eq 'check-news'
1416 || $_ eq 'subdir-objects' || $_ eq 'nostdinc'
1417 || $_ eq 'no-exeext')
1419 # Explicitly recognize these.
1421 elsif ($_ eq 'no-dependencies')
1423 $use_dependencies = 0;
1425 elsif (/(\d+)\.(\d+)([a-z]?)(-[A-Za-z0-9]+)?/)
1427 # Got a version number.
1428 if (version_check ($1, $2, $3, $4))
1435 am_macro_error ('AUTOMAKE_OPTIONS',
1436 "option `" . $_ . "\' not recognized");
1441 if ($strictness == $GNITS)
1443 $options{'readme-alpha'} = 1;
1444 $options{'check-news'} = 1;
1451 # get_object_extension ($OUT)
1452 # ---------------------------
1453 # Return object extension. Just once, put some code into the output.
1454 # OUT is the name of the output file
1455 sub get_object_extension
1459 # Maybe require libtool library object files.
1460 my $extension = '.$(OBJEXT)';
1461 $extension = '.lo' if ($out =~ /\.la$/);
1463 # Check for automatic de-ANSI-fication.
1464 $extension = '$U' . $extension
1465 if defined $options{'ansi2knr'};
1467 $get_object_extension_was_run = 1;
1473 # Call finish function for each language that was used.
1474 sub handle_languages
1476 if ($use_dependencies)
1478 # Include auto-dep code. Don't include it if DEP_FILES would
1480 if (&saw_sources_p (0) && keys %dep_files)
1482 # Set location of depcomp.
1483 &define_variable ('depcomp', "\$(SHELL) $config_aux_dir/depcomp");
1485 &require_conf_file ($FOREIGN, 'depcomp');
1487 my @deplist = sort keys %dep_files;
1489 # We define this as a conditional variable because BSD
1490 # make can't handle backslashes for continuing comments on
1491 # the following line.
1492 define_pretty_variable ('DEP_FILES', 'AMDEP_TRUE', @deplist);
1494 # Generate each `include' individually. Irix 6 make will
1495 # not properly include several files resulting from a
1496 # variable expansion; generating many separate includes
1498 $output_rules .= "\n";
1499 foreach my $iter (@deplist)
1501 $output_rules .= (subst ('AMDEP_TRUE')
1502 . subst ('am__include')
1504 . subst ('am__quote')
1506 . subst ('am__quote')
1510 $output_rules .= &file_contents ('depend');
1515 &define_variable ('depcomp', '');
1520 # Is the c linker needed?
1522 foreach my $ext (sort keys %extension_seen)
1524 next unless $extension_map{$ext};
1526 my $lang = $languages{$extension_map{$ext}};
1528 my $rule_file = $lang->rule_file || 'depend2';
1530 # Get information on $LANG.
1531 my $pfx = $lang->autodep;
1532 my $fpfx = ($pfx eq '') ? 'CC' : $pfx;
1534 my $AMDEP = (($use_dependencies && $lang->autodep ne 'no')
1535 ? 'AMDEP' : 'FALSE');
1537 my %transform = ('EXT' => $ext,
1540 'LIBTOOL' => $seen_libtool,
1542 '-c' => $lang->compile_flag || '',
1544 => (count_files_for_language ($lang->name) > 1));
1546 # Generate the appropriate rules for this extension.
1547 if (($use_dependencies && $lang->autodep ne 'no')
1548 || defined $lang->compile)
1550 # Some C compilers don't support -c -o. Use it only if really
1552 my $output_flag = $lang->output_flag || '';
1555 && $lang->flags eq 'CFLAGS'
1556 && defined $options{'subdir-objects'});
1558 # FIXME: this is a temporary hack to compute a possible
1559 # derived extension. This is not used by depend2.am.
1560 (my $der_ext = $ext) =~ tr/yl/cc/;
1562 # Another yacc/lex hack.
1563 my $destfile = '$*.' . $der_ext;
1566 file_contents ($rule_file,
1570 'DERIVED-EXT' => $der_ext,
1578 'COMPILE' => '$(' . $lang->compiler . ')',
1579 'LTCOMPILE' => '$(LT' . $lang->compiler . ')',
1580 '-o' => $output_flag);
1583 # Now include code for each specially handled object with this
1585 my %seen_files = ();
1586 foreach my $file (@{$lang_specific_files{$lang->name}})
1588 my ($derived, $source, $obj, $myext) = split (' ', $file);
1590 # We might see a given object twice, for instance if it is
1591 # used under different conditions.
1592 next if defined $seen_files{$obj};
1593 $seen_files{$obj} = 1;
1595 my $flags = $lang->flags || '';
1596 my $val = "${derived}_${flags}";
1598 &prog_error ("found $lang->name in handle_languages, but compiler not defined")
1599 unless defined $lang->compile;
1601 (my $obj_compile = $lang->compile) =~ s/\(AM_$flags/\($val/;
1602 my $obj_ltcompile = '$(LIBTOOL) --mode=compile ' . $obj_compile;
1604 # We _need_ `-o' for per object rules.
1605 my $output_flag = $lang->output_flag || '-o';
1607 # Generate a transform which will turn suffix targets in
1608 # depend2.am into real targets for the particular objects we
1611 file_contents ($rule_file,
1616 'SOURCE' => $source,
1617 # Use $myext and not `.o' here, in case
1618 # we are actually building a new source
1619 # file -- e.g. via yacc.
1620 'OBJ' => "$obj$myext",
1621 'OBJOBJ' => "$obj.obj",
1622 'LTOBJ' => "$obj.lo",
1624 'COMPILE' => $obj_compile,
1625 'LTCOMPILE' => $obj_ltcompile,
1626 '-o' => $output_flag));
1629 # The rest of the loop is done once per language.
1630 next if defined $done{$lang};
1633 # Load the language dependent Makefile chunks.
1634 my %lang = map { uc ($_) => 0 } keys %languages;
1635 $lang{uc ($lang->name)} = 1;
1636 $output_rules .= file_contents ('lang-compile', %transform, %lang);
1638 # If the source to a program consists entirely of code from a
1639 # `pure' language, for instance C++ for Fortran 77, then we
1640 # don't need the C compiler code. However if we run into
1641 # something unusual then we do generate the C code. There are
1642 # probably corner cases here that do not work properly.
1643 # People linking Java code to Fortran code deserve pain.
1644 $needs_c ||= ! $lang->pure;
1646 define_compiler_variable ($lang)
1647 if ($lang->compile);
1649 define_linker_variable ($lang)
1652 foreach my $var (@{$lang->config_vars})
1654 am_error ($lang->Name
1655 . " source seen but `$var' not defined in"
1656 . " `$configure_ac'")
1657 if !exists $configure_vars{$var};
1660 # The compiler's flag must be a configure variable.
1661 define_configure_variable ($lang->flags)
1662 if defined $lang->flags && $lang->define_flag;
1664 # Call the finisher.
1668 # If the project is entirely C++ or entirely Fortran 77 (i.e., 1
1669 # suffix rule was learned), don't bother with the C stuff. But if
1670 # anything else creeps in, then use it.
1672 if $need_link || scalar keys %suffix_rules > 1;
1676 if (! defined $done{$languages{'c'}})
1678 &define_configure_variable ($languages{'c'}->flags);
1679 &define_compiler_variable ($languages{'c'});
1681 define_linker_variable ($languages{'c'});
1685 # Check to make sure a source defined in LIBOBJS is not explicitly
1686 # mentioned. This is a separate function (as opposed to being inlined
1687 # in handle_source_transform) because it isn't always appropriate to
1689 sub check_libobjs_sources
1691 my ($one_file, $unxformed) = @_;
1693 foreach my $prefix ('', 'EXTRA_', 'dist_', 'nodist_',
1694 'dist_EXTRA_', 'nodist_EXTRA_')
1697 if (&variable_defined ($prefix . $one_file . '_SOURCES'))
1699 @files = &variable_value_as_list_recursive (
1700 ($prefix . $one_file . '_SOURCES'),
1703 elsif ($prefix eq '')
1705 @files = ($unxformed . '.c');
1712 foreach my $file (@files)
1714 if (defined $libsources{$file})
1716 am_macro_error ($prefix . $one_file . '_SOURCES',
1717 "automatically discovered file `$file' should not be explicitly mentioned");
1725 # handle_single_transform_list ($VAR, $TOPPARENT, $DERIVED, $OBJ, @FILES)
1726 # -----------------------------------------------------------------------
1727 # Does much of the actual work for handle_source_transform.
1729 # $VAR is the name of the variable that the source filenames come from
1730 # $TOPPARENT is the name of the _SOURCES variable which is being processed
1731 # $DERIVED is the name of resulting executable or library
1732 # $OBJ is the object extension (e.g., `$U.lo')
1733 # @FILES is the list of source files to transform
1734 # Result is a list of the names of objects
1735 # %linkers_used will be updated with any linkers needed
1736 sub handle_single_transform_list ($$$$@)
1738 my ($var, $topparent, $derived, $obj, @files) = @_;
1740 my $nonansi_obj = $obj;
1741 $nonansi_obj =~ s/\$U//g;
1743 # Turn sources into objects. We use a while loop like this
1744 # because we might add to @files in the loop.
1745 while (scalar @files > 0)
1749 # Configure substitutions in _SOURCES variables are errors.
1752 am_macro_error ($var, "`$var' includes configure substitution `$_', and is referred to from `$topparent': configure substitutions not allowed in _SOURCES variables");
1756 # If the source file is in a subdirectory then the `.o' is put
1757 # into the current directory, unless the subdir-objects option
1760 # Split file name into base and extension.
1761 next if ! /^(?:(.*)\/)?([^\/]*)\.(.*)$/;
1763 my $directory = $1 || '';
1767 # We must generate a rule for the object if it requires its own flags.
1769 my ($linker, $object);
1771 # This records whether we've seen a derived source file (eg,
1773 my $derived_source = 0;
1775 # This holds the `aggregate context' of the file we are
1776 # currently examining. If the file is compiled with
1777 # per-object flags, then it will be the name of the object.
1778 # Otherwise it will be `AM'. This is used by the target hook
1779 # language function.
1780 my $aggregate = 'AM';
1782 $extension = &derive_suffix ($extension);
1784 if ($extension_map{$extension} &&
1785 ($lang = $languages{$extension_map{$extension}}))
1787 # Found the language, so see what it says.
1788 &saw_extension ($extension);
1790 # Note: computed subr call. The language rewrite function
1791 # should return one of the $LANG_* constants. It could
1792 # also return a list whose first value is such a constant
1793 # and whose second value is a new source extension which
1794 # should be applied. This means this particular language
1795 # generates another source file which we must then process
1797 my $subr = 'lang_' . $lang->name . '_rewrite';
1798 my ($r, $source_extension)
1799 = & $subr ($directory, $base, $extension);
1800 # Skip this entry if we were asked not to process it.
1801 next if $r == $LANG_IGNORE;
1803 # Now extract linker and other info.
1804 $linker = $lang->linker;
1807 if (defined $source_extension)
1809 $this_obj_ext = '.' . $source_extension;
1810 $derived_source = 1;
1814 $this_obj_ext = $obj;
1818 $this_obj_ext = $nonansi_obj;
1820 $object = $base . $this_obj_ext;
1822 if (defined $lang->flags
1823 && &variable_defined ($derived . '_' . $lang->flags))
1825 # We have a per-executable flag in effect for this
1826 # object. In this case we rewrite the object's
1827 # name to ensure it is unique. We also require
1828 # the `compile' program to deal with compilers
1829 # where `-c -o' does not work.
1831 # We choose the name `DERIVED_OBJECT' to ensure
1832 # (1) uniqueness, and (2) continuity between
1833 # invocations. However, this will result in a
1834 # name that is too long for losing systems, in
1835 # some situations. So we provide _SHORTNAME to
1838 my $dname = $derived;
1839 if (&variable_defined ($derived . '_SHORTNAME'))
1841 # FIXME: should use the same conditional as
1842 # the _SOURCES variable. But this is really
1843 # silly overkill -- nobody should have
1844 # conditional shortnames.
1845 $dname = &variable_value ($derived . '_SHORTNAME');
1847 $object = $dname . '-' . $object;
1849 &require_conf_file ($FOREIGN, 'compile')
1850 if $lang->name eq 'c';
1852 &prog_error ("$lang->name flags defined without compiler")
1853 if ! defined $lang->compile;
1858 # If rewrite said it was ok, put the object into a
1860 if ($r == $LANG_SUBDIR && $directory ne '')
1862 $object = $directory . '/' . $object;
1865 # If doing dependency tracking, then we can't print
1866 # the rule. If we have a subdir object, we need to
1867 # generate an explicit rule. Actually, in any case
1868 # where the object is not in `.' we need a special
1869 # rule. The per-object rules in this case are
1870 # generated later, by handle_languages.
1871 if ($renamed || $directory ne '')
1873 my $obj_sans_ext = substr ($object, 0,
1874 - length ($this_obj_ext));
1875 my $val = ("$full $obj_sans_ext "
1876 # Only use $this_obj_ext in the derived
1877 # source case because in the other case we
1878 # *don't* want $(OBJEXT) to appear here.
1879 . ($derived_source ? $this_obj_ext : '.o'));
1881 # If we renamed the object then we want to use the
1882 # per-executable flag name. But if this is simply a
1883 # subdir build then we still want to use the AM_ flag
1887 $val = "$derived $val";
1888 $aggregate = $derived;
1895 # Each item on this list is a string consisting of
1896 # four space-separated values: the derived flag prefix
1897 # (eg, for `foo_CFLAGS', it is `foo'), the name of the
1898 # source file, the base name of the output file, and
1899 # the extension for the object file.
1900 push (@{$lang_specific_files{$lang->name}}, $val);
1903 elsif ($extension eq 'o')
1905 # This is probably the result of a direct suffix rule.
1906 # In this case we just accept the rewrite. FIXME:
1907 # this fails if we want libtool objects.
1908 $object = $base . '.' . $extension;
1913 # No error message here. Used to have one, but it was
1915 # FIXME: we could potentially do more processing here,
1916 # perhaps treating the new extension as though it were a
1917 # new source extension (as above). This would require
1918 # more restructuring than is appropriate right now.
1922 if (defined $object_map{$object})
1924 if ($object_map{$object} ne $full)
1926 &am_error ("object `$object' created by `$full' and `$object_map{$object}'");
1930 # Let the language do some special magic if required.
1931 $lang->target_hook ($aggregate, $object, $full);
1933 if ($derived_source)
1935 &prog_error ("$lang->name has automatic dependency tracking")
1936 if $lang->autodep ne 'no';
1937 # Make sure this new source file is handled next. That will
1938 # make it appear to be at the right place in the list.
1939 unshift (@files, $object);
1941 &push_dist_common ($object);
1945 $linkers_used{$linker} = 1;
1947 push (@result, $object);
1949 if (! defined $object_map{$object})
1952 $object_map{$object} = $full;
1954 # If file is in subdirectory, we need explicit
1956 if ($directory ne '' || $renamed)
1958 push (@dep_list, $full);
1961 # If resulting object is in subdir, we need to make
1962 # sure the subdir exists at build time.
1963 if ($object =~ /\//)
1965 # FIXME: check that $DIRECTORY is somewhere in the
1968 # We don't allow `..' in object file names for
1969 # *any* source, not just Java. For Java it just
1970 # doesn't make sense, but in general it is
1971 # a problem because we can't pick a good name for
1973 if ($object =~ /(\/|^)\.\.\//)
1975 &am_error ("`$full' contains `..' component but should not");
1978 # Make sure object is removed by `make mostlyclean'.
1979 $compile_clean_files{$object} = $MOSTLY_CLEAN;
1981 push (@dep_list, &require_build_directory ($directory));
1983 # If we're generating dependencies, we also want
1984 # to make sure that the appropriate subdir of the
1985 # .deps directory is created.
1986 push (@dep_list, &require_build_directory ('$(DEPDIR)/' . $directory))
1987 if ($use_dependencies);
1990 &pretty_print_rule ($object . ':', "\t", @dep_list)
1991 if scalar @dep_list > 0;
1994 # Transform .o or $o file into .P file (for automatic
1996 if ($lang && $lang->autodep ne 'no')
1998 my $depfile = $object;
1999 $depfile =~ s/\.([^.]*)$/.P$1/;
2000 $depfile =~ s/\$\(OBJEXT\)$/o/;
2001 $dep_files{'$(DEPDIR)/' . $depfile} = 1;
2009 # define_objects_from_sources ($VAR, $OBJVAR, $NODEFINE, $ONE_FILE,
2010 # $OBJ, $PARENT, $TOPPARENT)
2011 # ---------------------------------------------------------------------
2012 # Define an _OBJECTS variable for a _SOURCES variable (or subvariable)
2015 # $VAR is the name of the _SOURCES variable
2016 # $OBJVAR is the name of the _OBJECTS
2017 # $NODEFINE is a boolean: if true, $OBJVAR will not be defined (but
2018 # work done to determine the linker will be).
2019 # $ONE_FILE is the canonical (transformed) name of object to build
2020 # $OBJ is the object extension (ie either `.o' or `$o'.
2021 # $PARENT is the variable in which $VAR is used, or $VAR if not applicable.
2022 # $TOPPARENT is the _SOURCES variable being processed.
2024 # Result is a boolean, true if a linker is needed to deal with the objects.
2026 # %linkers_used, %vars_scanned, @substfroms and @substtos should be cleared
2028 # %linkers_used variable will be set to contain the linkers desired.
2029 # %vars_scanned will be used to check for recursive definitions.
2030 # @substfroms and @substtos will be used to keep a stack of variable
2031 # substitutions to be applied.
2033 sub define_objects_from_sources ($$$$$$$)
2035 my ($var, $objvar, $nodefine, $one_file, $obj, $parent, $topparent) = @_;
2037 if (defined $vars_scanned{$var})
2039 am_macro_error ($var, "variable `$var' recursively defined");
2042 $vars_scanned{$var} = 1;
2044 my $needlinker = "";
2045 foreach my $cond (variable_conditions ($var))
2048 foreach my $val (&variable_value_as_list ($var, $cond, $parent))
2050 if ($val =~ /^\$\{([^}]*)\}$/ || $val =~ /^\$\(([^)]*)\)$/)
2052 # Handle a sub variable
2055 # If the user uses a losing variable name, just ignore it.
2056 # This isn't ideal, but people have requested it.
2057 next if ($subvar =~ /\@.*\@/);
2059 # See if the variable is actually a substitution reference
2062 if ($subvar =~ /$SUBST_REF_PATTERN/o)
2066 ($from = $2) =~ s/(\W)/\\$1/g;
2068 push @substfroms, $from;
2069 push @substtos, $to;
2071 my $subobjvar = subobjname ($subvar);
2072 push (@result, '$('. $subobjvar . ')');
2074 my $temp = define_objects_from_sources ($subvar, $subobjvar,
2075 $nodefine, $one_file,
2076 $obj, $var, $topparent);
2077 $needlinker ||= $temp;
2084 my $substnum=$#substfroms;
2085 while ($substnum >= 0)
2087 $val =~ s/$substfroms[$substnum]$/$substtos[$substnum]/
2088 if defined $substfroms[$substnum];
2093 &handle_single_transform_list ($var, $topparent, $one_file, $obj, $val);
2094 push (@result, @transformed);
2095 $needlinker = "true" if @transformed;
2099 # Define _OBJECTS conditionally.
2100 define_pretty_variable ($objvar, $cond, (@result))
2104 delete $vars_scanned{$var};
2110 # subobjname ($VARNAME)
2111 # ---------------------
2112 # Return a name for an object variable.
2115 # $VARNAME is the name of the variable the object variable is being
2118 # This function also looks at @substfroms and @substtos to determine any
2119 # substitutions to be performed on the object variable.
2121 # The name returned is unique for the combination of $varname and
2122 # substitutions to be performed.
2127 my $substnum=$#substfroms;
2128 while ($substnum >= 0)
2130 if (defined $substfroms[$substnum] &&
2131 ($substfroms[$substnum] || $substtos[$substnum]))
2133 $key .= ":" . $substfroms[$substnum] . "=" . $substtos[$substnum];
2138 my $num = $substnums{$key};
2141 $num = keys(%substnums) + 1;
2142 $substnums{$key} = $num;
2145 return "am__objects_$num";
2149 # Handle SOURCE->OBJECT transform for one program or library.
2151 # canonical (transformed) name of object to build
2152 # actual name of object to build
2153 # object extension (ie either `.o' or `$o'.
2154 # Return result is name of linker variable that must be used.
2155 # Empty return means just use `LINK'.
2156 sub handle_source_transform
2158 # one_file is canonical name. unxformed is given name. obj is
2160 my ($one_file, $unxformed, $obj) = @_;
2164 if (&variable_defined ($one_file . "_OBJECTS"))
2166 am_macro_error ($one_file . '_OBJECTS',
2167 $one_file . '_OBJECTS', 'should not be defined');
2168 # No point in continuing.
2175 foreach my $prefix ('', 'EXTRA_', 'dist_', 'nodist_',
2176 'dist_EXTRA_', 'nodist_EXTRA_')
2178 my $var = $prefix . $one_file . "_SOURCES";
2180 if !variable_defined ($var);
2182 # We are going to define _OBJECTS variables using the prefix.
2183 # Then we glom them all together. So we can't use the null
2184 # prefix here as we need it later.
2185 my $xpfx = ($prefix eq '') ? 'am_' : $prefix;
2187 # Keep track of which prefixes we saw.
2188 $used_pfx{$xpfx} = 1
2189 unless $prefix =~ /EXTRA_/;
2191 push (@sources, '$(' . $prefix . $one_file . "_SOURCES)");
2192 push (@dist_sources, '$(' . $prefix . $one_file . "_SOURCES)")
2193 unless $prefix =~ /^nodist_/;
2198 my $temp = define_objects_from_sources ($var,
2199 $xpfx . $one_file . '_OBJECTS',
2200 $prefix =~ /EXTRA_/,
2201 $one_file, $obj, $var, $var);
2202 $needlinker ||= $temp;
2206 $linker ||= &resolve_linker (%linkers_used);
2209 my @keys = sort keys %used_pfx;
2210 if (scalar @keys == 0)
2212 &define_variable ($one_file . "_SOURCES", $unxformed . ".c");
2213 push (@sources, $unxformed . '.c');
2214 push (@dist_sources, $unxformed . '.c');
2218 &handle_single_transform_list ($one_file . '_SOURCES',
2219 $one_file . '_SOURCES',
2222 $linker ||= &resolve_linker (%linkers_used);
2223 define_pretty_variable ($one_file . "_OBJECTS", '', @result)
2227 grep ($_ = '$(' . $_ . $one_file . '_OBJECTS)', @keys);
2228 define_pretty_variable ($one_file . '_OBJECTS', '', @keys);
2231 # If we want to use `LINK' we must make sure it is defined.
2241 # handle_lib_objects ($XNAME, $VAR)
2242 # ---------------------------------
2243 # Special-case @ALLOCA@ and @LIBOBJS@ in _LDADD or _LIBADD variables.
2244 # Also, generate _DEPENDENCIES variable if appropriate.
2246 # transformed name of object being built, or empty string if no object
2247 # name of _LDADD/_LIBADD-type variable to examine
2248 # Returns 1 if LIBOBJS seen, 0 otherwise.
2249 sub handle_lib_objects
2251 my ($xname, $var) = @_;
2253 &prog_error ("handle_lib_objects: $var undefined")
2254 if ! &variable_defined ($var);
2257 foreach my $cond (variable_conditions_recursive ($var))
2259 if (&handle_lib_objects_cond ($xname, $var, $cond))
2267 # Subroutine of handle_lib_objects: handle a particular condition.
2268 sub handle_lib_objects_cond
2270 my ($xname, $var, $cond) = @_;
2272 # We recognize certain things that are commonly put in LIBADD or
2276 my $seen_libobjs = 0;
2279 foreach my $lsearch (&variable_value_as_list_recursive ($var, $cond))
2281 # Skip -lfoo and -Ldir; these are explicitly allowed.
2282 next if $lsearch =~ /^-[lL]/;
2283 if (! $flagvar && $lsearch =~ /^-/)
2285 if ($var =~ /^(.*)LDADD$/)
2287 # Skip -dlopen and -dlpreopen; these are explicitly allowed.
2288 next if $lsearch =~ /^-dl(pre)?open$/;
2289 am_macro_error ($var, "linker flags such as `$lsearch' belong in `${1}LDFLAGS");
2293 # Only get this error once.
2295 am_macro_error ($var, "linker flags such as `$lsearch' belong in `${1}LDFLAGS");
2299 # Assume we have a file of some sort, and push it onto the
2300 # dependency list. Autoconf substitutions are not pushed;
2301 # rarely is a new dependency substituted into (eg) foo_LDADD
2302 # -- but "bad things (eg -lX11) are routinely substituted.
2303 # Note that LIBOBJS and ALLOCA are exceptions to this rule,
2304 # and handled specially below.
2305 push (@dep_list, $lsearch)
2306 unless $lsearch =~ /^\@.*\@$/;
2308 # Automatically handle @LIBOBJS@ and @ALLOCA@. Basically this
2309 # means adding entries to dep_files.
2310 if ($lsearch =~ /^\@(LT)?LIBOBJS\@$/)
2312 my $lt = $1 ? $1 : '';
2313 my $myobjext = ($1 ? 'l' : '') . 'o';
2315 push (@dep_list, $lsearch);
2317 if (! keys %libsources
2318 && ! &variable_defined ($lt . 'LIBOBJS'))
2320 am_macro_error ($var, "\@$lt" . "LIBOBJS\@ seen but never set in `$configure_ac'");
2323 foreach my $iter (keys %libsources)
2325 if ($iter =~ /\.([cly])$/)
2327 &saw_extension ($1);
2328 &saw_extension ('c');
2331 if ($iter =~ /\.h$/)
2333 require_file_with_macro ($var, $FOREIGN, $iter);
2335 elsif ($iter ne 'alloca.c')
2337 my $rewrite = $iter;
2338 $rewrite =~ s/\.c$/.P$myobjext/;
2339 $dep_files{'$(DEPDIR)/' . $rewrite} = 1;
2340 ($rewrite = $iter) =~ s/(\W)/\\$1/g;
2341 $rewrite = "^" . $rewrite . "\$";
2342 # Only require the file if it is not a built source.
2343 if (! &variable_defined ('BUILT_SOURCES')
2344 || ! grep (/$rewrite/,
2345 &variable_value_as_list_recursive (
2346 'BUILT_SOURCES', 'all')))
2348 require_file_with_macro ($var, $FOREIGN, $iter);
2353 elsif ($lsearch =~ /^\@(LT)?ALLOCA\@$/)
2355 my $lt = $1 ? $1 : '';
2356 my $myobjext = ($1 ? 'l' : '') . 'o';
2358 push (@dep_list, $lsearch);
2359 am_macro_error ($var,
2360 "\@$lt" . "ALLOCA\@ seen but `AC_FUNC_ALLOCA' not in `$configure_ac'")
2361 if ! defined $libsources{'alloca.c'};
2362 $dep_files{'$(DEPDIR)/alloca.P' . $myobjext} = 1;
2363 require_file_with_macro ($var, $FOREIGN, 'alloca.c');
2364 &saw_extension ('c');
2368 if ($xname ne '' && ! &variable_defined ($xname . '_DEPENDENCIES', $cond))
2370 define_pretty_variable ($xname . '_DEPENDENCIES', $cond, @dep_list);
2373 return $seen_libobjs;
2376 # Canonicalize the input parameter
2380 $string =~ tr/A-Za-z0-9_\@/_/c;
2384 # Canonicalize a name, and check to make sure the non-canonical name
2385 # is never used. Returns canonical name. Arguments are name and a
2386 # list of suffixes to check for.
2387 sub check_canonical_spelling
2389 my ($name, @suffixes) = @_;
2391 my $xname = &canonicalize ($name);
2392 if ($xname ne $name)
2394 foreach my $xt (@suffixes)
2396 am_macro_error ("$name$xt",
2397 "invalid variable `$name$xt'; "
2398 . "should be `$xname$xt'")
2399 if &variable_defined ("$name$xt");
2409 # Set up the compile suite.
2410 sub handle_compile ()
2413 unless $get_object_extension_was_run;
2416 my $default_includes = '';
2417 if (! defined $options{'nostdinc'})
2419 $default_includes = ' -I. -I$(srcdir)';
2421 if (&variable_defined ('CONFIG_HEADER'))
2423 foreach my $hdr (split (' ', &variable_value ('CONFIG_HEADER')))
2425 $default_includes .= ' -I' . dirname ($hdr);
2430 my (@mostly_rms, @dist_rms);
2431 foreach my $item (sort keys %compile_clean_files)
2433 if ($compile_clean_files{$item} == $MOSTLY_CLEAN)
2435 push (@mostly_rms, "\t-rm -f $item");
2437 elsif ($compile_clean_files{$item} == $DIST_CLEAN)
2439 push (@dist_rms, "\t-rm -f $item");
2443 &prog_error ("invalid entry in \%compile_clean_files");
2447 my ($coms, $vars, $rules) =
2448 &file_contents_internal (1, "$libdir/am/compile.am",
2449 ('DEFAULT_INCLUDES' => $default_includes,
2450 'MOSTLYRMS' => join ("\n", @mostly_rms),
2451 'DISTRMS' => join ("\n", @dist_rms)));
2452 $output_vars .= $vars;
2453 $output_rules .= "$coms$rules";
2455 # Check for automatic de-ANSI-fication.
2456 if (defined $options{'ansi2knr'})
2458 if (! $am_c_prototypes)
2460 am_macro_error ('AUTOMAKE_OPTIONS',
2461 "option `ansi2knr' in use but `AM_C_PROTOTYPES' not in `$configure_ac'");
2462 &keyed_aclocal_warning ('AM_C_PROTOTYPES');
2463 # Only give this error once.
2464 $am_c_prototypes = 1;
2467 # topdir is where ansi2knr should be.
2468 if ($options{'ansi2knr'} eq 'ansi2knr')
2470 # Only require ansi2knr files if they should appear in
2472 require_file_with_macro ('AUTOMAKE_OPTIONS', $FOREIGN,
2473 'ansi2knr.c', 'ansi2knr.1');
2475 # ansi2knr needs to be built before subdirs, so unshift it.
2476 unshift (@all, '$(ANSI2KNR)');
2479 my $ansi2knr_dir = '';
2480 $ansi2knr_dir = dirname ($options{'ansi2knr'})
2481 if $options{'ansi2knr'} ne 'ansi2knr';
2483 $output_rules .= &file_contents ('ansi2knr',
2484 ('ANSI2KNR-DIR' => $ansi2knr_dir));
2491 # Handle libtool rules.
2494 return unless $seen_libtool;
2496 # libtool requires some files, but only at top level.
2497 &require_conf_file_with_conf_line ($libtool_line, $FOREIGN,
2499 if $relative_dir eq '.';
2501 # Output the libtool compilation rules.
2502 $output_rules .= &file_contents ('libtool');
2505 # handle_programs ()
2506 # ------------------
2507 # Handle C programs.
2510 my @proglist = &am_install_var ('progs', 'PROGRAMS',
2511 'bin', 'sbin', 'libexec', 'pkglib',
2513 return if ! @proglist;
2515 my $seen_libobjs = 0;
2516 foreach my $one_file (@proglist)
2518 my $obj = &get_object_extension ($one_file);
2520 # Canonicalize names and check for misspellings.
2521 my $xname = &check_canonical_spelling ($one_file, '_LDADD', '_LDFLAGS',
2522 '_SOURCES', '_OBJECTS',
2525 my $linker = &handle_source_transform ($xname, $one_file, $obj);
2528 if (&variable_defined ($xname . "_LDADD"))
2530 if (&handle_lib_objects ($xname, $xname . '_LDADD'))
2538 # User didn't define prog_LDADD override. So do it.
2539 &define_variable ($xname . '_LDADD', '$(LDADD)');
2541 # This does a bit too much work. But we need it to
2542 # generate _DEPENDENCIES when appropriate.
2543 if (&variable_defined ('LDADD'))
2545 if (&handle_lib_objects ($xname, 'LDADD'))
2550 elsif (! &variable_defined ($xname . '_DEPENDENCIES'))
2552 &define_variable ($xname . '_DEPENDENCIES', '');
2557 if (&variable_defined ($xname . '_LIBADD'))
2559 am_macro_error ($xname . '_LIBADD',
2560 "use `" . $xname . "_LDADD', not `"
2561 . $xname . "_LIBADD'");
2564 if (! &variable_defined ($xname . '_LDFLAGS'))
2566 # Define the prog_LDFLAGS variable.
2567 &define_variable ($xname . '_LDFLAGS', '');
2570 # Determine program to use for link.
2572 if (&variable_defined ($xname . '_LINK'))
2574 $xlink = $xname . '_LINK';
2578 $xlink = $linker ? $linker : 'LINK';
2581 # If the resulting program lies into a subdirectory,
2582 # make sure this directory will exist.
2583 my $dirstamp = &require_build_directory_maybe ($one_file);
2585 # Don't add $(EXEEXT) if user already did.
2586 my $extension = ($one_file !~ /\$\(EXEEXT\)$/
2590 $output_rules .= &file_contents ('program',
2591 ('PROGRAM' => $one_file,
2592 'XPROGRAM' => $xname,
2594 'DIRSTAMP' => $dirstamp,
2595 'EXEEXT' => $extension));
2598 if (&variable_defined ('LDADD') && &handle_lib_objects ('', 'LDADD'))
2605 foreach my $one_file (@proglist)
2607 my $xname = &canonicalize ($one_file);
2609 if (&variable_defined ($xname . '_LDADD'))
2611 &check_libobjs_sources ($xname, $xname . '_LDADD');
2613 elsif (&variable_defined ('LDADD'))
2615 &check_libobjs_sources ($xname, 'LDADD');
2622 # handle_libraries ()
2623 # -------------------
2625 sub handle_libraries
2627 my @liblist = &am_install_var ('libs', 'LIBRARIES',
2628 'lib', 'pkglib', 'noinst', 'check');
2629 return if ! @liblist;
2631 my %valid = &am_primary_prefixes ('LIBRARIES', 0, 'lib', 'pkglib',
2633 if (! defined $configure_vars{'RANLIB'})
2635 foreach my $key (keys %valid)
2637 if (&variable_defined ($key . '_LIBRARIES'))
2639 am_macro_error ($key . '_LIBRARIES', "library used but `RANLIB' not defined in `$configure_ac'");
2640 # Only get this error once. If this is ever printed,
2642 $configure_vars{'RANLIB'} = 'BUG';
2648 my $seen_libobjs = 0;
2649 foreach my $onelib (@liblist)
2651 # Check that the library fits the standard naming convention.
2652 if (basename ($onelib) !~ /^lib.*\.a/)
2654 # FIXME should put line number here. That means mapping
2655 # from library name back to variable name.
2656 &am_error ("`$onelib' is not a standard library name");
2659 my $obj = &get_object_extension ($onelib);
2661 # Canonicalize names and check for misspellings.
2662 my $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_SOURCES',
2663 '_OBJECTS', '_DEPENDENCIES',
2666 if (! &variable_defined ($xlib . '_AR'))
2668 &define_variable ($xlib . '_AR', '$(AR) cru');
2671 if (&variable_defined ($xlib . '_LIBADD'))
2673 if (&handle_lib_objects ($xlib, $xlib . '_LIBADD'))
2680 # Generate support for conditional object inclusion in
2682 &define_variable ($xlib . "_LIBADD", '');
2685 if (&variable_defined ($xlib . '_LDADD'))
2687 am_macro_error ($xlib . '_LDADD',
2688 "use `" . $xlib . "_LIBADD', not `"
2689 . $xlib . "_LDADD'");
2692 # Make sure we at look at this.
2693 &examine_variable ($xlib . '_DEPENDENCIES');
2695 &handle_source_transform ($xlib, $onelib, $obj);
2697 # If the resulting library lies into a subdirectory,
2698 # make sure this directory will exist.
2699 my $dirstamp = &require_build_directory_maybe ($onelib);
2701 $output_rules .= &file_contents ('library',
2702 ('LIBRARY' => $onelib,
2703 'XLIBRARY' => $xlib,
2704 'DIRSTAMP' => $dirstamp));
2709 foreach my $onelib (@liblist)
2711 my $xlib = &canonicalize ($onelib);
2712 if (&variable_defined ($xlib . '_LIBADD'))
2714 &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
2721 # handle_ltlibraries ()
2722 # ---------------------
2723 # Handle shared libraries.
2724 sub handle_ltlibraries
2726 my @liblist = &am_install_var ('ltlib', 'LTLIBRARIES',
2727 'noinst', 'lib', 'pkglib', 'check');
2728 return if ! @liblist;
2731 my %valid = &am_primary_prefixes ('LTLIBRARIES', 0, 'lib', 'pkglib',
2734 foreach my $key (keys %valid)
2736 if (&variable_defined ($key . '_LTLIBRARIES'))
2740 am_macro_error ($key . '_LTLIBRARIES', "library used but `LIBTOOL' not defined in `$configure_ac'");
2741 # Only get this error once. If this is ever printed,
2743 $configure_vars{'LIBTOOL'} = 'BUG';
2747 # Get the installation directory of each library.
2748 for (&variable_value_as_list_recursive ($key . '_LTLIBRARIES', 'all'))
2752 &am_error ("`$_' is already going to be installed in `$instdirs{$_}'");
2756 $instdirs{$_} = $key;
2762 my $seen_libobjs = 0;
2763 foreach my $onelib (@liblist)
2765 my $obj = &get_object_extension ($onelib);
2767 # Canonicalize names and check for misspellings.
2768 my $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_LDFLAGS',
2769 '_SOURCES', '_OBJECTS',
2772 if (! &variable_defined ($xlib . '_LDFLAGS'))
2774 # Define the lib_LDFLAGS variable.
2775 &define_variable ($xlib . '_LDFLAGS', '');
2778 # Check that the library fits the standard naming convention.
2779 my $libname_rx = "^lib.*\.la";
2780 if ((&variable_defined ($xlib . '_LDFLAGS')
2781 && grep (/-module/, &variable_value_as_list_recursive (
2782 $xlib . '_LDFLAGS', 'all')))
2783 || (&variable_defined ('LDFLAGS')
2784 && grep (/-module/, &variable_value_as_list_recursive (
2785 'LDFLAGS', 'all'))))
2787 # Relax name checking for libtool modules.
2788 $libname_rx = "\.la";
2790 if (basename ($onelib) !~ /$libname_rx$/)
2792 # FIXME this should only be a warning for foreign packages
2793 # FIXME should put line number here. That means mapping
2794 # from library name back to variable name.
2795 &am_error ("`$onelib' is not a standard libtool library name");
2798 if (&variable_defined ($xlib . '_LIBADD'))
2800 if (&handle_lib_objects ($xlib, $xlib . '_LIBADD'))
2807 # Generate support for conditional object inclusion in
2809 &define_variable ($xlib . "_LIBADD", '');
2812 if (&variable_defined ($xlib . '_LDADD'))
2814 am_macro_error ($xlib . '_LDADD',
2815 "use `" . $xlib . "_LIBADD', not `"
2816 . $xlib . "_LDADD'");
2819 # Make sure we at look at this.
2820 &examine_variable ($xlib . '_DEPENDENCIES');
2822 my $linker = &handle_source_transform ($xlib, $onelib, $obj);
2824 # Determine program to use for link.
2826 if (&variable_defined ($xlib . '_LINK'))
2828 $xlink = $xlib . '_LINK';
2832 $xlink = $linker ? $linker : 'LINK';
2836 if ($instdirs{$onelib} eq 'EXTRA'
2837 || $instdirs{$onelib} eq 'noinst'
2838 || $instdirs{$onelib} eq 'check')
2840 # It's an EXTRA_ library, so we can't specify -rpath,
2841 # because we don't know where the library will end up.
2842 # The user probably knows, but generally speaking automake
2843 # doesn't -- and in fact configure could decide
2844 # dynamically between two different locations.
2849 $rpath = ('-rpath $(' . $instdirs{$onelib} . 'dir)');
2852 # If the resulting library lies into a subdirectory,
2853 # make sure this directory will exist.
2854 my $dirstamp = &require_build_directory_maybe ($onelib);
2856 $output_rules .= &file_contents ('ltlibrary',
2857 ('LTLIBRARY' => $onelib,
2858 'XLTLIBRARY' => $xlib,
2861 'DIRSTAMP' => $dirstamp));
2866 foreach my $onelib (@liblist)
2868 my $xlib = &canonicalize ($onelib);
2869 if (&variable_defined ($xlib . '_LIBADD'))
2871 &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
2877 # See if any _SOURCES variable were misspelled. Also, make sure that
2878 # EXTRA_ variables don't contain configure substitutions.
2881 foreach my $varname (keys %var_value)
2883 foreach my $primary ('_SOURCES', '_LIBADD', '_LDADD', '_LDFLAGS',
2886 if ($varname =~ /$primary$/ && ! $content_seen{$varname})
2888 am_macro_error ($varname,
2889 "invalid unused variable name: `$varname'");
2898 # NOTE we no longer automatically clean SCRIPTS, because it is
2899 # useful to sometimes distribute scripts verbatim. This happens
2900 # eg in Automake itself.
2901 &am_install_var ('-candist', 'scripts', 'SCRIPTS',
2902 'bin', 'sbin', 'libexec', 'pkgdata',
2907 # ($OUTFILE, $VFILE, @CLEAN_FILES)
2908 # &scan_texinfo_file ($FILENAME)
2909 # ------------------------------
2910 # $OUTFILE is the name of the info file produced by $FILENAME.
2911 # $VFILE is the name of the version.texi file used (empty if none).
2912 # @CLEAN_FILES is the list of by products (indexes etc.)
2913 sub scan_texinfo_file
2915 my ($filename) = @_;
2917 # These are always created, no matter whether indexes are used or not.
2918 my @clean_suffixes = ('aux', 'dvi', 'log', 'ps', 'toc',
2919 # grep new.*index texinfo.tex
2920 'cp', 'fn', 'ky', 'vr', 'tp', 'pg');
2922 # There are predefined indexes which don't follow the regular rules.
2923 my %predefined_index =
2926 'c' => 'cps', 'f' => 'fns', 'k' => 'kys',
2927 'v' => 'vrs', 't' => 'tps', 'p' => 'pgs'
2930 # There are commands which include a hidden index command.
2934 'fn' => 'fns', 'un' => 'fns',
2935 'typefn' => 'fns', 'typefun' => 'fns',
2936 'mac' => 'fns', 'spec' => 'fns',
2937 'op' => 'fns', 'typeop' => 'fns',
2938 'method' => 'fns', 'typemethod' => 'fns',
2940 'vr' => 'vrs', 'var' => 'vrs',
2941 'typevr' => 'vrs', 'typevar' => 'vrs',
2944 'ivar' => 'vrs', 'typeivar' => 'vrs',
2949 # Indexes stored into another one. In this case, the *.??s file
2951 my @syncodeindexes = ();
2953 my $texi = new IO::File ("< $filename");
2956 &am_error ("couldn't open `$filename': $!");
2959 print "$me: reading $filename\n" if $verbose;
2961 my ($outfile, $vfile);
2962 while ($_ = $texi->getline)
2964 if (/^\@setfilename +(\S+)/)
2967 if ($outfile =~ /\.(.+)$/ && $1 ne 'info')
2969 &am_file_error ($filename, "$.: ",
2970 "output `$outfile' has unrecognized extension");
2974 # A "version.texi" file is actually any file whose name
2975 # matches "vers*.texi".
2976 elsif (/^\@include\s+(vers[^.]*\.texi)\s*$/)
2981 # Try to find what are the indexes which are used.
2983 # Creating a new category of index.
2984 elsif (/^\@def(code)?index (\w+)/)
2986 push @clean_suffixes, $2;
2989 # Storing in a predefined index.
2990 elsif (/^\@([cfkvtp])index /)
2992 push @clean_suffixes, $predefined_index{$1};
2994 elsif (/^\@def(\w+) /)
2996 push @clean_suffixes, $hidden_index{$1}
2997 if defined $hidden_index{$1};
3000 # Merging an index into an another.
3001 elsif (/^\@syn(code)?index (\w+) (\w+)/)
3003 push @syncodeindexes, "$2s";
3004 push @clean_suffixes, "$3s";
3012 &am_error ("`$filename' missing \@setfilename");
3016 my $infobase = basename ($filename);
3017 $infobase =~ s/\.te?xi(nfo)?$//;
3018 # FIXME: I don't understand why, but I can't use "$infobase.$_" => 1.
3019 my %clean_files = map { "$infobase" . ".$_" => 1 } @clean_suffixes;
3020 grep { delete $clean_files{"$infobase.$_"} } @syncodeindexes;
3021 return ($outfile, $vfile, (sort keys %clean_files));
3025 # ($DO-SOMETHING, $TEXICLEANS)
3026 # handle_texinfo_helper ()
3028 # Handle all Texinfo source; helper for handle_texinfo
3029 sub handle_texinfo_helper
3031 am_macro_error ('TEXINFOS',
3032 "`TEXINFOS' is an anachronism; use `info_TEXINFOS'")
3033 if &variable_defined ('TEXINFOS');
3034 return (0, '') if (! &variable_defined ('info_TEXINFOS')
3035 && ! &variable_defined ('html_TEXINFOS'));
3037 if (&variable_defined ('html_TEXINFOS'))
3039 am_macro_error ('html_TEXINFOS',
3040 "HTML generation not yet supported");
3044 my @texis = &variable_value_as_list_recursive ('info_TEXINFOS', 'all');
3046 my (@info_deps_list, @dvis_list, @texi_deps);
3053 foreach my $info_cursor (@texis)
3055 my $infobase = $info_cursor;
3056 $infobase =~ s/\.(txi|texinfo|texi)$//;
3058 if ($infobase eq $info_cursor)
3060 # FIXME: report line number.
3061 &am_error ("texinfo file `$info_cursor' has unrecognized extension");
3064 $texi_suffixes{$1} = 1;
3066 # If 'version.texi' is referenced by input file, then include
3067 # automatic versioning capability.
3068 my ($out_file, $vtexi, @clean_files) =
3069 &scan_texinfo_file ("$relative_dir/$info_cursor")
3071 push (@texi_cleans, @clean_files);
3075 &am_error ("`$vtexi', included in `$info_cursor', also included in `$versions{$vtexi}'")
3076 if (defined $versions{$vtexi});
3077 $versions{$vtexi} = $info_cursor;
3079 # We number the stamp-vti files. This is doable since the
3080 # actual names don't matter much. We only number starting
3081 # with the second one, so that the common case looks nice.
3082 my $vti = ($done ? $done : 'vti');
3085 # This is ugly, but it is our historical practice.
3086 if ($config_aux_dir_set_in_configure_in)
3088 &require_conf_file_with_line ('info_TEXINFOS', $FOREIGN,
3093 require_file_with_macro ('info_TEXINFOS', $FOREIGN,
3098 if ($config_aux_dir_set_in_configure_in)
3100 $conf_dir = $config_aux_dir;
3101 $conf_dir .= '/' unless $conf_dir =~ /\/$/;
3105 $conf_dir = '$(srcdir)/';
3107 $output_rules .= &file_contents ('texi-vers',
3108 ('TEXI' => $info_cursor,
3111 'MDDIR' => $conf_dir));
3114 # If user specified file_TEXINFOS, then use that as explicit
3117 push (@texi_deps, $info_cursor);
3118 # Prefix with $(srcdir) because some version of make won't
3119 # work if the target has it and the dependency doesn't.
3120 push (@texi_deps, '$(srcdir)/' . $vtexi) if $vtexi;
3122 my $canonical = &canonicalize ($infobase);
3123 if (&variable_defined ($canonical . "_TEXINFOS"))
3125 push (@texi_deps, '$(' . $canonical . '_TEXINFOS)');
3126 &push_dist_common ('$(' . $canonical . '_TEXINFOS)');
3129 $output_rules .= ("\n" . $out_file . ": "
3130 . join (' ', @texi_deps)
3131 . "\n" . $infobase . ".dvi: "
3132 . join (' ', @texi_deps)
3135 push (@info_deps_list, $out_file);
3136 push (@dvis_list, $infobase . '.dvi');
3139 # Handle location of texinfo.tex.
3140 my $need_texi_file = 0;
3144 $texinfodir = '$(top_srcdir)/../texinfo';
3145 &define_variable ('TEXINFO_TEX', "$texinfodir/texinfo.tex");
3147 elsif ($config_aux_dir_set_in_configure_in)
3149 $texinfodir = $config_aux_dir;
3150 &define_variable ('TEXINFO_TEX', "$texinfodir/texinfo.tex");
3151 $need_texi_file = 2; # so that we require_conf_file later
3153 elsif (&variable_defined ('TEXINFO_TEX'))
3155 # The user defined TEXINFO_TEX so assume he knows what he is
3157 $texinfodir = ('$(srcdir)/'
3158 . dirname (&variable_value ('TEXINFO_TEX')));
3162 $texinfodir = '$(srcdir)';
3163 $need_texi_file = 1;
3166 foreach my $txsfx (sort keys %texi_suffixes)
3168 $output_rules .= &file_contents ('texibuild',
3169 ('TEXINFODIR' => $texinfodir,
3170 'SUFFIX' => $txsfx));
3174 my $texiclean = &pretty_print_internal ("", "\t ", @texi_cleans);
3176 push (@dist_targets, 'dist-info');
3178 if (! defined $options{'no-installinfo'})
3180 # Make sure documentation is made and installed first. Use
3181 # $(INFO_DEPS), not 'info', because otherwise recursive makes
3182 # get run twice during "make all".
3183 unshift (@all, '$(INFO_DEPS)');
3186 &define_variable ("INFO_DEPS", join (' ', @info_deps_list));
3187 &define_variable ("DVIS", join (' ', @dvis_list));
3188 # This next isn't strictly needed now -- the places that look here
3189 # could easily be changed to look in info_TEXINFOS. But this is
3190 # probably better, in case noinst_TEXINFOS is ever supported.
3191 &define_variable ("TEXINFOS", &variable_value ('info_TEXINFOS'));
3193 # Do some error checking. Note that this file is not required
3194 # when in Cygnus mode; instead we defined TEXINFO_TEX explicitly
3196 if ($need_texi_file && ! defined $options{'no-texinfo.tex'})
3198 if ($need_texi_file > 1)
3200 &require_conf_file_with_line ('info_TEXINFOS', $FOREIGN,
3205 require_file_with_macro ('info_TEXINFOS', $FOREIGN, 'texinfo.tex');
3209 return (1, $texiclean);
3214 # Handle all Texinfo source.
3217 my ($do_something, $texiclean) = handle_texinfo_helper ();
3218 $output_rules .= &file_contents ('texinfos',
3219 ('TEXICLEAN' => $texiclean,
3220 'LOCAL-TEXIS' => $do_something));
3223 # Handle any man pages.
3224 sub handle_man_pages
3226 am_macro_error ('MANS', "`MANS' is an anachronism; use `man_MANS'")
3227 if &variable_defined ('MANS');
3229 # Find all the sections in use. We do this by first looking for
3230 # "standard" sections, and then looking for any additional
3231 # sections used in man_MANS.
3232 my (%sections, %vlist);
3233 # We handle nodist_ for uniformity. man pages aren't distributed
3234 # by default so it isn't actually very important.
3235 foreach my $pfx ('', 'dist_', 'nodist_')
3237 # Add more sections as needed.
3238 foreach my $section ('0'..'9', 'n', 'l')
3240 if (&variable_defined ($pfx . 'man' . $section . '_MANS'))
3242 $sections{$section} = 1;
3243 $vlist{'$(' . $pfx . 'man' . $section . '_MANS)'} = 1;
3245 &push_dist_common ('$(' . $pfx . 'man' . $section . '_MANS)')
3250 if (&variable_defined ($pfx . 'man_MANS'))
3252 $vlist{'$(' . $pfx . 'man_MANS)'} = 1;
3253 foreach (&variable_value_as_list_recursive ($pfx . 'man_MANS', 'all'))
3255 # A page like `foo.1c' goes into man1dir.
3256 if (/\.([0-9a-z])([a-z]*)$/)
3262 &push_dist_common ('$(' . $pfx . 'man_MANS)')
3267 return unless %sections;
3269 # Now for each section, generate an install and unintall rule.
3270 # Sort sections so output is deterministic.
3271 foreach my $section (sort keys %sections)
3273 $output_rules .= &file_contents ('mans', ('SECTION' => $section));
3276 $output_vars .= &file_contents ('mans-vars',
3277 ('MANS' => join (' ', sort keys %vlist)));
3279 if (! defined $options{'no-installman'})
3281 push (@all, '$(MANS)');
3285 # Handle DATA variables.
3288 &am_install_var ('-noextra', '-candist', 'data', 'DATA',
3289 'data', 'sysconf', 'sharedstate', 'localstate',
3290 'pkgdata', 'noinst', 'check');
3297 if (&variable_defined ('SUBDIRS'))
3299 $output_rules .= ("tags-recursive:\n"
3300 . "\tlist=\'\$(SUBDIRS)\'; for subdir in \$\$list; do \\\n"
3301 # Never fail here if a subdir fails; it
3303 . "\t test \"\$\$subdir\" = . || (cd \$\$subdir"
3304 . " && \$(MAKE) \$(AM_MAKEFLAGS) tags); \\\n"
3306 push (@tag_deps, 'tags-recursive');
3307 &depend ('.PHONY', 'tags-recursive');
3310 if (&saw_sources_p (1)
3311 || &variable_defined ('ETAGS_ARGS')
3315 foreach my $one_hdr (@config_headers)
3317 if ($relative_dir eq dirname ($one_hdr))
3319 # The config header is in this directory. So require it.
3320 $config .= ' ' if $config;
3321 $config .= basename ($one_hdr);
3324 $output_rules .= &file_contents ('tags',
3325 ('CONFIG' => $config,
3326 'DIRS' => join (' ', @tag_deps)));
3327 &examine_variable ('TAGS_DEPENDENCIES');
3329 elsif (&variable_defined ('TAGS_DEPENDENCIES'))
3331 am_macro_error ('TAGS_DEPENDENCIES',
3332 "doesn't make sense to define `TAGS_DEPENDENCIES' without sources or `ETAGS_ARGS'");
3336 # Every Makefile must define some sort of TAGS rule.
3337 # Otherwise, it would be possible for a top-level "make TAGS"
3338 # to fail because some subdirectory failed.
3339 $output_rules .= "tags: TAGS\nTAGS:\n\n";
3343 # Handle multilib support.
3346 if ($seen_multilib && $relative_dir eq '.')
3348 $output_rules .= &file_contents ('multilib');
3354 # &for_dist_common ($A, $B)
3355 # -------------------------
3356 # Subroutine for &handle_dist: sort files to dist.
3358 # We put README first because it then becomes easier to make a
3359 # Usenet-compliant shar file (in these, README must be first).
3361 # FIXME: do more ordering of files here.
3374 # handle_dist ($MAKEFILE)
3375 # -----------------------
3376 # Handle 'dist' target.
3379 my ($makefile) = @_;
3381 # `make dist' isn't used in a Cygnus-style tree.
3382 # Omit the rules so that people don't try to use them.
3383 return if $cygnus_mode;
3385 # Look for common files that should be included in distribution.
3386 # If the aux dir is set, and it does not have a Makefile.am, then
3387 # we check for these files there as well.
3390 if ($relative_dir eq '.'
3391 && $config_aux_dir_set_in_configure_in)
3393 ($auxdir = $config_aux_dir) =~ s,^\$\(top_srcdir\)/,,;
3394 if (! &is_make_dir ($auxdir))
3399 foreach my $cfile (@common_files)
3401 if (-f ($relative_dir . "/" . $cfile))
3403 &push_dist_common ($cfile);
3406 # Don't use `elsif' here because a file might meaningfully
3407 # appear in both directories.
3408 if ($check_aux && -f ($auxdir . '/' . $cfile))
3410 &push_dist_common ($auxdir . '/' . $cfile);
3414 # We might copy elements from $configure_dist_common to
3415 # %dist_common if we think we need to. If the file appears in our
3416 # directory, we would have discovered it already, so we don't
3417 # check that. But if the file is in a subdir without a Makefile,
3418 # we want to distribute it here if we are doing `.'. Ugly!
3419 if ($relative_dir eq '.')
3421 foreach my $file (split (' ' , $configure_dist_common))
3423 if (! &is_make_dir (dirname ($file)))
3425 &push_dist_common ($file);
3432 # Files to distributed. Don't use &variable_value_as_list_recursive
3433 # as it recursively expands `$(dist_pkgdata_DATA)' etc.
3434 check_variable_defined_unconditionally ('DIST_COMMON');
3435 my @dist_common = split (' ', variable_value ('DIST_COMMON', 'TRUE'));
3436 @dist_common = uniq (sort for_dist_common (@dist_common));
3437 pretty_print ('DIST_COMMON = ', "\t", @dist_common);
3439 # Now that we've processed DIST_COMMON, disallow further attempts
3441 $handle_dist_run = 1;
3443 # Scan EXTRA_DIST to see if we need to distribute anything from a
3444 # subdir. If so, add it to the list. I didn't want to do this
3445 # originally, but there were so many requests that I finally
3447 if (&variable_defined ('EXTRA_DIST'))
3449 # FIXME: This should be fixed to work with conditionals. That
3450 # will require only making the entries in %dist_dirs under the
3451 # appropriate condition. This is meaningful if the nature of
3452 # the distribution should depend upon the configure options
3454 foreach (&variable_value_as_list_recursive ('EXTRA_DIST', ''))
3457 next unless s,/+[^/]+$,,;
3463 # We have to check DIST_COMMON for extra directories in case the
3464 # user put a source used in AC_OUTPUT into a subdir.
3465 foreach (&variable_value_as_list_recursive ('DIST_COMMON', 'all'))
3468 next unless s,/+[^/]+$,,;
3473 # Rule to check whether a distribution is viable.
3474 my %transform = ('DISTCHECK-HOOK' => &target_defined ('distcheck-hook'),
3475 'GETTEXT' => $seen_gettext);
3477 # Prepend $(distdir) to each directory given.
3478 my %rewritten = map { '$(distdir)/' . "$_" => 1 } keys %dist_dirs;
3479 $transform{'DISTDIRS'} = join (' ', sort keys %rewritten);
3481 # If we have SUBDIRS, create all dist subdirectories and do
3483 if (&variable_defined ('SUBDIRS'))
3485 # If SUBDIRS is conditionally defined, then set DIST_SUBDIRS
3486 # to all possible directories, and use it. If DIST_SUBDIRS is
3487 # defined, just use it.
3488 my $dist_subdir_name;
3489 # Note that we check DIST_SUBDIRS first on purpose. At least
3490 # one project uses so many conditional subdirectories that
3491 # calling variable_conditionally_defined on SUBDIRS will cause
3492 # automake to grow to 150Mb. Sigh.
3493 if (&variable_defined ('DIST_SUBDIRS')
3494 || variable_conditionally_defined ('SUBDIRS'))
3496 $dist_subdir_name = 'DIST_SUBDIRS';
3497 if (! &variable_defined ('DIST_SUBDIRS'))
3499 define_pretty_variable
3500 ('DIST_SUBDIRS', '',
3501 uniq (&variable_value_as_list_recursive ('SUBDIRS', 'all')));
3506 $dist_subdir_name = 'SUBDIRS';
3507 # We always define this because that is what `distclean'
3509 define_pretty_variable ('DIST_SUBDIRS', '', '$(SUBDIRS)');
3512 $transform{'DIST_SUBDIR_NAME'} = $dist_subdir_name;
3515 # If the target `dist-hook' exists, make sure it is run. This
3516 # allows users to do random weird things to the distribution
3517 # before it is packaged up.
3518 push (@dist_targets, 'dist-hook')
3519 if &target_defined ('dist-hook');
3520 $transform{'DIST-TARGETS'} = join(' ', @dist_targets);
3522 # Defining $(DISTDIR).
3523 $transform{'DISTDIR'} = !&variable_defined('distdir');
3524 $transform{'TOP_DISTDIR'} = backname ($relative_dir);
3526 $output_rules .= &file_contents ('distdir', %transform);
3530 # Handle subdirectories.
3534 unless &variable_defined ('SUBDIRS');
3536 # Make sure each directory mentioned in SUBDIRS actually exists.
3537 foreach my $dir (&variable_value_as_list_recursive ('SUBDIRS', 'all'))
3539 # Skip directories substituted by configure.
3540 next if $dir =~ /^\@.*\@$/;
3542 if (! -d $am_relative_dir . '/' . $dir)
3544 am_macro_error ('SUBDIRS',
3545 "required directory $am_relative_dir/$dir does not exist");
3549 am_macro_error ('SUBDIRS', "directory should not contain `/'")
3553 $output_rules .= &file_contents ('subdirs');
3554 variable_pretty_output ('RECURSIVE_TARGETS', 'TRUE');
3558 # ($REGEN, @DEPENDENCIES)
3561 # If aclocal.m4 creation is automated, return the list of its dependencies.
3564 my $regen_aclocal = 0;
3567 unless $relative_dir eq '.';
3569 &examine_variable ('CONFIG_STATUS_DEPENDENCIES');
3570 &examine_variable ('CONFIGURE_DEPENDENCIES');
3572 if (-f 'aclocal.m4')
3574 &define_variable ("ACLOCAL_M4", '$(top_srcdir)/aclocal.m4');
3575 &push_dist_common ('aclocal.m4');
3577 my $aclocal = new IO::File ("< aclocal.m4");
3580 my $line = $aclocal->getline;
3583 if ($line =~ 'generated automatically by aclocal')
3592 if (-f 'acinclude.m4')
3595 push @ac_deps, 'acinclude.m4';
3598 if (&variable_defined ('ACLOCAL_M4_SOURCES'))
3600 push (@ac_deps, '$(ACLOCAL_M4_SOURCES)');
3602 elsif (&variable_defined ('ACLOCAL_AMFLAGS'))
3604 # Scan all -I directories for m4 files. These are our
3606 my $examine_next = 0;
3607 foreach my $amdir (&variable_value_as_list_recursive ('ACLOCAL_AMFLAGS', ''))
3612 if ($amdir !~ /^\// && -d $amdir)
3614 foreach my $ac_dep (&my_glob ($amdir . '/*.m4'))
3616 $ac_dep =~ s/^\.\/+//;
3617 push (@ac_deps, $ac_dep)
3618 unless $ac_dep eq "aclocal.m4"
3619 || $ac_dep eq "acinclude.m4";
3623 elsif ($amdir eq '-I')
3630 # Note that it might be possible that aclocal.m4 doesn't exist but
3631 # should be auto-generated. This case probably isn't very
3634 return ($regen_aclocal, @ac_deps);
3637 # Rewrite a list of input files into a form suitable to put on a
3638 # dependency list. The idea is that if an input file has a directory
3639 # part the same as the current directory, then the directory part is
3640 # simply removed. But if the directory part is different, then
3641 # $(top_srcdir) is prepended. Among other things, this is used to
3642 # generate the dependency list for the output files generated by
3643 # AC_OUTPUT. Consider what the dependencies should look like in this
3645 # AC_OUTPUT(src/out:src/in1:lib/in2)
3646 # The first argument, ADD_SRCDIR, is 1 if $(top_srcdir) should be added.
3647 # If 0 then files that require this addition will simply be ignored.
3648 sub rewrite_inputs_into_dependencies
3650 my ($add_srcdir, @inputs) = @_;
3653 foreach my $single (@inputs)
3655 if (dirname ($single) eq $relative_dir)
3657 push (@newinputs, basename ($single));
3661 push (@newinputs, '$(top_srcdir)/' . $single);
3668 # Handle remaking and configure stuff.
3669 # We need the name of the input file, to do proper remaking rules.
3670 sub handle_configure
3672 my ($local, $input, @secondary_inputs) = @_;
3674 my $input_base = basename ($input);
3675 my $local_base = basename ($local);
3677 my $amfile = $input_base . '.am';
3678 # We know we can always add '.in' because it really should be an
3679 # error if the .in was missing originally.
3680 my $infile = '$(srcdir)/' . $input_base . '.in';
3681 my $colon_infile = '';
3682 if ($local ne $input || @secondary_inputs)
3684 $colon_infile = ':' . $input . '.in';
3686 $colon_infile .= ':' . join (':', @secondary_inputs)
3687 if @secondary_inputs;
3689 my @rewritten = &rewrite_inputs_into_dependencies (1, @secondary_inputs);
3691 my ($regen_aclocal_m4, @aclocal_m4_deps) = scan_aclocal_m4 ();
3694 &file_contents ('configure',
3698 => join (' ', @rewritten),
3700 => ((($relative_dir eq '.') ? '$@' : '$(subdir)/$@')
3705 => join (' ', @include_stack),
3709 => $cygnus_mode ? 'cygnus' : $strictness_name,
3711 => $cmdline_use_dependencies ? '' : ' --ignore-deps',
3712 'MAKEFILE-AM-SOURCES'
3713 => "$input$colon_infile",
3715 => $regen_aclocal_m4,
3717 => join (' ', @aclocal_m4_deps)));
3719 if ($relative_dir eq '.')
3721 &push_dist_common ('acconfig.h')
3725 # If we have a configure header, require it.
3726 my @local_fullnames = @config_fullnames;
3727 my @local_names = @config_names;
3729 my $distclean_config = '';
3730 foreach my $one_hdr (@config_headers)
3732 my $one_fullname = shift (@local_fullnames);
3733 my $one_name = shift (@local_names);
3735 my $header_dir = dirname ($one_name);
3737 # If the header is in the current directory we want to build
3738 # the header here. Otherwise, if we're at the topmost
3739 # directory and the header's directory doesn't have a
3740 # Makefile, then we also want to build the header.
3741 if ($relative_dir eq $header_dir
3742 || ($relative_dir eq '.' && ! &is_make_dir ($header_dir)))
3744 my ($cn_sans_dir, $stamp_dir);
3745 if ($relative_dir eq $header_dir)
3747 $cn_sans_dir = basename ($one_name);
3752 $cn_sans_dir = $one_name;
3753 if ($header_dir eq '.')
3759 $stamp_dir = $header_dir . '/';
3763 # Compute relative path from directory holding output
3764 # header to directory holding input header. FIXME:
3765 # doesn't handle case where we have multiple inputs.
3767 if (dirname ($one_hdr) eq $relative_dir)
3769 $ch_sans_dir = basename ($one_hdr);
3773 $ch_sans_dir = backname ($relative_dir) . '/' . $one_hdr;
3776 require_file ($config_header_location, $FOREIGN, $ch_sans_dir);
3778 # Header defined and in this directory.
3780 if (-f $one_name . '.top')
3782 push (@files, "${cn_sans_dir}.top");
3784 if (-f $one_name . '.bot')
3786 push (@files, "${cn_sans_dir}.bot");
3789 &push_dist_common (@files);
3791 # For now, acconfig.h can only appear in the top srcdir.
3792 if (-f 'acconfig.h')
3794 push (@files, '$(top_srcdir)/acconfig.h');
3797 my $stamp_name = 'stamp-h';
3798 $stamp_name .= "${hdr_index}";
3800 my $out_dir = dirname ($ch_sans_dir);
3803 &file_contents ('remake-hdr',
3804 ('FILES' => join (' ', @files),
3805 'CONFIG_HEADER' => $cn_sans_dir,
3806 'CONFIG_HEADER_IN' => $ch_sans_dir,
3807 'CONFIG_HEADER_FULL' => $one_fullname,
3808 'STAMP' => "$stamp_dir$stamp_name",
3809 'SRC_STAMP' => "$out_dir/$stamp_name"));
3811 &create ("${relative_dir}/${out_dir}/${stamp_name}.in");
3812 require_file ($config_header_location, $FOREIGN,
3813 "${out_dir}/${stamp_name}.in");
3815 $distclean_config .= ' ' if $distclean_config;
3816 $distclean_config .= $cn_sans_dir;
3820 if ($distclean_config)
3822 $output_rules .= &file_contents ('clean-hdr',
3823 ('FILES' => $distclean_config));
3826 # Set location of mkinstalldirs.
3827 &define_variable ('mkinstalldirs',
3828 ('$(SHELL) ' . $config_aux_dir . '/mkinstalldirs'));
3830 am_macro_error ('CONFIG_HEADER',
3831 "`CONFIG_HEADER' is an anachronism; now determined from `$configure_ac'")
3832 if &variable_defined ('CONFIG_HEADER');
3834 my $config_header = '';
3835 foreach my $one_name (@config_names)
3837 # Generate CONFIG_HEADER define.
3839 if ($relative_dir eq dirname ($one_name))
3841 $one_hdr = basename ($one_name);
3845 $one_hdr = "\$(top_builddir)/${one_name}";
3848 $config_header .= ' ' if $config_header;
3849 $config_header .= $one_hdr;
3853 &define_variable ("CONFIG_HEADER", $config_header);
3856 # Now look for other files in this directory which must be remade
3857 # by config.status, and generate rules for them.
3858 my @actual_other_files = ();
3859 foreach my $lfile (@other_input_files)
3862 my (@inputs, @rewritten_inputs);
3863 my ($need_rewritten);
3864 if ($lfile =~ /^([^:]*):(.*)$/)
3866 # This is the ":" syntax of AC_OUTPUT.
3868 $local = basename ($file);
3869 @inputs = split (':', $2);
3870 @rewritten_inputs = &rewrite_inputs_into_dependencies (1, @inputs);
3871 $need_rewritten = 1;
3877 $local = basename ($file);
3878 @inputs = ($file . '.in');
3880 &rewrite_inputs_into_dependencies (1, @inputs);
3881 $need_rewritten = 0;
3884 # Make sure the dist directory for each input file is created.
3885 # We only have to do this at the topmost level though. This
3886 # is a bit ugly but it easier than spreading out the logic,
3887 # especially in cases like AC_OUTPUT(foo/out:bar/in), where
3888 # there is no Makefile in bar/.
3889 if ($relative_dir eq '.')
3893 $dist_dirs{dirname ($_)} = 1;
3897 # We skip any automake input files, as they are handled
3898 # elsewhere. We also skip files that aren't in this
3899 # directory. However, if the file's directory does not have a
3900 # Makefile, and we are currently doing `.', then we create a
3901 # rule to rebuild the file in the subdir.
3902 next if -f $file . '.am';
3903 my $fd = dirname ($file);
3904 if ($fd ne $relative_dir)
3906 if ($relative_dir eq '.' && ! &is_make_dir ($fd))
3916 # Some users have been tempted to put `stamp-h' in the
3917 # AC_OUTPUT line. This won't do the right thing, so we
3918 # explicitly fail here.
3919 if ($local eq 'stamp-h')
3921 # FIXME: allow real filename.
3922 am_file_error ($ac_output_location,
3923 'stamp-h should not appear in AC_OUTPUT');
3927 $output_rules .= ($local . ': '
3928 . '$(top_builddir)/config.status '
3929 . join (' ', @rewritten_inputs) . "\n"
3931 . 'cd $(top_builddir) && CONFIG_FILES='
3932 . ($relative_dir eq '.' ? '' : '$(subdir)/')
3933 . '$@' . ($need_rewritten
3934 ? (':' . join (':', @inputs))
3936 . ' CONFIG_HEADERS= CONFIG_LINKS= $(SHELL) ./config.status'
3938 push (@actual_other_files, $local);
3940 # Require all input files.
3941 require_file ($ac_output_location, $FOREIGN,
3942 &rewrite_inputs_into_dependencies (0, @inputs));
3945 # These files get removed by "make clean".
3946 define_pretty_variable ('CONFIG_CLEAN_FILES', '', @actual_other_files);
3952 my @r = &am_install_var ('-defaultdist', 'header', 'HEADERS', 'include',
3953 'oldinclude', 'pkginclude',
3957 next unless /\.(.*)$/;
3958 &saw_extension ($1);
3964 return if ! $seen_gettext || $relative_dir ne '.';
3966 if (! &variable_defined ('SUBDIRS'))
3969 ("AM_GNU_GETTEXT used but SUBDIRS not defined");
3973 my @subdirs = &variable_value_as_list_recursive ('SUBDIRS', 'all');
3974 am_macro_error ('SUBDIRS',
3975 "AM_GNU_GETTEXT used but `po' not in SUBDIRS")
3976 if ! grep ('po', @subdirs);
3977 am_macro_error ('SUBDIRS',
3978 "AM_GNU_GETTEXT used but `intl' not in SUBDIRS")
3979 if ! grep ('intl', @subdirs);
3981 require_file ($ac_gettext_location, $GNU, 'ABOUT-NLS');
3984 # Handle footer elements.
3987 # NOTE don't use define_pretty_variable here, because
3988 # $contents{...} is already defined.
3989 $output_vars .= 'SOURCES = ' . variable_value ('SOURCES') . "\n\n"
3990 if variable_value ('SOURCES');
3993 am_target_error ('.SUFFIXES',
3994 "use variable `SUFFIXES', not target `.SUFFIXES'")
3995 if target_defined ('.SUFFIXES');
3997 # Note: AIX 4.1 /bin/make will fail if any suffix rule appears
3998 # before .SUFFIXES. So we make sure that .SUFFIXES appears before
3999 # anything else, by sticking it right after the default: target.
4000 $output_header .= ".SUFFIXES:\n";
4001 if (@suffixes || &variable_defined ('SUFFIXES'))
4003 # Make sure suffixes has unique elements. Sort them to ensure
4004 # the output remains consistent. However, $(SUFFIXES) is
4005 # always at the start of the list, unsorted. This is done
4006 # because make will choose rules depending on the ordering of
4007 # suffixes, and this lets the user have some control. Push
4008 # actual suffixes, and not $(SUFFIXES). Some versions of make
4009 # do not like variable substitutions on the .SUFFIXES line.
4010 my @user_suffixes = (&variable_defined ('SUFFIXES')
4011 ? &variable_value_as_list_recursive ('SUFFIXES', '')
4014 my %suffixes = map { $_ => 1 } @suffixes;
4015 delete @suffixes{@user_suffixes};
4017 $output_header .= (".SUFFIXES: "
4018 . join (' ', @user_suffixes, sort keys %suffixes)
4022 $output_trailer .= file_contents ('footer');
4025 # Deal with installdirs target.
4026 sub handle_installdirs ()
4029 &file_contents ('install',
4031 => variable_value ('_am_installdirs') || ''));
4035 # Deal with all and all-am.
4038 my ($makefile) = @_;
4042 # Put this at the beginning for the sake of non-GNU makes. This
4043 # is still wrong if these makes can run parallel jobs. But it is
4045 unshift (@all, basename ($makefile));
4047 foreach my $one_name (@config_names)
4049 push (@all, basename ($one_name))
4050 if dirname ($one_name) eq $relative_dir;
4053 # Install `all' hooks.
4054 if (&target_defined ("all-local"))
4056 push (@all, "all-local");
4057 &depend ('.PHONY', "all-local");
4060 &pretty_print_rule ("all-am:", "\t\t", @all);
4061 &depend ('.PHONY', 'all-am', 'all');
4066 my @local_headers = ();
4067 push @local_headers, '$(BUILT_SOURCES)'
4068 if &variable_defined ('BUILT_SOURCES');
4069 foreach my $one_name (@config_names)
4071 push @local_headers, basename ($one_name)
4072 if dirname ($one_name) eq $relative_dir;
4077 # We need to make sure config.h is built before we recurse.
4078 # We also want to make sure that built sources are built
4079 # before any ordinary `all' targets are run. We can't do this
4080 # by changing the order of dependencies to the "all" because
4081 # that breaks when using parallel makes. Instead we handle
4082 # things explicitly.
4083 $output_all .= ("all: " . join (' ', @local_headers)
4085 . '$(MAKE) $(AM_MAKEFLAGS) '
4086 . (&variable_defined ('SUBDIRS')
4087 ? 'all-recursive' : 'all-am')
4092 $output_all .= "all: " . (&variable_defined ('SUBDIRS')
4093 ? 'all-recursive' : 'all-am') . "\n\n";
4098 # Handle check merge target specially.
4099 sub do_check_merge_target
4101 if (&target_defined ('check-local'))
4103 # User defined local form of target. So include it.
4104 push (@check_tests, 'check-local');
4105 &depend ('.PHONY', 'check-local');
4108 # In --cygnus mode, check doesn't depend on all.
4111 # Just run the local check rules.
4112 &pretty_print_rule ('check-am:', "\t\t", @check);
4116 # The check target must depend on the local equivalent of
4117 # `all', to ensure all the primary targets are built. Then it
4118 # must build the local check rules.
4119 $output_rules .= "check-am: all-am\n";
4120 &pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ",
4124 &pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ",
4128 &depend ('.PHONY', 'check', 'check-am');
4129 $output_rules .= ("check: "
4130 . (&variable_defined ('SUBDIRS')
4131 ? 'check-recursive' : 'check-am')
4135 # Handle all 'clean' targets.
4140 # Don't include `MAINTAINER'; it is handled specially below.
4141 foreach my $name ('MOSTLY', '', 'DIST')
4143 $transform{"${name}CLEAN"} = &variable_defined ("${name}CLEANFILES");
4146 # Built sources are automatically removed by maintainer-clean.
4147 push (@maintainer_clean_files, '$(BUILT_SOURCES)')
4148 if &variable_defined ('BUILT_SOURCES');
4149 push (@maintainer_clean_files, '$(MAINTAINERCLEANFILES)')
4150 if &variable_defined ('MAINTAINERCLEANFILES');
4152 $output_rules .= &file_contents ('clean',
4155 # Join with no space to avoid
4156 # spurious `test -z' success at
4158 => join ('', @maintainer_clean_files),
4160 # A space is required in the join here.
4161 => join (' ', @maintainer_clean_files)));
4165 # &depend ($CATEGORY, @DEPENDENDEES)
4166 # ----------------------------------
4167 # The target $CATEGORY depends on @DEPENDENDEES.
4170 my ($category, @dependendees) = @_;
4172 push (@{$dependencies{$category}}, @dependendees);
4177 # &target_cmp ($A, $B)
4178 # --------------------
4179 # Subroutine for &handle_factored_dependencies to let `.PHONY' be last.
4192 # &handle_factored_dependencies ()
4193 # --------------------------------
4194 # Handle everything related to gathered targets.
4195 sub handle_factored_dependencies
4198 foreach my $utarg ('uninstall-data-local', 'uninstall-data-hook',
4199 'uninstall-exec-local', 'uninstall-exec-hook')
4201 if (&target_defined ($utarg))
4204 $x =~ s/(data|exec)-//;
4205 am_target_error ($utarg, "use `$x', not `$utarg'");
4209 if (&target_defined ('install-local'))
4211 am_target_error ('install-local',
4212 "use `install-data-local' or `install-exec-local', "
4213 . "not `install-local'");
4216 if (!defined $options{'no-installinfo'}
4217 && &target_defined ('install-info-local'))
4219 am_target_error ('install-info-local',
4220 "`install-info-local' target defined but "
4221 . "`no-installinfo' option not in use");
4224 # Install the -local hooks.
4225 foreach (keys %dependencies)
4227 # Hooks are installed on the -am targets.
4229 if (&target_defined ("$_-local"))
4231 depend ("$_-am", "$_-local");
4232 &depend ('.PHONY', "$_-local");
4236 # Install the -hook hooks.
4237 # FIXME: Why not be as liberal as we are with -local hooks?
4238 foreach ('install-exec', 'install-data')
4240 if (&target_defined ("$_-hook"))
4242 $actions{"$_-am"} .=
4243 ("\t\@\$(NORMAL_INSTALL)\n"
4244 . "\t" . '$(MAKE) $(AM_MAKEFLAGS) ' . "$_-hook\n");
4248 # All the required targets are phony.
4249 depend ('.PHONY', keys %required_targets);
4251 # Actually output gathered targets.
4252 foreach (sort target_cmp keys %dependencies)
4254 # If there is nothing about this guy, skip it.
4256 unless (@{$dependencies{$_}}
4258 || $required_targets{$_});
4259 &pretty_print_rule ("$_:", "\t",
4260 uniq (sort @{$dependencies{$_}}));
4261 $output_rules .= $actions{$_}
4262 if defined $actions{$_};
4263 $output_rules .= "\n";
4268 # &handle_tests_dejagnu ()
4269 # ------------------------
4270 sub handle_tests_dejagnu
4272 push (@check_tests, 'check-DEJAGNU');
4273 $output_rules .= file_contents ('dejagnu');
4277 # Handle TESTS variable and other checks.
4280 if (defined $options{'dejagnu'})
4282 &handle_tests_dejagnu;
4286 foreach my $c ('DEJATOOL', 'RUNTEST', 'RUNTESTFLAGS')
4289 "`$c' defined but `dejagnu' not in `AUTOMAKE_OPTIONS'")
4290 if &variable_defined ($c);
4294 if (&variable_defined ('TESTS'))
4296 push (@check_tests, 'check-TESTS');
4297 $output_rules .= &file_contents ('check');
4301 # Handle Emacs Lisp.
4302 sub handle_emacs_lisp
4304 my @elfiles = &am_install_var ('-candist', 'lisp', 'LISP',
4307 return if ! @elfiles;
4309 # Generate .elc files.
4310 my @elcfiles = map { $_ . 'c' } @elfiles;
4311 define_pretty_variable ('ELCFILES', '', @elcfiles);
4313 push (@all, '$(ELCFILES)');
4315 &am_error ("`lisp_LISP' defined but `AM_PATH_LISPDIR' not in `$configure_ac'")
4316 if ! $seen_lispdir && &variable_defined ('lisp_LISP');
4318 &require_conf_file_with_conf_line ('AM_PATH_LISPDIR',
4319 $FOREIGN, 'elisp-comp');
4320 &define_variable ('elisp_comp', $config_aux_dir . '/elisp-comp');
4326 my @pyfiles = &am_install_var ('-defaultdist', 'python', 'PYTHON',
4327 'python', 'noinst');
4328 return if ! @pyfiles;
4330 # Found some python.
4331 &am_error ("`python_PYTHON' defined but `AM_PATH_PYTHON' not in `$configure_ac'")
4332 if ! $seen_pythondir && &variable_defined ('python_PYTHON');
4334 &require_conf_file_with_conf_line ('AM_PATH_PYTHON',
4335 $FOREIGN, 'py-compile');
4336 &define_variable ('py_compile', $config_aux_dir . '/py-compile');
4342 my @sourcelist = &am_install_var ('-candist',
4344 'java', 'noinst', 'check');
4345 return if ! @sourcelist;
4347 my %valid = &am_primary_prefixes ('JAVA', 1,
4348 'java', 'noinst', 'check');
4351 foreach my $curs (keys %valid)
4353 if (! &variable_defined ($curs . '_JAVA') || $curs eq 'EXTRA')
4360 am_macro_error ($curs . '_JAVA',
4361 "multiple _JAVA primaries in use");
4366 push (@all, 'class' . $dir . '.stamp');
4370 # Handle some of the minor options.
4371 sub handle_minor_options
4373 if (defined $options{'readme-alpha'})
4375 if ($relative_dir eq '.')
4377 if ($package_version !~ /^$GNITS_VERSION_PATTERN$/)
4379 # FIXME: allow real filename.
4380 &am_file_error ($package_version_location,
4381 "version `$package_version' doesn't follow Gnits standards");
4383 elsif (defined $1 && -f 'README-alpha')
4385 # This means we have an alpha release. See
4386 # GNITS_VERSION_PATTERN for details.
4387 require_file_with_macro ('AUTOMAKE_OPTIONS',
4388 $FOREIGN, 'README-alpha');
4394 ################################################################
4398 # &scan_autoconf_config_files ($CONFIG-FILES)
4399 # -------------------------------------------
4400 # Study $CONFIG-FILES which is the first argument to AC_CONFIG_FILES
4402 sub scan_autoconf_config_files
4404 my ($config_files) = @_;
4405 # Look at potential Makefile.am's.
4406 foreach (split ' ', $config_files)
4408 # Must skip empty string for Perl 4.
4409 next if $_ eq "\\" || $_ eq '';
4411 # Handle $local:$input syntax. Note that we ignore
4412 # every input file past the first, though we keep
4413 # those around for later.
4414 my ($local, $input, @rest) = split (/:/);
4421 # FIXME: should be error if .in is missing.
4422 $input =~ s/\.in$//;
4425 if (-f $input . '.am')
4427 # We have a file that automake should generate.
4428 $make_list{$input} = join (':', ($local, @rest));
4432 # We have a file that automake should cause to be
4433 # rebuilt, but shouldn't generate itself.
4434 push (@other_input_files, $_);
4440 # &scan_autoconf_traces ($FILENAME)
4441 # ---------------------------------
4442 # FIXME: For the time being, we don't care about the FILENAME.
4443 sub scan_autoconf_traces ($)
4445 my ($filename) = @_;
4448 'AC_CANONICAL_HOST',
4449 'AC_CANONICAL_SYSTEM',
4450 'AC_CONFIG_AUX_DIR',
4453 'AC_PROG_LIBTOOL', 'AM_PROG_LIBTOOL',
4461 'AM_MAINTAINER_MODE',
4467 my $traces = "$ENV{amtraces} ";
4469 # Use a separator unlikely to be used, not `:', the default, which
4470 # has a precise meaning for AC_CONFIG_FILES and so on.
4471 $traces .= join (' ',
4472 map { "--trace=$_" . ':\$f::\$l::\$n::\${::}%' } @traced);
4474 my $tracefh = new Automake::XFile ("$traces |");
4475 verbose "reading $traces";
4477 while ($_ = $tracefh->getline)
4480 my ($file, $line, @args) = split /::/;
4481 my $macro = $args[0];
4482 my $here = "$file:$line";
4484 # Alphabetical ordering please.
4485 if ($macro eq 'AC_CANONICAL_HOST')
4487 $seen_canonical = $AC_CANONICAL_HOST
4488 if ! $seen_canonical;
4490 elsif ($macro eq 'AC_CANONICAL_SYSTEM')
4492 $seen_canonical = $AC_CANONICAL_SYSTEM;
4494 elsif ($macro eq 'AC_CONFIG_AUX_DIR')
4496 @config_aux_path = $args[1];
4497 $config_aux_dir_set_in_configure_in = 1;
4499 elsif ($macro eq 'AC_CONFIG_FILES')
4501 # Look at potential Makefile.am's.
4502 &scan_autoconf_config_files ($args[1]);
4504 elsif ($macro eq 'AC_LIBSOURCE')
4506 # We should actually also `close' the sources: getopt.c
4507 # wants getopt.h etc. But actually it should be done in the
4508 # macro itself, i.e., we have to first fix Autoconf to extend
4509 # _AC_LIBOBJ_DECL and use it the in various macros.
4510 $libsources{$args[1]} = $here;
4512 elsif ($macro =~ /A(C|M)_PROG_LIBTOOL/)
4514 $seen_libtool = $here;
4515 $libtool_line = $line;
4517 elsif ($macro =~ /AC_PROG_LEX/)
4519 $seen_prog_lex = $here;
4521 elsif ($macro eq 'AC_SUBST')
4523 # Just check for alphanumeric in AC_SUBST. If you do
4524 # AC_SUBST(5), then too bad.
4525 $configure_vars{$args[1]} = $here
4526 if $args[1] =~ /^\w+$/;
4528 elsif ($macro eq 'AM_CONDITIONAL')
4530 $configure_cond{$args[1]} = $here;
4532 elsif ($macro eq 'AM_CONFIG_HEADER')
4534 $config_header_location = $here;
4535 foreach my $one_hdr (split (' ', $args[1]))
4537 push (@config_fullnames, $one_hdr);
4538 if ($one_hdr =~ /^([^:]+):(.+)$/)
4540 push (@config_names, $1);
4541 push (@config_headers, $2);
4545 push (@config_names, $one_hdr);
4546 push (@config_headers, $one_hdr . '.in');
4550 elsif ($macro eq 'AM_C_PROTOTYPES')
4552 $am_c_prototypes = $here;
4554 elsif ($macro eq 'AM_GNU_GETTEXT')
4556 $seen_gettext = $here;
4557 $ac_gettext_location = $here;
4559 elsif ($macro eq 'AM_INIT_AUTOMAKE')
4561 $package_version = $args[2];
4562 $package_version_location = $here;
4563 $seen_init_automake = 1;
4565 elsif ($macro eq 'AM_MAINTAINER_MODE')
4567 $seen_maint_mode = $here;
4569 elsif ($macro eq 'AM_PATH_LISPDIR')
4571 $seen_lispdir = $here;
4573 elsif ($macro eq 'AM_PATH_PYTHON')
4575 $seen_pythondir = $here;
4577 elsif ($macro eq 'AM_PROG_CC_C_O')
4579 $seen_cc_c_o = $here;
4585 # &scan_one_autoconf_file ($FILENAME)
4586 # -----------------------------------
4587 # Scan one file for interesting things. Subroutine of
4588 # &scan_autoconf_files.
4589 sub scan_one_autoconf_file
4591 my ($filename) = @_;
4593 # Some macros already provide the right traces to enable generic
4594 # code and specific arguments, instead of dedicated code. But
4595 # currently we don't handle traces. Rewrite these dedicated
4596 # macros handling into the generic macro invocation, and let our
4597 # generic case handle them.
4601 'AC_FUNC_ALLOCA' => 'AC_LIBSOURCES([alloca.c])',
4602 'AC_FUNC_GETLOADAVG' => 'AC_LIBSOURCES([getloadavg.c])',
4603 'AC_FUNC_MEMCMP' => 'AC_LIBSOURCES([memcmp.c])',
4604 'AC_STRUCT_ST_BLOCKS' => 'AC_LIBSOURCES([fileblocks.c])',
4605 'A[CM]_REPLACE_GNU_GETOPT' => 'AC_LIBSOURCES([getopt.c, getopt1.c])',
4606 'A[CM]_FUNC_STRTOD' => 'AC_LIBSOURCES([strtod.c])',
4607 'AM_WITH_REGEX' => 'AC_LIBSOURCES([rx.c, rx.h, regex.c, regex.h])',
4608 'AC_FUNC_MKTIME' => 'AC_LIBSOURCES([mktime.c])',
4609 'A[CM]_FUNC_ERROR_AT_LINE' => 'AC_LIBSOURCES([error.c, error.h])',
4610 'A[CM]_FUNC_OBSTACK' => 'AC_LIBSOURCES([obstack.c, obstack.h])',
4613 my $configfh = new Automake::XFile ("< $filename");
4614 print "$me: reading $filename\n" if $verbose;
4616 my ($in_ac_output, $in_ac_replace) = (0, 0);
4617 while ($_ = $configfh->getline)
4619 # Remove comments from current line.
4623 # Skip macro definitions. Otherwise we might be confused into
4624 # thinking that a macro that was only defined was actually
4628 # Follow includes. This is a weirdness commonly in use at
4629 # Cygnus and hopefully nowhere else.
4630 if (/sinclude\((.*)\)/ && -f $1)
4632 # $_ being local, if we don't preserve it, when coming
4633 # back we will have $_ undefined, which is bad for the
4634 # the rest of this routine.
4635 my $underscore = $_;
4636 &scan_one_autoconf_file ($1);
4640 for my $generalize (keys %generalize)
4642 s/$generalize/$generalize{$generalize}/g;
4646 my $here = "$filename:$.";
4648 # Populate libobjs array.
4649 if (/LIBOBJS="(.*)\s+\$LIBOBJS"/
4650 || /LIBOBJS="\$LIBOBJS\s+(.*)"/)
4652 foreach my $libobj_iter (split (' ', $1))
4654 if ($libobj_iter =~ /^(.*)\.o(bj)?$/
4655 || $libobj_iter =~ /^(.*)\.\$ac_objext$/
4656 || $libobj_iter =~ /^(.*)\.\$\{ac_objext\}$/)
4658 $libsources{$1 . '.c'} = $here;
4662 elsif (/AC_LIBOBJ\(([^)]+)\)/)
4664 $libsources{"$1.c"} = $here;
4666 elsif (/AC_LIBSOURCE\(([^)]+)\)/)
4668 $libsources{&unquote_m4_arg ($1)} = $here;
4670 elsif (/AC_LIBSOURCES\(([^)]+)\)/)
4672 foreach my $lc_iter (split (/[, ]+/, &unquote_m4_arg ($1)))
4674 $libsources{$lc_iter} = $here;
4678 if (! $in_ac_replace && s/AC_REPLACE_FUNCS\s*\(\[?//)
4684 $in_ac_replace = 0 if s/[\]\)].*$//;
4685 # Remove trailing backslash.
4689 # Need to skip empty elements for Perl 4.
4691 $libsources{$_ . '.c'} = $here;
4695 if (/$obsolete_rx/o)
4698 if ($obsolete_macros{$1} ne '')
4700 $hint = '; ' . $obsolete_macros{$1};
4702 &am_file_error ($here, "`$1' is obsolete$hint");
4705 # Process the AC_OUTPUT and AC_CONFIG_FILES macros.
4706 if (! $in_ac_output && s/AC_(OUTPUT|CONFIG_FILES)\s*\(\[?//)
4709 $ac_output_location = $here;
4720 # Look at potential Makefile.am's.
4721 &scan_autoconf_config_files ($_);
4724 && scalar keys %make_list == 0
4725 && @other_input_files == 0)
4727 am_file_error ($ac_output_location,
4728 "No files mentioned in `AC_OUTPUT'");
4733 if (/$AC_CONFIG_AUX_DIR_PATTERN/o)
4735 @config_aux_path = &unquote_m4_arg ($1);
4736 $config_aux_dir_set_in_configure_in = $here;
4739 # Check for ansi2knr.
4740 $am_c_prototypes = $here if /AM_C_PROTOTYPES/;
4742 # Check for `-c -o' code.
4743 $seen_cc_c_o = $here if /AM_PROG_CC_C_O/;
4745 # Check for NLS support.
4746 if (/AM_GNU_GETTEXT/)
4748 $seen_gettext = $here;
4749 $ac_gettext_location = $here;
4752 # Handle configuration headers. A config header of `[$1]'
4753 # means we are actually scanning AM_CONFIG_HEADER from
4755 if (/A([CM])_CONFIG_HEADERS?\s*\((.*)\)/
4758 &am_file_error ($here,
4759 "`automake requires `AM_CONFIG_HEADER', not `AC_CONFIG_HEADER'")
4762 $config_header_location = $here;
4763 foreach my $one_hdr (split (' ', &unquote_m4_arg ($2)))
4765 push (@config_fullnames, $one_hdr);
4766 if ($one_hdr =~ /^([^:]+):(.+)$/)
4768 push (@config_names, $1);
4769 push (@config_headers, $2);
4773 push (@config_names, $one_hdr);
4774 push (@config_headers, $one_hdr . '.in');
4779 # Handle AC_CANONICAL_*. Always allow upgrading to
4780 # AC_CANONICAL_SYSTEM, but never downgrading.
4781 $seen_canonical = $AC_CANONICAL_HOST
4782 if ! $seen_canonical
4783 && (/AC_CANONICAL_HOST/ || /AC_CHECK_TOOL/);
4784 $seen_canonical = $AC_CANONICAL_SYSTEM if /AC_CANONICAL_SYSTEM/;
4786 # If using X, include some extra variable definitions. NOTE
4787 # we don't want to force these into CFLAGS or anything,
4788 # because not all programs will necessarily use X.
4791 foreach my $var ('X_CFLAGS', 'X_LIBS', 'X_EXTRA_LIBS',
4794 $configure_vars{$var} = $here;
4798 # This macro handles several different things.
4799 if (/$AM_INIT_AUTOMAKE_PATTERN/o)
4801 ($package_version = $1) =~ s/$AM_PACKAGE_VERSION_PATTERN/$1/o;
4802 $package_version_location = $here;
4803 $seen_init_automake = $here;
4808 $configure_vars{'LEX'} = $here;
4809 $seen_prog_lex = $here;
4811 if (/AC_PROG_LEX/ && $filename =~ /configure\.(ac|in)$/)
4813 $configure_vars{'LEX'} = $here;
4814 $seen_prog_lex = $here;
4815 &am_file_warning ($here,
4816 "automake requires `AM_PROG_LEX', not `AC_PROG_LEX'");
4819 if (/AC_PROG_(F77|YACC|RANLIB|CC|CXXCPP|CXX|LEX|AWK|CPP|LN_S)/)
4821 $configure_vars{$1} = $here;
4823 if (/$AC_CHECK_PATTERN/o)
4825 $configure_vars{$3} = $here;
4827 if (/$AM_MISSING_PATTERN/o
4831 && $1 ne 'AUTOHEADER'
4832 # AM_INIT_AUTOMAKE is AM_MISSING_PROG'ing MAKEINFO. But
4833 # we handle it elsewhere.
4834 && $1 ne 'MAKEINFO')
4836 $configure_vars{$1} = $here;
4839 # Explicitly avoid ANSI2KNR -- we AC_SUBST that in protos.m4,
4840 # but later define it elsewhere. This is pretty hacky. We
4841 # also explicitly avoid INSTALL_SCRIPT and some other
4842 # variables because they are defined in header-vars.am.
4843 # AMDEPBACKSLASH might be subst'd by `\', which certainly would
4844 # not be appreciated by Make.
4845 if (/$AC_SUBST_PATTERN/o
4847 && $1 ne 'INSTALL_SCRIPT'
4848 && $1 ne 'INSTALL_DATA'
4849 && $1 ne 'AMDEPBACKSLASH')
4851 $configure_vars{$1} = $here;
4854 if (/AM_MAINTAINER_MODE/)
4856 $seen_maint_mode = $here;
4857 $configure_cond{'MAINTAINER_MODE'} = $here;
4860 $seen_lispdir = 1 if /AM_PATH_LISPDIR/;
4862 if (/AM_PATH_PYTHON/)
4864 $seen_pythondir = $here;
4865 $configure_vars{'pythondir'} = $here;
4866 $configure_vars{'PYTHON'} = $here;
4869 if (/A(C|M)_PROG_LIBTOOL/)
4871 # We're not ready for this yet. People still use a
4872 # libtool with no AC_PROG_LIBTOOL. Once that is the
4873 # dominant version we can reenable this code -- but next
4874 # time by mentioning the macro in %obsolete_macros, both
4875 # here and in aclocal.in.
4877 # if (/AM_PROG_LIBTOOL/)
4879 # &am_file_warning ($here, "`AM_PROG_LIBTOOL' is obsolete, use `AC_PROG_LIBTOOL' instead");
4881 $seen_libtool = $here;
4883 $configure_vars{'LIBTOOL'} = $here;
4884 $configure_vars{'RANLIB'} = $here;
4885 $configure_vars{'CC'} = $here;
4886 # AC_PROG_LIBTOOL runs AC_CANONICAL_HOST. Make sure we
4887 # never downgrade (if we've seen AC_CANONICAL_SYSTEM).
4888 $seen_canonical = $AC_CANONICAL_HOST if ! $seen_canonical;
4891 $seen_multilib = $here if (/AM_ENABLE_MULTILIB/);
4893 if (/$AM_CONDITIONAL_PATTERN/o)
4895 $configure_cond{$1} = $here;
4898 # Check for Fortran 77 intrinsic and run-time libraries.
4899 if (/AC_F77_LIBRARY_LDFLAGS/)
4901 $configure_vars{'FLIBS'} = $here;
4909 # &scan_autoconf_files ()
4910 # -----------------------
4911 # Check whether we use `configure.ac' or `configure.in'.
4912 # Scan it (and possibly `aclocal.m4') for interesting things.
4913 # We must scan aclocal.m4 because there might be AC_SUBSTs and such there.
4914 sub scan_autoconf_files
4916 # Reinitialize libsources here. This isn't really necessary,
4917 # since we currently assume there is only one configure.ac. But
4918 # that won't always be the case.
4921 $configure_ac = find_configure_ac;
4922 die "$me: `configure.ac' or `configure.in' is required\n"
4925 if (defined $ENV{'amtraces'})
4927 print STDERR "$me: Autoconf traces is an experimental feature\n";
4928 print STDERR "$me: use at your own risks\n";
4930 scan_autoconf_traces ($configure_ac);
4934 scan_one_autoconf_file ($configure_ac);
4935 scan_one_autoconf_file ('aclocal.m4')
4939 # Set input and output files if not specified by user.
4942 @input_files = sort keys %make_list;
4943 %output_files = %make_list;
4946 @configure_input_files = sort keys %make_list;
4948 &am_conf_error ("`AM_INIT_AUTOMAKE' must be used")
4949 if ! $seen_init_automake;
4951 # Look for some files we need. Always check for these. This
4952 # check must be done for every run, even those where we are only
4953 # looking at a subdir Makefile. We must set relative_dir so that
4954 # the file-finding machinery works.
4955 # FIXME: Is this broken because it needs dynamic scopes.
4956 # My tests seems to show it's not the case.
4957 $relative_dir = '.';
4958 &require_config_file ($FOREIGN, 'install-sh', 'mkinstalldirs', 'missing');
4959 &am_error ("`install.sh' is an anachronism; use `install-sh' instead")
4960 if -f $config_aux_path[0] . '/install.sh';
4962 &require_config_file ($FOREIGN, 'py-compile')
4965 # Preserve dist_common for later.
4966 $configure_dist_common = variable_value ('DIST_COMMON', 'TRUE') || '';
4969 ################################################################
4971 # Set up for Cygnus mode.
4974 return unless $cygnus_mode;
4976 &set_strictness ('foreign');
4977 $options{'no-installinfo'} = 1;
4978 $options{'no-dependencies'} = 1;
4979 $use_dependencies = 0;
4981 am_conf_error ("`AM_MAINTAINER_MODE' required when --cygnus specified")
4982 if !$seen_maint_mode;
4985 # Do any extra checking for GNU standards.
4986 sub check_gnu_standards
4988 if ($relative_dir eq '.')
4990 # In top level (or only) directory.
4992 $GNU, 'INSTALL', 'NEWS', 'README', 'COPYING',
4993 'AUTHORS', 'ChangeLog');
4996 if ($strictness >= $GNU
4997 && defined $options{'no-installman'})
4999 am_macro_error ('AUTOMAKE_OPTIONS',
5000 "option `no-installman' disallowed by GNU standards");
5003 if ($strictness >= $GNU
5004 && defined $options{'no-installinfo'})
5006 am_macro_error ('AUTOMAKE_OPTIONS',
5007 "option `no-installinfo' disallowed by GNU standards");
5011 # Do any extra checking for GNITS standards.
5012 sub check_gnits_standards
5014 if ($relative_dir eq '.')
5016 # In top level (or only) directory.
5017 require_file ('', $GNITS, 'THANKS');
5021 ################################################################
5023 # Functions to handle files of each language.
5025 # Each `lang_X_rewrite($DIRECTORY, $BASE, $EXT)' function follows a
5026 # simple formula: Return value is $LANG_SUBDIR if the resulting object
5027 # file should be in a subdir if the source file is, $LANG_PROCESS if
5028 # file is to be dealt with, $LANG_IGNORE otherwise.
5030 # Much of the actual processing is handled in
5031 # handle_single_transform_list. These functions exist so that
5032 # auxiliary information can be recorded for a later cleanup pass.
5033 # Note that the calls to these functions are computed, so don't bother
5034 # searching for their precise names in the source.
5036 # This is just a convenience function that can be used to determine
5037 # when a subdir object should be used.
5040 return defined $options{'subdir-objects'} ? $LANG_SUBDIR : $LANG_PROCESS;
5043 # Rewrite a single C source file.
5046 my ($directory, $base, $ext) = @_;
5048 if (defined $options{'ansi2knr'} && $base =~ /_$/)
5050 # FIXME: include line number in error.
5051 &am_error ("C source file `$base.c' would be deleted by ansi2knr rules");
5054 my $r = $LANG_PROCESS;
5055 if (defined $options{'subdir-objects'})
5058 $base = $directory . '/' . $base;
5062 # Only give error once.
5064 # FIXME: line number.
5065 &am_error ("C objects in subdir but `AM_PROG_CC_C_O' not in `$configure_ac'");
5068 &require_conf_file ($FOREIGN, 'compile');
5071 $de_ansi_files{$base} = 1;
5075 # Rewrite a single C++ source file.
5076 sub lang_cxx_rewrite
5078 return &lang_sub_obj;
5081 # Rewrite a single header file.
5082 sub lang_header_rewrite
5084 # Header files are simply ignored.
5085 return $LANG_IGNORE;
5088 # Rewrite a single yacc file.
5089 sub lang_yacc_rewrite
5091 my ($directory, $base, $ext) = @_;
5093 my $r = &lang_sub_obj;
5094 (my $newext = $ext) =~ tr/y/c/;
5095 return ($r, $newext);
5098 # Rewrite a single yacc++ file.
5099 sub lang_yaccxx_rewrite
5101 my ($directory, $base, $ext) = @_;
5103 my $r = &lang_sub_obj;
5104 (my $newext = $ext) =~ tr/y/c/;
5105 return ($r, $newext);
5108 # Rewrite a single lex file.
5109 sub lang_lex_rewrite
5111 my ($directory, $base, $ext) = @_;
5113 my $r = &lang_sub_obj;
5114 (my $newext = $ext) =~ tr/l/c/;
5115 return ($r, $newext);
5118 # Rewrite a single lex++ file.
5119 sub lang_lexxx_rewrite
5121 my ($directory, $base, $ext) = @_;
5123 my $r = &lang_sub_obj;
5124 (my $newext = $ext) =~ tr/l/c/;
5125 return ($r, $newext);
5128 # Rewrite a single assembly file.
5129 sub lang_asm_rewrite
5131 return &lang_sub_obj;
5134 # Rewrite a single Fortran 77 file.
5135 sub lang_f77_rewrite
5137 return $LANG_PROCESS;
5140 # Rewrite a single preprocessed Fortran 77 file.
5141 sub lang_ppf77_rewrite
5143 return $LANG_PROCESS;
5146 # Rewrite a single ratfor file.
5147 sub lang_ratfor_rewrite
5149 return $LANG_PROCESS;
5152 # Rewrite a single Objective C file.
5153 sub lang_objc_rewrite
5155 return &lang_sub_obj;
5158 # Rewrite a single Java file.
5159 sub lang_java_rewrite
5161 return $LANG_SUBDIR;
5164 # The lang_X_finish functions are called after all source file
5165 # processing is done. Each should handle defining rules for the
5166 # language, etc. A finish function is only called if a source file of
5167 # the appropriate type has been seen.
5171 # Push all libobjs files onto de_ansi_files. We actually only
5172 # push files which exist in the current directory, and which are
5173 # genuine source files.
5174 foreach my $file (keys %libsources)
5176 if ($file =~ /^(.*)\.[cly]$/ && -f "$relative_dir/$file")
5178 $de_ansi_files{$1} = 1;
5182 if (defined $options{'ansi2knr'} && keys %de_ansi_files)
5184 # Make all _.c files depend on their corresponding .c files.
5186 foreach my $base (sort keys %de_ansi_files)
5188 # Each _.c file must depend on ansi2knr; otherwise it
5189 # might be used in a parallel build before it is built.
5190 # We need to support files in the srcdir and in the build
5191 # dir (because these files might be auto-generated. But
5192 # we can't use $< -- some makes only define $< during a
5194 $output_rules .= ($base . "_.c: $base.c \$(ANSI2KNR)\n\t"
5195 . '$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) '
5196 . '`if test -f $(srcdir)/' . $base . '.c'
5197 . '; then echo $(srcdir)/' . $base . '.c'
5198 . '; else echo ' . $base . '.c; fi` '
5199 . "| sed 's/^# \\([0-9]\\)/#line \\1/' "
5200 . '| $(ANSI2KNR) > ' . $base . "_.c"
5201 # If ansi2knr fails then we shouldn't
5202 # create the _.c file
5203 . " || rm -f ${base}_.c\n");
5204 push (@objects, $base . '_.$(OBJEXT)');
5205 push (@objects, $base . '_.lo')
5209 # Make all _.o (and _.lo) files depend on ansi2knr.
5210 # Use a sneaky little hack to make it print nicely.
5211 &pretty_print_rule ('', '', @objects, ':', '$(ANSI2KNR)');
5215 # This is a yacc helper which is called whenever we have decided to
5216 # compile a yacc file.
5217 sub lang_yacc_target_hook
5219 my ($self, $aggregate, $output, $input) = @_;
5221 my $flag = $aggregate . "_YFLAGS";
5222 if ((&variable_defined ($flag)
5223 && &variable_value ($flag) =~ /$DASH_D_PATTERN/o)
5224 || (&variable_defined ('YFLAGS')
5225 && &variable_value ('YFLAGS') =~ /$DASH_D_PATTERN/o))
5227 (my $output_base = $output) =~ s/\..*$//;
5228 my $header = $output_base . '.h';
5230 # Found a `-d' that applies to the compilation of this file.
5231 # Add a dependency for the generated header file, and arrange
5232 # for that file to be included in the distribution.
5233 # FIXME: this fails for `nodist_*_SOURCES'.
5234 $output_rules .= "${header}: $output\n";
5235 &push_dist_common ($header);
5236 # If the files are built in the build directory, then we want
5237 # to remove them with `make clean'. If they are in srcdir
5238 # they shouldn't be touched. However, we can't determine this
5239 # statically, and the GNU rules say that yacc/lex output files
5240 # should be removed by maintainer-clean. So that's what we
5242 push (@maintainer_clean_files, $header);
5246 # This is a helper for both lex and yacc.
5247 sub yacc_lex_finish_helper
5249 return if defined $language_scratch{'lex-yacc-done'};
5250 $language_scratch{'lex-yacc-done'} = 1;
5252 # If there is more than one distinct yacc (resp lex) source file
5253 # in a given directory, then the `ylwrap' program is required to
5254 # allow parallel builds to work correctly. FIXME: for now, no
5256 &require_config_file ($FOREIGN, 'ylwrap');
5257 if ($config_aux_dir_set_in_configure_in)
5259 &define_variable ('YLWRAP', $config_aux_dir . "/ylwrap");
5263 &define_variable ('YLWRAP', '$(top_srcdir)/ylwrap');
5267 sub lang_yacc_finish
5269 return if defined $language_scratch{'yacc-done'};
5270 $language_scratch{'yacc-done'} = 1;
5272 if (&variable_defined ('YACCFLAGS'))
5274 am_macro_error ('YACCFLAGS',
5275 "`YACCFLAGS' obsolete; use `YFLAGS' instead");
5278 if (count_files_for_language ('yacc') > 1)
5280 &yacc_lex_finish_helper;
5287 return if defined $language_scratch{'lex-done'};
5288 $language_scratch{'lex-done'} = 1;
5290 if (! $seen_prog_lex)
5292 &am_error ("lex source seen but `AM_PROG_LEX' not in `$configure_ac'");
5295 if (count_files_for_language ('lex') > 1)
5297 &yacc_lex_finish_helper;
5302 # Given a hash table of linker names, pick the name that has the most
5303 # precedence. This is lame, but something has to have global
5304 # knowledge in order to eliminate the conflict. Add more linkers as
5311 if defined $linkers{'GCJLINK'};
5313 if defined $linkers{'CXXLINK'};
5315 if defined $linkers{'F77LINK'};
5317 if defined $linkers{'OBJCLINK'};
5321 # Called to indicate that an extension was used.
5325 if (! defined $extension_seen{$ext})
5327 $extension_seen{$ext} = 1;
5331 ++$extension_seen{$ext};
5335 # Return the number of files seen for a given language. Knows about
5336 # special cases we care about. FIXME: this is hideous. We need
5337 # something that involves real language objects. For instance yacc
5338 # and yaccxx could both derive from a common yacc class which would
5339 # know about the strange ylwrap requirement. (Or better yet we could
5340 # just not support legacy yacc!)
5341 sub count_files_for_language
5346 if ($name eq 'yacc' || $name eq 'yaccxx')
5348 @names = ('yacc', 'yaccxx');
5350 elsif ($name eq 'lex' || $name eq 'lexxx')
5352 @names = ('lex', 'lexxx');
5360 foreach $name (@names)
5362 my $lang = $languages{$name};
5363 foreach my $ext (@{$lang->extensions})
5365 $r += $extension_seen{$ext}
5366 if defined $extension_seen{$ext};
5373 # Called to ask whether source files have been seen . If HEADERS is 1,
5374 # headers can be included.
5379 # count all the sources
5381 foreach my $val (values %extension_seen)
5388 $count -= count_files_for_language ('header');
5395 # register_language (%ATTRIBUTE)
5396 # ------------------------------
5397 # Register a single language.
5398 # Each %ATTRIBUTE is of the form ATTRIBUTE => VALUE.
5399 sub register_language (%)
5405 unless defined $option{'ansi'};
5406 $option{'autodep'} = 'no'
5407 unless defined $option{'autodep'};
5408 $option{'linker'} = ''
5409 unless defined $option{'linker'};
5410 $option{'define_flag'} = 1
5411 unless defined $option{'define_flag'};
5413 my $lang = new Language (%option);
5416 grep ($extension_map{$_} = $lang->name, @{$lang->extensions});
5417 $languages{$lang->name} = $lang;
5420 # This function is used to find a path from a user-specified suffix to
5421 # `o' or to some other suffix we recognize internally, eg `cc'.
5424 my ($source_ext) = @_;
5426 # FIXME: hard-coding `o' is a mistake. Doing something
5427 # intelligent is harder.
5428 while (! $extension_map{$source_ext}
5429 && $source_ext ne 'o'
5430 && defined $suffix_rules{$source_ext})
5432 $source_ext = $suffix_rules{$source_ext};
5439 ################################################################
5441 # Pretty-print something. HEAD is what should be printed at the
5442 # beginning of the first line, FILL is what should be printed at the
5443 # beginning of every subsequent line.
5444 sub pretty_print_internal
5446 my ($head, $fill, @values) = @_;
5448 my $column = length ($head);
5451 # Fill length is number of characters. However, each Tab
5452 # character counts for eight. So we count the number of Tabs and
5454 my $fill_length = length ($fill);
5455 $fill_length += 7 * ($fill =~ tr/\t/\t/d);
5459 # "71" because we also print a space.
5460 if ($column + length ($_) > 71)
5462 $result .= " \\\n" . $fill;
5463 $column = $fill_length;
5465 $result .= ' ' if $result =~ /\S\z/;
5467 $column += length ($_) + 1;
5474 # Pretty-print something and append to output_vars.
5477 $output_vars .= &pretty_print_internal (@_);
5480 # Pretty-print something and append to output_rules.
5481 sub pretty_print_rule
5483 $output_rules .= &pretty_print_internal (@_);
5487 ################################################################
5491 # &conditional_string(@COND-STACK)
5492 # --------------------------------
5493 # Build a string which denotes the conditional in @COND-STACK. Some
5494 # simplifications are done: `TRUE' entries are elided, and any `FALSE'
5495 # entry results in a return of `FALSE'.
5496 sub conditional_string
5500 if (grep (/^FALSE$/, @stack))
5506 return join (' ', uniq sort grep (!/^TRUE$/, @stack));
5512 # &conditional_true_when ($COND, $WHEN)
5513 # -------------------------------------
5514 # See if a conditional is true. Both arguments are conditional
5515 # strings. This returns true if the first conditional is true when
5516 # the second conditional is true.
5517 # For instance with $COND = `BAR FOO', and $WHEN = `BAR BAZ FOO',
5518 # obviously return 1, and 0 when, for instance, $WHEN = `FOO'.
5519 sub conditional_true_when ($$)
5521 my ($cond, $when) = @_;
5523 # Make a hash holding all the values from $WHEN.
5524 my %cond_vals = map { $_ => 1 } split (' ', $when);
5526 # Check each component of $cond, which looks `COND1 COND2'.
5527 foreach my $comp (split (' ', $cond))
5529 # TRUE is always true.
5530 next if $comp eq 'TRUE';
5531 return 0 if ! defined $cond_vals{$comp};
5539 # &conditional_is_redundant ($COND, @WHENS)
5540 # ----------------------------------------
5541 # Determine whether $COND is redundant with respect to @WHENS.
5543 # Returns true if $COND is true for any of the conditions in @WHENS.
5545 # If there are no @WHENS, then behave as if @WHENS contained a single empty
5547 sub conditional_is_redundant ($@)
5549 my ($cond, @whens) = @_;
5553 return 1 if conditional_true_when ($cond, "");
5557 foreach my $when (@whens)
5559 return 1 if conditional_true_when ($cond, $when);
5568 # condition_negate ($COND)
5569 # ------------------------
5570 sub condition_negate ($)
5574 $cond =~ s/TRUE$/TRUEO/;
5575 $cond =~ s/FALSE$/TRUE/;
5576 $cond =~ s/TRUEO$/FALSE/;
5582 # Compare condition names.
5583 # Issue them in alphabetical order, foo_TRUE before foo_FALSE.
5586 # Be careful we might be comparing `' or `#'.
5587 $a =~ /^(.*)_(TRUE|FALSE)$/;
5588 my ($aname, $abool) = ($1 || '', $2 || '');
5589 $b =~ /^(.*)_(TRUE|FALSE)$/;
5590 my ($bname, $bbool) = ($1 || '', $2 || '');
5591 return ($aname cmp $bname
5592 # Don't bother with IFs, given that TRUE is after FALSE
5593 # just cmp in the reverse order.
5594 || $bbool cmp $abool
5600 # &make_condition (@CONDITIONS)
5601 # -----------------------------
5602 # Transform a list of conditions (themselves can be an internal list
5603 # of conditions, e.g., @CONDITIONS = ('cond1 cond2', 'cond3')) into a
5604 # Make conditional (a pattern for AC_SUBST).
5605 # Correctly returns the empty string when there are no conditions.
5608 my $res = conditional_string (@_);
5610 # There are no conditions.
5616 elsif ($res eq 'FALSE')
5623 $res = '@' . $res . '@';
5632 ## ------------------------------ ##
5633 ## Handling the condition stack. ##
5634 ## ------------------------------ ##
5638 # cond_stack_if ($NEGATE, $COND, $WHERE)
5639 # --------------------------------------
5640 sub cond_stack_if ($$$)
5642 my ($negate, $cond, $where) = @_;
5644 &am_file_error ($where, "$cond does not appear in AM_CONDITIONAL")
5645 if ! $configure_cond{$cond} && $cond !~ /^TRUE|FALSE$/;
5647 $cond = "${cond}_TRUE"
5648 unless $cond =~ /^TRUE|FALSE$/;
5649 $cond = condition_negate ($cond)
5652 push (@cond_stack, $cond);
5654 return conditional_string (@cond_stack);
5659 # cond_stack_else ($NEGATE, $COND, $WHERE)
5660 # ----------------------------------------
5661 sub cond_stack_else ($$$)
5663 my ($negate, $cond, $where) = @_;
5667 &am_file_error ($where, "else without if");
5671 $cond_stack[$#cond_stack] = condition_negate ($cond_stack[$#cond_stack]);
5673 # If $COND is given, check against it.
5676 $cond = "${cond}_TRUE"
5677 unless $cond =~ /^TRUE|FALSE$/;
5678 $cond = condition_negate ($cond)
5681 &am_file_error ($where,
5682 "else reminder ($negate$cond) incompatible with "
5683 . "current conditional: $cond_stack[$#cond_stack]")
5684 if $cond_stack[$#cond_stack] ne $cond;
5687 return conditional_string (@cond_stack);
5692 # cond_stack_endif ($NEGATE, $COND, $WHERE)
5693 # -----------------------------------------
5694 sub cond_stack_endif ($$$)
5696 my ($negate, $cond, $where) = @_;
5701 &am_file_error ($where, "endif without if: $negate$cond");
5706 # If $COND is given, check against it.
5709 $cond = "${cond}_TRUE"
5710 unless $cond =~ /^TRUE|FALSE$/;
5711 $cond = condition_negate ($cond)
5714 &am_file_error ($where,
5715 "endif reminder ($negate$cond) incompatible with "
5716 . "current conditional: $cond_stack[$#cond_stack]")
5717 if $cond_stack[$#cond_stack] ne $cond;
5722 return conditional_string (@cond_stack);
5729 ## ------------------------ ##
5730 ## Handling the variables. ##
5731 ## ------------------------ ##
5734 # check_ambiguous_conditional ($VAR, $COND)
5735 # -----------------------------------------
5736 # Check for an ambiguous conditional. This is called when a variable
5737 # is being defined conditionally. If we already know about a
5738 # definition that is true under the same conditions, then we have an
5740 sub check_ambiguous_conditional ($$)
5742 my ($var, $cond) = @_;
5743 foreach my $vcond (keys %{$var_value{$var}})
5746 if ($vcond eq $cond)
5748 $message = "$var multiply defined in condition $cond";
5750 elsif (&conditional_true_when ($vcond, $cond))
5752 $message = ("$var was already defined in condition $vcond, "
5753 . "which implies condition $cond");
5755 elsif (&conditional_true_when ($cond, $vcond))
5757 $message = ("$var was already defined in condition $vcond, "
5758 . "which is implied by condition $cond");
5762 am_macro_error ($var, $message);
5769 # ¯o_define($VAR, $VAR_IS_AM, $TYPE, $COND, $VALUE, $WHERE)
5770 # -------------------------------------------------------------
5771 # The $VAR can go from Automake to user, but not the converse.
5772 sub macro_define ($$$$$$)
5774 my ($var, $var_is_am, $type, $cond, $value, $where) = @_;
5776 am_file_error ($where, "bad macro name `$var'")
5777 if $var !~ /$MACRO_PATTERN/o;
5781 # An Automake variable must be consistently defined with the same
5782 # sign by Automake. A user variable must be set by either `=' or
5783 # `:=', and later promoted to `+='.
5786 if (defined $var_type{$var} && $var_type{$var} ne $type)
5788 am_macro_error ($var,
5789 ("$var was set with `$var_type{$var}=' "
5790 . "and is now set with `$type='"));
5795 if (!defined $var_type{$var} && $type eq '+')
5797 am_macro_error ($var, "$var must be set with `=' before using `+='");
5800 $var_type{$var} = $type;
5802 # When adding, since we rewrite, don't try to preserve the
5803 # Automake continuation backslashes.
5805 if $type eq '+' && $var_is_am;
5807 # Differentiate the first assignment (including with `+=').
5808 if ($type eq '+' && defined $var_value{$var}{$cond})
5810 if (substr ($var_value{$var}{$cond}, -1) eq "\n")
5812 # Insert a backslash before a trailing newline.
5813 $var_value{$var}{$cond} =
5814 substr ($var_value{$var}{$cond}, 0, -1) . "\\\n";
5816 elsif ($var_value{$var}{$cond})
5818 # Insert a separator.
5819 $var_value{$var}{$cond} .= ' ';
5821 $var_value{$var}{$cond} .= $value;
5825 # The first assignment to a macro sets its location. Ideally I
5826 # suppose we would associate line numbers with random bits of text.
5827 # FIXME: We sometimes redefine some variables, but we want to keep
5828 # the original location. More subs are needed to handle
5829 # properly variables. Once this done, remove this hack.
5830 $var_location{$var} = $where
5831 unless defined $var_location{$var};
5833 # If Automake tries to override a value specified by the user,
5834 # just don't let it do.
5835 if (defined $var_value{$var}{$cond} && !$var_is_am{$var} && $var_is_am)
5839 print STDERR "$me: refusing to override the user definition of:\n";
5841 print STDERR "$me: with `$cond' => `$value'\n";
5846 # There must be no previous value unless the user is redefining
5847 # an Automake variable or an AC_SUBST variable.
5848 check_ambiguous_conditional ($var, $cond)
5849 unless ($var_is_am{$var} && !$var_is_am
5850 || exists $configure_vars{$var});
5852 $var_value{$var}{$cond} = $value;
5856 # An Automake variable can be given to the user, but not the converse.
5857 if (! defined $var_is_am{$var} || !$var_is_am)
5859 $var_is_am{$var} = $var_is_am;
5864 # &variable_delete ($VAR, [@CONDS])
5865 # ---------------------------------
5866 # Forget about $VAR under the conditions @CONDS, or completely if
5868 sub variable_delete ($@)
5870 my ($var, @conds) = @_;
5874 delete $var_value{$var};
5875 delete $var_location{$var};
5876 delete $var_is_am{$var};
5877 delete $var_comment{$var};
5878 delete $var_type{$var};
5882 foreach my $cond (@conds)
5884 delete $var_value{$var}{$cond};
5890 # ¯o_dump ($VAR)
5891 # ------------------
5896 if (!exists $var_value{$var})
5898 print STDERR " $var does not exist\n";
5902 my $var_is_am = $var_is_am{$var} ? "Automake" : "User";
5903 my $where = (defined $var_location{$var}
5904 ? $var_location{$var} : "undefined");
5905 print STDERR "$var_comment{$var}"
5906 if defined $var_comment{$var};
5907 print STDERR " $var ($var_is_am, where = $where) $var_type{$var}=\n";
5908 print STDERR " {\n";
5909 foreach my $vcond (sort by_condition keys %{$var_value{$var}})
5911 print STDERR " $vcond => $var_value{$var}{$vcond}\n";
5913 print STDERR " }\n";
5924 print STDERR "%var_value =\n";
5926 foreach my $var (sort (keys %var_value))
5935 # &variable_defined ($VAR, [$COND])
5936 # ---------------------------------
5937 # See if a variable exists. $VAR is the variable name, and $COND is
5938 # the condition which we should check. If no condition is given, we
5939 # currently return true if the variable is defined under any
5941 sub variable_defined ($$)
5943 my ($var, $cond) = @_;
5945 # Unfortunately we can't just check for $var_value{VAR}{COND}
5946 # as this would make perl create $condition{VAR}, which we
5948 if (!exists $var_value{$var})
5950 if (defined $targets{$var})
5952 am_macro_error ($var, "`$var' is a target; expected a variable")
5954 # The variable is not defined
5958 if ($cond && !exists $var_value{$var}{$cond})
5960 # The variable is not defined for the given condition.
5964 # Even a var_value examination is good enough for us. FIXME:
5965 # really should maintain examined status on a per-condition basis.
5966 $content_seen{$var} = 1;
5970 # Mark a variable as examined.
5971 sub examine_variable
5974 &variable_defined ($var);
5977 # Return the set of conditions for which a variable is defined.
5979 # If the variable is not defined conditionally, and is not defined in
5980 # terms of any variables which are defined conditionally, then this
5981 # returns the empty list.
5983 # If the variable is defined conditionally, but is not defined in
5984 # terms of any variables which are defined conditionally, then this
5985 # returns the list of conditions for which the variable is defined.
5987 # If the variable is defined in terms of any variables which are
5988 # defined conditionally, then this returns a full set of permutations
5989 # of the subvariable conditions. For example, if the variable is
5990 # defined in terms of a variable which is defined for COND_TRUE,
5991 # then this returns both COND_TRUE and COND_FALSE. This is
5992 # because we will need to define the variable under both conditions.
5994 sub variable_conditions_recursive ($)
6000 my @new_conds = variable_conditions_recursive_sub ($var, '');
6001 # Now we want to return all permutations of the subvariable
6004 foreach my $item (@new_conds)
6006 foreach (split (' ', $item))
6008 s/^(.*)_(TRUE|FALSE)$/$1_TRUE/;
6012 @new_conds = variable_conditions_permutations (sort keys %allconds);
6015 foreach my $cond (@new_conds)
6017 my $reduce = variable_conditions_reduce (split (' ', $cond));
6019 if $reduce eq 'FALSE';
6020 $uniqify{$cond} = 1;
6023 # Note we cannot just do `return sort keys %uniqify', because this
6024 # function is sometimes used in a scalar context.
6025 my @uniq_list = sort by_condition keys %uniqify;
6030 # variable_conditions ($VAR)
6031 # --------------------------
6032 # Get the list of conditions that a variable is defined with, without
6033 # recursing through the conditions of any subvariables.
6034 # Argument is $VAR: the variable to get the conditions of.
6035 # Returns the list of conditions.
6036 sub variable_conditions ($)
6039 my @conds = keys %{$var_value{$var}};
6040 return sort by_condition @conds;
6045 # &variable_conditionally_defined ($VAR)
6046 # --------------------------------------
6047 sub variable_conditionally_defined ($)
6050 foreach my $cond (variable_conditions_recursive ($var))
6053 unless $cond =~ /^TRUE|FALSE$/;
6060 # &variable_conditions_recursive_sub ($VAR, $PARENT)
6061 # -------------------------------------------------------
6062 # A subroutine of variable_conditions_recursive. This returns all the
6063 # conditions of $VAR, including those of any sub-variables.
6064 sub variable_conditions_recursive_sub
6066 my ($var, $parent) = @_;
6069 if (defined $vars_scanned{$var})
6071 am_macro_error ($parent, "variable `$var' recursively defined");
6074 $vars_scanned{$var} = 1;
6076 my @this_conds = ();
6077 # Examine every condition under which $VAR is defined.
6078 foreach my $vcond (keys %{$var_value{$var}})
6080 push (@this_conds, $vcond);
6082 # If $VAR references some other variable, then compute the
6083 # conditions for that subvariable.
6084 my @subvar_conds = ();
6085 foreach (split (' ', $var_value{$var}{$vcond}))
6087 # If a comment seen, just leave.
6090 # Handle variable substitutions.
6091 if (/^\$\{(.*)\}$/ || /^\$\((.*)\)$/)
6094 if ($varname =~ /$SUBST_REF_PATTERN/o)
6100 # Here we compute all the conditions under which the
6101 # subvariable is defined. Then we go through and add
6103 my @svc = variable_conditions_recursive_sub ($varname, $var);
6104 foreach my $item (@svc)
6106 my $val = conditional_string ($vcond, split (' ', $item));
6108 push (@subvar_conds, $val);
6113 # If there are no conditional subvariables, then we want to
6114 # return this condition. Otherwise, we want to return the
6115 # permutations of the subvariables, taking into account the
6116 # conditions of $VAR.
6117 if (! @subvar_conds)
6119 push (@new_conds, $vcond);
6123 push (@new_conds, variable_conditions_reduce (@subvar_conds));
6127 # Unset our entry in vars_scanned. We only care about recursive
6129 delete $vars_scanned{$var};
6131 # If we are being called on behalf of another variable, we need to
6132 # return all possible permutations of the conditions. We have
6133 # already handled everything in @this_conds along with their
6134 # subvariables. We now need to add any permutations that are not
6136 foreach my $this_cond (@this_conds)
6139 variable_conditions_permutations (split (' ', $this_cond));
6140 foreach my $perm (@perms)
6143 foreach my $scan (@this_conds)
6145 if (&conditional_true_when ($perm, $scan)
6146 || &conditional_true_when ($scan, $perm))
6154 # This permutation was not already handled, and is valid
6156 push (@new_conds, $perm);
6164 # Filter a list of conditionals so that only the exclusive ones are
6165 # retained. For example, if both `COND1_TRUE COND2_TRUE' and
6166 # `COND1_TRUE' are in the list, discard the latter.
6167 # If the list is empty, return TRUE
6168 sub variable_conditions_reduce
6175 $cond = shift(@conds);
6177 # FALSE is absorbent.
6178 if ($cond eq 'FALSE')
6182 elsif (!conditional_is_redundant ($cond, @ret, @conds))
6188 return "TRUE" if @ret == 0;
6193 # invert_conditions (@CONDS)
6194 # --------------------------
6195 # Invert a list of conditionals. Returns a set of conditionals which
6196 # are never true for any of the input conditionals, and when taken
6197 # together with the input conditionals cover all possible cases.
6199 # For example: invert_conditions("A_TRUE B_TRUE", "A_FALSE B_FALSE") will
6200 # return ("A_FALSE B_TRUE", "A_TRUE B_FALSE")
6201 sub invert_conditions
6206 foreach my $cond (@conds)
6208 foreach my $perm (variable_conditions_permutations (split(' ', $cond)))
6210 push @notconds, $perm
6211 if ! conditional_is_redundant ($perm, @conds);
6214 return variable_conditions_reduce (@notconds);
6217 # Return a list of permutations of a conditional string.
6218 sub variable_conditions_permutations
6223 my $comp = shift (@comps);
6224 return variable_conditions_permutations (@comps)
6226 my $neg = condition_negate ($comp);
6229 foreach my $sub (variable_conditions_permutations (@comps))
6231 push (@ret, "$comp $sub");
6232 push (@ret, "$neg $sub");
6244 # &check_variable_defined_unconditionally($VAR, $PARENT)
6245 # ------------------------------------------------------
6246 # Warn if a variable is conditionally defined. This is called if we
6247 # are using the value of a variable.
6248 sub check_variable_defined_unconditionally ($$)
6250 my ($var, $parent) = @_;
6251 foreach my $cond (keys %{$var_value{$var}})
6254 if $cond =~ /^TRUE|FALSE$/;
6258 am_macro_error ($parent,
6259 "warning: automake does not support conditional definition of $var in $parent");
6263 am_macro_error ($parent,
6264 "warning: automake does not support $var being defined conditionally");
6270 # Get the TRUE value of a variable, warn if the variable is
6271 # conditionally defined.
6275 &check_variable_defined_unconditionally ($var);
6276 return $var_value{$var}{'TRUE'};
6281 # &value_to_list ($VAR, $VAL, $COND)
6282 # ----------------------------------
6283 # Convert a variable value to a list, split as whitespace. This will
6284 # recursively follow $(...) and ${...} inclusions. It preserves @...@
6287 # If COND is 'all', then all values under all conditions should be
6288 # returned; if COND is a particular condition (all conditions are
6289 # surrounded by @...@) then only the value for that condition should
6290 # be returned; otherwise, warn if VAR is conditionally defined.
6291 # SCANNED is a global hash listing whose keys are all the variables
6292 # already scanned; it is an error to rescan a variable.
6295 my ($var, $val, $cond) = @_;
6299 $val =~ s/\\(\n|$)/ /g;
6301 foreach (split (' ', $val))
6303 # If a comment seen, just leave.
6306 # Handle variable substitutions.
6307 if (/^\$\{([^}]*)\}$/ || /^\$\(([^)]*)\)$/)
6311 # If the user uses a losing variable name, just ignore it.
6312 # This isn't ideal, but people have requested it.
6313 next if ($varname =~ /\@.*\@/);
6317 if ($varname =~ /$SUBST_REF_PATTERN/o)
6321 ($from = $2) =~ s/(\W)/\\$1/g;
6325 @temp_list = &variable_value_as_list_recursive_worker ($1, $cond, $var);
6327 # Now rewrite the value if appropriate.
6330 grep (s/$from$/$to/, @temp_list);
6333 push (@result, @temp_list);
6345 # variable_value_as_list ($VAR, $COND, $PARENT)
6346 # ---------------------------------------------
6347 # Get the value of a variable given a specified condition. without
6348 # recursing through any subvariables.
6350 # $VAR is the variable
6351 # $COND is the condition. If this is not given, the value for the
6352 # "TRUE" condition will be returned.
6353 # $PARENT is the variable in which the variable is used: this is used
6354 # only for error messages.
6355 # Returns the list of conditions.
6356 # For example, if A is defined as "foo $(B) bar", and B is defined as
6357 # "baz", this will return ("foo", "$(B)", "bar")
6358 sub variable_value_as_list
6360 my ($var, $cond, $parent) = @_;
6364 if (! defined $var_value{$var})
6366 if (defined $targets{$var})
6368 am_macro_error ($var, "`$var' is a target; expected a variable");
6372 am_macro_error ($parent, "variable `$var' not defined");
6376 # Get value for given condition
6379 foreach my $vcond (keys %{$var_value{$var}})
6381 my $val = $var_value{$var}{$vcond};
6383 if (&conditional_true_when ($vcond, $cond))
6385 # Unless variable is not defined conditionally, there should only
6386 # be one value of $vcond true when $cond.
6387 &check_variable_defined_unconditionally ($var, $parent)
6392 $val =~ s/\\(\n|$)/ /g;
6394 foreach (split (' ', $val))
6396 # If a comment seen, just leave.
6407 # Return contents of variable as list, split as whitespace. This will
6408 # recursively follow $(...) and ${...} inclusions. It preserves @...@
6409 # substitutions. If COND is 'all', then all values under all
6410 # conditions should be returned; if COND is a particular condition
6411 # (all conditions are surrounded by @...@) then only the value for
6412 # that condition should be returned; otherwise, warn if VAR is
6413 # conditionally defined. If PARENT is specified, it is the name of
6414 # the including variable; this is only used for error reports.
6415 sub variable_value_as_list_recursive_worker
6417 my ($var, $cond, $parent) = @_;
6420 if (! defined $var_value{$var})
6422 if (defined $targets{$var})
6424 am_macro_error ($var, "`$var' is a target; expected a variable");
6428 am_macro_error ($parent, "variable `$var' not defined");
6431 elsif (defined $vars_scanned{$var})
6433 # `vars_scanned' is a global we use to keep track of which
6434 # variables we've already examined.
6435 am_macro_error ($parent, "variable `$var' recursively defined");
6437 elsif ($cond eq 'all')
6439 $vars_scanned{$var} = 1;
6440 foreach my $vcond (keys %{$var_value{$var}})
6442 my $val = $var_value{$var}{$vcond};
6443 push (@result, &value_to_list ($var, $val, $cond));
6449 $vars_scanned{$var} = 1;
6451 foreach my $vcond (keys %{$var_value{$var}})
6453 my $val = $var_value{$var}{$vcond};
6454 if (&conditional_true_when ($vcond, $cond))
6456 # Warn if we have an ambiguity. It's hard to know how
6457 # to handle this case correctly.
6458 &check_variable_defined_unconditionally ($var, $parent)
6461 push (@result, &value_to_list ($var, $val, $cond));
6466 # Unset our entry in vars_scanned. We only care about recursive
6468 delete $vars_scanned{$var};
6474 # &variable_output ($VAR, [@CONDS])
6475 # ---------------------------------
6476 # Output all the values of $VAR is @COND is not specified, else only
6477 # that corresponding to @COND.
6478 sub variable_output ($@)
6480 my ($var, @conds) = @_;
6482 @conds = keys %{$var_value{$var}}
6485 $output_vars .= $var_comment{$var}
6486 if defined $var_comment{$var};
6488 foreach my $cond (sort by_condition @conds)
6490 my $val = $var_value{$var}{$cond};
6491 my $equals = $var_type{$var} eq ':' ? ':=' : '=';
6492 my $output_var = "$var $equals $val";
6493 $output_var =~ s/^/make_condition ($cond)/meg;
6494 $output_vars .= $output_var . "\n";
6499 # &variable_pretty_output ($VAR, [@CONDS])
6500 # ----------------------------------------
6501 # Likewise, but pretty, i.e., we *split* the values at spaces. Use only
6502 # with variables holding filenames.
6503 sub variable_pretty_output ($@)
6505 my ($var, @conds) = @_;
6507 @conds = keys %{$var_value{$var}}
6510 $output_vars .= $var_comment{$var}
6511 if defined $var_comment{$var};
6513 foreach my $cond (sort by_condition @conds)
6515 my $val = $var_value{$var}{$cond};
6516 my $equals = $var_type{$var} eq ':' ? ':=' : '=';
6517 my $make_condition = make_condition ($cond);
6518 $output_vars .= pretty_print_internal ("$make_condition$var $equals",
6519 "$make_condition\t",
6520 split (' ' , $val));
6525 # This is just a wrapper for variable_value_as_list_recursive_worker that
6526 # initializes the global hash `vars_scanned'. This hash is used to
6527 # avoid infinite recursion.
6528 sub variable_value_as_list_recursive
6530 my ($var, $cond, $parent) = @_;
6532 return &variable_value_as_list_recursive_worker ($var, $cond, $parent);
6536 # Like define_variable, but the value is a list, and the variable may
6537 # be defined conditionally. The second argument is the conditional
6538 # under which the value should be defined; this should be the empty
6539 # string to define the variable unconditionally. The third argument
6540 # is a list holding the values to use for the variable. The value is
6541 # pretty printed in the output file.
6542 sub define_pretty_variable
6544 my ($var, $cond, @value) = @_;
6546 # Beware that an empty $cond has a different semantics for
6547 # macro_define and variable_pretty_output.
6550 if (! &variable_defined ($var, $cond))
6552 macro_define ($var, 1, '', $cond, join (' ', @value), undef);
6553 variable_pretty_output ($var, $cond || 'TRUE');
6554 $content_seen{$var} = 1;
6559 # define_variable ($VAR, $VALUE)
6560 # ------------------------------
6561 # Define a new user variable VAR to VALUE, but only if not already defined.
6564 my ($var, $value) = @_;
6566 define_pretty_variable ($var, 'TRUE', $value);
6570 # Like define_variable, but define a variable to be the configure
6571 # substitution by the same name.
6572 sub define_configure_variable
6575 my $value = '@' . $var . '@';
6576 &define_variable ($var, $value);
6580 # define_compiler_variable ($LANG)
6581 # --------------------------------
6582 # Define a compiler variable. We also handle defining the `LT'
6583 # version of the command when using libtool.
6584 sub define_compiler_variable ($)
6588 my ($var, $value) = ($lang->compiler, $lang->compile);
6589 &define_variable ($var, $value);
6590 &define_variable ("LT$var", "\$(LIBTOOL) --mode=compile $value")
6595 # define_linker_variable ($LANG)
6596 # ------------------------------
6597 # Define linker variables.
6598 sub define_linker_variable ($)
6602 my ($var, $value) = ($lang->lder, $lang->ld);
6604 &define_variable ($lang->lder, $lang->ld);
6605 # CCLINK = $(CCLD) blah blah...
6606 &define_variable ($lang->linker,
6607 (($seen_libtool ? '$(LIBTOOL) --mode=link ' : '')
6611 ################################################################
6613 ## ---------------- ##
6614 ## Handling rules. ##
6615 ## ---------------- ##
6618 # rule_define ($TARGET, $IS_AM, $COND, $WHERE)
6619 # --------------------------------------------
6620 # Define a new rule. $TARGET is the rule name. $IS_AM is a boolean
6621 # which is true if the new rule is defined by the user. $COND is the
6622 # condition under which the rule is defined. $WHERE is where the rule
6623 # is defined (file name or line number). Returns true if it is ok to
6624 # define the rule, false otherwise.
6625 sub rule_define ($$$$)
6627 my ($target, $rule_is_am, $cond, $where) = @_;
6629 # For now `foo:' will override `foo$(EXEEXT):'. This is temporary,
6630 # though, so we emit a warning.
6631 (my $noexe = $target) =~ s,\$\(EXEEXT\)$,,;
6632 if ($noexe ne $target && defined $targets{$noexe})
6634 # The no-exeext option enables this feature.
6635 if (! defined $options{'no-exeext'})
6637 am_macro_error ($noexe,
6638 "deprecated feature: `$noexe' overrides `$noexe\$(EXEEXT)'\nchange your target to read `$noexe\$(EXEEXT)'");
6644 if (defined $targets{$target}
6646 ? ! defined $target_conditional{$target}
6647 : defined $target_conditional{$target}))
6649 am_target_error ($target,
6650 "$target defined both conditionally and unconditionally");
6653 # Value here doesn't matter; for targets we only note existence.
6654 $targets{$target} = $where;
6657 if ($target_conditional{$target})
6659 &check_ambiguous_conditional ($target, $cond);
6661 $target_conditional{$target}{$cond} = $where;
6665 # Check the rule for being a suffix rule. If so, store in a hash.
6667 if ((my ($source_suffix, $object_suffix)) = ($target =~ $SUFFIX_RULE_PATTERN))
6669 $suffix_rules{$source_suffix} = $object_suffix;
6670 print "Sources ending in .$source_suffix become .$object_suffix\n"
6672 # Set SUFFIXES from suffix_rules.
6673 push @suffixes, ".$source_suffix", ".$object_suffix";
6680 # See if a target exists.
6684 return defined $targets{$target};
6688 ################################################################
6690 # &read_am_file ($AMFILE)
6691 # -----------------------
6692 # Read Makefile.am and set up %contents. Simultaneously copy lines
6693 # from Makefile.am into $output_trailer or $output_vars as
6694 # appropriate. NOTE we put rules in the trailer section. We want
6695 # user rules to come after our generated stuff.
6696 sub read_am_file ($)
6700 my $am_file = new Automake::XFile ("< $amfile");
6701 verbose "reading $amfile";
6707 while ($_ = $am_file->getline)
6709 if (/$IGNORE_PATTERN/o)
6711 # Merely delete comments beginning with two hashes.
6713 elsif (/$WHITE_PATTERN/o)
6715 # Stick a single white line before the incoming macro or rule.
6719 elsif (/$COMMENT_PATTERN/o)
6721 # Stick comments before the incoming macro or rule. Make
6722 # sure a blank line preceeds first block of comments.
6723 $spacing = "\n" unless $blank;
6725 $comment .= $spacing . $_;
6734 $output_vars .= $comment . "\n";
6738 # We save the conditional stack on entry, and then check to make
6739 # sure it is the same on exit. This lets us conditonally include
6741 my @saved_cond_stack = @cond_stack;
6742 my $cond = conditional_string (@cond_stack);
6746 my $last_var_name = '';
6747 my $last_var_type = '';
6748 my $last_var_value = '';
6749 my $here = "$amfile:$.";
6750 # FIXME: shouldn't use $_ in this loop; it is too big.
6754 unless substr ($_, -1, 1) eq "\n";
6756 # Don't look at MAINTAINER_MODE_TRUE here. That shouldn't be
6757 # used by users. @MAINT@ is an anachronism now.
6758 $_ =~ s/\@MAINT\@//g
6759 unless $seen_maint_mode;
6761 my $new_saw_bk = /\\$/ && ! /$COMMENT_PATTERN/o;
6763 if (/$IGNORE_PATTERN/o)
6765 # Merely delete comments beginning with two hashes.
6767 elsif (/$WHITE_PATTERN/o)
6769 # Stick a single white line before the incoming macro or rule.
6771 am_file_error ($here, "blank line following trailing backslash")
6774 elsif (/$COMMENT_PATTERN/o)
6776 # Stick comments before the incoming macro or rule.
6777 $comment .= $spacing . $_;
6779 am_file_error ($here, "comment following trailing backslash")
6786 $output_trailer .= &make_condition (@cond_stack);
6787 $output_trailer .= $_;
6791 $last_var_value .= ' '
6792 unless $last_var_value =~ /\s$/;
6793 $last_var_value .= $_;
6797 $var_comment{$last_var_name} .= "$spacing"
6798 if (!defined $var_comment{$last_var_name}
6799 || substr ($var_comment{$last_var_name}, -1) ne "\n");
6800 $var_comment{$last_var_name} .= "$comment";
6801 $comment = $spacing = '';
6802 macro_define ($last_var_name, 0,
6803 $last_var_type, $cond,
6804 $last_var_value, $here)
6805 if $cond ne 'FALSE';
6806 push (@var_list, $last_var_name);
6811 elsif (/$IF_PATTERN/o)
6813 $cond = cond_stack_if ($1, $2, $here);
6815 elsif (/$ELSE_PATTERN/o)
6817 $cond = cond_stack_else ($1, $2, $here);
6819 elsif (/$ENDIF_PATTERN/o)
6821 $cond = cond_stack_endif ($1, $2, $here);
6824 elsif (/$RULE_PATTERN/o)
6829 rule_define ($1, 0, $cond, $here);
6831 $output_trailer .= $comment . $spacing;
6832 $output_trailer .= &make_condition (@cond_stack);
6833 $output_trailer .= $_;
6834 $comment = $spacing = '';
6836 elsif (/$ASSIGNMENT_PATTERN/o)
6838 # Found a macro definition.
6840 $last_var_name = $1;
6841 $last_var_type = $2;
6842 $last_var_value = $3;
6843 if ($3 ne '' && substr ($3, -1) eq "\\")
6845 # We preserve the `\' because otherwise the long lines
6846 # that are generated will be truncated by broken
6848 $last_var_value = $3 . "\n";
6853 # FIXME: this doesn't always work correctly; it will
6854 # group all comments for a given variable, no matter
6856 # Accumulating variables must not be output.
6857 $var_comment{$last_var_name} .= "$spacing"
6858 if (!defined $var_comment{$last_var_name}
6859 || substr ($var_comment{$last_var_name}, -1) ne "\n");
6860 $var_comment{$last_var_name} .= "$comment";
6861 $comment = $spacing = '';
6863 macro_define ($last_var_name, 0,
6864 $last_var_type, $cond,
6865 $last_var_value, $here)
6866 if $cond ne 'FALSE';
6867 push (@var_list, $last_var_name);
6870 elsif (/$INCLUDE_PATTERN/o)
6874 if ($path =~ s/^\$\(top_srcdir\)\///)
6876 push (@include_stack, "\$\(top_srcdir\)/$path");
6880 $path =~ s/\$\(srcdir\)\///;
6881 push (@include_stack, "\$\(srcdir\)/$path");
6882 $path = $relative_dir . "/" . $path;
6884 &read_am_file ($path);
6888 # This isn't an error; it is probably a continued rule.
6889 # In fact, this is what we assume.
6891 $output_trailer .= $comment . $spacing;
6892 $output_trailer .= &make_condition (@cond_stack);
6893 $output_trailer .= $_;
6894 $comment = $spacing = '';
6895 am_file_error ($here, "`#' comment at start of rule is unportable")
6896 if $_ =~ /^\t\s*\#/;
6899 $saw_bk = $new_saw_bk;
6900 $_ = $am_file->getline;
6903 $output_trailer .= $comment;
6905 if (join (' ', @saved_cond_stack) ne join (' ', @cond_stack))
6909 &am_error ("unterminated conditionals: @cond_stack");
6913 # FIXME: better error message here.
6914 &am_error ("conditionals not nested in include file");
6920 # define_standard_variables ()
6921 # ----------------------------
6922 # A helper for read_main_am_file which initializes configure variables
6923 # and variables from header-vars.am. This is a subr so we can call it
6925 sub define_standard_variables
6927 my $saved_output_vars = $output_vars;
6928 my ($comments, undef, $rules) =
6929 file_contents_internal (1, "$libdir/am/header-vars.am");
6931 # This will output the definitions in $output_vars, which we don't
6933 foreach my $var (sort keys %configure_vars)
6935 &define_configure_variable ($var);
6936 push (@var_list, $var);
6939 # ... hence, we restore $output_vars.
6940 $output_vars = $saved_output_vars . $comments . $rules;
6943 # Read main am file.
6944 sub read_main_am_file
6948 # This supports the strange variable tricks we are about to play.
6949 if (scalar keys %var_value > 0)
6952 &prog_error ("variable defined before read_main_am_file");
6955 # Generate copyright header for generated Makefile.in.
6956 # We do discard the output of predefined variables, handled below.
6957 $output_vars = ("# $in_file_name generated by automake "
6958 . $VERSION . " from $am_file_name.\n");
6959 $output_vars .= '# ' . subst ('configure_input') . "\n";
6960 $output_vars .= $gen_copyright;
6962 # We want to predefine as many variables as possible. This lets
6963 # the user set them with `+=' in Makefile.am. However, we don't
6964 # want these initial definitions to end up in the output quite
6965 # yet. So we just load them, but output them later.
6966 &define_standard_variables;
6968 # Read user file, which might override some of our values.
6969 &read_am_file ($amfile);
6971 # Ouput all the Automake variables. If the user changed one, then
6972 # it is now marked as owned by the user.
6973 foreach my $var (uniq @var_list)
6975 # Don't process user variables.
6976 variable_output ($var)
6977 unless !$var_is_am{$var};
6980 # Now dump the user variables that were defined. We do it in the same
6981 # order in which they were defined (skipping duplicates).
6982 foreach my $var (uniq @var_list)
6984 # Don't process Automake variables.
6985 variable_output ($var)
6986 unless $var_is_am{$var};
6990 ################################################################
6993 # &flatten ($STRING)
6994 # ------------------
6995 # Flatten the $STRING and return the result.
7010 # &make_paragraphs ($MAKEFILE, [%TRANSFORM])
7011 # ------------------------------------------
7012 # Load a $MAKEFILE, apply the %TRANSFORM, and return it as a list of
7014 sub make_paragraphs ($%)
7016 my ($file, %transform) = @_;
7018 # Complete %transform with global options and make it a Perl
7021 "s/$IGNORE_PATTERN//gm;"
7022 . transform (%transform,
7024 'CYGNUS' => $cygnus_mode,
7026 => $seen_maint_mode ? subst ('MAINTAINER_MODE_TRUE') : '',
7028 'SHAR' => $options{'dist-shar'} || 0,
7029 'BZIP2' => $options{'dist-bzip2'} || 0,
7030 'ZIP' => $options{'dist-zip'} || 0,
7031 'COMPRESS' => $options{'dist-tarZ'} || 0,
7033 'INSTALL-INFO' => !$options{'no-installinfo'},
7034 'INSTALL-MAN' => !$options{'no-installman'},
7035 'CK-NEWS' => $options{'check-news'} || 0,
7037 'SUBDIRS' => &variable_defined ('SUBDIRS'),
7038 'TOPDIR' => backname ($relative_dir),
7039 'TOPDIR_P' => $relative_dir eq '.',
7040 'CONFIGURE-AC' => $configure_ac,
7042 'BUILD' => $seen_canonical == $AC_CANONICAL_SYSTEM,
7043 'HOST' => $seen_canonical,
7044 'TARGET' => $seen_canonical == $AC_CANONICAL_SYSTEM,
7046 'LIBTOOL' => defined $configure_vars{'LIBTOOL'})
7047 # We don't need more than two consecutive new-lines.
7048 . 's/\n{3,}/\n\n/g';
7050 # Swallow the file and apply the COMMAND.
7051 my $fc_file = new Automake::XFile ("< $file");
7053 print "$me: reading $file\n"
7055 my $saved_dollar_slash = $/;
7057 $_ = $fc_file->getline;
7058 $/ = $saved_dollar_slash;
7063 # Split at unescaped new lines.
7064 my @lines = split (/(?<!\\)\n/, $content);
7067 while (defined ($_ = shift @lines))
7069 my $paragraph = "$_";
7070 # If we are a rule, eat as long as we start with a tab.
7071 if (/$RULE_PATTERN/smo)
7073 while (defined ($_ = shift @lines) && $_ =~ /^\t/)
7075 $paragraph .= "\n$_";
7077 unshift (@lines, $_);
7080 # If we are a comments, eat as much comments as you can.
7081 elsif (/$COMMENT_PATTERN/smo)
7083 while (defined ($_ = shift @lines)
7084 && $_ =~ /$COMMENT_PATTERN/smo)
7086 $paragraph .= "\n$_";
7088 unshift (@lines, $_);
7091 push @res, $paragraph;
7100 # ($COMMENT, $VARIABLES, $RULES)
7101 # &file_contents_internal ($IS_AM, $FILE, [%TRANSFORM])
7102 # -----------------------------------------------------
7103 # Return contents of a file from $libdir/am, automatically skipping
7104 # macros or rules which are already known. $IS_AM iff the caller is
7105 # reading an Automake file (as opposed to the user's Makefile.am).
7106 sub file_contents_internal ($$%)
7108 my ($is_am, $file, %transform) = @_;
7110 my $result_vars = '';
7111 my $result_rules = '';
7115 # We save the conditional stack on entry, and then check to make
7116 # sure it is the same on exit. This lets us conditonally include
7118 my @saved_cond_stack = @cond_stack;
7119 my $cond = conditional_string (@cond_stack);
7121 foreach (make_paragraphs ($file, %transform))
7124 &am_file_error ($file, "blank line following trailing backslash:\n$_")
7126 &am_file_error ($file, "comment following trailing backslash:\n$_")
7131 # Stick empty line before the incoming macro or rule.
7134 elsif (/$COMMENT_PATTERN/mso)
7136 # Stick comments before the incoming macro or rule.
7140 # Handle inclusion of other files.
7141 elsif (/$INCLUDE_PATTERN/o)
7143 if ($cond ne 'FALSE')
7145 my $file = ($is_am ? "$libdir/am/" : '') . $1;
7147 my ($com, $vars, $rules)
7148 = file_contents_internal ($is_am, $file, %transform);
7150 $result_vars .= $vars;
7151 $result_rules .= $rules;
7155 # Handling the conditionals.
7156 elsif (/$IF_PATTERN/o)
7158 $cond = cond_stack_if ($1, $2, $file);
7160 elsif (/$ELSE_PATTERN/o)
7162 $cond = cond_stack_else ($1, $2, $file);
7164 elsif (/$ENDIF_PATTERN/o)
7166 $cond = cond_stack_endif ($1, $2, $file);
7170 elsif (/$RULE_PATTERN/mso)
7172 # Separate relationship from optional actions: the first
7173 # `new-line tab" not preceded by backslash (continuation
7175 # I'm quite shoked! It seems that (\\\n|[^\n]) is not the
7176 # same as `([^\n]|\\\n)!!! Don't swap it, it breaks.
7178 /^((?:\\\n|[^\n])*)(?:\n(\t.*))?$/som;
7179 my ($relationship, $actions) = ($1, $2 || '');
7181 # Separate targets from dependencies: the first colon.
7182 $relationship =~ /^([^:]+\S+) *: *(.*)$/som;
7183 my ($targets, $dependencies) = ($1, $2);
7184 # Remove the escaped new lines.
7185 # I don't know why, but I have to use a tmp $flat_deps.
7186 my $flat_deps = &flatten ($dependencies);
7187 my @deps = split (' ', $flat_deps);
7189 foreach (split (' ' , $targets))
7191 # FIXME: We are not robust to people defining several targets
7192 # at once, only some of them being in %dependencies.
7194 # Output only if not in FALSE.
7195 if (defined $dependencies{$_}
7196 && $cond ne 'FALSE')
7198 &depend ($_, @deps);
7199 $actions{$_} .= $actions;
7203 # Free-lance dependency. Output the rule for all the
7204 # targets instead of one by one.
7206 # Work out all the conditions for which the target hasn't
7208 my @undefined_conds;
7209 if (defined $target_conditional{$targets})
7211 my @defined_conds = keys %{$target_conditional{$targets}};
7212 @undefined_conds = invert_conditions(@defined_conds);
7216 if (defined $targets{$targets})
7218 # No conditions for which target hasn't been defined
7219 @undefined_conds = ();
7223 # Target hasn't been defined for any conditions
7224 @undefined_conds = ("");
7228 if ($cond ne 'FALSE')
7231 for $undefined_cond (@undefined_conds)
7233 my $condparagraph = $paragraph;
7234 $condparagraph =~ s/^/make_condition (@cond_stack, $undefined_cond)/gme;
7235 $result_rules .= "$spacing$comment$condparagraph\n"
7236 if rule_define ($targets, $is_am,
7237 "$cond $undefined_cond", $file);
7240 $comment = $spacing = '';
7246 elsif (/$ASSIGNMENT_PATTERN/mso)
7248 my ($var, $type, $val) = ($1, $2, $3);
7249 &am_file_error ($file, "macro `$var' with trailing backslash")
7252 # Accumulating variables must not be output.
7253 $var_comment{$var} .= "$spacing"
7254 if (!defined $var_comment{$var}
7255 || substr ($var_comment{$var}, -1) ne "\n");
7256 $var_comment{$var} .= "$comment";
7257 macro_define ($var, $is_am, $type, $cond, $val, $file)
7258 if $cond ne 'FALSE';
7259 push (@var_list, $var);
7261 # If the user has set some variables we were in charge
7262 # of (which is detected by the first reading of
7263 # `header-vars.am'), we must not output them.
7264 $result_vars .= "$spacing$comment$_\n"
7265 if $type ne '+' && $var_is_am{$var} && $cond ne 'FALSE';
7267 $comment = $spacing = '';
7271 # This isn't an error; it is probably some tokens which
7272 # configure is supposed to replace, such as `@SET-MAKE@',
7273 # or some part of a rule cut by an if/endif.
7274 if ($cond ne 'FALSE')
7276 s/^/make_condition (@cond_stack)/gme;
7277 $result_rules .= "$spacing$comment$_\n";
7279 $comment = $spacing = '';
7283 if (join (' ', @saved_cond_stack) ne join (' ', @cond_stack))
7287 &am_error ("unterminated conditionals: @cond_stack");
7291 # FIXME: better error message here.
7292 &am_error ("conditionals not nested in include file");
7296 return ($comment, $result_vars, $result_rules);
7301 # &file_contents ($BASENAME, [%TRANSFORM])
7302 # ----------------------------------------
7303 # Return contents of a file from $libdir/am, automatically skipping
7304 # macros or rules which are already known.
7305 sub file_contents ($%)
7307 my ($basename, %transform) = @_;
7308 my ($comments, $variables, $rules) =
7309 file_contents_internal (1, "$libdir/am/$basename.am", %transform);
7310 return "$comments$variables$rules";
7315 # &transform (%PAIRS)
7316 # -------------------
7317 # Foreach ($TOKEN, $VAL) in %PAIRS produce a replacement expression suitable
7318 # for file_contents which:
7319 # - replaces @$TOKEN@ with $VALUE,
7320 # - enables/disables ?$TOKEN?.
7326 while (my ($token, $val) = each %pairs)
7328 $result .= "s/\Q%$token%\E/\Q$val\E/gm;";
7331 $result .= "s/\Q?$token?\E//gm;s/^.*\Q?!$token?\E.*\\n//gm;";
7332 $result .= "s/\Q%?$token%\E/TRUE/gm;";
7336 $result .= "s/\Q?!$token?\E//gm;s/^.*\Q?$token?\E.*\\n//gm;";
7337 $result .= "s/\Q%?$token%\E/FALSE/gm;";
7345 # Find all variable prefixes that are used for install directories. A
7346 # prefix `zar' qualifies iff:
7347 # * `zardir' is a variable.
7348 # * `zar_PRIMARY' is a variable.
7349 sub am_primary_prefixes
7351 my ($primary, $can_dist, @prefixes) = @_;
7353 my %valid = map { $_ => 0 } @prefixes;
7354 $valid{'EXTRA'} = 0;
7355 foreach my $varname (keys %var_value)
7357 # Automake is allowed to define variables that look like they
7358 # are magic variables, such as INSTALL_DATA.
7360 if $var_is_am{$varname};
7362 if ($varname =~ /^(nobase_)?(dist_|nodist_)?(.*)_$primary$/)
7364 my ($base, $dist, $X) = ($1 || '', $2 || '', $3 || '');
7365 if ($dist ne '' && ! $can_dist)
7367 # Note that a configure variable is always legitimate.
7368 # It is natural to name such variables after the
7369 # primary, so we explicitly allow it.
7370 if (! defined $configure_vars{$varname})
7372 &am_line_error ($varname,
7373 "invalid variable `$varname': `dist' is forbidden");
7376 elsif (! defined $valid{$X} && ! &variable_defined ("${X}dir"))
7378 # Note that a configure variable is always legitimate.
7379 # It is natural to name such variables after the
7380 # primary, so we explicitly allow it.
7381 if (! defined $configure_vars{$varname})
7383 &am_line_error ($varname,
7384 "invalid variable `$varname'");
7389 # Ensure all extended prefixes are actually used.
7390 $valid{"$base$dist$X"} = 1;
7398 # Handle `where_HOW' variable magic. Does all lookups, generates
7399 # install code, and possibly generates code to define the primary
7400 # variable. The first argument is the name of the .am file to munge,
7401 # the second argument is the primary variable (eg HEADERS), and all
7402 # subsequent arguments are possible installation locations. Returns
7403 # list of all values of all _HOW targets.
7405 # FIXME: this should be rewritten to be cleaner. It should be broken
7406 # up into multiple functions.
7408 # Usage is: am_install_var (OPTION..., file, HOW, where...)
7415 my $default_dist = 0;
7418 if ($args[0] eq '-noextra')
7422 elsif ($args[0] eq '-candist')
7426 elsif ($args[0] eq '-defaultdist')
7431 elsif ($args[0] !~ /^-/)
7438 my ($file, $primary, @prefixes) = @args;
7440 # Now that configure substitutions are allowed in where_HOW
7441 # variables, it is an error to actually define the primary. We
7442 # allow `JAVA', as it is customarily used to mean the Java
7443 # interpreter. This is but one of several Java hacks. Similarly,
7444 # `PYTHON' is customarily used to mean the Python interpreter.
7445 am_macro_error ($primary, "`$primary' is an anachronism")
7446 if &variable_defined ($primary)
7447 && ($primary ne 'JAVA' && $primary ne 'PYTHON');
7450 # Look for misspellings. It is an error to have a variable ending
7451 # in a "reserved" suffix whose prefix is unknown, eg
7452 # "bni_PROGRAMS". However, unusual prefixes are allowed if a
7453 # variable of the same name (with "dir" appended) exists. For
7454 # instance, if the variable "zardir" is defined, then
7455 # "zar_PROGRAMS" becomes valid. This is to provide a little extra
7456 # flexibility in those cases which need it.
7457 my %valid = &am_primary_prefixes ($primary, $can_dist, @prefixes);
7459 # If a primary includes a configure substitution, then the EXTRA_
7460 # form is required. Otherwise we can't properly do our job.
7462 my $warned_about_extra = 0;
7467 # True if the iteration is the first one. Used for instance to
7468 # output parts of the associated file only once.
7470 foreach my $X (sort keys %valid)
7472 my $nodir_name = $X;
7473 my $one_name = $X . '_' . $primary;
7475 unless (&variable_defined ($one_name));
7477 my $strip_subdir = 1;
7478 # If subdir prefix should be preserved, do so.
7479 if ($nodir_name =~ /^nobase_/)
7482 $nodir_name =~ s/^nobase_//;
7485 # If files should be distributed, do so.
7489 $dist_p = (($default_dist && $nodir_name !~ /^nodist_/)
7490 || (! $default_dist && $nodir_name =~ /^dist_/));
7491 $nodir_name =~ s/^(dist|nodist)_//;
7494 # Append actual contents of where_PRIMARY variable to
7496 foreach my $rcurs (&variable_value_as_list_recursive ($one_name, 'all'))
7498 # Skip configure substitutions. Possibly bogus.
7499 if ($rcurs =~ /^\@.*\@$/)
7501 if ($nodir_name eq 'EXTRA')
7503 if (! $warned_about_extra)
7505 $warned_about_extra = 1;
7506 am_macro_error ($one_name,
7507 "`$one_name' contains configure substitution, but shouldn't");
7510 # Check here to make sure variables defined in
7511 # configure.ac do not imply that EXTRA_PRIMARY
7513 elsif (! defined $configure_vars{$one_name})
7515 $require_extra = $one_name
7522 push (@result, $rcurs);
7525 # A blatant hack: we rewrite each _PROGRAMS primary to include
7527 if ($primary eq 'PROGRAMS')
7529 my @conds = variable_conditions_recursive ($one_name);
7532 foreach my $cond (@conds)
7534 my @one_binlist = ();
7535 my @condval = &variable_value_as_list_recursive ($one_name,
7537 foreach my $rcurs (@condval)
7539 # Skip autoconf substs. Also skip if the user
7540 # already applied $(EXEEXT).
7541 if ($rcurs =~ /^\@.*\@$/ || $rcurs =~ /\$\(EXEEXT\)$/)
7543 push (@one_binlist, $rcurs);
7547 push (@one_binlist, $rcurs . '$(EXEEXT)');
7551 push (@condvals, $cond);
7552 push (@condvals, join (' ', @one_binlist));
7555 variable_delete ($one_name);
7558 my $cond = shift (@condvals);
7559 my @val = split (' ', shift (@condvals));
7560 define_pretty_variable ($one_name, $cond, @val);
7564 # "EXTRA" shouldn't be used when generating clean targets,
7565 # all, or install targets.
7566 if ($nodir_name eq 'EXTRA')
7568 # We used to warn if EXTRA_FOO was defined uselessly,
7569 # but this was annoying.
7573 if ($nodir_name eq 'check')
7575 push (@check, '$(' . $one_name . ')');
7579 push (@used, '$(' . $one_name . ')');
7582 # Is this to be installed?
7583 my $install_p = $nodir_name ne 'noinst' && $nodir_name ne 'check';
7585 # If so, with install-exec? (or install-data?).
7586 my $exec_p = (defined $exec_dir_p {$nodir_name}
7587 ? $exec_dir_p {$nodir_name}
7588 : ($nodir_name =~ /exec/));
7590 # Singular form of $PRIMARY.
7591 (my $one_primary = $primary) =~ s/S$//;
7592 $output_rules .= &file_contents ($file,
7595 'PRIMARY' => $primary,
7596 'ONE_PRIMARY' => $one_primary,
7598 'NDIR' => $nodir_name,
7599 'BASE' => $strip_subdir,
7602 'INSTALL' => $install_p,
7603 'DIST' => $dist_p));
7608 # The JAVA variable is used as the name of the Java interpreter.
7609 # The PYTHON variable is used as the name of the Python interpreter.
7610 if (@used && $primary ne 'JAVA' && $primary ne 'PYTHON')
7613 define_pretty_variable ($primary, '', @used);
7614 $output_vars .= "\n";
7617 if ($require_extra && ! &variable_defined ('EXTRA_' . $primary))
7619 am_macro_error ($require_extra,
7620 "`$require_extra' contains configure substitution, but `EXTRA_$primary' not defined");
7623 # Push here because PRIMARY might be configure time determined.
7624 push (@all, '$(' . $primary . ')')
7625 if @used && $primary ne 'JAVA' && $primary ne 'PYTHON';
7627 # Make the result unique. This lets the user use conditionals in
7628 # a natural way, but still lets us program lazily -- we don't have
7629 # to worry about handling a particular object more than once.
7630 return uniq (sort @result);
7634 ################################################################
7636 # Each key in this hash is the name of a directory holding a
7637 # Makefile.in. These variables are local to `is_make_dir'.
7639 my $make_dirs_set = 0;
7644 if (! $make_dirs_set)
7646 foreach my $iter (@configure_input_files)
7648 $make_dirs{dirname ($iter)} = 1;
7650 # We also want to notice Makefile.in's.
7651 foreach my $iter (@other_input_files)
7653 if ($iter =~ /Makefile\.in$/)
7655 $make_dirs{dirname ($iter)} = 1;
7660 return defined $make_dirs{$dir};
7663 ################################################################
7665 # This variable is local to the "require file" set of functions.
7666 my @require_file_paths = ();
7668 # If a file name appears as a key in this hash, then it has already
7669 # been checked for. This variable is local to the "require file"
7671 %require_file_found = ();
7673 # See if we want to push this file onto dist_common. This function
7674 # encodes the rules for deciding when to do so.
7675 sub maybe_push_required_file
7677 my ($dir, $file, $fullfile) = @_;
7679 if ($dir eq $relative_dir)
7681 &push_dist_common ($file);
7683 elsif ($relative_dir eq '.' && ! &is_make_dir ($dir))
7685 # If we are doing the topmost directory, and the file is in a
7686 # subdir which does not have a Makefile, then we distribute it
7688 &push_dist_common ($fullfile);
7693 # &require_file_internal ($WHERE, $MYSTRICT, @FILES)
7694 # --------------------------------------------------
7695 # Verify that the file must exist in the current directory.
7696 # $MYSTRICT is the strictness level at which this file becomes required.
7698 # Must set require_file_paths before calling this function.
7699 # require_file_paths is set to hold a single directory (the one in
7700 # which the first file was found) before return.
7701 sub require_file_internal
7703 my ($where, $mystrict, @files) = @_;
7705 foreach my $file (@files)
7713 my $dangling_sym = 0;
7714 foreach my $dir (@require_file_paths)
7716 $fullfile = $dir . "/" . $file;
7717 $errdir = $dir unless $errdir;
7719 # Use different name for "error filename". Otherwise on
7720 # an error the bad file will be reported as eg
7721 # `../../install-sh' when using the default
7723 $errfile = $errdir . '/' . $file;
7725 if (-l $fullfile && ! -f $fullfile)
7730 elsif (-f $fullfile)
7733 &maybe_push_required_file ($dir, $file, $fullfile);
7739 # `--force-missing' only has an effect if `--add-missing' is
7741 if ($found_it && (! $add_missing || ! $force_missing))
7743 # Prune the path list.
7744 @require_file_paths = $save_dir;
7748 # If we've already looked for it, we're done. You might
7749 # wonder why we don't do this before searching for the
7750 # file. If we do that, then something like
7751 # AC_OUTPUT(subdir/foo foo) will fail to put foo.in into
7755 next if defined $require_file_found{$file};
7756 $require_file_found{$file} = 1;
7759 if ($strictness >= $mystrict)
7761 if ($dangling_sym && $add_missing)
7769 # Only install missing files according to our desired
7771 my $message = "required file `$errfile' not found";
7776 # Maybe run libtoolize.
7777 my @syslist = ('libtoolize', '--automake');
7778 push @syslist, '--copy'
7781 && grep ($_ eq $file, @libtoolize_files)
7782 && system (@syslist))
7784 $message = "installing `$errfile'";
7786 $trailer = "; cannot run `libtoolize': $!";
7788 elsif (-f ("$libdir/$file"))
7790 # Install the missing file. Symlink if we
7791 # can, copy if we must. Note: delete the file
7792 # first, in case it is a dangling symlink.
7793 $message = "installing `$errfile'";
7794 # Windows Perl will hang if we try to delete a
7795 # file that doesn't exist.
7796 unlink ($errfile) if -f $errfile;
7797 if ($symlink_exists && ! $copy_missing)
7799 if (! symlink ("$libdir/$file", $errfile))
7802 $trailer = "; error while making link: $!";
7805 elsif (system ('cp', "$libdir/$file", $errfile))
7808 $trailer = "\n error while copying";
7812 &maybe_push_required_file (dirname ($errfile),
7815 # Prune the path list.
7816 @require_file_paths = &dirname ($errfile);
7819 # If --force-missing was specified, and we have
7820 # actually found the file, then do nothing.
7822 if $found_it && $force_missing;
7828 # FIXME: allow actual file to be specified.
7829 am_file_warning ("$configure_ac:$line",
7830 "$message$trailer");
7834 &am_line_warning ($line, "$message$trailer");
7841 # FIXME: allow actual file to be specified.
7842 am_file_error ("$configure_ac:$line",
7843 "$message$trailer");
7847 am_line_error ($line, "$message$trailer");
7855 # Like require_file_with_line, but error messages refer to
7856 # configure.ac, not the current Makefile.am.
7857 sub require_file_with_conf_line
7859 @require_file_paths = $relative_dir;
7860 &require_file_internal (1, @_);
7863 sub require_file_with_line
7865 @require_file_paths = $relative_dir;
7866 &require_file_internal (0, @_);
7871 @require_file_paths = $relative_dir;
7872 &require_file_internal (0, '', @_);
7875 # Require an auxiliary file.
7876 # Looks in configuration path, as specified by AC_CONFIG_AUX_DIR.
7877 sub require_aux_file_with_line
7879 my $from = shift; # 1 for configure.ac, 0 for Makefile.am
7881 @require_file_paths = @config_aux_path;
7882 &require_file_internal ($from, $line, @_);
7883 my $dir = $require_file_paths[0];
7884 # &require_file_internal pruned the file path to the
7885 # exact directory where the file is lying. Update
7886 # @config_aux_path to speed up future uses.
7887 @config_aux_path = @require_file_paths;
7888 # Avoid unsightly '/.'s.
7889 $config_aux_dir = '$(top_srcdir)' . ($dir eq '.' ? "" : "/$dir");
7892 # Assumes that the line number is in Makefile.am.
7893 sub require_conf_file_with_line
7895 &require_aux_file_with_line (0, @_);
7898 # File required from a Makefile.am. No line number available.
7899 sub require_conf_file
7901 &require_conf_file_with_line ('', @_);
7904 # Assumes that the line number is in configure.ac.
7905 sub require_conf_file_with_conf_line
7907 &require_aux_file_with_line (1, @_);
7910 # Require a file that is also required by Autoconf. No line number available.
7911 sub require_config_file
7913 &require_conf_file_with_conf_line ('', @_);
7916 ################################################################
7918 # &require_build_directory ($DIRECTORY)
7919 # ------------------------------------
7920 # Emit rules to create $DIRECTORY if needed, and return
7921 # the file that any target requiring this directory should be made
7923 sub require_build_directory ($)
7925 my $directory = shift;
7926 my $dirstamp = "$directory/.dirstamp";
7928 # Don't emit the rule twice.
7929 if (! defined $directory_map{$directory})
7931 $directory_map{$directory} = 1;
7933 # Directory must be removed by `make distclean'.
7934 $compile_clean_files{$dirstamp} = $DIST_CLEAN;
7936 $output_rules .= ("$dirstamp:\n"
7937 . "\t\@\$(mkinstalldirs) $directory\n"
7938 . "\t\@: > $dirstamp\n");
7944 # &require_build_directory_maybe ($FILE)
7945 # --------------------------------------
7946 # If $FILE lies in a subdirectory, emit a rule to create this
7947 # directory and return the file that $FILE should be made
7948 # dependent upon. Otherwise, just return the empty string.
7949 sub require_build_directory_maybe ($)
7952 my $directory = dirname ($file);
7954 if ($directory ne '.')
7956 return &require_build_directory ($directory);
7964 ################################################################
7966 # Push a list of files onto dist_common.
7967 sub push_dist_common
7969 &prog_error ("push_dist_common run after handle_dist")
7970 if $handle_dist_run;
7971 macro_define ('DIST_COMMON', 1, '+', '', join (' ', @_), '');
7978 $strictness_name = $_[0];
7979 if ($strictness_name eq 'gnu')
7983 elsif ($strictness_name eq 'gnits')
7985 $strictness = $GNITS;
7987 elsif ($strictness_name eq 'foreign')
7989 $strictness = $FOREIGN;
7993 die "$me: level `$strictness_name' not recognized\n";
7998 ################################################################
8000 # Ensure a file exists.
8005 my $touch = new IO::File (">> $file");
8009 # Glob something. Do this to avoid indentation screwups everywhere we
8010 # want to glob. Gross!
8017 # Remove one level of brackets and strip leading spaces,
8018 # as does m4 to function arguments.
8024 my @letters = split //;
8033 next if $depth == 1;
8038 next if $depth == 0;
8039 # don't count orphan right brackets
8040 $depth = 0 if $depth < 0;
8044 return join '', @result;
8047 ################################################################
8049 # am_print_error ($LEADER, @ARGS)
8050 # -------------------------------
8051 # Do the work of printing the error message. Join @ARGS with spaces,
8052 # then split at newlines and add $LEADER to each line. Uses `warn' to
8053 # print message. Set exit status.
8056 my ($leader, @args) = @_;
8057 my $text = join (' ', @args);
8058 @args = split ("\n", $text);
8059 $text = $leader . join ("\n" . $leader, @args) . "\n";
8064 # Print an error message and set exit status.
8067 am_print_error ("$me: ${am_file}.am: ", @_);
8070 # am_file_error ($FILE, @ARGS)
8071 # ----------------------------
8074 my ($file, @args) = @_;
8076 am_print_error ("$file: ", @args);
8080 # &am_macro_error ($MACRO, @ARGS)
8081 # -------------------------------
8082 # Report an error, @ARGS, about $MACRO.
8083 sub am_macro_error ($@)
8085 my ($macro, @args) = @_;
8086 am_file_error ($var_location{$macro}, @args);
8090 # &am_target_error ($TARGET, @ARGS)
8091 # ---------------------------------
8092 # Report an error, @ARGS, about the rule $TARGET.
8093 sub am_target_error ($@)
8095 my ($target, @args) = @_;
8096 am_file_error ($targets{$target}, @args);
8100 # &am_line_error ($SYMBOL or $LINE, @ARGS)
8101 # ----------------------------------------
8102 # Report an error about $SYMBOL. The error message is composed of the
8103 # @ARGS, and try to find the location of the error of $SYMBOL.
8104 sub am_line_error ($@)
8106 my ($symbol, @args) = @_;
8108 if ($symbol && "$symbol" ne '-1')
8110 if ($symbol =~ /^\d+$/)
8112 # SYMBOL is a line number, then it must be a Makefile.am.
8113 am_file_error ("${am_file}.am:$symbol", @args);
8115 elsif (defined $configure_vars{$symbol})
8117 # SYMBOL is a variable defined in configure.ac, so add the
8118 # appropriate line number.
8119 am_file_error ($configure_vars{$symbol}, @args);
8121 elsif (defined $var_location{$symbol})
8123 croak "use am_macro_error for macros: $symbol\n";
8125 elsif (defined $targets{$symbol})
8127 croak "use am_target_error for targets: $symbol\n";
8131 # Couldn't find the line number.
8132 $where = "${am_file}.am";
8135 am_file_error ($where, @args);
8143 # Like am_error, but while scanning configure.ac.
8146 # FIXME: can run in subdirs.
8147 am_print_error ("$me: $configure_ac: ", @_);
8150 # Warning message with line number referring to configure.ac.
8151 # Does not affect exit_status
8152 sub am_file_warning (@)
8154 my $saved_exit_status = $exit_status;
8155 my $sig = $SIG{'__WARN__'};
8156 $SIG{'__WARN__'} = 'DEFAULT';
8158 $exit_status = $saved_exit_status;
8159 $SIG{'__WARN__'} = $sig;
8162 # Like am_line_error, but doesn't affect exit status.
8163 sub am_line_warning (@)
8165 my $saved_exit_status = $exit_status;
8166 my $sig = $SIG{'__WARN__'};
8167 $SIG{'__WARN__'} = 'DEFAULT';
8169 $exit_status = $saved_exit_status;
8170 $SIG{'__WARN__'} = $sig;
8173 # Tell user where our aclocal.m4 is, but only once.
8174 sub keyed_aclocal_warning ($)
8177 warn "$me: macro `$key' can be generated by `aclocal'\n";
8180 # Print usage information.
8184 Usage: $0 [OPTION] ... [Makefile]...
8186 Generate Makefile.in for configure from Makefile.am.
8189 --help print this help, then exit
8190 --version print version number, then exit
8191 -v, --verbose verbosely list files processed
8192 -o, --output-dir=DIR put generated Makefile.in's into DIR
8193 --no-force only update Makefile.in's that are out of date
8195 Dependency tracking:
8196 -i, --ignore-deps disable dependency tracking code
8197 --include-deps enable dependency tracking code
8200 --cygnus assume program is part of Cygnus-style tree
8201 --foreign set strictness to foreign
8202 --gnits set strictness to gnits
8203 --gnu set strictness to gnu
8206 -a, --add-missing add missing standard files to package
8207 --libdir=DIR directory storing library files
8208 -c, --copy with -a, copy missing files (default is symlink)
8209 -f, --force-missing force update of standard files
8214 foreach my $iter (sort ((@common_files, @common_sometimes)))
8216 push (@lcomm, $iter) unless $iter eq $last;
8221 print "\nFiles which are automatically distributed, if found:\n";
8222 format USAGE_FORMAT =
8223 @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<
8224 $four[0], $four[1], $four[2], $four[3]
8226 $~ = "USAGE_FORMAT";
8229 my $rows = int(@lcomm / $cols);
8230 my $rest = @lcomm % $cols;
8241 for (my $y = 0; $y < $rows; $y++)
8243 @four = ("", "", "", "");
8244 for (my $x = 0; $x < $cols; $x++)
8246 last if $y + 1 == $rows && $x == $rest;
8248 my $idx = (($x > $rest)
8249 ? ($rows * $rest + ($rows - 1) * ($x - $rest))
8253 $four[$x] = $lcomm[$idx];
8258 print "\nReport bugs to <bug-automake\@gnu.org>.\n";
8265 # Print version information
8269 automake (GNU $PACKAGE) $VERSION
8270 Written by Tom Tromey <tromey\@cygnus.com>.
8272 Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
8273 Free Software Foundation, Inc.
8274 This is free software; see the source for copying conditions. There is NO
8275 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.