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 $output_rules .= ".l.c:\n\t";
700 $output_rules .= '$(SHELL) $(INTERLOCK) =lexlockdir $(YLWRAP) "$(LEX)" $(LEX_OUTPUT_ROOT).c $@ -- $(LFLAGS) $<';
704 $output_rules .= '$(LEX) $(LFLAGS) $< && mv $(LEX_OUTPUT_ROOT).c $@';
706 $output_rules .= "\n";
708 if (! $seen_prog_lex)
710 &am_error ("lex source seen but \`AC_PROG_LEX' not in \`configure.in'\n");
712 if (! $seen_decl_yytext)
714 &am_error ("lex source seen but \`AC_DECL_YYTEXT' not in \`configure.in'\n");
718 if ($yacc_count > 1 || $lex_count > 1)
720 # If there is more than one distinct yacc (resp lex) source
721 # file in a given directory, then the `interlock' program is
722 # required to allow parallel builds to work correctly. FIXME:
723 # for now, no line number.
724 &require_config_file ($FOREIGN, 'interlock', 'ylwrap');
725 &define_variable ('INTERLOCK', $config_aux_dir . "/interlock");
726 &define_variable ('YLWRAP', $config_aux_dir . "/ylwrap");
732 local (@cxx_list) = keys %cxx_extensions;
733 local ($cxx_count) = scalar @cxx_list;
736 push (@suffixes, @cxx_list);
738 &define_variable ("CXX", "\@CXX\@");
739 &define_variable ("CXXFLAGS", "\@CXXFLAGS\@");
740 &define_variable ('CXXCOMPILE', '$(CXX) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CXXFLAGS)');
741 &define_variable ('CXXLINK', '$(CXX) $(LDFLAGS) -o $@');
744 foreach $ext (@cxx_list)
746 $output_rules .= ("$ext.o:\n"
747 . "\t\$(CXXCOMPILE) -c \$<\n");
750 if (! $seen_prog_cxx)
752 &am_error ("C++ source seen but \`AC_PROG_CXX' not in \`configure.in'\n");
757 # Last, handle some C cleanup.
761 &define_variable ('CC', "\@CC\@");
762 &define_variable ('CFLAGS', "\@CFLAGS\@");
763 &define_variable ('COMPILE',
764 '$(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)');
765 &define_variable ('LINK', '$(CC) $(LDFLAGS) -o $@');
769 # Handle SOURCE->OBJECT transform for one program or library.
771 # canonical (transformed) name of object to build
772 # actual name of object to build
773 # object extension (ie either `.o' or `$o'.
774 # Return result is name of linker variable that must be used.
775 # Empty return means just use `LINK'.
776 sub handle_source_transform
778 # one_file is canonical name. unxformed is given name. obj is
780 local ($one_file, $unxformed, $obj) = @_;
781 local ($objpat) = $obj;
782 $objpat =~ s/(\W)/\\$1/g;
784 local ($linker) = '';
786 if (&variable_defined ($one_file . "_OBJECTS"))
788 &am_line_error ($one_file . '_OBJECTS',
789 $one_file . '_OBJECTS', 'should not be defined');
790 # No point in continuing.
796 foreach $prefix ('', 'EXTRA_')
799 if (&variable_defined ($prefix . $one_file . "_SOURCES"))
801 push (@sources, '$(' . $prefix . $one_file . "_SOURCES)");
802 push (@objects, '$(' . $prefix . $one_file . "_OBJECTS)")
803 unless $prefix eq 'EXTRA_';
804 @files = &variable_value_as_list ($prefix
805 . $one_file . "_SOURCES");
807 elsif ($prefix eq '')
809 &define_variable ($one_file . "_SOURCES", $unxformed . ".c");
810 push (@sources, $unxformed . '.c');
811 push (@objects, $unxformed . $obj);
812 push (@files, $unxformed . '.c');
816 &define_variable ("EXTRA_" . $one_file . "_SOURCES", '');
821 # Turn sources into objects.
822 local (@result) = ();
825 # If an automatically-discovered source file is
826 # mentioned, that is an error.
827 if (defined $libsources{$_})
829 # FIXME: saving $_ is stupid.
831 &am_line_error ($prefix . $one_file . '_SOURCES',
832 "automatically discovered file \`$_' should not be explicitly mentioned");
836 # Skip header files, including C++-ish ones. The list
837 # of C++ header extensions comes from Emacs 19.32
844 # Skip things that look like configure substitutions.
847 # Include .c file for lex or yacc source in distribution.
851 &push_dist_common ($1 . '.c');
852 $yacc_sources{$_} = 1;
857 &push_dist_common ($1 . '.c');
858 $lex_sources{$_} = 1;
861 # Transform source files into .o files. List of C++
862 # extensions comes from Emacs 19.32 etags.
863 if (s/\.c\+\+$/$obj/g
869 $cxx_extensions{$&} = 1;
874 # FORTRAN support. FIXME: not finished.
878 # .y is yacc. .l is lex. .f and .F is fortran.
879 # .s is assembly. .M is Objective-C++. .m is
881 s/\.[cylfFsmM]$/$obj/g;
883 # FIXME: of course, this should only happen for C
884 # source. The multi-language support must really
885 # be cleaned up more globally.
890 unless $prefix eq 'EXTRA_';
892 # Transform .o or $o file into .P file (for automatic
895 $dep_files{'.deps/' . $_} = 1;
898 &define_pretty_variable ($one_file . "_OBJECTS", @result)
899 unless $prefix eq 'EXTRA_';
903 if (&variable_defined ('CONFIG_HEADER'))
905 $output_rules .= ('$(' . $one_file . "_OBJECTS): "
906 . $contents{'CONFIG_HEADER'} . "\n");
912 # Special-case @ALLOCA@ and @LIBOBJS@ in _LDADD or _LIBADD variables.
913 # Also, generate _DEPENDENCIES variable if appropriate.
915 # transformed name of object being built, or empty string if no object
916 # name of _LDADD/_LIBADD-type variable to examine
917 sub handle_lib_objects
919 local ($xname, $var) = @_;
921 die "programming error in handle_lib_objects"
922 if ! &variable_defined ($var);
924 # We recognize certain things that are commonly put in LIBADD or
927 local (@dep_list) = ();
929 foreach $lsearch (&variable_value_as_list ($var))
931 # Skip -lfoo and -Ldir.
932 next if $lsearch =~ /^-[lL]/;
934 # Assume we have a file of some sort, and push it onto the
935 # dependency list. Autoconf substitutions are not pushed;
936 # rarely is a new dependency substituted into (eg) foo_LDADD
937 # -- but "bad things (eg -lX11) are routinely substituted.
938 push (@dep_list, $lsearch)
939 unless $lsearch =~ /^\@.*\@$/;
941 # Automatically handle @LIBOBJS@ and @ALLOCA@. Basically this
942 # means adding entries to dep_files.
943 if ($lsearch eq '@LIBOBJS@')
945 if (! keys %libsources)
947 &am_line_error ($var, "\@LIBOBJS\@ seen but never set in \`configure.in'");
950 local ($iter, $rewrite);
951 foreach $iter (keys %libsources)
955 &require_file_with_line ($var, $FOREIGN, $iter);
957 elsif ($iter ne 'alloca.c')
959 ($rewrite = $iter) =~ s/\.c$/.P/;
960 $dep_files{'.deps/' . $rewrite} = 1;
961 &require_file_with_line ($var, $FOREIGN, $iter);
965 elsif ($lsearch eq '@ALLOCA@')
967 &am_line_error ($var,
968 "\@ALLOCA\@ seen but \`AC_FUNC_ALLOCA' not in \`configure.in'")
969 if ! defined $libsources{'alloca.c'};
970 $dep_files{'.deps/alloca.P'} = 1;
971 &require_file_with_line ($var, $FOREIGN, 'alloca.c');
975 if ($xname ne '' && ! &variable_defined ($xname . '_DEPENDENCIES'))
977 &define_pretty_variable ($xname . '_DEPENDENCIES', @dep_list);
984 local (@proglist) = &am_install_var ('-clean',
986 'bin', 'sbin', 'libexec', 'pkglib',
988 return if ! @proglist;
990 # If a program is installed, this is required. We only want this
991 # error to appear once.
992 &am_conf_error ("AC_ARG_PROGRAM must be used in configure.in")
993 unless $seen_arg_prog;
996 local ($obj) = &get_object_extension;
997 local ($one_file, $xname, $munge);
999 foreach $one_file (@proglist)
1001 # Canonicalize names.
1002 ($xname = $one_file) =~ tr/A-Za-z0-9_/_/c;
1003 if ($xname ne $one_file)
1006 foreach $xt ('_LDADD', '_SOURCES', '_OBJECTS', '_DEPENDENCIES')
1008 &am_line_error ($one_file . $xt,
1009 "invalid variable \`" . $one_file . $xt
1010 . "'; should be \`" . $xname . $xt . "'")
1011 if &variable_defined ($one_file . $xt);
1015 local ($linker) = &handle_source_transform ($xname, $one_file, $obj);
1017 if (&variable_defined ($xname . "_LDADD"))
1019 &handle_lib_objects ($xname, $xname . '_LDADD');
1023 # User didn't define prog_LDADD override. So do it.
1024 &define_variable ($xname . '_LDADD', '$(LDADD)');
1026 # This does a bit too much work. But we need it to
1027 # generate _DEPENDENCIES when appropriate.
1028 &handle_lib_objects ($xname, 'LDADD')
1029 if (&variable_defined ('LDADD'));
1032 # Determine program to use for link.
1034 if (&variable_defined ($xname . '_LINK'))
1036 $xlink = $xname . '_LINK';
1040 $xlink = $linker ? $linker : 'LINK';
1044 &file_contents_with_transform
1045 ('s/\@PROGRAM\@/' . $one_file . '/go;'
1046 . 's/\@XPROGRAM\@/' . $xname . '/go;'
1047 . 's/\@XLINK\@/' . $xlink . '/go;',
1051 &handle_lib_objects ('', 'LDADD')
1052 if &variable_defined ('LDADD');
1056 sub handle_libraries
1058 local (@liblist) = &am_install_var ('-no-all', '-clean',
1059 'libs', 'LIBRARIES',
1060 'lib', 'pkglib', 'noinst', 'check');
1061 return if ! @liblist;
1063 local (%valid) = &am_primary_prefixes ('LIBRARIES', 'lib', 'pkglib',
1068 foreach $key (keys %valid)
1070 if (&variable_defined ($key . '_LIBRARIES'))
1072 &am_line_error ($key . '_LIBRARIES', "library requires either \`AC_PROG_RANLIB' or `AM_PROG_LIBTOOL' in configure.in");
1073 # Only get this error once.
1080 # Generate _LIBFILES variables. Too bad we can't do this in
1082 local ($onedir, $onelib);
1084 local (@libfiles_list);
1085 foreach $onedir (keys %valid)
1087 if (&variable_defined ($onedir . '_LIBRARIES'))
1090 foreach $onelib (&variable_value_as_list ($onedir . '_LIBRARIES'))
1092 push (@outlist, 'lib' . $onelib . '.a');
1094 &define_pretty_variable ($onedir . '_LIBFILES', @outlist);
1097 push (@libfiles_list, '$(' . $onedir . '_LIBFILES)')
1098 unless $onedir eq 'EXTRA';
1100 push (@all, '$(LIBFILES)');
1102 local ($obj) = &get_object_extension;
1105 foreach $onelib (@liblist)
1107 # Canonicalize names.
1108 ($xlib = $onelib) =~ tr/A-Za-z0-9_/_/c;
1109 if ($xlib ne $onelib)
1112 foreach $xt ('_LIBADD', '_SOURCES', '_OBJECTS', '_DEPENDENCIES')
1114 &am_line_error ($one_file . $xt,
1115 "invalid variable \`" . $onelib . $xt
1116 . "'; should be \`" . $xlib . $xt . "'")
1117 if &variable_defined ($onelib . $xt);
1121 if (&variable_defined ($xlib . '_LIBADD'))
1123 &handle_lib_objects ($xlib, $xlib . '_LIBADD');
1127 # Generate support for conditional object inclusion in
1129 &define_variable ($xlib . "_LIBADD", '');
1132 &handle_source_transform ($xlib, $onelib, $obj);
1135 &file_contents_with_transform ('s/\@LIBRARY\@/' . $onelib . '/go;'
1141 # Turn "foo" into "libfoo.a" and include macro definition.
1142 grep (($_ = 'lib' . $_ . '.a') && 0, @liblist);
1144 if (! &variable_defined ('LIBFILES'))
1146 &define_pretty_variable ('LIBFILES ', @libfiles_list);
1151 &define_variable ('AR', '$(LIBTOOL) archive');
1152 &define_variable ('RANLIB', '$(LIBTOOL) ranlib');
1153 &define_variable ('LCOMPILE', ('$(LIBTOOL) compile $(DEFS) $(INCLUDES)'
1154 . ' $(CPPFLAGS) $(CFLAGS)'));
1158 &define_variable ('AR', 'ar');
1159 &define_variable ('RANLIB', '@RANLIB@');
1163 # See if any _SOURCES variable were misspelled.
1166 local ($varname, $primary);
1167 foreach $varname (keys %contents)
1169 foreach $primary ('_SOURCES', '_LIBADD', '_LDADD', '_DEPENDENCIES')
1171 if ($varname =~ /$primary$/ && ! $content_seen{$varname})
1173 &am_line_error ($varname,
1174 "invalid unused variable name: \`$varname'");
1183 # NOTE we no longer automatically clean SCRIPTS, because it is
1184 # useful to sometimes distribute scripts verbatim. This happens
1185 # eg in Automake itself.
1186 &am_install_var ('scripts', 'SCRIPTS',
1187 'bin', 'sbin', 'libexec', 'pkgdata',
1190 # Set $scripts_installed if appropriate. Make sure we only find
1191 # scripts which are actually installed -- this is why we can't
1192 # simply use the return value of am_install_var.
1193 local (%valid) = &am_primary_prefixes ('SCRIPTS', 'bin', 'sbin',
1194 'libexec', 'pkgdata',
1197 foreach $key (keys %valid)
1199 if ($key ne 'noinst'
1201 && &variable_defined ($key . '_SCRIPTS'))
1203 $scripts_installed = 1;
1204 # push (@check, 'check-' . $key . 'SCRIPTS');
1208 if ($scripts_installed)
1210 # If a program is installed, this is required. We only want this
1211 # error to appear once.
1212 &am_conf_error ("AC_ARG_PROGRAM must be used in configure.in")
1213 unless $seen_arg_prog;
1218 # Search a file for a "version.texi" Texinfo include. Return the name
1219 # of the include file if found, or the empty string if not. A
1220 # "version.texi" file is actually any file whose name matches
1222 sub grep_for_vers_texi
1224 local ($filename) = @_;
1226 if (! open (TEXI, $filename))
1228 &am_error ("couldn't open \`$filename': $!");
1231 print "automake: reading $filename\n" if $verbose;
1235 if (/^\@include\s+(vers[^.]*\.texi)\s*$/)
1247 # Handle all Texinfo source.
1250 &am_line_error ('TEXINFOS',
1251 "\`TEXINFOS' is an anachronism; use \`info_TEXINFOS'")
1252 if &variable_defined ('TEXINFOS');
1253 return if (! &variable_defined ('info_TEXINFOS')
1254 && ! &variable_defined ('html_TEXINFOS'));
1256 local (@texis) = &variable_value_as_list ('info_TEXINFOS');
1258 local (@infos_list, @info_deps_list, @dvis_list, @texi_deps);
1259 local ($infobase, $info_cursor);
1263 local ($tc_cursor, @texi_cleans);
1266 foreach $info_cursor (@texis)
1268 ($infobase = $info_cursor) =~ s/\.texi(nfo)?$//;
1270 # If 'version.texi' is referenced by input file, then include
1271 # automatic versioning capability.
1273 = &grep_for_vers_texi ($relative_dir . "/" . $info_cursor);
1276 &am_error ("\`$vtexi', included in \`$info_cursor', also included in \`$versions{$vtexi}'")
1277 if (defined $versions{$vtexi});
1278 $versions{$vtexi} = $info_cursor;
1280 # We number the stamp-vti files. This is doable since the
1281 # actual names don't matter much. We only number starting
1282 # with the second one, so that the common case looks nice.
1283 $vti = 'vti' . ($done ? $done : '');
1284 &push_dist_common ($vtexi, 'stamp-' . $vti);
1285 push (@clean, $vti);
1287 # Only require once.
1288 &require_conf_file_with_line ('info_TEXINFOS', $FOREIGN,
1294 ($conf_pat = $config_aux_dir) =~ s/(\W)/\\$1/g;
1296 &file_contents_with_transform
1297 ('s/\@TEXI\@/' . $info_cursor . '/g; '
1298 . 's/\@VTI\@/' . $vti . '/g; '
1299 . 's/\@VTEXI\@/' . $vtexi . '/g;'
1300 . 's,\@MDDIR\@,' . $conf_pat . ',g;',
1303 &push_phony_cleaners ($vti);
1306 # If user specified file_TEXINFOS, then use that as explicit
1309 push (@texi_deps, $info_cursor);
1310 push (@texi_deps, $vtexi) if $vtexi;
1312 # Canonicalize name first.
1313 ($canonical = $infobase) =~ tr/A-Za-z0-9_/_/c;
1314 if (&variable_defined ($canonical . "_TEXINFOS"))
1316 push (@texi_deps, '$(' . $canonical . '_TEXINFOS)');
1317 &push_dist_common ('$(' . $canonical . '_TEXINFOS)');
1320 $output_rules .= ("\n" . $infobase . ".info: "
1321 . join (' ', @texi_deps)
1322 . "\n" . $infobase . ".dvi: "
1323 . join (' ', @texi_deps)
1326 # FIXME: this distributes too much. How to find out precisely
1327 # which files will be generated by `makeinfo'?
1328 push (@infos_list, $infobase . '.info', $infobase . '.info[-0-9]*');
1329 push (@info_deps_list, $infobase . '.info');
1330 push (@dvis_list, $infobase . '.dvi');
1332 # Generate list of things to clean for this target. We do
1333 # this explicitly because otherwise too many things could be
1334 # removed. In particular the ".log" extension might
1335 # reasonably be used in other contexts by the user.
1336 foreach $tc_cursor ('aux', 'cp', 'cps', 'dvi', 'fn', 'fns',
1337 'ky', 'log', 'pg', 'toc', 'tp', 'vr', 'op')
1339 push (@texi_cleans, $infobase . '.' . $tc_cursor);
1344 $output_vars .= &file_contents ('texi-vars');
1345 $output_rules .= &file_contents ('texinfos');
1346 push (@phony, 'install-info', 'uninstall-info');
1349 $output_rules .= "\nmostlyclean-info:\n";
1350 &pretty_print_rule ("\trm -f", "\t ", @texi_cleans);
1351 $output_rules .= ("\nclean-info:\n\ndistclean-info:\n\n"
1352 . "maintainer-clean-info:\n\t"
1353 . 'rm -f $(INFOS)' . "\n");
1354 &push_phony_cleaners ('info');
1356 push (@suffixes, '.texi', '.texinfo', '.info', '.dvi');
1358 if (! defined $options{'no-installinfo'})
1360 push (@uninstall, 'uninstall-info');
1361 push (@installdirs, '$(infodir)');
1362 unshift (@install_data, 'install-info');
1364 # Make sure documentation is made and installed first. Use
1365 # $(INFO_DEPS), not 'info', because otherwise recursive makes
1366 # get run twice during "make all".
1367 unshift (@all, '$(INFO_DEPS)');
1369 push (@clean, 'info');
1370 push (@info, '$(INFO_DEPS)');
1371 push (@dvi, '$(DVIS)');
1373 &define_variable ("INFOS", join (' ', @infos_list));
1374 &define_variable ("INFO_DEPS", join (' ', @info_deps_list));
1375 &define_variable ("DVIS", join (' ', @dvis_list));
1376 # This next isn't strictly needed now -- the places that look here
1377 # could easily be changed to look in info_TEXINFOS. But this is
1378 # probably better, in case noinst_TEXINFOS is ever supported.
1379 &define_variable ("TEXINFOS", $contents{'info_TEXINFOS'});
1381 # Do some error checking.
1382 &require_file_with_line ('info_TEXINFOS', $FOREIGN, 'texinfo.tex');
1385 # Handle any man pages.
1386 sub handle_man_pages
1388 &am_line_error ('MANS', "\`MANS' is an anachronism; use \`man_MANS'")
1389 if &variable_defined ('MANS');
1390 return if ! &variable_defined ('man_MANS');
1392 # We generate the manpage install code by hand to avoid the use of
1393 # basename in the generated Makefile.
1394 local (@mans) = &variable_value_as_list ('man_MANS');
1395 local (%sections, %inames, %mbases, %secmap, %fullsecmap);
1399 # FIXME: statement without effect:
1400 /^(.*)\.([0-9])([a-z]*)$/;
1405 $fullsecmap{$i} = $2 . $3;
1409 # We don't really need this, but we use it in case we ever want to
1410 # support noinst_MANS.
1411 &define_variable ("MANS", $contents{'man_MANS'});
1413 # Generate list of install dirs.
1414 $output_rules .= "install-man: \$(MANS)\n";
1415 $output_rules .= "\t\$(NORMAL_INSTALL)\n";
1416 foreach (keys %sections)
1418 push (@installdirs, '$(mandir)/man' . $_)
1419 unless defined $options{'no-installman'};
1420 $output_rules .= ("\t" . '$(mkinstalldirs) $(mandir)/man'
1423 push (@phony, 'install-man');
1425 # Generate install target.
1427 foreach $key (keys %inames)
1429 $_ = $install_man_format;
1430 s/\@SECTION\@/$secmap{$key}/g;
1431 s/\@MAN\@/$inames{$key}/g;
1432 s/\@FULLSECT\@/$fullsecmap{$key}/g;
1433 s/\@MANBASE\@/$mbases{$key}/g;
1434 $output_rules .= $_;
1436 $output_rules .= "\n";
1438 $output_rules .= "uninstall-man:\n";
1439 foreach $key (keys %inames)
1441 $_ = $uninstall_man_format;
1442 s/\@SECTION\@/$secmap{$key}/g;
1443 s/\@MAN\@/$inames{$key}/g;
1444 s/\@FULLSECT\@/$fullsecmap{$key}/g;
1445 s/\@MANBASE\@/$mbases{$key}/g;
1446 $output_rules .= $_;
1448 $output_rules .= "\n";
1449 push (@phony, 'uninstall-man');
1451 $output_vars .= &file_contents ('mans-vars');
1453 if (! defined $options{'no-installman'})
1455 push (@install_data, 'install-man');
1456 push (@uninstall, 'uninstall-man');
1457 push (@all, '$(MANS)');
1461 # Handle DATA variables.
1464 &am_install_var ('data', 'DATA', 'data', 'sysconf',
1465 'sharedstate', 'localstate', 'pkgdata',
1472 local ($tagging) = 0;
1474 push (@phony, 'tags');
1475 if (&variable_defined ('SUBDIRS'))
1477 $output_rules .= &file_contents ('tags');
1478 push (@phony, 'tags-recursive');
1481 elsif ($dir_holds_sources
1482 || $dir_holds_headers
1483 || &variable_defined ('ETAGS_ARGS'))
1485 $output_rules .= &file_contents ('tags-subd');
1488 elsif (&variable_defined ('TAGS_DEPENDENCIES'))
1490 &am_line_error ('TAGS_DEPENDENCIES',
1491 "doesn't make sense to define \`TAGS_DEPENDENCIES' without sources or \`ETAGS_ARGS'");
1496 $output_rules .= &file_contents ('tags-clean');
1497 push (@clean, 'tags');
1498 &push_phony_cleaners ('tags');
1499 &examine_variable ('TAGS_DEPENDENCIES');
1503 # Every Makefile must define some sort of TAGS rule.
1504 # Otherwise, it would be possible for a top-level "make TAGS"
1505 # to fail because some subdirectory failed.
1506 $output_rules .= "tags: TAGS\nTAGS:\n\n";
1510 # Worker for handle_dist.
1511 sub handle_dist_worker
1513 $output_rules .= 'distdir: $(DEP_DISTFILES)' . "\n";
1515 # Initialization; only at top level.
1516 if ($relative_dir eq '.')
1518 if ($strictness >= $GNITS)
1520 # For Gnits users, this is pretty handy. Look at 15 lines
1521 # in case some explanatory text is desirable.
1522 $output_rules .= ' @if sed 15q $(srcdir)/NEWS | fgrep -e "$(VERSION)" > /dev/null; then :; else \\
1523 echo "NEWS not updated; not releasing" 1>&2; \\
1531 # Create dist directory.
1534 -chmod 755 $(distdir)
1537 # Only run automake in `dist' target if --include-deps not
1538 # specified. That way the recipient of a distribution can run
1539 # "make dist" and not need Automake.
1540 if ($cmdline_use_dependencies)
1544 # We need an absolute path for --output-dir. Thus the
1546 ' here=`pwd`; distdir=`cd $(distdir) && pwd` \\
1548 && automake --include-deps --build-dir=$$here --srcdir-name=$(srcdir) --output-dir=$$distdir --strictness='
1549 # Set strictness of output.
1550 . $strictness_name . "\n"
1555 # Scan EXTRA_DIST to see if we need to distribute anything from a
1556 # subdir. If so, add it to the list. I didn't want to do this
1557 # originally, but there were so many requests that I finally
1560 if (&variable_defined ('EXTRA_DIST'))
1562 foreach (&variable_value_as_list ('EXTRA_DIST'))
1565 next unless s,/+[^/]+$,,;
1566 push (@dist_dirs, $_)
1570 if (&variable_defined ('EXTRA_DIST_DIRS'))
1572 push (@dist_dirs, &variable_value_as_list ('EXTRA_DIST_DIRS'));
1576 # Prepend $(distdir) to each directory given. Doing it via a
1577 # hash lets us ensure that each directory is used only once.
1579 grep ($dhash{'$(distdir)/' . _} = 1, @dist_dirs);
1580 $output_rules .= "\t";
1581 &pretty_print_rule ('$(mkinstalldirs)', "\t ", sort keys %dhash);
1584 # In loop, test for file existence because sometimes a file gets
1585 # included in DISTFILES twice. For example this happens when a
1586 # single source file is used in building more than one program.
1587 # Also, there are situations in which "ln" can fail. For instance
1588 # a file to distribute could actually be a cross-filesystem
1589 # symlink -- this can easily happen if "gettextize" was run on the
1590 # distribution. Note that DISTFILES can contain a wildcard (for
1591 # info files, sigh), so we must use the echo trick.
1592 $output_rules .= ' @for file in `cd $(srcdir) && echo $(DISTFILES)`; do \\
1593 test -f $(distdir)/$$file \\
1594 || ln $(srcdir)/$$file $(distdir)/$$file 2> /dev/null \\
1595 || cp -p $(srcdir)/$$file $(distdir)/$$file; \\
1599 # If we have SUBDIRS, create all dist subdirectories and do
1601 if (&variable_defined ('SUBDIRS'))
1603 # Test for directory existence here because previous automake
1604 # invocation might have created some directories. Note that
1605 # we explicitly set distdir for the subdir make; that lets us
1606 # mix-n-match many automake-using packages into one large
1607 # package, and have "dist" at the top level do the right
1609 $output_rules .= ' for subdir in $(SUBDIRS); do \\
1610 test -d $(distdir)/$$subdir \\
1611 || mkdir $(distdir)/$$subdir \\
1613 chmod 755 $(distdir)/$$subdir; \\
1614 (cd $$subdir && $(MAKE) distdir=../$(distdir)/$$subdir distdir) \\
1620 # If the target `dist-hook' exists, run it now. This allows
1621 # users to do random weird things to the distribution before it is
1623 if (defined $contents{'dist-hook'})
1625 $output_rules .= "\t\$(MAKE) dist-hook\n";
1628 push (@phony, 'distdir');
1631 # Handle 'dist' target.
1634 # Set up maint_charset.
1635 $local_maint_charset = $contents{'MAINT_CHARSET'}
1636 if &variable_defined ('MAINT_CHARSET');
1637 $maint_charset = $local_maint_charset
1638 if $relative_dir eq '.';
1640 if (&variable_defined ('DIST_CHARSET'))
1642 &am_line_error ('DIST_CHARSET',
1643 "DIST_CHARSET defined but no MAINT_CHARSET defined")
1644 if ! $local_maint_charset;
1645 if ($relative_dir eq '.')
1647 $dist_charset = $contents{'DIST_CHARSET'}
1651 &am_line_error ('DIST_CHARSET',
1652 "DIST_CHARSET can only be defined at top level");
1656 # Look for common files that should be included in distribution.
1658 foreach $cfile (@common_files)
1660 if (-f ($relative_dir . "/" . $cfile))
1662 &push_dist_common ($cfile);
1666 # Keys of %dist_common are names of files to distributed. We put
1667 # README first because it then becomes easier to make a
1668 # Usenet-compliant shar file (in these, README must be first).
1669 # FIXME: do more ordering of files here.
1671 if (defined $dist_common{'README'})
1673 push (@coms, 'README');
1674 undef $dist_common{'README'};
1676 push (@coms, sort keys %dist_common);
1678 &define_pretty_variable ("DIST_COMMON", @coms);
1679 $output_vars .= "\n";
1682 $output_vars .= &file_contents ('dist-vars');
1684 # Put these things in rules section so it is easier for whoever
1685 # reads Makefile.in.
1686 if (! &variable_defined ('distdir'))
1688 if ($relative_dir eq '.')
1690 $output_rules .= "\n" . 'distdir = $(PACKAGE)-$(VERSION)' . "\n";
1694 $output_rules .= ("\n"
1695 . 'distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)'
1699 if ($relative_dir ne '.')
1701 $output_rules .= "\nsubdir = " . $relative_dir . "\n";
1704 # Generate 'dist' target, and maybe dist-shar / dist-zip / dist-tarZ.
1705 if ($relative_dir eq '.')
1707 # Rule to check whether a distribution is viable.
1708 $output_rules .= ('# This target untars the dist file and tries a VPATH configuration. Then
1709 # it guarantees that the distribution is self-contained by making another
1713 $(TAR) zxf $(distdir).tar.gz
1714 mkdir $(distdir)/=build
1715 mkdir $(distdir)/=inst
1716 dc_install_base=`cd $(distdir)/=inst && pwd`; \\'
1717 . (defined $contents{'distcheck-hook'}
1718 ? "\t\$(MAKE) distcheck-hook"
1721 cd $(distdir)/=build \\
1724 . ($seen_gettext ? '--with-included-gettext ' : '')
1725 . '--srcdir=.. --prefix=$$dc_install_base \\
1729 && $(MAKE) install \\
1730 && $(MAKE) installcheck \\
1733 @echo "========================"; \\
1734 echo "$(distdir).tar.gz is ready for distribution"; \\
1735 echo "========================"
1738 local ($dist_all) = ('dist-all: distdir' . "\n"
1741 foreach $curs ('dist', 'dist-shar', 'dist-zip', 'dist-tarZ')
1743 if (defined $options{$curs} || $curs eq 'dist')
1745 $output_rules .= ($curs . ': distdir' . "\n"
1749 $dist_all .= $dist{$curs};
1752 $output_rules .= $dist_all . $dist_trailer;
1755 # Generate distdir target.
1756 &handle_dist_worker;
1759 # Scan a single dependency file and rewrite the dependencies as
1760 # appropriate. Essentially this means:
1761 # * Clean out absolute dependencies which are not desirable.
1762 # * Rewrite other dependencies to be relative to $(top_srcdir).
1763 sub scan_dependency_file
1765 local ($depfile) = @_;
1767 if (! open (DEP_FILE, $depfile))
1769 &am_error ("couldn't open \`$depfile': $!");
1772 print "automake: reading $depfile\n" if $verbose;
1774 local ($first_line) = 1;
1775 local ($last_line) = 0;
1776 local ($target, @dependencies);
1777 local ($one_dep, $xform);
1779 local ($srcdir_rx, $fixup_rx);
1780 # If the top srcdir is absolute, then the current directory is
1781 # just relative_dir. But if the top srcdir is relative, then we
1782 # need to add some dots first. The same holds when matching
1784 if ($srcdir_name =~ /^\//)
1786 ($fixup_rx = $srcdir_name . '/' . $relative_dir . '/')
1788 ($srcdir_rx = $srcdir_name) =~ s/(\W)/\\$1/g;
1792 ($fixup_rx = ($srcdir_name . '/' . $top_builddir . '/'
1793 . $relative_dir . '/')) =~ s/(\W)/\\$1/g;
1794 ($srcdir_rx = ($srcdir_name . '/' . $top_builddir))
1802 # If LAST_LINE set then we've already seen what we thought
1803 # was the last line.
1806 next if (/$WHITE_PATTERN/o);
1810 # No trailing "\" means this should be the last line.
1816 if (! /^([^:]+:)(.+)$/)
1819 &am_error ("\`$depfile' has incorrect format");
1830 foreach $one_dep (split (' ', $_))
1832 if ($one_dep =~ /^$fixup_rx/)
1834 # The dependency points to the current directory in
1836 ($xform = $one_dep) =~ s/^$fixup_rx//;
1837 push (@dependencies, $xform);
1839 elsif ($one_dep =~ /^$srcdir_rx\//)
1841 # The dependency is in some other directory in the package.
1842 ($xform = $one_dep) =~ s/^$srcdir_rx/$top_builddir/;
1843 push (@dependencies, $xform);
1845 elsif ($one_dep =~ /^\//)
1847 # Absolute path; ignore.
1851 # Anything else is assumed to be correct.
1852 push (@dependencies, $one_dep);
1857 &pretty_print_rule ($target, "\t", @dependencies);
1862 # Handle auto-dependency code.
1863 sub handle_dependencies
1865 if ($use_dependencies)
1867 # Include GNU-make-specific auto-dep code.
1868 if ($dir_holds_sources)
1870 &define_pretty_variable ('DEP_FILES', sort keys %dep_files);
1871 $output_rules .= &file_contents ('depend');
1872 push (@clean, 'depend');
1873 &push_phony_cleaners ('depend');
1875 &file_contents_with_transform ('s/\@EXT\@/.c/g;'
1876 . 's/\@MKDEP\@/MKDEP/g',
1879 local ($need_cxx) = 0;
1880 foreach $ext (keys %cxx_extensions)
1883 &file_contents_with_transform ('s/\@EXT\@/' . $ext .'/g;'
1884 . 's/\@MKDEP\@/CXXMKDEP/g',
1890 &define_variable ('CXXMKDEP', '$(CXX) -MM $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CXXFLAGS)');
1896 # FIXME: consider requiring --build-dir here. What about case
1897 # where this is done via an option?
1899 # Include any auto-generated deps that are present. Note that
1900 # $build_directory ends in a "/".
1901 if (-d ($build_directory . $relative_dir . "/.deps")
1902 && -f ($build_directory . $relative_dir . "/.deps/.P"))
1905 local ($gpat) = $build_directory . $relative_dir . "/.deps/*.P";
1907 foreach $depfile (<${gpat}>)
1909 &scan_dependency_file ($depfile);
1912 $output_rules .= "\n";
1917 # Handle subdirectories.
1920 return if ! &variable_defined ('SUBDIRS');
1922 # Make sure each directory mentioned in SUBDIRS actually exists.
1924 foreach $dir (&variable_value_as_list ('SUBDIRS'))
1926 # Skip directories substituted by configure.
1927 next if $dir =~ /^\@.*\@$/;
1928 &am_line_error ('SUBDIRS',
1929 "required directory $relative_dir/$dir does not exist")
1930 if ! -d $relative_dir . '/' . $dir;
1933 $output_rules .= &file_contents ('subdirs');
1935 # Push a bunch of phony targets.
1937 foreach $phonies ('-data', '-exec', 'dirs')
1939 push (@phony, 'install' . $phonies . '-recursive');
1940 push (@phony, 'uninstall' . $phonies . '-recursive');
1942 foreach $phonies ('all', 'check', 'installcheck', 'info', 'dvi')
1944 push (@phony, $phonies . '-recursive');
1946 &push_phony_cleaners ('recursive');
1948 push (@check, "check-recursive");
1949 push (@installcheck, "installcheck-recursive");
1950 push (@info, "info-recursive");
1951 push (@dvi, "dvi-recursive");
1953 $recursive_install = 1;
1956 # Handle aclocal.m4.
1957 sub handle_aclocal_m4
1959 local ($regen_aclocal) = 0;
1960 if (-f 'aclocal.m4')
1962 &define_variable ("ACLOCAL", "aclocal.m4");
1963 &push_dist_common ('aclocal.m4');
1965 if (open (ACLOCAL, '< aclocal.m4'))
1971 if ($line =~ 'generated automatically by aclocal')
1978 local ($acinclude) = 0;
1979 if (-f 'acinclude.m4')
1985 # Note that it might be possible that aclocal.m4 doesn't exist but
1986 # should be auto-generated. This case probably isn't very
1990 $output_rules .= ("aclocal.m4: "
1991 . ($seen_maint_mode ? "\@MAINT\@" : "")
1993 . ($acinclude ? ' acinclude.m4' : '')
1995 . 'cd $(srcdir) && aclocal'
2000 # Handle remaking and configure stuff.
2001 sub handle_configure
2003 # If SUBDIRS defined, require AC_PROG_MAKE_SET.
2004 &am_line_error ('SUBDIRS', "AC_PROG_MAKE_SET must be used in configure.in")
2005 if &variable_defined ('SUBDIRS') && ! $seen_make_set;
2007 local ($top_reldir);
2008 if ($relative_dir ne '.')
2011 $output_rules .= &file_contents ('remake-subd');
2012 $top_reldir = '../';
2017 $output_rules .= &file_contents_with_transform ('s/\@STRICTNESS\@/'
2021 &examine_variable ('CONFIGURE_DEPENDENCIES');
2025 # If we have a configure header, require it.
2026 if ($config_header && $relative_dir eq &dirname ($config_header))
2028 local ($ch_sans_dir) = &basename ($config_header);
2029 local ($cn_sans_dir) = &basename ($config_name);
2031 &require_file_with_conf_line ($config_header_line,
2032 $FOREIGN, $ch_sans_dir);
2034 # Header defined and in this directory.
2035 if (-f $relative_dir . '/acconfig.h')
2037 &define_variable ("ACCONFIG", "acconfig.h");
2038 &push_dist_common ('acconfig.h');
2040 if (-f $config_name . '.top')
2042 &define_variable ("CONFIG_TOP", "${cn_sans_dir}.top");
2043 &push_dist_common ($cn_sans_dir . '.top');
2045 if (-f $config_name . '.bot')
2047 &define_variable ("CONFIG_BOT", "${cn_sans_dir}.bot");
2048 &push_dist_common ($cn_sans_dir . '.bot');
2051 &touch ($relative_dir . '/stamp-h.in');
2052 &require_file_with_conf_line ($config_header_line, $FOREIGN,
2055 $output_rules .= &file_contents ('remake-hdr');
2056 push (@clean, 'hdr');
2057 &push_phony_cleaners ('hdr');
2058 &define_variable ("CONFIG_HEADER_IN", "${ch_sans_dir}");
2061 # Set location of mkinstalldirs.
2062 if ($config_aux_dir ne '.' && $config_aux_dir ne '')
2064 &define_variable ('mkinstalldirs', ('$(SHELL) ' . $config_aux_dir
2065 . '/mkinstalldirs'));
2069 &define_variable ('mkinstalldirs',
2070 '$(SHELL) $(top_srcdir)/mkinstalldirs');
2073 &am_line_error ('CONFIG_HEADER',
2074 "\`CONFIG_HEADER' is an anachronism; now determined from \`configure.in'")
2075 if &variable_defined ('CONFIG_HEADER');
2079 # Generate CONFIG_HEADER define.
2080 if ($relative_dir eq &dirname ($config_name))
2082 &define_variable ("CONFIG_HEADER", &basename ($config_name));
2086 &define_variable ("CONFIG_HEADER",
2087 "${top_builddir}/${config_name}");
2091 # Now look for other files in this directory which must be remade
2092 # by config.status, and generate rules for them.
2093 local (@actual_other_files) = ();
2094 local ($file, $local, $input);
2095 foreach $file (@other_input_files)
2097 # Skip files not in this directory, any Makefile, and the
2098 # config header. These last two must be handled specially.
2099 next unless &dirname ($file) eq $relative_dir;
2100 next if $file eq $top_builddir . '/' . $config_name;
2101 ($local = $file) =~ s/^.*\///;
2102 next if $local eq 'Makefile';
2104 if ($local =~ /^(.*):(.*)$/)
2106 # This is the ":" syntax of AC_OUTPUT.
2113 $input = $local . '.in';
2115 # FIXME: when using autoconf ":" syntax, should we set CONFIG_FILES
2117 $output_rules .= ($local . ': '
2118 . '$(top_builddir)/config.status ' . $input . "\n"
2120 . 'cd $(top_builddir) && CONFIG_FILES='
2121 . ($relative_dir eq '.' ? '' : '$(subdir)/')
2122 . '$@ CONFIG_HEADERS= ./config.status'
2124 push (@actual_other_files, $local);
2126 &require_file_with_conf_line ($ac_output_line, $FOREIGN,
2130 # These files get removed by "make clean".
2131 &define_pretty_variable ('CONFIG_CLEAN_FILES', @actual_other_files);
2137 $dir_holds_headers = &am_install_var ('header', 'HEADERS', 'include',
2138 'oldinclude', 'pkginclude',
2144 return if ! $seen_gettext || $relative_dir ne '.';
2146 if (! &variable_defined ('SUBDIRS'))
2149 ("ud_GNU_GETTEXT in configure.in but SUBDIRS not defined");
2153 &require_file_with_conf_line ($ac_gettext_line, $FOREIGN, 'ABOUT-NLS')
2156 if (&variable_defined ('SUBDIRS'))
2160 "ud_GNU_GETTEXT in configure.in but \`po' not in SUBDIRS")
2161 if $contents{'SUBDIRS'} !~ /\bpo\b/;
2164 "ud_GNU_GETTEXT in configure.in but \`intl' not in SUBDIRS")
2165 if $contents{'SUBDIRS'} !~ /\bintl\b/;
2168 # Ensure that each language in ALL_LINGUAS has a .po file, and
2169 # each po file is mentioned in ALL_LINGUAS.
2172 local (%linguas) = ();
2173 grep ($linguas{$_} = 1, split (' ', $all_linguas));
2180 &am_line_error ($all_linguas_line,
2181 ("po/$_.po exists but \`$_' not in \`ALL_LINGUAS'"))
2185 foreach (keys %linguas)
2187 &am_line_error ($all_linguas_line,
2188 "$_ in \`ALL_LINGUAS' but po/$_.po does not exist")
2194 &am_error ("ud_GNU_GETTEXT in configure.in but \`ALL_LINGUAS' not defined");
2198 # Handle footer elements.
2201 if ($contents{'SOURCES'})
2203 # NOTE don't use define_pretty_variable here, because
2204 # $contents{...} is already defined.
2205 $output_vars .= 'SOURCES = ' . $contents{'SOURCES'} . "\n";
2207 if ($contents{'OBJECTS'})
2209 # NOTE don't use define_pretty_variable here, because
2210 # $contents{...} is already defined.
2211 $output_vars .= 'OBJECTS = ' . $contents{'OBJECTS'} . "\n";
2213 if ($contents{'SOURCES'} || $contents{'OBJECTS'})
2215 $output_vars .= "\n";
2218 if (defined $contents{'SUFFIXES'})
2220 # Push actual suffixes, and not $(SUFFIXES). Some versions of
2221 # make do not like variable substitutions on the .SUFFIXES
2223 push (@suffixes, split (' ', $contents{'SUFFIXES'}));
2226 $output_trailer .= ".SUFFIXES:\n";
2229 $output_trailer .= ".SUFFIXES: " . join (' ', @suffixes) . "\n";
2231 $output_trailer .= &file_contents ('footer');
2234 # Deal with installdirs target.
2235 sub handle_installdirs
2237 # GNU Makefile standards recommend this.
2238 $output_rules .= ("installdirs:"
2239 . ($recursive_install
2240 ? " installdirs-recursive\n"
2242 push (@phony, 'installdirs');
2245 &pretty_print_rule ("\t" . '$(mkinstalldirs) ', "\t\t",
2248 $output_rules .= "\n";
2251 # There are several targets which need to be merged. This is because
2252 # their complete definition is compiled from many parts. Note that we
2253 # avoid double colon rules, otherwise we'd use them instead.
2254 sub handle_merge_targets
2256 # There are a few install-related variables that you should not define.
2258 foreach $var ('PRE_INSTALL', 'POST_INSTALL', 'NORMAL_INSTALL')
2260 if (&variable_defined ($var))
2262 &am_line_error ($var, "\`$var' should not be defined");
2266 push (@all, 'Makefile');
2267 push (@all, $config_name)
2268 if $config_name && &dirname ($config_name) eq $relative_dir;
2270 &do_one_merge_target ('info', @info);
2271 &do_one_merge_target ('dvi', @dvi);
2272 &do_one_merge_target ('check', @check);
2273 &do_one_merge_target ('installcheck', @installcheck);
2275 # Handle the various install targets specially. We do this so
2276 # that (eg) "make install-exec" will run "install-exec-recursive"
2277 # if required, but "make install" won't run it twice. Step one is
2278 # to see if the user specified local versions of any of the
2279 # targets we handle. "all" is treated as one of these since
2280 # "install" can run it.
2281 push (@install_exec, 'install-exec-local')
2282 if defined $contents{'install-exec-local'};
2283 push (@install_data, 'install-data-local')
2284 if defined $contents{'install-data-local'};
2285 push (@uninstall, 'uninstall-local')
2286 if defined $contents{'uninstall-local'};
2288 foreach $utarg ('uninstall-data-local', 'uninstall-data-hook',
2289 'uninstall-exec-local', 'uninstall-exec-hook')
2291 if (defined $contents{$utarg})
2294 ($x = $utarg) =~ s/(data|exec)-//;
2295 &am_line_error ($utarg, "use \`$x', not \`$utarg'");
2298 push (@all, 'all-local')
2299 if defined $contents{'all-local'};
2301 if (defined $contents{'install-local'})
2303 &am_line_error ('install-local',
2304 "use \`install-data' or \`install-exec', not \`install'");
2307 # Step two: if we are doing recursive makes, write out the
2308 # appropriate rules.
2310 if ($recursive_install)
2312 push (@install, 'install-recursive');
2316 local (@hackall) = ();
2317 if ($config_name && &dirname ($config_name) eq $relative_dir)
2320 # This is kind of a hack, but I couldn't see a better
2321 # way to handle it. In this particular case, we need
2322 # to make sure config.h is built before we recurse.
2323 # We can't do this by changing the order of
2324 # dependencies to the "all" because that breaks when
2325 # using parallel makes. Instead we handle things
2327 $output_rules .= ('all-recursive-hack: $(CONFIG_HEADER)'
2328 . "\n\t" . '$(MAKE) all-recursive'
2330 push (@hackall, 'all-recursive-hack');
2331 push (@phony, 'all-recursive-hack');
2335 push (@hackall, 'all-recursive');
2338 $output_rules .= ('all-am: '
2342 push (@all, 'all-am');
2343 push (@phony, 'all-am');
2347 @all = ('all-recursive');
2349 # Must always generate `all-am' target, so it can be
2350 # referred to elsewhere.
2351 $output_rules .= "all-am:\n";
2355 $output_rules .= ('install-exec-am: '
2356 . join (' ', @install_exec)
2358 @install_exec = ('install-exec-recursive', 'install-exec-am');
2359 push (@install, 'install-exec-am');
2360 push (@phony, 'install-exec-am');
2364 @install_exec = ('install-exec-recursive');
2368 $output_rules .= ('install-data-am: '
2369 . join (' ', @install_data)
2371 @install_data = ('install-data-recursive', 'install-data-am');
2372 push (@install, 'install-data-am');
2373 push (@phony, 'install-data-am');
2377 @install_data = ('install-data-recursive');
2381 $output_rules .= ('uninstall-am: '
2382 . join (' ', @uninstall)
2384 @uninstall = ('uninstall-recursive', 'uninstall-am');
2385 push (@phony, 'uninstall-am');
2389 @uninstall = ('uninstall-recursive');
2393 # Step three: print definitions users can use. Code below knows
2394 # that install-exec is done before install-data, beware.
2395 $output_rules .= ("install-exec: "
2396 . join (' ', @install_exec)
2398 $output_rules .= "\t\$(NORMAL_INSTALL)\n";
2399 if (defined $contents{'install-exec-hook'})
2401 $output_rules .= "\t" . '$(MAKE) install-exec-hook' . "\n";
2403 $output_rules .= "\n";
2404 push (@install, 'install-exec') if !$recursive_install;
2405 push (@phony, 'install-exec');
2407 $output_rules .= ("install-data: "
2408 . join (' ', @install_data)
2410 $output_rules .= "\t\$(NORMAL_INSTALL)\n";
2411 if (defined $contents{'install-data-hook'})
2413 $output_rules .= "\t" . '$(MAKE) install-data-hook' . "\n";
2415 $output_rules .= "\n";
2416 push (@install, 'install-data') if !$recursive_install;
2417 push (@phony, 'install-data');
2419 # If no dependencies for 'install', add 'all'. Why? That way
2420 # "make install" at top level of distclean'd distribution won't
2421 # fail because stuff in 'lib' fails to build.
2422 if (! @install || (scalar (@install) == 2
2423 && $install[0] eq 'install-exec'
2424 && $install[1] eq 'install-data'))
2426 push (@install, 'all');
2428 $output_rules .= ('install: '
2429 . join (' ', @install)
2430 # Use "@:" as empty command so nothing prints.
2434 . join (' ', @uninstall)
2436 push (@phony, 'install', 'uninstall');
2438 $output_rules .= ('all: '
2441 push (@phony, 'all');
2443 # Generate the new 'install-strip' target.
2444 $output_rules .= ("install-strip:\n\t"
2445 . '$(MAKE) INSTALL_PROGRAM=\'$(INSTALL_PROGRAM) -s\' install'
2449 # Helper for handle_merge_targets.
2450 sub do_one_merge_target
2452 local ($name, @values) = @_;
2454 if (defined $contents{$name . '-local'})
2456 # User defined local form of target. So include it.
2457 push (@values, $name . '-local');
2458 push (@phony, $name . '-local');
2462 if ($name eq 'check')
2464 if (! &variable_defined ('SUBDIRS'))
2466 # 'check' must depend on `all', but not when doing
2468 unshift (@values, 'all');
2472 # When subdirs are used, do the `all' build and then do
2473 # all the recursive stuff. Actually use `all-am' because
2474 # it doesn't recurse; we rely on the check target in the
2475 # subdirs to do the required builds there.
2476 $output_rules .= "check: all-am\n";
2477 &pretty_print_rule ("\t\$(MAKE)", "\t ", @values);
2482 &pretty_print_rule ($name . ":", "\t\t", @values)
2484 push (@phony, $name);
2487 # Handle all 'clean' targets.
2490 push (@clean, 'generic');
2491 $output_rules .= &file_contents ('clean');
2492 &push_phony_cleaners ('generic');
2494 local ($target) = $recursive_install ? 'clean-am' : 'clean';
2495 &do_one_clean_target ($target, 'mostly', '', @clean);
2496 &do_one_clean_target ($target, '', 'mostly', @clean);
2497 &do_one_clean_target ($target, 'dist', '', @clean);
2498 &do_one_clean_target ($target, 'maintainer-', 'dist', @clean);
2500 push (@phony, 'clean', 'mostlyclean', 'distclean', 'maintainer-clean');
2503 if ($recursive_install)
2505 @deps = ('am', 'recursive');
2506 &do_one_clean_target ('', 'mostly', '', @deps);
2507 &do_one_clean_target ('', '', '', @deps);
2508 &do_one_clean_target ('', 'dist', '', @deps);
2509 &do_one_clean_target ('', 'maintainer-', '', @deps);
2513 # Helper for handle_clean.
2514 sub do_one_clean_target
2516 local ($target, $name, $last_name, @deps) = @_;
2518 # Special case: if target not passed, then don't generate
2519 # dependency on next "lower" clean target (eg no
2520 # clean<-mostlyclean derivation). In this case the target is
2521 # implicitly known to be 'clean'.
2522 local ($flag) = $target;
2523 $target = 'clean' if ! $flag;
2525 grep (($_ = $name . 'clean-' . $_) && 0, @deps);
2528 if ($last_name || $name ne 'mostly')
2530 push (@deps, $last_name . $target . " ");
2533 # FIXME: not sure if I like the tabs here.
2534 &pretty_print_rule ($name . $target . ": ", "\t\t", @deps);
2536 # FIXME: shouldn't we really print these messages before running
2538 if ($name . $target eq 'maintainer-clean')
2540 # Print a special warning.
2542 ("\t\@echo \"This command is intended for maintainers to use;\"\n"
2543 . "\t\@echo \"it deletes files that may require special "
2544 . "tools to rebuild.\"\n");
2546 $output_rules .= "\trm -f config.status\n"
2547 if $relative_dir eq '.';
2549 elsif ($name . $target eq 'distclean')
2551 $output_rules .= "\trm -f config.status\n";
2553 $output_rules .= "\n";
2556 # Handle .PHONY target.
2559 &pretty_print_rule ('.PHONY:', "", @phony);
2560 $output_rules .= "\n";
2563 # Handle TESTS variable and other checks.
2566 if (defined $options{'dejagnu'})
2568 push (@check, 'check-DEJAGNU');
2569 push (@phony, 'check-DEJAGNU');
2570 $output_rules .= &file_contents ('dejagnu') . "\n";
2571 # Note that in the rule we don't directly generate site.exp to
2572 # avoid the possibility of a corrupted site.exp if make is
2573 # interrupted. Jim Meyering has some useful text on this
2575 $output_rules .= ("site.exp: Makefile\n"
2576 . "\t\@echo 'Making a new site.exp file...'\n"
2577 . "\t-\@rm -f site.bak\n"
2578 . "\t\@echo '## these variables are automatically generated by make ##' > \$\@-t\n"
2579 . "\t\@echo '# Do not edit here. If you wish to override these values' >> \$\@-t\n"
2580 . "\t\@echo '# edit the last section' >> \$\@-t\n"
2581 . "\t\@echo 'set tool \$(DEJATOOL)' >> \$\@-t\n"
2582 . "\t\@echo 'set srcdir \$(srcdir)' >> \$\@-t\n"
2583 . "\t\@echo 'set objdir' \`pwd\` >> \$\@-t\n");
2585 # Extra stuff for AC_CANONICAL_*
2586 local (@whatlist) = ();
2587 if ($seen_canonical)
2589 push (@whatlist, 'host')
2592 # Extra stuff only for AC_CANONICAL_SYSTEM.
2593 if ($seen_canonical == $AC_CANONICAL_SYSTEM)
2595 push (@whatlist, 'target', 'build');
2599 foreach $c1 (@whatlist)
2601 foreach $c2 ('alias', 'triplet')
2603 $output_rules .= "\t\@echo 'set ${c1}_${c2} \$(${c1}_${c2})' >> \$\@-t\n";
2607 $output_rules .= ("\t\@echo '## All variables above are generated by configure. Do Not Edit ##' >> \$\@-t\n"
2608 . "\t-\@sed '1,/^## All variables above are.*##/ d' site.bak >> \$\@-t\n"
2609 . "\t-\@mv site.exp site.bak\n"
2610 . "\t\@mv \$\@-t site.exp\n");
2615 foreach $c ('DEJATOOL', 'RUNTEST', 'RUNTESTFLAGS')
2617 if (&variable_defined ($c))
2619 &am_line_error ($c, "\`$c' defined but \`dejagnu' not in \`AUTOMAKE_OPTIONS'");
2624 if (&variable_defined ('TESTS'))
2626 push (@check, 'check-TESTS');
2627 push (@phony, 'check-TESTS');
2628 # FIXME: use $(SHELL) here? That is what Ulrich suggests.
2629 # Maybe a new macro, $(TEST_SHELL), a la $(CONFIG_SHELL)? For
2630 # now we just execute the file directly; this allows test
2631 # files which are compiled -- a possibly useful feature.
2632 $output_rules .= 'check-TESTS: $(TESTS)
2633 @failed=0; all=0; \\
2634 srcdir=$(srcdir); export srcdir; \\
2635 for tst in $(TESTS); do \\
2636 all=`expr $$all + 1`; \\
2637 if test -f $$tst; then dir=.; \\
2638 else dir="$(srcdir)"; fi; \\
2639 if $(TESTS_ENVIRONMENT) $$dir/$$tst; then \\
2640 echo "PASS: $$tst"; \\
2642 failed=`expr $$failed + 1`; \\
2643 echo "FAIL: $$tst"; \\
2646 if test "$$failed" -eq 0; then \\
2647 echo "========================"; \\
2648 echo "All $$all tests passed"; \\
2649 echo "========================"; \\
2651 echo "$$failed of $$all tests failed"; \\
2657 # Handle Emacs Lisp.
2658 sub handle_emacs_lisp
2660 local (@elfiles) = &am_install_var ('lisp', 'LISP', 'lisp', 'noinst');
2665 &define_variable ("lispdir", "\@lispdir\@");
2666 &define_variable ("EMACS", "\@EMACS\@");
2667 $output_rules .= (".el.elc:\n"
2668 . "\t\@echo 'WARNING: Warnings can be ignored. :-)'\n"
2669 . "\t\EMACS=$(EMACS) $(SHELL) \$(srcdir)/elisp-comp \$<\n");
2670 push (@suffixes, '.el', '.elc');
2672 # Generate .elc files.
2673 grep ($_ .= 'c', @elfiles);
2674 &define_pretty_variable ('ELCFILES', @elfiles);
2676 push (@clean, 'lisp');
2677 &push_phony_cleaners ('lisp');
2680 if (&variable_defined ('lisp_LISP'))
2682 $varname = 'lisp_LISP';
2683 &am_error ("\`lisp_LISP' defined but \`AM_PATH_LISPDIR' not in \`configure.in'")
2688 $varname = 'noinst_LISP';
2691 &require_file_with_line ($varname, $FOREIGN, 'elisp-comp');
2695 ################################################################
2697 # Scan configure.in for interesting things.
2700 open (CONFIGURE, 'configure.in')
2701 || die "automake: couldn't open \`configure.in': $!\n";
2702 print "automake: reading configure.in\n" if $verbose;
2704 # Reinitialize libsources here. This isn't really necessary,
2705 # since we currently assume there is only one configure.in. But
2706 # that won't always be the case.
2709 local ($in_ac_output, @make_list) = 0;
2710 local ($libobj_iter);
2713 # Remove comments from current line.
2717 # Populate libobjs array.
2718 if (/AC_FUNC_ALLOCA/)
2720 $libsources{'alloca.c'} = 1;
2722 elsif (/AC_FUNC_GETLOADAVG/)
2724 $libsources{'getloadavg.c'} = 1;
2726 elsif (/AC_FUNC_MEMCMP/)
2728 $libsources{'memcmp.c'} = 1;
2730 elsif (/AC_STRUCT_ST_BLOCKS/)
2732 $libsources{'fileblocks.c'} = 1;
2734 elsif (/AM_FUNC_FNMATCH/)
2736 $libsources{'fnmatch.c'} = 1;
2738 elsif (/AC_REPLACE_FUNCS\s*\((.*)\)/)
2740 foreach (split (' ', $1))
2742 $libsources{$_ . '.c'} = 1;
2745 elsif (/A[CM]_REPLACE_GNU_GETOPT/)
2747 $libsources{'getopt.c'} = 1;
2748 $libsources{'getopt1.c'} = 1;
2750 elsif (/AM_FUNC_STRTOD/)
2752 $libsources{'strtod.c'} = 1;
2754 elsif (/AM_WITH_REGEX/)
2756 $libsources{'rx.c'} = 1;
2757 $libsources{'rx.h'} = 1;
2758 $libsources{'regex.c'} = 1;
2759 $libsources{'regex.h'} = 1;
2761 elsif (/AM_FUNC_MKTIME/)
2763 $libsources{'mktime.c'} = 1;
2765 elsif (/AM_FUNC_ERROR_AT_LINE/)
2767 $libsources{'error.c'} = 1;
2768 $libsources{'error.h'} = 1;
2770 elsif (/AM_FUNC_OBSTACK/)
2772 $libsources{'obstack.c'} = 1;
2773 $libsources{'obstack.h'} = 1;
2775 elsif (/LIBOBJS="(.*)\s+\$LIBOBJS"/
2776 || /LIBOBJS="\$LIBOBJS\s+(.*)"/)
2778 foreach $libobj_iter (split (' ', $1))
2780 if ($libobj_iter =~ /^(.*)\.o$/)
2782 $libsources{$1 . '.c'} = 1;
2787 if (/(fp_WITH_DMALLOC|fp_WITH_REGEX|fp_FUNC_FNMATCH|fp_PROG_INSTALL|fp_C_PROTOTYPES|jm_MAINTAINER_MODE)/)
2789 &am_conf_line_error ($., "\`$1' is obsolete; use corresponding \`AM_' macro");
2792 # Process the AC_OUTPUT macro.
2793 if (! $in_ac_output && s/AC_OUTPUT\s*\(\[?//)
2796 $ac_output_line = $.;
2800 $in_ac_output = 0 if s/[\]\),].*$//;
2802 # Look at potential Makefile.am's.
2808 push (@make_list, $_);
2812 push (@other_input_files, $_);
2817 if (/$AC_CONFIG_AUX_DIR_PATTERN/o)
2819 @config_aux_path = $1;
2822 # Check for ansi2knr.
2823 $am_c_prototypes = 1 if /AM_C_PROTOTYPES/;
2825 # Check for NLS support.
2826 if (/ud_GNU_GETTEXT/)
2829 $ac_gettext_line = $.;
2832 # Look for ALL_LINGUAS.
2833 if (/ALL_LINGUAS="(.*)"$/ || /ALL_LINGUAS=(.*)$/)
2837 $all_linguas_line = $.;
2840 # Handle configuration headers.
2841 if (/AC_CONFIG_HEADER\s*\((.*)\)/)
2843 $config_header_line = $.;
2845 if ($config_name =~ /^([^:]+):(.+)$/)
2848 $config_header = $2;
2852 $config_header = $config_name . '.in';
2856 # Handle AC_CANONICAL_*. Always allow upgrading to
2857 # AC_CANONICAL_SYSTEM, but never downgrading.
2858 $seen_canonical = $AC_CANONICAL_HOST
2859 if ! $seen_canonical
2860 && (/AC_CANONICAL_HOST/ || /AC_CHECK_TOOL/);
2861 $seen_canonical = $AC_CANONICAL_SYSTEM if /AC_CANONICAL_SYSTEM/;
2863 $seen_path_xtra = 1 if /AC_PATH_XTRA/;
2865 # Sometimes it is desirable to explicitly set YACC. For
2866 # instance some people don't want to use bison.
2867 $seen_prog_yacc = 1 if (/AC_PROG_YACC/
2868 || /AC_SUBST\(YACC\)/
2869 || /AC_(PATH|CHECK)_PROGS?\(YACC/);
2871 # This macro handles several different things.
2872 if (/$AM_INIT_AUTOMAKE_PATTERN/o)
2878 $seen_prog_install = 2;
2879 ($package_version = $1) =~ s/\s//;
2880 $package_version_line = $.;
2883 # Some things required by Automake.
2884 $seen_make_set = 1 if /AC_PROG_MAKE_SET/;
2885 $seen_arg_prog = 1 if /AC_ARG_PROGRAM/;
2886 $seen_ranlib = 1 if /AC_PROG_RANLIB/;
2887 $seen_prog_cc = 1 if /AC_PROG_CC/;
2888 $seen_prog_cxx = 1 if /AC_PROG_CXX/;
2889 $seen_prog_lex = 1 if /AC_PROG_LEX/;
2890 $seen_decl_yytext = 1 if /AC_DECL_YYTEXT/;
2891 $seen_maint_mode = 1 if /AM_MAINTAINER_MODE/;
2892 $seen_package = 1 if /PACKAGE=/;
2894 if (/VERSION=(\S+)/)
2897 $package_version = $1;
2898 $package_version_line = $.;
2905 # Weird conditionals here because it is always allowed to
2906 # upgrade to AM_PROG_INSTALL but never to downgrade to
2908 $seen_prog_install = 1 if ! $seen_prog_install && /AC_PROG_INSTALL/;
2909 $seen_prog_install = 2 if /AM_PROG_INSTALL/;
2911 $seen_lispdir = 1 if /AM_PATH_LISPDIR/;
2913 if (/AM_PROG_LIBTOOL/)
2921 # Set input files if not specified by user.
2922 @input_files = @make_list if (! @input_files);
2926 &am_conf_error ("\`PACKAGE' not defined in configure.in")
2928 &am_conf_error ("\`VERSION' not defined in configure.in")
2931 # Look for some files we need. Always check for these. This
2932 # check must be done for every run, even those where we are only
2933 # looking at a subdir Makefile. We must set relative_dir so that
2934 # the file-finding machinery works.
2935 local ($relative_dir) = '.';
2936 &require_config_file ($FOREIGN, 'install-sh', 'mkinstalldirs');
2937 &am_error ("\`install.sh' is an anachronism; use \`install-sh' instead")
2938 if -f $config_aux_path[0] . '/install.sh';
2941 ################################################################
2943 # Do any extra checking for GNU standards.
2944 sub check_gnu_standards
2946 if ($relative_dir eq '.')
2948 # In top level (or only) directory.
2949 &require_file ($GNU, 'INSTALL', 'NEWS', 'README', 'COPYING',
2950 'AUTHORS', 'ChangeLog');
2953 if ($strictness >= $GNU)
2955 if (defined $options{'no-installman'})
2957 &am_line_error ('AUTOMAKE_OPTIONS',
2958 "option \`no-installman' disallowed by GNU standards");
2961 if (defined $options{'no-installinfo'})
2963 &am_line_error ('AUTOMAKE_OPTIONS',
2964 "option \`no-installinfo' disallowed by GNU standards");
2969 # Do any extra checking for GNITS standards.
2970 sub check_gnits_standards
2972 if ($strictness >= $GNITS)
2974 if (-f $relative_dir . '/COPYING.LIB')
2976 &am_error ("\`${relative_dir}/COPYING.LIB' disallowed by Gnits standards");
2979 if ($relative_dir eq '.')
2981 if ($package_version !~ /^$GNITS_VERSION_PATTERN$/)
2983 &am_conf_line_error ($package_version_line,
2984 "version \`$package_version' doesn't follow Gnits standards");
2986 elsif (defined $1 && -f 'README-alpha')
2988 # This means we have an alpha release. See
2989 # GNITS_VERSION_PATTERN for details.
2990 &require_file ($GNITS, 'README-alpha');
2995 if ($relative_dir eq '.')
2997 # In top level (or only) directory.
2998 &require_file ($GNITS, 'THANKS');
3002 ################################################################
3004 # Pretty-print something. HEAD is what should be printed at the
3005 # beginning of the first line, FILL is what should be printed at the
3006 # beginning of every subsequent line.
3007 sub pretty_print_internal
3009 local ($head, $fill, @values) = @_;
3011 local ($column) = length ($head);
3012 local ($result) = $head;
3014 # Fill length is number of characters. However, each Tab
3015 # character counts for eight. So we count the number of Tabs and
3017 local ($fill_length) = length ($fill);
3018 $fill_length += 7 * ($fill =~ tr/\t/\t/d);
3023 # "71" because we also print a space.
3024 if ($column + length ($_) > 71)
3026 $result .= " \\\n" . $fill;
3027 $column = $fill_length;
3031 $result .= ' ' unless ($bol);
3033 $column += length ($_) + 1;
3041 # Pretty-print something and append to output_vars.
3044 $output_vars .= &pretty_print_internal (@_);
3047 # Pretty-print something and append to output_rules.
3048 sub pretty_print_rule
3050 $output_rules .= &pretty_print_internal (@_);
3054 ################################################################
3056 # See if a variable exists.
3057 sub variable_defined
3060 if (defined $targets{$var})
3062 &am_line_error ($var, "\`$var' is target; expected variable");
3065 elsif (defined $contents{$var})
3067 $content_seen{$var} = 1;
3073 # Mark a variable as examined.
3074 sub examine_variable
3077 &variable_defined ($var);
3080 # Return contents of variable as list, split as whitespace. This will
3081 # recursively follow $(...) and ${...} inclusions. It preserves @...@
3082 # substitutions. If PARENT is specified, it is the name of the
3083 # including variable; this is only used for error reports.
3084 sub variable_value_as_list
3086 local ($var, $parent) = @_;
3089 if (defined $targets{$var})
3091 &am_line_error ($var, "\`$var' is target; expected variable");
3093 elsif (! defined $contents{$var})
3095 &am_line_error ($parent, "variable \`$var' not defined");
3099 $content_seen{$var} = 1;
3100 foreach (split (' ', $contents{$var}))
3102 # If a comment seen, just leave.
3105 # Handle variable substitutions.
3106 if (/^\$\{(.*)\}$/ || /^\$\((.*)\)$/)
3108 push (@result, &variable_value_as_list ($1, $var));
3120 # Define a new variable, but only if not already defined.
3123 local ($var, $value) = @_;
3125 if (! defined $contents{$var})
3127 $output_vars .= $var . ' = ' . $value . "\n";
3128 $contents{$var} = $value;
3129 $content_seen{$var} = 1;
3133 # Like define_variable, but second arg is a list, and is
3135 sub define_pretty_variable
3137 local ($var, @value) = @_;
3138 if (! defined $contents{$var})
3140 $contents{$var} = join (' ', @value);
3141 &pretty_print ($var . ' = ', '', @value);
3142 $content_seen{$var} = 1;
3146 # Read Makefile.am and set up %contents. Simultaneously copy lines
3147 # from Makefile.am into $output_trailer or $output_vars as
3148 # appropriate. NOTE we put rules in the trailer section. We want
3149 # user rules to come after our generated stuff.
3152 local ($amfile) = @_;
3154 open (AM_FILE, $amfile) || die "automake: couldn't open \`$amfile': $!\n";
3155 print "automake: reading $amfile\n" if $verbose;
3157 $output_vars = ("# $in_file_name generated automatically by automake "
3158 . $VERSION . " from $am_file_name\n");
3160 # Generate copyright for generated Makefile.in.
3161 $output_vars .= $gen_copyright;
3163 local ($saw_bk) = 0;
3164 local ($was_rule) = 0;
3165 local ($spacing) = '';
3166 local ($comment) = '';
3167 local ($last_var_name) = '';
3172 if (/$IGNORE_PATTERN/o)
3174 # Merely delete comments beginning with two hashes.
3176 elsif (/$WHITE_PATTERN/o)
3178 # Stick a single white line before the incoming macro or rule.
3182 elsif (/$COMMENT_PATTERN/o)
3184 # Stick comments before the incoming macro or rule. Make
3185 # sure a blank line preceeds first block of comments.
3186 $spacing = "\n" unless $blank;
3188 $comment .= $spacing . $_;
3197 $output_vars .= $comment . "\n";
3200 local ($am_vars) = '';
3202 local ($is_ok_macro);
3206 unless substr ($_, -1, 1) eq "\n";
3208 $_ =~ s/\@MAINT\@//g
3209 unless $seen_maint_mode;
3211 if (/$IGNORE_PATTERN/o)
3213 # Merely delete comments beginning with two hashes.
3215 elsif (/$WHITE_PATTERN/o)
3217 # Stick a single white line before the incoming macro or rule.
3220 elsif (/$COMMENT_PATTERN/o)
3222 # Stick comments before the incoming macro or rule.
3223 $comment .= $spacing . $_;
3230 $output_trailer .= $_;
3237 # Chop newline and backslash if this line is
3238 # continued. FIXME: maybe ensure trailing whitespace
3242 $contents{$last_var_name} .= $_;
3245 elsif (/$RULE_PATTERN/o)
3247 # warn "** Saw rule .$1.\n";
3250 # Value here doesn't matter; for targets we only note
3254 $content_lines{$1} = $.;
3255 $output_trailer .= $comment . $spacing . $_;
3256 $comment = $spacing = '';
3259 elsif (($is_ok_macro = /$MACRO_PATTERN/o)
3260 || /$BOGUS_MACRO_PATTERN/o)
3262 # Found a macro definition.
3264 $last_var_name = $1;
3265 if (substr ($2, -1) eq "\\")
3267 $contents{$1} = substr ($2, 0, length ($2) - 1);
3273 $content_lines{$1} = $.;
3274 $am_vars .= $comment . $spacing . $_;
3275 $comment = $spacing = '';
3279 &am_line_error ($., "bad macro name \`$1'")
3284 # This isn't an error; it is probably a continued rule.
3285 # In fact, this is what we assume.
3287 $output_trailer .= $comment . $spacing . $_;
3288 $comment = $spacing = '';
3295 $output_trailer .= $comment;
3297 # Compute relative location of the top object directory.
3298 local (@topdir) = ();
3299 foreach (split (/\//, $relative_dir))
3301 next if $_ eq '.' || $_ eq '';
3308 push (@topdir, '..');
3311 @topdir = ('.') if ! @topdir;
3313 $top_builddir = join ('/', @topdir);
3315 ($build_rx = $top_builddir) =~ s/(\W)/\\$1/g;
3316 $output_vars .= &file_contents_with_transform
3317 ('s/\@top_builddir\@/' . $build_rx . '/g',
3320 # Generate some useful variables when AC_CANONICAL_* used.
3321 if ($seen_canonical)
3323 local ($curs, %vars);
3324 $vars{'host_alias'} = 'host_alias';
3325 $vars{'host_triplet'} = 'host';
3326 if ($seen_canonical == $AC_CANONICAL_SYSTEM)
3328 $vars{'build_alias'} = 'build_alias';
3329 $vars{'build_triplet'} = 'build';
3330 $vars{'target_alias'} = 'target_alias';
3331 $vars{'target_triplet'} = 'target';
3333 foreach $curs (keys %vars)
3335 $output_vars .= "$curs = \@$vars{$curs}\@\n";
3336 $contents{$curs} = "\@$vars{$curs}\@";
3340 $output_vars .= $am_vars;
3343 ################################################################
3345 sub initialize_global_constants
3347 # Values for AC_CANONICAL_*
3348 $AC_CANONICAL_HOST = 1;
3349 $AC_CANONICAL_SYSTEM = 2;
3351 # Associative array of standard directory names. Entry is TRUE if
3352 # corresponding directory should be installed during
3353 # 'install-exec' phase.
3371 # Helper text for dealing with man pages.
3372 $install_man_format =
3373 ' sect=@SECTION@; \\
3374 inst=`echo "@MANBASE@" | sed \'$(transform)\'`.@FULLSECT@; \\
3375 if test -f $(srcdir)/@MAN@; then file=$(srcdir)/@MAN@; \\
3376 else file=@MAN@; fi; \\
3377 $(INSTALL_DATA) $$file $(mandir)/man$$sect/$$inst
3380 $uninstall_man_format =
3381 ' inst=`echo "@MANBASE@" | sed \'$(transform)\'`.@FULLSECT@; \\
3382 rm -f $(mandir)/man@SECTION@/$$inst
3385 # Commonly found files we look for and automatically include in
3389 "README", "THANKS", "TODO", "NEWS", "COPYING", "COPYING.LIB",
3390 "INSTALL", "ABOUT-NLS", "ChangeLog", "configure", "configure.in",
3391 "config.guess", "config.sub", "AUTHORS", "BACKLOG", "ABOUT-GNU",
3392 "libversion.in", "mdate-sh", "mkinstalldirs", "install-sh",
3393 'texinfo.tex', "ansi2knr.c", "ansi2knr.1", 'elisp-comp',
3394 'interlock', 'ylwrap', 'acinclude.m4'
3397 # Commonly used files we auto-include, but only sometimes.
3400 "aclocal.m4", "acconfig.h", "config.h.top",
3401 "config.h.bot", "stamp-h.in", 'stamp-vti', 'libtool'
3405 -a, --add-missing add missing standard files to package
3406 --amdir=DIR directory storing config files
3407 --build-dir=DIR directory where build being done (for dependencies)
3408 --foreign same as --strictness=foreign
3409 --gnits same as --strictness=gnits
3410 --gnu same as --strictness=gnu
3411 --help print this help, then exit
3412 -i, --include-deps include generated dependencies in Makefile.in
3413 --no-force only update Makefile.in's that are out of date
3414 -o DIR, --output-dir=DIR
3415 put generated Makefile.in's into DIR
3416 --srcdir-name=DIR name used for srcdir (for dependencies)
3417 -s LEVEL, --strictness=LEVEL
3418 set strictness level. LEVEL is foreign, gnu, gnits
3419 -v, --verbose verbosely list files processed
3420 --version print version number, then exit\n";
3422 # Copyright on generated Makefile.ins.
3424 # Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
3425 # This Makefile.in is free software; the Free Software Foundation
3426 # gives unlimited permission to copy, distribute and modify it.
3429 # Ignore return result from chmod, because it might give an error
3430 # if we chmod a symlink.
3431 $dist_header = "\t" . '-chmod -R a+r $(distdir)' . "\n";
3432 $dist{'tarZ'} = ("\t"
3433 . '$(TAR) chf - $(distdir) | compress -c > $(distdir).tar.Z'
3435 $dist{'shar'} = ("\t"
3436 . 'shar $(distdir) | gzip > $(distdir).shar.gz'
3438 $dist{'zip'} = "\t" . 'zip -rq $(distdir).zip $(distdir)' . "\n";
3439 $dist{'dist'} = "\t" . '$(TAR) chozf $(distdir).tar.gz $(distdir)' . "\n";
3440 $dist_trailer = "\t" . 'rm -rf $(distdir)' . "\n";
3443 # (Re)-Initialize per-Makefile.am variables.
3444 sub initialize_per_input
3446 # These two variables are used when generating each Makefile.in.
3447 # They hold the Makefile.in until it is ready to be printed.
3450 $output_trailer = '';
3452 # Suffixes found during a run.
3455 # This holds the contents of a Makefile.am, as parsed by
3459 # This holds the names which are targets. These also appear in
3463 # This holds the line numbers at which various elements of
3464 # %contents are defined.
3465 %content_lines = ();
3467 # This holds a 1 if a particular variable was examined.
3470 # This holds the "relative directory" of the current Makefile.in.
3471 # Eg for src/Makefile.in, this is "src".
3474 # This holds a list of files that are included in the
3478 # List of dependencies for the obvious targets.
3493 # These are pretty obvious, too. They are used to define the
3494 # SOURCES and OBJECTS variables.
3498 # TRUE if current directory holds any C source files. (Actually
3499 # holds object extension, but this information is encapsulated in
3500 # the function get_object_extension).
3501 $dir_holds_sources = '';
3503 # TRUE if current directory holds any headers.
3504 $dir_holds_headers = 0;
3506 # TRUE if install targets should work recursively.
3507 $recursive_install = 0;
3512 # Strictness levels.
3513 $strictness = $default_strictness;
3514 $strictness_name = $default_strictness_name;
3516 # Options from AUTOMAKE_OPTIONS.
3519 # Whether or not dependencies are handled. Can be further changed
3520 # in handle_options.
3521 $use_dependencies = $cmdline_use_dependencies;
3524 $local_maint_charset = $maint_charset;
3526 # All yacc and lex source filenames for this directory. Use
3527 # filenames instead of raw count so that multiple instances are
3528 # counted correctly (eg one yacc file can appear in multiple
3529 # programs without harm).
3533 # C++ source extensions we've seen.
3534 %cxx_extensions = ();
3536 # TRUE if we've seen any non-C++ sources.
3541 ################################################################
3543 # Return contents of a file from $am_dir, automatically skipping
3544 # macros or rules which are already known. Runs command on each line
3545 # as it is read; this command can modify $_.
3546 sub file_contents_with_transform
3548 local ($command, $basename) = @_;
3549 local ($file) = $am_dir . '/' . $basename . '.am';
3551 open (FC_FILE, $file)
3552 || die "automake: installation error: cannot open \`$file'\n";
3554 # print "automake: reading $file\n" if $verbose;
3556 local ($was_rule) = 0;
3557 local ($result_vars) = '';
3558 local ($result_rules) = '';
3559 local ($comment) = '';
3560 local ($spacing) = "\n";
3561 local ($skipping) = 0;
3565 $_ =~ s/\@MAINT\@//g
3566 unless $seen_maint_mode;
3570 if (/$IGNORE_PATTERN/o)
3572 # Merely delete comments beginning with two hashes.
3574 elsif (/$WHITE_PATTERN/o)
3576 # Stick a single white line before the incoming macro or rule.
3579 elsif (/$COMMENT_PATTERN/o)
3581 # Stick comments before the incoming macro or rule.
3582 $comment .= $spacing . $_;
3589 $result_rules .= $_ if ! $skipping;
3593 $result_vars .= $_ if ! $skipping;
3597 elsif (/$RULE_PATTERN/o)
3599 # warn "** Found rule .$1.\n";
3602 $skipping = defined $contents{$1};
3603 # warn "** Skip $skipping\n" if $skipping;
3604 $result_rules .= $comment . $spacing . $_ if ! $skipping;
3605 $comment = $spacing = '';
3608 elsif (/$MACRO_PATTERN/o)
3610 # warn "** Found macro .$1.\n";
3611 # Found a variable reference.
3613 $skipping = defined $contents{$1};
3614 # warn "** Skip $skipping\n" if $skipping;
3615 $result_vars .= $comment . $spacing . $_ if ! $skipping;
3616 $comment = $spacing = '';
3621 # This isn't an error; it is probably a continued rule.
3622 # In fact, this is what we assume.
3624 $result_rules .= $comment . $spacing . $_ if ! $skipping;
3625 $comment = $spacing = '';
3631 return $result_vars . $result_rules . $comment;
3634 # Like file_contents_with_transform, but no transform.
3637 return &file_contents_with_transform ('', @_);
3640 # Find all variable prefixes that are used for install directories. A
3641 # prefix `zar' qualifies iff:
3642 # * `zardir' is a variable.
3643 # * `zar_PRIMARY' is a variable.
3644 sub am_primary_prefixes
3646 local ($primary, @prefixes) = @_;
3648 local (%valid, $varname);
3649 grep ($valid{$_} = 0, @prefixes);
3650 $valid{'EXTRA'} = 0;
3651 foreach $varname (keys %contents)
3653 if ($varname =~ /^(.*)_$primary$/)
3655 if (! defined $valid{$1} && ! &variable_defined ($1 . 'dir'))
3657 &am_line_error ($varname, "invalid variable \"$varname\"");
3661 # Ensure all extended prefixes are actually used.
3670 # Handle `where_HOW' variable magic. Does all lookups, generates
3671 # install code, and possibly generates code to define the primary
3672 # variable. The first argument is the name of the .am file to munge,
3673 # the second argument is the primary variable (eg HEADERS), and all
3674 # subsequent arguments are possible installation locations. Returns
3675 # list of all values of all _HOW targets.
3677 # FIXME: this should be rewritten to be cleaner. It should be broken
3678 # up into multiple functions.
3680 # Usage is: am_install_var (OPTION..., file, HOW, where...)
3685 local ($do_all, $do_clean) = (1, 0);
3688 if ($args[0] eq '-clean')
3692 elsif ($args[0] eq '-no-all')
3696 elsif ($args[0] !~ /^-/)
3702 local ($file, $primary, @prefixes) = @args;
3705 local (@result) = ();
3707 # Now that configure substitutions are allowed in where_HOW
3708 # variables, it is an error to actually define the primary.
3709 &am_line_error ($primary, "\`$primary' is an anachronism")
3710 if &variable_defined ($primary);
3713 # Look for misspellings. It is an error to have a variable ending
3714 # in a "reserved" suffix whose prefix is unknown, eg
3715 # "bni_PROGRAMS". However, unusual prefixes are allowed if a
3716 # variable of the same name (with "dir" appended) exists. For
3717 # instance, if the variable "zardir" is defined, then
3718 # "zar_PROGRAMS" becomes valid. This is to provide a little extra
3719 # flexibility in those cases which need it. Perhaps it should be
3720 # disallowed in the Gnits case? The problem is, sometimes it is
3721 # useful to put things in a subdir of eg pkgdatadir, perhaps even
3723 local (%valid) = &am_primary_prefixes ($primary, @prefixes);
3725 # If a primary includes a configure substitution, then the EXTRA_
3726 # form is required. Otherwise we can't properly do our job.
3727 local ($require_extra);
3728 local ($warned_about_extra) = 0;
3730 local ($clean_file) = $file . '-clean';
3733 foreach $X (keys %valid)
3735 $one_name = $X . '_' . $primary;
3736 if (&variable_defined ($one_name))
3738 # Append actual contents of where_PRIMARY variable to
3741 foreach $rcurs (&variable_value_as_list ($one_name))
3743 # Skip configure substitutions. Possibly bogus.
3744 if ($rcurs =~ /^\@.*\@$/)
3748 if (! $warned_about_extra)
3750 $warned_about_extra = 1;
3751 &am_line_error ($one_name,
3752 "\`$one_name' contains configure substitution, but shouldn't");
3757 $require_extra = $one_name;
3761 push (@result, $rcurs);
3764 # "EXTRA" shouldn't be used when generating clean targets,
3765 # @all, or install targets.
3766 next if $X eq 'EXTRA';
3771 &file_contents_with_transform ('s/\@DIR\@/' . $X . '/go',
3774 push (@clean, $X . $primary);
3775 &push_phony_cleaners ($X . $primary);
3780 push (@check, '$(' . $one_name . ')');
3784 push (@used, '$(' . $one_name . ')');
3786 if ($X eq 'noinst' || $X eq 'check')
3788 # Objects which don't get installed by default.
3793 &file_contents_with_transform ('s/\@DIR\@/' . $X . '/go',
3796 push (@uninstall, 'uninstall-' . $X . $primary);
3797 push (@phony, 'uninstall-' . $X . $primary);
3798 push (@installdirs, '$(' . $X . 'dir)');
3799 if ($exec_dir_p{$X})
3801 push (@install_exec, 'install-' . $X . $primary);
3802 push (@phony, 'install-' . $X . $primary);
3806 push (@install_data, 'install-' . $X . $primary);
3807 push (@phony, 'install-' . $X . $primary);
3815 &define_pretty_variable ($primary, @used);
3816 $output_vars .= "\n";
3819 if ($require_extra && ! &variable_defined ('EXTRA_' . $primary))
3821 &am_line_error ($require_extra,
3822 "\`$require_extra' contains configure substitution, but \`EXTRA_$primary' not defined");
3825 # Push here because PRIMARY might be configure time determined.
3826 push (@all, '$(' . $primary . ')')
3827 if $do_all && @used;
3833 ################################################################
3835 # This variable is local to the "require file" set of functions.
3836 @require_file_paths = ();
3838 # Verify that the file must exist in the current directory. Usage:
3839 # require_file (isconfigure, line_number, strictness, file) strictness
3840 # is the strictness level at which this file becomes required. Must
3841 # set require_file_paths before calling this function.
3842 # require_file_paths is set to hold a single directory (the one in
3843 # which the first file was found) before return.
3844 sub require_file_internal
3846 local ($is_configure, $line, $mystrict, @files) = @_;
3847 local ($file, $fullfile);
3848 local ($found_it, $errfile, $errdir);
3851 foreach $file (@files)
3854 foreach $dir (@require_file_paths)
3858 $fullfile = $relative_dir . "/" . $file;
3859 $errdir = $relative_dir unless $errdir;
3863 $fullfile = $dir . "/" . $file;
3864 $errdir = $dir unless $errdir;
3867 # Use different name for "error filename". Otherwise on
3868 # an error the bad file will be reported as eg
3869 # `../../install-sh' when using the default
3871 $errfile = $errdir . '/' . $file;
3876 # FIXME: Once again, special-case `.'.
3877 &push_dist_common ($file)
3878 if $dir eq $relative_dir || $dir eq '.';
3886 # Prune the path list.
3887 @require_file_paths = $save_dir;
3891 if ($strictness >= $mystrict)
3893 local ($trailer) = '';
3894 local ($suppress) = 0;
3896 # Only install missing files according to our desired
3898 if ($add_missing && -f ($am_dir . '/' . $file))
3900 $trailer = "; installing";
3902 # Install the missing file. Symlink if we can, copy
3904 if ($symlink_exists)
3906 if (! symlink ($am_dir . '/' . $file, $errfile))
3909 $trailer .= "; error while making link: $!\n";
3914 if (! system ('cp', $am_dir . '/' . $file, $errfile))
3917 $trailer .= "\n error while making link: $!\n";
3922 local ($save) = $exit_status;
3927 "required file \"$errfile\" not found$trailer");
3933 "required file \"$errfile\" not found$trailer");
3935 $exit_status = $save if $suppress;
3941 # Like require_file_with_line, but error messages refer to
3942 # configure.in, not the current Makefile.am.
3943 sub require_file_with_conf_line
3945 @require_file_paths = '.';
3946 &require_file_internal (1, @_);
3949 sub require_file_with_line
3951 @require_file_paths = '.';
3952 &require_file_internal (0, @_);
3957 @require_file_paths = '.';
3958 &require_file_internal (0, '', @_);
3961 # Require a file that is also required by Autoconf. Looks in
3962 # configuration path, as specified by AC_CONFIG_AUX_DIR.
3963 sub require_config_file
3965 @require_file_paths = @config_aux_path;
3966 &require_file_internal (1, '', @_);
3967 local ($dir) = $require_file_paths[0];
3968 @config_aux_path = @require_file_paths;
3971 $config_aux_dir = '.';
3975 $config_aux_dir = '$(top_srcdir)/' . $dir;
3979 # Assumes that the line number is in Makefile.am.
3980 sub require_conf_file_with_line
3982 @require_file_paths = @config_aux_path;
3983 &require_file_internal (0, @_);
3984 local ($dir) = $require_file_paths[0];
3985 @config_aux_path = @require_file_paths;
3988 $config_aux_dir = '.';
3992 $config_aux_dir = '$(top_srcdir)/' . $dir;
3996 # Assumes that the line number is in Makefile.am.
3997 sub require_conf_file_with_conf_line
3999 @require_file_paths = @config_aux_path;
4000 &require_file_internal (1, @_);
4001 local ($dir) = $require_file_paths[0];
4002 @config_aux_path = @require_file_paths;
4005 $config_aux_dir = '.';
4009 $config_aux_dir = '$(top_srcdir)/' . $dir;
4013 ################################################################
4015 # Push a list of files onto dist_common.
4016 sub push_dist_common
4018 local (@files) = @_;
4021 foreach $file (@files)
4023 $dist_common{$file} = 1;
4027 # Push a list of clean targets onto phony.
4028 sub push_phony_cleaners
4032 foreach $target ('mostly', 'dist', '', 'maintainer-')
4034 push (@phony, $target . 'clean-' . $base);
4041 $strictness_name = $_[0];
4042 if ($strictness_name eq 'gnu')
4046 elsif ($strictness_name eq 'gnits')
4048 $strictness = $GNITS;
4050 elsif ($strictness_name eq 'foreign')
4052 $strictness = $FOREIGN;
4056 die "automake: level \`$strictness_name' not recognized\n";
4061 ################################################################
4063 # Return directory name of file.
4069 ($sub = $file) =~ s,/+[^/]+$,,g;
4070 $sub = '.' if $sub eq $file;
4074 # Return file name of a file.
4080 ($sub = $file) =~s,^.*/+,,g;
4089 open (TOUCH, ">> $file");
4093 ################################################################
4095 # Print an error message and set exit status.
4098 warn "automake: ${am_file}.am: ", join (' ', @_), "\n";
4104 local ($symbol, @args) = @_;
4108 # If SYMBOL not already a line number, look it up in Makefile.am.
4109 $symbol = $content_lines{$symbol} unless $symbol =~ /^\d+$/;
4110 $symbol .= ': ' if $symbol;
4111 warn "${am_file}.am:", $symbol, join (' ', @args), "\n";
4120 # Like am_error, but while scanning configure.in.
4123 # FIXME: can run in subdirs.
4124 warn "automake: configure.in: ", join (' ', @_), "\n";
4128 # Error message with line number referring to configure.in.
4129 sub am_conf_line_error
4131 local ($line, @args) = @_;
4135 warn "configure.in: $line: ", join (' ', @args), "\n";
4140 &am_conf_error (@args);
4144 # Tell user where our aclocal.m4 is, but only once.
4145 sub keyed_aclocal_warning
4148 warn "automake: macro \`$key' can be generated by \`aclocal'\n";
4151 # Print usage information.
4154 print "Usage: automake [OPTION] ... [Makefile]...\n";
4156 print "\nFiles which are automatically distributed, if found:\n";
4157 $~ = "USAGE_FORMAT";
4158 local (@lcomm) = sort ((@common_files, @common_sometimes));
4159 local ($one, $two, $three, $four);
4162 $one = shift @lcomm;
4163 $two = @lcomm ? shift @lcomm : '';
4164 $three = @lcomm ? shift @lcomm : '';
4165 $four = @lcomm ? shift @lcomm : '';
4169 print "\nReport bugs to <bug-gnu-utils\@prep.ai.mit.edu>\n";
4174 format USAGE_FORMAT =
4175 @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<
4176 $one, $two, $three, $four