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 = '^##([^#\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));
2794 # Handle all Texinfo source.
2797 &am_line_error ('TEXINFOS',
2798 "`TEXINFOS' is an anachronism; use `info_TEXINFOS'")
2799 if &variable_defined ('TEXINFOS');
2800 return if (! &variable_defined ('info_TEXINFOS')
2801 && ! &variable_defined ('html_TEXINFOS'));
2803 if (&variable_defined ('html_TEXINFOS'))
2805 &am_line_error ('html_TEXINFOS',
2806 "HTML generation not yet supported");
2810 my @texis = &variable_value_as_list ('info_TEXINFOS', 'all');
2812 my (@info_deps_list, @dvis_list, @texi_deps);
2819 foreach my $info_cursor (@texis)
2821 my $infobase = $info_cursor;
2822 $infobase =~ s/\.(txi|texinfo|texi)$//;
2824 if ($infobase eq $info_cursor)
2826 # FIXME: report line number.
2827 &am_error ("texinfo file `$info_cursor' has unrecognized extension");
2830 $texi_suffixes{$1} = 1;
2832 # If 'version.texi' is referenced by input file, then include
2833 # automatic versioning capability.
2834 my ($out_file, $vtexi, @clean_files) =
2835 &scan_texinfo_file ("$relative_dir/$info_cursor")
2837 push (@texi_cleans, @clean_files);
2841 &am_error ("`$vtexi', included in `$info_cursor', also included in `$versions{$vtexi}'")
2842 if (defined $versions{$vtexi});
2843 $versions{$vtexi} = $info_cursor;
2845 # We number the stamp-vti files. This is doable since the
2846 # actual names don't matter much. We only number starting
2847 # with the second one, so that the common case looks nice.
2848 my $vti = ($done ? $done : 'vti');
2851 &require_conf_file_with_line ('info_TEXINFOS', $FOREIGN,
2855 if ($config_aux_dir_set_in_configure_in)
2857 $conf_dir = $config_aux_dir;
2858 $conf_dir .= '/' unless $conf_dir =~ /\/$/;
2862 $conf_dir = '$(srcdir)/';
2864 $output_rules .= &file_contents ('texi-vers',
2865 ('TEXI' => $info_cursor,
2868 'MDDIR' => $conf_dir));
2871 # If user specified file_TEXINFOS, then use that as explicit
2874 push (@texi_deps, $info_cursor);
2875 # Prefix with $(srcdir) because some version of make won't
2876 # work if the target has it and the dependency doesn't.
2877 push (@texi_deps, '$(srcdir)/' . $vtexi) if $vtexi;
2879 my $canonical = &canonicalize ($infobase);
2880 if (&variable_defined ($canonical . "_TEXINFOS"))
2882 push (@texi_deps, '$(' . $canonical . '_TEXINFOS)');
2883 &push_dist_common ('$(' . $canonical . '_TEXINFOS)');
2886 $output_rules .= ("\n" . $out_file . ": "
2887 . join (' ', @texi_deps)
2888 . "\n" . $infobase . ".dvi: "
2889 . join (' ', @texi_deps)
2892 push (@info_deps_list, $out_file);
2893 push (@dvis_list, $infobase . '.dvi');
2896 # Handle location of texinfo.tex.
2897 my $need_texi_file = 0;
2901 $texinfodir = '$(top_srcdir)/../texinfo';
2902 &define_variable ('TEXINFO_TEX', "$texinfodir/texinfo.tex");
2905 elsif ($config_aux_dir_set_in_configure_in)
2907 $texinfodir = $config_aux_dir;
2908 &define_variable ('TEXINFO_TEX', "$texinfodir/texinfo.tex");
2909 $need_texi_file = 2; # so that we require_conf_file later
2911 elsif (&variable_defined ('TEXINFO_TEX'))
2913 # The user defined TEXINFO_TEX so assume he knows what he is
2915 $texinfodir = ('$(srcdir)/'
2916 . dirname (&variable_value ('TEXINFO_TEX')));
2920 $texinfodir = '$(srcdir)';
2921 $need_texi_file = 1;
2924 foreach my $txsfx (sort keys %texi_suffixes)
2926 $output_rules .= &file_contents ('texibuild',
2927 ('TEXINFODIR' => $texinfodir,
2928 'SUFFIX' => $txsfx));
2931 my $texiclean = &pretty_print_internal ("", "\t ", @texi_cleans);
2932 $output_rules .= &file_contents ('texinfos',
2933 ('TEXICLEAN' => $texiclean));
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');
2969 # Handle any man pages.
2970 sub handle_man_pages
2972 &am_line_error ('MANS', "`MANS' is an anachronism; use `man_MANS'")
2973 if &variable_defined ('MANS');
2975 # Find all the sections in use. We do this by first looking for
2976 # "standard" sections, and then looking for any additional
2977 # sections used in man_MANS.
2978 my (%sections, %vlist);
2979 # We handle nodist_ for uniformity. man pages aren't distributed
2980 # by default so it isn't actually very important.
2981 foreach my $pfx ('', 'dist_', 'nodist_')
2983 # Add more sections as needed.
2984 foreach my $section ('0'..'9', 'n', 'l')
2986 if (&variable_defined ($pfx . 'man' . $section . '_MANS'))
2988 $sections{$section} = 1;
2989 $vlist{'$(' . $pfx . 'man' . $section . '_MANS)'} = 1;
2991 &push_dist_common ('$(' . $pfx . 'man' . $section . '_MANS)')
2996 if (&variable_defined ($pfx . 'man_MANS'))
2998 $vlist{'$(' . $pfx . 'man_MANS)'} = 1;
2999 foreach (&variable_value_as_list ($pfx . 'man_MANS', 'all'))
3001 # A page like `foo.1c' goes into man1dir.
3002 if (/\.([0-9a-z])([a-z]*)$/)
3008 &push_dist_common ('$(' . $pfx . 'man_MANS)')
3013 return unless %sections;
3015 # Now for each section, generate an install and unintall rule.
3016 # Sort sections so output is deterministic.
3017 foreach my $section (sort keys %sections)
3019 $output_rules .= &file_contents ('mans', ('SECTION' => $section));
3022 $output_vars .= &file_contents ('mans-vars',
3023 ('MANS' => join (' ', sort keys %vlist)));
3025 if (! defined $options{'no-installman'})
3027 push (@all, '$(MANS)');
3031 # Handle DATA variables.
3034 &am_install_var ('-noextra', '-candist', 'data', 'DATA',
3035 'data', 'sysconf', 'sharedstate', 'localstate',
3036 'pkgdata', 'noinst', 'check');
3043 if (&variable_defined ('SUBDIRS'))
3045 $output_rules .= ("tags-recursive:\n"
3046 . "\tlist=\'\$(SUBDIRS)\'; for subdir in \$\$list; do \\\n"
3047 # Never fail here if a subdir fails; it
3049 . "\t test \"\$\$subdir\" = . || (cd \$\$subdir"
3050 . " && \$(MAKE) \$(AM_MAKEFLAGS) tags); \\\n"
3052 push (@tag_deps, 'tags-recursive');
3053 &depend ('.PHONY', 'tags-recursive');
3056 if (&saw_sources_p (1)
3057 || &variable_defined ('ETAGS_ARGS')
3061 foreach my $one_hdr (@config_headers)
3063 if ($relative_dir eq dirname ($one_hdr))
3065 # The config header is in this directory. So require it.
3066 $config .= ' ' if $config;
3067 $config .= basename ($one_hdr);
3070 $output_rules .= &file_contents ('tags',
3071 ('CONFIG' => $config,
3072 'DIRS' => join (' ', @tag_deps)));
3073 &examine_variable ('TAGS_DEPENDENCIES');
3075 elsif (&variable_defined ('TAGS_DEPENDENCIES'))
3077 &am_line_error ('TAGS_DEPENDENCIES',
3078 "doesn't make sense to define `TAGS_DEPENDENCIES' without sources or `ETAGS_ARGS'");
3082 # Every Makefile must define some sort of TAGS rule.
3083 # Otherwise, it would be possible for a top-level "make TAGS"
3084 # to fail because some subdirectory failed.
3085 $output_rules .= "tags: TAGS\nTAGS:\n\n";
3089 # Handle multilib support.
3092 return unless $seen_multilib;
3094 $output_rules .= &file_contents ('multilib');
3099 # &for_dist_common ($A, $B)
3100 # -------------------------
3101 # Subroutine for &handle_dist: sort files to dist.
3103 # We put README first because it then becomes easier to make a
3104 # Usenet-compliant shar file (in these, README must be first).
3106 # FIXME: do more ordering of files here.
3119 # handle_dist ($MAKEFILE)
3120 # -----------------------
3121 # Handle 'dist' target.
3124 my ($makefile) = @_;
3126 # `make dist' isn't used in a Cygnus-style tree.
3127 # Omit the rules so that people don't try to use them.
3128 return if $cygnus_mode;
3130 # Set up maint_charset.
3131 $local_maint_charset = &variable_value ('MAINT_CHARSET')
3132 if &variable_defined ('MAINT_CHARSET');
3133 $maint_charset = $local_maint_charset
3134 if $relative_dir eq '.';
3136 if (&variable_defined ('DIST_CHARSET'))
3138 &am_line_error ('DIST_CHARSET',
3139 "DIST_CHARSET defined but no MAINT_CHARSET defined")
3140 if ! $local_maint_charset;
3141 if ($relative_dir eq '.')
3143 $dist_charset = &variable_value ('DIST_CHARSET')
3147 &am_line_error ('DIST_CHARSET',
3148 "DIST_CHARSET can only be defined at top level");
3152 # Look for common files that should be included in distribution.
3153 foreach my $cfile (@common_files)
3155 if (-f ($relative_dir . "/" . $cfile))
3157 &push_dist_common ($cfile);
3161 # We might copy elements from $configure_dist_common to
3162 # %dist_common if we think we need to. If the file appears in our
3163 # directory, we would have discovered it already, so we don't
3164 # check that. But if the file is in a subdir without a Makefile,
3165 # we want to distribute it here if we are doing `.'. Ugly!
3166 if ($relative_dir eq '.')
3168 foreach my $file (split (' ' , $configure_dist_common))
3170 if (! &is_make_dir (dirname ($file)))
3172 &push_dist_common ($file);
3179 # Files to distributed. Don't use &variable_value_as_list
3180 # as it recursively expands `$(dist_pkgdata_DATA)' etc.
3181 check_variable_defined_unconditionally ('DIST_COMMON');
3182 my @dist_common = split (' ', variable_value ('DIST_COMMON', 'TRUE'));
3183 @dist_common = uniq (sort for_dist_common (@dist_common));
3184 pretty_print ('DIST_COMMON = ', "\t", @dist_common);
3186 # Now that we've processed DIST_COMMON, disallow further attempts
3188 $handle_dist_run = 1;
3190 # Scan EXTRA_DIST to see if we need to distribute anything from a
3191 # subdir. If so, add it to the list. I didn't want to do this
3192 # originally, but there were so many requests that I finally
3194 if (&variable_defined ('EXTRA_DIST'))
3196 # FIXME: This should be fixed to work with conditionals. That
3197 # will require only making the entries in %dist_dirs under the
3198 # appropriate condition. This is meaningful if the nature of
3199 # the distribution should depend upon the configure options
3201 foreach (&variable_value_as_list ('EXTRA_DIST', ''))
3204 next unless s,/+[^/]+$,,;
3210 # We have to check DIST_COMMON for extra directories in case the
3211 # user put a source used in AC_OUTPUT into a subdir.
3212 foreach (&variable_value_as_list ('DIST_COMMON', 'all'))
3215 next unless s,/+[^/]+$,,;
3220 # Rule to check whether a distribution is viable.
3221 my %transform = ('DISTCHECK-HOOK' => &target_defined ('distcheck-hook'),
3222 'GETTEXT' => $seen_gettext);
3224 # Prepend $(distdir) to each directory given.
3225 my %rewritten = map { '$(distdir)/' . "$_" => 1 } keys %dist_dirs;
3226 $transform{'DISTDIRS'} = join (' ', sort keys %rewritten);
3228 # If we have SUBDIRS, create all dist subdirectories and do
3230 if (&variable_defined ('SUBDIRS'))
3232 # If SUBDIRS is conditionally defined, then set DIST_SUBDIRS
3233 # to all possible directories, and use it. If DIST_SUBDIRS is
3234 # defined, just use it.
3235 my $dist_subdir_name;
3236 # Note that we check DIST_SUBDIRS first on purpose. At least
3237 # one project uses so many conditional subdirectories that
3238 # calling variable_conditionally_defined on SUBDIRS will cause
3239 # automake to grow to 150Mb. Sigh.
3240 if (&variable_defined ('DIST_SUBDIRS')
3241 || variable_conditionally_defined ('SUBDIRS'))
3243 $dist_subdir_name = 'DIST_SUBDIRS';
3244 if (! &variable_defined ('DIST_SUBDIRS'))
3246 &define_pretty_variable
3247 ('DIST_SUBDIRS', '',
3248 uniq (&variable_value_as_list ('SUBDIRS', 'all')));
3253 $dist_subdir_name = 'SUBDIRS';
3254 # We always define this because that is what `distclean'
3256 &define_pretty_variable ('DIST_SUBDIRS', '', '$(SUBDIRS)');
3259 $transform{'DIST_SUBDIR_NAME'} = $dist_subdir_name;
3262 # If the target `dist-hook' exists, make sure it is run. This
3263 # allows users to do random weird things to the distribution
3264 # before it is packaged up.
3265 push (@dist_targets, 'dist-hook')
3266 if &target_defined ('dist-hook');
3267 $transform{'DIST-TARGETS'} = join(' ', @dist_targets);
3269 # Defining $(DISTDIR).
3270 $transform{'DISTDIR'} = !&variable_defined('distdir');
3271 $transform{'TOP_DISTDIR'} = backname ($relative_dir);
3273 $output_rules .= &file_contents ('distdir', %transform);
3277 # Handle subdirectories.
3281 unless &variable_defined ('SUBDIRS');
3283 # Make sure each directory mentioned in SUBDIRS actually exists.
3284 foreach my $dir (&variable_value_as_list ('SUBDIRS', 'all'))
3286 # Skip directories substituted by configure.
3287 next if $dir =~ /^\@.*\@$/;
3289 if (! -d $am_relative_dir . '/' . $dir)
3291 &am_line_error ('SUBDIRS',
3292 "required directory $am_relative_dir/$dir does not exist");
3296 &am_line_error ('SUBDIRS', "directory should not contain `/'")
3300 $output_rules .= &file_contents ('subdirs');
3301 variable_pretty_output ('RECURSIVE_TARGETS', 'TRUE');
3305 # ($REGEN, @DEPENDENCIES)
3308 # If aclocal.m4 creation is automated, return the list of its dependencies.
3311 my $regen_aclocal = 0;
3314 unless $relative_dir eq '.';
3316 &examine_variable ('CONFIG_STATUS_DEPENDENCIES');
3317 &examine_variable ('CONFIGURE_DEPENDENCIES');
3319 if (-f 'aclocal.m4')
3321 &define_variable ("ACLOCAL_M4", '$(top_srcdir)/aclocal.m4');
3322 &push_dist_common ('aclocal.m4');
3324 my $aclocal = new IO::File ("< aclocal.m4");
3327 my $line = $aclocal->getline;
3330 if ($line =~ 'generated automatically by aclocal')
3339 if (-f 'acinclude.m4')
3342 push @ac_deps, 'acinclude.m4';
3345 if (&variable_defined ('ACLOCAL_M4_SOURCES'))
3347 push (@ac_deps, '$(ACLOCAL_M4_SOURCES)');
3349 elsif (&variable_defined ('ACLOCAL_AMFLAGS'))
3351 # Scan all -I directories for m4 files. These are our
3353 my $examine_next = 0;
3354 foreach my $amdir (&variable_value_as_list ('ACLOCAL_AMFLAGS', ''))
3359 if ($amdir !~ /^\// && -d $amdir)
3361 foreach my $ac_dep (&my_glob ($amdir . '/*.m4'))
3363 $ac_dep =~ s/^\.\/+//;
3364 push (@ac_deps, $ac_dep)
3365 unless $ac_dep eq "aclocal.m4"
3366 || $ac_dep eq "acinclude.m4";
3370 elsif ($amdir eq '-I')
3377 # Note that it might be possible that aclocal.m4 doesn't exist but
3378 # should be auto-generated. This case probably isn't very
3381 return ($regen_aclocal, @ac_deps);
3384 # Rewrite a list of input files into a form suitable to put on a
3385 # dependency list. The idea is that if an input file has a directory
3386 # part the same as the current directory, then the directory part is
3387 # simply removed. But if the directory part is different, then
3388 # $(top_srcdir) is prepended. Among other things, this is used to
3389 # generate the dependency list for the output files generated by
3390 # AC_OUTPUT. Consider what the dependencies should look like in this
3392 # AC_OUTPUT(src/out:src/in1:lib/in2)
3393 # The first argument, ADD_SRCDIR, is 1 if $(top_srcdir) should be added.
3394 # If 0 then files that require this addition will simply be ignored.
3395 sub rewrite_inputs_into_dependencies
3397 my ($add_srcdir, @inputs) = @_;
3400 foreach my $single (@inputs)
3402 if (dirname ($single) eq $relative_dir)
3404 push (@newinputs, basename ($single));
3408 push (@newinputs, '$(top_srcdir)/' . $single);
3415 # Handle remaking and configure stuff.
3416 # We need the name of the input file, to do proper remaking rules.
3417 sub handle_configure
3419 my ($local, $input, @secondary_inputs) = @_;
3421 my $input_base = basename ($input);
3422 my $local_base = basename ($local);
3424 my $amfile = $input_base . '.am';
3425 # We know we can always add '.in' because it really should be an
3426 # error if the .in was missing originally.
3427 my $infile = '$(srcdir)/' . $input_base . '.in';
3428 my $colon_infile = '';
3429 if ($local ne $input || @secondary_inputs)
3431 $colon_infile = ':' . $input . '.in';
3433 $colon_infile .= ':' . join (':', @secondary_inputs)
3434 if @secondary_inputs;
3436 my @rewritten = &rewrite_inputs_into_dependencies (1, @secondary_inputs);
3438 my ($regen_aclocal_m4, @aclocal_m4_deps) = scan_aclocal_m4 ();
3441 &file_contents ('configure',
3445 => join (' ', @rewritten),
3447 => ((($relative_dir eq '.') ? '$@' : '$(subdir)/$@')
3452 => join (' ', @include_stack),
3456 => $cygnus_mode ? 'cygnus' : $strictness_name,
3458 => $cmdline_use_dependencies ? '' : ' --ignore-deps',
3459 'MAKEFILE-AM-SOURCES'
3460 => "$input$colon_infile",
3462 => $regen_aclocal_m4,
3464 => join (' ', @aclocal_m4_deps)));
3466 if ($relative_dir eq '.')
3468 &push_dist_common ('acconfig.h')
3472 # If we have a configure header, require it.
3473 my @local_fullnames = @config_fullnames;
3474 my @local_names = @config_names;
3476 my $distclean_config = '';
3477 foreach my $one_hdr (@config_headers)
3479 my $one_fullname = shift (@local_fullnames);
3480 my $one_name = shift (@local_names);
3482 my $header_dir = dirname ($one_name);
3484 # If the header is in the current directory we want to build
3485 # the header here. Otherwise, if we're at the topmost
3486 # directory and the header's directory doesn't have a
3487 # Makefile, then we also want to build the header.
3488 if ($relative_dir eq $header_dir
3489 || ($relative_dir eq '.' && ! &is_make_dir ($header_dir)))
3491 my ($cn_sans_dir, $stamp_dir);
3492 if ($relative_dir eq $header_dir)
3494 $cn_sans_dir = basename ($one_name);
3499 $cn_sans_dir = $one_name;
3500 if ($header_dir eq '.')
3506 $stamp_dir = $header_dir . '/';
3510 # Compute relative path from directory holding output
3511 # header to directory holding input header. FIXME:
3512 # doesn't handle case where we have multiple inputs.
3514 if (dirname ($one_hdr) eq $relative_dir)
3516 $ch_sans_dir = basename ($one_hdr);
3520 $ch_sans_dir = backname ($relative_dir) . '/' . $one_hdr;
3523 &require_file_with_conf_line ($config_header_line,
3524 $FOREIGN, $ch_sans_dir);
3526 # Header defined and in this directory.
3528 if (-f $one_name . '.top')
3530 push (@files, "${cn_sans_dir}.top");
3532 if (-f $one_name . '.bot')
3534 push (@files, "${cn_sans_dir}.bot");
3537 &push_dist_common (@files);
3539 # For now, acconfig.h can only appear in the top srcdir.
3540 if (-f 'acconfig.h')
3542 push (@files, '$(top_srcdir)/acconfig.h');
3545 my $stamp_name = 'stamp-h';
3546 $stamp_name .= "${hdr_index}" if scalar (@config_headers) > 1;
3548 my $out_dir = dirname ($ch_sans_dir);
3551 &file_contents ('remake-hdr',
3552 ('FILES' => join (' ', @files),
3553 'CONFIG_HEADER' => $cn_sans_dir,
3554 'CONFIG_HEADER_IN' => $ch_sans_dir,
3555 'CONFIG_HEADER_FULL' => $one_fullname,
3556 'STAMP' => "$stamp_dir$stamp_name",
3557 'SRC_STAMP' => "$out_dir/$stamp_name"));
3559 &create ("${relative_dir}/${out_dir}/${stamp_name}.in");
3560 &require_file_with_conf_line ($config_header_line, $FOREIGN,
3561 "${out_dir}/${stamp_name}.in");
3563 $distclean_config .= ' ' if $distclean_config;
3564 $distclean_config .= $cn_sans_dir;
3568 if ($distclean_config)
3570 $output_rules .= &file_contents ('clean-hdr',
3571 ('FILES' => $distclean_config));
3574 # Set location of mkinstalldirs.
3575 &define_variable ('mkinstalldirs',
3576 ('$(SHELL) ' . $config_aux_dir . '/mkinstalldirs'));
3578 &am_line_error ('CONFIG_HEADER',
3579 "`CONFIG_HEADER' is an anachronism; now determined from `$configure_ac'")
3580 if &variable_defined ('CONFIG_HEADER');
3582 my $config_header = '';
3583 foreach my $one_name (@config_names)
3585 # Generate CONFIG_HEADER define.
3587 if ($relative_dir eq dirname ($one_name))
3589 $one_hdr = basename ($one_name);
3593 $one_hdr = "\$(top_builddir)/${one_name}";
3596 $config_header .= ' ' if $config_header;
3597 $config_header .= $one_hdr;
3601 &define_variable ("CONFIG_HEADER", $config_header);
3604 # Now look for other files in this directory which must be remade
3605 # by config.status, and generate rules for them.
3606 my @actual_other_files = ();
3607 foreach my $lfile (@other_input_files)
3610 my (@inputs, @rewritten_inputs);
3611 my ($need_rewritten);
3612 if ($lfile =~ /^([^:]*):(.*)$/)
3614 # This is the ":" syntax of AC_OUTPUT.
3616 $local = basename ($file);
3617 @inputs = split (':', $2);
3618 @rewritten_inputs = &rewrite_inputs_into_dependencies (1, @inputs);
3619 $need_rewritten = 1;
3625 $local = basename ($file);
3626 @inputs = ($file . '.in');
3628 &rewrite_inputs_into_dependencies (1, @inputs);
3629 $need_rewritten = 0;
3632 # Make sure the dist directory for each input file is created.
3633 # We only have to do this at the topmost level though. This
3634 # is a bit ugly but it easier than spreading out the logic,
3635 # especially in cases like AC_OUTPUT(foo/out:bar/in), where
3636 # there is no Makefile in bar/.
3637 if ($relative_dir eq '.')
3641 $dist_dirs{dirname ($_)} = 1;
3645 # We skip any automake input files, as they are handled
3646 # elsewhere. We also skip files that aren't in this
3647 # directory. However, if the file's directory does not have a
3648 # Makefile, and we are currently doing `.', then we create a
3649 # rule to rebuild the file in the subdir.
3650 next if -f $file . '.am';
3651 my $fd = dirname ($file);
3652 if ($fd ne $relative_dir)
3654 if ($relative_dir eq '.' && ! &is_make_dir ($fd))
3664 # Some users have been tempted to put `stamp-h' in the
3665 # AC_OUTPUT line. This won't do the right thing, so we
3666 # explicitly fail here.
3667 if ($local eq 'stamp-h')
3669 # FIXME: allow real filename.
3670 &am_conf_error ($configure_ac, $ac_output_line,
3671 'stamp-h should not appear in AC_OUTPUT');
3675 $output_rules .= ($local . ': '
3676 . '$(top_builddir)/config.status '
3677 . join (' ', @rewritten_inputs) . "\n"
3679 . 'cd $(top_builddir) && CONFIG_FILES='
3680 . ($relative_dir eq '.' ? '' : '$(subdir)/')
3681 . '$@' . ($need_rewritten
3682 ? (':' . join (':', @inputs))
3684 . ' CONFIG_HEADERS= CONFIG_LINKS= $(SHELL) ./config.status'
3686 push (@actual_other_files, $local);
3688 # Require all input files.
3689 &require_file_with_conf_line ($ac_output_line, $FOREIGN,
3690 &rewrite_inputs_into_dependencies (0, @inputs));
3693 # These files get removed by "make clean".
3694 &define_pretty_variable ('CONFIG_CLEAN_FILES', '', @actual_other_files);
3700 my @r = &am_install_var ('-defaultdist', 'header', 'HEADERS', 'include',
3701 'oldinclude', 'pkginclude',
3705 next unless /\.(.*)$/;
3706 &saw_extension ($1);
3712 return if ! $seen_gettext || $relative_dir ne '.';
3714 if (! &variable_defined ('SUBDIRS'))
3717 ("AM_GNU_GETTEXT used but SUBDIRS not defined");
3721 my @subdirs = &variable_value_as_list ('SUBDIRS', 'all');
3722 &am_line_error ('SUBDIRS',
3723 "AM_GNU_GETTEXT used but `po' not in SUBDIRS")
3724 if ! grep ('po', @subdirs);
3725 &am_line_error ('SUBDIRS',
3726 "AM_GNU_GETTEXT used but `intl' not in SUBDIRS")
3727 if ! grep ('intl', @subdirs);
3729 &require_file_with_conf_line ($ac_gettext_line, $GNU, 'ABOUT-NLS');
3731 # Ensure that each language in ALL_LINGUAS has a .po file, and
3732 # each po file is mentioned in ALL_LINGUAS.
3735 my %linguas = map { $_ => 1 } split (' ', $all_linguas);
3742 &am_line_error ($all_linguas_line,
3743 ("po/$_.po exists but `$_' not in `ALL_LINGUAS'"))
3747 foreach (keys %linguas)
3749 &am_line_error ($all_linguas_line,
3750 "$_ in `ALL_LINGUAS' but po/$_.po does not exist")
3756 &am_error ("AM_GNU_GETTEXT in `$configure_ac' but `ALL_LINGUAS' not defined");
3760 # Handle footer elements.
3763 # NOTE don't use define_pretty_variable here, because
3764 # $contents{...} is already defined.
3765 $output_vars .= 'SOURCES = ' . variable_value ('SOURCES') . "\n\n"
3766 if variable_value ('SOURCES');
3769 &am_line_error ('.SUFFIXES',
3770 "use variable `SUFFIXES', not target `.SUFFIXES'")
3771 if target_defined ('.SUFFIXES');
3773 # Note: AIX 4.1 /bin/make will fail if any suffix rule appears
3774 # before .SUFFIXES. So we make sure that .SUFFIXES appears before
3775 # anything else, by sticking it right after the default: target.
3776 $output_header .= ".SUFFIXES:\n";
3777 if (@suffixes || &variable_defined ('SUFFIXES'))
3779 # Make sure suffixes has unique elements. Sort them to ensure
3780 # the output remains consistent. However, $(SUFFIXES) is
3781 # always at the start of the list, unsorted. This is done
3782 # because make will choose rules depending on the ordering of
3783 # suffixes, and this lets the user have some control. Push
3784 # actual suffixes, and not $(SUFFIXES). Some versions of make
3785 # do not like variable substitutions on the .SUFFIXES line.
3786 my @user_suffixes = (&variable_defined ('SUFFIXES')
3787 ? &variable_value_as_list ('SUFFIXES', '')
3790 my %suffixes = map { $_ => 1 } @suffixes;
3791 delete @suffixes{@user_suffixes};
3793 $output_header .= (".SUFFIXES: "
3794 . join (' ', @user_suffixes, sort keys %suffixes)
3798 $output_trailer .= file_contents ('footer');
3801 # Deal with installdirs target.
3802 sub handle_installdirs ()
3805 &file_contents ('install',
3807 => variable_value ('_am_installdirs') || ''));
3811 # Deal with all and all-am.
3814 my ($makefile) = @_;
3818 # Put this at the beginning for the sake of non-GNU makes. This
3819 # is still wrong if these makes can run parallel jobs. But it is
3821 unshift (@all, basename ($makefile));
3823 foreach my $one_name (@config_names)
3825 push (@all, basename ($one_name))
3826 if dirname ($one_name) eq $relative_dir;
3829 # Install `all' hooks.
3830 if (&target_defined ("all-local"))
3832 push (@all, "all-local");
3833 &depend ('.PHONY', "all-local");
3836 &pretty_print_rule ("all-am:", "\t\t", @all);
3837 &depend ('.PHONY', 'all-am', 'all');
3842 my @local_headers = ();
3843 push @local_headers, '$(BUILT_SOURCES)'
3844 if &variable_defined ('BUILT_SOURCES');
3845 foreach my $one_name (@config_names)
3847 push @local_headers, basename ($one_name)
3848 if dirname ($one_name) eq $relative_dir;
3853 # We need to make sure config.h is built before we recurse.
3854 # We also want to make sure that built sources are built
3855 # before any ordinary `all' targets are run. We can't do this
3856 # by changing the order of dependencies to the "all" because
3857 # that breaks when using parallel makes. Instead we handle
3858 # things explicitly.
3859 $output_all .= ("all: " . join (' ', @local_headers)
3861 . '$(MAKE) $(AM_MAKEFLAGS) '
3862 . (&variable_defined ('SUBDIRS')
3863 ? 'all-recursive' : 'all-am')
3868 $output_all .= "all: " . (&variable_defined ('SUBDIRS')
3869 ? 'all-recursive' : 'all-am') . "\n\n";
3874 # Handle check merge target specially.
3875 sub do_check_merge_target
3877 if (&target_defined ('check-local'))
3879 # User defined local form of target. So include it.
3880 push (@check_tests, 'check-local');
3881 &depend ('.PHONY', 'check-local');
3884 # In --cygnus mode, check doesn't depend on all.
3887 # Just run the local check rules.
3888 &pretty_print_rule ('check-am:', "\t\t", @check);
3892 # The check target must depend on the local equivalent of
3893 # `all', to ensure all the primary targets are built. Then it
3894 # must build the local check rules.
3895 $output_rules .= "check-am: all-am\n";
3896 &pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ",
3900 &pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ",
3904 &depend ('.PHONY', 'check', 'check-am');
3905 $output_rules .= ("check: "
3906 . (&variable_defined ('SUBDIRS')
3907 ? 'check-recursive' : 'check-am')
3911 # Handle all 'clean' targets.
3916 # Don't include `MAINTAINER'; it is handled specially below.
3917 foreach my $name ('MOSTLY', '', 'DIST')
3919 $transform{"${name}CLEAN"} = &variable_defined ("${name}CLEANFILES");
3922 # Built sources are automatically removed by maintainer-clean.
3923 push (@maintainer_clean_files, '$(BUILT_SOURCES)')
3924 if &variable_defined ('BUILT_SOURCES');
3925 push (@maintainer_clean_files, '$(MAINTAINERCLEANFILES)')
3926 if &variable_defined ('MAINTAINERCLEANFILES');
3928 $output_rules .= &file_contents ('clean',
3931 # Join with no space to avoid
3932 # spurious `test -z' success at
3934 => join ('', @maintainer_clean_files),
3936 # A space is required in the join here.
3937 => join (' ', @maintainer_clean_files)));
3941 # &depend ($CATEGORY, @DEPENDENDEES)
3942 # ----------------------------------
3943 # The target $CATEGORY depends on @DEPENDENDEES.
3946 my ($category, @dependendees) = @_;
3948 push (@{$dependencies{$category}}, @dependendees);
3953 # &target_cmp ($A, $B)
3954 # --------------------
3955 # Subroutine for &handle_factored_dependencies to let `.PHONY' be last.
3968 # &handle_factored_dependencies ()
3969 # --------------------------------
3970 # Handle everything related to gathered targets.
3971 sub handle_factored_dependencies
3974 foreach my $utarg ('uninstall-data-local', 'uninstall-data-hook',
3975 'uninstall-exec-local', 'uninstall-exec-hook')
3977 if (&target_defined ($utarg))
3980 $x =~ s/(data|exec)-//;
3981 &am_line_error ($utarg, "use `$x', not `$utarg'");
3985 if (&target_defined ('install-local'))
3987 &am_line_error ('install-local',
3988 "use `install-data-local' or `install-exec-local', "
3989 . "not `install-local'");
3992 if (!defined $options{'no-installinfo'}
3993 && &target_defined ('install-info-local'))
3995 &am_line_error ('install-info-local',
3996 "`install-info-local' target defined but "
3997 . "`no-installinfo' option not in use");
4000 # Install the -local hooks.
4001 foreach (keys %dependencies)
4003 # Hooks are installed on the -am targets.
4005 if (&target_defined ("$_-local"))
4007 depend ("$_-am", "$_-local");
4008 &depend ('.PHONY', "$_-local");
4012 # Install the -hook hooks.
4013 # FIXME: Why not be as liberal as we are with -local hooks?
4014 foreach ('install-exec', 'install-data')
4016 if (&target_defined ("$_-hook"))
4018 $actions{"$_-am"} .=
4019 ("\t\@\$(NORMAL_INSTALL)\n"
4020 . "\t" . '$(MAKE) $(AM_MAKEFLAGS) ' . "$_-hook\n");
4024 # All the required targets are phony.
4025 depend ('.PHONY', keys %required_targets);
4027 # Actually output gathered targets.
4028 foreach (sort target_cmp keys %dependencies)
4030 # If there is nothing about this guy, skip it.
4032 unless (@{$dependencies{$_}}
4034 || $required_targets{$_});
4035 &pretty_print_rule ("$_:", "\t",
4036 uniq (sort @{$dependencies{$_}}));
4037 $output_rules .= $actions{$_}
4038 if defined $actions{$_};
4039 $output_rules .= "\n";
4044 # &handle_tests_dejagnu ()
4045 # ------------------------
4046 sub handle_tests_dejagnu
4048 push (@check_tests, 'check-DEJAGNU');
4050 # Only create site.exp rule if user hasn't already written one.
4052 file_contents ('dejagnu', ('SITE-EXP' => ! target_defined ('site.exp')));
4056 # Handle TESTS variable and other checks.
4059 if (defined $options{'dejagnu'})
4061 &handle_tests_dejagnu;
4065 foreach my $c ('DEJATOOL', 'RUNTEST', 'RUNTESTFLAGS')
4068 "`$c' defined but `dejagnu' not in `AUTOMAKE_OPTIONS'")
4069 if &variable_defined ($c);
4073 if (&variable_defined ('TESTS'))
4075 push (@check_tests, 'check-TESTS');
4076 $output_rules .= &file_contents ('check');
4080 # Handle Emacs Lisp.
4081 sub handle_emacs_lisp
4083 my @elfiles = &am_install_var ('-candist', 'lisp', 'LISP',
4086 return if ! @elfiles;
4088 # Generate .elc files.
4089 my @elcfiles = map { $_ . 'c' } @elfiles;
4090 &define_pretty_variable ('ELCFILES', '', @elcfiles);
4092 push (@all, '$(ELCFILES)');
4094 &am_error ("`lisp_LISP' defined but `AM_PATH_LISPDIR' not in `$configure_ac'")
4095 if ! $seen_lispdir && &variable_defined ('lisp_LISP');
4097 &require_file_with_conf_line ('AM_PATH_LISPDIR', $FOREIGN, 'elisp-comp');
4103 my @pyfiles = &am_install_var ('-defaultdist', 'python', 'PYTHON',
4104 'python', 'noinst');
4105 return if ! @pyfiles;
4107 # Found some python.
4108 &am_error ("`python_PYTHON' defined but `AM_PATH_PYTHON' not in `$configure_ac'")
4109 if ! $seen_pythondir && &variable_defined ('python_PYTHON');
4111 &require_file_with_conf_line ('AM_PATH_PYTHON', $FOREIGN, 'py-compile');
4112 &define_variable ('py_compile', $config_aux_dir . '/py-compile');
4118 my @sourcelist = &am_install_var ('-candist',
4120 'java', 'noinst', 'check');
4121 return if ! @sourcelist;
4123 my %valid = &am_primary_prefixes ('JAVA', 1,
4124 'java', 'noinst', 'check');
4127 foreach my $curs (keys %valid)
4129 if (! &variable_defined ($curs . '_JAVA') || $curs eq 'EXTRA')
4136 &am_line_error ($curs . '_JAVA',
4137 "multiple _JAVA primaries in use");
4142 push (@all, 'class' . $dir . '.stamp');
4146 # Handle some of the minor options.
4147 sub handle_minor_options
4149 if (defined $options{'readme-alpha'})
4151 if ($relative_dir eq '.')
4153 if ($package_version !~ /^$GNITS_VERSION_PATTERN$/)
4155 # FIXME: allow real filename.
4156 &am_conf_line_error ($configure_ac,
4157 $package_version_line,
4158 "version `$package_version' doesn't follow Gnits standards");
4160 elsif (defined $1 && -f 'README-alpha')
4162 # This means we have an alpha release. See
4163 # GNITS_VERSION_PATTERN for details.
4164 &require_file ($FOREIGN, 'README-alpha');
4170 ################################################################
4173 my @make_input_list;
4174 # &scan_autoconf_config_files ($CONFIG-FILES)
4175 # -------------------------------------------
4176 # Study $CONFIG-FILES which is the first argument to AC_CONFIG_FILES
4178 sub scan_autoconf_config_files
4180 my ($config_files) = @_;
4181 # Look at potential Makefile.am's.
4182 foreach (split ' ', $config_files)
4184 # Must skip empty string for Perl 4.
4185 next if $_ eq "\\" || $_ eq '';
4187 # Handle $local:$input syntax. Note that we ignore
4188 # every input file past the first, though we keep
4189 # those around for later.
4190 my ($local, $input, @rest) = split (/:/);
4197 # FIXME: should be error if .in is missing.
4198 $input =~ s/\.in$//;
4201 if (-f $input . '.am')
4203 # We have a file that automake should generate.
4204 push (@make_input_list, $input);
4205 $make_list{$input} = join (':', ($local, @rest));
4209 # We have a file that automake should cause to be
4210 # rebuilt, but shouldn't generate itself.
4211 push (@other_input_files, $_);
4217 # &scan_autoconf_traces ($FILENAME)
4218 # ---------------------------------
4219 # FIXME: For the time being, we don't care about the FILENAME.
4220 sub scan_autoconf_traces
4222 my ($filename) = @_;
4224 my $traces = "$ENV{amtraces} ";
4226 $traces .= ' -t AC_CONFIG_FILES';
4227 $traces .= ' -t AC_LIBSOURCE';
4228 $traces .= ' -t AC_SUBST';
4230 my $tracefh = new IO::File ("$traces |");
4233 die "$me: couldn't open `$traces': $!\n";
4235 print "$me: reading $traces\n" if $verbose;
4237 while ($_ = $tracefh->getline)
4240 my ($file, $line, $macro, @args) = split /:/;
4241 my $here = "$file:$line";
4243 # Alphabetical ordering please.
4244 if ($macro eq 'AC_CONFIG_FILES')
4246 # Look at potential Makefile.am's.
4247 &scan_autoconf_config_files ($args[0]);
4249 elsif ($macro eq 'AC_LIBSOURCE')
4251 my $source = "$args[0].c";
4252 # We should actually also `close' the sources: getopt.c
4253 # wants getopt.h etc. But actually it should be done in the
4254 # macro itself, i.e., we have to first fix Autoconf to extend
4255 # _AC_LIBOBJ_DECL and use it the in various macros.
4256 if (!defined $libsources{$source})
4258 print STDERR "traces: discovered $source\n";
4259 $libsources{$source} = $here;
4262 elsif ($macro eq 'AC_SUBST')
4264 if (!defined $configure_vars{$args[0]})
4266 print STDERR "traces: discovered AC_SUBST($args[0])\n";
4267 $configure_vars{$args[0]} = $here;
4273 || die "$me: close: $traces: $!\n";
4277 # &scan_one_autoconf_file ($FILENAME)
4278 # -----------------------------------
4279 # Scan one file for interesting things. Subroutine of
4280 # &scan_autoconf_files.
4281 sub scan_one_autoconf_file
4283 my ($filename) = @_;
4285 my $configfh = new IO::File ("< $filename");
4288 die "$me: couldn't open `$filename': $!\n";
4290 print "$me: reading $filename\n" if $verbose;
4292 my ($in_ac_output, $in_ac_replace) = (0, 0);
4293 while ($_ = $configfh->getline)
4295 # Remove comments from current line.
4299 # Skip macro definitions. Otherwise we might be confused into
4300 # thinking that a macro that was only defined was actually
4304 # Follow includes. This is a weirdness commonly in use at
4305 # Cygnus and hopefully nowhere else.
4306 if (/sinclude\((.*)\)/ && -f $1)
4308 # $_ being local, if we don't preserve it, when coming
4309 # back we will have $_ undefined, which is bad for the
4310 # the rest of this routine.
4311 my $underscore = $_;
4312 &scan_one_autoconf_file ($1);
4316 # Populate libobjs array.
4317 if (/AC_FUNC_ALLOCA/)
4319 $libsources{'alloca.c'} = 1;
4321 elsif (/AC_FUNC_GETLOADAVG/)
4323 $libsources{'getloadavg.c'} = 1;
4325 elsif (/AC_FUNC_MEMCMP/)
4327 $libsources{'memcmp.c'} = 1;
4329 elsif (/AC_STRUCT_ST_BLOCKS/)
4331 $libsources{'fileblocks.c'} = 1;
4333 elsif (/A[CM]_REPLACE_GNU_GETOPT/)
4335 $libsources{'getopt.c'} = 1;
4336 $libsources{'getopt1.c'} = 1;
4338 elsif (/AM_FUNC_STRTOD/)
4340 $libsources{'strtod.c'} = 1;
4342 elsif (/AM_WITH_REGEX/)
4344 $libsources{'rx.c'} = 1;
4345 $libsources{'rx.h'} = 1;
4346 $libsources{'regex.c'} = 1;
4347 $libsources{'regex.h'} = 1;
4349 elsif (/AC_FUNC_MKTIME/)
4351 $libsources{'mktime.c'} = 1;
4353 elsif (/AM_FUNC_ERROR_AT_LINE/)
4355 $libsources{'error.c'} = 1;
4356 $libsources{'error.h'} = 1;
4358 elsif (/AM_FUNC_OBSTACK/)
4360 $libsources{'obstack.c'} = 1;
4361 $libsources{'obstack.h'} = 1;
4363 elsif (/LIBOBJS="(.*)\s+\$LIBOBJS"/
4364 || /LIBOBJS="\$LIBOBJS\s+(.*)"/)
4366 foreach my $libobj_iter (split (' ', $1))
4368 if ($libobj_iter =~ /^(.*)\.o(bj)?$/
4369 || $libobj_iter =~ /^(.*)\.\$ac_objext$/
4370 || $libobj_iter =~ /^(.*)\.\$\{ac_objext\}$/)
4372 $libsources{$1 . '.c'} = 1;
4376 elsif (/AC_LIBOBJ\(([^)]+)\)/)
4378 $libsources{"$1.c"} = 1;
4381 if (! $in_ac_replace && s/AC_REPLACE_FUNCS\s*\(\[?//)
4387 $in_ac_replace = 0 if s/[\]\)].*$//;
4388 # Remove trailing backslash.
4392 # Need to skip empty elements for Perl 4.
4394 $libsources{$_ . '.c'} = 1;
4398 if (/$obsolete_rx/o)
4401 if ($obsolete_macros{$1} ne '')
4403 $hint = '; ' . $obsolete_macros{$1};
4405 &am_conf_line_error ($filename, $., "`$1' is obsolete$hint");
4408 # Process the AC_OUTPUT and AC_CONFIG_FILES macros.
4409 if (! $in_ac_output && s/AC_(OUTPUT|CONFIG_FILES)\s*\(\[?//)
4412 $ac_output_line = $.;
4423 # Look at potential Makefile.am's.
4424 &scan_autoconf_config_files ($_);
4426 if ($closing && @make_input_list == 0 && @other_input_files == 0)
4428 &am_conf_line_error ($filename, $ac_output_line,
4429 "No files mentioned in `AC_OUTPUT'");
4434 if (/$AC_CONFIG_AUX_DIR_PATTERN/o)
4436 @config_aux_path = &unquote_m4_arg ($1);
4437 $config_aux_dir_set_in_configure_in = 1;
4440 # Check for ansi2knr.
4441 $am_c_prototypes = 1 if /AM_C_PROTOTYPES/;
4443 # Check for exe extension stuff.
4447 $configure_vars{'EXEEXT'} = $filename . ':' . $.;
4453 $configure_vars{'OBJEXT'} = $filename . ':' . $.;
4456 # Check for `-c -o' code.
4457 $seen_cc_c_o = 1 if /AM_PROG_CC_C_O/;
4459 # Check for NLS support.
4460 if (/AM_GNU_GETTEXT/)
4463 $ac_gettext_line = $.;
4466 # Look for ALL_LINGUAS.
4467 if (/ALL_LINGUAS="(.*)"$/ || /ALL_LINGUAS=(.*)$/)
4471 $all_linguas_line = $.;
4474 # Handle configuration headers. A config header of `[$1]'
4475 # means we are actually scanning AM_CONFIG_HEADER from
4477 if (/A([CM])_CONFIG_HEADERS?\s*\((.*)\)/
4481 ($filename, $., "`automake requires `AM_CONFIG_HEADER', not `AC_CONFIG_HEADER'")
4484 $config_header_line = $.;
4485 foreach my $one_hdr (split (' ', &unquote_m4_arg ($2)))
4487 push (@config_fullnames, $one_hdr);
4488 if ($one_hdr =~ /^([^:]+):(.+)$/)
4490 push (@config_names, $1);
4491 push (@config_headers, $2);
4495 push (@config_names, $one_hdr);
4496 push (@config_headers, $one_hdr . '.in');
4501 # Handle AC_CANONICAL_*. Always allow upgrading to
4502 # AC_CANONICAL_SYSTEM, but never downgrading.
4503 $seen_canonical = $AC_CANONICAL_HOST
4504 if ! $seen_canonical
4505 && (/AC_CANONICAL_HOST/ || /AC_CHECK_TOOL/);
4506 $seen_canonical = $AC_CANONICAL_SYSTEM if /AC_CANONICAL_SYSTEM/;
4508 # If using X, include some extra variable definitions. NOTE
4509 # we don't want to force these into CFLAGS or anything,
4510 # because not all programs will necessarily use X.
4513 foreach my $var ('X_CFLAGS', 'X_LIBS', 'X_EXTRA_LIBS',
4516 $configure_vars{$var} = $filename . ':' . $.
4520 # This macro handles several different things.
4521 if (/$AM_INIT_AUTOMAKE_PATTERN/o)
4523 ($package_version = $1) =~ s/$AM_PACKAGE_VERSION_PATTERN/$1/o;
4524 $package_version_line = $.;
4525 $seen_init_automake = 1;
4530 $configure_vars{'LEX'} = $filename . ':' . $.;
4531 $seen_decl_yytext = 1;
4533 if (/AC_DECL_YYTEXT/ && $filename =~ /configure\.(ac|in)$/)
4535 &am_conf_line_warning ($filename, $., "`AC_DECL_YYTEXT' is covered by `AM_PROG_LEX'");
4537 if (/AC_PROG_LEX/ && $filename =~ /configure\.(ac|in)$/)
4539 &am_conf_line_warning ($filename, $., "automake requires `AM_PROG_LEX', not `AC_PROG_LEX'");
4542 if (/AC_PROG_(F77|YACC|RANLIB|CC|CXXCPP|CXX|LEX|AWK|CPP|LN_S)/)
4544 $configure_vars{$1} = $filename . ':' . $.;
4546 if (/$AC_CHECK_PATTERN/o)
4548 $configure_vars{$3} = $filename . ':' . $.;
4550 if (/$AM_MISSING_PATTERN/o
4554 && $1 ne 'AUTOHEADER'
4555 # AM_INIT_AUTOMAKE is AM_MISSING_PROG'ing MAKEINFO. But
4556 # we handle it elsewhere.
4557 && $1 ne 'MAKEINFO')
4559 $configure_vars{$1} = $filename . ':' . $.;
4562 # Explicitly avoid ANSI2KNR -- we AC_SUBST that in protos.m4,
4563 # but later define it elsewhere. This is pretty hacky. We
4564 # also explicitly avoid INSTALL_SCRIPT and some other
4565 # variables because they are defined in header-vars.am.
4567 if (/$AC_SUBST_PATTERN/o
4569 && $1 ne 'INSTALL_SCRIPT'
4570 && $1 ne 'INSTALL_DATA')
4572 $configure_vars{$1} = $filename . ':' . $.;
4575 $seen_decl_yytext = 1 if /AC_DECL_YYTEXT/;
4576 if (/AM_MAINTAINER_MODE/)
4578 $seen_maint_mode = 1;
4579 $configure_cond{'MAINTAINER_MODE'} = 1;
4582 $seen_lispdir = 1 if /AM_PATH_LISPDIR/;
4584 if (/AM_PATH_PYTHON/)
4586 $seen_pythondir = 1;
4587 $configure_vars{'pythondir'} = $filename . ':' . $.;
4588 $configure_vars{'PYTHON'} = $filename . ':' . $.;
4591 if (/A(C|M)_PROG_LIBTOOL/)
4593 # We're not ready for this yet. People still use a
4594 # libtool with no AC_PROG_LIBTOOL. Once that is the
4595 # dominant version we can reenable this code -- but next
4596 # time by mentioning the macro in %obsolete_macros, both
4597 # here and in aclocal.in.
4599 # if (/AM_PROG_LIBTOOL/)
4601 # &am_conf_line_warning ($filename, $., "`AM_PROG_LIBTOOL' is obsolete, use `AC_PROG_LIBTOOL' instead");
4605 $configure_vars{'LIBTOOL'} = $filename . ':' . $.;
4606 $configure_vars{'RANLIB'} = $filename . ':' . $.;
4607 $configure_vars{'CC'} = $filename . ':' . $.;
4608 # AC_PROG_LIBTOOL runs AC_CANONICAL_HOST. Make sure we
4609 # never downgrade (if we've seen AC_CANONICAL_SYSTEM).
4610 $seen_canonical = $AC_CANONICAL_HOST if ! $seen_canonical;
4613 $seen_multilib = 1 if (/AM_ENABLE_MULTILIB/);
4615 if (/$AM_CONDITIONAL_PATTERN/o)
4617 $configure_cond{$1} = 1;
4620 # Check for Fortran 77 intrinsic and run-time libraries.
4621 if (/AC_F77_LIBRARY_LDFLAGS/)
4623 $configure_vars{'FLIBS'} = $filename . ':' . $.;
4631 # &scan_autoconf_files ()
4632 # -----------------------
4633 # Check whether we use `configure.ac' or `configure.in'.
4634 # Scan it (and possibly `aclocal.m4') for interesting things.
4635 # We must scan aclocal.m4 because there might be AC_SUBSTs and such there.
4636 sub scan_autoconf_files
4638 # Reinitialize libsources here. This isn't really necessary,
4639 # since we currently assume there is only one configure.ac. But
4640 # that won't always be the case.
4643 warn "$me: both `configure.ac' and `configure.in' present:"
4644 . " ignoring `configure.in'\n"
4645 if -f 'configure.ac' && -f 'configure.in';
4646 $configure_ac = 'configure.in'
4647 if -f 'configure.in';
4648 $configure_ac = 'configure.ac'
4649 if -f 'configure.ac';
4650 die "$me: `configure.ac' or `configure.in' is required\n"
4653 &scan_one_autoconf_file ($configure_ac);
4654 &scan_one_autoconf_file ('aclocal.m4')
4657 if (defined $ENV{'amtraces'})
4659 warn '$me: Autoconf traces is an experimental feature';
4660 warn '$me: use at your own risks';
4662 &scan_autoconf_traces ($configure_ac);
4665 # Set input and output files if not specified by user.
4668 @input_files = @make_input_list;
4669 %output_files = %make_list;
4672 @configure_input_files = @make_input_list;
4674 &am_conf_error ("`AM_INIT_AUTOMAKE' must be used")
4675 if ! $seen_init_automake;
4677 # Look for some files we need. Always check for these. This
4678 # check must be done for every run, even those where we are only
4679 # looking at a subdir Makefile. We must set relative_dir so that
4680 # the file-finding machinery works.
4681 # FIXME: Is this broken because it needs dynamic scopes.
4682 # My tests seems to show it's not the case.
4683 $relative_dir = '.';
4684 &require_config_file ($FOREIGN, 'install-sh', 'mkinstalldirs', 'missing');
4685 &am_error ("`install.sh' is an anachronism; use `install-sh' instead")
4686 if -f $config_aux_path[0] . '/install.sh';
4688 &require_config_file ($FOREIGN, 'py-compile')
4691 # Preserve dist_common for later.
4692 $configure_dist_common = variable_value ('DIST_COMMON', 'TRUE') || '';
4695 ################################################################
4697 # Set up for Cygnus mode.
4700 return unless $cygnus_mode;
4702 &set_strictness ('foreign');
4703 $options{'no-installinfo'} = 1;
4704 $options{'no-dependencies'} = 1;
4705 $use_dependencies = 0;
4707 if (! $seen_maint_mode)
4709 &am_conf_error ("`AM_MAINTAINER_MODE' required when --cygnus specified");
4713 # Do any extra checking for GNU standards.
4714 sub check_gnu_standards
4716 if ($relative_dir eq '.')
4718 # In top level (or only) directory.
4719 &require_file ($GNU, 'INSTALL', 'NEWS', 'README', 'COPYING',
4720 'AUTHORS', 'ChangeLog');
4723 if ($strictness >= $GNU
4724 && defined $options{'no-installman'})
4726 &am_line_error ('AUTOMAKE_OPTIONS',
4727 "option `no-installman' disallowed by GNU standards");
4730 if ($strictness >= $GNU
4731 && defined $options{'no-installinfo'})
4733 &am_line_error ('AUTOMAKE_OPTIONS',
4734 "option `no-installinfo' disallowed by GNU standards");
4738 # Do any extra checking for GNITS standards.
4739 sub check_gnits_standards
4741 if ($relative_dir eq '.')
4743 # In top level (or only) directory.
4744 &require_file ($GNITS, 'THANKS');
4748 ################################################################
4750 # Functions to handle files of each language.
4752 # Each `lang_X_rewrite($DIRECTORY, $BASE, $EXT)' function follows a
4753 # simple formula: Return value is $LANG_SUBDIR if the resulting object
4754 # file should be in a subdir if the source file is, $LANG_PROCESS if
4755 # file is to be dealt with, $LANG_IGNORE otherwise.
4757 # Much of the actual processing is handled in
4758 # handle_single_transform_list. These functions exist so that
4759 # auxiliary information can be recorded for a later cleanup pass.
4760 # Note that the calls to these functions are computed, so don't bother
4761 # searching for their precise names in the source.
4763 # This is just a convenience function that can be used to determine
4764 # when a subdir object should be used.
4767 return defined $options{'subdir-objects'} ? $LANG_SUBDIR : $LANG_PROCESS;
4770 # Rewrite a single C source file.
4773 my ($directory, $base, $ext) = @_;
4775 if (defined $options{'ansi2knr'} && $base =~ /_$/)
4777 # FIXME: include line number in error.
4778 &am_error ("C source file `$base.c' would be deleted by ansi2knr rules");
4781 my $r = $LANG_PROCESS;
4782 if (defined $options{'subdir-objects'})
4785 $base = $directory . '/' . $base;
4789 # Only give error once.
4791 # FIXME: line number.
4792 &am_error ("C objects in subdir but `AM_PROG_CC_C_O' not in `$configure_ac'");
4795 &require_file ($FOREIGN, 'compile')
4796 if $relative_dir eq '.';
4799 $de_ansi_files{$base} = 1;
4803 # Rewrite a single C++ source file.
4804 sub lang_cxx_rewrite
4806 return &lang_sub_obj;
4809 # Rewrite a single header file.
4810 sub lang_header_rewrite
4812 # Header files are simply ignored.
4813 return $LANG_IGNORE;
4816 # Rewrite a single yacc file.
4817 sub lang_yacc_rewrite
4819 my ($directory, $base, $ext) = @_;
4821 my $r = &lang_c_rewrite ($directory, $base, $ext);
4823 if ($r == $LANG_SUBDIR)
4825 $pfx = $directory . '/';
4827 $yacc_sources{$pfx . $base . '.' . $ext} = 1;
4829 &saw_extension ('c');
4831 &push_dist_common ($pfx . $base . '.' . $ext);
4835 # Rewrite a single yacc++ file.
4836 sub lang_yaccxx_rewrite
4838 my ($directory, $base, $ext) = @_;
4840 my $r = $LANG_PROCESS;
4842 if (defined $options{'subdir-objects'})
4844 $pfx = $directory . '/';
4847 $yacc_sources{$pfx . $base . '.' . $ext} = 1;
4849 &saw_extension ($ext);
4851 &push_dist_common ($pfx . $base . '.' . $ext);
4855 # Rewrite a single lex file.
4856 sub lang_lex_rewrite
4858 my ($directory, $base, $ext) = @_;
4860 my $r = &lang_c_rewrite ($directory, $base, $ext);
4862 if ($r == $LANG_SUBDIR)
4864 $pfx = $directory . '/';
4866 $lex_sources{$pfx . $base . '.' . $ext} = 1;
4868 &saw_extension ('c');
4870 &push_dist_common ($pfx . $base . '.' . $ext);
4874 # Rewrite a single lex++ file.
4875 sub lang_lexxx_rewrite
4877 my ($directory, $base, $ext) = @_;
4879 my $r = $LANG_PROCESS;
4881 if (defined $options{'subdir-objects'})
4883 $pfx = $directory . '/';
4886 $lex_sources{$pfx . $base . '.' . $ext} = 1;
4888 &saw_extension ($ext);
4890 &push_dist_common ($pfx . $base . '.' . $ext);
4894 # Rewrite a single assembly file.
4895 sub lang_asm_rewrite
4897 return &lang_sub_obj;
4900 # Rewrite a single Fortran 77 file.
4901 sub lang_f77_rewrite
4903 return $LANG_PROCESS;
4906 # Rewrite a single preprocessed Fortran 77 file.
4907 sub lang_ppf77_rewrite
4909 return $LANG_PROCESS;
4912 # Rewrite a single ratfor file.
4913 sub lang_ratfor_rewrite
4915 return $LANG_PROCESS;
4918 # Rewrite a single Objective C file.
4919 sub lang_objc_rewrite
4921 return &lang_sub_obj;
4924 # Rewrite a single Java file.
4925 sub lang_java_rewrite
4927 return $LANG_SUBDIR;
4930 # The lang_X_finish functions are called after all source file
4931 # processing is done. Each should handle defining rules for the
4932 # language, etc. A finish function is only called if a source file of
4933 # the appropriate type has been seen.
4937 # Push all libobjs files onto de_ansi_files. We actually only
4938 # push files which exist in the current directory, and which are
4939 # genuine source files.
4940 foreach my $file (keys %libsources)
4942 if ($file =~ /^(.*)\.[cly]$/ && -f "$relative_dir/$file")
4944 $de_ansi_files{$1} = 1;
4948 if (defined $options{'ansi2knr'} && keys %de_ansi_files)
4950 # Make all _.c files depend on their corresponding .c files.
4952 foreach my $base (sort keys %de_ansi_files)
4954 # Each _.c file must depend on ansi2knr; otherwise it
4955 # might be used in a parallel build before it is built.
4956 # We need to support files in the srcdir and in the build
4957 # dir (because these files might be auto-generated. But
4958 # we can't use $< -- some makes only define $< during a
4960 $output_rules .= ($base . "_.c: $base.c \$(ANSI2KNR)\n\t"
4961 . '$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) '
4962 . '`if test -f $(srcdir)/' . $base . '.c'
4963 . '; then echo $(srcdir)/' . $base . '.c'
4964 . '; else echo ' . $base . '.c; fi` '
4965 . "| sed 's/^# \\([0-9]\\)/#line \\1/' "
4966 . '| $(ANSI2KNR) > ' . $base . "_.c\n");
4967 push (@objects, $base . '_.$(OBJEXT)');
4968 push (@objects, $base . '_.lo')
4972 # Make all _.o (and _.lo) files depend on ansi2knr.
4973 # Use a sneaky little hack to make it print nicely.
4974 &pretty_print_rule ('', '', @objects, ':', '$(ANSI2KNR)');
4979 # This is a helper for both lex and yacc.
4980 sub yacc_lex_finish_helper
4982 return if defined $language_scratch{'lex-yacc-done'};
4983 $language_scratch{'lex-yacc-done'} = 1;
4985 # If there is more than one distinct yacc (resp lex) source file
4986 # in a given directory, then the `ylwrap' program is required to
4987 # allow parallel builds to work correctly. FIXME: for now, no
4989 &require_config_file ($FOREIGN, 'ylwrap');
4990 if ($config_aux_dir_set_in_configure_in)
4992 &define_variable ('YLWRAP', $config_aux_dir . "/ylwrap");
4996 &define_variable ('YLWRAP', '$(srcdir)/ylwrap');
5000 sub lang_yacc_finish
5002 return if defined $language_scratch{'yacc-done'};
5003 $language_scratch{'yacc-done'} = 1;
5005 my %seen_suffix = ();
5006 my @yacc_files = sort keys %yacc_sources;
5007 my $yacc_count = scalar (@yacc_files);
5008 foreach my $file (@yacc_files)
5011 &output_yacc_build_rule ($1, $yacc_count > 1)
5012 if ! defined $seen_suffix{$1};
5013 $seen_suffix{$1} = 1;
5015 $file =~ /^(.*)\.(y|yy|y\+\+|yxx|ypp)$/;
5017 my $hname = 'h'; # Always use `.h' for header file.
5021 if ((&variable_defined ('AM_YFLAGS')
5022 && &variable_value ('AM_YFLAGS') =~ /(^|\s)-d(\s|$)/)
5023 || (&variable_defined ('YFLAGS')
5024 && &variable_value ('YFLAGS') =~ /(^|\s)-d(\s|$)/)) {
5025 # Now generate rule to make the header file. This should only
5026 # be generated if `yacc -d' specified.
5027 $output_rules .= "${base}.${hname}: ${base}.${cname}\n";
5029 # If the files are built in the build directory, then we want
5030 # to remove them with `make clean'. If they are in srcdir
5031 # they shouldn't be touched. However, we can't determine this
5032 # statically, and the GNU rules say that yacc/lex output files
5033 # should be removed by maintainer-clean. So that's what we
5035 push (@maintainer_clean_files, "${base}.${hname}");
5037 &push_dist_common ("${base}.${hname}");
5039 push (@maintainer_clean_files, "${base}.${cname}");
5041 $output_rules .= "\n";
5043 if (&variable_defined ('YACCFLAGS'))
5045 &am_line_error ('YACCFLAGS',
5046 "`YACCFLAGS' obsolete; use `YFLAGS' instead");
5049 if ($yacc_count > 1)
5051 &yacc_lex_finish_helper;
5058 return if defined $language_scratch{'lex-done'};
5059 $language_scratch{'lex-done'} = 1;
5061 my %seen_suffix = ();
5062 my $lex_count = scalar (keys %lex_sources);
5063 foreach my $file (sort keys %lex_sources)
5066 &output_lex_build_rule ($1, $lex_count > 1)
5067 if (! defined $seen_suffix{$1});
5068 $seen_suffix{$1} = 1;
5070 # If the files are built in the build directory, then we want
5071 # to remove them with `make clean'. If they are in srcdir
5072 # they shouldn't be touched. However, we can't determine this
5073 # statically, and the GNU rules say that yacc/lex output files
5074 # should be removed by maintainer-clean. So that's what we
5076 $file =~ /^(.*)\.(l|ll|l\+\+|lxx|lpp)$/;
5078 ($cname = $2) =~ tr/l/c/;
5079 push (@maintainer_clean_files, "${1}.${cname}");
5082 if (! $seen_decl_yytext)
5084 &am_error ("lex source seen but `AC_DECL_YYTEXT' not in `$configure_ac'");
5089 &yacc_lex_finish_helper;
5094 # Given a hash table of linker names, pick the name that has the most
5095 # precedence. This is lame, but something has to have global
5096 # knowledge in order to eliminate the conflict. Add more linkers as
5103 if defined $linkers{'GCJLINK'};
5105 if defined $linkers{'CXXLINK'};
5107 if defined $linkers{'F77LINK'};
5109 if defined $linkers{'OBJCLINK'};
5113 # Called to indicate that an extension was used.
5117 $extension_seen{$ext} = 1;
5120 # Called to ask whether source files have been seen . If HEADERS is 1,
5121 # headers can be included.
5132 $headers = grep ($extension_seen{$_},
5133 @{$languages{'header'}->extensions});
5136 return scalar keys %extension_seen > $headers;
5140 # register_language (%ATTRIBUTE)
5141 # ------------------------------
5142 # Register a single language.
5143 # Each %ATTRIBUTE is of the form ATTRIBUTE => VALUE.
5144 sub register_language (%)
5150 unless defined $option{'ansi'};
5151 $option{'autodep'} = 'no'
5152 unless defined $option{'autodep'};
5153 $option{'derived_autodep'} = 'no'
5154 unless defined $option{'derived_autodep'};
5155 $option{'linker'} = ''
5156 unless defined $option{'linker'};
5158 my $lang = new Language (%option);
5161 grep ($extension_map{$_} = $lang->name, @{$lang->extensions});
5162 $languages{$lang->name} = $lang;
5165 # This function is used to find a path from a user-specified suffix to
5166 # `o' or to some other suffix we recognize internally, eg `cc'.
5169 my ($source_ext) = @_;
5171 # FIXME: hard-coding `o' is a mistake. Doing something
5172 # intelligent is harder.
5173 while ($extension_map{$source_ext} eq ''
5174 && $source_ext ne 'o'
5175 && defined $suffix_rules{$source_ext})
5177 $source_ext = $suffix_rules{$source_ext};
5184 ################################################################
5186 # Pretty-print something. HEAD is what should be printed at the
5187 # beginning of the first line, FILL is what should be printed at the
5188 # beginning of every subsequent line.
5189 sub pretty_print_internal
5191 my ($head, $fill, @values) = @_;
5193 my $column = length ($head);
5196 # Fill length is number of characters. However, each Tab
5197 # character counts for eight. So we count the number of Tabs and
5199 my $fill_length = length ($fill);
5200 $fill_length += 7 * ($fill =~ tr/\t/\t/d);
5204 # "71" because we also print a space.
5205 if ($column + length ($_) > 71)
5207 $result .= " \\\n" . $fill;
5208 $column = $fill_length;
5210 $result .= ' ' if $result =~ /\S\z/;
5212 $column += length ($_) + 1;
5219 # Pretty-print something and append to output_vars.
5222 $output_vars .= &pretty_print_internal (@_);
5225 # Pretty-print something and append to output_rules.
5226 sub pretty_print_rule
5228 $output_rules .= &pretty_print_internal (@_);
5232 ################################################################
5236 # &conditional_string(@COND-STACK)
5237 # --------------------------------
5239 sub conditional_string
5243 if (grep (/^FALSE$/, @stack))
5249 return join (' ', uniq sort grep (!/^TRUE$/, @stack));
5255 # &conditional_true_when ($COND, $WHEN)
5256 # -------------------------------------
5257 # See if a conditional is true. Both arguments are conditional
5258 # strings. This returns true if the first conditional is true when
5259 # the second conditional is true.
5260 # For instance with $COND = `BAR FOO', and $WHEN = `BAR BAZ FOO',
5261 # obviously return 1, and 0 when, for instance, $WHEN = `FOO'.
5262 sub conditional_true_when ($$)
5264 my ($cond, $when) = @_;
5266 # Make a hash holding all the values from $WHEN.
5267 my %cond_vals = map { $_ => 1 } split (' ', $when);
5269 # Check each component of $cond, which looks `COND1 COND2'.
5270 foreach my $comp (split (' ', $cond))
5272 # TRUE is always true.
5273 next if $comp eq 'TRUE';
5274 return 0 if ! defined $cond_vals{$comp};
5282 # &conditionals_true_when (@CONDS, @WHENS)
5283 # ----------------------------------------
5284 # Same as above, but true if all the @CONDS are true when *ALL*
5285 # the @WHENS are sufficient.
5287 # If there are no @CONDS, then return true, of course. *BUT*, even if there
5288 # are @CONDS but @WHENS is empty, return true. This is counter intuitive,
5289 # and against all the rules of logic, but is needed by the current code.
5290 # FIXME: Do something saner when the logic of conditionals is understood.
5291 sub conditionals_true_when (@@)
5293 my (@conds, @whens) = @_;
5295 foreach my $cond (@conds)
5297 foreach my $when (@whens)
5300 unless conditional_true_when ($cond, $when);
5309 # condition_negate ($COND)
5310 # ------------------------
5311 sub condition_negate ($)
5315 $cond =~ s/TRUE$/TRUEO/;
5316 $cond =~ s/FALSE$/TRUE/;
5317 $cond =~ s/TRUEO$/FALSE/;
5323 # Compare condition names.
5324 # Issue them in alphabetical order, foo_TRUE before foo_FALSE.
5327 # Be careful we might be comparing `' or `#'.
5328 $a =~ /^(.*)_(TRUE|FALSE)$/;
5329 my ($aname, $abool) = ($1 || '', $2 || '');
5330 $b =~ /^(.*)_(TRUE|FALSE)$/;
5331 my ($bname, $bbool) = ($1 || '', $2 || '');
5332 return ($aname cmp $bname
5333 # Don't bother with IFs, given that TRUE is after FALSE
5334 # just cmp in the reverse order.
5335 || $bbool cmp $abool
5341 # &make_condition (@CONDITIONS)
5342 # -----------------------------
5343 # Transform a list of conditions (themselves can be an internal list
5344 # of conditions, e.g., @CONDITIONS = ('cond1 cond2', 'cond3')) into a
5345 # Make conditional (a pattern for AC_SUBST).
5346 # Correctly returns the empty string when there are no conditions.
5349 my $res = conditional_string (@_);
5351 # There are no conditions.
5357 elsif ($res eq 'FALSE')
5364 $res = '@' . $res . '@';
5373 ## ------------------------------ ##
5374 ## Handling the condition stack. ##
5375 ## ------------------------------ ##
5379 # cond_stack_if ($NEGATE, $COND, $WHERE)
5380 # --------------------------------------
5381 sub cond_stack_if ($$$)
5383 my ($negate, $cond, $where) = @_;
5385 &am_file_error ($where, "$cond does not appear in AM_CONDITIONAL")
5386 if ! $configure_cond{$cond} && $cond !~ /^TRUE|FALSE$/;
5388 $cond = "${cond}_TRUE"
5389 unless $cond =~ /^TRUE|FALSE$/;
5390 $cond = condition_negate ($cond)
5393 push (@cond_stack, $cond);
5395 return conditional_string (@cond_stack);
5400 # cond_stack_else ($NEGATE, $COND, $WHERE)
5401 # ----------------------------------------
5402 sub cond_stack_else ($$$)
5404 my ($negate, $cond, $where) = @_;
5408 &am_file_error ($where, "else without if");
5412 $cond_stack[$#cond_stack] = condition_negate ($cond_stack[$#cond_stack]);
5414 # If $COND is given, check against it.
5417 $cond = "${cond}_TRUE"
5418 unless $cond =~ /^TRUE|FALSE$/;
5419 $cond = condition_negate ($cond)
5422 &am_file_error ($where,
5423 "else reminder ($negate$cond) incompatible with "
5424 . "current conditional: $cond_stack[$#cond_stack]")
5425 if $cond_stack[$#cond_stack] ne $cond;
5428 return conditional_string (@cond_stack);
5433 # cond_stack_endif ($NEGATE, $COND, $WHERE)
5434 # -----------------------------------------
5435 sub cond_stack_endif ($$$)
5437 my ($negate, $cond, $where) = @_;
5442 &am_file_error ($where, "endif without if: $negate$cond");
5447 # If $COND is given, check against it.
5450 $cond = "${cond}_TRUE"
5451 unless $cond =~ /^TRUE|FALSE$/;
5452 $cond = condition_negate ($cond)
5455 &am_file_error ($where,
5456 "endif reminder ($negate$cond) incompatible with "
5457 . "current conditional: $cond_stack[$#cond_stack]")
5458 if $cond_stack[$#cond_stack] ne $cond;
5463 return conditional_string (@cond_stack);
5470 ## ------------------------ ##
5471 ## Handling the variables. ##
5472 ## ------------------------ ##
5475 # check_ambiguous_conditional ($VAR, $COND)
5476 # -----------------------------------------
5477 # Check for an ambiguous conditional. This is called when a variable
5478 # is being defined conditionally. If we already know about a
5479 # definition that is true under the same conditions, then we have an
5481 sub check_ambiguous_conditional ($$)
5483 my ($var, $cond) = @_;
5484 foreach my $vcond (keys %{$var_value{$var}})
5487 if ($vcond eq $cond)
5489 $message = "$var multiply defined in condition $cond";
5491 elsif (&conditional_true_when ($vcond, $cond))
5493 $message = ("$var was already defined in condition $vcond, "
5494 . "which implies condition $cond");
5496 elsif (&conditional_true_when ($cond, $vcond))
5498 $message = ("$var was already defined in condition $vcond, "
5499 . "which is implied by condition $cond");
5503 &am_line_error ($var, $message);
5510 # ¯o_define($VAR, $VAR_IS_AM, $TYPE, $COND, $VALUE, $WHERE)
5511 # -------------------------------------------------------------
5512 # The $VAR can go from Automake to user, but not the converse.
5513 sub macro_define ($$$$$$)
5515 my ($var, $var_is_am, $type, $cond, $value, $where) = @_;
5517 am_file_error ($where, "bad macro name `$var'")
5518 if $var !~ /$MACRO_PATTERN/o;
5522 # An Automake variable must be consistently defined with the same
5523 # sign by Automake. A user variable must be set by either `=' or
5524 # `:=', and later promoted to `+='.
5527 if (defined $var_type{$var} && $var_type{$var} ne $type)
5529 am_line_error ($var,
5530 ("$var was set with `$var_type{$var}=' "
5531 . "and is now set with `$type='"));
5536 if (!defined $var_type{$var} && $type eq '+')
5538 am_line_error ($var, "$var must be set with `=' before using `+='");
5541 $var_type{$var} = $type;
5543 # When adding, since we rewrite, don't try to preserve the
5544 # Automake continuation backslashes.
5546 if $type eq '+' && $var_is_am;
5548 # Differentiate the first assignment (including with `+=').
5549 if ($type eq '+' && defined $var_value{$var}{$cond})
5551 if (substr ($var_value{$var}{$cond}, -1) eq "\n")
5553 # Insert a backslash before a trailing newline.
5554 $var_value{$var}{$cond} =
5555 substr ($var_value{$var}{$cond}, 0, -1) . "\\\n";
5557 elsif ($var_value{$var}{$cond})
5559 # Insert a separator.
5560 $var_value{$var}{$cond} .= ' ';
5562 $var_value{$var}{$cond} .= $value;
5566 # The first assignment to a macro sets the line number. Ideally I
5567 # suppose we would associate line numbers with random bits of text.
5568 # FIXME: We sometimes redefine some variables, but we want to keep
5569 # the original location. More subs are needed to handle
5570 # properly variables. Once this done, remove this hack.
5571 $var_line{$var} = $where
5572 unless defined $var_line{$var};
5574 # If Automake tries to override a value specified by the user,
5575 # just don't let it do.
5576 if (defined $var_value{$var}{$cond} && !$var_is_am{$var} && $var_is_am)
5580 print STDERR "$me: refusing to override the user definition of:\n";
5582 print STDERR "$me: with `$cond' => `$value'\n";
5587 # There must be no previous value unless the user is redefining
5588 # an Automake variable or an AC_SUBST variable.
5589 check_ambiguous_conditional ($var, $cond)
5590 unless ($var_is_am{$var} && !$var_is_am
5591 || exists $configure_vars{$var});
5593 $var_value{$var}{$cond} = $value;
5597 # An Automake variable can be given to the user, but not the converse.
5598 if (! defined $var_is_am{$var} || !$var_is_am)
5600 $var_is_am{$var} = $var_is_am;
5605 # &variable_delete ($VAR, [@CONDS])
5606 # ---------------------------------
5607 # Forget about $VAR under the conditions @CONDS, or completely if
5609 sub variable_delete ($@)
5611 my ($var, @conds) = @_;
5615 delete $var_value{$var};
5616 delete $var_line{$var};
5617 delete $var_is_am{$var};
5618 delete $var_comment{$var};
5619 delete $var_type{$var};
5623 foreach my $cond (@conds)
5625 delete $var_value{$var}{$cond};
5631 # ¯o_dump ($VAR)
5632 # ------------------
5637 if (!exists $var_value{$var})
5639 print STDERR " $var does not exist\n";
5643 my $var_is_am = $var_is_am{$var} ? "Automake" : "User";
5644 my $where = (defined $var_line{$var}
5645 ? $var_line{$var} : "undefined");
5646 print STDERR "$var_comment{$var}"
5647 if defined $var_comment{$var};
5648 print STDERR " $var ($var_is_am, where = $where) $var_type{$var}=\n";
5649 print STDERR " {\n";
5650 foreach my $vcond (sort by_condition keys %{$var_value{$var}})
5652 print STDERR " $vcond => $var_value{$var}{$vcond}\n";
5654 print STDERR " }\n";
5665 print STDERR "%var_value =\n";
5667 foreach my $var (sort (keys %var_value))
5676 # &variable_defined ($VAR, [$COND])
5677 # ---------------------------------
5678 # See if a variable exists. $VAR is the variable name, and $COND is
5679 # the condition which we should check. If no condition is given, we
5680 # currently return true if the variable is defined under any
5682 sub variable_defined ($$)
5684 my ($var, $cond) = @_;
5686 # Unfortunately we can't just check for $var_value{VAR}{COND}
5687 # as this would make perl create $condition{VAR}, which we
5689 if (!exists $var_value{$var})
5691 if (defined $targets{$var})
5693 &am_line_error ($var, "`$var' is a target; expected a variable")
5695 # The variable is not defined
5699 if ($cond && !exists $var_value{$var}{$cond})
5701 # The variable is not defined for the given condition.
5705 # Even a var_value examination is good enough for us. FIXME:
5706 # really should maintain examined status on a per-condition basis.
5707 $content_seen{$var} = 1;
5711 # Mark a variable as examined.
5712 sub examine_variable
5715 &variable_defined ($var);
5718 # Return the set of conditions for which a variable is defined.
5720 # If the variable is not defined conditionally, and is not defined in
5721 # terms of any variables which are defined conditionally, then this
5722 # returns the empty list.
5724 # If the variable is defined conditionally, but is not defined in
5725 # terms of any variables which are defined conditionally, then this
5726 # returns the list of conditions for which the variable is defined.
5728 # If the variable is defined in terms of any variables which are
5729 # defined conditionally, then this returns a full set of permutations
5730 # of the subvariable conditions. For example, if the variable is
5731 # defined in terms of a variable which is defined for COND_TRUE,
5732 # then this returns both COND_TRUE and COND_FALSE. This is
5733 # because we will need to define the variable under both conditions.
5735 sub variable_conditions ($)
5742 foreach my $cond (&variable_conditions_sub ($var, '', ()))
5745 if $cond eq 'FALSE';
5746 $uniqify{$cond} = 1;
5749 @uniq_list = sort by_condition keys %uniqify;
5750 # Note we cannot just do `return sort keys %uniqify', because this
5751 # function is sometimes used in a scalar context.
5757 # &variable_conditionally_defined ($VAR)
5758 # --------------------------------------
5759 sub variable_conditionally_defined ($)
5762 foreach my $cond (variable_conditions ($var))
5765 unless $cond =~ /^TRUE|FALSE$/;
5772 # &variable_conditions_sub ($VAR, $PARENT, @PARENT_CONDS)
5773 # -------------------------------------------------------
5774 # A subroutine of variable_conditions. We only return conditions
5775 # which are true for all the conditions in @PARENT_CONDS.
5776 sub variable_conditions_sub
5778 my ($var, $parent, @parent_conds) = @_;
5781 if (defined $vars_scanned{$var})
5783 &am_line_error ($parent, "variable `$var' recursively defined");
5786 $vars_scanned{$var} = 1;
5788 my @this_conds = ();
5789 foreach my $vcond (keys %{$var_value{$var}})
5792 if ! conditionals_true_when ((@parent_conds), ($vcond));
5794 push (@this_conds, $vcond);
5796 push (@parent_conds, $vcond);
5797 my @subvar_conds = ();
5798 foreach (split (' ', $var_value{$var}{$vcond}))
5800 # If a comment seen, just leave.
5803 # Handle variable substitutions.
5804 if (/^\$\{(.*)\}$/ || /^\$\((.*)\)$/)
5806 push (@subvar_conds,
5807 &variable_conditions_sub ($1, $var, @parent_conds));
5810 pop (@parent_conds);
5812 # If there are no conditional subvariables, then we want to
5813 # return this condition. Otherwise, we want to return the
5814 # permutations of the subvariables.
5815 if (! @subvar_conds)
5817 push (@new_conds, $vcond);
5821 push (@new_conds, &variable_conditions_reduce (@subvar_conds));
5825 # Unset our entry in vars_scanned. We only care about recursive
5827 delete $vars_scanned{$var};
5829 # If there are no parents, then this call is the top level call.
5832 # Now we want to return all permutations of the subvariable
5835 foreach my $item (@new_conds)
5837 foreach (split (' ', $item))
5839 s/^(.*)_(TRUE|FALSE)$/$1_TRUE/;
5843 return &variable_conditions_permutations (sort keys %allconds);
5846 # If we are being called on behalf of another variable, we need to
5847 # return all possible permutations of the conditions. We have
5848 # already handled everything in @this_conds along with their
5849 # subvariables. We now need to add any permutations that are not
5851 foreach my $this_cond (@this_conds)
5854 &variable_conditions_permutations (split(' ', $this_cond));
5855 foreach my $perm (@perms)
5858 foreach my $scan (@this_conds)
5860 if (&conditional_true_when ($perm, $scan)
5861 || &conditional_true_when ($scan, $perm))
5870 if ! conditionals_true_when ((@parent_conds), ($perm));
5872 # This permutation was not already handled, and is valid
5874 push (@new_conds, $perm);
5882 # Filter a list of conditionals so that only the exclusive ones are
5883 # retained. For example, if both `COND1_TRUE COND2_TRUE' and
5884 # `COND1_TRUE' are in the list, discard the latter.
5885 sub variable_conditions_reduce
5889 foreach my $cond (@conds)
5891 # FALSE is absorbent.
5892 if ($cond eq 'FALSE')
5896 elsif (conditionals_true_when (($cond), (@ret)))
5905 # Return a list of permutations of a conditional string.
5906 sub variable_conditions_permutations
5911 my $comp = shift (@comps);
5912 return &variable_conditions_permutations (@comps)
5914 my $neg = condition_negate ($comp);
5917 foreach my $sub (&variable_conditions_permutations (@comps))
5919 push (@ret, "$comp $sub");
5920 push (@ret, "$neg $sub");
5932 # &check_variable_defined_unconditionally($VAR, $PARENT)
5933 # ------------------------------------------------------
5934 # Warn if a variable is conditionally defined. This is called if we
5935 # are using the value of a variable.
5936 sub check_variable_defined_unconditionally ($$)
5938 my ($var, $parent) = @_;
5939 foreach my $cond (keys %{$var_value{$var}})
5942 if $cond =~ /^TRUE|FALSE$/;
5946 &am_line_error ($parent,
5947 "warning: automake does not support conditional definition of $var in $parent");
5951 &am_line_error ($parent,
5952 "warning: automake does not support $var being defined conditionally");
5960 # Get the TRUE value of a variable, warn if the variable is
5961 # conditionally defined.
5965 &check_variable_defined_unconditionally ($var);
5966 return $var_value{$var}{'TRUE'};
5971 # &value_to_list ($VAR, $VAL, $COND)
5972 # ----------------------------------
5973 # Convert a variable value to a list, split as whitespace. This will
5974 # recursively follow $(...) and ${...} inclusions. It preserves @...@
5977 # If COND is 'all', then all values under all conditions should be
5978 # returned; if COND is a particular condition (all conditions are
5979 # surrounded by @...@) then only the value for that condition should
5980 # be returned; otherwise, warn if VAR is conditionally defined.
5981 # SCANNED is a global hash listing whose keys are all the variables
5982 # already scanned; it is an error to rescan a variable.
5985 my ($var, $val, $cond) = @_;
5989 $val =~ s/\\(\n|$)/ /g;
5991 foreach (split (' ', $val))
5993 # If a comment seen, just leave.
5996 # Handle variable substitutions.
5997 if (/^\$\{([^}]*)\}$/ || /^\$\(([^)]*)\)$/)
6001 # If the user uses a losing variable name, just ignore it.
6002 # This isn't ideal, but people have requested it.
6003 next if ($varname =~ /\@.*\@/);
6007 if ($varname =~ /^([^:]*):([^=]*)=(.*)$/)
6011 ($from = $2) =~ s/(\W)/\\$1/g;
6015 @temp_list = &variable_value_as_list_worker ($1, $cond, $var);
6017 # Now rewrite the value if appropriate.
6020 grep (s/$from$/$to/, @temp_list);
6023 push (@result, @temp_list);
6034 # Return contents of variable as list, split as whitespace. This will
6035 # recursively follow $(...) and ${...} inclusions. It preserves @...@
6036 # substitutions. If COND is 'all', then all values under all
6037 # conditions should be returned; if COND is a particular condition
6038 # (all conditions are surrounded by @...@) then only the value for
6039 # that condition should be returned; otherwise, warn if VAR is
6040 # conditionally defined. If PARENT is specified, it is the name of
6041 # the including variable; this is only used for error reports.
6042 sub variable_value_as_list_worker
6044 my ($var, $cond, $parent) = @_;
6047 if (! defined $var_value{$var})
6049 if (defined $targets{$var})
6051 &am_line_error ($var, "`$var' is a target; expected a variable");
6055 &am_line_error ($parent, "variable `$var' not defined");
6058 elsif (defined $vars_scanned{$var})
6060 # `vars_scanned' is a global we use to keep track of which
6061 # variables we've already examined.
6062 &am_line_error ($parent, "variable `$var' recursively defined");
6064 elsif ($cond eq 'all')
6066 $vars_scanned{$var} = 1;
6067 foreach my $vcond (keys %{$var_value{$var}})
6069 my $val = $var_value{$var}{$vcond};
6070 push (@result, &value_to_list ($var, $val, $cond));
6076 $vars_scanned{$var} = 1;
6078 foreach my $vcond (keys %{$var_value{$var}})
6080 my $val = $var_value{$var}{$vcond};
6081 if (&conditional_true_when ($vcond, $cond))
6083 # Warn if we have an ambiguity. It's hard to know how
6084 # to handle this case correctly.
6085 &check_variable_defined_unconditionally ($var, $parent)
6088 push (@result, &value_to_list ($var, $val, $cond));
6093 # Unset our entry in vars_scanned. We only care about recursive
6095 delete $vars_scanned{$var};
6101 # &variable_output ($VAR, [@CONDS])
6102 # ---------------------------------
6103 # Output all the values of $VAR is @COND is not specified, else only
6104 # that corresponding to @COND.
6105 sub variable_output ($@)
6107 my ($var, @conds) = @_;
6109 @conds = sort by_condition keys %{$var_value{$var}}
6112 $output_vars .= $var_comment{$var}
6113 if defined $var_comment{$var};
6115 foreach my $cond (@conds)
6117 my $val = $var_value{$var}{$cond};
6118 my $equals = $var_type{$var} eq ':' ? ':=' : '=';
6119 my $output_var = "$var $equals $val";
6120 $output_var =~ s/^/make_condition ($cond)/meg;
6121 $output_vars .= $output_var . "\n";
6126 # &variable_pretty_output ($VAR, [@CONDS])
6127 # ----------------------------------------
6128 # Likewise, but pretty, i.e., we *split* the values at spaces. Use only
6129 # with variables holding filenames.
6130 sub variable_pretty_output ($@)
6132 my ($var, @conds) = @_;
6134 @conds = sort by_condition keys %{$var_value{$var}}
6137 $output_vars .= $var_comment{$var}
6138 if defined $var_comment{$var};
6140 foreach my $cond (@conds)
6142 my $val = $var_value{$var}{$cond};
6143 my $equals = $var_type{$var} eq ':' ? ':=' : '=';
6144 my $make_condition = make_condition ($cond);
6145 $output_vars .= pretty_print_internal ("$make_condition$var $equals",
6146 "$make_condition\t",
6147 split (' ' , $val));
6152 # This is just a wrapper for variable_value_as_list_worker that
6153 # initializes the global hash `vars_scanned'. This hash is used to
6154 # avoid infinite recursion.
6155 sub variable_value_as_list
6157 my ($var, $cond, $parent) = @_;
6159 return &variable_value_as_list_worker ($var, $cond, $parent);
6163 # Like define_variable, but the value is a list, and the variable may
6164 # be defined conditionally. The second argument is the conditional
6165 # under which the value should be defined; this should be the empty
6166 # string to define the variable unconditionally. The third argument
6167 # is a list holding the values to use for the variable. The value is
6168 # pretty printed in the output file.
6169 sub define_pretty_variable
6171 my ($var, $cond, @value) = @_;
6173 # Beware that an empty $cond has a different semantics for
6174 # macro_define and variable_pretty_output.
6177 if (! &variable_defined ($var, $cond))
6179 macro_define ($var, 1, '', $cond, join (' ', @value), undef);
6180 variable_pretty_output ($var, $cond || 'TRUE');
6181 $content_seen{$var} = 1;
6186 # define_variable ($VAR, $VALUE)
6187 # ------------------------------
6188 # Define a new user variable VAR to VALUE, but only if not already defined.
6191 my ($var, $value) = @_;
6193 define_pretty_variable ($var, 'TRUE', $value);
6197 # Like define_variable, but define a variable to be the configure
6198 # substitution by the same name.
6199 sub define_configure_variable
6202 my $value = '@' . $var . '@';
6203 &define_variable ($var, $value);
6207 # define_compiler_variable ($LANG)
6208 # --------------------------------
6209 # Define a compiler variable. We also handle defining the `LT'
6210 # version of the command when using libtool.
6211 sub define_compiler_variable ($)
6215 my ($var, $value) = ($lang->compiler, $lang->compile);
6216 &define_variable ($var, $value);
6217 &define_variable ("LT$var", "\$(LIBTOOL) --mode=compile $value")
6222 # define_linker_variable ($LANG)
6223 # ------------------------------
6224 # Define linker variables.
6225 sub define_linker_variable ($)
6229 my ($var, $value) = ($lang->lder, $lang->ld);
6231 &define_variable ($lang->lder, $lang->ld);
6232 # CCLINK = $(CCLD) blah blah...
6233 &define_variable ($lang->linker,
6234 (($seen_libtool ? '$(LIBTOOL) --mode=link ' : '')
6238 ################################################################
6240 ## ---------------- ##
6241 ## Handling rules. ##
6242 ## ---------------- ##
6244 sub rule_define ($$$$)
6246 my ($target, $rule_is_am, $cond, $where) = @_;
6248 if (defined $targets{$target}
6250 ? ! defined $target_conditional{$target}
6251 : defined $target_conditional{$target}))
6253 &am_line_error ($target,
6254 "$target defined both conditionally and unconditionally");
6257 # Value here doesn't matter; for targets we only note existence.
6258 $targets{$target} = $where;
6261 if ($target_conditional{$target})
6263 &check_ambiguous_conditional ($target, $cond);
6265 $target_conditional{$target}{$cond} = $where;
6269 # Check the rule for being a suffix rule. If so, store in a hash.
6271 if ((my ($source_suffix, $object_suffix)) = ($target =~ $SUFFIX_RULE_PATTERN))
6273 $suffix_rules{$source_suffix} = $object_suffix;
6274 print "Sources ending in .$source_suffix become .$object_suffix\n"
6276 # Set SUFFIXES from suffix_rules.
6277 push @suffixes, ".$source_suffix", ".$object_suffix";
6282 # See if a target exists.
6286 return defined $targets{$target};
6290 ################################################################
6292 # Read Makefile.am and set up %contents. Simultaneously copy lines
6293 # from Makefile.am into $output_trailer or $output_vars as
6294 # appropriate. NOTE we put rules in the trailer section. We want
6295 # user rules to come after our generated stuff.
6300 my $am_file = new IO::File ("< $amfile");
6303 die "$me: couldn't open `$amfile': $!\n";
6305 print "$me: reading $amfile\n" if $verbose;
6311 while ($_ = $am_file->getline)
6313 if (/$IGNORE_PATTERN/o)
6315 # Merely delete comments beginning with two hashes.
6317 elsif (/$WHITE_PATTERN/o)
6319 # Stick a single white line before the incoming macro or rule.
6323 elsif (/$COMMENT_PATTERN/o)
6325 # Stick comments before the incoming macro or rule. Make
6326 # sure a blank line preceeds first block of comments.
6327 $spacing = "\n" unless $blank;
6329 $comment .= $spacing . $_;
6338 $output_vars .= $comment . "\n";
6342 # We save the conditional stack on entry, and then check to make
6343 # sure it is the same on exit. This lets us conditonally include
6345 my @saved_cond_stack = @cond_stack;
6346 my $cond = conditional_string (@cond_stack);
6350 my $last_var_name = '';
6351 my $last_var_type = '';
6352 my $last_var_value = '';
6353 # FIXME: shouldn't use $_ in this loop; it is too big.
6357 unless substr ($_, -1, 1) eq "\n";
6359 # Don't look at MAINTAINER_MODE_TRUE here. That shouldn't be
6360 # used by users. @MAINT@ is an anachronism now.
6361 $_ =~ s/\@MAINT\@//g
6362 unless $seen_maint_mode;
6364 my $new_saw_bk = /\\$/;
6366 if (/$IGNORE_PATTERN/o)
6368 # Merely delete comments beginning with two hashes.
6370 elsif (/$WHITE_PATTERN/o)
6372 # Stick a single white line before the incoming macro or rule.
6374 &am_line_error ($., "blank line following trailing backslash")
6377 elsif (/$COMMENT_PATTERN/o)
6379 # Stick comments before the incoming macro or rule.
6380 $comment .= $spacing . $_;
6382 &am_line_error ($., "comment following trailing backslash")
6389 $output_trailer .= &make_condition (@cond_stack);
6390 $output_trailer .= $_;
6394 $last_var_value .= ' '
6395 unless $last_var_value =~ /\s$/;
6396 $last_var_value .= $_;
6400 $var_comment{$last_var_name} .= "$spacing"
6401 if (!defined $var_comment{$last_var_name}
6402 || substr ($var_comment{$last_var_name}, -1) ne "\n");
6403 $var_comment{$last_var_name} .= "$comment";
6404 $comment = $spacing = '';
6405 macro_define ($last_var_name, 0,
6406 $last_var_type, $cond,
6407 $last_var_value, $.)
6408 if $cond ne 'FALSE';
6409 push (@var_list, $last_var_name);
6414 elsif (/$IF_PATTERN/o)
6416 $cond = cond_stack_if ($1, $2, "$amfile:$.");
6418 elsif (/$ELSE_PATTERN/o)
6420 $cond = cond_stack_else ($1, $2, "$amfile:$.");
6422 elsif (/$ENDIF_PATTERN/o)
6424 $cond = cond_stack_endif ($1, $2, "$amfile:$.");
6427 elsif (/$RULE_PATTERN/o)
6432 rule_define ($1, 0, $cond, $.);
6435 $output_trailer .= $comment . $spacing;
6436 $output_trailer .= &make_condition (@cond_stack);
6437 $output_trailer .= $_;
6438 $comment = $spacing = '';
6440 elsif (/$ASSIGNMENT_PATTERN/o)
6442 # Found a macro definition.
6444 $last_var_name = $1;
6445 $last_var_type = $2;
6446 $last_var_value = $3;
6447 if ($3 ne '' && substr ($3, -1) eq "\\")
6449 # We preserve the `\' because otherwise the long lines
6450 # that are generated will be truncated by broken
6452 $last_var_value = $3 . "\n";
6457 # FIXME: this doesn't always work correctly; it will
6458 # group all comments for a given variable, no matter
6460 # Accumulating variables must not be output.
6461 $var_comment{$last_var_name} .= "$spacing"
6462 if (!defined $var_comment{$last_var_name}
6463 || substr ($var_comment{$last_var_name}, -1) ne "\n");
6464 $var_comment{$last_var_name} .= "$comment";
6465 $comment = $spacing = '';
6467 macro_define ($last_var_name, 0,
6468 $last_var_type, $cond,
6469 $last_var_value, $.)
6470 if $cond ne 'FALSE';
6471 push (@var_list, $last_var_name);
6474 elsif (/$INCLUDE_PATTERN/o)
6478 if ($path =~ s/^\$\(top_srcdir\)\///)
6480 push (@include_stack, "\$\(top_srcdir\)/$path");
6484 $path =~ s/\$\(srcdir\)\///;
6485 push (@include_stack, "\$\(srcdir\)/$path");
6486 $path = $relative_dir . "/" . $path;
6488 &read_am_file ($path);
6492 # This isn't an error; it is probably a continued rule.
6493 # In fact, this is what we assume.
6495 $output_trailer .= $comment . $spacing;
6496 $output_trailer .= &make_condition (@cond_stack);
6497 $output_trailer .= $_;
6498 $comment = $spacing = '';
6501 $saw_bk = $new_saw_bk;
6502 $_ = $am_file->getline;
6505 $output_trailer .= $comment;
6507 if (join (' ', @saved_cond_stack) ne join (' ', @cond_stack))
6511 &am_error ("unterminated conditionals: @cond_stack");
6515 # FIXME: better error message here.
6516 &am_error ("conditionals not nested in include file");
6522 # define_standard_variables ()
6523 # ----------------------------
6524 # A helper for read_main_am_file which initializes configure variables
6525 # and variables from header-vars.am. This is a subr so we can call it
6527 sub define_standard_variables
6529 my $saved_output_vars = $output_vars;
6530 my ($comments, undef, $rules) =
6531 file_contents_internal (1, "$libdir/am/header-vars.am");
6533 # This will output the definitions in $output_vars, which we don't
6535 foreach my $var (sort keys %configure_vars)
6537 &define_configure_variable ($var);
6538 push (@var_list, $var);
6541 # ... hence, we restore $output_vars.
6542 $output_vars = $saved_output_vars . $comments . $rules;
6545 # Read main am file.
6546 sub read_main_am_file
6550 # This supports the strange variable tricks we are about to play.
6551 if (scalar keys %var_value > 0)
6554 &prog_error ("variable defined before read_main_am_file");
6557 # Generate copyright header for generated Makefile.in.
6558 # We do discard the output of predefined variables, handled below.
6559 $output_vars = ("# $in_file_name generated automatically by automake "
6560 . $VERSION . " from $am_file_name.\n");
6561 $output_vars .= $gen_copyright;
6563 # We want to predefine as many variables as possible. This lets
6564 # the user set them with `+=' in Makefile.am. However, we don't
6565 # want these initial definitions to end up in the output quite
6566 # yet. So we just load them, but output them later.
6567 &define_standard_variables;
6569 # Read user file, which might override some of our values.
6570 &read_am_file ($amfile);
6572 # Ouput all the Automake variables. If the user changed one, then
6573 # it is now marked as owned by the user.
6574 foreach my $var (uniq @var_list)
6576 # Don't process user variables.
6577 variable_output ($var)
6578 unless !$var_is_am{$var};
6581 # Now dump the user variables that were defined. We do it in the same
6582 # order in which they were defined (skipping duplicates).
6583 foreach my $var (uniq @var_list)
6585 # Don't process Automake variables.
6586 variable_output ($var)
6587 unless $var_is_am{$var};
6591 ################################################################
6594 # &flatten ($STRING)
6595 # ------------------
6596 # Flatten the $STRING and return the result.
6611 # &make_paragraphs ($MAKEFILE, [%TRANSFORM])
6612 # ------------------------------------------
6613 # Load a $MAKEFILE, apply the %TRANSFORM, and return it as a list of
6615 sub make_paragraphs ($%)
6617 my ($file, %transform) = @_;
6619 # Complete %transform with global options and make it a Perl
6622 "s/$IGNORE_PATTERN//gm;"
6623 . transform (%transform,
6625 'CYGNUS' => $cygnus_mode,
6627 => $seen_maint_mode ? subst ('MAINTAINER_MODE_TRUE') : '',
6629 'SHAR' => $options{'dist-shar'} || 0,
6630 'BZIP2' => $options{'dist-bzip2'} || 0,
6631 'ZIP' => $options{'dist-zip'} || 0,
6632 'COMPRESS' => $options{'dist-tarZ'} || 0,
6634 'INSTALL-INFO' => !$options{'no-installinfo'},
6635 'INSTALL-MAN' => !$options{'no-installman'},
6636 'CK-NEWS' => $options{'check-news'} || 0,
6638 'SUBDIRS' => &variable_defined ('SUBDIRS'),
6639 'TOPDIR' => backname ($relative_dir),
6640 'TOPDIR_P' => $relative_dir eq '.',
6641 'CONFIGURE-AC' => $configure_ac,
6643 'BUILD' => $seen_canonical == $AC_CANONICAL_SYSTEM,
6644 'HOST' => $seen_canonical,
6645 'TARGET' => $seen_canonical == $AC_CANONICAL_SYSTEM,
6647 'LIBTOOL' => defined $configure_vars{'LIBTOOL'})
6648 # We don't need more than two consecutive new-lines.
6649 . 's/\n{3,}/\n\n/g';
6651 # Swallow the file and apply the COMMAND.
6652 my $fc_file = new IO::File ("< $file");
6655 die "$me: installation error: cannot open `$file'\n";
6658 print "$me: reading $file\n"
6660 my $saved_dollar_slash = $/;
6662 $_ = $fc_file->getline;
6663 $/ = $saved_dollar_slash;
6668 # Split at unescaped new lines.
6669 my @lines = split (/(?<!\\)\n/, $content);
6672 while (defined ($_ = shift @lines))
6674 my $paragraph = "$_";
6675 # If we are a rule, eat as long as we start with a tab.
6676 if (/$RULE_PATTERN/smo)
6678 while (defined ($_ = shift @lines) && $_ =~ /^\t/)
6680 $paragraph .= "\n$_";
6682 unshift (@lines, $_);
6685 # If we are a comments, eat as much comments as you can.
6686 elsif (/$COMMENT_PATTERN/smo)
6688 while (defined ($_ = shift @lines)
6689 && $_ =~ /$COMMENT_PATTERN/smo)
6691 $paragraph .= "\n$_";
6693 unshift (@lines, $_);
6696 push @res, $paragraph;
6705 # ($COMMENT, $VARIABLES, $RULES)
6706 # &file_contents_internal ($IS_AM, $FILE, [%TRANSFORM])
6707 # -----------------------------------------------------
6708 # Return contents of a file from $libdir/am, automatically skipping
6709 # macros or rules which are already known. $IS_AM iff the caller is
6710 # reading an Automake file (as opposed to the user's Makefile.am).
6711 sub file_contents_internal ($$%)
6713 my ($is_am, $file, %transform) = @_;
6715 my $result_vars = '';
6716 my $result_rules = '';
6720 # We save the conditional stack on entry, and then check to make
6721 # sure it is the same on exit. This lets us conditonally include
6723 my @saved_cond_stack = @cond_stack;
6724 my $cond = conditional_string (@cond_stack);
6726 foreach (make_paragraphs ($file, %transform))
6729 &am_file_error ($file, "blank line following trailing backslash:\n$_")
6731 &am_file_error ($file, "comment following trailing backslash:\n$_")
6736 # Stick empty line before the incoming macro or rule.
6739 elsif (/$COMMENT_PATTERN/mso)
6741 # Stick comments before the incoming macro or rule.
6745 # Handle inclusion of other files.
6746 elsif (/$INCLUDE_PATTERN/o)
6748 if ($cond ne 'FALSE')
6750 my $file = ($is_am ? "$libdir/am/" : '') . $1;
6752 my ($com, $vars, $rules)
6753 = file_contents_internal ($is_am, $file, %transform);
6755 $result_vars .= $vars;
6756 $result_rules .= $rules;
6760 # Handling the conditionals.
6761 elsif (/$IF_PATTERN/o)
6763 $cond = cond_stack_if ($1, $2, $file);
6765 elsif (/$ELSE_PATTERN/o)
6767 $cond = cond_stack_else ($1, $2, $file);
6769 elsif (/$ENDIF_PATTERN/o)
6771 $cond = cond_stack_endif ($1, $2, $file);
6775 elsif (/$RULE_PATTERN/mso)
6777 # Separate relationship from optional actions: the first
6778 # `new-line tab" not preceded by backslash (continuation
6780 # I'm quite shoked! It seems that (\\\n|[^\n]) is not the
6781 # same as `([^\n]|\\\n)!!! Don't swap it, it breaks.
6783 /^((?:\\\n|[^\n])*)(?:\n(\t.*))?$/som;
6784 my ($relationship, $actions) = ($1, $2 || '');
6786 # Separate targets from dependencies: the first colon.
6787 $relationship =~ /^([^:]+\S+) *: *(.*)$/som;
6788 my ($targets, $dependencies) = ($1, $2);
6789 # Remove the escaped new lines.
6790 # I don't know why, but I have to use a tmp $flat_deps.
6791 my $flat_deps = &flatten ($dependencies);
6792 my @deps = split (' ', $flat_deps);
6794 foreach (split (' ' , $targets))
6796 # FIXME: We are not robust to people defining several targets
6797 # at once, only some of them being in %dependencies.
6799 # Output only if not in FALSE.
6800 if (defined $dependencies{$_}
6801 && $cond ne 'FALSE')
6803 &depend ($_, @deps);
6804 $actions{$_} .= $actions;
6808 # Free lance dependency. Output the rule for all the
6809 # targets instead of one by one.
6810 if (!defined $targets{$targets}
6811 && $cond ne 'FALSE')
6813 $paragraph =~ s/^/make_condition (@cond_stack)/gme;
6814 $result_rules .= "$spacing$comment$paragraph\n";
6815 rule_define ($targets, $is_am, $cond, $file);
6817 $comment = $spacing = '';
6823 elsif (/$ASSIGNMENT_PATTERN/mso)
6825 my ($var, $type, $val) = ($1, $2, $3);
6826 &am_file_error ($file, "macro `$var' with trailing backslash")
6829 # Accumulating variables must not be output.
6830 $var_comment{$var} .= "$spacing"
6831 if (!defined $var_comment{$var}
6832 || substr ($var_comment{$var}, -1) ne "\n");
6833 $var_comment{$var} .= "$comment";
6834 macro_define ($var, $is_am, $type, $cond, $val, $file)
6835 if $cond ne 'FALSE';
6836 push (@var_list, $var);
6838 # If the user has set some variables we were in charge
6839 # of (which is detected by the first reading of
6840 # `header-vars.am'), we must not output them.
6841 $result_vars .= "$spacing$comment$_\n"
6842 if $type ne '+' && $var_is_am{$var} && $cond ne 'FALSE';
6844 $comment = $spacing = '';
6848 # This isn't an error; it is probably some tokens which
6849 # configure is supposed to replace, such as `@SET-MAKE@',
6850 # or some part of a rule cut by an if/endif.
6851 if ($cond ne 'FALSE')
6853 s/^/make_condition (@cond_stack)/gme;
6854 $result_rules .= "$spacing$comment$_\n";
6856 $comment = $spacing = '';
6860 if (join (' ', @saved_cond_stack) ne join (' ', @cond_stack))
6864 &am_error ("unterminated conditionals: @cond_stack");
6868 # FIXME: better error message here.
6869 &am_error ("conditionals not nested in include file");
6873 return ($comment, $result_vars, $result_rules);
6878 # &file_contents ($BASENAME, [%TRANSFORM])
6879 # ----------------------------------------
6880 # Return contents of a file from $libdir/am, automatically skipping
6881 # macros or rules which are already known.
6882 sub file_contents ($%)
6884 my ($basename, %transform) = @_;
6885 my ($comments, $variables, $rules) =
6886 file_contents_internal (1, "$libdir/am/$basename.am", %transform);
6887 return "$comments$variables$rules";
6892 # &transform (%PAIRS)
6893 # -------------------
6894 # Foreach ($TOKEN, $VAL) in %PAIRS produce a replacement expression suitable
6895 # for file_contents which:
6896 # - replaces @$TOKEN@ with $VALUE,
6897 # - enables/disables ?$TOKEN?.
6903 while (my ($token, $val) = each %pairs)
6905 $result .= "s/\Q%$token%\E/\Q$val\E/gm;";
6908 $result .= "s/\Q?$token?\E//gm;s/^.*\Q?!$token?\E.*\\n//gm;";
6909 $result .= "s/\Q%?$token%\E/TRUE/gm;";
6913 $result .= "s/\Q?!$token?\E//gm;s/^.*\Q?$token?\E.*\\n//gm;";
6914 $result .= "s/\Q%?$token%\E/FALSE/gm;";
6922 # Find all variable prefixes that are used for install directories. A
6923 # prefix `zar' qualifies iff:
6924 # * `zardir' is a variable.
6925 # * `zar_PRIMARY' is a variable.
6926 sub am_primary_prefixes
6928 my ($primary, $can_dist, @prefixes) = @_;
6930 my %valid = map { $_ => 0 } @prefixes;
6931 $valid{'EXTRA'} = 0;
6932 foreach my $varname (keys %var_value)
6934 # Automake is allowed to define variables that look like they
6935 # are magic variables, such as INSTALL_DATA.
6937 if $var_is_am{$varname};
6939 if ($varname =~ /^(nobase_)?(dist_|nodist_)?(.*)_$primary$/)
6941 my ($base, $dist, $X) = ($1 || '', $2 || '', $3 || '');
6942 if ($dist ne '' && ! $can_dist)
6944 # Note that a configure variable is always legitimate.
6945 # It is natural to name such variables after the
6946 # primary, so we explicitly allow it.
6947 if (! defined $configure_vars{$varname})
6949 &am_line_error ($varname,
6950 "invalid variable `$varname': `dist' is forbidden");
6953 elsif (! defined $valid{$X} && ! &variable_defined ("${X}dir"))
6955 # Note that a configure variable is always legitimate.
6956 # It is natural to name such variables after the
6957 # primary, so we explicitly allow it.
6958 if (! defined $configure_vars{$varname})
6960 &am_line_error ($varname,
6961 "invalid variable `$varname'");
6966 # Ensure all extended prefixes are actually used.
6967 $valid{"$base$dist$X"} = 1;
6975 # Handle `where_HOW' variable magic. Does all lookups, generates
6976 # install code, and possibly generates code to define the primary
6977 # variable. The first argument is the name of the .am file to munge,
6978 # the second argument is the primary variable (eg HEADERS), and all
6979 # subsequent arguments are possible installation locations. Returns
6980 # list of all values of all _HOW targets.
6982 # FIXME: this should be rewritten to be cleaner. It should be broken
6983 # up into multiple functions.
6985 # Usage is: am_install_var (OPTION..., file, HOW, where...)
6992 my $default_dist = 0;
6995 if ($args[0] eq '-noextra')
6999 elsif ($args[0] eq '-candist')
7003 elsif ($args[0] eq '-defaultdist')
7008 elsif ($args[0] !~ /^-/)
7015 my ($file, $primary, @prefixes) = @args;
7017 # Now that configure substitutions are allowed in where_HOW
7018 # variables, it is an error to actually define the primary. We
7019 # allow `JAVA', as it is customarily used to mean the Java
7020 # interpreter. This is but one of several Java hacks. Similarly,
7021 # `PYTHON' is customarily used to mean the Python interpreter.
7022 &am_line_error ($primary, "`$primary' is an anachronism")
7023 if &variable_defined ($primary)
7024 && ($primary ne 'JAVA' && $primary ne 'PYTHON');
7027 # Look for misspellings. It is an error to have a variable ending
7028 # in a "reserved" suffix whose prefix is unknown, eg
7029 # "bni_PROGRAMS". However, unusual prefixes are allowed if a
7030 # variable of the same name (with "dir" appended) exists. For
7031 # instance, if the variable "zardir" is defined, then
7032 # "zar_PROGRAMS" becomes valid. This is to provide a little extra
7033 # flexibility in those cases which need it.
7034 my %valid = &am_primary_prefixes ($primary, $can_dist, @prefixes);
7036 # If a primary includes a configure substitution, then the EXTRA_
7037 # form is required. Otherwise we can't properly do our job.
7039 my $warned_about_extra = 0;
7044 # True if the iteration is the first one. Used for instance to
7045 # output parts of the associated file only once.
7047 foreach my $X (sort keys %valid)
7049 my $one_name = $X . '_' . $primary;
7051 unless (&variable_defined ($one_name));
7053 my $strip_subdir = 1;
7054 # If subdir prefix should be preserved, do so.
7055 if ($X =~ /^nobase_/)
7061 my $nodir_name = $X;
7062 # If files should be distributed, do so.
7066 $dist_p = (($default_dist && $one_name !~ /^nodist_/)
7067 || (! $default_dist && $one_name =~ /^dist_/));
7068 $nodir_name =~ s/^(dist|nodist)_//;
7071 # Append actual contents of where_PRIMARY variable to
7073 foreach my $rcurs (&variable_value_as_list ($one_name, 'all'))
7075 # Skip configure substitutions. Possibly bogus.
7076 if ($rcurs =~ /^\@.*\@$/)
7080 if (! $warned_about_extra)
7082 $warned_about_extra = 1;
7083 &am_line_error ($one_name,
7084 "`$one_name' contains configure substitution, but shouldn't");
7087 # Check here to make sure variables defined in
7088 # configure.ac do not imply that EXTRA_PRIMARY
7090 elsif (! defined $configure_vars{$one_name})
7092 $require_extra = $one_name
7099 push (@result, $rcurs);
7102 # A blatant hack: we rewrite each _PROGRAMS primary to
7103 # include EXEEXT when in Cygwin32 mode.
7104 if ($primary eq 'PROGRAMS')
7106 my @conds = &variable_conditions ($one_name);
7109 foreach my $cond (@conds)
7111 my @one_binlist = ();
7112 my @condval = &variable_value_as_list ($one_name,
7114 foreach my $rcurs (@condval)
7116 if ($rcurs =~ /\./ || $rcurs =~ /^\@.*\@$/)
7118 push (@one_binlist, $rcurs);
7122 push (@one_binlist, $rcurs . '$(EXEEXT)');
7126 push (@condvals, $cond);
7127 push (@condvals, join (' ', @one_binlist));
7130 variable_delete ($one_name);
7133 my $cond = shift (@condvals);
7134 my @val = split (' ', shift (@condvals));
7135 &define_pretty_variable ($one_name, $cond, @val);
7139 # "EXTRA" shouldn't be used when generating clean targets,
7140 # all, or install targets.
7143 # We used to warn if EXTRA_FOO was defined uselessly,
7144 # but this was annoying.
7150 push (@check, '$(' . $one_name . ')');
7154 push (@used, '$(' . $one_name . ')');
7157 # Is this to be installed?
7158 my $install_p = $X ne 'noinst' && $X ne 'check';
7160 # If so, with install-exec? (or install-data?).
7161 my $exec_p = (defined $exec_dir_p {$X}
7165 # Singular form of $PRIMARY.
7166 (my $one_primary = $primary) =~ s/S$//;
7167 $output_rules .= &file_contents ($file,
7170 'PRIMARY' => $primary,
7171 'ONE_PRIMARY' => $one_primary,
7173 'NDIR' => $nodir_name,
7174 'BASE' => $strip_subdir,
7177 'INSTALL' => $install_p,
7178 'DIST' => $dist_p));
7183 # The JAVA variable is used as the name of the Java interpreter.
7184 # The PYTHON variable is used as the name of the Python interpreter.
7185 if (@used && $primary ne 'JAVA' && $primary ne 'PYTHON')
7188 &define_pretty_variable ($primary, '', @used);
7189 $output_vars .= "\n";
7192 if ($require_extra && ! &variable_defined ('EXTRA_' . $primary))
7194 &am_line_error ($require_extra,
7195 "`$require_extra' contains configure substitution, but `EXTRA_$primary' not defined");
7198 # Push here because PRIMARY might be configure time determined.
7199 push (@all, '$(' . $primary . ')')
7200 if @used && $primary ne 'JAVA' && $primary ne 'PYTHON';
7202 # Make the result unique. This lets the user use conditionals in
7203 # a natural way, but still lets us program lazily -- we don't have
7204 # to worry about handling a particular object more than once.
7205 return uniq (sort @result);
7209 ################################################################
7211 # Each key in this hash is the name of a directory holding a
7212 # Makefile.in. These variables are local to `is_make_dir'.
7214 my $make_dirs_set = 0;
7219 if (! $make_dirs_set)
7221 foreach my $iter (@configure_input_files)
7223 $make_dirs{dirname ($iter)} = 1;
7225 # We also want to notice Makefile.in's.
7226 foreach my $iter (@other_input_files)
7228 if ($iter =~ /Makefile\.in$/)
7230 $make_dirs{dirname ($iter)} = 1;
7235 return defined $make_dirs{$dir};
7238 ################################################################
7240 # This variable is local to the "require file" set of functions.
7241 my @require_file_paths = ();
7243 # If a file name appears as a key in this hash, then it has already
7244 # been checked for. This variable is local to the "require file"
7246 %require_file_found = ();
7248 # See if we want to push this file onto dist_common. This function
7249 # encodes the rules for deciding when to do so.
7250 sub maybe_push_required_file
7252 my ($dir, $file, $fullfile) = @_;
7254 if ($dir eq $relative_dir)
7256 &push_dist_common ($file);
7258 elsif ($relative_dir eq '.' && ! &is_make_dir ($dir))
7260 # If we are doing the topmost directory, and the file is in a
7261 # subdir which does not have a Makefile, then we distribute it
7263 &push_dist_common ($fullfile);
7268 # &require_file_internal ($IS_CONFIGURE, $LINE, $MYSTRICT, @FILES)
7269 # ----------------------------------------------------------------
7270 # Verify that the file must exist in the current directory.
7271 # $MYSTRICT is the strictness level at which this file becomes required.
7273 # Must set require_file_paths before calling this function.
7274 # require_file_paths is set to hold a single directory (the one in
7275 # which the first file was found) before return.
7276 sub require_file_internal
7278 my ($is_configure, $line, $mystrict, @files) = @_;
7280 foreach my $file (@files)
7287 # If we've already looked for it, we're done.
7288 next if defined $require_file_found{$file};
7289 $require_file_found{$file} = 1;
7292 my $dangling_sym = 0;
7293 foreach my $dir (@require_file_paths)
7295 $fullfile = $dir . "/" . $file;
7296 $errdir = $dir unless $errdir;
7298 # Use different name for "error filename". Otherwise on
7299 # an error the bad file will be reported as eg
7300 # `../../install-sh' when using the default
7302 $errfile = $errdir . '/' . $file;
7304 if (-l $fullfile && ! -f readlink ($fullfile))
7309 elsif (-f $fullfile)
7312 &maybe_push_required_file ($dir, $file, $fullfile);
7318 if ($found_it && ! $force_missing)
7320 # Prune the path list.
7321 @require_file_paths = $save_dir;
7325 if ($strictness >= $mystrict)
7327 if ($dangling_sym && $add_missing)
7335 # Only install missing files according to our desired
7337 my $message = "required file `$errfile' not found";
7342 # Maybe run libtoolize.
7343 my @syslist = ('libtoolize', '--automake');
7344 push @syslist, '--copy'
7347 && grep ($_ eq $file, @libtoolize_files)
7348 && system (@syslist))
7350 $message = "installing `$errfile'";
7352 $trailer = "; cannot run `libtoolize': $!";
7354 elsif (-f ("$libdir/$file"))
7356 # Install the missing file. Symlink if we
7357 # can, copy if we must. Note: delete the file
7358 # first, in case it is a dangling symlink.
7359 $message = "installing `$errfile'";
7360 # Windows Perl will hang if we try to delete a
7361 # file that doesn't exist.
7362 unlink ($errfile) if -f $errfile;
7363 if ($symlink_exists && ! $copy_missing)
7365 if (! symlink ("$libdir/$file", $errfile))
7368 $trailer = "; error while making link: $!";
7371 elsif (system ('cp', "$libdir/$file", $errfile))
7374 $trailer = "\n error while copying";
7378 &maybe_push_required_file (dirname ($errfile),
7381 # Prune the path list.
7382 @require_file_paths = &dirname ($errfile);
7389 # FIXME: allow actual file to be specified.
7390 &am_conf_line_warning ($configure_ac, $line,
7391 "$message$trailer");
7395 &am_line_warning ($line, "$message$trailer");
7402 # FIXME: allow actual file to be specified.
7403 &am_conf_line_error ($configure_ac, $line,
7404 "$message$trailer");
7408 &am_line_error ($line, "$message$trailer");
7416 # Like require_file_with_line, but error messages refer to
7417 # configure.ac, not the current Makefile.am.
7418 sub require_file_with_conf_line
7420 @require_file_paths = $relative_dir;
7421 &require_file_internal (1, @_);
7424 sub require_file_with_line
7426 @require_file_paths = $relative_dir;
7427 &require_file_internal (0, @_);
7432 @require_file_paths = $relative_dir;
7433 &require_file_internal (0, '', @_);
7436 # Require a file that is also required by Autoconf. Looks in
7437 # configuration path, as specified by AC_CONFIG_AUX_DIR.
7438 sub require_config_file
7440 @require_file_paths = @config_aux_path;
7441 &require_file_internal (1, '', @_);
7442 my $dir = $require_file_paths[0];
7443 @config_aux_path = @require_file_paths;
7444 # Avoid unsightly '/.'s.
7445 $config_aux_dir = '$(top_srcdir)' . ($dir eq '.' ? "" : "/$dir");
7448 # Assumes that the line number is in Makefile.am.
7449 sub require_conf_file_with_line
7451 @require_file_paths = @config_aux_path;
7452 &require_file_internal (0, @_);
7453 my $dir = $require_file_paths[0];
7454 @config_aux_path = @require_file_paths;
7455 # Avoid unsightly '/.'s.
7456 $config_aux_dir = '$(top_srcdir)' . ($dir eq '.' ? "" : "/$dir");
7459 # Assumes that the line number is in configure.ac.
7460 sub require_conf_file_with_conf_line
7462 @require_file_paths = @config_aux_path;
7463 &require_file_internal (1, @_);
7464 my $dir = $require_file_paths[0];
7465 @config_aux_path = @require_file_paths;
7466 # avoid unsightly '/.'s.
7467 $config_aux_dir = '$(top_srcdir)' . ($dir eq '.' ? "" : "/$dir");
7470 ################################################################
7472 # Push a list of files onto dist_common.
7473 sub push_dist_common
7475 &prog_error ("push_dist_common run after handle_dist")
7476 if $handle_dist_run;
7477 macro_define ('DIST_COMMON', 1, '+', '', join (' ', @_), '');
7484 $strictness_name = $_[0];
7485 if ($strictness_name eq 'gnu')
7489 elsif ($strictness_name eq 'gnits')
7491 $strictness = $GNITS;
7493 elsif ($strictness_name eq 'foreign')
7495 $strictness = $FOREIGN;
7499 die "$me: level `$strictness_name' not recognized\n";
7504 ################################################################
7506 # Ensure a file exists.
7511 my $touch = new IO::File (">> $file");
7515 # Glob something. Do this to avoid indentation screwups everywhere we
7516 # want to glob. Gross!
7523 # Remove one level of brackets and strip leading spaces,
7524 # as does m4 to function arguments.
7530 my @letters = split //;
7539 next if $depth == 1;
7544 next if $depth == 0;
7545 # don't count orphan right brackets
7546 $depth = 0 if $depth < 0;
7550 return join '', @result;
7553 ################################################################
7555 # Print an error message and set exit status.
7558 warn "$me: ${am_file}.am: @_\n";
7562 # am_file_error ($FILE, @ARGS)
7563 # ----------------------------
7566 my ($file, @args) = @_;
7568 warn "$file: @args\n";
7574 my ($symbol, @args) = @_;
7576 if ($symbol && "$symbol" ne '-1')
7578 my $file = "${am_file}.am";
7580 if ($symbol =~ /^\d+$/)
7582 # SYMBOL is a line number, so just add the colon.
7583 $file .= ':' . $symbol;
7585 elsif (defined $var_line{$symbol})
7587 # SYMBOL is a variable defined in Makefile.am, so add the
7588 # line number we saved from there.
7589 $file .= ':' . $var_line{$symbol};
7591 elsif (defined $configure_vars{$symbol})
7593 # SYMBOL is a variable defined in configure.ac, so add the
7594 # appropriate line number.
7595 $file = $configure_vars{$symbol};
7599 # Couldn't find the line number.
7601 warn $file, ": @args\n";
7610 # Like am_error, but while scanning configure.ac.
7613 # FIXME: can run in subdirs.
7614 warn "$me: $configure_ac: @_\n";
7618 # Error message with line number referring to configure.ac.
7619 sub am_conf_line_error
7621 my ($file, $line, @args) = @_;
7625 warn "$file: $line: @args\n";
7630 &am_conf_error (@args);
7634 # Warning message with line number referring to configure.ac.
7635 # Does not affect exit_status
7636 sub am_conf_line_warning
7638 my $saved_exit_status = $exit_status;
7639 my $sig = $SIG{'__WARN__'};
7640 $SIG{'__WARN__'} = 'DEFAULT';
7641 am_conf_line_error (@_);
7642 $exit_status = $saved_exit_status;
7643 $SIG{'__WARN__'} = $sig;
7646 # Like am_line_error, but doesn't affect exit status.
7649 my $saved_exit_status = $exit_status;
7650 my $sig = $SIG{'__WARN__'};
7651 $SIG{'__WARN__'} = 'DEFAULT';
7653 $exit_status = $saved_exit_status;
7654 $SIG{'__WARN__'} = $sig;
7657 # Tell user where our aclocal.m4 is, but only once.
7658 sub keyed_aclocal_warning
7661 warn "$me: macro `$key' can be generated by `aclocal'\n";
7664 # Print usage information.
7668 Usage: $0 [OPTION] ... [Makefile]...
7670 Generate Makefile.in for configure from Makefile.am.
7673 --help print this help, then exit
7674 --version print version number, then exit
7675 -v, --verbose verbosely list files processed
7676 -o, --output-dir=DIR put generated Makefile.in's into DIR
7677 --no-force only update Makefile.in's that are out of date
7679 Dependency tracking:
7680 -i, --ignore-deps disable dependency tracking code
7681 --include-deps enable dependency tracking code
7684 --cygnus assume program is part of Cygnus-style tree
7685 --foreign set strictness to foreign
7686 --gnits set strictness to gnits
7687 --gnu set strictness to gnu
7690 -a, --add-missing add missing standard files to package
7691 --libdir=DIR directory storing library files
7692 -c, --copy with -a, copy missing files (default is symlink)
7693 -f, --force-missing force update of standard files
7698 foreach my $iter (sort ((@common_files, @common_sometimes)))
7700 push (@lcomm, $iter) unless $iter eq $last;
7704 my ($one, $two, $three, $four, $max);
7705 print "\nFiles which are automatically distributed, if found:\n";
7706 format USAGE_FORMAT =
7707 @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<
7708 $one, $two, $three, $four
7710 $~ = "USAGE_FORMAT";
7711 $max = int (($#lcomm + 1) / 4);
7713 for (my $i = 0; $i < $max; ++$i)
7716 $two = $lcomm[$max + $i];
7717 $three = $lcomm[2 * $max + $i];
7718 $four = $lcomm[3 * $max + $i];
7722 my $mod = ($#lcomm + 1) % 4;
7725 $one = $lcomm[$max];
7726 $two = ($mod > 1) ? $lcomm[2 * $max] : '';
7727 $three = ($mod > 2) ? $lcomm[3 * $max] : '';
7728 $four = ($mod > 3) ? $lcomm[4 * $max] : '';
7732 print "\nReport bugs to <bug-automake\@gnu.org>.\n";
7739 # Print version information
7743 automake (GNU $PACKAGE) $VERSION
7744 Written by Tom Tromey <tromey\@cygnus.com>.
7746 Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
7747 Free Software Foundation, Inc.
7748 This is free software; see the source for copying conditions. There is NO
7749 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.