5 eval 'exec @PERL@ -S $0 ${1+"$@"}'
8 # automake - create Makefile.in from Makefile.am
9 # Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
11 # This program is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by
13 # the Free Software Foundation; either version 2, or (at your option)
16 # This program is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write to the Free Software
23 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
26 # Originally written by David Mackenzie <djm@gnu.ai.mit.edu>.
27 # Perl reimplementation by Tom Tromey <tromey@drip.colorado.edu>.
30 # Parameters set by configure. Not to be changed. NOTE: assign
31 # VERSION as string so that eg version 0.30 will print correctly.
32 $VERSION = "@VERSION@";
33 $PACKAGE = "@PACKAGE@";
35 $am_dir = "@datadir@/@PACKAGE@";
38 $IGNORE_PATTERN = "^##([^#].*)?\$";
39 $WHITE_PATTERN = "^[ \t]*\$";
40 $COMMENT_PATTERN = "^#";
41 $RULE_PATTERN = "^([\$a-zA-Z_.][-.a-zA-Z0-9_(){}/]*) *:";
42 $MACRO_PATTERN = "^([A-Za-z][A-Za-z0-9_]*)[ \t]*=[ \t]*(.*)\$";
43 $BOGUS_MACRO_PATTERN = "^([^ \t]*)[ \t]*=[ \t]*(.*)\$";
44 $GNITS_VERSION_PATTERN = "[0-9]+\\.[0-9]+([a-z]|\\.[0-9]+)";
46 # Constants to define the "strictness" level.
53 # Variables global to entire run.
55 # TRUE if we should always generate Makefile.in.
56 $force_generation = 1;
58 # Strictness level as set on command line.
59 $default_strictness = $GNU;
61 # Name of strictness level, as set on command line.
62 $default_strictness_name = 'gnu';
64 # This is TRUE if GNU make specific automatic dependency generation
65 # code should be included in generated Makefile.in.
66 $cmdline_use_dependencies = 1;
68 # TRUE if in verbose mode.
71 # This holds our (eventual) exit status. We don't actually exit until
72 # we have processed all input files.
75 # From the Perl manual.
76 $symlink_exists = (eval 'symlink ("", "");', $@ eq '');
78 # TRUE if missing standard files should be installed.
81 # Files found by scanning configure.in for LIBOBJS.
84 # True if AM_C_PROTOTYPES appears in configure.in.
87 # Names used in AC_CONFIG_HEADER call. $config_name is the actual
88 # (first) argument. $config_header is the '.in' file. Ordinarily the
89 # second is derived from the first, but they can be different if the
90 # weird "NAME:FILE" syntax is used.
93 # Line number at which AC_CONFIG_HEADER appears in configure.in.
94 $config_header_line = 0;
96 # Directory where output files go. Actually, output files are
97 # relative to this directory.
98 $output_directory = '.';
100 # Relative location of top build directory.
103 # Absolute location of top build directory.
104 $build_directory = '';
106 # Name of srcdir as given in build directory's Makefile. For
110 # List of Makefile.am's to process.
113 # List of files in AC_OUTPUT without Makefile.am.
114 @other_input_files = ();
115 # Line number at which AC_OUTPUT seen.
118 # List of directories to search for configure-required files. This
119 # can be set by AC_CONFIG_AUX_DIR.
120 @config_aux_path = ('.', '..', '../..');
121 $config_aux_dir = '';
123 # Whether AC_PROG_MAKE_SET has been seen in configure.in.
126 # Whether ud_GNU_GETTEXT has been seen in configure.in.
128 # Line number at which ud_GNU_GETTEXT seen.
129 $ac_gettext_line = 0;
131 # Whether ALL_LINGUAS has been seen.
135 # Line number at which it appears.
136 $all_linguas_line = 0;
138 # 1 if AC_PROG_INSTALL seen, 2 if AM_PROG_INSTALL seen.
139 $seen_prog_install = 0;
141 # 1 if any scripts installed, 0 otherwise.
142 $scripts_installed = 0;
144 # Whether AC_PATH_XTRA has been seen in configure.in.
147 # Whether YACC variable has been seen in configure.in.
150 # Two variables to control lex use. One is for AC_DECL_YYTEXT and the
151 # other is for AC_PROG_LEX.
152 $seen_decl_yytext = 0;
155 # TRUE if we've seen AC_PROG_CC.
158 # TRUE if we've seen AC_PROG_CXX.
161 # TRUE if we've seen AC_CANONICAL_(HOST|SYSTEM). The presence of
162 # AC_CHECK_TOOL also sets this.
165 # TRUE if we've seen AC_PROG_RANLIB.
168 # TRUE if we've seen AC_ARG_PROGRAM.
171 # TRUE if we've seen AM_PROG_LIBTOOL.
175 # TRUE if we've seen AM_MAINTAINER_MODE.
176 $seen_maint_mode = 0;
178 # TRUE if we've seen PACKAGE and VERSION.
182 # Actual version we've seen.
183 $package_version = '';
185 # Line number where we saw version definition.
186 $package_version_line = 0;
188 # TRUE if we've seen AM_PATH_LISPDIR.
192 # Charsets used by maintainer and in distribution. MAINT_CHARSET is
193 # handled in a funny way: if seen in the top-level Makefile.am, it is
194 # used for every directory which does not specify a different value.
195 # The rationale here is that some directories (eg gettext) might be
196 # distributions of other packages, and thus require their own charset
197 # info. However, the DIST_CHARSET must be the same for the entire
198 # package; it can only be set at top-level.
199 # FIXME: this yields bugs when rebuilding. What to do? Always
200 # read (and sometimes discard) top-level Makefile.am?
202 $dist_charset = 'utf8'; # recode doesn't support this yet.
204 # Name of input file ("Makefile.in") and output file ("Makefile.am").
205 # These have no directory components.
211 &initialize_global_constants;
213 # Parse command line.
214 &parse_arguments (@ARGV);
216 # Do configure.in scan only once.
219 die "automake: no \`Makefile.am' found or specified\n"
222 # Now do all the work on each file.
223 foreach $am_file (@input_files)
225 # FIXME: should support the AC_OUTPUT ":" syntax here.
226 if (! -f ($am_file . '.am'))
228 &am_error ('no such file');
232 &generate_makefile ($am_file);
236 if ($seen_prog_install <= $scripts_installed)
238 &am_conf_error (($scripts_installed ? 'AM_PROG_INSTALL' : 'AC_PROG_INSTALL')
239 . " must be used in configure.in");
240 &keyed_aclocal_warning ('AM_PROG_INSTALL')
241 if $scripts_installed;
247 ################################################################
249 # Parse command line.
252 local (@arglist) = @_;
255 &set_strictness ('gnu');
259 if ($arglist[0] eq "--version")
261 print "automake - GNU $PACKAGE $VERSION\n";
264 elsif ($arglist[0] eq "--help")
268 elsif ($arglist[0] =~ /^--amdir=(.+)$/)
272 elsif ($arglist[0] eq '--amdir')
274 &require_argument (@arglist);
276 $am_dir = $arglist[0];
278 elsif ($arglist[0] =~ /^--build-dir=(.+)$/)
281 $build_directory = $1 . '/';
283 elsif ($arglist[0] eq '--build-dir')
285 &require_argument (@arglist);
288 $build_directory = $arglist[0] . '/';
290 elsif ($arglist[0] =~ /^--srcdir-name=(.+)$/)
294 elsif ($arglist[0] eq '--srcdir-name')
296 &require_argument (@arglist);
298 $srcdir_name = $arglist[0];
300 elsif ($arglist[0] =~ /^--strictness=(.+)$/)
302 &set_strictness ($1);
304 elsif ($arglist[0] eq '--gnu')
306 &set_strictness ('gnu');
308 elsif ($arglist[0] eq '--gnits')
310 &set_strictness ('gnits');
312 elsif ($arglist[0] eq '--foreign')
314 &set_strictness ('foreign');
316 elsif ($arglist[0] eq '--strictness' || $arglist[0] eq '-s')
318 &require_argument (@arglist);
320 &set_strictness ($arglist[0]);
322 elsif ($arglist[0] eq '--include-deps' || $arglist[0] eq '-i')
324 $cmdline_use_dependencies = 0;
326 elsif ($arglist[0] eq '--no-force')
328 $force_generation = 0;
330 elsif ($arglist[0] =~ /^--output-dir=(.*)$/)
332 # Set output directory.
333 $output_directory = $1;
335 elsif ($arglist[0] eq '--output-dir' || $arglist[0] eq '-o')
337 &require_argument (@arglist);
339 $output_directory = $arglist[0];
341 elsif ($arglist[0] eq '--add-missing' || $arglist[0] eq '-a')
345 elsif ($arglist[0] eq '--verbose' || $arglist[0] eq '-v')
349 elsif ($arglist[0] eq '--')
351 # Stop option processing.
353 push (@input_files, @arglist);
356 elsif ($arglist[0] =~ /^-/)
358 die "automake: unrecognized option -- \`$arglist[0]'\n";
362 push (@input_files, $arglist[0]);
368 # Take global strictness from whatever we currently have set.
369 $default_strictness = $strictness;
370 $default_strictness_name = $strictness_name;
373 # Ensure argument exists, or die.
376 local ($arg, @arglist) = @_;
377 die "automake: no argument given for option \`$arg'\n"
381 ################################################################
383 # Generate a Makefile.in given the name of the corresponding Makefile.
384 sub generate_makefile
386 local ($makefile) = @_;
388 ($am_file_name = $makefile) =~ s/^.*\///;
389 $in_file_name = $am_file_name . '.in';
390 $am_file_name .= '.am';
392 &initialize_per_input;
393 $relative_dir = &dirname ($makefile);
395 # At the toplevel directory, we might need config.guess, config.sub
397 if ($relative_dir eq '.')
399 # libtool requires some files.
400 &require_conf_file_with_conf_line ($libtool_line, $FOREIGN,
401 'config.sub', 'config.guess',
402 'libtool') if $seen_libtool;
404 # AC_CANONICAL_HOST and AC_CANONICAL_SYSTEM need config.guess and
406 &require_config_file ($FOREIGN, 'config.guess', 'config.sub')
410 # We still need Makefile.in here, because sometimes the `dist'
411 # target doesn't re-run automake.
412 &push_dist_common ($in_file_name, $am_file_name);
413 push (@sources, '$(SOURCES)')
414 if &variable_defined ('SOURCES');
415 push (@objects, '$(OBJECTS)')
416 if &variable_defined ('OBJECTS');
418 # This is always the default target. This gives us freedom to do
419 # things in whatever order is convenient.
420 $output_rules .= "default: all\n\n";
421 push (@phony, 'default');
423 &read_am_file ($makefile . '.am');
426 # Check first, because we might modify some state.
427 &check_gnu_standards;
428 &check_gnits_standards;
436 # This must be run after all the sources are scanned.
437 &handle_yacc_lex_cxx;
439 # Re-init SOURCES and OBJECTS. FIXME: other code shouldn't depend
440 # on this (but currently does).
441 $contents{'SOURCES'} = join (' ', @sources);
442 $contents{'OBJECTS'} = join (' ', @objects);
452 &handle_dependencies;
455 &handle_merge_targets;
460 if (! -d ($output_directory . '/' . $relative_dir))
462 mkdir ($output_directory . '/' . $relative_dir, 0755);
465 local ($out_file) = $output_directory . '/' . $makefile . ".in";
466 if (! $force_generation && -e $out_file)
468 local ($am_time) = (stat ($makefile . '.am'))[9];
469 local ($in_time) = (stat ($out_file))[9];
470 # FIXME: how to do unsigned comparison?
471 if ($am_time < $in_time)
478 if (! open (GM_FILE, "> " . $out_file))
480 warn "automake: ${am_file}.in: cannot open: $!\n";
484 print "automake: creating ", $makefile, ".in\n" if $verbose;
486 print GM_FILE $output_vars;
487 print GM_FILE $output_rules;
488 print GM_FILE $output_trailer;
493 ################################################################
495 # Handle AUTOMAKE_OPTIONS variable.
498 return if ! &variable_defined ('AUTOMAKE_OPTIONS');
500 foreach (&variable_value_as_list ('AUTOMAKE_OPTIONS'))
505 if ($_ eq 'gnits' || $_ eq 'gnu' || $_ eq 'foreign')
507 &set_strictness ($_);
511 # An option like "../lib/ansi2knr" is allowed. With no
512 # path prefix, we assume the required programs are in this
513 # directory. We save the actual option for later.
514 $options{'ansi2knr'} = $_;
516 elsif ($_ eq 'no-installman' || $_ eq 'no-installinfo'
517 || $_ eq 'dist-shar' || $_ eq 'dist-zip'
518 || $_ eq 'dist-tarZ' || $_ eq 'dejagnu')
520 # Explicitly recognize these.
522 elsif ($_ eq 'no-dependencies')
524 $use_dependencies = 0;
526 elsif (/[0-9]+\.?[0-9]+/)
528 # Got a version number. Is the syntax too strict?
529 local ($num_version);
530 ($num_version = $VERSION) =~ tr/0-9//cd;
531 if ($num_version < $_)
533 &am_line_error ('AUTOMAKE_OPTIONS',
534 "require version $_, only have $VERSION");
540 &am_line_error ('AUTOMAKE_OPTIONS',
541 'option ', $_, 'not recognized');
546 # Return object extension. Just once, put some code into the output.
547 sub get_object_extension
549 if (! $dir_holds_sources)
553 if (&variable_defined ('CONFIG_HEADER'))
555 ($xform = &dirname ($contents{'CONFIG_HEADER'}))
557 $xform = '-I' . $xform;
559 $xform = 's/\@CONFIG_INCLUDE_SPEC\@/' . $xform . '/go';
560 $output_vars .= &file_contents_with_transform ($xform,
562 $output_rules .= &file_contents ('compile');
563 &push_phony_cleaners ('compile');
565 # If using X, include some extra variable definitions. NOTE
566 # we don't want to force these into CFLAGS or anything,
567 # because not all programs will necessarily use X.
570 $output_vars .= ("X_CFLAGS = \@X_CFLAGS\@\n"
571 . "X_LIBS = \@X_LIBS\@\n"
572 . "X_EXTRA_LIBS = \@X_EXTRA_LIBS\@\n"
573 . "X_PRE_LIBS = \@X_PRE_LIBS\@\n");
576 # Check for automatic de-ANSI-fication.
577 $dir_holds_sources = '.o';
578 push (@suffixes, '.c', '.o');
579 push (@clean, 'compile');
581 if (defined $options{'ansi2knr'})
583 if (! $am_c_prototypes)
585 &am_line_error ('AUTOMAKE_OPTIONS',
586 "option \`ansi2knr' in use but \`AM_C_PROTOTYPES' not in configure.in");
587 &keyed_aclocal_warning ('AM_C_PROTOTYPES');
588 # Only give this error once.
589 $am_c_prototypes = 1;
592 $dir_holds_sources = '$o';
593 push (@suffixes, '._c', '._o');
595 # Only require ansi2knr files if they should appear in
597 if ($options{'ansi2knr'} eq 'ansi2knr')
599 &require_file_with_line ('AUTOMAKE_OPTIONS', $FOREIGN,
600 'ansi2knr.c', 'ansi2knr.1');
601 $output_rules .= &file_contents ('kr-extra');
602 push (@clean, 'krextra');
603 &push_phony_cleaners ('krextra');
606 $output_vars .= "o = .\@U\@o\n";
608 # Make sure ansi2knr can be found: if no path specified,
610 local ($apath) = $options{'ansi2knr'};
611 $apath = './' . $apath
612 unless $apath =~ /\//;
613 $output_vars .= "ANSI2KNR = " . $apath . "\n";
615 $output_rules .= &file_contents ('compile-kr');
616 $output_rules .= &file_contents ('clean-kr');
619 &push_phony_cleaners ('kr');
622 return $dir_holds_sources;
625 # Handle yacc and lex.
626 sub handle_yacc_lex_cxx
629 # First do yacc and lex.
632 local ($yacc_count) = scalar (keys %yacc_sources);
633 local ($lex_count) = scalar (keys %lex_sources);
636 push (@suffixes, '.y');
637 $output_vars .= "YACC = \@YACC\@\n";
638 $output_rules .= ".y.c:\n\t";
641 $output_rules .= '$(INTERLOCK) =yacclockdir $(YLWRAP) y.tab.c $@ $(YACC) $(YFLAGS) $<';
645 $output_rules .= '$(YACC) $(YFLAGS) $< && mv y.tab.c $@';
647 $output_rules .= "\n";
649 if (! $seen_prog_yacc)
651 # FIXME: should include a reference line. FIXME: maybe
652 # directly reference AC_PROG_YACC somehow?
653 &am_error ("yacc source seen but \`YACC' not defined in \`configure.in'\n");
658 push (@suffixes, '.l');
659 $output_vars .= ("LEX = \@LEX\@\n"
660 . "LEX_OUTPUT_ROOT = \@LEX_OUTPUT_ROOT\@\n");
661 $output_rules .= ".l.c:\n\t";
664 $output_rules .= '$(INTERLOCK) =lexlockdir $(YLWRAP) $(LEX_OUTPUT_ROOT).c $@ $(LEX) $(LFLAGS) $<';
668 $output_rules .= '$(LEX) $(LFLAGS) $< && mv $(LEX_OUTPUT_ROOT).c $@';
670 $output_rules .= "\n";
672 if (! $seen_prog_lex)
674 &am_error ("lex source seen but \`AC_PROG_LEX' not in \`configure.in'\n");
676 if (! $seen_decl_yytext)
678 &am_error ("lex source seen but \`AC_DECL_YYTEXT' not in \`configure.in'\n");
682 if ($yacc_count > 1 || $lex_count > 1)
684 # If there is more than one distinct yacc (resp lex) source
685 # file in a given directory, then the `interlock' program is
686 # required to allow parallel builds to work correctly. FIXME:
687 # for now, no line number.
688 &require_config_file ($FOREIGN, 'interlock', 'ylwrap');
689 $output_vars .= ('INTERLOCK = ' . $config_aux_dir . "/interlock\n"
690 . 'YLWRAP = ' . $config_aux_dir . "/ylwrap\n");
696 local (@cxx_list) = keys %cxx_extensions;
697 local ($cxx_count) = scalar @cxx_list;
700 push (@suffixes, @cxx_list);
702 $output_vars .= ("CXX = \@CXX\@\n"
703 . "CXXFLAGS = \@CXXFLAGS\@\n"
704 . 'CXXCOMPILE = $(CXX) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CXXFLAGS)'
706 . 'CXXLINK = $(CXX) $(LDFLAGS) -o $@'
710 foreach $ext (@cxx_list)
712 $output_rules .= ("$ext.o:\n"
713 . "\t\$(CXXCOMPILE) -c \$<\n");
716 if (! $seen_prog_cxx)
718 &am_error ("C++ source seen but \`AC_PROG_CXX' not in \`configure.in'\n");
723 # Last, handle some C cleanup.
727 $output_vars .= ("CC = \@CC\@\n"
728 . "CFLAGS = \@CFLAGS\@\n"
729 . 'COMPILE = $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)'
731 . 'LINK = $(CC) $(LDFLAGS) -o $@'
736 # Handle SOURCE->OBJECT transform for one program or library.
738 # canonical (transformed) name of object to build
739 # actual name of object to build
740 # object extension (ie either `.o' or `$o'.
741 # Return result is name of linker variable that must be used.
742 # Empty return means just use `LINK'.
743 sub handle_source_transform
745 # one_file is canonical name. unxformed is given name. obj is
747 local ($one_file, $unxformed, $obj) = @_;
748 local ($objpat) = $obj;
749 $objpat =~ s/(\W)/\\$1/g;
751 local ($linker) = '';
753 if (&variable_defined ($one_file . "_OBJECTS"))
755 &am_line_error ($one_file . '_OBJECTS',
756 $one_file . '_OBJECTS', 'should not be defined');
757 # No point in continuing.
763 foreach $prefix ('', 'EXTRA_')
766 if (&variable_defined ($prefix . $one_file . "_SOURCES"))
768 push (@sources, '$(' . $prefix . $one_file . "_SOURCES)");
769 push (@objects, '$(' . $prefix . $one_file . "_OBJECTS)")
770 unless $prefix eq 'EXTRA_';
771 @files = &variable_value_as_list ($prefix
772 . $one_file . "_SOURCES");
774 elsif ($prefix eq '')
776 $output_vars .= $one_file . "_SOURCES = " . $unxformed . ".c\n";
777 push (@sources, $unxformed . '.c');
778 push (@objects, $unxformed . $obj);
779 push (@files, $unxformed . ".c ");
783 $output_vars .= "EXTRA_" . $one_file . "_SOURCES =\n";
788 # Turn sources into objects.
789 local (@result) = ();
792 # Skip header files, including C++-ish ones. The list
793 # of C++ header extensions comes from Emacs 19.32
800 # Skip things that look like configure substitutions.
803 # Include .c file for lex or yacc source in distribution.
807 &push_dist_common ($1 . '.c');
808 $yacc_sources{$_} = 1;
813 &push_dist_common ($1 . '.c');
814 $lex_sources{$_} = 1;
817 # Transform source files into .o files. List of C++
818 # extensions comes from Emacs 19.32 etags.
819 if (s/\.c\+\+$/$obj/g
825 $cxx_extensions{$&} = 1;
830 # FORTRAN support. FIXME: not finished.
834 # .y is yacc. .l is lex. .f and .F is fortran.
835 # .s is assembly. .M is Objective-C++. .m is
837 s/\.[cylfFsmM]$/$obj/g;
839 # FIXME: of course, this should only happen for C
840 # source. The multi-language support must really
841 # be cleaned up more globally.
846 unless $prefix eq 'EXTRA_';
848 # Transform .o or $o file into .P file (for automatic
851 $dep_files{'.deps/' . $_} = 1;
854 &pretty_print ($one_file . "_OBJECTS =", "", @result)
855 unless $prefix eq 'EXTRA_';
859 if (&variable_defined ('CONFIG_HEADER'))
861 $output_rules .= ('$(' . $one_file . "_OBJECTS): "
862 . $contents{'CONFIG_HEADER'} . "\n");
868 # Special-case @ALLOCA@ and @LIBOBJS@ in _LDADD or _LIBADD variables.
869 # Also, generate _DEPENDENCIES variable if appropriate.
871 # transformed name of object being built, or empty string if no object
872 # name of _LDADD/_LIBADD-type variable to examine
873 sub handle_lib_objects
875 local ($xname, $var) = @_;
877 die "programming error in handle_lib_objects"
878 if ! &variable_defined ($var);
880 # We recognize certain things that are commonly put in LIBADD or
883 local (@dep_list) = ();
885 foreach $lsearch (&variable_value_as_list ($var))
887 # Skip -lfoo and -Ldir.
888 next if $lsearch =~ /^-[lL]/;
890 # Assume we have a file of some sort, and push it onto the
891 # dependency list. This isn't perfect, but hopefully people
892 # will point out the exceptions I'm obviously too lazy to
894 push (@dep_list, $lsearch);
896 # Automatically handle @LIBOBJS@ and @ALLOCA@. Basically this
897 # means adding entries to dep_files.
898 if ($lsearch eq '@LIBOBJS@')
900 if (! keys %libsources)
902 &am_line_error ($var, "\@LIBOBJS\@ seen but never set in \`configure.in'");
905 local ($iter, $rewrite);
906 foreach $iter (keys %libsources)
910 &require_file_with_line ($var, $FOREIGN, $iter);
912 elsif ($iter ne 'alloca.c')
914 ($rewrite = $iter) =~ s/\.c$/.P/;
915 $dep_files{'.deps/' . $rewrite} = 1;
916 &require_file_with_line ($var, $FOREIGN, $iter);
920 elsif ($lsearch eq '@ALLOCA@')
922 &am_line_error ($var,
923 "\@ALLOCA\@ seen but \`AC_FUNC_ALLOCA' not in \`configure.in'")
924 if ! defined $libsources{'alloca.c'};
925 $dep_files{'.deps/alloca.P'} = 1;
926 &require_file_with_line ($var, $FOREIGN, 'alloca.c');
930 if ($xname ne '' && ! &variable_defined ($xname . '_DEPENDENCIES'))
932 &pretty_print ($xname . '_DEPENDENCIES = ', '', @dep_list);
939 local (@proglist) = &am_install_var ('-clean',
940 'programs', 'PROGRAMS',
941 'bin', 'sbin', 'libexec', 'pkglib',
943 return if ! @proglist;
945 # If a program is installed, this is required. We only want this
946 # error to appear once.
947 &am_conf_error ("AC_ARG_PROGRAM must be used in configure.in")
948 unless $seen_arg_prog;
951 local ($obj) = &get_object_extension;
952 local ($one_file, $xname, $munge);
954 foreach $one_file (@proglist)
956 # Canonicalize names.
957 ($xname = $one_file) =~ tr/A-Za-z0-9_/_/c;
958 if ($xname ne $one_file)
961 foreach $xt ('_LDADD', '_SOURCES', '_OBJECTS', '_DEPENDENCIES')
963 &am_line_error ($one_file . $xt,
964 "invalid variable \`" . $one_file . $xt
965 . "'; should be \`" . $xname . $xt . "'")
966 if &variable_defined ($one_file . $xt);
970 local ($linker) = &handle_source_transform ($xname, $one_file, $obj);
972 if (&variable_defined ($xname . "_LDADD"))
974 &handle_lib_objects ($xname, $xname . '_LDADD');
978 # User didn't define prog_LDADD override. So do it.
979 $output_vars .= $xname . '_LDADD = $(LDADD)' . "\n";
981 # This does a bit too much work. But we need it to
982 # generate _DEPENDENCIES when appropriate.
983 &handle_lib_objects ($xname, 'LDADD')
984 if (&variable_defined ('LDADD'));
987 # Determine program to use for link.
989 if (&variable_defined ($xname . '_LINK'))
991 $xlink = $xname . '_LINK';
995 $xlink = $linker ? $linker : 'LINK';
999 &file_contents_with_transform
1000 ('s/\@PROGRAM\@/' . $one_file . '/go;'
1001 . 's/\@XPROGRAM\@/' . $xname . '/go;'
1002 . 's/\@XLINK\@/' . $xlink . '/go;',
1006 &handle_lib_objects ('', 'LDADD')
1007 if &variable_defined ('LDADD');
1011 sub handle_libraries
1013 local (@liblist) = &am_install_var ('-no-all', '-clean',
1014 'libraries', 'LIBRARIES',
1015 'lib', 'pkglib', 'noinst', 'check');
1016 return if ! @liblist;
1018 local (%valid) = &am_primary_prefixes ('LIBRARIES', 'lib', 'pkglib',
1023 foreach $key (keys %valid)
1025 if (&variable_defined ($key . '_LIBRARIES'))
1027 &am_line_error ($key . '_LIBRARIES', "library requires either \`AC_PROG_RANLIB' or `AM_PROG_LIBTOOL' in configure.in");
1028 # Only get this error once.
1035 # Generate _LIBFILES variables. Too bad we can't do this in
1037 local ($onedir, $onelib);
1039 local (@libfiles_list);
1040 foreach $onedir (keys %valid)
1042 if (&variable_defined ($onedir . '_LIBRARIES'))
1045 foreach $onelib (&variable_value_as_list ($onedir . '_LIBRARIES'))
1047 push (@outlist, 'lib' . $onelib . '.a');
1049 &pretty_print ($onedir . '_LIBFILES =', "", @outlist);
1052 push (@libfiles_list, '$(' . $onedir . '_LIBFILES)')
1053 unless $onedir eq 'EXTRA';
1055 push (@all, '$(LIBFILES)');
1057 local ($obj) = &get_object_extension;
1060 foreach $onelib (@liblist)
1062 # Canonicalize names.
1063 ($xlib = $onelib) =~ tr/A-Za-z0-9_/_/c;
1064 if ($xlib ne $onelib)
1067 foreach $xt ('_LIBADD', '_SOURCES', '_OBJECTS', '_DEPENDENCIES')
1069 &am_line_error ($one_file . $xt,
1070 "invalid variable \`" . $onelib . $xt
1071 . "'; should be \`" . $xlib . $xt . "'")
1072 if &variable_defined ($onelib . $xt);
1076 if (&variable_defined ($xlib . '_LIBADD'))
1078 &handle_lib_objects ($xlib, $xlib . '_LIBADD');
1082 # Generate support for conditional object inclusion in
1084 $output_vars .= $xlib . "_LIBADD =\n";
1087 &handle_source_transform ($xlib, $onelib, $obj);
1090 &file_contents_with_transform ('s/\@LIBRARY\@/' . $onelib . '/go;'
1096 # Turn "foo" into "libfoo.a" and include macro definition.
1097 grep (($_ = 'lib' . $_ . '.a') && 0, @liblist);
1099 if (! &variable_defined ('LIBFILES'))
1101 &pretty_print ('LIBFILES = ', "", @libfiles_list);
1106 $output_vars .= ('AR = $(LIBTOOL) archive' . "\n"
1107 . 'RANLIB = $(LIBTOOL) ranlib' . "\n"
1108 . 'LCOMPILE = $(LIBTOOL) compile $(DEFS) $(INCLUDES)'
1109 . ' $(CPPFLAGS) $(CFLAGS)' . "\n");
1113 $output_vars .= ('AR = ar' . "\n"
1114 . 'RANLIB = @RANLIB@' . "\n");
1121 # NOTE we no longer automatically clean SCRIPTS, because it is
1122 # useful to sometimes distribute scripts verbatim. This happens
1123 # eg in Automake itself.
1124 &am_install_var ('scripts', 'SCRIPTS',
1125 'bin', 'sbin', 'libexec', 'pkgdata',
1128 # Set $scripts_installed if appropriate. Make sure we only find
1129 # scripts which are actually installed -- this is why we can't
1130 # simply use the return value of am_install_var.
1131 local (%valid) = &am_primary_prefixes ('SCRIPTS', 'bin', 'sbin',
1132 'libexec', 'pkgdata',
1135 foreach $key (keys %valid)
1137 if ($key ne 'noinst'
1139 && &variable_defined ($key . '_SCRIPTS'))
1141 $scripts_installed = 1;
1146 if ($scripts_installed)
1148 # If a program is installed, this is required. We only want this
1149 # error to appear once.
1150 &am_conf_error ("AC_ARG_PROGRAM must be used in configure.in")
1151 unless $seen_arg_prog;
1156 # Search a file for a "version.texi" Texinfo include. Return the name
1157 # of the include file if found, or the empty string if not. A
1158 # "version.texi" file is actually any file whose name matches
1160 sub grep_for_vers_texi
1162 local ($filename) = @_;
1164 if (! open (TEXI, $filename))
1166 &am_error ("couldn't open \`$filename': $!");
1169 print "automake: reading $filename\n" if $verbose;
1173 if (/^\@include\s+(vers[^.]*\.texi)\s*$/)
1185 # Handle all Texinfo source.
1188 &am_line_error ('TEXINFOS',
1189 "\`TEXINFOS' is an anachronism; use \`info_TEXINFOS'")
1190 if &variable_defined ('TEXINFOS');
1191 return if (! &variable_defined ('info_TEXINFOS')
1192 && ! &variable_defined ('html_TEXINFOS'));
1194 local (@texis) = &variable_value_as_list ('info_TEXINFOS');
1196 local (@infos_list, @info_deps_list, @dvis_list, @texi_deps);
1197 local ($infobase, $info_cursor);
1201 local ($tc_cursor, @texi_cleans);
1204 foreach $info_cursor (@texis)
1206 ($infobase = $info_cursor) =~ s/\.texi(nfo)?$//;
1208 # If 'version.texi' is referenced by input file, then include
1209 # automatic versioning capability.
1211 = &grep_for_vers_texi ($relative_dir . "/" . $info_cursor);
1214 &am_error ("\`$vtexi', included in \`$info_cursor', also included in \`$versions{$vtexi}'")
1215 if (defined $versions{$vtexi});
1216 $versions{$vtexi} = $info_cursor;
1218 # We number the stamp-vti files. This is doable since the
1219 # actual names don't matter much. We only number starting
1220 # with the second one, so that the common case looks nice.
1221 $vti = 'vti' . ($done ? $done : '');
1222 &push_dist_common ($vtexi, 'stamp-' . $vti);
1223 push (@clean, $vti);
1225 # Only require once.
1226 &require_conf_file_with_line ('info_TEXINFOS', $FOREIGN,
1232 ($conf_pat = $config_aux_dir) =~ s/(\W)/\\$1/g;
1234 &file_contents_with_transform
1235 ('s/\@TEXI\@/' . $info_cursor . '/g; '
1236 . 's/\@VTI\@/' . $vti . '/g; '
1237 . 's/\@VTEXI\@/' . $vtexi . '/g;'
1238 . 's,\@MDDIR\@,' . $conf_pat . ',g;',
1241 &push_phony_cleaners ($vti);
1244 # If user specified file_TEXINFOS, then use that as explicit
1247 push (@texi_deps, $info_cursor);
1248 push (@texi_deps, $vtexi) if $vtexi;
1250 # Canonicalize name first.
1251 ($canonical = $infobase) =~ tr/A-Za-z0-9_/_/c;
1252 if (&variable_defined ($canonical . "_TEXINFOS"))
1254 push (@texi_deps, '$(' . $canonical . '_TEXINFOS)');
1255 &push_dist_common ('$(' . $canonical . '_TEXINFOS)');
1258 $output_rules .= ("\n" . $infobase . ".info: "
1259 . join (' ', @texi_deps)
1260 . "\n" . $infobase . ".dvi: "
1261 . join (' ', @texi_deps)
1264 push (@infos_list, $infobase . '.info[-0-9]*');
1265 push (@info_deps_list, $infobase . '.info');
1266 push (@dvis_list, $infobase . '.dvi');
1268 # Generate list of things to clean for this target. We do
1269 # this explicitly because otherwise too many things could be
1270 # removed. In particular the ".log" extension might
1271 # reasonably be used in other contexts by the user.
1272 foreach $tc_cursor ('aux', 'cp', 'cps', 'dvi', 'fn', 'fns',
1273 'ky', 'log', 'pg', 'toc', 'tp', 'vr', 'op')
1275 push (@texi_cleans, $infobase . '.' . $tc_cursor);
1280 $output_vars .= &file_contents ('texinfos-vars');
1281 $output_rules .= &file_contents ('texinfos');
1282 push (@phony, 'install-info', 'uninstall-info');
1285 $output_rules .= "\nmostlyclean-info:\n";
1286 &pretty_print_rule ("\trm -f", "\t ", @texi_cleans);
1287 $output_rules .= ("\nclean-info:\n\ndistclean-info:\n\n"
1288 . "maintainer-clean-info:\n\t"
1289 . 'rm -f $(INFOS)' . "\n");
1290 &push_phony_cleaners ('info');
1292 push (@suffixes, '.texi', '.texinfo', '.info', '.dvi');
1294 if (! defined $options{'no-installinfo'})
1296 push (@uninstall, 'uninstall-info');
1297 push (@installdirs, '$(infodir)');
1298 unshift (@install_data, 'install-info');
1300 # Make sure documentation is made and installed first. Use
1301 # $(INFO_DEPS), not 'info', because otherwise recursive makes
1302 # get run twice during "make all".
1303 unshift (@all, '$(INFO_DEPS)');
1305 push (@clean, 'info');
1306 push (@info, '$(INFO_DEPS)');
1307 push (@dvi, '$(DVIS)');
1309 $output_vars .= ("INFOS = " . join (' ', @infos_list) . "\n"
1310 . "INFO_DEPS = " . join (' ', @info_deps_list) . "\n"
1311 . "DVIS = " . join (' ', @dvis_list) . "\n"
1312 # This next isn't strictly needed now -- the
1313 # places that look here could easily be changed
1314 # to look in info_TEXINFOS. But this is probably
1315 # better, in case noinst_TEXINFOS is ever
1317 . "TEXINFOS = " . $contents{'info_TEXINFOS'} . "\n\n");
1319 # Do some error checking.
1320 &require_file_with_line ('info_TEXINFOS', $FOREIGN, 'texinfo.tex');
1323 # Handle any man pages.
1324 sub handle_man_pages
1326 &am_line_error ('MANS', "\`MANS' is an anachronism; use \`man_MANS'")
1327 if &variable_defined ('MANS');
1328 return if ! &variable_defined ('man_MANS');
1330 # We generate the manpage install code by hand to avoid the use of
1331 # basename in the generated Makefile.
1332 local (@mans) = &variable_value_as_list ('man_MANS');
1333 local (%sections, %inames, %mbases, %secmap, %fullsecmap);
1337 # FIXME: statement without effect:
1338 /^(.*)\.([0-9])([a-z]*)$/;
1343 $fullsecmap{$i} = $2 . $3;
1347 # We don't really need this, but we use it in case we ever want to
1348 # support noinst_MANS.
1349 $output_vars .= "MANS = " . $contents{'man_MANS'} . "\n";
1351 # Generate list of install dirs.
1352 $output_rules .= "install-man: \$(MANS)\n";
1353 $output_rules .= "\t\$(NORMAL_INSTALL)\n";
1354 foreach (keys %sections)
1356 push (@installdirs, '$(mandir)/man' . $_)
1357 unless defined $options{'no-installman'};
1358 $output_rules .= ("\t" . '$(mkinstalldirs) $(mandir)/man'
1361 push (@phony, 'install-man');
1363 # Generate install target.
1365 foreach $key (keys %inames)
1367 $_ = $install_man_format;
1368 s/\@SECTION\@/$secmap{$key}/g;
1369 s/\@MAN\@/$inames{$key}/g;
1370 s/\@FULLSECT\@/$fullsecmap{$key}/g;
1371 s/\@MANBASE\@/$mbases{$key}/g;
1372 $output_rules .= $_;
1374 $output_rules .= "\n";
1376 $output_rules .= "uninstall-man:\n";
1377 foreach $key (keys %inames)
1379 $_ = $uninstall_man_format;
1380 s/\@SECTION\@/$secmap{$key}/g;
1381 s/\@MAN\@/$inames{$key}/g;
1382 s/\@FULLSECT\@/$fullsecmap{$key}/g;
1383 s/\@MANBASE\@/$mbases{$key}/g;
1384 $output_rules .= $_;
1386 $output_rules .= "\n";
1387 push (@phony, 'uninstall-man');
1389 $output_vars .= &file_contents ('mans-vars');
1391 if (! defined $options{'no-installman'})
1393 push (@install_data, 'install-man');
1394 push (@uninstall, 'uninstall-man');
1395 push (@all, '$(MANS)');
1399 # Handle DATA variables.
1402 &am_install_var ('data', 'DATA', 'data', 'sysconf',
1403 'sharedstate', 'localstate', 'pkgdata',
1410 local ($tagging) = 0;
1412 push (@phony, 'tags');
1413 if (&variable_defined ('SUBDIRS'))
1415 $output_rules .= &file_contents ('tags');
1416 push (@phony, 'tags-recursive');
1419 elsif ($dir_holds_sources
1420 || $dir_holds_headers
1421 || &variable_defined ('ETAGS_ARGS'))
1423 $output_rules .= &file_contents ('tags-subd');
1429 $output_rules .= &file_contents ('tags-clean');
1430 push (@clean, 'tags');
1431 &push_phony_cleaners ('tags');
1435 # Every Makefile must define some sort of TAGS rule.
1436 # Otherwise, it would be possible for a top-level "make TAGS"
1437 # to fail because some subdirectory failed.
1438 $output_rules .= "tags: TAGS\nTAGS:\n\n";
1442 # Worker for handle_dist.
1443 sub handle_dist_worker
1445 $output_rules .= 'distdir: $(DEP_DISTFILES)' . "\n";
1447 # Initialization; only at top level.
1448 if ($relative_dir eq '.')
1450 if ($strictness >= $GNITS)
1452 # For Gnits users, this is pretty handy. Look at 15 lines
1453 # in case some explanatory text is desirable.
1454 $output_rules .= ' @if sed 15q $(srcdir)/NEWS | fgrep -e "$(VERSION)" > /dev/null; then :; else \\
1455 echo "NEWS not updated; not releasing" 1>&2; \\
1463 # Create dist directory.
1466 -chmod 755 $(distdir)
1469 # Only run automake in `dist' target if --include-deps not
1470 # specified. That way the recipient of a distribution can run
1471 # "make dist" and not need Automake.
1472 if ($cmdline_use_dependencies)
1476 # We need an absolute path for --output-dir. Thus the
1478 ' here=`pwd`; distdir=`cd $(distdir) && pwd` \\
1480 && automake --include-deps --build-dir=$$here --srcdir-name=$(srcdir) --output-dir=$$distdir --strictness='
1481 # Set strictness of output.
1482 . $strictness_name . "\n"
1487 # In loop, test for file existence because sometimes a file gets
1488 # included in DISTFILES twice. For example this happens when a
1489 # single source file is used in building more than one program.
1490 # Also, there are situations in which "ln" can fail. For instance
1491 # a file to distribute could actually be a cross-filesystem
1492 # symlink -- this can easily happen if "gettextize" was run on the
1493 # distribution. Note that DISTFILES can contain a wildcard (for
1494 # info files, sigh), so we must use the echo trick.
1495 $output_rules .= ' @for file in `cd $(srcdir) && echo $(DISTFILES)`; do \\
1496 test -f $(distdir)/$$file \\
1497 || ln $(srcdir)/$$file $(distdir)/$$file 2> /dev/null \\
1498 || cp -p $(srcdir)/$$file $(distdir)/$$file; \\
1502 # If we have SUBDIRS, create all dist subdirectories and do
1504 if (&variable_defined ('SUBDIRS'))
1506 # Test for directory existence here because previous automake
1507 # invocation might have created some directories. Note that
1508 # we explicitly set distdir for the subdir make; that lets us
1509 # mix-n-match many automake-using packages into one large
1510 # package, and have "dist" at the top level do the right
1512 $output_rules .= ' for subdir in $(SUBDIRS); do \\
1513 test -d $(distdir)/$$subdir \\
1514 || mkdir $(distdir)/$$subdir \\
1516 chmod 755 $(distdir)/$$subdir; \\
1517 (cd $$subdir && $(MAKE) distdir=../$(distdir)/$$subdir distdir) \\
1523 # If the target `dist-hook' exists, run it now. This allows
1524 # users to do random weird things to the distribution before it is
1526 if (defined $contents{'dist-hook'})
1528 $output_rules .= "\t\$(MAKE) dist-hook\n";
1531 push (@phony, 'distdir');
1534 # Handle 'dist' target.
1537 # Set up maint_charset.
1538 $local_maint_charset = $contents{'MAINT_CHARSET'}
1539 if &variable_defined ('MAINT_CHARSET');
1540 $maint_charset = $local_maint_charset
1541 if $relative_dir eq '.';
1543 if (&variable_defined ('DIST_CHARSET'))
1545 &am_line_error ('DIST_CHARSET',
1546 "DIST_CHARSET defined but no MAINT_CHARSET defined")
1547 if ! $local_maint_charset;
1548 if ($relative_dir eq '.')
1550 $dist_charset = $contents{'DIST_CHARSET'}
1554 &am_line_error ('DIST_CHARSET',
1555 "DIST_CHARSET can only be defined at top level");
1559 # Look for common files that should be included in distribution.
1561 foreach $cfile (@common_files)
1563 if (-f ($relative_dir . "/" . $cfile))
1565 &push_dist_common ($cfile);
1569 # Keys of %dist_common are names of files to distributed. We put
1570 # README first because it then becomes easier to make a
1571 # Usenet-compliant shar file (in these, README must be first).
1572 # FIXME: do more ordering of files here.
1574 if (defined $dist_common{'README'})
1576 push (@coms, 'README');
1577 undef $dist_common{'README'};
1579 push (@coms, sort keys %dist_common);
1581 &pretty_print ("DIST_COMMON =", "", @coms);
1582 $output_vars .= "\n";
1585 $output_vars .= &file_contents ('dist-vars');
1587 # Put these things in rules section so it is easier for whoever
1588 # reads Makefile.in.
1589 if (! &variable_defined ('distdir'))
1591 if ($relative_dir eq '.')
1593 $output_rules .= "\n" . 'distdir = $(PACKAGE)-$(VERSION)' . "\n";
1597 $output_rules .= ("\n"
1598 . 'distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)'
1602 if ($relative_dir ne '.')
1604 $output_rules .= "\nsubdir = " . $relative_dir . "\n";
1607 # Generate 'dist' target, and maybe dist-shar / dist-zip / dist-tarZ.
1608 if ($relative_dir eq '.')
1610 # Rule to check whether a distribution is viable.
1611 $output_rules .= ('# This target untars the dist file and tries a VPATH configuration. Then
1612 # it guarantees that the distribution is self-contained by making another
1616 $(TAR) zxf $(distdir).tar.gz
1617 mkdir $(distdir)/=build
1618 mkdir $(distdir)/=inst
1619 dc_install_base=`cd $(distdir)/=inst && pwd`; \\'
1620 . (defined $contents{'distcheck-hook'}
1621 ? "\t\$(MAKE) distcheck-hook"
1624 cd $(distdir)/=build \\
1627 . ($seen_gettext ? '--with-included-gettext ' : '')
1628 . '--srcdir=.. --prefix=$$dc_install_base \\
1632 && $(MAKE) install \\
1633 && $(MAKE) installcheck \\
1636 @echo "========================"; \\
1637 echo "$(distdir).tar.gz is ready for distribution"; \\
1638 echo "========================"
1641 $output_rules .= 'dist: distdir' . "\n\t";
1642 # Ignore return result from chmod, because it might give an
1643 # error if we chmod a symlink.
1644 $output_rules .= '-chmod -R a+r $(distdir)' . "\n\t";
1645 $output_rules .= '$(TAR) chozf $(distdir).tar.gz $(distdir)';
1646 $output_rules .= "\n\t" . 'rm -rf $(distdir)' . "\n";
1648 if (defined $options{'dist-shar'})
1650 $output_rules .= 'dist-shar: distdir' . "\n\t";
1651 # Ignore return result from chmod, because it might give
1652 # an error if we chmod a symlink.
1653 $output_rules .= '-chmod -R a+r $(distdir)' . "\n\t";
1654 $output_rules .= 'shar $(distdir) | gzip > $(distdir).shar.gz';
1655 $output_rules .= "\n\t" . 'rm -rf $(distdir)' . "\n";
1658 if (defined $options{'dist-zip'})
1660 $output_rules .= 'dist-zip: distdir' . "\n\t";
1661 $output_rules .= '-chmod -R a+r $(distdir)' . "\n\t";
1662 $output_rules .= 'zip -rq $(distdir).zip $(distdir)';
1663 $output_rules .= "\n\t" . 'rm -rf $(distdir)' . "\n";
1666 if (defined $options{'dist-tarZ'})
1668 $output_rules .= 'dist-tarZ: distdir' . "\n\t";
1669 $output_rules .= '-chmod -R a+r $(distdir)' . "\n\t";
1670 $output_rules .= '$(TAR) chf - $(distdir) | compress -c > $(distdir).tar.Z';
1671 $output_rules .= "\n\t" . 'rm -rf $(distdir)' . "\n";
1675 # Generate distdir target.
1676 &handle_dist_worker;
1679 # Scan a single dependency file and rewrite the dependencies as
1680 # appropriate. Essentially this means:
1681 # * Clean out absolute dependencies which are not desirable.
1682 # * Rewrite other dependencies to be relative to $(top_srcdir).
1683 sub scan_dependency_file
1685 local ($depfile) = @_;
1687 if (! open (DEP_FILE, $depfile))
1689 &am_error ("couldn't open \`$depfile': $!");
1692 print "automake: reading $depfile\n" if $verbose;
1694 local ($first_line) = 1;
1695 local ($last_line) = 0;
1696 local ($target, @dependencies);
1697 local ($one_dep, $xform);
1699 local ($srcdir_rx, $fixup_rx, $fixup2_rx);
1700 ($srcdir_rx = $srcdir_name) =~ s/(\W)/\\$1/g;
1702 # If the top srcdir is absolute, then the current directory is
1703 # just relative_dir.
1704 ($fixup_rx = $srcdir_name . '/' . $relative_dir . '/') =~ s/(\W)/\\$1/g;
1706 # But if the top srcdir is relative, then we need some dots first.
1707 ($fixup2_rx = ($srcdir_name . '/' . $top_builddir . '/'
1708 . $relative_dir . '/')) =~ s/(\W)/\\$1/g;
1714 # If LAST_LINE set then we've already seen what we thought
1715 # was the last line.
1718 next if (/$WHITE_PATTERN/o);
1722 # No trailing "\" means this should be the last line.
1728 if (! /^([^:]+:)(.+)$/)
1731 &am_error ("\`$depfile' has incorrect format");
1742 foreach $one_dep (split (' ', $_))
1744 if ($one_dep =~ /^$fixup_rx/)
1746 # The dependency points to the current directory in
1748 ($xform = $one_dep) =~ s/^$fixup_rx//;
1749 push (@dependencies, $xform);
1751 elsif ($one_dep =~ /^$fixup2_rx/)
1753 # The dependency points to the current directory in
1755 ($xform = $one_dep) =~ s/^$fixup2_rx//;
1756 push (@dependencies, $xform);
1758 elsif ($one_dep =~ /^$srcdir_rx\//)
1760 # The dependency is in some other directory in the package.
1761 ($xform = $one_dep) =~ s/^$srcdir_rx/$top_builddir/;
1762 push (@dependencies, $xform);
1764 elsif ($one_dep =~ /^\//)
1766 # Absolute path; ignore.
1770 # Anything else is assumed to be correct.
1771 push (@dependencies, $one_dep);
1776 &pretty_print_rule ($target, "\t", @dependencies);
1781 # Handle auto-dependency code.
1782 sub handle_dependencies
1784 if ($use_dependencies)
1786 # Include GNU-make-specific auto-dep code.
1787 if ($dir_holds_sources)
1789 &pretty_print ('DEP_FILES =', "", sort keys %dep_files);
1790 $output_rules .= &file_contents ('depend');
1791 push (@clean, 'depend');
1792 &push_phony_cleaners ('depend');
1794 &file_contents_with_transform ('s/\@EXT\@/.c/g;'
1795 . 's/\@MKDEP\@/MKDEP/g',
1798 local ($need_cxx) = 0;
1799 foreach $ext (keys %cxx_extensions)
1802 &file_contents_with_transform ('s/\@EXT\@/' . $ext .'/g;'
1803 . 's/\@MKDEP\@/CXXMKDEP/g',
1809 $output_vars .= 'CXXMKDEP = $(CXX) -MM $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CXXFLAGS)' . "\n";
1815 # FIXME: consider requiring --build-dir here. What about case
1816 # where this is done via an option?
1818 # Include any auto-generated deps that are present. Note that
1819 # $build_directory ends in a "/".
1820 if (-d ($build_directory . $relative_dir . "/.deps")
1821 && -f ($build_directory . $relative_dir . "/.deps/.P"))
1824 local ($gpat) = $build_directory . $relative_dir . "/.deps/*.P";
1826 foreach $depfile (<${gpat}>)
1828 &scan_dependency_file ($depfile);
1831 $output_rules .= "\n";
1836 # Handle subdirectories.
1839 if (! &variable_defined ('SUBDIRS'))
1842 ("ud_GNU_GETTEXT in configure.in but SUBDIRS not defined")
1843 if $seen_gettext && $relative_dir eq '.';
1847 &require_file_with_conf_line ($ac_gettext_line, $FOREIGN, 'ABOUT-NLS')
1850 return if ! &variable_defined ('SUBDIRS');
1852 # Make sure each directory mentioned in SUBDIRS actually exists.
1854 foreach $dir (&variable_value_as_list ('SUBDIRS'))
1856 # Skip directories substituted by configure.
1857 next if $dir =~ /^\@.*\@$/;
1858 &am_line_error ('SUBDIRS',
1859 "required directory $relative_dir/$dir does not exist")
1860 if ! -d $relative_dir . '/' . $dir;
1863 $output_rules .= &file_contents ('subdirs');
1865 # Push a bunch of phony targets.
1867 foreach $phonies ('-data', '-exec', 'dirs')
1869 push (@phony, 'install' . $phonies . '-recursive');
1870 push (@phony, 'uninstall' . $phonies . '-recursive');
1872 foreach $phonies ('all', 'check', 'installcheck', 'info', 'dvi')
1874 push (@phony, $phonies . '-recursive');
1876 &push_phony_cleaners ('recursive');
1878 push (@check, "check-recursive");
1879 push (@installcheck, "installcheck-recursive");
1880 push (@info, "info-recursive");
1881 push (@dvi, "dvi-recursive");
1883 $recursive_install = 1;
1886 # Handle aclocal.m4.
1887 sub handle_aclocal_m4
1889 local ($regen_aclocal) = 0;
1890 if (-f 'aclocal.m4')
1892 $output_vars .= "ACLOCAL = aclocal.m4\n";
1893 &push_dist_common ('aclocal.m4');
1895 if (open (ACLOCAL, '< aclocal.m4'))
1901 if ($line =~ 'generated automatically by aclocal')
1908 local ($acinclude) = 0;
1909 if (-f 'acinclude.m4')
1916 # FIXME: how to tell if aclocal.m4 should be automatically
1922 $output_rules .= ("aclocal.m4: "
1923 . ($seen_maint_mode ? "\@MAINT\@" : "")
1925 . ($acinclude ? ' acinclude.m4' : '')
1927 . 'cd $(srcdir) && aclocal'
1932 # Handle remaking and configure stuff.
1933 sub handle_configure
1935 # If SUBDIRS defined, require AC_PROG_MAKE_SET.
1936 &am_line_error ('SUBDIRS', "AC_PROG_MAKE_SET must be used in configure.in")
1937 if &variable_defined ('SUBDIRS') && ! $seen_make_set;
1939 local ($top_reldir);
1940 if ($relative_dir ne '.')
1943 $output_rules .= &file_contents ('remake-subd');
1944 $top_reldir = '../';
1949 $output_rules .= &file_contents_with_transform ('s/\@STRICTNESS\@/'
1955 ("\`install.sh' is an anachronism; use \`install-sh' instead")
1956 if -f $relative_dir . '/install.sh';
1958 # If we have a configure header, require it.
1961 # FIXME: this restriction should be lifted.
1962 # FIXME: first see if it is even needed as-is.
1963 &am_conf_line_error ($config_header_line,
1964 "argument to AC_CONFIG_HEADER contains \`/'\n")
1965 if ($config_header =~ /\//);
1967 &require_file_with_conf_line ($config_header_line,
1968 $FOREIGN, $config_header);
1970 # Header defined and in this directory.
1971 if (-f 'acconfig.h')
1973 $output_vars .= "ACCONFIG = acconfig.h\n";
1974 &push_dist_common ('acconfig.h');
1976 if (-f $config_name . '.top')
1978 $output_vars .= "CONFIG_TOP = ${config_name}.top\n";
1979 &push_dist_common ($config_name . '.top');
1981 if (-f $config_name . '.bot')
1983 $output_vars .= "CONFIG_BOT = ${config_name}.bot\n";
1984 &push_dist_common ($config_name . '.bot');
1987 &require_file_with_conf_line ($config_header_line, $FOREIGN,
1990 $output_rules .= &file_contents ('remake-hdr');
1991 $output_vars .= "CONFIG_HEADER_IN = ${config_header}\n";
1997 # Set location of mkinstalldirs.
1998 if ($config_aux_dir ne '.' && $config_aux_dir ne '')
2000 $output_vars .= 'mkinstalldirs = ' . $config_aux_dir;
2004 $output_vars .= 'mkinstalldirs = $(top_srcdir)';
2006 $output_vars .= '/mkinstalldirs' . "\n";
2008 &am_line_error ('CONFIG_HEADER',
2009 "\`CONFIG_HEADER' is an anachronism; now determined from \`configure.in'")
2010 if &variable_defined ('CONFIG_HEADER');
2012 # Generate CONFIG_HEADER define, and define interally.
2013 $output_vars .= "CONFIG_HEADER = ${top_builddir}/${config_name}\n"
2015 $contents{'CONFIG_HEADER'} = "${top_builddir}/${config_name}"
2018 # Now look for other files in this directory which must be remade
2019 # by config.status, and generate rules for them.
2020 local (@actual_other_files) = ();
2021 local ($file, $local, $input);
2022 foreach $file (@other_input_files)
2024 # Skip files not in this directory, any Makefile, and the
2025 # config header. These last two must be handled specially.
2026 next unless &dirname ($file) eq $relative_dir;
2027 next if $file eq $top_builddir . '/' . $config_name;
2028 ($local = $file) =~ s/^.*\///;
2029 next if $local eq 'Makefile';
2031 if ($local =~ /^(.*):(.*)$/)
2033 # This is the ":" syntax of AC_OUTPUT.
2040 $input = $local . '.in';
2042 # FIXME: when using autoconf ":" syntax, should we set CONFIG_FILES
2044 $output_rules .= ($local . ': '
2045 . '$(top_builddir)/config.status ' . $input . "\n"
2047 . 'cd $(top_builddir) && CONFIG_FILES='
2048 . ($relative_dir eq '.' ? '' : '$(subdir)/')
2049 . '$@ CONFIG_HEADERS= ./config.status'
2051 push (@actual_other_files, $local);
2053 &require_file_with_conf_line ($ac_output_line, $FOREIGN,
2057 # These files get removed by "make clean".
2058 &pretty_print ('CONFIG_CLEAN_FILES = ', '', @actual_other_files);
2064 $dir_holds_headers = &am_install_var ('header', 'HEADERS', 'include',
2065 'oldinclude', 'pkginclude',
2071 return if ! $seen_gettext || $relative_dir ne '.';
2073 if (&variable_defined ('SUBDIRS'))
2077 "ud_GNU_GETTEXT in configure.in but \`po' not in SUBDIRS")
2078 if $contents{'SUBDIRS'} !~ /\bpo\b/;
2081 "ud_GNU_GETTEXT in configure.in but \`intl' not in SUBDIRS")
2082 if $contents{'SUBDIRS'} !~ /\bintl\b/;
2085 # Ensure that each language in ALL_LINGUAS has a .po file, and
2086 # each po file is mentioned in ALL_LINGUAS.
2089 local (%linguas) = ();
2090 grep ($linguas{$_} = 1, split (' ', $all_linguas));
2097 &am_line_error ($all_linguas_line,
2098 ("po/$_.po exists but \`$_' not in \`ALL_LINGUAS'"))
2102 foreach (keys %linguas)
2104 &am_line_error ($all_linguas_line,
2105 "$_ in \`ALL_LINGUAS' but po/$_.po does not exist")
2111 &am_error ("ud_GNU_GETTEXT in configure.in but \`ALL_LINGUAS' not defined");
2115 # Handle footer elements.
2118 if ($contents{'SOURCES'})
2120 &pretty_print ('SOURCES =', "",
2121 split (' ', $contents{'SOURCES'}));
2123 if ($contents{'OBJECTS'})
2125 &pretty_print ('OBJECTS =', "",
2126 split (' ', $contents{'OBJECTS'}));
2128 if ($contents{'SOURCES'} || $contents{'OBJECTS'})
2130 $output_vars .= "\n";
2133 if (defined $contents{'SUFFIXES'})
2135 # Push actual suffixes, and not $(SUFFIXES). Some versions of
2136 # make do not like variable substitutions on the .SUFFIXES
2138 push (@suffixes, split (' ', $contents{'SUFFIXES'}));
2141 $output_trailer .= ".SUFFIXES:\n";
2144 $output_trailer .= ".SUFFIXES: " . join (' ', @suffixes) . "\n";
2146 $output_trailer .= &file_contents ('footer');
2149 # Deal with installdirs target.
2150 sub handle_installdirs
2152 # GNU Makefile standards recommend this.
2153 $output_rules .= ("installdirs:"
2154 . ($recursive_install
2155 ? " installdirs-recursive\n"
2157 push (@phony, 'installdirs');
2160 &pretty_print_rule ("\t" . '$(mkinstalldirs) ', "\t\t",
2163 $output_rules .= "\n";
2166 # There are several targets which need to be merged. This is because
2167 # their complete definition is compiled from many parts. Note that we
2168 # avoid double colon rules, otherwise we'd use them instead.
2169 sub handle_merge_targets
2171 # There are a few install-related variables that you should not define.
2173 foreach $var ('PRE_INSTALL', 'POST_INSTALL', 'NORMAL_INSTALL')
2175 if (&variable_defined ($var))
2177 &am_line_error ($var, "\`$var' should not be defined");
2181 push (@all, 'Makefile');
2182 push (@all, $config_name)
2183 if $config_name && &dirname ($config_name) eq $relative_dir;
2185 &do_one_merge_target ('info', @info);
2186 &do_one_merge_target ('dvi', @dvi);
2188 if (! &variable_defined ('SUBDIRS') || $relative_dir ne '.')
2190 # 'check' must depend on 'all', but not at top level.
2192 unshift (@check, 'all');
2193 unshift (@install, 'all');
2195 &do_one_merge_target ('check', @check);
2196 &do_one_merge_target ('installcheck', @installcheck);
2198 # Handle the various install targets specially. We do this so
2199 # that (eg) "make install-exec" will run "install-exec-recursive"
2200 # if required, but "make install" won't run it twice. Step one is
2201 # to see if the user specified local versions of any of the
2202 # targets we handle. "all" is treated as one of these since
2203 # "install" can run it.
2204 push (@install_exec, 'install-exec-local')
2205 if defined $contents{'install-exec-local'};
2206 push (@install_data, 'install-data-local')
2207 if defined $contents{'install-data-local'};
2208 push (@uninstall, 'uninstall-local')
2209 if defined $contents{'uninstall-local'};
2211 foreach $utarg ('uninstall-data-local', 'uninstall-data-hook',
2212 'uninstall-exec-local', 'uninstall-exec-hook')
2214 if (defined $contents{$utarg})
2217 ($x = $utarg) =~ s/(data|exec)-//;
2218 &am_line_error ($utarg, "use \`$x', not \`$utarg'");
2221 push (@all, 'all-local')
2222 if defined $contents{'all-local'};
2224 if (defined $contents{'install-local'})
2226 &am_line_error ('install-local',
2227 "use \`install-data' or \`install-exec', not \`install'");
2230 # Step two: if we are doing recursive makes, write out the
2231 # appropriate rules.
2233 if ($recursive_install)
2235 push (@install, 'install-recursive');
2239 local (@hackall) = ();
2240 if ($config_name && &dirname ($config_name) eq $relative_dir)
2243 # This is kind of a hack, but I couldn't see a better
2244 # way to handle it. In this particular case, we need
2245 # to make sure config.h is built before we recurse.
2246 # We can't do this by changing the order of
2247 # dependencies to the "all" because that breaks when
2248 # using parallel makes. Instead we handle things
2250 $output_rules .= ('all-recursive-hack: $(CONFIG_HEADER)'
2251 . "\n\t" . '$(MAKE) all-recursive'
2253 push (@hackall, 'all-recursive-hack');
2254 push (@phony, 'all-recursive-hack');
2258 push (@hackall, 'all-recursive');
2261 $output_rules .= ('all-am: '
2265 push (@all, 'all-am');
2266 push (@phony, 'all-am');
2270 @all = ('all-recursive');
2274 $output_rules .= ('install-exec-am: '
2275 . join (' ', @install_exec)
2277 @install_exec = ('install-exec-recursive', 'install-exec-am');
2278 push (@install, 'install-exec-am');
2279 push (@phony, 'install-exec-am');
2283 @install_exec = ('install-exec-recursive');
2287 $output_rules .= ('install-data-am: '
2288 . join (' ', @install_data)
2290 @install_data = ('install-data-recursive', 'install-data-am');
2291 push (@install, 'install-data-am');
2292 push (@phony, 'install-data-am');
2296 @install_data = ('install-data-recursive');
2300 $output_rules .= ('uninstall-am: '
2301 . join (' ', @uninstall)
2303 @uninstall = ('uninstall-recursive', 'uninstall-am');
2304 push (@phony, 'uninstall-am');
2308 @uninstall = ('uninstall-recursive');
2312 # Step three: print definitions users can use. Code below knows
2313 # that install-exec is done before install-data, beware.
2314 $output_rules .= ("install-exec: "
2315 . join (' ', @install_exec)
2317 $output_rules .= "\t\$(NORMAL_INSTALL)\n";
2318 if (defined $contents{'install-exec-hook'})
2320 $output_rules .= "\t" . '$(MAKE) install-exec-hook' . "\n";
2322 $output_rules .= "\n";
2323 push (@install, 'install-exec') if !$recursive_install;
2324 push (@phony, 'install-exec');
2326 $output_rules .= ("install-data: "
2327 . join (' ', @install_data)
2329 $output_rules .= "\t\$(NORMAL_INSTALL)\n";
2330 if (defined $contents{'install-data-hook'})
2332 $output_rules .= "\t" . '$(MAKE) install-data-hook' . "\n";
2334 $output_rules .= "\n";
2335 push (@install, 'install-data') if !$recursive_install;
2336 push (@phony, 'install-data');
2338 # If no dependencies for 'install', add 'all'. Why? That way
2339 # "make install" at top level of distclean'd distribution won't
2340 # fail because stuff in 'lib' fails to build.
2341 if (! @install || (scalar (@install) == 2
2342 && $install[0] eq 'install-exec'
2343 && $install[1] eq 'install-data'))
2345 push (@install, 'all');
2347 $output_rules .= ('install: '
2348 . join (' ', @install)
2349 # Use "@:" as empty command so nothing prints.
2353 . join (' ', @uninstall)
2355 push (@phony, 'install', 'uninstall');
2357 $output_rules .= ('all: '
2360 push (@phony, 'all');
2362 # Generate the new 'install-strip' target.
2363 $output_rules .= ("install-strip:\n\t"
2364 . '$(MAKE) INSTALL_PROGRAM=\'$(INSTALL_PROGRAM) -s\' install'
2368 # Helper for handle_merge_targets.
2369 sub do_one_merge_target
2371 local ($name, @values) = @_;
2373 if (defined $contents{$name . '-local'})
2375 # User defined local form of target. So include it.
2376 push (@values, $name . '-local');
2377 push (@phony, $name . '-local');
2380 $output_rules .= $name . ":";
2383 $output_rules .= ' ' . join (' ', @values);
2385 $output_rules .= "\n\n";
2386 push (@phony, $name);
2389 # Handle all 'clean' targets.
2392 push (@clean, 'generic');
2393 $output_rules .= &file_contents ('clean');
2394 &push_phony_cleaners ('generic');
2396 local ($target) = $recursive_install ? 'clean-am' : 'clean';
2397 &do_one_clean_target ($target, 'mostly', '', @clean);
2398 &do_one_clean_target ($target, '', 'mostly', @clean);
2399 &do_one_clean_target ($target, 'dist', '', @clean);
2400 &do_one_clean_target ($target, 'maintainer-', 'dist', @clean);
2402 push (@phony, 'clean', 'mostlyclean', 'distclean', 'maintainer-clean');
2405 if ($recursive_install)
2407 @deps = ('am', 'recursive');
2408 &do_one_clean_target ('', 'mostly', '', @deps);
2409 &do_one_clean_target ('', '', '', @deps);
2410 &do_one_clean_target ('', 'dist', '', @deps);
2411 &do_one_clean_target ('', 'maintainer-', '', @deps);
2415 # Helper for handle_clean.
2416 sub do_one_clean_target
2418 local ($target, $name, $last_name, @deps) = @_;
2420 # Special case: if target not passed, then don't generate
2421 # dependency on next "lower" clean target (eg no
2422 # clean<-mostlyclean derivation). In this case the target is
2423 # implicitly known to be 'clean'.
2424 local ($flag) = $target;
2425 $target = 'clean' if ! $flag;
2427 grep (($_ = $name . 'clean-' . $_) && 0, @deps);
2430 if ($last_name || $name ne 'mostly')
2432 push (@deps, $last_name . $target . " ");
2435 # FIXME: not sure if I like the tabs here.
2436 &pretty_print_rule ($name . $target . ": ", "\t\t", @deps);
2438 # FIXME: shouldn't we really print these messages before running
2440 if ($name . $target eq 'maintainer-clean')
2442 # Print a special warning.
2444 ("\t\@echo \"This command is intended for maintainers to use;\"\n"
2445 . "\t\@echo \"it deletes files that may require special "
2446 . "tools to rebuild.\"\n");
2448 $output_rules .= "\trm -f config.status\n"
2449 if $relative_dir eq '.';
2451 elsif ($name . $target eq 'distclean')
2453 $output_rules .= "\trm -f config.status\n";
2455 $output_rules .= "\n";
2458 # Handle .PHONY target.
2461 &pretty_print_rule ('.PHONY:', "", @phony);
2462 $output_rules .= "\n";
2465 # Handle TESTS variable and other checks.
2468 if (defined $options{'dejagnu'})
2470 push (@check, 'check-DEJAGNU');
2471 push (@phony, 'check-DEJAGNU');
2472 $output_rules .= &file_contents ('dejagnu') . "\n";
2473 # Note that in the rule we don't directly generate site.exp to
2474 # avoid the possibility of a corrupted site.exp if make is
2475 # interrupted. Jim Meyering has some useful text on this
2477 $output_rules .= ("site.exp: Makefile\n"
2478 . "\t\@echo 'Making a new site.exp file...'\n"
2479 . "\t-\@rm -f site.bak\n"
2480 . "\t\@echo '## these variables are automatically generated by make ##' > \$\@-t\n"
2481 . "\t\@echo '# Do not edit here. If you wish to override these values' >> \$\@-t\n"
2482 . "\t\@echo '# edit the last section' >> \$\@-t\n"
2483 . "\t\@echo 'set tool \$(DEJATOOL)' >> \$\@-t\n"
2484 . "\t\@echo 'set srcdir \$(srcdir)' >> \$\@-t\n"
2485 . "\t\@echo 'set objdir' \`pwd\` >> \$\@-t\n");
2487 # Extra stuff for AC_CANONICAL_*
2488 local (@whatlist) = ();
2489 if ($seen_canonical)
2491 push (@whatlist, 'host')
2494 # Extra stuff only for AC_CANONICAL_SYSTEM.
2495 if ($seen_canonical == $AC_CANONICAL_SYSTEM)
2497 push (@whatlist, 'target', 'build');
2501 foreach $c1 (@whatlist)
2503 foreach $c2 ('alias', 'triplet')
2505 $output_rules .= "\t\@echo 'set ${c1}_${c2} \$(${c1}_${c2})' >> \$\@-t\n";
2509 $output_rules .= ("\t\@echo '## All variables above are generated by configure. Do Not Edit ##' >> \$\@-t\n"
2510 . "\t-\@sed '1,/^## All variables above are.*##/ d' site.bak >> \$\@-t\n"
2511 . "\t-\@mv site.exp site.bak\n"
2512 . "\t\@mv \$\@-t site.exp\n");
2517 foreach $c ('DEJATOOL', 'RUNTEST', 'RUNTESTFLAGS')
2519 if (&variable_defined ($c))
2521 &am_line_error ($c, "\`$c' defined but \`dejagnu' not in \`AUTOMAKE_OPTIONS'");
2526 if (&variable_defined ('TESTS'))
2528 push (@check, 'check-TESTS');
2529 push (@phony, 'check-TESTS');
2530 # FIXME: use $(SHELL) here? That is what Ulrich suggests.
2531 # Maybe a new macro, $(TEST_SHELL), a la $(CONFIG_SHELL)? For
2532 # now we just execute the file directly; this allows test
2533 # files which are compiled -- a possibly useful feature.
2534 $output_rules .= 'check-TESTS: $(TESTS)
2535 @failed=0; all=0; \\
2536 srcdir=$(srcdir); export srcdir; \\
2537 for tst in $(TESTS); do \\
2538 all=`expr $$all + 1`; \\
2539 if test -f $$tst; then dir=.; \\
2540 else dir="$(srcdir)"; fi; \\
2541 if $(TESTS_ENVIRONMENT) $$dir/$$tst; then \\
2542 echo "PASS: $$tst"; \\
2544 failed=`expr $$failed + 1`; \\
2545 echo "FAIL: $$tst"; \\
2548 if test "$$failed" -eq 0; then \\
2549 echo "========================"; \\
2550 echo "All $$all tests passed"; \\
2551 echo "========================"; \\
2553 echo "$$failed of $$all tests failed"; \\
2559 # Handle Emacs Lisp.
2560 sub handle_emacs_lisp
2562 local (@elfiles) = &am_install_var ('lisp', 'LISP', 'lisp', 'noinst');
2567 $output_vars .= "lispdir = \@lispdir\@\n";
2568 $output_rules .= (".el.elc:\n"
2569 . "\t\@echo 'WARNING: Warnings can be ignored. :-)'\n"
2570 . "\t\$(SHELL) \$(srcdir)/elisp-comp \$<\n");
2571 push (@suffixes, '.el', '.elc');
2573 # Generate .elc files.
2574 grep ($_ .= 'c', @elfiles);
2575 &pretty_print ('ELCFILES =', '', @elfiles);
2577 push (@clean, 'lisp');
2578 &push_phony_cleaners ('lisp');
2581 if (&variable_defined ('lisp_LISP'))
2583 $varname = 'lisp_LISP';
2584 &am_error ("\`lisp_LISP' defined but \`AM_PATH_LISPDIR' not in \`configure.in'")
2589 $varname = 'noinst_LISP';
2592 &require_file_with_line ($varname, $FOREIGN, 'elisp-comp');
2596 ################################################################
2598 # Scan configure.in for interesting things.
2599 # FIXME: ensure VERSION, PACKAGE are set.
2602 open (CONFIGURE, 'configure.in')
2603 || die "automake: couldn't open \`configure.in': $!\n";
2604 print "automake: reading configure.in\n" if $verbose;
2606 # Reinitialize libsources here. This isn't really necessary,
2607 # since we currently assume there is only one configure.in. But
2608 # that won't always be the case.
2611 local ($in_ac_output, @make_list) = 0;
2612 local ($libobj_iter);
2615 # Remove comments from current line.
2619 # Populate libobjs array.
2620 if (/AC_FUNC_ALLOCA/)
2622 $libsources{'alloca.c'} = 1;
2624 elsif (/AC_FUNC_GETLOADAVG/)
2626 $libsources{'getloadavg.c'} = 1;
2628 elsif (/AC_FUNC_MEMCMP/)
2630 $libsources{'memcmp.c'} = 1;
2632 elsif (/AC_STRUCT_ST_BLOCKS/)
2634 $libsources{'fileblocks.c'} = 1;
2636 elsif (/AM_FUNC_FNMATCH/)
2638 $libsources{'fnmatch.c'} = 1;
2640 elsif (/AC_REPLACE_FUNCS\s*\((.*)\)/)
2642 foreach (split (' ', $1))
2644 $libsources{$_ . '.c'} = 1;
2647 elsif (/A[CM]_REPLACE_GNU_GETOPT/)
2649 $libsources{'getopt.c'} = 1;
2650 $libsources{'getopt1.c'} = 1;
2652 elsif (/AM_FUNC_STRTOD/)
2654 $libsources{'strtod.c'} = 1;
2656 elsif (/AM_WITH_REGEX/)
2658 $libsources{'rx.c'} = 1;
2659 $libsources{'rx.h'} = 1;
2660 $libsources{'regex.c'} = 1;
2661 $libsources{'regex.h'} = 1;
2663 elsif (/LIBOBJS="(.*)\s+\$LIBOBJS"/
2664 || /LIBOBJS="\$LIBOBJS\s+(.*)"/)
2666 foreach $libobj_iter (split (' ', $1))
2668 if ($libobj_iter =~ /^(.*)\.o$/)
2670 $libsources{$1 . '.c'} = 1;
2675 if (/(fp_FUNC_FNMATCH|fp_PROG_INSTALL|fp_C_PROTOTYPES|jm_MAINTAINER_MODE)/)
2677 &am_conf_line_error ($., "\`$1' is obsolete; use corresponding \`AM_' macro");
2680 # Process the AC_OUTPUT macro.
2681 if (! $in_ac_output && s/AC_OUTPUT\s*\(\[?//)
2684 $ac_output_line = $.;
2688 $in_ac_output = 0 if s/[\]\),].*$//;
2690 # Look at potential Makefile.am's.
2696 push (@make_list, $_);
2700 push (@other_input_files, $_);
2705 if (/AC_CONFIG_AUX_DIR\(([^)]+)\)/)
2707 @config_aux_path = $1;
2710 # Check for ansi2knr.
2711 $am_c_prototypes = 1 if /AM_C_PROTOTYPES/;
2713 # Check for NLS support.
2714 if (/ud_GNU_GETTEXT/)
2717 $ac_gettext_line = $.;
2720 # Look for ALL_LINGUAS.
2721 if (/ALL_LINGUAS="(.*)"$/ || /ALL_LINGUAS=(.*)$/)
2725 $all_linguas_line = $.;
2728 # Handle configuration headers.
2729 if (/AC_CONFIG_HEADER\s*\((.*)\)/)
2731 $config_header_line = $.;
2733 if ($config_name =~ /^([^:]+):(.+)$/)
2736 $config_header = $2;
2740 $config_header = $config_name . '.in';
2744 # Handle AC_CANONICAL_*. Always allow upgrading to
2745 # AC_CANONICAL_SYSTEM, but never downgrading.
2746 $seen_canonical = $AC_CANONICAL_HOST
2747 if ! $seen_canonical && /AC_CANONICAL_HOST/;
2748 $seen_canonical = $AC_CANONICAL_SYSTEM if /AC_CANONICAL_SYSTEM/;
2750 $seen_canonical = 1 if /AC_CHECK_TOOL/;
2751 $seen_path_xtra = 1 if /AC_PATH_XTRA/;
2753 # Sometimes it is desirable to explicitly set YACC. For
2754 # instance some people don't want to use bison.
2755 $seen_prog_yacc = 1 if (/AC_PROG_YACC/
2756 || /AC_SUBST\(YACC\)/
2757 || /AC_(PATH|CHECK)_PROGS?\(YACC/);
2759 # This macro handles several different things.
2760 if (/AM_INIT_AUTOMAKE\([^,]*,([^)]+)\)/)
2766 $seen_prog_install = 2;
2767 ($package_version = $1) =~ s/\s//;
2768 $package_version_line = $.;
2771 # Some things required by Automake.
2772 $seen_make_set = 1 if /AC_PROG_MAKE_SET/;
2773 $seen_arg_prog = 1 if /AC_ARG_PROGRAM/;
2774 $seen_ranlib = 1 if /AC_PROG_RANLIB/;
2775 $seen_prog_cc = 1 if /AC_PROG_CC/;
2776 $seen_prog_cxx = 1 if /AC_PROG_CXX/;
2777 $seen_prog_lex = 1 if /AC_PROG_LEX/;
2778 $seen_decl_yytext = 1 if /AC_DECL_YYTEXT/;
2779 $seen_maint_mode = 1 if /AM_MAINTAINER_MODE/;
2780 $seen_package = 1 if /PACKAGE=/;
2782 if (/VERSION=(\S+)/)
2785 $package_version = $1;
2786 $package_version_line = $.;
2793 # Weird conditionals here because it is always allowed to
2794 # upgrade to AM_PROG_INSTALL but never to downgrade to
2796 $seen_prog_install = 1 if ! $seen_prog_install && /AC_PROG_INSTALL/;
2797 $seen_prog_install = 2 if /AM_PROG_INSTALL/;
2799 $seen_lispdir = 1 if /AM_PATH_LISPDIR/;
2801 if (/AM_PROG_LIBTOOL/)
2809 # Set input files if not specified by user.
2810 @input_files = @make_list if (! @input_files);
2814 &am_conf_error ("\`PACKAGE' not defined in configure.in")
2816 &am_conf_error ("\`VERSION' not defined in configure.in")
2819 # Look for some files we need. Always check for these. This
2820 # check must be done for every run, even those where we are only
2821 # looking at a subdir Makefile. We must set relative_dir so that
2822 # the file-finding machinery works.
2823 local ($relative_dir) = '.';
2824 &require_config_file ($FOREIGN, 'install-sh', 'mkinstalldirs');
2827 ################################################################
2829 # Do any extra checking for GNU standards.
2830 sub check_gnu_standards
2832 if ($relative_dir eq '.')
2834 # In top level (or only) directory.
2835 &require_file ($GNU, 'INSTALL', 'NEWS', 'README', 'COPYING',
2836 'AUTHORS', 'ChangeLog');
2839 if ($strictness >= $GNU)
2841 if (defined $options{'no-installman'})
2843 &am_line_error ('AUTOMAKE_OPTIONS',
2844 "option \`no-installman' disallowed by GNU standards");
2847 if (defined $options{'no-installinfo'})
2849 &am_line_error ('AUTOMAKE_OPTIONS',
2850 "option \`no-installinfo' disallowed by GNU standards");
2855 # Do any extra checking for GNITS standards.
2856 sub check_gnits_standards
2858 if ($strictness >= $GNITS)
2860 if (-f $relative_dir . '/COPYING.LIB')
2862 &am_error ("\`${relative_dir}/COPYING.LIB' disallowed by Gnits standards");
2865 if ($relative_dir eq '.')
2867 if ($package_version !~ /^$GNITS_VERSION_PATTERN$/)
2869 &am_conf_line_error ($package_version_line,
2870 "version \`$package_version' doesn't follow Gnits standards");
2872 elsif (defined $1 && -f 'README-alpha')
2874 # This means we have an alpha release. See
2875 # GNITS_VERSION_PATTERN for details.
2876 &require_file ($GNITS, 'README-alpha');
2881 if ($relative_dir eq '.')
2883 # In top level (or only) directory.
2884 &require_file ($GNITS, 'THANKS');
2888 ################################################################
2890 # Pretty-print something. HEAD is what should be printed at the
2891 # beginning of the first line, FILL is what should be printed at the
2892 # beginning of every subsequent line.
2893 sub pretty_print_internal
2895 local ($head, $fill, @values) = @_;
2897 local ($column) = length ($head);
2898 local ($result) = $head;
2900 # Fill length is number of characters. However, each Tab
2901 # character counts for eight. So we count the number of Tabs and
2903 local ($fill_length) = length ($fill);
2904 $fill_length += 7 * ($fill =~ tr/\t/\t/d);
2909 # "71" because we also print a space.
2910 if ($column + length ($_) > 71)
2912 $result .= " \\\n" . $fill;
2913 $column = $fill_length;
2917 $result .= ' ' unless ($bol);
2919 $column += length ($_) + 1;
2927 # Pretty-print something and append to output_vars.
2930 $output_vars .= &pretty_print_internal (@_);
2933 # Pretty-print something and append to output_rules.
2934 sub pretty_print_rule
2936 $output_rules .= &pretty_print_internal (@_);
2940 ################################################################
2942 # See if a variable exists.
2943 sub variable_defined
2946 if (defined $targets{$var})
2948 &am_line_error ($var, "\`$var' is target; expected variable");
2950 return (defined $contents{$var} && ! defined $targets{$var});
2953 # Return contents of variable as list, split as whitespace. This will
2954 # recursively follow $(...) and ${...} inclusions. It preserves @...@
2955 # substitutions. If PARENT is specified, it is the name of the
2956 # including variable; this is only used for error reports.
2957 sub variable_value_as_list
2959 local ($var, $parent) = @_;
2962 if (defined $targets{$var})
2964 &am_line_error ($var, "\`$var' is target; expected variable");
2966 elsif (! defined $contents{$var})
2968 &am_error ($parent, "variable \`$var' not defined");
2972 foreach (split (' ', $contents{$var}))
2974 # Handle variable substitutions.
2975 if (/^\$\{(.*)\}$/ || /^\$\((.*)\)$/)
2977 push (@result, &variable_value_as_list ($1, $var));
2989 # Read Makefile.am and set up %contents. Simultaneously copy lines
2990 # from Makefile.am into $output_trailer or $output_vars as
2991 # appropriate. NOTE we put rules in the trailer section. We want
2992 # user rules to come after our generated stuff.
2995 local ($amfile) = @_;
2997 # Compute relative location of the top object directory.
2998 local (@topdir) = ();
2999 foreach (split (/\//, $relative_dir))
3001 next if $_ eq '.' || $_ eq '';
3008 push (@topdir, '..');
3011 @topdir = ('.') if ! @topdir;
3013 $top_builddir = join ('/', @topdir);
3015 ($build_rx = $top_builddir) =~ s/(\W)/\\$1/g;
3016 local ($header_vars) =
3017 &file_contents_with_transform
3018 ('s/\@top_builddir\@/' . $build_rx . '/g',
3021 # Generate some useful variables when AC_CANONICAL_* used.
3022 if ($seen_canonical)
3024 $header_vars .= ('host_alias = @host_alias@' . "\n"
3025 . 'host_triplet = @host@' . "\n");
3026 if ($seen_canonical == $AC_CANONICAL_SYSTEM)
3028 $header_vars .= ('build_alias = @build_alias@' . "\n"
3029 . 'build_triplet = @build@' . "\n");
3030 $header_vars .= ('target_alias = @target_alias@' . "\n"
3031 . 'target_triplet = @target@' . "\n");
3035 open (AM_FILE, $amfile) || die "automake: couldn't open \`$amfile': $!\n";
3036 print "automake: reading $amfile\n" if $verbose;
3038 $output_vars .= ("# $in_file_name generated automatically by automake "
3039 . $VERSION . " from $am_file_name\n");
3041 # Generate copyright for generated Makefile.in.
3042 $output_vars .= $gen_copyright;
3044 local ($saw_bk) = 0;
3045 local ($was_rule) = 0;
3046 local ($spacing) = '';
3047 local ($comment) = '';
3048 local ($last_var_name) = '';
3053 if (/$IGNORE_PATTERN/o)
3055 # Merely delete comments beginning with two hashes.
3057 elsif (/$WHITE_PATTERN/o)
3059 # Stick a single white line before the incoming macro or rule.
3063 elsif (/$COMMENT_PATTERN/o)
3065 # Stick comments before the incoming macro or rule. Make
3066 # sure a blank line preceeds first block of comments.
3067 $spacing = "\n" unless $blank;
3069 $comment .= $spacing . $_;
3078 $output_vars .= $comment . "\n" . $header_vars;
3082 local ($is_ok_macro);
3086 unless substr ($_, -1, 1) eq "\n";
3088 $_ =~ s/\@(UN)?MAINT\@//g
3089 unless $seen_maint_mode;
3091 if (/$IGNORE_PATTERN/o)
3093 # Merely delete comments beginning with two hashes.
3095 elsif (/$WHITE_PATTERN/o)
3097 # Stick a single white line before the incoming macro or rule.
3100 elsif (/$COMMENT_PATTERN/o)
3102 # Stick comments before the incoming macro or rule.
3103 $comment .= $spacing . $_;
3110 $output_trailer .= $_;
3117 # Chop newline and backslash if this line is
3118 # continued. FIXME: maybe ensure trailing whitespace
3122 $contents{$last_var_name} .= $_;
3125 elsif (/$RULE_PATTERN/o)
3127 # warn "** Saw rule .$1.\n";
3130 # Value here doesn't matter; for targets we only note
3134 $content_lines{$1} = $.;
3135 $output_trailer .= $comment . $spacing . $_;
3136 $comment = $spacing = '';
3139 elsif (($is_ok_macro = /$MACRO_PATTERN/o)
3140 || /$BOGUS_MACRO_PATTERN/o)
3142 # Found a macro definition.
3144 $last_var_name = $1;
3145 if (substr ($2, -1) eq "\\")
3147 $contents{$1} = substr ($2, 0, length ($2) - 1);
3153 $content_lines{$1} = $.;
3154 $output_vars .= $comment . $spacing . $_;
3155 $comment = $spacing = '';
3159 &am_line_error ($., "bad macro name \`$1'")
3164 # This isn't an error; it is probably a continued rule.
3165 # In fact, this is what we assume.
3167 $output_trailer .= $comment . $spacing . $_;
3168 $comment = $spacing = '';
3175 $output_trailer .= $comment;
3178 ################################################################
3180 sub initialize_global_constants
3182 # Values for AC_CANONICAL_*
3183 $AC_CANONICAL_HOST = 1;
3184 $AC_CANONICAL_SYSTEM = 2;
3186 # Associative array of standard directory names. Entry is TRUE if
3187 # corresponding directory should be installed during
3188 # 'install-exec' phase.
3206 # Helper text for dealing with man pages.
3207 $install_man_format =
3208 ' sect=@SECTION@; \\
3209 inst=`echo "@MANBASE@" | sed \'$(transform)\'`.@FULLSECT@; \\
3210 if test -f $(srcdir)/@MAN@; then file=$(srcdir)/@MAN@; \\
3211 else file=@MAN@; fi; \\
3212 $(INSTALL_DATA) $$file $(mandir)/man$$sect/$$inst
3215 $uninstall_man_format =
3216 ' inst=`echo "@MANBASE@" | sed \'$(transform)\'`.@FULLSECT@; \\
3217 rm -f $(mandir)/man@SECTION@/$$inst
3220 # Commonly found files we look for and automatically include in
3224 "README", "THANKS", "TODO", "NEWS", "COPYING", "COPYING.LIB",
3225 "INSTALL", "ABOUT-NLS", "ChangeLog", "configure", "configure.in",
3226 "config.guess", "config.sub", "AUTHORS", "BACKLOG", "ABOUT-GNU",
3227 "libversion.in", "mdate-sh", "mkinstalldirs", "install-sh",
3228 'texinfo.tex', "ansi2knr.c", "ansi2knr.1", 'elisp-comp',
3229 'interlock', 'ylwrap', 'acinclude.m4'
3232 # Commonly used files we auto-include, but only sometimes.
3235 "aclocal.m4", "acconfig.h", "config.h.top",
3236 "config.h.bot", "stamp-h.in", 'stamp-vti', 'libtool'
3240 -a, --add-missing add missing standard files to package
3241 --amdir=DIR directory storing config files
3242 --build-dir=DIR directory where build being done (for dependencies)
3243 --foreign same as --strictness=foreign
3244 --gnits same as --strictness=gnits
3245 --gnu same as --strictness=gnu
3246 --help print this help, then exit
3247 -i, --include-deps include generated dependencies in Makefile.in
3248 --no-force only update Makefile.in's that are out of date
3249 -o DIR, --output-dir=DIR
3250 put generated Makefile.in's into DIR
3251 --srcdir-name=DIR name used for srcdir (for dependencies)
3252 -s LEVEL, --strictness=LEVEL
3253 set strictness level. LEVEL is foreign, gnu, gnits
3254 -v, --verbose verbosely list files processed
3255 --version print version number, then exit\n";
3257 # Copyright on generated Makefile.ins.
3259 # Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
3260 # This Makefile.in is free software; the Free Software Foundation
3261 # gives unlimited permission to copy, distribute and modify it.
3265 # (Re)-Initialize per-Makefile.am variables.
3266 sub initialize_per_input
3268 # These two variables are used when generating each Makefile.in.
3269 # They hold the Makefile.in until it is ready to be printed.
3272 $output_trailer = '';
3274 # Suffixes found during a run.
3277 # This holds the contents of a Makefile.am, as parsed by
3281 # This holds the names which are targets. These also appear in
3285 # This holds the line numbers at which various elements of
3286 # %contents are defined.
3287 %content_lines = ();
3289 # This holds the "relative directory" of the current Makefile.in.
3290 # Eg for src/Makefile.in, this is "src".
3293 # This holds a list of files that are included in the
3297 # List of dependencies for the obvious targets.
3312 # These are pretty obvious, too. They are used to define the
3313 # SOURCES and OBJECTS variables.
3317 # TRUE if current directory holds any C source files. (Actually
3318 # holds object extension, but this information is encapsulated in
3319 # the function get_object_extension).
3320 $dir_holds_sources = '';
3322 # TRUE if current directory holds any headers.
3323 $dir_holds_headers = 0;
3325 # TRUE if install targets should work recursively.
3326 $recursive_install = 0;
3331 # Strictness levels.
3332 $strictness = $default_strictness;
3333 $strictness_name = $default_strictness_name;
3335 # Options from AUTOMAKE_OPTIONS.
3338 # Whether or not dependencies are handled. Can be further changed
3339 # in handle_options.
3340 $use_dependencies = $cmdline_use_dependencies;
3343 $local_maint_charset = $maint_charset;
3345 # All yacc and lex source filenames for this directory. Use
3346 # filenames instead of raw count so that multiple instances are
3347 # counted correctly (eg one yacc file can appear in multiple
3348 # programs without harm).
3352 # C++ source extensions we've seen.
3353 %cxx_extensions = ();
3355 # TRUE if we've seen any non-C++ sources.
3360 ################################################################
3362 # Return contents of a file from $am_dir, automatically skipping
3363 # macros or rules which are already known. Runs command on each line
3364 # as it is read; this command can modify $_.
3365 sub file_contents_with_transform
3367 local ($command, $basename) = @_;
3368 local ($file) = $am_dir . '/' . $basename . '.am';
3370 open (FC_FILE, $file)
3371 || die "automake: installation error: cannot open \`$file'\n";
3373 # print "automake: reading $file\n" if $verbose;
3375 local ($was_rule) = 0;
3376 local ($result_vars) = '';
3377 local ($result_rules) = '';
3378 local ($comment) = '';
3379 local ($spacing) = "\n";
3380 local ($skipping) = 0;
3384 $_ =~ s/\@(UN)?MAINT\@//g
3385 unless $seen_maint_mode;
3389 if (/$IGNORE_PATTERN/o)
3391 # Merely delete comments beginning with two hashes.
3393 elsif (/$WHITE_PATTERN/o)
3395 # Stick a single white line before the incoming macro or rule.
3398 elsif (/$COMMENT_PATTERN/o)
3400 # Stick comments before the incoming macro or rule.
3401 $comment .= $spacing . $_;
3408 $result_rules .= $_ if ! $skipping;
3412 $result_vars .= $_ if ! $skipping;
3416 elsif (/$RULE_PATTERN/o)
3418 # warn "** Found rule .$1.\n";
3421 $skipping = defined $contents{$1};
3422 # warn "** Skip $skipping\n" if $skipping;
3423 $result_rules .= $comment . $spacing . $_ if ! $skipping;
3424 $comment = $spacing = '';
3427 elsif (/$MACRO_PATTERN/o)
3429 # warn "** Found macro .$1.\n";
3430 # Found a variable reference.
3432 $skipping = defined $contents{$1};
3433 # warn "** Skip $skipping\n" if $skipping;
3434 $result_vars .= $comment . $spacing . $_ if ! $skipping;
3435 $comment = $spacing = '';
3440 # This isn't an error; it is probably a continued rule.
3441 # In fact, this is what we assume.
3443 $result_rules .= $comment . $spacing . $_ if ! $skipping;
3444 $comment = $spacing = '';
3450 return $result_vars . $result_rules . $comment;
3453 # Like file_contents_with_transform, but no transform.
3456 return &file_contents_with_transform ('', @_);
3459 # Find all variable prefixes that are used for install directories. A
3460 # prefix `zar' qualifies iff:
3461 # * `zardir' is a variable.
3462 # * `zar_PRIMARY' is a variable.
3463 sub am_primary_prefixes
3465 local ($primary, @prefixes) = @_;
3467 local (%valid, $varname);
3468 grep ($valid{$_} = 0, @prefixes);
3469 $valid{'EXTRA'} = 0;
3470 foreach $varname (keys %contents)
3472 if ($varname =~ /^(.*)_$primary$/)
3474 if (! defined $valid{$1} && ! &variable_defined ($1 . 'dir'))
3476 &am_line_error ($varname, "invalid variable \"$varname\"");
3480 # Ensure all extended prefixes are actually used.
3489 # Handle `where_HOW' variable magic. Does all lookups, generates
3490 # install code, and possibly generates code to define the primary
3491 # variable. The first argument is the name of the .am file to munge,
3492 # the second argument is the primary variable (eg HEADERS), and all
3493 # subsequent arguments are possible installation locations. Returns
3494 # list of all values of all _HOW targets.
3496 # FIXME: this should be rewritten to be cleaner. It should be broken
3497 # up into multiple functions.
3499 # Usage is: am_install_var (OPTION..., file, HOW, where...)
3504 local ($do_all, $do_clean) = (1, 0);
3507 if ($args[0] eq '-clean')
3511 elsif ($args[0] eq '-no-all')
3515 elsif ($args[0] !~ /^-/)
3521 local ($file, $primary, @prefixes) = @args;
3524 local (@result) = ();
3526 # Now that configure substitutions are allowed in where_HOW
3527 # variables, it is an error to actually define the primary.
3528 &am_line_error ($primary, "\`$primary' is an anachronism")
3529 if &variable_defined ($primary);
3532 # Look for misspellings. It is an error to have a variable ending
3533 # in a "reserved" suffix whose prefix is unknown, eg
3534 # "bni_PROGRAMS". However, unusual prefixes are allowed if a
3535 # variable of the same name (with "dir" appended) exists. For
3536 # instance, if the variable "zardir" is defined, then
3537 # "zar_PROGRAMS" becomes valid. This is to provide a little extra
3538 # flexibility in those cases which need it. Perhaps it should be
3539 # disallowed in the Gnits case? The problem is, sometimes it is
3540 # useful to put things in a subdir of eg pkgdatadir, perhaps even
3542 local (%valid) = &am_primary_prefixes ($primary, @prefixes);
3544 local ($clean_file) = $file . '-clean';
3547 foreach $X (keys %valid)
3549 $one_name = $X . '_' . $primary;
3550 if (&variable_defined ($one_name))
3552 # Append actual contents of where_PRIMARY variable to
3555 foreach $rcurs (&variable_value_as_list ($one_name))
3557 # Skip configure substitutions. Possibly bogus.
3558 next if $rcurs =~ /^\@.*\@$/;
3559 push (@result, $rcurs);
3562 # "EXTRA" shouldn't be used when generating clean targets,
3563 # @all, or install targets.
3564 next if $X eq 'EXTRA';
3569 &file_contents_with_transform ('s/\@DIR\@/' . $X . '/go',
3572 push (@clean, $X . $primary);
3573 &push_phony_cleaners ($X . $primary);
3578 push (@check, '$(' . $one_name . ')');
3582 push (@used, '$(' . $one_name . ')');
3584 if ($X eq 'noinst' || $X eq 'check')
3586 # Objects which don't get installed by default.
3591 &file_contents_with_transform ('s/\@DIR\@/' . $X . '/go',
3594 push (@uninstall, 'uninstall-' . $X . $primary);
3595 push (@phony, 'uninstall-' . $X . $primary);
3596 push (@installdirs, '$(' . $X . 'dir)');
3597 if ($exec_dir_p{$X})
3599 push (@install_exec, 'install-' . $X . $primary);
3600 push (@phony, 'install-' . $X . $primary);
3604 push (@install_data, 'install-' . $X . $primary);
3605 push (@phony, 'install-' . $X . $primary);
3613 &pretty_print ($primary . ' =', '', @used);
3614 $output_vars .= "\n";
3617 # Push here because PRIMARY might be configure time determined.
3618 push (@all, '$(' . $primary . ')')
3619 if $do_all && @used;
3625 ################################################################
3627 # This variable is local to the "require file" set of functions.
3628 @require_file_paths = ();
3630 # Verify that the file must exist in the current directory. Usage:
3631 # require_file (isconfigure, line_number, strictness, file) strictness
3632 # is the strictness level at which this file becomes required. Must
3633 # set require_file_paths before calling this function.
3634 # require_file_paths is set to hold a single directory (the one in
3635 # which the first file was found) before return.
3636 sub require_file_internal
3638 local ($is_configure, $line, $mystrict, @files) = @_;
3639 local ($file, $fullfile);
3640 local ($found_it, $errfile, $errdir);
3643 foreach $file (@files)
3646 foreach $dir (@require_file_paths)
3650 $fullfile = $relative_dir . "/" . $file;
3651 $errdir = $relative_dir unless $errdir;
3655 $fullfile = $dir . "/" . $file;
3656 $errdir = $dir unless $errdir;
3659 # Use different name for "error filename". Otherwise on
3660 # an error the bad file will be reported as eg
3661 # `../../install-sh' when using the default
3663 $errfile = $errdir . '/' . $file;
3668 # FIXME: Once again, special-case `.'.
3669 &push_dist_common ($file)
3670 if $dir eq $relative_dir || $dir eq '.';
3678 # Prune the path list.
3679 @require_file_paths = $save_dir;
3683 if ($strictness >= $mystrict)
3685 # Only install missing files according to our desired
3687 if ($add_missing && -f ($am_dir . '/' . $file))
3689 # Install the missing file. Symlink if we can, copy
3691 if ($symlink_exists)
3693 symlink ($am_dir . '/' . $file, $errfile);
3697 system ('cp', $am_dir . '/' . $file, $errfile);
3700 # FIXME: this is a hack. Should have am_warn.
3701 local ($save) = $exit_status;
3706 "required file \"$errfile\" not found; installing");
3712 "required file \"$errfile\" not found; installing");
3714 $exit_status = $save;
3718 # Only an error if strictness constraint violated.
3722 ($line, "required file \"$errfile\" not found");
3727 ($line, "required file \"$errfile\" not found");
3735 # Like require_file_with_line, but error messages refer to
3736 # configure.in, not the current Makefile.am.
3737 sub require_file_with_conf_line
3739 @require_file_paths = '.';
3740 &require_file_internal (1, @_);
3743 sub require_file_with_line
3745 @require_file_paths = '.';
3746 &require_file_internal (0, @_);
3751 @require_file_paths = '.';
3752 &require_file_internal (0, '', @_);
3755 # Require a file that is also required by Autoconf. Looks in
3756 # configuration path, as specified by AC_CONFIG_AUX_DIR.
3757 sub require_config_file
3759 @require_file_paths = @config_aux_path;
3760 &require_file_internal (0, '', @_);
3761 local ($dir) = $require_file_paths[0];
3762 @config_aux_path = @require_file_paths;
3765 $config_aux_dir = '.';
3769 $config_aux_dir = '$(top_srcdir)/' . $dir;
3773 # Assumes that the line number is in Makefile.am.
3774 sub require_conf_file_with_line
3776 @require_file_paths = @config_aux_path;
3777 &require_file_internal (0, @_);
3778 local ($dir) = $require_file_paths[0];
3779 @config_aux_path = @require_file_paths;
3782 $config_aux_dir = '.';
3786 $config_aux_dir = '$(top_srcdir)/' . $dir;
3790 # Assumes that the line number is in Makefile.am.
3791 sub require_conf_file_with_conf_line
3793 @require_file_paths = @config_aux_path;
3794 &require_file_internal (1, @_);
3795 local ($dir) = $require_file_paths[0];
3796 @config_aux_path = @require_file_paths;
3799 $config_aux_dir = '.';
3803 $config_aux_dir = '$(top_srcdir)/' . $dir;
3807 ################################################################
3809 # Push a list of files onto dist_common.
3810 sub push_dist_common
3812 local (@files) = @_;
3815 foreach $file (@files)
3817 $dist_common{$file} = 1;
3821 # Push a list of clean targets onto phony.
3822 sub push_phony_cleaners
3826 foreach $target ('mostly', 'dist', '', 'maintainer-')
3828 push (@phony, $target . 'clean-' . $base);
3835 $strictness_name = $_[0];
3836 if ($strictness_name eq 'gnu')
3840 elsif ($strictness_name eq 'gnits')
3842 $strictness = $GNITS;
3844 elsif ($strictness_name eq 'foreign')
3846 $strictness = $FOREIGN;
3850 die "automake: level \`$strictness_name' not recognized\n";
3855 ################################################################
3857 # Return directory name of file.
3863 ($sub = $file) =~ s,/+[^/]+$,,g;
3864 $sub = '.' if $sub eq $file;
3868 ################################################################
3870 # Print an error message and set exit status.
3873 warn "automake: ${am_file}.am: ", join (' ', @_), "\n";
3879 local ($symbol, @args) = @_;
3883 # If SYMBOL not already a line number, look it up in Makefile.am.
3884 $symbol = $content_lines{$symbol} unless $symbol =~ /^\d+$/;
3885 $symbol .= ': ' if $symbol;
3886 warn "${am_file}.am:", $symbol, join (' ', @args), "\n";
3895 # Like am_error, but while scanning configure.in.
3898 # FIXME: can run in subdirs.
3899 warn "automake: configure.in: ", join (' ', @_), "\n";
3903 # Error message with line number referring to configure.in.
3904 sub am_conf_line_error
3906 local ($line, @args) = @_;
3910 warn "configure.in: $line: ", join (' ', @args), "\n";
3915 &am_conf_error (@args);
3919 # Tell user where our aclocal.m4 is, but only once.
3920 sub keyed_aclocal_warning
3923 warn "automake: macro \`$key' can be generated by \`aclocal'\n";
3926 # Print usage information.
3929 print "Usage: automake [OPTION] ... [Makefile]...\n";
3931 print "\nFiles which are automatically distributed, if found:\n";
3932 $~ = "USAGE_FORMAT";
3933 local (@lcomm) = sort ((@common_files, @common_sometimes));
3934 local ($one, $two, $three, $four);
3937 $one = shift @lcomm;
3938 $two = @lcomm ? shift @lcomm : '';
3939 $three = @lcomm ? shift @lcomm : '';
3940 $four = @lcomm ? shift @lcomm : '';
3944 print "\nReport bugs to <bug-gnu-utils\@prep.ai.mit.edu>\n";
3949 format USAGE_FORMAT =
3950 @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<
3951 $one, $two, $three, $four