5 eval 'exec @PERL@ -S $0 ${1+"$@"}'
8 # automake - create Makefile.in from Makefile.am
9 # Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
10 # Free Software Foundation, Inc.
12 # This program is free software; you can redistribute it and/or modify
13 # it under the terms of the GNU General Public License as published by
14 # the Free Software Foundation; either version 2, or (at your option)
17 # This program is distributed in the hope that it will be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # GNU General Public License for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, write to the Free Software
24 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
27 # Originally written by David Mackenzie <djm@gnu.ai.mit.edu>.
28 # Perl reimplementation by Tom Tromey <tromey@cygnus.com>.
34 my $prefix = "@prefix@";
35 my $perllibdir = $ENV{'perllibdir'} || "@datadir@/@PACKAGE@";
36 unshift @INC, "$perllibdir";
40 struct (# Short name of the language (c, f77...).
42 # Nice name of the language (C, Fortran 77...).
45 # List of configure variables which must be defined.
49 # `pure' is `1' or `'. A `pure' language is one where, if
50 # all the files in a directory are of that language, then we
51 # do not require the C compiler or any code to call it.
56 # Name of the compiling variable (COMPILE).
58 # Content of the compiling variable.
60 # Flag to require compilation without linking (-c).
61 'compile_flag' => "\$",
64 # Should the flag be defined as a configure variable.
65 # Defaults to true. FIXME: this should go away once
66 # we move to autoconf tracing.
67 'define_flag' => "\$",
69 # The file to use when generating rules for this language.
70 # The default is 'depend2'.
73 # Name of the linking variable (LINK).
75 # Content of the linking variable.
78 # Name of the linker variable (LD).
80 # Content of the linker variable ($(CC)).
83 # Flag to specify the output file (-o).
84 'output_flag' => "\$",
87 # This is a subroutine which is called whenever we finally
88 # determine the context in which a source file will be
90 '_target_hook' => "\$");
96 if (defined $self->_finish)
102 sub target_hook ($$$$)
105 if (defined $self->_target_hook)
107 &{$self->_target_hook} (@_);
113 use strict 'vars', 'subs';
114 use Automake::General;
123 # Parameters set by configure. Not to be changed. NOTE: assign
124 # VERSION as string so that eg version 0.30 will print correctly.
125 my $VERSION = "@VERSION@";
126 my $PACKAGE = "@PACKAGE@";
127 my $prefix = "@prefix@";
128 my $libdir = "@datadir@/@PACKAGE@";
131 my $IGNORE_PATTERN = '^\s*##([^#\n].*)?\n';
132 my $WHITE_PATTERN = '^\s*$';
133 my $COMMENT_PATTERN = '^#';
134 my $TARGET_PATTERN='[$a-zA-Z_.@][-.a-zA-Z0-9_(){}/$+@]*';
135 # A rule has three parts: a list of targets, a list of dependencies,
136 # and optionally actions.
138 "^($TARGET_PATTERN(?:(?:\\\\\n|\\s)+$TARGET_PATTERN)*) *:([^=].*|)\$";
140 my $SUFFIX_RULE_PATTERN = '^(\.[a-zA-Z0-9_(){}$+@]+)(\.[a-zA-Z0-9_(){}$+@]+)$';
141 # Only recognize leading spaces, not leading tabs. If we recognize
142 # leading tabs here then we need to make the reader smarter, because
143 # otherwise it will think rules like `foo=bar; \' are errors.
144 my $MACRO_PATTERN = '^[A-Za-z0-9_@]+$';
145 my $ASSIGNMENT_PATTERN = '^ *([^ \t=:+]*)\s*([:+]?)=\s*(.*)$';
146 # This pattern recognizes a Gnits version id and sets $1 if the
147 # release is an alpha release. We also allow a suffix which can be
148 # used to extend the version number with a "fork" identifier.
149 my $GNITS_VERSION_PATTERN = '\d+\.\d+([a-z]|\.\d+)?(-[A-Za-z0-9]+)?';
150 my $IF_PATTERN = '^if\s+(!?)\s*([A-Za-z][A-Za-z0-9_]*)\s*(?:#.*)?$';
151 my $ELSE_PATTERN = '^else(?:\s+(!?)\s*([A-Za-z][A-Za-z0-9_]*))?\s*(?:#.*)?$';
152 my $ENDIF_PATTERN = '^endif(?:\s+(!?)\s*([A-Za-z][A-Za-z0-9_]*))?\s*(?:#.*)?$';
153 my $PATH_PATTERN='(\w|[/.-])+';
154 # This will pass through anything not of the prescribed form.
155 my $INCLUDE_PATTERN = ('^include\s+'
156 . '((\$\(top_srcdir\)/' . $PATH_PATTERN . ')'
157 . '|(\$\(srcdir\)/' . $PATH_PATTERN . ')'
158 . '|([^/\$]' . $PATH_PATTERN. '))\s*(#.*)?$');
160 # Some regular expressions. One reason to put them here is that it
161 # makes indentation work better in Emacs.
162 my $AC_CONFIG_AUX_DIR_PATTERN = 'AC_CONFIG_AUX_DIR\(([^)]+)\)';
163 my $AM_INIT_AUTOMAKE_PATTERN = 'AM_INIT_AUTOMAKE\([^,]*,([^,)]+)[,)]';
164 my $AM_PACKAGE_VERSION_PATTERN = '^\s*\[?([^]\s]+)\]?\s*$';
166 # This handles substitution references like ${foo:.a=.b}.
167 my $SUBST_REF_PATTERN = "^([^:]*):([^=]*)=(.*)\$";
169 # Note that there is no AC_PATH_TOOL. But we don't really care.
170 my $AC_CHECK_PATTERN = 'AC_(CHECK|PATH)_(PROG|PROGS|TOOL)\(\[?(\w+)';
171 my $AM_MISSING_PATTERN = 'AM_MISSING_PROG\(\[?(\w+)';
172 # Just check for alphanumeric in AC_SUBST. If you do AC_SUBST(5),
174 my $AC_SUBST_PATTERN = 'AC_SUBST\(\[?(\w+)';
175 my $AM_CONDITIONAL_PATTERN = 'AM_CONDITIONAL\(\[?(\w+)';
176 # Match `-d' as a command-line argument in a string.
177 my $DASH_D_PATTERN = "(^|\\s)-d(\\s|\$)";
178 # Directories installed during 'install-exec' phase.
179 my $EXEC_DIR_PATTERN =
180 '^(?:bin|sbin|libexec|sysconf|localstate|lib|pkglib|.*exec.*)$'; #'
182 # Constants to define the "strictness" level.
183 use constant FOREIGN => 0;
184 use constant GNU => 1;
185 use constant GNITS => 2;
187 # Values for AC_CANONICAL_*
188 use constant AC_CANONICAL_HOST => 1;
189 use constant AC_CANONICAL_SYSTEM => 2;
191 # Values indicating when something should be cleaned. Right now we
192 # only need to handle `mostly'- and `dist'-clean; add more as
194 use constant MOSTLY_CLEAN => 0;
195 use constant DIST_CLEAN => 1;
198 my @libtool_files = qw(ltmain.sh config.guess config.sub);
199 # ltconfig appears here for compatibility with old versions of libtool.
200 my @libtool_sometimes = qw(ltconfig ltcf-c.sh ltcf-cxx.sh ltcf-gcj.sh);
202 # Commonly found files we look for and automatically include in
205 (qw(ABOUT-GNU ABOUT-NLS AUTHORS BACKLOG COPYING COPYING.LIB
206 ChangeLog INSTALL NEWS README THANKS TODO acinclude.m4
207 ansi2knr.1 ansi2knr.c compile config.guess config.sub
208 configure configure.ac configure.in depcomp elisp-comp
209 install-sh libversion.in mdate-sh missing mkinstalldirs
210 py-compile texinfo.tex ylwrap),
211 @libtool_files, @libtool_sometimes);
213 # Commonly used files we auto-include, but only sometimes.
214 my @common_sometimes =
215 qw(aclocal.m4 acconfig.h config.h.top config.h.bot stamp-vti);
217 # Copyright on generated Makefile.ins.
218 my $gen_copyright = "\
219 # Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
220 # Free Software Foundation, Inc.
221 # This Makefile.in is free software; the Free Software Foundation
222 # gives unlimited permission to copy and/or distribute it,
223 # with or without modifications, as long as this notice is preserved.
225 # This program is distributed in the hope that it will be useful,
226 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
227 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
228 # PARTICULAR PURPOSE.
231 # These constants are returned by lang_*_rewrite functions.
232 # LANG_SUBDIR means that the resulting object file should be in a
233 # subdir if the source file is. In this case the file name cannot
234 # have `..' components.
236 my $LANG_PROCESS = 1;
239 # Map from obsolete macros to hints for new macros.
240 # If you change this, change the corresponding list in aclocal.in.
241 # FIXME: should just put this into a single file.
242 my %obsolete_macros =
244 'AC_FEATURE_CTYPE' => "use `AC_HEADER_STDC'",
245 'AC_FEATURE_ERRNO' => "add `strerror' to `AC_REPLACE_FUNCS(...)'",
246 'AC_FEATURE_EXIT' => '',
247 'AC_SYSTEM_HEADER' => '',
249 # Note that we do not handle this one, because it is still run
250 # from AM_CONFIG_HEADER. So we deal with it specially in
251 # &scan_autoconf_files.
252 # 'AC_CONFIG_HEADER' => "use `AM_CONFIG_HEADER'",
254 'fp_C_PROTOTYPES' => "use `AM_C_PROTOTYPES'",
255 'fp_PROG_CC_STDC' => "use `AM_PROG_CC_STDC'",
256 'fp_PROG_INSTALL' => "use `AC_PROG_INSTALL'",
257 'fp_WITH_DMALLOC' => "use `AM_WITH_DMALLOC'",
258 'fp_WITH_REGEX' => "use `AM_WITH_REGEX'",
259 'gm_PROG_LIBTOOL' => "use `AM_PROG_LIBTOOL'",
260 'jm_MAINTAINER_MODE' => "use `AM_MAINTAINER_MODE'",
261 'md_TYPE_PTRDIFF_T' => "add `ptrdiff_t' to `AC_CHECK_TYPES(...)'",
262 'ud_PATH_LISPDIR' => "use `AM_PATH_LISPDIR'",
263 'ud_GNU_GETTEXT' => "use `AM_GNU_GETTEXT'",
265 # Now part of autoconf proper, under a different name.
266 'fp_FUNC_FNMATCH' => "use `AC_FUNC_FNMATCH'",
267 'AM_SANITY_CHECK_CC' => "automatically done by `AC_PROG_CC'",
268 'AM_PROG_INSTALL' => "use `AC_PROG_INSTALL'",
269 'AM_EXEEXT' => "automatically done by `AC_PROG_(CC|CXX|F77)'",
270 'AM_CYGWIN32' => "use `AC_CYGWIN'",
271 'AM_MINGW32' => "use `AC_MINGW32'",
272 'AM_FUNC_MKTIME' => "use `AC_FUNC_MKTIME'",
275 # Regexp to match the above macros.
276 my $obsolete_rx = '\b(' . join ('|', keys %obsolete_macros) . ')\b';
280 ## ---------------------------------- ##
281 ## Variables related to the options. ##
282 ## ---------------------------------- ##
284 # TRUE if we should always generate Makefile.in.
285 my $force_generation = 1;
287 # Strictness level as set on command line.
288 my $default_strictness = GNU;
290 # Name of strictness level, as set on command line.
291 my $default_strictness_name = 'gnu';
293 # This is TRUE if automatic dependency generation code should be
294 # included in generated Makefile.in.
295 my $cmdline_use_dependencies = 1;
297 # This holds our (eventual) exit status. We don't actually exit until
298 # we have processed all input files.
301 # From the Perl manual.
302 my $symlink_exists = (eval 'symlink ("", "");', $@ eq '');
304 # TRUE if missing standard files should be installed.
307 # TRUE if we should copy missing files; otherwise symlink if possible.
308 my $copy_missing = 0;
310 # TRUE if we should always update files that we know about.
311 my $force_missing = 0;
314 ## ---------------------------------------- ##
315 ## Variables filled during files scanning. ##
316 ## ---------------------------------------- ##
318 # Name of the top autoconf input: `configure.ac' or `configure.in'.
319 my $configure_ac = '';
321 # Files found by scanning configure.ac for LIBOBJS.
324 # True if AM_C_PROTOTYPES appears in configure.ac.
325 my $am_c_prototypes = 0;
327 # Names used in AC_CONFIG_HEADER call.
328 my @config_headers = ();
329 # Where AC_CONFIG_HEADER appears.
330 my $config_header_location;
332 # Directory where output files go. Actually, output files are
333 # relative to this directory.
334 my $output_directory = '.';
336 # List of Makefile.am's to process, and their corresponding outputs.
337 my @input_files = ();
338 my %output_files = ();
340 # Complete list of Makefile.am's that exist.
341 my @configure_input_files = ();
343 # List of files in AC_CONFIG_FILES/AC_OUTPUT without Makefile.am's,
345 my @other_input_files = ();
346 # Where the last AC_CONFIG_FILES/AC_OUTPUT appears.
347 my $ac_config_files_location;
349 # List of directories to search for configure-required files. This
350 # can be set by AC_CONFIG_AUX_DIR.
351 my @config_aux_path = qw(. .. ../..);
352 my $config_aux_dir = '';
353 my $config_aux_dir_set_in_configure_in = 0;
355 # Whether AM_GNU_GETTEXT has been seen in configure.ac.
356 my $seen_gettext = 0;
357 # Where AM_GNU_GETTEXT appears.
358 my $ac_gettext_location;
360 # TRUE if AC_PROG_LEX or AM_PROG_LEX were seen.
361 my $seen_prog_lex = 0;
363 # TRUE if we've seen AC_CANONICAL_(HOST|SYSTEM).
364 my $seen_canonical = 0;
365 my $canonical_location;
367 # Where AC_PROG_LIBTOOL appears.
370 # Where AM_MAINTAINER_MODE appears.
373 # Actual version we've seen.
374 my $package_version = '';
376 # Where version is defined.
377 my $package_version_location;
379 # Where AM_PATH_LISPDIR appears.
380 my $am_lispdir_location;
382 # Where AM_PATH_PYTHON appears.
383 my $pythondir_location;
385 # TRUE if we've seen AC_ENABLE_MULTILIB.
386 my $seen_multilib = 0;
388 # TRUE if we've seen AM_PROG_CC_C_O
391 # TRUE if we've seen AM_INIT_AUTOMAKE.
392 my $seen_init_automake = 0;
394 # Hash table of discovered configure substitutions. Keys are names,
395 # values are `FILE:LINE' strings which are used by error message
397 my %configure_vars = ();
399 # This is used to keep track of which variable definitions we are
400 # scanning. It is only used in certain limited ways, but it has to be
401 # global. It is declared just for documentation purposes.
402 my %vars_scanned = ();
404 # TRUE if --cygnus seen.
407 # Hash table of AM_CONDITIONAL variables seen in configure.
408 my %configure_cond = ();
410 # This maps extensions onto language names.
411 my %extension_map = ();
413 # List of the DIST_COMMON files we discovered while reading
415 my $configure_dist_common = '';
417 # This maps languages names onto objects.
420 # List of targets we must always output.
421 # FIXME: Complete, and remove falsely required targets.
422 my %required_targets =
433 # FIXME: Not required, temporary hacks.
434 # Well, actually they are sort of required: the -recursive
435 # targets will run them anyway...
438 'install-data-am' => 1,
439 'install-exec-am' => 1,
440 'installcheck-am' => 1,
446 # This is set to 1 when Automake needs to be run again.
447 # (For instance, this happens when an auxiliary file such as
448 # depcomp is added after the toplevel Makefile.in -- which
449 # should distribute depcomp -- has been generated.)
450 my $automake_needs_to_reprocess_all_files = 0;
453 ################################################################
455 ## ------------------------------------------ ##
456 ## Variables reset by &initialize_per_input. ##
457 ## ------------------------------------------ ##
459 # Basename and relative dir of the input file.
463 # Same but wrt Makefile.in.
467 # These two variables are used when generating each Makefile.in.
468 # They hold the Makefile.in until it is ready to be printed.
475 # Suffixes found during a run.
478 # Handling the variables.
481 # - $var_value{$VAR}{$COND} is its value associated to $COND,
482 # - $var_location{$VAR} is where it was defined,
483 # - $var_comment{$VAR} are the comments associated to it.
484 # - $var_type{$VAR} is how it has been defined (`', `+', or `:'),
485 # - $var_is_am{$VAR} is true if the variable is owned by Automake.
492 # This holds a 1 if a particular variable was examined.
495 # This holds the names which are targets. These also appear in
499 # Same as %VAR_VALUE, but for targets.
500 my %target_conditional;
502 # This is the conditional stack.
505 # This holds the set of included files.
508 # This holds a list of directories which we must create at `dist'
509 # time. This is used in some strange scenarios involving weird
510 # AC_OUTPUT commands.
513 # List of dependencies for the obvious targets.
518 # Holds the dependencies of targets which dependencies are factored.
519 # Typically, `.PHONY' will appear in plenty of *.am files, but must
520 # be output once. Arguably all pure dependencies could be subject
521 # to this factorization, but it is not unpleasant to have paragraphs
522 # in Makefile: keeping related stuff altogether.
525 # Holds the factored actions. Tied to %DEPENDENCIES, i.e., filled
526 # only when keys exists in %DEPENDENCIES.
529 # A list of files deleted by `maintainer-clean'.
530 my @maintainer_clean_files;
532 # Keys in this hash table are object files or other files in
533 # subdirectories which need to be removed. This only holds files
534 # which are created by compilations. The value in the hash indicates
535 # when the file should be removed.
536 my %compile_clean_files;
538 # Value of `$(SOURCES)', used by tags.am.
540 # Sources which go in the distribution.
543 # This hash maps object file names onto their corresponding source
544 # file names. This is used to ensure that each object is created
545 # by a single source file.
548 # This keeps track of the directories for which we've already
549 # created `.dirstamp' code.
559 # Options from AUTOMAKE_OPTIONS.
562 # Whether or not dependencies are handled. Can be further changed
564 my $use_dependencies;
566 # This is a list of all targets to run during "make dist".
569 # Keys in this hash are the basenames of files which must depend
573 # This maps the source extension of a suffix rule to its
574 # corresponding output extension.
575 # FIXME: because this hash maps one input extension to one output
576 # extension, Automake cannot handle two suffix rules with the same
580 # This is the name of the redirect `all' target to use.
583 # This keeps track of which extensions we've seen (that we care
587 # This is random scratch space for the language finish functions.
588 # Don't randomly overwrite it; examine other uses of keys first.
589 my %language_scratch;
591 # We keep track of which objects need special (per-executable)
592 # handling on a per-language basis.
593 my %lang_specific_files;
595 # This is set when `handle_dist' has finished. Once this happens,
596 # we should no longer push on dist_common.
599 # Used to store a set of linkers needed to generate the sources currently
600 # under consideration.
603 # True if we need `LINK' defined. This is a hack.
606 # This is the list of such variables to output.
607 # FIXME: Might be useless actually.
610 # Was get_object_extension run?
611 # FIXME: This is a hack. a better switch should be found.
612 my $get_object_extension_was_run;
614 # Contains a stack of `from' parts of variable substitutions currently in
618 # Contains a stack of `to' parts of variable substitutions currently in
622 # Associates a variable name, together with a list of substitutions to be
623 # performed on it, with a number. Used to provide unique names for generated
627 ## --------------------------------- ##
628 ## Forward subroutine declarations. ##
629 ## --------------------------------- ##
630 sub register_language (%);
631 sub file_contents_internal ($$%);
632 sub define_objects_from_sources ($$$$$$$);
635 # &initialize_per_input ()
636 # ------------------------
637 # (Re)-Initialize per-Makefile.am variables.
638 sub initialize_per_input ()
641 $am_relative_dir = '';
648 $output_trailer = '';
664 %target_conditional = ();
684 # Installing/uninstalling.
685 'install-data-am' => [],
686 'install-exec-am' => [],
687 'uninstall-am' => [],
690 'uninstall-man' => [],
692 'install-info' => [],
693 'install-info-am' => [],
694 'uninstall-info' => [],
696 'installcheck-am' => [],
700 'mostlyclean-am' => [],
701 'maintainer-clean-am' => [],
702 'distclean-am' => [],
705 'maintainer-clean' => [],
716 @maintainer_clean_files = ();
727 $strictness = $default_strictness;
728 $strictness_name = $default_strictness_name;
732 $use_dependencies = $cmdline_use_dependencies;
742 %extension_seen = ();
744 %language_scratch = ();
746 %lang_specific_files = ();
748 $handle_dist_run = 0;
754 $get_object_extension_was_run = 0;
756 %compile_clean_files = ();
760 ################################################################
762 # Initialize our list of languages that are internally supported.
765 register_language ('name' => 'c',
767 'config_vars' => ['CC'],
771 'compiler' => 'COMPILE',
772 'compile' => '$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)',
776 'link' => '$(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
777 'compile_flag' => '-c',
778 'extensions' => ['.c'],
779 '_finish' => \&lang_c_finish);
782 register_language ('name' => 'cxx',
784 'config_vars' => ['CXX'],
785 'linker' => 'CXXLINK',
786 'link' => '$(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
788 'flags' => 'CXXFLAGS',
789 'compile' => '$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)',
790 'compiler' => 'CXXCOMPILE',
791 'compile_flag' => '-c',
792 'output_flag' => '-o',
796 'extensions' => ['.c++', '.cc', '.cpp', '.cxx', '.C']);
799 register_language ('name' => 'objc',
800 'Name' => 'Objective C',
801 'config_vars' => ['OBJC'],
802 'linker' => 'OBJCLINK',,
803 'link' => '$(OBJCLD) $(AM_OBJCFLAGS) $(OBJCFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
805 'flags' => 'OBJCFLAGS',
806 'compile' => '$(OBJC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_OBJCFLAGS) $(OBJCFLAGS)',
807 'compiler' => 'OBJCCOMPILE',
808 'compile_flag' => '-c',
809 'output_flag' => '-o',
813 'extensions' => ['.m']);
816 register_language ('name' => 'header',
818 'extensions' => ['.h', '.H', '.hxx', '.h++', '.hh',
821 '_finish' => sub { });
824 register_language ('name' => 'yacc',
826 'config_vars' => ['YACC'],
829 'compile' => '$(YACC) $(YFLAGS) $(AM_YFLAGS)',
830 'compiler' => 'YACCCOMPILE',
831 'extensions' => ['.y'],
832 'rule_file' => 'yacc',
833 '_finish' => \&lang_yacc_finish,
834 '_target_hook' => \&lang_yacc_target_hook);
835 register_language ('name' => 'yaccxx',
836 'Name' => 'Yacc (C++)',
837 'config_vars' => ['YACC'],
838 'rule_file' => 'yacc',
841 'compiler' => 'YACCCOMPILE',
842 'compile' => '$(YACC) $(YFLAGS) $(AM_YFLAGS)',
843 'extensions' => ['.y++', '.yy', '.yxx', '.ypp'],
844 '_finish' => \&lang_yacc_finish,
845 '_target_hook' => \&lang_yacc_target_hook);
848 register_language ('name' => 'lex',
850 'config_vars' => ['LEX'],
851 'rule_file' => 'lex',
854 'compile' => '$(LEX) $(LFLAGS) $(AM_LFLAGS)',
855 'compiler' => 'LEXCOMPILE',
856 'extensions' => ['.l'],
857 '_finish' => \&lang_lex_finish);
858 register_language ('name' => 'lexxx',
859 'Name' => 'Lex (C++)',
860 'config_vars' => ['LEX'],
861 'rule_file' => 'lex',
864 'compile' => '$(LEX) $(LFLAGS) $(AM_LFLAGS)',
865 'compiler' => 'LEXCOMPILE',
866 'extensions' => ['.l++', '.ll', '.lxx', '.lpp'],
867 '_finish' => \&lang_lex_finish);
870 register_language ('name' => 'asm',
871 'Name' => 'Assembler',
872 'config_vars' => ['AS', 'ASFLAGS'],
874 'flags' => 'ASFLAGS',
875 # Users can set AM_ASFLAGS to includes DEFS, INCLUDES,
876 # or anything else required. They can also set AS.
877 'compile' => '$(AS) $(AM_ASFLAGS) $(ASFLAGS)',
878 'compiler' => 'ASCOMPILE',
879 'compile_flag' => '-c',
880 'extensions' => ['.s', '.S'],
882 # With assembly we still use the C linker.
883 '_finish' => \&lang_c_finish);
886 register_language ('name' => 'f77',
887 'Name' => 'Fortran 77',
888 'linker' => 'F77LINK',
889 'link' => '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
891 'compile' => '$(F77) $(AM_FFLAGS) $(FFLAGS)',
892 'compiler' => 'F77COMPILE',
893 'compile_flag' => '-c',
894 'output_flag' => '-o',
898 'extensions' => ['.f', '.for', '.f90']);
900 # Preprocessed Fortran 77
902 # The current support for preprocessing Fortran 77 just involves
903 # passing `$(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS)
904 # $(CPPFLAGS)' as additional flags to the Fortran 77 compiler, since
905 # this is how GNU Make does it; see the `GNU Make Manual, Edition 0.51
906 # for `make' Version 3.76 Beta' (specifically, from info file
907 # `(make)Catalogue of Rules').
909 # A better approach would be to write an Autoconf test
910 # (i.e. AC_PROG_FPP) for a Fortran 77 preprocessor, because not all
911 # Fortran 77 compilers know how to do preprocessing. The Autoconf
912 # macro AC_PROG_FPP should test the Fortran 77 compiler first for
913 # preprocessing capabilities, and then fall back on cpp (if cpp were
915 register_language ('name' => 'ppf77',
916 'Name' => 'Preprocessed Fortran 77',
917 'config_vars' => ['F77'],
918 'linker' => 'F77LINK',
919 'link' => '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
923 'compiler' => 'PPF77COMPILE',
924 'compile' => '$(F77) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FFLAGS) $(FFLAGS)',
925 'compile_flag' => '-c',
926 'output_flag' => '-o',
928 'extensions' => ['.F']);
931 register_language ('name' => 'ratfor',
933 'config_vars' => ['F77'],
934 'linker' => 'F77LINK',
935 'link' => '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
940 'compile' => '$(F77) $(AM_FFLAGS) $(FFLAGS) $(AM_RFLAGS) $(RFLAGS)',
941 'compiler' => 'RCOMPILE',
942 'compile_flag' => '-c',
943 'output_flag' => '-o',
945 'extensions' => ['.r']);
948 register_language ('name' => 'java',
950 'config_vars' => ['GCJ'],
951 'linker' => 'GCJLINK',
952 'link' => '$(GCJLD) $(AM_GCJFLAGS) $(GCJFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
954 'flags' => 'GCJFLAGS',
955 'compile' => '$(GCJ) $(AM_GCJFLAGS) $(GCJFLAGS)',
956 'compiler' => 'GCJCOMPILE',
957 'compile_flag' => '-c',
958 'output_flag' => '-o',
962 'extensions' => ['.java', '.class', '.zip', '.jar']);
964 ################################################################
966 # Parse command line.
969 # Do configure.ac scan only once.
970 &scan_autoconf_files;
972 die "$me: no `Makefile.am' found or specified\n"
975 my $automake_has_run = 0;
979 if ($automake_has_run)
981 print "$me: processing Makefiles another time to fix them up.\n";
982 &prog_error ("running more than two times should never be needed.")
983 if $automake_has_run >= 2;
985 $automake_needs_to_reprocess_all_files = 0;
987 # Now do all the work on each file.
988 # This guy must be local otherwise it's private to the loop.
991 foreach $am_file (@input_files)
993 if (! -f ($am_file . '.am'))
995 &am_error ("`" . $am_file . ".am' does not exist");
999 &generate_makefile ($output_files{$am_file}, $am_file);
1002 ++$automake_has_run;
1004 while ($automake_needs_to_reprocess_all_files);
1008 # FIXME: This should be `my'ed next to its subs.
1009 use vars '%require_file_found';
1011 ################################################################
1013 # prog_error (@PRINT-ME)
1014 # ----------------------
1015 # Signal a programming error, display PRINT-ME, and exit 1.
1018 print STDERR "$me: programming error: @_\n";
1025 # Return a configure-style substitution using the indicated text.
1026 # We do this to avoid having the substitutions directly in automake.in;
1027 # when we do that they are sometimes removed and this causes confusion
1032 return '@' . $text . '@';
1035 ################################################################
1039 # &backname ($REL-DIR)
1040 # --------------------
1041 # If I `cd $REL-DIR', then to come back, I should `cd $BACKPATH'.
1042 # For instance `src/foo' => `../..'.
1043 # Works with non strictly increasing paths, i.e., `src/../lib' => `..'.
1048 foreach (split (/\//, $file))
1050 next if $_ eq '.' || $_ eq '';
1060 return join ('/', @res) || '.';
1063 ################################################################
1065 # Pattern that matches all know input extensions (i.e. extensions used
1066 # by the languages supported by Automake). Using this pattern
1067 # (instead of `\..*$') to match extensions allows Automake to support
1068 # dot-less extensions.
1069 my $KNOWN_EXTENSIONS_PATTERN = "";
1070 my @known_extensions_list = ();
1072 # accept_extensions (@EXTS)
1073 # -------------------------
1074 # Update $KNOWN_EXTENSIONS_PATTERN to recognize the extensions
1075 # listed @EXTS. Extensions should contain a dot if needed.
1076 sub accept_extensions (@)
1078 push @known_extensions_list, @_;
1079 $KNOWN_EXTENSIONS_PATTERN =
1080 '(?:' . join ('|', map (quotemeta, @known_extensions_list)) . ')';
1083 # var_SUFFIXES_trigger ($TYPE, $VALUE)
1084 # ------------------------------------
1085 # This is called automagically by define_macro() when SUFFIXES
1086 # is defined ($TYPE eq '') or appended ($TYPE eq '+').
1087 # The work here needs to be performed as a side-effect of the
1088 # define_macro() call because SUFFIXES definitions impact
1089 # on $KNOWN_EXTENSIONS_PATTERN, and $KNOWN_EXTENSIONS_PATTERN
1090 # are used when parsing the input am file.
1091 sub var_SUFFIXES_trigger ($$)
1093 my ($type, $value) = @_;
1094 accept_extensions (split (' ', $value));
1097 ################################################################
1099 # Parse command line.
1100 sub parse_arguments ()
1103 &set_strictness ('gnu');
1106 Getopt::Long::config ("bundling");
1107 Getopt::Long::GetOptions
1109 'version' => \&version,
1111 'libdir:s' => \$libdir,
1112 'gnu' => sub { &set_strictness ('gnu'); },
1113 'gnits' => sub { &set_strictness ('gnits'); },
1114 'cygnus' => \$cygnus_mode,
1115 'foreign' => sub { &set_strictness ('foreign'); },
1116 'include-deps' => sub { $cmdline_use_dependencies = 1; },
1117 'i|ignore-deps' => sub { $cmdline_use_dependencies = 0; },
1118 'no-force' => sub { $force_generation = 0; },
1119 'f|force-missing'=> \$force_missing,
1120 'o|output-dir:s' => \$output_directory,
1121 'a|add-missing' => \$add_missing,
1122 'c|copy' => \$copy_missing,
1123 'v|verbose' => \$verbose,
1124 'Werror' => sub { $SIG{"__WARN__"} = sub { die $_[0] } },
1125 'Wno-error' => sub { $SIG{"__WARN__"} = 'DEFAULT' }
1129 foreach my $arg (@ARGV)
1131 # Handle $local:$input syntax. Note that we only examine the
1132 # first ":" file to see if it is automake input; the rest are
1133 # just taken verbatim. We still keep all the files around for
1134 # dependency checking, however.
1135 my ($local, $input, @rest) = split (/:/, $arg);
1142 # Strip .in; later on .am is tacked on. That is how the
1143 # automake input file is found. Maybe not the best way, but
1144 # it is easy to explain.
1146 or die "$me: invalid input file name `$arg'\n.";
1148 push (@input_files, $input);
1149 $output_files{$input} = join (':', ($local, @rest));
1152 # Take global strictness from whatever we currently have set.
1153 $default_strictness = $strictness;
1154 $default_strictness_name = $strictness_name;
1157 ################################################################
1159 # Generate a Makefile.in given the name of the corresponding Makefile and
1160 # the name of the file output by config.status.
1161 sub generate_makefile
1163 my ($output, $makefile) = @_;
1165 # Reset all the Makefile.am related variables.
1166 &initialize_per_input;
1168 # Name of input file ("Makefile.am") and output file
1169 # ("Makefile.in"). These have no directory components.
1170 $am_file_name = basename ($makefile) . '.am';
1171 $in_file_name = basename ($makefile) . '.in';
1173 # $OUTPUT is encoded. If it contains a ":" then the first element
1174 # is the real output file, and all remaining elements are input
1175 # files. We don't scan or otherwise deal with these input file,
1176 # other than to mark them as dependencies. See
1177 # &scan_autoconf_files for details.
1178 my (@secondary_inputs);
1179 ($output, @secondary_inputs) = split (/:/, $output);
1181 $relative_dir = dirname ($output);
1182 $am_relative_dir = dirname ($makefile);
1184 &read_main_am_file ($makefile . '.am');
1185 if (&handle_options)
1187 # Fatal error. Just return, so we can continue with next file.
1191 # There are a few install-related variables that you should not define.
1192 foreach my $var ('PRE_INSTALL', 'POST_INSTALL', 'NORMAL_INSTALL')
1194 if (variable_defined ($var) && !$var_is_am{$var})
1196 macro_error ($var, "`$var' should not be defined");
1202 # At the toplevel directory, we might need config.guess, config.sub
1203 # or libtool scripts (ltconfig and ltmain.sh).
1204 if ($relative_dir eq '.')
1206 # AC_CANONICAL_HOST and AC_CANONICAL_SYSTEM need config.guess and
1208 require_conf_file ($canonical_location, FOREIGN,
1209 'config.guess', 'config.sub')
1213 # We still need Makefile.in here, because sometimes the `dist'
1214 # target doesn't re-run automake.
1215 if ($am_relative_dir eq $relative_dir)
1217 # Only distribute the files if they are in the same subdir as
1218 # the generated makefile.
1219 &push_dist_common ($in_file_name, $am_file_name);
1222 push (@sources, '$(SOURCES)')
1223 if variable_defined ('SOURCES');
1225 # Must do this after reading .am file. See read_main_am_file to
1226 # understand weird tricks we play there with variables.
1227 &define_variable ('subdir', $relative_dir);
1229 # Check first, because we might modify some state.
1231 &check_gnu_standards;
1232 &check_gnits_standards;
1234 &handle_configure ($output, $makefile, @secondary_inputs);
1237 &handle_ltlibraries;
1241 # This must run first so that the ANSI2KNR definition is generated
1242 # before it is used by the _.c rules. We have to do this because
1243 # a variable which is used in a dependency must be defined before
1244 # the target, or else make won't properly see it.
1246 # This must be run after all the sources are scanned.
1249 # Re-init SOURCES. FIXME: other code shouldn't depend on this
1250 # (but currently does).
1251 macro_define ('SOURCES', 1, '', 'TRUE', "@sources", 'internal');
1252 define_pretty_variable ('DIST_SOURCES', '', @dist_sources);
1264 &handle_minor_options;
1267 # This must come after most other rules.
1268 &handle_dist ($makefile);
1271 &do_check_merge_target;
1272 &handle_all ($output);
1275 if (variable_defined ('lib_LTLIBRARIES') &&
1276 variable_defined ('bin_PROGRAMS'))
1278 $output_rules .= "install-binPROGRAMS: install-libLTLIBRARIES\n\n";
1281 &handle_installdirs;
1283 &handle_factored_dependencies;
1287 if (! -d ($output_directory . '/' . $am_relative_dir))
1289 mkdir ($output_directory . '/' . $am_relative_dir, 0755);
1292 my ($out_file) = $output_directory . '/' . $makefile . ".in";
1293 if (! $force_generation && -e $out_file)
1295 my ($am_time) = (stat ($makefile . '.am'))[9];
1296 my ($in_time) = (stat ($out_file))[9];
1297 # FIXME: should cache these times.
1298 my ($conf_time) = (stat ($configure_ac))[9];
1299 # FIXME: how to do unsigned comparison?
1300 if ($am_time < $in_time || $am_time < $conf_time)
1302 # No need to update.
1305 if (-f 'aclocal.m4')
1307 my ($acl_time) = (stat _)[9];
1308 return if ($am_time < $acl_time);
1312 my $gm_file = new Automake::XFile "> $out_file";
1313 verbose "creating ", $makefile, ".in";
1315 print $gm_file $output_vars;
1316 # We make sure that `all:' is the first target.
1317 print $gm_file $output_all;
1318 print $gm_file $output_header;
1319 print $gm_file $output_rules;
1320 print $gm_file $output_trailer;
1323 ################################################################
1325 # A helper which handles the logic of requiring a version number in
1326 # AUTOMAKE_OPTIONS. Return 1 on error, 0 on success.
1327 sub version_check ($$$$)
1329 my ($rmajor, $rminor, $ralpha, $rfork) = ($1, $2, $3, $4);
1331 prog_error ("version is incorrect: $VERSION")
1332 if $VERSION !~ /(\d+)\.(\d+)([a-z]?)-?([A-Za-z0-9]+)?/;
1334 my ($tmajor, $tminor, $talpha, $tfork) = ($1, $2, $3, $4);
1339 my $rminorminor = 0;
1340 my $tminorminor = 0;
1342 # Some versions were labelled like `1.4-p3a'. This is the same as
1343 # an alpha release labelled `1.4.3a'. However, a version like
1344 # `1.4g' is the same as `1.4.99g'. Yes, this sucks. Moral:
1345 # always listen to the users.
1346 if ($rfork =~ /p([0-9]+)([a-z]?)/)
1349 # `1.4a-p3b' never existed. But we'll accept it anyway.
1350 $ralpha = $ralpha || $2 || '';
1353 if ($tfork =~ /p([0-9]+)([a-z]?)/)
1356 # `1.4a-p3b' never existed. But we'll accept it anyway.
1357 $talpha = $talpha || $2 || '';
1361 $rminorminor = 99 if $ralpha ne '' && $rminorminor == 0;
1362 $tminorminor = 99 if $talpha ne '' && $tminorminor == 0;
1364 # 2.0 is better than 1.0.
1365 # 1.2 is better than 1.1.
1366 # 1.2a is better than 1.2.
1367 # If we require 3.4n-foo then we require something
1368 # >= 3.4n, with the `foo' fork identifier.
1369 # The $r* variables are what the user specified.
1370 # The $t* variables denote automake itself.
1371 if ($rmajor > $tmajor
1372 || ($rmajor == $tmajor && $rminor > $tminor)
1373 || ($rminor == $tminor && $rminor == $tminor
1374 && $rminorminor > $tminorminor)
1375 || ($rminor == $tminor && $rminor == $tminor
1376 && $rminorminor == $tminorminor
1377 && $ralpha gt $talpha)
1378 || ($rfork ne '' && $rfork ne $tfork))
1380 macro_error ('AUTOMAKE_OPTIONS',
1381 "require version $_, but have $VERSION");
1388 # Handle AUTOMAKE_OPTIONS variable. Return 1 on error, 0 otherwise.
1391 if (variable_defined ('AUTOMAKE_OPTIONS'))
1393 foreach (&variable_value_as_list_recursive ('AUTOMAKE_OPTIONS', ''))
1396 if ($_ eq 'gnits' || $_ eq 'gnu' || $_ eq 'foreign')
1398 &set_strictness ($_);
1400 elsif ($_ eq 'cygnus')
1404 elsif (/^(.*\/)?ansi2knr$/)
1406 # An option like "../lib/ansi2knr" is allowed. With
1407 # no path prefix, we assume the required programs are
1408 # in this directory. We save the actual option for
1410 $options{'ansi2knr'} = $_;
1412 elsif ($_ eq 'no-installman' || $_ eq 'no-installinfo'
1413 || $_ eq 'dist-shar' || $_ eq 'dist-zip'
1414 || $_ eq 'dist-tarZ' || $_ eq 'dist-bzip2'
1415 || $_ eq 'dejagnu' || $_ eq 'no-texinfo.tex'
1416 || $_ eq 'readme-alpha' || $_ eq 'check-news'
1417 || $_ eq 'subdir-objects' || $_ eq 'nostdinc'
1418 || $_ eq 'no-exeext')
1420 # Explicitly recognize these.
1422 elsif ($_ eq 'no-dependencies')
1424 $use_dependencies = 0;
1426 elsif (/(\d+)\.(\d+)([a-z]?)(-[A-Za-z0-9]+)?/)
1428 # Got a version number.
1429 if (version_check ($1, $2, $3, $4))
1436 macro_error ('AUTOMAKE_OPTIONS',
1437 "option `" . $_ . "\' not recognized");
1442 if ($strictness == GNITS)
1444 $options{'readme-alpha'} = 1;
1445 $options{'check-news'} = 1;
1452 # get_object_extension ($OUT)
1453 # ---------------------------
1454 # Return object extension. Just once, put some code into the output.
1455 # OUT is the name of the output file
1456 sub get_object_extension
1460 # Maybe require libtool library object files.
1461 my $extension = '.$(OBJEXT)';
1462 $extension = '.lo' if ($out =~ /\.la$/);
1464 # Check for automatic de-ANSI-fication.
1465 $extension = '$U' . $extension
1466 if defined $options{'ansi2knr'};
1468 $get_object_extension_was_run = 1;
1474 # Call finish function for each language that was used.
1475 sub handle_languages
1477 if ($use_dependencies)
1479 # Include auto-dep code. Don't include it if DEP_FILES would
1481 if (&saw_sources_p (0) && keys %dep_files)
1483 # Set location of depcomp.
1484 &define_variable ('depcomp', "\$(SHELL) $config_aux_dir/depcomp");
1486 require_conf_file ("$am_file.am", FOREIGN, 'depcomp');
1488 my @deplist = sort keys %dep_files;
1490 # We define this as a conditional variable because BSD
1491 # make can't handle backslashes for continuing comments on
1492 # the following line.
1493 define_pretty_variable ('DEP_FILES', 'AMDEP_TRUE', @deplist);
1495 # Generate each `include' individually. Irix 6 make will
1496 # not properly include several files resulting from a
1497 # variable expansion; generating many separate includes
1499 $output_rules .= "\n";
1500 foreach my $iter (@deplist)
1502 $output_rules .= (subst ('AMDEP_TRUE')
1503 . subst ('am__include')
1505 . subst ('am__quote')
1507 . subst ('am__quote')
1511 $output_rules .= &file_contents ('depend');
1516 &define_variable ('depcomp', '');
1521 # Is the c linker needed?
1523 foreach my $ext (sort keys %extension_seen)
1525 next unless $extension_map{$ext};
1527 my $lang = $languages{$extension_map{$ext}};
1529 my $rule_file = $lang->rule_file || 'depend2';
1531 # Get information on $LANG.
1532 my $pfx = $lang->autodep;
1533 my $fpfx = ($pfx eq '') ? 'CC' : $pfx;
1535 my $AMDEP = (($use_dependencies && $lang->autodep ne 'no')
1536 ? 'AMDEP' : 'FALSE');
1538 my %transform = ('EXT' => $ext,
1541 'LIBTOOL' => defined $seen_libtool,
1543 '-c' => $lang->compile_flag || '',
1545 => (count_files_for_language ($lang->name) > 1));
1547 # Generate the appropriate rules for this extension.
1548 if (($use_dependencies && $lang->autodep ne 'no')
1549 || defined $lang->compile)
1551 # Some C compilers don't support -c -o. Use it only if really
1553 my $output_flag = $lang->output_flag || '';
1556 && $lang->flags eq 'CFLAGS'
1557 && defined $options{'subdir-objects'});
1559 # FIXME: this is a temporary hack to compute a possible
1560 # derived extension. This is not used by depend2.am.
1561 (my $der_ext = $ext) =~ tr/yl/cc/;
1563 # Another yacc/lex hack.
1564 my $destfile = '$*' . $der_ext;
1567 file_contents ($rule_file,
1571 'DERIVED-EXT' => $der_ext,
1579 'COMPILE' => '$(' . $lang->compiler . ')',
1580 'LTCOMPILE' => '$(LT' . $lang->compiler . ')',
1581 '-o' => $output_flag);
1584 # Now include code for each specially handled object with this
1586 my %seen_files = ();
1587 foreach my $file (@{$lang_specific_files{$lang->name}})
1589 my ($derived, $source, $obj, $myext) = split (' ', $file);
1591 # We might see a given object twice, for instance if it is
1592 # used under different conditions.
1593 next if defined $seen_files{$obj};
1594 $seen_files{$obj} = 1;
1596 my $flags = $lang->flags || '';
1597 my $val = "${derived}_${flags}";
1599 prog_error ("found $lang->name in handle_languages, but compiler not defined")
1600 unless defined $lang->compile;
1602 (my $obj_compile = $lang->compile) =~ s/\(AM_$flags/\($val/;
1603 my $obj_ltcompile = '$(LIBTOOL) --mode=compile ' . $obj_compile;
1605 # We _need_ `-o' for per object rules.
1606 my $output_flag = $lang->output_flag || '-o';
1608 # Generate a transform which will turn suffix targets in
1609 # depend2.am into real targets for the particular objects we
1612 file_contents ($rule_file,
1617 'SOURCE' => $source,
1618 # Use $myext and not `.o' here, in case
1619 # we are actually building a new source
1620 # file -- e.g. via yacc.
1621 'OBJ' => "$obj$myext",
1622 'OBJOBJ' => "$obj.obj",
1623 'LTOBJ' => "$obj.lo",
1625 'COMPILE' => $obj_compile,
1626 'LTCOMPILE' => $obj_ltcompile,
1627 '-o' => $output_flag));
1630 # The rest of the loop is done once per language.
1631 next if defined $done{$lang};
1634 # Load the language dependent Makefile chunks.
1635 my %lang = map { uc ($_) => 0 } keys %languages;
1636 $lang{uc ($lang->name)} = 1;
1637 $output_rules .= file_contents ('lang-compile', %transform, %lang);
1639 # If the source to a program consists entirely of code from a
1640 # `pure' language, for instance C++ for Fortran 77, then we
1641 # don't need the C compiler code. However if we run into
1642 # something unusual then we do generate the C code. There are
1643 # probably corner cases here that do not work properly.
1644 # People linking Java code to Fortran code deserve pain.
1645 $needs_c ||= ! $lang->pure;
1647 define_compiler_variable ($lang)
1648 if ($lang->compile);
1650 define_linker_variable ($lang)
1653 foreach my $var (@{$lang->config_vars})
1655 am_error ($lang->Name
1656 . " source seen but `$var' not defined in"
1657 . " `$configure_ac'")
1658 if !exists $configure_vars{$var};
1661 # The compiler's flag must be a configure variable.
1662 define_configure_variable ($lang->flags)
1663 if defined $lang->flags && $lang->define_flag;
1665 # Call the finisher.
1669 # If the project is entirely C++ or entirely Fortran 77 (i.e., 1
1670 # suffix rule was learned), don't bother with the C stuff. But if
1671 # anything else creeps in, then use it.
1673 if $need_link || scalar keys %suffix_rules > 1;
1677 if (! defined $done{$languages{'c'}})
1679 &define_configure_variable ($languages{'c'}->flags);
1680 &define_compiler_variable ($languages{'c'});
1682 define_linker_variable ($languages{'c'});
1686 # Check to make sure a source defined in LIBOBJS is not explicitly
1687 # mentioned. This is a separate function (as opposed to being inlined
1688 # in handle_source_transform) because it isn't always appropriate to
1690 sub check_libobjs_sources
1692 my ($one_file, $unxformed) = @_;
1694 foreach my $prefix ('', 'EXTRA_', 'dist_', 'nodist_',
1695 'dist_EXTRA_', 'nodist_EXTRA_')
1698 if (variable_defined ($prefix . $one_file . '_SOURCES'))
1700 @files = &variable_value_as_list_recursive (
1701 ($prefix . $one_file . '_SOURCES'),
1704 elsif ($prefix eq '')
1706 @files = ($unxformed . '.c');
1713 foreach my $file (@files)
1715 macro_error ($prefix . $one_file . '_SOURCES',
1716 "automatically discovered file `$file' should not be explicitly mentioned")
1717 if defined $libsources{$file};
1724 # handle_single_transform_list ($VAR, $TOPPARENT, $DERIVED, $OBJ, @FILES)
1725 # -----------------------------------------------------------------------
1726 # Does much of the actual work for handle_source_transform.
1728 # $VAR is the name of the variable that the source filenames come from
1729 # $TOPPARENT is the name of the _SOURCES variable which is being processed
1730 # $DERIVED is the name of resulting executable or library
1731 # $OBJ is the object extension (e.g., `$U.lo')
1732 # @FILES is the list of source files to transform
1733 # Result is a list of the names of objects
1734 # %linkers_used will be updated with any linkers needed
1735 sub handle_single_transform_list ($$$$@)
1737 my ($var, $topparent, $derived, $obj, @files) = @_;
1739 my $nonansi_obj = $obj;
1740 $nonansi_obj =~ s/\$U//g;
1742 # Turn sources into objects. We use a while loop like this
1743 # because we might add to @files in the loop.
1744 while (scalar @files > 0)
1748 # Configure substitutions in _SOURCES variables are errors.
1752 "`$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 ! /^(?:(.*)\/)?([^\/]*)($KNOWN_EXTENSIONS_PATTERN)$/;
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, $nonansi_obj);
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 ("$am_file.am", 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 $nonansi_obj)
1905 # This is probably the result of a direct suffix rule.
1906 # In this case we just accept the rewrite.
1907 $object = "$base$extension";
1912 # No error message here. Used to have one, but it was
1914 # FIXME: we could potentially do more processing here,
1915 # perhaps treating the new extension as though it were a
1916 # new source extension (as above). This would require
1917 # more restructuring than is appropriate right now.
1921 if (defined $object_map{$object})
1923 if ($object_map{$object} ne $full)
1925 am_error ("object `$object' created by `$full' and `$object_map{$object}'");
1929 if (defined $lang) {
1930 # Let the language do some special magic if required.
1931 $lang->target_hook ($aggregate, $object, $full);
1934 if ($derived_source)
1936 prog_error ("$lang->name has automatic dependency tracking")
1937 if $lang->autodep ne 'no';
1938 # Make sure this new source file is handled next. That will
1939 # make it appear to be at the right place in the list.
1940 unshift (@files, $object);
1942 &push_dist_common ($object);
1946 $linkers_used{$linker} = 1;
1948 push (@result, $object);
1950 if (! defined $object_map{$object})
1953 $object_map{$object} = $full;
1955 # If file is in subdirectory, we need explicit
1957 if ($directory ne '' || $renamed)
1959 push (@dep_list, $full);
1962 # If resulting object is in subdir, we need to make
1963 # sure the subdir exists at build time.
1964 if ($object =~ /\//)
1966 # FIXME: check that $DIRECTORY is somewhere in the
1969 # We don't allow `..' in object file names for
1970 # *any* source, not just Java. For Java it just
1971 # doesn't make sense, but in general it is
1972 # a problem because we can't pick a good name for
1974 if ($object =~ /(\/|^)\.\.\//)
1976 am_error ("`$full' contains `..' component but should not");
1979 # Make sure object is removed by `make mostlyclean'.
1980 $compile_clean_files{$object} = MOSTLY_CLEAN;
1982 push (@dep_list, require_build_directory ($directory));
1984 # If we're generating dependencies, we also want
1985 # to make sure that the appropriate subdir of the
1986 # .deps directory is created.
1987 push (@dep_list, require_build_directory ('$(DEPDIR)/' . $directory))
1988 if ($use_dependencies);
1991 &pretty_print_rule ($object . ':', "\t", @dep_list)
1992 if scalar @dep_list > 0;
1995 # Transform .o or $o file into .P file (for automatic
1997 if ($lang && $lang->autodep ne 'no')
1999 my $depfile = $object;
2000 $depfile =~ s/\.([^.]*)$/.P$1/;
2001 $depfile =~ s/\$\(OBJEXT\)$/o/;
2002 $dep_files{'$(DEPDIR)/' . $depfile} = 1;
2010 # define_objects_from_sources ($VAR, $OBJVAR, $NODEFINE, $ONE_FILE,
2011 # $OBJ, $PARENT, $TOPPARENT)
2012 # ---------------------------------------------------------------------
2013 # Define an _OBJECTS variable for a _SOURCES variable (or subvariable)
2016 # $VAR is the name of the _SOURCES variable
2017 # $OBJVAR is the name of the _OBJECTS
2018 # $NODEFINE is a boolean: if true, $OBJVAR will not be defined (but
2019 # work done to determine the linker will be).
2020 # $ONE_FILE is the canonical (transformed) name of object to build
2021 # $OBJ is the object extension (ie either `.o' or `.lo').
2022 # $PARENT is the variable in which $VAR is used, or $VAR if not applicable.
2023 # $TOPPARENT is the _SOURCES variable being processed.
2025 # Result is a boolean, true if a linker is needed to deal with the objects.
2027 # %linkers_used, %vars_scanned, @substfroms and @substtos should be cleared
2029 # %linkers_used variable will be set to contain the linkers desired.
2030 # %vars_scanned will be used to check for recursive definitions.
2031 # @substfroms and @substtos will be used to keep a stack of variable
2032 # substitutions to be applied.
2034 sub define_objects_from_sources ($$$$$$$)
2036 my ($var, $objvar, $nodefine, $one_file, $obj, $parent, $topparent) = @_;
2038 if (defined $vars_scanned{$var})
2040 macro_error ($var, "variable `$var' recursively defined");
2043 $vars_scanned{$var} = 1;
2045 my $needlinker = "";
2046 foreach my $cond (variable_conditions ($var))
2049 foreach my $val (&variable_value_as_list ($var, $cond, $parent))
2051 # If $val is a variable (i.e. ${foo} or $(bar), not a filename),
2052 # handle the sub variable recursively.
2053 if ($val =~ /^\$\{([^}]*)\}$/ || $val =~ /^\$\(([^)]*)\)$/)
2057 # If the user uses a losing variable name, just ignore it.
2058 # This isn't ideal, but people have requested it.
2059 next if ($subvar =~ /\@.*\@/);
2061 # See if the variable is actually a substitution reference
2064 if ($subvar =~ /$SUBST_REF_PATTERN/o)
2068 ($from = $2) =~ s/(\W)/\\$1/g;
2070 push @substfroms, $from;
2071 push @substtos, $to;
2073 my $subobjvar = subobjname ($subvar);
2074 push (@result, '$('. $subobjvar . ')');
2076 my $temp = define_objects_from_sources ($subvar, $subobjvar,
2077 $nodefine, $one_file,
2078 $obj, $var, $topparent);
2079 $needlinker ||= $temp;
2084 else # $var is a filename
2086 my $substnum=$#substfroms;
2087 while ($substnum >= 0)
2089 $val =~ s/$substfroms[$substnum]$/$substtos[$substnum]/
2090 if defined $substfroms[$substnum];
2095 &handle_single_transform_list ($var, $topparent, $one_file, $obj, $val);
2096 push (@result, @transformed);
2097 $needlinker = "true" if @transformed;
2101 # Define _OBJECTS conditionally.
2102 define_pretty_variable ($objvar, $cond, (@result))
2106 delete $vars_scanned{$var};
2112 # subobjname ($VARNAME)
2113 # ---------------------
2114 # Return a name for an object variable.
2117 # $VARNAME is the name of the variable the object variable is being
2120 # This function also looks at @substfroms and @substtos to determine any
2121 # substitutions to be performed on the object variable.
2123 # The name returned is unique for the combination of $varname and
2124 # substitutions to be performed.
2129 my $substnum=$#substfroms;
2130 while ($substnum >= 0)
2132 if (defined $substfroms[$substnum] &&
2133 ($substfroms[$substnum] || $substtos[$substnum]))
2135 $key .= ":" . $substfroms[$substnum] . "=" . $substtos[$substnum];
2140 my $num = $substnums{$key};
2143 $num = keys(%substnums) + 1;
2144 $substnums{$key} = $num;
2147 return "am__objects_$num";
2151 # Handle SOURCE->OBJECT transform for one program or library.
2153 # canonical (transformed) name of object to build
2154 # actual name of object to build
2155 # object extension (ie either `.o' or `$o'.
2156 # Return result is name of linker variable that must be used.
2157 # Empty return means just use `LINK'.
2158 sub handle_source_transform
2160 # one_file is canonical name. unxformed is given name. obj is
2162 my ($one_file, $unxformed, $obj) = @_;
2166 if (variable_defined ($one_file . "_OBJECTS"))
2168 macro_error ($one_file . '_OBJECTS',
2169 $one_file . '_OBJECTS', 'should not be defined');
2170 # No point in continuing.
2177 foreach my $prefix ('', 'EXTRA_', 'dist_', 'nodist_',
2178 'dist_EXTRA_', 'nodist_EXTRA_')
2180 my $var = $prefix . $one_file . "_SOURCES";
2182 if !variable_defined ($var);
2184 # We are going to define _OBJECTS variables using the prefix.
2185 # Then we glom them all together. So we can't use the null
2186 # prefix here as we need it later.
2187 my $xpfx = ($prefix eq '') ? 'am_' : $prefix;
2189 # Keep track of which prefixes we saw.
2190 $used_pfx{$xpfx} = 1
2191 unless $prefix =~ /EXTRA_/;
2193 push @sources, "\$($var)";
2194 push @dist_sources, "\$($var)"
2195 unless $prefix =~ /^nodist_/;
2200 my $temp = define_objects_from_sources ($var,
2201 $xpfx . $one_file . '_OBJECTS',
2202 $prefix =~ /EXTRA_/,
2203 $one_file, $obj, $var, $var);
2204 $needlinker ||= $temp;
2208 $linker ||= &resolve_linker (%linkers_used);
2211 my @keys = sort keys %used_pfx;
2212 if (scalar @keys == 0)
2214 &define_variable ($one_file . "_SOURCES", $unxformed . ".c");
2215 push (@sources, $unxformed . '.c');
2216 push (@dist_sources, $unxformed . '.c');
2220 &handle_single_transform_list ($one_file . '_SOURCES',
2221 $one_file . '_SOURCES',
2224 $linker ||= &resolve_linker (%linkers_used);
2225 define_pretty_variable ($one_file . "_OBJECTS", '', @result)
2229 grep ($_ = '$(' . $_ . $one_file . '_OBJECTS)', @keys);
2230 define_pretty_variable ($one_file . '_OBJECTS', '', @keys);
2233 # If we want to use `LINK' we must make sure it is defined.
2243 # handle_lib_objects ($XNAME, $VAR)
2244 # ---------------------------------
2245 # Special-case @ALLOCA@ and @LIBOBJS@ in _LDADD or _LIBADD variables.
2246 # Also, generate _DEPENDENCIES variable if appropriate.
2248 # transformed name of object being built, or empty string if no object
2249 # name of _LDADD/_LIBADD-type variable to examine
2250 # Returns 1 if LIBOBJS seen, 0 otherwise.
2251 sub handle_lib_objects
2253 my ($xname, $var) = @_;
2255 prog_error ("handle_lib_objects: $var undefined")
2256 if ! variable_defined ($var);
2259 foreach my $cond (variable_conditions_recursive ($var))
2261 if (&handle_lib_objects_cond ($xname, $var, $cond))
2269 # Subroutine of handle_lib_objects: handle a particular condition.
2270 sub handle_lib_objects_cond
2272 my ($xname, $var, $cond) = @_;
2274 # We recognize certain things that are commonly put in LIBADD or
2278 my $seen_libobjs = 0;
2281 foreach my $lsearch (&variable_value_as_list_recursive ($var, $cond))
2283 # Skip -lfoo and -Ldir; these are explicitly allowed.
2284 next if $lsearch =~ /^-[lL]/;
2285 if (! $flagvar && $lsearch =~ /^-/)
2287 if ($var =~ /^(.*)LDADD$/)
2289 # Skip -dlopen and -dlpreopen; these are explicitly allowed.
2290 next if $lsearch =~ /^-dl(pre)?open$/;
2292 "linker flags such as `$lsearch' belong in `${1}LDFLAGS");
2296 # Only get this error once.
2299 "linker flags such as `$lsearch' belong in `${1}LDFLAGS");
2303 # Assume we have a file of some sort, and push it onto the
2304 # dependency list. Autoconf substitutions are not pushed;
2305 # rarely is a new dependency substituted into (eg) foo_LDADD
2306 # -- but "bad things (eg -lX11) are routinely substituted.
2307 # Note that LIBOBJS and ALLOCA are exceptions to this rule,
2308 # and handled specially below.
2309 push (@dep_list, $lsearch)
2310 unless $lsearch =~ /^\@.*\@$/;
2312 # Automatically handle @LIBOBJS@ and @ALLOCA@. Basically this
2313 # means adding entries to dep_files.
2314 if ($lsearch =~ /^\@(LT)?LIBOBJS\@$/)
2316 my $lt = $1 ? $1 : '';
2317 my $myobjext = ($1 ? 'l' : '') . 'o';
2319 push (@dep_list, $lsearch);
2321 if (! keys %libsources
2322 && ! variable_defined ($lt . 'LIBOBJS'))
2325 "\@$lt" . "LIBOBJS\@ seen but never set in `$configure_ac'");
2328 foreach my $iter (keys %libsources)
2330 if ($iter =~ /\.[cly]$/)
2332 &saw_extension ($&);
2333 &saw_extension ('.c');
2336 if ($iter =~ /\.h$/)
2338 require_file_with_macro ($var, FOREIGN, $iter);
2340 elsif ($iter ne 'alloca.c')
2342 my $rewrite = $iter;
2343 $rewrite =~ s/\.c$/.P$myobjext/;
2344 $dep_files{'$(DEPDIR)/' . $rewrite} = 1;
2345 ($rewrite = $iter) =~ s/(\W)/\\$1/g;
2346 $rewrite = "^" . $rewrite . "\$";
2347 # Only require the file if it is not a built source.
2348 if (! variable_defined ('BUILT_SOURCES')
2349 || ! grep (/$rewrite/,
2350 &variable_value_as_list_recursive (
2351 'BUILT_SOURCES', 'all')))
2353 require_file_with_macro ($var, FOREIGN, $iter);
2358 elsif ($lsearch =~ /^\@(LT)?ALLOCA\@$/)
2360 my $lt = $1 ? $1 : '';
2361 my $myobjext = ($1 ? 'l' : '') . 'o';
2363 push (@dep_list, $lsearch);
2365 "\@$lt" . "ALLOCA\@ seen but `AC_FUNC_ALLOCA' not in `$configure_ac'")
2366 if ! defined $libsources{'alloca.c'};
2367 $dep_files{'$(DEPDIR)/alloca.P' . $myobjext} = 1;
2368 require_file_with_macro ($var, FOREIGN, 'alloca.c');
2369 &saw_extension ('c');
2373 if ($xname ne '' && ! variable_defined ($xname . '_DEPENDENCIES', $cond))
2375 define_pretty_variable ($xname . '_DEPENDENCIES', $cond, @dep_list);
2378 return $seen_libobjs;
2381 # Canonicalize the input parameter
2385 $string =~ tr/A-Za-z0-9_\@/_/c;
2389 # Canonicalize a name, and check to make sure the non-canonical name
2390 # is never used. Returns canonical name. Arguments are name and a
2391 # list of suffixes to check for.
2392 sub check_canonical_spelling
2394 my ($name, @suffixes) = @_;
2396 my $xname = &canonicalize ($name);
2397 if ($xname ne $name)
2399 foreach my $xt (@suffixes)
2401 macro_error ("$name$xt",
2402 "invalid variable `$name$xt'; should be `$xname$xt'")
2403 if variable_defined ("$name$xt");
2413 # Set up the compile suite.
2414 sub handle_compile ()
2417 unless $get_object_extension_was_run;
2420 my $default_includes = '';
2421 if (! defined $options{'nostdinc'})
2423 $default_includes = ' -I. -I$(srcdir)';
2425 if (variable_defined ('CONFIG_HEADER'))
2427 foreach my $hdr (split (' ', &variable_value ('CONFIG_HEADER')))
2429 $default_includes .= ' -I' . dirname ($hdr);
2434 my (@mostly_rms, @dist_rms);
2435 foreach my $item (sort keys %compile_clean_files)
2437 if ($compile_clean_files{$item} == MOSTLY_CLEAN)
2439 push (@mostly_rms, "\t-rm -f $item");
2441 elsif ($compile_clean_files{$item} == DIST_CLEAN)
2443 push (@dist_rms, "\t-rm -f $item");
2447 prog_error ("invalid entry in \%compile_clean_files");
2451 my ($coms, $vars, $rules) =
2452 &file_contents_internal (1, "$libdir/am/compile.am",
2453 ('DEFAULT_INCLUDES' => $default_includes,
2454 'MOSTLYRMS' => join ("\n", @mostly_rms),
2455 'DISTRMS' => join ("\n", @dist_rms)));
2456 $output_vars .= $vars;
2457 $output_rules .= "$coms$rules";
2459 # Check for automatic de-ANSI-fication.
2460 if (defined $options{'ansi2knr'})
2462 if (! $am_c_prototypes)
2464 macro_error ('AUTOMAKE_OPTIONS',
2465 "option `ansi2knr' in use but `AM_C_PROTOTYPES' not in `$configure_ac'");
2466 &keyed_aclocal_warning ('AM_C_PROTOTYPES');
2467 # Only give this error once.
2468 $am_c_prototypes = 1;
2471 # topdir is where ansi2knr should be.
2472 if ($options{'ansi2knr'} eq 'ansi2knr')
2474 # Only require ansi2knr files if they should appear in
2476 require_file_with_macro ('AUTOMAKE_OPTIONS', FOREIGN,
2477 'ansi2knr.c', 'ansi2knr.1');
2479 # ansi2knr needs to be built before subdirs, so unshift it.
2480 unshift (@all, '$(ANSI2KNR)');
2483 my $ansi2knr_dir = '';
2484 $ansi2knr_dir = dirname ($options{'ansi2knr'})
2485 if $options{'ansi2knr'} ne 'ansi2knr';
2487 $output_rules .= &file_contents ('ansi2knr',
2488 ('ANSI2KNR-DIR' => $ansi2knr_dir));
2495 # Handle libtool rules.
2498 return unless $seen_libtool;
2500 # Libtool requires some files, but only at top level.
2501 require_conf_file ($seen_libtool, FOREIGN, @libtool_files)
2502 if $relative_dir eq '.';
2504 # Output the libtool compilation rules.
2505 $output_rules .= &file_contents ('libtool');
2508 # handle_programs ()
2509 # ------------------
2510 # Handle C programs.
2513 my @proglist = &am_install_var ('progs', 'PROGRAMS',
2514 'bin', 'sbin', 'libexec', 'pkglib',
2516 return if ! @proglist;
2518 my $seen_libobjs = 0;
2519 foreach my $one_file (@proglist)
2521 my $obj = &get_object_extension ($one_file);
2523 # Canonicalize names and check for misspellings.
2524 my $xname = &check_canonical_spelling ($one_file, '_LDADD', '_LDFLAGS',
2525 '_SOURCES', '_OBJECTS',
2528 my $linker = &handle_source_transform ($xname, $one_file, $obj);
2531 if (variable_defined ($xname . "_LDADD"))
2533 if (&handle_lib_objects ($xname, $xname . '_LDADD'))
2541 # User didn't define prog_LDADD override. So do it.
2542 &define_variable ($xname . '_LDADD', '$(LDADD)');
2544 # This does a bit too much work. But we need it to
2545 # generate _DEPENDENCIES when appropriate.
2546 if (variable_defined ('LDADD'))
2548 if (&handle_lib_objects ($xname, 'LDADD'))
2553 elsif (! variable_defined ($xname . '_DEPENDENCIES'))
2555 &define_variable ($xname . '_DEPENDENCIES', '');
2560 if (variable_defined ($xname . '_LIBADD'))
2562 macro_error ($xname . '_LIBADD',
2563 "use `" . $xname . "_LDADD', not `"
2564 . $xname . "_LIBADD'");
2567 if (! variable_defined ($xname . '_LDFLAGS'))
2569 # Define the prog_LDFLAGS variable.
2570 &define_variable ($xname . '_LDFLAGS', '');
2573 # Determine program to use for link.
2575 if (variable_defined ($xname . '_LINK'))
2577 $xlink = $xname . '_LINK';
2581 $xlink = $linker ? $linker : 'LINK';
2584 # If the resulting program lies into a subdirectory,
2585 # make sure this directory will exist.
2586 my $dirstamp = require_build_directory_maybe ($one_file);
2588 # Don't add $(EXEEXT) if user already did.
2589 my $extension = ($one_file !~ /\$\(EXEEXT\)$/
2593 $output_rules .= &file_contents ('program',
2594 ('PROGRAM' => $one_file,
2595 'XPROGRAM' => $xname,
2597 'DIRSTAMP' => $dirstamp,
2598 'EXEEXT' => $extension));
2601 if (variable_defined ('LDADD') && &handle_lib_objects ('', 'LDADD'))
2608 foreach my $one_file (@proglist)
2610 my $xname = &canonicalize ($one_file);
2612 if (variable_defined ($xname . '_LDADD'))
2614 &check_libobjs_sources ($xname, $xname . '_LDADD');
2616 elsif (variable_defined ('LDADD'))
2618 &check_libobjs_sources ($xname, 'LDADD');
2625 # handle_libraries ()
2626 # -------------------
2628 sub handle_libraries
2630 my @liblist = &am_install_var ('libs', 'LIBRARIES',
2631 'lib', 'pkglib', 'noinst', 'check');
2632 return if ! @liblist;
2634 my @prefix = am_primary_prefixes ('LIBRARIES', 0, 'lib', 'pkglib',
2636 if (! defined $configure_vars{'RANLIB'}
2639 macro_error ($prefix[0] . '_LIBRARIES',
2640 "library used but `RANLIB' not defined in `$configure_ac'");
2641 # Only get this error once. If this is ever printed, we have
2643 $configure_vars{'RANLIB'} = 'BUG';
2646 my $seen_libobjs = 0;
2647 foreach my $onelib (@liblist)
2649 # Check that the library fits the standard naming convention.
2650 if (basename ($onelib) !~ /^lib.*\.a/)
2652 # FIXME should put line number here. That means mapping
2653 # from library name back to variable name.
2654 &am_error ("`$onelib' is not a standard library name");
2657 my $obj = &get_object_extension ($onelib);
2659 # Canonicalize names and check for misspellings.
2660 my $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_SOURCES',
2661 '_OBJECTS', '_DEPENDENCIES',
2664 if (! variable_defined ($xlib . '_AR'))
2666 &define_variable ($xlib . '_AR', '$(AR) cru');
2669 if (variable_defined ($xlib . '_LIBADD'))
2671 if (&handle_lib_objects ($xlib, $xlib . '_LIBADD'))
2678 # Generate support for conditional object inclusion in
2680 &define_variable ($xlib . "_LIBADD", '');
2683 if (variable_defined ($xlib . '_LDADD'))
2685 macro_error ($xlib . '_LDADD',
2686 "use `" . $xlib . "_LIBADD', not `"
2687 . $xlib . "_LDADD'");
2690 # Make sure we at look at this.
2691 &examine_variable ($xlib . '_DEPENDENCIES');
2693 &handle_source_transform ($xlib, $onelib, $obj);
2695 # If the resulting library lies into a subdirectory,
2696 # make sure this directory will exist.
2697 my $dirstamp = require_build_directory_maybe ($onelib);
2699 $output_rules .= &file_contents ('library',
2700 ('LIBRARY' => $onelib,
2701 'XLIBRARY' => $xlib,
2702 'DIRSTAMP' => $dirstamp));
2707 foreach my $onelib (@liblist)
2709 my $xlib = &canonicalize ($onelib);
2710 if (variable_defined ($xlib . '_LIBADD'))
2712 &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
2719 # handle_ltlibraries ()
2720 # ---------------------
2721 # Handle shared libraries.
2722 sub handle_ltlibraries
2724 my @liblist = &am_install_var ('ltlib', 'LTLIBRARIES',
2725 'noinst', 'lib', 'pkglib', 'check');
2726 return if ! @liblist;
2729 my @prefix = am_primary_prefixes ('LTLIBRARIES', 0, 'lib', 'pkglib',
2732 foreach my $key (@prefix)
2736 macro_error ($key . '_LTLIBRARIES',
2737 "library used but `LIBTOOL' not defined in `$configure_ac'");
2738 # Only get this error once. If this is ever printed,
2740 $configure_vars{'LIBTOOL'} = 'BUG';
2741 $seen_libtool = $var_location{$key . '_LTLIBRARIES'};
2744 # Get the installation directory of each library.
2745 for (variable_value_as_list_recursive ($key . '_LTLIBRARIES', 'all'))
2749 am_error ("`$_' is already going to be installed in `$instdirs{$_}'");
2753 $instdirs{$_} = $key;
2758 my $seen_libobjs = 0;
2759 foreach my $onelib (@liblist)
2761 my $obj = &get_object_extension ($onelib);
2763 # Canonicalize names and check for misspellings.
2764 my $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_LDFLAGS',
2765 '_SOURCES', '_OBJECTS',
2768 if (! variable_defined ($xlib . '_LDFLAGS'))
2770 # Define the lib_LDFLAGS variable.
2771 &define_variable ($xlib . '_LDFLAGS', '');
2774 # Check that the library fits the standard naming convention.
2775 my $libname_rx = "^lib.*\.la";
2776 if ((variable_defined ($xlib . '_LDFLAGS')
2777 && grep (/-module/, &variable_value_as_list_recursive (
2778 $xlib . '_LDFLAGS', 'all')))
2779 || (variable_defined ('LDFLAGS')
2780 && grep (/-module/, &variable_value_as_list_recursive (
2781 'LDFLAGS', 'all'))))
2783 # Relax name checking for libtool modules.
2784 $libname_rx = "\.la";
2786 if (basename ($onelib) !~ /$libname_rx$/)
2788 # FIXME this should only be a warning for foreign packages
2789 # FIXME should put line number here. That means mapping
2790 # from library name back to variable name.
2791 &am_error ("`$onelib' is not a standard libtool library name");
2794 if (variable_defined ($xlib . '_LIBADD'))
2796 if (&handle_lib_objects ($xlib, $xlib . '_LIBADD'))
2803 # Generate support for conditional object inclusion in
2805 &define_variable ($xlib . "_LIBADD", '');
2808 if (variable_defined ($xlib . '_LDADD'))
2810 macro_error ($xlib . '_LDADD',
2811 "use `" . $xlib . "_LIBADD', not `"
2812 . $xlib . "_LDADD'");
2815 # Make sure we at look at this.
2816 &examine_variable ($xlib . '_DEPENDENCIES');
2818 my $linker = &handle_source_transform ($xlib, $onelib, $obj);
2820 # Determine program to use for link.
2822 if (variable_defined ($xlib . '_LINK'))
2824 $xlink = $xlib . '_LINK';
2828 $xlink = $linker ? $linker : 'LINK';
2832 if ($instdirs{$onelib} eq 'EXTRA'
2833 || $instdirs{$onelib} eq 'noinst'
2834 || $instdirs{$onelib} eq 'check')
2836 # It's an EXTRA_ library, so we can't specify -rpath,
2837 # because we don't know where the library will end up.
2838 # The user probably knows, but generally speaking automake
2839 # doesn't -- and in fact configure could decide
2840 # dynamically between two different locations.
2845 $rpath = ('-rpath $(' . $instdirs{$onelib} . 'dir)');
2848 # If the resulting library lies into a subdirectory,
2849 # make sure this directory will exist.
2850 my $dirstamp = require_build_directory_maybe ($onelib);
2852 $output_rules .= &file_contents ('ltlibrary',
2853 ('LTLIBRARY' => $onelib,
2854 'XLTLIBRARY' => $xlib,
2857 'DIRSTAMP' => $dirstamp));
2862 foreach my $onelib (@liblist)
2864 my $xlib = &canonicalize ($onelib);
2865 if (variable_defined ($xlib . '_LIBADD'))
2867 &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
2873 # See if any _SOURCES variable were misspelled. Also, make sure that
2874 # EXTRA_ variables don't contain configure substitutions.
2877 foreach my $varname (keys %var_value)
2879 foreach my $primary ('_SOURCES', '_LIBADD', '_LDADD', '_LDFLAGS',
2882 macro_error ($varname,
2883 "invalid unused variable name: `$varname'")
2884 if $varname =~ /$primary$/ && ! $content_seen{$varname};
2893 # NOTE we no longer automatically clean SCRIPTS, because it is
2894 # useful to sometimes distribute scripts verbatim. This happens
2895 # eg in Automake itself.
2896 &am_install_var ('-candist', 'scripts', 'SCRIPTS',
2897 'bin', 'sbin', 'libexec', 'pkgdata',
2902 # ($OUTFILE, $VFILE, @CLEAN_FILES)
2903 # &scan_texinfo_file ($FILENAME)
2904 # ------------------------------
2905 # $OUTFILE is the name of the info file produced by $FILENAME.
2906 # $VFILE is the name of the version.texi file used (empty if none).
2907 # @CLEAN_FILES is the list of by products (indexes etc.)
2908 sub scan_texinfo_file
2910 my ($filename) = @_;
2912 # These are always created, no matter whether indexes are used or not.
2913 my @clean_suffixes = qw(aux dvi log ps toc
2914 cp fn ky vr tp pg); # grep new.*index texinfo.tex
2916 # There are predefined indexes which don't follow the regular rules.
2917 my %predefined_index = qw(c cps
2924 # There are commands which include a hidden index command.
2925 my %hidden_index = (tp => 'tps');
2926 $hidden_index{$_} = 'fns' foreach qw(fn un typefn typefun max spec
2927 op typeop method typemethod);
2928 $hidden_index{$_} = 'vrs' foreach qw(vr var typevr typevar opt cv
2931 # Indexes stored into another one. In this case, the *.??s file
2933 my @syncodeindexes = ();
2935 my $texi = new Automake::XFile "< $filename";
2936 verbose "reading $filename";
2938 my ($outfile, $vfile);
2939 while ($_ = $texi->getline)
2941 if (/^\@setfilename +(\S+)/)
2944 if ($outfile =~ /\.(.+)$/ && $1 ne 'info')
2946 file_error ("$filename:$.",
2947 "output `$outfile' has unrecognized extension");
2951 # A "version.texi" file is actually any file whose name
2952 # matches "vers*.texi".
2953 elsif (/^\@include\s+(vers[^.]*\.texi)\s*$/)
2958 # Try to find what are the indexes which are used.
2960 # Creating a new category of index.
2961 elsif (/^\@def(code)?index (\w+)/)
2963 push @clean_suffixes, $2;
2966 # Storing in a predefined index.
2967 elsif (/^\@([cfkvtp])index /)
2969 push @clean_suffixes, $predefined_index{$1};
2971 elsif (/^\@def(\w+) /)
2973 push @clean_suffixes, $hidden_index{$1}
2974 if defined $hidden_index{$1};
2977 # Merging an index into an another.
2978 elsif (/^\@syn(code)?index (\w+) (\w+)/)
2980 push @syncodeindexes, "$2s";
2981 push @clean_suffixes, "$3s";
2988 &am_error ("`$filename' missing \@setfilename");
2992 my $infobase = basename ($filename);
2993 $infobase =~ s/\.te?xi(nfo)?$//;
2994 # FIXME: I don't understand why, but I can't use "$infobase.$_" => 1.
2995 my %clean_files = map { "$infobase" . ".$_" => 1 } @clean_suffixes;
2996 grep { delete $clean_files{"$infobase.$_"} } @syncodeindexes;
2997 return ($outfile, $vfile, (sort keys %clean_files));
3001 # ($DO-SOMETHING, $TEXICLEANS)
3002 # handle_texinfo_helper ()
3003 # ------------------------
3004 # Handle all Texinfo source; helper for handle_texinfo
3005 sub handle_texinfo_helper
3007 macro_error ('TEXINFOS',
3008 "`TEXINFOS' is an anachronism; use `info_TEXINFOS'")
3009 if variable_defined ('TEXINFOS');
3010 return (0, '') if (! variable_defined ('info_TEXINFOS')
3011 && ! variable_defined ('html_TEXINFOS'));
3013 if (variable_defined ('html_TEXINFOS'))
3015 macro_error ('html_TEXINFOS',
3016 "HTML generation not yet supported");
3020 my @texis = &variable_value_as_list_recursive ('info_TEXINFOS', 'all');
3022 my (@info_deps_list, @dvis_list, @texi_deps);
3029 foreach my $info_cursor (@texis)
3031 my $infobase = $info_cursor;
3032 $infobase =~ s/\.(txi|texinfo|texi)$//;
3034 if ($infobase eq $info_cursor)
3036 # FIXME: report line number.
3037 &am_error ("texinfo file `$info_cursor' has unrecognized extension");
3040 $texi_suffixes{$1} = 1;
3042 # If 'version.texi' is referenced by input file, then include
3043 # automatic versioning capability.
3044 my ($out_file, $vtexi, @clean_files) =
3045 &scan_texinfo_file ("$relative_dir/$info_cursor")
3047 push (@texi_cleans, @clean_files);
3051 &am_error ("`$vtexi', included in `$info_cursor', also included in `$versions{$vtexi}'")
3052 if (defined $versions{$vtexi});
3053 $versions{$vtexi} = $info_cursor;
3055 # We number the stamp-vti files. This is doable since the
3056 # actual names don't matter much. We only number starting
3057 # with the second one, so that the common case looks nice.
3058 my $vti = ($done ? $done : 'vti');
3061 # This is ugly, but it is our historical practice.
3062 if ($config_aux_dir_set_in_configure_in)
3064 require_conf_file_with_macro ('info_TEXINFOS', FOREIGN,
3069 require_file_with_macro ('info_TEXINFOS', FOREIGN,
3074 if ($config_aux_dir_set_in_configure_in)
3076 $conf_dir = $config_aux_dir;
3077 $conf_dir .= '/' unless $conf_dir =~ /\/$/;
3081 $conf_dir = '$(srcdir)/';
3083 $output_rules .= &file_contents ('texi-vers',
3084 ('TEXI' => $info_cursor,
3087 'MDDIR' => $conf_dir));
3090 # If user specified file_TEXINFOS, then use that as explicit
3093 push (@texi_deps, $info_cursor);
3094 # Prefix with $(srcdir) because some version of make won't
3095 # work if the target has it and the dependency doesn't.
3096 push (@texi_deps, '$(srcdir)/' . $vtexi) if $vtexi;
3098 my $canonical = &canonicalize ($infobase);
3099 if (variable_defined ($canonical . "_TEXINFOS"))
3101 push (@texi_deps, '$(' . $canonical . '_TEXINFOS)');
3102 &push_dist_common ('$(' . $canonical . '_TEXINFOS)');
3105 $output_rules .= ("\n" . $out_file . ": "
3107 . "\n" . $infobase . ".dvi: "
3111 push (@info_deps_list, $out_file);
3112 push (@dvis_list, $infobase . '.dvi');
3115 # Handle location of texinfo.tex.
3116 my $need_texi_file = 0;
3120 $texinfodir = '$(top_srcdir)/../texinfo';
3121 &define_variable ('TEXINFO_TEX', "$texinfodir/texinfo.tex");
3123 elsif ($config_aux_dir_set_in_configure_in)
3125 $texinfodir = $config_aux_dir;
3126 &define_variable ('TEXINFO_TEX', "$texinfodir/texinfo.tex");
3127 $need_texi_file = 2; # so that we require_conf_file later
3129 elsif (variable_defined ('TEXINFO_TEX'))
3131 # The user defined TEXINFO_TEX so assume he knows what he is
3133 $texinfodir = ('$(srcdir)/'
3134 . dirname (&variable_value ('TEXINFO_TEX')));
3138 $texinfodir = '$(srcdir)';
3139 $need_texi_file = 1;
3142 foreach my $txsfx (sort keys %texi_suffixes)
3144 $output_rules .= &file_contents ('texibuild',
3145 ('TEXINFODIR' => $texinfodir,
3146 'SUFFIX' => $txsfx));
3150 my $texiclean = &pretty_print_internal ("", "\t ", @texi_cleans);
3152 push (@dist_targets, 'dist-info');
3154 if (! defined $options{'no-installinfo'})
3156 # Make sure documentation is made and installed first. Use
3157 # $(INFO_DEPS), not 'info', because otherwise recursive makes
3158 # get run twice during "make all".
3159 unshift (@all, '$(INFO_DEPS)');
3162 &define_variable ("INFO_DEPS", "@info_deps_list");
3163 &define_variable ("DVIS", "@dvis_list");
3164 # This next isn't strictly needed now -- the places that look here
3165 # could easily be changed to look in info_TEXINFOS. But this is
3166 # probably better, in case noinst_TEXINFOS is ever supported.
3167 &define_variable ("TEXINFOS", &variable_value ('info_TEXINFOS'));
3169 # Do some error checking. Note that this file is not required
3170 # when in Cygnus mode; instead we defined TEXINFO_TEX explicitly
3172 if ($need_texi_file && ! defined $options{'no-texinfo.tex'})
3174 if ($need_texi_file > 1)
3176 require_conf_file_with_macro ('info_TEXINFOS', FOREIGN,
3181 require_file_with_macro ('info_TEXINFOS', FOREIGN, 'texinfo.tex');
3185 return (1, $texiclean);
3190 # Handle all Texinfo source.
3193 my ($do_something, $texiclean) = handle_texinfo_helper ();
3194 $output_rules .= &file_contents ('texinfos',
3195 ('TEXICLEAN' => $texiclean,
3196 'LOCAL-TEXIS' => $do_something));
3199 # Handle any man pages.
3200 sub handle_man_pages
3202 macro_error ('MANS', "`MANS' is an anachronism; use `man_MANS'")
3203 if variable_defined ('MANS');
3205 # Find all the sections in use. We do this by first looking for
3206 # "standard" sections, and then looking for any additional
3207 # sections used in man_MANS.
3208 my (%sections, %vlist);
3209 # We handle nodist_ for uniformity. man pages aren't distributed
3210 # by default so it isn't actually very important.
3211 foreach my $pfx ('', 'dist_', 'nodist_')
3213 # Add more sections as needed.
3214 foreach my $section ('0'..'9', 'n', 'l')
3216 if (variable_defined ($pfx . 'man' . $section . '_MANS'))
3218 $sections{$section} = 1;
3219 $vlist{'$(' . $pfx . 'man' . $section . '_MANS)'} = 1;
3221 &push_dist_common ('$(' . $pfx . 'man' . $section . '_MANS)')
3226 if (variable_defined ($pfx . 'man_MANS'))
3228 $vlist{'$(' . $pfx . 'man_MANS)'} = 1;
3229 foreach (&variable_value_as_list_recursive ($pfx . 'man_MANS', 'all'))
3231 # A page like `foo.1c' goes into man1dir.
3232 if (/\.([0-9a-z])([a-z]*)$/)
3238 &push_dist_common ('$(' . $pfx . 'man_MANS)')
3243 return unless %sections;
3245 # Now for each section, generate an install and unintall rule.
3246 # Sort sections so output is deterministic.
3247 foreach my $section (sort keys %sections)
3249 $output_rules .= &file_contents ('mans', ('SECTION' => $section));
3252 my @mans = sort keys %vlist;
3253 $output_vars .= file_contents ('mans-vars',
3254 ('MANS' => "@mans"));
3256 if (! defined $options{'no-installman'})
3258 push (@all, '$(MANS)');
3262 # Handle DATA variables.
3265 &am_install_var ('-noextra', '-candist', 'data', 'DATA',
3266 'data', 'sysconf', 'sharedstate', 'localstate',
3267 'pkgdata', 'noinst', 'check');
3274 if (variable_defined ('SUBDIRS'))
3276 $output_rules .= ("tags-recursive:\n"
3277 . "\tlist=\'\$(SUBDIRS)\'; for subdir in \$\$list; do \\\n"
3278 # Never fail here if a subdir fails; it
3280 . "\t test \"\$\$subdir\" = . || (cd \$\$subdir"
3281 . " && \$(MAKE) \$(AM_MAKEFLAGS) tags); \\\n"
3283 push (@tag_deps, 'tags-recursive');
3284 &depend ('.PHONY', 'tags-recursive');
3287 if (&saw_sources_p (1)
3288 || variable_defined ('ETAGS_ARGS')
3292 foreach my $spec (@config_headers)
3294 my ($out, @ins) = split_config_file_spec ($spec);
3295 foreach my $in (@ins)
3297 # If the config header source is in this directory,
3299 push @config, basename ($in)
3300 if $relative_dir eq dirname ($in);
3303 $output_rules .= &file_contents ('tags',
3304 ('CONFIG' => "@config",
3305 'DIRS' => "@tag_deps"));
3306 &examine_variable ('TAGS_DEPENDENCIES');
3308 elsif (variable_defined ('TAGS_DEPENDENCIES'))
3310 macro_error ('TAGS_DEPENDENCIES',
3311 "doesn't make sense to define `TAGS_DEPENDENCIES' without sources or `ETAGS_ARGS'");
3315 # Every Makefile must define some sort of TAGS rule.
3316 # Otherwise, it would be possible for a top-level "make TAGS"
3317 # to fail because some subdirectory failed.
3318 $output_rules .= "tags: TAGS\nTAGS:\n\n";
3322 # Handle multilib support.
3325 if ($seen_multilib && $relative_dir eq '.')
3327 $output_rules .= &file_contents ('multilib');
3333 # &for_dist_common ($A, $B)
3334 # -------------------------
3335 # Subroutine for &handle_dist: sort files to dist.
3337 # We put README first because it then becomes easier to make a
3338 # Usenet-compliant shar file (in these, README must be first).
3340 # FIXME: do more ordering of files here.
3353 # handle_dist ($MAKEFILE)
3354 # -----------------------
3355 # Handle 'dist' target.
3358 my ($makefile) = @_;
3360 # `make dist' isn't used in a Cygnus-style tree.
3361 # Omit the rules so that people don't try to use them.
3362 return if $cygnus_mode;
3364 # Look for common files that should be included in distribution.
3365 # If the aux dir is set, and it does not have a Makefile.am, then
3366 # we check for these files there as well.
3369 if ($relative_dir eq '.'
3370 && $config_aux_dir_set_in_configure_in)
3372 ($auxdir = $config_aux_dir) =~ s,^\$\(top_srcdir\)/,,;
3373 if (! &is_make_dir ($auxdir))
3378 foreach my $cfile (@common_files)
3380 if (-f ($relative_dir . "/" . $cfile))
3382 &push_dist_common ($cfile);
3385 # Don't use `elsif' here because a file might meaningfully
3386 # appear in both directories.
3387 if ($check_aux && -f ($auxdir . '/' . $cfile))
3389 &push_dist_common ($auxdir . '/' . $cfile);
3393 # We might copy elements from $configure_dist_common to
3394 # %dist_common if we think we need to. If the file appears in our
3395 # directory, we would have discovered it already, so we don't
3396 # check that. But if the file is in a subdir without a Makefile,
3397 # we want to distribute it here if we are doing `.'. Ugly!
3398 if ($relative_dir eq '.')
3400 foreach my $file (split (' ' , $configure_dist_common))
3402 push_dist_common ($file)
3403 unless is_make_dir (dirname ($file));
3409 # Files to distributed. Don't use &variable_value_as_list_recursive
3410 # as it recursively expands `$(dist_pkgdata_DATA)' etc.
3411 check_variable_defined_unconditionally ('DIST_COMMON');
3412 my @dist_common = split (' ', variable_value ('DIST_COMMON', 'TRUE'));
3413 @dist_common = uniq (sort for_dist_common (@dist_common));
3414 pretty_print ('DIST_COMMON = ', "\t", @dist_common);
3416 # Now that we've processed DIST_COMMON, disallow further attempts
3418 $handle_dist_run = 1;
3420 # Scan EXTRA_DIST to see if we need to distribute anything from a
3421 # subdir. If so, add it to the list. I didn't want to do this
3422 # originally, but there were so many requests that I finally
3424 if (variable_defined ('EXTRA_DIST'))
3426 # FIXME: This should be fixed to work with conditionals. That
3427 # will require only making the entries in %dist_dirs under the
3428 # appropriate condition. This is meaningful if the nature of
3429 # the distribution should depend upon the configure options
3431 foreach (&variable_value_as_list_recursive ('EXTRA_DIST', ''))
3434 next unless s,/+[^/]+$,,;
3440 # We have to check DIST_COMMON for extra directories in case the
3441 # user put a source used in AC_OUTPUT into a subdir.
3442 foreach (&variable_value_as_list_recursive ('DIST_COMMON', 'all'))
3445 next unless s,/+[^/]+$,,;
3450 # Rule to check whether a distribution is viable.
3451 my %transform = ('DISTCHECK-HOOK' => &target_defined ('distcheck-hook'),
3452 'GETTEXT' => $seen_gettext);
3454 # Prepend $(distdir) to each directory given.
3455 my %rewritten = map { '$(distdir)/' . "$_" => 1 } keys %dist_dirs;
3456 $transform{'DISTDIRS'} = join (' ', sort keys %rewritten);
3458 # If we have SUBDIRS, create all dist subdirectories and do
3460 if (variable_defined ('SUBDIRS'))
3462 # If SUBDIRS is conditionally defined, then set DIST_SUBDIRS
3463 # to all possible directories, and use it. If DIST_SUBDIRS is
3464 # defined, just use it.
3465 my $dist_subdir_name;
3466 # Note that we check DIST_SUBDIRS first on purpose. At least
3467 # one project uses so many conditional subdirectories that
3468 # calling variable_conditionally_defined on SUBDIRS will cause
3469 # automake to grow to 150Mb. Sigh.
3470 if (variable_defined ('DIST_SUBDIRS')
3471 || variable_conditionally_defined ('SUBDIRS'))
3473 $dist_subdir_name = 'DIST_SUBDIRS';
3474 if (! variable_defined ('DIST_SUBDIRS'))
3476 define_pretty_variable
3477 ('DIST_SUBDIRS', '',
3478 uniq (&variable_value_as_list_recursive ('SUBDIRS', 'all')));
3483 $dist_subdir_name = 'SUBDIRS';
3484 # We always define this because that is what `distclean'
3486 define_pretty_variable ('DIST_SUBDIRS', '', '$(SUBDIRS)');
3489 $transform{'DIST_SUBDIR_NAME'} = $dist_subdir_name;
3492 # If the target `dist-hook' exists, make sure it is run. This
3493 # allows users to do random weird things to the distribution
3494 # before it is packaged up.
3495 push (@dist_targets, 'dist-hook')
3496 if &target_defined ('dist-hook');
3497 $transform{'DIST-TARGETS'} = join(' ', @dist_targets);
3499 # Defining $(DISTDIR).
3500 $transform{'DISTDIR'} = !variable_defined('distdir');
3501 $transform{'TOP_DISTDIR'} = backname ($relative_dir);
3503 $output_rules .= &file_contents ('distdir', %transform);
3507 # Handle subdirectories.
3511 unless variable_defined ('SUBDIRS');
3513 # Make sure each directory mentioned in SUBDIRS actually exists.
3514 foreach my $dir (&variable_value_as_list_recursive ('SUBDIRS', 'all'))
3516 # Skip directories substituted by configure.
3517 next if $dir =~ /^\@.*\@$/;
3519 if (! -d $am_relative_dir . '/' . $dir)
3521 macro_error ('SUBDIRS',
3522 "required directory $am_relative_dir/$dir does not exist");
3526 macro_error ('SUBDIRS', "directory should not contain `/'")
3530 $output_rules .= &file_contents ('subdirs');
3531 variable_pretty_output ('RECURSIVE_TARGETS', 'TRUE');
3535 # ($REGEN, @DEPENDENCIES)
3538 # If aclocal.m4 creation is automated, return the list of its dependencies.
3541 my $regen_aclocal = 0;
3544 unless $relative_dir eq '.';
3546 &examine_variable ('CONFIG_STATUS_DEPENDENCIES');
3547 &examine_variable ('CONFIGURE_DEPENDENCIES');
3549 if (-f 'aclocal.m4')
3551 &define_variable ("ACLOCAL_M4", '$(top_srcdir)/aclocal.m4');
3552 &push_dist_common ('aclocal.m4');
3554 my $aclocal = new Automake::XFile "< aclocal.m4";
3555 my $line = $aclocal->getline;
3556 $regen_aclocal = $line =~ 'generated automatically by aclocal';
3561 if (-f 'acinclude.m4')
3564 push @ac_deps, 'acinclude.m4';
3567 if (variable_defined ('ACLOCAL_M4_SOURCES'))
3569 push (@ac_deps, '$(ACLOCAL_M4_SOURCES)');
3571 elsif (variable_defined ('ACLOCAL_AMFLAGS'))
3573 # Scan all -I directories for m4 files. These are our
3575 my $examine_next = 0;
3576 foreach my $amdir (&variable_value_as_list_recursive ('ACLOCAL_AMFLAGS', ''))
3581 if ($amdir !~ /^\// && -d $amdir)
3583 foreach my $ac_dep (&my_glob ($amdir . '/*.m4'))
3585 $ac_dep =~ s/^\.\/+//;
3586 push (@ac_deps, $ac_dep)
3587 unless $ac_dep eq "aclocal.m4"
3588 || $ac_dep eq "acinclude.m4";
3592 elsif ($amdir eq '-I')
3599 # Note that it might be possible that aclocal.m4 doesn't exist but
3600 # should be auto-generated. This case probably isn't very
3603 return ($regen_aclocal, @ac_deps);
3608 # &rewrite_inputs_into_dependencies ($ADD_SRCDIR, @INPUTS)
3609 # --------------------------------------------------------
3610 # Rewrite a list of input files into a form suitable to put on a
3611 # dependency list. The idea is that if an input file has a directory
3612 # part the same as the current directory, then the directory part is
3613 # simply removed. But if the directory part is different, then
3614 # $(top_srcdir) is prepended. Among other things, this is used to
3615 # generate the dependency list for the output files generated by
3616 # AC_OUTPUT. Consider what the dependencies should look like in this
3618 # AC_OUTPUT(src/out:src/in1:lib/in2)
3619 # The first argument, ADD_SRCDIR, is 1 if $(top_srcdir) should be added.
3620 # If 0 then files that require this addition will simply be ignored.
3621 sub rewrite_inputs_into_dependencies ($@)
3623 my ($add_srcdir, @inputs) = @_;
3626 foreach my $single (@inputs)
3628 if (dirname ($single) eq $relative_dir)
3630 push (@newinputs, basename ($single));
3634 push (@newinputs, '$(top_srcdir)/' . $single);
3641 # Handle remaking and configure stuff.
3642 # We need the name of the input file, to do proper remaking rules.
3643 sub handle_configure
3645 my ($local, $input, @secondary_inputs) = @_;
3647 my $input_base = basename ($input);
3648 my $local_base = basename ($local);
3650 my $amfile = $input_base . '.am';
3651 # We know we can always add '.in' because it really should be an
3652 # error if the .in was missing originally.
3653 my $infile = '$(srcdir)/' . $input_base . '.in';
3654 my $colon_infile = '';
3655 if ($local ne $input || @secondary_inputs)
3657 $colon_infile = ':' . $input . '.in';
3659 $colon_infile .= ':' . join (':', @secondary_inputs)
3660 if @secondary_inputs;
3662 my @rewritten = rewrite_inputs_into_dependencies (1, @secondary_inputs);
3664 my ($regen_aclocal_m4, @aclocal_m4_deps) = scan_aclocal_m4 ();
3667 &file_contents ('configure',
3673 => ((($relative_dir eq '.') ? '$@' : '$(subdir)/$@')
3678 => "@include_stack",
3682 => $cygnus_mode ? 'cygnus' : $strictness_name,
3684 => $cmdline_use_dependencies ? '' : ' --ignore-deps',
3685 'MAKEFILE-AM-SOURCES'
3686 => "$input$colon_infile",
3688 => $regen_aclocal_m4,
3690 => "@aclocal_m4_deps"));
3692 if ($relative_dir eq '.')
3694 &push_dist_common ('acconfig.h')
3698 # If we have a configure header, require it.
3700 my @distclean_config;
3701 foreach my $spec (@config_headers)
3704 # $CONFIG_H_PATH: config.h from top level.
3705 my ($config_h_path, @ins) = split_config_file_spec ($spec);
3706 my $config_h_dir = dirname ($config_h_path);
3708 # If the header is in the current directory we want to build
3709 # the header here. Otherwise, if we're at the topmost
3710 # directory and the header's directory doesn't have a
3711 # Makefile, then we also want to build the header.
3712 if ($relative_dir eq $config_h_dir
3713 || ($relative_dir eq '.' && ! &is_make_dir ($config_h_dir)))
3715 my ($cn_sans_dir, $stamp_dir);
3716 if ($relative_dir eq $config_h_dir)
3718 $cn_sans_dir = basename ($config_h_path);
3723 $cn_sans_dir = $config_h_path;
3724 if ($config_h_dir eq '.')
3730 $stamp_dir = $config_h_dir . '/';
3734 # Compute relative path from directory holding output
3735 # header to directory holding input header. FIXME:
3736 # doesn't handle case where we have multiple inputs.
3738 if (dirname ($ins[0]) eq $relative_dir)
3740 $in0_sans_dir = basename ($ins[0]);
3744 $in0_sans_dir = backname ($relative_dir) . '/' . $ins[0];
3747 require_file ($config_header_location, FOREIGN, $in0_sans_dir);
3749 # Header defined and in this directory.
3751 if (-f $config_h_path . '.top')
3753 push (@files, "$cn_sans_dir.top");
3755 if (-f $config_h_path . '.bot')
3757 push (@files, "$cn_sans_dir.bot");
3760 push_dist_common (@files);
3762 # For now, acconfig.h can only appear in the top srcdir.
3763 if (-f 'acconfig.h')
3765 push (@files, '$(top_srcdir)/acconfig.h');
3768 my $stamp = "${stamp_dir}stamp-h${hdr_index}";
3770 file_contents ('remake-hdr',
3771 ('FILES' => "@files",
3772 'CONFIG_H' => $cn_sans_dir,
3773 'CONFIG_HIN' => $in0_sans_dir,
3774 'CONFIG_H_PATH' => $config_h_path,
3775 'STAMP' => "$stamp"));
3777 push @distclean_config, $cn_sans_dir;
3781 $output_rules .= file_contents ('clean-hdr',
3782 ('FILES' => "@distclean_config"))
3783 if @distclean_config;
3785 # Set location of mkinstalldirs.
3786 define_variable ('mkinstalldirs',
3787 ('$(SHELL) ' . $config_aux_dir . '/mkinstalldirs'));
3789 macro_error ('CONFIG_HEADER',
3790 "`CONFIG_HEADER' is an anachronism; now determined from `$configure_ac'")
3791 if variable_defined ('CONFIG_HEADER');
3794 foreach my $spec (@config_headers)
3796 my ($out, @ins) = split_config_file_spec ($spec);
3797 # Generate CONFIG_HEADER define.
3798 if ($relative_dir eq dirname ($out))
3800 push @config_h, basename ($out);
3804 push @config_h, "\$(top_builddir)/$out";
3807 define_variable ("CONFIG_HEADER", "@config_h")
3810 # Now look for other files in this directory which must be remade
3811 # by config.status, and generate rules for them.
3812 my @actual_other_files = ();
3813 foreach my $lfile (@other_input_files)
3817 if ($lfile =~ /^([^:]*):(.*)$/)
3819 # This is the ":" syntax of AC_OUTPUT.
3821 @inputs = split (':', $2);
3827 @inputs = $file . '.in';
3830 # Automake files should not be stored in here, but in %MAKE_LIST.
3831 prog_error ("$lfile in \@other_input_files")
3832 if -f $file . '.am';
3834 my $local = basename ($file);
3836 # Make sure the dist directory for each input file is created.
3837 # We only have to do this at the topmost level though. This
3838 # is a bit ugly but it easier than spreading out the logic,
3839 # especially in cases like AC_OUTPUT(foo/out:bar/in), where
3840 # there is no Makefile in bar/.
3841 if ($relative_dir eq '.')
3845 $dist_dirs{dirname ($_)} = 1;
3849 # We skip files that aren't in this directory. However, if
3850 # the file's directory does not have a Makefile, and we are
3851 # currently doing `.', then we create a rule to rebuild the
3852 # file in the subdir.
3853 my $fd = dirname ($file);
3854 if ($fd ne $relative_dir)
3856 if ($relative_dir eq '.' && ! &is_make_dir ($fd))
3866 # Some users have been tempted to put `stamp-h' in the
3867 # AC_OUTPUT line. This won't do the right thing, so we
3868 # explicitly fail here.
3869 if ($local eq 'stamp-h')
3871 # FIXME: allow real filename.
3872 file_error ($ac_config_files_location,
3873 'stamp-h should not appear in AC_OUTPUT');
3877 my @rewritten_inputs = rewrite_inputs_into_dependencies (1, @inputs);
3878 $output_rules .= ($local . ': '
3879 . '$(top_builddir)/config.status '
3880 . "@rewritten_inputs\n"
3882 . 'cd $(top_builddir) && '
3883 . '$(SHELL) ./config.status '
3884 . ($relative_dir eq '.' ? '' : '$(subdir)/')
3887 push (@actual_other_files, $local);
3889 # Require all input files.
3890 require_file ($ac_config_files_location, FOREIGN,
3891 rewrite_inputs_into_dependencies (0, @inputs));
3894 # These files get removed by "make clean".
3895 define_pretty_variable ('CONFIG_CLEAN_FILES', '', @actual_other_files);
3901 my @r = &am_install_var ('-defaultdist', 'header', 'HEADERS', 'include',
3902 'oldinclude', 'pkginclude',
3906 next unless /\..*$/;
3907 &saw_extension ($&);
3913 return if ! $seen_gettext || $relative_dir ne '.';
3915 if (! variable_defined ('SUBDIRS'))
3917 conf_error ("AM_GNU_GETTEXT used but SUBDIRS not defined");
3921 my @subdirs = &variable_value_as_list_recursive ('SUBDIRS', 'all');
3922 macro_error ('SUBDIRS',
3923 "AM_GNU_GETTEXT used but `po' not in SUBDIRS")
3924 if ! grep ('po', @subdirs);
3925 macro_error ('SUBDIRS',
3926 "AM_GNU_GETTEXT used but `intl' not in SUBDIRS")
3927 if ! grep ('intl', @subdirs);
3929 require_file ($ac_gettext_location, GNU, 'ABOUT-NLS');
3932 # Handle footer elements.
3935 # NOTE don't use define_pretty_variable here, because
3936 # $contents{...} is already defined.
3937 $output_vars .= 'SOURCES = ' . variable_value ('SOURCES') . "\n\n"
3938 if variable_value ('SOURCES');
3941 target_error ('.SUFFIXES',
3942 "use variable `SUFFIXES', not target `.SUFFIXES'")
3943 if target_defined ('.SUFFIXES');
3945 # Note: AIX 4.1 /bin/make will fail if any suffix rule appears
3946 # before .SUFFIXES. So we make sure that .SUFFIXES appears before
3947 # anything else, by sticking it right after the default: target.
3948 $output_header .= ".SUFFIXES:\n";
3949 if (@suffixes || variable_defined ('SUFFIXES'))
3951 # Make sure suffixes has unique elements. Sort them to ensure
3952 # the output remains consistent. However, $(SUFFIXES) is
3953 # always at the start of the list, unsorted. This is done
3954 # because make will choose rules depending on the ordering of
3955 # suffixes, and this lets the user have some control. Push
3956 # actual suffixes, and not $(SUFFIXES). Some versions of make
3957 # do not like variable substitutions on the .SUFFIXES line.
3958 my @user_suffixes = (variable_defined ('SUFFIXES')
3959 ? &variable_value_as_list_recursive ('SUFFIXES', '')
3962 my %suffixes = map { $_ => 1 } @suffixes;
3963 delete @suffixes{@user_suffixes};
3965 $output_header .= (".SUFFIXES: "
3966 . join (' ', @user_suffixes, sort keys %suffixes)
3970 $output_trailer .= file_contents ('footer');
3973 # Deal with installdirs target.
3974 sub handle_installdirs ()
3977 &file_contents ('install',
3979 => variable_value ('_am_installdirs') || ''));
3983 # Deal with all and all-am.
3986 my ($makefile) = @_;
3990 # Put this at the beginning for the sake of non-GNU makes. This
3991 # is still wrong if these makes can run parallel jobs. But it is
3993 unshift (@all, basename ($makefile));
3995 foreach my $spec (@config_headers)
3997 my ($out, @ins) = split_config_file_spec ($spec);
3998 push (@all, basename ($out))
3999 if dirname ($out) eq $relative_dir;
4002 # Install `all' hooks.
4003 if (&target_defined ("all-local"))
4005 push (@all, "all-local");
4006 &depend ('.PHONY', "all-local");
4009 &pretty_print_rule ("all-am:", "\t\t", @all);
4010 &depend ('.PHONY', 'all-am', 'all');
4015 my @local_headers = ();
4016 push @local_headers, '$(BUILT_SOURCES)'
4017 if variable_defined ('BUILT_SOURCES');
4018 foreach my $spec (@config_headers)
4020 my ($out, @ins) = split_config_file_spec ($spec);
4021 push @local_headers, basename ($out)
4022 if dirname ($out) eq $relative_dir;
4027 # We need to make sure config.h is built before we recurse.
4028 # We also want to make sure that built sources are built
4029 # before any ordinary `all' targets are run. We can't do this
4030 # by changing the order of dependencies to the "all" because
4031 # that breaks when using parallel makes. Instead we handle
4032 # things explicitly.
4033 $output_all .= ("all: @local_headers"
4035 . '$(MAKE) $(AM_MAKEFLAGS) '
4036 . (variable_defined ('SUBDIRS')
4037 ? 'all-recursive' : 'all-am')
4042 $output_all .= "all: " . (variable_defined ('SUBDIRS')
4043 ? 'all-recursive' : 'all-am') . "\n\n";
4048 # Handle check merge target specially.
4049 sub do_check_merge_target
4051 if (&target_defined ('check-local'))
4053 # User defined local form of target. So include it.
4054 push (@check_tests, 'check-local');
4055 &depend ('.PHONY', 'check-local');
4058 # In --cygnus mode, check doesn't depend on all.
4061 # Just run the local check rules.
4062 &pretty_print_rule ('check-am:', "\t\t", @check);
4066 # The check target must depend on the local equivalent of
4067 # `all', to ensure all the primary targets are built. Then it
4068 # must build the local check rules.
4069 $output_rules .= "check-am: all-am\n";
4070 &pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ",
4074 &pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ",
4078 &depend ('.PHONY', 'check', 'check-am');
4079 $output_rules .= ("check: "
4080 . (variable_defined ('SUBDIRS')
4081 ? 'check-recursive' : 'check-am')
4085 # Handle all 'clean' targets.
4090 # Don't include `MAINTAINER'; it is handled specially below.
4091 foreach my $name ('MOSTLY', '', 'DIST')
4093 $transform{"${name}CLEAN"} = variable_defined ("${name}CLEANFILES");
4096 # Built sources are automatically removed by maintainer-clean.
4097 push (@maintainer_clean_files, '$(BUILT_SOURCES)')
4098 if variable_defined ('BUILT_SOURCES');
4099 push (@maintainer_clean_files, '$(MAINTAINERCLEANFILES)')
4100 if variable_defined ('MAINTAINERCLEANFILES');
4102 $output_rules .= &file_contents ('clean',
4105 # Join with no space to avoid
4106 # spurious `test -z' success at
4108 => join ('', @maintainer_clean_files),
4110 # A space is required in the join here.
4111 => "@maintainer_clean_files"));
4115 # &depend ($CATEGORY, @DEPENDENDEES)
4116 # ----------------------------------
4117 # The target $CATEGORY depends on @DEPENDENDEES.
4120 my ($category, @dependendees) = @_;
4122 push (@{$dependencies{$category}}, @dependendees);
4127 # &target_cmp ($A, $B)
4128 # --------------------
4129 # Subroutine for &handle_factored_dependencies to let `.PHONY' be last.
4142 # &handle_factored_dependencies ()
4143 # --------------------------------
4144 # Handle everything related to gathered targets.
4145 sub handle_factored_dependencies
4148 foreach my $utarg ('uninstall-data-local', 'uninstall-data-hook',
4149 'uninstall-exec-local', 'uninstall-exec-hook')
4151 if (&target_defined ($utarg))
4154 $x =~ s/(data|exec)-//;
4155 target_error ($utarg, "use `$x', not `$utarg'");
4159 if (&target_defined ('install-local'))
4161 target_error ('install-local',
4162 "use `install-data-local' or `install-exec-local', "
4163 . "not `install-local'");
4166 if (!defined $options{'no-installinfo'}
4167 && &target_defined ('install-info-local'))
4169 target_error ('install-info-local',
4170 "`install-info-local' target defined but "
4171 . "`no-installinfo' option not in use");
4174 # Install the -local hooks.
4175 foreach (keys %dependencies)
4177 # Hooks are installed on the -am targets.
4179 if (&target_defined ("$_-local"))
4181 depend ("$_-am", "$_-local");
4182 &depend ('.PHONY', "$_-local");
4186 # Install the -hook hooks.
4187 # FIXME: Why not be as liberal as we are with -local hooks?
4188 foreach ('install-exec', 'install-data')
4190 if (&target_defined ("$_-hook"))
4192 $actions{"$_-am"} .=
4193 ("\t\@\$(NORMAL_INSTALL)\n"
4194 . "\t" . '$(MAKE) $(AM_MAKEFLAGS) ' . "$_-hook\n");
4198 # All the required targets are phony.
4199 depend ('.PHONY', keys %required_targets);
4201 # Actually output gathered targets.
4202 foreach (sort target_cmp keys %dependencies)
4204 # If there is nothing about this guy, skip it.
4206 unless (@{$dependencies{$_}}
4208 || $required_targets{$_});
4209 &pretty_print_rule ("$_:", "\t",
4210 uniq (sort @{$dependencies{$_}}));
4211 $output_rules .= $actions{$_}
4212 if defined $actions{$_};
4213 $output_rules .= "\n";
4218 # &handle_tests_dejagnu ()
4219 # ------------------------
4220 sub handle_tests_dejagnu
4222 push (@check_tests, 'check-DEJAGNU');
4223 $output_rules .= file_contents ('dejagnu');
4227 # Handle TESTS variable and other checks.
4230 if (defined $options{'dejagnu'})
4232 &handle_tests_dejagnu;
4236 foreach my $c ('DEJATOOL', 'RUNTEST', 'RUNTESTFLAGS')
4239 "`$c' defined but `dejagnu' not in `AUTOMAKE_OPTIONS'")
4240 if variable_defined ($c);
4244 if (variable_defined ('TESTS'))
4246 push (@check_tests, 'check-TESTS');
4247 $output_rules .= &file_contents ('check');
4251 # Handle Emacs Lisp.
4252 sub handle_emacs_lisp
4254 my @elfiles = &am_install_var ('-candist', 'lisp', 'LISP',
4257 return if ! @elfiles;
4259 # Generate .elc files.
4260 my @elcfiles = map { $_ . 'c' } @elfiles;
4261 define_pretty_variable ('ELCFILES', '', @elcfiles);
4263 push (@all, '$(ELCFILES)');
4265 &am_error ("`lisp_LISP' defined but `AM_PATH_LISPDIR' not in `$configure_ac'")
4266 if ! $am_lispdir_location && variable_defined ('lisp_LISP');
4268 require_conf_file ($am_lispdir_location, FOREIGN, 'elisp-comp');
4269 &define_variable ('elisp_comp', $config_aux_dir . '/elisp-comp');
4275 my @pyfiles = &am_install_var ('-defaultdist', 'python', 'PYTHON',
4276 'python', 'noinst');
4277 return if ! @pyfiles;
4279 # Found some python.
4280 &am_error ("`python_PYTHON' defined but `AM_PATH_PYTHON' not in `$configure_ac'")
4281 if ! $pythondir_location && variable_defined ('python_PYTHON');
4283 require_conf_file ($pythondir_location, FOREIGN, 'py-compile');
4284 &define_variable ('py_compile', $config_aux_dir . '/py-compile');
4290 my @sourcelist = &am_install_var ('-candist',
4292 'java', 'noinst', 'check');
4293 return if ! @sourcelist;
4295 my @prefix = am_primary_prefixes ('JAVA', 1,
4296 'java', 'noinst', 'check');
4299 foreach my $curs (@prefix)
4302 if $curs eq 'EXTRA';
4304 macro_error ($curs . '_JAVA',
4305 "multiple _JAVA primaries in use")
4311 push (@all, 'class' . $dir . '.stamp');
4315 # Handle some of the minor options.
4316 sub handle_minor_options
4318 if (defined $options{'readme-alpha'})
4320 if ($relative_dir eq '.')
4322 if ($package_version !~ /^$GNITS_VERSION_PATTERN$/)
4324 # FIXME: allow real filename.
4325 file_error ($package_version_location,
4326 "version `$package_version' doesn't follow Gnits standards");
4328 elsif (defined $1 && -f 'README-alpha')
4330 # This means we have an alpha release. See
4331 # GNITS_VERSION_PATTERN for details.
4332 require_file_with_macro ('AUTOMAKE_OPTIONS',
4333 FOREIGN, 'README-alpha');
4339 ################################################################
4341 # ($OUTPUT, @INPUTS)
4342 # &split_config_file_spec ($SPEC)
4343 # -------------------------------
4344 # Decode the Autoconf syntax for config files (files, headers, links
4346 sub split_config_file_spec ($)
4349 my ($output, @inputs) = split (/:/, $spec);
4351 push @inputs, "$output.in"
4354 return ($output, @inputs);
4360 # &scan_autoconf_config_files ($CONFIG-FILES)
4361 # -------------------------------------------
4362 # Study $CONFIG-FILES which is the first argument to AC_CONFIG_FILES
4364 sub scan_autoconf_config_files
4366 my ($config_files) = @_;
4367 # Look at potential Makefile.am's.
4368 foreach (split ' ', $config_files)
4370 # Must skip empty string for Perl 4.
4371 next if $_ eq "\\" || $_ eq '';
4373 # Handle $local:$input syntax. Note that we ignore
4374 # every input file past the first, though we keep
4375 # those around for later.
4376 my ($local, $input, @rest) = split (/:/);
4383 # FIXME: should be error if .in is missing.
4384 $input =~ s/\.in$//;
4387 if (-f $input . '.am')
4389 # We have a file that automake should generate.
4390 $make_list{$input} = join (':', ($local, @rest));
4394 # We have a file that automake should cause to be
4395 # rebuilt, but shouldn't generate itself.
4396 push (@other_input_files, $_);
4402 # &scan_autoconf_traces ($FILENAME)
4403 # ---------------------------------
4404 # FIXME: For the time being, we don't care about the FILENAME.
4405 sub scan_autoconf_traces ($)
4407 my ($filename) = @_;
4409 my @traced = qw(AC_CANONICAL_HOST
4414 AC_PROG_LIBTOOL AM_PROG_LIBTOOL
4427 my $traces = "$ENV{amtraces} ";
4429 # Use a separator unlikely to be used, not `:', the default, which
4430 # has a precise meaning for AC_CONFIG_FILES and so on.
4431 $traces .= join (' ',
4432 map { "--trace=$_" . ':\$f:\$l::\$n::\${::}%' } @traced);
4434 my $tracefh = new Automake::XFile ("$traces |");
4435 verbose "reading $traces";
4437 while ($_ = $tracefh->getline)
4440 my ($here, @args) = split /::/;
4441 my $macro = $args[0];
4443 # Alphabetical ordering please.
4444 if ($macro eq 'AC_CANONICAL_HOST')
4446 if (! $seen_canonical)
4448 $seen_canonical = AC_CANONICAL_HOST;
4449 $canonical_location = $here;
4452 elsif ($macro eq 'AC_CANONICAL_SYSTEM')
4454 $seen_canonical = AC_CANONICAL_SYSTEM;
4455 $canonical_location = $here;
4457 elsif ($macro eq 'AC_CONFIG_AUX_DIR')
4459 @config_aux_path = $args[1];
4460 $config_aux_dir_set_in_configure_in = 1;
4462 elsif ($macro eq 'AC_CONFIG_FILES')
4464 # Look at potential Makefile.am's.
4465 $ac_config_files_location = $here;
4466 &scan_autoconf_config_files ($args[1]);
4468 elsif ($macro eq 'AC_LIBSOURCE')
4470 $libsources{$args[1]} = $here;
4472 elsif ($macro =~ /^A(C|M)_PROG_LIBTOOL$/)
4474 $seen_libtool = $here;
4476 elsif ($macro eq 'AC_PROG_LEX')
4478 $seen_prog_lex = $here;
4480 elsif ($macro eq 'AC_SUBST')
4482 # Just check for alphanumeric in AC_SUBST. If you do
4483 # AC_SUBST(5), then too bad.
4484 $configure_vars{$args[1]} = $here
4485 if $args[1] =~ /^\w+$/;
4487 elsif ($macro eq 'AM_CONDITIONAL')
4489 $configure_cond{$args[1]} = $here;
4491 elsif ($macro eq 'AM_CONFIG_HEADER')
4493 $config_header_location = $here;
4494 push @config_headers, split (' ', $args[1]);
4496 elsif ($macro eq 'AM_C_PROTOTYPES')
4498 $am_c_prototypes = $here;
4500 elsif ($macro eq 'AM_GNU_GETTEXT')
4502 $seen_gettext = $here;
4503 $ac_gettext_location = $here;
4505 elsif ($macro eq 'AM_INIT_AUTOMAKE')
4507 $package_version = $args[2];
4508 $package_version_location = $here;
4509 $seen_init_automake = 1;
4511 elsif ($macro eq 'AM_MAINTAINER_MODE')
4513 $seen_maint_mode = $here;
4515 elsif ($macro eq 'AM_PATH_LISPDIR')
4517 $am_lispdir_location = $here;
4519 elsif ($macro eq 'AM_PATH_PYTHON')
4521 $pythondir_location = $here;
4523 elsif ($macro eq 'AM_PROG_CC_C_O')
4525 $seen_cc_c_o = $here;
4531 # &scan_one_autoconf_file ($FILENAME)
4532 # -----------------------------------
4533 # Scan one file for interesting things. Subroutine of
4534 # &scan_autoconf_files.
4535 sub scan_one_autoconf_file
4537 my ($filename) = @_;
4539 # Some macros already provide the right traces to enable generic
4540 # code and specific arguments, instead of dedicated code. But
4541 # currently we don't handle traces. Rewrite these dedicated
4542 # macros handling into the generic macro invocation, and let our
4543 # generic case handle them.
4547 'AC_FUNC_ALLOCA' => 'AC_LIBSOURCES([alloca.c])',
4548 'AC_FUNC_GETLOADAVG' => 'AC_LIBSOURCES([getloadavg.c])',
4549 'AC_FUNC_MEMCMP' => 'AC_LIBSOURCES([memcmp.c])',
4550 'AC_STRUCT_ST_BLOCKS' => 'AC_LIBSOURCES([fileblocks.c])',
4551 'A[CM]_REPLACE_GNU_GETOPT' => 'AC_LIBSOURCES([getopt.c, getopt1.c])',
4552 'A[CM]_FUNC_STRTOD' => 'AC_LIBSOURCES([strtod.c])',
4553 'AM_WITH_REGEX' => 'AC_LIBSOURCES([rx.c, rx.h, regex.c, regex.h])',
4554 'AC_FUNC_MKTIME' => 'AC_LIBSOURCES([mktime.c])',
4555 'A[CM]_FUNC_ERROR_AT_LINE' => 'AC_LIBSOURCES([error.c, error.h])',
4556 'A[CM]_FUNC_OBSTACK' => 'AC_LIBSOURCES([obstack.c, obstack.h])',
4559 my $configfh = new Automake::XFile ("< $filename");
4560 verbose "reading $filename";
4562 my ($in_ac_output, $in_ac_replace) = (0, 0);
4563 while ($_ = $configfh->getline)
4565 # Remove comments from current line.
4569 # Skip macro definitions. Otherwise we might be confused into
4570 # thinking that a macro that was only defined was actually
4574 # Follow includes. This is a weirdness commonly in use at
4575 # Cygnus and hopefully nowhere else.
4576 if (/sinclude\((.*)\)/ && -f $1)
4578 # $_ being local, if we don't preserve it, when coming
4579 # back we will have $_ undefined, which is bad for the
4580 # the rest of this routine.
4581 my $underscore = $_;
4582 &scan_one_autoconf_file ($1);
4586 for my $generalize (keys %generalize)
4588 s/\b$generalize\b/$generalize{$generalize}/g;
4592 my $here = "$filename:$.";
4594 # Populate libobjs array.
4595 if (/LIBOBJS="(.*)\s+\$LIBOBJS"/
4596 || /LIBOBJS="\$LIBOBJS\s+(.*)"/)
4598 foreach my $libobj_iter (split (' ', $1))
4600 if ($libobj_iter =~ /^(.*)\.o(bj)?$/
4601 || $libobj_iter =~ /^(.*)\.\$ac_objext$/
4602 || $libobj_iter =~ /^(.*)\.\$\{ac_objext\}$/)
4604 $libsources{$1 . '.c'} = $here;
4608 elsif (/AC_LIBOBJ\(([^)]+)\)/)
4610 $libsources{"$1.c"} = $here;
4612 elsif (/AC_LIBSOURCE\(([^)]+)\)/)
4614 $libsources{&unquote_m4_arg ($1)} = $here;
4616 elsif (/AC_LIBSOURCES\(([^)]+)\)/)
4618 foreach my $lc_iter (split (/[, ]+/, &unquote_m4_arg ($1)))
4620 $libsources{$lc_iter} = $here;
4624 if (! $in_ac_replace && s/AC_REPLACE_FUNCS\s*\(\[?//)
4630 $in_ac_replace = 0 if s/[\]\)].*$//;
4631 # Remove trailing backslash.
4635 # Need to skip empty elements for Perl 4.
4637 $libsources{$_ . '.c'} = $here;
4641 if (/$obsolete_rx/o)
4644 if ($obsolete_macros{$1} ne '')
4646 $hint = '; ' . $obsolete_macros{$1};
4648 file_error ($here, "`$1' is obsolete$hint");
4651 # Process the AC_OUTPUT and AC_CONFIG_FILES macros.
4652 if (! $in_ac_output && s/(AC_(OUTPUT|CONFIG_FILES))\s*\(\[?//)
4655 $ac_config_files_location = $here;
4666 # Look at potential Makefile.am's.
4667 &scan_autoconf_config_files ($_);
4670 && scalar keys %make_list == 0
4671 && @other_input_files == 0)
4673 file_error ($ac_config_files_location,
4674 "no files mentioned in `$in_ac_output'");
4679 if (/$AC_CONFIG_AUX_DIR_PATTERN/o)
4681 @config_aux_path = &unquote_m4_arg ($1);
4682 $config_aux_dir_set_in_configure_in = $here;
4685 # Check for ansi2knr.
4686 $am_c_prototypes = $here if /AM_C_PROTOTYPES/;
4688 # Check for `-c -o' code.
4689 $seen_cc_c_o = $here if /AM_PROG_CC_C_O/;
4691 # Check for NLS support.
4692 if (/AM_GNU_GETTEXT/)
4694 $seen_gettext = $here;
4695 $ac_gettext_location = $here;
4698 # Handle configuration headers. A config header of `[$1]'
4699 # means we are actually scanning AM_CONFIG_HEADER from
4700 # aclocal.m4. Same thing with a leading underscore.
4701 if (/(?<!_)A([CM])_CONFIG_HEADERS?\s*\((.*)\)/
4705 "`automake requires `AM_CONFIG_HEADER', not `AC_CONFIG_HEADER'")
4708 $config_header_location = $here;
4709 push @config_headers, split (' ', unquote_m4_arg ($2));
4712 # Handle AC_CANONICAL_*. Always allow upgrading to
4713 # AC_CANONICAL_SYSTEM, but never downgrading.
4714 if (/AC_CANONICAL_HOST/ || /AC_CHECK_TOOL/)
4716 if (! $seen_canonical)
4718 $seen_canonical = AC_CANONICAL_HOST;
4719 $canonical_location = $here;
4722 if (/AC_CANONICAL_SYSTEM/)
4724 $seen_canonical = AC_CANONICAL_SYSTEM;
4725 $canonical_location = $here;
4728 # If using X, include some extra variable definitions. NOTE
4729 # we don't want to force these into CFLAGS or anything,
4730 # because not all programs will necessarily use X.
4733 foreach my $var qw(X_CFLAGS X_LIBS X_EXTRA_LIBS X_PRE_LIBS)
4735 $configure_vars{$var} = $here;
4739 # This macro handles several different things.
4740 if (/$AM_INIT_AUTOMAKE_PATTERN/o)
4742 ($package_version = $1) =~ s/$AM_PACKAGE_VERSION_PATTERN/$1/o;
4743 $package_version_location = $here;
4744 $seen_init_automake = $here;
4749 $configure_vars{'LEX'} = $here;
4750 $seen_prog_lex = $here;
4752 if (/AC_PROG_LEX/ && $filename =~ /configure\.(ac|in)$/)
4754 $configure_vars{'LEX'} = $here;
4755 $seen_prog_lex = $here;
4756 file_warning ($here,
4757 "automake requires `AM_PROG_LEX', not `AC_PROG_LEX'");
4760 if (/AC_PROG_(F77|YACC|RANLIB|CC|CXXCPP|CXX|LEX|AWK|CPP|LN_S)/)
4762 $configure_vars{$1} = $here;
4764 if (/$AC_CHECK_PATTERN/o)
4766 $configure_vars{$3} = $here;
4768 if (/$AM_MISSING_PATTERN/o
4772 && $1 ne 'AUTOHEADER'
4773 # AM_INIT_AUTOMAKE is AM_MISSING_PROG'ing MAKEINFO. But
4774 # we handle it elsewhere.
4775 && $1 ne 'MAKEINFO')
4777 $configure_vars{$1} = $here;
4780 # Explicitly avoid ANSI2KNR -- we AC_SUBST that in protos.m4,
4781 # but later define it elsewhere. This is pretty hacky. We
4782 # also explicitly avoid INSTALL_SCRIPT and some other
4783 # variables because they are defined in header-vars.am.
4784 # AMDEPBACKSLASH might be subst'd by `\', which certainly would
4785 # not be appreciated by Make.
4786 if (/$AC_SUBST_PATTERN/o
4788 && $1 ne 'INSTALL_SCRIPT'
4789 && $1 ne 'INSTALL_DATA'
4790 && $1 ne 'AMDEPBACKSLASH')
4792 $configure_vars{$1} = $here;
4795 if (/AM_MAINTAINER_MODE/)
4797 $seen_maint_mode = $here;
4798 $configure_cond{'MAINTAINER_MODE'} = $here;
4801 $am_lispdir_location = $here if /AM_PATH_LISPDIR/;
4803 if (/AM_PATH_PYTHON/)
4805 $pythondir_location = $here;
4806 $configure_vars{'pythondir'} = $here;
4807 $configure_vars{'PYTHON'} = $here;
4810 if (/A(C|M)_PROG_LIBTOOL/)
4812 # We're not ready for this yet. People still use a
4813 # libtool with no AC_PROG_LIBTOOL. Once that is the
4814 # dominant version we can reenable this code -- but next
4815 # time by mentioning the macro in %obsolete_macros, both
4816 # here and in aclocal.in.
4818 # if (/AM_PROG_LIBTOOL/)
4820 # file_warning ($here, "`AM_PROG_LIBTOOL' is obsolete, use `AC_PROG_LIBTOOL' instead");
4822 $seen_libtool = $here;
4823 $configure_vars{'LIBTOOL'} = $here;
4824 $configure_vars{'RANLIB'} = $here;
4825 $configure_vars{'CC'} = $here;
4826 # AC_PROG_LIBTOOL runs AC_CANONICAL_HOST. Make sure we
4827 # never downgrade (if we've seen AC_CANONICAL_SYSTEM).
4828 $seen_canonical = AC_CANONICAL_HOST if ! $seen_canonical;
4831 $seen_multilib = $here if (/AM_ENABLE_MULTILIB/);
4833 if (/$AM_CONDITIONAL_PATTERN/o)
4835 $configure_cond{$1} = $here;
4838 # Check for Fortran 77 intrinsic and run-time libraries.
4839 if (/AC_F77_LIBRARY_LDFLAGS/)
4841 $configure_vars{'FLIBS'} = $here;
4847 # &scan_autoconf_files ()
4848 # -----------------------
4849 # Check whether we use `configure.ac' or `configure.in'.
4850 # Scan it (and possibly `aclocal.m4') for interesting things.
4851 # We must scan aclocal.m4 because there might be AC_SUBSTs and such there.
4852 sub scan_autoconf_files
4854 # Reinitialize libsources here. This isn't really necessary,
4855 # since we currently assume there is only one configure.ac. But
4856 # that won't always be the case.
4859 $configure_ac = find_configure_ac;
4860 die "$me: `configure.ac' or `configure.in' is required\n"
4863 if (defined $ENV{'amtraces'})
4865 print STDERR "$me: Autoconf traces is an experimental feature\n";
4866 print STDERR "$me: use at your own risks\n";
4868 scan_autoconf_traces ($configure_ac);
4872 scan_one_autoconf_file ($configure_ac);
4873 scan_one_autoconf_file ('aclocal.m4')
4877 # Set input and output files if not specified by user.
4880 @input_files = sort keys %make_list;
4881 %output_files = %make_list;
4884 @configure_input_files = sort keys %make_list;
4886 conf_error ("`AM_INIT_AUTOMAKE' must be used")
4887 if ! $seen_init_automake;
4889 # Look for some files we need. Always check for these. This
4890 # check must be done for every run, even those where we are only
4891 # looking at a subdir Makefile. We must set relative_dir so that
4892 # the file-finding machinery works.
4893 # FIXME: Is this broken because it needs dynamic scopes.
4894 # My tests seems to show it's not the case.
4895 $relative_dir = '.';
4896 require_conf_file ($configure_ac, FOREIGN,
4897 'install-sh', 'mkinstalldirs', 'missing');
4898 am_error ("`install.sh' is an anachronism; use `install-sh' instead")
4899 if -f $config_aux_path[0] . '/install.sh';
4901 require_conf_file ($pythondir_location, FOREIGN, 'py-compile')
4902 if $pythondir_location;
4904 # Preserve dist_common for later.
4905 $configure_dist_common = variable_value ('DIST_COMMON', 'TRUE') || '';
4908 ################################################################
4910 # Set up for Cygnus mode.
4913 return unless $cygnus_mode;
4915 &set_strictness ('foreign');
4916 $options{'no-installinfo'} = 1;
4917 $options{'no-dependencies'} = 1;
4918 $use_dependencies = 0;
4920 conf_error ("`AM_MAINTAINER_MODE' required when --cygnus specified")
4921 if !$seen_maint_mode;
4924 # Do any extra checking for GNU standards.
4925 sub check_gnu_standards
4927 if ($relative_dir eq '.')
4929 # In top level (or only) directory.
4930 require_file ('', GNU,
4931 qw(INSTALL NEWS README COPYING AUTHORS ChangeLog));
4934 if ($strictness >= GNU
4935 && defined $options{'no-installman'})
4937 macro_error ('AUTOMAKE_OPTIONS',
4938 "option `no-installman' disallowed by GNU standards");
4941 if ($strictness >= GNU
4942 && defined $options{'no-installinfo'})
4944 macro_error ('AUTOMAKE_OPTIONS',
4945 "option `no-installinfo' disallowed by GNU standards");
4949 # Do any extra checking for GNITS standards.
4950 sub check_gnits_standards
4952 if ($relative_dir eq '.')
4954 # In top level (or only) directory.
4955 require_file ('', GNITS, 'THANKS');
4959 ################################################################
4961 # Functions to handle files of each language.
4963 # Each `lang_X_rewrite($DIRECTORY, $BASE, $EXT)' function follows a
4964 # simple formula: Return value is $LANG_SUBDIR if the resulting object
4965 # file should be in a subdir if the source file is, $LANG_PROCESS if
4966 # file is to be dealt with, $LANG_IGNORE otherwise.
4968 # Much of the actual processing is handled in
4969 # handle_single_transform_list. These functions exist so that
4970 # auxiliary information can be recorded for a later cleanup pass.
4971 # Note that the calls to these functions are computed, so don't bother
4972 # searching for their precise names in the source.
4974 # This is just a convenience function that can be used to determine
4975 # when a subdir object should be used.
4978 return defined $options{'subdir-objects'} ? $LANG_SUBDIR : $LANG_PROCESS;
4981 # Rewrite a single C source file.
4984 my ($directory, $base, $ext) = @_;
4986 if (defined $options{'ansi2knr'} && $base =~ /_$/)
4988 # FIXME: include line number in error.
4989 am_error ("C source file `$base.c' would be deleted by ansi2knr rules");
4992 my $r = $LANG_PROCESS;
4993 if (defined $options{'subdir-objects'})
4996 $base = $directory . '/' . $base;
5000 # Only give error once.
5002 # FIXME: line number.
5003 am_error ("C objects in subdir but `AM_PROG_CC_C_O' not in `$configure_ac'");
5006 require_conf_file ("$am_file.am", FOREIGN, 'compile');
5009 $de_ansi_files{$base} = 1;
5013 # Rewrite a single C++ source file.
5014 sub lang_cxx_rewrite
5016 return &lang_sub_obj;
5019 # Rewrite a single header file.
5020 sub lang_header_rewrite
5022 # Header files are simply ignored.
5023 return $LANG_IGNORE;
5026 # Rewrite a single yacc file.
5027 sub lang_yacc_rewrite
5029 my ($directory, $base, $ext) = @_;
5031 my $r = &lang_sub_obj;
5032 (my $newext = $ext) =~ tr/y/c/;
5033 return ($r, $newext);
5036 # Rewrite a single yacc++ file.
5037 sub lang_yaccxx_rewrite
5039 my ($directory, $base, $ext) = @_;
5041 my $r = &lang_sub_obj;
5042 (my $newext = $ext) =~ tr/y/c/;
5043 return ($r, $newext);
5046 # Rewrite a single lex file.
5047 sub lang_lex_rewrite
5049 my ($directory, $base, $ext) = @_;
5051 my $r = &lang_sub_obj;
5052 (my $newext = $ext) =~ tr/l/c/;
5053 return ($r, $newext);
5056 # Rewrite a single lex++ file.
5057 sub lang_lexxx_rewrite
5059 my ($directory, $base, $ext) = @_;
5061 my $r = &lang_sub_obj;
5062 (my $newext = $ext) =~ tr/l/c/;
5063 return ($r, $newext);
5066 # Rewrite a single assembly file.
5067 sub lang_asm_rewrite
5069 return &lang_sub_obj;
5072 # Rewrite a single Fortran 77 file.
5073 sub lang_f77_rewrite
5075 return $LANG_PROCESS;
5078 # Rewrite a single preprocessed Fortran 77 file.
5079 sub lang_ppf77_rewrite
5081 return $LANG_PROCESS;
5084 # Rewrite a single ratfor file.
5085 sub lang_ratfor_rewrite
5087 return $LANG_PROCESS;
5090 # Rewrite a single Objective C file.
5091 sub lang_objc_rewrite
5093 return &lang_sub_obj;
5096 # Rewrite a single Java file.
5097 sub lang_java_rewrite
5099 return $LANG_SUBDIR;
5102 # The lang_X_finish functions are called after all source file
5103 # processing is done. Each should handle defining rules for the
5104 # language, etc. A finish function is only called if a source file of
5105 # the appropriate type has been seen.
5109 # Push all libobjs files onto de_ansi_files. We actually only
5110 # push files which exist in the current directory, and which are
5111 # genuine source files.
5112 foreach my $file (keys %libsources)
5114 if ($file =~ /^(.*)\.[cly]$/ && -f "$relative_dir/$file")
5116 $de_ansi_files{$1} = 1;
5120 if (defined $options{'ansi2knr'} && keys %de_ansi_files)
5122 # Make all _.c files depend on their corresponding .c files.
5124 foreach my $base (sort keys %de_ansi_files)
5126 # Each _.c file must depend on ansi2knr; otherwise it
5127 # might be used in a parallel build before it is built.
5128 # We need to support files in the srcdir and in the build
5129 # dir (because these files might be auto-generated. But
5130 # we can't use $< -- some makes only define $< during a
5132 $output_rules .= ($base . "_.c: $base.c \$(ANSI2KNR)\n\t"
5133 . '$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) '
5134 . '`if test -f $(srcdir)/' . $base . '.c'
5135 . '; then echo $(srcdir)/' . $base . '.c'
5136 . '; else echo ' . $base . '.c; fi` '
5137 . "| sed 's/^# \\([0-9]\\)/#line \\1/' "
5138 . '| $(ANSI2KNR) > ' . $base . "_.c"
5139 # If ansi2knr fails then we shouldn't
5140 # create the _.c file
5141 . " || rm -f ${base}_.c\n");
5142 push (@objects, $base . '_.$(OBJEXT)');
5143 push (@objects, $base . '_.lo')
5147 # Make all _.o (and _.lo) files depend on ansi2knr.
5148 # Use a sneaky little hack to make it print nicely.
5149 &pretty_print_rule ('', '', @objects, ':', '$(ANSI2KNR)');
5153 # This is a yacc helper which is called whenever we have decided to
5154 # compile a yacc file.
5155 sub lang_yacc_target_hook
5157 my ($self, $aggregate, $output, $input) = @_;
5159 my $flag = $aggregate . "_YFLAGS";
5160 if ((variable_defined ($flag)
5161 && &variable_value ($flag) =~ /$DASH_D_PATTERN/o)
5162 || (variable_defined ('YFLAGS')
5163 && &variable_value ('YFLAGS') =~ /$DASH_D_PATTERN/o))
5165 (my $output_base = $output) =~ s/$KNOWN_EXTENSIONS_PATTERN$//;
5166 my $header = $output_base . '.h';
5168 # Found a `-d' that applies to the compilation of this file.
5169 # Add a dependency for the generated header file, and arrange
5170 # for that file to be included in the distribution.
5171 # FIXME: this fails for `nodist_*_SOURCES'.
5172 $output_rules .= "${header}: $output\n";
5173 &push_dist_common ($header);
5174 # If the files are built in the build directory, then we want
5175 # to remove them with `make clean'. If they are in srcdir
5176 # they shouldn't be touched. However, we can't determine this
5177 # statically, and the GNU rules say that yacc/lex output files
5178 # should be removed by maintainer-clean. So that's what we
5180 push (@maintainer_clean_files, $header);
5184 # This is a helper for both lex and yacc.
5185 sub yacc_lex_finish_helper
5187 return if defined $language_scratch{'lex-yacc-done'};
5188 $language_scratch{'lex-yacc-done'} = 1;
5190 # If there is more than one distinct yacc (resp lex) source file
5191 # in a given directory, then the `ylwrap' program is required to
5192 # allow parallel builds to work correctly. FIXME: for now, no
5194 require_conf_file ($configure_ac, FOREIGN, 'ylwrap');
5195 if ($config_aux_dir_set_in_configure_in)
5197 &define_variable ('YLWRAP', $config_aux_dir . "/ylwrap");
5201 &define_variable ('YLWRAP', '$(top_srcdir)/ylwrap');
5205 sub lang_yacc_finish
5207 return if defined $language_scratch{'yacc-done'};
5208 $language_scratch{'yacc-done'} = 1;
5210 macro_error ('YACCFLAGS',
5211 "`YACCFLAGS' obsolete; use `YFLAGS' instead")
5212 if variable_defined ('YACCFLAGS');
5214 if (count_files_for_language ('yacc') > 1)
5216 &yacc_lex_finish_helper;
5223 return if defined $language_scratch{'lex-done'};
5224 $language_scratch{'lex-done'} = 1;
5226 am_error ("lex source seen but `AM_PROG_LEX' not in `$configure_ac'")
5227 unless $seen_prog_lex;
5229 if (count_files_for_language ('lex') > 1)
5231 &yacc_lex_finish_helper;
5236 # Given a hash table of linker names, pick the name that has the most
5237 # precedence. This is lame, but something has to have global
5238 # knowledge in order to eliminate the conflict. Add more linkers as
5244 foreach my $l (qw(GCJLINK CXXLINK F77LINK OBJCLINK))
5246 return $l if defined $linkers{$l};
5251 # Called to indicate that an extension was used.
5255 if (! defined $extension_seen{$ext})
5257 $extension_seen{$ext} = 1;
5261 ++$extension_seen{$ext};
5265 # Return the number of files seen for a given language. Knows about
5266 # special cases we care about. FIXME: this is hideous. We need
5267 # something that involves real language objects. For instance yacc
5268 # and yaccxx could both derive from a common yacc class which would
5269 # know about the strange ylwrap requirement. (Or better yet we could
5270 # just not support legacy yacc!)
5271 sub count_files_for_language
5276 if ($name eq 'yacc' || $name eq 'yaccxx')
5278 @names = ('yacc', 'yaccxx');
5280 elsif ($name eq 'lex' || $name eq 'lexxx')
5282 @names = ('lex', 'lexxx');
5290 foreach $name (@names)
5292 my $lang = $languages{$name};
5293 foreach my $ext (@{$lang->extensions})
5295 $r += $extension_seen{$ext}
5296 if defined $extension_seen{$ext};
5303 # Called to ask whether source files have been seen . If HEADERS is 1,
5304 # headers can be included.
5309 # count all the sources
5311 foreach my $val (values %extension_seen)
5318 $count -= count_files_for_language ('header');
5325 # register_language (%ATTRIBUTE)
5326 # ------------------------------
5327 # Register a single language.
5328 # Each %ATTRIBUTE is of the form ATTRIBUTE => VALUE.
5329 sub register_language (%)
5335 unless defined $option{'ansi'};
5336 $option{'autodep'} = 'no'
5337 unless defined $option{'autodep'};
5338 $option{'linker'} = ''
5339 unless defined $option{'linker'};
5340 $option{'define_flag'} = 1
5341 unless defined $option{'define_flag'};
5343 my $lang = new Language (%option);
5346 grep ($extension_map{$_} = $lang->name, @{$lang->extensions});
5347 $languages{$lang->name} = $lang;
5349 # Update the pattern of known extensions.
5350 accept_extensions (@{$lang->extensions});
5353 # derive_suffix ($EXT, $OBJ)
5354 # --------------------------
5355 # This function is used to find a path from a user-specified suffix $EXT
5356 # to $OBJ or to some other suffix we recognize internally, eg `cc'.
5357 sub derive_suffix ($$)
5359 my ($source_ext, $obj) = @_;
5361 while (! $extension_map{$source_ext}
5362 && $source_ext ne $obj
5363 && defined $suffix_rules{$source_ext})
5365 $source_ext = $suffix_rules{$source_ext};
5372 ################################################################
5374 # Pretty-print something. HEAD is what should be printed at the
5375 # beginning of the first line, FILL is what should be printed at the
5376 # beginning of every subsequent line.
5377 sub pretty_print_internal
5379 my ($head, $fill, @values) = @_;
5381 my $column = length ($head);
5384 # Fill length is number of characters. However, each Tab
5385 # character counts for eight. So we count the number of Tabs and
5387 my $fill_length = length ($fill);
5388 $fill_length += 7 * ($fill =~ tr/\t/\t/d);
5392 # "71" because we also print a space.
5393 if ($column + length ($_) > 71)
5395 $result .= " \\\n" . $fill;
5396 $column = $fill_length;
5398 $result .= ' ' if $result =~ /\S\z/;
5400 $column += length ($_) + 1;
5407 # Pretty-print something and append to output_vars.
5410 $output_vars .= &pretty_print_internal (@_);
5413 # Pretty-print something and append to output_rules.
5414 sub pretty_print_rule
5416 $output_rules .= &pretty_print_internal (@_);
5420 ################################################################
5424 # &conditional_string(@COND-STACK)
5425 # --------------------------------
5426 # Build a string which denotes the conditional in @COND-STACK. Some
5427 # simplifications are done: `TRUE' entries are elided, and any `FALSE'
5428 # entry results in a return of `FALSE'.
5429 sub conditional_string
5433 if (grep (/^FALSE$/, @stack))
5439 return join (' ', uniq sort grep (!/^TRUE$/, @stack));
5445 # &conditional_true_when ($COND, $WHEN)
5446 # -------------------------------------
5447 # See if a conditional is true. Both arguments are conditional
5448 # strings. This returns true if the first conditional is true when
5449 # the second conditional is true.
5450 # For instance with $COND = `BAR FOO', and $WHEN = `BAR BAZ FOO',
5451 # obviously return 1, and 0 when, for instance, $WHEN = `FOO'.
5452 sub conditional_true_when ($$)
5454 my ($cond, $when) = @_;
5456 # Make a hash holding all the values from $WHEN.
5457 my %cond_vals = map { $_ => 1 } split (' ', $when);
5459 # Check each component of $cond, which looks `COND1 COND2'.
5460 foreach my $comp (split (' ', $cond))
5462 # TRUE is always true.
5463 next if $comp eq 'TRUE';
5464 return 0 if ! defined $cond_vals{$comp};
5472 # &conditional_is_redundant ($COND, @WHENS)
5473 # ----------------------------------------
5474 # Determine whether $COND is redundant with respect to @WHENS.
5476 # Returns true if $COND is true for any of the conditions in @WHENS.
5478 # If there are no @WHENS, then behave as if @WHENS contained a single empty
5480 sub conditional_is_redundant ($@)
5482 my ($cond, @whens) = @_;
5486 return 1 if conditional_true_when ($cond, "");
5490 foreach my $when (@whens)
5492 return 1 if conditional_true_when ($cond, $when);
5501 # condition_negate ($COND)
5502 # ------------------------
5503 sub condition_negate ($)
5507 $cond =~ s/TRUE$/TRUEO/;
5508 $cond =~ s/FALSE$/TRUE/;
5509 $cond =~ s/TRUEO$/FALSE/;
5515 # Compare condition names.
5516 # Issue them in alphabetical order, foo_TRUE before foo_FALSE.
5519 # Be careful we might be comparing `' or `#'.
5520 $a =~ /^(.*)_(TRUE|FALSE)$/;
5521 my ($aname, $abool) = ($1 || '', $2 || '');
5522 $b =~ /^(.*)_(TRUE|FALSE)$/;
5523 my ($bname, $bbool) = ($1 || '', $2 || '');
5524 return ($aname cmp $bname
5525 # Don't bother with IFs, given that TRUE is after FALSE
5526 # just cmp in the reverse order.
5527 || $bbool cmp $abool
5533 # &make_condition (@CONDITIONS)
5534 # -----------------------------
5535 # Transform a list of conditions (themselves can be an internal list
5536 # of conditions, e.g., @CONDITIONS = ('cond1 cond2', 'cond3')) into a
5537 # Make conditional (a pattern for AC_SUBST).
5538 # Correctly returns the empty string when there are no conditions.
5541 my $res = conditional_string (@_);
5543 # There are no conditions.
5549 elsif ($res eq 'FALSE')
5556 $res = '@' . $res . '@';
5565 ## ------------------------------ ##
5566 ## Handling the condition stack. ##
5567 ## ------------------------------ ##
5571 # cond_stack_if ($NEGATE, $COND, $WHERE)
5572 # --------------------------------------
5573 sub cond_stack_if ($$$)
5575 my ($negate, $cond, $where) = @_;
5577 file_error ($where, "$cond does not appear in AM_CONDITIONAL")
5578 if ! $configure_cond{$cond} && $cond !~ /^TRUE|FALSE$/;
5580 $cond = "${cond}_TRUE"
5581 unless $cond =~ /^TRUE|FALSE$/;
5582 $cond = condition_negate ($cond)
5585 push (@cond_stack, $cond);
5587 return conditional_string (@cond_stack);
5592 # cond_stack_else ($NEGATE, $COND, $WHERE)
5593 # ----------------------------------------
5594 sub cond_stack_else ($$$)
5596 my ($negate, $cond, $where) = @_;
5600 file_error ($where, "else without if");
5604 $cond_stack[$#cond_stack] = condition_negate ($cond_stack[$#cond_stack]);
5606 # If $COND is given, check against it.
5609 $cond = "${cond}_TRUE"
5610 unless $cond =~ /^TRUE|FALSE$/;
5611 $cond = condition_negate ($cond)
5615 "else reminder ($negate$cond) incompatible with "
5616 . "current conditional: $cond_stack[$#cond_stack]")
5617 if $cond_stack[$#cond_stack] ne $cond;
5620 return conditional_string (@cond_stack);
5625 # cond_stack_endif ($NEGATE, $COND, $WHERE)
5626 # -----------------------------------------
5627 sub cond_stack_endif ($$$)
5629 my ($negate, $cond, $where) = @_;
5634 file_error ($where, "endif without if: $negate$cond");
5639 # If $COND is given, check against it.
5642 $cond = "${cond}_TRUE"
5643 unless $cond =~ /^TRUE|FALSE$/;
5644 $cond = condition_negate ($cond)
5648 "endif reminder ($negate$cond) incompatible with "
5649 . "current conditional: $cond_stack[$#cond_stack]")
5650 if $cond_stack[$#cond_stack] ne $cond;
5655 return conditional_string (@cond_stack);
5662 ## ------------------------ ##
5663 ## Handling the variables. ##
5664 ## ------------------------ ##
5667 # check_ambiguous_conditional ($VAR, $COND)
5668 # -----------------------------------------
5669 # Check for an ambiguous conditional. This is called when a variable
5670 # is being defined conditionally. If we already know about a
5671 # definition that is true under the same conditions, then we have an
5673 sub check_ambiguous_conditional ($$)
5675 my ($var, $cond) = @_;
5676 foreach my $vcond (keys %{$var_value{$var}})
5679 if ($vcond eq $cond)
5681 $message = "$var multiply defined in condition $cond";
5683 elsif (&conditional_true_when ($vcond, $cond))
5685 $message = ("$var was already defined in condition $vcond, "
5686 . "which implies condition $cond");
5688 elsif (&conditional_true_when ($cond, $vcond))
5690 $message = ("$var was already defined in condition $vcond, "
5691 . "which is implied by condition $cond");
5695 macro_error ($var, $message);
5702 # ¯o_define($VAR, $VAR_IS_AM, $TYPE, $COND, $VALUE, $WHERE)
5703 # -------------------------------------------------------------
5704 # The $VAR can go from Automake to user, but not the converse.
5705 sub macro_define ($$$$$$)
5707 my ($var, $var_is_am, $type, $cond, $value, $where) = @_;
5709 file_error ($where, "bad macro name `$var'")
5710 if $var !~ /$MACRO_PATTERN/o;
5714 # An Automake variable must be consistently defined with the same
5715 # sign by Automake. A user variable must be set by either `=' or
5716 # `:=', and later promoted to `+='.
5719 if (defined $var_type{$var} && $var_type{$var} ne $type)
5722 ("$var was set with `$var_type{$var}=' "
5723 . "and is now set with `$type='"));
5728 if (!defined $var_type{$var} && $type eq '+')
5730 macro_error ($var, "$var must be set with `=' before using `+='");
5733 $var_type{$var} = $type;
5735 # When adding, since we rewrite, don't try to preserve the
5736 # Automake continuation backslashes.
5738 if $type eq '+' && $var_is_am;
5740 # Differentiate the first assignment (including with `+=').
5741 if ($type eq '+' && defined $var_value{$var}{$cond})
5743 if (substr ($var_value{$var}{$cond}, -1) eq "\n")
5745 # Insert a backslash before a trailing newline.
5746 $var_value{$var}{$cond} =
5747 substr ($var_value{$var}{$cond}, 0, -1) . "\\\n";
5749 elsif ($var_value{$var}{$cond})
5751 # Insert a separator.
5752 $var_value{$var}{$cond} .= ' ';
5754 $var_value{$var}{$cond} .= $value;
5758 # The first assignment to a macro sets its location. Ideally I
5759 # suppose we would associate line numbers with random bits of text.
5760 # FIXME: We sometimes redefine some variables, but we want to keep
5761 # the original location. More subs are needed to handle
5762 # properly variables. Once this done, remove this hack.
5763 $var_location{$var} = $where
5764 unless defined $var_location{$var};
5766 # If Automake tries to override a value specified by the user,
5767 # just don't let it do.
5768 if (defined $var_value{$var}{$cond} && !$var_is_am{$var} && $var_is_am)
5772 print STDERR "$me: refusing to override the user definition of:\n";
5774 print STDERR "$me: with `$cond' => `$value'\n";
5779 # There must be no previous value unless the user is redefining
5780 # an Automake variable or an AC_SUBST variable.
5781 check_ambiguous_conditional ($var, $cond)
5782 unless ($var_is_am{$var} && !$var_is_am
5783 || exists $configure_vars{$var});
5785 $var_value{$var}{$cond} = $value;
5789 # An Automake variable can be given to the user, but not the converse.
5790 if (! defined $var_is_am{$var} || !$var_is_am)
5792 $var_is_am{$var} = $var_is_am;
5795 # Call var_VAR_trigger if it's defined.
5796 # This hook helps to update some internal state *while*
5797 # parsing the file. For instance the handling of SUFFIXES
5798 # requires this (see var_SUFFIXES_trigger).
5799 my $var_trigger = "var_${var}_trigger";
5800 &$var_trigger($type, $value) if defined &$var_trigger;
5804 # ¯o_delete ($VAR, [@CONDS])
5805 # ------------------------------
5806 # Forget about $VAR under the conditions @CONDS, or completely if
5808 sub macro_delete ($@)
5810 my ($var, @conds) = @_;
5814 delete $var_value{$var};
5815 delete $var_location{$var};
5816 delete $var_is_am{$var};
5817 delete $var_comment{$var};
5818 delete $var_type{$var};
5822 foreach my $cond (@conds)
5824 delete $var_value{$var}{$cond};
5830 # ¯o_dump ($VAR)
5831 # ------------------
5836 if (!exists $var_value{$var})
5838 print STDERR " $var does not exist\n";
5842 my $var_is_am = $var_is_am{$var} ? "Automake" : "User";
5843 my $where = (defined $var_location{$var}
5844 ? $var_location{$var} : "undefined");
5845 print STDERR "$var_comment{$var}"
5846 if defined $var_comment{$var};
5847 print STDERR " $var ($var_is_am, where = $where) $var_type{$var}=\n";
5848 print STDERR " {\n";
5849 foreach my $vcond (sort by_condition keys %{$var_value{$var}})
5851 print STDERR " $vcond => $var_value{$var}{$vcond}\n";
5853 print STDERR " }\n";
5864 print STDERR "%var_value =\n";
5866 foreach my $var (sort (keys %var_value))
5875 # variable_defined ($VAR, [$COND])
5876 # ---------------------------------
5877 # See if a variable exists. $VAR is the variable name, and $COND is
5878 # the condition which we should check. If no condition is given, we
5879 # currently return true if the variable is defined under any
5881 sub variable_defined ($;$)
5883 my ($var, $cond) = @_;
5885 # Unfortunately we can't just check for $var_value{VAR}{COND}
5886 # as this would make perl create $condition{VAR}, which we
5888 if (!exists $var_value{$var})
5890 macro_error ($var, "`$var' is a target; expected a variable")
5891 if defined $targets{$var};
5892 # The variable is not defined
5896 # The variable is not defined for the given condition.
5898 if $cond && !exists $var_value{$var}{$cond};
5900 # Even a var_value examination is good enough for us. FIXME:
5901 # really should maintain examined status on a per-condition basis.
5902 $content_seen{$var} = 1;
5908 # variable_assert ($VAR, $WHERE)
5909 # ------------------------------
5910 # Make sure a variable exists. $VAR is the variable name, and $WHERE
5911 # is the name of a macro which refers to $VAR.
5912 sub variable_assert ($$)
5914 my ($var, $where) = @_;
5917 if variable_defined $var;
5919 macro_error ($where, "variable `$var' not defined");
5925 # Mark a variable as examined.
5926 sub examine_variable
5929 variable_defined ($var);
5933 # &variable_conditions_recursive ($VAR)
5934 # -------------------------------------
5935 # Return the set of conditions for which a variable is defined.
5937 # If the variable is not defined conditionally, and is not defined in
5938 # terms of any variables which are defined conditionally, then this
5939 # returns the empty list.
5941 # If the variable is defined conditionally, but is not defined in
5942 # terms of any variables which are defined conditionally, then this
5943 # returns the list of conditions for which the variable is defined.
5945 # If the variable is defined in terms of any variables which are
5946 # defined conditionally, then this returns a full set of permutations
5947 # of the subvariable conditions. For example, if the variable is
5948 # defined in terms of a variable which is defined for COND_TRUE,
5949 # then this returns both COND_TRUE and COND_FALSE. This is
5950 # because we will need to define the variable under both conditions.
5951 sub variable_conditions_recursive ($)
5957 my @new_conds = variable_conditions_recursive_sub ($var, '');
5958 # Now we want to return all permutations of the subvariable
5961 foreach my $item (@new_conds)
5963 foreach (split (' ', $item))
5965 s/^(.*)_(TRUE|FALSE)$/$1_TRUE/;
5969 @new_conds = variable_conditions_permutations (sort keys %allconds);
5972 foreach my $cond (@new_conds)
5974 my $reduce = variable_conditions_reduce (split (' ', $cond));
5976 if $reduce eq 'FALSE';
5977 $uniqify{$cond} = 1;
5980 # Note we cannot just do `return sort keys %uniqify', because this
5981 # function is sometimes used in a scalar context.
5982 my @uniq_list = sort by_condition keys %uniqify;
5988 # variable_conditions ($VAR)
5989 # --------------------------
5990 # Get the list of conditions that a variable is defined with, without
5991 # recursing through the conditions of any subvariables.
5992 # Argument is $VAR: the variable to get the conditions of.
5993 # Returns the list of conditions.
5994 sub variable_conditions ($)
5997 my @conds = keys %{$var_value{$var}};
5998 return sort by_condition @conds;
6003 # &variable_conditionally_defined ($VAR)
6004 # --------------------------------------
6005 sub variable_conditionally_defined ($)
6008 foreach my $cond (variable_conditions_recursive ($var))
6011 unless $cond =~ /^TRUE|FALSE$/;
6018 # &variable_conditions_recursive_sub ($VAR, $PARENT)
6019 # -------------------------------------------------------
6020 # A subroutine of variable_conditions_recursive. This returns all the
6021 # conditions of $VAR, including those of any sub-variables.
6022 sub variable_conditions_recursive_sub
6024 my ($var, $parent) = @_;
6027 if (defined $vars_scanned{$var})
6029 macro_error ($parent, "variable `$var' recursively defined");
6032 $vars_scanned{$var} = 1;
6034 my @this_conds = ();
6035 # Examine every condition under which $VAR is defined.
6036 foreach my $vcond (keys %{$var_value{$var}})
6038 push (@this_conds, $vcond);
6040 # If $VAR references some other variable, then compute the
6041 # conditions for that subvariable.
6042 my @subvar_conds = ();
6043 foreach (split (' ', $var_value{$var}{$vcond}))
6045 # If a comment seen, just leave.
6048 # Handle variable substitutions.
6049 if (/^\$\{(.*)\}$/ || /^\$\((.*)\)$/)
6052 if ($varname =~ /$SUBST_REF_PATTERN/o)
6058 # Here we compute all the conditions under which the
6059 # subvariable is defined. Then we go through and add
6061 my @svc = variable_conditions_recursive_sub ($varname, $var);
6062 foreach my $item (@svc)
6064 my $val = conditional_string ($vcond, split (' ', $item));
6066 push (@subvar_conds, $val);
6071 # If there are no conditional subvariables, then we want to
6072 # return this condition. Otherwise, we want to return the
6073 # permutations of the subvariables, taking into account the
6074 # conditions of $VAR.
6075 if (! @subvar_conds)
6077 push (@new_conds, $vcond);
6081 push (@new_conds, variable_conditions_reduce (@subvar_conds));
6085 # Unset our entry in vars_scanned. We only care about recursive
6087 delete $vars_scanned{$var};
6089 # If we are being called on behalf of another variable, we need to
6090 # return all possible permutations of the conditions. We have
6091 # already handled everything in @this_conds along with their
6092 # subvariables. We now need to add any permutations that are not
6094 foreach my $this_cond (@this_conds)
6097 variable_conditions_permutations (split (' ', $this_cond));
6098 foreach my $perm (@perms)
6101 foreach my $scan (@this_conds)
6103 if (&conditional_true_when ($perm, $scan)
6104 || &conditional_true_when ($scan, $perm))
6112 # This permutation was not already handled, and is valid
6114 push (@new_conds, $perm);
6122 # Filter a list of conditionals so that only the exclusive ones are
6123 # retained. For example, if both `COND1_TRUE COND2_TRUE' and
6124 # `COND1_TRUE' are in the list, discard the latter.
6125 # If the list is empty, return TRUE
6126 sub variable_conditions_reduce
6133 $cond = shift(@conds);
6135 # FALSE is absorbent.
6137 if $cond eq 'FALSE';
6139 if (!conditional_is_redundant ($cond, @ret, @conds))
6145 return "TRUE" if @ret == 0;
6150 # invert_conditions (@CONDS)
6151 # --------------------------
6152 # Invert a list of conditionals. Returns a set of conditionals which
6153 # are never true for any of the input conditionals, and when taken
6154 # together with the input conditionals cover all possible cases.
6156 # For example: invert_conditions("A_TRUE B_TRUE", "A_FALSE B_FALSE") will
6157 # return ("A_FALSE B_TRUE", "A_TRUE B_FALSE")
6158 sub invert_conditions
6163 foreach my $cond (@conds)
6165 foreach my $perm (variable_conditions_permutations (split(' ', $cond)))
6167 push @notconds, $perm
6168 if ! conditional_is_redundant ($perm, @conds);
6171 return variable_conditions_reduce (@notconds);
6174 # Return a list of permutations of a conditional string.
6175 sub variable_conditions_permutations
6180 my $comp = shift (@comps);
6181 return variable_conditions_permutations (@comps)
6183 my $neg = condition_negate ($comp);
6186 foreach my $sub (variable_conditions_permutations (@comps))
6188 push (@ret, "$comp $sub");
6189 push (@ret, "$neg $sub");
6201 # &check_variable_defined_unconditionally($VAR, $PARENT)
6202 # ------------------------------------------------------
6203 # Warn if a variable is conditionally defined. This is called if we
6204 # are using the value of a variable.
6205 sub check_variable_defined_unconditionally ($$)
6207 my ($var, $parent) = @_;
6208 foreach my $cond (keys %{$var_value{$var}})
6211 if $cond =~ /^TRUE|FALSE$/;
6215 macro_error ($parent,
6216 "warning: automake does not support conditional definition of $var in $parent");
6220 macro_error ($parent,
6221 "warning: automake does not support $var being defined conditionally");
6227 # Get the TRUE value of a variable, warn if the variable is
6228 # conditionally defined.
6232 &check_variable_defined_unconditionally ($var);
6233 return $var_value{$var}{'TRUE'};
6238 # &value_to_list ($VAR, $VAL, $COND)
6239 # ----------------------------------
6240 # Convert a variable value to a list, split as whitespace. This will
6241 # recursively follow $(...) and ${...} inclusions. It preserves @...@
6244 # If COND is 'all', then all values under all conditions should be
6245 # returned; if COND is a particular condition (all conditions are
6246 # surrounded by @...@) then only the value for that condition should
6247 # be returned; otherwise, warn if VAR is conditionally defined.
6248 # SCANNED is a global hash listing whose keys are all the variables
6249 # already scanned; it is an error to rescan a variable.
6250 sub value_to_list ($$$)
6252 my ($var, $val, $cond) = @_;
6256 $val =~ s/\\(\n|$)/ /g;
6258 foreach (split (' ', $val))
6260 # If a comment seen, just leave.
6263 # Handle variable substitutions.
6264 if (/^\$\{([^}]*)\}$/ || /^\$\(([^)]*)\)$/)
6268 # If the user uses a losing variable name, just ignore it.
6269 # This isn't ideal, but people have requested it.
6270 next if ($varname =~ /\@.*\@/);
6274 if ($varname =~ /$SUBST_REF_PATTERN/o)
6278 ($from = $2) =~ s/(\W)/\\$1/g;
6283 variable_value_as_list_recursive_worker ($1, $cond, $var);
6285 # Now rewrite the value if appropriate.
6288 grep (s/$from$/$to/, @temp_list);
6291 push (@result, @temp_list);
6304 # variable_value_as_list ($VAR, $COND, $PARENT)
6305 # ---------------------------------------------
6306 # Get the value of a variable given a specified condition. without
6307 # recursing through any subvariables.
6309 # $VAR is the variable
6310 # $COND is the condition. If this is not given, the value for the
6311 # "TRUE" condition will be returned.
6312 # $PARENT is the variable in which the variable is used: this is used
6313 # only for error messages.
6314 # Returns the list of conditions.
6315 # For example, if A is defined as "foo $(B) bar", and B is defined as
6316 # "baz", this will return ("foo", "$(B)", "bar")
6317 sub variable_value_as_list
6319 my ($var, $cond, $parent) = @_;
6324 unless variable_assert $var, $parent;
6326 # Get value for given condition
6329 foreach my $vcond (keys %{$var_value{$var}})
6331 my $val = $var_value{$var}{$vcond};
6333 if (&conditional_true_when ($vcond, $cond))
6335 # Unless variable is not defined conditionally, there should only
6336 # be one value of $vcond true when $cond.
6337 &check_variable_defined_unconditionally ($var, $parent)
6342 $val =~ s/\\(\n|$)/ /g;
6344 foreach (split (' ', $val))
6346 # If a comment seen, just leave.
6359 # &variable_value_as_list_recursive_worker ($VAR, $COND, $PARENT)
6360 # ---------------------------------------------------------------
6361 # Return contents of VAR as a list, split on whitespace. This will
6362 # recursively follow $(...) and ${...} inclusions. It preserves @...@
6363 # substitutions. If COND is 'all', then all values under all
6364 # conditions should be returned; if COND is a particular condition
6365 # (all conditions are surrounded by @...@) then only the value for
6366 # that condition should be returned; otherwise, warn if VAR is
6367 # conditionally defined. If PARENT is specified, it is the name of
6368 # the including variable; this is only used for error reports.
6369 sub variable_value_as_list_recursive_worker ($$$)
6371 my ($var, $cond, $parent) = @_;
6375 unless variable_assert $var, $parent;
6377 if (defined $vars_scanned{$var})
6379 # `vars_scanned' is a global we use to keep track of which
6380 # variables we've already examined.
6381 macro_error ($parent, "variable `$var' recursively defined");
6383 elsif ($cond eq 'all')
6385 $vars_scanned{$var} = 1;
6386 foreach my $vcond (keys %{$var_value{$var}})
6388 my $val = $var_value{$var}{$vcond};
6389 push (@result, &value_to_list ($var, $val, $cond));
6395 $vars_scanned{$var} = 1;
6397 foreach my $vcond (keys %{$var_value{$var}})
6399 my $val = $var_value{$var}{$vcond};
6400 if (&conditional_true_when ($vcond, $cond))
6402 # Warn if we have an ambiguity. It's hard to know how
6403 # to handle this case correctly.
6404 &check_variable_defined_unconditionally ($var, $parent)
6407 push (@result, &value_to_list ($var, $val, $cond));
6412 # Unset our entry in vars_scanned. We only care about recursive
6414 delete $vars_scanned{$var};
6420 # &variable_output ($VAR, [@CONDS])
6421 # ---------------------------------
6422 # Output all the values of $VAR is @COND is not specified, else only
6423 # that corresponding to @COND.
6424 sub variable_output ($@)
6426 my ($var, @conds) = @_;
6428 @conds = keys %{$var_value{$var}}
6431 $output_vars .= $var_comment{$var}
6432 if defined $var_comment{$var};
6434 foreach my $cond (sort by_condition @conds)
6436 my $val = $var_value{$var}{$cond};
6437 my $equals = $var_type{$var} eq ':' ? ':=' : '=';
6438 my $output_var = "$var $equals $val";
6439 $output_var =~ s/^/make_condition ($cond)/meg;
6440 $output_vars .= $output_var . "\n";
6445 # &variable_pretty_output ($VAR, [@CONDS])
6446 # ----------------------------------------
6447 # Likewise, but pretty, i.e., we *split* the values at spaces. Use only
6448 # with variables holding filenames.
6449 sub variable_pretty_output ($@)
6451 my ($var, @conds) = @_;
6453 @conds = keys %{$var_value{$var}}
6456 $output_vars .= $var_comment{$var}
6457 if defined $var_comment{$var};
6459 foreach my $cond (sort by_condition @conds)
6461 my $val = $var_value{$var}{$cond};
6462 my $equals = $var_type{$var} eq ':' ? ':=' : '=';
6463 my $make_condition = make_condition ($cond);
6464 $output_vars .= pretty_print_internal ("$make_condition$var $equals",
6465 "$make_condition\t",
6466 split (' ' , $val));
6471 # &variable_value_as_list_recursive ($VAR, $COND, $PARENT)
6472 # --------------------------------------------------------
6473 # This is just a wrapper for variable_value_as_list_recursive_worker that
6474 # initializes the global hash `vars_scanned'. This hash is used to
6475 # avoid infinite recursion.
6476 sub variable_value_as_list_recursive ($$@)
6478 my ($var, $cond, $parent) = @_;
6480 return &variable_value_as_list_recursive_worker ($var, $cond, $parent);
6484 # &define_pretty_variable ($VAR, $COND, @VALUE)
6485 # ---------------------------------------------
6486 # Like define_variable, but the value is a list, and the variable may
6487 # be defined conditionally. The second argument is the conditional
6488 # under which the value should be defined; this should be the empty
6489 # string to define the variable unconditionally. The third argument
6490 # is a list holding the values to use for the variable. The value is
6491 # pretty printed in the output file.
6492 sub define_pretty_variable ($$@)
6494 my ($var, $cond, @value) = @_;
6496 # Beware that an empty $cond has a different semantics for
6497 # macro_define and variable_pretty_output.
6500 if (! variable_defined ($var, $cond))
6502 macro_define ($var, 1, '', $cond, "@value", undef);
6503 variable_pretty_output ($var, $cond || 'TRUE');
6504 $content_seen{$var} = 1;
6509 # define_variable ($VAR, $VALUE)
6510 # ------------------------------
6511 # Define a new user variable VAR to VALUE, but only if not already defined.
6512 sub define_variable ($$)
6514 my ($var, $value) = @_;
6515 define_pretty_variable ($var, 'TRUE', $value);
6519 # Like define_variable, but define a variable to be the configure
6520 # substitution by the same name.
6521 sub define_configure_variable ($)
6524 define_variable ($var, subst $var);
6528 # define_compiler_variable ($LANG)
6529 # --------------------------------
6530 # Define a compiler variable. We also handle defining the `LT'
6531 # version of the command when using libtool.
6532 sub define_compiler_variable ($)
6536 my ($var, $value) = ($lang->compiler, $lang->compile);
6537 &define_variable ($var, $value);
6538 &define_variable ("LT$var", "\$(LIBTOOL) --mode=compile $value")
6543 # define_linker_variable ($LANG)
6544 # ------------------------------
6545 # Define linker variables.
6546 sub define_linker_variable ($)
6550 my ($var, $value) = ($lang->lder, $lang->ld);
6552 &define_variable ($lang->lder, $lang->ld);
6553 # CCLINK = $(CCLD) blah blah...
6554 &define_variable ($lang->linker,
6555 (($seen_libtool ? '$(LIBTOOL) --mode=link ' : '')
6559 ################################################################
6561 ## ---------------- ##
6562 ## Handling rules. ##
6563 ## ---------------- ##
6566 # rule_define ($TARGET, $IS_AM, $COND, $WHERE)
6567 # --------------------------------------------
6568 # Define a new rule. $TARGET is the rule name. $IS_AM is a boolean
6569 # which is true if the new rule is defined by the user. $COND is the
6570 # condition under which the rule is defined. $WHERE is where the rule
6571 # is defined (file name or line number). Returns true if it is ok to
6572 # define the rule, false otherwise.
6573 sub rule_define ($$$$)
6575 my ($target, $rule_is_am, $cond, $where) = @_;
6577 # For now `foo:' will override `foo$(EXEEXT):'. This is temporary,
6578 # though, so we emit a warning.
6579 (my $noexe = $target) =~ s,\$\(EXEEXT\)$,,;
6580 if ($noexe ne $target && defined $targets{$noexe})
6582 # The no-exeext option enables this feature.
6583 if (! defined $options{'no-exeext'})
6585 macro_error ($noexe,
6586 "deprecated feature: `$noexe' overrides `$noexe\$(EXEEXT)'\nchange your target to read `$noexe\$(EXEEXT)'");
6592 if (defined $targets{$target}
6594 ? ! defined $target_conditional{$target}
6595 : defined $target_conditional{$target}))
6597 target_error ($target,
6598 "$target defined both conditionally and unconditionally");
6601 # Value here doesn't matter; for targets we only note existence.
6602 $targets{$target} = $where;
6605 if ($target_conditional{$target})
6607 &check_ambiguous_conditional ($target, $cond);
6609 $target_conditional{$target}{$cond} = $where;
6612 # Check the rule for being a suffix rule. If so, store in a hash.
6613 # Either it's a rule for two known extensions...
6614 if ($target =~ /^($KNOWN_EXTENSIONS_PATTERN)($KNOWN_EXTENSIONS_PATTERN)$/
6615 # ...or it's a rule with unknown extensions (.i.e, the rule looks like
6616 # `.foo.bar:' but `.foo' or `.bar' are not declared in SUFFIXES
6617 # and are not known language extensions).
6618 # Automake will complete SUFFIXES from @suffixes automatically
6619 # (see handle_footer).
6620 || ($target =~ /$SUFFIX_RULE_PATTERN/o && accept_extensions($1)))
6622 my $internal_ext = $2;
6624 # When tranforming sources to objects, Automake uses the
6625 # %suffix_rules to move from each source extension to
6626 # `.$(OBJEXT)', not to `.o' or `.obj'. However some people
6627 # define suffix rules for `.o' or `.obj', so internally we will
6628 # consider these extensions equivalent to `.$(OBJEXT)'. We
6629 # CANNOT rewrite the target (i.e., automagically replace `.o'
6630 # and `.obj' by `.$(OBJEXT)' in the output), or warn the user
6631 # that (s)he'd better use `.$(OBJEXT)', because Automake itself
6632 # output suffix rules for `.o' or `.obj'...
6633 $internal_ext = '.$(OBJEXT)' if ($2 eq '.o' || $2 eq '.obj');
6635 $suffix_rules{$1} = $internal_ext;
6636 verbose "Sources ending in $1 become $2";
6637 push @suffixes, $1, $2;
6644 # See if a target exists.
6648 return defined $targets{$target};
6652 ################################################################
6654 # &read_am_file ($AMFILE)
6655 # -----------------------
6656 # Read Makefile.am and set up %contents. Simultaneously copy lines
6657 # from Makefile.am into $output_trailer or $output_vars as
6658 # appropriate. NOTE we put rules in the trailer section. We want
6659 # user rules to come after our generated stuff.
6660 sub read_am_file ($)
6664 my $am_file = new Automake::XFile ("< $amfile");
6665 verbose "reading $amfile";
6671 while ($_ = $am_file->getline)
6673 if (/$IGNORE_PATTERN/o)
6675 # Merely delete comments beginning with two hashes.
6677 elsif (/$WHITE_PATTERN/o)
6679 # Stick a single white line before the incoming macro or rule.
6683 elsif (/$COMMENT_PATTERN/o)
6685 # Stick comments before the incoming macro or rule. Make
6686 # sure a blank line preceeds first block of comments.
6687 $spacing = "\n" unless $blank;
6689 $comment .= $spacing . $_;
6698 $output_vars .= $comment . "\n";
6702 # We save the conditional stack on entry, and then check to make
6703 # sure it is the same on exit. This lets us conditonally include
6705 my @saved_cond_stack = @cond_stack;
6706 my $cond = conditional_string (@cond_stack);
6710 my $last_var_name = '';
6711 my $last_var_type = '';
6712 my $last_var_value = '';
6713 # FIXME: shouldn't use $_ in this loop; it is too big.
6716 my $here = "$amfile:$.";
6719 unless substr ($_, -1, 1) eq "\n";
6721 # Don't look at MAINTAINER_MODE_TRUE here. That shouldn't be
6722 # used by users. @MAINT@ is an anachronism now.
6723 $_ =~ s/\@MAINT\@//g
6724 unless $seen_maint_mode;
6726 my $new_saw_bk = /\\$/ && ! /$COMMENT_PATTERN/o;
6728 if (/$IGNORE_PATTERN/o)
6730 # Merely delete comments beginning with two hashes.
6732 elsif (/$WHITE_PATTERN/o)
6734 # Stick a single white line before the incoming macro or rule.
6736 file_error ($here, "blank line following trailing backslash")
6739 elsif (/$COMMENT_PATTERN/o)
6741 # Stick comments before the incoming macro or rule.
6742 $comment .= $spacing . $_;
6744 file_error ($here, "comment following trailing backslash")
6751 $output_trailer .= &make_condition (@cond_stack);
6752 $output_trailer .= $_;
6756 $last_var_value .= ' '
6757 unless $last_var_value =~ /\s$/;
6758 $last_var_value .= $_;
6762 $var_comment{$last_var_name} .= "$spacing"
6763 if (!defined $var_comment{$last_var_name}
6764 || substr ($var_comment{$last_var_name}, -1) ne "\n");
6765 $var_comment{$last_var_name} .= "$comment";
6766 $comment = $spacing = '';
6767 macro_define ($last_var_name, 0,
6768 $last_var_type, $cond,
6769 $last_var_value, $here)
6770 if $cond ne 'FALSE';
6771 push (@var_list, $last_var_name);
6776 elsif (/$IF_PATTERN/o)
6778 $cond = cond_stack_if ($1, $2, $here);
6780 elsif (/$ELSE_PATTERN/o)
6782 $cond = cond_stack_else ($1, $2, $here);
6784 elsif (/$ENDIF_PATTERN/o)
6786 $cond = cond_stack_endif ($1, $2, $here);
6789 elsif (/$RULE_PATTERN/o)
6794 rule_define ($1, 0, $cond, $here);
6796 $output_trailer .= $comment . $spacing;
6797 $output_trailer .= &make_condition (@cond_stack);
6798 $output_trailer .= $_;
6799 $comment = $spacing = '';
6801 elsif (/$ASSIGNMENT_PATTERN/o)
6803 # Found a macro definition.
6805 $last_var_name = $1;
6806 $last_var_type = $2;
6807 $last_var_value = $3;
6808 if ($3 ne '' && substr ($3, -1) eq "\\")
6810 # We preserve the `\' because otherwise the long lines
6811 # that are generated will be truncated by broken
6813 $last_var_value = $3 . "\n";
6818 # FIXME: this doesn't always work correctly; it will
6819 # group all comments for a given variable, no matter
6821 # Accumulating variables must not be output.
6822 $var_comment{$last_var_name} .= "$spacing"
6823 if (!defined $var_comment{$last_var_name}
6824 || substr ($var_comment{$last_var_name}, -1) ne "\n");
6825 $var_comment{$last_var_name} .= "$comment";
6826 $comment = $spacing = '';
6828 macro_define ($last_var_name, 0,
6829 $last_var_type, $cond,
6830 $last_var_value, $here)
6831 if $cond ne 'FALSE';
6832 push (@var_list, $last_var_name);
6835 elsif (/$INCLUDE_PATTERN/o)
6839 if ($path =~ s/^\$\(top_srcdir\)\///)
6841 push (@include_stack, "\$\(top_srcdir\)/$path");
6845 $path =~ s/\$\(srcdir\)\///;
6846 push (@include_stack, "\$\(srcdir\)/$path");
6847 $path = $relative_dir . "/" . $path;
6849 &read_am_file ($path);
6853 # This isn't an error; it is probably a continued rule.
6854 # In fact, this is what we assume.
6856 $output_trailer .= $comment . $spacing;
6857 $output_trailer .= &make_condition (@cond_stack);
6858 $output_trailer .= $_;
6859 $comment = $spacing = '';
6860 file_error ($here, "`#' comment at start of rule is unportable")
6861 if $_ =~ /^\t\s*\#/;
6864 $saw_bk = $new_saw_bk;
6865 $_ = $am_file->getline;
6868 $output_trailer .= $comment;
6870 if ("@saved_cond_stack" ne "@cond_stack")
6874 &am_error ("unterminated conditionals: @cond_stack");
6878 # FIXME: better error message here.
6879 &am_error ("conditionals not nested in include file");
6885 # define_standard_variables ()
6886 # ----------------------------
6887 # A helper for read_main_am_file which initializes configure variables
6888 # and variables from header-vars.am. This is a subr so we can call it
6890 sub define_standard_variables
6892 my $saved_output_vars = $output_vars;
6893 my ($comments, undef, $rules) =
6894 file_contents_internal (1, "$libdir/am/header-vars.am");
6896 # This will output the definitions in $output_vars, which we don't
6898 foreach my $var (sort keys %configure_vars)
6900 &define_configure_variable ($var);
6901 push (@var_list, $var);
6904 # ... hence, we restore $output_vars.
6905 $output_vars = $saved_output_vars . $comments . $rules;
6908 # Read main am file.
6909 sub read_main_am_file
6913 # This supports the strange variable tricks we are about to play.
6914 if (scalar keys %var_value > 0)
6917 prog_error ("variable defined before read_main_am_file");
6920 # Generate copyright header for generated Makefile.in.
6921 # We do discard the output of predefined variables, handled below.
6922 $output_vars = ("# $in_file_name generated by automake "
6923 . $VERSION . " from $am_file_name.\n");
6924 $output_vars .= '# ' . subst ('configure_input') . "\n";
6925 $output_vars .= $gen_copyright;
6927 # We want to predefine as many variables as possible. This lets
6928 # the user set them with `+=' in Makefile.am. However, we don't
6929 # want these initial definitions to end up in the output quite
6930 # yet. So we just load them, but output them later.
6931 &define_standard_variables;
6933 # Read user file, which might override some of our values.
6934 &read_am_file ($amfile);
6936 # Ouput all the Automake variables. If the user changed one, then
6937 # it is now marked as owned by the user.
6938 foreach my $var (uniq @var_list)
6940 # Don't process user variables.
6941 variable_output ($var)
6942 unless !$var_is_am{$var};
6945 # Now dump the user variables that were defined. We do it in the same
6946 # order in which they were defined (skipping duplicates).
6947 foreach my $var (uniq @var_list)
6949 # Don't process Automake variables.
6950 variable_output ($var)
6951 unless $var_is_am{$var};
6955 ################################################################
6958 # &flatten ($STRING)
6959 # ------------------
6960 # Flatten the $STRING and return the result.
6975 # &make_paragraphs ($MAKEFILE, [%TRANSFORM])
6976 # ------------------------------------------
6977 # Load a $MAKEFILE, apply the %TRANSFORM, and return it as a list of
6979 sub make_paragraphs ($%)
6981 my ($file, %transform) = @_;
6983 # Complete %transform with global options and make it a Perl
6986 "s/$IGNORE_PATTERN//gm;"
6987 . transform (%transform,
6989 'CYGNUS' => $cygnus_mode,
6991 => $seen_maint_mode ? subst ('MAINTAINER_MODE_TRUE') : '',
6993 'SHAR' => $options{'dist-shar'} || 0,
6994 'BZIP2' => $options{'dist-bzip2'} || 0,
6995 'ZIP' => $options{'dist-zip'} || 0,
6996 'COMPRESS' => $options{'dist-tarZ'} || 0,
6998 'INSTALL-INFO' => !$options{'no-installinfo'},
6999 'INSTALL-MAN' => !$options{'no-installman'},
7000 'CK-NEWS' => $options{'check-news'} || 0,
7002 'SUBDIRS' => variable_defined ('SUBDIRS'),
7003 'TOPDIR' => backname ($relative_dir),
7004 'TOPDIR_P' => $relative_dir eq '.',
7005 'CONFIGURE-AC' => $configure_ac,
7007 'BUILD' => $seen_canonical == AC_CANONICAL_SYSTEM,
7008 'HOST' => $seen_canonical,
7009 'TARGET' => $seen_canonical == AC_CANONICAL_SYSTEM,
7011 'LIBTOOL' => defined $configure_vars{'LIBTOOL'})
7012 # We don't need more than two consecutive new-lines.
7013 . 's/\n{3,}/\n\n/g';
7015 # Swallow the file and apply the COMMAND.
7016 my $fc_file = new Automake::XFile "< $file";
7018 verbose "reading $file";
7019 my $saved_dollar_slash = $/;
7021 $_ = $fc_file->getline;
7022 $/ = $saved_dollar_slash;
7027 # Split at unescaped new lines.
7028 my @lines = split (/(?<!\\)\n/, $content);
7031 while (defined ($_ = shift @lines))
7033 my $paragraph = "$_";
7034 # If we are a rule, eat as long as we start with a tab.
7035 if (/$RULE_PATTERN/smo)
7037 while (defined ($_ = shift @lines) && $_ =~ /^\t/)
7039 $paragraph .= "\n$_";
7041 unshift (@lines, $_);
7044 # If we are a comments, eat as much comments as you can.
7045 elsif (/$COMMENT_PATTERN/smo)
7047 while (defined ($_ = shift @lines)
7048 && $_ =~ /$COMMENT_PATTERN/smo)
7050 $paragraph .= "\n$_";
7052 unshift (@lines, $_);
7055 push @res, $paragraph;
7064 # ($COMMENT, $VARIABLES, $RULES)
7065 # &file_contents_internal ($IS_AM, $FILE, [%TRANSFORM])
7066 # -----------------------------------------------------
7067 # Return contents of a file from $libdir/am, automatically skipping
7068 # macros or rules which are already known. $IS_AM iff the caller is
7069 # reading an Automake file (as opposed to the user's Makefile.am).
7070 sub file_contents_internal ($$%)
7072 my ($is_am, $file, %transform) = @_;
7074 my $result_vars = '';
7075 my $result_rules = '';
7079 # We save the conditional stack on entry, and then check to make
7080 # sure it is the same on exit. This lets us conditonally include
7082 my @saved_cond_stack = @cond_stack;
7083 my $cond = conditional_string (@cond_stack);
7085 foreach (make_paragraphs ($file, %transform))
7088 file_error ($file, "blank line following trailing backslash:\n$_")
7090 file_error ($file, "comment following trailing backslash:\n$_")
7095 # Stick empty line before the incoming macro or rule.
7098 elsif (/$COMMENT_PATTERN/mso)
7100 # Stick comments before the incoming macro or rule.
7104 # Handle inclusion of other files.
7105 elsif (/$INCLUDE_PATTERN/o)
7107 if ($cond ne 'FALSE')
7109 my $file = ($is_am ? "$libdir/am/" : '') . $1;
7111 my ($com, $vars, $rules)
7112 = file_contents_internal ($is_am, $file, %transform);
7114 $result_vars .= $vars;
7115 $result_rules .= $rules;
7119 # Handling the conditionals.
7120 elsif (/$IF_PATTERN/o)
7122 $cond = cond_stack_if ($1, $2, $file);
7124 elsif (/$ELSE_PATTERN/o)
7126 $cond = cond_stack_else ($1, $2, $file);
7128 elsif (/$ENDIF_PATTERN/o)
7130 $cond = cond_stack_endif ($1, $2, $file);
7134 elsif (/$RULE_PATTERN/mso)
7136 # Separate relationship from optional actions: the first
7137 # `new-line tab" not preceded by backslash (continuation
7139 # I'm quite shoked! It seems that (\\\n|[^\n]) is not the
7140 # same as `([^\n]|\\\n)!!! Don't swap it, it breaks.
7142 /^((?:\\\n|[^\n])*)(?:\n(\t.*))?$/som;
7143 my ($relationship, $actions) = ($1, $2 || '');
7145 # Separate targets from dependencies: the first colon.
7146 $relationship =~ /^([^:]+\S+) *: *(.*)$/som;
7147 my ($targets, $dependencies) = ($1, $2);
7148 # Remove the escaped new lines.
7149 # I don't know why, but I have to use a tmp $flat_deps.
7150 my $flat_deps = &flatten ($dependencies);
7151 my @deps = split (' ', $flat_deps);
7153 foreach (split (' ' , $targets))
7155 # FIXME: We are not robust to people defining several targets
7156 # at once, only some of them being in %dependencies.
7158 # Output only if not in FALSE.
7159 if (defined $dependencies{$_}
7160 && $cond ne 'FALSE')
7162 &depend ($_, @deps);
7163 $actions{$_} .= $actions;
7167 # Free-lance dependency. Output the rule for all the
7168 # targets instead of one by one.
7170 # Work out all the conditions for which the target hasn't
7172 my @undefined_conds;
7173 if (defined $target_conditional{$targets})
7175 my @defined_conds = keys %{$target_conditional{$targets}};
7176 @undefined_conds = invert_conditions(@defined_conds);
7180 if (defined $targets{$targets})
7182 # No conditions for which target hasn't been defined
7183 @undefined_conds = ();
7187 # Target hasn't been defined for any conditions
7188 @undefined_conds = ("");
7192 if ($cond ne 'FALSE')
7195 for $undefined_cond (@undefined_conds)
7197 my $condparagraph = $paragraph;
7198 $condparagraph =~ s/^/make_condition (@cond_stack, $undefined_cond)/gme;
7199 $result_rules .= "$spacing$comment$condparagraph\n"
7200 if rule_define ($targets, $is_am,
7201 "$cond $undefined_cond", $file);
7204 $comment = $spacing = '';
7210 elsif (/$ASSIGNMENT_PATTERN/mso)
7212 my ($var, $type, $val) = ($1, $2, $3);
7213 file_error ($file, "macro `$var' with trailing backslash")
7216 # Accumulating variables must not be output.
7217 $var_comment{$var} .= "$spacing"
7218 if (!defined $var_comment{$var}
7219 || substr ($var_comment{$var}, -1) ne "\n");
7220 $var_comment{$var} .= "$comment";
7221 macro_define ($var, $is_am, $type, $cond, $val, $file)
7222 if $cond ne 'FALSE';
7223 push (@var_list, $var);
7225 # If the user has set some variables we were in charge
7226 # of (which is detected by the first reading of
7227 # `header-vars.am'), we must not output them.
7228 $result_vars .= "$spacing$comment$_\n"
7229 if $type ne '+' && $var_is_am{$var} && $cond ne 'FALSE';
7231 $comment = $spacing = '';
7235 # This isn't an error; it is probably some tokens which
7236 # configure is supposed to replace, such as `@SET-MAKE@',
7237 # or some part of a rule cut by an if/endif.
7238 if ($cond ne 'FALSE')
7240 s/^/make_condition (@cond_stack)/gme;
7241 $result_rules .= "$spacing$comment$_\n";
7243 $comment = $spacing = '';
7247 if ("@saved_cond_stack" ne "@cond_stack")
7251 &am_error ("unterminated conditionals: @cond_stack");
7255 # FIXME: better error message here.
7256 &am_error ("conditionals not nested in include file");
7260 return ($comment, $result_vars, $result_rules);
7265 # &file_contents ($BASENAME, [%TRANSFORM])
7266 # ----------------------------------------
7267 # Return contents of a file from $libdir/am, automatically skipping
7268 # macros or rules which are already known.
7269 sub file_contents ($%)
7271 my ($basename, %transform) = @_;
7272 my ($comments, $variables, $rules) =
7273 file_contents_internal (1, "$libdir/am/$basename.am", %transform);
7274 return "$comments$variables$rules";
7279 # &transform (%PAIRS)
7280 # -------------------
7281 # Foreach ($TOKEN, $VAL) in %PAIRS produce a replacement expression suitable
7282 # for file_contents which:
7283 # - replaces %$TOKEN% with $VAL,
7284 # - enables/disables ?$TOKEN? and ?!$TOKEN?,
7285 # - replaces %?$TOKEN% with TRUE or FALSE.
7291 while (my ($token, $val) = each %pairs)
7293 $result .= "s/\Q%$token%\E/\Q$val\E/gm;";
7296 $result .= "s/\Q?$token?\E//gm;s/^.*\Q?!$token?\E.*\\n//gm;";
7297 $result .= "s/\Q%?$token%\E/TRUE/gm;";
7301 $result .= "s/\Q?!$token?\E//gm;s/^.*\Q?$token?\E.*\\n//gm;";
7302 $result .= "s/\Q%?$token%\E/FALSE/gm;";
7310 # &append_exeext ($MACRO)
7311 # -----------------------
7312 # Macro is an Automake magic macro which primary is PROGRAMS, e.g.
7313 # bin_PROGRAMS. Make sure these programs have $(EXEEXT) appended.
7314 sub append_exeext ($)
7318 prog_error "append_exeext ($macro)"
7319 unless $macro =~ /_PROGRAMS$/;
7321 my @conds = variable_conditions_recursive ($macro);
7324 foreach my $cond (@conds)
7326 my @one_binlist = ();
7327 my @condval = variable_value_as_list_recursive ($macro, $cond);
7328 foreach my $rcurs (@condval)
7330 # Skip autoconf substs. Also skip if the user
7331 # already applied $(EXEEXT).
7332 if ($rcurs =~ /^\@.*\@$/ || $rcurs =~ /\$\(EXEEXT\)$/)
7334 push (@one_binlist, $rcurs);
7338 push (@one_binlist, $rcurs . '$(EXEEXT)');
7342 push (@condvals, $cond);
7343 push (@condvals, "@one_binlist");
7346 macro_delete ($macro);
7349 my $cond = shift (@condvals);
7350 my @val = split (' ', shift (@condvals));
7351 define_pretty_variable ($macro, $cond, @val);
7357 # &am_primary_prefixes ($PRIMARY, $CAN_DIST, @PREFIXES)
7358 # -----------------------------------------------------
7359 # Find all variable prefixes that are used for install directories. A
7360 # prefix `zar' qualifies iff:
7362 # * `zardir' is a variable.
7363 # * `zar_PRIMARY' is a variable.
7365 # As a side effect, it looks for misspellings. It is an error to have
7366 # a variable ending in a "reserved" suffix whose prefix is unknown, eg
7367 # "bni_PROGRAMS". However, unusual prefixes are allowed if a variable
7368 # of the same name (with "dir" appended) exists. For instance, if the
7369 # variable "zardir" is defined, then "zar_PROGRAMS" becomes valid.
7370 # This is to provide a little extra flexibility in those cases which
7372 sub am_primary_prefixes ($$@)
7374 my ($primary, $can_dist, @prefixes) = @_;
7377 my %valid = map { $_ => 0 } @prefixes;
7378 $valid{'EXTRA'} = 0;
7379 foreach my $varname (keys %var_value)
7381 # Automake is allowed to define variables that look like they
7382 # are magic variables, such as INSTALL_DATA.
7384 if $var_is_am{$varname};
7386 if ($varname =~ /^(nobase_)?(dist_|nodist_)?(.*)_$primary$/)
7388 my ($base, $dist, $X) = ($1 || '', $2 || '', $3 || '');
7389 if ($dist ne '' && ! $can_dist)
7391 # Note that a configure variable is always legitimate.
7392 # It is natural to name such variables after the
7393 # primary, so we explicitly allow it.
7394 macro_error ($varname,
7395 "invalid variable `$varname': `dist' is forbidden")
7396 if ! exists $configure_vars{$varname};
7398 elsif (! defined $valid{$X} && ! variable_defined ("${X}dir"))
7400 # Note that a configure variable is always legitimate.
7401 # It is natural to name such variables after the
7402 # primary, so we explicitly allow it.
7403 macro_error ($varname, "invalid variable `$varname'")
7404 if ! exists $configure_vars{$varname};
7408 # Ensure all extended prefixes are actually used.
7409 $valid{"$base$dist$X"} = 1;
7414 # Return only those which are actually defined.
7415 return sort grep { variable_defined ($_ . '_' . $primary) } keys %valid;
7419 # Handle `where_HOW' variable magic. Does all lookups, generates
7420 # install code, and possibly generates code to define the primary
7421 # variable. The first argument is the name of the .am file to munge,
7422 # the second argument is the primary variable (eg HEADERS), and all
7423 # subsequent arguments are possible installation locations. Returns
7424 # list of all values of all _HOW targets.
7426 # FIXME: this should be rewritten to be cleaner. It should be broken
7427 # up into multiple functions.
7429 # Usage is: am_install_var (OPTION..., file, HOW, where...)
7436 my $default_dist = 0;
7439 if ($args[0] eq '-noextra')
7443 elsif ($args[0] eq '-candist')
7447 elsif ($args[0] eq '-defaultdist')
7452 elsif ($args[0] !~ /^-/)
7459 my ($file, $primary, @prefix) = @args;
7461 # Now that configure substitutions are allowed in where_HOW
7462 # variables, it is an error to actually define the primary. We
7463 # allow `JAVA', as it is customarily used to mean the Java
7464 # interpreter. This is but one of several Java hacks. Similarly,
7465 # `PYTHON' is customarily used to mean the Python interpreter.
7466 macro_error ($primary, "`$primary' is an anachronism")
7467 if variable_defined ($primary)
7468 && ($primary ne 'JAVA' && $primary ne 'PYTHON');
7471 # Get the prefixes which are valid and actually used.
7472 @prefix = am_primary_prefixes ($primary, $can_dist, @prefix);
7474 # If a primary includes a configure substitution, then the EXTRA_
7475 # form is required. Otherwise we can't properly do our job.
7477 my $warned_about_extra = 0;
7482 # True if the iteration is the first one. Used for instance to
7483 # output parts of the associated file only once.
7485 foreach my $X (@prefix)
7487 my $nodir_name = $X;
7488 my $one_name = $X . '_' . $primary;
7490 my $strip_subdir = 1;
7491 # If subdir prefix should be preserved, do so.
7492 if ($nodir_name =~ /^nobase_/)
7495 $nodir_name =~ s/^nobase_//;
7498 # If files should be distributed, do so.
7502 $dist_p = (($default_dist && $nodir_name !~ /^nodist_/)
7503 || (! $default_dist && $nodir_name =~ /^dist_/));
7504 $nodir_name =~ s/^(dist|nodist)_//;
7507 # Append actual contents of where_PRIMARY variable to
7509 foreach my $rcurs (&variable_value_as_list_recursive ($one_name, 'all'))
7511 # Skip configure substitutions. Possibly bogus.
7512 if ($rcurs =~ /^\@.*\@$/)
7514 if ($nodir_name eq 'EXTRA')
7516 if (! $warned_about_extra)
7518 $warned_about_extra = 1;
7519 macro_error ($one_name,
7520 "`$one_name' contains configure substitution, but shouldn't");
7523 # Check here to make sure variables defined in
7524 # configure.ac do not imply that EXTRA_PRIMARY
7526 elsif (! defined $configure_vars{$one_name})
7528 $require_extra = $one_name
7535 push (@result, $rcurs);
7538 # A blatant hack: we rewrite each _PROGRAMS primary to include
7540 append_exeext ($one_name)
7541 if $primary eq 'PROGRAMS';
7543 # "EXTRA" shouldn't be used when generating clean targets,
7544 # all, or install targets. We used to warn if EXTRA_FOO was
7545 # defined uselessly, but this was annoying.
7547 if $nodir_name eq 'EXTRA';
7549 if ($nodir_name eq 'check')
7551 push (@check, '$(' . $one_name . ')');
7555 push (@used, '$(' . $one_name . ')');
7558 # Is this to be installed?
7559 my $install_p = $nodir_name ne 'noinst' && $nodir_name ne 'check';
7561 # If so, with install-exec? (or install-data?).
7562 my $exec_p = ($nodir_name =~ /$EXEC_DIR_PATTERN/o);
7564 # Singular form of $PRIMARY.
7565 (my $one_primary = $primary) =~ s/S$//;
7566 $output_rules .= &file_contents ($file,
7569 'PRIMARY' => $primary,
7570 'ONE_PRIMARY' => $one_primary,
7572 'NDIR' => $nodir_name,
7573 'BASE' => $strip_subdir,
7576 'INSTALL' => $install_p,
7577 'DIST' => $dist_p));
7582 # The JAVA variable is used as the name of the Java interpreter.
7583 # The PYTHON variable is used as the name of the Python interpreter.
7584 if (@used && $primary ne 'JAVA' && $primary ne 'PYTHON')
7587 define_pretty_variable ($primary, '', @used);
7588 $output_vars .= "\n";
7591 if ($require_extra && ! variable_defined ('EXTRA_' . $primary))
7593 macro_error ($require_extra,
7594 "`$require_extra' contains configure substitution, but `EXTRA_$primary' not defined");
7597 # Push here because PRIMARY might be configure time determined.
7598 push (@all, '$(' . $primary . ')')
7599 if @used && $primary ne 'JAVA' && $primary ne 'PYTHON';
7601 # Make the result unique. This lets the user use conditionals in
7602 # a natural way, but still lets us program lazily -- we don't have
7603 # to worry about handling a particular object more than once.
7604 return uniq (sort @result);
7608 ################################################################
7610 # Each key in this hash is the name of a directory holding a
7611 # Makefile.in. These variables are local to `is_make_dir'.
7613 my $make_dirs_set = 0;
7618 if (! $make_dirs_set)
7620 foreach my $iter (@configure_input_files)
7622 $make_dirs{dirname ($iter)} = 1;
7624 # We also want to notice Makefile.in's.
7625 foreach my $iter (@other_input_files)
7627 if ($iter =~ /Makefile\.in$/)
7629 $make_dirs{dirname ($iter)} = 1;
7634 return defined $make_dirs{$dir};
7637 ################################################################
7639 # This variable is local to the "require file" set of functions.
7640 my @require_file_paths = ();
7642 # If a file name appears as a key in this hash, then it has already
7643 # been checked for. This variable is local to the "require file"
7645 %require_file_found = ();
7648 # &maybe_push_required_file ($DIR, $FILE, $FULLFILE)
7649 # --------------------------------------------------
7650 # See if we want to push this file onto dist_common. This function
7651 # encodes the rules for deciding when to do so.
7652 sub maybe_push_required_file
7654 my ($dir, $file, $fullfile) = @_;
7656 if ($dir eq $relative_dir)
7658 push_dist_common ($file);
7661 elsif ($relative_dir eq '.' && ! &is_make_dir ($dir))
7663 # If we are doing the topmost directory, and the file is in a
7664 # subdir which does not have a Makefile, then we distribute it
7666 push_dist_common ($fullfile);
7673 # &require_file_internal ($WHERE, $MYSTRICT, @FILES)
7674 # --------------------------------------------------
7675 # Verify that the file must exist in the current directory.
7676 # $MYSTRICT is the strictness level at which this file becomes required.
7678 # Must set require_file_paths before calling this function.
7679 # require_file_paths is set to hold a single directory (the one in
7680 # which the first file was found) before return.
7681 sub require_file_internal ($$@)
7683 my ($where, $mystrict, @files) = @_;
7685 foreach my $file (@files)
7693 my $dangling_sym = 0;
7694 foreach my $dir (@require_file_paths)
7696 $fullfile = $dir . "/" . $file;
7697 $errdir = $dir unless $errdir;
7699 # Use different name for "error filename". Otherwise on
7700 # an error the bad file will be reported as eg
7701 # `../../install-sh' when using the default
7703 $errfile = $errdir . '/' . $file;
7705 if (-l $fullfile && ! -f $fullfile)
7710 elsif (-f $fullfile)
7713 maybe_push_required_file ($dir, $file, $fullfile);
7719 # `--force-missing' only has an effect if `--add-missing' is
7721 if ($found_it && (! $add_missing || ! $force_missing))
7723 # Prune the path list.
7724 @require_file_paths = $save_dir;
7728 # If we've already looked for it, we're done. You might
7729 # wonder why we don't do this before searching for the
7730 # file. If we do that, then something like
7731 # AC_OUTPUT(subdir/foo foo) will fail to put foo.in into
7735 next if defined $require_file_found{$file};
7736 $require_file_found{$file} = 1;
7739 if ($strictness >= $mystrict)
7741 if ($dangling_sym && $add_missing)
7749 # Only install missing files according to our desired
7751 my $message = "required file `$errfile' not found";
7756 if (-f ("$libdir/$file"))
7758 # Install the missing file. Symlink if we
7759 # can, copy if we must. Note: delete the file
7760 # first, in case it is a dangling symlink.
7761 $message = "installing `$errfile'";
7762 # Windows Perl will hang if we try to delete a
7763 # file that doesn't exist.
7764 unlink ($errfile) if -f $errfile;
7765 if ($symlink_exists && ! $copy_missing)
7767 if (! symlink ("$libdir/$file", $errfile))
7770 $trailer = "; error while making link: $!";
7773 elsif (system ('cp', "$libdir/$file", $errfile))
7776 $trailer = "\n error while copying";
7780 if (! maybe_push_required_file (dirname ($errfile),
7785 # We have added the file but could not push it
7786 # into DIST_COMMON (probably because this is
7787 # an auxiliary file and we are not processing
7788 # the top level Makefile). This is unfortunate,
7789 # since it means we are using a file which is not
7792 # Get Automake to be run again: on the second
7793 # run the file will be found, and pushed into
7794 # the toplevel DIST_COMMON automatically.
7795 $automake_needs_to_reprocess_all_files = 1;
7799 # Prune the path list.
7800 @require_file_paths = &dirname ($errfile);
7803 # If --force-missing was specified, and we have
7804 # actually found the file, then do nothing.
7806 if $found_it && $force_missing;
7810 file_warning ($where, "$message$trailer");
7814 file_error ($where, "$message$trailer");
7821 # &require_file ($WHERE, $MYSTRICT, @FILES)
7822 # -----------------------------------------
7823 sub require_file ($$@)
7825 my ($where, $mystrict, @files) = @_;
7826 @require_file_paths = $relative_dir;
7827 require_file_internal ($where, $mystrict, @files);
7830 # &require_file_with_macro ($MACRO, $MYSTRICT, @FILES)
7831 # ----------------------------------------------------
7832 sub require_file_with_macro ($$@)
7834 my ($macro, $mystrict, @files) = @_;
7835 require_file ($var_location{$macro}, $mystrict, @files);
7839 # &require_conf_file ($WHERE, $MYSTRICT, @FILES)
7840 # ----------------------------------------------
7841 # Looks in configuration path, as specified by AC_CONFIG_AUX_DIR.
7842 sub require_conf_file ($$@)
7844 my ($where, $mystrict, @files) = @_;
7845 @require_file_paths = @config_aux_path;
7846 require_file_internal ($where, $mystrict, @files);
7847 my $dir = $require_file_paths[0];
7848 @config_aux_path = @require_file_paths;
7849 # Avoid unsightly '/.'s.
7850 $config_aux_dir = '$(top_srcdir)' . ($dir eq '.' ? "" : "/$dir");
7854 # &require_conf_file_with_macro ($MACRO, $MYSTRICT, @FILES)
7855 # ---------------------------------------------------------
7856 sub require_conf_file_with_macro ($$@)
7858 my ($macro, $mystrict, @files) = @_;
7859 require_conf_file ($var_location{$macro}, $mystrict, @files);
7862 ################################################################
7864 # &require_build_directory ($DIRECTORY)
7865 # ------------------------------------
7866 # Emit rules to create $DIRECTORY if needed, and return
7867 # the file that any target requiring this directory should be made
7869 sub require_build_directory ($)
7871 my $directory = shift;
7872 my $dirstamp = "$directory/.dirstamp";
7874 # Don't emit the rule twice.
7875 if (! defined $directory_map{$directory})
7877 $directory_map{$directory} = 1;
7879 # Directory must be removed by `make distclean'.
7880 $compile_clean_files{$dirstamp} = DIST_CLEAN;
7882 $output_rules .= ("$dirstamp:\n"
7883 . "\t\@\$(mkinstalldirs) $directory\n"
7884 . "\t\@: > $dirstamp\n");
7890 # &require_build_directory_maybe ($FILE)
7891 # --------------------------------------
7892 # If $FILE lies in a subdirectory, emit a rule to create this
7893 # directory and return the file that $FILE should be made
7894 # dependent upon. Otherwise, just return the empty string.
7895 sub require_build_directory_maybe ($)
7898 my $directory = dirname ($file);
7900 if ($directory ne '.')
7902 return require_build_directory ($directory);
7910 ################################################################
7912 # Push a list of files onto dist_common.
7913 sub push_dist_common
7915 prog_error ("push_dist_common run after handle_dist")
7916 if $handle_dist_run;
7917 macro_define ('DIST_COMMON', 1, '+', '', "@_", '');
7924 $strictness_name = $_[0];
7925 if ($strictness_name eq 'gnu')
7929 elsif ($strictness_name eq 'gnits')
7931 $strictness = GNITS;
7933 elsif ($strictness_name eq 'foreign')
7935 $strictness = FOREIGN;
7939 die "$me: level `$strictness_name' not recognized\n";
7944 ################################################################
7946 # Ensure a file exists.
7952 my $touch = new IO::File (">> $file");
7957 # Glob something. Do this to avoid indentation screwups everywhere we
7958 # want to glob. Gross!
7965 # Remove one level of brackets and strip leading spaces,
7966 # as does m4 to function arguments.
7972 my @letters = split //;
7981 next if $depth == 1;
7986 next if $depth == 0;
7987 # don't count orphan right brackets
7988 $depth = 0 if $depth < 0;
7992 return join '', @result;
7995 ################################################################
7997 # print_error ($LEADER, @ARGS)
7998 # ----------------------------
7999 # Do the work of printing the error message. Join @ARGS with spaces,
8000 # then split at newlines and add $LEADER to each line. Uses `warn' to
8001 # print message. Set exit status.
8004 my ($leader, @args) = @_;
8006 @args = split ("\n", $text);
8007 $text = $leader . join ("\n" . $leader, @args) . "\n";
8013 # Print an error message and set exit status.
8016 print_error ("$me: ${am_file}.am: ", @_);
8020 # &file_error ($FILE, @ARGS)
8021 # --------------------------
8024 my ($file, @args) = @_;
8025 print_error ("$file: ", @args);
8029 # ¯o_error ($MACRO, @ARGS)
8030 # ----------------------------
8031 # Report an error, @ARGS, about $MACRO.
8032 sub macro_error ($@)
8034 my ($macro, @args) = @_;
8035 file_error ($var_location{$macro}, @args);
8039 # &target_error ($TARGET, @ARGS)
8040 # ------------------------------
8041 # Report an error, @ARGS, about the rule $TARGET.
8042 sub target_error ($@)
8044 my ($target, @args) = @_;
8045 file_error ($targets{$target}, @args);
8049 # Like am_error, but while scanning configure.ac.
8052 # FIXME: can run in subdirs.
8053 print_error ("$me: $configure_ac: ", @_);
8056 # &file_warning ($FILE, @ARGS)
8057 # ----------------------------
8058 # Warning message with line number referring to configure.ac.
8059 # Does not affect exit_status
8060 sub file_warning ($@)
8062 my ($file, @args) = @_;
8064 my $saved_exit_status = $exit_status;
8065 my $sig = $SIG{'__WARN__'};
8066 $SIG{'__WARN__'} = 'DEFAULT';
8067 file_error ($file, @args);
8068 $exit_status = $saved_exit_status;
8069 $SIG{'__WARN__'} = $sig;
8072 # Tell user where our aclocal.m4 is, but only once.
8073 sub keyed_aclocal_warning ($)
8076 warn "$me: macro `$key' can be generated by `aclocal'\n";
8079 # Print usage information.
8083 Usage: $0 [OPTION] ... [Makefile]...
8085 Generate Makefile.in for configure from Makefile.am.
8088 --help print this help, then exit
8089 --version print version number, then exit
8090 -v, --verbose verbosely list files processed
8091 -o, --output-dir=DIR put generated Makefile.in's into DIR
8092 --no-force only update Makefile.in's that are out of date
8094 Dependency tracking:
8095 -i, --ignore-deps disable dependency tracking code
8096 --include-deps enable dependency tracking code
8099 --cygnus assume program is part of Cygnus-style tree
8100 --foreign set strictness to foreign
8101 --gnits set strictness to gnits
8102 --gnu set strictness to gnu
8105 -a, --add-missing add missing standard files to package
8106 --libdir=DIR directory storing library files
8107 -c, --copy with -a, copy missing files (default is symlink)
8108 -f, --force-missing force update of standard files
8113 foreach my $iter (sort ((@common_files, @common_sometimes)))
8115 push (@lcomm, $iter) unless $iter eq $last;
8120 print "\nFiles which are automatically distributed, if found:\n";
8121 format USAGE_FORMAT =
8122 @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<
8123 $four[0], $four[1], $four[2], $four[3]
8125 $~ = "USAGE_FORMAT";
8128 my $rows = int(@lcomm / $cols);
8129 my $rest = @lcomm % $cols;
8140 for (my $y = 0; $y < $rows; $y++)
8142 @four = ("", "", "", "");
8143 for (my $x = 0; $x < $cols; $x++)
8145 last if $y + 1 == $rows && $x == $rest;
8147 my $idx = (($x > $rest)
8148 ? ($rows * $rest + ($rows - 1) * ($x - $rest))
8152 $four[$x] = $lcomm[$idx];
8157 print "\nReport bugs to <bug-automake\@gnu.org>.\n";
8165 # Print version information
8169 automake (GNU $PACKAGE) $VERSION
8170 Written by Tom Tromey <tromey\@cygnus.com>.
8172 Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
8173 Free Software Foundation, Inc.
8174 This is free software; see the source for copying conditions. There is NO
8175 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.