5 eval 'exec @PERL@ -S $0 ${1+"$@"}'
8 # automake - create Makefile.in from Makefile.am
9 # Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
11 # This program is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by
13 # the Free Software Foundation; either version 2, or (at your option)
16 # This program is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write to the Free Software
23 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
26 # Originally written by David Mackenzie <djm@gnu.ai.mit.edu>.
27 # Perl reimplementation by Tom Tromey <tromey@drip.colorado.edu>.
30 # Parameters set by configure. Not to be changed. NOTE: assign
31 # VERSION as string so that eg version 0.30 will print correctly.
32 $VERSION = "@VERSION@";
33 $PACKAGE = "@PACKAGE@";
35 $am_dir = "@datadir@/@PACKAGE@";
38 $IGNORE_PATTERN = "^##([^#].*)?\$";
39 $WHITE_PATTERN = "^[ \t]*\$";
40 $COMMENT_PATTERN = "^#";
41 $RULE_PATTERN = "^([\$a-zA-Z_.][-.a-zA-Z0-9_(){}/]*) *:";
42 $MACRO_PATTERN = "^([A-Za-z][A-Za-z0-9_]*)[ \t]*=[ \t]*(.*)\$";
43 $BOGUS_MACRO_PATTERN = "^([^ \t]*)[ \t]*=[ \t]*(.*)\$";
45 # Constants to define the "strictness" level.
52 # Variables global to entire run.
54 # TRUE if we should always generate Makefile.in.
55 $force_generation = 1;
57 # Strictness level as set on command line.
58 $default_strictness = $GNU;
60 # Name of strictness level, as set on command line.
61 $default_strictness_name = 'gnu';
63 # This is TRUE if GNU make specific automatic dependency generation
64 # code should be included in generated Makefile.in.
65 $cmdline_use_dependencies = 1;
67 # TRUE if in verbose mode.
70 # This holds our (eventual) exit status. We don't actually exit until
71 # we have processed all input files.
74 # From the Perl manual.
75 $symlink_exists = (eval 'symlink ("", "");', $@ eq '');
77 # TRUE if missing standard files should be installed.
80 # Files found by scanning configure.in for LIBOBJS.
83 # True if AM_C_PROTOTYPES appears in configure.in.
86 # Names used in AC_CONFIG_HEADER call. $config_name is the actual
87 # (first) argument. $config_header is the '.in' file. Ordinarily the
88 # second is derived from the first, but they can be different if the
89 # weird "NAME:FILE" syntax is used.
92 # Line number at which AC_CONFIG_HEADER appears in configure.in.
93 $config_header_line = 0;
95 # Directory where output files go. Actually, output files are
96 # relative to this directory.
97 $output_directory = '.';
99 # Relative location of top build directory.
102 # List of Makefile.am's to process.
105 # List of files in AC_OUTPUT without Makefile.am.
106 @other_input_files = ();
107 # Line number at which AC_OUTPUT seen.
110 # List of directories to search for configure-required files. This
111 # can be set by AC_CONFIG_AUX_DIR.
112 @config_aux_path = ('.', '..', '../..');
113 $config_aux_dir = '';
115 # Whether AC_PROG_MAKE_SET has been seen in configure.in.
118 # Whether ud_GNU_GETTEXT has been seen in configure.in.
120 # Line number at which ud_GNU_GETTEXT seen.
121 $ac_gettext_line = 0;
123 # Whether ALL_LINGUAS has been seen.
127 # Line number at which it appears.
128 $all_linguas_line = 0;
130 # 1 if AC_PROG_INSTALL seen, 2 if AM_PROG_INSTALL seen.
131 $seen_prog_install = 0;
133 # 1 if any scripts installed, 0 otherwise.
134 $scripts_installed = 0;
136 # Whether AC_PATH_XTRA has been seen in configure.in.
139 # Whether YACC variable has been seen in configure.in.
142 # TRUE if we've seen AC_CANONICAL_(HOST|SYSTEM). The presence of
143 # AC_CHECK_TOOL also sets this.
146 # TRUE if we've seen AC_PROG_RANLIB.
149 # TRUE if we've seen AC_ARG_PROGRAM.
152 # TRUE if we've seen AM_PROG_LIBTOOL.
156 # TRUE if we've seen AM_MAINTAINER_MODE.
157 $seen_maint_mode = 0;
159 # TRUE if we've seen PACKAGE and VERSION.
163 # TRUE if we've seen ud_PATH_LISPDIR.
167 # Charsets used by maintainer and in distribution. MAINT_CHARSET is
168 # handled in a funny way: if seen in the top-level Makefile.am, it is
169 # used for every directory which does not specify a different value.
170 # The rationale here is that some directories (eg gettext) might be
171 # distributions of other packages, and thus require their own charset
172 # info. However, the DIST_CHARSET must be the same for the entire
173 # package; it can only be set at top-level.
174 # FIXME this yields bugs when rebuilding. What to do? Always
175 # read (and sometimes discard) top-level Makefile.am?
177 $dist_charset = 'utf8'; # recode doesn't support this yet.
179 # Name of input file ("Makefile.in") and output file ("Makefile.am").
180 # These have no directory components.
186 &initialize_global_constants;
188 # Parse command line.
189 &parse_arguments (@ARGV);
191 # Do configure.in scan only once.
194 die "automake: no \`Makefile.am' found or specified\n"
197 # Now do all the work on each file.
198 foreach $am_file (@input_files)
200 # FIXME should support the AC_OUTPUT ":" syntax here.
201 if (! -f ($am_file . '.am'))
203 &am_error ('no such file');
207 &generate_makefile ($am_file);
211 if ($seen_prog_install <= $scripts_installed)
213 &am_conf_error (($scripts_installed ? 'AM_PROG_INSTALL' : 'AC_PROG_INSTALL')
214 . " must be used in configure.in");
215 &keyed_aclocal_warning ('AM_PROG_INSTALL')
216 if $scripts_installed;
222 ################################################################
224 # Parse command line.
227 local (@arglist) = @_;
230 &set_strictness ('gnu');
234 if ($arglist[0] eq "--version")
236 print "automake - $PACKAGE $VERSION\n";
239 elsif ($arglist[0] eq "--help")
243 elsif ($arglist[0] =~ /^--amdir=(.+)$/)
247 elsif ($arglist[0] eq '--amdir')
249 &require_argument (@arglist);
251 $am_dir = $arglist[0];
253 elsif ($arglist[0] =~ /^--strictness=(.+)$/)
255 &set_strictness ($1);
257 elsif ($arglist[0] eq '--gnu')
259 &set_strictness ('gnu');
261 elsif ($arglist[0] eq '--gnits')
263 &set_strictness ('gnits');
265 elsif ($arglist[0] eq '--foreign')
267 &set_strictness ('foreign');
269 elsif ($arglist[0] eq '--strictness' || $arglist[0] eq '-s')
271 &require_argument (@arglist);
273 &set_strictness ($arglist[0]);
275 elsif ($arglist[0] eq '--include-deps' || $arglist[0] eq '-i')
277 $cmdline_use_dependencies = 0;
279 elsif ($arglist[0] eq '--no-force')
281 $force_generation = 0;
283 elsif ($arglist[0] =~ /^--output-dir=(.*)$/)
285 # Set output directory.
286 $output_directory = $1;
288 elsif ($arglist[0] eq '--output-dir' || $arglist[0] eq '-o')
290 &require_argument (@arglist);
292 $output_directory = $arglist[0];
294 elsif ($arglist[0] eq '--add-missing' || $arglist[0] eq '-a')
298 elsif ($arglist[0] eq '--verbose' || $arglist[0] eq '-v')
302 elsif ($arglist[0] eq '--')
304 # Stop option processing.
306 push (@input_files, @arglist);
309 elsif ($arglist[0] =~ /^-/)
311 die "automake: unrecognized option -- \`$arglist[0]'\n";
315 push (@input_files, $arglist[0]);
321 # Take global strictness from whatever we currently have set.
322 $default_strictness = $strictness;
323 $default_strictness_name = $strictness_name;
326 # Ensure argument exists, or die.
329 local ($arg, @arglist) = @_;
330 die "automake: no argument given for option \`$arg'\n"
334 ################################################################
336 # Generate a Makefile.in given the name of the corresponding Makefile.
337 sub generate_makefile
339 local ($makefile) = @_;
341 ($am_file_name = $makefile) =~ s/^.*\///;
342 $in_file_name = $am_file_name . '.in';
343 $am_file_name .= '.am';
345 &initialize_per_input;
346 $relative_dir = &dirname ($makefile);
348 # At the toplevel directory, we might need config.guess, config.sub
350 if ($relative_dir eq '.')
352 # libtool requires some files.
353 &require_conf_file_with_conf_line ($libtool_line, $FOREIGN,
354 'config.sub', 'config.guess',
355 'libtool') if $seen_libtool;
357 # AC_CANONICAL_HOST and AC_CANONICAL_SYSTEM need config.guess and
359 &require_config_file ($FOREIGN, 'config.guess', 'config.sub')
363 # We still need Makefile.in here, because sometimes the `dist'
364 # target doesn't re-run automake.
365 &push_dist_common ($in_file_name, $am_file_name);
366 push (@sources, '$(SOURCES)')
367 if &variable_defined ('SOURCES');
368 push (@objects, '$(OBJECTS)')
369 if &variable_defined ('OBJECTS');
371 # This is always the default target. This gives us freedom to do
372 # things in whatever order is convenient.
373 $output_rules .= "default: all\n\n";
374 push (@phony, 'default');
376 &read_am_file ($makefile . '.am');
379 # Check first, because we might modify some state.
380 &check_gnu_standards;
381 &check_gnits_standards;
389 # Re-init SOURCES and OBJECTS. FIXME other code shouldn't depend
390 # on this (but currently does).
391 $contents{'SOURCES'} = join (' ', @sources);
392 $contents{'OBJECTS'} = join (' ', @objects);
402 &handle_dependencies;
405 &handle_merge_targets;
410 if (! -d ($output_directory . '/' . $relative_dir))
412 &mkdir ($output_directory . '/' . $relative_dir);
415 local ($out_file) = $output_directory . '/' . $makefile . ".in";
416 if (! $force_generation && -e $out_file)
418 local ($am_time) = (stat ($makefile . '.am'))[9];
419 local ($in_time) = (stat ($out_file))[9];
420 # FIXME how to do unsigned comparison?
421 if ($am_time < $in_time)
428 if (! open (GM_FILE, "> " . $out_file))
430 warn "automake: ${am_file}.in: cannot open: $!\n";
434 print "automake: creating ", $makefile, ".in\n" if $verbose;
436 print GM_FILE $output_vars;
437 print GM_FILE $output_rules;
438 print GM_FILE $output_trailer;
443 ################################################################
445 # Handle AUTOMAKE_OPTIONS variable.
448 return if ! &variable_defined ('AUTOMAKE_OPTIONS');
450 foreach (split (' ', $contents{'AUTOMAKE_OPTIONS'}))
455 if ($_ eq 'gnits' || $_ eq 'gnu' || $_ eq 'foreign')
457 &set_strictness ($_);
459 elsif ($_ eq 'no-installman' || $_ eq 'ansi2knr'
460 || $_ eq 'dist-shar' || $_ eq 'dist-zip'
461 || $_ eq 'dist-tarZ' || $_ eq 'dejagnu'
462 || $_ eq 'no-installinfo')
464 # Explicitly recognize these.
466 elsif ($_ eq 'no-dependencies')
468 $use_dependencies = 0;
470 elsif (/[0-9]+\.?[0-9]+/)
472 # Got a version number. Is the syntax too strict?
473 local ($num_version);
474 ($num_version = $VERSION) =~ tr/0-9//cd;
475 if ($num_version < $_)
477 &am_line_error ('AUTOMAKE_OPTIONS',
478 "require version $_, only have $VERSION");
484 &am_line_error ('AUTOMAKE_OPTIONS',
485 'option ', $_, 'not recognized');
490 # Return object extension. Just once, put some code into the output.
491 sub get_object_extension
493 if (! $dir_holds_sources)
497 if (&variable_defined ('CONFIG_HEADER'))
499 ($xform = &dirname ($contents{'CONFIG_HEADER'}))
501 $xform = '-I' . $xform;
503 $xform = 's/\@CONFIG_INCLUDE_SPEC\@/' . $xform . '/go';
504 $output_vars .= &file_contents_with_transform ($xform,
506 $output_rules .= &file_contents ('compile');
507 &push_phony_cleaners ('compile');
509 # If using X, include some extra variable definitions. NOTE
510 # we don't want to force these into CFLAGS or anything,
511 # because not all programs will necessarily use X.
514 $output_vars .= ("X_CFLAGS = \@X_CFLAGS\@\n"
515 . "X_LIBS = \@X_LIBS\@\n"
516 . "X_EXTRA_LIBS = \@X_EXTRA_LIBS\@\n"
517 . "X_PRE_LIBS = \@X_PRE_LIBS\@\n");
520 # Check for automatic de-ANSI-fication.
521 $dir_holds_sources = '.o';
522 push (@suffixes, '.c', '.o');
523 push (@clean, 'compile');
525 if (defined $options{'ansi2knr'})
527 if (! $am_c_prototypes)
529 &am_line_error ('AUTOMAKE_OPTIONS',
530 "option \`ansi2knr' in use but \`AM_C_PROTOTYPES' not in configure.in");
531 &keyed_aclocal_warning ('AM_C_PROTOTYPES');
532 # Only give this error once.
533 $am_c_prototypes = 1;
536 $dir_holds_sources = '$o';
537 push (@suffixes, '._c', '._o');
539 &require_file_with_line ('AUTOMAKE_OPTIONS', $FOREIGN,
540 'ansi2knr.c', 'ansi2knr.1');
542 $output_vars .= &file_contents ('kr-vars');
543 $output_rules .= &file_contents ('compile-kr');
544 $output_rules .= &file_contents ('clean-kr');
547 &push_phony_cleaners ('kr');
550 return $dir_holds_sources;
553 # Handle SOURCE->OBJECT transform for one program or library.
554 sub handle_source_transform
556 # one_file is canonical name. unxformed is given name. obj is
558 local ($one_file, $unxformed, $obj) = @_;
559 local ($objpat) = $obj;
560 $objpat =~ s/(\W)/\\$1/g;
562 if (&variable_defined ($one_file . "_OBJECTS"))
564 &am_line_error ($one_file . '_OBJECTS',
565 $one_file . '_OBJECTS', 'should not be defined');
566 # No point in continuing.
570 local ($source_list);
572 foreach $prefix ('', 'EXTRA_')
575 if (&variable_defined ($prefix . $one_file . "_SOURCES"))
577 push (@sources, '$(' . $prefix . $one_file . "_SOURCES)");
578 push (@objects, '$(' . $prefix . $one_file . "_OBJECTS)")
579 unless $prefix eq 'EXTRA_';
580 $source_list = $contents{$prefix . $one_file . "_SOURCES"};
582 elsif ($prefix eq '')
584 $output_vars .= $one_file . "_SOURCES = " . $unxformed . ".c\n";
585 push (@sources, $unxformed . '.c');
586 push (@objects, $unxformed . $obj);
587 $source_list = $unxformed . ".c ";
591 $output_vars .= "EXTRA_" . $one_file . "_SOURCES =\n";
596 # Turn sources into objects.
597 local (@files) = split (' ', $source_list);
598 local (@result) = ();
601 # Skip header files, including C++-ish ones.
604 # Skip things that look like macro references.
605 next if /^\$\(.*\)$/;
606 next if /^\$\{.*\}$/;
607 # Skip things that look like configure substitutions.
610 # Include .c file for lex or yacc source in distribution.
614 &push_dist_common ($1 . '.c');
615 if (! defined $targets{$1 . '.c'})
618 $output_rules .= ($1 . '.c: ' . $_ . "\n"
620 . 'cd $(srcdir) && $(YACC) $(YFLAGS) $< && mv y.tab.c '
627 &push_dist_common ($1 . '.c');
628 if (! defined $targets{$1 . '.c'})
630 $output_rules .= ($1 . '.c: ' . $_ . "\n"
632 . 'cd $(srcdir) && $(LEX) $(LFLAGS) $< && mv lex.yy.c '
637 # Transform source files into .o files.
640 s/\.[cCmylfs]$/$obj/g;
642 unless $prefix eq 'EXTRA_';
644 # Transform .o or $o file into .P file (for automatic
647 $dep_files{'$(srcdir)/.deps/' . $_} = 1;
650 &pretty_print ($one_file . "_OBJECTS =", "", @result)
651 unless $prefix eq 'EXTRA_';
655 if (&variable_defined ('CONFIG_HEADER'))
657 $output_rules .= ('$(' . $one_file . "_OBJECTS): "
658 . $contents{'CONFIG_HEADER'} . "\n");
664 # Special-case @ALLOCA@ and @LIBOBJS@ in _LDADD or _LIBADD variables.
665 sub handle_lib_objects
669 die "programming error in handle_lib_objects"
670 if ! &variable_defined ($var);
672 # We recognize certain things that are commonly put in LIBADD or
676 foreach $lsearch (split (' ', $contents{$var}))
678 # Automatically handle @LIBOBJS@ and @ALLOCA@. Basically this
679 # means adding entries to dep_files.
680 if ($lsearch eq '@LIBOBJS@')
682 local ($iter, $rewrite);
683 foreach $iter (keys %libsources)
685 if ($iter ne 'alloca.c')
687 ($rewrite = $iter) =~ s/\.c$/.P/;
688 $dep_files{'$(srcdir)/.deps/' . $rewrite} = 1;
689 &require_file_with_line ($var, $FOREIGN, $iter);
693 elsif ($lsearch eq '@ALLOCA@')
695 &am_line_error ($var,
696 "\@ALLOCA\@ seen but \`AC_FUNC_ALLOCA' not in \`configure.in'")
697 if ! defined $libsources{'alloca.c'};
698 $dep_files{'$(srcdir)/.deps/alloca.P'} = 1;
699 &require_file_with_line ($var, $FOREIGN, 'alloca.c');
707 local (@proglist) = &am_install_var ('-clean',
708 'programs', 'PROGRAMS',
709 'bin', 'sbin', 'libexec', 'pkglib',
711 return if ! @proglist;
713 # If a program is installed, this is required. We only want this
714 # error to appear once.
715 &am_conf_error ("AC_ARG_PROGRAM must be used in configure.in")
716 unless $seen_arg_prog;
719 local ($obj) = &get_object_extension;
720 local ($one_file, $xname, $munge);
722 foreach $one_file (@proglist)
724 # Canonicalize names.
725 ($xname = $one_file) =~ tr/A-Za-z0-9_/_/c;
726 if ($xname ne $one_file)
729 foreach $xt ('_LDADD', '_SOURCES', '_OBJECTS', '_DEPENDENCIES')
731 &am_line_error ($one_file . $xt,
732 "invalid variable \`" . $one_file . $xt
733 . "'; should be \`" . $xname . $xt . "'")
734 if &variable_defined ($one_file . $xt);
738 &handle_source_transform ($xname, $one_file, $obj);
740 if (&variable_defined ($xname . "_LDADD"))
742 &handle_lib_objects ($xname . '_LDADD');
746 # User didn't define prog_LDADD override. So do it.
747 $output_vars .= $xname . '_LDADD = $(LDADD)' . "\n";
751 &file_contents_with_transform
752 ('s/\@PROGRAM\@/' . $one_file . '/go;'
753 . 's/\@XPROGRAM\@/' . $xname . '/go;',
757 &handle_lib_objects ('LDADD')
758 if &variable_defined ('LDADD');
764 local (@liblist) = &am_install_var ('-no-all', '-clean',
765 'libraries', 'LIBRARIES',
766 'lib', 'pkglib', 'noinst', 'check');
767 return if ! @liblist;
771 # FIXME need am_line_error here. But we don't know which
772 # variable exists. Must add a loop... No. Must have
773 # am_install_var return a hash. Otherwise the user could add
774 # install directories that we'd never find.
775 &am_error ("library requires either \`AC_PROG_RANLIB' or `AM_PROG_LIBTOOL' in configure.in");
776 # Only get this error once.
780 # Generate _LIBFILES variables. Too bad we can't do this in
782 local ($onedir, $onelib);
784 foreach $onedir (&am_primary_prefixes ('LIBRARIES', 'lib', 'pkglib',
787 if (&variable_defined ($onedir . '_LIBRARIES'))
790 foreach $onelib (split (' ', $contents{$onedir . '_LIBRARIES'}))
792 push (@outlist, 'lib' . $onelib . '.a');
794 &pretty_print ($onedir . '_LIBFILES =', "", @outlist);
797 push (@all, '$(LIBFILES)');
799 local ($obj) = &get_object_extension;
801 foreach $onelib (@liblist)
803 if (&variable_defined ($onelib . '_LIBADD'))
805 &handle_lib_objects ($onelib . '_LIBADD');
809 # Generate support for conditional object inclusion in
811 $output_vars .= $onelib . "_LIBADD =\n";
814 &handle_source_transform ($onelib, $onelib, $obj);
817 &file_contents_with_transform ('s/\@LIBRARY\@/' . $onelib . '/go',
821 # Turn "foo" into "libfoo.a" and include macro definition.
822 grep (($_ = 'lib' . $_ . '.a') && 0, @liblist);
824 if (! &variable_defined ('LIBFILES'))
826 &pretty_print ('LIBFILES = ', "", @liblist);
831 $output_vars .= ('AR = $(LIBTOOL) archive' . "\n"
832 . 'RANLIB = $(LIBTOOL) ranlib' . "\n"
833 . 'LCOMPILE = $(LIBTOOL) compile $(DEFS) $(INCLUDES)'
834 . ' $(CPPFLAGS) $(CFLAGS)' . "\n");
838 $output_vars .= ('AR = ar' . "\n"
839 . 'RANLIB = @RANLIB@' . "\n");
846 # NOTE we no longer automatically clean SCRIPTS, because it is
847 # useful to sometimes distribute scripts verbatim. This happens
848 # eg in Automake itself.
850 $msi = &am_install_var ('scripts', 'SCRIPTS',
851 'bin', 'sbin', 'libexec', 'pkgdata',
854 # We really only want a boolean value.
855 $scripts_installed = 1 if $msi;
857 if ($scripts_installed)
859 # If a program is installed, this is required. We only want this
860 # error to appear once.
861 &am_conf_error ("AC_ARG_PROGRAM must be used in configure.in")
862 unless $seen_arg_prog;
867 # Search a file for a "version.texi" Texinfo include. Return the name
868 # of the include file if found, or the empty string if not. A
869 # "version.texi" file is actually any file whose name matches
871 sub grep_for_vers_texi
873 local ($filename) = @_;
875 if (! open (TEXI, $filename))
877 &am_error ("couldn't open \`$filename': $!");
880 print "automake: reading $filename\n" if $verbose;
884 if (/^\@include\s+(vers[^.]*\.texi)\s*$/)
896 # Handle all Texinfo source.
899 &am_line_error ('TEXINFOS',
900 "\`TEXINFOS' is an anachronism; use \`info_TEXINFOS'")
901 if &variable_defined ('TEXINFOS');
902 return if (! &variable_defined ('info_TEXINFOS')
903 && ! &variable_defined ('html_TEXINFOS'));
905 local (@texis) = split (' ', $contents{'info_TEXINFOS'});
907 local (@infos_list, @info_deps_list, @dvis_list, @texi_deps);
908 local ($infobase, $info_cursor);
912 local ($tc_cursor, @texi_cleans);
915 foreach $info_cursor (@texis)
917 ($infobase = $info_cursor) =~ s/\.texi$//;
919 # If 'version.texi' is referenced by input file, then include
920 # automatic versioning capability.
922 = &grep_for_vers_texi ($relative_dir . "/" . $info_cursor);
925 &am_error ("\`$vtexi', included in \`$info_cursor', also included in \`$versions{$vtexi}'")
926 if (defined $versions{$vtexi});
927 $versions{$vtexi} = $info_cursor;
929 # We number the stamp-vti files. This is doable since the
930 # actual names don't matter much. We only number starting
931 # with the second one, so that the common case looks nice.
932 $vti = 'vti' . ($done ? $done : '');
933 &push_dist_common ($vtexi, 'stamp-' . $vti);
937 &require_conf_file_with_line ('info_TEXINFOS', $FOREIGN,
943 ($conf_pat = $config_aux_dir) =~ s/(\W)/\\$1/g;
945 &file_contents_with_transform
946 ('s/\@TEXI\@/' . $info_cursor . '/g; '
947 . 's/\@VTI\@/' . $vti . '/g; '
948 . 's/\@VTEXI\@/' . $vtexi . '/g;'
949 . 's,\@MDDIR\@,' . $conf_pat . ',g;',
952 &push_phony_cleaners ($vti);
955 # If user specified file_TEXINFOS, then use that as explicit
958 push (@texi_deps, $info_cursor);
959 push (@texi_deps, $vtexi) if $vtexi;
961 # Canonicalize name first.
962 ($canonical = $infobase) =~ tr/A-Za-z0-9_/_/c;
963 if (&variable_defined ($canonical . "_TEXINFOS"))
965 push (@texi_deps, '$(' . $canonical . '_TEXINFOS)');
966 &push_dist_common ('$(' . $canonical . '_TEXINFOS)');
969 $output_rules .= ("\n" . $infobase . ".info: "
970 . join (' ', @texi_deps)
971 . "\n" . $infobase . ".dvi: "
972 . join (' ', @texi_deps)
975 push (@infos_list, $infobase . '.info', $infobase . '.info-[0-9]',
976 $infobase . '.info-[0-9][0-9]');
977 push (@info_deps_list, $infobase . '.info');
978 push (@dvis_list, $infobase . '.dvi');
980 # Generate list of things to clean for this target. We do
981 # this explicitly because otherwise too many things could be
982 # removed. In particular the ".log" extension might
983 # reasonably be used in other contexts by the user.
984 foreach $tc_cursor ('aux', 'cp', 'cps', 'dvi', 'fn', 'fns',
985 'ky', 'log', 'pg', 'toc', 'tp', 'vr', 'op')
987 push (@texi_cleans, $infobase . '.' . $tc_cursor);
992 $output_vars .= &file_contents ('texinfos-vars');
993 $output_rules .= &file_contents ('texinfos');
994 push (@phony, 'install-info', 'uninstall-info');
997 $output_rules .= "\nmostlyclean-info:\n";
998 &pretty_print_rule ("\trm -f", "\t ", @texi_cleans);
999 $output_rules .= ("\nclean-info:\n\ndistclean-info:\n\n"
1000 . "maintainer-clean-info:\n\t"
1001 . 'rm -f $(INFOS)' . "\n");
1002 &push_phony_cleaners ('info');
1004 push (@suffixes, '.texi', '.info', '.dvi');
1006 if (! defined $options{'no-installinfo'})
1008 push (@uninstall, 'uninstall-info');
1009 push (@installdirs, '$(infodir)');
1010 unshift (@install_data, 'install-info');
1012 # Make sure documentation is made and installed first. Use
1013 # $(INFO_DEPS), not 'info', because otherwise recursive makes
1014 # get run twice during "make all".
1015 unshift (@all, '$(INFO_DEPS)');
1017 push (@clean, 'info');
1018 push (@info, '$(INFO_DEPS)');
1019 push (@dvi, '$(DVIS)');
1021 $output_vars .= ("INFOS = " . join (' ', @infos_list) . "\n"
1022 . "INFO_DEPS = " . join (' ', @info_deps_list) . "\n"
1023 . "DVIS = " . join (' ', @dvis_list) . "\n"
1024 # This next isn't strictly needed now -- the
1025 # places that look here could easily be changed
1026 # to look in info_TEXINFOS. But this is probably
1027 # better, in case noinst_TEXINFOS is ever
1029 . "TEXINFOS = " . $contents{'info_TEXINFOS'} . "\n\n");
1031 # Do some error checking.
1032 &require_file_with_line ('info_TEXINFOS', $FOREIGN, 'texinfo.tex');
1035 # Handle any man pages.
1036 sub handle_man_pages
1038 &am_line_error ('MANS', "\`MANS' is an anachronism; use \`man_MANS'")
1039 if &variable_defined ('MANS');
1040 return if ! &variable_defined ('man_MANS');
1042 # We generate the manpage install code by hand to avoid the use of
1043 # basename in the generated Makefile.
1044 local (@mans) = split (' ', $contents{'man_MANS'});
1045 local (%sections, %inames, %mbases, %secmap, %fullsecmap);
1049 # FIXME: statement without effect:
1050 /^(.*)\.([0-9])([a-z]*)$/;
1055 $fullsecmap{$i} = $2 . $3;
1059 # We don't really need this, but we use it in case we ever want to
1060 # support noinst_MANS.
1061 $output_vars .= "MANS = " . $contents{'man_MANS'} . "\n";
1063 # Generate list of install dirs.
1064 $output_rules .= "install-man: \$(MANS)\n";
1065 foreach (keys %sections)
1067 push (@installdirs, '$(mandir)/man' . $_)
1068 unless defined $options{'no-installman'};
1069 $output_rules .= ("\t" . '$(mkinstalldirs) $(mandir)/man'
1072 push (@phony, 'install-man');
1074 # Generate install target.
1076 foreach $key (keys %inames)
1078 $_ = $install_man_format;
1079 s/\@SECTION\@/$secmap{$key}/g;
1080 s/\@MAN\@/$inames{$key}/g;
1081 s/\@FULLSECT\@/$fullsecmap{$key}/g;
1082 s/\@MANBASE\@/$mbases{$key}/g;
1083 $output_rules .= $_;
1085 $output_rules .= "\n";
1087 $output_rules .= "uninstall-man:\n";
1088 foreach $key (keys %inames)
1090 $_ = $uninstall_man_format;
1091 s/\@SECTION\@/$secmap{$key}/g;
1092 s/\@MAN\@/$inames{$key}/g;
1093 s/\@FULLSECT\@/$fullsecmap{$key}/g;
1094 s/\@MANBASE\@/$mbases{$key}/g;
1095 $output_rules .= $_;
1097 $output_rules .= "\n";
1098 push (@phony, 'uninstall-man');
1100 $output_vars .= &file_contents ('mans-vars');
1102 if (! defined $options{'no-installman'})
1104 push (@install_data, 'install-man');
1105 push (@uninstall, 'uninstall-man');
1106 push (@all, '$(MANS)');
1110 # Handle DATA variables.
1113 &am_install_var ('data', 'DATA', 'data', 'sysconf',
1114 'sharedstate', 'localstate', 'pkgdata',
1121 local ($tagging) = 0;
1123 push (@phony, 'tags');
1124 if (&variable_defined ('SUBDIRS'))
1126 $output_rules .= &file_contents ('tags');
1127 push (@phony, 'tags-recursive');
1130 elsif ($dir_holds_sources
1131 || $dir_holds_headers
1132 || &variable_defined ('ETAGS_ARGS'))
1134 $output_rules .= &file_contents ('tags-subd');
1140 $output_rules .= &file_contents ('tags-clean');
1141 push (@clean, 'tags');
1142 &push_phony_cleaners ('tags');
1146 # Every Makefile must define some sort of TAGS rule.
1147 # Otherwise, it would be possible for a top-level "make TAGS"
1148 # to fail because some subdirectory failed.
1149 $output_rules .= "tags: TAGS\nTAGS:\n\n";
1153 # Worker for handle_dist.
1154 sub handle_dist_worker
1156 $output_rules .= 'distdir: $(DEP_DISTFILES)' . "\n";
1158 # Initialization; only at top level.
1159 if ($relative_dir eq '.')
1161 if ($strictness >= $GNITS)
1163 # For Gnits users, this is pretty handy. Look at 15 lines
1164 # in case some explanatory text is desirable.
1165 $output_rules .= ' @if sed 15q $(srcdir)/NEWS | fgrep -e "$(VERSION)" > /dev/null; then :; else \\
1166 echo "NEWS not updated; not releasing" 1>&2; \\
1174 # Create dist directory.
1177 -chmod 755 $(distdir)
1180 # Only run automake in `dist' target if --include-deps not
1181 # specified. That way the recipient of a distribution can run
1182 # "make dist" and not need Automake.
1183 if ($cmdline_use_dependencies)
1187 # We need an absolute path for --output-dir. Thus the
1189 ' distdir=`cd $(distdir) && pwd` \\
1191 && automake --include-deps --output-dir=$$distdir --strictness='
1192 # Set strictness of output.
1193 . $strictness_name . "\n"
1198 # In loop, test for file existence because sometimes a file gets
1199 # included in DISTFILES twice. For example this happens when a
1200 # single source file is used in building more than one program.
1201 # Also, there are situations in which "ln" can fail. For instance
1202 # a file to distribute could actually be a cross-filesystem
1203 # symlink -- this can easily happen if "gettextize" was run on the
1204 # distribution. Note that DISTFILES can contain a wildcard (for
1205 # info files, sigh), so we must use the echo trick.
1206 $output_rules .= ' @for file in `cd $(srcdir) && echo $(DISTFILES)`; do \\
1207 test -f $(distdir)/$$file \\
1208 || ln $(srcdir)/$$file $(distdir)/$$file 2> /dev/null \\
1209 || cp -p $(srcdir)/$$file $(distdir)/$$file; \\
1213 # If we have SUBDIRS, create all dist subdirectories and do
1215 if (&variable_defined ('SUBDIRS'))
1217 # Test for directory existence here because previous automake
1218 # invocation might have created some directories. Note that
1219 # we explicitly set distdir for the subdir make; that lets us
1220 # mix-n-match many automake-using packages into one large
1221 # package, and have "dist" at the top level do the right
1223 $output_rules .= ' for subdir in $(SUBDIRS); do \\
1224 test -d $(distdir)/$$subdir \\
1225 || mkdir $(distdir)/$$subdir \\
1227 chmod 755 $(distdir)/$$subdir; \\
1228 (cd $$subdir && $(MAKE) distdir=../$(distdir)/$$subdir distdir) \\
1234 # If the target `dist-hook' exists, run it now. This allows
1235 # users to do random weird things to the distribution before it is
1237 if (defined $contents{'dist-hook'})
1239 $output_rules .= "\t\$(MAKE) dist-hook\n";
1242 push (@phony, 'distdir');
1245 # Handle 'dist' target.
1248 # Set up maint_charset.
1249 $local_maint_charset = $contents{'MAINT_CHARSET'}
1250 if &variable_defined ('MAINT_CHARSET');
1251 $maint_charset = $local_maint_charset
1252 if $relative_dir eq '.';
1254 if (&variable_defined ('DIST_CHARSET'))
1256 &am_line_error ('DIST_CHARSET',
1257 "DIST_CHARSET defined but no MAINT_CHARSET defined")
1258 if ! $local_maint_charset;
1259 if ($relative_dir eq '.')
1261 $dist_charset = $contents{'DIST_CHARSET'}
1265 &am_line_error ('DIST_CHARSET',
1266 "DIST_CHARSET can only be defined at top level");
1270 # Look for common files that should be included in distribution.
1272 foreach $cfile (@common_files)
1274 if (-f ($relative_dir . "/" . $cfile))
1276 &push_dist_common ($cfile);
1280 # Keys of %dist_common are names of files to distributed. We put
1281 # README first because it then becomes easier to make a
1282 # Usenet-compliant shar file (in these, README must be first).
1283 # FIXME do more ordering of files here.
1285 if (defined $dist_common{'README'})
1287 push (@coms, 'README');
1288 undef $dist_common{'README'};
1290 push (@coms, sort keys %dist_common);
1292 &pretty_print ("DIST_COMMON =", "", @coms);
1293 $output_vars .= "\n";
1296 $output_vars .= &file_contents ('dist-vars');
1298 # Put these things in rules section so it is easier for whoever
1299 # reads Makefile.in.
1300 if (! &variable_defined ('distdir'))
1302 if ($relative_dir eq '.')
1304 $output_rules .= "\n" . 'distdir = $(PACKAGE)-$(VERSION)' . "\n";
1308 $output_rules .= ("\n"
1309 . 'distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)'
1313 if ($relative_dir ne '.')
1315 $output_rules .= "\nsubdir = " . $relative_dir . "\n";
1318 # Generate 'dist' target, and maybe dist-shar / dist-zip / dist-tarZ.
1319 if ($relative_dir eq '.')
1321 # Rule to check whether a distribution is viable.
1322 $output_rules .= ('# This target untars the dist file and tries a VPATH configuration. Then
1323 # it guarantees that the distribution is self-contained by making another
1327 $(TAR) zxf $(distdir).tar.gz
1328 mkdir $(distdir)/=build
1329 mkdir $(distdir)/=inst
1330 dc_install_base=`cd $(distdir)/=inst && pwd`; \\
1331 cd $(distdir)/=build \\
1334 . ($seen_gettext ? '--with-included-gettext ' : '')
1335 . '--srcdir=.. --prefix=$$dc_install_base \\
1339 && $(MAKE) install \\
1340 && $(MAKE) installcheck \\
1343 @echo "========================"; \\
1344 echo "$(distdir).tar.gz is ready for distribution"; \\
1345 echo "========================"
1348 $output_rules .= 'dist: distdir' . "\n\t";
1349 # Ignore return result from chmod, because it might give an
1350 # error if we chmod a symlink.
1351 $output_rules .= '-chmod -R a+r $(distdir)' . "\n\t";
1352 $output_rules .= '$(TAR) chozf $(distdir).tar.gz $(distdir)';
1353 $output_rules .= "\n\t" . 'rm -rf $(distdir)' . "\n";
1355 if (defined $options{'dist-shar'})
1357 $output_rules .= 'dist-shar: distdir' . "\n\t";
1358 # Ignore return result from chmod, because it might give
1359 # an error if we chmod a symlink.
1360 $output_rules .= '-chmod -R a+r $(distdir)' . "\n\t";
1361 $output_rules .= 'shar $(distdir) | gzip > $(distdir).shar.gz';
1362 $output_rules .= "\n\t" . 'rm -rf $(distdir)' . "\n";
1365 if (defined $options{'dist-zip'})
1367 $output_rules .= 'dist-zip: distdir' . "\n\t";
1368 $output_rules .= '-chmod -R a+r $(distdir)' . "\n\t";
1369 $output_rules .= 'zip -rq $(distdir).zip $(distdir)';
1370 $output_rules .= "\n\t" . 'rm -rf $(distdir)' . "\n";
1373 if (defined $options{'dist-tarZ'})
1375 $output_rules .= 'dist-tarZ: distdir' . "\n\t";
1376 $output_rules .= '-chmod -R a+r $(distdir)' . "\n\t";
1377 $output_rules .= '$(TAR) chf - $(distdir) | compress -c > $(distdir).tar.Z';
1378 $output_rules .= "\n\t" . 'rm -rf $(distdir)' . "\n";
1382 # Generate distdir target.
1383 &handle_dist_worker;
1386 # Handle auto-dependency code.
1387 sub handle_dependencies
1389 if ($use_dependencies)
1391 # Include GNU-make-specific auto-dep code.
1392 if ($dir_holds_sources)
1394 &pretty_print ('DEP_FILES =', "", sort keys %dep_files);
1395 $output_rules .= &file_contents ('depend');
1400 # Include any auto-generated deps that are present.
1401 if (-d ($relative_dir . "/.deps") && -f ($relative_dir . "/.deps/.P"))
1404 local ($gpat) = $relative_dir . "/.deps/*.P";
1406 foreach $depfile (<${gpat}>)
1408 if (! open (DEP_FILE, $depfile))
1410 &am_error ("couldn't open \`$depfile': $!");
1413 print "automake: reading $depfile\n" if $verbose;
1415 # Slurp entire file.
1416 $output_rules .= join ('', <DEP_FILE>);
1421 $output_rules .= "\n";
1426 # Handle subdirectories.
1429 if (! &variable_defined ('SUBDIRS'))
1432 ("ud_GNU_GETTEXT in configure.in but SUBDIRS not defined")
1433 if $seen_gettext && $relative_dir eq '.';
1437 &require_file_with_conf_line ($ac_gettext_line, $FOREIGN, 'ABOUT-NLS')
1440 return if ! &variable_defined ('SUBDIRS');
1442 # Make sure each directory mentioned in SUBDIRS actually exists.
1444 foreach $dir (split (' ', $contents{'SUBDIRS'}))
1446 # Skip directories substituted by configure.
1447 next if $dir =~ /^\@.*\@$/;
1448 &am_line_error ('SUBDIRS',
1449 "required directory $relative_dir/$dir does not exist")
1450 if ! -d $relative_dir . '/' . $dir;
1453 $output_rules .= &file_contents ('subdirs');
1455 # Push a bunch of phony targets.
1457 foreach $phonies ('-data', '-exec', 'dirs')
1459 push (@phony, 'install' . $phonies . '-recursive');
1460 push (@phony, 'uninstall' . $phonies . '-recursive');
1462 foreach $phonies ('all', 'check', 'installcheck', 'info', 'dvi')
1464 push (@phony, $phonies . '-recursive');
1466 &push_phony_cleaners ('recursive');
1468 push (@check, "check-recursive");
1469 push (@installcheck, "installcheck-recursive");
1470 push (@info, "info-recursive");
1471 push (@dvi, "dvi-recursive");
1473 $recursive_install = 1;
1476 # Handle aclocal.m4.
1477 sub handle_aclocal_m4
1479 local ($regen_aclocal) = 0;
1480 if (-f 'aclocal.m4')
1482 $output_vars .= "ACLOCAL = aclocal.m4\n";
1483 &push_dist_common ('aclocal.m4');
1485 if (open (ACLOCAL, '< aclocal.m4'))
1491 if ($line =~ 'generated automatically by aclocal')
1498 local ($acinclude) = 0;
1499 if (-f 'acinclude.m4')
1506 # FIXME how to tell if aclocal.m4 should be automatically
1512 $output_rules .= ("aclocal.m4: configure.in"
1513 . ($acinclude ? ' acinclude.m4' : '')
1515 . 'cd $(srcdir) && aclocal'
1520 # Handle remaking and configure stuff.
1521 sub handle_configure
1523 # If SUBDIRS defined, require AC_PROG_MAKE_SET.
1524 &am_line_error ('SUBDIRS', "AC_PROG_MAKE_SET must be used in configure.in")
1525 if &variable_defined ('SUBDIRS') && ! $seen_make_set;
1527 local ($top_reldir);
1528 if ($relative_dir ne '.')
1531 $output_rules .= &file_contents ('remake-subd');
1532 $top_reldir = '../';
1537 $output_rules .= &file_contents_with_transform ('s/\@STRICTNESS\@/'
1543 ("\`install.sh' is an anachronism; use \`install-sh' instead")
1544 if -f $relative_dir . '/install.sh';
1546 # If we have a configure header, require it.
1549 # FIXME this restriction should be lifted.
1550 # FIXME first see if it is even needed as-is.
1551 &am_conf_line_error ($config_header_line,
1552 "argument to AC_CONFIG_HEADER contains \`/'\n")
1553 if ($config_header =~ /\//);
1555 &require_file_with_conf_line ($config_header_line,
1556 $FOREIGN, $config_header);
1558 # Header defined and in this directory.
1559 if (-f 'acconfig.h')
1561 $output_vars .= "ACCONFIG = acconfig.h\n";
1562 &push_dist_common ('acconfig.h');
1564 if (-f $config_name . '.top')
1566 $output_vars .= "CONFIG_TOP = ${config_name}.top\n";
1567 &push_dist_common ($config_name . '.top');
1569 if (-f $config_name . '.bot')
1571 $output_vars .= "CONFIG_BOT = ${config_name}.bot\n";
1572 &push_dist_common ($config_name . '.bot');
1575 &require_file_with_conf_line ($config_header_line, $FOREIGN,
1578 $output_rules .= &file_contents ('remake-hdr');
1579 $output_vars .= "CONFIG_HEADER_IN = ${config_header}\n";
1585 # Set location of mkinstalldirs.
1586 if ($config_aux_dir ne '.' && $config_aux_dir ne '')
1588 $output_vars .= 'mkinstalldirs = ' . $config_aux_dir;
1592 $output_vars .= 'mkinstalldirs = $(top_srcdir)';
1594 $output_vars .= '/mkinstalldirs' . "\n";
1596 &am_line_error ('CONFIG_HEADER',
1597 "\`CONFIG_HEADER' is an anachronism; now determined from \`configure.in'")
1598 if &variable_defined ('CONFIG_HEADER');
1600 # Generate CONFIG_HEADER define, and define interally.
1601 $output_vars .= "CONFIG_HEADER = ${top_builddir}/${config_name}\n"
1603 $contents{'CONFIG_HEADER'} = "${top_builddir}/${config_name}"
1606 # Now look for other files in this directory which must be remade
1607 # by config.status, and generate rules for them.
1608 local ($file, $local, $input);
1609 foreach $file (@other_input_files)
1611 # Skip files not in this directory, any Makefile, and the
1612 # config header. These last two must be handled specially.
1613 next unless &dirname ($file) eq $relative_dir;
1614 next if $file eq $top_builddir . '/' . $config_name;
1615 ($local = $file) =~ s/^.*\///;
1616 next if $local eq 'Makefile';
1618 if ($local =~ /^(.*):(.*)$/)
1620 # This is the ":" syntax of AC_OUTPUT.
1627 $input = $local . '.in';
1629 # FIXME when using autoconf ":" syntax, should we set CONFIG_FILES
1631 $output_rules .= ($local . ': '
1632 . '$(top_builddir)/config.status ' . $input . "\n"
1634 . 'cd $(top_builddir) && CONFIG_FILES='
1635 . ($relative_dir eq '.' ? '' : '$(subdir)/')
1636 . '$@ CONFIG_HEADERS= ./config.status'
1639 &require_file_with_conf_line ($ac_output_line, $FOREIGN,
1647 $dir_holds_headers = &am_install_var ('header', 'HEADERS', 'include',
1648 'oldinclude', 'pkginclude',
1654 return if ! $seen_gettext || $relative_dir ne '.';
1656 if (&variable_defined ('SUBDIRS'))
1660 "ud_GNU_GETTEXT in configure.in but \`po' not in SUBDIRS")
1661 if $contents{'SUBDIRS'} !~ /\bpo\b/;
1664 "ud_GNU_GETTEXT in configure.in but \`intl' not in SUBDIRS")
1665 if $contents{'SUBDIRS'} !~ /\bintl\b/;
1668 # Ensure that each language in ALL_LINGUAS has a .po file, and
1669 # each po file is mentioned in ALL_LINGUAS.
1672 local (%linguas) = ();
1673 grep ($linguas{$_} = 1, split (' ', $all_linguas));
1680 &am_line_error ($all_linguas_line,
1681 ("po/$_.po exists but \`$_' not in \`ALL_LINGUAS'"))
1685 foreach (keys %linguas)
1687 &am_line_error ($all_linguas_line,
1688 "$_ in \`ALL_LINGUAS' but po/$_.po does not exist")
1694 &am_error ("ud_GNU_GETTEXT in configure.in but \`ALL_LINGUAS' not defined");
1698 # Handle footer elements.
1701 if ($contents{'SOURCES'})
1703 &pretty_print ('SOURCES =', "",
1704 split (' ', $contents{'SOURCES'}));
1706 if ($contents{'OBJECTS'})
1708 &pretty_print ('OBJECTS =', "",
1709 split (' ', $contents{'OBJECTS'}));
1711 if ($contents{'SOURCES'} || $contents{'OBJECTS'})
1713 $output_vars .= "\n";
1716 if (defined $contents{'SUFFIXES'})
1718 # Push actual suffixes, and not $(SUFFIXES). Some versions of
1719 # make do not like variable substitutions on the .SUFFIXES
1721 push (@suffixes, split (' ', $contents{'SUFFIXES'}));
1724 $output_trailer .= ".SUFFIXES:\n";
1727 $output_trailer .= ".SUFFIXES: " . join (' ', @suffixes) . "\n";
1729 $output_trailer .= &file_contents ('footer');
1732 # Deal with installdirs target.
1733 sub handle_installdirs
1735 # GNU Makefile standards recommend this.
1736 $output_rules .= ("installdirs:"
1737 . ($recursive_install
1738 ? " installdirs-recursive\n"
1740 push (@phony, 'installdirs');
1743 &pretty_print_rule ("\t" . '$(mkinstalldirs) ', "\t\t",
1746 $output_rules .= "\n";
1749 # There are several targets which need to be merged. This is because
1750 # their complete definition is compiled from many parts. Note that we
1751 # avoid double colon rules, otherwise we'd use them instead.
1752 sub handle_merge_targets
1754 push (@all, 'Makefile');
1755 push (@all, $config_name)
1756 if $config_name && &dirname ($config_name) eq $relative_dir;
1758 &do_one_merge_target ('info', @info);
1759 &do_one_merge_target ('dvi', @dvi);
1761 if (! &variable_defined ('SUBDIRS') || $relative_dir ne '.')
1763 # 'check' must depend on 'all', but not at top level.
1765 unshift (@check, 'all');
1766 unshift (@install, 'all');
1768 &do_one_merge_target ('check', @check);
1769 &do_one_merge_target ('installcheck', @installcheck);
1771 # Handle the various install targets specially. We do this so
1772 # that (eg) "make install-exec" will run "install-exec-recursive"
1773 # if required, but "make install" won't run it twice. Step one is
1774 # to see if the user specified local versions of any of the
1775 # targets we handle. "all" is treated as one of these since
1776 # "install" can run it.
1777 push (@install_exec, 'install-exec-local')
1778 if defined $contents{'install-exec-local'};
1779 push (@install_data, 'install-data-local')
1780 if defined $contents{'install-data-local'};
1781 push (@uninstall, 'uninstall-local')
1782 if defined $contents{'uninstall-local'};
1783 push (@all, 'all-local')
1784 if defined $contents{'all-local'};
1786 if (defined $contents{'install-local'})
1788 &am_line_error ('install-local',
1789 "use \`install-data' or \`install-exec', not \`install'");
1792 # Step two: if we are doing recursive makes, write out the
1793 # appropriate rules.
1795 if ($recursive_install)
1797 push (@install, 'install-recursive');
1801 local (@hackall) = ();
1802 if ($config_name && &dirname ($config_name) eq $relative_dir)
1805 # This is kind of a hack, but I couldn't see a better
1806 # way to handle it. In this particular case, we need
1807 # to make sure config.h is built before we recurse.
1808 # We can't do this by changing the order of
1809 # dependencies to the "all" because that breaks when
1810 # using parallel makes. Instead we handle things
1812 $output_rules .= ('all-recursive-hack: $(CONFIG_HEADER)'
1813 . "\n\t" . '$(MAKE) all-recursive'
1815 push (@hackall, 'all-recursive-hack');
1816 push (@phony, 'all-recursive-hack');
1820 push (@hackall, 'all-recursive');
1823 $output_rules .= ('all-am: '
1827 push (@all, 'all-am');
1828 push (@phony, 'all-am');
1832 @all = ('all-recursive');
1836 $output_rules .= ('install-exec-am: '
1837 . join (' ', @install_exec)
1839 @install_exec = ('install-exec-recursive', 'install-exec-am');
1840 push (@install, 'install-exec-am');
1841 push (@phony, 'install-exec-am');
1845 @install_exec = ('install-exec-recursive');
1849 $output_rules .= ('install-data-am: '
1850 . join (' ', @install_data)
1852 @install_data = ('install-data-recursive', 'install-data-am');
1853 push (@install, 'install-data-am');
1854 push (@phony, 'install-data-am');
1858 @install_data = ('install-data-recursive');
1862 $output_rules .= ('uninstall-am: '
1863 . join (' ', @uninstall)
1865 @uninstall = ('uninstall-recursive', 'uninstall-am');
1866 push (@phony, 'uninstall-am');
1870 @uninstall = ('uninstall-recursive');
1874 # Step three: print definitions users can use. Code below knows
1875 # that install-exec is done before install-data, beware.
1876 $output_rules .= ("install-exec: "
1877 . join (' ', @install_exec)
1879 if (defined $contents{'install-exec-hook'})
1881 $output_rules .= "\t" . '$(MAKE) install-exec-hook' . "\n";
1883 $output_rules .= "\n";
1884 push (@install, 'install-exec') if !$recursive_install;
1885 push (@phony, 'install-exec');
1887 $output_rules .= ("install-data: "
1888 . join (' ', @install_data)
1890 if (defined $contents{'install-data-hook'})
1892 $output_rules .= "\t" . '$(MAKE) install-data-hook' . "\n";
1894 $output_rules .= "\n";
1895 push (@install, 'install-data') if !$recursive_install;
1896 push (@phony, 'install-data');
1898 # If no dependencies for 'install', add 'all'. Why? That way
1899 # "make install" at top level of distclean'd distribution won't
1900 # fail because stuff in 'lib' fails to build.
1901 if (! @install || ($#install == 1
1902 && $install[0] eq 'install-exec'
1903 && $install[1] eq 'install-data'))
1905 push (@install, 'all');
1907 $output_rules .= ('install: '
1908 . join (' ', @install)
1909 # Use "@:" as empty command so nothing prints.
1913 . join (' ', @uninstall)
1915 push (@phony, 'install', 'uninstall');
1917 $output_rules .= ('all: '
1920 push (@phony, 'all');
1922 # Generate the new 'install-strip' target.
1923 $output_rules .= ("install-strip:\n\t"
1924 . '$(MAKE) INSTALL_PROGRAM=\'$(INSTALL_PROGRAM) -s\' install'
1928 # Helper for handle_merge_targets.
1929 sub do_one_merge_target
1931 local ($name, @values) = @_;
1933 if (defined $contents{$name . '-local'})
1935 # User defined local form of target. So include it.
1936 push (@values, $name . '-local');
1937 push (@phony, $name . '-local');
1940 $output_rules .= $name . ":";
1943 $output_rules .= ' ' . join (' ', @values);
1945 $output_rules .= "\n\n";
1946 push (@phony, $name);
1949 # Handle all 'clean' targets.
1952 push (@clean, 'generic');
1953 $output_rules .= &file_contents ('clean');
1954 &push_phony_cleaners ('generic');
1956 local ($target) = $recursive_install ? 'clean-am' : 'clean';
1957 &do_one_clean_target ($target, 'mostly', '', @clean);
1958 &do_one_clean_target ($target, '', 'mostly', @clean);
1959 &do_one_clean_target ($target, 'dist', '', @clean);
1960 &do_one_clean_target ($target, 'maintainer-', 'dist', @clean);
1962 push (@phony, 'clean', 'mostlyclean', 'distclean', 'maintainer-clean');
1965 if ($recursive_install)
1967 @deps = ('am', 'recursive');
1968 &do_one_clean_target ('', 'mostly', '', @deps);
1969 &do_one_clean_target ('', '', '', @deps);
1970 &do_one_clean_target ('', 'dist', '', @deps);
1971 &do_one_clean_target ('', 'maintainer-', '', @deps);
1975 # Helper for handle_clean.
1976 sub do_one_clean_target
1978 local ($target, $name, $last_name, @deps) = @_;
1980 # Special case: if target not passed, then don't generate
1981 # dependency on next "lower" clean target (eg no
1982 # clean<-mostlyclean derivation). In this case the target is
1983 # implicitly known to be 'clean'.
1984 local ($flag) = $target;
1985 $target = 'clean' if ! $flag;
1987 grep (($_ = $name . 'clean-' . $_) && 0, @deps);
1990 if ($last_name || $name ne 'mostly')
1992 push (@deps, $last_name . $target . " ");
1995 # FIXME not sure if I like the tabs here.
1996 &pretty_print_rule ($name . $target . ": ", "\t\t", @deps);
1998 # FIXME shouldn't we really print these messages before running
2000 if ($name . $target eq 'maintainer-clean')
2002 # Print a special warning.
2004 ("\t\@echo \"This command is intended for maintainers to use;\"\n"
2005 . "\t\@echo \"it deletes files that may require special "
2006 . "tools to rebuild.\"\n");
2008 $output_rules .= "\trm -f config.status\n"
2009 if $relative_dir eq '.';
2011 elsif ($name . $target eq 'distclean')
2013 $output_rules .= "\trm -f config.status\n";
2015 $output_rules .= "\n";
2018 # Handle .PHONY target.
2021 &pretty_print_rule ('.PHONY:', "", @phony);
2022 $output_rules .= "\n";
2025 # Handle TESTS variable and other checks.
2028 if (defined $options{'dejagnu'})
2030 push (@check, 'check-DEJAGNU');
2031 push (@phony, 'check-DEJAGNU');
2032 $output_rules .= &file_contents ('dejagnu') . "\n";
2033 # Note that in the rule we don't directly generate site.exp to
2034 # avoid the possibility of a corrupted site.exp if make is
2035 # interrupted. Jim Meyering has some useful text on this
2037 $output_rules .= ("site.exp: Makefile\n"
2038 . "\t\@echo 'Making a new site.exp file...'\n"
2039 . "\t-\@rm -f site.bak\n"
2040 . "\t\@echo '## these variables are automatically generated by make ##' > \$\@-t\n"
2041 . "\t\@echo '# Do not edit here. If you wish to override these values' >> \$\@-t\n"
2042 . "\t\@echo '# edit the last section' >> \$\@-t\n"
2043 . "\t\@echo 'set tool \$(DEJATOOL)' >> \$\@-t\n"
2044 . "\t\@echo 'set srcdir \$(srcdir)' >> \$\@-t\n"
2045 . "\t\@echo 'set objdir' \`pwd\` >> \$\@-t\n");
2047 # Extra stuff for AC_CANONICAL_*
2048 local (@whatlist) = ();
2049 if ($seen_canonical)
2051 push (@whatlist, 'host')
2054 # Extra stuff only for AC_CANONICAL_SYSTEM.
2055 if ($seen_canonical == $AC_CANONICAL_SYSTEM)
2057 push (@whatlist, 'target', 'build');
2061 foreach $c1 (@whatlist)
2063 foreach $c2 ('alias', 'triplet')
2065 $output_rules .= "\t\@echo 'set ${c1}_${c2} \$(${c1}_${c2})' >> \$\@-t\n";
2069 $output_rules .= ("\t\@echo '## All variables above are generated by configure. Do Not Edit ##' >> \$\@-t\n"
2070 . "\t-\@sed '1,/^## All variables above are.*##/ d' site.bak >> \$\@-t\n"
2071 . "\t-\@mv site.exp site.bak\n"
2072 . "\t\@mv \$\@-t site.exp\n");
2077 foreach $c ('DEJATOOL', 'RUNTEST', 'RUNTESTFLAGS')
2079 if (&variable_defined ($c))
2081 &am_line_error ($c, "\`$c' defined but \`dejagnu' not in \`AUTOMAKE_OPTIONS'");
2086 if (&variable_defined ('TESTS'))
2088 push (@check, 'check-TESTS');
2089 push (@phony, 'check-TESTS');
2090 # FIXME use $(SHELL) here? That is what Ulrich suggests.
2091 # Maybe a new macro, $(TEST_SHELL), a la $(CONFIG_SHELL)? For
2092 # now we just execute the file directly; this allows test
2093 # files which are compiled -- a possibly useful feature.
2094 $output_rules .= 'check-TESTS: $(TESTS)
2095 @failed=0; all=0; \\
2096 srcdir=$(srcdir); export srcdir; \\
2097 for tst in $(TESTS); do \\
2098 all=`expr $$all + 1`; \\
2099 if test -f $$tst; then dir=.; \\
2100 else dir="$(srcdir)"; fi; \\
2101 if $(TESTS_ENVIRONMENT) $$dir/$$tst; then \\
2102 echo "PASS: $$tst"; \\
2104 failed=`expr $$failed + 1`; \\
2105 echo "FAIL: $$tst"; \\
2108 if test "$$failed" -eq 0; then \\
2109 echo "========================"; \\
2110 echo "All $$all tests passed"; \\
2111 echo "========================"; \\
2113 echo "$$failed of $$all tests failed"; \\
2119 # Handle Emacs Lisp.
2120 sub handle_emacs_lisp
2122 local (@elfiles) = &am_install_var ('lisp', 'LISP', 'lisp', 'noinst');
2127 $output_vars .= "lispdir = \@lispdir\@\n";
2128 $output_rules .= (".el.elc:\n"
2129 . "\t\@echo 'WARNING: Warnings can be ignored. :-)'\n"
2130 . "\t\$(SHELL) \$(srcdir)/elisp-comp \$<\n");
2131 push (@suffixes, '.el', '.elc');
2133 # Generate .elc files.
2134 grep ($_ .= 'c', @elfiles);
2135 &pretty_print ('ELCFILES =', '', @elfiles);
2137 push (@clean, 'lisp');
2138 &push_phony_cleaners ('lisp');
2141 if (&variable_defined ('lisp_LISP'))
2143 $varname = 'lisp_LISP';
2144 &am_error ("\`lisp_LISP' defined but \`ud_PATH_LISPDIR' not in \`configure.in'")
2149 $varname = 'noinst_LISP';
2152 &require_file_with_line ($varname, $FOREIGN, 'elisp-comp');
2156 ################################################################
2158 # Scan configure.in for interesting things.
2159 # FIXME ensure VERSION, PACKAGE are set.
2162 open (CONFIGURE, 'configure.in')
2163 || die "automake: couldn't open \`configure.in': $!\n";
2164 print "automake: reading configure.in\n" if $verbose;
2166 # Reinitialize libsources here. This isn't really necessary,
2167 # since we currently assume there is only one configure.in. But
2168 # that won't always be the case.
2171 local ($in_ac_output, @make_list) = 0;
2172 local ($libobj_iter);
2175 # Remove comments from current line.
2179 # Populate libobjs array.
2180 if (/AC_FUNC_ALLOCA/)
2182 $libsources{'alloca.c'} = 1;
2184 elsif (/AC_FUNC_GETLOADAVG/)
2186 $libsources{'getloadavg.c'} = 1;
2188 elsif (/AC_FUNC_MEMCMP/)
2190 $libsources{'memcmp.c'} = 1;
2192 elsif (/AC_STRUCT_ST_BLOCKS/)
2194 $libsources{'fileblocks.c'} = 1;
2196 elsif (/(AC|fp)_FUNC_FNMATCH/)
2198 # AC_FUNC_FNMATCH is just wishful thinking at this point.
2199 $libsources{'fnmatch.c'} = 1;
2201 elsif (/AC_REPLACE_FUNCS\s*\((.*)\)/)
2203 foreach (split (' ', $1))
2205 $libsources{$_ . '.c'} = 1;
2208 elsif (/AC_REPLACE_GNU_GETOPT/)
2210 $libsources{'getopt.c'} = 1;
2211 $libsources{'getopt1.c'} = 1;
2213 elsif (/LIBOBJS="(.*)\s+\$LIBOBJS"/
2214 || /LIBOBJS="\$LIBOBJS\s+(.*)"/)
2216 foreach $libobj_iter (split (' ', $1))
2218 if ($libobj_iter =~ /^(.*)\.o$/)
2220 $libsources{$1 . '.c'} = 1;
2225 if (/(fp_PROG_INSTALL|fp_C_PROTOTYPES|jm_MAINTAINER_MODE)/)
2227 &am_conf_line_error ($., "\`$1' is obsolete; use corresponding \`AM_' macro");
2230 # Process the AC_OUTPUT macro.
2231 if (! $in_ac_output && s/AC_OUTPUT\s*\(\[?//)
2234 $ac_output_line = $.;
2238 $in_ac_output = 0 if s/[\]\),].*$//;
2240 # Look at potential Makefile.am's.
2246 push (@make_list, $_);
2250 push (@other_input_files, $_);
2255 if (/AC_CONFIG_AUX_DIR\(([^)]+)\)/)
2257 @config_aux_path = $1;
2260 # Check for ansi2knr.
2261 $am_c_prototypes = 1 if /AM_C_PROTOTYPES/;
2263 # Check for NLS support.
2264 if (/ud_GNU_GETTEXT/)
2267 $ac_gettext_line = $.;
2270 # Look for ALL_LINGUAS.
2271 if (/ALL_LINGUAS="(.*)"$/ || /ALL_LINGUAS=(.*)$/)
2275 $all_linguas_line = $.;
2278 # Handle configuration headers.
2279 if (/AC_CONFIG_HEADER\s*\((.*)\)/)
2281 $config_header_line = $.;
2283 if ($config_name =~ /^([^:]+):(.+)$/)
2286 $config_header = $2;
2290 $config_header = $config_name . '.in';
2294 # Handle AC_CANONICAL_*. Always allow upgrading to
2295 # AC_CANONICAL_SYSTEM, but never downgrading.
2296 $seen_canonical = $AC_CANONICAL_HOST
2297 if ! $seen_canonical && /AC_CANONICAL_HOST/;
2298 $seen_canonical = $AC_CANONICAL_SYSTEM if /AC_CANONICAL_SYSTEM/;
2300 $seen_canonical = 1 if /AC_CHECK_TOOL/;
2301 $seen_path_xtra = 1 if /AC_PATH_XTRA/;
2303 # Sometimes it is desirable to explicitly set YACC. For
2304 # instance some people don't want to use bison.
2305 $seen_prog_yacc = 1 if (/AC_PROG_YACC/
2306 || /AC_SUBST\(YACC\)/
2307 || /AC_(PATH|CHECK)_PROGS?\(YACC/);
2309 # This macro handles several different things.
2310 if (/AM_INIT_AUTOMAKE/)
2316 $seen_prog_install = 2;
2319 # Some things required by Automake.
2320 $seen_make_set = 1 if /AC_PROG_MAKE_SET/;
2321 $seen_arg_prog = 1 if /AC_ARG_PROGRAM/;
2322 $seen_ranlib = 1 if /AC_PROG_RANLIB/;
2323 $seen_maint_mode = 1 if /AM_MAINTAINER_MODE/;
2324 $seen_package = 1 if /PACKAGE=/;
2325 $seen_version = 1 if /VERSION=/;
2327 # Weird conditionals here because it is always allowed to
2328 # upgrade to AM_PROG_INSTALL but never to downgrade to
2330 $seen_prog_install = 1 if ! $seen_prog_install && /AC_PROG_INSTALL/;
2331 $seen_prog_install = 2 if /AM_PROG_INSTALL/;
2333 $seen_lispdir = 1 if /ud_PATH_LISPDIR/;
2335 if (/AM_PROG_LIBTOOL/)
2343 # Set input files if not specified by user.
2344 @input_files = @make_list if (! @input_files);
2348 &am_conf_error ("\`PACKAGE' not defined in configure.in")
2350 &am_conf_error ("\`VERSION' not defined in configure.in")
2353 # Look for some files we need. Always check for these. This
2354 # check must be done for every run, even those where we are only
2355 # looking at a subdir Makefile. We must set relative_dir so that
2356 # the file-finding machinery works.
2357 local ($relative_dir) = '.';
2358 &require_config_file ($FOREIGN, 'install-sh', 'mkinstalldirs');
2361 ################################################################
2363 # Do any extra checking for GNU standards.
2364 sub check_gnu_standards
2366 if ($relative_dir eq '.')
2368 # In top level (or only) directory.
2369 &require_file ($GNU, 'INSTALL', 'NEWS', 'README', 'COPYING',
2370 'AUTHORS', 'ChangeLog');
2374 # Do any extra checking for GNITS standards.
2375 sub check_gnits_standards
2377 if ($strictness >= $GNITS && -f $relative_dir . '/COPYING.LIB')
2380 ("\`${relative_dir}/COPYING.LIB' disallowed by Gnits standards");
2383 if ($relative_dir eq '.')
2385 # In top level (or only) directory.
2386 &require_file ($GNITS, 'THANKS');
2390 ################################################################
2392 # Pretty-print something. HEAD is what should be printed at the
2393 # beginning of the first line, FILL is what should be printed at the
2394 # beginning of every subsequent line.
2395 sub pretty_print_internal
2397 local ($head, $fill, @values) = @_;
2399 local ($column) = length ($head);
2400 local ($result) = $head;
2402 # Fill length is number of characters. However, each Tab
2403 # character counts for eight. So we count the number of Tabs and
2405 local ($fill_length) = length ($fill);
2406 $fill_length += 7 * ($fill =~ tr/\t/\t/d);
2411 # "71" because we also print a space.
2412 if ($column + length ($_) > 71)
2414 $result .= " \\\n" . $fill;
2415 $column = $fill_length;
2419 $result .= ' ' unless ($bol);
2421 $column += length ($_) + 1;
2429 # Pretty-print something and append to output_vars.
2432 $output_vars .= &pretty_print_internal (@_);
2435 # Pretty-print something and append to output_rules.
2436 sub pretty_print_rule
2438 $output_rules .= &pretty_print_internal (@_);
2442 ################################################################
2444 # See if a variable exists.
2445 sub variable_defined
2448 if (defined $targets{$var})
2450 &am_line_error ($var, "\`$var' is target; expected variable");
2452 return (defined $contents{$var} && ! defined $targets{$var});
2455 # Read Makefile.am and set up %contents. Simultaneously copy lines
2456 # from Makefile.am into $output_trailer or $output_vars as
2457 # appropriate. NOTE we put rules in the trailer section. We want
2458 # user rules to come after our generated stuff.
2461 local ($amfile) = @_;
2463 # Compute relative location of the top object directory.
2464 local (@topdir) = ();
2465 foreach (split (/\//, $relative_dir))
2467 next if $_ eq '.' || $_ eq '';
2474 push (@topdir, '..');
2477 @topdir = ('.') if ! @topdir;
2479 $top_builddir = join ('/', @topdir);
2481 ($build_rx = $top_builddir) =~ s/(\W)/\\$1/g;
2482 local ($header_vars) =
2483 &file_contents_with_transform
2484 ('s/\@top_builddir\@/' . $build_rx . '/g',
2487 # Generate some useful variables when AC_CANONICAL_* used.
2488 if ($seen_canonical)
2490 $header_vars .= ('host_alias = @host_alias@' . "\n"
2491 . 'host_triplet = @host@' . "\n");
2492 if ($seen_canonical == $AC_CANONICAL_SYSTEM)
2494 $header_vars .= ('build_alias = @build_alias@' . "\n"
2495 . 'build_triplet = @build@' . "\n");
2496 $header_vars .= ('target_alias = @target_alias@' . "\n"
2497 . 'target_triplet = @target@' . "\n");
2501 open (AM_FILE, $amfile) || die "automake: couldn't open \`$amfile': $!\n";
2502 print "automake: reading $amfile\n" if $verbose;
2504 $output_vars .= ("# $in_file_name generated automatically by automake "
2505 . $VERSION . " from $am_file_name\n");
2507 # Generate copyright for generated Makefile.in.
2508 $output_vars .= $gen_copyright;
2510 local ($saw_bk) = 0;
2511 local ($was_rule) = 0;
2512 local ($spacing) = '';
2513 local ($comment) = '';
2514 local ($last_var_name) = '';
2519 if (/$IGNORE_PATTERN/o)
2521 # Merely delete comments beginning with two hashes.
2523 elsif (/$WHITE_PATTERN/o)
2525 # Stick a single white line before the incoming macro or rule.
2529 elsif (/$COMMENT_PATTERN/o)
2531 # Stick comments before the incoming macro or rule. Make
2532 # sure a blank line preceeds comments.
2533 $spacing = "\n" unless $blank;
2534 $comment .= $spacing . $_;
2543 $output_vars .= $comment . "\n" . $header_vars;
2547 local ($is_ok_macro);
2551 unless substr ($_, -1, 1) eq "\n";
2553 $_ =~ s/\@MAINT\@//g
2554 unless $seen_maint_mode;
2556 if (/$IGNORE_PATTERN/o)
2558 # Merely delete comments beginning with two hashes.
2560 elsif (/$WHITE_PATTERN/o)
2562 # Stick a single white line before the incoming macro or rule.
2565 elsif (/$COMMENT_PATTERN/o)
2567 # Stick comments before the incoming macro or rule.
2568 $comment .= $spacing . $_;
2575 $output_trailer .= $_;
2582 # Chop newline and backslash if this line is
2583 # continued. FIXME maybe ensure trailing whitespace
2587 $contents{$last_var_name} .= $_;
2590 elsif (/$RULE_PATTERN/o)
2592 # warn "** Saw rule .$1.\n";
2595 # Value here doesn't matter; for targets we only note
2599 $content_lines{$1} = $.;
2600 $output_trailer .= $comment . $spacing . $_;
2601 $comment = $spacing = '';
2604 elsif (($is_ok_macro = /$MACRO_PATTERN/o)
2605 || /$BOGUS_MACRO_PATTERN/o)
2607 # Found a macro definition.
2609 $last_var_name = $1;
2610 if (substr ($2, -1) eq "\\")
2612 $contents{$1} = substr ($2, 0, length ($2) - 1);
2618 $content_lines{$1} = $.;
2619 $output_vars .= $comment . $spacing . $_;
2620 $comment = $spacing = '';
2624 &am_line_error ($., "bad macro name \`$1'")
2629 # This isn't an error; it is probably a continued rule.
2630 # In fact, this is what we assume.
2632 $output_trailer .= $comment . $spacing . $_;
2633 $comment = $spacing = '';
2640 $output_trailer .= $comment;
2643 ################################################################
2645 sub initialize_global_constants
2647 # Values for AC_CANONICAL_*
2648 $AC_CANONICAL_HOST = 1;
2649 $AC_CANONICAL_SYSTEM = 2;
2651 # Associative array of standard directory names. Entry is TRUE if
2652 # corresponding directory should be installed during
2653 # 'install-exec' phase.
2671 # Helper text for dealing with man pages.
2672 $install_man_format =
2673 ' sect=@SECTION@; \\
2674 inst=`echo "@MANBASE@" | sed \'$(transform)\'`.@FULLSECT@; \\
2675 if test -f $(srcdir)/@MAN@; then file=$(srcdir)/@MAN@; \\
2676 else file=@MAN@; fi; \\
2677 $(INSTALL_DATA) $$file $(mandir)/man$$sect/$$inst
2680 $uninstall_man_format =
2681 ' inst=`echo "@MANBASE@" | sed \'$(transform)\'`.@FULLSECT@; \\
2682 rm -f $(mandir)/man@SECTION@/$$inst
2685 # Commonly found files we look for and automatically include in
2689 "README", "THANKS", "TODO", "NEWS", "COPYING", "COPYING.LIB",
2690 "INSTALL", "ABOUT-NLS", "ChangeLog", "configure", "configure.in",
2691 "config.guess", "config.sub", "AUTHORS", "BACKLOG", "ABOUT-GNU",
2692 "libversion.in", "mdate-sh", "mkinstalldirs", "install-sh",
2693 'texinfo.tex', "ansi2knr.c", "ansi2knr.1", 'elisp-comp'
2696 # Commonly used files we auto-include, but only sometimes.
2699 "aclocal.m4", "acconfig.h", "config.h.top",
2700 "config.h.bot", "stamp-h.in", 'stamp-vti', 'libtool'
2704 --amdir=DIR directory storing config files
2705 --foreign same as --strictness=foreign
2706 --gnits same as --strictness=gnits
2707 --gnu same as --strictness=gnu
2708 --help print this help, then exit
2709 -i, --include-deps include generated dependencies in Makefile.in
2710 -a, --add-missing add missing standard files to package
2711 --no-force only update Makefile.in's that are out of date
2712 -o DIR, --output-dir=DIR
2713 put generated Makefile.in's into DIR
2714 -s LEVEL, --strictness=LEVEL
2715 set strictness level. LEVEL is foreign, gnu, gnits
2716 -v, --verbose verbosely list files processed
2717 --version print version number, then exit\n";
2719 # Copyright on generated Makefile.ins.
2721 # Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
2722 # This Makefile.in is free software; the Free Software Foundation
2723 # gives unlimited permission to copy, distribute and modify it.
2727 # (Re)-Initialize per-Makefile.am variables.
2728 sub initialize_per_input
2730 # These two variables are used when generating each Makefile.in.
2731 # They hold the Makefile.in until it is ready to be printed.
2734 $output_trailer = '';
2736 # Suffixes found during a run.
2739 # This holds the contents of a Makefile.am, as parsed by
2743 # This holds the names which are targets. These also appear in
2747 # This holds the line numbers at which various elements of
2748 # %contents are defined.
2749 %content_lines = ();
2751 # This holds the "relative directory" of the current Makefile.in.
2752 # Eg for src/Makefile.in, this is "src".
2755 # This holds a list of files that are included in the
2759 # List of dependencies for the obvious targets.
2774 # These are pretty obvious, too. They are used to define the
2775 # SOURCES and OBJECTS variables.
2779 # TRUE if current directory holds any C source files. (Actually
2780 # holds object extension, but this information is encapsulated in
2781 # the function get_object_extension).
2782 $dir_holds_sources = '';
2784 # TRUE if current directory holds any headers.
2785 $dir_holds_headers = 0;
2787 # TRUE if install targets should work recursively.
2788 $recursive_install = 0;
2793 # Strictness levels.
2794 $strictness = $default_strictness;
2795 $strictness_name = $default_strictness_name;
2797 # Options from AUTOMAKE_OPTIONS.
2800 # Whether or not dependencies are handled. Can be further changed
2801 # in handle_options.
2802 $use_dependencies = $cmdline_use_dependencies;
2805 $local_maint_charset = $maint_charset;
2809 ################################################################
2811 # Return contents of a file from $am_dir, automatically skipping
2812 # macros or rules which are already known. Runs command on each line
2813 # as it is read; this command can modify $_.
2814 sub file_contents_with_transform
2816 local ($command, $basename) = @_;
2817 local ($file) = $am_dir . '/' . $basename . '.am';
2819 open (FC_FILE, $file)
2820 || die "automake: installation error: cannot open \`$file'\n";
2822 # print "automake: reading $file\n" if $verbose;
2824 local ($was_rule) = 0;
2825 local ($result_vars) = '';
2826 local ($result_rules) = '';
2827 local ($comment) = '';
2828 local ($spacing) = "\n";
2829 local ($skipping) = 0;
2833 $_ =~ s/\@MAINT\@//g
2834 unless $seen_maint_mode;
2838 if (/$IGNORE_PATTERN/o)
2840 # Merely delete comments beginning with two hashes.
2842 elsif (/$WHITE_PATTERN/o)
2844 # Stick a single white line before the incoming macro or rule.
2847 elsif (/$COMMENT_PATTERN/o)
2849 # Stick comments before the incoming macro or rule.
2850 $comment .= $spacing . $_;
2857 $result_rules .= $_ if ! $skipping;
2861 $result_vars .= $_ if ! $skipping;
2865 elsif (/$RULE_PATTERN/o)
2867 # warn "** Found rule .$1.\n";
2870 $skipping = defined $contents{$1};
2871 # warn "** Skip $skipping\n" if $skipping;
2872 $result_rules .= $comment . $spacing . $_ if ! $skipping;
2873 $comment = $spacing = '';
2876 elsif (/$MACRO_PATTERN/o)
2878 # warn "** Found macro .$1.\n";
2879 # Found a variable reference.
2881 $skipping = defined $contents{$1};
2882 # warn "** Skip $skipping\n" if $skipping;
2883 $result_vars .= $comment . $spacing . $_ if ! $skipping;
2884 $comment = $spacing = '';
2889 # This isn't an error; it is probably a continued rule.
2890 # In fact, this is what we assume.
2892 $result_rules .= $comment . $spacing . $_ if ! $skipping;
2893 $comment = $spacing = '';
2899 return $result_vars . $result_rules . $comment;
2902 # Like file_contents_with_transform, but no transform.
2905 return &file_contents_with_transform ('', @_);
2908 # Find all variable prefixes that are used for install directories. A
2909 # prefix `zar' qualifies iff:
2910 # * `zardir' is a variable.
2911 # * `zar_PRIMARY' is a variable.
2912 sub am_primary_prefixes
2914 local ($primary, @prefixes) = @_;
2916 local (%valid, $varname);
2917 grep ($valid{$_} = 0, @prefixes);
2918 $valid{'EXTRA'} = 0;
2919 foreach $varname (keys %contents)
2921 if ($varname =~ /^(.*)_$primary$/)
2923 if (! defined $valid{$1} && ! &variable_defined ($1 . 'dir'))
2925 &am_line_error ($varname, "invalid variable \"$varname\"");
2929 # Ensure all extended prefixes are actually used.
2938 # Handle `where_HOW' variable magic. Does all lookups, generates
2939 # install code, and possibly generates code to define the primary
2940 # variable. The first argument is the name of the .am file to munge,
2941 # the second argument is the primary variable (eg HEADERS), and all
2942 # subsequent arguments are possible installation locations. Returns
2943 # list of all values of all _HOW targets.
2945 # FIXME this should be rewritten to be cleaner. It should be broken
2946 # up into multiple functions.
2948 # Usage is: am_install_var (OPTION..., file, HOW, where...)
2953 local ($do_all, $do_clean) = (1, 0);
2956 if ($args[0] eq '-clean')
2960 elsif ($args[0] eq '-no-all')
2964 elsif ($args[0] !~ /^-/)
2970 local ($file, $primary, @prefixes) = @args;
2973 local (@result) = ();
2975 # Now that configure substitutions are allowed in where_HOW
2976 # variables, it is an error to actually define the primary.
2977 &am_line_error ($primary, "\`$primary' is an anachronism")
2978 if &variable_defined ($primary);
2981 # Look for misspellings. It is an error to have a variable ending
2982 # in a "reserved" suffix whose prefix is unknown, eg
2983 # "bni_PROGRAMS". However, unusual prefixes are allowed if a
2984 # variable of the same name (with "dir" appended) exists. For
2985 # instance, if the variable "zardir" is defined, then
2986 # "zar_PROGRAMS" becomes valid. This is to provide a little extra
2987 # flexibility in those cases which need it. Perhaps it should be
2988 # disallowed in the Gnits case? The problem is, sometimes it is
2989 # useful to put things in a subdir of eg pkgdatadir, perhaps even
2991 local (%valid) = &am_primary_prefixes ($primary, @prefixes);
2993 local ($clean_file) = $file . '-clean';
2996 foreach $X (keys %valid)
2998 $one_name = $X . '_' . $primary;
2999 if (&variable_defined ($one_name))
3001 # Append actual contents of where_PRIMARY variable to
3004 foreach $rcurs (split (' ', $contents{$one_name}))
3006 # Skip configure substitutions. Possibly bogus.
3007 next if $rcurs =~ /^\@.*\@$/;
3008 push (@result, $rcurs);
3011 # "EXTRA" shouldn't be used when generating clean targets,
3012 # @all, or install targets.
3013 next if $X eq 'EXTRA';
3018 &file_contents_with_transform ('s/\@DIR\@/' . $X . '/go',
3021 push (@clean, $X . $primary);
3022 &push_phony_cleaners ($X . $primary);
3027 push (@check, '$(' . $one_name . ')');
3031 push (@used, '$(' . $one_name . ')');
3033 if ($X eq 'noinst' || $X eq 'check')
3035 # Objects which don't get installed by default.
3040 &file_contents_with_transform ('s/\@DIR\@/' . $X . '/go',
3043 push (@uninstall, 'uninstall-' . $X . $primary);
3044 push (@phony, 'uninstall-' . $X . $primary);
3045 push (@installdirs, '$(' . $X . 'dir)');
3046 if ($exec_dir_p{$X})
3048 push (@install_exec, 'install-' . $X . $primary);
3049 push (@phony, 'install-' . $X . $primary);
3053 push (@install_data, 'install-' . $X . $primary);
3054 push (@phony, 'install-' . $X . $primary);
3062 &pretty_print ($primary . ' =', '', @used);
3063 $output_vars .= "\n";
3066 # Push here because PRIMARY might be configure time determined.
3067 push (@all, '$(' . $primary . ')')
3068 if $do_all && @used;
3074 ################################################################
3076 # This variable is local to the "require file" set of functions.
3077 @require_file_paths = ();
3079 # Verify that the file must exist in the current directory. Usage:
3080 # require_file (isconfigure, line_number, strictness, file) strictness
3081 # is the strictness level at which this file becomes required. Must
3082 # set require_file_paths before calling this function.
3083 # require_file_paths is set to hold a single directory (the one in
3084 # which the first file was found) before return.
3085 sub require_file_internal
3087 local ($is_configure, $line, $mystrict, @files) = @_;
3088 local ($file, $fullfile);
3089 local ($found_it, $errfile, $errdir);
3092 foreach $file (@files)
3095 foreach $dir (@require_file_paths)
3099 $fullfile = $relative_dir . "/" . $file;
3100 $errdir = $relative_dir unless $errdir;
3104 $fullfile = $dir . "/" . $file;
3105 $errdir = $dir unless $errdir;
3108 # Use different name for "error filename". Otherwise on
3109 # an error the bad file will be reported as eg
3110 # `../../install-sh' when using the default
3112 $errfile = $errdir . '/' . $file;
3117 &push_dist_common ($file) if $dir eq $relative_dir;
3125 # Prune the path list.
3126 @require_file_paths = $save_dir;
3130 if ($strictness >= $mystrict)
3132 # Only install missing files according to our desired
3134 if ($add_missing && -f ($am_dir . '/' . $file))
3136 # Install the missing file. Symlink if we can, copy
3138 if ($symlink_exists)
3140 symlink ($am_dir . '/' . $file, $errfile);
3144 system ('cp', $am_dir . '/' . $file, $errfile);
3147 # FIXME this is a hack. Should have am_warn.
3148 local ($save) = $exit_status;
3153 "required file \"$errfile\" not found; installing");
3159 "required file \"$errfile\" not found; installing");
3161 $exit_status = $save;
3165 # Only an error if strictness constraint violated.
3169 ($line, "required file \"$errfile\" not found");
3174 ($line, "required file \"$errfile\" not found");
3182 # Like require_file_with_line, but error messages refer to
3183 # configure.in, not the current Makefile.am.
3184 sub require_file_with_conf_line
3186 @require_file_paths = '.';
3187 &require_file_internal (1, @_);
3190 sub require_file_with_line
3192 @require_file_paths = '.';
3193 &require_file_internal (0, @_);
3198 @require_file_paths = '.';
3199 &require_file_internal (0, '', @_);
3202 # Require a file that is also required by Autoconf. Looks in
3203 # configuration path, as specified by AC_CONFIG_AUX_DIR.
3204 sub require_config_file
3206 @require_file_paths = @config_aux_path;
3207 &require_file_internal (0, '', @_);
3208 local ($dir) = $require_file_paths[0];
3209 @config_aux_path = @require_file_paths;
3212 $config_aux_dir = '.';
3216 $config_aux_dir = '$(top_srcdir)/' . $dir;
3220 # Assumes that the line number is in Makefile.am.
3221 sub require_conf_file_with_line
3223 @require_file_paths = @config_aux_path;
3224 &require_file_internal (0, @_);
3225 local ($dir) = $require_file_paths[0];
3226 @config_aux_path = @require_file_paths;
3229 $config_aux_dir = '.';
3233 $config_aux_dir = '$(top_srcdir)/' . $dir;
3237 # Assumes that the line number is in Makefile.am.
3238 sub require_conf_file_with_conf_line
3240 @require_file_paths = @config_aux_path;
3241 &require_file_internal (1, @_);
3242 local ($dir) = $require_file_paths[0];
3243 @config_aux_path = @require_file_paths;
3246 $config_aux_dir = '.';
3250 $config_aux_dir = '$(top_srcdir)/' . $dir;
3254 ################################################################
3256 # Push a list of files onto dist_common.
3257 sub push_dist_common
3259 local (@files) = @_;
3262 foreach $file (@files)
3264 $dist_common{$file} = 1;
3268 # Push a list of clean targets onto phony.
3269 sub push_phony_cleaners
3273 foreach $target ('mostly', 'dist', '', 'maintainer-')
3275 push (@phony, $target . 'clean-' . $base);
3282 $strictness_name = $_[0];
3283 if ($strictness_name eq 'gnu')
3287 elsif ($strictness_name eq 'gnits')
3289 $strictness = $GNITS;
3291 elsif ($strictness_name eq 'foreign')
3293 $strictness = $FOREIGN;
3297 die "automake: level \`$strictness_name' not recognized\n";
3302 ################################################################
3304 # Return directory name of file.
3310 ($sub = $file) =~ s,/+[^/]+$,,g;
3311 $sub = '.' if $sub eq $file;
3318 local ($dirname) = @_;
3319 system ("mkdir", $dirname);
3322 ################################################################
3324 # Print an error message and set exit status.
3327 warn "automake: ${am_file}.am: ", join (' ', @_), "\n";
3333 local ($symbol, @args) = @_;
3337 # If SYMBOL not already a line number, look it up in Makefile.am.
3338 $symbol = $content_lines{$symbol} unless $symbol =~ /^\d+$/;
3339 $symbol .= ': ' if $symbol;
3340 warn "${am_file}.am:", $symbol, join (' ', @args), "\n";
3349 # Like am_error, but while scanning configure.in.
3352 # FIXME can run in subdirs.
3353 warn "automake: configure.in: ", join (' ', @_), "\n";
3357 # Error message with line number referring to configure.in.
3358 sub am_conf_line_error
3360 local ($line, @args) = @_;
3364 warn "configure.in: $line: ", join (' ', @args), "\n";
3369 &am_conf_error (@args);
3373 # Tell user where our aclocal.m4 is, but only once.
3374 sub keyed_aclocal_warning
3377 warn "automake: macro \`$key' can be generated by \`aclocal'\n";
3380 # Print usage information.
3383 print "Usage: automake [OPTION] ... [Makefile]...\n";
3385 print "\nFiles which are automatically distributed, if found:\n";
3386 $~ = "USAGE_FORMAT";
3387 local (@lcomm) = sort ((@common_files, @common_sometimes));
3388 local ($one, $two, $three, $four);
3391 $one = shift @lcomm;
3392 $two = @lcomm ? shift @lcomm : '';
3393 $three = @lcomm ? shift @lcomm : '';
3394 $four = @lcomm ? shift @lcomm : '';
3401 format USAGE_FORMAT =
3402 @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<
3403 $one, $two, $three, $four