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@";
34 $am_dir = "@datadir@/@PACKAGE@";
37 $IGNORE_PATTERN = "^##([^#].*)?\$";
38 $WHITE_PATTERN = "^[ \t]*\$";
39 $COMMENT_PATTERN = "^#";
40 $RULE_PATTERN = "^([\$a-zA-Z_.][-.a-zA-Z0-9_(){}/]*) *:";
41 $MACRO_PATTERN = "^([A-Za-z][A-Za-z0-9_]*)[ \t]*=[ \t]*(.*)\$";
42 $BOGUS_MACRO_PATTERN = "^([^ \t]*)[ \t]*=[ \t]*(.*)\$";
44 # Constants to define the "strictness" level.
51 # Variables global to entire run.
53 # Strictness level as set on command line.
54 $default_strictness = $GNU;
56 # Name of strictness level, as set on command line.
57 $default_strictness_name = 'gnu';
59 # This is TRUE if GNU make specific automatic dependency generation
60 # code should be included in generated Makefile.in.
61 $cmdline_use_dependencies = 1;
63 # TRUE if in verbose mode.
66 # This holds our (eventual) exit status. We don't actually exit until
67 # we have processed all input files.
70 # From the Perl manual.
71 $symlink_exists = (eval 'symlink ("", "");', $@ eq '');
73 # TRUE if missing standard files should be installed.
76 # Files found by scanning configure.in for LIBOBJS.
79 # True if fp_C_PROTOTYPES appears in configure.in.
82 # Names used in AC_CONFIG_HEADER call. $config_name is the actual
83 # (first) argument. $config_header is the '.in' file. Ordinarily the
84 # second is derived from the first, but they can be different if the
85 # weird "NAME:FILE" syntax is used.
88 # Line number at which AC_CONFIG_HEADER appears in configure.in.
89 $config_header_line = 0;
91 # Directory where output files go. Actually, output files are
92 # relative to this directory.
93 $output_directory = '.';
95 # Relative location of top build directory.
98 # List of Makefile.am's to process.
101 # List of files in AC_OUTPUT without Makefile.am.
102 @other_input_files = ();
103 # Line number at which AC_OUTPUT seen.
106 # List of directories to search for configure-required files. This
107 # can be set by AC_CONFIG_AUX_DIR.
108 @config_aux_path = ('.', '..', '../..');
109 $config_aux_dir = '';
111 # Whether AC_PROG_MAKE_SET has been seen in configure.in.
114 # Whether ud_GNU_GETTEXT has been seen in configure.in.
116 # Line number at which ud_GNU_GETTEXT seen.
117 $ac_gettext_line = 0;
119 # Whether ALL_LINGUAS has been seen.
123 # Line number at which it appears.
124 $all_linguas_line = 0;
126 # 1 if AC_PROG_INSTALL seen, 2 if fp_PROG_INSTALL seen.
127 $seen_prog_install = 0;
129 # 1 if any scripts installed, 0 otherwise.
130 $scripts_installed = 0;
132 # Whether AC_PATH_XTRA has been seen in configure.in.
135 # Whether YACC variable has been seen in configure.in.
138 # TRUE if we've seen AC_CANONICAL_(HOST|SYSTEM). The presence of
139 # AC_CHECK_TOOL also sets this.
142 # TRUE if we've seen AC_PROG_RANLIB.
145 # TRUE if we've seen AC_ARG_PROGRAM.
148 # TRUE if we've seen gm_PROG_LIBTOOL or AC_PROG_LIBTOOL.
152 # TRUE if we've seen jm_MAINTAINER_MODE.
153 $seen_maint_mode = 0;
155 # TRUE if we've seen PACKAGE and VERSION.
160 # Charsets used by maintainer and in distribution. MAINT_CHARSET is
161 # handled in a funny way: if seen in the top-level Makefile.am, it is
162 # used for every directory which does not specify a different value.
163 # The rationale here is that some directories (eg gettext) might be
164 # distributions of other packages, and thus require their own charset
165 # info. However, the DIST_CHARSET must be the same for the entire
166 # package; it can only be set at top-level.
167 # FIXME this yields bugs when rebuilding. What to do? Always
168 # read (and sometimes discard) top-level Makefile.am?
170 $dist_charset = 'utf8'; # recode doesn't support this yet.
172 # Name of input file ("Makefile.in") and output file ("Makefile.am").
173 # These have no directory components.
179 &initialize_global_constants;
181 # Parse command line.
182 &parse_arguments (@ARGV);
184 # Do configure.in scan only once.
187 die "automake: no \`Makefile.am' found or specified\n"
190 # Now do all the work on each file.
191 foreach $am_file (@input_files)
193 # FIXME should support the AC_OUTPUT ":" syntax here.
194 if (! -f ($am_file . '.am'))
196 &am_error ('no such file');
200 &generate_makefile ($am_file);
204 if ($seen_prog_install <= $scripts_installed)
206 &am_conf_error (($scripts_installed ? 'fp_PROG_INSTALL' : 'AC_PROG_INSTALL')
207 . " must be used in configure.in");
208 &keyed_aclocal_warning ('fp_PROG_INSTALL')
209 if $scripts_installed;
215 ################################################################
217 # Parse command line.
220 local (@arglist) = @_;
223 &set_strictness ('gnu');
227 if ($arglist[0] eq "--version")
229 print "Automake version $VERSION\n";
232 elsif ($arglist[0] eq "--help")
236 elsif ($arglist[0] =~ /^--amdir=(.+)$/)
240 elsif ($arglist[0] eq '--amdir')
242 &require_argument (@arglist);
244 $am_dir = $arglist[0];
246 elsif ($arglist[0] =~ /^--strictness=(.+)$/)
248 &set_strictness ($1);
250 elsif ($arglist[0] eq '--gnu')
252 &set_strictness ('gnu');
254 elsif ($arglist[0] eq '--gnits')
256 &set_strictness ('gnits');
258 elsif ($arglist[0] eq '--foreign')
260 &set_strictness ('foreign');
262 elsif ($arglist[0] eq '--strictness' || $arglist[0] eq '-s')
264 &require_argument (@arglist);
266 &set_strictness ($arglist[0]);
268 elsif ($arglist[0] eq '--include-deps' || $arglist[0] eq '-i')
270 $cmdline_use_dependencies = 0;
272 elsif ($arglist[0] =~ /^--output-dir=(.*)$/)
274 # Set output directory.
275 $output_directory = $1;
277 elsif ($arglist[0] eq '--output-dir' || $arglist[0] eq '-o')
279 &require_argument (@arglist);
281 $output_directory = $arglist[0];
283 elsif ($arglist[0] eq '--add-missing' || $arglist[0] eq '-a')
287 elsif ($arglist[0] eq '--verbose' || $arglist[0] eq '-v')
291 elsif ($arglist[0] eq '--')
293 # Stop option processing.
295 push (@input_files, @arglist);
298 elsif ($arglist[0] =~ /^-/)
300 die "automake: unrecognized option -- \`$arglist[0]'\n";
304 push (@input_files, $arglist[0]);
310 # Take global strictness from whatever we currently have set.
311 $default_strictness = $strictness;
312 $default_strictness_name = $strictness_name;
315 # Ensure argument exists, or die.
318 local ($arg, @arglist) = @_;
319 die "automake: no argument given for option \`$arg'\n"
323 ################################################################
325 # Generate a Makefile.in given the name of the corresponding Makefile.
326 sub generate_makefile
328 local ($makefile) = @_;
330 ($am_file_name = $makefile) =~ s/^.*\///;
331 $in_file_name = $am_file_name . '.in';
332 $am_file_name .= '.am';
334 print "automake: creating ", $makefile, ".in\n" if $verbose;
336 &initialize_per_input;
337 $relative_dir = &dirname ($makefile);
339 # At the toplevel directory, we might need config.guess, config.sub
341 if ($relative_dir eq '.')
343 # libtool requires some files.
344 &require_conf_file_with_conf_line ($libtool_line, $FOREIGN,
345 'config.sub', 'config.guess',
346 'libtool') if $seen_libtool;
348 # AC_CANONICAL_HOST and AC_CANONICAL_SYSTEM need config.guess and
350 &require_config_file ($FOREIGN, 'config.guess', 'config.sub')
354 # We still need Makefile.in here, because sometimes the `dist'
355 # target doesn't re-run automake.
356 &push_dist_common ($in_file_name, $am_file_name);
357 push (@sources, '$(SOURCES)')
358 if &variable_defined ('SOURCES');
359 push (@objects, '$(OBJECTS)')
360 if &variable_defined ('OBJECTS');
362 # This is always the default target. This gives us freedom to do
363 # things in whatever order is convenient.
364 $output_rules .= "default: all\n\n";
365 push (@phony, 'default');
367 &read_am_file ($makefile . '.am');
370 # Check first, because we might modify some state.
371 &check_gnu_standards;
372 &check_gnits_standards;
380 # Re-init SOURCES and OBJECTS. FIXME other code shouldn't depend
381 # on this (but currently does).
382 $contents{'SOURCES'} = join (' ', @sources);
383 $contents{'OBJECTS'} = join (' ', @objects);
392 &handle_dependencies;
395 &handle_merge_targets;
400 if (! -d ($output_directory . '/' . $relative_dir))
402 &mkdir ($output_directory . '/' . $relative_dir);
404 if (! open (GM_FILE, "> " . $output_directory . '/' . $makefile . ".in"))
406 warn "automake: ${am_file}.in: cannot open: $!\n";
411 print GM_FILE $output_vars;
412 print GM_FILE $output_rules;
413 print GM_FILE $output_trailer;
418 ################################################################
420 # Handle AUTOMAKE_OPTIONS variable.
423 return if ! &variable_defined ('AUTOMAKE_OPTIONS');
425 foreach (split (' ', $contents{'AUTOMAKE_OPTIONS'}))
428 if ($_ eq 'gnits' || $_ eq 'gnu' || $_ eq 'foreign')
430 &set_strictness ($_);
432 elsif ($_ eq 'no-installman' || $_ eq 'ansi2knr'
433 || $_ eq 'dist-shar' || $_ eq 'dist-zip'
436 # Explicitly recognize these.
438 elsif ($_ eq 'no-dependencies')
440 $use_dependencies = 0;
442 elsif (/[0-9]+\.?[0-9]+/)
444 # Got a version number. Is the syntax too strict?
445 local ($num_version);
446 ($num_version = $VERSION) =~ tr/0-9//d;
449 &am_line_error ('AUTOMAKE_OPTIONS',
450 "require version $_, only have $VERSION");
456 &am_line_error ('AUTOMAKE_OPTIONS',
457 'option ', $_, 'not recognized');
462 # Return object extension. Just once, put some code into the output.
463 sub get_object_extension
465 if (! $dir_holds_sources)
469 if (&variable_defined ('CONFIG_HEADER'))
471 ($xform = &dirname ($contents{'CONFIG_HEADER'}))
473 $xform = '-I' . $xform;
475 $xform = 's/\@CONFIG_INCLUDE_SPEC\@/' . $xform . '/go';
476 $output_vars .= &file_contents_with_transform ($xform,
478 $output_rules .= &file_contents ('compile');
479 &push_phony_cleaners ('compile');
481 # If using X, include some extra variable definitions. NOTE
482 # we don't want to force these into CFLAGS or anything,
483 # because not all programs will necessarily use X.
486 $output_vars .= ("X_CFLAGS = \@X_CFLAGS\@\n"
487 . "X_LIBS = \@X_LIBS\@\n"
488 . "X_EXTRA_LIBS = \@X_EXTRA_LIBS\@\n"
489 . "X_PRE_LIBS = \@X_PRE_LIBS\@\n");
492 # Check for automatic de-ANSI-fication.
493 $dir_holds_sources = '.o';
494 push (@suffixes, '.c', '.o');
495 push (@clean, 'compile');
497 if (defined $options{'ansi2knr'})
499 if (! $fp_c_prototypes)
501 &am_line_error ('AUTOMAKE_OPTIONS',
502 "option \`ansi2knr' in use but \`fp_C_PROTOTYPES' not in configure.in");
503 &keyed_aclocal_warning ('fp_C_PROTOTYPES');
504 # Only give this error once.
505 $fp_c_prototypes = 1;
508 $dir_holds_sources = '$o';
509 push (@suffixes, '._c', '._o');
511 &require_file_with_line ('AUTOMAKE_OPTIONS', $FOREIGN,
512 'ansi2knr.c', 'ansi2knr.1');
514 $output_vars .= &file_contents ('kr-vars');
515 $output_rules .= &file_contents ('compile-kr');
516 $output_rules .= &file_contents ('clean-kr');
519 &push_phony_cleaners ('kr');
522 return $dir_holds_sources;
525 # Handle SOURCE->OBJECT transform for one program or library.
526 sub handle_source_transform
528 # one_file is canonical name. unxformed is given name. obj is
530 local ($one_file, $unxformed, $obj) = @_;
531 local ($objpat) = $obj;
532 $objpat =~ s/(\W)/\\$1/g;
534 if (&variable_defined ($one_file . "_OBJECTS"))
536 &am_line_error ($one_file . '_OBJECTS',
537 $one_file . '_OBJECTS', 'should not be defined');
538 # No point in continuing.
542 local ($source_list);
544 foreach $prefix ('', 'EXTRA_')
547 if (&variable_defined ($prefix . $one_file . "_SOURCES"))
549 push (@sources, '$(' . $prefix . $one_file . "_SOURCES)");
550 push (@objects, '$(' . $prefix . $one_file . "_OBJECTS)")
551 unless $prefix eq 'EXTRA_';
552 $source_list = $contents{$prefix . $one_file . "_SOURCES"};
554 elsif ($prefix eq '')
556 $output_vars .= $one_file . "_SOURCES = " . $unxformed . ".c\n";
557 push (@sources, $unxformed . '.c');
558 push (@objects, $unxformed . $obj);
559 $source_list = $unxformed . ".c ";
563 $output_vars .= "EXTRA_" . $one_file . "_SOURCES =\n";
568 # Turn sources into objects.
569 local (@files) = split (' ', $source_list);
570 local (@result) = ();
573 # Skip header files, including C++-ish ones.
576 # Skip things that look like macro references.
577 next if /^\$\(.*\)$/;
578 next if /^\$\{.*\}$/;
579 # Skip things that look like configure substitutions.
584 # Automatically include generated .c file in
586 &push_dist_common ($1 . '.c');
589 # Transform source files into .o files.
592 s/\.[cCmylfs]$/$obj/g;
594 unless $prefix eq 'EXTRA_';
596 # Transform .o or $o file into .P file (for automatic
599 $dep_files{'$(srcdir)/.deps/' . $_} = 1;
602 &pretty_print ($one_file . "_OBJECTS =", "", @result)
603 unless $prefix eq 'EXTRA_';
607 if (&variable_defined ('CONFIG_HEADER'))
609 $output_rules .= ('$(' . $one_file . "_OBJECTS): "
610 . $contents{'CONFIG_HEADER'} . "\n");
616 # Special-case @ALLOCA@ and @LIBOBJS@ in _LDADD or _LIBADD variables.
617 sub handle_lib_objects
621 die "programming error in handle_lib_objects"
622 if ! &variable_defined ($var);
624 # We recognize certain things that are commonly put in LIBADD or
628 foreach $lsearch (split (' ', $contents{$var}))
630 # Automatically handle @LIBOBJS@ and @ALLOCA@. Basically this
631 # means adding entries to dep_files.
632 if ($lsearch eq '@LIBOBJS@')
634 local ($iter, $rewrite);
635 foreach $iter (keys %libsources)
637 if ($iter ne 'alloca.c')
639 ($rewrite = $iter) =~ s/\.c$/.P/;
640 $dep_files{'$(srcdir)/.deps/' . $rewrite} = 1;
641 &require_file_with_line ($var, $FOREIGN, $iter);
645 elsif ($lsearch eq '@ALLOCA@')
647 &am_line_error ($var,
648 "\@ALLOCA\@ seen but \`AC_FUNC_ALLOCA' not in \`configure.in'")
649 if ! defined $libsources{'alloca.c'};
650 $dep_files{'$(srcdir)/.deps/alloca.P'} = 1;
651 &require_file_with_line ($var, $FOREIGN, 'alloca.c');
659 local (@proglist) = &am_install_var ('-clean',
660 'programs', 'PROGRAMS',
661 'bin', 'sbin', 'libexec', 'pkglib',
663 return if ! @proglist;
665 # If a program is installed, this is required. We only want this
666 # error to appear once.
667 &am_conf_error ("AC_ARG_PROGRAM must be used in configure.in")
668 unless $seen_arg_prog;
671 local ($obj) = &get_object_extension;
672 local ($one_file, $xname, $munge);
674 foreach $one_file (@proglist)
676 # Canonicalize names.
677 ($xname = $one_file) =~ tr/A-Za-z0-9_/_/c;
678 if ($xname ne $one_file)
681 foreach $xt ('_LDADD', '_SOURCES', '_OBJECTS', '_DEPENDENCIES')
683 &am_line_error ($one_file . $xt,
684 "invalid variable \`" . $one_file . $xt
685 . "'; should be \`" . $xname . $xt . "'")
686 if &variable_defined ($one_file . $xt);
690 &handle_source_transform ($xname, $one_file, $obj);
692 if (&variable_defined ($xname . "_LDADD"))
694 &handle_lib_objects ($xname . '_LDADD');
698 # User didn't define prog_LDADD override. So do it.
699 $output_vars .= $xname . '_LDADD = $(LDADD)' . "\n";
703 &file_contents_with_transform
704 ('s/\@PROGRAM\@/' . $one_file . '/go;'
705 . 's/\@XPROGRAM\@/' . $xname . '/go;',
709 &handle_lib_objects ('LDADD')
710 if &variable_defined ('LDADD');
716 local (@liblist) = &am_install_var ('-no-all', '-clean',
717 'libraries', 'LIBRARIES',
718 'lib', 'pkglib', 'noinst', 'check');
719 return if ! @liblist;
723 # FIXME need am_line_error here. But we don't know which
724 # variable exists. Must add a loop... No. Must have
725 # am_install_var return a hash. Otherwise the user could add
726 # install directories that we'd never find.
727 &am_error ("library requires either \`AC_PROG_RANLIB' or `gm_PROG_LIBTOOL' in configure.in");
728 # Only get this error once.
732 # Generate _LIBFILES variables. Too bad we can't do this in
734 local ($onedir, $onelib);
736 foreach $onedir ('lib', 'pkglib', 'noinst', 'check')
738 if (&variable_defined ($onedir . '_LIBRARIES'))
741 foreach $onelib (split (' ', $contents{$onedir . '_LIBRARIES'}))
743 push (@outlist, 'lib' . $onelib . '.a');
745 &pretty_print ($onedir . '_LIBFILES =', "", @outlist);
748 push (@all, '$(LIBFILES)');
750 local ($obj) = &get_object_extension;
752 foreach $onelib (@liblist)
754 if (&variable_defined ($onelib . '_LIBADD'))
756 &handle_lib_objects ($onelib . '_LIBADD');
760 # Generate support for conditional object inclusion in
762 $output_vars .= $onelib . "_LIBADD =\n";
765 &handle_source_transform ($onelib, $onelib, $obj);
768 &file_contents_with_transform ('s/\@LIBRARY\@/' . $onelib . '/go',
772 # Turn "foo" into "libfoo.a" and include macro definition.
773 grep (($_ = 'lib' . $_ . '.a') && 0, @liblist);
775 if (! &variable_defined ('LIBFILES'))
777 &pretty_print ('LIBFILES = ', "", @liblist);
782 $output_vars .= ('AR = $(LIBTOOL) archive' . "\n"
783 . 'RANLIB = $(LIBTOOL) ranlib' . "\n"
784 . 'LCOMPILE = $(LIBTOOL) compile $(DEFS) $(INCLUDES)'
785 . ' $(CPPFLAGS) $(CFLAGS)' . "\n");
789 $output_vars .= ('AR = ar' . "\n"
790 . 'RANLIB = @RANLIB@' . "\n");
797 # NOTE we no longer automatically clean SCRIPTS, because it is
798 # useful to sometimes distribute scripts verbatim. This happens
799 # eg in Automake itself.
801 $msi = &am_install_var ('scripts', 'SCRIPTS',
802 'bin', 'sbin', 'libexec', 'pkgdata',
805 # We really only want a boolean value.
806 $scripts_installed = 1 if $msi;
808 if ($scripts_installed)
810 # If a program is installed, this is required. We only want this
811 # error to appear once.
812 &am_conf_error ("AC_ARG_PROGRAM must be used in configure.in")
813 unless $seen_arg_prog;
818 # Search a file for a "version.texi" Texinfo include. Return the name
819 # of the include file if found, or the empty string if not. A
820 # "version.texi" file is actually any file whose name matches
822 sub grep_for_vers_texi
824 local ($filename) = @_;
826 if (! open (TEXI, $filename))
828 &am_error ("couldn't open \`$filename': $!");
831 print "automake: reading $filename\n" if $verbose;
835 if (/^\@include\s+(vers[^.]*\.texi)\s*$/)
847 # Handle all Texinfo source.
850 &am_line_error ('TEXINFOS',
851 "\`TEXINFOS' is an anachronism; use \`info_TEXINFOS'")
852 if &variable_defined ('TEXINFOS');
853 return if (! &variable_defined ('info_TEXINFOS')
854 && ! &variable_defined ('html_TEXINFOS'));
856 local (@texis) = split (' ', $contents{'info_TEXINFOS'});
858 local (@infos_list, @info_deps_list, @dvis_list, @texi_deps);
859 local ($infobase, $info_cursor);
863 local ($tc_cursor, @texi_cleans);
866 foreach $info_cursor (@texis)
868 ($infobase = $info_cursor) =~ s/\.texi$//;
870 # If 'version.texi' is referenced by input file, then include
871 # automatic versioning capability.
873 = &grep_for_vers_texi ($relative_dir . "/" . $info_cursor);
876 &am_error ("\`$vtexi', included in \`$info_cursor', also included in \`$versions{$vtexi}'")
877 if (defined $versions{$vtexi});
878 $versions{$vtexi} = $info_cursor;
880 # We number the stamp-vti files. This is doable since the
881 # actual names don't matter much. We only number starting
882 # with the second one, so that the common case looks nice.
883 $vti = 'vti' . ($done ? $done : '');
884 &push_dist_common ($vtexi, 'stamp-' . $vti);
888 &require_conf_file_with_line ('info_TEXINFOS', $FOREIGN,
894 ($conf_pat = $config_aux_dir) =~ s/(\W)/\\$1/g;
896 &file_contents_with_transform
897 ('s/\@TEXI\@/' . $info_cursor . '/g; '
898 . 's/\@VTI\@/' . $vti . '/g; '
899 . 's/\@VTEXI\@/' . $vtexi . '/g;'
900 . 's,\@MDDIR\@,' . $conf_pat . ',g;',
903 &push_phony_cleaners ($vti);
906 # If user specified file_TEXINFOS, then use that as explicit
909 push (@texi_deps, $info_cursor);
910 push (@texi_deps, $vtexi) if $vtexi;
912 # Canonicalize name first.
913 ($canonical = $infobase) =~ tr/A-Za-z0-9_/_/c;
914 if (&variable_defined ($canonical . "_TEXINFOS"))
916 push (@texi_deps, '$(' . $canonical . '_TEXINFOS)');
917 &push_dist_common ('$(' . $canonical . '_TEXINFOS)');
920 $output_rules .= ("\n" . $infobase . ".info: "
921 . join (' ', @texi_deps) . "\n\n");
923 push (@infos_list, $infobase . '.info*');
924 push (@info_deps_list, $infobase . '.info');
925 push (@dvis_list, $infobase . '.dvi');
927 # Generate list of things to clean for this target. We do
928 # this explicitly because otherwise too many things could be
929 # removed. In particular the ".log" extension might
930 # reasonably be used in other contexts by the user.
931 foreach $tc_cursor ('aux', 'cp', 'cps', 'dvi', 'fn', 'fns',
932 'ky', 'log', 'pg', 'toc', 'tp', 'vr', 'op')
934 push (@texi_cleans, $infobase . '.' . $tc_cursor);
939 $output_vars .= &file_contents ('texinfos-vars');
940 $output_rules .= &file_contents ('texinfos');
941 push (@phony, 'install-info', 'uninstall-info');
944 $output_rules .= "\nmostlyclean-info:\n";
945 &pretty_print_rule ("\trm -f", "\t ", @texi_cleans);
946 $output_rules .= ("\nclean-info:\n\ndistclean-info:\n\n"
947 . "maintainer-clean-info:\n\t"
948 . 'rm -f $(INFOS)' . "\n");
949 &push_phony_cleaners ('info');
951 push (@suffixes, '.texi', '.info', '.dvi');
952 push (@uninstall, 'uninstall-info');
953 push (@clean, 'info');
954 push (@info, '$(INFO_DEPS)');
955 push (@dvi, '$(DVIS)');
956 push (@installdirs, '$(infodir)');
957 unshift (@install_data, 'install-info');
959 # Make sure documentation is made and installed first. Use
960 # $(INFO_DEPS), not 'info', because otherwise recursive makes get
961 # run twice during "make all".
962 unshift (@all, '$(INFO_DEPS)');
964 $output_vars .= ("INFOS = " . join (' ', @infos_list) . "\n"
965 . "INFO_DEPS = " . join (' ', @info_deps_list) . "\n"
966 . "DVIS = " . join (' ', @dvis_list) . "\n"
967 # This next isn't strictly needed now -- the
968 # places that look here could easily be changed
969 # to look in info_TEXINFOS. But this is probably
970 # better, in case noinst_TEXINFOS is ever
972 . "TEXINFOS = " . $contents{'info_TEXINFOS'} . "\n\n");
974 # Do some error checking.
975 &require_file_with_line ('info_TEXINFOS', $FOREIGN, 'texinfo.tex');
978 # Handle any man pages.
981 &am_line_error ('MANS', "\`MANS' is an anachronism; use \`man_MANS'")
982 if &variable_defined ('MANS');
983 return if ! &variable_defined ('man_MANS');
985 # We generate the manpage install code by hand to avoid the use of
986 # basename in the generated Makefile.
987 local (@mans) = split (' ', $contents{'man_MANS'});
988 local (%sections, %inames, %secmap, %fullsecmap);
991 # FIXME: statement without effect:
992 /^(.*)\.([0-9])([a-z]*)$/;
996 $fullsecmap{$1} = $2 . $3;
999 # We don't really need this, but we use it in case we ever want to
1000 # support noinst_MANS.
1001 $output_vars .= "MANS = " . $contents{'man_MANS'} . "\n";
1003 # Generate list of install dirs.
1004 $output_rules .= "install-man: \$(MANS)\n";
1005 foreach (keys %sections)
1007 push (@installdirs, '$(mandir)/man' . $_);
1008 $output_rules .= ("\t" . '$(mkinstalldirs) $(mandir)/man'
1011 push (@phony, 'install-man');
1013 # Generate install target.
1015 foreach $key (keys %inames)
1017 $_ = $install_man_format;
1018 s/\@SECTION\@/$secmap{$key}/g;
1019 s/\@MAN\@/$inames{$key}/g;
1020 s/\@FULLSECT\@/$fullsecmap{$key}/g;
1021 s/\@MANBASE\@/$key/g;
1022 $output_rules .= $_;
1024 $output_rules .= "\n";
1026 $output_rules .= "uninstall-man:\n";
1027 foreach $key (keys %inames)
1029 $_ = $uninstall_man_format;
1030 s/\@SECTION\@/$secmap{$key}/g;
1031 s/\@MAN\@/$inames{$key}/g;
1032 s/\@FULLSECT\@/$fullsecmap{$key}/g;
1033 s/\@MANBASE\@/$key/g;
1034 $output_rules .= $_;
1036 $output_rules .= "\n";
1037 push (@phony, 'uninstall-man');
1039 $output_vars .= &file_contents ('mans-vars');
1041 if (! defined $options{'no-installman'})
1043 push (@install_data, 'install-man');
1044 push (@uninstall, 'uninstall-man');
1045 push (@all, '$(MANS)');
1049 # Handle DATA variables.
1052 &am_install_var ('data', 'DATA', 'data', 'sysconf',
1053 'sharedstate', 'localstate', 'pkgdata',
1060 local ($tagging) = 0;
1062 push (@phony, 'tags');
1063 if (&variable_defined ('SUBDIRS'))
1065 $output_rules .= &file_contents ('tags');
1066 push (@phony, 'tags-recursive');
1069 elsif ($dir_holds_sources || &variable_defined ('ETAGS_ARGS'))
1071 $output_rules .= &file_contents ('tags-subd');
1077 $output_rules .= &file_contents ('tags-clean');
1078 push (@clean, 'tags');
1079 &push_phony_cleaners ('tags');
1083 # Every Makefile must define some sort of TAGS rule.
1084 # Otherwise, it would be possible for a top-level "make TAGS"
1085 # to fail because some subdirectory failed.
1086 $output_rules .= "tags: TAGS\nTAGS:\n\n";
1090 # Worker for handle_dist.
1091 sub handle_dist_worker
1093 $output_rules .= 'distdir: $(DEP_DISTFILES)' . "\n";
1095 # Initialization; only at top level.
1096 if ($relative_dir eq '.')
1098 if ($strictness >= $GNITS)
1100 # For Gnits users, this is pretty handy. Look at 15 lines
1101 # in case some explanatory text is desirable.
1102 $output_rules .= ' @if sed 15q $(srcdir)/NEWS | grep -e "$(VERSION)" > /dev/null; then :; else \\
1103 echo "NEWS not updated; not releasing" 1>&2; \\
1111 # Create dist directory.
1114 chmod 777 $(distdir)
1117 # Only run automake in `dist' target if --include-deps not
1118 # specified. That way the recipient of a distribution can run
1119 # "make dist" and not need Automake.
1120 if ($cmdline_use_dependencies)
1124 # We need an absolute path for --output-dir. Thus the
1126 ' distdir=`cd $(distdir) && pwd` \\
1128 && automake --include-deps --output-dir=$$distdir --strictness='
1129 # Set strictness of output.
1130 . $strictness_name . "\n"
1135 # In loop, test for file existence because sometimes a file gets
1136 # included in DISTFILES twice. For example this happens when a
1137 # single source file is used in building more than one program.
1138 # Also, there are situations in which "ln" can fail. For instance
1139 # a file to distribute could actually be a cross-filesystem
1140 # symlink -- this can easily happen if "gettextize" was run on the
1141 # distribution. Note that DISTFILES can contain a wildcard (for
1142 # info files, sigh), so we must use the echo trick.
1143 $output_rules .= ' @for file in `cd $(srcdir) && echo $(DISTFILES)`; do \\
1144 test -f $(distdir)/$$file \\
1145 || ln $(srcdir)/$$file $(distdir)/$$file 2> /dev/null \\
1146 || cp -p $(srcdir)/$$file $(distdir)/$$file; \\
1150 # If we have SUBDIRS, create all dist subdirectories and do
1152 if (&variable_defined ('SUBDIRS'))
1154 # Test for directory existence here because previous automake
1155 # invocation might have created some directories. Note that
1156 # we explicitly set distdir for the subdir make; that lets us
1157 # mix-n-match many automake-using packages into one large
1158 # package, and have "dist" at the top level do the right
1160 $output_rules .= ' for subdir in $(SUBDIRS); do \\
1161 test -d $(distdir)/$$subdir \\
1162 || mkdir $(distdir)/$$subdir \\
1164 chmod 777 $(distdir)/$$subdir; \\
1165 (cd $$subdir && $(MAKE) distdir=../$(distdir)/$$subdir distdir) \\
1171 # If the target `dist-hook' exists, run it now. This allows
1172 # users to do random weird things to the distribution before it is
1174 if (defined $contents{'dist-hook'})
1176 $output_rules .= "\t\$(MAKE) dist-hook\n";
1179 push (@phony, 'distdir');
1182 # Handle 'dist' target.
1185 # Set up maint_charset.
1186 $local_maint_charset = $contents{'MAINT_CHARSET'}
1187 if &variable_defined ('MAINT_CHARSET');
1188 $maint_charset = $local_maint_charset
1189 if $relative_dir eq '.';
1191 if (&variable_defined ('DIST_CHARSET'))
1193 &am_line_error ('DIST_CHARSET',
1194 "DIST_CHARSET defined but no MAINT_CHARSET defined")
1195 if ! $local_maint_charset;
1196 if ($relative_dir eq '.')
1198 $dist_charset = $contents{'DIST_CHARSET'}
1202 &am_line_error ('DIST_CHARSET',
1203 "DIST_CHARSET can only be defined at top level");
1207 # Look for common files that should be included in distribution.
1209 foreach $cfile (@common_files)
1211 if (-f ($relative_dir . "/" . $cfile))
1213 &push_dist_common ($cfile);
1217 # Keys of %dist_common are names of files to distributed. We put
1218 # README first because it then becomes easier to make a
1219 # Usenet-compliant shar file (in these, README must be first).
1220 # FIXME do more ordering of files here.
1222 if (defined $dist_common{'README'})
1224 push (@coms, 'README');
1225 undef $dist_common{'README'};
1227 push (@coms, sort keys %dist_common);
1229 &pretty_print ("DIST_COMMON =", "", @coms);
1230 $output_vars .= "\n";
1233 $output_vars .= &file_contents ('dist-vars');
1235 # Put these things in rules section so it is easier for whoever
1236 # reads Makefile.in.
1237 if ($relative_dir eq '.')
1239 $output_rules .= "\n" . 'distdir = $(PACKAGE)-$(VERSION)' . "\n";
1243 $output_rules .= ("\nsubdir = " . $relative_dir . "\n"
1244 . 'distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)'
1248 # Generate 'dist' target, and maybe dist-shar / dist-zip.
1249 if ($relative_dir eq '.')
1251 # Rule to check whether a distribution is viable.
1252 $output_rules .= '# This target untars the dist file and tries a VPATH configuration. Then
1253 # it guarantees that the distribution is self-contained by making another
1257 $(TAR) zxf $(distdir).tar.gz
1258 mkdir $(distdir)/=build
1259 mkdir $(distdir)/=inst
1260 dc_install_base=`cd $(distdir)/=inst && pwd`; \\
1261 cd $(distdir)/=build \\
1262 && ../configure --srcdir=.. --prefix=$$dc_install_base \\
1265 && $(MAKE) install \\
1266 && $(MAKE) installcheck \\
1269 @echo "========================"; \\
1270 echo "$(distdir).tar.gz is ready for distribution"; \\
1271 echo "========================"
1274 $output_rules .= 'dist: distdir' . "\n\t";
1275 $output_rules .= 'chmod -R a+r $(distdir)' . "\n\t";
1276 $output_rules .= '$(TAR) chozf $(distdir).tar.gz $(distdir)';
1277 $output_rules .= "\n\t" . 'rm -rf $(distdir)' . "\n";
1279 if (defined $options{'dist-shar'})
1281 $output_rules .= 'dist-shar: distdir' . "\n\t";
1282 $output_rules .= 'chmod -R a+r $(distdir)' . "\n\t";
1283 $output_rules .= 'shar $(distdir) | gzip > $(distdir).shar.gz';
1284 $output_rules .= "\n\t" . 'rm -rf $(distdir)' . "\n";
1287 if (defined $options{'dist-zip'})
1289 $output_rules .= 'dist-zip: distdir' . "\n\t";
1290 $output_rules .= 'chmod -R a+r $(distdir)' . "\n\t";
1291 $output_rules .= 'zip -rq $(distdir).zip $(distdir)';
1292 $output_rules .= "\n\t" . 'rm -rf $(distdir)' . "\n";
1296 # Generate distdir target.
1297 &handle_dist_worker;
1300 # Handle auto-dependency code.
1301 sub handle_dependencies
1303 if ($use_dependencies)
1305 # Include GNU-make-specific auto-dep code.
1306 if ($dir_holds_sources)
1308 &pretty_print ('DEP_FILES =', "", sort keys %dep_files);
1309 $output_rules .= &file_contents ('depend');
1314 # Include any auto-generated deps that are present.
1315 if (-d ($relative_dir . "/.deps") && -f ($relative_dir . "/.deps/.P"))
1318 local ($gpat) = $relative_dir . "/.deps/*.P";
1320 foreach $depfile (<${gpat}>)
1322 if (! open (DEP_FILE, $depfile))
1324 &am_error ("couldn't open \`$depfile': $!");
1327 print "automake: reading $depfile\n" if $verbose;
1329 # Slurp entire file.
1330 $output_rules .= join ('', <DEP_FILE>);
1335 $output_rules .= "\n";
1340 # Handle subdirectories.
1343 if (! &variable_defined ('SUBDIRS'))
1346 ("ud_GNU_GETTEXT in configure.in but SUBDIRS not defined")
1347 if $seen_gettext && $relative_dir eq '.';
1351 &require_file_with_conf_line ($ac_gettext_line, $FOREIGN, 'ABOUT-NLS')
1354 return if ! &variable_defined ('SUBDIRS');
1356 # Make sure each directory mentioned in SUBDIRS actually exists.
1358 foreach $dir (split (' ', $contents{'SUBDIRS'}))
1360 # Skip directories substituted by configure.
1361 next if $dir =~ /^\@.*\@$/;
1362 &am_line_error ('SUBDIRS',
1363 "required directory $relative_dir/$dir does not exist")
1364 if ! -d $relative_dir . '/' . $dir;
1367 $output_rules .= &file_contents ('subdirs');
1369 # Push a bunch of phony targets.
1371 foreach $phonies ('-data', '-exec', 'dirs')
1373 push (@phony, 'install' . $phonies . '-recursive');
1374 push (@phony, 'uninstall' . $phonies . '-recursive');
1376 foreach $phonies ('all', 'check', 'installcheck', 'info', 'dvi')
1378 push (@phony, $phonies . '-recursive');
1380 &push_phony_cleaners ('recursive');
1382 push (@check, "check-recursive");
1383 push (@installcheck, "installcheck-recursive");
1384 push (@info, "info-recursive");
1385 push (@dvi, "dvi-recursive");
1387 $recursive_install = 1;
1390 # Handle remaking and configure stuff.
1391 sub handle_configure
1393 # If SUBDIRS defined, require AC_PROG_MAKE_SET.
1394 &am_line_error ('SUBDIRS', "AC_PROG_MAKE_SET must be used in configure.in")
1395 if &variable_defined ('SUBDIRS') && ! $seen_make_set;
1397 local ($top_reldir);
1398 if ($relative_dir ne '.')
1401 $output_rules .= &file_contents ('remake-subd');
1402 $top_reldir = '../';
1406 if (-f 'aclocal.m4')
1408 $output_vars .= "ACLOCAL = aclocal.m4\n";
1409 &push_dist_common ('aclocal.m4');
1411 $output_rules .= &file_contents ('remake');
1414 ("\`install.sh' is an anachronism; use \`install-sh' instead")
1415 if -f $relative_dir . '/install.sh';
1417 # If we have a configure header, require it.
1420 # FIXME this restriction should be lifted.
1421 # FIXME first see if it is even needed as-is.
1422 &am_conf_line_error ($config_header_line,
1423 "argument to AC_CONFIG_HEADER contains \`/'\n")
1424 if ($config_header =~ /\//);
1426 &require_file_with_conf_line ($config_header_line,
1427 $FOREIGN, $config_header);
1429 # Header defined and in this directory.
1430 if (-f 'acconfig.h')
1432 $output_vars .= "ACCONFIG = acconfig.h\n";
1433 &push_dist_common ('acconfig.h');
1435 if (-f $config_name . '.top')
1437 $output_vars .= "CONFIG_TOP = ${config_name}.top\n";
1438 &push_dist_common ($config_name . '.top');
1440 if (-f $config_name . '.bot')
1442 $output_vars .= "CONFIG_BOT = ${config_name}.bot\n";
1443 &push_dist_common ($config_name . '.bot');
1446 &require_file_with_conf_line ($config_header_line, $FOREIGN,
1449 $output_rules .= &file_contents ('remake-hdr');
1450 $output_vars .= "CONFIG_HEADER_IN = ${config_header}\n";
1456 # Set location of mkinstalldirs.
1457 if ($config_aux_dir ne '.' && $config_aux_dir ne '')
1459 $output_vars .= 'mkinstalldirs = ' . $config_aux_dir;
1463 $output_vars .= 'mkinstalldirs = $(top_srcdir)';
1465 $output_vars .= '/mkinstalldirs' . "\n";
1467 &am_line_error ('CONFIG_HEADER',
1468 "\`CONFIG_HEADER' is an anachronism; now determined from \`configure.in'")
1469 if &variable_defined ('CONFIG_HEADER');
1471 # Generate CONFIG_HEADER define, and define interally.
1472 $output_vars .= "CONFIG_HEADER = ${top_builddir}/${config_name}\n"
1474 $contents{'CONFIG_HEADER'} = "${top_builddir}/${config_name}"
1477 # Now look for other files in this directory which must be remade
1478 # by config.status, and generate rules for them.
1479 local ($file, $local, $input);
1480 foreach $file (@other_input_files)
1482 # Skip files not in this directory, any Makefile, and the
1483 # config header. These last two must be handled specially.
1484 next unless &dirname ($file) eq $relative_dir;
1485 next if $file eq $top_builddir . '/' . $config_name;
1486 ($local = $file) =~ s/^.*\///;
1487 next if $local eq 'Makefile';
1489 if ($local =~ /^(.*):(.*)$/)
1491 # This is the ":" syntax of AC_OUTPUT.
1498 $input = $local . '.in';
1500 # FIXME when using autoconf ":" syntax, should we set CONFIG_FILES
1502 $output_rules .= ($local . ': '
1503 . '$(top_builddir)/config.status ' . $input . "\n"
1505 . 'cd $(top_builddir) && CONFIG_FILES='
1506 . ($relative_dir eq '.' ? '' : '$(subdir)/')
1507 . '$@ CONFIG_HEADERS= ./config.status'
1510 &require_file_with_conf_line ($ac_output_line, $FOREIGN,
1518 &am_install_var ('header', 'HEADERS', 'include',
1519 'oldinclude', 'pkginclude',
1525 return if ! $seen_gettext || $relative_dir ne '.';
1527 # As of 0.10.6, gettext still wants @INTLSUB@ and @POSUB@ in
1528 # SUBDIRS. This is going to change in a future version. So for
1529 # now we simply do no checking.
1530 if (0 && &variable_defined ('SUBDIRS'))
1534 "ud_GNU_GETTEXT in configure.in but \`po' not in SUBDIRS")
1535 if $contents{'SUBDIRS'} !~ /\bpo\b/;
1538 "ud_GNU_GETTEXT in configure.in but \`intl' not in SUBDIRS")
1539 if $contents{'SUBDIRS'} !~ /\bintl\b/;
1542 # Ensure that each language in ALL_LINGUAS has a .po file, and
1543 # each po file is mentioned in ALL_LINGUAS.
1546 local (%linguas) = ();
1547 grep ($linguas{$_} = 1, split (' ', $all_linguas));
1554 &am_line_error ($all_linguas_line,
1555 ("po/$_.po exists but \`$_' not in \`ALL_LINGUAS'"))
1559 foreach (keys %linguas)
1561 &am_line_error ($all_linguas_line,
1562 "$_ in \`ALL_LINGUAS' but po/$_.po does not exist")
1568 &am_error ("ud_GNU_GETTEXT in configure.in but \`ALL_LINGUAS' not defined");
1572 # Handle footer elements.
1575 if ($contents{'SOURCES'})
1577 &pretty_print ('SOURCES =', "",
1578 split (' ', $contents{'SOURCES'}));
1580 if ($contents{'OBJECTS'})
1582 &pretty_print ('OBJECTS =', "",
1583 split (' ', $contents{'OBJECTS'}));
1585 if ($contents{'SOURCES'} || $contents{'OBJECTS'})
1587 $output_vars .= "\n";
1590 if (defined $contents{'SUFFIXES'})
1592 push (@suffixes, '$(SUFFIXES)');
1595 $output_trailer .= ".SUFFIXES:\n";
1598 $output_trailer .= ".SUFFIXES: " . join (' ', @suffixes) . "\n";
1600 $output_trailer .= &file_contents ('footer');
1603 # Deal with installdirs target.
1604 sub handle_installdirs
1606 # GNU Makefile standards recommend this.
1607 $output_rules .= ("installdirs:"
1608 . ($recursive_install
1609 ? " installdirs-recursive\n"
1611 push (@phony, 'installdirs');
1614 &pretty_print_rule ("\t" . '$(mkinstalldirs) ', "\t\t",
1617 $output_rules .= "\n";
1620 # There are several targets which need to be merged. This is because
1621 # their complete definition is compiled from many parts. Note that we
1622 # avoid double colon rules, otherwise we'd use them instead.
1623 sub handle_merge_targets
1625 push (@all, 'Makefile');
1626 push (@all, $config_name)
1627 if $config_name && &dirname ($config_name) eq $relative_dir;
1629 &do_one_merge_target ('info', @info);
1630 &do_one_merge_target ('dvi', @dvi);
1632 if (! &variable_defined ('SUBDIRS') || $relative_dir ne '.')
1634 # 'check' must depend on 'all', but not at top level.
1636 unshift (@check, 'all');
1637 unshift (@install, 'all');
1639 &do_one_merge_target ('check', @check);
1640 &do_one_merge_target ('installcheck', @installcheck);
1642 # Handle the various install targets specially. We do this so
1643 # that (eg) "make install-exec" will run "install-exec-recursive"
1644 # if required, but "make install" won't run it twice. Step one is
1645 # to see if the user specified local versions of any of the
1646 # targets we handle. "all" is treated as one of these since
1647 # "install" can run it.
1648 push (@install_exec, 'install-exec-local')
1649 if defined $contents{'install-exec-local'};
1650 push (@install_data, 'install-data-local')
1651 if defined $contents{'install-data-local'};
1652 push (@uninstall, 'uninstall-local')
1653 if defined $contents{'uninstall-local'};
1654 push (@all, 'all-local')
1655 if defined $contents{'all-local'};
1657 if (defined $contents{'install-local'})
1659 &am_line_error ('install-local',
1660 "use \`install-data' or \`install-exec', not \`install'");
1663 # Step two: if we are doing recursive makes, write out the
1664 # appropriate rules.
1666 if ($recursive_install)
1668 push (@install, 'install-recursive');
1672 local (@hackall) = ();
1673 if ($config_name && &dirname ($config_name) eq $relative_dir)
1676 # This is kind of a hack, but I couldn't see a better
1677 # way to handle it. In this particular case, we need
1678 # to make sure config.h is built before we recurse.
1679 # We can't do this by changing the order of
1680 # dependencies to the "all" because that breaks when
1681 # using parallel makes. Instead we handle things
1683 $output_rules .= ('all-recursive-hack: $(CONFIG_HEADER)'
1684 . "\n\t" . '$(MAKE) all-recursive'
1686 push (@hackall, 'all-recursive-hack');
1687 push (@phony, 'all-recursive-hack');
1691 push (@hackall, 'all-recursive');
1694 $output_rules .= ('all-am: '
1698 push (@all, 'all-am');
1699 push (@phony, 'all-am');
1703 @all = ('all-recursive');
1707 $output_rules .= ('install-exec-am: '
1708 . join (' ', @install_exec)
1710 @install_exec = ('install-exec-recursive', 'install-exec-am');
1711 push (@install, 'install-exec-am');
1712 push (@phony, 'install-exec-am');
1716 @install_exec = ('install-exec-recursive');
1720 $output_rules .= ('install-data-am: '
1721 . join (' ', @install_data)
1723 @install_data = ('install-data-recursive', 'install-data-am');
1724 push (@install, 'install-data-am');
1725 push (@phony, 'install-data-am');
1729 @install_data = ('install-data-recursive');
1733 $output_rules .= ('uninstall-am: '
1734 . join (' ', @uninstall)
1736 @uninstall = ('uninstall-recursive', 'uninstall-am');
1737 push (@phony, 'uninstall-am');
1741 @uninstall = ('uninstall-recursive');
1745 # Step three: print definitions users can use. Code below knows
1746 # that install-exec is done before install-data, beware.
1747 $output_rules .= ("install-exec: "
1748 . join (' ', @install_exec)
1750 if (defined $contents{'install-exec-hook'})
1752 $output_rules .= "\t" . '$(MAKE) install-exec-hook' . "\n";
1754 $output_rules .= "\n";
1755 push (@install, 'install-exec') if !$recursive_install;
1756 push (@phony, 'install-exec');
1758 $output_rules .= ("install-data: "
1759 . join (' ', @install_data)
1761 if (defined $contents{'install-data-hook'})
1763 $output_rules .= "\t" . '$(MAKE) install-data-hook' . "\n";
1765 $output_rules .= "\n";
1766 push (@install, 'install-data') if !$recursive_install;
1767 push (@phony, 'install-data');
1769 # If no dependencies for 'install', add 'all'. Why? That way
1770 # "make install" at top level of distclean'd distribution won't
1771 # fail because stuff in 'lib' fails to build.
1772 if (! @install || ($#install == 1
1773 && $install[0] eq 'install-exec'
1774 && $install[1] eq 'install-data'))
1776 push (@install, 'all');
1778 $output_rules .= ('install: '
1779 . join (' ', @install)
1780 # Use "@:" as empty command so nothing prints.
1784 . join (' ', @uninstall)
1786 push (@phony, 'install', 'uninstall');
1788 $output_rules .= ('all: '
1791 push (@phony, 'all');
1793 # Generate the new 'install-strip' target.
1794 $output_rules .= ("install-strip:\n\t"
1795 . '$(MAKE) INSTALL_PROGRAM=\'$(INSTALL_PROGRAM) -s\' install'
1799 # Helper for handle_merge_targets.
1800 sub do_one_merge_target
1802 local ($name, @values) = @_;
1804 if (defined $contents{$name . '-local'})
1806 # User defined local form of target. So include it.
1807 push (@values, $name . '-local');
1808 push (@phony, $name . '-local');
1811 $output_rules .= $name . ":";
1814 $output_rules .= ' ' . join (' ', @values);
1816 $output_rules .= "\n\n";
1817 push (@phony, $name);
1820 # Handle all 'clean' targets.
1823 push (@clean, 'generic');
1824 $output_rules .= &file_contents ('clean');
1825 &push_phony_cleaners ('generic');
1827 local ($target) = $recursive_install ? 'clean-am' : 'clean';
1828 &do_one_clean_target ($target, 'mostly', '', @clean);
1829 &do_one_clean_target ($target, '', 'mostly', @clean);
1830 &do_one_clean_target ($target, 'dist', '', @clean);
1831 &do_one_clean_target ($target, 'maintainer-', 'dist', @clean);
1833 push (@phony, 'clean', 'mostlyclean', 'distclean', 'maintainer-clean');
1836 if ($recursive_install)
1838 @deps = ('am', 'recursive');
1839 &do_one_clean_target ('', 'mostly', '', @deps);
1840 &do_one_clean_target ('', '', '', @deps);
1841 &do_one_clean_target ('', 'dist', '', @deps);
1842 &do_one_clean_target ('', 'maintainer-', '', @deps);
1846 # Helper for handle_clean.
1847 sub do_one_clean_target
1849 local ($target, $name, $last_name, @deps) = @_;
1851 # Special case: if target not passed, then don't generate
1852 # dependency on next "lower" clean target (eg no
1853 # clean<-mostlyclean derivation). In this case the target is
1854 # implicitly known to be 'clean'.
1855 local ($flag) = $target;
1856 $target = 'clean' if ! $flag;
1858 grep (($_ = $name . 'clean-' . $_) && 0, @deps);
1861 if ($last_name || $name ne 'mostly')
1863 push (@deps, $last_name . $target . " ");
1866 # FIXME not sure if I like the tabs here.
1867 &pretty_print_rule ($name . $target . ": ", "\t\t", @deps);
1869 # FIXME shouldn't we really print these messages before running
1871 if ($name . $target eq 'maintainer-clean')
1873 # Print a special warning.
1875 ("\t\@echo \"This command is intended for maintainers to use;\"\n"
1876 . "\t\@echo \"it deletes files that may require special "
1877 . "tools to rebuild.\"\n");
1879 $output_rules .= "\trm -f config.status\n"
1880 if $relative_dir eq '.';
1882 elsif ($name . $target eq 'distclean')
1884 $output_rules .= "\trm -f config.status\n";
1886 $output_rules .= "\n";
1889 # Handle .PHONY target.
1892 &pretty_print_rule ('.PHONY:', "", @phony);
1893 $output_rules .= "\n";
1896 # Handle TESTS variable and other checks.
1899 if (&variable_defined ('DEJATOOL') && ! defined $options{'dejagnu'})
1902 &am_line_error ('DEJATOOL',
1903 "\`DEJATOOL' defined but \`dejagnu' not in \`AUTOMAKE_OPTIONS'");
1907 if (defined $options{'dejagnu'})
1909 push (@check, 'check-DEJAGNU');
1910 push (@phony, 'check-DEJAGNU');
1911 $output_rules .= &file_contents ('dejagnu') . "\n";
1912 $output_rules .= ("site.exp: Makefile\n"
1913 . "\t\@echo 'Making a new site.exp file...'\n"
1914 . "\t-\@rm -f site.bak\n"
1915 . "\t-\@mv site.exp site.bak\n"
1916 . "\t\@echo '## these variables are automatically generated by make ##' > site.exp\n"
1917 . "\t\@echo '# Do not edit here. If you wish to override these values' >> site.exp\n"
1918 . "\t\@echo '# edit the last section' >> site.exp\n"
1919 . "\t\@echo 'set tool \$(DEJATOOL)' >> site.exp\n"
1920 . "\t\@echo 'set srcdir \$(srcdir)' >> site.exp\n"
1921 . "\t\@echo 'set objdir \`pwd\`' >> site.exp\n");
1923 # Extra stuff for AC_CANONICAL_*
1924 local (@whatlist) = ();
1925 if ($seen_canonical)
1927 push (@whatlist, 'host')
1930 # Extra stuff only for AC_CANONICAL_SYSTEM.
1931 if ($seen_canonical == $AC_CANONICAL_SYSTEM)
1933 push (@whatlist, 'target', 'build');
1937 foreach $c1 (@whatlist)
1939 foreach $c2 ('alias', 'triplet')
1941 $output_rules .= "\t\@echo 'set ${c1}_${c2} \$(${c1}_${c2})' >> site.exp\n";
1945 $output_rules .= ("\t\@echo '## All variables above are generated by configure. Do Not Edit ##' >> site.exp\n"
1946 . "\t-\@sed '1,/^## All variables above are.*##/ d' site.bak >> site.exp\n");
1949 if (&variable_defined ('TESTS'))
1951 push (@check, 'check-TESTS');
1952 push (@phony, 'check-TESTS');
1953 # FIXME use $(SHELL) here? That is what Ulrich suggests.
1954 # Maybe a new macro, $(TEST_SHELL), a la $(CONFIG_SHELL)? For
1955 # now we just execute the file directly; this allows test
1956 # files which are compiled -- a possibly useful feature.
1957 $output_rules .= 'check-TESTS: $(TESTS)
1958 @failed=0; all=0; \\
1959 srcdir=$(srcdir); export srcdir; \\
1960 for tst in $(TESTS); do \\
1961 all=`expr $$all + 1`; \\
1962 if test -f $$tst; then dir=.; \\
1963 else dir="$(srcdir)"; fi; \\
1964 if $$dir/$$tst; then \\
1965 echo "PASS: $$tst"; \\
1967 failed=`expr $$failed + 1`; \\
1968 echo "FAIL: $$tst"; \\
1971 if test "$$failed" -eq 0; then \\
1972 echo "========================"; \\
1973 echo "All $$all tests passed"; \\
1974 echo "========================"; \\
1976 echo "$$failed of $$all tests failed"; \\
1982 ################################################################
1984 # Scan configure.in for interesting things.
1985 # FIXME ensure VERSION, PACKAGE are set.
1988 open (CONFIGURE, 'configure.in')
1989 || die "automake: couldn't open \`configure.in': $!\n";
1990 print "automake: reading configure.in\n" if $verbose;
1992 # Reinitialize libsources here. This isn't really necessary,
1993 # since we currently assume there is only one configure.in. But
1994 # that won't always be the case.
1997 local ($in_ac_output, @make_list) = 0;
1998 local ($libobj_iter);
2001 # Remove comments from current line.
2005 # Populate libobjs array.
2006 if (/AC_FUNC_ALLOCA/)
2008 $libsources{'alloca.c'} = 1;
2010 elsif (/AC_FUNC_GETLOADAVG/)
2012 $libsources{'getloadavg.c'} = 1;
2014 elsif (/AC_FUNC_MEMCMP/)
2016 $libsources{'memcmp.c'} = 1;
2018 elsif (/AC_STRUCT_ST_BLOCKS/)
2020 $libsources{'fileblocks.c'} = 1;
2022 elsif (/(AC|fp)_FUNC_FNMATCH/)
2024 # AC_FUNC_FNMATCH is just wishful thinking at this point.
2025 $libsources{'fnmatch.c'} = 1;
2027 elsif (/AC_REPLACE_FUNCS\s*\((.*)\)/)
2029 foreach (split (' ', $1))
2031 $libsources{$_ . '.c'} = 1;
2034 elsif (/AC_REPLACE_GNU_GETOPT/)
2036 $libsources{'getopt.c'} = 1;
2037 $libsources{'getopt1.c'} = 1;
2039 elsif (/LIBOBJS="(.*)\s+\$LIBOBJS"/
2040 || /LIBOBJS="\$LIBOBJS\s+(.*)"/)
2042 foreach $libobj_iter (split (' ', $1))
2044 if ($libobj_iter =~ /^(.*)\.o$/)
2046 $libsources{$1 . '.c'} = 1;
2051 # Process the AC_OUTPUT macro.
2052 if (! $in_ac_output && s/AC_OUTPUT\s*\(\[?//)
2055 $ac_output_line = $.;
2059 $in_ac_output = 0 if s/[\]\),].*$//;
2061 # Look at potential Makefile.am's.
2067 push (@make_list, $_);
2071 push (@other_input_files, $_);
2076 if (/AC_CONFIG_AUX_DIR\(([^)]+)\)/)
2078 @config_aux_path = $1;
2081 # Check for ansi2knr.
2082 $fp_c_prototypes = 1 if /fp_C_PROTOTYPES/;
2084 # Check for NLS support.
2085 if (/ud_GNU_GETTEXT/)
2088 $ac_gettext_line = $.;
2091 # Look for ALL_LINGUAS.
2092 if (/ALL_LINGUAS="(.*)"$/ || /ALL_LINGUAS=(.*)$/)
2096 $all_linguas_line = $.;
2099 # Handle configuration headers.
2100 if (/AC_CONFIG_HEADER\s*\((.*)\)/)
2102 $config_header_line = $.;
2104 if ($config_name =~ /^([^:]+):(.+)$/)
2107 $config_header = $2;
2111 $config_header = $config_name . '.in';
2115 # Handle AC_CANONICAL_*. Always allow upgrading to
2116 # AC_CANONICAL_SYSTEM, but never downgrading.
2117 $seen_canonical = $AC_CANONICAL_HOST
2118 if ! $seen_canonical && /AC_CANONICAL_HOST/;
2119 $seen_canonical = $AC_CANONICAL_SYSTEM if /AC_CANONICAL_SYSTEM/;
2121 $seen_canonical = 1 if /AC_CHECK_TOOL/;
2122 $seen_path_xtra = 1 if /AC_PATH_XTRA/;
2124 # Sometimes it is desirable to explicitly set YACC. For
2125 # instance some people don't want to use bison.
2126 $seen_prog_yacc = 1 if (/AC_PROG_YACC/
2127 || /AC_SUBST\(YACC\)/
2128 || /AC_(PATH|CHECK)_PROGS?\(YACC/);
2130 # Some things required by Automake.
2131 $seen_make_set = 1 if /AC_PROG_MAKE_SET/;
2132 $seen_arg_prog = 1 if /AC_ARG_PROGRAM/;
2133 $seen_ranlib = 1 if /AC_PROG_RANLIB/;
2134 $seen_maint_mode = 1 if /jm_MAINTAINER_MODE/;
2135 $seen_package = 1 if /PACKAGE=/;
2136 $seen_version = 1 if /VERSION=/;
2138 # Weird conditionals here because it is always allowed to
2139 # upgrade to fp_PROG_INSTALL but never to downgrade to
2141 $seen_prog_install = 1 if ! $seen_prog_install && /AC_PROG_INSTALL/;
2142 $seen_prog_install = 2 if /fp_PROG_INSTALL/;
2144 if (/AC_PROG_LIBTOOL/ || /gm_PROG_LIBTOOL/)
2152 # Set input files if not specified by user.
2153 @input_files = @make_list if (! @input_files);
2157 &am_conf_error ("\`PACKAGE' not defined in configure.in")
2159 &am_conf_error ("\`VERSION' not defined in configure.in")
2162 # Look for some files we need. Always check for these. This
2163 # check must be done for every run, even those where we are only
2164 # looking at a subdir Makefile. We must set relative_dir so that
2165 # the file-finding machinery works.
2166 local ($relative_dir) = '.';
2167 &require_config_file ($FOREIGN, 'install-sh', 'mkinstalldirs');
2170 ################################################################
2172 # Do any extra checking for GNU standards.
2173 sub check_gnu_standards
2175 if ($relative_dir eq '.')
2177 # In top level (or only) directory.
2178 &require_file ($GNU, 'INSTALL', 'NEWS', 'README', 'COPYING',
2179 'AUTHORS', 'ChangeLog');
2183 # Do any extra checking for GNITS standards.
2184 sub check_gnits_standards
2186 if ($strictness >= $GNITS && -f $relative_dir . '/COPYING.LIB')
2189 ("\`${relative_dir}/COPYING.LIB' disallowed by Gnits standards");
2192 if ($relative_dir eq '.')
2194 # In top level (or only) directory.
2195 &require_file ($GNITS, 'THANKS');
2199 ################################################################
2201 # Pretty-print something. HEAD is what should be printed at the
2202 # beginning of the first line, FILL is what should be printed at the
2203 # beginning of every subsequent line.
2204 sub pretty_print_internal
2206 local ($head, $fill, @values) = @_;
2208 local ($column) = length ($head);
2209 local ($result) = $head;
2211 # Fill length is number of characters. However, each Tab
2212 # character counts for eight. So we count the number of Tabs and
2214 local ($fill_length) = length ($fill);
2215 $fill_length += 7 * ($fill =~ tr/\t/\t/d);
2220 # "71" because we also print a space.
2221 if ($column + length ($_) > 71)
2223 $result .= " \\\n" . $fill;
2224 $column = $fill_length;
2228 $result .= ' ' unless ($bol);
2230 $column += length ($_) + 1;
2238 # Pretty-print something and append to output_vars.
2241 $output_vars .= &pretty_print_internal (@_);
2244 # Pretty-print something and append to output_rules.
2245 sub pretty_print_rule
2247 $output_rules .= &pretty_print_internal (@_);
2251 ################################################################
2253 # See if a variable exists.
2254 sub variable_defined
2257 if (defined $targets{$var})
2259 &am_line_error ($var, "\`$var' is target; expected variable");
2261 return (defined $contents{$var} && ! defined $targets{$var});
2264 # Read Makefile.am and set up %contents. Simultaneously copy lines
2265 # from Makefile.am into $output_trailer or $output_vars as
2266 # appropriate. NOTE we put rules in the trailer section. We want
2267 # user rules to come after our generated stuff.
2270 local ($amfile) = @_;
2272 # Compute relative location of the top object directory.
2273 local (@topdir) = ();
2274 foreach (split (/\//, $relative_dir))
2276 next if $_ eq '.' || $_ eq '';
2283 push (@topdir, '..');
2286 @topdir = ('.') if ! @topdir;
2288 $top_builddir = join ('/', @topdir);
2290 ($build_rx = $top_builddir) =~ s/(\W)/\\$1/g;
2291 local ($header_vars) =
2292 &file_contents_with_transform
2293 ('s/\@top_builddir\@/' . $build_rx . '/g',
2296 # Generate some useful variables when AC_CANONICAL_* used.
2297 if ($seen_canonical)
2299 $header_vars .= ('host_alias = @host_alias@' . "\n"
2300 . 'host_triplet = @host@' . "\n");
2301 if ($seen_canonical == $AC_CANONICAL_SYSTEM)
2303 $header_vars .= ('build_alias = @build_alias@' . "\n"
2304 . 'build_triplet = @build@' . "\n");
2305 $header_vars .= ('target_alias = @target_alias@' . "\n"
2306 . 'target_triplet = @target@' . "\n");
2310 open (AM_FILE, $amfile) || die "automake: couldn't open \`$amfile': $!\n";
2311 print "automake: reading $amfile\n" if $verbose;
2313 $output_vars .= ("# $in_file_name generated automatically by automake "
2314 . $VERSION . " from $am_file_name\n");
2316 # Generate copyright for generated Makefile.in.
2317 $output_vars .= $gen_copyright;
2319 local ($saw_bk) = 0;
2320 local ($was_rule) = 0;
2321 local ($spacing) = '';
2322 local ($comment) = '';
2323 local ($last_var_name) = '';
2328 if (/$IGNORE_PATTERN/o)
2330 # Merely delete comments beginning with two hashes.
2332 elsif (/$WHITE_PATTERN/o)
2334 # Stick a single white line before the incoming macro or rule.
2338 elsif (/$COMMENT_PATTERN/o)
2340 # Stick comments before the incoming macro or rule. Make
2341 # sure a blank line preceeds comments.
2342 $spacing = "\n" unless $blank;
2343 $comment .= $spacing . $_;
2352 $output_vars .= $comment . "\n" . $header_vars;
2356 local ($is_ok_macro);
2360 unless substr ($_, -1, 1) eq "\n";
2362 $_ =~ s/\@MAINT\@//g
2363 unless $seen_maint_mode;
2365 if (/$IGNORE_PATTERN/o)
2367 # Merely delete comments beginning with two hashes.
2369 elsif (/$WHITE_PATTERN/o)
2371 # Stick a single white line before the incoming macro or rule.
2374 elsif (/$COMMENT_PATTERN/o)
2376 # Stick comments before the incoming macro or rule.
2377 $comment .= $spacing . $_;
2384 $output_trailer .= $_;
2391 # Chop newline and backslash if this line is
2392 # continued. FIXME maybe ensure trailing whitespace
2396 $contents{$last_var_name} .= $_;
2399 elsif (/$RULE_PATTERN/o)
2401 # warn "** Saw rule .$1.\n";
2404 # Value here doesn't matter; for targets we only note
2408 $content_lines{$1} = $.;
2409 $output_trailer .= $comment . $spacing . $_;
2410 $comment = $spacing = '';
2413 elsif (($is_ok_macro = /$MACRO_PATTERN/o)
2414 || /$BOGUS_MACRO_PATTERN/o)
2416 # Found a macro definition.
2418 $last_var_name = $1;
2419 if (substr ($2, -1) eq "\\")
2421 $contents{$1} = substr ($2, 0, length ($2) - 1);
2427 $content_lines{$1} = $.;
2428 $output_vars .= $comment . $spacing . $_;
2429 $comment = $spacing = '';
2433 &am_line_error ($., "bad macro name \`$1'")
2438 # This isn't an error; it is probably a continued rule.
2439 # In fact, this is what we assume.
2441 $output_trailer .= $comment . $spacing . $_;
2442 $comment = $spacing = '';
2449 $output_trailer .= $comment;
2452 ################################################################
2454 sub initialize_global_constants
2456 # Values for AC_CANONICAL_*
2457 $AC_CANONICAL_HOST = 1;
2458 $AC_CANONICAL_SYSTEM = 2;
2460 # Associative array of standard directory names. Entry is TRUE if
2461 # corresponding directory should be installed during
2462 # 'install-exec' phase.
2480 # Helper text for dealing with man pages.
2481 $install_man_format =
2482 ' @sect=@SECTION@; \\
2483 inst=`echo "@MANBASE@" | sed \'$(transform)\'`.@FULLSECT@; \\
2484 echo installing @MAN@ as $(mandir)/man$$sect/$$inst; \\
2485 $(INSTALL_DATA) $(srcdir)/@MAN@ $(mandir)/man$$sect/$$inst
2488 $uninstall_man_format =
2489 ' inst=`echo "@MANBASE@" | sed \'$(transform)\'`.@FULLSECT@; \\
2490 rm -f $(mandir)/man@SECTION@/$$inst
2493 # Commonly found files we look for and automatically include in
2497 "README", "THANKS", "TODO", "NEWS", "COPYING", "COPYING.LIB",
2498 "INSTALL", "ABOUT-NLS", "ChangeLog", "configure", "configure.in",
2499 "config.guess", "config.sub", "AUTHORS", "BACKLOG", "ABOUT-GNU",
2500 "libversion.in", "mdate-sh", "mkinstalldirs", "install-sh",
2504 # Commonly used files we auto-include, but only sometimes.
2507 "aclocal.m4", "acconfig.h", "config.h.top",
2508 "config.h.bot", "stamp-h.in", "ansi2knr.c",
2509 "ansi2knr.1", 'stamp-vti'
2513 --amdir=DIR directory storing config files
2514 --foreign same as --strictness=foreign
2515 --gnits same as --strictness=gnits
2516 --gnu same as --strictness=gnu
2517 --help print this help, then exit
2518 -i, --include-deps include generated dependencies in Makefile.in
2519 -a, --add-missing add missing standard files to package
2520 -o DIR, --output-dir=DIR
2521 put generated Makefile.in's into DIR
2522 -s LEVEL, --strictness=LEVEL
2523 set strictness level. LEVEL is foreign, gnu, gnits
2524 -v, --verbose verbosely list files processed
2525 --version print version number, then exit\n";
2527 # Copyright on generated Makefile.ins.
2529 # Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
2530 # This Makefile.in is free software; the Free Software Foundation
2531 # gives unlimited permission to copy, distribute and modify it.
2535 # (Re)-Initialize per-Makefile.am variables.
2536 sub initialize_per_input
2538 # These two variables are used when generating each Makefile.in.
2539 # They hold the Makefile.in until it is ready to be printed.
2542 $output_trailer = '';
2544 # Suffixes found during a run.
2547 # This holds the contents of a Makefile.am, as parsed by
2551 # This holds the names which are targets. These also appear in
2555 # This holds the line numbers at which various elements of
2556 # %contents are defined.
2557 %content_lines = ();
2559 # This holds the "relative directory" of the current Makefile.in.
2560 # Eg for src/Makefile.in, this is "src".
2563 # This holds a list of files that are included in the
2567 # List of dependencies for the obvious targets.
2582 # These are pretty obvious, too. They are used to define the
2583 # SOURCES and OBJECTS variables.
2587 # TRUE if current directory holds any C source files. (Actually
2588 # holds object extension, but this information is encapsulated in
2589 # the function get_object_extension).
2590 $dir_holds_sources = '';
2592 # TRUE if install targets should work recursively.
2593 $recursive_install = 0;
2598 # Strictness levels.
2599 $strictness = $default_strictness;
2600 $strictness_name = $default_strictness_name;
2602 # Options from AUTOMAKE_OPTIONS.
2605 # Whether or not dependencies are handled. Can be further changed
2606 # in handle_options.
2607 $use_dependencies = $cmdline_use_dependencies;
2610 $local_maint_charset = $maint_charset;
2614 ################################################################
2616 # Return contents of a file from $am_dir, automatically skipping
2617 # macros or rules which are already known. Runs command on each line
2618 # as it is read; this command can modify $_.
2619 sub file_contents_with_transform
2621 local ($command, $basename) = @_;
2622 local ($file) = $am_dir . '/' . $basename . '.am';
2624 open (FC_FILE, $file)
2625 || die "automake: installation error: cannot open \`$file'\n";
2627 # print "automake: reading $file\n" if $verbose;
2629 local ($was_rule) = 0;
2630 local ($result_vars) = '';
2631 local ($result_rules) = '';
2632 local ($comment) = '';
2633 local ($spacing) = "\n";
2634 local ($skipping) = 0;
2638 $_ =~ s/\@MAINT\@//g
2639 unless $seen_maint_mode;
2643 if (/$IGNORE_PATTERN/o)
2645 # Merely delete comments beginning with two hashes.
2647 elsif (/$WHITE_PATTERN/o)
2649 # Stick a single white line before the incoming macro or rule.
2652 elsif (/$COMMENT_PATTERN/o)
2654 # Stick comments before the incoming macro or rule.
2655 $comment .= $spacing . $_;
2662 $result_rules .= $_ if ! $skipping;
2666 $result_vars .= $_ if ! $skipping;
2670 elsif (/$RULE_PATTERN/o)
2672 # warn "** Found rule .$1.\n";
2675 $skipping = defined $contents{$1};
2676 # warn "** Skip $skipping\n" if $skipping;
2677 $result_rules .= $comment . $spacing . $_ if ! $skipping;
2678 $comment = $spacing = '';
2681 elsif (/$MACRO_PATTERN/o)
2683 # warn "** Found macro .$1.\n";
2684 # Found a variable reference.
2686 $skipping = defined $contents{$1};
2687 # warn "** Skip $skipping\n" if $skipping;
2688 $result_vars .= $comment . $spacing . $_ if ! $skipping;
2689 $comment = $spacing = '';
2694 # This isn't an error; it is probably a continued rule.
2695 # In fact, this is what we assume.
2697 $result_rules .= $comment . $spacing . $_ if ! $skipping;
2698 $comment = $spacing = '';
2704 return $result_vars . $result_rules . $comment;
2707 # Like file_contents_with_transform, but no transform.
2710 return &file_contents_with_transform ('', @_);
2713 # Handle `where_HOW' variable magic. Does all lookups, generates
2714 # install code, and possibly generates code to define the primary
2715 # variable. The first argument is the name of the .am file to munge,
2716 # the second argument is the primary variable (eg HEADERS), and all
2717 # subsequent arguments are possible installation locations. Returns
2718 # list of all values of all _HOW targets.
2720 # FIXME this should be rewritten to be cleaner. It should be broken
2721 # up into multiple functions.
2723 # Usage is: am_install_var (OPTION..., file, HOW, where...)
2728 local ($do_all, $do_clean) = (1, 0);
2731 if ($args[0] eq '-clean')
2735 elsif ($args[0] eq '-no-all')
2739 elsif ($args[0] !~ /^-/)
2745 local ($file, $primary, @prefixes) = @args;
2748 local (@result) = ();
2750 # Now that configure substitutions are allowed in where_HOW
2751 # variables, it is an error to actually define the primary.
2752 &am_line_error ($primary, "\`$primary' is an anachronism")
2753 if &variable_defined ($primary);
2756 # Look for misspellings. It is an error to have a variable ending
2757 # in a "reserved" suffix whose prefix is unknown, eg
2758 # "bni_PROGRAMS". However, unusual prefixes are allowed if a
2759 # variable of the same name (with "dir" appended) exists. For
2760 # instance, if the variable "zardir" is defined, then
2761 # "zar_PROGRAMS" becomes valid. This is to provide a little extra
2762 # flexibility in those cases which need it. Perhaps it should be
2763 # disallowed in the Gnits case? The problem is, sometimes it is
2764 # useful to put things in a subdir of eg pkgdatadir, perhaps even
2766 local (%valid, $varname);
2767 grep ($valid{$_} = 0, @prefixes);
2768 $valid{'EXTRA'} = 0;
2769 foreach $varname (keys %contents)
2771 if ($varname =~ /^(.*)_$primary$/)
2773 if (! defined $valid{$1} && ! &variable_defined ($1 . 'dir'))
2775 &am_line_error ($varname, "invalid variable \"$varname\"");
2779 # Ensure all extended prefixes are actually used.
2785 local ($clean_file) = $file . '-clean';
2788 foreach $X (keys %valid)
2790 $one_name = $X . '_' . $primary;
2791 if (&variable_defined ($one_name))
2793 # Append actual contents of where_PRIMARY variable to
2796 foreach $rcurs (split (' ', $contents{$one_name}))
2798 # Skip configure substitutions. Possibly bogus.
2799 next if $rcurs =~ /^\@.*\@$/;
2800 push (@result, $rcurs);
2803 # "EXTRA" shouldn't be used when generating clean targets,
2804 # @all, or install targets.
2805 next if $X eq 'EXTRA';
2810 &file_contents_with_transform ('s/\@DIR\@/' . $X . '/go',
2813 push (@clean, $X . $primary);
2814 &push_phony_cleaners ($X . $primary);
2819 push (@check, '$(' . $one_name . ')');
2823 push (@used, '$(' . $one_name . ')');
2825 if ($X eq 'noinst' || $X eq 'check')
2827 # Objects which don't get installed by default.
2832 &file_contents_with_transform ('s/\@DIR\@/' . $X . '/go',
2835 push (@uninstall, 'uninstall-' . $X . $primary);
2836 push (@phony, 'uninstall-' . $X . $primary);
2837 push (@installdirs, '$(' . $X . 'dir)');
2838 if ($exec_dir_p{$X})
2840 push (@install_exec, 'install-' . $X . $primary);
2841 push (@phony, 'install-' . $X . $primary);
2845 push (@install_data, 'install-' . $X . $primary);
2846 push (@phony, 'install-' . $X . $primary);
2854 &pretty_print ($primary . ' =', '', @used);
2855 $output_vars .= "\n";
2858 # Push here because PRIMARY might be configure time determined.
2859 push (@all, '$(' . $primary . ')')
2860 if $do_all && @used;
2866 ################################################################
2868 # This variable is local to the "require file" set of functions.
2869 @require_file_paths = ();
2871 # Verify that the file must exist in the current directory. Usage:
2872 # require_file (isconfigure, line_number, strictness, file) strictness
2873 # is the strictness level at which this file becomes required. Must
2874 # set require_file_paths before calling this function.
2875 # require_file_paths is set to hold a single directory (the one in
2876 # which the first file was found) before return.
2877 sub require_file_internal
2879 local ($is_configure, $line, $mystrict, @files) = @_;
2880 local ($file, $fullfile);
2881 local ($found_it, $errfile, $errdir);
2884 foreach $file (@files)
2887 foreach $dir (@require_file_paths)
2891 $fullfile = $relative_dir . "/" . $file;
2892 $errdir = $relative_dir unless $errdir;
2896 $fullfile = $dir . "/" . $file;
2897 $errdir = $dir unless $errdir;
2900 # Use different name for "error filename". Otherwise on
2901 # an error the bad file will be reported as eg
2902 # `../../install-sh' when using the default
2904 $errfile = $errdir . '/' . $file;
2909 &push_dist_common ($file) if $dir eq $relative_dir;
2917 # Prune the path list.
2918 @require_file_paths = $save_dir;
2922 if ($strictness >= $mystrict)
2924 # Only install missing files according to our desired
2926 if ($add_missing && -f ($am_dir . '/' . $file))
2928 # Install the missing file. Symlink if we can, copy
2930 if ($symlink_exists)
2932 symlink ($am_dir . '/' . $file, $errfile);
2936 system ('cp', $am_dir . '/' . $file, $errfile);
2939 # FIXME this is a hack. Should have am_warn.
2940 local ($save) = $exit_status;
2945 "required file \"$errfile\" not found; installing");
2951 "required file \"$errfile\" not found; installing");
2953 $exit_status = $save;
2957 # Only an error if strictness constraint violated.
2961 ($line, "required file \"$errfile\" not found");
2966 ($line, "required file \"$errfile\" not found");
2974 # Like require_file_with_line, but error messages refer to
2975 # configure.in, not the current Makefile.am.
2976 sub require_file_with_conf_line
2978 @require_file_paths = '.';
2979 &require_file_internal (1, @_);
2982 sub require_file_with_line
2984 @require_file_paths = '.';
2985 &require_file_internal (0, @_);
2990 @require_file_paths = '.';
2991 &require_file_internal (0, '', @_);
2994 # Require a file that is also required by Autoconf. Looks in
2995 # configuration path, as specified by AC_CONFIG_AUX_DIR.
2996 sub require_config_file
2998 @require_file_paths = @config_aux_path;
2999 &require_file_internal (0, '', @_);
3000 local ($dir) = $require_file_paths[0];
3001 @config_aux_path = @require_file_paths;
3004 $config_aux_dir = '.';
3008 $config_aux_dir = '$(top_srcdir)/' . $dir;
3012 # Assumes that the line number is in Makefile.am.
3013 sub require_conf_file_with_line
3015 @require_file_paths = @config_aux_path;
3016 &require_file_internal (0, @_);
3017 local ($dir) = $require_file_paths[0];
3018 @config_aux_path = @require_file_paths;
3021 $config_aux_dir = '.';
3025 $config_aux_dir = '$(top_srcdir)/' . $dir;
3029 # Assumes that the line number is in Makefile.am.
3030 sub require_conf_file_with_conf_line
3032 @require_file_paths = @config_aux_path;
3033 &require_file_internal (1, @_);
3034 local ($dir) = $require_file_paths[0];
3035 @config_aux_path = @require_file_paths;
3038 $config_aux_dir = '.';
3042 $config_aux_dir = '$(top_srcdir)/' . $dir;
3046 ################################################################
3048 # Push a list of files onto dist_common.
3049 sub push_dist_common
3051 local (@files) = @_;
3054 foreach $file (@files)
3056 $dist_common{$file} = 1;
3060 # Push a list of clean targets onto phony.
3061 sub push_phony_cleaners
3065 foreach $target ('mostly', 'dist', '', 'maintainer-')
3067 push (@phony, $target . 'clean-' . $base);
3074 $strictness_name = $_[0];
3075 if ($strictness_name eq 'gnu')
3079 elsif ($strictness_name eq 'gnits')
3081 $strictness = $GNITS;
3083 elsif ($strictness_name eq 'foreign')
3085 $strictness = $FOREIGN;
3089 die "automake: level \`$strictness_name' not recognized\n";
3094 ################################################################
3096 # Return directory name of file.
3102 ($sub = $file) =~ s,/+[^/]+$,,g;
3103 $sub = '.' if $sub eq $file;
3110 local ($dirname) = @_;
3111 system ("mkdir", $dirname);
3114 ################################################################
3116 # Print an error message and set exit status.
3119 warn "automake: ${am_file}.am: ", join (' ', @_), "\n";
3125 local ($symbol, @args) = @_;
3129 # If SYMBOL not already a line number, look it up in Makefile.am.
3130 $symbol = $content_lines{$symbol} unless $symbol =~ /^\d+$/;
3131 $symbol .= ': ' if $symbol;
3132 warn "${am_file}.am:", $symbol, join (' ', @args), "\n";
3141 # Like am_error, but while scanning configure.in.
3144 # FIXME can run in subdirs.
3145 warn "automake: configure.in: ", join (' ', @_), "\n";
3149 # Error message with line number referring to configure.in.
3150 sub am_conf_line_error
3152 local ($line, @args) = @_;
3156 warn "configure.in: $line: ", join (' ', @args), "\n";
3161 &am_conf_error (@args);
3165 # Tell user where our aclocal.m4 is, but only once.
3166 sub keyed_aclocal_warning
3169 warn "automake: macro \`$key' can be found in ${am_dir}/aclocal.m4\n";
3172 # Print usage information.
3175 print "Usage: automake [OPTION] ... [Makefile]...\n";
3177 print "\nFiles which are automatically distributed, if found:\n";
3178 $~ = "USAGE_FORMAT";
3179 local (@lcomm) = sort ((@common_files, @common_sometimes));
3180 local ($one, $two, $three, $four);
3183 $one = shift @lcomm;
3184 $two = @lcomm ? shift @lcomm : '';
3185 $three = @lcomm ? shift @lcomm : '';
3186 $four = @lcomm ? shift @lcomm : '';
3193 format USAGE_FORMAT =
3194 @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<
3195 $one, $two, $three, $four