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} (@_);
124 use Automake::General;
126 use Automake::Channels;
127 use Automake::ChannelDefs;
128 use Automake::Configure_ac;
129 use Automake::FileUtils;
130 use Automake::Location;
131 use Automake::Condition qw/TRUE FALSE/;
132 use Automake::DisjConditions;
133 use Automake::Version;
134 use Automake::Variable;
135 use Automake::VarDef;
136 use Automake::Wrap 'makefile_wrap';
145 # Parameters set by configure. Not to be changed. NOTE: assign
146 # VERSION as string so that e.g. version 0.30 will print correctly.
147 my $VERSION = '@VERSION@';
148 my $PACKAGE = '@PACKAGE@';
149 my $libdir = '@datadir@/@PACKAGE@-@APIVERSION@';
151 # Some regular expressions. One reason to put them here is that it
152 # makes indentation work better in Emacs.
154 # Writing singled-quoted-$-terminated regexes is a pain because
155 # perl-mode thinks of $' as the ${'} variable (instead of a $ followed
156 # by a closing quote. Letting perl-mode think the quote is not closed
157 # leads to all sort of misindentations. On the other hand, defining
158 # regexes as double-quoted strings is far less readable. So usually
161 # $REGEX = '^regex_value' . "\$";
163 my $IGNORE_PATTERN = '^\s*##([^#\n].*)?\n';
164 my $WHITE_PATTERN = '^\s*' . "\$";
165 my $COMMENT_PATTERN = '^#';
166 my $TARGET_PATTERN='[$a-zA-Z_.@%][-.a-zA-Z0-9_(){}/$+@%]*';
167 # A rule has three parts: a list of targets, a list of dependencies,
168 # and optionally actions.
170 "^($TARGET_PATTERN(?:(?:\\\\\n|\\s)+$TARGET_PATTERN)*) *:([^=].*|)\$";
172 my $SUFFIX_RULE_PATTERN =
173 '^(\.[a-zA-Z0-9_(){}$+@]+)(\.[a-zA-Z0-9_(){}$+@]+)' . "\$";
174 # Only recognize leading spaces, not leading tabs. If we recognize
175 # leading tabs here then we need to make the reader smarter, because
176 # otherwise it will think rules like `foo=bar; \' are errors.
177 my $ASSIGNMENT_PATTERN = '^ *([^ \t=:+]*)\s*([:+]?)=\s*(.*)' . "\$";
178 # This pattern recognizes a Gnits version id and sets $1 if the
179 # release is an alpha release. We also allow a suffix which can be
180 # used to extend the version number with a "fork" identifier.
181 my $GNITS_VERSION_PATTERN = '\d+\.\d+([a-z]|\.\d+)?(-[A-Za-z0-9]+)?';
183 my $IF_PATTERN = '^if\s+(!?)\s*([A-Za-z][A-Za-z0-9_]*)\s*(?:#.*)?' . "\$";
185 '^else(?:\s+(!?)\s*([A-Za-z][A-Za-z0-9_]*))?\s*(?:#.*)?' . "\$";
187 '^endif(?:\s+(!?)\s*([A-Za-z][A-Za-z0-9_]*))?\s*(?:#.*)?' . "\$";
188 my $PATH_PATTERN = '(\w|[/.-])+';
189 # This will pass through anything not of the prescribed form.
190 my $INCLUDE_PATTERN = ('^include\s+'
191 . '((\$\(top_srcdir\)/' . $PATH_PATTERN . ')'
192 . '|(\$\(srcdir\)/' . $PATH_PATTERN . ')'
193 . '|([^/\$]' . $PATH_PATTERN . '))\s*(#.*)?' . "\$");
195 # Match `-d' as a command-line argument in a string.
196 my $DASH_D_PATTERN = "(^|\\s)-d(\\s|\$)";
197 # Directories installed during 'install-exec' phase.
198 my $EXEC_DIR_PATTERN =
199 '^(?:bin|sbin|libexec|sysconf|localstate|lib|pkglib|.*exec.*)' . "\$";
201 # Constants to define the "strictness" level.
202 use constant FOREIGN => 0;
203 use constant GNU => 1;
204 use constant GNITS => 2;
206 # Values for AC_CANONICAL_*
207 use constant AC_CANONICAL_HOST => 1;
208 use constant AC_CANONICAL_SYSTEM => 2;
210 # Values indicating when something should be cleaned.
211 use constant MOSTLY_CLEAN => 0;
212 use constant CLEAN => 1;
213 use constant DIST_CLEAN => 2;
214 use constant MAINTAINER_CLEAN => 3;
217 my @libtool_files = qw(ltmain.sh config.guess config.sub);
218 # ltconfig appears here for compatibility with old versions of libtool.
219 my @libtool_sometimes = qw(ltconfig ltcf-c.sh ltcf-cxx.sh ltcf-gcj.sh);
221 # Commonly found files we look for and automatically include in
224 (qw(ABOUT-GNU ABOUT-NLS AUTHORS BACKLOG COPYING COPYING.DOC COPYING.LIB
225 COPYING.LESSER ChangeLog INSTALL NEWS README THANKS TODO
226 ansi2knr.1 ansi2knr.c compile config.guess config.rpath config.sub
227 configure configure.ac configure.in depcomp elisp-comp
228 install-sh libversion.in mdate-sh missing mkinstalldirs
229 py-compile texinfo.tex ylwrap),
230 @libtool_files, @libtool_sometimes);
232 # Commonly used files we auto-include, but only sometimes.
233 my @common_sometimes =
234 qw(aclocal.m4 acconfig.h config.h.top config.h.bot stamp-vti);
236 # Standard directories from the GNU Coding Standards, and additional
237 # pkg* directories from Automake. Stored in a hash for fast member check.
238 my %standard_prefix =
239 map { $_ => 1 } (qw(bin data exec include info lib libexec lisp
240 localstate man man1 man2 man3 man4 man5 man6
241 man7 man8 man9 oldinclude pkgdatadir
242 pkgincludedir pkglibdir sbin sharedstate
245 # Copyright on generated Makefile.ins.
246 my $gen_copyright = "\
247 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
248 # Free Software Foundation, Inc.
249 # This Makefile.in is free software; the Free Software Foundation
250 # gives unlimited permission to copy and/or distribute it,
251 # with or without modifications, as long as this notice is preserved.
253 # This program is distributed in the hope that it will be useful,
254 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
255 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
256 # PARTICULAR PURPOSE.
259 # These constants are returned by lang_*_rewrite functions.
260 # LANG_SUBDIR means that the resulting object file should be in a
261 # subdir if the source file is. In this case the file name cannot
262 # have `..' components.
263 use constant LANG_IGNORE => 0;
264 use constant LANG_PROCESS => 1;
265 use constant LANG_SUBDIR => 2;
267 # These are used when keeping track of whether an object can be built
268 # by two different paths.
269 use constant COMPILE_LIBTOOL => 1;
270 use constant COMPILE_ORDINARY => 2;
272 # We can't always associate a location to a variable or a rule,
273 # when its defined by Automake. We use INTERNAL in this case.
274 use constant INTERNAL => new Automake::Location;
277 ## ---------------------------------- ##
278 ## Variables related to the options. ##
279 ## ---------------------------------- ##
281 # TRUE if we should always generate Makefile.in.
282 my $force_generation = 1;
284 # Strictness level as set on command line.
285 my $default_strictness = GNU;
287 # Name of strictness level, as set on command line.
288 my $default_strictness_name = 'gnu';
290 # This is TRUE if automatic dependency generation code should be
291 # included in generated Makefile.in.
292 my $cmdline_use_dependencies = 1;
294 # From the Perl manual.
295 my $symlink_exists = (eval 'symlink ("", "");', $@ eq '');
297 # TRUE if missing standard files should be installed.
300 # TRUE if we should copy missing files; otherwise symlink if possible.
301 my $copy_missing = 0;
303 # TRUE if we should always update files that we know about.
304 my $force_missing = 0;
307 ## ---------------------------------------- ##
308 ## Variables filled during files scanning. ##
309 ## ---------------------------------------- ##
311 # Files found by scanning configure.ac for LIBOBJS.
314 # Names used in AC_CONFIG_HEADER call.
315 my @config_headers = ();
316 # Where AC_CONFIG_HEADER appears.
317 my $config_header_location;
319 # Names used in AC_CONFIG_LINKS call.
320 my @config_links = ();
322 # Directory where output files go. Actually, output files are
323 # relative to this directory.
324 my $output_directory;
326 # List of Makefile.am's to process, and their corresponding outputs.
327 my @input_files = ();
328 my %output_files = ();
330 # Complete list of Makefile.am's that exist.
331 my @configure_input_files = ();
333 # List of files in AC_CONFIG_FILES/AC_OUTPUT without Makefile.am's,
335 my @other_input_files = ();
336 # Where the last AC_CONFIG_FILES/AC_OUTPUT appears.
337 my $ac_config_files_location;
339 # List of directories to search for configure-required files. This
340 # can be set by AC_CONFIG_AUX_DIR.
341 my @config_aux_path = qw(. .. ../..);
342 my $config_aux_dir = '';
343 my $config_aux_dir_set_in_configure_in = 0;
345 # Whether AM_GNU_GETTEXT has been seen in configure.ac.
346 my $seen_gettext = 0;
347 # Whether AM_GNU_GETTEXT([external]) is used.
348 my $seen_gettext_external = 0;
349 # Where AM_GNU_GETTEXT appears.
350 my $ac_gettext_location;
352 # TRUE if we've seen AC_CANONICAL_(HOST|SYSTEM).
353 my $seen_canonical = 0;
354 my $canonical_location;
356 # Where AM_MAINTAINER_MODE appears.
359 # Actual version we've seen.
360 my $package_version = '';
362 # Where version is defined.
363 my $package_version_location;
365 # TRUE if we've seen AC_ENABLE_MULTILIB.
366 my $seen_multilib = 0;
368 # TRUE if we've seen AM_PROG_CC_C_O
371 # Where AM_INIT_AUTOMAKE is called;
372 my $seen_init_automake = 0;
374 # TRUE if we've seen AM_AUTOMAKE_VERSION.
375 my $seen_automake_version = 0;
377 # Hash table of discovered configure substitutions. Keys are names,
378 # values are `FILE:LINE' strings which are used by error message
380 my %configure_vars = ();
382 # Files included by @configure.
383 my @configure_deps = ();
385 # Hash table of AM_CONDITIONAL variables seen in configure.
386 my %configure_cond = ();
388 # This maps extensions onto language names.
389 my %extension_map = ();
391 # List of the DIST_COMMON files we discovered while reading
393 my $configure_dist_common = '';
395 # This maps languages names onto objects.
398 # List of targets we must always output.
399 # FIXME: Complete, and remove falsely required targets.
400 my %required_targets =
413 # FIXME: Not required, temporary hacks.
414 # Well, actually they are sort of required: the -recursive
415 # targets will run them anyway...
420 'install-data-am' => 1,
421 'install-exec-am' => 1,
422 'installcheck-am' => 1,
428 # This is set to 1 when Automake needs to be run again.
429 # (For instance, this happens when an auxiliary file such as
430 # depcomp is added after the toplevel Makefile.in -- which
431 # should distribute depcomp -- has been generated.)
432 my $automake_needs_to_reprocess_all_files = 0;
434 # Options set via AM_INIT_AUTOMAKE.
435 my $global_options = '';
437 # Same as $suffix_rules (declared below), but records only the
438 # default rules supplied by the languages Automake supports.
439 my $suffix_rules_default;
441 # If a file name appears as a key in this hash, then it has already
442 # been checked for. This variable is local to the "require file"
444 my %require_file_found = ();
446 # The name of the Makefile currently being processed.
450 ################################################################
452 ## ------------------------------------------ ##
453 ## Variables reset by &initialize_per_input. ##
454 ## ------------------------------------------ ##
456 # Basename and relative dir of the input file.
460 # Same but wrt Makefile.in.
464 # These two variables are used when generating each Makefile.in.
465 # They hold the Makefile.in until it is ready to be printed.
472 # Suffixes found during a run.
475 # This holds the names which are targets. These also appear in
476 # %contents. $targets{TARGET}{COND} is the location of the definition
477 # of TARGET for condition COND. TARGETs should not include
478 # a trailing $(EXEEXT), we record this in %target_name.
479 my %targets; tie %targets, 'Tie::RefHash::Nestable';
481 # $target_source{TARGET}{COND} is the filename where TARGET
482 # were defined for condition COND. Note this must be a
483 # filename, *without* any line number.
484 my %target_source; tie %target_source, 'Tie::RefHash::Nestable';
486 # $target_name{TARGET}{COND} is the real name of TARGET (in condition COND).
487 # The real name is often TARGET or TARGET$(EXEEXT), and TARGET never
489 my %target_name; tie %target_name, 'Tie::RefHash::Nestable';
491 # $target_owner{TARGET}{COND} the owner of TARGET in condition COND.
492 my %target_owner; tie %target_owner, 'Tie::RefHash::Nestable';
493 use constant TARGET_AUTOMAKE => 0; # Target defined by Automake.
494 use constant TARGET_USER => 1; # Target defined in the user's Makefile.am.
496 # This is the conditional stack, updated on if/else/endif, and
497 # used to build Condition objects.
500 # This holds the set of included files.
503 # This holds a list of directories which we must create at `dist'
504 # time. This is used in some strange scenarios involving weird
505 # AC_OUTPUT commands.
508 # List of dependencies for the obvious targets.
513 # Holds the dependencies of targets which dependencies are factored.
514 # Typically, `.PHONY' will appear in plenty of *.am files, but must
515 # be output once. Arguably all pure dependencies could be subject
516 # to this factorization, but it is not unpleasant to have paragraphs
517 # in Makefile: keeping related stuff altogether.
520 # &depend ($CATEGORY, @DEPENDENDEES)
521 # ----------------------------------
522 # The target $CATEGORY depends on @DEPENDENDEES.
525 my ($category, @dependendees) = @_;
526 push (@{$dependencies{$category}}, @dependendees);
530 # Holds the factored actions. Tied to %DEPENDENCIES, i.e., filled
531 # only when keys exists in %DEPENDENCIES.
534 # Keys in this hash table are files to delete. The associated
535 # value tells when this should happen (MOSTLY_CLEAN, DIST_CLEAN, etc.)
538 # Keys in this hash table are object files or other files in
539 # subdirectories which need to be removed. This only holds files
540 # which are created by compilations. The value in the hash indicates
541 # when the file should be removed.
542 my %compile_clean_files;
544 # Keys in this hash table are directories where we expect to build a
545 # libtool object. We use this information to decide what directories
547 my %libtool_clean_directories;
549 # Value of `$(SOURCES)', used by tags.am.
551 # Sources which go in the distribution.
554 # This hash maps object file names onto their corresponding source
555 # file names. This is used to ensure that each object is created
556 # by a single source file.
559 # This hash maps object file names onto an integer value representing
560 # whether this object has been built via ordinary compilation or
561 # libtool compilation (the COMPILE_* constants).
562 my %object_compilation_map;
565 # This keeps track of the directories for which we've already
566 # created dirstamp code.
576 # Options from AUTOMAKE_OPTIONS.
579 # Whether or not dependencies are handled. Can be further changed
581 my $use_dependencies;
583 # This is a list of all targets to run during "make dist".
586 # Keys in this hash are the basenames of files which must depend on
587 # ansi2knr. Values are either the empty string, or the directory in
588 # which the ANSI source file appears; the directory must have a
592 # This maps the source extension for all suffix rule seen to
593 # a \hash whose keys are the possible output extensions.
595 # Note that this is transitively closed by construction:
597 # exists $suffix_rules{$ext1}{$ext2}
598 # && exists $suffix_rules{$ext2}{$ext3}
600 # exists $suffix_rules{$ext1}{$ext3}
602 # So it's easy to check whether '.foo' can be transformed to '.$(OBJEXT)'
603 # by checking whether $suffix_rules{'.foo'}{'.$(OBJEXT)'} exist. This
604 # will work even if transforming '.foo' to '.$(OBJEXT)' involves a chain
605 # of several suffix rules.
607 # The value of `$suffix_rules{$ext1}{$ext2}' is the a pair
608 # `[ $next_sfx, $dist ]' where `$next_sfx' is target suffix
609 # for the next rule to use to reach '$ext2', and `$dist' the
610 # distance to `$ext2'.
613 # This is the name of the redirect `all' target to use.
616 # This keeps track of which extensions we've seen (that we care
620 # This is random scratch space for the language finish functions.
621 # Don't randomly overwrite it; examine other uses of keys first.
622 my %language_scratch;
624 # We keep track of which objects need special (per-executable)
625 # handling on a per-language basis.
626 my %lang_specific_files;
628 # This is set when `handle_dist' has finished. Once this happens,
629 # we should no longer push on dist_common.
632 # Used to store a set of linkers needed to generate the sources currently
633 # under consideration.
636 # True if we need `LINK' defined. This is a hack.
639 # Was get_object_extension run?
640 # FIXME: This is a hack. a better switch should be found.
641 my $get_object_extension_was_run;
643 ################################################################
645 # Pattern that matches all know input extensions (i.e. extensions used
646 # by the languages supported by Automake). Using this pattern
647 # (instead of `\..*$') to match extensions allows Automake to support
648 # dot-less extensions.
649 my $KNOWN_EXTENSIONS_PATTERN = "";
650 my @known_extensions_list = ();
652 # accept_extensions (@EXTS)
653 # -------------------------
654 # Update $KNOWN_EXTENSIONS_PATTERN to recognize the extensions
655 # listed @EXTS. Extensions should contain a dot if needed.
656 sub accept_extensions (@)
658 push @known_extensions_list, @_;
659 $KNOWN_EXTENSIONS_PATTERN =
660 '(?:' . join ('|', map (quotemeta, @known_extensions_list)) . ')';
663 # var_SUFFIXES_trigger ($TYPE, $VALUE)
664 # ------------------------------------
665 # This is called automagically by macro_define() when SUFFIXES
666 # is defined ($TYPE eq '') or appended ($TYPE eq '+').
667 # The work here needs to be performed as a side-effect of the
668 # macro_define() call because SUFFIXES definitions impact
669 # on $KNOWN_EXTENSIONS_PATTERN, and $KNOWN_EXTENSIONS_PATTERN
670 # are used when parsing the input am file.
671 sub var_SUFFIXES_trigger ($$)
673 my ($type, $value) = @_;
674 accept_extensions (split (' ', $value));
676 Automake::Variable::hook ('SUFFIXES', &var_SUFFIXES_trigger);
678 ################################################################
680 ## --------------------------------- ##
681 ## Forward subroutine declarations. ##
682 ## --------------------------------- ##
683 sub register_language (%);
684 sub file_contents_internal ($$$%);
685 sub define_files_variable ($\@$$);
688 # &initialize_per_input ()
689 # ------------------------
690 # (Re)-Initialize per-Makefile.am variables.
691 sub initialize_per_input ()
693 reset_local_duplicates ();
696 $am_relative_dir = '';
703 $output_trailer = '';
709 Automake::Variable::reset ();
740 # Installing/uninstalling.
741 'install-data-am' => [],
742 'install-exec-am' => [],
743 'uninstall-am' => [],
746 'uninstall-man' => [],
748 'install-info' => [],
749 'install-info-am' => [],
750 'uninstall-info' => [],
752 'installcheck-am' => [],
756 'mostlyclean-am' => [],
757 'maintainer-clean-am' => [],
758 'distclean-am' => [],
761 'maintainer-clean' => [],
778 %object_compilation_map = ();
784 $strictness = $default_strictness;
785 $strictness_name = $default_strictness_name;
789 # TRUE if --cygnus seen.
793 $use_dependencies = $cmdline_use_dependencies;
800 # The first time we initialize the variables,
801 # we save the value of $suffix_rules.
802 if (defined $suffix_rules_default)
804 $suffix_rules = $suffix_rules_default;
808 $suffix_rules_default = $suffix_rules;
813 %extension_seen = ();
815 %language_scratch = ();
817 %lang_specific_files = ();
819 $handle_dist_run = 0;
823 $get_object_extension_was_run = 0;
825 %compile_clean_files = ();
827 # We always include `.'. This isn't strictly correct.
828 %libtool_clean_directories = ('.' => 1);
832 ################################################################
834 # Initialize our list of languages that are internally supported.
837 register_language ('name' => 'c',
839 'config_vars' => ['CC'],
842 'flags' => ['CFLAGS', 'CPPFLAGS'],
843 'compiler' => 'COMPILE',
844 'compile' => '$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)',
848 'link' => '$(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
849 'compile_flag' => '-c',
850 'extensions' => ['.c'],
851 '_finish' => \&lang_c_finish);
854 register_language ('name' => 'cxx',
856 'config_vars' => ['CXX'],
857 'linker' => 'CXXLINK',
858 'link' => '$(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
860 'flags' => ['CXXFLAGS', 'CPPFLAGS'],
861 'compile' => '$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)',
862 'compiler' => 'CXXCOMPILE',
863 'compile_flag' => '-c',
864 'output_flag' => '-o',
868 'extensions' => ['.c++', '.cc', '.cpp', '.cxx', '.C']);
871 register_language ('name' => 'objc',
872 'Name' => 'Objective C',
873 'config_vars' => ['OBJC'],
874 'linker' => 'OBJCLINK',,
875 'link' => '$(OBJCLD) $(AM_OBJCFLAGS) $(OBJCFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
877 'flags' => ['OBJCFLAGS', 'CPPFLAGS'],
878 'compile' => '$(OBJC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_OBJCFLAGS) $(OBJCFLAGS)',
879 'compiler' => 'OBJCCOMPILE',
880 'compile_flag' => '-c',
881 'output_flag' => '-o',
885 'extensions' => ['.m']);
888 register_language ('name' => 'header',
890 'extensions' => ['.h', '.H', '.hxx', '.h++', '.hh',
893 'output_extensions' => sub { return () },
895 '_finish' => sub { });
898 register_language ('name' => 'yacc',
900 'config_vars' => ['YACC'],
901 'flags' => ['YFLAGS'],
902 'compile' => '$(YACC) $(YFLAGS) $(AM_YFLAGS)',
903 'compiler' => 'YACCCOMPILE',
904 'extensions' => ['.y'],
905 'output_extensions' => sub { (my $ext = $_[0]) =~ tr/y/c/;
907 'rule_file' => 'yacc',
908 '_finish' => \&lang_yacc_finish,
909 '_target_hook' => \&lang_yacc_target_hook);
910 register_language ('name' => 'yaccxx',
911 'Name' => 'Yacc (C++)',
912 'config_vars' => ['YACC'],
913 'rule_file' => 'yacc',
914 'flags' => ['YFLAGS'],
915 'compiler' => 'YACCCOMPILE',
916 'compile' => '$(YACC) $(YFLAGS) $(AM_YFLAGS)',
917 'extensions' => ['.y++', '.yy', '.yxx', '.ypp'],
918 'output_extensions' => sub { (my $ext = $_[0]) =~ tr/y/c/;
920 '_finish' => \&lang_yacc_finish,
921 '_target_hook' => \&lang_yacc_target_hook);
924 register_language ('name' => 'lex',
926 'config_vars' => ['LEX'],
927 'rule_file' => 'lex',
928 'flags' => ['LFLAGS'],
929 'compile' => '$(LEX) $(LFLAGS) $(AM_LFLAGS)',
930 'compiler' => 'LEXCOMPILE',
931 'extensions' => ['.l'],
932 'output_extensions' => sub { (my $ext = $_[0]) =~ tr/l/c/;
934 '_finish' => \&lang_lex_finish,
935 '_target_hook' => \&lang_lex_target_hook);
936 register_language ('name' => 'lexxx',
937 'Name' => 'Lex (C++)',
938 'config_vars' => ['LEX'],
939 'rule_file' => 'lex',
940 'flags' => ['LFLAGS'],
941 'compile' => '$(LEX) $(LFLAGS) $(AM_LFLAGS)',
942 'compiler' => 'LEXCOMPILE',
943 'extensions' => ['.l++', '.ll', '.lxx', '.lpp'],
944 'output_extensions' => sub { (my $ext = $_[0]) =~ tr/l/c/;
946 '_finish' => \&lang_lex_finish,
947 '_target_hook' => \&lang_lex_target_hook);
950 register_language ('name' => 'asm',
951 'Name' => 'Assembler',
952 'config_vars' => ['CCAS', 'CCASFLAGS'],
954 'flags' => ['CCASFLAGS'],
955 # Users can set AM_ASFLAGS to includes DEFS, INCLUDES,
956 # or anything else required. They can also set AS.
957 'compile' => '$(CCAS) $(AM_CCASFLAGS) $(CCASFLAGS)',
958 'compiler' => 'CCASCOMPILE',
959 'compile_flag' => '-c',
960 'extensions' => ['.s', '.S'],
962 # With assembly we still use the C linker.
963 '_finish' => \&lang_c_finish);
966 register_language ('name' => 'f77',
967 'Name' => 'Fortran 77',
968 'linker' => 'F77LINK',
969 'link' => '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
970 'flags' => ['FFLAGS'],
971 'compile' => '$(F77) $(AM_FFLAGS) $(FFLAGS)',
972 'compiler' => 'F77COMPILE',
973 'compile_flag' => '-c',
974 'output_flag' => '-o',
978 'extensions' => ['.f', '.for', '.f90']);
980 # Preprocessed Fortran 77
982 # The current support for preprocessing Fortran 77 just involves
983 # passing `$(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS)
984 # $(CPPFLAGS)' as additional flags to the Fortran 77 compiler, since
985 # this is how GNU Make does it; see the `GNU Make Manual, Edition 0.51
986 # for `make' Version 3.76 Beta' (specifically, from info file
987 # `(make)Catalogue of Rules').
989 # A better approach would be to write an Autoconf test
990 # (i.e. AC_PROG_FPP) for a Fortran 77 preprocessor, because not all
991 # Fortran 77 compilers know how to do preprocessing. The Autoconf
992 # macro AC_PROG_FPP should test the Fortran 77 compiler first for
993 # preprocessing capabilities, and then fall back on cpp (if cpp were
995 register_language ('name' => 'ppf77',
996 'Name' => 'Preprocessed Fortran 77',
997 'config_vars' => ['F77'],
998 'linker' => 'F77LINK',
999 'link' => '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
1002 'flags' => ['FFLAGS', 'CPPFLAGS'],
1003 'compiler' => 'PPF77COMPILE',
1004 'compile' => '$(F77) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FFLAGS) $(FFLAGS)',
1005 'compile_flag' => '-c',
1006 'output_flag' => '-o',
1008 'extensions' => ['.F']);
1011 register_language ('name' => 'ratfor',
1013 'config_vars' => ['F77'],
1014 'linker' => 'F77LINK',
1015 'link' => '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
1018 'flags' => ['RFLAGS', 'FFLAGS'],
1019 # FIXME also FFLAGS.
1020 'compile' => '$(F77) $(AM_FFLAGS) $(FFLAGS) $(AM_RFLAGS) $(RFLAGS)',
1021 'compiler' => 'RCOMPILE',
1022 'compile_flag' => '-c',
1023 'output_flag' => '-o',
1025 'extensions' => ['.r']);
1028 register_language ('name' => 'java',
1030 'config_vars' => ['GCJ'],
1031 'linker' => 'GCJLINK',
1032 'link' => '$(GCJLD) $(AM_GCJFLAGS) $(GCJFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
1034 'flags' => ['GCJFLAGS'],
1035 'compile' => '$(GCJ) $(AM_GCJFLAGS) $(GCJFLAGS)',
1036 'compiler' => 'GCJCOMPILE',
1037 'compile_flag' => '-c',
1038 'output_flag' => '-o',
1042 'extensions' => ['.java', '.class', '.zip', '.jar']);
1044 ################################################################
1046 # Error reporting functions.
1048 # err_target ($TARGETNAME, $MESSAGE, [%OPTIONS])
1049 # ----------------------------------------------
1050 # Uncategorized errors about targets.
1051 sub err_target ($$;%)
1053 msg_target ('error', @_);
1056 # err_cond_target ($COND, $TARGETNAME, $MESSAGE, [%OPTIONS])
1057 # ----------------------------------------------------------
1058 # Uncategorized errors about conditional targets.
1059 sub err_cond_target ($$$;%)
1061 msg_cond_target ('error', @_);
1064 # err_am ($MESSAGE, [%OPTIONS])
1065 # -----------------------------
1066 # Uncategorized errors about the current Makefile.am.
1069 msg_am ('error', @_);
1072 # err_ac ($MESSAGE, [%OPTIONS])
1073 # -----------------------------
1074 # Uncategorized errors about configure.ac.
1077 msg_ac ('error', @_);
1080 # msg_cond_target ($CHANNEL, $COND, $TARGETNAME, $MESSAGE, [%OPTIONS])
1081 # --------------------------------------------------------------------
1082 # Messages about conditional targets.
1083 sub msg_cond_target ($$$$;%)
1085 my ($channel, $cond, $target, $msg, %opts) = @_;
1086 msg $channel, $targets{$target}{$cond}, $msg, %opts;
1089 # msg_target ($CHANNEL, $TARGETNAME, $MESSAGE, [%OPTIONS])
1090 # --------------------------------------------------------
1091 # Messages about targets.
1092 sub msg_target ($$$;%)
1094 my ($channel, $target, $msg, %opts) = @_;
1095 # Don't know which condition is concerned. Pick any.
1096 my $cond = target_conditions ($target)->one_cond;
1097 msg_cond_target ($channel, $cond, $target, $msg, %opts);
1100 # msg_am ($CHANNEL, $MESSAGE, [%OPTIONS])
1101 # ---------------------------------------
1102 # Messages about about the current Makefile.am.
1105 my ($channel, $msg, %opts) = @_;
1106 msg $channel, "${am_file}.am", $msg, %opts;
1109 # msg_ac ($CHANNEL, $MESSAGE, [%OPTIONS])
1110 # ---------------------------------------
1111 # Messages about about configure.ac.
1114 my ($channel, $msg, %opts) = @_;
1115 msg $channel, $configure_ac, $msg, %opts;
1119 # reject_target ($VAR, $ERROR_MSG)
1120 # --------------------------------
1121 sub reject_target ($$)
1123 my ($target, $msg) = @_;
1124 if (target_defined ($target))
1126 err_target $target, $msg;
1132 ################################################################
1136 # Return a configure-style substitution using the indicated text.
1137 # We do this to avoid having the substitutions directly in automake.in;
1138 # when we do that they are sometimes removed and this causes confusion
1143 return '@' . $text . '@';
1146 ################################################################
1150 # &backname ($REL-DIR)
1151 # --------------------
1152 # If I `cd $REL-DIR', then to come back, I should `cd $BACKPATH'.
1153 # For instance `src/foo' => `../..'.
1154 # Works with non strictly increasing paths, i.e., `src/../lib' => `..'.
1159 foreach (split (/\//, $file))
1161 next if $_ eq '.' || $_ eq '';
1171 return join ('/', @res) || '.';
1174 ################################################################
1177 # process_option_list ($CONFIG, @OPTIONS)
1178 # ---------------------------------------
1179 # Process a list of options. Return 1 on error, 0 otherwise.
1180 # This is a helper for handle_options. CONFIG is true if we're
1181 # handling global options.
1182 sub process_option_list
1184 my ($config, @list) = @_;
1186 # FIXME: We should disallow conditional definitions of AUTOMAKE_OPTIONS.
1187 my $where = ($config ?
1188 $seen_init_automake :
1189 rvar ('AUTOMAKE_OPTIONS')->rdef (TRUE)->location);
1193 $options{$_} = $where;
1194 if ($_ eq 'gnits' || $_ eq 'gnu' || $_ eq 'foreign')
1196 &set_strictness ($_);
1198 elsif (/^(.*\/)?ansi2knr$/)
1200 # An option like "../lib/ansi2knr" is allowed. With no
1201 # path prefix, we assume the required programs are in this
1202 # directory. We save the actual option for later.
1203 $options{'ansi2knr'} = [$_, $where];
1205 elsif ($_ eq 'no-installman' || $_ eq 'no-installinfo'
1206 || $_ eq 'dist-shar' || $_ eq 'dist-zip'
1207 || $_ eq 'dist-tarZ' || $_ eq 'dist-bzip2'
1208 || $_ eq 'no-dist-gzip'
1209 || $_ eq 'dejagnu' || $_ eq 'no-texinfo.tex'
1210 || $_ eq 'readme-alpha' || $_ eq 'check-news'
1211 || $_ eq 'subdir-objects' || $_ eq 'nostdinc'
1212 || $_ eq 'no-exeext' || $_ eq 'no-define'
1213 || $_ eq 'std-options'
1216 # Explicitly recognize these.
1218 elsif ($_ eq 'no-dependencies')
1220 $use_dependencies = 0;
1222 elsif (/^\d+\.\d+(?:\.\d+)?[a-z]?(?:-[A-Za-z0-9]+)?$/)
1224 # Got a version number.
1225 if (Automake::Version::check ($VERSION, $&))
1227 error ($where, "require Automake $_, but have $VERSION",
1228 uniq_scope => US_GLOBAL);
1232 elsif (/^(?:--warnings=|-W)(.*)$/)
1234 foreach my $cat (split (',', $1))
1236 msg 'unsupported', $where, "unknown warning category `$cat'"
1237 if switch_warning $cat;
1242 error ($where, "option `$_' not recognized",
1243 uniq_scope => US_GLOBAL);
1249 # Handle AUTOMAKE_OPTIONS variable. Return 1 on error, 0 otherwise.
1252 # Process global options first so that more specific options can
1254 if (&process_option_list (1, split (' ', $global_options)))
1259 my $var = var ('AUTOMAKE_OPTIONS');
1262 if (&process_option_list (0, $var->value_as_list_recursive (TRUE)))
1268 if ($strictness == GNITS)
1270 $options{'readme-alpha'} = 1;
1271 $options{'std-options'} = 1;
1272 $options{'check-news'} = 1;
1279 # get_object_extension ($OUT)
1280 # ---------------------------
1281 # Return object extension. Just once, put some code into the output.
1282 # OUT is the name of the output file
1283 sub get_object_extension
1287 # Maybe require libtool library object files.
1288 my $extension = '.$(OBJEXT)';
1289 $extension = '.lo' if ($out =~ /\.la$/);
1291 # Check for automatic de-ANSI-fication.
1292 $extension = '$U' . $extension
1293 if defined $options{'ansi2knr'};
1295 $get_object_extension_was_run = 1;
1301 # Call finish function for each language that was used.
1302 sub handle_languages
1304 if ($use_dependencies)
1306 # Include auto-dep code. Don't include it if DEP_FILES would
1308 if (&saw_sources_p (0) && keys %dep_files)
1310 # Set location of depcomp.
1311 &define_variable ('depcomp', "\$(SHELL) $config_aux_dir/depcomp",
1313 &define_variable ('am__depfiles_maybe', 'depfiles', INTERNAL);
1315 require_conf_file ("$am_file.am", FOREIGN, 'depcomp');
1317 my @deplist = sort keys %dep_files;
1319 # We define this as a conditional variable because BSD
1320 # make can't handle backslashes for continuing comments on
1321 # the following line.
1322 define_pretty_variable ('DEP_FILES',
1323 new Automake::Condition ('AMDEP_TRUE'),
1324 INTERNAL, @deplist);
1326 # Generate each `include' individually. Irix 6 make will
1327 # not properly include several files resulting from a
1328 # variable expansion; generating many separate includes
1330 $output_rules .= "\n";
1331 foreach my $iter (@deplist)
1333 $output_rules .= (subst ('AMDEP_TRUE')
1334 . subst ('am__include')
1336 . subst ('am__quote')
1338 . subst ('am__quote')
1342 # Compute the set of directories to remove in distclean-depend.
1343 my @depdirs = uniq (map { dirname ($_) } @deplist);
1344 $output_rules .= &file_contents ('depend',
1345 new Automake::Location,
1346 DEPDIRS => "@depdirs");
1351 &define_variable ('depcomp', '', INTERNAL);
1352 &define_variable ('am__depfiles_maybe', '', INTERNAL);
1357 # Is the c linker needed?
1359 foreach my $ext (sort keys %extension_seen)
1361 next unless $extension_map{$ext};
1363 my $lang = $languages{$extension_map{$ext}};
1365 my $rule_file = $lang->rule_file || 'depend2';
1367 # Get information on $LANG.
1368 my $pfx = $lang->autodep;
1369 my $fpfx = ($pfx eq '') ? 'CC' : $pfx;
1371 my $AMDEP = (($use_dependencies && $lang->autodep ne 'no')
1372 ? 'AMDEP' : 'FALSE');
1373 my $FASTDEP = (($use_dependencies && $lang->autodep ne 'no')
1374 ? ('am__fastdep' . $fpfx) : 'FALSE');
1376 my %transform = ('EXT' => $ext,
1380 'FASTDEP' => $FASTDEP,
1381 '-c' => $lang->compile_flag || '',
1383 => (count_files_for_language ($lang->name) > 1));
1385 # Generate the appropriate rules for this extension.
1386 if (($use_dependencies && $lang->autodep ne 'no')
1387 || defined $lang->compile)
1389 # Some C compilers don't support -c -o. Use it only if really
1391 my $output_flag = $lang->output_flag || '';
1394 && $lang->name eq 'c'
1395 && defined $options{'subdir-objects'});
1397 # Compute a possible derived extension.
1398 # This is not used by depend2.am.
1399 my $der_ext = (&{$lang->output_extensions} ($ext))[0];
1402 file_contents ($rule_file,
1403 new Automake::Location,
1407 'DERIVED-EXT' => $der_ext,
1409 # In this situation we know that the
1410 # object is in this directory, so
1411 # $(DEPDIR) is the correct location for
1413 DEPBASE => '$(DEPDIR)/$*',
1420 COMPILE => '$(' . $lang->compiler . ')',
1421 LTCOMPILE => '$(LT' . $lang->compiler . ')',
1422 -o => $output_flag);
1425 # Now include code for each specially handled object with this
1427 my %seen_files = ();
1428 foreach my $file (@{$lang_specific_files{$lang->name}})
1430 my ($derived, $source, $obj, $myext) = split (' ', $file);
1432 # We might see a given object twice, for instance if it is
1433 # used under different conditions.
1434 next if defined $seen_files{$obj};
1435 $seen_files{$obj} = 1;
1437 prog_error ("found " . $lang->name .
1438 " in handle_languages, but compiler not defined")
1439 unless defined $lang->compile;
1441 my $obj_compile = $lang->compile;
1443 # Rewrite each occurence of `AM_$flag' in the compile
1444 # rule into `${derived}_$flag' if it exists.
1445 for my $flag (@{$lang->flags})
1447 my $val = "${derived}_$flag";
1448 $obj_compile =~ s/\(AM_$flag\)/\($val\)/
1452 my $obj_ltcompile = '$(LIBTOOL) --mode=compile ' . $obj_compile;
1454 # We _need_ `-o' for per object rules.
1455 my $output_flag = $lang->output_flag || '-o';
1457 my $depbase = dirname ($obj);
1461 unless $depbase eq '';
1462 $depbase .= '$(DEPDIR)/' . basename ($obj);
1464 # Support for deansified files in subdirectories is ugly
1465 # enough to deserve an explanation.
1467 # A Note about normal ansi2knr processing first. On
1469 # AUTOMAKE_OPTIONS = ansi2knr
1470 # bin_PROGRAMS = foo
1471 # foo_SOURCES = foo.c
1473 # we generate rules similar to:
1475 # foo: foo$U.o; link ...
1476 # foo$U.o: foo$U.c; compile ...
1477 # foo_.c: foo.c; ansi2knr ...
1479 # this is fairly compact, and will call ansi2knr depending
1480 # on the value of $U (`' or `_').
1482 # It's harder with subdir sources. On
1484 # AUTOMAKE_OPTIONS = ansi2knr
1485 # bin_PROGRAMS = foo
1486 # foo_SOURCES = sub/foo.c
1488 # we have to create foo_.c in the current directory.
1489 # (Unless the user asks 'subdir-objects'.) This is important
1490 # in case the same file (`foo.c') is compiled from other
1491 # directories with different cpp options: foo_.c would
1492 # be preprocessed for only one set of options if it were
1493 # put in the subdirectory.
1495 # Because foo$U.o must be built from either foo_.c or
1496 # sub/foo.c we can't be as concise as in the first example.
1499 # foo: foo$U.o; link ...
1500 # foo_.o: foo_.c; compile ...
1501 # foo.o: sub/foo.c; compile ...
1502 # foo_.c: foo.c; ansi2knr ...
1504 # This is why we'll now transform $rule_file twice
1505 # if we detect this case.
1506 # A first time we output the compile rule with `$U'
1507 # replaced by `_' and the source directory removed,
1508 # and another time we simply remove `$U'.
1510 # Note that at this point $source (as computed by
1511 # &handle_single_transform_list) is `sub/foo$U.c'.
1512 # This can be confusing: it can be used as-is when
1513 # subdir-objects is set, otherwise you have to know
1514 # it really means `foo_.c' or `sub/foo.c'.
1515 my $objdir = dirname ($obj);
1516 my $srcdir = dirname ($source);
1517 if ($lang->ansi && $obj =~ /\$U/)
1519 prog_error "`$obj' contains \$U, but `$source' doesn't."
1520 if $source !~ /\$U/;
1522 (my $source_ = $source) =~ s/\$U/_/g;
1523 # Explicitely clean the _.c files if they are in
1524 # a subdirectory. (In the current directory they get
1525 # erased by a `rm -f *_.c' rule.)
1526 $clean_files{$source_} = MOSTLY_CLEAN
1528 # Output an additional rule if _.c and .c are not in
1529 # the same directory. (_.c is always in $objdir.)
1530 if ($objdir ne $srcdir)
1532 (my $obj_ = $obj) =~ s/\$U/_/g;
1533 (my $depbase_ = $depbase) =~ s/\$U/_/g;
1534 $source_ = basename ($source_);
1537 file_contents ($rule_file,
1538 new Automake::Location,
1542 DEPBASE => $depbase_,
1545 OBJ => "$obj_$myext",
1546 OBJOBJ => "$obj_.obj",
1547 LTOBJ => "$obj_.lo",
1549 COMPILE => $obj_compile,
1550 LTCOMPILE => $obj_ltcompile,
1551 -o => $output_flag);
1553 $depbase =~ s/\$U//g;
1554 $source =~ s/\$U//g;
1559 file_contents ($rule_file,
1560 new Automake::Location,
1564 DEPBASE => $depbase,
1567 # Use $myext and not `.o' here, in case
1568 # we are actually building a new source
1569 # file -- e.g. via yacc.
1570 OBJ => "$obj$myext",
1571 OBJOBJ => "$obj.obj",
1574 COMPILE => $obj_compile,
1575 LTCOMPILE => $obj_ltcompile,
1576 -o => $output_flag);
1579 # The rest of the loop is done once per language.
1580 next if defined $done{$lang};
1583 # Load the language dependent Makefile chunks.
1584 my %lang = map { uc ($_) => 0 } keys %languages;
1585 $lang{uc ($lang->name)} = 1;
1586 $output_rules .= file_contents ('lang-compile',
1587 new Automake::Location,
1590 # If the source to a program consists entirely of code from a
1591 # `pure' language, for instance C++ for Fortran 77, then we
1592 # don't need the C compiler code. However if we run into
1593 # something unusual then we do generate the C code. There are
1594 # probably corner cases here that do not work properly.
1595 # People linking Java code to Fortran code deserve pain.
1596 $needs_c ||= ! $lang->pure;
1598 define_compiler_variable ($lang)
1599 if ($lang->compile);
1601 define_linker_variable ($lang)
1604 require_variables ("$am_file.am", $lang->Name . " source seen",
1605 TRUE, @{$lang->config_vars});
1607 # Call the finisher.
1610 # Flags listed in `->flags' are user variables (per GNU Standards),
1611 # they should not be overriden in the Makefile...
1612 my @dont_override = @{$lang->flags};
1613 # ... and so is LDFLAGS.
1614 push @dont_override, 'LDFLAGS' if $lang->link;
1616 foreach my $flag (@dont_override)
1618 my $var = var $flag;
1621 for my $cond ($var->conditions->conds)
1623 if ($var->rdef ($cond)->owner == VAR_MAKEFILE)
1625 msg_cond_var ('gnu', $cond, $flag,
1626 "`$flag' is a user variable, "
1627 . "you should not override it;\n"
1628 . "use `AM_$flag' instead.");
1635 # If the project is entirely C++ or entirely Fortran 77 (i.e., 1
1636 # suffix rule was learned), don't bother with the C stuff. But if
1637 # anything else creeps in, then use it.
1639 if $need_link || ((scalar keys %$suffix_rules)
1640 - (scalar keys %$suffix_rules_default)) > 1;
1644 &define_compiler_variable ($languages{'c'})
1645 unless defined $done{$languages{'c'}};
1646 define_linker_variable ($languages{'c'});
1650 # Check to make sure a source defined in LIBOBJS is not explicitly
1651 # mentioned. This is a separate function (as opposed to being inlined
1652 # in handle_source_transform) because it isn't always appropriate to
1654 sub check_libobjs_sources
1656 my ($one_file, $unxformed) = @_;
1658 foreach my $prefix ('', 'EXTRA_', 'dist_', 'nodist_',
1659 'dist_EXTRA_', 'nodist_EXTRA_')
1662 my $varname = $prefix . $one_file . '_SOURCES';
1663 my $var = var ($varname);
1666 @files = $var->value_as_list_recursive ('all');
1668 elsif ($prefix eq '')
1670 @files = ($unxformed . '.c');
1677 foreach my $file (@files)
1679 err_var ($prefix . $one_file . '_SOURCES',
1680 "automatically discovered file `$file' should not" .
1681 " be explicitly mentioned")
1682 if defined $libsources{$file};
1689 # handle_single_transform_list ($VAR, $TOPPARENT, $DERIVED, $OBJ, @FILES)
1690 # -----------------------------------------------------------------------
1691 # Does much of the actual work for handle_source_transform.
1693 # $VAR is the name of the variable that the source filenames come from
1694 # $TOPPARENT is the name of the _SOURCES variable which is being processed
1695 # $DERIVED is the name of resulting executable or library
1696 # $OBJ is the object extension (e.g., `$U.lo')
1697 # @FILES is the list of source files to transform
1698 # Result is a list of the names of objects
1699 # %linkers_used will be updated with any linkers needed
1700 sub handle_single_transform_list ($$$$@)
1702 my ($var, $topparent, $derived, $obj, @files) = @_;
1704 my $nonansi_obj = $obj;
1705 $nonansi_obj =~ s/\$U//g;
1707 # Turn sources into objects. We use a while loop like this
1708 # because we might add to @files in the loop.
1709 while (scalar @files > 0)
1713 # Configure substitutions in _SOURCES variables are errors.
1716 my $parent_msg = '';
1717 $parent_msg = "\nand is referred to from `$topparent'"
1718 if $topparent ne $var->name;
1720 "`" . $var->name . "' includes configure substitution `$_'"
1721 . $parent_msg . ";\nconfigure " .
1722 "substitutions are not allowed in _SOURCES variables");
1726 # If the source file is in a subdirectory then the `.o' is put
1727 # into the current directory, unless the subdir-objects option
1730 # Split file name into base and extension.
1731 next if ! /^(?:(.*)\/)?([^\/]*)($KNOWN_EXTENSIONS_PATTERN)$/;
1733 my $directory = $1 || '';
1737 # We must generate a rule for the object if it requires its own flags.
1739 my ($linker, $object);
1741 # This records whether we've seen a derived source file (e.g.
1743 my $derived_source = 0;
1745 # This holds the `aggregate context' of the file we are
1746 # currently examining. If the file is compiled with
1747 # per-object flags, then it will be the name of the object.
1748 # Otherwise it will be `AM'. This is used by the target hook
1749 # language function.
1750 my $aggregate = 'AM';
1752 $extension = &derive_suffix ($extension, $nonansi_obj);
1754 if ($extension_map{$extension} &&
1755 ($lang = $languages{$extension_map{$extension}}))
1757 # Found the language, so see what it says.
1758 &saw_extension ($extension);
1760 # Note: computed subr call. The language rewrite function
1761 # should return one of the LANG_* constants. It could
1762 # also return a list whose first value is such a constant
1763 # and whose second value is a new source extension which
1764 # should be applied. This means this particular language
1765 # generates another source file which we must then process
1767 my $subr = \&{'lang_' . $lang->name . '_rewrite'};
1768 my ($r, $source_extension)
1769 = &$subr ($directory, $base, $extension);
1770 # Skip this entry if we were asked not to process it.
1771 next if $r == LANG_IGNORE;
1773 # Now extract linker and other info.
1774 $linker = $lang->linker;
1777 if (defined $source_extension)
1779 $this_obj_ext = $source_extension;
1780 $derived_source = 1;
1784 $this_obj_ext = $obj;
1788 $this_obj_ext = $nonansi_obj;
1790 $object = $base . $this_obj_ext;
1792 # Do we have per-executable flags for this executable?
1793 my $have_per_exec_flags = 0;
1794 foreach my $flag (@{$lang->flags})
1796 if (set_seen ("${derived}_$flag"))
1798 $have_per_exec_flags = 1;
1803 if ($have_per_exec_flags)
1805 # We have a per-executable flag in effect for this
1806 # object. In this case we rewrite the object's
1807 # name to ensure it is unique. We also require
1808 # the `compile' program to deal with compilers
1809 # where `-c -o' does not work.
1811 # We choose the name `DERIVED_OBJECT' to ensure
1812 # (1) uniqueness, and (2) continuity between
1813 # invocations. However, this will result in a
1814 # name that is too long for losing systems, in
1815 # some situations. So we provide _SHORTNAME to
1818 my $dname = $derived;
1819 my $var = var ($derived . '_SHORTNAME');
1822 # FIXME: should use the same Condition as
1823 # the _SOURCES variable. But this is really
1824 # silly overkill -- nobody should have
1825 # conditional shortnames.
1826 $dname = $var->variable_value;
1828 $object = $dname . '-' . $object;
1830 require_conf_file ("$am_file.am", FOREIGN, 'compile')
1831 if $lang->name eq 'c';
1833 prog_error ($lang->name . " flags defined without compiler")
1834 if ! defined $lang->compile;
1839 # If rewrite said it was ok, put the object into a
1841 if ($r == LANG_SUBDIR && $directory ne '')
1843 $object = $directory . '/' . $object;
1846 # If doing dependency tracking, then we can't print
1847 # the rule. If we have a subdir object, we need to
1848 # generate an explicit rule. Actually, in any case
1849 # where the object is not in `.' we need a special
1850 # rule. The per-object rules in this case are
1851 # generated later, by handle_languages.
1852 if ($renamed || $directory ne '')
1854 my $obj_sans_ext = substr ($object, 0,
1855 - length ($this_obj_ext));
1856 my $full_ansi = $full;
1857 if ($lang->ansi && defined $options{'ansi2knr'})
1859 $full_ansi =~ s/$KNOWN_EXTENSIONS_PATTERN$/\$U$&/;
1860 $obj_sans_ext .= '$U';
1863 my $val = ("$full_ansi $obj_sans_ext "
1864 # Only use $this_obj_ext in the derived
1865 # source case because in the other case we
1866 # *don't* want $(OBJEXT) to appear here.
1867 . ($derived_source ? $this_obj_ext : '.o'));
1869 # If we renamed the object then we want to use the
1870 # per-executable flag name. But if this is simply a
1871 # subdir build then we still want to use the AM_ flag
1875 $val = "$derived $val";
1876 $aggregate = $derived;
1883 # Each item on this list is a string consisting of
1884 # four space-separated values: the derived flag prefix
1885 # (e.g. for `foo_CFLAGS', it is `foo'), the name of the
1886 # source file, the base name of the output file, and
1887 # the extension for the object file.
1888 push (@{$lang_specific_files{$lang->name}}, $val);
1891 elsif ($extension eq $nonansi_obj)
1893 # This is probably the result of a direct suffix rule.
1894 # In this case we just accept the rewrite.
1895 $object = "$base$extension";
1900 # No error message here. Used to have one, but it was
1902 # FIXME: we could potentially do more processing here,
1903 # perhaps treating the new extension as though it were a
1904 # new source extension (as above). This would require
1905 # more restructuring than is appropriate right now.
1909 err_am "object `$object' created by `$full' and `$object_map{$object}'"
1910 if (defined $object_map{$object}
1911 && $object_map{$object} ne $full);
1913 my $comp_val = (($object =~ /\.lo$/)
1914 ? COMPILE_LIBTOOL : COMPILE_ORDINARY);
1915 (my $comp_obj = $object) =~ s/\.lo$/.\$(OBJEXT)/;
1916 if (defined $object_compilation_map{$comp_obj}
1917 && $object_compilation_map{$comp_obj} != 0
1918 # Only see the error once.
1919 && ($object_compilation_map{$comp_obj}
1920 != (COMPILE_LIBTOOL | COMPILE_ORDINARY))
1921 && $object_compilation_map{$comp_obj} != $comp_val)
1923 err_am "object `$object' created both with libtool and without";
1925 $object_compilation_map{$comp_obj} |= $comp_val;
1929 # Let the language do some special magic if required.
1930 $lang->target_hook ($aggregate, $object, $full);
1933 if ($derived_source)
1935 prog_error ($lang->name . " has automatic dependency tracking")
1936 if $lang->autodep ne 'no';
1937 # Make sure this new source file is handled next. That will
1938 # make it appear to be at the right place in the list.
1939 unshift (@files, $object);
1940 # Distribute derived sources unless the source they are
1941 # derived from is not.
1942 &push_dist_common ($object)
1943 unless ($topparent =~ /^(?:nobase_)?nodist_/);
1947 $linkers_used{$linker} = 1;
1949 push (@result, $object);
1951 if (! defined $object_map{$object})
1954 $object_map{$object} = $full;
1956 # If resulting object is in subdir, we need to make
1957 # sure the subdir exists at build time.
1958 if ($object =~ /\//)
1960 # FIXME: check that $DIRECTORY is somewhere in the
1963 # For Java, the way we're handling it right now, a
1964 # `..' component doesn't make sense.
1965 if ($lang->name eq 'java' && $object =~ /(\/|^)\.\.\//)
1967 err_am "`$full' should not contain a `..' component";
1970 # Make sure object is removed by `make mostlyclean'.
1971 $compile_clean_files{$object} = MOSTLY_CLEAN;
1972 # If we have a libtool object then we also must remove
1974 if ($object =~ /\.lo$/)
1976 (my $xobj = $object) =~ s,lo$,\$(OBJEXT),;
1977 $compile_clean_files{$xobj} = MOSTLY_CLEAN;
1979 # Remove any libtool object in this directory.
1980 $libtool_clean_directories{$directory} = 1;
1983 push (@dep_list, require_build_directory ($directory));
1985 # If we're generating dependencies, we also want
1986 # to make sure that the appropriate subdir of the
1987 # .deps directory is created.
1989 require_build_directory ($directory . '/$(DEPDIR)'))
1990 if $use_dependencies;
1993 &pretty_print_rule ($object . ':', "\t", @dep_list)
1994 if scalar @dep_list > 0;
1997 # Transform .o or $o file into .P file (for automatic
1999 if ($lang && $lang->autodep ne 'no')
2001 my $depfile = $object;
2002 $depfile =~ s/\.([^.]*)$/.P$1/;
2003 $depfile =~ s/\$\(OBJEXT\)$/o/;
2004 $dep_files{dirname ($depfile) . '/$(DEPDIR)/'
2005 . basename ($depfile)} = 1;
2014 # define_objects_from_sources ($VAR, $OBJVAR, $NODEFINE, $ONE_FILE,
2015 # $OBJ, $PARENT, $TOPPARENT, $WHERE)
2016 # ---------------------------------------------------------------------
2017 # Define an _OBJECTS variable for a _SOURCES variable (or subvariable)
2020 # $VAR is the name of the _SOURCES variable
2021 # $OBJVAR is the name of the _OBJECTS variable if known (otherwise
2022 # it will be generated and returned).
2023 # $NODEFINE is a boolean: if true, $OBJVAR will not be defined (but
2024 # work done to determine the linker will be).
2025 # $ONE_FILE is the canonical (transformed) name of object to build
2026 # $OBJ is the object extension (i.e. either `.o' or `.lo').
2027 # $TOPPARENT is the _SOURCES variable being processed.
2028 # $WHERE context into which this definition is done
2030 # Result is a pair ($LINKER, $OBJVAR):
2031 # $LINKER is a boolean, true if a linker is needed to deal with the objects
2032 sub define_objects_from_sources ($$$$$$$)
2034 my ($var, $objvar, $nodefine, $one_file, $obj, $topparent, $where) = @_;
2036 my $needlinker = "";
2038 transform_variable_recursively
2039 ($var, $objvar, 'am__objects', $nodefine, $where,
2040 # The transfom code to run on each filename.
2042 my ($subvar, $val, $cond, $full_cond) = @_;
2043 my @trans = &handle_single_transform_list ($subvar, $topparent,
2044 $one_file, $obj, $val);
2045 $needlinker = "true" if @trans;
2053 # Handle SOURCE->OBJECT transform for one program or library.
2055 # canonical (transformed) name of object to build
2056 # actual name of object to build
2057 # object extension (i.e. either `.o' or `$o'.
2058 # Return result is name of linker variable that must be used.
2059 # Empty return means just use `LINK'.
2060 sub handle_source_transform
2062 # one_file is canonical name. unxformed is given name. obj is
2064 my ($one_file, $unxformed, $obj, $where) = @_;
2068 # No point in continuing if _OBJECTS is defined.
2069 return if reject_var ($one_file . '_OBJECTS',
2070 $one_file . '_OBJECTS should not be defined');
2075 foreach my $prefix ('', 'EXTRA_', 'dist_', 'nodist_',
2076 'dist_EXTRA_', 'nodist_EXTRA_')
2078 my $varname = $prefix . $one_file . "_SOURCES";
2079 my $var = var $varname;
2082 # We are going to define _OBJECTS variables using the prefix.
2083 # Then we glom them all together. So we can't use the null
2084 # prefix here as we need it later.
2085 my $xpfx = ($prefix eq '') ? 'am_' : $prefix;
2087 # Keep track of which prefixes we saw.
2088 $used_pfx{$xpfx} = 1
2089 unless $prefix =~ /EXTRA_/;
2091 push @sources, "\$($varname)";
2092 if ($prefix !~ /^nodist_/)
2094 # If the VAR wasn't definined conditionally, we add
2095 # it to DIST_SOURCES as is. Otherwise we create a
2096 # am__VAR_DIST variable which contains all possible values,
2097 # and add this variable to DIST_SOURCES.
2098 my $distvar = $varname;
2099 if ($var->has_conditional_contents)
2101 $distvar = "am__${varname}_DIST";
2103 uniq ($var->value_as_list_recursive ('all'));
2104 define_pretty_variable ($distvar, TRUE, $where, @files);
2106 push @dist_sources, "\$($distvar)"
2110 define_objects_from_sources ($varname,
2111 $xpfx . $one_file . '_OBJECTS',
2112 $prefix =~ /EXTRA_/,
2113 $one_file, $obj, $varname, $where);
2117 $linker ||= &resolve_linker (%linkers_used);
2120 my @keys = sort keys %used_pfx;
2121 if (scalar @keys == 0)
2123 &define_variable ($one_file . "_SOURCES", $unxformed . ".c", $where);
2124 push (@sources, $unxformed . '.c');
2125 push (@dist_sources, $unxformed . '.c');
2129 &handle_single_transform_list ($one_file . '_SOURCES',
2130 $one_file . '_SOURCES',
2133 $linker ||= &resolve_linker (%linkers_used);
2134 define_pretty_variable ($one_file . '_OBJECTS', TRUE, $where, @result);
2138 grep ($_ = '$(' . $_ . $one_file . '_OBJECTS)', @keys);
2139 define_pretty_variable ($one_file . '_OBJECTS', TRUE, $where, @keys);
2142 # If we want to use `LINK' we must make sure it is defined.
2152 # handle_lib_objects ($XNAME, $VAR)
2153 # ---------------------------------
2154 # Special-case ALLOCA and LIBOBJS substitutions in _LDADD or _LIBADD variables.
2155 # Also, generate _DEPENDENCIES variable if appropriate.
2157 # transformed name of object being built, or empty string if no object
2158 # name of _LDADD/_LIBADD-type variable to examine
2159 # Returns 1 if LIBOBJS seen, 0 otherwise.
2160 sub handle_lib_objects
2162 my ($xname, $varname) = @_;
2164 my $var = var ($varname);
2165 prog_error "handle_lib_objects: `$varname' undefined"
2167 prog_error "handle_lib_objects: unexpected variable name `$varname'"
2168 unless $varname =~ /^(.*)(?:LIB|LD)ADD$/;
2169 my $prefix = $1 || 'AM_';
2171 my $seen_libobjs = 0;
2174 transform_variable_recursively
2175 ($varname, $xname . '_DEPENDENCIES', 'am__DEPENDENCIES',
2177 # Transformation function, run on each filename.
2179 my ($subvar, $val, $cond, $full_cond) = @_;
2183 # Skip -lfoo and -Ldir silently; these are explicitly allowed.
2184 if ($val !~ /^-[lL]/ &&
2185 # Skip -dlopen and -dlpreopen; these are explicitly allowed
2186 # for Libtool libraries or programs. (Actually we are a bit
2187 # laxest here since this code also applies to non-libtool
2188 # libraries or programs, for which -dlopen and -dlopreopen
2189 # are pure non-sence. Diagnosting this doesn't seems very
2190 # important: the developer will quickly get complaints from
2192 $val !~ /^-dl(?:pre)?open$/ &&
2193 # Only get this error once.
2197 # FIXME: should display a stack of nested variables
2198 # as context when $var != $subvar.
2199 err_var ($var, "linker flags such as `$val' belong in "
2200 . "`${prefix}LDFLAGS");
2204 elsif ($val !~ /^\@.*\@$/)
2206 # Assume we have a file of some sort, and output it into the
2207 # dependency variable. Autoconf substitutions are not output;
2208 # rarely is a new dependency substituted into e.g. foo_LDADD
2209 # -- but bad things (e.g. -lX11) are routinely substituted.
2210 # Note that LIBOBJS and ALLOCA are exceptions to this rule,
2211 # and handled specially below.
2214 elsif ($val =~ /^\@(LT)?LIBOBJS\@$/)
2216 handle_LIBOBJS ($subvar, $full_cond, $1);
2220 elsif ($val =~ /^\@(LT)?ALLOCA\@$/)
2222 handle_ALLOCA ($subvar, $full_cond, $1);
2231 return $seen_libobjs;
2234 sub handle_LIBOBJS ($$$)
2236 my ($var, $cond, $lt) = @_;
2238 my $myobjext = ($1 ? 'l' : '') . 'o';
2240 if (! keys %libsources)
2242 require_variables_for_variable ($var,
2243 "\@${lt}LIBOBJS\@ used",
2247 foreach my $iter (keys %libsources)
2249 if ($iter =~ /\.[cly]$/)
2251 &saw_extension ($&);
2252 &saw_extension ('.c');
2255 if ($iter =~ /\.h$/)
2257 require_file_with_macro ($cond, $var, FOREIGN, $iter);
2259 elsif ($iter ne 'alloca.c')
2261 my $rewrite = $iter;
2262 $rewrite =~ s/\.c$/.P$myobjext/;
2263 $dep_files{'$(DEPDIR)/' . $rewrite} = 1;
2264 $rewrite = "^" . quotemeta ($iter) . "\$";
2265 # Only require the file if it is not a built source.
2266 my $bs = var ('BUILT_SOURCES');
2268 || ! grep (/$rewrite/, $bs->value_as_list_recursive ('all')))
2270 require_file_with_macro ($cond, $var, FOREIGN, $iter);
2276 sub handle_ALLOCA ($$$)
2278 my ($var, $cond, $lt) = @_;
2279 my $myobjext = ($lt ? 'l' : '') . 'o';
2281 require_variables_for_variable ($var, "\@${lt}ALLOCA\@ used",
2283 $dep_files{'$(DEPDIR)/alloca.P' . $myobjext} = 1;
2284 require_file_with_macro ($cond, $var, FOREIGN, 'alloca.c');
2285 &saw_extension ('c');
2288 # Canonicalize the input parameter
2292 $string =~ tr/A-Za-z0-9_\@/_/c;
2296 # Canonicalize a name, and check to make sure the non-canonical name
2297 # is never used. Returns canonical name. Arguments are name and a
2298 # list of suffixes to check for.
2299 sub check_canonical_spelling
2301 my ($name, @suffixes) = @_;
2303 my $xname = &canonicalize ($name);
2304 if ($xname ne $name)
2306 foreach my $xt (@suffixes)
2308 reject_var ("$name$xt", "use `$xname$xt', not `$name$xt'");
2318 # Set up the compile suite.
2319 sub handle_compile ()
2322 unless $get_object_extension_was_run;
2325 my $default_includes = '';
2326 if (! defined $options{'nostdinc'})
2328 $default_includes = ' -I. -I$(srcdir)';
2330 my $var = var 'CONFIG_HEADER';
2333 foreach my $hdr (split (' ', $var->variable_value))
2335 $default_includes .= ' -I' . dirname ($hdr);
2340 my (@mostly_rms, @dist_rms);
2341 foreach my $item (sort keys %compile_clean_files)
2343 if ($compile_clean_files{$item} == MOSTLY_CLEAN)
2345 push (@mostly_rms, "\t-rm -f $item");
2347 elsif ($compile_clean_files{$item} == DIST_CLEAN)
2349 push (@dist_rms, "\t-rm -f $item");
2353 prog_error 'invalid entry in %compile_clean_files';
2357 my ($coms, $vars, $rules) =
2358 &file_contents_internal (1, "$libdir/am/compile.am",
2359 new Automake::Location,
2360 ('DEFAULT_INCLUDES' => $default_includes,
2361 'MOSTLYRMS' => join ("\n", @mostly_rms),
2362 'DISTRMS' => join ("\n", @dist_rms)));
2363 $output_vars .= $vars;
2364 $output_rules .= "$coms$rules";
2366 # Check for automatic de-ANSI-fication.
2367 if (defined $options{'ansi2knr'})
2369 my ($ansi2knr_filename, $ansi2knr_where) = @{$options{'ansi2knr'}};
2370 my $ansi2knr_dir = '';
2372 require_variables ($ansi2knr_where, "option `ansi2knr' is used",
2373 TRUE, "ANSI2KNR", "U");
2375 # topdir is where ansi2knr should be.
2376 if ($ansi2knr_filename eq 'ansi2knr')
2378 # Only require ansi2knr files if they should appear in
2380 require_file ($ansi2knr_where, FOREIGN,
2381 'ansi2knr.c', 'ansi2knr.1');
2383 # ansi2knr needs to be built before subdirs, so unshift it.
2384 unshift (@all, '$(ANSI2KNR)');
2388 $ansi2knr_dir = dirname ($ansi2knr_filename);
2391 $output_rules .= &file_contents ('ansi2knr',
2392 new Automake::Location,
2393 'ANSI2KNR-DIR' => $ansi2knr_dir);
2400 # Handle libtool rules.
2403 return unless var ('LIBTOOL');
2405 # Libtool requires some files, but only at top level.
2406 require_conf_file_with_macro (TRUE, 'LIBTOOL', FOREIGN, @libtool_files)
2407 if $relative_dir eq '.';
2410 foreach my $item (sort keys %libtool_clean_directories)
2412 my $dir = ($item eq '.') ? '' : "$item/";
2413 # .libs is for Unix, _libs for DOS.
2414 push (@libtool_rms, "\t-rm -rf ${dir}.libs ${dir}_libs");
2417 # Output the libtool compilation rules.
2418 $output_rules .= &file_contents ('libtool',
2419 new Automake::Location,
2420 LTRMS => join ("\n", @libtool_rms));
2423 # handle_programs ()
2424 # ------------------
2425 # Handle C programs.
2428 my @proglist = &am_install_var ('progs', 'PROGRAMS',
2429 'bin', 'sbin', 'libexec', 'pkglib',
2431 return if ! @proglist;
2433 my $seen_global_libobjs =
2434 var ('LDADD') && &handle_lib_objects ('', 'LDADD');
2436 foreach my $pair (@proglist)
2438 my ($where, $one_file) = @$pair;
2440 my $seen_libobjs = 0;
2441 my $obj = &get_object_extension ($one_file);
2443 # Strip any $(EXEEXT) suffix the user might have added, or this
2444 # will confuse &handle_source_transform and &check_canonical_spelling.
2445 # We'll add $(EXEEXT) back later anyway.
2446 $one_file =~ s/\$\(EXEEXT\)$//;
2448 # Canonicalize names and check for misspellings.
2449 my $xname = &check_canonical_spelling ($one_file, '_LDADD', '_LDFLAGS',
2450 '_SOURCES', '_OBJECTS',
2453 $where->push_context ("while processing program `$one_file'");
2454 $where->set (INTERNAL->get);
2456 my $linker = &handle_source_transform ($xname, $one_file, $obj, $where);
2458 if (var ($xname . "_LDADD"))
2460 $seen_libobjs = &handle_lib_objects ($xname, $xname . '_LDADD');
2464 # User didn't define prog_LDADD override. So do it.
2465 &define_variable ($xname . '_LDADD', '$(LDADD)', $where);
2467 # This does a bit too much work. But we need it to
2468 # generate _DEPENDENCIES when appropriate.
2471 $seen_libobjs = &handle_lib_objects ($xname, 'LDADD');
2475 reject_var ($xname . '_LIBADD',
2476 "use `${xname}_LDADD', not `${xname}_LIBADD'");
2478 set_seen ($xname . '_DEPENDENCIES');
2479 set_seen ($xname . '_LDFLAGS');
2481 # Determine program to use for link.
2483 if (var ($xname . '_LINK'))
2485 $xlink = $xname . '_LINK';
2489 $xlink = $linker ? $linker : 'LINK';
2492 # If the resulting program lies into a subdirectory,
2493 # make sure this directory will exist.
2494 my $dirstamp = require_build_directory_maybe ($one_file);
2496 $output_rules .= &file_contents ('program',
2498 PROGRAM => $one_file,
2501 DIRSTAMP => $dirstamp,
2502 EXEEXT => '$(EXEEXT)');
2504 if ($seen_libobjs || $seen_global_libobjs)
2506 if (var ($xname . '_LDADD'))
2508 &check_libobjs_sources ($xname, $xname . '_LDADD');
2510 elsif (var ('LDADD'))
2512 &check_libobjs_sources ($xname, 'LDADD');
2519 # handle_libraries ()
2520 # -------------------
2522 sub handle_libraries
2524 my @liblist = &am_install_var ('libs', 'LIBRARIES',
2525 'lib', 'pkglib', 'noinst', 'check');
2526 return if ! @liblist;
2528 my @prefix = am_primary_prefixes ('LIBRARIES', 0, 'lib', 'pkglib',
2531 require_variables_for_variable ($prefix[0] . '_LIBRARIES',
2532 'library used', 'RANLIB')
2535 foreach my $pair (@liblist)
2537 my ($where, $onelib) = @$pair;
2539 my $seen_libobjs = 0;
2540 # Check that the library fits the standard naming convention.
2541 if (basename ($onelib) !~ /^lib.*\.a/)
2543 error $where, "`$onelib' is not a standard library name";
2546 $where->push_context ("while processing library `$onelib'");
2547 $where->set (INTERNAL->get);
2549 my $obj = &get_object_extension ($onelib);
2551 # Canonicalize names and check for misspellings.
2552 my $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_SOURCES',
2553 '_OBJECTS', '_DEPENDENCIES',
2556 if (! var ($xlib . '_AR'))
2558 &define_variable ($xlib . '_AR', '$(AR) $(ARFLAGS)', $where);
2561 # Generate support for conditional object inclusion in
2563 if (var ($xlib . '_LIBADD'))
2565 if (&handle_lib_objects ($xlib, $xlib . '_LIBADD'))
2572 &define_variable ($xlib . "_LIBADD", '', $where);
2575 reject_var ($xlib . '_LDADD',
2576 "use `${xlib}_LIBADD', not `${xlib}_LDADD'");
2578 # Make sure we at look at this.
2579 set_seen ($xlib . '_DEPENDENCIES');
2581 &handle_source_transform ($xlib, $onelib, $obj, $where);
2583 # If the resulting library lies into a subdirectory,
2584 # make sure this directory will exist.
2585 my $dirstamp = require_build_directory_maybe ($onelib);
2587 $output_rules .= &file_contents ('library',
2591 DIRSTAMP => $dirstamp);
2595 if (var ($xlib . '_LIBADD'))
2597 &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
2604 # handle_ltlibraries ()
2605 # ---------------------
2606 # Handle shared libraries.
2607 sub handle_ltlibraries
2609 my @liblist = &am_install_var ('ltlib', 'LTLIBRARIES',
2610 'noinst', 'lib', 'pkglib', 'check');
2611 return if ! @liblist;
2614 my @prefix = am_primary_prefixes ('LTLIBRARIES', 0, 'lib', 'pkglib',
2617 require_variables_for_variable ($prefix[0] . '_LTLIBRARIES',
2618 'Libtool library used', 'LIBTOOL')
2621 my %liblocations = (); # Location (in Makefile.am) of each library.
2623 foreach my $key (@prefix)
2625 # Get the installation directory of each library.
2626 (my $dir = $key) =~ s/^nobase_//;
2627 my $var = rvar ($key . '_LTLIBRARIES');
2628 for my $pair ($var->loc_and_value_as_list_recursive ('all'))
2630 my ($where, $lib) = @$pair;
2631 # We reject libraries which are installed in several places,
2632 # because we don't handle this in the rules (think `-rpath').
2634 # However, we allow the same library to be listed many times
2635 # for the same directory. This is for users who need setups
2638 # lib_LTLIBRARIES = libfoo.la
2641 # lib_LTLIBRARIES = libfoo.la
2644 # Actually this will also allow
2645 # lib_LTLIBRARIES = libfoo.la libfoo.la
2646 # Diagnosing this case doesn't seem worth the plain (we'd
2647 # have to fill $instdirs on a per-condition basis, check
2648 # implied conditions, etc.)
2649 if (defined $instdirs{$lib} && $instdirs{$lib} ne $dir)
2651 error ($where, "`$lib' is already going to be installed in "
2652 . "`$instdirs{$lib}'", partial => 1);
2653 error ($liblocations{$lib}, "`$lib' previously declared here");
2657 $instdirs{$lib} = $dir;
2658 $liblocations{$lib} = $where->clone;
2663 foreach my $pair (@liblist)
2665 my ($where, $onelib) = @$pair;
2667 my $seen_libobjs = 0;
2668 my $obj = &get_object_extension ($onelib);
2670 # Canonicalize names and check for misspellings.
2671 my $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_LDFLAGS',
2672 '_SOURCES', '_OBJECTS',
2675 # Check that the library fits the standard naming convention.
2676 my $libname_rx = "^lib.*\.la";
2677 my $ldvar = var ("${xlib}_LDFLAGS") || var ('LDFLAGS');
2678 if ($ldvar && grep (/-module/, $ldvar->value_as_list_recursive ('all')))
2680 # Relax name checking for libtool modules.
2681 $libname_rx = "\.la";
2683 if (basename ($onelib) !~ /$libname_rx$/)
2685 msg ('error-gnu/warn', $where,
2686 "`$onelib' is not a standard libtool library name");
2689 $where->push_context ("while processing Libtool library `$onelib'");
2690 $where->set (INTERNAL->get);
2692 # Make sure we at look at these.
2693 set_seen ($xlib . '_LDFLAGS');
2694 set_seen ($xlib . '_DEPENDENCIES');
2696 # Generate support for conditional object inclusion in
2698 if (var ($xlib . '_LIBADD'))
2700 if (&handle_lib_objects ($xlib, $xlib . '_LIBADD'))
2707 &define_variable ($xlib . "_LIBADD", '', $where);
2710 reject_var ("${xlib}_LDADD",
2711 "use `${xlib}_LIBADD', not `${xlib}_LDADD'");
2714 my $linker = &handle_source_transform ($xlib, $onelib, $obj, $where);
2716 # Determine program to use for link.
2718 if (var ($xlib . '_LINK'))
2720 $xlink = $xlib . '_LINK';
2724 $xlink = $linker ? $linker : 'LINK';
2728 if ($instdirs{$onelib} eq 'EXTRA'
2729 || $instdirs{$onelib} eq 'noinst'
2730 || $instdirs{$onelib} eq 'check')
2732 # It's an EXTRA_ library, so we can't specify -rpath,
2733 # because we don't know where the library will end up.
2734 # The user probably knows, but generally speaking automake
2735 # doesn't -- and in fact configure could decide
2736 # dynamically between two different locations.
2741 $rpath = ('-rpath $(' . $instdirs{$onelib} . 'dir)');
2744 # If the resulting library lies into a subdirectory,
2745 # make sure this directory will exist.
2746 my $dirstamp = require_build_directory_maybe ($onelib);
2748 # Remember to cleanup .libs/ in this directory.
2749 my $dirname = dirname $onelib;
2750 $libtool_clean_directories{$dirname} = 1;
2752 $output_rules .= &file_contents ('ltlibrary',
2754 LTLIBRARY => $onelib,
2755 XLTLIBRARY => $xlib,
2758 DIRSTAMP => $dirstamp);
2761 if (var ($xlib . '_LIBADD'))
2763 &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
2769 # See if any _SOURCES variable were misspelled.
2772 # It is ok if the user sets this particular variable.
2773 set_seen 'AM_LDFLAGS';
2775 foreach my $varname (variables)
2777 # A configure variable is always legitimate.
2778 next if exists $configure_vars{$varname};
2781 foreach my $primary ('_SOURCES', '_LIBADD', '_LDADD', '_LDFLAGS',
2784 if ($varname =~ /$primary$/)
2792 my $var = rvar $varname;
2794 for my $cond ($var->conditions->conds)
2796 msg_var 'syntax', $var, "unused variable: `$varname'"
2797 unless $var->rdef ($cond)->seen;
2806 # NOTE we no longer automatically clean SCRIPTS, because it is
2807 # useful to sometimes distribute scripts verbatim. This happens
2808 # e.g. in Automake itself.
2809 &am_install_var ('-candist', 'scripts', 'SCRIPTS',
2810 'bin', 'sbin', 'libexec', 'pkgdata',
2817 ## ------------------------ ##
2818 ## Handling Texinfo files. ##
2819 ## ------------------------ ##
2821 # ($OUTFILE, $VFILE, @CLEAN_FILES)
2822 # &scan_texinfo_file ($FILENAME)
2823 # ------------------------------
2824 # $OUTFILE - name of the info file produced by $FILENAME.
2825 # $VFILE - name of the version.texi file used (undef if none).
2826 # @CLEAN_FILES - list of byproducts (indexes etc.)
2827 sub scan_texinfo_file ($)
2829 my ($filename) = @_;
2831 # Some of the following extensions are always created, no matter
2832 # whether indexes are used or not. Other (like cps, fns, ... pgs)
2833 # are only created when they are used. We used to scan $FILENAME
2834 # for their use, but that is not enough: they could be used in
2835 # included files. We can't scan included files because we don't
2836 # know the include path. Therefore we always erase these files, no
2837 # matter whether they are used or not.
2839 # (tmp is only created if an @macro is used and a certain e-TeX
2840 # feature is not available.)
2841 my %clean_suffixes =
2842 map { $_ => 1 } (qw(aux log toc tmp
2848 pg pgs)); # grep 'new.*index' texinfo.tex
2850 my $texi = new Automake::XFile "< $filename";
2851 verb "reading $filename";
2853 my ($outfile, $vfile);
2854 while ($_ = $texi->getline)
2856 if (/^\@setfilename +(\S+)/)
2858 # Honor only the first @setfilename. (It's possible to have
2859 # more occurences later if the manual shows examples of how
2860 # to use @setfilename...)
2864 if ($outfile =~ /\.(.+)$/ && $1 ne 'info')
2866 error ("$filename:$.",
2867 "output `$outfile' has unrecognized extension");
2871 # A "version.texi" file is actually any file whose name matches
2873 elsif (/^\@include\s+(vers[^.]*\.texi)\s*$/)
2878 # Try to find new or unused indexes.
2880 # Creating a new category of index.
2881 elsif (/^\@def(code)?index (\w+)/)
2883 $clean_suffixes{$2} = 1;
2884 $clean_suffixes{"$2s"} = 1;
2887 # Merging an index into an another.
2888 elsif (/^\@syn(code)?index (\w+) (\w+)/)
2890 delete $clean_suffixes{"$2s"};
2891 $clean_suffixes{"$3s"} = 1;
2898 err_am "`$filename' missing \@setfilename";
2902 my $infobase = basename ($filename);
2903 $infobase =~ s/\.te?xi(nfo)?$//;
2904 return ($outfile, $vfile,
2905 map { "$infobase.$_" } (sort keys %clean_suffixes));
2909 # ($DIRSTAMP, @CLEAN_FILES)
2910 # output_texinfo_build_rules ($SOURCE, $DEST, @DEPENDENCIES)
2911 # ----------------------------------------------------------
2912 # SOURCE - the source Texinfo file
2913 # DEST - the destination Info file
2914 # DEPENDENCIES - known dependencies
2915 sub output_texinfo_build_rules ($$@)
2917 my ($source, $dest, @deps) = @_;
2919 # Split `a.texi' into `a' and `.texi'.
2920 my ($spfx, $ssfx) = ($source =~ /^(.*?)(\.[^.]*)?$/);
2921 my ($dpfx, $dsfx) = ($dest =~ /^(.*?)(\.[^.]*)?$/);
2926 # We can output two kinds of rules: the "generic" rules use Make
2927 # suffix rules and are appropritate when $source and $dest lie in
2928 # the current directory; the "specifix" rules is needed in the other
2931 # The former are output only once (this is not really apparent here,
2932 # but just remember that some logic deeper in Automake will not
2933 # output the same rule twice); while the later need to be output for
2934 # each Texinfo source.
2937 my $sdir = dirname $source;
2938 if ($sdir eq '.' && dirname ($dest) eq '.')
2941 $makeinfoflags = '-I $(srcdir)';
2946 $makeinfoflags = "-I $sdir -I \$(srcdir)/$sdir";
2949 # We cannot use a suffix rule to build info files with an empty
2950 # extension. Otherwise we would output a single suffix inference
2951 # rule, with separate dependencies, as in
2955 # foo.info: foo.texi
2957 # which confuse Solaris make. (See the Autoconf manual for
2958 # details.) Therefore we use a specific rule in this case. This
2959 # applies to info files only (dvi and pdf files always have an
2961 my $generic_info = ($generic && $dsfx) ? 1 : 0;
2963 # If the resulting file lie into a subdirectory,
2964 # make sure this directory will exist.
2965 my $dirstamp = require_build_directory_maybe ($dest);
2967 $output_rules .= file_contents ('texibuild',
2968 new Automake::Location,
2969 GENERIC => $generic,
2970 GENERIC_INFO => $generic_info,
2971 SOURCE_SUFFIX => $ssfx,
2972 SOURCE => ($generic ? '$<' : $source),
2973 SOURCE_INFO => ($generic_info ?
2975 SOURCE_REAL => $source,
2976 DEST_PREFIX => $dpfx,
2977 DEST_SUFFIX => $dsfx,
2978 MAKEINFOFLAGS => $makeinfoflags,
2980 DIRSTAMP => $dirstamp);
2981 return ($dirstamp, "$dpfx.dvi", "$dpfx.pdf", "$dpfx.ps", "$dpfx.html");
2986 # handle_texinfo_helper ($info_texinfos)
2987 # --------------------------------------
2988 # Handle all Texinfo source; helper for handle_texinfo.
2989 sub handle_texinfo_helper ($)
2991 my ($info_texinfos) = @_;
2992 my (@infobase, @info_deps_list, @texi_deps);
2997 foreach my $texi ($info_texinfos->value_as_list_recursive ('all'))
2999 my $infobase = $texi;
3000 $infobase =~ s/\.(txi|texinfo|texi)$//;
3002 if ($infobase eq $texi)
3004 # FIXME: report line number.
3005 err_am "texinfo file `$texi' has unrecognized extension";
3009 push @infobase, $infobase;
3011 # If 'version.texi' is referenced by input file, then include
3012 # automatic versioning capability.
3013 my ($out_file, $vtexi, @clean_files) =
3014 scan_texinfo_file ("$relative_dir/$texi")
3016 push (@texi_cleans, @clean_files);
3018 # If the Texinfo source is in a subdirectory, create the
3019 # resulting info in this subdirectory. If it is in the current
3020 # directory, try hard to not prefix "./" because it breaks the
3022 my $outdir = dirname ($texi) . '/';
3023 $outdir = "" if $outdir eq './';
3024 $out_file = $outdir . $out_file;
3026 # If user specified file_TEXINFOS, then use that as explicit
3029 push (@texi_deps, "$outdir$vtexi") if $vtexi;
3031 my $canonical = canonicalize ($infobase);
3032 if (var ($canonical . "_TEXINFOS"))
3034 push (@texi_deps, '$(' . $canonical . '_TEXINFOS)');
3035 push_dist_common ('$(' . $canonical . '_TEXINFOS)');
3038 my ($dirstamp, @cfiles) =
3039 output_texinfo_build_rules ($texi, $out_file, @texi_deps);
3040 push (@texi_cleans, @cfiles);
3042 push (@info_deps_list, $out_file);
3044 # If a vers*.texi file is needed, emit the rule.
3047 err_am ("`$vtexi', included in `$texi', "
3048 . "also included in `$versions{$vtexi}'")
3049 if defined $versions{$vtexi};
3050 $versions{$vtexi} = $texi;
3052 # We number the stamp-vti files. This is doable since the
3053 # actual names don't matter much. We only number starting
3054 # with the second one, so that the common case looks nice.
3055 my $vti = ($done ? $done : 'vti');
3058 # This is ugly, but it is our historical practice.
3059 if ($config_aux_dir_set_in_configure_in)
3061 require_conf_file_with_macro (TRUE, 'info_TEXINFOS', FOREIGN,
3066 require_file_with_macro (TRUE, 'info_TEXINFOS',
3067 FOREIGN, 'mdate-sh');
3071 if ($config_aux_dir_set_in_configure_in)
3073 $conf_dir = $config_aux_dir;
3074 $conf_dir .= '/' unless $conf_dir =~ /\/$/;
3078 $conf_dir = '$(srcdir)/';
3080 $output_rules .= file_contents ('texi-vers',
3081 new Automake::Location,
3084 STAMPVTI => "${outdir}stamp-$vti",
3085 VTEXI => "$outdir$vtexi",
3087 DIRSTAMP => $dirstamp);
3091 # Handle location of texinfo.tex.
3092 my $need_texi_file = 0;
3094 if ($options{'cygnus'})
3096 $texinfodir = '$(top_srcdir)/../texinfo';
3097 define_variable ('TEXINFO_TEX', "$texinfodir/texinfo.tex", INTERNAL);
3099 elsif ($config_aux_dir_set_in_configure_in)
3101 $texinfodir = $config_aux_dir;
3102 define_variable ('TEXINFO_TEX', "$texinfodir/texinfo.tex", INTERNAL);
3103 $need_texi_file = 2; # so that we require_conf_file later
3105 elsif (var ('TEXINFO_TEX'))
3107 # The user defined TEXINFO_TEX so assume he knows what he is
3109 $texinfodir = ('$(srcdir)/'
3110 . dirname (variable_value ('TEXINFO_TEX')));
3114 $texinfodir = '$(srcdir)';
3115 $need_texi_file = 1;
3117 define_variable ('am__TEXINFO_TEX_DIR', $texinfodir, INTERNAL);
3119 push (@dist_targets, 'dist-info');
3121 if (! defined $options{'no-installinfo'})
3123 # Make sure documentation is made and installed first. Use
3124 # $(INFO_DEPS), not 'info', because otherwise recursive makes
3125 # get run twice during "make all".
3126 unshift (@all, '$(INFO_DEPS)');
3129 define_variable ("INFO_DEPS", "@info_deps_list", INTERNAL);
3130 define_files_variable ("DVIS", @infobase, 'dvi', INTERNAL);
3131 define_files_variable ("PDFS", @infobase, 'pdf', INTERNAL);
3132 define_files_variable ("PSS", @infobase, 'ps', INTERNAL);
3133 define_files_variable ("HTMLS", @infobase, 'html', INTERNAL);
3135 # This next isn't strictly needed now -- the places that look here
3136 # could easily be changed to look in info_TEXINFOS. But this is
3137 # probably better, in case noinst_TEXINFOS is ever supported.
3138 define_variable ("TEXINFOS", variable_value ('info_TEXINFOS'), INTERNAL);
3140 # Do some error checking. Note that this file is not required
3141 # when in Cygnus mode; instead we defined TEXINFO_TEX explicitly
3143 if ($need_texi_file && ! defined $options{'no-texinfo.tex'})
3145 if ($need_texi_file > 1)
3147 require_conf_file_with_macro (TRUE, 'info_TEXINFOS', FOREIGN,
3152 require_file_with_macro (TRUE, 'info_TEXINFOS', FOREIGN,
3157 return makefile_wrap ("", "\t ", @texi_cleans);
3163 # Handle all Texinfo source.
3164 sub handle_texinfo ()
3166 reject_var 'TEXINFOS', "`TEXINFOS' is an anachronism; use `info_TEXINFOS'";
3167 # FIXME: I think this is an obsolete future feature name.
3168 reject_var 'html_TEXINFOS', "HTML generation not yet supported";
3170 my $info_texinfos = var ('info_TEXINFOS');
3174 $texiclean = handle_texinfo_helper ($info_texinfos);
3176 $output_rules .= file_contents ('texinfos',
3177 new Automake::Location,
3178 TEXICLEAN => $texiclean,
3179 'LOCAL-TEXIS' => !!$info_texinfos);
3183 # Handle any man pages.
3184 sub handle_man_pages
3186 reject_var 'MANS', "`MANS' is an anachronism; use `man_MANS'";
3188 # Find all the sections in use. We do this by first looking for
3189 # "standard" sections, and then looking for any additional
3190 # sections used in man_MANS.
3191 my (%sections, %vlist);
3192 # We handle nodist_ for uniformity. man pages aren't distributed
3193 # by default so it isn't actually very important.
3194 foreach my $pfx ('', 'dist_', 'nodist_')
3196 # Add more sections as needed.
3197 foreach my $section ('0'..'9', 'n', 'l')
3199 my $varname = $pfx . 'man' . $section . '_MANS';
3202 $sections{$section} = 1;
3203 $varname = '$(' . $varname . ')';
3204 $vlist{$varname} = 1;
3206 &push_dist_common ($varname)
3211 my $varname = $pfx . 'man_MANS';
3212 my $var = var ($varname);
3215 foreach ($var->value_as_list_recursive ('all'))
3217 # A page like `foo.1c' goes into man1dir.
3218 if (/\.([0-9a-z])([a-z]*)$/)
3224 $varname = '$(' . $varname . ')';
3225 $vlist{$varname} = 1;
3226 &push_dist_common ($varname)
3231 return unless %sections;
3233 # Now for each section, generate an install and unintall rule.
3234 # Sort sections so output is deterministic.
3235 foreach my $section (sort keys %sections)
3237 $output_rules .= &file_contents ('mans',
3238 new Automake::Location,
3239 SECTION => $section);
3242 my @mans = sort keys %vlist;
3243 $output_vars .= file_contents ('mans-vars',
3244 new Automake::Location,
3247 if (! defined $options{'no-installman'})
3249 push (@all, '$(MANS)');
3253 # Handle DATA variables.
3256 &am_install_var ('-noextra', '-candist', 'data', 'DATA',
3257 'data', 'sysconf', 'sharedstate', 'localstate',
3258 'pkgdata', 'lisp', 'noinst', 'check');
3266 if (var ('SUBDIRS'))
3268 $output_rules .= ("tags-recursive:\n"
3269 . "\tlist=\'\$(SUBDIRS)\'; for subdir in \$\$list; do \\\n"
3270 # Never fail here if a subdir fails; it
3272 . "\t test \"\$\$subdir\" = . || (cd \$\$subdir"
3273 . " && \$(MAKE) \$(AM_MAKEFLAGS) tags); \\\n"
3275 push (@tag_deps, 'tags-recursive');
3276 &depend ('.PHONY', 'tags-recursive');
3278 $output_rules .= ("ctags-recursive:\n"
3279 . "\tlist=\'\$(SUBDIRS)\'; for subdir in \$\$list; do \\\n"
3280 # Never fail here if a subdir fails; it
3282 . "\t test \"\$\$subdir\" = . || (cd \$\$subdir"
3283 . " && \$(MAKE) \$(AM_MAKEFLAGS) ctags); \\\n"
3285 push (@ctag_deps, 'ctags-recursive');
3286 &depend ('.PHONY', 'ctags-recursive');
3289 if (&saw_sources_p (1)
3290 || var ('ETAGS_ARGS')
3294 foreach my $spec (@config_headers)
3296 my ($out, @ins) = split_config_file_spec ($spec);
3297 foreach my $in (@ins)
3299 # If the config header source is in this directory,
3301 push @config, basename ($in)
3302 if $relative_dir eq dirname ($in);
3305 $output_rules .= &file_contents ('tags',
3306 new Automake::Location,
3307 CONFIG => "@config",
3308 TAGSDIRS => "@tag_deps",
3309 CTAGSDIRS => "@ctag_deps");
3311 set_seen 'TAGS_DEPENDENCIES';
3313 elsif (reject_var ('TAGS_DEPENDENCIES',
3314 "doesn't make sense to define `TAGS_DEPENDENCIES'"
3315 . "without\nsources or `ETAGS_ARGS'"))
3320 # Every Makefile must define some sort of TAGS rule.
3321 # Otherwise, it would be possible for a top-level "make TAGS"
3322 # to fail because some subdirectory failed.
3323 $output_rules .= "tags: TAGS\nTAGS:\n\n";
3325 $output_rules .= "ctags: CTAGS\nCTAGS:\n\n";
3329 # Handle multilib support.
3332 if ($seen_multilib && $relative_dir eq '.')
3334 $output_rules .= &file_contents ('multilib', new Automake::Location);
3335 push (@all, 'all-multi');
3341 # &for_dist_common ($A, $B)
3342 # -------------------------
3343 # Subroutine for &handle_dist: sort files to dist.
3345 # We put README first because it then becomes easier to make a
3346 # Usenet-compliant shar file (in these, README must be first).
3348 # FIXME: do more ordering of files here.
3361 # handle_dist ($MAKEFILE)
3362 # -----------------------
3363 # Handle 'dist' target.
3366 my ($makefile) = @_;
3368 # `make dist' isn't used in a Cygnus-style tree.
3369 # Omit the rules so that people don't try to use them.
3370 return if $options{'cygnus'};
3372 # At least one of the archive formats must be enabled.
3373 if ($relative_dir eq '.')
3375 my $archive_defined = $options{'no-dist-gzip'} ? 0 : 1;
3376 $archive_defined ||=
3377 grep { $options{"dist-$_"} } ('shar', 'zip', 'tarZ', 'bzip2');
3378 error ($options{'no-dist-gzip'},
3379 "no-dist-gzip specified but no dist-* specified, "
3380 . "at least one archive format must be enabled")
3381 unless $archive_defined;
3384 # Look for common files that should be included in distribution.
3385 # If the aux dir is set, and it does not have a Makefile.am, then
3386 # we check for these files there as well.
3389 if ($relative_dir eq '.'
3390 && $config_aux_dir_set_in_configure_in)
3392 ($auxdir = $config_aux_dir) =~ s,^\$\(top_srcdir\)/,,;
3393 if (! &is_make_dir ($auxdir))
3398 foreach my $cfile (@common_files)
3400 if (-f ($relative_dir . "/" . $cfile)
3401 # The file might be absent, but if it can be built it's ok.
3402 || exists $targets{$cfile})
3404 &push_dist_common ($cfile);
3407 # Don't use `elsif' here because a file might meaningfully
3408 # appear in both directories.
3409 if ($check_aux && -f ($auxdir . '/' . $cfile))
3411 &push_dist_common ($auxdir . '/' . $cfile);
3415 # We might copy elements from $configure_dist_common to
3416 # %dist_common if we think we need to. If the file appears in our
3417 # directory, we would have discovered it already, so we don't
3418 # check that. But if the file is in a subdir without a Makefile,
3419 # we want to distribute it here if we are doing `.'. Ugly!
3420 if ($relative_dir eq '.')
3422 foreach my $file (split (' ' , $configure_dist_common))
3424 push_dist_common ($file)
3425 unless is_make_dir (dirname ($file));
3429 # Files to distributed. Don't use ->value_as_list_recursive
3430 # as it recursively expands `$(dist_pkgdata_DATA)' etc.
3431 my @dist_common = split (' ', rvar ('DIST_COMMON')->variable_value);
3432 @dist_common = uniq (sort for_dist_common (@dist_common));
3433 variable_delete 'DIST_COMMON';
3434 define_pretty_variable ('DIST_COMMON', TRUE, INTERNAL, @dist_common);
3436 # Now that we've processed DIST_COMMON, disallow further attempts
3438 $handle_dist_run = 1;
3440 # Scan EXTRA_DIST to see if we need to distribute anything from a
3441 # subdir. If so, add it to the list. I didn't want to do this
3442 # originally, but there were so many requests that I finally
3444 my $extra_dist = var ('EXTRA_DIST');
3447 # FIXME: This should be fixed to work with conditions. That
3448 # will require only making the entries in %dist_dirs under the
3449 # appropriate condition. This is meaningful if the nature of
3450 # the distribution should depend upon the configure options
3452 foreach ($extra_dist->value_as_list_recursive ('all'))
3455 next unless s,/+[^/]+$,,;
3461 # We have to check DIST_COMMON for extra directories in case the
3462 # user put a source used in AC_OUTPUT into a subdir.
3463 my $topsrcdir = backname ($relative_dir);
3464 foreach (rvar ('DIST_COMMON')->value_as_list_recursive ('all'))
3467 s/\$\(top_srcdir\)/$topsrcdir/;
3469 # Strip any leading `./'.
3471 next unless s,/+[^/]+$,,;
3476 # Rule to check whether a distribution is viable.
3477 my %transform = ('DISTCHECK-HOOK' => &target_defined ('distcheck-hook'),
3478 'GETTEXT' => $seen_gettext && !$seen_gettext_external);
3480 # Prepend $(distdir) to each directory given.
3481 my %rewritten = map { '$(distdir)/' . "$_" => 1 } keys %dist_dirs;
3482 $transform{'DISTDIRS'} = join (' ', sort keys %rewritten);
3484 # If we have SUBDIRS, create all dist subdirectories and do
3486 my $subdirs = var ('SUBDIRS');
3489 # If SUBDIRS is conditionally defined, then set DIST_SUBDIRS
3490 # to all possible directories, and use it. If DIST_SUBDIRS is
3491 # defined, just use it.
3492 my $dist_subdir_name;
3493 # Note that we check DIST_SUBDIRS first on purpose, so that
3494 # we don't call has_conditional_contents for now reason.
3495 # (In the past one project used so many conditional subdirectories
3496 # that calling has_conditional_contents on SUBDIRS caused
3497 # automake to grow to 150Mb -- this should not happen with
3498 # the current implementation of has_conditional_contents,
3499 # but it's more efficient to avoid the call anyway.)
3500 if (var ('DIST_SUBDIRS'))
3502 $dist_subdir_name = 'DIST_SUBDIRS';
3504 elsif ($subdirs->has_conditional_contents)
3506 $dist_subdir_name = 'DIST_SUBDIRS';
3507 define_pretty_variable
3508 ('DIST_SUBDIRS', TRUE, INTERNAL,
3509 uniq ($subdirs->value_as_list_recursive ('all')));
3513 $dist_subdir_name = 'SUBDIRS';
3514 # We always define this because that is what `distclean'
3516 define_pretty_variable ('DIST_SUBDIRS', TRUE, INTERNAL,
3520 $transform{'DIST_SUBDIR_NAME'} = $dist_subdir_name;
3523 # If the target `dist-hook' exists, make sure it is run. This
3524 # allows users to do random weird things to the distribution
3525 # before it is packaged up.
3526 push (@dist_targets, 'dist-hook')
3527 if &target_defined ('dist-hook');
3528 $transform{'DIST-TARGETS'} = join(' ', @dist_targets);
3530 $output_rules .= &file_contents ('distdir',
3531 new Automake::Location,
3536 # &handle_subdirs ()
3537 # ------------------
3538 # Handle subdirectories.
3539 sub handle_subdirs ()
3541 my $subdirs = var ('SUBDIRS');
3545 my @subdirs = $subdirs->value_as_list_recursive ('all');
3547 my $dsubdirs = var ('DIST_SUBDIRS');
3548 @dsubdirs = $dsubdirs->value_as_list_recursive ('all')
3551 # If an `obj/' directory exists, BSD make will enter it before
3552 # reading `Makefile'. Hence the `Makefile' in the current directory
3558 # % cat obj/Makefile
3564 # % pmake # BSD make
3567 msg_var ('portability', 'SUBDIRS',
3568 "naming a subdirectory `obj' causes troubles with BSD make")
3569 if grep ($_ eq 'obj', @subdirs);
3570 msg_var ('portability', 'DIST_SUBDIRS',
3571 "naming a subdirectory `obj' causes troubles with BSD make")
3572 if grep ($_ eq 'obj', @dsubdirs);
3574 # Make sure each directory mentioned in SUBDIRS actually exists.
3575 foreach my $dir (@subdirs)
3577 # Skip directories substituted by configure.
3578 next if $dir =~ /^\@.*\@$/;
3580 if (! -d $am_relative_dir . '/' . $dir)
3582 err_var ('SUBDIRS', "required directory $am_relative_dir/$dir "
3583 . "does not exist");
3587 err_var 'SUBDIRS', "directory should not contain `/'"
3591 $output_rules .= &file_contents ('subdirs', new Automake::Location);
3592 rvar ('RECURSIVE_TARGETS')->rdef (TRUE)->{'pretty'} = VAR_SORTED; # Gross!
3596 # ($REGEN, @DEPENDENCIES)
3599 # If aclocal.m4 creation is automated, return the list of its dependencies.
3602 my $regen_aclocal = 0;
3604 set_seen 'CONFIG_STATUS_DEPENDENCIES';
3605 set_seen 'CONFIGURE_DEPENDENCIES';
3607 if (-f 'aclocal.m4')
3609 &push_dist_common ('aclocal.m4')
3610 if $relative_dir eq '.';
3611 &define_variable ("ACLOCAL_M4", '$(top_srcdir)/aclocal.m4', INTERNAL);
3613 my $aclocal = new Automake::XFile "< aclocal.m4";
3614 my $line = $aclocal->getline;
3615 $regen_aclocal = $line =~ 'generated automatically by aclocal';
3620 if (set_seen ('ACLOCAL_M4_SOURCES'))
3622 push (@ac_deps, '$(ACLOCAL_M4_SOURCES)');
3623 msg_var ('obsolete', 'ACLOCAL_M4_SOURCES',
3624 "`ACLOCAL_M4_SOURCES' is obsolete.\n"
3625 . "It should be safe to simply remove it.");
3628 # Note that it might be possible that aclocal.m4 doesn't exist but
3629 # should be auto-generated. This case probably isn't very
3632 return ($regen_aclocal, @ac_deps);
3637 # &rewrite_inputs_into_dependencies ($ADD_SRCDIR, @INPUTS)
3638 # --------------------------------------------------------
3639 # Rewrite a list of input files into a form suitable to put on a
3640 # dependency list. The idea is that if an input file has a directory
3641 # part the same as the current directory, then the directory part is
3642 # simply removed. But if the directory part is different, then
3643 # $(top_srcdir) is prepended. Among other things, this is used to
3644 # generate the dependency list for the output files generated by
3645 # AC_OUTPUT. Consider what the dependencies should look like in this
3647 # AC_OUTPUT(src/out:src/in1:lib/in2)
3648 # The first argument, ADD_SRCDIR, is 1 if $(top_srcdir) should be added.
3649 # If 0 then files that require this addition will simply be ignored.
3650 sub rewrite_inputs_into_dependencies ($@)
3652 my ($add_srcdir, @inputs) = @_;
3655 foreach my $single (@inputs)
3657 if (dirname ($single) eq $relative_dir)
3659 push (@newinputs, basename ($single));
3663 push (@newinputs, ($add_srcdir ? '$(top_srcdir)/' : '') . $single);
3670 # &handle_configure ($LOCAL, $INPUT, @SECONDARY_INPUTS)
3671 # -----------------------------------------------------
3672 # Handle remaking and configure stuff.
3673 # We need the name of the input file, to do proper remaking rules.
3674 sub handle_configure ($$@)
3676 my ($local, $input, @secondary_inputs) = @_;
3678 my $input_base = basename ($input);
3679 my $local_base = basename ($local);
3681 my $amfile = $input_base . '.am';
3682 # We know we can always add '.in' because it really should be an
3683 # error if the .in was missing originally.
3684 my $infile = '$(srcdir)/' . $input_base . '.in';
3685 my $colon_infile = '';
3686 if ($local ne $input || @secondary_inputs)
3688 $colon_infile = ':' . $input . '.in';
3690 $colon_infile .= ':' . join (':', @secondary_inputs)
3691 if @secondary_inputs;
3693 my @rewritten = rewrite_inputs_into_dependencies (1, @secondary_inputs);
3695 my ($regen_aclocal_m4, @aclocal_m4_deps) = scan_aclocal_m4 ();
3698 define_pretty_variable ('am__configure_deps', TRUE, INTERNAL,
3701 $output_rules .= file_contents
3703 new Automake::Location,
3704 MAKEFILE => $local_base,
3705 'MAKEFILE-DEPS' => "@rewritten",
3706 'CONFIG-MAKEFILE' => ($relative_dir eq '.') ? '$@' : '$(subdir)/$@',
3707 'MAKEFILE-IN' => $infile,
3708 'MAKEFILE-IN-DEPS' => "@include_stack",
3709 'MAKEFILE-AM' => $amfile,
3710 STRICTNESS => $options{'cygnus'} ? 'cygnus' : $strictness_name,
3711 'USE-DEPS' => $cmdline_use_dependencies ? '' : ' --ignore-deps',
3712 'MAKEFILE-AM-SOURCES' => "$input$colon_infile",
3713 'REGEN-ACLOCAL-M4' => $regen_aclocal_m4,
3714 ACLOCAL_M4_DEPS => "@aclocal_m4_deps");
3716 if ($relative_dir eq '.')
3718 &push_dist_common ('acconfig.h')
3722 # If we have a configure header, require it.
3724 my @distclean_config;
3725 foreach my $spec (@config_headers)
3728 # $CONFIG_H_PATH: config.h from top level.
3729 my ($config_h_path, @ins) = split_config_file_spec ($spec);
3730 my $config_h_dir = dirname ($config_h_path);
3732 # If the header is in the current directory we want to build
3733 # the header here. Otherwise, if we're at the topmost
3734 # directory and the header's directory doesn't have a
3735 # Makefile, then we also want to build the header.
3736 if ($relative_dir eq $config_h_dir
3737 || ($relative_dir eq '.' && ! &is_make_dir ($config_h_dir)))
3739 my ($cn_sans_dir, $stamp_dir);
3740 if ($relative_dir eq $config_h_dir)
3742 $cn_sans_dir = basename ($config_h_path);
3747 $cn_sans_dir = $config_h_path;
3748 if ($config_h_dir eq '.')
3754 $stamp_dir = $config_h_dir . '/';
3758 # Compute relative path from directory holding output
3759 # header to directory holding input header. FIXME:
3760 # doesn't handle case where we have multiple inputs.
3762 if (dirname ($ins[0]) eq $relative_dir)
3764 $in0_sans_dir = basename ($ins[0]);
3768 $in0_sans_dir = backname ($relative_dir) . '/' . $ins[0];
3771 require_file ($config_header_location, FOREIGN, $in0_sans_dir);
3773 # Header defined and in this directory.
3775 if (-f $config_h_path . '.top')
3777 push (@files, "$cn_sans_dir.top");
3779 if (-f $config_h_path . '.bot')
3781 push (@files, "$cn_sans_dir.bot");
3784 push_dist_common (@files);
3786 # For now, acconfig.h can only appear in the top srcdir.
3787 if (-f 'acconfig.h')
3789 push (@files, '$(top_srcdir)/acconfig.h');
3792 my $stamp = "${stamp_dir}stamp-h${hdr_index}";
3794 file_contents ('remake-hdr',
3795 new Automake::Location,
3797 CONFIG_H => $cn_sans_dir,
3798 CONFIG_HIN => $in0_sans_dir,
3799 CONFIG_H_PATH => $config_h_path,
3802 push @distclean_config, $cn_sans_dir, $stamp;
3806 $output_rules .= file_contents ('clean-hdr',
3807 new Automake::Location,
3808 FILES => "@distclean_config")
3809 if @distclean_config;
3811 # Set location of mkinstalldirs.
3812 define_variable ('mkinstalldirs',
3813 '$(SHELL) ' . $config_aux_dir . '/mkinstalldirs',
3816 reject_var ('CONFIG_HEADER',
3817 "`CONFIG_HEADER' is an anachronism; now determined "
3818 . "automatically\nfrom `$configure_ac'");
3821 foreach my $spec (@config_headers)
3823 my ($out, @ins) = split_config_file_spec ($spec);
3824 # Generate CONFIG_HEADER define.
3825 if ($relative_dir eq dirname ($out))
3827 push @config_h, basename ($out);
3831 push @config_h, "\$(top_builddir)/$out";
3834 define_variable ("CONFIG_HEADER", "@config_h", INTERNAL)
3837 # Now look for other files in this directory which must be remade
3838 # by config.status, and generate rules for them.
3839 my @actual_other_files = ();
3840 foreach my $lfile (@other_input_files)
3844 if ($lfile =~ /^([^:]*):(.*)$/)
3846 # This is the ":" syntax of AC_OUTPUT.
3848 @inputs = split (':', $2);
3854 @inputs = $file . '.in';
3857 # Automake files should not be stored in here, but in %MAKE_LIST.
3858 prog_error "$lfile in \@other_input_files"
3859 if -f $file . '.am';
3861 my $local = basename ($file);
3863 # Make sure the dist directory for each input file is created.
3864 # We only have to do this at the topmost level though. This
3865 # is a bit ugly but it easier than spreading out the logic,
3866 # especially in cases like AC_OUTPUT(foo/out:bar/in), where
3867 # there is no Makefile in bar/.
3868 if ($relative_dir eq '.')
3872 $dist_dirs{dirname ($_)} = 1;
3876 # We skip files that aren't in this directory. However, if
3877 # the file's directory does not have a Makefile, and we are
3878 # currently doing `.', then we create a rule to rebuild the
3879 # file in the subdir.
3880 my $fd = dirname ($file);
3881 if ($fd ne $relative_dir)
3883 if ($relative_dir eq '.' && ! &is_make_dir ($fd))
3893 my @rewritten_inputs = rewrite_inputs_into_dependencies (1, @inputs);
3894 $output_rules .= ($local . ': '
3895 . '$(top_builddir)/config.status '
3896 . "@rewritten_inputs\n"
3898 . 'cd $(top_builddir) && '
3899 . '$(SHELL) ./config.status '
3900 . ($relative_dir eq '.' ? '' : '$(subdir)/')
3903 push (@actual_other_files, $local);
3905 # Require all input files.
3906 require_file ($ac_config_files_location, FOREIGN,
3907 rewrite_inputs_into_dependencies (0, @inputs));
3910 foreach my $struct (@config_links)
3912 my ($spec, $where) = @$struct;
3913 my ($link, $file) = split /:/, $spec;
3915 # We skip links that aren't in this directory. However, if
3916 # the link's directory does not have a Makefile, and we are
3917 # currently doing `.', then we add the link to CONFIG_CLEAN_FILES
3918 # in `.'s Makefile.in.
3919 my $local = basename ($link);
3920 my $fd = dirname ($link);
3921 if ($fd ne $relative_dir)
3923 if ($relative_dir eq '.' && ! &is_make_dir ($fd))
3933 push @actual_other_files, $local if $local;
3935 $local = basename ($file);
3936 $fd = dirname ($file);
3938 # Make sure the dist directory for each input file is created.
3939 # We only have to do this at the topmost level though.
3940 if ($relative_dir eq '.')
3942 $dist_dirs{$fd} = 1;
3945 # We skip files that aren't in this directory. However, if
3946 # the files's directory does not have a Makefile, and we are
3947 # currently doing `.', then we require the file from `.'.
3948 if ($fd ne $relative_dir)
3950 if ($relative_dir eq '.' && ! &is_make_dir ($fd))
3960 # Require all input files.
3961 require_file ($where, FOREIGN, $local);
3964 # These files get removed by "make distclean".
3965 define_pretty_variable ('CONFIG_CLEAN_FILES', TRUE, INTERNAL,
3966 @actual_other_files);
3972 my @r = &am_install_var ('-defaultdist', 'header', 'HEADERS', 'include',
3973 'oldinclude', 'pkginclude',
3977 next unless $_->[1] =~ /\..*$/;
3978 &saw_extension ($&);
3984 return if ! $seen_gettext || $relative_dir ne '.';
3986 my $subdirs = var 'SUBDIRS';
3990 err_ac "AM_GNU_GETTEXT used but SUBDIRS not defined";
3994 # Perform some sanity checks to help users get the right setup.
3995 # We disable these tests when po/ doesn't exist in order not to disallow
3996 # unusual gettext setups.
4001 # | 1) If a package doesn't have a directory po/ at top level, it
4002 # | will likely have multiple po/ directories in subpackages.
4004 # | 2) It is useful to warn for the absence of intl/ if AM_GNU_GETTEXT
4005 # | is used without 'external'. It is also useful to warn for the
4006 # | presence of intl/ if AM_GNU_GETTEXT([external]) is used. Both
4007 # | warnings apply only to the usual layout of packages, therefore
4008 # | they should both be disabled if no po/ directory is found at
4013 my @subdirs = $subdirs->value_as_list_recursive ('all');
4015 msg_var ('syntax', $subdirs,
4016 "AM_GNU_GETTEXT used but `po' not in SUBDIRS")
4017 if ! grep ($_ eq 'po', @subdirs);
4019 # intl/ is not required when AM_GNU_GETTEXT is called with
4020 # the `external' option.
4021 msg_var ('syntax', $subdirs,
4022 "AM_GNU_GETTEXT used but `intl' not in SUBDIRS")
4023 if (! $seen_gettext_external
4024 && ! grep ($_ eq 'intl', @subdirs));
4026 # intl/ should not be used with AM_GNU_GETTEXT([external])
4027 msg_var ('syntax', $subdirs,
4028 "`intl' should not be in SUBDIRS when "
4029 . "AM_GNU_GETTEXT([external]) is used")
4030 if ($seen_gettext_external && grep ($_ eq 'intl', @subdirs));
4033 require_file ($ac_gettext_location, GNU, 'ABOUT-NLS');
4036 # Handle footer elements.
4039 # NOTE don't use define_pretty_variable here, because
4040 # $contents{...} is already defined.
4041 $output_vars .= 'SOURCES = ' . variable_value ('SOURCES') . "\n\n"
4042 if variable_value ('SOURCES');
4044 reject_target ('.SUFFIXES',
4045 "use variable `SUFFIXES', not target `.SUFFIXES'");
4047 # Note: AIX 4.1 /bin/make will fail if any suffix rule appears
4048 # before .SUFFIXES. So we make sure that .SUFFIXES appears before
4049 # anything else, by sticking it right after the default: target.
4050 $output_header .= ".SUFFIXES:\n";
4051 my $suffixes = var 'SUFFIXES';
4052 if (@suffixes || $suffixes)
4054 # Make sure suffixes has unique elements. Sort them to ensure
4055 # the output remains consistent. However, $(SUFFIXES) is
4056 # always at the start of the list, unsorted. This is done
4057 # because make will choose rules depending on the ordering of
4058 # suffixes, and this lets the user have some control. Push
4059 # actual suffixes, and not $(SUFFIXES). Some versions of make
4060 # do not like variable substitutions on the .SUFFIXES line.
4061 my @user_suffixes = ($suffixes
4062 ? $suffixes->value_as_list_recursive ('all')
4065 my %suffixes = map { $_ => 1 } @suffixes;
4066 delete @suffixes{@user_suffixes};
4068 $output_header .= (".SUFFIXES: "
4069 . join (' ', @user_suffixes, sort keys %suffixes)
4073 $output_trailer .= file_contents ('footer', new Automake::Location);
4077 # Generate `make install' rules.
4078 sub handle_install ()
4080 $output_rules .= &file_contents
4082 new Automake::Location,
4083 maybe_BUILT_SOURCES => (set_seen ('BUILT_SOURCES')
4084 ? (" \$(BUILT_SOURCES)\n"
4085 . "\t\$(MAKE) \$(AM_MAKEFLAGS)")
4087 'installdirs-local' => (target_defined ('installdirs-local')
4088 ? ' installdirs-local' : ''),
4089 am__installdirs => variable_value ('am__installdirs') || '');
4093 # Deal with all and all-am.
4096 my ($makefile) = @_;
4100 # Put this at the beginning for the sake of non-GNU makes. This
4101 # is still wrong if these makes can run parallel jobs. But it is
4103 unshift (@all, basename ($makefile));
4105 foreach my $spec (@config_headers)
4107 my ($out, @ins) = split_config_file_spec ($spec);
4108 push (@all, basename ($out))
4109 if dirname ($out) eq $relative_dir;
4112 # Install `all' hooks.
4113 if (&target_defined ("all-local"))
4115 push (@all, "all-local");
4116 &depend ('.PHONY', "all-local");
4119 &pretty_print_rule ("all-am:", "\t\t", @all);
4120 &depend ('.PHONY', 'all-am', 'all');
4125 my @local_headers = ();
4126 push @local_headers, '$(BUILT_SOURCES)'
4127 if var ('BUILT_SOURCES');
4128 foreach my $spec (@config_headers)
4130 my ($out, @ins) = split_config_file_spec ($spec);
4131 push @local_headers, basename ($out)
4132 if dirname ($out) eq $relative_dir;
4137 # We need to make sure config.h is built before we recurse.
4138 # We also want to make sure that built sources are built
4139 # before any ordinary `all' targets are run. We can't do this
4140 # by changing the order of dependencies to the "all" because
4141 # that breaks when using parallel makes. Instead we handle
4142 # things explicitly.
4143 $output_all .= ("all: @local_headers"
4145 . '$(MAKE) $(AM_MAKEFLAGS) '
4146 . (var ('SUBDIRS') ? 'all-recursive' : 'all-am')
4151 $output_all .= "all: " . (var ('SUBDIRS')
4152 ? 'all-recursive' : 'all-am') . "\n\n";
4157 # &do_check_merge_target ()
4158 # -------------------------
4159 # Handle check merge target specially.
4160 sub do_check_merge_target ()
4162 if (target_defined ('check-local'))
4164 # User defined local form of target. So include it.
4165 push @check_tests, 'check-local';
4166 depend '.PHONY', 'check-local';
4169 # In --cygnus mode, check doesn't depend on all.
4170 if ($options{'cygnus'})
4172 # Just run the local check rules.
4173 pretty_print_rule ('check-am:', "\t\t", @check);
4177 # The check target must depend on the local equivalent of
4178 # `all', to ensure all the primary targets are built. Then it
4179 # must build the local check rules.
4180 $output_rules .= "check-am: all-am\n";
4181 pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ",
4185 pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ",
4189 depend '.PHONY', 'check', 'check-am';
4190 # Handle recursion. We have to honor BUILT_SOURCES like for `all:'.
4191 $output_rules .= ("check: "
4192 . (var ('BUILT_SOURCES')
4193 ? "\$(BUILT_SOURCES)\n\t\$(MAKE) \$(AM_MAKEFLAGS) "
4195 . (var ('SUBDIRS') ? 'check-recursive' : 'check-am')
4199 # Handle all 'clean' targets.
4202 # Clean the files listed in user variables if they exist.
4203 $clean_files{'$(MOSTLYCLEANFILES)'} = MOSTLY_CLEAN
4204 if var ('MOSTLYCLEANFILES');
4205 $clean_files{'$(CLEANFILES)'} = CLEAN
4206 if var ('CLEANFILES');
4207 $clean_files{'$(DISTCLEANFILES)'} = DIST_CLEAN
4208 if var ('DISTCLEANFILES');
4209 $clean_files{'$(MAINTAINERCLEANFILES)'} = MAINTAINER_CLEAN
4210 if var ('MAINTAINERCLEANFILES');
4212 # Built sources are automatically removed by maintainer-clean.
4213 $clean_files{'$(BUILT_SOURCES)'} = MAINTAINER_CLEAN
4214 if var ('BUILT_SOURCES');
4216 # Compute a list of "rm"s to run for each target.
4217 my %rms = (MOSTLY_CLEAN, [],
4220 MAINTAINER_CLEAN, []);
4222 foreach my $file (keys %clean_files)
4224 my $when = $clean_files{$file};
4225 prog_error 'invalid entry in %clean_files'
4226 unless exists $rms{$when};
4228 my $rm = "rm -f $file";
4229 # If file is a variable, make sure when don't call `rm -f' without args.
4230 $rm ="test -z \"$file\" || $rm"
4231 if ($file =~ /^\s*\$(\(.*\)|\{.*\})\s*$/);
4233 push @{$rms{$when}}, "\t-$rm\n";
4236 $output_rules .= &file_contents
4238 new Automake::Location,
4239 MOSTLYCLEAN_RMS => join ('', @{$rms{&MOSTLY_CLEAN}}),
4240 CLEAN_RMS => join ('', @{$rms{&CLEAN}}),
4241 DISTCLEAN_RMS => join ('', @{$rms{&DIST_CLEAN}}),
4242 MAINTAINER_CLEAN_RMS => join ('', @{$rms{&MAINTAINER_CLEAN}}));
4246 # &target_cmp ($A, $B)
4247 # --------------------
4248 # Subroutine for &handle_factored_dependencies to let `.PHONY' be last.
4261 # &handle_factored_dependencies ()
4262 # --------------------------------
4263 # Handle everything related to gathered targets.
4264 sub handle_factored_dependencies
4267 foreach my $utarg ('uninstall-data-local', 'uninstall-data-hook',
4268 'uninstall-exec-local', 'uninstall-exec-hook')
4271 $x =~ s/(data|exec)-//;
4272 reject_target ($utarg, "use `$x', not `$utarg'");
4275 reject_target ('install-local',
4276 "use `install-data-local' or `install-exec-local', "
4277 . "not `install-local'");
4279 reject_target ('install-info-local',
4280 "`install-info-local' target defined but "
4281 . "`no-installinfo' option not in use")
4282 unless defined $options{'no-installinfo'};
4284 # Install the -local hooks.
4285 foreach (keys %dependencies)
4287 # Hooks are installed on the -am targets.
4289 if (&target_defined ("$_-local"))
4291 depend ("$_-am", "$_-local");
4292 &depend ('.PHONY', "$_-local");
4296 # Install the -hook hooks.
4297 # FIXME: Why not be as liberal as we are with -local hooks?
4298 foreach ('install-exec', 'install-data', 'uninstall')
4300 if (&target_defined ("$_-hook"))
4302 $actions{"$_-am"} .=
4303 ("\t\@\$(NORMAL_INSTALL)\n"
4304 . "\t" . '$(MAKE) $(AM_MAKEFLAGS) ' . "$_-hook\n");
4308 # All the required targets are phony.
4309 depend ('.PHONY', keys %required_targets);
4311 # Actually output gathered targets.
4312 foreach (sort target_cmp keys %dependencies)
4314 # If there is nothing about this guy, skip it.
4316 unless (@{$dependencies{$_}}
4318 || $required_targets{$_});
4320 # Define gathered targets in undefined conditions.
4321 # FIXME: Right now we must handle .PHONY as an exception,
4322 # because people write things like
4323 # .PHONY: myphonytarget
4324 # to append dependencies. This would not work if Automake
4325 # refrained from defining its own .PHONY target as it does
4326 # with other overridden targets.
4327 my @undefined_conds = (TRUE,);
4331 rule_define ($_, 'internal', TARGET_AUTOMAKE, TRUE, INTERNAL);
4333 my @uniq_deps = uniq (sort @{$dependencies{$_}});
4334 foreach my $cond (@undefined_conds)
4336 my $condstr = $cond->subst_string;
4337 &pretty_print_rule ("$condstr$_:", "$condstr\t", @uniq_deps);
4338 $output_rules .= $actions{$_} if defined $actions{$_};
4339 $output_rules .= "\n";
4345 # &handle_tests_dejagnu ()
4346 # ------------------------
4347 sub handle_tests_dejagnu
4349 push (@check_tests, 'check-DEJAGNU');
4350 $output_rules .= file_contents ('dejagnu', new Automake::Location);
4354 # Handle TESTS variable and other checks.
4357 if (defined $options{'dejagnu'})
4359 &handle_tests_dejagnu;
4363 foreach my $c ('DEJATOOL', 'RUNTEST', 'RUNTESTFLAGS')
4365 reject_var ($c, "`$c' defined but `dejagnu' not in "
4366 . "`AUTOMAKE_OPTIONS'");
4372 push (@check_tests, 'check-TESTS');
4373 $output_rules .= &file_contents ('check', new Automake::Location);
4377 # Handle Emacs Lisp.
4378 sub handle_emacs_lisp
4380 my @elfiles = &am_install_var ('-candist', 'lisp', 'LISP',
4383 return if ! @elfiles;
4385 # Generate .elc files.
4386 my @elcfiles = map { $_->[1] . 'c' } @elfiles;
4388 define_pretty_variable ('ELCFILES', TRUE, INTERNAL, @elcfiles);
4389 define_pretty_variable ('am__ELFILES', TRUE, INTERNAL,
4390 map { $_->[1] } @elfiles);
4392 # Do not depend on the build rules if ELCFILES is empty.
4393 # This is necessary because overriding ELCFILES= is a documented
4394 # idiom to disable byte-compilation.
4395 if (variable_value ('ELCFILES'))
4397 # It's important that all depends on elc-stamp so that
4398 # all .elc files get recompiled whenever a .el changes.
4399 # It's important that all depends on $(ELCFILES) so that
4400 # we can recover if any of them is deleted.
4401 push (@all, 'elc-stamp', '$(ELCFILES)');
4404 require_variables ($elfiles[0][0], "Emacs Lisp sources seen", TRUE,
4405 'EMACS', 'lispdir');
4406 require_conf_file ($elfiles[0][0], FOREIGN, 'elisp-comp');
4407 &define_variable ('elisp_comp', $config_aux_dir . '/elisp-comp', INTERNAL);
4413 my @pyfiles = &am_install_var ('-defaultdist', 'python', 'PYTHON',
4415 return if ! @pyfiles;
4417 require_variables ($pyfiles[0][0], "Python sources seen", TRUE, 'PYTHON');
4418 require_conf_file ($pyfiles[0][0], FOREIGN, 'py-compile');
4419 &define_variable ('py_compile', $config_aux_dir . '/py-compile', INTERNAL);
4425 my @sourcelist = &am_install_var ('-candist',
4427 'java', 'noinst', 'check');
4428 return if ! @sourcelist;
4430 my @prefix = am_primary_prefixes ('JAVA', 1,
4431 'java', 'noinst', 'check');
4434 foreach my $curs (@prefix)
4437 if $curs eq 'EXTRA';
4439 err_var "${curs}_JAVA", "multiple _JAVA primaries in use"
4445 push (@all, 'class' . $dir . '.stamp');
4449 # Handle some of the minor options.
4450 sub handle_minor_options
4452 if (defined $options{'readme-alpha'})
4454 if ($relative_dir eq '.')
4456 if ($package_version !~ /^$GNITS_VERSION_PATTERN$/)
4458 msg ('error-gnits', $package_version_location,
4459 "version `$package_version' doesn't follow " .
4462 if (defined $1 && -f 'README-alpha')
4464 # This means we have an alpha release. See
4465 # GNITS_VERSION_PATTERN for details.
4466 push_dist_common ('README-alpha');
4472 ################################################################
4474 # ($OUTPUT, @INPUTS)
4475 # &split_config_file_spec ($SPEC)
4476 # -------------------------------
4477 # Decode the Autoconf syntax for config files (files, headers, links
4479 sub split_config_file_spec ($)
4482 my ($output, @inputs) = split (/:/, $spec);
4484 push @inputs, "$output.in"
4487 return ($output, @inputs);
4493 # &scan_autoconf_config_files ($CONFIG-FILES)
4494 # -------------------------------------------
4495 # Study $CONFIG-FILES which is the first argument to AC_CONFIG_FILES
4497 sub scan_autoconf_config_files
4499 my ($config_files) = @_;
4500 # Look at potential Makefile.am's.
4501 foreach (split ' ', $config_files)
4503 # Must skip empty string for Perl 4.
4504 next if $_ eq "\\" || $_ eq '';
4506 # Handle $local:$input syntax. Note that we ignore
4507 # every input file past the first, though we keep
4508 # those around for later.
4509 my ($local, $input, @rest) = split (/:/);
4516 # FIXME: should be error if .in is missing.
4517 $input =~ s/\.in$//;
4520 if (-f $input . '.am')
4522 # We have a file that automake should generate.
4523 $make_list{$input} = join (':', ($local, @rest));
4527 # We have a file that automake should cause to be
4528 # rebuilt, but shouldn't generate itself.
4529 push (@other_input_files, $_);
4535 # &scan_autoconf_traces ($FILENAME)
4536 # ---------------------------------
4537 sub scan_autoconf_traces ($)
4539 my ($filename) = @_;
4541 # Macros to trace, with their minimal number of arguments.
4543 AC_CANONICAL_HOST => 0,
4544 AC_CANONICAL_SYSTEM => 0,
4545 AC_CONFIG_AUX_DIR => 1,
4546 AC_CONFIG_FILES => 1,
4547 AC_CONFIG_HEADERS => 1,
4548 AC_CONFIG_LINKS => 1,
4552 AM_AUTOMAKE_VERSION => 1,
4553 AM_CONDITIONAL => 2,
4554 AM_ENABLE_MULTILIB => 0,
4555 AM_GNU_GETTEXT => 0,
4556 AM_INIT_AUTOMAKE => 0,
4557 AM_MAINTAINER_MODE => 0,
4558 AM_PROG_CC_C_O => 0,
4563 my $traces = ($ENV{AUTOCONF} || 'autoconf') . " ";
4565 # Use a separator unlikely to be used, not `:', the default, which
4566 # has a precise meaning for AC_CONFIG_FILES and so on.
4567 $traces .= join (' ',
4568 map { "--trace=$_" . ':\$f:\$l::\$n::\${::}%' }
4571 my $tracefh = new Automake::XFile ("$traces $filename |");
4572 verb "reading $traces";
4574 while ($_ = $tracefh->getline)
4577 my ($here, @args) = split /::/;
4578 my $where = new Automake::Location $here;
4579 my $macro = $args[0];
4581 prog_error ("unrequested trace `$macro'")
4582 unless exists $traced{$macro};
4584 # Skip and diagnose malformed calls.
4585 if ($#args < $traced{$macro})
4587 msg ('syntax', $where, "not enough arguments for $macro");
4591 # Alphabetical ordering please.
4592 if ($macro eq 'AC_CANONICAL_HOST')
4594 if (! $seen_canonical)
4596 $seen_canonical = AC_CANONICAL_HOST;
4597 $canonical_location = $where;
4600 elsif ($macro eq 'AC_CANONICAL_SYSTEM')
4602 $seen_canonical = AC_CANONICAL_SYSTEM;
4603 $canonical_location = $where;
4605 elsif ($macro eq 'AC_CONFIG_AUX_DIR')
4607 @config_aux_path = $args[1];
4608 $config_aux_dir_set_in_configure_in = 1;
4610 elsif ($macro eq 'AC_CONFIG_FILES')
4612 # Look at potential Makefile.am's.
4613 $ac_config_files_location = $where;
4614 &scan_autoconf_config_files ($args[1]);
4616 elsif ($macro eq 'AC_CONFIG_HEADERS')
4618 $config_header_location = $where;
4619 push @config_headers, split (' ', $args[1]);
4621 elsif ($macro eq 'AC_CONFIG_LINKS')
4623 push @config_links, map { [$_, $where] } split (' ', $args[1]);
4625 elsif ($macro eq 'AC_INIT')
4627 if (defined $args[2])
4629 $package_version = $args[2];
4630 $package_version_location = $where;
4633 elsif ($macro eq 'AC_LIBSOURCE')
4635 $libsources{$args[1]} = $here;
4637 elsif ($macro eq 'AC_SUBST')
4639 # Just check for alphanumeric in AC_SUBST. If you do
4640 # AC_SUBST(5), then too bad.
4641 $configure_vars{$args[1]} = $where
4642 if $args[1] =~ /^\w+$/;
4644 elsif ($macro eq 'AM_AUTOMAKE_VERSION')
4647 "version mismatch. This is Automake $VERSION,\n" .
4648 "but the definition used by this AM_INIT_AUTOMAKE\n" .
4649 "comes from Automake $args[1]. You should recreate\n" .
4650 "aclocal.m4 with aclocal and run automake again.\n")
4651 if $VERSION ne $args[1];
4653 $seen_automake_version = 1;
4655 elsif ($macro eq 'AM_CONDITIONAL')
4657 $configure_cond{$args[1]} = $where;
4659 elsif ($macro eq 'AM_ENABLE_MULTILIB')
4661 $seen_multilib = $where;
4663 elsif ($macro eq 'AM_GNU_GETTEXT')
4665 $seen_gettext = $where;
4666 $ac_gettext_location = $where;
4667 $seen_gettext_external = grep ($_ eq 'external', @args);
4669 elsif ($macro eq 'AM_INIT_AUTOMAKE')
4671 $seen_init_automake = $where;
4672 if (defined $args[2])
4674 $package_version = $args[2];
4675 $package_version_location = $where;
4677 elsif (defined $args[1])
4679 $global_options = $args[1];
4682 elsif ($macro eq 'AM_MAINTAINER_MODE')
4684 $seen_maint_mode = $where;
4686 elsif ($macro eq 'AM_PROG_CC_C_O')
4688 $seen_cc_c_o = $where;
4690 elsif ($macro eq 'm4_include' || $macro eq 'm4_sinclude')
4692 # Some modified versions of Autoconf don't use
4693 # forzen files. Consequently it's possible that we see all
4694 # m4_include's performed during Autoconf's startup.
4695 # Obviously we don't want to distribute Autoconf's files
4696 # so we skip absolute filenames here.
4697 push @configure_deps, '$(top_srcdir)/' . $args[1]
4698 unless $here =~ m,^(?:\w:)?[\\/],;
4704 # &scan_autoconf_files ()
4705 # -----------------------
4706 # Check whether we use `configure.ac' or `configure.in'.
4707 # Scan it (and possibly `aclocal.m4') for interesting things.
4708 # We must scan aclocal.m4 because there might be AC_SUBSTs and such there.
4709 sub scan_autoconf_files
4711 # Reinitialize libsources here. This isn't really necessary,
4712 # since we currently assume there is only one configure.ac. But
4713 # that won't always be the case.
4716 scan_autoconf_traces (require_configure_ac);
4718 # Set input and output files if not specified by user.
4721 @input_files = sort keys %make_list;
4722 %output_files = %make_list;
4725 @configure_input_files = sort keys %make_list;
4727 if (! $seen_init_automake)
4729 err_ac ("no proper invocation of AM_INIT_AUTOMAKE was found.\nYou "
4730 . "should verify that $configure_ac invokes AM_INIT_AUTOMAKE,"
4731 . "\nthat aclocal.m4 is present in the top-level directory,\n"
4732 . "and that aclocal.m4 was recently regenerated "
4733 . "(using aclocal).");
4737 if (! $seen_automake_version)
4739 if (-f 'aclocal.m4')
4741 error ($seen_init_automake,
4742 "your implementation of AM_INIT_AUTOMAKE comes from " .
4743 "an\nold Automake version. You should recreate " .
4744 "aclocal.m4\nwith aclocal and run automake again.\n");
4748 error ($seen_init_automake,
4749 "no proper implementation of AM_INIT_AUTOMAKE was " .
4750 "found,\nprobably because aclocal.m4 is missing...\n" .
4751 "You should run aclocal to create this file, then\n" .
4752 "run automake again.\n");
4757 # Look for some files we need. Always check for these. This
4758 # check must be done for every run, even those where we are only
4759 # looking at a subdir Makefile. We must set relative_dir so that
4760 # the file-finding machinery works.
4761 # FIXME: Is this broken because it needs dynamic scopes.
4762 # My tests seems to show it's not the case.
4763 $relative_dir = '.';
4764 require_conf_file ($configure_ac, FOREIGN,
4765 'install-sh', 'mkinstalldirs', 'missing');
4766 err_am "`install.sh' is an anachronism; use `install-sh' instead"
4767 if -f $config_aux_path[0] . '/install.sh';
4769 # Preserve dist_common for later.
4770 $configure_dist_common = variable_value ('DIST_COMMON') || '';
4773 ################################################################
4775 # Set up for Cygnus mode.
4778 return unless $options{'cygnus'};
4780 &set_strictness ('foreign');
4781 $options{'no-installinfo'} = $options{'cygnus'};
4782 $options{'no-dependencies'} = $options{'cygnus'};
4783 $use_dependencies = 0;
4785 err_ac "`AM_MAINTAINER_MODE' required when --cygnus specified"
4786 if !$seen_maint_mode;
4789 # Do any extra checking for GNU standards.
4790 sub check_gnu_standards
4792 if ($relative_dir eq '.')
4794 # In top level (or only) directory.
4796 # Accept one of these three licenses; default to COPYING.
4797 my $license = 'COPYING';
4798 foreach (qw /COPYING.LIB COPYING.LESSER/)
4800 $license = $_ if -f $_;
4802 require_file ("$am_file.am", GNU, $license,
4803 qw/INSTALL NEWS README AUTHORS ChangeLog/);
4806 for my $opt ('no-installman', 'no-installinfo')
4808 msg ('error-gnu', $options{$opt},
4809 "option `$opt' disallowed by GNU standards")
4810 if (defined $options{$opt});
4814 # Do any extra checking for GNITS standards.
4815 sub check_gnits_standards
4817 if ($relative_dir eq '.')
4819 # In top level (or only) directory.
4820 require_file ("$am_file.am", GNITS, 'THANKS');
4824 ################################################################
4826 # Functions to handle files of each language.
4828 # Each `lang_X_rewrite($DIRECTORY, $BASE, $EXT)' function follows a
4829 # simple formula: Return value is LANG_SUBDIR if the resulting object
4830 # file should be in a subdir if the source file is, LANG_PROCESS if
4831 # file is to be dealt with, LANG_IGNORE otherwise.
4833 # Much of the actual processing is handled in
4834 # handle_single_transform_list. These functions exist so that
4835 # auxiliary information can be recorded for a later cleanup pass.
4836 # Note that the calls to these functions are computed, so don't bother
4837 # searching for their precise names in the source.
4839 # This is just a convenience function that can be used to determine
4840 # when a subdir object should be used.
4843 return defined $options{'subdir-objects'} ? LANG_SUBDIR : LANG_PROCESS;
4846 # Rewrite a single C source file.
4849 my ($directory, $base, $ext) = @_;
4851 if (defined $options{'ansi2knr'} && $base =~ /_$/)
4853 # FIXME: include line number in error.
4854 err_am "C source file `$base.c' would be deleted by ansi2knr rules";
4857 my $r = LANG_PROCESS;
4858 if (defined $options{'subdir-objects'})
4861 $base = $directory . '/' . $base
4862 unless $directory eq '.' || $directory eq '';
4864 err_am ("C objects in subdir but `AM_PROG_CC_C_O' "
4865 . "not in `$configure_ac'",
4866 uniq_scope => US_GLOBAL)
4867 unless $seen_cc_c_o;
4869 require_conf_file ("$am_file.am", FOREIGN, 'compile');
4871 # In this case we already have the directory information, so
4872 # don't add it again.
4873 $de_ansi_files{$base} = '';
4877 $de_ansi_files{$base} = (($directory eq '.' || $directory eq '')
4885 # Rewrite a single C++ source file.
4886 sub lang_cxx_rewrite
4888 return &lang_sub_obj;
4891 # Rewrite a single header file.
4892 sub lang_header_rewrite
4894 # Header files are simply ignored.
4898 # Rewrite a single yacc file.
4899 sub lang_yacc_rewrite
4901 my ($directory, $base, $ext) = @_;
4903 my $r = &lang_sub_obj;
4904 (my $newext = $ext) =~ tr/y/c/;
4905 return ($r, $newext);
4908 # Rewrite a single yacc++ file.
4909 sub lang_yaccxx_rewrite
4911 my ($directory, $base, $ext) = @_;
4913 my $r = &lang_sub_obj;
4914 (my $newext = $ext) =~ tr/y/c/;
4915 return ($r, $newext);
4918 # Rewrite a single lex file.
4919 sub lang_lex_rewrite
4921 my ($directory, $base, $ext) = @_;
4923 my $r = &lang_sub_obj;
4924 (my $newext = $ext) =~ tr/l/c/;
4925 return ($r, $newext);
4928 # Rewrite a single lex++ file.
4929 sub lang_lexxx_rewrite
4931 my ($directory, $base, $ext) = @_;
4933 my $r = &lang_sub_obj;
4934 (my $newext = $ext) =~ tr/l/c/;
4935 return ($r, $newext);
4938 # Rewrite a single assembly file.
4939 sub lang_asm_rewrite
4941 return &lang_sub_obj;
4944 # Rewrite a single Fortran 77 file.
4945 sub lang_f77_rewrite
4947 return LANG_PROCESS;
4950 # Rewrite a single preprocessed Fortran 77 file.
4951 sub lang_ppf77_rewrite
4953 return LANG_PROCESS;
4956 # Rewrite a single ratfor file.
4957 sub lang_ratfor_rewrite
4959 return LANG_PROCESS;
4962 # Rewrite a single Objective C file.
4963 sub lang_objc_rewrite
4965 return &lang_sub_obj;
4968 # Rewrite a single Java file.
4969 sub lang_java_rewrite
4974 # The lang_X_finish functions are called after all source file
4975 # processing is done. Each should handle defining rules for the
4976 # language, etc. A finish function is only called if a source file of
4977 # the appropriate type has been seen.
4981 # Push all libobjs files onto de_ansi_files. We actually only
4982 # push files which exist in the current directory, and which are
4983 # genuine source files.
4984 foreach my $file (keys %libsources)
4986 if ($file =~ /^(.*)\.[cly]$/ && -f "$relative_dir/$file")
4988 $de_ansi_files{$1} = ''
4992 if (defined $options{'ansi2knr'} && keys %de_ansi_files)
4994 # Make all _.c files depend on their corresponding .c files.
4996 foreach my $base (sort keys %de_ansi_files)
4998 # Each _.c file must depend on ansi2knr; otherwise it
4999 # might be used in a parallel build before it is built.
5000 # We need to support files in the srcdir and in the build
5001 # dir (because these files might be auto-generated. But
5002 # we can't use $< -- some makes only define $< during a
5004 my $ansfile = $de_ansi_files{$base} . $base . '.c';
5005 $output_rules .= ($base . "_.c: $ansfile \$(ANSI2KNR)\n\t"
5006 . '$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) '
5007 . '`if test -f $(srcdir)/' . $ansfile
5008 . '; then echo $(srcdir)/' . $ansfile
5009 . '; else echo ' . $ansfile . '; fi` '
5010 . "| sed 's/^# \\([0-9]\\)/#line \\1/' "
5011 . '| $(ANSI2KNR) > $@'
5012 # If ansi2knr fails then we shouldn't
5013 # create the _.c file
5014 . " || rm -f \$\@\n");
5015 push (@objects, $base . '_.$(OBJEXT)');
5016 push (@objects, $base . '_.lo')
5020 # Make all _.o (and _.lo) files depend on ansi2knr.
5021 # Use a sneaky little hack to make it print nicely.
5022 &pretty_print_rule ('', '', @objects, ':', '$(ANSI2KNR)');
5026 # This is a yacc helper which is called whenever we have decided to
5027 # compile a yacc file.
5028 sub lang_yacc_target_hook
5030 my ($self, $aggregate, $output, $input) = @_;
5032 my $flag = $aggregate . "_YFLAGS";
5033 my $flagvar = var $flag;
5034 my $YFLAGSvar = var 'YFLAGS';
5035 if (($flagvar && $flagvar->variable_value =~ /$DASH_D_PATTERN/o)
5036 || ($YFLAGSvar && $YFLAGSvar->variable_value =~ /$DASH_D_PATTERN/o))
5038 (my $output_base = $output) =~ s/$KNOWN_EXTENSIONS_PATTERN$//;
5039 my $header = $output_base . '.h';
5041 # Found a `-d' that applies to the compilation of this file.
5042 # Add a dependency for the generated header file, and arrange
5043 # for that file to be included in the distribution.
5044 # FIXME: this fails for `nodist_*_SOURCES'.
5045 $output_rules .= ("${header}: $output\n"
5046 # Recover from removal of $header
5047 . "\t\@if test ! -f \$@; then \\\n"
5048 . "\t rm -f $output; \\\n"
5049 . "\t \$(MAKE) $output; \\\n"
5050 . "\telse :; fi\n");
5051 &push_dist_common ($header);
5052 # If the files are built in the build directory, then we want
5053 # to remove them with `make clean'. If they are in srcdir
5054 # they shouldn't be touched. However, we can't determine this
5055 # statically, and the GNU rules say that yacc/lex output files
5056 # should be removed by maintainer-clean. So that's what we
5058 $clean_files{$header} = MAINTAINER_CLEAN;
5060 # Erase $OUTPUT on `make maintainer-clean' (by GNU standards).
5061 # See the comment above for $HEADER.
5062 $clean_files{$output} = MAINTAINER_CLEAN;
5065 # This is a lex helper which is called whenever we have decided to
5066 # compile a lex file.
5067 sub lang_lex_target_hook
5069 my ($self, $aggregate, $output, $input) = @_;
5070 # If the files are built in the build directory, then we want to
5071 # remove them with `make clean'. If they are in srcdir they
5072 # shouldn't be touched. However, we can't determine this
5073 # statically, and the GNU rules say that yacc/lex output files
5074 # should be removed by maintainer-clean. So that's what we do.
5075 $clean_files{$output} = MAINTAINER_CLEAN;
5078 # This is a helper for both lex and yacc.
5079 sub yacc_lex_finish_helper
5081 return if defined $language_scratch{'lex-yacc-done'};
5082 $language_scratch{'lex-yacc-done'} = 1;
5084 # If there is more than one distinct yacc (resp lex) source file
5085 # in a given directory, then the `ylwrap' program is required to
5086 # allow parallel builds to work correctly. FIXME: for now, no
5088 require_conf_file ($configure_ac, FOREIGN, 'ylwrap');
5089 if ($config_aux_dir_set_in_configure_in)
5091 &define_variable ('YLWRAP', $config_aux_dir . "/ylwrap", INTERNAL);
5095 &define_variable ('YLWRAP', '$(top_srcdir)/ylwrap', INTERNAL);
5099 sub lang_yacc_finish
5101 return if defined $language_scratch{'yacc-done'};
5102 $language_scratch{'yacc-done'} = 1;
5104 reject_var 'YACCFLAGS', "`YACCFLAGS' obsolete; use `YFLAGS' instead";
5106 &yacc_lex_finish_helper
5107 if count_files_for_language ('yacc') > 1;
5113 return if defined $language_scratch{'lex-done'};
5114 $language_scratch{'lex-done'} = 1;
5116 &yacc_lex_finish_helper
5117 if count_files_for_language ('lex') > 1;
5121 # Given a hash table of linker names, pick the name that has the most
5122 # precedence. This is lame, but something has to have global
5123 # knowledge in order to eliminate the conflict. Add more linkers as
5129 foreach my $l (qw(GCJLINK CXXLINK F77LINK OBJCLINK))
5131 return $l if defined $linkers{$l};
5136 # Called to indicate that an extension was used.
5140 if (! defined $extension_seen{$ext})
5142 $extension_seen{$ext} = 1;
5146 ++$extension_seen{$ext};
5150 # Return the number of files seen for a given language. Knows about
5151 # special cases we care about. FIXME: this is hideous. We need
5152 # something that involves real language objects. For instance yacc
5153 # and yaccxx could both derive from a common yacc class which would
5154 # know about the strange ylwrap requirement. (Or better yet we could
5155 # just not support legacy yacc!)
5156 sub count_files_for_language
5161 if ($name eq 'yacc' || $name eq 'yaccxx')
5163 @names = ('yacc', 'yaccxx');
5165 elsif ($name eq 'lex' || $name eq 'lexxx')
5167 @names = ('lex', 'lexxx');
5175 foreach $name (@names)
5177 my $lang = $languages{$name};
5178 foreach my $ext (@{$lang->extensions})
5180 $r += $extension_seen{$ext}
5181 if defined $extension_seen{$ext};
5188 # Called to ask whether source files have been seen . If HEADERS is 1,
5189 # headers can be included.
5194 # count all the sources
5196 foreach my $val (values %extension_seen)
5203 $count -= count_files_for_language ('header');
5210 # register_language (%ATTRIBUTE)
5211 # ------------------------------
5212 # Register a single language.
5213 # Each %ATTRIBUTE is of the form ATTRIBUTE => VALUE.
5214 sub register_language (%)
5220 unless defined $option{'ansi'};
5221 $option{'autodep'} = 'no'
5222 unless defined $option{'autodep'};
5223 $option{'linker'} = ''
5224 unless defined $option{'linker'};
5225 $option{'flags'} = []
5226 unless defined $option{'flags'};
5227 $option{'output_extensions'} = sub { return ( '.$(OBJEXT)', '.lo' ) }
5228 unless defined $option{'output_extensions'};
5230 my $lang = new Language (%option);
5233 grep ($extension_map{$_} = $lang->name, @{$lang->extensions});
5234 $languages{$lang->name} = $lang;
5236 # Update the pattern of known extensions.
5237 accept_extensions (@{$lang->extensions});
5239 # Upate the $suffix_rule map.
5240 foreach my $suffix (@{$lang->extensions})
5242 foreach my $dest (&{$lang->output_extensions} ($suffix))
5244 ®ister_suffix_rule ('internal', $suffix, $dest);
5249 # derive_suffix ($EXT, $OBJ)
5250 # --------------------------
5251 # This function is used to find a path from a user-specified suffix $EXT
5252 # to $OBJ or to some other suffix we recognize internally, e.g. `cc'.
5253 sub derive_suffix ($$)
5255 my ($source_ext, $obj) = @_;
5257 while (! $extension_map{$source_ext}
5258 && $source_ext ne $obj
5259 && exists $suffix_rules->{$source_ext}
5260 && exists $suffix_rules->{$source_ext}{$obj})
5262 $source_ext = $suffix_rules->{$source_ext}{$obj}[0];
5269 ################################################################
5271 # Pretty-print something and append to output_rules.
5272 sub pretty_print_rule
5274 $output_rules .= &makefile_wrap (@_);
5278 ################################################################
5281 ## -------------------------------- ##
5282 ## Handling the conditional stack. ##
5283 ## -------------------------------- ##
5287 # make_conditional_string ($NEGATE, $COND)
5288 # ----------------------------------------
5289 sub make_conditional_string ($$)
5291 my ($negate, $cond) = @_;
5292 $cond = "${cond}_TRUE"
5293 unless $cond =~ /^TRUE|FALSE$/;
5294 $cond = Automake::Condition::conditional_negate ($cond)
5301 # cond_stack_if ($NEGATE, $COND, $WHERE)
5302 # --------------------------------------
5303 sub cond_stack_if ($$$)
5305 my ($negate, $cond, $where) = @_;
5307 error $where, "$cond does not appear in AM_CONDITIONAL"
5308 if ! $configure_cond{$cond} && $cond !~ /^TRUE|FALSE$/;
5310 push (@cond_stack, make_conditional_string ($negate, $cond));
5312 return new Automake::Condition (@cond_stack);
5317 # cond_stack_else ($NEGATE, $COND, $WHERE)
5318 # ----------------------------------------
5319 sub cond_stack_else ($$$)
5321 my ($negate, $cond, $where) = @_;
5325 error $where, "else without if";
5329 $cond_stack[$#cond_stack] =
5330 Automake::Condition::conditional_negate ($cond_stack[$#cond_stack]);
5332 # If $COND is given, check against it.
5335 $cond = make_conditional_string ($negate, $cond);
5337 error ($where, "else reminder ($negate$cond) incompatible with "
5338 . "current conditional: $cond_stack[$#cond_stack]")
5339 if $cond_stack[$#cond_stack] ne $cond;
5342 return new Automake::Condition (@cond_stack);
5347 # cond_stack_endif ($NEGATE, $COND, $WHERE)
5348 # -----------------------------------------
5349 sub cond_stack_endif ($$$)
5351 my ($negate, $cond, $where) = @_;
5356 error $where, "endif without if";
5360 # If $COND is given, check against it.
5363 $cond = make_conditional_string ($negate, $cond);
5365 error ($where, "endif reminder ($negate$cond) incompatible with "
5366 . "current conditional: $cond_stack[$#cond_stack]")
5367 if $cond_stack[$#cond_stack] ne $cond;
5372 return new Automake::Condition (@cond_stack);
5379 ## ------------------------ ##
5380 ## Handling the variables. ##
5381 ## ------------------------ ##
5385 # target_conditions ($TARGET)
5386 # ---------------------------
5387 # Get the list of conditions that a target is defined with.
5388 sub target_conditions ($)
5391 my @conds = keys %{$targets{$target}};
5392 return new Automake::DisjConditions @conds;
5396 # &define_pretty_variable ($VAR, $COND, $WHERE, @VALUE)
5397 # -----------------------------------------------------
5398 # Like define_variable, but the value is a list, and the variable may
5399 # be defined conditionally. The second argument is the Condition
5400 # under which the value should be defined; this should be the empty
5401 # string to define the variable unconditionally. The third argument
5402 # is a list holding the values to use for the variable. The value is
5403 # pretty printed in the output file.
5404 sub define_pretty_variable ($$$@)
5406 my ($var, $cond, $where, @value) = @_;
5408 if (! vardef ($var, $cond))
5410 Automake::Variable::define ($var, VAR_AUTOMAKE, '', $cond, "@value",
5411 '', $where, VAR_PRETTY);
5412 rvar ($var)->rdef ($cond)->set_seen;
5417 # define_variable ($VAR, $VALUE, $WHERE)
5418 # --------------------------------------
5419 # Define a new user variable VAR to VALUE, but only if not already defined.
5420 sub define_variable ($$$)
5422 my ($var, $value, $where) = @_;
5423 define_pretty_variable ($var, TRUE, $where, $value);
5427 # define_files_variable ($VAR, \@BASENAME, $EXTENSION, $WHERE)
5428 # -----------------------------------------------------------
5429 # Define the $VAR which content is the list of file names composed of
5430 # a @BASENAME and the $EXTENSION.
5431 sub define_files_variable ($\@$$)
5433 my ($var, $basename, $extension, $where) = @_;
5434 define_variable ($var,
5435 join (' ', map { "$_.$extension" } @$basename),
5440 # Like define_variable, but define a variable to be the configure
5441 # substitution by the same name.
5442 sub define_configure_variable ($)
5446 my $pretty = VAR_ASIS;
5447 my $owner = VAR_CONFIGURE;
5449 # Do not output the ANSI2KNR configure variable -- we AC_SUBST
5450 # it in protos.m4, but later redefine it elsewhere. This is
5451 # pretty hacky. We also don't output AMDEPBACKSLASH: it might
5452 # be subst'd by `\', which certainly would not be appreciated by
5454 if ($var eq 'ANSI2KNR' || $var eq 'AMDEPBACKSLASH')
5456 $pretty = VAR_SILENT;
5457 $owner = VAR_AUTOMAKE;
5460 Automake::Variable::define ($var, $owner, '', TRUE, subst $var,
5461 '', $configure_vars{$var}, $pretty);
5465 # define_compiler_variable ($LANG)
5466 # --------------------------------
5467 # Define a compiler variable. We also handle defining the `LT'
5468 # version of the command when using libtool.
5469 sub define_compiler_variable ($)
5473 my ($var, $value) = ($lang->compiler, $lang->compile);
5474 &define_variable ($var, $value, INTERNAL);
5475 &define_variable ("LT$var", "\$(LIBTOOL) --mode=compile $value", INTERNAL)
5480 # define_linker_variable ($LANG)
5481 # ------------------------------
5482 # Define linker variables.
5483 sub define_linker_variable ($)
5487 my ($var, $value) = ($lang->lder, $lang->ld);
5489 &define_variable ($lang->lder, $lang->ld, INTERNAL);
5490 # CCLINK = $(CCLD) blah blah...
5491 &define_variable ($lang->linker,
5492 ((var ('LIBTOOL') ? '$(LIBTOOL) --mode=link ' : '')
5497 ################################################################
5499 ## ---------------- ##
5500 ## Handling rules. ##
5501 ## ---------------- ##
5503 sub register_suffix_rule ($$$)
5505 my ($where, $src, $dest) = @_;
5507 verb "Sources ending in $src become $dest";
5508 push @suffixes, $src, $dest;
5510 # When tranforming sources to objects, Automake uses the
5511 # %suffix_rules to move from each source extension to
5512 # `.$(OBJEXT)', not to `.o' or `.obj'. However some people
5513 # define suffix rules for `.o' or `.obj', so internally we will
5514 # consider these extensions equivalent to `.$(OBJEXT)'. We
5515 # CANNOT rewrite the target (i.e., automagically replace `.o'
5516 # and `.obj' by `.$(OBJEXT)' in the output), or warn the user
5517 # that (s)he'd better use `.$(OBJEXT)', because Automake itself
5518 # output suffix rules for `.o' or `.obj'...
5519 $dest = '.$(OBJEXT)' if ($dest eq '.o' || $dest eq '.obj');
5521 # Reading the comments near the declaration of $suffix_rules might
5522 # help to understand the update of $suffix_rules that follows...
5524 # Register $dest as a possible destination from $src.
5525 # We might have the create the \hash.
5526 if (exists $suffix_rules->{$src})
5528 $suffix_rules->{$src}{$dest} = [ $dest, 1 ];
5532 $suffix_rules->{$src} = { $dest => [ $dest, 1 ] };
5535 # If we know how to transform $dest in something else, then
5536 # we know how to transform $src in that "something else".
5537 if (exists $suffix_rules->{$dest})
5539 for my $dest2 (keys %{$suffix_rules->{$dest}})
5541 my $dist = $suffix_rules->{$dest}{$dest2}[1] + 1;
5542 # Overwrite an existing $src->$dest2 path only if
5543 # the path via $dest which is shorter.
5544 if (! exists $suffix_rules->{$src}{$dest2}
5545 || $suffix_rules->{$src}{$dest2}[1] > $dist)
5547 $suffix_rules->{$src}{$dest2} = [ $dest, $dist ];
5552 # Similarly, any extension that can be derived into $src
5553 # can be derived into the same extenstions as $src can.
5554 my @dest2 = keys %{$suffix_rules->{$src}};
5555 for my $src2 (keys %$suffix_rules)
5557 if (exists $suffix_rules->{$src2}{$src})
5559 for my $dest2 (@dest2)
5561 my $dist = $suffix_rules->{$src}{$dest2} + 1;
5562 # Overwrite an existing $src2->$dest2 path only if
5563 # the path via $src is shorter.
5564 if (! exists $suffix_rules->{$src2}{$dest2}
5565 || $suffix_rules->{$src2}{$dest2}[1] > $dist)
5567 $suffix_rules->{$src2}{$dest2} = [ $src, $dist ];
5575 # rule_define ($TARGET, $SOURCE, $OWNER, $COND, $WHERE)
5576 # -----------------------------------------------------
5577 # Define a new rule. $TARGET is the rule name. $SOURCE
5578 # is the filename the rule comes from. $OWNER is the
5579 # owner of the rule (TARGET_AUTOMAKE or TARGET_USER).
5580 # $COND is the Condition under which the rule is defined.
5581 # $WHERE is the Location where the rule is defined.
5582 # Returns a (possibly empty) list of Conditions where the rule
5583 # should be defined.
5584 sub rule_define ($$$$$)
5586 my ($target, $source, $owner, $cond, $where) = @_;
5588 prog_error "$where is not a reference"
5590 prog_error "$cond is not a reference"
5593 # Don't even think about defining a rule in condition FALSE.
5594 return () if $cond == FALSE;
5596 # For now `foo:' will override `foo$(EXEEXT):'. This is temporary,
5597 # though, so we emit a warning.
5598 (my $noexe = $target) =~ s,\$\(EXEEXT\)$,,;
5599 if ($noexe ne $target
5600 && exists $targets{$noexe}
5601 && exists $targets{$noexe}{$cond}
5602 && $target_name{$noexe}{$cond} ne $target)
5604 # The no-exeext option enables this feature.
5605 if (! defined $options{'no-exeext'})
5607 msg ('obsolete', $targets{$noexe}{$cond},
5608 "deprecated feature: target `$noexe' overrides "
5609 . "`$noexe\$(EXEEXT)'\n"
5610 . "change your target to read `$noexe\$(EXEEXT)'");
5611 msg ('obsolete', $where, "target `$target' was defined here");
5613 # Don't `return ()' now, as this might hide target clashes
5617 # For now on, strip off $(EXEEXT) from $target, so we can diagnose
5618 # a clash if `ctags$(EXEEXT):' is redefined after `ctags:'.
5619 my $realtarget = $target;
5622 # A GNU make-style pattern rule has a single "%" in the target name.
5623 msg ('portability', $where,
5624 "`%'-style pattern rules are a GNU make extension")
5625 if $target =~ /^[^%]*%[^%]*$/;
5627 # Diagnose target redefinitions.
5628 if (exists $target_source{$target}{$cond})
5631 prog_error ("\$target_source{$target}{$cond} exists, but \$target_owner"
5633 unless exists $target_owner{$target}{$cond};
5634 prog_error ("\$target_source{$target}{$cond} exists, but \$targets"
5636 unless exists $targets{$target}{$cond};
5637 prog_error ("\$target_source{$target}{$cond} exists, but \$target_name"
5639 unless exists $target_name{$target}{$cond};
5641 my $oldowner = $target_owner{$target}{$cond};
5643 # Don't mention true conditions in diagnostics.
5645 $cond == TRUE ? '' : " in condition `" . $cond->human . "'";
5647 if ($owner == TARGET_USER)
5649 if ($oldowner == TARGET_USER)
5651 # Ignore `%'-style pattern rules. We'd need the
5652 # dependencies to detect duplicates, and they are
5653 # already diagnosed as unportable by -Wportability.
5654 if ($target !~ /^[^%]*%[^%]*$/)
5656 ## FIXME: Presently we can't diagnose duplcate user rules
5657 ## because we doesn't distinguish rules with commands
5658 ## from rules that only add dependencies. E.g.,
5661 ## is legitimate. (This is phony.test.)
5663 # msg ('syntax', $where,
5664 # "redefinition of `$target'$condmsg...", partial => 1);
5665 # msg_cond_target ('syntax', $cond, $target,
5666 # "... `$target' previously defined here");
5668 # Return so we don't redefine the rule in our tables,
5669 # don't check for ambiguous condition, etc. The rule
5670 # will be output anyway beauce &read_am_file ignore the
5676 # Since we parse the user Makefile.am before reading
5677 # the Automake fragments, this condition should never happen.
5678 prog_error ("user target `$target' seen after Automake's "
5679 . "definition\nfrom `$targets{$target}$condmsg'");
5682 else # $owner == TARGET_AUTOMAKE
5684 if ($oldowner == TARGET_USER)
5686 # -am targets listed in %dependencies support a -local
5687 # variant. If the user tries to override TARGET or
5688 # TARGET-am for which there exists a -local variant,
5689 # just tell the user to use it.
5693 if (exists $dependencies{"$noam-am"})
5695 $hint = "consider using $target-local instead of $target";
5698 msg_cond_target ('override', $cond, $target,
5699 "user target `$target' defined here"
5700 . "$condmsg...", partial => 1);
5701 msg ('override', $where,
5702 "... overrides Automake target `$target' defined here",
5704 msg_cond_target ('override', $cond, $target, $hint)
5707 # Don't overwrite the user definition of TARGET.
5710 else # $oldowner == TARGET_AUTOMAKE
5712 # Automake should ignore redefinitions of its own
5713 # rules if they came from the same file. This makes
5714 # it easier to process a Makefile fragment several times.
5715 # Hower it's an error if the target is defined in many
5716 # files. E.g., the user might be using bin_PROGRAMS = ctags
5717 # which clashes with our `ctags' rule.
5718 # (It would be more accurate if we had a way to compare
5719 # the *content* of both rules. Then $targets_source would
5721 my $oldsource = $target_source{$target}{$cond};
5722 return () if $source eq $oldsource;
5724 msg ('syntax', $where, "redefinition of `$target'$condmsg...",
5726 msg_cond_target ('syntax', $cond, $target,
5727 "... `$target' previously defined here");
5732 prog_error ("Unreachable place reached.");
5735 # Conditions for which the rule should be defined.
5738 # Check ambiguous conditional definitions.
5739 my ($message, $ambig_cond) =
5740 condition_ambiguous_p ($target, $cond, target_conditions ($target));
5741 if ($message) # We have an ambiguty.
5743 if ($owner == TARGET_USER)
5745 # For user rules, just diagnose the ambiguity.
5746 msg 'syntax', $where, "$message ...", partial => 1;
5747 msg_cond_target ('syntax', $ambig_cond, $target,
5748 "... `$target' previously defined here");
5753 # FIXME: for Automake rules, we can't diagnose ambiguities yet.
5754 # The point is that Automake doesn't propagate conditions
5755 # everywhere. For instance &handle_PROGRAMS doesn't care if
5756 # bin_PROGRAMS was defined conditionally or not.
5757 # On the following input
5762 # bin_PROGRAMS = foo
5764 # &handle_PROGRAMS will attempt to define a `foo:' rule
5765 # in condition TRUE (which conflicts with COND1). Fixing
5766 # this in &handle_PROGRAMS and siblings seems hard: you'd
5767 # have to explain &file_contents what to do with a
5768 # condition. So for now we do our best *here*. If `foo:'
5769 # was already defined in condition COND1 and we want to define
5770 # it in condition TRUE, then define it only in condition !COND1.
5771 # (See cond14.test and cond15.test for some test cases.)
5772 my $defined_conds = target_conditions ($target);
5774 for my $undefined_cond ($defined_conds->invert->conds)
5776 push @conds, $cond->merge ($undefined_cond);
5778 # No conditions left to define the rule.
5779 # Warn, because our workaround is meaningless in this case.
5780 if (scalar @conds == 0)
5782 msg 'syntax', $where, "$message ...", partial => 1;
5783 msg_cond_target ('syntax', $ambig_cond, $target,
5784 "... `$target' previously defined here");
5790 # Finally define this rule.
5793 $targets{$target}{$c} = $where->clone;
5794 $target_source{$target}{$c} = $source;
5795 $target_owner{$target}{$c} = $owner;
5796 $target_name{$target}{$c} = $realtarget;
5799 # We honor inference rules with multiple targets because many
5800 # make support this and people use it. However this is disallowed
5801 # by POSIX. We'll print a warning later.
5802 my $target_count = 0;
5803 my $inference_rule_count = 0;
5804 for my $t (split (' ', $target))
5807 # Check the rule for being a suffix rule. If so, store in a hash.
5808 # Either it's a rule for two known extensions...
5809 if ($t =~ /^($KNOWN_EXTENSIONS_PATTERN)($KNOWN_EXTENSIONS_PATTERN)$/
5810 # ...or it's a rule with unknown extensions (.i.e, the rule
5811 # looks like `.foo.bar:' but `.foo' or `.bar' are not
5812 # declared in SUFFIXES and are not known language
5813 # extensions). Automake will complete SUFFIXES from
5814 # @suffixes automatically (see handle_footer).
5815 || ($t =~ /$SUFFIX_RULE_PATTERN/o && accept_extensions($1)))
5817 ++$inference_rule_count;
5818 register_suffix_rule ($where, $1, $2);
5822 # POSIX allow multiple targets befor the colon, but disallow
5823 # definitions of multiple Inference rules. It's also
5824 # disallowed to mix plain targets with inference rules.
5825 msg ('portability', $where,
5826 "Inference rules can have only one target before the colon (POSIX).")
5827 if $inference_rule_count > 0 && $target_count > 1;
5833 # See if a target exists.
5837 return exists $targets{$target};
5841 ################################################################
5843 # &check_trailing_slash ($WHERE, $LINE)
5844 # --------------------------------------
5845 # Return 1 iff $LINE ends with a slash.
5846 # Might modify $LINE.
5847 sub check_trailing_slash ($\$)
5849 my ($where, $line) = @_;
5851 # Ignore `##' lines.
5852 return 0 if $$line =~ /$IGNORE_PATTERN/o;
5854 # Catch and fix a common error.
5855 msg "syntax", $where, "whitespace following trailing backslash"
5856 if $$line =~ s/\\\s+\n$/\\\n/;
5858 return $$line =~ /\\$/;
5862 # &read_am_file ($AMFILE, $WHERE)
5863 # -------------------------------
5864 # Read Makefile.am and set up %contents. Simultaneously copy lines
5865 # from Makefile.am into $output_trailer, or define variables as
5866 # appropriate. NOTE we put rules in the trailer section. We want
5867 # user rules to come after our generated stuff.
5868 sub read_am_file ($$)
5870 my ($amfile, $where) = @_;
5872 my $am_file = new Automake::XFile ("< $amfile");
5873 verb "reading $amfile";
5880 use constant IN_VAR_DEF => 0;
5881 use constant IN_RULE_DEF => 1;
5882 use constant IN_COMMENT => 2;
5883 my $prev_state = IN_RULE_DEF;
5885 while ($_ = $am_file->getline)
5887 $where->set ("$amfile:$.");
5888 if (/$IGNORE_PATTERN/o)
5890 # Merely delete comments beginning with two hashes.
5892 elsif (/$WHITE_PATTERN/o)
5894 error $where, "blank line following trailing backslash"
5896 # Stick a single white line before the incoming macro or rule.
5899 # Flush all comments seen so far.
5902 $output_vars .= $comment;
5906 elsif (/$COMMENT_PATTERN/o)
5908 # Stick comments before the incoming macro or rule. Make
5909 # sure a blank line preceeds first block of comments.
5910 $spacing = "\n" unless $blank;
5912 $comment .= $spacing . $_;
5914 $prev_state = IN_COMMENT;
5920 $saw_bk = check_trailing_slash ($where, $_);
5923 # We save the conditional stack on entry, and then check to make
5924 # sure it is the same on exit. This lets us conditonally include
5926 my @saved_cond_stack = @cond_stack;
5927 my $cond = new Automake::Condition (@cond_stack);
5929 my $last_var_name = '';
5930 my $last_var_type = '';
5931 my $last_var_value = '';
5933 # FIXME: shouldn't use $_ in this loop; it is too big.
5936 $where->set ("$amfile:$.");
5938 # Make sure the line is \n-terminated.
5942 # Don't look at MAINTAINER_MODE_TRUE here. That shouldn't be
5943 # used by users. @MAINT@ is an anachronism now.
5944 $_ =~ s/\@MAINT\@//g
5945 unless $seen_maint_mode;
5947 my $new_saw_bk = check_trailing_slash ($where, $_);
5949 if (/$IGNORE_PATTERN/o)
5951 # Merely delete comments beginning with two hashes.
5953 elsif (/$WHITE_PATTERN/o)
5955 # Stick a single white line before the incoming macro or rule.
5957 error $where, "blank line following trailing backslash"
5960 elsif (/$COMMENT_PATTERN/o)
5962 # Stick comments before the incoming macro or rule.
5963 $comment .= $spacing . $_;
5965 error $where, "comment following trailing backslash"
5966 if $saw_bk && $comment eq '';
5967 $prev_state = IN_COMMENT;
5971 if ($prev_state == IN_RULE_DEF)
5973 my $cond = new Automake::Condition @cond_stack;
5974 $output_trailer .= $cond->subst_string;
5975 $output_trailer .= $_;
5977 elsif ($prev_state == IN_COMMENT)
5979 # If the line doesn't start with a `#', add it.
5980 # We do this because a continuated comment like
5984 # is not portable. BSD make doesn't honor
5985 # escaped newlines in comments.
5987 $comment .= $spacing . $_;
5989 else # $prev_state == IN_VAR_DEF
5991 $last_var_value .= ' '
5992 unless $last_var_value =~ /\s$/;
5993 $last_var_value .= $_;
5997 Automake::Variable::define ($last_var_name, VAR_MAKEFILE,
5998 $last_var_type, $cond,
5999 $last_var_value, $comment,
6000 $last_where, VAR_ASIS)
6002 $comment = $spacing = '';
6007 elsif (/$IF_PATTERN/o)
6009 $cond = cond_stack_if ($1, $2, $where);
6011 elsif (/$ELSE_PATTERN/o)
6013 $cond = cond_stack_else ($1, $2, $where);
6015 elsif (/$ENDIF_PATTERN/o)
6017 $cond = cond_stack_endif ($1, $2, $where);
6020 elsif (/$RULE_PATTERN/o)
6023 $prev_state = IN_RULE_DEF;
6025 # For now we have to output all definitions of user rules
6026 # and can't diagnose duplicates (see the comment in
6027 # rule_define). So we go on and ignore the return value.
6028 rule_define ($1, $amfile, TARGET_USER, $cond, $where);
6030 check_variable_expansions ($_, $where);
6032 $output_trailer .= $comment . $spacing;
6033 my $cond = new Automake::Condition @cond_stack;
6034 $output_trailer .= $cond->subst_string;
6035 $output_trailer .= $_;
6036 $comment = $spacing = '';
6038 elsif (/$ASSIGNMENT_PATTERN/o)
6040 # Found a macro definition.
6041 $prev_state = IN_VAR_DEF;
6042 $last_var_name = $1;
6043 $last_var_type = $2;
6044 $last_var_value = $3;
6045 $last_where = $where->clone;
6046 if ($3 ne '' && substr ($3, -1) eq "\\")
6048 # We preserve the `\' because otherwise the long lines
6049 # that are generated will be truncated by broken
6051 $last_var_value = $3 . "\n";
6056 Automake::Variable::define ($last_var_name, VAR_MAKEFILE,
6057 $last_var_type, $cond,
6058 $last_var_value, $comment,
6059 $last_where, VAR_ASIS)
6061 $comment = $spacing = '';
6064 elsif (/$INCLUDE_PATTERN/o)
6068 if ($path =~ s/^\$\(top_srcdir\)\///)
6070 push (@include_stack, "\$\(top_srcdir\)/$path");
6071 # Distribute any included file.
6073 # Always use the $(top_srcdir) prefix in DIST_COMMON,
6074 # otherwise OSF make will implicitely copy the included
6075 # file in the build tree during `make distdir' to satisfy
6077 # (subdircond2.test and subdircond3.test will fail.)
6078 push_dist_common ("\$\(top_srcdir\)/$path");
6082 $path =~ s/\$\(srcdir\)\///;
6083 push (@include_stack, "\$\(srcdir\)/$path");
6084 # Always use the $(srcdir) prefix in DIST_COMMON,
6085 # otherwise OSF make will implicitely copy the included
6086 # file in the build tree during `make distdir' to satisfy
6088 # (subdircond2.test and subdircond3.test will fail.)
6089 push_dist_common ("\$\(srcdir\)/$path");
6090 $path = $relative_dir . "/" . $path if $relative_dir ne '.';
6092 $where->push_context ("`$path' included from here");
6093 &read_am_file ($path, $where);
6094 $where->pop_context;
6098 # This isn't an error; it is probably a continued rule.
6099 # In fact, this is what we assume.
6100 $prev_state = IN_RULE_DEF;
6101 check_variable_expansions ($_, $where);
6102 $output_trailer .= $comment . $spacing;
6103 my $cond = new Automake::Condition @cond_stack;
6104 $output_trailer .= $cond->subst_string;
6105 $output_trailer .= $_;
6106 $comment = $spacing = '';
6107 error $where, "`#' comment at start of rule is unportable"
6108 if $_ =~ /^\t\s*\#/;
6111 $saw_bk = $new_saw_bk;
6112 $_ = $am_file->getline;
6115 $output_trailer .= $comment;
6117 error ($where, "trailing backslash on last line")
6120 error ($where, (@cond_stack ? "unterminated conditionals: @cond_stack"
6121 : "too many conditionals closed in include file"))
6122 if "@saved_cond_stack" ne "@cond_stack";
6126 # define_standard_variables ()
6127 # ----------------------------
6128 # A helper for read_main_am_file which initializes configure variables
6129 # and variables from header-vars.am.
6130 sub define_standard_variables
6132 my $saved_output_vars = $output_vars;
6133 my ($comments, undef, $rules) =
6134 file_contents_internal (1, "$libdir/am/header-vars.am",
6135 new Automake::Location);
6137 foreach my $var (sort keys %configure_vars)
6139 &define_configure_variable ($var);
6142 $output_vars .= $comments . $rules;
6145 # Read main am file.
6146 sub read_main_am_file
6150 # This supports the strange variable tricks we are about to play.
6151 prog_error (macros_dump () . "variable defined before read_main_am_file")
6152 if (scalar (variables) > 0);
6154 # Generate copyright header for generated Makefile.in.
6155 # We do discard the output of predefined variables, handled below.
6156 $output_vars = ("# $in_file_name generated by automake "
6157 . $VERSION . " from $am_file_name.\n");
6158 $output_vars .= '# ' . subst ('configure_input') . "\n";
6159 $output_vars .= $gen_copyright;
6161 # We want to predefine as many variables as possible. This lets
6162 # the user set them with `+=' in Makefile.am.
6163 &define_standard_variables;
6165 # Read user file, which might override some of our values.
6166 &read_am_file ($amfile, new Automake::Location);
6171 ################################################################
6174 # &flatten ($STRING)
6175 # ------------------
6176 # Flatten the $STRING and return the result.
6191 # &make_paragraphs ($MAKEFILE, [%TRANSFORM])
6192 # ------------------------------------------
6193 # Load a $MAKEFILE, apply the %TRANSFORM, and return it as a list of
6195 sub make_paragraphs ($%)
6197 my ($file, %transform) = @_;
6199 # Complete %transform with global options and make it a Perl
6202 "s/$IGNORE_PATTERN//gm;"
6203 . transform (%transform,
6205 'CYGNUS' => $options{'cygnus'},
6207 => $seen_maint_mode ? subst ('MAINTAINER_MODE_TRUE') : '',
6209 'BZIP2' => $options{'dist-bzip2'} || 0,
6210 'COMPRESS' => $options{'dist-tarZ'} || 0,
6211 'GZIP' => $options{'no-dist-gzip'} ? 0 : 1,
6212 'SHAR' => $options{'dist-shar'} || 0,
6213 'ZIP' => $options{'dist-zip'} || 0,
6215 'INSTALL-INFO' => !$options{'no-installinfo'},
6216 'INSTALL-MAN' => !$options{'no-installman'},
6217 'CK-NEWS' => $options{'check-news'} || 0,
6219 'SUBDIRS' => !! var ('SUBDIRS'),
6220 'TOPDIR' => backname ($relative_dir),
6221 'TOPDIR_P' => $relative_dir eq '.',
6222 'CONFIGURE-AC' => $configure_ac,
6224 'BUILD' => $seen_canonical == AC_CANONICAL_SYSTEM,
6225 'HOST' => $seen_canonical,
6226 'TARGET' => $seen_canonical == AC_CANONICAL_SYSTEM,
6228 'LIBTOOL' => !! var ('LIBTOOL'))
6229 # We don't need more than two consecutive new-lines.
6230 . 's/\n{3,}/\n\n/g';
6232 # Swallow the file and apply the COMMAND.
6233 my $fc_file = new Automake::XFile "< $file";
6235 verb "reading $file";
6236 my $saved_dollar_slash = $/;
6238 $_ = $fc_file->getline;
6239 $/ = $saved_dollar_slash;
6244 # Split at unescaped new lines.
6245 my @lines = split (/(?<!\\)\n/, $content);
6248 while (defined ($_ = shift @lines))
6250 my $paragraph = "$_";
6251 # If we are a rule, eat as long as we start with a tab.
6252 if (/$RULE_PATTERN/smo)
6254 while (defined ($_ = shift @lines) && $_ =~ /^\t/)
6256 $paragraph .= "\n$_";
6258 unshift (@lines, $_);
6261 # If we are a comments, eat as much comments as you can.
6262 elsif (/$COMMENT_PATTERN/smo)
6264 while (defined ($_ = shift @lines)
6265 && $_ =~ /$COMMENT_PATTERN/smo)
6267 $paragraph .= "\n$_";
6269 unshift (@lines, $_);
6272 push @res, $paragraph;
6281 # ($COMMENT, $VARIABLES, $RULES)
6282 # &file_contents_internal ($IS_AM, $FILE, $WHERE, [%TRANSFORM])
6283 # -------------------------------------------------------------
6284 # Return contents of a file from $libdir/am, automatically skipping
6285 # macros or rules which are already known. $IS_AM iff the caller is
6286 # reading an Automake file (as opposed to the user's Makefile.am).
6287 sub file_contents_internal ($$$%)
6289 my ($is_am, $file, $where, %transform) = @_;
6291 $where->set ($file);
6293 my $result_vars = '';
6294 my $result_rules = '';
6298 # The following flags are used to track rules spanning across
6299 # multiple paragraphs.
6300 my $is_rule = 0; # 1 if we are processing a rule.
6301 my $discard_rule = 0; # 1 if the current rule should not be output.
6303 # We save the conditional stack on entry, and then check to make
6304 # sure it is the same on exit. This lets us conditonally include
6306 my @saved_cond_stack = @cond_stack;
6307 my $cond = new Automake::Condition (@cond_stack);
6309 foreach (make_paragraphs ($file, %transform))
6311 # FIXME: no line number available.
6312 $where->set ($file);
6315 error $where, "blank line following trailing backslash:\n$_"
6317 error $where, "comment following trailing backslash:\n$_"
6323 # Stick empty line before the incoming macro or rule.
6326 elsif (/$COMMENT_PATTERN/mso)
6329 # Stick comments before the incoming macro or rule.
6333 # Handle inclusion of other files.
6334 elsif (/$INCLUDE_PATTERN/o)
6338 my $file = ($is_am ? "$libdir/am/" : '') . $1;
6339 $where->push_context ("`$file' included from here");
6341 my ($com, $vars, $rules)
6342 = file_contents_internal ($is_am, $file, $where, %transform);
6343 $where->pop_context;
6345 $result_vars .= $vars;
6346 $result_rules .= $rules;
6350 # Handling the conditionals.
6351 elsif (/$IF_PATTERN/o)
6353 $cond = cond_stack_if ($1, $2, $file);
6355 elsif (/$ELSE_PATTERN/o)
6357 $cond = cond_stack_else ($1, $2, $file);
6359 elsif (/$ENDIF_PATTERN/o)
6361 $cond = cond_stack_endif ($1, $2, $file);
6365 elsif (/$RULE_PATTERN/mso)
6369 # Separate relationship from optional actions: the first
6370 # `new-line tab" not preceded by backslash (continuation
6373 /^(.*?)(?:(?<!\\)\n(\t.*))?$/s;
6374 my ($relationship, $actions) = ($1, $2 || '');
6376 # Separate targets from dependencies: the first colon.
6377 $relationship =~ /^([^:]+\S+) *: *(.*)$/som;
6378 my ($targets, $dependencies) = ($1, $2);
6379 # Remove the escaped new lines.
6380 # I don't know why, but I have to use a tmp $flat_deps.
6381 my $flat_deps = &flatten ($dependencies);
6382 my @deps = split (' ', $flat_deps);
6384 foreach (split (' ' , $targets))
6386 # FIXME: 1. We are not robust to people defining several targets
6387 # at once, only some of them being in %dependencies. The
6388 # actions from the targets in %dependencies are usually generated
6389 # from the content of %actions, but if some targets in $targets
6390 # are not in %dependencies the ELSE branch will output
6391 # a rule for all $targets (i.e. the targets which are both
6392 # in %dependencies and $targets will have two rules).
6394 # FIXME: 2. The logic here is not able to output a
6395 # multi-paragraph rule several time (e.g. for each condition
6396 # it is defined for) because it only knows the first paragraph.
6398 # FIXME: 3. We are not robust to people defining a subset
6399 # of a previously defined "multiple-target" rule. E.g.
6400 # `foo:' after `foo bar:'.
6402 # Output only if not in FALSE.
6403 if (defined $dependencies{$_} && $cond != FALSE)
6405 &depend ($_, @deps);
6408 $actions{$_} .= "\n$actions";
6412 $actions{$_} = $actions;
6417 # Free-lance dependency. Output the rule for all the
6418 # targets instead of one by one.
6419 my @undefined_conds =
6420 rule_define ($targets, $file,
6421 $is_am ? TARGET_AUTOMAKE : TARGET_USER,
6423 for my $undefined_cond (@undefined_conds)
6425 my $condparagraph = $paragraph;
6426 $condparagraph =~ s/^/$undefined_cond->subst_string/gme;
6427 $result_rules .= "$spacing$comment$condparagraph\n";
6429 if (scalar @undefined_conds == 0)
6431 # Remember to discard next paragraphs
6432 # if they belong to this rule.
6433 # (but see also FIXME: #2 above.)
6436 $comment = $spacing = '';
6442 elsif (/$ASSIGNMENT_PATTERN/mso)
6444 my ($var, $type, $val) = ($1, $2, $3);
6445 error $where, "variable `$var' with trailing backslash"
6450 Automake::Variable::define ($var,
6451 $is_am ? VAR_AUTOMAKE : VAR_MAKEFILE,
6452 $type, $cond, $val, $comment, $where,
6456 $comment = $spacing = '';
6460 # This isn't an error; it is probably some tokens which
6461 # configure is supposed to replace, such as `@SET-MAKE@',
6462 # or some part of a rule cut by an if/endif.
6463 if (! $cond->false && ! ($is_rule && $discard_rule))
6465 s/^/$cond->subst_string/gme;
6466 $result_rules .= "$spacing$comment$_\n";
6468 $comment = $spacing = '';
6472 error ($where, @cond_stack ?
6473 "unterminated conditionals: @cond_stack" :
6474 "too many conditionals closed in include file")
6475 if "@saved_cond_stack" ne "@cond_stack";
6477 return ($comment, $result_vars, $result_rules);
6482 # &file_contents ($BASENAME, $WHERE, [%TRANSFORM])
6483 # ------------------------------------------------
6484 # Return contents of a file from $libdir/am, automatically skipping
6485 # macros or rules which are already known.
6486 sub file_contents ($$%)
6488 my ($basename, $where, %transform) = @_;
6489 my ($comments, $variables, $rules) =
6490 file_contents_internal (1, "$libdir/am/$basename.am", $where,
6492 return "$comments$variables$rules";
6497 # &transform (%PAIRS)
6498 # -------------------
6499 # For each ($TOKEN, $VAL) in %PAIRS produce a replacement expression
6500 # suitable for file_contents which:
6501 # - replaces %$TOKEN% with $VAL,
6502 # - enables/disables ?$TOKEN? and ?!$TOKEN?,
6503 # - replaces %?$TOKEN% with TRUE or FALSE.
6509 while (my ($token, $val) = each %pairs)
6511 $result .= "s/\Q%$token%\E/\Q$val\E/gm;";
6514 $result .= "s/\Q?$token?\E//gm;s/^.*\Q?!$token?\E.*\\n//gm;";
6515 $result .= "s/\Q%?$token%\E/TRUE/gm;";
6519 $result .= "s/\Q?!$token?\E//gm;s/^.*\Q?$token?\E.*\\n//gm;";
6520 $result .= "s/\Q%?$token%\E/FALSE/gm;";
6528 # &append_exeext ($MACRO)
6529 # -----------------------
6530 # Macro is an Automake magic macro which primary is PROGRAMS, e.g.
6531 # bin_PROGRAMS. Make sure these programs have $(EXEEXT) appended.
6532 sub append_exeext ($)
6536 prog_error "append_exeext ($macro)"
6537 unless $macro =~ /_PROGRAMS$/;
6539 transform_variable_recursively
6540 ($macro, $macro, 'am__EXEEXT', 0, INTERNAL,
6542 my ($subvar, $val, $cond, $full_cond) = @_;
6543 # Append $(EXEEXT) unless the user did it already.
6544 $val .= '$(EXEEXT)' unless $val =~ /\$\(EXEEXT\)$/;
6551 # &am_primary_prefixes ($PRIMARY, $CAN_DIST, @PREFIXES)
6552 # -----------------------------------------------------
6553 # Find all variable prefixes that are used for install directories. A
6554 # prefix `zar' qualifies iff:
6556 # * `zardir' is a variable.
6557 # * `zar_PRIMARY' is a variable.
6559 # As a side effect, it looks for misspellings. It is an error to have
6560 # a variable ending in a "reserved" suffix whose prefix is unknown, e.g.
6561 # "bin_PROGRAMS". However, unusual prefixes are allowed if a variable
6562 # of the same name (with "dir" appended) exists. For instance, if the
6563 # variable "zardir" is defined, then "zar_PROGRAMS" becomes valid.
6564 # This is to provide a little extra flexibility in those cases which
6566 sub am_primary_prefixes ($$@)
6568 my ($primary, $can_dist, @prefixes) = @_;
6571 my %valid = map { $_ => 0 } @prefixes;
6572 $valid{'EXTRA'} = 0;
6573 foreach my $varname (variables)
6575 my $var = var $varname;
6576 # Automake is allowed to define variables that look like primaries
6577 # but which aren't. E.g. INSTALL_sh_DATA.
6578 # Autoconf can also define variables like INSTALL_DATA, so
6579 # ignore all configure variables (at least those which are not
6580 # redefined in Makefile.am).
6581 # FIXME: We should make sure that these variables are not
6582 # conditionally defined (or else adjust the condition below).
6585 my $def = $var->def (TRUE);
6586 next if $def && $def->owner != VAR_MAKEFILE;
6589 if ($varname =~ /^(nobase_)?(dist_|nodist_)?(.*)_$primary$/)
6591 my ($base, $dist, $X) = ($1 || '', $2 || '', $3 || '');
6592 if ($dist ne '' && ! $can_dist)
6595 "invalid variable `$varname': `dist' is forbidden");
6597 # Standard directories must be explicitely allowed.
6598 elsif (! defined $valid{$X} && exists $standard_prefix{$X})
6601 "`${X}dir' is not a legitimate directory " .
6604 # A not explicitely valid directory is allowed if Xdir is defined.
6605 elsif (! defined $valid{$X} &&
6606 require_variables_for_variable ($varname,
6607 "`$varname' is used",
6610 # Nothing to do. Any error message has been output
6611 # by require_variables_for_variable.
6615 # Ensure all extended prefixes are actually used.
6616 $valid{"$base$dist$X"} = 1;
6621 # Return only those which are actually defined.
6622 return sort grep { var ($_ . '_' . $primary) } keys %valid;
6626 # Handle `where_HOW' variable magic. Does all lookups, generates
6627 # install code, and possibly generates code to define the primary
6628 # variable. The first argument is the name of the .am file to munge,
6629 # the second argument is the primary variable (e.g. HEADERS), and all
6630 # subsequent arguments are possible installation locations.
6632 # Returns list of [$location, $value] pairs, where
6633 # $value's are the values in all where_HOW variable, and $location
6634 # there associated location (the place here their parent variables were
6637 # FIXME: this should be rewritten to be cleaner. It should be broken
6638 # up into multiple functions.
6640 # Usage is: am_install_var (OPTION..., file, HOW, where...)
6647 my $default_dist = 0;
6650 if ($args[0] eq '-noextra')
6654 elsif ($args[0] eq '-candist')
6658 elsif ($args[0] eq '-defaultdist')
6663 elsif ($args[0] !~ /^-/)
6670 my ($file, $primary, @prefix) = @args;
6672 # Now that configure substitutions are allowed in where_HOW
6673 # variables, it is an error to actually define the primary. We
6674 # allow `JAVA', as it is customarily used to mean the Java
6675 # interpreter. This is but one of several Java hacks. Similarly,
6676 # `PYTHON' is customarily used to mean the Python interpreter.
6677 reject_var $primary, "`$primary' is an anachronism"
6678 unless $primary eq 'JAVA' || $primary eq 'PYTHON';
6680 # Get the prefixes which are valid and actually used.
6681 @prefix = am_primary_prefixes ($primary, $can_dist, @prefix);
6683 # If a primary includes a configure substitution, then the EXTRA_
6684 # form is required. Otherwise we can't properly do our job.
6690 # True if the iteration is the first one. Used for instance to
6691 # output parts of the associated file only once.
6693 foreach my $X (@prefix)
6695 my $nodir_name = $X;
6696 my $one_name = $X . '_' . $primary;
6697 my $one_var = var $one_name;
6699 my $strip_subdir = 1;
6700 # If subdir prefix should be preserved, do so.
6701 if ($nodir_name =~ /^nobase_/)
6704 $nodir_name =~ s/^nobase_//;
6707 # If files should be distributed, do so.
6711 $dist_p = (($default_dist && $nodir_name !~ /^nodist_/)
6712 || (! $default_dist && $nodir_name =~ /^dist_/));
6713 $nodir_name =~ s/^(dist|nodist)_//;
6717 # Use the location of the currently processed variable.
6718 # We are not processing a particular condition, so pick the first
6720 my $tmpcond = $one_var->conditions->one_cond;
6721 my $where = $one_var->rdef ($tmpcond)->location->clone;
6723 # Append actual contents of where_PRIMARY variable to
6724 # @result, skipping @substitutions@.
6725 foreach my $locvals ($one_var->loc_and_value_as_list_recursive ('all'))
6727 my ($loc, $value) = @$locvals;
6728 # Skip configure substitutions.
6729 if ($value =~ /^\@.*\@$/)
6731 if ($nodir_name eq 'EXTRA')
6734 "`$one_name' contains configure substitution, "
6737 # Check here to make sure variables defined in
6738 # configure.ac do not imply that EXTRA_PRIMARY
6740 elsif (! defined $configure_vars{$one_name})
6742 $require_extra = $one_name
6748 push (@result, $locvals);
6751 # A blatant hack: we rewrite each _PROGRAMS primary to include
6753 append_exeext ($one_name)
6754 if $primary eq 'PROGRAMS';
6755 # "EXTRA" shouldn't be used when generating clean targets,
6756 # all, or install targets. We used to warn if EXTRA_FOO was
6757 # defined uselessly, but this was annoying.
6759 if $nodir_name eq 'EXTRA';
6761 if ($nodir_name eq 'check')
6763 push (@check, '$(' . $one_name . ')');
6767 push (@used, '$(' . $one_name . ')');
6770 # Is this to be installed?
6771 my $install_p = $nodir_name ne 'noinst' && $nodir_name ne 'check';
6773 # If so, with install-exec? (or install-data?).
6774 my $exec_p = ($nodir_name =~ /$EXEC_DIR_PATTERN/o);
6776 my $check_options_p = $install_p
6777 && defined $options{'std-options'};
6779 # Use the location of the currently processed variable as context.
6780 $where->push_context ("while processing `$one_name'");
6782 # Singular form of $PRIMARY.
6783 (my $one_primary = $primary) =~ s/S$//;
6784 $output_rules .= &file_contents ($file, $where,
6787 PRIMARY => $primary,
6788 ONE_PRIMARY => $one_primary,
6790 NDIR => $nodir_name,
6791 BASE => $strip_subdir,
6794 INSTALL => $install_p,
6796 'CK-OPTS' => $check_options_p);
6801 # The JAVA variable is used as the name of the Java interpreter.
6802 # The PYTHON variable is used as the name of the Python interpreter.
6803 if (@used && $primary ne 'JAVA' && $primary ne 'PYTHON')
6806 define_pretty_variable ($primary, TRUE, INTERNAL, @used);
6807 $output_vars .= "\n";
6810 err_var ($require_extra,
6811 "`$require_extra' contains configure substitution,\n"
6812 . "but `EXTRA_$primary' not defined")
6813 if ($require_extra && ! var ('EXTRA_' . $primary));
6815 # Push here because PRIMARY might be configure time determined.
6816 push (@all, '$(' . $primary . ')')
6817 if @used && $primary ne 'JAVA' && $primary ne 'PYTHON';
6819 # Make the result unique. This lets the user use conditionals in
6820 # a natural way, but still lets us program lazily -- we don't have
6821 # to worry about handling a particular object more than once.
6822 # We will keep only one location per object.
6824 for my $pair (@result)
6826 my ($loc, $val) = @$pair;
6827 $result{$val} = $loc;
6829 my @l = sort keys %result;
6830 return map { [$result{$_}->clone, $_] } @l;
6834 ################################################################
6836 # Each key in this hash is the name of a directory holding a
6837 # Makefile.in. These variables are local to `is_make_dir'.
6839 my $make_dirs_set = 0;
6844 if (! $make_dirs_set)
6846 foreach my $iter (@configure_input_files)
6848 $make_dirs{dirname ($iter)} = 1;
6850 # We also want to notice Makefile.in's.
6851 foreach my $iter (@other_input_files)
6853 if ($iter =~ /Makefile\.in$/)
6855 $make_dirs{dirname ($iter)} = 1;
6860 return defined $make_dirs{$dir};
6863 ################################################################
6865 # This variable is local to the "require file" set of functions.
6866 my @require_file_paths = ();
6869 # &maybe_push_required_file ($DIR, $FILE, $FULLFILE)
6870 # --------------------------------------------------
6871 # See if we want to push this file onto dist_common. This function
6872 # encodes the rules for deciding when to do so.
6873 sub maybe_push_required_file
6875 my ($dir, $file, $fullfile) = @_;
6877 if ($dir eq $relative_dir)
6879 push_dist_common ($file);
6882 elsif ($relative_dir eq '.' && ! &is_make_dir ($dir))
6884 # If we are doing the topmost directory, and the file is in a
6885 # subdir which does not have a Makefile, then we distribute it
6887 push_dist_common ($fullfile);
6894 # &require_file_internal ($WHERE, $MYSTRICT, @FILES)
6895 # --------------------------------------------------
6896 # Verify that the file must exist in the current directory.
6897 # $MYSTRICT is the strictness level at which this file becomes required.
6899 # Must set require_file_paths before calling this function.
6900 # require_file_paths is set to hold a single directory (the one in
6901 # which the first file was found) before return.
6902 sub require_file_internal ($$@)
6904 my ($where, $mystrict, @files) = @_;
6906 foreach my $file (@files)
6914 my $dangling_sym = 0;
6915 foreach my $dir (@require_file_paths)
6917 $fullfile = $dir . "/" . $file;
6918 $errdir = $dir unless $errdir;
6920 # Use different name for "error filename". Otherwise on
6921 # an error the bad file will be reported as e.g.
6922 # `../../install-sh' when using the default
6924 $errfile = $errdir . '/' . $file;
6926 if (-l $fullfile && ! -f $fullfile)
6931 elsif (-f $fullfile)
6934 maybe_push_required_file ($dir, $file, $fullfile);
6940 # `--force-missing' only has an effect if `--add-missing' is
6942 if ($found_it && (! $add_missing || ! $force_missing))
6944 # Prune the path list.
6945 @require_file_paths = $save_dir;
6949 # If we've already looked for it, we're done. You might
6950 # wonder why we don't do this before searching for the
6951 # file. If we do that, then something like
6952 # AC_OUTPUT(subdir/foo foo) will fail to put foo.in into
6956 next if defined $require_file_found{$fullfile};
6957 $require_file_found{$fullfile} = 1;
6960 if ($strictness >= $mystrict)
6962 if ($dangling_sym && $add_missing)
6970 # Only install missing files according to our desired
6972 my $message = "required file `$errfile' not found";
6975 if (-f ("$libdir/$file"))
6979 # Install the missing file. Symlink if we
6980 # can, copy if we must. Note: delete the file
6981 # first, in case it is a dangling symlink.
6982 $message = "installing `$errfile'";
6983 # Windows Perl will hang if we try to delete a
6984 # file that doesn't exist.
6985 unlink ($errfile) if -f $errfile;
6986 if ($symlink_exists && ! $copy_missing)
6988 if (! symlink ("$libdir/$file", $errfile))
6991 $trailer = "; error while making link: $!";
6994 elsif (system ('cp', "$libdir/$file", $errfile))
6997 $trailer = "\n error while copying";
7001 if (! maybe_push_required_file (dirname ($errfile),
7006 # We have added the file but could not push it
7007 # into DIST_COMMON (probably because this is
7008 # an auxiliary file and we are not processing
7009 # the top level Makefile). This is unfortunate,
7010 # since it means we are using a file which is not
7013 # Get Automake to be run again: on the second
7014 # run the file will be found, and pushed into
7015 # the toplevel DIST_COMMON automatically.
7016 $automake_needs_to_reprocess_all_files = 1;
7020 # Prune the path list.
7021 @require_file_paths = &dirname ($errfile);
7024 # If --force-missing was specified, and we have
7025 # actually found the file, then do nothing.
7027 if $found_it && $force_missing;
7029 # If we couldn' install the file, but it is a target in
7030 # the Makefile, don't print anything. This allows files
7031 # like README, AUTHORS, or THANKS to be generated.
7033 if !$suppress && target_defined ($file);
7035 msg ($suppress ? 'note' : 'error', $where, "$message$trailer");
7041 # &require_file ($WHERE, $MYSTRICT, @FILES)
7042 # -----------------------------------------
7043 sub require_file ($$@)
7045 my ($where, $mystrict, @files) = @_;
7046 @require_file_paths = $relative_dir;
7047 require_file_internal ($where, $mystrict, @files);
7050 # &require_file_with_macro ($COND, $MACRO, $MYSTRICT, @FILES)
7051 # -----------------------------------------------------------
7052 sub require_file_with_macro ($$$@)
7054 my ($cond, $macro, $mystrict, @files) = @_;
7055 $macro = rvar ($macro) unless ref $macro;
7056 require_file ($macro->rdef ($cond)->location, $mystrict, @files);
7060 # &require_conf_file ($WHERE, $MYSTRICT, @FILES)
7061 # ----------------------------------------------
7062 # Looks in configuration path, as specified by AC_CONFIG_AUX_DIR.
7063 sub require_conf_file ($$@)
7065 my ($where, $mystrict, @files) = @_;
7066 @require_file_paths = @config_aux_path;
7067 require_file_internal ($where, $mystrict, @files);
7068 my $dir = $require_file_paths[0];
7069 @config_aux_path = @require_file_paths;
7070 # Avoid unsightly '/.'s.
7071 $config_aux_dir = '$(top_srcdir)' . ($dir eq '.' ? "" : "/$dir");
7075 # &require_conf_file_with_macro ($COND, $MACRO, $MYSTRICT, @FILES)
7076 # ----------------------------------------------------------------
7077 sub require_conf_file_with_macro ($$$@)
7079 my ($cond, $macro, $mystrict, @files) = @_;
7080 require_conf_file (rvar ($macro)->rdef ($cond)->location,
7084 ################################################################
7086 # &require_build_directory ($DIRECTORY)
7087 # ------------------------------------
7088 # Emit rules to create $DIRECTORY if needed, and return
7089 # the file that any target requiring this directory should be made
7091 sub require_build_directory ($)
7093 my $directory = shift;
7094 my $dirstamp = "$directory/\$(am__dirstamp)";
7096 # Don't emit the rule twice.
7097 if (! defined $directory_map{$directory})
7099 $directory_map{$directory} = 1;
7101 # Set a variable for the dirstamp basename.
7102 define_pretty_variable ('am__dirstamp', TRUE, INTERNAL,
7103 '$(am__leading_dot)dirstamp');
7105 # Directory must be removed by `make distclean'.
7106 $clean_files{$dirstamp} = DIST_CLEAN;
7108 $output_rules .= ("$dirstamp:\n"
7109 . "\t\@\$(mkinstalldirs) $directory\n"
7110 . "\t\@: > $dirstamp\n");
7116 # &require_build_directory_maybe ($FILE)
7117 # --------------------------------------
7118 # If $FILE lies in a subdirectory, emit a rule to create this
7119 # directory and return the file that $FILE should be made
7120 # dependent upon. Otherwise, just return the empty string.
7121 sub require_build_directory_maybe ($)
7124 my $directory = dirname ($file);
7126 if ($directory ne '.')
7128 return require_build_directory ($directory);
7136 ################################################################
7138 # Push a list of files onto dist_common.
7139 sub push_dist_common
7141 prog_error "push_dist_common run after handle_dist"
7142 if $handle_dist_run;
7143 Automake::Variable::define ('DIST_COMMON', VAR_AUTOMAKE, '+', TRUE, "@_",
7144 '', INTERNAL, VAR_PRETTY);
7148 ################################################################
7150 # Generate a Makefile.in given the name of the corresponding Makefile and
7151 # the name of the file output by config.status.
7152 sub generate_makefile
7154 my ($output, $makefile) = @_;
7156 # Reset all the Makefile.am related variables.
7157 initialize_per_input;
7159 # Any warning setting now local to this Makefile.am.
7161 # AUTOMAKE_OPTIONS can contains -W flags to disable or enable
7162 # warnings for this file. So hold any warning issued before
7163 # we have processed AUTOMAKE_OPTIONS.
7164 buffer_messages ('warning');
7166 # Name of input file ("Makefile.am") and output file
7167 # ("Makefile.in"). These have no directory components.
7168 $am_file_name = basename ($makefile) . '.am';
7169 $in_file_name = basename ($makefile) . '.in';
7171 # $OUTPUT is encoded. If it contains a ":" then the first element
7172 # is the real output file, and all remaining elements are input
7173 # files. We don't scan or otherwise deal with these input files,
7174 # other than to mark them as dependencies. See
7175 # &scan_autoconf_files for details.
7176 my (@secondary_inputs);
7177 ($output, @secondary_inputs) = split (/:/, $output);
7179 $relative_dir = dirname ($output);
7180 $am_relative_dir = dirname ($makefile);
7182 read_main_am_file ($makefile . '.am');
7185 # Process buffered warnings.
7187 # Fatal error. Just return, so we can continue with next file.
7190 # Process buffered warnings.
7193 # There are a few install-related variables that you should not define.
7194 foreach my $var ('PRE_INSTALL', 'POST_INSTALL', 'NORMAL_INSTALL')
7199 my $def = $v->def (TRUE);
7200 prog_error "$var not defined in condition TRUE"
7202 reject_var $var, "`$var' should not be defined"
7203 if $def->owner != VAR_AUTOMAKE;
7207 # Catch some obsolete variables.
7208 msg_var ('obsolete', 'INCLUDES',
7209 "`INCLUDES' is the old name for `AM_CPPFLAGS'")
7210 if var ('INCLUDES');
7212 # At the toplevel directory, we might need config.guess, config.sub
7213 # or libtool scripts (ltconfig and ltmain.sh).
7214 if ($relative_dir eq '.')
7216 # AC_CANONICAL_HOST and AC_CANONICAL_SYSTEM need config.guess and
7218 require_conf_file ($canonical_location, FOREIGN,
7219 'config.guess', 'config.sub')
7223 # Must do this after reading .am file.
7224 define_variable ('subdir', $relative_dir, INTERNAL);
7226 # Check first, because we might modify some state.
7228 check_gnu_standards;
7229 check_gnits_standards;
7231 handle_configure ($output, $makefile, @secondary_inputs);
7238 # This must run first so that the ANSI2KNR definition is generated
7239 # before it is used by the _.c rules. We have to do this because
7240 # a variable which is used in a dependency must be defined before
7241 # the target, or else make won't properly see it.
7243 # This must be run after all the sources are scanned.
7246 # We have to run this after dealing with all the programs.
7249 # Variables used by distdir.am and tags.am.
7250 define_pretty_variable ('SOURCES', TRUE, INTERNAL, @sources);
7251 define_pretty_variable ('DIST_SOURCES', TRUE, INTERNAL, @dist_sources);
7263 handle_minor_options;
7266 # This must come after most other rules.
7267 handle_dist ($makefile);
7270 do_check_merge_target;
7271 handle_all ($output);
7274 if (var ('lib_LTLIBRARIES') && var ('bin_PROGRAMS'))
7276 $output_rules .= "install-binPROGRAMS: install-libLTLIBRARIES\n\n";
7281 handle_factored_dependencies;
7283 # Comes last, because all the above procedures may have
7284 # defined or overridden variables.
7285 $output_vars .= output_variables;
7289 if (! -d ($output_directory . '/' . $am_relative_dir))
7291 mkdir ($output_directory . '/' . $am_relative_dir, 0755);
7294 my ($out_file) = $output_directory . '/' . $makefile . ".in";
7295 if (! $force_generation && -e $out_file)
7297 my ($am_time) = (stat ($makefile . '.am'))[9];
7298 my ($in_time) = (stat ($out_file))[9];
7299 # FIXME: should cache these times.
7300 my ($conf_time) = (stat ($configure_ac))[9];
7301 # FIXME: how to do unsigned comparison?
7302 if ($am_time < $in_time || $am_time < $conf_time)
7304 # No need to update.
7307 if (-f 'aclocal.m4')
7309 my ($acl_time) = (stat _)[9];
7310 return if ($am_time < $acl_time);
7317 or fatal "cannot remove $out_file: $!\n";
7319 my $gm_file = new Automake::XFile "> $out_file";
7320 verb "creating $makefile.in";
7322 print $gm_file $output_vars;
7323 # We make sure that `all:' is the first target.
7324 print $gm_file $output_all;
7325 print $gm_file $output_header;
7326 print $gm_file $output_rules;
7327 print $gm_file $output_trailer;
7329 # Back out any warning setting.
7333 ################################################################
7339 $strictness_name = $_[0];
7341 Automake::ChannelDefs::set_strictness ($strictness_name);
7343 if ($strictness_name eq 'gnu')
7347 elsif ($strictness_name eq 'gnits')
7349 $strictness = GNITS;
7351 elsif ($strictness_name eq 'foreign')
7353 $strictness = FOREIGN;
7357 prog_error "level `$strictness_name' not recognized\n";
7362 ################################################################
7364 # Print usage information.
7367 print "Usage: $0 [OPTION] ... [Makefile]...
7369 Generate Makefile.in for configure from Makefile.am.
7372 --help print this help, then exit
7373 --version print version number, then exit
7374 -v, --verbose verbosely list files processed
7375 --no-force only update Makefile.in's that are out of date
7376 -W, --warnings=CATEGORY report the warnings falling in CATEGORY
7378 Dependency tracking:
7379 -i, --ignore-deps disable dependency tracking code
7380 --include-deps enable dependency tracking code
7383 --cygnus assume program is part of Cygnus-style tree
7384 --foreign set strictness to foreign
7385 --gnits set strictness to gnits
7386 --gnu set strictness to gnu
7389 -a, --add-missing add missing standard files to package
7390 --libdir=DIR directory storing library files
7391 -c, --copy with -a, copy missing files (default is symlink)
7392 -f, --force-missing force update of standard files
7395 Automake::ChannelDefs::usage;
7399 foreach my $iter (sort ((@common_files, @common_sometimes)))
7401 push (@lcomm, $iter) unless $iter eq $last;
7406 print "\nFiles which are automatically distributed, if found:\n";
7407 format USAGE_FORMAT =
7408 @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<
7409 $four[0], $four[1], $four[2], $four[3]
7411 $~ = "USAGE_FORMAT";
7414 my $rows = int(@lcomm / $cols);
7415 my $rest = @lcomm % $cols;
7426 for (my $y = 0; $y < $rows; $y++)
7428 @four = ("", "", "", "");
7429 for (my $x = 0; $x < $cols; $x++)
7431 last if $y + 1 == $rows && $x == $rest;
7433 my $idx = (($x > $rest)
7434 ? ($rows * $rest + ($rows - 1) * ($x - $rest))
7438 $four[$x] = $lcomm[$idx];
7443 print "\nReport bugs to <bug-automake\@gnu.org>.\n";
7445 # --help always returns 0 per GNU standards.
7452 # Print version information
7456 automake (GNU $PACKAGE) $VERSION
7457 Written by Tom Tromey <tromey\@redhat.com>.
7459 Copyright 2003 Free Software Foundation, Inc.
7460 This is free software; see the source for copying conditions. There is NO
7461 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7463 # --version always returns 0 per GNU standards.
7467 ################################################################
7469 # Parse command line.
7470 sub parse_arguments ()
7473 &set_strictness ('gnu');
7477 'libdir:s' => \$libdir,
7478 'gnu' => sub { &set_strictness ('gnu'); },
7479 'gnits' => sub { &set_strictness ('gnits'); },
7480 'cygnus' => \$options{'cygnus'},
7481 'foreign' => sub { &set_strictness ('foreign'); },
7482 'include-deps' => sub { $cmdline_use_dependencies = 1; },
7483 'i|ignore-deps' => sub { $cmdline_use_dependencies = 0; },
7484 'no-force' => sub { $force_generation = 0; },
7485 'f|force-missing' => \$force_missing,
7486 'o|output-dir:s' => \$output_directory,
7487 'a|add-missing' => \$add_missing,
7488 'c|copy' => \$copy_missing,
7489 'v|verbose' => sub { setup_channel 'verb', silent => 0; },
7490 'W|warnings:s' => \&parse_warnings,
7491 # These long options (--Werror and --Wno-error) for backward
7492 # compatibility. Use -Werror and -Wno-error today.
7493 'Werror' => sub { parse_warnings 'W', 'error'; },
7494 'Wno-error' => sub { parse_warnings 'W', 'no-error'; },
7497 Getopt::Long::config ("bundling", "pass_through");
7499 # See if --version or --help is used. We want to process these before
7500 # anything else because the GNU Coding Standards require us to
7501 # `exit 0' after processing these options, and we can't garanty this
7502 # if we treat other options first. (Handling other options first
7503 # could produce error diagnostics, and in this condition it is
7504 # confusing if Automake `exit 0'.)
7505 my %cli_options_1st_pass =
7507 'version' => \&version,
7509 # Recognize all other options (and their arguments) but do nothing.
7510 map { $_ => sub {} } (keys %cli_options)
7512 my @ARGV_backup = @ARGV;
7513 Getopt::Long::GetOptions %cli_options_1st_pass
7515 @ARGV = @ARGV_backup;
7517 # Now *really* process the options. This time we know
7518 # that --help and --version are not present.
7519 Getopt::Long::GetOptions %cli_options
7522 if (defined $output_directory)
7524 msg 'obsolete', "`--output-dir' is deprecated\n";
7528 # In the next release we'll remove this entirely.
7529 $output_directory = '.';
7532 foreach my $arg (@ARGV)
7536 fatal ("unrecognized option `$arg'\n"
7537 . "Try `$0 --help' for more information.");
7540 # Handle $local:$input syntax. Note that we only examine the
7541 # first ":" file to see if it is automake input; the rest are
7542 # just taken verbatim. We still keep all the files around for
7543 # dependency checking, however.
7544 my ($local, $input, @rest) = split (/:/, $arg);
7551 # Strip .in; later on .am is tacked on. That is how the
7552 # automake input file is found. Maybe not the best way, but
7553 # it is easy to explain.
7555 or fatal "invalid input file name `$arg'\n.";
7557 push (@input_files, $input);
7558 $output_files{$input} = join (':', ($local, @rest));
7561 # Take global strictness from whatever we currently have set.
7562 $default_strictness = $strictness;
7563 $default_strictness_name = $strictness_name;
7566 ################################################################
7568 # Parse the WARNINGS environment variable.
7571 # Parse command line.
7574 # Do configure.ac scan only once.
7575 scan_autoconf_files;
7577 fatal "no `Makefile.am' found or specified\n"
7580 my $automake_has_run = 0;
7584 if ($automake_has_run)
7586 verb 'processing Makefiles another time to fix them up.';
7587 prog_error 'running more than two times should never be needed.'
7588 if $automake_has_run >= 2;
7590 $automake_needs_to_reprocess_all_files = 0;
7592 # Now do all the work on each file.
7593 foreach my $file (@input_files)
7596 if (! -f ($am_file . '.am'))
7598 error "`$am_file.am' does not exist";
7602 generate_makefile ($output_files{$am_file}, $am_file);
7605 ++$automake_has_run;
7607 while ($automake_needs_to_reprocess_all_files);
7612 ### Setup "GNU" style for perl-mode and cperl-mode.
7614 ## perl-indent-level: 2
7615 ## perl-continued-statement-offset: 2
7616 ## perl-continued-brace-offset: 0
7617 ## perl-brace-offset: 0
7618 ## perl-brace-imaginary-offset: 0
7619 ## perl-label-offset: -2
7620 ## cperl-indent-level: 2
7621 ## cperl-brace-offset: 0
7622 ## cperl-continued-brace-offset: 0
7623 ## cperl-label-offset: -2
7624 ## cperl-extra-newline-before-brace: t
7625 ## cperl-merge-trailing-else: nil
7626 ## cperl-continued-statement-offset: 2