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 # Constants to define the "strictness" level.
53 # Variables global to entire run.
55 # TRUE if we should always generate Makefile.in.
56 $force_generation = 1;
58 # Strictness level as set on command line.
59 $default_strictness = $GNU;
61 # Name of strictness level, as set on command line.
62 $default_strictness_name = 'gnu';
64 # This is TRUE if GNU make specific automatic dependency generation
65 # code should be included in generated Makefile.in.
66 $cmdline_use_dependencies = 1;
68 # TRUE if in verbose mode.
71 # This holds our (eventual) exit status. We don't actually exit until
72 # we have processed all input files.
75 # From the Perl manual.
76 $symlink_exists = (eval 'symlink ("", "");', $@ eq '');
78 # TRUE if missing standard files should be installed.
81 # Files found by scanning configure.in for LIBOBJS.
84 # True if AM_C_PROTOTYPES appears in configure.in.
87 # Names used in AC_CONFIG_HEADER call. $config_name is the actual
88 # (first) argument. $config_header is the '.in' file. Ordinarily the
89 # second is derived from the first, but they can be different if the
90 # weird "NAME:FILE" syntax is used.
93 # Line number at which AC_CONFIG_HEADER appears in configure.in.
94 $config_header_line = 0;
96 # Directory where output files go. Actually, output files are
97 # relative to this directory.
98 $output_directory = '.';
100 # Relative location of top build directory.
103 # Absolute location of top build directory.
104 $build_directory = '';
106 # Name of srcdir as given in build directory's Makefile. For
110 # List of Makefile.am's to process.
113 # List of files in AC_OUTPUT without Makefile.am.
114 @other_input_files = ();
115 # Line number at which AC_OUTPUT seen.
118 # List of directories to search for configure-required files. This
119 # can be set by AC_CONFIG_AUX_DIR.
120 @config_aux_path = ('.', '..', '../..');
121 $config_aux_dir = '';
123 # Whether AC_PROG_MAKE_SET has been seen in configure.in.
126 # Whether ud_GNU_GETTEXT has been seen in configure.in.
128 # Line number at which ud_GNU_GETTEXT seen.
129 $ac_gettext_line = 0;
131 # Whether ALL_LINGUAS has been seen.
135 # Line number at which it appears.
136 $all_linguas_line = 0;
138 # 1 if AC_PROG_INSTALL seen, 2 if AM_PROG_INSTALL seen.
139 $seen_prog_install = 0;
141 # 1 if any scripts installed, 0 otherwise.
142 $scripts_installed = 0;
144 # Whether AC_PATH_XTRA has been seen in configure.in.
147 # Whether YACC variable has been seen in configure.in.
150 # Two variables to control lex use. One is for AC_DECL_YYTEXT and the
151 # other is for AC_PROG_LEX.
152 $seen_decl_yytext = 0;
155 # TRUE if we've seen AC_PROG_CC.
158 # TRUE if we've seen AC_PROG_CXX.
161 # TRUE if we've seen AC_CANONICAL_(HOST|SYSTEM). The presence of
162 # AC_CHECK_TOOL also sets this.
165 # TRUE if we've seen AC_PROG_RANLIB.
168 # TRUE if we've seen AC_ARG_PROGRAM.
171 # TRUE if we've seen AM_PROG_LIBTOOL.
175 # TRUE if we've seen AM_MAINTAINER_MODE.
176 $seen_maint_mode = 0;
178 # TRUE if we've seen PACKAGE and VERSION.
182 # Actual version we've seen.
183 $package_version = '';
185 # Line number where we saw version definition.
186 $package_version_line = 0;
188 # TRUE if we've seen AM_PATH_LISPDIR.
192 # Charsets used by maintainer and in distribution. MAINT_CHARSET is
193 # handled in a funny way: if seen in the top-level Makefile.am, it is
194 # used for every directory which does not specify a different value.
195 # The rationale here is that some directories (eg gettext) might be
196 # distributions of other packages, and thus require their own charset
197 # info. However, the DIST_CHARSET must be the same for the entire
198 # package; it can only be set at top-level.
199 # FIXME: this yields bugs when rebuilding. What to do? Always
200 # read (and sometimes discard) top-level Makefile.am?
202 $dist_charset = 'utf8'; # recode doesn't support this yet.
204 # Name of input file ("Makefile.in") and output file ("Makefile.am").
205 # These have no directory components.
211 &initialize_global_constants;
213 # Parse command line.
214 &parse_arguments (@ARGV);
216 # Do configure.in scan only once.
219 die "automake: no \`Makefile.am' found or specified\n"
222 # Now do all the work on each file.
223 foreach $am_file (@input_files)
225 # FIXME: should support the AC_OUTPUT ":" syntax here.
226 if (! -f ($am_file . '.am'))
228 &am_error ('no such file');
232 &generate_makefile ($am_file);
236 if ($seen_prog_install <= $scripts_installed)
238 &am_conf_error (($scripts_installed ? 'AM_PROG_INSTALL' : 'AC_PROG_INSTALL')
239 . " must be used in configure.in");
240 &keyed_aclocal_warning ('AM_PROG_INSTALL')
241 if $scripts_installed;
247 ################################################################
249 # Parse command line.
252 local (@arglist) = @_;
255 &set_strictness ('gnu');
259 if ($arglist[0] eq "--version")
261 print "automake (GNU $PACKAGE) $VERSION\n";
262 print "Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.\n";
263 print "automake comes with ABSOLUTELY NO WARRANTY.\n";
264 print "You may redistribute copies of automake\n";
265 print "under the terms of the GNU General Public License.\n";
266 print "For more information about these matters, see the file named COPYING.\n";
269 elsif ($arglist[0] eq "--help")
273 elsif ($arglist[0] =~ /^--amdir=(.+)$/)
277 elsif ($arglist[0] eq '--amdir')
279 &require_argument (@arglist);
281 $am_dir = $arglist[0];
283 elsif ($arglist[0] =~ /^--build-dir=(.+)$/)
286 $build_directory = $1 . '/';
288 elsif ($arglist[0] eq '--build-dir')
290 &require_argument (@arglist);
293 $build_directory = $arglist[0] . '/';
295 elsif ($arglist[0] =~ /^--srcdir-name=(.+)$/)
299 elsif ($arglist[0] eq '--srcdir-name')
301 &require_argument (@arglist);
303 $srcdir_name = $arglist[0];
305 elsif ($arglist[0] =~ /^--strictness=(.+)$/)
307 &set_strictness ($1);
309 elsif ($arglist[0] eq '--gnu')
311 &set_strictness ('gnu');
313 elsif ($arglist[0] eq '--gnits')
315 &set_strictness ('gnits');
317 elsif ($arglist[0] eq '--foreign')
319 &set_strictness ('foreign');
321 elsif ($arglist[0] eq '--strictness' || $arglist[0] eq '-s')
323 &require_argument (@arglist);
325 &set_strictness ($arglist[0]);
327 elsif ($arglist[0] eq '--include-deps' || $arglist[0] eq '-i')
329 $cmdline_use_dependencies = 0;
331 elsif ($arglist[0] eq '--no-force')
333 $force_generation = 0;
335 elsif ($arglist[0] =~ /^--output-dir=(.*)$/)
337 # Set output directory.
338 $output_directory = $1;
340 elsif ($arglist[0] eq '--output-dir' || $arglist[0] eq '-o')
342 &require_argument (@arglist);
344 $output_directory = $arglist[0];
346 elsif ($arglist[0] eq '--add-missing' || $arglist[0] eq '-a')
350 elsif ($arglist[0] eq '--verbose' || $arglist[0] eq '-v')
354 elsif ($arglist[0] eq '--')
356 # Stop option processing.
358 push (@input_files, @arglist);
361 elsif ($arglist[0] =~ /^-/)
363 die "automake: unrecognized option -- \`$arglist[0]'\n";
367 push (@input_files, $arglist[0]);
373 # Take global strictness from whatever we currently have set.
374 $default_strictness = $strictness;
375 $default_strictness_name = $strictness_name;
378 # Ensure argument exists, or die.
381 local ($arg, @arglist) = @_;
382 die "automake: no argument given for option \`$arg'\n"
386 ################################################################
388 # Generate a Makefile.in given the name of the corresponding Makefile.
389 sub generate_makefile
391 local ($makefile) = @_;
393 ($am_file_name = $makefile) =~ s/^.*\///;
394 $in_file_name = $am_file_name . '.in';
395 $am_file_name .= '.am';
397 &initialize_per_input;
398 $relative_dir = &dirname ($makefile);
400 # At the toplevel directory, we might need config.guess, config.sub
402 if ($relative_dir eq '.')
404 # libtool requires some files.
405 &require_conf_file_with_conf_line ($libtool_line, $FOREIGN,
406 'config.sub', 'config.guess',
407 'libtool') if $seen_libtool;
409 # AC_CANONICAL_HOST and AC_CANONICAL_SYSTEM need config.guess and
411 &require_config_file ($FOREIGN, 'config.guess', 'config.sub')
415 # We still need Makefile.in here, because sometimes the `dist'
416 # target doesn't re-run automake.
417 &push_dist_common ($in_file_name, $am_file_name);
418 push (@sources, '$(SOURCES)')
419 if &variable_defined ('SOURCES');
420 push (@objects, '$(OBJECTS)')
421 if &variable_defined ('OBJECTS');
423 # This is always the default target. This gives us freedom to do
424 # things in whatever order is convenient.
425 $output_rules .= "default: all\n\n";
426 push (@phony, 'default');
428 &read_am_file ($makefile . '.am');
431 # Fatal error. Just return, so we can continue with next file.
435 # Check first, because we might modify some state.
436 &check_gnu_standards;
437 &check_gnits_standards;
445 # This must be run after all the sources are scanned.
446 &handle_yacc_lex_cxx;
448 # Re-init SOURCES and OBJECTS. FIXME: other code shouldn't depend
449 # on this (but currently does).
450 $contents{'SOURCES'} = join (' ', @sources);
451 $contents{'OBJECTS'} = join (' ', @objects);
461 &handle_dependencies;
464 &handle_merge_targets;
471 if (! -d ($output_directory . '/' . $relative_dir))
473 mkdir ($output_directory . '/' . $relative_dir, 0755);
476 local ($out_file) = $output_directory . '/' . $makefile . ".in";
477 if (! $force_generation && -e $out_file)
479 local ($am_time) = (stat ($makefile . '.am'))[9];
480 local ($in_time) = (stat ($out_file))[9];
481 # FIXME: how to do unsigned comparison?
482 if ($am_time < $in_time)
489 if (! open (GM_FILE, "> " . $out_file))
491 warn "automake: ${am_file}.in: cannot open: $!\n";
495 print "automake: creating ", $makefile, ".in\n" if $verbose;
497 print GM_FILE $output_vars;
498 print GM_FILE $output_rules;
499 print GM_FILE $output_trailer;
504 ################################################################
506 # Handle AUTOMAKE_OPTIONS variable. Return 1 on error, 0 otherwise.
509 return 0 if ! &variable_defined ('AUTOMAKE_OPTIONS');
511 foreach (&variable_value_as_list ('AUTOMAKE_OPTIONS'))
514 if ($_ eq 'gnits' || $_ eq 'gnu' || $_ eq 'foreign')
516 &set_strictness ($_);
520 # An option like "../lib/ansi2knr" is allowed. With no
521 # path prefix, we assume the required programs are in this
522 # directory. We save the actual option for later.
523 $options{'ansi2knr'} = $_;
525 elsif ($_ eq 'no-installman' || $_ eq 'no-installinfo'
526 || $_ eq 'dist-shar' || $_ eq 'dist-zip'
527 || $_ eq 'dist-tarZ' || $_ eq 'dejagnu')
529 # Explicitly recognize these.
531 elsif ($_ eq 'no-dependencies')
533 $use_dependencies = 0;
535 elsif (/([0-9]+)\.([0-9]+)/)
537 # Got a version number. Note that alpha releases count as
538 # the next higher release. Note also that we assume there
539 # will be a maximum of 100 minor releases for any given
541 local ($rmajor, $rminor) = ($1, $2);
542 if ($VERSION !~ /([0-9]+)\.([0-9]+)([a-z])?/)
545 "automake: programming error: version is incorrect\n";
548 local ($tmajor, $tminor) = ($1, $2);
549 # Handle alpha versions.
550 ++$tminor if defined $3;
552 if ($rmajor > $tmajor || ($rmajor == $tmajor && $rminor > $tminor))
554 &am_line_error ('AUTOMAKE_OPTIONS',
555 "require version $_, only have $VERSION");
561 &am_line_error ('AUTOMAKE_OPTIONS',
562 'option ', $_, 'not recognized');
569 # Return object extension. Just once, put some code into the output.
570 sub get_object_extension
572 if (! $dir_holds_sources)
576 if (&variable_defined ('CONFIG_HEADER'))
578 ($xform = &dirname ($contents{'CONFIG_HEADER'}))
580 $xform = '-I' . $xform;
582 $xform = 's/\@CONFIG_INCLUDE_SPEC\@/' . $xform . '/go';
583 $output_vars .= &file_contents_with_transform ($xform,
585 $output_rules .= &file_contents ('compile');
586 &push_phony_cleaners ('compile');
588 # If using X, include some extra variable definitions. NOTE
589 # we don't want to force these into CFLAGS or anything,
590 # because not all programs will necessarily use X.
594 foreach $var ('X_CFLAGS', 'X_LIBS', 'X_EXTRA_LIBS', 'X_PRE_LIBS')
596 &define_variable ($var, "\@$var\@");
600 # Check for automatic de-ANSI-fication.
601 $dir_holds_sources = '.o';
602 push (@suffixes, '.c', '.o');
603 push (@clean, 'compile');
605 if (defined $options{'ansi2knr'})
607 if (! $am_c_prototypes)
609 &am_line_error ('AUTOMAKE_OPTIONS',
610 "option \`ansi2knr' in use but \`AM_C_PROTOTYPES' not in configure.in");
611 &keyed_aclocal_warning ('AM_C_PROTOTYPES');
612 # Only give this error once.
613 $am_c_prototypes = 1;
616 $dir_holds_sources = '$o';
617 push (@suffixes, '._c', '._o');
619 # Only require ansi2knr files if they should appear in
621 if ($options{'ansi2knr'} eq 'ansi2knr')
623 &require_file_with_line ('AUTOMAKE_OPTIONS', $FOREIGN,
624 'ansi2knr.c', 'ansi2knr.1');
625 $output_rules .= &file_contents ('kr-extra');
626 push (@clean, 'krextra');
627 &push_phony_cleaners ('krextra');
630 &define_variable ('o', ".\@U\@o");
632 # Make sure ansi2knr can be found: if no path specified,
634 local ($apath) = $options{'ansi2knr'};
635 $apath = './' . $apath
636 unless $apath =~ /\//;
637 &define_variable ("ANSI2KNR", $apath);
639 $output_rules .= &file_contents ('compile-kr');
640 $output_rules .= &file_contents ('clean-kr');
643 &push_phony_cleaners ('kr');
646 return $dir_holds_sources;
649 # Handle yacc and lex.
650 sub handle_yacc_lex_cxx
653 # First do yacc and lex.
656 local ($yacc_count) = scalar (keys %yacc_sources);
657 local ($lex_count) = scalar (keys %lex_sources);
660 push (@suffixes, '.y');
661 &define_variable ('YACC', "\@YACC\@");
662 $output_rules .= ".y.c:\n\t";
665 $output_rules .= '$(INTERLOCK) =yacclockdir $(YLWRAP) y.tab.c $@ $(YACC) $(YFLAGS) $<';
669 $output_rules .= '$(YACC) $(YFLAGS) $< && mv y.tab.c $@';
671 $output_rules .= "\n";
673 if (! $seen_prog_yacc)
675 # FIXME: should include a reference line. FIXME: maybe
676 # directly reference AC_PROG_YACC somehow?
677 &am_error ("yacc source seen but \`YACC' not defined in \`configure.in'\n");
682 push (@suffixes, '.l');
683 &define_variable ("LEX", "\@LEX\@");
684 &define_variable ("LEX_OUTPUT_ROOT", "\@LEX_OUTPUT_ROOT\@");
685 $output_rules .= ".l.c:\n\t";
688 $output_rules .= '$(INTERLOCK) =lexlockdir $(YLWRAP) $(LEX_OUTPUT_ROOT).c $@ $(LEX) $(LFLAGS) $<';
692 $output_rules .= '$(LEX) $(LFLAGS) $< && mv $(LEX_OUTPUT_ROOT).c $@';
694 $output_rules .= "\n";
696 if (! $seen_prog_lex)
698 &am_error ("lex source seen but \`AC_PROG_LEX' not in \`configure.in'\n");
700 if (! $seen_decl_yytext)
702 &am_error ("lex source seen but \`AC_DECL_YYTEXT' not in \`configure.in'\n");
706 if ($yacc_count > 1 || $lex_count > 1)
708 # If there is more than one distinct yacc (resp lex) source
709 # file in a given directory, then the `interlock' program is
710 # required to allow parallel builds to work correctly. FIXME:
711 # for now, no line number.
712 &require_config_file ($FOREIGN, 'interlock', 'ylwrap');
713 &define_variable ('INTERLOCK', $config_aux_dir . "/interlock");
714 &define_variable ('YLWRAP', $config_aux_dir . "/ylwrap");
720 local (@cxx_list) = keys %cxx_extensions;
721 local ($cxx_count) = scalar @cxx_list;
724 push (@suffixes, @cxx_list);
726 &define_variable ("CXX", "\@CXX\@");
727 &define_variable ("CXXFLAGS", "\@CXXFLAGS\@");
728 &define_variable ('CXXCOMPILE', '$(CXX) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CXXFLAGS)');
729 &define_variable ('CXXLINK', '$(CXX) $(LDFLAGS) -o $@');
732 foreach $ext (@cxx_list)
734 $output_rules .= ("$ext.o:\n"
735 . "\t\$(CXXCOMPILE) -c \$<\n");
738 if (! $seen_prog_cxx)
740 &am_error ("C++ source seen but \`AC_PROG_CXX' not in \`configure.in'\n");
745 # Last, handle some C cleanup.
749 &define_variable ('CC', "\@CC\@");
750 &define_variable ('CFLAGS', "\@CFLAGS\@");
751 &define_variable ('COMPILE',
752 '$(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)');
753 &define_variable ('LINK', '$(CC) $(LDFLAGS) -o $@');
757 # Handle SOURCE->OBJECT transform for one program or library.
759 # canonical (transformed) name of object to build
760 # actual name of object to build
761 # object extension (ie either `.o' or `$o'.
762 # Return result is name of linker variable that must be used.
763 # Empty return means just use `LINK'.
764 sub handle_source_transform
766 # one_file is canonical name. unxformed is given name. obj is
768 local ($one_file, $unxformed, $obj) = @_;
769 local ($objpat) = $obj;
770 $objpat =~ s/(\W)/\\$1/g;
772 local ($linker) = '';
774 if (&variable_defined ($one_file . "_OBJECTS"))
776 &am_line_error ($one_file . '_OBJECTS',
777 $one_file . '_OBJECTS', 'should not be defined');
778 # No point in continuing.
784 foreach $prefix ('', 'EXTRA_')
787 if (&variable_defined ($prefix . $one_file . "_SOURCES"))
789 push (@sources, '$(' . $prefix . $one_file . "_SOURCES)");
790 push (@objects, '$(' . $prefix . $one_file . "_OBJECTS)")
791 unless $prefix eq 'EXTRA_';
792 @files = &variable_value_as_list ($prefix
793 . $one_file . "_SOURCES");
795 elsif ($prefix eq '')
797 &define_variable ($one_file . "_SOURCES", $unxformed . ".c");
798 push (@sources, $unxformed . '.c');
799 push (@objects, $unxformed . $obj);
800 push (@files, $unxformed . '.c');
804 &define_variable ("EXTRA_" . $one_file . "_SOURCES", '');
809 # Turn sources into objects.
810 local (@result) = ();
813 # Skip header files, including C++-ish ones. The list
814 # of C++ header extensions comes from Emacs 19.32
821 # Skip things that look like configure substitutions.
824 # Include .c file for lex or yacc source in distribution.
828 &push_dist_common ($1 . '.c');
829 $yacc_sources{$_} = 1;
834 &push_dist_common ($1 . '.c');
835 $lex_sources{$_} = 1;
838 # Transform source files into .o files. List of C++
839 # extensions comes from Emacs 19.32 etags.
840 if (s/\.c\+\+$/$obj/g
846 $cxx_extensions{$&} = 1;
851 # FORTRAN support. FIXME: not finished.
855 # .y is yacc. .l is lex. .f and .F is fortran.
856 # .s is assembly. .M is Objective-C++. .m is
858 s/\.[cylfFsmM]$/$obj/g;
860 # FIXME: of course, this should only happen for C
861 # source. The multi-language support must really
862 # be cleaned up more globally.
867 unless $prefix eq 'EXTRA_';
869 # Transform .o or $o file into .P file (for automatic
872 $dep_files{'.deps/' . $_} = 1;
875 &define_pretty_variable ($one_file . "_OBJECTS", @result)
876 unless $prefix eq 'EXTRA_';
880 if (&variable_defined ('CONFIG_HEADER'))
882 $output_rules .= ('$(' . $one_file . "_OBJECTS): "
883 . $contents{'CONFIG_HEADER'} . "\n");
889 # Special-case @ALLOCA@ and @LIBOBJS@ in _LDADD or _LIBADD variables.
890 # Also, generate _DEPENDENCIES variable if appropriate.
892 # transformed name of object being built, or empty string if no object
893 # name of _LDADD/_LIBADD-type variable to examine
894 sub handle_lib_objects
896 local ($xname, $var) = @_;
898 die "programming error in handle_lib_objects"
899 if ! &variable_defined ($var);
901 # We recognize certain things that are commonly put in LIBADD or
904 local (@dep_list) = ();
906 foreach $lsearch (&variable_value_as_list ($var))
908 # Skip -lfoo and -Ldir.
909 next if $lsearch =~ /^-[lL]/;
911 # Assume we have a file of some sort, and push it onto the
912 # dependency list. Autoconf substitutions are not pushed;
913 # rarely is a new dependency substituted into (eg) foo_LDADD
914 # -- but "bad things (eg -lX11) are routinely substituted.
915 push (@dep_list, $lsearch)
916 unless $lsearch =~ /^\@.*\@$/;
918 # Automatically handle @LIBOBJS@ and @ALLOCA@. Basically this
919 # means adding entries to dep_files.
920 if ($lsearch eq '@LIBOBJS@')
922 if (! keys %libsources)
924 &am_line_error ($var, "\@LIBOBJS\@ seen but never set in \`configure.in'");
927 local ($iter, $rewrite);
928 foreach $iter (keys %libsources)
932 &require_file_with_line ($var, $FOREIGN, $iter);
934 elsif ($iter ne 'alloca.c')
936 ($rewrite = $iter) =~ s/\.c$/.P/;
937 $dep_files{'.deps/' . $rewrite} = 1;
938 &require_file_with_line ($var, $FOREIGN, $iter);
942 elsif ($lsearch eq '@ALLOCA@')
944 &am_line_error ($var,
945 "\@ALLOCA\@ seen but \`AC_FUNC_ALLOCA' not in \`configure.in'")
946 if ! defined $libsources{'alloca.c'};
947 $dep_files{'.deps/alloca.P'} = 1;
948 &require_file_with_line ($var, $FOREIGN, 'alloca.c');
952 if ($xname ne '' && ! &variable_defined ($xname . '_DEPENDENCIES'))
954 &define_pretty_variable ($xname . '_DEPENDENCIES', @dep_list);
961 local (@proglist) = &am_install_var ('-clean',
962 'programs', 'PROGRAMS',
963 'bin', 'sbin', 'libexec', 'pkglib',
965 return if ! @proglist;
967 # If a program is installed, this is required. We only want this
968 # error to appear once.
969 &am_conf_error ("AC_ARG_PROGRAM must be used in configure.in")
970 unless $seen_arg_prog;
973 local ($obj) = &get_object_extension;
974 local ($one_file, $xname, $munge);
976 foreach $one_file (@proglist)
978 # Canonicalize names.
979 ($xname = $one_file) =~ tr/A-Za-z0-9_/_/c;
980 if ($xname ne $one_file)
983 foreach $xt ('_LDADD', '_SOURCES', '_OBJECTS', '_DEPENDENCIES')
985 &am_line_error ($one_file . $xt,
986 "invalid variable \`" . $one_file . $xt
987 . "'; should be \`" . $xname . $xt . "'")
988 if &variable_defined ($one_file . $xt);
992 local ($linker) = &handle_source_transform ($xname, $one_file, $obj);
994 if (&variable_defined ($xname . "_LDADD"))
996 &handle_lib_objects ($xname, $xname . '_LDADD');
1000 # User didn't define prog_LDADD override. So do it.
1001 &define_variable ($xname . '_LDADD', '$(LDADD)');
1003 # This does a bit too much work. But we need it to
1004 # generate _DEPENDENCIES when appropriate.
1005 &handle_lib_objects ($xname, 'LDADD')
1006 if (&variable_defined ('LDADD'));
1009 # Determine program to use for link.
1011 if (&variable_defined ($xname . '_LINK'))
1013 $xlink = $xname . '_LINK';
1017 $xlink = $linker ? $linker : 'LINK';
1021 &file_contents_with_transform
1022 ('s/\@PROGRAM\@/' . $one_file . '/go;'
1023 . 's/\@XPROGRAM\@/' . $xname . '/go;'
1024 . 's/\@XLINK\@/' . $xlink . '/go;',
1028 &handle_lib_objects ('', 'LDADD')
1029 if &variable_defined ('LDADD');
1033 sub handle_libraries
1035 local (@liblist) = &am_install_var ('-no-all', '-clean',
1036 'libraries', 'LIBRARIES',
1037 'lib', 'pkglib', 'noinst', 'check');
1038 return if ! @liblist;
1040 local (%valid) = &am_primary_prefixes ('LIBRARIES', 'lib', 'pkglib',
1045 foreach $key (keys %valid)
1047 if (&variable_defined ($key . '_LIBRARIES'))
1049 &am_line_error ($key . '_LIBRARIES', "library requires either \`AC_PROG_RANLIB' or `AM_PROG_LIBTOOL' in configure.in");
1050 # Only get this error once.
1057 # Generate _LIBFILES variables. Too bad we can't do this in
1059 local ($onedir, $onelib);
1061 local (@libfiles_list);
1062 foreach $onedir (keys %valid)
1064 if (&variable_defined ($onedir . '_LIBRARIES'))
1067 foreach $onelib (&variable_value_as_list ($onedir . '_LIBRARIES'))
1069 push (@outlist, 'lib' . $onelib . '.a');
1071 &define_pretty_variable ($onedir . '_LIBFILES', @outlist);
1074 push (@libfiles_list, '$(' . $onedir . '_LIBFILES)')
1075 unless $onedir eq 'EXTRA';
1077 push (@all, '$(LIBFILES)');
1079 local ($obj) = &get_object_extension;
1082 foreach $onelib (@liblist)
1084 # Canonicalize names.
1085 ($xlib = $onelib) =~ tr/A-Za-z0-9_/_/c;
1086 if ($xlib ne $onelib)
1089 foreach $xt ('_LIBADD', '_SOURCES', '_OBJECTS', '_DEPENDENCIES')
1091 &am_line_error ($one_file . $xt,
1092 "invalid variable \`" . $onelib . $xt
1093 . "'; should be \`" . $xlib . $xt . "'")
1094 if &variable_defined ($onelib . $xt);
1098 if (&variable_defined ($xlib . '_LIBADD'))
1100 &handle_lib_objects ($xlib, $xlib . '_LIBADD');
1104 # Generate support for conditional object inclusion in
1106 &define_variable ($xlib . "_LIBADD", '');
1109 &handle_source_transform ($xlib, $onelib, $obj);
1112 &file_contents_with_transform ('s/\@LIBRARY\@/' . $onelib . '/go;'
1118 # Turn "foo" into "libfoo.a" and include macro definition.
1119 grep (($_ = 'lib' . $_ . '.a') && 0, @liblist);
1121 if (! &variable_defined ('LIBFILES'))
1123 &define_pretty_variable ('LIBFILES ', @libfiles_list);
1128 &define_variable ('AR', '$(LIBTOOL) archive');
1129 &define_variable ('RANLIB', '$(LIBTOOL) ranlib');
1130 &define_variable ('LCOMPILE', ('$(LIBTOOL) compile $(DEFS) $(INCLUDES)'
1131 . ' $(CPPFLAGS) $(CFLAGS)'));
1135 &define_variable ('AR', 'ar');
1136 &define_variable ('RANLIB', '@RANLIB@');
1140 # See if any _SOURCES variable were misspelled.
1143 local ($varname, $primary);
1144 foreach $varname (keys %contents)
1146 foreach $primary ('_SOURCES', '_LIBADD', '_LDADD', '_DEPENDENCIES')
1148 if ($varname =~ /$primary$/ && ! $content_seen{$varname})
1150 &am_line_error ($varname,
1151 "invalid unused variable name: \`$varname'");
1160 # NOTE we no longer automatically clean SCRIPTS, because it is
1161 # useful to sometimes distribute scripts verbatim. This happens
1162 # eg in Automake itself.
1163 &am_install_var ('scripts', 'SCRIPTS',
1164 'bin', 'sbin', 'libexec', 'pkgdata',
1167 # Set $scripts_installed if appropriate. Make sure we only find
1168 # scripts which are actually installed -- this is why we can't
1169 # simply use the return value of am_install_var.
1170 local (%valid) = &am_primary_prefixes ('SCRIPTS', 'bin', 'sbin',
1171 'libexec', 'pkgdata',
1174 foreach $key (keys %valid)
1176 if ($key ne 'noinst'
1178 && &variable_defined ($key . '_SCRIPTS'))
1180 $scripts_installed = 1;
1181 # push (@check, 'check-' . $key . 'SCRIPTS');
1185 if ($scripts_installed)
1187 # If a program is installed, this is required. We only want this
1188 # error to appear once.
1189 &am_conf_error ("AC_ARG_PROGRAM must be used in configure.in")
1190 unless $seen_arg_prog;
1195 # Search a file for a "version.texi" Texinfo include. Return the name
1196 # of the include file if found, or the empty string if not. A
1197 # "version.texi" file is actually any file whose name matches
1199 sub grep_for_vers_texi
1201 local ($filename) = @_;
1203 if (! open (TEXI, $filename))
1205 &am_error ("couldn't open \`$filename': $!");
1208 print "automake: reading $filename\n" if $verbose;
1212 if (/^\@include\s+(vers[^.]*\.texi)\s*$/)
1224 # Handle all Texinfo source.
1227 &am_line_error ('TEXINFOS',
1228 "\`TEXINFOS' is an anachronism; use \`info_TEXINFOS'")
1229 if &variable_defined ('TEXINFOS');
1230 return if (! &variable_defined ('info_TEXINFOS')
1231 && ! &variable_defined ('html_TEXINFOS'));
1233 local (@texis) = &variable_value_as_list ('info_TEXINFOS');
1235 local (@infos_list, @info_deps_list, @dvis_list, @texi_deps);
1236 local ($infobase, $info_cursor);
1240 local ($tc_cursor, @texi_cleans);
1243 foreach $info_cursor (@texis)
1245 ($infobase = $info_cursor) =~ s/\.texi(nfo)?$//;
1247 # If 'version.texi' is referenced by input file, then include
1248 # automatic versioning capability.
1250 = &grep_for_vers_texi ($relative_dir . "/" . $info_cursor);
1253 &am_error ("\`$vtexi', included in \`$info_cursor', also included in \`$versions{$vtexi}'")
1254 if (defined $versions{$vtexi});
1255 $versions{$vtexi} = $info_cursor;
1257 # We number the stamp-vti files. This is doable since the
1258 # actual names don't matter much. We only number starting
1259 # with the second one, so that the common case looks nice.
1260 $vti = 'vti' . ($done ? $done : '');
1261 &push_dist_common ($vtexi, 'stamp-' . $vti);
1262 push (@clean, $vti);
1264 # Only require once.
1265 &require_conf_file_with_line ('info_TEXINFOS', $FOREIGN,
1271 ($conf_pat = $config_aux_dir) =~ s/(\W)/\\$1/g;
1273 &file_contents_with_transform
1274 ('s/\@TEXI\@/' . $info_cursor . '/g; '
1275 . 's/\@VTI\@/' . $vti . '/g; '
1276 . 's/\@VTEXI\@/' . $vtexi . '/g;'
1277 . 's,\@MDDIR\@,' . $conf_pat . ',g;',
1280 &push_phony_cleaners ($vti);
1283 # If user specified file_TEXINFOS, then use that as explicit
1286 push (@texi_deps, $info_cursor);
1287 push (@texi_deps, $vtexi) if $vtexi;
1289 # Canonicalize name first.
1290 ($canonical = $infobase) =~ tr/A-Za-z0-9_/_/c;
1291 if (&variable_defined ($canonical . "_TEXINFOS"))
1293 push (@texi_deps, '$(' . $canonical . '_TEXINFOS)');
1294 &push_dist_common ('$(' . $canonical . '_TEXINFOS)');
1297 $output_rules .= ("\n" . $infobase . ".info: "
1298 . join (' ', @texi_deps)
1299 . "\n" . $infobase . ".dvi: "
1300 . join (' ', @texi_deps)
1303 # FIXME: this distributes too much. How to find out precisely
1304 # which files will be generated by `makeinfo'?
1305 push (@infos_list, $infobase . '.info', $infobase . '.info[-0-9]*');
1306 push (@info_deps_list, $infobase . '.info');
1307 push (@dvis_list, $infobase . '.dvi');
1309 # Generate list of things to clean for this target. We do
1310 # this explicitly because otherwise too many things could be
1311 # removed. In particular the ".log" extension might
1312 # reasonably be used in other contexts by the user.
1313 foreach $tc_cursor ('aux', 'cp', 'cps', 'dvi', 'fn', 'fns',
1314 'ky', 'log', 'pg', 'toc', 'tp', 'vr', 'op')
1316 push (@texi_cleans, $infobase . '.' . $tc_cursor);
1321 $output_vars .= &file_contents ('texinfos-vars');
1322 $output_rules .= &file_contents ('texinfos');
1323 push (@phony, 'install-info', 'uninstall-info');
1326 $output_rules .= "\nmostlyclean-info:\n";
1327 &pretty_print_rule ("\trm -f", "\t ", @texi_cleans);
1328 $output_rules .= ("\nclean-info:\n\ndistclean-info:\n\n"
1329 . "maintainer-clean-info:\n\t"
1330 . 'rm -f $(INFOS)' . "\n");
1331 &push_phony_cleaners ('info');
1333 push (@suffixes, '.texi', '.texinfo', '.info', '.dvi');
1335 if (! defined $options{'no-installinfo'})
1337 push (@uninstall, 'uninstall-info');
1338 push (@installdirs, '$(infodir)');
1339 unshift (@install_data, 'install-info');
1341 # Make sure documentation is made and installed first. Use
1342 # $(INFO_DEPS), not 'info', because otherwise recursive makes
1343 # get run twice during "make all".
1344 unshift (@all, '$(INFO_DEPS)');
1346 push (@clean, 'info');
1347 push (@info, '$(INFO_DEPS)');
1348 push (@dvi, '$(DVIS)');
1350 &define_variable ("INFOS", join (' ', @infos_list));
1351 &define_variable ("INFO_DEPS", join (' ', @info_deps_list));
1352 &define_variable ("DVIS", join (' ', @dvis_list));
1353 # This next isn't strictly needed now -- the places that look here
1354 # could easily be changed to look in info_TEXINFOS. But this is
1355 # probably better, in case noinst_TEXINFOS is ever supported.
1356 &define_variable ("TEXINFOS", $contents{'info_TEXINFOS'});
1358 # Do some error checking.
1359 &require_file_with_line ('info_TEXINFOS', $FOREIGN, 'texinfo.tex');
1362 # Handle any man pages.
1363 sub handle_man_pages
1365 &am_line_error ('MANS', "\`MANS' is an anachronism; use \`man_MANS'")
1366 if &variable_defined ('MANS');
1367 return if ! &variable_defined ('man_MANS');
1369 # We generate the manpage install code by hand to avoid the use of
1370 # basename in the generated Makefile.
1371 local (@mans) = &variable_value_as_list ('man_MANS');
1372 local (%sections, %inames, %mbases, %secmap, %fullsecmap);
1376 # FIXME: statement without effect:
1377 /^(.*)\.([0-9])([a-z]*)$/;
1382 $fullsecmap{$i} = $2 . $3;
1386 # We don't really need this, but we use it in case we ever want to
1387 # support noinst_MANS.
1388 &define_variable ("MANS", $contents{'man_MANS'});
1390 # Generate list of install dirs.
1391 $output_rules .= "install-man: \$(MANS)\n";
1392 $output_rules .= "\t\$(NORMAL_INSTALL)\n";
1393 foreach (keys %sections)
1395 push (@installdirs, '$(mandir)/man' . $_)
1396 unless defined $options{'no-installman'};
1397 $output_rules .= ("\t" . '$(mkinstalldirs) $(mandir)/man'
1400 push (@phony, 'install-man');
1402 # Generate install target.
1404 foreach $key (keys %inames)
1406 $_ = $install_man_format;
1407 s/\@SECTION\@/$secmap{$key}/g;
1408 s/\@MAN\@/$inames{$key}/g;
1409 s/\@FULLSECT\@/$fullsecmap{$key}/g;
1410 s/\@MANBASE\@/$mbases{$key}/g;
1411 $output_rules .= $_;
1413 $output_rules .= "\n";
1415 $output_rules .= "uninstall-man:\n";
1416 foreach $key (keys %inames)
1418 $_ = $uninstall_man_format;
1419 s/\@SECTION\@/$secmap{$key}/g;
1420 s/\@MAN\@/$inames{$key}/g;
1421 s/\@FULLSECT\@/$fullsecmap{$key}/g;
1422 s/\@MANBASE\@/$mbases{$key}/g;
1423 $output_rules .= $_;
1425 $output_rules .= "\n";
1426 push (@phony, 'uninstall-man');
1428 $output_vars .= &file_contents ('mans-vars');
1430 if (! defined $options{'no-installman'})
1432 push (@install_data, 'install-man');
1433 push (@uninstall, 'uninstall-man');
1434 push (@all, '$(MANS)');
1438 # Handle DATA variables.
1441 &am_install_var ('data', 'DATA', 'data', 'sysconf',
1442 'sharedstate', 'localstate', 'pkgdata',
1449 local ($tagging) = 0;
1451 push (@phony, 'tags');
1452 if (&variable_defined ('SUBDIRS'))
1454 $output_rules .= &file_contents ('tags');
1455 push (@phony, 'tags-recursive');
1458 elsif ($dir_holds_sources
1459 || $dir_holds_headers
1460 || &variable_defined ('ETAGS_ARGS'))
1462 $output_rules .= &file_contents ('tags-subd');
1465 elsif (&variable_defined ('TAGS_DEPENDENCIES'))
1467 &am_line_error ('TAGS_DEPENDENCIES',
1468 "doesn't make sense to define \`TAGS_DEPENDENCIES' without sources or \`ETAGS_ARGS'");
1473 $output_rules .= &file_contents ('tags-clean');
1474 push (@clean, 'tags');
1475 &push_phony_cleaners ('tags');
1476 &examine_variable ('TAGS_DEPENDENCIES');
1480 # Every Makefile must define some sort of TAGS rule.
1481 # Otherwise, it would be possible for a top-level "make TAGS"
1482 # to fail because some subdirectory failed.
1483 $output_rules .= "tags: TAGS\nTAGS:\n\n";
1487 # Worker for handle_dist.
1488 sub handle_dist_worker
1490 $output_rules .= 'distdir: $(DEP_DISTFILES)' . "\n";
1492 # Initialization; only at top level.
1493 if ($relative_dir eq '.')
1495 if ($strictness >= $GNITS)
1497 # For Gnits users, this is pretty handy. Look at 15 lines
1498 # in case some explanatory text is desirable.
1499 $output_rules .= ' @if sed 15q $(srcdir)/NEWS | fgrep -e "$(VERSION)" > /dev/null; then :; else \\
1500 echo "NEWS not updated; not releasing" 1>&2; \\
1508 # Create dist directory.
1511 -chmod 755 $(distdir)
1514 # Only run automake in `dist' target if --include-deps not
1515 # specified. That way the recipient of a distribution can run
1516 # "make dist" and not need Automake.
1517 if ($cmdline_use_dependencies)
1521 # We need an absolute path for --output-dir. Thus the
1523 ' here=`pwd`; distdir=`cd $(distdir) && pwd` \\
1525 && automake --include-deps --build-dir=$$here --srcdir-name=$(srcdir) --output-dir=$$distdir --strictness='
1526 # Set strictness of output.
1527 . $strictness_name . "\n"
1532 # In loop, test for file existence because sometimes a file gets
1533 # included in DISTFILES twice. For example this happens when a
1534 # single source file is used in building more than one program.
1535 # Also, there are situations in which "ln" can fail. For instance
1536 # a file to distribute could actually be a cross-filesystem
1537 # symlink -- this can easily happen if "gettextize" was run on the
1538 # distribution. Note that DISTFILES can contain a wildcard (for
1539 # info files, sigh), so we must use the echo trick.
1540 $output_rules .= ' @for file in `cd $(srcdir) && echo $(DISTFILES)`; do \\
1541 test -f $(distdir)/$$file \\
1542 || ln $(srcdir)/$$file $(distdir)/$$file 2> /dev/null \\
1543 || cp -p $(srcdir)/$$file $(distdir)/$$file; \\
1547 # If we have SUBDIRS, create all dist subdirectories and do
1549 if (&variable_defined ('SUBDIRS'))
1551 # Test for directory existence here because previous automake
1552 # invocation might have created some directories. Note that
1553 # we explicitly set distdir for the subdir make; that lets us
1554 # mix-n-match many automake-using packages into one large
1555 # package, and have "dist" at the top level do the right
1557 $output_rules .= ' for subdir in $(SUBDIRS); do \\
1558 test -d $(distdir)/$$subdir \\
1559 || mkdir $(distdir)/$$subdir \\
1561 chmod 755 $(distdir)/$$subdir; \\
1562 (cd $$subdir && $(MAKE) distdir=../$(distdir)/$$subdir distdir) \\
1568 # If the target `dist-hook' exists, run it now. This allows
1569 # users to do random weird things to the distribution before it is
1571 if (defined $contents{'dist-hook'})
1573 $output_rules .= "\t\$(MAKE) dist-hook\n";
1576 push (@phony, 'distdir');
1579 # Handle 'dist' target.
1582 # Set up maint_charset.
1583 $local_maint_charset = $contents{'MAINT_CHARSET'}
1584 if &variable_defined ('MAINT_CHARSET');
1585 $maint_charset = $local_maint_charset
1586 if $relative_dir eq '.';
1588 if (&variable_defined ('DIST_CHARSET'))
1590 &am_line_error ('DIST_CHARSET',
1591 "DIST_CHARSET defined but no MAINT_CHARSET defined")
1592 if ! $local_maint_charset;
1593 if ($relative_dir eq '.')
1595 $dist_charset = $contents{'DIST_CHARSET'}
1599 &am_line_error ('DIST_CHARSET',
1600 "DIST_CHARSET can only be defined at top level");
1604 # Look for common files that should be included in distribution.
1606 foreach $cfile (@common_files)
1608 if (-f ($relative_dir . "/" . $cfile))
1610 &push_dist_common ($cfile);
1614 # Keys of %dist_common are names of files to distributed. We put
1615 # README first because it then becomes easier to make a
1616 # Usenet-compliant shar file (in these, README must be first).
1617 # FIXME: do more ordering of files here.
1619 if (defined $dist_common{'README'})
1621 push (@coms, 'README');
1622 undef $dist_common{'README'};
1624 push (@coms, sort keys %dist_common);
1626 &define_pretty_variable ("DIST_COMMON", @coms);
1627 $output_vars .= "\n";
1630 $output_vars .= &file_contents ('dist-vars');
1632 # Put these things in rules section so it is easier for whoever
1633 # reads Makefile.in.
1634 if (! &variable_defined ('distdir'))
1636 if ($relative_dir eq '.')
1638 $output_rules .= "\n" . 'distdir = $(PACKAGE)-$(VERSION)' . "\n";
1642 $output_rules .= ("\n"
1643 . 'distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)'
1647 if ($relative_dir ne '.')
1649 $output_rules .= "\nsubdir = " . $relative_dir . "\n";
1652 # Generate 'dist' target, and maybe dist-shar / dist-zip / dist-tarZ.
1653 if ($relative_dir eq '.')
1655 # Rule to check whether a distribution is viable.
1656 $output_rules .= ('# This target untars the dist file and tries a VPATH configuration. Then
1657 # it guarantees that the distribution is self-contained by making another
1661 $(TAR) zxf $(distdir).tar.gz
1662 mkdir $(distdir)/=build
1663 mkdir $(distdir)/=inst
1664 dc_install_base=`cd $(distdir)/=inst && pwd`; \\'
1665 . (defined $contents{'distcheck-hook'}
1666 ? "\t\$(MAKE) distcheck-hook"
1669 cd $(distdir)/=build \\
1672 . ($seen_gettext ? '--with-included-gettext ' : '')
1673 . '--srcdir=.. --prefix=$$dc_install_base \\
1677 && $(MAKE) install \\
1678 && $(MAKE) installcheck \\
1681 @echo "========================"; \\
1682 echo "$(distdir).tar.gz is ready for distribution"; \\
1683 echo "========================"
1686 local ($dist_all) = ('dist-all: distdir' . "\n"
1690 foreach $curs ('dist', 'dist-shar', 'dist-zip', 'dist-tarZ')
1692 if (defined $options{$curs} || $curs eq 'dist')
1694 $output_rules .= ($curs . ': distdir' . "\n"
1698 $dist_all .= $dist{$curs};
1701 $output_rules .= $dist_all . $dist_trailer;
1704 # Generate distdir target.
1705 &handle_dist_worker;
1708 # Scan a single dependency file and rewrite the dependencies as
1709 # appropriate. Essentially this means:
1710 # * Clean out absolute dependencies which are not desirable.
1711 # * Rewrite other dependencies to be relative to $(top_srcdir).
1712 sub scan_dependency_file
1714 local ($depfile) = @_;
1716 if (! open (DEP_FILE, $depfile))
1718 &am_error ("couldn't open \`$depfile': $!");
1721 print "automake: reading $depfile\n" if $verbose;
1723 local ($first_line) = 1;
1724 local ($last_line) = 0;
1725 local ($target, @dependencies);
1726 local ($one_dep, $xform);
1728 local ($srcdir_rx, $fixup_rx);
1729 # If the top srcdir is absolute, then the current directory is
1730 # just relative_dir. But if the top srcdir is relative, then we
1731 # need to add some dots first. The same holds when matching
1733 if ($srcdir_name =~ /^\//)
1735 ($fixup_rx = $srcdir_name . '/' . $relative_dir . '/')
1737 ($srcdir_rx = $srcdir_name) =~ s/(\W)/\\$1/g;
1741 ($fixup_rx = ($srcdir_name . '/' . $top_builddir . '/'
1742 . $relative_dir . '/')) =~ s/(\W)/\\$1/g;
1743 ($srcdir_rx = ($srcdir_name . '/' . $top_builddir))
1751 # If LAST_LINE set then we've already seen what we thought
1752 # was the last line.
1755 next if (/$WHITE_PATTERN/o);
1759 # No trailing "\" means this should be the last line.
1765 if (! /^([^:]+:)(.+)$/)
1768 &am_error ("\`$depfile' has incorrect format");
1779 foreach $one_dep (split (' ', $_))
1781 if ($one_dep =~ /^$fixup_rx/)
1783 # The dependency points to the current directory in
1785 ($xform = $one_dep) =~ s/^$fixup_rx//;
1786 push (@dependencies, $xform);
1788 elsif ($one_dep =~ /^$srcdir_rx\//)
1790 # The dependency is in some other directory in the package.
1791 ($xform = $one_dep) =~ s/^$srcdir_rx/$top_builddir/;
1792 push (@dependencies, $xform);
1794 elsif ($one_dep =~ /^\//)
1796 # Absolute path; ignore.
1800 # Anything else is assumed to be correct.
1801 push (@dependencies, $one_dep);
1806 &pretty_print_rule ($target, "\t", @dependencies);
1811 # Handle auto-dependency code.
1812 sub handle_dependencies
1814 if ($use_dependencies)
1816 # Include GNU-make-specific auto-dep code.
1817 if ($dir_holds_sources)
1819 &define_pretty_variable ('DEP_FILES', sort keys %dep_files);
1820 $output_rules .= &file_contents ('depend');
1821 push (@clean, 'depend');
1822 &push_phony_cleaners ('depend');
1824 &file_contents_with_transform ('s/\@EXT\@/.c/g;'
1825 . 's/\@MKDEP\@/MKDEP/g',
1828 local ($need_cxx) = 0;
1829 foreach $ext (keys %cxx_extensions)
1832 &file_contents_with_transform ('s/\@EXT\@/' . $ext .'/g;'
1833 . 's/\@MKDEP\@/CXXMKDEP/g',
1839 &define_variable ('CXXMKDEP', '$(CXX) -MM $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CXXFLAGS)');
1845 # FIXME: consider requiring --build-dir here. What about case
1846 # where this is done via an option?
1848 # Include any auto-generated deps that are present. Note that
1849 # $build_directory ends in a "/".
1850 if (-d ($build_directory . $relative_dir . "/.deps")
1851 && -f ($build_directory . $relative_dir . "/.deps/.P"))
1854 local ($gpat) = $build_directory . $relative_dir . "/.deps/*.P";
1856 foreach $depfile (<${gpat}>)
1858 &scan_dependency_file ($depfile);
1861 $output_rules .= "\n";
1866 # Handle subdirectories.
1869 if (! &variable_defined ('SUBDIRS'))
1872 ("ud_GNU_GETTEXT in configure.in but SUBDIRS not defined")
1873 if $seen_gettext && $relative_dir eq '.';
1877 &require_file_with_conf_line ($ac_gettext_line, $FOREIGN, 'ABOUT-NLS')
1880 return if ! &variable_defined ('SUBDIRS');
1882 # Make sure each directory mentioned in SUBDIRS actually exists.
1884 foreach $dir (&variable_value_as_list ('SUBDIRS'))
1886 # Skip directories substituted by configure.
1887 next if $dir =~ /^\@.*\@$/;
1888 &am_line_error ('SUBDIRS',
1889 "required directory $relative_dir/$dir does not exist")
1890 if ! -d $relative_dir . '/' . $dir;
1893 $output_rules .= &file_contents ('subdirs');
1895 # Push a bunch of phony targets.
1897 foreach $phonies ('-data', '-exec', 'dirs')
1899 push (@phony, 'install' . $phonies . '-recursive');
1900 push (@phony, 'uninstall' . $phonies . '-recursive');
1902 foreach $phonies ('all', 'check', 'installcheck', 'info', 'dvi')
1904 push (@phony, $phonies . '-recursive');
1906 &push_phony_cleaners ('recursive');
1908 push (@check, "check-recursive");
1909 push (@installcheck, "installcheck-recursive");
1910 push (@info, "info-recursive");
1911 push (@dvi, "dvi-recursive");
1913 $recursive_install = 1;
1916 # Handle aclocal.m4.
1917 sub handle_aclocal_m4
1919 local ($regen_aclocal) = 0;
1920 if (-f 'aclocal.m4')
1922 &define_variable ("ACLOCAL", "aclocal.m4");
1923 &push_dist_common ('aclocal.m4');
1925 if (open (ACLOCAL, '< aclocal.m4'))
1931 if ($line =~ 'generated automatically by aclocal')
1938 local ($acinclude) = 0;
1939 if (-f 'acinclude.m4')
1945 # Note that it might be possible that aclocal.m4 doesn't exist but
1946 # should be auto-generated. This case probably isn't very
1950 $output_rules .= ("aclocal.m4: "
1951 . ($seen_maint_mode ? "\@MAINT\@" : "")
1953 . ($acinclude ? ' acinclude.m4' : '')
1955 . 'cd $(srcdir) && aclocal'
1960 # Handle remaking and configure stuff.
1961 sub handle_configure
1963 # If SUBDIRS defined, require AC_PROG_MAKE_SET.
1964 &am_line_error ('SUBDIRS', "AC_PROG_MAKE_SET must be used in configure.in")
1965 if &variable_defined ('SUBDIRS') && ! $seen_make_set;
1967 local ($top_reldir);
1968 if ($relative_dir ne '.')
1971 $output_rules .= &file_contents ('remake-subd');
1972 $top_reldir = '../';
1977 $output_rules .= &file_contents_with_transform ('s/\@STRICTNESS\@/'
1981 &examine_variable ('CONFIGURE_DEPENDENCIES');
1985 # If we have a configure header, require it.
1986 if ($config_header && $relative_dir eq &dirname ($config_header))
1988 local ($ch_sans_dir) = &basename ($config_header);
1989 local ($cn_sans_dir) = &basename ($config_name);
1991 &require_file_with_conf_line ($config_header_line,
1992 $FOREIGN, $ch_sans_dir);
1994 # Header defined and in this directory.
1995 if (-f $relative_dir . '/acconfig.h')
1997 &define_variable ("ACCONFIG", "acconfig.h");
1998 &push_dist_common ('acconfig.h');
2000 if (-f $config_name . '.top')
2002 &define_variable ("CONFIG_TOP", "${cn_sans_dir}.top");
2003 &push_dist_common ($cn_sans_dir . '.top');
2005 if (-f $config_name . '.bot')
2007 &define_variable ("CONFIG_BOT", "${cn_sans_dir}.bot");
2008 &push_dist_common ($cn_sans_dir . '.bot');
2011 &touch ($relative_dir . '/stamp-h.in');
2012 &require_file_with_conf_line ($config_header_line, $FOREIGN,
2015 $output_rules .= &file_contents ('remake-hdr');
2016 push (@clean, 'hdr');
2017 &push_phony_cleaners ('hdr');
2018 &define_variable ("CONFIG_HEADER_IN", "${ch_sans_dir}");
2021 # Set location of mkinstalldirs.
2022 if ($config_aux_dir ne '.' && $config_aux_dir ne '')
2024 &define_variable ('mkinstalldirs', $config_aux_dir . '/mkinstalldirs');
2028 &define_variable ('mkinstalldirs', '$(top_srcdir)/mkinstalldirs');
2031 &am_line_error ('CONFIG_HEADER',
2032 "\`CONFIG_HEADER' is an anachronism; now determined from \`configure.in'")
2033 if &variable_defined ('CONFIG_HEADER');
2037 # Generate CONFIG_HEADER define.
2038 if ($relative_dir eq &dirname ($config_name))
2040 &define_variable ("CONFIG_HEADER", &basename ($config_name));
2044 &define_variable ("CONFIG_HEADER",
2045 "${top_builddir}/${config_name}");
2049 # Now look for other files in this directory which must be remade
2050 # by config.status, and generate rules for them.
2051 local (@actual_other_files) = ();
2052 local ($file, $local, $input);
2053 foreach $file (@other_input_files)
2055 # Skip files not in this directory, any Makefile, and the
2056 # config header. These last two must be handled specially.
2057 next unless &dirname ($file) eq $relative_dir;
2058 next if $file eq $top_builddir . '/' . $config_name;
2059 ($local = $file) =~ s/^.*\///;
2060 next if $local eq 'Makefile';
2062 if ($local =~ /^(.*):(.*)$/)
2064 # This is the ":" syntax of AC_OUTPUT.
2071 $input = $local . '.in';
2073 # FIXME: when using autoconf ":" syntax, should we set CONFIG_FILES
2075 $output_rules .= ($local . ': '
2076 . '$(top_builddir)/config.status ' . $input . "\n"
2078 . 'cd $(top_builddir) && CONFIG_FILES='
2079 . ($relative_dir eq '.' ? '' : '$(subdir)/')
2080 . '$@ CONFIG_HEADERS= ./config.status'
2082 push (@actual_other_files, $local);
2084 &require_file_with_conf_line ($ac_output_line, $FOREIGN,
2088 # These files get removed by "make clean".
2089 &define_pretty_variable ('CONFIG_CLEAN_FILES', @actual_other_files);
2095 $dir_holds_headers = &am_install_var ('header', 'HEADERS', 'include',
2096 'oldinclude', 'pkginclude',
2102 return if ! $seen_gettext || $relative_dir ne '.';
2104 if (&variable_defined ('SUBDIRS'))
2108 "ud_GNU_GETTEXT in configure.in but \`po' not in SUBDIRS")
2109 if $contents{'SUBDIRS'} !~ /\bpo\b/;
2112 "ud_GNU_GETTEXT in configure.in but \`intl' not in SUBDIRS")
2113 if $contents{'SUBDIRS'} !~ /\bintl\b/;
2116 # Ensure that each language in ALL_LINGUAS has a .po file, and
2117 # each po file is mentioned in ALL_LINGUAS.
2120 local (%linguas) = ();
2121 grep ($linguas{$_} = 1, split (' ', $all_linguas));
2128 &am_line_error ($all_linguas_line,
2129 ("po/$_.po exists but \`$_' not in \`ALL_LINGUAS'"))
2133 foreach (keys %linguas)
2135 &am_line_error ($all_linguas_line,
2136 "$_ in \`ALL_LINGUAS' but po/$_.po does not exist")
2142 &am_error ("ud_GNU_GETTEXT in configure.in but \`ALL_LINGUAS' not defined");
2146 # Handle footer elements.
2149 if ($contents{'SOURCES'})
2151 # NOTE don't use define_pretty_variable here, because
2152 # $contents{...} is already defined.
2153 $output_vars .= 'SOURCES = ' . $contents{'SOURCES'} . "\n";
2155 if ($contents{'OBJECTS'})
2157 # NOTE don't use define_pretty_variable here, because
2158 # $contents{...} is already defined.
2159 $output_vars .= 'OBJECTS = ' . $contents{'OBJECTS'} . "\n";
2161 if ($contents{'SOURCES'} || $contents{'OBJECTS'})
2163 $output_vars .= "\n";
2166 if (defined $contents{'SUFFIXES'})
2168 # Push actual suffixes, and not $(SUFFIXES). Some versions of
2169 # make do not like variable substitutions on the .SUFFIXES
2171 push (@suffixes, split (' ', $contents{'SUFFIXES'}));
2174 $output_trailer .= ".SUFFIXES:\n";
2177 $output_trailer .= ".SUFFIXES: " . join (' ', @suffixes) . "\n";
2179 $output_trailer .= &file_contents ('footer');
2182 # Deal with installdirs target.
2183 sub handle_installdirs
2185 # GNU Makefile standards recommend this.
2186 $output_rules .= ("installdirs:"
2187 . ($recursive_install
2188 ? " installdirs-recursive\n"
2190 push (@phony, 'installdirs');
2193 &pretty_print_rule ("\t" . '$(mkinstalldirs) ', "\t\t",
2196 $output_rules .= "\n";
2199 # There are several targets which need to be merged. This is because
2200 # their complete definition is compiled from many parts. Note that we
2201 # avoid double colon rules, otherwise we'd use them instead.
2202 sub handle_merge_targets
2204 # There are a few install-related variables that you should not define.
2206 foreach $var ('PRE_INSTALL', 'POST_INSTALL', 'NORMAL_INSTALL')
2208 if (&variable_defined ($var))
2210 &am_line_error ($var, "\`$var' should not be defined");
2214 push (@all, 'Makefile');
2215 push (@all, $config_name)
2216 if $config_name && &dirname ($config_name) eq $relative_dir;
2218 &do_one_merge_target ('info', @info);
2219 &do_one_merge_target ('dvi', @dvi);
2221 if (! &variable_defined ('SUBDIRS') || $relative_dir ne '.')
2223 # 'check' must depend on 'all', but not at top level.
2225 unshift (@check, 'all');
2226 unshift (@install, 'all');
2228 &do_one_merge_target ('check', @check);
2229 &do_one_merge_target ('installcheck', @installcheck);
2231 # Handle the various install targets specially. We do this so
2232 # that (eg) "make install-exec" will run "install-exec-recursive"
2233 # if required, but "make install" won't run it twice. Step one is
2234 # to see if the user specified local versions of any of the
2235 # targets we handle. "all" is treated as one of these since
2236 # "install" can run it.
2237 push (@install_exec, 'install-exec-local')
2238 if defined $contents{'install-exec-local'};
2239 push (@install_data, 'install-data-local')
2240 if defined $contents{'install-data-local'};
2241 push (@uninstall, 'uninstall-local')
2242 if defined $contents{'uninstall-local'};
2244 foreach $utarg ('uninstall-data-local', 'uninstall-data-hook',
2245 'uninstall-exec-local', 'uninstall-exec-hook')
2247 if (defined $contents{$utarg})
2250 ($x = $utarg) =~ s/(data|exec)-//;
2251 &am_line_error ($utarg, "use \`$x', not \`$utarg'");
2254 push (@all, 'all-local')
2255 if defined $contents{'all-local'};
2257 if (defined $contents{'install-local'})
2259 &am_line_error ('install-local',
2260 "use \`install-data' or \`install-exec', not \`install'");
2263 # Step two: if we are doing recursive makes, write out the
2264 # appropriate rules.
2266 if ($recursive_install)
2268 push (@install, 'install-recursive');
2272 local (@hackall) = ();
2273 if ($config_name && &dirname ($config_name) eq $relative_dir)
2276 # This is kind of a hack, but I couldn't see a better
2277 # way to handle it. In this particular case, we need
2278 # to make sure config.h is built before we recurse.
2279 # We can't do this by changing the order of
2280 # dependencies to the "all" because that breaks when
2281 # using parallel makes. Instead we handle things
2283 $output_rules .= ('all-recursive-hack: $(CONFIG_HEADER)'
2284 . "\n\t" . '$(MAKE) all-recursive'
2286 push (@hackall, 'all-recursive-hack');
2287 push (@phony, 'all-recursive-hack');
2291 push (@hackall, 'all-recursive');
2294 $output_rules .= ('all-am: '
2298 push (@all, 'all-am');
2299 push (@phony, 'all-am');
2303 @all = ('all-recursive');
2307 $output_rules .= ('install-exec-am: '
2308 . join (' ', @install_exec)
2310 @install_exec = ('install-exec-recursive', 'install-exec-am');
2311 push (@install, 'install-exec-am');
2312 push (@phony, 'install-exec-am');
2316 @install_exec = ('install-exec-recursive');
2320 $output_rules .= ('install-data-am: '
2321 . join (' ', @install_data)
2323 @install_data = ('install-data-recursive', 'install-data-am');
2324 push (@install, 'install-data-am');
2325 push (@phony, 'install-data-am');
2329 @install_data = ('install-data-recursive');
2333 $output_rules .= ('uninstall-am: '
2334 . join (' ', @uninstall)
2336 @uninstall = ('uninstall-recursive', 'uninstall-am');
2337 push (@phony, 'uninstall-am');
2341 @uninstall = ('uninstall-recursive');
2345 # Step three: print definitions users can use. Code below knows
2346 # that install-exec is done before install-data, beware.
2347 $output_rules .= ("install-exec: "
2348 . join (' ', @install_exec)
2350 $output_rules .= "\t\$(NORMAL_INSTALL)\n";
2351 if (defined $contents{'install-exec-hook'})
2353 $output_rules .= "\t" . '$(MAKE) install-exec-hook' . "\n";
2355 $output_rules .= "\n";
2356 push (@install, 'install-exec') if !$recursive_install;
2357 push (@phony, 'install-exec');
2359 $output_rules .= ("install-data: "
2360 . join (' ', @install_data)
2362 $output_rules .= "\t\$(NORMAL_INSTALL)\n";
2363 if (defined $contents{'install-data-hook'})
2365 $output_rules .= "\t" . '$(MAKE) install-data-hook' . "\n";
2367 $output_rules .= "\n";
2368 push (@install, 'install-data') if !$recursive_install;
2369 push (@phony, 'install-data');
2371 # If no dependencies for 'install', add 'all'. Why? That way
2372 # "make install" at top level of distclean'd distribution won't
2373 # fail because stuff in 'lib' fails to build.
2374 if (! @install || (scalar (@install) == 2
2375 && $install[0] eq 'install-exec'
2376 && $install[1] eq 'install-data'))
2378 push (@install, 'all');
2380 $output_rules .= ('install: '
2381 . join (' ', @install)
2382 # Use "@:" as empty command so nothing prints.
2386 . join (' ', @uninstall)
2388 push (@phony, 'install', 'uninstall');
2390 $output_rules .= ('all: '
2393 push (@phony, 'all');
2395 # Generate the new 'install-strip' target.
2396 $output_rules .= ("install-strip:\n\t"
2397 . '$(MAKE) INSTALL_PROGRAM=\'$(INSTALL_PROGRAM) -s\' install'
2401 # Helper for handle_merge_targets.
2402 sub do_one_merge_target
2404 local ($name, @values) = @_;
2406 if (defined $contents{$name . '-local'})
2408 # User defined local form of target. So include it.
2409 push (@values, $name . '-local');
2410 push (@phony, $name . '-local');
2413 $output_rules .= $name . ":";
2416 $output_rules .= ' ' . join (' ', @values);
2418 $output_rules .= "\n\n";
2419 push (@phony, $name);
2422 # Handle all 'clean' targets.
2425 push (@clean, 'generic');
2426 $output_rules .= &file_contents ('clean');
2427 &push_phony_cleaners ('generic');
2429 local ($target) = $recursive_install ? 'clean-am' : 'clean';
2430 &do_one_clean_target ($target, 'mostly', '', @clean);
2431 &do_one_clean_target ($target, '', 'mostly', @clean);
2432 &do_one_clean_target ($target, 'dist', '', @clean);
2433 &do_one_clean_target ($target, 'maintainer-', 'dist', @clean);
2435 push (@phony, 'clean', 'mostlyclean', 'distclean', 'maintainer-clean');
2438 if ($recursive_install)
2440 @deps = ('am', 'recursive');
2441 &do_one_clean_target ('', 'mostly', '', @deps);
2442 &do_one_clean_target ('', '', '', @deps);
2443 &do_one_clean_target ('', 'dist', '', @deps);
2444 &do_one_clean_target ('', 'maintainer-', '', @deps);
2448 # Helper for handle_clean.
2449 sub do_one_clean_target
2451 local ($target, $name, $last_name, @deps) = @_;
2453 # Special case: if target not passed, then don't generate
2454 # dependency on next "lower" clean target (eg no
2455 # clean<-mostlyclean derivation). In this case the target is
2456 # implicitly known to be 'clean'.
2457 local ($flag) = $target;
2458 $target = 'clean' if ! $flag;
2460 grep (($_ = $name . 'clean-' . $_) && 0, @deps);
2463 if ($last_name || $name ne 'mostly')
2465 push (@deps, $last_name . $target . " ");
2468 # FIXME: not sure if I like the tabs here.
2469 &pretty_print_rule ($name . $target . ": ", "\t\t", @deps);
2471 # FIXME: shouldn't we really print these messages before running
2473 if ($name . $target eq 'maintainer-clean')
2475 # Print a special warning.
2477 ("\t\@echo \"This command is intended for maintainers to use;\"\n"
2478 . "\t\@echo \"it deletes files that may require special "
2479 . "tools to rebuild.\"\n");
2481 $output_rules .= "\trm -f config.status\n"
2482 if $relative_dir eq '.';
2484 elsif ($name . $target eq 'distclean')
2486 $output_rules .= "\trm -f config.status\n";
2488 $output_rules .= "\n";
2491 # Handle .PHONY target.
2494 &pretty_print_rule ('.PHONY:', "", @phony);
2495 $output_rules .= "\n";
2498 # Handle TESTS variable and other checks.
2501 if (defined $options{'dejagnu'})
2503 push (@check, 'check-DEJAGNU');
2504 push (@phony, 'check-DEJAGNU');
2505 $output_rules .= &file_contents ('dejagnu') . "\n";
2506 # Note that in the rule we don't directly generate site.exp to
2507 # avoid the possibility of a corrupted site.exp if make is
2508 # interrupted. Jim Meyering has some useful text on this
2510 $output_rules .= ("site.exp: Makefile\n"
2511 . "\t\@echo 'Making a new site.exp file...'\n"
2512 . "\t-\@rm -f site.bak\n"
2513 . "\t\@echo '## these variables are automatically generated by make ##' > \$\@-t\n"
2514 . "\t\@echo '# Do not edit here. If you wish to override these values' >> \$\@-t\n"
2515 . "\t\@echo '# edit the last section' >> \$\@-t\n"
2516 . "\t\@echo 'set tool \$(DEJATOOL)' >> \$\@-t\n"
2517 . "\t\@echo 'set srcdir \$(srcdir)' >> \$\@-t\n"
2518 . "\t\@echo 'set objdir' \`pwd\` >> \$\@-t\n");
2520 # Extra stuff for AC_CANONICAL_*
2521 local (@whatlist) = ();
2522 if ($seen_canonical)
2524 push (@whatlist, 'host')
2527 # Extra stuff only for AC_CANONICAL_SYSTEM.
2528 if ($seen_canonical == $AC_CANONICAL_SYSTEM)
2530 push (@whatlist, 'target', 'build');
2534 foreach $c1 (@whatlist)
2536 foreach $c2 ('alias', 'triplet')
2538 $output_rules .= "\t\@echo 'set ${c1}_${c2} \$(${c1}_${c2})' >> \$\@-t\n";
2542 $output_rules .= ("\t\@echo '## All variables above are generated by configure. Do Not Edit ##' >> \$\@-t\n"
2543 . "\t-\@sed '1,/^## All variables above are.*##/ d' site.bak >> \$\@-t\n"
2544 . "\t-\@mv site.exp site.bak\n"
2545 . "\t\@mv \$\@-t site.exp\n");
2550 foreach $c ('DEJATOOL', 'RUNTEST', 'RUNTESTFLAGS')
2552 if (&variable_defined ($c))
2554 &am_line_error ($c, "\`$c' defined but \`dejagnu' not in \`AUTOMAKE_OPTIONS'");
2559 if (&variable_defined ('TESTS'))
2561 push (@check, 'check-TESTS');
2562 push (@phony, 'check-TESTS');
2563 # FIXME: use $(SHELL) here? That is what Ulrich suggests.
2564 # Maybe a new macro, $(TEST_SHELL), a la $(CONFIG_SHELL)? For
2565 # now we just execute the file directly; this allows test
2566 # files which are compiled -- a possibly useful feature.
2567 $output_rules .= 'check-TESTS: $(TESTS)
2568 @failed=0; all=0; \\
2569 srcdir=$(srcdir); export srcdir; \\
2570 for tst in $(TESTS); do \\
2571 all=`expr $$all + 1`; \\
2572 if test -f $$tst; then dir=.; \\
2573 else dir="$(srcdir)"; fi; \\
2574 if $(TESTS_ENVIRONMENT) $$dir/$$tst; then \\
2575 echo "PASS: $$tst"; \\
2577 failed=`expr $$failed + 1`; \\
2578 echo "FAIL: $$tst"; \\
2581 if test "$$failed" -eq 0; then \\
2582 echo "========================"; \\
2583 echo "All $$all tests passed"; \\
2584 echo "========================"; \\
2586 echo "$$failed of $$all tests failed"; \\
2592 # Handle Emacs Lisp.
2593 sub handle_emacs_lisp
2595 local (@elfiles) = &am_install_var ('lisp', 'LISP', 'lisp', 'noinst');
2600 &define_variable ("lispdir", "\@lispdir\@");
2601 $output_rules .= (".el.elc:\n"
2602 . "\t\@echo 'WARNING: Warnings can be ignored. :-)'\n"
2603 . "\t\$(SHELL) \$(srcdir)/elisp-comp \$<\n");
2604 push (@suffixes, '.el', '.elc');
2606 # Generate .elc files.
2607 grep ($_ .= 'c', @elfiles);
2608 &define_pretty_variable ('ELCFILES', @elfiles);
2610 push (@clean, 'lisp');
2611 &push_phony_cleaners ('lisp');
2614 if (&variable_defined ('lisp_LISP'))
2616 $varname = 'lisp_LISP';
2617 &am_error ("\`lisp_LISP' defined but \`AM_PATH_LISPDIR' not in \`configure.in'")
2622 $varname = 'noinst_LISP';
2625 &require_file_with_line ($varname, $FOREIGN, 'elisp-comp');
2629 ################################################################
2631 # Scan configure.in for interesting things.
2634 open (CONFIGURE, 'configure.in')
2635 || die "automake: couldn't open \`configure.in': $!\n";
2636 print "automake: reading configure.in\n" if $verbose;
2638 # Reinitialize libsources here. This isn't really necessary,
2639 # since we currently assume there is only one configure.in. But
2640 # that won't always be the case.
2643 local ($in_ac_output, @make_list) = 0;
2644 local ($libobj_iter);
2647 # Remove comments from current line.
2651 # Populate libobjs array.
2652 if (/AC_FUNC_ALLOCA/)
2654 $libsources{'alloca.c'} = 1;
2656 elsif (/AC_FUNC_GETLOADAVG/)
2658 $libsources{'getloadavg.c'} = 1;
2660 elsif (/AC_FUNC_MEMCMP/)
2662 $libsources{'memcmp.c'} = 1;
2664 elsif (/AC_STRUCT_ST_BLOCKS/)
2666 $libsources{'fileblocks.c'} = 1;
2668 elsif (/AM_FUNC_FNMATCH/)
2670 $libsources{'fnmatch.c'} = 1;
2672 elsif (/AC_REPLACE_FUNCS\s*\((.*)\)/)
2674 foreach (split (' ', $1))
2676 $libsources{$_ . '.c'} = 1;
2679 elsif (/A[CM]_REPLACE_GNU_GETOPT/)
2681 $libsources{'getopt.c'} = 1;
2682 $libsources{'getopt1.c'} = 1;
2684 elsif (/AM_FUNC_STRTOD/)
2686 $libsources{'strtod.c'} = 1;
2688 elsif (/AM_WITH_REGEX/)
2690 $libsources{'rx.c'} = 1;
2691 $libsources{'rx.h'} = 1;
2692 $libsources{'regex.c'} = 1;
2693 $libsources{'regex.h'} = 1;
2695 elsif (/LIBOBJS="(.*)\s+\$LIBOBJS"/
2696 || /LIBOBJS="\$LIBOBJS\s+(.*)"/)
2698 foreach $libobj_iter (split (' ', $1))
2700 if ($libobj_iter =~ /^(.*)\.o$/)
2702 $libsources{$1 . '.c'} = 1;
2707 if (/(fp_FUNC_FNMATCH|fp_PROG_INSTALL|fp_C_PROTOTYPES|jm_MAINTAINER_MODE)/)
2709 &am_conf_line_error ($., "\`$1' is obsolete; use corresponding \`AM_' macro");
2712 # Process the AC_OUTPUT macro.
2713 if (! $in_ac_output && s/AC_OUTPUT\s*\(\[?//)
2716 $ac_output_line = $.;
2720 $in_ac_output = 0 if s/[\]\),].*$//;
2722 # Look at potential Makefile.am's.
2728 push (@make_list, $_);
2732 push (@other_input_files, $_);
2737 if (/AC_CONFIG_AUX_DIR\(([^)]+)\)/)
2739 @config_aux_path = $1;
2742 # Check for ansi2knr.
2743 $am_c_prototypes = 1 if /AM_C_PROTOTYPES/;
2745 # Check for NLS support.
2746 if (/ud_GNU_GETTEXT/)
2749 $ac_gettext_line = $.;
2752 # Look for ALL_LINGUAS.
2753 if (/ALL_LINGUAS="(.*)"$/ || /ALL_LINGUAS=(.*)$/)
2757 $all_linguas_line = $.;
2760 # Handle configuration headers.
2761 if (/AC_CONFIG_HEADER\s*\((.*)\)/)
2763 $config_header_line = $.;
2765 if ($config_name =~ /^([^:]+):(.+)$/)
2768 $config_header = $2;
2772 $config_header = $config_name . '.in';
2776 # Handle AC_CANONICAL_*. Always allow upgrading to
2777 # AC_CANONICAL_SYSTEM, but never downgrading.
2778 $seen_canonical = $AC_CANONICAL_HOST
2779 if ! $seen_canonical
2780 && (/AC_CANONICAL_HOST/ || /AC_CHECK_TOOL/);
2781 $seen_canonical = $AC_CANONICAL_SYSTEM if /AC_CANONICAL_SYSTEM/;
2783 $seen_path_xtra = 1 if /AC_PATH_XTRA/;
2785 # Sometimes it is desirable to explicitly set YACC. For
2786 # instance some people don't want to use bison.
2787 $seen_prog_yacc = 1 if (/AC_PROG_YACC/
2788 || /AC_SUBST\(YACC\)/
2789 || /AC_(PATH|CHECK)_PROGS?\(YACC/);
2791 # This macro handles several different things.
2792 if (/AM_INIT_AUTOMAKE\([^,]*,([^)]+)\)/)
2798 $seen_prog_install = 2;
2799 ($package_version = $1) =~ s/\s//;
2800 $package_version_line = $.;
2803 # Some things required by Automake.
2804 $seen_make_set = 1 if /AC_PROG_MAKE_SET/;
2805 $seen_arg_prog = 1 if /AC_ARG_PROGRAM/;
2806 $seen_ranlib = 1 if /AC_PROG_RANLIB/;
2807 $seen_prog_cc = 1 if /AC_PROG_CC/;
2808 $seen_prog_cxx = 1 if /AC_PROG_CXX/;
2809 $seen_prog_lex = 1 if /AC_PROG_LEX/;
2810 $seen_decl_yytext = 1 if /AC_DECL_YYTEXT/;
2811 $seen_maint_mode = 1 if /AM_MAINTAINER_MODE/;
2812 $seen_package = 1 if /PACKAGE=/;
2814 if (/VERSION=(\S+)/)
2817 $package_version = $1;
2818 $package_version_line = $.;
2825 # Weird conditionals here because it is always allowed to
2826 # upgrade to AM_PROG_INSTALL but never to downgrade to
2828 $seen_prog_install = 1 if ! $seen_prog_install && /AC_PROG_INSTALL/;
2829 $seen_prog_install = 2 if /AM_PROG_INSTALL/;
2831 $seen_lispdir = 1 if /AM_PATH_LISPDIR/;
2833 if (/AM_PROG_LIBTOOL/)
2841 # Set input files if not specified by user.
2842 @input_files = @make_list if (! @input_files);
2846 &am_conf_error ("\`PACKAGE' not defined in configure.in")
2848 &am_conf_error ("\`VERSION' not defined in configure.in")
2851 # Look for some files we need. Always check for these. This
2852 # check must be done for every run, even those where we are only
2853 # looking at a subdir Makefile. We must set relative_dir so that
2854 # the file-finding machinery works.
2855 local ($relative_dir) = '.';
2856 &require_config_file ($FOREIGN, 'install-sh', 'mkinstalldirs');
2857 &am_error ("\`install.sh' is an anachronism; use \`install-sh' instead")
2858 if -f $config_aux_path[0] . '/install.sh';
2861 ################################################################
2863 # Do any extra checking for GNU standards.
2864 sub check_gnu_standards
2866 if ($relative_dir eq '.')
2868 # In top level (or only) directory.
2869 &require_file ($GNU, 'INSTALL', 'NEWS', 'README', 'COPYING',
2870 'AUTHORS', 'ChangeLog');
2873 if ($strictness >= $GNU)
2875 if (defined $options{'no-installman'})
2877 &am_line_error ('AUTOMAKE_OPTIONS',
2878 "option \`no-installman' disallowed by GNU standards");
2881 if (defined $options{'no-installinfo'})
2883 &am_line_error ('AUTOMAKE_OPTIONS',
2884 "option \`no-installinfo' disallowed by GNU standards");
2889 # Do any extra checking for GNITS standards.
2890 sub check_gnits_standards
2892 if ($strictness >= $GNITS)
2894 if (-f $relative_dir . '/COPYING.LIB')
2896 &am_error ("\`${relative_dir}/COPYING.LIB' disallowed by Gnits standards");
2899 if ($relative_dir eq '.')
2901 if ($package_version !~ /^$GNITS_VERSION_PATTERN$/)
2903 &am_conf_line_error ($package_version_line,
2904 "version \`$package_version' doesn't follow Gnits standards");
2906 elsif (defined $1 && -f 'README-alpha')
2908 # This means we have an alpha release. See
2909 # GNITS_VERSION_PATTERN for details.
2910 &require_file ($GNITS, 'README-alpha');
2915 if ($relative_dir eq '.')
2917 # In top level (or only) directory.
2918 &require_file ($GNITS, 'THANKS');
2922 ################################################################
2924 # Pretty-print something. HEAD is what should be printed at the
2925 # beginning of the first line, FILL is what should be printed at the
2926 # beginning of every subsequent line.
2927 sub pretty_print_internal
2929 local ($head, $fill, @values) = @_;
2931 local ($column) = length ($head);
2932 local ($result) = $head;
2934 # Fill length is number of characters. However, each Tab
2935 # character counts for eight. So we count the number of Tabs and
2937 local ($fill_length) = length ($fill);
2938 $fill_length += 7 * ($fill =~ tr/\t/\t/d);
2943 # "71" because we also print a space.
2944 if ($column + length ($_) > 71)
2946 $result .= " \\\n" . $fill;
2947 $column = $fill_length;
2951 $result .= ' ' unless ($bol);
2953 $column += length ($_) + 1;
2961 # Pretty-print something and append to output_vars.
2964 $output_vars .= &pretty_print_internal (@_);
2967 # Pretty-print something and append to output_rules.
2968 sub pretty_print_rule
2970 $output_rules .= &pretty_print_internal (@_);
2974 ################################################################
2976 # See if a variable exists.
2977 sub variable_defined
2980 if (defined $targets{$var})
2982 &am_line_error ($var, "\`$var' is target; expected variable");
2985 elsif (defined $contents{$var})
2987 $content_seen{$var} = 1;
2993 # Mark a variable as examined.
2994 sub examine_variable
2997 &variable_defined ($var);
3000 # Return contents of variable as list, split as whitespace. This will
3001 # recursively follow $(...) and ${...} inclusions. It preserves @...@
3002 # substitutions. If PARENT is specified, it is the name of the
3003 # including variable; this is only used for error reports.
3004 sub variable_value_as_list
3006 local ($var, $parent) = @_;
3009 if (defined $targets{$var})
3011 &am_line_error ($var, "\`$var' is target; expected variable");
3013 elsif (! defined $contents{$var})
3015 &am_line_error ($parent, "variable \`$var' not defined");
3019 $content_seen{$var} = 1;
3020 foreach (split (' ', $contents{$var}))
3022 # If a comment seen, just leave.
3025 # Handle variable substitutions.
3026 if (/^\$\{(.*)\}$/ || /^\$\((.*)\)$/)
3028 push (@result, &variable_value_as_list ($1, $var));
3040 # Define a new variable, but only if not already defined.
3043 local ($var, $value) = @_;
3045 if (! defined $contents{$var})
3047 $output_vars .= $var . ' = ' . $value . "\n";
3048 $contents{$var} = $value;
3049 $content_seen{$var} = 1;
3053 # Like define_variable, but second arg is a list, and is
3055 sub define_pretty_variable
3057 local ($var, @value) = @_;
3058 if (! defined $contents{$var})
3060 $contents{$var} = join (' ', @value);
3061 &pretty_print ($var . ' = ', '', @value);
3062 $content_seen{$var} = 1;
3066 # Read Makefile.am and set up %contents. Simultaneously copy lines
3067 # from Makefile.am into $output_trailer or $output_vars as
3068 # appropriate. NOTE we put rules in the trailer section. We want
3069 # user rules to come after our generated stuff.
3072 local ($amfile) = @_;
3074 open (AM_FILE, $amfile) || die "automake: couldn't open \`$amfile': $!\n";
3075 print "automake: reading $amfile\n" if $verbose;
3077 $output_vars = ("# $in_file_name generated automatically by automake "
3078 . $VERSION . " from $am_file_name\n");
3080 # Generate copyright for generated Makefile.in.
3081 $output_vars .= $gen_copyright;
3083 local ($saw_bk) = 0;
3084 local ($was_rule) = 0;
3085 local ($spacing) = '';
3086 local ($comment) = '';
3087 local ($last_var_name) = '';
3092 if (/$IGNORE_PATTERN/o)
3094 # Merely delete comments beginning with two hashes.
3096 elsif (/$WHITE_PATTERN/o)
3098 # Stick a single white line before the incoming macro or rule.
3102 elsif (/$COMMENT_PATTERN/o)
3104 # Stick comments before the incoming macro or rule. Make
3105 # sure a blank line preceeds first block of comments.
3106 $spacing = "\n" unless $blank;
3108 $comment .= $spacing . $_;
3117 $output_vars .= $comment . "\n";
3120 local ($am_vars) = '';
3122 local ($is_ok_macro);
3126 unless substr ($_, -1, 1) eq "\n";
3128 $_ =~ s/\@(UN)?MAINT\@//g
3129 unless $seen_maint_mode;
3131 if (/$IGNORE_PATTERN/o)
3133 # Merely delete comments beginning with two hashes.
3135 elsif (/$WHITE_PATTERN/o)
3137 # Stick a single white line before the incoming macro or rule.
3140 elsif (/$COMMENT_PATTERN/o)
3142 # Stick comments before the incoming macro or rule.
3143 $comment .= $spacing . $_;
3150 $output_trailer .= $_;
3157 # Chop newline and backslash if this line is
3158 # continued. FIXME: maybe ensure trailing whitespace
3162 $contents{$last_var_name} .= $_;
3165 elsif (/$RULE_PATTERN/o)
3167 # warn "** Saw rule .$1.\n";
3170 # Value here doesn't matter; for targets we only note
3174 $content_lines{$1} = $.;
3175 $output_trailer .= $comment . $spacing . $_;
3176 $comment = $spacing = '';
3179 elsif (($is_ok_macro = /$MACRO_PATTERN/o)
3180 || /$BOGUS_MACRO_PATTERN/o)
3182 # Found a macro definition.
3184 $last_var_name = $1;
3185 if (substr ($2, -1) eq "\\")
3187 $contents{$1} = substr ($2, 0, length ($2) - 1);
3193 $content_lines{$1} = $.;
3194 $am_vars .= $comment . $spacing . $_;
3195 $comment = $spacing = '';
3199 &am_line_error ($., "bad macro name \`$1'")
3204 # This isn't an error; it is probably a continued rule.
3205 # In fact, this is what we assume.
3207 $output_trailer .= $comment . $spacing . $_;
3208 $comment = $spacing = '';
3215 $output_trailer .= $comment;
3217 # Compute relative location of the top object directory.
3218 local (@topdir) = ();
3219 foreach (split (/\//, $relative_dir))
3221 next if $_ eq '.' || $_ eq '';
3228 push (@topdir, '..');
3231 @topdir = ('.') if ! @topdir;
3233 $top_builddir = join ('/', @topdir);
3235 ($build_rx = $top_builddir) =~ s/(\W)/\\$1/g;
3236 $output_vars .= &file_contents_with_transform
3237 ('s/\@top_builddir\@/' . $build_rx . '/g',
3240 # Generate some useful variables when AC_CANONICAL_* used.
3241 if ($seen_canonical)
3243 local ($curs, %vars);
3244 $vars{'host_alias'} = 'host_alias';
3245 $vars{'host_triplet'} = 'host';
3246 if ($seen_canonical == $AC_CANONICAL_SYSTEM)
3248 $vars{'build_alias'} = 'build_alias';
3249 $vars{'build_triplet'} = 'build';
3250 $vars{'target_alias'} = 'target_alias';
3251 $vars{'target_triplet'} = 'target';
3253 foreach $curs (keys %vars)
3255 $output_vars .= "$curs = \@$vars{$curs}\@\n";
3256 $contents{$curs} = "\@$vars{$curs}\@";
3260 $output_vars .= $am_vars;
3263 ################################################################
3265 sub initialize_global_constants
3267 # Values for AC_CANONICAL_*
3268 $AC_CANONICAL_HOST = 1;
3269 $AC_CANONICAL_SYSTEM = 2;
3271 # Associative array of standard directory names. Entry is TRUE if
3272 # corresponding directory should be installed during
3273 # 'install-exec' phase.
3291 # Helper text for dealing with man pages.
3292 $install_man_format =
3293 ' sect=@SECTION@; \\
3294 inst=`echo "@MANBASE@" | sed \'$(transform)\'`.@FULLSECT@; \\
3295 if test -f $(srcdir)/@MAN@; then file=$(srcdir)/@MAN@; \\
3296 else file=@MAN@; fi; \\
3297 $(INSTALL_DATA) $$file $(mandir)/man$$sect/$$inst
3300 $uninstall_man_format =
3301 ' inst=`echo "@MANBASE@" | sed \'$(transform)\'`.@FULLSECT@; \\
3302 rm -f $(mandir)/man@SECTION@/$$inst
3305 # Commonly found files we look for and automatically include in
3309 "README", "THANKS", "TODO", "NEWS", "COPYING", "COPYING.LIB",
3310 "INSTALL", "ABOUT-NLS", "ChangeLog", "configure", "configure.in",
3311 "config.guess", "config.sub", "AUTHORS", "BACKLOG", "ABOUT-GNU",
3312 "libversion.in", "mdate-sh", "mkinstalldirs", "install-sh",
3313 'texinfo.tex', "ansi2knr.c", "ansi2knr.1", 'elisp-comp',
3314 'interlock', 'ylwrap', 'acinclude.m4'
3317 # Commonly used files we auto-include, but only sometimes.
3320 "aclocal.m4", "acconfig.h", "config.h.top",
3321 "config.h.bot", "stamp-h.in", 'stamp-vti', 'libtool'
3325 -a, --add-missing add missing standard files to package
3326 --amdir=DIR directory storing config files
3327 --build-dir=DIR directory where build being done (for dependencies)
3328 --foreign same as --strictness=foreign
3329 --gnits same as --strictness=gnits
3330 --gnu same as --strictness=gnu
3331 --help print this help, then exit
3332 -i, --include-deps include generated dependencies in Makefile.in
3333 --no-force only update Makefile.in's that are out of date
3334 -o DIR, --output-dir=DIR
3335 put generated Makefile.in's into DIR
3336 --srcdir-name=DIR name used for srcdir (for dependencies)
3337 -s LEVEL, --strictness=LEVEL
3338 set strictness level. LEVEL is foreign, gnu, gnits
3339 -v, --verbose verbosely list files processed
3340 --version print version number, then exit\n";
3342 # Copyright on generated Makefile.ins.
3344 # Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
3345 # This Makefile.in is free software; the Free Software Foundation
3346 # gives unlimited permission to copy, distribute and modify it.
3349 # Ignore return result from chmod, because it might give an error
3350 # if we chmod a symlink.
3351 $dist_header = "\t" . '-chmod -R a+r $(distdir)' . "\n";
3352 $dist{'tarZ'} = ("\t"
3353 . '$(TAR) chf - $(distdir) | compress -c > $(distdir).tar.Z'
3355 $dist{'shar'} = ("\t"
3356 . 'shar $(distdir) | gzip > $(distdir).shar.gz'
3358 $dist{'zip'} = "\t" . 'zip -rq $(distdir).zip $(distdir)' . "\n";
3359 $dist{'dist'} = "\t" . '$(TAR) chozf $(distdir).tar.gz $(distdir)' . "\n";
3360 $dist_trailer = "\t" . 'rm -rf $(distdir)' . "\n";
3363 # (Re)-Initialize per-Makefile.am variables.
3364 sub initialize_per_input
3366 # These two variables are used when generating each Makefile.in.
3367 # They hold the Makefile.in until it is ready to be printed.
3370 $output_trailer = '';
3372 # Suffixes found during a run.
3375 # This holds the contents of a Makefile.am, as parsed by
3379 # This holds the names which are targets. These also appear in
3383 # This holds the line numbers at which various elements of
3384 # %contents are defined.
3385 %content_lines = ();
3387 # This holds a 1 if a particular variable was examined.
3390 # This holds the "relative directory" of the current Makefile.in.
3391 # Eg for src/Makefile.in, this is "src".
3394 # This holds a list of files that are included in the
3398 # List of dependencies for the obvious targets.
3413 # These are pretty obvious, too. They are used to define the
3414 # SOURCES and OBJECTS variables.
3418 # TRUE if current directory holds any C source files. (Actually
3419 # holds object extension, but this information is encapsulated in
3420 # the function get_object_extension).
3421 $dir_holds_sources = '';
3423 # TRUE if current directory holds any headers.
3424 $dir_holds_headers = 0;
3426 # TRUE if install targets should work recursively.
3427 $recursive_install = 0;
3432 # Strictness levels.
3433 $strictness = $default_strictness;
3434 $strictness_name = $default_strictness_name;
3436 # Options from AUTOMAKE_OPTIONS.
3439 # Whether or not dependencies are handled. Can be further changed
3440 # in handle_options.
3441 $use_dependencies = $cmdline_use_dependencies;
3444 $local_maint_charset = $maint_charset;
3446 # All yacc and lex source filenames for this directory. Use
3447 # filenames instead of raw count so that multiple instances are
3448 # counted correctly (eg one yacc file can appear in multiple
3449 # programs without harm).
3453 # C++ source extensions we've seen.
3454 %cxx_extensions = ();
3456 # TRUE if we've seen any non-C++ sources.
3461 ################################################################
3463 # Return contents of a file from $am_dir, automatically skipping
3464 # macros or rules which are already known. Runs command on each line
3465 # as it is read; this command can modify $_.
3466 sub file_contents_with_transform
3468 local ($command, $basename) = @_;
3469 local ($file) = $am_dir . '/' . $basename . '.am';
3471 open (FC_FILE, $file)
3472 || die "automake: installation error: cannot open \`$file'\n";
3474 # print "automake: reading $file\n" if $verbose;
3476 local ($was_rule) = 0;
3477 local ($result_vars) = '';
3478 local ($result_rules) = '';
3479 local ($comment) = '';
3480 local ($spacing) = "\n";
3481 local ($skipping) = 0;
3485 $_ =~ s/\@(UN)?MAINT\@//g
3486 unless $seen_maint_mode;
3490 if (/$IGNORE_PATTERN/o)
3492 # Merely delete comments beginning with two hashes.
3494 elsif (/$WHITE_PATTERN/o)
3496 # Stick a single white line before the incoming macro or rule.
3499 elsif (/$COMMENT_PATTERN/o)
3501 # Stick comments before the incoming macro or rule.
3502 $comment .= $spacing . $_;
3509 $result_rules .= $_ if ! $skipping;
3513 $result_vars .= $_ if ! $skipping;
3517 elsif (/$RULE_PATTERN/o)
3519 # warn "** Found rule .$1.\n";
3522 $skipping = defined $contents{$1};
3523 # warn "** Skip $skipping\n" if $skipping;
3524 $result_rules .= $comment . $spacing . $_ if ! $skipping;
3525 $comment = $spacing = '';
3528 elsif (/$MACRO_PATTERN/o)
3530 # warn "** Found macro .$1.\n";
3531 # Found a variable reference.
3533 $skipping = defined $contents{$1};
3534 # warn "** Skip $skipping\n" if $skipping;
3535 $result_vars .= $comment . $spacing . $_ if ! $skipping;
3536 $comment = $spacing = '';
3541 # This isn't an error; it is probably a continued rule.
3542 # In fact, this is what we assume.
3544 $result_rules .= $comment . $spacing . $_ if ! $skipping;
3545 $comment = $spacing = '';
3551 return $result_vars . $result_rules . $comment;
3554 # Like file_contents_with_transform, but no transform.
3557 return &file_contents_with_transform ('', @_);
3560 # Find all variable prefixes that are used for install directories. A
3561 # prefix `zar' qualifies iff:
3562 # * `zardir' is a variable.
3563 # * `zar_PRIMARY' is a variable.
3564 sub am_primary_prefixes
3566 local ($primary, @prefixes) = @_;
3568 local (%valid, $varname);
3569 grep ($valid{$_} = 0, @prefixes);
3570 $valid{'EXTRA'} = 0;
3571 foreach $varname (keys %contents)
3573 if ($varname =~ /^(.*)_$primary$/)
3575 if (! defined $valid{$1} && ! &variable_defined ($1 . 'dir'))
3577 &am_line_error ($varname, "invalid variable \"$varname\"");
3581 # Ensure all extended prefixes are actually used.
3590 # Handle `where_HOW' variable magic. Does all lookups, generates
3591 # install code, and possibly generates code to define the primary
3592 # variable. The first argument is the name of the .am file to munge,
3593 # the second argument is the primary variable (eg HEADERS), and all
3594 # subsequent arguments are possible installation locations. Returns
3595 # list of all values of all _HOW targets.
3597 # FIXME: this should be rewritten to be cleaner. It should be broken
3598 # up into multiple functions.
3600 # Usage is: am_install_var (OPTION..., file, HOW, where...)
3605 local ($do_all, $do_clean) = (1, 0);
3608 if ($args[0] eq '-clean')
3612 elsif ($args[0] eq '-no-all')
3616 elsif ($args[0] !~ /^-/)
3622 local ($file, $primary, @prefixes) = @args;
3625 local (@result) = ();
3627 # Now that configure substitutions are allowed in where_HOW
3628 # variables, it is an error to actually define the primary.
3629 &am_line_error ($primary, "\`$primary' is an anachronism")
3630 if &variable_defined ($primary);
3633 # Look for misspellings. It is an error to have a variable ending
3634 # in a "reserved" suffix whose prefix is unknown, eg
3635 # "bni_PROGRAMS". However, unusual prefixes are allowed if a
3636 # variable of the same name (with "dir" appended) exists. For
3637 # instance, if the variable "zardir" is defined, then
3638 # "zar_PROGRAMS" becomes valid. This is to provide a little extra
3639 # flexibility in those cases which need it. Perhaps it should be
3640 # disallowed in the Gnits case? The problem is, sometimes it is
3641 # useful to put things in a subdir of eg pkgdatadir, perhaps even
3643 local (%valid) = &am_primary_prefixes ($primary, @prefixes);
3645 # If a primary includes a configure substitution, then the EXTRA_
3646 # form is required. Otherwise we can't properly do our job.
3647 local ($require_extra);
3648 local ($warned_about_extra) = 0;
3650 local ($clean_file) = $file . '-clean';
3653 foreach $X (keys %valid)
3655 $one_name = $X . '_' . $primary;
3656 if (&variable_defined ($one_name))
3658 # Append actual contents of where_PRIMARY variable to
3661 foreach $rcurs (&variable_value_as_list ($one_name))
3663 # Skip configure substitutions. Possibly bogus.
3664 if ($rcurs =~ /^\@.*\@$/)
3668 if (! $warned_about_extra)
3670 $warned_about_extra = 1;
3671 &am_line_error ($one_name,
3672 "\`$one_name' contains configure substitution, but shouldn't");
3677 $require_extra = $one_name;
3681 push (@result, $rcurs);
3684 # "EXTRA" shouldn't be used when generating clean targets,
3685 # @all, or install targets.
3686 next if $X eq 'EXTRA';
3691 &file_contents_with_transform ('s/\@DIR\@/' . $X . '/go',
3694 push (@clean, $X . $primary);
3695 &push_phony_cleaners ($X . $primary);
3700 push (@check, '$(' . $one_name . ')');
3704 push (@used, '$(' . $one_name . ')');
3706 if ($X eq 'noinst' || $X eq 'check')
3708 # Objects which don't get installed by default.
3713 &file_contents_with_transform ('s/\@DIR\@/' . $X . '/go',
3716 push (@uninstall, 'uninstall-' . $X . $primary);
3717 push (@phony, 'uninstall-' . $X . $primary);
3718 push (@installdirs, '$(' . $X . 'dir)');
3719 if ($exec_dir_p{$X})
3721 push (@install_exec, 'install-' . $X . $primary);
3722 push (@phony, 'install-' . $X . $primary);
3726 push (@install_data, 'install-' . $X . $primary);
3727 push (@phony, 'install-' . $X . $primary);
3735 &define_pretty_variable ($primary, @used);
3736 $output_vars .= "\n";
3739 if ($require_extra && ! &variable_defined ('EXTRA_' . $primary))
3741 &am_line_error ($require_extra,
3742 "\`$require_extra' contains configure substitution, but \`EXTRA_$primary' not defined");
3745 # Push here because PRIMARY might be configure time determined.
3746 push (@all, '$(' . $primary . ')')
3747 if $do_all && @used;
3753 ################################################################
3755 # This variable is local to the "require file" set of functions.
3756 @require_file_paths = ();
3758 # Verify that the file must exist in the current directory. Usage:
3759 # require_file (isconfigure, line_number, strictness, file) strictness
3760 # is the strictness level at which this file becomes required. Must
3761 # set require_file_paths before calling this function.
3762 # require_file_paths is set to hold a single directory (the one in
3763 # which the first file was found) before return.
3764 sub require_file_internal
3766 local ($is_configure, $line, $mystrict, @files) = @_;
3767 local ($file, $fullfile);
3768 local ($found_it, $errfile, $errdir);
3771 foreach $file (@files)
3774 foreach $dir (@require_file_paths)
3778 $fullfile = $relative_dir . "/" . $file;
3779 $errdir = $relative_dir unless $errdir;
3783 $fullfile = $dir . "/" . $file;
3784 $errdir = $dir unless $errdir;
3787 # Use different name for "error filename". Otherwise on
3788 # an error the bad file will be reported as eg
3789 # `../../install-sh' when using the default
3791 $errfile = $errdir . '/' . $file;
3796 # FIXME: Once again, special-case `.'.
3797 &push_dist_common ($file)
3798 if $dir eq $relative_dir || $dir eq '.';
3806 # Prune the path list.
3807 @require_file_paths = $save_dir;
3811 if ($strictness >= $mystrict)
3813 # Only install missing files according to our desired
3815 if ($add_missing && -f ($am_dir . '/' . $file))
3817 # Install the missing file. Symlink if we can, copy
3819 if ($symlink_exists)
3821 symlink ($am_dir . '/' . $file, $errfile);
3825 system ('cp', $am_dir . '/' . $file, $errfile);
3828 # FIXME: this is a hack. Should have am_warn.
3829 local ($save) = $exit_status;
3834 "required file \"$errfile\" not found; installing");
3840 "required file \"$errfile\" not found; installing");
3842 $exit_status = $save;
3846 # Only an error if strictness constraint violated.
3850 ($line, "required file \"$errfile\" not found");
3855 ($line, "required file \"$errfile\" not found");
3863 # Like require_file_with_line, but error messages refer to
3864 # configure.in, not the current Makefile.am.
3865 sub require_file_with_conf_line
3867 @require_file_paths = '.';
3868 &require_file_internal (1, @_);
3871 sub require_file_with_line
3873 @require_file_paths = '.';
3874 &require_file_internal (0, @_);
3879 @require_file_paths = '.';
3880 &require_file_internal (0, '', @_);
3883 # Require a file that is also required by Autoconf. Looks in
3884 # configuration path, as specified by AC_CONFIG_AUX_DIR.
3885 sub require_config_file
3887 @require_file_paths = @config_aux_path;
3888 &require_file_internal (0, '', @_);
3889 local ($dir) = $require_file_paths[0];
3890 @config_aux_path = @require_file_paths;
3893 $config_aux_dir = '.';
3897 $config_aux_dir = '$(top_srcdir)/' . $dir;
3901 # Assumes that the line number is in Makefile.am.
3902 sub require_conf_file_with_line
3904 @require_file_paths = @config_aux_path;
3905 &require_file_internal (0, @_);
3906 local ($dir) = $require_file_paths[0];
3907 @config_aux_path = @require_file_paths;
3910 $config_aux_dir = '.';
3914 $config_aux_dir = '$(top_srcdir)/' . $dir;
3918 # Assumes that the line number is in Makefile.am.
3919 sub require_conf_file_with_conf_line
3921 @require_file_paths = @config_aux_path;
3922 &require_file_internal (1, @_);
3923 local ($dir) = $require_file_paths[0];
3924 @config_aux_path = @require_file_paths;
3927 $config_aux_dir = '.';
3931 $config_aux_dir = '$(top_srcdir)/' . $dir;
3935 ################################################################
3937 # Push a list of files onto dist_common.
3938 sub push_dist_common
3940 local (@files) = @_;
3943 foreach $file (@files)
3945 $dist_common{$file} = 1;
3949 # Push a list of clean targets onto phony.
3950 sub push_phony_cleaners
3954 foreach $target ('mostly', 'dist', '', 'maintainer-')
3956 push (@phony, $target . 'clean-' . $base);
3963 $strictness_name = $_[0];
3964 if ($strictness_name eq 'gnu')
3968 elsif ($strictness_name eq 'gnits')
3970 $strictness = $GNITS;
3972 elsif ($strictness_name eq 'foreign')
3974 $strictness = $FOREIGN;
3978 die "automake: level \`$strictness_name' not recognized\n";
3983 ################################################################
3985 # Return directory name of file.
3991 ($sub = $file) =~ s,/+[^/]+$,,g;
3992 $sub = '.' if $sub eq $file;
3996 # Return file name of a file.
4002 ($sub = $file) =~s,^.*/+,,g;
4011 open (TOUCH, ">> $file");
4015 ################################################################
4017 # Print an error message and set exit status.
4020 warn "automake: ${am_file}.am: ", join (' ', @_), "\n";
4026 local ($symbol, @args) = @_;
4030 # If SYMBOL not already a line number, look it up in Makefile.am.
4031 $symbol = $content_lines{$symbol} unless $symbol =~ /^\d+$/;
4032 $symbol .= ': ' if $symbol;
4033 warn "${am_file}.am:", $symbol, join (' ', @args), "\n";
4042 # Like am_error, but while scanning configure.in.
4045 # FIXME: can run in subdirs.
4046 warn "automake: configure.in: ", join (' ', @_), "\n";
4050 # Error message with line number referring to configure.in.
4051 sub am_conf_line_error
4053 local ($line, @args) = @_;
4057 warn "configure.in: $line: ", join (' ', @args), "\n";
4062 &am_conf_error (@args);
4066 # Tell user where our aclocal.m4 is, but only once.
4067 sub keyed_aclocal_warning
4070 warn "automake: macro \`$key' can be generated by \`aclocal'\n";
4073 # Print usage information.
4076 print "Usage: automake [OPTION] ... [Makefile]...\n";
4078 print "\nFiles which are automatically distributed, if found:\n";
4079 $~ = "USAGE_FORMAT";
4080 local (@lcomm) = sort ((@common_files, @common_sometimes));
4081 local ($one, $two, $three, $four);
4084 $one = shift @lcomm;
4085 $two = @lcomm ? shift @lcomm : '';
4086 $three = @lcomm ? shift @lcomm : '';
4087 $four = @lcomm ? shift @lcomm : '';
4091 print "\nReport bugs to <bug-gnu-utils\@prep.ai.mit.edu>\n";
4096 format USAGE_FORMAT =
4097 @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<
4098 $one, $two, $three, $four