5 eval 'exec @PERL@ -S $0 ${1+"$@"}'
8 # automake - create Makefile.in from Makefile.am
9 # Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
11 # This program is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by
13 # the Free Software Foundation; either version 2, or (at your option)
16 # This program is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write to the Free Software
23 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
26 # Originally written by David Mackenzie <djm@gnu.ai.mit.edu>.
27 # Perl reimplementation by Tom Tromey <tromey@drip.colorado.edu>.
30 # Parameters set by configure. Not to be changed. NOTE: assign
31 # VERSION as string so that eg version 0.30 will print correctly.
32 $VERSION = "@VERSION@";
33 $PACKAGE = "@PACKAGE@";
35 $am_dir = "@datadir@/@PACKAGE@";
38 $IGNORE_PATTERN = "^##([^#].*)?\$";
39 $WHITE_PATTERN = "^[ \t]*\$";
40 $COMMENT_PATTERN = "^#";
41 $RULE_PATTERN = "^([\$a-zA-Z_.][-.a-zA-Z0-9_(){}/]*) *:([^=].*|)\$";
42 $MACRO_PATTERN = "^([A-Za-z][A-Za-z0-9_]*)[ \t]*:?=[ \t]*(.*)\$";
43 $BOGUS_MACRO_PATTERN = "^([^ \t]*)[ \t]*:?=[ \t]*(.*)\$";
44 $GNITS_VERSION_PATTERN = "[0-9]+\\.[0-9]+([a-z]|\\.[0-9]+)?";
46 # Some regular expressions. One reason to put them here is that it
47 # makes indentation work better in Emacs.
48 $AC_CONFIG_AUX_DIR_PATTERN = "AC_CONFIG_AUX_DIR\\(([^)]+)\\)";
49 $AM_INIT_AUTOMAKE_PATTERN = "AM_INIT_AUTOMAKE\\([^,]*,([^)]+)\\)";
51 # Constants to define the "strictness" level.
58 # Variables global to entire run.
60 # TRUE if we should always generate Makefile.in.
61 $force_generation = 1;
63 # Strictness level as set on command line.
64 $default_strictness = $GNU;
66 # Name of strictness level, as set on command line.
67 $default_strictness_name = 'gnu';
69 # This is TRUE if GNU make specific automatic dependency generation
70 # code should be included in generated Makefile.in.
71 $cmdline_use_dependencies = 1;
73 # TRUE if in verbose mode.
76 # This holds our (eventual) exit status. We don't actually exit until
77 # we have processed all input files.
80 # From the Perl manual.
81 $symlink_exists = (eval 'symlink ("", "");', $@ eq '');
83 # TRUE if missing standard files should be installed.
86 # Files found by scanning configure.in for LIBOBJS.
89 # True if AM_C_PROTOTYPES appears in configure.in.
92 # Names used in AC_CONFIG_HEADER call. $config_name is the actual
93 # (first) argument. $config_header is the '.in' file. Ordinarily the
94 # second is derived from the first, but they can be different if the
95 # weird "NAME:FILE" syntax is used.
98 # Line number at which AC_CONFIG_HEADER appears in configure.in.
99 $config_header_line = 0;
101 # Directory where output files go. Actually, output files are
102 # relative to this directory.
103 $output_directory = '.';
105 # Relative location of top build directory.
108 # Absolute location of top build directory.
109 $build_directory = '';
111 # Name of srcdir as given in build directory's Makefile. For
115 # List of Makefile.am's to process.
118 # List of files in AC_OUTPUT without Makefile.am.
119 @other_input_files = ();
120 # Line number at which AC_OUTPUT seen.
123 # List of directories to search for configure-required files. This
124 # can be set by AC_CONFIG_AUX_DIR.
125 @config_aux_path = ('.', '..', '../..');
126 $config_aux_dir = '';
128 # Whether AC_PROG_MAKE_SET has been seen in configure.in.
131 # Whether ud_GNU_GETTEXT has been seen in configure.in.
133 # Line number at which ud_GNU_GETTEXT seen.
134 $ac_gettext_line = 0;
136 # Whether ALL_LINGUAS has been seen.
140 # Line number at which it appears.
141 $all_linguas_line = 0;
143 # 1 if AC_PROG_INSTALL seen, 2 if AM_PROG_INSTALL seen.
144 $seen_prog_install = 0;
146 # 1 if any scripts installed, 0 otherwise.
147 $scripts_installed = 0;
149 # Whether AC_PATH_XTRA has been seen in configure.in.
152 # Whether YACC variable has been seen in configure.in.
155 # Two variables to control lex use. One is for AC_DECL_YYTEXT and the
156 # other is for AC_PROG_LEX.
157 $seen_decl_yytext = 0;
160 # TRUE if we've seen AC_PROG_CC.
163 # TRUE if we've seen AC_PROG_CXX.
166 # TRUE if we've seen AC_CANONICAL_(HOST|SYSTEM). The presence of
167 # AC_CHECK_TOOL also sets this.
170 # TRUE if we've seen AC_PROG_RANLIB.
173 # TRUE if we've seen AC_ARG_PROGRAM.
176 # TRUE if we've seen AM_PROG_LIBTOOL.
180 # TRUE if we've seen AM_MAINTAINER_MODE.
181 $seen_maint_mode = 0;
183 # TRUE if we've seen PACKAGE and VERSION.
187 # Actual version we've seen.
188 $package_version = '';
190 # Line number where we saw version definition.
191 $package_version_line = 0;
193 # TRUE if we've seen AM_PATH_LISPDIR.
197 # Charsets used by maintainer and in distribution. MAINT_CHARSET is
198 # handled in a funny way: if seen in the top-level Makefile.am, it is
199 # used for every directory which does not specify a different value.
200 # The rationale here is that some directories (eg gettext) might be
201 # distributions of other packages, and thus require their own charset
202 # info. However, the DIST_CHARSET must be the same for the entire
203 # package; it can only be set at top-level.
204 # FIXME: this yields bugs when rebuilding. What to do? Always
205 # read (and sometimes discard) top-level Makefile.am?
207 $dist_charset = 'utf8'; # recode doesn't support this yet.
209 # Name of input file ("Makefile.in") and output file ("Makefile.am").
210 # These have no directory components.
216 &initialize_global_constants;
218 # Parse command line.
219 &parse_arguments (@ARGV);
221 # Do configure.in scan only once.
224 die "automake: no \`Makefile.am' found or specified\n"
227 # Now do all the work on each file.
228 foreach $am_file (@input_files)
230 # FIXME: should support the AC_OUTPUT ":" syntax here.
231 if (! -f ($am_file . '.am'))
233 &am_error ('no such file');
237 &generate_makefile ($am_file);
241 if ($seen_prog_install <= $scripts_installed)
243 &am_conf_error (($scripts_installed ? 'AM_PROG_INSTALL' : 'AC_PROG_INSTALL')
244 . " must be used in configure.in");
245 &keyed_aclocal_warning ('AM_PROG_INSTALL')
246 if $scripts_installed;
252 ################################################################
254 # Parse command line.
257 local (@arglist) = @_;
260 &set_strictness ('gnu');
264 if ($arglist[0] eq "--version")
266 print "automake (GNU $PACKAGE) $VERSION\n";
267 print "Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.\n";
268 print "automake comes with ABSOLUTELY NO WARRANTY.\n";
269 print "You may redistribute copies of automake\n";
270 print "under the terms of the GNU General Public License.\n";
271 print "For more information about these matters, see the file named COPYING.\n";
274 elsif ($arglist[0] eq "--help")
278 elsif ($arglist[0] =~ /^--amdir=(.+)$/)
282 elsif ($arglist[0] eq '--amdir')
284 &require_argument (@arglist);
286 $am_dir = $arglist[0];
288 elsif ($arglist[0] =~ /^--build-dir=(.+)$/)
291 $build_directory = $1 . '/';
293 elsif ($arglist[0] eq '--build-dir')
295 &require_argument (@arglist);
298 $build_directory = $arglist[0] . '/';
300 elsif ($arglist[0] =~ /^--srcdir-name=(.+)$/)
304 elsif ($arglist[0] eq '--srcdir-name')
306 &require_argument (@arglist);
308 $srcdir_name = $arglist[0];
310 elsif ($arglist[0] =~ /^--strictness=(.+)$/)
312 &set_strictness ($1);
314 elsif ($arglist[0] eq '--gnu')
316 &set_strictness ('gnu');
318 elsif ($arglist[0] eq '--gnits')
320 &set_strictness ('gnits');
322 elsif ($arglist[0] eq '--foreign')
324 &set_strictness ('foreign');
326 elsif ($arglist[0] eq '--strictness' || $arglist[0] eq '-s')
328 &require_argument (@arglist);
330 &set_strictness ($arglist[0]);
332 elsif ($arglist[0] eq '--include-deps' || $arglist[0] eq '-i')
334 $cmdline_use_dependencies = 0;
336 elsif ($arglist[0] eq '--no-force')
338 $force_generation = 0;
340 elsif ($arglist[0] =~ /^--output-dir=(.*)$/)
342 # Set output directory.
343 $output_directory = $1;
345 elsif ($arglist[0] eq '--output-dir' || $arglist[0] eq '-o')
347 &require_argument (@arglist);
349 $output_directory = $arglist[0];
351 elsif ($arglist[0] eq '--add-missing' || $arglist[0] eq '-a')
355 elsif ($arglist[0] eq '--verbose' || $arglist[0] eq '-v')
359 elsif ($arglist[0] eq '--')
361 # Stop option processing.
363 push (@input_files, @arglist);
366 elsif ($arglist[0] =~ /^-/)
368 die "automake: unrecognized option -- \`$arglist[0]'\nTry \`automake --help' for more information.\n";
372 push (@input_files, $arglist[0]);
378 # Take global strictness from whatever we currently have set.
379 $default_strictness = $strictness;
380 $default_strictness_name = $strictness_name;
383 # Ensure argument exists, or die.
386 local ($arg, @arglist) = @_;
387 die "automake: no argument given for option \`$arg'\n"
391 ################################################################
393 # Generate a Makefile.in given the name of the corresponding Makefile.
394 sub generate_makefile
396 local ($makefile) = @_;
398 ($am_file_name = $makefile) =~ s/^.*\///;
399 $in_file_name = $am_file_name . '.in';
400 $am_file_name .= '.am';
402 &initialize_per_input;
403 $relative_dir = &dirname ($makefile);
405 # At the toplevel directory, we might need config.guess, config.sub
407 if ($relative_dir eq '.')
409 # libtool requires some files.
410 &require_conf_file_with_conf_line ($libtool_line, $FOREIGN,
411 'config.sub', 'config.guess',
412 'libtool') if $seen_libtool;
414 # AC_CANONICAL_HOST and AC_CANONICAL_SYSTEM need config.guess and
416 &require_config_file ($FOREIGN, 'config.guess', 'config.sub')
420 # We still need Makefile.in here, because sometimes the `dist'
421 # target doesn't re-run automake.
422 &push_dist_common ($in_file_name, $am_file_name);
423 push (@sources, '$(SOURCES)')
424 if &variable_defined ('SOURCES');
425 push (@objects, '$(OBJECTS)')
426 if &variable_defined ('OBJECTS');
428 # This is always the default target. This gives us freedom to do
429 # things in whatever order is convenient.
430 $output_rules .= "default: all\n\n";
431 push (@phony, 'default');
433 &read_am_file ($makefile . '.am');
436 # Fatal error. Just return, so we can continue with next file.
440 # Check first, because we might modify some state.
441 &check_gnu_standards;
442 &check_gnits_standards;
450 # This must be run after all the sources are scanned.
451 &handle_yacc_lex_cxx;
453 # This is here for lack of a better place to put it.
454 if (&variable_defined ('BUILT_SOURCES'))
456 push (@all, '$(BUILT_SOURCES)');
459 # Re-init SOURCES and OBJECTS. FIXME: other code shouldn't depend
460 # on this (but currently does).
461 $contents{'SOURCES'} = join (' ', @sources);
462 $contents{'OBJECTS'} = join (' ', @objects);
472 &handle_dependencies;
475 &handle_merge_targets;
482 if (! -d ($output_directory . '/' . $relative_dir))
484 mkdir ($output_directory . '/' . $relative_dir, 0755);
487 local ($out_file) = $output_directory . '/' . $makefile . ".in";
488 if (! $force_generation && -e $out_file)
490 local ($am_time) = (stat ($makefile . '.am'))[9];
491 local ($in_time) = (stat ($out_file))[9];
492 # FIXME: how to do unsigned comparison?
493 if ($am_time < $in_time)
500 if (! open (GM_FILE, "> " . $out_file))
502 warn "automake: ${am_file}.in: cannot open: $!\n";
506 print "automake: creating ", $makefile, ".in\n" if $verbose;
508 print GM_FILE $output_vars;
509 print GM_FILE $output_rules;
510 print GM_FILE $output_trailer;
515 ################################################################
517 # Handle AUTOMAKE_OPTIONS variable. Return 1 on error, 0 otherwise.
520 return 0 if ! &variable_defined ('AUTOMAKE_OPTIONS');
522 foreach (&variable_value_as_list ('AUTOMAKE_OPTIONS'))
525 if ($_ eq 'gnits' || $_ eq 'gnu' || $_ eq 'foreign')
527 &set_strictness ($_);
531 # An option like "../lib/ansi2knr" is allowed. With no
532 # path prefix, we assume the required programs are in this
533 # directory. We save the actual option for later.
534 $options{'ansi2knr'} = $_;
536 elsif ($_ eq 'no-installman' || $_ eq 'no-installinfo'
537 || $_ eq 'dist-shar' || $_ eq 'dist-zip'
538 || $_ eq 'dist-tarZ' || $_ eq 'dejagnu')
540 # Explicitly recognize these.
542 elsif ($_ eq 'no-dependencies')
544 $use_dependencies = 0;
546 elsif (/([0-9]+)\.([0-9]+)/)
548 # Got a version number. Note that alpha releases count as
549 # the next higher release. Note also that we assume there
550 # will be a maximum of 100 minor releases for any given
552 local ($rmajor, $rminor) = ($1, $2);
553 if ($VERSION !~ /([0-9]+)\.([0-9]+)([a-z])?/)
556 "automake: programming error: version is incorrect\n";
559 local ($tmajor, $tminor) = ($1, $2);
560 # Handle alpha versions.
561 ++$tminor if defined $3;
563 if ($rmajor > $tmajor || ($rmajor == $tmajor && $rminor > $tminor))
565 &am_line_error ('AUTOMAKE_OPTIONS',
566 "require version $_, only have $VERSION");
572 &am_line_error ('AUTOMAKE_OPTIONS',
573 'option ', $_, 'not recognized');
580 # Return object extension. Just once, put some code into the output.
581 sub get_object_extension
583 if (! $dir_holds_sources)
587 if (&variable_defined ('CONFIG_HEADER'))
589 ($xform = &dirname ($contents{'CONFIG_HEADER'}))
591 $xform = '-I' . $xform;
593 $xform = 's/\@CONFIG_INCLUDE_SPEC\@/' . $xform . '/go';
594 $output_vars .= &file_contents_with_transform ($xform,
596 $output_rules .= &file_contents ('compile');
597 &push_phony_cleaners ('compile');
599 # If using X, include some extra variable definitions. NOTE
600 # we don't want to force these into CFLAGS or anything,
601 # because not all programs will necessarily use X.
605 foreach $var ('X_CFLAGS', 'X_LIBS', 'X_EXTRA_LIBS', 'X_PRE_LIBS')
607 &define_variable ($var, "\@$var\@");
611 # Check for automatic de-ANSI-fication.
612 $dir_holds_sources = '.o';
613 push (@suffixes, '.c', '.o');
614 push (@clean, 'compile');
616 if (defined $options{'ansi2knr'})
618 if (! $am_c_prototypes)
620 &am_line_error ('AUTOMAKE_OPTIONS',
621 "option \`ansi2knr' in use but \`AM_C_PROTOTYPES' not in configure.in");
622 &keyed_aclocal_warning ('AM_C_PROTOTYPES');
623 # Only give this error once.
624 $am_c_prototypes = 1;
627 $dir_holds_sources = '$o';
628 push (@suffixes, '._c', '._o');
630 # Only require ansi2knr files if they should appear in
632 if ($options{'ansi2knr'} eq 'ansi2knr')
634 &require_file_with_line ('AUTOMAKE_OPTIONS', $FOREIGN,
635 'ansi2knr.c', 'ansi2knr.1');
636 $output_rules .= &file_contents ('kr-extra');
637 push (@clean, 'krextra');
638 &push_phony_cleaners ('krextra');
641 &define_variable ('o', ".\@U\@o");
643 # Make sure ansi2knr can be found: if no path specified,
645 local ($apath) = $options{'ansi2knr'};
646 $apath = './' . $apath
647 unless $apath =~ /\//;
648 &define_variable ("ANSI2KNR", $apath);
650 $output_rules .= &file_contents ('compile-kr');
651 $output_rules .= &file_contents ('clean-kr');
654 &push_phony_cleaners ('kr');
657 return $dir_holds_sources;
660 # Handle yacc and lex.
661 sub handle_yacc_lex_cxx
664 # First do yacc and lex.
667 local ($yacc_count) = scalar (keys %yacc_sources);
668 local ($lex_count) = scalar (keys %lex_sources);
671 push (@suffixes, '.y');
672 &define_variable ('YACC', "\@YACC\@");
673 $output_rules .= ".y.c:\n\t";
676 $output_rules .= '$(SHELL) $(INTERLOCK) =yacclockdir $(YLWRAP) "$(YACC)" y.tab.c $*.c y.tab.h $*.h -- $(YFLAGS) $<';
680 $output_rules .= ('$(YACC) $(YFLAGS) $< && mv y.tab.c $@' . "\n\t"
681 . 'if test -f y.tab.h; then mv y.tab.h $*.h; else :; fi');
683 $output_rules .= "\n";
685 if (! $seen_prog_yacc)
687 # FIXME: should include a reference line. FIXME: maybe
688 # directly reference AC_PROG_YACC somehow?
689 &am_error ("yacc source seen but \`YACC' not defined in \`configure.in'\n");
694 push (@suffixes, '.l');
695 &define_variable ("LEX", "\@LEX\@");
696 &define_variable ("LEX_OUTPUT_ROOT", "\@LEX_OUTPUT_ROOT\@");
697 &define_variable ("LEXLIB", "\@LEXLIB\@");
698 $output_rules .= ".l.c:\n\t";
701 $output_rules .= '$(SHELL) $(INTERLOCK) =lexlockdir $(YLWRAP) "$(LEX)" $(LEX_OUTPUT_ROOT).c $@ -- $(LFLAGS) $<';
705 $output_rules .= '$(LEX) $(LFLAGS) $< && mv $(LEX_OUTPUT_ROOT).c $@';
707 $output_rules .= "\n";
709 if (! $seen_prog_lex)
711 &am_error ("lex source seen but \`AC_PROG_LEX' not in \`configure.in'\n");
713 if (! $seen_decl_yytext)
715 &am_error ("lex source seen but \`AC_DECL_YYTEXT' not in \`configure.in'\n");
719 if ($yacc_count > 1 || $lex_count > 1)
721 # If there is more than one distinct yacc (resp lex) source
722 # file in a given directory, then the `interlock' program is
723 # required to allow parallel builds to work correctly. FIXME:
724 # for now, no line number.
725 &require_config_file ($FOREIGN, 'interlock', 'ylwrap');
726 &define_variable ('INTERLOCK', $config_aux_dir . "/interlock");
727 &define_variable ('YLWRAP', $config_aux_dir . "/ylwrap");
733 local (@cxx_list) = keys %cxx_extensions;
734 local ($cxx_count) = scalar @cxx_list;
737 push (@suffixes, @cxx_list);
739 &define_variable ("CXX", "\@CXX\@");
740 &define_variable ("CXXFLAGS", "\@CXXFLAGS\@");
741 &define_variable ('CXXCOMPILE', '$(CXX) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CXXFLAGS)');
742 &define_variable ('CXXLINK', '$(CXX) $(LDFLAGS) -o $@');
745 foreach $ext (@cxx_list)
747 $output_rules .= ("$ext.o:\n"
748 . "\t\$(CXXCOMPILE) -c \$<\n");
751 if (! $seen_prog_cxx)
753 &am_error ("C++ source seen but \`AC_PROG_CXX' not in \`configure.in'\n");
758 # Last, handle some C cleanup.
762 &define_variable ('CC', "\@CC\@");
763 &define_variable ('CFLAGS', "\@CFLAGS\@");
764 &define_variable ('COMPILE',
765 '$(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)');
766 &define_variable ('LINK', '$(CC) $(LDFLAGS) -o $@');
770 # Handle SOURCE->OBJECT transform for one program or library.
772 # canonical (transformed) name of object to build
773 # actual name of object to build
774 # object extension (ie either `.o' or `$o'.
775 # Return result is name of linker variable that must be used.
776 # Empty return means just use `LINK'.
777 sub handle_source_transform
779 # one_file is canonical name. unxformed is given name. obj is
781 local ($one_file, $unxformed, $obj) = @_;
782 local ($objpat) = $obj;
783 $objpat =~ s/(\W)/\\$1/g;
784 # Handle explicit `.o' as well as whatever we're passed.
785 $objpat = '(' . $objpat . "|\\.o)";
787 local ($linker) = '';
789 if (&variable_defined ($one_file . "_OBJECTS"))
791 &am_line_error ($one_file . '_OBJECTS',
792 $one_file . '_OBJECTS', 'should not be defined');
793 # No point in continuing.
799 foreach $prefix ('', 'EXTRA_')
802 if (&variable_defined ($prefix . $one_file . "_SOURCES"))
804 push (@sources, '$(' . $prefix . $one_file . "_SOURCES)");
805 push (@objects, '$(' . $prefix . $one_file . "_OBJECTS)")
806 unless $prefix eq 'EXTRA_';
807 @files = &variable_value_as_list ($prefix
808 . $one_file . "_SOURCES");
810 elsif ($prefix eq '')
812 &define_variable ($one_file . "_SOURCES", $unxformed . ".c");
813 push (@sources, $unxformed . '.c');
814 push (@objects, $unxformed . $obj);
815 push (@files, $unxformed . '.c');
819 &define_variable ("EXTRA_" . $one_file . "_SOURCES", '');
824 # Turn sources into objects.
825 local (@result) = ();
828 # If an automatically-discovered source file is
829 # mentioned, that is an error.
830 if (defined $libsources{$_})
832 # FIXME: saving $_ is stupid.
834 &am_line_error ($prefix . $one_file . '_SOURCES',
835 "automatically discovered file \`$_' should not be explicitly mentioned");
839 # Skip header files, including C++-ish ones. The list
840 # of C++ header extensions comes from Emacs 19.32
847 # Skip things that look like configure substitutions.
850 # Include .c file for lex or yacc source in distribution.
854 &push_dist_common ($1 . '.c');
855 $yacc_sources{$_} = 1;
860 &push_dist_common ($1 . '.c');
861 $lex_sources{$_} = 1;
864 # Transform source files into .o files. List of C++
865 # extensions comes from Emacs 19.32 etags.
872 $cxx_extensions{$&} = 1;
877 # FORTRAN support. FIXME: not finished.
881 # C, yacc, and lex need special $obj extension,
882 # for de-ansification. Hopefully someday this
886 # .f and .F is fortran. .s is assembly. .M is
887 # Objective-C++. .m is Objective-C.
890 # FIXME: of course, this should only happen for C
891 # source. The multi-language support must really
892 # be cleaned up more globally.
897 unless $prefix eq 'EXTRA_';
899 # Transform .o or $o file into .P file (for automatic
902 $dep_files{'.deps/' . $_} = 1;
905 &define_pretty_variable ($one_file . "_OBJECTS", @result)
906 unless $prefix eq 'EXTRA_';
910 if (&variable_defined ('CONFIG_HEADER'))
912 $output_rules .= ('$(' . $one_file . "_OBJECTS): "
913 . $contents{'CONFIG_HEADER'} . "\n");
919 # Special-case @ALLOCA@ and @LIBOBJS@ in _LDADD or _LIBADD variables.
920 # Also, generate _DEPENDENCIES variable if appropriate.
922 # transformed name of object being built, or empty string if no object
923 # name of _LDADD/_LIBADD-type variable to examine
924 # boolean (lex_seen) which is true if a lex source file was seen in this
925 # object. valid only for LDADDs, not LIBADDs. If set, LEXLIB
927 sub handle_lib_objects
929 local ($xname, $var, $lex_seen) = @_;
931 die "programming error 1 in handle_lib_objects"
932 if ! &variable_defined ($var);
934 die "programming error 2 in handle_lib_objects"
935 if $lex_seen && $var =~ /LIBADD/;
937 # We recognize certain things that are commonly put in LIBADD or
940 local (@dep_list) = ();
942 # If no lex source seen, just assume this is ok.
943 local ($lex_ok) = $lex_seen ? 0 : 1;
945 foreach $lsearch (&variable_value_as_list ($var))
947 # Skip -lfoo and -Ldir.
948 next if $lsearch =~ /^-[lL]/;
950 # Assume we have a file of some sort, and push it onto the
951 # dependency list. Autoconf substitutions are not pushed;
952 # rarely is a new dependency substituted into (eg) foo_LDADD
953 # -- but "bad things (eg -lX11) are routinely substituted.
954 push (@dep_list, $lsearch)
955 unless $lsearch =~ /^\@.*\@$/;
957 # Automatically handle @LIBOBJS@ and @ALLOCA@. Basically this
958 # means adding entries to dep_files.
959 if ($lsearch eq '@LIBOBJS@')
961 if (! keys %libsources)
963 &am_line_error ($var, "\@LIBOBJS\@ seen but never set in \`configure.in'");
966 local ($iter, $rewrite);
967 foreach $iter (keys %libsources)
971 &require_file_with_line ($var, $FOREIGN, $iter);
973 elsif ($iter ne 'alloca.c')
975 ($rewrite = $iter) =~ s/\.c$/.P/;
976 $dep_files{'.deps/' . $rewrite} = 1;
977 &require_file_with_line ($var, $FOREIGN, $iter);
981 elsif ($lsearch eq '@ALLOCA@')
983 &am_line_error ($var,
984 "\@ALLOCA\@ seen but \`AC_FUNC_ALLOCA' not in \`configure.in'")
985 if ! defined $libsources{'alloca.c'};
986 $dep_files{'.deps/alloca.P'} = 1;
987 &require_file_with_line ($var, $FOREIGN, 'alloca.c');
989 elsif ($lsearch eq '@LEXLIB@')
991 # FIXME: variable_value_as_list requires us to force
992 # @LEXLIB@ here, where we're really prefer $(LEXLIB).
993 # Nasty -- this will have to wait until many cleanups are
1002 &am_line_error ($var, 'lex source file used without @LEXLIB@');
1005 if ($xname ne '' && ! &variable_defined ($xname . '_DEPENDENCIES'))
1007 &define_pretty_variable ($xname . '_DEPENDENCIES', @dep_list);
1011 # Handle C programs.
1014 local (@proglist) = &am_install_var ('-clean',
1015 'progs', 'PROGRAMS',
1016 'bin', 'sbin', 'libexec', 'pkglib',
1018 return if ! @proglist;
1020 # If a program is installed, this is required. We only want this
1021 # error to appear once.
1022 &am_conf_error ("AC_ARG_PROGRAM must be used in configure.in")
1023 unless $seen_arg_prog;
1026 local ($obj) = &get_object_extension;
1027 local ($one_file, $xname, $munge);
1029 foreach $one_file (@proglist)
1031 # Canonicalize names.
1032 ($xname = $one_file) =~ tr/A-Za-z0-9_/_/c;
1033 if ($xname ne $one_file)
1036 foreach $xt ('_LDADD', '_SOURCES', '_OBJECTS', '_DEPENDENCIES')
1038 &am_line_error ($one_file . $xt,
1039 "invalid variable \`" . $one_file . $xt
1040 . "'; should be \`" . $xname . $xt . "'")
1041 if &variable_defined ($one_file . $xt);
1045 # FIXME: Using a trick to figure out if any lex sources appear
1046 # in our program; should use some cleaner method.
1047 local ($lex_num) = scalar (keys %lex_sources);
1048 local ($linker) = &handle_source_transform ($xname, $one_file, $obj);
1049 local ($lex_file_seen) = (scalar (keys %lex_sources) > $lex_num);
1051 if (&variable_defined ($xname . "_LDADD"))
1053 &handle_lib_objects ($xname, $xname . '_LDADD', $lex_file_seen);
1058 # User didn't define prog_LDADD override. So do it.
1059 &define_variable ($xname . '_LDADD', '$(LDADD)');
1061 # This does a bit too much work. But we need it to
1062 # generate _DEPENDENCIES when appropriate.
1063 if (&variable_defined ('LDADD'))
1065 &handle_lib_objects ($xname, 'LDADD', $lex_file_seen);
1072 &am_line_error ($one_file . $xt,
1073 'lex source file used without @LEXLIB@');
1076 # Determine program to use for link.
1078 if (&variable_defined ($xname . '_LINK'))
1080 $xlink = $xname . '_LINK';
1084 $xlink = $linker ? $linker : 'LINK';
1088 &file_contents_with_transform
1089 ('s/\@PROGRAM\@/' . $one_file . '/go;'
1090 . 's/\@XPROGRAM\@/' . $xname . '/go;'
1091 . 's/\@XLINK\@/' . $xlink . '/go;',
1095 &handle_lib_objects ('', 'LDADD', 0)
1096 if &variable_defined ('LDADD');
1100 sub handle_libraries
1102 local (@liblist) = &am_install_var ('-no-all', '-clean',
1103 'libs', 'LIBRARIES',
1104 'lib', 'pkglib', 'noinst', 'check');
1105 return if ! @liblist;
1107 local (%valid) = &am_primary_prefixes ('LIBRARIES', 'lib', 'pkglib',
1112 foreach $key (keys %valid)
1114 if (&variable_defined ($key . '_LIBRARIES'))
1116 &am_line_error ($key . '_LIBRARIES', "library requires either \`AC_PROG_RANLIB' or `AM_PROG_LIBTOOL' in configure.in");
1117 # Only get this error once.
1124 # Generate _LIBFILES variables. Too bad we can't do this in
1126 local ($onedir, $onelib);
1128 local (@libfiles_list);
1129 foreach $onedir (keys %valid)
1131 if (&variable_defined ($onedir . '_LIBRARIES'))
1134 foreach $onelib (&variable_value_as_list ($onedir . '_LIBRARIES'))
1136 push (@outlist, 'lib' . $onelib . '.a');
1138 &define_pretty_variable ($onedir . '_LIBFILES', @outlist);
1141 push (@libfiles_list, '$(' . $onedir . '_LIBFILES)')
1142 unless $onedir eq 'EXTRA';
1144 push (@all, '$(LIBFILES)');
1146 local ($obj) = &get_object_extension;
1149 foreach $onelib (@liblist)
1151 # Canonicalize names.
1152 ($xlib = $onelib) =~ tr/A-Za-z0-9_/_/c;
1153 if ($xlib ne $onelib)
1156 foreach $xt ('_LIBADD', '_SOURCES', '_OBJECTS', '_DEPENDENCIES')
1158 &am_line_error ($one_file . $xt,
1159 "invalid variable \`" . $onelib . $xt
1160 . "'; should be \`" . $xlib . $xt . "'")
1161 if &variable_defined ($onelib . $xt);
1165 if (&variable_defined ($xlib . '_LIBADD'))
1167 &handle_lib_objects ($xlib, $xlib . '_LIBADD', 0);
1171 # Generate support for conditional object inclusion in
1173 &define_variable ($xlib . "_LIBADD", '');
1176 &handle_source_transform ($xlib, $onelib, $obj);
1179 &file_contents_with_transform ('s/\@LIBRARY\@/' . $onelib . '/go;'
1185 # Turn "foo" into "libfoo.a" and include macro definition.
1186 grep (($_ = 'lib' . $_ . '.a') && 0, @liblist);
1188 if (! &variable_defined ('LIBFILES'))
1190 &define_pretty_variable ('LIBFILES ', @libfiles_list);
1195 &define_variable ('AR', '$(LIBTOOL) archive');
1196 &define_variable ('RANLIB', '$(LIBTOOL) ranlib');
1197 &define_variable ('LCOMPILE', ('$(LIBTOOL) compile $(DEFS) $(INCLUDES)'
1198 . ' $(CPPFLAGS) $(CFLAGS)'));
1202 &define_variable ('AR', 'ar');
1203 &define_variable ('RANLIB', '@RANLIB@');
1207 # See if any _SOURCES variable were misspelled.
1210 local ($varname, $primary);
1211 foreach $varname (keys %contents)
1213 foreach $primary ('_SOURCES', '_LIBADD', '_LDADD', '_DEPENDENCIES')
1215 if ($varname =~ /$primary$/ && ! $content_seen{$varname})
1217 &am_line_error ($varname,
1218 "invalid unused variable name: \`$varname'");
1227 # NOTE we no longer automatically clean SCRIPTS, because it is
1228 # useful to sometimes distribute scripts verbatim. This happens
1229 # eg in Automake itself.
1230 &am_install_var ('scripts', 'SCRIPTS',
1231 'bin', 'sbin', 'libexec', 'pkgdata',
1234 # Set $scripts_installed if appropriate. Make sure we only find
1235 # scripts which are actually installed -- this is why we can't
1236 # simply use the return value of am_install_var.
1237 local (%valid) = &am_primary_prefixes ('SCRIPTS', 'bin', 'sbin',
1238 'libexec', 'pkgdata',
1241 foreach $key (keys %valid)
1243 if ($key ne 'noinst'
1245 && &variable_defined ($key . '_SCRIPTS'))
1247 $scripts_installed = 1;
1248 # push (@check, 'check-' . $key . 'SCRIPTS');
1252 if ($scripts_installed)
1254 # If a program is installed, this is required. We only want this
1255 # error to appear once.
1256 &am_conf_error ("AC_ARG_PROGRAM must be used in configure.in")
1257 unless $seen_arg_prog;
1262 # Search a file for a "version.texi" Texinfo include. Return the name
1263 # of the include file if found, or the empty string if not. A
1264 # "version.texi" file is actually any file whose name matches
1266 sub grep_for_vers_texi
1268 local ($filename) = @_;
1270 if (! open (TEXI, $filename))
1272 &am_error ("couldn't open \`$filename': $!");
1275 print "automake: reading $filename\n" if $verbose;
1279 if (/^\@include\s+(vers[^.]*\.texi)\s*$/)
1291 # Handle all Texinfo source.
1294 &am_line_error ('TEXINFOS',
1295 "\`TEXINFOS' is an anachronism; use \`info_TEXINFOS'")
1296 if &variable_defined ('TEXINFOS');
1297 return if (! &variable_defined ('info_TEXINFOS')
1298 && ! &variable_defined ('html_TEXINFOS'));
1300 local (@texis) = &variable_value_as_list ('info_TEXINFOS');
1302 local (@infos_list, @info_deps_list, @dvis_list, @texi_deps);
1303 local ($infobase, $info_cursor);
1307 local ($tc_cursor, @texi_cleans);
1310 foreach $info_cursor (@texis)
1312 ($infobase = $info_cursor) =~ s/\.texi(nfo)?$//;
1314 # If 'version.texi' is referenced by input file, then include
1315 # automatic versioning capability.
1317 = &grep_for_vers_texi ($relative_dir . "/" . $info_cursor);
1320 &am_error ("\`$vtexi', included in \`$info_cursor', also included in \`$versions{$vtexi}'")
1321 if (defined $versions{$vtexi});
1322 $versions{$vtexi} = $info_cursor;
1324 # We number the stamp-vti files. This is doable since the
1325 # actual names don't matter much. We only number starting
1326 # with the second one, so that the common case looks nice.
1327 $vti = 'vti' . ($done ? $done : '');
1328 &push_dist_common ($vtexi, 'stamp-' . $vti);
1329 push (@clean, $vti);
1331 # Only require once.
1332 &require_conf_file_with_line ('info_TEXINFOS', $FOREIGN,
1338 ($conf_pat = $config_aux_dir) =~ s/(\W)/\\$1/g;
1340 &file_contents_with_transform
1341 ('s/\@TEXI\@/' . $info_cursor . '/g; '
1342 . 's/\@VTI\@/' . $vti . '/g; '
1343 . 's/\@VTEXI\@/' . $vtexi . '/g;'
1344 . 's,\@MDDIR\@,' . $conf_pat . ',g;',
1347 &push_phony_cleaners ($vti);
1350 # If user specified file_TEXINFOS, then use that as explicit
1353 push (@texi_deps, $info_cursor);
1354 push (@texi_deps, $vtexi) if $vtexi;
1356 # Canonicalize name first.
1357 ($canonical = $infobase) =~ tr/A-Za-z0-9_/_/c;
1358 if (&variable_defined ($canonical . "_TEXINFOS"))
1360 push (@texi_deps, '$(' . $canonical . '_TEXINFOS)');
1361 &push_dist_common ('$(' . $canonical . '_TEXINFOS)');
1364 $output_rules .= ("\n" . $infobase . ".info: "
1365 . join (' ', @texi_deps)
1366 . "\n" . $infobase . ".dvi: "
1367 . join (' ', @texi_deps)
1370 # FIXME: this distributes too much. How to find out precisely
1371 # which files will be generated by `makeinfo'?
1372 push (@infos_list, $infobase . '.info', $infobase . '.info[-0-9]*');
1373 push (@info_deps_list, $infobase . '.info');
1374 push (@dvis_list, $infobase . '.dvi');
1376 # Generate list of things to clean for this target. We do
1377 # this explicitly because otherwise too many things could be
1378 # removed. In particular the ".log" extension might
1379 # reasonably be used in other contexts by the user.
1380 foreach $tc_cursor ('aux', 'cp', 'cps', 'dvi', 'fn', 'fns',
1381 'ky', 'log', 'pg', 'toc', 'tp', 'vr', 'op')
1383 push (@texi_cleans, $infobase . '.' . $tc_cursor);
1388 $output_vars .= &file_contents ('texi-vars');
1389 $output_rules .= &file_contents ('texinfos');
1390 push (@phony, 'install-info', 'uninstall-info');
1393 $output_rules .= "\nmostlyclean-info:\n";
1394 &pretty_print_rule ("\trm -f", "\t ", @texi_cleans);
1395 $output_rules .= ("\nclean-info:\n\ndistclean-info:\n\n"
1396 . "maintainer-clean-info:\n\t"
1397 . 'rm -f $(INFOS)' . "\n");
1398 &push_phony_cleaners ('info');
1400 push (@suffixes, '.texi', '.texinfo', '.info', '.dvi');
1402 if (! defined $options{'no-installinfo'})
1404 push (@uninstall, 'uninstall-info');
1405 push (@installdirs, '$(infodir)');
1406 unshift (@install_data, 'install-info');
1408 # Make sure documentation is made and installed first. Use
1409 # $(INFO_DEPS), not 'info', because otherwise recursive makes
1410 # get run twice during "make all".
1411 unshift (@all, '$(INFO_DEPS)');
1413 push (@clean, 'info');
1414 push (@info, '$(INFO_DEPS)');
1415 push (@dvi, '$(DVIS)');
1417 &define_variable ("INFOS", join (' ', @infos_list));
1418 &define_variable ("INFO_DEPS", join (' ', @info_deps_list));
1419 &define_variable ("DVIS", join (' ', @dvis_list));
1420 # This next isn't strictly needed now -- the places that look here
1421 # could easily be changed to look in info_TEXINFOS. But this is
1422 # probably better, in case noinst_TEXINFOS is ever supported.
1423 &define_variable ("TEXINFOS", $contents{'info_TEXINFOS'});
1425 # Do some error checking.
1426 &require_file_with_line ('info_TEXINFOS', $FOREIGN, 'texinfo.tex');
1429 # Handle any man pages.
1430 sub handle_man_pages
1432 &am_line_error ('MANS', "\`MANS' is an anachronism; use \`man_MANS'")
1433 if &variable_defined ('MANS');
1434 return if ! &variable_defined ('man_MANS');
1436 # We generate the manpage install code by hand to avoid the use of
1437 # basename in the generated Makefile.
1438 local (@mans) = &variable_value_as_list ('man_MANS');
1439 local (%sections, %inames, %mbases, %secmap, %fullsecmap);
1443 # FIXME: statement without effect:
1444 /^(.*)\.([0-9])([a-z]*)$/;
1449 $fullsecmap{$i} = $2 . $3;
1453 # We don't really need this, but we use it in case we ever want to
1454 # support noinst_MANS.
1455 &define_variable ("MANS", $contents{'man_MANS'});
1457 # Generate list of install dirs.
1458 $output_rules .= "install-man: \$(MANS)\n";
1459 $output_rules .= "\t\$(NORMAL_INSTALL)\n";
1460 foreach (keys %sections)
1462 push (@installdirs, '$(mandir)/man' . $_)
1463 unless defined $options{'no-installman'};
1464 $output_rules .= ("\t" . '$(mkinstalldirs) $(mandir)/man'
1467 push (@phony, 'install-man');
1469 # Generate install target.
1471 foreach $key (keys %inames)
1473 $_ = $install_man_format;
1474 s/\@SECTION\@/$secmap{$key}/g;
1475 s/\@MAN\@/$inames{$key}/g;
1476 s/\@FULLSECT\@/$fullsecmap{$key}/g;
1477 s/\@MANBASE\@/$mbases{$key}/g;
1478 $output_rules .= $_;
1480 $output_rules .= "\n";
1482 $output_rules .= "uninstall-man:\n";
1483 foreach $key (keys %inames)
1485 $_ = $uninstall_man_format;
1486 s/\@SECTION\@/$secmap{$key}/g;
1487 s/\@MAN\@/$inames{$key}/g;
1488 s/\@FULLSECT\@/$fullsecmap{$key}/g;
1489 s/\@MANBASE\@/$mbases{$key}/g;
1490 $output_rules .= $_;
1492 $output_rules .= "\n";
1493 push (@phony, 'uninstall-man');
1495 $output_vars .= &file_contents ('mans-vars');
1497 if (! defined $options{'no-installman'})
1499 push (@install_data, 'install-man');
1500 push (@uninstall, 'uninstall-man');
1501 push (@all, '$(MANS)');
1505 # Handle DATA variables.
1508 &am_install_var ('data', 'DATA', 'data', 'sysconf',
1509 'sharedstate', 'localstate', 'pkgdata',
1516 local ($tagging) = 0;
1518 push (@phony, 'tags');
1519 if (&variable_defined ('SUBDIRS'))
1521 $output_rules .= &file_contents ('tags');
1522 push (@phony, 'tags-recursive');
1525 elsif ($dir_holds_sources
1526 || $dir_holds_headers
1527 || &variable_defined ('ETAGS_ARGS'))
1529 $output_rules .= &file_contents ('tags-subd');
1532 elsif (&variable_defined ('TAGS_DEPENDENCIES'))
1534 &am_line_error ('TAGS_DEPENDENCIES',
1535 "doesn't make sense to define \`TAGS_DEPENDENCIES' without sources or \`ETAGS_ARGS'");
1540 $output_rules .= &file_contents ('tags-clean');
1541 push (@clean, 'tags');
1542 &push_phony_cleaners ('tags');
1543 &examine_variable ('TAGS_DEPENDENCIES');
1547 # Every Makefile must define some sort of TAGS rule.
1548 # Otherwise, it would be possible for a top-level "make TAGS"
1549 # to fail because some subdirectory failed.
1550 $output_rules .= "tags: TAGS\nTAGS:\n\n";
1554 # Worker for handle_dist.
1555 sub handle_dist_worker
1557 $output_rules .= 'distdir: $(DEP_DISTFILES)' . "\n";
1559 # Initialization; only at top level.
1560 if ($relative_dir eq '.')
1562 if ($strictness >= $GNITS)
1564 # For Gnits users, this is pretty handy. Look at 15 lines
1565 # in case some explanatory text is desirable.
1566 $output_rules .= ' @if sed 15q $(srcdir)/NEWS | fgrep -e "$(VERSION)" > /dev/null; then :; else \\
1567 echo "NEWS not updated; not releasing" 1>&2; \\
1575 # Create dist directory.
1578 -chmod 755 $(distdir)
1581 # Only run automake in `dist' target if --include-deps not
1582 # specified. That way the recipient of a distribution can run
1583 # "make dist" and not need Automake.
1584 if ($cmdline_use_dependencies)
1588 # We need an absolute path for --output-dir. Thus the
1590 ' here=`pwd`; distdir=`cd $(distdir) && pwd` \\
1592 && automake --include-deps --build-dir=$$here --srcdir-name=$(srcdir) --output-dir=$$distdir --strictness='
1593 # Set strictness of output.
1594 . $strictness_name . "\n"
1599 # Scan EXTRA_DIST to see if we need to distribute anything from a
1600 # subdir. If so, add it to the list. I didn't want to do this
1601 # originally, but there were so many requests that I finally
1604 if (&variable_defined ('EXTRA_DIST'))
1606 foreach (&variable_value_as_list ('EXTRA_DIST'))
1609 next unless s,/+[^/]+$,,;
1610 push (@dist_dirs, $_)
1614 if (&variable_defined ('EXTRA_DIST_DIRS'))
1616 push (@dist_dirs, &variable_value_as_list ('EXTRA_DIST_DIRS'));
1620 # Prepend $(distdir) to each directory given. Doing it via a
1621 # hash lets us ensure that each directory is used only once.
1623 grep ($dhash{'$(distdir)/' . $_} = 1, @dist_dirs);
1624 $output_rules .= "\t";
1625 &pretty_print_rule ('$(mkinstalldirs)', "\t ", sort keys %dhash);
1628 # In loop, test for file existence because sometimes a file gets
1629 # included in DISTFILES twice. For example this happens when a
1630 # single source file is used in building more than one program.
1631 # Also, there are situations in which "ln" can fail. For instance
1632 # a file to distribute could actually be a cross-filesystem
1633 # symlink -- this can easily happen if "gettextize" was run on the
1634 # distribution. Note that DISTFILES can contain a wildcard (for
1635 # info files, sigh), so we must use the echo trick.
1636 $output_rules .= ' @for file in `cd $(srcdir) && echo $(DISTFILES)`; do \\
1637 test -f $(distdir)/$$file \\
1638 || ln $(srcdir)/$$file $(distdir)/$$file 2> /dev/null \\
1639 || cp -p $(srcdir)/$$file $(distdir)/$$file; \\
1643 # If we have SUBDIRS, create all dist subdirectories and do
1645 if (&variable_defined ('SUBDIRS'))
1647 # Test for directory existence here because previous automake
1648 # invocation might have created some directories. Note that
1649 # we explicitly set distdir for the subdir make; that lets us
1650 # mix-n-match many automake-using packages into one large
1651 # package, and have "dist" at the top level do the right
1653 $output_rules .= ' for subdir in $(SUBDIRS); do \\
1654 test -d $(distdir)/$$subdir \\
1655 || mkdir $(distdir)/$$subdir \\
1657 chmod 755 $(distdir)/$$subdir; \\
1658 (cd $$subdir && $(MAKE) distdir=../$(distdir)/$$subdir distdir) \\
1664 # If the target `dist-hook' exists, run it now. This allows
1665 # users to do random weird things to the distribution before it is
1667 if (defined $contents{'dist-hook'})
1669 # We must explicitly set distdir here.
1670 $output_rules .= "\t\$(MAKE) distdir=\"$(distdir)\" dist-hook\n";
1673 push (@phony, 'distdir');
1676 # Handle 'dist' target.
1679 # Set up maint_charset.
1680 $local_maint_charset = $contents{'MAINT_CHARSET'}
1681 if &variable_defined ('MAINT_CHARSET');
1682 $maint_charset = $local_maint_charset
1683 if $relative_dir eq '.';
1685 if (&variable_defined ('DIST_CHARSET'))
1687 &am_line_error ('DIST_CHARSET',
1688 "DIST_CHARSET defined but no MAINT_CHARSET defined")
1689 if ! $local_maint_charset;
1690 if ($relative_dir eq '.')
1692 $dist_charset = $contents{'DIST_CHARSET'}
1696 &am_line_error ('DIST_CHARSET',
1697 "DIST_CHARSET can only be defined at top level");
1701 # Look for common files that should be included in distribution.
1703 foreach $cfile (@common_files)
1705 if (-f ($relative_dir . "/" . $cfile))
1707 &push_dist_common ($cfile);
1711 # Keys of %dist_common are names of files to distributed. We put
1712 # README first because it then becomes easier to make a
1713 # Usenet-compliant shar file (in these, README must be first).
1714 # FIXME: do more ordering of files here.
1716 if (defined $dist_common{'README'})
1718 push (@coms, 'README');
1719 undef $dist_common{'README'};
1721 push (@coms, sort keys %dist_common);
1723 &define_pretty_variable ("DIST_COMMON", @coms);
1724 $output_vars .= "\n";
1727 $output_vars .= &file_contents ('dist-vars');
1729 # Put these things in rules section so it is easier for whoever
1730 # reads Makefile.in.
1731 if (! &variable_defined ('distdir'))
1733 if ($relative_dir eq '.')
1735 $output_rules .= "\n" . 'distdir = $(PACKAGE)-$(VERSION)' . "\n";
1739 $output_rules .= ("\n"
1740 . 'distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)'
1744 if ($relative_dir ne '.')
1746 $output_rules .= "\nsubdir = " . $relative_dir . "\n";
1749 # Generate 'dist' target, and maybe dist-shar / dist-zip / dist-tarZ.
1750 if ($relative_dir eq '.')
1752 # Rule to check whether a distribution is viable.
1753 $output_rules .= ('# This target untars the dist file and tries a VPATH configuration. Then
1754 # it guarantees that the distribution is self-contained by making another
1758 $(TAR) zxf $(distdir).tar.gz
1759 mkdir $(distdir)/=build
1760 mkdir $(distdir)/=inst
1761 dc_install_base=`cd $(distdir)/=inst && pwd`; \\'
1762 . (defined $contents{'distcheck-hook'}
1763 ? "\t\$(MAKE) distcheck-hook"
1766 cd $(distdir)/=build \\
1769 . ($seen_gettext ? '--with-included-gettext ' : '')
1770 . '--srcdir=.. --prefix=$$dc_install_base \\
1774 && $(MAKE) install \\
1775 && $(MAKE) installcheck \\
1778 @echo "========================"; \\
1779 echo "$(distdir).tar.gz is ready for distribution"; \\
1780 echo "========================"
1783 local ($dist_all) = ('dist-all: distdir' . "\n"
1786 foreach $curs ('dist', 'dist-shar', 'dist-zip', 'dist-tarZ')
1788 if (defined $options{$curs} || $curs eq 'dist')
1790 $output_rules .= ($curs . ': distdir' . "\n"
1794 $dist_all .= $dist{$curs};
1797 $output_rules .= $dist_all . $dist_trailer;
1800 # Generate distdir target.
1801 &handle_dist_worker;
1804 # Scan a single dependency file and rewrite the dependencies as
1805 # appropriate. Essentially this means:
1806 # * Clean out absolute dependencies which are not desirable.
1807 # * Rewrite other dependencies to be relative to $(top_srcdir).
1808 sub scan_dependency_file
1810 local ($depfile) = @_;
1812 if (! open (DEP_FILE, $depfile))
1814 &am_error ("couldn't open \`$depfile': $!");
1817 print "automake: reading $depfile\n" if $verbose;
1819 local ($first_line) = 1;
1820 local ($last_line) = 0;
1821 local ($target, @dependencies);
1822 local ($one_dep, $xform);
1824 local ($srcdir_rx, $fixup_rx);
1825 # If the top srcdir is absolute, then the current directory is
1826 # just relative_dir. But if the top srcdir is relative, then we
1827 # need to add some dots first. The same holds when matching
1829 if ($srcdir_name =~ /^\//)
1831 ($fixup_rx = $srcdir_name . '/' . $relative_dir . '/')
1833 ($srcdir_rx = $srcdir_name) =~ s/(\W)/\\$1/g;
1837 ($fixup_rx = ($srcdir_name . '/' . $top_builddir . '/'
1838 . $relative_dir . '/')) =~ s/(\W)/\\$1/g;
1839 ($srcdir_rx = ($srcdir_name . '/' . $top_builddir))
1847 # If LAST_LINE set then we've already seen what we thought
1848 # was the last line.
1851 next if (/$WHITE_PATTERN/o);
1855 # No trailing "\" means this should be the last line.
1861 if (! /^([^:]+:)(.+)$/)
1864 &am_error ("\`$depfile' has incorrect format");
1875 foreach $one_dep (split (' ', $_))
1877 if ($one_dep =~ /^$fixup_rx/)
1879 # The dependency points to the current directory in
1881 ($xform = $one_dep) =~ s/^$fixup_rx//;
1882 push (@dependencies, $xform);
1884 elsif ($one_dep =~ /^$srcdir_rx\//)
1886 # The dependency is in some other directory in the package.
1887 ($xform = $one_dep) =~ s/^$srcdir_rx/$top_builddir/;
1888 push (@dependencies, $xform);
1890 elsif ($one_dep =~ /^\//)
1892 # Absolute path; ignore.
1896 # Anything else is assumed to be correct.
1897 push (@dependencies, $one_dep);
1902 &pretty_print_rule ($target, "\t", @dependencies);
1907 # Handle auto-dependency code.
1908 sub handle_dependencies
1910 if ($use_dependencies)
1912 # Include GNU-make-specific auto-dep code.
1913 if ($dir_holds_sources)
1915 &define_pretty_variable ('DEP_FILES', sort keys %dep_files);
1916 $output_rules .= &file_contents ('depend');
1917 push (@clean, 'depend');
1918 &push_phony_cleaners ('depend');
1920 &file_contents_with_transform ('s/\@EXT\@/.c/g;'
1921 . 's/\@MKDEP\@/MKDEP/g',
1924 local ($need_cxx) = 0;
1925 foreach $ext (keys %cxx_extensions)
1928 &file_contents_with_transform ('s/\@EXT\@/' . $ext .'/g;'
1929 . 's/\@MKDEP\@/CXXMKDEP/g',
1935 &define_variable ('CXXMKDEP', '$(CXX) -MM $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CXXFLAGS)');
1941 # FIXME: consider requiring --build-dir here. What about case
1942 # where this is done via an option?
1944 # Include any auto-generated deps that are present. Note that
1945 # $build_directory ends in a "/".
1946 if (-d ($build_directory . $relative_dir . "/.deps")
1947 && -f ($build_directory . $relative_dir . "/.deps/.P"))
1950 local ($gpat) = $build_directory . $relative_dir . "/.deps/*.P";
1952 foreach $depfile (<${gpat}>)
1954 &scan_dependency_file ($depfile);
1957 $output_rules .= "\n";
1962 # Handle subdirectories.
1965 return if ! &variable_defined ('SUBDIRS');
1967 # Make sure each directory mentioned in SUBDIRS actually exists.
1969 foreach $dir (&variable_value_as_list ('SUBDIRS'))
1971 # Skip directories substituted by configure.
1972 next if $dir =~ /^\@.*\@$/;
1973 &am_line_error ('SUBDIRS',
1974 "required directory $relative_dir/$dir does not exist")
1975 if ! -d $relative_dir . '/' . $dir;
1978 $output_rules .= &file_contents ('subdirs');
1980 # Push a bunch of phony targets.
1982 foreach $phonies ('-data', '-exec', 'dirs')
1984 push (@phony, 'install' . $phonies . '-recursive');
1985 push (@phony, 'uninstall' . $phonies . '-recursive');
1987 foreach $phonies ('all', 'check', 'installcheck', 'info', 'dvi')
1989 push (@phony, $phonies . '-recursive');
1991 &push_phony_cleaners ('recursive');
1993 push (@check, "check-recursive");
1994 push (@installcheck, "installcheck-recursive");
1995 push (@info, "info-recursive");
1996 push (@dvi, "dvi-recursive");
1998 $recursive_install = 1;
2001 # Handle aclocal.m4.
2002 sub handle_aclocal_m4
2004 local ($regen_aclocal) = 0;
2005 if (-f 'aclocal.m4')
2007 &define_variable ("ACLOCAL", "aclocal.m4");
2008 &push_dist_common ('aclocal.m4');
2010 if (open (ACLOCAL, '< aclocal.m4'))
2016 if ($line =~ 'generated automatically by aclocal')
2023 local ($acinclude) = 0;
2024 if (-f 'acinclude.m4')
2030 # Note that it might be possible that aclocal.m4 doesn't exist but
2031 # should be auto-generated. This case probably isn't very
2035 $output_rules .= ("aclocal.m4: "
2036 . ($seen_maint_mode ? "\@MAINT\@" : "")
2038 . ($acinclude ? ' acinclude.m4' : '')
2040 . 'cd $(srcdir) && aclocal'
2045 # Handle remaking and configure stuff.
2046 sub handle_configure
2048 # If SUBDIRS defined, require AC_PROG_MAKE_SET.
2049 &am_line_error ('SUBDIRS', "AC_PROG_MAKE_SET must be used in configure.in")
2050 if &variable_defined ('SUBDIRS') && ! $seen_make_set;
2052 local ($top_reldir);
2053 if ($relative_dir ne '.')
2056 $output_rules .= &file_contents ('remake-subd');
2057 $top_reldir = '../';
2062 $output_rules .= &file_contents_with_transform ('s/\@STRICTNESS\@/'
2066 &examine_variable ('CONFIGURE_DEPENDENCIES');
2070 # If we have a configure header, require it.
2071 if ($config_header && $relative_dir eq &dirname ($config_header))
2073 local ($ch_sans_dir) = &basename ($config_header);
2074 local ($cn_sans_dir) = &basename ($config_name);
2076 &require_file_with_conf_line ($config_header_line,
2077 $FOREIGN, $ch_sans_dir);
2079 # Header defined and in this directory.
2080 if (-f $relative_dir . '/acconfig.h')
2082 &define_variable ("ACCONFIG", "acconfig.h");
2083 &push_dist_common ('acconfig.h');
2085 if (-f $config_name . '.top')
2087 &define_variable ("CONFIG_TOP", "${cn_sans_dir}.top");
2088 &push_dist_common ($cn_sans_dir . '.top');
2090 if (-f $config_name . '.bot')
2092 &define_variable ("CONFIG_BOT", "${cn_sans_dir}.bot");
2093 &push_dist_common ($cn_sans_dir . '.bot');
2096 &touch ($relative_dir . '/stamp-h.in');
2097 &require_file_with_conf_line ($config_header_line, $FOREIGN,
2100 $output_rules .= &file_contents ('remake-hdr');
2101 push (@clean, 'hdr');
2102 &push_phony_cleaners ('hdr');
2103 &define_variable ("CONFIG_HEADER_IN", "${ch_sans_dir}");
2106 # Set location of mkinstalldirs.
2107 if ($config_aux_dir ne '.' && $config_aux_dir ne '')
2109 &define_variable ('mkinstalldirs', ('$(SHELL) ' . $config_aux_dir
2110 . '/mkinstalldirs'));
2114 &define_variable ('mkinstalldirs',
2115 '$(SHELL) $(top_srcdir)/mkinstalldirs');
2118 &am_line_error ('CONFIG_HEADER',
2119 "\`CONFIG_HEADER' is an anachronism; now determined from \`configure.in'")
2120 if &variable_defined ('CONFIG_HEADER');
2124 # Generate CONFIG_HEADER define.
2125 if ($relative_dir eq &dirname ($config_name))
2127 &define_variable ("CONFIG_HEADER", &basename ($config_name));
2131 &define_variable ("CONFIG_HEADER",
2132 "${top_builddir}/${config_name}");
2136 # Now look for other files in this directory which must be remade
2137 # by config.status, and generate rules for them.
2138 local (@actual_other_files) = ();
2139 local ($file, $local, $input);
2140 foreach $file (@other_input_files)
2142 # Skip files not in this directory, any Makefile, and the
2143 # config header. These last two must be handled specially.
2144 next unless &dirname ($file) eq $relative_dir;
2145 next if $file eq $top_builddir . '/' . $config_name;
2146 ($local = $file) =~ s/^.*\///;
2147 next if $local eq 'Makefile';
2149 if ($local =~ /^(.*):(.*)$/)
2151 # This is the ":" syntax of AC_OUTPUT.
2158 $input = $local . '.in';
2160 # FIXME: when using autoconf ":" syntax, should we set CONFIG_FILES
2162 $output_rules .= ($local . ': '
2163 . '$(top_builddir)/config.status ' . $input . "\n"
2165 . 'cd $(top_builddir) && CONFIG_FILES='
2166 . ($relative_dir eq '.' ? '' : '$(subdir)/')
2167 . '$@ CONFIG_HEADERS= ./config.status'
2169 push (@actual_other_files, $local);
2171 &require_file_with_conf_line ($ac_output_line, $FOREIGN,
2175 # These files get removed by "make clean".
2176 &define_pretty_variable ('CONFIG_CLEAN_FILES', @actual_other_files);
2182 $dir_holds_headers = &am_install_var ('header', 'HEADERS', 'include',
2183 'oldinclude', 'pkginclude',
2189 return if ! $seen_gettext || $relative_dir ne '.';
2191 if (! &variable_defined ('SUBDIRS'))
2194 ("ud_GNU_GETTEXT in configure.in but SUBDIRS not defined");
2198 &require_file_with_conf_line ($ac_gettext_line, $FOREIGN, 'ABOUT-NLS')
2201 if (&variable_defined ('SUBDIRS'))
2205 "ud_GNU_GETTEXT in configure.in but \`po' not in SUBDIRS")
2206 if $contents{'SUBDIRS'} !~ /\bpo\b/;
2209 "ud_GNU_GETTEXT in configure.in but \`intl' not in SUBDIRS")
2210 if $contents{'SUBDIRS'} !~ /\bintl\b/;
2213 # Ensure that each language in ALL_LINGUAS has a .po file, and
2214 # each po file is mentioned in ALL_LINGUAS.
2217 local (%linguas) = ();
2218 grep ($linguas{$_} = 1, split (' ', $all_linguas));
2225 &am_line_error ($all_linguas_line,
2226 ("po/$_.po exists but \`$_' not in \`ALL_LINGUAS'"))
2230 foreach (keys %linguas)
2232 &am_line_error ($all_linguas_line,
2233 "$_ in \`ALL_LINGUAS' but po/$_.po does not exist")
2239 &am_error ("ud_GNU_GETTEXT in configure.in but \`ALL_LINGUAS' not defined");
2243 # Handle footer elements.
2246 if ($contents{'SOURCES'})
2248 # NOTE don't use define_pretty_variable here, because
2249 # $contents{...} is already defined.
2250 $output_vars .= 'SOURCES = ' . $contents{'SOURCES'} . "\n";
2252 if ($contents{'OBJECTS'})
2254 # NOTE don't use define_pretty_variable here, because
2255 # $contents{...} is already defined.
2256 $output_vars .= 'OBJECTS = ' . $contents{'OBJECTS'} . "\n";
2258 if ($contents{'SOURCES'} || $contents{'OBJECTS'})
2260 $output_vars .= "\n";
2263 if (defined $contents{'SUFFIXES'})
2265 # Push actual suffixes, and not $(SUFFIXES). Some versions of
2266 # make do not like variable substitutions on the .SUFFIXES
2268 push (@suffixes, split (' ', $contents{'SUFFIXES'}));
2271 $output_trailer .= ".SUFFIXES:\n";
2274 $output_trailer .= ".SUFFIXES: " . join (' ', @suffixes) . "\n";
2276 $output_trailer .= &file_contents ('footer');
2279 # Deal with installdirs target.
2280 sub handle_installdirs
2282 # GNU Makefile standards recommend this.
2283 $output_rules .= ("installdirs:"
2284 . ($recursive_install
2285 ? " installdirs-recursive\n"
2287 push (@phony, 'installdirs');
2290 &pretty_print_rule ("\t" . '$(mkinstalldirs) ', "\t\t",
2293 $output_rules .= "\n";
2296 # There are several targets which need to be merged. This is because
2297 # their complete definition is compiled from many parts. Note that we
2298 # avoid double colon rules, otherwise we'd use them instead.
2299 sub handle_merge_targets
2301 # There are a few install-related variables that you should not define.
2303 foreach $var ('PRE_INSTALL', 'POST_INSTALL', 'NORMAL_INSTALL')
2305 if (&variable_defined ($var))
2307 &am_line_error ($var, "\`$var' should not be defined");
2311 push (@all, 'Makefile');
2312 push (@all, $config_name)
2313 if $config_name && &dirname ($config_name) eq $relative_dir;
2315 &do_one_merge_target ('info', @info);
2316 &do_one_merge_target ('dvi', @dvi);
2317 &do_one_merge_target ('check', @check);
2318 &do_one_merge_target ('installcheck', @installcheck);
2320 # Handle the various install targets specially. We do this so
2321 # that (eg) "make install-exec" will run "install-exec-recursive"
2322 # if required, but "make install" won't run it twice. Step one is
2323 # to see if the user specified local versions of any of the
2324 # targets we handle. "all" is treated as one of these since
2325 # "install" can run it.
2326 push (@install_exec, 'install-exec-local')
2327 if defined $contents{'install-exec-local'};
2328 push (@install_data, 'install-data-local')
2329 if defined $contents{'install-data-local'};
2330 push (@uninstall, 'uninstall-local')
2331 if defined $contents{'uninstall-local'};
2333 foreach $utarg ('uninstall-data-local', 'uninstall-data-hook',
2334 'uninstall-exec-local', 'uninstall-exec-hook')
2336 if (defined $contents{$utarg})
2339 ($x = $utarg) =~ s/(data|exec)-//;
2340 &am_line_error ($utarg, "use \`$x', not \`$utarg'");
2343 push (@all, 'all-local')
2344 if defined $contents{'all-local'};
2346 if (defined $contents{'install-local'})
2348 &am_line_error ('install-local',
2349 "use \`install-data' or \`install-exec', not \`install'");
2352 # Step two: if we are doing recursive makes, write out the
2353 # appropriate rules.
2355 if ($recursive_install)
2357 push (@install, 'install-recursive');
2361 local (@hackall) = ();
2362 if ($config_name && &dirname ($config_name) eq $relative_dir)
2365 # This is kind of a hack, but I couldn't see a better
2366 # way to handle it. In this particular case, we need
2367 # to make sure config.h is built before we recurse.
2368 # We can't do this by changing the order of
2369 # dependencies to the "all" because that breaks when
2370 # using parallel makes. Instead we handle things
2372 $output_rules .= ('all-recursive-hack: $(CONFIG_HEADER)'
2373 . "\n\t" . '$(MAKE) all-recursive'
2375 push (@hackall, 'all-recursive-hack');
2376 push (@phony, 'all-recursive-hack');
2380 push (@hackall, 'all-recursive');
2383 $output_rules .= ('all-am: '
2387 push (@all, 'all-am');
2388 push (@phony, 'all-am');
2392 @all = ('all-recursive');
2394 # Must always generate `all-am' target, so it can be
2395 # referred to elsewhere.
2396 $output_rules .= "all-am:\n";
2400 $output_rules .= ('install-exec-am: '
2401 . join (' ', @install_exec)
2403 @install_exec = ('install-exec-recursive', 'install-exec-am');
2404 push (@install, 'install-exec-am');
2405 push (@phony, 'install-exec-am');
2409 @install_exec = ('install-exec-recursive');
2413 $output_rules .= ('install-data-am: '
2414 . join (' ', @install_data)
2416 @install_data = ('install-data-recursive', 'install-data-am');
2417 push (@install, 'install-data-am');
2418 push (@phony, 'install-data-am');
2422 @install_data = ('install-data-recursive');
2426 $output_rules .= ('uninstall-am: '
2427 . join (' ', @uninstall)
2429 @uninstall = ('uninstall-recursive', 'uninstall-am');
2430 push (@phony, 'uninstall-am');
2434 @uninstall = ('uninstall-recursive');
2438 # Step three: print definitions users can use. Code below knows
2439 # that install-exec is done before install-data, beware.
2440 $output_rules .= ("install-exec: "
2441 . join (' ', @install_exec)
2443 $output_rules .= "\t\$(NORMAL_INSTALL)\n";
2444 if (defined $contents{'install-exec-hook'})
2446 $output_rules .= "\t" . '$(MAKE) install-exec-hook' . "\n";
2448 $output_rules .= "\n";
2449 push (@install, 'install-exec') if !$recursive_install;
2450 push (@phony, 'install-exec');
2452 $output_rules .= ("install-data: "
2453 . join (' ', @install_data)
2455 $output_rules .= "\t\$(NORMAL_INSTALL)\n";
2456 if (defined $contents{'install-data-hook'})
2458 $output_rules .= "\t" . '$(MAKE) install-data-hook' . "\n";
2460 $output_rules .= "\n";
2461 push (@install, 'install-data') if !$recursive_install;
2462 push (@phony, 'install-data');
2464 # If no dependencies for 'install', add 'all'. Why? That way
2465 # "make install" at top level of distclean'd distribution won't
2466 # fail because stuff in 'lib' fails to build.
2467 if (! @install || (scalar (@install) == 2
2468 && $install[0] eq 'install-exec'
2469 && $install[1] eq 'install-data'))
2471 push (@install, 'all');
2473 $output_rules .= ('install: '
2474 . join (' ', @install)
2475 # Use "@:" as empty command so nothing prints.
2479 . join (' ', @uninstall)
2481 push (@phony, 'install', 'uninstall');
2483 $output_rules .= ('all: '
2486 push (@phony, 'all');
2488 # Generate the new 'install-strip' target.
2489 $output_rules .= ("install-strip:\n\t"
2490 . '$(MAKE) INSTALL_PROGRAM=\'$(INSTALL_PROGRAM) -s\' install'
2494 # Helper for handle_merge_targets.
2495 sub do_one_merge_target
2497 local ($name, @values) = @_;
2499 if (defined $contents{$name . '-local'})
2501 # User defined local form of target. So include it.
2502 push (@values, $name . '-local');
2503 push (@phony, $name . '-local');
2507 if ($name eq 'check')
2509 if (! &variable_defined ('SUBDIRS'))
2511 # 'check' must depend on `all', but not when doing
2513 unshift (@values, 'all');
2517 # When subdirs are used, do the `all' build and then do
2518 # all the recursive stuff. Actually use `all-am' because
2519 # it doesn't recurse; we rely on the check target in the
2520 # subdirs to do the required builds there.
2521 $output_rules .= "check: all-am\n";
2522 &pretty_print_rule ("\t\$(MAKE)", "\t ", @values);
2527 &pretty_print_rule ($name . ":", "\t\t", @values)
2529 push (@phony, $name);
2532 # Handle all 'clean' targets.
2535 push (@clean, 'generic');
2536 $output_rules .= &file_contents ('clean');
2537 &push_phony_cleaners ('generic');
2539 local ($target) = $recursive_install ? 'clean-am' : 'clean';
2540 &do_one_clean_target ($target, 'mostly', '', @clean);
2541 &do_one_clean_target ($target, '', 'mostly', @clean);
2542 &do_one_clean_target ($target, 'dist', '', @clean);
2543 &do_one_clean_target ($target, 'maintainer-', 'dist', @clean);
2545 push (@phony, 'clean', 'mostlyclean', 'distclean', 'maintainer-clean');
2548 if ($recursive_install)
2550 @deps = ('am', 'recursive');
2551 &do_one_clean_target ('', 'mostly', '', @deps);
2552 &do_one_clean_target ('', '', '', @deps);
2553 &do_one_clean_target ('', 'dist', '', @deps);
2554 &do_one_clean_target ('', 'maintainer-', '', @deps);
2558 # Helper for handle_clean.
2559 sub do_one_clean_target
2561 local ($target, $name, $last_name, @deps) = @_;
2563 # Special case: if target not passed, then don't generate
2564 # dependency on next "lower" clean target (eg no
2565 # clean<-mostlyclean derivation). In this case the target is
2566 # implicitly known to be 'clean'.
2567 local ($flag) = $target;
2568 $target = 'clean' if ! $flag;
2570 grep (($_ = $name . 'clean-' . $_) && 0, @deps);
2573 if ($last_name || $name ne 'mostly')
2575 push (@deps, $last_name . $target . " ");
2578 # FIXME: not sure if I like the tabs here.
2579 &pretty_print_rule ($name . $target . ": ", "\t\t", @deps);
2581 # FIXME: shouldn't we really print these messages before running
2583 if ($name . $target eq 'maintainer-clean')
2585 # Print a special warning.
2587 ("\t\@echo \"This command is intended for maintainers to use;\"\n"
2588 . "\t\@echo \"it deletes files that may require special "
2589 . "tools to rebuild.\"\n");
2591 $output_rules .= "\trm -f config.status\n"
2592 if $relative_dir eq '.';
2594 elsif ($name . $target eq 'distclean')
2596 $output_rules .= "\trm -f config.status\n";
2598 $output_rules .= "\n";
2601 # Handle .PHONY target.
2604 &pretty_print_rule ('.PHONY:', "", @phony);
2605 $output_rules .= "\n";
2608 # Handle TESTS variable and other checks.
2611 if (defined $options{'dejagnu'})
2613 push (@check, 'check-DEJAGNU');
2614 push (@phony, 'check-DEJAGNU');
2615 $output_rules .= &file_contents ('dejagnu') . "\n";
2616 # Note that in the rule we don't directly generate site.exp to
2617 # avoid the possibility of a corrupted site.exp if make is
2618 # interrupted. Jim Meyering has some useful text on this
2620 $output_rules .= ("site.exp: Makefile\n"
2621 . "\t\@echo 'Making a new site.exp file...'\n"
2622 . "\t-\@rm -f site.bak\n"
2623 . "\t\@echo '## these variables are automatically generated by make ##' > \$\@-t\n"
2624 . "\t\@echo '# Do not edit here. If you wish to override these values' >> \$\@-t\n"
2625 . "\t\@echo '# edit the last section' >> \$\@-t\n"
2626 . "\t\@echo 'set tool \$(DEJATOOL)' >> \$\@-t\n"
2627 . "\t\@echo 'set srcdir \$(srcdir)' >> \$\@-t\n"
2628 . "\t\@echo 'set objdir' \`pwd\` >> \$\@-t\n");
2630 # Extra stuff for AC_CANONICAL_*
2631 local (@whatlist) = ();
2632 if ($seen_canonical)
2634 push (@whatlist, 'host')
2637 # Extra stuff only for AC_CANONICAL_SYSTEM.
2638 if ($seen_canonical == $AC_CANONICAL_SYSTEM)
2640 push (@whatlist, 'target', 'build');
2644 foreach $c1 (@whatlist)
2646 foreach $c2 ('alias', 'triplet')
2648 $output_rules .= "\t\@echo 'set ${c1}_${c2} \$(${c1}_${c2})' >> \$\@-t\n";
2652 $output_rules .= ("\t\@echo '## All variables above are generated by configure. Do Not Edit ##' >> \$\@-t\n"
2653 . "\t-\@sed '1,/^## All variables above are.*##/ d' site.bak >> \$\@-t\n"
2654 . "\t-\@mv site.exp site.bak\n"
2655 . "\t\@mv \$\@-t site.exp\n");
2660 foreach $c ('DEJATOOL', 'RUNTEST', 'RUNTESTFLAGS')
2662 if (&variable_defined ($c))
2664 &am_line_error ($c, "\`$c' defined but \`dejagnu' not in \`AUTOMAKE_OPTIONS'");
2669 if (&variable_defined ('TESTS'))
2671 push (@check, 'check-TESTS');
2672 push (@phony, 'check-TESTS');
2673 # FIXME: use $(SHELL) here? That is what Ulrich suggests.
2674 # Maybe a new macro, $(TEST_SHELL), a la $(CONFIG_SHELL)? For
2675 # now we just execute the file directly; this allows test
2676 # files which are compiled -- a possibly useful feature.
2677 $output_rules .= 'check-TESTS: $(TESTS)
2678 @failed=0; all=0; \\
2679 srcdir=$(srcdir); export srcdir; \\
2680 for tst in $(TESTS); do \\
2681 all=`expr $$all + 1`; \\
2682 if test -f $$tst; then dir=.; \\
2683 else dir="$(srcdir)"; fi; \\
2684 if $(TESTS_ENVIRONMENT) $$dir/$$tst; then \\
2685 echo "PASS: $$tst"; \\
2687 failed=`expr $$failed + 1`; \\
2688 echo "FAIL: $$tst"; \\
2691 if test "$$failed" -eq 0; then \\
2692 echo "========================"; \\
2693 echo "All $$all tests passed"; \\
2694 echo "========================"; \\
2696 echo "$$failed of $$all tests failed"; \\
2702 # Handle Emacs Lisp.
2703 sub handle_emacs_lisp
2705 local (@elfiles) = &am_install_var ('lisp', 'LISP', 'lisp', 'noinst');
2710 &define_variable ("lispdir", "\@lispdir\@");
2711 &define_variable ("EMACS", "\@EMACS\@");
2712 $output_rules .= (".el.elc:\n"
2713 . "\t\@echo 'WARNING: Warnings can be ignored. :-)'\n"
2714 . "\t\EMACS=$(EMACS) $(SHELL) \$(srcdir)/elisp-comp \$<\n");
2715 push (@suffixes, '.el', '.elc');
2717 # Generate .elc files.
2718 grep ($_ .= 'c', @elfiles);
2719 &define_pretty_variable ('ELCFILES', @elfiles);
2721 push (@clean, 'lisp');
2722 &push_phony_cleaners ('lisp');
2725 if (&variable_defined ('lisp_LISP'))
2727 $varname = 'lisp_LISP';
2728 &am_error ("\`lisp_LISP' defined but \`AM_PATH_LISPDIR' not in \`configure.in'")
2733 $varname = 'noinst_LISP';
2736 &require_file_with_line ($varname, $FOREIGN, 'elisp-comp');
2740 ################################################################
2742 # Scan configure.in for interesting things.
2745 open (CONFIGURE, 'configure.in')
2746 || die "automake: couldn't open \`configure.in': $!\n";
2747 print "automake: reading configure.in\n" if $verbose;
2749 # Reinitialize libsources here. This isn't really necessary,
2750 # since we currently assume there is only one configure.in. But
2751 # that won't always be the case.
2754 local ($in_ac_output, $in_ac_replace, @make_list) = (0, 0);
2755 local ($libobj_iter);
2758 # Remove comments from current line.
2762 # Populate libobjs array.
2763 if (/AC_FUNC_ALLOCA/)
2765 $libsources{'alloca.c'} = 1;
2767 elsif (/AC_FUNC_GETLOADAVG/)
2769 $libsources{'getloadavg.c'} = 1;
2771 elsif (/AC_FUNC_MEMCMP/)
2773 $libsources{'memcmp.c'} = 1;
2775 elsif (/AC_STRUCT_ST_BLOCKS/)
2777 $libsources{'fileblocks.c'} = 1;
2779 elsif (/AM_FUNC_FNMATCH/)
2781 $libsources{'fnmatch.c'} = 1;
2783 elsif (/A[CM]_REPLACE_GNU_GETOPT/)
2785 $libsources{'getopt.c'} = 1;
2786 $libsources{'getopt1.c'} = 1;
2788 elsif (/AM_FUNC_STRTOD/)
2790 $libsources{'strtod.c'} = 1;
2792 elsif (/AM_WITH_REGEX/)
2794 $libsources{'rx.c'} = 1;
2795 $libsources{'rx.h'} = 1;
2796 $libsources{'regex.c'} = 1;
2797 $libsources{'regex.h'} = 1;
2799 elsif (/AM_FUNC_MKTIME/)
2801 $libsources{'mktime.c'} = 1;
2803 elsif (/AM_FUNC_ERROR_AT_LINE/)
2805 $libsources{'error.c'} = 1;
2806 $libsources{'error.h'} = 1;
2808 elsif (/AM_FUNC_OBSTACK/)
2810 $libsources{'obstack.c'} = 1;
2811 $libsources{'obstack.h'} = 1;
2813 elsif (/LIBOBJS="(.*)\s+\$LIBOBJS"/
2814 || /LIBOBJS="\$LIBOBJS\s+(.*)"/)
2816 foreach $libobj_iter (split (' ', $1))
2818 if ($libobj_iter =~ /^(.*)\.o$/)
2820 $libsources{$1 . '.c'} = 1;
2825 if (! $in_ac_replace && s/AC_REPLACE_FUNCS\s*\(\[?//)
2831 $in_ac_replace = 0 if s/[\]\)].*$//;
2832 # Remove trailing backslash.
2836 $libsources{$_ . '.c'} = 1;
2840 if (/(fp_WITH_DMALLOC|fp_WITH_REGEX|fp_FUNC_FNMATCH|fp_PROG_INSTALL|fp_C_PROTOTYPES|jm_MAINTAINER_MODE)/)
2842 &am_conf_line_error ($., "\`$1' is obsolete; use corresponding \`AM_' macro");
2845 # Process the AC_OUTPUT macro.
2846 if (! $in_ac_output && s/AC_OUTPUT\s*\(\[?//)
2849 $ac_output_line = $.;
2853 $in_ac_output = 0 if s/[\]\),].*$//;
2855 # Look at potential Makefile.am's.
2861 push (@make_list, $_);
2865 push (@other_input_files, $_);
2870 if (/$AC_CONFIG_AUX_DIR_PATTERN/o)
2872 @config_aux_path = $1;
2875 # Check for ansi2knr.
2876 $am_c_prototypes = 1 if /AM_C_PROTOTYPES/;
2878 # Check for NLS support.
2879 if (/ud_GNU_GETTEXT/)
2882 $ac_gettext_line = $.;
2885 # Look for ALL_LINGUAS.
2886 if (/ALL_LINGUAS="(.*)"$/ || /ALL_LINGUAS=(.*)$/)
2890 $all_linguas_line = $.;
2893 # Handle configuration headers.
2894 if (/AC_CONFIG_HEADER\s*\((.*)\)/)
2896 $config_header_line = $.;
2898 if ($config_name =~ /^([^:]+):(.+)$/)
2901 $config_header = $2;
2905 $config_header = $config_name . '.in';
2909 # Handle AC_CANONICAL_*. Always allow upgrading to
2910 # AC_CANONICAL_SYSTEM, but never downgrading.
2911 $seen_canonical = $AC_CANONICAL_HOST
2912 if ! $seen_canonical
2913 && (/AC_CANONICAL_HOST/ || /AC_CHECK_TOOL/);
2914 $seen_canonical = $AC_CANONICAL_SYSTEM if /AC_CANONICAL_SYSTEM/;
2916 $seen_path_xtra = 1 if /AC_PATH_XTRA/;
2918 # Sometimes it is desirable to explicitly set YACC. For
2919 # instance some people don't want to use bison.
2920 $seen_prog_yacc = 1 if (/AC_PROG_YACC/
2921 || /AC_SUBST\(YACC\)/
2922 || /AC_(PATH|CHECK)_PROGS?\(YACC/);
2924 # This macro handles several different things.
2925 if (/$AM_INIT_AUTOMAKE_PATTERN/o)
2931 $seen_prog_install = 2;
2932 ($package_version = $1) =~ s/\s//;
2933 $package_version_line = $.;
2936 # Some things required by Automake.
2937 $seen_make_set = 1 if /AC_PROG_MAKE_SET/;
2938 $seen_arg_prog = 1 if /AC_ARG_PROGRAM/;
2939 $seen_ranlib = 1 if /AC_PROG_RANLIB/;
2940 $seen_prog_cc = 1 if /AC_PROG_CC/;
2941 $seen_prog_cxx = 1 if /AC_PROG_CXX/;
2942 $seen_prog_lex = 1 if /AC_PROG_LEX/;
2943 $seen_decl_yytext = 1 if /AC_DECL_YYTEXT/;
2944 $seen_maint_mode = 1 if /AM_MAINTAINER_MODE/;
2945 $seen_package = 1 if /PACKAGE=/;
2947 if (/VERSION=(\S+)/)
2950 $package_version = $1;
2951 $package_version_line = $.;
2958 # Weird conditionals here because it is always allowed to
2959 # upgrade to AM_PROG_INSTALL but never to downgrade to
2961 $seen_prog_install = 1 if ! $seen_prog_install && /AC_PROG_INSTALL/;
2962 $seen_prog_install = 2 if /AM_PROG_INSTALL/;
2964 $seen_lispdir = 1 if /AM_PATH_LISPDIR/;
2966 if (/AM_PROG_LIBTOOL/)
2974 # Set input files if not specified by user.
2975 @input_files = @make_list if (! @input_files);
2979 &am_conf_error ("\`PACKAGE' not defined in configure.in")
2981 &am_conf_error ("\`VERSION' not defined in configure.in")
2984 # Look for some files we need. Always check for these. This
2985 # check must be done for every run, even those where we are only
2986 # looking at a subdir Makefile. We must set relative_dir so that
2987 # the file-finding machinery works.
2988 local ($relative_dir) = '.';
2989 &require_config_file ($FOREIGN, 'install-sh', 'mkinstalldirs');
2990 &am_error ("\`install.sh' is an anachronism; use \`install-sh' instead")
2991 if -f $config_aux_path[0] . '/install.sh';
2994 ################################################################
2996 # Do any extra checking for GNU standards.
2997 sub check_gnu_standards
2999 if ($relative_dir eq '.')
3001 # In top level (or only) directory.
3002 &require_file ($GNU, 'INSTALL', 'NEWS', 'README', 'COPYING',
3003 'AUTHORS', 'ChangeLog');
3006 if ($strictness >= $GNU)
3008 if (defined $options{'no-installman'})
3010 &am_line_error ('AUTOMAKE_OPTIONS',
3011 "option \`no-installman' disallowed by GNU standards");
3014 if (defined $options{'no-installinfo'})
3016 &am_line_error ('AUTOMAKE_OPTIONS',
3017 "option \`no-installinfo' disallowed by GNU standards");
3022 # Do any extra checking for GNITS standards.
3023 sub check_gnits_standards
3025 if ($strictness >= $GNITS)
3027 if (-f $relative_dir . '/COPYING.LIB')
3029 &am_error ("\`${relative_dir}/COPYING.LIB' disallowed by Gnits standards");
3032 if ($relative_dir eq '.')
3034 if ($package_version !~ /^$GNITS_VERSION_PATTERN$/)
3036 &am_conf_line_error ($package_version_line,
3037 "version \`$package_version' doesn't follow Gnits standards");
3039 elsif (defined $1 && -f 'README-alpha')
3041 # This means we have an alpha release. See
3042 # GNITS_VERSION_PATTERN for details.
3043 &require_file ($GNITS, 'README-alpha');
3048 if ($relative_dir eq '.')
3050 # In top level (or only) directory.
3051 &require_file ($GNITS, 'THANKS');
3055 ################################################################
3057 # Pretty-print something. HEAD is what should be printed at the
3058 # beginning of the first line, FILL is what should be printed at the
3059 # beginning of every subsequent line.
3060 sub pretty_print_internal
3062 local ($head, $fill, @values) = @_;
3064 local ($column) = length ($head);
3065 local ($result) = $head;
3067 # Fill length is number of characters. However, each Tab
3068 # character counts for eight. So we count the number of Tabs and
3070 local ($fill_length) = length ($fill);
3071 $fill_length += 7 * ($fill =~ tr/\t/\t/d);
3076 # "71" because we also print a space.
3077 if ($column + length ($_) > 71)
3079 $result .= " \\\n" . $fill;
3080 $column = $fill_length;
3084 $result .= ' ' unless ($bol);
3086 $column += length ($_) + 1;
3094 # Pretty-print something and append to output_vars.
3097 $output_vars .= &pretty_print_internal (@_);
3100 # Pretty-print something and append to output_rules.
3101 sub pretty_print_rule
3103 $output_rules .= &pretty_print_internal (@_);
3107 ################################################################
3109 # See if a variable exists.
3110 sub variable_defined
3113 if (defined $targets{$var})
3115 &am_line_error ($var, "\`$var' is target; expected variable");
3118 elsif (defined $contents{$var})
3120 $content_seen{$var} = 1;
3126 # Mark a variable as examined.
3127 sub examine_variable
3130 &variable_defined ($var);
3133 # Return contents of variable as list, split as whitespace. This will
3134 # recursively follow $(...) and ${...} inclusions. It preserves @...@
3135 # substitutions. If PARENT is specified, it is the name of the
3136 # including variable; this is only used for error reports.
3137 sub variable_value_as_list
3139 local ($var, $parent) = @_;
3142 if (defined $targets{$var})
3144 &am_line_error ($var, "\`$var' is target; expected variable");
3146 elsif (! defined $contents{$var})
3148 &am_line_error ($parent, "variable \`$var' not defined");
3152 $content_seen{$var} = 1;
3153 foreach (split (' ', $contents{$var}))
3155 # If a comment seen, just leave.
3158 # Handle variable substitutions.
3159 if (/^\$\{(.*)\}$/ || /^\$\((.*)\)$/)
3161 push (@result, &variable_value_as_list ($1, $var));
3173 # Define a new variable, but only if not already defined.
3176 local ($var, $value) = @_;
3178 if (! defined $contents{$var})
3180 $output_vars .= $var . ' = ' . $value . "\n";
3181 $contents{$var} = $value;
3182 $content_seen{$var} = 1;
3186 # Like define_variable, but second arg is a list, and is
3188 sub define_pretty_variable
3190 local ($var, @value) = @_;
3191 if (! defined $contents{$var})
3193 $contents{$var} = join (' ', @value);
3194 &pretty_print ($var . ' = ', '', @value);
3195 $content_seen{$var} = 1;
3199 # Read Makefile.am and set up %contents. Simultaneously copy lines
3200 # from Makefile.am into $output_trailer or $output_vars as
3201 # appropriate. NOTE we put rules in the trailer section. We want
3202 # user rules to come after our generated stuff.
3205 local ($amfile) = @_;
3207 open (AM_FILE, $amfile) || die "automake: couldn't open \`$amfile': $!\n";
3208 print "automake: reading $amfile\n" if $verbose;
3210 $output_vars = ("# $in_file_name generated automatically by automake "
3211 . $VERSION . " from $am_file_name\n");
3213 # Generate copyright for generated Makefile.in.
3214 $output_vars .= $gen_copyright;
3216 local ($saw_bk) = 0;
3217 local ($was_rule) = 0;
3218 local ($spacing) = '';
3219 local ($comment) = '';
3220 local ($last_var_name) = '';
3225 if (/$IGNORE_PATTERN/o)
3227 # Merely delete comments beginning with two hashes.
3229 elsif (/$WHITE_PATTERN/o)
3231 # Stick a single white line before the incoming macro or rule.
3235 elsif (/$COMMENT_PATTERN/o)
3237 # Stick comments before the incoming macro or rule. Make
3238 # sure a blank line preceeds first block of comments.
3239 $spacing = "\n" unless $blank;
3241 $comment .= $spacing . $_;
3250 $output_vars .= $comment . "\n";
3253 local ($am_vars) = '';
3255 local ($is_ok_macro);
3259 unless substr ($_, -1, 1) eq "\n";
3261 $_ =~ s/\@MAINT\@//g
3262 unless $seen_maint_mode;
3264 if (/$IGNORE_PATTERN/o)
3266 # Merely delete comments beginning with two hashes.
3268 elsif (/$WHITE_PATTERN/o)
3270 # Stick a single white line before the incoming macro or rule.
3273 elsif (/$COMMENT_PATTERN/o)
3275 # Stick comments before the incoming macro or rule.
3276 $comment .= $spacing . $_;
3283 $output_trailer .= $_;
3290 # Chop newline and backslash if this line is
3291 # continued. FIXME: maybe ensure trailing whitespace
3295 $contents{$last_var_name} .= $_;
3298 elsif (/$RULE_PATTERN/o)
3300 # warn "** Saw rule .$1.\n";
3303 # Value here doesn't matter; for targets we only note
3307 $content_lines{$1} = $.;
3308 $output_trailer .= $comment . $spacing . $_;
3309 $comment = $spacing = '';
3312 elsif (($is_ok_macro = /$MACRO_PATTERN/o)
3313 || /$BOGUS_MACRO_PATTERN/o)
3315 # Found a macro definition.
3317 $last_var_name = $1;
3318 if (substr ($2, -1) eq "\\")
3320 $contents{$1} = substr ($2, 0, length ($2) - 1);
3326 $content_lines{$1} = $.;
3327 $am_vars .= $comment . $spacing . $_;
3328 $comment = $spacing = '';
3332 &am_line_error ($., "bad macro name \`$1'")
3337 # This isn't an error; it is probably a continued rule.
3338 # In fact, this is what we assume.
3340 $output_trailer .= $comment . $spacing . $_;
3341 $comment = $spacing = '';
3348 $output_trailer .= $comment;
3350 # Compute relative location of the top object directory.
3351 local (@topdir) = ();
3352 foreach (split (/\//, $relative_dir))
3354 next if $_ eq '.' || $_ eq '';
3361 push (@topdir, '..');
3364 @topdir = ('.') if ! @topdir;
3366 $top_builddir = join ('/', @topdir);
3368 ($build_rx = $top_builddir) =~ s/(\W)/\\$1/g;
3369 $output_vars .= &file_contents_with_transform
3370 ('s/\@top_builddir\@/' . $build_rx . '/g',
3373 # Generate some useful variables when AC_CANONICAL_* used.
3374 if ($seen_canonical)
3376 local ($curs, %vars);
3377 $vars{'host_alias'} = 'host_alias';
3378 $vars{'host_triplet'} = 'host';
3379 if ($seen_canonical == $AC_CANONICAL_SYSTEM)
3381 $vars{'build_alias'} = 'build_alias';
3382 $vars{'build_triplet'} = 'build';
3383 $vars{'target_alias'} = 'target_alias';
3384 $vars{'target_triplet'} = 'target';
3386 foreach $curs (keys %vars)
3388 $output_vars .= "$curs = \@$vars{$curs}\@\n";
3389 $contents{$curs} = "\@$vars{$curs}\@";
3393 $output_vars .= $am_vars;
3396 ################################################################
3398 sub initialize_global_constants
3400 # Values for AC_CANONICAL_*
3401 $AC_CANONICAL_HOST = 1;
3402 $AC_CANONICAL_SYSTEM = 2;
3404 # Associative array of standard directory names. Entry is TRUE if
3405 # corresponding directory should be installed during
3406 # 'install-exec' phase.
3424 # Helper text for dealing with man pages.
3425 $install_man_format =
3426 ' sect=@SECTION@; \\
3427 inst=`echo "@MANBASE@" | sed \'$(transform)\'`.@FULLSECT@; \\
3428 if test -f $(srcdir)/@MAN@; then file=$(srcdir)/@MAN@; \\
3429 else file=@MAN@; fi; \\
3430 $(INSTALL_DATA) $$file $(mandir)/man$$sect/$$inst
3433 $uninstall_man_format =
3434 ' inst=`echo "@MANBASE@" | sed \'$(transform)\'`.@FULLSECT@; \\
3435 rm -f $(mandir)/man@SECTION@/$$inst
3438 # Commonly found files we look for and automatically include in
3442 "README", "THANKS", "TODO", "NEWS", "COPYING", "COPYING.LIB",
3443 "INSTALL", "ABOUT-NLS", "ChangeLog", "configure", "configure.in",
3444 "config.guess", "config.sub", "AUTHORS", "BACKLOG", "ABOUT-GNU",
3445 "libversion.in", "mdate-sh", "mkinstalldirs", "install-sh",
3446 'texinfo.tex', "ansi2knr.c", "ansi2knr.1", 'elisp-comp',
3447 'interlock', 'ylwrap', 'acinclude.m4'
3450 # Commonly used files we auto-include, but only sometimes.
3453 "aclocal.m4", "acconfig.h", "config.h.top",
3454 "config.h.bot", "stamp-h.in", 'stamp-vti', 'libtool'
3458 -a, --add-missing add missing standard files to package
3459 --amdir=DIR directory storing config files
3460 --build-dir=DIR directory where build being done (for dependencies)
3461 --foreign same as --strictness=foreign
3462 --gnits same as --strictness=gnits
3463 --gnu same as --strictness=gnu
3464 --help print this help, then exit
3465 -i, --include-deps include generated dependencies in Makefile.in
3466 --no-force only update Makefile.in's that are out of date
3467 -o DIR, --output-dir=DIR
3468 put generated Makefile.in's into DIR
3469 --srcdir-name=DIR name used for srcdir (for dependencies)
3470 -s LEVEL, --strictness=LEVEL
3471 set strictness level. LEVEL is foreign, gnu, gnits
3472 -v, --verbose verbosely list files processed
3473 --version print version number, then exit\n";
3475 # Copyright on generated Makefile.ins.
3477 # Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
3478 # This Makefile.in is free software; the Free Software Foundation
3479 # gives unlimited permission to copy, distribute and modify it.
3482 # Ignore return result from chmod, because it might give an error
3483 # if we chmod a symlink.
3484 $dist_header = "\t" . '-chmod -R a+r $(distdir)' . "\n";
3485 $dist{'tarZ'} = ("\t"
3486 . '$(TAR) chf - $(distdir) | compress -c > $(distdir).tar.Z'
3488 $dist{'shar'} = ("\t"
3489 . 'shar $(distdir) | gzip > $(distdir).shar.gz'
3491 $dist{'zip'} = "\t" . 'zip -rq $(distdir).zip $(distdir)' . "\n";
3492 $dist{'dist'} = "\t" . '$(TAR) chozf $(distdir).tar.gz $(distdir)' . "\n";
3493 $dist_trailer = "\t" . 'rm -rf $(distdir)' . "\n";
3496 # (Re)-Initialize per-Makefile.am variables.
3497 sub initialize_per_input
3499 # These two variables are used when generating each Makefile.in.
3500 # They hold the Makefile.in until it is ready to be printed.
3503 $output_trailer = '';
3505 # Suffixes found during a run.
3508 # This holds the contents of a Makefile.am, as parsed by
3512 # This holds the names which are targets. These also appear in
3516 # This holds the line numbers at which various elements of
3517 # %contents are defined.
3518 %content_lines = ();
3520 # This holds a 1 if a particular variable was examined.
3523 # This holds the "relative directory" of the current Makefile.in.
3524 # Eg for src/Makefile.in, this is "src".
3527 # This holds a list of files that are included in the
3531 # List of dependencies for the obvious targets.
3546 # These are pretty obvious, too. They are used to define the
3547 # SOURCES and OBJECTS variables.
3551 # TRUE if current directory holds any C source files. (Actually
3552 # holds object extension, but this information is encapsulated in
3553 # the function get_object_extension).
3554 $dir_holds_sources = '';
3556 # TRUE if current directory holds any headers.
3557 $dir_holds_headers = 0;
3559 # TRUE if install targets should work recursively.
3560 $recursive_install = 0;
3565 # Strictness levels.
3566 $strictness = $default_strictness;
3567 $strictness_name = $default_strictness_name;
3569 # Options from AUTOMAKE_OPTIONS.
3572 # Whether or not dependencies are handled. Can be further changed
3573 # in handle_options.
3574 $use_dependencies = $cmdline_use_dependencies;
3577 $local_maint_charset = $maint_charset;
3579 # All yacc and lex source filenames for this directory. Use
3580 # filenames instead of raw count so that multiple instances are
3581 # counted correctly (eg one yacc file can appear in multiple
3582 # programs without harm).
3586 # C++ source extensions we've seen.
3587 %cxx_extensions = ();
3589 # TRUE if we've seen any non-C++ sources.
3594 ################################################################
3596 # Return contents of a file from $am_dir, automatically skipping
3597 # macros or rules which are already known. Runs command on each line
3598 # as it is read; this command can modify $_.
3599 sub file_contents_with_transform
3601 local ($command, $basename) = @_;
3602 local ($file) = $am_dir . '/' . $basename . '.am';
3604 open (FC_FILE, $file)
3605 || die "automake: installation error: cannot open \`$file'\n";
3607 # print "automake: reading $file\n" if $verbose;
3609 local ($was_rule) = 0;
3610 local ($result_vars) = '';
3611 local ($result_rules) = '';
3612 local ($comment) = '';
3613 local ($spacing) = "\n";
3614 local ($skipping) = 0;
3618 $_ =~ s/\@MAINT\@//g
3619 unless $seen_maint_mode;
3623 if (/$IGNORE_PATTERN/o)
3625 # Merely delete comments beginning with two hashes.
3627 elsif (/$WHITE_PATTERN/o)
3629 # Stick a single white line before the incoming macro or rule.
3632 elsif (/$COMMENT_PATTERN/o)
3634 # Stick comments before the incoming macro or rule.
3635 $comment .= $spacing . $_;
3642 $result_rules .= $_ if ! $skipping;
3646 $result_vars .= $_ if ! $skipping;
3650 elsif (/$RULE_PATTERN/o)
3652 # warn "** Found rule .$1.\n";
3655 $skipping = defined $contents{$1};
3656 # warn "** Skip $skipping\n" if $skipping;
3657 $result_rules .= $comment . $spacing . $_ if ! $skipping;
3658 $comment = $spacing = '';
3661 elsif (/$MACRO_PATTERN/o)
3663 # warn "** Found macro .$1.\n";
3664 # Found a variable reference.
3666 $skipping = defined $contents{$1};
3667 # warn "** Skip $skipping\n" if $skipping;
3668 $result_vars .= $comment . $spacing . $_ if ! $skipping;
3669 $comment = $spacing = '';
3674 # This isn't an error; it is probably a continued rule.
3675 # In fact, this is what we assume.
3677 $result_rules .= $comment . $spacing . $_ if ! $skipping;
3678 $comment = $spacing = '';
3684 return $result_vars . $result_rules . $comment;
3687 # Like file_contents_with_transform, but no transform.
3690 return &file_contents_with_transform ('', @_);
3693 # Find all variable prefixes that are used for install directories. A
3694 # prefix `zar' qualifies iff:
3695 # * `zardir' is a variable.
3696 # * `zar_PRIMARY' is a variable.
3697 sub am_primary_prefixes
3699 local ($primary, @prefixes) = @_;
3701 local (%valid, $varname);
3702 grep ($valid{$_} = 0, @prefixes);
3703 $valid{'EXTRA'} = 0;
3704 foreach $varname (keys %contents)
3706 if ($varname =~ /^(.*)_$primary$/)
3708 if (! defined $valid{$1} && ! &variable_defined ($1 . 'dir'))
3710 &am_line_error ($varname, "invalid variable \"$varname\"");
3714 # Ensure all extended prefixes are actually used.
3723 # Handle `where_HOW' variable magic. Does all lookups, generates
3724 # install code, and possibly generates code to define the primary
3725 # variable. The first argument is the name of the .am file to munge,
3726 # the second argument is the primary variable (eg HEADERS), and all
3727 # subsequent arguments are possible installation locations. Returns
3728 # list of all values of all _HOW targets.
3730 # FIXME: this should be rewritten to be cleaner. It should be broken
3731 # up into multiple functions.
3733 # Usage is: am_install_var (OPTION..., file, HOW, where...)
3738 local ($do_all, $do_clean) = (1, 0);
3741 if ($args[0] eq '-clean')
3745 elsif ($args[0] eq '-no-all')
3749 elsif ($args[0] !~ /^-/)
3755 local ($file, $primary, @prefixes) = @args;
3758 local (@result) = ();
3760 # Now that configure substitutions are allowed in where_HOW
3761 # variables, it is an error to actually define the primary.
3762 &am_line_error ($primary, "\`$primary' is an anachronism")
3763 if &variable_defined ($primary);
3766 # Look for misspellings. It is an error to have a variable ending
3767 # in a "reserved" suffix whose prefix is unknown, eg
3768 # "bni_PROGRAMS". However, unusual prefixes are allowed if a
3769 # variable of the same name (with "dir" appended) exists. For
3770 # instance, if the variable "zardir" is defined, then
3771 # "zar_PROGRAMS" becomes valid. This is to provide a little extra
3772 # flexibility in those cases which need it. Perhaps it should be
3773 # disallowed in the Gnits case? The problem is, sometimes it is
3774 # useful to put things in a subdir of eg pkgdatadir, perhaps even
3776 local (%valid) = &am_primary_prefixes ($primary, @prefixes);
3778 # If a primary includes a configure substitution, then the EXTRA_
3779 # form is required. Otherwise we can't properly do our job.
3780 local ($require_extra);
3781 local ($warned_about_extra) = 0;
3783 local ($clean_file) = $file . '-clean';
3786 foreach $X (keys %valid)
3788 $one_name = $X . '_' . $primary;
3789 if (&variable_defined ($one_name))
3791 # Append actual contents of where_PRIMARY variable to
3794 foreach $rcurs (&variable_value_as_list ($one_name))
3796 # Skip configure substitutions. Possibly bogus.
3797 if ($rcurs =~ /^\@.*\@$/)
3801 if (! $warned_about_extra)
3803 $warned_about_extra = 1;
3804 &am_line_error ($one_name,
3805 "\`$one_name' contains configure substitution, but shouldn't");
3810 $require_extra = $one_name;
3814 push (@result, $rcurs);
3817 # "EXTRA" shouldn't be used when generating clean targets,
3818 # @all, or install targets.
3819 next if $X eq 'EXTRA';
3824 &file_contents_with_transform ('s/\@DIR\@/' . $X . '/go',
3827 push (@clean, $X . $primary);
3828 &push_phony_cleaners ($X . $primary);
3833 push (@check, '$(' . $one_name . ')');
3837 push (@used, '$(' . $one_name . ')');
3839 if ($X eq 'noinst' || $X eq 'check')
3841 # Objects which don't get installed by default.
3846 &file_contents_with_transform ('s/\@DIR\@/' . $X . '/go',
3849 push (@uninstall, 'uninstall-' . $X . $primary);
3850 push (@phony, 'uninstall-' . $X . $primary);
3851 push (@installdirs, '$(' . $X . 'dir)');
3852 if ($exec_dir_p{$X})
3854 push (@install_exec, 'install-' . $X . $primary);
3855 push (@phony, 'install-' . $X . $primary);
3859 push (@install_data, 'install-' . $X . $primary);
3860 push (@phony, 'install-' . $X . $primary);
3868 &define_pretty_variable ($primary, @used);
3869 $output_vars .= "\n";
3872 if ($require_extra && ! &variable_defined ('EXTRA_' . $primary))
3874 &am_line_error ($require_extra,
3875 "\`$require_extra' contains configure substitution, but \`EXTRA_$primary' not defined");
3878 # Push here because PRIMARY might be configure time determined.
3879 push (@all, '$(' . $primary . ')')
3880 if $do_all && @used;
3886 ################################################################
3888 # This variable is local to the "require file" set of functions.
3889 @require_file_paths = ();
3891 # Verify that the file must exist in the current directory. Usage:
3892 # require_file (isconfigure, line_number, strictness, file) strictness
3893 # is the strictness level at which this file becomes required. Must
3894 # set require_file_paths before calling this function.
3895 # require_file_paths is set to hold a single directory (the one in
3896 # which the first file was found) before return.
3897 sub require_file_internal
3899 local ($is_configure, $line, $mystrict, @files) = @_;
3900 local ($file, $fullfile);
3901 local ($found_it, $errfile, $errdir);
3904 foreach $file (@files)
3907 foreach $dir (@require_file_paths)
3911 $fullfile = $relative_dir . "/" . $file;
3912 $errdir = $relative_dir unless $errdir;
3916 $fullfile = $dir . "/" . $file;
3917 $errdir = $dir unless $errdir;
3920 # Use different name for "error filename". Otherwise on
3921 # an error the bad file will be reported as eg
3922 # `../../install-sh' when using the default
3924 $errfile = $errdir . '/' . $file;
3929 # FIXME: Once again, special-case `.'.
3930 &push_dist_common ($file)
3931 if $dir eq $relative_dir || $dir eq '.';
3939 # Prune the path list.
3940 @require_file_paths = $save_dir;
3944 if ($strictness >= $mystrict)
3946 local ($trailer) = '';
3947 local ($suppress) = 0;
3949 # Only install missing files according to our desired
3951 if ($add_missing && -f ($am_dir . '/' . $file))
3953 $trailer = "; installing";
3955 # Install the missing file. Symlink if we can, copy
3957 if ($symlink_exists)
3959 if (! symlink ($am_dir . '/' . $file, $errfile))
3962 $trailer .= "; error while making link: $!\n";
3967 if (! system ('cp', $am_dir . '/' . $file, $errfile))
3970 $trailer .= "\n error while making link: $!\n";
3975 local ($save) = $exit_status;
3980 "required file \"$errfile\" not found$trailer");
3986 "required file \"$errfile\" not found$trailer");
3988 $exit_status = $save if $suppress;
3994 # Like require_file_with_line, but error messages refer to
3995 # configure.in, not the current Makefile.am.
3996 sub require_file_with_conf_line
3998 @require_file_paths = '.';
3999 &require_file_internal (1, @_);
4002 sub require_file_with_line
4004 @require_file_paths = '.';
4005 &require_file_internal (0, @_);
4010 @require_file_paths = '.';
4011 &require_file_internal (0, '', @_);
4014 # Require a file that is also required by Autoconf. Looks in
4015 # configuration path, as specified by AC_CONFIG_AUX_DIR.
4016 sub require_config_file
4018 @require_file_paths = @config_aux_path;
4019 &require_file_internal (1, '', @_);
4020 local ($dir) = $require_file_paths[0];
4021 @config_aux_path = @require_file_paths;
4024 $config_aux_dir = '.';
4028 $config_aux_dir = '$(top_srcdir)/' . $dir;
4032 # Assumes that the line number is in Makefile.am.
4033 sub require_conf_file_with_line
4035 @require_file_paths = @config_aux_path;
4036 &require_file_internal (0, @_);
4037 local ($dir) = $require_file_paths[0];
4038 @config_aux_path = @require_file_paths;
4041 $config_aux_dir = '.';
4045 $config_aux_dir = '$(top_srcdir)/' . $dir;
4049 # Assumes that the line number is in Makefile.am.
4050 sub require_conf_file_with_conf_line
4052 @require_file_paths = @config_aux_path;
4053 &require_file_internal (1, @_);
4054 local ($dir) = $require_file_paths[0];
4055 @config_aux_path = @require_file_paths;
4058 $config_aux_dir = '.';
4062 $config_aux_dir = '$(top_srcdir)/' . $dir;
4066 ################################################################
4068 # Push a list of files onto dist_common.
4069 sub push_dist_common
4071 local (@files) = @_;
4074 foreach $file (@files)
4076 $dist_common{$file} = 1;
4080 # Push a list of clean targets onto phony.
4081 sub push_phony_cleaners
4085 foreach $target ('mostly', 'dist', '', 'maintainer-')
4087 push (@phony, $target . 'clean-' . $base);
4094 $strictness_name = $_[0];
4095 if ($strictness_name eq 'gnu')
4099 elsif ($strictness_name eq 'gnits')
4101 $strictness = $GNITS;
4103 elsif ($strictness_name eq 'foreign')
4105 $strictness = $FOREIGN;
4109 die "automake: level \`$strictness_name' not recognized\n";
4114 ################################################################
4116 # Return directory name of file.
4122 ($sub = $file) =~ s,/+[^/]+$,,g;
4123 $sub = '.' if $sub eq $file;
4127 # Return file name of a file.
4133 ($sub = $file) =~s,^.*/+,,g;
4142 open (TOUCH, ">> $file");
4146 ################################################################
4148 # Print an error message and set exit status.
4151 warn "automake: ${am_file}.am: ", join (' ', @_), "\n";
4157 local ($symbol, @args) = @_;
4161 # If SYMBOL not already a line number, look it up in Makefile.am.
4162 $symbol = $content_lines{$symbol} unless $symbol =~ /^\d+$/;
4163 $symbol .= ': ' if $symbol;
4164 warn "${am_file}.am:", $symbol, join (' ', @args), "\n";
4173 # Like am_error, but while scanning configure.in.
4176 # FIXME: can run in subdirs.
4177 warn "automake: configure.in: ", join (' ', @_), "\n";
4181 # Error message with line number referring to configure.in.
4182 sub am_conf_line_error
4184 local ($line, @args) = @_;
4188 warn "configure.in: $line: ", join (' ', @args), "\n";
4193 &am_conf_error (@args);
4197 # Tell user where our aclocal.m4 is, but only once.
4198 sub keyed_aclocal_warning
4201 warn "automake: macro \`$key' can be generated by \`aclocal'\n";
4204 # Print usage information.
4207 print "Usage: automake [OPTION] ... [Makefile]...\n";
4209 print "\nFiles which are automatically distributed, if found:\n";
4210 $~ = "USAGE_FORMAT";
4211 local (@lcomm) = sort ((@common_files, @common_sometimes));
4212 local ($one, $two, $three, $four);
4215 $one = shift @lcomm;
4216 $two = @lcomm ? shift @lcomm : '';
4217 $three = @lcomm ? shift @lcomm : '';
4218 $four = @lcomm ? shift @lcomm : '';
4222 print "\nReport bugs to <bug-gnu-utils\@prep.ai.mit.edu>\n";
4227 format USAGE_FORMAT =
4228 @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<
4229 $one, $two, $three, $four