5 eval 'exec @PERL@ -S $0 ${1+"$@"}'
8 # automake - create Makefile.in from Makefile.am
9 # Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
10 # Free Software Foundation, Inc.
12 # This program is free software; you can redistribute it and/or modify
13 # it under the terms of the GNU General Public License as published by
14 # the Free Software Foundation; either version 2, or (at your option)
17 # This program is distributed in the hope that it will be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # GNU General Public License for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, write to the Free Software
24 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
27 # Originally written by David Mackenzie <djm@gnu.ai.mit.edu>.
28 # Perl reimplementation by Tom Tromey <tromey@cygnus.com>.
34 my $prefix = "@prefix@";
35 my $perllibdir = $ENV{'perllibdir'} || "@datadir@/@PACKAGE@";
36 unshift @INC, "$perllibdir";
40 struct (# Short name of the language (c, f77...).
42 # Nice name of the language (C, Fortran 77...).
45 # List of configure variables which must be defined.
49 # `pure' is `1' or `'. A `pure' language is one where, if
50 # all the files in a directory are of that language, then we
51 # do not require the C compiler or any code to call it.
56 # Name of the compiling variable (COMPILE).
58 # Content of the compiling variable.
60 # Flag to require compilation without linking (-c).
61 'compile_flag' => '$',
62 'derived_autodep' => '$',
66 # Name of the linking variable (LINK).
68 # Content of the linking variable.
71 # Name of the linker variable (LD).
73 # Content of the linker variable ($(CC)).
76 # Flag to specify the output file (-o).
84 if (defined $self->_finish)
94 use strict 'vars', 'subs';
98 my $me = basename ($0);
105 # Parameters set by configure. Not to be changed. NOTE: assign
106 # VERSION as string so that eg version 0.30 will print correctly.
107 my $VERSION = "@VERSION@";
108 my $PACKAGE = "@PACKAGE@";
109 my $prefix = "@prefix@";
110 my $libdir = "@datadir@/@PACKAGE@";
113 my $IGNORE_PATTERN = '^\s*##([^#\n].*)?\n';
114 my $WHITE_PATTERN = '^\s*$';
115 my $COMMENT_PATTERN = '^#';
116 my $TARGET_PATTERN='[$a-zA-Z_.][-.a-zA-Z0-9_(){}/$]*';
117 # A rule has three parts: a list of targets, a list of dependencies,
118 # and optionally actions.
120 "^($TARGET_PATTERN(?:(?:\\\\\n|\\s)+$TARGET_PATTERN)*) *:([^=].*|)\$";
122 my $SUFFIX_RULE_PATTERN = '^\.([a-zA-Z0-9]+)\.([a-zA-Z0-9]+)$';
123 # Only recognize leading spaces, not leading tabs. If we recognize
124 # leading tabs here then we need to make the reader smarter, because
125 # otherwise it will think rules like `foo=bar; \' are errors.
126 my $MACRO_PATTERN = '^[A-Za-z0-9_@]+$';
127 my $ASSIGNMENT_PATTERN = '^ *([^ \t=:+]*)\s*([:+]?)=\s*(.*)$';
128 # This pattern recognizes a Gnits version id and sets $1 if the
129 # release is an alpha release. We also allow a suffix which can be
130 # used to extend the version number with a "fork" identifier.
131 my $GNITS_VERSION_PATTERN = '\d+\.\d+([a-z]|\.\d+)?(-[A-Za-z0-9]+)?';
132 my $IF_PATTERN = '^if\s+(!?)\s*([A-Za-z][A-Za-z0-9_]*)\s*(?:#.*)?$';
133 my $ELSE_PATTERN = '^else(?:\s+(!?)\s*([A-Za-z][A-Za-z0-9_]*))?\s*(?:#.*)?$';
134 my $ENDIF_PATTERN = '^endif(?:\s+(!?)\s*([A-Za-z][A-Za-z0-9_]*))?\s*(?:#.*)?$';
135 my $PATH_PATTERN='(\w|[/.-])+';
136 # This will pass through anything not of the prescribed form.
137 my $INCLUDE_PATTERN = ('^include\s+'
138 . '((\$\(top_srcdir\)/' . $PATH_PATTERN . ')'
139 . '|(\$\(srcdir\)/' . $PATH_PATTERN . ')'
140 . '|([^/\$]' . $PATH_PATTERN. '))\s*(#.*)?$');
142 # Some regular expressions. One reason to put them here is that it
143 # makes indentation work better in Emacs.
144 my $AC_CONFIG_AUX_DIR_PATTERN = 'AC_CONFIG_AUX_DIR\(([^)]+)\)';
145 my $AM_INIT_AUTOMAKE_PATTERN = 'AM_INIT_AUTOMAKE\([^,]*,([^,)]+)[,)]';
146 my $AM_PACKAGE_VERSION_PATTERN = '^\s*\[?([^]\s]+)\]?\s*$';
147 # Note that there is no AC_PATH_TOOL. But we don't really care.
148 my $AC_CHECK_PATTERN = 'AC_(CHECK|PATH)_(PROG|PROGS|TOOL)\(\[?(\w+)';
149 my $AM_MISSING_PATTERN = 'AM_MISSING_PROG\(\[?(\w+)';
150 # Just check for alphanumeric in AC_SUBST. If you do AC_SUBST(5),
152 my $AC_SUBST_PATTERN = 'AC_SUBST\(\[?(\w+)';
153 my $AM_CONDITIONAL_PATTERN = 'AM_CONDITIONAL\(\[?(\w+)';
155 # Constants to define the "strictness" level.
160 # Values for AC_CANONICAL_*
161 my $AC_CANONICAL_HOST = 1;
162 my $AC_CANONICAL_SYSTEM = 2;
164 # Values indicating when something should be cleaned. Right now we
165 # only need to handle `mostly'- and `dist'-clean; add more as
167 my $MOSTLY_CLEAN = 0;
170 # Files installed by libtoolize.
171 my @libtoolize_files = ('ltmain.sh', 'config.guess', 'config.sub');
172 # ltconfig appears here for compatibility with old versions of libtool.
173 my @libtoolize_sometimes = ('ltconfig', 'ltcf-c.sh', 'ltcf-cxx.sh',
176 # Commonly found files we look for and automatically include in
180 'README', 'THANKS', 'TODO', 'NEWS', 'COPYING', 'COPYING.LIB',
181 'INSTALL', 'ABOUT-NLS', 'ChangeLog', 'configure.ac',
182 'configure.in', 'configure', 'config.guess', 'config.sub',
183 'AUTHORS', 'BACKLOG', 'ABOUT-GNU', 'libversion.in',
184 'mdate-sh', 'mkinstalldirs', 'install-sh', 'texinfo.tex',
185 'ansi2knr.c', 'ansi2knr.1', 'elisp-comp',
186 # ltconfig appears here for compatibility with old versions
188 'ylwrap', 'acinclude.m4', @libtoolize_files, @libtoolize_sometimes,
189 'missing', 'depcomp', 'compile', 'py-compile'
192 # Commonly used files we auto-include, but only sometimes.
193 my @common_sometimes =
195 'aclocal.m4', 'acconfig.h', 'config.h.top',
196 'config.h.bot', 'stamp-h.in', 'stamp-vti'
199 # Copyright on generated Makefile.ins.
200 my $gen_copyright = "\
201 # Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
202 # Free Software Foundation, Inc.
203 # This Makefile.in is free software; the Free Software Foundation
204 # gives unlimited permission to copy and/or distribute it,
205 # with or without modifications, as long as this notice is preserved.
207 # This program is distributed in the hope that it will be useful,
208 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
209 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
210 # PARTICULAR PURPOSE.
213 # These constants are returned by lang_*_rewrite functions.
214 # LANG_SUBDIR means that the resulting object file should be in a
215 # subdir if the source file is. In this case the file name cannot
216 # have `..' components.
218 my $LANG_PROCESS = 1;
221 # Directories installed during 'install-exec' phase.
240 # Map from obsolete macros to hints for new macros.
241 # If you change this, change the corresponding list in aclocal.in.
242 # FIXME: should just put this into a single file.
243 my %obsolete_macros =
245 'AC_FEATURE_CTYPE' => "use `AC_HEADER_STDC'",
246 'AC_FEATURE_ERRNO' => "add `strerror' to `AC_REPLACE_FUNCS(...)'",
247 'AC_FEATURE_EXIT' => '',
248 'AC_SYSTEM_HEADER' => '',
250 # Note that we do not handle this one, because it is still run
251 # from AM_CONFIG_HEADER. So we deal with it specially in
252 # &scan_autoconf_files.
253 # 'AC_CONFIG_HEADER' => "use `AM_CONFIG_HEADER'",
255 'fp_C_PROTOTYPES' => "use `AM_C_PROTOTYPES'",
256 'fp_PROG_CC_STDC' => "use `AM_PROG_CC_STDC'",
257 'fp_PROG_INSTALL' => "use `AC_PROG_INSTALL'",
258 'fp_WITH_DMALLOC' => "use `AM_WITH_DMALLOC'",
259 'fp_WITH_REGEX' => "use `AM_WITH_REGEX'",
260 'gm_PROG_LIBTOOL' => "use `AM_PROG_LIBTOOL'",
261 'jm_MAINTAINER_MODE' => "use `AM_MAINTAINER_MODE'",
262 'md_TYPE_PTRDIFF_T' => "use `AM_TYPE_PTRDIFF_T'",
263 'ud_PATH_LISPDIR' => "use `AM_PATH_LISPDIR'",
264 'ud_GNU_GETTEXT' => "use `AM_GNU_GETTEXT'",
266 # Now part of autoconf proper, under a different name.
267 'AM_FUNC_FNMATCH' => "use `AC_FUNC_FNMATCH'",
268 'fp_FUNC_FNMATCH' => "use `AC_FUNC_FNMATCH'",
269 'AM_SANITY_CHECK_CC' => "automatically done by `AC_PROG_CC'",
270 'AM_PROG_INSTALL' => "use `AC_PROG_INSTALL'",
271 'AM_EXEEXT' => "use `AC_EXEEXT'",
272 'AM_CYGWIN32' => "use `AC_CYGWIN'",
273 'AM_MINGW32' => "use `AC_MINGW32'",
274 'AM_FUNC_MKTIME' => "use `AC_FUNC_MKTIME'",
276 # These aren't quite obsolete.
280 # Regexp to match the above macros.
281 my $obsolete_rx = '(\b' . join ('\b|\b', keys %obsolete_macros) . '\b)';
285 ## ---------------------------------- ##
286 ## Variables related to the options. ##
287 ## ---------------------------------- ##
289 # TRUE if we should always generate Makefile.in.
290 my $force_generation = 1;
292 # Strictness level as set on command line.
293 my $default_strictness = $GNU;
295 # Name of strictness level, as set on command line.
296 my $default_strictness_name = 'gnu';
298 # This is TRUE if automatic dependency generation code should be
299 # included in generated Makefile.in.
300 my $cmdline_use_dependencies = 1;
302 # TRUE if in verbose mode.
305 # This holds our (eventual) exit status. We don't actually exit until
306 # we have processed all input files.
309 # From the Perl manual.
310 my $symlink_exists = (eval 'symlink ("", "");', $@ eq '');
312 # TRUE if missing standard files should be installed.
315 # TRUE if we should copy missing files; otherwise symlink if possible.
316 my $copy_missing = 0;
318 # TRUE if we should always update files that we know about.
319 my $force_missing = 0;
322 ## ---------------------------------------- ##
323 ## Variables filled during files scanning. ##
324 ## ---------------------------------------- ##
326 # Name of the top autoconf input: `configure.ac' or `configure.in'.
327 my $configure_ac = '';
329 # Files found by scanning configure.ac for LIBOBJS.
332 # True if AM_C_PROTOTYPES appears in configure.ac.
333 my $am_c_prototypes = 0;
335 # Names used in AC_CONFIG_HEADER call. @config_fullnames holds the
336 # name which appears in AC_CONFIG_HEADER, colon and all.
337 # @config_names holds the file names. @config_headers holds the '.in'
338 # files. Ordinarily these are similar, but they can be different if
339 # the weird "NAME:FILE" syntax is used.
340 my @config_fullnames = ();
341 my @config_names = ();
342 my @config_headers = ();
343 # Line number at which AC_CONFIG_HEADER appears in configure.ac.
344 my $config_header_line = 0;
346 # Directory where output files go. Actually, output files are
347 # relative to this directory.
348 my $output_directory = '.';
350 # List of Makefile.am's to process, and their corresponding outputs.
351 my @input_files = ();
352 my %output_files = ();
354 # Complete list of Makefile.am's that exist.
355 my @configure_input_files = ();
357 # List of files in AC_OUTPUT without Makefile.am, and their outputs.
358 my @other_input_files = ();
359 # Line number at which AC_OUTPUT seen.
360 my $ac_output_line = 0;
362 # List of directories to search for configure-required files. This
363 # can be set by AC_CONFIG_AUX_DIR.
364 my @config_aux_path = ('.', '..', '../..');
365 my $config_aux_dir = '';
366 my $config_aux_dir_set_in_configure_in = 0;
368 # Whether AM_GNU_GETTEXT has been seen in configure.ac.
369 my $seen_gettext = 0;
370 # Line number at which AM_GNU_GETTEXT seen.
371 my $ac_gettext_line = 0;
373 # Whether ALL_LINGUAS has been seen.
374 my $seen_linguas = '';
376 my $all_linguas = '';
377 # Line number at which it appears.
378 my $all_linguas_line = 0;
380 # TRUE if AC_DECL_YYTEXT was seen.
381 my $seen_decl_yytext = 0;
383 # TRUE if we've seen AC_CANONICAL_(HOST|SYSTEM). The presence of
384 # AC_CHECK_TOOL also sets this.
385 my $seen_canonical = 0;
387 # TRUE if we've seen AC_PROG_LIBTOOL.
388 my $seen_libtool = 0;
389 my $libtool_line = 0;
391 # TRUE if we've seen AM_MAINTAINER_MODE.
392 my $seen_maint_mode = 0;
394 # Actual version we've seen.
395 my $package_version = '';
397 # Line number where we saw version definition.
398 my $package_version_line = 0;
400 # TRUE if we've seen AM_PATH_LISPDIR.
401 my $seen_lispdir = 0;
403 # TRUE if we've seen AM_PATH_PYTHON.
404 my $seen_pythondir = 0;
406 # TRUE if we've seen AC_EXEEXT.
409 # TRUE if we've seen AC_OBJEXT.
412 # TRUE if we've seen AC_ENABLE_MULTILIB.
413 my $seen_multilib = 0;
415 # TRUE if we've seen AM_PROG_CC_C_O
418 # TRUE if we've seen AM_INIT_AUTOMAKE.
419 my $seen_init_automake = 0;
421 # Hash table of discovered configure substitutions. Keys are names,
422 # values are `FILE:LINE' strings which are used by error message
424 my %configure_vars = ();
426 # This is used to keep track of which variable definitions we are
427 # scanning. It is only used in certain limited ways, but it has to be
428 # global. It is declared just for documentation purposes.
429 my %vars_scanned = ();
431 # TRUE if --cygnus seen.
434 # Hash table of AM_CONDITIONAL variables seen in configure.
435 my %configure_cond = ();
437 # This maps extensions onto language names.
438 my %extension_map = ();
440 # List of the DIST_COMMON files we discovered while reading
442 my $configure_dist_common = '';
444 # This maps languages names onto objects.
447 # List of targets we must always output.
448 # FIXME: Complete, and remove falsely required targets.
449 my %required_targets =
460 # FIXME: Not required, temporary hacks.
461 # Well, actually they are sort of required: the -recursive
462 # targets will run them anyway...
465 'install-data-am' => 1,
466 'install-exec-am' => 1,
467 'installcheck-am' => 1,
475 ################################################################
477 ## ------------------------------------------ ##
478 ## Variables reset by &initialize_per_input. ##
479 ## ------------------------------------------ ##
481 # Basename and relative dir of the input file.
485 # Same but wrt Makefile.in.
489 # These two variables are used when generating each Makefile.in.
490 # They hold the Makefile.in until it is ready to be printed.
497 # Suffixes found during a run.
500 # Handling the variables.
503 # - $var_value{$VAR}{$COND} is its value associated to $COND,
504 # - $var_line{$VAR} is where it has been defined,
505 # - $var_comment{$VAR} are the comments associated to it.
506 # - $var_type{$VAR} is how it has been defined (`', `+', or `:'),
507 # - $var_is_am{$VAR} is true if the variable is owned by Automake.
514 # This holds a 1 if a particular variable was examined.
517 # This holds the names which are targets. These also appear in
521 # Same as %VAR_VALUE, but for targets.
522 my %target_conditional;
524 # This is the conditional stack.
527 # This holds the set of included files.
530 # This holds a list of directories which we must create at `dist'
531 # time. This is used in some strange scenarios involving weird
532 # AC_OUTPUT commands.
535 # List of dependencies for the obvious targets.
540 # Holds the dependencies of targets which dependencies are factored.
541 # Typically, `.PHONY' will appear in plenty of *.am files, but must
542 # be output once. Arguably all pure dependencies could be subject
543 # to this factorization, but it is not unpleasant to have paragraphs
544 # in Makefile: keeping related stuff altogether.
547 # Holds the factored actions. Tied to %DEPENDENCIES, i.e., filled
548 # only when keys exists in %DEPENDENCIES.
551 # A list of files deleted by `maintainer-clean'.
552 my @maintainer_clean_files;
554 # Keys in this hash table are object files or other files in
555 # subdirectories which need to be removed. This only holds files
556 # which are created by compilations. The value in the hash indicates
557 # when the file should be removed.
558 my %compile_clean_files;
560 # Value of `$(SOURCES)', used by tags.am.
562 # Sources which go in the distribution.
565 # This hash maps object file names onto their corresponding source
566 # file names. This is used to ensure that each object is created
567 # by a single source file.
570 # This keeps track of the directories for which we've already
571 # created `.dirstamp' code.
581 # Options from AUTOMAKE_OPTIONS.
584 # Whether or not dependencies are handled. Can be further changed
586 my $use_dependencies;
588 # All yacc and lex source filenames for this directory. Use
589 # filenames instead of raw count so that multiple instances are
590 # counted correctly (eg one yacc file can appear in multiple
591 # programs without harm).
595 # This is a list of all targets to run during "make dist".
598 # Keys in this hash are the basenames of files which must depend
602 # This maps the source extension of a suffix rule to its
603 # corresponding output extension.
606 # This is the name of the redirect `all' target to use.
609 # This keeps track of which extensions we've seen (that we care
613 # This is random scratch space for the language finish functions.
614 # Don't randomly overwrite it; examine other uses of keys first.
615 my %language_scratch;
617 # We keep track of which objects need special (per-executable)
618 # handling on a per-language basis.
619 my %lang_specific_files;
621 # This is set when `handle_dist' has finished. Once this happens,
622 # we should no longer push on dist_common.
625 # True if we need `LINK' defined. This is a hack.
628 # This is the list of such variables to output.
629 # FIXME: Might be useless actually.
632 # Was get_object_extension run?
633 # FIXME: This is a hack. a better switch should be found.
634 my $get_object_extension_was_run;
637 ## --------------------------------- ##
638 ## Forward subroutine declarations. ##
639 ## --------------------------------- ##
640 sub register_language (%);
641 sub file_contents_internal ($$%);
644 # &initialize_per_input ()
645 # ------------------------
646 # (Re)-Initialize per-Makefile.am variables.
647 sub initialize_per_input ()
650 $am_relative_dir = '';
657 $output_trailer = '';
673 %target_conditional = ();
681 $am_relative_dir = '';
697 # Installing/uninstalling.
698 'install-data-am' => [],
699 'install-exec-am' => [],
700 'uninstall-am' => [],
703 'uninstall-man' => [],
705 'install-info' => [],
706 'install-info-am' => [],
707 'uninstall-info' => [],
709 'installcheck-am' => [],
713 'mostlyclean-am' => [],
714 'maintainer-clean-am' => [],
715 'distclean-am' => [],
718 'maintainer-clean' => [],
729 @maintainer_clean_files = ();
740 $strictness = $default_strictness;
741 $strictness_name = $default_strictness_name;
745 $use_dependencies = $cmdline_use_dependencies;
758 %extension_seen = ();
760 %language_scratch = ();
762 %lang_specific_files = ();
764 $handle_dist_run = 0;
770 $get_object_extension_was_run = 0;
772 %compile_clean_files = ();
776 ################################################################
778 # Initialize our list of languages that are internally supported.
781 register_language ('name' => 'c',
783 'config_vars' => ['CC'],
787 'compiler' => 'COMPILE',
788 'compile' => '$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)',
792 'link' => '$(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
793 'compile_flag' => '-c',
794 'extensions' => ['c'],
795 '_finish' => \&lang_c_finish);
798 register_language ('name' => 'cxx',
800 'config_vars' => ['CXX'],
801 'linker' => 'CXXLINK',
802 'link' => '$(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
804 'flags' => 'CXXFLAGS',
805 'compile' => '$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)',
806 'compiler' => 'CXXCOMPILE',
807 'compile_flag' => '-c',
808 'output_flag' => '-o',
812 'extensions' => ['c++', 'cc', 'cpp', 'cxx', 'C']);
815 register_language ('name' => 'objc',
816 'Name' => 'Objective C',
817 'config_vars' => ['OBJC'],
818 'linker' => 'OBJCLINK',,
819 'link' => '$(OBJCLD) $(AM_OBJCFLAGS) $(OBJCFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
821 'flags' => 'OBJCFLAGS',
822 'compile' => '$(OBJC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_OBJCFLAGS) $(OBJCFLAGS)',
823 'compiler' => 'OBJCCOMPILE',
824 'compile_flag' => '-c',
825 'output_flag' => '-o',
829 'extensions' => ['m']);
832 register_language ('name' => 'header',
834 'extensions' => ['h', 'H', 'hxx', 'h++', 'hh', 'hpp', 'inc'],
836 '_finish' => sub { });
838 # For now, yacc and lex can't be handled on a per-exe basis.
841 register_language ('name' => 'yacc',
844 'config_vars' => ['YACC'],
845 'derived_autodep' => 'yes',
846 'extensions' => ['y'],
847 '_finish' => \&lang_yacc_finish);
848 register_language ('name' => 'yaccxx',
849 'Name' => 'Yacc (C++)',
850 'config_vars' => ['YACC'],
851 'linker' => 'CXXLINK',
852 'derived_autodep' => 'yes',
853 'extensions' => ['y++', 'yy', 'yxx', 'ypp'],
854 '_finish' => \&lang_yacc_finish);
857 register_language ('name' => 'lex',
860 'config_vars' => ['LEX'],
861 'derived_autodep' => 'yes',
862 'extensions' => ['l'],
863 '_finish' => \&lang_lex_finish);
864 register_language ('name' => 'lexxx',
865 'Name' => 'Lex (C++)',
866 'config_vars' => ['LEX'],
867 'linker' => 'CXXLINK',
868 'derived_autodep' => 'yes',
869 'extensions' => ['l++', 'll', 'lxx', 'lpp'],
870 '_finish' => \&lang_lex_finish);
873 register_language ('name' => 'asm',
874 'Name' => 'Assembler',
875 'config_vars' => ['AS', 'ASFLAGS'],
877 'flags' => 'ASFLAGS',
878 # Users can set AM_ASFLAGS to includes DEFS, INCLUDES,
879 # or anything else required. They can also set AS.
880 'compile' => '$(AS) $(AM_ASFLAGS) $(ASFLAGS)',
881 'compiler' => 'ASCOMPILE',
882 'compile_flag' => '-c',
883 'extensions' => ['s', 'S'],
885 # With assembly we still use the C linker.
886 '_finish' => \&lang_c_finish);
889 register_language ('name' => 'f77',
890 'Name' => 'Fortran 77',
891 'linker' => 'F77LINK',
892 'link' => '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
894 'compile' => '$(F77) $(AM_FFLAGS) $(FFLAGS)',
895 'compiler' => 'F77COMPILE',
896 'compile_flag' => '-c',
897 'output_flag' => '-o',
901 'extensions' => ['f', 'for', 'f90']);
903 # Preprocessed Fortran 77
905 # The current support for preprocessing Fortran 77 just involves
906 # passing `$(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS)
907 # $(CPPFLAGS)' as additional flags to the Fortran 77 compiler, since
908 # this is how GNU Make does it; see the `GNU Make Manual, Edition 0.51
909 # for `make' Version 3.76 Beta' (specifically, from info file
910 # `(make)Catalogue of Rules').
912 # A better approach would be to write an Autoconf test
913 # (i.e. AC_PROG_FPP) for a Fortran 77 preprocessor, because not all
914 # Fortran 77 compilers know how to do preprocessing. The Autoconf
915 # macro AC_PROG_FPP should test the Fortran 77 compiler first for
916 # preprocessing capabilities, and then fall back on cpp (if cpp were
918 register_language ('name' => 'ppf77',
919 'Name' => 'Preprocessed Fortran 77',
920 'config_vars' => ['F77'],
921 'linker' => 'F77LINK',
922 'link' => '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
926 'compiler' => 'PPF77COMPILE',
927 'compile' => '$(F77) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FFLAGS) $(FFLAGS)',
928 'compile_flag' => '-c',
929 'output_flag' => '-o',
931 'extensions' => ['F']);
934 register_language ('name' => 'ratfor',
936 'config_vars' => ['F77'],
937 'linker' => 'F77LINK',
938 'link' => '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
943 'compile' => '$(F77) $(AM_FFLAGS) $(FFLAGS) $(AM_RFLAGS) $(RFLAGS)',
944 'compiler' => 'RCOMPILE',
945 'compile_flag' => '-c',
946 'output_flag' => '-o',
948 'extensions' => ['r']);
951 register_language ('name' => 'java',
953 'config_vars' => ['GCJ'],
954 'linker' => 'GCJLINK',
955 'link' => '$(GCJLD) $(AM_GCJFLAGS) $(GCJFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
957 'flags' => 'GCJFLAGS',
958 'compile' => '$(GCJ) $(AM_GCJFLAGS) $(GCJFLAGS)',
959 'compiler' => 'GCJCOMPILE',
960 'compile_flag' => '-c',
961 'output_flag' => '-o',
965 'extensions' => ['java', 'class', 'zip', 'jar']);
967 ################################################################
969 # Parse command line.
972 # Do configure.ac scan only once.
973 &scan_autoconf_files;
975 die "$me: no `Makefile.am' found or specified\n"
978 # Now do all the work on each file.
979 # This guy must be local otherwise it's private to the loop.
982 foreach $am_file (@input_files)
984 if (! -f ($am_file . '.am'))
986 &am_error ("`" . $am_file . ".am' does not exist");
990 &generate_makefile ($output_files{$am_file}, $am_file);
996 # FIXME: This should be `my'ed next to its subs.
997 use vars '%require_file_found';
999 ################################################################
1001 # prog_error (@PRINT-ME)
1002 # ----------------------
1003 # Signal a programming error, display PRINT-ME, and exit 1.
1006 print STDERR "$me: programming error: @_\n";
1014 # Return LIST with no duplicates.
1019 foreach my $item (@_)
1021 if (! defined $seen{$item})
1032 # Return a configure-style substitution using the indicated text.
1033 # We do this to avoid having the substitutions directly in automake.in;
1034 # when we do that they are sometimes removed and this causes confusion
1039 return '@' . $text . '@';
1042 ################################################################
1046 # &backname ($REL-DIR)
1047 # --------------------
1048 # If I `cd $REL-DIR', then to come back, I should `cd $BACKPATH'.
1049 # For instance `src/foo' => `../..'.
1050 # Works with non strictly increasing paths, i.e., `src/../lib' => `..'.
1055 foreach (split (/\//, $file))
1057 next if $_ eq '.' || $_ eq '';
1067 return join ('/', @res) || '.';
1070 ################################################################
1072 # Parse command line.
1073 sub parse_arguments ()
1076 &set_strictness ('gnu');
1079 Getopt::Long::config ("bundling");
1080 Getopt::Long::GetOptions
1082 'version' => \&version,
1084 'libdir:s' => \$libdir,
1085 'gnu' => sub { &set_strictness ('gnu'); },
1086 'gnits' => sub { &set_strictness ('gnits'); },
1087 'cygnus' => \$cygnus_mode,
1088 'foreign' => sub { &set_strictness ('foreign'); },
1089 'include-deps' => sub { $cmdline_use_dependencies = 1; },
1090 'i|ignore-deps' => sub { $cmdline_use_dependencies = 0; },
1091 'no-force' => sub { $force_generation = 0; },
1092 'f|force-missing'=> \$force_missing,
1093 'o|output-dir:s' => \$output_directory,
1094 'a|add-missing' => \$add_missing,
1095 'c|copy' => \$copy_missing,
1096 'v|verbose' => \$verbose,
1097 'Werror' => sub { $SIG{"__WARN__"} = sub { die $_[0] } },
1098 'Wno-error' => sub { $SIG{"__WARN__"} = 'DEFAULT' }
1102 foreach my $arg (@ARGV)
1104 # Handle $local:$input syntax. Note that we only examine the
1105 # first ":" file to see if it is automake input; the rest are
1106 # just taken verbatim. We still keep all the files around for
1107 # dependency checking, however.
1108 my ($local, $input, @rest) = split (/:/, $arg);
1115 # Strip .in; later on .am is tacked on. That is how the
1116 # automake input file is found. Maybe not the best way, but
1117 # it is easy to explain.
1119 or die "$me: invalid input file name `$arg'\n.";
1121 push (@input_files, $input);
1122 $output_files{$input} = join (':', ($local, @rest));
1125 # Take global strictness from whatever we currently have set.
1126 $default_strictness = $strictness;
1127 $default_strictness_name = $strictness_name;
1130 ################################################################
1132 # Generate a Makefile.in given the name of the corresponding Makefile and
1133 # the name of the file output by config.status.
1134 sub generate_makefile
1136 my ($output, $makefile) = @_;
1138 # Reset all the Makefile.am related variables.
1139 &initialize_per_input;
1141 # Name of input file ("Makefile.am") and output file
1142 # ("Makefile.in"). These have no directory components.
1143 $am_file_name = basename ($makefile) . '.am';
1144 $in_file_name = basename ($makefile) . '.in';
1146 # $OUTPUT is encoded. If it contains a ":" then the first element
1147 # is the real output file, and all remaining elements are input
1148 # files. We don't scan or otherwise deal with these input file,
1149 # other than to mark them as dependencies. See
1150 # &scan_autoconf_files for details.
1151 my (@secondary_inputs);
1152 ($output, @secondary_inputs) = split (/:/, $output);
1154 $relative_dir = dirname ($output);
1155 $am_relative_dir = dirname ($makefile);
1157 &read_main_am_file ($makefile . '.am');
1158 if (&handle_options)
1160 # Fatal error. Just return, so we can continue with next file.
1164 # There are a few install-related variables that you should not define.
1165 foreach my $var ('PRE_INSTALL', 'POST_INSTALL', 'NORMAL_INSTALL')
1167 if (&variable_defined ($var) && !$var_is_am{$var})
1169 &am_line_error ($var, "`$var' should not be defined");
1173 # At the toplevel directory, we might need config.guess, config.sub
1174 # or libtool scripts (ltconfig and ltmain.sh).
1175 if ($relative_dir eq '.')
1177 # libtool requires some files.
1178 &require_conf_file_with_conf_line ($libtool_line, $FOREIGN,
1182 # AC_CANONICAL_HOST and AC_CANONICAL_SYSTEM need config.guess and
1184 &require_config_file ($FOREIGN, 'config.guess', 'config.sub')
1188 # We still need Makefile.in here, because sometimes the `dist'
1189 # target doesn't re-run automake.
1190 if ($am_relative_dir eq $relative_dir)
1192 # Only distribute the files if they are in the same subdir as
1193 # the generated makefile.
1194 &push_dist_common ($in_file_name, $am_file_name);
1197 push (@sources, '$(SOURCES)')
1198 if &variable_defined ('SOURCES');
1200 # If OBJEXT/EXEEXT were not set in configure.in, do it, it
1201 # simplifies our task, and anyway starting with Autoconf 2.50, it
1202 # will always be defined, and this code will be dead.
1203 $output_vars .= "EXEEXT =\n"
1204 unless $seen_exeext;
1205 $output_vars .= "OBJEXT = o\n"
1206 unless $seen_objext;
1208 # Must do this after reading .am file. See read_main_am_file to
1209 # understand weird tricks we play there with variables.
1210 &define_variable ('subdir', $relative_dir);
1212 # Check first, because we might modify some state.
1214 &check_gnu_standards;
1215 &check_gnits_standards;
1217 &handle_configure ($output, $makefile, @secondary_inputs);
1220 &handle_ltlibraries;
1224 # This must run first so that the ANSI2KNR definition is generated
1225 # before it is used by the _.c rules. We have to do this because
1226 # a variable which is used in a dependency must be defined before
1227 # the target, or else make won't properly see it.
1229 # This must be run after all the sources are scanned.
1232 # Re-init SOURCES. FIXME: other code shouldn't depend on this
1233 # (but currently does).
1234 macro_define ('SOURCES', 1, '', 'TRUE',
1235 join (' ', @sources), 'internal');
1236 &define_pretty_variable ('DIST_SOURCES', '', @dist_sources);
1248 &handle_minor_options;
1251 # This must come after most other rules.
1252 &handle_dist ($makefile);
1255 &do_check_merge_target;
1256 &handle_all ($output);
1259 if (&variable_defined('lib_LTLIBRARIES') &&
1260 &variable_defined('bin_PROGRAMS'))
1262 $output_rules .= "install-binPROGRAMS: install-libLTLIBRARIES\n\n";
1265 &handle_installdirs;
1267 &handle_factored_dependencies;
1271 if (! -d ($output_directory . '/' . $am_relative_dir))
1273 mkdir ($output_directory . '/' . $am_relative_dir, 0755);
1276 my ($out_file) = $output_directory . '/' . $makefile . ".in";
1277 if (! $force_generation && -e $out_file)
1279 my ($am_time) = (stat ($makefile . '.am'))[9];
1280 my ($in_time) = (stat ($out_file))[9];
1281 # FIXME: should cache these times.
1282 my ($conf_time) = (stat ($configure_ac))[9];
1283 # FIXME: how to do unsigned comparison?
1284 if ($am_time < $in_time || $am_time < $conf_time)
1286 # No need to update.
1289 if (-f 'aclocal.m4')
1291 my ($acl_time) = (stat _)[9];
1292 return if ($am_time < $acl_time);
1296 my $gm_file = new IO::File "> $out_file";
1299 warn "$me: ${am_file}.in: cannot write: $!\n";
1303 print "$me: creating ", $makefile, ".in\n" if $verbose;
1305 # In case we're running under MSWindows, don't write with CRLF
1306 # (as it causes problems for the dependency-file extraction in
1307 # AM_OUTPUT_DEPENDENCY_COMMANDS).
1310 print $gm_file $output_vars;
1311 # We make sure that `all:' is the first target.
1312 print $gm_file $output_all;
1313 print $gm_file $output_header;
1314 print $gm_file $output_rules;
1315 print $gm_file $output_trailer;
1317 if (! $gm_file->close)
1319 warn "$me: $am_file.in: cannot close: $!\n";
1325 ################################################################
1327 # Handle AUTOMAKE_OPTIONS variable. Return 1 on error, 0 otherwise.
1330 if (&variable_defined ('AUTOMAKE_OPTIONS'))
1332 foreach (&variable_value_as_list ('AUTOMAKE_OPTIONS', ''))
1335 if ($_ eq 'gnits' || $_ eq 'gnu' || $_ eq 'foreign')
1337 &set_strictness ($_);
1339 elsif ($_ eq 'cygnus')
1345 # An option like "../lib/ansi2knr" is allowed. With
1346 # no path prefix, we assume the required programs are
1347 # in this directory. We save the actual option for
1349 $options{'ansi2knr'} = $_;
1351 elsif ($_ eq 'no-installman' || $_ eq 'no-installinfo'
1352 || $_ eq 'dist-shar' || $_ eq 'dist-zip'
1353 || $_ eq 'dist-tarZ' || $_ eq 'dist-bzip2'
1354 || $_ eq 'dejagnu' || $_ eq 'no-texinfo.tex'
1355 || $_ eq 'readme-alpha' || $_ eq 'check-news'
1356 || $_ eq 'subdir-objects' || $_ eq 'nostdinc')
1358 # Explicitly recognize these.
1360 elsif ($_ eq 'no-dependencies')
1362 $use_dependencies = 0;
1364 elsif (/(\d+)\.(\d+)([a-z]?)(-[A-Za-z0-9]+)?/)
1366 # Got a version number.
1368 my ($rmajor, $rminor, $ralpha, $rfork) = ($1, $2, $3, $4);
1370 &prog_error ("version is incorrect: $VERSION")
1371 if $VERSION !~ /(\d+)\.(\d+)([a-z]?)(-[A-Za-z0-9]+)?/;
1373 my ($tmajor, $tminor, $talpha, $tfork) = ($1, $2, $3, $4);
1378 # 2.0 is better than 1.0.
1379 # 1.2 is better than 1.1.
1380 # 1.2a is better than 1.2.
1381 # If we require 3.4n-foo then we require something
1382 # >= 3.4n, with the `foo' fork identifier.
1383 if ($rmajor > $tmajor
1384 || ($rmajor == $tmajor && $rminor > $tminor)
1385 || ($rminor == $tminor && $rminor == $tminor
1386 && $ralpha gt $talpha)
1387 || ($rfork ne '' && $rfork ne $tfork))
1389 &am_line_error ('AUTOMAKE_OPTIONS',
1390 "require version $_, but have $VERSION");
1396 &am_line_error ('AUTOMAKE_OPTIONS',
1397 "option `" . $_ . "\' not recognized");
1402 if ($strictness == $GNITS)
1404 $options{'readme-alpha'} = 1;
1405 $options{'check-news'} = 1;
1412 # get_object_extension ($OUT)
1413 # ---------------------------
1414 # Return object extension. Just once, put some code into the output.
1415 # OUT is the name of the output file
1416 sub get_object_extension
1420 # Maybe require libtool library object files.
1421 my $extension = '.$(OBJEXT)';
1422 $extension = '.lo' if ($out =~ /\.la$/);
1424 # Check for automatic de-ANSI-fication.
1425 $extension = '$U' . $extension
1426 if defined $options{'ansi2knr'};
1428 $get_object_extension_was_run = 1;
1434 # Call finish function for each language that was used.
1435 sub handle_languages
1437 if ($use_dependencies)
1439 # Include auto-dep code. Don't include it if DEP_FILES would
1441 if (&saw_sources_p (0) && keys %dep_files)
1443 # Set location of depcomp.
1444 &define_variable ('depcomp', "\$(SHELL) $config_aux_dir/depcomp");
1446 &require_config_file ($FOREIGN, 'depcomp');
1448 my @deplist = sort keys %dep_files;
1450 # We define this as a conditional variable because BSD
1451 # make can't handle backslashes for continuing comments on
1452 # the following line.
1453 &define_pretty_variable ('DEP_FILES', 'AMDEP_TRUE', @deplist);
1455 # Generate each `include' individually. Irix 6 make will
1456 # not properly include several files resulting from a
1457 # variable expansion; generating many separate includes
1459 $output_rules .= "\n";
1460 foreach my $iter (@deplist)
1462 $output_rules .= (subst ('AMDEP_TRUE')
1463 . subst ('_am_include')
1465 . subst ('_am_quote')
1467 . subst ('_am_quote')
1471 $output_rules .= &file_contents ('depend');
1476 &define_variable ('depcomp', '');
1481 # Is the c linker needed?
1483 foreach my $ext (sort keys %extension_seen)
1485 next unless $extension_map{$ext};
1487 my $lang = $languages{$extension_map{$ext}};
1489 # Get information on $LANG.
1490 my $pfx = $lang->autodep;
1491 my $fpfx = ($pfx eq '') ? 'CC' : $pfx;
1493 my $AMDEP = (($use_dependencies && $lang->autodep ne 'no')
1494 ? 'AMDEP' : 'FALSE');
1496 my %transform = ('EXT' => $ext,
1499 'LIBTOOL' => $seen_libtool,
1501 '-c' => $lang->compile_flag || '');
1503 # Generate the appropriate rules for this extension.
1504 if ($use_dependencies && $lang->autodep ne 'no'
1505 || defined $lang->compile)
1507 # Some C compilers don't support -c -o. Use it only if really
1509 my $output_flag = $lang->output_flag || '';
1512 && $lang->flags eq 'CFLAGS'
1513 && defined $options{'subdir-objects'});
1516 file_contents ('depend2',
1526 'COMPILE' => '$(' . $lang->compiler . ')',
1527 'LTCOMPILE' => '$(LT' . $lang->compiler . ')',
1528 '-o' => $output_flag);
1531 # Now include code for each specially handled object with this
1533 my %seen_files = ();
1534 foreach my $file (@{$lang_specific_files{$lang->name}})
1536 my ($derived, $source, $obj) = split (' ', $file);
1538 # We might see a given object twice, for instance if it is
1539 # used under different conditions.
1540 next if defined $seen_files{$obj};
1541 $seen_files{$obj} = 1;
1543 my $flags = $lang->flags || '';
1544 my $val = "${derived}_${flags}";
1546 (my $obj_compile = $lang->compile) =~ s/\(AM_$flags/\($val/;
1547 my $obj_ltcompile = '$(LIBTOOL) --mode=compile ' . $obj_compile;
1549 # We _need_ `-o' for per object rules.
1550 my $output_flag = $lang->output_flag || '-o';
1552 # Generate a transform which will turn suffix targets in
1553 # depend2.am into real targets for the particular objects we
1556 file_contents ('depend2',
1561 'SOURCE' => $source,
1563 'OBJOBJ' => "$obj.obj",
1564 'LTOBJ' => "$obj.lo",
1566 'COMPILE' => $obj_compile,
1567 'LTCOMPILE' => $obj_ltcompile,
1568 '-o' => $output_flag));
1571 # The rest of the loop is done once per language.
1572 next if defined $done{$lang};
1575 # Load the language dependent Makefile chunks.
1576 my %lang = map { uc ($_) => 0 } keys %languages;
1577 $lang{uc ($lang->name)} = 1;
1578 $output_rules .= file_contents ('lang-compile', %transform, %lang);
1580 # If the source to a program consists entirely of code from a
1581 # `pure' language, for instance C++ for Fortran 77, then we
1582 # don't need the C compiler code. However if we run into
1583 # something unusual then we do generate the C code. There are
1584 # probably corner cases here that do not work properly.
1585 # People linking Java code to Fortran code deserve pain.
1586 $needs_c ||= ! $lang->pure;
1588 define_compiler_variable ($lang)
1589 if ($lang->compile);
1591 define_linker_variable ($lang)
1594 foreach my $var (@{$lang->config_vars})
1596 am_error ($lang->Name
1597 . " source seen but `$var' not defined in"
1598 . " `$configure_ac'")
1599 if !exists $configure_vars{$var};
1602 # The compiler's flag must be a configure variable.
1603 define_configure_variable ($lang->flags)
1604 if (defined $lang->flags);
1606 # Call the finisher.
1610 # If the project is entirely C++ or entirely Fortran 77 (i.e., 1
1611 # suffix rule was learned), don't bother with the C stuff. But if
1612 # anything else creeps in, then use it.
1614 if $need_link || scalar keys %suffix_rules > 1;
1618 if (! defined $done{$languages{'c'}})
1620 &define_configure_variable ($languages{'c'}->flags);
1621 &define_compiler_variable ($languages{'c'});
1623 define_linker_variable ($languages{'c'});
1627 # Output a rule to build from a YACC source. The output from YACC is
1628 # compiled with C or C++, depending on the extension of the YACC file.
1629 sub output_yacc_build_rule
1631 my ($yacc_suffix, $use_ylwrap) = @_;
1633 (my $c_suffix = $yacc_suffix) =~ tr/y/c/;
1635 # Generate rule for c/c++.
1636 $output_rules .= &file_contents ('yacc',
1637 ('YLWRAP' => $use_ylwrap,
1638 'YACC_SUFFIX' => $yacc_suffix,
1639 'C_SUFFIX' => $c_suffix));
1642 sub output_lex_build_rule
1644 my ($lex_suffix, $use_ylwrap) = @_;
1646 (my $c_suffix = $lex_suffix) =~ tr/l/c/;
1648 $output_rules .= &file_contents ('lex',
1649 ('YLWRAP' => $use_ylwrap,
1650 'LEX_SUFFIX' => $lex_suffix,
1651 'C_SUFFIX' => $c_suffix));
1654 # Check to make sure a source defined in LIBOBJS is not explicitly
1655 # mentioned. This is a separate function (as opposed to being inlined
1656 # in handle_source_transform) because it isn't always appropriate to
1658 sub check_libobjs_sources
1660 my ($one_file, $unxformed) = @_;
1662 foreach my $prefix ('', 'EXTRA_', 'dist_', 'nodist_',
1663 'dist_EXTRA_', 'nodist_EXTRA_')
1666 if (&variable_defined ($prefix . $one_file . '_SOURCES'))
1668 @files = &variable_value_as_list (($prefix
1669 . $one_file . '_SOURCES'),
1672 elsif ($prefix eq '')
1674 @files = ($unxformed . '.c');
1681 foreach my $file (@files)
1683 if (defined $libsources{$file})
1685 &am_line_error ($prefix . $one_file . '_SOURCES',
1686 "automatically discovered file `$file' should not be explicitly mentioned");
1693 # ($LINKER, @OBJECTS)
1694 # handle_single_transform_list ($VAR, $DERIVED, $OBJ, @FILES)
1695 # -----------------------------------------------------------
1696 # Does much of the actual work for handle_source_transform.
1698 # $DERIVED is the name of resulting executable or library
1699 # $OBJ is the object extension (e.g., `$U.lo')
1700 # @FILES is the list of source files to transform
1702 # $LINKER is name of linker to use (empty string for default linker)
1703 # @OBJECTS are names of objects
1704 sub handle_single_transform_list ($$$@)
1706 my ($var, $derived, $obj, @files) = @_;
1708 my $nonansi_obj = $obj;
1709 $nonansi_obj =~ s/\$U//g;
1710 my %linkers_used = ();
1712 # Turn sources into objects.
1715 # Configure substitutions in _SOURCES variables are errors.
1718 &am_line_error ($var, "$var includes configure substitution `$_'");
1722 # If the source file is in a subdirectory then the `.o' is
1723 # put into the current directory.
1725 # Split file name into base and extension.
1726 next if ! /^(?:(.*)\/)?([^\/]*)\.(.*)$/;
1728 my $directory = $1 || '';
1732 # We must generate a rule for the object if it requires its own flags.
1734 my ($linker, $object);
1736 $extension = &derive_suffix ($extension);
1738 if ($extension_map{$extension} &&
1739 ($lang = $languages{$extension_map{$extension}}))
1741 &saw_extension ($extension);
1742 # Found the language, so see what it says.
1743 my $subr = 'lang_' . $lang->name . '_rewrite';
1744 # Note: computed subr call.
1745 my $r = & $subr ($directory, $base, $extension);
1746 # Skip this entry if we were asked not to process it.
1747 next if $r == $LANG_IGNORE;
1749 # Now extract linker and other info.
1750 $linker = $lang->linker;
1752 my $this_obj_ext = $lang->ansi ? $obj : $nonansi_obj;
1753 $object = $base . $this_obj_ext;
1755 if (defined $lang->flags
1756 && &variable_defined ($derived . '_' . $lang->flags))
1758 # We have a per-executable flag in effect for this
1759 # object. In this case we rewrite the object's
1760 # name to ensure it is unique. We also require
1761 # the `compile' program to deal with compilers
1762 # where `-c -o' does not work.
1764 # We choose the name `DERIVED_OBJECT' to ensure
1765 # (1) uniqueness, and (2) continuity between
1766 # invocations. However, this will result in a
1767 # name that is too long for losing systems, in
1768 # some situations. So we provide _SHORTNAME to
1771 my $dname = $derived;
1772 if (&variable_defined ($derived . '_SHORTNAME'))
1774 # FIXME: should use the same conditional as
1775 # the _SOURCES variable. But this is really
1776 # silly overkill -- nobody should have
1777 # conditional shortnames.
1778 $dname = &variable_value ($derived . '_SHORTNAME');
1780 $object = $dname . '-' . $object;
1782 &require_file ($FOREIGN, 'compile')
1783 if $lang->name eq 'c';
1785 &prog_error ("$lang->name flags defined without compiler")
1786 if ! defined $lang->compile;
1791 # If rewrite said it was ok, put the object into a
1793 if ($r == $LANG_SUBDIR && $directory ne '')
1795 $object = $directory . '/' . $object;
1798 # If doing dependency tracking, then we can't print
1799 # the rule. If we have a subdir object, we need to
1800 # generate an explicit rule. Actually, in any case
1801 # where the object is not in `.' we need a special
1802 # rule. The per-object rules in this case are
1803 # generated later, by handle_languages.
1804 if ($renamed || $directory ne '')
1806 my $obj_sans_ext = substr ($object, 0,
1807 - length ($this_obj_ext));
1808 push (@{$lang_specific_files{$lang->name}},
1809 "$derived $full $obj_sans_ext");
1812 elsif ($extension eq 'o')
1814 # This is probably the result of a direct suffix rule.
1815 # In this case we just accept the rewrite. FIXME:
1816 # this fails if we want libtool objects.
1817 $object = $base . '.' . $extension;
1822 # No error message here. Used to have one, but it was
1827 $linkers_used{$linker} = 1;
1829 push (@result, $object);
1831 if (defined $object_map{$object})
1833 if ($object_map{$object} ne $full)
1835 &am_error ("object `$object' created by `$full' and `$object_map{$object}'");
1841 $object_map{$object} = $full;
1843 # If file is in subdirectory, we need explicit
1845 if ($directory ne '' || $renamed)
1847 push (@dep_list, $full);
1850 # If resulting object is in subdir, we need to make
1851 # sure the subdir exists at build time.
1852 if ($object =~ /\//)
1854 # FIXME: check that $DIRECTORY is somewhere in the
1857 # We don't allow `..' in object file names for
1858 # *any* source, not just Java. For Java it just
1859 # doesn't make sense, but in general it is
1860 # a problem because we can't pick a good name for
1862 if ($object =~ /(\/|^)\.\.\//)
1864 &am_error ("`$full' contains `..' component but should not");
1867 # Make sure object is removed by `make mostlyclean'.
1868 $compile_clean_files{$object} = $MOSTLY_CLEAN;
1870 push (@dep_list, $directory . '/.dirstamp');
1872 # If we're generating dependencies, we also want
1873 # to make sure that the appropriate subdir of the
1874 # .deps directory is created.
1875 if ($use_dependencies)
1877 push (@dep_list, '.deps/' . $directory . '/.dirstamp');
1880 if (! defined $directory_map{$directory})
1882 $directory_map{$directory} = 1;
1884 # Directory must be removed by `make distclean'.
1885 $compile_clean_files{$directory . "/.dirstamp"} =
1887 $output_rules .= ($directory . "/.dirstamp:\n"
1888 . "\t\@\$(mkinstalldirs) $directory\n"
1889 . "\t\@: > $directory/.dirstamp\n");
1890 if ($use_dependencies)
1892 $output_rules .= ('.deps/' . $directory
1894 . "\t\@\$(mkinstalldirs) .deps/$directory\n"
1895 . "\t\@: > .deps/$directory/.dirstamp\n");
1900 &pretty_print_rule ($object . ':', "\t", @dep_list)
1901 if scalar @dep_list > 0;
1904 # Transform .o or $o file into .P file (for automatic
1907 && ($lang->autodep ne 'no'
1908 || $lang->derived_autodep eq 'yes'))
1910 my $depfile = $object;
1911 $depfile =~ s/\.([^.]*)$/.P$1/;
1912 $depfile =~ s/\$\(OBJEXT\)$/o/;
1913 $dep_files{'$(DEPDIR)/' . $depfile} = 1;
1917 return (&resolve_linker (%linkers_used), @result);
1922 # Handle SOURCE->OBJECT transform for one program or library.
1924 # canonical (transformed) name of object to build
1925 # actual name of object to build
1926 # object extension (ie either `.o' or `$o'.
1927 # Return result is name of linker variable that must be used.
1928 # Empty return means just use `LINK'.
1929 sub handle_source_transform
1931 # one_file is canonical name. unxformed is given name. obj is
1933 my ($one_file, $unxformed, $obj) = @_;
1937 if (&variable_defined ($one_file . "_OBJECTS"))
1939 &am_line_error ($one_file . '_OBJECTS',
1940 $one_file . '_OBJECTS', 'should not be defined');
1941 # No point in continuing.
1946 foreach my $prefix ('', 'EXTRA_', 'dist_', 'nodist_',
1947 'dist_EXTRA_', 'nodist_EXTRA_')
1949 my $var = $prefix . $one_file . "_SOURCES";
1951 if !variable_defined ($var);
1953 # We are going to define _OBJECTS variables using the prefix.
1954 # Then we glom them all together. So we can't use the null
1955 # prefix here as we need it later.
1956 my $xpfx = ($prefix eq '') ? 'am_' : $prefix;
1958 # Keep track of which prefixes we saw.
1959 $used_pfx{$xpfx} = 1
1960 unless $prefix =~ /EXTRA_/;
1962 push (@sources, '$(' . $prefix . $one_file . "_SOURCES)");
1963 push (@dist_sources, '$(' . $prefix . $one_file . "_SOURCES)")
1964 unless $prefix =~ /^nodist_/;
1965 foreach my $cond (variable_conditions ($var))
1967 my @files = &variable_value_as_list ($var, $cond);
1968 my ($temp, @result) =
1969 &handle_single_transform_list ($var, $one_file, $obj,
1971 # If there are no files to compile, don't require a linker (yet).
1975 # Define _OBJECTS conditionally.
1976 &define_pretty_variable ($xpfx . $one_file . '_OBJECTS',
1978 unless $prefix =~ /EXTRA_/;
1982 my @keys = sort keys %used_pfx;
1983 if (scalar @keys == 0)
1985 &define_variable ($one_file . "_SOURCES", $unxformed . ".c");
1986 push (@sources, $unxformed . '.c');
1987 push (@dist_sources, $unxformed . '.c');
1989 my ($temp, @result) =
1990 &handle_single_transform_list ($one_file . '_SOURCES',
1993 $linker = $temp if $linker eq '';
1994 &define_pretty_variable ($one_file . "_OBJECTS", '', @result)
1998 grep ($_ = '$(' . $_ . $one_file . '_OBJECTS)', @keys);
1999 &define_pretty_variable ($one_file . '_OBJECTS', '', @keys);
2002 # If we want to use `LINK' we must make sure it is defined.
2012 # handle_lib_objects ($XNAME, $VAR)
2013 # ---------------------------------
2014 # Special-case @ALLOCA@ and @LIBOBJS@ in _LDADD or _LIBADD variables.
2015 # Also, generate _DEPENDENCIES variable if appropriate.
2017 # transformed name of object being built, or empty string if no object
2018 # name of _LDADD/_LIBADD-type variable to examine
2019 # Returns 1 if LIBOBJS seen, 0 otherwise.
2020 sub handle_lib_objects
2022 my ($xname, $var) = @_;
2024 &prog_error ("handle_lib_objects: $var undefined")
2025 if ! &variable_defined ($var);
2028 foreach my $cond (&variable_conditions ($var))
2030 if (&handle_lib_objects_cond ($xname, $var, $cond))
2038 # Subroutine of handle_lib_objects: handle a particular condition.
2039 sub handle_lib_objects_cond
2041 my ($xname, $var, $cond) = @_;
2043 # We recognize certain things that are commonly put in LIBADD or
2047 my $seen_libobjs = 0;
2050 foreach my $lsearch (&variable_value_as_list ($var, $cond))
2052 # Skip -lfoo and -Ldir; these are explicitly allowed.
2053 next if $lsearch =~ /^-[lL]/;
2054 if (! $flagvar && $lsearch =~ /^-/)
2056 if ($var =~ /^(.*)LDADD$/)
2058 # Skip -dlopen and -dlpreopen; these are explicitly allowed.
2059 next if $lsearch =~ /^-dl(pre)?open$/;
2060 &am_line_error ($var, "linker flags such as `$lsearch' belong in `${1}LDFLAGS");
2064 # Only get this error once.
2066 &am_line_error ($var, "linker flags such as `$lsearch' belong in `${1}LDFLAGS");
2070 # Assume we have a file of some sort, and push it onto the
2071 # dependency list. Autoconf substitutions are not pushed;
2072 # rarely is a new dependency substituted into (eg) foo_LDADD
2073 # -- but "bad things (eg -lX11) are routinely substituted.
2074 # Note that LIBOBJS and ALLOCA are exceptions to this rule,
2075 # and handled specially below.
2076 push (@dep_list, $lsearch)
2077 unless $lsearch =~ /^\@.*\@$/;
2079 # Automatically handle @LIBOBJS@ and @ALLOCA@. Basically this
2080 # means adding entries to dep_files.
2081 if ($lsearch =~ /^\@(LT)?LIBOBJS\@$/)
2083 my $myobjext = ($1 ? 'l' : '') . 'o';
2085 push (@dep_list, $lsearch);
2087 if (! keys %libsources
2088 && ! &variable_defined ($1 . 'LIBOBJS'))
2090 &am_line_error ($var, "\@$1" . "LIBOBJS\@ seen but never set in `$configure_ac'");
2093 foreach my $iter (keys %libsources)
2095 if ($iter =~ /\.([cly])$/)
2097 &saw_extension ($1);
2098 &saw_extension ('c');
2101 if ($iter =~ /\.h$/)
2103 &require_file_with_line ($var, $FOREIGN, $iter);
2105 elsif ($iter ne 'alloca.c')
2107 my $rewrite = $iter;
2108 $rewrite =~ s/\.c$/.P$myobjext/;
2109 $dep_files{'$(DEPDIR)/' . $rewrite} = 1;
2110 ($rewrite = $iter) =~ s/(\W)/\\$1/g;
2111 $rewrite = "^" . $rewrite . "\$";
2112 # Only require the file if it is not a built source.
2113 if (! &variable_defined ('BUILT_SOURCES')
2114 || ! grep (/$rewrite/,
2115 &variable_value_as_list ('BUILT_SOURCES',
2118 &require_file_with_line ($var, $FOREIGN, $iter);
2123 elsif ($lsearch =~ /^\@(LT)?ALLOCA\@$/)
2125 my $myobjext = ($1 ? 'l' : '') . 'o';
2127 push (@dep_list, $lsearch);
2128 &am_line_error ($var,
2129 "\@$1" . "ALLOCA\@ seen but `AC_FUNC_ALLOCA' not in `$configure_ac'")
2130 if ! defined $libsources{'alloca.c'};
2131 $dep_files{'$(DEPDIR)/alloca.P' . $myobjext} = 1;
2132 &require_file_with_line ($var, $FOREIGN, 'alloca.c');
2133 &saw_extension ('c');
2137 if ($xname ne '' && ! &variable_defined ($xname . '_DEPENDENCIES', $cond))
2139 &define_pretty_variable ($xname . '_DEPENDENCIES', $cond, @dep_list);
2142 return $seen_libobjs;
2145 # Canonicalize the input parameter
2149 $string =~ tr/A-Za-z0-9_\@/_/c;
2153 # Canonicalize a name, and check to make sure the non-canonical name
2154 # is never used. Returns canonical name. Arguments are name and a
2155 # list of suffixes to check for.
2156 sub check_canonical_spelling
2158 my ($name, @suffixes) = @_;
2160 my $xname = &canonicalize ($name);
2161 if ($xname ne $name)
2163 foreach my $xt (@suffixes)
2165 &am_line_error ("$name$xt",
2166 "invalid variable `$name$xt'; "
2167 . "should be `$xname$xt'")
2168 if &variable_defined ("$name$xt");
2178 # Set up the compile suite.
2179 sub handle_compile ()
2182 unless $get_object_extension_was_run;
2185 my $default_includes = '';
2186 if (! defined $options{'nostdinc'})
2188 $default_includes = ' -I. -I$(srcdir)';
2190 if (&variable_defined ('CONFIG_HEADER'))
2192 foreach my $hdr (split (' ', &variable_value ('CONFIG_HEADER')))
2194 $default_includes .= ' -I' . dirname ($hdr);
2199 my (@mostly_rms, @dist_rms);
2200 foreach my $item (sort keys %compile_clean_files)
2202 if ($compile_clean_files{$item} == $MOSTLY_CLEAN)
2204 push (@mostly_rms, "\t-rm -f $item");
2206 elsif ($compile_clean_files{$item} == $DIST_CLEAN)
2208 push (@dist_rms, "\t-rm -f $item");
2212 &prog_error ("invalid entry in \%compile_clean_files");
2216 my ($coms, $vars, $rules) =
2217 &file_contents_internal (1, "$libdir/am/compile.am",
2218 ('DEFAULT_INCLUDES' => $default_includes,
2219 'MOSTLYRMS' => join ("\n", @mostly_rms),
2220 'DISTRMS' => join ("\n", @dist_rms)));
2221 $output_vars .= $vars;
2222 $output_rules .= "$coms$rules";
2226 # Output the libtool compilation rules.
2227 $output_rules .= &file_contents ('libtool');
2230 # Check for automatic de-ANSI-fication.
2231 if (defined $options{'ansi2knr'})
2233 if (! $am_c_prototypes)
2235 &am_line_error ('AUTOMAKE_OPTIONS',
2236 "option `ansi2knr' in use but `AM_C_PROTOTYPES' not in `$configure_ac'");
2237 &keyed_aclocal_warning ('AM_C_PROTOTYPES');
2238 # Only give this error once.
2239 $am_c_prototypes = 1;
2242 # topdir is where ansi2knr should be.
2243 if ($options{'ansi2knr'} eq 'ansi2knr')
2245 # Only require ansi2knr files if they should appear in
2247 &require_file_with_line ('AUTOMAKE_OPTIONS', $FOREIGN,
2248 'ansi2knr.c', 'ansi2knr.1');
2250 # ansi2knr needs to be built before subdirs, so unshift it.
2251 unshift (@all, '$(ANSI2KNR)');
2254 my $ansi2knr_dir = '';
2255 $ansi2knr_dir = dirname ($options{'ansi2knr'})
2256 if $options{'ansi2knr'} ne 'ansi2knr';
2258 $output_rules .= &file_contents ('ansi2knr',
2259 ('ANSI2KNR-DIR' => $ansi2knr_dir));
2266 # handle_programs ()
2267 # ------------------
2268 # Handle C programs.
2271 my @proglist = &am_install_var ('progs', 'PROGRAMS',
2272 'bin', 'sbin', 'libexec', 'pkglib',
2274 return if ! @proglist;
2276 my $seen_libobjs = 0;
2277 foreach my $one_file (@proglist)
2279 my $obj = &get_object_extension ($one_file);
2281 # Canonicalize names and check for misspellings.
2282 my $xname = &check_canonical_spelling ($one_file, '_LDADD', '_LDFLAGS',
2283 '_SOURCES', '_OBJECTS',
2286 my $linker = &handle_source_transform ($xname, $one_file, $obj);
2289 if (&variable_defined ($xname . "_LDADD"))
2291 if (&handle_lib_objects ($xname, $xname . '_LDADD'))
2299 # User didn't define prog_LDADD override. So do it.
2300 &define_variable ($xname . '_LDADD', '$(LDADD)');
2302 # This does a bit too much work. But we need it to
2303 # generate _DEPENDENCIES when appropriate.
2304 if (&variable_defined ('LDADD'))
2306 if (&handle_lib_objects ($xname, 'LDADD'))
2311 elsif (! &variable_defined ($xname . '_DEPENDENCIES'))
2313 &define_variable ($xname . '_DEPENDENCIES', '');
2318 if (&variable_defined ($xname . '_LIBADD'))
2320 &am_line_error ($xname . '_LIBADD',
2321 "use `" . $xname . "_LDADD', not `"
2322 . $xname . "_LIBADD'");
2325 if (! &variable_defined ($xname . '_LDFLAGS'))
2327 # Define the prog_LDFLAGS variable.
2328 &define_variable ($xname . '_LDFLAGS', '');
2331 # Determine program to use for link.
2333 if (&variable_defined ($xname . '_LINK'))
2335 $xlink = $xname . '_LINK';
2339 $xlink = $linker ? $linker : 'LINK';
2342 $output_rules .= &file_contents ('program',
2343 ('PROGRAM' => $one_file,
2344 'XPROGRAM' => $xname,
2345 'XLINK' => $xlink));
2348 if (&variable_defined ('LDADD') && &handle_lib_objects ('', 'LDADD'))
2355 foreach my $one_file (@proglist)
2357 my $xname = &canonicalize ($one_file);
2359 if (&variable_defined ($xname . '_LDADD'))
2361 &check_libobjs_sources ($xname, $xname . '_LDADD');
2363 elsif (&variable_defined ('LDADD'))
2365 &check_libobjs_sources ($xname, 'LDADD');
2372 # handle_libraries ()
2373 # -------------------
2375 sub handle_libraries
2377 my @liblist = &am_install_var ('libs', 'LIBRARIES',
2378 'lib', 'pkglib', 'noinst', 'check');
2379 return if ! @liblist;
2381 my %valid = &am_primary_prefixes ('LIBRARIES', 0, 'lib', 'pkglib',
2383 if (! defined $configure_vars{'RANLIB'})
2385 foreach my $key (keys %valid)
2387 if (&variable_defined ($key . '_LIBRARIES'))
2389 &am_line_error ($key . '_LIBRARIES', "library used but `RANLIB' not defined in `$configure_ac'");
2390 # Only get this error once. If this is ever printed,
2392 $configure_vars{'RANLIB'} = 'BUG';
2398 my $seen_libobjs = 0;
2399 foreach my $onelib (@liblist)
2401 # Check that the library fits the standard naming convention.
2402 if ($onelib !~ /^lib.*\.a$/)
2404 # FIXME should put line number here. That means mapping
2405 # from library name back to variable name.
2406 &am_error ("`$onelib' is not a standard library name");
2409 my $obj = &get_object_extension ($onelib);
2411 # Canonicalize names and check for misspellings.
2412 my $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_SOURCES',
2413 '_OBJECTS', '_DEPENDENCIES',
2416 if (! &variable_defined ($xlib . '_AR'))
2418 &define_variable ($xlib . '_AR', '$(AR) cru');
2421 if (&variable_defined ($xlib . '_LIBADD'))
2423 if (&handle_lib_objects ($xlib, $xlib . '_LIBADD'))
2430 # Generate support for conditional object inclusion in
2432 &define_variable ($xlib . "_LIBADD", '');
2435 if (&variable_defined ($xlib . '_LDADD'))
2437 &am_line_error ($xlib . '_LDADD',
2438 "use `" . $xlib . "_LIBADD', not `"
2439 . $xlib . "_LDADD'");
2442 # Make sure we at look at this.
2443 &examine_variable ($xlib . '_DEPENDENCIES');
2445 &handle_source_transform ($xlib, $onelib, $obj);
2447 $output_rules .= &file_contents ('library',
2448 ('LIBRARY' => $onelib,
2449 'XLIBRARY' => $xlib));
2454 foreach my $onelib (@liblist)
2456 my $xlib = &canonicalize ($onelib);
2457 if (&variable_defined ($xlib . '_LIBADD'))
2459 &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
2466 # handle_ltlibraries ()
2467 # ---------------------
2468 # Handle shared libraries.
2469 sub handle_ltlibraries
2471 my @liblist = &am_install_var ('ltlib', 'LTLIBRARIES',
2472 'noinst', 'lib', 'pkglib', 'check');
2473 return if ! @liblist;
2476 my %valid = &am_primary_prefixes ('LTLIBRARIES', 0, 'lib', 'pkglib',
2479 foreach my $key (keys %valid)
2481 if (&variable_defined ($key . '_LTLIBRARIES'))
2485 &am_line_error ($key . '_LTLIBRARIES', "library used but `LIBTOOL' not defined in `$configure_ac'");
2486 # Only get this error once. If this is ever printed,
2488 $configure_vars{'LIBTOOL'} = 'BUG';
2492 # Get the installation directory of each library.
2493 for (&variable_value_as_list ($key . '_LTLIBRARIES', 'all'))
2497 &am_error ("`$_' is already going to be installed in `$instdirs{$_}'");
2501 $instdirs{$_} = $key;
2507 my $seen_libobjs = 0;
2508 foreach my $onelib (@liblist)
2510 my $obj = &get_object_extension ($onelib);
2512 # Canonicalize names and check for misspellings.
2513 my $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_LDFLAGS',
2514 '_SOURCES', '_OBJECTS',
2517 if (! &variable_defined ($xlib . '_LDFLAGS'))
2519 # Define the lib_LDFLAGS variable.
2520 &define_variable ($xlib . '_LDFLAGS', '');
2523 # Check that the library fits the standard naming convention.
2524 my $libname_rx = "^lib.*\.la";
2525 if ((&variable_defined ($xlib . '_LDFLAGS')
2526 && grep (/-module/, &variable_value_as_list ($xlib . '_LDFLAGS',
2528 || (&variable_defined ('LDFLAGS')
2529 && grep (/-module/, &variable_value_as_list ('LDFLAGS',
2532 # Relax name checking for libtool modules.
2533 $libname_rx = "\.la";
2535 if ($onelib !~ /$libname_rx$/)
2537 # FIXME this should only be a warning for foreign packages
2538 # FIXME should put line number here. That means mapping
2539 # from library name back to variable name.
2540 &am_error ("`$onelib' is not a standard libtool library name");
2543 if (&variable_defined ($xlib . '_LIBADD'))
2545 if (&handle_lib_objects ($xlib, $xlib . '_LIBADD'))
2552 # Generate support for conditional object inclusion in
2554 &define_variable ($xlib . "_LIBADD", '');
2557 if (&variable_defined ($xlib . '_LDADD'))
2559 &am_line_error ($xlib . '_LDADD',
2560 "use `" . $xlib . "_LIBADD', not `"
2561 . $xlib . "_LDADD'");
2564 # Make sure we at look at this.
2565 &examine_variable ($xlib . '_DEPENDENCIES');
2567 my $linker = &handle_source_transform ($xlib, $onelib, $obj);
2569 # Determine program to use for link.
2571 if (&variable_defined ($xlib . '_LINK'))
2573 $xlink = $xlib . '_LINK';
2577 $xlink = $linker ? $linker : 'LINK';
2581 if ($instdirs{$onelib} eq 'EXTRA'
2582 || $instdirs{$onelib} eq 'noinst'
2583 || $instdirs{$onelib} eq 'check')
2585 # It's an EXTRA_ library, so we can't specify -rpath,
2586 # because we don't know where the library will end up.
2587 # The user probably knows, but generally speaking automake
2588 # doesn't -- and in fact configure could decide
2589 # dynamically between two different locations.
2594 $rpath = ('-rpath $(' . $instdirs{$onelib} . 'dir)');
2597 $output_rules .= &file_contents ('ltlibrary',
2598 ('LTLIBRARY' => $onelib,
2599 'XLTLIBRARY' => $xlib,
2601 'XLINK' => $xlink));
2606 foreach my $onelib (@liblist)
2608 my $xlib = &canonicalize ($onelib);
2609 if (&variable_defined ($xlib . '_LIBADD'))
2611 &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
2617 # See if any _SOURCES variable were misspelled. Also, make sure that
2618 # EXTRA_ variables don't contain configure substitutions.
2621 foreach my $varname (keys %var_value)
2623 foreach my $primary ('_SOURCES', '_LIBADD', '_LDADD', '_LDFLAGS',
2626 if ($varname =~ /$primary$/ && ! $content_seen{$varname})
2628 &am_line_error ($varname,
2629 "invalid unused variable name: `$varname'");
2638 # NOTE we no longer automatically clean SCRIPTS, because it is
2639 # useful to sometimes distribute scripts verbatim. This happens
2640 # eg in Automake itself.
2641 &am_install_var ('-candist', 'scripts', 'SCRIPTS',
2642 'bin', 'sbin', 'libexec', 'pkgdata',
2645 my $scripts_installed = 0;
2646 # Set $scripts_installed if appropriate. Make sure we only find
2647 # scripts which are actually installed -- this is why we can't
2648 # simply use the return value of am_install_var.
2649 my %valid = &am_primary_prefixes ('SCRIPTS', 1, 'bin', 'sbin',
2650 'libexec', 'pkgdata',
2652 foreach my $key (keys %valid)
2654 if ($key ne 'noinst'
2656 && &variable_defined ($key . '_SCRIPTS'))
2658 $scripts_installed = 1;
2659 # push (@check_tests, 'check-' . $key . 'SCRIPTS');
2665 # ($OUTFILE, $VFILE, @CLEAN_FILES)
2666 # &scan_texinfo_file ($FILENAME)
2667 # ------------------------------
2668 # $OUTFILE is the name of the info file produced by $FILENAME.
2669 # $VFILE is the name of the version.texi file used (empty if none).
2670 # @CLEAN_FILES is the list of by products (indexes etc.)
2671 sub scan_texinfo_file
2673 my ($filename) = @_;
2675 # These are always created, no matter whether indexes are used or not.
2676 my @clean_suffixes = ('aux', 'dvi', 'log', 'ps', 'toc',
2677 # grep new.*index texinfo.tex
2678 'cp', 'fn', 'ky', 'vr', 'tp', 'pg');
2680 # There are predefined indexes which don't follow the regular rules.
2681 my %predefined_index =
2684 'c' => 'cps', 'f' => 'fns', 'k' => 'kys',
2685 'v' => 'vrs', 't' => 'tps', 'p' => 'pgs'
2688 # There are commands which include a hidden index command.
2692 'fn' => 'fns', 'un' => 'fns',
2693 'typefn' => 'fns', 'typefun' => 'fns',
2694 'mac' => 'fns', 'spec' => 'fns',
2695 'op' => 'fns', 'typeop' => 'fns',
2696 'method' => 'fns', 'typemethod' => 'fns',
2698 'vr' => 'vrs', 'var' => 'vrs',
2699 'typevr' => 'vrs', 'typevar' => 'vrs',
2702 'ivar' => 'vrs', 'typeivar' => 'vrs',
2707 # Indexes stored into another one. In this case, the *.??s file
2709 my @syncodeindexes = ();
2711 my $texi = new IO::File ("< $filename");
2714 &am_error ("couldn't open `$filename': $!");
2717 print "$me: reading $filename\n" if $verbose;
2719 my ($outfile, $vfile);
2720 while ($_ = $texi->getline)
2722 if (/^\@setfilename +(\S+)/)
2725 if ($outfile =~ /\.(.+)$/ && $1 ne 'info')
2727 &am_file_error ($filename, "$.: ",
2728 "output `$outfile' has unrecognized extension");
2732 # A "version.texi" file is actually any file whose name
2733 # matches "vers*.texi".
2734 elsif (/^\@include\s+(vers[^.]*\.texi)\s*$/)
2739 # Try to find what are the indexes which are used.
2741 # Creating a new category of index.
2742 elsif (/^\@def(code)?index (\w+)/)
2744 push @clean_suffixes, $2;
2747 # Storing in a predefined index.
2748 elsif (/^\@([cfkvtp])index /)
2750 push @clean_suffixes, $predefined_index{$1};
2752 elsif (/^\@def(\w+) /)
2754 push @clean_suffixes, $hidden_index{$1}
2755 if defined $hidden_index{$1};
2758 # Merging an index into an another.
2759 elsif (/^\@syn(code)?index (\w+) \w+/)
2761 push @syncodeindexes, "$2s";
2769 &am_error ("`$filename' missing \@setfilename");
2773 my $infobase = basename ($filename);
2774 $infobase =~ s/\.te?xi(nfo)?$//;
2775 # FIXME: I don't understand why, but I can't use "$infobase.$_" => 1.
2776 my %clean_files = map { "$infobase" . ".$_" => 1 } @clean_suffixes;
2777 grep { delete $clean_files{"$infobase.$_"} } @syncodeindexes;
2778 return ($outfile, $vfile, (sort keys %clean_files));
2782 # ($DO-SOMETHING, $TEXICLEANS)
2783 # handle_texinfo_helper ()
2785 # Handle all Texinfo source; helper for handle_texinfo
2786 sub handle_texinfo_helper
2788 &am_line_error ('TEXINFOS',
2789 "`TEXINFOS' is an anachronism; use `info_TEXINFOS'")
2790 if &variable_defined ('TEXINFOS');
2791 return (0, '') if (! &variable_defined ('info_TEXINFOS')
2792 && ! &variable_defined ('html_TEXINFOS'));
2794 if (&variable_defined ('html_TEXINFOS'))
2796 &am_line_error ('html_TEXINFOS',
2797 "HTML generation not yet supported");
2801 my @texis = &variable_value_as_list ('info_TEXINFOS', 'all');
2803 my (@info_deps_list, @dvis_list, @texi_deps);
2810 foreach my $info_cursor (@texis)
2812 my $infobase = $info_cursor;
2813 $infobase =~ s/\.(txi|texinfo|texi)$//;
2815 if ($infobase eq $info_cursor)
2817 # FIXME: report line number.
2818 &am_error ("texinfo file `$info_cursor' has unrecognized extension");
2821 $texi_suffixes{$1} = 1;
2823 # If 'version.texi' is referenced by input file, then include
2824 # automatic versioning capability.
2825 my ($out_file, $vtexi, @clean_files) =
2826 &scan_texinfo_file ("$relative_dir/$info_cursor")
2828 push (@texi_cleans, @clean_files);
2832 &am_error ("`$vtexi', included in `$info_cursor', also included in `$versions{$vtexi}'")
2833 if (defined $versions{$vtexi});
2834 $versions{$vtexi} = $info_cursor;
2836 # We number the stamp-vti files. This is doable since the
2837 # actual names don't matter much. We only number starting
2838 # with the second one, so that the common case looks nice.
2839 my $vti = ($done ? $done : 'vti');
2842 # This is ugly, but it is our historical practice.
2843 if ($config_aux_dir_set_in_configure_in)
2845 &require_conf_file_with_line ('info_TEXINFOS', $FOREIGN,
2850 &require_file_with_line ('info_TEXINFOS', $FOREIGN,
2855 if ($config_aux_dir_set_in_configure_in)
2857 $conf_dir = $config_aux_dir;
2858 $conf_dir .= '/' unless $conf_dir =~ /\/$/;
2862 $conf_dir = '$(srcdir)/';
2864 $output_rules .= &file_contents ('texi-vers',
2865 ('TEXI' => $info_cursor,
2868 'MDDIR' => $conf_dir));
2871 # If user specified file_TEXINFOS, then use that as explicit
2874 push (@texi_deps, $info_cursor);
2875 # Prefix with $(srcdir) because some version of make won't
2876 # work if the target has it and the dependency doesn't.
2877 push (@texi_deps, '$(srcdir)/' . $vtexi) if $vtexi;
2879 my $canonical = &canonicalize ($infobase);
2880 if (&variable_defined ($canonical . "_TEXINFOS"))
2882 push (@texi_deps, '$(' . $canonical . '_TEXINFOS)');
2883 &push_dist_common ('$(' . $canonical . '_TEXINFOS)');
2886 $output_rules .= ("\n" . $out_file . ": "
2887 . join (' ', @texi_deps)
2888 . "\n" . $infobase . ".dvi: "
2889 . join (' ', @texi_deps)
2892 push (@info_deps_list, $out_file);
2893 push (@dvis_list, $infobase . '.dvi');
2896 # Handle location of texinfo.tex.
2897 my $need_texi_file = 0;
2901 $texinfodir = '$(top_srcdir)/../texinfo';
2902 &define_variable ('TEXINFO_TEX', "$texinfodir/texinfo.tex");
2904 elsif ($config_aux_dir_set_in_configure_in)
2906 $texinfodir = $config_aux_dir;
2907 &define_variable ('TEXINFO_TEX', "$texinfodir/texinfo.tex");
2908 $need_texi_file = 2; # so that we require_conf_file later
2910 elsif (&variable_defined ('TEXINFO_TEX'))
2912 # The user defined TEXINFO_TEX so assume he knows what he is
2914 $texinfodir = ('$(srcdir)/'
2915 . dirname (&variable_value ('TEXINFO_TEX')));
2919 $texinfodir = '$(srcdir)';
2920 $need_texi_file = 1;
2923 foreach my $txsfx (sort keys %texi_suffixes)
2925 $output_rules .= &file_contents ('texibuild',
2926 ('TEXINFODIR' => $texinfodir,
2927 'SUFFIX' => $txsfx));
2931 my $texiclean = &pretty_print_internal ("", "\t ", @texi_cleans);
2933 push (@dist_targets, 'dist-info');
2935 if (! defined $options{'no-installinfo'})
2937 # Make sure documentation is made and installed first. Use
2938 # $(INFO_DEPS), not 'info', because otherwise recursive makes
2939 # get run twice during "make all".
2940 unshift (@all, '$(INFO_DEPS)');
2943 &define_variable ("INFO_DEPS", join (' ', @info_deps_list));
2944 &define_variable ("DVIS", join (' ', @dvis_list));
2945 # This next isn't strictly needed now -- the places that look here
2946 # could easily be changed to look in info_TEXINFOS. But this is
2947 # probably better, in case noinst_TEXINFOS is ever supported.
2948 &define_variable ("TEXINFOS", &variable_value ('info_TEXINFOS'));
2950 # Do some error checking. Note that this file is not required
2951 # when in Cygnus mode; instead we defined TEXINFO_TEX explicitly
2953 if ($need_texi_file && ! defined $options{'no-texinfo.tex'})
2955 if ($need_texi_file > 1)
2957 &require_conf_file_with_line ('info_TEXINFOS', $FOREIGN,
2962 &require_file_with_line ('info_TEXINFOS', $FOREIGN, 'texinfo.tex');
2966 return (1, $texiclean);
2971 # Handle all Texinfo source.
2974 my ($do_something, $texiclean) = handle_texinfo_helper ();
2975 $output_rules .= &file_contents ('texinfos',
2976 ('TEXICLEAN' => $texiclean,
2977 'LOCAL-TEXIS' => $do_something));
2980 # Handle any man pages.
2981 sub handle_man_pages
2983 &am_line_error ('MANS', "`MANS' is an anachronism; use `man_MANS'")
2984 if &variable_defined ('MANS');
2986 # Find all the sections in use. We do this by first looking for
2987 # "standard" sections, and then looking for any additional
2988 # sections used in man_MANS.
2989 my (%sections, %vlist);
2990 # We handle nodist_ for uniformity. man pages aren't distributed
2991 # by default so it isn't actually very important.
2992 foreach my $pfx ('', 'dist_', 'nodist_')
2994 # Add more sections as needed.
2995 foreach my $section ('0'..'9', 'n', 'l')
2997 if (&variable_defined ($pfx . 'man' . $section . '_MANS'))
2999 $sections{$section} = 1;
3000 $vlist{'$(' . $pfx . 'man' . $section . '_MANS)'} = 1;
3002 &push_dist_common ('$(' . $pfx . 'man' . $section . '_MANS)')
3007 if (&variable_defined ($pfx . 'man_MANS'))
3009 $vlist{'$(' . $pfx . 'man_MANS)'} = 1;
3010 foreach (&variable_value_as_list ($pfx . 'man_MANS', 'all'))
3012 # A page like `foo.1c' goes into man1dir.
3013 if (/\.([0-9a-z])([a-z]*)$/)
3019 &push_dist_common ('$(' . $pfx . 'man_MANS)')
3024 return unless %sections;
3026 # Now for each section, generate an install and unintall rule.
3027 # Sort sections so output is deterministic.
3028 foreach my $section (sort keys %sections)
3030 $output_rules .= &file_contents ('mans', ('SECTION' => $section));
3033 $output_vars .= &file_contents ('mans-vars',
3034 ('MANS' => join (' ', sort keys %vlist)));
3036 if (! defined $options{'no-installman'})
3038 push (@all, '$(MANS)');
3042 # Handle DATA variables.
3045 &am_install_var ('-noextra', '-candist', 'data', 'DATA',
3046 'data', 'sysconf', 'sharedstate', 'localstate',
3047 'pkgdata', 'noinst', 'check');
3054 if (&variable_defined ('SUBDIRS'))
3056 $output_rules .= ("tags-recursive:\n"
3057 . "\tlist=\'\$(SUBDIRS)\'; for subdir in \$\$list; do \\\n"
3058 # Never fail here if a subdir fails; it
3060 . "\t test \"\$\$subdir\" = . || (cd \$\$subdir"
3061 . " && \$(MAKE) \$(AM_MAKEFLAGS) tags); \\\n"
3063 push (@tag_deps, 'tags-recursive');
3064 &depend ('.PHONY', 'tags-recursive');
3067 if (&saw_sources_p (1)
3068 || &variable_defined ('ETAGS_ARGS')
3072 foreach my $one_hdr (@config_headers)
3074 if ($relative_dir eq dirname ($one_hdr))
3076 # The config header is in this directory. So require it.
3077 $config .= ' ' if $config;
3078 $config .= basename ($one_hdr);
3081 $output_rules .= &file_contents ('tags',
3082 ('CONFIG' => $config,
3083 'DIRS' => join (' ', @tag_deps)));
3084 &examine_variable ('TAGS_DEPENDENCIES');
3086 elsif (&variable_defined ('TAGS_DEPENDENCIES'))
3088 &am_line_error ('TAGS_DEPENDENCIES',
3089 "doesn't make sense to define `TAGS_DEPENDENCIES' without sources or `ETAGS_ARGS'");
3093 # Every Makefile must define some sort of TAGS rule.
3094 # Otherwise, it would be possible for a top-level "make TAGS"
3095 # to fail because some subdirectory failed.
3096 $output_rules .= "tags: TAGS\nTAGS:\n\n";
3100 # Handle multilib support.
3103 if ($seen_multilib && $relative_dir eq '.')
3105 $output_rules .= &file_contents ('multilib');
3111 # &for_dist_common ($A, $B)
3112 # -------------------------
3113 # Subroutine for &handle_dist: sort files to dist.
3115 # We put README first because it then becomes easier to make a
3116 # Usenet-compliant shar file (in these, README must be first).
3118 # FIXME: do more ordering of files here.
3131 # handle_dist ($MAKEFILE)
3132 # -----------------------
3133 # Handle 'dist' target.
3136 my ($makefile) = @_;
3138 # `make dist' isn't used in a Cygnus-style tree.
3139 # Omit the rules so that people don't try to use them.
3140 return if $cygnus_mode;
3142 # Look for common files that should be included in distribution.
3143 foreach my $cfile (@common_files)
3145 if (-f ($relative_dir . "/" . $cfile))
3147 &push_dist_common ($cfile);
3151 # We might copy elements from $configure_dist_common to
3152 # %dist_common if we think we need to. If the file appears in our
3153 # directory, we would have discovered it already, so we don't
3154 # check that. But if the file is in a subdir without a Makefile,
3155 # we want to distribute it here if we are doing `.'. Ugly!
3156 if ($relative_dir eq '.')
3158 foreach my $file (split (' ' , $configure_dist_common))
3160 if (! &is_make_dir (dirname ($file)))
3162 &push_dist_common ($file);
3169 # Files to distributed. Don't use &variable_value_as_list
3170 # as it recursively expands `$(dist_pkgdata_DATA)' etc.
3171 check_variable_defined_unconditionally ('DIST_COMMON');
3172 my @dist_common = split (' ', variable_value ('DIST_COMMON', 'TRUE'));
3173 @dist_common = uniq (sort for_dist_common (@dist_common));
3174 pretty_print ('DIST_COMMON = ', "\t", @dist_common);
3176 # Now that we've processed DIST_COMMON, disallow further attempts
3178 $handle_dist_run = 1;
3180 # Scan EXTRA_DIST to see if we need to distribute anything from a
3181 # subdir. If so, add it to the list. I didn't want to do this
3182 # originally, but there were so many requests that I finally
3184 if (&variable_defined ('EXTRA_DIST'))
3186 # FIXME: This should be fixed to work with conditionals. That
3187 # will require only making the entries in %dist_dirs under the
3188 # appropriate condition. This is meaningful if the nature of
3189 # the distribution should depend upon the configure options
3191 foreach (&variable_value_as_list ('EXTRA_DIST', ''))
3194 next unless s,/+[^/]+$,,;
3200 # We have to check DIST_COMMON for extra directories in case the
3201 # user put a source used in AC_OUTPUT into a subdir.
3202 foreach (&variable_value_as_list ('DIST_COMMON', 'all'))
3205 next unless s,/+[^/]+$,,;
3210 # Rule to check whether a distribution is viable.
3211 my %transform = ('DISTCHECK-HOOK' => &target_defined ('distcheck-hook'),
3212 'GETTEXT' => $seen_gettext);
3214 # Prepend $(distdir) to each directory given.
3215 my %rewritten = map { '$(distdir)/' . "$_" => 1 } keys %dist_dirs;
3216 $transform{'DISTDIRS'} = join (' ', sort keys %rewritten);
3218 # If we have SUBDIRS, create all dist subdirectories and do
3220 if (&variable_defined ('SUBDIRS'))
3222 # If SUBDIRS is conditionally defined, then set DIST_SUBDIRS
3223 # to all possible directories, and use it. If DIST_SUBDIRS is
3224 # defined, just use it.
3225 my $dist_subdir_name;
3226 # Note that we check DIST_SUBDIRS first on purpose. At least
3227 # one project uses so many conditional subdirectories that
3228 # calling variable_conditionally_defined on SUBDIRS will cause
3229 # automake to grow to 150Mb. Sigh.
3230 if (&variable_defined ('DIST_SUBDIRS')
3231 || variable_conditionally_defined ('SUBDIRS'))
3233 $dist_subdir_name = 'DIST_SUBDIRS';
3234 if (! &variable_defined ('DIST_SUBDIRS'))
3236 &define_pretty_variable
3237 ('DIST_SUBDIRS', '',
3238 uniq (&variable_value_as_list ('SUBDIRS', 'all')));
3243 $dist_subdir_name = 'SUBDIRS';
3244 # We always define this because that is what `distclean'
3246 &define_pretty_variable ('DIST_SUBDIRS', '', '$(SUBDIRS)');
3249 $transform{'DIST_SUBDIR_NAME'} = $dist_subdir_name;
3252 # If the target `dist-hook' exists, make sure it is run. This
3253 # allows users to do random weird things to the distribution
3254 # before it is packaged up.
3255 push (@dist_targets, 'dist-hook')
3256 if &target_defined ('dist-hook');
3257 $transform{'DIST-TARGETS'} = join(' ', @dist_targets);
3259 # Defining $(DISTDIR).
3260 $transform{'DISTDIR'} = !&variable_defined('distdir');
3261 $transform{'TOP_DISTDIR'} = backname ($relative_dir);
3263 $output_rules .= &file_contents ('distdir', %transform);
3267 # Handle subdirectories.
3271 unless &variable_defined ('SUBDIRS');
3273 # Make sure each directory mentioned in SUBDIRS actually exists.
3274 foreach my $dir (&variable_value_as_list ('SUBDIRS', 'all'))
3276 # Skip directories substituted by configure.
3277 next if $dir =~ /^\@.*\@$/;
3279 if (! -d $am_relative_dir . '/' . $dir)
3281 &am_line_error ('SUBDIRS',
3282 "required directory $am_relative_dir/$dir does not exist");
3286 &am_line_error ('SUBDIRS', "directory should not contain `/'")
3290 $output_rules .= &file_contents ('subdirs');
3291 variable_pretty_output ('RECURSIVE_TARGETS', 'TRUE');
3295 # ($REGEN, @DEPENDENCIES)
3298 # If aclocal.m4 creation is automated, return the list of its dependencies.
3301 my $regen_aclocal = 0;
3304 unless $relative_dir eq '.';
3306 &examine_variable ('CONFIG_STATUS_DEPENDENCIES');
3307 &examine_variable ('CONFIGURE_DEPENDENCIES');
3309 if (-f 'aclocal.m4')
3311 &define_variable ("ACLOCAL_M4", '$(top_srcdir)/aclocal.m4');
3312 &push_dist_common ('aclocal.m4');
3314 my $aclocal = new IO::File ("< aclocal.m4");
3317 my $line = $aclocal->getline;
3320 if ($line =~ 'generated automatically by aclocal')
3329 if (-f 'acinclude.m4')
3332 push @ac_deps, 'acinclude.m4';
3335 if (&variable_defined ('ACLOCAL_M4_SOURCES'))
3337 push (@ac_deps, '$(ACLOCAL_M4_SOURCES)');
3339 elsif (&variable_defined ('ACLOCAL_AMFLAGS'))
3341 # Scan all -I directories for m4 files. These are our
3343 my $examine_next = 0;
3344 foreach my $amdir (&variable_value_as_list ('ACLOCAL_AMFLAGS', ''))
3349 if ($amdir !~ /^\// && -d $amdir)
3351 foreach my $ac_dep (&my_glob ($amdir . '/*.m4'))
3353 $ac_dep =~ s/^\.\/+//;
3354 push (@ac_deps, $ac_dep)
3355 unless $ac_dep eq "aclocal.m4"
3356 || $ac_dep eq "acinclude.m4";
3360 elsif ($amdir eq '-I')
3367 # Note that it might be possible that aclocal.m4 doesn't exist but
3368 # should be auto-generated. This case probably isn't very
3371 return ($regen_aclocal, @ac_deps);
3374 # Rewrite a list of input files into a form suitable to put on a
3375 # dependency list. The idea is that if an input file has a directory
3376 # part the same as the current directory, then the directory part is
3377 # simply removed. But if the directory part is different, then
3378 # $(top_srcdir) is prepended. Among other things, this is used to
3379 # generate the dependency list for the output files generated by
3380 # AC_OUTPUT. Consider what the dependencies should look like in this
3382 # AC_OUTPUT(src/out:src/in1:lib/in2)
3383 # The first argument, ADD_SRCDIR, is 1 if $(top_srcdir) should be added.
3384 # If 0 then files that require this addition will simply be ignored.
3385 sub rewrite_inputs_into_dependencies
3387 my ($add_srcdir, @inputs) = @_;
3390 foreach my $single (@inputs)
3392 if (dirname ($single) eq $relative_dir)
3394 push (@newinputs, basename ($single));
3398 push (@newinputs, '$(top_srcdir)/' . $single);
3405 # Handle remaking and configure stuff.
3406 # We need the name of the input file, to do proper remaking rules.
3407 sub handle_configure
3409 my ($local, $input, @secondary_inputs) = @_;
3411 my $input_base = basename ($input);
3412 my $local_base = basename ($local);
3414 my $amfile = $input_base . '.am';
3415 # We know we can always add '.in' because it really should be an
3416 # error if the .in was missing originally.
3417 my $infile = '$(srcdir)/' . $input_base . '.in';
3418 my $colon_infile = '';
3419 if ($local ne $input || @secondary_inputs)
3421 $colon_infile = ':' . $input . '.in';
3423 $colon_infile .= ':' . join (':', @secondary_inputs)
3424 if @secondary_inputs;
3426 my @rewritten = &rewrite_inputs_into_dependencies (1, @secondary_inputs);
3428 my ($regen_aclocal_m4, @aclocal_m4_deps) = scan_aclocal_m4 ();
3431 &file_contents ('configure',
3435 => join (' ', @rewritten),
3437 => ((($relative_dir eq '.') ? '$@' : '$(subdir)/$@')
3442 => join (' ', @include_stack),
3446 => $cygnus_mode ? 'cygnus' : $strictness_name,
3448 => $cmdline_use_dependencies ? '' : ' --ignore-deps',
3449 'MAKEFILE-AM-SOURCES'
3450 => "$input$colon_infile",
3452 => $regen_aclocal_m4,
3454 => join (' ', @aclocal_m4_deps)));
3456 if ($relative_dir eq '.')
3458 &push_dist_common ('acconfig.h')
3462 # If we have a configure header, require it.
3463 my @local_fullnames = @config_fullnames;
3464 my @local_names = @config_names;
3466 my $distclean_config = '';
3467 foreach my $one_hdr (@config_headers)
3469 my $one_fullname = shift (@local_fullnames);
3470 my $one_name = shift (@local_names);
3472 my $header_dir = dirname ($one_name);
3474 # If the header is in the current directory we want to build
3475 # the header here. Otherwise, if we're at the topmost
3476 # directory and the header's directory doesn't have a
3477 # Makefile, then we also want to build the header.
3478 if ($relative_dir eq $header_dir
3479 || ($relative_dir eq '.' && ! &is_make_dir ($header_dir)))
3481 my ($cn_sans_dir, $stamp_dir);
3482 if ($relative_dir eq $header_dir)
3484 $cn_sans_dir = basename ($one_name);
3489 $cn_sans_dir = $one_name;
3490 if ($header_dir eq '.')
3496 $stamp_dir = $header_dir . '/';
3500 # Compute relative path from directory holding output
3501 # header to directory holding input header. FIXME:
3502 # doesn't handle case where we have multiple inputs.
3504 if (dirname ($one_hdr) eq $relative_dir)
3506 $ch_sans_dir = basename ($one_hdr);
3510 $ch_sans_dir = backname ($relative_dir) . '/' . $one_hdr;
3513 &require_file_with_conf_line ($config_header_line,
3514 $FOREIGN, $ch_sans_dir);
3516 # Header defined and in this directory.
3518 if (-f $one_name . '.top')
3520 push (@files, "${cn_sans_dir}.top");
3522 if (-f $one_name . '.bot')
3524 push (@files, "${cn_sans_dir}.bot");
3527 &push_dist_common (@files);
3529 # For now, acconfig.h can only appear in the top srcdir.
3530 if (-f 'acconfig.h')
3532 push (@files, '$(top_srcdir)/acconfig.h');
3535 my $stamp_name = 'stamp-h';
3536 $stamp_name .= "${hdr_index}" if scalar (@config_headers) > 1;
3538 my $out_dir = dirname ($ch_sans_dir);
3541 &file_contents ('remake-hdr',
3542 ('FILES' => join (' ', @files),
3543 'CONFIG_HEADER' => $cn_sans_dir,
3544 'CONFIG_HEADER_IN' => $ch_sans_dir,
3545 'CONFIG_HEADER_FULL' => $one_fullname,
3546 'STAMP' => "$stamp_dir$stamp_name",
3547 'SRC_STAMP' => "$out_dir/$stamp_name"));
3549 &create ("${relative_dir}/${out_dir}/${stamp_name}.in");
3550 &require_file_with_conf_line ($config_header_line, $FOREIGN,
3551 "${out_dir}/${stamp_name}.in");
3553 $distclean_config .= ' ' if $distclean_config;
3554 $distclean_config .= $cn_sans_dir;
3558 if ($distclean_config)
3560 $output_rules .= &file_contents ('clean-hdr',
3561 ('FILES' => $distclean_config));
3564 # Set location of mkinstalldirs.
3565 &define_variable ('mkinstalldirs',
3566 ('$(SHELL) ' . $config_aux_dir . '/mkinstalldirs'));
3568 &am_line_error ('CONFIG_HEADER',
3569 "`CONFIG_HEADER' is an anachronism; now determined from `$configure_ac'")
3570 if &variable_defined ('CONFIG_HEADER');
3572 my $config_header = '';
3573 foreach my $one_name (@config_names)
3575 # Generate CONFIG_HEADER define.
3577 if ($relative_dir eq dirname ($one_name))
3579 $one_hdr = basename ($one_name);
3583 $one_hdr = "\$(top_builddir)/${one_name}";
3586 $config_header .= ' ' if $config_header;
3587 $config_header .= $one_hdr;
3591 &define_variable ("CONFIG_HEADER", $config_header);
3594 # Now look for other files in this directory which must be remade
3595 # by config.status, and generate rules for them.
3596 my @actual_other_files = ();
3597 foreach my $lfile (@other_input_files)
3600 my (@inputs, @rewritten_inputs);
3601 my ($need_rewritten);
3602 if ($lfile =~ /^([^:]*):(.*)$/)
3604 # This is the ":" syntax of AC_OUTPUT.
3606 $local = basename ($file);
3607 @inputs = split (':', $2);
3608 @rewritten_inputs = &rewrite_inputs_into_dependencies (1, @inputs);
3609 $need_rewritten = 1;
3615 $local = basename ($file);
3616 @inputs = ($file . '.in');
3618 &rewrite_inputs_into_dependencies (1, @inputs);
3619 $need_rewritten = 0;
3622 # Make sure the dist directory for each input file is created.
3623 # We only have to do this at the topmost level though. This
3624 # is a bit ugly but it easier than spreading out the logic,
3625 # especially in cases like AC_OUTPUT(foo/out:bar/in), where
3626 # there is no Makefile in bar/.
3627 if ($relative_dir eq '.')
3631 $dist_dirs{dirname ($_)} = 1;
3635 # We skip any automake input files, as they are handled
3636 # elsewhere. We also skip files that aren't in this
3637 # directory. However, if the file's directory does not have a
3638 # Makefile, and we are currently doing `.', then we create a
3639 # rule to rebuild the file in the subdir.
3640 next if -f $file . '.am';
3641 my $fd = dirname ($file);
3642 if ($fd ne $relative_dir)
3644 if ($relative_dir eq '.' && ! &is_make_dir ($fd))
3654 # Some users have been tempted to put `stamp-h' in the
3655 # AC_OUTPUT line. This won't do the right thing, so we
3656 # explicitly fail here.
3657 if ($local eq 'stamp-h')
3659 # FIXME: allow real filename.
3660 &am_conf_error ($configure_ac, $ac_output_line,
3661 'stamp-h should not appear in AC_OUTPUT');
3665 $output_rules .= ($local . ': '
3666 . '$(top_builddir)/config.status '
3667 . join (' ', @rewritten_inputs) . "\n"
3669 . 'cd $(top_builddir) && CONFIG_FILES='
3670 . ($relative_dir eq '.' ? '' : '$(subdir)/')
3671 . '$@' . ($need_rewritten
3672 ? (':' . join (':', @inputs))
3674 . ' CONFIG_HEADERS= CONFIG_LINKS= $(SHELL) ./config.status'
3676 push (@actual_other_files, $local);
3678 # Require all input files.
3679 &require_file_with_conf_line ($ac_output_line, $FOREIGN,
3680 &rewrite_inputs_into_dependencies (0, @inputs));
3683 # These files get removed by "make clean".
3684 &define_pretty_variable ('CONFIG_CLEAN_FILES', '', @actual_other_files);
3690 my @r = &am_install_var ('-defaultdist', 'header', 'HEADERS', 'include',
3691 'oldinclude', 'pkginclude',
3695 next unless /\.(.*)$/;
3696 &saw_extension ($1);
3702 return if ! $seen_gettext || $relative_dir ne '.';
3704 if (! &variable_defined ('SUBDIRS'))
3707 ("AM_GNU_GETTEXT used but SUBDIRS not defined");
3711 my @subdirs = &variable_value_as_list ('SUBDIRS', 'all');
3712 &am_line_error ('SUBDIRS',
3713 "AM_GNU_GETTEXT used but `po' not in SUBDIRS")
3714 if ! grep ('po', @subdirs);
3715 &am_line_error ('SUBDIRS',
3716 "AM_GNU_GETTEXT used but `intl' not in SUBDIRS")
3717 if ! grep ('intl', @subdirs);
3719 &require_file_with_conf_line ($ac_gettext_line, $GNU, 'ABOUT-NLS');
3721 # Ensure that each language in ALL_LINGUAS has a .po file, and
3722 # each po file is mentioned in ALL_LINGUAS.
3725 my %linguas = map { $_ => 1 } split (' ', $all_linguas);
3732 &am_line_error ($all_linguas_line,
3733 ("po/$_.po exists but `$_' not in `ALL_LINGUAS'"))
3737 foreach (keys %linguas)
3739 &am_line_error ($all_linguas_line,
3740 "$_ in `ALL_LINGUAS' but po/$_.po does not exist")
3746 &am_error ("AM_GNU_GETTEXT in `$configure_ac' but `ALL_LINGUAS' not defined");
3750 # Handle footer elements.
3753 # NOTE don't use define_pretty_variable here, because
3754 # $contents{...} is already defined.
3755 $output_vars .= 'SOURCES = ' . variable_value ('SOURCES') . "\n\n"
3756 if variable_value ('SOURCES');
3759 &am_line_error ('.SUFFIXES',
3760 "use variable `SUFFIXES', not target `.SUFFIXES'")
3761 if target_defined ('.SUFFIXES');
3763 # Note: AIX 4.1 /bin/make will fail if any suffix rule appears
3764 # before .SUFFIXES. So we make sure that .SUFFIXES appears before
3765 # anything else, by sticking it right after the default: target.
3766 $output_header .= ".SUFFIXES:\n";
3767 if (@suffixes || &variable_defined ('SUFFIXES'))
3769 # Make sure suffixes has unique elements. Sort them to ensure
3770 # the output remains consistent. However, $(SUFFIXES) is
3771 # always at the start of the list, unsorted. This is done
3772 # because make will choose rules depending on the ordering of
3773 # suffixes, and this lets the user have some control. Push
3774 # actual suffixes, and not $(SUFFIXES). Some versions of make
3775 # do not like variable substitutions on the .SUFFIXES line.
3776 my @user_suffixes = (&variable_defined ('SUFFIXES')
3777 ? &variable_value_as_list ('SUFFIXES', '')
3780 my %suffixes = map { $_ => 1 } @suffixes;
3781 delete @suffixes{@user_suffixes};
3783 $output_header .= (".SUFFIXES: "
3784 . join (' ', @user_suffixes, sort keys %suffixes)
3788 $output_trailer .= file_contents ('footer');
3791 # Deal with installdirs target.
3792 sub handle_installdirs ()
3795 &file_contents ('install',
3797 => variable_value ('_am_installdirs') || ''));
3801 # Deal with all and all-am.
3804 my ($makefile) = @_;
3808 # Put this at the beginning for the sake of non-GNU makes. This
3809 # is still wrong if these makes can run parallel jobs. But it is
3811 unshift (@all, basename ($makefile));
3813 foreach my $one_name (@config_names)
3815 push (@all, basename ($one_name))
3816 if dirname ($one_name) eq $relative_dir;
3819 # Install `all' hooks.
3820 if (&target_defined ("all-local"))
3822 push (@all, "all-local");
3823 &depend ('.PHONY', "all-local");
3826 &pretty_print_rule ("all-am:", "\t\t", @all);
3827 &depend ('.PHONY', 'all-am', 'all');
3832 my @local_headers = ();
3833 push @local_headers, '$(BUILT_SOURCES)'
3834 if &variable_defined ('BUILT_SOURCES');
3835 foreach my $one_name (@config_names)
3837 push @local_headers, basename ($one_name)
3838 if dirname ($one_name) eq $relative_dir;
3843 # We need to make sure config.h is built before we recurse.
3844 # We also want to make sure that built sources are built
3845 # before any ordinary `all' targets are run. We can't do this
3846 # by changing the order of dependencies to the "all" because
3847 # that breaks when using parallel makes. Instead we handle
3848 # things explicitly.
3849 $output_all .= ("all: " . join (' ', @local_headers)
3851 . '$(MAKE) $(AM_MAKEFLAGS) '
3852 . (&variable_defined ('SUBDIRS')
3853 ? 'all-recursive' : 'all-am')
3858 $output_all .= "all: " . (&variable_defined ('SUBDIRS')
3859 ? 'all-recursive' : 'all-am') . "\n\n";
3864 # Handle check merge target specially.
3865 sub do_check_merge_target
3867 if (&target_defined ('check-local'))
3869 # User defined local form of target. So include it.
3870 push (@check_tests, 'check-local');
3871 &depend ('.PHONY', 'check-local');
3874 # In --cygnus mode, check doesn't depend on all.
3877 # Just run the local check rules.
3878 &pretty_print_rule ('check-am:', "\t\t", @check);
3882 # The check target must depend on the local equivalent of
3883 # `all', to ensure all the primary targets are built. Then it
3884 # must build the local check rules.
3885 $output_rules .= "check-am: all-am\n";
3886 &pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ",
3890 &pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ",
3894 &depend ('.PHONY', 'check', 'check-am');
3895 $output_rules .= ("check: "
3896 . (&variable_defined ('SUBDIRS')
3897 ? 'check-recursive' : 'check-am')
3901 # Handle all 'clean' targets.
3906 # Don't include `MAINTAINER'; it is handled specially below.
3907 foreach my $name ('MOSTLY', '', 'DIST')
3909 $transform{"${name}CLEAN"} = &variable_defined ("${name}CLEANFILES");
3912 # Built sources are automatically removed by maintainer-clean.
3913 push (@maintainer_clean_files, '$(BUILT_SOURCES)')
3914 if &variable_defined ('BUILT_SOURCES');
3915 push (@maintainer_clean_files, '$(MAINTAINERCLEANFILES)')
3916 if &variable_defined ('MAINTAINERCLEANFILES');
3918 $output_rules .= &file_contents ('clean',
3921 # Join with no space to avoid
3922 # spurious `test -z' success at
3924 => join ('', @maintainer_clean_files),
3926 # A space is required in the join here.
3927 => join (' ', @maintainer_clean_files)));
3931 # &depend ($CATEGORY, @DEPENDENDEES)
3932 # ----------------------------------
3933 # The target $CATEGORY depends on @DEPENDENDEES.
3936 my ($category, @dependendees) = @_;
3938 push (@{$dependencies{$category}}, @dependendees);
3943 # &target_cmp ($A, $B)
3944 # --------------------
3945 # Subroutine for &handle_factored_dependencies to let `.PHONY' be last.
3958 # &handle_factored_dependencies ()
3959 # --------------------------------
3960 # Handle everything related to gathered targets.
3961 sub handle_factored_dependencies
3964 foreach my $utarg ('uninstall-data-local', 'uninstall-data-hook',
3965 'uninstall-exec-local', 'uninstall-exec-hook')
3967 if (&target_defined ($utarg))
3970 $x =~ s/(data|exec)-//;
3971 &am_line_error ($utarg, "use `$x', not `$utarg'");
3975 if (&target_defined ('install-local'))
3977 &am_line_error ('install-local',
3978 "use `install-data-local' or `install-exec-local', "
3979 . "not `install-local'");
3982 if (!defined $options{'no-installinfo'}
3983 && &target_defined ('install-info-local'))
3985 &am_line_error ('install-info-local',
3986 "`install-info-local' target defined but "
3987 . "`no-installinfo' option not in use");
3990 # Install the -local hooks.
3991 foreach (keys %dependencies)
3993 # Hooks are installed on the -am targets.
3995 if (&target_defined ("$_-local"))
3997 depend ("$_-am", "$_-local");
3998 &depend ('.PHONY', "$_-local");
4002 # Install the -hook hooks.
4003 # FIXME: Why not be as liberal as we are with -local hooks?
4004 foreach ('install-exec', 'install-data')
4006 if (&target_defined ("$_-hook"))
4008 $actions{"$_-am"} .=
4009 ("\t\@\$(NORMAL_INSTALL)\n"
4010 . "\t" . '$(MAKE) $(AM_MAKEFLAGS) ' . "$_-hook\n");
4014 # All the required targets are phony.
4015 depend ('.PHONY', keys %required_targets);
4017 # Actually output gathered targets.
4018 foreach (sort target_cmp keys %dependencies)
4020 # If there is nothing about this guy, skip it.
4022 unless (@{$dependencies{$_}}
4024 || $required_targets{$_});
4025 &pretty_print_rule ("$_:", "\t",
4026 uniq (sort @{$dependencies{$_}}));
4027 $output_rules .= $actions{$_}
4028 if defined $actions{$_};
4029 $output_rules .= "\n";
4034 # &handle_tests_dejagnu ()
4035 # ------------------------
4036 sub handle_tests_dejagnu
4038 push (@check_tests, 'check-DEJAGNU');
4040 # Only create site.exp rule if user hasn't already written one.
4042 file_contents ('dejagnu', ('SITE-EXP' => ! target_defined ('site.exp')));
4046 # Handle TESTS variable and other checks.
4049 if (defined $options{'dejagnu'})
4051 &handle_tests_dejagnu;
4055 foreach my $c ('DEJATOOL', 'RUNTEST', 'RUNTESTFLAGS')
4058 "`$c' defined but `dejagnu' not in `AUTOMAKE_OPTIONS'")
4059 if &variable_defined ($c);
4063 if (&variable_defined ('TESTS'))
4065 push (@check_tests, 'check-TESTS');
4066 $output_rules .= &file_contents ('check');
4070 # Handle Emacs Lisp.
4071 sub handle_emacs_lisp
4073 my @elfiles = &am_install_var ('-candist', 'lisp', 'LISP',
4076 return if ! @elfiles;
4078 # Generate .elc files.
4079 my @elcfiles = map { $_ . 'c' } @elfiles;
4080 &define_pretty_variable ('ELCFILES', '', @elcfiles);
4082 push (@all, '$(ELCFILES)');
4084 &am_error ("`lisp_LISP' defined but `AM_PATH_LISPDIR' not in `$configure_ac'")
4085 if ! $seen_lispdir && &variable_defined ('lisp_LISP');
4087 &require_file_with_conf_line ('AM_PATH_LISPDIR', $FOREIGN, 'elisp-comp');
4093 my @pyfiles = &am_install_var ('-defaultdist', 'python', 'PYTHON',
4094 'python', 'noinst');
4095 return if ! @pyfiles;
4097 # Found some python.
4098 &am_error ("`python_PYTHON' defined but `AM_PATH_PYTHON' not in `$configure_ac'")
4099 if ! $seen_pythondir && &variable_defined ('python_PYTHON');
4101 &require_file_with_conf_line ('AM_PATH_PYTHON', $FOREIGN, 'py-compile');
4102 &define_variable ('py_compile', $config_aux_dir . '/py-compile');
4108 my @sourcelist = &am_install_var ('-candist',
4110 'java', 'noinst', 'check');
4111 return if ! @sourcelist;
4113 my %valid = &am_primary_prefixes ('JAVA', 1,
4114 'java', 'noinst', 'check');
4117 foreach my $curs (keys %valid)
4119 if (! &variable_defined ($curs . '_JAVA') || $curs eq 'EXTRA')
4126 &am_line_error ($curs . '_JAVA',
4127 "multiple _JAVA primaries in use");
4132 push (@all, 'class' . $dir . '.stamp');
4136 # Handle some of the minor options.
4137 sub handle_minor_options
4139 if (defined $options{'readme-alpha'})
4141 if ($relative_dir eq '.')
4143 if ($package_version !~ /^$GNITS_VERSION_PATTERN$/)
4145 # FIXME: allow real filename.
4146 &am_conf_line_error ($configure_ac,
4147 $package_version_line,
4148 "version `$package_version' doesn't follow Gnits standards");
4150 elsif (defined $1 && -f 'README-alpha')
4152 # This means we have an alpha release. See
4153 # GNITS_VERSION_PATTERN for details.
4154 &require_file ($FOREIGN, 'README-alpha');
4160 ################################################################
4163 my @make_input_list;
4164 # &scan_autoconf_config_files ($CONFIG-FILES)
4165 # -------------------------------------------
4166 # Study $CONFIG-FILES which is the first argument to AC_CONFIG_FILES
4168 sub scan_autoconf_config_files
4170 my ($config_files) = @_;
4171 # Look at potential Makefile.am's.
4172 foreach (split ' ', $config_files)
4174 # Must skip empty string for Perl 4.
4175 next if $_ eq "\\" || $_ eq '';
4177 # Handle $local:$input syntax. Note that we ignore
4178 # every input file past the first, though we keep
4179 # those around for later.
4180 my ($local, $input, @rest) = split (/:/);
4187 # FIXME: should be error if .in is missing.
4188 $input =~ s/\.in$//;
4191 if (-f $input . '.am')
4193 # We have a file that automake should generate.
4194 push (@make_input_list, $input);
4195 $make_list{$input} = join (':', ($local, @rest));
4199 # We have a file that automake should cause to be
4200 # rebuilt, but shouldn't generate itself.
4201 push (@other_input_files, $_);
4207 # &scan_autoconf_traces ($FILENAME)
4208 # ---------------------------------
4209 # FIXME: For the time being, we don't care about the FILENAME.
4210 sub scan_autoconf_traces
4212 my ($filename) = @_;
4214 my $traces = "$ENV{amtraces} ";
4216 $traces .= ' -t AC_CONFIG_FILES';
4217 $traces .= ' -t AC_LIBSOURCE';
4218 $traces .= ' -t AC_SUBST';
4220 my $tracefh = new IO::File ("$traces |");
4223 die "$me: couldn't open `$traces': $!\n";
4225 print "$me: reading $traces\n" if $verbose;
4227 while ($_ = $tracefh->getline)
4230 my ($file, $line, $macro, @args) = split /:/;
4231 my $here = "$file:$line";
4233 # Alphabetical ordering please.
4234 if ($macro eq 'AC_CONFIG_FILES')
4236 # Look at potential Makefile.am's.
4237 &scan_autoconf_config_files ($args[0]);
4239 elsif ($macro eq 'AC_LIBSOURCE')
4241 my $source = "$args[0].c";
4242 # We should actually also `close' the sources: getopt.c
4243 # wants getopt.h etc. But actually it should be done in the
4244 # macro itself, i.e., we have to first fix Autoconf to extend
4245 # _AC_LIBOBJ_DECL and use it the in various macros.
4246 if (!defined $libsources{$source})
4248 print STDERR "traces: discovered $source\n";
4249 $libsources{$source} = $here;
4252 elsif ($macro eq 'AC_SUBST')
4254 if (!defined $configure_vars{$args[0]})
4256 print STDERR "traces: discovered AC_SUBST($args[0])\n";
4257 $configure_vars{$args[0]} = $here;
4263 || die "$me: close: $traces: $!\n";
4267 # &scan_one_autoconf_file ($FILENAME)
4268 # -----------------------------------
4269 # Scan one file for interesting things. Subroutine of
4270 # &scan_autoconf_files.
4271 sub scan_one_autoconf_file
4273 my ($filename) = @_;
4275 my $configfh = new IO::File ("< $filename");
4278 die "$me: couldn't open `$filename': $!\n";
4280 print "$me: reading $filename\n" if $verbose;
4282 my ($in_ac_output, $in_ac_replace) = (0, 0);
4283 while ($_ = $configfh->getline)
4285 # Remove comments from current line.
4289 # Skip macro definitions. Otherwise we might be confused into
4290 # thinking that a macro that was only defined was actually
4294 # Follow includes. This is a weirdness commonly in use at
4295 # Cygnus and hopefully nowhere else.
4296 if (/sinclude\((.*)\)/ && -f $1)
4298 # $_ being local, if we don't preserve it, when coming
4299 # back we will have $_ undefined, which is bad for the
4300 # the rest of this routine.
4301 my $underscore = $_;
4302 &scan_one_autoconf_file ($1);
4306 # Populate libobjs array.
4307 if (/AC_FUNC_ALLOCA/)
4309 $libsources{'alloca.c'} = 1;
4311 elsif (/AC_FUNC_GETLOADAVG/)
4313 $libsources{'getloadavg.c'} = 1;
4315 elsif (/AC_FUNC_MEMCMP/)
4317 $libsources{'memcmp.c'} = 1;
4319 elsif (/AC_STRUCT_ST_BLOCKS/)
4321 $libsources{'fileblocks.c'} = 1;
4323 elsif (/A[CM]_REPLACE_GNU_GETOPT/)
4325 $libsources{'getopt.c'} = 1;
4326 $libsources{'getopt1.c'} = 1;
4328 elsif (/AM_FUNC_STRTOD/)
4330 $libsources{'strtod.c'} = 1;
4332 elsif (/AM_WITH_REGEX/)
4334 $libsources{'rx.c'} = 1;
4335 $libsources{'rx.h'} = 1;
4336 $libsources{'regex.c'} = 1;
4337 $libsources{'regex.h'} = 1;
4339 elsif (/AC_FUNC_MKTIME/)
4341 $libsources{'mktime.c'} = 1;
4343 elsif (/AM_FUNC_ERROR_AT_LINE/)
4345 $libsources{'error.c'} = 1;
4346 $libsources{'error.h'} = 1;
4348 elsif (/AM_FUNC_OBSTACK/)
4350 $libsources{'obstack.c'} = 1;
4351 $libsources{'obstack.h'} = 1;
4353 elsif (/LIBOBJS="(.*)\s+\$LIBOBJS"/
4354 || /LIBOBJS="\$LIBOBJS\s+(.*)"/)
4356 foreach my $libobj_iter (split (' ', $1))
4358 if ($libobj_iter =~ /^(.*)\.o(bj)?$/
4359 || $libobj_iter =~ /^(.*)\.\$ac_objext$/
4360 || $libobj_iter =~ /^(.*)\.\$\{ac_objext\}$/)
4362 $libsources{$1 . '.c'} = 1;
4366 elsif (/AC_LIBOBJ\(([^)]+)\)/)
4368 $libsources{"$1.c"} = 1;
4371 if (! $in_ac_replace && s/AC_REPLACE_FUNCS\s*\(\[?//)
4377 $in_ac_replace = 0 if s/[\]\)].*$//;
4378 # Remove trailing backslash.
4382 # Need to skip empty elements for Perl 4.
4384 $libsources{$_ . '.c'} = 1;
4388 if (/$obsolete_rx/o)
4391 if ($obsolete_macros{$1} ne '')
4393 $hint = '; ' . $obsolete_macros{$1};
4395 &am_conf_line_error ($filename, $., "`$1' is obsolete$hint");
4398 # Process the AC_OUTPUT and AC_CONFIG_FILES macros.
4399 if (! $in_ac_output && s/AC_(OUTPUT|CONFIG_FILES)\s*\(\[?//)
4402 $ac_output_line = $.;
4413 # Look at potential Makefile.am's.
4414 &scan_autoconf_config_files ($_);
4416 if ($closing && @make_input_list == 0 && @other_input_files == 0)
4418 &am_conf_line_error ($filename, $ac_output_line,
4419 "No files mentioned in `AC_OUTPUT'");
4424 if (/$AC_CONFIG_AUX_DIR_PATTERN/o)
4426 @config_aux_path = &unquote_m4_arg ($1);
4427 $config_aux_dir_set_in_configure_in = 1;
4430 # Check for ansi2knr.
4431 $am_c_prototypes = 1 if /AM_C_PROTOTYPES/;
4433 # Check for exe extension stuff.
4437 $configure_vars{'EXEEXT'} = $filename . ':' . $.;
4443 $configure_vars{'OBJEXT'} = $filename . ':' . $.;
4446 # Check for `-c -o' code.
4447 $seen_cc_c_o = 1 if /AM_PROG_CC_C_O/;
4449 # Check for NLS support.
4450 if (/AM_GNU_GETTEXT/)
4453 $ac_gettext_line = $.;
4456 # Look for ALL_LINGUAS.
4457 if (/ALL_LINGUAS="(.*)"$/ || /ALL_LINGUAS=(.*)$/)
4461 $all_linguas_line = $.;
4464 # Handle configuration headers. A config header of `[$1]'
4465 # means we are actually scanning AM_CONFIG_HEADER from
4467 if (/A([CM])_CONFIG_HEADERS?\s*\((.*)\)/
4471 ($filename, $., "`automake requires `AM_CONFIG_HEADER', not `AC_CONFIG_HEADER'")
4474 $config_header_line = $.;
4475 foreach my $one_hdr (split (' ', &unquote_m4_arg ($2)))
4477 push (@config_fullnames, $one_hdr);
4478 if ($one_hdr =~ /^([^:]+):(.+)$/)
4480 push (@config_names, $1);
4481 push (@config_headers, $2);
4485 push (@config_names, $one_hdr);
4486 push (@config_headers, $one_hdr . '.in');
4491 # Handle AC_CANONICAL_*. Always allow upgrading to
4492 # AC_CANONICAL_SYSTEM, but never downgrading.
4493 $seen_canonical = $AC_CANONICAL_HOST
4494 if ! $seen_canonical
4495 && (/AC_CANONICAL_HOST/ || /AC_CHECK_TOOL/);
4496 $seen_canonical = $AC_CANONICAL_SYSTEM if /AC_CANONICAL_SYSTEM/;
4498 # If using X, include some extra variable definitions. NOTE
4499 # we don't want to force these into CFLAGS or anything,
4500 # because not all programs will necessarily use X.
4503 foreach my $var ('X_CFLAGS', 'X_LIBS', 'X_EXTRA_LIBS',
4506 $configure_vars{$var} = $filename . ':' . $.
4510 # This macro handles several different things.
4511 if (/$AM_INIT_AUTOMAKE_PATTERN/o)
4513 ($package_version = $1) =~ s/$AM_PACKAGE_VERSION_PATTERN/$1/o;
4514 $package_version_line = $.;
4515 $seen_init_automake = 1;
4520 $configure_vars{'LEX'} = $filename . ':' . $.;
4521 $seen_decl_yytext = 1;
4523 if (/AC_DECL_YYTEXT/ && $filename =~ /configure\.(ac|in)$/)
4525 &am_conf_line_warning ($filename, $., "`AC_DECL_YYTEXT' is covered by `AM_PROG_LEX'");
4527 if (/AC_PROG_LEX/ && $filename =~ /configure\.(ac|in)$/)
4529 &am_conf_line_warning ($filename, $., "automake requires `AM_PROG_LEX', not `AC_PROG_LEX'");
4532 if (/AC_PROG_(F77|YACC|RANLIB|CC|CXXCPP|CXX|LEX|AWK|CPP|LN_S)/)
4534 $configure_vars{$1} = $filename . ':' . $.;
4536 if (/$AC_CHECK_PATTERN/o)
4538 $configure_vars{$3} = $filename . ':' . $.;
4540 if (/$AM_MISSING_PATTERN/o
4544 && $1 ne 'AUTOHEADER'
4545 # AM_INIT_AUTOMAKE is AM_MISSING_PROG'ing MAKEINFO. But
4546 # we handle it elsewhere.
4547 && $1 ne 'MAKEINFO')
4549 $configure_vars{$1} = $filename . ':' . $.;
4552 # Explicitly avoid ANSI2KNR -- we AC_SUBST that in protos.m4,
4553 # but later define it elsewhere. This is pretty hacky. We
4554 # also explicitly avoid INSTALL_SCRIPT and some other
4555 # variables because they are defined in header-vars.am.
4557 if (/$AC_SUBST_PATTERN/o
4559 && $1 ne 'INSTALL_SCRIPT'
4560 && $1 ne 'INSTALL_DATA')
4562 $configure_vars{$1} = $filename . ':' . $.;
4565 $seen_decl_yytext = 1 if /AC_DECL_YYTEXT/;
4566 if (/AM_MAINTAINER_MODE/)
4568 $seen_maint_mode = 1;
4569 $configure_cond{'MAINTAINER_MODE'} = 1;
4572 $seen_lispdir = 1 if /AM_PATH_LISPDIR/;
4574 if (/AM_PATH_PYTHON/)
4576 $seen_pythondir = 1;
4577 $configure_vars{'pythondir'} = $filename . ':' . $.;
4578 $configure_vars{'PYTHON'} = $filename . ':' . $.;
4581 if (/A(C|M)_PROG_LIBTOOL/)
4583 # We're not ready for this yet. People still use a
4584 # libtool with no AC_PROG_LIBTOOL. Once that is the
4585 # dominant version we can reenable this code -- but next
4586 # time by mentioning the macro in %obsolete_macros, both
4587 # here and in aclocal.in.
4589 # if (/AM_PROG_LIBTOOL/)
4591 # &am_conf_line_warning ($filename, $., "`AM_PROG_LIBTOOL' is obsolete, use `AC_PROG_LIBTOOL' instead");
4595 $configure_vars{'LIBTOOL'} = $filename . ':' . $.;
4596 $configure_vars{'RANLIB'} = $filename . ':' . $.;
4597 $configure_vars{'CC'} = $filename . ':' . $.;
4598 # AC_PROG_LIBTOOL runs AC_CANONICAL_HOST. Make sure we
4599 # never downgrade (if we've seen AC_CANONICAL_SYSTEM).
4600 $seen_canonical = $AC_CANONICAL_HOST if ! $seen_canonical;
4603 $seen_multilib = 1 if (/AM_ENABLE_MULTILIB/);
4605 if (/$AM_CONDITIONAL_PATTERN/o)
4607 $configure_cond{$1} = 1;
4610 # Check for Fortran 77 intrinsic and run-time libraries.
4611 if (/AC_F77_LIBRARY_LDFLAGS/)
4613 $configure_vars{'FLIBS'} = $filename . ':' . $.;
4621 # &scan_autoconf_files ()
4622 # -----------------------
4623 # Check whether we use `configure.ac' or `configure.in'.
4624 # Scan it (and possibly `aclocal.m4') for interesting things.
4625 # We must scan aclocal.m4 because there might be AC_SUBSTs and such there.
4626 sub scan_autoconf_files
4628 # Reinitialize libsources here. This isn't really necessary,
4629 # since we currently assume there is only one configure.ac. But
4630 # that won't always be the case.
4633 warn "$me: both `configure.ac' and `configure.in' present:"
4634 . " ignoring `configure.in'\n"
4635 if -f 'configure.ac' && -f 'configure.in';
4636 $configure_ac = 'configure.in'
4637 if -f 'configure.in';
4638 $configure_ac = 'configure.ac'
4639 if -f 'configure.ac';
4640 die "$me: `configure.ac' or `configure.in' is required\n"
4643 &scan_one_autoconf_file ($configure_ac);
4644 &scan_one_autoconf_file ('aclocal.m4')
4647 if (defined $ENV{'amtraces'})
4649 warn '$me: Autoconf traces is an experimental feature';
4650 warn '$me: use at your own risks';
4652 &scan_autoconf_traces ($configure_ac);
4655 # Set input and output files if not specified by user.
4658 @input_files = @make_input_list;
4659 %output_files = %make_list;
4662 @configure_input_files = @make_input_list;
4664 &am_conf_error ("`AM_INIT_AUTOMAKE' must be used")
4665 if ! $seen_init_automake;
4667 # Look for some files we need. Always check for these. This
4668 # check must be done for every run, even those where we are only
4669 # looking at a subdir Makefile. We must set relative_dir so that
4670 # the file-finding machinery works.
4671 # FIXME: Is this broken because it needs dynamic scopes.
4672 # My tests seems to show it's not the case.
4673 $relative_dir = '.';
4674 &require_config_file ($FOREIGN, 'install-sh', 'mkinstalldirs', 'missing');
4675 &am_error ("`install.sh' is an anachronism; use `install-sh' instead")
4676 if -f $config_aux_path[0] . '/install.sh';
4678 &require_config_file ($FOREIGN, 'py-compile')
4681 # Preserve dist_common for later.
4682 $configure_dist_common = variable_value ('DIST_COMMON', 'TRUE') || '';
4685 ################################################################
4687 # Set up for Cygnus mode.
4690 return unless $cygnus_mode;
4692 &set_strictness ('foreign');
4693 $options{'no-installinfo'} = 1;
4694 $options{'no-dependencies'} = 1;
4695 $use_dependencies = 0;
4697 if (! $seen_maint_mode)
4699 &am_conf_error ("`AM_MAINTAINER_MODE' required when --cygnus specified");
4703 # Do any extra checking for GNU standards.
4704 sub check_gnu_standards
4706 if ($relative_dir eq '.')
4708 # In top level (or only) directory.
4709 &require_file ($GNU, 'INSTALL', 'NEWS', 'README', 'COPYING',
4710 'AUTHORS', 'ChangeLog');
4713 if ($strictness >= $GNU
4714 && defined $options{'no-installman'})
4716 &am_line_error ('AUTOMAKE_OPTIONS',
4717 "option `no-installman' disallowed by GNU standards");
4720 if ($strictness >= $GNU
4721 && defined $options{'no-installinfo'})
4723 &am_line_error ('AUTOMAKE_OPTIONS',
4724 "option `no-installinfo' disallowed by GNU standards");
4728 # Do any extra checking for GNITS standards.
4729 sub check_gnits_standards
4731 if ($relative_dir eq '.')
4733 # In top level (or only) directory.
4734 &require_file ($GNITS, 'THANKS');
4738 ################################################################
4740 # Functions to handle files of each language.
4742 # Each `lang_X_rewrite($DIRECTORY, $BASE, $EXT)' function follows a
4743 # simple formula: Return value is $LANG_SUBDIR if the resulting object
4744 # file should be in a subdir if the source file is, $LANG_PROCESS if
4745 # file is to be dealt with, $LANG_IGNORE otherwise.
4747 # Much of the actual processing is handled in
4748 # handle_single_transform_list. These functions exist so that
4749 # auxiliary information can be recorded for a later cleanup pass.
4750 # Note that the calls to these functions are computed, so don't bother
4751 # searching for their precise names in the source.
4753 # This is just a convenience function that can be used to determine
4754 # when a subdir object should be used.
4757 return defined $options{'subdir-objects'} ? $LANG_SUBDIR : $LANG_PROCESS;
4760 # Rewrite a single C source file.
4763 my ($directory, $base, $ext) = @_;
4765 if (defined $options{'ansi2knr'} && $base =~ /_$/)
4767 # FIXME: include line number in error.
4768 &am_error ("C source file `$base.c' would be deleted by ansi2knr rules");
4771 my $r = $LANG_PROCESS;
4772 if (defined $options{'subdir-objects'})
4775 $base = $directory . '/' . $base;
4779 # Only give error once.
4781 # FIXME: line number.
4782 &am_error ("C objects in subdir but `AM_PROG_CC_C_O' not in `$configure_ac'");
4785 &require_file ($FOREIGN, 'compile')
4786 if $relative_dir eq '.';
4789 $de_ansi_files{$base} = 1;
4793 # Rewrite a single C++ source file.
4794 sub lang_cxx_rewrite
4796 return &lang_sub_obj;
4799 # Rewrite a single header file.
4800 sub lang_header_rewrite
4802 # Header files are simply ignored.
4803 return $LANG_IGNORE;
4806 # Rewrite a single yacc file.
4807 sub lang_yacc_rewrite
4809 my ($directory, $base, $ext) = @_;
4811 my $r = &lang_c_rewrite ($directory, $base, $ext);
4813 if ($r == $LANG_SUBDIR)
4815 $pfx = $directory . '/';
4817 $yacc_sources{$pfx . $base . '.' . $ext} = 1;
4819 &saw_extension ('c');
4821 &push_dist_common ($pfx . $base . '.' . $ext);
4825 # Rewrite a single yacc++ file.
4826 sub lang_yaccxx_rewrite
4828 my ($directory, $base, $ext) = @_;
4830 my $r = $LANG_PROCESS;
4832 if (defined $options{'subdir-objects'})
4834 $pfx = $directory . '/';
4837 $yacc_sources{$pfx . $base . '.' . $ext} = 1;
4839 &saw_extension ($ext);
4841 &push_dist_common ($pfx . $base . '.' . $ext);
4845 # Rewrite a single lex file.
4846 sub lang_lex_rewrite
4848 my ($directory, $base, $ext) = @_;
4850 my $r = &lang_c_rewrite ($directory, $base, $ext);
4852 if ($r == $LANG_SUBDIR)
4854 $pfx = $directory . '/';
4856 $lex_sources{$pfx . $base . '.' . $ext} = 1;
4858 &saw_extension ('c');
4860 &push_dist_common ($pfx . $base . '.' . $ext);
4864 # Rewrite a single lex++ file.
4865 sub lang_lexxx_rewrite
4867 my ($directory, $base, $ext) = @_;
4869 my $r = $LANG_PROCESS;
4871 if (defined $options{'subdir-objects'})
4873 $pfx = $directory . '/';
4876 $lex_sources{$pfx . $base . '.' . $ext} = 1;
4878 &saw_extension ($ext);
4880 &push_dist_common ($pfx . $base . '.' . $ext);
4884 # Rewrite a single assembly file.
4885 sub lang_asm_rewrite
4887 return &lang_sub_obj;
4890 # Rewrite a single Fortran 77 file.
4891 sub lang_f77_rewrite
4893 return $LANG_PROCESS;
4896 # Rewrite a single preprocessed Fortran 77 file.
4897 sub lang_ppf77_rewrite
4899 return $LANG_PROCESS;
4902 # Rewrite a single ratfor file.
4903 sub lang_ratfor_rewrite
4905 return $LANG_PROCESS;
4908 # Rewrite a single Objective C file.
4909 sub lang_objc_rewrite
4911 return &lang_sub_obj;
4914 # Rewrite a single Java file.
4915 sub lang_java_rewrite
4917 return $LANG_SUBDIR;
4920 # The lang_X_finish functions are called after all source file
4921 # processing is done. Each should handle defining rules for the
4922 # language, etc. A finish function is only called if a source file of
4923 # the appropriate type has been seen.
4927 # Push all libobjs files onto de_ansi_files. We actually only
4928 # push files which exist in the current directory, and which are
4929 # genuine source files.
4930 foreach my $file (keys %libsources)
4932 if ($file =~ /^(.*)\.[cly]$/ && -f "$relative_dir/$file")
4934 $de_ansi_files{$1} = 1;
4938 if (defined $options{'ansi2knr'} && keys %de_ansi_files)
4940 # Make all _.c files depend on their corresponding .c files.
4942 foreach my $base (sort keys %de_ansi_files)
4944 # Each _.c file must depend on ansi2knr; otherwise it
4945 # might be used in a parallel build before it is built.
4946 # We need to support files in the srcdir and in the build
4947 # dir (because these files might be auto-generated. But
4948 # we can't use $< -- some makes only define $< during a
4950 $output_rules .= ($base . "_.c: $base.c \$(ANSI2KNR)\n\t"
4951 . '$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) '
4952 . '`if test -f $(srcdir)/' . $base . '.c'
4953 . '; then echo $(srcdir)/' . $base . '.c'
4954 . '; else echo ' . $base . '.c; fi` '
4955 . "| sed 's/^# \\([0-9]\\)/#line \\1/' "
4956 . '| $(ANSI2KNR) > ' . $base . "_.c"
4957 # If ansi2knr fails then we shouldn't
4958 # create the _.c file
4959 . " || rm -f ${base}_.c\n");
4960 push (@objects, $base . '_.$(OBJEXT)');
4961 push (@objects, $base . '_.lo')
4965 # Make all _.o (and _.lo) files depend on ansi2knr.
4966 # Use a sneaky little hack to make it print nicely.
4967 &pretty_print_rule ('', '', @objects, ':', '$(ANSI2KNR)');
4972 # This is a helper for both lex and yacc.
4973 sub yacc_lex_finish_helper
4975 return if defined $language_scratch{'lex-yacc-done'};
4976 $language_scratch{'lex-yacc-done'} = 1;
4978 # If there is more than one distinct yacc (resp lex) source file
4979 # in a given directory, then the `ylwrap' program is required to
4980 # allow parallel builds to work correctly. FIXME: for now, no
4982 &require_config_file ($FOREIGN, 'ylwrap');
4983 if ($config_aux_dir_set_in_configure_in)
4985 &define_variable ('YLWRAP', $config_aux_dir . "/ylwrap");
4989 &define_variable ('YLWRAP', '$(srcdir)/ylwrap');
4993 sub lang_yacc_finish
4995 return if defined $language_scratch{'yacc-done'};
4996 $language_scratch{'yacc-done'} = 1;
4998 my %seen_suffix = ();
4999 my @yacc_files = sort keys %yacc_sources;
5000 my $yacc_count = scalar (@yacc_files);
5001 foreach my $file (@yacc_files)
5004 &output_yacc_build_rule ($1, $yacc_count > 1)
5005 if ! defined $seen_suffix{$1};
5006 $seen_suffix{$1} = 1;
5008 $file =~ /^(.*)\.(y|yy|y\+\+|yxx|ypp)$/;
5010 my $hname = 'h'; # Always use `.h' for header file.
5014 if ((&variable_defined ('AM_YFLAGS')
5015 && &variable_value ('AM_YFLAGS') =~ /(^|\s)-d(\s|$)/)
5016 || (&variable_defined ('YFLAGS')
5017 && &variable_value ('YFLAGS') =~ /(^|\s)-d(\s|$)/)) {
5018 # Now generate rule to make the header file. This should only
5019 # be generated if `yacc -d' specified.
5020 $output_rules .= "${base}.${hname}: ${base}.${cname}\n";
5022 # If the files are built in the build directory, then we want
5023 # to remove them with `make clean'. If they are in srcdir
5024 # they shouldn't be touched. However, we can't determine this
5025 # statically, and the GNU rules say that yacc/lex output files
5026 # should be removed by maintainer-clean. So that's what we
5028 push (@maintainer_clean_files, "${base}.${hname}");
5030 &push_dist_common ("${base}.${hname}");
5032 push (@maintainer_clean_files, "${base}.${cname}");
5034 $output_rules .= "\n";
5036 if (&variable_defined ('YACCFLAGS'))
5038 &am_line_error ('YACCFLAGS',
5039 "`YACCFLAGS' obsolete; use `YFLAGS' instead");
5042 if ($yacc_count > 1)
5044 &yacc_lex_finish_helper;
5051 return if defined $language_scratch{'lex-done'};
5052 $language_scratch{'lex-done'} = 1;
5054 my %seen_suffix = ();
5055 my $lex_count = scalar (keys %lex_sources);
5056 foreach my $file (sort keys %lex_sources)
5059 &output_lex_build_rule ($1, $lex_count > 1)
5060 if (! defined $seen_suffix{$1});
5061 $seen_suffix{$1} = 1;
5063 # If the files are built in the build directory, then we want
5064 # to remove them with `make clean'. If they are in srcdir
5065 # they shouldn't be touched. However, we can't determine this
5066 # statically, and the GNU rules say that yacc/lex output files
5067 # should be removed by maintainer-clean. So that's what we
5069 $file =~ /^(.*)\.(l|ll|l\+\+|lxx|lpp)$/;
5071 ($cname = $2) =~ tr/l/c/;
5072 push (@maintainer_clean_files, "${1}.${cname}");
5075 if (! $seen_decl_yytext)
5077 &am_error ("lex source seen but `AC_DECL_YYTEXT' not in `$configure_ac'");
5082 &yacc_lex_finish_helper;
5087 # Given a hash table of linker names, pick the name that has the most
5088 # precedence. This is lame, but something has to have global
5089 # knowledge in order to eliminate the conflict. Add more linkers as
5096 if defined $linkers{'GCJLINK'};
5098 if defined $linkers{'CXXLINK'};
5100 if defined $linkers{'F77LINK'};
5102 if defined $linkers{'OBJCLINK'};
5106 # Called to indicate that an extension was used.
5110 $extension_seen{$ext} = 1;
5113 # Called to ask whether source files have been seen . If HEADERS is 1,
5114 # headers can be included.
5125 $headers = grep ($extension_seen{$_},
5126 @{$languages{'header'}->extensions});
5129 return scalar keys %extension_seen > $headers;
5133 # register_language (%ATTRIBUTE)
5134 # ------------------------------
5135 # Register a single language.
5136 # Each %ATTRIBUTE is of the form ATTRIBUTE => VALUE.
5137 sub register_language (%)
5143 unless defined $option{'ansi'};
5144 $option{'autodep'} = 'no'
5145 unless defined $option{'autodep'};
5146 $option{'derived_autodep'} = 'no'
5147 unless defined $option{'derived_autodep'};
5148 $option{'linker'} = ''
5149 unless defined $option{'linker'};
5151 my $lang = new Language (%option);
5154 grep ($extension_map{$_} = $lang->name, @{$lang->extensions});
5155 $languages{$lang->name} = $lang;
5158 # This function is used to find a path from a user-specified suffix to
5159 # `o' or to some other suffix we recognize internally, eg `cc'.
5162 my ($source_ext) = @_;
5164 # FIXME: hard-coding `o' is a mistake. Doing something
5165 # intelligent is harder.
5166 while (! $extension_map{$source_ext}
5167 && $source_ext ne 'o'
5168 && defined $suffix_rules{$source_ext})
5170 $source_ext = $suffix_rules{$source_ext};
5177 ################################################################
5179 # Pretty-print something. HEAD is what should be printed at the
5180 # beginning of the first line, FILL is what should be printed at the
5181 # beginning of every subsequent line.
5182 sub pretty_print_internal
5184 my ($head, $fill, @values) = @_;
5186 my $column = length ($head);
5189 # Fill length is number of characters. However, each Tab
5190 # character counts for eight. So we count the number of Tabs and
5192 my $fill_length = length ($fill);
5193 $fill_length += 7 * ($fill =~ tr/\t/\t/d);
5197 # "71" because we also print a space.
5198 if ($column + length ($_) > 71)
5200 $result .= " \\\n" . $fill;
5201 $column = $fill_length;
5203 $result .= ' ' if $result =~ /\S\z/;
5205 $column += length ($_) + 1;
5212 # Pretty-print something and append to output_vars.
5215 $output_vars .= &pretty_print_internal (@_);
5218 # Pretty-print something and append to output_rules.
5219 sub pretty_print_rule
5221 $output_rules .= &pretty_print_internal (@_);
5225 ################################################################
5229 # &conditional_string(@COND-STACK)
5230 # --------------------------------
5232 sub conditional_string
5236 if (grep (/^FALSE$/, @stack))
5242 return join (' ', uniq sort grep (!/^TRUE$/, @stack));
5248 # &conditional_true_when ($COND, $WHEN)
5249 # -------------------------------------
5250 # See if a conditional is true. Both arguments are conditional
5251 # strings. This returns true if the first conditional is true when
5252 # the second conditional is true.
5253 # For instance with $COND = `BAR FOO', and $WHEN = `BAR BAZ FOO',
5254 # obviously return 1, and 0 when, for instance, $WHEN = `FOO'.
5255 sub conditional_true_when ($$)
5257 my ($cond, $when) = @_;
5259 # Make a hash holding all the values from $WHEN.
5260 my %cond_vals = map { $_ => 1 } split (' ', $when);
5262 # Check each component of $cond, which looks `COND1 COND2'.
5263 foreach my $comp (split (' ', $cond))
5265 # TRUE is always true.
5266 next if $comp eq 'TRUE';
5267 return 0 if ! defined $cond_vals{$comp};
5275 # &conditionals_true_when (@CONDS, @WHENS)
5276 # ----------------------------------------
5277 # Same as above, but true if all the @CONDS are true when *ALL*
5278 # the @WHENS are sufficient.
5280 # If there are no @CONDS, then return true, of course. *BUT*, even if there
5281 # are @CONDS but @WHENS is empty, return true. This is counter intuitive,
5282 # and against all the rules of logic, but is needed by the current code.
5283 # FIXME: Do something saner when the logic of conditionals is understood.
5284 sub conditionals_true_when (@@)
5286 my (@conds, @whens) = @_;
5288 foreach my $cond (@conds)
5290 foreach my $when (@whens)
5293 unless conditional_true_when ($cond, $when);
5302 # condition_negate ($COND)
5303 # ------------------------
5304 sub condition_negate ($)
5308 $cond =~ s/TRUE$/TRUEO/;
5309 $cond =~ s/FALSE$/TRUE/;
5310 $cond =~ s/TRUEO$/FALSE/;
5316 # Compare condition names.
5317 # Issue them in alphabetical order, foo_TRUE before foo_FALSE.
5320 # Be careful we might be comparing `' or `#'.
5321 $a =~ /^(.*)_(TRUE|FALSE)$/;
5322 my ($aname, $abool) = ($1 || '', $2 || '');
5323 $b =~ /^(.*)_(TRUE|FALSE)$/;
5324 my ($bname, $bbool) = ($1 || '', $2 || '');
5325 return ($aname cmp $bname
5326 # Don't bother with IFs, given that TRUE is after FALSE
5327 # just cmp in the reverse order.
5328 || $bbool cmp $abool
5334 # &make_condition (@CONDITIONS)
5335 # -----------------------------
5336 # Transform a list of conditions (themselves can be an internal list
5337 # of conditions, e.g., @CONDITIONS = ('cond1 cond2', 'cond3')) into a
5338 # Make conditional (a pattern for AC_SUBST).
5339 # Correctly returns the empty string when there are no conditions.
5342 my $res = conditional_string (@_);
5344 # There are no conditions.
5350 elsif ($res eq 'FALSE')
5357 $res = '@' . $res . '@';
5366 ## ------------------------------ ##
5367 ## Handling the condition stack. ##
5368 ## ------------------------------ ##
5372 # cond_stack_if ($NEGATE, $COND, $WHERE)
5373 # --------------------------------------
5374 sub cond_stack_if ($$$)
5376 my ($negate, $cond, $where) = @_;
5378 &am_file_error ($where, "$cond does not appear in AM_CONDITIONAL")
5379 if ! $configure_cond{$cond} && $cond !~ /^TRUE|FALSE$/;
5381 $cond = "${cond}_TRUE"
5382 unless $cond =~ /^TRUE|FALSE$/;
5383 $cond = condition_negate ($cond)
5386 push (@cond_stack, $cond);
5388 return conditional_string (@cond_stack);
5393 # cond_stack_else ($NEGATE, $COND, $WHERE)
5394 # ----------------------------------------
5395 sub cond_stack_else ($$$)
5397 my ($negate, $cond, $where) = @_;
5401 &am_file_error ($where, "else without if");
5405 $cond_stack[$#cond_stack] = condition_negate ($cond_stack[$#cond_stack]);
5407 # If $COND is given, check against it.
5410 $cond = "${cond}_TRUE"
5411 unless $cond =~ /^TRUE|FALSE$/;
5412 $cond = condition_negate ($cond)
5415 &am_file_error ($where,
5416 "else reminder ($negate$cond) incompatible with "
5417 . "current conditional: $cond_stack[$#cond_stack]")
5418 if $cond_stack[$#cond_stack] ne $cond;
5421 return conditional_string (@cond_stack);
5426 # cond_stack_endif ($NEGATE, $COND, $WHERE)
5427 # -----------------------------------------
5428 sub cond_stack_endif ($$$)
5430 my ($negate, $cond, $where) = @_;
5435 &am_file_error ($where, "endif without if: $negate$cond");
5440 # If $COND is given, check against it.
5443 $cond = "${cond}_TRUE"
5444 unless $cond =~ /^TRUE|FALSE$/;
5445 $cond = condition_negate ($cond)
5448 &am_file_error ($where,
5449 "endif reminder ($negate$cond) incompatible with "
5450 . "current conditional: $cond_stack[$#cond_stack]")
5451 if $cond_stack[$#cond_stack] ne $cond;
5456 return conditional_string (@cond_stack);
5463 ## ------------------------ ##
5464 ## Handling the variables. ##
5465 ## ------------------------ ##
5468 # check_ambiguous_conditional ($VAR, $COND)
5469 # -----------------------------------------
5470 # Check for an ambiguous conditional. This is called when a variable
5471 # is being defined conditionally. If we already know about a
5472 # definition that is true under the same conditions, then we have an
5474 sub check_ambiguous_conditional ($$)
5476 my ($var, $cond) = @_;
5477 foreach my $vcond (keys %{$var_value{$var}})
5480 if ($vcond eq $cond)
5482 $message = "$var multiply defined in condition $cond";
5484 elsif (&conditional_true_when ($vcond, $cond))
5486 $message = ("$var was already defined in condition $vcond, "
5487 . "which implies condition $cond");
5489 elsif (&conditional_true_when ($cond, $vcond))
5491 $message = ("$var was already defined in condition $vcond, "
5492 . "which is implied by condition $cond");
5496 &am_line_error ($var, $message);
5503 # ¯o_define($VAR, $VAR_IS_AM, $TYPE, $COND, $VALUE, $WHERE)
5504 # -------------------------------------------------------------
5505 # The $VAR can go from Automake to user, but not the converse.
5506 sub macro_define ($$$$$$)
5508 my ($var, $var_is_am, $type, $cond, $value, $where) = @_;
5510 am_file_error ($where, "bad macro name `$var'")
5511 if $var !~ /$MACRO_PATTERN/o;
5515 # An Automake variable must be consistently defined with the same
5516 # sign by Automake. A user variable must be set by either `=' or
5517 # `:=', and later promoted to `+='.
5520 if (defined $var_type{$var} && $var_type{$var} ne $type)
5522 am_line_error ($var,
5523 ("$var was set with `$var_type{$var}=' "
5524 . "and is now set with `$type='"));
5529 if (!defined $var_type{$var} && $type eq '+')
5531 am_line_error ($var, "$var must be set with `=' before using `+='");
5534 $var_type{$var} = $type;
5536 # When adding, since we rewrite, don't try to preserve the
5537 # Automake continuation backslashes.
5539 if $type eq '+' && $var_is_am;
5541 # Differentiate the first assignment (including with `+=').
5542 if ($type eq '+' && defined $var_value{$var}{$cond})
5544 if (substr ($var_value{$var}{$cond}, -1) eq "\n")
5546 # Insert a backslash before a trailing newline.
5547 $var_value{$var}{$cond} =
5548 substr ($var_value{$var}{$cond}, 0, -1) . "\\\n";
5550 elsif ($var_value{$var}{$cond})
5552 # Insert a separator.
5553 $var_value{$var}{$cond} .= ' ';
5555 $var_value{$var}{$cond} .= $value;
5559 # The first assignment to a macro sets the line number. Ideally I
5560 # suppose we would associate line numbers with random bits of text.
5561 # FIXME: We sometimes redefine some variables, but we want to keep
5562 # the original location. More subs are needed to handle
5563 # properly variables. Once this done, remove this hack.
5564 $var_line{$var} = $where
5565 unless defined $var_line{$var};
5567 # If Automake tries to override a value specified by the user,
5568 # just don't let it do.
5569 if (defined $var_value{$var}{$cond} && !$var_is_am{$var} && $var_is_am)
5573 print STDERR "$me: refusing to override the user definition of:\n";
5575 print STDERR "$me: with `$cond' => `$value'\n";
5580 # There must be no previous value unless the user is redefining
5581 # an Automake variable or an AC_SUBST variable.
5582 check_ambiguous_conditional ($var, $cond)
5583 unless ($var_is_am{$var} && !$var_is_am
5584 || exists $configure_vars{$var});
5586 $var_value{$var}{$cond} = $value;
5590 # An Automake variable can be given to the user, but not the converse.
5591 if (! defined $var_is_am{$var} || !$var_is_am)
5593 $var_is_am{$var} = $var_is_am;
5598 # &variable_delete ($VAR, [@CONDS])
5599 # ---------------------------------
5600 # Forget about $VAR under the conditions @CONDS, or completely if
5602 sub variable_delete ($@)
5604 my ($var, @conds) = @_;
5608 delete $var_value{$var};
5609 delete $var_line{$var};
5610 delete $var_is_am{$var};
5611 delete $var_comment{$var};
5612 delete $var_type{$var};
5616 foreach my $cond (@conds)
5618 delete $var_value{$var}{$cond};
5624 # ¯o_dump ($VAR)
5625 # ------------------
5630 if (!exists $var_value{$var})
5632 print STDERR " $var does not exist\n";
5636 my $var_is_am = $var_is_am{$var} ? "Automake" : "User";
5637 my $where = (defined $var_line{$var}
5638 ? $var_line{$var} : "undefined");
5639 print STDERR "$var_comment{$var}"
5640 if defined $var_comment{$var};
5641 print STDERR " $var ($var_is_am, where = $where) $var_type{$var}=\n";
5642 print STDERR " {\n";
5643 foreach my $vcond (sort by_condition keys %{$var_value{$var}})
5645 print STDERR " $vcond => $var_value{$var}{$vcond}\n";
5647 print STDERR " }\n";
5658 print STDERR "%var_value =\n";
5660 foreach my $var (sort (keys %var_value))
5669 # &variable_defined ($VAR, [$COND])
5670 # ---------------------------------
5671 # See if a variable exists. $VAR is the variable name, and $COND is
5672 # the condition which we should check. If no condition is given, we
5673 # currently return true if the variable is defined under any
5675 sub variable_defined ($$)
5677 my ($var, $cond) = @_;
5679 # Unfortunately we can't just check for $var_value{VAR}{COND}
5680 # as this would make perl create $condition{VAR}, which we
5682 if (!exists $var_value{$var})
5684 if (defined $targets{$var})
5686 &am_line_error ($var, "`$var' is a target; expected a variable")
5688 # The variable is not defined
5692 if ($cond && !exists $var_value{$var}{$cond})
5694 # The variable is not defined for the given condition.
5698 # Even a var_value examination is good enough for us. FIXME:
5699 # really should maintain examined status on a per-condition basis.
5700 $content_seen{$var} = 1;
5704 # Mark a variable as examined.
5705 sub examine_variable
5708 &variable_defined ($var);
5711 # Return the set of conditions for which a variable is defined.
5713 # If the variable is not defined conditionally, and is not defined in
5714 # terms of any variables which are defined conditionally, then this
5715 # returns the empty list.
5717 # If the variable is defined conditionally, but is not defined in
5718 # terms of any variables which are defined conditionally, then this
5719 # returns the list of conditions for which the variable is defined.
5721 # If the variable is defined in terms of any variables which are
5722 # defined conditionally, then this returns a full set of permutations
5723 # of the subvariable conditions. For example, if the variable is
5724 # defined in terms of a variable which is defined for COND_TRUE,
5725 # then this returns both COND_TRUE and COND_FALSE. This is
5726 # because we will need to define the variable under both conditions.
5728 sub variable_conditions ($)
5735 foreach my $cond (&variable_conditions_sub ($var, '', ()))
5738 if $cond eq 'FALSE';
5739 $uniqify{$cond} = 1;
5742 @uniq_list = sort by_condition keys %uniqify;
5743 # Note we cannot just do `return sort keys %uniqify', because this
5744 # function is sometimes used in a scalar context.
5750 # &variable_conditionally_defined ($VAR)
5751 # --------------------------------------
5752 sub variable_conditionally_defined ($)
5755 foreach my $cond (variable_conditions ($var))
5758 unless $cond =~ /^TRUE|FALSE$/;
5765 # &variable_conditions_sub ($VAR, $PARENT, @PARENT_CONDS)
5766 # -------------------------------------------------------
5767 # A subroutine of variable_conditions. We only return conditions
5768 # which are true for all the conditions in @PARENT_CONDS.
5769 sub variable_conditions_sub
5771 my ($var, $parent, @parent_conds) = @_;
5774 if (defined $vars_scanned{$var})
5776 &am_line_error ($parent, "variable `$var' recursively defined");
5779 $vars_scanned{$var} = 1;
5781 my @this_conds = ();
5782 foreach my $vcond (keys %{$var_value{$var}})
5785 if ! conditionals_true_when ((@parent_conds), ($vcond));
5787 push (@this_conds, $vcond);
5789 push (@parent_conds, $vcond);
5790 my @subvar_conds = ();
5791 foreach (split (' ', $var_value{$var}{$vcond}))
5793 # If a comment seen, just leave.
5796 # Handle variable substitutions.
5797 if (/^\$\{(.*)\}$/ || /^\$\((.*)\)$/)
5799 push (@subvar_conds,
5800 &variable_conditions_sub ($1, $var, @parent_conds));
5803 pop (@parent_conds);
5805 # If there are no conditional subvariables, then we want to
5806 # return this condition. Otherwise, we want to return the
5807 # permutations of the subvariables.
5808 if (! @subvar_conds)
5810 push (@new_conds, $vcond);
5814 push (@new_conds, &variable_conditions_reduce (@subvar_conds));
5818 # Unset our entry in vars_scanned. We only care about recursive
5820 delete $vars_scanned{$var};
5822 # If there are no parents, then this call is the top level call.
5825 # Now we want to return all permutations of the subvariable
5828 foreach my $item (@new_conds)
5830 foreach (split (' ', $item))
5832 s/^(.*)_(TRUE|FALSE)$/$1_TRUE/;
5836 return &variable_conditions_permutations (sort keys %allconds);
5839 # If we are being called on behalf of another variable, we need to
5840 # return all possible permutations of the conditions. We have
5841 # already handled everything in @this_conds along with their
5842 # subvariables. We now need to add any permutations that are not
5844 foreach my $this_cond (@this_conds)
5847 &variable_conditions_permutations (split(' ', $this_cond));
5848 foreach my $perm (@perms)
5851 foreach my $scan (@this_conds)
5853 if (&conditional_true_when ($perm, $scan)
5854 || &conditional_true_when ($scan, $perm))
5863 if ! conditionals_true_when ((@parent_conds), ($perm));
5865 # This permutation was not already handled, and is valid
5867 push (@new_conds, $perm);
5875 # Filter a list of conditionals so that only the exclusive ones are
5876 # retained. For example, if both `COND1_TRUE COND2_TRUE' and
5877 # `COND1_TRUE' are in the list, discard the latter.
5878 sub variable_conditions_reduce
5882 foreach my $cond (@conds)
5884 # FALSE is absorbent.
5885 if ($cond eq 'FALSE')
5889 elsif (conditionals_true_when (($cond), (@ret)))
5898 # Return a list of permutations of a conditional string.
5899 sub variable_conditions_permutations
5904 my $comp = shift (@comps);
5905 return &variable_conditions_permutations (@comps)
5907 my $neg = condition_negate ($comp);
5910 foreach my $sub (&variable_conditions_permutations (@comps))
5912 push (@ret, "$comp $sub");
5913 push (@ret, "$neg $sub");
5925 # &check_variable_defined_unconditionally($VAR, $PARENT)
5926 # ------------------------------------------------------
5927 # Warn if a variable is conditionally defined. This is called if we
5928 # are using the value of a variable.
5929 sub check_variable_defined_unconditionally ($$)
5931 my ($var, $parent) = @_;
5932 foreach my $cond (keys %{$var_value{$var}})
5935 if $cond =~ /^TRUE|FALSE$/;
5939 &am_line_error ($parent,
5940 "warning: automake does not support conditional definition of $var in $parent");
5944 &am_line_error ($parent,
5945 "warning: automake does not support $var being defined conditionally");
5953 # Get the TRUE value of a variable, warn if the variable is
5954 # conditionally defined.
5958 &check_variable_defined_unconditionally ($var);
5959 return $var_value{$var}{'TRUE'};
5964 # &value_to_list ($VAR, $VAL, $COND)
5965 # ----------------------------------
5966 # Convert a variable value to a list, split as whitespace. This will
5967 # recursively follow $(...) and ${...} inclusions. It preserves @...@
5970 # If COND is 'all', then all values under all conditions should be
5971 # returned; if COND is a particular condition (all conditions are
5972 # surrounded by @...@) then only the value for that condition should
5973 # be returned; otherwise, warn if VAR is conditionally defined.
5974 # SCANNED is a global hash listing whose keys are all the variables
5975 # already scanned; it is an error to rescan a variable.
5978 my ($var, $val, $cond) = @_;
5982 $val =~ s/\\(\n|$)/ /g;
5984 foreach (split (' ', $val))
5986 # If a comment seen, just leave.
5989 # Handle variable substitutions.
5990 if (/^\$\{([^}]*)\}$/ || /^\$\(([^)]*)\)$/)
5994 # If the user uses a losing variable name, just ignore it.
5995 # This isn't ideal, but people have requested it.
5996 next if ($varname =~ /\@.*\@/);
6000 if ($varname =~ /^([^:]*):([^=]*)=(.*)$/)
6004 ($from = $2) =~ s/(\W)/\\$1/g;
6008 @temp_list = &variable_value_as_list_worker ($1, $cond, $var);
6010 # Now rewrite the value if appropriate.
6013 grep (s/$from$/$to/, @temp_list);
6016 push (@result, @temp_list);
6027 # Return contents of variable as list, split as whitespace. This will
6028 # recursively follow $(...) and ${...} inclusions. It preserves @...@
6029 # substitutions. If COND is 'all', then all values under all
6030 # conditions should be returned; if COND is a particular condition
6031 # (all conditions are surrounded by @...@) then only the value for
6032 # that condition should be returned; otherwise, warn if VAR is
6033 # conditionally defined. If PARENT is specified, it is the name of
6034 # the including variable; this is only used for error reports.
6035 sub variable_value_as_list_worker
6037 my ($var, $cond, $parent) = @_;
6040 if (! defined $var_value{$var})
6042 if (defined $targets{$var})
6044 &am_line_error ($var, "`$var' is a target; expected a variable");
6048 &am_line_error ($parent, "variable `$var' not defined");
6051 elsif (defined $vars_scanned{$var})
6053 # `vars_scanned' is a global we use to keep track of which
6054 # variables we've already examined.
6055 &am_line_error ($parent, "variable `$var' recursively defined");
6057 elsif ($cond eq 'all')
6059 $vars_scanned{$var} = 1;
6060 foreach my $vcond (keys %{$var_value{$var}})
6062 my $val = $var_value{$var}{$vcond};
6063 push (@result, &value_to_list ($var, $val, $cond));
6069 $vars_scanned{$var} = 1;
6071 foreach my $vcond (keys %{$var_value{$var}})
6073 my $val = $var_value{$var}{$vcond};
6074 if (&conditional_true_when ($vcond, $cond))
6076 # Warn if we have an ambiguity. It's hard to know how
6077 # to handle this case correctly.
6078 &check_variable_defined_unconditionally ($var, $parent)
6081 push (@result, &value_to_list ($var, $val, $cond));
6086 # Unset our entry in vars_scanned. We only care about recursive
6088 delete $vars_scanned{$var};
6094 # &variable_output ($VAR, [@CONDS])
6095 # ---------------------------------
6096 # Output all the values of $VAR is @COND is not specified, else only
6097 # that corresponding to @COND.
6098 sub variable_output ($@)
6100 my ($var, @conds) = @_;
6102 @conds = sort by_condition keys %{$var_value{$var}}
6105 $output_vars .= $var_comment{$var}
6106 if defined $var_comment{$var};
6108 foreach my $cond (@conds)
6110 my $val = $var_value{$var}{$cond};
6111 my $equals = $var_type{$var} eq ':' ? ':=' : '=';
6112 my $output_var = "$var $equals $val";
6113 $output_var =~ s/^/make_condition ($cond)/meg;
6114 $output_vars .= $output_var . "\n";
6119 # &variable_pretty_output ($VAR, [@CONDS])
6120 # ----------------------------------------
6121 # Likewise, but pretty, i.e., we *split* the values at spaces. Use only
6122 # with variables holding filenames.
6123 sub variable_pretty_output ($@)
6125 my ($var, @conds) = @_;
6127 @conds = sort by_condition keys %{$var_value{$var}}
6130 $output_vars .= $var_comment{$var}
6131 if defined $var_comment{$var};
6133 foreach my $cond (@conds)
6135 my $val = $var_value{$var}{$cond};
6136 my $equals = $var_type{$var} eq ':' ? ':=' : '=';
6137 my $make_condition = make_condition ($cond);
6138 $output_vars .= pretty_print_internal ("$make_condition$var $equals",
6139 "$make_condition\t",
6140 split (' ' , $val));
6145 # This is just a wrapper for variable_value_as_list_worker that
6146 # initializes the global hash `vars_scanned'. This hash is used to
6147 # avoid infinite recursion.
6148 sub variable_value_as_list
6150 my ($var, $cond, $parent) = @_;
6152 return &variable_value_as_list_worker ($var, $cond, $parent);
6156 # Like define_variable, but the value is a list, and the variable may
6157 # be defined conditionally. The second argument is the conditional
6158 # under which the value should be defined; this should be the empty
6159 # string to define the variable unconditionally. The third argument
6160 # is a list holding the values to use for the variable. The value is
6161 # pretty printed in the output file.
6162 sub define_pretty_variable
6164 my ($var, $cond, @value) = @_;
6166 # Beware that an empty $cond has a different semantics for
6167 # macro_define and variable_pretty_output.
6170 if (! &variable_defined ($var, $cond))
6172 macro_define ($var, 1, '', $cond, join (' ', @value), undef);
6173 variable_pretty_output ($var, $cond || 'TRUE');
6174 $content_seen{$var} = 1;
6179 # define_variable ($VAR, $VALUE)
6180 # ------------------------------
6181 # Define a new user variable VAR to VALUE, but only if not already defined.
6184 my ($var, $value) = @_;
6186 define_pretty_variable ($var, 'TRUE', $value);
6190 # Like define_variable, but define a variable to be the configure
6191 # substitution by the same name.
6192 sub define_configure_variable
6195 my $value = '@' . $var . '@';
6196 &define_variable ($var, $value);
6200 # define_compiler_variable ($LANG)
6201 # --------------------------------
6202 # Define a compiler variable. We also handle defining the `LT'
6203 # version of the command when using libtool.
6204 sub define_compiler_variable ($)
6208 my ($var, $value) = ($lang->compiler, $lang->compile);
6209 &define_variable ($var, $value);
6210 &define_variable ("LT$var", "\$(LIBTOOL) --mode=compile $value")
6215 # define_linker_variable ($LANG)
6216 # ------------------------------
6217 # Define linker variables.
6218 sub define_linker_variable ($)
6222 my ($var, $value) = ($lang->lder, $lang->ld);
6224 &define_variable ($lang->lder, $lang->ld);
6225 # CCLINK = $(CCLD) blah blah...
6226 &define_variable ($lang->linker,
6227 (($seen_libtool ? '$(LIBTOOL) --mode=link ' : '')
6231 ################################################################
6233 ## ---------------- ##
6234 ## Handling rules. ##
6235 ## ---------------- ##
6237 sub rule_define ($$$$)
6239 my ($target, $rule_is_am, $cond, $where) = @_;
6241 if (defined $targets{$target}
6243 ? ! defined $target_conditional{$target}
6244 : defined $target_conditional{$target}))
6246 &am_line_error ($target,
6247 "$target defined both conditionally and unconditionally");
6250 # Value here doesn't matter; for targets we only note existence.
6251 $targets{$target} = $where;
6254 if ($target_conditional{$target})
6256 &check_ambiguous_conditional ($target, $cond);
6258 $target_conditional{$target}{$cond} = $where;
6262 # Check the rule for being a suffix rule. If so, store in a hash.
6264 if ((my ($source_suffix, $object_suffix)) = ($target =~ $SUFFIX_RULE_PATTERN))
6266 $suffix_rules{$source_suffix} = $object_suffix;
6267 print "Sources ending in .$source_suffix become .$object_suffix\n"
6269 # Set SUFFIXES from suffix_rules.
6270 push @suffixes, ".$source_suffix", ".$object_suffix";
6275 # See if a target exists.
6279 return defined $targets{$target};
6283 ################################################################
6285 # Read Makefile.am and set up %contents. Simultaneously copy lines
6286 # from Makefile.am into $output_trailer or $output_vars as
6287 # appropriate. NOTE we put rules in the trailer section. We want
6288 # user rules to come after our generated stuff.
6293 my $am_file = new IO::File ("< $amfile");
6296 die "$me: couldn't open `$amfile': $!\n";
6298 print "$me: reading $amfile\n" if $verbose;
6304 while ($_ = $am_file->getline)
6306 if (/$IGNORE_PATTERN/o)
6308 # Merely delete comments beginning with two hashes.
6310 elsif (/$WHITE_PATTERN/o)
6312 # Stick a single white line before the incoming macro or rule.
6316 elsif (/$COMMENT_PATTERN/o)
6318 # Stick comments before the incoming macro or rule. Make
6319 # sure a blank line preceeds first block of comments.
6320 $spacing = "\n" unless $blank;
6322 $comment .= $spacing . $_;
6331 $output_vars .= $comment . "\n";
6335 # We save the conditional stack on entry, and then check to make
6336 # sure it is the same on exit. This lets us conditonally include
6338 my @saved_cond_stack = @cond_stack;
6339 my $cond = conditional_string (@cond_stack);
6343 my $last_var_name = '';
6344 my $last_var_type = '';
6345 my $last_var_value = '';
6346 # FIXME: shouldn't use $_ in this loop; it is too big.
6350 unless substr ($_, -1, 1) eq "\n";
6352 # Don't look at MAINTAINER_MODE_TRUE here. That shouldn't be
6353 # used by users. @MAINT@ is an anachronism now.
6354 $_ =~ s/\@MAINT\@//g
6355 unless $seen_maint_mode;
6357 my $new_saw_bk = /\\$/ && ! /$COMMENT_PATTERN/o;
6359 if (/$IGNORE_PATTERN/o)
6361 # Merely delete comments beginning with two hashes.
6363 elsif (/$WHITE_PATTERN/o)
6365 # Stick a single white line before the incoming macro or rule.
6367 &am_line_error ($., "blank line following trailing backslash")
6370 elsif (/$COMMENT_PATTERN/o)
6372 # Stick comments before the incoming macro or rule.
6373 $comment .= $spacing . $_;
6375 &am_line_error ($., "comment following trailing backslash")
6382 $output_trailer .= &make_condition (@cond_stack);
6383 $output_trailer .= $_;
6387 $last_var_value .= ' '
6388 unless $last_var_value =~ /\s$/;
6389 $last_var_value .= $_;
6393 $var_comment{$last_var_name} .= "$spacing"
6394 if (!defined $var_comment{$last_var_name}
6395 || substr ($var_comment{$last_var_name}, -1) ne "\n");
6396 $var_comment{$last_var_name} .= "$comment";
6397 $comment = $spacing = '';
6398 macro_define ($last_var_name, 0,
6399 $last_var_type, $cond,
6400 $last_var_value, $.)
6401 if $cond ne 'FALSE';
6402 push (@var_list, $last_var_name);
6407 elsif (/$IF_PATTERN/o)
6409 $cond = cond_stack_if ($1, $2, "$amfile:$.");
6411 elsif (/$ELSE_PATTERN/o)
6413 $cond = cond_stack_else ($1, $2, "$amfile:$.");
6415 elsif (/$ENDIF_PATTERN/o)
6417 $cond = cond_stack_endif ($1, $2, "$amfile:$.");
6420 elsif (/$RULE_PATTERN/o)
6425 rule_define ($1, 0, $cond, $.);
6428 $output_trailer .= $comment . $spacing;
6429 $output_trailer .= &make_condition (@cond_stack);
6430 $output_trailer .= $_;
6431 $comment = $spacing = '';
6433 elsif (/$ASSIGNMENT_PATTERN/o)
6435 # Found a macro definition.
6437 $last_var_name = $1;
6438 $last_var_type = $2;
6439 $last_var_value = $3;
6440 if ($3 ne '' && substr ($3, -1) eq "\\")
6442 # We preserve the `\' because otherwise the long lines
6443 # that are generated will be truncated by broken
6445 $last_var_value = $3 . "\n";
6450 # FIXME: this doesn't always work correctly; it will
6451 # group all comments for a given variable, no matter
6453 # Accumulating variables must not be output.
6454 $var_comment{$last_var_name} .= "$spacing"
6455 if (!defined $var_comment{$last_var_name}
6456 || substr ($var_comment{$last_var_name}, -1) ne "\n");
6457 $var_comment{$last_var_name} .= "$comment";
6458 $comment = $spacing = '';
6460 macro_define ($last_var_name, 0,
6461 $last_var_type, $cond,
6462 $last_var_value, $.)
6463 if $cond ne 'FALSE';
6464 push (@var_list, $last_var_name);
6467 elsif (/$INCLUDE_PATTERN/o)
6471 if ($path =~ s/^\$\(top_srcdir\)\///)
6473 push (@include_stack, "\$\(top_srcdir\)/$path");
6477 $path =~ s/\$\(srcdir\)\///;
6478 push (@include_stack, "\$\(srcdir\)/$path");
6479 $path = $relative_dir . "/" . $path;
6481 &read_am_file ($path);
6485 # This isn't an error; it is probably a continued rule.
6486 # In fact, this is what we assume.
6488 $output_trailer .= $comment . $spacing;
6489 $output_trailer .= &make_condition (@cond_stack);
6490 $output_trailer .= $_;
6491 $comment = $spacing = '';
6492 &am_line_error ($., "`#' comment at start of rule is unportable")
6493 if $_ =~ /^\t\s*\#/;
6496 $saw_bk = $new_saw_bk;
6497 $_ = $am_file->getline;
6500 $output_trailer .= $comment;
6502 if (join (' ', @saved_cond_stack) ne join (' ', @cond_stack))
6506 &am_error ("unterminated conditionals: @cond_stack");
6510 # FIXME: better error message here.
6511 &am_error ("conditionals not nested in include file");
6517 # define_standard_variables ()
6518 # ----------------------------
6519 # A helper for read_main_am_file which initializes configure variables
6520 # and variables from header-vars.am. This is a subr so we can call it
6522 sub define_standard_variables
6524 my $saved_output_vars = $output_vars;
6525 my ($comments, undef, $rules) =
6526 file_contents_internal (1, "$libdir/am/header-vars.am");
6528 # This will output the definitions in $output_vars, which we don't
6530 foreach my $var (sort keys %configure_vars)
6532 &define_configure_variable ($var);
6533 push (@var_list, $var);
6536 # ... hence, we restore $output_vars.
6537 $output_vars = $saved_output_vars . $comments . $rules;
6540 # Read main am file.
6541 sub read_main_am_file
6545 # This supports the strange variable tricks we are about to play.
6546 if (scalar keys %var_value > 0)
6549 &prog_error ("variable defined before read_main_am_file");
6552 # Generate copyright header for generated Makefile.in.
6553 # We do discard the output of predefined variables, handled below.
6554 $output_vars = ("# $in_file_name generated automatically by automake "
6555 . $VERSION . " from $am_file_name.\n");
6556 $output_vars .= $gen_copyright;
6558 # We want to predefine as many variables as possible. This lets
6559 # the user set them with `+=' in Makefile.am. However, we don't
6560 # want these initial definitions to end up in the output quite
6561 # yet. So we just load them, but output them later.
6562 &define_standard_variables;
6564 # Read user file, which might override some of our values.
6565 &read_am_file ($amfile);
6567 # Ouput all the Automake variables. If the user changed one, then
6568 # it is now marked as owned by the user.
6569 foreach my $var (uniq @var_list)
6571 # Don't process user variables.
6572 variable_output ($var)
6573 unless !$var_is_am{$var};
6576 # Now dump the user variables that were defined. We do it in the same
6577 # order in which they were defined (skipping duplicates).
6578 foreach my $var (uniq @var_list)
6580 # Don't process Automake variables.
6581 variable_output ($var)
6582 unless $var_is_am{$var};
6586 ################################################################
6589 # &flatten ($STRING)
6590 # ------------------
6591 # Flatten the $STRING and return the result.
6606 # &make_paragraphs ($MAKEFILE, [%TRANSFORM])
6607 # ------------------------------------------
6608 # Load a $MAKEFILE, apply the %TRANSFORM, and return it as a list of
6610 sub make_paragraphs ($%)
6612 my ($file, %transform) = @_;
6614 # Complete %transform with global options and make it a Perl
6617 "s/$IGNORE_PATTERN//gm;"
6618 . transform (%transform,
6620 'CYGNUS' => $cygnus_mode,
6622 => $seen_maint_mode ? subst ('MAINTAINER_MODE_TRUE') : '',
6624 'SHAR' => $options{'dist-shar'} || 0,
6625 'BZIP2' => $options{'dist-bzip2'} || 0,
6626 'ZIP' => $options{'dist-zip'} || 0,
6627 'COMPRESS' => $options{'dist-tarZ'} || 0,
6629 'INSTALL-INFO' => !$options{'no-installinfo'},
6630 'INSTALL-MAN' => !$options{'no-installman'},
6631 'CK-NEWS' => $options{'check-news'} || 0,
6633 'SUBDIRS' => &variable_defined ('SUBDIRS'),
6634 'TOPDIR' => backname ($relative_dir),
6635 'TOPDIR_P' => $relative_dir eq '.',
6636 'CONFIGURE-AC' => $configure_ac,
6638 'BUILD' => $seen_canonical == $AC_CANONICAL_SYSTEM,
6639 'HOST' => $seen_canonical,
6640 'TARGET' => $seen_canonical == $AC_CANONICAL_SYSTEM,
6642 'LIBTOOL' => defined $configure_vars{'LIBTOOL'})
6643 # We don't need more than two consecutive new-lines.
6644 . 's/\n{3,}/\n\n/g';
6646 # Swallow the file and apply the COMMAND.
6647 my $fc_file = new IO::File ("< $file");
6650 die "$me: installation error: cannot open `$file'\n";
6653 print "$me: reading $file\n"
6655 my $saved_dollar_slash = $/;
6657 $_ = $fc_file->getline;
6658 $/ = $saved_dollar_slash;
6663 # Split at unescaped new lines.
6664 my @lines = split (/(?<!\\)\n/, $content);
6667 while (defined ($_ = shift @lines))
6669 my $paragraph = "$_";
6670 # If we are a rule, eat as long as we start with a tab.
6671 if (/$RULE_PATTERN/smo)
6673 while (defined ($_ = shift @lines) && $_ =~ /^\t/)
6675 $paragraph .= "\n$_";
6677 unshift (@lines, $_);
6680 # If we are a comments, eat as much comments as you can.
6681 elsif (/$COMMENT_PATTERN/smo)
6683 while (defined ($_ = shift @lines)
6684 && $_ =~ /$COMMENT_PATTERN/smo)
6686 $paragraph .= "\n$_";
6688 unshift (@lines, $_);
6691 push @res, $paragraph;
6700 # ($COMMENT, $VARIABLES, $RULES)
6701 # &file_contents_internal ($IS_AM, $FILE, [%TRANSFORM])
6702 # -----------------------------------------------------
6703 # Return contents of a file from $libdir/am, automatically skipping
6704 # macros or rules which are already known. $IS_AM iff the caller is
6705 # reading an Automake file (as opposed to the user's Makefile.am).
6706 sub file_contents_internal ($$%)
6708 my ($is_am, $file, %transform) = @_;
6710 my $result_vars = '';
6711 my $result_rules = '';
6715 # We save the conditional stack on entry, and then check to make
6716 # sure it is the same on exit. This lets us conditonally include
6718 my @saved_cond_stack = @cond_stack;
6719 my $cond = conditional_string (@cond_stack);
6721 foreach (make_paragraphs ($file, %transform))
6724 &am_file_error ($file, "blank line following trailing backslash:\n$_")
6726 &am_file_error ($file, "comment following trailing backslash:\n$_")
6731 # Stick empty line before the incoming macro or rule.
6734 elsif (/$COMMENT_PATTERN/mso)
6736 # Stick comments before the incoming macro or rule.
6740 # Handle inclusion of other files.
6741 elsif (/$INCLUDE_PATTERN/o)
6743 if ($cond ne 'FALSE')
6745 my $file = ($is_am ? "$libdir/am/" : '') . $1;
6747 my ($com, $vars, $rules)
6748 = file_contents_internal ($is_am, $file, %transform);
6750 $result_vars .= $vars;
6751 $result_rules .= $rules;
6755 # Handling the conditionals.
6756 elsif (/$IF_PATTERN/o)
6758 $cond = cond_stack_if ($1, $2, $file);
6760 elsif (/$ELSE_PATTERN/o)
6762 $cond = cond_stack_else ($1, $2, $file);
6764 elsif (/$ENDIF_PATTERN/o)
6766 $cond = cond_stack_endif ($1, $2, $file);
6770 elsif (/$RULE_PATTERN/mso)
6772 # Separate relationship from optional actions: the first
6773 # `new-line tab" not preceded by backslash (continuation
6775 # I'm quite shoked! It seems that (\\\n|[^\n]) is not the
6776 # same as `([^\n]|\\\n)!!! Don't swap it, it breaks.
6778 /^((?:\\\n|[^\n])*)(?:\n(\t.*))?$/som;
6779 my ($relationship, $actions) = ($1, $2 || '');
6781 # Separate targets from dependencies: the first colon.
6782 $relationship =~ /^([^:]+\S+) *: *(.*)$/som;
6783 my ($targets, $dependencies) = ($1, $2);
6784 # Remove the escaped new lines.
6785 # I don't know why, but I have to use a tmp $flat_deps.
6786 my $flat_deps = &flatten ($dependencies);
6787 my @deps = split (' ', $flat_deps);
6789 foreach (split (' ' , $targets))
6791 # FIXME: We are not robust to people defining several targets
6792 # at once, only some of them being in %dependencies.
6794 # Output only if not in FALSE.
6795 if (defined $dependencies{$_}
6796 && $cond ne 'FALSE')
6798 &depend ($_, @deps);
6799 $actions{$_} .= $actions;
6803 # Free lance dependency. Output the rule for all the
6804 # targets instead of one by one.
6805 if (!defined $targets{$targets}
6806 && $cond ne 'FALSE')
6808 $paragraph =~ s/^/make_condition (@cond_stack)/gme;
6809 $result_rules .= "$spacing$comment$paragraph\n";
6810 rule_define ($targets, $is_am, $cond, $file);
6812 $comment = $spacing = '';
6818 elsif (/$ASSIGNMENT_PATTERN/mso)
6820 my ($var, $type, $val) = ($1, $2, $3);
6821 &am_file_error ($file, "macro `$var' with trailing backslash")
6824 # Accumulating variables must not be output.
6825 $var_comment{$var} .= "$spacing"
6826 if (!defined $var_comment{$var}
6827 || substr ($var_comment{$var}, -1) ne "\n");
6828 $var_comment{$var} .= "$comment";
6829 macro_define ($var, $is_am, $type, $cond, $val, $file)
6830 if $cond ne 'FALSE';
6831 push (@var_list, $var);
6833 # If the user has set some variables we were in charge
6834 # of (which is detected by the first reading of
6835 # `header-vars.am'), we must not output them.
6836 $result_vars .= "$spacing$comment$_\n"
6837 if $type ne '+' && $var_is_am{$var} && $cond ne 'FALSE';
6839 $comment = $spacing = '';
6843 # This isn't an error; it is probably some tokens which
6844 # configure is supposed to replace, such as `@SET-MAKE@',
6845 # or some part of a rule cut by an if/endif.
6846 if ($cond ne 'FALSE')
6848 s/^/make_condition (@cond_stack)/gme;
6849 $result_rules .= "$spacing$comment$_\n";
6851 $comment = $spacing = '';
6855 if (join (' ', @saved_cond_stack) ne join (' ', @cond_stack))
6859 &am_error ("unterminated conditionals: @cond_stack");
6863 # FIXME: better error message here.
6864 &am_error ("conditionals not nested in include file");
6868 return ($comment, $result_vars, $result_rules);
6873 # &file_contents ($BASENAME, [%TRANSFORM])
6874 # ----------------------------------------
6875 # Return contents of a file from $libdir/am, automatically skipping
6876 # macros or rules which are already known.
6877 sub file_contents ($%)
6879 my ($basename, %transform) = @_;
6880 my ($comments, $variables, $rules) =
6881 file_contents_internal (1, "$libdir/am/$basename.am", %transform);
6882 return "$comments$variables$rules";
6887 # &transform (%PAIRS)
6888 # -------------------
6889 # Foreach ($TOKEN, $VAL) in %PAIRS produce a replacement expression suitable
6890 # for file_contents which:
6891 # - replaces @$TOKEN@ with $VALUE,
6892 # - enables/disables ?$TOKEN?.
6898 while (my ($token, $val) = each %pairs)
6900 $result .= "s/\Q%$token%\E/\Q$val\E/gm;";
6903 $result .= "s/\Q?$token?\E//gm;s/^.*\Q?!$token?\E.*\\n//gm;";
6904 $result .= "s/\Q%?$token%\E/TRUE/gm;";
6908 $result .= "s/\Q?!$token?\E//gm;s/^.*\Q?$token?\E.*\\n//gm;";
6909 $result .= "s/\Q%?$token%\E/FALSE/gm;";
6917 # Find all variable prefixes that are used for install directories. A
6918 # prefix `zar' qualifies iff:
6919 # * `zardir' is a variable.
6920 # * `zar_PRIMARY' is a variable.
6921 sub am_primary_prefixes
6923 my ($primary, $can_dist, @prefixes) = @_;
6925 my %valid = map { $_ => 0 } @prefixes;
6926 $valid{'EXTRA'} = 0;
6927 foreach my $varname (keys %var_value)
6929 # Automake is allowed to define variables that look like they
6930 # are magic variables, such as INSTALL_DATA.
6932 if $var_is_am{$varname};
6934 if ($varname =~ /^(nobase_)?(dist_|nodist_)?(.*)_$primary$/)
6936 my ($base, $dist, $X) = ($1 || '', $2 || '', $3 || '');
6937 if ($dist ne '' && ! $can_dist)
6939 # Note that a configure variable is always legitimate.
6940 # It is natural to name such variables after the
6941 # primary, so we explicitly allow it.
6942 if (! defined $configure_vars{$varname})
6944 &am_line_error ($varname,
6945 "invalid variable `$varname': `dist' is forbidden");
6948 elsif (! defined $valid{$X} && ! &variable_defined ("${X}dir"))
6950 # Note that a configure variable is always legitimate.
6951 # It is natural to name such variables after the
6952 # primary, so we explicitly allow it.
6953 if (! defined $configure_vars{$varname})
6955 &am_line_error ($varname,
6956 "invalid variable `$varname'");
6961 # Ensure all extended prefixes are actually used.
6962 $valid{"$base$dist$X"} = 1;
6970 # Handle `where_HOW' variable magic. Does all lookups, generates
6971 # install code, and possibly generates code to define the primary
6972 # variable. The first argument is the name of the .am file to munge,
6973 # the second argument is the primary variable (eg HEADERS), and all
6974 # subsequent arguments are possible installation locations. Returns
6975 # list of all values of all _HOW targets.
6977 # FIXME: this should be rewritten to be cleaner. It should be broken
6978 # up into multiple functions.
6980 # Usage is: am_install_var (OPTION..., file, HOW, where...)
6987 my $default_dist = 0;
6990 if ($args[0] eq '-noextra')
6994 elsif ($args[0] eq '-candist')
6998 elsif ($args[0] eq '-defaultdist')
7003 elsif ($args[0] !~ /^-/)
7010 my ($file, $primary, @prefixes) = @args;
7012 # Now that configure substitutions are allowed in where_HOW
7013 # variables, it is an error to actually define the primary. We
7014 # allow `JAVA', as it is customarily used to mean the Java
7015 # interpreter. This is but one of several Java hacks. Similarly,
7016 # `PYTHON' is customarily used to mean the Python interpreter.
7017 &am_line_error ($primary, "`$primary' is an anachronism")
7018 if &variable_defined ($primary)
7019 && ($primary ne 'JAVA' && $primary ne 'PYTHON');
7022 # Look for misspellings. It is an error to have a variable ending
7023 # in a "reserved" suffix whose prefix is unknown, eg
7024 # "bni_PROGRAMS". However, unusual prefixes are allowed if a
7025 # variable of the same name (with "dir" appended) exists. For
7026 # instance, if the variable "zardir" is defined, then
7027 # "zar_PROGRAMS" becomes valid. This is to provide a little extra
7028 # flexibility in those cases which need it.
7029 my %valid = &am_primary_prefixes ($primary, $can_dist, @prefixes);
7031 # If a primary includes a configure substitution, then the EXTRA_
7032 # form is required. Otherwise we can't properly do our job.
7034 my $warned_about_extra = 0;
7039 # True if the iteration is the first one. Used for instance to
7040 # output parts of the associated file only once.
7042 foreach my $X (sort keys %valid)
7044 my $one_name = $X . '_' . $primary;
7046 unless (&variable_defined ($one_name));
7048 my $strip_subdir = 1;
7049 # If subdir prefix should be preserved, do so.
7050 if ($X =~ /^nobase_/)
7056 my $nodir_name = $X;
7057 # If files should be distributed, do so.
7061 $dist_p = (($default_dist && $one_name !~ /^nodist_/)
7062 || (! $default_dist && $one_name =~ /^dist_/));
7063 $nodir_name =~ s/^(dist|nodist)_//;
7066 # Append actual contents of where_PRIMARY variable to
7068 foreach my $rcurs (&variable_value_as_list ($one_name, 'all'))
7070 # Skip configure substitutions. Possibly bogus.
7071 if ($rcurs =~ /^\@.*\@$/)
7075 if (! $warned_about_extra)
7077 $warned_about_extra = 1;
7078 &am_line_error ($one_name,
7079 "`$one_name' contains configure substitution, but shouldn't");
7082 # Check here to make sure variables defined in
7083 # configure.ac do not imply that EXTRA_PRIMARY
7085 elsif (! defined $configure_vars{$one_name})
7087 $require_extra = $one_name
7094 push (@result, $rcurs);
7097 # A blatant hack: we rewrite each _PROGRAMS primary to
7098 # include EXEEXT when in Cygwin32 mode.
7099 if ($primary eq 'PROGRAMS')
7101 my @conds = &variable_conditions ($one_name);
7104 foreach my $cond (@conds)
7106 my @one_binlist = ();
7107 my @condval = &variable_value_as_list ($one_name,
7109 foreach my $rcurs (@condval)
7111 if ($rcurs =~ /\./ || $rcurs =~ /^\@.*\@$/)
7113 push (@one_binlist, $rcurs);
7117 push (@one_binlist, $rcurs . '$(EXEEXT)');
7121 push (@condvals, $cond);
7122 push (@condvals, join (' ', @one_binlist));
7125 variable_delete ($one_name);
7128 my $cond = shift (@condvals);
7129 my @val = split (' ', shift (@condvals));
7130 &define_pretty_variable ($one_name, $cond, @val);
7134 # "EXTRA" shouldn't be used when generating clean targets,
7135 # all, or install targets.
7138 # We used to warn if EXTRA_FOO was defined uselessly,
7139 # but this was annoying.
7145 push (@check, '$(' . $one_name . ')');
7149 push (@used, '$(' . $one_name . ')');
7152 # Is this to be installed?
7153 my $install_p = $X ne 'noinst' && $X ne 'check';
7155 # If so, with install-exec? (or install-data?).
7156 my $exec_p = (defined $exec_dir_p {$X}
7160 # Singular form of $PRIMARY.
7161 (my $one_primary = $primary) =~ s/S$//;
7162 $output_rules .= &file_contents ($file,
7165 'PRIMARY' => $primary,
7166 'ONE_PRIMARY' => $one_primary,
7168 'NDIR' => $nodir_name,
7169 'BASE' => $strip_subdir,
7172 'INSTALL' => $install_p,
7173 'DIST' => $dist_p));
7178 # The JAVA variable is used as the name of the Java interpreter.
7179 # The PYTHON variable is used as the name of the Python interpreter.
7180 if (@used && $primary ne 'JAVA' && $primary ne 'PYTHON')
7183 &define_pretty_variable ($primary, '', @used);
7184 $output_vars .= "\n";
7187 if ($require_extra && ! &variable_defined ('EXTRA_' . $primary))
7189 &am_line_error ($require_extra,
7190 "`$require_extra' contains configure substitution, but `EXTRA_$primary' not defined");
7193 # Push here because PRIMARY might be configure time determined.
7194 push (@all, '$(' . $primary . ')')
7195 if @used && $primary ne 'JAVA' && $primary ne 'PYTHON';
7197 # Make the result unique. This lets the user use conditionals in
7198 # a natural way, but still lets us program lazily -- we don't have
7199 # to worry about handling a particular object more than once.
7200 return uniq (sort @result);
7204 ################################################################
7206 # Each key in this hash is the name of a directory holding a
7207 # Makefile.in. These variables are local to `is_make_dir'.
7209 my $make_dirs_set = 0;
7214 if (! $make_dirs_set)
7216 foreach my $iter (@configure_input_files)
7218 $make_dirs{dirname ($iter)} = 1;
7220 # We also want to notice Makefile.in's.
7221 foreach my $iter (@other_input_files)
7223 if ($iter =~ /Makefile\.in$/)
7225 $make_dirs{dirname ($iter)} = 1;
7230 return defined $make_dirs{$dir};
7233 ################################################################
7235 # This variable is local to the "require file" set of functions.
7236 my @require_file_paths = ();
7238 # If a file name appears as a key in this hash, then it has already
7239 # been checked for. This variable is local to the "require file"
7241 %require_file_found = ();
7243 # See if we want to push this file onto dist_common. This function
7244 # encodes the rules for deciding when to do so.
7245 sub maybe_push_required_file
7247 my ($dir, $file, $fullfile) = @_;
7249 if ($dir eq $relative_dir)
7251 &push_dist_common ($file);
7253 elsif ($relative_dir eq '.' && ! &is_make_dir ($dir))
7255 # If we are doing the topmost directory, and the file is in a
7256 # subdir which does not have a Makefile, then we distribute it
7258 &push_dist_common ($fullfile);
7263 # &require_file_internal ($IS_CONFIGURE, $LINE, $MYSTRICT, @FILES)
7264 # ----------------------------------------------------------------
7265 # Verify that the file must exist in the current directory.
7266 # $MYSTRICT is the strictness level at which this file becomes required.
7268 # Must set require_file_paths before calling this function.
7269 # require_file_paths is set to hold a single directory (the one in
7270 # which the first file was found) before return.
7271 sub require_file_internal
7273 my ($is_configure, $line, $mystrict, @files) = @_;
7275 foreach my $file (@files)
7282 # If we've already looked for it, we're done.
7283 next if defined $require_file_found{$file};
7284 $require_file_found{$file} = 1;
7287 my $dangling_sym = 0;
7288 foreach my $dir (@require_file_paths)
7290 $fullfile = $dir . "/" . $file;
7291 $errdir = $dir unless $errdir;
7293 # Use different name for "error filename". Otherwise on
7294 # an error the bad file will be reported as eg
7295 # `../../install-sh' when using the default
7297 $errfile = $errdir . '/' . $file;
7299 if (-l $fullfile && ! -f readlink ($fullfile))
7304 elsif (-f $fullfile)
7307 &maybe_push_required_file ($dir, $file, $fullfile);
7313 if ($found_it && ! $force_missing)
7315 # Prune the path list.
7316 @require_file_paths = $save_dir;
7320 if ($strictness >= $mystrict)
7322 if ($dangling_sym && $add_missing)
7330 # Only install missing files according to our desired
7332 my $message = "required file `$errfile' not found";
7337 # Maybe run libtoolize.
7338 my @syslist = ('libtoolize', '--automake');
7339 push @syslist, '--copy'
7342 && grep ($_ eq $file, @libtoolize_files)
7343 && system (@syslist))
7345 $message = "installing `$errfile'";
7347 $trailer = "; cannot run `libtoolize': $!";
7349 elsif (-f ("$libdir/$file"))
7351 # Install the missing file. Symlink if we
7352 # can, copy if we must. Note: delete the file
7353 # first, in case it is a dangling symlink.
7354 $message = "installing `$errfile'";
7355 # Windows Perl will hang if we try to delete a
7356 # file that doesn't exist.
7357 unlink ($errfile) if -f $errfile;
7358 if ($symlink_exists && ! $copy_missing)
7360 if (! symlink ("$libdir/$file", $errfile))
7363 $trailer = "; error while making link: $!";
7366 elsif (system ('cp', "$libdir/$file", $errfile))
7369 $trailer = "\n error while copying";
7373 &maybe_push_required_file (dirname ($errfile),
7376 # Prune the path list.
7377 @require_file_paths = &dirname ($errfile);
7384 # FIXME: allow actual file to be specified.
7385 &am_conf_line_warning ($configure_ac, $line,
7386 "$message$trailer");
7390 &am_line_warning ($line, "$message$trailer");
7397 # FIXME: allow actual file to be specified.
7398 &am_conf_line_error ($configure_ac, $line,
7399 "$message$trailer");
7403 &am_line_error ($line, "$message$trailer");
7411 # Like require_file_with_line, but error messages refer to
7412 # configure.ac, not the current Makefile.am.
7413 sub require_file_with_conf_line
7415 @require_file_paths = $relative_dir;
7416 &require_file_internal (1, @_);
7419 sub require_file_with_line
7421 @require_file_paths = $relative_dir;
7422 &require_file_internal (0, @_);
7427 @require_file_paths = $relative_dir;
7428 &require_file_internal (0, '', @_);
7431 # Require a file that is also required by Autoconf. Looks in
7432 # configuration path, as specified by AC_CONFIG_AUX_DIR.
7433 sub require_config_file
7435 @require_file_paths = @config_aux_path;
7436 &require_file_internal (1, '', @_);
7437 my $dir = $require_file_paths[0];
7438 @config_aux_path = @require_file_paths;
7439 # Avoid unsightly '/.'s.
7440 $config_aux_dir = '$(top_srcdir)' . ($dir eq '.' ? "" : "/$dir");
7443 # Assumes that the line number is in Makefile.am.
7444 sub require_conf_file_with_line
7446 @require_file_paths = @config_aux_path;
7447 &require_file_internal (0, @_);
7448 my $dir = $require_file_paths[0];
7449 @config_aux_path = @require_file_paths;
7450 # Avoid unsightly '/.'s.
7451 $config_aux_dir = '$(top_srcdir)' . ($dir eq '.' ? "" : "/$dir");
7454 # Assumes that the line number is in configure.ac.
7455 sub require_conf_file_with_conf_line
7457 @require_file_paths = @config_aux_path;
7458 &require_file_internal (1, @_);
7459 my $dir = $require_file_paths[0];
7460 @config_aux_path = @require_file_paths;
7461 # avoid unsightly '/.'s.
7462 $config_aux_dir = '$(top_srcdir)' . ($dir eq '.' ? "" : "/$dir");
7465 ################################################################
7467 # Push a list of files onto dist_common.
7468 sub push_dist_common
7470 &prog_error ("push_dist_common run after handle_dist")
7471 if $handle_dist_run;
7472 macro_define ('DIST_COMMON', 1, '+', '', join (' ', @_), '');
7479 $strictness_name = $_[0];
7480 if ($strictness_name eq 'gnu')
7484 elsif ($strictness_name eq 'gnits')
7486 $strictness = $GNITS;
7488 elsif ($strictness_name eq 'foreign')
7490 $strictness = $FOREIGN;
7494 die "$me: level `$strictness_name' not recognized\n";
7499 ################################################################
7501 # Ensure a file exists.
7506 my $touch = new IO::File (">> $file");
7510 # Glob something. Do this to avoid indentation screwups everywhere we
7511 # want to glob. Gross!
7518 # Remove one level of brackets and strip leading spaces,
7519 # as does m4 to function arguments.
7525 my @letters = split //;
7534 next if $depth == 1;
7539 next if $depth == 0;
7540 # don't count orphan right brackets
7541 $depth = 0 if $depth < 0;
7545 return join '', @result;
7548 ################################################################
7550 # Print an error message and set exit status.
7553 warn "$me: ${am_file}.am: @_\n";
7557 # am_file_error ($FILE, @ARGS)
7558 # ----------------------------
7561 my ($file, @args) = @_;
7563 warn "$file: @args\n";
7569 my ($symbol, @args) = @_;
7571 if ($symbol && "$symbol" ne '-1')
7573 my $file = "${am_file}.am";
7575 if ($symbol =~ /^\d+$/)
7577 # SYMBOL is a line number, so just add the colon.
7578 $file .= ':' . $symbol;
7580 elsif (defined $var_line{$symbol})
7582 # SYMBOL is a variable defined in Makefile.am, so add the
7583 # line number we saved from there.
7584 $file .= ':' . $var_line{$symbol};
7586 elsif (defined $configure_vars{$symbol})
7588 # SYMBOL is a variable defined in configure.ac, so add the
7589 # appropriate line number.
7590 $file = $configure_vars{$symbol};
7594 # Couldn't find the line number.
7596 warn $file, ": @args\n";
7605 # Like am_error, but while scanning configure.ac.
7608 # FIXME: can run in subdirs.
7609 warn "$me: $configure_ac: @_\n";
7613 # Error message with line number referring to configure.ac.
7614 sub am_conf_line_error
7616 my ($file, $line, @args) = @_;
7620 warn "$file: $line: @args\n";
7625 &am_conf_error (@args);
7629 # Warning message with line number referring to configure.ac.
7630 # Does not affect exit_status
7631 sub am_conf_line_warning
7633 my $saved_exit_status = $exit_status;
7634 my $sig = $SIG{'__WARN__'};
7635 $SIG{'__WARN__'} = 'DEFAULT';
7636 am_conf_line_error (@_);
7637 $exit_status = $saved_exit_status;
7638 $SIG{'__WARN__'} = $sig;
7641 # Like am_line_error, but doesn't affect exit status.
7644 my $saved_exit_status = $exit_status;
7645 my $sig = $SIG{'__WARN__'};
7646 $SIG{'__WARN__'} = 'DEFAULT';
7648 $exit_status = $saved_exit_status;
7649 $SIG{'__WARN__'} = $sig;
7652 # Tell user where our aclocal.m4 is, but only once.
7653 sub keyed_aclocal_warning
7656 warn "$me: macro `$key' can be generated by `aclocal'\n";
7659 # Print usage information.
7663 Usage: $0 [OPTION] ... [Makefile]...
7665 Generate Makefile.in for configure from Makefile.am.
7668 --help print this help, then exit
7669 --version print version number, then exit
7670 -v, --verbose verbosely list files processed
7671 -o, --output-dir=DIR put generated Makefile.in's into DIR
7672 --no-force only update Makefile.in's that are out of date
7674 Dependency tracking:
7675 -i, --ignore-deps disable dependency tracking code
7676 --include-deps enable dependency tracking code
7679 --cygnus assume program is part of Cygnus-style tree
7680 --foreign set strictness to foreign
7681 --gnits set strictness to gnits
7682 --gnu set strictness to gnu
7685 -a, --add-missing add missing standard files to package
7686 --libdir=DIR directory storing library files
7687 -c, --copy with -a, copy missing files (default is symlink)
7688 -f, --force-missing force update of standard files
7693 foreach my $iter (sort ((@common_files, @common_sometimes)))
7695 push (@lcomm, $iter) unless $iter eq $last;
7699 my ($one, $two, $three, $four, $max);
7700 print "\nFiles which are automatically distributed, if found:\n";
7701 format USAGE_FORMAT =
7702 @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<
7703 $one, $two, $three, $four
7705 $~ = "USAGE_FORMAT";
7706 $max = int (($#lcomm + 1) / 4);
7708 for (my $i = 0; $i < $max; ++$i)
7711 $two = $lcomm[$max + $i];
7712 $three = $lcomm[2 * $max + $i];
7713 $four = $lcomm[3 * $max + $i];
7717 my $mod = ($#lcomm + 1) % 4;
7720 $one = $lcomm[$max];
7721 $two = ($mod > 1) ? $lcomm[2 * $max] : '';
7722 $three = ($mod > 2) ? $lcomm[3 * $max] : '';
7723 $four = ($mod > 3) ? $lcomm[4 * $max] : '';
7727 print "\nReport bugs to <bug-automake\@gnu.org>.\n";
7734 # Print version information
7738 automake (GNU $PACKAGE) $VERSION
7739 Written by Tom Tromey <tromey\@cygnus.com>.
7741 Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
7742 Free Software Foundation, Inc.
7743 This is free software; see the source for copying conditions. There is NO
7744 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.