5 eval 'exec @PERL@ -S $0 ${1+"$@"}'
8 # automake - create Makefile.in from Makefile.am
9 # Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
10 # Free Software Foundation, Inc.
12 # This program is free software; you can redistribute it and/or modify
13 # it under the terms of the GNU General Public License as published by
14 # the Free Software Foundation; either version 2, or (at your option)
17 # This program is distributed in the hope that it will be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # GNU General Public License for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, write to the Free Software
24 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
27 # Originally written by David Mackenzie <djm@gnu.ai.mit.edu>.
28 # Perl reimplementation by Tom Tromey <tromey@cygnus.com>.
34 my $prefix = "@prefix@";
35 my $perllibdir = $ENV{'perllibdir'} || "@datadir@/@PACKAGE@";
36 unshift @INC, "$perllibdir";
40 struct (# Short name of the language (c, f77...).
42 # Nice name of the language (C, Fortran 77...).
45 # List of configure variables which must be defined.
49 # `pure' is `1' or `'. A `pure' language is one where, if
50 # all the files in a directory are of that language, then we
51 # do not require the C compiler or any code to call it.
56 # Name of the compiling variable (COMPILE).
58 # Content of the compiling variable.
60 # Flag to require compilation without linking (-c).
61 'compile_flag' => '$',
62 'derived_autodep' => '$',
66 # Name of the linking variable (LINK).
68 # Content of the linking variable.
71 # Name of the linker variable (LD).
73 # Content of the linker variable ($(CC)).
76 # Flag to specify the output file (-o).
84 if (defined $self->_finish)
94 use strict 'vars', 'subs';
98 my $me = basename ($0);
105 # Parameters set by configure. Not to be changed. NOTE: assign
106 # VERSION as string so that eg version 0.30 will print correctly.
107 my $VERSION = "@VERSION@";
108 my $PACKAGE = "@PACKAGE@";
109 my $prefix = "@prefix@";
110 my $libdir = "@datadir@/@PACKAGE@";
113 my $IGNORE_PATTERN = '^\s*##([^#\n].*)?\n';
114 my $WHITE_PATTERN = '^\s*$';
115 my $COMMENT_PATTERN = '^#';
116 my $TARGET_PATTERN='[$a-zA-Z_.][-.a-zA-Z0-9_(){}/$]*';
117 # A rule has three parts: a list of targets, a list of dependencies,
118 # and optionally actions.
120 "^($TARGET_PATTERN(?:(?:\\\\\n|\\s)+$TARGET_PATTERN)*) *:([^=].*|)\$";
122 my $SUFFIX_RULE_PATTERN = '^\.([a-zA-Z0-9]+)\.([a-zA-Z0-9]+)$';
123 # Only recognize leading spaces, not leading tabs. If we recognize
124 # leading tabs here then we need to make the reader smarter, because
125 # otherwise it will think rules like `foo=bar; \' are errors.
126 my $MACRO_PATTERN = '^[A-Za-z0-9_@]+$';
127 my $ASSIGNMENT_PATTERN = '^ *([^ \t=]*)\s*([:+]?)=\s*(.*)$';
128 # This pattern recognizes a Gnits version id and sets $1 if the
129 # release is an alpha release. We also allow a suffix which can be
130 # used to extend the version number with a "fork" identifier.
131 my $GNITS_VERSION_PATTERN = '\d+\.\d+([a-z]|\.\d+)?(-[A-Za-z0-9]+)?';
132 my $IF_PATTERN = '^if\s+(!?)\s*([A-Za-z][A-Za-z0-9_]*)\s*(?:#.*)?$';
133 my $ELSE_PATTERN = '^else(?:\s+(!?)\s*([A-Za-z][A-Za-z0-9_]*))?\s*(?:#.*)?$';
134 my $ENDIF_PATTERN = '^endif(?:\s+(!?)\s*([A-Za-z][A-Za-z0-9_]*))?\s*(?:#.*)?$';
135 my $PATH_PATTERN='(\w|[/.-])+';
136 # This will pass through anything not of the prescribed form.
137 my $INCLUDE_PATTERN = ('^include\s+'
138 . '((\$\(top_srcdir\)/' . $PATH_PATTERN . ')'
139 . '|(\$\(srcdir\)/' . $PATH_PATTERN . ')'
140 . '|([^/\$]' . $PATH_PATTERN. '))\s*(#.*)?$');
142 # Some regular expressions. One reason to put them here is that it
143 # makes indentation work better in Emacs.
144 my $AC_CONFIG_AUX_DIR_PATTERN = 'AC_CONFIG_AUX_DIR\(([^)]+)\)';
145 my $AM_INIT_AUTOMAKE_PATTERN = 'AM_INIT_AUTOMAKE\([^,]*,([^,)]+)[,)]';
146 my $AM_PACKAGE_VERSION_PATTERN = '^\s*\[?([^]\s]+)\]?\s*$';
147 # Note that there is no AC_PATH_TOOL. But we don't really care.
148 my $AC_CHECK_PATTERN = 'AC_(CHECK|PATH)_(PROG|PROGS|TOOL)\(\[?(\w+)';
149 my $AM_MISSING_PATTERN = 'AM_MISSING_PROG\(\[?(\w+)';
150 # Just check for alphanumeric in AC_SUBST. If you do AC_SUBST(5),
152 my $AC_SUBST_PATTERN = 'AC_SUBST\(\[?(\w+)';
153 my $AM_CONDITIONAL_PATTERN = 'AM_CONDITIONAL\(\[?(\w+)';
155 # Constants to define the "strictness" level.
160 # Values for AC_CANONICAL_*
161 my $AC_CANONICAL_HOST = 1;
162 my $AC_CANONICAL_SYSTEM = 2;
164 # Values indicating when something should be cleaned. Right now we
165 # only need to handle `mostly'- and `dist'-clean; add more as
167 my $MOSTLY_CLEAN = 0;
170 # Files installed by libtoolize.
171 my @libtoolize_files = ('ltmain.sh', 'config.guess', 'config.sub');
172 # ltconfig appears here for compatibility with old versions of libtool.
173 my @libtoolize_sometimes = ('ltconfig', 'ltcf-c.sh', 'ltcf-cxx.sh',
176 # Commonly found files we look for and automatically include in
180 'README', 'THANKS', 'TODO', 'NEWS', 'COPYING', 'COPYING.LIB',
181 'INSTALL', 'ABOUT-NLS', 'ChangeLog', 'configure.ac',
182 'configure.in', 'configure', 'config.guess', 'config.sub',
183 'AUTHORS', 'BACKLOG', 'ABOUT-GNU', 'libversion.in',
184 'mdate-sh', 'mkinstalldirs', 'install-sh', 'texinfo.tex',
185 'ansi2knr.c', 'ansi2knr.1', 'elisp-comp',
186 # ltconfig appears here for compatibility with old versions
188 'ylwrap', 'acinclude.m4', @libtoolize_files, @libtoolize_sometimes,
189 'missing', 'depcomp', 'compile', 'py-compile'
192 # Commonly used files we auto-include, but only sometimes.
193 my @common_sometimes =
195 'aclocal.m4', 'acconfig.h', 'config.h.top',
196 'config.h.bot', 'stamp-h.in', 'stamp-vti'
199 # Copyright on generated Makefile.ins.
200 my $gen_copyright = "\
201 # Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
202 # Free Software Foundation, Inc.
203 # This Makefile.in is free software; the Free Software Foundation
204 # gives unlimited permission to copy and/or distribute it,
205 # with or without modifications, as long as this notice is preserved.
207 # This program is distributed in the hope that it will be useful,
208 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
209 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
210 # PARTICULAR PURPOSE.
213 # These constants are returned by lang_*_rewrite functions.
214 # LANG_SUBDIR means that the resulting object file should be in a
215 # subdir if the source file is. In this case the file name cannot
216 # have `..' components.
218 my $LANG_PROCESS = 1;
221 # Directories installed during 'install-exec' phase.
240 # Map from obsolete macros to hints for new macros.
241 # If you change this, change the corresponding list in aclocal.in.
242 # FIXME: should just put this into a single file.
243 my %obsolete_macros =
245 'AC_FEATURE_CTYPE' => "use `AC_HEADER_STDC'",
246 'AC_FEATURE_ERRNO' => "add `strerror' to `AC_REPLACE_FUNCS(...)'",
247 'AC_FEATURE_EXIT' => '',
248 'AC_SYSTEM_HEADER' => '',
250 # Note that we do not handle this one, because it is still run
251 # from AM_CONFIG_HEADER. So we deal with it specially in
252 # &scan_autoconf_files.
253 # 'AC_CONFIG_HEADER' => "use `AM_CONFIG_HEADER'",
255 'fp_C_PROTOTYPES' => "use `AM_C_PROTOTYPES'",
256 'fp_PROG_CC_STDC' => "use `AM_PROG_CC_STDC'",
257 'fp_PROG_INSTALL' => "use `AC_PROG_INSTALL'",
258 'fp_WITH_DMALLOC' => "use `AM_WITH_DMALLOC'",
259 'fp_WITH_REGEX' => "use `AM_WITH_REGEX'",
260 'gm_PROG_LIBTOOL' => "use `AM_PROG_LIBTOOL'",
261 'jm_MAINTAINER_MODE' => "use `AM_MAINTAINER_MODE'",
262 'md_TYPE_PTRDIFF_T' => "use `AM_TYPE_PTRDIFF_T'",
263 'ud_PATH_LISPDIR' => "use `AM_PATH_LISPDIR'",
264 'ud_GNU_GETTEXT' => "use `AM_GNU_GETTEXT'",
266 # Now part of autoconf proper, under a different name.
267 'AM_FUNC_FNMATCH' => "use `AC_FUNC_FNMATCH'",
268 'fp_FUNC_FNMATCH' => "use `AC_FUNC_FNMATCH'",
269 'AM_SANITY_CHECK_CC' => "automatically done by `AC_PROG_CC'",
270 'AM_PROG_INSTALL' => "use `AC_PROG_INSTALL'",
271 'AM_EXEEXT' => "use `AC_EXEEXT'",
272 'AM_CYGWIN32' => "use `AC_CYGWIN'",
273 'AM_MINGW32' => "use `AC_MINGW32'",
274 'AM_FUNC_MKTIME' => "use `AC_FUNC_MKTIME'",
276 # These aren't quite obsolete.
280 # Regexp to match the above macros.
281 my $obsolete_rx = '(\b' . join ('\b|\b', keys %obsolete_macros) . '\b)';
285 ## ---------------------------------- ##
286 ## Variables related to the options. ##
287 ## ---------------------------------- ##
289 # TRUE if we should always generate Makefile.in.
290 my $force_generation = 1;
292 # Strictness level as set on command line.
293 my $default_strictness = $GNU;
295 # Name of strictness level, as set on command line.
296 my $default_strictness_name = 'gnu';
298 # This is TRUE if automatic dependency generation code should be
299 # included in generated Makefile.in.
300 my $cmdline_use_dependencies = 1;
302 # TRUE if in verbose mode.
305 # This holds our (eventual) exit status. We don't actually exit until
306 # we have processed all input files.
309 # From the Perl manual.
310 my $symlink_exists = (eval 'symlink ("", "");', $@ eq '');
312 # TRUE if missing standard files should be installed.
315 # TRUE if we should copy missing files; otherwise symlink if possible.
316 my $copy_missing = 0;
318 # TRUE if we should always update files that we know about.
319 my $force_missing = 0;
322 ## ---------------------------------------- ##
323 ## Variables filled during files scanning. ##
324 ## ---------------------------------------- ##
326 # Name of the top autoconf input: `configure.ac' or `configure.in'.
327 my $configure_ac = '';
329 # Files found by scanning configure.ac for LIBOBJS.
332 # True if AM_C_PROTOTYPES appears in configure.ac.
333 my $am_c_prototypes = 0;
335 # Names used in AC_CONFIG_HEADER call. @config_fullnames holds the
336 # name which appears in AC_CONFIG_HEADER, colon and all.
337 # @config_names holds the file names. @config_headers holds the '.in'
338 # files. Ordinarily these are similar, but they can be different if
339 # the weird "NAME:FILE" syntax is used.
340 my @config_fullnames = ();
341 my @config_names = ();
342 my @config_headers = ();
343 # Line number at which AC_CONFIG_HEADER appears in configure.ac.
344 my $config_header_line = 0;
346 # Directory where output files go. Actually, output files are
347 # relative to this directory.
348 my $output_directory = '.';
350 # List of Makefile.am's to process, and their corresponding outputs.
351 my @input_files = ();
352 my %output_files = ();
354 # Complete list of Makefile.am's that exist.
355 my @configure_input_files = ();
357 # List of files in AC_OUTPUT without Makefile.am, and their outputs.
358 my @other_input_files = ();
359 # Line number at which AC_OUTPUT seen.
360 my $ac_output_line = 0;
362 # List of directories to search for configure-required files. This
363 # can be set by AC_CONFIG_AUX_DIR.
364 my @config_aux_path = ('.', '..', '../..');
365 my $config_aux_dir = '';
366 my $config_aux_dir_set_in_configure_in = 0;
368 # Whether AM_GNU_GETTEXT has been seen in configure.ac.
369 my $seen_gettext = 0;
370 # Line number at which AM_GNU_GETTEXT seen.
371 my $ac_gettext_line = 0;
373 # Whether ALL_LINGUAS has been seen.
374 my $seen_linguas = '';
376 my $all_linguas = '';
377 # Line number at which it appears.
378 my $all_linguas_line = 0;
380 # TRUE if AC_DECL_YYTEXT was seen.
381 my $seen_decl_yytext = 0;
383 # TRUE if we've seen AC_CANONICAL_(HOST|SYSTEM). The presence of
384 # AC_CHECK_TOOL also sets this.
385 my $seen_canonical = 0;
387 # TRUE if we've seen AC_PROG_LIBTOOL.
388 my $seen_libtool = 0;
389 my $libtool_line = 0;
391 # TRUE if we've seen AM_MAINTAINER_MODE.
392 my $seen_maint_mode = 0;
394 # Actual version we've seen.
395 my $package_version = '';
397 # Line number where we saw version definition.
398 my $package_version_line = 0;
400 # TRUE if we've seen AM_PATH_LISPDIR.
401 my $seen_lispdir = 0;
403 # TRUE if we've seen AM_PATH_PYTHON.
404 my $seen_pythondir = 0;
406 # TRUE if we've seen AC_EXEEXT.
409 # TRUE if we've seen AC_OBJEXT.
412 # TRUE if we've seen AC_ENABLE_MULTILIB.
413 my $seen_multilib = 0;
415 # TRUE if we've seen AM_PROG_CC_C_O
418 # TRUE if we've seen AM_INIT_AUTOMAKE.
419 my $seen_init_automake = 0;
421 # Hash table of discovered configure substitutions. Keys are names,
422 # values are `FILE:LINE' strings which are used by error message
424 my %configure_vars = ();
426 # This is used to keep track of which variable definitions we are
427 # scanning. It is only used in certain limited ways, but it has to be
428 # global. It is declared just for documentation purposes.
429 my %vars_scanned = ();
431 # Charsets used by maintainer and in distribution. MAINT_CHARSET is
432 # handled in a funny way: if seen in the top-level Makefile.am, it is
433 # used for every directory which does not specify a different value.
434 # The rationale here is that some directories (eg gettext) might be
435 # distributions of other packages, and thus require their own charset
436 # info. However, the DIST_CHARSET must be the same for the entire
437 # package; it can only be set at top-level.
438 # FIXME: this yields bugs when rebuilding. What to do? Always
439 # read (and sometimes discard) top-level Makefile.am?
440 my $maint_charset = '';
441 my $dist_charset = 'utf8'; # recode doesn't support this yet.
443 # TRUE if --cygnus seen.
446 # Hash table of AM_CONDITIONAL variables seen in configure.
447 my %configure_cond = ();
449 # This maps extensions onto language names.
450 my %extension_map = ();
452 # List of the DIST_COMMON files we discovered while reading
454 my $configure_dist_common = '';
456 # This maps languages names onto objects.
459 # List of targets we must always output.
460 # FIXME: Complete, and remove falsely required targets.
461 my %required_targets =
472 # FIXME: Not required, temporary hacks.
473 # Well, actually they are sort of required: the -recursive
474 # targets will run them anyway...
477 'install-data-am' => 1,
478 'install-exec-am' => 1,
479 'installcheck-am' => 1,
487 ################################################################
489 ## ------------------------------------------ ##
490 ## Variables reset by &initialize_per_input. ##
491 ## ------------------------------------------ ##
493 # Basename and relative dir of the input file.
497 # Same but wrt Makefile.in.
501 # These two variables are used when generating each Makefile.in.
502 # They hold the Makefile.in until it is ready to be printed.
509 # Suffixes found during a run.
512 # Handling the variables.
515 # - $var_value{$VAR}{$COND} is its value associated to $COND,
516 # - $var_line{$VAR} is where it has been defined,
517 # - $var_comment{$VAR} are the comments associated to it.
518 # - $var_type{$VAR} is how it has been defined (`', `+', or `:'),
519 # - $var_is_am{$VAR} is true if the variable is owned by Automake.
526 # This holds a 1 if a particular variable was examined.
529 # This holds the names which are targets. These also appear in
533 # Same as %VAR_VALUE, but for targets.
534 my %target_conditional;
536 # This is the conditional stack.
539 # This holds the set of included files.
542 # This holds a list of directories which we must create at `dist'
543 # time. This is used in some strange scenarios involving weird
544 # AC_OUTPUT commands.
547 # List of dependencies for the obvious targets.
552 # Holds the dependencies of targets which dependencies are factored.
553 # Typically, `.PHONY' will appear in plenty of *.am files, but must
554 # be output once. Arguably all pure dependencies could be subject
555 # to this factorization, but it is not unpleasant to have paragraphs
556 # in Makefile: keeping related stuff altogether.
559 # Holds the factored actions. Tied to %DEPENDENCIES, i.e., filled
560 # only when keys exists in %DEPENDENCIES.
563 # A list of files deleted by `maintainer-clean'.
564 my @maintainer_clean_files;
566 # Keys in this hash table are object files or other files in
567 # subdirectories which need to be removed. This only holds files
568 # which are created by compilations. The value in the hash indicates
569 # when the file should be removed.
570 my %compile_clean_files;
572 # Value of `$(SOURCES)', used by tags.am.
574 # Sources which go in the distribution.
577 # This hash maps object file names onto their corresponding source
578 # file names. This is used to ensure that each object is created
579 # by a single source file.
582 # This keeps track of the directories for which we've already
583 # created `.dirstamp' code.
593 # Options from AUTOMAKE_OPTIONS.
596 # Whether or not dependencies are handled. Can be further changed
598 my $use_dependencies;
601 my $local_maint_charset;
603 # All yacc and lex source filenames for this directory. Use
604 # filenames instead of raw count so that multiple instances are
605 # counted correctly (eg one yacc file can appear in multiple
606 # programs without harm).
610 # This is a list of all targets to run during "make dist".
613 # Keys in this hash are the basenames of files which must depend
617 # This maps the source extension of a suffix rule to its
618 # corresponding output extension.
621 # This is the name of the redirect `all' target to use.
624 # This keeps track of which extensions we've seen (that we care
628 # This is random scratch space for the language finish functions.
629 # Don't randomly overwrite it; examine other uses of keys first.
630 my %language_scratch;
632 # We keep track of which objects need special (per-executable)
633 # handling on a per-language basis.
634 my %lang_specific_files;
636 # This is set when `handle_dist' has finished. Once this happens,
637 # we should no longer push on dist_common.
640 # True if we need `LINK' defined. This is a hack.
643 # This is the list of such variables to output.
644 # FIXME: Might be useless actually.
647 # Was get_object_extension run?
648 # FIXME: This is a hack. a better switch should be found.
649 my $get_object_extension_was_run;
652 ## --------------------------------- ##
653 ## Forward subroutine declarations. ##
654 ## --------------------------------- ##
655 sub register_language (%);
656 sub file_contents_internal ($$%);
659 # &initialize_per_input ()
660 # ------------------------
661 # (Re)-Initialize per-Makefile.am variables.
662 sub initialize_per_input ()
665 $am_relative_dir = '';
672 $output_trailer = '';
688 %target_conditional = ();
696 $am_relative_dir = '';
712 # Installing/uninstalling.
713 'install-data-am' => [],
714 'install-exec-am' => [],
715 'uninstall-am' => [],
718 'uninstall-man' => [],
720 'install-info' => [],
721 'install-info-am' => [],
722 'uninstall-info' => [],
724 'installcheck-am' => [],
728 'mostlyclean-am' => [],
729 'maintainer-clean-am' => [],
730 'distclean-am' => [],
733 'maintainer-clean' => [],
744 @maintainer_clean_files = ();
755 $strictness = $default_strictness;
756 $strictness_name = $default_strictness_name;
760 $use_dependencies = $cmdline_use_dependencies;
762 $local_maint_charset = $maint_charset;
775 %extension_seen = ();
777 %language_scratch = ();
779 %lang_specific_files = ();
781 $handle_dist_run = 0;
787 $get_object_extension_was_run = 0;
789 %compile_clean_files = ();
793 ################################################################
795 # Initialize our list of languages that are internally supported.
798 register_language ('name' => 'c',
800 'config_vars' => ['CC'],
804 'compiler' => 'COMPILE',
805 'compile' => '$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)',
809 'link' => '$(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
810 'compile_flag' => '-c',
811 'extensions' => ['c'],
812 '_finish' => \&lang_c_finish);
815 register_language ('name' => 'cxx',
817 'config_vars' => ['CXX'],
818 'linker' => 'CXXLINK',
819 'link' => '$(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
821 'flags' => 'CXXFLAGS',
822 'compile' => '$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)',
823 'compiler' => 'CXXCOMPILE',
824 'compile_flag' => '-c',
825 'output_flag' => '-o',
829 'extensions' => ['c++', 'cc', 'cpp', 'cxx', 'C']);
832 register_language ('name' => 'objc',
833 'Name' => 'Objective C',
834 'config_vars' => ['OBJC'],
835 'linker' => 'OBJCLINK',,
836 'link' => '$(OBJCLD) $(AM_OBJCFLAGS) $(OBJCFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
838 'flags' => 'OBJCFLAGS',
839 'compile' => '$(OBJC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_OBJCFLAGS) $(OBJCFLAGS)',
840 'compiler' => 'OBJCCOMPILE',
841 'compile_flag' => '-c',
842 'output_flag' => '-o',
846 'extensions' => ['m']);
849 register_language ('name' => 'header',
851 'extensions' => ['h', 'H', 'hxx', 'h++', 'hh', 'hpp', 'inc'],
853 '_finish' => sub { });
855 # For now, yacc and lex can't be handled on a per-exe basis.
858 register_language ('name' => 'yacc',
861 'config_vars' => ['YACC'],
862 'derived_autodep' => 'yes',
863 'extensions' => ['y'],
864 '_finish' => \&lang_yacc_finish);
865 register_language ('name' => 'yaccxx',
866 'Name' => 'Yacc (C++)',
867 'config_vars' => ['YACC'],
868 'linker' => 'CXXLINK',
869 'derived_autodep' => 'yes',
870 'extensions' => ['y++', 'yy', 'yxx', 'ypp'],
871 '_finish' => \&lang_yacc_finish);
874 register_language ('name' => 'lex',
877 'config_vars' => ['LEX'],
878 'derived_autodep' => 'yes',
879 'extensions' => ['l'],
880 '_finish' => \&lang_lex_finish);
881 register_language ('name' => 'lexxx',
882 'Name' => 'Lex (C++)',
883 'config_vars' => ['LEX'],
884 'linker' => 'CXXLINK',
885 'derived_autodep' => 'yes',
886 'extensions' => ['l++', 'll', 'lxx', 'lpp'],
887 '_finish' => \&lang_lex_finish);
890 register_language ('name' => 'asm',
891 'Name' => 'Assembler',
892 'config_vars' => ['AS', 'ASFLAGS'],
894 'flags' => 'ASFLAGS',
895 # Users can set AM_ASFLAGS to includes DEFS, INCLUDES,
896 # or anything else required. They can also set AS.
897 'compile' => '$(AS) $(AM_ASFLAGS) $(ASFLAGS)',
898 'compiler' => 'ASCOMPILE',
899 'compile_flag' => '-c',
900 'extensions' => ['s', 'S'],
902 # With assembly we still use the C linker.
903 '_finish' => \&lang_c_finish);
906 register_language ('name' => 'f77',
907 'Name' => 'Fortran 77',
908 'linker' => 'F77LINK',
909 'link' => '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
911 'compile' => '$(F77) $(AM_FFLAGS) $(FFLAGS)',
912 'compiler' => 'F77COMPILE',
913 'compile_flag' => '-c',
914 'output_flag' => '-o',
918 'extensions' => ['f', 'for', 'f90']);
920 # Preprocessed Fortran 77
922 # The current support for preprocessing Fortran 77 just involves
923 # passing `$(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS)
924 # $(CPPFLAGS)' as additional flags to the Fortran 77 compiler, since
925 # this is how GNU Make does it; see the `GNU Make Manual, Edition 0.51
926 # for `make' Version 3.76 Beta' (specifically, from info file
927 # `(make)Catalogue of Rules').
929 # A better approach would be to write an Autoconf test
930 # (i.e. AC_PROG_FPP) for a Fortran 77 preprocessor, because not all
931 # Fortran 77 compilers know how to do preprocessing. The Autoconf
932 # macro AC_PROG_FPP should test the Fortran 77 compiler first for
933 # preprocessing capabilities, and then fall back on cpp (if cpp were
935 register_language ('name' => 'ppf77',
936 'Name' => 'Preprocessed Fortran 77',
937 'config_vars' => ['F77'],
938 'linker' => 'F77LINK',
939 'link' => '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
943 'compiler' => 'PPF77COMPILE',
944 'compile' => '$(F77) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FFLAGS) $(FFLAGS)',
945 'compile_flag' => '-c',
946 'output_flag' => '-o',
948 'extensions' => ['F']);
951 register_language ('name' => 'ratfor',
953 'config_vars' => ['F77'],
954 'linker' => 'F77LINK',
955 'link' => '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
960 'compile' => '$(F77) $(AM_FFLAGS) $(FFLAGS) $(AM_RFLAGS) $(RFLAGS)',
961 'compiler' => 'RCOMPILE',
962 'compile_flag' => '-c',
963 'output_flag' => '-o',
965 'extensions' => ['r']);
968 register_language ('name' => 'java',
970 'config_vars' => ['GCJ'],
971 'linker' => 'GCJLINK',
972 'link' => '$(GCJLD) $(AM_GCJFLAGS) $(GCJFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
974 'flags' => 'GCJFLAGS',
975 'compile' => '$(GCJ) $(AM_GCJFLAGS) $(GCJFLAGS)',
976 'compiler' => 'GCJCOMPILE',
977 'compile_flag' => '-c',
978 'output_flag' => '-o',
982 'extensions' => ['java', 'class', 'zip', 'jar']);
984 ################################################################
986 # Parse command line.
989 # Do configure.ac scan only once.
990 &scan_autoconf_files;
992 die "$me: no `Makefile.am' found or specified\n"
995 # Now do all the work on each file.
996 # This guy must be local otherwise it's private to the loop.
999 foreach $am_file (@input_files)
1001 if (! -f ($am_file . '.am'))
1003 &am_error ("`" . $am_file . ".am' does not exist");
1007 &generate_makefile ($output_files{$am_file}, $am_file);
1013 # FIXME: This should be `my'ed next to its subs.
1014 use vars '%require_file_found';
1016 ################################################################
1018 # prog_error (@PRINT-ME)
1019 # ----------------------
1020 # Signal a programming error, display PRINT-ME, and exit 1.
1023 print STDERR "$me: programming error: @_\n";
1031 # Return LIST with no duplicates.
1036 foreach my $item (@_)
1038 if (! defined $seen{$item})
1049 # Return a configure-style substitution using the indicated text.
1050 # We do this to avoid having the substitutions directly in automake.in;
1051 # when we do that they are sometimes removed and this causes confusion
1056 return '@' . $text . '@';
1059 ################################################################
1063 # &backname ($REL-DIR)
1064 # --------------------
1065 # If I `cd $REL-DIR', then to come back, I should `cd $BACKPATH'.
1066 # For instance `src/foo' => `../..'.
1067 # Works with non strictly increasing paths, i.e., `src/../lib' => `..'.
1072 foreach (split (/\//, $file))
1074 next if $_ eq '.' || $_ eq '';
1084 return join ('/', @res) || '.';
1087 ################################################################
1089 # Parse command line.
1090 sub parse_arguments ()
1093 &set_strictness ('gnu');
1096 Getopt::Long::config ("bundling");
1097 Getopt::Long::GetOptions
1099 'version' => \&version,
1101 'libdir:s' => \$libdir,
1102 'gnu' => sub { &set_strictness ('gnu'); },
1103 'gnits' => sub { &set_strictness ('gnits'); },
1104 'cygnus' => \$cygnus_mode,
1105 'foreign' => sub { &set_strictness ('foreign'); },
1106 'include-deps' => sub { $cmdline_use_dependencies = 1; },
1107 'i|ignore-deps' => sub { $cmdline_use_dependencies = 0; },
1108 'no-force' => sub { $force_generation = 0; },
1109 'f|force-missing'=> \$force_missing,
1110 'o|output-dir:s' => \$output_directory,
1111 'a|add-missing' => \$add_missing,
1112 'c|copy' => \$copy_missing,
1113 'v|verbose' => \$verbose,
1114 'Werror' => sub { $SIG{"__WARN__"} = sub { die $_[0] } },
1115 'Wno-error' => sub { $SIG{"__WARN__"} = 'DEFAULT' }
1119 foreach my $arg (@ARGV)
1121 # Handle $local:$input syntax. Note that we only examine the
1122 # first ":" file to see if it is automake input; the rest are
1123 # just taken verbatim. We still keep all the files around for
1124 # dependency checking, however.
1125 my ($local, $input, @rest) = split (/:/, $arg);
1132 # Strip .in; later on .am is tacked on. That is how the
1133 # automake input file is found. Maybe not the best way, but
1134 # it is easy to explain.
1136 or die "$me: invalid input file name `$arg'\n.";
1138 push (@input_files, $input);
1139 $output_files{$input} = join (':', ($local, @rest));
1142 # Take global strictness from whatever we currently have set.
1143 $default_strictness = $strictness;
1144 $default_strictness_name = $strictness_name;
1147 ################################################################
1149 # Generate a Makefile.in given the name of the corresponding Makefile and
1150 # the name of the file output by config.status.
1151 sub generate_makefile
1153 my ($output, $makefile) = @_;
1155 # Reset all the Makefile.am related variables.
1156 &initialize_per_input;
1158 # Name of input file ("Makefile.am") and output file
1159 # ("Makefile.in"). These have no directory components.
1160 $am_file_name = basename ($makefile) . '.am';
1161 $in_file_name = basename ($makefile) . '.in';
1163 # $OUTPUT is encoded. If it contains a ":" then the first element
1164 # is the real output file, and all remaining elements are input
1165 # files. We don't scan or otherwise deal with these input file,
1166 # other than to mark them as dependencies. See
1167 # &scan_autoconf_files for details.
1168 my (@secondary_inputs);
1169 ($output, @secondary_inputs) = split (/:/, $output);
1171 $relative_dir = dirname ($output);
1172 $am_relative_dir = dirname ($makefile);
1174 &read_main_am_file ($makefile . '.am');
1175 if (&handle_options)
1177 # Fatal error. Just return, so we can continue with next file.
1181 # There are a few install-related variables that you should not define.
1182 foreach my $var ('PRE_INSTALL', 'POST_INSTALL', 'NORMAL_INSTALL')
1184 if (&variable_defined ($var) && !$var_is_am{$var})
1186 &am_line_error ($var, "`$var' should not be defined");
1190 # At the toplevel directory, we might need config.guess, config.sub
1191 # or libtool scripts (ltconfig and ltmain.sh).
1192 if ($relative_dir eq '.')
1194 # libtool requires some files.
1195 &require_conf_file_with_conf_line ($libtool_line, $FOREIGN,
1199 # AC_CANONICAL_HOST and AC_CANONICAL_SYSTEM need config.guess and
1201 &require_config_file ($FOREIGN, 'config.guess', 'config.sub')
1205 # We still need Makefile.in here, because sometimes the `dist'
1206 # target doesn't re-run automake.
1207 if ($am_relative_dir eq $relative_dir)
1209 # Only distribute the files if they are in the same subdir as
1210 # the generated makefile.
1211 &push_dist_common ($in_file_name, $am_file_name);
1214 push (@sources, '$(SOURCES)')
1215 if &variable_defined ('SOURCES');
1217 # If OBJEXT/EXEEXT were not set in configure.in, do it, it
1218 # simplifies our task, and anyway starting with Autoconf 2.50, it
1219 # will always be defined, and this code will be dead.
1220 $output_vars .= "EXEEXT =\n"
1221 unless $seen_exeext;
1222 $output_vars .= "OBJEXT = o\n"
1223 unless $seen_objext;
1225 # Must do this after reading .am file. See read_main_am_file to
1226 # understand weird tricks we play there with variables.
1227 &define_variable ('subdir', $relative_dir);
1229 # Check first, because we might modify some state.
1231 &check_gnu_standards;
1232 &check_gnits_standards;
1234 &handle_configure ($output, $makefile, @secondary_inputs);
1237 &handle_ltlibraries;
1241 # This must be run after all the sources are scanned.
1245 # Re-init SOURCES. FIXME: other code shouldn't depend on this
1246 # (but currently does).
1247 macro_define ('SOURCES', 1, '', 'TRUE',
1248 join (' ', @sources), 'internal');
1249 &define_pretty_variable ('DIST_SOURCES', '', @dist_sources);
1261 &handle_minor_options;
1264 # This must come after most other rules.
1265 &handle_dist ($makefile);
1268 &do_check_merge_target;
1269 &handle_all ($output);
1272 if (&variable_defined('lib_LTLIBRARIES') &&
1273 &variable_defined('bin_PROGRAMS'))
1275 $output_rules .= "install-binPROGRAMS: install-libLTLIBRARIES\n\n";
1278 &handle_installdirs;
1280 &handle_factored_dependencies;
1284 if (! -d ($output_directory . '/' . $am_relative_dir))
1286 mkdir ($output_directory . '/' . $am_relative_dir, 0755);
1289 my ($out_file) = $output_directory . '/' . $makefile . ".in";
1290 if (! $force_generation && -e $out_file)
1292 my ($am_time) = (stat ($makefile . '.am'))[9];
1293 my ($in_time) = (stat ($out_file))[9];
1294 # FIXME: should cache these times.
1295 my ($conf_time) = (stat ($configure_ac))[9];
1296 # FIXME: how to do unsigned comparison?
1297 if ($am_time < $in_time || $am_time < $conf_time)
1299 # No need to update.
1302 if (-f 'aclocal.m4')
1304 my ($acl_time) = (stat _)[9];
1305 return if ($am_time < $acl_time);
1309 my $gm_file = new IO::File "> $out_file";
1312 warn "$me: ${am_file}.in: cannot write: $!\n";
1316 print "$me: creating ", $makefile, ".in\n" if $verbose;
1318 # In case we're running under MSWindows, don't write with CRLF
1319 # (as it causes problems for the dependency-file extraction in
1320 # AM_OUTPUT_DEPENDENCY_COMMANDS).
1323 print $gm_file $output_vars;
1324 # We make sure that `all:' is the first target.
1325 print $gm_file $output_all;
1326 print $gm_file $output_header;
1327 print $gm_file $output_rules;
1328 print $gm_file $output_trailer;
1330 if (! $gm_file->close)
1332 warn "$me: $am_file.in: cannot close: $!\n";
1338 ################################################################
1340 # Handle AUTOMAKE_OPTIONS variable. Return 1 on error, 0 otherwise.
1343 if (&variable_defined ('AUTOMAKE_OPTIONS'))
1345 foreach (&variable_value_as_list ('AUTOMAKE_OPTIONS', ''))
1348 if ($_ eq 'gnits' || $_ eq 'gnu' || $_ eq 'foreign')
1350 &set_strictness ($_);
1352 elsif ($_ eq 'cygnus')
1358 # An option like "../lib/ansi2knr" is allowed. With
1359 # no path prefix, we assume the required programs are
1360 # in this directory. We save the actual option for
1362 $options{'ansi2knr'} = $_;
1364 elsif ($_ eq 'no-installman' || $_ eq 'no-installinfo'
1365 || $_ eq 'dist-shar' || $_ eq 'dist-zip'
1366 || $_ eq 'dist-tarZ' || $_ eq 'dist-bzip2'
1367 || $_ eq 'dejagnu' || $_ eq 'no-texinfo.tex'
1368 || $_ eq 'readme-alpha' || $_ eq 'check-news'
1369 || $_ eq 'subdir-objects' || $_ eq 'nostdinc')
1371 # Explicitly recognize these.
1373 elsif ($_ eq 'no-dependencies')
1375 $use_dependencies = 0;
1377 elsif (/(\d+)\.(\d+)([a-z]?)(-[A-Za-z0-9]+)?/)
1379 # Got a version number.
1381 my ($rmajor, $rminor, $ralpha, $rfork) = ($1, $2, $3, $4);
1383 &prog_error ("version is incorrect: $VERSION")
1384 if $VERSION !~ /(\d+)\.(\d+)([a-z]?)(-[A-Za-z0-9]+)?/;
1386 my ($tmajor, $tminor, $talpha, $tfork) = ($1, $2, $3, $4);
1391 # 2.0 is better than 1.0.
1392 # 1.2 is better than 1.1.
1393 # 1.2a is better than 1.2.
1394 # If we require 3.4n-foo then we require something
1395 # >= 3.4n, with the `foo' fork identifier.
1396 if ($rmajor > $tmajor
1397 || ($rmajor == $tmajor && $rminor > $tminor)
1398 || ($rminor == $tminor && $rminor == $tminor
1399 && $ralpha gt $talpha)
1400 || ($rfork ne '' && $rfork ne $tfork))
1402 &am_line_error ('AUTOMAKE_OPTIONS',
1403 "require version $_, but have $VERSION");
1409 &am_line_error ('AUTOMAKE_OPTIONS',
1410 "option `" . $_ . "\' not recognized");
1415 if ($strictness == $GNITS)
1417 $options{'readme-alpha'} = 1;
1418 $options{'check-news'} = 1;
1425 # get_object_extension ($OUT)
1426 # ---------------------------
1427 # Return object extension. Just once, put some code into the output.
1428 # OUT is the name of the output file
1429 sub get_object_extension
1433 # Maybe require libtool library object files.
1434 my $extension = '.$(OBJEXT)';
1435 $extension = '.lo' if ($out =~ /\.la$/);
1437 # Check for automatic de-ANSI-fication.
1438 $extension = '$U' . $extension
1439 if defined $options{'ansi2knr'};
1441 $get_object_extension_was_run = 1;
1447 # Call finish function for each language that was used.
1448 sub handle_languages
1450 if ($use_dependencies)
1452 # Include auto-dep code. Don't include it if DEP_FILES would
1454 if (&saw_sources_p (0) && keys %dep_files)
1456 # Set location of depcomp.
1457 &define_variable ('depcomp', "\$(SHELL) $config_aux_dir/depcomp");
1459 &require_config_file ($FOREIGN, 'depcomp');
1461 my @deplist = sort keys %dep_files;
1463 # We define this as a conditional variable because BSD
1464 # make can't handle backslashes for continuing comments on
1465 # the following line.
1466 &define_pretty_variable ('DEP_FILES', 'AMDEP_TRUE', @deplist);
1468 # Generate each `include' individually. Irix 6 make will
1469 # not properly include several files resulting from a
1470 # variable expansion; generating many separate includes
1472 $output_rules .= "\n";
1473 foreach my $iter (@deplist)
1475 $output_rules .= (subst ('AMDEP_TRUE')
1476 . subst ('_am_include')
1478 . subst ('_am_quote')
1480 . subst ('_am_quote')
1484 $output_rules .= &file_contents ('depend');
1489 &define_variable ('depcomp', '');
1494 # Is the c linker needed?
1496 foreach my $ext (sort keys %extension_seen)
1498 my $lang = $languages{$extension_map{$ext}};
1500 # Get information on $LANG.
1501 my $pfx = $lang->autodep;
1502 my $fpfx = ($pfx eq '') ? 'CC' : $pfx;
1504 my $AMDEP = (($use_dependencies && $lang->autodep ne 'no')
1505 ? 'AMDEP' : 'FALSE');
1507 my %transform = ('EXT' => $ext,
1510 'LIBTOOL' => $seen_libtool,
1512 '-c' => $lang->compile_flag || '');
1514 # Generate the appropriate rules for this extension.
1515 if ($use_dependencies && $lang->autodep ne 'no'
1516 || defined $lang->compile)
1518 # Some C compilers don't support -c -o. Use it only if really
1520 my $output_flag = $lang->output_flag || '';
1523 && $lang->flags eq 'CFLAGS'
1524 && defined $options{'subdir-objects'});
1527 file_contents ('depend2',
1537 'COMPILE' => '$(' . $lang->compiler . ')',
1538 'LTCOMPILE' => '$(LT' . $lang->compiler . ')',
1539 '-o' => $output_flag);
1542 # Now include code for each specially handled object with this
1544 my %seen_files = ();
1545 foreach my $file (@{$lang_specific_files{$lang->name}})
1547 my ($derived, $source, $obj) = split (' ', $file);
1549 # We might see a given object twice, for instance if it is
1550 # used under different conditions.
1551 next if defined $seen_files{$obj};
1552 $seen_files{$obj} = 1;
1554 my $flags = $lang->flags || '';
1555 my $val = "${derived}_${flags}";
1557 (my $obj_compile = $lang->compile) =~ s/\(AM_$flags/\($val/;
1558 my $obj_ltcompile = '$(LIBTOOL) --mode=compile ' . $obj_compile;
1560 # We _need_ `-o' for per object rules.
1561 my $output_flag = $lang->output_flag || '-o';
1563 # Generate a transform which will turn suffix targets in
1564 # depend2.am into real targets for the particular objects we
1567 file_contents ('depend2',
1572 'SOURCE' => $source,
1574 'OBJOBJ' => "$obj.obj",
1575 'LTOBJ' => "$obj.lo",
1577 'COMPILE' => $obj_compile,
1578 'LTCOMPILE' => $obj_ltcompile,
1579 '-o' => $output_flag));
1582 # The rest of the loop is done once per language.
1583 next if defined $done{$lang};
1586 # Load the language dependent Makefile chunks.
1587 my %lang = map { uc ($_) => 0 } keys %languages;
1588 $lang{uc ($lang->name)} = 1;
1589 $output_rules .= file_contents ('lang-compile', %transform, %lang);
1591 # If the source to a program consists entirely of code from a
1592 # `pure' language, for instance C++ for Fortran 77, then we
1593 # don't need the C compiler code. However if we run into
1594 # something unusual then we do generate the C code. There are
1595 # probably corner cases here that do not work properly.
1596 # People linking Java code to Fortran code deserve pain.
1597 $needs_c ||= ! $lang->pure;
1599 define_compiler_variable ($lang)
1600 if ($lang->compile);
1602 define_linker_variable ($lang)
1605 foreach my $var (@{$lang->config_vars})
1607 am_error ($lang->Name
1608 . " source seen but `$var' not defined in"
1609 . " `$configure_ac'")
1610 if !exists $configure_vars{$var};
1613 # The compiler's flag must be a configure variable.
1614 define_configure_variable ($lang->flags)
1615 if (defined $lang->flags);
1617 # Call the finisher.
1621 # If the project is entirely C++ or entirely Fortran 77 (i.e., 1
1622 # suffix rule was learned), don't bother with the C stuff. But if
1623 # anything else creeps in, then use it.
1625 if $need_link || scalar keys %suffix_rules > 1;
1629 if (! defined $done{$languages{'c'}})
1631 &define_configure_variable ($languages{'c'}->flags);
1632 &define_compiler_variable ($languages{'c'});
1634 define_linker_variable ($languages{'c'});
1638 # Output a rule to build from a YACC source. The output from YACC is
1639 # compiled with C or C++, depending on the extension of the YACC file.
1640 sub output_yacc_build_rule
1642 my ($yacc_suffix, $use_ylwrap) = @_;
1644 (my $c_suffix = $yacc_suffix) =~ tr/y/c/;
1646 # Generate rule for c/c++.
1647 $output_rules .= &file_contents ('yacc',
1648 ('YLWRAP' => $use_ylwrap,
1649 'YACC_SUFFIX' => $yacc_suffix,
1650 'C_SUFFIX' => $c_suffix));
1653 sub output_lex_build_rule
1655 my ($lex_suffix, $use_ylwrap) = @_;
1657 (my $c_suffix = $lex_suffix) =~ tr/l/c/;
1659 $output_rules .= &file_contents ('lex',
1660 ('YLWRAP' => $use_ylwrap,
1661 'LEX_SUFFIX' => $lex_suffix,
1662 'C_SUFFIX' => $c_suffix));
1665 # Check to make sure a source defined in LIBOBJS is not explicitly
1666 # mentioned. This is a separate function (as opposed to being inlined
1667 # in handle_source_transform) because it isn't always appropriate to
1669 sub check_libobjs_sources
1671 my ($one_file, $unxformed) = @_;
1673 foreach my $prefix ('', 'EXTRA_', 'dist_', 'nodist_',
1674 'dist_EXTRA_', 'nodist_EXTRA_')
1677 if (&variable_defined ($prefix . $one_file . '_SOURCES'))
1679 @files = &variable_value_as_list (($prefix
1680 . $one_file . '_SOURCES'),
1683 elsif ($prefix eq '')
1685 @files = ($unxformed . '.c');
1692 foreach my $file (@files)
1694 if (defined $libsources{$file})
1696 &am_line_error ($prefix . $one_file . '_SOURCES',
1697 "automatically discovered file `$file' should not be explicitly mentioned");
1704 # ($LINKER, @OBJECTS)
1705 # handle_single_transform_list ($VAR, $DERIVED, $OBJ, @FILES)
1706 # -----------------------------------------------------------
1707 # Does much of the actual work for handle_source_transform.
1709 # $DERIVED is the name of resulting executable or library
1710 # $OBJ is the object extension (e.g., `$U.lo')
1711 # @FILES is the list of source files to transform
1713 # $LINKER is name of linker to use (empty string for default linker)
1714 # @OBJECTS are names of objects
1715 sub handle_single_transform_list ($$$@)
1717 my ($var, $derived, $obj, @files) = @_;
1719 my $nonansi_obj = $obj;
1720 $nonansi_obj =~ s/\$U//g;
1721 my %linkers_used = ();
1723 # Turn sources into objects.
1726 # Configure substitutions in _SOURCES variables are errors.
1729 &am_line_error ($var, "$var includes configure substitution `$_'");
1733 # If the source file is in a subdirectory then the `.o' is
1734 # put into the current directory.
1736 # Split file name into base and extension.
1737 next if ! /^(?:(.*)\/)?([^\/]*)\.(.*)$/;
1739 my $directory = $1 || '';
1743 # We must generate a rule for the object if it requires its own flags.
1745 my ($linker, $object);
1747 $extension = &derive_suffix ($extension);
1748 my $lang = $languages{$extension_map{$extension}};
1751 &saw_extension ($extension);
1752 # Found the language, so see what it says.
1753 my $subr = 'lang_' . $lang->name . '_rewrite';
1754 # Note: computed subr call.
1755 my $r = & $subr ($directory, $base, $extension);
1756 # Skip this entry if we were asked not to process it.
1757 next if $r == $LANG_IGNORE;
1759 # Now extract linker and other info.
1760 $linker = $lang->linker;
1762 my $this_obj_ext = $lang->ansi ? $obj : $nonansi_obj;
1763 $object = $base . $this_obj_ext;
1765 if (defined $lang->flags
1766 && &variable_defined ($derived . '_' . $lang->flags))
1768 # We have a per-executable flag in effect for this
1769 # object. In this case we rewrite the object's
1770 # name to ensure it is unique. We also require
1771 # the `compile' program to deal with compilers
1772 # where `-c -o' does not work.
1774 # We choose the name `DERIVED_OBJECT' to ensure
1775 # (1) uniqueness, and (2) continuity between
1776 # invocations. However, this will result in a
1777 # name that is too long for losing systems, in
1778 # some situations. So we provide _SHORTNAME to
1781 my $dname = $derived;
1782 if (&variable_defined ($derived . '_SHORTNAME'))
1784 # FIXME: should use the same conditional as
1785 # the _SOURCES variable. But this is really
1786 # silly overkill -- nobody should have
1787 # conditional shortnames.
1788 $dname = &variable_value ($derived . '_SHORTNAME');
1790 $object = $dname . '-' . $object;
1792 &require_file ($FOREIGN, 'compile')
1793 if $lang->name eq 'c';
1795 &prog_error ("$lang->name flags defined without compiler")
1796 if ! defined $lang->compile;
1801 # If rewrite said it was ok, put the object into a
1803 if ($r == $LANG_SUBDIR && $directory ne '')
1805 $object = $directory . '/' . $object;
1808 # If doing dependency tracking, then we can't print
1809 # the rule. If we have a subdir object, we need to
1810 # generate an explicit rule. Actually, in any case
1811 # where the object is not in `.' we need a special
1812 # rule. The per-object rules in this case are
1813 # generated later, by handle_languages.
1814 if ($renamed || $directory ne '')
1816 my $obj_sans_ext = substr ($object, 0,
1817 - length ($this_obj_ext));
1818 push (@{$lang_specific_files{$lang->name}},
1819 "$derived $full $obj_sans_ext");
1822 elsif ($extension eq 'o')
1824 # This is probably the result of a direct suffix rule.
1825 # In this case we just accept the rewrite. FIXME:
1826 # this fails if we want libtool objects.
1827 $object = $base . '.' . $extension;
1832 # No error message here. Used to have one, but it was
1837 $linkers_used{$linker} = 1;
1839 push (@result, $object);
1841 if (defined $object_map{$object})
1843 if ($object_map{$object} ne $full)
1845 &am_error ("object `$object' created by `$full' and `$object_map{$object}'");
1851 $object_map{$object} = $full;
1853 # If file is in subdirectory, we need explicit
1855 if ($directory ne '' || $renamed)
1857 push (@dep_list, $full);
1860 # If resulting object is in subdir, we need to make
1861 # sure the subdir exists at build time.
1862 if ($object =~ /\//)
1864 # FIXME: check that $DIRECTORY is somewhere in the
1867 # We don't allow `..' in object file names for
1868 # *any* source, not just Java. For Java it just
1869 # doesn't make sense, but in general it is
1870 # a problem because we can't pick a good name for
1872 if ($object =~ /(\/|^)\.\.\//)
1874 &am_error ("`$full' contains `..' component but should not");
1877 # Make sure object is removed by `make mostlyclean'.
1878 $compile_clean_files{$object} = $MOSTLY_CLEAN;
1880 push (@dep_list, $directory . '/.dirstamp');
1882 # If we're generating dependencies, we also want
1883 # to make sure that the appropriate subdir of the
1884 # .deps directory is created.
1885 if ($use_dependencies)
1887 push (@dep_list, '.deps/' . $directory . '/.dirstamp');
1890 if (! defined $directory_map{$directory})
1892 $directory_map{$directory} = 1;
1894 # Directory must be removed by `make distclean'.
1895 $compile_clean_files{$directory . "/.dirstamp"} =
1897 $output_rules .= ($directory . "/.dirstamp:\n"
1898 . "\t\@\$(mkinstalldirs) $directory\n"
1899 . "\t\@: > $directory/.dirstamp\n");
1900 if ($use_dependencies)
1902 $output_rules .= ('.deps/' . $directory
1904 . "\t\@\$(mkinstalldirs) .deps/$directory\n"
1905 . "\t\@: > .deps/$directory/.dirstamp\n");
1910 &pretty_print_rule ($object . ':', "\t", @dep_list)
1911 if scalar @dep_list > 0;
1914 # Transform .o or $o file into .P file (for automatic
1917 && ($lang->autodep ne 'no'
1918 || $lang->derived_autodep eq 'yes'))
1920 my $depfile = $object;
1921 $depfile =~ s/\.([^.]*)$/.P$1/;
1922 $depfile =~ s/\$\(OBJEXT\)$/o/;
1923 $dep_files{'$(DEPDIR)/' . $depfile} = 1;
1927 return (&resolve_linker (%linkers_used), @result);
1932 # Handle SOURCE->OBJECT transform for one program or library.
1934 # canonical (transformed) name of object to build
1935 # actual name of object to build
1936 # object extension (ie either `.o' or `$o'.
1937 # Return result is name of linker variable that must be used.
1938 # Empty return means just use `LINK'.
1939 sub handle_source_transform
1941 # one_file is canonical name. unxformed is given name. obj is
1943 my ($one_file, $unxformed, $obj) = @_;
1947 if (&variable_defined ($one_file . "_OBJECTS"))
1949 &am_line_error ($one_file . '_OBJECTS',
1950 $one_file . '_OBJECTS', 'should not be defined');
1951 # No point in continuing.
1956 foreach my $prefix ('', 'EXTRA_', 'dist_', 'nodist_',
1957 'dist_EXTRA_', 'nodist_EXTRA_')
1959 my $var = $prefix . $one_file . "_SOURCES";
1961 if !variable_defined ($var);
1963 # We are going to define _OBJECTS variables using the prefix.
1964 # Then we glom them all together. So we can't use the null
1965 # prefix here as we need it later.
1966 my $xpfx = ($prefix eq '') ? 'am_' : $prefix;
1968 # Keep track of which prefixes we saw.
1969 $used_pfx{$xpfx} = 1
1970 unless $prefix =~ /EXTRA_/;
1972 push (@sources, '$(' . $prefix . $one_file . "_SOURCES)");
1973 push (@dist_sources, '$(' . $prefix . $one_file . "_SOURCES)")
1974 unless $prefix =~ /^nodist_/;
1975 foreach my $cond (variable_conditions ($var))
1977 my @files = &variable_value_as_list ($var, $cond);
1978 my ($temp, @result) =
1979 &handle_single_transform_list ($var, $one_file, $obj,
1981 # If there are no files to compile, don't require a linker (yet).
1985 # Define _OBJECTS conditionally.
1986 &define_pretty_variable ($xpfx . $one_file . '_OBJECTS',
1988 unless $prefix =~ /EXTRA_/;
1992 my @keys = sort keys %used_pfx;
1993 if (scalar @keys == 0)
1995 &define_variable ($one_file . "_SOURCES", $unxformed . ".c");
1996 push (@sources, $unxformed . '.c');
1997 push (@dist_sources, $unxformed . '.c');
1999 my ($temp, @result) =
2000 &handle_single_transform_list ($one_file . '_SOURCES',
2003 $linker = $temp if $linker eq '';
2004 &define_pretty_variable ($one_file . "_OBJECTS", '', @result)
2008 grep ($_ = '$(' . $_ . $one_file . '_OBJECTS)', @keys);
2009 &define_pretty_variable ($one_file . '_OBJECTS', '', @keys);
2012 # If we want to use `LINK' we must make sure it is defined.
2022 # handle_lib_objects ($XNAME, $VAR)
2023 # ---------------------------------
2024 # Special-case @ALLOCA@ and @LIBOBJS@ in _LDADD or _LIBADD variables.
2025 # Also, generate _DEPENDENCIES variable if appropriate.
2027 # transformed name of object being built, or empty string if no object
2028 # name of _LDADD/_LIBADD-type variable to examine
2029 # Returns 1 if LIBOBJS seen, 0 otherwise.
2030 sub handle_lib_objects
2032 my ($xname, $var) = @_;
2034 &prog_error ("handle_lib_objects: $var undefined")
2035 if ! &variable_defined ($var);
2038 foreach my $cond (&variable_conditions ($var))
2040 if (&handle_lib_objects_cond ($xname, $var, $cond))
2048 # Subroutine of handle_lib_objects: handle a particular condition.
2049 sub handle_lib_objects_cond
2051 my ($xname, $var, $cond) = @_;
2053 # We recognize certain things that are commonly put in LIBADD or
2057 my $seen_libobjs = 0;
2060 foreach my $lsearch (&variable_value_as_list ($var, $cond))
2062 # Skip -lfoo and -Ldir; these are explicitly allowed.
2063 next if $lsearch =~ /^-[lL]/;
2064 if (! $flagvar && $lsearch =~ /^-/)
2066 if ($var =~ /^(.*)LDADD$/)
2068 # Skip -dlopen and -dlpreopen; these are explicitly allowed.
2069 next if $lsearch =~ /^-dl(pre)?open$/;
2070 &am_line_error ($var, "linker flags such as `$lsearch' belong in `${1}LDFLAGS");
2074 # Only get this error once.
2076 &am_line_error ($var, "linker flags such as `$lsearch' belong in `${1}LDFLAGS");
2080 # Assume we have a file of some sort, and push it onto the
2081 # dependency list. Autoconf substitutions are not pushed;
2082 # rarely is a new dependency substituted into (eg) foo_LDADD
2083 # -- but "bad things (eg -lX11) are routinely substituted.
2084 # Note that LIBOBJS and ALLOCA are exceptions to this rule,
2085 # and handled specially below.
2086 push (@dep_list, $lsearch)
2087 unless $lsearch =~ /^\@.*\@$/;
2089 # Automatically handle @LIBOBJS@ and @ALLOCA@. Basically this
2090 # means adding entries to dep_files.
2091 if ($lsearch =~ /^\@(LT)?LIBOBJS\@$/)
2093 my $myobjext = ($1 ? 'l' : '') . 'o';
2095 push (@dep_list, $lsearch);
2097 if (! keys %libsources
2098 && ! &variable_defined ($1 . 'LIBOBJS'))
2100 &am_line_error ($var, "\@$1" . "LIBOBJS\@ seen but never set in `$configure_ac'");
2103 foreach my $iter (keys %libsources)
2105 if ($iter =~ /\.([cly])$/)
2107 &saw_extension ($1);
2108 &saw_extension ('c');
2111 if ($iter =~ /\.h$/)
2113 &require_file_with_line ($var, $FOREIGN, $iter);
2115 elsif ($iter ne 'alloca.c')
2117 my $rewrite = $iter;
2118 $rewrite =~ s/\.c$/.P$myobjext/;
2119 $dep_files{'$(DEPDIR)/' . $rewrite} = 1;
2120 ($rewrite = $iter) =~ s/(\W)/\\$1/g;
2121 $rewrite = "^" . $rewrite . "\$";
2122 # Only require the file if it is not a built source.
2123 if (! &variable_defined ('BUILT_SOURCES')
2124 || ! grep (/$rewrite/,
2125 &variable_value_as_list ('BUILT_SOURCES',
2128 &require_file_with_line ($var, $FOREIGN, $iter);
2133 elsif ($lsearch =~ /^\@(LT)?ALLOCA\@$/)
2135 my $myobjext = ($1 ? 'l' : '') . 'o';
2137 push (@dep_list, $lsearch);
2138 &am_line_error ($var,
2139 "\@$1" . "ALLOCA\@ seen but `AC_FUNC_ALLOCA' not in `$configure_ac'")
2140 if ! defined $libsources{'alloca.c'};
2141 $dep_files{'$(DEPDIR)/alloca.P' . $myobjext} = 1;
2142 &require_file_with_line ($var, $FOREIGN, 'alloca.c');
2143 &saw_extension ('c');
2147 if ($xname ne '' && ! &variable_defined ($xname . '_DEPENDENCIES', $cond))
2149 &define_pretty_variable ($xname . '_DEPENDENCIES', $cond, @dep_list);
2152 return $seen_libobjs;
2155 # Canonicalize the input parameter
2159 $string =~ tr/A-Za-z0-9_\@/_/c;
2163 # Canonicalize a name, and check to make sure the non-canonical name
2164 # is never used. Returns canonical name. Arguments are name and a
2165 # list of suffixes to check for.
2166 sub check_canonical_spelling
2168 my ($name, @suffixes) = @_;
2170 my $xname = &canonicalize ($name);
2171 if ($xname ne $name)
2173 foreach my $xt (@suffixes)
2175 &am_line_error ("$name$xt",
2176 "invalid variable `$name$xt'; "
2177 . "should be `$xname$xt'")
2178 if &variable_defined ("$name$xt");
2188 # Set up the compile suite.
2189 sub handle_compile ()
2192 unless $get_object_extension_was_run;
2195 my $default_includes = '';
2196 if (! defined $options{'nostdinc'})
2198 $default_includes = ' -I. -I$(srcdir)';
2200 if (&variable_defined ('CONFIG_HEADER'))
2202 foreach my $hdr (split (' ', &variable_value ('CONFIG_HEADER')))
2204 $default_includes .= ' -I' . dirname ($hdr);
2209 my (@mostly_rms, @dist_rms);
2210 foreach my $item (sort keys %compile_clean_files)
2212 if ($compile_clean_files{$item} == $MOSTLY_CLEAN)
2214 push (@mostly_rms, "\t-rm -f $item");
2216 elsif ($compile_clean_files{$item} == $DIST_CLEAN)
2218 push (@dist_rms, "\t-rm -f $item");
2222 &prog_error ("invalid entry in \%compile_clean_files");
2226 my ($coms, $vars, $rules) =
2227 &file_contents_internal (1, "$libdir/am/compile.am",
2228 ('DEFAULT_INCLUDES' => $default_includes,
2229 'MOSTLYRMS' => join ("\n", @mostly_rms),
2230 'DISTRMS' => join ("\n", @dist_rms)));
2231 $output_vars .= $vars;
2232 $output_rules .= "$coms$rules";
2236 # Output the libtool compilation rules.
2237 $output_rules .= &file_contents ('libtool');
2240 # Check for automatic de-ANSI-fication.
2241 if (defined $options{'ansi2knr'})
2243 if (! $am_c_prototypes)
2245 &am_line_error ('AUTOMAKE_OPTIONS',
2246 "option `ansi2knr' in use but `AM_C_PROTOTYPES' not in `$configure_ac'");
2247 &keyed_aclocal_warning ('AM_C_PROTOTYPES');
2248 # Only give this error once.
2249 $am_c_prototypes = 1;
2252 # topdir is where ansi2knr should be.
2253 if ($options{'ansi2knr'} eq 'ansi2knr')
2255 # Only require ansi2knr files if they should appear in
2257 &require_file_with_line ('AUTOMAKE_OPTIONS', $FOREIGN,
2258 'ansi2knr.c', 'ansi2knr.1');
2260 # ansi2knr needs to be built before subdirs, so unshift it.
2261 unshift (@all, '$(ANSI2KNR)');
2264 my $ansi2knr_dir = '';
2265 $ansi2knr_dir = dirname ($options{'ansi2knr'})
2266 if $options{'ansi2knr'} ne 'ansi2knr';
2268 $output_rules .= &file_contents ('ansi2knr',
2269 ('ANSI2KNR-DIR' => $ansi2knr_dir));
2276 # handle_programs ()
2277 # ------------------
2278 # Handle C programs.
2281 my @proglist = &am_install_var ('progs', 'PROGRAMS',
2282 'bin', 'sbin', 'libexec', 'pkglib',
2284 return if ! @proglist;
2286 my $seen_libobjs = 0;
2287 foreach my $one_file (@proglist)
2289 my $obj = &get_object_extension ($one_file);
2291 # Canonicalize names and check for misspellings.
2292 my $xname = &check_canonical_spelling ($one_file, '_LDADD', '_LDFLAGS',
2293 '_SOURCES', '_OBJECTS',
2296 my $linker = &handle_source_transform ($xname, $one_file, $obj);
2299 if (&variable_defined ($xname . "_LDADD"))
2301 if (&handle_lib_objects ($xname, $xname . '_LDADD'))
2309 # User didn't define prog_LDADD override. So do it.
2310 &define_variable ($xname . '_LDADD', '$(LDADD)');
2312 # This does a bit too much work. But we need it to
2313 # generate _DEPENDENCIES when appropriate.
2314 if (&variable_defined ('LDADD'))
2316 if (&handle_lib_objects ($xname, 'LDADD'))
2321 elsif (! &variable_defined ($xname . '_DEPENDENCIES'))
2323 &define_variable ($xname . '_DEPENDENCIES', '');
2328 if (&variable_defined ($xname . '_LIBADD'))
2330 &am_line_error ($xname . '_LIBADD',
2331 "use `" . $xname . "_LDADD', not `"
2332 . $xname . "_LIBADD'");
2335 if (! &variable_defined ($xname . '_LDFLAGS'))
2337 # Define the prog_LDFLAGS variable.
2338 &define_variable ($xname . '_LDFLAGS', '');
2341 # Determine program to use for link.
2343 if (&variable_defined ($xname . '_LINK'))
2345 $xlink = $xname . '_LINK';
2349 $xlink = $linker ? $linker : 'LINK';
2352 $output_rules .= &file_contents ('program',
2353 ('PROGRAM' => $one_file,
2354 'XPROGRAM' => $xname,
2355 'XLINK' => $xlink));
2358 if (&variable_defined ('LDADD') && &handle_lib_objects ('', 'LDADD'))
2365 foreach my $one_file (@proglist)
2367 my $xname = &canonicalize ($one_file);
2369 if (&variable_defined ($xname . '_LDADD'))
2371 &check_libobjs_sources ($xname, $xname . '_LDADD');
2373 elsif (&variable_defined ('LDADD'))
2375 &check_libobjs_sources ($xname, 'LDADD');
2382 # handle_libraries ()
2383 # -------------------
2385 sub handle_libraries
2387 my @liblist = &am_install_var ('libs', 'LIBRARIES',
2388 'lib', 'pkglib', 'noinst', 'check');
2389 return if ! @liblist;
2391 my %valid = &am_primary_prefixes ('LIBRARIES', 0, 'lib', 'pkglib',
2393 if (! defined $configure_vars{'RANLIB'})
2395 foreach my $key (keys %valid)
2397 if (&variable_defined ($key . '_LIBRARIES'))
2399 &am_line_error ($key . '_LIBRARIES', "library used but `RANLIB' not defined in `$configure_ac'");
2400 # Only get this error once. If this is ever printed,
2402 $configure_vars{'RANLIB'} = 'BUG';
2408 my $seen_libobjs = 0;
2409 foreach my $onelib (@liblist)
2411 # Check that the library fits the standard naming convention.
2412 if ($onelib !~ /^lib.*\.a$/)
2414 # FIXME should put line number here. That means mapping
2415 # from library name back to variable name.
2416 &am_error ("`$onelib' is not a standard library name");
2419 my $obj = &get_object_extension ($onelib);
2421 # Canonicalize names and check for misspellings.
2422 my $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_SOURCES',
2423 '_OBJECTS', '_DEPENDENCIES',
2426 if (! &variable_defined ($xlib . '_AR'))
2428 &define_variable ($xlib . '_AR', '$(AR) cru');
2431 if (&variable_defined ($xlib . '_LIBADD'))
2433 if (&handle_lib_objects ($xlib, $xlib . '_LIBADD'))
2440 # Generate support for conditional object inclusion in
2442 &define_variable ($xlib . "_LIBADD", '');
2445 if (&variable_defined ($xlib . '_LDADD'))
2447 &am_line_error ($xlib . '_LDADD',
2448 "use `" . $xlib . "_LIBADD', not `"
2449 . $xlib . "_LDADD'");
2452 # Make sure we at look at this.
2453 &examine_variable ($xlib . '_DEPENDENCIES');
2455 &handle_source_transform ($xlib, $onelib, $obj);
2457 $output_rules .= &file_contents ('library',
2458 ('LIBRARY' => $onelib,
2459 'XLIBRARY' => $xlib));
2464 foreach my $onelib (@liblist)
2466 my $xlib = &canonicalize ($onelib);
2467 if (&variable_defined ($xlib . '_LIBADD'))
2469 &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
2476 # handle_ltlibraries ()
2477 # ---------------------
2478 # Handle shared libraries.
2479 sub handle_ltlibraries
2481 my @liblist = &am_install_var ('ltlib', 'LTLIBRARIES',
2482 'noinst', 'lib', 'pkglib', 'check');
2483 return if ! @liblist;
2486 my %valid = &am_primary_prefixes ('LTLIBRARIES', 0, 'lib', 'pkglib',
2489 foreach my $key (keys %valid)
2491 if (&variable_defined ($key . '_LTLIBRARIES'))
2495 &am_line_error ($key . '_LTLIBRARIES', "library used but `LIBTOOL' not defined in `$configure_ac'");
2496 # Only get this error once. If this is ever printed,
2498 $configure_vars{'LIBTOOL'} = 'BUG';
2502 # Get the installation directory of each library.
2503 for (&variable_value_as_list ($key . '_LTLIBRARIES', 'all'))
2507 &am_error ("`$_' is already going to be installed in `$instdirs{$_}'");
2511 $instdirs{$_} = $key;
2517 my $seen_libobjs = 0;
2518 foreach my $onelib (@liblist)
2520 my $obj = &get_object_extension ($onelib);
2522 # Canonicalize names and check for misspellings.
2523 my $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_LDFLAGS',
2524 '_SOURCES', '_OBJECTS',
2527 if (! &variable_defined ($xlib . '_LDFLAGS'))
2529 # Define the lib_LDFLAGS variable.
2530 &define_variable ($xlib . '_LDFLAGS', '');
2533 # Check that the library fits the standard naming convention.
2534 my $libname_rx = "^lib.*\.la";
2535 if ((&variable_defined ($xlib . '_LDFLAGS')
2536 && grep (/-module/, &variable_value_as_list ($xlib . '_LDFLAGS',
2538 || (&variable_defined ('LDFLAGS')
2539 && grep (/-module/, &variable_value_as_list ('LDFLAGS',
2542 # Relax name checking for libtool modules.
2543 $libname_rx = "\.la";
2545 if ($onelib !~ /$libname_rx$/)
2547 # FIXME this should only be a warning for foreign packages
2548 # FIXME should put line number here. That means mapping
2549 # from library name back to variable name.
2550 &am_error ("`$onelib' is not a standard libtool library name");
2553 if (&variable_defined ($xlib . '_LIBADD'))
2555 if (&handle_lib_objects ($xlib, $xlib . '_LIBADD'))
2562 # Generate support for conditional object inclusion in
2564 &define_variable ($xlib . "_LIBADD", '');
2567 if (&variable_defined ($xlib . '_LDADD'))
2569 &am_line_error ($xlib . '_LDADD',
2570 "use `" . $xlib . "_LIBADD', not `"
2571 . $xlib . "_LDADD'");
2574 # Make sure we at look at this.
2575 &examine_variable ($xlib . '_DEPENDENCIES');
2577 my $linker = &handle_source_transform ($xlib, $onelib, $obj);
2579 # Determine program to use for link.
2581 if (&variable_defined ($xlib . '_LINK'))
2583 $xlink = $xlib . '_LINK';
2587 $xlink = $linker ? $linker : 'LINK';
2591 if ($instdirs{$onelib} eq 'EXTRA'
2592 || $instdirs{$onelib} eq 'noinst'
2593 || $instdirs{$onelib} eq 'check')
2595 # It's an EXTRA_ library, so we can't specify -rpath,
2596 # because we don't know where the library will end up.
2597 # The user probably knows, but generally speaking automake
2598 # doesn't -- and in fact configure could decide
2599 # dynamically between two different locations.
2604 $rpath = ('-rpath $(' . $instdirs{$onelib} . 'dir)');
2607 $output_rules .= &file_contents ('ltlibrary',
2608 ('LTLIBRARY' => $onelib,
2609 'XLTLIBRARY' => $xlib,
2611 'XLINK' => $xlink));
2616 foreach my $onelib (@liblist)
2618 my $xlib = &canonicalize ($onelib);
2619 if (&variable_defined ($xlib . '_LIBADD'))
2621 &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
2627 # See if any _SOURCES variable were misspelled. Also, make sure that
2628 # EXTRA_ variables don't contain configure substitutions.
2631 foreach my $varname (keys %var_value)
2633 foreach my $primary ('_SOURCES', '_LIBADD', '_LDADD', '_LDFLAGS',
2636 if ($varname =~ /$primary$/ && ! $content_seen{$varname})
2638 &am_line_error ($varname,
2639 "invalid unused variable name: `$varname'");
2648 # NOTE we no longer automatically clean SCRIPTS, because it is
2649 # useful to sometimes distribute scripts verbatim. This happens
2650 # eg in Automake itself.
2651 &am_install_var ('-candist', 'scripts', 'SCRIPTS',
2652 'bin', 'sbin', 'libexec', 'pkgdata',
2655 my $scripts_installed = 0;
2656 # Set $scripts_installed if appropriate. Make sure we only find
2657 # scripts which are actually installed -- this is why we can't
2658 # simply use the return value of am_install_var.
2659 my %valid = &am_primary_prefixes ('SCRIPTS', 1, 'bin', 'sbin',
2660 'libexec', 'pkgdata',
2662 foreach my $key (keys %valid)
2664 if ($key ne 'noinst'
2666 && &variable_defined ($key . '_SCRIPTS'))
2668 $scripts_installed = 1;
2669 # push (@check_tests, 'check-' . $key . 'SCRIPTS');
2675 # ($OUTFILE, $VFILE, @CLEAN_FILES)
2676 # &scan_texinfo_file ($FILENAME)
2677 # ------------------------------
2678 # $OUTFILE is the name of the info file produced by $FILENAME.
2679 # $VFILE is the name of the version.texi file used (empty if none).
2680 # @CLEAN_FILES is the list of by products (indexes etc.)
2681 sub scan_texinfo_file
2683 my ($filename) = @_;
2685 # These are always created, no matter whether indexes are used or not.
2686 my @clean_suffixes = ('aux', 'dvi', 'log', 'ps', 'toc',
2687 # grep new.*index texinfo.tex
2688 'cp', 'fn', 'ky', 'vr', 'tp', 'pg');
2690 # There are predefined indexes which don't follow the regular rules.
2691 my %predefined_index =
2694 'c' => 'cps', 'f' => 'fns', 'k' => 'kys',
2695 'v' => 'vrs', 't' => 'tps', 'p' => 'pgs'
2698 # There are commands which include a hidden index command.
2702 'fn' => 'fns', 'un' => 'fns',
2703 'typefn' => 'fns', 'typefun' => 'fns',
2704 'mac' => 'fns', 'spec' => 'fns',
2705 'op' => 'fns', 'typeop' => 'fns',
2706 'method' => 'fns', 'typemethod' => 'fns',
2708 'vr' => 'vrs', 'var' => 'vrs',
2709 'typevr' => 'vrs', 'typevar' => 'vrs',
2712 'ivar' => 'vrs', 'typeivar' => 'vrs',
2717 # Indexes stored into another one. In this case, the *.??s file
2719 my @syncodeindexes = ();
2721 my $texi = new IO::File ("< $filename");
2724 &am_error ("couldn't open `$filename': $!");
2727 print "$me: reading $filename\n" if $verbose;
2729 my ($outfile, $vfile);
2730 while ($_ = $texi->getline)
2732 if (/^\@setfilename +(\S+)/)
2735 if ($outfile =~ /\.(.+)$/ && $1 ne 'info')
2737 &am_file_error ($filename, "$.: ",
2738 "output `$outfile' has unrecognized extension");
2742 # A "version.texi" file is actually any file whose name
2743 # matches "vers*.texi".
2744 elsif (/^\@include\s+(vers[^.]*\.texi)\s*$/)
2749 # Try to find what are the indexes which are used.
2751 # Creating a new category of index.
2752 elsif (/^\@def(code)?index (\w+)/)
2754 push @clean_suffixes, $2;
2757 # Storing in a predefined index.
2758 elsif (/^\@([cfkvtp])index /)
2760 push @clean_suffixes, $predefined_index{$1};
2762 elsif (/^\@def(\w+) /)
2764 push @clean_suffixes, $hidden_index{$1}
2765 if defined $hidden_index{$1};
2768 # Merging an index into an another.
2769 elsif (/^\@syn(code)?index (\w+) \w+/)
2771 push @syncodeindexes, "$2s";
2779 &am_error ("`$filename' missing \@setfilename");
2783 my $infobase = basename ($filename);
2784 $infobase =~ s/\.te?xi(nfo)?$//;
2785 # FIXME: I don't understand why, but I can't use "$infobase.$_" => 1.
2786 my %clean_files = map { "$infobase" . ".$_" => 1 } @clean_suffixes;
2787 grep { delete $clean_files{"$infobase.$_"} } @syncodeindexes;
2788 return ($outfile, $vfile, (sort keys %clean_files));
2792 # ($DO-SOMETHING, $TEXICLEANS)
2793 # handle_texinfo_helper ()
2795 # Handle all Texinfo source; helper for handle_texinfo
2796 sub handle_texinfo_helper
2798 &am_line_error ('TEXINFOS',
2799 "`TEXINFOS' is an anachronism; use `info_TEXINFOS'")
2800 if &variable_defined ('TEXINFOS');
2801 return (0, '') if (! &variable_defined ('info_TEXINFOS')
2802 && ! &variable_defined ('html_TEXINFOS'));
2804 if (&variable_defined ('html_TEXINFOS'))
2806 &am_line_error ('html_TEXINFOS',
2807 "HTML generation not yet supported");
2811 my @texis = &variable_value_as_list ('info_TEXINFOS', 'all');
2813 my (@info_deps_list, @dvis_list, @texi_deps);
2820 foreach my $info_cursor (@texis)
2822 my $infobase = $info_cursor;
2823 $infobase =~ s/\.(txi|texinfo|texi)$//;
2825 if ($infobase eq $info_cursor)
2827 # FIXME: report line number.
2828 &am_error ("texinfo file `$info_cursor' has unrecognized extension");
2831 $texi_suffixes{$1} = 1;
2833 # If 'version.texi' is referenced by input file, then include
2834 # automatic versioning capability.
2835 my ($out_file, $vtexi, @clean_files) =
2836 &scan_texinfo_file ("$relative_dir/$info_cursor")
2838 push (@texi_cleans, @clean_files);
2842 &am_error ("`$vtexi', included in `$info_cursor', also included in `$versions{$vtexi}'")
2843 if (defined $versions{$vtexi});
2844 $versions{$vtexi} = $info_cursor;
2846 # We number the stamp-vti files. This is doable since the
2847 # actual names don't matter much. We only number starting
2848 # with the second one, so that the common case looks nice.
2849 my $vti = ($done ? $done : 'vti');
2852 &require_conf_file_with_line ('info_TEXINFOS', $FOREIGN,
2856 if ($config_aux_dir_set_in_configure_in)
2858 $conf_dir = $config_aux_dir;
2859 $conf_dir .= '/' unless $conf_dir =~ /\/$/;
2863 $conf_dir = '$(srcdir)/';
2865 $output_rules .= &file_contents ('texi-vers',
2866 ('TEXI' => $info_cursor,
2869 'MDDIR' => $conf_dir));
2872 # If user specified file_TEXINFOS, then use that as explicit
2875 push (@texi_deps, $info_cursor);
2876 # Prefix with $(srcdir) because some version of make won't
2877 # work if the target has it and the dependency doesn't.
2878 push (@texi_deps, '$(srcdir)/' . $vtexi) if $vtexi;
2880 my $canonical = &canonicalize ($infobase);
2881 if (&variable_defined ($canonical . "_TEXINFOS"))
2883 push (@texi_deps, '$(' . $canonical . '_TEXINFOS)');
2884 &push_dist_common ('$(' . $canonical . '_TEXINFOS)');
2887 $output_rules .= ("\n" . $out_file . ": "
2888 . join (' ', @texi_deps)
2889 . "\n" . $infobase . ".dvi: "
2890 . join (' ', @texi_deps)
2893 push (@info_deps_list, $out_file);
2894 push (@dvis_list, $infobase . '.dvi');
2897 # Handle location of texinfo.tex.
2898 my $need_texi_file = 0;
2902 $texinfodir = '$(top_srcdir)/../texinfo';
2903 &define_variable ('TEXINFO_TEX', "$texinfodir/texinfo.tex");
2906 elsif ($config_aux_dir_set_in_configure_in)
2908 $texinfodir = $config_aux_dir;
2909 &define_variable ('TEXINFO_TEX', "$texinfodir/texinfo.tex");
2910 $need_texi_file = 2; # so that we require_conf_file later
2912 elsif (&variable_defined ('TEXINFO_TEX'))
2914 # The user defined TEXINFO_TEX so assume he knows what he is
2916 $texinfodir = ('$(srcdir)/'
2917 . dirname (&variable_value ('TEXINFO_TEX')));
2921 $texinfodir = '$(srcdir)';
2922 $need_texi_file = 1;
2925 foreach my $txsfx (sort keys %texi_suffixes)
2927 $output_rules .= &file_contents ('texibuild',
2928 ('TEXINFODIR' => $texinfodir,
2929 'SUFFIX' => $txsfx));
2933 my $texiclean = &pretty_print_internal ("", "\t ", @texi_cleans);
2935 push (@dist_targets, 'dist-info');
2937 if (! defined $options{'no-installinfo'})
2939 # Make sure documentation is made and installed first. Use
2940 # $(INFO_DEPS), not 'info', because otherwise recursive makes
2941 # get run twice during "make all".
2942 unshift (@all, '$(INFO_DEPS)');
2945 &define_variable ("INFO_DEPS", join (' ', @info_deps_list));
2946 &define_variable ("DVIS", join (' ', @dvis_list));
2947 # This next isn't strictly needed now -- the places that look here
2948 # could easily be changed to look in info_TEXINFOS. But this is
2949 # probably better, in case noinst_TEXINFOS is ever supported.
2950 &define_variable ("TEXINFOS", &variable_value ('info_TEXINFOS'));
2952 # Do some error checking. Note that this file is not required
2953 # when in Cygnus mode; instead we defined TEXINFO_TEX explicitly
2955 if ($need_texi_file && ! defined $options{'no-texinfo.tex'})
2957 if ($need_texi_file > 1)
2959 &require_conf_file_with_line ('info_TEXINFOS', $FOREIGN,
2964 &require_file_with_line ('info_TEXINFOS', $FOREIGN, 'texinfo.tex');
2968 return (1, $texiclean);
2973 # Handle all Texinfo source.
2976 my ($do_something, $texiclean) = handle_texinfo_helper ();
2977 $output_rules .= &file_contents ('texinfos',
2978 ('TEXICLEAN' => $texiclean,
2979 'LOCAL-TEXIS' => $do_something));
2982 # Handle any man pages.
2983 sub handle_man_pages
2985 &am_line_error ('MANS', "`MANS' is an anachronism; use `man_MANS'")
2986 if &variable_defined ('MANS');
2988 # Find all the sections in use. We do this by first looking for
2989 # "standard" sections, and then looking for any additional
2990 # sections used in man_MANS.
2991 my (%sections, %vlist);
2992 # We handle nodist_ for uniformity. man pages aren't distributed
2993 # by default so it isn't actually very important.
2994 foreach my $pfx ('', 'dist_', 'nodist_')
2996 # Add more sections as needed.
2997 foreach my $section ('0'..'9', 'n', 'l')
2999 if (&variable_defined ($pfx . 'man' . $section . '_MANS'))
3001 $sections{$section} = 1;
3002 $vlist{'$(' . $pfx . 'man' . $section . '_MANS)'} = 1;
3004 &push_dist_common ('$(' . $pfx . 'man' . $section . '_MANS)')
3009 if (&variable_defined ($pfx . 'man_MANS'))
3011 $vlist{'$(' . $pfx . 'man_MANS)'} = 1;
3012 foreach (&variable_value_as_list ($pfx . 'man_MANS', 'all'))
3014 # A page like `foo.1c' goes into man1dir.
3015 if (/\.([0-9a-z])([a-z]*)$/)
3021 &push_dist_common ('$(' . $pfx . 'man_MANS)')
3026 return unless %sections;
3028 # Now for each section, generate an install and unintall rule.
3029 # Sort sections so output is deterministic.
3030 foreach my $section (sort keys %sections)
3032 $output_rules .= &file_contents ('mans', ('SECTION' => $section));
3035 $output_vars .= &file_contents ('mans-vars',
3036 ('MANS' => join (' ', sort keys %vlist)));
3038 if (! defined $options{'no-installman'})
3040 push (@all, '$(MANS)');
3044 # Handle DATA variables.
3047 &am_install_var ('-noextra', '-candist', 'data', 'DATA',
3048 'data', 'sysconf', 'sharedstate', 'localstate',
3049 'pkgdata', 'noinst', 'check');
3056 if (&variable_defined ('SUBDIRS'))
3058 $output_rules .= ("tags-recursive:\n"
3059 . "\tlist=\'\$(SUBDIRS)\'; for subdir in \$\$list; do \\\n"
3060 # Never fail here if a subdir fails; it
3062 . "\t test \"\$\$subdir\" = . || (cd \$\$subdir"
3063 . " && \$(MAKE) \$(AM_MAKEFLAGS) tags); \\\n"
3065 push (@tag_deps, 'tags-recursive');
3066 &depend ('.PHONY', 'tags-recursive');
3069 if (&saw_sources_p (1)
3070 || &variable_defined ('ETAGS_ARGS')
3074 foreach my $one_hdr (@config_headers)
3076 if ($relative_dir eq dirname ($one_hdr))
3078 # The config header is in this directory. So require it.
3079 $config .= ' ' if $config;
3080 $config .= basename ($one_hdr);
3083 $output_rules .= &file_contents ('tags',
3084 ('CONFIG' => $config,
3085 'DIRS' => join (' ', @tag_deps)));
3086 &examine_variable ('TAGS_DEPENDENCIES');
3088 elsif (&variable_defined ('TAGS_DEPENDENCIES'))
3090 &am_line_error ('TAGS_DEPENDENCIES',
3091 "doesn't make sense to define `TAGS_DEPENDENCIES' without sources or `ETAGS_ARGS'");
3095 # Every Makefile must define some sort of TAGS rule.
3096 # Otherwise, it would be possible for a top-level "make TAGS"
3097 # to fail because some subdirectory failed.
3098 $output_rules .= "tags: TAGS\nTAGS:\n\n";
3102 # Handle multilib support.
3105 return unless $seen_multilib;
3107 $output_rules .= &file_contents ('multilib');
3112 # &for_dist_common ($A, $B)
3113 # -------------------------
3114 # Subroutine for &handle_dist: sort files to dist.
3116 # We put README first because it then becomes easier to make a
3117 # Usenet-compliant shar file (in these, README must be first).
3119 # FIXME: do more ordering of files here.
3132 # handle_dist ($MAKEFILE)
3133 # -----------------------
3134 # Handle 'dist' target.
3137 my ($makefile) = @_;
3139 # `make dist' isn't used in a Cygnus-style tree.
3140 # Omit the rules so that people don't try to use them.
3141 return if $cygnus_mode;
3143 # Set up maint_charset.
3144 $local_maint_charset = &variable_value ('MAINT_CHARSET')
3145 if &variable_defined ('MAINT_CHARSET');
3146 $maint_charset = $local_maint_charset
3147 if $relative_dir eq '.';
3149 if (&variable_defined ('DIST_CHARSET'))
3151 &am_line_error ('DIST_CHARSET',
3152 "DIST_CHARSET defined but no MAINT_CHARSET defined")
3153 if ! $local_maint_charset;
3154 if ($relative_dir eq '.')
3156 $dist_charset = &variable_value ('DIST_CHARSET')
3160 &am_line_error ('DIST_CHARSET',
3161 "DIST_CHARSET can only be defined at top level");
3165 # Look for common files that should be included in distribution.
3166 foreach my $cfile (@common_files)
3168 if (-f ($relative_dir . "/" . $cfile))
3170 &push_dist_common ($cfile);
3174 # We might copy elements from $configure_dist_common to
3175 # %dist_common if we think we need to. If the file appears in our
3176 # directory, we would have discovered it already, so we don't
3177 # check that. But if the file is in a subdir without a Makefile,
3178 # we want to distribute it here if we are doing `.'. Ugly!
3179 if ($relative_dir eq '.')
3181 foreach my $file (split (' ' , $configure_dist_common))
3183 if (! &is_make_dir (dirname ($file)))
3185 &push_dist_common ($file);
3192 # Files to distributed. Don't use &variable_value_as_list
3193 # as it recursively expands `$(dist_pkgdata_DATA)' etc.
3194 check_variable_defined_unconditionally ('DIST_COMMON');
3195 my @dist_common = split (' ', variable_value ('DIST_COMMON', 'TRUE'));
3196 @dist_common = uniq (sort for_dist_common (@dist_common));
3197 pretty_print ('DIST_COMMON = ', "\t", @dist_common);
3199 # Now that we've processed DIST_COMMON, disallow further attempts
3201 $handle_dist_run = 1;
3203 # Scan EXTRA_DIST to see if we need to distribute anything from a
3204 # subdir. If so, add it to the list. I didn't want to do this
3205 # originally, but there were so many requests that I finally
3207 if (&variable_defined ('EXTRA_DIST'))
3209 # FIXME: This should be fixed to work with conditionals. That
3210 # will require only making the entries in %dist_dirs under the
3211 # appropriate condition. This is meaningful if the nature of
3212 # the distribution should depend upon the configure options
3214 foreach (&variable_value_as_list ('EXTRA_DIST', ''))
3217 next unless s,/+[^/]+$,,;
3223 # We have to check DIST_COMMON for extra directories in case the
3224 # user put a source used in AC_OUTPUT into a subdir.
3225 foreach (&variable_value_as_list ('DIST_COMMON', 'all'))
3228 next unless s,/+[^/]+$,,;
3233 # Rule to check whether a distribution is viable.
3234 my %transform = ('DISTCHECK-HOOK' => &target_defined ('distcheck-hook'),
3235 'GETTEXT' => $seen_gettext);
3237 # Prepend $(distdir) to each directory given.
3238 my %rewritten = map { '$(distdir)/' . "$_" => 1 } keys %dist_dirs;
3239 $transform{'DISTDIRS'} = join (' ', sort keys %rewritten);
3241 # If we have SUBDIRS, create all dist subdirectories and do
3243 if (&variable_defined ('SUBDIRS'))
3245 # If SUBDIRS is conditionally defined, then set DIST_SUBDIRS
3246 # to all possible directories, and use it. If DIST_SUBDIRS is
3247 # defined, just use it.
3248 my $dist_subdir_name;
3249 # Note that we check DIST_SUBDIRS first on purpose. At least
3250 # one project uses so many conditional subdirectories that
3251 # calling variable_conditionally_defined on SUBDIRS will cause
3252 # automake to grow to 150Mb. Sigh.
3253 if (&variable_defined ('DIST_SUBDIRS')
3254 || variable_conditionally_defined ('SUBDIRS'))
3256 $dist_subdir_name = 'DIST_SUBDIRS';
3257 if (! &variable_defined ('DIST_SUBDIRS'))
3259 &define_pretty_variable
3260 ('DIST_SUBDIRS', '',
3261 uniq (&variable_value_as_list ('SUBDIRS', 'all')));
3266 $dist_subdir_name = 'SUBDIRS';
3267 # We always define this because that is what `distclean'
3269 &define_pretty_variable ('DIST_SUBDIRS', '', '$(SUBDIRS)');
3272 $transform{'DIST_SUBDIR_NAME'} = $dist_subdir_name;
3275 # If the target `dist-hook' exists, make sure it is run. This
3276 # allows users to do random weird things to the distribution
3277 # before it is packaged up.
3278 push (@dist_targets, 'dist-hook')
3279 if &target_defined ('dist-hook');
3280 $transform{'DIST-TARGETS'} = join(' ', @dist_targets);
3282 # Defining $(DISTDIR).
3283 $transform{'DISTDIR'} = !&variable_defined('distdir');
3284 $transform{'TOP_DISTDIR'} = backname ($relative_dir);
3286 $output_rules .= &file_contents ('distdir', %transform);
3290 # Handle subdirectories.
3294 unless &variable_defined ('SUBDIRS');
3296 # Make sure each directory mentioned in SUBDIRS actually exists.
3297 foreach my $dir (&variable_value_as_list ('SUBDIRS', 'all'))
3299 # Skip directories substituted by configure.
3300 next if $dir =~ /^\@.*\@$/;
3302 if (! -d $am_relative_dir . '/' . $dir)
3304 &am_line_error ('SUBDIRS',
3305 "required directory $am_relative_dir/$dir does not exist");
3309 &am_line_error ('SUBDIRS', "directory should not contain `/'")
3313 $output_rules .= &file_contents ('subdirs');
3314 variable_pretty_output ('RECURSIVE_TARGETS', 'TRUE');
3318 # ($REGEN, @DEPENDENCIES)
3321 # If aclocal.m4 creation is automated, return the list of its dependencies.
3324 my $regen_aclocal = 0;
3327 unless $relative_dir eq '.';
3329 &examine_variable ('CONFIG_STATUS_DEPENDENCIES');
3330 &examine_variable ('CONFIGURE_DEPENDENCIES');
3332 if (-f 'aclocal.m4')
3334 &define_variable ("ACLOCAL_M4", '$(top_srcdir)/aclocal.m4');
3335 &push_dist_common ('aclocal.m4');
3337 my $aclocal = new IO::File ("< aclocal.m4");
3340 my $line = $aclocal->getline;
3343 if ($line =~ 'generated automatically by aclocal')
3352 if (-f 'acinclude.m4')
3355 push @ac_deps, 'acinclude.m4';
3358 if (&variable_defined ('ACLOCAL_M4_SOURCES'))
3360 push (@ac_deps, '$(ACLOCAL_M4_SOURCES)');
3362 elsif (&variable_defined ('ACLOCAL_AMFLAGS'))
3364 # Scan all -I directories for m4 files. These are our
3366 my $examine_next = 0;
3367 foreach my $amdir (&variable_value_as_list ('ACLOCAL_AMFLAGS', ''))
3372 if ($amdir !~ /^\// && -d $amdir)
3374 foreach my $ac_dep (&my_glob ($amdir . '/*.m4'))
3376 $ac_dep =~ s/^\.\/+//;
3377 push (@ac_deps, $ac_dep)
3378 unless $ac_dep eq "aclocal.m4"
3379 || $ac_dep eq "acinclude.m4";
3383 elsif ($amdir eq '-I')
3390 # Note that it might be possible that aclocal.m4 doesn't exist but
3391 # should be auto-generated. This case probably isn't very
3394 return ($regen_aclocal, @ac_deps);
3397 # Rewrite a list of input files into a form suitable to put on a
3398 # dependency list. The idea is that if an input file has a directory
3399 # part the same as the current directory, then the directory part is
3400 # simply removed. But if the directory part is different, then
3401 # $(top_srcdir) is prepended. Among other things, this is used to
3402 # generate the dependency list for the output files generated by
3403 # AC_OUTPUT. Consider what the dependencies should look like in this
3405 # AC_OUTPUT(src/out:src/in1:lib/in2)
3406 # The first argument, ADD_SRCDIR, is 1 if $(top_srcdir) should be added.
3407 # If 0 then files that require this addition will simply be ignored.
3408 sub rewrite_inputs_into_dependencies
3410 my ($add_srcdir, @inputs) = @_;
3413 foreach my $single (@inputs)
3415 if (dirname ($single) eq $relative_dir)
3417 push (@newinputs, basename ($single));
3421 push (@newinputs, '$(top_srcdir)/' . $single);
3428 # Handle remaking and configure stuff.
3429 # We need the name of the input file, to do proper remaking rules.
3430 sub handle_configure
3432 my ($local, $input, @secondary_inputs) = @_;
3434 my $input_base = basename ($input);
3435 my $local_base = basename ($local);
3437 my $amfile = $input_base . '.am';
3438 # We know we can always add '.in' because it really should be an
3439 # error if the .in was missing originally.
3440 my $infile = '$(srcdir)/' . $input_base . '.in';
3441 my $colon_infile = '';
3442 if ($local ne $input || @secondary_inputs)
3444 $colon_infile = ':' . $input . '.in';
3446 $colon_infile .= ':' . join (':', @secondary_inputs)
3447 if @secondary_inputs;
3449 my @rewritten = &rewrite_inputs_into_dependencies (1, @secondary_inputs);
3451 my ($regen_aclocal_m4, @aclocal_m4_deps) = scan_aclocal_m4 ();
3454 &file_contents ('configure',
3458 => join (' ', @rewritten),
3460 => ((($relative_dir eq '.') ? '$@' : '$(subdir)/$@')
3465 => join (' ', @include_stack),
3469 => $cygnus_mode ? 'cygnus' : $strictness_name,
3471 => $cmdline_use_dependencies ? '' : ' --ignore-deps',
3472 'MAKEFILE-AM-SOURCES'
3473 => "$input$colon_infile",
3475 => $regen_aclocal_m4,
3477 => join (' ', @aclocal_m4_deps)));
3479 if ($relative_dir eq '.')
3481 &push_dist_common ('acconfig.h')
3485 # If we have a configure header, require it.
3486 my @local_fullnames = @config_fullnames;
3487 my @local_names = @config_names;
3489 my $distclean_config = '';
3490 foreach my $one_hdr (@config_headers)
3492 my $one_fullname = shift (@local_fullnames);
3493 my $one_name = shift (@local_names);
3495 my $header_dir = dirname ($one_name);
3497 # If the header is in the current directory we want to build
3498 # the header here. Otherwise, if we're at the topmost
3499 # directory and the header's directory doesn't have a
3500 # Makefile, then we also want to build the header.
3501 if ($relative_dir eq $header_dir
3502 || ($relative_dir eq '.' && ! &is_make_dir ($header_dir)))
3504 my ($cn_sans_dir, $stamp_dir);
3505 if ($relative_dir eq $header_dir)
3507 $cn_sans_dir = basename ($one_name);
3512 $cn_sans_dir = $one_name;
3513 if ($header_dir eq '.')
3519 $stamp_dir = $header_dir . '/';
3523 # Compute relative path from directory holding output
3524 # header to directory holding input header. FIXME:
3525 # doesn't handle case where we have multiple inputs.
3527 if (dirname ($one_hdr) eq $relative_dir)
3529 $ch_sans_dir = basename ($one_hdr);
3533 $ch_sans_dir = backname ($relative_dir) . '/' . $one_hdr;
3536 &require_file_with_conf_line ($config_header_line,
3537 $FOREIGN, $ch_sans_dir);
3539 # Header defined and in this directory.
3541 if (-f $one_name . '.top')
3543 push (@files, "${cn_sans_dir}.top");
3545 if (-f $one_name . '.bot')
3547 push (@files, "${cn_sans_dir}.bot");
3550 &push_dist_common (@files);
3552 # For now, acconfig.h can only appear in the top srcdir.
3553 if (-f 'acconfig.h')
3555 push (@files, '$(top_srcdir)/acconfig.h');
3558 my $stamp_name = 'stamp-h';
3559 $stamp_name .= "${hdr_index}" if scalar (@config_headers) > 1;
3561 my $out_dir = dirname ($ch_sans_dir);
3564 &file_contents ('remake-hdr',
3565 ('FILES' => join (' ', @files),
3566 'CONFIG_HEADER' => $cn_sans_dir,
3567 'CONFIG_HEADER_IN' => $ch_sans_dir,
3568 'CONFIG_HEADER_FULL' => $one_fullname,
3569 'STAMP' => "$stamp_dir$stamp_name",
3570 'SRC_STAMP' => "$out_dir/$stamp_name"));
3572 &create ("${relative_dir}/${out_dir}/${stamp_name}.in");
3573 &require_file_with_conf_line ($config_header_line, $FOREIGN,
3574 "${out_dir}/${stamp_name}.in");
3576 $distclean_config .= ' ' if $distclean_config;
3577 $distclean_config .= $cn_sans_dir;
3581 if ($distclean_config)
3583 $output_rules .= &file_contents ('clean-hdr',
3584 ('FILES' => $distclean_config));
3587 # Set location of mkinstalldirs.
3588 &define_variable ('mkinstalldirs',
3589 ('$(SHELL) ' . $config_aux_dir . '/mkinstalldirs'));
3591 &am_line_error ('CONFIG_HEADER',
3592 "`CONFIG_HEADER' is an anachronism; now determined from `$configure_ac'")
3593 if &variable_defined ('CONFIG_HEADER');
3595 my $config_header = '';
3596 foreach my $one_name (@config_names)
3598 # Generate CONFIG_HEADER define.
3600 if ($relative_dir eq dirname ($one_name))
3602 $one_hdr = basename ($one_name);
3606 $one_hdr = "\$(top_builddir)/${one_name}";
3609 $config_header .= ' ' if $config_header;
3610 $config_header .= $one_hdr;
3614 &define_variable ("CONFIG_HEADER", $config_header);
3617 # Now look for other files in this directory which must be remade
3618 # by config.status, and generate rules for them.
3619 my @actual_other_files = ();
3620 foreach my $lfile (@other_input_files)
3623 my (@inputs, @rewritten_inputs);
3624 my ($need_rewritten);
3625 if ($lfile =~ /^([^:]*):(.*)$/)
3627 # This is the ":" syntax of AC_OUTPUT.
3629 $local = basename ($file);
3630 @inputs = split (':', $2);
3631 @rewritten_inputs = &rewrite_inputs_into_dependencies (1, @inputs);
3632 $need_rewritten = 1;
3638 $local = basename ($file);
3639 @inputs = ($file . '.in');
3641 &rewrite_inputs_into_dependencies (1, @inputs);
3642 $need_rewritten = 0;
3645 # Make sure the dist directory for each input file is created.
3646 # We only have to do this at the topmost level though. This
3647 # is a bit ugly but it easier than spreading out the logic,
3648 # especially in cases like AC_OUTPUT(foo/out:bar/in), where
3649 # there is no Makefile in bar/.
3650 if ($relative_dir eq '.')
3654 $dist_dirs{dirname ($_)} = 1;
3658 # We skip any automake input files, as they are handled
3659 # elsewhere. We also skip files that aren't in this
3660 # directory. However, if the file's directory does not have a
3661 # Makefile, and we are currently doing `.', then we create a
3662 # rule to rebuild the file in the subdir.
3663 next if -f $file . '.am';
3664 my $fd = dirname ($file);
3665 if ($fd ne $relative_dir)
3667 if ($relative_dir eq '.' && ! &is_make_dir ($fd))
3677 # Some users have been tempted to put `stamp-h' in the
3678 # AC_OUTPUT line. This won't do the right thing, so we
3679 # explicitly fail here.
3680 if ($local eq 'stamp-h')
3682 # FIXME: allow real filename.
3683 &am_conf_error ($configure_ac, $ac_output_line,
3684 'stamp-h should not appear in AC_OUTPUT');
3688 $output_rules .= ($local . ': '
3689 . '$(top_builddir)/config.status '
3690 . join (' ', @rewritten_inputs) . "\n"
3692 . 'cd $(top_builddir) && CONFIG_FILES='
3693 . ($relative_dir eq '.' ? '' : '$(subdir)/')
3694 . '$@' . ($need_rewritten
3695 ? (':' . join (':', @inputs))
3697 . ' CONFIG_HEADERS= CONFIG_LINKS= $(SHELL) ./config.status'
3699 push (@actual_other_files, $local);
3701 # Require all input files.
3702 &require_file_with_conf_line ($ac_output_line, $FOREIGN,
3703 &rewrite_inputs_into_dependencies (0, @inputs));
3706 # These files get removed by "make clean".
3707 &define_pretty_variable ('CONFIG_CLEAN_FILES', '', @actual_other_files);
3713 my @r = &am_install_var ('-defaultdist', 'header', 'HEADERS', 'include',
3714 'oldinclude', 'pkginclude',
3718 next unless /\.(.*)$/;
3719 &saw_extension ($1);
3725 return if ! $seen_gettext || $relative_dir ne '.';
3727 if (! &variable_defined ('SUBDIRS'))
3730 ("AM_GNU_GETTEXT used but SUBDIRS not defined");
3734 my @subdirs = &variable_value_as_list ('SUBDIRS', 'all');
3735 &am_line_error ('SUBDIRS',
3736 "AM_GNU_GETTEXT used but `po' not in SUBDIRS")
3737 if ! grep ('po', @subdirs);
3738 &am_line_error ('SUBDIRS',
3739 "AM_GNU_GETTEXT used but `intl' not in SUBDIRS")
3740 if ! grep ('intl', @subdirs);
3742 &require_file_with_conf_line ($ac_gettext_line, $GNU, 'ABOUT-NLS');
3744 # Ensure that each language in ALL_LINGUAS has a .po file, and
3745 # each po file is mentioned in ALL_LINGUAS.
3748 my %linguas = map { $_ => 1 } split (' ', $all_linguas);
3755 &am_line_error ($all_linguas_line,
3756 ("po/$_.po exists but `$_' not in `ALL_LINGUAS'"))
3760 foreach (keys %linguas)
3762 &am_line_error ($all_linguas_line,
3763 "$_ in `ALL_LINGUAS' but po/$_.po does not exist")
3769 &am_error ("AM_GNU_GETTEXT in `$configure_ac' but `ALL_LINGUAS' not defined");
3773 # Handle footer elements.
3776 # NOTE don't use define_pretty_variable here, because
3777 # $contents{...} is already defined.
3778 $output_vars .= 'SOURCES = ' . variable_value ('SOURCES') . "\n\n"
3779 if variable_value ('SOURCES');
3782 &am_line_error ('.SUFFIXES',
3783 "use variable `SUFFIXES', not target `.SUFFIXES'")
3784 if target_defined ('.SUFFIXES');
3786 # Note: AIX 4.1 /bin/make will fail if any suffix rule appears
3787 # before .SUFFIXES. So we make sure that .SUFFIXES appears before
3788 # anything else, by sticking it right after the default: target.
3789 $output_header .= ".SUFFIXES:\n";
3790 if (@suffixes || &variable_defined ('SUFFIXES'))
3792 # Make sure suffixes has unique elements. Sort them to ensure
3793 # the output remains consistent. However, $(SUFFIXES) is
3794 # always at the start of the list, unsorted. This is done
3795 # because make will choose rules depending on the ordering of
3796 # suffixes, and this lets the user have some control. Push
3797 # actual suffixes, and not $(SUFFIXES). Some versions of make
3798 # do not like variable substitutions on the .SUFFIXES line.
3799 my @user_suffixes = (&variable_defined ('SUFFIXES')
3800 ? &variable_value_as_list ('SUFFIXES', '')
3803 my %suffixes = map { $_ => 1 } @suffixes;
3804 delete @suffixes{@user_suffixes};
3806 $output_header .= (".SUFFIXES: "
3807 . join (' ', @user_suffixes, sort keys %suffixes)
3811 $output_trailer .= file_contents ('footer');
3814 # Deal with installdirs target.
3815 sub handle_installdirs ()
3818 &file_contents ('install',
3820 => variable_value ('_am_installdirs') || ''));
3824 # Deal with all and all-am.
3827 my ($makefile) = @_;
3831 # Put this at the beginning for the sake of non-GNU makes. This
3832 # is still wrong if these makes can run parallel jobs. But it is
3834 unshift (@all, basename ($makefile));
3836 foreach my $one_name (@config_names)
3838 push (@all, basename ($one_name))
3839 if dirname ($one_name) eq $relative_dir;
3842 # Install `all' hooks.
3843 if (&target_defined ("all-local"))
3845 push (@all, "all-local");
3846 &depend ('.PHONY', "all-local");
3849 &pretty_print_rule ("all-am:", "\t\t", @all);
3850 &depend ('.PHONY', 'all-am', 'all');
3855 my @local_headers = ();
3856 push @local_headers, '$(BUILT_SOURCES)'
3857 if &variable_defined ('BUILT_SOURCES');
3858 foreach my $one_name (@config_names)
3860 push @local_headers, basename ($one_name)
3861 if dirname ($one_name) eq $relative_dir;
3866 # We need to make sure config.h is built before we recurse.
3867 # We also want to make sure that built sources are built
3868 # before any ordinary `all' targets are run. We can't do this
3869 # by changing the order of dependencies to the "all" because
3870 # that breaks when using parallel makes. Instead we handle
3871 # things explicitly.
3872 $output_all .= ("all: " . join (' ', @local_headers)
3874 . '$(MAKE) $(AM_MAKEFLAGS) '
3875 . (&variable_defined ('SUBDIRS')
3876 ? 'all-recursive' : 'all-am')
3881 $output_all .= "all: " . (&variable_defined ('SUBDIRS')
3882 ? 'all-recursive' : 'all-am') . "\n\n";
3887 # Handle check merge target specially.
3888 sub do_check_merge_target
3890 if (&target_defined ('check-local'))
3892 # User defined local form of target. So include it.
3893 push (@check_tests, 'check-local');
3894 &depend ('.PHONY', 'check-local');
3897 # In --cygnus mode, check doesn't depend on all.
3900 # Just run the local check rules.
3901 &pretty_print_rule ('check-am:', "\t\t", @check);
3905 # The check target must depend on the local equivalent of
3906 # `all', to ensure all the primary targets are built. Then it
3907 # must build the local check rules.
3908 $output_rules .= "check-am: all-am\n";
3909 &pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ",
3913 &pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ",
3917 &depend ('.PHONY', 'check', 'check-am');
3918 $output_rules .= ("check: "
3919 . (&variable_defined ('SUBDIRS')
3920 ? 'check-recursive' : 'check-am')
3924 # Handle all 'clean' targets.
3929 # Don't include `MAINTAINER'; it is handled specially below.
3930 foreach my $name ('MOSTLY', '', 'DIST')
3932 $transform{"${name}CLEAN"} = &variable_defined ("${name}CLEANFILES");
3935 # Built sources are automatically removed by maintainer-clean.
3936 push (@maintainer_clean_files, '$(BUILT_SOURCES)')
3937 if &variable_defined ('BUILT_SOURCES');
3938 push (@maintainer_clean_files, '$(MAINTAINERCLEANFILES)')
3939 if &variable_defined ('MAINTAINERCLEANFILES');
3941 $output_rules .= &file_contents ('clean',
3944 # Join with no space to avoid
3945 # spurious `test -z' success at
3947 => join ('', @maintainer_clean_files),
3949 # A space is required in the join here.
3950 => join (' ', @maintainer_clean_files)));
3954 # &depend ($CATEGORY, @DEPENDENDEES)
3955 # ----------------------------------
3956 # The target $CATEGORY depends on @DEPENDENDEES.
3959 my ($category, @dependendees) = @_;
3961 push (@{$dependencies{$category}}, @dependendees);
3966 # &target_cmp ($A, $B)
3967 # --------------------
3968 # Subroutine for &handle_factored_dependencies to let `.PHONY' be last.
3981 # &handle_factored_dependencies ()
3982 # --------------------------------
3983 # Handle everything related to gathered targets.
3984 sub handle_factored_dependencies
3987 foreach my $utarg ('uninstall-data-local', 'uninstall-data-hook',
3988 'uninstall-exec-local', 'uninstall-exec-hook')
3990 if (&target_defined ($utarg))
3993 $x =~ s/(data|exec)-//;
3994 &am_line_error ($utarg, "use `$x', not `$utarg'");
3998 if (&target_defined ('install-local'))
4000 &am_line_error ('install-local',
4001 "use `install-data-local' or `install-exec-local', "
4002 . "not `install-local'");
4005 if (!defined $options{'no-installinfo'}
4006 && &target_defined ('install-info-local'))
4008 &am_line_error ('install-info-local',
4009 "`install-info-local' target defined but "
4010 . "`no-installinfo' option not in use");
4013 # Install the -local hooks.
4014 foreach (keys %dependencies)
4016 # Hooks are installed on the -am targets.
4018 if (&target_defined ("$_-local"))
4020 depend ("$_-am", "$_-local");
4021 &depend ('.PHONY', "$_-local");
4025 # Install the -hook hooks.
4026 # FIXME: Why not be as liberal as we are with -local hooks?
4027 foreach ('install-exec', 'install-data')
4029 if (&target_defined ("$_-hook"))
4031 $actions{"$_-am"} .=
4032 ("\t\@\$(NORMAL_INSTALL)\n"
4033 . "\t" . '$(MAKE) $(AM_MAKEFLAGS) ' . "$_-hook\n");
4037 # All the required targets are phony.
4038 depend ('.PHONY', keys %required_targets);
4040 # Actually output gathered targets.
4041 foreach (sort target_cmp keys %dependencies)
4043 # If there is nothing about this guy, skip it.
4045 unless (@{$dependencies{$_}}
4047 || $required_targets{$_});
4048 &pretty_print_rule ("$_:", "\t",
4049 uniq (sort @{$dependencies{$_}}));
4050 $output_rules .= $actions{$_}
4051 if defined $actions{$_};
4052 $output_rules .= "\n";
4057 # &handle_tests_dejagnu ()
4058 # ------------------------
4059 sub handle_tests_dejagnu
4061 push (@check_tests, 'check-DEJAGNU');
4063 # Only create site.exp rule if user hasn't already written one.
4065 file_contents ('dejagnu', ('SITE-EXP' => ! target_defined ('site.exp')));
4069 # Handle TESTS variable and other checks.
4072 if (defined $options{'dejagnu'})
4074 &handle_tests_dejagnu;
4078 foreach my $c ('DEJATOOL', 'RUNTEST', 'RUNTESTFLAGS')
4081 "`$c' defined but `dejagnu' not in `AUTOMAKE_OPTIONS'")
4082 if &variable_defined ($c);
4086 if (&variable_defined ('TESTS'))
4088 push (@check_tests, 'check-TESTS');
4089 $output_rules .= &file_contents ('check');
4093 # Handle Emacs Lisp.
4094 sub handle_emacs_lisp
4096 my @elfiles = &am_install_var ('-candist', 'lisp', 'LISP',
4099 return if ! @elfiles;
4101 # Generate .elc files.
4102 my @elcfiles = map { $_ . 'c' } @elfiles;
4103 &define_pretty_variable ('ELCFILES', '', @elcfiles);
4105 push (@all, '$(ELCFILES)');
4107 &am_error ("`lisp_LISP' defined but `AM_PATH_LISPDIR' not in `$configure_ac'")
4108 if ! $seen_lispdir && &variable_defined ('lisp_LISP');
4110 &require_file_with_conf_line ('AM_PATH_LISPDIR', $FOREIGN, 'elisp-comp');
4116 my @pyfiles = &am_install_var ('-defaultdist', 'python', 'PYTHON',
4117 'python', 'noinst');
4118 return if ! @pyfiles;
4120 # Found some python.
4121 &am_error ("`python_PYTHON' defined but `AM_PATH_PYTHON' not in `$configure_ac'")
4122 if ! $seen_pythondir && &variable_defined ('python_PYTHON');
4124 &require_file_with_conf_line ('AM_PATH_PYTHON', $FOREIGN, 'py-compile');
4125 &define_variable ('py_compile', $config_aux_dir . '/py-compile');
4131 my @sourcelist = &am_install_var ('-candist',
4133 'java', 'noinst', 'check');
4134 return if ! @sourcelist;
4136 my %valid = &am_primary_prefixes ('JAVA', 1,
4137 'java', 'noinst', 'check');
4140 foreach my $curs (keys %valid)
4142 if (! &variable_defined ($curs . '_JAVA') || $curs eq 'EXTRA')
4149 &am_line_error ($curs . '_JAVA',
4150 "multiple _JAVA primaries in use");
4155 push (@all, 'class' . $dir . '.stamp');
4159 # Handle some of the minor options.
4160 sub handle_minor_options
4162 if (defined $options{'readme-alpha'})
4164 if ($relative_dir eq '.')
4166 if ($package_version !~ /^$GNITS_VERSION_PATTERN$/)
4168 # FIXME: allow real filename.
4169 &am_conf_line_error ($configure_ac,
4170 $package_version_line,
4171 "version `$package_version' doesn't follow Gnits standards");
4173 elsif (defined $1 && -f 'README-alpha')
4175 # This means we have an alpha release. See
4176 # GNITS_VERSION_PATTERN for details.
4177 &require_file ($FOREIGN, 'README-alpha');
4183 ################################################################
4186 my @make_input_list;
4187 # &scan_autoconf_config_files ($CONFIG-FILES)
4188 # -------------------------------------------
4189 # Study $CONFIG-FILES which is the first argument to AC_CONFIG_FILES
4191 sub scan_autoconf_config_files
4193 my ($config_files) = @_;
4194 # Look at potential Makefile.am's.
4195 foreach (split ' ', $config_files)
4197 # Must skip empty string for Perl 4.
4198 next if $_ eq "\\" || $_ eq '';
4200 # Handle $local:$input syntax. Note that we ignore
4201 # every input file past the first, though we keep
4202 # those around for later.
4203 my ($local, $input, @rest) = split (/:/);
4210 # FIXME: should be error if .in is missing.
4211 $input =~ s/\.in$//;
4214 if (-f $input . '.am')
4216 # We have a file that automake should generate.
4217 push (@make_input_list, $input);
4218 $make_list{$input} = join (':', ($local, @rest));
4222 # We have a file that automake should cause to be
4223 # rebuilt, but shouldn't generate itself.
4224 push (@other_input_files, $_);
4230 # &scan_autoconf_traces ($FILENAME)
4231 # ---------------------------------
4232 # FIXME: For the time being, we don't care about the FILENAME.
4233 sub scan_autoconf_traces
4235 my ($filename) = @_;
4237 my $traces = "$ENV{amtraces} ";
4239 $traces .= ' -t AC_CONFIG_FILES';
4240 $traces .= ' -t AC_LIBSOURCE';
4241 $traces .= ' -t AC_SUBST';
4243 my $tracefh = new IO::File ("$traces |");
4246 die "$me: couldn't open `$traces': $!\n";
4248 print "$me: reading $traces\n" if $verbose;
4250 while ($_ = $tracefh->getline)
4253 my ($file, $line, $macro, @args) = split /:/;
4254 my $here = "$file:$line";
4256 # Alphabetical ordering please.
4257 if ($macro eq 'AC_CONFIG_FILES')
4259 # Look at potential Makefile.am's.
4260 &scan_autoconf_config_files ($args[0]);
4262 elsif ($macro eq 'AC_LIBSOURCE')
4264 my $source = "$args[0].c";
4265 # We should actually also `close' the sources: getopt.c
4266 # wants getopt.h etc. But actually it should be done in the
4267 # macro itself, i.e., we have to first fix Autoconf to extend
4268 # _AC_LIBOBJ_DECL and use it the in various macros.
4269 if (!defined $libsources{$source})
4271 print STDERR "traces: discovered $source\n";
4272 $libsources{$source} = $here;
4275 elsif ($macro eq 'AC_SUBST')
4277 if (!defined $configure_vars{$args[0]})
4279 print STDERR "traces: discovered AC_SUBST($args[0])\n";
4280 $configure_vars{$args[0]} = $here;
4286 || die "$me: close: $traces: $!\n";
4290 # &scan_one_autoconf_file ($FILENAME)
4291 # -----------------------------------
4292 # Scan one file for interesting things. Subroutine of
4293 # &scan_autoconf_files.
4294 sub scan_one_autoconf_file
4296 my ($filename) = @_;
4298 my $configfh = new IO::File ("< $filename");
4301 die "$me: couldn't open `$filename': $!\n";
4303 print "$me: reading $filename\n" if $verbose;
4305 my ($in_ac_output, $in_ac_replace) = (0, 0);
4306 while ($_ = $configfh->getline)
4308 # Remove comments from current line.
4312 # Skip macro definitions. Otherwise we might be confused into
4313 # thinking that a macro that was only defined was actually
4317 # Follow includes. This is a weirdness commonly in use at
4318 # Cygnus and hopefully nowhere else.
4319 if (/sinclude\((.*)\)/ && -f $1)
4321 # $_ being local, if we don't preserve it, when coming
4322 # back we will have $_ undefined, which is bad for the
4323 # the rest of this routine.
4324 my $underscore = $_;
4325 &scan_one_autoconf_file ($1);
4329 # Populate libobjs array.
4330 if (/AC_FUNC_ALLOCA/)
4332 $libsources{'alloca.c'} = 1;
4334 elsif (/AC_FUNC_GETLOADAVG/)
4336 $libsources{'getloadavg.c'} = 1;
4338 elsif (/AC_FUNC_MEMCMP/)
4340 $libsources{'memcmp.c'} = 1;
4342 elsif (/AC_STRUCT_ST_BLOCKS/)
4344 $libsources{'fileblocks.c'} = 1;
4346 elsif (/A[CM]_REPLACE_GNU_GETOPT/)
4348 $libsources{'getopt.c'} = 1;
4349 $libsources{'getopt1.c'} = 1;
4351 elsif (/AM_FUNC_STRTOD/)
4353 $libsources{'strtod.c'} = 1;
4355 elsif (/AM_WITH_REGEX/)
4357 $libsources{'rx.c'} = 1;
4358 $libsources{'rx.h'} = 1;
4359 $libsources{'regex.c'} = 1;
4360 $libsources{'regex.h'} = 1;
4362 elsif (/AC_FUNC_MKTIME/)
4364 $libsources{'mktime.c'} = 1;
4366 elsif (/AM_FUNC_ERROR_AT_LINE/)
4368 $libsources{'error.c'} = 1;
4369 $libsources{'error.h'} = 1;
4371 elsif (/AM_FUNC_OBSTACK/)
4373 $libsources{'obstack.c'} = 1;
4374 $libsources{'obstack.h'} = 1;
4376 elsif (/LIBOBJS="(.*)\s+\$LIBOBJS"/
4377 || /LIBOBJS="\$LIBOBJS\s+(.*)"/)
4379 foreach my $libobj_iter (split (' ', $1))
4381 if ($libobj_iter =~ /^(.*)\.o(bj)?$/
4382 || $libobj_iter =~ /^(.*)\.\$ac_objext$/
4383 || $libobj_iter =~ /^(.*)\.\$\{ac_objext\}$/)
4385 $libsources{$1 . '.c'} = 1;
4389 elsif (/AC_LIBOBJ\(([^)]+)\)/)
4391 $libsources{"$1.c"} = 1;
4394 if (! $in_ac_replace && s/AC_REPLACE_FUNCS\s*\(\[?//)
4400 $in_ac_replace = 0 if s/[\]\)].*$//;
4401 # Remove trailing backslash.
4405 # Need to skip empty elements for Perl 4.
4407 $libsources{$_ . '.c'} = 1;
4411 if (/$obsolete_rx/o)
4414 if ($obsolete_macros{$1} ne '')
4416 $hint = '; ' . $obsolete_macros{$1};
4418 &am_conf_line_error ($filename, $., "`$1' is obsolete$hint");
4421 # Process the AC_OUTPUT and AC_CONFIG_FILES macros.
4422 if (! $in_ac_output && s/AC_(OUTPUT|CONFIG_FILES)\s*\(\[?//)
4425 $ac_output_line = $.;
4436 # Look at potential Makefile.am's.
4437 &scan_autoconf_config_files ($_);
4439 if ($closing && @make_input_list == 0 && @other_input_files == 0)
4441 &am_conf_line_error ($filename, $ac_output_line,
4442 "No files mentioned in `AC_OUTPUT'");
4447 if (/$AC_CONFIG_AUX_DIR_PATTERN/o)
4449 @config_aux_path = &unquote_m4_arg ($1);
4450 $config_aux_dir_set_in_configure_in = 1;
4453 # Check for ansi2knr.
4454 $am_c_prototypes = 1 if /AM_C_PROTOTYPES/;
4456 # Check for exe extension stuff.
4460 $configure_vars{'EXEEXT'} = $filename . ':' . $.;
4466 $configure_vars{'OBJEXT'} = $filename . ':' . $.;
4469 # Check for `-c -o' code.
4470 $seen_cc_c_o = 1 if /AM_PROG_CC_C_O/;
4472 # Check for NLS support.
4473 if (/AM_GNU_GETTEXT/)
4476 $ac_gettext_line = $.;
4479 # Look for ALL_LINGUAS.
4480 if (/ALL_LINGUAS="(.*)"$/ || /ALL_LINGUAS=(.*)$/)
4484 $all_linguas_line = $.;
4487 # Handle configuration headers. A config header of `[$1]'
4488 # means we are actually scanning AM_CONFIG_HEADER from
4490 if (/A([CM])_CONFIG_HEADERS?\s*\((.*)\)/
4494 ($filename, $., "`automake requires `AM_CONFIG_HEADER', not `AC_CONFIG_HEADER'")
4497 $config_header_line = $.;
4498 foreach my $one_hdr (split (' ', &unquote_m4_arg ($2)))
4500 push (@config_fullnames, $one_hdr);
4501 if ($one_hdr =~ /^([^:]+):(.+)$/)
4503 push (@config_names, $1);
4504 push (@config_headers, $2);
4508 push (@config_names, $one_hdr);
4509 push (@config_headers, $one_hdr . '.in');
4514 # Handle AC_CANONICAL_*. Always allow upgrading to
4515 # AC_CANONICAL_SYSTEM, but never downgrading.
4516 $seen_canonical = $AC_CANONICAL_HOST
4517 if ! $seen_canonical
4518 && (/AC_CANONICAL_HOST/ || /AC_CHECK_TOOL/);
4519 $seen_canonical = $AC_CANONICAL_SYSTEM if /AC_CANONICAL_SYSTEM/;
4521 # If using X, include some extra variable definitions. NOTE
4522 # we don't want to force these into CFLAGS or anything,
4523 # because not all programs will necessarily use X.
4526 foreach my $var ('X_CFLAGS', 'X_LIBS', 'X_EXTRA_LIBS',
4529 $configure_vars{$var} = $filename . ':' . $.
4533 # This macro handles several different things.
4534 if (/$AM_INIT_AUTOMAKE_PATTERN/o)
4536 ($package_version = $1) =~ s/$AM_PACKAGE_VERSION_PATTERN/$1/o;
4537 $package_version_line = $.;
4538 $seen_init_automake = 1;
4543 $configure_vars{'LEX'} = $filename . ':' . $.;
4544 $seen_decl_yytext = 1;
4546 if (/AC_DECL_YYTEXT/ && $filename =~ /configure\.(ac|in)$/)
4548 &am_conf_line_warning ($filename, $., "`AC_DECL_YYTEXT' is covered by `AM_PROG_LEX'");
4550 if (/AC_PROG_LEX/ && $filename =~ /configure\.(ac|in)$/)
4552 &am_conf_line_warning ($filename, $., "automake requires `AM_PROG_LEX', not `AC_PROG_LEX'");
4555 if (/AC_PROG_(F77|YACC|RANLIB|CC|CXXCPP|CXX|LEX|AWK|CPP|LN_S)/)
4557 $configure_vars{$1} = $filename . ':' . $.;
4559 if (/$AC_CHECK_PATTERN/o)
4561 $configure_vars{$3} = $filename . ':' . $.;
4563 if (/$AM_MISSING_PATTERN/o
4567 && $1 ne 'AUTOHEADER'
4568 # AM_INIT_AUTOMAKE is AM_MISSING_PROG'ing MAKEINFO. But
4569 # we handle it elsewhere.
4570 && $1 ne 'MAKEINFO')
4572 $configure_vars{$1} = $filename . ':' . $.;
4575 # Explicitly avoid ANSI2KNR -- we AC_SUBST that in protos.m4,
4576 # but later define it elsewhere. This is pretty hacky. We
4577 # also explicitly avoid INSTALL_SCRIPT and some other
4578 # variables because they are defined in header-vars.am.
4580 if (/$AC_SUBST_PATTERN/o
4582 && $1 ne 'INSTALL_SCRIPT'
4583 && $1 ne 'INSTALL_DATA')
4585 $configure_vars{$1} = $filename . ':' . $.;
4588 $seen_decl_yytext = 1 if /AC_DECL_YYTEXT/;
4589 if (/AM_MAINTAINER_MODE/)
4591 $seen_maint_mode = 1;
4592 $configure_cond{'MAINTAINER_MODE'} = 1;
4595 $seen_lispdir = 1 if /AM_PATH_LISPDIR/;
4597 if (/AM_PATH_PYTHON/)
4599 $seen_pythondir = 1;
4600 $configure_vars{'pythondir'} = $filename . ':' . $.;
4601 $configure_vars{'PYTHON'} = $filename . ':' . $.;
4604 if (/A(C|M)_PROG_LIBTOOL/)
4606 # We're not ready for this yet. People still use a
4607 # libtool with no AC_PROG_LIBTOOL. Once that is the
4608 # dominant version we can reenable this code -- but next
4609 # time by mentioning the macro in %obsolete_macros, both
4610 # here and in aclocal.in.
4612 # if (/AM_PROG_LIBTOOL/)
4614 # &am_conf_line_warning ($filename, $., "`AM_PROG_LIBTOOL' is obsolete, use `AC_PROG_LIBTOOL' instead");
4618 $configure_vars{'LIBTOOL'} = $filename . ':' . $.;
4619 $configure_vars{'RANLIB'} = $filename . ':' . $.;
4620 $configure_vars{'CC'} = $filename . ':' . $.;
4621 # AC_PROG_LIBTOOL runs AC_CANONICAL_HOST. Make sure we
4622 # never downgrade (if we've seen AC_CANONICAL_SYSTEM).
4623 $seen_canonical = $AC_CANONICAL_HOST if ! $seen_canonical;
4626 $seen_multilib = 1 if (/AM_ENABLE_MULTILIB/);
4628 if (/$AM_CONDITIONAL_PATTERN/o)
4630 $configure_cond{$1} = 1;
4633 # Check for Fortran 77 intrinsic and run-time libraries.
4634 if (/AC_F77_LIBRARY_LDFLAGS/)
4636 $configure_vars{'FLIBS'} = $filename . ':' . $.;
4644 # &scan_autoconf_files ()
4645 # -----------------------
4646 # Check whether we use `configure.ac' or `configure.in'.
4647 # Scan it (and possibly `aclocal.m4') for interesting things.
4648 # We must scan aclocal.m4 because there might be AC_SUBSTs and such there.
4649 sub scan_autoconf_files
4651 # Reinitialize libsources here. This isn't really necessary,
4652 # since we currently assume there is only one configure.ac. But
4653 # that won't always be the case.
4656 warn "$me: both `configure.ac' and `configure.in' present:"
4657 . " ignoring `configure.in'\n"
4658 if -f 'configure.ac' && -f 'configure.in';
4659 $configure_ac = 'configure.in'
4660 if -f 'configure.in';
4661 $configure_ac = 'configure.ac'
4662 if -f 'configure.ac';
4663 die "$me: `configure.ac' or `configure.in' is required\n"
4666 &scan_one_autoconf_file ($configure_ac);
4667 &scan_one_autoconf_file ('aclocal.m4')
4670 if (defined $ENV{'amtraces'})
4672 warn '$me: Autoconf traces is an experimental feature';
4673 warn '$me: use at your own risks';
4675 &scan_autoconf_traces ($configure_ac);
4678 # Set input and output files if not specified by user.
4681 @input_files = @make_input_list;
4682 %output_files = %make_list;
4685 @configure_input_files = @make_input_list;
4687 &am_conf_error ("`AM_INIT_AUTOMAKE' must be used")
4688 if ! $seen_init_automake;
4690 # Look for some files we need. Always check for these. This
4691 # check must be done for every run, even those where we are only
4692 # looking at a subdir Makefile. We must set relative_dir so that
4693 # the file-finding machinery works.
4694 # FIXME: Is this broken because it needs dynamic scopes.
4695 # My tests seems to show it's not the case.
4696 $relative_dir = '.';
4697 &require_config_file ($FOREIGN, 'install-sh', 'mkinstalldirs', 'missing');
4698 &am_error ("`install.sh' is an anachronism; use `install-sh' instead")
4699 if -f $config_aux_path[0] . '/install.sh';
4701 &require_config_file ($FOREIGN, 'py-compile')
4704 # Preserve dist_common for later.
4705 $configure_dist_common = variable_value ('DIST_COMMON', 'TRUE') || '';
4708 ################################################################
4710 # Set up for Cygnus mode.
4713 return unless $cygnus_mode;
4715 &set_strictness ('foreign');
4716 $options{'no-installinfo'} = 1;
4717 $options{'no-dependencies'} = 1;
4718 $use_dependencies = 0;
4720 if (! $seen_maint_mode)
4722 &am_conf_error ("`AM_MAINTAINER_MODE' required when --cygnus specified");
4726 # Do any extra checking for GNU standards.
4727 sub check_gnu_standards
4729 if ($relative_dir eq '.')
4731 # In top level (or only) directory.
4732 &require_file ($GNU, 'INSTALL', 'NEWS', 'README', 'COPYING',
4733 'AUTHORS', 'ChangeLog');
4736 if ($strictness >= $GNU
4737 && defined $options{'no-installman'})
4739 &am_line_error ('AUTOMAKE_OPTIONS',
4740 "option `no-installman' disallowed by GNU standards");
4743 if ($strictness >= $GNU
4744 && defined $options{'no-installinfo'})
4746 &am_line_error ('AUTOMAKE_OPTIONS',
4747 "option `no-installinfo' disallowed by GNU standards");
4751 # Do any extra checking for GNITS standards.
4752 sub check_gnits_standards
4754 if ($relative_dir eq '.')
4756 # In top level (or only) directory.
4757 &require_file ($GNITS, 'THANKS');
4761 ################################################################
4763 # Functions to handle files of each language.
4765 # Each `lang_X_rewrite($DIRECTORY, $BASE, $EXT)' function follows a
4766 # simple formula: Return value is $LANG_SUBDIR if the resulting object
4767 # file should be in a subdir if the source file is, $LANG_PROCESS if
4768 # file is to be dealt with, $LANG_IGNORE otherwise.
4770 # Much of the actual processing is handled in
4771 # handle_single_transform_list. These functions exist so that
4772 # auxiliary information can be recorded for a later cleanup pass.
4773 # Note that the calls to these functions are computed, so don't bother
4774 # searching for their precise names in the source.
4776 # This is just a convenience function that can be used to determine
4777 # when a subdir object should be used.
4780 return defined $options{'subdir-objects'} ? $LANG_SUBDIR : $LANG_PROCESS;
4783 # Rewrite a single C source file.
4786 my ($directory, $base, $ext) = @_;
4788 if (defined $options{'ansi2knr'} && $base =~ /_$/)
4790 # FIXME: include line number in error.
4791 &am_error ("C source file `$base.c' would be deleted by ansi2knr rules");
4794 my $r = $LANG_PROCESS;
4795 if (defined $options{'subdir-objects'})
4798 $base = $directory . '/' . $base;
4802 # Only give error once.
4804 # FIXME: line number.
4805 &am_error ("C objects in subdir but `AM_PROG_CC_C_O' not in `$configure_ac'");
4808 &require_file ($FOREIGN, 'compile')
4809 if $relative_dir eq '.';
4812 $de_ansi_files{$base} = 1;
4816 # Rewrite a single C++ source file.
4817 sub lang_cxx_rewrite
4819 return &lang_sub_obj;
4822 # Rewrite a single header file.
4823 sub lang_header_rewrite
4825 # Header files are simply ignored.
4826 return $LANG_IGNORE;
4829 # Rewrite a single yacc file.
4830 sub lang_yacc_rewrite
4832 my ($directory, $base, $ext) = @_;
4834 my $r = &lang_c_rewrite ($directory, $base, $ext);
4836 if ($r == $LANG_SUBDIR)
4838 $pfx = $directory . '/';
4840 $yacc_sources{$pfx . $base . '.' . $ext} = 1;
4842 &saw_extension ('c');
4844 &push_dist_common ($pfx . $base . '.' . $ext);
4848 # Rewrite a single yacc++ file.
4849 sub lang_yaccxx_rewrite
4851 my ($directory, $base, $ext) = @_;
4853 my $r = $LANG_PROCESS;
4855 if (defined $options{'subdir-objects'})
4857 $pfx = $directory . '/';
4860 $yacc_sources{$pfx . $base . '.' . $ext} = 1;
4862 &saw_extension ($ext);
4864 &push_dist_common ($pfx . $base . '.' . $ext);
4868 # Rewrite a single lex file.
4869 sub lang_lex_rewrite
4871 my ($directory, $base, $ext) = @_;
4873 my $r = &lang_c_rewrite ($directory, $base, $ext);
4875 if ($r == $LANG_SUBDIR)
4877 $pfx = $directory . '/';
4879 $lex_sources{$pfx . $base . '.' . $ext} = 1;
4881 &saw_extension ('c');
4883 &push_dist_common ($pfx . $base . '.' . $ext);
4887 # Rewrite a single lex++ file.
4888 sub lang_lexxx_rewrite
4890 my ($directory, $base, $ext) = @_;
4892 my $r = $LANG_PROCESS;
4894 if (defined $options{'subdir-objects'})
4896 $pfx = $directory . '/';
4899 $lex_sources{$pfx . $base . '.' . $ext} = 1;
4901 &saw_extension ($ext);
4903 &push_dist_common ($pfx . $base . '.' . $ext);
4907 # Rewrite a single assembly file.
4908 sub lang_asm_rewrite
4910 return &lang_sub_obj;
4913 # Rewrite a single Fortran 77 file.
4914 sub lang_f77_rewrite
4916 return $LANG_PROCESS;
4919 # Rewrite a single preprocessed Fortran 77 file.
4920 sub lang_ppf77_rewrite
4922 return $LANG_PROCESS;
4925 # Rewrite a single ratfor file.
4926 sub lang_ratfor_rewrite
4928 return $LANG_PROCESS;
4931 # Rewrite a single Objective C file.
4932 sub lang_objc_rewrite
4934 return &lang_sub_obj;
4937 # Rewrite a single Java file.
4938 sub lang_java_rewrite
4940 return $LANG_SUBDIR;
4943 # The lang_X_finish functions are called after all source file
4944 # processing is done. Each should handle defining rules for the
4945 # language, etc. A finish function is only called if a source file of
4946 # the appropriate type has been seen.
4950 # Push all libobjs files onto de_ansi_files. We actually only
4951 # push files which exist in the current directory, and which are
4952 # genuine source files.
4953 foreach my $file (keys %libsources)
4955 if ($file =~ /^(.*)\.[cly]$/ && -f "$relative_dir/$file")
4957 $de_ansi_files{$1} = 1;
4961 if (defined $options{'ansi2knr'} && keys %de_ansi_files)
4963 # Make all _.c files depend on their corresponding .c files.
4965 foreach my $base (sort keys %de_ansi_files)
4967 # Each _.c file must depend on ansi2knr; otherwise it
4968 # might be used in a parallel build before it is built.
4969 # We need to support files in the srcdir and in the build
4970 # dir (because these files might be auto-generated. But
4971 # we can't use $< -- some makes only define $< during a
4973 $output_rules .= ($base . "_.c: $base.c \$(ANSI2KNR)\n\t"
4974 . '$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) '
4975 . '`if test -f $(srcdir)/' . $base . '.c'
4976 . '; then echo $(srcdir)/' . $base . '.c'
4977 . '; else echo ' . $base . '.c; fi` '
4978 . "| sed 's/^# \\([0-9]\\)/#line \\1/' "
4979 . '| $(ANSI2KNR) > ' . $base . "_.c"
4980 # If ansi2knr fails then we shouldn't
4981 # create the _.c file
4982 . " || rm -f ${base}_.c\n");
4983 push (@objects, $base . '_.$(OBJEXT)');
4984 push (@objects, $base . '_.lo')
4988 # Make all _.o (and _.lo) files depend on ansi2knr.
4989 # Use a sneaky little hack to make it print nicely.
4990 &pretty_print_rule ('', '', @objects, ':', '$(ANSI2KNR)');
4995 # This is a helper for both lex and yacc.
4996 sub yacc_lex_finish_helper
4998 return if defined $language_scratch{'lex-yacc-done'};
4999 $language_scratch{'lex-yacc-done'} = 1;
5001 # If there is more than one distinct yacc (resp lex) source file
5002 # in a given directory, then the `ylwrap' program is required to
5003 # allow parallel builds to work correctly. FIXME: for now, no
5005 &require_config_file ($FOREIGN, 'ylwrap');
5006 if ($config_aux_dir_set_in_configure_in)
5008 &define_variable ('YLWRAP', $config_aux_dir . "/ylwrap");
5012 &define_variable ('YLWRAP', '$(srcdir)/ylwrap');
5016 sub lang_yacc_finish
5018 return if defined $language_scratch{'yacc-done'};
5019 $language_scratch{'yacc-done'} = 1;
5021 my %seen_suffix = ();
5022 my @yacc_files = sort keys %yacc_sources;
5023 my $yacc_count = scalar (@yacc_files);
5024 foreach my $file (@yacc_files)
5027 &output_yacc_build_rule ($1, $yacc_count > 1)
5028 if ! defined $seen_suffix{$1};
5029 $seen_suffix{$1} = 1;
5031 $file =~ /^(.*)\.(y|yy|y\+\+|yxx|ypp)$/;
5033 my $hname = 'h'; # Always use `.h' for header file.
5037 if ((&variable_defined ('AM_YFLAGS')
5038 && &variable_value ('AM_YFLAGS') =~ /(^|\s)-d(\s|$)/)
5039 || (&variable_defined ('YFLAGS')
5040 && &variable_value ('YFLAGS') =~ /(^|\s)-d(\s|$)/)) {
5041 # Now generate rule to make the header file. This should only
5042 # be generated if `yacc -d' specified.
5043 $output_rules .= "${base}.${hname}: ${base}.${cname}\n";
5045 # If the files are built in the build directory, then we want
5046 # to remove them with `make clean'. If they are in srcdir
5047 # they shouldn't be touched. However, we can't determine this
5048 # statically, and the GNU rules say that yacc/lex output files
5049 # should be removed by maintainer-clean. So that's what we
5051 push (@maintainer_clean_files, "${base}.${hname}");
5053 &push_dist_common ("${base}.${hname}");
5055 push (@maintainer_clean_files, "${base}.${cname}");
5057 $output_rules .= "\n";
5059 if (&variable_defined ('YACCFLAGS'))
5061 &am_line_error ('YACCFLAGS',
5062 "`YACCFLAGS' obsolete; use `YFLAGS' instead");
5065 if ($yacc_count > 1)
5067 &yacc_lex_finish_helper;
5074 return if defined $language_scratch{'lex-done'};
5075 $language_scratch{'lex-done'} = 1;
5077 my %seen_suffix = ();
5078 my $lex_count = scalar (keys %lex_sources);
5079 foreach my $file (sort keys %lex_sources)
5082 &output_lex_build_rule ($1, $lex_count > 1)
5083 if (! defined $seen_suffix{$1});
5084 $seen_suffix{$1} = 1;
5086 # If the files are built in the build directory, then we want
5087 # to remove them with `make clean'. If they are in srcdir
5088 # they shouldn't be touched. However, we can't determine this
5089 # statically, and the GNU rules say that yacc/lex output files
5090 # should be removed by maintainer-clean. So that's what we
5092 $file =~ /^(.*)\.(l|ll|l\+\+|lxx|lpp)$/;
5094 ($cname = $2) =~ tr/l/c/;
5095 push (@maintainer_clean_files, "${1}.${cname}");
5098 if (! $seen_decl_yytext)
5100 &am_error ("lex source seen but `AC_DECL_YYTEXT' not in `$configure_ac'");
5105 &yacc_lex_finish_helper;
5110 # Given a hash table of linker names, pick the name that has the most
5111 # precedence. This is lame, but something has to have global
5112 # knowledge in order to eliminate the conflict. Add more linkers as
5119 if defined $linkers{'GCJLINK'};
5121 if defined $linkers{'CXXLINK'};
5123 if defined $linkers{'F77LINK'};
5125 if defined $linkers{'OBJCLINK'};
5129 # Called to indicate that an extension was used.
5133 $extension_seen{$ext} = 1;
5136 # Called to ask whether source files have been seen . If HEADERS is 1,
5137 # headers can be included.
5148 $headers = grep ($extension_seen{$_},
5149 @{$languages{'header'}->extensions});
5152 return scalar keys %extension_seen > $headers;
5156 # register_language (%ATTRIBUTE)
5157 # ------------------------------
5158 # Register a single language.
5159 # Each %ATTRIBUTE is of the form ATTRIBUTE => VALUE.
5160 sub register_language (%)
5166 unless defined $option{'ansi'};
5167 $option{'autodep'} = 'no'
5168 unless defined $option{'autodep'};
5169 $option{'derived_autodep'} = 'no'
5170 unless defined $option{'derived_autodep'};
5171 $option{'linker'} = ''
5172 unless defined $option{'linker'};
5174 my $lang = new Language (%option);
5177 grep ($extension_map{$_} = $lang->name, @{$lang->extensions});
5178 $languages{$lang->name} = $lang;
5181 # This function is used to find a path from a user-specified suffix to
5182 # `o' or to some other suffix we recognize internally, eg `cc'.
5185 my ($source_ext) = @_;
5187 # FIXME: hard-coding `o' is a mistake. Doing something
5188 # intelligent is harder.
5189 while ($extension_map{$source_ext} eq ''
5190 && $source_ext ne 'o'
5191 && defined $suffix_rules{$source_ext})
5193 $source_ext = $suffix_rules{$source_ext};
5200 ################################################################
5202 # Pretty-print something. HEAD is what should be printed at the
5203 # beginning of the first line, FILL is what should be printed at the
5204 # beginning of every subsequent line.
5205 sub pretty_print_internal
5207 my ($head, $fill, @values) = @_;
5209 my $column = length ($head);
5212 # Fill length is number of characters. However, each Tab
5213 # character counts for eight. So we count the number of Tabs and
5215 my $fill_length = length ($fill);
5216 $fill_length += 7 * ($fill =~ tr/\t/\t/d);
5220 # "71" because we also print a space.
5221 if ($column + length ($_) > 71)
5223 $result .= " \\\n" . $fill;
5224 $column = $fill_length;
5226 $result .= ' ' if $result =~ /\S\z/;
5228 $column += length ($_) + 1;
5235 # Pretty-print something and append to output_vars.
5238 $output_vars .= &pretty_print_internal (@_);
5241 # Pretty-print something and append to output_rules.
5242 sub pretty_print_rule
5244 $output_rules .= &pretty_print_internal (@_);
5248 ################################################################
5252 # &conditional_string(@COND-STACK)
5253 # --------------------------------
5255 sub conditional_string
5259 if (grep (/^FALSE$/, @stack))
5265 return join (' ', uniq sort grep (!/^TRUE$/, @stack));
5271 # &conditional_true_when ($COND, $WHEN)
5272 # -------------------------------------
5273 # See if a conditional is true. Both arguments are conditional
5274 # strings. This returns true if the first conditional is true when
5275 # the second conditional is true.
5276 # For instance with $COND = `BAR FOO', and $WHEN = `BAR BAZ FOO',
5277 # obviously return 1, and 0 when, for instance, $WHEN = `FOO'.
5278 sub conditional_true_when ($$)
5280 my ($cond, $when) = @_;
5282 # Make a hash holding all the values from $WHEN.
5283 my %cond_vals = map { $_ => 1 } split (' ', $when);
5285 # Check each component of $cond, which looks `COND1 COND2'.
5286 foreach my $comp (split (' ', $cond))
5288 # TRUE is always true.
5289 next if $comp eq 'TRUE';
5290 return 0 if ! defined $cond_vals{$comp};
5298 # &conditionals_true_when (@CONDS, @WHENS)
5299 # ----------------------------------------
5300 # Same as above, but true if all the @CONDS are true when *ALL*
5301 # the @WHENS are sufficient.
5303 # If there are no @CONDS, then return true, of course. *BUT*, even if there
5304 # are @CONDS but @WHENS is empty, return true. This is counter intuitive,
5305 # and against all the rules of logic, but is needed by the current code.
5306 # FIXME: Do something saner when the logic of conditionals is understood.
5307 sub conditionals_true_when (@@)
5309 my (@conds, @whens) = @_;
5311 foreach my $cond (@conds)
5313 foreach my $when (@whens)
5316 unless conditional_true_when ($cond, $when);
5325 # condition_negate ($COND)
5326 # ------------------------
5327 sub condition_negate ($)
5331 $cond =~ s/TRUE$/TRUEO/;
5332 $cond =~ s/FALSE$/TRUE/;
5333 $cond =~ s/TRUEO$/FALSE/;
5339 # Compare condition names.
5340 # Issue them in alphabetical order, foo_TRUE before foo_FALSE.
5343 # Be careful we might be comparing `' or `#'.
5344 $a =~ /^(.*)_(TRUE|FALSE)$/;
5345 my ($aname, $abool) = ($1 || '', $2 || '');
5346 $b =~ /^(.*)_(TRUE|FALSE)$/;
5347 my ($bname, $bbool) = ($1 || '', $2 || '');
5348 return ($aname cmp $bname
5349 # Don't bother with IFs, given that TRUE is after FALSE
5350 # just cmp in the reverse order.
5351 || $bbool cmp $abool
5357 # &make_condition (@CONDITIONS)
5358 # -----------------------------
5359 # Transform a list of conditions (themselves can be an internal list
5360 # of conditions, e.g., @CONDITIONS = ('cond1 cond2', 'cond3')) into a
5361 # Make conditional (a pattern for AC_SUBST).
5362 # Correctly returns the empty string when there are no conditions.
5365 my $res = conditional_string (@_);
5367 # There are no conditions.
5373 elsif ($res eq 'FALSE')
5380 $res = '@' . $res . '@';
5389 ## ------------------------------ ##
5390 ## Handling the condition stack. ##
5391 ## ------------------------------ ##
5395 # cond_stack_if ($NEGATE, $COND, $WHERE)
5396 # --------------------------------------
5397 sub cond_stack_if ($$$)
5399 my ($negate, $cond, $where) = @_;
5401 &am_file_error ($where, "$cond does not appear in AM_CONDITIONAL")
5402 if ! $configure_cond{$cond} && $cond !~ /^TRUE|FALSE$/;
5404 $cond = "${cond}_TRUE"
5405 unless $cond =~ /^TRUE|FALSE$/;
5406 $cond = condition_negate ($cond)
5409 push (@cond_stack, $cond);
5411 return conditional_string (@cond_stack);
5416 # cond_stack_else ($NEGATE, $COND, $WHERE)
5417 # ----------------------------------------
5418 sub cond_stack_else ($$$)
5420 my ($negate, $cond, $where) = @_;
5424 &am_file_error ($where, "else without if");
5428 $cond_stack[$#cond_stack] = condition_negate ($cond_stack[$#cond_stack]);
5430 # If $COND is given, check against it.
5433 $cond = "${cond}_TRUE"
5434 unless $cond =~ /^TRUE|FALSE$/;
5435 $cond = condition_negate ($cond)
5438 &am_file_error ($where,
5439 "else reminder ($negate$cond) incompatible with "
5440 . "current conditional: $cond_stack[$#cond_stack]")
5441 if $cond_stack[$#cond_stack] ne $cond;
5444 return conditional_string (@cond_stack);
5449 # cond_stack_endif ($NEGATE, $COND, $WHERE)
5450 # -----------------------------------------
5451 sub cond_stack_endif ($$$)
5453 my ($negate, $cond, $where) = @_;
5458 &am_file_error ($where, "endif without if: $negate$cond");
5463 # If $COND is given, check against it.
5466 $cond = "${cond}_TRUE"
5467 unless $cond =~ /^TRUE|FALSE$/;
5468 $cond = condition_negate ($cond)
5471 &am_file_error ($where,
5472 "endif reminder ($negate$cond) incompatible with "
5473 . "current conditional: $cond_stack[$#cond_stack]")
5474 if $cond_stack[$#cond_stack] ne $cond;
5479 return conditional_string (@cond_stack);
5486 ## ------------------------ ##
5487 ## Handling the variables. ##
5488 ## ------------------------ ##
5491 # check_ambiguous_conditional ($VAR, $COND)
5492 # -----------------------------------------
5493 # Check for an ambiguous conditional. This is called when a variable
5494 # is being defined conditionally. If we already know about a
5495 # definition that is true under the same conditions, then we have an
5497 sub check_ambiguous_conditional ($$)
5499 my ($var, $cond) = @_;
5500 foreach my $vcond (keys %{$var_value{$var}})
5503 if ($vcond eq $cond)
5505 $message = "$var multiply defined in condition $cond";
5507 elsif (&conditional_true_when ($vcond, $cond))
5509 $message = ("$var was already defined in condition $vcond, "
5510 . "which implies condition $cond");
5512 elsif (&conditional_true_when ($cond, $vcond))
5514 $message = ("$var was already defined in condition $vcond, "
5515 . "which is implied by condition $cond");
5519 &am_line_error ($var, $message);
5526 # ¯o_define($VAR, $VAR_IS_AM, $TYPE, $COND, $VALUE, $WHERE)
5527 # -------------------------------------------------------------
5528 # The $VAR can go from Automake to user, but not the converse.
5529 sub macro_define ($$$$$$)
5531 my ($var, $var_is_am, $type, $cond, $value, $where) = @_;
5533 am_file_error ($where, "bad macro name `$var'")
5534 if $var !~ /$MACRO_PATTERN/o;
5538 # An Automake variable must be consistently defined with the same
5539 # sign by Automake. A user variable must be set by either `=' or
5540 # `:=', and later promoted to `+='.
5543 if (defined $var_type{$var} && $var_type{$var} ne $type)
5545 am_line_error ($var,
5546 ("$var was set with `$var_type{$var}=' "
5547 . "and is now set with `$type='"));
5552 if (!defined $var_type{$var} && $type eq '+')
5554 am_line_error ($var, "$var must be set with `=' before using `+='");
5557 $var_type{$var} = $type;
5559 # When adding, since we rewrite, don't try to preserve the
5560 # Automake continuation backslashes.
5562 if $type eq '+' && $var_is_am;
5564 # Differentiate the first assignment (including with `+=').
5565 if ($type eq '+' && defined $var_value{$var}{$cond})
5567 if (substr ($var_value{$var}{$cond}, -1) eq "\n")
5569 # Insert a backslash before a trailing newline.
5570 $var_value{$var}{$cond} =
5571 substr ($var_value{$var}{$cond}, 0, -1) . "\\\n";
5573 elsif ($var_value{$var}{$cond})
5575 # Insert a separator.
5576 $var_value{$var}{$cond} .= ' ';
5578 $var_value{$var}{$cond} .= $value;
5582 # The first assignment to a macro sets the line number. Ideally I
5583 # suppose we would associate line numbers with random bits of text.
5584 # FIXME: We sometimes redefine some variables, but we want to keep
5585 # the original location. More subs are needed to handle
5586 # properly variables. Once this done, remove this hack.
5587 $var_line{$var} = $where
5588 unless defined $var_line{$var};
5590 # If Automake tries to override a value specified by the user,
5591 # just don't let it do.
5592 if (defined $var_value{$var}{$cond} && !$var_is_am{$var} && $var_is_am)
5596 print STDERR "$me: refusing to override the user definition of:\n";
5598 print STDERR "$me: with `$cond' => `$value'\n";
5603 # There must be no previous value unless the user is redefining
5604 # an Automake variable or an AC_SUBST variable.
5605 check_ambiguous_conditional ($var, $cond)
5606 unless ($var_is_am{$var} && !$var_is_am
5607 || exists $configure_vars{$var});
5609 $var_value{$var}{$cond} = $value;
5613 # An Automake variable can be given to the user, but not the converse.
5614 if (! defined $var_is_am{$var} || !$var_is_am)
5616 $var_is_am{$var} = $var_is_am;
5621 # &variable_delete ($VAR, [@CONDS])
5622 # ---------------------------------
5623 # Forget about $VAR under the conditions @CONDS, or completely if
5625 sub variable_delete ($@)
5627 my ($var, @conds) = @_;
5631 delete $var_value{$var};
5632 delete $var_line{$var};
5633 delete $var_is_am{$var};
5634 delete $var_comment{$var};
5635 delete $var_type{$var};
5639 foreach my $cond (@conds)
5641 delete $var_value{$var}{$cond};
5647 # ¯o_dump ($VAR)
5648 # ------------------
5653 if (!exists $var_value{$var})
5655 print STDERR " $var does not exist\n";
5659 my $var_is_am = $var_is_am{$var} ? "Automake" : "User";
5660 my $where = (defined $var_line{$var}
5661 ? $var_line{$var} : "undefined");
5662 print STDERR "$var_comment{$var}"
5663 if defined $var_comment{$var};
5664 print STDERR " $var ($var_is_am, where = $where) $var_type{$var}=\n";
5665 print STDERR " {\n";
5666 foreach my $vcond (sort by_condition keys %{$var_value{$var}})
5668 print STDERR " $vcond => $var_value{$var}{$vcond}\n";
5670 print STDERR " }\n";
5681 print STDERR "%var_value =\n";
5683 foreach my $var (sort (keys %var_value))
5692 # &variable_defined ($VAR, [$COND])
5693 # ---------------------------------
5694 # See if a variable exists. $VAR is the variable name, and $COND is
5695 # the condition which we should check. If no condition is given, we
5696 # currently return true if the variable is defined under any
5698 sub variable_defined ($$)
5700 my ($var, $cond) = @_;
5702 # Unfortunately we can't just check for $var_value{VAR}{COND}
5703 # as this would make perl create $condition{VAR}, which we
5705 if (!exists $var_value{$var})
5707 if (defined $targets{$var})
5709 &am_line_error ($var, "`$var' is a target; expected a variable")
5711 # The variable is not defined
5715 if ($cond && !exists $var_value{$var}{$cond})
5717 # The variable is not defined for the given condition.
5721 # Even a var_value examination is good enough for us. FIXME:
5722 # really should maintain examined status on a per-condition basis.
5723 $content_seen{$var} = 1;
5727 # Mark a variable as examined.
5728 sub examine_variable
5731 &variable_defined ($var);
5734 # Return the set of conditions for which a variable is defined.
5736 # If the variable is not defined conditionally, and is not defined in
5737 # terms of any variables which are defined conditionally, then this
5738 # returns the empty list.
5740 # If the variable is defined conditionally, but is not defined in
5741 # terms of any variables which are defined conditionally, then this
5742 # returns the list of conditions for which the variable is defined.
5744 # If the variable is defined in terms of any variables which are
5745 # defined conditionally, then this returns a full set of permutations
5746 # of the subvariable conditions. For example, if the variable is
5747 # defined in terms of a variable which is defined for COND_TRUE,
5748 # then this returns both COND_TRUE and COND_FALSE. This is
5749 # because we will need to define the variable under both conditions.
5751 sub variable_conditions ($)
5758 foreach my $cond (&variable_conditions_sub ($var, '', ()))
5761 if $cond eq 'FALSE';
5762 $uniqify{$cond} = 1;
5765 @uniq_list = sort by_condition keys %uniqify;
5766 # Note we cannot just do `return sort keys %uniqify', because this
5767 # function is sometimes used in a scalar context.
5773 # &variable_conditionally_defined ($VAR)
5774 # --------------------------------------
5775 sub variable_conditionally_defined ($)
5778 foreach my $cond (variable_conditions ($var))
5781 unless $cond =~ /^TRUE|FALSE$/;
5788 # &variable_conditions_sub ($VAR, $PARENT, @PARENT_CONDS)
5789 # -------------------------------------------------------
5790 # A subroutine of variable_conditions. We only return conditions
5791 # which are true for all the conditions in @PARENT_CONDS.
5792 sub variable_conditions_sub
5794 my ($var, $parent, @parent_conds) = @_;
5797 if (defined $vars_scanned{$var})
5799 &am_line_error ($parent, "variable `$var' recursively defined");
5802 $vars_scanned{$var} = 1;
5804 my @this_conds = ();
5805 foreach my $vcond (keys %{$var_value{$var}})
5808 if ! conditionals_true_when ((@parent_conds), ($vcond));
5810 push (@this_conds, $vcond);
5812 push (@parent_conds, $vcond);
5813 my @subvar_conds = ();
5814 foreach (split (' ', $var_value{$var}{$vcond}))
5816 # If a comment seen, just leave.
5819 # Handle variable substitutions.
5820 if (/^\$\{(.*)\}$/ || /^\$\((.*)\)$/)
5822 push (@subvar_conds,
5823 &variable_conditions_sub ($1, $var, @parent_conds));
5826 pop (@parent_conds);
5828 # If there are no conditional subvariables, then we want to
5829 # return this condition. Otherwise, we want to return the
5830 # permutations of the subvariables.
5831 if (! @subvar_conds)
5833 push (@new_conds, $vcond);
5837 push (@new_conds, &variable_conditions_reduce (@subvar_conds));
5841 # Unset our entry in vars_scanned. We only care about recursive
5843 delete $vars_scanned{$var};
5845 # If there are no parents, then this call is the top level call.
5848 # Now we want to return all permutations of the subvariable
5851 foreach my $item (@new_conds)
5853 foreach (split (' ', $item))
5855 s/^(.*)_(TRUE|FALSE)$/$1_TRUE/;
5859 return &variable_conditions_permutations (sort keys %allconds);
5862 # If we are being called on behalf of another variable, we need to
5863 # return all possible permutations of the conditions. We have
5864 # already handled everything in @this_conds along with their
5865 # subvariables. We now need to add any permutations that are not
5867 foreach my $this_cond (@this_conds)
5870 &variable_conditions_permutations (split(' ', $this_cond));
5871 foreach my $perm (@perms)
5874 foreach my $scan (@this_conds)
5876 if (&conditional_true_when ($perm, $scan)
5877 || &conditional_true_when ($scan, $perm))
5886 if ! conditionals_true_when ((@parent_conds), ($perm));
5888 # This permutation was not already handled, and is valid
5890 push (@new_conds, $perm);
5898 # Filter a list of conditionals so that only the exclusive ones are
5899 # retained. For example, if both `COND1_TRUE COND2_TRUE' and
5900 # `COND1_TRUE' are in the list, discard the latter.
5901 sub variable_conditions_reduce
5905 foreach my $cond (@conds)
5907 # FALSE is absorbent.
5908 if ($cond eq 'FALSE')
5912 elsif (conditionals_true_when (($cond), (@ret)))
5921 # Return a list of permutations of a conditional string.
5922 sub variable_conditions_permutations
5927 my $comp = shift (@comps);
5928 return &variable_conditions_permutations (@comps)
5930 my $neg = condition_negate ($comp);
5933 foreach my $sub (&variable_conditions_permutations (@comps))
5935 push (@ret, "$comp $sub");
5936 push (@ret, "$neg $sub");
5948 # &check_variable_defined_unconditionally($VAR, $PARENT)
5949 # ------------------------------------------------------
5950 # Warn if a variable is conditionally defined. This is called if we
5951 # are using the value of a variable.
5952 sub check_variable_defined_unconditionally ($$)
5954 my ($var, $parent) = @_;
5955 foreach my $cond (keys %{$var_value{$var}})
5958 if $cond =~ /^TRUE|FALSE$/;
5962 &am_line_error ($parent,
5963 "warning: automake does not support conditional definition of $var in $parent");
5967 &am_line_error ($parent,
5968 "warning: automake does not support $var being defined conditionally");
5976 # Get the TRUE value of a variable, warn if the variable is
5977 # conditionally defined.
5981 &check_variable_defined_unconditionally ($var);
5982 return $var_value{$var}{'TRUE'};
5987 # &value_to_list ($VAR, $VAL, $COND)
5988 # ----------------------------------
5989 # Convert a variable value to a list, split as whitespace. This will
5990 # recursively follow $(...) and ${...} inclusions. It preserves @...@
5993 # If COND is 'all', then all values under all conditions should be
5994 # returned; if COND is a particular condition (all conditions are
5995 # surrounded by @...@) then only the value for that condition should
5996 # be returned; otherwise, warn if VAR is conditionally defined.
5997 # SCANNED is a global hash listing whose keys are all the variables
5998 # already scanned; it is an error to rescan a variable.
6001 my ($var, $val, $cond) = @_;
6005 $val =~ s/\\(\n|$)/ /g;
6007 foreach (split (' ', $val))
6009 # If a comment seen, just leave.
6012 # Handle variable substitutions.
6013 if (/^\$\{([^}]*)\}$/ || /^\$\(([^)]*)\)$/)
6017 # If the user uses a losing variable name, just ignore it.
6018 # This isn't ideal, but people have requested it.
6019 next if ($varname =~ /\@.*\@/);
6023 if ($varname =~ /^([^:]*):([^=]*)=(.*)$/)
6027 ($from = $2) =~ s/(\W)/\\$1/g;
6031 @temp_list = &variable_value_as_list_worker ($1, $cond, $var);
6033 # Now rewrite the value if appropriate.
6036 grep (s/$from$/$to/, @temp_list);
6039 push (@result, @temp_list);
6050 # Return contents of variable as list, split as whitespace. This will
6051 # recursively follow $(...) and ${...} inclusions. It preserves @...@
6052 # substitutions. If COND is 'all', then all values under all
6053 # conditions should be returned; if COND is a particular condition
6054 # (all conditions are surrounded by @...@) then only the value for
6055 # that condition should be returned; otherwise, warn if VAR is
6056 # conditionally defined. If PARENT is specified, it is the name of
6057 # the including variable; this is only used for error reports.
6058 sub variable_value_as_list_worker
6060 my ($var, $cond, $parent) = @_;
6063 if (! defined $var_value{$var})
6065 if (defined $targets{$var})
6067 &am_line_error ($var, "`$var' is a target; expected a variable");
6071 &am_line_error ($parent, "variable `$var' not defined");
6074 elsif (defined $vars_scanned{$var})
6076 # `vars_scanned' is a global we use to keep track of which
6077 # variables we've already examined.
6078 &am_line_error ($parent, "variable `$var' recursively defined");
6080 elsif ($cond eq 'all')
6082 $vars_scanned{$var} = 1;
6083 foreach my $vcond (keys %{$var_value{$var}})
6085 my $val = $var_value{$var}{$vcond};
6086 push (@result, &value_to_list ($var, $val, $cond));
6092 $vars_scanned{$var} = 1;
6094 foreach my $vcond (keys %{$var_value{$var}})
6096 my $val = $var_value{$var}{$vcond};
6097 if (&conditional_true_when ($vcond, $cond))
6099 # Warn if we have an ambiguity. It's hard to know how
6100 # to handle this case correctly.
6101 &check_variable_defined_unconditionally ($var, $parent)
6104 push (@result, &value_to_list ($var, $val, $cond));
6109 # Unset our entry in vars_scanned. We only care about recursive
6111 delete $vars_scanned{$var};
6117 # &variable_output ($VAR, [@CONDS])
6118 # ---------------------------------
6119 # Output all the values of $VAR is @COND is not specified, else only
6120 # that corresponding to @COND.
6121 sub variable_output ($@)
6123 my ($var, @conds) = @_;
6125 @conds = sort by_condition keys %{$var_value{$var}}
6128 $output_vars .= $var_comment{$var}
6129 if defined $var_comment{$var};
6131 foreach my $cond (@conds)
6133 my $val = $var_value{$var}{$cond};
6134 my $equals = $var_type{$var} eq ':' ? ':=' : '=';
6135 my $output_var = "$var $equals $val";
6136 $output_var =~ s/^/make_condition ($cond)/meg;
6137 $output_vars .= $output_var . "\n";
6142 # &variable_pretty_output ($VAR, [@CONDS])
6143 # ----------------------------------------
6144 # Likewise, but pretty, i.e., we *split* the values at spaces. Use only
6145 # with variables holding filenames.
6146 sub variable_pretty_output ($@)
6148 my ($var, @conds) = @_;
6150 @conds = sort by_condition keys %{$var_value{$var}}
6153 $output_vars .= $var_comment{$var}
6154 if defined $var_comment{$var};
6156 foreach my $cond (@conds)
6158 my $val = $var_value{$var}{$cond};
6159 my $equals = $var_type{$var} eq ':' ? ':=' : '=';
6160 my $make_condition = make_condition ($cond);
6161 $output_vars .= pretty_print_internal ("$make_condition$var $equals",
6162 "$make_condition\t",
6163 split (' ' , $val));
6168 # This is just a wrapper for variable_value_as_list_worker that
6169 # initializes the global hash `vars_scanned'. This hash is used to
6170 # avoid infinite recursion.
6171 sub variable_value_as_list
6173 my ($var, $cond, $parent) = @_;
6175 return &variable_value_as_list_worker ($var, $cond, $parent);
6179 # Like define_variable, but the value is a list, and the variable may
6180 # be defined conditionally. The second argument is the conditional
6181 # under which the value should be defined; this should be the empty
6182 # string to define the variable unconditionally. The third argument
6183 # is a list holding the values to use for the variable. The value is
6184 # pretty printed in the output file.
6185 sub define_pretty_variable
6187 my ($var, $cond, @value) = @_;
6189 # Beware that an empty $cond has a different semantics for
6190 # macro_define and variable_pretty_output.
6193 if (! &variable_defined ($var, $cond))
6195 macro_define ($var, 1, '', $cond, join (' ', @value), undef);
6196 variable_pretty_output ($var, $cond || 'TRUE');
6197 $content_seen{$var} = 1;
6202 # define_variable ($VAR, $VALUE)
6203 # ------------------------------
6204 # Define a new user variable VAR to VALUE, but only if not already defined.
6207 my ($var, $value) = @_;
6209 define_pretty_variable ($var, 'TRUE', $value);
6213 # Like define_variable, but define a variable to be the configure
6214 # substitution by the same name.
6215 sub define_configure_variable
6218 my $value = '@' . $var . '@';
6219 &define_variable ($var, $value);
6223 # define_compiler_variable ($LANG)
6224 # --------------------------------
6225 # Define a compiler variable. We also handle defining the `LT'
6226 # version of the command when using libtool.
6227 sub define_compiler_variable ($)
6231 my ($var, $value) = ($lang->compiler, $lang->compile);
6232 &define_variable ($var, $value);
6233 &define_variable ("LT$var", "\$(LIBTOOL) --mode=compile $value")
6238 # define_linker_variable ($LANG)
6239 # ------------------------------
6240 # Define linker variables.
6241 sub define_linker_variable ($)
6245 my ($var, $value) = ($lang->lder, $lang->ld);
6247 &define_variable ($lang->lder, $lang->ld);
6248 # CCLINK = $(CCLD) blah blah...
6249 &define_variable ($lang->linker,
6250 (($seen_libtool ? '$(LIBTOOL) --mode=link ' : '')
6254 ################################################################
6256 ## ---------------- ##
6257 ## Handling rules. ##
6258 ## ---------------- ##
6260 sub rule_define ($$$$)
6262 my ($target, $rule_is_am, $cond, $where) = @_;
6264 if (defined $targets{$target}
6266 ? ! defined $target_conditional{$target}
6267 : defined $target_conditional{$target}))
6269 &am_line_error ($target,
6270 "$target defined both conditionally and unconditionally");
6273 # Value here doesn't matter; for targets we only note existence.
6274 $targets{$target} = $where;
6277 if ($target_conditional{$target})
6279 &check_ambiguous_conditional ($target, $cond);
6281 $target_conditional{$target}{$cond} = $where;
6285 # Check the rule for being a suffix rule. If so, store in a hash.
6287 if ((my ($source_suffix, $object_suffix)) = ($target =~ $SUFFIX_RULE_PATTERN))
6289 $suffix_rules{$source_suffix} = $object_suffix;
6290 print "Sources ending in .$source_suffix become .$object_suffix\n"
6292 # Set SUFFIXES from suffix_rules.
6293 push @suffixes, ".$source_suffix", ".$object_suffix";
6298 # See if a target exists.
6302 return defined $targets{$target};
6306 ################################################################
6308 # Read Makefile.am and set up %contents. Simultaneously copy lines
6309 # from Makefile.am into $output_trailer or $output_vars as
6310 # appropriate. NOTE we put rules in the trailer section. We want
6311 # user rules to come after our generated stuff.
6316 my $am_file = new IO::File ("< $amfile");
6319 die "$me: couldn't open `$amfile': $!\n";
6321 print "$me: reading $amfile\n" if $verbose;
6327 while ($_ = $am_file->getline)
6329 if (/$IGNORE_PATTERN/o)
6331 # Merely delete comments beginning with two hashes.
6333 elsif (/$WHITE_PATTERN/o)
6335 # Stick a single white line before the incoming macro or rule.
6339 elsif (/$COMMENT_PATTERN/o)
6341 # Stick comments before the incoming macro or rule. Make
6342 # sure a blank line preceeds first block of comments.
6343 $spacing = "\n" unless $blank;
6345 $comment .= $spacing . $_;
6354 $output_vars .= $comment . "\n";
6358 # We save the conditional stack on entry, and then check to make
6359 # sure it is the same on exit. This lets us conditonally include
6361 my @saved_cond_stack = @cond_stack;
6362 my $cond = conditional_string (@cond_stack);
6366 my $last_var_name = '';
6367 my $last_var_type = '';
6368 my $last_var_value = '';
6369 # FIXME: shouldn't use $_ in this loop; it is too big.
6373 unless substr ($_, -1, 1) eq "\n";
6375 # Don't look at MAINTAINER_MODE_TRUE here. That shouldn't be
6376 # used by users. @MAINT@ is an anachronism now.
6377 $_ =~ s/\@MAINT\@//g
6378 unless $seen_maint_mode;
6380 my $new_saw_bk = /\\$/;
6382 if (/$IGNORE_PATTERN/o)
6384 # Merely delete comments beginning with two hashes.
6386 elsif (/$WHITE_PATTERN/o)
6388 # Stick a single white line before the incoming macro or rule.
6390 &am_line_error ($., "blank line following trailing backslash")
6393 elsif (/$COMMENT_PATTERN/o)
6395 # Stick comments before the incoming macro or rule.
6396 $comment .= $spacing . $_;
6398 &am_line_error ($., "comment following trailing backslash")
6405 $output_trailer .= &make_condition (@cond_stack);
6406 $output_trailer .= $_;
6410 $last_var_value .= ' '
6411 unless $last_var_value =~ /\s$/;
6412 $last_var_value .= $_;
6416 $var_comment{$last_var_name} .= "$spacing"
6417 if (!defined $var_comment{$last_var_name}
6418 || substr ($var_comment{$last_var_name}, -1) ne "\n");
6419 $var_comment{$last_var_name} .= "$comment";
6420 $comment = $spacing = '';
6421 macro_define ($last_var_name, 0,
6422 $last_var_type, $cond,
6423 $last_var_value, $.)
6424 if $cond ne 'FALSE';
6425 push (@var_list, $last_var_name);
6430 elsif (/$IF_PATTERN/o)
6432 $cond = cond_stack_if ($1, $2, "$amfile:$.");
6434 elsif (/$ELSE_PATTERN/o)
6436 $cond = cond_stack_else ($1, $2, "$amfile:$.");
6438 elsif (/$ENDIF_PATTERN/o)
6440 $cond = cond_stack_endif ($1, $2, "$amfile:$.");
6443 elsif (/$RULE_PATTERN/o)
6448 rule_define ($1, 0, $cond, $.);
6451 $output_trailer .= $comment . $spacing;
6452 $output_trailer .= &make_condition (@cond_stack);
6453 $output_trailer .= $_;
6454 $comment = $spacing = '';
6456 elsif (/$ASSIGNMENT_PATTERN/o)
6458 # Found a macro definition.
6460 $last_var_name = $1;
6461 $last_var_type = $2;
6462 $last_var_value = $3;
6463 if ($3 ne '' && substr ($3, -1) eq "\\")
6465 # We preserve the `\' because otherwise the long lines
6466 # that are generated will be truncated by broken
6468 $last_var_value = $3 . "\n";
6473 # FIXME: this doesn't always work correctly; it will
6474 # group all comments for a given variable, no matter
6476 # Accumulating variables must not be output.
6477 $var_comment{$last_var_name} .= "$spacing"
6478 if (!defined $var_comment{$last_var_name}
6479 || substr ($var_comment{$last_var_name}, -1) ne "\n");
6480 $var_comment{$last_var_name} .= "$comment";
6481 $comment = $spacing = '';
6483 macro_define ($last_var_name, 0,
6484 $last_var_type, $cond,
6485 $last_var_value, $.)
6486 if $cond ne 'FALSE';
6487 push (@var_list, $last_var_name);
6490 elsif (/$INCLUDE_PATTERN/o)
6494 if ($path =~ s/^\$\(top_srcdir\)\///)
6496 push (@include_stack, "\$\(top_srcdir\)/$path");
6500 $path =~ s/\$\(srcdir\)\///;
6501 push (@include_stack, "\$\(srcdir\)/$path");
6502 $path = $relative_dir . "/" . $path;
6504 &read_am_file ($path);
6508 # This isn't an error; it is probably a continued rule.
6509 # In fact, this is what we assume.
6511 $output_trailer .= $comment . $spacing;
6512 $output_trailer .= &make_condition (@cond_stack);
6513 $output_trailer .= $_;
6514 $comment = $spacing = '';
6515 &am_line_error ($., "`#' comment at start of rule is unportable")
6516 if $_ =~ /^\t\s*\#/;
6519 $saw_bk = $new_saw_bk;
6520 $_ = $am_file->getline;
6523 $output_trailer .= $comment;
6525 if (join (' ', @saved_cond_stack) ne join (' ', @cond_stack))
6529 &am_error ("unterminated conditionals: @cond_stack");
6533 # FIXME: better error message here.
6534 &am_error ("conditionals not nested in include file");
6540 # define_standard_variables ()
6541 # ----------------------------
6542 # A helper for read_main_am_file which initializes configure variables
6543 # and variables from header-vars.am. This is a subr so we can call it
6545 sub define_standard_variables
6547 my $saved_output_vars = $output_vars;
6548 my ($comments, undef, $rules) =
6549 file_contents_internal (1, "$libdir/am/header-vars.am");
6551 # This will output the definitions in $output_vars, which we don't
6553 foreach my $var (sort keys %configure_vars)
6555 &define_configure_variable ($var);
6556 push (@var_list, $var);
6559 # ... hence, we restore $output_vars.
6560 $output_vars = $saved_output_vars . $comments . $rules;
6563 # Read main am file.
6564 sub read_main_am_file
6568 # This supports the strange variable tricks we are about to play.
6569 if (scalar keys %var_value > 0)
6572 &prog_error ("variable defined before read_main_am_file");
6575 # Generate copyright header for generated Makefile.in.
6576 # We do discard the output of predefined variables, handled below.
6577 $output_vars = ("# $in_file_name generated automatically by automake "
6578 . $VERSION . " from $am_file_name.\n");
6579 $output_vars .= $gen_copyright;
6581 # We want to predefine as many variables as possible. This lets
6582 # the user set them with `+=' in Makefile.am. However, we don't
6583 # want these initial definitions to end up in the output quite
6584 # yet. So we just load them, but output them later.
6585 &define_standard_variables;
6587 # Read user file, which might override some of our values.
6588 &read_am_file ($amfile);
6590 # Ouput all the Automake variables. If the user changed one, then
6591 # it is now marked as owned by the user.
6592 foreach my $var (uniq @var_list)
6594 # Don't process user variables.
6595 variable_output ($var)
6596 unless !$var_is_am{$var};
6599 # Now dump the user variables that were defined. We do it in the same
6600 # order in which they were defined (skipping duplicates).
6601 foreach my $var (uniq @var_list)
6603 # Don't process Automake variables.
6604 variable_output ($var)
6605 unless $var_is_am{$var};
6609 ################################################################
6612 # &flatten ($STRING)
6613 # ------------------
6614 # Flatten the $STRING and return the result.
6629 # &make_paragraphs ($MAKEFILE, [%TRANSFORM])
6630 # ------------------------------------------
6631 # Load a $MAKEFILE, apply the %TRANSFORM, and return it as a list of
6633 sub make_paragraphs ($%)
6635 my ($file, %transform) = @_;
6637 # Complete %transform with global options and make it a Perl
6640 "s/$IGNORE_PATTERN//gm;"
6641 . transform (%transform,
6643 'CYGNUS' => $cygnus_mode,
6645 => $seen_maint_mode ? subst ('MAINTAINER_MODE_TRUE') : '',
6647 'SHAR' => $options{'dist-shar'} || 0,
6648 'BZIP2' => $options{'dist-bzip2'} || 0,
6649 'ZIP' => $options{'dist-zip'} || 0,
6650 'COMPRESS' => $options{'dist-tarZ'} || 0,
6652 'INSTALL-INFO' => !$options{'no-installinfo'},
6653 'INSTALL-MAN' => !$options{'no-installman'},
6654 'CK-NEWS' => $options{'check-news'} || 0,
6656 'SUBDIRS' => &variable_defined ('SUBDIRS'),
6657 'TOPDIR' => backname ($relative_dir),
6658 'TOPDIR_P' => $relative_dir eq '.',
6659 'CONFIGURE-AC' => $configure_ac,
6661 'BUILD' => $seen_canonical == $AC_CANONICAL_SYSTEM,
6662 'HOST' => $seen_canonical,
6663 'TARGET' => $seen_canonical == $AC_CANONICAL_SYSTEM,
6665 'LIBTOOL' => defined $configure_vars{'LIBTOOL'})
6666 # We don't need more than two consecutive new-lines.
6667 . 's/\n{3,}/\n\n/g';
6669 # Swallow the file and apply the COMMAND.
6670 my $fc_file = new IO::File ("< $file");
6673 die "$me: installation error: cannot open `$file'\n";
6676 print "$me: reading $file\n"
6678 my $saved_dollar_slash = $/;
6680 $_ = $fc_file->getline;
6681 $/ = $saved_dollar_slash;
6686 # Split at unescaped new lines.
6687 my @lines = split (/(?<!\\)\n/, $content);
6690 while (defined ($_ = shift @lines))
6692 my $paragraph = "$_";
6693 # If we are a rule, eat as long as we start with a tab.
6694 if (/$RULE_PATTERN/smo)
6696 while (defined ($_ = shift @lines) && $_ =~ /^\t/)
6698 $paragraph .= "\n$_";
6700 unshift (@lines, $_);
6703 # If we are a comments, eat as much comments as you can.
6704 elsif (/$COMMENT_PATTERN/smo)
6706 while (defined ($_ = shift @lines)
6707 && $_ =~ /$COMMENT_PATTERN/smo)
6709 $paragraph .= "\n$_";
6711 unshift (@lines, $_);
6714 push @res, $paragraph;
6723 # ($COMMENT, $VARIABLES, $RULES)
6724 # &file_contents_internal ($IS_AM, $FILE, [%TRANSFORM])
6725 # -----------------------------------------------------
6726 # Return contents of a file from $libdir/am, automatically skipping
6727 # macros or rules which are already known. $IS_AM iff the caller is
6728 # reading an Automake file (as opposed to the user's Makefile.am).
6729 sub file_contents_internal ($$%)
6731 my ($is_am, $file, %transform) = @_;
6733 my $result_vars = '';
6734 my $result_rules = '';
6738 # We save the conditional stack on entry, and then check to make
6739 # sure it is the same on exit. This lets us conditonally include
6741 my @saved_cond_stack = @cond_stack;
6742 my $cond = conditional_string (@cond_stack);
6744 foreach (make_paragraphs ($file, %transform))
6747 &am_file_error ($file, "blank line following trailing backslash:\n$_")
6749 &am_file_error ($file, "comment following trailing backslash:\n$_")
6754 # Stick empty line before the incoming macro or rule.
6757 elsif (/$COMMENT_PATTERN/mso)
6759 # Stick comments before the incoming macro or rule.
6763 # Handle inclusion of other files.
6764 elsif (/$INCLUDE_PATTERN/o)
6766 if ($cond ne 'FALSE')
6768 my $file = ($is_am ? "$libdir/am/" : '') . $1;
6770 my ($com, $vars, $rules)
6771 = file_contents_internal ($is_am, $file, %transform);
6773 $result_vars .= $vars;
6774 $result_rules .= $rules;
6778 # Handling the conditionals.
6779 elsif (/$IF_PATTERN/o)
6781 $cond = cond_stack_if ($1, $2, $file);
6783 elsif (/$ELSE_PATTERN/o)
6785 $cond = cond_stack_else ($1, $2, $file);
6787 elsif (/$ENDIF_PATTERN/o)
6789 $cond = cond_stack_endif ($1, $2, $file);
6793 elsif (/$RULE_PATTERN/mso)
6795 # Separate relationship from optional actions: the first
6796 # `new-line tab" not preceded by backslash (continuation
6798 # I'm quite shoked! It seems that (\\\n|[^\n]) is not the
6799 # same as `([^\n]|\\\n)!!! Don't swap it, it breaks.
6801 /^((?:\\\n|[^\n])*)(?:\n(\t.*))?$/som;
6802 my ($relationship, $actions) = ($1, $2 || '');
6804 # Separate targets from dependencies: the first colon.
6805 $relationship =~ /^([^:]+\S+) *: *(.*)$/som;
6806 my ($targets, $dependencies) = ($1, $2);
6807 # Remove the escaped new lines.
6808 # I don't know why, but I have to use a tmp $flat_deps.
6809 my $flat_deps = &flatten ($dependencies);
6810 my @deps = split (' ', $flat_deps);
6812 foreach (split (' ' , $targets))
6814 # FIXME: We are not robust to people defining several targets
6815 # at once, only some of them being in %dependencies.
6817 # Output only if not in FALSE.
6818 if (defined $dependencies{$_}
6819 && $cond ne 'FALSE')
6821 &depend ($_, @deps);
6822 $actions{$_} .= $actions;
6826 # Free lance dependency. Output the rule for all the
6827 # targets instead of one by one.
6828 if (!defined $targets{$targets}
6829 && $cond ne 'FALSE')
6831 $paragraph =~ s/^/make_condition (@cond_stack)/gme;
6832 $result_rules .= "$spacing$comment$paragraph\n";
6833 rule_define ($targets, $is_am, $cond, $file);
6835 $comment = $spacing = '';
6841 elsif (/$ASSIGNMENT_PATTERN/mso)
6843 my ($var, $type, $val) = ($1, $2, $3);
6844 &am_file_error ($file, "macro `$var' with trailing backslash")
6847 # Accumulating variables must not be output.
6848 $var_comment{$var} .= "$spacing"
6849 if (!defined $var_comment{$var}
6850 || substr ($var_comment{$var}, -1) ne "\n");
6851 $var_comment{$var} .= "$comment";
6852 macro_define ($var, $is_am, $type, $cond, $val, $file)
6853 if $cond ne 'FALSE';
6854 push (@var_list, $var);
6856 # If the user has set some variables we were in charge
6857 # of (which is detected by the first reading of
6858 # `header-vars.am'), we must not output them.
6859 $result_vars .= "$spacing$comment$_\n"
6860 if $type ne '+' && $var_is_am{$var} && $cond ne 'FALSE';
6862 $comment = $spacing = '';
6866 # This isn't an error; it is probably some tokens which
6867 # configure is supposed to replace, such as `@SET-MAKE@',
6868 # or some part of a rule cut by an if/endif.
6869 if ($cond ne 'FALSE')
6871 s/^/make_condition (@cond_stack)/gme;
6872 $result_rules .= "$spacing$comment$_\n";
6874 $comment = $spacing = '';
6878 if (join (' ', @saved_cond_stack) ne join (' ', @cond_stack))
6882 &am_error ("unterminated conditionals: @cond_stack");
6886 # FIXME: better error message here.
6887 &am_error ("conditionals not nested in include file");
6891 return ($comment, $result_vars, $result_rules);
6896 # &file_contents ($BASENAME, [%TRANSFORM])
6897 # ----------------------------------------
6898 # Return contents of a file from $libdir/am, automatically skipping
6899 # macros or rules which are already known.
6900 sub file_contents ($%)
6902 my ($basename, %transform) = @_;
6903 my ($comments, $variables, $rules) =
6904 file_contents_internal (1, "$libdir/am/$basename.am", %transform);
6905 return "$comments$variables$rules";
6910 # &transform (%PAIRS)
6911 # -------------------
6912 # Foreach ($TOKEN, $VAL) in %PAIRS produce a replacement expression suitable
6913 # for file_contents which:
6914 # - replaces @$TOKEN@ with $VALUE,
6915 # - enables/disables ?$TOKEN?.
6921 while (my ($token, $val) = each %pairs)
6923 $result .= "s/\Q%$token%\E/\Q$val\E/gm;";
6926 $result .= "s/\Q?$token?\E//gm;s/^.*\Q?!$token?\E.*\\n//gm;";
6927 $result .= "s/\Q%?$token%\E/TRUE/gm;";
6931 $result .= "s/\Q?!$token?\E//gm;s/^.*\Q?$token?\E.*\\n//gm;";
6932 $result .= "s/\Q%?$token%\E/FALSE/gm;";
6940 # Find all variable prefixes that are used for install directories. A
6941 # prefix `zar' qualifies iff:
6942 # * `zardir' is a variable.
6943 # * `zar_PRIMARY' is a variable.
6944 sub am_primary_prefixes
6946 my ($primary, $can_dist, @prefixes) = @_;
6948 my %valid = map { $_ => 0 } @prefixes;
6949 $valid{'EXTRA'} = 0;
6950 foreach my $varname (keys %var_value)
6952 # Automake is allowed to define variables that look like they
6953 # are magic variables, such as INSTALL_DATA.
6955 if $var_is_am{$varname};
6957 if ($varname =~ /^(nobase_)?(dist_|nodist_)?(.*)_$primary$/)
6959 my ($base, $dist, $X) = ($1 || '', $2 || '', $3 || '');
6960 if ($dist ne '' && ! $can_dist)
6962 # Note that a configure variable is always legitimate.
6963 # It is natural to name such variables after the
6964 # primary, so we explicitly allow it.
6965 if (! defined $configure_vars{$varname})
6967 &am_line_error ($varname,
6968 "invalid variable `$varname': `dist' is forbidden");
6971 elsif (! defined $valid{$X} && ! &variable_defined ("${X}dir"))
6973 # Note that a configure variable is always legitimate.
6974 # It is natural to name such variables after the
6975 # primary, so we explicitly allow it.
6976 if (! defined $configure_vars{$varname})
6978 &am_line_error ($varname,
6979 "invalid variable `$varname'");
6984 # Ensure all extended prefixes are actually used.
6985 $valid{"$base$dist$X"} = 1;
6993 # Handle `where_HOW' variable magic. Does all lookups, generates
6994 # install code, and possibly generates code to define the primary
6995 # variable. The first argument is the name of the .am file to munge,
6996 # the second argument is the primary variable (eg HEADERS), and all
6997 # subsequent arguments are possible installation locations. Returns
6998 # list of all values of all _HOW targets.
7000 # FIXME: this should be rewritten to be cleaner. It should be broken
7001 # up into multiple functions.
7003 # Usage is: am_install_var (OPTION..., file, HOW, where...)
7010 my $default_dist = 0;
7013 if ($args[0] eq '-noextra')
7017 elsif ($args[0] eq '-candist')
7021 elsif ($args[0] eq '-defaultdist')
7026 elsif ($args[0] !~ /^-/)
7033 my ($file, $primary, @prefixes) = @args;
7035 # Now that configure substitutions are allowed in where_HOW
7036 # variables, it is an error to actually define the primary. We
7037 # allow `JAVA', as it is customarily used to mean the Java
7038 # interpreter. This is but one of several Java hacks. Similarly,
7039 # `PYTHON' is customarily used to mean the Python interpreter.
7040 &am_line_error ($primary, "`$primary' is an anachronism")
7041 if &variable_defined ($primary)
7042 && ($primary ne 'JAVA' && $primary ne 'PYTHON');
7045 # Look for misspellings. It is an error to have a variable ending
7046 # in a "reserved" suffix whose prefix is unknown, eg
7047 # "bni_PROGRAMS". However, unusual prefixes are allowed if a
7048 # variable of the same name (with "dir" appended) exists. For
7049 # instance, if the variable "zardir" is defined, then
7050 # "zar_PROGRAMS" becomes valid. This is to provide a little extra
7051 # flexibility in those cases which need it.
7052 my %valid = &am_primary_prefixes ($primary, $can_dist, @prefixes);
7054 # If a primary includes a configure substitution, then the EXTRA_
7055 # form is required. Otherwise we can't properly do our job.
7057 my $warned_about_extra = 0;
7062 # True if the iteration is the first one. Used for instance to
7063 # output parts of the associated file only once.
7065 foreach my $X (sort keys %valid)
7067 my $one_name = $X . '_' . $primary;
7069 unless (&variable_defined ($one_name));
7071 my $strip_subdir = 1;
7072 # If subdir prefix should be preserved, do so.
7073 if ($X =~ /^nobase_/)
7079 my $nodir_name = $X;
7080 # If files should be distributed, do so.
7084 $dist_p = (($default_dist && $one_name !~ /^nodist_/)
7085 || (! $default_dist && $one_name =~ /^dist_/));
7086 $nodir_name =~ s/^(dist|nodist)_//;
7089 # Append actual contents of where_PRIMARY variable to
7091 foreach my $rcurs (&variable_value_as_list ($one_name, 'all'))
7093 # Skip configure substitutions. Possibly bogus.
7094 if ($rcurs =~ /^\@.*\@$/)
7098 if (! $warned_about_extra)
7100 $warned_about_extra = 1;
7101 &am_line_error ($one_name,
7102 "`$one_name' contains configure substitution, but shouldn't");
7105 # Check here to make sure variables defined in
7106 # configure.ac do not imply that EXTRA_PRIMARY
7108 elsif (! defined $configure_vars{$one_name})
7110 $require_extra = $one_name
7117 push (@result, $rcurs);
7120 # A blatant hack: we rewrite each _PROGRAMS primary to
7121 # include EXEEXT when in Cygwin32 mode.
7122 if ($primary eq 'PROGRAMS')
7124 my @conds = &variable_conditions ($one_name);
7127 foreach my $cond (@conds)
7129 my @one_binlist = ();
7130 my @condval = &variable_value_as_list ($one_name,
7132 foreach my $rcurs (@condval)
7134 if ($rcurs =~ /\./ || $rcurs =~ /^\@.*\@$/)
7136 push (@one_binlist, $rcurs);
7140 push (@one_binlist, $rcurs . '$(EXEEXT)');
7144 push (@condvals, $cond);
7145 push (@condvals, join (' ', @one_binlist));
7148 variable_delete ($one_name);
7151 my $cond = shift (@condvals);
7152 my @val = split (' ', shift (@condvals));
7153 &define_pretty_variable ($one_name, $cond, @val);
7157 # "EXTRA" shouldn't be used when generating clean targets,
7158 # all, or install targets.
7161 # We used to warn if EXTRA_FOO was defined uselessly,
7162 # but this was annoying.
7168 push (@check, '$(' . $one_name . ')');
7172 push (@used, '$(' . $one_name . ')');
7175 # Is this to be installed?
7176 my $install_p = $X ne 'noinst' && $X ne 'check';
7178 # If so, with install-exec? (or install-data?).
7179 my $exec_p = (defined $exec_dir_p {$X}
7183 # Singular form of $PRIMARY.
7184 (my $one_primary = $primary) =~ s/S$//;
7185 $output_rules .= &file_contents ($file,
7188 'PRIMARY' => $primary,
7189 'ONE_PRIMARY' => $one_primary,
7191 'NDIR' => $nodir_name,
7192 'BASE' => $strip_subdir,
7195 'INSTALL' => $install_p,
7196 'DIST' => $dist_p));
7201 # The JAVA variable is used as the name of the Java interpreter.
7202 # The PYTHON variable is used as the name of the Python interpreter.
7203 if (@used && $primary ne 'JAVA' && $primary ne 'PYTHON')
7206 &define_pretty_variable ($primary, '', @used);
7207 $output_vars .= "\n";
7210 if ($require_extra && ! &variable_defined ('EXTRA_' . $primary))
7212 &am_line_error ($require_extra,
7213 "`$require_extra' contains configure substitution, but `EXTRA_$primary' not defined");
7216 # Push here because PRIMARY might be configure time determined.
7217 push (@all, '$(' . $primary . ')')
7218 if @used && $primary ne 'JAVA' && $primary ne 'PYTHON';
7220 # Make the result unique. This lets the user use conditionals in
7221 # a natural way, but still lets us program lazily -- we don't have
7222 # to worry about handling a particular object more than once.
7223 return uniq (sort @result);
7227 ################################################################
7229 # Each key in this hash is the name of a directory holding a
7230 # Makefile.in. These variables are local to `is_make_dir'.
7232 my $make_dirs_set = 0;
7237 if (! $make_dirs_set)
7239 foreach my $iter (@configure_input_files)
7241 $make_dirs{dirname ($iter)} = 1;
7243 # We also want to notice Makefile.in's.
7244 foreach my $iter (@other_input_files)
7246 if ($iter =~ /Makefile\.in$/)
7248 $make_dirs{dirname ($iter)} = 1;
7253 return defined $make_dirs{$dir};
7256 ################################################################
7258 # This variable is local to the "require file" set of functions.
7259 my @require_file_paths = ();
7261 # If a file name appears as a key in this hash, then it has already
7262 # been checked for. This variable is local to the "require file"
7264 %require_file_found = ();
7266 # See if we want to push this file onto dist_common. This function
7267 # encodes the rules for deciding when to do so.
7268 sub maybe_push_required_file
7270 my ($dir, $file, $fullfile) = @_;
7272 if ($dir eq $relative_dir)
7274 &push_dist_common ($file);
7276 elsif ($relative_dir eq '.' && ! &is_make_dir ($dir))
7278 # If we are doing the topmost directory, and the file is in a
7279 # subdir which does not have a Makefile, then we distribute it
7281 &push_dist_common ($fullfile);
7286 # &require_file_internal ($IS_CONFIGURE, $LINE, $MYSTRICT, @FILES)
7287 # ----------------------------------------------------------------
7288 # Verify that the file must exist in the current directory.
7289 # $MYSTRICT is the strictness level at which this file becomes required.
7291 # Must set require_file_paths before calling this function.
7292 # require_file_paths is set to hold a single directory (the one in
7293 # which the first file was found) before return.
7294 sub require_file_internal
7296 my ($is_configure, $line, $mystrict, @files) = @_;
7298 foreach my $file (@files)
7305 # If we've already looked for it, we're done.
7306 next if defined $require_file_found{$file};
7307 $require_file_found{$file} = 1;
7310 my $dangling_sym = 0;
7311 foreach my $dir (@require_file_paths)
7313 $fullfile = $dir . "/" . $file;
7314 $errdir = $dir unless $errdir;
7316 # Use different name for "error filename". Otherwise on
7317 # an error the bad file will be reported as eg
7318 # `../../install-sh' when using the default
7320 $errfile = $errdir . '/' . $file;
7322 if (-l $fullfile && ! -f readlink ($fullfile))
7327 elsif (-f $fullfile)
7330 &maybe_push_required_file ($dir, $file, $fullfile);
7336 if ($found_it && ! $force_missing)
7338 # Prune the path list.
7339 @require_file_paths = $save_dir;
7343 if ($strictness >= $mystrict)
7345 if ($dangling_sym && $add_missing)
7353 # Only install missing files according to our desired
7355 my $message = "required file `$errfile' not found";
7360 # Maybe run libtoolize.
7361 my @syslist = ('libtoolize', '--automake');
7362 push @syslist, '--copy'
7365 && grep ($_ eq $file, @libtoolize_files)
7366 && system (@syslist))
7368 $message = "installing `$errfile'";
7370 $trailer = "; cannot run `libtoolize': $!";
7372 elsif (-f ("$libdir/$file"))
7374 # Install the missing file. Symlink if we
7375 # can, copy if we must. Note: delete the file
7376 # first, in case it is a dangling symlink.
7377 $message = "installing `$errfile'";
7378 # Windows Perl will hang if we try to delete a
7379 # file that doesn't exist.
7380 unlink ($errfile) if -f $errfile;
7381 if ($symlink_exists && ! $copy_missing)
7383 if (! symlink ("$libdir/$file", $errfile))
7386 $trailer = "; error while making link: $!";
7389 elsif (system ('cp', "$libdir/$file", $errfile))
7392 $trailer = "\n error while copying";
7396 &maybe_push_required_file (dirname ($errfile),
7399 # Prune the path list.
7400 @require_file_paths = &dirname ($errfile);
7407 # FIXME: allow actual file to be specified.
7408 &am_conf_line_warning ($configure_ac, $line,
7409 "$message$trailer");
7413 &am_line_warning ($line, "$message$trailer");
7420 # FIXME: allow actual file to be specified.
7421 &am_conf_line_error ($configure_ac, $line,
7422 "$message$trailer");
7426 &am_line_error ($line, "$message$trailer");
7434 # Like require_file_with_line, but error messages refer to
7435 # configure.ac, not the current Makefile.am.
7436 sub require_file_with_conf_line
7438 @require_file_paths = $relative_dir;
7439 &require_file_internal (1, @_);
7442 sub require_file_with_line
7444 @require_file_paths = $relative_dir;
7445 &require_file_internal (0, @_);
7450 @require_file_paths = $relative_dir;
7451 &require_file_internal (0, '', @_);
7454 # Require a file that is also required by Autoconf. Looks in
7455 # configuration path, as specified by AC_CONFIG_AUX_DIR.
7456 sub require_config_file
7458 @require_file_paths = @config_aux_path;
7459 &require_file_internal (1, '', @_);
7460 my $dir = $require_file_paths[0];
7461 @config_aux_path = @require_file_paths;
7462 # Avoid unsightly '/.'s.
7463 $config_aux_dir = '$(top_srcdir)' . ($dir eq '.' ? "" : "/$dir");
7466 # Assumes that the line number is in Makefile.am.
7467 sub require_conf_file_with_line
7469 @require_file_paths = @config_aux_path;
7470 &require_file_internal (0, @_);
7471 my $dir = $require_file_paths[0];
7472 @config_aux_path = @require_file_paths;
7473 # Avoid unsightly '/.'s.
7474 $config_aux_dir = '$(top_srcdir)' . ($dir eq '.' ? "" : "/$dir");
7477 # Assumes that the line number is in configure.ac.
7478 sub require_conf_file_with_conf_line
7480 @require_file_paths = @config_aux_path;
7481 &require_file_internal (1, @_);
7482 my $dir = $require_file_paths[0];
7483 @config_aux_path = @require_file_paths;
7484 # avoid unsightly '/.'s.
7485 $config_aux_dir = '$(top_srcdir)' . ($dir eq '.' ? "" : "/$dir");
7488 ################################################################
7490 # Push a list of files onto dist_common.
7491 sub push_dist_common
7493 &prog_error ("push_dist_common run after handle_dist")
7494 if $handle_dist_run;
7495 macro_define ('DIST_COMMON', 1, '+', '', join (' ', @_), '');
7502 $strictness_name = $_[0];
7503 if ($strictness_name eq 'gnu')
7507 elsif ($strictness_name eq 'gnits')
7509 $strictness = $GNITS;
7511 elsif ($strictness_name eq 'foreign')
7513 $strictness = $FOREIGN;
7517 die "$me: level `$strictness_name' not recognized\n";
7522 ################################################################
7524 # Ensure a file exists.
7529 my $touch = new IO::File (">> $file");
7533 # Glob something. Do this to avoid indentation screwups everywhere we
7534 # want to glob. Gross!
7541 # Remove one level of brackets and strip leading spaces,
7542 # as does m4 to function arguments.
7548 my @letters = split //;
7557 next if $depth == 1;
7562 next if $depth == 0;
7563 # don't count orphan right brackets
7564 $depth = 0 if $depth < 0;
7568 return join '', @result;
7571 ################################################################
7573 # Print an error message and set exit status.
7576 warn "$me: ${am_file}.am: @_\n";
7580 # am_file_error ($FILE, @ARGS)
7581 # ----------------------------
7584 my ($file, @args) = @_;
7586 warn "$file: @args\n";
7592 my ($symbol, @args) = @_;
7594 if ($symbol && "$symbol" ne '-1')
7596 my $file = "${am_file}.am";
7598 if ($symbol =~ /^\d+$/)
7600 # SYMBOL is a line number, so just add the colon.
7601 $file .= ':' . $symbol;
7603 elsif (defined $var_line{$symbol})
7605 # SYMBOL is a variable defined in Makefile.am, so add the
7606 # line number we saved from there.
7607 $file .= ':' . $var_line{$symbol};
7609 elsif (defined $configure_vars{$symbol})
7611 # SYMBOL is a variable defined in configure.ac, so add the
7612 # appropriate line number.
7613 $file = $configure_vars{$symbol};
7617 # Couldn't find the line number.
7619 warn $file, ": @args\n";
7628 # Like am_error, but while scanning configure.ac.
7631 # FIXME: can run in subdirs.
7632 warn "$me: $configure_ac: @_\n";
7636 # Error message with line number referring to configure.ac.
7637 sub am_conf_line_error
7639 my ($file, $line, @args) = @_;
7643 warn "$file: $line: @args\n";
7648 &am_conf_error (@args);
7652 # Warning message with line number referring to configure.ac.
7653 # Does not affect exit_status
7654 sub am_conf_line_warning
7656 my $saved_exit_status = $exit_status;
7657 my $sig = $SIG{'__WARN__'};
7658 $SIG{'__WARN__'} = 'DEFAULT';
7659 am_conf_line_error (@_);
7660 $exit_status = $saved_exit_status;
7661 $SIG{'__WARN__'} = $sig;
7664 # Like am_line_error, but doesn't affect exit status.
7667 my $saved_exit_status = $exit_status;
7668 my $sig = $SIG{'__WARN__'};
7669 $SIG{'__WARN__'} = 'DEFAULT';
7671 $exit_status = $saved_exit_status;
7672 $SIG{'__WARN__'} = $sig;
7675 # Tell user where our aclocal.m4 is, but only once.
7676 sub keyed_aclocal_warning
7679 warn "$me: macro `$key' can be generated by `aclocal'\n";
7682 # Print usage information.
7686 Usage: $0 [OPTION] ... [Makefile]...
7688 Generate Makefile.in for configure from Makefile.am.
7691 --help print this help, then exit
7692 --version print version number, then exit
7693 -v, --verbose verbosely list files processed
7694 -o, --output-dir=DIR put generated Makefile.in's into DIR
7695 --no-force only update Makefile.in's that are out of date
7697 Dependency tracking:
7698 -i, --ignore-deps disable dependency tracking code
7699 --include-deps enable dependency tracking code
7702 --cygnus assume program is part of Cygnus-style tree
7703 --foreign set strictness to foreign
7704 --gnits set strictness to gnits
7705 --gnu set strictness to gnu
7708 -a, --add-missing add missing standard files to package
7709 --libdir=DIR directory storing library files
7710 -c, --copy with -a, copy missing files (default is symlink)
7711 -f, --force-missing force update of standard files
7716 foreach my $iter (sort ((@common_files, @common_sometimes)))
7718 push (@lcomm, $iter) unless $iter eq $last;
7722 my ($one, $two, $three, $four, $max);
7723 print "\nFiles which are automatically distributed, if found:\n";
7724 format USAGE_FORMAT =
7725 @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<
7726 $one, $two, $three, $four
7728 $~ = "USAGE_FORMAT";
7729 $max = int (($#lcomm + 1) / 4);
7731 for (my $i = 0; $i < $max; ++$i)
7734 $two = $lcomm[$max + $i];
7735 $three = $lcomm[2 * $max + $i];
7736 $four = $lcomm[3 * $max + $i];
7740 my $mod = ($#lcomm + 1) % 4;
7743 $one = $lcomm[$max];
7744 $two = ($mod > 1) ? $lcomm[2 * $max] : '';
7745 $three = ($mod > 2) ? $lcomm[3 * $max] : '';
7746 $four = ($mod > 3) ? $lcomm[4 * $max] : '';
7750 print "\nReport bugs to <bug-automake\@gnu.org>.\n";
7757 # Print version information
7761 automake (GNU $PACKAGE) $VERSION
7762 Written by Tom Tromey <tromey\@cygnus.com>.
7764 Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
7765 Free Software Foundation, Inc.
7766 This is free software; see the source for copying conditions. There is NO
7767 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.