5 eval 'case $# in 0) exec @PERL@ -S "$0";; *) exec @PERL@ -S "$0" "$@";; esac'
8 # automake - create Makefile.in from Makefile.am
9 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
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@redhat.com>.
34 my $perllibdir = $ENV{'perllibdir'} || '@datadir@/@PACKAGE@-@APIVERSION@';
35 unshift @INC, $perllibdir;
37 # Override SHELL. This is required on DJGPP so that system() uses
38 # bash, not COMMAND.COM which doesn't quote arguments properly.
39 # Other systems aren't expected to use $SHELL when Automake
40 # runs, but it should be safe to drop the `if DJGPP' guard if
41 # it turns up other systems need the same thing. After all,
42 # if SHELL is used, ./configure's SHELL is always better than
43 # the user's SHELL (which may be something like tcsh).
44 $ENV{'SHELL'} = '@SHELL@' if exists $ENV{'DJGPP'};
48 struct (# Short name of the language (c, f77...).
50 # Nice name of the language (C, Fortran 77...).
53 # List of configure variables which must be defined.
57 # `pure' is `1' or `'. A `pure' language is one where, if
58 # all the files in a directory are of that language, then we
59 # do not require the C compiler or any code to call it.
64 # Name of the compiling variable (COMPILE).
66 # Content of the compiling variable.
68 # Flag to require compilation without linking (-c).
69 'compile_flag' => "\$",
71 # A subroutine to compute a list of possible extensions of
72 # the product given the input extensions.
73 # (defaults to a subroutine which returns ('.$(OBJEXT)', '.lo'))
74 'output_extensions' => "\$",
75 # A list of flag variables used in 'compile'.
79 # The file to use when generating rules for this language.
80 # The default is 'depend2'.
83 # Name of the linking variable (LINK).
85 # Content of the linking variable.
88 # Name of the linker variable (LD).
90 # Content of the linker variable ($(CC)).
93 # Flag to specify the output file (-o).
94 'output_flag' => "\$",
97 # This is a subroutine which is called whenever we finally
98 # determine the context in which a source file will be
100 '_target_hook' => "\$");
106 if (defined $self->_finish)
108 &{$self->_finish} ();
112 sub target_hook ($$$$)
115 if (defined $self->_target_hook)
117 &{$self->_target_hook} (@_);
123 use strict 'vars', 'subs';
124 use Automake::General;
126 use Automake::Channels;
134 # Parameters set by configure. Not to be changed. NOTE: assign
135 # VERSION as string so that eg version 0.30 will print correctly.
136 my $VERSION = '@VERSION@';
137 my $PACKAGE = '@PACKAGE@';
138 my $libdir = '@datadir@/@PACKAGE@-@APIVERSION@';
140 # Some regular expressions. One reason to put them here is that it
141 # makes indentation work better in Emacs.
143 # Writting singled-quoted-$-terminated regexes is a pain because
144 # perl-mode thinks of $' as the ${'} variable (intead of a $ followed
145 # by a closing quote. Letting perl-mode think the quote is not closed
146 # leads to all sort of misindentations. On the other hand, defining
147 # regexes as double-quoted strings is far less readable. So usually
150 # $REGEX = '^regex_value' . "\$";
152 my $IGNORE_PATTERN = '^\s*##([^#\n].*)?\n';
153 my $WHITE_PATTERN = '^\s*' . "\$";
154 my $COMMENT_PATTERN = '^#';
155 my $TARGET_PATTERN='[$a-zA-Z_.@%][-.a-zA-Z0-9_(){}/$+@%]*';
156 # A rule has three parts: a list of targets, a list of dependencies,
157 # and optionally actions.
159 "^($TARGET_PATTERN(?:(?:\\\\\n|\\s)+$TARGET_PATTERN)*) *:([^=].*|)\$";
161 my $SUFFIX_RULE_PATTERN =
162 '^(\.[a-zA-Z0-9_(){}$+@]+)(\.[a-zA-Z0-9_(){}$+@]+)' . "\$";
163 # Only recognize leading spaces, not leading tabs. If we recognize
164 # leading tabs here then we need to make the reader smarter, because
165 # otherwise it will think rules like `foo=bar; \' are errors.
166 my $MACRO_PATTERN = '^[.A-Za-z0-9_@]+' . "\$";
167 my $ASSIGNMENT_PATTERN = '^ *([^ \t=:+]*)\s*([:+]?)=\s*(.*)' . "\$";
168 # This pattern recognizes a Gnits version id and sets $1 if the
169 # release is an alpha release. We also allow a suffix which can be
170 # used to extend the version number with a "fork" identifier.
171 my $GNITS_VERSION_PATTERN = '\d+\.\d+([a-z]|\.\d+)?(-[A-Za-z0-9]+)?';
173 my $IF_PATTERN = '^if\s+(!?)\s*([A-Za-z][A-Za-z0-9_]*)\s*(?:#.*)?' . "\$";
175 '^else(?:\s+(!?)\s*([A-Za-z][A-Za-z0-9_]*))?\s*(?:#.*)?' . "\$";
177 '^endif(?:\s+(!?)\s*([A-Za-z][A-Za-z0-9_]*))?\s*(?:#.*)?' . "\$";
178 my $PATH_PATTERN = '(\w|[/.-])+';
179 # This will pass through anything not of the prescribed form.
180 my $INCLUDE_PATTERN = ('^include\s+'
181 . '((\$\(top_srcdir\)/' . $PATH_PATTERN . ')'
182 . '|(\$\(srcdir\)/' . $PATH_PATTERN . ')'
183 . '|([^/\$]' . $PATH_PATTERN . '))\s*(#.*)?' . "\$");
185 # This handles substitution references like ${foo:.a=.b}.
186 my $SUBST_REF_PATTERN = "^([^:]*):([^=]*)=(.*)\$";
188 # Match `-d' as a command-line argument in a string.
189 my $DASH_D_PATTERN = "(^|\\s)-d(\\s|\$)";
190 # Directories installed during 'install-exec' phase.
191 my $EXEC_DIR_PATTERN =
192 '^(?:bin|sbin|libexec|sysconf|localstate|lib|pkglib|.*exec.*)' . "\$";
194 # Constants to define the "strictness" level.
195 use constant FOREIGN => 0;
196 use constant GNU => 1;
197 use constant GNITS => 2;
199 # Values for AC_CANONICAL_*
200 use constant AC_CANONICAL_HOST => 1;
201 use constant AC_CANONICAL_SYSTEM => 2;
203 # Values indicating when something should be cleaned.
204 use constant MOSTLY_CLEAN => 0;
205 use constant CLEAN => 1;
206 use constant DIST_CLEAN => 2;
207 use constant MAINTAINER_CLEAN => 3;
210 my @libtool_files = qw(ltmain.sh config.guess config.sub);
211 # ltconfig appears here for compatibility with old versions of libtool.
212 my @libtool_sometimes = qw(ltconfig ltcf-c.sh ltcf-cxx.sh ltcf-gcj.sh);
214 # Commonly found files we look for and automatically include in
217 (qw(ABOUT-GNU ABOUT-NLS AUTHORS BACKLOG COPYING COPYING.DOC COPYING.LIB
218 COPYING.LESSER ChangeLog INSTALL NEWS README THANKS TODO acinclude.m4
219 ansi2knr.1 ansi2knr.c compile config.guess config.rpath config.sub
220 configure configure.ac configure.in depcomp elisp-comp
221 install-sh libversion.in mdate-sh missing mkinstalldirs
222 py-compile texinfo.tex ylwrap),
223 @libtool_files, @libtool_sometimes);
225 # Commonly used files we auto-include, but only sometimes.
226 my @common_sometimes =
227 qw(aclocal.m4 acconfig.h config.h.top config.h.bot stamp-vti);
229 # Standard directories from the GNU Coding Standards, and additional
230 # pkg* directories from Automake. Stored in a hash for fast member check.
231 my %standard_prefix =
232 map { $_ => 1 } (qw(bin data exec include info lib libexec lisp
233 localstate man man1 man2 man3 man4 man5 man6
234 man7 man8 man9 oldinclude pkgdatadir
235 pkgincludedir pkglibdir sbin sharedstate
238 # Declare the macros that define known variables, so we can
239 # hint the user if she try to use one of these variables.
241 # Macros accessible via aclocal.
242 my %am_macro_for_var =
244 ANSI2KNR => 'AM_C_PROTOTYPES',
245 CCAS => 'AM_PROG_AS',
246 CCASFLAGS => 'AM_PROG_AS',
247 EMACS => 'AM_PATH_LISPDIR',
248 GCJ => 'AM_PROG_GCJ',
249 LEX => 'AM_PROG_LEX',
250 LIBTOOL => 'AC_PROG_LIBTOOL',
251 lispdir => 'AM_PATH_LISPDIR',
252 pkgpyexecdir => 'AM_PATH_PYTHON',
253 pkgpythondir => 'AM_PATH_PYTHON',
254 pyexecdir => 'AM_PATH_PYTHON',
255 PYTHON => 'AM_PATH_PYTHON',
256 pythondir => 'AM_PATH_PYTHON',
257 U => 'AM_C_PROTOTYPES',
260 # Macros shipped with Autoconf.
261 my %ac_macro_for_var =
264 CFLAGS => 'AC_PROG_CC',
265 CXX => 'AC_PROG_CXX',
266 CXXFLAGS => 'AC_PROG_CXX',
267 F77 => 'AC_PROG_F77',
268 F77FLAGS => 'AC_PROG_F77',
269 RANLIB => 'AC_PROG_RANLIB',
270 YACC => 'AC_PROG_YACC',
273 # Copyright on generated Makefile.ins.
274 my $gen_copyright = "\
275 # Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
276 # Free Software Foundation, Inc.
277 # This Makefile.in is free software; the Free Software Foundation
278 # gives unlimited permission to copy and/or distribute it,
279 # with or without modifications, as long as this notice is preserved.
281 # This program is distributed in the hope that it will be useful,
282 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
283 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
284 # PARTICULAR PURPOSE.
287 # These constants are returned by lang_*_rewrite functions.
288 # LANG_SUBDIR means that the resulting object file should be in a
289 # subdir if the source file is. In this case the file name cannot
290 # have `..' components.
291 use constant LANG_IGNORE => 0;
292 use constant LANG_PROCESS => 1;
293 use constant LANG_SUBDIR => 2;
295 # These are used when keeping track of whether an object can be built
296 # by two different paths.
297 use constant COMPILE_LIBTOOL => 1;
298 use constant COMPILE_ORDINARY => 2;
302 ## ---------------------------------- ##
303 ## Variables related to the options. ##
304 ## ---------------------------------- ##
306 # TRUE if we should always generate Makefile.in.
307 my $force_generation = 1;
309 # Strictness level as set on command line.
310 my $default_strictness = GNU;
312 # Name of strictness level, as set on command line.
313 my $default_strictness_name = 'gnu';
315 # This is TRUE if automatic dependency generation code should be
316 # included in generated Makefile.in.
317 my $cmdline_use_dependencies = 1;
319 # From the Perl manual.
320 my $symlink_exists = (eval 'symlink ("", "");', $@ eq '');
322 # TRUE if missing standard files should be installed.
325 # TRUE if we should copy missing files; otherwise symlink if possible.
326 my $copy_missing = 0;
328 # TRUE if we should always update files that we know about.
329 my $force_missing = 0;
332 ## ---------------------------------------- ##
333 ## Variables filled during files scanning. ##
334 ## ---------------------------------------- ##
336 # Name of the top autoconf input: `configure.ac' or `configure.in'.
337 my $configure_ac = '';
339 # Files found by scanning configure.ac for LIBOBJS.
342 # Names used in AC_CONFIG_HEADER call.
343 my @config_headers = ();
344 # Where AC_CONFIG_HEADER appears.
345 my $config_header_location;
347 # Directory where output files go. Actually, output files are
348 # relative to this directory.
349 my $output_directory;
351 # List of Makefile.am's to process, and their corresponding outputs.
352 my @input_files = ();
353 my %output_files = ();
355 # Complete list of Makefile.am's that exist.
356 my @configure_input_files = ();
358 # List of files in AC_CONFIG_FILES/AC_OUTPUT without Makefile.am's,
360 my @other_input_files = ();
361 # Where the last AC_CONFIG_FILES/AC_OUTPUT appears.
362 my $ac_config_files_location;
364 # List of directories to search for configure-required files. This
365 # can be set by AC_CONFIG_AUX_DIR.
366 my @config_aux_path = qw(. .. ../..);
367 my $config_aux_dir = '';
368 my $config_aux_dir_set_in_configure_in = 0;
370 # Whether AM_GNU_GETTEXT has been seen in configure.ac.
371 my $seen_gettext = 0;
372 # Whether AM_GNU_GETTEXT([external]) is used.
373 my $seen_gettext_external = 0;
374 # Where AM_GNU_GETTEXT appears.
375 my $ac_gettext_location;
377 # TRUE if we've seen AC_CANONICAL_(HOST|SYSTEM).
378 my $seen_canonical = 0;
379 my $canonical_location;
381 # Where AM_MAINTAINER_MODE appears.
384 # Actual version we've seen.
385 my $package_version = '';
387 # Where version is defined.
388 my $package_version_location;
390 # TRUE if we've seen AC_ENABLE_MULTILIB.
391 my $seen_multilib = 0;
393 # TRUE if we've seen AM_PROG_CC_C_O
396 # Where AM_INIT_AUTOMAKE is called;
397 my $seen_init_automake = 0;
399 # TRUE if we've seen AM_AUTOMAKE_VERSION.
400 my $seen_automake_version = 0;
402 # Hash table of discovered configure substitutions. Keys are names,
403 # values are `FILE:LINE' strings which are used by error message
405 my %configure_vars = ();
407 # This is used to keep track of which variable definitions we are
408 # scanning. It is only used in certain limited ways, but it has to be
409 # global. It is declared just for documentation purposes.
410 my %vars_scanned = ();
412 # TRUE if --cygnus seen.
415 # Hash table of AM_CONDITIONAL variables seen in configure.
416 my %configure_cond = ();
418 # This maps extensions onto language names.
419 my %extension_map = ();
421 # List of the DIST_COMMON files we discovered while reading
423 my $configure_dist_common = '';
425 # This maps languages names onto objects.
428 # List of targets we must always output.
429 # FIXME: Complete, and remove falsely required targets.
430 my %required_targets =
443 # FIXME: Not required, temporary hacks.
444 # Well, actually they are sort of required: the -recursive
445 # targets will run them anyway...
450 'install-data-am' => 1,
451 'install-exec-am' => 1,
452 'installcheck-am' => 1,
458 # This is set to 1 when Automake needs to be run again.
459 # (For instance, this happens when an auxiliary file such as
460 # depcomp is added after the toplevel Makefile.in -- which
461 # should distribute depcomp -- has been generated.)
462 my $automake_needs_to_reprocess_all_files = 0;
464 # Options set via AM_INIT_AUTOMAKE.
465 my $global_options = '';
467 # Same as $suffix_rules (declared below), but records only the
468 # default rules supplied by the languages Automake supports.
469 my $suffix_rules_default;
471 # If a file name appears as a key in this hash, then it has already
472 # been checked for. This variable is local to the "require file"
474 my %require_file_found = ();
477 ################################################################
479 ## ------------------------------------------ ##
480 ## Variables reset by &initialize_per_input. ##
481 ## ------------------------------------------ ##
483 # Basename and relative dir of the input file.
487 # Same but wrt Makefile.in.
491 # These two variables are used when generating each Makefile.in.
492 # They hold the Makefile.in until it is ready to be printed.
499 # Suffixes found during a run.
502 # Handling the variables.
505 # - $var_value{$VAR}{$COND} is its value associated to $COND,
506 # - $var_location{$VAR}{$COND} is where it was defined,
507 # - $var_comment{$VAR}{$COND} are the comments associated to it.
508 # - $var_type{$VAR}{$COND} is how it has been defined (`', `+', or `:'),
509 # - $var_owner{$VAR}{$COND} tells who owns the variable (VAR_AUTOMAKE,
510 # VAR_CONFIGURE, or VAR_MAKEFILE).
516 # Possible values for var_owner. Defined so that the owner of
517 # a variable can only be increased (e.g Automake should not
518 # override a configure or Makefile variable).
519 use constant VAR_AUTOMAKE => 0; # Variable defined by Automake.
520 use constant VAR_CONFIGURE => 1;# Variable defined in configure.ac.
521 use constant VAR_MAKEFILE => 2; # Variable defined in Makefile.am.
523 # This holds a 1 if a particular variable was examined.
526 # This holds the names which are targets. These also appear in
527 # %contents. $targets{TARGET}{COND} is the location of the definition
528 # of TARGET for condition COND. TARGETs should not include
529 # a trailing $(EXEEXT), we record this in %target_name.
532 # $target_source{TARGET}{COND} is the filename where TARGET
533 # were defined for condition COND. Note this must be a
534 # filename, *without* any line number.
537 # $target_name{TARGET}{COND} is the real name of TARGET (in condition COND).
538 # The real name is often TARGET or TARGET$(EXEEXT), and TARGET never
542 # $target_owner{TARGET}{COND} the owner of TARGET in condition COND.
544 use constant TARGET_AUTOMAKE => 0; # Target defined by Automake.
545 use constant TARGET_USER => 1; # Target defined in the user's Makefile.am.
547 # This is the conditional stack.
550 # This holds the set of included files.
553 # This holds a list of directories which we must create at `dist'
554 # time. This is used in some strange scenarios involving weird
555 # AC_OUTPUT commands.
558 # List of dependencies for the obvious targets.
563 # Holds the dependencies of targets which dependencies are factored.
564 # Typically, `.PHONY' will appear in plenty of *.am files, but must
565 # be output once. Arguably all pure dependencies could be subject
566 # to this factorization, but it is not unpleasant to have paragraphs
567 # in Makefile: keeping related stuff altogether.
570 # Holds the factored actions. Tied to %DEPENDENCIES, i.e., filled
571 # only when keys exists in %DEPENDENCIES.
574 # Keys in this hash table are files to delete. The associated
575 # value tells when this should happen (MOSTLY_CLEAN, DIST_CLEAN, etc.)
578 # Keys in this hash table are object files or other files in
579 # subdirectories which need to be removed. This only holds files
580 # which are created by compilations. The value in the hash indicates
581 # when the file should be removed.
582 my %compile_clean_files;
584 # Keys in this hash table are directories where we expect to build a
585 # libtool object. We use this information to decide what directories
587 my %libtool_clean_directories;
589 # Value of `$(SOURCES)', used by tags.am.
591 # Sources which go in the distribution.
594 # This hash maps object file names onto their corresponding source
595 # file names. This is used to ensure that each object is created
596 # by a single source file.
599 # This hash maps object file names onto an integer value representing
600 # whether this object has been built via ordinary compilation or
601 # libtool compilation (the COMPILE_* constants).
602 my %object_compilation_map;
605 # This keeps track of the directories for which we've already
606 # created dirstamp code.
616 # Options from AUTOMAKE_OPTIONS.
619 # Whether or not dependencies are handled. Can be further changed
621 my $use_dependencies;
623 # This is a list of all targets to run during "make dist".
626 # Keys in this hash are the basenames of files which must depend on
627 # ansi2knr. Values are either the empty string, or the directory in
628 # which the ANSI source file appears; the directory must have a
632 # This maps the source extension for all suffix rule seen to
633 # a \hash whose keys are the possible output extensions.
635 # Note that this is transitively closed by construction:
637 # exists $suffix_rules{$ext1}{$ext2}
638 # && exists $suffix_rules{$ext2}{$ext3}
640 # exists $suffix_rules{$ext1}{$ext3}
642 # So it's easy to check whether '.foo' can be transformed to '.$(OBJEXT)'
643 # by checking whether $suffix_rules{'.foo'}{'.$(OBJEXT)'} exist. This
644 # will work even if transforming '.foo' to '.$(OBJEXT)' involves a chain
645 # of several suffix rules.
647 # The value of `$suffix_rules{$ext1}{$ext2}' is the a pair
648 # `[ $next_sfx, $dist ]' where `$next_sfx' is target suffix
649 # for the next rule to use to reach '$ext2', and `$dist' the
650 # distance to `$ext2'.
653 # This is the name of the redirect `all' target to use.
656 # This keeps track of which extensions we've seen (that we care
660 # This is random scratch space for the language finish functions.
661 # Don't randomly overwrite it; examine other uses of keys first.
662 my %language_scratch;
664 # We keep track of which objects need special (per-executable)
665 # handling on a per-language basis.
666 my %lang_specific_files;
668 # This is set when `handle_dist' has finished. Once this happens,
669 # we should no longer push on dist_common.
672 # Used to store a set of linkers needed to generate the sources currently
673 # under consideration.
676 # True if we need `LINK' defined. This is a hack.
679 # This is the list of such variables to output.
680 # FIXME: Might be useless actually.
683 # Was get_object_extension run?
684 # FIXME: This is a hack. a better switch should be found.
685 my $get_object_extension_was_run;
687 # Contains a stack of `from' parts of variable substitutions currently in
691 # Contains a stack of `to' parts of variable substitutions currently in
695 # This keeps track of all variables defined by subobjname.
696 # The value stored is the variable names.
697 # The key has the form "(COND1)VAL1(COND2)VAL2..." where VAL1 and VAL2
698 # are the values of the variable for condition COND1 and COND2.
701 # This hash records helper variables used to implement '+=' in conditionals.
702 # Keys have the form "VAR:CONDITIONS". The value associated to a key is
703 # the named of the helper variable used to append to VAR in CONDITIONS.
707 ## --------------------------------- ##
708 ## Forward subroutine declarations. ##
709 ## --------------------------------- ##
710 sub register_language (%);
711 sub file_contents_internal ($$%);
712 sub define_objects_from_sources ($$$$$$$);
715 # &initialize_per_input ()
716 # ------------------------
717 # (Re)-Initialize per-Makefile.am variables.
718 sub initialize_per_input ()
720 reset_local_duplicates ();
723 $am_relative_dir = '';
730 $output_trailer = '';
771 # Installing/uninstalling.
772 'install-data-am' => [],
773 'install-exec-am' => [],
774 'uninstall-am' => [],
777 'uninstall-man' => [],
779 'install-info' => [],
780 'install-info-am' => [],
781 'uninstall-info' => [],
783 'installcheck-am' => [],
787 'mostlyclean-am' => [],
788 'maintainer-clean-am' => [],
789 'distclean-am' => [],
792 'maintainer-clean' => [],
809 %object_compilation_map = ();
815 $strictness = $default_strictness;
816 $strictness_name = $default_strictness_name;
820 $use_dependencies = $cmdline_use_dependencies;
827 # The first time we initialize the variables,
828 # we save the value of $suffix_rules.
829 if (defined $suffix_rules_default)
831 $suffix_rules = $suffix_rules_default;
835 $suffix_rules_default = $suffix_rules;
840 %extension_seen = ();
842 %language_scratch = ();
844 %lang_specific_files = ();
846 $handle_dist_run = 0;
852 $get_object_extension_was_run = 0;
854 %compile_clean_files = ();
856 # We always include `.'. This isn't strictly correct.
857 %libtool_clean_directories = ('.' => 1);
865 ################################################################
867 # Initialize our list of error/warning channels.
868 # Do not forget to update &usage and the manual
869 # if you add or change a warning channel.
872 register_channel 'fatal', type => 'fatal';
874 register_channel 'error', type => 'error';
875 # Errors related to GNU Standards.
876 register_channel 'error-gnu', type => 'error';
877 # Errors related to GNU Standards that should be warnings in `foreign' mode.
878 register_channel 'error-gnu/warn', type => 'error';
879 # Errors related to GNITS Standards (silent by default).
880 register_channel 'error-gnits', type => 'error', silent => 1;
882 register_channel 'automake', type => 'fatal', backtrace => 1,
883 header => ("####################\n" .
884 "## Internal Error ##\n" .
885 "####################\n"),
886 footer => "\nPlease contact <bug-automake\@gnu.org>.";
888 # Warnings related to GNU Coding Standards.
889 register_channel 'gnu', type => 'warning';
890 # Warnings about obsolete features (silent by default).
891 register_channel 'obsolete', type => 'warning', silent => 1;
892 # Warnings about non-portable constructs.
893 register_channel 'portability', type => 'warning', silent => 1;
894 # Weird syntax, unused variables, typos...
895 register_channel 'syntax', type => 'warning';
896 # Warnings about unsupported (or mis-supported) features.
897 register_channel 'unsupported', type => 'warning';
900 register_channel 'verb', type => 'debug', silent => 1;
901 # Informative messages.
902 register_channel 'note', type => 'debug', silent => 0;
905 # Initialize our list of languages that are internally supported.
908 register_language ('name' => 'c',
910 'config_vars' => ['CC'],
913 'flags' => ['CFLAGS', 'CPPFLAGS'],
914 'compiler' => 'COMPILE',
915 'compile' => '$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)',
919 'link' => '$(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
920 'compile_flag' => '-c',
921 'extensions' => ['.c'],
922 '_finish' => \&lang_c_finish);
925 register_language ('name' => 'cxx',
927 'config_vars' => ['CXX'],
928 'linker' => 'CXXLINK',
929 'link' => '$(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
931 'flags' => ['CXXFLAGS', 'CPPFLAGS'],
932 'compile' => '$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)',
933 'compiler' => 'CXXCOMPILE',
934 'compile_flag' => '-c',
935 'output_flag' => '-o',
939 'extensions' => ['.c++', '.cc', '.cpp', '.cxx', '.C']);
942 register_language ('name' => 'objc',
943 'Name' => 'Objective C',
944 'config_vars' => ['OBJC'],
945 'linker' => 'OBJCLINK',,
946 'link' => '$(OBJCLD) $(AM_OBJCFLAGS) $(OBJCFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
948 'flags' => ['OBJCFLAGS', 'CPPFLAGS'],
949 'compile' => '$(OBJC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_OBJCFLAGS) $(OBJCFLAGS)',
950 'compiler' => 'OBJCCOMPILE',
951 'compile_flag' => '-c',
952 'output_flag' => '-o',
956 'extensions' => ['.m']);
959 register_language ('name' => 'header',
961 'extensions' => ['.h', '.H', '.hxx', '.h++', '.hh',
964 'output_extensions' => sub { return () },
966 '_finish' => sub { });
969 register_language ('name' => 'yacc',
971 'config_vars' => ['YACC'],
972 'flags' => ['YFLAGS'],
973 'compile' => '$(YACC) $(YFLAGS) $(AM_YFLAGS)',
974 'compiler' => 'YACCCOMPILE',
975 'extensions' => ['.y'],
976 'output_extensions' => sub { (my $ext = $_[0]) =~ tr/y/c/;
978 'rule_file' => 'yacc',
979 '_finish' => \&lang_yacc_finish,
980 '_target_hook' => \&lang_yacc_target_hook);
981 register_language ('name' => 'yaccxx',
982 'Name' => 'Yacc (C++)',
983 'config_vars' => ['YACC'],
984 'rule_file' => 'yacc',
985 'flags' => ['YFLAGS'],
986 'compiler' => 'YACCCOMPILE',
987 'compile' => '$(YACC) $(YFLAGS) $(AM_YFLAGS)',
988 'extensions' => ['.y++', '.yy', '.yxx', '.ypp'],
989 'output_extensions' => sub { (my $ext = $_[0]) =~ tr/y/c/;
991 '_finish' => \&lang_yacc_finish,
992 '_target_hook' => \&lang_yacc_target_hook);
995 register_language ('name' => 'lex',
997 'config_vars' => ['LEX'],
998 'rule_file' => 'lex',
999 'flags' => ['LFLAGS'],
1000 'compile' => '$(LEX) $(LFLAGS) $(AM_LFLAGS)',
1001 'compiler' => 'LEXCOMPILE',
1002 'extensions' => ['.l'],
1003 'output_extensions' => sub { (my $ext = $_[0]) =~ tr/l/c/;
1005 '_finish' => \&lang_lex_finish,
1006 '_target_hook' => \&lang_lex_target_hook);
1007 register_language ('name' => 'lexxx',
1008 'Name' => 'Lex (C++)',
1009 'config_vars' => ['LEX'],
1010 'rule_file' => 'lex',
1011 'flags' => ['LFLAGS'],
1012 'compile' => '$(LEX) $(LFLAGS) $(AM_LFLAGS)',
1013 'compiler' => 'LEXCOMPILE',
1014 'extensions' => ['.l++', '.ll', '.lxx', '.lpp'],
1015 'output_extensions' => sub { (my $ext = $_[0]) =~ tr/l/c/;
1017 '_finish' => \&lang_lex_finish,
1018 '_target_hook' => \&lang_lex_target_hook);
1021 register_language ('name' => 'asm',
1022 'Name' => 'Assembler',
1023 'config_vars' => ['CCAS', 'CCASFLAGS'],
1025 'flags' => ['CCASFLAGS'],
1026 # Users can set AM_ASFLAGS to includes DEFS, INCLUDES,
1027 # or anything else required. They can also set AS.
1028 'compile' => '$(CCAS) $(AM_CCASFLAGS) $(CCASFLAGS)',
1029 'compiler' => 'CCASCOMPILE',
1030 'compile_flag' => '-c',
1031 'extensions' => ['.s', '.S'],
1033 # With assembly we still use the C linker.
1034 '_finish' => \&lang_c_finish);
1037 register_language ('name' => 'f77',
1038 'Name' => 'Fortran 77',
1039 'linker' => 'F77LINK',
1040 'link' => '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
1041 'flags' => ['FFLAGS'],
1042 'compile' => '$(F77) $(AM_FFLAGS) $(FFLAGS)',
1043 'compiler' => 'F77COMPILE',
1044 'compile_flag' => '-c',
1045 'output_flag' => '-o',
1049 'extensions' => ['.f', '.for', '.f90']);
1051 # Preprocessed Fortran 77
1053 # The current support for preprocessing Fortran 77 just involves
1054 # passing `$(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS)
1055 # $(CPPFLAGS)' as additional flags to the Fortran 77 compiler, since
1056 # this is how GNU Make does it; see the `GNU Make Manual, Edition 0.51
1057 # for `make' Version 3.76 Beta' (specifically, from info file
1058 # `(make)Catalogue of Rules').
1060 # A better approach would be to write an Autoconf test
1061 # (i.e. AC_PROG_FPP) for a Fortran 77 preprocessor, because not all
1062 # Fortran 77 compilers know how to do preprocessing. The Autoconf
1063 # macro AC_PROG_FPP should test the Fortran 77 compiler first for
1064 # preprocessing capabilities, and then fall back on cpp (if cpp were
1066 register_language ('name' => 'ppf77',
1067 'Name' => 'Preprocessed Fortran 77',
1068 'config_vars' => ['F77'],
1069 'linker' => 'F77LINK',
1070 'link' => '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
1073 'flags' => ['FFLAGS', 'CPPFLAGS'],
1074 'compiler' => 'PPF77COMPILE',
1075 'compile' => '$(F77) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FFLAGS) $(FFLAGS)',
1076 'compile_flag' => '-c',
1077 'output_flag' => '-o',
1079 'extensions' => ['.F']);
1082 register_language ('name' => 'ratfor',
1084 'config_vars' => ['F77'],
1085 'linker' => 'F77LINK',
1086 'link' => '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
1089 'flags' => ['RFLAGS', 'FFLAGS'],
1090 # FIXME also FFLAGS.
1091 'compile' => '$(F77) $(AM_FFLAGS) $(FFLAGS) $(AM_RFLAGS) $(RFLAGS)',
1092 'compiler' => 'RCOMPILE',
1093 'compile_flag' => '-c',
1094 'output_flag' => '-o',
1096 'extensions' => ['.r']);
1099 register_language ('name' => 'java',
1101 'config_vars' => ['GCJ'],
1102 'linker' => 'GCJLINK',
1103 'link' => '$(GCJLD) $(AM_GCJFLAGS) $(GCJFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
1105 'flags' => ['GCJFLAGS'],
1106 'compile' => '$(GCJ) $(AM_GCJFLAGS) $(GCJFLAGS)',
1107 'compiler' => 'GCJCOMPILE',
1108 'compile_flag' => '-c',
1109 'output_flag' => '-o',
1113 'extensions' => ['.java', '.class', '.zip', '.jar']);
1115 ################################################################
1117 # Parse the WARNINGS environnent variable.
1120 # Parse command line.
1123 # Do configure.ac scan only once.
1124 &scan_autoconf_files;
1126 &fatal ("no `Makefile.am' found or specified\n")
1129 my $automake_has_run = 0;
1133 if ($automake_has_run)
1135 &verb ('processing Makefiles another time to fix them up.');
1136 &prog_error ('running more than two times should never be needed.')
1137 if $automake_has_run >= 2;
1139 $automake_needs_to_reprocess_all_files = 0;
1141 # Now do all the work on each file.
1142 # This guy must be local otherwise it's private to the loop.
1143 use vars '$am_file';
1145 foreach $am_file (@input_files)
1147 if (! -f ($am_file . '.am'))
1149 &error ("`$am_file.am' does not exist");
1153 &generate_makefile ($output_files{$am_file}, $am_file);
1156 ++$automake_has_run;
1158 while ($automake_needs_to_reprocess_all_files);
1162 ################################################################
1164 # Error reporting functions.
1166 # prog_error ($MESSAGE, [%OPTIONS])
1167 # -------------------------------
1168 # Signal a programming error, display $MESSAGE, and exit 1.
1169 sub prog_error ($;%)
1171 my ($msg, %opts) = @_;
1172 msg 'automake', '', $msg, %opts;
1175 # error ($WHERE, $MESSAGE, [%OPTIONS])
1177 # ------------------------------------
1178 # Uncategorized errors.
1181 my ($where, $msg, %opts) = @_;
1182 msg ('error', $where, $msg, %opts);
1185 # fatal ($WHERE, $MESSAGE, [%OPTIONS])
1187 # ----------------------------------
1191 my ($where, $msg, %opts) = @_;
1192 msg ('fatal', $where, $msg, %opts);
1195 # err_var ($VARNAME, $MESSAGE, [%OPTIONS])
1196 # ----------------------------------------
1197 # Uncategorized errors about variables.
1200 msg_var ('error', @_);
1203 # err_target ($TARGETNAME, $MESSAGE, [%OPTIONS])
1204 # ----------------------------------------------
1205 # Uncategorized errors about targets.
1206 sub err_target ($$;%)
1208 msg_target ('error', @_);
1211 # err_cond_target ($COND, $TARGETNAME, $MESSAGE, [%OPTIONS])
1212 # ----------------------------------------------------------
1213 # Uncategorized errors about conditional targets.
1214 sub err_cond_target ($$$;%)
1216 msg_cond_target ('error', @_);
1219 # err_am ($MESSAGE, [%OPTIONS])
1220 # -----------------------------
1221 # Uncategorized errors about the current Makefile.am.
1224 msg_am ('error', @_);
1227 # err_ac ($MESSAGE, [%OPTIONS])
1228 # -----------------------------
1229 # Uncategorized errors about configure.ac.
1232 msg_ac ('error', @_);
1235 # msg_cond_var ($CHANNEL, $COND, $VARNAME, $MESSAGE, [%OPTIONS])
1236 # --------------------------------------------------------------
1237 # Messages about conditional variable.
1238 sub msg_cond_var ($$$$;%)
1240 my ($channel, $cond, $var, $msg, %opts) = @_;
1241 msg $channel, $var_location{$var}{$cond}, $msg, %opts;
1244 # msg_var ($CHANNEL, $VARNAME, $MESSAGE, [%OPTIONS])
1245 # --------------------------------------------------
1246 # Messages about variables.
1249 my ($channel, $var, $msg, %opts) = @_;
1250 # Don't know which condition is concerned. Pick any.
1251 my $cond = (keys %{$var_value{$var}})[0];
1252 msg_cond_var $channel, $cond, $var, $msg, %opts;
1255 # msg_cond_target ($CHANNEL, $COND, $TARGETNAME, $MESSAGE, [%OPTIONS])
1256 # --------------------------------------------------------------------
1257 # Messages about conditional targets.
1258 sub msg_cond_target ($$$$;%)
1260 my ($channel, $cond, $target, $msg, %opts) = @_;
1261 msg $channel, $targets{$target}{$cond}, $msg, %opts;
1264 # msg_target ($CHANNEL, $TARGETNAME, $MESSAGE, [%OPTIONS])
1265 # --------------------------------------------------------
1266 # Messages about targets.
1267 sub msg_target ($$$;%)
1269 my ($channel, $target, $msg, %opts) = @_;
1270 # Don't know which condition is concerned. Pick any.
1271 my $cond = (keys %{$targets{$target}})[0];
1272 msg_cond_target ($channel, $cond, $target, $msg, %opts);
1275 # msg_am ($CHANNEL, $MESSAGE, [%OPTIONS])
1276 # ---------------------------------------
1277 # Messages about about the current Makefile.am.
1280 my ($channel, $msg, %opts) = @_;
1281 msg $channel, "${am_file}.am", $msg, %opts;
1284 # msg_ac ($CHANNEL, $MESSAGE, [%OPTIONS])
1285 # ---------------------------------------
1286 # Messages about about configure.ac.
1289 my ($channel, $msg, %opts) = @_;
1290 msg $channel, $configure_ac, $msg, %opts;
1294 # reject_var ($VAR, $ERROR_MSG)
1295 # -----------------------------
1298 my ($var, $msg) = @_;
1299 if (variable_defined ($var))
1308 # reject_target ($VAR, $ERROR_MSG)
1309 # --------------------------------
1310 sub reject_target ($$)
1312 my ($target, $msg) = @_;
1313 if (target_defined ($target))
1315 err_target $target, $msg;
1321 # verb ($MESSAGE, [%OPTIONS])
1322 # ---------------------------
1325 my ($msg, %opts) = @_;
1326 msg 'verb', '', $msg, %opts;
1329 ################################################################
1333 # Return a configure-style substitution using the indicated text.
1334 # We do this to avoid having the substitutions directly in automake.in;
1335 # when we do that they are sometimes removed and this causes confusion
1340 return '@' . $text . '@';
1343 ################################################################
1347 # &backname ($REL-DIR)
1348 # --------------------
1349 # If I `cd $REL-DIR', then to come back, I should `cd $BACKPATH'.
1350 # For instance `src/foo' => `../..'.
1351 # Works with non strictly increasing paths, i.e., `src/../lib' => `..'.
1356 foreach (split (/\//, $file))
1358 next if $_ eq '.' || $_ eq '';
1368 return join ('/', @res) || '.';
1371 ################################################################
1373 # Pattern that matches all know input extensions (i.e. extensions used
1374 # by the languages supported by Automake). Using this pattern
1375 # (instead of `\..*$') to match extensions allows Automake to support
1376 # dot-less extensions.
1377 my $KNOWN_EXTENSIONS_PATTERN = "";
1378 my @known_extensions_list = ();
1380 # accept_extensions (@EXTS)
1381 # -------------------------
1382 # Update $KNOWN_EXTENSIONS_PATTERN to recognize the extensions
1383 # listed @EXTS. Extensions should contain a dot if needed.
1384 sub accept_extensions (@)
1386 push @known_extensions_list, @_;
1387 $KNOWN_EXTENSIONS_PATTERN =
1388 '(?:' . join ('|', map (quotemeta, @known_extensions_list)) . ')';
1391 # var_SUFFIXES_trigger ($TYPE, $VALUE)
1392 # ------------------------------------
1393 # This is called automagically by macro_define() when SUFFIXES
1394 # is defined ($TYPE eq '') or appended ($TYPE eq '+').
1395 # The work here needs to be performed as a side-effect of the
1396 # macro_define() call because SUFFIXES definitions impact
1397 # on $KNOWN_EXTENSIONS_PATTERN, and $KNOWN_EXTENSIONS_PATTERN
1398 # are used when parsing the input am file.
1399 sub var_SUFFIXES_trigger ($$)
1401 my ($type, $value) = @_;
1402 accept_extensions (split (' ', $value));
1405 ################################################################
1408 # switch_warning ($CATEGORY)
1409 # --------------------------
1410 # If $CATEGORY is mumble, turn on the mumble channel.
1411 # If it's no-mumble, turn mumble off.
1412 # Alse handle `all' and `none' for completeness.
1413 sub switch_warning ($)
1418 if ($cat =~ /^no-(.*)$/)
1426 setup_channel_type 'warning', silent => $has_no;
1428 elsif ($cat eq 'none')
1430 setup_channel_type 'warning', silent => ! $has_no;
1432 elsif ($cat eq 'error')
1434 $warnings_are_errors = ! $has_no;
1435 # Set exit code if Perl warns about something
1436 # (like uninitialized variables).
1438 $has_no ? 'DEFAULT' : sub { print STDERR @_; $exit_code = 1; };
1440 elsif (channel_type ($cat) eq 'warning')
1442 setup_channel $cat, silent => $has_no;
1453 # Honor the WARNINGS environment variable.
1454 sub parse_WARNINGS ($$)
1456 if (exists $ENV{'WARNINGS'})
1458 # Ignore unknown categories. This is required because WARNINGS
1459 # should be honored by many tools.
1460 switch_warning $_ foreach (split (',', $ENV{'WARNINGS'}));
1464 # parse_warning ($OPTION, $ARGUMENT)
1465 # ----------------------------------
1466 # Parse the argument of --warning=CATEGORY or -WCATEGORY.
1467 sub parse_warnings ($$)
1469 my ($opt, $categories) = @_;
1471 foreach my $cat (split (',', $categories))
1473 msg 'unsupported', "unknown warning category `$cat'"
1474 if switch_warning $cat;
1478 # Parse command line.
1479 sub parse_arguments ()
1482 &set_strictness ('gnu');
1486 'libdir:s' => \$libdir,
1487 'gnu' => sub { &set_strictness ('gnu'); },
1488 'gnits' => sub { &set_strictness ('gnits'); },
1489 'cygnus' => \$cygnus_mode,
1490 'foreign' => sub { &set_strictness ('foreign'); },
1491 'include-deps' => sub { $cmdline_use_dependencies = 1; },
1492 'i|ignore-deps' => sub { $cmdline_use_dependencies = 0; },
1493 'no-force' => sub { $force_generation = 0; },
1494 'f|force-missing' => \$force_missing,
1495 'o|output-dir:s' => \$output_directory,
1496 'a|add-missing' => \$add_missing,
1497 'c|copy' => \$copy_missing,
1498 'v|verbose' => sub { setup_channel 'verb', silent => 0; },
1499 'W|warnings:s' => \&parse_warnings,
1500 # These long options (--Werror and --Wno-error) for backward
1501 # compatibility. Use -Werror and -Wno-error today.
1502 'Werror' => sub { parse_warnings 'W', 'error'; },
1503 'Wno-error' => sub { parse_warnings 'W', 'no-error'; },
1507 Getopt::Long::config ("bundling", "pass_through");
1509 # See if --version or --help is used. We want to process these before
1510 # anything else because the GNU Coding Standards require us to
1511 # `exit 0' after processing these options, and we can't garanty this
1512 # if we treat other options first. (Handling other options first
1513 # could produce error diagnostics, and in this condition it is
1514 # confusing if Automake `exit 0'.)
1515 my %options_1st_pass =
1517 'version' => \&version,
1519 # Recognize all other options (and their arguments) but do nothing.
1520 map { $_ => sub {} } (keys %options)
1522 my @ARGV_backup = @ARGV;
1523 Getopt::Long::GetOptions %options_1st_pass
1525 @ARGV = @ARGV_backup;
1527 # Now *really* process the options. This time we know
1528 # that --help and --version are not present.
1529 Getopt::Long::GetOptions %options
1532 if (defined $output_directory)
1534 msg 'obsolete', "`--output-dir' is deprecated\n";
1538 # In the next release we'll remove this entirely.
1539 $output_directory = '.';
1542 foreach my $arg (@ARGV)
1546 fatal ("unrecognized option `$arg'\n"
1547 . "Try `$0 --help' for more information.");
1550 # Handle $local:$input syntax. Note that we only examine the
1551 # first ":" file to see if it is automake input; the rest are
1552 # just taken verbatim. We still keep all the files around for
1553 # dependency checking, however.
1554 my ($local, $input, @rest) = split (/:/, $arg);
1561 # Strip .in; later on .am is tacked on. That is how the
1562 # automake input file is found. Maybe not the best way, but
1563 # it is easy to explain.
1565 or fatal "invalid input file name `$arg'\n.";
1567 push (@input_files, $input);
1568 $output_files{$input} = join (':', ($local, @rest));
1571 # Take global strictness from whatever we currently have set.
1572 $default_strictness = $strictness;
1573 $default_strictness_name = $strictness_name;
1576 ################################################################
1578 # Generate a Makefile.in given the name of the corresponding Makefile and
1579 # the name of the file output by config.status.
1580 sub generate_makefile
1582 my ($output, $makefile) = @_;
1584 # Reset all the Makefile.am related variables.
1585 &initialize_per_input;
1587 # Any warning setting now local to this Makefile.am.
1589 # AUTOMAKE_OPTIONS can contains -W flags to disable or enable
1590 # warnings for this file. So hold any warning issued before
1591 # we have processed AUTOMAKE_OPTIONS.
1592 &buffer_messages ('warning');
1594 # Name of input file ("Makefile.am") and output file
1595 # ("Makefile.in"). These have no directory components.
1596 $am_file_name = basename ($makefile) . '.am';
1597 $in_file_name = basename ($makefile) . '.in';
1599 # $OUTPUT is encoded. If it contains a ":" then the first element
1600 # is the real output file, and all remaining elements are input
1601 # files. We don't scan or otherwise deal with these input file,
1602 # other than to mark them as dependencies. See
1603 # &scan_autoconf_files for details.
1604 my (@secondary_inputs);
1605 ($output, @secondary_inputs) = split (/:/, $output);
1607 $relative_dir = dirname ($output);
1608 $am_relative_dir = dirname ($makefile);
1610 &read_main_am_file ($makefile . '.am');
1611 if (&handle_options)
1613 # Process buffered warnings.
1615 # Fatal error. Just return, so we can continue with next file.
1618 # Process buffered warnings.
1621 # There are a few install-related variables that you should not define.
1622 foreach my $var ('PRE_INSTALL', 'POST_INSTALL', 'NORMAL_INSTALL')
1624 if (exists $var_owner{$var})
1626 prog_error "\$var_owner{$var}{TRUE} doesn't exist"
1627 unless exists $var_owner{$var}{'TRUE'};
1628 reject_var $var, "`$var' should not be defined"
1629 if $var_owner{$var}{'TRUE'} != VAR_AUTOMAKE;
1633 # Catch some obsolete variables.
1634 msg_var ('obsolete', 'INCLUDES',
1635 "`INCLUDES' is the old name for `AM_CPPFLAGS'")
1636 if variable_defined ('INCLUDES');
1638 # At the toplevel directory, we might need config.guess, config.sub
1639 # or libtool scripts (ltconfig and ltmain.sh).
1640 if ($relative_dir eq '.')
1642 # AC_CANONICAL_HOST and AC_CANONICAL_SYSTEM need config.guess and
1644 require_conf_file ($canonical_location, FOREIGN,
1645 'config.guess', 'config.sub')
1649 # We still need Makefile.in here, because sometimes the `dist'
1650 # target doesn't re-run automake.
1651 if ($am_relative_dir eq $relative_dir)
1653 # Only distribute the files if they are in the same subdir as
1654 # the generated makefile.
1655 &push_dist_common ($in_file_name, $am_file_name);
1658 push (@sources, '$(SOURCES)')
1659 if variable_defined ('SOURCES');
1661 # Must do this after reading .am file. See read_main_am_file to
1662 # understand weird tricks we play there with variables.
1663 &define_variable ('subdir', $relative_dir);
1665 # Check first, because we might modify some state.
1667 &check_gnu_standards;
1668 &check_gnits_standards;
1670 &handle_configure ($output, $makefile, @secondary_inputs);
1673 &handle_ltlibraries;
1677 # This must run first so that the ANSI2KNR definition is generated
1678 # before it is used by the _.c rules. We have to do this because
1679 # a variable which is used in a dependency must be defined before
1680 # the target, or else make won't properly see it.
1682 # This must be run after all the sources are scanned.
1685 # We have to run this after dealing with all the programs.
1688 # Re-init SOURCES. FIXME: other code shouldn't depend on this
1689 # (but currently does).
1690 macro_define ('SOURCES', VAR_AUTOMAKE, '', 'TRUE', "@sources", 'internal');
1691 define_pretty_variable ('DIST_SOURCES', '', @dist_sources);
1703 &handle_minor_options;
1706 # This must come after most other rules.
1707 &handle_dist ($makefile);
1710 &do_check_merge_target;
1711 &handle_all ($output);
1714 if (variable_defined ('lib_LTLIBRARIES') &&
1715 variable_defined ('bin_PROGRAMS'))
1717 $output_rules .= "install-binPROGRAMS: install-libLTLIBRARIES\n\n";
1720 &handle_installdirs;
1722 &handle_factored_dependencies;
1726 if (! -d ($output_directory . '/' . $am_relative_dir))
1728 mkdir ($output_directory . '/' . $am_relative_dir, 0755);
1731 my ($out_file) = $output_directory . '/' . $makefile . ".in";
1732 if (! $force_generation && -e $out_file)
1734 my ($am_time) = (stat ($makefile . '.am'))[9];
1735 my ($in_time) = (stat ($out_file))[9];
1736 # FIXME: should cache these times.
1737 my ($conf_time) = (stat ($configure_ac))[9];
1738 # FIXME: how to do unsigned comparison?
1739 if ($am_time < $in_time || $am_time < $conf_time)
1741 # No need to update.
1744 if (-f 'aclocal.m4')
1746 my ($acl_time) = (stat _)[9];
1747 return if ($am_time < $acl_time);
1754 or fatal "cannot remove $out_file: $!\n";
1756 my $gm_file = new Automake::XFile "> $out_file";
1757 verb "creating $makefile.in";
1759 print $gm_file $output_vars;
1760 # We make sure that `all:' is the first target.
1761 print $gm_file $output_all;
1762 print $gm_file $output_header;
1763 print $gm_file $output_rules;
1764 print $gm_file $output_trailer;
1766 # Back out any warning setting.
1767 &drop_channel_setup;
1770 ################################################################
1772 # A version is a string that looks like
1773 # MAJOR.MINOR[.MICRO][ALPHA][-FORK]
1775 # MAJOR, MINOR, and MICRO are digits, ALPHA is a character, and
1776 # FORK any alphanumeric word.
1777 # Usually, ALPHA is used to label alpha releases or intermediate snapshots,
1778 # FORK is used for CVS branches or patched releases, and MICRO is used
1779 # for bug fixes releases on the MAJOR.MINOR branch.
1781 # For the purpose of ordering, 1.4 is the same as 1.4.0, but 1.4g is
1782 # the same as 1.4.99g. The FORK identifier is ignored in the
1783 # ordering, except when it looks like -pMINOR[ALPHA]: some versions
1784 # were labelled like 1.4-p3a, this is the same as an alpha release
1785 # labelled 1.4.3a. Yes it's horrible, but Automake did not support
1786 # two-dot versions in the past.
1788 # version_split (VERSION)
1789 # -----------------------
1790 # Split a version string into the corresponding (MAJOR, MINOR, MICRO,
1791 # ALPHA, FORK) tuple. For instance "1.4g" would be split into
1792 # (1, 4, 99, 'g', '').
1793 # Return () on error.
1794 sub version_split ($)
1798 # Special case for versions like 1.4-p2a.
1799 if ($ver =~ /^(\d+)\.(\d+)(?:-p(\d+)([a-z]+)?)$/)
1801 return ($1, $2, $3, $4 || '', '');
1804 elsif ($ver =~ /^(\d+)\.(\d+)(?:\.(\d+))?([a-z])?(?:-([A-Za-z0-9]+))?$/)
1806 return ($1, $2, $3 || (defined $4 ? 99 : 0), $4 || '', $5 || '');
1811 # version_compare (\@LVERSION, \@RVERSION)
1812 # ----------------------------------------
1813 # Return 1 if LVERSION > RVERSION,
1814 # -1 if LVERSION < RVERSION,
1815 # 0 if LVERSION = RVERSION.
1816 sub version_compare (\@\@)
1823 return 1 if ($l[$i] > $r[$i]);
1824 return -1 if ($l[$i] < $r[$i]);
1828 return 1 if ($l[$i] gt $r[$i]);
1829 return -1 if ($l[$i] lt $r[$i]);
1834 # Handles the logic of requiring a version number in AUTOMAKE_OPTIONS.
1835 # Return 0 if the required version is satisfied, 1 otherwise.
1836 sub version_check ($)
1838 my ($required) = @_;
1839 my @version = version_split $VERSION;
1840 my @required = version_split $required;
1842 prog_error "version is incorrect: $VERSION"
1845 # This should not happen, because process_option_list and split_version
1846 # use similar regexes.
1847 prog_error "required version is incorrect: $required"
1848 if $#required == -1;
1850 # If we require 3.4n-foo then we require something
1851 # >= 3.4n, with the `foo' fork identifier.
1853 if ($required[4] ne '' && $required[4] ne $version[4]);
1855 return 0 > version_compare @version, @required;
1859 # process_option_list ($CONFIG, @OPTIONS)
1860 # ------------------------------
1861 # Process a list of options. Return 1 on error, 0 otherwise.
1862 # This is a helper for handle_options. CONFIG is true if we're
1863 # handling global options.
1864 sub process_option_list
1866 my ($config, @list) = @_;
1868 # FIXME: We should disallow conditional deffinitions of AUTOMAKE_OPTIONS.
1869 my $where = ($config ?
1870 $seen_init_automake :
1871 $var_location{'AUTOMAKE_OPTIONS'}{'TRUE'});
1876 if ($_ eq 'gnits' || $_ eq 'gnu' || $_ eq 'foreign')
1878 &set_strictness ($_);
1880 elsif ($_ eq 'cygnus')
1884 elsif (/^(.*\/)?ansi2knr$/)
1886 # An option like "../lib/ansi2knr" is allowed. With no
1887 # path prefix, we assume the required programs are in this
1888 # directory. We save the actual option for later.
1889 $options{'ansi2knr'} = $_;
1891 elsif ($_ eq 'no-installman' || $_ eq 'no-installinfo'
1892 || $_ eq 'dist-shar' || $_ eq 'dist-zip'
1893 || $_ eq 'dist-tarZ' || $_ eq 'dist-bzip2'
1894 || $_ eq 'dejagnu' || $_ eq 'no-texinfo.tex'
1895 || $_ eq 'readme-alpha' || $_ eq 'check-news'
1896 || $_ eq 'subdir-objects' || $_ eq 'nostdinc'
1897 || $_ eq 'no-exeext' || $_ eq 'no-define'
1898 || $_ eq 'std-options')
1900 # Explicitly recognize these.
1902 elsif ($_ eq 'no-dependencies')
1904 $use_dependencies = 0;
1906 elsif (/^\d+\.\d+(?:\.\d+)?[a-z]?(?:-[A-Za-z0-9]+)?$/)
1908 # Got a version number.
1909 if (version_check $&)
1911 error ($where, "require Automake $_, but have $VERSION",
1912 uniq_scope => US_GLOBAL);
1916 elsif (/^(?:--warnings=|-W)(.*)$/)
1918 foreach my $cat (split (',', $1))
1920 msg 'unsupported', $where, "unknown warning category `$cat'"
1921 if switch_warning $cat;
1926 error ($where, "option `$_' not recognized",
1927 uniq_scope => US_GLOBAL);
1933 # Handle AUTOMAKE_OPTIONS variable. Return 1 on error, 0 otherwise.
1936 # Process global options first so that more specific options can
1938 if (&process_option_list (1, split (' ', $global_options)))
1943 if (variable_defined ('AUTOMAKE_OPTIONS'))
1945 if (&process_option_list (0, &variable_value_as_list_recursive ('AUTOMAKE_OPTIONS', '')))
1951 if ($strictness == GNITS)
1953 $options{'readme-alpha'} = 1;
1954 $options{'std-options'} = 1;
1955 $options{'check-news'} = 1;
1962 # get_object_extension ($OUT)
1963 # ---------------------------
1964 # Return object extension. Just once, put some code into the output.
1965 # OUT is the name of the output file
1966 sub get_object_extension
1970 # Maybe require libtool library object files.
1971 my $extension = '.$(OBJEXT)';
1972 $extension = '.lo' if ($out =~ /\.la$/);
1974 # Check for automatic de-ANSI-fication.
1975 $extension = '$U' . $extension
1976 if defined $options{'ansi2knr'};
1978 $get_object_extension_was_run = 1;
1984 # Call finish function for each language that was used.
1985 sub handle_languages
1987 if ($use_dependencies)
1989 # Include auto-dep code. Don't include it if DEP_FILES would
1991 if (&saw_sources_p (0) && keys %dep_files)
1993 # Set location of depcomp.
1994 &define_variable ('depcomp', "\$(SHELL) $config_aux_dir/depcomp");
1995 &define_variable ('am__depfiles_maybe', 'depfiles');
1997 require_conf_file ("$am_file.am", FOREIGN, 'depcomp');
1999 my @deplist = sort keys %dep_files;
2001 # We define this as a conditional variable because BSD
2002 # make can't handle backslashes for continuing comments on
2003 # the following line.
2004 define_pretty_variable ('DEP_FILES', 'AMDEP_TRUE', @deplist);
2006 # Generate each `include' individually. Irix 6 make will
2007 # not properly include several files resulting from a
2008 # variable expansion; generating many separate includes
2010 $output_rules .= "\n";
2011 foreach my $iter (@deplist)
2013 $output_rules .= (subst ('AMDEP_TRUE')
2014 . subst ('am__include')
2016 . subst ('am__quote')
2018 . subst ('am__quote')
2022 # Compute the set of directories to remove in distclean-depend.
2023 my @depdirs = uniq (map { dirname ($_) } @deplist);
2024 $output_rules .= &file_contents ('depend',
2025 DEPDIRS => "@depdirs");
2030 &define_variable ('depcomp', '');
2031 &define_variable ('am__depfiles_maybe', '');
2036 # Is the c linker needed?
2038 foreach my $ext (sort keys %extension_seen)
2040 next unless $extension_map{$ext};
2042 my $lang = $languages{$extension_map{$ext}};
2044 my $rule_file = $lang->rule_file || 'depend2';
2046 # Get information on $LANG.
2047 my $pfx = $lang->autodep;
2048 my $fpfx = ($pfx eq '') ? 'CC' : $pfx;
2050 my $AMDEP = (($use_dependencies && $lang->autodep ne 'no')
2051 ? 'AMDEP' : 'FALSE');
2052 my $FASTDEP = (($use_dependencies && $lang->autodep ne 'no')
2053 ? ('am__fastdep' . $fpfx) : 'FALSE');
2055 my %transform = ('EXT' => $ext,
2059 'FASTDEP' => $FASTDEP,
2060 '-c' => $lang->compile_flag || '',
2062 => (count_files_for_language ($lang->name) > 1));
2064 # Generate the appropriate rules for this extension.
2065 if (($use_dependencies && $lang->autodep ne 'no')
2066 || defined $lang->compile)
2068 # Some C compilers don't support -c -o. Use it only if really
2070 my $output_flag = $lang->output_flag || '';
2073 && $lang->name eq 'c'
2074 && defined $options{'subdir-objects'});
2076 # Compute a possible derived extension.
2077 # This is not used by depend2.am.
2078 my $der_ext = (&{$lang->output_extensions} ($ext))[0];
2081 file_contents ($rule_file,
2085 'DERIVED-EXT' => $der_ext,
2087 # In this situation we know that the
2088 # object is in this directory, so
2089 # $(DEPDIR) is the correct location for
2091 'DEPBASE' => '$(DEPDIR)/$*',
2098 'COMPILE' => '$(' . $lang->compiler . ')',
2099 'LTCOMPILE' => '$(LT' . $lang->compiler . ')',
2100 '-o' => $output_flag);
2103 # Now include code for each specially handled object with this
2105 my %seen_files = ();
2106 foreach my $file (@{$lang_specific_files{$lang->name}})
2108 my ($derived, $source, $obj, $myext) = split (' ', $file);
2110 # We might see a given object twice, for instance if it is
2111 # used under different conditions.
2112 next if defined $seen_files{$obj};
2113 $seen_files{$obj} = 1;
2115 prog_error ("found " . $lang->name .
2116 " in handle_languages, but compiler not defined")
2117 unless defined $lang->compile;
2119 my $obj_compile = $lang->compile;
2121 # Rewrite each occurence of `AM_$flag' in the compile
2122 # rule into `${derived}_$flag' if it exists.
2123 for my $flag (@{$lang->flags})
2125 my $val = "${derived}_$flag";
2126 $obj_compile =~ s/\(AM_$flag\)/\($val\)/
2127 if variable_defined ($val);
2130 my $obj_ltcompile = '$(LIBTOOL) --mode=compile ' . $obj_compile;
2132 # We _need_ `-o' for per object rules.
2133 my $output_flag = $lang->output_flag || '-o';
2135 my $depbase = dirname ($obj);
2139 unless $depbase eq '';
2140 $depbase .= '$(DEPDIR)/' . basename ($obj);
2142 # Support for deansified files in subdirectories is ugly
2143 # enough to deserve an explanation.
2145 # A Note about normal ansi2knr processing first. On
2147 # AUTOMAKE_OPTIONS = ansi2knr
2148 # bin_PROGRAMS = foo
2149 # foo_SOURCES = foo.c
2151 # we generate rules similar to:
2153 # foo: foo$U.o; link ...
2154 # foo$U.o: foo$U.c; compile ...
2155 # foo_.c: foo.c; ansi2knr ...
2157 # this is fairly compact, and will call ansi2knr depending
2158 # on the value of $U (`' or `_').
2160 # It's harder with subdir sources. On
2162 # AUTOMAKE_OPTIONS = ansi2knr
2163 # bin_PROGRAMS = foo
2164 # foo_SOURCES = sub/foo.c
2166 # we have to create foo_.c in the current directory.
2167 # (Unless the user asks 'subdir-objects'.) This is important
2168 # in case the same file (`foo.c') is compiled from other
2169 # directories with different cpp options: foo_.c would
2170 # be preprocessed for only one set of options if it were
2171 # put in the subdirectory.
2173 # Because foo$U.o must be built from either foo_.c or
2174 # sub/foo.c we can't be as concise as in the first example.
2177 # foo: foo$U.o; link ...
2178 # foo_.o: foo_.c; compile ...
2179 # foo.o: sub/foo.c; compile ...
2180 # foo_.c: foo.c; ansi2knr ...
2182 # This is why we'll now transform $rule_file twice
2183 # if we detect this case.
2184 # A first time we output the compile rule with `$U'
2185 # replaced by `_' and the source directory removed,
2186 # and another time we simply remove `$U'.
2188 # Note that at this point $source (as computed by
2189 # &handle_single_transform_list) is `sub/foo$U.c'.
2190 # This can be confusing: it can be used as-is when
2191 # subdir-objects is set, otherwise you have to know
2192 # it really means `foo_.c' or `sub/foo.c'.
2193 my $objdir = dirname ($obj);
2194 my $srcdir = dirname ($source);
2195 if ($lang->ansi && $obj =~ /\$U/)
2197 prog_error "`$obj' contains \$U, but `$source' doesn't."
2198 if $source !~ /\$U/;
2200 (my $source_ = $source) =~ s/\$U/_/g;
2201 # Explicitely clean the _.c files if they are in
2202 # a subdirectory. (In the current directory they get
2203 # erased by a `rm -f *_.c' rule.)
2204 $clean_files{$source_} = MOSTLY_CLEAN
2206 # Output an additional rule if _.c and .c are not in
2207 # the same directory. (_.c is always in $objdir.)
2208 if ($objdir ne $srcdir)
2210 (my $obj_ = $obj) =~ s/\$U/_/g;
2211 (my $depbase_ = $depbase) =~ s/\$U/_/g;
2212 $source_ = basename ($source_);
2215 file_contents ($rule_file,
2219 DEPBASE => $depbase_,
2222 OBJ => "$obj_$myext",
2223 OBJOBJ => "$obj_.obj",
2224 LTOBJ => "$obj_.lo",
2226 COMPILE => $obj_compile,
2227 LTCOMPILE => $obj_ltcompile,
2228 -o => $output_flag);
2230 $depbase =~ s/\$U//g;
2231 $source =~ s/\$U//g;
2236 file_contents ($rule_file,
2240 'DEPBASE' => $depbase,
2242 'SOURCE' => $source,
2243 # Use $myext and not `.o' here, in case
2244 # we are actually building a new source
2245 # file -- e.g. via yacc.
2246 'OBJ' => "$obj$myext",
2247 'OBJOBJ' => "$obj.obj",
2248 'LTOBJ' => "$obj.lo",
2250 'COMPILE' => $obj_compile,
2251 'LTCOMPILE' => $obj_ltcompile,
2252 '-o' => $output_flag));
2255 # The rest of the loop is done once per language.
2256 next if defined $done{$lang};
2259 # Load the language dependent Makefile chunks.
2260 my %lang = map { uc ($_) => 0 } keys %languages;
2261 $lang{uc ($lang->name)} = 1;
2262 $output_rules .= file_contents ('lang-compile', %transform, %lang);
2264 # If the source to a program consists entirely of code from a
2265 # `pure' language, for instance C++ for Fortran 77, then we
2266 # don't need the C compiler code. However if we run into
2267 # something unusual then we do generate the C code. There are
2268 # probably corner cases here that do not work properly.
2269 # People linking Java code to Fortran code deserve pain.
2270 $needs_c ||= ! $lang->pure;
2272 define_compiler_variable ($lang)
2273 if ($lang->compile);
2275 define_linker_variable ($lang)
2278 require_variables ("$am_file.am", $lang->Name . " source seen",
2279 'TRUE', @{$lang->config_vars});
2281 # Call the finisher.
2284 # Flags listed in `->flags' are user variables (per GNU Standards),
2285 # they should not be overriden in the Makefile...
2286 my @dont_override = @{$lang->flags};
2287 # ... and so is LDFLAGS.
2288 push @dont_override, 'LDFLAGS' if $lang->link;
2290 foreach my $flag (@dont_override)
2292 if (exists $var_owner{$flag})
2294 for my $cond (keys %{$var_owner{$flag}})
2296 if ($var_owner{$flag}{$cond} == VAR_MAKEFILE)
2298 msg_cond_var ('gnu', $cond, $flag,
2299 "`$flag' is a user variable, "
2300 . "you should not override it;\n"
2301 . "use `AM_$flag' instead.");
2308 # If the project is entirely C++ or entirely Fortran 77 (i.e., 1
2309 # suffix rule was learned), don't bother with the C stuff. But if
2310 # anything else creeps in, then use it.
2312 if $need_link || ((scalar keys %$suffix_rules)
2313 - (scalar keys %$suffix_rules_default)) > 1;
2317 &define_compiler_variable ($languages{'c'})
2318 unless defined $done{$languages{'c'}};
2319 define_linker_variable ($languages{'c'});
2323 # Check to make sure a source defined in LIBOBJS is not explicitly
2324 # mentioned. This is a separate function (as opposed to being inlined
2325 # in handle_source_transform) because it isn't always appropriate to
2327 sub check_libobjs_sources
2329 my ($one_file, $unxformed) = @_;
2331 foreach my $prefix ('', 'EXTRA_', 'dist_', 'nodist_',
2332 'dist_EXTRA_', 'nodist_EXTRA_')
2335 if (variable_defined ($prefix . $one_file . '_SOURCES'))
2337 @files = &variable_value_as_list_recursive (
2338 ($prefix . $one_file . '_SOURCES'),
2341 elsif ($prefix eq '')
2343 @files = ($unxformed . '.c');
2350 foreach my $file (@files)
2352 err_var ($prefix . $one_file . '_SOURCES',
2353 "automatically discovered file `$file' should not" .
2354 " be explicitly mentioned")
2355 if defined $libsources{$file};
2362 # handle_single_transform_list ($VAR, $TOPPARENT, $DERIVED, $OBJ, @FILES)
2363 # -----------------------------------------------------------------------
2364 # Does much of the actual work for handle_source_transform.
2366 # $VAR is the name of the variable that the source filenames come from
2367 # $TOPPARENT is the name of the _SOURCES variable which is being processed
2368 # $DERIVED is the name of resulting executable or library
2369 # $OBJ is the object extension (e.g., `$U.lo')
2370 # @FILES is the list of source files to transform
2371 # Result is a list of the names of objects
2372 # %linkers_used will be updated with any linkers needed
2373 sub handle_single_transform_list ($$$$@)
2375 my ($var, $topparent, $derived, $obj, @files) = @_;
2377 my $nonansi_obj = $obj;
2378 $nonansi_obj =~ s/\$U//g;
2380 # Turn sources into objects. We use a while loop like this
2381 # because we might add to @files in the loop.
2382 while (scalar @files > 0)
2386 # Configure substitutions in _SOURCES variables are errors.
2390 "`$var' includes configure substitution `$_', and is " .
2391 "referred to\nfrom `$topparent': configure " .
2392 "substitutions are not allowed\nin _SOURCES variables");
2396 # If the source file is in a subdirectory then the `.o' is put
2397 # into the current directory, unless the subdir-objects option
2400 # Split file name into base and extension.
2401 next if ! /^(?:(.*)\/)?([^\/]*)($KNOWN_EXTENSIONS_PATTERN)$/;
2403 my $directory = $1 || '';
2407 # We must generate a rule for the object if it requires its own flags.
2409 my ($linker, $object);
2411 # This records whether we've seen a derived source file (eg,
2413 my $derived_source = 0;
2415 # This holds the `aggregate context' of the file we are
2416 # currently examining. If the file is compiled with
2417 # per-object flags, then it will be the name of the object.
2418 # Otherwise it will be `AM'. This is used by the target hook
2419 # language function.
2420 my $aggregate = 'AM';
2422 $extension = &derive_suffix ($extension, $nonansi_obj);
2424 if ($extension_map{$extension} &&
2425 ($lang = $languages{$extension_map{$extension}}))
2427 # Found the language, so see what it says.
2428 &saw_extension ($extension);
2430 # Note: computed subr call. The language rewrite function
2431 # should return one of the LANG_* constants. It could
2432 # also return a list whose first value is such a constant
2433 # and whose second value is a new source extension which
2434 # should be applied. This means this particular language
2435 # generates another source file which we must then process
2437 my $subr = 'lang_' . $lang->name . '_rewrite';
2438 my ($r, $source_extension)
2439 = & $subr ($directory, $base, $extension);
2440 # Skip this entry if we were asked not to process it.
2441 next if $r == LANG_IGNORE;
2443 # Now extract linker and other info.
2444 $linker = $lang->linker;
2447 if (defined $source_extension)
2449 $this_obj_ext = $source_extension;
2450 $derived_source = 1;
2454 $this_obj_ext = $obj;
2458 $this_obj_ext = $nonansi_obj;
2460 $object = $base . $this_obj_ext;
2462 # Do we have per-executable flags for this executable?
2463 my $have_per_exec_flags = 0;
2464 foreach my $flag (@{$lang->flags})
2466 if (variable_defined ("${derived}_$flag"))
2468 $have_per_exec_flags = 1;
2473 if ($have_per_exec_flags)
2475 # We have a per-executable flag in effect for this
2476 # object. In this case we rewrite the object's
2477 # name to ensure it is unique. We also require
2478 # the `compile' program to deal with compilers
2479 # where `-c -o' does not work.
2481 # We choose the name `DERIVED_OBJECT' to ensure
2482 # (1) uniqueness, and (2) continuity between
2483 # invocations. However, this will result in a
2484 # name that is too long for losing systems, in
2485 # some situations. So we provide _SHORTNAME to
2488 my $dname = $derived;
2489 if (variable_defined ($derived . '_SHORTNAME'))
2491 # FIXME: should use the same conditional as
2492 # the _SOURCES variable. But this is really
2493 # silly overkill -- nobody should have
2494 # conditional shortnames.
2495 $dname = &variable_value ($derived . '_SHORTNAME');
2497 $object = $dname . '-' . $object;
2499 require_conf_file ("$am_file.am", FOREIGN, 'compile')
2500 if $lang->name eq 'c';
2502 prog_error ($lang->name . " flags defined without compiler")
2503 if ! defined $lang->compile;
2508 # If rewrite said it was ok, put the object into a
2510 if ($r == LANG_SUBDIR && $directory ne '')
2512 $object = $directory . '/' . $object;
2515 # If doing dependency tracking, then we can't print
2516 # the rule. If we have a subdir object, we need to
2517 # generate an explicit rule. Actually, in any case
2518 # where the object is not in `.' we need a special
2519 # rule. The per-object rules in this case are
2520 # generated later, by handle_languages.
2521 if ($renamed || $directory ne '')
2523 my $obj_sans_ext = substr ($object, 0,
2524 - length ($this_obj_ext));
2525 my $full_ansi = $full;
2526 if ($lang->ansi && defined $options{'ansi2knr'})
2528 $full_ansi =~ s/$KNOWN_EXTENSIONS_PATTERN$/\$U$&/;
2529 $obj_sans_ext .= '$U';
2532 my $val = ("$full_ansi $obj_sans_ext "
2533 # Only use $this_obj_ext in the derived
2534 # source case because in the other case we
2535 # *don't* want $(OBJEXT) to appear here.
2536 . ($derived_source ? $this_obj_ext : '.o'));
2538 # If we renamed the object then we want to use the
2539 # per-executable flag name. But if this is simply a
2540 # subdir build then we still want to use the AM_ flag
2544 $val = "$derived $val";
2545 $aggregate = $derived;
2552 # Each item on this list is a string consisting of
2553 # four space-separated values: the derived flag prefix
2554 # (eg, for `foo_CFLAGS', it is `foo'), the name of the
2555 # source file, the base name of the output file, and
2556 # the extension for the object file.
2557 push (@{$lang_specific_files{$lang->name}}, $val);
2560 elsif ($extension eq $nonansi_obj)
2562 # This is probably the result of a direct suffix rule.
2563 # In this case we just accept the rewrite.
2564 $object = "$base$extension";
2569 # No error message here. Used to have one, but it was
2571 # FIXME: we could potentially do more processing here,
2572 # perhaps treating the new extension as though it were a
2573 # new source extension (as above). This would require
2574 # more restructuring than is appropriate right now.
2578 err_am "object `$object' created by `$full' and `$object_map{$object}'"
2579 if (defined $object_map{$object}
2580 && $object_map{$object} ne $full);
2582 my $comp_val = (($object =~ /\.lo$/)
2583 ? COMPILE_LIBTOOL : COMPILE_ORDINARY);
2584 (my $comp_obj = $object) =~ s/\.lo$/.\$(OBJEXT)/;
2585 if (defined $object_compilation_map{$comp_obj}
2586 && $object_compilation_map{$comp_obj} != 0
2587 # Only see the error once.
2588 && ($object_compilation_map{$comp_obj}
2589 != (COMPILE_LIBTOOL | COMPILE_ORDINARY))
2590 && $object_compilation_map{$comp_obj} != $comp_val)
2592 err_am "object `$object' created both with libtool and without";
2594 $object_compilation_map{$comp_obj} |= $comp_val;
2598 # Let the language do some special magic if required.
2599 $lang->target_hook ($aggregate, $object, $full);
2602 if ($derived_source)
2604 prog_error ($lang->name . " has automatic dependency tracking")
2605 if $lang->autodep ne 'no';
2606 # Make sure this new source file is handled next. That will
2607 # make it appear to be at the right place in the list.
2608 unshift (@files, $object);
2609 # Distribute derived sources unless the source they are
2610 # derived from is not.
2611 &push_dist_common ($object)
2612 unless ($topparent =~ /^(?:nobase_)?nodist_/);
2616 $linkers_used{$linker} = 1;
2618 push (@result, $object);
2620 if (! defined $object_map{$object})
2623 $object_map{$object} = $full;
2625 # If resulting object is in subdir, we need to make
2626 # sure the subdir exists at build time.
2627 if ($object =~ /\//)
2629 # FIXME: check that $DIRECTORY is somewhere in the
2632 # For Java, the way we're handling it right now, a
2633 # `..' component doesn't make sense.
2634 if ($lang->name eq 'java' && $object =~ /(\/|^)\.\.\//)
2636 err_am "`$full' should not contain a `..' component";
2639 # Make sure object is removed by `make mostlyclean'.
2640 $compile_clean_files{$object} = MOSTLY_CLEAN;
2641 # If we have a libtool object then we also must remove
2643 if ($object =~ /\.lo$/)
2645 (my $xobj = $object) =~ s,lo$,\$(OBJEXT),;
2646 $compile_clean_files{$xobj} = MOSTLY_CLEAN;
2648 # Remove any libtool object in this directory.
2649 $libtool_clean_directories{$directory} = 1;
2652 push (@dep_list, require_build_directory ($directory));
2654 # If we're generating dependencies, we also want
2655 # to make sure that the appropriate subdir of the
2656 # .deps directory is created.
2658 require_build_directory ($directory . '/$(DEPDIR)'))
2659 if $use_dependencies;
2662 &pretty_print_rule ($object . ':', "\t", @dep_list)
2663 if scalar @dep_list > 0;
2666 # Transform .o or $o file into .P file (for automatic
2668 if ($lang && $lang->autodep ne 'no')
2670 my $depfile = $object;
2671 $depfile =~ s/\.([^.]*)$/.P$1/;
2672 $depfile =~ s/\$\(OBJEXT\)$/o/;
2673 $dep_files{dirname ($depfile) . '/$(DEPDIR)/'
2674 . basename ($depfile)} = 1;
2681 # ($LINKER, $OBJVAR)
2682 # define_objects_from_sources ($VAR, $OBJVAR, $NODEFINE, $ONE_FILE,
2683 # $OBJ, $PARENT, $TOPPARENT)
2684 # ---------------------------------------------------------------------
2685 # Define an _OBJECTS variable for a _SOURCES variable (or subvariable)
2688 # $VAR is the name of the _SOURCES variable
2689 # $OBJVAR is the name of the _OBJECTS variable if known (otherwise
2690 # it will be generated and returned).
2691 # $NODEFINE is a boolean: if true, $OBJVAR will not be defined (but
2692 # work done to determine the linker will be).
2693 # $ONE_FILE is the canonical (transformed) name of object to build
2694 # $OBJ is the object extension (ie either `.o' or `.lo').
2695 # $PARENT is the variable in which $VAR is used, or $VAR if not applicable.
2696 # $TOPPARENT is the _SOURCES variable being processed.
2698 # Result is a pair ($LINKER, $OBJVAR):
2699 # $LINKER is a boolean, true if a linker is needed to deal with the objects,
2700 # $OBJVAR is the name of the variable defined to hold the objects.
2702 # %linkers_used, %vars_scanned, @substfroms and @substtos should be cleared
2704 # %linkers_used variable will be set to contain the linkers desired.
2705 # %vars_scanned will be used to check for recursive definitions.
2706 # @substfroms and @substtos will be used to keep a stack of variable
2707 # substitutions to be applied.
2709 sub define_objects_from_sources ($$$$$$$)
2711 my ($var, $objvar, $nodefine, $one_file, $obj, $parent, $topparent) = @_;
2713 if (defined $vars_scanned{$var})
2715 err_var $var, "variable `$var' recursively defined";
2718 $vars_scanned{$var} = 1;
2720 my $needlinker = "";
2721 my @allresults = ();
2722 foreach my $cond (variable_conditions ($var))
2725 foreach my $val (&variable_value_as_list ($var, $cond, $parent))
2727 # If $val is a variable (i.e. ${foo} or $(bar), not a filename),
2728 # handle the sub variable recursively.
2729 if ($val =~ /^\$\{([^}]*)\}$/ || $val =~ /^\$\(([^)]*)\)$/)
2733 # If the user uses a losing variable name, just ignore it.
2734 # This isn't ideal, but people have requested it.
2735 next if ($subvar =~ /\@.*\@/);
2737 # See if the variable is actually a substitution reference
2740 if ($subvar =~ /$SUBST_REF_PATTERN/o)
2744 $from = quotemeta $2;
2746 push @substfroms, $from;
2747 push @substtos, $to;
2749 my ($temp, $varname)
2750 = define_objects_from_sources ($subvar, undef,
2751 $nodefine, $one_file,
2752 $obj, $var, $topparent);
2754 push (@result, '$('. $varname . ')');
2755 $needlinker ||= $temp;
2760 else # $var is a filename
2762 my $substnum=$#substfroms;
2763 while ($substnum >= 0)
2765 $val =~ s/$substfroms[$substnum]$/$substtos[$substnum]/
2766 if defined $substfroms[$substnum];
2771 &handle_single_transform_list ($var, $topparent, $one_file, $obj, $val);
2772 push (@result, @transformed);
2773 $needlinker = "true" if @transformed;
2776 push (@allresults, [$cond, @result]);
2778 # Find a name for the variable, unless imposed.
2779 $objvar = subobjname (@allresults) unless defined $objvar;
2780 # Define _OBJECTS conditionally
2783 foreach my $pair (@allresults)
2785 my ($cond, @result) = @$pair;
2786 define_pretty_variable ($objvar, $cond, @result);
2790 delete $vars_scanned{$var};
2791 return ($needlinker, $objvar);
2796 # subobjname (@DEFINITIONS)
2797 # -------------------------
2798 # Return a name for an object variable that with definitions @DEFINITIONS.
2799 # @DEFINITIONS is a list of pair [$COND, @OBJECTS].
2801 # If we already have an object variable containing @DEFINITIONS, reuse it.
2802 # This way, we avoid combinatorial explosion of the generated
2803 # variables. Especially, in a Makefile such as:
2819 # | B=$(A1) $(A2) ... $(AN)
2824 # The generated c_OBJECTS and d_OBJECTS will share the same variable
2827 # This setup can be the case of a testsuite containing lots (>100) of
2828 # small C programs, all testing the same set of source files.
2832 foreach my $pair (@_)
2834 my ($cond, @values) = @$pair;
2835 $key .= "($cond)@values";
2838 return $subobjvar{$key} if exists $subobjvar{$key};
2840 my $num = 1 + keys (%subobjvar);
2841 my $name = "am__objects_${num}";
2842 $subobjvar{$key} = $name;
2847 # Handle SOURCE->OBJECT transform for one program or library.
2849 # canonical (transformed) name of object to build
2850 # actual name of object to build
2851 # object extension (ie either `.o' or `$o'.
2852 # Return result is name of linker variable that must be used.
2853 # Empty return means just use `LINK'.
2854 sub handle_source_transform
2856 # one_file is canonical name. unxformed is given name. obj is
2858 my ($one_file, $unxformed, $obj) = @_;
2862 # No point in continuing if _OBJECTS is defined.
2863 return if reject_var ($one_file . '_OBJECTS',
2864 $one_file . '_OBJECTS should not be defined');
2869 foreach my $prefix ('', 'EXTRA_', 'dist_', 'nodist_',
2870 'dist_EXTRA_', 'nodist_EXTRA_')
2872 my $var = $prefix . $one_file . "_SOURCES";
2874 if !variable_defined ($var);
2876 # We are going to define _OBJECTS variables using the prefix.
2877 # Then we glom them all together. So we can't use the null
2878 # prefix here as we need it later.
2879 my $xpfx = ($prefix eq '') ? 'am_' : $prefix;
2881 # Keep track of which prefixes we saw.
2882 $used_pfx{$xpfx} = 1
2883 unless $prefix =~ /EXTRA_/;
2885 push @sources, "\$($var)";
2886 if ($prefix !~ /^nodist_/)
2888 # If the VAR wasn't definined conditionally, we add
2889 # it to DIST_SOURCES as is. Otherwise we create a
2890 # am__VAR_DIST variable which contains all possible values,
2891 # and add this variable to DIST_SOURCES.
2892 my $distvar = "$var";
2893 my @conds = variable_conditions_recursive ($var);
2894 if (@conds && $conds[0] ne 'TRUE')
2896 $distvar = "am__${var}_DIST";
2898 uniq (variable_value_as_list_recursive ($var, 'all'));
2899 define_pretty_variable ($distvar, '', @files);
2901 push @dist_sources, "\$($distvar)"
2907 my ($temp, $objvar) =
2908 define_objects_from_sources ($var,
2909 $xpfx . $one_file . '_OBJECTS',
2910 $prefix =~ /EXTRA_/,
2911 $one_file, $obj, $var, $var);
2912 $needlinker ||= $temp;
2916 $linker ||= &resolve_linker (%linkers_used);
2919 my @keys = sort keys %used_pfx;
2920 if (scalar @keys == 0)
2922 &define_variable ($one_file . "_SOURCES", $unxformed . ".c");
2923 push (@sources, $unxformed . '.c');
2924 push (@dist_sources, $unxformed . '.c');
2928 &handle_single_transform_list ($one_file . '_SOURCES',
2929 $one_file . '_SOURCES',
2932 $linker ||= &resolve_linker (%linkers_used);
2933 define_pretty_variable ($one_file . "_OBJECTS", '', @result)
2937 grep ($_ = '$(' . $_ . $one_file . '_OBJECTS)', @keys);
2938 define_pretty_variable ($one_file . '_OBJECTS', '', @keys);
2941 # If we want to use `LINK' we must make sure it is defined.
2951 # handle_lib_objects ($XNAME, $VAR)
2952 # ---------------------------------
2953 # Special-case ALLOCA and LIBOBJS substitutions in _LDADD or _LIBADD variables.
2954 # Also, generate _DEPENDENCIES variable if appropriate.
2956 # transformed name of object being built, or empty string if no object
2957 # name of _LDADD/_LIBADD-type variable to examine
2958 # Returns 1 if LIBOBJS seen, 0 otherwise.
2959 sub handle_lib_objects
2961 my ($xname, $var) = @_;
2963 prog_error "handle_lib_objects: $var undefined"
2964 if ! variable_defined ($var);
2967 foreach my $cond (variable_conditions_recursive ($var))
2969 if (&handle_lib_objects_cond ($xname, $var, $cond))
2977 # Subroutine of handle_lib_objects: handle a particular condition.
2978 sub handle_lib_objects_cond
2980 my ($xname, $var, $cond) = @_;
2982 # We recognize certain things that are commonly put in LIBADD or
2986 my $seen_libobjs = 0;
2989 foreach my $lsearch (&variable_value_as_list_recursive ($var, $cond))
2991 # Skip -lfoo and -Ldir; these are explicitly allowed.
2992 next if $lsearch =~ /^-[lL]/;
2993 if (! $flagvar && $lsearch =~ /^-/)
2995 if ($var =~ /^(.*)LDADD$/)
2997 # Skip -dlopen and -dlpreopen; these are explicitly allowed.
2998 next if $lsearch =~ /^-dl(pre)?open$/;
2999 my $prefix = $1 || 'AM_';
3000 err_var ($var, "linker flags such as `$lsearch' belong in "
3001 . "`${prefix}LDFLAGS");
3005 $var =~ /^(.*)LIBADD$/;
3006 # Only get this error once.
3008 err_var ($var, "linker flags such as `$lsearch' belong in "
3013 # Assume we have a file of some sort, and push it onto the
3014 # dependency list. Autoconf substitutions are not pushed;
3015 # rarely is a new dependency substituted into (eg) foo_LDADD
3016 # -- but "bad things (eg -lX11) are routinely substituted.
3017 # Note that LIBOBJS and ALLOCA are exceptions to this rule,
3018 # and handled specially below.
3019 push (@dep_list, $lsearch)
3020 unless $lsearch =~ /^\@.*\@$/;
3022 # Automatically handle LIBOBJS and ALLOCA substitutions.
3023 # Basically this means adding entries to dep_files.
3024 if ($lsearch =~ /^\@(LT)?LIBOBJS\@$/)
3026 my $lt = $1 ? $1 : '';
3027 my $myobjext = ($1 ? 'l' : '') . 'o';
3029 push (@dep_list, $lsearch);
3031 if (! keys %libsources
3032 && ! variable_defined ($lt . 'LIBOBJS'))
3034 err_var ($var, "\@${lt}LIBOBJS\@ seen but never set in "
3035 . "`$configure_ac'");
3038 foreach my $iter (keys %libsources)
3040 if ($iter =~ /\.[cly]$/)
3042 &saw_extension ($&);
3043 &saw_extension ('.c');
3046 if ($iter =~ /\.h$/)
3048 require_file_with_macro ($cond, $var, FOREIGN, $iter);
3050 elsif ($iter ne 'alloca.c')
3052 my $rewrite = $iter;
3053 $rewrite =~ s/\.c$/.P$myobjext/;
3054 $dep_files{'$(DEPDIR)/' . $rewrite} = 1;
3055 $rewrite = "^" . quotemeta ($iter) . "\$";
3056 # Only require the file if it is not a built source.
3057 if (! variable_defined ('BUILT_SOURCES')
3058 || ! grep (/$rewrite/,
3059 &variable_value_as_list_recursive (
3060 'BUILT_SOURCES', 'all')))
3062 require_file_with_macro ($cond, $var, FOREIGN, $iter);
3067 elsif ($lsearch =~ /^\@(LT)?ALLOCA\@$/)
3069 my $lt = $1 ? $1 : '';
3070 my $myobjext = ($1 ? 'l' : '') . 'o';
3072 push (@dep_list, $lsearch);
3073 err_var ($var, "\@${lt}ALLOCA\@ seen but `AC_FUNC_ALLOCA' not in "
3074 . "`$configure_ac'")
3075 if ! defined $libsources{'alloca.c'};
3076 $dep_files{'$(DEPDIR)/alloca.P' . $myobjext} = 1;
3077 require_file_with_macro ($cond, $var, FOREIGN, 'alloca.c');
3078 &saw_extension ('c');
3084 my $depvar = $xname . '_DEPENDENCIES';
3085 if ((conditional_ambiguous_p ($depvar, $cond,
3086 keys %{$var_value{$depvar}}))[0] ne '')
3088 # Note that we've examined this.
3089 &examine_variable ($depvar);
3093 define_pretty_variable ($depvar, $cond, @dep_list);
3097 return $seen_libobjs;
3100 # Canonicalize the input parameter
3104 $string =~ tr/A-Za-z0-9_\@/_/c;
3108 # Canonicalize a name, and check to make sure the non-canonical name
3109 # is never used. Returns canonical name. Arguments are name and a
3110 # list of suffixes to check for.
3111 sub check_canonical_spelling
3113 my ($name, @suffixes) = @_;
3115 my $xname = &canonicalize ($name);
3116 if ($xname ne $name)
3118 foreach my $xt (@suffixes)
3120 reject_var ("$name$xt", "use `$xname$xt', not `$name$xt'");
3130 # Set up the compile suite.
3131 sub handle_compile ()
3134 unless $get_object_extension_was_run;
3137 my $default_includes = '';
3138 if (! defined $options{'nostdinc'})
3140 $default_includes = ' -I. -I$(srcdir)';
3142 if (variable_defined ('CONFIG_HEADER'))
3144 foreach my $hdr (split (' ', &variable_value ('CONFIG_HEADER')))
3146 $default_includes .= ' -I' . dirname ($hdr);
3151 my (@mostly_rms, @dist_rms);
3152 foreach my $item (sort keys %compile_clean_files)
3154 if ($compile_clean_files{$item} == MOSTLY_CLEAN)
3156 push (@mostly_rms, "\t-rm -f $item");
3158 elsif ($compile_clean_files{$item} == DIST_CLEAN)
3160 push (@dist_rms, "\t-rm -f $item");
3164 prog_error 'invalid entry in %compile_clean_files';
3168 my ($coms, $vars, $rules) =
3169 &file_contents_internal (1, "$libdir/am/compile.am",
3170 ('DEFAULT_INCLUDES' => $default_includes,
3171 'MOSTLYRMS' => join ("\n", @mostly_rms),
3172 'DISTRMS' => join ("\n", @dist_rms)));
3173 $output_vars .= $vars;
3174 $output_rules .= "$coms$rules";
3176 # Check for automatic de-ANSI-fication.
3177 if (defined $options{'ansi2knr'})
3179 require_variables_for_macro ('AUTOMAKE_OPTIONS',
3180 "option `ansi2knr' is used",
3183 # topdir is where ansi2knr should be.
3184 if ($options{'ansi2knr'} eq 'ansi2knr')
3186 # Only require ansi2knr files if they should appear in
3188 require_file_with_macro ('TRUE', 'AUTOMAKE_OPTIONS', FOREIGN,
3189 'ansi2knr.c', 'ansi2knr.1');
3191 # ansi2knr needs to be built before subdirs, so unshift it.
3192 unshift (@all, '$(ANSI2KNR)');
3195 my $ansi2knr_dir = '';
3196 $ansi2knr_dir = dirname ($options{'ansi2knr'})
3197 if $options{'ansi2knr'} ne 'ansi2knr';
3199 $output_rules .= &file_contents ('ansi2knr',
3200 ('ANSI2KNR-DIR' => $ansi2knr_dir));
3207 # Handle libtool rules.
3210 return unless variable_defined ('LIBTOOL');
3212 # Libtool requires some files, but only at top level.
3213 require_conf_file_with_macro ('TRUE', 'LIBTOOL', FOREIGN, @libtool_files)
3214 if $relative_dir eq '.';
3217 foreach my $item (sort keys %libtool_clean_directories)
3219 my $dir = ($item eq '.') ? '' : "$item/";
3220 # .libs is for Unix, _libs for DOS.
3221 push (@libtool_rms, "\t-rm -rf ${dir}.libs ${dir}_libs");
3224 # Output the libtool compilation rules.
3225 $output_rules .= &file_contents ('libtool',
3226 ('LTRMS' => join ("\n", @libtool_rms)));
3229 # handle_programs ()
3230 # ------------------
3231 # Handle C programs.
3234 my @proglist = &am_install_var ('progs', 'PROGRAMS',
3235 'bin', 'sbin', 'libexec', 'pkglib',
3237 return if ! @proglist;
3239 my $seen_global_libobjs =
3240 variable_defined ('LDADD') && &handle_lib_objects ('', 'LDADD');
3242 foreach my $one_file (@proglist)
3244 my $seen_libobjs = 0;
3245 my $obj = &get_object_extension ($one_file);
3247 # Canonicalize names and check for misspellings.
3248 my $xname = &check_canonical_spelling ($one_file, '_LDADD', '_LDFLAGS',
3249 '_SOURCES', '_OBJECTS',
3252 my $linker = &handle_source_transform ($xname, $one_file, $obj);
3255 if (variable_defined ($xname . "_LDADD"))
3257 $seen_libobjs = &handle_lib_objects ($xname, $xname . '_LDADD');
3262 # User didn't define prog_LDADD override. So do it.
3263 &define_variable ($xname . '_LDADD', '$(LDADD)');
3265 # This does a bit too much work. But we need it to
3266 # generate _DEPENDENCIES when appropriate.
3267 if (variable_defined ('LDADD'))
3269 $seen_libobjs = &handle_lib_objects ($xname, 'LDADD');
3271 elsif (! variable_defined ($xname . '_DEPENDENCIES'))
3273 &define_variable ($xname . '_DEPENDENCIES', '');
3278 reject_var ($xname . '_LIBADD',
3279 "use `${xname}_LDADD', not `${xname}_LIBADD'");
3281 if (! variable_defined ($xname . '_LDFLAGS'))
3283 # Define the prog_LDFLAGS variable.
3284 &define_variable ($xname . '_LDFLAGS', '');
3287 # Determine program to use for link.
3289 if (variable_defined ($xname . '_LINK'))
3291 $xlink = $xname . '_LINK';
3295 $xlink = $linker ? $linker : 'LINK';
3298 # If the resulting program lies into a subdirectory,
3299 # make sure this directory will exist.
3300 my $dirstamp = require_build_directory_maybe ($one_file);
3302 # Don't add $(EXEEXT) if user already did.
3303 my $extension = ($one_file !~ /\$\(EXEEXT\)$/
3307 $output_rules .= &file_contents ('program',
3308 ('PROGRAM' => $one_file,
3309 'XPROGRAM' => $xname,
3311 'DIRSTAMP' => $dirstamp,
3312 'EXEEXT' => $extension));
3314 if ($seen_libobjs || $seen_global_libobjs)
3316 if (variable_defined ($xname . '_LDADD'))
3318 &check_libobjs_sources ($xname, $xname . '_LDADD');
3320 elsif (variable_defined ('LDADD'))
3322 &check_libobjs_sources ($xname, 'LDADD');
3329 # handle_libraries ()
3330 # -------------------
3332 sub handle_libraries
3334 my @liblist = &am_install_var ('libs', 'LIBRARIES',
3335 'lib', 'pkglib', 'noinst', 'check');
3336 return if ! @liblist;
3338 my @prefix = am_primary_prefixes ('LIBRARIES', 0, 'lib', 'pkglib',
3341 require_variables_for_macro ($prefix[0] . '_LIBRARIES',
3342 'library used', 'RANLIB')
3345 foreach my $onelib (@liblist)
3347 my $seen_libobjs = 0;
3348 # Check that the library fits the standard naming convention.
3349 if (basename ($onelib) !~ /^lib.*\.a/)
3351 # FIXME should put line number here. That means mapping
3352 # from library name back to variable name.
3353 err_am "`$onelib' is not a standard library name";
3356 my $obj = &get_object_extension ($onelib);
3358 # Canonicalize names and check for misspellings.
3359 my $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_SOURCES',
3360 '_OBJECTS', '_DEPENDENCIES',
3363 if (! variable_defined ($xlib . '_AR'))
3365 &define_variable ($xlib . '_AR', '$(AR) cru');
3368 if (variable_defined ($xlib . '_LIBADD'))
3370 if (&handle_lib_objects ($xlib, $xlib . '_LIBADD'))
3377 # Generate support for conditional object inclusion in
3379 &define_variable ($xlib . "_LIBADD", '');
3382 reject_var ($xlib . '_LDADD',
3383 "use `${xlib}_LIBADD', not `${xlib}_LDADD'");
3385 # Make sure we at look at this.
3386 &examine_variable ($xlib . '_DEPENDENCIES');
3388 &handle_source_transform ($xlib, $onelib, $obj);
3390 # If the resulting library lies into a subdirectory,
3391 # make sure this directory will exist.
3392 my $dirstamp = require_build_directory_maybe ($onelib);
3394 $output_rules .= &file_contents ('library',
3395 ('LIBRARY' => $onelib,
3396 'XLIBRARY' => $xlib,
3397 'DIRSTAMP' => $dirstamp));
3401 if (variable_defined ($xlib . '_LIBADD'))
3403 &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
3410 # handle_ltlibraries ()
3411 # ---------------------
3412 # Handle shared libraries.
3413 sub handle_ltlibraries
3415 my @liblist = &am_install_var ('ltlib', 'LTLIBRARIES',
3416 'noinst', 'lib', 'pkglib', 'check');
3417 return if ! @liblist;
3420 my @prefix = am_primary_prefixes ('LTLIBRARIES', 0, 'lib', 'pkglib',
3423 require_variables_for_macro ($prefix[0] . '_LTLIBRARIES',
3424 'Libtool library used', 'LIBTOOL')
3427 foreach my $key (@prefix)
3429 # Get the installation directory of each library.
3430 (my $dir = $key) =~ s/^nobase_//;
3431 for (variable_value_as_list_recursive ($key . '_LTLIBRARIES', 'all'))
3433 # We reject libraries which are installed in several places,
3434 # because we don't handle this in the rules (think `-rpath').
3436 # However, we allow the same library to be listed many times
3437 # for the same directory. This is for users who need setups
3440 # lib_LTLIBRARIES = libfoo.la
3443 # lib_LTLIBRARIES = libfoo.la
3446 # Actually this will also allow
3447 # lib_LTLIBRARIES = libfoo.la libfoo.la
3448 # Diagnosing this case doesn't seem worth the plain (we'd
3449 # have to fill $instdirs on a per-condition basis, check
3450 # implied conditions, etc.)
3451 if (defined $instdirs{$_} && $instdirs{$_} ne $dir)
3453 err_am ("`$_' is already going to be installed in "
3454 . "`$instdirs{$_}'");
3458 $instdirs{$_} = $dir;
3463 foreach my $onelib (@liblist)
3465 my $seen_libobjs = 0;
3466 my $obj = &get_object_extension ($onelib);
3468 # Canonicalize names and check for misspellings.
3469 my $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_LDFLAGS',
3470 '_SOURCES', '_OBJECTS',
3473 if (! variable_defined ($xlib . '_LDFLAGS'))
3475 # Define the lib_LDFLAGS variable.
3476 &define_variable ($xlib . '_LDFLAGS', '');
3479 # Check that the library fits the standard naming convention.
3480 my $libname_rx = "^lib.*\.la";
3481 if ((variable_defined ($xlib . '_LDFLAGS')
3483 &variable_value_as_list_recursive ($xlib . '_LDFLAGS',
3485 || (variable_defined ('LDFLAGS')
3487 &variable_value_as_list_recursive ('LDFLAGS', 'all'))))
3489 # Relax name checking for libtool modules.
3490 $libname_rx = "\.la";
3492 if (basename ($onelib) !~ /$libname_rx$/)
3494 # FIXME should put line number here. That means mapping
3495 # from library name back to variable name.
3496 msg_am ('error-gnu/warn',
3497 "`$onelib' is not a standard libtool library name");
3500 if (variable_defined ($xlib . '_LIBADD'))
3502 if (&handle_lib_objects ($xlib, $xlib . '_LIBADD'))
3509 # Generate support for conditional object inclusion in
3511 &define_variable ($xlib . "_LIBADD", '');
3514 reject_var ("${xlib}_LDADD",
3515 "use `${xlib}_LIBADD', not `${xlib}_LDADD'");
3517 # Make sure we at look at this.
3518 &examine_variable ($xlib . '_DEPENDENCIES');
3520 my $linker = &handle_source_transform ($xlib, $onelib, $obj);
3522 # Determine program to use for link.
3524 if (variable_defined ($xlib . '_LINK'))
3526 $xlink = $xlib . '_LINK';
3530 $xlink = $linker ? $linker : 'LINK';
3534 if ($instdirs{$onelib} eq 'EXTRA'
3535 || $instdirs{$onelib} eq 'noinst'
3536 || $instdirs{$onelib} eq 'check')
3538 # It's an EXTRA_ library, so we can't specify -rpath,
3539 # because we don't know where the library will end up.
3540 # The user probably knows, but generally speaking automake
3541 # doesn't -- and in fact configure could decide
3542 # dynamically between two different locations.
3547 $rpath = ('-rpath $(' . $instdirs{$onelib} . 'dir)');
3550 # If the resulting library lies into a subdirectory,
3551 # make sure this directory will exist.
3552 my $dirstamp = require_build_directory_maybe ($onelib);
3554 # Remember to cleanup .libs/ in this directory.
3555 my $dirname = dirname $onelib;
3556 $libtool_clean_directories{$dirname} = 1;
3558 $output_rules .= &file_contents ('ltlibrary',
3559 ('LTLIBRARY' => $onelib,
3560 'XLTLIBRARY' => $xlib,
3563 'DIRSTAMP' => $dirstamp));
3566 if (variable_defined ($xlib . '_LIBADD'))
3568 &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
3574 # See if any _SOURCES variable were misspelled.
3577 # It is ok if the user sets this particular variable.
3578 &examine_variable ('AM_LDFLAGS');
3580 foreach my $varname (keys %var_value)
3582 foreach my $primary ('_SOURCES', '_LIBADD', '_LDADD', '_LDFLAGS',
3585 msg_var 'syntax', $varname, "unused variable: `$varname'"
3586 # Note that a configure variable is always legitimate.
3587 if ($varname =~ /$primary$/ && ! $content_seen{$varname}
3588 && ! exists $configure_vars{$varname});
3597 # NOTE we no longer automatically clean SCRIPTS, because it is
3598 # useful to sometimes distribute scripts verbatim. This happens
3599 # eg in Automake itself.
3600 &am_install_var ('-candist', 'scripts', 'SCRIPTS',
3601 'bin', 'sbin', 'libexec', 'pkgdata',
3606 # ($OUTFILE, $VFILE, @CLEAN_FILES)
3607 # &scan_texinfo_file ($FILENAME)
3608 # ------------------------------
3609 # $OUTFILE is the name of the info file produced by $FILENAME.
3610 # $VFILE is the name of the version.texi file used (empty if none).
3611 # @CLEAN_FILES is the list of by products (indexes etc.)
3612 sub scan_texinfo_file
3614 my ($filename) = @_;
3616 # Some of the following extensions are always created, no matter
3617 # whether indexes are used or not. Other (like cps, fns, ... pgs)
3618 # are only created when they are used. We used to scan $FILENAME
3619 # for their use, but that is not enough: they could be used in
3620 # included files. We can't scan included files because we don't
3621 # know the include path. Therefore we always erase these files,
3622 # no matter whether they are used or not.
3624 # (tmp is only created if an @macro is used and a certain e-TeX
3625 # feature is not available.)
3626 my %clean_suffixes =
3627 map { $_ => 1 } (qw(aux log toc tmp
3633 pg pgs)); # grep 'new.*index' texinfo.tex
3635 my $texi = new Automake::XFile "< $filename";
3636 verb "reading $filename";
3638 my ($outfile, $vfile);
3639 while ($_ = $texi->getline)
3641 if (/^\@setfilename +(\S+)/)
3643 # Honor only the first @setfilename. (It's possible to have
3644 # more occurences later if the manual shows examples of how
3645 # to use @setfilename...)
3649 if ($outfile =~ /\.(.+)$/ && $1 ne 'info')
3651 error ("$filename:$.",
3652 "output `$outfile' has unrecognized extension");
3656 # A "version.texi" file is actually any file whose name
3657 # matches "vers*.texi".
3658 elsif (/^\@include\s+(vers[^.]*\.texi)\s*$/)
3663 # Try to find new or unused indexes.
3665 # Creating a new category of index.
3666 elsif (/^\@def(code)?index (\w+)/)
3668 $clean_suffixes{$2} = 1;
3669 $clean_suffixes{"$2s"} = 1;
3672 # Merging an index into an another.
3673 elsif (/^\@syn(code)?index (\w+) (\w+)/)
3675 delete $clean_suffixes{"$2s"};
3676 $clean_suffixes{"$3s"} = 1;
3683 err_am "`$filename' missing \@setfilename";
3687 my $infobase = basename ($filename);
3688 $infobase =~ s/\.te?xi(nfo)?$//;
3689 return ($outfile, $vfile,
3690 map { "$infobase.$_" } (sort keys %clean_suffixes));
3693 # ($DIRSTAMP, @CLEAN_FILES)
3694 # output_texinfo_build_rules ($SOURCE, $DEST, @DEPENDENCIES)
3695 # ----------------------------------------------------------
3696 # SOURCE - the source Texinfo file
3697 # DEST - the destination Info file
3698 # DEPENDENCIES - known dependencies
3699 sub output_texinfo_build_rules ($$@)
3701 my ($source, $dest, @deps) = @_;
3703 # Split `a.texi' into `a' and `.texi'.
3704 my ($spfx, $ssfx) = ($source =~ /^(.*?)(\.[^.]*)?$/);
3705 my ($dpfx, $dsfx) = ($dest =~ /^(.*?)(\.[^.]*)?$/);
3710 # We can output two kinds of rules: the "generic" rules
3711 # use Make suffix rules and are appropritate when
3712 # $source and $dest lie in the current directory; the "specifix"
3713 # rules is needed in the other case.
3715 # The former are output only once (this is not really apparent
3716 # here, but just remember that some logic deeper in Automake will
3717 # not output the same rule twice); while the later need to be output
3718 # for each Texinfo source.
3721 my $sdir = dirname $source;
3722 if ($sdir eq '.' && dirname ($dest) eq '.')
3725 $makeinfoflags = '-I $(srcdir)';
3730 $makeinfoflags = "-I $sdir -I \$(srcdir)/$sdir";
3733 # We cannot use a suffix rule to build info files with
3734 # an empty extension. Otherwise we would output a single suffix
3735 # inference rule, with separate dependencies, as in
3738 # foo.info: foo.texi
3739 # which confuse Solaris make. (See the Autoconf manual for details.)
3740 # Therefore we use a specific rule in this case. This applies
3741 # to info files only (dvi and pdf files always have an extension).
3742 my $generic_info = ($generic && $dsfx) ? 1 : 0;
3744 # If the resulting file lie into a subdirectory,
3745 # make sure this directory will exist.
3746 my $dirstamp = require_build_directory_maybe ($dest);
3748 $output_rules .= &file_contents ('texibuild',
3749 GENERIC => $generic,
3750 GENERIC_INFO => $generic_info,
3751 SOURCE_SUFFIX => $ssfx,
3752 SOURCE => ($generic ? '$<' : $source),
3753 SOURCE_INFO => ($generic_info ?
3755 SOURCE_REAL => $source,
3756 DEST_PREFIX => $dpfx,
3757 DEST_SUFFIX => $dsfx,
3758 MAKEINFOFLAGS => $makeinfoflags,
3760 DIRSTAMP => $dirstamp);
3761 return ($dirstamp, "$dpfx.dvi", "$dpfx.pdf", "$dpfx.ps");
3765 # ($DO-SOMETHING, $TEXICLEANS)
3766 # handle_texinfo_helper ()
3767 # ------------------------
3768 # Handle all Texinfo source; helper for handle_texinfo
3769 sub handle_texinfo_helper
3771 reject_var 'TEXINFOS', "`TEXINFOS' is an anachronism; use `info_TEXINFOS'";
3772 reject_var 'html_TEXINFOS', "HTML generation not yet supported";
3774 return (0, '') if ! variable_defined ('info_TEXINFOS');
3776 my @texis = &variable_value_as_list_recursive ('info_TEXINFOS', 'all');
3778 my (@info_deps_list, @dvis_list, @pdfs_list, @pss_list, @texi_deps);
3784 foreach my $info_cursor (@texis)
3786 my $infobase = $info_cursor;
3787 $infobase =~ s/\.(txi|texinfo|texi)$//;
3789 if ($infobase eq $info_cursor)
3791 # FIXME: report line number.
3792 err_am "texinfo file `$info_cursor' has unrecognized extension";
3796 # If 'version.texi' is referenced by input file, then include
3797 # automatic versioning capability.
3798 my ($out_file, $vtexi, @clean_files) =
3799 &scan_texinfo_file ("$relative_dir/$info_cursor")
3801 push (@texi_cleans, @clean_files);
3803 # If the Texinfo source is in a subdirectory, create the
3804 # resulting info in this subdirectory. If it is in the
3805 # current directory, try hard to not prefix "./" because
3806 # it breaks the generic rules.
3807 my $outdir = dirname ($info_cursor) . '/';
3808 $outdir = "" if $outdir eq './';
3809 $out_file = $outdir . $out_file;
3811 # If user specified file_TEXINFOS, then use that as explicit
3814 push (@texi_deps, "$outdir$vtexi") if $vtexi;
3816 my $canonical = &canonicalize ($infobase);
3817 if (variable_defined ($canonical . "_TEXINFOS"))
3819 push (@texi_deps, '$(' . $canonical . '_TEXINFOS)');
3820 &push_dist_common ('$(' . $canonical . '_TEXINFOS)');
3823 my ($dirstamp, @cfiles) =
3824 output_texinfo_build_rules ($info_cursor, $out_file, @texi_deps);
3825 push (@texi_cleans, @cfiles);
3827 push (@info_deps_list, $out_file);
3828 push (@dvis_list, $infobase . '.dvi');
3829 push (@pdfs_list, $infobase . '.pdf');
3830 push (@pss_list, $infobase . '.ps');
3832 # If a vers*.texi file is needed, emit the rule.
3835 err_am ("`$vtexi', included in `$info_cursor', "
3836 . "also included in `$versions{$vtexi}'")
3837 if defined $versions{$vtexi};
3838 $versions{$vtexi} = $info_cursor;
3840 # We number the stamp-vti files. This is doable since the
3841 # actual names don't matter much. We only number starting
3842 # with the second one, so that the common case looks nice.
3843 my $vti = ($done ? $done : 'vti');
3846 # This is ugly, but it is our historical practice.
3847 if ($config_aux_dir_set_in_configure_in)
3849 require_conf_file_with_macro ('TRUE', 'info_TEXINFOS', FOREIGN,
3854 require_file_with_macro ('TRUE', 'info_TEXINFOS',
3855 FOREIGN, 'mdate-sh');
3859 if ($config_aux_dir_set_in_configure_in)
3861 $conf_dir = $config_aux_dir;
3862 $conf_dir .= '/' unless $conf_dir =~ /\/$/;
3866 $conf_dir = '$(srcdir)/';
3868 $output_rules .= &file_contents ('texi-vers',
3869 TEXI => $info_cursor,
3871 STAMPVTI => "${outdir}stamp-$vti",
3872 VTEXI => "$outdir$vtexi",
3874 DIRSTAMP => $dirstamp);
3878 # Handle location of texinfo.tex.
3879 my $need_texi_file = 0;
3883 $texinfodir = '$(top_srcdir)/../texinfo';
3884 &define_variable ('TEXINFO_TEX', "$texinfodir/texinfo.tex");
3886 elsif ($config_aux_dir_set_in_configure_in)
3888 $texinfodir = $config_aux_dir;
3889 &define_variable ('TEXINFO_TEX', "$texinfodir/texinfo.tex");
3890 $need_texi_file = 2; # so that we require_conf_file later
3892 elsif (variable_defined ('TEXINFO_TEX'))
3894 # The user defined TEXINFO_TEX so assume he knows what he is
3896 $texinfodir = ('$(srcdir)/'
3897 . dirname (&variable_value ('TEXINFO_TEX')));
3901 $texinfodir = '$(srcdir)';
3902 $need_texi_file = 1;
3904 &define_variable ('am__TEXINFO_TEX_DIR', $texinfodir);
3907 my $texiclean = &pretty_print_internal ("", "\t ", @texi_cleans);
3909 push (@dist_targets, 'dist-info');
3911 if (! defined $options{'no-installinfo'})
3913 # Make sure documentation is made and installed first. Use
3914 # $(INFO_DEPS), not 'info', because otherwise recursive makes
3915 # get run twice during "make all".
3916 unshift (@all, '$(INFO_DEPS)');
3919 &define_variable ("INFO_DEPS", "@info_deps_list");
3920 &define_variable ("DVIS", "@dvis_list");
3921 &define_variable ("PDFS", "@pdfs_list");
3922 &define_variable ("PSS", "@pss_list");
3923 # This next isn't strictly needed now -- the places that look here
3924 # could easily be changed to look in info_TEXINFOS. But this is
3925 # probably better, in case noinst_TEXINFOS is ever supported.
3926 &define_variable ("TEXINFOS", &variable_value ('info_TEXINFOS'));
3928 # Do some error checking. Note that this file is not required
3929 # when in Cygnus mode; instead we defined TEXINFO_TEX explicitly
3931 if ($need_texi_file && ! defined $options{'no-texinfo.tex'})
3933 if ($need_texi_file > 1)
3935 require_conf_file_with_macro ('TRUE', 'info_TEXINFOS', FOREIGN,
3940 require_file_with_macro ('TRUE', 'info_TEXINFOS', FOREIGN,
3945 return (1, $texiclean);
3950 # Handle all Texinfo source.
3953 my ($do_something, $texiclean) = handle_texinfo_helper ();
3954 $output_rules .= &file_contents ('texinfos',
3955 ('TEXICLEAN' => $texiclean,
3956 'LOCAL-TEXIS' => $do_something));
3959 # Handle any man pages.
3960 sub handle_man_pages
3962 reject_var 'MANS', "`MANS' is an anachronism; use `man_MANS'";
3964 # Find all the sections in use. We do this by first looking for
3965 # "standard" sections, and then looking for any additional
3966 # sections used in man_MANS.
3967 my (%sections, %vlist);
3968 # We handle nodist_ for uniformity. man pages aren't distributed
3969 # by default so it isn't actually very important.
3970 foreach my $pfx ('', 'dist_', 'nodist_')
3972 # Add more sections as needed.
3973 foreach my $section ('0'..'9', 'n', 'l')
3975 if (variable_defined ($pfx . 'man' . $section . '_MANS'))
3977 $sections{$section} = 1;
3978 $vlist{'$(' . $pfx . 'man' . $section . '_MANS)'} = 1;
3980 &push_dist_common ('$(' . $pfx . 'man' . $section . '_MANS)')
3985 if (variable_defined ($pfx . 'man_MANS'))
3987 $vlist{'$(' . $pfx . 'man_MANS)'} = 1;
3988 foreach (&variable_value_as_list_recursive ($pfx . 'man_MANS', 'all'))
3990 # A page like `foo.1c' goes into man1dir.
3991 if (/\.([0-9a-z])([a-z]*)$/)
3997 &push_dist_common ('$(' . $pfx . 'man_MANS)')
4002 return unless %sections;
4004 # Now for each section, generate an install and unintall rule.
4005 # Sort sections so output is deterministic.
4006 foreach my $section (sort keys %sections)
4008 $output_rules .= &file_contents ('mans', ('SECTION' => $section));
4011 my @mans = sort keys %vlist;
4012 $output_vars .= file_contents ('mans-vars',
4013 ('MANS' => "@mans"));
4015 if (! defined $options{'no-installman'})
4017 push (@all, '$(MANS)');
4021 # Handle DATA variables.
4024 &am_install_var ('-noextra', '-candist', 'data', 'DATA',
4025 'data', 'sysconf', 'sharedstate', 'localstate',
4026 'pkgdata', 'noinst', 'check');
4034 if (variable_defined ('SUBDIRS'))
4036 $output_rules .= ("tags-recursive:\n"
4037 . "\tlist=\'\$(SUBDIRS)\'; for subdir in \$\$list; do \\\n"
4038 # Never fail here if a subdir fails; it
4040 . "\t test \"\$\$subdir\" = . || (cd \$\$subdir"
4041 . " && \$(MAKE) \$(AM_MAKEFLAGS) tags); \\\n"
4043 push (@tag_deps, 'tags-recursive');
4044 &depend ('.PHONY', 'tags-recursive');
4046 $output_rules .= ("ctags-recursive:\n"
4047 . "\tlist=\'\$(SUBDIRS)\'; for subdir in \$\$list; do \\\n"
4048 # Never fail here if a subdir fails; it
4050 . "\t test \"\$\$subdir\" = . || (cd \$\$subdir"
4051 . " && \$(MAKE) \$(AM_MAKEFLAGS) ctags); \\\n"
4053 push (@ctag_deps, 'ctags-recursive');
4054 &depend ('.PHONY', 'ctags-recursive');
4057 if (&saw_sources_p (1)
4058 || variable_defined ('ETAGS_ARGS')
4062 foreach my $spec (@config_headers)
4064 my ($out, @ins) = split_config_file_spec ($spec);
4065 foreach my $in (@ins)
4067 # If the config header source is in this directory,
4069 push @config, basename ($in)
4070 if $relative_dir eq dirname ($in);
4073 $output_rules .= &file_contents ('tags',
4074 ('CONFIG' => "@config",
4075 'TAGSDIRS' => "@tag_deps",
4076 'CTAGSDIRS' => "@ctag_deps"));
4077 &examine_variable ('TAGS_DEPENDENCIES');
4079 elsif (reject_var ('TAGS_DEPENDENCIES',
4080 "doesn't make sense to define `TAGS_DEPENDENCIES'"
4081 . "without\nsources or `ETAGS_ARGS'"))
4086 # Every Makefile must define some sort of TAGS rule.
4087 # Otherwise, it would be possible for a top-level "make TAGS"
4088 # to fail because some subdirectory failed.
4089 $output_rules .= "tags: TAGS\nTAGS:\n\n";
4091 $output_rules .= "ctags: CTAGS\nCTAGS:\n\n";
4095 # Handle multilib support.
4098 if ($seen_multilib && $relative_dir eq '.')
4100 $output_rules .= &file_contents ('multilib');
4106 # &for_dist_common ($A, $B)
4107 # -------------------------
4108 # Subroutine for &handle_dist: sort files to dist.
4110 # We put README first because it then becomes easier to make a
4111 # Usenet-compliant shar file (in these, README must be first).
4113 # FIXME: do more ordering of files here.
4126 # handle_dist ($MAKEFILE)
4127 # -----------------------
4128 # Handle 'dist' target.
4131 my ($makefile) = @_;
4133 # `make dist' isn't used in a Cygnus-style tree.
4134 # Omit the rules so that people don't try to use them.
4135 return if $cygnus_mode;
4137 # Look for common files that should be included in distribution.
4138 # If the aux dir is set, and it does not have a Makefile.am, then
4139 # we check for these files there as well.
4142 if ($relative_dir eq '.'
4143 && $config_aux_dir_set_in_configure_in)
4145 ($auxdir = $config_aux_dir) =~ s,^\$\(top_srcdir\)/,,;
4146 if (! &is_make_dir ($auxdir))
4151 foreach my $cfile (@common_files)
4153 if (-f ($relative_dir . "/" . $cfile)
4154 # The file might be absent, but if it can be built it's ok.
4155 || exists $targets{$cfile})
4157 &push_dist_common ($cfile);
4160 # Don't use `elsif' here because a file might meaningfully
4161 # appear in both directories.
4162 if ($check_aux && -f ($auxdir . '/' . $cfile))
4164 &push_dist_common ($auxdir . '/' . $cfile);
4168 # We might copy elements from $configure_dist_common to
4169 # %dist_common if we think we need to. If the file appears in our
4170 # directory, we would have discovered it already, so we don't
4171 # check that. But if the file is in a subdir without a Makefile,
4172 # we want to distribute it here if we are doing `.'. Ugly!
4173 if ($relative_dir eq '.')
4175 foreach my $file (split (' ' , $configure_dist_common))
4177 push_dist_common ($file)
4178 unless is_make_dir (dirname ($file));
4184 # Files to distributed. Don't use &variable_value_as_list_recursive
4185 # as it recursively expands `$(dist_pkgdata_DATA)' etc.
4186 check_variable_defined_unconditionally ('DIST_COMMON');
4187 my @dist_common = split (' ', variable_value ('DIST_COMMON', 'TRUE'));
4188 @dist_common = uniq (sort for_dist_common (@dist_common));
4189 pretty_print ('DIST_COMMON = ', "\t", @dist_common);
4191 # Now that we've processed DIST_COMMON, disallow further attempts
4193 $handle_dist_run = 1;
4195 # Scan EXTRA_DIST to see if we need to distribute anything from a
4196 # subdir. If so, add it to the list. I didn't want to do this
4197 # originally, but there were so many requests that I finally
4199 if (variable_defined ('EXTRA_DIST'))
4201 # FIXME: This should be fixed to work with conditionals. That
4202 # will require only making the entries in %dist_dirs under the
4203 # appropriate condition. This is meaningful if the nature of
4204 # the distribution should depend upon the configure options
4206 foreach (&variable_value_as_list_recursive ('EXTRA_DIST', ''))
4209 next unless s,/+[^/]+$,,;
4215 # We have to check DIST_COMMON for extra directories in case the
4216 # user put a source used in AC_OUTPUT into a subdir.
4217 my $topsrcdir = backname ($relative_dir);
4218 foreach (&variable_value_as_list_recursive ('DIST_COMMON', 'all'))
4221 s/\$\(top_srcdir\)/$topsrcdir/;
4223 next unless s,/+[^/]+$,,;
4228 # Rule to check whether a distribution is viable.
4229 my %transform = ('DISTCHECK-HOOK' => &target_defined ('distcheck-hook'),
4230 'GETTEXT' => $seen_gettext && !$seen_gettext_external);
4232 # Prepend $(distdir) to each directory given.
4233 my %rewritten = map { '$(distdir)/' . "$_" => 1 } keys %dist_dirs;
4234 $transform{'DISTDIRS'} = join (' ', sort keys %rewritten);
4236 # If we have SUBDIRS, create all dist subdirectories and do
4238 if (variable_defined ('SUBDIRS'))
4240 # If SUBDIRS is conditionally defined, then set DIST_SUBDIRS
4241 # to all possible directories, and use it. If DIST_SUBDIRS is
4242 # defined, just use it.
4243 my $dist_subdir_name;
4244 # Note that we check DIST_SUBDIRS first on purpose. At least
4245 # one project uses so many conditional subdirectories that
4246 # calling variable_conditionally_defined on SUBDIRS will cause
4247 # automake to grow to 150Mb. Sigh.
4248 if (variable_defined ('DIST_SUBDIRS')
4249 || variable_conditionally_defined ('SUBDIRS'))
4251 $dist_subdir_name = 'DIST_SUBDIRS';
4252 if (! variable_defined ('DIST_SUBDIRS'))
4254 define_pretty_variable
4255 ('DIST_SUBDIRS', '',
4256 uniq (&variable_value_as_list_recursive ('SUBDIRS', 'all')));
4261 $dist_subdir_name = 'SUBDIRS';
4262 # We always define this because that is what `distclean'
4264 define_pretty_variable ('DIST_SUBDIRS', '', '$(SUBDIRS)');
4267 $transform{'DIST_SUBDIR_NAME'} = $dist_subdir_name;
4270 # If the target `dist-hook' exists, make sure it is run. This
4271 # allows users to do random weird things to the distribution
4272 # before it is packaged up.
4273 push (@dist_targets, 'dist-hook')
4274 if &target_defined ('dist-hook');
4275 $transform{'DIST-TARGETS'} = join(' ', @dist_targets);
4277 # Defining $(DISTDIR).
4278 $transform{'DISTDIR'} = !variable_defined('distdir');
4279 $transform{'TOP_DISTDIR'} = backname ($relative_dir);
4281 $output_rules .= &file_contents ('distdir', %transform);
4285 # Handle subdirectories.
4289 unless variable_defined ('SUBDIRS');
4291 my @subdirs = &variable_value_as_list_recursive ('SUBDIRS', 'all');
4293 @dsubdirs = &variable_value_as_list_recursive ('DIST_SUBDIRS', 'all')
4294 if variable_defined ('DIST_SUBDIRS');
4296 # If an `obj/' directory exists, BSD make will enter it before
4297 # reading `Makefile'. Hence the `Makefile' in the current directory
4303 # % cat obj/Makefile
4309 # % pmake # BSD make
4312 msg_var ('portability', 'SUBDIRS',
4313 "naming a subdirectory `obj' causes troubles with BSD make")
4314 if grep ($_ eq 'obj', @subdirs);
4315 msg_var ('portability', 'DIST_SUBDIRS',
4316 "naming a subdirectory `obj' causes troubles with BSD make")
4317 if grep ($_ eq 'obj', @dsubdirs);
4319 # Make sure each directory mentioned in SUBDIRS actually exists.
4320 foreach my $dir (@subdirs)
4322 # Skip directories substituted by configure.
4323 next if $dir =~ /^\@.*\@$/;
4325 if (! -d $am_relative_dir . '/' . $dir)
4327 err_var ('SUBDIRS', "required directory $am_relative_dir/$dir "
4328 . "does not exist");
4332 err_var 'SUBDIRS', "directory should not contain `/'"
4336 $output_rules .= &file_contents ('subdirs');
4337 variable_pretty_output ('RECURSIVE_TARGETS', 'TRUE');
4341 # ($REGEN, @DEPENDENCIES)
4344 # If aclocal.m4 creation is automated, return the list of its dependencies.
4347 my $regen_aclocal = 0;
4349 if (-f 'aclocal.m4')
4351 # When using aclocal.m4, define this variable even in subdirectories,
4352 # because every Makefile.in depends on $(ACLOCAL_M4).
4353 &define_variable ("ACLOCAL_M4", '$(top_srcdir)/aclocal.m4');
4357 unless $relative_dir eq '.';
4359 &examine_variable ('CONFIG_STATUS_DEPENDENCIES');
4360 &examine_variable ('CONFIGURE_DEPENDENCIES');
4362 if (-f 'aclocal.m4')
4364 &push_dist_common ('aclocal.m4');
4366 my $aclocal = new Automake::XFile "< aclocal.m4";
4367 my $line = $aclocal->getline;
4368 $regen_aclocal = $line =~ 'generated automatically by aclocal';
4373 if (-f 'acinclude.m4')
4376 push @ac_deps, 'acinclude.m4';
4379 if (variable_defined ('ACLOCAL_M4_SOURCES'))
4381 push (@ac_deps, '$(ACLOCAL_M4_SOURCES)');
4383 elsif (variable_defined ('ACLOCAL_AMFLAGS'))
4385 # Scan all -I directories for m4 files. These are our
4387 my $examine_next = 0;
4388 foreach my $amdir (&variable_value_as_list_recursive ('ACLOCAL_AMFLAGS', ''))
4393 if ($amdir !~ /^\// && -d $amdir)
4395 foreach my $ac_dep (&my_glob ($amdir . '/*.m4'))
4397 $ac_dep =~ s/^\.\/+//;
4398 push (@ac_deps, $ac_dep)
4399 unless $ac_dep eq "aclocal.m4"
4400 || $ac_dep eq "acinclude.m4";
4404 elsif ($amdir eq '-I')
4411 # Note that it might be possible that aclocal.m4 doesn't exist but
4412 # should be auto-generated. This case probably isn't very
4415 return ($regen_aclocal, @ac_deps);
4420 # &rewrite_inputs_into_dependencies ($ADD_SRCDIR, @INPUTS)
4421 # --------------------------------------------------------
4422 # Rewrite a list of input files into a form suitable to put on a
4423 # dependency list. The idea is that if an input file has a directory
4424 # part the same as the current directory, then the directory part is
4425 # simply removed. But if the directory part is different, then
4426 # $(top_srcdir) is prepended. Among other things, this is used to
4427 # generate the dependency list for the output files generated by
4428 # AC_OUTPUT. Consider what the dependencies should look like in this
4430 # AC_OUTPUT(src/out:src/in1:lib/in2)
4431 # The first argument, ADD_SRCDIR, is 1 if $(top_srcdir) should be added.
4432 # If 0 then files that require this addition will simply be ignored.
4433 sub rewrite_inputs_into_dependencies ($@)
4435 my ($add_srcdir, @inputs) = @_;
4438 foreach my $single (@inputs)
4440 if (dirname ($single) eq $relative_dir)
4442 push (@newinputs, basename ($single));
4446 push (@newinputs, '$(top_srcdir)/' . $single);
4453 # Handle remaking and configure stuff.
4454 # We need the name of the input file, to do proper remaking rules.
4455 sub handle_configure
4457 my ($local, $input, @secondary_inputs) = @_;
4459 my $input_base = basename ($input);
4460 my $local_base = basename ($local);
4462 my $amfile = $input_base . '.am';
4463 # We know we can always add '.in' because it really should be an
4464 # error if the .in was missing originally.
4465 my $infile = '$(srcdir)/' . $input_base . '.in';
4466 my $colon_infile = '';
4467 if ($local ne $input || @secondary_inputs)
4469 $colon_infile = ':' . $input . '.in';
4471 $colon_infile .= ':' . join (':', @secondary_inputs)
4472 if @secondary_inputs;
4474 my @rewritten = rewrite_inputs_into_dependencies (1, @secondary_inputs);
4476 my ($regen_aclocal_m4, @aclocal_m4_deps) = scan_aclocal_m4 ();
4479 &file_contents ('configure',
4485 => ((($relative_dir eq '.') ? '$@' : '$(subdir)/$@')
4490 => "@include_stack",
4494 => $cygnus_mode ? 'cygnus' : $strictness_name,
4496 => $cmdline_use_dependencies ? '' : ' --ignore-deps',
4497 'MAKEFILE-AM-SOURCES'
4498 => "$input$colon_infile",
4500 => $regen_aclocal_m4,
4502 => "@aclocal_m4_deps"));
4504 if ($relative_dir eq '.')
4506 &push_dist_common ('acconfig.h')
4510 # If we have a configure header, require it.
4512 my @distclean_config;
4513 foreach my $spec (@config_headers)
4516 # $CONFIG_H_PATH: config.h from top level.
4517 my ($config_h_path, @ins) = split_config_file_spec ($spec);
4518 my $config_h_dir = dirname ($config_h_path);
4520 # If the header is in the current directory we want to build
4521 # the header here. Otherwise, if we're at the topmost
4522 # directory and the header's directory doesn't have a
4523 # Makefile, then we also want to build the header.
4524 if ($relative_dir eq $config_h_dir
4525 || ($relative_dir eq '.' && ! &is_make_dir ($config_h_dir)))
4527 my ($cn_sans_dir, $stamp_dir);
4528 if ($relative_dir eq $config_h_dir)
4530 $cn_sans_dir = basename ($config_h_path);
4535 $cn_sans_dir = $config_h_path;
4536 if ($config_h_dir eq '.')
4542 $stamp_dir = $config_h_dir . '/';
4546 # Compute relative path from directory holding output
4547 # header to directory holding input header. FIXME:
4548 # doesn't handle case where we have multiple inputs.
4550 if (dirname ($ins[0]) eq $relative_dir)
4552 $in0_sans_dir = basename ($ins[0]);
4556 $in0_sans_dir = backname ($relative_dir) . '/' . $ins[0];
4559 require_file ($config_header_location, FOREIGN, $in0_sans_dir);
4561 # Header defined and in this directory.
4563 if (-f $config_h_path . '.top')
4565 push (@files, "$cn_sans_dir.top");
4567 if (-f $config_h_path . '.bot')
4569 push (@files, "$cn_sans_dir.bot");
4572 push_dist_common (@files);
4574 # For now, acconfig.h can only appear in the top srcdir.
4575 if (-f 'acconfig.h')
4577 push (@files, '$(top_srcdir)/acconfig.h');
4580 my $stamp = "${stamp_dir}stamp-h${hdr_index}";
4582 file_contents ('remake-hdr',
4583 ('FILES' => "@files",
4584 'CONFIG_H' => $cn_sans_dir,
4585 'CONFIG_HIN' => $in0_sans_dir,
4586 'CONFIG_H_PATH' => $config_h_path,
4587 'STAMP' => "$stamp"));
4589 push @distclean_config, $cn_sans_dir, $stamp;
4593 $output_rules .= file_contents ('clean-hdr',
4594 ('FILES' => "@distclean_config"))
4595 if @distclean_config;
4597 # Set location of mkinstalldirs.
4598 define_variable ('mkinstalldirs',
4599 ('$(SHELL) ' . $config_aux_dir . '/mkinstalldirs'));
4601 reject_var ('CONFIG_HEADER',
4602 "`CONFIG_HEADER' is an anachronism; now determined "
4603 . "automatically\nfrom `$configure_ac'");
4606 foreach my $spec (@config_headers)
4608 my ($out, @ins) = split_config_file_spec ($spec);
4609 # Generate CONFIG_HEADER define.
4610 if ($relative_dir eq dirname ($out))
4612 push @config_h, basename ($out);
4616 push @config_h, "\$(top_builddir)/$out";
4619 define_variable ("CONFIG_HEADER", "@config_h")
4622 # Now look for other files in this directory which must be remade
4623 # by config.status, and generate rules for them.
4624 my @actual_other_files = ();
4625 foreach my $lfile (@other_input_files)
4629 if ($lfile =~ /^([^:]*):(.*)$/)
4631 # This is the ":" syntax of AC_OUTPUT.
4633 @inputs = split (':', $2);
4639 @inputs = $file . '.in';
4642 # Automake files should not be stored in here, but in %MAKE_LIST.
4643 prog_error "$lfile in \@other_input_files"
4644 if -f $file . '.am';
4646 my $local = basename ($file);
4648 # Make sure the dist directory for each input file is created.
4649 # We only have to do this at the topmost level though. This
4650 # is a bit ugly but it easier than spreading out the logic,
4651 # especially in cases like AC_OUTPUT(foo/out:bar/in), where
4652 # there is no Makefile in bar/.
4653 if ($relative_dir eq '.')
4657 $dist_dirs{dirname ($_)} = 1;
4661 # We skip files that aren't in this directory. However, if
4662 # the file's directory does not have a Makefile, and we are
4663 # currently doing `.', then we create a rule to rebuild the
4664 # file in the subdir.
4665 my $fd = dirname ($file);
4666 if ($fd ne $relative_dir)
4668 if ($relative_dir eq '.' && ! &is_make_dir ($fd))
4678 my @rewritten_inputs = rewrite_inputs_into_dependencies (1, @inputs);
4679 $output_rules .= ($local . ': '
4680 . '$(top_builddir)/config.status '
4681 . "@rewritten_inputs\n"
4683 . 'cd $(top_builddir) && '
4684 . '$(SHELL) ./config.status '
4685 . ($relative_dir eq '.' ? '' : '$(subdir)/')
4688 push (@actual_other_files, $local);
4690 # Require all input files.
4691 require_file ($ac_config_files_location, FOREIGN,
4692 rewrite_inputs_into_dependencies (0, @inputs));
4695 # These files get removed by "make clean".
4696 define_pretty_variable ('CONFIG_CLEAN_FILES', '', @actual_other_files);
4702 my @r = &am_install_var ('-defaultdist', 'header', 'HEADERS', 'include',
4703 'oldinclude', 'pkginclude',
4707 next unless /\..*$/;
4708 &saw_extension ($&);
4714 return if ! $seen_gettext || $relative_dir ne '.';
4716 if (! variable_defined ('SUBDIRS'))
4718 err_ac "AM_GNU_GETTEXT used but SUBDIRS not defined";
4722 # Perform some sanity checks to help users get the right setup.
4723 # We disable these tests when po/ doesn't exist in order not to disallow
4724 # unusual gettext setups.
4729 # | 1) If a package doesn't have a directory po/ at top level, it
4730 # | will likely have multiple po/ directories in subpackages.
4732 # | 2) It is useful to warn for the absence of intl/ if AM_GNU_GETTEXT
4733 # | is used without 'external'. It is also useful to warn for the
4734 # | presence of intl/ if AM_GNU_GETTEXT([external]) is used. Both
4735 # | warnings apply only to the usual layout of packages, therefore
4736 # | they should both be disabled if no po/ directory is found at
4741 my @subdirs = &variable_value_as_list_recursive ('SUBDIRS', 'all');
4743 msg_var ('syntax', 'SUBDIRS',
4744 "AM_GNU_GETTEXT used but `po' not in SUBDIRS")
4745 if ! grep ($_ eq 'po', @subdirs);
4747 # intl/ is not required when AM_GNU_GETTEXT is called with
4748 # the `external' option.
4749 msg_var ('syntax', 'SUBDIRS',
4750 "AM_GNU_GETTEXT used but `intl' not in SUBDIRS")
4751 if (! $seen_gettext_external
4752 && ! grep ($_ eq 'intl', @subdirs));
4754 # intl/ should not be used with AM_GNU_GETTEXT([external])
4755 msg_var ('syntax', 'SUBDIRS',
4756 "`intl' should not be in SUBDIRS when "
4757 . "AM_GNU_GETTEXT([external]) is used")
4758 if ($seen_gettext_external && grep ($_ eq 'intl', @subdirs));
4761 require_file ($ac_gettext_location, GNU, 'ABOUT-NLS');
4764 # Handle footer elements.
4767 # NOTE don't use define_pretty_variable here, because
4768 # $contents{...} is already defined.
4769 $output_vars .= 'SOURCES = ' . variable_value ('SOURCES') . "\n\n"
4770 if variable_value ('SOURCES');
4772 reject_target ('.SUFFIXES',
4773 "use variable `SUFFIXES', not target `.SUFFIXES'");
4775 # Note: AIX 4.1 /bin/make will fail if any suffix rule appears
4776 # before .SUFFIXES. So we make sure that .SUFFIXES appears before
4777 # anything else, by sticking it right after the default: target.
4778 $output_header .= ".SUFFIXES:\n";
4779 if (@suffixes || variable_defined ('SUFFIXES'))
4781 # Make sure suffixes has unique elements. Sort them to ensure
4782 # the output remains consistent. However, $(SUFFIXES) is
4783 # always at the start of the list, unsorted. This is done
4784 # because make will choose rules depending on the ordering of
4785 # suffixes, and this lets the user have some control. Push
4786 # actual suffixes, and not $(SUFFIXES). Some versions of make
4787 # do not like variable substitutions on the .SUFFIXES line.
4788 my @user_suffixes = (variable_defined ('SUFFIXES')
4789 ? &variable_value_as_list_recursive ('SUFFIXES', '')
4792 my %suffixes = map { $_ => 1 } @suffixes;
4793 delete @suffixes{@user_suffixes};
4795 $output_header .= (".SUFFIXES: "
4796 . join (' ', @user_suffixes, sort keys %suffixes)
4800 $output_trailer .= file_contents ('footer');
4803 # Deal with installdirs target.
4804 sub handle_installdirs ()
4807 &file_contents ('install',
4809 => variable_value ('am__installdirs') || '',
4811 => (target_defined ('installdirs-local')
4812 ? ' installdirs-local' : '')));
4816 # Deal with all and all-am.
4819 my ($makefile) = @_;
4823 # Put this at the beginning for the sake of non-GNU makes. This
4824 # is still wrong if these makes can run parallel jobs. But it is
4826 unshift (@all, basename ($makefile));
4828 foreach my $spec (@config_headers)
4830 my ($out, @ins) = split_config_file_spec ($spec);
4831 push (@all, basename ($out))
4832 if dirname ($out) eq $relative_dir;
4835 # Install `all' hooks.
4836 if (&target_defined ("all-local"))
4838 push (@all, "all-local");
4839 &depend ('.PHONY', "all-local");
4842 &pretty_print_rule ("all-am:", "\t\t", @all);
4843 &depend ('.PHONY', 'all-am', 'all');
4848 my @local_headers = ();
4849 push @local_headers, '$(BUILT_SOURCES)'
4850 if variable_defined ('BUILT_SOURCES');
4851 foreach my $spec (@config_headers)
4853 my ($out, @ins) = split_config_file_spec ($spec);
4854 push @local_headers, basename ($out)
4855 if dirname ($out) eq $relative_dir;
4860 # We need to make sure config.h is built before we recurse.
4861 # We also want to make sure that built sources are built
4862 # before any ordinary `all' targets are run. We can't do this
4863 # by changing the order of dependencies to the "all" because
4864 # that breaks when using parallel makes. Instead we handle
4865 # things explicitly.
4866 $output_all .= ("all: @local_headers"
4868 . '$(MAKE) $(AM_MAKEFLAGS) '
4869 . (variable_defined ('SUBDIRS')
4870 ? 'all-recursive' : 'all-am')
4875 $output_all .= "all: " . (variable_defined ('SUBDIRS')
4876 ? 'all-recursive' : 'all-am') . "\n\n";
4881 # Handle check merge target specially.
4882 sub do_check_merge_target
4884 if (&target_defined ('check-local'))
4886 # User defined local form of target. So include it.
4887 push (@check_tests, 'check-local');
4888 &depend ('.PHONY', 'check-local');
4891 # In --cygnus mode, check doesn't depend on all.
4894 # Just run the local check rules.
4895 &pretty_print_rule ('check-am:', "\t\t", @check);
4899 # The check target must depend on the local equivalent of
4900 # `all', to ensure all the primary targets are built. Then it
4901 # must build the local check rules.
4902 $output_rules .= "check-am: all-am\n";
4903 &pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ",
4907 &pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ",
4911 &depend ('.PHONY', 'check', 'check-am');
4912 # Handle recursion. We have to honor BUILT_SOURCES like for `all:'.
4913 $output_rules .= ("check: "
4914 . (variable_defined ('BUILT_SOURCES')
4915 ? "\$(BUILT_SOURCES)\n\t\$(MAKE) \$(AM_MAKEFLAGS) "
4917 . (variable_defined ('SUBDIRS')
4918 ? 'check-recursive' : 'check-am')
4922 # Handle all 'clean' targets.
4925 # Clean the files listed in user variables if they exist.
4926 $clean_files{'$(MOSTLYCLEANFILES)'} = MOSTLY_CLEAN
4927 if variable_defined ('MOSTLYCLEANFILES');
4928 $clean_files{'$(CLEANFILES)'} = CLEAN
4929 if variable_defined ('CLEANFILES');
4930 $clean_files{'$(DISTCLEANFILES)'} = DIST_CLEAN
4931 if variable_defined ('DISTCLEANFILES');
4932 $clean_files{'$(MAINTAINERCLEANFILES)'} = MAINTAINER_CLEAN
4933 if variable_defined ('MAINTAINERCLEANFILES');
4935 # Built sources are automatically removed by maintainer-clean.
4936 $clean_files{'$(BUILT_SOURCES)'} = MAINTAINER_CLEAN
4937 if variable_defined ('BUILT_SOURCES');
4939 # Compute a list of "rm"s to run for each target.
4940 my %rms = (MOSTLY_CLEAN, [],
4943 MAINTAINER_CLEAN, []);
4945 foreach my $file (keys %clean_files)
4947 my $when = $clean_files{$file};
4948 prog_error 'invalid entry in %clean_files'
4949 unless exists $rms{$when};
4951 my $rm = "rm -f $file";
4952 # If file is a variable, make sure when don't call `rm -f' without args.
4953 $rm ="test -z \"$file\" || $rm"
4954 if ($file =~ /^\s*\$(\(.*\)|\{.*\})\s*$/);
4956 push @{$rms{$when}}, "\t-$rm\n";
4959 $output_rules .= &file_contents
4961 MOSTLYCLEAN_RMS => join ('', @{$rms{&MOSTLY_CLEAN}}),
4962 CLEAN_RMS => join ('', @{$rms{&CLEAN}}),
4963 DISTCLEAN_RMS => join ('', @{$rms{&DIST_CLEAN}}),
4964 MAINTAINER_CLEAN_RMS => join ('', @{$rms{&MAINTAINER_CLEAN}}));
4968 # &depend ($CATEGORY, @DEPENDENDEES)
4969 # ----------------------------------
4970 # The target $CATEGORY depends on @DEPENDENDEES.
4973 my ($category, @dependendees) = @_;
4975 push (@{$dependencies{$category}}, @dependendees);
4980 # &target_cmp ($A, $B)
4981 # --------------------
4982 # Subroutine for &handle_factored_dependencies to let `.PHONY' be last.
4995 # &handle_factored_dependencies ()
4996 # --------------------------------
4997 # Handle everything related to gathered targets.
4998 sub handle_factored_dependencies
5001 foreach my $utarg ('uninstall-data-local', 'uninstall-data-hook',
5002 'uninstall-exec-local', 'uninstall-exec-hook')
5005 $x =~ s/(data|exec)-//;
5006 reject_target ($utarg, "use `$x', not `$utarg'");
5009 reject_target ('install-local',
5010 "use `install-data-local' or `install-exec-local', "
5011 . "not `install-local'");
5013 reject_target ('install-info-local',
5014 "`install-info-local' target defined but "
5015 . "`no-installinfo' option not in use")
5016 unless defined $options{'no-installinfo'};
5018 # Install the -local hooks.
5019 foreach (keys %dependencies)
5021 # Hooks are installed on the -am targets.
5023 if (&target_defined ("$_-local"))
5025 depend ("$_-am", "$_-local");
5026 &depend ('.PHONY', "$_-local");
5030 # Install the -hook hooks.
5031 # FIXME: Why not be as liberal as we are with -local hooks?
5032 foreach ('install-exec', 'install-data', 'uninstall')
5034 if (&target_defined ("$_-hook"))
5036 $actions{"$_-am"} .=
5037 ("\t\@\$(NORMAL_INSTALL)\n"
5038 . "\t" . '$(MAKE) $(AM_MAKEFLAGS) ' . "$_-hook\n");
5042 # All the required targets are phony.
5043 depend ('.PHONY', keys %required_targets);
5045 # Actually output gathered targets.
5046 foreach (sort target_cmp keys %dependencies)
5048 # If there is nothing about this guy, skip it.
5050 unless (@{$dependencies{$_}}
5052 || $required_targets{$_});
5053 &pretty_print_rule ("$_:", "\t",
5054 uniq (sort @{$dependencies{$_}}));
5055 $output_rules .= $actions{$_}
5056 if defined $actions{$_};
5057 $output_rules .= "\n";
5062 # &handle_tests_dejagnu ()
5063 # ------------------------
5064 sub handle_tests_dejagnu
5066 push (@check_tests, 'check-DEJAGNU');
5067 $output_rules .= file_contents ('dejagnu');
5071 # Handle TESTS variable and other checks.
5074 if (defined $options{'dejagnu'})
5076 &handle_tests_dejagnu;
5080 foreach my $c ('DEJATOOL', 'RUNTEST', 'RUNTESTFLAGS')
5082 reject_var ($c, "`$c' defined but `dejagnu' not in "
5083 . "`AUTOMAKE_OPTIONS'");
5087 if (variable_defined ('TESTS'))
5089 push (@check_tests, 'check-TESTS');
5090 $output_rules .= &file_contents ('check');
5094 # Handle Emacs Lisp.
5095 sub handle_emacs_lisp
5097 my @elfiles = &am_install_var ('-candist', 'lisp', 'LISP',
5100 return if ! @elfiles;
5102 # Generate .elc files.
5103 my @elcfiles = map { $_ . 'c' } @elfiles;
5104 define_pretty_variable ('ELCFILES', '', @elcfiles);
5106 define_pretty_variable ('am__ELFILES', '', @elfiles);
5108 # Do not depend on the build rules if ELCFILES is empty.
5109 # This is necessary because overriding ELCFILES= is a documented
5110 # idiom to disable byte-compilation.
5111 if (variable_value ('ELCFILES'))
5113 # It's important that all depends on elc-stamp so that
5114 # all .elc files get recompiled whenever a .el changes.
5115 # It's important that all depends on $(ELCFILES) so that
5116 # we can recover if any of them is deleted.
5117 push (@all, 'elc-stamp', '$(ELCFILES)');
5120 require_variables ("$am_file.am", "Emacs Lisp sources seen", 'TRUE',
5121 'EMACS', 'lispdir');
5122 require_conf_file ("$am_file.am", FOREIGN, 'elisp-comp');
5123 &define_variable ('elisp_comp', $config_aux_dir . '/elisp-comp');
5129 my @pyfiles = &am_install_var ('-defaultdist', 'python', 'PYTHON',
5131 return if ! @pyfiles;
5133 require_variables ("$am_file.am", "Python sources seen", 'TRUE',
5135 require_conf_file ("$am_file.am", FOREIGN, 'py-compile');
5136 &define_variable ('py_compile', $config_aux_dir . '/py-compile');
5142 my @sourcelist = &am_install_var ('-candist',
5144 'java', 'noinst', 'check');
5145 return if ! @sourcelist;
5147 my @prefix = am_primary_prefixes ('JAVA', 1,
5148 'java', 'noinst', 'check');
5151 foreach my $curs (@prefix)
5154 if $curs eq 'EXTRA';
5156 err_var "${curs}_JAVA", "multiple _JAVA primaries in use"
5162 push (@all, 'class' . $dir . '.stamp');
5166 # Handle some of the minor options.
5167 sub handle_minor_options
5169 if (defined $options{'readme-alpha'})
5171 if ($relative_dir eq '.')
5173 if ($package_version !~ /^$GNITS_VERSION_PATTERN$/)
5175 msg ('error-gnits', $package_version_location,
5176 "version `$package_version' doesn't follow " .
5179 if (defined $1 && -f 'README-alpha')
5181 # This means we have an alpha release. See
5182 # GNITS_VERSION_PATTERN for details.
5183 require_file_with_macro ('TRUE', 'AUTOMAKE_OPTIONS',
5184 FOREIGN, 'README-alpha');
5190 ################################################################
5192 # ($OUTPUT, @INPUTS)
5193 # &split_config_file_spec ($SPEC)
5194 # -------------------------------
5195 # Decode the Autoconf syntax for config files (files, headers, links
5197 sub split_config_file_spec ($)
5200 my ($output, @inputs) = split (/:/, $spec);
5202 push @inputs, "$output.in"
5205 return ($output, @inputs);
5211 # &scan_autoconf_config_files ($CONFIG-FILES)
5212 # -------------------------------------------
5213 # Study $CONFIG-FILES which is the first argument to AC_CONFIG_FILES
5215 sub scan_autoconf_config_files
5217 my ($config_files) = @_;
5218 # Look at potential Makefile.am's.
5219 foreach (split ' ', $config_files)
5221 # Must skip empty string for Perl 4.
5222 next if $_ eq "\\" || $_ eq '';
5224 # Handle $local:$input syntax. Note that we ignore
5225 # every input file past the first, though we keep
5226 # those around for later.
5227 my ($local, $input, @rest) = split (/:/);
5234 # FIXME: should be error if .in is missing.
5235 $input =~ s/\.in$//;
5238 if (-f $input . '.am')
5240 # We have a file that automake should generate.
5241 $make_list{$input} = join (':', ($local, @rest));
5245 # We have a file that automake should cause to be
5246 # rebuilt, but shouldn't generate itself.
5247 push (@other_input_files, $_);
5253 # &scan_autoconf_traces ($FILENAME)
5254 # ---------------------------------
5255 sub scan_autoconf_traces ($)
5257 my ($filename) = @_;
5259 my @traced = qw(AC_CANONICAL_HOST
5274 my $traces = ($ENV{AUTOCONF} || 'autoconf') . " ";
5276 # Use a separator unlikely to be used, not `:', the default, which
5277 # has a precise meaning for AC_CONFIG_FILES and so on.
5278 $traces .= join (' ',
5279 map { "--trace=$_" . ':\$f:\$l::\$n::\${::}%' } @traced);
5281 my $tracefh = new Automake::XFile ("$traces $filename |");
5282 verb "reading $traces";
5284 while ($_ = $tracefh->getline)
5287 my ($here, @args) = split /::/;
5288 my $macro = $args[0];
5290 # Alphabetical ordering please.
5291 if ($macro eq 'AC_CANONICAL_HOST')
5293 if (! $seen_canonical)
5295 $seen_canonical = AC_CANONICAL_HOST;
5296 $canonical_location = $here;
5299 elsif ($macro eq 'AC_CANONICAL_SYSTEM')
5301 $seen_canonical = AC_CANONICAL_SYSTEM;
5302 $canonical_location = $here;
5304 elsif ($macro eq 'AC_CONFIG_AUX_DIR')
5306 @config_aux_path = $args[1];
5307 $config_aux_dir_set_in_configure_in = 1;
5309 elsif ($macro eq 'AC_CONFIG_FILES')
5311 # Look at potential Makefile.am's.
5312 $ac_config_files_location = $here;
5313 &scan_autoconf_config_files ($args[1]);
5315 elsif ($macro eq 'AC_CONFIG_HEADERS')
5317 $config_header_location = $here;
5318 push @config_headers, split (' ', $args[1]);
5320 elsif ($macro eq 'AC_INIT')
5322 if (defined $args[2])
5324 $package_version = $args[2];
5325 $package_version_location = $here;
5328 elsif ($macro eq 'AC_LIBSOURCE')
5330 $libsources{$args[1]} = $here;
5332 elsif ($macro eq 'AC_SUBST')
5334 # Just check for alphanumeric in AC_SUBST. If you do
5335 # AC_SUBST(5), then too bad.
5336 $configure_vars{$args[1]} = $here
5337 if $args[1] =~ /^\w+$/;
5339 elsif ($macro eq 'AM_AUTOMAKE_VERSION')
5342 "version mismatch. This is Automake $VERSION,\n" .
5343 "but the definition used by this AM_INIT_AUTOMAKE\n" .
5344 "comes from Automake $args[1]. You should recreate\n" .
5345 "aclocal.m4 with aclocal and run automake again.\n")
5346 if $VERSION ne $args[1];
5348 $seen_automake_version = 1;
5350 elsif ($macro eq 'AM_CONDITIONAL')
5352 $configure_cond{$args[1]} = $here;
5354 elsif ($macro eq 'AM_GNU_GETTEXT')
5356 $seen_gettext = $here;
5357 $ac_gettext_location = $here;
5358 $seen_gettext_external = grep ($_ eq 'external', @args);
5360 elsif ($macro eq 'AM_INIT_AUTOMAKE')
5362 $seen_init_automake = $here;
5363 if (defined $args[2])
5365 $package_version = $args[2];
5366 $package_version_location = $here;
5368 elsif (defined $args[1])
5370 $global_options = $args[1];
5373 elsif ($macro eq 'AM_MAINTAINER_MODE')
5375 $seen_maint_mode = $here;
5377 elsif ($macro eq 'AM_PROG_CC_C_O')
5379 $seen_cc_c_o = $here;
5385 # &scan_autoconf_files ()
5386 # -----------------------
5387 # Check whether we use `configure.ac' or `configure.in'.
5388 # Scan it (and possibly `aclocal.m4') for interesting things.
5389 # We must scan aclocal.m4 because there might be AC_SUBSTs and such there.
5390 sub scan_autoconf_files
5392 # Reinitialize libsources here. This isn't really necessary,
5393 # since we currently assume there is only one configure.ac. But
5394 # that won't always be the case.
5397 $configure_ac = find_configure_ac;
5398 fatal "`configure.ac' or `configure.in' is required\n"
5401 scan_autoconf_traces ($configure_ac);
5403 # Set input and output files if not specified by user.
5406 @input_files = sort keys %make_list;
5407 %output_files = %make_list;
5410 @configure_input_files = sort keys %make_list;
5412 if (! $seen_init_automake)
5414 err_ac "`AM_INIT_AUTOMAKE' must be used";
5418 if (! $seen_automake_version)
5420 if (-f 'aclocal.m4')
5422 error ($seen_init_automake,
5423 "your implementation of AM_INIT_AUTOMAKE comes from " .
5424 "an\nold Automake version. You should recreate " .
5425 "aclocal.m4\nwith aclocal and run automake again.\n");
5429 error ($seen_init_automake,
5430 "no proper implementation of AM_INIT_AUTOMAKE was " .
5431 "found,\nprobably because aclocal.m4 is missing...\n" .
5432 "You should run aclocal to create this file, then\n" .
5433 "run automake again.\n");
5438 # Look for some files we need. Always check for these. This
5439 # check must be done for every run, even those where we are only
5440 # looking at a subdir Makefile. We must set relative_dir so that
5441 # the file-finding machinery works.
5442 # FIXME: Is this broken because it needs dynamic scopes.
5443 # My tests seems to show it's not the case.
5444 $relative_dir = '.';
5445 require_conf_file ($configure_ac, FOREIGN,
5446 'install-sh', 'mkinstalldirs', 'missing');
5447 err_am "`install.sh' is an anachronism; use `install-sh' instead"
5448 if -f $config_aux_path[0] . '/install.sh';
5450 # Preserve dist_common for later.
5451 $configure_dist_common = variable_value ('DIST_COMMON', 'TRUE') || '';
5454 ################################################################
5456 # Set up for Cygnus mode.
5459 return unless $cygnus_mode;
5461 &set_strictness ('foreign');
5462 $options{'no-installinfo'} = 1;
5463 $options{'no-dependencies'} = 1;
5464 $use_dependencies = 0;
5466 err_ac "`AM_MAINTAINER_MODE' required when --cygnus specified"
5467 if !$seen_maint_mode;
5470 # Do any extra checking for GNU standards.
5471 sub check_gnu_standards
5473 if ($relative_dir eq '.')
5475 # In top level (or only) directory.
5477 # Accept one of these three licenses; default to COPYING.
5478 my $license = 'COPYING';
5479 foreach (qw /COPYING.LIB COPYING.LESSER/)
5481 $license = $_ if -f $_;
5483 require_file ("$am_file.am", GNU, $license,
5484 qw/INSTALL NEWS README AUTHORS ChangeLog/);
5487 for my $opt ('no-installman', 'no-installinfo')
5489 msg_var ('error-gnu', 'AUTOMAKE_OPTIONS',
5490 "option `$opt' disallowed by GNU standards")
5491 if (defined $options{$opt});
5495 # Do any extra checking for GNITS standards.
5496 sub check_gnits_standards
5498 if ($relative_dir eq '.')
5500 # In top level (or only) directory.
5501 require_file ("$am_file.am", GNITS, 'THANKS');
5505 ################################################################
5507 # Functions to handle files of each language.
5509 # Each `lang_X_rewrite($DIRECTORY, $BASE, $EXT)' function follows a
5510 # simple formula: Return value is LANG_SUBDIR if the resulting object
5511 # file should be in a subdir if the source file is, LANG_PROCESS if
5512 # file is to be dealt with, LANG_IGNORE otherwise.
5514 # Much of the actual processing is handled in
5515 # handle_single_transform_list. These functions exist so that
5516 # auxiliary information can be recorded for a later cleanup pass.
5517 # Note that the calls to these functions are computed, so don't bother
5518 # searching for their precise names in the source.
5520 # This is just a convenience function that can be used to determine
5521 # when a subdir object should be used.
5524 return defined $options{'subdir-objects'} ? LANG_SUBDIR : LANG_PROCESS;
5527 # Rewrite a single C source file.
5530 my ($directory, $base, $ext) = @_;
5532 if (defined $options{'ansi2knr'} && $base =~ /_$/)
5534 # FIXME: include line number in error.
5535 err_am "C source file `$base.c' would be deleted by ansi2knr rules";
5538 my $r = LANG_PROCESS;
5539 if (defined $options{'subdir-objects'})
5542 $base = $directory . '/' . $base
5543 unless $directory eq '.' || $directory eq '';
5545 err_am ("C objects in subdir but `AM_PROG_CC_C_O' "
5546 . "not in `$configure_ac'",
5547 uniq_scope => US_GLOBAL)
5548 unless $seen_cc_c_o;
5550 require_conf_file ("$am_file.am", FOREIGN, 'compile');
5552 # In this case we already have the directory information, so
5553 # don't add it again.
5554 $de_ansi_files{$base} = '';
5558 $de_ansi_files{$base} = (($directory eq '.' || $directory eq '')
5566 # Rewrite a single C++ source file.
5567 sub lang_cxx_rewrite
5569 return &lang_sub_obj;
5572 # Rewrite a single header file.
5573 sub lang_header_rewrite
5575 # Header files are simply ignored.
5579 # Rewrite a single yacc file.
5580 sub lang_yacc_rewrite
5582 my ($directory, $base, $ext) = @_;
5584 my $r = &lang_sub_obj;
5585 (my $newext = $ext) =~ tr/y/c/;
5586 return ($r, $newext);
5589 # Rewrite a single yacc++ file.
5590 sub lang_yaccxx_rewrite
5592 my ($directory, $base, $ext) = @_;
5594 my $r = &lang_sub_obj;
5595 (my $newext = $ext) =~ tr/y/c/;
5596 return ($r, $newext);
5599 # Rewrite a single lex file.
5600 sub lang_lex_rewrite
5602 my ($directory, $base, $ext) = @_;
5604 my $r = &lang_sub_obj;
5605 (my $newext = $ext) =~ tr/l/c/;
5606 return ($r, $newext);
5609 # Rewrite a single lex++ file.
5610 sub lang_lexxx_rewrite
5612 my ($directory, $base, $ext) = @_;
5614 my $r = &lang_sub_obj;
5615 (my $newext = $ext) =~ tr/l/c/;
5616 return ($r, $newext);
5619 # Rewrite a single assembly file.
5620 sub lang_asm_rewrite
5622 return &lang_sub_obj;
5625 # Rewrite a single Fortran 77 file.
5626 sub lang_f77_rewrite
5628 return LANG_PROCESS;
5631 # Rewrite a single preprocessed Fortran 77 file.
5632 sub lang_ppf77_rewrite
5634 return LANG_PROCESS;
5637 # Rewrite a single ratfor file.
5638 sub lang_ratfor_rewrite
5640 return LANG_PROCESS;
5643 # Rewrite a single Objective C file.
5644 sub lang_objc_rewrite
5646 return &lang_sub_obj;
5649 # Rewrite a single Java file.
5650 sub lang_java_rewrite
5655 # The lang_X_finish functions are called after all source file
5656 # processing is done. Each should handle defining rules for the
5657 # language, etc. A finish function is only called if a source file of
5658 # the appropriate type has been seen.
5662 # Push all libobjs files onto de_ansi_files. We actually only
5663 # push files which exist in the current directory, and which are
5664 # genuine source files.
5665 foreach my $file (keys %libsources)
5667 if ($file =~ /^(.*)\.[cly]$/ && -f "$relative_dir/$file")
5669 $de_ansi_files{$1} = ''
5673 if (defined $options{'ansi2knr'} && keys %de_ansi_files)
5675 # Make all _.c files depend on their corresponding .c files.
5677 foreach my $base (sort keys %de_ansi_files)
5679 # Each _.c file must depend on ansi2knr; otherwise it
5680 # might be used in a parallel build before it is built.
5681 # We need to support files in the srcdir and in the build
5682 # dir (because these files might be auto-generated. But
5683 # we can't use $< -- some makes only define $< during a
5685 my $ansfile = $de_ansi_files{$base} . $base . '.c';
5686 $output_rules .= ($base . "_.c: $ansfile \$(ANSI2KNR)\n\t"
5687 . '$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) '
5688 . '`if test -f $(srcdir)/' . $ansfile
5689 . '; then echo $(srcdir)/' . $ansfile
5690 . '; else echo ' . $ansfile . '; fi` '
5691 . "| sed 's/^# \\([0-9]\\)/#line \\1/' "
5692 . '| $(ANSI2KNR) > $@'
5693 # If ansi2knr fails then we shouldn't
5694 # create the _.c file
5695 . " || rm -f \$\@\n");
5696 push (@objects, $base . '_.$(OBJEXT)');
5697 push (@objects, $base . '_.lo')
5698 if variable_defined ('LIBTOOL');
5701 # Make all _.o (and _.lo) files depend on ansi2knr.
5702 # Use a sneaky little hack to make it print nicely.
5703 &pretty_print_rule ('', '', @objects, ':', '$(ANSI2KNR)');
5707 # This is a yacc helper which is called whenever we have decided to
5708 # compile a yacc file.
5709 sub lang_yacc_target_hook
5711 my ($self, $aggregate, $output, $input) = @_;
5713 my $flag = $aggregate . "_YFLAGS";
5714 if ((variable_defined ($flag)
5715 && &variable_value ($flag) =~ /$DASH_D_PATTERN/o)
5716 || (variable_defined ('YFLAGS')
5717 && &variable_value ('YFLAGS') =~ /$DASH_D_PATTERN/o))
5719 (my $output_base = $output) =~ s/$KNOWN_EXTENSIONS_PATTERN$//;
5720 my $header = $output_base . '.h';
5722 # Found a `-d' that applies to the compilation of this file.
5723 # Add a dependency for the generated header file, and arrange
5724 # for that file to be included in the distribution.
5725 # FIXME: this fails for `nodist_*_SOURCES'.
5726 $output_rules .= ("${header}: $output\n"
5727 # Recover from removal of $header
5728 . "\t\@if test ! -f \$@; then \\\n"
5729 . "\t rm -f $output; \\\n"
5730 . "\t \$(MAKE) $output; \\\n"
5731 . "\telse :; fi\n");
5732 &push_dist_common ($header);
5733 # If the files are built in the build directory, then we want
5734 # to remove them with `make clean'. If they are in srcdir
5735 # they shouldn't be touched. However, we can't determine this
5736 # statically, and the GNU rules say that yacc/lex output files
5737 # should be removed by maintainer-clean. So that's what we
5739 $clean_files{$header} = MAINTAINER_CLEAN;
5741 # Erase $OUTPUT on `make maintainer-clean' (by GNU standards).
5742 # See the comment above for $HEADER.
5743 $clean_files{$output} = MAINTAINER_CLEAN;
5746 # This is a lex helper which is called whenever we have decided to
5747 # compile a lex file.
5748 sub lang_lex_target_hook
5750 my ($self, $aggregate, $output, $input) = @_;
5751 # If the files are built in the build directory, then we want to
5752 # remove them with `make clean'. If they are in srcdir they
5753 # shouldn't be touched. However, we can't determine this
5754 # statically, and the GNU rules say that yacc/lex output files
5755 # should be removed by maintainer-clean. So that's what we do.
5756 $clean_files{$output} = MAINTAINER_CLEAN;
5759 # This is a helper for both lex and yacc.
5760 sub yacc_lex_finish_helper
5762 return if defined $language_scratch{'lex-yacc-done'};
5763 $language_scratch{'lex-yacc-done'} = 1;
5765 # If there is more than one distinct yacc (resp lex) source file
5766 # in a given directory, then the `ylwrap' program is required to
5767 # allow parallel builds to work correctly. FIXME: for now, no
5769 require_conf_file ($configure_ac, FOREIGN, 'ylwrap');
5770 if ($config_aux_dir_set_in_configure_in)
5772 &define_variable ('YLWRAP', $config_aux_dir . "/ylwrap");
5776 &define_variable ('YLWRAP', '$(top_srcdir)/ylwrap');
5780 sub lang_yacc_finish
5782 return if defined $language_scratch{'yacc-done'};
5783 $language_scratch{'yacc-done'} = 1;
5785 reject_var 'YACCFLAGS', "`YACCFLAGS' obsolete; use `YFLAGS' instead";
5787 &yacc_lex_finish_helper
5788 if count_files_for_language ('yacc') > 1;
5794 return if defined $language_scratch{'lex-done'};
5795 $language_scratch{'lex-done'} = 1;
5797 &yacc_lex_finish_helper
5798 if count_files_for_language ('lex') > 1;
5802 # Given a hash table of linker names, pick the name that has the most
5803 # precedence. This is lame, but something has to have global
5804 # knowledge in order to eliminate the conflict. Add more linkers as
5810 foreach my $l (qw(GCJLINK CXXLINK F77LINK OBJCLINK))
5812 return $l if defined $linkers{$l};
5817 # Called to indicate that an extension was used.
5821 if (! defined $extension_seen{$ext})
5823 $extension_seen{$ext} = 1;
5827 ++$extension_seen{$ext};
5831 # Return the number of files seen for a given language. Knows about
5832 # special cases we care about. FIXME: this is hideous. We need
5833 # something that involves real language objects. For instance yacc
5834 # and yaccxx could both derive from a common yacc class which would
5835 # know about the strange ylwrap requirement. (Or better yet we could
5836 # just not support legacy yacc!)
5837 sub count_files_for_language
5842 if ($name eq 'yacc' || $name eq 'yaccxx')
5844 @names = ('yacc', 'yaccxx');
5846 elsif ($name eq 'lex' || $name eq 'lexxx')
5848 @names = ('lex', 'lexxx');
5856 foreach $name (@names)
5858 my $lang = $languages{$name};
5859 foreach my $ext (@{$lang->extensions})
5861 $r += $extension_seen{$ext}
5862 if defined $extension_seen{$ext};
5869 # Called to ask whether source files have been seen . If HEADERS is 1,
5870 # headers can be included.
5875 # count all the sources
5877 foreach my $val (values %extension_seen)
5884 $count -= count_files_for_language ('header');
5891 # register_language (%ATTRIBUTE)
5892 # ------------------------------
5893 # Register a single language.
5894 # Each %ATTRIBUTE is of the form ATTRIBUTE => VALUE.
5895 sub register_language (%)
5901 unless defined $option{'ansi'};
5902 $option{'autodep'} = 'no'
5903 unless defined $option{'autodep'};
5904 $option{'linker'} = ''
5905 unless defined $option{'linker'};
5906 $option{'flags'} = []
5907 unless defined $option{'flags'};
5908 $option{'output_extensions'} = sub { return ( '.$(OBJEXT)', '.lo' ) }
5909 unless defined $option{'output_extensions'};
5911 my $lang = new Language (%option);
5914 grep ($extension_map{$_} = $lang->name, @{$lang->extensions});
5915 $languages{$lang->name} = $lang;
5917 # Update the pattern of known extensions.
5918 accept_extensions (@{$lang->extensions});
5920 # Upate the $suffix_rule map.
5921 foreach my $suffix (@{$lang->extensions})
5923 foreach my $dest (&{$lang->output_extensions} ($suffix))
5925 ®ister_suffix_rule ('internal', $suffix, $dest);
5930 # derive_suffix ($EXT, $OBJ)
5931 # --------------------------
5932 # This function is used to find a path from a user-specified suffix $EXT
5933 # to $OBJ or to some other suffix we recognize internally, eg `cc'.
5934 sub derive_suffix ($$)
5936 my ($source_ext, $obj) = @_;
5938 while (! $extension_map{$source_ext}
5939 && $source_ext ne $obj
5940 && exists $suffix_rules->{$source_ext}
5941 && exists $suffix_rules->{$source_ext}{$obj})
5943 $source_ext = $suffix_rules->{$source_ext}{$obj}[0];
5950 ################################################################
5952 # Pretty-print something. HEAD is what should be printed at the
5953 # beginning of the first line, FILL is what should be printed at the
5954 # beginning of every subsequent line.
5955 sub pretty_print_internal
5957 my ($head, $fill, @values) = @_;
5959 my $column = length ($head);
5962 # Fill length is number of characters. However, each Tab
5963 # character counts for eight. So we count the number of Tabs and
5965 my $fill_length = length ($fill);
5966 $fill_length += 7 * ($fill =~ tr/\t/\t/d);
5970 # "71" because we also print a space.
5971 if ($column + length ($_) > 71)
5973 $result .= " \\\n" . $fill;
5974 $column = $fill_length;
5976 $result .= ' ' if $result =~ /\S\z/;
5978 $column += length ($_) + 1;
5985 # Pretty-print something and append to output_vars.
5988 $output_vars .= &pretty_print_internal (@_);
5991 # Pretty-print something and append to output_rules.
5992 sub pretty_print_rule
5994 $output_rules .= &pretty_print_internal (@_);
5998 ################################################################
6002 # &conditional_string(@COND-STACK)
6003 # --------------------------------
6004 # Build a string which denotes the conditional in @COND-STACK. Some
6005 # simplifications are done: `TRUE' entries are elided, and any `FALSE'
6006 # entry results in a return of `FALSE'.
6007 sub conditional_string
6011 if (grep (/^FALSE$/, @stack))
6017 return join (' ', uniq sort grep (!/^TRUE$/, @stack));
6023 # &conditional_true_when ($COND, $WHEN)
6024 # -------------------------------------
6025 # See if a conditional is true. Both arguments are conditional
6026 # strings. This returns true if the first conditional is true when
6027 # the second conditional is true.
6028 # For instance with $COND = `BAR FOO', and $WHEN = `BAR BAZ FOO',
6029 # obviously return 1, and 0 when, for instance, $WHEN = `FOO'.
6030 sub conditional_true_when ($$)
6032 my ($cond, $when) = @_;
6034 # Make a hash holding all the values from $WHEN.
6035 my %cond_vals = map { $_ => 1 } split (' ', $when);
6037 # Nothing is true when FALSE (not even FALSE itself, but it
6038 # shouldn't hurt if you decide to change that).
6039 return 0 if exists $cond_vals{'FALSE'};
6041 # Check each component of $cond, which looks `COND1 COND2'.
6042 foreach my $comp (split (' ', $cond))
6044 # TRUE is always true.
6045 next if $comp eq 'TRUE';
6046 return 0 if ! defined $cond_vals{$comp};
6054 # &conditional_is_redundant ($COND, @WHENS)
6055 # ----------------------------------------
6056 # Determine whether $COND is redundant with respect to @WHENS.
6058 # Returns true if $COND is true for any of the conditions in @WHENS.
6060 # If there are no @WHENS, then behave as if @WHENS contained a single empty
6062 sub conditional_is_redundant ($@)
6064 my ($cond, @whens) = @_;
6066 @whens = ("") if @whens == 0;
6068 foreach my $when (@whens)
6070 return 1 if conditional_true_when ($cond, $when);
6077 # &conditional_implies_any ($COND, @CONDS)
6078 # ----------------------------------------
6079 # Returns true iff $COND implies any of the conditions in @CONDS.
6080 sub conditional_implies_any ($@)
6082 my ($cond, @conds) = @_;
6084 @conds = ("") if @conds == 0;
6086 foreach my $c (@conds)
6088 return 1 if conditional_true_when ($c, $cond);
6095 # condition_negate ($COND)
6096 # ------------------------
6097 sub condition_negate ($)
6101 $cond =~ s/TRUE$/TRUEO/;
6102 $cond =~ s/FALSE$/TRUE/;
6103 $cond =~ s/TRUEO$/FALSE/;
6109 # Compare condition names.
6110 # Issue them in alphabetical order, foo_TRUE before foo_FALSE.
6113 # Be careful we might be comparing `' or `#'.
6114 $a =~ /^(.*)_(TRUE|FALSE)$/;
6115 my ($aname, $abool) = ($1 || '', $2 || '');
6116 $b =~ /^(.*)_(TRUE|FALSE)$/;
6117 my ($bname, $bbool) = ($1 || '', $2 || '');
6118 return ($aname cmp $bname
6119 # Don't bother with IFs, given that TRUE is after FALSE
6120 # just cmp in the reverse order.
6121 || $bbool cmp $abool
6127 # &make_condition (@CONDITIONS)
6128 # -----------------------------
6129 # Transform a list of conditions (themselves can be an internal list
6130 # of conditions, e.g., @CONDITIONS = ('cond1 cond2', 'cond3')) into a
6131 # Make conditional (a pattern for AC_SUBST).
6132 # Correctly returns the empty string when there are no conditions.
6135 my $res = conditional_string (@_);
6137 # There are no conditions.
6143 elsif ($res eq 'FALSE')
6150 $res = '@' . $res . '@';
6159 ## ------------------------------ ##
6160 ## Handling the condition stack. ##
6161 ## ------------------------------ ##
6165 # cond_stack_if ($NEGATE, $COND, $WHERE)
6166 # --------------------------------------
6167 sub cond_stack_if ($$$)
6169 my ($negate, $cond, $where) = @_;
6171 error $where, "$cond does not appear in AM_CONDITIONAL"
6172 if ! $configure_cond{$cond} && $cond !~ /^TRUE|FALSE$/;
6174 $cond = "${cond}_TRUE"
6175 unless $cond =~ /^TRUE|FALSE$/;
6176 $cond = condition_negate ($cond)
6179 push (@cond_stack, $cond);
6181 return conditional_string (@cond_stack);
6186 # cond_stack_else ($NEGATE, $COND, $WHERE)
6187 # ----------------------------------------
6188 sub cond_stack_else ($$$)
6190 my ($negate, $cond, $where) = @_;
6194 error $where, "else without if";
6198 $cond_stack[$#cond_stack] = condition_negate ($cond_stack[$#cond_stack]);
6200 # If $COND is given, check against it.
6203 $cond = "${cond}_TRUE"
6204 unless $cond =~ /^TRUE|FALSE$/;
6205 $cond = condition_negate ($cond)
6208 error ($where, "else reminder ($negate$cond) incompatible with "
6209 . "current conditional: $cond_stack[$#cond_stack]")
6210 if $cond_stack[$#cond_stack] ne $cond;
6213 return conditional_string (@cond_stack);
6218 # cond_stack_endif ($NEGATE, $COND, $WHERE)
6219 # -----------------------------------------
6220 sub cond_stack_endif ($$$)
6222 my ($negate, $cond, $where) = @_;
6227 error $where, "endif without if: $negate$cond";
6232 # If $COND is given, check against it.
6235 $cond = "${cond}_TRUE"
6236 unless $cond =~ /^TRUE|FALSE$/;
6237 $cond = condition_negate ($cond)
6240 error ($where, "endif reminder ($negate$cond) incompatible with "
6241 . "current conditional: $cond_stack[$#cond_stack]")
6242 if $cond_stack[$#cond_stack] ne $cond;
6247 return conditional_string (@cond_stack);
6254 ## ------------------------ ##
6255 ## Handling the variables. ##
6256 ## ------------------------ ##
6259 # check_ambiguous_conditional ($VAR, $COND, $WHERE)
6260 # -------------------------------------------------
6261 # Check for an ambiguous conditional. This is called when a variable
6262 # is being defined conditionally. If we already know about a
6263 # definition that is true under the same conditions, then we have an
6265 sub check_ambiguous_conditional ($$$)
6267 my ($var, $cond, $where) = @_;
6268 my ($message, $ambig_cond) =
6269 conditional_ambiguous_p ($var, $cond, keys %{$var_value{$var}});
6272 msg 'syntax', $where, "$message ...";
6273 msg_var ('syntax', $var, "... `$var' previously defined here.");
6274 verb (macro_dump ($var));
6278 # $STRING, $AMBIG_COND
6279 # conditional_ambiguous_p ($WHAT, $COND, @CONDS)
6280 # ----------------------------------------------
6281 # Check for an ambiguous conditional. Return an error message and
6282 # the other condition involved if we have one, two empty strings otherwise.
6283 # WHAT: the thing being defined
6284 # COND: the condition under which is is being defined
6285 # CONDS: the conditons under which is had already been defined
6286 sub conditional_ambiguous_p ($$@)
6288 my ($var, $cond, @conds) = @_;
6289 foreach my $vcond (@conds)
6291 # Note that these rules doesn't consider the following
6292 # example as ambiguous.
6301 # It's up to the user to not define COND1 and COND2
6304 if ($vcond eq $cond)
6306 return ("$var multiply defined in condition $cond", $vcond);
6308 elsif (&conditional_true_when ($vcond, $cond))
6310 return ("$var was already defined in condition $vcond, "
6311 . "which implies condition $cond", $vcond);
6313 elsif (&conditional_true_when ($cond, $vcond))
6315 return ("$var was already defined in condition $vcond, "
6316 . "which is implied by condition $cond", $vcond);
6323 # variable_not_always_defined_in_cond ($VAR, $COND)
6324 # ---------------------------------------------
6325 # Check whether $VAR is always defined for condition $COND.
6326 # Return a list of conditions where the definition is missing.
6328 # For instance, given
6348 # variable_not_always_defined_in_cond ('A', 'COND1_TRUE COND2_TRUE')
6350 # variable_not_always_defined_in_cond ('A', 'COND1_TRUE')
6352 # variable_not_always_defined_in_cond ('A', 'TRUE')
6353 # => ("COND1_FALSE COND2_FALSE COND3_FALSE",
6354 # "COND1_FALSE COND2_TRUE COND3_FALSE",
6355 # "COND1_TRUE COND2_FALSE COND3_FALSE",
6356 # "COND1_TRUE COND2_TRUE COND3_FALSE")
6357 # variable_not_always_defined_in_cond ('B', 'COND1_TRUE')
6358 # => ("COND3_FALSE")
6359 # variable_not_always_defined_in_cond ('C', 'COND1_TRUE')
6361 # variable_not_always_defined_in_cond ('D', 'TRUE')
6363 # variable_not_always_defined_in_cond ('Z', 'TRUE')
6366 sub variable_not_always_defined_in_cond ($$)
6368 my ($var, $cond) = @_;
6370 # It's easy to answer if the variable is not defined.
6371 return ("TRUE",) unless exists $var_value{$var};
6373 # How does it work? Let's take the second example:
6375 # variable_not_always_defined_in_cond ('A', 'COND1_TRUE')
6377 # (1) First, we get the list of conditions where A is defined:
6379 # ("COND1_TRUE COND2_TRUE", "COND1_TRUE COND2_FALSE", "COND3_TRUE")
6381 # (2) Then we generate the set of inverted conditions:
6383 # ("COND1_FALSE COND2_TRUE COND3_FALSE",
6384 # "COND1_FALSE COND2_FALSE COND3_FALSE")
6386 # (3) Finally we remove these conditions which are not implied by
6387 # COND1_TRUE. This yields an empty list and we are done.
6390 my @cond_defs = keys %{$var_value{$var}}; # (1)
6391 foreach my $icond (invert_conditions (@cond_defs)) # (2)
6393 prog_error "invert_conditions returned an input condition"
6394 if exists $var_value{$var}{$icond};
6397 if (conditional_true_when ($cond, $icond)); # (3)
6402 # ¯o_define($VAR, $OWNER, $TYPE, $COND, $VALUE, $WHERE)
6403 # -------------------------------------------------------------
6404 # The $VAR can go from Automake to user, but not the converse.
6405 sub macro_define ($$$$$$)
6407 my ($var, $owner, $type, $cond, $value, $where) = @_;
6409 # We will adjust the owener of this variable unless told otherwise.
6410 my $adjust_owner = 1;
6412 error $where, "bad characters in variable name `$var'"
6413 if $var !~ /$MACRO_PATTERN/o;
6415 # NEWS-OS 4.2R complains if a Makefile variable begins with `_'.
6416 msg ('portability', $where,
6417 "$var: variable names starting with `_' are not portable")
6420 # `:='-style assignments are not acknowledged by POSIX. Moreover it
6421 # has multiple meanings. In GNU make or BSD make it means "assign
6422 # with immediate expansion", while in OSF make it is used for
6423 # conditional assignments.
6424 msg ('portability', $where, "`:='-style assignments are not portable")
6427 check_variable_expansions ($value, $where);
6431 # An Automake variable must be consistently defined with the same
6432 # sign by Automake. A user variable must be set by either `=' or
6433 # `:=', and later promoted to `+='.
6434 if ($owner == VAR_AUTOMAKE)
6436 if (exists $var_type{$var}
6437 && exists $var_type{$var}{$cond}
6438 && $var_type{$var}{$cond} ne $type)
6440 error ($where, "$var was set with `$var_type{$var}=' "
6441 . "and is now set with `$type='");
6446 if (!exists $var_type{$var} && $type eq '+')
6448 error $where, "$var must be set with `=' before using `+='";
6451 $var_type{$var}{$cond} = $type;
6453 # Differentiate assignment types.
6455 # 1. append (+=) to a variable defined for current condition
6456 if ($type eq '+' && exists $var_value{$var}{$cond})
6458 if (chomp $var_value{$var}{$cond})
6460 # Insert a backslash before a trailing newline.
6461 $var_value{$var}{$cond} .= "\\\n";
6463 elsif ($var_value{$var}{$cond})
6465 # Insert a separator.
6466 $var_value{$var}{$cond} .= ' ';
6468 $var_value{$var}{$cond} .= $value;
6470 # 2. append (+=) to a variable defined for *another* condition
6471 elsif ($type eq '+' && keys %{$var_value{$var}})
6473 # * Generally, $cond is not TRUE. For instance:
6478 # In this case, we declare an helper variable conditionally,
6479 # and append it to FOO:
6480 # FOO = foo $(am__append_1)
6481 # @COND_TRUE@am__append_1 = bar
6482 # Of course if FOO is defined under several conditions, we add
6483 # $(am__append_1) to each definitions.
6485 # * If $cond is TRUE, we don't need the helper variable. E.g., in
6492 # we can add bar directly to all definition of FOO, and output
6493 # @COND_TRUE@FOO = foo1 bar
6494 # @COND_FALSE@FOO = foo2 bar
6496 # Do we need an helper variable?
6497 if ($cond ne 'TRUE')
6499 # Does the helper variable already exists?
6500 my $key = "$var:$cond";
6501 if (exists $appendvar{$key})
6503 # Yes, let's simply append to it.
6504 $var = $appendvar{$key};
6505 $owner = VAR_AUTOMAKE;
6510 my $num = 1 + keys (%appendvar);
6511 my $hvar = "am__append_$num";
6512 $appendvar{$key} = $hvar;
6513 ¯o_define ($hvar, VAR_AUTOMAKE, '+',
6514 $cond, $value, $where);
6515 push @var_list, $hvar;
6516 # Now HVAR is to be added to VAR.
6517 $value = "\$($hvar)";
6521 # Add VALUE to all definitions of VAR.
6522 foreach my $vcond (keys %{$var_value{$var}})
6524 # We have a bit of error detection to do here.
6530 # should be rejected because X is not defined for all conditions
6531 # where `+=' applies.
6532 my @undef_cond = variable_not_always_defined_in_cond $var, $cond;
6533 if (@undef_cond != 0)
6536 "Cannot apply `+=' because `$var' is not defined "
6537 . "in\nthe following conditions:\n "
6538 . join ("\n ", @undef_cond)
6539 . "\nEither define `$var' in these conditions,"
6540 . " or use\n`+=' in the same conditions as"
6541 . " the definitions.");
6545 ¯o_define ($var, $owner, '+', $vcond, $value, $where);
6548 # Don't adjust the owner. The above ¯o_define did it in the
6552 # 3. first assignment (=, :=, or +=)
6555 # If Automake tries to override a value specified by the user,
6556 # just don't let it do.
6557 if (exists $var_value{$var}{$cond}
6558 && $var_owner{$var}{$cond} != VAR_AUTOMAKE
6559 && $owner == VAR_AUTOMAKE)
6561 verb ("refusing to override the user definition of:\n"
6563 ."with `$cond' => `$value'");
6567 # There must be no previous value unless the user is redefining
6568 # an Automake variable or an AC_SUBST variable for an existing
6570 check_ambiguous_conditional ($var, $cond, $where)
6571 unless (exists $var_owner{$var}{$cond}
6572 && (($var_owner{$var}{$cond} == VAR_AUTOMAKE
6573 && $owner != VAR_AUTOMAKE)
6574 || $var_owner{$var}{$cond} == VAR_CONFIGURE));
6576 $var_value{$var}{$cond} = $value;
6577 # Assignments to a macro set its location. We don't adjust
6578 # locations for `+='. Ideally I suppose we would associate
6579 # line numbers with random bits of text.
6580 $var_location{$var}{$cond} = $where;
6584 # The owner of a variable can only increase, because an Automake
6585 # variable can be given to the user, but not the converse.
6586 if ($adjust_owner &&
6587 (! exists $var_owner{$var}{$cond}
6588 || $owner > $var_owner{$var}{$cond}))
6590 $var_owner{$var}{$cond} = $owner;
6591 # Always adjust the location when the owner changes (even for
6592 # `+=' statements). The risk otherwise is to warn about
6593 # a VAR_MAKEFILE variable and locate it in configure.ac...
6594 $var_location{$var}{$cond} = $where;
6597 # Call var_VAR_trigger if it's defined.
6598 # This hook helps to update some internal state *while*
6599 # parsing the file. For instance the handling of SUFFIXES
6600 # requires this (see var_SUFFIXES_trigger).
6601 my $var_trigger = "var_${var}_trigger";
6602 &$var_trigger($type, $value) if defined &$var_trigger;
6606 # ¯o_delete ($VAR, [@CONDS])
6607 # ------------------------------
6608 # Forget about $VAR under the conditions @CONDS, or completely if
6610 sub macro_delete ($@)
6612 my ($var, @conds) = @_;
6616 delete $var_value{$var};
6617 delete $var_location{$var};
6618 delete $var_owner{$var};
6619 delete $var_comment{$var};
6620 delete $var_type{$var};
6624 foreach my $cond (@conds)
6626 delete $var_value{$var}{$cond};
6627 delete $var_location{$var}{$cond};
6628 delete $var_owner{$var}{$cond};
6629 delete $var_comment{$var}{$cond};
6630 delete $var_type{$var}{$cond};
6636 # ¯o_dump ($VAR)
6637 # ------------------
6643 if (!exists $var_value{$var})
6645 $text = " $var does not exist\n";
6649 $text .= " $var $var_type{$var}=\n {\n";
6650 foreach my $vcond (sort by_condition keys %{$var_value{$var}})
6652 prog_error ("`$var' is a key in \$var_value, "
6653 . "but not in \$var_owner\n")
6654 unless exists $var_owner{$var}{$vcond};
6657 if ($var_owner{$var}{$vcond} == VAR_AUTOMAKE)
6659 $var_owner = 'Automake';
6661 elsif ($var_owner{$var}{$vcond} == VAR_CONFIGURE)
6663 $var_owner = 'Configure';
6665 elsif ($var_owner{$var}{$vcond} == VAR_MAKEFILE)
6667 $var_owner = 'Makefile';
6671 prog_error ("unexpected value for `\$var_owner{$var}{$vcond}': "
6672 . $var_owner{$var}{$vcond})
6673 unless defined $var_owner;
6676 my $where = (defined $var_location{$var}{$vcond}
6677 ? $var_location{$var}{$vcond} : "undefined");
6678 $text .= "$var_comment{$var}{$vcond}"
6679 if exists $var_comment{$var}{$vcond};
6680 $text .= " $vcond => $var_value{$var}{$vcond}\n";
6694 my $text = "%var_value =\n{\n";
6695 foreach my $var (sort (keys %var_value))
6697 $text .= macro_dump ($var);
6705 # variable_defined ($VAR, [$COND])
6706 # ---------------------------------
6707 # See if a variable exists. $VAR is the variable name, and $COND is
6708 # the condition which we should check. If no condition is given, we
6709 # currently return true if the variable is defined under any
6711 sub variable_defined ($;$)
6713 my ($var, $cond) = @_;
6715 if (! exists $var_value{$var}
6716 || (defined $cond && ! exists $var_value{$var}{$cond}))
6718 # VAR is not defined.
6720 # Check there is no target defined with the name of the
6721 # variable we check.
6723 # adl> I'm wondering if this error still makes any sense today. I
6724 # adl> guess it was because targets and variables used to share
6725 # adl> the same namespace in older versions of Automake?
6726 # tom> While what you say is definitely part of it, I think it
6727 # tom> might also have been due to someone making a "spelling error"
6728 # tom> -- writing "foo:..." instead of "foo = ...".
6729 # tom> I'm not sure whether it is really worth diagnosing
6730 # tom> this sort of problem. In the old days I used to add warnings
6731 # tom> and errors like this pretty randomly, based on bug reports I
6732 # tom> got. But there's a plausible argument that I was trying
6733 # tom> too hard to prevent people from making mistakes.
6734 if (exists $targets{$var}
6735 && (! defined $cond || exists $targets{$var}{$cond}))
6737 for my $tcond ($cond || keys %{$targets{$var}})
6739 prog_error ("\$targets{$var}{$tcond} exists but "
6740 . "\$target_owner doesn't")
6741 unless exists $target_owner{$var}{$tcond};
6742 # Diagnose the first user target encountered, if any.
6743 # Restricting this test to user targets allows Automake
6744 # to create rules for things like `bin_PROGRAMS = LDADD'.
6745 if ($target_owner{$var}{$tcond} == TARGET_USER)
6747 msg_cond_target ('syntax', $tcond, $var,
6748 "`$var' is a target; "
6749 . "expected a variable");
6757 # Even a var_value examination is good enough for us. FIXME:
6758 # really should maintain examined status on a per-condition basis.
6759 $content_seen{$var} = 1;
6765 # variable_assert ($VAR, $WHERE)
6766 # ------------------------------
6767 # Make sure a variable exists. $VAR is the variable name, and $WHERE
6768 # is the name of a macro which refers to $VAR.
6769 sub variable_assert ($$)
6771 my ($var, $where) = @_;
6774 if variable_defined $var;
6776 require_variables ($where, "variable `$var' is used", 'TRUE', $var);
6781 # Mark a variable as examined.
6782 sub examine_variable
6785 variable_defined ($var);
6789 # &variable_conditions_recursive ($VAR)
6790 # -------------------------------------
6791 # Return the set of conditions for which a variable is defined.
6793 # If the variable is not defined conditionally, and is not defined in
6794 # terms of any variables which are defined conditionally, then this
6795 # returns the empty list.
6797 # If the variable is defined conditionally, but is not defined in
6798 # terms of any variables which are defined conditionally, then this
6799 # returns the list of conditions for which the variable is defined.
6801 # If the variable is defined in terms of any variables which are
6802 # defined conditionally, then this returns a full set of permutations
6803 # of the subvariable conditions. For example, if the variable is
6804 # defined in terms of a variable which is defined for COND_TRUE,
6805 # then this returns both COND_TRUE and COND_FALSE. This is
6806 # because we will need to define the variable under both conditions.
6807 sub variable_conditions_recursive ($)
6813 my @new_conds = variable_conditions_recursive_sub ($var, '');
6815 # Now we want to return all permutations of the subvariable
6818 foreach my $item (@new_conds)
6820 foreach (split (' ', $item))
6822 s/^(.*)_(TRUE|FALSE)$/$1_TRUE/;
6826 @new_conds = variable_conditions_permutations (sort keys %allconds);
6829 foreach my $cond (@new_conds)
6831 my $reduce = variable_conditions_reduce (split (' ', $cond));
6833 if $reduce eq 'FALSE';
6834 $uniqify{$cond} = 1;
6837 # Note we cannot just do `return sort keys %uniqify', because this
6838 # function is sometimes used in a scalar context.
6839 my @uniq_list = sort by_condition keys %uniqify;
6845 # variable_conditions ($VAR)
6846 # --------------------------
6847 # Get the list of conditions that a variable is defined with, without
6848 # recursing through the conditions of any subvariables.
6849 # Argument is $VAR: the variable to get the conditions of.
6850 # Returns the list of conditions.
6851 sub variable_conditions ($)
6854 my @conds = keys %{$var_value{$var}};
6855 return sort by_condition @conds;
6860 # &variable_conditionally_defined ($VAR)
6861 # --------------------------------------
6862 sub variable_conditionally_defined ($)
6865 foreach my $cond (variable_conditions_recursive ($var))
6868 unless $cond =~ /^TRUE|FALSE$/;
6874 # &scan_variable_expansions ($TEXT)
6875 # ---------------------------------
6876 # Return the list of variable names expanded in $TEXT.
6877 # Note that unlike some other functions, $TEXT is not split
6878 # on spaces before we check for subvariables.
6879 sub scan_variable_expansions ($)
6887 # Record each use of ${stuff} or $(stuff) that do not follow a $.
6888 while ($text =~ /(?<!\$)\$(?:\{([^\}]*)\}|\(([^\)]*)\))/g)
6891 # The occurent may look like $(string1[:subst1=[subst2]]) but
6892 # we want only `string1'.
6893 $var =~ s/:[^:=]*=[^=]*$//;
6900 # &check_variable_expansions ($TEXT, $WHERE)
6901 # ------------------------------------------
6902 # Check variable expansions in $TEXT and warn about any name that
6903 # does not conform to POSIX. $WHERE is the location of $TEXT for
6904 # the error message.
6905 sub check_variable_expansions ($$)
6907 my ($text, $where) = @_;
6908 # Catch expansion of variables whose name does not conform to POSIX.
6909 foreach my $var (scan_variable_expansions ($text))
6911 if ($var !~ /$MACRO_PATTERN/)
6913 # If the variable name contains a space, it's likely
6914 # to be a GNU make extension (such as $(addsuffix ...)).
6915 # Mention this in the diagnostic.
6917 $gnuext = "\n(probably a GNU make extension)" if $var =~ / /;
6918 msg ('portability', $where,
6919 "$var: non-POSIX variable name$gnuext");
6924 # &variable_conditions_recursive_sub ($VAR, $PARENT)
6925 # -------------------------------------------------------
6926 # A subroutine of variable_conditions_recursive. This returns all the
6927 # conditions of $VAR, including those of any sub-variables.
6928 sub variable_conditions_recursive_sub
6930 my ($var, $parent) = @_;
6933 if (defined $vars_scanned{$var})
6935 err_var $parent, "variable `$var' recursively defined";
6938 $vars_scanned{$var} = 1;
6940 my @this_conds = ();
6941 # Examine every condition under which $VAR is defined.
6942 foreach my $vcond (keys %{$var_value{$var}})
6944 push (@this_conds, $vcond);
6946 # If $VAR references some other variable, then compute the
6947 # conditions for that subvariable.
6948 my @subvar_conds = ();
6949 foreach my $varname (scan_variable_expansions $var_value{$var}{$vcond})
6951 if ($varname =~ /$SUBST_REF_PATTERN/o)
6956 # Here we compute all the conditions under which the
6957 # subvariable is defined. Then we go through and add
6959 my @svc = variable_conditions_recursive_sub ($varname, $var);
6960 foreach my $item (@svc)
6962 my $val = conditional_string ($vcond, split (' ', $item));
6964 push (@subvar_conds, $val);
6968 # If there are no conditional subvariables, then we want to
6969 # return this condition. Otherwise, we want to return the
6970 # permutations of the subvariables, taking into account the
6971 # conditions of $VAR.
6972 if (! @subvar_conds)
6974 push (@new_conds, $vcond);
6978 push (@new_conds, variable_conditions_reduce (@subvar_conds));
6982 # Unset our entry in vars_scanned. We only care about recursive
6984 delete $vars_scanned{$var};
6986 # If we are being called on behalf of another variable, we need to
6987 # return all possible permutations of the conditions. We have
6988 # already handled everything in @this_conds along with their
6989 # subvariables. We now need to add any permutations that are not
6991 foreach my $this_cond (@this_conds)
6994 variable_conditions_permutations (split (' ', $this_cond));
6995 foreach my $perm (@perms)
6998 foreach my $scan (@this_conds)
7000 if (&conditional_true_when ($perm, $scan)
7001 || &conditional_true_when ($scan, $perm))
7009 # This permutation was not already handled, and is valid
7011 push (@new_conds, $perm);
7019 # Filter a list of conditionals so that only the exclusive ones are
7020 # retained. For example, if both `COND1_TRUE COND2_TRUE' and
7021 # `COND1_TRUE' are in the list, discard the latter.
7022 # If the list is empty, return TRUE
7023 sub variable_conditions_reduce
7030 $cond = shift(@conds);
7032 # FALSE is absorbent.
7034 if $cond eq 'FALSE';
7036 if (!conditional_is_redundant ($cond, @ret, @conds))
7042 return "TRUE" if @ret == 0;
7047 # invert_conditions (@CONDS)
7048 # --------------------------
7049 # Invert a list of conditionals. Returns a set of conditionals which
7050 # are never true for any of the input conditionals, and when taken
7051 # together with the input conditionals cover all possible cases.
7054 # invert_conditions("A_TRUE B_TRUE", "A_FALSE B_FALSE")
7055 # => ("A_FALSE B_TRUE", "A_TRUE B_FALSE")
7057 # invert_conditions("A_TRUE B_TRUE", "A_TRUE B_FALSE", "A_FALSE")
7059 sub invert_conditions
7065 # Generate all permutation for all inputs.
7067 map { variable_conditions_permutations (split(' ', $_)); } @conds;
7068 # Remove redundant conditions.
7069 @perm = variable_conditions_reduce @perm;
7071 # Now remove all conditions which imply one of the input conditions.
7072 foreach my $perm (@perm)
7074 push @notconds, $perm
7075 if ! conditional_implies_any ($perm, @conds);
7080 # Return a list of permutations of a conditional string.
7081 # (But never output FALSE conditions, they are useless.)
7084 # variable_conditions_permutations ("FOO_FALSE", "BAR_TRUE")
7085 # => ("FOO_FALSE BAR_FALSE",
7086 # "FOO_FALSE BAR_TRUE",
7087 # "FOO_TRUE BAR_FALSE",
7088 # "FOO_TRUE BAR_TRUE")
7089 # variable_conditions_permutations ("FOO_FALSE", "TRUE")
7090 # => ("FOO_FALSE TRUE",
7092 # variable_conditions_permutations ("TRUE")
7094 # variable_conditions_permutations ("FALSE")
7096 sub variable_conditions_permutations
7101 my $comp = shift (@comps);
7102 return variable_conditions_permutations (@comps)
7104 my $neg = condition_negate ($comp);
7107 foreach my $sub (variable_conditions_permutations (@comps))
7109 push (@ret, "$comp $sub") if $comp ne 'FALSE';
7110 push (@ret, "$neg $sub") if $neg ne 'FALSE';
7114 push (@ret, $comp) if $comp ne 'FALSE';
7115 push (@ret, $neg) if $neg ne 'FALSE';
7122 # &check_variable_defined_unconditionally($VAR, $PARENT)
7123 # ------------------------------------------------------
7124 # Warn if a variable is conditionally defined. This is called if we
7125 # are using the value of a variable.
7126 sub check_variable_defined_unconditionally ($$)
7128 my ($var, $parent) = @_;
7129 foreach my $cond (keys %{$var_value{$var}})
7132 if $cond =~ /^TRUE|FALSE$/;
7136 msg_var ('unsupported', $parent,
7137 "automake does not support conditional definition of "
7138 . "$var in $parent");
7142 msg_var ('unsupported', $var,
7143 "automake does not support $var being defined "
7150 # Get the TRUE value of a variable, warn if the variable is
7151 # conditionally defined.
7155 &check_variable_defined_unconditionally ($var);
7156 return $var_value{$var}{'TRUE'};
7161 # &value_to_list ($VAR, $VAL, $COND)
7162 # ----------------------------------
7163 # Convert a variable value to a list, split as whitespace. This will
7164 # recursively follow $(...) and ${...} inclusions. It preserves @...@
7167 # If COND is 'all', then all values under all conditions should be
7168 # returned; if COND is a particular condition (all conditions are
7169 # surrounded by @...@) then only the value for that condition should
7170 # be returned; otherwise, warn if VAR is conditionally defined.
7171 # SCANNED is a global hash listing whose keys are all the variables
7172 # already scanned; it is an error to rescan a variable.
7173 sub value_to_list ($$$)
7175 my ($var, $val, $cond) = @_;
7179 $val =~ s/\\(\n|$)/ /g;
7181 foreach (split (' ', $val))
7183 # If a comment seen, just leave.
7186 # Handle variable substitutions.
7187 if (/^\$\{([^}]*)\}$/ || /^\$\(([^)]*)\)$/)
7191 # If the user uses a losing variable name, just ignore it.
7192 # This isn't ideal, but people have requested it.
7193 next if ($varname =~ /\@.*\@/);
7197 if ($varname =~ /$SUBST_REF_PATTERN/o)
7201 $from = quotemeta $2;
7206 variable_value_as_list_recursive_worker ($1, $cond, $var);
7208 # Now rewrite the value if appropriate.
7211 grep (s/$from$/$to/, @temp_list);
7214 push (@result, @temp_list);
7227 # variable_value_as_list ($VAR, $COND, $PARENT)
7228 # ---------------------------------------------
7229 # Get the value of a variable given a specified condition. without
7230 # recursing through any subvariables.
7232 # $VAR is the variable
7233 # $COND is the condition. If this is not given, the value for the
7234 # "TRUE" condition will be returned.
7235 # $PARENT is the variable in which the variable is used: this is used
7236 # only for error messages.
7237 # Returns the list of conditions.
7238 # For example, if A is defined as "foo $(B) bar", and B is defined as
7239 # "baz", this will return ("foo", "$(B)", "bar")
7240 sub variable_value_as_list
7242 my ($var, $cond, $parent) = @_;
7247 unless variable_assert $var, $parent;
7249 # Get value for given condition
7252 foreach my $vcond (keys %{$var_value{$var}})
7254 my $val = $var_value{$var}{$vcond};
7256 if (&conditional_true_when ($vcond, $cond))
7258 # Unless variable is not defined conditionally, there should only
7259 # be one value of $vcond true when $cond.
7260 &check_variable_defined_unconditionally ($var, $parent)
7265 $val =~ s/\\(\n|$)/ /g;
7267 foreach (split (' ', $val))
7269 # If a comment seen, just leave.
7282 # &variable_value_as_list_recursive_worker ($VAR, $COND, $PARENT)
7283 # ---------------------------------------------------------------
7284 # Return contents of VAR as a list, split on whitespace. This will
7285 # recursively follow $(...) and ${...} inclusions. It preserves @...@
7286 # substitutions. If COND is 'all', then all values under all
7287 # conditions should be returned; if COND is a particular condition
7288 # (all conditions are surrounded by @...@) then only the value for
7289 # that condition should be returned; otherwise, warn if VAR is
7290 # conditionally defined. If PARENT is specified, it is the name of
7291 # the including variable; this is only used for error reports.
7292 sub variable_value_as_list_recursive_worker ($$$)
7294 my ($var, $cond, $parent) = @_;
7298 unless variable_assert $var, $parent;
7300 if (defined $vars_scanned{$var})
7302 # `vars_scanned' is a global we use to keep track of which
7303 # variables we've already examined.
7304 err_var $parent, "variable `$var' recursively defined";
7306 elsif ($cond eq 'all')
7308 $vars_scanned{$var} = 1;
7309 foreach my $vcond (keys %{$var_value{$var}})
7311 my $val = $var_value{$var}{$vcond};
7312 push (@result, &value_to_list ($var, $val, $cond));
7318 $vars_scanned{$var} = 1;
7320 foreach my $vcond (keys %{$var_value{$var}})
7322 my $val = $var_value{$var}{$vcond};
7323 if (&conditional_true_when ($vcond, $cond))
7325 # Warn if we have an ambiguity. It's hard to know how
7326 # to handle this case correctly.
7327 &check_variable_defined_unconditionally ($var, $parent)
7330 push (@result, &value_to_list ($var, $val, $cond));
7335 # Unset our entry in vars_scanned. We only care about recursive
7337 delete $vars_scanned{$var};
7343 # &variable_output ($VAR, [@CONDS])
7344 # ---------------------------------
7345 # Output all the values of $VAR is @COND is not specified, else only
7346 # that corresponding to @COND.
7347 sub variable_output ($@)
7349 my ($var, @conds) = @_;
7351 @conds = keys %{$var_value{$var}}
7354 foreach my $cond (sort by_condition @conds)
7356 prog_error ("unknown condition `$cond' for `$var'")
7357 unless exists $var_value{$var}{$cond};
7359 if (exists $var_comment{$var} && exists $var_comment{$var}{$cond})
7361 $output_vars .= $var_comment{$var}{$cond};
7364 my $val = $var_value{$var}{$cond};
7365 my $equals = $var_type{$var}{$cond} eq ':' ? ':=' : '=';
7366 my $output_var = "$var $equals $val";
7367 $output_var =~ s/^/make_condition ($cond)/meg;
7368 $output_vars .= $output_var . "\n";
7373 # &variable_pretty_output ($VAR, [@CONDS])
7374 # ----------------------------------------
7375 # Likewise, but pretty, i.e., we *split* the values at spaces. Use only
7376 # with variables holding filenames.
7377 sub variable_pretty_output ($@)
7379 my ($var, @conds) = @_;
7381 @conds = keys %{$var_value{$var}}
7384 foreach my $cond (sort by_condition @conds)
7386 prog_error ("unknown condition `$cond' for `$var'")
7387 unless exists $var_value{$var}{$cond};
7389 if (exists $var_comment{$var} && exists $var_comment{$var}{$cond})
7391 $output_vars .= $var_comment{$var}{$cond};
7394 my $val = $var_value{$var}{$cond};
7395 my $equals = $var_type{$var}{$cond} eq ':' ? ':=' : '=';
7396 my $make_condition = make_condition ($cond);
7398 # Suppress escaped new lines. &pretty_print_internal will
7399 # add them back, maybe at other places.
7402 $output_vars .= pretty_print_internal ("$make_condition$var $equals",
7403 "$make_condition\t",
7404 split (' ' , $val));
7409 # &variable_value_as_list_recursive ($VAR, $COND, $PARENT)
7410 # --------------------------------------------------------
7411 # This is just a wrapper for variable_value_as_list_recursive_worker that
7412 # initializes the global hash `vars_scanned'. This hash is used to
7413 # avoid infinite recursion.
7414 sub variable_value_as_list_recursive ($$@)
7416 my ($var, $cond, $parent) = @_;
7418 return &variable_value_as_list_recursive_worker ($var, $cond, $parent);
7422 # &define_pretty_variable ($VAR, $COND, @VALUE)
7423 # ---------------------------------------------
7424 # Like define_variable, but the value is a list, and the variable may
7425 # be defined conditionally. The second argument is the conditional
7426 # under which the value should be defined; this should be the empty
7427 # string to define the variable unconditionally. The third argument
7428 # is a list holding the values to use for the variable. The value is
7429 # pretty printed in the output file.
7430 sub define_pretty_variable ($$@)
7432 my ($var, $cond, @value) = @_;
7434 # Beware that an empty $cond has a different semantics for
7435 # macro_define and variable_pretty_output.
7438 if (! variable_defined ($var, $cond))
7440 macro_define ($var, VAR_AUTOMAKE, '', $cond, "@value", undef);
7441 variable_pretty_output ($var, $cond || 'TRUE');
7442 $content_seen{$var} = 1;
7447 # define_variable ($VAR, $VALUE)
7448 # ------------------------------
7449 # Define a new user variable VAR to VALUE, but only if not already defined.
7450 sub define_variable ($$)
7452 my ($var, $value) = @_;
7453 define_pretty_variable ($var, 'TRUE', $value);
7457 # Like define_variable, but define a variable to be the configure
7458 # substitution by the same name.
7459 sub define_configure_variable ($)
7462 if (! variable_defined ($var, 'TRUE')
7463 # Explicitly avoid ANSI2KNR -- we AC_SUBST that in
7464 # protos.m4, but later define it elsewhere. This is
7465 # pretty hacky. We also explicitly avoid AMDEPBACKSLASH:
7466 # it might be subst'd by `\', which certainly would not be
7467 # appreciated by Make.
7468 && ! grep { $_ eq $var } (qw(ANSI2KNR AMDEPBACKSLASH)))
7470 macro_define ($var, VAR_CONFIGURE, '', 'TRUE',
7471 subst $var, $configure_vars{$var});
7472 variable_pretty_output ($var, 'TRUE');
7477 # define_compiler_variable ($LANG)
7478 # --------------------------------
7479 # Define a compiler variable. We also handle defining the `LT'
7480 # version of the command when using libtool.
7481 sub define_compiler_variable ($)
7485 my ($var, $value) = ($lang->compiler, $lang->compile);
7486 &define_variable ($var, $value);
7487 &define_variable ("LT$var", "\$(LIBTOOL) --mode=compile $value")
7488 if variable_defined ('LIBTOOL');
7492 # define_linker_variable ($LANG)
7493 # ------------------------------
7494 # Define linker variables.
7495 sub define_linker_variable ($)
7499 my ($var, $value) = ($lang->lder, $lang->ld);
7501 &define_variable ($lang->lder, $lang->ld);
7502 # CCLINK = $(CCLD) blah blah...
7503 &define_variable ($lang->linker,
7504 ((variable_defined ('LIBTOOL')
7505 ? '$(LIBTOOL) --mode=link ' : '')
7509 ################################################################
7511 ## ---------------- ##
7512 ## Handling rules. ##
7513 ## ---------------- ##
7515 sub register_suffix_rule ($$$)
7517 my ($where, $src, $dest) = @_;
7519 verb "Sources ending in $src become $dest";
7520 push @suffixes, $src, $dest;
7522 # When tranforming sources to objects, Automake uses the
7523 # %suffix_rules to move from each source extension to
7524 # `.$(OBJEXT)', not to `.o' or `.obj'. However some people
7525 # define suffix rules for `.o' or `.obj', so internally we will
7526 # consider these extensions equivalent to `.$(OBJEXT)'. We
7527 # CANNOT rewrite the target (i.e., automagically replace `.o'
7528 # and `.obj' by `.$(OBJEXT)' in the output), or warn the user
7529 # that (s)he'd better use `.$(OBJEXT)', because Automake itself
7530 # output suffix rules for `.o' or `.obj'...
7531 $dest = '.$(OBJEXT)' if ($dest eq '.o' || $dest eq '.obj');
7533 # Reading the comments near the declaration of $suffix_rules might
7534 # help to understand the update of $suffix_rules that follows...
7536 # Register $dest as a possible destination from $src.
7537 # We might have the create the \hash.
7538 if (exists $suffix_rules->{$src})
7540 $suffix_rules->{$src}{$dest} = [ $dest, 1 ];
7544 $suffix_rules->{$src} = { $dest => [ $dest, 1 ] };
7547 # If we know how to transform $dest in something else, then
7548 # we know how to transform $src in that "something else".
7549 if (exists $suffix_rules->{$dest})
7551 for my $dest2 (keys %{$suffix_rules->{$dest}})
7553 my $dist = $suffix_rules->{$dest}{$dest2}[1] + 1;
7554 # Overwrite an existing $src->$dest2 path only if
7555 # the path via $dest which is shorter.
7556 if (! exists $suffix_rules->{$src}{$dest2}
7557 || $suffix_rules->{$src}{$dest2}[1] > $dist)
7559 $suffix_rules->{$src}{$dest2} = [ $dest, $dist ];
7564 # Similarly, any extension that can be derived into $src
7565 # can be derived into the same extenstions as $src can.
7566 my @dest2 = keys %{$suffix_rules->{$src}};
7567 for my $src2 (keys %$suffix_rules)
7569 if (exists $suffix_rules->{$src2}{$src})
7571 for my $dest2 (@dest2)
7573 my $dist = $suffix_rules->{$src}{$dest2} + 1;
7574 # Overwrite an existing $src2->$dest2 path only if
7575 # the path via $src is shorter.
7576 if (! exists $suffix_rules->{$src2}{$dest2}
7577 || $suffix_rules->{$src2}{$dest2}[1] > $dist)
7579 $suffix_rules->{$src2}{$dest2} = [ $src, $dist ];
7587 # rule_define ($TARGET, $SOURCE, $OWNER, $COND, $WHERE)
7588 # -----------------------------------------------------
7589 # Define a new rule. $TARGET is the rule name. $SOURCE
7590 # is the filename the rule comes from. $OWNER is the
7591 # owener of the rule (TARGET_AUTOMAKE or TARGET_USER).
7592 # $COND is the condition string under which the rule is defined.
7593 # $WHERE is where the rule is defined (file name and/or line number).
7594 # Returns a (possibly empty) list of conditions where the rule
7595 # should be defined.
7596 sub rule_define ($$$$$)
7598 my ($target, $source, $owner, $cond, $where) = @_;
7600 # Don't even think about defining a rule in condition FALSE.
7601 return () if $cond eq 'FALSE';
7603 # For now `foo:' will override `foo$(EXEEXT):'. This is temporary,
7604 # though, so we emit a warning.
7605 (my $noexe = $target) =~ s,\$\(EXEEXT\)$,,;
7606 if ($noexe ne $target
7607 && exists $targets{$noexe}
7608 && exists $targets{$noexe}{$cond}
7609 && $target_name{$noexe}{$cond} ne $target)
7611 # The no-exeext option enables this feature.
7612 if (! defined $options{'no-exeext'})
7614 msg ('obsolete', $noexe,
7615 "deprecated feature: `$noexe' overrides `$noexe\$(EXEEXT)'\n"
7616 . "change your target to read `$noexe\$(EXEEXT)'");
7622 # For now on, strip off $(EXEEXT) from $target, so we can diagnose
7623 # a clash if `ctags$(EXEEXT):' is redefined after `ctags:'.
7624 my $realtarget = $target;
7627 # A GNU make-style pattern rule has a single "%" in the target name.
7628 msg ('portability', $where,
7629 "`%'-style pattern rules are a GNU make extension")
7630 if $target =~ /^[^%]*%[^%]*$/;
7632 # Diagnose target redefinitions.
7633 if (exists $target_source{$target}{$cond})
7636 prog_error ("\$target_source{$target}{$cond} exists, but \$target_owner"
7638 unless exists $target_owner{$target}{$cond};
7639 prog_error ("\$target_source{$target}{$cond} exists, but \$targets"
7641 unless exists $targets{$target}{$cond};
7642 prog_error ("\$target_source{$target}{$cond} exists, but \$target_name"
7644 unless exists $target_name{$target}{$cond};
7646 my $oldowner = $target_owner{$target}{$cond};
7648 # Don't mention true conditions in diagnostics.
7649 my $condmsg = $cond ne 'TRUE' ? " in condition `$cond'" : '';
7651 if ($owner == TARGET_USER)
7653 if ($oldowner eq TARGET_USER)
7655 # Ignore `%'-style pattern rules. We'd need the
7656 # dependencies to detect duplicates, and they are
7657 # already diagnosed as unportable by -Wportability.
7658 if ($target !~ /^[^%]*%[^%]*$/)
7660 ## FIXME: Presently we can't diagnose duplcate user rules
7661 ## because we doesn't distinguish rules with commands
7662 ## from rules that only add dependencies. E.g.,
7665 ## is legitimate. (This is phony.test.)
7667 # msg ('syntax', $where,
7668 # "redefinition of `$target'$condmsg...");
7669 # msg_cond_target ('syntax', $cond, $target,
7670 # "... `$target' previously defined here.");
7672 # Return so we don't redefine the rule in our tables,
7673 # don't check for ambiguous conditional, etc. The rule
7674 # will be output anyway beauce &read_am_file ignore the
7680 # Since we parse the user Makefile.am before reading
7681 # the Automake fragments, this condition should never happen.
7682 prog_error ("user target `$target' seen after Automake's "
7683 . "definition\nfrom `$targets{$target}$condmsg'");
7686 else # $owner == TARGET_AUTOMAKE
7688 if ($oldowner == TARGET_USER)
7690 # Don't overwrite the user definition of TARGET.
7693 else # $oldowner == TARGET_AUTOMAKE
7695 # Automake should ignore redefinitions of its own
7696 # rules if they came from the same file. This makes
7697 # it easier to process a Makefile fragment several times.
7698 # Hower it's an error if the target is defined in many
7699 # files. E.g., the user might be using bin_PROGRAMS = ctags
7700 # which clashes with our `ctags' rule.
7701 # (It would be more accurate if we had a way to compare
7702 # the *content* of both rules. Then $targets_source would
7704 my $oldsource = $target_source{$target}{$cond};
7705 return () if $source eq $oldsource;
7707 msg ('syntax', $where, "redefinition of `$target'$condmsg...");
7708 msg_cond_target ('syntax', $cond, $target,
7709 "... `$target' previously defined here.");
7714 prog_error ("Unreachable place reached.");
7717 # Conditions for which the rule should be defined.
7720 # Check ambiguous conditional definitions.
7721 my ($message, $ambig_cond) =
7722 conditional_ambiguous_p ($target, $cond, keys %{$targets{$target}});
7723 if ($message) # We have an ambiguty.
7725 if ($owner == TARGET_USER)
7727 # For user rules, just diagnose the ambiguity.
7728 msg 'syntax', $where, "$message ...";
7729 msg_cond_target ('syntax', $ambig_cond, $target,
7730 "... `$target' previously defined here.");
7735 # FIXME: for Automake rules, we can't diagnose ambiguities yet.
7736 # The point is that Automake doesn't propagate conditionals
7737 # everywhere. For instance &handle_PROGRAMS doesn't care if
7738 # bin_PROGRAMS was defined conditionally or not.
7739 # On the following input
7744 # bin_PROGRAMS = foo
7746 # &handle_PROGRAMS will attempt to define a `foo:' rule
7747 # in condition TRUE (which conflicts with COND1). Fixing
7748 # this in &handle_PROGRAMS and siblings seems hard: you'd
7749 # have to explain &file_contents what to do with a
7750 # conditional. So for now we do our best *here*. If `foo:'
7751 # was already defined in condition COND1 and we want to define
7752 # it in condition TRUE, then define it only in condition !COND1.
7753 # (See cond14.test and cond15.test for some test cases.)
7754 my @defined_conds = keys %{$targets{$target}};
7756 for my $undefined_cond (invert_conditions(@defined_conds))
7758 push @conds, make_condition ($cond, $undefined_cond);
7760 # No conditions left to define the rule.
7761 # Warn, because our workaround is meaningless in this case.
7762 if (scalar @conds == 0)
7764 msg 'syntax', $where, "$message ...";
7765 msg_cond_target ('syntax', $ambig_cond, $target,
7766 "... `$target' previously defined here.");
7772 # Finally define this rule.
7775 $targets{$target}{$c} = $where;
7776 $target_source{$target}{$c} = $source;
7777 $target_owner{$target}{$c} = $owner;
7778 $target_name{$target}{$c} = $realtarget;
7781 # We honor inference rules with multiple targets because many
7782 # make support this and people use it. However this is disallowed
7783 # by POSIX. We'll print a warning later.
7784 my $target_count = 0;
7785 my $inference_rule_count = 0;
7786 for my $t (split (' ', $target))
7789 # Check the rule for being a suffix rule. If so, store in a hash.
7790 # Either it's a rule for two known extensions...
7791 if ($t =~ /^($KNOWN_EXTENSIONS_PATTERN)($KNOWN_EXTENSIONS_PATTERN)$/
7792 # ...or it's a rule with unknown extensions (.i.e, the rule
7793 # looks like `.foo.bar:' but `.foo' or `.bar' are not
7794 # declared in SUFFIXES and are not known language
7795 # extensions). Automake will complete SUFFIXES from
7796 # @suffixes automatically (see handle_footer).
7797 || ($t =~ /$SUFFIX_RULE_PATTERN/o && accept_extensions($1)))
7799 ++$inference_rule_count;
7800 register_suffix_rule ($where, $1, $2);
7804 # POSIX allow multiple targets befor the colon, but disallow
7805 # definitions of multiple Inference rules. It's also
7806 # disallowed to mix plain targets with inference rules.
7807 msg ('portability', $where,
7808 "Inference rules can have only one target before the colon (POSIX).")
7809 if $inference_rule_count > 0 && $target_count > 1;
7811 # Return "" instead of TRUE so it can be used with make_paragraphs
7813 return "" if 1 == @conds && $conds[0] eq 'TRUE';
7818 # See if a target exists.
7822 return exists $targets{$target};
7826 ################################################################
7828 # &append_comments ($VARIABLE, $SPACING, $COMMENT)
7829 # ------------------------------------------------
7830 # Apped $COMMENT to the other comments for $VARIABLE, using
7831 # $SPACING as separator.
7832 sub append_comments ($$$$)
7834 my ($cond, $var, $spacing, $comment) = @_;
7835 $var_comment{$var}{$cond} .= $spacing
7836 if (!defined $var_comment{$var}{$cond}
7837 || $var_comment{$var}{$cond} !~ /\n$/o);
7838 $var_comment{$var}{$cond} .= $comment;
7842 # &read_am_file ($AMFILE)
7843 # -----------------------
7844 # Read Makefile.am and set up %contents. Simultaneously copy lines
7845 # from Makefile.am into $output_trailer or $output_vars as
7846 # appropriate. NOTE we put rules in the trailer section. We want
7847 # user rules to come after our generated stuff.
7848 sub read_am_file ($)
7852 my $am_file = new Automake::XFile ("< $amfile");
7853 verb "reading $amfile";
7860 use constant IN_VAR_DEF => 0;
7861 use constant IN_RULE_DEF => 1;
7862 use constant IN_COMMENT => 2;
7863 my $prev_state = IN_RULE_DEF;
7865 while ($_ = $am_file->getline)
7867 if (/$IGNORE_PATTERN/o)
7869 # Merely delete comments beginning with two hashes.
7871 elsif (/$WHITE_PATTERN/o)
7873 error "$amfile:$.", "blank line following trailing backslash"
7875 # Stick a single white line before the incoming macro or rule.
7878 # Flush all comments seen so far.
7881 $output_vars .= $comment;
7885 elsif (/$COMMENT_PATTERN/o)
7887 # Stick comments before the incoming macro or rule. Make
7888 # sure a blank line preceeds first block of comments.
7889 $spacing = "\n" unless $blank;
7891 $comment .= $spacing . $_;
7893 $prev_state = IN_COMMENT;
7899 $saw_bk = /\\$/ && ! /$IGNORE_PATTERN/o;
7902 # We save the conditional stack on entry, and then check to make
7903 # sure it is the same on exit. This lets us conditonally include
7905 my @saved_cond_stack = @cond_stack;
7906 my $cond = conditional_string (@cond_stack);
7908 my $last_var_name = '';
7909 my $last_var_type = '';
7910 my $last_var_value = '';
7911 # FIXME: shouldn't use $_ in this loop; it is too big.
7914 my $here = "$amfile:$.";
7916 # Make sure the line is \n-terminated.
7920 # Don't look at MAINTAINER_MODE_TRUE here. That shouldn't be
7921 # used by users. @MAINT@ is an anachronism now.
7922 $_ =~ s/\@MAINT\@//g
7923 unless $seen_maint_mode;
7925 my $new_saw_bk = /\\$/ && ! /$IGNORE_PATTERN/o;
7927 if (/$IGNORE_PATTERN/o)
7929 # Merely delete comments beginning with two hashes.
7931 elsif (/$WHITE_PATTERN/o)
7933 # Stick a single white line before the incoming macro or rule.
7935 error $here, "blank line following trailing backslash"
7938 elsif (/$COMMENT_PATTERN/o)
7940 # Stick comments before the incoming macro or rule.
7941 $comment .= $spacing . $_;
7943 error $here, "comment following trailing backslash"
7944 if $saw_bk && $comment eq '';
7945 $prev_state = IN_COMMENT;
7949 if ($prev_state == IN_RULE_DEF)
7951 $output_trailer .= &make_condition (@cond_stack);
7952 $output_trailer .= $_;
7954 elsif ($prev_state == IN_COMMENT)
7956 # If the line doesn't start with a `#', add it.
7957 # We do this because a continuated comment like
7961 # is not portable. BSD make doesn't honor
7962 # escaped newlines in comments.
7964 $comment .= $spacing . $_;
7966 else # $prev_state == IN_VAR_DEF
7968 $last_var_value .= ' '
7969 unless $last_var_value =~ /\s$/;
7970 $last_var_value .= $_;
7974 append_comments ($cond || 'TRUE',
7975 $last_var_name, $spacing, $comment);
7976 $comment = $spacing = '';
7977 macro_define ($last_var_name, VAR_MAKEFILE,
7978 $last_var_type, $cond,
7979 $last_var_value, $here)
7980 if $cond ne 'FALSE';
7981 push (@var_list, $last_var_name);
7986 elsif (/$IF_PATTERN/o)
7988 $cond = cond_stack_if ($1, $2, $here);
7990 elsif (/$ELSE_PATTERN/o)
7992 $cond = cond_stack_else ($1, $2, $here);
7994 elsif (/$ENDIF_PATTERN/o)
7996 $cond = cond_stack_endif ($1, $2, $here);
7999 elsif (/$RULE_PATTERN/o)
8002 $prev_state = IN_RULE_DEF;
8004 # For now we have to output all definitions of user rules
8005 # and can't diagnose duplicates (see the comment in
8006 # rule_define). So we go on and ignore the return value.
8007 rule_define ($1, $amfile, TARGET_USER, $cond || 'TRUE', $here);
8009 check_variable_expansions ($_, $here);
8011 $output_trailer .= $comment . $spacing;
8012 $output_trailer .= &make_condition (@cond_stack);
8013 $output_trailer .= $_;
8014 $comment = $spacing = '';
8016 elsif (/$ASSIGNMENT_PATTERN/o)
8018 # Found a macro definition.
8019 $prev_state = IN_VAR_DEF;
8020 $last_var_name = $1;
8021 $last_var_type = $2;
8022 $last_var_value = $3;
8023 if ($3 ne '' && substr ($3, -1) eq "\\")
8025 # We preserve the `\' because otherwise the long lines
8026 # that are generated will be truncated by broken
8028 $last_var_value = $3 . "\n";
8033 # Accumulating variables must not be output.
8034 append_comments ($cond || 'TRUE',
8035 $last_var_name, $spacing, $comment);
8036 $comment = $spacing = '';
8038 macro_define ($last_var_name, VAR_MAKEFILE,
8039 $last_var_type, $cond,
8040 $last_var_value, $here)
8041 if $cond ne 'FALSE';
8042 push (@var_list, $last_var_name);
8045 elsif (/$INCLUDE_PATTERN/o)
8049 if ($path =~ s/^\$\(top_srcdir\)\///)
8051 push (@include_stack, "\$\(top_srcdir\)/$path");
8052 # Distribute any included file.
8054 # Always use the $(top_srcdir) prefix in DIST_COMMON,
8055 # otherwise OSF make will implicitely copy the included
8056 # file in the build tree during `make distdir' to satisfy
8058 # (subdircond2.test and subdircond3.test will fail.)
8059 push_dist_common ("\$\(top_srcdir\)/$path");
8063 $path =~ s/\$\(srcdir\)\///;
8064 push (@include_stack, "\$\(srcdir\)/$path");
8065 # Always use the $(srcdir) prefix in DIST_COMMON,
8066 # otherwise OSF make will implicitely copy the included
8067 # file in the build tree during `make distdir' to satisfy
8069 # (subdircond2.test and subdircond3.test will fail.)
8070 push_dist_common ("\$\(srcdir\)/$path");
8071 $path = $relative_dir . "/" . $path;
8073 &read_am_file ($path);
8077 # This isn't an error; it is probably a continued rule.
8078 # In fact, this is what we assume.
8079 $prev_state = IN_RULE_DEF;
8080 check_variable_expansions ($_, $here);
8081 $output_trailer .= $comment . $spacing;
8082 $output_trailer .= &make_condition (@cond_stack);
8083 $output_trailer .= $_;
8084 $comment = $spacing = '';
8085 error $here, "`#' comment at start of rule is unportable"
8086 if $_ =~ /^\t\s*\#/;
8089 $saw_bk = $new_saw_bk;
8090 $_ = $am_file->getline;
8093 $output_trailer .= $comment;
8095 err_am ("trailing backslash on last line")
8098 err_am (@cond_stack ? "unterminated conditionals: @cond_stack"
8099 : "too many conditionals closed in include file")
8100 if "@saved_cond_stack" ne "@cond_stack";
8104 # define_standard_variables ()
8105 # ----------------------------
8106 # A helper for read_main_am_file which initializes configure variables
8107 # and variables from header-vars.am.
8108 sub define_standard_variables
8110 my $saved_output_vars = $output_vars;
8111 my ($comments, undef, $rules) =
8112 file_contents_internal (1, "$libdir/am/header-vars.am");
8114 # This will output the definitions in $output_vars, which we don't
8116 foreach my $var (sort keys %configure_vars)
8118 &define_configure_variable ($var);
8119 push (@var_list, $var);
8122 # ... hence, we restore $output_vars.
8123 $output_vars = $saved_output_vars . $comments . $rules;
8126 # Read main am file.
8127 sub read_main_am_file
8131 # This supports the strange variable tricks we are about to play.
8132 prog_error (macros_dump () . "variable defined before read_main_am_file")
8133 if (scalar keys %var_value > 0);
8135 # Generate copyright header for generated Makefile.in.
8136 # We do discard the output of predefined variables, handled below.
8137 $output_vars = ("# $in_file_name generated by automake "
8138 . $VERSION . " from $am_file_name.\n");
8139 $output_vars .= '# ' . subst ('configure_input') . "\n";
8140 $output_vars .= $gen_copyright;
8142 # We want to predefine as many variables as possible. This lets
8143 # the user set them with `+=' in Makefile.am. However, we don't
8144 # want these initial definitions to end up in the output quite
8145 # yet. So we just load them, but output them later.
8146 &define_standard_variables;
8148 # Read user file, which might override some of our values.
8149 &read_am_file ($amfile);
8151 # Output all the Automake variables. If the user changed one,
8152 # then it is now marked as VAR_CONFIGURE or VAR_MAKEFILE.
8153 foreach my $var (uniq @var_list)
8155 # Some variables, like AMDEPBACKSLASH are in @var_list
8156 # but don't have a owner. This is good, because we don't want
8158 foreach my $cond (keys %{$var_owner{$var}})
8160 variable_output ($var, $cond)
8161 if $var_owner{$var}{$cond} == VAR_AUTOMAKE;
8165 # Now dump the user variables that were defined. We do it in the same
8166 # order in which they were defined (skipping duplicates).
8167 foreach my $var (uniq @var_list)
8169 foreach my $cond (keys %{$var_owner{$var}})
8171 variable_output ($var, $cond)
8172 if $var_owner{$var}{$cond} != VAR_AUTOMAKE;
8177 ################################################################
8180 # &flatten ($STRING)
8181 # ------------------
8182 # Flatten the $STRING and return the result.
8197 # &make_paragraphs ($MAKEFILE, [%TRANSFORM])
8198 # ------------------------------------------
8199 # Load a $MAKEFILE, apply the %TRANSFORM, and return it as a list of
8201 sub make_paragraphs ($%)
8203 my ($file, %transform) = @_;
8205 # Complete %transform with global options and make it a Perl
8208 "s/$IGNORE_PATTERN//gm;"
8209 . transform (%transform,
8211 'CYGNUS' => $cygnus_mode,
8213 => $seen_maint_mode ? subst ('MAINTAINER_MODE_TRUE') : '',
8215 'SHAR' => $options{'dist-shar'} || 0,
8216 'BZIP2' => $options{'dist-bzip2'} || 0,
8217 'ZIP' => $options{'dist-zip'} || 0,
8218 'COMPRESS' => $options{'dist-tarZ'} || 0,
8220 'INSTALL-INFO' => !$options{'no-installinfo'},
8221 'INSTALL-MAN' => !$options{'no-installman'},
8222 'CK-NEWS' => $options{'check-news'} || 0,
8224 'SUBDIRS' => variable_defined ('SUBDIRS'),
8225 'TOPDIR' => backname ($relative_dir),
8226 'TOPDIR_P' => $relative_dir eq '.',
8227 'CONFIGURE-AC' => $configure_ac,
8229 'BUILD' => $seen_canonical == AC_CANONICAL_SYSTEM,
8230 'HOST' => $seen_canonical,
8231 'TARGET' => $seen_canonical == AC_CANONICAL_SYSTEM,
8233 'LIBTOOL' => variable_defined ('LIBTOOL'))
8234 # We don't need more than two consecutive new-lines.
8235 . 's/\n{3,}/\n\n/g';
8237 # Swallow the file and apply the COMMAND.
8238 my $fc_file = new Automake::XFile "< $file";
8240 verb "reading $file";
8241 my $saved_dollar_slash = $/;
8243 $_ = $fc_file->getline;
8244 $/ = $saved_dollar_slash;
8249 # Split at unescaped new lines.
8250 my @lines = split (/(?<!\\)\n/, $content);
8253 while (defined ($_ = shift @lines))
8255 my $paragraph = "$_";
8256 # If we are a rule, eat as long as we start with a tab.
8257 if (/$RULE_PATTERN/smo)
8259 while (defined ($_ = shift @lines) && $_ =~ /^\t/)
8261 $paragraph .= "\n$_";
8263 unshift (@lines, $_);
8266 # If we are a comments, eat as much comments as you can.
8267 elsif (/$COMMENT_PATTERN/smo)
8269 while (defined ($_ = shift @lines)
8270 && $_ =~ /$COMMENT_PATTERN/smo)
8272 $paragraph .= "\n$_";
8274 unshift (@lines, $_);
8277 push @res, $paragraph;
8286 # ($COMMENT, $VARIABLES, $RULES)
8287 # &file_contents_internal ($IS_AM, $FILE, [%TRANSFORM])
8288 # -----------------------------------------------------
8289 # Return contents of a file from $libdir/am, automatically skipping
8290 # macros or rules which are already known. $IS_AM iff the caller is
8291 # reading an Automake file (as opposed to the user's Makefile.am).
8292 sub file_contents_internal ($$%)
8294 my ($is_am, $file, %transform) = @_;
8296 my $result_vars = '';
8297 my $result_rules = '';
8301 # The following flags are used to track rules spanning across
8302 # multiple paragraphs.
8303 my $is_rule = 0; # 1 if we are processing a rule.
8304 my $discard_rule = 0; # 1 if the current rule should not be output.
8306 # We save the conditional stack on entry, and then check to make
8307 # sure it is the same on exit. This lets us conditonally include
8309 my @saved_cond_stack = @cond_stack;
8310 my $cond = conditional_string (@cond_stack);
8312 foreach (make_paragraphs ($file, %transform))
8315 error $file, "blank line following trailing backslash:\n$_"
8317 error $file, "comment following trailing backslash:\n$_"
8323 # Stick empty line before the incoming macro or rule.
8326 elsif (/$COMMENT_PATTERN/mso)
8329 # Stick comments before the incoming macro or rule.
8333 # Handle inclusion of other files.
8334 elsif (/$INCLUDE_PATTERN/o)
8336 if ($cond ne 'FALSE')
8338 my $file = ($is_am ? "$libdir/am/" : '') . $1;
8340 my ($com, $vars, $rules)
8341 = file_contents_internal ($is_am, $file, %transform);
8343 $result_vars .= $vars;
8344 $result_rules .= $rules;
8348 # Handling the conditionals.
8349 elsif (/$IF_PATTERN/o)
8351 $cond = cond_stack_if ($1, $2, $file);
8353 elsif (/$ELSE_PATTERN/o)
8355 $cond = cond_stack_else ($1, $2, $file);
8357 elsif (/$ENDIF_PATTERN/o)
8359 $cond = cond_stack_endif ($1, $2, $file);
8363 elsif (/$RULE_PATTERN/mso)
8367 # Separate relationship from optional actions: the first
8368 # `new-line tab" not preceded by backslash (continuation
8371 /^(.*?)(?:(?<!\\)\n(\t.*))?$/s;
8372 my ($relationship, $actions) = ($1, $2 || '');
8374 # Separate targets from dependencies: the first colon.
8375 $relationship =~ /^([^:]+\S+) *: *(.*)$/som;
8376 my ($targets, $dependencies) = ($1, $2);
8377 # Remove the escaped new lines.
8378 # I don't know why, but I have to use a tmp $flat_deps.
8379 my $flat_deps = &flatten ($dependencies);
8380 my @deps = split (' ', $flat_deps);
8382 foreach (split (' ' , $targets))
8384 # FIXME: 1. We are not robust to people defining several targets
8385 # at once, only some of them being in %dependencies. The
8386 # actions from the targets in %dependencies are usually generated
8387 # from the content of %actions, but if some targets in $targets
8388 # are not in %dependencies the ELSE branch will output
8389 # a rule for all $targets (i.e. the targets which are both
8390 # in %dependencies and $targets will have two rules).
8392 # FIXME: 2. The logic here is not able to output a
8393 # multi-paragraph rule several time (e.g. for each conditional
8394 # it is defined for) because it only knows the first paragraph.
8396 # FIXME: 3. We are not robust to people defining a subset
8397 # of a previously defined "multiple-target" rule. E.g.
8398 # `foo:' after `foo bar:'.
8400 # Output only if not in FALSE.
8401 if (defined $dependencies{$_} && $cond ne 'FALSE')
8403 &depend ($_, @deps);
8404 $actions{$_} .= $actions;
8408 # Free-lance dependency. Output the rule for all the
8409 # targets instead of one by one.
8410 my @undefined_conds =
8411 rule_define ($targets, $file,
8412 $is_am ? TARGET_AUTOMAKE : TARGET_USER,
8413 $cond || 'TRUE', $file);
8414 for my $undefined_cond (@undefined_conds)
8416 my $condparagraph = $paragraph;
8417 $condparagraph =~ s/^/$undefined_cond/gm;
8418 $result_rules .= "$spacing$comment$condparagraph\n";
8420 if (scalar @undefined_conds == 0)
8422 # Remember to discard next paragraphs
8423 # if they belong to this rule.
8424 # (but see also FIXME: #2 above.)
8427 $comment = $spacing = '';
8433 elsif (/$ASSIGNMENT_PATTERN/mso)
8435 my ($var, $type, $val) = ($1, $2, $3);
8436 error $file, "variable `$var' with trailing backslash"
8441 # Accumulating variables must not be output.
8442 append_comments ($cond || 'TRUE', $var, $spacing, $comment);
8443 macro_define ($var, $is_am ? VAR_AUTOMAKE : VAR_MAKEFILE,
8444 $type, $cond, $val, $file)
8445 if $cond ne 'FALSE';
8446 push (@var_list, $var);
8448 # If the user has set some variables we were in charge
8449 # of (which is detected by the first reading of
8450 # `header-vars.am'), we must not output them.
8451 $result_vars .= "$spacing$comment$_\n"
8452 if ($cond ne 'FALSE' && $type ne '+'
8453 && exists $var_owner{$var}{$cond || 'TRUE'}
8454 && $var_owner{$var}{$cond || 'TRUE'} == VAR_AUTOMAKE);
8456 $comment = $spacing = '';
8460 # This isn't an error; it is probably some tokens which
8461 # configure is supposed to replace, such as `@SET-MAKE@',
8462 # or some part of a rule cut by an if/endif.
8463 if ($cond ne 'FALSE' && ! ($is_rule && $discard_rule))
8465 s/^/make_condition (@cond_stack)/gme;
8466 $result_rules .= "$spacing$comment$_\n";
8468 $comment = $spacing = '';
8472 err_am (@cond_stack ?
8473 "unterminated conditionals: @cond_stack" :
8474 "too many conditionals closed in include file")
8475 if "@saved_cond_stack" ne "@cond_stack";
8477 return ($comment, $result_vars, $result_rules);
8482 # &file_contents ($BASENAME, [%TRANSFORM])
8483 # ----------------------------------------
8484 # Return contents of a file from $libdir/am, automatically skipping
8485 # macros or rules which are already known.
8486 sub file_contents ($%)
8488 my ($basename, %transform) = @_;
8489 my ($comments, $variables, $rules) =
8490 file_contents_internal (1, "$libdir/am/$basename.am", %transform);
8491 return "$comments$variables$rules";
8496 # &transform (%PAIRS)
8497 # -------------------
8498 # Foreach ($TOKEN, $VAL) in %PAIRS produce a replacement expression suitable
8499 # for file_contents which:
8500 # - replaces %$TOKEN% with $VAL,
8501 # - enables/disables ?$TOKEN? and ?!$TOKEN?,
8502 # - replaces %?$TOKEN% with TRUE or FALSE.
8508 while (my ($token, $val) = each %pairs)
8510 $result .= "s/\Q%$token%\E/\Q$val\E/gm;";
8513 $result .= "s/\Q?$token?\E//gm;s/^.*\Q?!$token?\E.*\\n//gm;";
8514 $result .= "s/\Q%?$token%\E/TRUE/gm;";
8518 $result .= "s/\Q?!$token?\E//gm;s/^.*\Q?$token?\E.*\\n//gm;";
8519 $result .= "s/\Q%?$token%\E/FALSE/gm;";
8527 # &append_exeext ($MACRO)
8528 # -----------------------
8529 # Macro is an Automake magic macro which primary is PROGRAMS, e.g.
8530 # bin_PROGRAMS. Make sure these programs have $(EXEEXT) appended.
8531 sub append_exeext ($)
8535 prog_error "append_exeext ($macro)"
8536 unless $macro =~ /_PROGRAMS$/;
8538 my @conds = variable_conditions_recursive ($macro);
8541 foreach my $cond (@conds)
8543 my @one_binlist = ();
8544 my @condval = variable_value_as_list_recursive ($macro, $cond);
8545 foreach my $rcurs (@condval)
8547 # Skip autoconf substs. Also skip if the user
8548 # already applied $(EXEEXT).
8549 if ($rcurs =~ /^\@.*\@$/ || $rcurs =~ /\$\(EXEEXT\)$/)
8551 push (@one_binlist, $rcurs);
8555 push (@one_binlist, $rcurs . '$(EXEEXT)');
8559 push (@condvals, $cond);
8560 push (@condvals, "@one_binlist");
8563 macro_delete ($macro);
8566 my $cond = shift (@condvals);
8567 my @val = split (' ', shift (@condvals));
8568 define_pretty_variable ($macro, $cond, @val);
8574 # &am_primary_prefixes ($PRIMARY, $CAN_DIST, @PREFIXES)
8575 # -----------------------------------------------------
8576 # Find all variable prefixes that are used for install directories. A
8577 # prefix `zar' qualifies iff:
8579 # * `zardir' is a variable.
8580 # * `zar_PRIMARY' is a variable.
8582 # As a side effect, it looks for misspellings. It is an error to have
8583 # a variable ending in a "reserved" suffix whose prefix is unknown, eg
8584 # "bni_PROGRAMS". However, unusual prefixes are allowed if a variable
8585 # of the same name (with "dir" appended) exists. For instance, if the
8586 # variable "zardir" is defined, then "zar_PROGRAMS" becomes valid.
8587 # This is to provide a little extra flexibility in those cases which
8589 sub am_primary_prefixes ($$@)
8591 my ($primary, $can_dist, @prefixes) = @_;
8594 my %valid = map { $_ => 0 } @prefixes;
8595 $valid{'EXTRA'} = 0;
8596 foreach my $varname (keys %var_value)
8598 # Automake is allowed to define variables that look like primaries
8599 # but which aren't. E.g. INSTALL_sh_DATA.
8600 # Autoconf can also define variables like INSTALL_DATA, so
8601 # ignore all configure variables (at least those which are not
8602 # redefined in Makefile.am).
8603 # FIXME: We should make sure that these variables are not
8604 # conditionally defined (or else adjust the condition below).
8606 if (exists $var_owner{$varname}
8607 && exists $var_owner{$varname}{'TRUE'}
8608 && $var_owner{$varname}{'TRUE'} != VAR_MAKEFILE);
8610 if ($varname =~ /^(nobase_)?(dist_|nodist_)?(.*)_$primary$/)
8612 my ($base, $dist, $X) = ($1 || '', $2 || '', $3 || '');
8613 if ($dist ne '' && ! $can_dist)
8616 "invalid variable `$varname': `dist' is forbidden");
8618 # Standard directories must be explicitely allowed.
8619 elsif (! defined $valid{$X} && exists $standard_prefix{$X})
8622 "`${X}dir' is not a legitimate directory " .
8625 # A not explicitely valid directory is allowed if Xdir is defined.
8626 elsif (! defined $valid{$X} &&
8627 require_variables_for_macro ($varname, "`$varname' is used",
8630 # Nothing to do. Any error message has been output
8631 # by require_variables_for_macro.
8635 # Ensure all extended prefixes are actually used.
8636 $valid{"$base$dist$X"} = 1;
8641 # Return only those which are actually defined.
8642 return sort grep { variable_defined ($_ . '_' . $primary) } keys %valid;
8646 # Handle `where_HOW' variable magic. Does all lookups, generates
8647 # install code, and possibly generates code to define the primary
8648 # variable. The first argument is the name of the .am file to munge,
8649 # the second argument is the primary variable (eg HEADERS), and all
8650 # subsequent arguments are possible installation locations. Returns
8651 # list of all values of all _HOW targets.
8653 # FIXME: this should be rewritten to be cleaner. It should be broken
8654 # up into multiple functions.
8656 # Usage is: am_install_var (OPTION..., file, HOW, where...)
8663 my $default_dist = 0;
8666 if ($args[0] eq '-noextra')
8670 elsif ($args[0] eq '-candist')
8674 elsif ($args[0] eq '-defaultdist')
8679 elsif ($args[0] !~ /^-/)
8686 my ($file, $primary, @prefix) = @args;
8688 # Now that configure substitutions are allowed in where_HOW
8689 # variables, it is an error to actually define the primary. We
8690 # allow `JAVA', as it is customarily used to mean the Java
8691 # interpreter. This is but one of several Java hacks. Similarly,
8692 # `PYTHON' is customarily used to mean the Python interpreter.
8693 reject_var $primary, "`$primary' is an anachronism"
8694 unless $primary eq 'JAVA' || $primary eq 'PYTHON';
8696 # Get the prefixes which are valid and actually used.
8697 @prefix = am_primary_prefixes ($primary, $can_dist, @prefix);
8699 # If a primary includes a configure substitution, then the EXTRA_
8700 # form is required. Otherwise we can't properly do our job.
8706 # True if the iteration is the first one. Used for instance to
8707 # output parts of the associated file only once.
8709 foreach my $X (@prefix)
8711 my $nodir_name = $X;
8712 my $one_name = $X . '_' . $primary;
8714 my $strip_subdir = 1;
8715 # If subdir prefix should be preserved, do so.
8716 if ($nodir_name =~ /^nobase_/)
8719 $nodir_name =~ s/^nobase_//;
8722 # If files should be distributed, do so.
8726 $dist_p = (($default_dist && $nodir_name !~ /^nodist_/)
8727 || (! $default_dist && $nodir_name =~ /^dist_/));
8728 $nodir_name =~ s/^(dist|nodist)_//;
8731 # Append actual contents of where_PRIMARY variable to
8733 foreach my $rcurs (&variable_value_as_list_recursive ($one_name, 'all'))
8735 # Skip configure substitutions. Possibly bogus.
8736 if ($rcurs =~ /^\@.*\@$/)
8738 if ($nodir_name eq 'EXTRA')
8741 "`$one_name' contains configure substitution, "
8744 # Check here to make sure variables defined in
8745 # configure.ac do not imply that EXTRA_PRIMARY
8747 elsif (! defined $configure_vars{$one_name})
8749 $require_extra = $one_name
8756 push (@result, $rcurs);
8758 # A blatant hack: we rewrite each _PROGRAMS primary to include
8760 append_exeext ($one_name)
8761 if $primary eq 'PROGRAMS';
8762 # "EXTRA" shouldn't be used when generating clean targets,
8763 # all, or install targets. We used to warn if EXTRA_FOO was
8764 # defined uselessly, but this was annoying.
8766 if $nodir_name eq 'EXTRA';
8768 if ($nodir_name eq 'check')
8770 push (@check, '$(' . $one_name . ')');
8774 push (@used, '$(' . $one_name . ')');
8777 # Is this to be installed?
8778 my $install_p = $nodir_name ne 'noinst' && $nodir_name ne 'check';
8780 # If so, with install-exec? (or install-data?).
8781 my $exec_p = ($nodir_name =~ /$EXEC_DIR_PATTERN/o);
8783 my $check_options_p = $install_p
8784 && defined $options{'std-options'};
8786 # Singular form of $PRIMARY.
8787 (my $one_primary = $primary) =~ s/S$//;
8788 $output_rules .= &file_contents ($file,
8791 'PRIMARY' => $primary,
8792 'ONE_PRIMARY' => $one_primary,
8794 'NDIR' => $nodir_name,
8795 'BASE' => $strip_subdir,
8798 'INSTALL' => $install_p,
8800 'CK-OPTS' => $check_options_p));
8805 # The JAVA variable is used as the name of the Java interpreter.
8806 # The PYTHON variable is used as the name of the Python interpreter.
8807 if (@used && $primary ne 'JAVA' && $primary ne 'PYTHON')
8810 define_pretty_variable ($primary, '', @used);
8811 $output_vars .= "\n";
8814 err_var ($require_extra,
8815 "`$require_extra' contains configure substitution,\n"
8816 . "but `EXTRA_$primary' not defined")
8817 if ($require_extra && ! variable_defined ('EXTRA_' . $primary));
8819 # Push here because PRIMARY might be configure time determined.
8820 push (@all, '$(' . $primary . ')')
8821 if @used && $primary ne 'JAVA' && $primary ne 'PYTHON';
8823 # Make the result unique. This lets the user use conditionals in
8824 # a natural way, but still lets us program lazily -- we don't have
8825 # to worry about handling a particular object more than once.
8826 return uniq (sort @result);
8830 ################################################################
8832 # Each key in this hash is the name of a directory holding a
8833 # Makefile.in. These variables are local to `is_make_dir'.
8835 my $make_dirs_set = 0;
8840 if (! $make_dirs_set)
8842 foreach my $iter (@configure_input_files)
8844 $make_dirs{dirname ($iter)} = 1;
8846 # We also want to notice Makefile.in's.
8847 foreach my $iter (@other_input_files)
8849 if ($iter =~ /Makefile\.in$/)
8851 $make_dirs{dirname ($iter)} = 1;
8856 return defined $make_dirs{$dir};
8859 ################################################################
8861 # This variable is local to the "require file" set of functions.
8862 my @require_file_paths = ();
8865 # &maybe_push_required_file ($DIR, $FILE, $FULLFILE)
8866 # --------------------------------------------------
8867 # See if we want to push this file onto dist_common. This function
8868 # encodes the rules for deciding when to do so.
8869 sub maybe_push_required_file
8871 my ($dir, $file, $fullfile) = @_;
8873 if ($dir eq $relative_dir)
8875 push_dist_common ($file);
8878 elsif ($relative_dir eq '.' && ! &is_make_dir ($dir))
8880 # If we are doing the topmost directory, and the file is in a
8881 # subdir which does not have a Makefile, then we distribute it
8883 push_dist_common ($fullfile);
8890 # &require_file_internal ($WHERE, $MYSTRICT, @FILES)
8891 # --------------------------------------------------
8892 # Verify that the file must exist in the current directory.
8893 # $MYSTRICT is the strictness level at which this file becomes required.
8895 # Must set require_file_paths before calling this function.
8896 # require_file_paths is set to hold a single directory (the one in
8897 # which the first file was found) before return.
8898 sub require_file_internal ($$@)
8900 my ($where, $mystrict, @files) = @_;
8902 foreach my $file (@files)
8910 my $dangling_sym = 0;
8911 foreach my $dir (@require_file_paths)
8913 $fullfile = $dir . "/" . $file;
8914 $errdir = $dir unless $errdir;
8916 # Use different name for "error filename". Otherwise on
8917 # an error the bad file will be reported as eg
8918 # `../../install-sh' when using the default
8920 $errfile = $errdir . '/' . $file;
8922 if (-l $fullfile && ! -f $fullfile)
8927 elsif (-f $fullfile)
8930 maybe_push_required_file ($dir, $file, $fullfile);
8936 # `--force-missing' only has an effect if `--add-missing' is
8938 if ($found_it && (! $add_missing || ! $force_missing))
8940 # Prune the path list.
8941 @require_file_paths = $save_dir;
8945 # If we've already looked for it, we're done. You might
8946 # wonder why we don't do this before searching for the
8947 # file. If we do that, then something like
8948 # AC_OUTPUT(subdir/foo foo) will fail to put foo.in into
8952 next if defined $require_file_found{$fullfile};
8953 $require_file_found{$fullfile} = 1;
8956 if ($strictness >= $mystrict)
8958 if ($dangling_sym && $add_missing)
8966 # Only install missing files according to our desired
8968 my $message = "required file `$errfile' not found";
8971 if (-f ("$libdir/$file"))
8975 # Install the missing file. Symlink if we
8976 # can, copy if we must. Note: delete the file
8977 # first, in case it is a dangling symlink.
8978 $message = "installing `$errfile'";
8979 # Windows Perl will hang if we try to delete a
8980 # file that doesn't exist.
8981 unlink ($errfile) if -f $errfile;
8982 if ($symlink_exists && ! $copy_missing)
8984 if (! symlink ("$libdir/$file", $errfile))
8987 $trailer = "; error while making link: $!";
8990 elsif (system ('cp', "$libdir/$file", $errfile))
8993 $trailer = "\n error while copying";
8997 if (! maybe_push_required_file (dirname ($errfile),
9002 # We have added the file but could not push it
9003 # into DIST_COMMON (probably because this is
9004 # an auxiliary file and we are not processing
9005 # the top level Makefile). This is unfortunate,
9006 # since it means we are using a file which is not
9009 # Get Automake to be run again: on the second
9010 # run the file will be found, and pushed into
9011 # the toplevel DIST_COMMON automatically.
9012 $automake_needs_to_reprocess_all_files = 1;
9016 # Prune the path list.
9017 @require_file_paths = &dirname ($errfile);
9020 # If --force-missing was specified, and we have
9021 # actually found the file, then do nothing.
9023 if $found_it && $force_missing;
9025 # If we couldn' install the file, but it is a target in
9026 # the Makefile, don't print anything. This allows files
9027 # like README, AUTHORS, or THANKS to be generated.
9029 if !$suppress && target_defined ($file);
9031 msg ($suppress ? 'note' : 'error', $where, "$message$trailer");
9037 # &require_file ($WHERE, $MYSTRICT, @FILES)
9038 # -----------------------------------------
9039 sub require_file ($$@)
9041 my ($where, $mystrict, @files) = @_;
9042 @require_file_paths = $relative_dir;
9043 require_file_internal ($where, $mystrict, @files);
9046 # &require_file_with_macro ($COND, $MACRO, $MYSTRICT, @FILES)
9047 # -----------------------------------------------------------
9048 sub require_file_with_macro ($$$@)
9050 my ($cond, $macro, $mystrict, @files) = @_;
9051 require_file ($var_location{$macro}{$cond}, $mystrict, @files);
9055 # &require_conf_file ($WHERE, $MYSTRICT, @FILES)
9056 # ----------------------------------------------
9057 # Looks in configuration path, as specified by AC_CONFIG_AUX_DIR.
9058 sub require_conf_file ($$@)
9060 my ($where, $mystrict, @files) = @_;
9061 @require_file_paths = @config_aux_path;
9062 require_file_internal ($where, $mystrict, @files);
9063 my $dir = $require_file_paths[0];
9064 @config_aux_path = @require_file_paths;
9065 # Avoid unsightly '/.'s.
9066 $config_aux_dir = '$(top_srcdir)' . ($dir eq '.' ? "" : "/$dir");
9070 # &require_conf_file_with_macro ($COND, $MACRO, $MYSTRICT, @FILES)
9071 # ----------------------------------------------------------------
9072 sub require_conf_file_with_macro ($$$@)
9074 my ($cond, $macro, $mystrict, @files) = @_;
9075 require_conf_file ($var_location{$macro}{$cond}, $mystrict, @files);
9078 ################################################################
9080 # &require_build_directory ($DIRECTORY)
9081 # ------------------------------------
9082 # Emit rules to create $DIRECTORY if needed, and return
9083 # the file that any target requiring this directory should be made
9085 sub require_build_directory ($)
9087 my $directory = shift;
9088 my $dirstamp = "$directory/\$(am__dirstamp)";
9090 # Don't emit the rule twice.
9091 if (! defined $directory_map{$directory})
9093 $directory_map{$directory} = 1;
9095 # Set a variable for the dirstamp basename.
9096 define_pretty_variable ('am__dirstamp', 'TRUE',
9097 '$(am__leading_dot)dirstamp')
9098 unless variable_defined ('am__dirstamp');
9100 # Directory must be removed by `make distclean'.
9101 $clean_files{$dirstamp} = DIST_CLEAN;
9103 $output_rules .= ("$dirstamp:\n"
9104 . "\t\@\$(mkinstalldirs) $directory\n"
9105 . "\t\@: > $dirstamp\n");
9111 # &require_build_directory_maybe ($FILE)
9112 # --------------------------------------
9113 # If $FILE lies in a subdirectory, emit a rule to create this
9114 # directory and return the file that $FILE should be made
9115 # dependent upon. Otherwise, just return the empty string.
9116 sub require_build_directory_maybe ($)
9119 my $directory = dirname ($file);
9121 if ($directory ne '.')
9123 return require_build_directory ($directory);
9131 ################################################################
9133 # Push a list of files onto dist_common.
9134 sub push_dist_common
9136 prog_error "push_dist_common run after handle_dist"
9137 if $handle_dist_run;
9138 macro_define ('DIST_COMMON', VAR_AUTOMAKE, '+', '', "@_", '');
9145 $strictness_name = $_[0];
9147 # FIXME: 'portability' warnings are currently disabled by default.
9148 # Eventually we want to turn them on in GNU and GNITS modes, but
9149 # we don't do this yet in Automake 1.7 to help the 1.6/1.7 transition.
9151 # Indeed there would be only two ways to get rid of these new warnings:
9152 # 1. adjusting Makefile.am
9153 # This is not always easy (or wanted). Consider %-rules or
9154 # $(function args) variables.
9155 # 2. using -Wno-portability
9156 # This means there is no way to have the same Makefile.am
9157 # working both with Automake 1.6 and 1.7 (since 1.6 does not
9158 # understand -Wno-portability).
9160 # In Automake 1.8 (or whatever it is called) we can turn these
9161 # warnings on, since -Wno-portability will not be an issue for
9162 # the 1.7/1.8 transition.
9163 if ($strictness_name eq 'gnu')
9166 setup_channel 'error-gnu', silent => 0;
9167 setup_channel 'error-gnu/warn', silent => 0, type => 'error';
9168 setup_channel 'error-gnits', silent => 1;
9169 # setup_channel 'portability', silent => 0;
9170 setup_channel 'gnu', silent => 0;
9172 elsif ($strictness_name eq 'gnits')
9174 $strictness = GNITS;
9175 setup_channel 'error-gnu', silent => 0;
9176 setup_channel 'error-gnu/warn', silent => 0, type => 'error';
9177 setup_channel 'error-gnits', silent => 0;
9178 # setup_channel 'portability', silent => 0;
9179 setup_channel 'gnu', silent => 0;
9181 elsif ($strictness_name eq 'foreign')
9183 $strictness = FOREIGN;
9184 setup_channel 'error-gnu', silent => 1;
9185 setup_channel 'error-gnu/warn', silent => 0, type => 'warning';
9186 setup_channel 'error-gnits', silent => 1;
9187 # setup_channel 'portability', silent => 1;
9188 setup_channel 'gnu', silent => 1;
9192 prog_error "level `$strictness_name' not recognized\n";
9197 ################################################################
9199 # Glob something. Do this to avoid indentation screwups everywhere we
9200 # want to glob. Gross!
9207 ################################################################
9210 # require_variables ($WHERE, $REASON, $COND, @VARIABLES)
9211 # ------------------------------------------------------
9212 # Make sure that each supplied variable is defined in $COND.
9213 # Otherwise, issue a warning. If we know which macro can
9214 # define this variable, hint the user.
9215 # Return the number of undefined variables.
9216 sub require_variables ($$$@)
9218 my ($where, $reason, $cond, @vars) = @_;
9220 $reason .= ' but ' unless $reason eq '';
9223 foreach my $var (@vars)
9225 # Nothing to do if the variable exists. The $configure_vars test
9226 # needed for strange variables like AMDEPBACKSLASH or ANSI2KNR
9227 # that are AC_SUBST'ed but never macro_define'd.
9229 if ((exists $var_value{$var} && exists $var_value{$var}{$cond})
9230 || exists $configure_vars{$var});
9232 my @undef_cond = variable_not_always_defined_in_cond $var, $cond;
9236 my $text = "$reason`$var' is undefined\n";
9237 if (@undef_cond && $undef_cond[0] ne 'TRUE')
9239 $text .= ("in the following conditions:\n "
9240 . join ("\n ", @undef_cond));
9245 if (exists $am_macro_for_var{$var})
9247 $text .= "\nThe usual way to define `$var' is to add "
9248 . "`$am_macro_for_var{$var}'\nto `$configure_ac' and run "
9249 . "`aclocal' and `autoconf' again.";
9251 elsif (exists $ac_macro_for_var{$var})
9253 $text .= "\nThe usual way to define `$var' is to add "
9254 . "`$ac_macro_for_var{$var}'\nto `$configure_ac' and run "
9255 . "`autoconf' again.";
9258 error $where, $text, uniq_scope => US_GLOBAL;
9264 # require_variables_for_macro ($MACRO, $REASON, @VARIABLES)
9265 # ---------------------------------------------------------
9266 # Same as require_variables, but take a macro mame as first argument.
9267 sub require_variables_for_macro ($$@)
9269 my ($macro, $reason, @args) = @_;
9270 for my $cond (keys %{$var_value{$macro}})
9272 return require_variables ($var_location{$macro}{$cond}, $reason,
9277 # Print usage information.
9280 print "Usage: $0 [OPTION] ... [Makefile]...
9282 Generate Makefile.in for configure from Makefile.am.
9285 --help print this help, then exit
9286 --version print version number, then exit
9287 -v, --verbose verbosely list files processed
9288 --no-force only update Makefile.in's that are out of date
9289 -W, --warnings=CATEGORY report the warnings falling in CATEGORY
9291 Dependency tracking:
9292 -i, --ignore-deps disable dependency tracking code
9293 --include-deps enable dependency tracking code
9296 --cygnus assume program is part of Cygnus-style tree
9297 --foreign set strictness to foreign
9298 --gnits set strictness to gnits
9299 --gnu set strictness to gnu
9302 -a, --add-missing add missing standard files to package
9303 --libdir=DIR directory storing library files
9304 -c, --copy with -a, copy missing files (default is symlink)
9305 -f, --force-missing force update of standard files
9307 Warning categories include:
9308 `gnu' GNU coding standards (default in gnu and gnits modes)
9309 `obsolete' obsolete features or constructions
9310 `portability' portability issues
9311 `syntax' dubious syntactic constructs (default)
9312 `unsupported' unsupported or incomplete features (default)
9313 `all' all the warnings
9314 `no-CATEGORY' turn off warnings in CATEGORY
9315 `none' turn off all the warnings
9316 `error' treat warnings as errors
9321 foreach my $iter (sort ((@common_files, @common_sometimes)))
9323 push (@lcomm, $iter) unless $iter eq $last;
9328 print "\nFiles which are automatically distributed, if found:\n";
9329 format USAGE_FORMAT =
9330 @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<
9331 $four[0], $four[1], $four[2], $four[3]
9333 $~ = "USAGE_FORMAT";
9336 my $rows = int(@lcomm / $cols);
9337 my $rest = @lcomm % $cols;
9348 for (my $y = 0; $y < $rows; $y++)
9350 @four = ("", "", "", "");
9351 for (my $x = 0; $x < $cols; $x++)
9353 last if $y + 1 == $rows && $x == $rest;
9355 my $idx = (($x > $rest)
9356 ? ($rows * $rest + ($rows - 1) * ($x - $rest))
9360 $four[$x] = $lcomm[$idx];
9365 print "\nReport bugs to <bug-automake\@gnu.org>.\n";
9367 # --help always returns 0 per GNU standards.
9374 # Print version information
9378 automake (GNU $PACKAGE) $VERSION
9379 Written by Tom Tromey <tromey\@redhat.com>.
9381 Copyright 2003 Free Software Foundation, Inc.
9382 This is free software; see the source for copying conditions. There is NO
9383 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9385 # --version always returns 0 per GNU standards.
9389 ### Setup "GNU" style for perl-mode and cperl-mode.
9391 ## perl-indent-level: 2
9392 ## perl-continued-statement-offset: 2
9393 ## perl-continued-brace-offset: 0
9394 ## perl-brace-offset: 0
9395 ## perl-brace-imaginary-offset: 0
9396 ## perl-label-offset: -2
9397 ## cperl-indent-level: 2
9398 ## cperl-brace-offset: 0
9399 ## cperl-continued-brace-offset: 0
9400 ## cperl-label-offset: -2
9401 ## cperl-extra-newline-before-brace: t
9402 ## cperl-merge-trailing-else: nil
9403 ## cperl-continued-statement-offset: 2