5 eval 'exec @PERL@ -S $0 ${1+"$@"}'
6 if $running_under_some_shell;
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 # Relative location of top build directory.
94 # List of Makefile.am's to process.
97 # List of files in AC_OUTPUT without Makefile.am.
98 @other_input_files = ();
99 # Line number at which AC_OUTPUT seen.
102 # List of directories to search for configure-required files. This
103 # can be set by AC_CONFIG_AUX_DIR.
104 @config_aux_path = ('.', '..', '../..');
105 $config_aux_dir = '';
107 # Whether AC_PROG_MAKE_SET has been seen in configure.in.
110 # Whether ud_GNU_GETTEXT has been seen in configure.in.
112 # Line number at which ud_GNU_GETTEXT seen.
113 $ac_gettext_line = 0;
115 # Whether ALL_LINGUAS has been seen.
119 # Line number at which it appears.
120 $all_linguas_line = 0;
122 # 1 if AC_PROG_INSTALL seen, 2 if fp_PROG_INSTALL seen.
123 $seen_prog_install = 0;
125 # 1 if any scripts installed, 0 otherwise.
126 $scripts_installed = 0;
128 # Whether AC_PATH_XTRA has been seen in configure.in.
131 # Whether YACC variable has been seen in configure.in.
134 # TRUE if we've seen AC_CANONICAL_(HOST|SYSTEM). The presence of
135 # AC_CHECK_TOOL also sets this.
138 # TRUE if we've seen AC_PROG_RANLIB.
141 # TRUE if we've seen AC_ARG_PROGRAM.
144 # TRUE if we've seen gm_PROG_LIBTOOL or AC_PROG_LIBTOOL.
148 # TRUE if we've seen jm_MAINTAINER_MODE.
149 $seen_maint_mode = 0;
152 # Charsets used by maintainer and in distribution. MAINT_CHARSET is
153 # handled in a funny way: if seen in the top-level Makefile.am, it is
154 # used for every directory which does not specify a different value.
155 # The rationale here is that some directories (eg gettext) might be
156 # distributions of other packages, and thus require their own charset
157 # info. However, the DIST_CHARSET must be the same for the entire
158 # package; it can only be set at top-level.
159 # FIXME this yields bugs when rebuilding. What to do? Always
160 # read (and sometimes discard) top-level Makefile.am?
162 $dist_charset = 'utf8'; # recode doesn't support this yet.
164 # Name of input file ("Makefile.in") and output file ("Makefile.am").
165 # These have no directory components.
171 &initialize_global_constants;
173 # Parse command line.
174 &parse_arguments (@ARGV);
176 # Do configure.in scan only once.
179 die "automake: no \`Makefile.am' found or specified\n"
182 # Now do all the work on each file.
183 foreach $am_file (@input_files)
185 # FIXME should support the AC_OUTPUT ":" syntax here.
186 if (! -f ($am_file . '.am'))
188 &am_error ('no such file');
192 &generate_makefile ($am_file);
196 if ($seen_prog_install <= $scripts_installed)
198 &am_conf_error (($scripts_installed ? 'fp_PROG_INSTALL' : 'AC_PROG_INSTALL')
199 . " must be used in configure.in");
200 &keyed_aclocal_warning ('fp_PROG_INSTALL')
201 if $scripts_installed;
207 ################################################################
209 # Parse command line.
212 local (@arglist) = @_;
215 &set_strictness ('gnu');
219 if ($arglist[0] eq "--version")
221 print "Automake version $VERSION\n";
224 elsif ($arglist[0] eq "--help")
228 elsif ($arglist[0] =~ /^--amdir=(.+)$/)
232 elsif ($arglist[0] eq '--amdir')
234 &require_argument (@arglist);
236 $am_dir = $arglist[0];
238 elsif ($arglist[0] =~ /^--strictness=(.+)$/)
240 &set_strictness ($1);
242 elsif ($arglist[0] eq '--gnu')
244 &set_strictness ('gnu');
246 elsif ($arglist[0] eq '--gnits')
248 &set_strictness ('gnits');
250 elsif ($arglist[0] eq '--foreign')
252 &set_strictness ('foreign');
254 elsif ($arglist[0] eq '--strictness' || $arglist[0] eq '-s')
256 &require_argument (@arglist);
258 &set_strictness ($arglist[0]);
260 elsif ($arglist[0] eq '--include-deps' || $arglist[0] eq '-i')
262 $cmdline_use_dependencies = 0;
264 elsif ($arglist[0] =~ /^--output-dir=(.*)$/)
266 # Set output directory.
267 $output_directory = $1;
269 elsif ($arglist[0] eq '--output-dir' || $arglist[0] eq '-o')
271 &require_argument (@arglist);
273 $output_directory = $arglist[0];
275 elsif ($arglist[0] eq '--add-missing' || $arglist[0] eq '-a')
279 elsif ($arglist[0] eq '--verbose' || $arglist[0] eq '-v')
283 elsif ($arglist[0] eq '--')
285 # Stop option processing.
287 push (@input_files, @arglist);
290 elsif ($arglist[0] =~ /^-/)
292 die "automake: unrecognized option -- \`$arglist[0]'\n";
296 push (@input_files, $arglist[0]);
302 # Take global strictness from whatever we currently have set.
303 $default_strictness = $strictness;
304 $default_strictness_name = $strictness_name;
307 # Ensure argument exists, or die.
310 local ($arg, @arglist) = @_;
311 die "automake: no argument given for option \`$arg'\n"
315 ################################################################
317 # Generate a Makefile.in given the name of the corresponding Makefile.
318 sub generate_makefile
320 local ($makefile) = @_;
322 ($am_file_name = $makefile) =~ s/^.*\///;
323 $in_file_name = $am_file_name . '.in';
324 $am_file_name .= '.am';
326 print "automake: creating ", $makefile, ".in\n" if $verbose;
328 &initialize_per_input;
329 $relative_dir = &dirname ($makefile);
331 # At the toplevel directory, we might need config.guess, config.sub
333 if ($relative_dir eq '.')
335 # libtool requires some files.
336 &require_conf_file_with_conf_line ($libtool_line, $FOREIGN,
337 'config.sub', 'config.guess',
338 'libtool') if $seen_libtool;
340 # AC_CANONICAL_HOST and AC_CANONICAL_SYSTEM need config.guess and
342 &require_config_file ($FOREIGN, 'config.guess', 'config.sub')
346 # We still need Makefile.in here, because sometimes the `dist'
347 # target doesn't re-run automake.
348 &push_dist_common ($in_file_name, $am_file_name);
349 push (@sources, '$(SOURCES)')
350 if &variable_defined ('SOURCES');
351 push (@objects, '$(OBJECTS)')
352 if &variable_defined ('OBJECTS');
354 # This is always the default target. This gives us freedom to do
355 # things in whatever order is convenient.
356 $output_rules .= "default: all\n\n";
357 push (@phony, 'default');
359 &read_am_file ($makefile . '.am');
362 # Check first, because we might modify some state.
363 &check_gnu_standards;
364 &check_gnits_standards;
372 # Re-init SOURCES and OBJECTS. FIXME other code shouldn't depend
373 # on this (but currently does).
374 $contents{'SOURCES'} = join (' ', @sources);
375 $contents{'OBJECTS'} = join (' ', @objects);
384 &handle_dependencies;
387 &handle_merge_targets;
392 if (! -d ($output_directory . '/' . $relative_dir))
394 &mkdir ($output_directory . '/' . $relative_dir);
396 if (! open (GM_FILE, "> " . $output_directory . '/' . $makefile . ".in"))
398 warn "automake: ${am_file}.in: cannot open: $!\n";
403 print GM_FILE $output_vars;
404 print GM_FILE $output_rules;
405 print GM_FILE $output_trailer;
410 ################################################################
412 # Handle AUTOMAKE_OPTIONS variable.
415 return if ! &variable_defined ('AUTOMAKE_OPTIONS');
417 foreach (split (/\s+/, $contents{'AUTOMAKE_OPTIONS'}))
420 if ($_ eq 'gnits' || $_ eq 'gnu' || $_ eq 'foreign')
422 &set_strictness ($_);
424 elsif ($_ eq 'no-installman' || $_ eq 'ansi2knr' || $_ eq 'dist-shar')
426 # Explicitly recognize these.
428 elsif ($_ eq 'no-dependencies')
430 $use_dependencies = 0;
432 elsif (/[0-9]+\.?[0-9]+/)
434 # Got a version number. Is the syntax too strict?
437 &am_line_error ('AUTOMAKE_OPTIONS',
438 "require version $_, only have $VERSION");
444 &am_line_error ('AUTOMAKE_OPTIONS',
445 'option ', $_, 'not recognized');
450 # Return object extension. Just once, put some code into the output.
451 sub get_object_extension
453 if (! $dir_holds_sources)
457 if (&variable_defined ('CONFIG_HEADER'))
459 ($xform = &dirname ($contents{'CONFIG_HEADER'}))
461 $xform = '-I' . $xform;
463 $xform = 's/\@CONFIG_INCLUDE_SPEC\@/' . $xform . '/go';
464 $output_vars .= &file_contents_with_transform ($xform,
466 $output_rules .= &file_contents ('compile');
467 &push_phony_cleaners ('compile');
469 # If using X, include some extra variable definitions. NOTE
470 # we don't want to force these into CFLAGS or anything,
471 # because not all programs will necessarily use X.
474 $output_vars .= ("X_CFLAGS = \@X_CFLAGS\@\n"
475 . "X_LIBS = \@X_LIBS\@\n"
476 . "X_EXTRA_LIBS = \@X_EXTRA_LIBS\@\n"
477 . "X_PRE_LIBS = \@X_PRE_LIBS\@\n");
480 # Check for automatic de-ANSI-fication.
481 $dir_holds_sources = '.o';
482 push (@suffixes, '.c', '.o');
483 push (@clean, 'compile');
485 if (defined $options{'ansi2knr'})
487 if (! $fp_c_prototypes)
489 &am_line_error ('AUTOMAKE_OPTIONS',
490 "option \`ansi2knr' in use but \`fp_C_PROTOTYPES' not in configure.in");
491 &keyed_aclocal_warning ('fp_C_PROTOTYPES');
492 # Only give this error once.
493 $fp_c_prototypes = 1;
496 $dir_holds_sources = '$o';
497 push (@suffixes, '._c', '._o');
499 &require_file_with_line ('AUTOMAKE_OPTIONS', $FOREIGN,
500 'ansi2knr.c', 'ansi2knr.1');
502 $output_vars .= &file_contents ('kr-vars');
503 $output_rules .= &file_contents ('compile-kr');
504 $output_rules .= &file_contents ('clean-kr');
507 &push_phony_cleaners ('kr');
510 return $dir_holds_sources;
513 # Handle SOURCE->OBJECT transform for one program or library.
514 sub handle_source_transform
516 # one_file is canonical name. unxformed is given name. obj is
518 local ($one_file, $unxformed, $obj) = @_;
519 local ($objpat) = $obj;
520 $objpat =~ s/(\W)/\\$1/g;
522 if (&variable_defined ($one_file . "_OBJECTS"))
524 &am_line_error ($one_file . '_OBJECTS',
525 $one_file . '_OBJECTS', 'should not be defined');
526 # No point in continuing.
530 local ($source_list);
532 foreach $prefix ('', 'EXTRA_')
535 if (&variable_defined ($prefix . $one_file . "_SOURCES"))
537 push (@sources, '$(' . $prefix . $one_file . "_SOURCES)");
538 push (@objects, '$(' . $prefix . $one_file . "_OBJECTS)")
539 unless $prefix eq 'EXTRA_';
540 $source_list = $contents{$prefix . $one_file . "_SOURCES"};
542 elsif ($prefix eq '')
544 $output_vars .= ($one_file . "_SOURCES = " . $unxformed . ".c\n"
545 . $one_file . "_OBJECTS = ". $unxformed
547 push (@sources, $unxformed . '.c');
548 push (@objects, $unxformed . $obj);
549 $source_list = $unxformed . ".c ";
553 $output_vars .= "EXTRA_" . $one_file . "_SOURCES =\n";
558 # Turn sources into objects.
559 local (@files) = split (/\s+/, $source_list);
560 local (@result) = ();
563 # Skip header files, including C++-ish ones.
566 # Skip things that look like macro references.
567 next if /^\$\(.*\)$/;
568 next if /^\$\{.*\}$/;
569 # Skip things that look like configure substitutions.
572 # One wonders how this can happen. But, apparently,
573 # it can. I believe it happens when nothing precedes
574 # a backslash-newline on a line -- the \s+ regexp
575 # doesn't match the newline. Anyway, skip empty
576 # strings. See tests/depend.test for an example of
577 # how to trigger this code.
582 # Automatically include generated .c file in
584 &push_dist_common ($1 . '.c');
587 # Transform source files into .o files.
590 s/\.[cCmylfs]$/$obj/g;
592 unless $prefix eq 'EXTRA_';
594 # Transform .o or $o file into .P file (for automatic
597 $dep_files{'$(srcdir)/.deps/' . $_} = 1;
600 &pretty_print ($one_file . "_OBJECTS =", "", @result)
601 unless $prefix eq 'EXTRA_';
605 if (&variable_defined ('CONFIG_HEADER'))
607 $output_rules .= ('$(' . $one_file . "_OBJECTS): "
608 . $contents{'CONFIG_HEADER'} . "\n");
614 # Special-case @ALLOCA@ and @LIBOBJS@ in _LDADD or _LIBADD variables.
615 sub handle_lib_objects
619 die "programming error in handle_lib_objects"
620 if ! &variable_defined ($var);
622 # We recognize certain things that are commonly put in LIBADD or
626 foreach $lsearch (split (/\s+/, $contents{$var}))
628 # Automatically handle @LIBOBJS@ and @ALLOCA@. Basically this
629 # means adding entries to dep_files.
630 if ($lsearch eq '@LIBOBJS@')
632 local ($iter, $rewrite);
633 foreach $iter (keys %libsources)
635 if ($iter ne 'alloca.c')
637 ($rewrite = $iter) =~ s/\.c$/.P/;
638 $dep_files{'$(srcdir)/.deps/' . $rewrite} = 1;
639 &require_file_with_line ($var, $FOREIGN, $iter);
643 elsif ($lsearch eq '@ALLOCA@')
645 &am_line_error ($var,
646 "\@ALLOCA\@ seen but \`AC_FUNC_ALLOCA' not in \`configure.in'")
647 if ! defined $libsources{'alloca.c'};
648 $dep_files{'$(srcdir)/.deps/alloca.P'} = 1;
649 &require_file_with_line ($var, $FOREIGN, 'alloca.c');
657 local (@proglist) = &am_install_var ('-clean',
658 'programs', 'PROGRAMS',
659 'bin', 'sbin', 'libexec', 'pkglib',
661 return if ! @proglist;
663 # If a program is installed, this is required. We only want this
664 # error to appear once.
665 &am_conf_error ("AC_ARG_PROGRAM must be used in configure.in")
666 unless $seen_arg_prog;
669 local ($obj) = &get_object_extension;
670 local ($one_file, $xname, $munge);
672 foreach $one_file (@proglist)
674 # Canonicalize names.
675 ($xname = $one_file) =~ tr/A-Za-z0-9_/_/c;
676 if ($xname ne $one_file)
679 foreach $xt ('_LDADD', '_SOURCES', '_OBJECTS', '_DEPENDENCIES')
681 &am_line_error ($one_file . $xt,
682 "invalid variable \`" . $one_file . $xt
683 . "'; should be \`" . $xname . $xt . "'")
684 if &variable_defined ($one_file . $xt);
688 &handle_source_transform ($xname, $one_file, $obj);
690 if (&variable_defined ($xname . "_LDADD"))
692 &handle_lib_objects ($xname . '_LDADD');
696 # User didn't define prog_LDADD override. So do it.
697 $output_vars .= $xname . '_LDADD = $(LDADD)' . "\n";
701 &file_contents_with_transform
702 ('s/\@PROGRAM\@/' . $one_file . '/go;'
703 . 's/\@XPROGRAM\@/' . $xname . '/go;',
707 &handle_lib_objects ('LDADD')
708 if &variable_defined ('LDADD');
714 local (@liblist) = &am_install_var ('-no-all', '-clean',
715 'libraries', 'LIBRARIES',
716 'lib', 'pkglib', 'noinst', 'check');
717 return if ! @liblist;
721 # FIXME need am_line_error here. But we don't know which
722 # variable exists. Must add a loop... No. Must have
723 # am_install_var return a hash. Otherwise the user could add
724 # install directories that we'd never find.
725 &am_error ("library requires either \`AC_PROG_RANLIB' or `gm_PROG_LIBTOOL' in configure.in");
726 # Only get this error once.
730 # Generate _LIBFILES variables. Too bad we can't do this in
732 local ($onedir, $onelib);
734 foreach $onedir ('lib', 'pkglib', 'noinst', 'check')
736 if (&variable_defined ($onedir . '_LIBRARIES'))
739 foreach $onelib (split (/\s+/, $contents{$onedir . '_LIBRARIES'}))
741 push (@outlist, 'lib' . $onelib . '.a');
743 &pretty_print ($onedir . '_LIBFILES =', "", @outlist);
746 push (@all, '$(LIBFILES)');
748 local ($obj) = &get_object_extension;
750 foreach $onelib (@liblist)
752 if (&variable_defined ($onelib . '_LIBADD'))
754 &handle_lib_objects ($onelib . '_LIBADD');
758 # Generate support for conditional object inclusion in
760 $output_vars .= $onelib . "_LIBADD =\n";
763 &handle_source_transform ($onelib, $onelib, $obj);
766 &file_contents_with_transform ('s/\@LIBRARY\@/' . $onelib . '/go',
770 # Turn "foo" into "libfoo.a" and include macro definition.
771 grep (($_ = 'lib' . $_ . '.a') && 0, @liblist);
773 if (! &variable_defined ('LIBFILES'))
775 &pretty_print ('LIBFILES = ', "", @liblist);
780 $output_vars .= ('AR = $(LIBTOOL) archive' . "\n"
781 . 'RANLIB = $(LIBTOOL) ranlib' . "\n"
782 . 'LCOMPILE = $(LIBTOOL) compile $(DEFS) $(INCLUDES)'
783 . ' $(CPPFLAGS) $(CFLAGS)' . "\n");
787 $output_vars .= ('AR = ar' . "\n"
788 . 'RANLIB = @RANLIB@' . "\n");
795 # NOTE we no longer automatically clean SCRIPTS, because it is
796 # useful to sometimes distribute scripts verbatim. This happens
797 # eg in Automake itself.
799 $msi = &am_install_var ('scripts', 'SCRIPTS',
800 'bin', 'sbin', 'libexec', 'pkgdata',
803 # We really only want a boolean value.
804 $scripts_installed = 1 if $msi;
806 if ($scripts_installed)
808 # If a program is installed, this is required. We only want this
809 # error to appear once.
810 &am_conf_error ("AC_ARG_PROGRAM must be used in configure.in")
811 unless $seen_arg_prog;
816 # Search a file for a "version.texi" Texinfo include. Return the name
817 # of the include file if found, or the empty string if not. A
818 # "version.texi" file is actually any file whose name matches
820 sub grep_for_vers_texi
822 local ($filename) = @_;
824 if (! open (TEXI, $filename))
826 &am_error ("couldn't open \`$filename': $!");
829 print "automake: reading $filename\n" if $verbose;
833 if (/^\@include\s+(vers[^.]*\.texi)\s*$/)
845 # Handle all Texinfo source.
848 &am_line_error ('TEXINFOS',
849 "\`TEXINFOS' is an anachronism; use \`info_TEXINFOS'")
850 if &variable_defined ('TEXINFOS');
851 return if (! &variable_defined ('info_TEXINFOS')
852 && ! &variable_defined ('html_TEXINFOS'));
854 local (@texis) = split (/\s+/, $contents{'info_TEXINFOS'});
856 local (@infos_list, @info_deps_list, @dvis_list, @texi_deps);
857 local ($infobase, $info_cursor);
861 local ($tc_cursor, @texi_cleans);
864 foreach $info_cursor (@texis)
866 ($infobase = $info_cursor) =~ s/\.texi$//;
868 # If 'version.texi' is referenced by input file, then include
869 # automatic versioning capability.
871 = &grep_for_vers_texi ($relative_dir . "/" . $info_cursor);
874 &am_error ("\`$vtexi', included in \`$info_cursor', also included in \`$versions{$vtexi}'")
875 if (defined $versions{$vtexi});
876 $versions{$vtexi} = $info_cursor;
878 # We number the stamp-vti files. This is doable since the
879 # actual names don't matter much. We only number starting
880 # with the second one, so that the common case looks nice.
881 $vti = 'vti' . ($done ? $done : '');
882 &push_dist_common ($vtexi, 'stamp-' . $vti);
886 &require_conf_file_with_line ('info_TEXINFOS', $FOREIGN,
892 ($conf_pat = $config_aux_dir) =~ s/(\W)/\\$1/g;
894 &file_contents_with_transform
895 ('s/\@TEXI\@/' . $info_cursor . '/g; '
896 . 's/\@VTI\@/' . $vti . '/g; '
897 . 's/\@VTEXI\@/' . $vtexi . '/g;'
898 . 's,\@MDDIR\@,' . $conf_pat . ',g;',
901 &push_phony_cleaners ($vti);
904 # If user specified file_TEXINFOS, then use that as explicit
907 push (@texi_deps, $info_cursor);
908 push (@texi_deps, $vtexi) if $vtexi;
910 # Canonicalize name first.
911 ($canonical = $infobase) =~ tr/A-Za-z0-9_/_/c;
912 if (&variable_defined ($canonical . "_TEXINFOS"))
914 push (@texi_deps, '$(' . $canonical . '_TEXINFOS)');
915 &push_dist_common ('$(' . $canonical . '_TEXINFOS)');
918 $output_rules .= ("\n" . $infobase . ".info: "
919 . join (' ', @texi_deps) . "\n\n");
921 push (@infos_list, $infobase . '.info*');
922 push (@info_deps_list, $infobase . '.info');
923 push (@dvis_list, $infobase . '.dvi');
925 # Generate list of things to clean for this target. We do
926 # this explicitly because otherwise too many things could be
927 # removed. In particular the ".log" extension might
928 # reasonably be used in other contexts by the user.
929 foreach $tc_cursor ('aux', 'cp', 'cps', 'dvi', 'fn', 'fns',
930 'ky', 'log', 'pg', 'toc', 'tp', 'vr', 'op')
932 push (@texi_cleans, $infobase . '.' . $tc_cursor);
937 $output_vars .= &file_contents ('texinfos-vars');
938 $output_rules .= &file_contents ('texinfos');
939 push (@phony, 'install-info', 'uninstall-info');
942 $output_rules .= "\nmostlyclean-info:\n";
943 &pretty_print_rule ("\trm -f", "\t ", @texi_cleans);
944 $output_rules .= ("\nclean-info:\n\ndistclean-info:\n\n"
945 . "maintainer-clean-info:\n\t"
946 . 'rm -f $(INFOS)' . "\n");
947 &push_phony_cleaners ('info');
949 push (@suffixes, '.texi', '.info', '.dvi');
950 push (@uninstall, 'uninstall-info');
951 push (@clean, 'info');
952 push (@info, '$(INFO_DEPS)');
953 push (@dvi, '$(DVIS)');
954 push (@installdirs, '$(infodir)');
955 unshift (@install_data, 'install-info');
957 # Make sure documentation is made and installed first. Use
958 # $(INFO_DEPS), not 'info', because otherwise recursive makes get
959 # run twice during "make all".
960 unshift (@all, '$(INFO_DEPS)');
962 $output_vars .= ("INFOS = " . join (' ', @infos_list) . "\n"
963 . "INFO_DEPS = " . join (' ', @info_deps_list) . "\n"
964 . "DVIS = " . join (' ', @dvis_list) . "\n"
965 # This next isn't strictly needed now -- the
966 # places that look here could easily be changed
967 # to look in info_TEXINFOS. But this is probably
968 # better, in case noinst_TEXINFOS is ever
970 . "TEXINFOS = " . $contents{'info_TEXINFOS'} . "\n\n");
972 # Do some error checking.
973 &require_file_with_line ('info_TEXINFOS', $FOREIGN, 'texinfo.tex');
976 # Handle any man pages.
979 &am_line_error ('MANS', "\`MANS' is an anachronism; use \`man_MANS'")
980 if &variable_defined ('MANS');
981 return if ! &variable_defined ('man_MANS');
983 # We generate the manpage install code by hand to avoid the use of
984 # basename in the generated Makefile.
985 local (@mans) = split (/\s+/, $contents{'man_MANS'});
986 local (%sections, %inames, %secmap, %fullsecmap);
989 # FIXME: statement without effect:
990 /^(.*)\.([0-9])([a-z]*)$/;
994 $fullsecmap{$1} = $2 . $3;
997 # We don't really need this, but we use it in case we ever want to
998 # support noinst_MANS.
999 $output_vars .= "MANS = " . $contents{'man_MANS'} . "\n";
1001 # Generate list of install dirs.
1002 $output_rules .= "install-man: \$(MANS)\n";
1003 foreach (keys %sections)
1005 push (@installdirs, '$(mandir)/man' . $_);
1006 $output_rules .= ("\t" . '$(mkinstalldirs) $(mandir)/man'
1009 push (@phony, 'install-man');
1011 # Generate install target.
1013 foreach $key (keys %inames)
1015 $_ = $install_man_format;
1016 s/\@SECTION\@/$secmap{$key}/g;
1017 s/\@MAN\@/$inames{$key}/g;
1018 s/\@FULLSECT\@/$fullsecmap{$key}/g;
1019 s/\@MANBASE\@/$key/g;
1020 $output_rules .= $_;
1022 $output_rules .= "\n";
1024 $output_rules .= "uninstall-man:\n";
1025 foreach $key (keys %inames)
1027 $_ = $uninstall_man_format;
1028 s/\@SECTION\@/$secmap{$key}/g;
1029 s/\@MAN\@/$inames{$key}/g;
1030 s/\@FULLSECT\@/$fullsecmap{$key}/g;
1031 s/\@MANBASE\@/$key/g;
1032 $output_rules .= $_;
1034 $output_rules .= "\n";
1035 push (@phony, 'uninstall-man');
1037 $output_vars .= &file_contents ('mans-vars');
1039 if (! defined $options{'no-installman'})
1041 push (@install_data, 'install-man');
1042 push (@uninstall, 'uninstall-man');
1043 push (@all, '$(MANS)');
1047 # Handle DATA variables.
1050 &am_install_var ('data', 'DATA', 'data', 'sysconf',
1051 'sharedstate', 'localstate', 'pkgdata',
1058 local ($tagging) = 0;
1060 push (@phony, 'tags');
1061 if (&variable_defined ('SUBDIRS'))
1063 $output_rules .= &file_contents ('tags');
1066 elsif ($dir_holds_sources || &variable_defined ('ETAGS_ARGS'))
1068 $output_rules .= &file_contents ('tags-subd');
1074 $output_rules .= &file_contents ('tags-clean');
1075 push (@clean, 'tags');
1076 &push_phony_cleaners ('tags');
1080 # Every Makefile must define some sort of TAGS rule.
1081 # Otherwise, it would be possible for a top-level "make TAGS"
1082 # to fail because some subdirectory failed.
1083 $output_rules .= "tags: TAGS\nTAGS:\n\n";
1087 # Generate actual 'dist' (or dist-shar) rule.
1088 sub handle_dist_worker
1090 $output_rules .= 'distdir: $(DEP_DISTFILES)' . "\n";
1092 # Initialization; only at top level.
1093 if ($relative_dir eq '.')
1095 if ($strictness >= $GNITS)
1097 # For Gnits users, this is pretty handy. Look at 15 lines
1098 # in case some explanatory text is desirable.
1099 $output_rules .= ' @if sed 15q $(srcdir)/NEWS | grep -e "$(VERSION)" > /dev/null; then :; else \\
1100 echo "NEWS not updated; not releasing" 1>&2; \\
1108 # Create dist directory.
1111 chmod 777 $(distdir)
1114 # Only run automake in `dist' target if --include-deps not
1115 # specified. That way the recipient of a distribution can run
1116 # "make dist" and not need Automake.
1117 if ($cmdline_use_dependencies)
1121 # We need an absolute path for --output-dir. Thus the
1123 ' distdir=`cd $(distdir) && pwd` \\
1125 && automake --include-deps --output-dir=$$distdir --strictness='
1126 # Set strictness of output.
1127 . $strictness_name . "\n"
1132 # In loop, test for file existence because sometimes a file gets
1133 # included in DISTFILES twice. For example this happens when a
1134 # single source file is used in building more than one program.
1135 # Also, there are situations in which "ln" can fail. For instance
1136 # a file to distribute could actually be a cross-filesystem
1137 # symlink -- this can easily happen if "gettextize" was run on the
1138 # distribution. Note that DISTFILES can contain a wildcard (for
1139 # info files, sigh), so we must use the echo trick.
1140 $output_rules .= ' @for file in `cd $(srcdir) && echo $(DISTFILES)`; do \\
1141 test -f $(distdir)/$$file \\
1142 || ln $(srcdir)/$$file $(distdir)/$$file 2> /dev/null \\
1143 || cp -p $(srcdir)/$$file $(distdir)/$$file; \\
1147 # If we have SUBDIRS, create all dist subdirectories and do
1149 if (&variable_defined ('SUBDIRS'))
1151 # Test for directory existence here because previous automake
1152 # invocation might have created some directories. Note that
1153 # we explicitly set distdir for the subdir make; that lets us
1154 # mix-n-match many automake-using packages into one large
1155 # package, and have "dist" at the top level do the right
1157 $output_rules .= ' for subdir in $(SUBDIRS); do \\
1158 test -d $(distdir)/$$subdir \\
1159 || mkdir $(distdir)/$$subdir \\
1161 chmod 777 $(distdir)/$$subdir; \\
1162 (cd $$subdir && $(MAKE) distdir=../$(distdir)/$$subdir distdir) \\
1168 # If the target `dist-hook' exists, run it now. This allows
1169 # users to do random weird things to the distribution before it is
1171 if (defined $contents{'dist-hook'})
1173 $output_rules .= "\t\$(MAKE) dist-hook\n";
1176 push (@phony, 'distdir');
1179 # Handle 'dist' target.
1182 # Set up maint_charset.
1183 $local_maint_charset = $contents{'MAINT_CHARSET'}
1184 if &variable_defined ('MAINT_CHARSET');
1185 $maint_charset = $local_maint_charset
1186 if $relative_dir eq '.';
1188 if (&variable_defined ('DIST_CHARSET'))
1190 &am_line_error ('DIST_CHARSET',
1191 "DIST_CHARSET defined but no MAINT_CHARSET defined")
1192 if ! $local_maint_charset;
1193 if ($relative_dir eq '.')
1195 $dist_charset = $contents{'DIST_CHARSET'}
1199 &am_line_error ('DIST_CHARSET',
1200 "DIST_CHARSET can only be defined at top level");
1204 # Look for common files that should be included in distribution.
1206 foreach $cfile (@common_files)
1208 if (-f ($relative_dir . "/" . $cfile))
1210 &push_dist_common ($cfile);
1214 # Keys of %dist_common are names of files to distributed. We put
1215 # README first because it then becomes easier to make a
1216 # Usenet-compliant shar file (in these, README must be first).
1217 # FIXME do more ordering of files here.
1219 if (defined $dist_common{'README'})
1221 push (@coms, 'README');
1222 undef $dist_common{'README'};
1224 push (@coms, sort keys %dist_common);
1226 &pretty_print ("DIST_COMMON =", "", @coms);
1227 $output_vars .= "\n";
1230 $output_vars .= &file_contents ('dist-vars');
1232 # Put these things in rules section so it is easier for whoever
1233 # reads Makefile.in.
1234 if ($relative_dir eq '.')
1236 $output_rules .= "\n" . 'distdir = $(PACKAGE)-$(VERSION)' . "\n";
1240 $output_rules .= ("\nsubdir = " . $relative_dir . "\n"
1241 . 'distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)'
1245 # Generate 'dist' target, and maybe dist-shar.
1246 if ($relative_dir eq '.')
1248 # Rule to check whether a distribution is viable.
1249 $output_rules .= '# This target untars the dist file and tries a VPATH configuration. Then
1250 # it guarantees that the distribution is self-contained by making another
1254 $(TAR) zxf $(distdir).tar.gz
1255 mkdir $(distdir)/$(distdir)
1256 cd $(distdir)/$(distdir) \\
1257 && ../configure --srcdir=.. \\
1262 @echo "========================"; \\
1263 echo "$(distdir).tar.gz is ready for distribution"; \\
1264 echo "========================"
1267 $output_rules .= 'dist: distdir' . "\n\t";
1268 $output_rules .= 'chmod -R a+r $(distdir)' . "\n\t";
1269 $output_rules .= '$(TAR) chozf $(distdir).tar.gz $(distdir)';
1270 $output_rules .= "\n\t" . 'rm -rf $(distdir)' . "\n";
1272 if (defined $options{'dist-shar'})
1274 $output_rules .= 'dist-shar: distdir' . "\n\t";
1275 $output_rules .= 'chmod -R a+r $(distdir)' . "\n\t";
1276 $output_rules .= 'shar $(distdir) | gzip > $(distdir).shar.gz';
1277 $output_rules .= "\n\t" . 'rm -rf $(distdir)' . "\n";
1281 # Generate distdir target.
1282 &handle_dist_worker;
1285 # Handle auto-dependency code.
1286 sub handle_dependencies
1288 if ($use_dependencies)
1290 # Include GNU-make-specific auto-dep code.
1291 if ($dir_holds_sources)
1293 &pretty_print ('DEP_FILES =', "", sort keys %dep_files);
1294 $output_rules .= &file_contents ('depend');
1299 # Include any auto-generated deps that are present.
1300 if (-d ($relative_dir . "/.deps") && -f ($relative_dir . "/.deps/.P"))
1303 local ($gpat) = $relative_dir . "/.deps/*.P";
1305 foreach $depfile (<${gpat}>)
1307 if (! open (DEP_FILE, $depfile))
1309 &am_error ("couldn't open \`$depfile': $!");
1312 print "automake: reading $depfile\n" if $verbose;
1314 # Slurp entire file.
1315 $output_rules .= join ('', <DEP_FILE>);
1320 $output_rules .= "\n";
1325 # Handle subdirectories.
1328 if (! &variable_defined ('SUBDIRS'))
1331 ("ud_GNU_GETTEXT in configure.in but SUBDIRS not defined")
1332 if $seen_gettext && $relative_dir eq '.';
1336 &require_file_with_conf_line ($ac_gettext_line, $FOREIGN, 'ABOUT-NLS')
1339 return if ! &variable_defined ('SUBDIRS');
1341 # Make sure each directory mentioned in SUBDIRS actually exists.
1343 foreach $dir (split (/\s+/, $contents{'SUBDIRS'}))
1345 # Skip directories substituted by configure.
1346 next if $dir =~ /^\@.*\@$/;
1347 &am_line_error ('SUBDIRS',
1348 "required directory $relative_dir/$dir does not exist")
1349 if ! -d $relative_dir . '/' . $dir;
1352 $output_rules .= &file_contents ('subdirs');
1354 # Push a bunch of phony targets.
1356 foreach $phonies ('-data', '-exec', 'dirs')
1358 push (@phony, 'install' . $phonies . '-recursive');
1359 push (@phony, 'uninstall' . $phonies . '-recursive');
1361 foreach $phonies ('all', 'check', 'installcheck', 'info', 'dvi')
1363 push (@phony, $phonies . '-recursive');
1365 &push_phony_cleaners ('recursive');
1367 push (@check, "check-recursive");
1368 push (@installcheck, "installcheck-recursive");
1369 push (@info, "info-recursive");
1370 push (@dvi, "dvi-recursive");
1372 $recursive_install = 1;
1375 # Handle remaking and configure stuff.
1376 sub handle_configure
1378 # If SUBDIRS defined, require AC_PROG_MAKE_SET.
1379 &am_line_error ('SUBDIRS', "AC_PROG_MAKE_SET must be used in configure.in")
1380 if &variable_defined ('SUBDIRS') && ! $seen_make_set;
1382 local ($top_reldir);
1383 if ($relative_dir ne '.')
1386 $output_rules .= &file_contents ('remake-subd');
1387 $top_reldir = '../';
1391 if (-f 'aclocal.m4')
1393 $output_vars .= "ACLOCAL = aclocal.m4\n";
1394 &push_dist_common ('aclocal.m4');
1396 $output_rules .= &file_contents ('remake');
1399 ("\`install.sh' is an anachronism; use \`install-sh' instead")
1400 if -f $relative_dir . '/install.sh';
1402 # If we have a configure header, require it.
1405 # FIXME this restriction should be lifted.
1406 # FIXME first see if it is even needed as-is.
1407 &am_conf_line_error ($config_header_line,
1408 "argument to AC_CONFIG_HEADER contains \`/'\n")
1409 if ($config_header =~ /\//);
1411 &require_file_with_conf_line ($config_header_line,
1412 $FOREIGN, $config_header);
1414 # Header defined and in this directory.
1415 if (-f 'acconfig.h')
1417 $output_vars .= "ACCONFIG = acconfig.h\n";
1418 &push_dist_common ('acconfig.h');
1420 if (-f $config_name . '.top')
1422 $output_vars .= "CONFIG_TOP = ${config_name}.top\n";
1423 &push_dist_common ($config_name . '.top');
1425 if (-f $config_name . '.bot')
1427 $output_vars .= "CONFIG_BOT = ${config_name}.bot\n";
1428 &push_dist_common ($config_name . '.bot');
1431 &require_file_with_conf_line ($config_header_line, $FOREIGN,
1434 $output_rules .= &file_contents ('remake-hdr');
1435 $output_vars .= "CONFIG_HEADER_IN = ${config_header}\n";
1441 # Set location of mkinstalldirs.
1442 if ($config_aux_dir ne '.' && $config_aux_dir ne '')
1444 $output_vars .= 'mkinstalldirs = ' . $config_aux_dir;
1448 $output_vars .= 'mkinstalldirs = $(top_srcdir)';
1450 $output_vars .= '/mkinstalldirs' . "\n";
1452 &am_line_error ('CONFIG_HEADER',
1453 "\`CONFIG_HEADER' is an anachronism; now determined from \`configure.in'")
1454 if &variable_defined ('CONFIG_HEADER');
1456 # Generate CONFIG_HEADER define, and define interally.
1457 $output_vars .= "CONFIG_HEADER = ${top_builddir}/${config_name}\n"
1459 $contents{'CONFIG_HEADER'} = "${top_builddir}/${config_name}"
1462 # Now look for other files in this directory which must be remade
1463 # by config.status, and generate rules for them.
1464 local ($file, $local, $input);
1465 foreach $file (@other_input_files)
1467 # Skip files not in this directory, any Makefile, and the
1468 # config header. These last two must be handled specially.
1469 next unless &dirname ($file) eq $relative_dir;
1470 next if $file eq $top_builddir . '/' . $config_name;
1471 ($local = $file) =~ s/^.*\///;
1472 next if $local eq 'Makefile';
1474 if ($local =~ /^(.*):(.*)$/)
1476 # This is the ":" syntax of AC_OUTPUT.
1483 $input = $local . '.in';
1485 # FIXME when using autoconf ":" syntax, should we set CONFIG_FILES
1487 $output_rules .= ($local . ': '
1488 . '$(top_builddir)/config.status ' . $input . "\n"
1490 . 'cd $(top_builddir) && CONFIG_FILES='
1491 . ($relative_dir eq '.' ? '' : '$(subdir)/')
1492 . '$@ CONFIG_HEADERS= ./config.status'
1495 &require_file_with_conf_line ($ac_output_line, $FOREIGN,
1503 &am_install_var ('header', 'HEADERS', 'include',
1504 'oldinclude', 'pkginclude',
1510 return if ! $seen_gettext || $relative_dir ne '.';
1512 # As of 0.10.6, gettext still wants @INTLSUB@ and @POSUB@ in
1513 # SUBDIRS. This is going to change in a future version. So for
1514 # now we simply do no checking.
1515 if (0 && &variable_defined ('SUBDIRS'))
1519 "ud_GNU_GETTEXT in configure.in but \`po' not in SUBDIRS")
1520 if $contents{'SUBDIRS'} !~ /\bpo\b/;
1523 "ud_GNU_GETTEXT in configure.in but \`intl' not in SUBDIRS")
1524 if $contents{'SUBDIRS'} !~ /\bintl\b/;
1527 # Ensure that each language in ALL_LINGUAS has a .po file, and
1528 # each po file is mentioned in ALL_LINGUAS.
1531 local (%linguas) = ();
1532 grep ($linguas{$_} = 1, split (/\s+/, $all_linguas));
1539 &am_line_error ($all_linguas_line,
1540 ("po/$_.po exists but \`$_' not in \`ALL_LINGUAS'"))
1544 foreach (keys %linguas)
1546 &am_line_error ($all_linguas_line,
1547 "$_ in \`ALL_LINGUAS' but po/$_.po does not exist")
1553 &am_error ("ud_GNU_GETTEXT in configure.in but \`ALL_LINGUAS' not defined");
1557 # Handle footer elements.
1560 if ($contents{'SOURCES'})
1562 &pretty_print ('SOURCES =', "",
1563 split (/\s+/, $contents{'SOURCES'}));
1565 if ($contents{'OBJECTS'})
1567 &pretty_print ('OBJECTS =', "",
1568 split (/\s+/, $contents{'OBJECTS'}));
1570 if ($contents{'SOURCES'} || $contents{'OBJECTS'})
1572 $output_vars .= "\n";
1575 if (defined $contents{'SUFFIXES'})
1577 push (@suffixes, '$(SUFFIXES)');
1580 $output_trailer .= ".SUFFIXES:\n";
1583 $output_trailer .= ".SUFFIXES: " . join (' ', @suffixes) . "\n";
1585 $output_trailer .= &file_contents ('footer');
1588 # Deal with installdirs target.
1589 sub handle_installdirs
1591 # GNU Makefile standards recommend this.
1592 $output_rules .= ("installdirs:"
1593 . ($recursive_install
1594 ? " installdirs-recursive\n"
1596 push (@phony, 'installdirs');
1599 &pretty_print_rule ("\t" . '$(mkinstalldirs) ', "\t\t",
1602 $output_rules .= "\n";
1605 # There are several targets which need to be merged. This is because
1606 # their complete definition is compiled from many parts. Note that we
1607 # avoid double colon rules, otherwise we'd use them instead.
1608 sub handle_merge_targets
1610 push (@all, 'Makefile');
1611 push (@all, $config_name)
1612 if $config_name && &dirname ($config_name) eq $relative_dir;
1614 &do_one_merge_target ('info', @info);
1615 &do_one_merge_target ('dvi', @dvi);
1617 if (! &variable_defined ('SUBDIRS') || $relative_dir ne '.')
1619 # 'check' must depend on 'all', but not at top level.
1621 unshift (@check, 'all');
1622 unshift (@install, 'all');
1624 &do_one_merge_target ('check', @check);
1625 &do_one_merge_target ('installcheck', @installcheck);
1627 # Handle the various install targets specially. We do this so
1628 # that (eg) "make install-exec" will run "install-exec-recursive"
1629 # if required, but "make install" won't run it twice. Step one is
1630 # to see if the user specified local versions of any of the
1631 # targets we handle. "all" is treated as one of these since
1632 # "install" can run it.
1633 push (@install_exec, 'install-exec-local')
1634 if defined $contents{'install-exec-local'};
1635 push (@install_data, 'install-data-local')
1636 if defined $contents{'install-data-local'};
1637 push (@uninstall, 'uninstall-local')
1638 if defined $contents{'uninstall-local'};
1639 push (@all, 'all-local')
1640 if defined $contents{'all-local'};
1642 if (defined $contents{'install-local'})
1644 &am_line_error ('install-local',
1645 "use \`install-data' or \`install-exec', not \`install'");
1648 # Step two: if we are doing recursive makes, write out the
1649 # appropriate rules.
1651 if ($recursive_install)
1653 push (@install, 'install-recursive');
1657 local (@hackall) = ();
1658 if ($config_name && &dirname ($config_name) eq $relative_dir)
1661 # This is kind of a hack, but I couldn't see a better
1662 # way to handle it. In this particular case, we need
1663 # to make sure config.h is built before we recurse.
1664 # We can't do this by changing the order of
1665 # dependencies to the "all" because that breaks when
1666 # using parallel makes. Instead we handle things
1668 $output_rules .= ('all-recursive-hack: $(CONFIG_HEADER)'
1669 . "\n\t" . '$(MAKE) all-recursive'
1671 push (@hackall, 'all-recursive-hack');
1672 push (@phony, 'all-recursive-hack');
1676 push (@hackall, 'all-recursive');
1679 $output_rules .= ('all-am: '
1683 push (@all, 'all-am');
1684 push (@phony, 'all-am');
1688 @all = ('all-recursive');
1692 $output_rules .= ('install-exec-am: '
1693 . join (' ', @install_exec)
1695 @install_exec = ('install-exec-recursive', 'install-exec-am');
1696 push (@install, 'install-exec-am');
1697 push (@phony, 'install-exec-am');
1701 @install_exec = ('install-exec-recursive');
1705 $output_rules .= ('install-data-am: '
1706 . join (' ', @install_data)
1708 @install_data = ('install-data-recursive', 'install-data-am');
1709 push (@install, 'install-data-am');
1710 push (@phony, 'install-data-am');
1714 @install_data = ('install-data-recursive');
1718 $output_rules .= ('uninstall-am: '
1719 . join (' ', @uninstall)
1721 @uninstall = ('uninstall-recursive', 'uninstall-am');
1722 push (@phony, 'uninstall-am');
1726 @uninstall = ('uninstall-recursive');
1730 # Step three: print definitions users can use. Code below knows
1731 # that install-exec is done before install-data, beware.
1732 $output_rules .= ("install-exec: "
1733 . join (' ', @install_exec)
1735 if (defined $contents{'install-exec-hook'})
1737 $output_rules .= "\t" . '$(MAKE) install-exec-hook' . "\n";
1739 $output_rules .= "\n";
1740 push (@install, 'install-exec') if !$recursive_install;
1741 push (@phony, 'install-exec');
1743 $output_rules .= ("install-data: "
1744 . join (' ', @install_data)
1746 if (defined $contents{'install-data-hook'})
1748 $output_rules .= "\t" . '$(MAKE) install-data-hook' . "\n";
1750 $output_rules .= "\n";
1751 push (@install, 'install-data') if !$recursive_install;
1752 push (@phony, 'install-data');
1754 # If no dependencies for 'install', add 'all'. Why? That way
1755 # "make install" at top level of distclean'd distribution won't
1756 # fail because stuff in 'lib' fails to build.
1757 if (! @install || ($#install == 1
1758 && $install[0] eq 'install-exec'
1759 && $install[1] eq 'install-data'))
1761 push (@install, 'all');
1763 $output_rules .= ('install: '
1764 . join (' ', @install)
1765 # Use "@:" as empty command so nothing prints.
1769 . join (' ', @uninstall)
1771 push (@phony, 'install', 'uninstall');
1773 $output_rules .= ('all: '
1776 push (@phony, 'all');
1778 # Generate the new 'install-strip' target.
1779 $output_rules .= ("install-strip:\n\t"
1780 . '$(MAKE) INSTALL_PROGRAM=\'$(INSTALL_PROGRAM) -s\' install'
1784 # Helper for handle_merge_targets.
1785 sub do_one_merge_target
1787 local ($name, @values) = @_;
1789 if (defined $contents{$name . '-local'})
1791 # User defined local form of target. So include it.
1792 push (@values, $name . '-local');
1793 push (@phony, $name . '-local');
1796 $output_rules .= $name . ":";
1799 $output_rules .= ' ' . join (' ', @values);
1801 $output_rules .= "\n\n";
1802 push (@phony, $name);
1805 # Handle all 'clean' targets.
1808 push (@clean, 'generic');
1809 $output_rules .= &file_contents ('clean');
1810 &push_phony_cleaners ('generic');
1812 local ($target) = $recursive_install ? 'clean-am' : 'clean';
1813 &do_one_clean_target ($target, 'mostly', '', @clean);
1814 &do_one_clean_target ($target, '', 'mostly', @clean);
1815 &do_one_clean_target ($target, 'dist', '', @clean);
1816 &do_one_clean_target ($target, 'maintainer-', 'dist', @clean);
1818 push (@phony, 'clean', 'mostlyclean', 'distclean', 'maintainer-clean');
1821 if ($recursive_install)
1823 @deps = ('am', 'recursive');
1824 &do_one_clean_target ('', 'mostly', '', @deps);
1825 &do_one_clean_target ('', '', '', @deps);
1826 &do_one_clean_target ('', 'dist', '', @deps);
1827 &do_one_clean_target ('', 'maintainer-', '', @deps);
1831 # Helper for handle_clean.
1832 sub do_one_clean_target
1834 local ($target, $name, $last_name, @deps) = @_;
1836 # Special case: if target not passed, then don't generate
1837 # dependency on next "lower" clean target (eg no
1838 # clean<-mostlyclean derivation). In this case the target is
1839 # implicitly known to be 'clean'.
1840 local ($flag) = $target;
1841 $target = 'clean' if ! $flag;
1843 grep (($_ = $name . 'clean-' . $_) && 0, @deps);
1846 if ($last_name || $name ne 'mostly')
1848 push (@deps, $last_name . $target . " ");
1851 # FIXME not sure if I like the tabs here.
1852 &pretty_print_rule ($name . $target . ": ", "\t\t", @deps);
1854 # FIXME shouldn't we really print these messages before running
1856 if ($name . $target eq 'maintainer-clean')
1858 # Print a special warning.
1860 ("\t\@echo \"This command is intended for maintainers to use;\"\n"
1861 . "\t\@echo \"it deletes files that may require special "
1862 . "tools to rebuild.\"\n");
1864 $output_rules .= "\trm -f config.status\n"
1865 if $relative_dir eq '.';
1867 elsif ($name . $target eq 'distclean')
1869 $output_rules .= "\trm -f config.status\n";
1871 $output_rules .= "\n";
1874 # Handle .PHONY target.
1877 &pretty_print_rule ('.PHONY:', "", @phony);
1878 $output_rules .= "\n";
1881 # Handle TESTS variable.
1884 return if ! &variable_defined ('TESTS');
1886 &push_dist_common (split (/\s+/, $contents{'TESTS'}));
1887 push (@check, 'check-TESTS');
1888 push (@phony, 'check-TESTS');
1889 # FIXME use $(SHELL) here? That is what Ulrich suggests. Maybe a
1890 # new macro, $(TEST_SHELL), a la $(CONFIG_SHELL)? For now we just
1891 # execute the file directly; this allows test files which are
1892 # compiled -- a possibly useful feature.
1893 $output_rules .= 'check-TESTS: $(TESTS)
1894 @failed=0; all=0; \\
1895 srcdir=$(srcdir); export srcdir; \\
1896 for tst in $(TESTS); do \\
1897 all=`expr $$all + 1`; \\
1898 if test -f $$tst; then dir=.; \\
1899 else dir="$(srcdir)"; fi; \\
1900 if $$dir/$$tst; then \\
1901 echo "PASS: $$tst"; \\
1903 failed=`expr $$failed + 1`; \\
1904 echo "FAIL: $$tst"; \\
1907 if test "$$failed" -eq 0; then \\
1908 echo "========================"; \\
1909 echo "All $$all tests passed"; \\
1910 echo "========================"; \\
1912 echo "$$failed of $$all tests failed"; \\
1917 ################################################################
1919 # Scan configure.in for interesting things.
1920 # FIXME ensure VERSION, PACKAGE are set.
1923 open (CONFIGURE, 'configure.in')
1924 || die "automake: couldn't open \`configure.in': $!\n";
1925 print "automake: reading configure.in\n" if $verbose;
1927 # Reinitialize libsources here. This isn't really necessary,
1928 # since we currently assume there is only one configure.in. But
1929 # that won't always be the case.
1932 local ($in_ac_output, @make_list) = 0;
1933 local ($libobj_iter);
1936 # Remove comments from current line.
1940 # Populate libobjs array.
1941 if (/AC_FUNC_ALLOCA/)
1943 $libsources{'alloca.c'} = 1;
1945 elsif (/AC_FUNC_GETLOADAVG/)
1947 $libsources{'getloadavg.c'} = 1;
1949 elsif (/AC_FUNC_MEMCMP/)
1951 $libsources{'memcmp.c'} = 1;
1953 elsif (/AC_STRUCT_ST_BLOCKS/)
1955 $libsources{'fileblocks.c'} = 1;
1957 elsif (/(AC|fp)_FUNC_FNMATCH/)
1959 # AC_FUNC_FNMATCH is just wishful thinking at this point.
1960 $libsources{'fnmatch.c'} = 1;
1962 elsif (/AC_REPLACE_FUNCS\s*\((.*)\)/)
1964 foreach (split (/\s+/, $1))
1966 $libsources{$_ . '.c'} = 1;
1969 elsif (/AC_REPLACE_GNU_GETOPT/)
1971 $libsources{'getopt.c'} = 1;
1972 $libsources{'getopt1.c'} = 1;
1974 elsif (/LIBOBJS="(.*)\s+\$LIBOBJS"/
1975 || /LIBOBJS="\$LIBOBJS\s+(.*)"/)
1977 foreach $libobj_iter (split (/\s+/, $1))
1979 if ($libobj_iter =~ /^(.*)\.o$/)
1981 $libsources{$1 . '.c'} = 1;
1986 # Process the AC_OUTPUT macro.
1987 if (! $in_ac_output && s/AC_OUTPUT\s*\(\[?//)
1990 $ac_output_line = $.;
1994 $in_ac_output = 0 if s/[\]\),].*$//;
1996 # Look at potential Makefile.am's.
2002 push (@make_list, $_);
2006 push (@other_input_files, $_);
2011 if (/AC_CONFIG_AUX_DIR\(([^)]+)\)/)
2013 @config_aux_path = $1;
2016 # Check for ansi2knr.
2017 $fp_c_prototypes = 1 if /fp_C_PROTOTYPES/;
2019 # Check for NLS support.
2020 if (/ud_GNU_GETTEXT/)
2023 $ac_gettext_line = $.;
2026 # Look for ALL_LINGUAS.
2027 if (/ALL_LINGUAS="(.*)"$/ || /ALL_LINGUAS=(.*)$/)
2031 $all_linguas_line = $.;
2034 # Handle configuration headers.
2035 if (/AC_CONFIG_HEADER\s*\((.*)\)/)
2037 $config_header_line = $.;
2039 if ($config_name =~ /^([^:]+):(.+)$/)
2042 $config_header = $2;
2046 $config_header = $config_name . '.in';
2050 $seen_canonical = 1 if /AC_CANONICAL_(HOST|SYSTEM)/;
2051 $seen_canonical = 1 if /AC_CHECK_TOOL/;
2052 $seen_path_xtra = 1 if /AC_PATH_XTRA/;
2054 # Sometimes it is desirable to explicitly set YACC. For
2055 # instance some people don't want to use bison.
2056 $seen_prog_yacc = 1 if (/AC_PROG_YACC/
2057 || /AC_SUBST\(YACC\)/
2058 || /AC_(PATH|CHECK)_PROGS?\(YACC/);
2060 # Some things required by Automake.
2061 $seen_make_set = 1 if /AC_PROG_MAKE_SET/;
2062 $seen_prog_install = 1 if ! $seen_prog_install && /AC_PROG_INSTALL/;
2063 $seen_prog_install = 2 if ! $seen_prog_install && /fp_PROG_INSTALL/;
2064 $seen_arg_prog = 1 if /AC_ARG_PROGRAM/;
2065 $seen_ranlib = 1 if /AC_PROG_RANLIB/;
2066 $seen_maint_mode = 1 if /jm_MAINTAINER_MODE/;
2068 if (/AC_PROG_LIBTOOL/ || /gm_PROG_LIBTOOL/)
2076 # Set input files if not specified by user.
2077 @input_files = @make_list if (! @input_files);
2081 # Look for some files we need. Always check for these. This
2082 # check must be done for every run, even those where we are only
2083 # looking at a subdir Makefile. We must set relative_dir so that
2084 # the file-finding machinery works.
2085 local ($relative_dir) = '.';
2086 &require_config_file ($FOREIGN, 'install-sh', 'mkinstalldirs');
2089 ################################################################
2091 # Do any extra checking for GNU standards.
2092 sub check_gnu_standards
2094 if ($relative_dir eq '.')
2096 # In top level (or only) directory.
2097 &require_file ($GNU, 'INSTALL', 'NEWS', 'README', 'COPYING',
2098 'AUTHORS', 'ChangeLog');
2102 # Do any extra checking for GNITS standards.
2103 sub check_gnits_standards
2105 if ($strictness >= $GNITS && -f $relative_dir . '/COPYING.LIB')
2108 ("\`${relative_dir}/COPYING.LIB' disallowed by Gnits standards");
2111 if ($relative_dir eq '.')
2113 # In top level (or only) directory.
2114 &require_file ($GNITS, 'THANKS');
2118 ################################################################
2120 # Pretty-print something. HEAD is what should be printed at the
2121 # beginning of the first line, FILL is what should be printed at the
2122 # beginning of every subsequent line.
2123 sub pretty_print_internal
2125 local ($head, $fill, @values) = @_;
2127 local ($column) = length ($head);
2128 local ($result) = $head;
2130 # Fill length is number of characters. However, each Tab
2131 # character counts for eight. So we count the number of Tabs and
2133 local ($fill_length) = length ($fill);
2134 $fill_length += 7 * ($fill =~ tr/\t/\t/d);
2139 # "71" because we also print a space.
2140 if ($column + length ($_) > 71)
2142 $result .= " \\\n" . $fill;
2143 $column = $fill_length;
2147 $result .= ' ' unless ($bol);
2149 $column += length ($_) + 1;
2157 # Pretty-print something and append to output_vars.
2160 $output_vars .= &pretty_print_internal (@_);
2163 # Pretty-print something and append to output_rules.
2164 sub pretty_print_rule
2166 $output_rules .= &pretty_print_internal (@_);
2170 ################################################################
2172 # See if a variable exists.
2173 sub variable_defined
2176 if (defined $targets{$var})
2178 &am_line_error ($var, "\`$var' is target; expected variable");
2180 return (defined $contents{$var} && ! defined $targets{$var});
2183 # Read Makefile.am and set up %contents. Simultaneously copy lines
2184 # from Makefile.am into $output_trailer or $output_vars as
2185 # appropriate. NOTE we put rules in the trailer section. We want
2186 # user rules to come after our generated stuff.
2189 local ($amfile) = @_;
2191 # Compute relative location of the top object directory.
2192 local (@topdir) = ();
2193 foreach (split (/\//, $relative_dir))
2195 next if $_ eq '.' || $_ eq '';
2202 push (@topdir, '..');
2205 @topdir = ('.') if ! @topdir;
2207 $top_builddir = join ('/', @topdir);
2209 ($build_rx = $top_builddir) =~ s/(\W)/\\$1/g;
2210 local ($header_vars) =
2211 &file_contents_with_transform
2212 ('s/\@top_builddir\@/' . $build_rx . '/g',
2215 open (AM_FILE, $amfile) || die "automake: couldn't open \`$amfile': $!\n";
2216 print "automake: reading $amfile\n" if $verbose;
2218 $output_vars .= ("# $in_file_name generated automatically by automake "
2219 . $VERSION . " from $am_file_name\n");
2221 # Generate copyright for generated Makefile.in.
2222 $output_vars .= $gen_copyright;
2224 local ($saw_bk) = 0;
2225 local ($was_rule) = 0;
2226 local ($spacing) = '';
2227 local ($comment) = '';
2228 local ($last_var_name) = '';
2233 if (/$IGNORE_PATTERN/o)
2235 # Merely delete comments beginning with two hashes.
2237 elsif (/$WHITE_PATTERN/o)
2239 # Stick a single white line before the incoming macro or rule.
2243 elsif (/$COMMENT_PATTERN/o)
2245 # Stick comments before the incoming macro or rule. Make
2246 # sure a blank line preceeds comments.
2247 $spacing = "\n" unless $blank;
2248 $comment .= $spacing . $_;
2257 $output_vars .= $comment . "\n" . $header_vars;
2261 local ($is_ok_macro);
2265 unless substr ($_, -1, 1) eq "\n";
2267 $_ =~ s/\@MAINT\@//g
2268 unless $seen_maint_mode;
2270 if (/$IGNORE_PATTERN/o)
2272 # Merely delete comments beginning with two hashes.
2274 elsif (/$WHITE_PATTERN/o)
2276 # Stick a single white line before the incoming macro or rule.
2279 elsif (/$COMMENT_PATTERN/o)
2281 # Stick comments before the incoming macro or rule.
2282 $comment .= $spacing . $_;
2289 $output_trailer .= $_;
2296 # Chop newline and backslash if this line is
2297 # continued. FIXME maybe ensure trailing whitespace
2301 $contents{$last_var_name} .= $_;
2304 elsif (/$RULE_PATTERN/o)
2306 # warn "** Saw rule .$1.\n";
2309 # Value here doesn't matter; for targets we only note
2313 $content_lines{$1} = $.;
2314 $output_trailer .= $comment . $spacing . $_;
2315 $comment = $spacing = '';
2318 elsif (($is_ok_macro = /$MACRO_PATTERN/o)
2319 || /$BOGUS_MACRO_PATTERN/o)
2321 # Found a macro definition.
2323 $last_var_name = $1;
2324 if (substr ($2, -1) eq "\\")
2326 $contents{$1} = substr ($2, 0, length ($2) - 1);
2332 $content_lines{$1} = $.;
2333 $output_vars .= $comment . $spacing . $_;
2334 $comment = $spacing = '';
2338 &am_line_error ($., "bad macro name \`$1'")
2343 # This isn't an error; it is probably a continued rule.
2344 # In fact, this is what we assume.
2346 $output_trailer .= $comment . $spacing . $_;
2347 $comment = $spacing = '';
2354 $output_trailer .= $comment;
2357 ################################################################
2359 sub initialize_global_constants
2361 # Associative array of standard directory names. Entry is TRUE if
2362 # corresponding directory should be installed during
2363 # 'install-exec' phase.
2381 # Helper text for dealing with man pages.
2382 $install_man_format =
2383 ' @sect=@SECTION@; \\
2384 inst=`echo "@MANBASE@" | sed \'$(transform)\'`.@FULLSECT@; \\
2385 echo installing @MAN@ as $(mandir)/man$$sect/$$inst; \\
2386 $(INSTALL_DATA) $(srcdir)/@MAN@ $(mandir)/man$$sect/$$inst
2389 $uninstall_man_format =
2390 ' inst=`echo "@MANBASE@" | sed \'$(transform)\'`.@FULLSECT@; \\
2391 rm -f $(mandir)/man@SECTION@/$$inst
2394 # Commonly found files we look for and automatically include in
2398 "README", "THANKS", "TODO", "NEWS", "COPYING", "COPYING.LIB",
2399 "INSTALL", "ABOUT-NLS", "ChangeLog", "configure", "configure.in",
2400 "config.guess", "config.sub", "AUTHORS", "BACKLOG", "ABOUT-GNU",
2401 "libversion.in", "mdate-sh"
2404 # Commonly used files we auto-include, but only sometimes.
2407 "version.texi", "aclocal.m4", "acconfig.h", "config.h.top",
2408 "config.h.bot", "stamp-h.in", "ansi2knr.c",
2409 "ansi2knr.1", 'stamp-vti', "mkinstalldirs", "install-sh"
2413 --amdir=DIR directory storing config files
2414 --foreign same as --strictness=foreign
2415 --gnits same as --strictness=gnits
2416 --gnu same as --strictness=gnu
2417 --help print this help, then exit
2418 -i, --include-deps include generated dependencies in Makefile.in
2419 -a, --add-missing add missing standard files to package
2420 -o DIR, --output-dir=DIR
2421 put generated Makefile.in's into DIR
2422 -s LEVEL, --strictness=LEVEL
2423 set strictness level. LEVEL is foreign, gnu, gnits
2424 -v, --verbose verbosely list files processed
2425 --version print version number, then exit\n";
2427 # Copyright on generated Makefile.ins.
2429 # Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
2430 # This Makefile.in is free software; the Free Software Foundation
2431 # gives unlimited permission to copy, distribute and modify it.
2435 # (Re)-Initialize per-Makefile.am variables.
2436 sub initialize_per_input
2438 # These two variables are used when generating each Makefile.in.
2439 # They hold the Makefile.in until it is ready to be printed.
2442 $output_trailer = '';
2444 # Suffixes found during a run.
2447 # This holds the contents of a Makefile.am, as parsed by
2451 # This holds the names which are targets. These also appear in
2455 # This holds the line numbers at which various elements of
2456 # %contents are defined.
2457 %content_lines = ();
2459 # This holds the "relative directory" of the current Makefile.in.
2460 # Eg for src/Makefile.in, this is "src".
2463 # Directory where output files go. Actually, output files are
2464 # relative to this directory.
2465 $output_directory = '.';
2467 # This holds a list of files that are included in the
2471 # List of dependencies for the obvious targets.
2486 # These are pretty obvious, too. They are used to define the
2487 # SOURCES and OBJECTS variables.
2491 # TRUE if current directory holds any C source files. (Actually
2492 # holds object extension, but this information is encapsulated in
2493 # the function get_object_extension).
2494 $dir_holds_sources = '';
2496 # TRUE if install targets should work recursively.
2497 $recursive_install = 0;
2502 # Strictness levels.
2503 $strictness = $default_strictness;
2504 $strictness_name = $default_strictness_name;
2506 # Options from AUTOMAKE_OPTIONS.
2509 # Whether or not dependencies are handled. Can be further changed
2510 # in handle_options.
2511 $use_dependencies = $cmdline_use_dependencies;
2514 $local_maint_charset = $maint_charset;
2518 ################################################################
2520 # Return contents of a file from $am_dir, automatically skipping
2521 # macros or rules which are already known. Runs command on each line
2522 # as it is read; this command can modify $_.
2523 sub file_contents_with_transform
2525 local ($command, $basename) = @_;
2526 local ($file) = $am_dir . '/' . $basename . '.am';
2528 open (FC_FILE, $file)
2529 || die "automake: installation error: cannot open \`$file'\n";
2531 # print "automake: reading $file\n" if $verbose;
2533 local ($was_rule) = 0;
2534 local ($result_vars) = '';
2535 local ($result_rules) = '';
2536 local ($comment) = '';
2537 local ($spacing) = "\n";
2538 local ($skipping) = 0;
2542 $_ =~ s/\@MAINT\@//g
2543 unless $seen_maint_mode;
2547 if (/$IGNORE_PATTERN/o)
2549 # Merely delete comments beginning with two hashes.
2551 elsif (/$WHITE_PATTERN/o)
2553 # Stick a single white line before the incoming macro or rule.
2556 elsif (/$COMMENT_PATTERN/o)
2558 # Stick comments before the incoming macro or rule.
2559 $comment .= $spacing . $_;
2566 $result_rules .= $_ if ! $skipping;
2570 $result_vars .= $_ if ! $skipping;
2574 elsif (/$RULE_PATTERN/o)
2576 # warn "** Found rule .$1.\n";
2579 $skipping = defined $contents{$1};
2580 # warn "** Skip $skipping\n" if $skipping;
2581 $result_rules .= $comment . $spacing . $_ if ! $skipping;
2582 $comment = $spacing = '';
2585 elsif (/$MACRO_PATTERN/o)
2587 # warn "** Found macro .$1.\n";
2588 # Found a variable reference.
2590 $skipping = defined $contents{$1};
2591 # warn "** Skip $skipping\n" if $skipping;
2592 $result_vars .= $comment . $spacing . $_ if ! $skipping;
2593 $comment = $spacing = '';
2598 # This isn't an error; it is probably a continued rule.
2599 # In fact, this is what we assume.
2601 $result_rules .= $comment . $spacing . $_ if ! $skipping;
2602 $comment = $spacing = '';
2608 return $result_vars . $result_rules . $comment;
2611 # Like file_contents_with_transform, but no transform.
2614 return &file_contents_with_transform ('', @_);
2617 # Handle `where_HOW' variable magic. Does all lookups, generates
2618 # install code, and possibly generates code to define the primary
2619 # variable. The first argument is the name of the .am file to munge,
2620 # the second argument is the primary variable (eg HEADERS), and all
2621 # subsequent arguments are possible installation locations. Returns
2622 # list of all values of all _HOW targets.
2624 # FIXME this should be rewritten to be cleaner. It should be broken
2625 # up into multiple functions.
2627 # Usage is: am_install_var (OPTION..., file, HOW, where...)
2632 local ($do_all, $do_clean) = (1, 0);
2635 if ($args[0] eq '-clean')
2639 elsif ($args[0] eq '-no-all')
2643 elsif ($args[0] !~ /^-/)
2649 local ($file, $primary, @prefixes) = @args;
2652 local (@result) = ();
2654 # Now that configure substitutions are allowed in where_HOW
2655 # variables, it is an error to actually define the primary.
2656 &am_line_error ($primary, "\`$primary' is an anachronism")
2657 if &variable_defined ($primary);
2660 # Look for misspellings. It is an error to have a variable ending
2661 # in a "reserved" suffix whose prefix is unknown, eg
2662 # "bni_PROGRAMS". However, unusual prefixes are allowed if a
2663 # variable of the same name (with "dir" appended) exists. For
2664 # instance, if the variable "zardir" is defined, then
2665 # "zar_PROGRAMS" becomes valid. This is to provide a little extra
2666 # flexibility in those cases which need it. Perhaps it should be
2667 # disallowed in the Gnits case? The problem is, sometimes it is
2668 # useful to put things in a subdir of eg pkgdatadir, perhaps even
2670 local (%valid, $varname);
2671 grep ($valid{$_} = 0, @prefixes);
2672 $valid{'EXTRA'} = 0;
2673 foreach $varname (keys %contents)
2675 if ($varname =~ /^(.*)_$primary$/)
2677 if (! defined $valid{$1} && ! &variable_defined ($1 . 'dir'))
2679 &am_line_error ($varname, "invalid variable \"$varname\"");
2683 # Ensure all extended prefixes are actually used.
2689 local ($clean_file) = $file . '-clean';
2692 foreach $X (keys %valid)
2694 $one_name = $X . '_' . $primary;
2695 if (&variable_defined ($one_name))
2697 # Append actual contents of where_PRIMARY variable to
2700 foreach $rcurs (split (/\s+/, $contents{$one_name}))
2702 # Skip configure substitutions. Possibly bogus.
2703 next if $rcurs =~ /^\@.*\@$/;
2704 push (@result, $rcurs);
2707 # "EXTRA" shouldn't be used when generating clean targets,
2708 # @all, or install targets.
2709 next if $X eq 'EXTRA';
2714 &file_contents_with_transform ('s/\@DIR\@/' . $X . '/go',
2717 push (@clean, $X . $primary);
2718 &push_phony_cleaners ($X . $primary);
2723 push (@check, '$(' . $one_name . ')');
2727 push (@used, '$(' . $one_name . ')');
2729 if ($X eq 'noinst' || $X eq 'check')
2731 # Objects which don't get installed by default.
2736 &file_contents_with_transform ('s/\@DIR\@/' . $X . '/go',
2739 push (@uninstall, 'uninstall-' . $X . $primary);
2740 push (@phony, 'uninstall-' . $X . $primary);
2741 push (@installdirs, '$(' . $X . 'dir)');
2742 if ($exec_dir_p{$X})
2744 push (@install_exec, 'install-' . $X . $primary);
2745 push (@phony, 'install-' . $X . $primary);
2749 push (@install_data, 'install-' . $X . $primary);
2750 push (@phony, 'install-' . $X . $primary);
2758 &pretty_print ($primary . ' =', '', @used);
2759 $output_vars .= "\n";
2762 # Push here because PRIMARY might be configure time determined.
2763 push (@all, '$(' . $primary . ')')
2764 if $do_all && @used;
2770 ################################################################
2772 # This variable is local to the "require file" set of functions.
2773 @require_file_paths = ();
2775 # Verify that the file must exist in the current directory. Usage:
2776 # require_file (isconfigure, line_number, strictness, file) strictness
2777 # is the strictness level at which this file becomes required. Must
2778 # set require_file_paths before calling this function.
2779 # require_file_paths is set to hold a single directory (the one in
2780 # which the first file was found) before return.
2781 sub require_file_internal
2783 local ($is_configure, $line, $mystrict, @files) = @_;
2784 local ($file, $fullfile);
2785 local ($found_it, $errfile, $errdir);
2788 foreach $file (@files)
2791 foreach $dir (@require_file_paths)
2795 $fullfile = $relative_dir . "/" . $file;
2796 $errdir = $relative_dir unless $errdir;
2800 $fullfile = $dir . "/" . $file;
2801 $errdir = $dir unless $errdir;
2804 # Use different name for "error filename". Otherwise on
2805 # an error the bad file will be reported as eg
2806 # `../../install-sh' when using the default
2808 $errfile = $errdir . '/' . $file;
2813 &push_dist_common ($file) if $dir eq $relative_dir;
2821 # Prune the path list.
2822 @require_file_paths = $save_dir;
2826 if ($strictness >= $mystrict)
2828 # Only install missing files according to our desired
2830 if ($add_missing && -f ($am_dir . '/' . $file))
2832 # Install the missing file. Symlink if we can, copy
2834 if ($symlink_exists)
2836 symlink ($am_dir . '/' . $file, $errfile);
2840 system ('cp', $am_dir . '/' . $file, $errfile);
2843 # FIXME this is a hack. Should have am_warn.
2844 local ($save) = $exit_status;
2849 "required file \"$errfile\" not found; installing");
2855 "required file \"$errfile\" not found; installing");
2857 $exit_status = $save;
2861 # Only an error if strictness constraint violated.
2865 ($line, "required file \"$errfile\" not found");
2870 ($line, "required file \"$errfile\" not found");
2878 # Like require_file_with_line, but error messages refer to
2879 # configure.in, not the current Makefile.am.
2880 sub require_file_with_conf_line
2882 @require_file_paths = '.';
2883 &require_file_internal (1, @_);
2886 sub require_file_with_line
2888 @require_file_paths = '.';
2889 &require_file_internal (0, @_);
2894 @require_file_paths = '.';
2895 &require_file_internal (0, '', @_);
2898 # Require a file that is also required by Autoconf. Looks in
2899 # configuration path, as specified by AC_CONFIG_AUX_DIR.
2900 sub require_config_file
2902 @require_file_paths = @config_aux_path;
2903 &require_file_internal (0, '', @_);
2904 local ($dir) = $require_file_paths[0];
2905 @config_aux_path = @require_file_paths;
2908 $config_aux_dir = '.';
2912 $config_aux_dir = '$(top_srcdir)/' . $dir;
2916 # Assumes that the line number is in Makefile.am.
2917 sub require_conf_file_with_line
2919 @require_file_paths = @config_aux_path;
2920 &require_file_internal (0, @_);
2921 local ($dir) = $require_file_paths[0];
2922 @config_aux_path = @require_file_paths;
2925 $config_aux_dir = '.';
2929 $config_aux_dir = '$(top_srcdir)/' . $dir;
2933 # Assumes that the line number is in Makefile.am.
2934 sub require_conf_file_with_conf_line
2936 @require_file_paths = @config_aux_path;
2937 &require_file_internal (1, @_);
2938 local ($dir) = $require_file_paths[0];
2939 @config_aux_path = @require_file_paths;
2942 $config_aux_dir = '.';
2946 $config_aux_dir = '$(top_srcdir)/' . $dir;
2950 ################################################################
2952 # Push a list of files onto dist_common.
2953 sub push_dist_common
2955 local (@files) = @_;
2958 foreach $file (@files)
2960 $dist_common{$file} = 1;
2964 # Push a list of clean targets onto phony.
2965 sub push_phony_cleaners
2969 foreach $target ('mostly', 'dist', '', 'maintainer-')
2971 push (@phony, $target . 'clean-' . $base);
2978 $strictness_name = $_[0];
2979 if ($strictness_name eq 'gnu')
2983 elsif ($strictness_name eq 'gnits')
2985 $strictness = $GNITS;
2987 elsif ($strictness_name eq 'foreign')
2989 $strictness = $FOREIGN;
2993 die "automake: level \`$strictness_name' not recognized\n";
2998 ################################################################
3000 # Return directory name of file.
3006 ($sub = $file) =~ s,/+[^/]+$,,g;
3007 $sub = '.' if $sub eq $file;
3014 local ($dirname) = @_;
3015 system ("mkdir", $dirname);
3018 ################################################################
3020 # Print an error message and set exit status.
3023 warn "automake: ${am_file}.am: ", join (' ', @_), "\n";
3029 local ($symbol, @args) = @_;
3033 # If SYMBOL not already a line number, look it up in Makefile.am.
3034 $symbol = $content_lines{$symbol} unless $symbol =~ /^\d+$/;
3035 $symbol .= ': ' if $symbol;
3036 warn "${am_file}.am:", $symbol, join (' ', @args), "\n";
3045 # Like am_error, but while scanning configure.in.
3048 # FIXME can run in subdirs.
3049 warn "automake: configure.in: ", join (' ', @_), "\n";
3053 # Error message with line number referring to configure.in.
3054 sub am_conf_line_error
3056 local ($line, @args) = @_;
3060 warn "configure.in: $line: ", join (' ', @args), "\n";
3065 &am_conf_error (@args);
3069 # Tell user where our aclocal.m4 is, but only once.
3070 sub keyed_aclocal_warning
3073 warn "automake: macro \`$key' can be found in ${am_dir}/aclocal.m4\n";
3076 # Print usage information.
3079 print "Usage: automake [OPTION] ... [Makefile]...\n";
3081 print "\nFiles which are automatically distributed, if found:\n";
3082 $~ = "USAGE_FORMAT";
3083 local (@lcomm) = sort ((@common_files, @common_sometimes));
3084 local ($one, $two, $three, $four);
3087 $one = shift @lcomm;
3088 $two = @lcomm ? shift @lcomm : '';
3089 $three = @lcomm ? shift @lcomm : '';
3090 $four = @lcomm ? shift @lcomm : '';
3097 format USAGE_FORMAT =
3098 @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<
3099 $one, $two, $three, $four