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)
966 . "\n" . $infobase . ".dvi: "
967 . join (' ', @texi_deps)
970 push (@infos_list, $infobase . '.info', '.info-[0-9]',
972 push (@info_deps_list, $infobase . '.info');
973 push (@dvis_list, $infobase . '.dvi');
975 # Generate list of things to clean for this target. We do
976 # this explicitly because otherwise too many things could be
977 # removed. In particular the ".log" extension might
978 # reasonably be used in other contexts by the user.
979 foreach $tc_cursor ('aux', 'cp', 'cps', 'dvi', 'fn', 'fns',
980 'ky', 'log', 'pg', 'toc', 'tp', 'vr', 'op')
982 push (@texi_cleans, $infobase . '.' . $tc_cursor);
987 $output_vars .= &file_contents ('texinfos-vars');
988 $output_rules .= &file_contents ('texinfos');
989 push (@phony, 'install-info', 'uninstall-info');
992 $output_rules .= "\nmostlyclean-info:\n";
993 &pretty_print_rule ("\trm -f", "\t ", @texi_cleans);
994 $output_rules .= ("\nclean-info:\n\ndistclean-info:\n\n"
995 . "maintainer-clean-info:\n\t"
996 . 'rm -f $(INFOS)' . "\n");
997 &push_phony_cleaners ('info');
999 push (@suffixes, '.texi', '.info', '.dvi');
1001 if (! defined $options{'no-installinfo'})
1003 push (@uninstall, 'uninstall-info');
1004 push (@installdirs, '$(infodir)');
1005 unshift (@install_data, 'install-info');
1007 # Make sure documentation is made and installed first. Use
1008 # $(INFO_DEPS), not 'info', because otherwise recursive makes
1009 # get run twice during "make all".
1010 unshift (@all, '$(INFO_DEPS)');
1012 push (@clean, 'info');
1013 push (@info, '$(INFO_DEPS)');
1014 push (@dvi, '$(DVIS)');
1016 $output_vars .= ("INFOS = " . join (' ', @infos_list) . "\n"
1017 . "INFO_DEPS = " . join (' ', @info_deps_list) . "\n"
1018 . "DVIS = " . join (' ', @dvis_list) . "\n"
1019 # This next isn't strictly needed now -- the
1020 # places that look here could easily be changed
1021 # to look in info_TEXINFOS. But this is probably
1022 # better, in case noinst_TEXINFOS is ever
1024 . "TEXINFOS = " . $contents{'info_TEXINFOS'} . "\n\n");
1026 # Do some error checking.
1027 &require_file_with_line ('info_TEXINFOS', $FOREIGN, 'texinfo.tex');
1030 # Handle any man pages.
1031 sub handle_man_pages
1033 &am_line_error ('MANS', "\`MANS' is an anachronism; use \`man_MANS'")
1034 if &variable_defined ('MANS');
1035 return if ! &variable_defined ('man_MANS');
1037 # We generate the manpage install code by hand to avoid the use of
1038 # basename in the generated Makefile.
1039 local (@mans) = split (' ', $contents{'man_MANS'});
1040 local (%sections, %inames, %secmap, %fullsecmap);
1043 # FIXME: statement without effect:
1044 /^(.*)\.([0-9])([a-z]*)$/;
1048 $fullsecmap{$1} = $2 . $3;
1051 # We don't really need this, but we use it in case we ever want to
1052 # support noinst_MANS.
1053 $output_vars .= "MANS = " . $contents{'man_MANS'} . "\n";
1055 # Generate list of install dirs.
1056 $output_rules .= "install-man: \$(MANS)\n";
1057 foreach (keys %sections)
1059 push (@installdirs, '$(mandir)/man' . $_)
1060 unless defined $options{'no-installman'};
1061 $output_rules .= ("\t" . '$(mkinstalldirs) $(mandir)/man'
1064 push (@phony, 'install-man');
1066 # Generate install target.
1068 foreach $key (keys %inames)
1070 $_ = $install_man_format;
1071 s/\@SECTION\@/$secmap{$key}/g;
1072 s/\@MAN\@/$inames{$key}/g;
1073 s/\@FULLSECT\@/$fullsecmap{$key}/g;
1074 s/\@MANBASE\@/$key/g;
1075 $output_rules .= $_;
1077 $output_rules .= "\n";
1079 $output_rules .= "uninstall-man:\n";
1080 foreach $key (keys %inames)
1082 $_ = $uninstall_man_format;
1083 s/\@SECTION\@/$secmap{$key}/g;
1084 s/\@MAN\@/$inames{$key}/g;
1085 s/\@FULLSECT\@/$fullsecmap{$key}/g;
1086 s/\@MANBASE\@/$key/g;
1087 $output_rules .= $_;
1089 $output_rules .= "\n";
1090 push (@phony, 'uninstall-man');
1092 $output_vars .= &file_contents ('mans-vars');
1094 if (! defined $options{'no-installman'})
1096 push (@install_data, 'install-man');
1097 push (@uninstall, 'uninstall-man');
1098 push (@all, '$(MANS)');
1102 # Handle DATA variables.
1105 &am_install_var ('data', 'DATA', 'data', 'sysconf',
1106 'sharedstate', 'localstate', 'pkgdata',
1113 local ($tagging) = 0;
1115 push (@phony, 'tags');
1116 if (&variable_defined ('SUBDIRS'))
1118 $output_rules .= &file_contents ('tags');
1119 push (@phony, 'tags-recursive');
1122 elsif ($dir_holds_sources || &variable_defined ('ETAGS_ARGS'))
1124 $output_rules .= &file_contents ('tags-subd');
1130 $output_rules .= &file_contents ('tags-clean');
1131 push (@clean, 'tags');
1132 &push_phony_cleaners ('tags');
1136 # Every Makefile must define some sort of TAGS rule.
1137 # Otherwise, it would be possible for a top-level "make TAGS"
1138 # to fail because some subdirectory failed.
1139 $output_rules .= "tags: TAGS\nTAGS:\n\n";
1143 # Worker for handle_dist.
1144 sub handle_dist_worker
1146 $output_rules .= 'distdir: $(DEP_DISTFILES)' . "\n";
1148 # Initialization; only at top level.
1149 if ($relative_dir eq '.')
1151 if ($strictness >= $GNITS)
1153 # For Gnits users, this is pretty handy. Look at 15 lines
1154 # in case some explanatory text is desirable.
1155 $output_rules .= ' @if sed 15q $(srcdir)/NEWS | grep -e "$(VERSION)" > /dev/null; then :; else \\
1156 echo "NEWS not updated; not releasing" 1>&2; \\
1164 # Create dist directory.
1167 chmod 777 $(distdir)
1170 # Only run automake in `dist' target if --include-deps not
1171 # specified. That way the recipient of a distribution can run
1172 # "make dist" and not need Automake.
1173 if ($cmdline_use_dependencies)
1177 # We need an absolute path for --output-dir. Thus the
1179 ' distdir=`cd $(distdir) && pwd` \\
1181 && automake --include-deps --output-dir=$$distdir --strictness='
1182 # Set strictness of output.
1183 . $strictness_name . "\n"
1188 # In loop, test for file existence because sometimes a file gets
1189 # included in DISTFILES twice. For example this happens when a
1190 # single source file is used in building more than one program.
1191 # Also, there are situations in which "ln" can fail. For instance
1192 # a file to distribute could actually be a cross-filesystem
1193 # symlink -- this can easily happen if "gettextize" was run on the
1194 # distribution. Note that DISTFILES can contain a wildcard (for
1195 # info files, sigh), so we must use the echo trick.
1196 $output_rules .= ' @for file in `cd $(srcdir) && echo $(DISTFILES)`; do \\
1197 test -f $(distdir)/$$file \\
1198 || ln $(srcdir)/$$file $(distdir)/$$file 2> /dev/null \\
1199 || cp -p $(srcdir)/$$file $(distdir)/$$file; \\
1203 # If we have SUBDIRS, create all dist subdirectories and do
1205 if (&variable_defined ('SUBDIRS'))
1207 # Test for directory existence here because previous automake
1208 # invocation might have created some directories. Note that
1209 # we explicitly set distdir for the subdir make; that lets us
1210 # mix-n-match many automake-using packages into one large
1211 # package, and have "dist" at the top level do the right
1213 $output_rules .= ' for subdir in $(SUBDIRS); do \\
1214 test -d $(distdir)/$$subdir \\
1215 || mkdir $(distdir)/$$subdir \\
1217 chmod 777 $(distdir)/$$subdir; \\
1218 (cd $$subdir && $(MAKE) distdir=../$(distdir)/$$subdir distdir) \\
1224 # If the target `dist-hook' exists, run it now. This allows
1225 # users to do random weird things to the distribution before it is
1227 if (defined $contents{'dist-hook'})
1229 $output_rules .= "\t\$(MAKE) dist-hook\n";
1232 push (@phony, 'distdir');
1235 # Handle 'dist' target.
1238 # Set up maint_charset.
1239 $local_maint_charset = $contents{'MAINT_CHARSET'}
1240 if &variable_defined ('MAINT_CHARSET');
1241 $maint_charset = $local_maint_charset
1242 if $relative_dir eq '.';
1244 if (&variable_defined ('DIST_CHARSET'))
1246 &am_line_error ('DIST_CHARSET',
1247 "DIST_CHARSET defined but no MAINT_CHARSET defined")
1248 if ! $local_maint_charset;
1249 if ($relative_dir eq '.')
1251 $dist_charset = $contents{'DIST_CHARSET'}
1255 &am_line_error ('DIST_CHARSET',
1256 "DIST_CHARSET can only be defined at top level");
1260 # Look for common files that should be included in distribution.
1262 foreach $cfile (@common_files)
1264 if (-f ($relative_dir . "/" . $cfile))
1266 &push_dist_common ($cfile);
1270 # Keys of %dist_common are names of files to distributed. We put
1271 # README first because it then becomes easier to make a
1272 # Usenet-compliant shar file (in these, README must be first).
1273 # FIXME do more ordering of files here.
1275 if (defined $dist_common{'README'})
1277 push (@coms, 'README');
1278 undef $dist_common{'README'};
1280 push (@coms, sort keys %dist_common);
1282 &pretty_print ("DIST_COMMON =", "", @coms);
1283 $output_vars .= "\n";
1286 $output_vars .= &file_contents ('dist-vars');
1288 # Put these things in rules section so it is easier for whoever
1289 # reads Makefile.in.
1290 if ($relative_dir eq '.')
1292 $output_rules .= "\n" . 'distdir = $(PACKAGE)-$(VERSION)' . "\n";
1296 $output_rules .= ("\nsubdir = " . $relative_dir . "\n"
1297 . 'distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)'
1301 # Generate 'dist' target, and maybe dist-shar / dist-zip.
1302 if ($relative_dir eq '.')
1304 # Rule to check whether a distribution is viable.
1305 $output_rules .= ('# This target untars the dist file and tries a VPATH configuration. Then
1306 # it guarantees that the distribution is self-contained by making another
1310 $(TAR) zxf $(distdir).tar.gz
1311 mkdir $(distdir)/=build
1312 mkdir $(distdir)/=inst
1313 dc_install_base=`cd $(distdir)/=inst && pwd`; \\
1314 cd $(distdir)/=build \\
1317 . ($seen_gettext ? '--with-included-gettext ' : '')
1318 . '--srcdir=.. --prefix=$$dc_install_base \\
1322 && $(MAKE) install \\
1323 && $(MAKE) installcheck \\
1326 @echo "========================"; \\
1327 echo "$(distdir).tar.gz is ready for distribution"; \\
1328 echo "========================"
1331 $output_rules .= 'dist: distdir' . "\n\t";
1332 # Ignore return result from chmod, because it might give an
1333 # error if we chmod a symlink.
1334 $output_rules .= '-chmod -R a+r $(distdir)' . "\n\t";
1335 $output_rules .= '$(TAR) chozf $(distdir).tar.gz $(distdir)';
1336 $output_rules .= "\n\t" . 'rm -rf $(distdir)' . "\n";
1338 if (defined $options{'dist-shar'})
1340 $output_rules .= 'dist-shar: distdir' . "\n\t";
1341 # Ignore return result from chmod, because it might give
1342 # an error if we chmod a symlink.
1343 $output_rules .= '-chmod -R a+r $(distdir)' . "\n\t";
1344 $output_rules .= 'shar $(distdir) | gzip > $(distdir).shar.gz';
1345 $output_rules .= "\n\t" . 'rm -rf $(distdir)' . "\n";
1348 if (defined $options{'dist-zip'})
1350 $output_rules .= 'dist-zip: distdir' . "\n\t";
1351 $output_rules .= 'chmod -R a+r $(distdir)' . "\n\t";
1352 $output_rules .= 'zip -rq $(distdir).zip $(distdir)';
1353 $output_rules .= "\n\t" . 'rm -rf $(distdir)' . "\n";
1357 # Generate distdir target.
1358 &handle_dist_worker;
1361 # Handle auto-dependency code.
1362 sub handle_dependencies
1364 if ($use_dependencies)
1366 # Include GNU-make-specific auto-dep code.
1367 if ($dir_holds_sources)
1369 &pretty_print ('DEP_FILES =', "", sort keys %dep_files);
1370 $output_rules .= &file_contents ('depend');
1375 # Include any auto-generated deps that are present.
1376 if (-d ($relative_dir . "/.deps") && -f ($relative_dir . "/.deps/.P"))
1379 local ($gpat) = $relative_dir . "/.deps/*.P";
1381 foreach $depfile (<${gpat}>)
1383 if (! open (DEP_FILE, $depfile))
1385 &am_error ("couldn't open \`$depfile': $!");
1388 print "automake: reading $depfile\n" if $verbose;
1390 # Slurp entire file.
1391 $output_rules .= join ('', <DEP_FILE>);
1396 $output_rules .= "\n";
1401 # Handle subdirectories.
1404 if (! &variable_defined ('SUBDIRS'))
1407 ("ud_GNU_GETTEXT in configure.in but SUBDIRS not defined")
1408 if $seen_gettext && $relative_dir eq '.';
1412 &require_file_with_conf_line ($ac_gettext_line, $FOREIGN, 'ABOUT-NLS')
1415 return if ! &variable_defined ('SUBDIRS');
1417 # Make sure each directory mentioned in SUBDIRS actually exists.
1419 foreach $dir (split (' ', $contents{'SUBDIRS'}))
1421 # Skip directories substituted by configure.
1422 next if $dir =~ /^\@.*\@$/;
1423 &am_line_error ('SUBDIRS',
1424 "required directory $relative_dir/$dir does not exist")
1425 if ! -d $relative_dir . '/' . $dir;
1428 $output_rules .= &file_contents ('subdirs');
1430 # Push a bunch of phony targets.
1432 foreach $phonies ('-data', '-exec', 'dirs')
1434 push (@phony, 'install' . $phonies . '-recursive');
1435 push (@phony, 'uninstall' . $phonies . '-recursive');
1437 foreach $phonies ('all', 'check', 'installcheck', 'info', 'dvi')
1439 push (@phony, $phonies . '-recursive');
1441 &push_phony_cleaners ('recursive');
1443 push (@check, "check-recursive");
1444 push (@installcheck, "installcheck-recursive");
1445 push (@info, "info-recursive");
1446 push (@dvi, "dvi-recursive");
1448 $recursive_install = 1;
1451 # Handle remaking and configure stuff.
1452 sub handle_configure
1454 # If SUBDIRS defined, require AC_PROG_MAKE_SET.
1455 &am_line_error ('SUBDIRS', "AC_PROG_MAKE_SET must be used in configure.in")
1456 if &variable_defined ('SUBDIRS') && ! $seen_make_set;
1458 local ($top_reldir);
1459 if ($relative_dir ne '.')
1462 $output_rules .= &file_contents ('remake-subd');
1463 $top_reldir = '../';
1467 if (-f 'aclocal.m4')
1469 $output_vars .= "ACLOCAL = aclocal.m4\n";
1470 &push_dist_common ('aclocal.m4');
1472 $output_rules .= &file_contents_with_transform ('s/\@STRICTNESS\@/'
1478 ("\`install.sh' is an anachronism; use \`install-sh' instead")
1479 if -f $relative_dir . '/install.sh';
1481 # If we have a configure header, require it.
1484 # FIXME this restriction should be lifted.
1485 # FIXME first see if it is even needed as-is.
1486 &am_conf_line_error ($config_header_line,
1487 "argument to AC_CONFIG_HEADER contains \`/'\n")
1488 if ($config_header =~ /\//);
1490 &require_file_with_conf_line ($config_header_line,
1491 $FOREIGN, $config_header);
1493 # Header defined and in this directory.
1494 if (-f 'acconfig.h')
1496 $output_vars .= "ACCONFIG = acconfig.h\n";
1497 &push_dist_common ('acconfig.h');
1499 if (-f $config_name . '.top')
1501 $output_vars .= "CONFIG_TOP = ${config_name}.top\n";
1502 &push_dist_common ($config_name . '.top');
1504 if (-f $config_name . '.bot')
1506 $output_vars .= "CONFIG_BOT = ${config_name}.bot\n";
1507 &push_dist_common ($config_name . '.bot');
1510 &require_file_with_conf_line ($config_header_line, $FOREIGN,
1513 $output_rules .= &file_contents ('remake-hdr');
1514 $output_vars .= "CONFIG_HEADER_IN = ${config_header}\n";
1520 # Set location of mkinstalldirs.
1521 if ($config_aux_dir ne '.' && $config_aux_dir ne '')
1523 $output_vars .= 'mkinstalldirs = ' . $config_aux_dir;
1527 $output_vars .= 'mkinstalldirs = $(top_srcdir)';
1529 $output_vars .= '/mkinstalldirs' . "\n";
1531 &am_line_error ('CONFIG_HEADER',
1532 "\`CONFIG_HEADER' is an anachronism; now determined from \`configure.in'")
1533 if &variable_defined ('CONFIG_HEADER');
1535 # Generate CONFIG_HEADER define, and define interally.
1536 $output_vars .= "CONFIG_HEADER = ${top_builddir}/${config_name}\n"
1538 $contents{'CONFIG_HEADER'} = "${top_builddir}/${config_name}"
1541 # Now look for other files in this directory which must be remade
1542 # by config.status, and generate rules for them.
1543 local ($file, $local, $input);
1544 foreach $file (@other_input_files)
1546 # Skip files not in this directory, any Makefile, and the
1547 # config header. These last two must be handled specially.
1548 next unless &dirname ($file) eq $relative_dir;
1549 next if $file eq $top_builddir . '/' . $config_name;
1550 ($local = $file) =~ s/^.*\///;
1551 next if $local eq 'Makefile';
1553 if ($local =~ /^(.*):(.*)$/)
1555 # This is the ":" syntax of AC_OUTPUT.
1562 $input = $local . '.in';
1564 # FIXME when using autoconf ":" syntax, should we set CONFIG_FILES
1566 $output_rules .= ($local . ': '
1567 . '$(top_builddir)/config.status ' . $input . "\n"
1569 . 'cd $(top_builddir) && CONFIG_FILES='
1570 . ($relative_dir eq '.' ? '' : '$(subdir)/')
1571 . '$@ CONFIG_HEADERS= ./config.status'
1574 &require_file_with_conf_line ($ac_output_line, $FOREIGN,
1582 &am_install_var ('header', 'HEADERS', 'include',
1583 'oldinclude', 'pkginclude',
1589 return if ! $seen_gettext || $relative_dir ne '.';
1591 if (&variable_defined ('SUBDIRS'))
1595 "ud_GNU_GETTEXT in configure.in but \`po' not in SUBDIRS")
1596 if $contents{'SUBDIRS'} !~ /\bpo\b/;
1599 "ud_GNU_GETTEXT in configure.in but \`intl' not in SUBDIRS")
1600 if $contents{'SUBDIRS'} !~ /\bintl\b/;
1603 # Ensure that each language in ALL_LINGUAS has a .po file, and
1604 # each po file is mentioned in ALL_LINGUAS.
1607 local (%linguas) = ();
1608 grep ($linguas{$_} = 1, split (' ', $all_linguas));
1615 &am_line_error ($all_linguas_line,
1616 ("po/$_.po exists but \`$_' not in \`ALL_LINGUAS'"))
1620 foreach (keys %linguas)
1622 &am_line_error ($all_linguas_line,
1623 "$_ in \`ALL_LINGUAS' but po/$_.po does not exist")
1629 &am_error ("ud_GNU_GETTEXT in configure.in but \`ALL_LINGUAS' not defined");
1633 # Handle footer elements.
1636 if ($contents{'SOURCES'})
1638 &pretty_print ('SOURCES =', "",
1639 split (' ', $contents{'SOURCES'}));
1641 if ($contents{'OBJECTS'})
1643 &pretty_print ('OBJECTS =', "",
1644 split (' ', $contents{'OBJECTS'}));
1646 if ($contents{'SOURCES'} || $contents{'OBJECTS'})
1648 $output_vars .= "\n";
1651 if (defined $contents{'SUFFIXES'})
1653 # Push actual suffixes, and not $(SUFFIXES). Some versions of
1654 # make do not like variable substitutions on the .SUFFIXES
1656 push (@suffixes, split (' ', $contents{'SUFFIXES'}));
1659 $output_trailer .= ".SUFFIXES:\n";
1662 $output_trailer .= ".SUFFIXES: " . join (' ', @suffixes) . "\n";
1664 $output_trailer .= &file_contents ('footer');
1667 # Deal with installdirs target.
1668 sub handle_installdirs
1670 # GNU Makefile standards recommend this.
1671 $output_rules .= ("installdirs:"
1672 . ($recursive_install
1673 ? " installdirs-recursive\n"
1675 push (@phony, 'installdirs');
1678 &pretty_print_rule ("\t" . '$(mkinstalldirs) ', "\t\t",
1681 $output_rules .= "\n";
1684 # There are several targets which need to be merged. This is because
1685 # their complete definition is compiled from many parts. Note that we
1686 # avoid double colon rules, otherwise we'd use them instead.
1687 sub handle_merge_targets
1689 push (@all, 'Makefile');
1690 push (@all, $config_name)
1691 if $config_name && &dirname ($config_name) eq $relative_dir;
1693 &do_one_merge_target ('info', @info);
1694 &do_one_merge_target ('dvi', @dvi);
1696 if (! &variable_defined ('SUBDIRS') || $relative_dir ne '.')
1698 # 'check' must depend on 'all', but not at top level.
1700 unshift (@check, 'all');
1701 unshift (@install, 'all');
1703 &do_one_merge_target ('check', @check);
1704 &do_one_merge_target ('installcheck', @installcheck);
1706 # Handle the various install targets specially. We do this so
1707 # that (eg) "make install-exec" will run "install-exec-recursive"
1708 # if required, but "make install" won't run it twice. Step one is
1709 # to see if the user specified local versions of any of the
1710 # targets we handle. "all" is treated as one of these since
1711 # "install" can run it.
1712 push (@install_exec, 'install-exec-local')
1713 if defined $contents{'install-exec-local'};
1714 push (@install_data, 'install-data-local')
1715 if defined $contents{'install-data-local'};
1716 push (@uninstall, 'uninstall-local')
1717 if defined $contents{'uninstall-local'};
1718 push (@all, 'all-local')
1719 if defined $contents{'all-local'};
1721 if (defined $contents{'install-local'})
1723 &am_line_error ('install-local',
1724 "use \`install-data' or \`install-exec', not \`install'");
1727 # Step two: if we are doing recursive makes, write out the
1728 # appropriate rules.
1730 if ($recursive_install)
1732 push (@install, 'install-recursive');
1736 local (@hackall) = ();
1737 if ($config_name && &dirname ($config_name) eq $relative_dir)
1740 # This is kind of a hack, but I couldn't see a better
1741 # way to handle it. In this particular case, we need
1742 # to make sure config.h is built before we recurse.
1743 # We can't do this by changing the order of
1744 # dependencies to the "all" because that breaks when
1745 # using parallel makes. Instead we handle things
1747 $output_rules .= ('all-recursive-hack: $(CONFIG_HEADER)'
1748 . "\n\t" . '$(MAKE) all-recursive'
1750 push (@hackall, 'all-recursive-hack');
1751 push (@phony, 'all-recursive-hack');
1755 push (@hackall, 'all-recursive');
1758 $output_rules .= ('all-am: '
1762 push (@all, 'all-am');
1763 push (@phony, 'all-am');
1767 @all = ('all-recursive');
1771 $output_rules .= ('install-exec-am: '
1772 . join (' ', @install_exec)
1774 @install_exec = ('install-exec-recursive', 'install-exec-am');
1775 push (@install, 'install-exec-am');
1776 push (@phony, 'install-exec-am');
1780 @install_exec = ('install-exec-recursive');
1784 $output_rules .= ('install-data-am: '
1785 . join (' ', @install_data)
1787 @install_data = ('install-data-recursive', 'install-data-am');
1788 push (@install, 'install-data-am');
1789 push (@phony, 'install-data-am');
1793 @install_data = ('install-data-recursive');
1797 $output_rules .= ('uninstall-am: '
1798 . join (' ', @uninstall)
1800 @uninstall = ('uninstall-recursive', 'uninstall-am');
1801 push (@phony, 'uninstall-am');
1805 @uninstall = ('uninstall-recursive');
1809 # Step three: print definitions users can use. Code below knows
1810 # that install-exec is done before install-data, beware.
1811 $output_rules .= ("install-exec: "
1812 . join (' ', @install_exec)
1814 if (defined $contents{'install-exec-hook'})
1816 $output_rules .= "\t" . '$(MAKE) install-exec-hook' . "\n";
1818 $output_rules .= "\n";
1819 push (@install, 'install-exec') if !$recursive_install;
1820 push (@phony, 'install-exec');
1822 $output_rules .= ("install-data: "
1823 . join (' ', @install_data)
1825 if (defined $contents{'install-data-hook'})
1827 $output_rules .= "\t" . '$(MAKE) install-data-hook' . "\n";
1829 $output_rules .= "\n";
1830 push (@install, 'install-data') if !$recursive_install;
1831 push (@phony, 'install-data');
1833 # If no dependencies for 'install', add 'all'. Why? That way
1834 # "make install" at top level of distclean'd distribution won't
1835 # fail because stuff in 'lib' fails to build.
1836 if (! @install || ($#install == 1
1837 && $install[0] eq 'install-exec'
1838 && $install[1] eq 'install-data'))
1840 push (@install, 'all');
1842 $output_rules .= ('install: '
1843 . join (' ', @install)
1844 # Use "@:" as empty command so nothing prints.
1848 . join (' ', @uninstall)
1850 push (@phony, 'install', 'uninstall');
1852 $output_rules .= ('all: '
1855 push (@phony, 'all');
1857 # Generate the new 'install-strip' target.
1858 $output_rules .= ("install-strip:\n\t"
1859 . '$(MAKE) INSTALL_PROGRAM=\'$(INSTALL_PROGRAM) -s\' install'
1863 # Helper for handle_merge_targets.
1864 sub do_one_merge_target
1866 local ($name, @values) = @_;
1868 if (defined $contents{$name . '-local'})
1870 # User defined local form of target. So include it.
1871 push (@values, $name . '-local');
1872 push (@phony, $name . '-local');
1875 $output_rules .= $name . ":";
1878 $output_rules .= ' ' . join (' ', @values);
1880 $output_rules .= "\n\n";
1881 push (@phony, $name);
1884 # Handle all 'clean' targets.
1887 push (@clean, 'generic');
1888 $output_rules .= &file_contents ('clean');
1889 &push_phony_cleaners ('generic');
1891 local ($target) = $recursive_install ? 'clean-am' : 'clean';
1892 &do_one_clean_target ($target, 'mostly', '', @clean);
1893 &do_one_clean_target ($target, '', 'mostly', @clean);
1894 &do_one_clean_target ($target, 'dist', '', @clean);
1895 &do_one_clean_target ($target, 'maintainer-', 'dist', @clean);
1897 push (@phony, 'clean', 'mostlyclean', 'distclean', 'maintainer-clean');
1900 if ($recursive_install)
1902 @deps = ('am', 'recursive');
1903 &do_one_clean_target ('', 'mostly', '', @deps);
1904 &do_one_clean_target ('', '', '', @deps);
1905 &do_one_clean_target ('', 'dist', '', @deps);
1906 &do_one_clean_target ('', 'maintainer-', '', @deps);
1910 # Helper for handle_clean.
1911 sub do_one_clean_target
1913 local ($target, $name, $last_name, @deps) = @_;
1915 # Special case: if target not passed, then don't generate
1916 # dependency on next "lower" clean target (eg no
1917 # clean<-mostlyclean derivation). In this case the target is
1918 # implicitly known to be 'clean'.
1919 local ($flag) = $target;
1920 $target = 'clean' if ! $flag;
1922 grep (($_ = $name . 'clean-' . $_) && 0, @deps);
1925 if ($last_name || $name ne 'mostly')
1927 push (@deps, $last_name . $target . " ");
1930 # FIXME not sure if I like the tabs here.
1931 &pretty_print_rule ($name . $target . ": ", "\t\t", @deps);
1933 # FIXME shouldn't we really print these messages before running
1935 if ($name . $target eq 'maintainer-clean')
1937 # Print a special warning.
1939 ("\t\@echo \"This command is intended for maintainers to use;\"\n"
1940 . "\t\@echo \"it deletes files that may require special "
1941 . "tools to rebuild.\"\n");
1943 $output_rules .= "\trm -f config.status\n"
1944 if $relative_dir eq '.';
1946 elsif ($name . $target eq 'distclean')
1948 $output_rules .= "\trm -f config.status\n";
1950 $output_rules .= "\n";
1953 # Handle .PHONY target.
1956 &pretty_print_rule ('.PHONY:', "", @phony);
1957 $output_rules .= "\n";
1960 # Handle TESTS variable and other checks.
1963 if (defined $options{'dejagnu'})
1965 push (@check, 'check-DEJAGNU');
1966 push (@phony, 'check-DEJAGNU');
1967 $output_rules .= &file_contents ('dejagnu') . "\n";
1968 # Note that in the rule we don't directly generate site.exp to
1969 # avoid the possibility of a corrupted site.exp if make is
1970 # interrupted. Jim Meyering has some useful text on this
1972 $output_rules .= ("site.exp: Makefile\n"
1973 . "\t\@echo 'Making a new site.exp file...'\n"
1974 . "\t-\@rm -f site.bak\n"
1975 . "\t\@echo '## these variables are automatically generated by make ##' > \$\@-t\n"
1976 . "\t\@echo '# Do not edit here. If you wish to override these values' >> \$\@-t\n"
1977 . "\t\@echo '# edit the last section' >> \$\@-t\n"
1978 . "\t\@echo 'set tool \$(DEJATOOL)' >> \$\@-t\n"
1979 . "\t\@echo 'set srcdir \$(srcdir)' >> \$\@-t\n"
1980 . "\t\@echo 'set objdir' \`pwd\` >> \$\@-t\n");
1982 # Extra stuff for AC_CANONICAL_*
1983 local (@whatlist) = ();
1984 if ($seen_canonical)
1986 push (@whatlist, 'host')
1989 # Extra stuff only for AC_CANONICAL_SYSTEM.
1990 if ($seen_canonical == $AC_CANONICAL_SYSTEM)
1992 push (@whatlist, 'target', 'build');
1996 foreach $c1 (@whatlist)
1998 foreach $c2 ('alias', 'triplet')
2000 $output_rules .= "\t\@echo 'set ${c1}_${c2} \$(${c1}_${c2})' >> \$\@-t\n";
2004 $output_rules .= ("\t\@echo '## All variables above are generated by configure. Do Not Edit ##' >> \$\@-t\n"
2005 . "\t-\@sed '1,/^## All variables above are.*##/ d' site.bak >> \$\@-t\n"
2006 . "\t-\@mv site.exp site.bak\n"
2007 . "\t\@mv \$\@-t site.exp\n");
2012 foreach $c ('DEJATOOL', 'RUNTEST', 'RUNTESTFLAGS')
2014 if (&variable_defined ($c))
2016 &am_line_error ($c, "\`$c' defined but \`dejagnu' not in \`AUTOMAKE_OPTIONS'");
2021 if (&variable_defined ('TESTS'))
2023 push (@check, 'check-TESTS');
2024 push (@phony, 'check-TESTS');
2025 # FIXME use $(SHELL) here? That is what Ulrich suggests.
2026 # Maybe a new macro, $(TEST_SHELL), a la $(CONFIG_SHELL)? For
2027 # now we just execute the file directly; this allows test
2028 # files which are compiled -- a possibly useful feature.
2029 $output_rules .= 'check-TESTS: $(TESTS)
2030 @failed=0; all=0; \\
2031 srcdir=$(srcdir); export srcdir; \\
2032 for tst in $(TESTS); do \\
2033 all=`expr $$all + 1`; \\
2034 if test -f $$tst; then dir=.; \\
2035 else dir="$(srcdir)"; fi; \\
2036 if $(TESTS_ENVIRONMENT) $$dir/$$tst; then \\
2037 echo "PASS: $$tst"; \\
2039 failed=`expr $$failed + 1`; \\
2040 echo "FAIL: $$tst"; \\
2043 if test "$$failed" -eq 0; then \\
2044 echo "========================"; \\
2045 echo "All $$all tests passed"; \\
2046 echo "========================"; \\
2048 echo "$$failed of $$all tests failed"; \\
2054 # Handle Emacs Lisp.
2055 sub handle_emacs_lisp
2057 local (@elfiles) = &am_install_var ('lisp', 'LISP', 'lisp', 'noinst');
2062 $output_vars .= "lispdir = \@lispdir\@\n";
2063 $output_rules .= (".el.elc:\n"
2064 . "\t\@echo 'WARNING: Warnings can be ignored. :-)'\n"
2065 . "\t\$(SHELL) \$(srcdir)/elisp-comp \$<\n");
2066 push (@suffixes, '.el', '.elc');
2068 # Generate .elc files.
2069 grep ($_ .= 'c', @elfiles);
2070 &pretty_print ('ELCFILES =', '', @elfiles);
2073 if (&variable_defined ('lisp_LISP'))
2075 $varname = 'lisp_LISP';
2076 &am_error ("\`lisp_LISP' defined but \`ud_PATH_LISPDIR' not in \`configure.in'")
2081 $varname = 'noinst_LISP';
2083 &require_file_with_line ($varname, $FOREIGN, 'elisp-comp');
2088 ################################################################
2090 # Scan configure.in for interesting things.
2091 # FIXME ensure VERSION, PACKAGE are set.
2094 open (CONFIGURE, 'configure.in')
2095 || die "automake: couldn't open \`configure.in': $!\n";
2096 print "automake: reading configure.in\n" if $verbose;
2098 # Reinitialize libsources here. This isn't really necessary,
2099 # since we currently assume there is only one configure.in. But
2100 # that won't always be the case.
2103 local ($in_ac_output, @make_list) = 0;
2104 local ($libobj_iter);
2107 # Remove comments from current line.
2111 # Populate libobjs array.
2112 if (/AC_FUNC_ALLOCA/)
2114 $libsources{'alloca.c'} = 1;
2116 elsif (/AC_FUNC_GETLOADAVG/)
2118 $libsources{'getloadavg.c'} = 1;
2120 elsif (/AC_FUNC_MEMCMP/)
2122 $libsources{'memcmp.c'} = 1;
2124 elsif (/AC_STRUCT_ST_BLOCKS/)
2126 $libsources{'fileblocks.c'} = 1;
2128 elsif (/(AC|fp)_FUNC_FNMATCH/)
2130 # AC_FUNC_FNMATCH is just wishful thinking at this point.
2131 $libsources{'fnmatch.c'} = 1;
2133 elsif (/AC_REPLACE_FUNCS\s*\((.*)\)/)
2135 foreach (split (' ', $1))
2137 $libsources{$_ . '.c'} = 1;
2140 elsif (/AC_REPLACE_GNU_GETOPT/)
2142 $libsources{'getopt.c'} = 1;
2143 $libsources{'getopt1.c'} = 1;
2145 elsif (/LIBOBJS="(.*)\s+\$LIBOBJS"/
2146 || /LIBOBJS="\$LIBOBJS\s+(.*)"/)
2148 foreach $libobj_iter (split (' ', $1))
2150 if ($libobj_iter =~ /^(.*)\.o$/)
2152 $libsources{$1 . '.c'} = 1;
2157 # Process the AC_OUTPUT macro.
2158 if (! $in_ac_output && s/AC_OUTPUT\s*\(\[?//)
2161 $ac_output_line = $.;
2165 $in_ac_output = 0 if s/[\]\),].*$//;
2167 # Look at potential Makefile.am's.
2173 push (@make_list, $_);
2177 push (@other_input_files, $_);
2182 if (/AC_CONFIG_AUX_DIR\(([^)]+)\)/)
2184 @config_aux_path = $1;
2187 # Check for ansi2knr.
2188 $fp_c_prototypes = 1 if /fp_C_PROTOTYPES/;
2190 # Check for NLS support.
2191 if (/ud_GNU_GETTEXT/)
2194 $ac_gettext_line = $.;
2197 # Look for ALL_LINGUAS.
2198 if (/ALL_LINGUAS="(.*)"$/ || /ALL_LINGUAS=(.*)$/)
2202 $all_linguas_line = $.;
2205 # Handle configuration headers.
2206 if (/AC_CONFIG_HEADER\s*\((.*)\)/)
2208 $config_header_line = $.;
2210 if ($config_name =~ /^([^:]+):(.+)$/)
2213 $config_header = $2;
2217 $config_header = $config_name . '.in';
2221 # Handle AC_CANONICAL_*. Always allow upgrading to
2222 # AC_CANONICAL_SYSTEM, but never downgrading.
2223 $seen_canonical = $AC_CANONICAL_HOST
2224 if ! $seen_canonical && /AC_CANONICAL_HOST/;
2225 $seen_canonical = $AC_CANONICAL_SYSTEM if /AC_CANONICAL_SYSTEM/;
2227 $seen_canonical = 1 if /AC_CHECK_TOOL/;
2228 $seen_path_xtra = 1 if /AC_PATH_XTRA/;
2230 # Sometimes it is desirable to explicitly set YACC. For
2231 # instance some people don't want to use bison.
2232 $seen_prog_yacc = 1 if (/AC_PROG_YACC/
2233 || /AC_SUBST\(YACC\)/
2234 || /AC_(PATH|CHECK)_PROGS?\(YACC/);
2236 # Some things required by Automake.
2237 $seen_make_set = 1 if /AC_PROG_MAKE_SET/;
2238 $seen_arg_prog = 1 if /AC_ARG_PROGRAM/;
2239 $seen_ranlib = 1 if /AC_PROG_RANLIB/;
2240 $seen_maint_mode = 1 if /jm_MAINTAINER_MODE/;
2241 $seen_package = 1 if /PACKAGE=/;
2242 $seen_version = 1 if /VERSION=/;
2244 # Weird conditionals here because it is always allowed to
2245 # upgrade to fp_PROG_INSTALL but never to downgrade to
2247 $seen_prog_install = 1 if ! $seen_prog_install && /AC_PROG_INSTALL/;
2248 $seen_prog_install = 2 if /fp_PROG_INSTALL/;
2250 $seen_lispdir = 1 if /ud_PATH_LISPDIR/;
2252 if (/AM_PROG_LIBTOOL/)
2260 # Set input files if not specified by user.
2261 @input_files = @make_list if (! @input_files);
2265 &am_conf_error ("\`PACKAGE' not defined in configure.in")
2267 &am_conf_error ("\`VERSION' not defined in configure.in")
2270 # Look for some files we need. Always check for these. This
2271 # check must be done for every run, even those where we are only
2272 # looking at a subdir Makefile. We must set relative_dir so that
2273 # the file-finding machinery works.
2274 local ($relative_dir) = '.';
2275 &require_config_file ($FOREIGN, 'install-sh', 'mkinstalldirs');
2278 ################################################################
2280 # Do any extra checking for GNU standards.
2281 sub check_gnu_standards
2283 if ($relative_dir eq '.')
2285 # In top level (or only) directory.
2286 &require_file ($GNU, 'INSTALL', 'NEWS', 'README', 'COPYING',
2287 'AUTHORS', 'ChangeLog');
2291 # Do any extra checking for GNITS standards.
2292 sub check_gnits_standards
2294 if ($strictness >= $GNITS && -f $relative_dir . '/COPYING.LIB')
2297 ("\`${relative_dir}/COPYING.LIB' disallowed by Gnits standards");
2300 if ($relative_dir eq '.')
2302 # In top level (or only) directory.
2303 &require_file ($GNITS, 'THANKS');
2307 ################################################################
2309 # Pretty-print something. HEAD is what should be printed at the
2310 # beginning of the first line, FILL is what should be printed at the
2311 # beginning of every subsequent line.
2312 sub pretty_print_internal
2314 local ($head, $fill, @values) = @_;
2316 local ($column) = length ($head);
2317 local ($result) = $head;
2319 # Fill length is number of characters. However, each Tab
2320 # character counts for eight. So we count the number of Tabs and
2322 local ($fill_length) = length ($fill);
2323 $fill_length += 7 * ($fill =~ tr/\t/\t/d);
2328 # "71" because we also print a space.
2329 if ($column + length ($_) > 71)
2331 $result .= " \\\n" . $fill;
2332 $column = $fill_length;
2336 $result .= ' ' unless ($bol);
2338 $column += length ($_) + 1;
2346 # Pretty-print something and append to output_vars.
2349 $output_vars .= &pretty_print_internal (@_);
2352 # Pretty-print something and append to output_rules.
2353 sub pretty_print_rule
2355 $output_rules .= &pretty_print_internal (@_);
2359 ################################################################
2361 # See if a variable exists.
2362 sub variable_defined
2365 if (defined $targets{$var})
2367 &am_line_error ($var, "\`$var' is target; expected variable");
2369 return (defined $contents{$var} && ! defined $targets{$var});
2372 # Read Makefile.am and set up %contents. Simultaneously copy lines
2373 # from Makefile.am into $output_trailer or $output_vars as
2374 # appropriate. NOTE we put rules in the trailer section. We want
2375 # user rules to come after our generated stuff.
2378 local ($amfile) = @_;
2380 # Compute relative location of the top object directory.
2381 local (@topdir) = ();
2382 foreach (split (/\//, $relative_dir))
2384 next if $_ eq '.' || $_ eq '';
2391 push (@topdir, '..');
2394 @topdir = ('.') if ! @topdir;
2396 $top_builddir = join ('/', @topdir);
2398 ($build_rx = $top_builddir) =~ s/(\W)/\\$1/g;
2399 local ($header_vars) =
2400 &file_contents_with_transform
2401 ('s/\@top_builddir\@/' . $build_rx . '/g',
2404 # Generate some useful variables when AC_CANONICAL_* used.
2405 if ($seen_canonical)
2407 $header_vars .= ('host_alias = @host_alias@' . "\n"
2408 . 'host_triplet = @host@' . "\n");
2409 if ($seen_canonical == $AC_CANONICAL_SYSTEM)
2411 $header_vars .= ('build_alias = @build_alias@' . "\n"
2412 . 'build_triplet = @build@' . "\n");
2413 $header_vars .= ('target_alias = @target_alias@' . "\n"
2414 . 'target_triplet = @target@' . "\n");
2418 open (AM_FILE, $amfile) || die "automake: couldn't open \`$amfile': $!\n";
2419 print "automake: reading $amfile\n" if $verbose;
2421 $output_vars .= ("# $in_file_name generated automatically by automake "
2422 . $VERSION . " from $am_file_name\n");
2424 # Generate copyright for generated Makefile.in.
2425 $output_vars .= $gen_copyright;
2427 local ($saw_bk) = 0;
2428 local ($was_rule) = 0;
2429 local ($spacing) = '';
2430 local ($comment) = '';
2431 local ($last_var_name) = '';
2436 if (/$IGNORE_PATTERN/o)
2438 # Merely delete comments beginning with two hashes.
2440 elsif (/$WHITE_PATTERN/o)
2442 # Stick a single white line before the incoming macro or rule.
2446 elsif (/$COMMENT_PATTERN/o)
2448 # Stick comments before the incoming macro or rule. Make
2449 # sure a blank line preceeds comments.
2450 $spacing = "\n" unless $blank;
2451 $comment .= $spacing . $_;
2460 $output_vars .= $comment . "\n" . $header_vars;
2464 local ($is_ok_macro);
2468 unless substr ($_, -1, 1) eq "\n";
2470 $_ =~ s/\@MAINT\@//g
2471 unless $seen_maint_mode;
2473 if (/$IGNORE_PATTERN/o)
2475 # Merely delete comments beginning with two hashes.
2477 elsif (/$WHITE_PATTERN/o)
2479 # Stick a single white line before the incoming macro or rule.
2482 elsif (/$COMMENT_PATTERN/o)
2484 # Stick comments before the incoming macro or rule.
2485 $comment .= $spacing . $_;
2492 $output_trailer .= $_;
2499 # Chop newline and backslash if this line is
2500 # continued. FIXME maybe ensure trailing whitespace
2504 $contents{$last_var_name} .= $_;
2507 elsif (/$RULE_PATTERN/o)
2509 # warn "** Saw rule .$1.\n";
2512 # Value here doesn't matter; for targets we only note
2516 $content_lines{$1} = $.;
2517 $output_trailer .= $comment . $spacing . $_;
2518 $comment = $spacing = '';
2521 elsif (($is_ok_macro = /$MACRO_PATTERN/o)
2522 || /$BOGUS_MACRO_PATTERN/o)
2524 # Found a macro definition.
2526 $last_var_name = $1;
2527 if (substr ($2, -1) eq "\\")
2529 $contents{$1} = substr ($2, 0, length ($2) - 1);
2535 $content_lines{$1} = $.;
2536 $output_vars .= $comment . $spacing . $_;
2537 $comment = $spacing = '';
2541 &am_line_error ($., "bad macro name \`$1'")
2546 # This isn't an error; it is probably a continued rule.
2547 # In fact, this is what we assume.
2549 $output_trailer .= $comment . $spacing . $_;
2550 $comment = $spacing = '';
2557 $output_trailer .= $comment;
2560 ################################################################
2562 sub initialize_global_constants
2564 # Values for AC_CANONICAL_*
2565 $AC_CANONICAL_HOST = 1;
2566 $AC_CANONICAL_SYSTEM = 2;
2568 # Associative array of standard directory names. Entry is TRUE if
2569 # corresponding directory should be installed during
2570 # 'install-exec' phase.
2588 # Helper text for dealing with man pages.
2589 $install_man_format =
2590 ' @sect=@SECTION@; \\
2591 inst=`echo "@MANBASE@" | sed \'$(transform)\'`.@FULLSECT@; \\
2592 echo installing @MAN@ as $(mandir)/man$$sect/$$inst; \\
2593 if test -f $(srcdir)/@MAN@; then file=$(srcdir)/@MAN@; \\
2594 else file=@MAN@; fi; \\
2595 $(INSTALL_DATA) $(srcdir)/@MAN@ $(mandir)/man$$sect/$$inst
2598 $uninstall_man_format =
2599 ' inst=`echo "@MANBASE@" | sed \'$(transform)\'`.@FULLSECT@; \\
2600 rm -f $(mandir)/man@SECTION@/$$inst
2603 # Commonly found files we look for and automatically include in
2607 "README", "THANKS", "TODO", "NEWS", "COPYING", "COPYING.LIB",
2608 "INSTALL", "ABOUT-NLS", "ChangeLog", "configure", "configure.in",
2609 "config.guess", "config.sub", "AUTHORS", "BACKLOG", "ABOUT-GNU",
2610 "libversion.in", "mdate-sh", "mkinstalldirs", "install-sh",
2611 'texinfo.tex', "ansi2knr.c", "ansi2knr.1"
2614 # Commonly used files we auto-include, but only sometimes.
2617 "aclocal.m4", "acconfig.h", "config.h.top",
2618 "config.h.bot", "stamp-h.in", 'stamp-vti', 'elisp-comp', 'libtool'
2622 --amdir=DIR directory storing config files
2623 --foreign same as --strictness=foreign
2624 --gnits same as --strictness=gnits
2625 --gnu same as --strictness=gnu
2626 --help print this help, then exit
2627 -i, --include-deps include generated dependencies in Makefile.in
2628 -a, --add-missing add missing standard files to package
2629 --no-force only update Makefile.in's that are out of date
2630 -o DIR, --output-dir=DIR
2631 put generated Makefile.in's into DIR
2632 -s LEVEL, --strictness=LEVEL
2633 set strictness level. LEVEL is foreign, gnu, gnits
2634 -v, --verbose verbosely list files processed
2635 --version print version number, then exit\n";
2637 # Copyright on generated Makefile.ins.
2639 # Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
2640 # This Makefile.in is free software; the Free Software Foundation
2641 # gives unlimited permission to copy, distribute and modify it.
2645 # (Re)-Initialize per-Makefile.am variables.
2646 sub initialize_per_input
2648 # These two variables are used when generating each Makefile.in.
2649 # They hold the Makefile.in until it is ready to be printed.
2652 $output_trailer = '';
2654 # Suffixes found during a run.
2657 # This holds the contents of a Makefile.am, as parsed by
2661 # This holds the names which are targets. These also appear in
2665 # This holds the line numbers at which various elements of
2666 # %contents are defined.
2667 %content_lines = ();
2669 # This holds the "relative directory" of the current Makefile.in.
2670 # Eg for src/Makefile.in, this is "src".
2673 # This holds a list of files that are included in the
2677 # List of dependencies for the obvious targets.
2692 # These are pretty obvious, too. They are used to define the
2693 # SOURCES and OBJECTS variables.
2697 # TRUE if current directory holds any C source files. (Actually
2698 # holds object extension, but this information is encapsulated in
2699 # the function get_object_extension).
2700 $dir_holds_sources = '';
2702 # TRUE if install targets should work recursively.
2703 $recursive_install = 0;
2708 # Strictness levels.
2709 $strictness = $default_strictness;
2710 $strictness_name = $default_strictness_name;
2712 # Options from AUTOMAKE_OPTIONS.
2715 # Whether or not dependencies are handled. Can be further changed
2716 # in handle_options.
2717 $use_dependencies = $cmdline_use_dependencies;
2720 $local_maint_charset = $maint_charset;
2724 ################################################################
2726 # Return contents of a file from $am_dir, automatically skipping
2727 # macros or rules which are already known. Runs command on each line
2728 # as it is read; this command can modify $_.
2729 sub file_contents_with_transform
2731 local ($command, $basename) = @_;
2732 local ($file) = $am_dir . '/' . $basename . '.am';
2734 open (FC_FILE, $file)
2735 || die "automake: installation error: cannot open \`$file'\n";
2737 # print "automake: reading $file\n" if $verbose;
2739 local ($was_rule) = 0;
2740 local ($result_vars) = '';
2741 local ($result_rules) = '';
2742 local ($comment) = '';
2743 local ($spacing) = "\n";
2744 local ($skipping) = 0;
2748 $_ =~ s/\@MAINT\@//g
2749 unless $seen_maint_mode;
2753 if (/$IGNORE_PATTERN/o)
2755 # Merely delete comments beginning with two hashes.
2757 elsif (/$WHITE_PATTERN/o)
2759 # Stick a single white line before the incoming macro or rule.
2762 elsif (/$COMMENT_PATTERN/o)
2764 # Stick comments before the incoming macro or rule.
2765 $comment .= $spacing . $_;
2772 $result_rules .= $_ if ! $skipping;
2776 $result_vars .= $_ if ! $skipping;
2780 elsif (/$RULE_PATTERN/o)
2782 # warn "** Found rule .$1.\n";
2785 $skipping = defined $contents{$1};
2786 # warn "** Skip $skipping\n" if $skipping;
2787 $result_rules .= $comment . $spacing . $_ if ! $skipping;
2788 $comment = $spacing = '';
2791 elsif (/$MACRO_PATTERN/o)
2793 # warn "** Found macro .$1.\n";
2794 # Found a variable reference.
2796 $skipping = defined $contents{$1};
2797 # warn "** Skip $skipping\n" if $skipping;
2798 $result_vars .= $comment . $spacing . $_ if ! $skipping;
2799 $comment = $spacing = '';
2804 # This isn't an error; it is probably a continued rule.
2805 # In fact, this is what we assume.
2807 $result_rules .= $comment . $spacing . $_ if ! $skipping;
2808 $comment = $spacing = '';
2814 return $result_vars . $result_rules . $comment;
2817 # Like file_contents_with_transform, but no transform.
2820 return &file_contents_with_transform ('', @_);
2823 # Handle `where_HOW' variable magic. Does all lookups, generates
2824 # install code, and possibly generates code to define the primary
2825 # variable. The first argument is the name of the .am file to munge,
2826 # the second argument is the primary variable (eg HEADERS), and all
2827 # subsequent arguments are possible installation locations. Returns
2828 # list of all values of all _HOW targets.
2830 # FIXME this should be rewritten to be cleaner. It should be broken
2831 # up into multiple functions.
2833 # Usage is: am_install_var (OPTION..., file, HOW, where...)
2838 local ($do_all, $do_clean) = (1, 0);
2841 if ($args[0] eq '-clean')
2845 elsif ($args[0] eq '-no-all')
2849 elsif ($args[0] !~ /^-/)
2855 local ($file, $primary, @prefixes) = @args;
2858 local (@result) = ();
2860 # Now that configure substitutions are allowed in where_HOW
2861 # variables, it is an error to actually define the primary.
2862 &am_line_error ($primary, "\`$primary' is an anachronism")
2863 if &variable_defined ($primary);
2866 # Look for misspellings. It is an error to have a variable ending
2867 # in a "reserved" suffix whose prefix is unknown, eg
2868 # "bni_PROGRAMS". However, unusual prefixes are allowed if a
2869 # variable of the same name (with "dir" appended) exists. For
2870 # instance, if the variable "zardir" is defined, then
2871 # "zar_PROGRAMS" becomes valid. This is to provide a little extra
2872 # flexibility in those cases which need it. Perhaps it should be
2873 # disallowed in the Gnits case? The problem is, sometimes it is
2874 # useful to put things in a subdir of eg pkgdatadir, perhaps even
2876 local (%valid, $varname);
2877 grep ($valid{$_} = 0, @prefixes);
2878 $valid{'EXTRA'} = 0;
2879 foreach $varname (keys %contents)
2881 if ($varname =~ /^(.*)_$primary$/)
2883 if (! defined $valid{$1} && ! &variable_defined ($1 . 'dir'))
2885 &am_line_error ($varname, "invalid variable \"$varname\"");
2889 # Ensure all extended prefixes are actually used.
2895 local ($clean_file) = $file . '-clean';
2898 foreach $X (keys %valid)
2900 $one_name = $X . '_' . $primary;
2901 if (&variable_defined ($one_name))
2903 # Append actual contents of where_PRIMARY variable to
2906 foreach $rcurs (split (' ', $contents{$one_name}))
2908 # Skip configure substitutions. Possibly bogus.
2909 next if $rcurs =~ /^\@.*\@$/;
2910 push (@result, $rcurs);
2913 # "EXTRA" shouldn't be used when generating clean targets,
2914 # @all, or install targets.
2915 next if $X eq 'EXTRA';
2920 &file_contents_with_transform ('s/\@DIR\@/' . $X . '/go',
2923 push (@clean, $X . $primary);
2924 &push_phony_cleaners ($X . $primary);
2929 push (@check, '$(' . $one_name . ')');
2933 push (@used, '$(' . $one_name . ')');
2935 if ($X eq 'noinst' || $X eq 'check')
2937 # Objects which don't get installed by default.
2942 &file_contents_with_transform ('s/\@DIR\@/' . $X . '/go',
2945 push (@uninstall, 'uninstall-' . $X . $primary);
2946 push (@phony, 'uninstall-' . $X . $primary);
2947 push (@installdirs, '$(' . $X . 'dir)');
2948 if ($exec_dir_p{$X})
2950 push (@install_exec, 'install-' . $X . $primary);
2951 push (@phony, 'install-' . $X . $primary);
2955 push (@install_data, 'install-' . $X . $primary);
2956 push (@phony, 'install-' . $X . $primary);
2964 &pretty_print ($primary . ' =', '', @used);
2965 $output_vars .= "\n";
2968 # Push here because PRIMARY might be configure time determined.
2969 push (@all, '$(' . $primary . ')')
2970 if $do_all && @used;
2976 ################################################################
2978 # This variable is local to the "require file" set of functions.
2979 @require_file_paths = ();
2981 # Verify that the file must exist in the current directory. Usage:
2982 # require_file (isconfigure, line_number, strictness, file) strictness
2983 # is the strictness level at which this file becomes required. Must
2984 # set require_file_paths before calling this function.
2985 # require_file_paths is set to hold a single directory (the one in
2986 # which the first file was found) before return.
2987 sub require_file_internal
2989 local ($is_configure, $line, $mystrict, @files) = @_;
2990 local ($file, $fullfile);
2991 local ($found_it, $errfile, $errdir);
2994 foreach $file (@files)
2997 foreach $dir (@require_file_paths)
3001 $fullfile = $relative_dir . "/" . $file;
3002 $errdir = $relative_dir unless $errdir;
3006 $fullfile = $dir . "/" . $file;
3007 $errdir = $dir unless $errdir;
3010 # Use different name for "error filename". Otherwise on
3011 # an error the bad file will be reported as eg
3012 # `../../install-sh' when using the default
3014 $errfile = $errdir . '/' . $file;
3019 &push_dist_common ($file) if $dir eq $relative_dir;
3027 # Prune the path list.
3028 @require_file_paths = $save_dir;
3032 if ($strictness >= $mystrict)
3034 # Only install missing files according to our desired
3036 if ($add_missing && -f ($am_dir . '/' . $file))
3038 # Install the missing file. Symlink if we can, copy
3040 if ($symlink_exists)
3042 symlink ($am_dir . '/' . $file, $errfile);
3046 system ('cp', $am_dir . '/' . $file, $errfile);
3049 # FIXME this is a hack. Should have am_warn.
3050 local ($save) = $exit_status;
3055 "required file \"$errfile\" not found; installing");
3061 "required file \"$errfile\" not found; installing");
3063 $exit_status = $save;
3067 # Only an error if strictness constraint violated.
3071 ($line, "required file \"$errfile\" not found");
3076 ($line, "required file \"$errfile\" not found");
3084 # Like require_file_with_line, but error messages refer to
3085 # configure.in, not the current Makefile.am.
3086 sub require_file_with_conf_line
3088 @require_file_paths = '.';
3089 &require_file_internal (1, @_);
3092 sub require_file_with_line
3094 @require_file_paths = '.';
3095 &require_file_internal (0, @_);
3100 @require_file_paths = '.';
3101 &require_file_internal (0, '', @_);
3104 # Require a file that is also required by Autoconf. Looks in
3105 # configuration path, as specified by AC_CONFIG_AUX_DIR.
3106 sub require_config_file
3108 @require_file_paths = @config_aux_path;
3109 &require_file_internal (0, '', @_);
3110 local ($dir) = $require_file_paths[0];
3111 @config_aux_path = @require_file_paths;
3114 $config_aux_dir = '.';
3118 $config_aux_dir = '$(top_srcdir)/' . $dir;
3122 # Assumes that the line number is in Makefile.am.
3123 sub require_conf_file_with_line
3125 @require_file_paths = @config_aux_path;
3126 &require_file_internal (0, @_);
3127 local ($dir) = $require_file_paths[0];
3128 @config_aux_path = @require_file_paths;
3131 $config_aux_dir = '.';
3135 $config_aux_dir = '$(top_srcdir)/' . $dir;
3139 # Assumes that the line number is in Makefile.am.
3140 sub require_conf_file_with_conf_line
3142 @require_file_paths = @config_aux_path;
3143 &require_file_internal (1, @_);
3144 local ($dir) = $require_file_paths[0];
3145 @config_aux_path = @require_file_paths;
3148 $config_aux_dir = '.';
3152 $config_aux_dir = '$(top_srcdir)/' . $dir;
3156 ################################################################
3158 # Push a list of files onto dist_common.
3159 sub push_dist_common
3161 local (@files) = @_;
3164 foreach $file (@files)
3166 $dist_common{$file} = 1;
3170 # Push a list of clean targets onto phony.
3171 sub push_phony_cleaners
3175 foreach $target ('mostly', 'dist', '', 'maintainer-')
3177 push (@phony, $target . 'clean-' . $base);
3184 $strictness_name = $_[0];
3185 if ($strictness_name eq 'gnu')
3189 elsif ($strictness_name eq 'gnits')
3191 $strictness = $GNITS;
3193 elsif ($strictness_name eq 'foreign')
3195 $strictness = $FOREIGN;
3199 die "automake: level \`$strictness_name' not recognized\n";
3204 ################################################################
3206 # Return directory name of file.
3212 ($sub = $file) =~ s,/+[^/]+$,,g;
3213 $sub = '.' if $sub eq $file;
3220 local ($dirname) = @_;
3221 system ("mkdir", $dirname);
3224 ################################################################
3226 # Print an error message and set exit status.
3229 warn "automake: ${am_file}.am: ", join (' ', @_), "\n";
3235 local ($symbol, @args) = @_;
3239 # If SYMBOL not already a line number, look it up in Makefile.am.
3240 $symbol = $content_lines{$symbol} unless $symbol =~ /^\d+$/;
3241 $symbol .= ': ' if $symbol;
3242 warn "${am_file}.am:", $symbol, join (' ', @args), "\n";
3251 # Like am_error, but while scanning configure.in.
3254 # FIXME can run in subdirs.
3255 warn "automake: configure.in: ", join (' ', @_), "\n";
3259 # Error message with line number referring to configure.in.
3260 sub am_conf_line_error
3262 local ($line, @args) = @_;
3266 warn "configure.in: $line: ", join (' ', @args), "\n";
3271 &am_conf_error (@args);
3275 # Tell user where our aclocal.m4 is, but only once.
3276 sub keyed_aclocal_warning
3279 warn "automake: macro \`$key' can be found in ${am_dir}/aclocal.m4\n";
3282 # Print usage information.
3285 print "Usage: automake [OPTION] ... [Makefile]...\n";
3287 print "\nFiles which are automatically distributed, if found:\n";
3288 $~ = "USAGE_FORMAT";
3289 local (@lcomm) = sort ((@common_files, @common_sometimes));
3290 local ($one, $two, $three, $four);
3293 $one = shift @lcomm;
3294 $two = @lcomm ? shift @lcomm : '';
3295 $three = @lcomm ? shift @lcomm : '';
3296 $four = @lcomm ? shift @lcomm : '';
3303 format USAGE_FORMAT =
3304 @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<
3305 $one, $two, $three, $four