5 eval 'exec @PERL@ -S $0 ${1+"$@"}'
8 # automake - create Makefile.in from Makefile.am
9 # Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
10 # Free Software Foundation, Inc.
12 # This program is free software; you can redistribute it and/or modify
13 # it under the terms of the GNU General Public License as published by
14 # the Free Software Foundation; either version 2, or (at your option)
17 # This program is distributed in the hope that it will be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # GNU General Public License for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, write to the Free Software
24 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
27 # Originally written by David Mackenzie <djm@gnu.ai.mit.edu>.
28 # Perl reimplementation by Tom Tromey <tromey@cygnus.com>.
34 my $prefix = "@prefix@";
35 unshift @INC, $libdir ||"@datadir@/@PACKAGE@";
39 struct (# Short name of the language (c, f77...).
41 # Nice name of the language (C, Fortran 77...).
44 # List of configure variables which must be defined.
48 # `pure' is `1' or `'. A `pure' language is one where, if
49 # all the files in a directory are of that language, then we
50 # do not require the C compiler or any code to call it.
55 # Name of the compiling variable (COMPILE).
57 # Content of the compiling variable.
59 # Flag to require compilation without linking (-c).
60 'compile_flag' => '$',
61 'derived_autodep' => '$',
65 # Name of the linking variable (LINK).
67 # Content of the linking variable.
70 # Name of the linker variable (LD).
72 # Content of the linker variable ($(CC)).
75 # Flag to specify the output file (-o).
83 if (defined $self->_finish)
93 use strict 'vars', 'subs';
97 my $me = basename ($0);
104 # Parameters set by configure. Not to be changed. NOTE: assign
105 # VERSION as string so that eg version 0.30 will print correctly.
106 my $VERSION = "@VERSION@";
107 my $PACKAGE = "@PACKAGE@";
108 my $prefix = "@prefix@";
109 my $libdir = "@datadir@/@PACKAGE@";
112 my $IGNORE_PATTERN = '^\s*##([^#\n].*)?\n';
113 my $WHITE_PATTERN = '^\s*$';
114 my $COMMENT_PATTERN = '^#';
115 my $TARGET_PATTERN='[$a-zA-Z_.][-.a-zA-Z0-9_(){}/$]*';
116 # A rule has three parts: a list of targets, a list of dependencies,
117 # and optionally actions.
119 "^($TARGET_PATTERN(?:(?:\\\\\n|\\s)+$TARGET_PATTERN)*) *:([^=].*|)\$";
121 my $SUFFIX_RULE_PATTERN = '^\.([a-zA-Z0-9]+)\.([a-zA-Z0-9]+)$';
122 # Only recognize leading spaces, not leading tabs. If we recognize
123 # leading tabs here then we need to make the reader smarter, because
124 # otherwise it will think rules like `foo=bar; \' are errors.
125 my $MACRO_PATTERN = '^[A-Za-z0-9_@]+$';
126 my $ASSIGNMENT_PATTERN = '^ *([^ \t=]*)\s*([:+]?)=\s*(.*)$';
127 # This pattern recognizes a Gnits version id and sets $1 if the
128 # release is an alpha release. We also allow a suffix which can be
129 # used to extend the version number with a "fork" identifier.
130 my $GNITS_VERSION_PATTERN = '\d+\.\d+([a-z]|\.\d+)?(-[A-Za-z0-9]+)?';
131 my $IF_PATTERN = '^if\s+(!?)\s*([A-Za-z][A-Za-z0-9_]*)\s*(?:#.*)?$';
132 my $ELSE_PATTERN = '^else(?:\s+(!?)\s*([A-Za-z][A-Za-z0-9_]*))?\s*(?:#.*)?$';
133 my $ENDIF_PATTERN = '^endif(?:\s+(!?)\s*([A-Za-z][A-Za-z0-9_]*))?\s*(?:#.*)?$';
134 my $PATH_PATTERN='(\w|[/.-])+';
135 # This will pass through anything not of the prescribed form.
136 my $INCLUDE_PATTERN = ('^include\s+'
137 . '((\$\(top_srcdir\)/' . $PATH_PATTERN . ')'
138 . '|(\$\(srcdir\)/' . $PATH_PATTERN . ')'
139 . '|([^/\$]' . $PATH_PATTERN. '))\s*(#.*)?$');
141 # Some regular expressions. One reason to put them here is that it
142 # makes indentation work better in Emacs.
143 my $AC_CONFIG_AUX_DIR_PATTERN = 'AC_CONFIG_AUX_DIR\(([^)]+)\)';
144 my $AM_INIT_AUTOMAKE_PATTERN = 'AM_INIT_AUTOMAKE\([^,]*,([^,)]+)[,)]';
145 my $AM_PACKAGE_VERSION_PATTERN = '^\s*\[?([^]\s]+)\]?\s*$';
146 # Note that there is no AC_PATH_TOOL. But we don't really care.
147 my $AC_CHECK_PATTERN = 'AC_(CHECK|PATH)_(PROG|PROGS|TOOL)\(\[?(\w+)';
148 my $AM_MISSING_PATTERN = 'AM_MISSING_PROG\(\[?(\w+)';
149 # Just check for alphanumeric in AC_SUBST. If you do AC_SUBST(5),
151 my $AC_SUBST_PATTERN = 'AC_SUBST\(\[?(\w+)';
152 my $AM_CONDITIONAL_PATTERN = 'AM_CONDITIONAL\(\[?(\w+)';
154 # Constants to define the "strictness" level.
159 # Values for AC_CANONICAL_*
160 my $AC_CANONICAL_HOST = 1;
161 my $AC_CANONICAL_SYSTEM = 2;
163 # Values indicating when something should be cleaned. Right now we
164 # only need to handle `mostly'- and `dist'-clean; add more as
166 my $MOSTLY_CLEAN = 0;
169 # Files installed by libtoolize.
170 my @libtoolize_files = ('ltmain.sh', 'config.guess', 'config.sub');
171 # ltconfig appears here for compatibility with old versions of libtool.
172 my @libtoolize_sometimes = ('ltconfig', 'ltcf-c.sh', 'ltcf-cxx.sh',
175 # Commonly found files we look for and automatically include in
179 'README', 'THANKS', 'TODO', 'NEWS', 'COPYING', 'COPYING.LIB',
180 'INSTALL', 'ABOUT-NLS', 'ChangeLog', 'configure.ac',
181 'configure.in', 'configure', 'config.guess', 'config.sub',
182 'AUTHORS', 'BACKLOG', 'ABOUT-GNU', 'libversion.in',
183 'mdate-sh', 'mkinstalldirs', 'install-sh', 'texinfo.tex',
184 'ansi2knr.c', 'ansi2knr.1', 'elisp-comp',
185 # ltconfig appears here for compatibility with old versions
187 'ylwrap', 'acinclude.m4', @libtoolize_files, @libtoolize_sometimes,
188 'missing', 'depcomp', 'compile', 'py-compile'
191 # Commonly used files we auto-include, but only sometimes.
192 my @common_sometimes =
194 'aclocal.m4', 'acconfig.h', 'config.h.top',
195 'config.h.bot', 'stamp-h.in', 'stamp-vti'
198 # Copyright on generated Makefile.ins.
199 my $gen_copyright = "\
200 # Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
201 # Free Software Foundation, Inc.
202 # This Makefile.in is free software; the Free Software Foundation
203 # gives unlimited permission to copy and/or distribute it,
204 # with or without modifications, as long as this notice is preserved.
206 # This program is distributed in the hope that it will be useful,
207 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
208 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
209 # PARTICULAR PURPOSE.
212 # These constants are returned by lang_*_rewrite functions.
213 # LANG_SUBDIR means that the resulting object file should be in a
214 # subdir if the source file is. In this case the file name cannot
215 # have `..' components.
217 my $LANG_PROCESS = 1;
220 # Directories installed during 'install-exec' phase.
239 # Map from obsolete macros to hints for new macros.
240 # If you change this, change the corresponding list in aclocal.in.
241 # FIXME: should just put this into a single file.
242 my %obsolete_macros =
244 'AC_FEATURE_CTYPE' => "use `AC_HEADER_STDC'",
245 'AC_FEATURE_ERRNO' => "add `strerror' to `AC_REPLACE_FUNCS(...)'",
246 'AC_FEATURE_EXIT' => '',
247 'AC_SYSTEM_HEADER' => '',
249 # Note that we do not handle this one, because it is still run
250 # from AM_CONFIG_HEADER. So we deal with it specially in
251 # &scan_autoconf_files.
252 # 'AC_CONFIG_HEADER' => "use `AM_CONFIG_HEADER'",
254 'fp_C_PROTOTYPES' => "use `AM_C_PROTOTYPES'",
255 'fp_PROG_CC_STDC' => "use `AM_PROG_CC_STDC'",
256 'fp_PROG_INSTALL' => "use `AC_PROG_INSTALL'",
257 'fp_WITH_DMALLOC' => "use `AM_WITH_DMALLOC'",
258 'fp_WITH_REGEX' => "use `AM_WITH_REGEX'",
259 'gm_PROG_LIBTOOL' => "use `AM_PROG_LIBTOOL'",
260 'jm_MAINTAINER_MODE' => "use `AM_MAINTAINER_MODE'",
261 'md_TYPE_PTRDIFF_T' => "use `AM_TYPE_PTRDIFF_T'",
262 'ud_PATH_LISPDIR' => "use `AM_PATH_LISPDIR'",
263 'ud_GNU_GETTEXT' => "use `AM_GNU_GETTEXT'",
265 # Now part of autoconf proper, under a different name.
266 'AM_FUNC_FNMATCH' => "use `AC_FUNC_FNMATCH'",
267 'fp_FUNC_FNMATCH' => "use `AC_FUNC_FNMATCH'",
268 'AM_SANITY_CHECK_CC' => "automatically done by `AC_PROG_CC'",
269 'AM_PROG_INSTALL' => "use `AC_PROG_INSTALL'",
270 'AM_EXEEXT' => "use `AC_EXEEXT'",
271 'AM_CYGWIN32' => "use `AC_CYGWIN'",
272 'AM_MINGW32' => "use `AC_MINGW32'",
273 'AM_FUNC_MKTIME' => "use `AC_FUNC_MKTIME'",
275 # These aren't quite obsolete.
279 # Regexp to match the above macros.
280 my $obsolete_rx = '(\b' . join ('\b|\b', keys %obsolete_macros) . '\b)';
284 ## ---------------------------------- ##
285 ## Variables related to the options. ##
286 ## ---------------------------------- ##
288 # TRUE if we should always generate Makefile.in.
289 my $force_generation = 1;
291 # Strictness level as set on command line.
292 my $default_strictness = $GNU;
294 # Name of strictness level, as set on command line.
295 my $default_strictness_name = 'gnu';
297 # This is TRUE if automatic dependency generation code should be
298 # included in generated Makefile.in.
299 my $cmdline_use_dependencies = 1;
301 # TRUE if in verbose mode.
304 # This holds our (eventual) exit status. We don't actually exit until
305 # we have processed all input files.
308 # From the Perl manual.
309 my $symlink_exists = (eval 'symlink ("", "");', $@ eq '');
311 # TRUE if missing standard files should be installed.
314 # TRUE if we should copy missing files; otherwise symlink if possible.
315 my $copy_missing = 0;
317 # TRUE if we should always update files that we know about.
318 my $force_missing = 0;
321 ## ---------------------------------------- ##
322 ## Variables filled during files scanning. ##
323 ## ---------------------------------------- ##
325 # Name of the top autoconf input: `configure.ac' or `configure.in'.
326 my $configure_ac = '';
328 # Files found by scanning configure.ac for LIBOBJS.
331 # True if AM_C_PROTOTYPES appears in configure.ac.
332 my $am_c_prototypes = 0;
334 # Names used in AC_CONFIG_HEADER call. @config_fullnames holds the
335 # name which appears in AC_CONFIG_HEADER, colon and all.
336 # @config_names holds the file names. @config_headers holds the '.in'
337 # files. Ordinarily these are similar, but they can be different if
338 # the weird "NAME:FILE" syntax is used.
339 my @config_fullnames = ();
340 my @config_names = ();
341 my @config_headers = ();
342 # Line number at which AC_CONFIG_HEADER appears in configure.ac.
343 my $config_header_line = 0;
345 # Directory where output files go. Actually, output files are
346 # relative to this directory.
347 my $output_directory = '.';
349 # List of Makefile.am's to process, and their corresponding outputs.
350 my @input_files = ();
351 my %output_files = ();
353 # Complete list of Makefile.am's that exist.
354 my @configure_input_files = ();
356 # List of files in AC_OUTPUT without Makefile.am, and their outputs.
357 my @other_input_files = ();
358 # Line number at which AC_OUTPUT seen.
359 my $ac_output_line = 0;
361 # List of directories to search for configure-required files. This
362 # can be set by AC_CONFIG_AUX_DIR.
363 my @config_aux_path = ('.', '..', '../..');
364 my $config_aux_dir = '';
365 my $config_aux_dir_set_in_configure_in = 0;
367 # Whether AM_GNU_GETTEXT has been seen in configure.ac.
368 my $seen_gettext = 0;
369 # Line number at which AM_GNU_GETTEXT seen.
370 my $ac_gettext_line = 0;
372 # Whether ALL_LINGUAS has been seen.
373 my $seen_linguas = '';
375 my $all_linguas = '';
376 # Line number at which it appears.
377 my $all_linguas_line = 0;
379 # TRUE if AC_DECL_YYTEXT was seen.
380 my $seen_decl_yytext = 0;
382 # TRUE if we've seen AC_CANONICAL_(HOST|SYSTEM). The presence of
383 # AC_CHECK_TOOL also sets this.
384 my $seen_canonical = 0;
386 # TRUE if we've seen AC_PROG_LIBTOOL.
387 my $seen_libtool = 0;
388 my $libtool_line = 0;
390 # TRUE if we've seen AM_MAINTAINER_MODE.
391 my $seen_maint_mode = 0;
393 # Actual version we've seen.
394 my $package_version = '';
396 # Line number where we saw version definition.
397 my $package_version_line = 0;
399 # TRUE if we've seen AM_PATH_LISPDIR.
400 my $seen_lispdir = 0;
402 # TRUE if we've seen AM_PATH_PYTHON.
403 my $seen_pythondir = 0;
405 # TRUE if we've seen AC_EXEEXT.
408 # TRUE if we've seen AC_OBJEXT.
411 # TRUE if we've seen AC_ENABLE_MULTILIB.
412 my $seen_multilib = 0;
414 # TRUE if we've seen AM_PROG_CC_C_O
417 # TRUE if we've seen AM_INIT_AUTOMAKE.
418 my $seen_init_automake = 0;
420 # Hash table of discovered configure substitutions. Keys are names,
421 # values are `FILE:LINE' strings which are used by error message
423 my %configure_vars = ();
425 # This is used to keep track of which variable definitions we are
426 # scanning. It is only used in certain limited ways, but it has to be
427 # global. It is declared just for documentation purposes.
428 my %vars_scanned = ();
430 # Charsets used by maintainer and in distribution. MAINT_CHARSET is
431 # handled in a funny way: if seen in the top-level Makefile.am, it is
432 # used for every directory which does not specify a different value.
433 # The rationale here is that some directories (eg gettext) might be
434 # distributions of other packages, and thus require their own charset
435 # info. However, the DIST_CHARSET must be the same for the entire
436 # package; it can only be set at top-level.
437 # FIXME: this yields bugs when rebuilding. What to do? Always
438 # read (and sometimes discard) top-level Makefile.am?
439 my $maint_charset = '';
440 my $dist_charset = 'utf8'; # recode doesn't support this yet.
442 # TRUE if --cygnus seen.
445 # Hash table of AM_CONDITIONAL variables seen in configure.
446 my %configure_cond = ();
448 # This maps extensions onto language names.
449 my %extension_map = ();
451 # List of the DIST_COMMON files we discovered while reading
453 my $configure_dist_common = '';
455 # This maps languages names onto objects.
458 # List of targets we must always output.
459 # FIXME: Complete, and remove falsely required targets.
460 my %required_targets =
471 # FIXME: Not required, temporary hacks.
472 # Well, actually they are sort of required: the -recursive
473 # targets will run them anyway...
476 'install-data-am' => 1,
477 'install-exec-am' => 1,
478 'installcheck-am' => 1,
486 ################################################################
488 ## ------------------------------------------ ##
489 ## Variables reset by &initialize_per_input. ##
490 ## ------------------------------------------ ##
492 # Basename and relative dir of the input file.
496 # Same but wrt Makefile.in.
500 # These two variables are used when generating each Makefile.in.
501 # They hold the Makefile.in until it is ready to be printed.
508 # Suffixes found during a run.
511 # Handling the variables.
514 # - $var_value{$VAR}{$COND} is its value associated to $COND,
515 # - $var_line{$VAR} is where it has been defined,
516 # - $var_comment{$VAR} are the comments associated to it.
517 # - $var_type{$VAR} is how it has been defined (`', `+', or `:'),
518 # - $var_is_am{$VAR} is true if the variable is owned by Automake.
525 # This holds a 1 if a particular variable was examined.
528 # This holds the names which are targets. These also appear in
532 # Same as %VAR_VALUE, but for targets.
533 my %target_conditional;
535 # This is the conditional stack.
538 # This holds the set of included files.
541 # This holds a list of directories which we must create at `dist'
542 # time. This is used in some strange scenarios involving weird
543 # AC_OUTPUT commands.
546 # List of dependencies for the obvious targets.
551 # Holds the dependencies of targets which dependencies are factored.
552 # Typically, `.PHONY' will appear in plenty of *.am files, but must
553 # be output once. Arguably all pure dependencies could be subject
554 # to this factorization, but it is not unpleasant to have paragraphs
555 # in Makefile: keeping related stuff altogether.
558 # Holds the factored actions. Tied to %DEPENDENCIES, i.e., filled
559 # only when keys exists in %DEPENDENCIES.
562 # A list of files deleted by `maintainer-clean'.
563 my @maintainer_clean_files;
565 # Keys in this hash table are object files or other files in
566 # subdirectories which need to be removed. This only holds files
567 # which are created by compilations. The value in the hash indicates
568 # when the file should be removed.
569 my %compile_clean_files;
571 # Value of `$(SOURCES)', used by tags.am.
573 # Sources which go in the distribution.
576 # This hash maps object file names onto their corresponding source
577 # file names. This is used to ensure that each object is created
578 # by a single source file.
581 # This keeps track of the directories for which we've already
582 # created `.dirstamp' code.
592 # Options from AUTOMAKE_OPTIONS.
595 # Whether or not dependencies are handled. Can be further changed
597 my $use_dependencies;
600 my $local_maint_charset;
602 # All yacc and lex source filenames for this directory. Use
603 # filenames instead of raw count so that multiple instances are
604 # counted correctly (eg one yacc file can appear in multiple
605 # programs without harm).
609 # This is a list of all targets to run during "make dist".
612 # Keys in this hash are the basenames of files which must depend
616 # This maps the source extension of a suffix rule to its
617 # corresponding output extension.
620 # This is the name of the redirect `all' target to use.
623 # This keeps track of which extensions we've seen (that we care
627 # This is random scratch space for the language finish functions.
628 # Don't randomly overwrite it; examine other uses of keys first.
629 my %language_scratch;
631 # We keep track of which objects need special (per-executable)
632 # handling on a per-language basis.
633 my %lang_specific_files;
635 # This is set when `handle_dist' has finished. Once this happens,
636 # we should no longer push on dist_common.
639 # True if we need `LINK' defined. This is a hack.
642 # This is the list of such variables to output.
643 # FIXME: Might be useless actually.
646 # Was get_object_extension run?
647 # FIXME: This is a hack. a better switch should be found.
648 my $get_object_extension_was_run;
651 ## --------------------------------- ##
652 ## Forward subroutine declarations. ##
653 ## --------------------------------- ##
654 sub register_language (%);
655 sub file_contents_internal ($$%);
658 # &initialize_per_input ()
659 # ------------------------
660 # (Re)-Initialize per-Makefile.am variables.
661 sub initialize_per_input ()
664 $am_relative_dir = '';
671 $output_trailer = '';
687 %target_conditional = ();
695 $am_relative_dir = '';
711 # Installing/uninstalling.
712 'install-data-am' => [],
713 'install-exec-am' => [],
714 'uninstall-am' => [],
717 'uninstall-man' => [],
719 'install-info' => [],
720 'install-info-am' => [],
721 'uninstall-info' => [],
723 'installcheck-am' => [],
727 'mostlyclean-am' => [],
728 'maintainer-clean-am' => [],
729 'distclean-am' => [],
732 'maintainer-clean' => [],
743 @maintainer_clean_files = ();
754 $strictness = $default_strictness;
755 $strictness_name = $default_strictness_name;
759 $use_dependencies = $cmdline_use_dependencies;
761 $local_maint_charset = $maint_charset;
774 %extension_seen = ();
776 %language_scratch = ();
778 %lang_specific_files = ();
780 $handle_dist_run = 0;
786 $get_object_extension_was_run = 0;
788 %compile_clean_files = ();
792 ################################################################
794 # Initialize our list of languages that are internally supported.
797 register_language ('name' => 'c',
799 'config_vars' => ['CC'],
803 'compiler' => 'COMPILE',
804 'compile' => '$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)',
808 'link' => '$(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
809 'compile_flag' => '-c',
810 'extensions' => ['c'],
811 '_finish' => \&lang_c_finish);
814 register_language ('name' => 'cxx',
816 'config_vars' => ['CXX'],
817 'linker' => 'CXXLINK',
818 'link' => '$(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
820 'flags' => 'CXXFLAGS',
821 'compile' => '$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)',
822 'compiler' => 'CXXCOMPILE',
823 'compile_flag' => '-c',
824 'output_flag' => '-o',
828 'extensions' => ['c++', 'cc', 'cpp', 'cxx', 'C']);
831 register_language ('name' => 'objc',
832 'Name' => 'Objective C',
833 'config_vars' => ['OBJC'],
834 'linker' => 'OBJCLINK',,
835 'link' => '$(OBJCLD) $(AM_OBJCFLAGS) $(OBJCFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
837 'flags' => 'OBJCFLAGS',
838 'compile' => '$(OBJC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_OBJCFLAGS) $(OBJCFLAGS)',
839 'compiler' => 'OBJCCOMPILE',
840 'compile_flag' => '-c',
841 'output_flag' => '-o',
845 'extensions' => ['m']);
848 register_language ('name' => 'header',
850 'extensions' => ['h', 'H', 'hxx', 'h++', 'hh', 'hpp', 'inc'],
852 '_finish' => sub { });
854 # For now, yacc and lex can't be handled on a per-exe basis.
857 register_language ('name' => 'yacc',
860 'config_vars' => ['YACC'],
861 'derived_autodep' => 'yes',
862 'extensions' => ['y'],
863 '_finish' => \&lang_yacc_finish);
864 register_language ('name' => 'yaccxx',
865 'Name' => 'Yacc (C++)',
866 'config_vars' => ['YACC'],
867 'linker' => 'CXXLINK',
868 'derived_autodep' => 'yes',
869 'extensions' => ['y++', 'yy', 'yxx', 'ypp'],
870 '_finish' => \&lang_yacc_finish);
873 register_language ('name' => 'lex',
876 'config_vars' => ['LEX'],
877 'derived_autodep' => 'yes',
878 'extensions' => ['l'],
879 '_finish' => \&lang_lex_finish);
880 register_language ('name' => 'lexxx',
881 'Name' => 'Lex (C++)',
882 'config_vars' => ['LEX'],
883 'linker' => 'CXXLINK',
884 'derived_autodep' => 'yes',
885 'extensions' => ['l++', 'll', 'lxx', 'lpp'],
886 '_finish' => \&lang_lex_finish);
889 register_language ('name' => 'asm',
890 'Name' => 'Assembler',
891 'config_vars' => ['AS', 'ASFLAGS'],
893 'flags' => 'ASFLAGS',
894 # Users can set AM_ASFLAGS to includes DEFS, INCLUDES,
895 # or anything else required. They can also set AS.
896 'compile' => '$(AS) $(AM_ASFLAGS) $(ASFLAGS)',
897 'compiler' => 'ASCOMPILE',
898 'compile_flag' => '-c',
899 'extensions' => ['s', 'S'],
901 # With assembly we still use the C linker.
902 '_finish' => \&lang_c_finish);
905 register_language ('name' => 'f77',
906 'Name' => 'Fortran 77',
907 'linker' => 'F77LINK',
908 'link' => '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
910 'compile' => '$(F77) $(AM_FFLAGS) $(FFLAGS)',
911 'compiler' => 'F77COMPILE',
912 'compile_flag' => '-c',
913 'output_flag' => '-o',
917 'extensions' => ['f', 'for', 'f90']);
919 # Preprocessed Fortran 77
921 # The current support for preprocessing Fortran 77 just involves
922 # passing `$(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS)
923 # $(CPPFLAGS)' as additional flags to the Fortran 77 compiler, since
924 # this is how GNU Make does it; see the `GNU Make Manual, Edition 0.51
925 # for `make' Version 3.76 Beta' (specifically, from info file
926 # `(make)Catalogue of Rules').
928 # A better approach would be to write an Autoconf test
929 # (i.e. AC_PROG_FPP) for a Fortran 77 preprocessor, because not all
930 # Fortran 77 compilers know how to do preprocessing. The Autoconf
931 # macro AC_PROG_FPP should test the Fortran 77 compiler first for
932 # preprocessing capabilities, and then fall back on cpp (if cpp were
934 register_language ('name' => 'ppf77',
935 'Name' => 'Preprocessed Fortran 77',
936 'config_vars' => ['F77'],
937 'linker' => 'F77LINK',
938 'link' => '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
942 'compiler' => 'PPF77COMPILE',
943 'compile' => '$(F77) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FFLAGS) $(FFLAGS)',
944 'compile_flag' => '-c',
945 'output_flag' => '-o',
947 'extensions' => ['F']);
950 register_language ('name' => 'ratfor',
952 'config_vars' => ['F77'],
953 'linker' => 'F77LINK',
954 'link' => '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
959 'compile' => '$(F77) $(AM_FFLAGS) $(FFLAGS) $(AM_RFLAGS) $(RFLAGS)',
960 'compiler' => 'RCOMPILE',
961 'compile_flag' => '-c',
962 'output_flag' => '-o',
964 'extensions' => ['r']);
967 register_language ('name' => 'java',
969 'config_vars' => ['GCJ'],
970 'linker' => 'GCJLINK',
971 'link' => '$(GCJLD) $(AM_GCJFLAGS) $(GCJFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
973 'flags' => 'GCJFLAGS',
974 'compile' => '$(GCJ) $(AM_GCJFLAGS) $(GCJFLAGS)',
975 'compiler' => 'GCJCOMPILE',
976 'compile_flag' => '-c',
977 'output_flag' => '-o',
981 'extensions' => ['java', 'class', 'zip', 'jar']);
983 ################################################################
985 # Parse command line.
988 # Do configure.ac scan only once.
989 &scan_autoconf_files;
991 die "$me: no `Makefile.am' found or specified\n"
994 # Now do all the work on each file.
995 # This guy must be local otherwise it's private to the loop.
998 foreach $am_file (@input_files)
1000 if (! -f ($am_file . '.am'))
1002 &am_error ("`" . $am_file . ".am' does not exist");
1006 &generate_makefile ($output_files{$am_file}, $am_file);
1012 # FIXME: This should be `my'ed next to its subs.
1013 use vars '%require_file_found';
1015 ################################################################
1017 # prog_error (@PRINT-ME)
1018 # ----------------------
1019 # Signal a programming error, display PRINT-ME, and exit 1.
1022 print STDERR "$me: programming error: @_\n";
1030 # Return LIST with no duplicates.
1035 foreach my $item (@_)
1037 if (! defined $seen{$item})
1048 # Return a configure-style substitution using the indicated text.
1049 # We do this to avoid having the substitutions directly in automake.in;
1050 # when we do that they are sometimes removed and this causes confusion
1055 return '@' . $text . '@';
1058 ################################################################
1062 # &backname ($REL-DIR)
1063 # --------------------
1064 # If I `cd $REL-DIR', then to come back, I should `cd $BACKPATH'.
1065 # For instance `src/foo' => `../..'.
1066 # Works with non strictly increasing paths, i.e., `src/../lib' => `..'.
1071 foreach (split (/\//, $file))
1073 next if $_ eq '.' || $_ eq '';
1083 return join ('/', @res) || '.';
1086 ################################################################
1088 # Parse command line.
1089 sub parse_arguments ()
1092 &set_strictness ('gnu');
1095 Getopt::Long::config ("bundling");
1096 Getopt::Long::GetOptions
1098 'version' => \&version,
1100 'libdir:s' => \$libdir,
1101 'gnu' => sub { &set_strictness ('gnu'); },
1102 'gnits' => sub { &set_strictness ('gnits'); },
1103 'cygnus' => \$cygnus_mode,
1104 'foreign' => sub { &set_strictness ('foreign'); },
1105 'include-deps' => sub { $cmdline_use_dependencies = 1; },
1106 'i|ignore-deps' => sub { $cmdline_use_dependencies = 0; },
1107 'no-force' => sub { $force_generation = 0; },
1108 'f|force-missing'=> \$force_missing,
1109 'o|output-dir:s' => \$output_directory,
1110 'a|add-missing' => \$add_missing,
1111 'c|copy' => \$copy_missing,
1112 'v|verbose' => \$verbose,
1113 'Werror' => sub { $SIG{"__WARN__"} = sub { die $_[0] } },
1114 'Wno-error' => sub { $SIG{"__WARN__"} = 'DEFAULT' }
1118 foreach my $arg (@ARGV)
1120 # Handle $local:$input syntax. Note that we only examine the
1121 # first ":" file to see if it is automake input; the rest are
1122 # just taken verbatim. We still keep all the files around for
1123 # dependency checking, however.
1124 my ($local, $input, @rest) = split (/:/, $arg);
1131 # Strip .in; later on .am is tacked on. That is how the
1132 # automake input file is found. Maybe not the best way, but
1133 # it is easy to explain.
1135 or die "$me: invalid input file name `$arg'\n.";
1137 push (@input_files, $input);
1138 $output_files{$input} = join (':', ($local, @rest));
1141 # Take global strictness from whatever we currently have set.
1142 $default_strictness = $strictness;
1143 $default_strictness_name = $strictness_name;
1146 ################################################################
1148 # Generate a Makefile.in given the name of the corresponding Makefile and
1149 # the name of the file output by config.status.
1150 sub generate_makefile
1152 my ($output, $makefile) = @_;
1154 # Reset all the Makefile.am related variables.
1155 &initialize_per_input;
1157 # Name of input file ("Makefile.am") and output file
1158 # ("Makefile.in"). These have no directory components.
1159 $am_file_name = basename ($makefile) . '.am';
1160 $in_file_name = basename ($makefile) . '.in';
1162 # $OUTPUT is encoded. If it contains a ":" then the first element
1163 # is the real output file, and all remaining elements are input
1164 # files. We don't scan or otherwise deal with these input file,
1165 # other than to mark them as dependencies. See
1166 # &scan_autoconf_files for details.
1167 my (@secondary_inputs);
1168 ($output, @secondary_inputs) = split (/:/, $output);
1170 $relative_dir = dirname ($output);
1171 $am_relative_dir = dirname ($makefile);
1173 &read_main_am_file ($makefile . '.am');
1174 if (&handle_options)
1176 # Fatal error. Just return, so we can continue with next file.
1180 # There are a few install-related variables that you should not define.
1181 foreach my $var ('PRE_INSTALL', 'POST_INSTALL', 'NORMAL_INSTALL')
1183 if (&variable_defined ($var) && !$var_is_am{$var})
1185 &am_line_error ($var, "`$var' should not be defined");
1189 # At the toplevel directory, we might need config.guess, config.sub
1190 # or libtool scripts (ltconfig and ltmain.sh).
1191 if ($relative_dir eq '.')
1193 # libtool requires some files.
1194 &require_conf_file_with_conf_line ($libtool_line, $FOREIGN,
1198 # AC_CANONICAL_HOST and AC_CANONICAL_SYSTEM need config.guess and
1200 &require_config_file ($FOREIGN, 'config.guess', 'config.sub')
1204 # We still need Makefile.in here, because sometimes the `dist'
1205 # target doesn't re-run automake.
1206 if ($am_relative_dir eq $relative_dir)
1208 # Only distribute the files if they are in the same subdir as
1209 # the generated makefile.
1210 &push_dist_common ($in_file_name, $am_file_name);
1213 push (@sources, '$(SOURCES)')
1214 if &variable_defined ('SOURCES');
1216 # If OBJEXT/EXEEXT were not set in configure.in, do it, it
1217 # simplifies our task, and anyway starting with Autoconf 2.50, it
1218 # will always be defined, and this code will be dead.
1219 $output_vars .= "EXEEXT =\n"
1220 unless $seen_exeext;
1221 $output_vars .= "OBJEXT = o\n"
1222 unless $seen_objext;
1224 # Must do this after reading .am file. See read_main_am_file to
1225 # understand weird tricks we play there with variables.
1226 &define_variable ('subdir', $relative_dir);
1228 # Check first, because we might modify some state.
1230 &check_gnu_standards;
1231 &check_gnits_standards;
1233 &handle_configure ($output, $makefile, @secondary_inputs);
1236 &handle_ltlibraries;
1240 # This must be run after all the sources are scanned.
1244 # Re-init SOURCES. FIXME: other code shouldn't depend on this
1245 # (but currently does).
1246 macro_define ('SOURCES', 1, '', 'TRUE',
1247 join (' ', @sources), 'internal');
1248 &define_pretty_variable ('DIST_SOURCES', '', @dist_sources);
1260 &handle_minor_options;
1263 # This must come after most other rules.
1264 &handle_dist ($makefile);
1267 &do_check_merge_target;
1268 &handle_all ($output);
1271 if (&variable_defined('lib_LTLIBRARIES') &&
1272 &variable_defined('bin_PROGRAMS'))
1274 $output_rules .= "install-binPROGRAMS: install-libLTLIBRARIES\n\n";
1277 &handle_installdirs;
1279 &handle_factored_dependencies;
1283 if (! -d ($output_directory . '/' . $am_relative_dir))
1285 mkdir ($output_directory . '/' . $am_relative_dir, 0755);
1288 my ($out_file) = $output_directory . '/' . $makefile . ".in";
1289 if (! $force_generation && -e $out_file)
1291 my ($am_time) = (stat ($makefile . '.am'))[9];
1292 my ($in_time) = (stat ($out_file))[9];
1293 # FIXME: should cache these times.
1294 my ($conf_time) = (stat ($configure_ac))[9];
1295 # FIXME: how to do unsigned comparison?
1296 if ($am_time < $in_time || $am_time < $conf_time)
1298 # No need to update.
1301 if (-f 'aclocal.m4')
1303 my ($acl_time) = (stat _)[9];
1304 return if ($am_time < $acl_time);
1308 my $gm_file = new IO::File "> $out_file";
1311 warn "$me: ${am_file}.in: cannot write: $!\n";
1315 print "$me: creating ", $makefile, ".in\n" if $verbose;
1317 # In case we're running under MSWindows, don't write with CRLF
1318 # (as it causes problems for the dependency-file extraction in
1319 # AM_OUTPUT_DEPENDENCY_COMMANDS).
1322 print $gm_file $output_vars;
1323 # We make sure that `all:' is the first target.
1324 print $gm_file $output_all;
1325 print $gm_file $output_header;
1326 print $gm_file $output_rules;
1327 print $gm_file $output_trailer;
1329 if (! $gm_file->close)
1331 warn "$me: $am_file.in: cannot close: $!\n";
1337 ################################################################
1339 # Handle AUTOMAKE_OPTIONS variable. Return 1 on error, 0 otherwise.
1342 if (&variable_defined ('AUTOMAKE_OPTIONS'))
1344 foreach (&variable_value_as_list ('AUTOMAKE_OPTIONS', ''))
1347 if ($_ eq 'gnits' || $_ eq 'gnu' || $_ eq 'foreign')
1349 &set_strictness ($_);
1351 elsif ($_ eq 'cygnus')
1357 # An option like "../lib/ansi2knr" is allowed. With
1358 # no path prefix, we assume the required programs are
1359 # in this directory. We save the actual option for
1361 $options{'ansi2knr'} = $_;
1363 elsif ($_ eq 'no-installman' || $_ eq 'no-installinfo'
1364 || $_ eq 'dist-shar' || $_ eq 'dist-zip'
1365 || $_ eq 'dist-tarZ' || $_ eq 'dist-bzip2'
1366 || $_ eq 'dejagnu' || $_ eq 'no-texinfo.tex'
1367 || $_ eq 'readme-alpha' || $_ eq 'check-news'
1368 || $_ eq 'subdir-objects' || $_ eq 'nostdinc')
1370 # Explicitly recognize these.
1372 elsif ($_ eq 'no-dependencies')
1374 $use_dependencies = 0;
1376 elsif (/(\d+)\.(\d+)([a-z]?)(-[A-Za-z0-9]+)?/)
1378 # Got a version number.
1380 my ($rmajor, $rminor, $ralpha, $rfork) = ($1, $2, $3, $4);
1382 &prog_error ("version is incorrect: $VERSION")
1383 if $VERSION !~ /(\d+)\.(\d+)([a-z]?)(-[A-Za-z0-9]+)?/;
1385 my ($tmajor, $tminor, $talpha, $tfork) = ($1, $2, $3, $4);
1390 # 2.0 is better than 1.0.
1391 # 1.2 is better than 1.1.
1392 # 1.2a is better than 1.2.
1393 # If we require 3.4n-foo then we require something
1394 # >= 3.4n, with the `foo' fork identifier.
1395 if ($rmajor > $tmajor
1396 || ($rmajor == $tmajor && $rminor > $tminor)
1397 || ($rminor == $tminor && $rminor == $tminor
1398 && $ralpha gt $talpha)
1399 || ($rfork ne '' && $rfork ne $tfork))
1401 &am_line_error ('AUTOMAKE_OPTIONS',
1402 "require version $_, but have $VERSION");
1408 &am_line_error ('AUTOMAKE_OPTIONS',
1409 "option `" . $_ . "\' not recognized");
1414 if ($strictness == $GNITS)
1416 $options{'readme-alpha'} = 1;
1417 $options{'check-news'} = 1;
1424 # get_object_extension ($OUT)
1425 # ---------------------------
1426 # Return object extension. Just once, put some code into the output.
1427 # OUT is the name of the output file
1428 sub get_object_extension
1432 # Maybe require libtool library object files.
1433 my $extension = '.$(OBJEXT)';
1434 $extension = '.lo' if ($out =~ /\.la$/);
1436 # Check for automatic de-ANSI-fication.
1437 $extension = '$U' . $extension
1438 if defined $options{'ansi2knr'};
1440 $get_object_extension_was_run = 1;
1446 # Call finish function for each language that was used.
1447 sub handle_languages
1449 if ($use_dependencies)
1451 # Include auto-dep code. Don't include it if DEP_FILES would
1453 if (&saw_sources_p (0) && keys %dep_files)
1455 # Set location of depcomp.
1456 &define_variable ('depcomp', "\$(SHELL) $config_aux_dir/depcomp");
1458 &require_config_file ($FOREIGN, 'depcomp');
1460 my @deplist = sort keys %dep_files;
1462 # We define this as a conditional variable because BSD
1463 # make can't handle backslashes for continuing comments on
1464 # the following line.
1465 &define_pretty_variable ('DEP_FILES', 'AMDEP_TRUE', @deplist);
1467 # Generate each `include' individually. Irix 6 make will
1468 # not properly include several files resulting from a
1469 # variable expansion; generating many separate includes
1471 $output_rules .= "\n";
1472 foreach my $iter (@deplist)
1474 $output_rules .= (subst ('AMDEP_TRUE')
1475 . subst ('_am_include')
1477 . subst ('_am_quote')
1479 . subst ('_am_quote')
1483 $output_rules .= &file_contents ('depend');
1488 &define_variable ('depcomp', '');
1493 # Is the c linker needed?
1495 foreach my $ext (sort keys %extension_seen)
1497 my $lang = $languages{$extension_map{$ext}};
1499 # Get information on $LANG.
1500 my $pfx = $lang->autodep;
1501 my $fpfx = ($pfx eq '') ? 'CC' : $pfx;
1503 my $AMDEP = (($use_dependencies && $lang->autodep ne 'no')
1504 ? 'AMDEP' : 'FALSE');
1506 my %transform = ('EXT' => $ext,
1509 'LIBTOOL' => $seen_libtool,
1511 '-c' => $lang->compile_flag || '');
1513 # Generate the appropriate rules for this extension.
1514 if ($use_dependencies && $lang->autodep ne 'no'
1515 || defined $lang->compile)
1517 # Some C compilers don't support -c -o. Use it only if really
1519 my $output_flag = $lang->output_flag || '';
1522 && $lang->flags eq 'CFLAGS'
1523 && defined $options{'subdir-objects'});
1526 file_contents ('depend2',
1536 'COMPILE' => '$(' . $lang->compiler . ')',
1537 'LTCOMPILE' => '$(LT' . $lang->compiler . ')',
1538 '-o' => $output_flag);
1541 # Now include code for each specially handled object with this
1543 my %seen_files = ();
1544 foreach my $file (@{$lang_specific_files{$lang->name}})
1546 my ($derived, $source, $obj) = split (' ', $file);
1548 # We might see a given object twice, for instance if it is
1549 # used under different conditions.
1550 next if defined $seen_files{$obj};
1551 $seen_files{$obj} = 1;
1553 my $flags = $lang->flags || '';
1554 my $val = "${derived}_${flags}";
1556 (my $obj_compile = $lang->compile) =~ s/\(AM_$flags/\($val/;
1557 my $obj_ltcompile = '$(LIBTOOL) --mode=compile ' . $obj_compile;
1559 # We _need_ `-o' for per object rules.
1560 my $output_flag = $lang->output_flag || '-o';
1562 # Generate a transform which will turn suffix targets in
1563 # depend2.am into real targets for the particular objects we
1566 file_contents ('depend2',
1571 'SOURCE' => $source,
1573 'OBJOBJ' => "$obj.obj",
1574 'LTOBJ' => "$obj.lo",
1576 'COMPILE' => $obj_compile,
1577 'LTCOMPILE' => $obj_ltcompile,
1578 '-o' => $output_flag));
1581 # The rest of the loop is done once per language.
1582 next if defined $done{$lang};
1585 # Load the language dependent Makefile chunks.
1586 my %lang = map { uc ($_) => 0 } keys %languages;
1587 $lang{uc ($lang->name)} = 1;
1588 $output_rules .= file_contents ('lang-compile', %transform, %lang);
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 foreach my $var (@{$lang->config_vars})
1606 am_error ($lang->Name
1607 . " source seen but `$var' not defined in"
1608 . " `$configure_ac'")
1609 if !exists $configure_vars{$var};
1612 # The compiler's flag must be a configure variable.
1613 define_configure_variable ($lang->flags)
1614 if (defined $lang->flags);
1616 # Call the finisher.
1620 # If the project is entirely C++ or entirely Fortran 77 (i.e., 1
1621 # suffix rule was learned), don't bother with the C stuff. But if
1622 # anything else creeps in, then use it.
1624 if $need_link || scalar keys %suffix_rules > 1;
1628 if (! defined $done{$languages{'c'}})
1630 &define_configure_variable ($languages{'c'}->flags);
1631 &define_compiler_variable ($languages{'c'});
1633 define_linker_variable ($languages{'c'});
1637 # Output a rule to build from a YACC source. The output from YACC is
1638 # compiled with C or C++, depending on the extension of the YACC file.
1639 sub output_yacc_build_rule
1641 my ($yacc_suffix, $use_ylwrap) = @_;
1643 (my $c_suffix = $yacc_suffix) =~ tr/y/c/;
1645 # Generate rule for c/c++.
1646 $output_rules .= &file_contents ('yacc',
1647 ('YLWRAP' => $use_ylwrap,
1648 'YACC_SUFFIX' => $yacc_suffix,
1649 'C_SUFFIX' => $c_suffix));
1652 sub output_lex_build_rule
1654 my ($lex_suffix, $use_ylwrap) = @_;
1656 (my $c_suffix = $lex_suffix) =~ tr/l/c/;
1658 $output_rules .= &file_contents ('lex',
1659 ('YLWRAP' => $use_ylwrap,
1660 'LEX_SUFFIX' => $lex_suffix,
1661 'C_SUFFIX' => $c_suffix));
1664 # Check to make sure a source defined in LIBOBJS is not explicitly
1665 # mentioned. This is a separate function (as opposed to being inlined
1666 # in handle_source_transform) because it isn't always appropriate to
1668 sub check_libobjs_sources
1670 my ($one_file, $unxformed) = @_;
1672 foreach my $prefix ('', 'EXTRA_', 'dist_', 'nodist_',
1673 'dist_EXTRA_', 'nodist_EXTRA_')
1676 if (&variable_defined ($prefix . $one_file . '_SOURCES'))
1678 @files = &variable_value_as_list (($prefix
1679 . $one_file . '_SOURCES'),
1682 elsif ($prefix eq '')
1684 @files = ($unxformed . '.c');
1691 foreach my $file (@files)
1693 if (defined $libsources{$file})
1695 &am_line_error ($prefix . $one_file . '_SOURCES',
1696 "automatically discovered file `$file' should not be explicitly mentioned");
1703 # ($LINKER, @OBJECTS)
1704 # handle_single_transform_list ($VAR, $DERIVED, $OBJ, @FILES)
1705 # -----------------------------------------------------------
1706 # Does much of the actual work for handle_source_transform.
1708 # $DERIVED is the name of resulting executable or library
1709 # $OBJ is the object extension (e.g., `$U.lo')
1710 # @FILES is the list of source files to transform
1712 # $LINKER is name of linker to use (empty string for default linker)
1713 # @OBJECTS are names of objects
1714 sub handle_single_transform_list ($$$@)
1716 my ($var, $derived, $obj, @files) = @_;
1718 my $nonansi_obj = $obj;
1719 $nonansi_obj =~ s/\$U//g;
1720 my %linkers_used = ();
1722 # Turn sources into objects.
1725 # Configure substitutions in _SOURCES variables are errors.
1728 &am_line_error ($var, "$var includes configure substitution `$_'");
1732 # If the source file is in a subdirectory then the `.o' is
1733 # put into the current directory.
1735 # Split file name into base and extension.
1736 next if ! /^(?:(.*)\/)?([^\/]*)\.(.*)$/;
1738 my $directory = $1 || '';
1742 # We must generate a rule for the object if it requires its own flags.
1744 my ($linker, $object);
1746 $extension = &derive_suffix ($extension);
1747 my $lang = $languages{$extension_map{$extension}};
1750 &saw_extension ($extension);
1751 # Found the language, so see what it says.
1752 my $subr = 'lang_' . $lang->name . '_rewrite';
1753 # Note: computed subr call.
1754 my $r = & $subr ($directory, $base, $extension);
1755 # Skip this entry if we were asked not to process it.
1756 next if $r == $LANG_IGNORE;
1758 # Now extract linker and other info.
1759 $linker = $lang->linker;
1761 my $this_obj_ext = $lang->ansi ? $obj : $nonansi_obj;
1762 $object = $base . $this_obj_ext;
1764 if (defined $lang->flags
1765 && &variable_defined ($derived . '_' . $lang->flags))
1767 # We have a per-executable flag in effect for this
1768 # object. In this case we rewrite the object's
1769 # name to ensure it is unique. We also require
1770 # the `compile' program to deal with compilers
1771 # where `-c -o' does not work.
1773 # We choose the name `DERIVED_OBJECT' to ensure
1774 # (1) uniqueness, and (2) continuity between
1775 # invocations. However, this will result in a
1776 # name that is too long for losing systems, in
1777 # some situations. So we provide _SHORTNAME to
1780 my $dname = $derived;
1781 if (&variable_defined ($derived . '_SHORTNAME'))
1783 # FIXME: should use the same conditional as
1784 # the _SOURCES variable. But this is really
1785 # silly overkill -- nobody should have
1786 # conditional shortnames.
1787 $dname = &variable_value ($derived . '_SHORTNAME');
1789 $object = $dname . '-' . $object;
1791 &require_file ($FOREIGN, 'compile')
1792 if $lang->name eq 'c';
1794 &prog_error ("$lang->name flags defined without compiler")
1795 if ! defined $lang->compile;
1800 # If rewrite said it was ok, put the object into a
1802 if ($r == $LANG_SUBDIR && $directory ne '')
1804 $object = $directory . '/' . $object;
1807 # If doing dependency tracking, then we can't print
1808 # the rule. If we have a subdir object, we need to
1809 # generate an explicit rule. Actually, in any case
1810 # where the object is not in `.' we need a special
1811 # rule. The per-object rules in this case are
1812 # generated later, by handle_languages.
1813 if ($renamed || $directory ne '')
1815 my $obj_sans_ext = substr ($object, 0,
1816 - length ($this_obj_ext));
1817 push (@{$lang_specific_files{$lang->name}},
1818 "$derived $full $obj_sans_ext");
1821 elsif ($extension eq 'o')
1823 # This is probably the result of a direct suffix rule.
1824 # In this case we just accept the rewrite. FIXME:
1825 # this fails if we want libtool objects.
1826 $object = $base . '.' . $extension;
1831 # No error message here. Used to have one, but it was
1836 $linkers_used{$linker} = 1;
1838 push (@result, $object);
1840 if (defined $object_map{$object})
1842 if ($object_map{$object} ne $full)
1844 &am_error ("object `$object' created by `$full' and `$object_map{$object}'");
1850 $object_map{$object} = $full;
1852 # If file is in subdirectory, we need explicit
1854 if ($directory ne '' || $renamed)
1856 push (@dep_list, $full);
1859 # If resulting object is in subdir, we need to make
1860 # sure the subdir exists at build time.
1861 if ($object =~ /\//)
1863 # FIXME: check that $DIRECTORY is somewhere in the
1866 # We don't allow `..' in object file names for
1867 # *any* source, not just Java. For Java it just
1868 # doesn't make sense, but in general it is
1869 # a problem because we can't pick a good name for
1871 if ($object =~ /(\/|^)\.\.\//)
1873 &am_error ("`$full' contains `..' component but should not");
1876 # Make sure object is removed by `make mostlyclean'.
1877 $compile_clean_files{$object} = $MOSTLY_CLEAN;
1879 push (@dep_list, $directory . '/.dirstamp');
1881 # If we're generating dependencies, we also want
1882 # to make sure that the appropriate subdir of the
1883 # .deps directory is created.
1884 if ($use_dependencies)
1886 push (@dep_list, '.deps/' . $directory . '/.dirstamp');
1889 if (! defined $directory_map{$directory})
1891 $directory_map{$directory} = 1;
1893 # Directory must be removed by `make distclean'.
1894 $compile_clean_files{$directory . "/.dirstamp"} =
1896 $output_rules .= ($directory . "/.dirstamp:\n"
1897 . "\t\@\$(mkinstalldirs) $directory\n"
1898 . "\t\@: > $directory/.dirstamp\n");
1899 if ($use_dependencies)
1901 $output_rules .= ('.deps/' . $directory
1903 . "\t\@\$(mkinstalldirs) .deps/$directory\n"
1904 . "\t\@: > .deps/$directory/.dirstamp\n");
1909 &pretty_print_rule ($object . ':', "\t", @dep_list)
1910 if scalar @dep_list > 0;
1913 # Transform .o or $o file into .P file (for automatic
1916 && ($lang->autodep ne 'no'
1917 || $lang->derived_autodep eq 'yes'))
1919 my $depfile = $object;
1920 $depfile =~ s/\.([^.]*)$/.P$1/;
1921 $depfile =~ s/\$\(OBJEXT\)$/o/;
1922 $dep_files{'$(DEPDIR)/' . $depfile} = 1;
1926 return (&resolve_linker (%linkers_used), @result);
1931 # Handle SOURCE->OBJECT transform for one program or library.
1933 # canonical (transformed) name of object to build
1934 # actual name of object to build
1935 # object extension (ie either `.o' or `$o'.
1936 # Return result is name of linker variable that must be used.
1937 # Empty return means just use `LINK'.
1938 sub handle_source_transform
1940 # one_file is canonical name. unxformed is given name. obj is
1942 my ($one_file, $unxformed, $obj) = @_;
1946 if (&variable_defined ($one_file . "_OBJECTS"))
1948 &am_line_error ($one_file . '_OBJECTS',
1949 $one_file . '_OBJECTS', 'should not be defined');
1950 # No point in continuing.
1955 foreach my $prefix ('', 'EXTRA_', 'dist_', 'nodist_',
1956 'dist_EXTRA_', 'nodist_EXTRA_')
1958 my $var = $prefix . $one_file . "_SOURCES";
1960 if !variable_defined ($var);
1962 # We are going to define _OBJECTS variables using the prefix.
1963 # Then we glom them all together. So we can't use the null
1964 # prefix here as we need it later.
1965 my $xpfx = ($prefix eq '') ? 'am_' : $prefix;
1967 # Keep track of which prefixes we saw.
1968 $used_pfx{$xpfx} = 1
1969 unless $prefix =~ /EXTRA_/;
1971 push (@sources, '$(' . $prefix . $one_file . "_SOURCES)");
1972 push (@dist_sources, '$(' . $prefix . $one_file . "_SOURCES)")
1973 unless $prefix =~ /^nodist_/;
1974 foreach my $cond (variable_conditions ($var))
1976 my @files = &variable_value_as_list ($var, $cond);
1977 my ($temp, @result) =
1978 &handle_single_transform_list ($var, $one_file, $obj,
1980 # If there are no files to compile, don't require a linker (yet).
1984 # Define _OBJECTS conditionally.
1985 &define_pretty_variable ($xpfx . $one_file . '_OBJECTS',
1987 unless $prefix =~ /EXTRA_/;
1991 my @keys = sort keys %used_pfx;
1992 if (scalar @keys == 0)
1994 &define_variable ($one_file . "_SOURCES", $unxformed . ".c");
1995 push (@sources, $unxformed . '.c');
1996 push (@dist_sources, $unxformed . '.c');
1998 my ($temp, @result) =
1999 &handle_single_transform_list ($one_file . '_SOURCES',
2002 $linker = $temp if $linker eq '';
2003 &define_pretty_variable ($one_file . "_OBJECTS", '', @result)
2007 grep ($_ = '$(' . $_ . $one_file . '_OBJECTS)', @keys);
2008 &define_pretty_variable ($one_file . '_OBJECTS', '', @keys);
2011 # If we want to use `LINK' we must make sure it is defined.
2021 # handle_lib_objects ($XNAME, $VAR)
2022 # ---------------------------------
2023 # Special-case @ALLOCA@ and @LIBOBJS@ in _LDADD or _LIBADD variables.
2024 # Also, generate _DEPENDENCIES variable if appropriate.
2026 # transformed name of object being built, or empty string if no object
2027 # name of _LDADD/_LIBADD-type variable to examine
2028 # Returns 1 if LIBOBJS seen, 0 otherwise.
2029 sub handle_lib_objects
2031 my ($xname, $var) = @_;
2033 &prog_error ("handle_lib_objects: $var undefined")
2034 if ! &variable_defined ($var);
2037 foreach my $cond (&variable_conditions ($var))
2039 if (&handle_lib_objects_cond ($xname, $var, $cond))
2047 # Subroutine of handle_lib_objects: handle a particular condition.
2048 sub handle_lib_objects_cond
2050 my ($xname, $var, $cond) = @_;
2052 # We recognize certain things that are commonly put in LIBADD or
2056 my $seen_libobjs = 0;
2059 foreach my $lsearch (&variable_value_as_list ($var, $cond))
2061 # Skip -lfoo and -Ldir; these are explicitly allowed.
2062 next if $lsearch =~ /^-[lL]/;
2063 if (! $flagvar && $lsearch =~ /^-/)
2065 if ($var =~ /^(.*)LDADD$/)
2067 # Skip -dlopen and -dlpreopen; these are explicitly allowed.
2068 next if $lsearch =~ /^-dl(pre)?open$/;
2069 &am_line_error ($var, "linker flags such as `$lsearch' belong in `${1}LDFLAGS");
2073 # Only get this error once.
2075 &am_line_error ($var, "linker flags such as `$lsearch' belong in `${1}LDFLAGS");
2079 # Assume we have a file of some sort, and push it onto the
2080 # dependency list. Autoconf substitutions are not pushed;
2081 # rarely is a new dependency substituted into (eg) foo_LDADD
2082 # -- but "bad things (eg -lX11) are routinely substituted.
2083 # Note that LIBOBJS and ALLOCA are exceptions to this rule,
2084 # and handled specially below.
2085 push (@dep_list, $lsearch)
2086 unless $lsearch =~ /^\@.*\@$/;
2088 # Automatically handle @LIBOBJS@ and @ALLOCA@. Basically this
2089 # means adding entries to dep_files.
2090 if ($lsearch =~ /^\@(LT)?LIBOBJS\@$/)
2092 my $myobjext = ($1 ? 'l' : '') . 'o';
2094 push (@dep_list, $lsearch);
2096 if (! keys %libsources
2097 && ! &variable_defined ($1 . 'LIBOBJS'))
2099 &am_line_error ($var, "\@$1" . "LIBOBJS\@ seen but never set in `$configure_ac'");
2102 foreach my $iter (keys %libsources)
2104 if ($iter =~ /\.([cly])$/)
2106 &saw_extension ($1);
2107 &saw_extension ('c');
2110 if ($iter =~ /\.h$/)
2112 &require_file_with_line ($var, $FOREIGN, $iter);
2114 elsif ($iter ne 'alloca.c')
2116 my $rewrite = $iter;
2117 $rewrite =~ s/\.c$/.P$myobjext/;
2118 $dep_files{'$(DEPDIR)/' . $rewrite} = 1;
2119 ($rewrite = $iter) =~ s/(\W)/\\$1/g;
2120 $rewrite = "^" . $rewrite . "\$";
2121 # Only require the file if it is not a built source.
2122 if (! &variable_defined ('BUILT_SOURCES')
2123 || ! grep (/$rewrite/,
2124 &variable_value_as_list ('BUILT_SOURCES',
2127 &require_file_with_line ($var, $FOREIGN, $iter);
2132 elsif ($lsearch =~ /^\@(LT)?ALLOCA\@$/)
2134 my $myobjext = ($1 ? 'l' : '') . 'o';
2136 push (@dep_list, $lsearch);
2137 &am_line_error ($var,
2138 "\@$1" . "ALLOCA\@ seen but `AC_FUNC_ALLOCA' not in `$configure_ac'")
2139 if ! defined $libsources{'alloca.c'};
2140 $dep_files{'$(DEPDIR)/alloca.P' . $myobjext} = 1;
2141 &require_file_with_line ($var, $FOREIGN, 'alloca.c');
2142 &saw_extension ('c');
2146 if ($xname ne '' && ! &variable_defined ($xname . '_DEPENDENCIES', $cond))
2148 &define_pretty_variable ($xname . '_DEPENDENCIES', $cond, @dep_list);
2151 return $seen_libobjs;
2154 # Canonicalize the input parameter
2158 $string =~ tr/A-Za-z0-9_\@/_/c;
2162 # Canonicalize a name, and check to make sure the non-canonical name
2163 # is never used. Returns canonical name. Arguments are name and a
2164 # list of suffixes to check for.
2165 sub check_canonical_spelling
2167 my ($name, @suffixes) = @_;
2169 my $xname = &canonicalize ($name);
2170 if ($xname ne $name)
2172 foreach my $xt (@suffixes)
2174 &am_line_error ("$name$xt",
2175 "invalid variable `$name$xt'; "
2176 . "should be `$xname$xt'")
2177 if &variable_defined ("$name$xt");
2187 # Set up the compile suite.
2188 sub handle_compile ()
2191 unless $get_object_extension_was_run;
2194 my $default_includes = '';
2195 if (! defined $options{'nostdinc'})
2197 $default_includes = ' -I. -I$(srcdir)';
2199 if (&variable_defined ('CONFIG_HEADER'))
2201 foreach my $hdr (split (' ', &variable_value ('CONFIG_HEADER')))
2203 $default_includes .= ' -I' . dirname ($hdr);
2208 my (@mostly_rms, @dist_rms);
2209 foreach my $item (sort keys %compile_clean_files)
2211 if ($compile_clean_files{$item} == $MOSTLY_CLEAN)
2213 push (@mostly_rms, "\t-rm -f $item");
2215 elsif ($compile_clean_files{$item} == $DIST_CLEAN)
2217 push (@dist_rms, "\t-rm -f $item");
2221 &prog_error ("invalid entry in \%compile_clean_files");
2225 my ($coms, $vars, $rules) =
2226 &file_contents_internal (1, "$libdir/am/compile.am",
2227 ('DEFAULT_INCLUDES' => $default_includes,
2228 'MOSTLYRMS' => join ("\n", @mostly_rms),
2229 'DISTRMS' => join ("\n", @dist_rms)));
2230 $output_vars .= $vars;
2231 $output_rules .= "$coms$rules";
2235 # Output the libtool compilation rules.
2236 $output_rules .= &file_contents ('libtool');
2239 # Check for automatic de-ANSI-fication.
2240 if (defined $options{'ansi2knr'})
2242 if (! $am_c_prototypes)
2244 &am_line_error ('AUTOMAKE_OPTIONS',
2245 "option `ansi2knr' in use but `AM_C_PROTOTYPES' not in `$configure_ac'");
2246 &keyed_aclocal_warning ('AM_C_PROTOTYPES');
2247 # Only give this error once.
2248 $am_c_prototypes = 1;
2251 # topdir is where ansi2knr should be.
2252 if ($options{'ansi2knr'} eq 'ansi2knr')
2254 # Only require ansi2knr files if they should appear in
2256 &require_file_with_line ('AUTOMAKE_OPTIONS', $FOREIGN,
2257 'ansi2knr.c', 'ansi2knr.1');
2259 # ansi2knr needs to be built before subdirs, so unshift it.
2260 unshift (@all, '$(ANSI2KNR)');
2263 my $ansi2knr_dir = '';
2264 $ansi2knr_dir = dirname ($options{'ansi2knr'})
2265 if $options{'ansi2knr'} ne 'ansi2knr';
2267 $output_rules .= &file_contents ('ansi2knr',
2268 ('ANSI2KNR-DIR' => $ansi2knr_dir));
2275 # handle_programs ()
2276 # ------------------
2277 # Handle C programs.
2280 my @proglist = &am_install_var ('progs', 'PROGRAMS',
2281 'bin', 'sbin', 'libexec', 'pkglib',
2283 return if ! @proglist;
2285 my $seen_libobjs = 0;
2286 foreach my $one_file (@proglist)
2288 my $obj = &get_object_extension ($one_file);
2290 # Canonicalize names and check for misspellings.
2291 my $xname = &check_canonical_spelling ($one_file, '_LDADD', '_LDFLAGS',
2292 '_SOURCES', '_OBJECTS',
2295 my $linker = &handle_source_transform ($xname, $one_file, $obj);
2298 if (&variable_defined ($xname . "_LDADD"))
2300 if (&handle_lib_objects ($xname, $xname . '_LDADD'))
2308 # User didn't define prog_LDADD override. So do it.
2309 &define_variable ($xname . '_LDADD', '$(LDADD)');
2311 # This does a bit too much work. But we need it to
2312 # generate _DEPENDENCIES when appropriate.
2313 if (&variable_defined ('LDADD'))
2315 if (&handle_lib_objects ($xname, 'LDADD'))
2320 elsif (! &variable_defined ($xname . '_DEPENDENCIES'))
2322 &define_variable ($xname . '_DEPENDENCIES', '');
2327 if (&variable_defined ($xname . '_LIBADD'))
2329 &am_line_error ($xname . '_LIBADD',
2330 "use `" . $xname . "_LDADD', not `"
2331 . $xname . "_LIBADD'");
2334 if (! &variable_defined ($xname . '_LDFLAGS'))
2336 # Define the prog_LDFLAGS variable.
2337 &define_variable ($xname . '_LDFLAGS', '');
2340 # Determine program to use for link.
2342 if (&variable_defined ($xname . '_LINK'))
2344 $xlink = $xname . '_LINK';
2348 $xlink = $linker ? $linker : 'LINK';
2351 $output_rules .= &file_contents ('program',
2352 ('PROGRAM' => $one_file,
2353 'XPROGRAM' => $xname,
2354 'XLINK' => $xlink));
2357 if (&variable_defined ('LDADD') && &handle_lib_objects ('', 'LDADD'))
2364 foreach my $one_file (@proglist)
2366 my $xname = &canonicalize ($one_file);
2368 if (&variable_defined ($xname . '_LDADD'))
2370 &check_libobjs_sources ($xname, $xname . '_LDADD');
2372 elsif (&variable_defined ('LDADD'))
2374 &check_libobjs_sources ($xname, 'LDADD');
2381 # handle_libraries ()
2382 # -------------------
2384 sub handle_libraries
2386 my @liblist = &am_install_var ('libs', 'LIBRARIES',
2387 'lib', 'pkglib', 'noinst', 'check');
2388 return if ! @liblist;
2390 my %valid = &am_primary_prefixes ('LIBRARIES', 0, 'lib', 'pkglib',
2392 if (! defined $configure_vars{'RANLIB'})
2394 foreach my $key (keys %valid)
2396 if (&variable_defined ($key . '_LIBRARIES'))
2398 &am_line_error ($key . '_LIBRARIES', "library used but `RANLIB' not defined in `$configure_ac'");
2399 # Only get this error once. If this is ever printed,
2401 $configure_vars{'RANLIB'} = 'BUG';
2407 my $seen_libobjs = 0;
2408 foreach my $onelib (@liblist)
2410 # Check that the library fits the standard naming convention.
2411 if ($onelib !~ /^lib.*\.a$/)
2413 # FIXME should put line number here. That means mapping
2414 # from library name back to variable name.
2415 &am_error ("`$onelib' is not a standard library name");
2418 my $obj = &get_object_extension ($onelib);
2420 # Canonicalize names and check for misspellings.
2421 my $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_SOURCES',
2422 '_OBJECTS', '_DEPENDENCIES',
2425 if (! &variable_defined ($xlib . '_AR'))
2427 &define_variable ($xlib . '_AR', '$(AR) cru');
2430 if (&variable_defined ($xlib . '_LIBADD'))
2432 if (&handle_lib_objects ($xlib, $xlib . '_LIBADD'))
2439 # Generate support for conditional object inclusion in
2441 &define_variable ($xlib . "_LIBADD", '');
2444 if (&variable_defined ($xlib . '_LDADD'))
2446 &am_line_error ($xlib . '_LDADD',
2447 "use `" . $xlib . "_LIBADD', not `"
2448 . $xlib . "_LDADD'");
2451 # Make sure we at look at this.
2452 &examine_variable ($xlib . '_DEPENDENCIES');
2454 &handle_source_transform ($xlib, $onelib, $obj);
2456 $output_rules .= &file_contents ('library',
2457 ('LIBRARY' => $onelib,
2458 'XLIBRARY' => $xlib));
2463 foreach my $onelib (@liblist)
2465 my $xlib = &canonicalize ($onelib);
2466 if (&variable_defined ($xlib . '_LIBADD'))
2468 &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
2475 # handle_ltlibraries ()
2476 # ---------------------
2477 # Handle shared libraries.
2478 sub handle_ltlibraries
2480 my @liblist = &am_install_var ('ltlib', 'LTLIBRARIES',
2481 'noinst', 'lib', 'pkglib', 'check');
2482 return if ! @liblist;
2485 my %valid = &am_primary_prefixes ('LTLIBRARIES', 0, 'lib', 'pkglib',
2488 foreach my $key (keys %valid)
2490 if (&variable_defined ($key . '_LTLIBRARIES'))
2494 &am_line_error ($key . '_LTLIBRARIES', "library used but `LIBTOOL' not defined in `$configure_ac'");
2495 # Only get this error once. If this is ever printed,
2497 $configure_vars{'LIBTOOL'} = 'BUG';
2501 # Get the installation directory of each library.
2502 for (&variable_value_as_list ($key . '_LTLIBRARIES', 'all'))
2506 &am_error ("`$_' is already going to be installed in `$instdirs{$_}'");
2510 $instdirs{$_} = $key;
2516 my $seen_libobjs = 0;
2517 foreach my $onelib (@liblist)
2519 my $obj = &get_object_extension ($onelib);
2521 # Canonicalize names and check for misspellings.
2522 my $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_LDFLAGS',
2523 '_SOURCES', '_OBJECTS',
2526 if (! &variable_defined ($xlib . '_LDFLAGS'))
2528 # Define the lib_LDFLAGS variable.
2529 &define_variable ($xlib . '_LDFLAGS', '');
2532 # Check that the library fits the standard naming convention.
2533 my $libname_rx = "^lib.*\.la";
2534 if ((&variable_defined ($xlib . '_LDFLAGS')
2535 && grep (/-module/, &variable_value_as_list ($xlib . '_LDFLAGS',
2537 || (&variable_defined ('LDFLAGS')
2538 && grep (/-module/, &variable_value_as_list ('LDFLAGS',
2541 # Relax name checking for libtool modules.
2542 $libname_rx = "\.la";
2544 if ($onelib !~ /$libname_rx$/)
2546 # FIXME this should only be a warning for foreign packages
2547 # FIXME should put line number here. That means mapping
2548 # from library name back to variable name.
2549 &am_error ("`$onelib' is not a standard libtool library name");
2552 if (&variable_defined ($xlib . '_LIBADD'))
2554 if (&handle_lib_objects ($xlib, $xlib . '_LIBADD'))
2561 # Generate support for conditional object inclusion in
2563 &define_variable ($xlib . "_LIBADD", '');
2566 if (&variable_defined ($xlib . '_LDADD'))
2568 &am_line_error ($xlib . '_LDADD',
2569 "use `" . $xlib . "_LIBADD', not `"
2570 . $xlib . "_LDADD'");
2573 # Make sure we at look at this.
2574 &examine_variable ($xlib . '_DEPENDENCIES');
2576 my $linker = &handle_source_transform ($xlib, $onelib, $obj);
2578 # Determine program to use for link.
2580 if (&variable_defined ($xlib . '_LINK'))
2582 $xlink = $xlib . '_LINK';
2586 $xlink = $linker ? $linker : 'LINK';
2590 if ($instdirs{$onelib} eq 'EXTRA'
2591 || $instdirs{$onelib} eq 'noinst'
2592 || $instdirs{$onelib} eq 'check')
2594 # It's an EXTRA_ library, so we can't specify -rpath,
2595 # because we don't know where the library will end up.
2596 # The user probably knows, but generally speaking automake
2597 # doesn't -- and in fact configure could decide
2598 # dynamically between two different locations.
2603 $rpath = ('-rpath $(' . $instdirs{$onelib} . 'dir)');
2606 $output_rules .= &file_contents ('ltlibrary',
2607 ('LTLIBRARY' => $onelib,
2608 'XLTLIBRARY' => $xlib,
2610 'XLINK' => $xlink));
2615 foreach my $onelib (@liblist)
2617 my $xlib = &canonicalize ($onelib);
2618 if (&variable_defined ($xlib . '_LIBADD'))
2620 &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
2626 # See if any _SOURCES variable were misspelled. Also, make sure that
2627 # EXTRA_ variables don't contain configure substitutions.
2630 foreach my $varname (keys %var_value)
2632 foreach my $primary ('_SOURCES', '_LIBADD', '_LDADD', '_LDFLAGS',
2635 if ($varname =~ /$primary$/ && ! $content_seen{$varname})
2637 &am_line_error ($varname,
2638 "invalid unused variable name: `$varname'");
2647 # NOTE we no longer automatically clean SCRIPTS, because it is
2648 # useful to sometimes distribute scripts verbatim. This happens
2649 # eg in Automake itself.
2650 &am_install_var ('-candist', 'scripts', 'SCRIPTS',
2651 'bin', 'sbin', 'libexec', 'pkgdata',
2654 my $scripts_installed = 0;
2655 # Set $scripts_installed if appropriate. Make sure we only find
2656 # scripts which are actually installed -- this is why we can't
2657 # simply use the return value of am_install_var.
2658 my %valid = &am_primary_prefixes ('SCRIPTS', 1, 'bin', 'sbin',
2659 'libexec', 'pkgdata',
2661 foreach my $key (keys %valid)
2663 if ($key ne 'noinst'
2665 && &variable_defined ($key . '_SCRIPTS'))
2667 $scripts_installed = 1;
2668 # push (@check_tests, 'check-' . $key . 'SCRIPTS');
2674 # ($OUTFILE, $VFILE, @CLEAN_FILES)
2675 # &scan_texinfo_file ($FILENAME)
2676 # ------------------------------
2677 # $OUTFILE is the name of the info file produced by $FILENAME.
2678 # $VFILE is the name of the version.texi file used (empty if none).
2679 # @CLEAN_FILES is the list of by products (indexes etc.)
2680 sub scan_texinfo_file
2682 my ($filename) = @_;
2684 # These are always created, no matter whether indexes are used or not.
2685 my @clean_suffixes = ('aux', 'dvi', 'log', 'ps', 'toc',
2686 # grep new.*index texinfo.tex
2687 'cp', 'fn', 'ky', 'vr', 'tp', 'pg');
2689 # There are predefined indexes which don't follow the regular rules.
2690 my %predefined_index =
2693 'c' => 'cps', 'f' => 'fns', 'k' => 'kys',
2694 'v' => 'vrs', 't' => 'tps', 'p' => 'pgs'
2697 # There are commands which include a hidden index command.
2701 'fn' => 'fns', 'un' => 'fns',
2702 'typefn' => 'fns', 'typefun' => 'fns',
2703 'mac' => 'fns', 'spec' => 'fns',
2704 'op' => 'fns', 'typeop' => 'fns',
2705 'method' => 'fns', 'typemethod' => 'fns',
2707 'vr' => 'vrs', 'var' => 'vrs',
2708 'typevr' => 'vrs', 'typevar' => 'vrs',
2711 'ivar' => 'vrs', 'typeivar' => 'vrs',
2716 # Indexes stored into another one. In this case, the *.??s file
2718 my @syncodeindexes = ();
2720 my $texi = new IO::File ("< $filename");
2723 &am_error ("couldn't open `$filename': $!");
2726 print "$me: reading $filename\n" if $verbose;
2728 my ($outfile, $vfile);
2729 while ($_ = $texi->getline)
2731 if (/^\@setfilename +(\S+)/)
2734 if ($outfile =~ /\.(.+)$/ && $1 ne 'info')
2736 &am_file_error ($filename, "$.: ",
2737 "output `$outfile' has unrecognized extension");
2741 # A "version.texi" file is actually any file whose name
2742 # matches "vers*.texi".
2743 elsif (/^\@include\s+(vers[^.]*\.texi)\s*$/)
2748 # Try to find what are the indexes which are used.
2750 # Creating a new category of index.
2751 elsif (/^\@def(code)?index (\w+)/)
2753 push @clean_suffixes, $2;
2756 # Storing in a predefined index.
2757 elsif (/^\@([cfkvtp])index /)
2759 push @clean_suffixes, $predefined_index{$1};
2761 elsif (/^\@def(\w+) /)
2763 push @clean_suffixes, $hidden_index{$1}
2764 if defined $hidden_index{$1};
2767 # Merging an index into an another.
2768 elsif (/^\@syn(code)?index (\w+) \w+/)
2770 push @syncodeindexes, "$2s";
2778 &am_error ("`$filename' missing \@setfilename");
2782 my $infobase = basename ($filename);
2783 $infobase =~ s/\.te?xi(nfo)?$//;
2784 # FIXME: I don't understand why, but I can't use "$infobase.$_" => 1.
2785 my %clean_files = map { "$infobase" . ".$_" => 1 } @clean_suffixes;
2786 grep { delete $clean_files{"$infobase.$_"} } @syncodeindexes;
2787 return ($outfile, $vfile, (sort keys %clean_files));
2791 # ($DO-SOMETHING, $TEXICLEANS)
2792 # handle_texinfo_helper ()
2794 # Handle all Texinfo source; helper for handle_texinfo
2795 sub handle_texinfo_helper
2797 &am_line_error ('TEXINFOS',
2798 "`TEXINFOS' is an anachronism; use `info_TEXINFOS'")
2799 if &variable_defined ('TEXINFOS');
2800 return (0, '') if (! &variable_defined ('info_TEXINFOS')
2801 && ! &variable_defined ('html_TEXINFOS'));
2803 if (&variable_defined ('html_TEXINFOS'))
2805 &am_line_error ('html_TEXINFOS',
2806 "HTML generation not yet supported");
2810 my @texis = &variable_value_as_list ('info_TEXINFOS', 'all');
2812 my (@info_deps_list, @dvis_list, @texi_deps);
2819 foreach my $info_cursor (@texis)
2821 my $infobase = $info_cursor;
2822 $infobase =~ s/\.(txi|texinfo|texi)$//;
2824 if ($infobase eq $info_cursor)
2826 # FIXME: report line number.
2827 &am_error ("texinfo file `$info_cursor' has unrecognized extension");
2830 $texi_suffixes{$1} = 1;
2832 # If 'version.texi' is referenced by input file, then include
2833 # automatic versioning capability.
2834 my ($out_file, $vtexi, @clean_files) =
2835 &scan_texinfo_file ("$relative_dir/$info_cursor")
2837 push (@texi_cleans, @clean_files);
2841 &am_error ("`$vtexi', included in `$info_cursor', also included in `$versions{$vtexi}'")
2842 if (defined $versions{$vtexi});
2843 $versions{$vtexi} = $info_cursor;
2845 # We number the stamp-vti files. This is doable since the
2846 # actual names don't matter much. We only number starting
2847 # with the second one, so that the common case looks nice.
2848 my $vti = ($done ? $done : 'vti');
2851 &require_conf_file_with_line ('info_TEXINFOS', $FOREIGN,
2855 if ($config_aux_dir_set_in_configure_in)
2857 $conf_dir = $config_aux_dir;
2858 $conf_dir .= '/' unless $conf_dir =~ /\/$/;
2862 $conf_dir = '$(srcdir)/';
2864 $output_rules .= &file_contents ('texi-vers',
2865 ('TEXI' => $info_cursor,
2868 'MDDIR' => $conf_dir));
2871 # If user specified file_TEXINFOS, then use that as explicit
2874 push (@texi_deps, $info_cursor);
2875 # Prefix with $(srcdir) because some version of make won't
2876 # work if the target has it and the dependency doesn't.
2877 push (@texi_deps, '$(srcdir)/' . $vtexi) if $vtexi;
2879 my $canonical = &canonicalize ($infobase);
2880 if (&variable_defined ($canonical . "_TEXINFOS"))
2882 push (@texi_deps, '$(' . $canonical . '_TEXINFOS)');
2883 &push_dist_common ('$(' . $canonical . '_TEXINFOS)');
2886 $output_rules .= ("\n" . $out_file . ": "
2887 . join (' ', @texi_deps)
2888 . "\n" . $infobase . ".dvi: "
2889 . join (' ', @texi_deps)
2892 push (@info_deps_list, $out_file);
2893 push (@dvis_list, $infobase . '.dvi');
2896 # Handle location of texinfo.tex.
2897 my $need_texi_file = 0;
2901 $texinfodir = '$(top_srcdir)/../texinfo';
2902 &define_variable ('TEXINFO_TEX', "$texinfodir/texinfo.tex");
2905 elsif ($config_aux_dir_set_in_configure_in)
2907 $texinfodir = $config_aux_dir;
2908 &define_variable ('TEXINFO_TEX', "$texinfodir/texinfo.tex");
2909 $need_texi_file = 2; # so that we require_conf_file later
2911 elsif (&variable_defined ('TEXINFO_TEX'))
2913 # The user defined TEXINFO_TEX so assume he knows what he is
2915 $texinfodir = ('$(srcdir)/'
2916 . dirname (&variable_value ('TEXINFO_TEX')));
2920 $texinfodir = '$(srcdir)';
2921 $need_texi_file = 1;
2924 foreach my $txsfx (sort keys %texi_suffixes)
2926 $output_rules .= &file_contents ('texibuild',
2927 ('TEXINFODIR' => $texinfodir,
2928 'SUFFIX' => $txsfx));
2932 my $texiclean = &pretty_print_internal ("", "\t ", @texi_cleans);
2934 push (@dist_targets, 'dist-info');
2936 if (! defined $options{'no-installinfo'})
2938 # Make sure documentation is made and installed first. Use
2939 # $(INFO_DEPS), not 'info', because otherwise recursive makes
2940 # get run twice during "make all".
2941 unshift (@all, '$(INFO_DEPS)');
2944 &define_variable ("INFO_DEPS", join (' ', @info_deps_list));
2945 &define_variable ("DVIS", join (' ', @dvis_list));
2946 # This next isn't strictly needed now -- the places that look here
2947 # could easily be changed to look in info_TEXINFOS. But this is
2948 # probably better, in case noinst_TEXINFOS is ever supported.
2949 &define_variable ("TEXINFOS", &variable_value ('info_TEXINFOS'));
2951 # Do some error checking. Note that this file is not required
2952 # when in Cygnus mode; instead we defined TEXINFO_TEX explicitly
2954 if ($need_texi_file && ! defined $options{'no-texinfo.tex'})
2956 if ($need_texi_file > 1)
2958 &require_conf_file_with_line ('info_TEXINFOS', $FOREIGN,
2963 &require_file_with_line ('info_TEXINFOS', $FOREIGN, 'texinfo.tex');
2967 return (1, $texiclean);
2972 # Handle all Texinfo source.
2975 my ($do_something, $texiclean) = handle_texinfo_helper ();
2976 $output_rules .= &file_contents ('texinfos',
2977 ('TEXICLEAN' => $texiclean,
2978 'LOCAL-TEXIS' => $do_something));
2981 # Handle any man pages.
2982 sub handle_man_pages
2984 &am_line_error ('MANS', "`MANS' is an anachronism; use `man_MANS'")
2985 if &variable_defined ('MANS');
2987 # Find all the sections in use. We do this by first looking for
2988 # "standard" sections, and then looking for any additional
2989 # sections used in man_MANS.
2990 my (%sections, %vlist);
2991 # We handle nodist_ for uniformity. man pages aren't distributed
2992 # by default so it isn't actually very important.
2993 foreach my $pfx ('', 'dist_', 'nodist_')
2995 # Add more sections as needed.
2996 foreach my $section ('0'..'9', 'n', 'l')
2998 if (&variable_defined ($pfx . 'man' . $section . '_MANS'))
3000 $sections{$section} = 1;
3001 $vlist{'$(' . $pfx . 'man' . $section . '_MANS)'} = 1;
3003 &push_dist_common ('$(' . $pfx . 'man' . $section . '_MANS)')
3008 if (&variable_defined ($pfx . 'man_MANS'))
3010 $vlist{'$(' . $pfx . 'man_MANS)'} = 1;
3011 foreach (&variable_value_as_list ($pfx . 'man_MANS', 'all'))
3013 # A page like `foo.1c' goes into man1dir.
3014 if (/\.([0-9a-z])([a-z]*)$/)
3020 &push_dist_common ('$(' . $pfx . 'man_MANS)')
3025 return unless %sections;
3027 # Now for each section, generate an install and unintall rule.
3028 # Sort sections so output is deterministic.
3029 foreach my $section (sort keys %sections)
3031 $output_rules .= &file_contents ('mans', ('SECTION' => $section));
3034 $output_vars .= &file_contents ('mans-vars',
3035 ('MANS' => join (' ', sort keys %vlist)));
3037 if (! defined $options{'no-installman'})
3039 push (@all, '$(MANS)');
3043 # Handle DATA variables.
3046 &am_install_var ('-noextra', '-candist', 'data', 'DATA',
3047 'data', 'sysconf', 'sharedstate', 'localstate',
3048 'pkgdata', 'noinst', 'check');
3055 if (&variable_defined ('SUBDIRS'))
3057 $output_rules .= ("tags-recursive:\n"
3058 . "\tlist=\'\$(SUBDIRS)\'; for subdir in \$\$list; do \\\n"
3059 # Never fail here if a subdir fails; it
3061 . "\t test \"\$\$subdir\" = . || (cd \$\$subdir"
3062 . " && \$(MAKE) \$(AM_MAKEFLAGS) tags); \\\n"
3064 push (@tag_deps, 'tags-recursive');
3065 &depend ('.PHONY', 'tags-recursive');
3068 if (&saw_sources_p (1)
3069 || &variable_defined ('ETAGS_ARGS')
3073 foreach my $one_hdr (@config_headers)
3075 if ($relative_dir eq dirname ($one_hdr))
3077 # The config header is in this directory. So require it.
3078 $config .= ' ' if $config;
3079 $config .= basename ($one_hdr);
3082 $output_rules .= &file_contents ('tags',
3083 ('CONFIG' => $config,
3084 'DIRS' => join (' ', @tag_deps)));
3085 &examine_variable ('TAGS_DEPENDENCIES');
3087 elsif (&variable_defined ('TAGS_DEPENDENCIES'))
3089 &am_line_error ('TAGS_DEPENDENCIES',
3090 "doesn't make sense to define `TAGS_DEPENDENCIES' without sources or `ETAGS_ARGS'");
3094 # Every Makefile must define some sort of TAGS rule.
3095 # Otherwise, it would be possible for a top-level "make TAGS"
3096 # to fail because some subdirectory failed.
3097 $output_rules .= "tags: TAGS\nTAGS:\n\n";
3101 # Handle multilib support.
3104 return unless $seen_multilib;
3106 $output_rules .= &file_contents ('multilib');
3111 # &for_dist_common ($A, $B)
3112 # -------------------------
3113 # Subroutine for &handle_dist: sort files to dist.
3115 # We put README first because it then becomes easier to make a
3116 # Usenet-compliant shar file (in these, README must be first).
3118 # FIXME: do more ordering of files here.
3131 # handle_dist ($MAKEFILE)
3132 # -----------------------
3133 # Handle 'dist' target.
3136 my ($makefile) = @_;
3138 # `make dist' isn't used in a Cygnus-style tree.
3139 # Omit the rules so that people don't try to use them.
3140 return if $cygnus_mode;
3142 # Set up maint_charset.
3143 $local_maint_charset = &variable_value ('MAINT_CHARSET')
3144 if &variable_defined ('MAINT_CHARSET');
3145 $maint_charset = $local_maint_charset
3146 if $relative_dir eq '.';
3148 if (&variable_defined ('DIST_CHARSET'))
3150 &am_line_error ('DIST_CHARSET',
3151 "DIST_CHARSET defined but no MAINT_CHARSET defined")
3152 if ! $local_maint_charset;
3153 if ($relative_dir eq '.')
3155 $dist_charset = &variable_value ('DIST_CHARSET')
3159 &am_line_error ('DIST_CHARSET',
3160 "DIST_CHARSET can only be defined at top level");
3164 # Look for common files that should be included in distribution.
3165 foreach my $cfile (@common_files)
3167 if (-f ($relative_dir . "/" . $cfile))
3169 &push_dist_common ($cfile);
3173 # We might copy elements from $configure_dist_common to
3174 # %dist_common if we think we need to. If the file appears in our
3175 # directory, we would have discovered it already, so we don't
3176 # check that. But if the file is in a subdir without a Makefile,
3177 # we want to distribute it here if we are doing `.'. Ugly!
3178 if ($relative_dir eq '.')
3180 foreach my $file (split (' ' , $configure_dist_common))
3182 if (! &is_make_dir (dirname ($file)))
3184 &push_dist_common ($file);
3191 # Files to distributed. Don't use &variable_value_as_list
3192 # as it recursively expands `$(dist_pkgdata_DATA)' etc.
3193 check_variable_defined_unconditionally ('DIST_COMMON');
3194 my @dist_common = split (' ', variable_value ('DIST_COMMON', 'TRUE'));
3195 @dist_common = uniq (sort for_dist_common (@dist_common));
3196 pretty_print ('DIST_COMMON = ', "\t", @dist_common);
3198 # Now that we've processed DIST_COMMON, disallow further attempts
3200 $handle_dist_run = 1;
3202 # Scan EXTRA_DIST to see if we need to distribute anything from a
3203 # subdir. If so, add it to the list. I didn't want to do this
3204 # originally, but there were so many requests that I finally
3206 if (&variable_defined ('EXTRA_DIST'))
3208 # FIXME: This should be fixed to work with conditionals. That
3209 # will require only making the entries in %dist_dirs under the
3210 # appropriate condition. This is meaningful if the nature of
3211 # the distribution should depend upon the configure options
3213 foreach (&variable_value_as_list ('EXTRA_DIST', ''))
3216 next unless s,/+[^/]+$,,;
3222 # We have to check DIST_COMMON for extra directories in case the
3223 # user put a source used in AC_OUTPUT into a subdir.
3224 foreach (&variable_value_as_list ('DIST_COMMON', 'all'))
3227 next unless s,/+[^/]+$,,;
3232 # Rule to check whether a distribution is viable.
3233 my %transform = ('DISTCHECK-HOOK' => &target_defined ('distcheck-hook'),
3234 'GETTEXT' => $seen_gettext);
3236 # Prepend $(distdir) to each directory given.
3237 my %rewritten = map { '$(distdir)/' . "$_" => 1 } keys %dist_dirs;
3238 $transform{'DISTDIRS'} = join (' ', sort keys %rewritten);
3240 # If we have SUBDIRS, create all dist subdirectories and do
3242 if (&variable_defined ('SUBDIRS'))
3244 # If SUBDIRS is conditionally defined, then set DIST_SUBDIRS
3245 # to all possible directories, and use it. If DIST_SUBDIRS is
3246 # defined, just use it.
3247 my $dist_subdir_name;
3248 # Note that we check DIST_SUBDIRS first on purpose. At least
3249 # one project uses so many conditional subdirectories that
3250 # calling variable_conditionally_defined on SUBDIRS will cause
3251 # automake to grow to 150Mb. Sigh.
3252 if (&variable_defined ('DIST_SUBDIRS')
3253 || variable_conditionally_defined ('SUBDIRS'))
3255 $dist_subdir_name = 'DIST_SUBDIRS';
3256 if (! &variable_defined ('DIST_SUBDIRS'))
3258 &define_pretty_variable
3259 ('DIST_SUBDIRS', '',
3260 uniq (&variable_value_as_list ('SUBDIRS', 'all')));
3265 $dist_subdir_name = 'SUBDIRS';
3266 # We always define this because that is what `distclean'
3268 &define_pretty_variable ('DIST_SUBDIRS', '', '$(SUBDIRS)');
3271 $transform{'DIST_SUBDIR_NAME'} = $dist_subdir_name;
3274 # If the target `dist-hook' exists, make sure it is run. This
3275 # allows users to do random weird things to the distribution
3276 # before it is packaged up.
3277 push (@dist_targets, 'dist-hook')
3278 if &target_defined ('dist-hook');
3279 $transform{'DIST-TARGETS'} = join(' ', @dist_targets);
3281 # Defining $(DISTDIR).
3282 $transform{'DISTDIR'} = !&variable_defined('distdir');
3283 $transform{'TOP_DISTDIR'} = backname ($relative_dir);
3285 $output_rules .= &file_contents ('distdir', %transform);
3289 # Handle subdirectories.
3293 unless &variable_defined ('SUBDIRS');
3295 # Make sure each directory mentioned in SUBDIRS actually exists.
3296 foreach my $dir (&variable_value_as_list ('SUBDIRS', 'all'))
3298 # Skip directories substituted by configure.
3299 next if $dir =~ /^\@.*\@$/;
3301 if (! -d $am_relative_dir . '/' . $dir)
3303 &am_line_error ('SUBDIRS',
3304 "required directory $am_relative_dir/$dir does not exist");
3308 &am_line_error ('SUBDIRS', "directory should not contain `/'")
3312 $output_rules .= &file_contents ('subdirs');
3313 variable_pretty_output ('RECURSIVE_TARGETS', 'TRUE');
3317 # ($REGEN, @DEPENDENCIES)
3320 # If aclocal.m4 creation is automated, return the list of its dependencies.
3323 my $regen_aclocal = 0;
3326 unless $relative_dir eq '.';
3328 &examine_variable ('CONFIG_STATUS_DEPENDENCIES');
3329 &examine_variable ('CONFIGURE_DEPENDENCIES');
3331 if (-f 'aclocal.m4')
3333 &define_variable ("ACLOCAL_M4", '$(top_srcdir)/aclocal.m4');
3334 &push_dist_common ('aclocal.m4');
3336 my $aclocal = new IO::File ("< aclocal.m4");
3339 my $line = $aclocal->getline;
3342 if ($line =~ 'generated automatically by aclocal')
3351 if (-f 'acinclude.m4')
3354 push @ac_deps, 'acinclude.m4';
3357 if (&variable_defined ('ACLOCAL_M4_SOURCES'))
3359 push (@ac_deps, '$(ACLOCAL_M4_SOURCES)');
3361 elsif (&variable_defined ('ACLOCAL_AMFLAGS'))
3363 # Scan all -I directories for m4 files. These are our
3365 my $examine_next = 0;
3366 foreach my $amdir (&variable_value_as_list ('ACLOCAL_AMFLAGS', ''))
3371 if ($amdir !~ /^\// && -d $amdir)
3373 foreach my $ac_dep (&my_glob ($amdir . '/*.m4'))
3375 $ac_dep =~ s/^\.\/+//;
3376 push (@ac_deps, $ac_dep)
3377 unless $ac_dep eq "aclocal.m4"
3378 || $ac_dep eq "acinclude.m4";
3382 elsif ($amdir eq '-I')
3389 # Note that it might be possible that aclocal.m4 doesn't exist but
3390 # should be auto-generated. This case probably isn't very
3393 return ($regen_aclocal, @ac_deps);
3396 # Rewrite a list of input files into a form suitable to put on a
3397 # dependency list. The idea is that if an input file has a directory
3398 # part the same as the current directory, then the directory part is
3399 # simply removed. But if the directory part is different, then
3400 # $(top_srcdir) is prepended. Among other things, this is used to
3401 # generate the dependency list for the output files generated by
3402 # AC_OUTPUT. Consider what the dependencies should look like in this
3404 # AC_OUTPUT(src/out:src/in1:lib/in2)
3405 # The first argument, ADD_SRCDIR, is 1 if $(top_srcdir) should be added.
3406 # If 0 then files that require this addition will simply be ignored.
3407 sub rewrite_inputs_into_dependencies
3409 my ($add_srcdir, @inputs) = @_;
3412 foreach my $single (@inputs)
3414 if (dirname ($single) eq $relative_dir)
3416 push (@newinputs, basename ($single));
3420 push (@newinputs, '$(top_srcdir)/' . $single);
3427 # Handle remaking and configure stuff.
3428 # We need the name of the input file, to do proper remaking rules.
3429 sub handle_configure
3431 my ($local, $input, @secondary_inputs) = @_;
3433 my $input_base = basename ($input);
3434 my $local_base = basename ($local);
3436 my $amfile = $input_base . '.am';
3437 # We know we can always add '.in' because it really should be an
3438 # error if the .in was missing originally.
3439 my $infile = '$(srcdir)/' . $input_base . '.in';
3440 my $colon_infile = '';
3441 if ($local ne $input || @secondary_inputs)
3443 $colon_infile = ':' . $input . '.in';
3445 $colon_infile .= ':' . join (':', @secondary_inputs)
3446 if @secondary_inputs;
3448 my @rewritten = &rewrite_inputs_into_dependencies (1, @secondary_inputs);
3450 my ($regen_aclocal_m4, @aclocal_m4_deps) = scan_aclocal_m4 ();
3453 &file_contents ('configure',
3457 => join (' ', @rewritten),
3459 => ((($relative_dir eq '.') ? '$@' : '$(subdir)/$@')
3464 => join (' ', @include_stack),
3468 => $cygnus_mode ? 'cygnus' : $strictness_name,
3470 => $cmdline_use_dependencies ? '' : ' --ignore-deps',
3471 'MAKEFILE-AM-SOURCES'
3472 => "$input$colon_infile",
3474 => $regen_aclocal_m4,
3476 => join (' ', @aclocal_m4_deps)));
3478 if ($relative_dir eq '.')
3480 &push_dist_common ('acconfig.h')
3484 # If we have a configure header, require it.
3485 my @local_fullnames = @config_fullnames;
3486 my @local_names = @config_names;
3488 my $distclean_config = '';
3489 foreach my $one_hdr (@config_headers)
3491 my $one_fullname = shift (@local_fullnames);
3492 my $one_name = shift (@local_names);
3494 my $header_dir = dirname ($one_name);
3496 # If the header is in the current directory we want to build
3497 # the header here. Otherwise, if we're at the topmost
3498 # directory and the header's directory doesn't have a
3499 # Makefile, then we also want to build the header.
3500 if ($relative_dir eq $header_dir
3501 || ($relative_dir eq '.' && ! &is_make_dir ($header_dir)))
3503 my ($cn_sans_dir, $stamp_dir);
3504 if ($relative_dir eq $header_dir)
3506 $cn_sans_dir = basename ($one_name);
3511 $cn_sans_dir = $one_name;
3512 if ($header_dir eq '.')
3518 $stamp_dir = $header_dir . '/';
3522 # Compute relative path from directory holding output
3523 # header to directory holding input header. FIXME:
3524 # doesn't handle case where we have multiple inputs.
3526 if (dirname ($one_hdr) eq $relative_dir)
3528 $ch_sans_dir = basename ($one_hdr);
3532 $ch_sans_dir = backname ($relative_dir) . '/' . $one_hdr;
3535 &require_file_with_conf_line ($config_header_line,
3536 $FOREIGN, $ch_sans_dir);
3538 # Header defined and in this directory.
3540 if (-f $one_name . '.top')
3542 push (@files, "${cn_sans_dir}.top");
3544 if (-f $one_name . '.bot')
3546 push (@files, "${cn_sans_dir}.bot");
3549 &push_dist_common (@files);
3551 # For now, acconfig.h can only appear in the top srcdir.
3552 if (-f 'acconfig.h')
3554 push (@files, '$(top_srcdir)/acconfig.h');
3557 my $stamp_name = 'stamp-h';
3558 $stamp_name .= "${hdr_index}" if scalar (@config_headers) > 1;
3560 my $out_dir = dirname ($ch_sans_dir);
3563 &file_contents ('remake-hdr',
3564 ('FILES' => join (' ', @files),
3565 'CONFIG_HEADER' => $cn_sans_dir,
3566 'CONFIG_HEADER_IN' => $ch_sans_dir,
3567 'CONFIG_HEADER_FULL' => $one_fullname,
3568 'STAMP' => "$stamp_dir$stamp_name",
3569 'SRC_STAMP' => "$out_dir/$stamp_name"));
3571 &create ("${relative_dir}/${out_dir}/${stamp_name}.in");
3572 &require_file_with_conf_line ($config_header_line, $FOREIGN,
3573 "${out_dir}/${stamp_name}.in");
3575 $distclean_config .= ' ' if $distclean_config;
3576 $distclean_config .= $cn_sans_dir;
3580 if ($distclean_config)
3582 $output_rules .= &file_contents ('clean-hdr',
3583 ('FILES' => $distclean_config));
3586 # Set location of mkinstalldirs.
3587 &define_variable ('mkinstalldirs',
3588 ('$(SHELL) ' . $config_aux_dir . '/mkinstalldirs'));
3590 &am_line_error ('CONFIG_HEADER',
3591 "`CONFIG_HEADER' is an anachronism; now determined from `$configure_ac'")
3592 if &variable_defined ('CONFIG_HEADER');
3594 my $config_header = '';
3595 foreach my $one_name (@config_names)
3597 # Generate CONFIG_HEADER define.
3599 if ($relative_dir eq dirname ($one_name))
3601 $one_hdr = basename ($one_name);
3605 $one_hdr = "\$(top_builddir)/${one_name}";
3608 $config_header .= ' ' if $config_header;
3609 $config_header .= $one_hdr;
3613 &define_variable ("CONFIG_HEADER", $config_header);
3616 # Now look for other files in this directory which must be remade
3617 # by config.status, and generate rules for them.
3618 my @actual_other_files = ();
3619 foreach my $lfile (@other_input_files)
3622 my (@inputs, @rewritten_inputs);
3623 my ($need_rewritten);
3624 if ($lfile =~ /^([^:]*):(.*)$/)
3626 # This is the ":" syntax of AC_OUTPUT.
3628 $local = basename ($file);
3629 @inputs = split (':', $2);
3630 @rewritten_inputs = &rewrite_inputs_into_dependencies (1, @inputs);
3631 $need_rewritten = 1;
3637 $local = basename ($file);
3638 @inputs = ($file . '.in');
3640 &rewrite_inputs_into_dependencies (1, @inputs);
3641 $need_rewritten = 0;
3644 # Make sure the dist directory for each input file is created.
3645 # We only have to do this at the topmost level though. This
3646 # is a bit ugly but it easier than spreading out the logic,
3647 # especially in cases like AC_OUTPUT(foo/out:bar/in), where
3648 # there is no Makefile in bar/.
3649 if ($relative_dir eq '.')
3653 $dist_dirs{dirname ($_)} = 1;
3657 # We skip any automake input files, as they are handled
3658 # elsewhere. We also skip files that aren't in this
3659 # directory. However, if the file's directory does not have a
3660 # Makefile, and we are currently doing `.', then we create a
3661 # rule to rebuild the file in the subdir.
3662 next if -f $file . '.am';
3663 my $fd = dirname ($file);
3664 if ($fd ne $relative_dir)
3666 if ($relative_dir eq '.' && ! &is_make_dir ($fd))
3676 # Some users have been tempted to put `stamp-h' in the
3677 # AC_OUTPUT line. This won't do the right thing, so we
3678 # explicitly fail here.
3679 if ($local eq 'stamp-h')
3681 # FIXME: allow real filename.
3682 &am_conf_error ($configure_ac, $ac_output_line,
3683 'stamp-h should not appear in AC_OUTPUT');
3687 $output_rules .= ($local . ': '
3688 . '$(top_builddir)/config.status '
3689 . join (' ', @rewritten_inputs) . "\n"
3691 . 'cd $(top_builddir) && CONFIG_FILES='
3692 . ($relative_dir eq '.' ? '' : '$(subdir)/')
3693 . '$@' . ($need_rewritten
3694 ? (':' . join (':', @inputs))
3696 . ' CONFIG_HEADERS= CONFIG_LINKS= $(SHELL) ./config.status'
3698 push (@actual_other_files, $local);
3700 # Require all input files.
3701 &require_file_with_conf_line ($ac_output_line, $FOREIGN,
3702 &rewrite_inputs_into_dependencies (0, @inputs));
3705 # These files get removed by "make clean".
3706 &define_pretty_variable ('CONFIG_CLEAN_FILES', '', @actual_other_files);
3712 my @r = &am_install_var ('-defaultdist', 'header', 'HEADERS', 'include',
3713 'oldinclude', 'pkginclude',
3717 next unless /\.(.*)$/;
3718 &saw_extension ($1);
3724 return if ! $seen_gettext || $relative_dir ne '.';
3726 if (! &variable_defined ('SUBDIRS'))
3729 ("AM_GNU_GETTEXT used but SUBDIRS not defined");
3733 my @subdirs = &variable_value_as_list ('SUBDIRS', 'all');
3734 &am_line_error ('SUBDIRS',
3735 "AM_GNU_GETTEXT used but `po' not in SUBDIRS")
3736 if ! grep ('po', @subdirs);
3737 &am_line_error ('SUBDIRS',
3738 "AM_GNU_GETTEXT used but `intl' not in SUBDIRS")
3739 if ! grep ('intl', @subdirs);
3741 &require_file_with_conf_line ($ac_gettext_line, $GNU, 'ABOUT-NLS');
3743 # Ensure that each language in ALL_LINGUAS has a .po file, and
3744 # each po file is mentioned in ALL_LINGUAS.
3747 my %linguas = map { $_ => 1 } split (' ', $all_linguas);
3754 &am_line_error ($all_linguas_line,
3755 ("po/$_.po exists but `$_' not in `ALL_LINGUAS'"))
3759 foreach (keys %linguas)
3761 &am_line_error ($all_linguas_line,
3762 "$_ in `ALL_LINGUAS' but po/$_.po does not exist")
3768 &am_error ("AM_GNU_GETTEXT in `$configure_ac' but `ALL_LINGUAS' not defined");
3772 # Handle footer elements.
3775 # NOTE don't use define_pretty_variable here, because
3776 # $contents{...} is already defined.
3777 $output_vars .= 'SOURCES = ' . variable_value ('SOURCES') . "\n\n"
3778 if variable_value ('SOURCES');
3781 &am_line_error ('.SUFFIXES',
3782 "use variable `SUFFIXES', not target `.SUFFIXES'")
3783 if target_defined ('.SUFFIXES');
3785 # Note: AIX 4.1 /bin/make will fail if any suffix rule appears
3786 # before .SUFFIXES. So we make sure that .SUFFIXES appears before
3787 # anything else, by sticking it right after the default: target.
3788 $output_header .= ".SUFFIXES:\n";
3789 if (@suffixes || &variable_defined ('SUFFIXES'))
3791 # Make sure suffixes has unique elements. Sort them to ensure
3792 # the output remains consistent. However, $(SUFFIXES) is
3793 # always at the start of the list, unsorted. This is done
3794 # because make will choose rules depending on the ordering of
3795 # suffixes, and this lets the user have some control. Push
3796 # actual suffixes, and not $(SUFFIXES). Some versions of make
3797 # do not like variable substitutions on the .SUFFIXES line.
3798 my @user_suffixes = (&variable_defined ('SUFFIXES')
3799 ? &variable_value_as_list ('SUFFIXES', '')
3802 my %suffixes = map { $_ => 1 } @suffixes;
3803 delete @suffixes{@user_suffixes};
3805 $output_header .= (".SUFFIXES: "
3806 . join (' ', @user_suffixes, sort keys %suffixes)
3810 $output_trailer .= file_contents ('footer');
3813 # Deal with installdirs target.
3814 sub handle_installdirs ()
3817 &file_contents ('install',
3819 => variable_value ('_am_installdirs') || ''));
3823 # Deal with all and all-am.
3826 my ($makefile) = @_;
3830 # Put this at the beginning for the sake of non-GNU makes. This
3831 # is still wrong if these makes can run parallel jobs. But it is
3833 unshift (@all, basename ($makefile));
3835 foreach my $one_name (@config_names)
3837 push (@all, basename ($one_name))
3838 if dirname ($one_name) eq $relative_dir;
3841 # Install `all' hooks.
3842 if (&target_defined ("all-local"))
3844 push (@all, "all-local");
3845 &depend ('.PHONY', "all-local");
3848 &pretty_print_rule ("all-am:", "\t\t", @all);
3849 &depend ('.PHONY', 'all-am', 'all');
3854 my @local_headers = ();
3855 push @local_headers, '$(BUILT_SOURCES)'
3856 if &variable_defined ('BUILT_SOURCES');
3857 foreach my $one_name (@config_names)
3859 push @local_headers, basename ($one_name)
3860 if dirname ($one_name) eq $relative_dir;
3865 # We need to make sure config.h is built before we recurse.
3866 # We also want to make sure that built sources are built
3867 # before any ordinary `all' targets are run. We can't do this
3868 # by changing the order of dependencies to the "all" because
3869 # that breaks when using parallel makes. Instead we handle
3870 # things explicitly.
3871 $output_all .= ("all: " . join (' ', @local_headers)
3873 . '$(MAKE) $(AM_MAKEFLAGS) '
3874 . (&variable_defined ('SUBDIRS')
3875 ? 'all-recursive' : 'all-am')
3880 $output_all .= "all: " . (&variable_defined ('SUBDIRS')
3881 ? 'all-recursive' : 'all-am') . "\n\n";
3886 # Handle check merge target specially.
3887 sub do_check_merge_target
3889 if (&target_defined ('check-local'))
3891 # User defined local form of target. So include it.
3892 push (@check_tests, 'check-local');
3893 &depend ('.PHONY', 'check-local');
3896 # In --cygnus mode, check doesn't depend on all.
3899 # Just run the local check rules.
3900 &pretty_print_rule ('check-am:', "\t\t", @check);
3904 # The check target must depend on the local equivalent of
3905 # `all', to ensure all the primary targets are built. Then it
3906 # must build the local check rules.
3907 $output_rules .= "check-am: all-am\n";
3908 &pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ",
3912 &pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ",
3916 &depend ('.PHONY', 'check', 'check-am');
3917 $output_rules .= ("check: "
3918 . (&variable_defined ('SUBDIRS')
3919 ? 'check-recursive' : 'check-am')
3923 # Handle all 'clean' targets.
3928 # Don't include `MAINTAINER'; it is handled specially below.
3929 foreach my $name ('MOSTLY', '', 'DIST')
3931 $transform{"${name}CLEAN"} = &variable_defined ("${name}CLEANFILES");
3934 # Built sources are automatically removed by maintainer-clean.
3935 push (@maintainer_clean_files, '$(BUILT_SOURCES)')
3936 if &variable_defined ('BUILT_SOURCES');
3937 push (@maintainer_clean_files, '$(MAINTAINERCLEANFILES)')
3938 if &variable_defined ('MAINTAINERCLEANFILES');
3940 $output_rules .= &file_contents ('clean',
3943 # Join with no space to avoid
3944 # spurious `test -z' success at
3946 => join ('', @maintainer_clean_files),
3948 # A space is required in the join here.
3949 => join (' ', @maintainer_clean_files)));
3953 # &depend ($CATEGORY, @DEPENDENDEES)
3954 # ----------------------------------
3955 # The target $CATEGORY depends on @DEPENDENDEES.
3958 my ($category, @dependendees) = @_;
3960 push (@{$dependencies{$category}}, @dependendees);
3965 # &target_cmp ($A, $B)
3966 # --------------------
3967 # Subroutine for &handle_factored_dependencies to let `.PHONY' be last.
3980 # &handle_factored_dependencies ()
3981 # --------------------------------
3982 # Handle everything related to gathered targets.
3983 sub handle_factored_dependencies
3986 foreach my $utarg ('uninstall-data-local', 'uninstall-data-hook',
3987 'uninstall-exec-local', 'uninstall-exec-hook')
3989 if (&target_defined ($utarg))
3992 $x =~ s/(data|exec)-//;
3993 &am_line_error ($utarg, "use `$x', not `$utarg'");
3997 if (&target_defined ('install-local'))
3999 &am_line_error ('install-local',
4000 "use `install-data-local' or `install-exec-local', "
4001 . "not `install-local'");
4004 if (!defined $options{'no-installinfo'}
4005 && &target_defined ('install-info-local'))
4007 &am_line_error ('install-info-local',
4008 "`install-info-local' target defined but "
4009 . "`no-installinfo' option not in use");
4012 # Install the -local hooks.
4013 foreach (keys %dependencies)
4015 # Hooks are installed on the -am targets.
4017 if (&target_defined ("$_-local"))
4019 depend ("$_-am", "$_-local");
4020 &depend ('.PHONY', "$_-local");
4024 # Install the -hook hooks.
4025 # FIXME: Why not be as liberal as we are with -local hooks?
4026 foreach ('install-exec', 'install-data')
4028 if (&target_defined ("$_-hook"))
4030 $actions{"$_-am"} .=
4031 ("\t\@\$(NORMAL_INSTALL)\n"
4032 . "\t" . '$(MAKE) $(AM_MAKEFLAGS) ' . "$_-hook\n");
4036 # All the required targets are phony.
4037 depend ('.PHONY', keys %required_targets);
4039 # Actually output gathered targets.
4040 foreach (sort target_cmp keys %dependencies)
4042 # If there is nothing about this guy, skip it.
4044 unless (@{$dependencies{$_}}
4046 || $required_targets{$_});
4047 &pretty_print_rule ("$_:", "\t",
4048 uniq (sort @{$dependencies{$_}}));
4049 $output_rules .= $actions{$_}
4050 if defined $actions{$_};
4051 $output_rules .= "\n";
4056 # &handle_tests_dejagnu ()
4057 # ------------------------
4058 sub handle_tests_dejagnu
4060 push (@check_tests, 'check-DEJAGNU');
4062 # Only create site.exp rule if user hasn't already written one.
4064 file_contents ('dejagnu', ('SITE-EXP' => ! target_defined ('site.exp')));
4068 # Handle TESTS variable and other checks.
4071 if (defined $options{'dejagnu'})
4073 &handle_tests_dejagnu;
4077 foreach my $c ('DEJATOOL', 'RUNTEST', 'RUNTESTFLAGS')
4080 "`$c' defined but `dejagnu' not in `AUTOMAKE_OPTIONS'")
4081 if &variable_defined ($c);
4085 if (&variable_defined ('TESTS'))
4087 push (@check_tests, 'check-TESTS');
4088 $output_rules .= &file_contents ('check');
4092 # Handle Emacs Lisp.
4093 sub handle_emacs_lisp
4095 my @elfiles = &am_install_var ('-candist', 'lisp', 'LISP',
4098 return if ! @elfiles;
4100 # Generate .elc files.
4101 my @elcfiles = map { $_ . 'c' } @elfiles;
4102 &define_pretty_variable ('ELCFILES', '', @elcfiles);
4104 push (@all, '$(ELCFILES)');
4106 &am_error ("`lisp_LISP' defined but `AM_PATH_LISPDIR' not in `$configure_ac'")
4107 if ! $seen_lispdir && &variable_defined ('lisp_LISP');
4109 &require_file_with_conf_line ('AM_PATH_LISPDIR', $FOREIGN, 'elisp-comp');
4115 my @pyfiles = &am_install_var ('-defaultdist', 'python', 'PYTHON',
4116 'python', 'noinst');
4117 return if ! @pyfiles;
4119 # Found some python.
4120 &am_error ("`python_PYTHON' defined but `AM_PATH_PYTHON' not in `$configure_ac'")
4121 if ! $seen_pythondir && &variable_defined ('python_PYTHON');
4123 &require_file_with_conf_line ('AM_PATH_PYTHON', $FOREIGN, 'py-compile');
4124 &define_variable ('py_compile', $config_aux_dir . '/py-compile');
4130 my @sourcelist = &am_install_var ('-candist',
4132 'java', 'noinst', 'check');
4133 return if ! @sourcelist;
4135 my %valid = &am_primary_prefixes ('JAVA', 1,
4136 'java', 'noinst', 'check');
4139 foreach my $curs (keys %valid)
4141 if (! &variable_defined ($curs . '_JAVA') || $curs eq 'EXTRA')
4148 &am_line_error ($curs . '_JAVA',
4149 "multiple _JAVA primaries in use");
4154 push (@all, 'class' . $dir . '.stamp');
4158 # Handle some of the minor options.
4159 sub handle_minor_options
4161 if (defined $options{'readme-alpha'})
4163 if ($relative_dir eq '.')
4165 if ($package_version !~ /^$GNITS_VERSION_PATTERN$/)
4167 # FIXME: allow real filename.
4168 &am_conf_line_error ($configure_ac,
4169 $package_version_line,
4170 "version `$package_version' doesn't follow Gnits standards");
4172 elsif (defined $1 && -f 'README-alpha')
4174 # This means we have an alpha release. See
4175 # GNITS_VERSION_PATTERN for details.
4176 &require_file ($FOREIGN, 'README-alpha');
4182 ################################################################
4185 my @make_input_list;
4186 # &scan_autoconf_config_files ($CONFIG-FILES)
4187 # -------------------------------------------
4188 # Study $CONFIG-FILES which is the first argument to AC_CONFIG_FILES
4190 sub scan_autoconf_config_files
4192 my ($config_files) = @_;
4193 # Look at potential Makefile.am's.
4194 foreach (split ' ', $config_files)
4196 # Must skip empty string for Perl 4.
4197 next if $_ eq "\\" || $_ eq '';
4199 # Handle $local:$input syntax. Note that we ignore
4200 # every input file past the first, though we keep
4201 # those around for later.
4202 my ($local, $input, @rest) = split (/:/);
4209 # FIXME: should be error if .in is missing.
4210 $input =~ s/\.in$//;
4213 if (-f $input . '.am')
4215 # We have a file that automake should generate.
4216 push (@make_input_list, $input);
4217 $make_list{$input} = join (':', ($local, @rest));
4221 # We have a file that automake should cause to be
4222 # rebuilt, but shouldn't generate itself.
4223 push (@other_input_files, $_);
4229 # &scan_autoconf_traces ($FILENAME)
4230 # ---------------------------------
4231 # FIXME: For the time being, we don't care about the FILENAME.
4232 sub scan_autoconf_traces
4234 my ($filename) = @_;
4236 my $traces = "$ENV{amtraces} ";
4238 $traces .= ' -t AC_CONFIG_FILES';
4239 $traces .= ' -t AC_LIBSOURCE';
4240 $traces .= ' -t AC_SUBST';
4242 my $tracefh = new IO::File ("$traces |");
4245 die "$me: couldn't open `$traces': $!\n";
4247 print "$me: reading $traces\n" if $verbose;
4249 while ($_ = $tracefh->getline)
4252 my ($file, $line, $macro, @args) = split /:/;
4253 my $here = "$file:$line";
4255 # Alphabetical ordering please.
4256 if ($macro eq 'AC_CONFIG_FILES')
4258 # Look at potential Makefile.am's.
4259 &scan_autoconf_config_files ($args[0]);
4261 elsif ($macro eq 'AC_LIBSOURCE')
4263 my $source = "$args[0].c";
4264 # We should actually also `close' the sources: getopt.c
4265 # wants getopt.h etc. But actually it should be done in the
4266 # macro itself, i.e., we have to first fix Autoconf to extend
4267 # _AC_LIBOBJ_DECL and use it the in various macros.
4268 if (!defined $libsources{$source})
4270 print STDERR "traces: discovered $source\n";
4271 $libsources{$source} = $here;
4274 elsif ($macro eq 'AC_SUBST')
4276 if (!defined $configure_vars{$args[0]})
4278 print STDERR "traces: discovered AC_SUBST($args[0])\n";
4279 $configure_vars{$args[0]} = $here;
4285 || die "$me: close: $traces: $!\n";
4289 # &scan_one_autoconf_file ($FILENAME)
4290 # -----------------------------------
4291 # Scan one file for interesting things. Subroutine of
4292 # &scan_autoconf_files.
4293 sub scan_one_autoconf_file
4295 my ($filename) = @_;
4297 my $configfh = new IO::File ("< $filename");
4300 die "$me: couldn't open `$filename': $!\n";
4302 print "$me: reading $filename\n" if $verbose;
4304 my ($in_ac_output, $in_ac_replace) = (0, 0);
4305 while ($_ = $configfh->getline)
4307 # Remove comments from current line.
4311 # Skip macro definitions. Otherwise we might be confused into
4312 # thinking that a macro that was only defined was actually
4316 # Follow includes. This is a weirdness commonly in use at
4317 # Cygnus and hopefully nowhere else.
4318 if (/sinclude\((.*)\)/ && -f $1)
4320 # $_ being local, if we don't preserve it, when coming
4321 # back we will have $_ undefined, which is bad for the
4322 # the rest of this routine.
4323 my $underscore = $_;
4324 &scan_one_autoconf_file ($1);
4328 # Populate libobjs array.
4329 if (/AC_FUNC_ALLOCA/)
4331 $libsources{'alloca.c'} = 1;
4333 elsif (/AC_FUNC_GETLOADAVG/)
4335 $libsources{'getloadavg.c'} = 1;
4337 elsif (/AC_FUNC_MEMCMP/)
4339 $libsources{'memcmp.c'} = 1;
4341 elsif (/AC_STRUCT_ST_BLOCKS/)
4343 $libsources{'fileblocks.c'} = 1;
4345 elsif (/A[CM]_REPLACE_GNU_GETOPT/)
4347 $libsources{'getopt.c'} = 1;
4348 $libsources{'getopt1.c'} = 1;
4350 elsif (/AM_FUNC_STRTOD/)
4352 $libsources{'strtod.c'} = 1;
4354 elsif (/AM_WITH_REGEX/)
4356 $libsources{'rx.c'} = 1;
4357 $libsources{'rx.h'} = 1;
4358 $libsources{'regex.c'} = 1;
4359 $libsources{'regex.h'} = 1;
4361 elsif (/AC_FUNC_MKTIME/)
4363 $libsources{'mktime.c'} = 1;
4365 elsif (/AM_FUNC_ERROR_AT_LINE/)
4367 $libsources{'error.c'} = 1;
4368 $libsources{'error.h'} = 1;
4370 elsif (/AM_FUNC_OBSTACK/)
4372 $libsources{'obstack.c'} = 1;
4373 $libsources{'obstack.h'} = 1;
4375 elsif (/LIBOBJS="(.*)\s+\$LIBOBJS"/
4376 || /LIBOBJS="\$LIBOBJS\s+(.*)"/)
4378 foreach my $libobj_iter (split (' ', $1))
4380 if ($libobj_iter =~ /^(.*)\.o(bj)?$/
4381 || $libobj_iter =~ /^(.*)\.\$ac_objext$/
4382 || $libobj_iter =~ /^(.*)\.\$\{ac_objext\}$/)
4384 $libsources{$1 . '.c'} = 1;
4388 elsif (/AC_LIBOBJ\(([^)]+)\)/)
4390 $libsources{"$1.c"} = 1;
4393 if (! $in_ac_replace && s/AC_REPLACE_FUNCS\s*\(\[?//)
4399 $in_ac_replace = 0 if s/[\]\)].*$//;
4400 # Remove trailing backslash.
4404 # Need to skip empty elements for Perl 4.
4406 $libsources{$_ . '.c'} = 1;
4410 if (/$obsolete_rx/o)
4413 if ($obsolete_macros{$1} ne '')
4415 $hint = '; ' . $obsolete_macros{$1};
4417 &am_conf_line_error ($filename, $., "`$1' is obsolete$hint");
4420 # Process the AC_OUTPUT and AC_CONFIG_FILES macros.
4421 if (! $in_ac_output && s/AC_(OUTPUT|CONFIG_FILES)\s*\(\[?//)
4424 $ac_output_line = $.;
4435 # Look at potential Makefile.am's.
4436 &scan_autoconf_config_files ($_);
4438 if ($closing && @make_input_list == 0 && @other_input_files == 0)
4440 &am_conf_line_error ($filename, $ac_output_line,
4441 "No files mentioned in `AC_OUTPUT'");
4446 if (/$AC_CONFIG_AUX_DIR_PATTERN/o)
4448 @config_aux_path = &unquote_m4_arg ($1);
4449 $config_aux_dir_set_in_configure_in = 1;
4452 # Check for ansi2knr.
4453 $am_c_prototypes = 1 if /AM_C_PROTOTYPES/;
4455 # Check for exe extension stuff.
4459 $configure_vars{'EXEEXT'} = $filename . ':' . $.;
4465 $configure_vars{'OBJEXT'} = $filename . ':' . $.;
4468 # Check for `-c -o' code.
4469 $seen_cc_c_o = 1 if /AM_PROG_CC_C_O/;
4471 # Check for NLS support.
4472 if (/AM_GNU_GETTEXT/)
4475 $ac_gettext_line = $.;
4478 # Look for ALL_LINGUAS.
4479 if (/ALL_LINGUAS="(.*)"$/ || /ALL_LINGUAS=(.*)$/)
4483 $all_linguas_line = $.;
4486 # Handle configuration headers. A config header of `[$1]'
4487 # means we are actually scanning AM_CONFIG_HEADER from
4489 if (/A([CM])_CONFIG_HEADERS?\s*\((.*)\)/
4493 ($filename, $., "`automake requires `AM_CONFIG_HEADER', not `AC_CONFIG_HEADER'")
4496 $config_header_line = $.;
4497 foreach my $one_hdr (split (' ', &unquote_m4_arg ($2)))
4499 push (@config_fullnames, $one_hdr);
4500 if ($one_hdr =~ /^([^:]+):(.+)$/)
4502 push (@config_names, $1);
4503 push (@config_headers, $2);
4507 push (@config_names, $one_hdr);
4508 push (@config_headers, $one_hdr . '.in');
4513 # Handle AC_CANONICAL_*. Always allow upgrading to
4514 # AC_CANONICAL_SYSTEM, but never downgrading.
4515 $seen_canonical = $AC_CANONICAL_HOST
4516 if ! $seen_canonical
4517 && (/AC_CANONICAL_HOST/ || /AC_CHECK_TOOL/);
4518 $seen_canonical = $AC_CANONICAL_SYSTEM if /AC_CANONICAL_SYSTEM/;
4520 # If using X, include some extra variable definitions. NOTE
4521 # we don't want to force these into CFLAGS or anything,
4522 # because not all programs will necessarily use X.
4525 foreach my $var ('X_CFLAGS', 'X_LIBS', 'X_EXTRA_LIBS',
4528 $configure_vars{$var} = $filename . ':' . $.
4532 # This macro handles several different things.
4533 if (/$AM_INIT_AUTOMAKE_PATTERN/o)
4535 ($package_version = $1) =~ s/$AM_PACKAGE_VERSION_PATTERN/$1/o;
4536 $package_version_line = $.;
4537 $seen_init_automake = 1;
4542 $configure_vars{'LEX'} = $filename . ':' . $.;
4543 $seen_decl_yytext = 1;
4545 if (/AC_DECL_YYTEXT/ && $filename =~ /configure\.(ac|in)$/)
4547 &am_conf_line_warning ($filename, $., "`AC_DECL_YYTEXT' is covered by `AM_PROG_LEX'");
4549 if (/AC_PROG_LEX/ && $filename =~ /configure\.(ac|in)$/)
4551 &am_conf_line_warning ($filename, $., "automake requires `AM_PROG_LEX', not `AC_PROG_LEX'");
4554 if (/AC_PROG_(F77|YACC|RANLIB|CC|CXXCPP|CXX|LEX|AWK|CPP|LN_S)/)
4556 $configure_vars{$1} = $filename . ':' . $.;
4558 if (/$AC_CHECK_PATTERN/o)
4560 $configure_vars{$3} = $filename . ':' . $.;
4562 if (/$AM_MISSING_PATTERN/o
4566 && $1 ne 'AUTOHEADER'
4567 # AM_INIT_AUTOMAKE is AM_MISSING_PROG'ing MAKEINFO. But
4568 # we handle it elsewhere.
4569 && $1 ne 'MAKEINFO')
4571 $configure_vars{$1} = $filename . ':' . $.;
4574 # Explicitly avoid ANSI2KNR -- we AC_SUBST that in protos.m4,
4575 # but later define it elsewhere. This is pretty hacky. We
4576 # also explicitly avoid INSTALL_SCRIPT and some other
4577 # variables because they are defined in header-vars.am.
4579 if (/$AC_SUBST_PATTERN/o
4581 && $1 ne 'INSTALL_SCRIPT'
4582 && $1 ne 'INSTALL_DATA')
4584 $configure_vars{$1} = $filename . ':' . $.;
4587 $seen_decl_yytext = 1 if /AC_DECL_YYTEXT/;
4588 if (/AM_MAINTAINER_MODE/)
4590 $seen_maint_mode = 1;
4591 $configure_cond{'MAINTAINER_MODE'} = 1;
4594 $seen_lispdir = 1 if /AM_PATH_LISPDIR/;
4596 if (/AM_PATH_PYTHON/)
4598 $seen_pythondir = 1;
4599 $configure_vars{'pythondir'} = $filename . ':' . $.;
4600 $configure_vars{'PYTHON'} = $filename . ':' . $.;
4603 if (/A(C|M)_PROG_LIBTOOL/)
4605 # We're not ready for this yet. People still use a
4606 # libtool with no AC_PROG_LIBTOOL. Once that is the
4607 # dominant version we can reenable this code -- but next
4608 # time by mentioning the macro in %obsolete_macros, both
4609 # here and in aclocal.in.
4611 # if (/AM_PROG_LIBTOOL/)
4613 # &am_conf_line_warning ($filename, $., "`AM_PROG_LIBTOOL' is obsolete, use `AC_PROG_LIBTOOL' instead");
4617 $configure_vars{'LIBTOOL'} = $filename . ':' . $.;
4618 $configure_vars{'RANLIB'} = $filename . ':' . $.;
4619 $configure_vars{'CC'} = $filename . ':' . $.;
4620 # AC_PROG_LIBTOOL runs AC_CANONICAL_HOST. Make sure we
4621 # never downgrade (if we've seen AC_CANONICAL_SYSTEM).
4622 $seen_canonical = $AC_CANONICAL_HOST if ! $seen_canonical;
4625 $seen_multilib = 1 if (/AM_ENABLE_MULTILIB/);
4627 if (/$AM_CONDITIONAL_PATTERN/o)
4629 $configure_cond{$1} = 1;
4632 # Check for Fortran 77 intrinsic and run-time libraries.
4633 if (/AC_F77_LIBRARY_LDFLAGS/)
4635 $configure_vars{'FLIBS'} = $filename . ':' . $.;
4643 # &scan_autoconf_files ()
4644 # -----------------------
4645 # Check whether we use `configure.ac' or `configure.in'.
4646 # Scan it (and possibly `aclocal.m4') for interesting things.
4647 # We must scan aclocal.m4 because there might be AC_SUBSTs and such there.
4648 sub scan_autoconf_files
4650 # Reinitialize libsources here. This isn't really necessary,
4651 # since we currently assume there is only one configure.ac. But
4652 # that won't always be the case.
4655 warn "$me: both `configure.ac' and `configure.in' present:"
4656 . " ignoring `configure.in'\n"
4657 if -f 'configure.ac' && -f 'configure.in';
4658 $configure_ac = 'configure.in'
4659 if -f 'configure.in';
4660 $configure_ac = 'configure.ac'
4661 if -f 'configure.ac';
4662 die "$me: `configure.ac' or `configure.in' is required\n"
4665 &scan_one_autoconf_file ($configure_ac);
4666 &scan_one_autoconf_file ('aclocal.m4')
4669 if (defined $ENV{'amtraces'})
4671 warn '$me: Autoconf traces is an experimental feature';
4672 warn '$me: use at your own risks';
4674 &scan_autoconf_traces ($configure_ac);
4677 # Set input and output files if not specified by user.
4680 @input_files = @make_input_list;
4681 %output_files = %make_list;
4684 @configure_input_files = @make_input_list;
4686 &am_conf_error ("`AM_INIT_AUTOMAKE' must be used")
4687 if ! $seen_init_automake;
4689 # Look for some files we need. Always check for these. This
4690 # check must be done for every run, even those where we are only
4691 # looking at a subdir Makefile. We must set relative_dir so that
4692 # the file-finding machinery works.
4693 # FIXME: Is this broken because it needs dynamic scopes.
4694 # My tests seems to show it's not the case.
4695 $relative_dir = '.';
4696 &require_config_file ($FOREIGN, 'install-sh', 'mkinstalldirs', 'missing');
4697 &am_error ("`install.sh' is an anachronism; use `install-sh' instead")
4698 if -f $config_aux_path[0] . '/install.sh';
4700 &require_config_file ($FOREIGN, 'py-compile')
4703 # Preserve dist_common for later.
4704 $configure_dist_common = variable_value ('DIST_COMMON', 'TRUE') || '';
4707 ################################################################
4709 # Set up for Cygnus mode.
4712 return unless $cygnus_mode;
4714 &set_strictness ('foreign');
4715 $options{'no-installinfo'} = 1;
4716 $options{'no-dependencies'} = 1;
4717 $use_dependencies = 0;
4719 if (! $seen_maint_mode)
4721 &am_conf_error ("`AM_MAINTAINER_MODE' required when --cygnus specified");
4725 # Do any extra checking for GNU standards.
4726 sub check_gnu_standards
4728 if ($relative_dir eq '.')
4730 # In top level (or only) directory.
4731 &require_file ($GNU, 'INSTALL', 'NEWS', 'README', 'COPYING',
4732 'AUTHORS', 'ChangeLog');
4735 if ($strictness >= $GNU
4736 && defined $options{'no-installman'})
4738 &am_line_error ('AUTOMAKE_OPTIONS',
4739 "option `no-installman' disallowed by GNU standards");
4742 if ($strictness >= $GNU
4743 && defined $options{'no-installinfo'})
4745 &am_line_error ('AUTOMAKE_OPTIONS',
4746 "option `no-installinfo' disallowed by GNU standards");
4750 # Do any extra checking for GNITS standards.
4751 sub check_gnits_standards
4753 if ($relative_dir eq '.')
4755 # In top level (or only) directory.
4756 &require_file ($GNITS, 'THANKS');
4760 ################################################################
4762 # Functions to handle files of each language.
4764 # Each `lang_X_rewrite($DIRECTORY, $BASE, $EXT)' function follows a
4765 # simple formula: Return value is $LANG_SUBDIR if the resulting object
4766 # file should be in a subdir if the source file is, $LANG_PROCESS if
4767 # file is to be dealt with, $LANG_IGNORE otherwise.
4769 # Much of the actual processing is handled in
4770 # handle_single_transform_list. These functions exist so that
4771 # auxiliary information can be recorded for a later cleanup pass.
4772 # Note that the calls to these functions are computed, so don't bother
4773 # searching for their precise names in the source.
4775 # This is just a convenience function that can be used to determine
4776 # when a subdir object should be used.
4779 return defined $options{'subdir-objects'} ? $LANG_SUBDIR : $LANG_PROCESS;
4782 # Rewrite a single C source file.
4785 my ($directory, $base, $ext) = @_;
4787 if (defined $options{'ansi2knr'} && $base =~ /_$/)
4789 # FIXME: include line number in error.
4790 &am_error ("C source file `$base.c' would be deleted by ansi2knr rules");
4793 my $r = $LANG_PROCESS;
4794 if (defined $options{'subdir-objects'})
4797 $base = $directory . '/' . $base;
4801 # Only give error once.
4803 # FIXME: line number.
4804 &am_error ("C objects in subdir but `AM_PROG_CC_C_O' not in `$configure_ac'");
4807 &require_file ($FOREIGN, 'compile')
4808 if $relative_dir eq '.';
4811 $de_ansi_files{$base} = 1;
4815 # Rewrite a single C++ source file.
4816 sub lang_cxx_rewrite
4818 return &lang_sub_obj;
4821 # Rewrite a single header file.
4822 sub lang_header_rewrite
4824 # Header files are simply ignored.
4825 return $LANG_IGNORE;
4828 # Rewrite a single yacc file.
4829 sub lang_yacc_rewrite
4831 my ($directory, $base, $ext) = @_;
4833 my $r = &lang_c_rewrite ($directory, $base, $ext);
4835 if ($r == $LANG_SUBDIR)
4837 $pfx = $directory . '/';
4839 $yacc_sources{$pfx . $base . '.' . $ext} = 1;
4841 &saw_extension ('c');
4843 &push_dist_common ($pfx . $base . '.' . $ext);
4847 # Rewrite a single yacc++ file.
4848 sub lang_yaccxx_rewrite
4850 my ($directory, $base, $ext) = @_;
4852 my $r = $LANG_PROCESS;
4854 if (defined $options{'subdir-objects'})
4856 $pfx = $directory . '/';
4859 $yacc_sources{$pfx . $base . '.' . $ext} = 1;
4861 &saw_extension ($ext);
4863 &push_dist_common ($pfx . $base . '.' . $ext);
4867 # Rewrite a single lex file.
4868 sub lang_lex_rewrite
4870 my ($directory, $base, $ext) = @_;
4872 my $r = &lang_c_rewrite ($directory, $base, $ext);
4874 if ($r == $LANG_SUBDIR)
4876 $pfx = $directory . '/';
4878 $lex_sources{$pfx . $base . '.' . $ext} = 1;
4880 &saw_extension ('c');
4882 &push_dist_common ($pfx . $base . '.' . $ext);
4886 # Rewrite a single lex++ file.
4887 sub lang_lexxx_rewrite
4889 my ($directory, $base, $ext) = @_;
4891 my $r = $LANG_PROCESS;
4893 if (defined $options{'subdir-objects'})
4895 $pfx = $directory . '/';
4898 $lex_sources{$pfx . $base . '.' . $ext} = 1;
4900 &saw_extension ($ext);
4902 &push_dist_common ($pfx . $base . '.' . $ext);
4906 # Rewrite a single assembly file.
4907 sub lang_asm_rewrite
4909 return &lang_sub_obj;
4912 # Rewrite a single Fortran 77 file.
4913 sub lang_f77_rewrite
4915 return $LANG_PROCESS;
4918 # Rewrite a single preprocessed Fortran 77 file.
4919 sub lang_ppf77_rewrite
4921 return $LANG_PROCESS;
4924 # Rewrite a single ratfor file.
4925 sub lang_ratfor_rewrite
4927 return $LANG_PROCESS;
4930 # Rewrite a single Objective C file.
4931 sub lang_objc_rewrite
4933 return &lang_sub_obj;
4936 # Rewrite a single Java file.
4937 sub lang_java_rewrite
4939 return $LANG_SUBDIR;
4942 # The lang_X_finish functions are called after all source file
4943 # processing is done. Each should handle defining rules for the
4944 # language, etc. A finish function is only called if a source file of
4945 # the appropriate type has been seen.
4949 # Push all libobjs files onto de_ansi_files. We actually only
4950 # push files which exist in the current directory, and which are
4951 # genuine source files.
4952 foreach my $file (keys %libsources)
4954 if ($file =~ /^(.*)\.[cly]$/ && -f "$relative_dir/$file")
4956 $de_ansi_files{$1} = 1;
4960 if (defined $options{'ansi2knr'} && keys %de_ansi_files)
4962 # Make all _.c files depend on their corresponding .c files.
4964 foreach my $base (sort keys %de_ansi_files)
4966 # Each _.c file must depend on ansi2knr; otherwise it
4967 # might be used in a parallel build before it is built.
4968 # We need to support files in the srcdir and in the build
4969 # dir (because these files might be auto-generated. But
4970 # we can't use $< -- some makes only define $< during a
4972 $output_rules .= ($base . "_.c: $base.c \$(ANSI2KNR)\n\t"
4973 . '$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) '
4974 . '`if test -f $(srcdir)/' . $base . '.c'
4975 . '; then echo $(srcdir)/' . $base . '.c'
4976 . '; else echo ' . $base . '.c; fi` '
4977 . "| sed 's/^# \\([0-9]\\)/#line \\1/' "
4978 . '| $(ANSI2KNR) > ' . $base . "_.c"
4979 # If ansi2knr fails then we shouldn't
4980 # create the _.c file
4981 . " || rm -f ${base}_.c\n");
4982 push (@objects, $base . '_.$(OBJEXT)');
4983 push (@objects, $base . '_.lo')
4987 # Make all _.o (and _.lo) files depend on ansi2knr.
4988 # Use a sneaky little hack to make it print nicely.
4989 &pretty_print_rule ('', '', @objects, ':', '$(ANSI2KNR)');
4994 # This is a helper for both lex and yacc.
4995 sub yacc_lex_finish_helper
4997 return if defined $language_scratch{'lex-yacc-done'};
4998 $language_scratch{'lex-yacc-done'} = 1;
5000 # If there is more than one distinct yacc (resp lex) source file
5001 # in a given directory, then the `ylwrap' program is required to
5002 # allow parallel builds to work correctly. FIXME: for now, no
5004 &require_config_file ($FOREIGN, 'ylwrap');
5005 if ($config_aux_dir_set_in_configure_in)
5007 &define_variable ('YLWRAP', $config_aux_dir . "/ylwrap");
5011 &define_variable ('YLWRAP', '$(srcdir)/ylwrap');
5015 sub lang_yacc_finish
5017 return if defined $language_scratch{'yacc-done'};
5018 $language_scratch{'yacc-done'} = 1;
5020 my %seen_suffix = ();
5021 my @yacc_files = sort keys %yacc_sources;
5022 my $yacc_count = scalar (@yacc_files);
5023 foreach my $file (@yacc_files)
5026 &output_yacc_build_rule ($1, $yacc_count > 1)
5027 if ! defined $seen_suffix{$1};
5028 $seen_suffix{$1} = 1;
5030 $file =~ /^(.*)\.(y|yy|y\+\+|yxx|ypp)$/;
5032 my $hname = 'h'; # Always use `.h' for header file.
5036 if ((&variable_defined ('AM_YFLAGS')
5037 && &variable_value ('AM_YFLAGS') =~ /(^|\s)-d(\s|$)/)
5038 || (&variable_defined ('YFLAGS')
5039 && &variable_value ('YFLAGS') =~ /(^|\s)-d(\s|$)/)) {
5040 # Now generate rule to make the header file. This should only
5041 # be generated if `yacc -d' specified.
5042 $output_rules .= "${base}.${hname}: ${base}.${cname}\n";
5044 # If the files are built in the build directory, then we want
5045 # to remove them with `make clean'. If they are in srcdir
5046 # they shouldn't be touched. However, we can't determine this
5047 # statically, and the GNU rules say that yacc/lex output files
5048 # should be removed by maintainer-clean. So that's what we
5050 push (@maintainer_clean_files, "${base}.${hname}");
5052 &push_dist_common ("${base}.${hname}");
5054 push (@maintainer_clean_files, "${base}.${cname}");
5056 $output_rules .= "\n";
5058 if (&variable_defined ('YACCFLAGS'))
5060 &am_line_error ('YACCFLAGS',
5061 "`YACCFLAGS' obsolete; use `YFLAGS' instead");
5064 if ($yacc_count > 1)
5066 &yacc_lex_finish_helper;
5073 return if defined $language_scratch{'lex-done'};
5074 $language_scratch{'lex-done'} = 1;
5076 my %seen_suffix = ();
5077 my $lex_count = scalar (keys %lex_sources);
5078 foreach my $file (sort keys %lex_sources)
5081 &output_lex_build_rule ($1, $lex_count > 1)
5082 if (! defined $seen_suffix{$1});
5083 $seen_suffix{$1} = 1;
5085 # If the files are built in the build directory, then we want
5086 # to remove them with `make clean'. If they are in srcdir
5087 # they shouldn't be touched. However, we can't determine this
5088 # statically, and the GNU rules say that yacc/lex output files
5089 # should be removed by maintainer-clean. So that's what we
5091 $file =~ /^(.*)\.(l|ll|l\+\+|lxx|lpp)$/;
5093 ($cname = $2) =~ tr/l/c/;
5094 push (@maintainer_clean_files, "${1}.${cname}");
5097 if (! $seen_decl_yytext)
5099 &am_error ("lex source seen but `AC_DECL_YYTEXT' not in `$configure_ac'");
5104 &yacc_lex_finish_helper;
5109 # Given a hash table of linker names, pick the name that has the most
5110 # precedence. This is lame, but something has to have global
5111 # knowledge in order to eliminate the conflict. Add more linkers as
5118 if defined $linkers{'GCJLINK'};
5120 if defined $linkers{'CXXLINK'};
5122 if defined $linkers{'F77LINK'};
5124 if defined $linkers{'OBJCLINK'};
5128 # Called to indicate that an extension was used.
5132 $extension_seen{$ext} = 1;
5135 # Called to ask whether source files have been seen . If HEADERS is 1,
5136 # headers can be included.
5147 $headers = grep ($extension_seen{$_},
5148 @{$languages{'header'}->extensions});
5151 return scalar keys %extension_seen > $headers;
5155 # register_language (%ATTRIBUTE)
5156 # ------------------------------
5157 # Register a single language.
5158 # Each %ATTRIBUTE is of the form ATTRIBUTE => VALUE.
5159 sub register_language (%)
5165 unless defined $option{'ansi'};
5166 $option{'autodep'} = 'no'
5167 unless defined $option{'autodep'};
5168 $option{'derived_autodep'} = 'no'
5169 unless defined $option{'derived_autodep'};
5170 $option{'linker'} = ''
5171 unless defined $option{'linker'};
5173 my $lang = new Language (%option);
5176 grep ($extension_map{$_} = $lang->name, @{$lang->extensions});
5177 $languages{$lang->name} = $lang;
5180 # This function is used to find a path from a user-specified suffix to
5181 # `o' or to some other suffix we recognize internally, eg `cc'.
5184 my ($source_ext) = @_;
5186 # FIXME: hard-coding `o' is a mistake. Doing something
5187 # intelligent is harder.
5188 while ($extension_map{$source_ext} eq ''
5189 && $source_ext ne 'o'
5190 && defined $suffix_rules{$source_ext})
5192 $source_ext = $suffix_rules{$source_ext};
5199 ################################################################
5201 # Pretty-print something. HEAD is what should be printed at the
5202 # beginning of the first line, FILL is what should be printed at the
5203 # beginning of every subsequent line.
5204 sub pretty_print_internal
5206 my ($head, $fill, @values) = @_;
5208 my $column = length ($head);
5211 # Fill length is number of characters. However, each Tab
5212 # character counts for eight. So we count the number of Tabs and
5214 my $fill_length = length ($fill);
5215 $fill_length += 7 * ($fill =~ tr/\t/\t/d);
5219 # "71" because we also print a space.
5220 if ($column + length ($_) > 71)
5222 $result .= " \\\n" . $fill;
5223 $column = $fill_length;
5225 $result .= ' ' if $result =~ /\S\z/;
5227 $column += length ($_) + 1;
5234 # Pretty-print something and append to output_vars.
5237 $output_vars .= &pretty_print_internal (@_);
5240 # Pretty-print something and append to output_rules.
5241 sub pretty_print_rule
5243 $output_rules .= &pretty_print_internal (@_);
5247 ################################################################
5251 # &conditional_string(@COND-STACK)
5252 # --------------------------------
5254 sub conditional_string
5258 if (grep (/^FALSE$/, @stack))
5264 return join (' ', uniq sort grep (!/^TRUE$/, @stack));
5270 # &conditional_true_when ($COND, $WHEN)
5271 # -------------------------------------
5272 # See if a conditional is true. Both arguments are conditional
5273 # strings. This returns true if the first conditional is true when
5274 # the second conditional is true.
5275 # For instance with $COND = `BAR FOO', and $WHEN = `BAR BAZ FOO',
5276 # obviously return 1, and 0 when, for instance, $WHEN = `FOO'.
5277 sub conditional_true_when ($$)
5279 my ($cond, $when) = @_;
5281 # Make a hash holding all the values from $WHEN.
5282 my %cond_vals = map { $_ => 1 } split (' ', $when);
5284 # Check each component of $cond, which looks `COND1 COND2'.
5285 foreach my $comp (split (' ', $cond))
5287 # TRUE is always true.
5288 next if $comp eq 'TRUE';
5289 return 0 if ! defined $cond_vals{$comp};
5297 # &conditionals_true_when (@CONDS, @WHENS)
5298 # ----------------------------------------
5299 # Same as above, but true if all the @CONDS are true when *ALL*
5300 # the @WHENS are sufficient.
5302 # If there are no @CONDS, then return true, of course. *BUT*, even if there
5303 # are @CONDS but @WHENS is empty, return true. This is counter intuitive,
5304 # and against all the rules of logic, but is needed by the current code.
5305 # FIXME: Do something saner when the logic of conditionals is understood.
5306 sub conditionals_true_when (@@)
5308 my (@conds, @whens) = @_;
5310 foreach my $cond (@conds)
5312 foreach my $when (@whens)
5315 unless conditional_true_when ($cond, $when);
5324 # condition_negate ($COND)
5325 # ------------------------
5326 sub condition_negate ($)
5330 $cond =~ s/TRUE$/TRUEO/;
5331 $cond =~ s/FALSE$/TRUE/;
5332 $cond =~ s/TRUEO$/FALSE/;
5338 # Compare condition names.
5339 # Issue them in alphabetical order, foo_TRUE before foo_FALSE.
5342 # Be careful we might be comparing `' or `#'.
5343 $a =~ /^(.*)_(TRUE|FALSE)$/;
5344 my ($aname, $abool) = ($1 || '', $2 || '');
5345 $b =~ /^(.*)_(TRUE|FALSE)$/;
5346 my ($bname, $bbool) = ($1 || '', $2 || '');
5347 return ($aname cmp $bname
5348 # Don't bother with IFs, given that TRUE is after FALSE
5349 # just cmp in the reverse order.
5350 || $bbool cmp $abool
5356 # &make_condition (@CONDITIONS)
5357 # -----------------------------
5358 # Transform a list of conditions (themselves can be an internal list
5359 # of conditions, e.g., @CONDITIONS = ('cond1 cond2', 'cond3')) into a
5360 # Make conditional (a pattern for AC_SUBST).
5361 # Correctly returns the empty string when there are no conditions.
5364 my $res = conditional_string (@_);
5366 # There are no conditions.
5372 elsif ($res eq 'FALSE')
5379 $res = '@' . $res . '@';
5388 ## ------------------------------ ##
5389 ## Handling the condition stack. ##
5390 ## ------------------------------ ##
5394 # cond_stack_if ($NEGATE, $COND, $WHERE)
5395 # --------------------------------------
5396 sub cond_stack_if ($$$)
5398 my ($negate, $cond, $where) = @_;
5400 &am_file_error ($where, "$cond does not appear in AM_CONDITIONAL")
5401 if ! $configure_cond{$cond} && $cond !~ /^TRUE|FALSE$/;
5403 $cond = "${cond}_TRUE"
5404 unless $cond =~ /^TRUE|FALSE$/;
5405 $cond = condition_negate ($cond)
5408 push (@cond_stack, $cond);
5410 return conditional_string (@cond_stack);
5415 # cond_stack_else ($NEGATE, $COND, $WHERE)
5416 # ----------------------------------------
5417 sub cond_stack_else ($$$)
5419 my ($negate, $cond, $where) = @_;
5423 &am_file_error ($where, "else without if");
5427 $cond_stack[$#cond_stack] = condition_negate ($cond_stack[$#cond_stack]);
5429 # If $COND is given, check against it.
5432 $cond = "${cond}_TRUE"
5433 unless $cond =~ /^TRUE|FALSE$/;
5434 $cond = condition_negate ($cond)
5437 &am_file_error ($where,
5438 "else reminder ($negate$cond) incompatible with "
5439 . "current conditional: $cond_stack[$#cond_stack]")
5440 if $cond_stack[$#cond_stack] ne $cond;
5443 return conditional_string (@cond_stack);
5448 # cond_stack_endif ($NEGATE, $COND, $WHERE)
5449 # -----------------------------------------
5450 sub cond_stack_endif ($$$)
5452 my ($negate, $cond, $where) = @_;
5457 &am_file_error ($where, "endif without if: $negate$cond");
5462 # If $COND is given, check against it.
5465 $cond = "${cond}_TRUE"
5466 unless $cond =~ /^TRUE|FALSE$/;
5467 $cond = condition_negate ($cond)
5470 &am_file_error ($where,
5471 "endif reminder ($negate$cond) incompatible with "
5472 . "current conditional: $cond_stack[$#cond_stack]")
5473 if $cond_stack[$#cond_stack] ne $cond;
5478 return conditional_string (@cond_stack);
5485 ## ------------------------ ##
5486 ## Handling the variables. ##
5487 ## ------------------------ ##
5490 # check_ambiguous_conditional ($VAR, $COND)
5491 # -----------------------------------------
5492 # Check for an ambiguous conditional. This is called when a variable
5493 # is being defined conditionally. If we already know about a
5494 # definition that is true under the same conditions, then we have an
5496 sub check_ambiguous_conditional ($$)
5498 my ($var, $cond) = @_;
5499 foreach my $vcond (keys %{$var_value{$var}})
5502 if ($vcond eq $cond)
5504 $message = "$var multiply defined in condition $cond";
5506 elsif (&conditional_true_when ($vcond, $cond))
5508 $message = ("$var was already defined in condition $vcond, "
5509 . "which implies condition $cond");
5511 elsif (&conditional_true_when ($cond, $vcond))
5513 $message = ("$var was already defined in condition $vcond, "
5514 . "which is implied by condition $cond");
5518 &am_line_error ($var, $message);
5525 # ¯o_define($VAR, $VAR_IS_AM, $TYPE, $COND, $VALUE, $WHERE)
5526 # -------------------------------------------------------------
5527 # The $VAR can go from Automake to user, but not the converse.
5528 sub macro_define ($$$$$$)
5530 my ($var, $var_is_am, $type, $cond, $value, $where) = @_;
5532 am_file_error ($where, "bad macro name `$var'")
5533 if $var !~ /$MACRO_PATTERN/o;
5537 # An Automake variable must be consistently defined with the same
5538 # sign by Automake. A user variable must be set by either `=' or
5539 # `:=', and later promoted to `+='.
5542 if (defined $var_type{$var} && $var_type{$var} ne $type)
5544 am_line_error ($var,
5545 ("$var was set with `$var_type{$var}=' "
5546 . "and is now set with `$type='"));
5551 if (!defined $var_type{$var} && $type eq '+')
5553 am_line_error ($var, "$var must be set with `=' before using `+='");
5556 $var_type{$var} = $type;
5558 # When adding, since we rewrite, don't try to preserve the
5559 # Automake continuation backslashes.
5561 if $type eq '+' && $var_is_am;
5563 # Differentiate the first assignment (including with `+=').
5564 if ($type eq '+' && defined $var_value{$var}{$cond})
5566 if (substr ($var_value{$var}{$cond}, -1) eq "\n")
5568 # Insert a backslash before a trailing newline.
5569 $var_value{$var}{$cond} =
5570 substr ($var_value{$var}{$cond}, 0, -1) . "\\\n";
5572 elsif ($var_value{$var}{$cond})
5574 # Insert a separator.
5575 $var_value{$var}{$cond} .= ' ';
5577 $var_value{$var}{$cond} .= $value;
5581 # The first assignment to a macro sets the line number. Ideally I
5582 # suppose we would associate line numbers with random bits of text.
5583 # FIXME: We sometimes redefine some variables, but we want to keep
5584 # the original location. More subs are needed to handle
5585 # properly variables. Once this done, remove this hack.
5586 $var_line{$var} = $where
5587 unless defined $var_line{$var};
5589 # If Automake tries to override a value specified by the user,
5590 # just don't let it do.
5591 if (defined $var_value{$var}{$cond} && !$var_is_am{$var} && $var_is_am)
5595 print STDERR "$me: refusing to override the user definition of:\n";
5597 print STDERR "$me: with `$cond' => `$value'\n";
5602 # There must be no previous value unless the user is redefining
5603 # an Automake variable or an AC_SUBST variable.
5604 check_ambiguous_conditional ($var, $cond)
5605 unless ($var_is_am{$var} && !$var_is_am
5606 || exists $configure_vars{$var});
5608 $var_value{$var}{$cond} = $value;
5612 # An Automake variable can be given to the user, but not the converse.
5613 if (! defined $var_is_am{$var} || !$var_is_am)
5615 $var_is_am{$var} = $var_is_am;
5620 # &variable_delete ($VAR, [@CONDS])
5621 # ---------------------------------
5622 # Forget about $VAR under the conditions @CONDS, or completely if
5624 sub variable_delete ($@)
5626 my ($var, @conds) = @_;
5630 delete $var_value{$var};
5631 delete $var_line{$var};
5632 delete $var_is_am{$var};
5633 delete $var_comment{$var};
5634 delete $var_type{$var};
5638 foreach my $cond (@conds)
5640 delete $var_value{$var}{$cond};
5646 # ¯o_dump ($VAR)
5647 # ------------------
5652 if (!exists $var_value{$var})
5654 print STDERR " $var does not exist\n";
5658 my $var_is_am = $var_is_am{$var} ? "Automake" : "User";
5659 my $where = (defined $var_line{$var}
5660 ? $var_line{$var} : "undefined");
5661 print STDERR "$var_comment{$var}"
5662 if defined $var_comment{$var};
5663 print STDERR " $var ($var_is_am, where = $where) $var_type{$var}=\n";
5664 print STDERR " {\n";
5665 foreach my $vcond (sort by_condition keys %{$var_value{$var}})
5667 print STDERR " $vcond => $var_value{$var}{$vcond}\n";
5669 print STDERR " }\n";
5680 print STDERR "%var_value =\n";
5682 foreach my $var (sort (keys %var_value))
5691 # &variable_defined ($VAR, [$COND])
5692 # ---------------------------------
5693 # See if a variable exists. $VAR is the variable name, and $COND is
5694 # the condition which we should check. If no condition is given, we
5695 # currently return true if the variable is defined under any
5697 sub variable_defined ($$)
5699 my ($var, $cond) = @_;
5701 # Unfortunately we can't just check for $var_value{VAR}{COND}
5702 # as this would make perl create $condition{VAR}, which we
5704 if (!exists $var_value{$var})
5706 if (defined $targets{$var})
5708 &am_line_error ($var, "`$var' is a target; expected a variable")
5710 # The variable is not defined
5714 if ($cond && !exists $var_value{$var}{$cond})
5716 # The variable is not defined for the given condition.
5720 # Even a var_value examination is good enough for us. FIXME:
5721 # really should maintain examined status on a per-condition basis.
5722 $content_seen{$var} = 1;
5726 # Mark a variable as examined.
5727 sub examine_variable
5730 &variable_defined ($var);
5733 # Return the set of conditions for which a variable is defined.
5735 # If the variable is not defined conditionally, and is not defined in
5736 # terms of any variables which are defined conditionally, then this
5737 # returns the empty list.
5739 # If the variable is defined conditionally, but is not defined in
5740 # terms of any variables which are defined conditionally, then this
5741 # returns the list of conditions for which the variable is defined.
5743 # If the variable is defined in terms of any variables which are
5744 # defined conditionally, then this returns a full set of permutations
5745 # of the subvariable conditions. For example, if the variable is
5746 # defined in terms of a variable which is defined for COND_TRUE,
5747 # then this returns both COND_TRUE and COND_FALSE. This is
5748 # because we will need to define the variable under both conditions.
5750 sub variable_conditions ($)
5757 foreach my $cond (&variable_conditions_sub ($var, '', ()))
5760 if $cond eq 'FALSE';
5761 $uniqify{$cond} = 1;
5764 @uniq_list = sort by_condition keys %uniqify;
5765 # Note we cannot just do `return sort keys %uniqify', because this
5766 # function is sometimes used in a scalar context.
5772 # &variable_conditionally_defined ($VAR)
5773 # --------------------------------------
5774 sub variable_conditionally_defined ($)
5777 foreach my $cond (variable_conditions ($var))
5780 unless $cond =~ /^TRUE|FALSE$/;
5787 # &variable_conditions_sub ($VAR, $PARENT, @PARENT_CONDS)
5788 # -------------------------------------------------------
5789 # A subroutine of variable_conditions. We only return conditions
5790 # which are true for all the conditions in @PARENT_CONDS.
5791 sub variable_conditions_sub
5793 my ($var, $parent, @parent_conds) = @_;
5796 if (defined $vars_scanned{$var})
5798 &am_line_error ($parent, "variable `$var' recursively defined");
5801 $vars_scanned{$var} = 1;
5803 my @this_conds = ();
5804 foreach my $vcond (keys %{$var_value{$var}})
5807 if ! conditionals_true_when ((@parent_conds), ($vcond));
5809 push (@this_conds, $vcond);
5811 push (@parent_conds, $vcond);
5812 my @subvar_conds = ();
5813 foreach (split (' ', $var_value{$var}{$vcond}))
5815 # If a comment seen, just leave.
5818 # Handle variable substitutions.
5819 if (/^\$\{(.*)\}$/ || /^\$\((.*)\)$/)
5821 push (@subvar_conds,
5822 &variable_conditions_sub ($1, $var, @parent_conds));
5825 pop (@parent_conds);
5827 # If there are no conditional subvariables, then we want to
5828 # return this condition. Otherwise, we want to return the
5829 # permutations of the subvariables.
5830 if (! @subvar_conds)
5832 push (@new_conds, $vcond);
5836 push (@new_conds, &variable_conditions_reduce (@subvar_conds));
5840 # Unset our entry in vars_scanned. We only care about recursive
5842 delete $vars_scanned{$var};
5844 # If there are no parents, then this call is the top level call.
5847 # Now we want to return all permutations of the subvariable
5850 foreach my $item (@new_conds)
5852 foreach (split (' ', $item))
5854 s/^(.*)_(TRUE|FALSE)$/$1_TRUE/;
5858 return &variable_conditions_permutations (sort keys %allconds);
5861 # If we are being called on behalf of another variable, we need to
5862 # return all possible permutations of the conditions. We have
5863 # already handled everything in @this_conds along with their
5864 # subvariables. We now need to add any permutations that are not
5866 foreach my $this_cond (@this_conds)
5869 &variable_conditions_permutations (split(' ', $this_cond));
5870 foreach my $perm (@perms)
5873 foreach my $scan (@this_conds)
5875 if (&conditional_true_when ($perm, $scan)
5876 || &conditional_true_when ($scan, $perm))
5885 if ! conditionals_true_when ((@parent_conds), ($perm));
5887 # This permutation was not already handled, and is valid
5889 push (@new_conds, $perm);
5897 # Filter a list of conditionals so that only the exclusive ones are
5898 # retained. For example, if both `COND1_TRUE COND2_TRUE' and
5899 # `COND1_TRUE' are in the list, discard the latter.
5900 sub variable_conditions_reduce
5904 foreach my $cond (@conds)
5906 # FALSE is absorbent.
5907 if ($cond eq 'FALSE')
5911 elsif (conditionals_true_when (($cond), (@ret)))
5920 # Return a list of permutations of a conditional string.
5921 sub variable_conditions_permutations
5926 my $comp = shift (@comps);
5927 return &variable_conditions_permutations (@comps)
5929 my $neg = condition_negate ($comp);
5932 foreach my $sub (&variable_conditions_permutations (@comps))
5934 push (@ret, "$comp $sub");
5935 push (@ret, "$neg $sub");
5947 # &check_variable_defined_unconditionally($VAR, $PARENT)
5948 # ------------------------------------------------------
5949 # Warn if a variable is conditionally defined. This is called if we
5950 # are using the value of a variable.
5951 sub check_variable_defined_unconditionally ($$)
5953 my ($var, $parent) = @_;
5954 foreach my $cond (keys %{$var_value{$var}})
5957 if $cond =~ /^TRUE|FALSE$/;
5961 &am_line_error ($parent,
5962 "warning: automake does not support conditional definition of $var in $parent");
5966 &am_line_error ($parent,
5967 "warning: automake does not support $var being defined conditionally");
5975 # Get the TRUE value of a variable, warn if the variable is
5976 # conditionally defined.
5980 &check_variable_defined_unconditionally ($var);
5981 return $var_value{$var}{'TRUE'};
5986 # &value_to_list ($VAR, $VAL, $COND)
5987 # ----------------------------------
5988 # Convert a variable value to a list, split as whitespace. This will
5989 # recursively follow $(...) and ${...} inclusions. It preserves @...@
5992 # If COND is 'all', then all values under all conditions should be
5993 # returned; if COND is a particular condition (all conditions are
5994 # surrounded by @...@) then only the value for that condition should
5995 # be returned; otherwise, warn if VAR is conditionally defined.
5996 # SCANNED is a global hash listing whose keys are all the variables
5997 # already scanned; it is an error to rescan a variable.
6000 my ($var, $val, $cond) = @_;
6004 $val =~ s/\\(\n|$)/ /g;
6006 foreach (split (' ', $val))
6008 # If a comment seen, just leave.
6011 # Handle variable substitutions.
6012 if (/^\$\{([^}]*)\}$/ || /^\$\(([^)]*)\)$/)
6016 # If the user uses a losing variable name, just ignore it.
6017 # This isn't ideal, but people have requested it.
6018 next if ($varname =~ /\@.*\@/);
6022 if ($varname =~ /^([^:]*):([^=]*)=(.*)$/)
6026 ($from = $2) =~ s/(\W)/\\$1/g;
6030 @temp_list = &variable_value_as_list_worker ($1, $cond, $var);
6032 # Now rewrite the value if appropriate.
6035 grep (s/$from$/$to/, @temp_list);
6038 push (@result, @temp_list);
6049 # Return contents of variable as list, split as whitespace. This will
6050 # recursively follow $(...) and ${...} inclusions. It preserves @...@
6051 # substitutions. If COND is 'all', then all values under all
6052 # conditions should be returned; if COND is a particular condition
6053 # (all conditions are surrounded by @...@) then only the value for
6054 # that condition should be returned; otherwise, warn if VAR is
6055 # conditionally defined. If PARENT is specified, it is the name of
6056 # the including variable; this is only used for error reports.
6057 sub variable_value_as_list_worker
6059 my ($var, $cond, $parent) = @_;
6062 if (! defined $var_value{$var})
6064 if (defined $targets{$var})
6066 &am_line_error ($var, "`$var' is a target; expected a variable");
6070 &am_line_error ($parent, "variable `$var' not defined");
6073 elsif (defined $vars_scanned{$var})
6075 # `vars_scanned' is a global we use to keep track of which
6076 # variables we've already examined.
6077 &am_line_error ($parent, "variable `$var' recursively defined");
6079 elsif ($cond eq 'all')
6081 $vars_scanned{$var} = 1;
6082 foreach my $vcond (keys %{$var_value{$var}})
6084 my $val = $var_value{$var}{$vcond};
6085 push (@result, &value_to_list ($var, $val, $cond));
6091 $vars_scanned{$var} = 1;
6093 foreach my $vcond (keys %{$var_value{$var}})
6095 my $val = $var_value{$var}{$vcond};
6096 if (&conditional_true_when ($vcond, $cond))
6098 # Warn if we have an ambiguity. It's hard to know how
6099 # to handle this case correctly.
6100 &check_variable_defined_unconditionally ($var, $parent)
6103 push (@result, &value_to_list ($var, $val, $cond));
6108 # Unset our entry in vars_scanned. We only care about recursive
6110 delete $vars_scanned{$var};
6116 # &variable_output ($VAR, [@CONDS])
6117 # ---------------------------------
6118 # Output all the values of $VAR is @COND is not specified, else only
6119 # that corresponding to @COND.
6120 sub variable_output ($@)
6122 my ($var, @conds) = @_;
6124 @conds = sort by_condition keys %{$var_value{$var}}
6127 $output_vars .= $var_comment{$var}
6128 if defined $var_comment{$var};
6130 foreach my $cond (@conds)
6132 my $val = $var_value{$var}{$cond};
6133 my $equals = $var_type{$var} eq ':' ? ':=' : '=';
6134 my $output_var = "$var $equals $val";
6135 $output_var =~ s/^/make_condition ($cond)/meg;
6136 $output_vars .= $output_var . "\n";
6141 # &variable_pretty_output ($VAR, [@CONDS])
6142 # ----------------------------------------
6143 # Likewise, but pretty, i.e., we *split* the values at spaces. Use only
6144 # with variables holding filenames.
6145 sub variable_pretty_output ($@)
6147 my ($var, @conds) = @_;
6149 @conds = sort by_condition keys %{$var_value{$var}}
6152 $output_vars .= $var_comment{$var}
6153 if defined $var_comment{$var};
6155 foreach my $cond (@conds)
6157 my $val = $var_value{$var}{$cond};
6158 my $equals = $var_type{$var} eq ':' ? ':=' : '=';
6159 my $make_condition = make_condition ($cond);
6160 $output_vars .= pretty_print_internal ("$make_condition$var $equals",
6161 "$make_condition\t",
6162 split (' ' , $val));
6167 # This is just a wrapper for variable_value_as_list_worker that
6168 # initializes the global hash `vars_scanned'. This hash is used to
6169 # avoid infinite recursion.
6170 sub variable_value_as_list
6172 my ($var, $cond, $parent) = @_;
6174 return &variable_value_as_list_worker ($var, $cond, $parent);
6178 # Like define_variable, but the value is a list, and the variable may
6179 # be defined conditionally. The second argument is the conditional
6180 # under which the value should be defined; this should be the empty
6181 # string to define the variable unconditionally. The third argument
6182 # is a list holding the values to use for the variable. The value is
6183 # pretty printed in the output file.
6184 sub define_pretty_variable
6186 my ($var, $cond, @value) = @_;
6188 # Beware that an empty $cond has a different semantics for
6189 # macro_define and variable_pretty_output.
6192 if (! &variable_defined ($var, $cond))
6194 macro_define ($var, 1, '', $cond, join (' ', @value), undef);
6195 variable_pretty_output ($var, $cond || 'TRUE');
6196 $content_seen{$var} = 1;
6201 # define_variable ($VAR, $VALUE)
6202 # ------------------------------
6203 # Define a new user variable VAR to VALUE, but only if not already defined.
6206 my ($var, $value) = @_;
6208 define_pretty_variable ($var, 'TRUE', $value);
6212 # Like define_variable, but define a variable to be the configure
6213 # substitution by the same name.
6214 sub define_configure_variable
6217 my $value = '@' . $var . '@';
6218 &define_variable ($var, $value);
6222 # define_compiler_variable ($LANG)
6223 # --------------------------------
6224 # Define a compiler variable. We also handle defining the `LT'
6225 # version of the command when using libtool.
6226 sub define_compiler_variable ($)
6230 my ($var, $value) = ($lang->compiler, $lang->compile);
6231 &define_variable ($var, $value);
6232 &define_variable ("LT$var", "\$(LIBTOOL) --mode=compile $value")
6237 # define_linker_variable ($LANG)
6238 # ------------------------------
6239 # Define linker variables.
6240 sub define_linker_variable ($)
6244 my ($var, $value) = ($lang->lder, $lang->ld);
6246 &define_variable ($lang->lder, $lang->ld);
6247 # CCLINK = $(CCLD) blah blah...
6248 &define_variable ($lang->linker,
6249 (($seen_libtool ? '$(LIBTOOL) --mode=link ' : '')
6253 ################################################################
6255 ## ---------------- ##
6256 ## Handling rules. ##
6257 ## ---------------- ##
6259 sub rule_define ($$$$)
6261 my ($target, $rule_is_am, $cond, $where) = @_;
6263 if (defined $targets{$target}
6265 ? ! defined $target_conditional{$target}
6266 : defined $target_conditional{$target}))
6268 &am_line_error ($target,
6269 "$target defined both conditionally and unconditionally");
6272 # Value here doesn't matter; for targets we only note existence.
6273 $targets{$target} = $where;
6276 if ($target_conditional{$target})
6278 &check_ambiguous_conditional ($target, $cond);
6280 $target_conditional{$target}{$cond} = $where;
6284 # Check the rule for being a suffix rule. If so, store in a hash.
6286 if ((my ($source_suffix, $object_suffix)) = ($target =~ $SUFFIX_RULE_PATTERN))
6288 $suffix_rules{$source_suffix} = $object_suffix;
6289 print "Sources ending in .$source_suffix become .$object_suffix\n"
6291 # Set SUFFIXES from suffix_rules.
6292 push @suffixes, ".$source_suffix", ".$object_suffix";
6297 # See if a target exists.
6301 return defined $targets{$target};
6305 ################################################################
6307 # Read Makefile.am and set up %contents. Simultaneously copy lines
6308 # from Makefile.am into $output_trailer or $output_vars as
6309 # appropriate. NOTE we put rules in the trailer section. We want
6310 # user rules to come after our generated stuff.
6315 my $am_file = new IO::File ("< $amfile");
6318 die "$me: couldn't open `$amfile': $!\n";
6320 print "$me: reading $amfile\n" if $verbose;
6326 while ($_ = $am_file->getline)
6328 if (/$IGNORE_PATTERN/o)
6330 # Merely delete comments beginning with two hashes.
6332 elsif (/$WHITE_PATTERN/o)
6334 # Stick a single white line before the incoming macro or rule.
6338 elsif (/$COMMENT_PATTERN/o)
6340 # Stick comments before the incoming macro or rule. Make
6341 # sure a blank line preceeds first block of comments.
6342 $spacing = "\n" unless $blank;
6344 $comment .= $spacing . $_;
6353 $output_vars .= $comment . "\n";
6357 # We save the conditional stack on entry, and then check to make
6358 # sure it is the same on exit. This lets us conditonally include
6360 my @saved_cond_stack = @cond_stack;
6361 my $cond = conditional_string (@cond_stack);
6365 my $last_var_name = '';
6366 my $last_var_type = '';
6367 my $last_var_value = '';
6368 # FIXME: shouldn't use $_ in this loop; it is too big.
6372 unless substr ($_, -1, 1) eq "\n";
6374 # Don't look at MAINTAINER_MODE_TRUE here. That shouldn't be
6375 # used by users. @MAINT@ is an anachronism now.
6376 $_ =~ s/\@MAINT\@//g
6377 unless $seen_maint_mode;
6379 my $new_saw_bk = /\\$/;
6381 if (/$IGNORE_PATTERN/o)
6383 # Merely delete comments beginning with two hashes.
6385 elsif (/$WHITE_PATTERN/o)
6387 # Stick a single white line before the incoming macro or rule.
6389 &am_line_error ($., "blank line following trailing backslash")
6392 elsif (/$COMMENT_PATTERN/o)
6394 # Stick comments before the incoming macro or rule.
6395 $comment .= $spacing . $_;
6397 &am_line_error ($., "comment following trailing backslash")
6404 $output_trailer .= &make_condition (@cond_stack);
6405 $output_trailer .= $_;
6409 $last_var_value .= ' '
6410 unless $last_var_value =~ /\s$/;
6411 $last_var_value .= $_;
6415 $var_comment{$last_var_name} .= "$spacing"
6416 if (!defined $var_comment{$last_var_name}
6417 || substr ($var_comment{$last_var_name}, -1) ne "\n");
6418 $var_comment{$last_var_name} .= "$comment";
6419 $comment = $spacing = '';
6420 macro_define ($last_var_name, 0,
6421 $last_var_type, $cond,
6422 $last_var_value, $.)
6423 if $cond ne 'FALSE';
6424 push (@var_list, $last_var_name);
6429 elsif (/$IF_PATTERN/o)
6431 $cond = cond_stack_if ($1, $2, "$amfile:$.");
6433 elsif (/$ELSE_PATTERN/o)
6435 $cond = cond_stack_else ($1, $2, "$amfile:$.");
6437 elsif (/$ENDIF_PATTERN/o)
6439 $cond = cond_stack_endif ($1, $2, "$amfile:$.");
6442 elsif (/$RULE_PATTERN/o)
6447 rule_define ($1, 0, $cond, $.);
6450 $output_trailer .= $comment . $spacing;
6451 $output_trailer .= &make_condition (@cond_stack);
6452 $output_trailer .= $_;
6453 $comment = $spacing = '';
6455 elsif (/$ASSIGNMENT_PATTERN/o)
6457 # Found a macro definition.
6459 $last_var_name = $1;
6460 $last_var_type = $2;
6461 $last_var_value = $3;
6462 if ($3 ne '' && substr ($3, -1) eq "\\")
6464 # We preserve the `\' because otherwise the long lines
6465 # that are generated will be truncated by broken
6467 $last_var_value = $3 . "\n";
6472 # FIXME: this doesn't always work correctly; it will
6473 # group all comments for a given variable, no matter
6475 # Accumulating variables must not be output.
6476 $var_comment{$last_var_name} .= "$spacing"
6477 if (!defined $var_comment{$last_var_name}
6478 || substr ($var_comment{$last_var_name}, -1) ne "\n");
6479 $var_comment{$last_var_name} .= "$comment";
6480 $comment = $spacing = '';
6482 macro_define ($last_var_name, 0,
6483 $last_var_type, $cond,
6484 $last_var_value, $.)
6485 if $cond ne 'FALSE';
6486 push (@var_list, $last_var_name);
6489 elsif (/$INCLUDE_PATTERN/o)
6493 if ($path =~ s/^\$\(top_srcdir\)\///)
6495 push (@include_stack, "\$\(top_srcdir\)/$path");
6499 $path =~ s/\$\(srcdir\)\///;
6500 push (@include_stack, "\$\(srcdir\)/$path");
6501 $path = $relative_dir . "/" . $path;
6503 &read_am_file ($path);
6507 # This isn't an error; it is probably a continued rule.
6508 # In fact, this is what we assume.
6510 $output_trailer .= $comment . $spacing;
6511 $output_trailer .= &make_condition (@cond_stack);
6512 $output_trailer .= $_;
6513 $comment = $spacing = '';
6514 &am_line_error ($., "`#' comment at start of rule is unportable")
6515 if $_ =~ /^\t\s*\#/;
6518 $saw_bk = $new_saw_bk;
6519 $_ = $am_file->getline;
6522 $output_trailer .= $comment;
6524 if (join (' ', @saved_cond_stack) ne join (' ', @cond_stack))
6528 &am_error ("unterminated conditionals: @cond_stack");
6532 # FIXME: better error message here.
6533 &am_error ("conditionals not nested in include file");
6539 # define_standard_variables ()
6540 # ----------------------------
6541 # A helper for read_main_am_file which initializes configure variables
6542 # and variables from header-vars.am. This is a subr so we can call it
6544 sub define_standard_variables
6546 my $saved_output_vars = $output_vars;
6547 my ($comments, undef, $rules) =
6548 file_contents_internal (1, "$libdir/am/header-vars.am");
6550 # This will output the definitions in $output_vars, which we don't
6552 foreach my $var (sort keys %configure_vars)
6554 &define_configure_variable ($var);
6555 push (@var_list, $var);
6558 # ... hence, we restore $output_vars.
6559 $output_vars = $saved_output_vars . $comments . $rules;
6562 # Read main am file.
6563 sub read_main_am_file
6567 # This supports the strange variable tricks we are about to play.
6568 if (scalar keys %var_value > 0)
6571 &prog_error ("variable defined before read_main_am_file");
6574 # Generate copyright header for generated Makefile.in.
6575 # We do discard the output of predefined variables, handled below.
6576 $output_vars = ("# $in_file_name generated automatically by automake "
6577 . $VERSION . " from $am_file_name.\n");
6578 $output_vars .= $gen_copyright;
6580 # We want to predefine as many variables as possible. This lets
6581 # the user set them with `+=' in Makefile.am. However, we don't
6582 # want these initial definitions to end up in the output quite
6583 # yet. So we just load them, but output them later.
6584 &define_standard_variables;
6586 # Read user file, which might override some of our values.
6587 &read_am_file ($amfile);
6589 # Ouput all the Automake variables. If the user changed one, then
6590 # it is now marked as owned by the user.
6591 foreach my $var (uniq @var_list)
6593 # Don't process user variables.
6594 variable_output ($var)
6595 unless !$var_is_am{$var};
6598 # Now dump the user variables that were defined. We do it in the same
6599 # order in which they were defined (skipping duplicates).
6600 foreach my $var (uniq @var_list)
6602 # Don't process Automake variables.
6603 variable_output ($var)
6604 unless $var_is_am{$var};
6608 ################################################################
6611 # &flatten ($STRING)
6612 # ------------------
6613 # Flatten the $STRING and return the result.
6628 # &make_paragraphs ($MAKEFILE, [%TRANSFORM])
6629 # ------------------------------------------
6630 # Load a $MAKEFILE, apply the %TRANSFORM, and return it as a list of
6632 sub make_paragraphs ($%)
6634 my ($file, %transform) = @_;
6636 # Complete %transform with global options and make it a Perl
6639 "s/$IGNORE_PATTERN//gm;"
6640 . transform (%transform,
6642 'CYGNUS' => $cygnus_mode,
6644 => $seen_maint_mode ? subst ('MAINTAINER_MODE_TRUE') : '',
6646 'SHAR' => $options{'dist-shar'} || 0,
6647 'BZIP2' => $options{'dist-bzip2'} || 0,
6648 'ZIP' => $options{'dist-zip'} || 0,
6649 'COMPRESS' => $options{'dist-tarZ'} || 0,
6651 'INSTALL-INFO' => !$options{'no-installinfo'},
6652 'INSTALL-MAN' => !$options{'no-installman'},
6653 'CK-NEWS' => $options{'check-news'} || 0,
6655 'SUBDIRS' => &variable_defined ('SUBDIRS'),
6656 'TOPDIR' => backname ($relative_dir),
6657 'TOPDIR_P' => $relative_dir eq '.',
6658 'CONFIGURE-AC' => $configure_ac,
6660 'BUILD' => $seen_canonical == $AC_CANONICAL_SYSTEM,
6661 'HOST' => $seen_canonical,
6662 'TARGET' => $seen_canonical == $AC_CANONICAL_SYSTEM,
6664 'LIBTOOL' => defined $configure_vars{'LIBTOOL'})
6665 # We don't need more than two consecutive new-lines.
6666 . 's/\n{3,}/\n\n/g';
6668 # Swallow the file and apply the COMMAND.
6669 my $fc_file = new IO::File ("< $file");
6672 die "$me: installation error: cannot open `$file'\n";
6675 print "$me: reading $file\n"
6677 my $saved_dollar_slash = $/;
6679 $_ = $fc_file->getline;
6680 $/ = $saved_dollar_slash;
6685 # Split at unescaped new lines.
6686 my @lines = split (/(?<!\\)\n/, $content);
6689 while (defined ($_ = shift @lines))
6691 my $paragraph = "$_";
6692 # If we are a rule, eat as long as we start with a tab.
6693 if (/$RULE_PATTERN/smo)
6695 while (defined ($_ = shift @lines) && $_ =~ /^\t/)
6697 $paragraph .= "\n$_";
6699 unshift (@lines, $_);
6702 # If we are a comments, eat as much comments as you can.
6703 elsif (/$COMMENT_PATTERN/smo)
6705 while (defined ($_ = shift @lines)
6706 && $_ =~ /$COMMENT_PATTERN/smo)
6708 $paragraph .= "\n$_";
6710 unshift (@lines, $_);
6713 push @res, $paragraph;
6722 # ($COMMENT, $VARIABLES, $RULES)
6723 # &file_contents_internal ($IS_AM, $FILE, [%TRANSFORM])
6724 # -----------------------------------------------------
6725 # Return contents of a file from $libdir/am, automatically skipping
6726 # macros or rules which are already known. $IS_AM iff the caller is
6727 # reading an Automake file (as opposed to the user's Makefile.am).
6728 sub file_contents_internal ($$%)
6730 my ($is_am, $file, %transform) = @_;
6732 my $result_vars = '';
6733 my $result_rules = '';
6737 # We save the conditional stack on entry, and then check to make
6738 # sure it is the same on exit. This lets us conditonally include
6740 my @saved_cond_stack = @cond_stack;
6741 my $cond = conditional_string (@cond_stack);
6743 foreach (make_paragraphs ($file, %transform))
6746 &am_file_error ($file, "blank line following trailing backslash:\n$_")
6748 &am_file_error ($file, "comment following trailing backslash:\n$_")
6753 # Stick empty line before the incoming macro or rule.
6756 elsif (/$COMMENT_PATTERN/mso)
6758 # Stick comments before the incoming macro or rule.
6762 # Handle inclusion of other files.
6763 elsif (/$INCLUDE_PATTERN/o)
6765 if ($cond ne 'FALSE')
6767 my $file = ($is_am ? "$libdir/am/" : '') . $1;
6769 my ($com, $vars, $rules)
6770 = file_contents_internal ($is_am, $file, %transform);
6772 $result_vars .= $vars;
6773 $result_rules .= $rules;
6777 # Handling the conditionals.
6778 elsif (/$IF_PATTERN/o)
6780 $cond = cond_stack_if ($1, $2, $file);
6782 elsif (/$ELSE_PATTERN/o)
6784 $cond = cond_stack_else ($1, $2, $file);
6786 elsif (/$ENDIF_PATTERN/o)
6788 $cond = cond_stack_endif ($1, $2, $file);
6792 elsif (/$RULE_PATTERN/mso)
6794 # Separate relationship from optional actions: the first
6795 # `new-line tab" not preceded by backslash (continuation
6797 # I'm quite shoked! It seems that (\\\n|[^\n]) is not the
6798 # same as `([^\n]|\\\n)!!! Don't swap it, it breaks.
6800 /^((?:\\\n|[^\n])*)(?:\n(\t.*))?$/som;
6801 my ($relationship, $actions) = ($1, $2 || '');
6803 # Separate targets from dependencies: the first colon.
6804 $relationship =~ /^([^:]+\S+) *: *(.*)$/som;
6805 my ($targets, $dependencies) = ($1, $2);
6806 # Remove the escaped new lines.
6807 # I don't know why, but I have to use a tmp $flat_deps.
6808 my $flat_deps = &flatten ($dependencies);
6809 my @deps = split (' ', $flat_deps);
6811 foreach (split (' ' , $targets))
6813 # FIXME: We are not robust to people defining several targets
6814 # at once, only some of them being in %dependencies.
6816 # Output only if not in FALSE.
6817 if (defined $dependencies{$_}
6818 && $cond ne 'FALSE')
6820 &depend ($_, @deps);
6821 $actions{$_} .= $actions;
6825 # Free lance dependency. Output the rule for all the
6826 # targets instead of one by one.
6827 if (!defined $targets{$targets}
6828 && $cond ne 'FALSE')
6830 $paragraph =~ s/^/make_condition (@cond_stack)/gme;
6831 $result_rules .= "$spacing$comment$paragraph\n";
6832 rule_define ($targets, $is_am, $cond, $file);
6834 $comment = $spacing = '';
6840 elsif (/$ASSIGNMENT_PATTERN/mso)
6842 my ($var, $type, $val) = ($1, $2, $3);
6843 &am_file_error ($file, "macro `$var' with trailing backslash")
6846 # Accumulating variables must not be output.
6847 $var_comment{$var} .= "$spacing"
6848 if (!defined $var_comment{$var}
6849 || substr ($var_comment{$var}, -1) ne "\n");
6850 $var_comment{$var} .= "$comment";
6851 macro_define ($var, $is_am, $type, $cond, $val, $file)
6852 if $cond ne 'FALSE';
6853 push (@var_list, $var);
6855 # If the user has set some variables we were in charge
6856 # of (which is detected by the first reading of
6857 # `header-vars.am'), we must not output them.
6858 $result_vars .= "$spacing$comment$_\n"
6859 if $type ne '+' && $var_is_am{$var} && $cond ne 'FALSE';
6861 $comment = $spacing = '';
6865 # This isn't an error; it is probably some tokens which
6866 # configure is supposed to replace, such as `@SET-MAKE@',
6867 # or some part of a rule cut by an if/endif.
6868 if ($cond ne 'FALSE')
6870 s/^/make_condition (@cond_stack)/gme;
6871 $result_rules .= "$spacing$comment$_\n";
6873 $comment = $spacing = '';
6877 if (join (' ', @saved_cond_stack) ne join (' ', @cond_stack))
6881 &am_error ("unterminated conditionals: @cond_stack");
6885 # FIXME: better error message here.
6886 &am_error ("conditionals not nested in include file");
6890 return ($comment, $result_vars, $result_rules);
6895 # &file_contents ($BASENAME, [%TRANSFORM])
6896 # ----------------------------------------
6897 # Return contents of a file from $libdir/am, automatically skipping
6898 # macros or rules which are already known.
6899 sub file_contents ($%)
6901 my ($basename, %transform) = @_;
6902 my ($comments, $variables, $rules) =
6903 file_contents_internal (1, "$libdir/am/$basename.am", %transform);
6904 return "$comments$variables$rules";
6909 # &transform (%PAIRS)
6910 # -------------------
6911 # Foreach ($TOKEN, $VAL) in %PAIRS produce a replacement expression suitable
6912 # for file_contents which:
6913 # - replaces @$TOKEN@ with $VALUE,
6914 # - enables/disables ?$TOKEN?.
6920 while (my ($token, $val) = each %pairs)
6922 $result .= "s/\Q%$token%\E/\Q$val\E/gm;";
6925 $result .= "s/\Q?$token?\E//gm;s/^.*\Q?!$token?\E.*\\n//gm;";
6926 $result .= "s/\Q%?$token%\E/TRUE/gm;";
6930 $result .= "s/\Q?!$token?\E//gm;s/^.*\Q?$token?\E.*\\n//gm;";
6931 $result .= "s/\Q%?$token%\E/FALSE/gm;";
6939 # Find all variable prefixes that are used for install directories. A
6940 # prefix `zar' qualifies iff:
6941 # * `zardir' is a variable.
6942 # * `zar_PRIMARY' is a variable.
6943 sub am_primary_prefixes
6945 my ($primary, $can_dist, @prefixes) = @_;
6947 my %valid = map { $_ => 0 } @prefixes;
6948 $valid{'EXTRA'} = 0;
6949 foreach my $varname (keys %var_value)
6951 # Automake is allowed to define variables that look like they
6952 # are magic variables, such as INSTALL_DATA.
6954 if $var_is_am{$varname};
6956 if ($varname =~ /^(nobase_)?(dist_|nodist_)?(.*)_$primary$/)
6958 my ($base, $dist, $X) = ($1 || '', $2 || '', $3 || '');
6959 if ($dist ne '' && ! $can_dist)
6961 # Note that a configure variable is always legitimate.
6962 # It is natural to name such variables after the
6963 # primary, so we explicitly allow it.
6964 if (! defined $configure_vars{$varname})
6966 &am_line_error ($varname,
6967 "invalid variable `$varname': `dist' is forbidden");
6970 elsif (! defined $valid{$X} && ! &variable_defined ("${X}dir"))
6972 # Note that a configure variable is always legitimate.
6973 # It is natural to name such variables after the
6974 # primary, so we explicitly allow it.
6975 if (! defined $configure_vars{$varname})
6977 &am_line_error ($varname,
6978 "invalid variable `$varname'");
6983 # Ensure all extended prefixes are actually used.
6984 $valid{"$base$dist$X"} = 1;
6992 # Handle `where_HOW' variable magic. Does all lookups, generates
6993 # install code, and possibly generates code to define the primary
6994 # variable. The first argument is the name of the .am file to munge,
6995 # the second argument is the primary variable (eg HEADERS), and all
6996 # subsequent arguments are possible installation locations. Returns
6997 # list of all values of all _HOW targets.
6999 # FIXME: this should be rewritten to be cleaner. It should be broken
7000 # up into multiple functions.
7002 # Usage is: am_install_var (OPTION..., file, HOW, where...)
7009 my $default_dist = 0;
7012 if ($args[0] eq '-noextra')
7016 elsif ($args[0] eq '-candist')
7020 elsif ($args[0] eq '-defaultdist')
7025 elsif ($args[0] !~ /^-/)
7032 my ($file, $primary, @prefixes) = @args;
7034 # Now that configure substitutions are allowed in where_HOW
7035 # variables, it is an error to actually define the primary. We
7036 # allow `JAVA', as it is customarily used to mean the Java
7037 # interpreter. This is but one of several Java hacks. Similarly,
7038 # `PYTHON' is customarily used to mean the Python interpreter.
7039 &am_line_error ($primary, "`$primary' is an anachronism")
7040 if &variable_defined ($primary)
7041 && ($primary ne 'JAVA' && $primary ne 'PYTHON');
7044 # Look for misspellings. It is an error to have a variable ending
7045 # in a "reserved" suffix whose prefix is unknown, eg
7046 # "bni_PROGRAMS". However, unusual prefixes are allowed if a
7047 # variable of the same name (with "dir" appended) exists. For
7048 # instance, if the variable "zardir" is defined, then
7049 # "zar_PROGRAMS" becomes valid. This is to provide a little extra
7050 # flexibility in those cases which need it.
7051 my %valid = &am_primary_prefixes ($primary, $can_dist, @prefixes);
7053 # If a primary includes a configure substitution, then the EXTRA_
7054 # form is required. Otherwise we can't properly do our job.
7056 my $warned_about_extra = 0;
7061 # True if the iteration is the first one. Used for instance to
7062 # output parts of the associated file only once.
7064 foreach my $X (sort keys %valid)
7066 my $one_name = $X . '_' . $primary;
7068 unless (&variable_defined ($one_name));
7070 my $strip_subdir = 1;
7071 # If subdir prefix should be preserved, do so.
7072 if ($X =~ /^nobase_/)
7078 my $nodir_name = $X;
7079 # If files should be distributed, do so.
7083 $dist_p = (($default_dist && $one_name !~ /^nodist_/)
7084 || (! $default_dist && $one_name =~ /^dist_/));
7085 $nodir_name =~ s/^(dist|nodist)_//;
7088 # Append actual contents of where_PRIMARY variable to
7090 foreach my $rcurs (&variable_value_as_list ($one_name, 'all'))
7092 # Skip configure substitutions. Possibly bogus.
7093 if ($rcurs =~ /^\@.*\@$/)
7097 if (! $warned_about_extra)
7099 $warned_about_extra = 1;
7100 &am_line_error ($one_name,
7101 "`$one_name' contains configure substitution, but shouldn't");
7104 # Check here to make sure variables defined in
7105 # configure.ac do not imply that EXTRA_PRIMARY
7107 elsif (! defined $configure_vars{$one_name})
7109 $require_extra = $one_name
7116 push (@result, $rcurs);
7119 # A blatant hack: we rewrite each _PROGRAMS primary to
7120 # include EXEEXT when in Cygwin32 mode.
7121 if ($primary eq 'PROGRAMS')
7123 my @conds = &variable_conditions ($one_name);
7126 foreach my $cond (@conds)
7128 my @one_binlist = ();
7129 my @condval = &variable_value_as_list ($one_name,
7131 foreach my $rcurs (@condval)
7133 if ($rcurs =~ /\./ || $rcurs =~ /^\@.*\@$/)
7135 push (@one_binlist, $rcurs);
7139 push (@one_binlist, $rcurs . '$(EXEEXT)');
7143 push (@condvals, $cond);
7144 push (@condvals, join (' ', @one_binlist));
7147 variable_delete ($one_name);
7150 my $cond = shift (@condvals);
7151 my @val = split (' ', shift (@condvals));
7152 &define_pretty_variable ($one_name, $cond, @val);
7156 # "EXTRA" shouldn't be used when generating clean targets,
7157 # all, or install targets.
7160 # We used to warn if EXTRA_FOO was defined uselessly,
7161 # but this was annoying.
7167 push (@check, '$(' . $one_name . ')');
7171 push (@used, '$(' . $one_name . ')');
7174 # Is this to be installed?
7175 my $install_p = $X ne 'noinst' && $X ne 'check';
7177 # If so, with install-exec? (or install-data?).
7178 my $exec_p = (defined $exec_dir_p {$X}
7182 # Singular form of $PRIMARY.
7183 (my $one_primary = $primary) =~ s/S$//;
7184 $output_rules .= &file_contents ($file,
7187 'PRIMARY' => $primary,
7188 'ONE_PRIMARY' => $one_primary,
7190 'NDIR' => $nodir_name,
7191 'BASE' => $strip_subdir,
7194 'INSTALL' => $install_p,
7195 'DIST' => $dist_p));
7200 # The JAVA variable is used as the name of the Java interpreter.
7201 # The PYTHON variable is used as the name of the Python interpreter.
7202 if (@used && $primary ne 'JAVA' && $primary ne 'PYTHON')
7205 &define_pretty_variable ($primary, '', @used);
7206 $output_vars .= "\n";
7209 if ($require_extra && ! &variable_defined ('EXTRA_' . $primary))
7211 &am_line_error ($require_extra,
7212 "`$require_extra' contains configure substitution, but `EXTRA_$primary' not defined");
7215 # Push here because PRIMARY might be configure time determined.
7216 push (@all, '$(' . $primary . ')')
7217 if @used && $primary ne 'JAVA' && $primary ne 'PYTHON';
7219 # Make the result unique. This lets the user use conditionals in
7220 # a natural way, but still lets us program lazily -- we don't have
7221 # to worry about handling a particular object more than once.
7222 return uniq (sort @result);
7226 ################################################################
7228 # Each key in this hash is the name of a directory holding a
7229 # Makefile.in. These variables are local to `is_make_dir'.
7231 my $make_dirs_set = 0;
7236 if (! $make_dirs_set)
7238 foreach my $iter (@configure_input_files)
7240 $make_dirs{dirname ($iter)} = 1;
7242 # We also want to notice Makefile.in's.
7243 foreach my $iter (@other_input_files)
7245 if ($iter =~ /Makefile\.in$/)
7247 $make_dirs{dirname ($iter)} = 1;
7252 return defined $make_dirs{$dir};
7255 ################################################################
7257 # This variable is local to the "require file" set of functions.
7258 my @require_file_paths = ();
7260 # If a file name appears as a key in this hash, then it has already
7261 # been checked for. This variable is local to the "require file"
7263 %require_file_found = ();
7265 # See if we want to push this file onto dist_common. This function
7266 # encodes the rules for deciding when to do so.
7267 sub maybe_push_required_file
7269 my ($dir, $file, $fullfile) = @_;
7271 if ($dir eq $relative_dir)
7273 &push_dist_common ($file);
7275 elsif ($relative_dir eq '.' && ! &is_make_dir ($dir))
7277 # If we are doing the topmost directory, and the file is in a
7278 # subdir which does not have a Makefile, then we distribute it
7280 &push_dist_common ($fullfile);
7285 # &require_file_internal ($IS_CONFIGURE, $LINE, $MYSTRICT, @FILES)
7286 # ----------------------------------------------------------------
7287 # Verify that the file must exist in the current directory.
7288 # $MYSTRICT is the strictness level at which this file becomes required.
7290 # Must set require_file_paths before calling this function.
7291 # require_file_paths is set to hold a single directory (the one in
7292 # which the first file was found) before return.
7293 sub require_file_internal
7295 my ($is_configure, $line, $mystrict, @files) = @_;
7297 foreach my $file (@files)
7304 # If we've already looked for it, we're done.
7305 next if defined $require_file_found{$file};
7306 $require_file_found{$file} = 1;
7309 my $dangling_sym = 0;
7310 foreach my $dir (@require_file_paths)
7312 $fullfile = $dir . "/" . $file;
7313 $errdir = $dir unless $errdir;
7315 # Use different name for "error filename". Otherwise on
7316 # an error the bad file will be reported as eg
7317 # `../../install-sh' when using the default
7319 $errfile = $errdir . '/' . $file;
7321 if (-l $fullfile && ! -f readlink ($fullfile))
7326 elsif (-f $fullfile)
7329 &maybe_push_required_file ($dir, $file, $fullfile);
7335 if ($found_it && ! $force_missing)
7337 # Prune the path list.
7338 @require_file_paths = $save_dir;
7342 if ($strictness >= $mystrict)
7344 if ($dangling_sym && $add_missing)
7352 # Only install missing files according to our desired
7354 my $message = "required file `$errfile' not found";
7359 # Maybe run libtoolize.
7360 my @syslist = ('libtoolize', '--automake');
7361 push @syslist, '--copy'
7364 && grep ($_ eq $file, @libtoolize_files)
7365 && system (@syslist))
7367 $message = "installing `$errfile'";
7369 $trailer = "; cannot run `libtoolize': $!";
7371 elsif (-f ("$libdir/$file"))
7373 # Install the missing file. Symlink if we
7374 # can, copy if we must. Note: delete the file
7375 # first, in case it is a dangling symlink.
7376 $message = "installing `$errfile'";
7377 # Windows Perl will hang if we try to delete a
7378 # file that doesn't exist.
7379 unlink ($errfile) if -f $errfile;
7380 if ($symlink_exists && ! $copy_missing)
7382 if (! symlink ("$libdir/$file", $errfile))
7385 $trailer = "; error while making link: $!";
7388 elsif (system ('cp', "$libdir/$file", $errfile))
7391 $trailer = "\n error while copying";
7395 &maybe_push_required_file (dirname ($errfile),
7398 # Prune the path list.
7399 @require_file_paths = &dirname ($errfile);
7406 # FIXME: allow actual file to be specified.
7407 &am_conf_line_warning ($configure_ac, $line,
7408 "$message$trailer");
7412 &am_line_warning ($line, "$message$trailer");
7419 # FIXME: allow actual file to be specified.
7420 &am_conf_line_error ($configure_ac, $line,
7421 "$message$trailer");
7425 &am_line_error ($line, "$message$trailer");
7433 # Like require_file_with_line, but error messages refer to
7434 # configure.ac, not the current Makefile.am.
7435 sub require_file_with_conf_line
7437 @require_file_paths = $relative_dir;
7438 &require_file_internal (1, @_);
7441 sub require_file_with_line
7443 @require_file_paths = $relative_dir;
7444 &require_file_internal (0, @_);
7449 @require_file_paths = $relative_dir;
7450 &require_file_internal (0, '', @_);
7453 # Require a file that is also required by Autoconf. Looks in
7454 # configuration path, as specified by AC_CONFIG_AUX_DIR.
7455 sub require_config_file
7457 @require_file_paths = @config_aux_path;
7458 &require_file_internal (1, '', @_);
7459 my $dir = $require_file_paths[0];
7460 @config_aux_path = @require_file_paths;
7461 # Avoid unsightly '/.'s.
7462 $config_aux_dir = '$(top_srcdir)' . ($dir eq '.' ? "" : "/$dir");
7465 # Assumes that the line number is in Makefile.am.
7466 sub require_conf_file_with_line
7468 @require_file_paths = @config_aux_path;
7469 &require_file_internal (0, @_);
7470 my $dir = $require_file_paths[0];
7471 @config_aux_path = @require_file_paths;
7472 # Avoid unsightly '/.'s.
7473 $config_aux_dir = '$(top_srcdir)' . ($dir eq '.' ? "" : "/$dir");
7476 # Assumes that the line number is in configure.ac.
7477 sub require_conf_file_with_conf_line
7479 @require_file_paths = @config_aux_path;
7480 &require_file_internal (1, @_);
7481 my $dir = $require_file_paths[0];
7482 @config_aux_path = @require_file_paths;
7483 # avoid unsightly '/.'s.
7484 $config_aux_dir = '$(top_srcdir)' . ($dir eq '.' ? "" : "/$dir");
7487 ################################################################
7489 # Push a list of files onto dist_common.
7490 sub push_dist_common
7492 &prog_error ("push_dist_common run after handle_dist")
7493 if $handle_dist_run;
7494 macro_define ('DIST_COMMON', 1, '+', '', join (' ', @_), '');
7501 $strictness_name = $_[0];
7502 if ($strictness_name eq 'gnu')
7506 elsif ($strictness_name eq 'gnits')
7508 $strictness = $GNITS;
7510 elsif ($strictness_name eq 'foreign')
7512 $strictness = $FOREIGN;
7516 die "$me: level `$strictness_name' not recognized\n";
7521 ################################################################
7523 # Ensure a file exists.
7528 my $touch = new IO::File (">> $file");
7532 # Glob something. Do this to avoid indentation screwups everywhere we
7533 # want to glob. Gross!
7540 # Remove one level of brackets and strip leading spaces,
7541 # as does m4 to function arguments.
7547 my @letters = split //;
7556 next if $depth == 1;
7561 next if $depth == 0;
7562 # don't count orphan right brackets
7563 $depth = 0 if $depth < 0;
7567 return join '', @result;
7570 ################################################################
7572 # Print an error message and set exit status.
7575 warn "$me: ${am_file}.am: @_\n";
7579 # am_file_error ($FILE, @ARGS)
7580 # ----------------------------
7583 my ($file, @args) = @_;
7585 warn "$file: @args\n";
7591 my ($symbol, @args) = @_;
7593 if ($symbol && "$symbol" ne '-1')
7595 my $file = "${am_file}.am";
7597 if ($symbol =~ /^\d+$/)
7599 # SYMBOL is a line number, so just add the colon.
7600 $file .= ':' . $symbol;
7602 elsif (defined $var_line{$symbol})
7604 # SYMBOL is a variable defined in Makefile.am, so add the
7605 # line number we saved from there.
7606 $file .= ':' . $var_line{$symbol};
7608 elsif (defined $configure_vars{$symbol})
7610 # SYMBOL is a variable defined in configure.ac, so add the
7611 # appropriate line number.
7612 $file = $configure_vars{$symbol};
7616 # Couldn't find the line number.
7618 warn $file, ": @args\n";
7627 # Like am_error, but while scanning configure.ac.
7630 # FIXME: can run in subdirs.
7631 warn "$me: $configure_ac: @_\n";
7635 # Error message with line number referring to configure.ac.
7636 sub am_conf_line_error
7638 my ($file, $line, @args) = @_;
7642 warn "$file: $line: @args\n";
7647 &am_conf_error (@args);
7651 # Warning message with line number referring to configure.ac.
7652 # Does not affect exit_status
7653 sub am_conf_line_warning
7655 my $saved_exit_status = $exit_status;
7656 my $sig = $SIG{'__WARN__'};
7657 $SIG{'__WARN__'} = 'DEFAULT';
7658 am_conf_line_error (@_);
7659 $exit_status = $saved_exit_status;
7660 $SIG{'__WARN__'} = $sig;
7663 # Like am_line_error, but doesn't affect exit status.
7666 my $saved_exit_status = $exit_status;
7667 my $sig = $SIG{'__WARN__'};
7668 $SIG{'__WARN__'} = 'DEFAULT';
7670 $exit_status = $saved_exit_status;
7671 $SIG{'__WARN__'} = $sig;
7674 # Tell user where our aclocal.m4 is, but only once.
7675 sub keyed_aclocal_warning
7678 warn "$me: macro `$key' can be generated by `aclocal'\n";
7681 # Print usage information.
7685 Usage: $0 [OPTION] ... [Makefile]...
7687 Generate Makefile.in for configure from Makefile.am.
7690 --help print this help, then exit
7691 --version print version number, then exit
7692 -v, --verbose verbosely list files processed
7693 -o, --output-dir=DIR put generated Makefile.in's into DIR
7694 --no-force only update Makefile.in's that are out of date
7696 Dependency tracking:
7697 -i, --ignore-deps disable dependency tracking code
7698 --include-deps enable dependency tracking code
7701 --cygnus assume program is part of Cygnus-style tree
7702 --foreign set strictness to foreign
7703 --gnits set strictness to gnits
7704 --gnu set strictness to gnu
7707 -a, --add-missing add missing standard files to package
7708 --libdir=DIR directory storing library files
7709 -c, --copy with -a, copy missing files (default is symlink)
7710 -f, --force-missing force update of standard files
7715 foreach my $iter (sort ((@common_files, @common_sometimes)))
7717 push (@lcomm, $iter) unless $iter eq $last;
7721 my ($one, $two, $three, $four, $max);
7722 print "\nFiles which are automatically distributed, if found:\n";
7723 format USAGE_FORMAT =
7724 @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<
7725 $one, $two, $three, $four
7727 $~ = "USAGE_FORMAT";
7728 $max = int (($#lcomm + 1) / 4);
7730 for (my $i = 0; $i < $max; ++$i)
7733 $two = $lcomm[$max + $i];
7734 $three = $lcomm[2 * $max + $i];
7735 $four = $lcomm[3 * $max + $i];
7739 my $mod = ($#lcomm + 1) % 4;
7742 $one = $lcomm[$max];
7743 $two = ($mod > 1) ? $lcomm[2 * $max] : '';
7744 $three = ($mod > 2) ? $lcomm[3 * $max] : '';
7745 $four = ($mod > 3) ? $lcomm[4 * $max] : '';
7749 print "\nReport bugs to <bug-automake\@gnu.org>.\n";
7756 # Print version information
7760 automake (GNU $PACKAGE) $VERSION
7761 Written by Tom Tromey <tromey\@cygnus.com>.
7763 Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
7764 Free Software Foundation, Inc.
7765 This is free software; see the source for copying conditions. There is NO
7766 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.