5 eval 'exec @PERL@ -S $0 ${1+"$@"}'
8 # automake - create Makefile.in from Makefile.am
9 # Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
11 # This program is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by
13 # the Free Software Foundation; either version 2, or (at your option)
16 # This program is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write to the Free Software
23 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
26 # Originally written by David Mackenzie <djm@gnu.ai.mit.edu>.
27 # Perl reimplementation by Tom Tromey <tromey@drip.colorado.edu>.
30 # Parameters set by configure. Not to be changed. NOTE: assign
31 # VERSION as string so that eg version 0.30 will print correctly.
32 $VERSION = "@VERSION@";
34 $am_dir = "@datadir@/@PACKAGE@";
37 $IGNORE_PATTERN = "^##([^#].*)?\$";
38 $WHITE_PATTERN = "^[ \t]*\$";
39 $COMMENT_PATTERN = "^#";
40 $RULE_PATTERN = "^([\$a-zA-Z_.][-.a-zA-Z0-9_(){}/]*) *:";
41 $MACRO_PATTERN = "^([A-Za-z][A-Za-z0-9_]*)[ \t]*=[ \t]*(.*)\$";
42 $BOGUS_MACRO_PATTERN = "^([^ \t]*)[ \t]*=[ \t]*(.*)\$";
44 # Constants to define the "strictness" level.
51 # Variables global to entire run.
53 # TRUE if we should always generate Makefile.in.
54 $force_generation = 1;
56 # Strictness level as set on command line.
57 $default_strictness = $GNU;
59 # Name of strictness level, as set on command line.
60 $default_strictness_name = 'gnu';
62 # This is TRUE if GNU make specific automatic dependency generation
63 # code should be included in generated Makefile.in.
64 $cmdline_use_dependencies = 1;
66 # TRUE if in verbose mode.
69 # This holds our (eventual) exit status. We don't actually exit until
70 # we have processed all input files.
73 # From the Perl manual.
74 $symlink_exists = (eval 'symlink ("", "");', $@ eq '');
76 # TRUE if missing standard files should be installed.
79 # Files found by scanning configure.in for LIBOBJS.
82 # True if fp_C_PROTOTYPES appears in configure.in.
85 # Names used in AC_CONFIG_HEADER call. $config_name is the actual
86 # (first) argument. $config_header is the '.in' file. Ordinarily the
87 # second is derived from the first, but they can be different if the
88 # weird "NAME:FILE" syntax is used.
91 # Line number at which AC_CONFIG_HEADER appears in configure.in.
92 $config_header_line = 0;
94 # Directory where output files go. Actually, output files are
95 # relative to this directory.
96 $output_directory = '.';
98 # Relative location of top build directory.
101 # List of Makefile.am's to process.
104 # List of files in AC_OUTPUT without Makefile.am.
105 @other_input_files = ();
106 # Line number at which AC_OUTPUT seen.
109 # List of directories to search for configure-required files. This
110 # can be set by AC_CONFIG_AUX_DIR.
111 @config_aux_path = ('.', '..', '../..');
112 $config_aux_dir = '';
114 # Whether AC_PROG_MAKE_SET has been seen in configure.in.
117 # Whether ud_GNU_GETTEXT has been seen in configure.in.
119 # Line number at which ud_GNU_GETTEXT seen.
120 $ac_gettext_line = 0;
122 # Whether ALL_LINGUAS has been seen.
126 # Line number at which it appears.
127 $all_linguas_line = 0;
129 # 1 if AC_PROG_INSTALL seen, 2 if fp_PROG_INSTALL seen.
130 $seen_prog_install = 0;
132 # 1 if any scripts installed, 0 otherwise.
133 $scripts_installed = 0;
135 # Whether AC_PATH_XTRA has been seen in configure.in.
138 # Whether YACC variable has been seen in configure.in.
141 # TRUE if we've seen AC_CANONICAL_(HOST|SYSTEM). The presence of
142 # AC_CHECK_TOOL also sets this.
145 # TRUE if we've seen AC_PROG_RANLIB.
148 # TRUE if we've seen AC_ARG_PROGRAM.
151 # TRUE if we've seen AM_PROG_LIBTOOL.
155 # TRUE if we've seen jm_MAINTAINER_MODE.
156 $seen_maint_mode = 0;
158 # TRUE if we've seen PACKAGE and VERSION.
162 # TRUE if we've seen ud_PATH_LISPDIR.
166 # Charsets used by maintainer and in distribution. MAINT_CHARSET is
167 # handled in a funny way: if seen in the top-level Makefile.am, it is
168 # used for every directory which does not specify a different value.
169 # The rationale here is that some directories (eg gettext) might be
170 # distributions of other packages, and thus require their own charset
171 # info. However, the DIST_CHARSET must be the same for the entire
172 # package; it can only be set at top-level.
173 # FIXME this yields bugs when rebuilding. What to do? Always
174 # read (and sometimes discard) top-level Makefile.am?
176 $dist_charset = 'utf8'; # recode doesn't support this yet.
178 # Name of input file ("Makefile.in") and output file ("Makefile.am").
179 # These have no directory components.
185 &initialize_global_constants;
187 # Parse command line.
188 &parse_arguments (@ARGV);
190 # Do configure.in scan only once.
193 die "automake: no \`Makefile.am' found or specified\n"
196 # Now do all the work on each file.
197 foreach $am_file (@input_files)
199 # FIXME should support the AC_OUTPUT ":" syntax here.
200 if (! -f ($am_file . '.am'))
202 &am_error ('no such file');
206 &generate_makefile ($am_file);
210 if ($seen_prog_install <= $scripts_installed)
212 &am_conf_error (($scripts_installed ? 'fp_PROG_INSTALL' : 'AC_PROG_INSTALL')
213 . " must be used in configure.in");
214 &keyed_aclocal_warning ('fp_PROG_INSTALL')
215 if $scripts_installed;
221 ################################################################
223 # Parse command line.
226 local (@arglist) = @_;
229 &set_strictness ('gnu');
233 if ($arglist[0] eq "--version")
235 print "Automake version $VERSION\n";
238 elsif ($arglist[0] eq "--help")
242 elsif ($arglist[0] =~ /^--amdir=(.+)$/)
246 elsif ($arglist[0] eq '--amdir')
248 &require_argument (@arglist);
250 $am_dir = $arglist[0];
252 elsif ($arglist[0] =~ /^--strictness=(.+)$/)
254 &set_strictness ($1);
256 elsif ($arglist[0] eq '--gnu')
258 &set_strictness ('gnu');
260 elsif ($arglist[0] eq '--gnits')
262 &set_strictness ('gnits');
264 elsif ($arglist[0] eq '--foreign')
266 &set_strictness ('foreign');
268 elsif ($arglist[0] eq '--strictness' || $arglist[0] eq '-s')
270 &require_argument (@arglist);
272 &set_strictness ($arglist[0]);
274 elsif ($arglist[0] eq '--include-deps' || $arglist[0] eq '-i')
276 $cmdline_use_dependencies = 0;
278 elsif ($arglist[0] eq '--no-force')
280 $force_generation = 0;
282 elsif ($arglist[0] =~ /^--output-dir=(.*)$/)
284 # Set output directory.
285 $output_directory = $1;
287 elsif ($arglist[0] eq '--output-dir' || $arglist[0] eq '-o')
289 &require_argument (@arglist);
291 $output_directory = $arglist[0];
293 elsif ($arglist[0] eq '--add-missing' || $arglist[0] eq '-a')
297 elsif ($arglist[0] eq '--verbose' || $arglist[0] eq '-v')
301 elsif ($arglist[0] eq '--')
303 # Stop option processing.
305 push (@input_files, @arglist);
308 elsif ($arglist[0] =~ /^-/)
310 die "automake: unrecognized option -- \`$arglist[0]'\n";
314 push (@input_files, $arglist[0]);
320 # Take global strictness from whatever we currently have set.
321 $default_strictness = $strictness;
322 $default_strictness_name = $strictness_name;
325 # Ensure argument exists, or die.
328 local ($arg, @arglist) = @_;
329 die "automake: no argument given for option \`$arg'\n"
333 ################################################################
335 # Generate a Makefile.in given the name of the corresponding Makefile.
336 sub generate_makefile
338 local ($makefile) = @_;
340 ($am_file_name = $makefile) =~ s/^.*\///;
341 $in_file_name = $am_file_name . '.in';
342 $am_file_name .= '.am';
344 &initialize_per_input;
345 $relative_dir = &dirname ($makefile);
347 # At the toplevel directory, we might need config.guess, config.sub
349 if ($relative_dir eq '.')
351 # libtool requires some files.
352 &require_conf_file_with_conf_line ($libtool_line, $FOREIGN,
353 'config.sub', 'config.guess',
354 'libtool') if $seen_libtool;
356 # AC_CANONICAL_HOST and AC_CANONICAL_SYSTEM need config.guess and
358 &require_config_file ($FOREIGN, 'config.guess', 'config.sub')
362 # We still need Makefile.in here, because sometimes the `dist'
363 # target doesn't re-run automake.
364 &push_dist_common ($in_file_name, $am_file_name);
365 push (@sources, '$(SOURCES)')
366 if &variable_defined ('SOURCES');
367 push (@objects, '$(OBJECTS)')
368 if &variable_defined ('OBJECTS');
370 # This is always the default target. This gives us freedom to do
371 # things in whatever order is convenient.
372 $output_rules .= "default: all\n\n";
373 push (@phony, 'default');
375 &read_am_file ($makefile . '.am');
378 # Check first, because we might modify some state.
379 &check_gnu_standards;
380 &check_gnits_standards;
388 # Re-init SOURCES and OBJECTS. FIXME other code shouldn't depend
389 # on this (but currently does).
390 $contents{'SOURCES'} = join (' ', @sources);
391 $contents{'OBJECTS'} = join (' ', @objects);
401 &handle_dependencies;
404 &handle_merge_targets;
409 if (! -d ($output_directory . '/' . $relative_dir))
411 &mkdir ($output_directory . '/' . $relative_dir);
414 local ($out_file) = $output_directory . '/' . $makefile . ".in";
415 if (! $force_generation && -e $out_file)
417 local ($am_time) = (stat ($makefile . '.am'))[9];
418 local ($in_time) = (stat ($out_file))[9];
419 # FIXME how to do unsigned comparison?
420 if ($am_time < $in_time)
427 if (! open (GM_FILE, "> " . $out_file))
429 warn "automake: ${am_file}.in: cannot open: $!\n";
433 print "automake: creating ", $makefile, ".in\n" if $verbose;
435 print GM_FILE $output_vars;
436 print GM_FILE $output_rules;
437 print GM_FILE $output_trailer;
442 ################################################################
444 # Handle AUTOMAKE_OPTIONS variable.
447 return if ! &variable_defined ('AUTOMAKE_OPTIONS');
449 foreach (split (' ', $contents{'AUTOMAKE_OPTIONS'}))
452 if ($_ eq 'gnits' || $_ eq 'gnu' || $_ eq 'foreign')
454 &set_strictness ($_);
456 elsif ($_ eq 'no-installman' || $_ eq 'ansi2knr'
457 || $_ eq 'dist-shar' || $_ eq 'dist-zip'
458 || $_ eq 'dejagnu' || $_ eq 'no-installinfo')
460 # Explicitly recognize these.
462 elsif ($_ eq 'no-dependencies')
464 $use_dependencies = 0;
466 elsif (/[0-9]+\.?[0-9]+/)
468 # Got a version number. Is the syntax too strict?
469 local ($num_version);
470 ($num_version = $VERSION) =~ tr/0-9//cd;
471 if ($num_version < $_)
473 &am_line_error ('AUTOMAKE_OPTIONS',
474 "require version $_, only have $VERSION");
480 &am_line_error ('AUTOMAKE_OPTIONS',
481 'option ', $_, 'not recognized');
486 # Return object extension. Just once, put some code into the output.
487 sub get_object_extension
489 if (! $dir_holds_sources)
493 if (&variable_defined ('CONFIG_HEADER'))
495 ($xform = &dirname ($contents{'CONFIG_HEADER'}))
497 $xform = '-I' . $xform;
499 $xform = 's/\@CONFIG_INCLUDE_SPEC\@/' . $xform . '/go';
500 $output_vars .= &file_contents_with_transform ($xform,
502 $output_rules .= &file_contents ('compile');
503 &push_phony_cleaners ('compile');
505 # If using X, include some extra variable definitions. NOTE
506 # we don't want to force these into CFLAGS or anything,
507 # because not all programs will necessarily use X.
510 $output_vars .= ("X_CFLAGS = \@X_CFLAGS\@\n"
511 . "X_LIBS = \@X_LIBS\@\n"
512 . "X_EXTRA_LIBS = \@X_EXTRA_LIBS\@\n"
513 . "X_PRE_LIBS = \@X_PRE_LIBS\@\n");
516 # Check for automatic de-ANSI-fication.
517 $dir_holds_sources = '.o';
518 push (@suffixes, '.c', '.o');
519 push (@clean, 'compile');
521 if (defined $options{'ansi2knr'})
523 if (! $fp_c_prototypes)
525 &am_line_error ('AUTOMAKE_OPTIONS',
526 "option \`ansi2knr' in use but \`fp_C_PROTOTYPES' not in configure.in");
527 &keyed_aclocal_warning ('fp_C_PROTOTYPES');
528 # Only give this error once.
529 $fp_c_prototypes = 1;
532 $dir_holds_sources = '$o';
533 push (@suffixes, '._c', '._o');
535 &require_file_with_line ('AUTOMAKE_OPTIONS', $FOREIGN,
536 'ansi2knr.c', 'ansi2knr.1');
538 $output_vars .= &file_contents ('kr-vars');
539 $output_rules .= &file_contents ('compile-kr');
540 $output_rules .= &file_contents ('clean-kr');
543 &push_phony_cleaners ('kr');
546 return $dir_holds_sources;
549 # Handle SOURCE->OBJECT transform for one program or library.
550 sub handle_source_transform
552 # one_file is canonical name. unxformed is given name. obj is
554 local ($one_file, $unxformed, $obj) = @_;
555 local ($objpat) = $obj;
556 $objpat =~ s/(\W)/\\$1/g;
558 if (&variable_defined ($one_file . "_OBJECTS"))
560 &am_line_error ($one_file . '_OBJECTS',
561 $one_file . '_OBJECTS', 'should not be defined');
562 # No point in continuing.
566 local ($source_list);
568 foreach $prefix ('', 'EXTRA_')
571 if (&variable_defined ($prefix . $one_file . "_SOURCES"))
573 push (@sources, '$(' . $prefix . $one_file . "_SOURCES)");
574 push (@objects, '$(' . $prefix . $one_file . "_OBJECTS)")
575 unless $prefix eq 'EXTRA_';
576 $source_list = $contents{$prefix . $one_file . "_SOURCES"};
578 elsif ($prefix eq '')
580 $output_vars .= $one_file . "_SOURCES = " . $unxformed . ".c\n";
581 push (@sources, $unxformed . '.c');
582 push (@objects, $unxformed . $obj);
583 $source_list = $unxformed . ".c ";
587 $output_vars .= "EXTRA_" . $one_file . "_SOURCES =\n";
592 # Turn sources into objects.
593 local (@files) = split (' ', $source_list);
594 local (@result) = ();
597 # Skip header files, including C++-ish ones.
600 # Skip things that look like macro references.
601 next if /^\$\(.*\)$/;
602 next if /^\$\{.*\}$/;
603 # Skip things that look like configure substitutions.
606 # Include .c file for lex or yacc source in distribution.
610 &push_dist_common ($1 . '.c');
611 if (! defined $targets{$1 . '.c'})
614 $output_rules .= ($1 . '.c: ' . $_ . "\n"
616 . 'cd $(srcdir) && $(YACC) $(YFLAGS) $< && mv y.tab.c '
623 &push_dist_common ($1 . '.c');
624 if (! defined $targets{$1 . '.c'})
626 $output_rules .= ($1 . '.c: ' . $_ . "\n"
628 . 'cd $(srcdir) && $(LEX) $(LFLAGS) $< && mv lex.yy.c '
633 # Transform source files into .o files.
636 s/\.[cCmylfs]$/$obj/g;
638 unless $prefix eq 'EXTRA_';
640 # Transform .o or $o file into .P file (for automatic
643 $dep_files{'$(srcdir)/.deps/' . $_} = 1;
646 &pretty_print ($one_file . "_OBJECTS =", "", @result)
647 unless $prefix eq 'EXTRA_';
651 if (&variable_defined ('CONFIG_HEADER'))
653 $output_rules .= ('$(' . $one_file . "_OBJECTS): "
654 . $contents{'CONFIG_HEADER'} . "\n");
660 # Special-case @ALLOCA@ and @LIBOBJS@ in _LDADD or _LIBADD variables.
661 sub handle_lib_objects
665 die "programming error in handle_lib_objects"
666 if ! &variable_defined ($var);
668 # We recognize certain things that are commonly put in LIBADD or
672 foreach $lsearch (split (' ', $contents{$var}))
674 # Automatically handle @LIBOBJS@ and @ALLOCA@. Basically this
675 # means adding entries to dep_files.
676 if ($lsearch eq '@LIBOBJS@')
678 local ($iter, $rewrite);
679 foreach $iter (keys %libsources)
681 if ($iter ne 'alloca.c')
683 ($rewrite = $iter) =~ s/\.c$/.P/;
684 $dep_files{'$(srcdir)/.deps/' . $rewrite} = 1;
685 &require_file_with_line ($var, $FOREIGN, $iter);
689 elsif ($lsearch eq '@ALLOCA@')
691 &am_line_error ($var,
692 "\@ALLOCA\@ seen but \`AC_FUNC_ALLOCA' not in \`configure.in'")
693 if ! defined $libsources{'alloca.c'};
694 $dep_files{'$(srcdir)/.deps/alloca.P'} = 1;
695 &require_file_with_line ($var, $FOREIGN, 'alloca.c');
703 local (@proglist) = &am_install_var ('-clean',
704 'programs', 'PROGRAMS',
705 'bin', 'sbin', 'libexec', 'pkglib',
707 return if ! @proglist;
709 # If a program is installed, this is required. We only want this
710 # error to appear once.
711 &am_conf_error ("AC_ARG_PROGRAM must be used in configure.in")
712 unless $seen_arg_prog;
715 local ($obj) = &get_object_extension;
716 local ($one_file, $xname, $munge);
718 foreach $one_file (@proglist)
720 # Canonicalize names.
721 ($xname = $one_file) =~ tr/A-Za-z0-9_/_/c;
722 if ($xname ne $one_file)
725 foreach $xt ('_LDADD', '_SOURCES', '_OBJECTS', '_DEPENDENCIES')
727 &am_line_error ($one_file . $xt,
728 "invalid variable \`" . $one_file . $xt
729 . "'; should be \`" . $xname . $xt . "'")
730 if &variable_defined ($one_file . $xt);
734 &handle_source_transform ($xname, $one_file, $obj);
736 if (&variable_defined ($xname . "_LDADD"))
738 &handle_lib_objects ($xname . '_LDADD');
742 # User didn't define prog_LDADD override. So do it.
743 $output_vars .= $xname . '_LDADD = $(LDADD)' . "\n";
747 &file_contents_with_transform
748 ('s/\@PROGRAM\@/' . $one_file . '/go;'
749 . 's/\@XPROGRAM\@/' . $xname . '/go;',
753 &handle_lib_objects ('LDADD')
754 if &variable_defined ('LDADD');
760 local (@liblist) = &am_install_var ('-no-all', '-clean',
761 'libraries', 'LIBRARIES',
762 'lib', 'pkglib', 'noinst', 'check');
763 return if ! @liblist;
767 # FIXME need am_line_error here. But we don't know which
768 # variable exists. Must add a loop... No. Must have
769 # am_install_var return a hash. Otherwise the user could add
770 # install directories that we'd never find.
771 &am_error ("library requires either \`AC_PROG_RANLIB' or `AM_PROG_LIBTOOL' in configure.in");
772 # Only get this error once.
776 # Generate _LIBFILES variables. Too bad we can't do this in
778 local ($onedir, $onelib);
780 foreach $onedir ('lib', 'pkglib', 'noinst', 'check')
782 if (&variable_defined ($onedir . '_LIBRARIES'))
785 foreach $onelib (split (' ', $contents{$onedir . '_LIBRARIES'}))
787 push (@outlist, 'lib' . $onelib . '.a');
789 &pretty_print ($onedir . '_LIBFILES =', "", @outlist);
792 push (@all, '$(LIBFILES)');
794 local ($obj) = &get_object_extension;
796 foreach $onelib (@liblist)
798 if (&variable_defined ($onelib . '_LIBADD'))
800 &handle_lib_objects ($onelib . '_LIBADD');
804 # Generate support for conditional object inclusion in
806 $output_vars .= $onelib . "_LIBADD =\n";
809 &handle_source_transform ($onelib, $onelib, $obj);
812 &file_contents_with_transform ('s/\@LIBRARY\@/' . $onelib . '/go',
816 # Turn "foo" into "libfoo.a" and include macro definition.
817 grep (($_ = 'lib' . $_ . '.a') && 0, @liblist);
819 if (! &variable_defined ('LIBFILES'))
821 &pretty_print ('LIBFILES = ', "", @liblist);
826 $output_vars .= ('AR = $(LIBTOOL) archive' . "\n"
827 . 'RANLIB = $(LIBTOOL) ranlib' . "\n"
828 . 'LCOMPILE = $(LIBTOOL) compile $(DEFS) $(INCLUDES)'
829 . ' $(CPPFLAGS) $(CFLAGS)' . "\n");
833 $output_vars .= ('AR = ar' . "\n"
834 . 'RANLIB = @RANLIB@' . "\n");
841 # NOTE we no longer automatically clean SCRIPTS, because it is
842 # useful to sometimes distribute scripts verbatim. This happens
843 # eg in Automake itself.
845 $msi = &am_install_var ('scripts', 'SCRIPTS',
846 'bin', 'sbin', 'libexec', 'pkgdata',
849 # We really only want a boolean value.
850 $scripts_installed = 1 if $msi;
852 if ($scripts_installed)
854 # If a program is installed, this is required. We only want this
855 # error to appear once.
856 &am_conf_error ("AC_ARG_PROGRAM must be used in configure.in")
857 unless $seen_arg_prog;
862 # Search a file for a "version.texi" Texinfo include. Return the name
863 # of the include file if found, or the empty string if not. A
864 # "version.texi" file is actually any file whose name matches
866 sub grep_for_vers_texi
868 local ($filename) = @_;
870 if (! open (TEXI, $filename))
872 &am_error ("couldn't open \`$filename': $!");
875 print "automake: reading $filename\n" if $verbose;
879 if (/^\@include\s+(vers[^.]*\.texi)\s*$/)
891 # Handle all Texinfo source.
894 &am_line_error ('TEXINFOS',
895 "\`TEXINFOS' is an anachronism; use \`info_TEXINFOS'")
896 if &variable_defined ('TEXINFOS');
897 return if (! &variable_defined ('info_TEXINFOS')
898 && ! &variable_defined ('html_TEXINFOS'));
900 local (@texis) = split (' ', $contents{'info_TEXINFOS'});
902 local (@infos_list, @info_deps_list, @dvis_list, @texi_deps);
903 local ($infobase, $info_cursor);
907 local ($tc_cursor, @texi_cleans);
910 foreach $info_cursor (@texis)
912 ($infobase = $info_cursor) =~ s/\.texi$//;
914 # If 'version.texi' is referenced by input file, then include
915 # automatic versioning capability.
917 = &grep_for_vers_texi ($relative_dir . "/" . $info_cursor);
920 &am_error ("\`$vtexi', included in \`$info_cursor', also included in \`$versions{$vtexi}'")
921 if (defined $versions{$vtexi});
922 $versions{$vtexi} = $info_cursor;
924 # We number the stamp-vti files. This is doable since the
925 # actual names don't matter much. We only number starting
926 # with the second one, so that the common case looks nice.
927 $vti = 'vti' . ($done ? $done : '');
928 &push_dist_common ($vtexi, 'stamp-' . $vti);
932 &require_conf_file_with_line ('info_TEXINFOS', $FOREIGN,
938 ($conf_pat = $config_aux_dir) =~ s/(\W)/\\$1/g;
940 &file_contents_with_transform
941 ('s/\@TEXI\@/' . $info_cursor . '/g; '
942 . 's/\@VTI\@/' . $vti . '/g; '
943 . 's/\@VTEXI\@/' . $vtexi . '/g;'
944 . 's,\@MDDIR\@,' . $conf_pat . ',g;',
947 &push_phony_cleaners ($vti);
950 # If user specified file_TEXINFOS, then use that as explicit
953 push (@texi_deps, $info_cursor);
954 push (@texi_deps, $vtexi) if $vtexi;
956 # Canonicalize name first.
957 ($canonical = $infobase) =~ tr/A-Za-z0-9_/_/c;
958 if (&variable_defined ($canonical . "_TEXINFOS"))
960 push (@texi_deps, '$(' . $canonical . '_TEXINFOS)');
961 &push_dist_common ('$(' . $canonical . '_TEXINFOS)');
964 $output_rules .= ("\n" . $infobase . ".info: "
965 . join (' ', @texi_deps) . "\n\n");
967 push (@infos_list, $infobase . '.info', '.info-[0-9]',
969 push (@info_deps_list, $infobase . '.info');
970 push (@dvis_list, $infobase . '.dvi');
972 # Generate list of things to clean for this target. We do
973 # this explicitly because otherwise too many things could be
974 # removed. In particular the ".log" extension might
975 # reasonably be used in other contexts by the user.
976 foreach $tc_cursor ('aux', 'cp', 'cps', 'dvi', 'fn', 'fns',
977 'ky', 'log', 'pg', 'toc', 'tp', 'vr', 'op')
979 push (@texi_cleans, $infobase . '.' . $tc_cursor);
984 $output_vars .= &file_contents ('texinfos-vars');
985 $output_rules .= &file_contents ('texinfos');
986 push (@phony, 'install-info', 'uninstall-info');
989 $output_rules .= "\nmostlyclean-info:\n";
990 &pretty_print_rule ("\trm -f", "\t ", @texi_cleans);
991 $output_rules .= ("\nclean-info:\n\ndistclean-info:\n\n"
992 . "maintainer-clean-info:\n\t"
993 . 'rm -f $(INFOS)' . "\n");
994 &push_phony_cleaners ('info');
996 push (@suffixes, '.texi', '.info', '.dvi');
998 if (! defined $options{'no-installinfo'})
1000 push (@uninstall, 'uninstall-info');
1001 push (@installdirs, '$(infodir)');
1002 unshift (@install_data, 'install-info');
1004 # Make sure documentation is made and installed first. Use
1005 # $(INFO_DEPS), not 'info', because otherwise recursive makes
1006 # get run twice during "make all".
1007 unshift (@all, '$(INFO_DEPS)');
1009 push (@clean, 'info');
1010 push (@info, '$(INFO_DEPS)');
1011 push (@dvi, '$(DVIS)');
1013 $output_vars .= ("INFOS = " . join (' ', @infos_list) . "\n"
1014 . "INFO_DEPS = " . join (' ', @info_deps_list) . "\n"
1015 . "DVIS = " . join (' ', @dvis_list) . "\n"
1016 # This next isn't strictly needed now -- the
1017 # places that look here could easily be changed
1018 # to look in info_TEXINFOS. But this is probably
1019 # better, in case noinst_TEXINFOS is ever
1021 . "TEXINFOS = " . $contents{'info_TEXINFOS'} . "\n\n");
1023 # Do some error checking.
1024 &require_file_with_line ('info_TEXINFOS', $FOREIGN, 'texinfo.tex');
1027 # Handle any man pages.
1028 sub handle_man_pages
1030 &am_line_error ('MANS', "\`MANS' is an anachronism; use \`man_MANS'")
1031 if &variable_defined ('MANS');
1032 return if ! &variable_defined ('man_MANS');
1034 # We generate the manpage install code by hand to avoid the use of
1035 # basename in the generated Makefile.
1036 local (@mans) = split (' ', $contents{'man_MANS'});
1037 local (%sections, %inames, %secmap, %fullsecmap);
1040 # FIXME: statement without effect:
1041 /^(.*)\.([0-9])([a-z]*)$/;
1045 $fullsecmap{$1} = $2 . $3;
1048 # We don't really need this, but we use it in case we ever want to
1049 # support noinst_MANS.
1050 $output_vars .= "MANS = " . $contents{'man_MANS'} . "\n";
1052 # Generate list of install dirs.
1053 $output_rules .= "install-man: \$(MANS)\n";
1054 foreach (keys %sections)
1056 push (@installdirs, '$(mandir)/man' . $_)
1057 unless defined $options{'no-installman'};
1058 $output_rules .= ("\t" . '$(mkinstalldirs) $(mandir)/man'
1061 push (@phony, 'install-man');
1063 # Generate install target.
1065 foreach $key (keys %inames)
1067 $_ = $install_man_format;
1068 s/\@SECTION\@/$secmap{$key}/g;
1069 s/\@MAN\@/$inames{$key}/g;
1070 s/\@FULLSECT\@/$fullsecmap{$key}/g;
1071 s/\@MANBASE\@/$key/g;
1072 $output_rules .= $_;
1074 $output_rules .= "\n";
1076 $output_rules .= "uninstall-man:\n";
1077 foreach $key (keys %inames)
1079 $_ = $uninstall_man_format;
1080 s/\@SECTION\@/$secmap{$key}/g;
1081 s/\@MAN\@/$inames{$key}/g;
1082 s/\@FULLSECT\@/$fullsecmap{$key}/g;
1083 s/\@MANBASE\@/$key/g;
1084 $output_rules .= $_;
1086 $output_rules .= "\n";
1087 push (@phony, 'uninstall-man');
1089 $output_vars .= &file_contents ('mans-vars');
1091 if (! defined $options{'no-installman'})
1093 push (@install_data, 'install-man');
1094 push (@uninstall, 'uninstall-man');
1095 push (@all, '$(MANS)');
1099 # Handle DATA variables.
1102 &am_install_var ('data', 'DATA', 'data', 'sysconf',
1103 'sharedstate', 'localstate', 'pkgdata',
1110 local ($tagging) = 0;
1112 push (@phony, 'tags');
1113 if (&variable_defined ('SUBDIRS'))
1115 $output_rules .= &file_contents ('tags');
1116 push (@phony, 'tags-recursive');
1119 elsif ($dir_holds_sources || &variable_defined ('ETAGS_ARGS'))
1121 $output_rules .= &file_contents ('tags-subd');
1127 $output_rules .= &file_contents ('tags-clean');
1128 push (@clean, 'tags');
1129 &push_phony_cleaners ('tags');
1133 # Every Makefile must define some sort of TAGS rule.
1134 # Otherwise, it would be possible for a top-level "make TAGS"
1135 # to fail because some subdirectory failed.
1136 $output_rules .= "tags: TAGS\nTAGS:\n\n";
1140 # Worker for handle_dist.
1141 sub handle_dist_worker
1143 $output_rules .= 'distdir: $(DEP_DISTFILES)' . "\n";
1145 # Initialization; only at top level.
1146 if ($relative_dir eq '.')
1148 if ($strictness >= $GNITS)
1150 # For Gnits users, this is pretty handy. Look at 15 lines
1151 # in case some explanatory text is desirable.
1152 $output_rules .= ' @if sed 15q $(srcdir)/NEWS | grep -e "$(VERSION)" > /dev/null; then :; else \\
1153 echo "NEWS not updated; not releasing" 1>&2; \\
1161 # Create dist directory.
1164 chmod 777 $(distdir)
1167 # Only run automake in `dist' target if --include-deps not
1168 # specified. That way the recipient of a distribution can run
1169 # "make dist" and not need Automake.
1170 if ($cmdline_use_dependencies)
1174 # We need an absolute path for --output-dir. Thus the
1176 ' distdir=`cd $(distdir) && pwd` \\
1178 && automake --include-deps --output-dir=$$distdir --strictness='
1179 # Set strictness of output.
1180 . $strictness_name . "\n"
1185 # In loop, test for file existence because sometimes a file gets
1186 # included in DISTFILES twice. For example this happens when a
1187 # single source file is used in building more than one program.
1188 # Also, there are situations in which "ln" can fail. For instance
1189 # a file to distribute could actually be a cross-filesystem
1190 # symlink -- this can easily happen if "gettextize" was run on the
1191 # distribution. Note that DISTFILES can contain a wildcard (for
1192 # info files, sigh), so we must use the echo trick.
1193 $output_rules .= ' @for file in `cd $(srcdir) && echo $(DISTFILES)`; do \\
1194 test -f $(distdir)/$$file \\
1195 || ln $(srcdir)/$$file $(distdir)/$$file 2> /dev/null \\
1196 || cp -p $(srcdir)/$$file $(distdir)/$$file; \\
1200 # If we have SUBDIRS, create all dist subdirectories and do
1202 if (&variable_defined ('SUBDIRS'))
1204 # Test for directory existence here because previous automake
1205 # invocation might have created some directories. Note that
1206 # we explicitly set distdir for the subdir make; that lets us
1207 # mix-n-match many automake-using packages into one large
1208 # package, and have "dist" at the top level do the right
1210 $output_rules .= ' for subdir in $(SUBDIRS); do \\
1211 test -d $(distdir)/$$subdir \\
1212 || mkdir $(distdir)/$$subdir \\
1214 chmod 777 $(distdir)/$$subdir; \\
1215 (cd $$subdir && $(MAKE) distdir=../$(distdir)/$$subdir distdir) \\
1221 # If the target `dist-hook' exists, run it now. This allows
1222 # users to do random weird things to the distribution before it is
1224 if (defined $contents{'dist-hook'})
1226 $output_rules .= "\t\$(MAKE) dist-hook\n";
1229 push (@phony, 'distdir');
1232 # Handle 'dist' target.
1235 # Set up maint_charset.
1236 $local_maint_charset = $contents{'MAINT_CHARSET'}
1237 if &variable_defined ('MAINT_CHARSET');
1238 $maint_charset = $local_maint_charset
1239 if $relative_dir eq '.';
1241 if (&variable_defined ('DIST_CHARSET'))
1243 &am_line_error ('DIST_CHARSET',
1244 "DIST_CHARSET defined but no MAINT_CHARSET defined")
1245 if ! $local_maint_charset;
1246 if ($relative_dir eq '.')
1248 $dist_charset = $contents{'DIST_CHARSET'}
1252 &am_line_error ('DIST_CHARSET',
1253 "DIST_CHARSET can only be defined at top level");
1257 # Look for common files that should be included in distribution.
1259 foreach $cfile (@common_files)
1261 if (-f ($relative_dir . "/" . $cfile))
1263 &push_dist_common ($cfile);
1267 # Keys of %dist_common are names of files to distributed. We put
1268 # README first because it then becomes easier to make a
1269 # Usenet-compliant shar file (in these, README must be first).
1270 # FIXME do more ordering of files here.
1272 if (defined $dist_common{'README'})
1274 push (@coms, 'README');
1275 undef $dist_common{'README'};
1277 push (@coms, sort keys %dist_common);
1279 &pretty_print ("DIST_COMMON =", "", @coms);
1280 $output_vars .= "\n";
1283 $output_vars .= &file_contents ('dist-vars');
1285 # Put these things in rules section so it is easier for whoever
1286 # reads Makefile.in.
1287 if ($relative_dir eq '.')
1289 $output_rules .= "\n" . 'distdir = $(PACKAGE)-$(VERSION)' . "\n";
1293 $output_rules .= ("\nsubdir = " . $relative_dir . "\n"
1294 . 'distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)'
1298 # Generate 'dist' target, and maybe dist-shar / dist-zip.
1299 if ($relative_dir eq '.')
1301 # Rule to check whether a distribution is viable.
1302 $output_rules .= ('# This target untars the dist file and tries a VPATH configuration. Then
1303 # it guarantees that the distribution is self-contained by making another
1307 $(TAR) zxf $(distdir).tar.gz
1308 mkdir $(distdir)/=build
1309 mkdir $(distdir)/=inst
1310 dc_install_base=`cd $(distdir)/=inst && pwd`; \\
1311 cd $(distdir)/=build \\
1314 . ($seen_gettext ? '--with-included-gettext ' : '')
1315 . '--srcdir=.. --prefix=$$dc_install_base \\
1319 && $(MAKE) install \\
1320 && $(MAKE) installcheck \\
1323 @echo "========================"; \\
1324 echo "$(distdir).tar.gz is ready for distribution"; \\
1325 echo "========================"
1328 $output_rules .= 'dist: distdir' . "\n\t";
1329 # Ignore return result from chmod, because it might give an
1330 # error if we chmod a symlink.
1331 $output_rules .= '-chmod -R a+r $(distdir)' . "\n\t";
1332 $output_rules .= '$(TAR) chozf $(distdir).tar.gz $(distdir)';
1333 $output_rules .= "\n\t" . 'rm -rf $(distdir)' . "\n";
1335 if (defined $options{'dist-shar'})
1337 $output_rules .= 'dist-shar: distdir' . "\n\t";
1338 # Ignore return result from chmod, because it might give
1339 # an error if we chmod a symlink.
1340 $output_rules .= '-chmod -R a+r $(distdir)' . "\n\t";
1341 $output_rules .= 'shar $(distdir) | gzip > $(distdir).shar.gz';
1342 $output_rules .= "\n\t" . 'rm -rf $(distdir)' . "\n";
1345 if (defined $options{'dist-zip'})
1347 $output_rules .= 'dist-zip: distdir' . "\n\t";
1348 $output_rules .= 'chmod -R a+r $(distdir)' . "\n\t";
1349 $output_rules .= 'zip -rq $(distdir).zip $(distdir)';
1350 $output_rules .= "\n\t" . 'rm -rf $(distdir)' . "\n";
1354 # Generate distdir target.
1355 &handle_dist_worker;
1358 # Handle auto-dependency code.
1359 sub handle_dependencies
1361 if ($use_dependencies)
1363 # Include GNU-make-specific auto-dep code.
1364 if ($dir_holds_sources)
1366 &pretty_print ('DEP_FILES =', "", sort keys %dep_files);
1367 $output_rules .= &file_contents ('depend');
1372 # Include any auto-generated deps that are present.
1373 if (-d ($relative_dir . "/.deps") && -f ($relative_dir . "/.deps/.P"))
1376 local ($gpat) = $relative_dir . "/.deps/*.P";
1378 foreach $depfile (<${gpat}>)
1380 if (! open (DEP_FILE, $depfile))
1382 &am_error ("couldn't open \`$depfile': $!");
1385 print "automake: reading $depfile\n" if $verbose;
1387 # Slurp entire file.
1388 $output_rules .= join ('', <DEP_FILE>);
1393 $output_rules .= "\n";
1398 # Handle subdirectories.
1401 if (! &variable_defined ('SUBDIRS'))
1404 ("ud_GNU_GETTEXT in configure.in but SUBDIRS not defined")
1405 if $seen_gettext && $relative_dir eq '.';
1409 &require_file_with_conf_line ($ac_gettext_line, $FOREIGN, 'ABOUT-NLS')
1412 return if ! &variable_defined ('SUBDIRS');
1414 # Make sure each directory mentioned in SUBDIRS actually exists.
1416 foreach $dir (split (' ', $contents{'SUBDIRS'}))
1418 # Skip directories substituted by configure.
1419 next if $dir =~ /^\@.*\@$/;
1420 &am_line_error ('SUBDIRS',
1421 "required directory $relative_dir/$dir does not exist")
1422 if ! -d $relative_dir . '/' . $dir;
1425 $output_rules .= &file_contents ('subdirs');
1427 # Push a bunch of phony targets.
1429 foreach $phonies ('-data', '-exec', 'dirs')
1431 push (@phony, 'install' . $phonies . '-recursive');
1432 push (@phony, 'uninstall' . $phonies . '-recursive');
1434 foreach $phonies ('all', 'check', 'installcheck', 'info', 'dvi')
1436 push (@phony, $phonies . '-recursive');
1438 &push_phony_cleaners ('recursive');
1440 push (@check, "check-recursive");
1441 push (@installcheck, "installcheck-recursive");
1442 push (@info, "info-recursive");
1443 push (@dvi, "dvi-recursive");
1445 $recursive_install = 1;
1448 # Handle remaking and configure stuff.
1449 sub handle_configure
1451 # If SUBDIRS defined, require AC_PROG_MAKE_SET.
1452 &am_line_error ('SUBDIRS', "AC_PROG_MAKE_SET must be used in configure.in")
1453 if &variable_defined ('SUBDIRS') && ! $seen_make_set;
1455 local ($top_reldir);
1456 if ($relative_dir ne '.')
1459 $output_rules .= &file_contents ('remake-subd');
1460 $top_reldir = '../';
1464 if (-f 'aclocal.m4')
1466 $output_vars .= "ACLOCAL = aclocal.m4\n";
1467 &push_dist_common ('aclocal.m4');
1469 $output_rules .= &file_contents_with_transform ('s/\@STRICTNESS\@/'
1475 ("\`install.sh' is an anachronism; use \`install-sh' instead")
1476 if -f $relative_dir . '/install.sh';
1478 # If we have a configure header, require it.
1481 # FIXME this restriction should be lifted.
1482 # FIXME first see if it is even needed as-is.
1483 &am_conf_line_error ($config_header_line,
1484 "argument to AC_CONFIG_HEADER contains \`/'\n")
1485 if ($config_header =~ /\//);
1487 &require_file_with_conf_line ($config_header_line,
1488 $FOREIGN, $config_header);
1490 # Header defined and in this directory.
1491 if (-f 'acconfig.h')
1493 $output_vars .= "ACCONFIG = acconfig.h\n";
1494 &push_dist_common ('acconfig.h');
1496 if (-f $config_name . '.top')
1498 $output_vars .= "CONFIG_TOP = ${config_name}.top\n";
1499 &push_dist_common ($config_name . '.top');
1501 if (-f $config_name . '.bot')
1503 $output_vars .= "CONFIG_BOT = ${config_name}.bot\n";
1504 &push_dist_common ($config_name . '.bot');
1507 &require_file_with_conf_line ($config_header_line, $FOREIGN,
1510 $output_rules .= &file_contents ('remake-hdr');
1511 $output_vars .= "CONFIG_HEADER_IN = ${config_header}\n";
1517 # Set location of mkinstalldirs.
1518 if ($config_aux_dir ne '.' && $config_aux_dir ne '')
1520 $output_vars .= 'mkinstalldirs = ' . $config_aux_dir;
1524 $output_vars .= 'mkinstalldirs = $(top_srcdir)';
1526 $output_vars .= '/mkinstalldirs' . "\n";
1528 &am_line_error ('CONFIG_HEADER',
1529 "\`CONFIG_HEADER' is an anachronism; now determined from \`configure.in'")
1530 if &variable_defined ('CONFIG_HEADER');
1532 # Generate CONFIG_HEADER define, and define interally.
1533 $output_vars .= "CONFIG_HEADER = ${top_builddir}/${config_name}\n"
1535 $contents{'CONFIG_HEADER'} = "${top_builddir}/${config_name}"
1538 # Now look for other files in this directory which must be remade
1539 # by config.status, and generate rules for them.
1540 local ($file, $local, $input);
1541 foreach $file (@other_input_files)
1543 # Skip files not in this directory, any Makefile, and the
1544 # config header. These last two must be handled specially.
1545 next unless &dirname ($file) eq $relative_dir;
1546 next if $file eq $top_builddir . '/' . $config_name;
1547 ($local = $file) =~ s/^.*\///;
1548 next if $local eq 'Makefile';
1550 if ($local =~ /^(.*):(.*)$/)
1552 # This is the ":" syntax of AC_OUTPUT.
1559 $input = $local . '.in';
1561 # FIXME when using autoconf ":" syntax, should we set CONFIG_FILES
1563 $output_rules .= ($local . ': '
1564 . '$(top_builddir)/config.status ' . $input . "\n"
1566 . 'cd $(top_builddir) && CONFIG_FILES='
1567 . ($relative_dir eq '.' ? '' : '$(subdir)/')
1568 . '$@ CONFIG_HEADERS= ./config.status'
1571 &require_file_with_conf_line ($ac_output_line, $FOREIGN,
1579 &am_install_var ('header', 'HEADERS', 'include',
1580 'oldinclude', 'pkginclude',
1586 return if ! $seen_gettext || $relative_dir ne '.';
1588 if (&variable_defined ('SUBDIRS'))
1592 "ud_GNU_GETTEXT in configure.in but \`po' not in SUBDIRS")
1593 if $contents{'SUBDIRS'} !~ /\bpo\b/;
1596 "ud_GNU_GETTEXT in configure.in but \`intl' not in SUBDIRS")
1597 if $contents{'SUBDIRS'} !~ /\bintl\b/;
1600 # Ensure that each language in ALL_LINGUAS has a .po file, and
1601 # each po file is mentioned in ALL_LINGUAS.
1604 local (%linguas) = ();
1605 grep ($linguas{$_} = 1, split (' ', $all_linguas));
1612 &am_line_error ($all_linguas_line,
1613 ("po/$_.po exists but \`$_' not in \`ALL_LINGUAS'"))
1617 foreach (keys %linguas)
1619 &am_line_error ($all_linguas_line,
1620 "$_ in \`ALL_LINGUAS' but po/$_.po does not exist")
1626 &am_error ("ud_GNU_GETTEXT in configure.in but \`ALL_LINGUAS' not defined");
1630 # Handle footer elements.
1633 if ($contents{'SOURCES'})
1635 &pretty_print ('SOURCES =', "",
1636 split (' ', $contents{'SOURCES'}));
1638 if ($contents{'OBJECTS'})
1640 &pretty_print ('OBJECTS =', "",
1641 split (' ', $contents{'OBJECTS'}));
1643 if ($contents{'SOURCES'} || $contents{'OBJECTS'})
1645 $output_vars .= "\n";
1648 if (defined $contents{'SUFFIXES'})
1650 # Push actual suffixes, and not $(SUFFIXES). Some versions of
1651 # make do not like variable substitutions on the .SUFFIXES
1653 push (@suffixes, split (' ', $contents{'SUFFIXES'}));
1656 $output_trailer .= ".SUFFIXES:\n";
1659 $output_trailer .= ".SUFFIXES: " . join (' ', @suffixes) . "\n";
1661 $output_trailer .= &file_contents ('footer');
1664 # Deal with installdirs target.
1665 sub handle_installdirs
1667 # GNU Makefile standards recommend this.
1668 $output_rules .= ("installdirs:"
1669 . ($recursive_install
1670 ? " installdirs-recursive\n"
1672 push (@phony, 'installdirs');
1675 &pretty_print_rule ("\t" . '$(mkinstalldirs) ', "\t\t",
1678 $output_rules .= "\n";
1681 # There are several targets which need to be merged. This is because
1682 # their complete definition is compiled from many parts. Note that we
1683 # avoid double colon rules, otherwise we'd use them instead.
1684 sub handle_merge_targets
1686 push (@all, 'Makefile');
1687 push (@all, $config_name)
1688 if $config_name && &dirname ($config_name) eq $relative_dir;
1690 &do_one_merge_target ('info', @info);
1691 &do_one_merge_target ('dvi', @dvi);
1693 if (! &variable_defined ('SUBDIRS') || $relative_dir ne '.')
1695 # 'check' must depend on 'all', but not at top level.
1697 unshift (@check, 'all');
1698 unshift (@install, 'all');
1700 &do_one_merge_target ('check', @check);
1701 &do_one_merge_target ('installcheck', @installcheck);
1703 # Handle the various install targets specially. We do this so
1704 # that (eg) "make install-exec" will run "install-exec-recursive"
1705 # if required, but "make install" won't run it twice. Step one is
1706 # to see if the user specified local versions of any of the
1707 # targets we handle. "all" is treated as one of these since
1708 # "install" can run it.
1709 push (@install_exec, 'install-exec-local')
1710 if defined $contents{'install-exec-local'};
1711 push (@install_data, 'install-data-local')
1712 if defined $contents{'install-data-local'};
1713 push (@uninstall, 'uninstall-local')
1714 if defined $contents{'uninstall-local'};
1715 push (@all, 'all-local')
1716 if defined $contents{'all-local'};
1718 if (defined $contents{'install-local'})
1720 &am_line_error ('install-local',
1721 "use \`install-data' or \`install-exec', not \`install'");
1724 # Step two: if we are doing recursive makes, write out the
1725 # appropriate rules.
1727 if ($recursive_install)
1729 push (@install, 'install-recursive');
1733 local (@hackall) = ();
1734 if ($config_name && &dirname ($config_name) eq $relative_dir)
1737 # This is kind of a hack, but I couldn't see a better
1738 # way to handle it. In this particular case, we need
1739 # to make sure config.h is built before we recurse.
1740 # We can't do this by changing the order of
1741 # dependencies to the "all" because that breaks when
1742 # using parallel makes. Instead we handle things
1744 $output_rules .= ('all-recursive-hack: $(CONFIG_HEADER)'
1745 . "\n\t" . '$(MAKE) all-recursive'
1747 push (@hackall, 'all-recursive-hack');
1748 push (@phony, 'all-recursive-hack');
1752 push (@hackall, 'all-recursive');
1755 $output_rules .= ('all-am: '
1759 push (@all, 'all-am');
1760 push (@phony, 'all-am');
1764 @all = ('all-recursive');
1768 $output_rules .= ('install-exec-am: '
1769 . join (' ', @install_exec)
1771 @install_exec = ('install-exec-recursive', 'install-exec-am');
1772 push (@install, 'install-exec-am');
1773 push (@phony, 'install-exec-am');
1777 @install_exec = ('install-exec-recursive');
1781 $output_rules .= ('install-data-am: '
1782 . join (' ', @install_data)
1784 @install_data = ('install-data-recursive', 'install-data-am');
1785 push (@install, 'install-data-am');
1786 push (@phony, 'install-data-am');
1790 @install_data = ('install-data-recursive');
1794 $output_rules .= ('uninstall-am: '
1795 . join (' ', @uninstall)
1797 @uninstall = ('uninstall-recursive', 'uninstall-am');
1798 push (@phony, 'uninstall-am');
1802 @uninstall = ('uninstall-recursive');
1806 # Step three: print definitions users can use. Code below knows
1807 # that install-exec is done before install-data, beware.
1808 $output_rules .= ("install-exec: "
1809 . join (' ', @install_exec)
1811 if (defined $contents{'install-exec-hook'})
1813 $output_rules .= "\t" . '$(MAKE) install-exec-hook' . "\n";
1815 $output_rules .= "\n";
1816 push (@install, 'install-exec') if !$recursive_install;
1817 push (@phony, 'install-exec');
1819 $output_rules .= ("install-data: "
1820 . join (' ', @install_data)
1822 if (defined $contents{'install-data-hook'})
1824 $output_rules .= "\t" . '$(MAKE) install-data-hook' . "\n";
1826 $output_rules .= "\n";
1827 push (@install, 'install-data') if !$recursive_install;
1828 push (@phony, 'install-data');
1830 # If no dependencies for 'install', add 'all'. Why? That way
1831 # "make install" at top level of distclean'd distribution won't
1832 # fail because stuff in 'lib' fails to build.
1833 if (! @install || ($#install == 1
1834 && $install[0] eq 'install-exec'
1835 && $install[1] eq 'install-data'))
1837 push (@install, 'all');
1839 $output_rules .= ('install: '
1840 . join (' ', @install)
1841 # Use "@:" as empty command so nothing prints.
1845 . join (' ', @uninstall)
1847 push (@phony, 'install', 'uninstall');
1849 $output_rules .= ('all: '
1852 push (@phony, 'all');
1854 # Generate the new 'install-strip' target.
1855 $output_rules .= ("install-strip:\n\t"
1856 . '$(MAKE) INSTALL_PROGRAM=\'$(INSTALL_PROGRAM) -s\' install'
1860 # Helper for handle_merge_targets.
1861 sub do_one_merge_target
1863 local ($name, @values) = @_;
1865 if (defined $contents{$name . '-local'})
1867 # User defined local form of target. So include it.
1868 push (@values, $name . '-local');
1869 push (@phony, $name . '-local');
1872 $output_rules .= $name . ":";
1875 $output_rules .= ' ' . join (' ', @values);
1877 $output_rules .= "\n\n";
1878 push (@phony, $name);
1881 # Handle all 'clean' targets.
1884 push (@clean, 'generic');
1885 $output_rules .= &file_contents ('clean');
1886 &push_phony_cleaners ('generic');
1888 local ($target) = $recursive_install ? 'clean-am' : 'clean';
1889 &do_one_clean_target ($target, 'mostly', '', @clean);
1890 &do_one_clean_target ($target, '', 'mostly', @clean);
1891 &do_one_clean_target ($target, 'dist', '', @clean);
1892 &do_one_clean_target ($target, 'maintainer-', 'dist', @clean);
1894 push (@phony, 'clean', 'mostlyclean', 'distclean', 'maintainer-clean');
1897 if ($recursive_install)
1899 @deps = ('am', 'recursive');
1900 &do_one_clean_target ('', 'mostly', '', @deps);
1901 &do_one_clean_target ('', '', '', @deps);
1902 &do_one_clean_target ('', 'dist', '', @deps);
1903 &do_one_clean_target ('', 'maintainer-', '', @deps);
1907 # Helper for handle_clean.
1908 sub do_one_clean_target
1910 local ($target, $name, $last_name, @deps) = @_;
1912 # Special case: if target not passed, then don't generate
1913 # dependency on next "lower" clean target (eg no
1914 # clean<-mostlyclean derivation). In this case the target is
1915 # implicitly known to be 'clean'.
1916 local ($flag) = $target;
1917 $target = 'clean' if ! $flag;
1919 grep (($_ = $name . 'clean-' . $_) && 0, @deps);
1922 if ($last_name || $name ne 'mostly')
1924 push (@deps, $last_name . $target . " ");
1927 # FIXME not sure if I like the tabs here.
1928 &pretty_print_rule ($name . $target . ": ", "\t\t", @deps);
1930 # FIXME shouldn't we really print these messages before running
1932 if ($name . $target eq 'maintainer-clean')
1934 # Print a special warning.
1936 ("\t\@echo \"This command is intended for maintainers to use;\"\n"
1937 . "\t\@echo \"it deletes files that may require special "
1938 . "tools to rebuild.\"\n");
1940 $output_rules .= "\trm -f config.status\n"
1941 if $relative_dir eq '.';
1943 elsif ($name . $target eq 'distclean')
1945 $output_rules .= "\trm -f config.status\n";
1947 $output_rules .= "\n";
1950 # Handle .PHONY target.
1953 &pretty_print_rule ('.PHONY:', "", @phony);
1954 $output_rules .= "\n";
1957 # Handle TESTS variable and other checks.
1960 if (defined $options{'dejagnu'})
1962 push (@check, 'check-DEJAGNU');
1963 push (@phony, 'check-DEJAGNU');
1964 $output_rules .= &file_contents ('dejagnu') . "\n";
1965 # Note that in the rule we don't directly generate site.exp to
1966 # avoid the possibility of a corrupted site.exp if make is
1967 # interrupted. Jim Meyering has some useful text on this
1969 $output_rules .= ("site.exp: Makefile\n"
1970 . "\t\@echo 'Making a new site.exp file...'\n"
1971 . "\t-\@rm -f site.bak\n"
1972 . "\t\@echo '## these variables are automatically generated by make ##' > \$\@-t\n"
1973 . "\t\@echo '# Do not edit here. If you wish to override these values' >> \$\@-t\n"
1974 . "\t\@echo '# edit the last section' >> \$\@-t\n"
1975 . "\t\@echo 'set tool \$(DEJATOOL)' >> \$\@-t\n"
1976 . "\t\@echo 'set srcdir \$(srcdir)' >> \$\@-t\n"
1977 . "\t\@echo 'set objdir' \`pwd\` >> \$\@-t\n");
1979 # Extra stuff for AC_CANONICAL_*
1980 local (@whatlist) = ();
1981 if ($seen_canonical)
1983 push (@whatlist, 'host')
1986 # Extra stuff only for AC_CANONICAL_SYSTEM.
1987 if ($seen_canonical == $AC_CANONICAL_SYSTEM)
1989 push (@whatlist, 'target', 'build');
1993 foreach $c1 (@whatlist)
1995 foreach $c2 ('alias', 'triplet')
1997 $output_rules .= "\t\@echo 'set ${c1}_${c2} \$(${c1}_${c2})' >> \$\@-t\n";
2001 $output_rules .= ("\t\@echo '## All variables above are generated by configure. Do Not Edit ##' >> \$\@-t\n"
2002 . "\t-\@sed '1,/^## All variables above are.*##/ d' site.bak >> \$\@-t\n"
2003 . "\t-\@mv site.exp site.bak\n"
2004 . "\t\@mv \$\@-t site.exp\n");
2009 foreach $c ('DEJATOOL', 'RUNTEST', 'RUNTESTFLAGS')
2011 if (&variable_defined ($c))
2013 &am_line_error ($c, "\`$c' defined but \`dejagnu' not in \`AUTOMAKE_OPTIONS'");
2018 if (&variable_defined ('TESTS'))
2020 push (@check, 'check-TESTS');
2021 push (@phony, 'check-TESTS');
2022 # FIXME use $(SHELL) here? That is what Ulrich suggests.
2023 # Maybe a new macro, $(TEST_SHELL), a la $(CONFIG_SHELL)? For
2024 # now we just execute the file directly; this allows test
2025 # files which are compiled -- a possibly useful feature.
2026 $output_rules .= 'check-TESTS: $(TESTS)
2027 @failed=0; all=0; \\
2028 srcdir=$(srcdir); export srcdir; \\
2029 for tst in $(TESTS); do \\
2030 all=`expr $$all + 1`; \\
2031 if test -f $$tst; then dir=.; \\
2032 else dir="$(srcdir)"; fi; \\
2033 if $(TESTS_ENVIRONMENT) $$dir/$$tst; then \\
2034 echo "PASS: $$tst"; \\
2036 failed=`expr $$failed + 1`; \\
2037 echo "FAIL: $$tst"; \\
2040 if test "$$failed" -eq 0; then \\
2041 echo "========================"; \\
2042 echo "All $$all tests passed"; \\
2043 echo "========================"; \\
2045 echo "$$failed of $$all tests failed"; \\
2051 # Handle Emacs Lisp.
2052 sub handle_emacs_lisp
2054 local (@elfiles) = &am_install_var ('lisp', 'LISP', 'lisp', 'noinst');
2059 $output_vars .= "lispdir = \@lispdir\@\n";
2060 $output_rules .= (".el.elc:\n"
2061 . "\t\@echo 'WARNING: Warnings can be ignored. :-)'\n"
2062 . "\t\$(SHELL) \$(srcdir)/elisp-comp \$<\n");
2063 push (@suffixes, '.el', '.elc');
2065 # Generate .elc files.
2066 grep ($_ .= 'c', @elfiles);
2067 &pretty_print ('ELCFILES =', '', @elfiles);
2070 if (&variable_defined ('lisp_LISP'))
2072 $varname = 'lisp_LISP';
2073 &am_error ("\`lisp_LISP' defined but \`ud_PATH_LISPDIR' not in \`configure.in'")
2078 $varname = 'noinst_LISP';
2080 &require_file_with_line ($varname, $FOREIGN, 'elisp-comp');
2085 ################################################################
2087 # Scan configure.in for interesting things.
2088 # FIXME ensure VERSION, PACKAGE are set.
2091 open (CONFIGURE, 'configure.in')
2092 || die "automake: couldn't open \`configure.in': $!\n";
2093 print "automake: reading configure.in\n" if $verbose;
2095 # Reinitialize libsources here. This isn't really necessary,
2096 # since we currently assume there is only one configure.in. But
2097 # that won't always be the case.
2100 local ($in_ac_output, @make_list) = 0;
2101 local ($libobj_iter);
2104 # Remove comments from current line.
2108 # Populate libobjs array.
2109 if (/AC_FUNC_ALLOCA/)
2111 $libsources{'alloca.c'} = 1;
2113 elsif (/AC_FUNC_GETLOADAVG/)
2115 $libsources{'getloadavg.c'} = 1;
2117 elsif (/AC_FUNC_MEMCMP/)
2119 $libsources{'memcmp.c'} = 1;
2121 elsif (/AC_STRUCT_ST_BLOCKS/)
2123 $libsources{'fileblocks.c'} = 1;
2125 elsif (/(AC|fp)_FUNC_FNMATCH/)
2127 # AC_FUNC_FNMATCH is just wishful thinking at this point.
2128 $libsources{'fnmatch.c'} = 1;
2130 elsif (/AC_REPLACE_FUNCS\s*\((.*)\)/)
2132 foreach (split (' ', $1))
2134 $libsources{$_ . '.c'} = 1;
2137 elsif (/AC_REPLACE_GNU_GETOPT/)
2139 $libsources{'getopt.c'} = 1;
2140 $libsources{'getopt1.c'} = 1;
2142 elsif (/LIBOBJS="(.*)\s+\$LIBOBJS"/
2143 || /LIBOBJS="\$LIBOBJS\s+(.*)"/)
2145 foreach $libobj_iter (split (' ', $1))
2147 if ($libobj_iter =~ /^(.*)\.o$/)
2149 $libsources{$1 . '.c'} = 1;
2154 # Process the AC_OUTPUT macro.
2155 if (! $in_ac_output && s/AC_OUTPUT\s*\(\[?//)
2158 $ac_output_line = $.;
2162 $in_ac_output = 0 if s/[\]\),].*$//;
2164 # Look at potential Makefile.am's.
2170 push (@make_list, $_);
2174 push (@other_input_files, $_);
2179 if (/AC_CONFIG_AUX_DIR\(([^)]+)\)/)
2181 @config_aux_path = $1;
2184 # Check for ansi2knr.
2185 $fp_c_prototypes = 1 if /fp_C_PROTOTYPES/;
2187 # Check for NLS support.
2188 if (/ud_GNU_GETTEXT/)
2191 $ac_gettext_line = $.;
2194 # Look for ALL_LINGUAS.
2195 if (/ALL_LINGUAS="(.*)"$/ || /ALL_LINGUAS=(.*)$/)
2199 $all_linguas_line = $.;
2202 # Handle configuration headers.
2203 if (/AC_CONFIG_HEADER\s*\((.*)\)/)
2205 $config_header_line = $.;
2207 if ($config_name =~ /^([^:]+):(.+)$/)
2210 $config_header = $2;
2214 $config_header = $config_name . '.in';
2218 # Handle AC_CANONICAL_*. Always allow upgrading to
2219 # AC_CANONICAL_SYSTEM, but never downgrading.
2220 $seen_canonical = $AC_CANONICAL_HOST
2221 if ! $seen_canonical && /AC_CANONICAL_HOST/;
2222 $seen_canonical = $AC_CANONICAL_SYSTEM if /AC_CANONICAL_SYSTEM/;
2224 $seen_canonical = 1 if /AC_CHECK_TOOL/;
2225 $seen_path_xtra = 1 if /AC_PATH_XTRA/;
2227 # Sometimes it is desirable to explicitly set YACC. For
2228 # instance some people don't want to use bison.
2229 $seen_prog_yacc = 1 if (/AC_PROG_YACC/
2230 || /AC_SUBST\(YACC\)/
2231 || /AC_(PATH|CHECK)_PROGS?\(YACC/);
2233 # Some things required by Automake.
2234 $seen_make_set = 1 if /AC_PROG_MAKE_SET/;
2235 $seen_arg_prog = 1 if /AC_ARG_PROGRAM/;
2236 $seen_ranlib = 1 if /AC_PROG_RANLIB/;
2237 $seen_maint_mode = 1 if /jm_MAINTAINER_MODE/;
2238 $seen_package = 1 if /PACKAGE=/;
2239 $seen_version = 1 if /VERSION=/;
2241 # Weird conditionals here because it is always allowed to
2242 # upgrade to fp_PROG_INSTALL but never to downgrade to
2244 $seen_prog_install = 1 if ! $seen_prog_install && /AC_PROG_INSTALL/;
2245 $seen_prog_install = 2 if /fp_PROG_INSTALL/;
2247 $seen_lispdir = 1 if /ud_PATH_LISPDIR/;
2249 if (/AM_PROG_LIBTOOL/)
2257 # Set input files if not specified by user.
2258 @input_files = @make_list if (! @input_files);
2262 &am_conf_error ("\`PACKAGE' not defined in configure.in")
2264 &am_conf_error ("\`VERSION' not defined in configure.in")
2267 # Look for some files we need. Always check for these. This
2268 # check must be done for every run, even those where we are only
2269 # looking at a subdir Makefile. We must set relative_dir so that
2270 # the file-finding machinery works.
2271 local ($relative_dir) = '.';
2272 &require_config_file ($FOREIGN, 'install-sh', 'mkinstalldirs');
2275 ################################################################
2277 # Do any extra checking for GNU standards.
2278 sub check_gnu_standards
2280 if ($relative_dir eq '.')
2282 # In top level (or only) directory.
2283 &require_file ($GNU, 'INSTALL', 'NEWS', 'README', 'COPYING',
2284 'AUTHORS', 'ChangeLog');
2288 # Do any extra checking for GNITS standards.
2289 sub check_gnits_standards
2291 if ($strictness >= $GNITS && -f $relative_dir . '/COPYING.LIB')
2294 ("\`${relative_dir}/COPYING.LIB' disallowed by Gnits standards");
2297 if ($relative_dir eq '.')
2299 # In top level (or only) directory.
2300 &require_file ($GNITS, 'THANKS');
2304 ################################################################
2306 # Pretty-print something. HEAD is what should be printed at the
2307 # beginning of the first line, FILL is what should be printed at the
2308 # beginning of every subsequent line.
2309 sub pretty_print_internal
2311 local ($head, $fill, @values) = @_;
2313 local ($column) = length ($head);
2314 local ($result) = $head;
2316 # Fill length is number of characters. However, each Tab
2317 # character counts for eight. So we count the number of Tabs and
2319 local ($fill_length) = length ($fill);
2320 $fill_length += 7 * ($fill =~ tr/\t/\t/d);
2325 # "71" because we also print a space.
2326 if ($column + length ($_) > 71)
2328 $result .= " \\\n" . $fill;
2329 $column = $fill_length;
2333 $result .= ' ' unless ($bol);
2335 $column += length ($_) + 1;
2343 # Pretty-print something and append to output_vars.
2346 $output_vars .= &pretty_print_internal (@_);
2349 # Pretty-print something and append to output_rules.
2350 sub pretty_print_rule
2352 $output_rules .= &pretty_print_internal (@_);
2356 ################################################################
2358 # See if a variable exists.
2359 sub variable_defined
2362 if (defined $targets{$var})
2364 &am_line_error ($var, "\`$var' is target; expected variable");
2366 return (defined $contents{$var} && ! defined $targets{$var});
2369 # Read Makefile.am and set up %contents. Simultaneously copy lines
2370 # from Makefile.am into $output_trailer or $output_vars as
2371 # appropriate. NOTE we put rules in the trailer section. We want
2372 # user rules to come after our generated stuff.
2375 local ($amfile) = @_;
2377 # Compute relative location of the top object directory.
2378 local (@topdir) = ();
2379 foreach (split (/\//, $relative_dir))
2381 next if $_ eq '.' || $_ eq '';
2388 push (@topdir, '..');
2391 @topdir = ('.') if ! @topdir;
2393 $top_builddir = join ('/', @topdir);
2395 ($build_rx = $top_builddir) =~ s/(\W)/\\$1/g;
2396 local ($header_vars) =
2397 &file_contents_with_transform
2398 ('s/\@top_builddir\@/' . $build_rx . '/g',
2401 # Generate some useful variables when AC_CANONICAL_* used.
2402 if ($seen_canonical)
2404 $header_vars .= ('host_alias = @host_alias@' . "\n"
2405 . 'host_triplet = @host@' . "\n");
2406 if ($seen_canonical == $AC_CANONICAL_SYSTEM)
2408 $header_vars .= ('build_alias = @build_alias@' . "\n"
2409 . 'build_triplet = @build@' . "\n");
2410 $header_vars .= ('target_alias = @target_alias@' . "\n"
2411 . 'target_triplet = @target@' . "\n");
2415 open (AM_FILE, $amfile) || die "automake: couldn't open \`$amfile': $!\n";
2416 print "automake: reading $amfile\n" if $verbose;
2418 $output_vars .= ("# $in_file_name generated automatically by automake "
2419 . $VERSION . " from $am_file_name\n");
2421 # Generate copyright for generated Makefile.in.
2422 $output_vars .= $gen_copyright;
2424 local ($saw_bk) = 0;
2425 local ($was_rule) = 0;
2426 local ($spacing) = '';
2427 local ($comment) = '';
2428 local ($last_var_name) = '';
2433 if (/$IGNORE_PATTERN/o)
2435 # Merely delete comments beginning with two hashes.
2437 elsif (/$WHITE_PATTERN/o)
2439 # Stick a single white line before the incoming macro or rule.
2443 elsif (/$COMMENT_PATTERN/o)
2445 # Stick comments before the incoming macro or rule. Make
2446 # sure a blank line preceeds comments.
2447 $spacing = "\n" unless $blank;
2448 $comment .= $spacing . $_;
2457 $output_vars .= $comment . "\n" . $header_vars;
2461 local ($is_ok_macro);
2465 unless substr ($_, -1, 1) eq "\n";
2467 $_ =~ s/\@MAINT\@//g
2468 unless $seen_maint_mode;
2470 if (/$IGNORE_PATTERN/o)
2472 # Merely delete comments beginning with two hashes.
2474 elsif (/$WHITE_PATTERN/o)
2476 # Stick a single white line before the incoming macro or rule.
2479 elsif (/$COMMENT_PATTERN/o)
2481 # Stick comments before the incoming macro or rule.
2482 $comment .= $spacing . $_;
2489 $output_trailer .= $_;
2496 # Chop newline and backslash if this line is
2497 # continued. FIXME maybe ensure trailing whitespace
2501 $contents{$last_var_name} .= $_;
2504 elsif (/$RULE_PATTERN/o)
2506 # warn "** Saw rule .$1.\n";
2509 # Value here doesn't matter; for targets we only note
2513 $content_lines{$1} = $.;
2514 $output_trailer .= $comment . $spacing . $_;
2515 $comment = $spacing = '';
2518 elsif (($is_ok_macro = /$MACRO_PATTERN/o)
2519 || /$BOGUS_MACRO_PATTERN/o)
2521 # Found a macro definition.
2523 $last_var_name = $1;
2524 if (substr ($2, -1) eq "\\")
2526 $contents{$1} = substr ($2, 0, length ($2) - 1);
2532 $content_lines{$1} = $.;
2533 $output_vars .= $comment . $spacing . $_;
2534 $comment = $spacing = '';
2538 &am_line_error ($., "bad macro name \`$1'")
2543 # This isn't an error; it is probably a continued rule.
2544 # In fact, this is what we assume.
2546 $output_trailer .= $comment . $spacing . $_;
2547 $comment = $spacing = '';
2554 $output_trailer .= $comment;
2557 ################################################################
2559 sub initialize_global_constants
2561 # Values for AC_CANONICAL_*
2562 $AC_CANONICAL_HOST = 1;
2563 $AC_CANONICAL_SYSTEM = 2;
2565 # Associative array of standard directory names. Entry is TRUE if
2566 # corresponding directory should be installed during
2567 # 'install-exec' phase.
2585 # Helper text for dealing with man pages.
2586 $install_man_format =
2587 ' @sect=@SECTION@; \\
2588 inst=`echo "@MANBASE@" | sed \'$(transform)\'`.@FULLSECT@; \\
2589 echo installing @MAN@ as $(mandir)/man$$sect/$$inst; \\
2590 if test -f $(srcdir)/@MAN@; then file=$(srcdir)/@MAN@; \\
2591 else file=@MAN@; fi; \\
2592 $(INSTALL_DATA) $(srcdir)/@MAN@ $(mandir)/man$$sect/$$inst
2595 $uninstall_man_format =
2596 ' inst=`echo "@MANBASE@" | sed \'$(transform)\'`.@FULLSECT@; \\
2597 rm -f $(mandir)/man@SECTION@/$$inst
2600 # Commonly found files we look for and automatically include in
2604 "README", "THANKS", "TODO", "NEWS", "COPYING", "COPYING.LIB",
2605 "INSTALL", "ABOUT-NLS", "ChangeLog", "configure", "configure.in",
2606 "config.guess", "config.sub", "AUTHORS", "BACKLOG", "ABOUT-GNU",
2607 "libversion.in", "mdate-sh", "mkinstalldirs", "install-sh",
2608 'texinfo.tex', "ansi2knr.c", "ansi2knr.1"
2611 # Commonly used files we auto-include, but only sometimes.
2614 "aclocal.m4", "acconfig.h", "config.h.top",
2615 "config.h.bot", "stamp-h.in", 'stamp-vti', 'elisp-comp', 'libtool'
2619 --amdir=DIR directory storing config files
2620 --foreign same as --strictness=foreign
2621 --gnits same as --strictness=gnits
2622 --gnu same as --strictness=gnu
2623 --help print this help, then exit
2624 -i, --include-deps include generated dependencies in Makefile.in
2625 -a, --add-missing add missing standard files to package
2626 --no-force only update Makefile.in's that are out of date
2627 -o DIR, --output-dir=DIR
2628 put generated Makefile.in's into DIR
2629 -s LEVEL, --strictness=LEVEL
2630 set strictness level. LEVEL is foreign, gnu, gnits
2631 -v, --verbose verbosely list files processed
2632 --version print version number, then exit\n";
2634 # Copyright on generated Makefile.ins.
2636 # Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
2637 # This Makefile.in is free software; the Free Software Foundation
2638 # gives unlimited permission to copy, distribute and modify it.
2642 # (Re)-Initialize per-Makefile.am variables.
2643 sub initialize_per_input
2645 # These two variables are used when generating each Makefile.in.
2646 # They hold the Makefile.in until it is ready to be printed.
2649 $output_trailer = '';
2651 # Suffixes found during a run.
2654 # This holds the contents of a Makefile.am, as parsed by
2658 # This holds the names which are targets. These also appear in
2662 # This holds the line numbers at which various elements of
2663 # %contents are defined.
2664 %content_lines = ();
2666 # This holds the "relative directory" of the current Makefile.in.
2667 # Eg for src/Makefile.in, this is "src".
2670 # This holds a list of files that are included in the
2674 # List of dependencies for the obvious targets.
2689 # These are pretty obvious, too. They are used to define the
2690 # SOURCES and OBJECTS variables.
2694 # TRUE if current directory holds any C source files. (Actually
2695 # holds object extension, but this information is encapsulated in
2696 # the function get_object_extension).
2697 $dir_holds_sources = '';
2699 # TRUE if install targets should work recursively.
2700 $recursive_install = 0;
2705 # Strictness levels.
2706 $strictness = $default_strictness;
2707 $strictness_name = $default_strictness_name;
2709 # Options from AUTOMAKE_OPTIONS.
2712 # Whether or not dependencies are handled. Can be further changed
2713 # in handle_options.
2714 $use_dependencies = $cmdline_use_dependencies;
2717 $local_maint_charset = $maint_charset;
2721 ################################################################
2723 # Return contents of a file from $am_dir, automatically skipping
2724 # macros or rules which are already known. Runs command on each line
2725 # as it is read; this command can modify $_.
2726 sub file_contents_with_transform
2728 local ($command, $basename) = @_;
2729 local ($file) = $am_dir . '/' . $basename . '.am';
2731 open (FC_FILE, $file)
2732 || die "automake: installation error: cannot open \`$file'\n";
2734 # print "automake: reading $file\n" if $verbose;
2736 local ($was_rule) = 0;
2737 local ($result_vars) = '';
2738 local ($result_rules) = '';
2739 local ($comment) = '';
2740 local ($spacing) = "\n";
2741 local ($skipping) = 0;
2745 $_ =~ s/\@MAINT\@//g
2746 unless $seen_maint_mode;
2750 if (/$IGNORE_PATTERN/o)
2752 # Merely delete comments beginning with two hashes.
2754 elsif (/$WHITE_PATTERN/o)
2756 # Stick a single white line before the incoming macro or rule.
2759 elsif (/$COMMENT_PATTERN/o)
2761 # Stick comments before the incoming macro or rule.
2762 $comment .= $spacing . $_;
2769 $result_rules .= $_ if ! $skipping;
2773 $result_vars .= $_ if ! $skipping;
2777 elsif (/$RULE_PATTERN/o)
2779 # warn "** Found rule .$1.\n";
2782 $skipping = defined $contents{$1};
2783 # warn "** Skip $skipping\n" if $skipping;
2784 $result_rules .= $comment . $spacing . $_ if ! $skipping;
2785 $comment = $spacing = '';
2788 elsif (/$MACRO_PATTERN/o)
2790 # warn "** Found macro .$1.\n";
2791 # Found a variable reference.
2793 $skipping = defined $contents{$1};
2794 # warn "** Skip $skipping\n" if $skipping;
2795 $result_vars .= $comment . $spacing . $_ if ! $skipping;
2796 $comment = $spacing = '';
2801 # This isn't an error; it is probably a continued rule.
2802 # In fact, this is what we assume.
2804 $result_rules .= $comment . $spacing . $_ if ! $skipping;
2805 $comment = $spacing = '';
2811 return $result_vars . $result_rules . $comment;
2814 # Like file_contents_with_transform, but no transform.
2817 return &file_contents_with_transform ('', @_);
2820 # Handle `where_HOW' variable magic. Does all lookups, generates
2821 # install code, and possibly generates code to define the primary
2822 # variable. The first argument is the name of the .am file to munge,
2823 # the second argument is the primary variable (eg HEADERS), and all
2824 # subsequent arguments are possible installation locations. Returns
2825 # list of all values of all _HOW targets.
2827 # FIXME this should be rewritten to be cleaner. It should be broken
2828 # up into multiple functions.
2830 # Usage is: am_install_var (OPTION..., file, HOW, where...)
2835 local ($do_all, $do_clean) = (1, 0);
2838 if ($args[0] eq '-clean')
2842 elsif ($args[0] eq '-no-all')
2846 elsif ($args[0] !~ /^-/)
2852 local ($file, $primary, @prefixes) = @args;
2855 local (@result) = ();
2857 # Now that configure substitutions are allowed in where_HOW
2858 # variables, it is an error to actually define the primary.
2859 &am_line_error ($primary, "\`$primary' is an anachronism")
2860 if &variable_defined ($primary);
2863 # Look for misspellings. It is an error to have a variable ending
2864 # in a "reserved" suffix whose prefix is unknown, eg
2865 # "bni_PROGRAMS". However, unusual prefixes are allowed if a
2866 # variable of the same name (with "dir" appended) exists. For
2867 # instance, if the variable "zardir" is defined, then
2868 # "zar_PROGRAMS" becomes valid. This is to provide a little extra
2869 # flexibility in those cases which need it. Perhaps it should be
2870 # disallowed in the Gnits case? The problem is, sometimes it is
2871 # useful to put things in a subdir of eg pkgdatadir, perhaps even
2873 local (%valid, $varname);
2874 grep ($valid{$_} = 0, @prefixes);
2875 $valid{'EXTRA'} = 0;
2876 foreach $varname (keys %contents)
2878 if ($varname =~ /^(.*)_$primary$/)
2880 if (! defined $valid{$1} && ! &variable_defined ($1 . 'dir'))
2882 &am_line_error ($varname, "invalid variable \"$varname\"");
2886 # Ensure all extended prefixes are actually used.
2892 local ($clean_file) = $file . '-clean';
2895 foreach $X (keys %valid)
2897 $one_name = $X . '_' . $primary;
2898 if (&variable_defined ($one_name))
2900 # Append actual contents of where_PRIMARY variable to
2903 foreach $rcurs (split (' ', $contents{$one_name}))
2905 # Skip configure substitutions. Possibly bogus.
2906 next if $rcurs =~ /^\@.*\@$/;
2907 push (@result, $rcurs);
2910 # "EXTRA" shouldn't be used when generating clean targets,
2911 # @all, or install targets.
2912 next if $X eq 'EXTRA';
2917 &file_contents_with_transform ('s/\@DIR\@/' . $X . '/go',
2920 push (@clean, $X . $primary);
2921 &push_phony_cleaners ($X . $primary);
2926 push (@check, '$(' . $one_name . ')');
2930 push (@used, '$(' . $one_name . ')');
2932 if ($X eq 'noinst' || $X eq 'check')
2934 # Objects which don't get installed by default.
2939 &file_contents_with_transform ('s/\@DIR\@/' . $X . '/go',
2942 push (@uninstall, 'uninstall-' . $X . $primary);
2943 push (@phony, 'uninstall-' . $X . $primary);
2944 push (@installdirs, '$(' . $X . 'dir)');
2945 if ($exec_dir_p{$X})
2947 push (@install_exec, 'install-' . $X . $primary);
2948 push (@phony, 'install-' . $X . $primary);
2952 push (@install_data, 'install-' . $X . $primary);
2953 push (@phony, 'install-' . $X . $primary);
2961 &pretty_print ($primary . ' =', '', @used);
2962 $output_vars .= "\n";
2965 # Push here because PRIMARY might be configure time determined.
2966 push (@all, '$(' . $primary . ')')
2967 if $do_all && @used;
2973 ################################################################
2975 # This variable is local to the "require file" set of functions.
2976 @require_file_paths = ();
2978 # Verify that the file must exist in the current directory. Usage:
2979 # require_file (isconfigure, line_number, strictness, file) strictness
2980 # is the strictness level at which this file becomes required. Must
2981 # set require_file_paths before calling this function.
2982 # require_file_paths is set to hold a single directory (the one in
2983 # which the first file was found) before return.
2984 sub require_file_internal
2986 local ($is_configure, $line, $mystrict, @files) = @_;
2987 local ($file, $fullfile);
2988 local ($found_it, $errfile, $errdir);
2991 foreach $file (@files)
2994 foreach $dir (@require_file_paths)
2998 $fullfile = $relative_dir . "/" . $file;
2999 $errdir = $relative_dir unless $errdir;
3003 $fullfile = $dir . "/" . $file;
3004 $errdir = $dir unless $errdir;
3007 # Use different name for "error filename". Otherwise on
3008 # an error the bad file will be reported as eg
3009 # `../../install-sh' when using the default
3011 $errfile = $errdir . '/' . $file;
3016 &push_dist_common ($file) if $dir eq $relative_dir;
3024 # Prune the path list.
3025 @require_file_paths = $save_dir;
3029 if ($strictness >= $mystrict)
3031 # Only install missing files according to our desired
3033 if ($add_missing && -f ($am_dir . '/' . $file))
3035 # Install the missing file. Symlink if we can, copy
3037 if ($symlink_exists)
3039 symlink ($am_dir . '/' . $file, $errfile);
3043 system ('cp', $am_dir . '/' . $file, $errfile);
3046 # FIXME this is a hack. Should have am_warn.
3047 local ($save) = $exit_status;
3052 "required file \"$errfile\" not found; installing");
3058 "required file \"$errfile\" not found; installing");
3060 $exit_status = $save;
3064 # Only an error if strictness constraint violated.
3068 ($line, "required file \"$errfile\" not found");
3073 ($line, "required file \"$errfile\" not found");
3081 # Like require_file_with_line, but error messages refer to
3082 # configure.in, not the current Makefile.am.
3083 sub require_file_with_conf_line
3085 @require_file_paths = '.';
3086 &require_file_internal (1, @_);
3089 sub require_file_with_line
3091 @require_file_paths = '.';
3092 &require_file_internal (0, @_);
3097 @require_file_paths = '.';
3098 &require_file_internal (0, '', @_);
3101 # Require a file that is also required by Autoconf. Looks in
3102 # configuration path, as specified by AC_CONFIG_AUX_DIR.
3103 sub require_config_file
3105 @require_file_paths = @config_aux_path;
3106 &require_file_internal (0, '', @_);
3107 local ($dir) = $require_file_paths[0];
3108 @config_aux_path = @require_file_paths;
3111 $config_aux_dir = '.';
3115 $config_aux_dir = '$(top_srcdir)/' . $dir;
3119 # Assumes that the line number is in Makefile.am.
3120 sub require_conf_file_with_line
3122 @require_file_paths = @config_aux_path;
3123 &require_file_internal (0, @_);
3124 local ($dir) = $require_file_paths[0];
3125 @config_aux_path = @require_file_paths;
3128 $config_aux_dir = '.';
3132 $config_aux_dir = '$(top_srcdir)/' . $dir;
3136 # Assumes that the line number is in Makefile.am.
3137 sub require_conf_file_with_conf_line
3139 @require_file_paths = @config_aux_path;
3140 &require_file_internal (1, @_);
3141 local ($dir) = $require_file_paths[0];
3142 @config_aux_path = @require_file_paths;
3145 $config_aux_dir = '.';
3149 $config_aux_dir = '$(top_srcdir)/' . $dir;
3153 ################################################################
3155 # Push a list of files onto dist_common.
3156 sub push_dist_common
3158 local (@files) = @_;
3161 foreach $file (@files)
3163 $dist_common{$file} = 1;
3167 # Push a list of clean targets onto phony.
3168 sub push_phony_cleaners
3172 foreach $target ('mostly', 'dist', '', 'maintainer-')
3174 push (@phony, $target . 'clean-' . $base);
3181 $strictness_name = $_[0];
3182 if ($strictness_name eq 'gnu')
3186 elsif ($strictness_name eq 'gnits')
3188 $strictness = $GNITS;
3190 elsif ($strictness_name eq 'foreign')
3192 $strictness = $FOREIGN;
3196 die "automake: level \`$strictness_name' not recognized\n";
3201 ################################################################
3203 # Return directory name of file.
3209 ($sub = $file) =~ s,/+[^/]+$,,g;
3210 $sub = '.' if $sub eq $file;
3217 local ($dirname) = @_;
3218 system ("mkdir", $dirname);
3221 ################################################################
3223 # Print an error message and set exit status.
3226 warn "automake: ${am_file}.am: ", join (' ', @_), "\n";
3232 local ($symbol, @args) = @_;
3236 # If SYMBOL not already a line number, look it up in Makefile.am.
3237 $symbol = $content_lines{$symbol} unless $symbol =~ /^\d+$/;
3238 $symbol .= ': ' if $symbol;
3239 warn "${am_file}.am:", $symbol, join (' ', @args), "\n";
3248 # Like am_error, but while scanning configure.in.
3251 # FIXME can run in subdirs.
3252 warn "automake: configure.in: ", join (' ', @_), "\n";
3256 # Error message with line number referring to configure.in.
3257 sub am_conf_line_error
3259 local ($line, @args) = @_;
3263 warn "configure.in: $line: ", join (' ', @args), "\n";
3268 &am_conf_error (@args);
3272 # Tell user where our aclocal.m4 is, but only once.
3273 sub keyed_aclocal_warning
3276 warn "automake: macro \`$key' can be found in ${am_dir}/aclocal.m4\n";
3279 # Print usage information.
3282 print "Usage: automake [OPTION] ... [Makefile]...\n";
3284 print "\nFiles which are automatically distributed, if found:\n";
3285 $~ = "USAGE_FORMAT";
3286 local (@lcomm) = sort ((@common_files, @common_sometimes));
3287 local ($one, $two, $three, $four);
3290 $one = shift @lcomm;
3291 $two = @lcomm ? shift @lcomm : '';
3292 $three = @lcomm ? shift @lcomm : '';
3293 $four = @lcomm ? shift @lcomm : '';
3300 format USAGE_FORMAT =
3301 @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<
3302 $one, $two, $three, $four