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 $am_dir = "@datadir@/@PACKAGE@/am";
111 my $pkgdata_dir = "@datadir@/@PACKAGE@";
114 my $IGNORE_PATTERN = '^##([^#\n].*)?\n';
115 my $WHITE_PATTERN = '^\s*$';
116 my $COMMENT_PATTERN = '^#';
117 my $TARGET_PATTERN='[$a-zA-Z_.][-.a-zA-Z0-9_(){}/$]*';
118 # A rule has three parts: a list of targets, a list of dependencies,
119 # and optionally actions.
121 "^($TARGET_PATTERN(?:(?:\\\\\n|\\s)+$TARGET_PATTERN)*) *:([^=].*|)\$";
123 my $SUFFIX_RULE_PATTERN = '^\.([a-zA-Z0-9]+)\.([a-zA-Z0-9]+)$';
124 # Only recognize leading spaces, not leading tabs. If we recognize
125 # leading tabs here then we need to make the reader smarter, because
126 # otherwise it will think rules like `foo=bar; \' are errors.
127 my $MACRO_PATTERN = '^[A-Za-z0-9_@]+$';
128 my $ASSIGNMENT_PATTERN = '^ *([^ \t]*)\s*([:+]?)=\s*(.*)$';
129 # This pattern recognizes a Gnits version id and sets $1 if the
130 # release is an alpha release. We also allow a suffix which can be
131 # used to extend the version number with a "fork" identifier.
132 my $GNITS_VERSION_PATTERN = '\d+\.\d+([a-z]|\.\d+)?(-[A-Za-z0-9]+)?';
133 my $IF_PATTERN = '^if\s+(!?)\s*([A-Za-z][A-Za-z0-9_]*)\s*(?:#.*)?$';
134 my $ELSE_PATTERN = '^else(?:\s+(!?)\s*([A-Za-z][A-Za-z0-9_]*))?\s*(?:#.*)?$';
135 my $ENDIF_PATTERN = '^endif(?:\s+(!?)\s*([A-Za-z][A-Za-z0-9_]*))?\s*(?:#.*)?$';
136 my $PATH_PATTERN='(\w|[/.-])+';
137 # This will pass through anything not of the prescribed form.
138 my $INCLUDE_PATTERN = ('^include\s+'
139 . '((\$\(top_srcdir\)/' . $PATH_PATTERN . ')'
140 . '|(\$\(srcdir\)/' . $PATH_PATTERN . ')'
141 . '|([^/\$]' . $PATH_PATTERN. '))\s*(#.*)?$');
143 # Some regular expressions. One reason to put them here is that it
144 # makes indentation work better in Emacs.
145 my $AC_CONFIG_AUX_DIR_PATTERN = 'AC_CONFIG_AUX_DIR\(([^)]+)\)';
146 my $AM_INIT_AUTOMAKE_PATTERN = 'AM_INIT_AUTOMAKE\([^,]*,([^,)]+)[,)]';
147 my $AM_PACKAGE_VERSION_PATTERN = '^\s*\[?([^]\s]+)\]?\s*$';
148 # Note that there is no AC_PATH_TOOL. But we don't really care.
149 my $AC_CHECK_PATTERN = 'AC_(CHECK|PATH)_(PROG|PROGS|TOOL)\(\[?(\w+)';
150 my $AM_MISSING_PATTERN = 'AM_MISSING_PROG\(\[?(\w+)';
151 # Just check for alphanumeric in AC_SUBST. If you do AC_SUBST(5),
153 my $AC_SUBST_PATTERN = 'AC_SUBST\(\[?(\w+)';
154 my $AM_CONDITIONAL_PATTERN = 'AM_CONDITIONAL\(\[?(\w+)';
156 # Constants to define the "strictness" level.
161 # Values for AC_CANONICAL_*
162 my $AC_CANONICAL_HOST = 1;
163 my $AC_CANONICAL_SYSTEM = 2;
165 # Values indicating when something should be cleaned. Right now we
166 # only need to handle `mostly'- and `dist'-clean; add more as
168 my $MOSTLY_CLEAN = 0;
171 # Files installed by libtoolize.
172 my @libtoolize_files = ('ltmain.sh', 'config.guess', 'config.sub');
173 # ltconfig appears here for compatibility with old versions of libtool.
174 my @libtoolize_sometimes = ('ltconfig', 'ltcf-c.sh', 'ltcf-cxx.sh',
177 # Commonly found files we look for and automatically include in
181 'README', 'THANKS', 'TODO', 'NEWS', 'COPYING', 'COPYING.LIB',
182 'INSTALL', 'ABOUT-NLS', 'ChangeLog', 'configure.ac',
183 'configure.in', 'configure', 'config.guess', 'config.sub',
184 'AUTHORS', 'BACKLOG', 'ABOUT-GNU', 'libversion.in',
185 'mdate-sh', 'mkinstalldirs', 'install-sh', 'texinfo.tex',
186 'ansi2knr.c', 'ansi2knr.1', 'elisp-comp',
187 # ltconfig appears here for compatibility with old versions
189 'ylwrap', 'acinclude.m4', @libtoolize_files, @libtoolize_sometimes,
190 'missing', 'depcomp', 'compile', 'py-compile'
193 # Commonly used files we auto-include, but only sometimes.
194 my @common_sometimes =
196 'aclocal.m4', 'acconfig.h', 'config.h.top',
197 'config.h.bot', 'stamp-h.in', 'stamp-vti'
200 # Copyright on generated Makefile.ins.
201 my $gen_copyright = "\
202 # Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
203 # Free Software Foundation, Inc.
204 # This Makefile.in is free software; the Free Software Foundation
205 # gives unlimited permission to copy and/or distribute it,
206 # with or without modifications, as long as this notice is preserved.
208 # This program is distributed in the hope that it will be useful,
209 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
210 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
211 # PARTICULAR PURPOSE.
214 # These constants are returned by lang_*_rewrite functions.
215 # LANG_SUBDIR means that the resulting object file should be in a
216 # subdir if the source file is. In this case the file name cannot
217 # have `..' components.
219 my $LANG_PROCESS = 1;
222 # Directories installed during 'install-exec' phase.
241 # Map from obsolete macros to hints for new macros.
242 # If you change this, change the corresponding list in aclocal.in.
243 # FIXME: should just put this into a single file.
244 my %obsolete_macros =
246 'AC_FEATURE_CTYPE' => "use `AC_HEADER_STDC'",
247 'AC_FEATURE_ERRNO' => "add `strerror' to `AC_REPLACE_FUNCS(...)'",
248 'AC_FEATURE_EXIT' => '',
249 'AC_SYSTEM_HEADER' => '',
251 # Note that we do not handle this one, because it is still run
252 # from AM_CONFIG_HEADER. So we deal with it specially in
253 # &scan_autoconf_files.
254 # 'AC_CONFIG_HEADER' => "use `AM_CONFIG_HEADER'",
256 'fp_C_PROTOTYPES' => "use `AM_C_PROTOTYPES'",
257 'fp_PROG_CC_STDC' => "use `AM_PROG_CC_STDC'",
258 'fp_PROG_INSTALL' => "use `AC_PROG_INSTALL'",
259 'fp_WITH_DMALLOC' => "use `AM_WITH_DMALLOC'",
260 'fp_WITH_REGEX' => "use `AM_WITH_REGEX'",
261 'gm_PROG_LIBTOOL' => "use `AM_PROG_LIBTOOL'",
262 'jm_MAINTAINER_MODE' => "use `AM_MAINTAINER_MODE'",
263 'md_TYPE_PTRDIFF_T' => "use `AM_TYPE_PTRDIFF_T'",
264 'ud_PATH_LISPDIR' => "use `AM_PATH_LISPDIR'",
265 'ud_GNU_GETTEXT' => "use `AM_GNU_GETTEXT'",
267 # Now part of autoconf proper, under a different name.
268 'AM_FUNC_FNMATCH' => "use `AC_FUNC_FNMATCH'",
269 'fp_FUNC_FNMATCH' => "use `AC_FUNC_FNMATCH'",
270 'AM_SANITY_CHECK_CC' => "automatically done by `AC_PROG_CC'",
271 'AM_PROG_INSTALL' => "use `AC_PROG_INSTALL'",
272 'AM_EXEEXT' => "use `AC_EXEEXT'",
273 'AM_CYGWIN32' => "use `AC_CYGWIN'",
274 'AM_MINGW32' => "use `AC_MINGW32'",
275 'AM_FUNC_MKTIME' => "use `AC_FUNC_MKTIME'",
277 # These aren't quite obsolete.
281 # Regexp to match the above macros.
282 my $obsolete_rx = '(\b' . join ('\b|\b', keys %obsolete_macros) . '\b)';
286 ## ---------------------------------- ##
287 ## Variables related to the options. ##
288 ## ---------------------------------- ##
290 # TRUE if we should always generate Makefile.in.
291 my $force_generation = 1;
293 # Strictness level as set on command line.
294 my $default_strictness = $GNU;
296 # Name of strictness level, as set on command line.
297 my $default_strictness_name = 'gnu';
299 # This is TRUE if automatic dependency generation code should be
300 # included in generated Makefile.in.
301 my $cmdline_use_dependencies = 1;
303 # TRUE if in verbose mode.
306 # This holds our (eventual) exit status. We don't actually exit until
307 # we have processed all input files.
310 # From the Perl manual.
311 my $symlink_exists = (eval 'symlink ("", "");', $@ eq '');
313 # TRUE if missing standard files should be installed.
316 # TRUE if we should copy missing files; otherwise symlink if possible.
317 my $copy_missing = 0;
319 # TRUE if we should always update files that we know about.
320 my $force_missing = 0;
323 ## ---------------------------------------- ##
324 ## Variables filled during files scanning. ##
325 ## ---------------------------------------- ##
327 # Name of the top autoconf input: `configure.ac' or `configure.in'.
328 my $configure_ac = '';
330 # Files found by scanning configure.ac for LIBOBJS.
333 # True if AM_C_PROTOTYPES appears in configure.ac.
334 my $am_c_prototypes = 0;
336 # Names used in AC_CONFIG_HEADER call. @config_fullnames holds the
337 # name which appears in AC_CONFIG_HEADER, colon and all.
338 # @config_names holds the file names. @config_headers holds the '.in'
339 # files. Ordinarily these are similar, but they can be different if
340 # the weird "NAME:FILE" syntax is used.
341 my @config_fullnames = ();
342 my @config_names = ();
343 my @config_headers = ();
344 # Line number at which AC_CONFIG_HEADER appears in configure.ac.
345 my $config_header_line = 0;
347 # Directory where output files go. Actually, output files are
348 # relative to this directory.
349 my $output_directory = '.';
351 # List of Makefile.am's to process, and their corresponding outputs.
352 my @input_files = ();
353 my %output_files = ();
355 # Complete list of Makefile.am's that exist.
356 my @configure_input_files = ();
358 # List of files in AC_OUTPUT without Makefile.am, and their outputs.
359 my @other_input_files = ();
360 # Line number at which AC_OUTPUT seen.
361 my $ac_output_line = 0;
363 # List of directories to search for configure-required files. This
364 # can be set by AC_CONFIG_AUX_DIR.
365 my @config_aux_path = ('.', '..', '../..');
366 my $config_aux_dir = '';
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_CHECK_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 # These are pretty obvious, too. They are used to define the
573 # SOURCES and OBJECTS variables.
576 # Sources which go in the distribution.
579 # This hash maps object file names onto their corresponding source
580 # file names. This is used to ensure that each object is created
581 # by a single source file.
584 # This keeps track of the directories for which we've already
585 # created `.dirstamp' code.
595 # Options from AUTOMAKE_OPTIONS.
598 # Whether or not dependencies are handled. Can be further changed
600 my $use_dependencies;
603 my $local_maint_charset;
605 # All yacc and lex source filenames for this directory. Use
606 # filenames instead of raw count so that multiple instances are
607 # counted correctly (eg one yacc file can appear in multiple
608 # programs without harm).
612 # This is a list of all targets to run during "make dist".
615 # Keys in this hash are the basenames of files which must depend
619 # This maps the source extension of a suffix rule to its
620 # corresponding output extension.
623 # This is the name of the redirect `all' target to use.
626 # This keeps track of which extensions we've seen (that we care
630 # This is random scratch space for the language finish functions.
631 # Don't randomly overwrite it; examine other uses of keys first.
632 my %language_scratch;
634 # We keep track of which objects need special (per-executable)
635 # handling on a per-language basis.
636 my %lang_specific_files;
638 # This is set when `handle_dist' has finished. Once this happens,
639 # we should no longer push on dist_common.
642 # True if we need `LINK' defined. This is a hack.
645 # This is the list of such variables to output.
646 # FIXME: Might be useless actually.
649 # Was get_object_extension run?
650 # FIXME: This is a hack. a better switch should be found.
651 my $get_object_extension_was_run;
654 ## --------------------------------- ##
655 ## Forward subroutine declarations. ##
656 ## --------------------------------- ##
657 sub register_language (%);
658 sub file_contents_internal ($$%);
661 # &initialize_per_input ()
662 # ------------------------
663 # (Re)-Initialize per-Makefile.am variables.
664 sub initialize_per_input ()
667 $am_relative_dir = '';
674 $output_trailer = '';
690 %target_conditional = ();
698 $am_relative_dir = '';
714 # Installing/uninstalling.
715 'install-data-am' => [],
716 'install-exec-am' => [],
717 'uninstall-am' => [],
720 'uninstall-man' => [],
722 'install-info' => [],
723 'install-info-am' => [],
724 'uninstall-info' => [],
726 'installcheck-am' => [],
730 'mostlyclean-am' => [],
731 'maintainer-clean-am' => [],
732 'distclean-am' => [],
735 'maintainer-clean' => [],
746 @maintainer_clean_files = ();
758 $strictness = $default_strictness;
759 $strictness_name = $default_strictness_name;
763 $use_dependencies = $cmdline_use_dependencies;
765 $local_maint_charset = $maint_charset;
778 %extension_seen = ();
780 %language_scratch = ();
782 %lang_specific_files = ();
784 $handle_dist_run = 0;
790 $get_object_extension_was_run = 0;
792 %compile_clean_files = ();
796 ################################################################
798 # Initialize our list of languages that are internally supported.
801 register_language ('name' => 'c',
803 'config_vars' => ['CC'],
807 'compiler' => 'COMPILE',
808 'compile' => '$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)',
812 'link' => '$(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
813 'compile_flag' => '-c',
814 'extensions' => ['c'],
815 '_finish' => \&lang_c_finish);
818 register_language ('name' => 'cxx',
820 'config_vars' => ['CXX'],
821 'linker' => 'CXXLINK',
822 'link' => '$(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
824 'flags' => 'CXXFLAGS',
825 'compile' => '$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)',
826 'compiler' => 'CXXCOMPILE',
827 'compile_flag' => '-c',
828 'output_flag' => '-o',
832 'extensions' => ['c++', 'cc', 'cpp', 'cxx', 'C']);
835 register_language ('name' => 'objc',
836 'Name' => 'Objective C',
837 'config_vars' => ['OBJC'],
838 'linker' => 'OBJCLINK',,
839 'link' => '$(OBJCLD) $(AM_OBJCFLAGS) $(OBJCFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
841 'flags' => 'OBJCFLAGS',
842 'compile' => '$(OBJC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_OBJCFLAGS) $(OBJCFLAGS)',
843 'compiler' => 'OBJCCOMPILE',
844 'compile_flag' => '-c',
845 'output_flag' => '-o',
849 'extensions' => ['m']);
852 register_language ('name' => 'header',
854 'extensions' => ['h', 'H', 'hxx', 'h++', 'hh', 'hpp', 'inc'],
856 '_finish' => sub { });
858 # For now, yacc and lex can't be handled on a per-exe basis.
861 register_language ('name' => 'yacc',
864 'derived_autodep' => 'yes',
865 'extensions' => ['y'],
866 '_finish' => \&lang_yacc_finish);
867 register_language ('name' => 'yaccxx',
868 'Name' => 'Yacc (C++)',
869 'linker' => 'CXXLINK',
870 'derived_autodep' => 'yes',
871 'extensions' => ['y++', 'yy', 'yxx', 'ypp'],
872 '_finish' => \&lang_yacc_finish);
875 register_language ('name' => 'lex',
878 'derived_autodep' => 'yes',
879 'extensions' => ['l'],
880 '_finish' => \&lang_lex_finish);
881 register_language ('name' => 'lexxx',
882 'Name' => 'Lex (C++)',
883 'linker' => 'CXXLINK',
884 'derived_autodep' => 'yes',
885 'extensions' => ['l++', 'll', 'lxx', 'lpp'],
886 '_finish' => \&lang_lex_finish);
889 register_language ('name' => 'asm',
890 'Name' => 'Assembler',
893 'compile' => '$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)',
894 # FIXME: a different compiler?
895 'compiler' => 'COMPILE',
896 'compile_flag' => '-c',
897 'extensions' => ['s', 'S'],
898 # We need the C code for assembly.
899 '_finish' => \&lang_c_finish);
902 register_language ('name' => 'f77',
903 'Name' => 'Fortran 77',
904 'linker' => 'F77LINK',
905 'link' => '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
907 'compile' => '$(F77) $(AM_FFLAGS) $(FFLAGS)',
908 'compiler' => 'F77COMPILE',
909 'compile_flag' => '-c',
910 'output_flag' => '-o',
914 'extensions' => ['f', 'for', 'f90']);
916 # Preprocessed Fortran 77
918 # The current support for preprocessing Fortran 77 just involves
919 # passing `$(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS)
920 # $(CPPFLAGS)' as additional flags to the Fortran 77 compiler, since
921 # this is how GNU Make does it; see the `GNU Make Manual, Edition 0.51
922 # for `make' Version 3.76 Beta' (specifically, from info file
923 # `(make)Catalogue of Rules').
925 # A better approach would be to write an Autoconf test
926 # (i.e. AC_PROG_FPP) for a Fortran 77 preprocessor, because not all
927 # Fortran 77 compilers know how to do preprocessing. The Autoconf
928 # macro AC_PROG_FPP should test the Fortran 77 compiler first for
929 # preprocessing capabilities, and then fall back on cpp (if cpp were
931 register_language ('name' => 'ppf77',
932 'Name' => 'Preprocessed Fortran 77',
933 'config_vars' => ['F77'],
934 'linker' => 'F77LINK',
935 'link' => '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
939 'compiler' => 'PPF77COMPILE',
940 'compile' => '$(F77) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FFLAGS) $(FFLAGS)',
941 'compile_flag' => '-c',
942 'output_flag' => '-o',
944 'extensions' => ['F'],
945 '_finish' => \&lang_ppf77_finish);
948 register_language ('name' => 'ratfor',
950 'config_vars' => ['F77'],
951 'linker' => 'F77LINK',
952 'link' => '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
957 'compile' => '$(F77) $(AM_FFLAGS) $(FFLAGS) $(AM_RFLAGS) $(RFLAGS)',
958 'compiler' => 'RCOMPILE',
959 'compile_flag' => '-c',
960 'output_flag' => '-o',
962 'extensions' => ['r'],
963 '_finish' => \&lang_ratfor_finish);
966 # FIXME: for now we can't do dependency tracking for Java.
968 register_language ('name' => 'java',
970 'config_vars' => ['GCJ'],
971 'linker' => 'GCJLINK',
972 'link' => '$(GCJLD) $(AM_GCJFLAGS) $(GCJFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
973 'flags' => 'GCJFLAGS',
974 'compile' => '$(GCJ) $(AM_GCJFLAGS) $(GCJFLAGS)',
975 'compiler' => 'GCJCOMPILE',
976 'compile_flag' => '-c',
977 'output_flag' => '-o',
981 'extensions' => ['java', 'class', 'zip', 'jar']);
983 ################################################################
985 # Parse command line.
988 # Do configure.ac scan only once.
989 &scan_autoconf_files;
991 die "$me: no `Makefile.am' found or specified\n"
994 # Now do all the work on each file.
995 # This guy must be local otherwise it's private to the loop.
998 foreach $am_file (@input_files)
1000 if (! -f ($am_file . '.am'))
1002 &am_error ("`" . $am_file . ".am' does not exist");
1006 &generate_makefile ($output_files{$am_file}, $am_file);
1012 # FIXME: This should be `my'ed next to its subs.
1013 use vars '%require_file_found';
1015 ################################################################
1017 # prog_error (@PRINT-ME)
1018 # ----------------------
1019 # Signal a programming error, display PRINT-ME, and exit 1.
1022 print STDERR "$me: programming error: @_\n";
1030 # Return LIST with no duplicates.
1035 foreach my $item (@_)
1037 if (! defined $seen{$item})
1048 # Return a configure-style substitution using the indicated text.
1049 # We do this to avoid having the substitutions directly in automake.in;
1050 # when we do that they are sometimes removed and this causes confusion
1055 return '@' . $text . '@';
1058 ################################################################
1062 # &backname ($REL-DIR)
1063 # --------------------
1064 # If I `cd $REL-DIR', then to come back, I should `cd $BACKPATH'.
1065 # For instance `src/foo' => `../..'.
1066 # Works with non strictly increasing paths, i.e., `src/../lib' => `..'.
1071 foreach (split (/\//, $file))
1073 next if $_ eq '.' || $_ eq '';
1083 return join ('/', @res) || '.';
1086 ################################################################
1088 # Parse command line.
1089 sub parse_arguments ()
1092 &set_strictness ('gnu');
1095 Getopt::Long::config ("bundling");
1096 Getopt::Long::GetOptions
1098 'version' => \&version,
1100 'amdir:s' => \$am_dir,
1101 'gnu' => sub { &set_strictness ('gnu'); },
1102 'gnits' => sub { &set_strictness ('gnits'); },
1103 'cygnus' => \$cygnus_mode,
1104 'foreign' => sub { &set_strictness ('foreign'); },
1105 'include-deps' => sub { $cmdline_use_dependencies = 1; },
1106 'i|ignore-deps' => sub { $cmdline_use_dependencies = 0; },
1107 'no-force' => sub { $force_generation = 0; },
1108 'f|force-missing'=> \$force_missing,
1109 'o|output-dir:s' => \$output_directory,
1110 'a|add-missing' => \$add_missing,
1111 'c|copy' => \$copy_missing,
1112 'v|verbose' => \$verbose,
1113 'Werror' => sub { $SIG{"__WARN__"} = sub { die $_[0] } },
1114 'Wno-error' => sub { $SIG{"__WARN__"} = 'DEFAULT' }
1118 foreach my $arg (@ARGV)
1120 # Handle $local:$input syntax. Note that we only examine the
1121 # first ":" file to see if it is automake input; the rest are
1122 # just taken verbatim. We still keep all the files around for
1123 # dependency checking, however.
1124 my ($local, $input, @rest) = split (/:/, $arg);
1131 # Strip .in; later on .am is tacked on. That is how the
1132 # automake input file is found. Maybe not the best way, but
1133 # it is easy to explain.
1135 or die "$me: invalid input file name `$arg'\n.";
1137 push (@input_files, $input);
1138 $output_files{$input} = join (':', ($local, @rest));
1141 # Take global strictness from whatever we currently have set.
1142 $default_strictness = $strictness;
1143 $default_strictness_name = $strictness_name;
1146 ################################################################
1148 # Generate a Makefile.in given the name of the corresponding Makefile and
1149 # the name of the file output by config.status.
1150 sub generate_makefile
1152 my ($output, $makefile) = @_;
1154 # Reset all the Makefile.am related variables.
1155 &initialize_per_input;
1157 # Name of input file ("Makefile.am") and output file
1158 # ("Makefile.in"). These have no directory components.
1159 $am_file_name = basename ($makefile) . '.am';
1160 $in_file_name = basename ($makefile) . '.in';
1162 # $OUTPUT is encoded. If it contains a ":" then the first element
1163 # is the real output file, and all remaining elements are input
1164 # files. We don't scan or otherwise deal with these input file,
1165 # other than to mark them as dependencies. See
1166 # &scan_autoconf_files for details.
1167 my (@secondary_inputs);
1168 ($output, @secondary_inputs) = split (/:/, $output);
1170 $relative_dir = dirname ($output);
1171 $am_relative_dir = dirname ($makefile);
1173 &read_main_am_file ($makefile . '.am');
1174 if (&handle_options)
1176 # Fatal error. Just return, so we can continue with next file.
1180 # There are a few install-related variables that you should not define.
1181 foreach my $var ('PRE_INSTALL', 'POST_INSTALL', 'NORMAL_INSTALL')
1183 if (&variable_defined ($var) && !$var_is_am{$var})
1185 &am_line_error ($var, "`$var' should not be defined");
1189 # At the toplevel directory, we might need config.guess, config.sub
1190 # or libtool scripts (ltconfig and ltmain.sh).
1191 if ($relative_dir eq '.')
1193 # libtool requires some files.
1194 &require_conf_file_with_conf_line ($libtool_line, $FOREIGN,
1198 # AC_CANONICAL_HOST and AC_CANONICAL_SYSTEM need config.guess and
1200 &require_config_file ($FOREIGN, 'config.guess', 'config.sub')
1204 # We still need Makefile.in here, because sometimes the `dist'
1205 # target doesn't re-run automake.
1206 if ($am_relative_dir eq $relative_dir)
1208 # Only distribute the files if they are in the same subdir as
1209 # the generated makefile.
1210 &push_dist_common ($in_file_name, $am_file_name);
1213 push (@sources, '$(SOURCES)')
1214 if &variable_defined ('SOURCES');
1215 push (@objects, '$(OBJECTS)')
1216 if &variable_defined ('OBJECTS');
1218 # If OBJEXT/EXEEXT were not set in configure.in, do it, it
1219 # simplifies our task, and anyway starting with Autoconf 2.50, it
1220 # will always be defined, and this code will be dead.
1221 $output_vars .= "EXEEXT =\n"
1222 unless $seen_exeext;
1223 $output_vars .= "OBJEXT = o\n"
1224 unless $seen_objext;
1226 # Must do this after reading .am file. See read_main_am_file to
1227 # understand weird tricks we play there with variables.
1228 &define_variable ('subdir', $relative_dir);
1230 # Check first, because we might modify some state.
1232 &check_gnu_standards;
1233 &check_gnits_standards;
1235 &handle_configure ($output, $makefile, @secondary_inputs);
1238 &handle_ltlibraries;
1242 # This must be run after all the sources are scanned.
1246 # Re-init SOURCES and OBJECTS. FIXME: other code shouldn't depend
1247 # on this (but currently does).
1248 macro_define ('SOURCES', 1, '', 'TRUE',
1249 join (' ', @sources), 'internal');
1250 macro_define ('OBJECTS', 1, '', 'TRUE',
1251 join (' ', @objects), 'internal');
1252 &define_pretty_variable ('DIST_SOURCES', '', @dist_sources);
1264 &handle_minor_options;
1267 # This must come after most other rules.
1268 &handle_dist ($makefile);
1271 &do_check_merge_target;
1272 &handle_all ($output);
1275 if (&variable_defined('lib_LTLIBRARIES') &&
1276 &variable_defined('bin_PROGRAMS'))
1278 $output_rules .= "install-binPROGRAMS: install-libLTLIBRARIES\n\n";
1281 &handle_installdirs;
1283 &handle_factored_dependencies;
1287 if (! -d ($output_directory . '/' . $am_relative_dir))
1289 mkdir ($output_directory . '/' . $am_relative_dir, 0755);
1292 my ($out_file) = $output_directory . '/' . $makefile . ".in";
1293 if (! $force_generation && -e $out_file)
1295 my ($am_time) = (stat ($makefile . '.am'))[9];
1296 my ($in_time) = (stat ($out_file))[9];
1297 # FIXME: should cache these times.
1298 my ($conf_time) = (stat ($configure_ac))[9];
1299 # FIXME: how to do unsigned comparison?
1300 if ($am_time < $in_time || $am_time < $conf_time)
1302 # No need to update.
1305 if (-f 'aclocal.m4')
1307 my ($acl_time) = (stat _)[9];
1308 return if ($am_time < $acl_time);
1312 my $gm_file = new IO::File "> $out_file";
1315 warn "$me: ${am_file}.in: cannot write: $!\n";
1319 print "$me: creating ", $makefile, ".in\n" if $verbose;
1321 # In case we're running under MSWindows, don't write with CRLF
1322 # (as it causes problems for the dependency-file extraction in
1323 # AM_OUTPUT_DEPENDENCY_COMMANDS).
1326 print $gm_file $output_vars;
1327 # We make sure that `all:' is the first target.
1328 print $gm_file $output_all;
1329 print $gm_file $output_header;
1330 print $gm_file $output_rules;
1331 print $gm_file $output_trailer;
1333 if (! $gm_file->close)
1335 warn "$me: $am_file.in: cannot close: $!\n";
1341 ################################################################
1343 # Handle AUTOMAKE_OPTIONS variable. Return 1 on error, 0 otherwise.
1346 if (&variable_defined ('AUTOMAKE_OPTIONS'))
1348 foreach (&variable_value_as_list ('AUTOMAKE_OPTIONS', ''))
1351 if ($_ eq 'gnits' || $_ eq 'gnu' || $_ eq 'foreign')
1353 &set_strictness ($_);
1355 elsif ($_ eq 'cygnus')
1361 # An option like "../lib/ansi2knr" is allowed. With
1362 # no path prefix, we assume the required programs are
1363 # in this directory. We save the actual option for
1365 $options{'ansi2knr'} = $_;
1367 elsif ($_ eq 'no-installman' || $_ eq 'no-installinfo'
1368 || $_ eq 'dist-shar' || $_ eq 'dist-zip'
1369 || $_ eq 'dist-tarZ' || $_ eq 'dist-bzip2'
1370 || $_ eq 'dejagnu' || $_ eq 'no-texinfo.tex'
1371 || $_ eq 'readme-alpha' || $_ eq 'check-news'
1372 || $_ eq 'subdir-objects' || $_ eq 'nostdinc')
1374 # Explicitly recognize these.
1376 elsif ($_ eq 'no-dependencies')
1378 $use_dependencies = 0;
1380 elsif (/(\d+)\.(\d+)([a-z]?)(-[A-Za-z0-9]+)?/)
1382 # Got a version number.
1384 my ($rmajor, $rminor, $ralpha, $rfork) = ($1, $2, $3, $4);
1386 &prog_error ("version is incorrect: $VERSION")
1387 if $VERSION !~ /(\d+)\.(\d+)([a-z]?)(-[A-Za-z0-9]+)?/;
1389 my ($tmajor, $tminor, $talpha, $tfork) = ($1, $2, $3, $4);
1394 # 2.0 is better than 1.0.
1395 # 1.2 is better than 1.1.
1396 # 1.2a is better than 1.2.
1397 # If we require 3.4n-foo then we require something
1398 # >= 3.4n, with the `foo' fork identifier.
1399 if ($rmajor > $tmajor
1400 || ($rmajor == $tmajor && $rminor > $tminor)
1401 || ($rminor == $tminor && $rminor == $tminor
1402 && $ralpha gt $talpha)
1403 || ($rfork ne '' && $rfork ne $tfork))
1405 &am_line_error ('AUTOMAKE_OPTIONS',
1406 "require version $_, but have $VERSION");
1412 &am_line_error ('AUTOMAKE_OPTIONS',
1413 "option `" . $_ . "\' not recognized");
1418 if ($strictness == $GNITS)
1420 $options{'readme-alpha'} = 1;
1421 $options{'check-news'} = 1;
1428 # get_object_extension ($OUT)
1429 # ---------------------------
1430 # Return object extension. Just once, put some code into the output.
1431 # OUT is the name of the output file
1432 sub get_object_extension
1436 # Maybe require libtool library object files.
1437 my $extension = '.$(OBJEXT)';
1438 $extension = '.lo' if ($out =~ /\.la$/);
1440 # Check for automatic de-ANSI-fication.
1441 $extension = '$U' . $extension
1442 if defined $options{'ansi2knr'};
1444 $get_object_extension_was_run = 1;
1450 # Call finish function for each language that was used.
1451 sub handle_languages
1453 if ($use_dependencies)
1455 # Include auto-dep code. Don't include it if DEP_FILES would
1457 if (&saw_sources_p (0) && keys %dep_files)
1459 my $config_aux_dir_specified = ($config_aux_dir ne '.'
1460 && $config_aux_dir ne '');
1462 # Set $require_file_found{'depcomp'} if the depcomp file exists,
1463 # before calling require_config_file on `depcomp'. This makes
1464 # require_file_internal skip its buggy existence test that would
1465 # make automake fail (with `required file `lib/depcomp' not found')
1466 # when AC_CONFIG_AUX_DIR is not set. See tests/subdir4.test.
1467 my $depcomp_dir = ($config_aux_dir_specified ? $config_aux_dir
1469 $require_file_found{'depcomp'} = 1 if -f "$depcomp_dir/depcomp";
1471 # Set location of depcomp.
1472 my $prefix = ($config_aux_dir_specified ? $config_aux_dir
1475 &define_variable ('depcomp', "\$(SHELL) $prefix/depcomp");
1477 &require_config_file ($FOREIGN, 'depcomp');
1479 my @deplist = sort keys %dep_files;
1481 # We define this as a conditional variable because BSD
1482 # make can't handle backslashes for continuing comments on
1483 # the following line.
1484 &define_pretty_variable ('DEP_FILES', 'AMDEP_TRUE', @deplist);
1486 # Generate each `include' individually. Irix 6 make will
1487 # not properly include several files resulting from a
1488 # variable expansion; generating many separate includes
1490 $output_rules .= "\n";
1491 foreach my $iter (@deplist)
1493 $output_rules .= (subst ('AMDEP_TRUE')
1494 . subst ('_am_include')
1496 . subst ('_am_quote')
1498 . subst ('_am_quote')
1502 $output_rules .= &file_contents ('depend');
1507 &define_variable ('depcomp', '');
1512 # Is the c linker needed?
1514 foreach my $ext (sort keys %extension_seen)
1516 my $lang = $languages{$extension_map{$ext}};
1518 # Get information on $LANG.
1519 my $pfx = $lang->autodep;
1520 my $fpfx = ($pfx eq '') ? 'CC' : $pfx;
1522 my $AMDEP = (($use_dependencies && $lang->autodep ne 'no')
1523 ? 'AMDEP' : 'FALSE');
1525 my %transform = ('EXT' => $ext,
1528 'LIBTOOL' => $seen_libtool,
1530 '-c' => $lang->compile_flag || '');
1532 # Generate the appropriate rules for this extension.
1533 if ($use_dependencies && $lang->autodep ne 'no'
1534 || defined $lang->compile)
1536 # Some C compilers don't support -c -o. Use it only if really
1538 my $output_flag = $lang->output_flag || '';
1541 && $lang->flags eq 'CFLAGS'
1542 && defined $options{'subdir-objects'});
1545 file_contents ('depend2',
1555 'COMPILE' => '$(' . $lang->compiler . ')',
1556 'LTCOMPILE' => '$(LT' . $lang->compiler . ')',
1557 '-o' => $output_flag);
1560 # Now include code for each specially handled object with this
1562 my %seen_files = ();
1563 foreach my $file (@{$lang_specific_files{$lang->name}})
1565 my ($derived, $source, $obj) = split (' ', $file);
1567 # We might see a given object twice, for instance if it is
1568 # used under different conditions.
1569 next if defined $seen_files{$obj};
1570 $seen_files{$obj} = 1;
1572 my $flags = $lang->flags || '';
1573 my $val = "${derived}_${flags}";
1575 (my $obj_compile = $lang->compile) =~ s/\(AM_$flags/\($val/;
1576 my $obj_ltcompile = '$(LIBTOOL) --mode=compile ' . $obj_compile;
1578 # We _need_ `-o' for per object rules.
1579 my $output_flag = $lang->output_flag || '-o';
1581 # Generate a transform which will turn suffix targets in
1582 # depend2.am into real targets for the particular objects we
1585 file_contents ('depend2',
1590 'SOURCE' => $source,
1592 'OBJOBJ' => "$obj.obj",
1593 'LTOBJ' => "$obj.lo",
1595 'COMPILE' => $obj_compile,
1596 'LTCOMPILE' => $obj_ltcompile,
1597 '-o' => $output_flag));
1600 # The rest of the loop is done once per language.
1601 next if defined $done{$lang};
1605 # If the source to a program consists entirely of code from a
1606 # `pure' language, for instance C++ for Fortran 77, then we
1607 # don't need the C compiler code. However if we run into
1608 # something unusual then we do generate the C code. There are
1609 # probably corner cases here that do not work properly.
1610 # People linking Java code to Fortran code deserve pain.
1611 $needs_c ||= ! $lang->pure;
1613 define_compiler_variable ($lang)
1614 if ($lang->compile);
1616 define_linker_variable ($lang)
1619 foreach my $var (@{$lang->config_vars})
1621 if (!exists $configure_vars{$var})
1623 am_error ($lang->Name
1624 . " source seen but `$var' not defined in"
1625 . " `$configure_ac'");
1629 # The compiler's flag must be a configure variable.
1630 define_configure_variable ($lang->flags)
1631 if (defined $lang->flags);
1633 # Call the finisher.
1637 # If the project is entirely C++ or entirely Fortran 77 (i.e., 1
1638 # suffix rule was learned), don't bother with the C stuff. But if
1639 # anything else creeps in, then use it.
1641 if $need_link || scalar keys %suffix_rules > 1;
1645 if (! defined $done{$languages{'c'}})
1647 &define_configure_variable ($languages{'c'}->flags);
1648 &define_compiler_variable ($languages{'c'});
1650 define_linker_variable ($languages{'c'});
1654 # Output a rule to build from a YACC source. The output from YACC is
1655 # compiled with C or C++, depending on the extension of the YACC file.
1656 sub output_yacc_build_rule
1658 my ($yacc_suffix, $use_ylwrap) = @_;
1660 (my $c_suffix = $yacc_suffix) =~ tr/y/c/;
1662 # Generate rule for c/c++.
1663 $output_rules .= &file_contents ('yacc',
1664 ('YLWRAP' => $use_ylwrap,
1665 'YACC_SUFFIX' => $yacc_suffix,
1666 'C_SUFFIX' => $c_suffix));
1669 sub output_lex_build_rule
1671 my ($lex_suffix, $use_ylwrap) = @_;
1673 (my $c_suffix = $lex_suffix) =~ tr/l/c/;
1675 $output_rules .= &file_contents ('lex',
1676 ('YLWRAP' => $use_ylwrap,
1677 'LEX_SUFFIX' => $lex_suffix,
1678 'C_SUFFIX' => $c_suffix));
1681 if ($use_dependencies)
1683 # Include auto-dep code. Don't include it if DEP_FILES would
1685 if (&saw_sources_p (0) && keys %dep_files)
1687 my $config_aux_dir_specified = ($config_aux_dir ne '.'
1688 && $config_aux_dir ne '');
1690 # Set $require_file_found{'depcomp'} if the depcomp file exists,
1691 # before calling require_config_file on `depcomp'. This makes
1692 # require_file_internal skip its buggy existence test that would
1693 # make automake fail (with `required file `lib/depcomp' not found')
1694 # when AC_CONFIG_AUX_DIR is not set. See tests/subdir4.test.
1695 my $depcomp_dir = ($config_aux_dir_specified ? $config_aux_dir
1697 $require_file_found{'depcomp'} = 1 if -f "$depcomp_dir/depcomp";
1699 # Set location of depcomp.
1700 my $prefix = ($config_aux_dir_specified ? $config_aux_dir
1703 &define_variable ('depcomp', "\$(SHELL) $prefix/depcomp");
1705 &require_config_file ($FOREIGN, 'depcomp');
1707 my @deplist = sort keys %dep_files;
1709 # We define this as a conditional variable because BSD
1710 # make can't handle backslashes for continuing comments on
1711 # the following line.
1712 &define_pretty_variable ('DEP_FILES', 'AMDEP_TRUE', @deplist);
1714 # Generate each `include' individually. Irix 6 make will
1715 # not properly include several files resulting from a
1716 # variable expansion; generating many separate includes
1718 $output_rules .= "\n";
1719 foreach my $iter (@deplist)
1721 $output_rules .= (subst ('AMDEP_TRUE')
1722 . subst ('_am_include')
1724 . subst ('_am_quote')
1726 . subst ('_am_quote')
1730 $output_rules .= &file_contents ('depend');
1735 &define_variable ('depcomp', '');
1738 # Check to make sure a source defined in LIBOBJS is not explicitly
1739 # mentioned. This is a separate function (as opposed to being inlined
1740 # in handle_source_transform) because it isn't always appropriate to
1742 sub check_libobjs_sources
1744 my ($one_file, $unxformed) = @_;
1746 foreach my $prefix ('', 'EXTRA_', 'dist_', 'nodist_',
1747 'dist_EXTRA_', 'nodist_EXTRA_')
1750 if (&variable_defined ($prefix . $one_file . '_SOURCES'))
1752 @files = &variable_value_as_list (($prefix
1753 . $one_file . '_SOURCES'),
1756 elsif ($prefix eq '')
1758 @files = ($unxformed . '.c');
1765 foreach my $file (@files)
1767 if (defined $libsources{$file})
1769 &am_line_error ($prefix . $one_file . '_SOURCES',
1770 "automatically discovered file `$file' should not be explicitly mentioned");
1776 if ($use_dependencies)
1778 # Include auto-dep code. Don't include it if DEP_FILES would
1780 if (&saw_sources_p (0) && keys %dep_files)
1782 my $config_aux_dir_specified = ($config_aux_dir ne '.'
1783 && $config_aux_dir ne '');
1785 # Set $require_file_found{'depcomp'} if the depcomp file exists,
1786 # before calling require_config_file on `depcomp'. This makes
1787 # require_file_internal skip its buggy existence test that would
1788 # make automake fail (with `required file `lib/depcomp' not found')
1789 # when AC_CONFIG_AUX_DIR is not set. See tests/subdir4.test.
1790 my $depcomp_dir = ($config_aux_dir_specified ? $config_aux_dir
1792 $require_file_found{'depcomp'} = 1 if -f "$depcomp_dir/depcomp";
1794 # Set location of depcomp.
1795 my $prefix = ($config_aux_dir_specified ? $config_aux_dir
1798 &define_variable ('depcomp', "\$(SHELL) $prefix/depcomp");
1800 &require_config_file ($FOREIGN, 'depcomp');
1802 my @deplist = sort keys %dep_files;
1804 # We define this as a conditional variable because BSD
1805 # make can't handle backslashes for continuing comments on
1806 # the following line.
1807 &define_pretty_variable ('DEP_FILES', 'AMDEP_TRUE', @deplist);
1809 # Generate each `include' individually. Irix 6 make will
1810 # not properly include several files resulting from a
1811 # variable expansion; generating many separate includes
1813 $output_rules .= "\n";
1814 foreach my $iter (@deplist)
1816 $output_rules .= (subst ('AMDEP_TRUE')
1817 . subst ('_am_include')
1819 . subst ('_am_quote')
1821 . subst ('_am_quote')
1825 $output_rules .= &file_contents ('depend');
1830 &define_variable ('depcomp', '');
1833 # ($LINKER, @OBJECTS)
1834 # handle_single_transform_list ($VAR, $DERIVED, $OBJ, @FILES)
1835 # -----------------------------------------------------------
1836 # Does much of the actual work for handle_source_transform.
1838 # $DERIVED is the name of resulting executable or library
1839 # $OBJ is the object extension (e.g., `$U.lo')
1840 # @FILES is the list of source files to transform
1842 # $LINKER is name of linker to use (empty string for default linker)
1843 # @OBJECTS are names of objects
1844 sub handle_single_transform_list ($$$@)
1846 my ($var, $derived, $obj, @files) = @_;
1848 my $nonansi_obj = $obj;
1849 $nonansi_obj =~ s/\$U//g;
1850 my %linkers_used = ();
1852 # Turn sources into objects.
1855 # Configure substitutions in _SOURCES variables are errors.
1858 &am_line_error ($var, "$var includes configure substitution `$_'");
1862 # If the source file is in a subdirectory then the `.o' is
1863 # put into the current directory.
1865 # Split file name into base and extension.
1866 next if ! /^(?:(.*)\/)?([^\/]*)\.(.*)$/;
1868 my $directory = $1 || '';
1872 # We must generate a rule for the object if it requires its own flags.
1874 my ($linker, $object);
1876 $extension = &derive_suffix ($extension);
1877 my $lang = $languages{$extension_map{$extension}};
1880 &saw_extension ($extension);
1881 # Found the language, so see what it says.
1882 my $subr = 'lang_' . $lang->name . '_rewrite';
1883 # Note: computed subr call.
1884 my $r = & $subr ($directory, $base, $extension);
1885 # Skip this entry if we were asked not to process it.
1886 next if $r == $LANG_IGNORE;
1888 # Now extract linker and other info.
1889 $linker = $lang->linker;
1894 $object = $base . $obj;
1895 $this_obj_ext = $obj;
1899 $object = $base . $nonansi_obj;
1900 $this_obj_ext = $nonansi_obj;
1903 if (defined $lang->flags
1904 && &variable_defined ($derived . '_' . $lang->flags))
1906 # We have a per-executable flag in effect for this
1907 # object. In this case we rewrite the object's
1908 # name to ensure it is unique. We also require
1909 # the `compile' program to deal with compilers
1910 # where `-c -o' does not work.
1912 # We choose the name `DERIVED_OBJECT' to ensure
1913 # (1) uniqueness, and (2) continuity between
1914 # invocations. However, this will result in a
1915 # name that is too long for losing systems, in
1916 # some situations. So we provide _SHORTNAME to
1919 my $dname = $derived;
1920 if (&variable_defined ($derived . '_SHORTNAME'))
1922 # FIXME: should use the same conditional as
1923 # the _SOURCES variable. But this is really
1924 # silly overkill -- nobody should have
1925 # conditional shortnames.
1926 $dname = &variable_value ($derived . '_SHORTNAME');
1928 $object = $dname . '-' . $object;
1930 &require_file ($FOREIGN, 'compile')
1931 if $lang->name eq 'c';
1933 &prog_error ("$lang->name flags defined without compiler")
1934 if ! defined $lang->compile;
1939 # If rewrite said it was ok, put the object into a
1941 if ($r == $LANG_SUBDIR && $directory ne '')
1943 $object = $directory . '/' . $object;
1946 # If doing dependency tracking, then we can't print
1947 # the rule. If we have a subdir object, we need to
1948 # generate an explicit rule. Actually, in any case
1949 # where the object is not in `.' we need a special
1950 # rule. The per-object rules in this case are
1951 # generated later, by handle_languages.
1952 if ($renamed || $directory ne '')
1954 my $obj_sans_ext = substr ($object, 0,
1955 - length ($this_obj_ext));
1956 push (@{$lang_specific_files{$lang->name}},
1957 "$derived $full $obj_sans_ext");
1960 elsif ($extension eq 'o')
1962 # This is probably the result of a direct suffix rule.
1963 # In this case we just accept the rewrite. FIXME:
1964 # this fails if we want libtool objects.
1965 $object = $base . '.' . $extension;
1970 # No error message here. Used to have one, but it was
1975 $linkers_used{$linker} = 1;
1977 push (@result, $object);
1979 if (defined $object_map{$object})
1981 if ($object_map{$object} ne $full)
1983 &am_error ("object `$object' created by `$full' and `$object_map{$object}'");
1989 $object_map{$object} = $full;
1991 # If file is in subdirectory, we need explicit
1993 if ($directory ne '' || $renamed)
1995 push (@dep_list, $full);
1998 # If resulting object is in subdir, we need to make
1999 # sure the subdir exists at build time.
2000 if ($object =~ /\//)
2002 # FIXME: check that $DIRECTORY is somewhere in the
2005 # We don't allow `..' in object file names for
2006 # *any* source, not just Java. For Java it just
2007 # doesn't make sense, but in general it is
2008 # a problem because we can't pick a good name for
2010 if ($object =~ /(\/|^)\.\.\//)
2012 &am_error ("`$full' contains `..' component but should not");
2015 # Make sure object is removed by `make mostlyclean'.
2016 $compile_clean_files{$object} = $MOSTLY_CLEAN;
2018 push (@dep_list, $directory . '/.dirstamp');
2020 # If we're generating dependencies, we also want
2021 # to make sure that the appropriate subdir of the
2022 # .deps directory is created.
2023 if ($use_dependencies)
2025 push (@dep_list, '.deps/' . $directory . '/.dirstamp');
2028 if (! defined $directory_map{$directory})
2030 $directory_map{$directory} = 1;
2032 # Directory must be removed by `make distclean'.
2033 $compile_clean_files{$directory . "/.dirstamp"} =
2035 $output_rules .= ($directory . "/.dirstamp:\n"
2036 . "\t\@\$(mkinstalldirs) $directory\n"
2037 . "\t\@: > $directory/.dirstamp\n");
2038 if ($use_dependencies)
2040 $output_rules .= ('.deps/' . $directory
2042 . "\t\@\$(mkinstalldirs) .deps/$directory\n"
2043 . "\t\@: > .deps/$directory/.dirstamp\n");
2048 &pretty_print_rule ($object . ':', "\t", @dep_list)
2049 if scalar @dep_list > 0;
2052 # Transform .o or $o file into .P file (for automatic
2055 && ($lang->autodep ne 'no'
2056 || $lang->derived_autodep eq 'yes'))
2058 my $depfile = $object;
2059 $depfile =~ s/\.([^.]*)$/.P$1/;
2060 $depfile =~ s/\$\(OBJEXT\)$/o/;
2061 $dep_files{'$(DEPDIR)/' . $depfile} = 1;
2065 return (&resolve_linker (%linkers_used), @result);
2070 # Handle SOURCE->OBJECT transform for one program or library.
2072 # canonical (transformed) name of object to build
2073 # actual name of object to build
2074 # object extension (ie either `.o' or `$o'.
2075 # Return result is name of linker variable that must be used.
2076 # Empty return means just use `LINK'.
2077 sub handle_source_transform
2079 # one_file is canonical name. unxformed is given name. obj is
2081 my ($one_file, $unxformed, $obj) = @_;
2085 if (&variable_defined ($one_file . "_OBJECTS"))
2087 &am_line_error ($one_file . '_OBJECTS',
2088 $one_file . '_OBJECTS', 'should not be defined');
2089 # No point in continuing.
2094 foreach my $prefix ('', 'EXTRA_', 'dist_', 'nodist_',
2095 'dist_EXTRA_', 'nodist_EXTRA_')
2097 my $var = $prefix . $one_file . "_SOURCES";
2099 if !variable_defined ($var);
2101 # We are going to define _OBJECTS variables using the prefix.
2102 # Then we glom them all together. So we can't use the null
2103 # prefix here as we need it later.
2104 my $xpfx = ($prefix eq '') ? 'am_' : $prefix;
2106 # Keep track of which prefixes we saw.
2107 $used_pfx{$xpfx} = 1
2108 unless $prefix =~ /EXTRA_/;
2110 push (@sources, '$(' . $prefix . $one_file . "_SOURCES)");
2111 push (@objects, '$(' . $xpfx . $one_file . "_OBJECTS)")
2112 unless $prefix =~ /EXTRA_/;
2113 push (@dist_sources, '$(' . $prefix . $one_file . "_SOURCES)")
2114 unless $prefix =~ /^nodist_/;
2115 foreach my $cond (variable_conditions ($var))
2117 my @files = &variable_value_as_list ($var, $cond);
2118 my ($temp, @result) =
2119 &handle_single_transform_list ($var, $one_file, $obj,
2121 # If there are no files to compile, don't require a linker (yet).
2125 # Define _OBJECTS conditionally.
2126 &define_pretty_variable ($xpfx . $one_file . '_OBJECTS',
2128 unless $prefix =~ /EXTRA_/;
2132 my @keys = sort keys %used_pfx;
2133 if (scalar @keys == 0)
2135 &define_variable ($one_file . "_SOURCES", $unxformed . ".c");
2136 push (@sources, $unxformed . '.c');
2137 push (@dist_sources, $unxformed . '.c');
2138 push (@objects, $unxformed . $obj);
2140 my ($temp, @result) =
2141 &handle_single_transform_list ($one_file . '_SOURCES',
2144 $linker = $temp if $linker eq '';
2145 &define_pretty_variable ($one_file . "_OBJECTS", '', @result)
2149 grep ($_ = '$(' . $_ . $one_file . '_OBJECTS)', @keys);
2150 &define_pretty_variable ($one_file . '_OBJECTS', '', @keys);
2153 # If we want to use `LINK' we must make sure it is defined.
2163 # handle_lib_objects ($XNAME, $VAR)
2164 # ---------------------------------
2165 # Special-case @ALLOCA@ and @LIBOBJS@ in _LDADD or _LIBADD variables.
2166 # Also, generate _DEPENDENCIES variable if appropriate.
2168 # transformed name of object being built, or empty string if no object
2169 # name of _LDADD/_LIBADD-type variable to examine
2170 # Returns 1 if LIBOBJS seen, 0 otherwise.
2171 sub handle_lib_objects
2173 my ($xname, $var) = @_;
2175 &prog_error ("handle_lib_objects: $var undefined")
2176 if ! &variable_defined ($var);
2179 foreach my $cond (&variable_conditions ($var))
2181 if (&handle_lib_objects_cond ($xname, $var, $cond))
2189 # Subroutine of handle_lib_objects: handle a particular condition.
2190 sub handle_lib_objects_cond
2192 my ($xname, $var, $cond) = @_;
2194 # We recognize certain things that are commonly put in LIBADD or
2198 my $seen_libobjs = 0;
2201 foreach my $lsearch (&variable_value_as_list ($var, $cond))
2203 # Skip -lfoo and -Ldir; these are explicitly allowed.
2204 next if $lsearch =~ /^-[lL]/;
2205 if (! $flagvar && $lsearch =~ /^-/)
2207 if ($var =~ /^(.*)LDADD$/)
2209 # Skip -dlopen and -dlpreopen; these are explicitly allowed.
2210 next if $lsearch =~ /^-dl(pre)?open$/;
2211 &am_line_error ($var, "linker flags such as `$lsearch' belong in `${1}LDFLAGS");
2215 # Only get this error once.
2217 &am_line_error ($var, "linker flags such as `$lsearch' belong in `${1}LDFLAGS");
2221 # Assume we have a file of some sort, and push it onto the
2222 # dependency list. Autoconf substitutions are not pushed;
2223 # rarely is a new dependency substituted into (eg) foo_LDADD
2224 # -- but "bad things (eg -lX11) are routinely substituted.
2225 # Note that LIBOBJS and ALLOCA are exceptions to this rule,
2226 # and handled specially below.
2227 push (@dep_list, $lsearch)
2228 unless $lsearch =~ /^\@.*\@$/;
2230 # Automatically handle @LIBOBJS@ and @ALLOCA@. Basically this
2231 # means adding entries to dep_files.
2232 if ($lsearch =~ /^\@(LT)?LIBOBJS\@$/)
2234 my $myobjext = ($1 ? 'l' : '') . 'o';
2236 push (@dep_list, $lsearch);
2238 if (! keys %libsources
2239 && ! &variable_defined ($1 . 'LIBOBJS'))
2241 &am_line_error ($var, "\@$1" . "LIBOBJS\@ seen but never set in `$configure_ac'");
2244 foreach my $iter (keys %libsources)
2246 if ($iter =~ /\.([cly])$/)
2248 &saw_extension ($1);
2249 &saw_extension ('c');
2252 if ($iter =~ /\.h$/)
2254 &require_file_with_line ($var, $FOREIGN, $iter);
2256 elsif ($iter ne 'alloca.c')
2258 my $rewrite = $iter;
2259 $rewrite =~ s/\.c$/.P$myobjext/;
2260 $dep_files{'$(DEPDIR)/' . $rewrite} = 1;
2261 ($rewrite = $iter) =~ s/(\W)/\\$1/g;
2262 $rewrite = "^" . $rewrite . "\$";
2263 # Only require the file if it is not a built source.
2264 if (! &variable_defined ('BUILT_SOURCES')
2265 || ! grep (/$rewrite/,
2266 &variable_value_as_list ('BUILT_SOURCES',
2269 &require_file_with_line ($var, $FOREIGN, $iter);
2274 elsif ($lsearch =~ /^\@(LT)?ALLOCA\@$/)
2276 my $myobjext = ($1 ? 'l' : '') . 'o';
2278 push (@dep_list, $lsearch);
2279 &am_line_error ($var,
2280 "\@$1" . "ALLOCA\@ seen but `AC_FUNC_ALLOCA' not in `$configure_ac'")
2281 if ! defined $libsources{'alloca.c'};
2282 $dep_files{'$(DEPDIR)/alloca.P' . $myobjext} = 1;
2283 &require_file_with_line ($var, $FOREIGN, 'alloca.c');
2284 &saw_extension ('c');
2288 if ($xname ne '' && ! &variable_defined ($xname . '_DEPENDENCIES', $cond))
2290 &define_pretty_variable ($xname . '_DEPENDENCIES', $cond, @dep_list);
2293 return $seen_libobjs;
2296 # Canonicalize the input parameter
2300 $string =~ tr/A-Za-z0-9_\@/_/c;
2304 # Canonicalize a name, and check to make sure the non-canonical name
2305 # is never used. Returns canonical name. Arguments are name and a
2306 # list of suffixes to check for.
2307 sub check_canonical_spelling
2309 my ($name, @suffixes) = @_;
2311 my $xname = &canonicalize ($name);
2312 if ($xname ne $name)
2314 foreach my $xt (@suffixes)
2316 &am_line_error ("$name$xt",
2317 "invalid variable `$name$xt'; "
2318 . "should be `$xname$xt'")
2319 if &variable_defined ("$name$xt");
2329 # Set up the compile suite.
2330 sub handle_compile ()
2333 unless $get_object_extension_was_run;
2336 my $default_includes = '';
2337 if (! defined $options{'nostdinc'})
2339 $default_includes = ' -I. -I$(srcdir)';
2341 if (&variable_defined ('CONFIG_HEADER'))
2343 foreach my $hdr (split (' ', &variable_value ('CONFIG_HEADER')))
2345 $default_includes .= ' -I' . dirname ($hdr);
2350 my (@mostly_rms, @dist_rms);
2351 foreach my $item (sort keys %compile_clean_files)
2353 if ($compile_clean_files{$item} == $MOSTLY_CLEAN)
2355 push (@mostly_rms, "\t-rm -f $item");
2357 elsif ($compile_clean_files{$item} == $DIST_CLEAN)
2359 push (@dist_rms, "\t-rm -f $item");
2363 &prog_error ("invalid entry in \%compile_clean_files");
2367 my ($coms, $vars, $rules) =
2368 &file_contents_internal (1, "$am_dir/compile.am",
2369 ('DEFAULT_INCLUDES' => $default_includes,
2370 'MOSTLYRMS' => join ("\n", @mostly_rms),
2371 'DISTRMS' => join ("\n", @dist_rms)));
2372 $output_vars .= $vars;
2373 $output_rules .= "$coms$rules";
2377 # Output the libtool compilation rules.
2378 $output_rules .= &file_contents ('libtool');
2381 # Check for automatic de-ANSI-fication.
2382 if (defined $options{'ansi2knr'})
2384 if (! $am_c_prototypes)
2386 &am_line_error ('AUTOMAKE_OPTIONS',
2387 "option `ansi2knr' in use but `AM_C_PROTOTYPES' not in `$configure_ac'");
2388 &keyed_aclocal_warning ('AM_C_PROTOTYPES');
2389 # Only give this error once.
2390 $am_c_prototypes = 1;
2393 # topdir is where ansi2knr should be.
2394 if ($options{'ansi2knr'} eq 'ansi2knr')
2396 # Only require ansi2knr files if they should appear in
2398 &require_file_with_line ('AUTOMAKE_OPTIONS', $FOREIGN,
2399 'ansi2knr.c', 'ansi2knr.1');
2401 # ansi2knr needs to be built before subdirs, so unshift it.
2402 unshift (@all, '$(ANSI2KNR)');
2405 my $ansi2knr_dir = '';
2406 $ansi2knr_dir = dirname ($options{'ansi2knr'})
2407 if $options{'ansi2knr'} ne 'ansi2knr';
2409 $output_rules .= &file_contents ('ansi2knr',
2410 ('ANSI2KNR-DIR' => $ansi2knr_dir));
2417 # handle_programs ()
2418 # ------------------
2419 # Handle C programs.
2422 my @proglist = &am_install_var ('progs', 'PROGRAMS',
2423 'bin', 'sbin', 'libexec', 'pkglib',
2425 return if ! @proglist;
2427 my $seen_libobjs = 0;
2428 foreach my $one_file (@proglist)
2430 my $obj = &get_object_extension ($one_file);
2432 # Canonicalize names and check for misspellings.
2433 my $xname = &check_canonical_spelling ($one_file, '_LDADD', '_LDFLAGS',
2434 '_SOURCES', '_OBJECTS',
2437 my $linker = &handle_source_transform ($xname, $one_file, $obj);
2440 if (&variable_defined ($xname . "_LDADD"))
2442 if (&handle_lib_objects ($xname, $xname . '_LDADD'))
2450 # User didn't define prog_LDADD override. So do it.
2451 &define_variable ($xname . '_LDADD', '$(LDADD)');
2453 # This does a bit too much work. But we need it to
2454 # generate _DEPENDENCIES when appropriate.
2455 if (&variable_defined ('LDADD'))
2457 if (&handle_lib_objects ($xname, 'LDADD'))
2462 elsif (! &variable_defined ($xname . '_DEPENDENCIES'))
2464 &define_variable ($xname . '_DEPENDENCIES', '');
2469 if (&variable_defined ($xname . '_LIBADD'))
2471 &am_line_error ($xname . '_LIBADD',
2472 "use `" . $xname . "_LDADD', not `"
2473 . $xname . "_LIBADD'");
2476 if (! &variable_defined ($xname . '_LDFLAGS'))
2478 # Define the prog_LDFLAGS variable.
2479 &define_variable ($xname . '_LDFLAGS', '');
2482 # Determine program to use for link.
2484 if (&variable_defined ($xname . '_LINK'))
2486 $xlink = $xname . '_LINK';
2490 $xlink = $linker ? $linker : 'LINK';
2493 $output_rules .= &file_contents ('program',
2494 ('PROGRAM' => $one_file,
2495 'XPROGRAM' => $xname,
2496 'XLINK' => $xlink));
2499 if (&variable_defined ('LDADD') && &handle_lib_objects ('', 'LDADD'))
2506 foreach my $one_file (@proglist)
2508 my $xname = &canonicalize ($one_file);
2510 if (&variable_defined ($xname . '_LDADD'))
2512 &check_libobjs_sources ($xname, $xname . '_LDADD');
2514 elsif (&variable_defined ('LDADD'))
2516 &check_libobjs_sources ($xname, 'LDADD');
2523 # handle_libraries ()
2524 # -------------------
2526 sub handle_libraries
2528 my @liblist = &am_install_var ('libs', 'LIBRARIES',
2529 'lib', 'pkglib', 'noinst', 'check');
2530 return if ! @liblist;
2532 my %valid = &am_primary_prefixes ('LIBRARIES', 0, 'lib', 'pkglib',
2534 if (! defined $configure_vars{'RANLIB'})
2536 foreach my $key (keys %valid)
2538 if (&variable_defined ($key . '_LIBRARIES'))
2540 &am_line_error ($key . '_LIBRARIES', "library used but `RANLIB' not defined in `$configure_ac'");
2541 # Only get this error once. If this is ever printed,
2543 $configure_vars{'RANLIB'} = 'BUG';
2549 my $seen_libobjs = 0;
2550 foreach my $onelib (@liblist)
2552 # Check that the library fits the standard naming convention.
2553 if ($onelib !~ /^lib.*\.a$/)
2555 # FIXME should put line number here. That means mapping
2556 # from library name back to variable name.
2557 &am_error ("`$onelib' is not a standard library name");
2560 my $obj = &get_object_extension ($onelib);
2562 # Canonicalize names and check for misspellings.
2563 my $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_SOURCES',
2564 '_OBJECTS', '_DEPENDENCIES',
2567 if (! &variable_defined ($xlib . '_AR'))
2569 &define_variable ($xlib . '_AR', '$(AR) cru');
2572 if (&variable_defined ($xlib . '_LIBADD'))
2574 if (&handle_lib_objects ($xlib, $xlib . '_LIBADD'))
2581 # Generate support for conditional object inclusion in
2583 &define_variable ($xlib . "_LIBADD", '');
2586 if (&variable_defined ($xlib . '_LDADD'))
2588 &am_line_error ($xlib . '_LDADD',
2589 "use `" . $xlib . "_LIBADD', not `"
2590 . $xlib . "_LDADD'");
2593 # Make sure we at look at this.
2594 &examine_variable ($xlib . '_DEPENDENCIES');
2596 &handle_source_transform ($xlib, $onelib, $obj);
2598 $output_rules .= &file_contents ('library',
2599 ('LIBRARY' => $onelib,
2600 'XLIBRARY' => $xlib));
2605 foreach my $onelib (@liblist)
2607 my $xlib = &canonicalize ($onelib);
2608 if (&variable_defined ($xlib . '_LIBADD'))
2610 &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
2617 # handle_ltlibraries ()
2618 # ---------------------
2619 # Handle shared libraries.
2620 sub handle_ltlibraries
2622 my @liblist = &am_install_var ('ltlib', 'LTLIBRARIES',
2623 'noinst', 'lib', 'pkglib', 'check');
2624 return if ! @liblist;
2627 my %valid = &am_primary_prefixes ('LTLIBRARIES', 0, 'lib', 'pkglib',
2630 foreach my $key (keys %valid)
2632 if (&variable_defined ($key . '_LTLIBRARIES'))
2636 &am_line_error ($key . '_LTLIBRARIES', "library used but `LIBTOOL' not defined in `$configure_ac'");
2637 # Only get this error once. If this is ever printed,
2639 $configure_vars{'LIBTOOL'} = 'BUG';
2643 # Get the installation directory of each library.
2644 for (&variable_value_as_list ($key . '_LTLIBRARIES', 'all'))
2648 &am_error ("`$_' is already going to be installed in `$instdirs{$_}'");
2652 $instdirs{$_} = $key;
2658 my $seen_libobjs = 0;
2659 foreach my $onelib (@liblist)
2661 my $obj = &get_object_extension ($onelib);
2663 # Canonicalize names and check for misspellings.
2664 my $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_LDFLAGS',
2665 '_SOURCES', '_OBJECTS',
2668 if (! &variable_defined ($xlib . '_LDFLAGS'))
2670 # Define the lib_LDFLAGS variable.
2671 &define_variable ($xlib . '_LDFLAGS', '');
2674 # Check that the library fits the standard naming convention.
2675 my $libname_rx = "^lib.*\.la";
2676 if ((&variable_defined ($xlib . '_LDFLAGS')
2677 && grep (/-module/, &variable_value_as_list ($xlib . '_LDFLAGS',
2679 || (&variable_defined ('LDFLAGS')
2680 && grep (/-module/, &variable_value_as_list ('LDFLAGS',
2683 # Relax name checking for libtool modules.
2684 $libname_rx = "\.la";
2686 if ($onelib !~ /$libname_rx$/)
2688 # FIXME this should only be a warning for foreign packages
2689 # FIXME should put line number here. That means mapping
2690 # from library name back to variable name.
2691 &am_error ("`$onelib' is not a standard libtool library name");
2694 if (&variable_defined ($xlib . '_LIBADD'))
2696 if (&handle_lib_objects ($xlib, $xlib . '_LIBADD'))
2703 # Generate support for conditional object inclusion in
2705 &define_variable ($xlib . "_LIBADD", '');
2708 if (&variable_defined ($xlib . '_LDADD'))
2710 &am_line_error ($xlib . '_LDADD',
2711 "use `" . $xlib . "_LIBADD', not `"
2712 . $xlib . "_LDADD'");
2715 # Make sure we at look at this.
2716 &examine_variable ($xlib . '_DEPENDENCIES');
2718 my $linker = &handle_source_transform ($xlib, $onelib, $obj);
2720 # Determine program to use for link.
2722 if (&variable_defined ($xlib . '_LINK'))
2724 $xlink = $xlib . '_LINK';
2728 $xlink = $linker ? $linker : 'LINK';
2732 if ($instdirs{$onelib} eq 'EXTRA'
2733 || $instdirs{$onelib} eq 'noinst'
2734 || $instdirs{$onelib} eq 'check')
2736 # It's an EXTRA_ library, so we can't specify -rpath,
2737 # because we don't know where the library will end up.
2738 # The user probably knows, but generally speaking automake
2739 # doesn't -- and in fact configure could decide
2740 # dynamically between two different locations.
2745 $rpath = ('-rpath $(' . $instdirs{$onelib} . 'dir)');
2748 $output_rules .= &file_contents ('ltlibrary',
2749 ('LTLIBRARY' => $onelib,
2750 'XLTLIBRARY' => $xlib,
2752 'XLINK' => $xlink));
2757 foreach my $onelib (@liblist)
2759 my $xlib = &canonicalize ($onelib);
2760 if (&variable_defined ($xlib . '_LIBADD'))
2762 &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
2768 # See if any _SOURCES variable were misspelled. Also, make sure that
2769 # EXTRA_ variables don't contain configure substitutions.
2772 foreach my $varname (keys %var_value)
2774 foreach my $primary ('_SOURCES', '_LIBADD', '_LDADD', '_LDFLAGS',
2777 if ($varname =~ /$primary$/ && ! $content_seen{$varname})
2779 &am_line_error ($varname,
2780 "invalid unused variable name: `$varname'");
2789 # NOTE we no longer automatically clean SCRIPTS, because it is
2790 # useful to sometimes distribute scripts verbatim. This happens
2791 # eg in Automake itself.
2792 &am_install_var ('-candist', 'scripts', 'SCRIPTS',
2793 'bin', 'sbin', 'libexec', 'pkgdata',
2796 my $scripts_installed = 0;
2797 # Set $scripts_installed if appropriate. Make sure we only find
2798 # scripts which are actually installed -- this is why we can't
2799 # simply use the return value of am_install_var.
2800 my %valid = &am_primary_prefixes ('SCRIPTS', 1, 'bin', 'sbin',
2801 'libexec', 'pkgdata',
2803 foreach my $key (keys %valid)
2805 if ($key ne 'noinst'
2807 && &variable_defined ($key . '_SCRIPTS'))
2809 $scripts_installed = 1;
2810 # push (@check_tests, 'check-' . $key . 'SCRIPTS');
2816 # ($OUTFILE, $VFILE, @CLEAN_FILES)
2817 # &scan_texinfo_file ($FILENAME)
2818 # ------------------------------
2819 # $OUTFILE is the name of the info file produced by $FILENAME.
2820 # $VFILE is the name of the version.texi file used (empty if none).
2821 # @CLEAN_FILES is the list of by products (indexes etc.)
2822 sub scan_texinfo_file
2824 my ($filename) = @_;
2826 # These are always created, no matter whether indexes are used or not.
2827 my @clean_suffixes = ('aux', 'dvi', 'log', 'ps', 'toc',
2828 # grep new.*index texinfo.tex
2829 'cp', 'fn', 'ky', 'vr', 'tp', 'pg');
2831 # There are predefined indexes which don't follow the regular rules.
2832 my %predefined_index =
2835 'c' => 'cps', 'f' => 'fns', 'k' => 'kys',
2836 'v' => 'vrs', 't' => 'tps', 'p' => 'pgs'
2839 # There are commands which include a hidden index command.
2843 'fn' => 'fns', 'un' => 'fns',
2844 'typefn' => 'fns', 'typefun' => 'fns',
2845 'mac' => 'fns', 'spec' => 'fns',
2846 'op' => 'fns', 'typeop' => 'fns',
2847 'method' => 'fns', 'typemethod' => 'fns',
2849 'vr' => 'vrs', 'var' => 'vrs',
2850 'typevr' => 'vrs', 'typevar' => 'vrs',
2853 'ivar' => 'vrs', 'typeivar' => 'vrs',
2858 # Indexes stored into another one. In this case, the *.??s file
2860 my @syncodeindexes = ();
2862 my $texi = new IO::File ("< $filename");
2865 &am_error ("couldn't open `$filename': $!");
2868 print "$me: reading $filename\n" if $verbose;
2870 my ($outfile, $vfile);
2871 while ($_ = $texi->getline)
2873 if (/^\@setfilename +(\S+)/)
2876 if ($outfile =~ /\.(.+)$/ && $1 ne 'info')
2878 &am_file_error ($filename, "$.: ",
2879 "output `$outfile' has unrecognized extension");
2883 # A "version.texi" file is actually any file whose name
2884 # matches "vers*.texi".
2885 elsif (/^\@include\s+(vers[^.]*\.texi)\s*$/)
2890 # Try to find what are the indexes which are used.
2892 # Creating a new category of index.
2893 elsif (/^\@def(code)?index (\w+)/)
2895 push @clean_suffixes, $2;
2898 # Storing in a predefined index.
2899 elsif (/^\@([cfkvtp])index /)
2901 push @clean_suffixes, $predefined_index{$1};
2903 elsif (/^\@def(\w+) /)
2905 push @clean_suffixes, $hidden_index{$1}
2906 if defined $hidden_index{$1};
2909 # Merging an index into an another.
2910 elsif (/^\@syn(code)?index (\w+) \w+/)
2912 push @syncodeindexes, "$2s";
2920 &am_error ("`$filename' missing \@setfilename");
2924 my $infobase = basename ($filename);
2925 $infobase =~ s/\.te?xi(nfo)?$//;
2927 grep { $clean_files{"$infobase.$_"} = 1 } @clean_suffixes;
2928 grep { delete $clean_files{"$infobase.$_"} } @syncodeindexes;
2929 return ($outfile, $vfile, (sort keys %clean_files));
2935 # Handle all Texinfo source.
2938 &am_line_error ('TEXINFOS',
2939 "`TEXINFOS' is an anachronism; use `info_TEXINFOS'")
2940 if &variable_defined ('TEXINFOS');
2941 return if (! &variable_defined ('info_TEXINFOS')
2942 && ! &variable_defined ('html_TEXINFOS'));
2944 if (&variable_defined ('html_TEXINFOS'))
2946 &am_line_error ('html_TEXINFOS',
2947 "HTML generation not yet supported");
2951 my @texis = &variable_value_as_list ('info_TEXINFOS', 'all');
2953 my (@info_deps_list, @dvis_list, @texi_deps);
2960 foreach my $info_cursor (@texis)
2962 my $infobase = $info_cursor;
2963 $infobase =~ s/\.(txi|texinfo|texi)$//;
2965 if ($infobase eq $info_cursor)
2967 # FIXME: report line number.
2968 &am_error ("texinfo file `$info_cursor' has unrecognized extension");
2971 $texi_suffixes{$1} = 1;
2973 # If 'version.texi' is referenced by input file, then include
2974 # automatic versioning capability.
2975 my ($out_file, $vtexi, @clean_files) =
2976 &scan_texinfo_file ("$relative_dir/$info_cursor")
2978 push (@texi_cleans, @clean_files);
2982 &am_error ("`$vtexi', included in `$info_cursor', also included in `$versions{$vtexi}'")
2983 if (defined $versions{$vtexi});
2984 $versions{$vtexi} = $info_cursor;
2986 # We number the stamp-vti files. This is doable since the
2987 # actual names don't matter much. We only number starting
2988 # with the second one, so that the common case looks nice.
2989 my $vti = ($done ? $done : 'vti');
2992 &require_conf_file_with_line ('info_TEXINFOS', $FOREIGN,
2996 if ($config_aux_dir eq '.' || $config_aux_dir eq '')
2998 $conf_dir = '$(srcdir)/';
3002 $conf_dir = $config_aux_dir;
3003 $conf_dir .= '/' unless $conf_dir =~ /\/$/;
3005 $output_rules .= &file_contents ('texi-vers',
3006 ('TEXI' => $info_cursor,
3009 'MDDIR' => $conf_dir));
3012 # If user specified file_TEXINFOS, then use that as explicit
3015 push (@texi_deps, $info_cursor);
3016 # Prefix with $(srcdir) because some version of make won't
3017 # work if the target has it and the dependency doesn't.
3018 push (@texi_deps, '$(srcdir)/' . $vtexi) if $vtexi;
3020 my $canonical = &canonicalize ($infobase);
3021 if (&variable_defined ($canonical . "_TEXINFOS"))
3023 push (@texi_deps, '$(' . $canonical . '_TEXINFOS)');
3024 &push_dist_common ('$(' . $canonical . '_TEXINFOS)');
3027 $output_rules .= ("\n" . $out_file . ": "
3028 . join (' ', @texi_deps)
3029 . "\n" . $infobase . ".dvi: "
3030 . join (' ', @texi_deps)
3033 push (@info_deps_list, $out_file);
3034 push (@dvis_list, $infobase . '.dvi');
3037 # Handle location of texinfo.tex.
3038 my $need_texi_file = 0;
3042 $texinfodir = '$(top_srcdir)/../texinfo';
3043 &define_variable ('TEXINFO_TEX', "$texinfodir/texinfo.tex");
3046 elsif ($config_aux_dir ne '.' && $config_aux_dir ne '')
3048 $texinfodir = $config_aux_dir;
3049 &define_variable ('TEXINFO_TEX', "$texinfodir/texinfo.tex");
3050 $need_texi_file = 2; # so that we require_conf_file later
3052 elsif (&variable_defined ('TEXINFO_TEX'))
3054 # The user defined TEXINFO_TEX so assume he knows what he is
3056 $texinfodir = ('$(srcdir)/'
3057 . dirname (&variable_value ('TEXINFO_TEX')));
3061 $texinfodir = '$(srcdir)';
3062 $need_texi_file = 1;
3065 foreach my $txsfx (sort keys %texi_suffixes)
3067 $output_rules .= &file_contents ('texibuild',
3068 ('TEXINFODIR' => $texinfodir,
3069 'SUFFIX' => $txsfx));
3072 my $texiclean = &pretty_print_internal ("", "\t ", @texi_cleans);
3073 $output_rules .= &file_contents ('texinfos',
3074 ('TEXICLEAN' => $texiclean));
3076 push (@dist_targets, 'dist-info');
3078 if (! defined $options{'no-installinfo'})
3080 # Make sure documentation is made and installed first. Use
3081 # $(INFO_DEPS), not 'info', because otherwise recursive makes
3082 # get run twice during "make all".
3083 unshift (@all, '$(INFO_DEPS)');
3086 &define_variable ("INFO_DEPS", join (' ', @info_deps_list));
3087 &define_variable ("DVIS", join (' ', @dvis_list));
3088 # This next isn't strictly needed now -- the places that look here
3089 # could easily be changed to look in info_TEXINFOS. But this is
3090 # probably better, in case noinst_TEXINFOS is ever supported.
3091 &define_variable ("TEXINFOS", &variable_value ('info_TEXINFOS'));
3093 # Do some error checking. Note that this file is not required
3094 # when in Cygnus mode; instead we defined TEXINFO_TEX explicitly
3096 if ($need_texi_file && ! defined $options{'no-texinfo.tex'})
3098 if ($need_texi_file > 1)
3100 &require_conf_file_with_line ('info_TEXINFOS', $FOREIGN,
3105 &require_file_with_line ('info_TEXINFOS', $FOREIGN, 'texinfo.tex');
3110 # Handle any man pages.
3111 sub handle_man_pages
3113 &am_line_error ('MANS', "`MANS' is an anachronism; use `man_MANS'")
3114 if &variable_defined ('MANS');
3116 # Find all the sections in use. We do this by first looking for
3117 # "standard" sections, and then looking for any additional
3118 # sections used in man_MANS.
3119 my (%sections, %vlist);
3120 # We handle nodist_ for uniformity. man pages aren't distributed
3121 # by default so it isn't actually very important.
3122 foreach my $pfx ('', 'dist_', 'nodist_')
3124 # Add more sections as needed.
3125 foreach my $section ('0'..'9', 'n', 'l')
3127 if (&variable_defined ($pfx . 'man' . $section . '_MANS'))
3129 $sections{$section} = 1;
3130 $vlist{'$(' . $pfx . 'man' . $section . '_MANS)'} = 1;
3132 &push_dist_common ('$(' . $pfx . 'man' . $section . '_MANS)')
3137 if (&variable_defined ($pfx . 'man_MANS'))
3139 $vlist{'$(' . $pfx . 'man_MANS)'} = 1;
3140 foreach (&variable_value_as_list ($pfx . 'man_MANS', 'all'))
3142 # A page like `foo.1c' goes into man1dir.
3143 if (/\.([0-9a-z])([a-z]*)$/)
3149 &push_dist_common ('$(' . $pfx . 'man_MANS)')
3154 return unless %sections;
3156 # Now for each section, generate an install and unintall rule.
3157 # Sort sections so output is deterministic.
3158 foreach my $section (sort keys %sections)
3160 $output_rules .= &file_contents ('mans', ('SECTION' => $section));
3163 $output_vars .= &file_contents ('mans-vars',
3164 ('MANS' => join (' ', sort keys %vlist)));
3166 if (! defined $options{'no-installman'})
3168 push (@all, '$(MANS)');
3172 # Handle DATA variables.
3175 &am_install_var ('-noextra', '-candist', 'data', 'DATA',
3176 'data', 'sysconf', 'sharedstate', 'localstate',
3177 'pkgdata', 'noinst', 'check');
3184 if (&variable_defined ('SUBDIRS'))
3186 $output_rules .= ("tags-recursive:\n"
3187 . "\tlist=\'\$(SUBDIRS)\'; for subdir in \$\$list; do \\\n"
3188 # Never fail here if a subdir fails; it
3190 . "\t test \"\$\$subdir\" = . || (cd \$\$subdir"
3191 . " && \$(MAKE) \$(AM_MAKEFLAGS) tags); \\\n"
3193 push (@tag_deps, 'tags-recursive');
3194 &depend ('.PHONY', 'tags-recursive');
3197 if (&saw_sources_p (1)
3198 || &variable_defined ('ETAGS_ARGS')
3202 foreach my $one_hdr (@config_headers)
3204 if ($relative_dir eq dirname ($one_hdr))
3206 # The config header is in this directory. So require it.
3207 $config .= ' ' if $config;
3208 $config .= basename ($one_hdr);
3211 $output_rules .= &file_contents ('tags',
3212 ('CONFIG' => $config,
3213 'DIRS' => join (' ', @tag_deps)));
3214 &examine_variable ('TAGS_DEPENDENCIES');
3216 elsif (&variable_defined ('TAGS_DEPENDENCIES'))
3218 &am_line_error ('TAGS_DEPENDENCIES',
3219 "doesn't make sense to define `TAGS_DEPENDENCIES' without sources or `ETAGS_ARGS'");
3223 # Every Makefile must define some sort of TAGS rule.
3224 # Otherwise, it would be possible for a top-level "make TAGS"
3225 # to fail because some subdirectory failed.
3226 $output_rules .= "tags: TAGS\nTAGS:\n\n";
3230 # Handle multilib support.
3233 return unless $seen_multilib;
3235 $output_rules .= &file_contents ('multilib');
3240 # &for_dist_common ($A, $B)
3241 # -------------------------
3242 # Subroutine for &handle_dist: sort files to dist.
3244 # We put README first because it then becomes easier to make a
3245 # Usenet-compliant shar file (in these, README must be first).
3247 # FIXME: do more ordering of files here.
3260 # handle_dist ($MAKEFILE)
3261 # -----------------------
3262 # Handle 'dist' target.
3265 my ($makefile) = @_;
3267 # `make dist' isn't used in a Cygnus-style tree.
3268 # Omit the rules so that people don't try to use them.
3269 return if $cygnus_mode;
3271 # Set up maint_charset.
3272 $local_maint_charset = &variable_value ('MAINT_CHARSET')
3273 if &variable_defined ('MAINT_CHARSET');
3274 $maint_charset = $local_maint_charset
3275 if $relative_dir eq '.';
3277 if (&variable_defined ('DIST_CHARSET'))
3279 &am_line_error ('DIST_CHARSET',
3280 "DIST_CHARSET defined but no MAINT_CHARSET defined")
3281 if ! $local_maint_charset;
3282 if ($relative_dir eq '.')
3284 $dist_charset = &variable_value ('DIST_CHARSET')
3288 &am_line_error ('DIST_CHARSET',
3289 "DIST_CHARSET can only be defined at top level");
3293 # Look for common files that should be included in distribution.
3294 foreach my $cfile (@common_files)
3296 if (-f ($relative_dir . "/" . $cfile))
3298 &push_dist_common ($cfile);
3302 # We might copy elements from $configure_dist_common to
3303 # %dist_common if we think we need to. If the file appears in our
3304 # directory, we would have discovered it already, so we don't
3305 # check that. But if the file is in a subdir without a Makefile,
3306 # we want to distribute it here if we are doing `.'. Ugly!
3307 if ($relative_dir eq '.')
3309 foreach my $file (split (' ' , $configure_dist_common))
3311 if (! &is_make_dir (dirname ($file)))
3313 &push_dist_common ($file);
3320 # Files to distributed. Don't use &variable_value_as_list
3321 # as it recursively expands `$(dist_pkgdata_DATA)' etc.
3322 check_variable_defined_unconditionally ('DIST_COMMON');
3323 my @dist_common = split (' ', variable_value ('DIST_COMMON', 'TRUE'));
3324 @dist_common = uniq (sort for_dist_common (@dist_common));
3325 pretty_print ('DIST_COMMON = ', "\t", @dist_common);
3327 # Now that we've processed DIST_COMMON, disallow further attempts
3329 $handle_dist_run = 1;
3331 # Scan EXTRA_DIST to see if we need to distribute anything from a
3332 # subdir. If so, add it to the list. I didn't want to do this
3333 # originally, but there were so many requests that I finally
3335 if (&variable_defined ('EXTRA_DIST'))
3337 # FIXME: This should be fixed to work with conditionals. That
3338 # will require only making the entries in %dist_dirs under the
3339 # appropriate condition. This is meaningful if the nature of
3340 # the distribution should depend upon the configure options
3342 foreach (&variable_value_as_list ('EXTRA_DIST', ''))
3345 next unless s,/+[^/]+$,,;
3351 # We have to check DIST_COMMON for extra directories in case the
3352 # user put a source used in AC_OUTPUT into a subdir.
3353 foreach (&variable_value_as_list ('DIST_COMMON', 'all'))
3356 next unless s,/+[^/]+$,,;
3361 # Rule to check whether a distribution is viable.
3362 my %transform = ('DISTCHECK-HOOK' => &target_defined ('distcheck-hook'),
3363 'GETTEXT' => $seen_gettext);
3365 # Prepend $(distdir) to each directory given.
3367 grep ($rewritten{'$(distdir)/' . $_} = 1, keys %dist_dirs);
3368 $transform{'DISTDIRS'} = join (' ', sort keys %rewritten);
3370 # If we have SUBDIRS, create all dist subdirectories and do
3372 if (&variable_defined ('SUBDIRS'))
3374 # If SUBDIRS is conditionally defined, then set DIST_SUBDIRS
3375 # to all possible directories, and use it. If DIST_SUBDIRS is
3376 # defined, just use it.
3377 my $dist_subdir_name;
3378 # Note that we check DIST_SUBDIRS first on purpose. At least
3379 # one project uses so many conditional subdirectories that
3380 # calling variable_conditionally_defined on SUBDIRS will cause
3381 # automake to grow to 150Mb. Sigh.
3382 if (&variable_defined ('DIST_SUBDIRS')
3383 || variable_conditionally_defined ('SUBDIRS'))
3385 $dist_subdir_name = 'DIST_SUBDIRS';
3386 if (! &variable_defined ('DIST_SUBDIRS'))
3388 &define_pretty_variable
3389 ('DIST_SUBDIRS', '',
3390 uniq (&variable_value_as_list ('SUBDIRS', 'all')));
3395 $dist_subdir_name = 'SUBDIRS';
3396 # We always define this because that is what `distclean'
3398 &define_pretty_variable ('DIST_SUBDIRS', '', '$(SUBDIRS)');
3401 $transform{'DIST_SUBDIR_NAME'} = $dist_subdir_name;
3404 # If the target `dist-hook' exists, make sure it is run. This
3405 # allows users to do random weird things to the distribution
3406 # before it is packaged up.
3407 push (@dist_targets, 'dist-hook')
3408 if &target_defined ('dist-hook');
3409 $transform{'DIST-TARGETS'} = join(' ', @dist_targets);
3411 # Defining $(DISTDIR).
3412 $transform{'DISTDIR'} = !&variable_defined('distdir');
3413 $transform{'TOP_DISTDIR'} = backname ($relative_dir);
3415 $output_rules .= &file_contents ('distdir', %transform);
3419 # Handle auto-dependency code.
3420 sub handle_dependencies
3422 if ($use_dependencies)
3424 # Include auto-dep code. Don't include it if DEP_FILES would
3426 if (&saw_sources_p (0) && keys %dep_files)
3428 my $config_aux_dir_specified = ($config_aux_dir ne '.'
3429 && $config_aux_dir ne '');
3431 # Set $require_file_found{'depcomp'} if the depcomp file exists,
3432 # before calling require_config_file on `depcomp'. This makes
3433 # require_file_internal skip its buggy existence test that would
3434 # make automake fail (with `required file `lib/depcomp' not found')
3435 # when AC_CONFIG_AUX_DIR is not set. See tests/subdir4.test.
3436 my $depcomp_dir = ($config_aux_dir_specified ? $config_aux_dir
3438 $require_file_found{'depcomp'} = 1 if -f "$depcomp_dir/depcomp";
3440 # Set location of depcomp.
3441 my $prefix = ($config_aux_dir_specified ? $config_aux_dir
3444 &define_variable ('depcomp', "\$(SHELL) $prefix/depcomp");
3446 &require_config_file ($FOREIGN, 'depcomp');
3448 my @deplist = sort keys %dep_files;
3450 # We define this as a conditional variable because BSD
3451 # make can't handle backslashes for continuing comments on
3452 # the following line.
3453 &define_pretty_variable ('DEP_FILES', 'AMDEP_TRUE', @deplist);
3455 # Generate each `include' individually. Irix 6 make will
3456 # not properly include several files resulting from a
3457 # variable expansion; generating many separate includes
3459 $output_rules .= "\n";
3460 foreach my $iter (@deplist)
3462 # The strange concatentation is used to avoid
3463 # substitutions from our own configure.
3464 $output_rules .= ('@AMDEP' . '_TRUE@@_am_include@ @_am_quote@'
3465 . $iter . '@_am_quote@' . "\n");
3468 $output_rules .= &file_contents ('depend');
3473 &define_variable ('depcomp', '');
3476 foreach my $lang (values %languages)
3478 if ($lang->autodep ne 'no')
3480 add_depend2 ($lang);
3485 # Handle subdirectories.
3489 unless &variable_defined ('SUBDIRS');
3491 # Make sure each directory mentioned in SUBDIRS actually exists.
3492 foreach my $dir (&variable_value_as_list ('SUBDIRS', 'all'))
3494 # Skip directories substituted by configure.
3495 next if $dir =~ /^\@.*\@$/;
3497 if (! -d $am_relative_dir . '/' . $dir)
3499 &am_line_error ('SUBDIRS',
3500 "required directory $am_relative_dir/$dir does not exist");
3504 &am_line_error ('SUBDIRS', "directory should not contain `/'")
3508 $output_rules .= &file_contents ('subdirs');
3509 variable_pretty_output ('RECURSIVE_TARGETS', 'TRUE');
3513 # ($REGEN, @DEPENDENCIES)
3516 # If aclocal.m4 creation is automated, return the list of its dependencies.
3519 my $regen_aclocal = 0;
3522 unless $relative_dir eq '.';
3524 &examine_variable ('CONFIG_STATUS_DEPENDENCIES');
3525 &examine_variable ('CONFIGURE_DEPENDENCIES');
3527 if (-f 'aclocal.m4')
3529 &define_variable ("ACLOCAL_M4", '$(top_srcdir)/aclocal.m4');
3530 &push_dist_common ('aclocal.m4');
3532 my $aclocal = new IO::File ("< aclocal.m4");
3535 my $line = $aclocal->getline;
3538 if ($line =~ 'generated automatically by aclocal')
3547 if (-f 'acinclude.m4')
3550 push @ac_deps, 'acinclude.m4';
3553 if (&variable_defined ('ACLOCAL_M4_SOURCES'))
3555 push (@ac_deps, '$(ACLOCAL_M4_SOURCES)');
3557 elsif (&variable_defined ('ACLOCAL_AMFLAGS'))
3559 # Scan all -I directories for m4 files. These are our
3561 my $examine_next = 0;
3562 foreach my $amdir (&variable_value_as_list ('ACLOCAL_AMFLAGS', ''))
3567 if ($amdir !~ /^\// && -d $amdir)
3569 foreach my $ac_dep (&my_glob ($amdir . '/*.m4'))
3571 $ac_dep =~ s/^\.\/+//;
3572 push (@ac_deps, $ac_dep)
3573 unless $ac_dep eq "aclocal.m4"
3574 || $ac_dep eq "acinclude.m4";
3578 elsif ($amdir eq '-I')
3585 # Note that it might be possible that aclocal.m4 doesn't exist but
3586 # should be auto-generated. This case probably isn't very
3589 return ($regen_aclocal, @ac_deps);
3592 # Rewrite a list of input files into a form suitable to put on a
3593 # dependency list. The idea is that if an input file has a directory
3594 # part the same as the current directory, then the directory part is
3595 # simply removed. But if the directory part is different, then
3596 # $(top_srcdir) is prepended. Among other things, this is used to
3597 # generate the dependency list for the output files generated by
3598 # AC_OUTPUT. Consider what the dependencies should look like in this
3600 # AC_OUTPUT(src/out:src/in1:lib/in2)
3601 # The first argument, ADD_SRCDIR, is 1 if $(top_srcdir) should be added.
3602 # If 0 then files that require this addition will simply be ignored.
3603 sub rewrite_inputs_into_dependencies
3605 my ($add_srcdir, @inputs) = @_;
3608 foreach my $single (@inputs)
3610 if (dirname ($single) eq $relative_dir)
3612 push (@newinputs, basename ($single));
3616 push (@newinputs, '$(top_srcdir)/' . $single);
3623 # Handle remaking and configure stuff.
3624 # We need the name of the input file, to do proper remaking rules.
3625 sub handle_configure
3627 my ($local, $input, @secondary_inputs) = @_;
3629 my $input_base = basename ($input);
3630 my $local_base = basename ($local);
3632 my $amfile = $input_base . '.am';
3633 # We know we can always add '.in' because it really should be an
3634 # error if the .in was missing originally.
3635 my $infile = '$(srcdir)/' . $input_base . '.in';
3636 my $colon_infile = '';
3637 if ($local ne $input || @secondary_inputs)
3639 $colon_infile = ':' . $input . '.in';
3641 $colon_infile .= ':' . join (':', @secondary_inputs)
3642 if @secondary_inputs;
3644 my @rewritten = &rewrite_inputs_into_dependencies (1, @secondary_inputs);
3646 my ($regen_aclocal_m4, @aclocal_m4_deps) = scan_aclocal_m4 ();
3649 &file_contents ('configure',
3653 => join (' ', @rewritten),
3655 => ((($relative_dir eq '.') ? '$@' : '$(subdir)/$@')
3660 => join (' ', @include_stack),
3664 => $cygnus_mode ? 'cygnus' : $strictness_name,
3666 => $cmdline_use_dependencies ? '' : ' --ignore-deps',
3667 'MAKEFILE-AM-SOURCES'
3668 => "$input$colon_infile",
3670 => $regen_aclocal_m4,
3672 => join (' ', @aclocal_m4_deps)));
3674 if ($relative_dir eq '.')
3676 &push_dist_common ('acconfig.h')
3680 # If we have a configure header, require it.
3681 my @local_fullnames = @config_fullnames;
3682 my @local_names = @config_names;
3684 my $distclean_config = '';
3685 foreach my $one_hdr (@config_headers)
3687 my $one_fullname = shift (@local_fullnames);
3688 my $one_name = shift (@local_names);
3690 my $header_dir = dirname ($one_name);
3692 # If the header is in the current directory we want to build
3693 # the header here. Otherwise, if we're at the topmost
3694 # directory and the header's directory doesn't have a
3695 # Makefile, then we also want to build the header.
3696 if ($relative_dir eq $header_dir
3697 || ($relative_dir eq '.' && ! &is_make_dir ($header_dir)))
3699 my ($cn_sans_dir, $stamp_dir);
3700 if ($relative_dir eq $header_dir)
3702 $cn_sans_dir = basename ($one_name);
3707 $cn_sans_dir = $one_name;
3708 if ($header_dir eq '.')
3714 $stamp_dir = $header_dir . '/';
3718 # Compute relative path from directory holding output
3719 # header to directory holding input header. FIXME:
3720 # doesn't handle case where we have multiple inputs.
3722 if (dirname ($one_hdr) eq $relative_dir)
3724 $ch_sans_dir = basename ($one_hdr);
3728 $ch_sans_dir = backname ($relative_dir) . '/' . $one_hdr;
3731 &require_file_with_conf_line ($config_header_line,
3732 $FOREIGN, $ch_sans_dir);
3734 # Header defined and in this directory.
3736 if (-f $one_name . '.top')
3738 push (@files, "${cn_sans_dir}.top");
3740 if (-f $one_name . '.bot')
3742 push (@files, "${cn_sans_dir}.bot");
3745 &push_dist_common (@files);
3747 # For now, acconfig.h can only appear in the top srcdir.
3748 if (-f 'acconfig.h')
3750 push (@files, '$(top_srcdir)/acconfig.h');
3753 my $stamp_name = 'stamp-h';
3754 $stamp_name .= "${hdr_index}" if scalar (@config_headers) > 1;
3756 my $out_dir = dirname ($ch_sans_dir);
3759 &file_contents ('remake-hdr',
3760 ('FILES' => join (' ', @files),
3761 'CONFIG_HEADER' => $cn_sans_dir,
3762 'CONFIG_HEADER_IN' => $ch_sans_dir,
3763 'CONFIG_HEADER_FULL' => $one_fullname,
3764 'STAMP' => "$stamp_dir$stamp_name",
3765 'SRC_STAMP' => "$out_dir/$stamp_name"));
3767 &create ("${relative_dir}/${out_dir}/${stamp_name}.in");
3768 &require_file_with_conf_line ($config_header_line, $FOREIGN,
3769 "${out_dir}/${stamp_name}.in");
3771 $distclean_config .= ' ' if $distclean_config;
3772 $distclean_config .= $cn_sans_dir;
3776 if ($distclean_config)
3778 $output_rules .= &file_contents ('clean-hdr',
3779 ('FILES' => $distclean_config));
3782 # Set location of mkinstalldirs.
3783 if ($config_aux_dir ne '.' && $config_aux_dir ne '')
3785 &define_variable ('mkinstalldirs', ('$(SHELL) ' . $config_aux_dir
3786 . '/mkinstalldirs'));
3790 &define_variable ('mkinstalldirs',
3791 '$(SHELL) $(top_srcdir)/mkinstalldirs');
3794 &am_line_error ('CONFIG_HEADER',
3795 "`CONFIG_HEADER' is an anachronism; now determined from `$configure_ac'")
3796 if &variable_defined ('CONFIG_HEADER');
3798 my $config_header = '';
3799 foreach my $one_name (@config_names)
3801 # Generate CONFIG_HEADER define.
3803 if ($relative_dir eq dirname ($one_name))
3805 $one_hdr = basename ($one_name);
3809 $one_hdr = "\$(top_builddir)/${one_name}";
3812 $config_header .= ' ' if $config_header;
3813 $config_header .= $one_hdr;
3817 &define_variable ("CONFIG_HEADER", $config_header);
3820 # Now look for other files in this directory which must be remade
3821 # by config.status, and generate rules for them.
3822 my @actual_other_files = ();
3823 foreach my $lfile (@other_input_files)
3826 my (@inputs, @rewritten_inputs);
3827 my ($need_rewritten);
3828 if ($lfile =~ /^([^:]*):(.*)$/)
3830 # This is the ":" syntax of AC_OUTPUT.
3832 $local = basename ($file);
3833 @inputs = split (':', $2);
3834 @rewritten_inputs = &rewrite_inputs_into_dependencies (1, @inputs);
3835 $need_rewritten = 1;
3841 $local = basename ($file);
3842 @inputs = ($file . '.in');
3844 &rewrite_inputs_into_dependencies (1, @inputs);
3845 $need_rewritten = 0;
3848 # Make sure the dist directory for each input file is created.
3849 # We only have to do this at the topmost level though. This
3850 # is a bit ugly but it easier than spreading out the logic,
3851 # especially in cases like AC_OUTPUT(foo/out:bar/in), where
3852 # there is no Makefile in bar/.
3853 if ($relative_dir eq '.')
3857 $dist_dirs{dirname ($_)} = 1;
3861 # We skip any automake input files, as they are handled
3862 # elsewhere. We also skip files that aren't in this
3863 # directory. However, if the file's directory does not have a
3864 # Makefile, and we are currently doing `.', then we create a
3865 # rule to rebuild the file in the subdir.
3866 next if -f $file . '.am';
3867 my $fd = dirname ($file);
3868 if ($fd ne $relative_dir)
3870 if ($relative_dir eq '.' && ! &is_make_dir ($fd))
3880 # Some users have been tempted to put `stamp-h' in the
3881 # AC_OUTPUT line. This won't do the right thing, so we
3882 # explicitly fail here.
3883 if ($local eq 'stamp-h')
3885 # FIXME: allow real filename.
3886 &am_conf_error ($configure_ac, $ac_output_line,
3887 'stamp-h should not appear in AC_OUTPUT');
3891 $output_rules .= ($local . ': '
3892 . '$(top_builddir)/config.status '
3893 . join (' ', @rewritten_inputs) . "\n"
3895 . 'cd $(top_builddir) && CONFIG_FILES='
3896 . ($relative_dir eq '.' ? '' : '$(subdir)/')
3897 . '$@' . ($need_rewritten
3898 ? (':' . join (':', @inputs))
3900 . ' CONFIG_HEADERS= CONFIG_LINKS= $(SHELL) ./config.status'
3902 push (@actual_other_files, $local);
3904 # Require all input files.
3905 &require_file_with_conf_line ($ac_output_line, $FOREIGN,
3906 &rewrite_inputs_into_dependencies (0, @inputs));
3909 # These files get removed by "make clean".
3910 &define_pretty_variable ('CONFIG_CLEAN_FILES', '', @actual_other_files);
3916 my @r = &am_install_var ('-defaultdist', 'header', 'HEADERS', 'include',
3917 'oldinclude', 'pkginclude',
3921 next unless /\.(.*)$/;
3922 &saw_extension ($1);
3928 return if ! $seen_gettext || $relative_dir ne '.';
3930 if (! &variable_defined ('SUBDIRS'))
3933 ("AM_GNU_GETTEXT used but SUBDIRS not defined");
3937 my @subdirs = &variable_value_as_list ('SUBDIRS', 'all');
3938 &am_line_error ('SUBDIRS',
3939 "AM_GNU_GETTEXT used but `po' not in SUBDIRS")
3940 if ! grep ('po', @subdirs);
3941 &am_line_error ('SUBDIRS',
3942 "AM_GNU_GETTEXT used but `intl' not in SUBDIRS")
3943 if ! grep ('intl', @subdirs);
3945 &require_file_with_conf_line ($ac_gettext_line, $GNU, 'ABOUT-NLS');
3947 # Ensure that each language in ALL_LINGUAS has a .po file, and
3948 # each po file is mentioned in ALL_LINGUAS.
3952 grep ($linguas{$_} = 1, split (' ', $all_linguas));
3959 &am_line_error ($all_linguas_line,
3960 ("po/$_.po exists but `$_' not in `ALL_LINGUAS'"))
3964 foreach (keys %linguas)
3966 &am_line_error ($all_linguas_line,
3967 "$_ in `ALL_LINGUAS' but po/$_.po does not exist")
3973 &am_error ("AM_GNU_GETTEXT in `$configure_ac' but `ALL_LINGUAS' not defined");
3977 # Handle footer elements.
3980 if (variable_value ('SOURCES'))
3982 # NOTE don't use define_pretty_variable here, because
3983 # $contents{...} is already defined.
3984 $output_vars .= 'SOURCES = ' . variable_value ('SOURCES') . "\n";
3986 if (variable_value ('OBJECTS'))
3988 # NOTE don't use define_pretty_variable here, because
3989 # $contents{...} is already defined.
3990 $output_vars .= 'OBJECTS = ' . variable_value ('OBJECTS') . "\n";
3992 if (variable_value ('SOURCES') || variable_value ('OBJECTS'))
3994 $output_vars .= "\n";
3997 if (&target_defined ('.SUFFIXES'))
3999 &am_line_error ('.SUFFIXES',
4000 "use variable `SUFFIXES', not target `.SUFFIXES'");
4003 # Note: AIX 4.1 /bin/make will fail if any suffix rule appears
4004 # before .SUFFIXES. So we make sure that .SUFFIXES appears before
4005 # anything else, by sticking it right after the default: target.
4006 $output_header .= ".SUFFIXES:\n";
4007 if (@suffixes || &variable_defined ('SUFFIXES'))
4009 # Make sure suffixes has unique elements. Sort them to ensure
4010 # the output remains consistent. However, $(SUFFIXES) is
4011 # always at the start of the list, unsorted. This is done
4012 # because make will choose rules depending on the ordering of
4013 # suffixes, and this lets the user have some control. Push
4014 # actual suffixes, and not $(SUFFIXES). Some versions of make
4015 # do not like variable substitutions on the .SUFFIXES line.
4016 my @user_suffixes = (&variable_defined ('SUFFIXES')
4017 ? &variable_value_as_list ('SUFFIXES', '')
4021 grep ($suffixes{$_} = 1, @suffixes);
4022 delete @suffixes{@user_suffixes};
4024 $output_header .= (".SUFFIXES: "
4025 . join (' ', @user_suffixes, sort keys %suffixes)
4028 $output_trailer .= &file_contents ('footer');
4031 # Deal with installdirs target.
4032 sub handle_installdirs ()
4035 &file_contents ('install',
4037 => variable_value ('_am_installdirs') || ''));
4041 # Deal with all and all-am.
4044 my ($makefile) = @_;
4048 # Put this at the beginning for the sake of non-GNU makes. This
4049 # is still wrong if these makes can run parallel jobs. But it is
4051 unshift (@all, basename ($makefile));
4053 foreach my $one_name (@config_names)
4055 push (@all, basename ($one_name))
4056 if dirname ($one_name) eq $relative_dir;
4059 # Install `all' hooks.
4060 if (&target_defined ("all-local"))
4062 push (@all, "all-local");
4063 &depend ('.PHONY', "all-local");
4066 &pretty_print_rule ("all-am:", "\t\t", @all);
4067 &depend ('.PHONY', 'all-am', 'all');
4072 my @local_headers = ();
4073 push @local_headers, '$(BUILT_SOURCES)'
4074 if &variable_defined ('BUILT_SOURCES');
4075 foreach my $one_name (@config_names)
4077 push @local_headers, basename ($one_name)
4078 if dirname ($one_name) eq $relative_dir;
4083 # We need to make sure config.h is built before we recurse.
4084 # We also want to make sure that built sources are built
4085 # before any ordinary `all' targets are run. We can't do this
4086 # by changing the order of dependencies to the "all" because
4087 # that breaks when using parallel makes. Instead we handle
4088 # things explicitly.
4089 $output_all .= ("all: " . join (' ', @local_headers)
4091 . '$(MAKE) $(AM_MAKEFLAGS) '
4092 . (&variable_defined ('SUBDIRS')
4093 ? 'all-recursive' : 'all-am')
4098 $output_all .= "all: " . (&variable_defined ('SUBDIRS')
4099 ? 'all-recursive' : 'all-am') . "\n\n";
4104 # Handle check merge target specially.
4105 sub do_check_merge_target
4107 if (&target_defined ('check-local'))
4109 # User defined local form of target. So include it.
4110 push (@check_tests, 'check-local');
4111 &depend ('.PHONY', 'check-local');
4114 # In --cygnus mode, check doesn't depend on all.
4117 # Just run the local check rules.
4118 &pretty_print_rule ('check-am:', "\t\t", @check);
4122 # The check target must depend on the local equivalent of
4123 # `all', to ensure all the primary targets are built. Then it
4124 # must build the local check rules.
4125 $output_rules .= "check-am: all-am\n";
4126 &pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ",
4130 &pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ",
4134 &depend ('.PHONY', 'check', 'check-am');
4135 $output_rules .= ("check: "
4136 . (&variable_defined ('SUBDIRS')
4137 ? 'check-recursive' : 'check-am')
4141 # Handle all 'clean' targets.
4146 # Don't include `MAINTAINER'; it is handled specially below.
4147 foreach my $name ('MOSTLY', '', 'DIST')
4149 $transform{"${name}CLEAN"} = &variable_defined ("${name}CLEANFILES");
4152 # Built sources are automatically removed by maintainer-clean.
4153 push (@maintainer_clean_files, '$(BUILT_SOURCES)')
4154 if &variable_defined ('BUILT_SOURCES');
4155 push (@maintainer_clean_files, '$(MAINTAINERCLEANFILES)')
4156 if &variable_defined ('MAINTAINERCLEANFILES');
4158 $output_rules .= &file_contents ('clean',
4161 # Join with no space to avoid
4162 # spurious `test -z' success at
4164 => join ('', @maintainer_clean_files),
4166 # A space is required in the join here.
4167 => join (' ', @maintainer_clean_files)));
4171 # &depend ($CATEGORY, @DEPENDENDEES)
4172 # ----------------------------------
4173 # The target $CATEGORY depends on @DEPENDENDEES.
4176 my ($category, @dependendees) = @_;
4178 push (@{$dependencies{$category}}, @dependendees);
4183 # &target_cmp ($A, $B)
4184 # --------------------
4185 # Subroutine for &handle_factored_dependencies to let `.PHONY' be last.
4198 # &handle_factored_dependencies ()
4199 # --------------------------------
4200 # Handle everything related to gathered targets.
4201 sub handle_factored_dependencies
4204 foreach my $utarg ('uninstall-data-local', 'uninstall-data-hook',
4205 'uninstall-exec-local', 'uninstall-exec-hook')
4207 if (&target_defined ($utarg))
4210 $x =~ s/(data|exec)-//;
4211 &am_line_error ($utarg, "use `$x', not `$utarg'");
4215 if (&target_defined ('install-local'))
4217 &am_line_error ('install-local',
4218 "use `install-data-local' or `install-exec-local', "
4219 . "not `install-local'");
4222 if (!defined $options{'no-installinfo'}
4223 && &target_defined ('install-info-local'))
4225 &am_line_error ('install-info-local',
4226 "`install-info-local' target defined but "
4227 . "`no-installinfo' option not in use");
4230 # Install the -local hooks.
4231 foreach (keys %dependencies)
4233 # Hooks are installed on the -am targets.
4235 if (&target_defined ("$_-local"))
4237 depend ("$_-am", "$_-local");
4238 &depend ('.PHONY', "$_-local");
4242 # Install the -hook hooks.
4243 # FIXME: Why not be as liberal as we are with -local hooks?
4244 foreach ('install-exec', 'install-data')
4246 if (&target_defined ("$_-hook"))
4248 $actions{"$_-am"} .=
4249 ("\t\@\$(NORMAL_INSTALL)\n"
4250 . "\t" . '$(MAKE) $(AM_MAKEFLAGS) ' . "$_-hook\n");
4254 # All the required targets are phony.
4255 grep { &depend ('.PHONY', $_) } keys %required_targets;
4257 # Actually output gathered targets.
4258 foreach (sort target_cmp keys %dependencies)
4260 # If there is nothing about this guy, skip it.
4262 unless (@{$dependencies{$_}}
4264 || $required_targets{$_});
4265 &pretty_print_rule ("$_:", "\t",
4266 uniq (sort @{$dependencies{$_}}));
4267 $output_rules .= $actions{$_}
4268 if defined $actions{$_};
4269 $output_rules .= "\n";
4274 # &handle_tests_dejagnu ()
4275 # ------------------------
4276 sub handle_tests_dejagnu
4278 push (@check_tests, 'check-DEJAGNU');
4280 # Only create site.exp rule if user hasn't already written one.
4282 &file_contents ('dejagnu',
4283 ('SITE-EXP' => ! &target_defined ('site.exp'),
4284 'BUILD' => $seen_canonical == $AC_CANONICAL_SYSTEM,
4285 'HOST' => $seen_canonical,
4286 'TARGET' => $seen_canonical == $AC_CANONICAL_SYSTEM));
4290 # Handle TESTS variable and other checks.
4293 if (defined $options{'dejagnu'})
4295 &handle_tests_dejagnu;
4299 foreach my $c ('DEJATOOL', 'RUNTEST', 'RUNTESTFLAGS')
4302 "`$c' defined but `dejagnu' not in `AUTOMAKE_OPTIONS'")
4303 if &variable_defined ($c);
4307 if (&variable_defined ('TESTS'))
4309 push (@check_tests, 'check-TESTS');
4310 $output_rules .= &file_contents ('check');
4314 # Handle Emacs Lisp.
4315 sub handle_emacs_lisp
4317 my @elfiles = &am_install_var ('-candist', 'lisp', 'LISP',
4320 return if ! @elfiles;
4322 # Generate .elc files.
4323 grep ($_ .= 'c', @elfiles);
4324 &define_pretty_variable ('ELCFILES', '', @elfiles);
4326 push (@all, '$(ELCFILES)');
4328 &am_error ("`lisp_LISP' defined but `AM_PATH_LISPDIR' not in `$configure_ac'")
4329 if ! $seen_lispdir && &variable_defined ('lisp_LISP');
4331 &require_file_with_conf_line ('AM_PATH_LISPDIR', $FOREIGN, 'elisp-comp');
4337 my @pyfiles = &am_install_var ('-defaultdist', 'python', 'PYTHON',
4338 'python', 'noinst');
4339 return if ! @pyfiles;
4341 # Found some python.
4342 &am_error ("`python_PYTHON' defined but `AM_CHECK_PYTHON' not in `$configure_ac'")
4343 if ! $seen_pythondir && &variable_defined ('python_PYTHON');
4345 &require_file_with_conf_line ('AM_CHECK_PYTHON', $FOREIGN, 'py_comp');
4351 my @sourcelist = &am_install_var ('-candist',
4353 'java', 'noinst', 'check');
4354 return if ! @sourcelist;
4356 my %valid = &am_primary_prefixes ('JAVA', 1,
4357 'java', 'noinst', 'check');
4360 foreach my $curs (keys %valid)
4362 if (! &variable_defined ($curs . '_JAVA') || $curs eq 'EXTRA')
4369 &am_line_error ($curs . '_JAVA',
4370 "multiple _JAVA primaries in use");
4375 push (@all, 'class' . $dir . '.stamp');
4379 # Handle some of the minor options.
4380 sub handle_minor_options
4382 if (defined $options{'readme-alpha'})
4384 if ($relative_dir eq '.')
4386 if ($package_version !~ /^$GNITS_VERSION_PATTERN$/)
4388 # FIXME: allow real filename.
4389 &am_conf_line_error ($configure_ac,
4390 $package_version_line,
4391 "version `$package_version' doesn't follow Gnits standards");
4393 elsif (defined $1 && -f 'README-alpha')
4395 # This means we have an alpha release. See
4396 # GNITS_VERSION_PATTERN for details.
4397 &require_file ($FOREIGN, 'README-alpha');
4403 ################################################################
4406 my @make_input_list;
4407 # &scan_autoconf_config_files ($CONFIG-FILES)
4408 # -------------------------------------------
4409 # Study $CONFIG-FILES which is the first argument to AC_CONFIG_FILES
4411 sub scan_autoconf_config_files
4413 my ($config_files) = @_;
4414 # Look at potential Makefile.am's.
4415 foreach (split ' ', $config_files)
4417 # Must skip empty string for Perl 4.
4418 next if $_ eq "\\" || $_ eq '';
4420 # Handle $local:$input syntax. Note that we ignore
4421 # every input file past the first, though we keep
4422 # those around for later.
4423 my ($local, $input, @rest) = split (/:/);
4430 # FIXME: should be error if .in is missing.
4431 $input =~ s/\.in$//;
4434 if (-f $input . '.am')
4436 # We have a file that automake should generate.
4437 push (@make_input_list, $input);
4438 $make_list{$input} = join (':', ($local, @rest));
4442 # We have a file that automake should cause to be
4443 # rebuilt, but shouldn't generate itself.
4444 push (@other_input_files, $_);
4450 # &scan_autoconf_traces ($FILENAME)
4451 # ---------------------------------
4452 # FIXME: For the time being, we don't care about the FILENAME.
4453 sub scan_autoconf_traces
4455 my ($filename) = @_;
4457 my $traces = "$ENV{amtraces} ";
4459 $traces .= ' -t AC_CONFIG_FILES';
4460 $traces .= ' -t AC_LIBSOURCE';
4461 $traces .= ' -t AC_SUBST';
4463 my $tracefh = new IO::File ("$traces |");
4466 die "$me: couldn't open `$traces': $!\n";
4468 print "$me: reading $traces\n" if $verbose;
4470 while ($_ = $tracefh->getline)
4473 my ($file, $line, $macro, @args) = split /:/;
4474 my $here = "$file:$line";
4476 # Alphabetical ordering please.
4477 if ($macro eq 'AC_CONFIG_FILES')
4479 # Look at potential Makefile.am's.
4480 &scan_autoconf_config_files ($args[0]);
4482 elsif ($macro eq 'AC_LIBSOURCE')
4484 my $source = "$args[0].c";
4485 # We should actually also `close' the sources: getopt.c
4486 # wants getopt.h etc. But actually it should be done in the
4487 # macro itself, i.e., we have to first fix Autoconf to extend
4488 # _AC_LIBOBJ_DECL and use it the in various macros.
4489 if (!defined $libsources{$source})
4491 print STDERR "traces: discovered $source\n";
4492 $libsources{$source} = $here;
4495 elsif ($macro eq 'AC_SUBST')
4497 if (!defined $configure_vars{$args[0]})
4499 print STDERR "traces: discovered AC_SUBST($args[0])\n";
4500 $configure_vars{$args[0]} = $here;
4506 || die "$me: close: $traces: $!\n";
4510 # &scan_one_autoconf_file ($FILENAME)
4511 # -----------------------------------
4512 # Scan one file for interesting things. Subroutine of
4513 # &scan_autoconf_files.
4514 sub scan_one_autoconf_file
4516 my ($filename) = @_;
4518 my $configfh = new IO::File ("< $filename");
4521 die "$me: couldn't open `$filename': $!\n";
4523 print "$me: reading $filename\n" if $verbose;
4525 my ($in_ac_output, $in_ac_replace) = (0, 0);
4526 while ($_ = $configfh->getline)
4528 # Remove comments from current line.
4532 # Skip macro definitions. Otherwise we might be confused into
4533 # thinking that a macro that was only defined was actually
4537 # Follow includes. This is a weirdness commonly in use at
4538 # Cygnus and hopefully nowhere else.
4539 if (/sinclude\((.*)\)/ && -f $1)
4541 # $_ being local, if we don't preserve it, when coming
4542 # back we will have $_ undefined, which is bad for the
4543 # the rest of this routine.
4544 my $underscore = $_;
4545 &scan_one_autoconf_file ($1);
4549 # Populate libobjs array.
4550 if (/AC_FUNC_ALLOCA/)
4552 $libsources{'alloca.c'} = 1;
4554 elsif (/AC_FUNC_GETLOADAVG/)
4556 $libsources{'getloadavg.c'} = 1;
4558 elsif (/AC_FUNC_MEMCMP/)
4560 $libsources{'memcmp.c'} = 1;
4562 elsif (/AC_STRUCT_ST_BLOCKS/)
4564 $libsources{'fileblocks.c'} = 1;
4566 elsif (/A[CM]_REPLACE_GNU_GETOPT/)
4568 $libsources{'getopt.c'} = 1;
4569 $libsources{'getopt1.c'} = 1;
4571 elsif (/AM_FUNC_STRTOD/)
4573 $libsources{'strtod.c'} = 1;
4575 elsif (/AM_WITH_REGEX/)
4577 $libsources{'rx.c'} = 1;
4578 $libsources{'rx.h'} = 1;
4579 $libsources{'regex.c'} = 1;
4580 $libsources{'regex.h'} = 1;
4582 elsif (/AC_FUNC_MKTIME/)
4584 $libsources{'mktime.c'} = 1;
4586 elsif (/AM_FUNC_ERROR_AT_LINE/)
4588 $libsources{'error.c'} = 1;
4589 $libsources{'error.h'} = 1;
4591 elsif (/AM_FUNC_OBSTACK/)
4593 $libsources{'obstack.c'} = 1;
4594 $libsources{'obstack.h'} = 1;
4596 elsif (/LIBOBJS="(.*)\s+\$LIBOBJS"/
4597 || /LIBOBJS="\$LIBOBJS\s+(.*)"/)
4599 foreach my $libobj_iter (split (' ', $1))
4601 if ($libobj_iter =~ /^(.*)\.o(bj)?$/
4602 || $libobj_iter =~ /^(.*)\.\$ac_objext$/
4603 || $libobj_iter =~ /^(.*)\.\$\{ac_objext\}$/)
4605 $libsources{$1 . '.c'} = 1;
4609 elsif (/AC_LIBOBJ\(([^)]+)\)/)
4611 $libsources{"$1.c"} = 1;
4614 if (! $in_ac_replace && s/AC_REPLACE_FUNCS\s*\(\[?//)
4620 $in_ac_replace = 0 if s/[\]\)].*$//;
4621 # Remove trailing backslash.
4625 # Need to skip empty elements for Perl 4.
4627 $libsources{$_ . '.c'} = 1;
4631 if (/$obsolete_rx/o)
4634 if ($obsolete_macros{$1} ne '')
4636 $hint = '; ' . $obsolete_macros{$1};
4638 &am_conf_line_error ($filename, $., "`$1' is obsolete$hint");
4641 # Process the AC_OUTPUT and AC_CONFIG_FILES macros.
4642 if (! $in_ac_output && s/AC_(OUTPUT|CONFIG_FILES)\s*\(\[?//)
4645 $ac_output_line = $.;
4656 # Look at potential Makefile.am's.
4657 &scan_autoconf_config_files ($_);
4659 if ($closing && @make_input_list == 0 && @other_input_files == 0)
4661 &am_conf_line_error ($filename, $ac_output_line,
4662 "No files mentioned in `AC_OUTPUT'");
4667 if (/$AC_CONFIG_AUX_DIR_PATTERN/o)
4669 @config_aux_path = &unquote_m4_arg ($1);
4672 # Check for ansi2knr.
4673 $am_c_prototypes = 1 if /AM_C_PROTOTYPES/;
4675 # Check for exe extension stuff.
4679 $configure_vars{'EXEEXT'} = $filename . ':' . $.;
4685 $configure_vars{'OBJEXT'} = $filename . ':' . $.;
4688 # Check for `-c -o' code.
4689 $seen_cc_c_o = 1 if /AM_PROG_CC_C_O/;
4691 # Check for NLS support.
4692 if (/AM_GNU_GETTEXT/)
4695 $ac_gettext_line = $.;
4698 # Look for ALL_LINGUAS.
4699 if (/ALL_LINGUAS="(.*)"$/ || /ALL_LINGUAS=(.*)$/)
4703 $all_linguas_line = $.;
4706 # Handle configuration headers. A config header of `[$1]'
4707 # means we are actually scanning AM_CONFIG_HEADER from
4709 if (/A([CM])_CONFIG_HEADERS?\s*\((.*)\)/
4713 ($filename, $., "`automake requires `AM_CONFIG_HEADER', not `AC_CONFIG_HEADER'")
4716 $config_header_line = $.;
4717 foreach my $one_hdr (split (' ', &unquote_m4_arg ($2)))
4719 push (@config_fullnames, $one_hdr);
4720 if ($one_hdr =~ /^([^:]+):(.+)$/)
4722 push (@config_names, $1);
4723 push (@config_headers, $2);
4727 push (@config_names, $one_hdr);
4728 push (@config_headers, $one_hdr . '.in');
4733 # Handle AC_CANONICAL_*. Always allow upgrading to
4734 # AC_CANONICAL_SYSTEM, but never downgrading.
4735 $seen_canonical = $AC_CANONICAL_HOST
4736 if ! $seen_canonical
4737 && (/AC_CANONICAL_HOST/ || /AC_CHECK_TOOL/);
4738 $seen_canonical = $AC_CANONICAL_SYSTEM if /AC_CANONICAL_SYSTEM/;
4740 # If using X, include some extra variable definitions. NOTE
4741 # we don't want to force these into CFLAGS or anything,
4742 # because not all programs will necessarily use X.
4745 foreach my $var ('X_CFLAGS', 'X_LIBS', 'X_EXTRA_LIBS',
4748 $configure_vars{$var} = $filename . ':' . $.
4752 # This macro handles several different things.
4753 if (/$AM_INIT_AUTOMAKE_PATTERN/o)
4755 ($package_version = $1) =~ s/$AM_PACKAGE_VERSION_PATTERN/$1/o;
4756 $package_version_line = $.;
4757 $seen_init_automake = 1;
4762 $configure_vars{'LEX'} = $filename . ':' . $.;
4763 $seen_decl_yytext = 1;
4765 if (/AC_DECL_YYTEXT/ && $filename =~ /configure\.(ac|in)$/)
4767 &am_conf_line_warning ($filename, $., "`AC_DECL_YYTEXT' is covered by `AM_PROG_LEX'");
4769 if (/AC_PROG_LEX/ && $filename =~ /configure\.(ac|in)$/)
4771 &am_conf_line_warning ($filename, $., "automake requires `AM_PROG_LEX', not `AC_PROG_LEX'");
4774 if (/AC_PROG_(F77|YACC|RANLIB|CC|CXXCPP|CXX|LEX|AWK|CPP|LN_S)/)
4776 $configure_vars{$1} = $filename . ':' . $.;
4778 if (/$AC_CHECK_PATTERN/o)
4780 $configure_vars{$3} = $filename . ':' . $.;
4782 if (/$AM_MISSING_PATTERN/o
4786 && $1 ne 'AUTOHEADER'
4787 # AM_INIT_AUTOMAKE is AM_MISSING_PROG'ing MAKEINFO. But
4788 # we handle it elsewhere.
4789 && $1 ne 'MAKEINFO')
4791 $configure_vars{$1} = $filename . ':' . $.;
4794 # Explicitly avoid ANSI2KNR -- we AC_SUBST that in protos.m4,
4795 # but later define it elsewhere. This is pretty hacky. We
4796 # also explicitly avoid INSTALL_SCRIPT and some other
4797 # variables because they are defined in header-vars.am.
4799 if (/$AC_SUBST_PATTERN/o
4801 && $1 ne 'INSTALL_SCRIPT'
4802 && $1 ne 'INSTALL_DATA')
4804 $configure_vars{$1} = $filename . ':' . $.;
4807 $seen_decl_yytext = 1 if /AC_DECL_YYTEXT/;
4808 if (/AM_MAINTAINER_MODE/)
4810 $seen_maint_mode = 1;
4811 $configure_cond{'MAINTAINER_MODE'} = 1;
4814 $seen_lispdir = 1 if /AM_PATH_LISPDIR/;
4816 if (/AM_PATH_PYTHON/)
4818 $seen_pythondir = 1;
4819 $configure_vars{'pythondir'} = $filename . ':' . $.;
4820 $configure_vars{'PYTHON'} = $filename . ':' . $.;
4823 if (/A(C|M)_PROG_LIBTOOL/)
4825 # We're not ready for this yet. People still use a
4826 # libtool with no AC_PROG_LIBTOOL. Once that is the
4827 # dominant version we can reenable this code -- but next
4828 # time by mentioning the macro in %obsolete_macros, both
4829 # here and in aclocal.in.
4831 # if (/AM_PROG_LIBTOOL/)
4833 # &am_conf_line_warning ($filename, $., "`AM_PROG_LIBTOOL' is obsolete, use `AC_PROG_LIBTOOL' instead");
4837 $configure_vars{'LIBTOOL'} = $filename . ':' . $.;
4838 $configure_vars{'RANLIB'} = $filename . ':' . $.;
4839 $configure_vars{'CC'} = $filename . ':' . $.;
4840 # AC_PROG_LIBTOOL runs AC_CANONICAL_HOST. Make sure we
4841 # never downgrade (if we've seen AC_CANONICAL_SYSTEM).
4842 $seen_canonical = $AC_CANONICAL_HOST if ! $seen_canonical;
4845 $seen_multilib = 1 if (/AM_ENABLE_MULTILIB/);
4847 if (/$AM_CONDITIONAL_PATTERN/o)
4849 $configure_cond{$1} = 1;
4852 # Check for Fortran 77 intrinsic and run-time libraries.
4853 if (/AC_F77_LIBRARY_LDFLAGS/)
4855 $configure_vars{'FLIBS'} = $filename . ':' . $.;
4863 # &scan_autoconf_files ()
4864 # -----------------------
4865 # Check whether we use `configure.ac' or `configure.in'.
4866 # Scan it (and possibly `aclocal.m4') for interesting things.
4867 # We must scan aclocal.m4 because there might be AC_SUBSTs and such there.
4868 sub scan_autoconf_files
4870 # Reinitialize libsources here. This isn't really necessary,
4871 # since we currently assume there is only one configure.ac. But
4872 # that won't always be the case.
4875 warn "$me: both `configure.ac' and `configure.in' present:"
4876 . " ignoring `configure.in'\n"
4877 if -f 'configure.ac' && -f 'configure.in';
4878 $configure_ac = 'configure.in'
4879 if -f 'configure.in';
4880 $configure_ac = 'configure.ac'
4881 if -f 'configure.ac';
4882 die "$me: `configure.ac' or `configure.in' is required\n"
4885 &scan_one_autoconf_file ($configure_ac);
4886 &scan_one_autoconf_file ('aclocal.m4')
4889 if (defined $ENV{'amtraces'})
4891 warn '$me: Autoconf traces is an experimental feature';
4892 warn '$me: use at your own risks';
4894 &scan_autoconf_traces ($configure_ac);
4897 # Set input and output files if not specified by user.
4900 @input_files = @make_input_list;
4901 %output_files = %make_list;
4904 @configure_input_files = @make_input_list;
4906 &am_conf_error ("`AM_INIT_AUTOMAKE' must be used")
4907 if ! $seen_init_automake;
4909 # Look for some files we need. Always check for these. This
4910 # check must be done for every run, even those where we are only
4911 # looking at a subdir Makefile. We must set relative_dir so that
4912 # the file-finding machinery works.
4913 # FIXME: Is this broken because it needs dynamic scopes.
4914 # My tests seems to show it's not the case.
4915 $relative_dir = '.';
4916 &require_config_file ($FOREIGN, 'install-sh', 'mkinstalldirs', 'missing');
4917 &am_error ("`install.sh' is an anachronism; use `install-sh' instead")
4918 if -f $config_aux_path[0] . '/install.sh';
4920 &require_config_file ($FOREIGN, 'py-compile')
4923 # Preserve dist_common for later.
4924 $configure_dist_common = variable_value ('DIST_COMMON', 'TRUE');
4927 ################################################################
4929 # Set up for Cygnus mode.
4932 return unless $cygnus_mode;
4934 &set_strictness ('foreign');
4935 $options{'no-installinfo'} = 1;
4936 $options{'no-dependencies'} = 1;
4937 $use_dependencies = 0;
4939 if (! $seen_maint_mode)
4941 &am_conf_error ("`AM_MAINTAINER_MODE' required when --cygnus specified");
4945 # Do any extra checking for GNU standards.
4946 sub check_gnu_standards
4948 if ($relative_dir eq '.')
4950 # In top level (or only) directory.
4951 &require_file ($GNU, 'INSTALL', 'NEWS', 'README', 'COPYING',
4952 'AUTHORS', 'ChangeLog');
4955 if ($strictness >= $GNU
4956 && defined $options{'no-installman'})
4958 &am_line_error ('AUTOMAKE_OPTIONS',
4959 "option `no-installman' disallowed by GNU standards");
4962 if ($strictness >= $GNU
4963 && defined $options{'no-installinfo'})
4965 &am_line_error ('AUTOMAKE_OPTIONS',
4966 "option `no-installinfo' disallowed by GNU standards");
4970 # Do any extra checking for GNITS standards.
4971 sub check_gnits_standards
4973 if ($relative_dir eq '.')
4975 # In top level (or only) directory.
4976 &require_file ($GNITS, 'THANKS');
4980 ################################################################
4982 # Functions to handle files of each language.
4984 # Each `lang_X_rewrite($DIRECTORY, $BASE, $EXT)' function follows a
4985 # simple formula: Return value is $LANG_SUBDIR if the resulting object
4986 # file should be in a subdir if the source file is, $LANG_PROCESS if
4987 # file is to be dealt with, $LANG_IGNORE otherwise.
4989 # Much of the actual processing is handled in
4990 # handle_single_transform_list. These functions exist so that
4991 # auxiliary information can be recorded for a later cleanup pass.
4992 # Note that the calls to these functions are computed, so don't bother
4993 # searching for their precise names in the source.
4995 # This is just a convenience function that can be used to determine
4996 # when a subdir object should be used.
4999 return defined $options{'subdir-objects'} ? $LANG_SUBDIR : $LANG_PROCESS;
5002 # Rewrite a single C source file.
5005 my ($directory, $base, $ext) = @_;
5007 if (defined $options{'ansi2knr'} && $base =~ /_$/)
5009 # FIXME: include line number in error.
5010 &am_error ("C source file `$base.c' would be deleted by ansi2knr rules");
5013 my $r = $LANG_PROCESS;
5014 if (defined $options{'subdir-objects'})
5017 $base = $directory . '/' . $base;
5021 # Only give error once.
5023 # FIXME: line number.
5024 &am_error ("C objects in subdir but `AM_PROG_CC_C_O' not in `$configure_ac'");
5027 &require_file ($FOREIGN, 'compile')
5028 if $relative_dir eq '.';
5031 $de_ansi_files{$base} = 1;
5035 # Rewrite a single C++ source file.
5036 sub lang_cxx_rewrite
5038 return &lang_sub_obj;
5041 # Rewrite a single header file.
5042 sub lang_header_rewrite
5044 # Header files are simply ignored.
5045 return $LANG_IGNORE;
5048 # Rewrite a single yacc file.
5049 sub lang_yacc_rewrite
5051 my ($directory, $base, $ext) = @_;
5053 my $r = &lang_c_rewrite ($directory, $base, $ext);
5055 if ($r == $LANG_SUBDIR)
5057 $pfx = $directory . '/';
5059 $yacc_sources{$pfx . $base . '.' . $ext} = 1;
5061 &saw_extension ('c');
5063 &push_dist_common ($pfx . $base . '.' . $ext);
5067 # Rewrite a single yacc++ file.
5068 sub lang_yaccxx_rewrite
5070 my ($directory, $base, $ext) = @_;
5072 my $r = $LANG_PROCESS;
5074 if (defined $options{'subdir-objects'})
5076 $pfx = $directory . '/';
5079 $yacc_sources{$pfx . $base . '.' . $ext} = 1;
5081 &saw_extension ($ext);
5083 &push_dist_common ($pfx . $base . '.' . $ext);
5087 # Rewrite a single lex file.
5088 sub lang_lex_rewrite
5090 my ($directory, $base, $ext) = @_;
5092 my $r = &lang_c_rewrite ($directory, $base, $ext);
5094 if ($r == $LANG_SUBDIR)
5096 $pfx = $directory . '/';
5098 $lex_sources{$pfx . $base . '.' . $ext} = 1;
5100 &saw_extension ('c');
5102 &push_dist_common ($pfx . $base . '.' . $ext);
5106 # Rewrite a single lex++ file.
5107 sub lang_lexxx_rewrite
5109 my ($directory, $base, $ext) = @_;
5111 my $r = $LANG_PROCESS;
5113 if (defined $options{'subdir-objects'})
5115 $pfx = $directory . '/';
5118 $lex_sources{$pfx . $base . '.' . $ext} = 1;
5120 &saw_extension ($ext);
5122 &push_dist_common ($pfx . $base . '.' . $ext);
5126 # Rewrite a single assembly file.
5127 sub lang_asm_rewrite
5129 return &lang_sub_obj;
5132 # Rewrite a single Fortran 77 file.
5133 sub lang_f77_rewrite
5135 return $LANG_PROCESS;
5138 # Rewrite a single preprocessed Fortran 77 file.
5139 sub lang_ppf77_rewrite
5141 return $LANG_PROCESS;
5144 # Rewrite a single ratfor file.
5145 sub lang_ratfor_rewrite
5147 return $LANG_PROCESS;
5150 # Rewrite a single Objective C file.
5151 sub lang_objc_rewrite
5153 return &lang_sub_obj;
5156 # Rewrite a single Java file.
5157 sub lang_java_rewrite
5159 return $LANG_SUBDIR;
5162 # The lang_X_finish functions are called after all source file
5163 # processing is done. Each should handle defining rules for the
5164 # language, etc. A finish function is only called if a source file of
5165 # the appropriate type has been seen.
5169 # Push all libobjs files onto de_ansi_files. We actually only
5170 # push files which exist in the current directory, and which are
5171 # genuine source files.
5172 foreach my $file (keys %libsources)
5174 if ($file =~ /^(.*)\.[cly]$/ && -f "$relative_dir/$file")
5176 $de_ansi_files{$1} = 1;
5180 if (defined $options{'ansi2knr'} && keys %de_ansi_files)
5182 # Make all _.c files depend on their corresponding .c files.
5184 foreach my $base (sort keys %de_ansi_files)
5186 # Each _.c file must depend on ansi2knr; otherwise it
5187 # might be used in a parallel build before it is built.
5188 # We need to support files in the srcdir and in the build
5189 # dir (because these files might be auto-generated. But
5190 # we can't use $< -- some makes only define $< during a
5192 $output_rules .= ($base . "_.c: $base.c \$(ANSI2KNR)\n\t"
5193 . '$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) '
5194 . '`if test -f $(srcdir)/' . $base . '.c'
5195 . '; then echo $(srcdir)/' . $base . '.c'
5196 . '; else echo ' . $base . '.c; fi` '
5197 . "| sed 's/^# \\([0-9]\\)/#line \\1/' "
5198 . '| $(ANSI2KNR) > ' . $base . "_.c\n");
5199 push (@objects, $base . '_.$(OBJEXT)');
5200 push (@objects, $base . '_.lo')
5204 # Make all _.o (and _.lo) files depend on ansi2knr.
5205 # Use a sneaky little hack to make it print nicely.
5206 &pretty_print_rule ('', '', @objects, ':', '$(ANSI2KNR)');
5209 if (! defined $configure_vars{'CC'})
5211 # FIXME: line number.
5212 &am_error ("C source seen but `CC' not defined in `$configure_ac'");
5216 # This is a helper for both lex and yacc.
5217 sub yacc_lex_finish_helper
5219 return if defined $language_scratch{'lex-yacc-done'};
5220 $language_scratch{'lex-yacc-done'} = 1;
5222 # If there is more than one distinct yacc (resp lex) source file
5223 # in a given directory, then the `ylwrap' program is required to
5224 # allow parallel builds to work correctly. FIXME: for now, no
5226 &require_config_file ($FOREIGN, 'ylwrap');
5227 if ($config_aux_dir ne '.' && $config_aux_dir ne '')
5229 &define_variable ('YLWRAP', $config_aux_dir . "/ylwrap");
5233 &define_variable ('YLWRAP', '$(srcdir)/ylwrap');
5237 sub lang_yacc_finish
5239 return if defined $language_scratch{'yacc-done'};
5240 $language_scratch{'yacc-done'} = 1;
5242 my %seen_suffix = ();
5243 my @yacc_files = sort keys %yacc_sources;
5244 my $yacc_count = scalar (@yacc_files);
5245 foreach my $file (@yacc_files)
5248 &output_yacc_build_rule ($1, $yacc_count > 1)
5249 if ! defined $seen_suffix{$1};
5250 $seen_suffix{$1} = 1;
5252 $file =~ /^(.*)\.(y|yy|y\+\+|yxx|ypp)$/;
5254 my $hname = 'h'; # Always use `.h' for header file.
5258 if ((&variable_defined ('AM_YFLAGS')
5259 && &variable_value ('AM_YFLAGS') =~ /(^|\s)-d(\s|$)/)
5260 || (&variable_defined ('YFLAGS')
5261 && &variable_value ('YFLAGS') =~ /(^|\s)-d(\s|$)/)) {
5262 # Now generate rule to make the header file. This should only
5263 # be generated if `yacc -d' specified.
5264 $output_rules .= "${base}.${hname}: ${base}.${cname}\n";
5266 # If the files are built in the build directory, then we want
5267 # to remove them with `make clean'. If they are in srcdir
5268 # they shouldn't be touched. However, we can't determine this
5269 # statically, and the GNU rules say that yacc/lex output files
5270 # should be removed by maintainer-clean. So that's what we
5272 push (@maintainer_clean_files, "${base}.${hname}");
5274 &push_dist_common ("${base}.${hname}");
5276 push (@maintainer_clean_files, "${base}.${cname}");
5278 $output_rules .= "\n";
5280 if (! defined $configure_vars{'YACC'})
5282 &am_error ("yacc source seen but `YACC' not defined in `$configure_ac'");
5284 if (&variable_defined ('YACCFLAGS'))
5286 &am_line_error ('YACCFLAGS',
5287 "`YACCFLAGS' obsolete; use `YFLAGS' instead");
5290 if ($yacc_count > 1)
5292 &yacc_lex_finish_helper;
5299 return if defined $language_scratch{'lex-done'};
5300 $language_scratch{'lex-done'} = 1;
5302 my %seen_suffix = ();
5303 my $lex_count = scalar (keys %lex_sources);
5304 foreach my $file (sort keys %lex_sources)
5307 &output_lex_build_rule ($1, $lex_count > 1)
5308 if (! defined $seen_suffix{$1});
5309 $seen_suffix{$1} = 1;
5311 # If the files are built in the build directory, then we want
5312 # to remove them with `make clean'. If they are in srcdir
5313 # they shouldn't be touched. However, we can't determine this
5314 # statically, and the GNU rules say that yacc/lex output files
5315 # should be removed by maintainer-clean. So that's what we
5317 $file =~ /^(.*)\.(l|ll|l\+\+|lxx|lpp)$/;
5319 ($cname = $2) =~ tr/l/c/;
5320 push (@maintainer_clean_files, "${1}.${cname}");
5323 if (! defined $configure_vars{'LEX'})
5325 &am_error ("lex source seen but `LEX' not defined in `$configure_ac'");
5327 if (! $seen_decl_yytext)
5329 &am_error ("lex source seen but `AC_DECL_YYTEXT' not in `$configure_ac'");
5334 &yacc_lex_finish_helper;
5339 sub lang_ppf77_finish
5341 # We also handle the case of preprocessing `.F' files into `.f'
5343 $output_rules .= (".F.f:\n"
5344 . "\t\$(F77COMPILE) -F \$<\n");
5347 sub lang_ratfor_finish
5349 # We also handle the case of preprocessing `.r' files into `.f'
5351 $output_rules .= (".r.f:\n"
5352 . "\t\$(RCOMPILE) -F \$<\n");
5356 # Given a hash table of linker names, pick the name that has the most
5357 # precedence. This is lame, but something has to have global
5358 # knowledge in order to eliminate the conflict. Add more linkers as
5365 if defined $linkers{'GCJLINK'};
5367 if defined $linkers{'CXXLINK'};
5369 if defined $linkers{'F77LINK'};
5371 if defined $linkers{'OBJCLINK'};
5375 # Called to indicate that an extension was used.
5379 $extension_seen{$ext} = 1;
5382 # Called to ask whether source files have been seen . If HEADERS is 1,
5383 # headers can be included.
5394 $headers = grep ($extension_seen{$_},
5395 @{$languages{'header'}->extensions});
5398 return scalar keys %extension_seen > $headers;
5402 # register_language (%ATTRIBUTE)
5403 # ------------------------------
5404 # Register a single language.
5405 # Each %ATTRIBUTE is of the form ATTRIBUTE => VALUE.
5406 sub register_language (%)
5412 unless defined $option{'ansi'};
5413 $option{'autodep'} = 'no'
5414 unless defined $option{'autodep'};
5415 $option{'derived_autodep'} = 'no'
5416 unless defined $option{'derived_autodep'};
5417 $option{'linker'} = ''
5418 unless defined $option{'linker'};
5420 my $lang = new Language (%option);
5423 grep ($extension_map{$_} = $lang->name, @{$lang->extensions});
5424 $languages{$lang->name} = $lang;
5427 # This function is used to find a path from a user-specified suffix to
5428 # `o' or to some other suffix we recognize internally, eg `cc'.
5431 my ($source_ext) = @_;
5433 # FIXME: hard-coding `o' is a mistake. Doing something
5434 # intelligent is harder.
5435 while ($extension_map{$source_ext} eq ''
5436 && $source_ext ne 'o'
5437 && defined $suffix_rules{$source_ext})
5439 $source_ext = $suffix_rules{$source_ext};
5446 ################################################################
5448 # Pretty-print something. HEAD is what should be printed at the
5449 # beginning of the first line, FILL is what should be printed at the
5450 # beginning of every subsequent line.
5451 sub pretty_print_internal
5453 my ($head, $fill, @values) = @_;
5455 my $column = length ($head);
5458 # Fill length is number of characters. However, each Tab
5459 # character counts for eight. So we count the number of Tabs and
5461 my $fill_length = length ($fill);
5462 $fill_length += 7 * ($fill =~ tr/\t/\t/d);
5466 # "71" because we also print a space.
5467 if ($column + length ($_) > 71)
5469 $result .= " \\\n" . $fill;
5470 $column = $fill_length;
5472 $result .= ' ' if $result =~ /\S\z/;
5474 $column += length ($_) + 1;
5481 # Pretty-print something and append to output_vars.
5484 $output_vars .= &pretty_print_internal (@_);
5487 # Pretty-print something and append to output_rules.
5488 sub pretty_print_rule
5490 $output_rules .= &pretty_print_internal (@_);
5494 ################################################################
5498 # &conditional_string(@COND-STACK)
5499 # --------------------------------
5501 sub conditional_string
5505 if (grep (/^FALSE$/, @stack))
5511 return join (' ', uniq sort grep (!/^TRUE$/, @stack));
5517 # &conditional_true_when ($COND, $WHEN)
5518 # -------------------------------------
5519 # See if a conditional is true. Both arguments are conditional
5520 # strings. This returns true if the first conditional is true when
5521 # the second conditional is true.
5522 # For instance with $COND = `BAR FOO', and $WHEN = `BAR BAZ FOO',
5523 # obviously return 1, and 0 when, for instance, $WHEN = `FOO'.
5524 sub conditional_true_when ($$)
5526 my ($cond, $when) = @_;
5528 # Make a hash holding all the values from $WHEN.
5529 my %cond_vals = map { $_ => 1 } split (' ', $when);
5531 # Check each component of $cond, which looks `COND1 COND2'.
5532 foreach my $comp (split (' ', $cond))
5534 # TRUE is always true.
5535 next if $comp eq 'TRUE';
5536 return 0 if ! defined $cond_vals{$comp};
5544 # &conditionals_true_when (@CONDS, @WHENS)
5545 # ----------------------------------------
5546 # Same as above, but true if all the @CONDS are true when *ALL*
5547 # the @WHENS are sufficient.
5549 # If there are no @CONDS, then return true, of course. *BUT*, even if there
5550 # are @CONDS but @WHENS is empty, return true. This is counter intuitive,
5551 # and against all the rules of logic, but is needed by the current code.
5552 # FIXME: Do something saner when the logic of conditionals is understood.
5553 sub conditionals_true_when (@@)
5555 my (@conds, @whens) = @_;
5557 foreach my $cond (@conds)
5559 foreach my $when (@whens)
5562 unless conditional_true_when ($cond, $when);
5571 # condition_negate ($COND)
5572 # ------------------------
5573 sub condition_negate ($)
5577 $cond =~ s/TRUE$/TRUEO/;
5578 $cond =~ s/FALSE$/TRUE/;
5579 $cond =~ s/TRUEO$/FALSE/;
5585 # Compare condition names.
5586 # Issue them in alphabetical order, foo_TRUE before foo_FALSE.
5589 # Be careful we might be comparing `' or `#'.
5590 $a =~ /^(.*)_(TRUE|FALSE)$/;
5591 my ($aname, $abool) = ($1 || '', $2 || '');
5592 $b =~ /^(.*)_(TRUE|FALSE)$/;
5593 my ($bname, $bbool) = ($1 || '', $2 || '');
5594 return ($aname cmp $bname
5595 # Don't bother with IFs, given that TRUE is after FALSE
5596 # just cmp in the reverse order.
5597 || $bbool cmp $abool
5603 # &make_condition (@CONDITIONS)
5604 # -----------------------------
5605 # Transform a list of conditions (themselves can be an internal list
5606 # of conditions, e.g., @CONDITIONS = ('cond1 cond2', 'cond3')) into a
5607 # Make conditional (a pattern for AC_SUBST).
5608 # Correctly returns the empty string when there are no conditions.
5611 my $res = conditional_string (@_);
5613 # There are no conditions.
5619 elsif ($res eq 'FALSE')
5626 $res = '@' . $res . '@';
5635 ## ------------------------------ ##
5636 ## Handling the condition stack. ##
5637 ## ------------------------------ ##
5641 # cond_stack_if ($NEGATE, $COND, $WHERE)
5642 # --------------------------------------
5643 sub cond_stack_if ($$$)
5645 my ($negate, $cond, $where) = @_;
5647 &am_file_error ($where, "$cond does not appear in AM_CONDITIONAL")
5648 if ! $configure_cond{$cond} && $cond !~ /^TRUE|FALSE$/;
5650 $cond = "${cond}_TRUE"
5651 unless $cond =~ /^TRUE|FALSE$/;
5652 $cond = condition_negate ($cond)
5655 push (@cond_stack, $cond);
5657 return conditional_string (@cond_stack);
5662 # cond_stack_else ($NEGATE, $COND, $WHERE)
5663 # ----------------------------------------
5664 sub cond_stack_else ($$$)
5666 my ($negate, $cond, $where) = @_;
5670 &am_file_error ($where, "else without if");
5674 $cond_stack[$#cond_stack] = condition_negate ($cond_stack[$#cond_stack]);
5676 # If $COND is given, check against it.
5679 $cond = "${cond}_TRUE"
5680 unless $cond =~ /^TRUE|FALSE$/;
5681 $cond = condition_negate ($cond)
5684 &am_file_error ($where,
5685 "else reminder ($negate$cond) incompatible with "
5686 . "current conditional: $cond_stack[$#cond_stack]")
5687 if $cond_stack[$#cond_stack] ne $cond;
5690 return conditional_string (@cond_stack);
5695 # cond_stack_endif ($NEGATE, $COND, $WHERE)
5696 # -----------------------------------------
5697 sub cond_stack_endif ($$$)
5699 my ($negate, $cond, $where) = @_;
5704 &am_file_error ($where, "endif without if: $negate$cond");
5709 # If $COND is given, check against it.
5712 $cond = "${cond}_TRUE"
5713 unless $cond =~ /^TRUE|FALSE$/;
5714 $cond = condition_negate ($cond)
5717 &am_file_error ($where,
5718 "endif reminder ($negate$cond) incompatible with "
5719 . "current conditional: $cond_stack[$#cond_stack]")
5720 if $cond_stack[$#cond_stack] ne $cond;
5725 return conditional_string (@cond_stack);
5732 ## ------------------------ ##
5733 ## Handling the variables. ##
5734 ## ------------------------ ##
5737 # check_ambiguous_conditional ($VAR, $COND)
5738 # -----------------------------------------
5739 # Check for an ambiguous conditional. This is called when a variable
5740 # is being defined conditionally. If we already know about a
5741 # definition that is true under the same conditions, then we have an
5743 sub check_ambiguous_conditional ($$)
5745 my ($var, $cond) = @_;
5746 foreach my $vcond (keys %{$var_value{$var}})
5749 if ($vcond eq $cond)
5751 $message = "$var multiply defined in condition $cond";
5753 elsif (&conditional_true_when ($vcond, $cond))
5755 $message = ("$var was already defined in condition $vcond, "
5756 . "which implies condition $cond");
5758 elsif (&conditional_true_when ($cond, $vcond))
5760 $message = ("$var was already defined in condition $vcond, "
5761 . "which is implied by condition $cond");
5765 &am_line_error ($var, $message);
5772 # ¯o_define($VAR, $VAR_IS_AM, $TYPE, $COND, $VALUE, $WHERE)
5773 # -------------------------------------------------------------
5774 # The $VAR can go from Automake to user, but not the converse.
5775 sub macro_define ($$$$$$)
5777 my ($var, $var_is_am, $type, $cond, $value, $where) = @_;
5779 am_file_error ($where, "bad macro name `$var'")
5780 if $var !~ /$MACRO_PATTERN/o;
5784 # An Automake variable must be consistently defined with the same
5785 # sign by Automake. A user variable must be set by either `=' or
5786 # `:=', and later promoted to `+='.
5789 if (defined $var_type{$var} && $var_type{$var} ne $type)
5791 am_line_error ($var,
5792 ("$var was set with `$var_type{$var}=' "
5793 . "and is now set with `$type='"));
5798 if (!defined $var_type{$var} && $type eq '+')
5800 am_line_error ($var, "$var must be set with `=' before using `+='");
5803 $var_type{$var} = $type;
5805 # When adding, since we rewrite, don't try to preserve the
5806 # Automake continuation backslashes.
5808 if $type eq '+' && $var_is_am;
5810 # Differentiate the first assignment (including with `+=').
5811 if ($type eq '+' && defined $var_value{$var}{$cond})
5813 if (substr ($var_value{$var}{$cond}, -1) eq "\n")
5815 # Insert a backslash before a trailing newline.
5816 $var_value{$var}{$cond} =
5817 substr ($var_value{$var}{$cond}, 0, -1) . "\\\n";
5819 elsif ($var_value{$var}{$cond})
5821 # Insert a separator.
5822 $var_value{$var}{$cond} .= ' ';
5824 $var_value{$var}{$cond} .= $value;
5828 # The first assignment to a macro sets the line number. Ideally I
5829 # suppose we would associate line numbers with random bits of text.
5830 # FIXME: We sometimes redefine some variables, but we want to keep
5831 # the original location. More subs are needed to handle
5832 # properly variables. Once this done, remove this hack.
5833 $var_line{$var} = $where
5834 unless defined $var_line{$var};
5836 # If Automake tries to override a value specified by the user,
5837 # just don't let it do.
5838 if (defined $var_value{$var}{$cond} && !$var_is_am{$var} && $var_is_am)
5842 print STDERR "$me: refusing to override the user definition of:\n";
5843 variable_dump ($var);
5844 print STDERR "$me: with `$cond' => `$value'\n";
5849 # There must be no previous value unless the user is redefining
5850 # an Automake variable or an AC_SUBST variable.
5851 check_ambiguous_conditional ($var, $cond)
5852 unless ($var_is_am{$var} && !$var_is_am
5853 || exists $configure_vars{$var});
5855 $var_value{$var}{$cond} = $value;
5859 # An Automake variable can be given to the user, but not the converse.
5860 if (! defined $var_is_am{$var} || !$var_is_am)
5862 $var_is_am{$var} = $var_is_am;
5867 # &variable_delete ($VAR, [@CONDS])
5868 # ---------------------------------
5869 # Forget about $VAR under the conditions @CONDS, or completely if
5871 sub variable_delete ($@)
5873 my ($var, @conds) = @_;
5877 delete $var_value{$var};
5878 delete $var_line{$var};
5879 delete $var_is_am{$var};
5880 delete $var_comment{$var};
5881 delete $var_type{$var};
5885 foreach my $cond (@conds)
5887 delete $var_value{$var}{$cond};
5893 # ¯o_dump ($VAR)
5894 # ------------------
5899 if (!exists $var_value{$var})
5901 print STDERR " $var does not exist\n";
5905 my $var_is_am = $var_is_am{$var} ? "Automake" : "User";
5906 my $where = (defined $var_line{$var}
5907 ? $var_line{$var} : "undefined");
5908 print STDERR "$var_comment{$var}"
5909 if defined $var_comment{$var};
5910 print STDERR " $var ($var_is_am, where = $where) $var_type{$var}=\n";
5911 print STDERR " {\n";
5912 foreach my $vcond (sort by_condition keys %{$var_value{$var}})
5914 print STDERR " $vcond => $var_value{$var}{$vcond}\n";
5916 print STDERR " }\n";
5927 print STDERR "%var_value =\n";
5929 foreach my $var (sort (keys %var_value))
5938 # &variable_defined ($VAR, [$COND])
5939 # ---------------------------------
5940 # See if a variable exists. $VAR is the variable name, and $COND is
5941 # the condition which we should check. If no condition is given, we
5942 # currently return true if the variable is defined under any
5944 sub variable_defined ($$)
5946 my ($var, $cond) = @_;
5948 # Unfortunately we can't just check for $var_value{VAR}{COND}
5949 # as this would make perl create $condition{VAR}, which we
5951 if (!exists $var_value{$var})
5953 if (defined $targets{$var})
5955 &am_line_error ($var, "`$var' is a target; expected a variable")
5957 # The variable is not defined
5961 if ($cond && !exists $var_value{$var}{$cond})
5963 # The variable is not defined for the given condition.
5967 # Even a var_value examination is good enough for us. FIXME:
5968 # really should maintain examined status on a per-condition basis.
5969 $content_seen{$var} = 1;
5973 # Mark a variable as examined.
5974 sub examine_variable
5977 &variable_defined ($var);
5980 # Return the set of conditions for which a variable is defined.
5982 # If the variable is not defined conditionally, and is not defined in
5983 # terms of any variables which are defined conditionally, then this
5984 # returns the empty list.
5986 # If the variable is defined conditionally, but is not defined in
5987 # terms of any variables which are defined conditionally, then this
5988 # returns the list of conditions for which the variable is defined.
5990 # If the variable is defined in terms of any variables which are
5991 # defined conditionally, then this returns a full set of permutations
5992 # of the subvariable conditions. For example, if the variable is
5993 # defined in terms of a variable which is defined for COND_TRUE,
5994 # then this returns both COND_TRUE and COND_FALSE. This is
5995 # because we will need to define the variable under both conditions.
5997 sub variable_conditions ($)
6004 foreach my $cond (&variable_conditions_sub ($var, '', ()))
6007 if $cond eq 'FALSE';
6008 $uniqify{$cond} = 1;
6011 @uniq_list = sort by_condition keys %uniqify;
6012 # Note we cannot just do `return sort keys %uniqify', because this
6013 # function is sometimes used in a scalar context.
6019 # &variable_conditionally_defined ($VAR)
6020 # --------------------------------------
6021 sub variable_conditionally_defined ($)
6024 foreach my $cond (variable_conditions ($var))
6027 unless $cond =~ /^TRUE|FALSE$/;
6034 # &variable_conditions_sub ($VAR, $PARENT, @PARENT_CONDS)
6035 # -------------------------------------------------------
6036 # A subroutine of variable_conditions. We only return conditions
6037 # which are true for all the conditions in @PARENT_CONDS.
6038 sub variable_conditions_sub
6040 my ($var, $parent, @parent_conds) = @_;
6043 if (defined $vars_scanned{$var})
6045 &am_line_error ($parent, "variable `$var' recursively defined");
6048 $vars_scanned{$var} = 1;
6050 my @this_conds = ();
6051 foreach my $vcond (keys %{$var_value{$var}})
6054 if ! conditionals_true_when ((@parent_conds), ($vcond));
6056 push (@this_conds, $vcond);
6058 push (@parent_conds, $vcond);
6059 my @subvar_conds = ();
6060 foreach (split (' ', $var_value{$var}{$vcond}))
6062 # If a comment seen, just leave.
6065 # Handle variable substitutions.
6066 if (/^\$\{(.*)\}$/ || /^\$\((.*)\)$/)
6068 push (@subvar_conds,
6069 &variable_conditions_sub ($1, $var, @parent_conds));
6072 pop (@parent_conds);
6074 # If there are no conditional subvariables, then we want to
6075 # return this condition. Otherwise, we want to return the
6076 # permutations of the subvariables.
6077 if (! @subvar_conds)
6079 push (@new_conds, $vcond);
6083 push (@new_conds, &variable_conditions_reduce (@subvar_conds));
6087 # Unset our entry in vars_scanned. We only care about recursive
6089 delete $vars_scanned{$var};
6091 # If there are no parents, then this call is the top level call.
6094 # Now we want to return all permutations of the subvariable
6097 foreach my $item (@new_conds)
6099 foreach (split (' ', $item))
6101 s/^(.*)_(TRUE|FALSE)$/$1_TRUE/;
6105 return &variable_conditions_permutations (sort keys %allconds);
6108 # If we are being called on behalf of another variable, we need to
6109 # return all possible permutations of the conditions. We have
6110 # already handled everything in @this_conds along with their
6111 # subvariables. We now need to add any permutations that are not
6113 foreach my $this_cond (@this_conds)
6116 &variable_conditions_permutations (split(' ', $this_cond));
6117 foreach my $perm (@perms)
6120 foreach my $scan (@this_conds)
6122 if (&conditional_true_when ($perm, $scan)
6123 || &conditional_true_when ($scan, $perm))
6132 if ! conditionals_true_when ((@parent_conds), ($perm));
6134 # This permutation was not already handled, and is valid
6136 push (@new_conds, $perm);
6144 # Filter a list of conditionals so that only the exclusive ones are
6145 # retained. For example, if both `COND1_TRUE COND2_TRUE' and
6146 # `COND1_TRUE' are in the list, discard the latter.
6147 sub variable_conditions_reduce
6151 foreach my $cond (@conds)
6153 # FALSE is absorbent.
6154 if ($cond eq 'FALSE')
6158 elsif (conditionals_true_when (($cond), (@ret)))
6167 # Return a list of permutations of a conditional string.
6168 sub variable_conditions_permutations
6173 my $comp = shift (@comps);
6174 return &variable_conditions_permutations (@comps)
6176 my $neg = condition_negate ($comp);
6179 foreach my $sub (&variable_conditions_permutations (@comps))
6181 push (@ret, "$comp $sub");
6182 push (@ret, "$neg $sub");
6194 # &check_variable_defined_unconditionally($VAR, $PARENT)
6195 # ------------------------------------------------------
6196 # Warn if a variable is conditionally defined. This is called if we
6197 # are using the value of a variable.
6198 sub check_variable_defined_unconditionally ($$)
6200 my ($var, $parent) = @_;
6201 foreach my $cond (keys %{$var_value{$var}})
6204 if $cond =~ /^TRUE|FALSE$/;
6208 &am_line_error ($parent,
6209 "warning: automake does not support conditional definition of $var in $parent");
6213 &am_line_error ($parent,
6214 "warning: automake does not support $var being defined conditionally");
6222 # Get the TRUE value of a variable, warn if the variable is
6223 # conditionally defined.
6227 &check_variable_defined_unconditionally ($var);
6228 return $var_value{$var}{'TRUE'};
6233 # &value_to_list ($VAR, $VAL, $COND)
6234 # ----------------------------------
6235 # Convert a variable value to a list, split as whitespace. This will
6236 # recursively follow $(...) and ${...} inclusions. It preserves @...@
6239 # If COND is 'all', then all values under all conditions should be
6240 # returned; if COND is a particular condition (all conditions are
6241 # surrounded by @...@) then only the value for that condition should
6242 # be returned; otherwise, warn if VAR is conditionally defined.
6243 # SCANNED is a global hash listing whose keys are all the variables
6244 # already scanned; it is an error to rescan a variable.
6247 my ($var, $val, $cond) = @_;
6251 $val =~ s/\\(\n|$)/ /g;
6253 foreach (split (' ', $val))
6255 # If a comment seen, just leave.
6258 # Handle variable substitutions.
6259 if (/^\$\{([^}]*)\}$/ || /^\$\(([^)]*)\)$/)
6263 # If the user uses a losing variable name, just ignore it.
6264 # This isn't ideal, but people have requested it.
6265 next if ($varname =~ /\@.*\@/);
6269 if ($varname =~ /^([^:]*):([^=]*)=(.*)$/)
6273 ($from = $2) =~ s/(\W)/\\$1/g;
6277 @temp_list = &variable_value_as_list_worker ($1, $cond, $var);
6279 # Now rewrite the value if appropriate.
6282 grep (s/$from$/$to/, @temp_list);
6285 push (@result, @temp_list);
6296 # Return contents of variable as list, split as whitespace. This will
6297 # recursively follow $(...) and ${...} inclusions. It preserves @...@
6298 # substitutions. If COND is 'all', then all values under all
6299 # conditions should be returned; if COND is a particular condition
6300 # (all conditions are surrounded by @...@) then only the value for
6301 # that condition should be returned; otherwise, warn if VAR is
6302 # conditionally defined. If PARENT is specified, it is the name of
6303 # the including variable; this is only used for error reports.
6304 sub variable_value_as_list_worker
6306 my ($var, $cond, $parent) = @_;
6309 if (! defined $var_value{$var})
6311 if (defined $targets{$var})
6313 &am_line_error ($var, "`$var' is a target; expected a variable");
6317 &am_line_error ($parent, "variable `$var' not defined");
6320 elsif (defined $vars_scanned{$var})
6322 # `vars_scanned' is a global we use to keep track of which
6323 # variables we've already examined.
6324 &am_line_error ($parent, "variable `$var' recursively defined");
6326 elsif ($cond eq 'all')
6328 $vars_scanned{$var} = 1;
6329 foreach my $vcond (keys %{$var_value{$var}})
6331 my $val = $var_value{$var}{$vcond};
6332 push (@result, &value_to_list ($var, $val, $cond));
6338 $vars_scanned{$var} = 1;
6340 foreach my $vcond (keys %{$var_value{$var}})
6342 my $val = $var_value{$var}{$vcond};
6343 if (&conditional_true_when ($vcond, $cond))
6345 # Warn if we have an ambiguity. It's hard to know how
6346 # to handle this case correctly.
6347 &check_variable_defined_unconditionally ($var, $parent)
6350 push (@result, &value_to_list ($var, $val, $cond));
6355 # Unset our entry in vars_scanned. We only care about recursive
6357 delete $vars_scanned{$var};
6363 # &variable_output ($VAR, [@CONDS])
6364 # ---------------------------------
6365 # Output all the values of $VAR is @COND is not specified, else only
6366 # that corresponding to @COND.
6367 sub variable_output ($@)
6369 my ($var, @conds) = @_;
6371 @conds = sort by_condition keys %{$var_value{$var}}
6374 $output_vars .= $var_comment{$var}
6375 if defined $var_comment{$var};
6377 foreach my $cond (@conds)
6379 my $val = $var_value{$var}{$cond};
6380 my $equals = $var_type{$var} eq ':' ? ':=' : '=';
6381 my $output_var = "$var $equals $val";
6382 $output_var =~ s/^/make_condition ($cond)/meg;
6383 $output_vars .= $output_var . "\n";
6388 # &variable_pretty_output ($VAR, [@CONDS])
6389 # ----------------------------------------
6390 # Likewise, but pretty, i.e., we *split* the values at spaces. Use only
6391 # with variables holding filenames.
6392 sub variable_pretty_output ($@)
6394 my ($var, @conds) = @_;
6396 @conds = sort by_condition keys %{$var_value{$var}}
6399 $output_vars .= $var_comment{$var}
6400 if defined $var_comment{$var};
6402 foreach my $cond (@conds)
6404 my $val = $var_value{$var}{$cond};
6405 my $equals = $var_type{$var} eq ':' ? ':=' : '=';
6406 my $make_condition = make_condition ($cond);
6407 $output_vars .= pretty_print_internal ("$make_condition$var $equals",
6408 "$make_condition\t",
6409 split (' ' , $val));
6414 # This is just a wrapper for variable_value_as_list_worker that
6415 # initializes the global hash `vars_scanned'. This hash is used to
6416 # avoid infinite recursion.
6417 sub variable_value_as_list
6419 my ($var, $cond, $parent) = @_;
6421 return &variable_value_as_list_worker ($var, $cond, $parent);
6425 # Like define_variable, but the value is a list, and the variable may
6426 # be defined conditionally. The second argument is the conditional
6427 # under which the value should be defined; this should be the empty
6428 # string to define the variable unconditionally. The third argument
6429 # is a list holding the values to use for the variable. The value is
6430 # pretty printed in the output file.
6431 sub define_pretty_variable
6433 my ($var, $cond, @value) = @_;
6435 # Beware that an empty $cond has a different semantics for
6436 # macro_define and variable_pretty_output.
6439 if (! &variable_defined ($var, $cond))
6441 macro_define ($var, 1, '', $cond, join (' ', @value), undef);
6442 variable_pretty_output ($var, $cond || 'TRUE');
6443 $content_seen{$var} = 1;
6448 # define_variable ($VAR, $VALUE)
6449 # ------------------------------
6450 # Define a new user variable VAR to VALUE, but only if not already defined.
6453 my ($var, $value) = @_;
6455 define_pretty_variable ($var, 'TRUE', $value);
6459 # Like define_variable, but define a variable to be the configure
6460 # substitution by the same name.
6461 sub define_configure_variable
6464 my $value = '@' . $var . '@';
6465 &define_variable ($var, $value);
6469 # define_compiler_variable ($LANG)
6470 # --------------------------------
6471 # Define a compiler variable. We also handle defining the `LT'
6472 # version of the command when using libtool.
6473 sub define_compiler_variable ($)
6477 my ($var, $value) = ($lang->compiler, $lang->compile);
6478 &define_variable ($var, $value);
6479 &define_variable ("LT$var", "$(LIBTOOL) --mode=compile $value")
6484 # define_linker_variable ($LANG)
6485 # ------------------------------
6486 # Define linker variables.
6487 sub define_linker_variable ($)
6491 my ($var, $value) = ($lang->lder, $lang->ld);
6493 &define_variable ($lang->lder, $lang->ld);
6494 # CCLINK = $(CCLD) blah blah...
6495 &define_variable ($lang->linker,
6496 (($seen_libtool ? '$(LIBTOOL) --mode=link ' : '')
6500 ################################################################
6502 ## ---------------- ##
6503 ## Handling rules. ##
6504 ## ---------------- ##
6506 sub rule_define ($$$$)
6508 my ($target, $rule_is_am, $cond, $where) = @_;
6510 if (defined $targets{$target}
6512 ? ! defined $target_conditional{$target}
6513 : defined $target_conditional{$target}))
6515 &am_line_error ($target,
6516 "$target defined both conditionally and unconditionally");
6519 # Value here doesn't matter; for targets we only note existence.
6520 $targets{$target} = $where;
6523 if ($target_conditional{$target})
6525 &check_ambiguous_conditional ($target, $cond);
6527 $target_conditional{$target}{$cond} = $where;
6531 # Check the rule for being a suffix rule. If so, store in a hash.
6533 if ((my ($source_suffix, $object_suffix)) = ($target =~ $SUFFIX_RULE_PATTERN))
6535 $suffix_rules{$source_suffix} = $object_suffix;
6536 print "Sources ending in .$source_suffix become .$object_suffix\n"
6538 # Set SUFFIXES from suffix_rules.
6539 push @suffixes, ".$source_suffix", ".$object_suffix";
6544 # See if a target exists.
6548 return defined $targets{$target};
6552 ################################################################
6554 # Read Makefile.am and set up %contents. Simultaneously copy lines
6555 # from Makefile.am into $output_trailer or $output_vars as
6556 # appropriate. NOTE we put rules in the trailer section. We want
6557 # user rules to come after our generated stuff.
6562 my $am_file = new IO::File ("< $amfile");
6565 die "$me: couldn't open `$amfile': $!\n";
6567 print "$me: reading $amfile\n" if $verbose;
6573 while ($_ = $am_file->getline)
6575 if (/$IGNORE_PATTERN/o)
6577 # Merely delete comments beginning with two hashes.
6579 elsif (/$WHITE_PATTERN/o)
6581 # Stick a single white line before the incoming macro or rule.
6585 elsif (/$COMMENT_PATTERN/o)
6587 # Stick comments before the incoming macro or rule. Make
6588 # sure a blank line preceeds first block of comments.
6589 $spacing = "\n" unless $blank;
6591 $comment .= $spacing . $_;
6600 $output_vars .= $comment . "\n";
6604 # We save the conditional stack on entry, and then check to make
6605 # sure it is the same on exit. This lets us conditonally include
6607 my @saved_cond_stack = @cond_stack;
6608 my $cond = conditional_string (@cond_stack);
6612 my $last_var_name = '';
6613 my $last_var_type = '';
6614 my $last_var_value = '';
6618 unless substr ($_, -1, 1) eq "\n";
6620 # Don't look at MAINTAINER_MODE_TRUE here. That shouldn't be
6621 # used by users. @MAINT@ is an anachronism now.
6622 $_ =~ s/\@MAINT\@//g
6623 unless $seen_maint_mode;
6625 if (/$IGNORE_PATTERN/o)
6627 # Merely delete comments beginning with two hashes.
6629 elsif (/$WHITE_PATTERN/o)
6631 # Stick a single white line before the incoming macro or rule.
6633 &am_line_error ($., "blank line following trailing backslash")
6636 elsif (/$COMMENT_PATTERN/o)
6638 # Stick comments before the incoming macro or rule.
6639 $comment .= $spacing . $_;
6641 &am_line_error ($., "comment following trailing backslash")
6648 $output_trailer .= &make_condition (@cond_stack);
6649 $output_trailer .= $_;
6653 $last_var_value .= ' '
6654 unless $last_var_value =~ /\s$/;
6655 $last_var_value .= $_;
6659 $var_comment{$last_var_name} .= "$spacing"
6660 if (!defined $var_comment{$last_var_name}
6661 || substr ($var_comment{$last_var_name}, -1) ne "\n");
6662 $var_comment{$last_var_name} .= "$comment";
6663 $comment = $spacing = '';
6664 macro_define ($last_var_name, 0,
6665 $last_var_type, $cond,
6666 $last_var_value, $.)
6667 if $cond ne 'FALSE';
6668 push (@var_list, $last_var_name);
6673 elsif (/$IF_PATTERN/o)
6675 $cond = cond_stack_if ($1, $2, "$amfile:$.");
6677 elsif (/$ELSE_PATTERN/o)
6679 $cond = cond_stack_else ($1, $2, "$amfile:$.");
6681 elsif (/$ENDIF_PATTERN/o)
6683 $cond = cond_stack_endif ($1, $2, "$amfile:$.");
6686 elsif (/$RULE_PATTERN/o)
6691 rule_define ($1, 0, $cond, $.);
6694 $output_trailer .= $comment . $spacing;
6695 $output_trailer .= &make_condition (@cond_stack);
6696 $output_trailer .= $_;
6697 $comment = $spacing = '';
6699 elsif (/$ASSIGNMENT_PATTERN/o)
6702 # Found a macro definition.
6704 $last_var_name = $1;
6705 $last_var_type = $2;
6706 $last_var_value = $3;
6707 if ($3 ne '' && substr ($3, -1) eq "\\")
6709 # We preserve the `\' because otherwise the long lines
6710 # that are generated will be truncated by broken
6712 $last_var_value = $3 . "\n";
6717 # FIXME: this doesn't always work correctly; it will
6718 # group all comments for a given variable, no matter
6720 # Accumulating variables must not be output.
6721 $var_comment{$last_var_name} .= "$spacing"
6722 if (!defined $var_comment{$last_var_name}
6723 || substr ($var_comment{$last_var_name}, -1) ne "\n");
6724 $var_comment{$last_var_name} .= "$comment";
6725 $comment = $spacing = '';
6727 # print STDERR "$last_var_name => $last_var_value\n";
6728 macro_define ($last_var_name, 0,
6729 $last_var_type, $cond,
6730 $last_var_value, $.)
6731 if $cond ne 'FALSE';
6732 push (@var_list, $last_var_name);
6735 elsif (/$INCLUDE_PATTERN/o)
6739 if ($path =~ s/^\$\(top_srcdir\)\///)
6741 push (@include_stack, "\$\(top_srcdir\)/$path");
6745 $path =~ s/\$\(srcdir\)\///;
6746 push (@include_stack, "\$\(srcdir\)/$path");
6747 $path = $relative_dir . "/" . $path;
6749 &read_am_file ($path);
6753 # This isn't an error; it is probably a continued rule.
6754 # In fact, this is what we assume.
6756 $output_trailer .= $comment . $spacing;
6757 $output_trailer .= &make_condition (@cond_stack);
6758 $output_trailer .= $_;
6759 $comment = $spacing = '';
6763 $_ = $am_file->getline;
6766 $output_trailer .= $comment;
6768 if (join (' ', @saved_cond_stack) ne join (' ', @cond_stack))
6772 &am_error ("unterminated conditionals: @cond_stack");
6776 # FIXME: better error message here.
6777 &am_error ("conditionals not nested in include file");
6783 # define_standard_variables ()
6784 # ----------------------------
6785 # A helper for read_main_am_file which initializes configure variables
6786 # and variables from header-vars.am. This is a subr so we can call it
6788 sub define_standard_variables
6790 my $saved_output_vars = $output_vars;
6791 my ($comments, undef, $rules) =
6792 &file_contents_internal (1, "$am_dir/header-vars.am",
6793 ('BUILD' => $seen_canonical == $AC_CANONICAL_SYSTEM,
6794 'HOST' => $seen_canonical,
6795 'TARGET' => $seen_canonical == $AC_CANONICAL_SYSTEM,
6796 'top_builddir' => backname ($relative_dir)));
6798 # This will output the definitions in $output_vars, which we don't
6800 foreach my $var (sort keys %configure_vars)
6802 &define_configure_variable ($var);
6803 push (@var_list, $var);
6806 # ... hence, we restore $output_vars.
6807 $output_vars = $saved_output_vars . $comments . $rules;
6810 # Read main am file.
6811 sub read_main_am_file
6815 # This supports the strange variable tricks we are about to play.
6816 if (scalar keys %var_value > 0)
6819 &prog_error ("variable defined before read_main_am_file");
6822 # Generate copyright header for generated Makefile.in.
6823 # We do discard the output of predefined variables, handled below.
6824 $output_vars = ("# $in_file_name generated automatically by automake "
6825 . $VERSION . " from $am_file_name.\n");
6826 $output_vars .= $gen_copyright;
6828 # We want to predefine as many variables as possible. This lets
6829 # the user set them with `+=' in Makefile.am. However, we don't
6830 # want these initial definitions to end up in the output quite
6831 # yet. So we just load them, but output them later.
6832 &define_standard_variables;
6834 # Read user file, which might override some of our values.
6835 &read_am_file ($amfile);
6837 # Ouput all the Automake variables. If the user changed one, then
6838 # it is now marked as owned by the user.
6839 foreach my $var (uniq @var_list)
6841 # Don't process user variables.
6842 variable_output ($var)
6843 unless !$var_is_am{$var};
6846 # Now dump the user variables that were defined. We do it in the same
6847 # order in which they were defined (skipping duplicates).
6848 foreach my $var (uniq @var_list)
6850 # Don't process Automake variables.
6851 variable_output ($var)
6852 unless $var_is_am{$var};
6856 ################################################################
6859 # &flatten ($STRING)
6860 # ------------------
6861 # Flatten the $STRING and return the result.
6876 # &make_paragraphs ($MAKEFILE, [%TRANSFORM])
6877 # ------------------------------------------
6878 # Load a $MAKEFILE, apply the %TRANSFORM, and return it as a list of
6880 sub make_paragraphs ($%)
6882 my ($file, %transform) = @_;
6884 # Complete %transform with global options and make it a Perl
6887 "s/$IGNORE_PATTERN//gm;"
6888 . transform (%transform,
6890 'CYGNUS' => $cygnus_mode,
6892 => $seen_maint_mode ? subst ('MAINTAINER_MODE_TRUE') : '',
6894 'SHAR' => $options{'dist-shar'} || 0,
6895 'BZIP2' => $options{'dist-bzip2'} || 0,
6896 'ZIP' => $options{'dist-zip'} || 0,
6897 'COMPRESS' => $options{'dist-tarZ'} || 0,
6899 'INSTALL-INFO' => !$options{'no-installinfo'},
6900 'INSTALL-MAN' => !$options{'no-installman'},
6901 'CK-NEWS' => $options{'check-news'} || 0,
6903 'SUBDIRS' => &variable_defined ('SUBDIRS'),
6904 'TOPDIR' => backname ($relative_dir),
6905 'TOPDIR_P' => $relative_dir eq '.',
6906 'CONFIGURE-AC' => $configure_ac,
6908 'LIBTOOL' => defined $configure_vars{'LIBTOOL'})
6909 # We don't need more than two consecutive new-lines.
6910 . 's/\n{3,}/\n\n/g';
6912 # Swallow the file and apply the COMMAND.
6913 my $fc_file = new IO::File ("< $file");
6916 die "$me: installation error: cannot open `$file'\n";
6919 print "$me: reading $file\n"
6921 my $saved_dollar_slash = $/;
6923 $_ = $fc_file->getline;
6924 $/ = $saved_dollar_slash;
6929 # Split at unescaped new lines.
6930 my @lines = split (/(?<!\\)\n/, $content);
6933 while (defined ($_ = shift @lines))
6935 my $paragraph = "$_";
6936 # If we are a rule, eat as long as we start with a tab.
6937 if (/$RULE_PATTERN/smo)
6939 while (defined ($_ = shift @lines) && $_ =~ /^\t/)
6941 $paragraph .= "\n$_";
6943 unshift (@lines, $_);
6946 # If we are a comments, eat as much comments as you can.
6947 elsif (/$COMMENT_PATTERN/smo)
6949 while (defined ($_ = shift @lines)
6950 && $_ =~ /$COMMENT_PATTERN/smo)
6952 $paragraph .= "\n$_";
6954 unshift (@lines, $_);
6957 push @res, $paragraph;
6966 # ($COMMENT, $VARIABLES, $RULES)
6967 # &file_contents_internal ($IS_AM, $FILE, [%TRANSFORM])
6968 # -----------------------------------------------------
6969 # Return contents of a file from $am_dir, automatically skipping
6970 # macros or rules which are already known. $IS_AM iff the caller is
6971 # reading an Automake file (as opposed to the user's Makefile.am).
6972 sub file_contents_internal ($$%)
6974 my ($is_am, $file, %transform) = @_;
6976 my $result_vars = '';
6977 my $result_rules = '';
6981 # We save the conditional stack on entry, and then check to make
6982 # sure it is the same on exit. This lets us conditonally include
6984 my @saved_cond_stack = @cond_stack;
6985 my $cond = conditional_string (@cond_stack);
6987 foreach (make_paragraphs ($file, %transform))
6990 &am_file_error ($file, "blank line following trailing backslash:\n$_")
6992 &am_file_error ($file, "comment following trailing backslash:\n$_")
6997 # Stick empty line before the incoming macro or rule.
7000 elsif (/$COMMENT_PATTERN/mso)
7002 # Stick comments before the incoming macro or rule.
7006 # Handle inclusion of other files.
7007 elsif (/$INCLUDE_PATTERN/o)
7009 if ($cond ne 'FALSE')
7011 my $file = ($is_am ? "$am_dir/" : '') . $1;
7013 my ($com, $vars, $rules)
7014 = file_contents_internal ($is_am, $file, %transform);
7016 $result_vars .= $vars;
7017 $result_rules .= $rules;
7021 # Handling the conditionals.
7022 elsif (/$IF_PATTERN/o)
7024 $cond = cond_stack_if ($1, $2, $file);
7026 elsif (/$ELSE_PATTERN/o)
7028 $cond = cond_stack_else ($1, $2, $file);
7030 elsif (/$ENDIF_PATTERN/o)
7032 $cond = cond_stack_endif ($1, $2, $file);
7036 elsif (/$RULE_PATTERN/mso)
7038 # Separate relationship from optional actions: the first
7039 # `new-line tab" not preceded by backslash (continuation
7041 # I'm quite shoked! It seems that (\\\n|[^\n]) is not the
7042 # same as `([^\n]|\\\n)!!! Don't swap it, it breaks.
7044 /^((?:\\\n|[^\n])*)(?:\n(\t.*))?$/som;
7045 my ($relationship, $actions) = ($1, $2 || '');
7047 # Separate targets from dependencies: the first colon.
7048 $relationship =~ /^([^:]+\S+) *: *(.*)$/som;
7049 my ($targets, $dependencies) = ($1, $2);
7050 # Remove the escaped new lines.
7051 # I don't know why, but I have to use a tmp $flat_deps.
7052 my $flat_deps = &flatten ($dependencies);
7053 my @deps = split (' ', $flat_deps);
7055 foreach (split (' ' , $targets))
7057 # FIXME: We are not robust to people defining several targets
7058 # at once, only some of them being in %dependencies.
7060 # Output only if not in FALSE.
7061 if (defined $dependencies{$_}
7062 && $cond ne 'FALSE')
7064 &depend ($_, @deps);
7065 $actions{$_} .= $actions;
7069 # Free lance dependency. Output the rule for all the
7070 # targets instead of one by one.
7071 if (!defined $targets{$targets}
7072 && $cond ne 'FALSE')
7074 $paragraph =~ s/^/make_condition (@cond_stack)/gme;
7075 $result_rules .= "$spacing$comment$paragraph\n";
7076 rule_define ($targets, $is_am, $cond, $file);
7078 $comment = $spacing = '';
7084 elsif (/$ASSIGNMENT_PATTERN/mso)
7086 my ($var, $type, $val) = ($1, $2, $3);
7087 &am_file_error ($file, "macro `$var' with trailing backslash")
7090 # Accumulating variables must not be output.
7091 $var_comment{$var} .= "$spacing"
7092 if (!defined $var_comment{$var}
7093 || substr ($var_comment{$var}, -1) ne "\n");
7094 $var_comment{$var} .= "$comment";
7095 macro_define ($var, $is_am, $type, $cond, $val, $file)
7096 if $cond ne 'FALSE';
7097 push (@var_list, $var);
7099 # If the user has set some variables we were in charge
7100 # of (which is detected by the first reading of
7101 # `header-vars.am'), we must not output them.
7102 $result_vars .= "$spacing$comment$_\n"
7103 if $type ne '+' && $var_is_am{$var} && $cond ne 'FALSE';
7105 $comment = $spacing = '';
7109 # This isn't an error; it is probably some tokens which
7110 # configure is supposed to replace, such as `@SET-MAKE@',
7111 # or some part of a rule cut by an if/endif.
7112 if ($cond ne 'FALSE')
7114 s/^/make_condition (@cond_stack)/gme;
7115 $result_rules .= "$spacing$comment$_\n";
7117 $comment = $spacing = '';
7121 if (join (' ', @saved_cond_stack) ne join (' ', @cond_stack))
7125 &am_error ("unterminated conditionals: @cond_stack");
7129 # FIXME: better error message here.
7130 &am_error ("conditionals not nested in include file");
7134 return ($comment, $result_vars, $result_rules);
7139 # &file_contents ($BASENAME, [%TRANSFORM])
7140 # ----------------------------------------
7141 # Return contents of a file from $am_dir, automatically skipping
7142 # macros or rules which are already known.
7143 sub file_contents ($%)
7145 my ($basename, %transform) = @_;
7146 my ($comments, $variables, $rules) =
7147 file_contents_internal (1, "$am_dir/$basename.am", %transform);
7148 return "$comments$variables$rules";
7153 # &transform (%PAIRS)
7154 # -------------------
7155 # Foreach ($TOKEN, $VAL) in %PAIRS produce a replacement expression suitable
7156 # for file_contents which:
7157 # - replaces @$TOKEN@ with $VALUE,
7158 # - enables/disables ?$TOKEN?.
7164 while (my ($token, $val) = each %pairs)
7166 $result .= "s/\Q%$token%\E/\Q$val\E/gm;";
7169 $result .= "s/\Q?$token?\E//gm;s/^.*\Q?!$token?\E.*\\n//gm;";
7170 $result .= "s/\Q%?$token%\E/TRUE/gm;";
7174 $result .= "s/\Q?!$token?\E//gm;s/^.*\Q?$token?\E.*\\n//gm;";
7175 $result .= "s/\Q%?$token%\E/FALSE/gm;";
7183 # Find all variable prefixes that are used for install directories. A
7184 # prefix `zar' qualifies iff:
7185 # * `zardir' is a variable.
7186 # * `zar_PRIMARY' is a variable.
7187 sub am_primary_prefixes
7189 my ($primary, $can_dist, @prefixes) = @_;
7192 grep ($valid{$_} = 0, @prefixes);
7193 $valid{'EXTRA'} = 0;
7194 foreach my $varname (keys %var_value)
7196 # Automake is allowed to define variables that look like they
7197 # are magic variables, such as INSTALL_DATA.
7199 if $var_is_am{$varname};
7201 if ($varname =~ /^(nobase_)?(dist_|nodist_)?(.*)_$primary$/)
7203 my ($base, $dist, $X) = ($1 || '', $2 || '', $3 || '');
7204 if ($dist ne '' && ! $can_dist)
7206 # Note that a configure variable is always legitimate.
7207 # It is natural to name such variables after the
7208 # primary, so we explicitly allow it.
7209 if (! defined $configure_vars{$varname})
7211 &am_line_error ($varname,
7212 "invalid variable `$varname': `dist' is forbidden");
7215 elsif (! defined $valid{$X} && ! &variable_defined ("${X}dir"))
7217 # Note that a configure variable is always legitimate.
7218 # It is natural to name such variables after the
7219 # primary, so we explicitly allow it.
7220 if (! defined $configure_vars{$varname})
7222 &am_line_error ($varname,
7223 "invalid variable `$varname'");
7228 # Ensure all extended prefixes are actually used.
7229 $valid{"$base$dist$X"} = 1;
7237 # Handle `where_HOW' variable magic. Does all lookups, generates
7238 # install code, and possibly generates code to define the primary
7239 # variable. The first argument is the name of the .am file to munge,
7240 # the second argument is the primary variable (eg HEADERS), and all
7241 # subsequent arguments are possible installation locations. Returns
7242 # list of all values of all _HOW targets.
7244 # FIXME: this should be rewritten to be cleaner. It should be broken
7245 # up into multiple functions.
7247 # Usage is: am_install_var (OPTION..., file, HOW, where...)
7254 my $default_dist = 0;
7257 if ($args[0] eq '-noextra')
7261 elsif ($args[0] eq '-candist')
7265 elsif ($args[0] eq '-defaultdist')
7270 elsif ($args[0] !~ /^-/)
7277 my ($file, $primary, @prefixes) = @args;
7279 # Now that configure substitutions are allowed in where_HOW
7280 # variables, it is an error to actually define the primary. We
7281 # allow `JAVA', as it is customarily used to mean the Java
7282 # interpreter. This is but one of several Java hacks. Similarly,
7283 # `PYTHON' is customarily used to mean the Python interpreter.
7284 &am_line_error ($primary, "`$primary' is an anachronism")
7285 if &variable_defined ($primary)
7286 && ($primary ne 'JAVA' && $primary ne 'PYTHON');
7289 # Look for misspellings. It is an error to have a variable ending
7290 # in a "reserved" suffix whose prefix is unknown, eg
7291 # "bni_PROGRAMS". However, unusual prefixes are allowed if a
7292 # variable of the same name (with "dir" appended) exists. For
7293 # instance, if the variable "zardir" is defined, then
7294 # "zar_PROGRAMS" becomes valid. This is to provide a little extra
7295 # flexibility in those cases which need it.
7296 my %valid = &am_primary_prefixes ($primary, $can_dist, @prefixes);
7298 # If a primary includes a configure substitution, then the EXTRA_
7299 # form is required. Otherwise we can't properly do our job.
7301 my $warned_about_extra = 0;
7306 # True if the iteration is the first one. Used for instance to
7307 # output parts of the associated file only once.
7309 foreach my $X (sort keys %valid)
7311 my $one_name = $X . '_' . $primary;
7313 unless (&variable_defined ($one_name));
7315 my $strip_subdir = 1;
7316 # If subdir prefix should be preserved, do so.
7317 if ($X =~ /^nobase_/)
7323 my $nodir_name = $X;
7324 # If files should be distributed, do so.
7328 $dist_p = (($default_dist && $one_name !~ /^nodist_/)
7329 || (! $default_dist && $one_name =~ /^dist_/));
7330 $nodir_name =~ s/^(dist|nodist)_//;
7333 # Append actual contents of where_PRIMARY variable to
7335 foreach my $rcurs (&variable_value_as_list ($one_name, 'all'))
7337 # Skip configure substitutions. Possibly bogus.
7338 if ($rcurs =~ /^\@.*\@$/)
7342 if (! $warned_about_extra)
7344 $warned_about_extra = 1;
7345 &am_line_error ($one_name,
7346 "`$one_name' contains configure substitution, but shouldn't");
7349 # Check here to make sure variables defined in
7350 # configure.ac do not imply that EXTRA_PRIMARY
7352 elsif (! defined $configure_vars{$one_name})
7354 $require_extra = $one_name
7361 push (@result, $rcurs);
7364 # A blatant hack: we rewrite each _PROGRAMS primary to
7365 # include EXEEXT when in Cygwin32 mode.
7366 if ($primary eq 'PROGRAMS')
7368 my @conds = &variable_conditions ($one_name);
7371 foreach my $cond (@conds)
7373 my @one_binlist = ();
7374 my @condval = &variable_value_as_list ($one_name,
7376 foreach my $rcurs (@condval)
7378 if ($rcurs =~ /\./ || $rcurs =~ /^\@.*\@$/)
7380 push (@one_binlist, $rcurs);
7384 push (@one_binlist, $rcurs . '$(EXEEXT)');
7388 push (@condvals, $cond);
7389 push (@condvals, join (' ', @one_binlist));
7392 variable_delete ($one_name);
7395 my $cond = shift (@condvals);
7396 my @val = split (' ', shift (@condvals));
7397 &define_pretty_variable ($one_name, $cond, @val);
7401 # "EXTRA" shouldn't be used when generating clean targets,
7402 # all, or install targets.
7405 # We used to warn if EXTRA_FOO was defined uselessly,
7406 # but this was annoying.
7412 push (@check, '$(' . $one_name . ')');
7416 push (@used, '$(' . $one_name . ')');
7419 # Is this to be installed?
7420 my $install_p = $X ne 'noinst' && $X ne 'check';
7422 # If so, with install-exec? (or install-data?).
7423 my $exec_p = (defined $exec_dir_p {$X}
7427 # Singular form of $PRIMARY.
7428 (my $one_primary = $primary) =~ s/S$//;
7429 $output_rules .= &file_contents ($file,
7432 'PRIMARY' => $primary,
7433 'ONE_PRIMARY' => $one_primary,
7435 'NDIR' => $nodir_name,
7436 'BASE' => $strip_subdir,
7439 'INSTALL' => $install_p,
7440 'DIST' => $dist_p));
7445 # The JAVA variable is used as the name of the Java interpreter.
7446 # The PYTHON variable is used as the name of the Python interpreter.
7447 if (@used && $primary ne 'JAVA' && $primary ne 'PYTHON')
7450 &define_pretty_variable ($primary, '', @used);
7451 $output_vars .= "\n";
7454 if ($require_extra && ! &variable_defined ('EXTRA_' . $primary))
7456 &am_line_error ($require_extra,
7457 "`$require_extra' contains configure substitution, but `EXTRA_$primary' not defined");
7460 # Push here because PRIMARY might be configure time determined.
7461 push (@all, '$(' . $primary . ')')
7462 if @used && $primary ne 'JAVA' && $primary ne 'PYTHON';
7464 # Make the result unique. This lets the user use conditionals in
7465 # a natural way, but still lets us program lazily -- we don't have
7466 # to worry about handling a particular object more than once.
7467 return uniq (sort @result);
7471 ################################################################
7473 # Each key in this hash is the name of a directory holding a
7474 # Makefile.in. These variables are local to `is_make_dir'.
7476 my $make_dirs_set = 0;
7481 if (! $make_dirs_set)
7483 foreach my $iter (@configure_input_files)
7485 $make_dirs{dirname ($iter)} = 1;
7487 # We also want to notice Makefile.in's.
7488 foreach my $iter (@other_input_files)
7490 if ($iter =~ /Makefile\.in$/)
7492 $make_dirs{dirname ($iter)} = 1;
7497 return defined $make_dirs{$dir};
7500 ################################################################
7502 # This variable is local to the "require file" set of functions.
7503 my @require_file_paths = ();
7505 # If a file name appears as a key in this hash, then it has already
7506 # been checked for. This variable is local to the "require file"
7508 %require_file_found = ();
7510 # See if we want to push this file onto dist_common. This function
7511 # encodes the rules for deciding when to do so.
7512 sub maybe_push_required_file
7514 my ($dir, $file, $fullfile) = @_;
7516 # FIXME: Once again, special-case `.'.
7517 if ($dir eq $relative_dir || $dir eq '.')
7519 &push_dist_common ($file);
7521 elsif ($relative_dir eq '.' && ! &is_make_dir ($dir))
7523 # If we are doing the topmost directory, and the file is in a
7524 # subdir which does not have a Makefile, then we distribute it
7526 &push_dist_common ($fullfile);
7531 # &require_file_internal ($IS_CONFIGURE, $LINE, $MYSTRICT, @FILES)
7532 # ----------------------------------------------------------------
7533 # Verify that the file must exist in the current directory.
7534 # $MYSTRICT is the strictness level at which this file becomes required.
7536 # Must set require_file_paths before calling this function.
7537 # require_file_paths is set to hold a single directory (the one in
7538 # which the first file was found) before return.
7539 sub require_file_internal
7541 my ($is_configure, $line, $mystrict, @files) = @_;
7543 foreach my $file (@files)
7550 # If we've already looked for it, we're done.
7551 next if defined $require_file_found{$file};
7552 $require_file_found{$file} = 1;
7555 my $dangling_sym = 0;
7556 foreach my $dir (@require_file_paths)
7560 $fullfile = $relative_dir . "/" . $file;
7561 $errdir = $relative_dir unless $errdir;
7565 $fullfile = $dir . "/" . $file;
7566 $errdir = $dir unless $errdir;
7569 # Use different name for "error filename". Otherwise on
7570 # an error the bad file will be reported as eg
7571 # `../../install-sh' when using the default
7573 $errfile = $errdir . '/' . $file;
7575 if (-l $fullfile && ! -f readlink ($fullfile))
7580 elsif (-f $fullfile)
7583 &maybe_push_required_file ($dir, $file, $fullfile);
7589 if ($found_it && ! $force_missing)
7591 # Prune the path list.
7592 @require_file_paths = $save_dir;
7596 if ($strictness >= $mystrict)
7598 if ($dangling_sym && ($force_missing || $add_missing))
7606 # Only install missing files according to our desired
7608 my $message = "required file `$errfile' not found";
7613 # Maybe run libtoolize.
7614 my @syslist = ('libtoolize', '--automake');
7615 push @syslist, '--copy'
7618 && grep ($_ eq $file, @libtoolize_files)
7619 && system (@syslist))
7621 $message = "installing `$errfile'";
7623 $trailer = "; cannot run `libtoolize': $!";
7625 elsif (-f ("$pkgdata_dir/$file"))
7627 # Install the missing file. Symlink if we
7628 # can, copy if we must. Note: delete the file
7629 # first, in case it is a dangling symlink.
7630 $message = "installing `$errfile'";
7631 # Windows Perl will hang if we try to delete a
7632 # file that doesn't exist.
7633 unlink ($errfile) if -f $errfile;
7634 if ($symlink_exists && ! $copy_missing)
7636 if (! symlink ("$pkgdata_dir/$file", $errfile))
7639 $trailer = "; error while making link: $!";
7642 elsif (system ('cp', "$pkgdata_dir/$file", $errfile))
7645 $trailer = "\n error while copying";
7649 &maybe_push_required_file (dirname ($errfile),
7653 my $save = $exit_status;
7656 # FIXME: allow actual file to be specified.
7657 &am_conf_line_error ($configure_ac, $line,
7658 "$message$trailer");
7662 &am_line_error ($line, "$message$trailer");
7664 $exit_status = $save if $suppress;
7670 # Like require_file_with_line, but error messages refer to
7671 # configure.ac, not the current Makefile.am.
7672 sub require_file_with_conf_line
7674 @require_file_paths = '.';
7675 &require_file_internal (1, @_);
7678 sub require_file_with_line
7680 @require_file_paths = '.';
7681 &require_file_internal (0, @_);
7686 @require_file_paths = '.';
7687 &require_file_internal (0, '', @_);
7690 # Require a file that is also required by Autoconf. Looks in
7691 # configuration path, as specified by AC_CONFIG_AUX_DIR.
7692 sub require_config_file
7694 @require_file_paths = @config_aux_path;
7695 &require_file_internal (1, '', @_);
7696 my $dir = $require_file_paths[0];
7697 @config_aux_path = @require_file_paths;
7700 $config_aux_dir = '.';
7704 $config_aux_dir = '$(top_srcdir)/' . $dir;
7708 # Assumes that the line number is in Makefile.am.
7709 sub require_conf_file_with_line
7711 @require_file_paths = @config_aux_path;
7712 &require_file_internal (0, @_);
7713 my $dir = $require_file_paths[0];
7714 @config_aux_path = @require_file_paths;
7717 $config_aux_dir = '.';
7721 $config_aux_dir = '$(top_srcdir)/' . $dir;
7725 # Assumes that the line number is in configure.ac.
7726 sub require_conf_file_with_conf_line
7728 @require_file_paths = @config_aux_path;
7729 &require_file_internal (1, @_);
7730 my $dir = $require_file_paths[0];
7731 @config_aux_path = @require_file_paths;
7734 $config_aux_dir = '.';
7738 $config_aux_dir = '$(top_srcdir)/' . $dir;
7742 ################################################################
7744 # Push a list of files onto dist_common.
7745 sub push_dist_common
7747 &prog_error ("push_dist_common run after handle_dist")
7748 if $handle_dist_run;
7749 macro_define ('DIST_COMMON', 1, '+', '', join (' ', @_), '');
7756 $strictness_name = $_[0];
7757 if ($strictness_name eq 'gnu')
7761 elsif ($strictness_name eq 'gnits')
7763 $strictness = $GNITS;
7765 elsif ($strictness_name eq 'foreign')
7767 $strictness = $FOREIGN;
7771 die "$me: level `$strictness_name' not recognized\n";
7776 ################################################################
7778 # Ensure a file exists.
7783 my $touch = new IO::File (">> $file");
7787 # Glob something. Do this to avoid indentation screwups everywhere we
7788 # want to glob. Gross!
7795 # Remove one level of brackets and strip leading spaces,
7796 # as does m4 to function arguments.
7802 my @letters = split //;
7811 next if $depth == 1;
7816 next if $depth == 0;
7817 # don't count orphan right brackets
7818 $depth = 0 if $depth < 0;
7822 return join '', @result;
7825 ################################################################
7827 # Print an error message and set exit status.
7830 warn "$me: ${am_file}.am: @_\n";
7835 # am_file_error ($FILE, @ARGS)
7836 # ----------------------------
7839 my ($file, @args) = @_;
7841 warn "$file: @args\n";
7847 my ($symbol, @args) = @_;
7849 if ($symbol && "$symbol" ne '-1')
7851 my $file = "${am_file}.am";
7853 if ($symbol =~ /^\d+$/)
7855 # SYMBOL is a line number, so just add the colon.
7856 $file .= ':' . $symbol;
7858 elsif (defined $var_line{$symbol})
7860 # SYMBOL is a variable defined in Makefile.am, so add the
7861 # line number we saved from there.
7862 $file .= ':' . $var_line{$symbol};
7864 elsif (defined $configure_vars{$symbol})
7866 # SYMBOL is a variable defined in configure.ac, so add the
7867 # appropriate line number.
7868 $file = $configure_vars{$symbol};
7872 # Couldn't find the line number.
7874 warn $file, ": @args\n";
7883 # Like am_error, but while scanning configure.ac.
7886 # FIXME: can run in subdirs.
7887 warn "$me: $configure_ac: @_\n";
7891 # Error message with line number referring to configure.ac.
7892 sub am_conf_line_error
7894 my ($file, $line, @args) = @_;
7898 warn "$file: $line: @args\n";
7903 &am_conf_error (@args);
7907 # Warning message with line number referring to configure.ac.
7908 # Does not affect exit_status
7909 sub am_conf_line_warning
7911 my $saved_exit_status = $exit_status;
7912 &am_conf_line_error (@_);
7913 $exit_status = $saved_exit_status;
7916 # Tell user where our aclocal.m4 is, but only once.
7917 sub keyed_aclocal_warning
7920 warn "$me: macro `$key' can be generated by `aclocal'\n";
7923 # Print usage information.
7927 Usage: $0 [OPTION] ... [Makefile]...
7929 Generate Makefile.in for configure from Makefile.am.
7932 --help print this help, then exit
7933 --version print version number, then exit
7934 -v, --verbose verbosely list files processed
7935 -o, --output-dir=DIR put generated Makefile.in's into DIR
7936 --no-force only update Makefile.in's that are out of date
7938 Dependency tracking:
7939 -i, --ignore-deps disable dependency tracking code
7940 --include-deps enable dependency tracking code
7943 --cygnus assume program is part of Cygnus-style tree
7944 --foreign set strictness to foreign
7945 --gnits set strictness to gnits
7946 --gnu set strictness to gnu
7949 -a, --add-missing add missing standard files to package
7950 --amdir=DIR directory storing config files
7951 -c, --copy with -a, copy missing files (default is symlink)
7952 -f, --force-missing force update of standard files
7957 foreach my $iter (sort ((@common_files, @common_sometimes)))
7959 push (@lcomm, $iter) unless $iter eq $last;
7963 my ($one, $two, $three, $four, $max);
7964 print "\nFiles which are automatically distributed, if found:\n";
7965 format USAGE_FORMAT =
7966 @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<
7967 $one, $two, $three, $four
7969 $~ = "USAGE_FORMAT";
7970 $max = int (($#lcomm + 1) / 4);
7972 for (my $i = 0; $i < $max; ++$i)
7975 $two = $lcomm[$max + $i];
7976 $three = $lcomm[2 * $max + $i];
7977 $four = $lcomm[3 * $max + $i];
7981 my $mod = ($#lcomm + 1) % 4;
7984 $one = $lcomm[$max];
7985 $two = ($mod > 1) ? $lcomm[2 * $max] : '';
7986 $three = ($mod > 2) ? $lcomm[3 * $max] : '';
7987 $four = ($mod > 3) ? $lcomm[4 * $max] : '';
7991 print "\nReport bugs to <bug-automake\@gnu.org>.\n";
7998 # Print version information
8002 automake (GNU $PACKAGE) $VERSION
8003 Written by Tom Tromey <tromey\@cygnus.com>.
8005 Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
8006 Free Software Foundation, Inc.
8007 This is free software; see the source for copying conditions. There is NO
8008 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.