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";
264 elsif ($arglist[0] eq "--help")
268 elsif ($arglist[0] =~ /^--amdir=(.+)$/)
272 elsif ($arglist[0] eq '--amdir')
274 &require_argument (@arglist);
276 $am_dir = $arglist[0];
278 elsif ($arglist[0] =~ /^--build-dir=(.+)$/)
281 $build_directory = $1 . '/';
283 elsif ($arglist[0] eq '--build-dir')
285 &require_argument (@arglist);
288 $build_directory = $arglist[0] . '/';
290 elsif ($arglist[0] =~ /^--srcdir-name=(.+)$/)
294 elsif ($arglist[0] eq '--srcdir-name')
296 &require_argument (@arglist);
298 $srcdir_name = $arglist[0];
300 elsif ($arglist[0] =~ /^--strictness=(.+)$/)
302 &set_strictness ($1);
304 elsif ($arglist[0] eq '--gnu')
306 &set_strictness ('gnu');
308 elsif ($arglist[0] eq '--gnits')
310 &set_strictness ('gnits');
312 elsif ($arglist[0] eq '--foreign')
314 &set_strictness ('foreign');
316 elsif ($arglist[0] eq '--strictness' || $arglist[0] eq '-s')
318 &require_argument (@arglist);
320 &set_strictness ($arglist[0]);
322 elsif ($arglist[0] eq '--include-deps' || $arglist[0] eq '-i')
324 $cmdline_use_dependencies = 0;
326 elsif ($arglist[0] eq '--no-force')
328 $force_generation = 0;
330 elsif ($arglist[0] =~ /^--output-dir=(.*)$/)
332 # Set output directory.
333 $output_directory = $1;
335 elsif ($arglist[0] eq '--output-dir' || $arglist[0] eq '-o')
337 &require_argument (@arglist);
339 $output_directory = $arglist[0];
341 elsif ($arglist[0] eq '--add-missing' || $arglist[0] eq '-a')
345 elsif ($arglist[0] eq '--verbose' || $arglist[0] eq '-v')
349 elsif ($arglist[0] eq '--')
351 # Stop option processing.
353 push (@input_files, @arglist);
356 elsif ($arglist[0] =~ /^-/)
358 die "automake: unrecognized option -- \`$arglist[0]'\n";
362 push (@input_files, $arglist[0]);
368 # Take global strictness from whatever we currently have set.
369 $default_strictness = $strictness;
370 $default_strictness_name = $strictness_name;
373 # Ensure argument exists, or die.
376 local ($arg, @arglist) = @_;
377 die "automake: no argument given for option \`$arg'\n"
381 ################################################################
383 # Generate a Makefile.in given the name of the corresponding Makefile.
384 sub generate_makefile
386 local ($makefile) = @_;
388 ($am_file_name = $makefile) =~ s/^.*\///;
389 $in_file_name = $am_file_name . '.in';
390 $am_file_name .= '.am';
392 &initialize_per_input;
393 $relative_dir = &dirname ($makefile);
395 # At the toplevel directory, we might need config.guess, config.sub
397 if ($relative_dir eq '.')
399 # libtool requires some files.
400 &require_conf_file_with_conf_line ($libtool_line, $FOREIGN,
401 'config.sub', 'config.guess',
402 'libtool') if $seen_libtool;
404 # AC_CANONICAL_HOST and AC_CANONICAL_SYSTEM need config.guess and
406 &require_config_file ($FOREIGN, 'config.guess', 'config.sub')
410 # We still need Makefile.in here, because sometimes the `dist'
411 # target doesn't re-run automake.
412 &push_dist_common ($in_file_name, $am_file_name);
413 push (@sources, '$(SOURCES)')
414 if &variable_defined ('SOURCES');
415 push (@objects, '$(OBJECTS)')
416 if &variable_defined ('OBJECTS');
418 # This is always the default target. This gives us freedom to do
419 # things in whatever order is convenient.
420 $output_rules .= "default: all\n\n";
421 push (@phony, 'default');
423 &read_am_file ($makefile . '.am');
426 # Fatal error. Just return, so we can continue with next file.
430 # Check first, because we might modify some state.
431 &check_gnu_standards;
432 &check_gnits_standards;
441 # This must be run after all the sources are scanned.
442 &handle_yacc_lex_cxx;
444 # Re-init SOURCES and OBJECTS. FIXME: other code shouldn't depend
445 # on this (but currently does).
446 $contents{'SOURCES'} = join (' ', @sources);
447 $contents{'OBJECTS'} = join (' ', @objects);
457 &handle_dependencies;
460 &handle_merge_targets;
465 if (! -d ($output_directory . '/' . $relative_dir))
467 mkdir ($output_directory . '/' . $relative_dir, 0755);
470 local ($out_file) = $output_directory . '/' . $makefile . ".in";
471 if (! $force_generation && -e $out_file)
473 local ($am_time) = (stat ($makefile . '.am'))[9];
474 local ($in_time) = (stat ($out_file))[9];
475 # FIXME: how to do unsigned comparison?
476 if ($am_time < $in_time)
483 if (! open (GM_FILE, "> " . $out_file))
485 warn "automake: ${am_file}.in: cannot open: $!\n";
489 print "automake: creating ", $makefile, ".in\n" if $verbose;
491 print GM_FILE $output_vars;
492 print GM_FILE $output_rules;
493 print GM_FILE $output_trailer;
498 ################################################################
500 # Handle AUTOMAKE_OPTIONS variable. Return 1 on error, 0 otherwise.
503 return 0 if ! &variable_defined ('AUTOMAKE_OPTIONS');
505 foreach (&variable_value_as_list ('AUTOMAKE_OPTIONS'))
510 if ($_ eq 'gnits' || $_ eq 'gnu' || $_ eq 'foreign')
512 &set_strictness ($_);
516 # An option like "../lib/ansi2knr" is allowed. With no
517 # path prefix, we assume the required programs are in this
518 # directory. We save the actual option for later.
519 $options{'ansi2knr'} = $_;
521 elsif ($_ eq 'no-installman' || $_ eq 'no-installinfo'
522 || $_ eq 'dist-shar' || $_ eq 'dist-zip'
523 || $_ eq 'dist-tarZ' || $_ eq 'dejagnu')
525 # Explicitly recognize these.
527 elsif ($_ eq 'no-dependencies')
529 $use_dependencies = 0;
531 elsif (/([0-9]+)\.([0-9]+)/)
533 # Got a version number. Note that alpha releases count as
534 # the next higher release. Note also that we assume there
535 # will be a maximum of 100 minor releases for any given
537 local ($rmajor, $rminor) = ($1, $2);
538 if ($VERSION !~ /([0-9]+)\.([0-9]+)([a-z])?/)
541 "automake: programming error: version is incorrect\n";
544 local ($tmajor, $tminor) = ($1, $2);
545 # Handle alpha versions.
546 ++$tminor if defined $3;
548 if ($rmajor > $tmajor || ($rmajor == $tmajor && $rminor > $tminor))
550 &am_line_error ('AUTOMAKE_OPTIONS',
551 "require version $_, only have $VERSION");
557 &am_line_error ('AUTOMAKE_OPTIONS',
558 'option ', $_, 'not recognized');
565 # Return object extension. Just once, put some code into the output.
566 sub get_object_extension
568 if (! $dir_holds_sources)
572 if (&variable_defined ('CONFIG_HEADER'))
574 ($xform = &dirname ($contents{'CONFIG_HEADER'}))
576 $xform = '-I' . $xform;
578 $xform = 's/\@CONFIG_INCLUDE_SPEC\@/' . $xform . '/go';
579 $output_vars .= &file_contents_with_transform ($xform,
581 $output_rules .= &file_contents ('compile');
582 &push_phony_cleaners ('compile');
584 # If using X, include some extra variable definitions. NOTE
585 # we don't want to force these into CFLAGS or anything,
586 # because not all programs will necessarily use X.
590 foreach $var ('X_CFLAGS', 'X_LIBS', 'X_EXTRA_LIBS', 'X_PRE_LIBS')
592 &define_variable ($var, "\@$var\@");
596 # Check for automatic de-ANSI-fication.
597 $dir_holds_sources = '.o';
598 push (@suffixes, '.c', '.o');
599 push (@clean, 'compile');
601 if (defined $options{'ansi2knr'})
603 if (! $am_c_prototypes)
605 &am_line_error ('AUTOMAKE_OPTIONS',
606 "option \`ansi2knr' in use but \`AM_C_PROTOTYPES' not in configure.in");
607 &keyed_aclocal_warning ('AM_C_PROTOTYPES');
608 # Only give this error once.
609 $am_c_prototypes = 1;
612 $dir_holds_sources = '$o';
613 push (@suffixes, '._c', '._o');
615 # Only require ansi2knr files if they should appear in
617 if ($options{'ansi2knr'} eq 'ansi2knr')
619 &require_file_with_line ('AUTOMAKE_OPTIONS', $FOREIGN,
620 'ansi2knr.c', 'ansi2knr.1');
621 $output_rules .= &file_contents ('kr-extra');
622 push (@clean, 'krextra');
623 &push_phony_cleaners ('krextra');
626 &define_variable ('o', ".\@U\@o");
628 # Make sure ansi2knr can be found: if no path specified,
630 local ($apath) = $options{'ansi2knr'};
631 $apath = './' . $apath
632 unless $apath =~ /\//;
633 &define_variable ("ANSI2KNR", $apath);
635 $output_rules .= &file_contents ('compile-kr');
636 $output_rules .= &file_contents ('clean-kr');
639 &push_phony_cleaners ('kr');
642 return $dir_holds_sources;
645 # Handle yacc and lex.
646 sub handle_yacc_lex_cxx
649 # First do yacc and lex.
652 local ($yacc_count) = scalar (keys %yacc_sources);
653 local ($lex_count) = scalar (keys %lex_sources);
656 push (@suffixes, '.y');
657 &define_variable ('YACC', "\@YACC\@");
658 $output_rules .= ".y.c:\n\t";
661 $output_rules .= '$(INTERLOCK) =yacclockdir $(YLWRAP) y.tab.c $@ $(YACC) $(YFLAGS) $<';
665 $output_rules .= '$(YACC) $(YFLAGS) $< && mv y.tab.c $@';
667 $output_rules .= "\n";
669 if (! $seen_prog_yacc)
671 # FIXME: should include a reference line. FIXME: maybe
672 # directly reference AC_PROG_YACC somehow?
673 &am_error ("yacc source seen but \`YACC' not defined in \`configure.in'\n");
678 push (@suffixes, '.l');
679 &define_variable ("LEX", "\@LEX\@");
680 &define_variable ("LEX_OUTPUT_ROOT", "\@LEX_OUTPUT_ROOT\@");
681 $output_rules .= ".l.c:\n\t";
684 $output_rules .= '$(INTERLOCK) =lexlockdir $(YLWRAP) $(LEX_OUTPUT_ROOT).c $@ $(LEX) $(LFLAGS) $<';
688 $output_rules .= '$(LEX) $(LFLAGS) $< && mv $(LEX_OUTPUT_ROOT).c $@';
690 $output_rules .= "\n";
692 if (! $seen_prog_lex)
694 &am_error ("lex source seen but \`AC_PROG_LEX' not in \`configure.in'\n");
696 if (! $seen_decl_yytext)
698 &am_error ("lex source seen but \`AC_DECL_YYTEXT' not in \`configure.in'\n");
702 if ($yacc_count > 1 || $lex_count > 1)
704 # If there is more than one distinct yacc (resp lex) source
705 # file in a given directory, then the `interlock' program is
706 # required to allow parallel builds to work correctly. FIXME:
707 # for now, no line number.
708 &require_config_file ($FOREIGN, 'interlock', 'ylwrap');
709 &define_variable ('INTERLOCK', $config_aux_dir . "/interlock");
710 &define_variable ('YLWRAP', $config_aux_dir . "/ylwrap");
716 local (@cxx_list) = keys %cxx_extensions;
717 local ($cxx_count) = scalar @cxx_list;
720 push (@suffixes, @cxx_list);
722 &define_variable ("CXX", "\@CXX\@");
723 &define_variable ("CXXFLAGS", "\@CXXFLAGS\@");
724 &define_variable ('CXXCOMPILE', '$(CXX) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CXXFLAGS)');
725 &define_variable ('CXXLINK', '$(CXX) $(LDFLAGS) -o $@');
728 foreach $ext (@cxx_list)
730 $output_rules .= ("$ext.o:\n"
731 . "\t\$(CXXCOMPILE) -c \$<\n");
734 if (! $seen_prog_cxx)
736 &am_error ("C++ source seen but \`AC_PROG_CXX' not in \`configure.in'\n");
741 # Last, handle some C cleanup.
745 &define_variable ('CC', "\@CC\@");
746 &define_variable ('CFLAGS', "\@CFLAGS\@");
747 &define_variable ('COMPILE',
748 '$(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)');
749 &define_variable ('LINK', '$(CC) $(LDFLAGS) -o $@');
753 # Handle SOURCE->OBJECT transform for one program or library.
755 # canonical (transformed) name of object to build
756 # actual name of object to build
757 # object extension (ie either `.o' or `$o'.
758 # Return result is name of linker variable that must be used.
759 # Empty return means just use `LINK'.
760 sub handle_source_transform
762 # one_file is canonical name. unxformed is given name. obj is
764 local ($one_file, $unxformed, $obj) = @_;
765 local ($objpat) = $obj;
766 $objpat =~ s/(\W)/\\$1/g;
768 local ($linker) = '';
770 if (&variable_defined ($one_file . "_OBJECTS"))
772 &am_line_error ($one_file . '_OBJECTS',
773 $one_file . '_OBJECTS', 'should not be defined');
774 # No point in continuing.
780 foreach $prefix ('', 'EXTRA_')
783 if (&variable_defined ($prefix . $one_file . "_SOURCES"))
785 push (@sources, '$(' . $prefix . $one_file . "_SOURCES)");
786 push (@objects, '$(' . $prefix . $one_file . "_OBJECTS)")
787 unless $prefix eq 'EXTRA_';
788 @files = &variable_value_as_list ($prefix
789 . $one_file . "_SOURCES");
791 elsif ($prefix eq '')
793 &define_variable ($one_file . "_SOURCES", $unxformed . ".c");
794 push (@sources, $unxformed . '.c');
795 push (@objects, $unxformed . $obj);
796 push (@files, $unxformed . '.c');
800 &define_variable ("EXTRA_" . $one_file . "_SOURCES", '');
805 # Turn sources into objects.
806 local (@result) = ();
809 # Skip header files, including C++-ish ones. The list
810 # of C++ header extensions comes from Emacs 19.32
817 # Skip things that look like configure substitutions.
820 # Include .c file for lex or yacc source in distribution.
824 &push_dist_common ($1 . '.c');
825 $yacc_sources{$_} = 1;
830 &push_dist_common ($1 . '.c');
831 $lex_sources{$_} = 1;
834 # Transform source files into .o files. List of C++
835 # extensions comes from Emacs 19.32 etags.
836 if (s/\.c\+\+$/$obj/g
842 $cxx_extensions{$&} = 1;
847 # FORTRAN support. FIXME: not finished.
851 # .y is yacc. .l is lex. .f and .F is fortran.
852 # .s is assembly. .M is Objective-C++. .m is
854 s/\.[cylfFsmM]$/$obj/g;
856 # FIXME: of course, this should only happen for C
857 # source. The multi-language support must really
858 # be cleaned up more globally.
863 unless $prefix eq 'EXTRA_';
865 # Transform .o or $o file into .P file (for automatic
868 $dep_files{'.deps/' . $_} = 1;
871 &define_pretty_variable ($one_file . "_OBJECTS", @result)
872 unless $prefix eq 'EXTRA_';
876 if (&variable_defined ('CONFIG_HEADER'))
878 $output_rules .= ('$(' . $one_file . "_OBJECTS): "
879 . $contents{'CONFIG_HEADER'} . "\n");
885 # Special-case @ALLOCA@ and @LIBOBJS@ in _LDADD or _LIBADD variables.
886 # Also, generate _DEPENDENCIES variable if appropriate.
888 # transformed name of object being built, or empty string if no object
889 # name of _LDADD/_LIBADD-type variable to examine
890 sub handle_lib_objects
892 local ($xname, $var) = @_;
894 die "programming error in handle_lib_objects"
895 if ! &variable_defined ($var);
897 # We recognize certain things that are commonly put in LIBADD or
900 local (@dep_list) = ();
902 foreach $lsearch (&variable_value_as_list ($var))
904 # Skip -lfoo and -Ldir.
905 next if $lsearch =~ /^-[lL]/;
907 # Assume we have a file of some sort, and push it onto the
908 # dependency list. Autoconf substitutions are not pushed;
909 # rarely is a new dependency substituted into (eg) foo_LDADD
910 # -- but "bad things (eg -lX11) are routinely substituted.
911 push (@dep_list, $lsearch)
912 unless $lsearch =~ /^\@.*\@$/;
914 # Automatically handle @LIBOBJS@ and @ALLOCA@. Basically this
915 # means adding entries to dep_files.
916 if ($lsearch eq '@LIBOBJS@')
918 if (! keys %libsources)
920 &am_line_error ($var, "\@LIBOBJS\@ seen but never set in \`configure.in'");
923 local ($iter, $rewrite);
924 foreach $iter (keys %libsources)
928 &require_file_with_line ($var, $FOREIGN, $iter);
930 elsif ($iter ne 'alloca.c')
932 ($rewrite = $iter) =~ s/\.c$/.P/;
933 $dep_files{'.deps/' . $rewrite} = 1;
934 &require_file_with_line ($var, $FOREIGN, $iter);
938 elsif ($lsearch eq '@ALLOCA@')
940 &am_line_error ($var,
941 "\@ALLOCA\@ seen but \`AC_FUNC_ALLOCA' not in \`configure.in'")
942 if ! defined $libsources{'alloca.c'};
943 $dep_files{'.deps/alloca.P'} = 1;
944 &require_file_with_line ($var, $FOREIGN, 'alloca.c');
948 if ($xname ne '' && ! &variable_defined ($xname . '_DEPENDENCIES'))
950 &define_pretty_variable ($xname . '_DEPENDENCIES', @dep_list);
957 local (@proglist) = &am_install_var ('-clean',
958 'programs', 'PROGRAMS',
959 'bin', 'sbin', 'libexec', 'pkglib',
961 return if ! @proglist;
963 # If a program is installed, this is required. We only want this
964 # error to appear once.
965 &am_conf_error ("AC_ARG_PROGRAM must be used in configure.in")
966 unless $seen_arg_prog;
969 local ($obj) = &get_object_extension;
970 local ($one_file, $xname, $munge);
972 foreach $one_file (@proglist)
974 # Canonicalize names.
975 ($xname = $one_file) =~ tr/A-Za-z0-9_/_/c;
976 if ($xname ne $one_file)
979 foreach $xt ('_LDADD', '_SOURCES', '_OBJECTS', '_DEPENDENCIES')
981 &am_line_error ($one_file . $xt,
982 "invalid variable \`" . $one_file . $xt
983 . "'; should be \`" . $xname . $xt . "'")
984 if &variable_defined ($one_file . $xt);
988 local ($linker) = &handle_source_transform ($xname, $one_file, $obj);
990 if (&variable_defined ($xname . "_LDADD"))
992 &handle_lib_objects ($xname, $xname . '_LDADD');
996 # User didn't define prog_LDADD override. So do it.
997 &define_variable ($xname . '_LDADD', '$(LDADD)');
999 # This does a bit too much work. But we need it to
1000 # generate _DEPENDENCIES when appropriate.
1001 &handle_lib_objects ($xname, 'LDADD')
1002 if (&variable_defined ('LDADD'));
1005 # Determine program to use for link.
1007 if (&variable_defined ($xname . '_LINK'))
1009 $xlink = $xname . '_LINK';
1013 $xlink = $linker ? $linker : 'LINK';
1017 &file_contents_with_transform
1018 ('s/\@PROGRAM\@/' . $one_file . '/go;'
1019 . 's/\@XPROGRAM\@/' . $xname . '/go;'
1020 . 's/\@XLINK\@/' . $xlink . '/go;',
1024 &handle_lib_objects ('', 'LDADD')
1025 if &variable_defined ('LDADD');
1029 sub handle_libraries
1031 local (@liblist) = &am_install_var ('-no-all', '-clean',
1032 'libraries', 'LIBRARIES',
1033 'lib', 'pkglib', 'noinst', 'check');
1034 return if ! @liblist;
1036 local (%valid) = &am_primary_prefixes ('LIBRARIES', 'lib', 'pkglib',
1041 foreach $key (keys %valid)
1043 if (&variable_defined ($key . '_LIBRARIES'))
1045 &am_line_error ($key . '_LIBRARIES', "library requires either \`AC_PROG_RANLIB' or `AM_PROG_LIBTOOL' in configure.in");
1046 # Only get this error once.
1053 # Generate _LIBFILES variables. Too bad we can't do this in
1055 local ($onedir, $onelib);
1057 local (@libfiles_list);
1058 foreach $onedir (keys %valid)
1060 if (&variable_defined ($onedir . '_LIBRARIES'))
1063 foreach $onelib (&variable_value_as_list ($onedir . '_LIBRARIES'))
1065 push (@outlist, 'lib' . $onelib . '.a');
1067 &define_pretty_variable ($onedir . '_LIBFILES', @outlist);
1070 push (@libfiles_list, '$(' . $onedir . '_LIBFILES)')
1071 unless $onedir eq 'EXTRA';
1073 push (@all, '$(LIBFILES)');
1075 local ($obj) = &get_object_extension;
1078 foreach $onelib (@liblist)
1080 # Canonicalize names.
1081 ($xlib = $onelib) =~ tr/A-Za-z0-9_/_/c;
1082 if ($xlib ne $onelib)
1085 foreach $xt ('_LIBADD', '_SOURCES', '_OBJECTS', '_DEPENDENCIES')
1087 &am_line_error ($one_file . $xt,
1088 "invalid variable \`" . $onelib . $xt
1089 . "'; should be \`" . $xlib . $xt . "'")
1090 if &variable_defined ($onelib . $xt);
1094 if (&variable_defined ($xlib . '_LIBADD'))
1096 &handle_lib_objects ($xlib, $xlib . '_LIBADD');
1100 # Generate support for conditional object inclusion in
1102 &define_variable ($xlib . "_LIBADD", '');
1105 &handle_source_transform ($xlib, $onelib, $obj);
1108 &file_contents_with_transform ('s/\@LIBRARY\@/' . $onelib . '/go;'
1114 # Turn "foo" into "libfoo.a" and include macro definition.
1115 grep (($_ = 'lib' . $_ . '.a') && 0, @liblist);
1117 if (! &variable_defined ('LIBFILES'))
1119 &define_pretty_variable ('LIBFILES ', @libfiles_list);
1124 &define_variable ('AR', '$(LIBTOOL) archive');
1125 &define_variable ('RANLIB', '$(LIBTOOL) ranlib');
1126 &define_variable ('LCOMPILE', ('$(LIBTOOL) compile $(DEFS) $(INCLUDES)'
1127 . ' $(CPPFLAGS) $(CFLAGS)'));
1131 &define_variable ('AR', 'ar');
1132 &define_variable ('RANLIB', '@RANLIB@');
1136 # See if any _SOURCES variable were misspelled.
1139 local ($varname, $primary);
1140 foreach $varname (keys %contents)
1142 foreach $primary ('_SOURCES', '_LIBADD', '_LDADD', '_DEPENDENCIES')
1144 if ($varname =~ /$primary$/ && ! $content_seen{$varname})
1146 &am_line_error ($varname,
1147 "invalid unused variable name: \`$varname'");
1156 # NOTE we no longer automatically clean SCRIPTS, because it is
1157 # useful to sometimes distribute scripts verbatim. This happens
1158 # eg in Automake itself.
1159 &am_install_var ('scripts', 'SCRIPTS',
1160 'bin', 'sbin', 'libexec', 'pkgdata',
1163 # Set $scripts_installed if appropriate. Make sure we only find
1164 # scripts which are actually installed -- this is why we can't
1165 # simply use the return value of am_install_var.
1166 local (%valid) = &am_primary_prefixes ('SCRIPTS', 'bin', 'sbin',
1167 'libexec', 'pkgdata',
1170 foreach $key (keys %valid)
1172 if ($key ne 'noinst'
1174 && &variable_defined ($key . '_SCRIPTS'))
1176 $scripts_installed = 1;
1181 if ($scripts_installed)
1183 # If a program is installed, this is required. We only want this
1184 # error to appear once.
1185 &am_conf_error ("AC_ARG_PROGRAM must be used in configure.in")
1186 unless $seen_arg_prog;
1191 # Search a file for a "version.texi" Texinfo include. Return the name
1192 # of the include file if found, or the empty string if not. A
1193 # "version.texi" file is actually any file whose name matches
1195 sub grep_for_vers_texi
1197 local ($filename) = @_;
1199 if (! open (TEXI, $filename))
1201 &am_error ("couldn't open \`$filename': $!");
1204 print "automake: reading $filename\n" if $verbose;
1208 if (/^\@include\s+(vers[^.]*\.texi)\s*$/)
1220 # Handle all Texinfo source.
1223 &am_line_error ('TEXINFOS',
1224 "\`TEXINFOS' is an anachronism; use \`info_TEXINFOS'")
1225 if &variable_defined ('TEXINFOS');
1226 return if (! &variable_defined ('info_TEXINFOS')
1227 && ! &variable_defined ('html_TEXINFOS'));
1229 local (@texis) = &variable_value_as_list ('info_TEXINFOS');
1231 local (@infos_list, @info_deps_list, @dvis_list, @texi_deps);
1232 local ($infobase, $info_cursor);
1236 local ($tc_cursor, @texi_cleans);
1239 foreach $info_cursor (@texis)
1241 ($infobase = $info_cursor) =~ s/\.texi(nfo)?$//;
1243 # If 'version.texi' is referenced by input file, then include
1244 # automatic versioning capability.
1246 = &grep_for_vers_texi ($relative_dir . "/" . $info_cursor);
1249 &am_error ("\`$vtexi', included in \`$info_cursor', also included in \`$versions{$vtexi}'")
1250 if (defined $versions{$vtexi});
1251 $versions{$vtexi} = $info_cursor;
1253 # We number the stamp-vti files. This is doable since the
1254 # actual names don't matter much. We only number starting
1255 # with the second one, so that the common case looks nice.
1256 $vti = 'vti' . ($done ? $done : '');
1257 &push_dist_common ($vtexi, 'stamp-' . $vti);
1258 push (@clean, $vti);
1260 # Only require once.
1261 &require_conf_file_with_line ('info_TEXINFOS', $FOREIGN,
1267 ($conf_pat = $config_aux_dir) =~ s/(\W)/\\$1/g;
1269 &file_contents_with_transform
1270 ('s/\@TEXI\@/' . $info_cursor . '/g; '
1271 . 's/\@VTI\@/' . $vti . '/g; '
1272 . 's/\@VTEXI\@/' . $vtexi . '/g;'
1273 . 's,\@MDDIR\@,' . $conf_pat . ',g;',
1276 &push_phony_cleaners ($vti);
1279 # If user specified file_TEXINFOS, then use that as explicit
1282 push (@texi_deps, $info_cursor);
1283 push (@texi_deps, $vtexi) if $vtexi;
1285 # Canonicalize name first.
1286 ($canonical = $infobase) =~ tr/A-Za-z0-9_/_/c;
1287 if (&variable_defined ($canonical . "_TEXINFOS"))
1289 push (@texi_deps, '$(' . $canonical . '_TEXINFOS)');
1290 &push_dist_common ('$(' . $canonical . '_TEXINFOS)');
1293 $output_rules .= ("\n" . $infobase . ".info: "
1294 . join (' ', @texi_deps)
1295 . "\n" . $infobase . ".dvi: "
1296 . join (' ', @texi_deps)
1299 # FIXME: this distributes too much. How to find out precisely
1300 # which files will be generated by `makeinfo'?
1301 push (@infos_list, $infobase . '.info', $infobase . '.info[-0-9]*');
1302 push (@info_deps_list, $infobase . '.info');
1303 push (@dvis_list, $infobase . '.dvi');
1305 # Generate list of things to clean for this target. We do
1306 # this explicitly because otherwise too many things could be
1307 # removed. In particular the ".log" extension might
1308 # reasonably be used in other contexts by the user.
1309 foreach $tc_cursor ('aux', 'cp', 'cps', 'dvi', 'fn', 'fns',
1310 'ky', 'log', 'pg', 'toc', 'tp', 'vr', 'op')
1312 push (@texi_cleans, $infobase . '.' . $tc_cursor);
1317 $output_vars .= &file_contents ('texinfos-vars');
1318 $output_rules .= &file_contents ('texinfos');
1319 push (@phony, 'install-info', 'uninstall-info');
1322 $output_rules .= "\nmostlyclean-info:\n";
1323 &pretty_print_rule ("\trm -f", "\t ", @texi_cleans);
1324 $output_rules .= ("\nclean-info:\n\ndistclean-info:\n\n"
1325 . "maintainer-clean-info:\n\t"
1326 . 'rm -f $(INFOS)' . "\n");
1327 &push_phony_cleaners ('info');
1329 push (@suffixes, '.texi', '.texinfo', '.info', '.dvi');
1331 if (! defined $options{'no-installinfo'})
1333 push (@uninstall, 'uninstall-info');
1334 push (@installdirs, '$(infodir)');
1335 unshift (@install_data, 'install-info');
1337 # Make sure documentation is made and installed first. Use
1338 # $(INFO_DEPS), not 'info', because otherwise recursive makes
1339 # get run twice during "make all".
1340 unshift (@all, '$(INFO_DEPS)');
1342 push (@clean, 'info');
1343 push (@info, '$(INFO_DEPS)');
1344 push (@dvi, '$(DVIS)');
1346 &define_variable ("INFOS", join (' ', @infos_list));
1347 &define_variable ("INFO_DEPS", join (' ', @info_deps_list));
1348 &define_variable ("DVIS", join (' ', @dvis_list));
1349 # This next isn't strictly needed now -- the places that look here
1350 # could easily be changed to look in info_TEXINFOS. But this is
1351 # probably better, in case noinst_TEXINFOS is ever supported.
1352 &define_variable ("TEXINFOS", $contents{'info_TEXINFOS'});
1354 # Do some error checking.
1355 &require_file_with_line ('info_TEXINFOS', $FOREIGN, 'texinfo.tex');
1358 # Handle any man pages.
1359 sub handle_man_pages
1361 &am_line_error ('MANS', "\`MANS' is an anachronism; use \`man_MANS'")
1362 if &variable_defined ('MANS');
1363 return if ! &variable_defined ('man_MANS');
1365 # We generate the manpage install code by hand to avoid the use of
1366 # basename in the generated Makefile.
1367 local (@mans) = &variable_value_as_list ('man_MANS');
1368 local (%sections, %inames, %mbases, %secmap, %fullsecmap);
1372 # FIXME: statement without effect:
1373 /^(.*)\.([0-9])([a-z]*)$/;
1378 $fullsecmap{$i} = $2 . $3;
1382 # We don't really need this, but we use it in case we ever want to
1383 # support noinst_MANS.
1384 &define_variable ("MANS", $contents{'man_MANS'});
1386 # Generate list of install dirs.
1387 $output_rules .= "install-man: \$(MANS)\n";
1388 $output_rules .= "\t\$(NORMAL_INSTALL)\n";
1389 foreach (keys %sections)
1391 push (@installdirs, '$(mandir)/man' . $_)
1392 unless defined $options{'no-installman'};
1393 $output_rules .= ("\t" . '$(mkinstalldirs) $(mandir)/man'
1396 push (@phony, 'install-man');
1398 # Generate install target.
1400 foreach $key (keys %inames)
1402 $_ = $install_man_format;
1403 s/\@SECTION\@/$secmap{$key}/g;
1404 s/\@MAN\@/$inames{$key}/g;
1405 s/\@FULLSECT\@/$fullsecmap{$key}/g;
1406 s/\@MANBASE\@/$mbases{$key}/g;
1407 $output_rules .= $_;
1409 $output_rules .= "\n";
1411 $output_rules .= "uninstall-man:\n";
1412 foreach $key (keys %inames)
1414 $_ = $uninstall_man_format;
1415 s/\@SECTION\@/$secmap{$key}/g;
1416 s/\@MAN\@/$inames{$key}/g;
1417 s/\@FULLSECT\@/$fullsecmap{$key}/g;
1418 s/\@MANBASE\@/$mbases{$key}/g;
1419 $output_rules .= $_;
1421 $output_rules .= "\n";
1422 push (@phony, 'uninstall-man');
1424 $output_vars .= &file_contents ('mans-vars');
1426 if (! defined $options{'no-installman'})
1428 push (@install_data, 'install-man');
1429 push (@uninstall, 'uninstall-man');
1430 push (@all, '$(MANS)');
1434 # Handle DATA variables.
1437 &am_install_var ('data', 'DATA', 'data', 'sysconf',
1438 'sharedstate', 'localstate', 'pkgdata',
1445 local ($tagging) = 0;
1447 push (@phony, 'tags');
1448 if (&variable_defined ('SUBDIRS'))
1450 $output_rules .= &file_contents ('tags');
1451 push (@phony, 'tags-recursive');
1454 elsif ($dir_holds_sources
1455 || $dir_holds_headers
1456 || &variable_defined ('ETAGS_ARGS'))
1458 $output_rules .= &file_contents ('tags-subd');
1464 $output_rules .= &file_contents ('tags-clean');
1465 push (@clean, 'tags');
1466 &push_phony_cleaners ('tags');
1470 # Every Makefile must define some sort of TAGS rule.
1471 # Otherwise, it would be possible for a top-level "make TAGS"
1472 # to fail because some subdirectory failed.
1473 $output_rules .= "tags: TAGS\nTAGS:\n\n";
1477 # Worker for handle_dist.
1478 sub handle_dist_worker
1480 $output_rules .= 'distdir: $(DEP_DISTFILES)' . "\n";
1482 # Initialization; only at top level.
1483 if ($relative_dir eq '.')
1485 if ($strictness >= $GNITS)
1487 # For Gnits users, this is pretty handy. Look at 15 lines
1488 # in case some explanatory text is desirable.
1489 $output_rules .= ' @if sed 15q $(srcdir)/NEWS | fgrep -e "$(VERSION)" > /dev/null; then :; else \\
1490 echo "NEWS not updated; not releasing" 1>&2; \\
1498 # Create dist directory.
1501 -chmod 755 $(distdir)
1504 # Only run automake in `dist' target if --include-deps not
1505 # specified. That way the recipient of a distribution can run
1506 # "make dist" and not need Automake.
1507 if ($cmdline_use_dependencies)
1511 # We need an absolute path for --output-dir. Thus the
1513 ' here=`pwd`; distdir=`cd $(distdir) && pwd` \\
1515 && automake --include-deps --build-dir=$$here --srcdir-name=$(srcdir) --output-dir=$$distdir --strictness='
1516 # Set strictness of output.
1517 . $strictness_name . "\n"
1522 # In loop, test for file existence because sometimes a file gets
1523 # included in DISTFILES twice. For example this happens when a
1524 # single source file is used in building more than one program.
1525 # Also, there are situations in which "ln" can fail. For instance
1526 # a file to distribute could actually be a cross-filesystem
1527 # symlink -- this can easily happen if "gettextize" was run on the
1528 # distribution. Note that DISTFILES can contain a wildcard (for
1529 # info files, sigh), so we must use the echo trick.
1530 $output_rules .= ' @for file in `cd $(srcdir) && echo $(DISTFILES)`; do \\
1531 test -f $(distdir)/$$file \\
1532 || ln $(srcdir)/$$file $(distdir)/$$file 2> /dev/null \\
1533 || cp -p $(srcdir)/$$file $(distdir)/$$file; \\
1537 # If we have SUBDIRS, create all dist subdirectories and do
1539 if (&variable_defined ('SUBDIRS'))
1541 # Test for directory existence here because previous automake
1542 # invocation might have created some directories. Note that
1543 # we explicitly set distdir for the subdir make; that lets us
1544 # mix-n-match many automake-using packages into one large
1545 # package, and have "dist" at the top level do the right
1547 $output_rules .= ' for subdir in $(SUBDIRS); do \\
1548 test -d $(distdir)/$$subdir \\
1549 || mkdir $(distdir)/$$subdir \\
1551 chmod 755 $(distdir)/$$subdir; \\
1552 (cd $$subdir && $(MAKE) distdir=../$(distdir)/$$subdir distdir) \\
1558 # If the target `dist-hook' exists, run it now. This allows
1559 # users to do random weird things to the distribution before it is
1561 if (defined $contents{'dist-hook'})
1563 $output_rules .= "\t\$(MAKE) dist-hook\n";
1566 push (@phony, 'distdir');
1569 # Handle 'dist' target.
1572 # Set up maint_charset.
1573 $local_maint_charset = $contents{'MAINT_CHARSET'}
1574 if &variable_defined ('MAINT_CHARSET');
1575 $maint_charset = $local_maint_charset
1576 if $relative_dir eq '.';
1578 if (&variable_defined ('DIST_CHARSET'))
1580 &am_line_error ('DIST_CHARSET',
1581 "DIST_CHARSET defined but no MAINT_CHARSET defined")
1582 if ! $local_maint_charset;
1583 if ($relative_dir eq '.')
1585 $dist_charset = $contents{'DIST_CHARSET'}
1589 &am_line_error ('DIST_CHARSET',
1590 "DIST_CHARSET can only be defined at top level");
1594 # Look for common files that should be included in distribution.
1596 foreach $cfile (@common_files)
1598 if (-f ($relative_dir . "/" . $cfile))
1600 &push_dist_common ($cfile);
1604 # Keys of %dist_common are names of files to distributed. We put
1605 # README first because it then becomes easier to make a
1606 # Usenet-compliant shar file (in these, README must be first).
1607 # FIXME: do more ordering of files here.
1609 if (defined $dist_common{'README'})
1611 push (@coms, 'README');
1612 undef $dist_common{'README'};
1614 push (@coms, sort keys %dist_common);
1616 &define_pretty_variable ("DIST_COMMON", @coms);
1617 $output_vars .= "\n";
1620 $output_vars .= &file_contents ('dist-vars');
1622 # Put these things in rules section so it is easier for whoever
1623 # reads Makefile.in.
1624 if (! &variable_defined ('distdir'))
1626 if ($relative_dir eq '.')
1628 $output_rules .= "\n" . 'distdir = $(PACKAGE)-$(VERSION)' . "\n";
1632 $output_rules .= ("\n"
1633 . 'distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)'
1637 if ($relative_dir ne '.')
1639 $output_rules .= "\nsubdir = " . $relative_dir . "\n";
1642 # Generate 'dist' target, and maybe dist-shar / dist-zip / dist-tarZ.
1643 if ($relative_dir eq '.')
1645 # Rule to check whether a distribution is viable.
1646 $output_rules .= ('# This target untars the dist file and tries a VPATH configuration. Then
1647 # it guarantees that the distribution is self-contained by making another
1651 $(TAR) zxf $(distdir).tar.gz
1652 mkdir $(distdir)/=build
1653 mkdir $(distdir)/=inst
1654 dc_install_base=`cd $(distdir)/=inst && pwd`; \\'
1655 . (defined $contents{'distcheck-hook'}
1656 ? "\t\$(MAKE) distcheck-hook"
1659 cd $(distdir)/=build \\
1662 . ($seen_gettext ? '--with-included-gettext ' : '')
1663 . '--srcdir=.. --prefix=$$dc_install_base \\
1667 && $(MAKE) install \\
1668 && $(MAKE) installcheck \\
1671 @echo "========================"; \\
1672 echo "$(distdir).tar.gz is ready for distribution"; \\
1673 echo "========================"
1676 $output_rules .= 'dist: distdir' . "\n\t";
1677 # Ignore return result from chmod, because it might give an
1678 # error if we chmod a symlink.
1679 $output_rules .= '-chmod -R a+r $(distdir)' . "\n\t";
1680 $output_rules .= '$(TAR) chozf $(distdir).tar.gz $(distdir)';
1681 $output_rules .= "\n\t" . 'rm -rf $(distdir)' . "\n";
1683 if (defined $options{'dist-shar'})
1685 $output_rules .= 'dist-shar: distdir' . "\n\t";
1686 # Ignore return result from chmod, because it might give
1687 # an error if we chmod a symlink.
1688 $output_rules .= '-chmod -R a+r $(distdir)' . "\n\t";
1689 $output_rules .= 'shar $(distdir) | gzip > $(distdir).shar.gz';
1690 $output_rules .= "\n\t" . 'rm -rf $(distdir)' . "\n";
1693 if (defined $options{'dist-zip'})
1695 $output_rules .= 'dist-zip: distdir' . "\n\t";
1696 $output_rules .= '-chmod -R a+r $(distdir)' . "\n\t";
1697 $output_rules .= 'zip -rq $(distdir).zip $(distdir)';
1698 $output_rules .= "\n\t" . 'rm -rf $(distdir)' . "\n";
1701 if (defined $options{'dist-tarZ'})
1703 $output_rules .= 'dist-tarZ: distdir' . "\n\t";
1704 $output_rules .= '-chmod -R a+r $(distdir)' . "\n\t";
1705 $output_rules .= '$(TAR) chf - $(distdir) | compress -c > $(distdir).tar.Z';
1706 $output_rules .= "\n\t" . 'rm -rf $(distdir)' . "\n";
1710 # Generate distdir target.
1711 &handle_dist_worker;
1714 # Scan a single dependency file and rewrite the dependencies as
1715 # appropriate. Essentially this means:
1716 # * Clean out absolute dependencies which are not desirable.
1717 # * Rewrite other dependencies to be relative to $(top_srcdir).
1718 sub scan_dependency_file
1720 local ($depfile) = @_;
1722 if (! open (DEP_FILE, $depfile))
1724 &am_error ("couldn't open \`$depfile': $!");
1727 print "automake: reading $depfile\n" if $verbose;
1729 local ($first_line) = 1;
1730 local ($last_line) = 0;
1731 local ($target, @dependencies);
1732 local ($one_dep, $xform);
1734 local ($srcdir_rx, $fixup_rx, $fixup2_rx);
1735 ($srcdir_rx = $srcdir_name) =~ s/(\W)/\\$1/g;
1737 # If the top srcdir is absolute, then the current directory is
1738 # just relative_dir.
1739 ($fixup_rx = $srcdir_name . '/' . $relative_dir . '/') =~ s/(\W)/\\$1/g;
1741 # But if the top srcdir is relative, then we need some dots first.
1742 ($fixup2_rx = ($srcdir_name . '/' . $top_builddir . '/'
1743 . $relative_dir . '/')) =~ s/(\W)/\\$1/g;
1749 # If LAST_LINE set then we've already seen what we thought
1750 # was the last line.
1753 next if (/$WHITE_PATTERN/o);
1757 # No trailing "\" means this should be the last line.
1763 if (! /^([^:]+:)(.+)$/)
1766 &am_error ("\`$depfile' has incorrect format");
1777 foreach $one_dep (split (' ', $_))
1779 if ($one_dep =~ /^$fixup_rx/)
1781 # The dependency points to the current directory in
1783 ($xform = $one_dep) =~ s/^$fixup_rx//;
1784 push (@dependencies, $xform);
1786 elsif ($one_dep =~ /^$fixup2_rx/)
1788 # The dependency points to the current directory in
1790 ($xform = $one_dep) =~ s/^$fixup2_rx//;
1791 push (@dependencies, $xform);
1793 elsif ($one_dep =~ /^$srcdir_rx\//)
1795 # The dependency is in some other directory in the package.
1796 ($xform = $one_dep) =~ s/^$srcdir_rx/$top_builddir/;
1797 push (@dependencies, $xform);
1799 elsif ($one_dep =~ /^\//)
1801 # Absolute path; ignore.
1805 # Anything else is assumed to be correct.
1806 push (@dependencies, $one_dep);
1811 &pretty_print_rule ($target, "\t", @dependencies);
1816 # Handle auto-dependency code.
1817 sub handle_dependencies
1819 if ($use_dependencies)
1821 # Include GNU-make-specific auto-dep code.
1822 if ($dir_holds_sources)
1824 &define_pretty_variable ('DEP_FILES', sort keys %dep_files);
1825 $output_rules .= &file_contents ('depend');
1826 push (@clean, 'depend');
1827 &push_phony_cleaners ('depend');
1829 &file_contents_with_transform ('s/\@EXT\@/.c/g;'
1830 . 's/\@MKDEP\@/MKDEP/g',
1833 local ($need_cxx) = 0;
1834 foreach $ext (keys %cxx_extensions)
1837 &file_contents_with_transform ('s/\@EXT\@/' . $ext .'/g;'
1838 . 's/\@MKDEP\@/CXXMKDEP/g',
1844 &define_variable ('CXXMKDEP', '$(CXX) -MM $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CXXFLAGS)');
1850 # FIXME: consider requiring --build-dir here. What about case
1851 # where this is done via an option?
1853 # Include any auto-generated deps that are present. Note that
1854 # $build_directory ends in a "/".
1855 if (-d ($build_directory . $relative_dir . "/.deps")
1856 && -f ($build_directory . $relative_dir . "/.deps/.P"))
1859 local ($gpat) = $build_directory . $relative_dir . "/.deps/*.P";
1861 foreach $depfile (<${gpat}>)
1863 &scan_dependency_file ($depfile);
1866 $output_rules .= "\n";
1871 # Handle subdirectories.
1874 if (! &variable_defined ('SUBDIRS'))
1877 ("ud_GNU_GETTEXT in configure.in but SUBDIRS not defined")
1878 if $seen_gettext && $relative_dir eq '.';
1882 &require_file_with_conf_line ($ac_gettext_line, $FOREIGN, 'ABOUT-NLS')
1885 return if ! &variable_defined ('SUBDIRS');
1887 # Make sure each directory mentioned in SUBDIRS actually exists.
1889 foreach $dir (&variable_value_as_list ('SUBDIRS'))
1891 # Skip directories substituted by configure.
1892 next if $dir =~ /^\@.*\@$/;
1893 &am_line_error ('SUBDIRS',
1894 "required directory $relative_dir/$dir does not exist")
1895 if ! -d $relative_dir . '/' . $dir;
1898 $output_rules .= &file_contents ('subdirs');
1900 # Push a bunch of phony targets.
1902 foreach $phonies ('-data', '-exec', 'dirs')
1904 push (@phony, 'install' . $phonies . '-recursive');
1905 push (@phony, 'uninstall' . $phonies . '-recursive');
1907 foreach $phonies ('all', 'check', 'installcheck', 'info', 'dvi')
1909 push (@phony, $phonies . '-recursive');
1911 &push_phony_cleaners ('recursive');
1913 push (@check, "check-recursive");
1914 push (@installcheck, "installcheck-recursive");
1915 push (@info, "info-recursive");
1916 push (@dvi, "dvi-recursive");
1918 $recursive_install = 1;
1921 # Handle aclocal.m4.
1922 sub handle_aclocal_m4
1924 local ($regen_aclocal) = 0;
1925 if (-f 'aclocal.m4')
1927 &define_variable ("ACLOCAL", "aclocal.m4");
1928 &push_dist_common ('aclocal.m4');
1930 if (open (ACLOCAL, '< aclocal.m4'))
1936 if ($line =~ 'generated automatically by aclocal')
1943 local ($acinclude) = 0;
1944 if (-f 'acinclude.m4')
1950 # Note that it might be possible that aclocal.m4 doesn't exist but
1951 # should be auto-generated. This case probably isn't very
1955 $output_rules .= ("aclocal.m4: "
1956 . ($seen_maint_mode ? "\@MAINT\@" : "")
1958 . ($acinclude ? ' acinclude.m4' : '')
1960 . 'cd $(srcdir) && aclocal'
1965 # Handle remaking and configure stuff.
1966 sub handle_configure
1968 # If SUBDIRS defined, require AC_PROG_MAKE_SET.
1969 &am_line_error ('SUBDIRS', "AC_PROG_MAKE_SET must be used in configure.in")
1970 if &variable_defined ('SUBDIRS') && ! $seen_make_set;
1972 local ($top_reldir);
1973 if ($relative_dir ne '.')
1976 $output_rules .= &file_contents ('remake-subd');
1977 $top_reldir = '../';
1982 $output_rules .= &file_contents_with_transform ('s/\@STRICTNESS\@/'
1989 # If we have a configure header, require it.
1990 if ($config_header && $relative_dir eq &dirname ($config_header))
1992 local ($ch_sans_dir) = &basename ($config_header);
1993 local ($cn_sans_dir) = &basename ($config_name);
1995 &require_file_with_conf_line ($config_header_line,
1996 $FOREIGN, $ch_sans_dir);
1998 # Header defined and in this directory.
1999 if (-f $relative_dir . '/acconfig.h')
2001 &define_variable ("ACCONFIG", "acconfig.h");
2002 &push_dist_common ('acconfig.h');
2004 if (-f $config_name . '.top')
2006 &define_variable ("CONFIG_TOP", "${cn_sans_dir}.top");
2007 &push_dist_common ($cn_sans_dir . '.top');
2009 if (-f $config_name . '.bot')
2011 &define_variable ("CONFIG_BOT", "${cn_sans_dir}.bot");
2012 &push_dist_common ($cn_sans_dir . '.bot');
2015 &touch ($relative_dir . '/stamp-h.in');
2016 &require_file_with_conf_line ($config_header_line, $FOREIGN,
2019 $output_rules .= &file_contents ('remake-hdr');
2020 push (@clean, 'hdr');
2021 &push_phony_cleaners ('hdr');
2022 &define_variable ("CONFIG_HEADER_IN", "${ch_sans_dir}");
2025 # Set location of mkinstalldirs.
2026 if ($config_aux_dir ne '.' && $config_aux_dir ne '')
2028 &define_variable ('mkinstalldirs', $config_aux_dir . '/mkinstalldirs');
2032 &define_variable ('mkinstalldirs', '$(top_srcdir)/mkinstalldirs');
2035 &am_line_error ('CONFIG_HEADER',
2036 "\`CONFIG_HEADER' is an anachronism; now determined from \`configure.in'")
2037 if &variable_defined ('CONFIG_HEADER');
2041 # Generate CONFIG_HEADER define.
2042 if ($relative_dir eq &dirname ($config_name))
2044 &define_variable ("CONFIG_HEADER", &basename ($config_name));
2048 &define_variable ("CONFIG_HEADER",
2049 "${top_builddir}/${config_name}");
2053 # Now look for other files in this directory which must be remade
2054 # by config.status, and generate rules for them.
2055 local (@actual_other_files) = ();
2056 local ($file, $local, $input);
2057 foreach $file (@other_input_files)
2059 # Skip files not in this directory, any Makefile, and the
2060 # config header. These last two must be handled specially.
2061 next unless &dirname ($file) eq $relative_dir;
2062 next if $file eq $top_builddir . '/' . $config_name;
2063 ($local = $file) =~ s/^.*\///;
2064 next if $local eq 'Makefile';
2066 if ($local =~ /^(.*):(.*)$/)
2068 # This is the ":" syntax of AC_OUTPUT.
2075 $input = $local . '.in';
2077 # FIXME: when using autoconf ":" syntax, should we set CONFIG_FILES
2079 $output_rules .= ($local . ': '
2080 . '$(top_builddir)/config.status ' . $input . "\n"
2082 . 'cd $(top_builddir) && CONFIG_FILES='
2083 . ($relative_dir eq '.' ? '' : '$(subdir)/')
2084 . '$@ CONFIG_HEADERS= ./config.status'
2086 push (@actual_other_files, $local);
2088 &require_file_with_conf_line ($ac_output_line, $FOREIGN,
2092 # These files get removed by "make clean".
2093 &define_pretty_variable ('CONFIG_CLEAN_FILES', @actual_other_files);
2099 $dir_holds_headers = &am_install_var ('header', 'HEADERS', 'include',
2100 'oldinclude', 'pkginclude',
2106 return if ! $seen_gettext || $relative_dir ne '.';
2108 if (&variable_defined ('SUBDIRS'))
2112 "ud_GNU_GETTEXT in configure.in but \`po' not in SUBDIRS")
2113 if $contents{'SUBDIRS'} !~ /\bpo\b/;
2116 "ud_GNU_GETTEXT in configure.in but \`intl' not in SUBDIRS")
2117 if $contents{'SUBDIRS'} !~ /\bintl\b/;
2120 # Ensure that each language in ALL_LINGUAS has a .po file, and
2121 # each po file is mentioned in ALL_LINGUAS.
2124 local (%linguas) = ();
2125 grep ($linguas{$_} = 1, split (' ', $all_linguas));
2132 &am_line_error ($all_linguas_line,
2133 ("po/$_.po exists but \`$_' not in \`ALL_LINGUAS'"))
2137 foreach (keys %linguas)
2139 &am_line_error ($all_linguas_line,
2140 "$_ in \`ALL_LINGUAS' but po/$_.po does not exist")
2146 &am_error ("ud_GNU_GETTEXT in configure.in but \`ALL_LINGUAS' not defined");
2150 # Handle footer elements.
2153 if ($contents{'SOURCES'})
2155 # NOTE don't use define_pretty_variable here, because
2156 # $contents{...} is already defined.
2157 $output_vars .= 'SOURCES = ' . $contents{'SOURCES'} . "\n";
2159 if ($contents{'OBJECTS'})
2161 # NOTE don't use define_pretty_variable here, because
2162 # $contents{...} is already defined.
2163 $output_vars .= 'OBJECTS = ' . $contents{'OBJECTS'} . "\n";
2165 if ($contents{'SOURCES'} || $contents{'OBJECTS'})
2167 $output_vars .= "\n";
2170 if (defined $contents{'SUFFIXES'})
2172 # Push actual suffixes, and not $(SUFFIXES). Some versions of
2173 # make do not like variable substitutions on the .SUFFIXES
2175 push (@suffixes, split (' ', $contents{'SUFFIXES'}));
2178 $output_trailer .= ".SUFFIXES:\n";
2181 $output_trailer .= ".SUFFIXES: " . join (' ', @suffixes) . "\n";
2183 $output_trailer .= &file_contents ('footer');
2186 # Deal with installdirs target.
2187 sub handle_installdirs
2189 # GNU Makefile standards recommend this.
2190 $output_rules .= ("installdirs:"
2191 . ($recursive_install
2192 ? " installdirs-recursive\n"
2194 push (@phony, 'installdirs');
2197 &pretty_print_rule ("\t" . '$(mkinstalldirs) ', "\t\t",
2200 $output_rules .= "\n";
2203 # There are several targets which need to be merged. This is because
2204 # their complete definition is compiled from many parts. Note that we
2205 # avoid double colon rules, otherwise we'd use them instead.
2206 sub handle_merge_targets
2208 # There are a few install-related variables that you should not define.
2210 foreach $var ('PRE_INSTALL', 'POST_INSTALL', 'NORMAL_INSTALL')
2212 if (&variable_defined ($var))
2214 &am_line_error ($var, "\`$var' should not be defined");
2218 push (@all, 'Makefile');
2219 push (@all, $config_name)
2220 if $config_name && &dirname ($config_name) eq $relative_dir;
2222 &do_one_merge_target ('info', @info);
2223 &do_one_merge_target ('dvi', @dvi);
2225 if (! &variable_defined ('SUBDIRS') || $relative_dir ne '.')
2227 # 'check' must depend on 'all', but not at top level.
2229 unshift (@check, 'all');
2230 unshift (@install, 'all');
2232 &do_one_merge_target ('check', @check);
2233 &do_one_merge_target ('installcheck', @installcheck);
2235 # Handle the various install targets specially. We do this so
2236 # that (eg) "make install-exec" will run "install-exec-recursive"
2237 # if required, but "make install" won't run it twice. Step one is
2238 # to see if the user specified local versions of any of the
2239 # targets we handle. "all" is treated as one of these since
2240 # "install" can run it.
2241 push (@install_exec, 'install-exec-local')
2242 if defined $contents{'install-exec-local'};
2243 push (@install_data, 'install-data-local')
2244 if defined $contents{'install-data-local'};
2245 push (@uninstall, 'uninstall-local')
2246 if defined $contents{'uninstall-local'};
2248 foreach $utarg ('uninstall-data-local', 'uninstall-data-hook',
2249 'uninstall-exec-local', 'uninstall-exec-hook')
2251 if (defined $contents{$utarg})
2254 ($x = $utarg) =~ s/(data|exec)-//;
2255 &am_line_error ($utarg, "use \`$x', not \`$utarg'");
2258 push (@all, 'all-local')
2259 if defined $contents{'all-local'};
2261 if (defined $contents{'install-local'})
2263 &am_line_error ('install-local',
2264 "use \`install-data' or \`install-exec', not \`install'");
2267 # Step two: if we are doing recursive makes, write out the
2268 # appropriate rules.
2270 if ($recursive_install)
2272 push (@install, 'install-recursive');
2276 local (@hackall) = ();
2277 if ($config_name && &dirname ($config_name) eq $relative_dir)
2280 # This is kind of a hack, but I couldn't see a better
2281 # way to handle it. In this particular case, we need
2282 # to make sure config.h is built before we recurse.
2283 # We can't do this by changing the order of
2284 # dependencies to the "all" because that breaks when
2285 # using parallel makes. Instead we handle things
2287 $output_rules .= ('all-recursive-hack: $(CONFIG_HEADER)'
2288 . "\n\t" . '$(MAKE) all-recursive'
2290 push (@hackall, 'all-recursive-hack');
2291 push (@phony, 'all-recursive-hack');
2295 push (@hackall, 'all-recursive');
2298 $output_rules .= ('all-am: '
2302 push (@all, 'all-am');
2303 push (@phony, 'all-am');
2307 @all = ('all-recursive');
2311 $output_rules .= ('install-exec-am: '
2312 . join (' ', @install_exec)
2314 @install_exec = ('install-exec-recursive', 'install-exec-am');
2315 push (@install, 'install-exec-am');
2316 push (@phony, 'install-exec-am');
2320 @install_exec = ('install-exec-recursive');
2324 $output_rules .= ('install-data-am: '
2325 . join (' ', @install_data)
2327 @install_data = ('install-data-recursive', 'install-data-am');
2328 push (@install, 'install-data-am');
2329 push (@phony, 'install-data-am');
2333 @install_data = ('install-data-recursive');
2337 $output_rules .= ('uninstall-am: '
2338 . join (' ', @uninstall)
2340 @uninstall = ('uninstall-recursive', 'uninstall-am');
2341 push (@phony, 'uninstall-am');
2345 @uninstall = ('uninstall-recursive');
2349 # Step three: print definitions users can use. Code below knows
2350 # that install-exec is done before install-data, beware.
2351 $output_rules .= ("install-exec: "
2352 . join (' ', @install_exec)
2354 $output_rules .= "\t\$(NORMAL_INSTALL)\n";
2355 if (defined $contents{'install-exec-hook'})
2357 $output_rules .= "\t" . '$(MAKE) install-exec-hook' . "\n";
2359 $output_rules .= "\n";
2360 push (@install, 'install-exec') if !$recursive_install;
2361 push (@phony, 'install-exec');
2363 $output_rules .= ("install-data: "
2364 . join (' ', @install_data)
2366 $output_rules .= "\t\$(NORMAL_INSTALL)\n";
2367 if (defined $contents{'install-data-hook'})
2369 $output_rules .= "\t" . '$(MAKE) install-data-hook' . "\n";
2371 $output_rules .= "\n";
2372 push (@install, 'install-data') if !$recursive_install;
2373 push (@phony, 'install-data');
2375 # If no dependencies for 'install', add 'all'. Why? That way
2376 # "make install" at top level of distclean'd distribution won't
2377 # fail because stuff in 'lib' fails to build.
2378 if (! @install || (scalar (@install) == 2
2379 && $install[0] eq 'install-exec'
2380 && $install[1] eq 'install-data'))
2382 push (@install, 'all');
2384 $output_rules .= ('install: '
2385 . join (' ', @install)
2386 # Use "@:" as empty command so nothing prints.
2390 . join (' ', @uninstall)
2392 push (@phony, 'install', 'uninstall');
2394 $output_rules .= ('all: '
2397 push (@phony, 'all');
2399 # Generate the new 'install-strip' target.
2400 $output_rules .= ("install-strip:\n\t"
2401 . '$(MAKE) INSTALL_PROGRAM=\'$(INSTALL_PROGRAM) -s\' install'
2405 # Helper for handle_merge_targets.
2406 sub do_one_merge_target
2408 local ($name, @values) = @_;
2410 if (defined $contents{$name . '-local'})
2412 # User defined local form of target. So include it.
2413 push (@values, $name . '-local');
2414 push (@phony, $name . '-local');
2417 $output_rules .= $name . ":";
2420 $output_rules .= ' ' . join (' ', @values);
2422 $output_rules .= "\n\n";
2423 push (@phony, $name);
2426 # Handle all 'clean' targets.
2429 push (@clean, 'generic');
2430 $output_rules .= &file_contents ('clean');
2431 &push_phony_cleaners ('generic');
2433 local ($target) = $recursive_install ? 'clean-am' : 'clean';
2434 &do_one_clean_target ($target, 'mostly', '', @clean);
2435 &do_one_clean_target ($target, '', 'mostly', @clean);
2436 &do_one_clean_target ($target, 'dist', '', @clean);
2437 &do_one_clean_target ($target, 'maintainer-', 'dist', @clean);
2439 push (@phony, 'clean', 'mostlyclean', 'distclean', 'maintainer-clean');
2442 if ($recursive_install)
2444 @deps = ('am', 'recursive');
2445 &do_one_clean_target ('', 'mostly', '', @deps);
2446 &do_one_clean_target ('', '', '', @deps);
2447 &do_one_clean_target ('', 'dist', '', @deps);
2448 &do_one_clean_target ('', 'maintainer-', '', @deps);
2452 # Helper for handle_clean.
2453 sub do_one_clean_target
2455 local ($target, $name, $last_name, @deps) = @_;
2457 # Special case: if target not passed, then don't generate
2458 # dependency on next "lower" clean target (eg no
2459 # clean<-mostlyclean derivation). In this case the target is
2460 # implicitly known to be 'clean'.
2461 local ($flag) = $target;
2462 $target = 'clean' if ! $flag;
2464 grep (($_ = $name . 'clean-' . $_) && 0, @deps);
2467 if ($last_name || $name ne 'mostly')
2469 push (@deps, $last_name . $target . " ");
2472 # FIXME: not sure if I like the tabs here.
2473 &pretty_print_rule ($name . $target . ": ", "\t\t", @deps);
2475 # FIXME: shouldn't we really print these messages before running
2477 if ($name . $target eq 'maintainer-clean')
2479 # Print a special warning.
2481 ("\t\@echo \"This command is intended for maintainers to use;\"\n"
2482 . "\t\@echo \"it deletes files that may require special "
2483 . "tools to rebuild.\"\n");
2485 $output_rules .= "\trm -f config.status\n"
2486 if $relative_dir eq '.';
2488 elsif ($name . $target eq 'distclean')
2490 $output_rules .= "\trm -f config.status\n";
2492 $output_rules .= "\n";
2495 # Handle .PHONY target.
2498 &pretty_print_rule ('.PHONY:', "", @phony);
2499 $output_rules .= "\n";
2502 # Handle TESTS variable and other checks.
2505 if (defined $options{'dejagnu'})
2507 push (@check, 'check-DEJAGNU');
2508 push (@phony, 'check-DEJAGNU');
2509 $output_rules .= &file_contents ('dejagnu') . "\n";
2510 # Note that in the rule we don't directly generate site.exp to
2511 # avoid the possibility of a corrupted site.exp if make is
2512 # interrupted. Jim Meyering has some useful text on this
2514 $output_rules .= ("site.exp: Makefile\n"
2515 . "\t\@echo 'Making a new site.exp file...'\n"
2516 . "\t-\@rm -f site.bak\n"
2517 . "\t\@echo '## these variables are automatically generated by make ##' > \$\@-t\n"
2518 . "\t\@echo '# Do not edit here. If you wish to override these values' >> \$\@-t\n"
2519 . "\t\@echo '# edit the last section' >> \$\@-t\n"
2520 . "\t\@echo 'set tool \$(DEJATOOL)' >> \$\@-t\n"
2521 . "\t\@echo 'set srcdir \$(srcdir)' >> \$\@-t\n"
2522 . "\t\@echo 'set objdir' \`pwd\` >> \$\@-t\n");
2524 # Extra stuff for AC_CANONICAL_*
2525 local (@whatlist) = ();
2526 if ($seen_canonical)
2528 push (@whatlist, 'host')
2531 # Extra stuff only for AC_CANONICAL_SYSTEM.
2532 if ($seen_canonical == $AC_CANONICAL_SYSTEM)
2534 push (@whatlist, 'target', 'build');
2538 foreach $c1 (@whatlist)
2540 foreach $c2 ('alias', 'triplet')
2542 $output_rules .= "\t\@echo 'set ${c1}_${c2} \$(${c1}_${c2})' >> \$\@-t\n";
2546 $output_rules .= ("\t\@echo '## All variables above are generated by configure. Do Not Edit ##' >> \$\@-t\n"
2547 . "\t-\@sed '1,/^## All variables above are.*##/ d' site.bak >> \$\@-t\n"
2548 . "\t-\@mv site.exp site.bak\n"
2549 . "\t\@mv \$\@-t site.exp\n");
2554 foreach $c ('DEJATOOL', 'RUNTEST', 'RUNTESTFLAGS')
2556 if (&variable_defined ($c))
2558 &am_line_error ($c, "\`$c' defined but \`dejagnu' not in \`AUTOMAKE_OPTIONS'");
2563 if (&variable_defined ('TESTS'))
2565 push (@check, 'check-TESTS');
2566 push (@phony, 'check-TESTS');
2567 # FIXME: use $(SHELL) here? That is what Ulrich suggests.
2568 # Maybe a new macro, $(TEST_SHELL), a la $(CONFIG_SHELL)? For
2569 # now we just execute the file directly; this allows test
2570 # files which are compiled -- a possibly useful feature.
2571 $output_rules .= 'check-TESTS: $(TESTS)
2572 @failed=0; all=0; \\
2573 srcdir=$(srcdir); export srcdir; \\
2574 for tst in $(TESTS); do \\
2575 all=`expr $$all + 1`; \\
2576 if test -f $$tst; then dir=.; \\
2577 else dir="$(srcdir)"; fi; \\
2578 if $(TESTS_ENVIRONMENT) $$dir/$$tst; then \\
2579 echo "PASS: $$tst"; \\
2581 failed=`expr $$failed + 1`; \\
2582 echo "FAIL: $$tst"; \\
2585 if test "$$failed" -eq 0; then \\
2586 echo "========================"; \\
2587 echo "All $$all tests passed"; \\
2588 echo "========================"; \\
2590 echo "$$failed of $$all tests failed"; \\
2596 # Handle Emacs Lisp.
2597 sub handle_emacs_lisp
2599 local (@elfiles) = &am_install_var ('lisp', 'LISP', 'lisp', 'noinst');
2604 &define_variable ("lispdir", "\@lispdir\@");
2605 $output_rules .= (".el.elc:\n"
2606 . "\t\@echo 'WARNING: Warnings can be ignored. :-)'\n"
2607 . "\t\$(SHELL) \$(srcdir)/elisp-comp \$<\n");
2608 push (@suffixes, '.el', '.elc');
2610 # Generate .elc files.
2611 grep ($_ .= 'c', @elfiles);
2612 &define_pretty_variable ('ELCFILES', @elfiles);
2614 push (@clean, 'lisp');
2615 &push_phony_cleaners ('lisp');
2618 if (&variable_defined ('lisp_LISP'))
2620 $varname = 'lisp_LISP';
2621 &am_error ("\`lisp_LISP' defined but \`AM_PATH_LISPDIR' not in \`configure.in'")
2626 $varname = 'noinst_LISP';
2629 &require_file_with_line ($varname, $FOREIGN, 'elisp-comp');
2633 ################################################################
2635 # Scan configure.in for interesting things.
2638 open (CONFIGURE, 'configure.in')
2639 || die "automake: couldn't open \`configure.in': $!\n";
2640 print "automake: reading configure.in\n" if $verbose;
2642 # Reinitialize libsources here. This isn't really necessary,
2643 # since we currently assume there is only one configure.in. But
2644 # that won't always be the case.
2647 local ($in_ac_output, @make_list) = 0;
2648 local ($libobj_iter);
2651 # Remove comments from current line.
2655 # Populate libobjs array.
2656 if (/AC_FUNC_ALLOCA/)
2658 $libsources{'alloca.c'} = 1;
2660 elsif (/AC_FUNC_GETLOADAVG/)
2662 $libsources{'getloadavg.c'} = 1;
2664 elsif (/AC_FUNC_MEMCMP/)
2666 $libsources{'memcmp.c'} = 1;
2668 elsif (/AC_STRUCT_ST_BLOCKS/)
2670 $libsources{'fileblocks.c'} = 1;
2672 elsif (/AM_FUNC_FNMATCH/)
2674 $libsources{'fnmatch.c'} = 1;
2676 elsif (/AC_REPLACE_FUNCS\s*\((.*)\)/)
2678 foreach (split (' ', $1))
2680 $libsources{$_ . '.c'} = 1;
2683 elsif (/A[CM]_REPLACE_GNU_GETOPT/)
2685 $libsources{'getopt.c'} = 1;
2686 $libsources{'getopt1.c'} = 1;
2688 elsif (/AM_FUNC_STRTOD/)
2690 $libsources{'strtod.c'} = 1;
2692 elsif (/AM_WITH_REGEX/)
2694 $libsources{'rx.c'} = 1;
2695 $libsources{'rx.h'} = 1;
2696 $libsources{'regex.c'} = 1;
2697 $libsources{'regex.h'} = 1;
2699 elsif (/LIBOBJS="(.*)\s+\$LIBOBJS"/
2700 || /LIBOBJS="\$LIBOBJS\s+(.*)"/)
2702 foreach $libobj_iter (split (' ', $1))
2704 if ($libobj_iter =~ /^(.*)\.o$/)
2706 $libsources{$1 . '.c'} = 1;
2711 if (/(fp_FUNC_FNMATCH|fp_PROG_INSTALL|fp_C_PROTOTYPES|jm_MAINTAINER_MODE)/)
2713 &am_conf_line_error ($., "\`$1' is obsolete; use corresponding \`AM_' macro");
2716 # Process the AC_OUTPUT macro.
2717 if (! $in_ac_output && s/AC_OUTPUT\s*\(\[?//)
2720 $ac_output_line = $.;
2724 $in_ac_output = 0 if s/[\]\),].*$//;
2726 # Look at potential Makefile.am's.
2732 push (@make_list, $_);
2736 push (@other_input_files, $_);
2741 if (/AC_CONFIG_AUX_DIR\(([^)]+)\)/)
2743 @config_aux_path = $1;
2746 # Check for ansi2knr.
2747 $am_c_prototypes = 1 if /AM_C_PROTOTYPES/;
2749 # Check for NLS support.
2750 if (/ud_GNU_GETTEXT/)
2753 $ac_gettext_line = $.;
2756 # Look for ALL_LINGUAS.
2757 if (/ALL_LINGUAS="(.*)"$/ || /ALL_LINGUAS=(.*)$/)
2761 $all_linguas_line = $.;
2764 # Handle configuration headers.
2765 if (/AC_CONFIG_HEADER\s*\((.*)\)/)
2767 $config_header_line = $.;
2769 if ($config_name =~ /^([^:]+):(.+)$/)
2772 $config_header = $2;
2776 $config_header = $config_name . '.in';
2780 # Handle AC_CANONICAL_*. Always allow upgrading to
2781 # AC_CANONICAL_SYSTEM, but never downgrading.
2782 $seen_canonical = $AC_CANONICAL_HOST
2783 if ! $seen_canonical
2784 && (/AC_CANONICAL_HOST/ || /AC_CHECK_TOOL/);
2785 $seen_canonical = $AC_CANONICAL_SYSTEM if /AC_CANONICAL_SYSTEM/;
2787 $seen_path_xtra = 1 if /AC_PATH_XTRA/;
2789 # Sometimes it is desirable to explicitly set YACC. For
2790 # instance some people don't want to use bison.
2791 $seen_prog_yacc = 1 if (/AC_PROG_YACC/
2792 || /AC_SUBST\(YACC\)/
2793 || /AC_(PATH|CHECK)_PROGS?\(YACC/);
2795 # This macro handles several different things.
2796 if (/AM_INIT_AUTOMAKE\([^,]*,([^)]+)\)/)
2802 $seen_prog_install = 2;
2803 ($package_version = $1) =~ s/\s//;
2804 $package_version_line = $.;
2807 # Some things required by Automake.
2808 $seen_make_set = 1 if /AC_PROG_MAKE_SET/;
2809 $seen_arg_prog = 1 if /AC_ARG_PROGRAM/;
2810 $seen_ranlib = 1 if /AC_PROG_RANLIB/;
2811 $seen_prog_cc = 1 if /AC_PROG_CC/;
2812 $seen_prog_cxx = 1 if /AC_PROG_CXX/;
2813 $seen_prog_lex = 1 if /AC_PROG_LEX/;
2814 $seen_decl_yytext = 1 if /AC_DECL_YYTEXT/;
2815 $seen_maint_mode = 1 if /AM_MAINTAINER_MODE/;
2816 $seen_package = 1 if /PACKAGE=/;
2818 if (/VERSION=(\S+)/)
2821 $package_version = $1;
2822 $package_version_line = $.;
2829 # Weird conditionals here because it is always allowed to
2830 # upgrade to AM_PROG_INSTALL but never to downgrade to
2832 $seen_prog_install = 1 if ! $seen_prog_install && /AC_PROG_INSTALL/;
2833 $seen_prog_install = 2 if /AM_PROG_INSTALL/;
2835 $seen_lispdir = 1 if /AM_PATH_LISPDIR/;
2837 if (/AM_PROG_LIBTOOL/)
2845 # Set input files if not specified by user.
2846 @input_files = @make_list if (! @input_files);
2850 &am_conf_error ("\`PACKAGE' not defined in configure.in")
2852 &am_conf_error ("\`VERSION' not defined in configure.in")
2855 # Look for some files we need. Always check for these. This
2856 # check must be done for every run, even those where we are only
2857 # looking at a subdir Makefile. We must set relative_dir so that
2858 # the file-finding machinery works.
2859 local ($relative_dir) = '.';
2860 &require_config_file ($FOREIGN, 'install-sh', 'mkinstalldirs');
2861 &am_error ("\`install.sh' is an anachronism; use \`install-sh' instead")
2862 if -f $config_aux_path[0] . '/install.sh';
2865 ################################################################
2867 # Do any extra checking for GNU standards.
2868 sub check_gnu_standards
2870 if ($relative_dir eq '.')
2872 # In top level (or only) directory.
2873 &require_file ($GNU, 'INSTALL', 'NEWS', 'README', 'COPYING',
2874 'AUTHORS', 'ChangeLog');
2877 if ($strictness >= $GNU)
2879 if (defined $options{'no-installman'})
2881 &am_line_error ('AUTOMAKE_OPTIONS',
2882 "option \`no-installman' disallowed by GNU standards");
2885 if (defined $options{'no-installinfo'})
2887 &am_line_error ('AUTOMAKE_OPTIONS',
2888 "option \`no-installinfo' disallowed by GNU standards");
2893 # Do any extra checking for GNITS standards.
2894 sub check_gnits_standards
2896 if ($strictness >= $GNITS)
2898 if (-f $relative_dir . '/COPYING.LIB')
2900 &am_error ("\`${relative_dir}/COPYING.LIB' disallowed by Gnits standards");
2903 if ($relative_dir eq '.')
2905 if ($package_version !~ /^$GNITS_VERSION_PATTERN$/)
2907 &am_conf_line_error ($package_version_line,
2908 "version \`$package_version' doesn't follow Gnits standards");
2910 elsif (defined $1 && -f 'README-alpha')
2912 # This means we have an alpha release. See
2913 # GNITS_VERSION_PATTERN for details.
2914 &require_file ($GNITS, 'README-alpha');
2919 if ($relative_dir eq '.')
2921 # In top level (or only) directory.
2922 &require_file ($GNITS, 'THANKS');
2926 ################################################################
2928 # Pretty-print something. HEAD is what should be printed at the
2929 # beginning of the first line, FILL is what should be printed at the
2930 # beginning of every subsequent line.
2931 sub pretty_print_internal
2933 local ($head, $fill, @values) = @_;
2935 local ($column) = length ($head);
2936 local ($result) = $head;
2938 # Fill length is number of characters. However, each Tab
2939 # character counts for eight. So we count the number of Tabs and
2941 local ($fill_length) = length ($fill);
2942 $fill_length += 7 * ($fill =~ tr/\t/\t/d);
2947 # "71" because we also print a space.
2948 if ($column + length ($_) > 71)
2950 $result .= " \\\n" . $fill;
2951 $column = $fill_length;
2955 $result .= ' ' unless ($bol);
2957 $column += length ($_) + 1;
2965 # Pretty-print something and append to output_vars.
2968 $output_vars .= &pretty_print_internal (@_);
2971 # Pretty-print something and append to output_rules.
2972 sub pretty_print_rule
2974 $output_rules .= &pretty_print_internal (@_);
2978 ################################################################
2980 # See if a variable exists.
2981 sub variable_defined
2984 if (defined $targets{$var})
2986 &am_line_error ($var, "\`$var' is target; expected variable");
2989 elsif (defined $contents{$var})
2991 $content_seen{$var} = 1;
2997 # Return contents of variable as list, split as whitespace. This will
2998 # recursively follow $(...) and ${...} inclusions. It preserves @...@
2999 # substitutions. If PARENT is specified, it is the name of the
3000 # including variable; this is only used for error reports.
3001 sub variable_value_as_list
3003 local ($var, $parent) = @_;
3006 if (defined $targets{$var})
3008 &am_line_error ($var, "\`$var' is target; expected variable");
3010 elsif (! defined $contents{$var})
3012 &am_line_error ($parent, "variable \`$var' not defined");
3016 $content_seen{$var} = 1;
3017 foreach (split (' ', $contents{$var}))
3019 # Handle variable substitutions.
3020 if (/^\$\{(.*)\}$/ || /^\$\((.*)\)$/)
3022 push (@result, &variable_value_as_list ($1, $var));
3034 # Define a new variable, but only if not already defined.
3037 local ($var, $value) = @_;
3039 if (! defined $contents{$var})
3041 $output_vars .= $var . ' = ' . $value . "\n";
3042 $contents{$var} = $value;
3043 $content_seen{$var} = 1;
3047 # Like define_variable, but second arg is a list, and is
3049 sub define_pretty_variable
3051 local ($var, @value) = @_;
3052 if (! defined $contents{$var})
3054 $contents{$var} = join (' ', @value);
3055 &pretty_print ($var . ' = ', '', @value);
3056 $content_seen{$var} = 1;
3060 # Read Makefile.am and set up %contents. Simultaneously copy lines
3061 # from Makefile.am into $output_trailer or $output_vars as
3062 # appropriate. NOTE we put rules in the trailer section. We want
3063 # user rules to come after our generated stuff.
3066 local ($amfile) = @_;
3068 # Compute relative location of the top object directory.
3069 local (@topdir) = ();
3070 foreach (split (/\//, $relative_dir))
3072 next if $_ eq '.' || $_ eq '';
3079 push (@topdir, '..');
3082 @topdir = ('.') if ! @topdir;
3084 $top_builddir = join ('/', @topdir);
3086 ($build_rx = $top_builddir) =~ s/(\W)/\\$1/g;
3087 local ($header_vars) =
3088 &file_contents_with_transform
3089 ('s/\@top_builddir\@/' . $build_rx . '/g',
3092 # Generate some useful variables when AC_CANONICAL_* used.
3093 if ($seen_canonical)
3095 local ($curs, @varlist);
3096 push (@varlist, 'host_alias', 'host_triplet');
3097 if ($seen_canonical == $AC_CANONICAL_SYSTEM)
3099 push (@varlist, 'build_alias', 'target_alias');
3101 foreach $curs (@varlist)
3103 $header_vars .= "$curs = \@$curs\@\n";
3104 $contents{$curs} = "\@$curs\@";
3108 open (AM_FILE, $amfile) || die "automake: couldn't open \`$amfile': $!\n";
3109 print "automake: reading $amfile\n" if $verbose;
3111 $output_vars .= ("# $in_file_name generated automatically by automake "
3112 . $VERSION . " from $am_file_name\n");
3114 # Generate copyright for generated Makefile.in.
3115 $output_vars .= $gen_copyright;
3117 local ($saw_bk) = 0;
3118 local ($was_rule) = 0;
3119 local ($spacing) = '';
3120 local ($comment) = '';
3121 local ($last_var_name) = '';
3126 if (/$IGNORE_PATTERN/o)
3128 # Merely delete comments beginning with two hashes.
3130 elsif (/$WHITE_PATTERN/o)
3132 # Stick a single white line before the incoming macro or rule.
3136 elsif (/$COMMENT_PATTERN/o)
3138 # Stick comments before the incoming macro or rule. Make
3139 # sure a blank line preceeds first block of comments.
3140 $spacing = "\n" unless $blank;
3142 $comment .= $spacing . $_;
3151 $output_vars .= $comment . "\n" . $header_vars;
3155 local ($is_ok_macro);
3159 unless substr ($_, -1, 1) eq "\n";
3161 $_ =~ s/\@(UN)?MAINT\@//g
3162 unless $seen_maint_mode;
3164 if (/$IGNORE_PATTERN/o)
3166 # Merely delete comments beginning with two hashes.
3168 elsif (/$WHITE_PATTERN/o)
3170 # Stick a single white line before the incoming macro or rule.
3173 elsif (/$COMMENT_PATTERN/o)
3175 # Stick comments before the incoming macro or rule.
3176 $comment .= $spacing . $_;
3183 $output_trailer .= $_;
3190 # Chop newline and backslash if this line is
3191 # continued. FIXME: maybe ensure trailing whitespace
3195 $contents{$last_var_name} .= $_;
3198 elsif (/$RULE_PATTERN/o)
3200 # warn "** Saw rule .$1.\n";
3203 # Value here doesn't matter; for targets we only note
3207 $content_lines{$1} = $.;
3208 $output_trailer .= $comment . $spacing . $_;
3209 $comment = $spacing = '';
3212 elsif (($is_ok_macro = /$MACRO_PATTERN/o)
3213 || /$BOGUS_MACRO_PATTERN/o)
3215 # Found a macro definition.
3217 $last_var_name = $1;
3218 if (substr ($2, -1) eq "\\")
3220 $contents{$1} = substr ($2, 0, length ($2) - 1);
3226 $content_lines{$1} = $.;
3227 $output_vars .= $comment . $spacing . $_;
3228 $comment = $spacing = '';
3232 &am_line_error ($., "bad macro name \`$1'")
3237 # This isn't an error; it is probably a continued rule.
3238 # In fact, this is what we assume.
3240 $output_trailer .= $comment . $spacing . $_;
3241 $comment = $spacing = '';
3248 $output_trailer .= $comment;
3251 ################################################################
3253 sub initialize_global_constants
3255 # Values for AC_CANONICAL_*
3256 $AC_CANONICAL_HOST = 1;
3257 $AC_CANONICAL_SYSTEM = 2;
3259 # Associative array of standard directory names. Entry is TRUE if
3260 # corresponding directory should be installed during
3261 # 'install-exec' phase.
3279 # Helper text for dealing with man pages.
3280 $install_man_format =
3281 ' sect=@SECTION@; \\
3282 inst=`echo "@MANBASE@" | sed \'$(transform)\'`.@FULLSECT@; \\
3283 if test -f $(srcdir)/@MAN@; then file=$(srcdir)/@MAN@; \\
3284 else file=@MAN@; fi; \\
3285 $(INSTALL_DATA) $$file $(mandir)/man$$sect/$$inst
3288 $uninstall_man_format =
3289 ' inst=`echo "@MANBASE@" | sed \'$(transform)\'`.@FULLSECT@; \\
3290 rm -f $(mandir)/man@SECTION@/$$inst
3293 # Commonly found files we look for and automatically include in
3297 "README", "THANKS", "TODO", "NEWS", "COPYING", "COPYING.LIB",
3298 "INSTALL", "ABOUT-NLS", "ChangeLog", "configure", "configure.in",
3299 "config.guess", "config.sub", "AUTHORS", "BACKLOG", "ABOUT-GNU",
3300 "libversion.in", "mdate-sh", "mkinstalldirs", "install-sh",
3301 'texinfo.tex', "ansi2knr.c", "ansi2knr.1", 'elisp-comp',
3302 'interlock', 'ylwrap', 'acinclude.m4'
3305 # Commonly used files we auto-include, but only sometimes.
3308 "aclocal.m4", "acconfig.h", "config.h.top",
3309 "config.h.bot", "stamp-h.in", 'stamp-vti', 'libtool'
3313 -a, --add-missing add missing standard files to package
3314 --amdir=DIR directory storing config files
3315 --build-dir=DIR directory where build being done (for dependencies)
3316 --foreign same as --strictness=foreign
3317 --gnits same as --strictness=gnits
3318 --gnu same as --strictness=gnu
3319 --help print this help, then exit
3320 -i, --include-deps include generated dependencies in Makefile.in
3321 --no-force only update Makefile.in's that are out of date
3322 -o DIR, --output-dir=DIR
3323 put generated Makefile.in's into DIR
3324 --srcdir-name=DIR name used for srcdir (for dependencies)
3325 -s LEVEL, --strictness=LEVEL
3326 set strictness level. LEVEL is foreign, gnu, gnits
3327 -v, --verbose verbosely list files processed
3328 --version print version number, then exit\n";
3330 # Copyright on generated Makefile.ins.
3332 # Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
3333 # This Makefile.in is free software; the Free Software Foundation
3334 # gives unlimited permission to copy, distribute and modify it.
3338 # (Re)-Initialize per-Makefile.am variables.
3339 sub initialize_per_input
3341 # These two variables are used when generating each Makefile.in.
3342 # They hold the Makefile.in until it is ready to be printed.
3345 $output_trailer = '';
3347 # Suffixes found during a run.
3350 # This holds the contents of a Makefile.am, as parsed by
3354 # This holds the names which are targets. These also appear in
3358 # This holds the line numbers at which various elements of
3359 # %contents are defined.
3360 %content_lines = ();
3362 # This holds a 1 if a particular variable was examined.
3365 # This holds the "relative directory" of the current Makefile.in.
3366 # Eg for src/Makefile.in, this is "src".
3369 # This holds a list of files that are included in the
3373 # List of dependencies for the obvious targets.
3388 # These are pretty obvious, too. They are used to define the
3389 # SOURCES and OBJECTS variables.
3393 # TRUE if current directory holds any C source files. (Actually
3394 # holds object extension, but this information is encapsulated in
3395 # the function get_object_extension).
3396 $dir_holds_sources = '';
3398 # TRUE if current directory holds any headers.
3399 $dir_holds_headers = 0;
3401 # TRUE if install targets should work recursively.
3402 $recursive_install = 0;
3407 # Strictness levels.
3408 $strictness = $default_strictness;
3409 $strictness_name = $default_strictness_name;
3411 # Options from AUTOMAKE_OPTIONS.
3414 # Whether or not dependencies are handled. Can be further changed
3415 # in handle_options.
3416 $use_dependencies = $cmdline_use_dependencies;
3419 $local_maint_charset = $maint_charset;
3421 # All yacc and lex source filenames for this directory. Use
3422 # filenames instead of raw count so that multiple instances are
3423 # counted correctly (eg one yacc file can appear in multiple
3424 # programs without harm).
3428 # C++ source extensions we've seen.
3429 %cxx_extensions = ();
3431 # TRUE if we've seen any non-C++ sources.
3436 ################################################################
3438 # Return contents of a file from $am_dir, automatically skipping
3439 # macros or rules which are already known. Runs command on each line
3440 # as it is read; this command can modify $_.
3441 sub file_contents_with_transform
3443 local ($command, $basename) = @_;
3444 local ($file) = $am_dir . '/' . $basename . '.am';
3446 open (FC_FILE, $file)
3447 || die "automake: installation error: cannot open \`$file'\n";
3449 # print "automake: reading $file\n" if $verbose;
3451 local ($was_rule) = 0;
3452 local ($result_vars) = '';
3453 local ($result_rules) = '';
3454 local ($comment) = '';
3455 local ($spacing) = "\n";
3456 local ($skipping) = 0;
3460 $_ =~ s/\@(UN)?MAINT\@//g
3461 unless $seen_maint_mode;
3465 if (/$IGNORE_PATTERN/o)
3467 # Merely delete comments beginning with two hashes.
3469 elsif (/$WHITE_PATTERN/o)
3471 # Stick a single white line before the incoming macro or rule.
3474 elsif (/$COMMENT_PATTERN/o)
3476 # Stick comments before the incoming macro or rule.
3477 $comment .= $spacing . $_;
3484 $result_rules .= $_ if ! $skipping;
3488 $result_vars .= $_ if ! $skipping;
3492 elsif (/$RULE_PATTERN/o)
3494 # warn "** Found rule .$1.\n";
3497 $skipping = defined $contents{$1};
3498 # warn "** Skip $skipping\n" if $skipping;
3499 $result_rules .= $comment . $spacing . $_ if ! $skipping;
3500 $comment = $spacing = '';
3503 elsif (/$MACRO_PATTERN/o)
3505 # warn "** Found macro .$1.\n";
3506 # Found a variable reference.
3508 $skipping = defined $contents{$1};
3509 # warn "** Skip $skipping\n" if $skipping;
3510 $result_vars .= $comment . $spacing . $_ if ! $skipping;
3511 $comment = $spacing = '';
3516 # This isn't an error; it is probably a continued rule.
3517 # In fact, this is what we assume.
3519 $result_rules .= $comment . $spacing . $_ if ! $skipping;
3520 $comment = $spacing = '';
3526 return $result_vars . $result_rules . $comment;
3529 # Like file_contents_with_transform, but no transform.
3532 return &file_contents_with_transform ('', @_);
3535 # Find all variable prefixes that are used for install directories. A
3536 # prefix `zar' qualifies iff:
3537 # * `zardir' is a variable.
3538 # * `zar_PRIMARY' is a variable.
3539 sub am_primary_prefixes
3541 local ($primary, @prefixes) = @_;
3543 local (%valid, $varname);
3544 grep ($valid{$_} = 0, @prefixes);
3545 $valid{'EXTRA'} = 0;
3546 foreach $varname (keys %contents)
3548 if ($varname =~ /^(.*)_$primary$/)
3550 if (! defined $valid{$1} && ! &variable_defined ($1 . 'dir'))
3552 &am_line_error ($varname, "invalid variable \"$varname\"");
3556 # Ensure all extended prefixes are actually used.
3565 # Handle `where_HOW' variable magic. Does all lookups, generates
3566 # install code, and possibly generates code to define the primary
3567 # variable. The first argument is the name of the .am file to munge,
3568 # the second argument is the primary variable (eg HEADERS), and all
3569 # subsequent arguments are possible installation locations. Returns
3570 # list of all values of all _HOW targets.
3572 # FIXME: this should be rewritten to be cleaner. It should be broken
3573 # up into multiple functions.
3575 # Usage is: am_install_var (OPTION..., file, HOW, where...)
3580 local ($do_all, $do_clean) = (1, 0);
3583 if ($args[0] eq '-clean')
3587 elsif ($args[0] eq '-no-all')
3591 elsif ($args[0] !~ /^-/)
3597 local ($file, $primary, @prefixes) = @args;
3600 local (@result) = ();
3602 # Now that configure substitutions are allowed in where_HOW
3603 # variables, it is an error to actually define the primary.
3604 &am_line_error ($primary, "\`$primary' is an anachronism")
3605 if &variable_defined ($primary);
3608 # Look for misspellings. It is an error to have a variable ending
3609 # in a "reserved" suffix whose prefix is unknown, eg
3610 # "bni_PROGRAMS". However, unusual prefixes are allowed if a
3611 # variable of the same name (with "dir" appended) exists. For
3612 # instance, if the variable "zardir" is defined, then
3613 # "zar_PROGRAMS" becomes valid. This is to provide a little extra
3614 # flexibility in those cases which need it. Perhaps it should be
3615 # disallowed in the Gnits case? The problem is, sometimes it is
3616 # useful to put things in a subdir of eg pkgdatadir, perhaps even
3618 local (%valid) = &am_primary_prefixes ($primary, @prefixes);
3620 local ($clean_file) = $file . '-clean';
3623 foreach $X (keys %valid)
3625 $one_name = $X . '_' . $primary;
3626 if (&variable_defined ($one_name))
3628 # Append actual contents of where_PRIMARY variable to
3631 foreach $rcurs (&variable_value_as_list ($one_name))
3633 # Skip configure substitutions. Possibly bogus.
3634 next if $rcurs =~ /^\@.*\@$/;
3635 push (@result, $rcurs);
3638 # "EXTRA" shouldn't be used when generating clean targets,
3639 # @all, or install targets.
3640 next if $X eq 'EXTRA';
3645 &file_contents_with_transform ('s/\@DIR\@/' . $X . '/go',
3648 push (@clean, $X . $primary);
3649 &push_phony_cleaners ($X . $primary);
3654 push (@check, '$(' . $one_name . ')');
3658 push (@used, '$(' . $one_name . ')');
3660 if ($X eq 'noinst' || $X eq 'check')
3662 # Objects which don't get installed by default.
3667 &file_contents_with_transform ('s/\@DIR\@/' . $X . '/go',
3670 push (@uninstall, 'uninstall-' . $X . $primary);
3671 push (@phony, 'uninstall-' . $X . $primary);
3672 push (@installdirs, '$(' . $X . 'dir)');
3673 if ($exec_dir_p{$X})
3675 push (@install_exec, 'install-' . $X . $primary);
3676 push (@phony, 'install-' . $X . $primary);
3680 push (@install_data, 'install-' . $X . $primary);
3681 push (@phony, 'install-' . $X . $primary);
3689 &define_pretty_variable ($primary, @used);
3690 $output_vars .= "\n";
3693 # Push here because PRIMARY might be configure time determined.
3694 push (@all, '$(' . $primary . ')')
3695 if $do_all && @used;
3701 ################################################################
3703 # This variable is local to the "require file" set of functions.
3704 @require_file_paths = ();
3706 # Verify that the file must exist in the current directory. Usage:
3707 # require_file (isconfigure, line_number, strictness, file) strictness
3708 # is the strictness level at which this file becomes required. Must
3709 # set require_file_paths before calling this function.
3710 # require_file_paths is set to hold a single directory (the one in
3711 # which the first file was found) before return.
3712 sub require_file_internal
3714 local ($is_configure, $line, $mystrict, @files) = @_;
3715 local ($file, $fullfile);
3716 local ($found_it, $errfile, $errdir);
3719 foreach $file (@files)
3722 foreach $dir (@require_file_paths)
3726 $fullfile = $relative_dir . "/" . $file;
3727 $errdir = $relative_dir unless $errdir;
3731 $fullfile = $dir . "/" . $file;
3732 $errdir = $dir unless $errdir;
3735 # Use different name for "error filename". Otherwise on
3736 # an error the bad file will be reported as eg
3737 # `../../install-sh' when using the default
3739 $errfile = $errdir . '/' . $file;
3744 # FIXME: Once again, special-case `.'.
3745 &push_dist_common ($file)
3746 if $dir eq $relative_dir || $dir eq '.';
3754 # Prune the path list.
3755 @require_file_paths = $save_dir;
3759 if ($strictness >= $mystrict)
3761 # Only install missing files according to our desired
3763 if ($add_missing && -f ($am_dir . '/' . $file))
3765 # Install the missing file. Symlink if we can, copy
3767 if ($symlink_exists)
3769 symlink ($am_dir . '/' . $file, $errfile);
3773 system ('cp', $am_dir . '/' . $file, $errfile);
3776 # FIXME: this is a hack. Should have am_warn.
3777 local ($save) = $exit_status;
3782 "required file \"$errfile\" not found; installing");
3788 "required file \"$errfile\" not found; installing");
3790 $exit_status = $save;
3794 # Only an error if strictness constraint violated.
3798 ($line, "required file \"$errfile\" not found");
3803 ($line, "required file \"$errfile\" not found");
3811 # Like require_file_with_line, but error messages refer to
3812 # configure.in, not the current Makefile.am.
3813 sub require_file_with_conf_line
3815 @require_file_paths = '.';
3816 &require_file_internal (1, @_);
3819 sub require_file_with_line
3821 @require_file_paths = '.';
3822 &require_file_internal (0, @_);
3827 @require_file_paths = '.';
3828 &require_file_internal (0, '', @_);
3831 # Require a file that is also required by Autoconf. Looks in
3832 # configuration path, as specified by AC_CONFIG_AUX_DIR.
3833 sub require_config_file
3835 @require_file_paths = @config_aux_path;
3836 &require_file_internal (0, '', @_);
3837 local ($dir) = $require_file_paths[0];
3838 @config_aux_path = @require_file_paths;
3841 $config_aux_dir = '.';
3845 $config_aux_dir = '$(top_srcdir)/' . $dir;
3849 # Assumes that the line number is in Makefile.am.
3850 sub require_conf_file_with_line
3852 @require_file_paths = @config_aux_path;
3853 &require_file_internal (0, @_);
3854 local ($dir) = $require_file_paths[0];
3855 @config_aux_path = @require_file_paths;
3858 $config_aux_dir = '.';
3862 $config_aux_dir = '$(top_srcdir)/' . $dir;
3866 # Assumes that the line number is in Makefile.am.
3867 sub require_conf_file_with_conf_line
3869 @require_file_paths = @config_aux_path;
3870 &require_file_internal (1, @_);
3871 local ($dir) = $require_file_paths[0];
3872 @config_aux_path = @require_file_paths;
3875 $config_aux_dir = '.';
3879 $config_aux_dir = '$(top_srcdir)/' . $dir;
3883 ################################################################
3885 # Push a list of files onto dist_common.
3886 sub push_dist_common
3888 local (@files) = @_;
3891 foreach $file (@files)
3893 $dist_common{$file} = 1;
3897 # Push a list of clean targets onto phony.
3898 sub push_phony_cleaners
3902 foreach $target ('mostly', 'dist', '', 'maintainer-')
3904 push (@phony, $target . 'clean-' . $base);
3911 $strictness_name = $_[0];
3912 if ($strictness_name eq 'gnu')
3916 elsif ($strictness_name eq 'gnits')
3918 $strictness = $GNITS;
3920 elsif ($strictness_name eq 'foreign')
3922 $strictness = $FOREIGN;
3926 die "automake: level \`$strictness_name' not recognized\n";
3931 ################################################################
3933 # Return directory name of file.
3939 ($sub = $file) =~ s,/+[^/]+$,,g;
3940 $sub = '.' if $sub eq $file;
3944 # Return file name of a file.
3950 ($sub = $file) =~s,^.*/+,,g;
3959 open (TOUCH, ">> $file");
3963 ################################################################
3965 # Print an error message and set exit status.
3968 warn "automake: ${am_file}.am: ", join (' ', @_), "\n";
3974 local ($symbol, @args) = @_;
3978 # If SYMBOL not already a line number, look it up in Makefile.am.
3979 $symbol = $content_lines{$symbol} unless $symbol =~ /^\d+$/;
3980 $symbol .= ': ' if $symbol;
3981 warn "${am_file}.am:", $symbol, join (' ', @args), "\n";
3990 # Like am_error, but while scanning configure.in.
3993 # FIXME: can run in subdirs.
3994 warn "automake: configure.in: ", join (' ', @_), "\n";
3998 # Error message with line number referring to configure.in.
3999 sub am_conf_line_error
4001 local ($line, @args) = @_;
4005 warn "configure.in: $line: ", join (' ', @args), "\n";
4010 &am_conf_error (@args);
4014 # Tell user where our aclocal.m4 is, but only once.
4015 sub keyed_aclocal_warning
4018 warn "automake: macro \`$key' can be generated by \`aclocal'\n";
4021 # Print usage information.
4024 print "Usage: automake [OPTION] ... [Makefile]...\n";
4026 print "\nFiles which are automatically distributed, if found:\n";
4027 $~ = "USAGE_FORMAT";
4028 local (@lcomm) = sort ((@common_files, @common_sometimes));
4029 local ($one, $two, $three, $four);
4032 $one = shift @lcomm;
4033 $two = @lcomm ? shift @lcomm : '';
4034 $three = @lcomm ? shift @lcomm : '';
4035 $four = @lcomm ? shift @lcomm : '';
4039 print "\nReport bugs to <bug-gnu-utils\@prep.ai.mit.edu>\n";
4044 format USAGE_FORMAT =
4045 @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<
4046 $one, $two, $three, $four