5 eval 'exec @PERL@ -S $0 ${1+"$@"}'
8 # automake - create Makefile.in from Makefile.am
9 # Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
11 # This program is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by
13 # the Free Software Foundation; either version 2, or (at your option)
16 # This program is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write to the Free Software
23 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
26 # Originally written by David Mackenzie <djm@gnu.ai.mit.edu>.
27 # Perl reimplementation by Tom Tromey <tromey@drip.colorado.edu>.
30 # Parameters set by configure. Not to be changed. NOTE: assign
31 # VERSION as string so that eg version 0.30 will print correctly.
32 $VERSION = "@VERSION@";
33 $PACKAGE = "@PACKAGE@";
35 $am_dir = "@datadir@/@PACKAGE@";
38 $IGNORE_PATTERN = "^##([^#].*)?\$";
39 $WHITE_PATTERN = "^[ \t]*\$";
40 $COMMENT_PATTERN = "^#";
41 $RULE_PATTERN = "^([\$a-zA-Z_.][-.a-zA-Z0-9_(){}/]*) *:([^=].*|)\$";
42 $MACRO_PATTERN = "^([A-Za-z][A-Za-z0-9_]*)[ \t]*:?=[ \t]*(.*)\$";
43 $BOGUS_MACRO_PATTERN = "^([^ \t]*)[ \t]*:?=[ \t]*(.*)\$";
44 $GNITS_VERSION_PATTERN = "[0-9]+\\.[0-9]+([a-z]|\\.[0-9]+)?";
46 # Some regular expressions. One reason to put them here is that it
47 # makes indentation work better in Emacs.
48 $AC_CONFIG_AUX_DIR_PATTERN = "AC_CONFIG_AUX_DIR\\(([^)]+)\\)";
49 $AM_INIT_AUTOMAKE_PATTERN = "AM_INIT_AUTOMAKE\\([^,]*,([^)]+)\\)";
51 # Constants to define the "strictness" level.
58 # Variables global to entire run.
60 # TRUE if we should always generate Makefile.in.
61 $force_generation = 1;
63 # Strictness level as set on command line.
64 $default_strictness = $GNU;
66 # Name of strictness level, as set on command line.
67 $default_strictness_name = 'gnu';
69 # This is TRUE if GNU make specific automatic dependency generation
70 # code should be included in generated Makefile.in.
71 $cmdline_use_dependencies = 1;
73 # TRUE if in verbose mode.
76 # This holds our (eventual) exit status. We don't actually exit until
77 # we have processed all input files.
80 # From the Perl manual.
81 $symlink_exists = (eval 'symlink ("", "");', $@ eq '');
83 # TRUE if missing standard files should be installed.
86 # Files found by scanning configure.in for LIBOBJS.
89 # True if AM_C_PROTOTYPES appears in configure.in.
92 # Names used in AC_CONFIG_HEADER call. $config_name is the actual
93 # (first) argument. $config_header is the '.in' file. Ordinarily the
94 # second is derived from the first, but they can be different if the
95 # weird "NAME:FILE" syntax is used.
98 # Line number at which AC_CONFIG_HEADER appears in configure.in.
99 $config_header_line = 0;
101 # Directory where output files go. Actually, output files are
102 # relative to this directory.
103 $output_directory = '.';
105 # Relative location of top build directory.
108 # Absolute location of top build directory.
109 $build_directory = '';
111 # Name of srcdir as given in build directory's Makefile. For
115 # List of Makefile.am's to process.
118 # List of files in AC_OUTPUT without Makefile.am.
119 @other_input_files = ();
120 # Line number at which AC_OUTPUT seen.
123 # List of directories to search for configure-required files. This
124 # can be set by AC_CONFIG_AUX_DIR.
125 @config_aux_path = ('.', '..', '../..');
126 $config_aux_dir = '';
128 # Whether AC_PROG_MAKE_SET has been seen in configure.in.
131 # Whether ud_GNU_GETTEXT has been seen in configure.in.
133 # Line number at which ud_GNU_GETTEXT seen.
134 $ac_gettext_line = 0;
136 # Whether ALL_LINGUAS has been seen.
140 # Line number at which it appears.
141 $all_linguas_line = 0;
143 # 1 if AC_PROG_INSTALL seen, 2 if AM_PROG_INSTALL seen.
144 $seen_prog_install = 0;
146 # 1 if any scripts installed, 0 otherwise.
147 $scripts_installed = 0;
149 # Whether AC_PATH_XTRA has been seen in configure.in.
152 # Whether YACC variable has been seen in configure.in.
155 # Two variables to control lex use. One is for AC_DECL_YYTEXT and the
156 # other is for AC_PROG_LEX.
157 $seen_decl_yytext = 0;
160 # TRUE if we've seen AC_PROG_CC.
163 # TRUE if we've seen AC_PROG_CXX.
166 # TRUE if we've seen AC_CANONICAL_(HOST|SYSTEM). The presence of
167 # AC_CHECK_TOOL also sets this.
170 # TRUE if we've seen AC_PROG_RANLIB.
173 # TRUE if we've seen AC_ARG_PROGRAM.
176 # TRUE if we've seen AM_PROG_LIBTOOL.
180 # TRUE if we've seen AM_MAINTAINER_MODE.
181 $seen_maint_mode = 0;
183 # TRUE if we've seen PACKAGE and VERSION.
187 # Actual version we've seen.
188 $package_version = '';
190 # Line number where we saw version definition.
191 $package_version_line = 0;
193 # TRUE if we've seen AM_PATH_LISPDIR.
197 # Charsets used by maintainer and in distribution. MAINT_CHARSET is
198 # handled in a funny way: if seen in the top-level Makefile.am, it is
199 # used for every directory which does not specify a different value.
200 # The rationale here is that some directories (eg gettext) might be
201 # distributions of other packages, and thus require their own charset
202 # info. However, the DIST_CHARSET must be the same for the entire
203 # package; it can only be set at top-level.
204 # FIXME: this yields bugs when rebuilding. What to do? Always
205 # read (and sometimes discard) top-level Makefile.am?
207 $dist_charset = 'utf8'; # recode doesn't support this yet.
209 # Name of input file ("Makefile.in") and output file ("Makefile.am").
210 # These have no directory components.
216 &initialize_global_constants;
218 # Parse command line.
219 &parse_arguments (@ARGV);
221 # Do configure.in scan only once.
224 die "automake: no \`Makefile.am' found or specified\n"
227 # Now do all the work on each file.
228 foreach $am_file (@input_files)
230 # FIXME: should support the AC_OUTPUT ":" syntax here.
231 if (! -f ($am_file . '.am'))
233 &am_error ('no such file');
237 &generate_makefile ($am_file);
241 if ($seen_prog_install <= $scripts_installed)
243 &am_conf_error (($scripts_installed ? 'AM_PROG_INSTALL' : 'AC_PROG_INSTALL')
244 . " must be used in configure.in");
245 &keyed_aclocal_warning ('AM_PROG_INSTALL')
246 if $scripts_installed;
252 ################################################################
254 # Parse command line.
257 local (@arglist) = @_;
260 &set_strictness ('gnu');
264 if ($arglist[0] eq "--version")
266 print "automake (GNU $PACKAGE) $VERSION\n";
267 print "Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.\n";
268 print "automake comes with ABSOLUTELY NO WARRANTY.\n";
269 print "You may redistribute copies of automake\n";
270 print "under the terms of the GNU General Public License.\n";
271 print "For more information about these matters, see the file named COPYING.\n";
274 elsif ($arglist[0] eq "--help")
278 elsif ($arglist[0] =~ /^--amdir=(.+)$/)
282 elsif ($arglist[0] eq '--amdir')
284 &require_argument (@arglist);
286 $am_dir = $arglist[0];
288 elsif ($arglist[0] =~ /^--build-dir=(.+)$/)
291 $build_directory = $1 . '/';
293 elsif ($arglist[0] eq '--build-dir')
295 &require_argument (@arglist);
298 $build_directory = $arglist[0] . '/';
300 elsif ($arglist[0] =~ /^--srcdir-name=(.+)$/)
304 elsif ($arglist[0] eq '--srcdir-name')
306 &require_argument (@arglist);
308 $srcdir_name = $arglist[0];
310 elsif ($arglist[0] =~ /^--strictness=(.+)$/)
312 &set_strictness ($1);
314 elsif ($arglist[0] eq '--gnu')
316 &set_strictness ('gnu');
318 elsif ($arglist[0] eq '--gnits')
320 &set_strictness ('gnits');
322 elsif ($arglist[0] eq '--foreign')
324 &set_strictness ('foreign');
326 elsif ($arglist[0] eq '--strictness' || $arglist[0] eq '-s')
328 &require_argument (@arglist);
330 &set_strictness ($arglist[0]);
332 elsif ($arglist[0] eq '--include-deps' || $arglist[0] eq '-i')
334 $cmdline_use_dependencies = 0;
336 elsif ($arglist[0] eq '--no-force')
338 $force_generation = 0;
340 elsif ($arglist[0] =~ /^--output-dir=(.*)$/)
342 # Set output directory.
343 $output_directory = $1;
345 elsif ($arglist[0] eq '--output-dir' || $arglist[0] eq '-o')
347 &require_argument (@arglist);
349 $output_directory = $arglist[0];
351 elsif ($arglist[0] eq '--add-missing' || $arglist[0] eq '-a')
355 elsif ($arglist[0] eq '--verbose' || $arglist[0] eq '-v')
359 elsif ($arglist[0] eq '--')
361 # Stop option processing.
363 push (@input_files, @arglist);
366 elsif ($arglist[0] =~ /^-/)
368 die "automake: unrecognized option -- \`$arglist[0]'\nTry \`automake --help' for more information.\n";
372 push (@input_files, $arglist[0]);
378 # Take global strictness from whatever we currently have set.
379 $default_strictness = $strictness;
380 $default_strictness_name = $strictness_name;
383 # Ensure argument exists, or die.
386 local ($arg, @arglist) = @_;
387 die "automake: no argument given for option \`$arg'\n"
391 ################################################################
393 # Generate a Makefile.in given the name of the corresponding Makefile.
394 sub generate_makefile
396 local ($makefile) = @_;
398 ($am_file_name = $makefile) =~ s/^.*\///;
399 $in_file_name = $am_file_name . '.in';
400 $am_file_name .= '.am';
402 &initialize_per_input;
403 $relative_dir = &dirname ($makefile);
405 # At the toplevel directory, we might need config.guess, config.sub
407 if ($relative_dir eq '.')
409 # libtool requires some files.
410 &require_conf_file_with_conf_line ($libtool_line, $FOREIGN,
411 'config.sub', 'config.guess',
412 'libtool') if $seen_libtool;
414 # AC_CANONICAL_HOST and AC_CANONICAL_SYSTEM need config.guess and
416 &require_config_file ($FOREIGN, 'config.guess', 'config.sub')
420 # We still need Makefile.in here, because sometimes the `dist'
421 # target doesn't re-run automake.
422 &push_dist_common ($in_file_name, $am_file_name);
423 push (@sources, '$(SOURCES)')
424 if &variable_defined ('SOURCES');
425 push (@objects, '$(OBJECTS)')
426 if &variable_defined ('OBJECTS');
428 # This is always the default target. This gives us freedom to do
429 # things in whatever order is convenient.
430 $output_rules .= "default: all\n\n";
431 push (@phony, 'default');
433 &read_am_file ($makefile . '.am');
436 # Fatal error. Just return, so we can continue with next file.
440 # Check first, because we might modify some state.
441 &check_gnu_standards;
442 &check_gnits_standards;
450 # This must be run after all the sources are scanned.
451 &handle_yacc_lex_cxx;
453 # This is here for lack of a better place to put it.
454 if (&variable_defined ('BUILT_SOURCES'))
456 push (@all, '$(BUILT_SOURCES)');
459 # Re-init SOURCES and OBJECTS. FIXME: other code shouldn't depend
460 # on this (but currently does).
461 $contents{'SOURCES'} = join (' ', @sources);
462 $contents{'OBJECTS'} = join (' ', @objects);
472 &handle_dependencies;
475 &handle_merge_targets;
482 if (! -d ($output_directory . '/' . $relative_dir))
484 mkdir ($output_directory . '/' . $relative_dir, 0755);
487 local ($out_file) = $output_directory . '/' . $makefile . ".in";
488 if (! $force_generation && -e $out_file)
490 local ($am_time) = (stat ($makefile . '.am'))[9];
491 local ($in_time) = (stat ($out_file))[9];
492 # FIXME: how to do unsigned comparison?
493 if ($am_time < $in_time)
500 if (! open (GM_FILE, "> " . $out_file))
502 warn "automake: ${am_file}.in: cannot open: $!\n";
506 print "automake: creating ", $makefile, ".in\n" if $verbose;
508 print GM_FILE $output_vars;
509 print GM_FILE $output_rules;
510 print GM_FILE $output_trailer;
515 ################################################################
517 # Handle AUTOMAKE_OPTIONS variable. Return 1 on error, 0 otherwise.
520 return 0 if ! &variable_defined ('AUTOMAKE_OPTIONS');
522 foreach (&variable_value_as_list ('AUTOMAKE_OPTIONS'))
525 if ($_ eq 'gnits' || $_ eq 'gnu' || $_ eq 'foreign')
527 &set_strictness ($_);
531 # An option like "../lib/ansi2knr" is allowed. With no
532 # path prefix, we assume the required programs are in this
533 # directory. We save the actual option for later.
534 $options{'ansi2knr'} = $_;
536 elsif ($_ eq 'no-installman' || $_ eq 'no-installinfo'
537 || $_ eq 'dist-shar' || $_ eq 'dist-zip'
538 || $_ eq 'dist-tarZ' || $_ eq 'dejagnu')
540 # Explicitly recognize these.
542 elsif ($_ eq 'no-dependencies')
544 $use_dependencies = 0;
546 elsif (/([0-9]+)\.([0-9]+)/)
548 # Got a version number. Note that alpha releases count as
549 # the next higher release. Note also that we assume there
550 # will be a maximum of 100 minor releases for any given
552 local ($rmajor, $rminor) = ($1, $2);
553 if ($VERSION !~ /([0-9]+)\.([0-9]+)([a-z])?/)
556 "automake: programming error: version is incorrect\n";
559 local ($tmajor, $tminor) = ($1, $2);
560 # Handle alpha versions.
561 ++$tminor if defined $3;
563 if ($rmajor > $tmajor || ($rmajor == $tmajor && $rminor > $tminor))
565 &am_line_error ('AUTOMAKE_OPTIONS',
566 "require version $_, only have $VERSION");
572 &am_line_error ('AUTOMAKE_OPTIONS',
573 'option ', $_, 'not recognized');
580 # Return object extension. Just once, put some code into the output.
581 sub get_object_extension
583 if (! $dir_holds_sources)
587 if (&variable_defined ('CONFIG_HEADER'))
589 ($xform = &dirname ($contents{'CONFIG_HEADER'}))
591 $xform = '-I' . $xform;
593 $xform = 's/\@CONFIG_INCLUDE_SPEC\@/' . $xform . '/go';
594 $output_vars .= &file_contents_with_transform ($xform,
596 $output_rules .= &file_contents ('compile');
597 &push_phony_cleaners ('compile');
599 # If using X, include some extra variable definitions. NOTE
600 # we don't want to force these into CFLAGS or anything,
601 # because not all programs will necessarily use X.
605 foreach $var ('X_CFLAGS', 'X_LIBS', 'X_EXTRA_LIBS', 'X_PRE_LIBS')
607 &define_variable ($var, "\@$var\@");
611 # Check for automatic de-ANSI-fication.
612 $dir_holds_sources = '.o';
613 push (@suffixes, '.c', '.o');
614 push (@clean, 'compile');
616 if (defined $options{'ansi2knr'})
618 if (! $am_c_prototypes)
620 &am_line_error ('AUTOMAKE_OPTIONS',
621 "option \`ansi2knr' in use but \`AM_C_PROTOTYPES' not in configure.in");
622 &keyed_aclocal_warning ('AM_C_PROTOTYPES');
623 # Only give this error once.
624 $am_c_prototypes = 1;
627 $dir_holds_sources = '$o';
628 push (@suffixes, '._c', '._o');
630 # Only require ansi2knr files if they should appear in
632 if ($options{'ansi2knr'} eq 'ansi2knr')
634 &require_file_with_line ('AUTOMAKE_OPTIONS', $FOREIGN,
635 'ansi2knr.c', 'ansi2knr.1');
636 $output_rules .= &file_contents ('kr-extra');
637 push (@clean, 'krextra');
638 &push_phony_cleaners ('krextra');
641 &define_variable ('o', ".\@U\@o");
643 # Make sure ansi2knr can be found: if no path specified,
645 local ($apath) = $options{'ansi2knr'};
646 $apath = './' . $apath
647 unless $apath =~ /\//;
648 &define_variable ("ANSI2KNR", $apath);
650 $output_rules .= &file_contents ('compile-kr');
651 $output_rules .= &file_contents ('clean-kr');
654 &push_phony_cleaners ('kr');
657 return $dir_holds_sources;
660 # Handle yacc and lex.
661 sub handle_yacc_lex_cxx
664 # First do yacc and lex.
667 local ($yacc_count) = scalar (keys %yacc_sources);
668 local ($lex_count) = scalar (keys %lex_sources);
671 push (@suffixes, '.y');
672 &define_variable ('YACC', "\@YACC\@");
673 $output_rules .= ".y.c:\n\t";
676 $output_rules .= '$(SHELL) $(INTERLOCK) =yacclockdir $(YLWRAP) "$(YACC)" y.tab.c $*.c y.tab.h $*.h -- $(YFLAGS) $<';
680 $output_rules .= ('$(YACC) $(YFLAGS) $< && mv y.tab.c $@' . "\n\t"
681 . 'if test -f y.tab.h; then mv y.tab.h $*.h; else :; fi');
683 $output_rules .= "\n";
685 if (! $seen_prog_yacc)
687 # FIXME: should include a reference line. FIXME: maybe
688 # directly reference AC_PROG_YACC somehow?
689 &am_error ("yacc source seen but \`YACC' not defined in \`configure.in'\n");
694 push (@suffixes, '.l');
695 &define_variable ("LEX", "\@LEX\@");
696 &define_variable ("LEX_OUTPUT_ROOT", "\@LEX_OUTPUT_ROOT\@");
697 &define_variable ("LEXLIB", "\@LEXLIB\@");
698 $output_rules .= ".l.c:\n\t";
701 $output_rules .= '$(SHELL) $(INTERLOCK) =lexlockdir $(YLWRAP) "$(LEX)" $(LEX_OUTPUT_ROOT).c $@ -- $(LFLAGS) $<';
705 $output_rules .= '$(LEX) $(LFLAGS) $< && mv $(LEX_OUTPUT_ROOT).c $@';
707 $output_rules .= "\n";
709 if (! $seen_prog_lex)
711 &am_error ("lex source seen but \`AC_PROG_LEX' not in \`configure.in'\n");
713 if (! $seen_decl_yytext)
715 &am_error ("lex source seen but \`AC_DECL_YYTEXT' not in \`configure.in'\n");
719 if ($yacc_count > 1 || $lex_count > 1)
721 # If there is more than one distinct yacc (resp lex) source
722 # file in a given directory, then the `interlock' program is
723 # required to allow parallel builds to work correctly. FIXME:
724 # for now, no line number.
725 &require_config_file ($FOREIGN, 'interlock', 'ylwrap');
726 &define_variable ('INTERLOCK', $config_aux_dir . "/interlock");
727 &define_variable ('YLWRAP', $config_aux_dir . "/ylwrap");
733 local (@cxx_list) = keys %cxx_extensions;
734 local ($cxx_count) = scalar @cxx_list;
737 push (@suffixes, @cxx_list);
739 &define_variable ("CXX", "\@CXX\@");
740 &define_variable ("CXXFLAGS", "\@CXXFLAGS\@");
741 &define_variable ('CXXCOMPILE', '$(CXX) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CXXFLAGS)');
742 &define_variable ('CXXLINK', '$(CXX) $(LDFLAGS) -o $@');
745 foreach $ext (@cxx_list)
747 $output_rules .= ("$ext.o:\n"
748 . "\t\$(CXXCOMPILE) -c \$<\n");
751 if (! $seen_prog_cxx)
753 &am_error ("C++ source seen but \`AC_PROG_CXX' not in \`configure.in'\n");
758 # Last, handle some C cleanup.
762 &define_variable ('CC', "\@CC\@");
763 &define_variable ('CFLAGS', "\@CFLAGS\@");
764 &define_variable ('COMPILE',
765 '$(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)');
766 &define_variable ('LINK', '$(CC) $(LDFLAGS) -o $@');
770 # Handle SOURCE->OBJECT transform for one program or library.
772 # canonical (transformed) name of object to build
773 # actual name of object to build
774 # object extension (ie either `.o' or `$o'.
775 # Return result is name of linker variable that must be used.
776 # Empty return means just use `LINK'.
777 sub handle_source_transform
779 # one_file is canonical name. unxformed is given name. obj is
781 local ($one_file, $unxformed, $obj) = @_;
782 local ($objpat) = $obj;
783 $objpat =~ s/(\W)/\\$1/g;
784 # Handle explicit `.o' as well as whatever we're passed.
785 $objpat = '(' . $objpat . "|\\.o)";
787 local ($linker) = '';
789 if (&variable_defined ($one_file . "_OBJECTS"))
791 &am_line_error ($one_file . '_OBJECTS',
792 $one_file . '_OBJECTS', 'should not be defined');
793 # No point in continuing.
799 foreach $prefix ('', 'EXTRA_')
802 if (&variable_defined ($prefix . $one_file . "_SOURCES"))
804 push (@sources, '$(' . $prefix . $one_file . "_SOURCES)");
805 push (@objects, '$(' . $prefix . $one_file . "_OBJECTS)")
806 unless $prefix eq 'EXTRA_';
807 @files = &variable_value_as_list ($prefix
808 . $one_file . "_SOURCES");
810 elsif ($prefix eq '')
812 &define_variable ($one_file . "_SOURCES", $unxformed . ".c");
813 push (@sources, $unxformed . '.c');
814 push (@objects, $unxformed . $obj);
815 push (@files, $unxformed . '.c');
819 &define_variable ("EXTRA_" . $one_file . "_SOURCES", '');
824 # Turn sources into objects.
825 local (@result) = ();
828 # If an automatically-discovered source file is
829 # mentioned, that is an error.
830 if (defined $libsources{$_})
832 # FIXME: saving $_ is stupid.
834 &am_line_error ($prefix . $one_file . '_SOURCES',
835 "automatically discovered file \`$_' should not be explicitly mentioned");
839 # Skip header files, including C++-ish ones. The list
840 # of C++ header extensions comes from Emacs 19.32
847 # Skip things that look like configure substitutions.
850 # Include .c file for lex or yacc source in distribution.
854 &push_dist_common ($1 . '.c');
855 $yacc_sources{$_} = 1;
860 &push_dist_common ($1 . '.c');
861 $lex_sources{$_} = 1;
864 # Transform source files into .o files. List of C++
865 # extensions comes from Emacs 19.32 etags.
872 $cxx_extensions{$&} = 1;
877 # FORTRAN support. FIXME: not finished.
881 # C, yacc, and lex need special $obj extension,
882 # for de-ansification. Hopefully someday this
886 # .f and .F is fortran. .s is assembly. .M is
887 # Objective-C++. .m is Objective-C.
890 # FIXME: of course, this should only happen for C
891 # source. The multi-language support must really
892 # be cleaned up more globally.
897 unless $prefix eq 'EXTRA_';
899 # Transform .o or $o file into .P file (for automatic
902 $dep_files{'.deps/' . $_} = 1;
905 &define_pretty_variable ($one_file . "_OBJECTS", @result)
906 unless $prefix eq 'EXTRA_';
910 if (&variable_defined ('CONFIG_HEADER'))
912 $output_rules .= ('$(' . $one_file . "_OBJECTS): "
913 . $contents{'CONFIG_HEADER'} . "\n");
919 # Special-case @ALLOCA@ and @LIBOBJS@ in _LDADD or _LIBADD variables.
920 # Also, generate _DEPENDENCIES variable if appropriate.
922 # transformed name of object being built, or empty string if no object
923 # name of _LDADD/_LIBADD-type variable to examine
924 # boolean (lex_seen) which is true if a lex source file was seen in this
925 # object. valid only for LDADDs, not LIBADDs. If set, LEXLIB
927 sub handle_lib_objects
929 local ($xname, $var, $lex_seen) = @_;
931 die "programming error 1 in handle_lib_objects"
932 if ! &variable_defined ($var);
934 die "programming error 2 in handle_lib_objects"
935 if $lex_seen && $var =~ /LIBADD/;
937 # We recognize certain things that are commonly put in LIBADD or
940 local (@dep_list) = ();
942 # If no lex source seen, just assume this is ok.
943 local ($lex_ok) = $lex_seen ? 0 : 1;
945 foreach $lsearch (&variable_value_as_list ($var))
947 # Skip -lfoo and -Ldir.
948 next if $lsearch =~ /^-[lL]/;
950 # Assume we have a file of some sort, and push it onto the
951 # dependency list. Autoconf substitutions are not pushed;
952 # rarely is a new dependency substituted into (eg) foo_LDADD
953 # -- but "bad things (eg -lX11) are routinely substituted.
954 push (@dep_list, $lsearch)
955 unless $lsearch =~ /^\@.*\@$/;
957 # Automatically handle @LIBOBJS@ and @ALLOCA@. Basically this
958 # means adding entries to dep_files.
959 if ($lsearch eq '@LIBOBJS@')
961 if (! keys %libsources)
963 &am_line_error ($var, "\@LIBOBJS\@ seen but never set in \`configure.in'");
966 local ($iter, $rewrite);
967 foreach $iter (keys %libsources)
971 &require_file_with_line ($var, $FOREIGN, $iter);
973 elsif ($iter ne 'alloca.c')
975 ($rewrite = $iter) =~ s/\.c$/.P/;
976 $dep_files{'.deps/' . $rewrite} = 1;
977 &require_file_with_line ($var, $FOREIGN, $iter);
981 elsif ($lsearch eq '@ALLOCA@')
983 &am_line_error ($var,
984 "\@ALLOCA\@ seen but \`AC_FUNC_ALLOCA' not in \`configure.in'")
985 if ! defined $libsources{'alloca.c'};
986 $dep_files{'.deps/alloca.P'} = 1;
987 &require_file_with_line ($var, $FOREIGN, 'alloca.c');
989 elsif ($lsearch eq '@LEXLIB@')
991 # FIXME: variable_value_as_list requires us to force
992 # @LEXLIB@ here, where we're really prefer $(LEXLIB).
993 # Nasty -- this will have to wait until many cleanups are
1002 &am_line_error ($var, 'lex source file used without @LEXLIB@');
1005 if ($xname ne '' && ! &variable_defined ($xname . '_DEPENDENCIES'))
1007 &define_pretty_variable ($xname . '_DEPENDENCIES', @dep_list);
1011 # Handle C programs.
1014 local (@proglist) = &am_install_var ('-clean',
1015 'progs', 'PROGRAMS',
1016 'bin', 'sbin', 'libexec', 'pkglib',
1018 return if ! @proglist;
1020 # If a program is installed, this is required. We only want this
1021 # error to appear once.
1022 &am_conf_error ("AC_ARG_PROGRAM must be used in configure.in")
1023 unless $seen_arg_prog;
1026 local ($obj) = &get_object_extension;
1027 local ($one_file, $xname, $munge);
1029 foreach $one_file (@proglist)
1031 # Canonicalize names.
1032 ($xname = $one_file) =~ tr/A-Za-z0-9_/_/c;
1033 if ($xname ne $one_file)
1036 foreach $xt ('_LDADD', '_SOURCES', '_OBJECTS', '_DEPENDENCIES')
1038 &am_line_error ($one_file . $xt,
1039 "invalid variable \`" . $one_file . $xt
1040 . "'; should be \`" . $xname . $xt . "'")
1041 if &variable_defined ($one_file . $xt);
1045 # FIXME: Using a trick to figure out if any lex sources appear
1046 # in our program; should use some cleaner method.
1047 local ($lex_num) = scalar (keys %lex_sources);
1048 local ($linker) = &handle_source_transform ($xname, $one_file, $obj);
1049 local ($lex_file_seen) = (scalar (keys %lex_sources) > $lex_num);
1051 if (&variable_defined ($xname . "_LDADD"))
1053 &handle_lib_objects ($xname, $xname . '_LDADD', $lex_file_seen);
1058 # User didn't define prog_LDADD override. So do it.
1059 &define_variable ($xname . '_LDADD', '$(LDADD)');
1061 # This does a bit too much work. But we need it to
1062 # generate _DEPENDENCIES when appropriate.
1063 if (&variable_defined ('LDADD'))
1065 &handle_lib_objects ($xname, 'LDADD', $lex_file_seen);
1072 &am_line_error ($one_file . $xt,
1073 'lex source file used without @LEXLIB@');
1076 # Determine program to use for link.
1078 if (&variable_defined ($xname . '_LINK'))
1080 $xlink = $xname . '_LINK';
1084 $xlink = $linker ? $linker : 'LINK';
1088 &file_contents_with_transform
1089 ('s/\@PROGRAM\@/' . $one_file . '/go;'
1090 . 's/\@XPROGRAM\@/' . $xname . '/go;'
1091 . 's/\@XLINK\@/' . $xlink . '/go;',
1095 &handle_lib_objects ('', 'LDADD', 0)
1096 if &variable_defined ('LDADD');
1100 sub handle_libraries
1102 local (@liblist) = &am_install_var ('-no-all', '-clean',
1103 'libs', 'LIBRARIES',
1104 'lib', 'pkglib', 'noinst', 'check');
1105 return if ! @liblist;
1107 local (%valid) = &am_primary_prefixes ('LIBRARIES', 'lib', 'pkglib',
1112 foreach $key (keys %valid)
1114 if (&variable_defined ($key . '_LIBRARIES'))
1116 &am_line_error ($key . '_LIBRARIES', "library requires either \`AC_PROG_RANLIB' or `AM_PROG_LIBTOOL' in configure.in");
1117 # Only get this error once.
1124 # Generate _LIBFILES variables. Too bad we can't do this in
1126 local ($onedir, $onelib);
1128 local (@libfiles_list);
1129 foreach $onedir (keys %valid)
1131 if (&variable_defined ($onedir . '_LIBRARIES'))
1134 foreach $onelib (&variable_value_as_list ($onedir . '_LIBRARIES'))
1136 push (@outlist, 'lib' . $onelib . '.a');
1138 &define_pretty_variable ($onedir . '_LIBFILES', @outlist);
1141 push (@libfiles_list, '$(' . $onedir . '_LIBFILES)')
1142 unless $onedir eq 'EXTRA';
1144 push (@all, '$(LIBFILES)');
1146 local ($obj) = &get_object_extension;
1149 foreach $onelib (@liblist)
1151 # Canonicalize names.
1152 ($xlib = $onelib) =~ tr/A-Za-z0-9_/_/c;
1153 if ($xlib ne $onelib)
1156 foreach $xt ('_LIBADD', '_SOURCES', '_OBJECTS', '_DEPENDENCIES')
1158 &am_line_error ($one_file . $xt,
1159 "invalid variable \`" . $onelib . $xt
1160 . "'; should be \`" . $xlib . $xt . "'")
1161 if &variable_defined ($onelib . $xt);
1165 if (&variable_defined ($xlib . '_LIBADD'))
1167 &handle_lib_objects ($xlib, $xlib . '_LIBADD', 0);
1171 # Generate support for conditional object inclusion in
1173 &define_variable ($xlib . "_LIBADD", '');
1176 &handle_source_transform ($xlib, $onelib, $obj);
1179 &file_contents_with_transform ('s/\@LIBRARY\@/' . $onelib . '/go;'
1185 # Turn "foo" into "libfoo.a" and include macro definition.
1186 grep (($_ = 'lib' . $_ . '.a') && 0, @liblist);
1188 if (! &variable_defined ('LIBFILES'))
1190 &define_pretty_variable ('LIBFILES ', @libfiles_list);
1195 &define_variable ('AR', '$(LIBTOOL) archive');
1196 &define_variable ('RANLIB', '$(LIBTOOL) ranlib');
1197 &define_variable ('LCOMPILE', ('$(LIBTOOL) compile $(DEFS) $(INCLUDES)'
1198 . ' $(CPPFLAGS) $(CFLAGS)'));
1202 &define_variable ('AR', 'ar');
1203 &define_variable ('RANLIB', '@RANLIB@');
1207 # See if any _SOURCES variable were misspelled.
1210 local ($varname, $primary);
1211 foreach $varname (keys %contents)
1213 foreach $primary ('_SOURCES', '_LIBADD', '_LDADD', '_DEPENDENCIES')
1215 if ($varname =~ /$primary$/ && ! $content_seen{$varname})
1217 &am_line_error ($varname,
1218 "invalid unused variable name: \`$varname'");
1227 # NOTE we no longer automatically clean SCRIPTS, because it is
1228 # useful to sometimes distribute scripts verbatim. This happens
1229 # eg in Automake itself.
1230 &am_install_var ('scripts', 'SCRIPTS',
1231 'bin', 'sbin', 'libexec', 'pkgdata',
1234 # Set $scripts_installed if appropriate. Make sure we only find
1235 # scripts which are actually installed -- this is why we can't
1236 # simply use the return value of am_install_var.
1237 local (%valid) = &am_primary_prefixes ('SCRIPTS', 'bin', 'sbin',
1238 'libexec', 'pkgdata',
1241 foreach $key (keys %valid)
1243 if ($key ne 'noinst'
1245 && &variable_defined ($key . '_SCRIPTS'))
1247 $scripts_installed = 1;
1248 # push (@check, 'check-' . $key . 'SCRIPTS');
1252 if ($scripts_installed)
1254 # If a program is installed, this is required. We only want this
1255 # error to appear once.
1256 &am_conf_error ("AC_ARG_PROGRAM must be used in configure.in")
1257 unless $seen_arg_prog;
1262 # Search a file for a "version.texi" Texinfo include. Return the name
1263 # of the include file if found, or the empty string if not. A
1264 # "version.texi" file is actually any file whose name matches
1266 sub grep_for_vers_texi
1268 local ($filename) = @_;
1270 if (! open (TEXI, $filename))
1272 &am_error ("couldn't open \`$filename': $!");
1275 print "automake: reading $filename\n" if $verbose;
1279 if (/^\@include\s+(vers[^.]*\.texi)\s*$/)
1291 # Handle all Texinfo source.
1294 &am_line_error ('TEXINFOS',
1295 "\`TEXINFOS' is an anachronism; use \`info_TEXINFOS'")
1296 if &variable_defined ('TEXINFOS');
1297 return if (! &variable_defined ('info_TEXINFOS')
1298 && ! &variable_defined ('html_TEXINFOS'));
1300 local (@texis) = &variable_value_as_list ('info_TEXINFOS');
1302 local (@infos_list, @info_deps_list, @dvis_list, @texi_deps);
1303 local ($infobase, $info_cursor);
1307 local ($tc_cursor, @texi_cleans);
1310 foreach $info_cursor (@texis)
1312 ($infobase = $info_cursor) =~ s/\.texi(nfo)?$//;
1314 # If 'version.texi' is referenced by input file, then include
1315 # automatic versioning capability.
1317 = &grep_for_vers_texi ($relative_dir . "/" . $info_cursor);
1320 &am_error ("\`$vtexi', included in \`$info_cursor', also included in \`$versions{$vtexi}'")
1321 if (defined $versions{$vtexi});
1322 $versions{$vtexi} = $info_cursor;
1324 # We number the stamp-vti files. This is doable since the
1325 # actual names don't matter much. We only number starting
1326 # with the second one, so that the common case looks nice.
1327 $vti = 'vti' . ($done ? $done : '');
1328 &push_dist_common ($vtexi, 'stamp-' . $vti);
1329 push (@clean, $vti);
1331 # Only require once.
1332 &require_conf_file_with_line ('info_TEXINFOS', $FOREIGN,
1338 ($conf_pat = $config_aux_dir) =~ s/(\W)/\\$1/g;
1340 &file_contents_with_transform
1341 ('s/\@TEXI\@/' . $info_cursor . '/g; '
1342 . 's/\@VTI\@/' . $vti . '/g; '
1343 . 's/\@VTEXI\@/' . $vtexi . '/g;'
1344 . 's,\@MDDIR\@,' . $conf_pat . ',g;',
1347 &push_phony_cleaners ($vti);
1350 # If user specified file_TEXINFOS, then use that as explicit
1353 push (@texi_deps, $info_cursor);
1354 push (@texi_deps, $vtexi) if $vtexi;
1356 # Canonicalize name first.
1357 ($canonical = $infobase) =~ tr/A-Za-z0-9_/_/c;
1358 if (&variable_defined ($canonical . "_TEXINFOS"))
1360 push (@texi_deps, '$(' . $canonical . '_TEXINFOS)');
1361 &push_dist_common ('$(' . $canonical . '_TEXINFOS)');
1364 $output_rules .= ("\n" . $infobase . ".info: "
1365 . join (' ', @texi_deps)
1366 . "\n" . $infobase . ".dvi: "
1367 . join (' ', @texi_deps)
1370 # FIXME: this distributes too much. How to find out precisely
1371 # which files will be generated by `makeinfo'?
1372 push (@infos_list, $infobase . '.info', $infobase . '.info[-0-9]*');
1373 push (@info_deps_list, $infobase . '.info');
1374 push (@dvis_list, $infobase . '.dvi');
1376 # Generate list of things to clean for this target. We do
1377 # this explicitly because otherwise too many things could be
1378 # removed. In particular the ".log" extension might
1379 # reasonably be used in other contexts by the user.
1380 foreach $tc_cursor ('aux', 'cp', 'cps', 'dvi', 'fn', 'fns',
1381 'ky', 'log', 'pg', 'toc', 'tp', 'vr', 'op')
1383 push (@texi_cleans, $infobase . '.' . $tc_cursor);
1388 $output_vars .= &file_contents ('texi-vars');
1389 $output_rules .= &file_contents ('texinfos');
1390 push (@phony, 'install-info', 'uninstall-info');
1393 $output_rules .= "\nmostlyclean-info:\n";
1394 &pretty_print_rule ("\trm -f", "\t ", @texi_cleans);
1395 $output_rules .= ("\nclean-info:\n\ndistclean-info:\n\n"
1396 . "maintainer-clean-info:\n\t"
1397 . 'rm -f $(INFOS)' . "\n");
1398 &push_phony_cleaners ('info');
1400 push (@suffixes, '.texi', '.texinfo', '.info', '.dvi');
1402 if (! defined $options{'no-installinfo'})
1404 push (@uninstall, 'uninstall-info');
1405 push (@installdirs, '$(infodir)');
1406 unshift (@install_data, 'install-info');
1408 # Make sure documentation is made and installed first. Use
1409 # $(INFO_DEPS), not 'info', because otherwise recursive makes
1410 # get run twice during "make all".
1411 unshift (@all, '$(INFO_DEPS)');
1413 push (@clean, 'info');
1414 push (@info, '$(INFO_DEPS)');
1415 push (@dvi, '$(DVIS)');
1417 &define_variable ("INFOS", join (' ', @infos_list));
1418 &define_variable ("INFO_DEPS", join (' ', @info_deps_list));
1419 &define_variable ("DVIS", join (' ', @dvis_list));
1420 # This next isn't strictly needed now -- the places that look here
1421 # could easily be changed to look in info_TEXINFOS. But this is
1422 # probably better, in case noinst_TEXINFOS is ever supported.
1423 &define_variable ("TEXINFOS", $contents{'info_TEXINFOS'});
1425 # Do some error checking.
1426 &require_file_with_line ('info_TEXINFOS', $FOREIGN, 'texinfo.tex');
1429 # Handle any man pages.
1430 sub handle_man_pages
1432 &am_line_error ('MANS', "\`MANS' is an anachronism; use \`man_MANS'")
1433 if &variable_defined ('MANS');
1434 return if ! &variable_defined ('man_MANS');
1436 # We generate the manpage install code by hand to avoid the use of
1437 # basename in the generated Makefile.
1438 local (@mans) = &variable_value_as_list ('man_MANS');
1439 local (%sections, %inames, %mbases, %secmap, %fullsecmap);
1443 # FIXME: statement without effect:
1444 /^(.*)\.([0-9])([a-z]*)$/;
1449 $fullsecmap{$i} = $2 . $3;
1453 # We don't really need this, but we use it in case we ever want to
1454 # support noinst_MANS.
1455 &define_variable ("MANS", $contents{'man_MANS'});
1457 # Generate list of install dirs.
1458 $output_rules .= "install-man: \$(MANS)\n";
1459 $output_rules .= "\t\$(NORMAL_INSTALL)\n";
1460 foreach (keys %sections)
1462 push (@installdirs, '$(mandir)/man' . $_)
1463 unless defined $options{'no-installman'};
1464 $output_rules .= ("\t" . '$(mkinstalldirs) $(mandir)/man'
1467 push (@phony, 'install-man');
1469 # Generate install target.
1471 foreach $key (keys %inames)
1473 $_ = $install_man_format;
1474 s/\@SECTION\@/$secmap{$key}/g;
1475 s/\@MAN\@/$inames{$key}/g;
1476 s/\@FULLSECT\@/$fullsecmap{$key}/g;
1477 s/\@MANBASE\@/$mbases{$key}/g;
1478 $output_rules .= $_;
1480 $output_rules .= "\n";
1482 $output_rules .= "uninstall-man:\n";
1483 foreach $key (keys %inames)
1485 $_ = $uninstall_man_format;
1486 s/\@SECTION\@/$secmap{$key}/g;
1487 s/\@MAN\@/$inames{$key}/g;
1488 s/\@FULLSECT\@/$fullsecmap{$key}/g;
1489 s/\@MANBASE\@/$mbases{$key}/g;
1490 $output_rules .= $_;
1492 $output_rules .= "\n";
1493 push (@phony, 'uninstall-man');
1495 $output_vars .= &file_contents ('mans-vars');
1497 if (! defined $options{'no-installman'})
1499 push (@install_data, 'install-man');
1500 push (@uninstall, 'uninstall-man');
1501 push (@all, '$(MANS)');
1505 # Handle DATA variables.
1508 &am_install_var ('data', 'DATA', 'data', 'sysconf',
1509 'sharedstate', 'localstate', 'pkgdata',
1516 local ($tagging) = 0;
1518 push (@phony, 'tags');
1519 if (&variable_defined ('SUBDIRS'))
1521 $output_rules .= &file_contents ('tags');
1522 push (@phony, 'tags-recursive');
1525 elsif ($dir_holds_sources
1526 || $dir_holds_headers
1527 || &variable_defined ('ETAGS_ARGS'))
1529 $output_rules .= &file_contents ('tags-subd');
1532 elsif (&variable_defined ('TAGS_DEPENDENCIES'))
1534 &am_line_error ('TAGS_DEPENDENCIES',
1535 "doesn't make sense to define \`TAGS_DEPENDENCIES' without sources or \`ETAGS_ARGS'");
1540 $output_rules .= &file_contents ('tags-clean');
1541 push (@clean, 'tags');
1542 &push_phony_cleaners ('tags');
1543 &examine_variable ('TAGS_DEPENDENCIES');
1547 # Every Makefile must define some sort of TAGS rule.
1548 # Otherwise, it would be possible for a top-level "make TAGS"
1549 # to fail because some subdirectory failed.
1550 $output_rules .= "tags: TAGS\nTAGS:\n\n";
1554 # Worker for handle_dist.
1555 sub handle_dist_worker
1557 $output_rules .= 'distdir: $(DEP_DISTFILES)' . "\n";
1559 # Initialization; only at top level.
1560 if ($relative_dir eq '.')
1562 if ($strictness >= $GNITS)
1564 # For Gnits users, this is pretty handy. Look at 15 lines
1565 # in case some explanatory text is desirable.
1566 $output_rules .= ' @if sed 15q $(srcdir)/NEWS | fgrep -e "$(VERSION)" > /dev/null; then :; else \\
1567 echo "NEWS not updated; not releasing" 1>&2; \\
1575 # Create dist directory.
1578 -chmod 755 $(distdir)
1581 # Only run automake in `dist' target if --include-deps not
1582 # specified. That way the recipient of a distribution can run
1583 # "make dist" and not need Automake.
1584 if ($cmdline_use_dependencies)
1588 # We need an absolute path for --output-dir. Thus the
1590 ' here=`pwd`; distdir=`cd $(distdir) && pwd` \\
1592 && automake --include-deps --build-dir=$$here --srcdir-name=$(srcdir) --output-dir=$$distdir --strictness='
1593 # Set strictness of output.
1594 . $strictness_name . "\n"
1599 # Scan EXTRA_DIST to see if we need to distribute anything from a
1600 # subdir. If so, add it to the list. I didn't want to do this
1601 # originally, but there were so many requests that I finally
1604 if (&variable_defined ('EXTRA_DIST'))
1606 foreach (&variable_value_as_list ('EXTRA_DIST'))
1609 next unless s,/+[^/]+$,,;
1610 push (@dist_dirs, $_)
1614 if (&variable_defined ('EXTRA_DIST_DIRS'))
1616 push (@dist_dirs, &variable_value_as_list ('EXTRA_DIST_DIRS'));
1620 # Prepend $(distdir) to each directory given. Doing it via a
1621 # hash lets us ensure that each directory is used only once.
1623 grep ($dhash{'$(distdir)/' . $_} = 1, @dist_dirs);
1624 $output_rules .= "\t";
1625 &pretty_print_rule ('$(mkinstalldirs)', "\t ", sort keys %dhash);
1628 # In loop, test for file existence because sometimes a file gets
1629 # included in DISTFILES twice. For example this happens when a
1630 # single source file is used in building more than one program.
1631 # Also, there are situations in which "ln" can fail. For instance
1632 # a file to distribute could actually be a cross-filesystem
1633 # symlink -- this can easily happen if "gettextize" was run on the
1634 # distribution. Note that DISTFILES can contain a wildcard (for
1635 # info files, sigh), so we must use the echo trick.
1636 $output_rules .= ' @for file in `cd $(srcdir) && echo $(DISTFILES)`; do \\
1637 test -f $(distdir)/$$file \\
1638 || ln $(srcdir)/$$file $(distdir)/$$file 2> /dev/null \\
1639 || cp -p $(srcdir)/$$file $(distdir)/$$file; \\
1643 # If we have SUBDIRS, create all dist subdirectories and do
1645 if (&variable_defined ('SUBDIRS'))
1647 # Test for directory existence here because previous automake
1648 # invocation might have created some directories. Note that
1649 # we explicitly set distdir for the subdir make; that lets us
1650 # mix-n-match many automake-using packages into one large
1651 # package, and have "dist" at the top level do the right
1653 $output_rules .= ' for subdir in $(SUBDIRS); do \\
1654 test -d $(distdir)/$$subdir \\
1655 || mkdir $(distdir)/$$subdir \\
1657 chmod 755 $(distdir)/$$subdir; \\
1658 (cd $$subdir && $(MAKE) distdir=../$(distdir)/$$subdir distdir) \\
1664 # If the target `dist-hook' exists, run it now. This allows
1665 # users to do random weird things to the distribution before it is
1667 if (defined $contents{'dist-hook'})
1669 $output_rules .= "\t\$(MAKE) dist-hook\n";
1672 push (@phony, 'distdir');
1675 # Handle 'dist' target.
1678 # Set up maint_charset.
1679 $local_maint_charset = $contents{'MAINT_CHARSET'}
1680 if &variable_defined ('MAINT_CHARSET');
1681 $maint_charset = $local_maint_charset
1682 if $relative_dir eq '.';
1684 if (&variable_defined ('DIST_CHARSET'))
1686 &am_line_error ('DIST_CHARSET',
1687 "DIST_CHARSET defined but no MAINT_CHARSET defined")
1688 if ! $local_maint_charset;
1689 if ($relative_dir eq '.')
1691 $dist_charset = $contents{'DIST_CHARSET'}
1695 &am_line_error ('DIST_CHARSET',
1696 "DIST_CHARSET can only be defined at top level");
1700 # Look for common files that should be included in distribution.
1702 foreach $cfile (@common_files)
1704 if (-f ($relative_dir . "/" . $cfile))
1706 &push_dist_common ($cfile);
1710 # Keys of %dist_common are names of files to distributed. We put
1711 # README first because it then becomes easier to make a
1712 # Usenet-compliant shar file (in these, README must be first).
1713 # FIXME: do more ordering of files here.
1715 if (defined $dist_common{'README'})
1717 push (@coms, 'README');
1718 undef $dist_common{'README'};
1720 push (@coms, sort keys %dist_common);
1722 &define_pretty_variable ("DIST_COMMON", @coms);
1723 $output_vars .= "\n";
1726 $output_vars .= &file_contents ('dist-vars');
1728 # Put these things in rules section so it is easier for whoever
1729 # reads Makefile.in.
1730 if (! &variable_defined ('distdir'))
1732 if ($relative_dir eq '.')
1734 $output_rules .= "\n" . 'distdir = $(PACKAGE)-$(VERSION)' . "\n";
1738 $output_rules .= ("\n"
1739 . 'distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)'
1743 if ($relative_dir ne '.')
1745 $output_rules .= "\nsubdir = " . $relative_dir . "\n";
1748 # Generate 'dist' target, and maybe dist-shar / dist-zip / dist-tarZ.
1749 if ($relative_dir eq '.')
1751 # Rule to check whether a distribution is viable.
1752 $output_rules .= ('# This target untars the dist file and tries a VPATH configuration. Then
1753 # it guarantees that the distribution is self-contained by making another
1757 $(TAR) zxf $(distdir).tar.gz
1758 mkdir $(distdir)/=build
1759 mkdir $(distdir)/=inst
1760 dc_install_base=`cd $(distdir)/=inst && pwd`; \\'
1761 . (defined $contents{'distcheck-hook'}
1762 ? "\t\$(MAKE) distcheck-hook"
1765 cd $(distdir)/=build \\
1768 . ($seen_gettext ? '--with-included-gettext ' : '')
1769 . '--srcdir=.. --prefix=$$dc_install_base \\
1773 && $(MAKE) install \\
1774 && $(MAKE) installcheck \\
1777 @echo "========================"; \\
1778 echo "$(distdir).tar.gz is ready for distribution"; \\
1779 echo "========================"
1782 local ($dist_all) = ('dist-all: distdir' . "\n"
1785 foreach $curs ('dist', 'dist-shar', 'dist-zip', 'dist-tarZ')
1787 if (defined $options{$curs} || $curs eq 'dist')
1789 $output_rules .= ($curs . ': distdir' . "\n"
1793 $dist_all .= $dist{$curs};
1796 $output_rules .= $dist_all . $dist_trailer;
1799 # Generate distdir target.
1800 &handle_dist_worker;
1803 # Scan a single dependency file and rewrite the dependencies as
1804 # appropriate. Essentially this means:
1805 # * Clean out absolute dependencies which are not desirable.
1806 # * Rewrite other dependencies to be relative to $(top_srcdir).
1807 sub scan_dependency_file
1809 local ($depfile) = @_;
1811 if (! open (DEP_FILE, $depfile))
1813 &am_error ("couldn't open \`$depfile': $!");
1816 print "automake: reading $depfile\n" if $verbose;
1818 local ($first_line) = 1;
1819 local ($last_line) = 0;
1820 local ($target, @dependencies);
1821 local ($one_dep, $xform);
1823 local ($srcdir_rx, $fixup_rx);
1824 # If the top srcdir is absolute, then the current directory is
1825 # just relative_dir. But if the top srcdir is relative, then we
1826 # need to add some dots first. The same holds when matching
1828 if ($srcdir_name =~ /^\//)
1830 ($fixup_rx = $srcdir_name . '/' . $relative_dir . '/')
1832 ($srcdir_rx = $srcdir_name) =~ s/(\W)/\\$1/g;
1836 ($fixup_rx = ($srcdir_name . '/' . $top_builddir . '/'
1837 . $relative_dir . '/')) =~ s/(\W)/\\$1/g;
1838 ($srcdir_rx = ($srcdir_name . '/' . $top_builddir))
1846 # If LAST_LINE set then we've already seen what we thought
1847 # was the last line.
1850 next if (/$WHITE_PATTERN/o);
1854 # No trailing "\" means this should be the last line.
1860 if (! /^([^:]+:)(.+)$/)
1863 &am_error ("\`$depfile' has incorrect format");
1874 foreach $one_dep (split (' ', $_))
1876 if ($one_dep =~ /^$fixup_rx/)
1878 # The dependency points to the current directory in
1880 ($xform = $one_dep) =~ s/^$fixup_rx//;
1881 push (@dependencies, $xform);
1883 elsif ($one_dep =~ /^$srcdir_rx\//)
1885 # The dependency is in some other directory in the package.
1886 ($xform = $one_dep) =~ s/^$srcdir_rx/$top_builddir/;
1887 push (@dependencies, $xform);
1889 elsif ($one_dep =~ /^\//)
1891 # Absolute path; ignore.
1895 # Anything else is assumed to be correct.
1896 push (@dependencies, $one_dep);
1901 &pretty_print_rule ($target, "\t", @dependencies);
1906 # Handle auto-dependency code.
1907 sub handle_dependencies
1909 if ($use_dependencies)
1911 # Include GNU-make-specific auto-dep code.
1912 if ($dir_holds_sources)
1914 &define_pretty_variable ('DEP_FILES', sort keys %dep_files);
1915 $output_rules .= &file_contents ('depend');
1916 push (@clean, 'depend');
1917 &push_phony_cleaners ('depend');
1919 &file_contents_with_transform ('s/\@EXT\@/.c/g;'
1920 . 's/\@MKDEP\@/MKDEP/g',
1923 local ($need_cxx) = 0;
1924 foreach $ext (keys %cxx_extensions)
1927 &file_contents_with_transform ('s/\@EXT\@/' . $ext .'/g;'
1928 . 's/\@MKDEP\@/CXXMKDEP/g',
1934 &define_variable ('CXXMKDEP', '$(CXX) -MM $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CXXFLAGS)');
1940 # FIXME: consider requiring --build-dir here. What about case
1941 # where this is done via an option?
1943 # Include any auto-generated deps that are present. Note that
1944 # $build_directory ends in a "/".
1945 if (-d ($build_directory . $relative_dir . "/.deps")
1946 && -f ($build_directory . $relative_dir . "/.deps/.P"))
1949 local ($gpat) = $build_directory . $relative_dir . "/.deps/*.P";
1951 foreach $depfile (<${gpat}>)
1953 &scan_dependency_file ($depfile);
1956 $output_rules .= "\n";
1961 # Handle subdirectories.
1964 return if ! &variable_defined ('SUBDIRS');
1966 # Make sure each directory mentioned in SUBDIRS actually exists.
1968 foreach $dir (&variable_value_as_list ('SUBDIRS'))
1970 # Skip directories substituted by configure.
1971 next if $dir =~ /^\@.*\@$/;
1972 &am_line_error ('SUBDIRS',
1973 "required directory $relative_dir/$dir does not exist")
1974 if ! -d $relative_dir . '/' . $dir;
1977 $output_rules .= &file_contents ('subdirs');
1979 # Push a bunch of phony targets.
1981 foreach $phonies ('-data', '-exec', 'dirs')
1983 push (@phony, 'install' . $phonies . '-recursive');
1984 push (@phony, 'uninstall' . $phonies . '-recursive');
1986 foreach $phonies ('all', 'check', 'installcheck', 'info', 'dvi')
1988 push (@phony, $phonies . '-recursive');
1990 &push_phony_cleaners ('recursive');
1992 push (@check, "check-recursive");
1993 push (@installcheck, "installcheck-recursive");
1994 push (@info, "info-recursive");
1995 push (@dvi, "dvi-recursive");
1997 $recursive_install = 1;
2000 # Handle aclocal.m4.
2001 sub handle_aclocal_m4
2003 local ($regen_aclocal) = 0;
2004 if (-f 'aclocal.m4')
2006 &define_variable ("ACLOCAL", "aclocal.m4");
2007 &push_dist_common ('aclocal.m4');
2009 if (open (ACLOCAL, '< aclocal.m4'))
2015 if ($line =~ 'generated automatically by aclocal')
2022 local ($acinclude) = 0;
2023 if (-f 'acinclude.m4')
2029 # Note that it might be possible that aclocal.m4 doesn't exist but
2030 # should be auto-generated. This case probably isn't very
2034 $output_rules .= ("aclocal.m4: "
2035 . ($seen_maint_mode ? "\@MAINT\@" : "")
2037 . ($acinclude ? ' acinclude.m4' : '')
2039 . 'cd $(srcdir) && aclocal'
2044 # Handle remaking and configure stuff.
2045 sub handle_configure
2047 # If SUBDIRS defined, require AC_PROG_MAKE_SET.
2048 &am_line_error ('SUBDIRS', "AC_PROG_MAKE_SET must be used in configure.in")
2049 if &variable_defined ('SUBDIRS') && ! $seen_make_set;
2051 local ($top_reldir);
2052 if ($relative_dir ne '.')
2055 $output_rules .= &file_contents ('remake-subd');
2056 $top_reldir = '../';
2061 $output_rules .= &file_contents_with_transform ('s/\@STRICTNESS\@/'
2065 &examine_variable ('CONFIGURE_DEPENDENCIES');
2069 # If we have a configure header, require it.
2070 if ($config_header && $relative_dir eq &dirname ($config_header))
2072 local ($ch_sans_dir) = &basename ($config_header);
2073 local ($cn_sans_dir) = &basename ($config_name);
2075 &require_file_with_conf_line ($config_header_line,
2076 $FOREIGN, $ch_sans_dir);
2078 # Header defined and in this directory.
2079 if (-f $relative_dir . '/acconfig.h')
2081 &define_variable ("ACCONFIG", "acconfig.h");
2082 &push_dist_common ('acconfig.h');
2084 if (-f $config_name . '.top')
2086 &define_variable ("CONFIG_TOP", "${cn_sans_dir}.top");
2087 &push_dist_common ($cn_sans_dir . '.top');
2089 if (-f $config_name . '.bot')
2091 &define_variable ("CONFIG_BOT", "${cn_sans_dir}.bot");
2092 &push_dist_common ($cn_sans_dir . '.bot');
2095 &touch ($relative_dir . '/stamp-h.in');
2096 &require_file_with_conf_line ($config_header_line, $FOREIGN,
2099 $output_rules .= &file_contents ('remake-hdr');
2100 push (@clean, 'hdr');
2101 &push_phony_cleaners ('hdr');
2102 &define_variable ("CONFIG_HEADER_IN", "${ch_sans_dir}");
2105 # Set location of mkinstalldirs.
2106 if ($config_aux_dir ne '.' && $config_aux_dir ne '')
2108 &define_variable ('mkinstalldirs', ('$(SHELL) ' . $config_aux_dir
2109 . '/mkinstalldirs'));
2113 &define_variable ('mkinstalldirs',
2114 '$(SHELL) $(top_srcdir)/mkinstalldirs');
2117 &am_line_error ('CONFIG_HEADER',
2118 "\`CONFIG_HEADER' is an anachronism; now determined from \`configure.in'")
2119 if &variable_defined ('CONFIG_HEADER');
2123 # Generate CONFIG_HEADER define.
2124 if ($relative_dir eq &dirname ($config_name))
2126 &define_variable ("CONFIG_HEADER", &basename ($config_name));
2130 &define_variable ("CONFIG_HEADER",
2131 "${top_builddir}/${config_name}");
2135 # Now look for other files in this directory which must be remade
2136 # by config.status, and generate rules for them.
2137 local (@actual_other_files) = ();
2138 local ($file, $local, $input);
2139 foreach $file (@other_input_files)
2141 # Skip files not in this directory, any Makefile, and the
2142 # config header. These last two must be handled specially.
2143 next unless &dirname ($file) eq $relative_dir;
2144 next if $file eq $top_builddir . '/' . $config_name;
2145 ($local = $file) =~ s/^.*\///;
2146 next if $local eq 'Makefile';
2148 if ($local =~ /^(.*):(.*)$/)
2150 # This is the ":" syntax of AC_OUTPUT.
2157 $input = $local . '.in';
2159 # FIXME: when using autoconf ":" syntax, should we set CONFIG_FILES
2161 $output_rules .= ($local . ': '
2162 . '$(top_builddir)/config.status ' . $input . "\n"
2164 . 'cd $(top_builddir) && CONFIG_FILES='
2165 . ($relative_dir eq '.' ? '' : '$(subdir)/')
2166 . '$@ CONFIG_HEADERS= ./config.status'
2168 push (@actual_other_files, $local);
2170 &require_file_with_conf_line ($ac_output_line, $FOREIGN,
2174 # These files get removed by "make clean".
2175 &define_pretty_variable ('CONFIG_CLEAN_FILES', @actual_other_files);
2181 $dir_holds_headers = &am_install_var ('header', 'HEADERS', 'include',
2182 'oldinclude', 'pkginclude',
2188 return if ! $seen_gettext || $relative_dir ne '.';
2190 if (! &variable_defined ('SUBDIRS'))
2193 ("ud_GNU_GETTEXT in configure.in but SUBDIRS not defined");
2197 &require_file_with_conf_line ($ac_gettext_line, $FOREIGN, 'ABOUT-NLS')
2200 if (&variable_defined ('SUBDIRS'))
2204 "ud_GNU_GETTEXT in configure.in but \`po' not in SUBDIRS")
2205 if $contents{'SUBDIRS'} !~ /\bpo\b/;
2208 "ud_GNU_GETTEXT in configure.in but \`intl' not in SUBDIRS")
2209 if $contents{'SUBDIRS'} !~ /\bintl\b/;
2212 # Ensure that each language in ALL_LINGUAS has a .po file, and
2213 # each po file is mentioned in ALL_LINGUAS.
2216 local (%linguas) = ();
2217 grep ($linguas{$_} = 1, split (' ', $all_linguas));
2224 &am_line_error ($all_linguas_line,
2225 ("po/$_.po exists but \`$_' not in \`ALL_LINGUAS'"))
2229 foreach (keys %linguas)
2231 &am_line_error ($all_linguas_line,
2232 "$_ in \`ALL_LINGUAS' but po/$_.po does not exist")
2238 &am_error ("ud_GNU_GETTEXT in configure.in but \`ALL_LINGUAS' not defined");
2242 # Handle footer elements.
2245 if ($contents{'SOURCES'})
2247 # NOTE don't use define_pretty_variable here, because
2248 # $contents{...} is already defined.
2249 $output_vars .= 'SOURCES = ' . $contents{'SOURCES'} . "\n";
2251 if ($contents{'OBJECTS'})
2253 # NOTE don't use define_pretty_variable here, because
2254 # $contents{...} is already defined.
2255 $output_vars .= 'OBJECTS = ' . $contents{'OBJECTS'} . "\n";
2257 if ($contents{'SOURCES'} || $contents{'OBJECTS'})
2259 $output_vars .= "\n";
2262 if (defined $contents{'SUFFIXES'})
2264 # Push actual suffixes, and not $(SUFFIXES). Some versions of
2265 # make do not like variable substitutions on the .SUFFIXES
2267 push (@suffixes, split (' ', $contents{'SUFFIXES'}));
2270 $output_trailer .= ".SUFFIXES:\n";
2273 $output_trailer .= ".SUFFIXES: " . join (' ', @suffixes) . "\n";
2275 $output_trailer .= &file_contents ('footer');
2278 # Deal with installdirs target.
2279 sub handle_installdirs
2281 # GNU Makefile standards recommend this.
2282 $output_rules .= ("installdirs:"
2283 . ($recursive_install
2284 ? " installdirs-recursive\n"
2286 push (@phony, 'installdirs');
2289 &pretty_print_rule ("\t" . '$(mkinstalldirs) ', "\t\t",
2292 $output_rules .= "\n";
2295 # There are several targets which need to be merged. This is because
2296 # their complete definition is compiled from many parts. Note that we
2297 # avoid double colon rules, otherwise we'd use them instead.
2298 sub handle_merge_targets
2300 # There are a few install-related variables that you should not define.
2302 foreach $var ('PRE_INSTALL', 'POST_INSTALL', 'NORMAL_INSTALL')
2304 if (&variable_defined ($var))
2306 &am_line_error ($var, "\`$var' should not be defined");
2310 push (@all, 'Makefile');
2311 push (@all, $config_name)
2312 if $config_name && &dirname ($config_name) eq $relative_dir;
2314 &do_one_merge_target ('info', @info);
2315 &do_one_merge_target ('dvi', @dvi);
2316 &do_one_merge_target ('check', @check);
2317 &do_one_merge_target ('installcheck', @installcheck);
2319 # Handle the various install targets specially. We do this so
2320 # that (eg) "make install-exec" will run "install-exec-recursive"
2321 # if required, but "make install" won't run it twice. Step one is
2322 # to see if the user specified local versions of any of the
2323 # targets we handle. "all" is treated as one of these since
2324 # "install" can run it.
2325 push (@install_exec, 'install-exec-local')
2326 if defined $contents{'install-exec-local'};
2327 push (@install_data, 'install-data-local')
2328 if defined $contents{'install-data-local'};
2329 push (@uninstall, 'uninstall-local')
2330 if defined $contents{'uninstall-local'};
2332 foreach $utarg ('uninstall-data-local', 'uninstall-data-hook',
2333 'uninstall-exec-local', 'uninstall-exec-hook')
2335 if (defined $contents{$utarg})
2338 ($x = $utarg) =~ s/(data|exec)-//;
2339 &am_line_error ($utarg, "use \`$x', not \`$utarg'");
2342 push (@all, 'all-local')
2343 if defined $contents{'all-local'};
2345 if (defined $contents{'install-local'})
2347 &am_line_error ('install-local',
2348 "use \`install-data' or \`install-exec', not \`install'");
2351 # Step two: if we are doing recursive makes, write out the
2352 # appropriate rules.
2354 if ($recursive_install)
2356 push (@install, 'install-recursive');
2360 local (@hackall) = ();
2361 if ($config_name && &dirname ($config_name) eq $relative_dir)
2364 # This is kind of a hack, but I couldn't see a better
2365 # way to handle it. In this particular case, we need
2366 # to make sure config.h is built before we recurse.
2367 # We can't do this by changing the order of
2368 # dependencies to the "all" because that breaks when
2369 # using parallel makes. Instead we handle things
2371 $output_rules .= ('all-recursive-hack: $(CONFIG_HEADER)'
2372 . "\n\t" . '$(MAKE) all-recursive'
2374 push (@hackall, 'all-recursive-hack');
2375 push (@phony, 'all-recursive-hack');
2379 push (@hackall, 'all-recursive');
2382 $output_rules .= ('all-am: '
2386 push (@all, 'all-am');
2387 push (@phony, 'all-am');
2391 @all = ('all-recursive');
2393 # Must always generate `all-am' target, so it can be
2394 # referred to elsewhere.
2395 $output_rules .= "all-am:\n";
2399 $output_rules .= ('install-exec-am: '
2400 . join (' ', @install_exec)
2402 @install_exec = ('install-exec-recursive', 'install-exec-am');
2403 push (@install, 'install-exec-am');
2404 push (@phony, 'install-exec-am');
2408 @install_exec = ('install-exec-recursive');
2412 $output_rules .= ('install-data-am: '
2413 . join (' ', @install_data)
2415 @install_data = ('install-data-recursive', 'install-data-am');
2416 push (@install, 'install-data-am');
2417 push (@phony, 'install-data-am');
2421 @install_data = ('install-data-recursive');
2425 $output_rules .= ('uninstall-am: '
2426 . join (' ', @uninstall)
2428 @uninstall = ('uninstall-recursive', 'uninstall-am');
2429 push (@phony, 'uninstall-am');
2433 @uninstall = ('uninstall-recursive');
2437 # Step three: print definitions users can use. Code below knows
2438 # that install-exec is done before install-data, beware.
2439 $output_rules .= ("install-exec: "
2440 . join (' ', @install_exec)
2442 $output_rules .= "\t\$(NORMAL_INSTALL)\n";
2443 if (defined $contents{'install-exec-hook'})
2445 $output_rules .= "\t" . '$(MAKE) install-exec-hook' . "\n";
2447 $output_rules .= "\n";
2448 push (@install, 'install-exec') if !$recursive_install;
2449 push (@phony, 'install-exec');
2451 $output_rules .= ("install-data: "
2452 . join (' ', @install_data)
2454 $output_rules .= "\t\$(NORMAL_INSTALL)\n";
2455 if (defined $contents{'install-data-hook'})
2457 $output_rules .= "\t" . '$(MAKE) install-data-hook' . "\n";
2459 $output_rules .= "\n";
2460 push (@install, 'install-data') if !$recursive_install;
2461 push (@phony, 'install-data');
2463 # If no dependencies for 'install', add 'all'. Why? That way
2464 # "make install" at top level of distclean'd distribution won't
2465 # fail because stuff in 'lib' fails to build.
2466 if (! @install || (scalar (@install) == 2
2467 && $install[0] eq 'install-exec'
2468 && $install[1] eq 'install-data'))
2470 push (@install, 'all');
2472 $output_rules .= ('install: '
2473 . join (' ', @install)
2474 # Use "@:" as empty command so nothing prints.
2478 . join (' ', @uninstall)
2480 push (@phony, 'install', 'uninstall');
2482 $output_rules .= ('all: '
2485 push (@phony, 'all');
2487 # Generate the new 'install-strip' target.
2488 $output_rules .= ("install-strip:\n\t"
2489 . '$(MAKE) INSTALL_PROGRAM=\'$(INSTALL_PROGRAM) -s\' install'
2493 # Helper for handle_merge_targets.
2494 sub do_one_merge_target
2496 local ($name, @values) = @_;
2498 if (defined $contents{$name . '-local'})
2500 # User defined local form of target. So include it.
2501 push (@values, $name . '-local');
2502 push (@phony, $name . '-local');
2506 if ($name eq 'check')
2508 if (! &variable_defined ('SUBDIRS'))
2510 # 'check' must depend on `all', but not when doing
2512 unshift (@values, 'all');
2516 # When subdirs are used, do the `all' build and then do
2517 # all the recursive stuff. Actually use `all-am' because
2518 # it doesn't recurse; we rely on the check target in the
2519 # subdirs to do the required builds there.
2520 $output_rules .= "check: all-am\n";
2521 &pretty_print_rule ("\t\$(MAKE)", "\t ", @values);
2526 &pretty_print_rule ($name . ":", "\t\t", @values)
2528 push (@phony, $name);
2531 # Handle all 'clean' targets.
2534 push (@clean, 'generic');
2535 $output_rules .= &file_contents ('clean');
2536 &push_phony_cleaners ('generic');
2538 local ($target) = $recursive_install ? 'clean-am' : 'clean';
2539 &do_one_clean_target ($target, 'mostly', '', @clean);
2540 &do_one_clean_target ($target, '', 'mostly', @clean);
2541 &do_one_clean_target ($target, 'dist', '', @clean);
2542 &do_one_clean_target ($target, 'maintainer-', 'dist', @clean);
2544 push (@phony, 'clean', 'mostlyclean', 'distclean', 'maintainer-clean');
2547 if ($recursive_install)
2549 @deps = ('am', 'recursive');
2550 &do_one_clean_target ('', 'mostly', '', @deps);
2551 &do_one_clean_target ('', '', '', @deps);
2552 &do_one_clean_target ('', 'dist', '', @deps);
2553 &do_one_clean_target ('', 'maintainer-', '', @deps);
2557 # Helper for handle_clean.
2558 sub do_one_clean_target
2560 local ($target, $name, $last_name, @deps) = @_;
2562 # Special case: if target not passed, then don't generate
2563 # dependency on next "lower" clean target (eg no
2564 # clean<-mostlyclean derivation). In this case the target is
2565 # implicitly known to be 'clean'.
2566 local ($flag) = $target;
2567 $target = 'clean' if ! $flag;
2569 grep (($_ = $name . 'clean-' . $_) && 0, @deps);
2572 if ($last_name || $name ne 'mostly')
2574 push (@deps, $last_name . $target . " ");
2577 # FIXME: not sure if I like the tabs here.
2578 &pretty_print_rule ($name . $target . ": ", "\t\t", @deps);
2580 # FIXME: shouldn't we really print these messages before running
2582 if ($name . $target eq 'maintainer-clean')
2584 # Print a special warning.
2586 ("\t\@echo \"This command is intended for maintainers to use;\"\n"
2587 . "\t\@echo \"it deletes files that may require special "
2588 . "tools to rebuild.\"\n");
2590 $output_rules .= "\trm -f config.status\n"
2591 if $relative_dir eq '.';
2593 elsif ($name . $target eq 'distclean')
2595 $output_rules .= "\trm -f config.status\n";
2597 $output_rules .= "\n";
2600 # Handle .PHONY target.
2603 &pretty_print_rule ('.PHONY:', "", @phony);
2604 $output_rules .= "\n";
2607 # Handle TESTS variable and other checks.
2610 if (defined $options{'dejagnu'})
2612 push (@check, 'check-DEJAGNU');
2613 push (@phony, 'check-DEJAGNU');
2614 $output_rules .= &file_contents ('dejagnu') . "\n";
2615 # Note that in the rule we don't directly generate site.exp to
2616 # avoid the possibility of a corrupted site.exp if make is
2617 # interrupted. Jim Meyering has some useful text on this
2619 $output_rules .= ("site.exp: Makefile\n"
2620 . "\t\@echo 'Making a new site.exp file...'\n"
2621 . "\t-\@rm -f site.bak\n"
2622 . "\t\@echo '## these variables are automatically generated by make ##' > \$\@-t\n"
2623 . "\t\@echo '# Do not edit here. If you wish to override these values' >> \$\@-t\n"
2624 . "\t\@echo '# edit the last section' >> \$\@-t\n"
2625 . "\t\@echo 'set tool \$(DEJATOOL)' >> \$\@-t\n"
2626 . "\t\@echo 'set srcdir \$(srcdir)' >> \$\@-t\n"
2627 . "\t\@echo 'set objdir' \`pwd\` >> \$\@-t\n");
2629 # Extra stuff for AC_CANONICAL_*
2630 local (@whatlist) = ();
2631 if ($seen_canonical)
2633 push (@whatlist, 'host')
2636 # Extra stuff only for AC_CANONICAL_SYSTEM.
2637 if ($seen_canonical == $AC_CANONICAL_SYSTEM)
2639 push (@whatlist, 'target', 'build');
2643 foreach $c1 (@whatlist)
2645 foreach $c2 ('alias', 'triplet')
2647 $output_rules .= "\t\@echo 'set ${c1}_${c2} \$(${c1}_${c2})' >> \$\@-t\n";
2651 $output_rules .= ("\t\@echo '## All variables above are generated by configure. Do Not Edit ##' >> \$\@-t\n"
2652 . "\t-\@sed '1,/^## All variables above are.*##/ d' site.bak >> \$\@-t\n"
2653 . "\t-\@mv site.exp site.bak\n"
2654 . "\t\@mv \$\@-t site.exp\n");
2659 foreach $c ('DEJATOOL', 'RUNTEST', 'RUNTESTFLAGS')
2661 if (&variable_defined ($c))
2663 &am_line_error ($c, "\`$c' defined but \`dejagnu' not in \`AUTOMAKE_OPTIONS'");
2668 if (&variable_defined ('TESTS'))
2670 push (@check, 'check-TESTS');
2671 push (@phony, 'check-TESTS');
2672 # FIXME: use $(SHELL) here? That is what Ulrich suggests.
2673 # Maybe a new macro, $(TEST_SHELL), a la $(CONFIG_SHELL)? For
2674 # now we just execute the file directly; this allows test
2675 # files which are compiled -- a possibly useful feature.
2676 $output_rules .= 'check-TESTS: $(TESTS)
2677 @failed=0; all=0; \\
2678 srcdir=$(srcdir); export srcdir; \\
2679 for tst in $(TESTS); do \\
2680 all=`expr $$all + 1`; \\
2681 if test -f $$tst; then dir=.; \\
2682 else dir="$(srcdir)"; fi; \\
2683 if $(TESTS_ENVIRONMENT) $$dir/$$tst; then \\
2684 echo "PASS: $$tst"; \\
2686 failed=`expr $$failed + 1`; \\
2687 echo "FAIL: $$tst"; \\
2690 if test "$$failed" -eq 0; then \\
2691 echo "========================"; \\
2692 echo "All $$all tests passed"; \\
2693 echo "========================"; \\
2695 echo "$$failed of $$all tests failed"; \\
2701 # Handle Emacs Lisp.
2702 sub handle_emacs_lisp
2704 local (@elfiles) = &am_install_var ('lisp', 'LISP', 'lisp', 'noinst');
2709 &define_variable ("lispdir", "\@lispdir\@");
2710 &define_variable ("EMACS", "\@EMACS\@");
2711 $output_rules .= (".el.elc:\n"
2712 . "\t\@echo 'WARNING: Warnings can be ignored. :-)'\n"
2713 . "\t\EMACS=$(EMACS) $(SHELL) \$(srcdir)/elisp-comp \$<\n");
2714 push (@suffixes, '.el', '.elc');
2716 # Generate .elc files.
2717 grep ($_ .= 'c', @elfiles);
2718 &define_pretty_variable ('ELCFILES', @elfiles);
2720 push (@clean, 'lisp');
2721 &push_phony_cleaners ('lisp');
2724 if (&variable_defined ('lisp_LISP'))
2726 $varname = 'lisp_LISP';
2727 &am_error ("\`lisp_LISP' defined but \`AM_PATH_LISPDIR' not in \`configure.in'")
2732 $varname = 'noinst_LISP';
2735 &require_file_with_line ($varname, $FOREIGN, 'elisp-comp');
2739 ################################################################
2741 # Scan configure.in for interesting things.
2744 open (CONFIGURE, 'configure.in')
2745 || die "automake: couldn't open \`configure.in': $!\n";
2746 print "automake: reading configure.in\n" if $verbose;
2748 # Reinitialize libsources here. This isn't really necessary,
2749 # since we currently assume there is only one configure.in. But
2750 # that won't always be the case.
2753 local ($in_ac_output, $in_ac_replace, @make_list) = (0, 0);
2754 local ($libobj_iter);
2757 # Remove comments from current line.
2761 # Populate libobjs array.
2762 if (/AC_FUNC_ALLOCA/)
2764 $libsources{'alloca.c'} = 1;
2766 elsif (/AC_FUNC_GETLOADAVG/)
2768 $libsources{'getloadavg.c'} = 1;
2770 elsif (/AC_FUNC_MEMCMP/)
2772 $libsources{'memcmp.c'} = 1;
2774 elsif (/AC_STRUCT_ST_BLOCKS/)
2776 $libsources{'fileblocks.c'} = 1;
2778 elsif (/AM_FUNC_FNMATCH/)
2780 $libsources{'fnmatch.c'} = 1;
2782 elsif (/A[CM]_REPLACE_GNU_GETOPT/)
2784 $libsources{'getopt.c'} = 1;
2785 $libsources{'getopt1.c'} = 1;
2787 elsif (/AM_FUNC_STRTOD/)
2789 $libsources{'strtod.c'} = 1;
2791 elsif (/AM_WITH_REGEX/)
2793 $libsources{'rx.c'} = 1;
2794 $libsources{'rx.h'} = 1;
2795 $libsources{'regex.c'} = 1;
2796 $libsources{'regex.h'} = 1;
2798 elsif (/AM_FUNC_MKTIME/)
2800 $libsources{'mktime.c'} = 1;
2802 elsif (/AM_FUNC_ERROR_AT_LINE/)
2804 $libsources{'error.c'} = 1;
2805 $libsources{'error.h'} = 1;
2807 elsif (/AM_FUNC_OBSTACK/)
2809 $libsources{'obstack.c'} = 1;
2810 $libsources{'obstack.h'} = 1;
2812 elsif (/LIBOBJS="(.*)\s+\$LIBOBJS"/
2813 || /LIBOBJS="\$LIBOBJS\s+(.*)"/)
2815 foreach $libobj_iter (split (' ', $1))
2817 if ($libobj_iter =~ /^(.*)\.o$/)
2819 $libsources{$1 . '.c'} = 1;
2824 if (! $in_ac_replace && s/AC_REPLACE_FUNCS\s*\(\[?//)
2830 $in_ac_replace = 0 if s/[\]\)].*$//;
2831 # Remove trailing backslash.
2835 $libsources{$_ . '.c'} = 1;
2839 if (/(fp_WITH_DMALLOC|fp_WITH_REGEX|fp_FUNC_FNMATCH|fp_PROG_INSTALL|fp_C_PROTOTYPES|jm_MAINTAINER_MODE)/)
2841 &am_conf_line_error ($., "\`$1' is obsolete; use corresponding \`AM_' macro");
2844 # Process the AC_OUTPUT macro.
2845 if (! $in_ac_output && s/AC_OUTPUT\s*\(\[?//)
2848 $ac_output_line = $.;
2852 $in_ac_output = 0 if s/[\]\),].*$//;
2854 # Look at potential Makefile.am's.
2860 push (@make_list, $_);
2864 push (@other_input_files, $_);
2869 if (/$AC_CONFIG_AUX_DIR_PATTERN/o)
2871 @config_aux_path = $1;
2874 # Check for ansi2knr.
2875 $am_c_prototypes = 1 if /AM_C_PROTOTYPES/;
2877 # Check for NLS support.
2878 if (/ud_GNU_GETTEXT/)
2881 $ac_gettext_line = $.;
2884 # Look for ALL_LINGUAS.
2885 if (/ALL_LINGUAS="(.*)"$/ || /ALL_LINGUAS=(.*)$/)
2889 $all_linguas_line = $.;
2892 # Handle configuration headers.
2893 if (/AC_CONFIG_HEADER\s*\((.*)\)/)
2895 $config_header_line = $.;
2897 if ($config_name =~ /^([^:]+):(.+)$/)
2900 $config_header = $2;
2904 $config_header = $config_name . '.in';
2908 # Handle AC_CANONICAL_*. Always allow upgrading to
2909 # AC_CANONICAL_SYSTEM, but never downgrading.
2910 $seen_canonical = $AC_CANONICAL_HOST
2911 if ! $seen_canonical
2912 && (/AC_CANONICAL_HOST/ || /AC_CHECK_TOOL/);
2913 $seen_canonical = $AC_CANONICAL_SYSTEM if /AC_CANONICAL_SYSTEM/;
2915 $seen_path_xtra = 1 if /AC_PATH_XTRA/;
2917 # Sometimes it is desirable to explicitly set YACC. For
2918 # instance some people don't want to use bison.
2919 $seen_prog_yacc = 1 if (/AC_PROG_YACC/
2920 || /AC_SUBST\(YACC\)/
2921 || /AC_(PATH|CHECK)_PROGS?\(YACC/);
2923 # This macro handles several different things.
2924 if (/$AM_INIT_AUTOMAKE_PATTERN/o)
2930 $seen_prog_install = 2;
2931 ($package_version = $1) =~ s/\s//;
2932 $package_version_line = $.;
2935 # Some things required by Automake.
2936 $seen_make_set = 1 if /AC_PROG_MAKE_SET/;
2937 $seen_arg_prog = 1 if /AC_ARG_PROGRAM/;
2938 $seen_ranlib = 1 if /AC_PROG_RANLIB/;
2939 $seen_prog_cc = 1 if /AC_PROG_CC/;
2940 $seen_prog_cxx = 1 if /AC_PROG_CXX/;
2941 $seen_prog_lex = 1 if /AC_PROG_LEX/;
2942 $seen_decl_yytext = 1 if /AC_DECL_YYTEXT/;
2943 $seen_maint_mode = 1 if /AM_MAINTAINER_MODE/;
2944 $seen_package = 1 if /PACKAGE=/;
2946 if (/VERSION=(\S+)/)
2949 $package_version = $1;
2950 $package_version_line = $.;
2957 # Weird conditionals here because it is always allowed to
2958 # upgrade to AM_PROG_INSTALL but never to downgrade to
2960 $seen_prog_install = 1 if ! $seen_prog_install && /AC_PROG_INSTALL/;
2961 $seen_prog_install = 2 if /AM_PROG_INSTALL/;
2963 $seen_lispdir = 1 if /AM_PATH_LISPDIR/;
2965 if (/AM_PROG_LIBTOOL/)
2973 # Set input files if not specified by user.
2974 @input_files = @make_list if (! @input_files);
2978 &am_conf_error ("\`PACKAGE' not defined in configure.in")
2980 &am_conf_error ("\`VERSION' not defined in configure.in")
2983 # Look for some files we need. Always check for these. This
2984 # check must be done for every run, even those where we are only
2985 # looking at a subdir Makefile. We must set relative_dir so that
2986 # the file-finding machinery works.
2987 local ($relative_dir) = '.';
2988 &require_config_file ($FOREIGN, 'install-sh', 'mkinstalldirs');
2989 &am_error ("\`install.sh' is an anachronism; use \`install-sh' instead")
2990 if -f $config_aux_path[0] . '/install.sh';
2993 ################################################################
2995 # Do any extra checking for GNU standards.
2996 sub check_gnu_standards
2998 if ($relative_dir eq '.')
3000 # In top level (or only) directory.
3001 &require_file ($GNU, 'INSTALL', 'NEWS', 'README', 'COPYING',
3002 'AUTHORS', 'ChangeLog');
3005 if ($strictness >= $GNU)
3007 if (defined $options{'no-installman'})
3009 &am_line_error ('AUTOMAKE_OPTIONS',
3010 "option \`no-installman' disallowed by GNU standards");
3013 if (defined $options{'no-installinfo'})
3015 &am_line_error ('AUTOMAKE_OPTIONS',
3016 "option \`no-installinfo' disallowed by GNU standards");
3021 # Do any extra checking for GNITS standards.
3022 sub check_gnits_standards
3024 if ($strictness >= $GNITS)
3026 if (-f $relative_dir . '/COPYING.LIB')
3028 &am_error ("\`${relative_dir}/COPYING.LIB' disallowed by Gnits standards");
3031 if ($relative_dir eq '.')
3033 if ($package_version !~ /^$GNITS_VERSION_PATTERN$/)
3035 &am_conf_line_error ($package_version_line,
3036 "version \`$package_version' doesn't follow Gnits standards");
3038 elsif (defined $1 && -f 'README-alpha')
3040 # This means we have an alpha release. See
3041 # GNITS_VERSION_PATTERN for details.
3042 &require_file ($GNITS, 'README-alpha');
3047 if ($relative_dir eq '.')
3049 # In top level (or only) directory.
3050 &require_file ($GNITS, 'THANKS');
3054 ################################################################
3056 # Pretty-print something. HEAD is what should be printed at the
3057 # beginning of the first line, FILL is what should be printed at the
3058 # beginning of every subsequent line.
3059 sub pretty_print_internal
3061 local ($head, $fill, @values) = @_;
3063 local ($column) = length ($head);
3064 local ($result) = $head;
3066 # Fill length is number of characters. However, each Tab
3067 # character counts for eight. So we count the number of Tabs and
3069 local ($fill_length) = length ($fill);
3070 $fill_length += 7 * ($fill =~ tr/\t/\t/d);
3075 # "71" because we also print a space.
3076 if ($column + length ($_) > 71)
3078 $result .= " \\\n" . $fill;
3079 $column = $fill_length;
3083 $result .= ' ' unless ($bol);
3085 $column += length ($_) + 1;
3093 # Pretty-print something and append to output_vars.
3096 $output_vars .= &pretty_print_internal (@_);
3099 # Pretty-print something and append to output_rules.
3100 sub pretty_print_rule
3102 $output_rules .= &pretty_print_internal (@_);
3106 ################################################################
3108 # See if a variable exists.
3109 sub variable_defined
3112 if (defined $targets{$var})
3114 &am_line_error ($var, "\`$var' is target; expected variable");
3117 elsif (defined $contents{$var})
3119 $content_seen{$var} = 1;
3125 # Mark a variable as examined.
3126 sub examine_variable
3129 &variable_defined ($var);
3132 # Return contents of variable as list, split as whitespace. This will
3133 # recursively follow $(...) and ${...} inclusions. It preserves @...@
3134 # substitutions. If PARENT is specified, it is the name of the
3135 # including variable; this is only used for error reports.
3136 sub variable_value_as_list
3138 local ($var, $parent) = @_;
3141 if (defined $targets{$var})
3143 &am_line_error ($var, "\`$var' is target; expected variable");
3145 elsif (! defined $contents{$var})
3147 &am_line_error ($parent, "variable \`$var' not defined");
3151 $content_seen{$var} = 1;
3152 foreach (split (' ', $contents{$var}))
3154 # If a comment seen, just leave.
3157 # Handle variable substitutions.
3158 if (/^\$\{(.*)\}$/ || /^\$\((.*)\)$/)
3160 push (@result, &variable_value_as_list ($1, $var));
3172 # Define a new variable, but only if not already defined.
3175 local ($var, $value) = @_;
3177 if (! defined $contents{$var})
3179 $output_vars .= $var . ' = ' . $value . "\n";
3180 $contents{$var} = $value;
3181 $content_seen{$var} = 1;
3185 # Like define_variable, but second arg is a list, and is
3187 sub define_pretty_variable
3189 local ($var, @value) = @_;
3190 if (! defined $contents{$var})
3192 $contents{$var} = join (' ', @value);
3193 &pretty_print ($var . ' = ', '', @value);
3194 $content_seen{$var} = 1;
3198 # Read Makefile.am and set up %contents. Simultaneously copy lines
3199 # from Makefile.am into $output_trailer or $output_vars as
3200 # appropriate. NOTE we put rules in the trailer section. We want
3201 # user rules to come after our generated stuff.
3204 local ($amfile) = @_;
3206 open (AM_FILE, $amfile) || die "automake: couldn't open \`$amfile': $!\n";
3207 print "automake: reading $amfile\n" if $verbose;
3209 $output_vars = ("# $in_file_name generated automatically by automake "
3210 . $VERSION . " from $am_file_name\n");
3212 # Generate copyright for generated Makefile.in.
3213 $output_vars .= $gen_copyright;
3215 local ($saw_bk) = 0;
3216 local ($was_rule) = 0;
3217 local ($spacing) = '';
3218 local ($comment) = '';
3219 local ($last_var_name) = '';
3224 if (/$IGNORE_PATTERN/o)
3226 # Merely delete comments beginning with two hashes.
3228 elsif (/$WHITE_PATTERN/o)
3230 # Stick a single white line before the incoming macro or rule.
3234 elsif (/$COMMENT_PATTERN/o)
3236 # Stick comments before the incoming macro or rule. Make
3237 # sure a blank line preceeds first block of comments.
3238 $spacing = "\n" unless $blank;
3240 $comment .= $spacing . $_;
3249 $output_vars .= $comment . "\n";
3252 local ($am_vars) = '';
3254 local ($is_ok_macro);
3258 unless substr ($_, -1, 1) eq "\n";
3260 $_ =~ s/\@MAINT\@//g
3261 unless $seen_maint_mode;
3263 if (/$IGNORE_PATTERN/o)
3265 # Merely delete comments beginning with two hashes.
3267 elsif (/$WHITE_PATTERN/o)
3269 # Stick a single white line before the incoming macro or rule.
3272 elsif (/$COMMENT_PATTERN/o)
3274 # Stick comments before the incoming macro or rule.
3275 $comment .= $spacing . $_;
3282 $output_trailer .= $_;
3289 # Chop newline and backslash if this line is
3290 # continued. FIXME: maybe ensure trailing whitespace
3294 $contents{$last_var_name} .= $_;
3297 elsif (/$RULE_PATTERN/o)
3299 # warn "** Saw rule .$1.\n";
3302 # Value here doesn't matter; for targets we only note
3306 $content_lines{$1} = $.;
3307 $output_trailer .= $comment . $spacing . $_;
3308 $comment = $spacing = '';
3311 elsif (($is_ok_macro = /$MACRO_PATTERN/o)
3312 || /$BOGUS_MACRO_PATTERN/o)
3314 # Found a macro definition.
3316 $last_var_name = $1;
3317 if (substr ($2, -1) eq "\\")
3319 $contents{$1} = substr ($2, 0, length ($2) - 1);
3325 $content_lines{$1} = $.;
3326 $am_vars .= $comment . $spacing . $_;
3327 $comment = $spacing = '';
3331 &am_line_error ($., "bad macro name \`$1'")
3336 # This isn't an error; it is probably a continued rule.
3337 # In fact, this is what we assume.
3339 $output_trailer .= $comment . $spacing . $_;
3340 $comment = $spacing = '';
3347 $output_trailer .= $comment;
3349 # Compute relative location of the top object directory.
3350 local (@topdir) = ();
3351 foreach (split (/\//, $relative_dir))
3353 next if $_ eq '.' || $_ eq '';
3360 push (@topdir, '..');
3363 @topdir = ('.') if ! @topdir;
3365 $top_builddir = join ('/', @topdir);
3367 ($build_rx = $top_builddir) =~ s/(\W)/\\$1/g;
3368 $output_vars .= &file_contents_with_transform
3369 ('s/\@top_builddir\@/' . $build_rx . '/g',
3372 # Generate some useful variables when AC_CANONICAL_* used.
3373 if ($seen_canonical)
3375 local ($curs, %vars);
3376 $vars{'host_alias'} = 'host_alias';
3377 $vars{'host_triplet'} = 'host';
3378 if ($seen_canonical == $AC_CANONICAL_SYSTEM)
3380 $vars{'build_alias'} = 'build_alias';
3381 $vars{'build_triplet'} = 'build';
3382 $vars{'target_alias'} = 'target_alias';
3383 $vars{'target_triplet'} = 'target';
3385 foreach $curs (keys %vars)
3387 $output_vars .= "$curs = \@$vars{$curs}\@\n";
3388 $contents{$curs} = "\@$vars{$curs}\@";
3392 $output_vars .= $am_vars;
3395 ################################################################
3397 sub initialize_global_constants
3399 # Values for AC_CANONICAL_*
3400 $AC_CANONICAL_HOST = 1;
3401 $AC_CANONICAL_SYSTEM = 2;
3403 # Associative array of standard directory names. Entry is TRUE if
3404 # corresponding directory should be installed during
3405 # 'install-exec' phase.
3423 # Helper text for dealing with man pages.
3424 $install_man_format =
3425 ' sect=@SECTION@; \\
3426 inst=`echo "@MANBASE@" | sed \'$(transform)\'`.@FULLSECT@; \\
3427 if test -f $(srcdir)/@MAN@; then file=$(srcdir)/@MAN@; \\
3428 else file=@MAN@; fi; \\
3429 $(INSTALL_DATA) $$file $(mandir)/man$$sect/$$inst
3432 $uninstall_man_format =
3433 ' inst=`echo "@MANBASE@" | sed \'$(transform)\'`.@FULLSECT@; \\
3434 rm -f $(mandir)/man@SECTION@/$$inst
3437 # Commonly found files we look for and automatically include in
3441 "README", "THANKS", "TODO", "NEWS", "COPYING", "COPYING.LIB",
3442 "INSTALL", "ABOUT-NLS", "ChangeLog", "configure", "configure.in",
3443 "config.guess", "config.sub", "AUTHORS", "BACKLOG", "ABOUT-GNU",
3444 "libversion.in", "mdate-sh", "mkinstalldirs", "install-sh",
3445 'texinfo.tex', "ansi2knr.c", "ansi2knr.1", 'elisp-comp',
3446 'interlock', 'ylwrap', 'acinclude.m4'
3449 # Commonly used files we auto-include, but only sometimes.
3452 "aclocal.m4", "acconfig.h", "config.h.top",
3453 "config.h.bot", "stamp-h.in", 'stamp-vti', 'libtool'
3457 -a, --add-missing add missing standard files to package
3458 --amdir=DIR directory storing config files
3459 --build-dir=DIR directory where build being done (for dependencies)
3460 --foreign same as --strictness=foreign
3461 --gnits same as --strictness=gnits
3462 --gnu same as --strictness=gnu
3463 --help print this help, then exit
3464 -i, --include-deps include generated dependencies in Makefile.in
3465 --no-force only update Makefile.in's that are out of date
3466 -o DIR, --output-dir=DIR
3467 put generated Makefile.in's into DIR
3468 --srcdir-name=DIR name used for srcdir (for dependencies)
3469 -s LEVEL, --strictness=LEVEL
3470 set strictness level. LEVEL is foreign, gnu, gnits
3471 -v, --verbose verbosely list files processed
3472 --version print version number, then exit\n";
3474 # Copyright on generated Makefile.ins.
3476 # Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
3477 # This Makefile.in is free software; the Free Software Foundation
3478 # gives unlimited permission to copy, distribute and modify it.
3481 # Ignore return result from chmod, because it might give an error
3482 # if we chmod a symlink.
3483 $dist_header = "\t" . '-chmod -R a+r $(distdir)' . "\n";
3484 $dist{'tarZ'} = ("\t"
3485 . '$(TAR) chf - $(distdir) | compress -c > $(distdir).tar.Z'
3487 $dist{'shar'} = ("\t"
3488 . 'shar $(distdir) | gzip > $(distdir).shar.gz'
3490 $dist{'zip'} = "\t" . 'zip -rq $(distdir).zip $(distdir)' . "\n";
3491 $dist{'dist'} = "\t" . '$(TAR) chozf $(distdir).tar.gz $(distdir)' . "\n";
3492 $dist_trailer = "\t" . 'rm -rf $(distdir)' . "\n";
3495 # (Re)-Initialize per-Makefile.am variables.
3496 sub initialize_per_input
3498 # These two variables are used when generating each Makefile.in.
3499 # They hold the Makefile.in until it is ready to be printed.
3502 $output_trailer = '';
3504 # Suffixes found during a run.
3507 # This holds the contents of a Makefile.am, as parsed by
3511 # This holds the names which are targets. These also appear in
3515 # This holds the line numbers at which various elements of
3516 # %contents are defined.
3517 %content_lines = ();
3519 # This holds a 1 if a particular variable was examined.
3522 # This holds the "relative directory" of the current Makefile.in.
3523 # Eg for src/Makefile.in, this is "src".
3526 # This holds a list of files that are included in the
3530 # List of dependencies for the obvious targets.
3545 # These are pretty obvious, too. They are used to define the
3546 # SOURCES and OBJECTS variables.
3550 # TRUE if current directory holds any C source files. (Actually
3551 # holds object extension, but this information is encapsulated in
3552 # the function get_object_extension).
3553 $dir_holds_sources = '';
3555 # TRUE if current directory holds any headers.
3556 $dir_holds_headers = 0;
3558 # TRUE if install targets should work recursively.
3559 $recursive_install = 0;
3564 # Strictness levels.
3565 $strictness = $default_strictness;
3566 $strictness_name = $default_strictness_name;
3568 # Options from AUTOMAKE_OPTIONS.
3571 # Whether or not dependencies are handled. Can be further changed
3572 # in handle_options.
3573 $use_dependencies = $cmdline_use_dependencies;
3576 $local_maint_charset = $maint_charset;
3578 # All yacc and lex source filenames for this directory. Use
3579 # filenames instead of raw count so that multiple instances are
3580 # counted correctly (eg one yacc file can appear in multiple
3581 # programs without harm).
3585 # C++ source extensions we've seen.
3586 %cxx_extensions = ();
3588 # TRUE if we've seen any non-C++ sources.
3593 ################################################################
3595 # Return contents of a file from $am_dir, automatically skipping
3596 # macros or rules which are already known. Runs command on each line
3597 # as it is read; this command can modify $_.
3598 sub file_contents_with_transform
3600 local ($command, $basename) = @_;
3601 local ($file) = $am_dir . '/' . $basename . '.am';
3603 open (FC_FILE, $file)
3604 || die "automake: installation error: cannot open \`$file'\n";
3606 # print "automake: reading $file\n" if $verbose;
3608 local ($was_rule) = 0;
3609 local ($result_vars) = '';
3610 local ($result_rules) = '';
3611 local ($comment) = '';
3612 local ($spacing) = "\n";
3613 local ($skipping) = 0;
3617 $_ =~ s/\@MAINT\@//g
3618 unless $seen_maint_mode;
3622 if (/$IGNORE_PATTERN/o)
3624 # Merely delete comments beginning with two hashes.
3626 elsif (/$WHITE_PATTERN/o)
3628 # Stick a single white line before the incoming macro or rule.
3631 elsif (/$COMMENT_PATTERN/o)
3633 # Stick comments before the incoming macro or rule.
3634 $comment .= $spacing . $_;
3641 $result_rules .= $_ if ! $skipping;
3645 $result_vars .= $_ if ! $skipping;
3649 elsif (/$RULE_PATTERN/o)
3651 # warn "** Found rule .$1.\n";
3654 $skipping = defined $contents{$1};
3655 # warn "** Skip $skipping\n" if $skipping;
3656 $result_rules .= $comment . $spacing . $_ if ! $skipping;
3657 $comment = $spacing = '';
3660 elsif (/$MACRO_PATTERN/o)
3662 # warn "** Found macro .$1.\n";
3663 # Found a variable reference.
3665 $skipping = defined $contents{$1};
3666 # warn "** Skip $skipping\n" if $skipping;
3667 $result_vars .= $comment . $spacing . $_ if ! $skipping;
3668 $comment = $spacing = '';
3673 # This isn't an error; it is probably a continued rule.
3674 # In fact, this is what we assume.
3676 $result_rules .= $comment . $spacing . $_ if ! $skipping;
3677 $comment = $spacing = '';
3683 return $result_vars . $result_rules . $comment;
3686 # Like file_contents_with_transform, but no transform.
3689 return &file_contents_with_transform ('', @_);
3692 # Find all variable prefixes that are used for install directories. A
3693 # prefix `zar' qualifies iff:
3694 # * `zardir' is a variable.
3695 # * `zar_PRIMARY' is a variable.
3696 sub am_primary_prefixes
3698 local ($primary, @prefixes) = @_;
3700 local (%valid, $varname);
3701 grep ($valid{$_} = 0, @prefixes);
3702 $valid{'EXTRA'} = 0;
3703 foreach $varname (keys %contents)
3705 if ($varname =~ /^(.*)_$primary$/)
3707 if (! defined $valid{$1} && ! &variable_defined ($1 . 'dir'))
3709 &am_line_error ($varname, "invalid variable \"$varname\"");
3713 # Ensure all extended prefixes are actually used.
3722 # Handle `where_HOW' variable magic. Does all lookups, generates
3723 # install code, and possibly generates code to define the primary
3724 # variable. The first argument is the name of the .am file to munge,
3725 # the second argument is the primary variable (eg HEADERS), and all
3726 # subsequent arguments are possible installation locations. Returns
3727 # list of all values of all _HOW targets.
3729 # FIXME: this should be rewritten to be cleaner. It should be broken
3730 # up into multiple functions.
3732 # Usage is: am_install_var (OPTION..., file, HOW, where...)
3737 local ($do_all, $do_clean) = (1, 0);
3740 if ($args[0] eq '-clean')
3744 elsif ($args[0] eq '-no-all')
3748 elsif ($args[0] !~ /^-/)
3754 local ($file, $primary, @prefixes) = @args;
3757 local (@result) = ();
3759 # Now that configure substitutions are allowed in where_HOW
3760 # variables, it is an error to actually define the primary.
3761 &am_line_error ($primary, "\`$primary' is an anachronism")
3762 if &variable_defined ($primary);
3765 # Look for misspellings. It is an error to have a variable ending
3766 # in a "reserved" suffix whose prefix is unknown, eg
3767 # "bni_PROGRAMS". However, unusual prefixes are allowed if a
3768 # variable of the same name (with "dir" appended) exists. For
3769 # instance, if the variable "zardir" is defined, then
3770 # "zar_PROGRAMS" becomes valid. This is to provide a little extra
3771 # flexibility in those cases which need it. Perhaps it should be
3772 # disallowed in the Gnits case? The problem is, sometimes it is
3773 # useful to put things in a subdir of eg pkgdatadir, perhaps even
3775 local (%valid) = &am_primary_prefixes ($primary, @prefixes);
3777 # If a primary includes a configure substitution, then the EXTRA_
3778 # form is required. Otherwise we can't properly do our job.
3779 local ($require_extra);
3780 local ($warned_about_extra) = 0;
3782 local ($clean_file) = $file . '-clean';
3785 foreach $X (keys %valid)
3787 $one_name = $X . '_' . $primary;
3788 if (&variable_defined ($one_name))
3790 # Append actual contents of where_PRIMARY variable to
3793 foreach $rcurs (&variable_value_as_list ($one_name))
3795 # Skip configure substitutions. Possibly bogus.
3796 if ($rcurs =~ /^\@.*\@$/)
3800 if (! $warned_about_extra)
3802 $warned_about_extra = 1;
3803 &am_line_error ($one_name,
3804 "\`$one_name' contains configure substitution, but shouldn't");
3809 $require_extra = $one_name;
3813 push (@result, $rcurs);
3816 # "EXTRA" shouldn't be used when generating clean targets,
3817 # @all, or install targets.
3818 next if $X eq 'EXTRA';
3823 &file_contents_with_transform ('s/\@DIR\@/' . $X . '/go',
3826 push (@clean, $X . $primary);
3827 &push_phony_cleaners ($X . $primary);
3832 push (@check, '$(' . $one_name . ')');
3836 push (@used, '$(' . $one_name . ')');
3838 if ($X eq 'noinst' || $X eq 'check')
3840 # Objects which don't get installed by default.
3845 &file_contents_with_transform ('s/\@DIR\@/' . $X . '/go',
3848 push (@uninstall, 'uninstall-' . $X . $primary);
3849 push (@phony, 'uninstall-' . $X . $primary);
3850 push (@installdirs, '$(' . $X . 'dir)');
3851 if ($exec_dir_p{$X})
3853 push (@install_exec, 'install-' . $X . $primary);
3854 push (@phony, 'install-' . $X . $primary);
3858 push (@install_data, 'install-' . $X . $primary);
3859 push (@phony, 'install-' . $X . $primary);
3867 &define_pretty_variable ($primary, @used);
3868 $output_vars .= "\n";
3871 if ($require_extra && ! &variable_defined ('EXTRA_' . $primary))
3873 &am_line_error ($require_extra,
3874 "\`$require_extra' contains configure substitution, but \`EXTRA_$primary' not defined");
3877 # Push here because PRIMARY might be configure time determined.
3878 push (@all, '$(' . $primary . ')')
3879 if $do_all && @used;
3885 ################################################################
3887 # This variable is local to the "require file" set of functions.
3888 @require_file_paths = ();
3890 # Verify that the file must exist in the current directory. Usage:
3891 # require_file (isconfigure, line_number, strictness, file) strictness
3892 # is the strictness level at which this file becomes required. Must
3893 # set require_file_paths before calling this function.
3894 # require_file_paths is set to hold a single directory (the one in
3895 # which the first file was found) before return.
3896 sub require_file_internal
3898 local ($is_configure, $line, $mystrict, @files) = @_;
3899 local ($file, $fullfile);
3900 local ($found_it, $errfile, $errdir);
3903 foreach $file (@files)
3906 foreach $dir (@require_file_paths)
3910 $fullfile = $relative_dir . "/" . $file;
3911 $errdir = $relative_dir unless $errdir;
3915 $fullfile = $dir . "/" . $file;
3916 $errdir = $dir unless $errdir;
3919 # Use different name for "error filename". Otherwise on
3920 # an error the bad file will be reported as eg
3921 # `../../install-sh' when using the default
3923 $errfile = $errdir . '/' . $file;
3928 # FIXME: Once again, special-case `.'.
3929 &push_dist_common ($file)
3930 if $dir eq $relative_dir || $dir eq '.';
3938 # Prune the path list.
3939 @require_file_paths = $save_dir;
3943 if ($strictness >= $mystrict)
3945 local ($trailer) = '';
3946 local ($suppress) = 0;
3948 # Only install missing files according to our desired
3950 if ($add_missing && -f ($am_dir . '/' . $file))
3952 $trailer = "; installing";
3954 # Install the missing file. Symlink if we can, copy
3956 if ($symlink_exists)
3958 if (! symlink ($am_dir . '/' . $file, $errfile))
3961 $trailer .= "; error while making link: $!\n";
3966 if (! system ('cp', $am_dir . '/' . $file, $errfile))
3969 $trailer .= "\n error while making link: $!\n";
3974 local ($save) = $exit_status;
3979 "required file \"$errfile\" not found$trailer");
3985 "required file \"$errfile\" not found$trailer");
3987 $exit_status = $save if $suppress;
3993 # Like require_file_with_line, but error messages refer to
3994 # configure.in, not the current Makefile.am.
3995 sub require_file_with_conf_line
3997 @require_file_paths = '.';
3998 &require_file_internal (1, @_);
4001 sub require_file_with_line
4003 @require_file_paths = '.';
4004 &require_file_internal (0, @_);
4009 @require_file_paths = '.';
4010 &require_file_internal (0, '', @_);
4013 # Require a file that is also required by Autoconf. Looks in
4014 # configuration path, as specified by AC_CONFIG_AUX_DIR.
4015 sub require_config_file
4017 @require_file_paths = @config_aux_path;
4018 &require_file_internal (1, '', @_);
4019 local ($dir) = $require_file_paths[0];
4020 @config_aux_path = @require_file_paths;
4023 $config_aux_dir = '.';
4027 $config_aux_dir = '$(top_srcdir)/' . $dir;
4031 # Assumes that the line number is in Makefile.am.
4032 sub require_conf_file_with_line
4034 @require_file_paths = @config_aux_path;
4035 &require_file_internal (0, @_);
4036 local ($dir) = $require_file_paths[0];
4037 @config_aux_path = @require_file_paths;
4040 $config_aux_dir = '.';
4044 $config_aux_dir = '$(top_srcdir)/' . $dir;
4048 # Assumes that the line number is in Makefile.am.
4049 sub require_conf_file_with_conf_line
4051 @require_file_paths = @config_aux_path;
4052 &require_file_internal (1, @_);
4053 local ($dir) = $require_file_paths[0];
4054 @config_aux_path = @require_file_paths;
4057 $config_aux_dir = '.';
4061 $config_aux_dir = '$(top_srcdir)/' . $dir;
4065 ################################################################
4067 # Push a list of files onto dist_common.
4068 sub push_dist_common
4070 local (@files) = @_;
4073 foreach $file (@files)
4075 $dist_common{$file} = 1;
4079 # Push a list of clean targets onto phony.
4080 sub push_phony_cleaners
4084 foreach $target ('mostly', 'dist', '', 'maintainer-')
4086 push (@phony, $target . 'clean-' . $base);
4093 $strictness_name = $_[0];
4094 if ($strictness_name eq 'gnu')
4098 elsif ($strictness_name eq 'gnits')
4100 $strictness = $GNITS;
4102 elsif ($strictness_name eq 'foreign')
4104 $strictness = $FOREIGN;
4108 die "automake: level \`$strictness_name' not recognized\n";
4113 ################################################################
4115 # Return directory name of file.
4121 ($sub = $file) =~ s,/+[^/]+$,,g;
4122 $sub = '.' if $sub eq $file;
4126 # Return file name of a file.
4132 ($sub = $file) =~s,^.*/+,,g;
4141 open (TOUCH, ">> $file");
4145 ################################################################
4147 # Print an error message and set exit status.
4150 warn "automake: ${am_file}.am: ", join (' ', @_), "\n";
4156 local ($symbol, @args) = @_;
4160 # If SYMBOL not already a line number, look it up in Makefile.am.
4161 $symbol = $content_lines{$symbol} unless $symbol =~ /^\d+$/;
4162 $symbol .= ': ' if $symbol;
4163 warn "${am_file}.am:", $symbol, join (' ', @args), "\n";
4172 # Like am_error, but while scanning configure.in.
4175 # FIXME: can run in subdirs.
4176 warn "automake: configure.in: ", join (' ', @_), "\n";
4180 # Error message with line number referring to configure.in.
4181 sub am_conf_line_error
4183 local ($line, @args) = @_;
4187 warn "configure.in: $line: ", join (' ', @args), "\n";
4192 &am_conf_error (@args);
4196 # Tell user where our aclocal.m4 is, but only once.
4197 sub keyed_aclocal_warning
4200 warn "automake: macro \`$key' can be generated by \`aclocal'\n";
4203 # Print usage information.
4206 print "Usage: automake [OPTION] ... [Makefile]...\n";
4208 print "\nFiles which are automatically distributed, if found:\n";
4209 $~ = "USAGE_FORMAT";
4210 local (@lcomm) = sort ((@common_files, @common_sometimes));
4211 local ($one, $two, $three, $four);
4214 $one = shift @lcomm;
4215 $two = @lcomm ? shift @lcomm : '';
4216 $three = @lcomm ? shift @lcomm : '';
4217 $four = @lcomm ? shift @lcomm : '';
4221 print "\nReport bugs to <bug-gnu-utils\@prep.ai.mit.edu>\n";
4226 format USAGE_FORMAT =
4227 @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<
4228 $one, $two, $three, $four