*** empty log message ***
[nvi.git] / dist / automake
blob2a72373d33f61da6a48d9142d364709dcdcea3b8
1 #!/usr/bin/perl
2 # -*- perl -*-
3 # Generated automatically from automake.in by configure.
5 eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
6 if 0;
8 # automake - create Makefile.in from Makefile.am
9 # Copyright (C) 1994-99, 2000 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)
14 # any later version.
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
24 # 02111-1307, USA.
26 # Originally written by David Mackenzie <djm@gnu.ai.mit.edu>.
27 # Perl reimplementation by Tom Tromey <tromey@cygnus.com>.
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 = "1.4a";
33 $PACKAGE = "automake";
34 $prefix = "/usr";
35 $am_dir = "${prefix}/share/automake";
37 # String constants.
38 $IGNORE_PATTERN = "^##([^#].*)?\$";
39 $WHITE_PATTERN = "^[ \t]*\$";
40 $COMMENT_PATTERN = "^#";
41 $RULE_PATTERN = "^([\$a-zA-Z_.][-.a-zA-Z0-9_(){}/\$]*) *:([^=].*|)\$";
42 $SUFFIX_RULE_PATTERN = "^\\.([a-zA-Z0-9]+)\\.([a-zA-Z0-9]+)\$";
43 $MACRO_PATTERN = "^([A-Za-z0-9_]+)[ \t]*([:+]?)=[ \t]*(.*)\$";
44 $BOGUS_MACRO_PATTERN = "^([^ \t]*)[ \t]*([:+]?)=[ \t]*(.*)\$";
45 $GNITS_VERSION_PATTERN = "[0-9]+\\.[0-9]+([a-z]|\\.[0-9]+)?";
46 $IF_PATTERN = "^if[ \t]+\([A-Za-z][A-Za-z0-9_]*\)[ \t]*\(#.*\)?\$";
47 $ELSE_PATTERN = "^else[ \t]*\(#.*\)?\$";
48 $ENDIF_PATTERN = "^endif[ \t]*\(#.*\)?\$";
49 $PATH_PATTERN='(\\w|[/.-])+';
50 # This will pass through anything not of the prescribed form.
51 $INCLUDE_PATTERN = "^include[ \t]+((\\\$\\\(top_srcdir\\\)/${PATH_PATTERN})|(\\\$\\\(srcdir\\\)/${PATH_PATTERN})|([^/\\\$]${PATH_PATTERN}))[ \t]*(#.*)?\$";
53 # Some regular expressions. One reason to put them here is that it
54 # makes indentation work better in Emacs.
55 $AC_CONFIG_AUX_DIR_PATTERN = "AC_CONFIG_AUX_DIR\\(([^)]+)\\)";
56 $AM_INIT_AUTOMAKE_PATTERN = "AM_INIT_AUTOMAKE\\([^,]*,([^,)]+)[,)]";
57 $AM_PACKAGE_VERSION_PATTERN = "^\\s*\\[?([^]\\s]+)\\]?\\s*\$";
58 # Note that there is no AC_PATH_TOOL. But we don't really care.
59 $AC_CHECK_PATTERN = "AC_(CHECK|PATH)_(PROG|PROGS|TOOL)\\(\\[?(\\w+)";
60 $AM_MISSING_PATTERN = "AM_MISSING_PROG\\(\\[?(\\w+)";
61 # Just check for alphanumeric in AC_SUBST. If you do AC_SUBST(5),
62 # then too bad.
63 $AC_SUBST_PATTERN = "AC_SUBST\\(\\[?(\\w+)";
64 $AM_CONDITIONAL_PATTERN = "AM_CONDITIONAL\\((\\w+)";
66 # Constants to define the "strictness" level.
67 $FOREIGN = 0;
68 $GNU = 1;
69 $GNITS = 2;
71 # These constants are returned by lang_*_rewrite functions.
72 # LANG_SUBDIR means that the resulting object file should be in a
73 # subdir if the source file is. In this case the file name cannot
74 # have `..' components.
75 $LANG_IGNORE = 0;
76 $LANG_PROCESS = 1;
77 $LANG_SUBDIR = 2;
81 # Variables global to entire run.
83 # TRUE if we should always generate Makefile.in.
84 $force_generation = 1;
86 # Strictness level as set on command line.
87 $default_strictness = $GNU;
89 # Name of strictness level, as set on command line.
90 $default_strictness_name = 'gnu';
92 # This is TRUE if automatic dependency generation code should be
93 # included in generated Makefile.in.
94 $cmdline_use_dependencies = 1;
96 # TRUE if in verbose mode.
97 $verbose = 0;
99 # This holds our (eventual) exit status. We don't actually exit until
100 # we have processed all input files.
101 $exit_status = 0;
103 # From the Perl manual.
104 $symlink_exists = (eval 'symlink ("", "");', $@ eq '');
106 # TRUE if missing standard files should be installed.
107 $add_missing = 0;
109 # TRUE if we should copy missing files; otherwise symlink if possible.
110 $copy_missing = 0;
112 # TRUE if we should always update files that we know about.
113 $force_missing = 0;
115 # Files found by scanning configure.in for LIBOBJS.
116 %libsources = ();
118 # True if AM_C_PROTOTYPES appears in configure.in.
119 $am_c_prototypes = 0;
121 # Names used in AC_CONFIG_HEADER call. @config_fullnames holds the
122 # name which appears in AC_CONFIG_HEADER, colon and all.
123 # @config_names holds the file names. @config_headers holds the '.in'
124 # files. Ordinarily these are similar, but they can be different if
125 # the weird "NAME:FILE" syntax is used.
126 @config_fullnames = ();
127 @config_names = ();
128 @config_headers = ();
129 # Line number at which AC_CONFIG_HEADER appears in configure.in.
130 $config_header_line = 0;
132 # Directory where output files go. Actually, output files are
133 # relative to this directory.
134 $output_directory = '.';
136 # Relative location of top build directory.
137 $top_builddir = '';
139 # List of Makefile.am's to process, and their corresponding outputs.
140 @input_files = ();
141 %output_files = ();
143 # Complete list of Makefile.am's that exist.
144 @configure_input_files = ();
146 # List of files in AC_OUTPUT without Makefile.am, and their outputs.
147 @other_input_files = ();
148 # Line number at which AC_OUTPUT seen.
149 $ac_output_line = 0;
151 # List of directories to search for configure-required files. This
152 # can be set by AC_CONFIG_AUX_DIR.
153 @config_aux_path = ('.', '..', '../..');
154 $config_aux_dir = '';
156 # Whether AC_PROG_MAKE_SET has been seen in configure.in.
157 $seen_make_set = 0;
159 # Whether AM_GNU_GETTEXT has been seen in configure.in.
160 $seen_gettext = 0;
161 # Line number at which AM_GNU_GETTEXT seen.
162 $ac_gettext_line = 0;
164 # Whether ALL_LINGUAS has been seen.
165 $seen_linguas = '';
166 # The actual text.
167 $all_linguas = '';
168 # Line number at which it appears.
169 $all_linguas_line = 0;
171 # 1 if AC_PROG_INSTALL seen.
172 $seen_prog_install = 0;
174 # Whether AC_PATH_XTRA has been seen in configure.in.
175 $seen_path_xtra = 0;
177 # TRUE if AC_DECL_YYTEXT was seen.
178 $seen_decl_yytext = 0;
180 # TRUE if we've seen AC_CANONICAL_(HOST|SYSTEM). The presence of
181 # AC_CHECK_TOOL also sets this.
182 $seen_canonical = 0;
184 # TRUE if we've seen AC_ARG_PROGRAM.
185 $seen_arg_prog = 0;
187 # TRUE if we've seen AC_PROG_LIBTOOL.
188 $seen_libtool = 0;
189 $libtool_line = 0;
191 # Files installed by libtoolize.
192 @libtoolize_files = ('ltconfig', 'ltmain.sh', 'config.guess', 'config.sub');
194 # TRUE if we've seen AM_MAINTAINER_MODE.
195 $seen_maint_mode = 0;
197 # TRUE if we've seen PACKAGE and VERSION.
198 $seen_package = 0;
199 $seen_version = 0;
201 # Actual version we've seen.
202 $package_version = '';
204 # Line number where we saw version definition.
205 $package_version_line = 0;
207 # TRUE if we've seen AM_PATH_LISPDIR.
208 $seen_lispdir = 0;
210 # TRUE if we've seen AM_CHECK_PYTHON.
211 $seen_pythondir = 0;
213 # TRUE if we've seen AC_EXEEXT.
214 $seen_exeext = 0;
216 # TRUE if we've seen AC_OBJEXT.
217 $seen_objext = 0;
219 # TRUE if we've seen AC_ENABLE_MULTILIB.
220 $seen_multilib = 0;
222 # TRUE if we've seen AM_PROG_CC_C_O
223 $seen_cc_c_o = 0;
225 # TRUE if we've seen AM_INIT_AUTOMAKE.
226 $seen_init_automake = 0;
228 # Hash table of discovered configure substitutions. Keys are names,
229 # values are `FILE:LINE' strings which are used by error message
230 # generation.
231 %configure_vars = ();
233 # This is used to keep track of which variable definitions we are
234 # scanning. It is only used in certain limited ways, but it has to be
235 # global. It is declared just for documentation purposes.
236 %vars_scanned = ();
238 # Charsets used by maintainer and in distribution. MAINT_CHARSET is
239 # handled in a funny way: if seen in the top-level Makefile.am, it is
240 # used for every directory which does not specify a different value.
241 # The rationale here is that some directories (eg gettext) might be
242 # distributions of other packages, and thus require their own charset
243 # info. However, the DIST_CHARSET must be the same for the entire
244 # package; it can only be set at top-level.
245 # FIXME: this yields bugs when rebuilding. What to do? Always
246 # read (and sometimes discard) top-level Makefile.am?
247 $maint_charset = '';
248 $dist_charset = 'utf8'; # recode doesn't support this yet.
250 # Name of input file ("Makefile.in") and output file ("Makefile.am").
251 # These have no directory components.
252 $am_file_name = '';
253 $in_file_name = '';
255 # TRUE if --cygnus seen.
256 $cygnus_mode = 0;
258 # Hash table of AM_CONDITIONAL variables seen in configure.
259 %configure_cond = ();
261 # Map from obsolete macros to hints for new macros.
262 # If you change this, change the corresponding list in aclocal.in.
263 # FIXME: should just put this into a single file.
264 %obsolete_macros =
266 'AC_FEATURE_CTYPE', "use \`AC_HEADER_STDC'",
267 'AC_FEATURE_ERRNO', "add \`strerror' to \`AC_REPLACE_FUNCS(...)'",
268 'AC_FEATURE_EXIT', '',
269 'AC_SYSTEM_HEADER', '',
271 # Note that we do not handle this one, because it is still run
272 # from AM_CONFIG_HEADER. So we deal with it specially in
273 # scan_configure.
274 # 'AC_CONFIG_HEADER', "use \`AM_CONFIG_HEADER'",
276 'fp_C_PROTOTYPES', "use \`AM_C_PROTOTYPES'",
277 'fp_PROG_CC_STDC', "use \`AM_PROG_CC_STDC'",
278 'fp_PROG_INSTALL', "use \`AC_PROG_INSTALL'",
279 'fp_WITH_DMALLOC', "use \`AM_WITH_DMALLOC'",
280 'fp_WITH_REGEX', "use \`AM_WITH_REGEX'",
281 'gm_PROG_LIBTOOL', "use \`AM_PROG_LIBTOOL'",
282 'jm_MAINTAINER_MODE', "use \`AM_MAINTAINER_MODE'",
283 'md_TYPE_PTRDIFF_T', "use \`AM_TYPE_PTRDIFF_T'",
284 'ud_PATH_LISPDIR', "use \`AM_PATH_LISPDIR'",
285 'ud_GNU_GETTEXT', "use \`AM_GNU_GETTEXT'",
287 # Now part of autoconf proper, under a different name.
288 'AM_FUNC_FNMATCH', "use \`AC_FUNC_FNMATCH'",
289 'fp_FUNC_FNMATCH', "use \`AC_FUNC_FNMATCH'",
290 'AM_SANITY_CHECK_CC', "automatically done by \`AC_PROG_CC'",
291 'AM_PROG_INSTALL', "use \`AC_PROG_INSTALL'",
292 'AM_EXEEXT', "use \`AC_EXEEXT'",
293 'AM_CYGWIN32', "use \`AC_CYGWIN'",
294 'AM_MINGW32', "use \`AC_MINGW32'",
295 'AM_FUNC_MKTIME', "use \`AC_FUNC_MKTIME'",
297 # These aren't quite obsolete.
298 # 'md_PATH_PROG',
301 # Regexp to match the above macros.
302 $obsolete_rx = '(' . join ('|', keys %obsolete_macros) . ')';
304 # This maps extensions onto language names.
305 %extension_map = ();
307 # This maps languages names onto properties.
308 %language_map = ();
310 # This holds all the files that would go in `dist_common' which we
311 # discovered while scanning configure.in. We might distribute these
312 # in the top-level Makefile.in.
313 %configure_dist_common = ();
317 # Initialize global constants and our list of languages that are
318 # internally supported.
319 &initialize_global_constants;
321 &register_language ('c', 'ansi-p=1', 'autodep=', 'flags=CFLAGS',
322 'compile=$(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)',
323 'compiler-name=COMPILE',
324 'output-arg=-c',
325 'c');
326 &register_language ('cxx', 'linker=CXXLINK', 'autodep=CXX', 'flags=CXXFLAGS',
327 'compile=$(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)',
328 'compiler-name=CXXCOMPILE',
329 'output-arg=-c -o $@',
330 'c++', 'cc', 'cpp', 'cxx', 'C');
331 &register_language ('objc', 'linker=OBJCLINK', 'autodep=OBJC',
332 'flags=OBJCFLAGS',
333 'compile=$(OBJC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_OBJCFLAGS) $(OBJCFLAGS)',
334 'compiler-name=OBJCCOMPILE',
335 'output-arg=-c -o $@',
336 'm');
337 &register_language ('header',
338 'h', 'H', 'hxx', 'h++', 'hh', 'hpp', 'inc');
340 # For now, yacc and lex can't be handled on a per-exe basis.
341 &register_language ('yacc', 'ansi-p=1',
342 'y');
343 &register_language ('yaccxx', 'linker=CXXLINK',
344 'y++', 'yy', 'yxx', 'ypp');
345 &register_language ('lex', 'ansi-p=1',
346 'l');
347 &register_language ('lexxx', 'linker=CXXLINK',
348 'l++', 'll', 'lxx', 'lpp');
350 &register_language ('asm',
351 'flags=CFLAGS', # FIXME: asmflags?
352 'compile=$(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)', # FIXME: a different compiler?
353 'compiler-name=COMPILE',
354 'output-arg=-c',
355 's', 'S');
357 &register_language ('f77', 'linker=F77LINK', 'flags=FFLAGS',
358 'compile=$(F77) $(AM_FFLAGS) $(FFLAGS)',
359 'compiler-name=F77COMPILE',
360 'output-arg=-c -o $@',
361 'f', 'for', 'f90');
362 &register_language ('ppf77', 'linker=F77LINK', 'flags=FFLAGS',
363 'compile=$(F77) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FFLAGS) $(FFLAGS)',
364 'compiler-name=PPF77COMPILE',
365 'output-arg=-c -o $@',
366 'F');
367 &register_language ('ratfor', 'linker=F77LINK',
368 'flags=RFLAGS', # FIXME also FFLAGS.
369 'compile=$(F77) $(AM_FFLAGS) $(FFLAGS) $(AM_RFLAGS) $(RFLAGS)',
370 'compiler-name=RCOMPILE',
371 'output-arg=-c -o $@',
372 'r');
373 # FIXME: for now we can't do dependency tracking for Java.
374 # autodep=GCJ
375 &register_language ('java', 'linker=GCJLINK', 'flags=GCJFLAGS',
376 'compile=$(GCJ) $(DEFS) $(INCLUDES) $(AM_GCJFLAGS) $(GCJFLAGS)',
377 'compiler-name=GCJCOMPILE',
378 'output-arg=-c -o $@',
379 'java', 'class', 'zip', 'jar');
382 # Parse command line.
383 &parse_arguments (@ARGV);
385 # Do configure.in scan only once.
386 &scan_configure;
388 die "automake: no \`Makefile.am' found or specified\n"
389 if ! @input_files;
391 # Now do all the work on each file.
392 foreach $am_file (@input_files)
394 if (! -f ($am_file . '.am'))
396 &am_error ("\`" . $am_file . ".am' does not exist");
398 else
400 &generate_makefile ($output_files{$am_file}, $am_file);
404 &am_conf_error ("AC_PROG_INSTALL must be used in configure.in")
405 if (! $seen_prog_install);
407 exit $exit_status;
410 ################################################################
412 # Parse command line.
413 sub parse_arguments
415 local (@arglist) = @_;
417 # Start off as gnu.
418 &set_strictness ('gnu');
420 while (@arglist)
422 if ($arglist[0] eq "--version")
424 print "automake (GNU $PACKAGE) $VERSION\n\n";
425 print "Copyright (C) 2000 Free Software Foundation, Inc.\n";
426 print "This is free software; see the source for copying conditions. There is NO\n";
427 print "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n";
428 print "Written by Tom Tromey <tromey\@cygnus.com>\n";
430 exit 0;
432 elsif ($arglist[0] eq "--help")
434 &usage;
436 elsif ($arglist[0] =~ /^--amdir=(.+)$/)
438 $am_dir = $1;
440 elsif ($arglist[0] eq '--amdir')
442 &require_argument (@arglist);
443 shift (@arglist);
444 $am_dir = $arglist[0];
446 elsif ($arglist[0] eq '--gnu')
448 &set_strictness ('gnu');
450 elsif ($arglist[0] eq '--gnits')
452 &set_strictness ('gnits');
454 elsif ($arglist[0] eq '--cygnus')
456 $cygnus_mode = 1;
458 elsif ($arglist[0] eq '--foreign')
460 &set_strictness ('foreign');
462 elsif ($arglist[0] eq '--include-deps')
464 $cmdline_use_dependencies = 1;
466 elsif ($arglist[0] eq '--ignore-deps' || $arglist[0] eq '-i')
468 $cmdline_use_dependencies = 0;
470 elsif ($arglist[0] eq '--no-force')
472 $force_generation = 0;
474 elsif ($arglist[0] eq '--force-missing')
476 $force_missing = 1;
478 elsif ($arglist[0] =~ /^--output-dir=(.*)$/)
480 # Set output directory.
481 $output_directory = $1;
483 elsif ($arglist[0] eq '--output-dir' || $arglist[0] eq '-o')
485 &require_argument (@arglist);
486 shift (@arglist);
487 $output_directory = $arglist[0];
489 elsif ($arglist[0] eq '--add-missing' || $arglist[0] eq '-a')
491 $add_missing = 1;
493 elsif ($arglist[0] eq '--copy' || $arglist[0] eq '-c')
495 $copy_missing = 1;
497 elsif ($arglist[0] eq '--verbose' || $arglist[0] eq '-v')
499 $verbose = 1;
501 elsif ($arglist[0] eq '--')
503 # Stop option processing.
504 shift (@arglist);
505 push (@input_files, @arglist);
506 last;
508 elsif ($arglist[0] =~ /^-/)
510 die "automake: unrecognized option -- \`$arglist[0]'\nTry \`automake --help' for more information.\n";
512 else
514 # Handle $local:$input syntax. Note that we only examine
515 # the first ":" file to see if it is automake input; the
516 # rest are just taken verbatim. We still keep all the
517 # files around for dependency checking, however.
518 local ($local, $input, @rest) = split (/:/, $arglist[0]);
519 if (! $input)
521 $input = $local;
523 else
525 # Strip .in; later on .am is tacked on. That is how
526 # the automake input file is found. Maybe not the
527 # best way, but it is easy to explain. FIXME: should
528 # be error if .in is missing.
529 $input =~ s/\.in$//;
531 push (@input_files, $input);
532 $output_files{$input} = join (':', ($local, @rest));
535 shift (@arglist);
538 # Take global strictness from whatever we currently have set.
539 $default_strictness = $strictness;
540 $default_strictness_name = $strictness_name;
543 # Ensure argument exists, or die.
544 sub require_argument
546 local ($arg, @arglist) = @_;
547 die "automake: no argument given for option \`$arg'\n"
548 if ! @arglist;
551 ################################################################
553 # Generate a Makefile.in given the name of the corresponding Makefile and
554 # the name of the file output by config.status.
555 sub generate_makefile
557 local ($output, $makefile) = @_;
559 ($am_file_name = $makefile) =~ s/^.*\///;
560 $in_file_name = $am_file_name . '.in';
561 $am_file_name .= '.am';
563 # $OUTPUT is encoded. If it contains a ":" then the first element
564 # is the real output file, and all remaining elements are input
565 # files. We don't scan or otherwise deal with these input file,
566 # other than to mark them as dependencies. See scan_configure for
567 # details.
568 local (@secondary_inputs);
569 ($output, @secondary_inputs) = split (/:/, $output);
571 &initialize_per_input;
572 $relative_dir = &dirname ($output);
573 $am_relative_dir = &dirname ($makefile);
575 # At the toplevel directory, we might need config.guess, config.sub
576 # or libtool scripts (ltconfig and ltmain.sh).
577 if ($relative_dir eq '.')
579 # libtool requires some files.
580 &require_conf_file_with_conf_line ($libtool_line, $FOREIGN,
581 @libtoolize_files)
582 if $seen_libtool;
584 # AC_CANONICAL_HOST and AC_CANONICAL_SYSTEM need config.guess and
585 # config.sub.
586 &require_config_file ($FOREIGN, 'config.guess', 'config.sub')
587 if $seen_canonical;
590 # We still need Makefile.in here, because sometimes the `dist'
591 # target doesn't re-run automake.
592 if ($am_relative_dir eq $relative_dir)
594 # Only distribute the files if they are in the same subdir as
595 # the generated makefile.
596 &push_dist_common ($in_file_name, $am_file_name);
599 push (@sources, '$(SOURCES)')
600 if &variable_defined ('SOURCES');
601 push (@objects, '$(OBJECTS)')
602 if &variable_defined ('OBJECTS');
604 &read_main_am_file ($makefile . '.am');
605 if (&handle_options)
607 # Fatal error. Just return, so we can continue with next file.
608 return;
611 # Must do this after reading .am file. See read_main_am_file to
612 # understand weird tricks we play there with variables.
613 &define_variable ('subdir', $relative_dir);
615 # Check first, because we might modify some state.
616 &check_cygnus;
617 &check_gnu_standards;
618 &check_gnits_standards;
620 &handle_configure ($output, $makefile, @secondary_inputs);
621 &handle_gettext;
622 &handle_libraries;
623 &handle_ltlibraries;
624 &handle_programs;
625 &handle_scripts;
627 &handle_built_sources;
629 # This must be run after all the sources are scanned.
630 &finish_languages;
632 # Re-init SOURCES and OBJECTS. FIXME: other code shouldn't depend
633 # on this (but currently does).
634 $contents{'SOURCES'} = join (' ', @sources);
635 $contents{'OBJECTS'} = join (' ', @objects);
636 &define_pretty_variable ('DIST_SOURCES', '', @dist_sources);
638 &handle_multilib;
639 &handle_texinfo;
640 &handle_emacs_lisp;
641 &handle_python;
642 &handle_java;
643 &handle_man_pages;
644 &handle_data;
645 &handle_headers;
646 &handle_subdirs;
647 &handle_tags;
648 &handle_minor_options;
649 &handle_dependencies;
650 &handle_tests;
652 # This must come after most other rules.
653 &handle_dist ($makefile);
655 &handle_footer;
656 &handle_merge_targets ($output);
657 &handle_installdirs;
658 &handle_clean;
659 &handle_phony;
661 &check_typos;
663 if (! -d ($output_directory . '/' . $am_relative_dir))
665 mkdir ($output_directory . '/' . $am_relative_dir, 0755);
668 local ($out_file) = $output_directory . '/' . $makefile . ".in";
669 if (! $force_generation && -e $out_file)
671 local ($am_time) = (stat ($makefile . '.am'))[9];
672 local ($in_time) = (stat ($out_file))[9];
673 # FIXME: should cache these times.
674 local ($conf_time) = (stat ('configure.in'))[9];
675 # FIXME: how to do unsigned comparison?
676 if ($am_time < $in_time || $am_time < $conf_time)
678 # No need to update.
679 return;
681 if (-f 'aclocal.m4')
683 local ($acl_time) = (stat _)[9];
684 return if ($am_time < $acl_time);
688 if (! open (GM_FILE, "> " . $out_file))
690 warn "automake: ${am_file}.in: cannot write: $!\n";
691 $exit_status = 1;
692 return;
694 print "automake: creating ", $makefile, ".in\n" if $verbose;
696 print GM_FILE $output_vars;
697 # We make sure that `all:' is the first target.
698 print GM_FILE $output_all;
699 print GM_FILE $output_header;
700 print GM_FILE $output_rules;
701 print GM_FILE $output_trailer;
703 if (! close (GM_FILE))
705 warn "automake: $am_file.in: cannot close: $!\n";
706 $exit_status = 1;
707 return;
711 ################################################################
713 # Handle AUTOMAKE_OPTIONS variable. Return 1 on error, 0 otherwise.
714 sub handle_options
716 if (&variable_defined ('AUTOMAKE_OPTIONS'))
718 foreach (&variable_value_as_list ('AUTOMAKE_OPTIONS', ''))
720 $options{$_} = 1;
721 if ($_ eq 'gnits' || $_ eq 'gnu' || $_ eq 'foreign')
723 &set_strictness ($_);
725 elsif ($_ eq 'cygnus')
727 $cygnus_mode = 1;
729 elsif (/ansi2knr/)
731 # An option like "../lib/ansi2knr" is allowed. With
732 # no path prefix, we assume the required programs are
733 # in this directory. We save the actual option for
734 # later.
735 $options{'ansi2knr'} = $_;
737 elsif ($_ eq 'no-installman' || $_ eq 'no-installinfo'
738 || $_ eq 'dist-shar' || $_ eq 'dist-zip'
739 || $_ eq 'dist-tarZ' || $_ eq 'dist-bzip2'
740 || $_ eq 'dejagnu' || $_ eq 'no-texinfo.tex'
741 || $_ eq 'readme-alpha' || $_ eq 'check-news'
742 || $_ eq 'subdir-objects' || $_ eq 'nostdinc')
744 # Explicitly recognize these.
746 elsif ($_ eq 'no-dependencies')
748 $use_dependencies = 0;
750 elsif (/([0-9]+)\.([0-9]+)([a-z])?/)
752 # Got a version number.
754 local ($rmajor, $rminor, $ralpha) = ($1, $2, $3);
756 if ($VERSION !~ /([0-9]+)\.([0-9]+)([a-z])?/)
758 print STDERR
759 "automake: programming error: version is incorrect\n";
760 exit 1;
762 local ($tmajor, $tminor, $talpha) = ($1, $2, $3);
764 # 2.0 is better than 1.0.
765 # 1.2 is better than 1.1.
766 # 1.2a is better than 1.2.
767 if ($rmajor > $tmajor
768 || ($rmajor == $tmajor && $rminor > $tminor)
769 || ($rminor == $tminor && $rminor == $tminor
770 && $ralpha gt $talpha))
772 &am_line_error ('AUTOMAKE_OPTIONS',
773 "require version $_, only have $VERSION");
774 return 1;
777 else
779 &am_line_error ('AUTOMAKE_OPTIONS',
780 "option \`" . $_ . "\' not recognized");
785 if ($strictness == $GNITS)
787 $options{'readme-alpha'} = 1;
788 $options{'check-news'} = 1;
791 return 0;
794 # Return object extension. Just once, put some code into the output.
795 # Argument is the name of the output file
796 sub get_object_extension
798 local ($out) = @_;
800 # Maybe require libtool library object files.
801 local ($extension) = '.o';
802 $extension = '.$(OBJEXT)' if $seen_objext;
803 $extension = '.lo' if ($out =~ /\.la$/);
805 if (! $included_generic_compile)
807 # Boilerplate.
808 local ($xform) = '';
809 if (! defined $options{'nostdinc'})
811 $xform = ' -I. -I\$(srcdir)';
813 if (&variable_defined ('CONFIG_HEADER'))
815 local ($one_hdr);
816 foreach $one_hdr (split (' ',
817 &variable_value ('CONFIG_HEADER')))
819 local ($var);
820 ($var = &dirname ($one_hdr)) =~ s/(\W)/\\$1/g;
821 $xform .= ' -I' . $var;
825 $xform = 's/\@DEFAULT_INCLUDES\@/' . $xform . '/go;';
826 $output_vars .= &file_contents_with_transform ($xform,
827 'comp-vars');
829 $xform = $seen_objext ? 's/^OBJEXT//;' : 's/^OBJEXT.*$//;';
830 $output_rules .= &file_contents_with_transform ($xform, 'compile');
832 &push_phony_cleaners ('compile');
834 # If using X, include some extra variable definitions. NOTE
835 # we don't want to force these into CFLAGS or anything,
836 # because not all programs will necessarily use X.
837 if ($seen_path_xtra)
839 local ($var);
840 foreach $var ('X_CFLAGS', 'X_LIBS', 'X_EXTRA_LIBS', 'X_PRE_LIBS')
842 &define_configure_variable ($var);
846 push (@suffixes, '.c', '.o');
847 push (@suffixes, '.obj') if $seen_objext;
848 push (@clean, 'compile');
850 $included_generic_compile = 1;
853 if ($seen_libtool && ! $included_libtool_compile)
855 # Output the libtool compilation rules.
856 $output_rules .= &file_contents ('libtool');
858 &push_phony_cleaners ('libtool');
860 push (@suffixes, '.lo');
861 push (@clean, 'libtool');
863 $included_libtool_compile = 1;
866 # Check for automatic de-ANSI-fication.
867 if (defined $options{'ansi2knr'})
869 $extension = '$U' . $extension;
870 if (! $included_knr_compile)
872 if (! $am_c_prototypes)
874 &am_line_error ('AUTOMAKE_OPTIONS',
875 "option \`ansi2knr' in use but \`AM_C_PROTOTYPES' not in configure.in");
876 &keyed_aclocal_warning ('AM_C_PROTOTYPES');
877 # Only give this error once.
878 $am_c_prototypes = 1;
881 # Only require ansi2knr files if they should appear in
882 # this directory.
883 if ($options{'ansi2knr'} eq 'ansi2knr')
885 &require_file_with_line ('AUTOMAKE_OPTIONS', $FOREIGN,
886 'ansi2knr.c', 'ansi2knr.1');
887 $output_rules .= &file_contents ('kr-extra');
888 push (@clean, 'krextra');
889 &push_phony_cleaners ('krextra');
892 # Generate rules to build ansi2knr. If it is in some
893 # other directory, then generate dependencies but have the
894 # rule just run elsewhere.
895 $objext = $seen_objext ? ".\$(OBJEXT)" : ".o";
896 $output_rules .= ($options{'ansi2knr'} . ': '
897 . $options{'ansi2knr'} . $objext . "\n");
898 if ($options{'ansi2knr'} eq 'ansi2knr')
900 $output_rules .= ("\t\$(LINK) ansi2knr" . $objext
901 . " \$(LIBS)\n"
902 . "ansi2knr" . $objext
903 . ": \$(CONFIG_HEADER)\n\n");
905 else
907 $output_rules .= ("\tcd " . &dirname ($options{'ansi2knr'})
908 . " && \$(MAKE) \$(AM_MAKEFLAGS) "
909 . "ansi2knr\n\n");
910 # This is required for non-GNU makes.
911 $output_rules .= ($options{'ansi2knr'} . $objext . ":\n");
912 $output_rules .= ("\tcd " . &dirname ($options{'ansi2knr'})
913 . " && \$(MAKE) \$(AM_MAKEFLAGS)"
914 . " ansi2knr" . $objext . "\n\n");
917 # Make sure ansi2knr can be found: if no path specified,
918 # specify "./".
919 if ($options{'ansi2knr'} eq 'ansi2knr')
921 # Substitution from AM_C_PROTOTYPES. This makes it be
922 # built only when necessary.
923 &define_configure_variable ('ANSI2KNR');
924 # ansi2knr needs to be built before subdirs, so unshift it.
925 unshift (@all, '$(ANSI2KNR)');
927 else
929 # Found in another directory.
930 &define_variable ("ANSI2KNR", $options{'ansi2knr'});
933 $output_rules .= &file_contents ('clean-kr');
935 push (@clean, 'kr');
936 &push_phony_cleaners ('kr');
938 $included_knr_compile = 1;
942 return $extension;
945 # Call finish function for each language that was used.
946 sub finish_languages
948 local ($ltcompile, $ltlink) = &libtool_compiler;
950 local ($ext, $name, $lang, %done);
951 local ($non_c) = 1;
952 foreach $ext (sort keys %extension_seen)
954 $lang = $extension_map{$ext};
956 # Generate the appropriate rules for this extension. If
957 # dependency tracking was requested, and this extension
958 # supports it, then we don't generate the rule here.
959 local ($comp) = '';
961 if ($use_dependencies && $language_map{$lang . '-autodep'} ne 'no')
963 # Don't generate the rule, but still generate the variables.
964 if (defined $language_map{$lang . '-compile'})
966 $comp = $language_map{$lang . '-compile'};
969 elsif (defined $language_map{$lang . '-compile'})
971 $comp = $language_map{$lang . '-compile'};
973 local ($outarg) = $language_map{$lang . '-output-arg'};
974 if ($language_map{$lang . '-flags'} eq 'CFLAGS')
976 # C compilers don't always support -c -o.
977 if (defined $options{'subdir-objects'})
979 $outarg .= ' -o $@';
983 local ($full) = ("\t\$("
984 . $language_map{$lang . '-compiler-name'}
985 . ") "
986 . $outarg);
987 $output_rules .= (".$ext.o:\n"
988 . $full
989 . " \$<\n");
990 # FIXME: Using cygpath should be somehow conditional.
991 $output_rules .= (".$ext.obj:\n"
992 . $full
993 . " \`cygpath -w \$<\`\n")
994 if $seen_objext;
995 $output_rules .= (".$ext.lo:\n"
996 . "\t\$(LT"
997 . $language_map{$lang . '-compiler-name'}
998 . ") "
999 . $language_map{$lang . '-output-arg'}
1000 # We can always use -c -o with libtool.
1001 . ($language_map{$lang . '-flags'} eq 'CFLAGS'
1002 ? ' -o $@' : '')
1003 . " \$<\n")
1004 if $seen_libtool;
1007 push (@suffixes, '.' . $ext);
1009 # The rest of the loop is done once per language.
1010 next if defined $done{$lang};
1011 $done{$lang} = 1;
1013 $non_c = 0 if $lang !~ /(objc|cxx|f77|ratfor)$/;
1015 if ($comp ne '')
1017 &define_compiler_variable ($language_map{$lang . '-compiler-name'},
1018 $ltcompile, $comp);
1020 # The compiler's flag must be a configure variable.
1021 if (defined $language_map{$lang . '-flags'})
1023 &define_configure_variable ($language_map{$lang . '-flags'});
1026 # Compute the function name of the finisher and then call it.
1027 $name = 'lang_' . $lang . '_finish';
1028 & $name ();
1031 # If the project is entirely C++ or entirely Fortran 77, don't
1032 # bother with the C stuff. But if anything else creeps in, then use
1033 # it.
1034 if (! $non_c || scalar keys %suffix_rules > 0)
1036 if (! defined $done{'c'})
1038 &define_configure_variable ($language_map{'c-flags'});
1039 &define_compiler_variable ($language_map{'c-compiler-name'},
1040 $ltcompile,
1041 $language_map{'c-compile'});
1043 &define_variable ('CCLD', '$(CC)');
1044 &define_variable ('LINK', $ltlink . '$(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@');
1048 # Output a rule to build from a YACC source. The output from YACC is
1049 # compiled with C or C++, depending on the extension of the YACC file.
1050 sub output_yacc_build_rule
1052 local ($yacc_suffix, $use_ylwrap, $c_suffix) = @_;
1054 local ($suffix);
1055 ($suffix = $yacc_suffix) =~ tr/y/c/;
1056 push (@suffixes, $yacc_suffix, $suffix);
1058 # Generate rule for c/c++.
1059 $output_rules .= "$yacc_suffix$suffix:\n\t";
1061 if ($use_ylwrap)
1063 $output_rules .= ('$(SHELL) $(YLWRAP)'
1064 . ' "$(YACC)" $< y.tab.c $*' . $suffix
1065 . ' y.tab.h $*.h -- $(AM_YFLAGS) $(YFLAGS)');
1067 else
1069 $output_rules .= ('$(YACC) $(AM_YFLAGS) $(YFLAGS) $< && mv y.tab.c $*'
1070 . $suffix . "\n"
1071 . "\tif test -f y.tab.h; then \\\n"
1072 . "\tif cmp -s y.tab.h \$*.h; then rm -f y.tab.h; else mv y.tab.h \$*.h; fi; \\\n"
1073 . "\telse :; fi");
1075 $output_rules .= "\n";
1078 sub output_lex_build_rule
1080 local ($lex_suffix, $use_ylwrap) = @_;
1081 local ($c_suffix);
1083 ($c_suffix = $lex_suffix) =~ tr/l/c/;
1084 push (@suffixes, $lex_suffix);
1085 &define_configure_variable ('LEX_OUTPUT_ROOT');
1086 &define_configure_variable ('LEXLIB');
1087 $output_rules .= "$lex_suffix$c_suffix:\n\t";
1089 if ($use_ylwrap)
1091 # Is the $@ correct here? If so, why not use it in the ylwrap
1092 # build rule for yacc above?
1093 $output_rules .= '$(SHELL) $(YLWRAP)'
1094 . ' "$(LEX)" $< $(LEX_OUTPUT_ROOT).c $@ -- $(AM_LFLAGS) $(LFLAGS)';
1096 else
1098 $output_rules .= '$(LEX) $(AM_LFLAGS) $(LFLAGS) $< && mv $(LEX_OUTPUT_ROOT).c $@';
1100 $output_rules .= "\n";
1104 # Check to make sure a source defined in LIBOBJS is not explicitly
1105 # mentioned. This is a separate function (as opposed to being inlined
1106 # in handle_source_transform) because it isn't always appropriate to
1107 # do this check.
1108 sub check_libobjs_sources
1110 local ($one_file, $unxformed) = @_;
1112 local ($prefix, $file, @files);
1113 foreach $prefix ('', 'EXTRA_', 'dist_', 'nodist_',
1114 'dist_EXTRA_', 'nodist_EXTRA_')
1116 if (&variable_defined ($prefix . $one_file . '_SOURCES'))
1118 @files = &variable_value_as_list (($prefix
1119 . $one_file . '_SOURCES'),
1120 'all');
1122 elsif ($prefix eq '')
1124 @files = ($unxformed . '.c');
1126 else
1128 next;
1131 foreach $file (@files)
1133 if (defined $libsources{$file})
1135 &am_line_error ($prefix . $one_file . '_SOURCES',
1136 "automatically discovered file \`$file' should not be explicitly mentioned");
1142 # Does much of the actual work for handle_source_transform.
1143 # Arguments are:
1144 # name of resulting executable or library ("derived")
1145 # object extension (e.g., `$U.lo')
1146 # list of source files to transform
1147 # Result is a list
1148 # first element is name of linker to use (empty string for default linker)
1149 # remaining elements are names of objects
1150 sub handle_single_transform_list
1152 local ($var, $derived, $obj, @files) = @_;
1153 local (@result) = ();
1154 local ($nonansi_obj) = $obj;
1155 $nonansi_obj =~ s/_//g;
1156 local (%linkers_used) = ();
1157 if (@files > 0)
1159 # Turn sources into objects.
1160 foreach (@files)
1162 # Configure substitutions in _SOURCES variables are errors.
1163 if (/^\@.*\@$/)
1165 &am_line_error ($var, "$var includes configure substitution \`$_'");
1166 next;
1169 # If the source file is in a subdirectory then the `.o' is
1170 # put into the current directory.
1172 # Split file name into base and extension.
1173 local ($full, $directory, $base, $extension, $linker, $object);
1174 next if ! /^((.*)\/)?([^\/]*)\.(.*)$/;
1175 $full = $_;
1176 $directory = $2;
1177 ++$sourcedirs{$2} if ($2);
1178 $base = $3;
1179 $extension = $4;
1181 local ($xbase) = $base;
1183 # We must generate a rule for the object if it requires
1184 # its own flags.
1185 local ($rule) = '';
1186 local ($renamed) = 0;
1188 $extension = &derive_suffix ($extension);
1189 local ($lang) = $extension_map{$extension};
1190 if ($lang)
1192 &saw_extension ($extension);
1193 # Found the language, so see what it says.
1194 local ($subr) = 'lang_' . $lang . '_rewrite';
1195 # Note: computed subr call.
1196 local ($r) = & $subr ($directory, $base, $extension);
1197 # Skip this entry if we were asked not to process it.
1198 next if $r == $LANG_IGNORE;
1200 # Now extract linker and other info.
1201 $linker = $language_map{$lang . '-linker'};
1203 local ($this_obj_ext);
1204 if ($language_map{$lang . '-ansi-p'})
1206 $object = $base . $obj;
1207 $this_obj_ext = $obj;
1209 else
1211 $object = $base . $nonansi_obj;
1212 $this_obj_ext = $nonansi_obj;
1215 if ($language_map{$lang . '-flags'} ne ''
1216 && &variable_defined ($derived . '_'
1217 . $language_map{$lang . '-flags'}))
1219 # We have a per-executable flag in effect for this
1220 # object. In this case we rewrite the object's
1221 # name to ensure it is unique. We also require
1222 # the `compile' program to deal with compilers
1223 # where `-c -o' does not work.
1225 # We choose the name `DERIVED-OBJECT' to ensure
1226 # (1) uniqueness, and (2) continuity between
1227 # invocations. However, this will result in a
1228 # name that is too long for losing systems, in
1229 # some situations. So we provide _SHORTNAME to
1230 # override.
1232 local ($dname) = $derived;
1233 if (&variable_defined ($derived . '_SHORTNAME'))
1235 # FIXME: should use the same conditional as
1236 # the _SOURCES variable. But this is really
1237 # silly overkill -- nobody should have
1238 # conditional shortnames.
1239 $dname = &variable_value ($derived . '_SHORTNAME');
1241 $object = $dname . '-' . $object;
1243 &require_file ($FOREIGN, 'compile')
1244 if $lang eq 'c';
1246 if (! defined $language_map{$lang . '-compile'})
1248 print STDERR "automake: programming error: $lang flags defined without compiler\n";
1249 exit 1;
1251 # Compute the rule to compile this object.
1252 local ($flag) = $language_map{$lang . '-flags'};
1253 local ($val) = "(${derived}_${flag}";
1254 ($rule = $language_map{$lang . '-compile'}) =~
1255 s/\(AM_$flag/$val/;
1257 $rule .= ' ' . $language_map{$lang . '-output-arg'};
1258 # For C we have to add the -o, because the
1259 # standard rule doesn't include it.
1260 if ($language_map{$lang . '-flags'} eq 'CFLAGS')
1262 $rule .= ' -o $@';
1265 $renamed = 1;
1268 # If rewrite said it was ok, put the object into a
1269 # subdir.
1270 if ($r == $LANG_SUBDIR && $directory ne '')
1272 $object = $directory . '/' . $object;
1273 $xbase = $directory . '/' . $base;
1276 # If doing dependency tracking, then we can't print
1277 # the rule. Also, if we have a subdir object, we need
1278 # to generate an explicit rule.
1279 if (($use_dependencies
1280 && $rule ne ''
1281 && $language_map{$lang . '-autodep'} ne 'no')
1282 || ($r == $LANG_SUBDIR && $directory ne ''))
1284 $rule = '';
1285 local ($obj_sans_ext) = substr ($object, 0,
1286 - length ($this_obj_ext));
1287 $lang_specific_files{$lang} .= (' ' . $derived
1288 . ' ' . $full
1289 . ' ' . $obj_sans_ext);
1292 elsif ($extension eq 'o')
1294 # This is probably the result of a direct suffix rule.
1295 # In this case we just accept the rewrite. FIXME:
1296 # this fails if we want libtool objects.
1297 $object = $base . '.' . $extension;
1298 $linker = '';
1300 else
1302 # No error message here. Used to have one, but it was
1303 # very unpopular.
1304 next;
1307 $linkers_used{$linker} = 1;
1309 push (@result, $object);
1311 if (defined $object_map{$object})
1313 if ($object_map{$object} ne $full)
1315 &am_error ("object \`$object' created by \`$full' and \`$object_map{$object}'");
1318 else
1320 local (@dep_list) = ();
1321 $object_map{$object} = $full;
1323 # If file is in subdirectory, we need explicit
1324 # dependency.
1325 if ($directory ne '' || $renamed)
1327 push (@dep_list, $full);
1330 # If resulting object is in subdir, we need to make
1331 # sure the subdir exists at build time.
1332 if ($object =~ /\//)
1334 # FIXME: check that $DIRECTORY is somewhere in the
1335 # project
1337 # We don't allow `..' in object file names for
1338 # *any* source, not just Java. For Java it just
1339 # doesn't make sense, but in general it is
1340 # a problem because we can't pick a good name for
1341 # the .deps entry.
1342 if ($object =~ /(\/|^)\.\.\//)
1344 &am_error ("\`$full' contains \`..' component but should not");
1347 push (@dep_list, $directory . '/.dirstamp');
1349 # If we're generating dependencies, we also want
1350 # to make sure that the appropriate subdir of the
1351 # .deps directory is created.
1352 if ($use_dependencies)
1354 push (@dep_list, '.deps/' . $directory . '/.dirstamp');
1357 if (! defined $directory_map{$directory})
1359 $directory_map{$directory} = 1;
1360 $output_rules .= ($directory . "/.dirstamp:\n"
1361 . "\t\@\$(mkinstalldirs) $directory\n"
1362 . "\t\@: > $directory/.dirstamp\n");
1363 if ($use_dependencies)
1365 $output_rules .= ('.deps/' . $directory
1366 . "/.dirstamp:\n"
1367 . "\t\@\$(mkinstalldirs) .deps/$directory\n"
1368 . "\t\@: > .deps/$directory/.dirstamp\n");
1373 &pretty_print_rule ($object . ':', "\t", @dep_list)
1374 if scalar @dep_list > 0 || $rule ne '';
1376 # Print the rule if we have one.
1377 if ($rule ne '')
1379 # Turn `$@' into name of our object file.
1380 local ($xform);
1381 ($xform = $object) =~ s,/,\\/,g;
1382 $rule =~ s/\$\@/$xform/;
1384 # We cannot use $< here since this is an explicit
1385 # rule and not all makes handle that.
1386 $rule .= " \`test -f $full || echo '\$(srcdir)/'\`$full";
1388 # FIXME: handle .lo and .obj as well.
1389 $output_rules .= "\t" . $rule . "\n";
1393 # Transform .o or $o file into .P file (for automatic
1394 # dependency code).
1395 local ($depfile) = $object;
1396 $depfile =~ s/\.([^.]*)$/.P$1/;
1397 $depfile =~ s/\$\(OBJEXT\)$/o/ if $seen_objext;
1398 $dep_files{'$(DEPDIR)/' . $depfile} = 1;
1402 return (&resolve_linker (%linkers_used), @result);
1405 # Handle SOURCE->OBJECT transform for one program or library.
1406 # Arguments are:
1407 # canonical (transformed) name of object to build
1408 # actual name of object to build
1409 # object extension (ie either `.o' or `$o'.
1410 # Return result is name of linker variable that must be used.
1411 # Empty return means just use `LINK'.
1412 sub handle_source_transform
1414 # one_file is canonical name. unxformed is given name. obj is
1415 # object extension.
1416 local ($one_file, $unxformed, $obj) = @_;
1418 local ($linker) = '';
1420 if (&variable_defined ($one_file . "_OBJECTS"))
1422 &am_line_error ($one_file . '_OBJECTS',
1423 $one_file . '_OBJECTS', 'should not be defined');
1424 # No point in continuing.
1425 return;
1428 local (@files, @result, $prefix, $temp, $xpfx);
1429 local (%used_pfx) = ();
1430 foreach $prefix ('', 'EXTRA_', 'dist_', 'nodist_',
1431 'dist_EXTRA_', 'nodist_EXTRA_')
1433 # We are going to define _OBJECTS variables using the prefix.
1434 # Then we glom them all together. So we can't use the null
1435 # prefix here as we need it later.
1436 $xpfx = ($prefix eq '') ? 'am_' : $prefix;
1438 @files = ();
1439 local ($var) = $prefix . $one_file . "_SOURCES";
1440 if (&variable_defined ($var))
1442 # Keep track of which prefixes we saw.
1443 $used_pfx{$xpfx} = 1
1444 unless $prefix =~ /EXTRA_/;
1446 push (@sources, '$(' . $prefix . $one_file . "_SOURCES)");
1447 push (@objects, '$(' . $xpfx . $one_file . "_OBJECTS)")
1448 unless $prefix =~ /EXTRA_/;
1449 push (@dist_sources, '$(' . $prefix . $one_file . "_SOURCES)")
1450 unless $prefix =~ /^nodist_/;
1451 local (@conds) = &variable_conditions ($var);
1452 if (! @conds)
1454 @files = &variable_value_as_list ($var, '');
1456 else
1458 local ($cond);
1459 foreach $cond (@conds)
1461 @files = &variable_value_as_list ($var, $cond);
1462 ($temp, @result) =
1463 &handle_single_transform_list ($var, $one_file, $obj,
1464 @files);
1465 $linker = $temp if $linker eq '';
1467 # Define _OBJECTS conditionally.
1468 &define_pretty_variable ($xpfx . $one_file . '_OBJECTS',
1469 $cond, @result)
1470 unless $prefix =~ /EXTRA_/;
1473 next;
1477 # Avoid defining needless variables.
1478 next if (scalar @files == 0);
1480 ($temp, @result) = &handle_single_transform_list ($var, $one_file,
1481 $obj, @files);
1482 $linker = $temp if $linker eq '';
1483 &define_pretty_variable ($xpfx . $one_file . "_OBJECTS", '', @result)
1484 unless $prefix =~ /EXTRA_/;
1487 local (@keys) = sort keys %used_pfx;
1488 if (scalar @keys == 0)
1490 &define_variable ($one_file . "_SOURCES", $unxformed . ".c");
1491 push (@sources, $unxformed . '.c');
1492 push (@dist_sources, $unxformed . '.c');
1493 push (@objects, $unxformed . $obj);
1494 push (@files, $unxformed . '.c');
1496 ($temp, @result) = &handle_single_transform_list ($one_file . '_SOURCES',
1497 $one_file, $obj,
1498 @files);
1499 $linker = $temp if $linker eq '';
1500 &define_pretty_variable ($one_file . "_OBJECTS", '', @result)
1502 else
1504 grep ($_ = '$(' . $_ . $one_file . '_OBJECTS)', @keys);
1505 &define_pretty_variable ($one_file . '_OBJECTS', '', @keys);
1508 return $linker;
1511 # Handle the BUILT_SOURCES variable.
1512 sub handle_built_sources
1514 return unless &variable_defined ('BUILT_SOURCES');
1516 local (@sources) = &variable_value_as_list ('BUILT_SOURCES', 'all');
1517 local ($s);
1518 foreach $s (@sources)
1520 if (/^\@.*\@$/)
1522 # FIXME: is this really the right thing to do?
1523 &am_line_error ('BUILT_SOURCES',
1524 "\`BUILT_SOURCES' should not contain a configure substitution");
1525 last;
1530 # Special-case @ALLOCA@ and @LIBOBJS@ in _LDADD or _LIBADD variables.
1531 # Also, generate _DEPENDENCIES variable if appropriate.
1532 # Arguments are:
1533 # transformed name of object being built, or empty string if no object
1534 # name of _LDADD/_LIBADD-type variable to examine
1535 # boolean (lex_seen) which is true if a lex source file was seen in this
1536 # object. valid only for LDADDs, not LIBADDs.
1537 # Returns 1 if LIBOBJS seen, 0 otherwise.
1538 sub handle_lib_objects
1540 local ($xname, $var, $lex_seen) = @_;
1541 local ($ret);
1543 die "automake: programming error 1 in handle_lib_objects\n"
1544 if ! &variable_defined ($var);
1546 die "automake: programming error 2 in handle_lib_objects\n"
1547 if $lex_seen && $var =~ /LIBADD/;
1549 local (@conds) = &variable_conditions ($var);
1550 if (! @conds)
1552 $ret = &handle_lib_objects_cond ($xname, $var, $lex_seen, '');
1554 else
1556 local ($cond);
1557 $ret = 0;
1558 foreach $cond (@conds)
1560 if (&handle_lib_objects_cond ($xname, $var, $lex_seen, $cond))
1562 $ret = 1;
1567 return $ret;
1570 # Subroutine of handle_lib_objects: handle a particular condition.
1571 sub handle_lib_objects_cond
1573 local ($xname, $var, $lex_seen, $cond) = @_;
1575 # We recognize certain things that are commonly put in LIBADD or
1576 # LDADD.
1577 local ($lsearch);
1578 local (@dep_list) = ();
1580 local ($seen_libobjs) = 0;
1581 local ($flagvar) = 0;
1583 foreach $lsearch (&variable_value_as_list ($var, $cond))
1585 # Skip -lfoo and -Ldir; these are explicitly allowed.
1586 next if $lsearch =~ /^-[lL]/;
1587 if (! $flagvar && $lsearch =~ /^-/)
1589 if ($var =~ /^(.*)LDADD$/)
1591 # Skip -dlopen and -dlpreopen; these are explicitly allowed.
1592 next if $lsearch =~ /^-dl(pre)?open$/;
1593 &am_line_error ($var, "linker flags such as \`$lsearch' belong in \`${1}LDFLAGS");
1595 else
1597 # Only get this error once.
1598 $flagvar = 1;
1599 &am_line_error ($var, "linker flags such as \`$lsearch' belong in \`${1}LDFLAGS");
1603 # Assume we have a file of some sort, and push it onto the
1604 # dependency list. Autoconf substitutions are not pushed;
1605 # rarely is a new dependency substituted into (eg) foo_LDADD
1606 # -- but "bad things (eg -lX11) are routinely substituted.
1607 # Note that LIBOBJS and ALLOCA are exceptions to this rule,
1608 # and handled specially below.
1609 push (@dep_list, $lsearch)
1610 unless $lsearch =~ /^\@.*\@$/;
1612 # Automatically handle @LIBOBJS@ and @ALLOCA@. Basically this
1613 # means adding entries to dep_files.
1614 if ($lsearch =~ /^\@(LT)?LIBOBJS\@$/)
1616 local ($myobjext) = ($1 ? 'l' : '') . 'o';
1618 push (@dep_list, $lsearch);
1619 $seen_libobjs = 1;
1620 if (! keys %libsources
1621 && ! &variable_defined ($1 . 'LIBOBJS'))
1623 &am_line_error ($var, "\@$1" . "LIBOBJS\@ seen but never set in \`configure.in'");
1626 local ($iter, $rewrite);
1627 foreach $iter (keys %libsources)
1629 if ($iter =~ /\.([cly])$/)
1631 &saw_extension ($1);
1632 &saw_extension ('c');
1635 if ($iter =~ /\.h$/)
1637 &require_file_with_line ($var, $FOREIGN, $iter);
1639 elsif ($iter ne 'alloca.c')
1641 ($rewrite = $iter) =~ s/\.c$/.P$myobjext/;
1642 $dep_files{'$(DEPDIR)/' . $rewrite} = 1;
1643 ($rewrite = $iter) =~ s/(\W)/\\$1/g;
1644 $rewrite = "^" . $rewrite . "\$";
1645 # Only require the file if it is not a built source.
1646 if (! &variable_defined ('BUILT_SOURCES')
1647 || ! grep (/$rewrite/,
1648 &variable_value_as_list ('BUILT_SOURCES',
1649 'all')))
1651 &require_file_with_line ($var, $FOREIGN, $iter);
1656 elsif ($lsearch =~ /^\@(LT)?ALLOCA\@$/)
1658 local ($myobjext) = ($1 ? 'l' : '') . 'o';
1660 push (@dep_list, $lsearch);
1661 &am_line_error ($var,
1662 "\@$1" . "ALLOCA\@ seen but \`AC_FUNC_ALLOCA' not in \`configure.in'")
1663 if ! defined $libsources{'alloca.c'};
1664 $dep_files{'$(DEPDIR)/alloca.P' . $myobjext} = 1;
1665 &require_file_with_line ($var, $FOREIGN, 'alloca.c');
1666 &saw_extension ('c');
1670 if ($xname ne '' && ! &variable_defined ($xname . '_DEPENDENCIES', $cond))
1672 &define_pretty_variable ($xname . '_DEPENDENCIES', $cond, @dep_list);
1675 return $seen_libobjs;
1678 # Canonicalize a name, and check to make sure the non-canonical name
1679 # is never used. Returns canonical name. Arguments are name and a
1680 # list of suffixes to check for.
1681 sub check_canonical_spelling
1683 local ($name, @suffixes) = @_;
1684 local ($xname, $xt);
1686 ($xname = $name) =~ tr/A-Za-z0-9_/_/c;
1687 if ($xname ne $name)
1689 local ($xt);
1690 foreach $xt (@suffixes)
1692 &am_line_error ($name . $xt,
1693 "invalid variable \`" . $name . $xt
1694 . "'; should be \`" . $xname . $xt . "'")
1695 if &variable_defined ($name . $xt);
1699 return $xname;
1702 # Handle C programs.
1703 sub handle_programs
1705 local (@proglist) = &am_install_var ('-clean',
1706 'progs', 'PROGRAMS',
1707 'bin', 'sbin', 'libexec', 'pkglib',
1708 'noinst', 'check');
1709 return if ! @proglist;
1711 # If a program is installed, this is required. We only want this
1712 # error to appear once.
1713 &am_conf_error ("AC_ARG_PROGRAM must be used in configure.in")
1714 unless $seen_arg_prog;
1715 $seen_arg_prog = 1;
1717 local ($one_file, $xname, $munge);
1719 local ($seen_libobjs) = 0;
1720 foreach $one_file (@proglist)
1722 local ($obj) = &get_object_extension ($one_file);
1724 # Canonicalize names and check for misspellings.
1725 $xname = &check_canonical_spelling ($one_file, '_LDADD', '_LDFLAGS',
1726 '_SOURCES', '_OBJECTS',
1727 '_DEPENDENCIES');
1729 # FIXME: Using a trick to figure out if any lex sources appear
1730 # in our program; should use some cleaner method.
1731 local ($lex_num) = scalar (keys %lex_sources);
1732 local ($linker) = &handle_source_transform ($xname, $one_file, $obj);
1733 local ($lex_file_seen) = (scalar (keys %lex_sources) > $lex_num);
1735 local ($xt) = '';
1736 if (&variable_defined ($xname . "_LDADD"))
1738 if (&handle_lib_objects ($xname, $xname . '_LDADD',
1739 $lex_file_seen))
1741 $seen_libobjs = 1;
1743 $lex_file_seen = 0;
1744 $xt = '_LDADD';
1746 else
1748 # User didn't define prog_LDADD override. So do it.
1749 &define_variable ($xname . '_LDADD', '$(LDADD)');
1751 # This does a bit too much work. But we need it to
1752 # generate _DEPENDENCIES when appropriate.
1753 if (&variable_defined ('LDADD'))
1755 if (&handle_lib_objects ($xname, 'LDADD', $lex_file_seen))
1757 $seen_libobjs = 1;
1759 $lex_file_seen = 0;
1761 elsif (! &variable_defined ($xname . '_DEPENDENCIES'))
1763 &define_variable ($xname . '_DEPENDENCIES', '');
1765 $xt = '_SOURCES'
1768 if (&variable_defined ($xname . '_LIBADD'))
1770 &am_line_error ($xname . '_LIBADD',
1771 "use \`" . $xname . "_LDADD', not \`"
1772 . $xname . "_LIBADD'");
1775 if (! &variable_defined ($xname . '_LDFLAGS'))
1777 # Define the prog_LDFLAGS variable.
1778 &define_variable ($xname . '_LDFLAGS', '');
1781 # Determine program to use for link.
1782 local ($xlink);
1783 if (&variable_defined ($xname . '_LINK'))
1785 $xlink = $xname . '_LINK';
1787 else
1789 $xlink = $linker ? $linker : 'LINK';
1792 local ($xexe);
1793 if ($seen_exeext && $one_file !~ /\./)
1795 $xexe = 's/\@EXEEXT\@/\$(EXEEXT)/g;';
1797 else
1799 $xexe = 's/\@EXEEXT\@//g;';
1802 $output_rules .=
1803 &file_contents_with_transform
1804 ('s/\@PROGRAM\@/' . $one_file . '/go;'
1805 . 's/\@XPROGRAM\@/' . $xname . '/go;'
1806 . 's/\@XLINK\@/' . $xlink . '/go;'
1807 . $xexe,
1808 'program');
1811 if (&variable_defined ('LDADD') && &handle_lib_objects ('', 'LDADD', 0))
1813 $seen_libobjs = 1;
1816 if ($seen_libobjs)
1818 foreach $one_file (@proglist)
1820 # Canonicalize names.
1821 ($xname = $one_file) =~ tr/A-Za-z0-9_/_/c;
1823 if (&variable_defined ($xname . '_LDADD'))
1825 &check_libobjs_sources ($xname, $xname . '_LDADD');
1827 elsif (&variable_defined ('LDADD'))
1829 &check_libobjs_sources ($xname, 'LDADD');
1836 # Handle libraries.
1837 sub handle_libraries
1839 local (@liblist) = &am_install_var ('-clean',
1840 'libs', 'LIBRARIES',
1841 'lib', 'pkglib', 'noinst', 'check');
1842 return if ! @liblist;
1844 local (%valid) = &am_primary_prefixes ('LIBRARIES', 0, 'lib', 'pkglib',
1845 'noinst', 'check');
1846 if (! defined $configure_vars{'RANLIB'})
1848 local ($key);
1849 foreach $key (keys %valid)
1851 if (&variable_defined ($key . '_LIBRARIES'))
1853 &am_line_error ($key . '_LIBRARIES', "library used but \`RANLIB' not defined in \`configure.in'");
1854 # Only get this error once. If this is ever printed,
1855 # we have a bug.
1856 $configure_vars{'RANLIB'} = 'BUG';
1857 last;
1862 local ($onelib);
1863 local ($munge);
1864 local ($xlib);
1865 local ($seen_libobjs) = 0;
1866 foreach $onelib (@liblist)
1868 # Check that the library fits the standard naming convention.
1869 if ($onelib !~ /^lib.*\.a$/)
1871 # FIXME should put line number here. That means mapping
1872 # from library name back to variable name.
1873 &am_error ("\`$onelib' is not a standard library name");
1876 local ($obj) = &get_object_extension ($onelib);
1878 # Canonicalize names and check for misspellings.
1879 $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_SOURCES',
1880 '_OBJECTS', '_DEPENDENCIES', '_AR');
1882 if (! &variable_defined ($xlib . '_AR'))
1884 &define_variable ($xlib . '_AR', '$(AR) cru');
1887 if (&variable_defined ($xlib . '_LIBADD'))
1889 if (&handle_lib_objects ($xlib, $xlib . '_LIBADD', 0))
1891 $seen_libobjs = 1;
1894 else
1896 # Generate support for conditional object inclusion in
1897 # libraries.
1898 &define_variable ($xlib . "_LIBADD", '');
1901 if (&variable_defined ($xlib . '_LDADD'))
1903 &am_line_error ($xlib . '_LDADD',
1904 "use \`" . $xlib . "_LIBADD', not \`"
1905 . $xlib . "_LDADD'");
1908 # Make sure we at look at this.
1909 &examine_variable ($xlib . '_DEPENDENCIES');
1911 &handle_source_transform ($xlib, $onelib, $obj);
1913 $output_rules .=
1914 &file_contents_with_transform ('s/\@LIBRARY\@/' . $onelib . '/go;'
1915 . 's/\@XLIBRARY\@/'
1916 . $xlib . '/go;',
1917 'library');
1920 if ($seen_libobjs)
1922 foreach $onelib (@liblist)
1924 # Canonicalize names.
1925 ($xlib = $onelib) =~ tr/A-Za-z0-9_/_/c;
1926 if (&variable_defined ($xlib . '_LIBADD'))
1928 &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
1933 &define_variable ('AR', 'ar');
1934 &define_configure_variable ('RANLIB');
1937 # Handle shared libraries.
1938 sub handle_ltlibraries
1940 local (@liblist) = &am_install_var ('-clean',
1941 'ltlib', 'LTLIBRARIES',
1942 'noinst', 'lib', 'pkglib', 'check');
1943 return if ! @liblist;
1945 local (%instdirs);
1946 local (%valid) = &am_primary_prefixes ('LTLIBRARIES', 0, 'lib', 'pkglib',
1947 'noinst', 'check');
1949 local ($key);
1950 foreach $key (keys %valid)
1952 if (&variable_defined ($key . '_LTLIBRARIES'))
1954 if (!$seen_libtool)
1956 &am_line_error ($key . '_LTLIBRARIES', "library used but \`LIBTOOL' not defined in \`configure.in'");
1957 # Only get this error once. If this is ever printed,
1958 # we have a bug.
1959 $configure_vars{'LIBTOOL'} = 'BUG';
1960 $seen_libtool = 1;
1963 # Get the installation directory of each library.
1964 for (&variable_value_as_list ($key . '_LTLIBRARIES', 'all'))
1966 if ($instdirs{$_})
1968 &am_error ("\`$_' is already going to be installed in \`$instdirs{$_}'");
1970 else
1972 $instdirs{$_} = $key;
1978 local ($onelib);
1979 local ($munge);
1980 local ($xlib);
1981 local ($seen_libobjs) = 0;
1982 foreach $onelib (@liblist)
1984 local ($obj) = &get_object_extension ($onelib);
1986 # Canonicalize names and check for misspellings.
1987 $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_LDFLAGS',
1988 '_SOURCES', '_OBJECTS',
1989 '_DEPENDENCIES');
1991 if (! &variable_defined ($xlib . '_LDFLAGS'))
1993 # Define the lib_LDFLAGS variable.
1994 &define_variable ($xlib . '_LDFLAGS', '');
1997 # Check that the library fits the standard naming convention.
1998 $libname_rx = "^lib.*\.la";
1999 if (&variable_value ($xlib . '_LDFLAGS') =~ /-module/
2000 || &variable_value ('LDFLAGS') =~ /-module/)
2002 # Relax name checking for libtool modules.
2003 $libname_rx = "\.la";
2005 if ($onelib !~ /$libname_rx$/)
2007 # FIXME this should only be a warning for foreign packages
2008 # FIXME should put line number here. That means mapping
2009 # from library name back to variable name.
2010 &am_error ("\`$onelib' is not a standard libtool library name");
2013 if (&variable_defined ($xlib . '_LIBADD'))
2015 if (&handle_lib_objects ($xlib, $xlib . '_LIBADD', 0))
2017 $seen_libobjs = 1;
2020 else
2022 # Generate support for conditional object inclusion in
2023 # libraries.
2024 &define_variable ($xlib . "_LIBADD", '');
2027 if (&variable_defined ($xlib . '_LDADD'))
2029 &am_line_error ($xlib . '_LDADD',
2030 "use \`" . $xlib . "_LIBADD', not \`"
2031 . $xlib . "_LDADD'");
2034 # Make sure we at look at this.
2035 &examine_variable ($xlib . '_DEPENDENCIES');
2037 local ($linker) = &handle_source_transform ($xlib, $onelib, $obj);
2039 # Determine program to use for link.
2040 local ($xlink);
2041 if (&variable_defined ($xlib . '_LINK'))
2043 $xlink = $xlib . '_LINK';
2045 else
2047 $xlink = $linker ? $linker : 'LINK';
2050 local ($rpath);
2051 if ($instdirs{$onelib} eq 'EXTRA' || $instdirs{$onelib} eq 'noinst')
2053 # It's an EXTRA_ library, so we can't specify -rpath,
2054 # because we don't know where the library will end up.
2055 # The user probably knows, but generally speaking automake
2056 # doesn't -- and in fact configure could decide
2057 # dynamically between two different locations.
2058 $rpath = 's/\@RPATH\@//go;';
2060 else
2062 $rpath = ('s/\@RPATH\@/-rpath \$(' . $instdirs{$onelib}
2063 . 'dir)/go;');
2066 $output_rules .=
2067 &file_contents_with_transform ('s/\@LTLIBRARY\@/'
2068 . $onelib . '/go;'
2069 . 's/\@XLTLIBRARY\@/'
2070 . $xlib . '/go;'
2071 . $rpath
2072 . 's/\@XLINK\@/' . $xlink . '/go;',
2073 'ltlibrary');
2076 if ($seen_libobjs)
2078 foreach $onelib (@liblist)
2080 # Canonicalize names.
2081 ($xlib = $onelib) =~ tr/A-Za-z0-9_/_/c;
2082 if (&variable_defined ($xlib . '_LIBADD'))
2084 &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
2090 # See if any _SOURCES variable were misspelled. Also, make sure that
2091 # EXTRA_ variables don't contain configure substitutions.
2092 sub check_typos
2094 local ($varname, $primary);
2095 foreach $varname (keys %contents)
2097 foreach $primary ('_SOURCES', '_LIBADD', '_LDADD', '_LDFLAGS',
2098 '_DEPENDENCIES')
2100 if ($varname =~ /$primary$/ && ! $content_seen{$varname})
2102 &am_line_error ($varname,
2103 "invalid unused variable name: \`$varname'");
2109 # Handle scripts.
2110 sub handle_scripts
2112 # NOTE we no longer automatically clean SCRIPTS, because it is
2113 # useful to sometimes distribute scripts verbatim. This happens
2114 # eg in Automake itself.
2115 &am_install_var ('-candist', 'scripts', 'SCRIPTS',
2116 'bin', 'sbin', 'libexec', 'pkgdata',
2117 'noinst', 'check');
2119 local ($scripts_installed) = 0;
2120 # Set $scripts_installed if appropriate. Make sure we only find
2121 # scripts which are actually installed -- this is why we can't
2122 # simply use the return value of am_install_var.
2123 local (%valid) = &am_primary_prefixes ('SCRIPTS', 1, 'bin', 'sbin',
2124 'libexec', 'pkgdata',
2125 'noinst', 'check');
2126 local ($key);
2127 foreach $key (keys %valid)
2129 if ($key ne 'noinst'
2130 && $key ne 'check'
2131 && &variable_defined ($key . '_SCRIPTS'))
2133 $scripts_installed = 1;
2134 # push (@check_tests, 'check-' . $key . 'SCRIPTS');
2138 if ($scripts_installed)
2140 # If a program is installed, this is required. We only want this
2141 # error to appear once.
2142 &am_conf_error ("AC_ARG_PROGRAM must be used in configure.in")
2143 unless $seen_arg_prog;
2144 $seen_arg_prog = 1;
2148 # Search a file for a "version.texi" Texinfo include. Return the name
2149 # of the include file if found, or the empty string if not. A
2150 # "version.texi" file is actually any file whose name matches
2151 # "vers*.texi".
2152 sub scan_texinfo_file
2154 local ($filename) = @_;
2156 if (! open (TEXI, $filename))
2158 &am_error ("couldn't open \`$filename': $!");
2159 return '';
2161 print "automake: reading $filename\n" if $verbose;
2163 local ($vfile, $outfile);
2164 while (<TEXI>)
2166 if (/^\@setfilename +(\S+)/)
2168 $outfile = $1;
2169 last if ($vfile);
2172 if (/^\@include\s+(vers[^.]*\.texi)\s*$/)
2174 # Found version.texi include.
2175 $vfile = $1;
2176 last if $outfile;
2180 close (TEXI);
2181 return ($outfile, $vfile);
2184 # Handle all Texinfo source.
2185 sub handle_texinfo
2187 &am_line_error ('TEXINFOS',
2188 "\`TEXINFOS' is an anachronism; use \`info_TEXINFOS'")
2189 if &variable_defined ('TEXINFOS');
2190 return if (! &variable_defined ('info_TEXINFOS')
2191 && ! &variable_defined ('html_TEXINFOS'));
2193 if (&variable_defined ('html_TEXINFOS'))
2195 &am_line_error ('html_TEXINFOS',
2196 "HTML generation not yet supported");
2197 return;
2200 local (@texis) = &variable_value_as_list ('info_TEXINFOS', 'all');
2202 local (@info_deps_list, @dvis_list, @texi_deps);
2203 local ($infobase, $info_cursor);
2204 local (%versions);
2205 local ($done) = 0;
2206 local ($vti);
2207 local ($tc_cursor, @texi_cleans);
2208 local ($canonical);
2210 foreach $info_cursor (@texis)
2212 # FIXME: This is mildly hacky, since it recognizes "txinfo".
2213 # I don't feel like making it right.
2214 ($infobase = $info_cursor) =~ s/\.te?xi(nfo)?$//;
2216 # If 'version.texi' is referenced by input file, then include
2217 # automatic versioning capability.
2218 local ($out_file, $vtexi) = &scan_texinfo_file ($relative_dir
2219 . "/" . $info_cursor);
2221 if ($out_file eq '')
2223 &am_error ("\`$info_cursor' missing \@setfilename");
2224 next;
2227 if ($out_file =~ /\.(.+)$/ && $1 ne 'info')
2229 # FIXME should report line number in input file.
2230 &am_error ("output of \`$info_cursor', \`$out_file', has unrecognized extension");
2231 next;
2234 if ($vtexi)
2236 &am_error ("\`$vtexi', included in \`$info_cursor', also included in \`$versions{$vtexi}'")
2237 if (defined $versions{$vtexi});
2238 $versions{$vtexi} = $info_cursor;
2240 # We number the stamp-vti files. This is doable since the
2241 # actual names don't matter much. We only number starting
2242 # with the second one, so that the common case looks nice.
2243 $vti = ($done ? $done : 'vti');
2244 ++$done;
2246 &push_dist_common ($vtexi, 'stamp-' . $vti);
2247 push (@clean, $vti);
2249 &require_conf_file_with_line ('info_TEXINFOS', $FOREIGN,
2250 'mdate-sh');
2252 local ($conf_pat, $conf_dir);
2253 if ($config_aux_dir eq '.' || $config_aux_dir eq '')
2255 $conf_dir = '$(srcdir)/';
2257 else
2259 $conf_dir = $config_aux_dir;
2260 $conf_dir .= '/' unless $conf_dir =~ /\/$/;
2262 ($conf_pat = $conf_dir) =~ s/(\W)/\\$1/g;
2263 $output_rules .=
2264 &file_contents_with_transform
2265 ('s/\@TEXI\@/' . $info_cursor . '/g; '
2266 . 's/\@VTI\@/' . $vti . '/g; '
2267 . 's/\@VTEXI\@/' . $vtexi . '/g;'
2268 . 's,\@MDDIR\@,' . $conf_pat . ',g;',
2269 'texi-vers');
2271 &push_phony_cleaners ($vti);
2274 # If user specified file_TEXINFOS, then use that as explicit
2275 # dependency list.
2276 @texi_deps = ();
2277 push (@texi_deps, $info_cursor);
2278 push (@texi_deps, $vtexi) if $vtexi;
2280 # Canonicalize name first.
2281 ($canonical = $infobase) =~ tr/A-Za-z0-9_/_/c;
2282 if (&variable_defined ($canonical . "_TEXINFOS"))
2284 push (@texi_deps, '$(' . $canonical . '_TEXINFOS)');
2285 &push_dist_common ('$(' . $canonical . '_TEXINFOS)');
2288 $output_rules .= ("\n" . $out_file . ": "
2289 . join (' ', @texi_deps)
2290 . "\n" . $infobase . ".dvi: "
2291 . join (' ', @texi_deps)
2292 . "\n\n");
2294 push (@info_deps_list, $out_file);
2295 push (@dvis_list, $infobase . '.dvi');
2297 # Generate list of things to clean for this target. We do
2298 # this explicitly because otherwise too many things could be
2299 # removed. In particular the ".log" extension might
2300 # reasonably be used in other contexts by the user.
2301 # FIXME: this is really out of control.
2302 foreach $tc_cursor ('aux', 'cp', 'cps', 'dvi', 'fn', 'fns', 'pgs',
2303 'ky', 'kys', 'ps', 'log', 'pg', 'toc', 'tp', 'tps',
2304 'vr', 'vrs', 'op', 'tr', 'cv', 'cn', 'cm', 'ov')
2306 push (@texi_cleans, $infobase . '.' . $tc_cursor);
2310 # Find these programs wherever they may lie. Yes, this has
2311 # intimate knowledge of the structure of the texinfo distribution.
2312 &define_program_variable ('MAKEINFO', 'build', 'texinfo/makeinfo',
2313 'makeinfo',
2314 # Circumlocution to avoid accidental
2315 # configure substitution.
2316 '@MAKE' . 'INFO@');
2317 &define_program_variable ('TEXI2DVI', 'src', 'texinfo/util',
2318 'texi2dvi');
2320 # Set transform for including texinfos.am. First, handle --cygnus
2321 # stuff.
2322 local ($xform);
2323 if ($cygnus_mode)
2325 $xform = 's/^NOTCYGNUS.*$//; s/^CYGNUS//;';
2327 else
2329 $xform = 's/^CYGNUS.*$//; s/^NOTCYGNUS//;';
2332 # Handle location of texinfo.tex.
2333 local ($need_texi_file) = 0;
2334 local ($texinfo_tex);
2335 if ($cygnus_mode)
2337 $texinfo_tex = '$(top_srcdir)/../texinfo/texinfo.tex';
2338 &define_variable ('TEXINFO_TEX', $texinfo_tex);
2341 elsif ($config_aux_dir ne '.' && $config_aux_dir ne '')
2343 $texinfo_tex = $config_aux_dir . '/texinfo.tex';
2344 &define_variable ('TEXINFO_TEX', $texinfo_tex);
2345 $need_texi_file = 2; # so that we require_conf_file later
2347 elsif (&variable_defined ('TEXINFO_TEX'))
2349 # The user defined TEXINFO_TEX so assume he knows what he is
2350 # doing.
2351 $texinfo_tex = ('$(srcdir)/'
2352 . &dirname (&variable_value ('TEXINFO_TEX')));
2354 else
2356 $texinfo_tex = '$(srcdir)/texinfo.tex';
2357 $need_texi_file = 1;
2359 local ($xxform);
2360 ($xxform = $texinfo_tex) =~ s/\/texinfo\.tex$//;
2361 $xxform =~ s/(\W)/\\$1/g;
2362 $xform .= ' s/\@TEXINFODIR\@/' . $xxform . '/g;';
2364 $output_rules .= &file_contents_with_transform ($xform, 'texinfos');
2365 push (@phony, 'install-info-am', 'uninstall-info');
2366 push (@dist_targets, 'dist-info');
2368 # How to clean. The funny name is due to --cygnus influence; in
2369 # Cygnus mode, `clean-info' is a target that users can use.
2370 $output_rules .= "\nmostlyclean-aminfo:\n";
2371 &pretty_print_rule ("\t-rm -f", "\t ", @texi_cleans);
2372 $output_rules .= ("\nclean-aminfo:\n\ndistclean-aminfo:\n\n"
2373 . "maintainer-clean-aminfo:\n\t"
2374 # Eww. But how else can we find all the output
2375 # files from makeinfo?
2376 . ($cygnus_mode ? '' : 'cd $(srcdir) && ')
2377 . 'for i in $(INFO_DEPS); do' . " \\\n"
2378 . "\t" . ' rm -f $$i;' . " \\\n"
2379 . "\t" . ' if test "`echo $$i-[0-9]*`" != "$$i-[0-9]*"; then' . " \\\n"
2380 . "\t" . ' rm -f $$i-[0-9]*;' . " \\\n"
2381 . "\t" . ' fi;' . " \\\n"
2382 . "\tdone\n");
2383 &push_phony_cleaners ('aminfo');
2384 if ($cygnus_mode)
2386 $output_rules .= "clean-info: mostlyclean-aminfo\n";
2389 push (@suffixes, '.texi', '.texinfo', '.txi', '.info', '.dvi', '.ps');
2391 if (! defined $options{'no-installinfo'})
2393 push (@uninstall, 'uninstall-info');
2394 push (@installdirs, '$(DESTDIR)$(infodir)');
2395 unshift (@install_data, 'install-info-am');
2397 # Make sure documentation is made and installed first. Use
2398 # $(INFO_DEPS), not 'info', because otherwise recursive makes
2399 # get run twice during "make all".
2400 unshift (@all, '$(INFO_DEPS)');
2402 push (@clean, 'aminfo');
2403 push (@info, '$(INFO_DEPS)');
2404 push (@dvi, '$(DVIS)');
2406 &define_variable ("INFO_DEPS", join (' ', @info_deps_list));
2407 &define_variable ("DVIS", join (' ', @dvis_list));
2408 # This next isn't strictly needed now -- the places that look here
2409 # could easily be changed to look in info_TEXINFOS. But this is
2410 # probably better, in case noinst_TEXINFOS is ever supported.
2411 &define_variable ("TEXINFOS", &variable_value ('info_TEXINFOS'));
2413 # Do some error checking. Note that this file is not required
2414 # when in Cygnus mode; instead we defined TEXINFO_TEX explicitly
2415 # up above.
2416 if ($need_texi_file && ! defined $options{'no-texinfo.tex'})
2418 if ($need_texi_file > 1)
2420 &require_conf_file_with_line ('info_TEXINFOS', $FOREIGN,
2421 'texinfo.tex');
2423 else
2425 &require_file_with_line ('info_TEXINFOS', $FOREIGN, 'texinfo.tex');
2430 # Handle any man pages.
2431 sub handle_man_pages
2433 &am_line_error ('MANS', "\`MANS' is an anachronism; use \`man_MANS'")
2434 if &variable_defined ('MANS');
2435 return if ! &variable_defined ('man_MANS');
2437 # Find all the sections in use. We do this by first looking for
2438 # "standard" sections, and then looking for any additional
2439 # sections used in man_MANS.
2440 local ($sect, %sections, %vlist);
2441 # Add more sections as needed.
2442 foreach $sect ('0'..'9', 'n', 'l')
2444 if (&variable_defined ('man' . $sect . '_MANS'))
2446 $sections{$sect} = 1;
2447 $vlist{'$(man' . $sect . '_MANS)'} = 1;
2451 if (&variable_defined ('man_MANS'))
2453 $vlist{'$(man_MANS)'} = 1;
2454 foreach (&variable_value_as_list ('man_MANS', 'all'))
2456 # A page like `foo.1c' goes into man1dir.
2457 if (/\.([0-9a-z])([a-z]*)$/)
2459 $sections{$1} = 1;
2465 # Now for each section, generate an install and unintall rule.
2466 # Sort sections so output is deterministic.
2467 local (@namelist);
2468 foreach $sect (sort keys %sections)
2470 &define_variable ('man' . $sect . 'dir', '$(mandir)/man' . $sect);
2471 push (@installdirs, '$(DESTDIR)$(mandir)/man' . $sect)
2472 unless defined $options{'no-installman'};
2473 $output_rules .= &file_contents_with_transform ('s/\@SECTION\@/'
2474 . $sect . '/g;',
2475 'mans');
2476 push (@phony, 'install-man' . $sect, 'uninstall-man' . $sect);
2477 push (@namelist, 'install-man' . $sect);
2480 # We don't really need this, but we use it in case we ever want to
2481 # support noinst_MANS.
2482 &define_variable ("MANS", join (' ', sort keys %vlist));
2484 # Generate list of install dirs.
2485 $output_rules .= ("install-man: \$(MANS)\n"
2486 . "\t\@\$(NORMAL_INSTALL)\n");
2487 &pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ", @namelist);
2488 push (@phony, 'install-man');
2490 $output_rules .= "uninstall-man:\n\t\@\$(NORMAL_UNINSTALL)\n";
2491 grep ($_ = 'un' . $_, @namelist);
2492 &pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ", @namelist);
2493 push (@phony, 'uninstall-man');
2495 $output_vars .= &file_contents ('mans-vars');
2497 if (! defined $options{'no-installman'})
2499 push (@install_data, 'install-man');
2500 push (@uninstall, 'uninstall-man');
2501 push (@all, '$(MANS)');
2505 # Handle DATA variables.
2506 sub handle_data
2508 &am_install_var ('-noextra', '-candist', 'data', 'DATA',
2509 'data', 'sysconf', 'sharedstate', 'localstate',
2510 'pkgdata', 'noinst', 'check');
2513 # Handle TAGS.
2514 sub handle_tags
2516 push (@phony, 'tags');
2517 local (@tag_deps) = ();
2518 if (&variable_defined ('SUBDIRS'))
2520 $output_rules .= ("tags-recursive:\n"
2521 . "\tlist=\'\$(SUBDIRS)\'; for subdir in \$\$list; do \\\n"
2522 # Never fail here if a subdir fails; it
2523 # isn't important.
2524 . "\t test \"\$\$subdir\" = . || (cd \$\$subdir"
2525 . " && \$(MAKE) \$(AM_MAKEFLAGS) tags); \\\n"
2526 . "\tdone\n");
2527 push (@tag_deps, 'tags-recursive');
2528 push (@phony, 'tags-recursive');
2531 if (&saw_sources_p (1)
2532 || &variable_defined ('ETAGS_ARGS')
2533 || @tag_deps)
2535 local ($xform) = '';
2536 local ($one_hdr);
2537 foreach $one_hdr (@config_headers)
2539 if ($relative_dir eq &dirname ($one_hdr))
2541 # The config header is in this directory. So require it.
2542 local ($var);
2543 ($var = &basename ($one_hdr)) =~ s/(\W)/\\$1/g;
2544 $xform .= ' ' if $xform;
2545 $xform .= $var;
2548 $xform = ('s/\@CONFIG\@/' . $xform . '/;'
2549 . 's/\@DIRS\@/' . join (' ', @tag_deps) . '/;');
2551 if (&variable_defined ('SUBDIRS'))
2553 $xform .= 's/^SUBDIRS//;';
2555 else
2557 $xform .= 's/^SUBDIRS.*$//;';
2560 $output_rules .= &file_contents_with_transform ($xform, 'tags');
2561 $output_rules .= &file_contents ('tags-clean');
2562 push (@clean, 'tags');
2563 &push_phony_cleaners ('tags');
2564 &examine_variable ('TAGS_DEPENDENCIES');
2566 elsif (&variable_defined ('TAGS_DEPENDENCIES'))
2568 &am_line_error ('TAGS_DEPENDENCIES',
2569 "doesn't make sense to define \`TAGS_DEPENDENCIES' without sources or \`ETAGS_ARGS'");
2571 else
2573 # Every Makefile must define some sort of TAGS rule.
2574 # Otherwise, it would be possible for a top-level "make TAGS"
2575 # to fail because some subdirectory failed.
2576 $output_rules .= "tags: TAGS\nTAGS:\n\n";
2580 # Handle multilib support.
2581 sub handle_multilib
2583 return unless $seen_multilib;
2585 $output_rules .= &file_contents ('multilib.am');
2586 &push_phony_cleaners ('multi');
2587 push (@phony, 'all-multi', 'install-multi');
2590 # Worker for handle_dist.
2591 sub handle_dist_worker
2593 local ($makefile) = @_;
2595 $output_rules .= 'distdir: $(DISTFILES)' . "\n";
2597 # Initialization; only at top level.
2598 if ($relative_dir eq '.')
2600 if (defined $options{'check-news'})
2602 # For Gnits users, this is pretty handy. Look at 15 lines
2603 # in case some explanatory text is desirable.
2604 $output_rules .= ' @if sed 15q $(srcdir)/NEWS | fgrep -e "$(VERSION)" > /dev/null; then :; else \\
2605 echo "NEWS not updated; not releasing" 1>&2; \\
2606 exit 1; \\
2612 # Create dist directory.
2613 $output_rules .= ("\t-chmod -R a+w \$(distdir) > /dev/null 2>&1; rm -rf \$(distdir)\n"
2614 . "\tmkdir \$(distdir)\n");
2617 # Scan EXTRA_DIST to see if we need to distribute anything from a
2618 # subdir. If so, add it to the list. I didn't want to do this
2619 # originally, but there were so many requests that I finally
2620 # relented.
2621 local (@dist_dirs);
2622 if (&variable_defined ('EXTRA_DIST'))
2624 # FIXME: This should be fixed to work with conditionals. That
2625 # will require only making the entries in @dist_dirs under the
2626 # appropriate condition. This is meaningful if the nature of
2627 # the distribution should depend upon the configure options
2628 # used.
2629 foreach (&variable_value_as_list ('EXTRA_DIST', ''))
2631 next if /^\@.*\@$/;
2632 next unless s,/+[^/]+$,,;
2633 push (@dist_dirs, $_)
2634 unless $_ eq '.';
2638 # We have to check DIST_COMMON for extra directories in case the
2639 # user put a source used in AC_OUTPUT into a subdir.
2640 foreach (&variable_value_as_list ('DIST_COMMON', 'all'))
2642 next if /^\@.*\@$/;
2643 next unless s,/+[^/]+$,,;
2644 push (@dist_dirs, $_)
2645 unless $_ eq '.';
2648 if (@dist_dirs)
2650 # Prepend $(distdir) to each directory given. Doing it via a
2651 # hash lets us ensure that each directory is used only once.
2652 local (%dhash);
2653 grep ($dhash{'$(distdir)/' . $_} = 1, @dist_dirs);
2654 $output_rules .= "\t";
2655 &pretty_print_rule ('$(mkinstalldirs)', "\t ", sort keys %dhash);
2658 # In loop, test for file existence because sometimes a file gets
2659 # included in DISTFILES twice. For example this happens when a
2660 # single source file is used in building more than one program.
2661 # Also, there are situations in which "ln" can fail. For instance
2662 # a file to distribute could actually be a cross-filesystem
2663 # symlink -- this can easily happen if "gettextize" was run on the
2664 # distribution.
2665 $output_rules .= "\t\@for file in \$(DISTFILES); do \\\n";
2666 if ($cygnus_mode)
2668 $output_rules .= "\t if test -f \$\$file; then d=.; else d=\$(srcdir); fi; \\\n";
2670 else
2672 $output_rules .= "\t d=\$(srcdir); \\\n";
2674 $output_rules .= ("\t if test -d \$\$d/\$\$file; then \\\n"
2675 # Don't mention $$file in destination argument,
2676 # since this fails if destination directory
2677 # already exists. Also, use `-R' and not `-r'.
2678 # `-r' is almost always incorrect.
2679 . "\t cp -pR \$\$d/\$\$file \$(distdir) \\\n"
2680 . "\t || exit 1; \\\n"
2681 . "\t else \\\n"
2682 . "\t test -f \$(distdir)/\$\$file \\\n"
2683 . "\t || cp -p \$\$d/\$\$file \$(distdir)/\$\$file \\\n"
2684 . "\t || exit 1; \\\n"
2685 . "\t fi; \\\n"
2686 . "\tdone\n");
2688 # If we have SUBDIRS, create all dist subdirectories and do
2689 # recursive build.
2690 if (&variable_defined ('SUBDIRS'))
2692 # If SUBDIRS is conditionally defined, then set DIST_SUBDIRS
2693 # to all possible directories, and use it. If DIST_SUBDIRS is
2694 # defined, just use it.
2695 local ($dist_subdir_name);
2696 if (&variable_conditions ('SUBDIRS')
2697 || &variable_defined ('DIST_SUBDIRS'))
2699 $dist_subdir_name = 'DIST_SUBDIRS';
2700 if (! &variable_defined ('DIST_SUBDIRS'))
2702 local (@full_list) = &variable_value_as_list ('SUBDIRS',
2703 'all');
2704 local (@ds_list, %uniq, $iter);
2705 foreach $iter (@full_list)
2707 if (! defined $uniq{$iter})
2709 $uniq{$iter} = 1;
2710 push (@ds_list, $iter);
2713 &define_pretty_variable ('DIST_SUBDIRS', '', @ds_list);
2716 else
2718 $dist_subdir_name = 'SUBDIRS';
2721 # Test for directory existence here because previous automake
2722 # invocation might have created some directories. Note that
2723 # we explicitly set distdir for the subdir make; that lets us
2724 # mix-n-match many automake-using packages into one large
2725 # package, and have "dist" at the top level do the right
2726 # thing. If we're in the topmost directory, then we use
2727 # `distdir' instead of `top_distdir'; this lets us work
2728 # correctly with an enclosing package.
2729 $output_rules .=
2730 ("\t" . 'for subdir in $(' . $dist_subdir_name . '); do ' . "\\\n"
2731 . "\t" . ' if test "$$subdir" = .; then :; else ' . "\\\n"
2732 . "\t" . ' test -d $(distdir)/$$subdir ' . "\\\n"
2733 . "\t" . ' || mkdir $(distdir)/$$subdir ' . "\\\n"
2734 . "\t" . ' || exit 1; ' . "\\\n"
2735 . "\t" . ' (cd $$subdir'
2736 . ' && $(MAKE) $(AM_MAKEFLAGS) top_distdir=../$('
2737 . (($relative_dir eq '.') ? 'distdir' : 'top_distdir')
2738 . ') distdir=../$(distdir)/$$subdir distdir) ' . "\\\n"
2739 . "\t" . ' || exit 1; ' . "\\\n"
2740 . "\t" . ' fi; ' . "\\\n"
2741 . "\tdone\n");
2744 # If the target `dist-hook' exists, make sure it is run. This
2745 # allows users to do random weird things to the distribution
2746 # before it is packaged up.
2747 push (@dist_targets, 'dist-hook') if &target_defined ('dist-hook');
2749 local ($targ);
2750 foreach $targ (@dist_targets)
2752 # We must explicitly set distdir and top_distdir for these
2753 # sub-makes.
2754 $output_rules .= ("\t\$(MAKE) \$(AM_MAKEFLAGS)"
2755 . " top_distdir=\"\$(top_distdir)\""
2756 . " distdir=\"\$(distdir)\" $targ\n");
2759 push (@phony, 'distdir');
2762 # Handle 'dist' target.
2763 sub handle_dist
2765 local ($makefile) = @_;
2767 # Set up maint_charset.
2768 $local_maint_charset = &variable_value ('MAINT_CHARSET')
2769 if &variable_defined ('MAINT_CHARSET');
2770 $maint_charset = $local_maint_charset
2771 if $relative_dir eq '.';
2773 if (&variable_defined ('DIST_CHARSET'))
2775 &am_line_error ('DIST_CHARSET',
2776 "DIST_CHARSET defined but no MAINT_CHARSET defined")
2777 if ! $local_maint_charset;
2778 if ($relative_dir eq '.')
2780 $dist_charset = &variable_value ('DIST_CHARSET')
2782 else
2784 &am_line_error ('DIST_CHARSET',
2785 "DIST_CHARSET can only be defined at top level");
2789 # Look for common files that should be included in distribution.
2790 local ($cfile);
2791 foreach $cfile (@common_files)
2793 if (-f ($relative_dir . "/" . $cfile))
2795 &push_dist_common ($cfile);
2799 # Always require configure.in and configure at top level, even if
2800 # they don't exist. This is especially important for configure,
2801 # since it won't be created until autoconf is run -- which might
2802 # be after automake is run.
2803 &push_dist_common ('configure.in', 'configure')
2804 if $relative_dir eq '.';
2806 # We might copy elements from %configure_dist_common to
2807 # %dist_common if we think we need to. If the file appears in our
2808 # directory, we would have discovered it already, so we don't
2809 # check that. But if the file is in a subdir without a Makefile,
2810 # we want to distribute it here if we are doing `.'. Ugly!
2811 if ($relative_dir eq '.')
2813 local ($iter);
2814 foreach $iter (keys %configure_dist_common)
2816 if (! &is_make_dir (&dirname ($iter)))
2818 &push_dist_common ($iter);
2823 # Keys of %dist_common are names of files to distributed. We put
2824 # README first because it then becomes easier to make a
2825 # Usenet-compliant shar file (in these, README must be first).
2826 # FIXME: do more ordering of files here.
2827 local (@coms);
2828 if (defined $dist_common{'README'})
2830 push (@coms, 'README');
2831 delete $dist_common{'README'};
2833 push (@coms, sort keys %dist_common);
2835 # Now that we've processed %dist_common, disallow further attempts
2836 # to set it.
2837 $handle_dist_run = 1;
2839 &define_pretty_variable ("DIST_COMMON", '', @coms);
2840 $output_vars .= "\n";
2842 # Some boilerplate.
2843 $output_vars .= &file_contents ('dist-vars') . "\n";
2844 &define_variable ('GZIP_ENV', '--best');
2846 # Put these things in rules section so it is easier for whoever
2847 # reads Makefile.in.
2848 if (! &variable_defined ('distdir'))
2850 if ($relative_dir eq '.')
2852 $output_rules .= "\n" . 'distdir = $(PACKAGE)-$(VERSION)' . "\n";
2854 else
2856 $output_rules .= ("\n"
2857 . 'distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)'
2858 . "\n");
2861 if ($relative_dir eq '.')
2863 $output_rules .= "top_distdir = \$(distdir)\n";
2865 $output_rules .= "\n";
2867 # Generate 'dist' target, and maybe other dist targets.
2868 if ($relative_dir eq '.')
2870 # Rule to check whether a distribution is viable.
2871 local ($xform) = '';
2873 if (&target_defined ('distcheck-hook'))
2875 $xform .= 's/^DISTHOOK//;';
2877 else
2879 $xform .= 's/^DISTHOOK.*$//;';
2881 if ($seen_gettext)
2883 $xform .= 's/^GETTEXT//;';
2885 else
2887 $xform .= 's/^GETTEXT.*$//;';
2890 $output_rules .= &file_contents_with_transform ($xform, 'dist');
2892 local ($dist_all) = ('dist-all: distdir' . "\n"
2893 . $dist_header);
2894 local ($curs);
2895 foreach $curs ('dist', 'dist-shar', 'dist-zip', 'dist-tarZ',
2896 'dist-bzip2')
2898 if (defined $options{$curs} || $curs eq 'dist')
2900 $output_rules .= ($curs . ': distdir' . "\n"
2901 . $dist_header
2902 . $dist{$curs}
2903 . $dist_trailer);
2904 $dist_all .= $dist{$curs};
2907 $output_rules .= $dist_all . $dist_trailer;
2910 # Generate distdir target.
2911 &handle_dist_worker ($makefile);
2914 # A subroutine of handle_dependencies. This function includes
2915 # `depend2' with appropriate transformations.
2916 sub add_depend2
2918 local ($lang) = @_;
2920 # First include code for ordinary objects.
2921 local ($key) = $lang . '-autodep';
2922 local ($xform, $ext);
2924 local ($pfx) = $language_map{$key};
2925 local ($fpfx) = ($pfx eq '') ? 'CC' : $pfx;
2926 $xform = ('s/\@PFX\@/' . $pfx . '/g;'
2927 . 's/\@FPFX\@/' . $fpfx . '/g;'
2928 . ($seen_objext ? 's/^OBJEXT//;' : 's/^OBJEXT.*$//;')
2929 . ($seen_libtool ? 's/^LIBTOOL//;' : 's/^LIBTOOL.*$//;'));
2931 # This function can be called even when we don't want dependency
2932 # tracking. This happens when we need an explicit rule for some
2933 # target. In this case we don't want to include the generic code.
2934 if ($use_dependencies)
2936 local ($xform1) = ($xform
2937 . 's/\@BASE\@/\$\*/g;'
2938 . 's/\@SOURCE\@/\$\</g;'
2939 . 's/\@(LT|OBJ)?OBJ\@/\$\@/g;');
2941 foreach $ext (&lang_extensions ($lang))
2943 $output_rules .= (&file_contents_with_transform ('s/\@EXT\@/'
2944 . $ext . '/g;'
2945 . $xform1,
2946 'depend2')
2947 . "\n");
2948 for $sourcedir (keys %sourcedirs) {
2949 $output_rules .= (&file_contents_with_transform (
2950 's/\@EXT\@([^:]*):/'
2951 . '%$1: ' . quotemeta($sourcedir) . '\/%' . $ext . '/g;'
2952 . $xform1,
2953 'depend2')
2954 . "\n");
2959 # Now include code for each specially handled object with this
2960 # language.
2961 local (@list) = grep ($_ ne '', split (' ', $lang_specific_files{$lang}));
2962 local ($max) = scalar @list;
2963 local ($i) = 0;
2964 local ($derived, $source, $obj);
2966 # If dependency tracking is disabled, we just elide the code.
2967 if (! $use_dependencies)
2969 $xform .= 's/\@AMDEP\@.*$//;';
2972 while ($i < $max)
2974 $derived = $list[$i];
2975 ($source = $list[$i + 1]) =~ s,([/\$]),\\$1,g;
2976 ($obj = $list[$i + 2]) =~ s,([/\$]),\\$1,g;
2977 $i += 3;
2979 local ($flag) = $language_map{$lang . '-flags'};
2980 local ($val) = "(${derived}_${flag}";
2981 ($rule = $language_map{$lang . '-compile'}) =~
2982 s/\(AM_$flag/$val/;
2984 $rule =~ s,([/\$]),\\$1,g;
2986 # Generate a transform which will turn suffix targets in
2987 # depend2.am into real targets for the particular objects we
2988 # are building.
2989 $output_rules .=
2990 &file_contents_with_transform ($xform
2991 . 's/\$\(' . $pfx . 'COMPILE\)/'
2992 . $rule . '/g;'
2993 . 's/\$\(LT' . $pfx . 'COMPILE\)/'
2994 . '\$(LIBTOOL) --mode=compile '
2995 . $rule . '/g;'
2996 # Generate rule for `.o'.
2997 . 's/^\@EXT\@\.o:/'
2998 . $obj . '.o: ' . $source
2999 . '/g;'
3000 # Maybe generate rule for `.lo'.
3001 # Might be eliminated by
3002 # $XFORM.
3003 . 's/^\@EXT\@\.lo:/'
3004 . $obj . '.lo: ' . $source
3005 . '/g;'
3006 # Maybe generate rule for `.obj'.
3007 # Might be eliminated by
3008 # $XFORM.
3009 . 's/^\@EXT\@\.obj:/'
3010 . $obj . '.obj: ' . $source
3011 . '/g;'
3012 # Handle source and obj
3013 # transforms.
3014 . 's/\@OBJ\@/' . $obj . '.o/g;'
3015 . 's/\@OBJOBJ\@/' . $obj . '.obj/g;'
3016 . 's/\@LTOBJ\@/' . $obj . '.lo/g;'
3017 . 's/\@BASE\@/' . $obj . '/g;'
3018 . 's/\@SOURCE\@/' . $source . '/g;',
3019 'depend2');
3023 # Handle auto-dependency code.
3024 sub handle_dependencies
3026 if ($use_dependencies)
3028 # Include auto-dep code. Don't include it if DEP_FILES would
3029 # be empty.
3030 if (&saw_sources_p (0) && keys %dep_files)
3032 &require_config_file ($FOREIGN, 'depcomp');
3034 # Set location of depcomp.
3035 if ($config_aux_dir ne '.' && $config_aux_dir ne '')
3037 &define_variable ('depcomp', ('$(SHELL) ' . $config_aux_dir
3038 . '/depcomp'));
3040 else
3042 &define_variable ('depcomp',
3043 '$(SHELL) $(top_srcdir)/depcomp');
3046 local ($iter);
3047 local (@deplist) = sort keys %dep_files;
3049 &define_pretty_variable ('DEP_FILES', '', ("\@AMDEP\@", @deplist));
3051 # Generate each `include' individually. Irix 6 make will
3052 # not properly include several files resulting from a
3053 # variable expansion; generating many separate includes
3054 # seems safest.
3055 $output_rules .= "\n";
3056 foreach $iter (@deplist)
3058 $output_rules .= "\@AMDEP\@" . 'include ' . $iter . "\n";
3061 $output_rules .= &file_contents ('depend');
3062 push (@clean, 'depend');
3063 &push_phony_cleaners ('depend');
3066 else
3068 &define_variable ('depcomp', '');
3071 local ($key, $lang, $ext, $xform);
3072 foreach $key (sort keys %language_map)
3074 next unless $key =~ /^(.*)-autodep$/;
3075 next if $language_map{$key} eq 'no';
3076 &add_depend2 ($1);
3080 # Handle subdirectories.
3081 sub handle_subdirs
3083 return if ! &variable_defined ('SUBDIRS');
3085 # Make sure each directory mentioned in SUBDIRS actually exists.
3086 local ($dir);
3087 foreach $dir (&variable_value_as_list ('SUBDIRS', 'all'))
3089 # Skip directories substituted by configure.
3090 next if $dir =~ /^\@.*\@$/;
3092 if (! -d $am_relative_dir . '/' . $dir)
3094 &am_line_error ('SUBDIRS',
3095 "required directory $am_relative_dir/$dir does not exist");
3096 next;
3099 &am_line_error ('SUBDIRS', "directory should not contain \`/'")
3100 if $dir =~ /\//;
3103 local ($xform) = ('s/\@INSTALLINFO\@/' .
3104 (defined $options{'no-installinfo'}
3105 ? 'install-info-recursive'
3106 : '')
3107 . '/;');
3108 $output_rules .= &file_contents_with_transform ($xform, 'subdirs');
3110 # Push a bunch of phony targets.
3111 local ($phonies);
3112 foreach $phonies ('', '-data', '-exec', 'dirs')
3114 push (@phony, 'install' . $phonies . '-recursive');
3115 push (@phony, 'uninstall' . $phonies . '-recursive');
3117 foreach $phonies ('all', 'check', 'installcheck', 'info', 'dvi')
3119 push (@phony, $phonies . '-recursive');
3121 &push_phony_cleaners ('recursive');
3123 $recursive_install = 1;
3126 # Handle aclocal.m4.
3127 sub handle_aclocal_m4
3129 local ($regen_aclocal) = 0;
3130 if (-f 'aclocal.m4')
3132 &define_variable ("ACLOCAL_M4", '$(top_srcdir)/aclocal.m4');
3133 &push_dist_common ('aclocal.m4');
3135 if (open (ACLOCAL, '< aclocal.m4'))
3137 local ($line);
3138 $line = <ACLOCAL>;
3139 close (ACLOCAL);
3141 if ($line =~ 'generated automatically by aclocal')
3143 $regen_aclocal = 1;
3148 local ($acinclude) = 0;
3149 if (-f 'acinclude.m4')
3151 $regen_aclocal = 1;
3152 $acinclude = 1;
3155 # Note that it might be possible that aclocal.m4 doesn't exist but
3156 # should be auto-generated. This case probably isn't very
3157 # important.
3158 if ($regen_aclocal)
3160 local (@ac_deps) = (
3161 ($seen_maint_mode
3162 ? "\@MAINTAINER_MODE_TRUE\@"
3163 : "") ,
3164 "configure.in",
3165 ($acinclude ? ' acinclude.m4' : '')
3168 # Scan all -I directories for m4 files. These are our
3169 # dependencies.
3170 if (&variable_defined ('ACLOCAL_AMFLAGS'))
3172 local ($examine_next, $amdir) = 0;
3173 foreach $amdir (&variable_value_as_list ('ACLOCAL_AMFLAGS', ''))
3175 if ($examine_next)
3177 $examine_next = 0;
3178 if ($amdir !~ /^\// && -d $amdir)
3180 push (@ac_deps, &my_glob ($amdir . '/*.m4'));
3183 elsif ($amdir eq '-I')
3185 $examine_next = 1;
3190 &pretty_print_rule ("\$(ACLOCAL_M4):", "\t\t", @ac_deps);
3192 $output_rules .= ("\t"
3193 . 'cd $(srcdir) && $(ACLOCAL)'
3194 . (&variable_defined ('ACLOCAL_AMFLAGS')
3195 ? ' $(ACLOCAL_AMFLAGS)' : '')
3196 . "\n");
3200 # Rewrite a list of input files into a form suitable to put on a
3201 # dependency list. The idea is that if an input file has a directory
3202 # part the same as the current directory, then the directory part is
3203 # simply removed. But if the directory part is different, then
3204 # $(top_srcdir) is prepended. Among other things, this is used to
3205 # generate the dependency list for the output files generated by
3206 # AC_OUTPUT. Consider what the dependencies should look like in this
3207 # case:
3208 # AC_OUTPUT(src/out:src/in1:lib/in2)
3209 # The first argument, ADD_SRCDIR, is 1 if $(top_srcdir) should be added.
3210 # If 0 then files that require this addition will simply be ignored.
3211 sub rewrite_inputs_into_dependencies
3213 local ($add_srcdir, @inputs) = @_;
3214 local ($single, @newinputs);
3216 foreach $single (@inputs)
3218 if (&dirname ($single) eq $relative_dir)
3220 push (@newinputs, &basename ($single));
3222 elsif ($add_srcdir)
3224 push (@newinputs, '$(top_srcdir)/' . $single);
3228 return @newinputs;
3231 # Handle remaking and configure stuff.
3232 # We need the name of the input file, to do proper remaking rules.
3233 sub handle_configure
3235 local ($local, $input, @secondary_inputs) = @_;
3237 local ($top_reldir);
3239 local ($input_base) = &basename ($input);
3240 local ($local_base) = &basename ($local);
3242 local ($amfile) = $input_base . '.am';
3243 # We know we can always add '.in' because it really should be an
3244 # error if the .in was missing originally.
3245 local ($infile) = '$(srcdir)/' . $input_base . '.in';
3246 local ($colon_infile);
3247 if ($local ne $input || @secondary_inputs)
3249 $colon_infile = ':' . $input . '.in';
3251 $colon_infile .= ':' . join (':', @secondary_inputs)
3252 if @secondary_inputs;
3254 local (@rewritten) = &rewrite_inputs_into_dependencies (1,
3255 @secondary_inputs);
3257 # This rule remakes the Makefile.in. Note use of
3258 # @MAINTAINER_MODE_TRUE@ forces us to abandon pretty-printing.
3259 # Sigh.
3260 $output_rules .= ($infile
3261 # NOTE perl 5.003 (with -w) gives a
3262 # uninitialized value error on the next line.
3263 # Don't know why.
3264 . ': '
3265 . ($seen_maint_mode ? "\@MAINTAINER_MODE_TRUE\@ " : '')
3266 . $amfile . ' '
3267 . '$(top_srcdir)/configure.in $(ACLOCAL_M4)'
3268 . ' ' . join (' ', @include_stack)
3269 . "\n"
3270 . "\tcd \$(top_srcdir) && \$(AUTOMAKE) "
3271 . ($cygnus_mode ? '--cygnus' : ('--' . $strictness_name))
3272 . ($cmdline_use_dependencies ? '' : ' --ignore-deps')
3273 . ' ' . $input . $colon_infile . "\n\n");
3275 # This rule remakes the Makefile.
3276 $output_rules .= ($local_base
3277 # NOTE: bogus uninit value error on next line;
3278 # see comment above.
3279 . ': '
3280 . $infile . ' '
3281 . join (' ', @rewritten)
3282 . ' $(top_builddir)/config.status'
3283 . "\n"
3284 . "\tcd \$(top_builddir) \\\n"
3285 . "\t && CONFIG_FILES="
3286 . (($relative_dir eq '.') ? '$@' : '$(subdir)/$@')
3287 . $colon_infile
3288 . ' CONFIG_HEADERS= $(SHELL) ./config.status'
3289 . "\n\n");
3291 if ($relative_dir ne '.')
3293 # In subdirectory.
3294 $top_reldir = '../';
3296 else
3298 &handle_aclocal_m4;
3299 $output_rules .= &file_contents ('remake');
3300 &examine_variable ('CONFIG_STATUS_DEPENDENCIES');
3301 &examine_variable ('CONFIGURE_DEPENDENCIES');
3302 $top_reldir = '';
3304 &push_dist_common ('acconfig.h')
3305 if -f 'acconfig.h';
3308 # If we have a configure header, require it.
3309 local ($one_hdr);
3310 local (@local_fullnames) = @config_fullnames;
3311 local (@local_names) = @config_names;
3312 local ($hdr_index) = 0;
3313 local ($distclean_config) = '';
3314 foreach $one_hdr (@config_headers)
3316 local ($one_fullname) = shift (@local_fullnames);
3317 local ($one_name) = shift (@local_names);
3318 $hdr_index += 1;
3319 local ($header_dir) = &dirname ($one_name);
3321 # If the header is in the current directory we want to build
3322 # the header here. Otherwise, if we're at the topmost
3323 # directory and the header's directory doesn't have a
3324 # Makefile, then we also want to build the header.
3325 if ($relative_dir eq $header_dir
3326 || ($relative_dir eq '.' && ! &is_make_dir ($header_dir)))
3328 local ($ch_sans_dir, $cn_sans_dir, $stamp_dir);
3329 if ($relative_dir eq $header_dir)
3331 $cn_sans_dir = &basename ($one_name);
3332 $stamp_dir = '';
3334 else
3336 $cn_sans_dir = $one_name;
3337 if ($header_dir eq '.')
3339 $stamp_dir = '';
3341 else
3343 $stamp_dir = $header_dir . '/';
3347 # Compute relative path from directory holding output
3348 # header to directory holding input header. FIXME:
3349 # doesn't handle case where we have multiple inputs.
3350 if (&dirname ($one_hdr) eq $relative_dir)
3352 $ch_sans_dir = &basename ($one_hdr);
3354 else
3356 local (@rel_out_path);
3357 # FIXME this chunk of code should be its own sub.
3358 # It is used elsewhere.
3359 foreach (split (/\//, $relative_dir))
3361 next if $_ eq '' || $_ eq '.';
3362 if ($_ eq '..')
3364 # FIXME: actually this is an error.
3365 pop @rel_out_path;
3367 else
3369 push (@rel_out_path, '..');
3372 if (@rel_out_path)
3374 $ch_sans_dir = join ('/', @rel_out_path) . '/' . $one_hdr;
3376 else
3378 $ch_sans_dir = $one_hdr;
3382 &require_file_with_conf_line ($config_header_line,
3383 $FOREIGN, $ch_sans_dir);
3385 # Header defined and in this directory.
3386 local (@files);
3387 if (-f $one_name . '.top')
3389 push (@files, "${cn_sans_dir}.top");
3391 if (-f $one_name . '.bot')
3393 push (@files, "${cn_sans_dir}.bot");
3396 &push_dist_common (@files);
3398 # For now, acconfig.h can only appear in the top srcdir.
3399 if (-f 'acconfig.h')
3401 if ($relative_dir eq '.')
3403 push (@files, 'acconfig.h');
3405 else
3407 # Strange quoting because this gets fed through
3408 # Perl.
3409 push (@files, '\$(top_srcdir)/acconfig.h');
3413 local ($stamp_name) = 'stamp-h';
3414 $stamp_name .= "${hdr_index}" if scalar (@config_headers) > 1;
3416 local ($xform) = '';
3418 $xform = 's,\@FILES\@,' . join (' ', @files) . ',;';
3419 $xform .= 's,\@CONFIG_HEADER\@,' . "${cn_sans_dir}" . ',;';
3420 $xform .= 's,\@CONFIG_HEADER_IN\@,' . "${ch_sans_dir}" . ',;';
3421 $xform .= 's,\@CONFIG_HEADER_FULL\@,' . "${one_fullname}" . ',;';
3422 $xform .= 's,\@STAMP\@,' . "${stamp_dir}${stamp_name}" . ',g;';
3424 local ($out_dir) = &dirname ($ch_sans_dir);
3425 $xform .= 's,\@SRC_STAMP\@,' . "${out_dir}/${stamp_name}" . ',g;';
3426 $output_rules .= &file_contents_with_transform ($xform,
3427 'remake-hdr');
3429 &create ("${relative_dir}/${out_dir}/${stamp_name}.in");
3430 &require_file_with_conf_line ($config_header_line, $FOREIGN,
3431 "${out_dir}/${stamp_name}.in");
3433 $distclean_config .= ' ' if $distclean_config;
3434 $distclean_config .= $cn_sans_dir;
3438 if ($distclean_config)
3440 $output_rules .= &file_contents_with_transform ('s,\@FILES\@,'
3441 . $distclean_config
3442 . ',;',
3443 'clean-hdr');
3444 push (@clean, 'hdr');
3445 &push_phony_cleaners ('hdr');
3448 # Set location of mkinstalldirs.
3449 if ($config_aux_dir ne '.' && $config_aux_dir ne '')
3451 &define_variable ('mkinstalldirs', ('$(SHELL) ' . $config_aux_dir
3452 . '/mkinstalldirs'));
3454 else
3456 &define_variable ('mkinstalldirs',
3457 '$(SHELL) $(top_srcdir)/mkinstalldirs');
3460 &am_line_error ('CONFIG_HEADER',
3461 "\`CONFIG_HEADER' is an anachronism; now determined from \`configure.in'")
3462 if &variable_defined ('CONFIG_HEADER');
3464 local ($one_name);
3465 local ($config_header) = '';
3466 foreach $one_name (@config_names)
3468 # Generate CONFIG_HEADER define.
3469 local ($one_hdr);
3470 if ($relative_dir eq &dirname ($one_name))
3472 $one_hdr = &basename ($one_name);
3474 else
3476 $one_hdr = "${top_builddir}/${one_name}";
3479 $config_header .= ' ' if $config_header;
3480 $config_header .= $one_hdr;
3482 if ($config_header)
3484 &define_variable ("CONFIG_HEADER", $config_header);
3487 # Now look for other files in this directory which must be remade
3488 # by config.status, and generate rules for them.
3489 local (@actual_other_files) = ();
3490 local ($file, $local);
3491 local (@inputs, @rewritten_inputs, $single);
3492 local ($need_rewritten);
3493 foreach $file (@other_input_files)
3495 if ($file =~ /^([^:]*):(.*)$/)
3497 # This is the ":" syntax of AC_OUTPUT.
3498 $file = $1;
3499 $local = &basename ($file);
3500 @inputs = split (':', $2);
3501 @rewritten_inputs = &rewrite_inputs_into_dependencies (1, @inputs);
3502 $need_rewritten = 1;
3504 else
3506 # Normal usage.
3507 $local = &basename ($file);
3508 @inputs = ($local . '.in');
3509 @rewritten_inputs =
3510 &rewrite_inputs_into_dependencies (1, $file . '.in');
3511 $need_rewritten = 0;
3514 # Skip files not in this directory.
3515 next unless &dirname ($file) eq $relative_dir;
3517 # Skip any file that is an automake input.
3518 next if -f $file . '.am';
3520 # Some users have been tempted to put `stamp-h' in the
3521 # AC_OUTPUT line. This won't do the right thing, so we
3522 # explicitly fail here.
3523 if ($local eq 'stamp-h')
3525 # FIXME: allow real filename.
3526 &am_conf_error ('configure.in', $ac_output_line,
3527 'stamp-h should not appear in AC_OUTPUT');
3528 next;
3531 $output_rules .= ($local . ': '
3532 . '$(top_builddir)/config.status '
3533 . join (' ', @rewritten_inputs) . "\n"
3534 . "\t"
3535 . 'cd $(top_builddir) && CONFIG_FILES='
3536 . ($relative_dir eq '.' ? '' : '$(subdir)/')
3537 . '$@' . ($need_rewritten
3538 ? (':' . join (':', @inputs))
3539 : '')
3540 . ' CONFIG_HEADERS= $(SHELL) ./config.status'
3541 . "\n");
3542 &push_dist_common (@inputs);
3543 push (@actual_other_files, $local);
3545 # Require all input files.
3546 &require_file_with_conf_line ($ac_output_line, $FOREIGN,
3547 &rewrite_inputs_into_dependencies (0, @inputs));
3550 # These files get removed by "make clean".
3551 &define_pretty_variable ('CONFIG_CLEAN_FILES', '', @actual_other_files);
3554 # Handle C headers.
3555 sub handle_headers
3557 local (@r);
3558 @r = &am_install_var ('-defaultdist', 'header', 'HEADERS', 'include',
3559 'oldinclude', 'pkginclude',
3560 'noinst', 'check');
3561 foreach (@r)
3563 next unless /\.(.*)$/;
3564 &saw_extension ($1);
3568 sub handle_gettext
3570 return if ! $seen_gettext || $relative_dir ne '.';
3572 if (! &variable_defined ('SUBDIRS'))
3574 &am_conf_error
3575 ("AM_GNU_GETTEXT in configure.in but SUBDIRS not defined");
3576 return;
3579 &require_file_with_conf_line ($ac_gettext_line, $GNU, 'ABOUT-NLS');
3581 if (&variable_defined ('SUBDIRS'))
3583 &am_line_error
3584 ('SUBDIRS',
3585 "AM_GNU_GETTEXT in configure.in but \`po' not in SUBDIRS")
3586 if $contents{'SUBDIRS'} !~ /\bpo\b/;
3587 &am_line_error
3588 ('SUBDIRS',
3589 "AM_GNU_GETTEXT in configure.in but \`intl' not in SUBDIRS")
3590 if $contents{'SUBDIRS'} !~ /\bintl\b/;
3593 # Ensure that each language in ALL_LINGUAS has a .po file, and
3594 # each po file is mentioned in ALL_LINGUAS.
3595 if ($seen_linguas)
3597 local (%linguas) = ();
3598 grep ($linguas{$_} = 1, split (' ', $all_linguas));
3600 foreach (<po/*.po>)
3602 s/^po\///;
3603 s/\.po$//;
3605 &am_line_error ($all_linguas_line,
3606 ("po/$_.po exists but \`$_' not in \`ALL_LINGUAS'"))
3607 if ! $linguas{$_};
3610 foreach (keys %linguas)
3612 &am_line_error ($all_linguas_line,
3613 "$_ in \`ALL_LINGUAS' but po/$_.po does not exist")
3614 if ! -f "po/$_.po";
3617 else
3619 &am_error ("AM_GNU_GETTEXT in configure.in but \`ALL_LINGUAS' not defined");
3623 # Handle footer elements.
3624 sub handle_footer
3626 if ($contents{'SOURCES'})
3628 # NOTE don't use define_pretty_variable here, because
3629 # $contents{...} is already defined.
3630 $output_vars .= 'SOURCES = ' . $contents{'SOURCES'} . "\n";
3632 if ($contents{'OBJECTS'})
3634 # NOTE don't use define_pretty_variable here, because
3635 # $contents{...} is already defined.
3636 $output_vars .= 'OBJECTS = ' . $contents{'OBJECTS'} . "\n";
3638 if ($contents{'SOURCES'} || $contents{'OBJECTS'})
3640 $output_vars .= "\n";
3643 if (&variable_defined ('SUFFIXES'))
3645 # Push actual suffixes, and not $(SUFFIXES). Some versions of
3646 # make do not like variable substitutions on the .SUFFIXES
3647 # line.
3648 push (@suffixes, &variable_value_as_list ('SUFFIXES', ''));
3650 if (&target_defined ('.SUFFIXES'))
3652 &am_line_error ('.SUFFIXES',
3653 "use variable \`SUFFIXES', not target \`.SUFFIXES'");
3656 # Note: AIX 4.1 /bin/make will fail if any suffix rule appears
3657 # before .SUFFIXES. So we make sure that .SUFFIXES appears before
3658 # anything else, by sticking it right after the default: target.
3659 $output_header .= ".SUFFIXES:\n";
3660 if (@suffixes)
3662 # Make sure suffixes has unique elements. Sort them to ensure
3663 # the output remains consistent.
3664 local (%suffixes);
3666 grep ($suffixes{$_} = 1, @suffixes);
3668 $output_header .= (".SUFFIXES: "
3669 . join (' ', sort keys %suffixes)
3670 . "\n");
3672 $output_trailer .= &file_contents ('footer');
3675 # Deal with installdirs target.
3676 sub handle_installdirs
3678 # GNU Makefile standards recommend this.
3679 if ($recursive_install)
3681 # We create a separate `-am' target so that the -recursive
3682 # rule will work correctly.
3683 $output_rules .= ("installdirs: installdirs-recursive\n"
3684 . "installdirs-am:\n");
3685 push (@phony, 'installdirs-am');
3687 else
3689 $output_rules .= "installdirs:\n";
3691 push (@phony, 'installdirs');
3692 if (@installdirs)
3694 &pretty_print_rule ("\t" . '$(mkinstalldirs) ', "\t\t",
3695 @installdirs);
3697 $output_rules .= "\n";
3700 # There are several targets which need to be merged. This is because
3701 # their complete definition is compiled from many parts. Note that we
3702 # avoid double colon rules, otherwise we'd use them instead.
3703 sub handle_merge_targets
3705 local ($makefile) = @_;
3707 # There are a few install-related variables that you should not define.
3708 local ($var);
3709 foreach $var ('PRE_INSTALL', 'POST_INSTALL', 'NORMAL_INSTALL')
3711 if (&variable_defined ($var))
3713 &am_line_error ($var, "\`$var' should not be defined");
3717 # Put this at the beginning for the sake of non-GNU makes. This
3718 # is still wrong if these makes can run parallel jobs. But it is
3719 # right enough.
3720 unshift (@all, &basename ($makefile));
3722 local ($one_name);
3723 foreach $one_name (@config_names)
3725 push (@all, &basename ($one_name))
3726 if &dirname ($one_name) eq $relative_dir;
3729 &do_one_merge_target ('info', @info);
3730 &do_one_merge_target ('dvi', @dvi);
3731 &do_check_merge_target;
3732 &do_one_merge_target ('installcheck', @installcheck);
3734 if (defined $options{'no-installinfo'})
3736 &do_one_merge_target ('install-info', '');
3738 elsif (&target_defined ('install-info-local'))
3740 &am_line_error ('install-info-local',
3741 "\`install-info-local' target defined but \`no-installinfo' option not in use");
3744 local ($utarg);
3745 foreach $utarg ('uninstall-data-local', 'uninstall-data-hook',
3746 'uninstall-exec-local', 'uninstall-exec-hook')
3748 if (&target_defined ($utarg))
3750 local ($x);
3751 ($x = $utarg) =~ s/(data|exec)-//;
3752 &am_line_error ($utarg, "use \`$x', not \`$utarg'");
3756 if (&target_defined ('install-local'))
3758 &am_line_error ('install-local',
3759 "use \`install-data-local' or \`install-exec-local', not \`install-local'");
3762 if (@all)
3764 local ($one_name);
3765 local ($local_headers) = '';
3766 foreach $one_name (@config_names)
3768 if (&dirname ($one_name) eq $relative_dir)
3770 $local_headers .= ' ' if $local_headers;
3771 $local_headers .= &basename ($one_name);
3774 if ($local_headers)
3776 # This is kind of a hack, but I couldn't see a better way
3777 # to handle it. In this particular case, we need to make
3778 # sure config.h is built before we recurse. We can't do
3779 # this by changing the order of dependencies to the "all"
3780 # because that breaks when using parallel makes. Instead
3781 # we handle things explicitly.
3782 $output_rules .= ("all-recursive-am: ${local_headers}"
3783 . "\n\t"
3784 . '$(MAKE) $(AM_MAKEFLAGS)'
3785 . " all-recursive"
3786 . "\n\n");
3787 $all_target = 'all-recursive-am';
3788 push (@phony, 'all-recursive-am');
3792 # Print definitions users can use.
3793 &do_one_merge_target ('install-exec', @install_exec);
3794 $output_rules .= "\n";
3796 &do_one_merge_target ('install-data', @install_data);
3797 $output_rules .= "\n";
3799 &do_one_merge_target ('install', 'all-am');
3800 &do_one_merge_target ('uninstall', @uninstall);
3802 &do_one_merge_target ('all', @all);
3804 # Generate the new 'install-strip' target. We can't just set
3805 # INSTALL_PROGRAM because that might be a relative path.
3806 $output_rules .= ("install-strip:\n\t"
3807 . '$(MAKE) $(AM_MAKEFLAGS) INSTALL_STRIP_FLAG=-s install'
3808 . "\n");
3809 push (@phony, 'install-strip');
3812 # Helper for handle_merge_targets. Note that handle_merge_targets
3813 # relies on the fact that this doesn't add an extra \n at the end.
3814 sub do_one_merge_target
3816 local ($name, @values) = @_;
3818 if (&target_defined ($name . '-local'))
3820 # User defined local form of target. So include it.
3821 push (@values, $name . '-local');
3822 push (@phony, $name . '-local');
3825 &pretty_print_rule ($name . "-am:", "\t\t", @values);
3826 if ($name eq 'install')
3828 # Special-case `install-am' to run install-exec-am and
3829 # install-data-am after all-am is built.
3830 &pretty_print_rule ("\t\@\$(MAKE) \$(AM_MAKEFLAGS)", "\t ",
3831 'install-exec-am', 'install-data-am');
3833 elsif ($name eq 'install-exec' && &target_defined ('install-exec-hook'))
3835 $output_rules .= ("\t\@\$(NORMAL_INSTALL)\n"
3836 . "\t" . '$(MAKE) $(AM_MAKEFLAGS) install-exec-hook'
3837 . "\n");
3839 elsif ($name eq 'install-data' && &target_defined ('install-data-hook'))
3841 $output_rules .= ("\t\@\$(NORMAL_INSTALL)\n"
3842 . "\t" . '$(MAKE) $(AM_MAKEFLAGS) install-data-hook'
3843 . "\n");
3846 local ($lname) = $name . ($recursive_install ? '-recursive' : '-am');
3847 local ($tname) = $name;
3848 # To understand this special case, see handle_merge_targets.
3849 if ($name eq 'all')
3851 $tname = 'all-redirect';
3852 $lname = $all_target if $recursive_install;
3853 push (@phony, 'all-redirect');
3854 $output_all = "all: all-redirect\n";
3856 &pretty_print_rule ($tname . ":", "\t\t", $lname);
3857 push (@phony, $name . '-am', $name);
3860 # Handle check merge target specially.
3861 sub do_check_merge_target
3863 if (&target_defined ('check-local'))
3865 # User defined local form of target. So include it.
3866 push (@check_tests, 'check-local');
3867 push (@phony, 'check-local');
3870 # In --cygnus mode, check doesn't depend on all.
3871 if ($cygnus_mode)
3873 # Just run the local check rules.
3874 &pretty_print_rule ('check-am:', "\t\t", @check);
3876 else
3878 # The check target must depend on the local equivalent of
3879 # `all', to ensure all the primary targets are built. Then it
3880 # must build the local check rules.
3881 $output_rules .= "check-am: all-am\n";
3882 &pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ",
3883 @check)
3884 if @check;
3886 &pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ",
3887 @check_tests)
3888 if @check_tests;
3890 push (@phony, 'check', 'check-am');
3891 $output_rules .= ("check: "
3892 . ($recursive_install ? 'check-recursive' : 'check-am')
3893 . "\n");
3896 # Handle all 'clean' targets.
3897 sub handle_clean
3899 local ($xform) = '';
3900 local ($name);
3902 # Don't include `MAINTAINER'; it is handled specially below.
3903 foreach $name ('MOSTLY', '', 'DIST')
3905 if (! &variable_defined ($name . 'CLEANFILES'))
3907 $xform .= 's/^' . $name . 'CLEAN.*$//;';
3909 else
3911 $xform .= 's/^' . $name . 'CLEAN//;';
3915 # Built sources are automatically removed by maintainer-clean.
3916 push (@maintainer_clean_files, '\$(BUILT_SOURCES)')
3917 if &variable_defined ('BUILT_SOURCES');
3918 push (@maintainer_clean_files, '\$(MAINTAINERCLEANFILES)')
3919 if &variable_defined ('MAINTAINERCLEANFILES');
3920 if (! @maintainer_clean_files)
3922 $xform .= 's/^MAINTAINERCLEAN.*$//;';
3924 else
3926 $xform .= ('s/^MAINTAINERCLEAN//;'
3927 # Join with no space to avoid spurious `test -z'
3928 # success at runtime.
3929 . 's,\@MCFILES\@,' . join ('', @maintainer_clean_files)
3930 . ',;'
3931 # A space is required in the join here.
3932 . 's,\@MFILES\@,' . join (' ', @maintainer_clean_files)
3933 . ',;');
3936 $output_rules .= &file_contents_with_transform ($xform, 'clean');
3938 push (@clean, 'generic');
3939 &push_phony_cleaners ('generic');
3941 &do_one_clean_target ('clean', 'mostly', '', @clean);
3942 &do_one_clean_target ('clean', '', 'mostly', @clean);
3943 &do_one_clean_target ('clean', 'dist', '', @clean);
3944 &do_one_clean_target ('clean', 'maintainer-', 'dist', @clean);
3946 push (@phony, 'clean', 'mostlyclean', 'distclean', 'maintainer-clean');
3949 # Helper for handle_clean.
3950 sub do_one_clean_target
3952 local ($target, $name, $last_name, @deps) = @_;
3954 # Change each dependency `BLARG' into `clean-BLARG'.
3955 grep (($_ = $name . 'clean-' . $_) && 0, @deps);
3957 # Push the previous clean target. There is no previous clean
3958 # target if we're doing mostlyclean.
3959 push (@deps, $last_name . $target . '-am')
3960 unless $name eq 'mostly';
3962 # If a -local version of the rule is given, add it to the list.
3963 if (&target_defined ($name . $target . '-local'))
3965 push (@deps, $name . $target . '-local');
3968 # Print the target and the dependencies.
3969 &pretty_print_rule ($name . $target . "-am: ", "\t\t", @deps);
3971 # FIXME: shouldn't we really print these messages before running
3972 # the dependencies?
3973 if ($name . $target eq 'maintainer-clean')
3975 # Print a special warning.
3976 $output_rules .=
3977 ("\t\@echo \"This command is intended for maintainers to use;\"\n"
3978 . "\t\@echo \"it deletes files that may require special "
3979 . "tools to rebuild.\"\n");
3981 elsif ($name . $target eq 'distclean')
3983 $output_rules .= "\t-rm -f libtool\n" if $seen_libtool;
3985 $output_rules .= "\n";
3987 # Now generate the actual clean target.
3988 $output_rules .= ($name . $target . ": " . $name . $target
3989 . ($recursive_install ? '-recursive' : '-am')
3990 . "\n");
3992 # We special-case config.status here. If we do it as part of the
3993 # normal clean processing for this directory, then it might be
3994 # removed before some subdir is cleaned. However, that subdir's
3995 # Makefile depends on config.status.
3996 if (($name . $target eq 'maintainer-clean'
3997 || $name . $target eq 'distclean')
3998 && $relative_dir eq '.')
4000 $output_rules .= "\t-rm -f config.status\n";
4002 $output_rules .= "\n";
4005 # Handle .PHONY target.
4006 sub handle_phony
4008 &pretty_print_rule ('.PHONY:', "", @phony);
4009 $output_rules .= "\n";
4012 # Handle TESTS variable and other checks.
4013 sub handle_tests
4015 if (defined $options{'dejagnu'})
4017 push (@check_tests, 'check-DEJAGNU');
4018 push (@phony, 'check-DEJAGNU');
4020 local ($xform);
4021 if ($cygnus_mode)
4023 $xform = 's/^CYGNUS//;';
4025 else
4027 $xform = 's/^CYGNUS.*$//;';
4029 $output_rules .= &file_contents_with_transform ($xform, 'dejagnu');
4031 # In Cygnus mode, these are found in the build tree.
4032 # Otherwise they are looked for in $PATH.
4033 &define_program_variable ('EXPECT', 'build', 'expect', 'expect');
4034 &define_program_variable ('RUNTEST', 'src', 'dejagnu', 'runtest');
4036 # Only create site.exp rule if user hasn't already written
4037 # one.
4038 if (! &target_defined ('site.exp'))
4040 # Note that in the rule we don't directly generate
4041 # site.exp to avoid the possibility of a corrupted
4042 # site.exp if make is interrupted. Jim Meyering has some
4043 # useful text on this topic.
4044 $output_rules .= ("site.exp: Makefile\n"
4045 . "\t\@echo 'Making a new site.exp file...'\n"
4046 . "\t\@test ! -f site.bak || rm -f site.bak\n"
4047 . "\t\@echo '## these variables are automatically generated by make ##' > \$\@-t\n"
4048 . "\t\@echo '# Do not edit here. If you wish to override these values' >> \$\@-t\n"
4049 . "\t\@echo '# edit the last section' >> \$\@-t\n"
4050 . "\t\@echo 'set tool \$(DEJATOOL)' >> \$\@-t\n"
4051 . "\t\@echo 'set srcdir \$(srcdir)' >> \$\@-t\n"
4052 . "\t\@echo 'set objdir' \`pwd\` >> \$\@-t\n");
4054 # Extra stuff for AC_CANONICAL_*
4055 local (@whatlist) = ();
4056 if ($seen_canonical)
4058 push (@whatlist, 'host');
4061 # Extra stuff only for AC_CANONICAL_SYSTEM.
4062 if ($seen_canonical == $AC_CANONICAL_SYSTEM)
4064 push (@whatlist, 'target', 'build');
4067 local ($c1, $c2);
4068 foreach $c1 (@whatlist)
4070 foreach $c2 ('alias', 'triplet')
4072 $output_rules .= "\t\@echo 'set ${c1}_${c2} \$(${c1}_${c2})' >> \$\@-t\n";
4076 $output_rules .= ("\t\@echo '## All variables above are generated by configure. Do Not Edit ##' >> \$\@-t\n"
4077 . "\t\@test ! -f site.exp || sed '1,/^## All variables above are.*##/ d' site.exp >> \$\@-t\n"
4078 . "\t\@test ! -f site.exp || mv site.exp site.bak\n"
4079 . "\t\@mv \$\@-t site.exp\n");
4082 else
4084 local ($c);
4085 foreach $c ('DEJATOOL', 'RUNTEST', 'RUNTESTFLAGS')
4087 if (&variable_defined ($c))
4089 &am_line_error ($c, "\`$c' defined but \`dejagnu' not in \`AUTOMAKE_OPTIONS'");
4094 if (&variable_defined ('TESTS'))
4096 push (@check_tests, 'check-TESTS');
4097 push (@phony, 'check-TESTS');
4099 # Note: Solaris 2.7 seems to expand TESTS using VPATH. That's
4100 # why we also try `dir='
4101 $output_rules .= 'check-TESTS: $(TESTS)
4102 @failed=0; all=0; xfail=0; xpass=0; \\
4103 srcdir=$(srcdir); export srcdir; \\
4104 for tst in $(TESTS); do \\
4105 if test -f ./$$tst; then dir=./; \\
4106 elif test -f $$tst; then dir=; \\
4107 else dir="$(srcdir)/"; fi; \\
4108 if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \\
4109 all=`expr $$all + 1`; \\
4110 case " $(XFAIL_TESTS) " in \\
4111 *" $$tst "*) \\
4112 xpass=`expr $$xpass + 1`; \\
4113 failed=`expr $$failed + 1`; \\
4114 echo "XPASS: $$tst"; \\
4115 ;; \\
4116 *) \\
4117 echo "PASS: $$tst"; \\
4118 ;; \\
4119 esac; \\
4120 elif test $$? -ne 77; then \\
4121 all=`expr $$all + 1`; \\
4122 case " $(XFAIL_TESTS) " in \\
4123 *" $$tst "*) \\
4124 xfail=`expr $$xfail + 1`; \\
4125 echo "XFAIL: $$tst"; \\
4126 ;; \\
4127 *) \\
4128 failed=`expr $$failed + 1`; \\
4129 echo "FAIL: $$tst"; \\
4130 ;; \\
4131 esac; \\
4132 fi; \\
4133 done; \\
4134 if test "$$failed" -eq 0; then \\
4135 if test "$$xfail" -eq 0; then \\
4136 banner="All $$all tests passed"; \\
4137 else \\
4138 banner="All $$all tests behaved as expected ($$xfail expected failures)"; \\
4139 fi; \\
4140 else \\
4141 if test "$$xpass" -eq 0; then \\
4142 banner="$$failed of $$all tests failed"; \\
4143 else \\
4144 banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \\
4145 fi; \\
4146 fi; \\
4147 dashes=`echo "$$banner" | sed s/./=/g`; \\
4148 echo "$$dashes"; \\
4149 echo "$$banner"; \\
4150 echo "$$dashes"; \\
4151 test "$$failed" -eq 0
4156 # Handle Emacs Lisp.
4157 sub handle_emacs_lisp
4159 local (@elfiles) = &am_install_var ('-candist', 'lisp', 'LISP',
4160 'lisp', 'noinst');
4162 if (@elfiles)
4164 # Found some lisp.
4165 &define_configure_variable ('lispdir');
4166 &define_configure_variable ('EMACS');
4167 $output_rules .= (".el.elc:\n"
4168 . "\t\@echo 'WARNING: Warnings can be ignored. :-)'\n"
4169 . "\tif test \$(EMACS) != no; then \\\n"
4170 . "\t EMACS=\$(EMACS) \$(SHELL) \$(srcdir)/elisp-comp \$<; \\\n"
4171 . "\tfi\n");
4172 push (@suffixes, '.el', '.elc');
4174 # Generate .elc files.
4175 grep ($_ .= 'c', @elfiles);
4176 &define_pretty_variable ('ELCFILES', '', @elfiles);
4178 $output_rules .= &file_contents ('lisp-clean');
4179 push (@clean, 'lisp');
4180 &push_phony_cleaners ('lisp');
4182 push (@all, '$(ELCFILES)');
4184 local ($varname);
4185 if (&variable_defined ('lisp_LISP'))
4187 $varname = 'lisp_LISP';
4188 &am_error ("\`lisp_LISP' defined but \`AM_PATH_LISPDIR' not in \`configure.in'")
4189 if ! $seen_lispdir;
4191 else
4193 $varname = 'noinst_LISP';
4196 &require_file_with_line ($varname, $FOREIGN, 'elisp-comp');
4200 # Handle Python
4201 sub handle_python
4203 local (@pyfiles) = &am_install_var ('-defaultdist', 'python', 'PYTHON',
4204 'python', 'noinst');
4205 return if ! @pyfiles;
4207 # Found some python.
4208 &define_configure_variable ('pythondir');
4209 &define_configure_variable ('PYTHON');
4211 $output_rules .= &file_contents ('python-clean');
4212 push (@clean, 'python');
4214 &am_error ("\`python_PYTHON' defined but \`AM_CHECK_PYTHON' not in \`configure.in'")
4215 if ! $seen_pythondir && &variable_defined ('python_PYTHON');
4217 if ($config_aux_dir eq '.' || $config_aux_dir eq '')
4219 &define_variable ('py_compile', '$(top_srcdir)/py-compile');
4221 else
4223 &define_variable ('py_compile', $config_aux_dir . '/py-compile');
4227 # Handle Java.
4228 sub handle_java
4230 local (@sourcelist) = &am_install_var ('-candist', '-clean',
4231 'java', 'JAVA',
4232 'java', 'noinst', 'check');
4233 return if ! @sourcelist;
4235 &define_variable ('JAVAC', 'javac');
4236 &define_variable ('JAVACFLAGS', '');
4237 &define_variable ('CLASSPATH_ENV',
4238 'CLASSPATH=$(JAVAROOT):$(srcdir)/$(JAVAROOT):$$CLASSPATH');
4239 &define_variable ('JAVAROOT', '$(top_builddir)');
4241 local (%valid) = &am_primary_prefixes ('JAVA', 1,
4242 'java', 'noinst', 'check');
4244 local ($dir, $curs);
4245 foreach $curs (keys %valid)
4247 if (! &variable_defined ($curs . '_JAVA') || $curs eq 'noinst'
4248 || $curs eq 'EXTRA')
4250 next;
4253 if (defined $dir)
4255 &am_line_error ($curs . '_JAVA',
4256 "multiple _JAVA primaries in use");
4258 $dir = $curs;
4261 $output_rules .= ('class' . $dir . '.stamp: $(' . $dir . '_JAVA)' . "\n"
4262 . "\t" . '$(CLASSPATH_ENV) $(JAVAC) -d $(JAVAROOT) '
4263 . '$(JAVACFLAGS) $?' . "\n"
4264 . "\t" . 'echo timestamp > class' . $dir . '.stamp'
4265 . "\n");
4266 push (@all, 'class' . $dir . '.stamp');
4267 &push_dist_common ('$(' . $dir . '_JAVA)');
4270 # Handle some of the minor options.
4271 sub handle_minor_options
4273 if (defined $options{'readme-alpha'})
4275 if ($relative_dir eq '.')
4277 if ($package_version !~ /^$GNITS_VERSION_PATTERN$/)
4279 # FIXME: allow real filename.
4280 &am_conf_line_error ('configure.in',
4281 $package_version_line,
4282 "version \`$package_version' doesn't follow Gnits standards");
4284 elsif (defined $1 && -f 'README-alpha')
4286 # This means we have an alpha release. See
4287 # GNITS_VERSION_PATTERN for details.
4288 &require_file ($FOREIGN, 'README-alpha');
4294 ################################################################
4296 # Scan one file for interesting things. Subroutine of scan_configure.
4297 sub scan_one_configure_file
4299 local ($filename) = @_;
4300 local (*CONFIGURE);
4302 open (CONFIGURE, $filename)
4303 || die "automake: couldn't open \`$filename': $!\n";
4304 print "automake: reading $filename\n" if $verbose;
4306 while (<CONFIGURE>)
4308 # Remove comments from current line.
4309 s/\bdnl\b.*$//;
4310 s/\#.*$//;
4312 # Skip macro definitions. Otherwise we might be confused into
4313 # thinking that a macro that was only defined was actually
4314 # used.
4315 next if /AC_DEFUN/;
4317 # Follow includes. This is a weirdness commonly in use at
4318 # Cygnus and hopefully nowhere else.
4319 if (/sinclude\((.*)\)/ && -f $1)
4321 &scan_one_configure_file ($1);
4324 # Populate libobjs array.
4325 if (/AC_FUNC_ALLOCA/)
4327 $libsources{'alloca.c'} = 1;
4329 elsif (/AC_FUNC_GETLOADAVG/)
4331 $libsources{'getloadavg.c'} = 1;
4333 elsif (/AC_FUNC_MEMCMP/)
4335 $libsources{'memcmp.c'} = 1;
4337 elsif (/AC_STRUCT_ST_BLOCKS/)
4339 $libsources{'fileblocks.c'} = 1;
4341 elsif (/A[CM]_REPLACE_GNU_GETOPT/)
4343 $libsources{'getopt.c'} = 1;
4344 $libsources{'getopt1.c'} = 1;
4346 elsif (/AM_FUNC_STRTOD/)
4348 $libsources{'strtod.c'} = 1;
4350 elsif (/AM_WITH_REGEX/)
4352 $libsources{'rx.c'} = 1;
4353 $libsources{'rx.h'} = 1;
4354 $libsources{'regex.c'} = 1;
4355 $libsources{'regex.h'} = 1;
4356 $omit_dependencies{'rx.h'} = 1;
4357 $omit_dependencies{'regex.h'} = 1;
4359 elsif (/AC_FUNC_MKTIME/)
4361 $libsources{'mktime.c'} = 1;
4363 elsif (/AM_FUNC_ERROR_AT_LINE/)
4365 $libsources{'error.c'} = 1;
4366 $libsources{'error.h'} = 1;
4368 elsif (/AM_FUNC_OBSTACK/)
4370 $libsources{'obstack.c'} = 1;
4371 $libsources{'obstack.h'} = 1;
4373 elsif (/LIBOBJS="(.*)\s+\$LIBOBJS"/
4374 || /LIBOBJS="\$LIBOBJS\s+(.*)"/)
4376 foreach $libobj_iter (split (' ', $1))
4378 if ($libobj_iter =~ /^(.*)\.o(bj)?$/
4379 || $libobj_iter =~ /^(.*)\.\$ac_objext$/
4380 || $libobj_iter =~ /^(.*)\.\$\{ac_objext\}$/)
4382 $libsources{$1 . '.c'} = 1;
4387 if (! $in_ac_replace && s/AC_REPLACE_FUNCS\s*\(\[?//)
4389 $in_ac_replace = 1;
4391 if ($in_ac_replace)
4393 $in_ac_replace = 0 if s/[\]\)].*$//;
4394 # Remove trailing backslash.
4395 s/\\$//;
4396 foreach (split)
4398 # Need to skip empty elements for Perl 4.
4399 next if $_ eq '';
4400 $libsources{$_ . '.c'} = 1;
4404 if (/$obsolete_rx/o)
4406 local ($hint) = '';
4407 if ($obsolete_macros{$1} ne '')
4409 $hint = '; ' . $obsolete_macros{$1};
4411 &am_conf_line_error ($filename, $., "\`$1' is obsolete$hint");
4414 # Process the AC_OUTPUT macro.
4415 if (! $in_ac_output && s/AC_OUTPUT\s*\(\[?//)
4417 $in_ac_output = 1;
4418 $ac_output_line = $.;
4420 if ($in_ac_output)
4422 local ($closing) = 0;
4423 if (s/[\]\),].*$//)
4425 $in_ac_output = 0;
4426 $closing = 1;
4429 # Look at potential Makefile.am's.
4430 foreach (split)
4432 # Must skip empty string for Perl 4.
4433 next if $_ eq "\\" || $_ eq '';
4435 # Handle $local:$input syntax. Note that we ignore
4436 # every input file past the first, though we keep
4437 # those around for later.
4438 local ($local, $input, @rest) = split (/:/);
4439 if (! $input)
4441 $input = $local;
4443 else
4445 # FIXME: should be error if .in is missing.
4446 $input =~ s/\.in$//;
4449 if (-f $input . '.am')
4451 # We have a file that automake should generate.
4452 push (@make_input_list, $input);
4453 $make_list{$input} = join (':', ($local, @rest));
4455 else
4457 # We have a file that automake should cause to be
4458 # rebuilt, but shouldn't generate itself.
4459 push (@other_input_files, $_);
4463 if ($closing && @make_input_list == 0 && @other_input_files == 0)
4465 &am_conf_line_error ($filename, $ac_output_line,
4466 "No files mentioned in \`AC_OUTPUT'");
4467 exit 1;
4471 if (/$AC_CONFIG_AUX_DIR_PATTERN/o)
4473 @config_aux_path = $1;
4476 # Check for ansi2knr.
4477 $am_c_prototypes = 1 if /AM_C_PROTOTYPES/;
4479 # Check for exe extension stuff.
4480 if (/AC_EXEEXT/)
4482 $seen_exeext = 1;
4483 $configure_vars{'EXEEXT'} = $filename . ':' . $.;
4486 if (/AC_OBJEXT/)
4488 $seen_objext = 1;
4489 $configure_vars{'OBJEXT'} = $filename . ':' . $.;
4492 # Check for `-c -o' code.
4493 $seen_cc_c_o = 1 if /AM_PROG_CC_C_O/;
4495 # Check for NLS support.
4496 if (/AM_GNU_GETTEXT/)
4498 $seen_gettext = 1;
4499 $ac_gettext_line = $.;
4500 $omit_dependencies{'libintl.h'} = 1;
4503 # Look for ALL_LINGUAS.
4504 if (/ALL_LINGUAS="(.*)"$/ || /ALL_LINGUAS=(.*)$/)
4506 $seen_linguas = 1;
4507 $all_linguas = $1;
4508 $all_linguas_line = $.;
4511 # Handle configuration headers. A config header of `[$1]'
4512 # means we are actually scanning AM_CONFIG_HEADER from
4513 # aclocal.m4.
4514 if (/A([CM])_CONFIG_HEADER\s*\((.*)\)/
4515 && $2 ne '[$1]')
4517 &am_conf_line_error
4518 ($filename, $., "\`automake requires \`AM_CONFIG_HEADER', not \`AC_CONFIG_HEADER'")
4519 if $1 eq 'C';
4521 $config_header_line = $.;
4522 local ($one_hdr);
4523 foreach $one_hdr (split (' ', $2))
4525 push (@config_fullnames, $one_hdr);
4526 if ($one_hdr =~ /^([^:]+):(.+)$/)
4528 push (@config_names, $1);
4529 push (@config_headers, $2);
4531 else
4533 push (@config_names, $one_hdr);
4534 push (@config_headers, $one_hdr . '.in');
4539 # Handle AC_CANONICAL_*. Always allow upgrading to
4540 # AC_CANONICAL_SYSTEM, but never downgrading.
4541 $seen_canonical = $AC_CANONICAL_HOST
4542 if ! $seen_canonical
4543 && (/AC_CANONICAL_HOST/ || /AC_CHECK_TOOL/);
4544 $seen_canonical = $AC_CANONICAL_SYSTEM if /AC_CANONICAL_SYSTEM/;
4546 $seen_path_xtra = 1 if /AC_PATH_XTRA/;
4548 # This macro handles several different things.
4549 if (/$AM_INIT_AUTOMAKE_PATTERN/o)
4551 $seen_make_set = 1;
4552 $seen_package = 1;
4553 $seen_version = 1;
4554 $seen_arg_prog = 1;
4555 $seen_prog_install = 1;
4556 ($package_version = $1) =~ s/$AM_PACKAGE_VERSION_PATTERN/$1/o;
4557 $package_version_line = $.;
4558 $seen_init_automake = 1;
4561 # Some things required by Automake.
4562 $seen_make_set = 1 if /AC_PROG_MAKE_SET/;
4563 $seen_arg_prog = 1 if /AC_ARG_PROGRAM/;
4565 if (/AM_PROG_LEX/)
4567 $configure_vars{'LEX'} = $filename . ':' . $.;
4568 $seen_decl_yytext = 1;
4570 if (/AC_DECL_YYTEXT/ && $filename =~ /configure\.in$/)
4572 &am_conf_line_warning ($filename, $., "\`AC_DECL_YYTEXT' is covered by \`AM_PROG_LEX'");
4574 if (/AC_PROG_LEX/ && $filename =~ /configure\.in$/)
4576 &am_conf_line_warning ($filename, $., "automake requires \`AM_PROG_LEX', not \`AC_PROG_LEX'");
4579 if (/AC_PROG_(F77|YACC|RANLIB|CC|CXXCPP|CXX|LEX|AWK|CPP|LN_S)/)
4581 $configure_vars{$1} = $filename . ':' . $.;
4583 if (/$AC_CHECK_PATTERN/o)
4585 $configure_vars{$3} = $filename . ':' . $.;
4587 if (/$AM_MISSING_PATTERN/o
4588 && $1 ne 'ACLOCAL'
4589 && $1 ne 'AUTOCONF'
4590 && $1 ne 'AUTOMAKE'
4591 && $1 ne 'AUTOHEADER')
4593 $configure_vars{$1} = $filename . ':' . $.;
4596 # Explicitly avoid ANSI2KNR -- we AC_SUBST that in protos.m4,
4597 # but later define it elsewhere. This is pretty hacky. We
4598 # also explicitly avoid INSTALL_SCRIPT and some other
4599 # variables because they are defined in header-vars.am.
4600 # FIXME.
4601 if (/$AC_SUBST_PATTERN/o
4602 && $1 ne 'ANSI2KNR'
4603 && $1 ne 'INSTALL_SCRIPT'
4604 && $1 ne 'INSTALL_DATA')
4606 $configure_vars{$1} = $filename . ':' . $.;
4609 $seen_decl_yytext = 1 if /AC_DECL_YYTEXT/;
4610 if (/AM_MAINTAINER_MODE/)
4612 $seen_maint_mode = 1;
4613 $configure_cond{'MAINTAINER_MODE'} = 1;
4615 $seen_package = 1 if /PACKAGE=/;
4617 # Skip VERSION of [$2]; that is from AM_INIT_AUTOMAKE.
4618 if (/\bVERSION=(\S+)/ && $1 ne '[$2]')
4620 $seen_version = 1;
4621 $package_version = $1;
4622 $package_version_line = $.;
4624 elsif (/VERSION=/)
4626 $seen_version = 1;
4629 $seen_prog_install = 1 if /AC_PROG_INSTALL/;
4630 $seen_lispdir = 1 if /AM_PATH_LISPDIR/;
4631 $seen_pythondir = 1 if /AM_PATH_PYTHON/;
4633 if (/A(C|M)_PROG_LIBTOOL/)
4635 if (/AM_PROG_LIBTOOL/)
4637 &am_conf_line_warning ($filename, $., "\`AM_PROG_LIBTOOL' is obsolete, use \`AC_PROG_LIBTOOL' instead");
4639 $seen_libtool = 1;
4640 $libtool_line = $.;
4641 $configure_vars{'LIBTOOL'} = $filename . ':' . $.;
4642 $configure_vars{'RANLIB'} = $filename . ':' . $.;
4643 $configure_vars{'CC'} = $filename . ':' . $.;
4644 # AC_PROG_LIBTOOL runs AC_CANONICAL_HOST. Make sure we
4645 # never downgrade (if we've seen AC_CANONICAL_SYSTEM).
4646 $seen_canonical = $AC_CANONICAL_HOST if ! $seen_canonical;
4649 $seen_multilib = 1 if (/AM_ENABLE_MULTILIB/);
4651 if (/$AM_CONDITIONAL_PATTERN/o)
4653 $configure_cond{$1} = 1;
4656 # Check for Fortran 77 intrinsic and run-time libraries.
4657 if (/AC_F77_LIBRARY_LDFLAGS/)
4659 $configure_vars{'FLIBS'} = $filename . ':' . $.;
4663 close (CONFIGURE);
4666 # Scan configure.in and aclocal.m4 for interesting things. We must
4667 # scan aclocal.m4 because there might be AC_SUBSTs and such there.
4668 sub scan_configure
4670 # Reinitialize libsources here. This isn't really necessary,
4671 # since we currently assume there is only one configure.in. But
4672 # that won't always be the case.
4673 %libsources = ();
4675 local ($in_ac_output, $in_ac_replace) = (0, 0);
4676 local (%make_list, @make_input_list);
4677 local ($libobj_iter);
4679 &scan_one_configure_file ('configure.in');
4680 &scan_one_configure_file ('aclocal.m4')
4681 if -f 'aclocal.m4';
4683 # Set input and output files if not specified by user.
4684 if (! @input_files)
4686 @input_files = @make_input_list;
4687 %output_files = %make_list;
4690 @configure_input_files = @make_input_list;
4692 &am_conf_error ("\`AM_INIT_AUTOMAKE' must be used in configure.in")
4693 if ! $seen_init_automake;
4695 &am_conf_error ("\`PACKAGE' not defined in configure.in")
4696 if ! $seen_package;
4697 &am_conf_error ("\`VERSION' not defined in configure.in")
4698 if ! $seen_version;
4700 # Always require AC_PROG_MAKE_SET. We might randomly use $(MAKE)
4701 # for our own reasons.
4702 &am_conf_error ("\`AC_PROG_MAKE_SET' must be used in configure.in")
4703 if ! $seen_make_set;
4705 # Look for some files we need. Always check for these. This
4706 # check must be done for every run, even those where we are only
4707 # looking at a subdir Makefile. We must set relative_dir so that
4708 # the file-finding machinery works.
4709 local ($relative_dir) = '.';
4710 &require_config_file ($FOREIGN, 'install-sh', 'mkinstalldirs', 'missing');
4711 &am_error ("\`install.sh' is an anachronism; use \`install-sh' instead")
4712 if -f $config_aux_path[0] . '/install.sh';
4714 &require_config_file ($FOREIGN, 'py-compile')
4715 if $seen_pythondir;
4717 # Preserve dist_common for later.
4718 %configure_dist_common = %dist_common;
4721 ################################################################
4723 # Set up for Cygnus mode.
4724 sub check_cygnus
4726 return unless $cygnus_mode;
4728 &set_strictness ('foreign');
4729 $options{'no-installinfo'} = 1;
4730 $options{'no-dependencies'} = 1;
4731 $use_dependencies = 0;
4733 if (! $seen_maint_mode)
4735 &am_conf_error ("\`AM_MAINTAINER_MODE' required when --cygnus specified");
4738 if (! $seen_exeext)
4740 &am_conf_error ("\`AC_EXEEXT' required when --cygnus specified");
4744 # Do any extra checking for GNU standards.
4745 sub check_gnu_standards
4747 if ($relative_dir eq '.')
4749 # In top level (or only) directory.
4750 &require_file ($GNU, 'INSTALL', 'NEWS', 'README', 'COPYING',
4751 'AUTHORS', 'ChangeLog');
4754 if ($strictness >= $GNU)
4756 if (defined $options{'no-installman'})
4758 &am_line_error ('AUTOMAKE_OPTIONS',
4759 "option \`no-installman' disallowed by GNU standards");
4762 if (defined $options{'no-installinfo'})
4764 &am_line_error ('AUTOMAKE_OPTIONS',
4765 "option \`no-installinfo' disallowed by GNU standards");
4770 # Do any extra checking for GNITS standards.
4771 sub check_gnits_standards
4773 if ($relative_dir eq '.')
4775 # In top level (or only) directory.
4776 &require_file ($GNITS, 'THANKS');
4780 ################################################################
4782 # Functions to handle files of each language.
4784 # Each `lang_X_rewrite' function follows a simple formula:
4785 # * Args are the directory, base name and extension of the file.
4786 # * Return value is 1 if file is to be dealt with, 0 otherwise.
4787 # Much of the actual processing is handled in handle_single_transform_list.
4788 # These functions exist so that auxiliary information can be recorded
4789 # for a later cleanup pass. Note that the calls to these functions
4790 # are computed, so don't bother searching for their precise names
4791 # in the source.
4793 # This is just a convenience function that can be used to determine
4794 # when a subdir object should be used.
4795 sub lang_sub_obj
4797 return defined $options{'subdir-objects'} ? $LANG_SUBDIR : $LANG_PROCESS;
4800 # Rewrite a single C source file.
4801 sub lang_c_rewrite
4803 local ($directory, $base, $ext) = @_;
4805 if (defined $options{'ansi2knr'} && $base =~ /_$/)
4807 # FIXME: include line number in error.
4808 &am_error ("C source file \`$base.c' would be deleted by ansi2knr rules");
4811 local ($r) = $LANG_PROCESS;
4812 if (defined $options{'subdir-objects'})
4814 $r = $LANG_SUBDIR;
4815 $base = $directory . '/' . $base;
4817 if (! $seen_cc_c_o)
4819 # Only give error once.
4820 $seen_cc_c_o = 1;
4821 # FIXME: line number.
4822 &am_error ("C objects in subdir but \`AM_PROG_CC_C_O' not in \`configure.in'");
4825 &require_file ($FOREIGN, 'compile')
4826 if $relative_dir eq '.';
4829 $de_ansi_files{$base} = 1;
4830 return $r;
4833 # Rewrite a single C++ source file.
4834 sub lang_cxx_rewrite
4836 return &lang_sub_obj;
4839 # Rewrite a single header file.
4840 sub lang_header_rewrite
4842 # Header files are simply ignored.
4843 return $LANG_IGNORE;
4846 # Rewrite a single yacc file.
4847 sub lang_yacc_rewrite
4849 local ($directory, $base, $ext) = @_;
4851 local ($r) = &lang_c_rewrite ($directory, $base, $ext);
4852 local ($pfx) = '';
4853 if ($r == $LANG_SUBDIR)
4855 $pfx = $directory . '/';
4857 $yacc_sources{$pfx . $base . '.' . $ext} = 1;
4858 $ext =~ tr/y/c/;
4859 &saw_extension ('c');
4860 # FIXME: nodist.
4861 &push_dist_common ($pfx . $base . '.' . $ext);
4862 return $r;
4865 # Rewrite a single yacc++ file.
4866 sub lang_yaccxx_rewrite
4868 local ($directory, $base, $ext) = @_;
4870 local ($r) = $LANG_PROCESS;
4871 local ($pfx) = '';
4872 if (defined $options{'subdir-objects'})
4874 $pfx = $directory . '/';
4875 $r = $LANG_SUBDIR;
4877 $yacc_sources{$pfx . $base . '.' . $ext} = 1;
4878 $ext =~ tr/y/c/;
4879 &saw_extension ($ext);
4880 # FIXME: nodist.
4881 &push_dist_common ($pfx . $base . '.' . $ext);
4882 return $r;
4885 # Rewrite a single lex file.
4886 sub lang_lex_rewrite
4888 local ($directory, $base, $ext) = @_;
4890 local ($r) = &lang_c_rewrite ($directory, $base, $ext);
4891 local ($pfx) = '';
4892 if ($r == $LANG_SUBDIR)
4894 $pfx = $directory . '/';
4896 $lex_sources{$pfx . $base . '.' . $ext} = 1;
4897 $ext =~ tr/l/c/;
4898 &saw_extension ('c');
4899 # FIXME: nodist.
4900 &push_dist_common ($pfx . $base . '.' . $ext);
4901 return $r;
4904 # Rewrite a single lex++ file.
4905 sub lang_lexxx_rewrite
4907 local ($directory, $base, $ext) = @_;
4909 local ($r) = $LANG_PROCESS;
4910 local ($pfx) = '';
4911 if (defined $options{'subdir-objects'})
4913 $pfx = $directory . '/';
4914 $r = $LANG_SUBDIR;
4916 $lex_sources{$pfx . $base . '.' . $ext} = 1;
4917 $ext =~ tr/l/c/;
4918 &saw_extension ($ext);
4919 # FIXME: nodist.
4920 &push_dist_common ($pfx . $base . '.' . $ext);
4921 return $r;
4924 # Rewrite a single assembly file.
4925 sub lang_asm_rewrite
4927 return &lang_sub_obj;
4930 # Rewrite a single Fortran 77 file.
4931 sub lang_f77_rewrite
4933 return $LANG_PROCESS;
4936 # Rewrite a single preprocessed Fortran 77 file.
4937 sub lang_ppf77_rewrite
4939 return $LANG_PROCESS;
4942 # Rewrite a single ratfor file.
4943 sub lang_ratfor_rewrite
4945 return $LANG_PROCESS;
4948 # Rewrite a single Objective C file.
4949 sub lang_objc_rewrite
4951 return &lang_sub_obj;
4954 # Rewrite a single Java file.
4955 sub lang_java_rewrite
4957 return $LANG_SUBDIR;
4960 # The lang_X_finish functions are called after all source file
4961 # processing is done. Each should handle defining rules for the
4962 # language, etc. A finish function is only called if a source file of
4963 # the appropriate type has been seen.
4965 sub lang_c_finish
4967 # Push all libobjs files onto de_ansi_files. We actually only
4968 # push files which exist in the current directory, and which are
4969 # genuine source files.
4970 local ($file);
4971 foreach $file (keys %libsources)
4973 if ($file =~ /^(.*)\.[cly]$/ && -f "$relative_dir/$file")
4975 $de_ansi_files{$1} = 1;
4979 if (defined $options{'ansi2knr'} && keys %de_ansi_files)
4981 # Make all _.c files depend on their corresponding .c files.
4982 local ($base, @objects);
4983 foreach $base (sort keys %de_ansi_files)
4985 # Each _.c file must depend on ansi2knr; otherwise it
4986 # might be used in a parallel build before it is built.
4987 # We need to support files in the srcdir and in the build
4988 # dir (because these files might be auto-generated. But
4989 # we can't use $< -- some makes only define $< during a
4990 # suffix rule.
4991 $output_rules .= ($base . "_.c: $base.c \$(ANSI2KNR)\n\t"
4992 . '$(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) '
4993 . '`if test -f $(srcdir)/' . $base . '.c'
4994 . '; then echo $(srcdir)/' . $base . '.c'
4995 . '; else echo ' . $base . '.c; fi` '
4996 . "| sed 's/^# \\([0-9]\\)/#line \\1/' "
4997 . '| $(ANSI2KNR) > ' . $base . "_.c\n");
4998 push (@objects, $base . '_'
4999 . ($seen_objext ? '.$(OBJEXT)' : '.o'));
5000 push (@objects, $base . '_.lo') if $seen_libtool;
5003 # Make all _.o (and _.lo) files depend on ansi2knr.
5004 # Use a sneaky little hack to make it print nicely.
5005 &pretty_print_rule ('', '', @objects, ':', '$(ANSI2KNR)');
5008 if (! defined $configure_vars{'CC'})
5010 # FIXME: line number.
5011 &am_error ("C source seen but \`CC' not defined in \`configure.in'");
5015 sub lang_cxx_finish
5017 local ($ltcompile, $ltlink) = &libtool_compiler;
5019 &define_variable ('CXXLD', '$(CXX)');
5020 &define_variable ('CXXLINK', $ltlink . '$(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@');
5022 if (! defined $configure_vars{'CXX'})
5024 &am_error ("C++ source seen but \`CXX' not defined in \`configure.in'");
5028 sub lang_header_finish
5030 # Nothing to do.
5033 # This is a helper for both lex and yacc.
5034 sub yacc_lex_finish_helper
5036 return if defined $language_scratch{'lex-yacc-done'};
5037 $language_scratch{'lex-yacc-done'} = 1;
5039 # If there is more than one distinct yacc (resp lex) source file
5040 # in a given directory, then the `ylwrap' program is required to
5041 # allow parallel builds to work correctly. FIXME: for now, no
5042 # line number.
5043 &require_config_file ($FOREIGN, 'ylwrap');
5044 if ($config_aux_dir ne '.' && $config_aux_dir ne '')
5046 &define_variable ('YLWRAP', $config_aux_dir . "/ylwrap");
5048 else
5050 &define_variable ('YLWRAP', '$(srcdir)/ylwrap');
5054 sub lang_yacc_finish
5056 return if defined $language_scratch{'yacc-done'};
5057 $language_scratch{'yacc-done'} = 1;
5059 local ($file, $base, $hname, $cname);
5060 local (%seen_suffix) = ();
5061 local (@yacc_files) = sort keys %yacc_sources;
5062 local ($yacc_count) = scalar (@yacc_files);
5063 foreach $file (@yacc_files)
5065 $file =~ /(\..*)$/;
5066 &output_yacc_build_rule ($1, $yacc_count > 1)
5067 if ! defined $seen_suffix{$1};
5068 $seen_suffix{$1} = 1;
5070 $file =~ /^(.*)\.(y|yy|y\+\+|yxx|ypp)$/;
5071 $base = $1;
5072 $hname = 'h'; # Always use `.h' for header file.
5073 ($cname = $2) =~ tr/y/c/;
5075 if ((&variable_defined ('AM_YFLAGS')
5076 && &variable_value ('AM_YFLAGS') =~ /(^|\s)-d(\s|$)/)
5077 || (&variable_defined ('YFLAGS')
5078 && &variable_value ('YFLAGS') =~ /(^|\s)-d(\s|$)/)) {
5079 # Now generate rule to make the header file. This should only
5080 # be generated if `yacc -d' specified.
5081 $output_rules .= "${base}.${hname}: ${base}.${cname}\n";
5083 # If the files are built in the build directory, then we want
5084 # to remove them with `make clean'. If they are in srcdir
5085 # they shouldn't be touched. However, we can't determine this
5086 # statically, and the GNU rules say that yacc/lex output files
5087 # should be removed by maintainer-clean. So that's what we
5088 # do.
5089 push (@maintainer_clean_files, "${base}.${hname}");
5091 &push_dist_common ("${base}.${hname}");
5093 push (@maintainer_clean_files, "${base}.${cname}");
5095 $output_rules .= "\n";
5097 if (! defined $configure_vars{'YACC'})
5099 &am_error ("yacc source seen but \`YACC' not defined in \`configure.in'");
5101 if (&variable_defined ('YACCFLAGS'))
5103 &am_line_error ('YACCFLAGS',
5104 "\`YACCFLAGS' obsolete; use \`YFLAGS' instead");
5107 if ($yacc_count > 1)
5109 &yacc_lex_finish_helper;
5113 sub lang_yaccxx_finish
5115 &lang_yacc_finish;
5118 sub lang_lex_finish
5120 return if defined $language_scratch{'lex-done'};
5121 $language_scratch{'lex-done'} = 1;
5123 local (%seen_suffix) = ();
5124 local ($file, $cname);
5125 local ($lex_count) = scalar (keys %lex_sources);
5126 foreach $file (sort keys %lex_sources)
5128 $file =~ /(\..*)$/;
5129 &output_lex_build_rule ($1, $lex_count > 1)
5130 if (! defined $seen_suffix{$1});
5131 $seen_suffix{$1} = 1;
5133 # If the files are built in the build directory, then we want
5134 # to remove them with `make clean'. If they are in srcdir
5135 # they shouldn't be touched. However, we can't determine this
5136 # statically, and the GNU rules say that yacc/lex output files
5137 # should be removed by maintainer-clean. So that's what we
5138 # do.
5139 $file =~ /^(.*)\.(l|ll|l\+\+|lxx|lpp)$/;
5140 ($cname = $2) =~ tr/l/c/;
5141 push (@maintainer_clean_files, "${1}.${cname}");
5144 if (! defined $configure_vars{'LEX'})
5146 &am_error ("lex source seen but \`LEX' not defined in \`configure.in'");
5148 if (! $seen_decl_yytext)
5150 &am_error ("lex source seen but \`AC_DECL_YYTEXT' not in \`configure.in'");
5153 if ($lex_count > 1)
5155 &yacc_lex_finish_helper;
5159 sub lang_lexxx_finish
5161 &lang_lex_finish;
5164 sub lang_asm_finish
5166 # We need the C code for assembly.
5167 &lang_c_finish;
5170 sub lang_f77_finish
5172 # FIXME: this function can be called more than once. We should
5173 # arrange for it to only do anything the first time through.
5175 local ($ltcompile, $ltlink) = &libtool_compiler;
5177 &define_variable ('F77LD', '$(F77)');
5178 &define_variable ('F77LINK', $ltlink . '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@');
5180 if (! defined $configure_vars{'F77'})
5182 &am_error ("Fortran 77 source seen but \`F77' not defined in \`configure.in'");
5186 # Preprocessed Fortran 77
5188 # The current support for preprocessing Fortran 77 just involves passing
5189 # `$(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS)' as additional flags
5190 # to the Fortran 77 compiler, since this is how GNU Make does it; see
5191 # the `GNU Make Manual, Edition 0.51 for `make' Version 3.76 Beta'
5192 # (specifically, from info file `(make)Catalogue of Rules').
5194 # A better approach would be to write an Autoconf test
5195 # (i.e. AC_PROG_FPP) for a Fortran 77 preprocessor, because not all
5196 # Fortran 77 compilers know how to do preprocessing. The Autoconf macro
5197 # AC_PROG_FPP should test the Fortran 77 compiler first for
5198 # preprocessing capabilities, and then fall back on cpp (if cpp were
5199 # available).
5200 sub lang_ppf77_finish
5202 &lang_f77_finish;
5204 # We also handle the case of preprocessing `.F' files into `.f'
5205 # files.
5206 $output_rules .= (".F.f:\n"
5207 . "\t\$(F77COMPILE) -F \$<\n");
5210 sub lang_ratfor_finish
5212 &lang_f77_finish;
5214 # We also handle the case of preprocessing `.r' files into `.f'
5215 # files.
5216 $output_rules .= (".r.f:\n"
5217 . "\t\$(RCOMPILE) -F \$<\n");
5220 sub lang_objc_finish
5222 local ($ltcompile, $ltlink) = &libtool_compiler;
5224 &define_variable ('OBJCLD', '$(OBJC)');
5225 &define_variable ('OBJCLINK', $ltlink . '$(OBJCLD) $(AM_OBJCFLAGS) $(OBJCFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@');
5227 if (! defined $configure_vars{'OBJC'})
5229 &am_error ("Objective C source seen but \`OBJC' not defined in \`configure.in'");
5233 sub lang_java_finish
5235 local ($ltcompile, $ltlink) = &libtool_compiler;
5237 &define_variable ('GCJLD', '$(GCJ)');
5238 &define_variable ('GCJLINK', $ltlink . '$(GCJLD) $(AM_GCJFLAGS) $(GCJFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@');
5240 if (! defined $configure_vars{'GCJ'})
5242 &am_error ("Java source seen but \`GCJ' not defined in \`configure.in'");
5246 # A helper which computes a sorted list of all extensions for LANG.
5247 sub lang_extensions
5249 local ($lang) = @_;
5250 local ($key, @r);
5251 foreach $key (sort keys %extension_seen)
5253 push (@r, '.' . $key) if $extension_map{$key} eq $lang;
5255 return @r;
5258 # A helper which decides whether libtool is needed. Returns prefix
5259 # for compiler and linker.
5260 sub libtool_compiler
5262 local ($ltcompile, $ltlink) = ('', '');
5263 if ($seen_libtool)
5265 &define_configure_variable ("LIBTOOL");
5266 $ltcompile = '$(LIBTOOL) --mode=compile ';
5267 $ltlink = '$(LIBTOOL) --mode=link ';
5269 return ($ltcompile, $ltlink);
5272 # Given a hash table of linker names, pick the name that has the most
5273 # precedence. This is lame, but something has to have global
5274 # knowledge in order to eliminate the conflict. Add more linkers as
5275 # required.
5276 sub resolve_linker
5278 local (%linkers) = @_;
5280 return 'GCJLINK'
5281 if defined $linkers{'GCJLINK'};
5282 return 'CXXLINK'
5283 if defined $linkers{'CXXLINK'};
5284 return 'F77LINK'
5285 if defined $linkers{'F77LINK'};
5286 return 'OBJCLINK'
5287 if defined $linkers{'OBJCLINK'};
5288 return 'LINK';
5291 # Called to indicate that an extension was used.
5292 sub saw_extension
5294 local ($ext) = @_;
5295 $extension_seen{$ext} = 1;
5298 # Called to ask whether source files have been seen . If HEADERS is 1,
5299 # headers can be included.
5300 sub saw_sources_p
5302 local ($headers) = @_;
5304 if ($headers)
5306 $headers = 0;
5308 else
5310 local (@exts) = &lang_extensions ('header');
5311 $headers = @exts;
5314 return scalar keys %extension_seen > $headers;
5317 # Register a single language. LANGUAGE is the name of the language.
5318 # Each OPTION is either of the form NAME=VALUE, or is a file extension
5319 # (sans `.').
5320 sub register_language
5322 local ($language, @options) = @_;
5324 # Set the defaults.
5325 $language_map{$language . '-ansi-p'} = 0;
5326 $language_map{$language . '-linker'} = '';
5327 $language_map{$language . '-autodep'} = 'no';
5329 local ($iter);
5330 foreach $iter (@options)
5332 if ($iter =~ /^(.*)=(.*)$/)
5334 $language_map{$language . '-' . $1} = $2;
5336 elsif (defined $extension_map{$iter})
5338 print STDERR
5339 "automake: programming error: duplicate extension $iter\n";
5340 exit 1;
5342 else
5344 $extension_map{$iter} = $language;
5349 # This function is used to find a path from a user-specified suffix to
5350 # `o' or to some other suffix we recognize internally, eg `cc'.
5351 sub derive_suffix
5353 local ($source_ext) = @_;
5355 # FIXME: hard-coding `o' is a mistake. Doing something
5356 # intelligent is harder.
5357 while ($extension_map{$source_ext} eq ''
5358 && $source_ext ne 'o'
5359 && defined $suffix_rules{$source_ext})
5361 $source_ext = $suffix_rules{$source_ext};
5364 return $source_ext;
5368 ################################################################
5370 # Pretty-print something. HEAD is what should be printed at the
5371 # beginning of the first line, FILL is what should be printed at the
5372 # beginning of every subsequent line.
5373 sub pretty_print_internal
5375 local ($head, $fill, @values) = @_;
5377 local ($column) = length ($head);
5378 local ($result) = $head;
5380 # Fill length is number of characters. However, each Tab
5381 # character counts for eight. So we count the number of Tabs and
5382 # multiply by 7.
5383 local ($fill_length) = length ($fill);
5384 $fill_length += 7 * ($fill =~ tr/\t/\t/d);
5386 local ($bol) = ($head eq '');
5387 foreach (@values)
5389 # "71" because we also print a space.
5390 if ($column + length ($_) > 71)
5392 $result .= " \\\n" . $fill;
5393 $column = $fill_length;
5394 $bol = 1;
5397 $result .= ' ' unless ($bol);
5398 $result .= $_;
5399 $column += length ($_) + 1;
5400 $bol = 0;
5403 $result .= "\n";
5404 return $result;
5407 # Pretty-print something and append to output_vars.
5408 sub pretty_print
5410 $output_vars .= &pretty_print_internal (@_);
5413 # Pretty-print something and append to output_rules.
5414 sub pretty_print_rule
5416 $output_rules .= &pretty_print_internal (@_);
5420 ################################################################
5422 # See if a target exists.
5423 sub target_defined
5425 local ($target) = @_;
5426 return defined $targets{$target};
5429 # See if two conditionals are the same.
5430 sub conditional_same
5432 local ($cond1, $cond2) = @_;
5434 return (&conditional_true_when ($cond1, $cond2)
5435 && &conditional_true_when ($cond2, $cond1));
5438 # See if a conditional is true. Both arguments are conditional
5439 # strings. This returns true if the first conditional is true when
5440 # the second conditional is true.
5441 sub conditional_true_when
5443 local ($cond, $when) = @_;
5445 # Check the easy case first.
5446 if ($cond eq $when)
5448 return 1;
5451 # Check each component of $cond, which looks @COND1@@COND2@.
5452 foreach $comp (split ('@', $cond))
5454 # The way we split will give null strings between each
5455 # condition.
5456 next if ! $comp;
5458 if (index ($when, '@' . $comp . '@') == -1)
5460 return 0;
5464 return 1;
5467 # Check for an ambiguous conditional. This is called when a variable
5468 # or target is being defined conditionally. If we already know about
5469 # a definition that is true under the same conditions, then we have an
5470 # ambiguity.
5471 sub check_ambiguous_conditional
5473 local ($var_name, $cond) = @_;
5474 local (@cond_vals) = split (' ', $conditional{$var_name});
5475 while (@cond_vals)
5477 local ($vcond) = shift (@cond_vals);
5478 shift (@cond_vals);
5479 if (&conditional_true_when ($vcond, $cond)
5480 || &conditional_true_when ($cond, $vcond))
5482 &am_line_error ($var_name,
5483 "$var_name multiply defined in condition");
5488 # See if a variable exists. The first argument is the variable name,
5489 # and the optional second argument is the condition which we should
5490 # check. If no condition is given, we currently return true if the
5491 # variable is defined under any condition.
5492 sub variable_defined
5494 local ($var, $cond) = @_;
5495 if (defined $targets{$var})
5497 &am_line_error ($var, "\`$var' is target; expected variable");
5498 return 0;
5500 elsif (defined $contents{$var})
5502 if ($cond && $conditional{$var})
5504 # We have been asked to check for a particular condition,
5505 # and the variable is defined conditionally. We need to
5506 # look through the conditions under which the variable is
5507 # defined, and see if any of them match the conditional we
5508 # have been asked to check.
5509 local (@cond_vars) = split (' ', $conditional{$var});
5510 while (@cond_vars)
5512 if (&conditional_same ($cond, shift (@cond_vars)))
5514 # Even a conditional examination is good enough
5515 # for us. FIXME: really should maintain examined
5516 # status on a per-condition basis.
5517 $content_seen{$var} = 1;
5518 return 1;
5520 shift (@cond_vars);
5523 # The variable is not defined for the given condition.
5524 return 0;
5527 $content_seen{$var} = 1;
5528 return 1;
5530 return 0;
5533 # Mark a variable as examined.
5534 sub examine_variable
5536 local ($var) = @_;
5537 &variable_defined ($var);
5540 # Quote a value in order to put it in $conditional. We need to quote
5541 # spaces, and we need to handle null strings, so that we can later
5542 # retrieve values by splitting on space.
5543 sub quote_cond_val
5545 local ($val) = @_;
5546 $val =~ tr/ \t\n/\001\003\004/;
5547 $val = "\002" if $val eq '';
5548 return $val;
5551 # Unquote a value in $conditional.
5552 sub unquote_cond_val
5554 local ($val) = @_;
5555 $val =~ tr/\001\003\004/ \t\n/;
5556 $val =~ s/\002//g;
5557 return $val;
5560 # Return the set of conditions for which a variable is defined.
5562 # If the variable is not defined conditionally, and is not defined in
5563 # terms of any variables which are defined conditionally, then this
5564 # returns the empty list.
5566 # If the variable is defined conditionally, but is not defined in
5567 # terms of any variables which are defined conditionally, then this
5568 # returns the list of conditions for which the variable is defined.
5570 # If the variable is defined in terms of any variables which are
5571 # defined conditionally, then this returns a full set of permutations
5572 # of the subvariable conditions. For example, if the variable is
5573 # defined in terms of a variable which is defined for @COND_TRUE@,
5574 # then this returns both @COND_TRUE@ and @COND_FALSE@. This is
5575 # because we will need to define the variable under both conditions.
5577 sub variable_conditions
5579 local ($var) = @_;
5580 local (%uniqify);
5581 local (@uniq_list);
5582 local ($cond);
5584 %vars_scanned = ();
5585 foreach $cond (&variable_conditions_sub ($var, '', ()))
5587 $uniqify{$cond} = 1;
5590 @uniq_list = sort keys %uniqify;
5591 # Note we cannot just do `return sort keys %uniqify', because this
5592 # function is sometimes used in a scalar context.
5593 return @uniq_list;
5596 # A subroutine of variable_conditions. We only return conditions
5597 # which are true for all the conditions in @PARENT_CONDS.
5598 sub variable_conditions_sub
5600 local ($var, $parent, @parent_conds) = @_;
5601 local (@new_conds) = ();
5603 if (defined $vars_scanned{$var})
5605 &am_line_error ($parent, "variable \`$var' recursively defined");
5606 return ();
5608 $vars_scanned{$var} = 1;
5610 if (! $conditional{$var})
5612 foreach (split (' ', $contents{$var}))
5614 # If a comment seen, just leave.
5615 last if /^#/;
5617 # Handle variable substitutions.
5618 if (/^\$\{(.*)\}$/ || /^\$\((.*)\)$/)
5620 push (@new_conds,
5621 &variable_conditions_sub ($1, $var, @parent_conds));
5625 # Now we want to return all permutations of the subvariable
5626 # conditions.
5627 local (%allconds, $item);
5628 foreach $item (@new_conds)
5630 foreach (split ('@', $item))
5632 next if ! $_;
5633 s/_(TRUE|FALSE)$//;
5634 $allconds{$_ . '_TRUE'} = 1;
5638 # Unset our entry in vars_scanned. We only care about recursive
5639 # definitions.
5640 delete $vars_scanned{$var};
5642 return &variable_conditions_permutations (sort keys %allconds);
5645 local (@this_conds) = ();
5646 local (@condvals) = split (' ', $conditional{$var});
5647 while (@condvals)
5649 local ($cond) = shift (@condvals);
5650 local ($val) = &unquote_cond_val (shift (@condvals));
5652 if (@parent_conds)
5654 local ($ok) = 1;
5655 local ($parent_cond);
5656 foreach $parent_cond (@parent_conds)
5658 if (! &conditional_true_when ($parent_cond, $cond))
5660 $ok = 0;
5661 last;
5665 next if ! $ok;
5668 push (@this_conds, $cond);
5670 push (@parent_conds, $cond);
5671 local (@subvar_conds) = ();
5672 foreach (split (' ', $val))
5674 # If a comment seen, just leave.
5675 last if /^#/;
5677 # Handle variable substitutions.
5678 if (/^\$\{(.*)\}$/ || /^\$\((.*)\)$/)
5680 push (@subvar_conds,
5681 &variable_conditions_sub ($1, $var, @parent_conds));
5684 pop (@parent_conds);
5686 # If there are no conditional subvariables, then we want to
5687 # return this condition. Otherwise, we want to return the
5688 # permutations of the subvariables.
5689 if (! @subvar_conds)
5691 push (@new_conds, $cond);
5693 else
5695 push (@new_conds, &variable_conditions_reduce (@subvar_conds));
5699 # Unset our entry in vars_scanned. We only care about recursive
5700 # definitions.
5701 delete $vars_scanned{$var};
5703 return @new_conds
5704 if ! $parent;
5706 # If we are being called on behalf of another variable, we need to
5707 # return all possible permutations of the conditions. We have
5708 # already handled everything in @this_conds along with their
5709 # subvariables. We now need to add any permutations that are not
5710 # in @this_conds.
5711 local ($this_cond);
5712 foreach $this_cond (@this_conds)
5714 local (@perms) =
5715 &variable_conditions_permutations (split('@', $this_cond));
5716 local ($perm);
5717 foreach $perm (@perms)
5719 local ($scan);
5720 local ($ok) = 1;
5721 foreach $scan (@this_conds)
5723 if (&conditional_true_when ($perm, $scan)
5724 || &conditional_true_when ($scan, $perm))
5726 $ok = 0;
5727 last;
5730 next if ! $ok;
5732 if (@parent_conds)
5734 local ($ok) = 1;
5735 local ($parent_cond);
5736 foreach $parent_cond (@parent_conds)
5738 if (! &conditional_true_when ($parent_cond, $perm))
5740 $ok = 0;
5741 last;
5745 next if ! $ok;
5748 # This permutation was not already handled, and is valid
5749 # for the parents.
5750 push (@new_conds, $perm);
5754 return @new_conds;
5757 # Subroutine for variable_conditions_sort
5758 sub variable_conditions_cmp
5760 local ($as) = $a;
5761 $as =~ s/[^@]//g;
5762 local ($bs) = $b;
5763 $bs =~ s/[^@]//g;
5764 return (length ($as) <=> length ($bs)
5765 || $a cmp $b);
5768 # Sort a list of conditionals so that only the exclusive ones are
5769 # retained. For example, if both @COND1_TRUE@@COND2_TRUE@ and
5770 # @COND1_TRUE@ are in the list, discard the latter.
5771 sub variable_conditions_reduce
5773 local (@conds) = @_;
5774 local (@ret) = ();
5775 local ($cond);
5776 foreach $cond (sort variable_conditions_cmp @conds)
5778 local ($ok) = 1;
5779 local ($scan);
5780 foreach $scan (@ret)
5782 if (&conditional_true_when ($cond, $scan))
5784 $ok = 0;
5785 last;
5788 next if ! $ok;
5789 push (@ret, $cond);
5792 return @ret;
5795 # Return a list of permutations of a conditional string.
5796 sub variable_conditions_permutations
5798 local (@comps) = @_;
5799 return ()
5800 if ! @comps;
5801 local ($comp) = shift (@comps);
5802 return &variable_conditions_permutations (@comps)
5803 if $comp eq '';
5804 local ($neg) = $comp;
5805 $neg =~ s/TRUE$/TRUEO/;
5806 $neg =~ s/FALSE$/TRUE/;
5807 $neg =~ s/TRUEO$/FALSE/;
5808 local (@ret);
5809 local ($sub);
5810 foreach $sub (&variable_conditions_permutations (@comps))
5812 push (@ret, '@' . $comp . '@' . $sub);
5813 push (@ret, '@' . $neg . '@' . $sub);
5815 if (! @ret)
5817 push (@ret, '@' . $comp . '@');
5818 push (@ret, '@' . $neg . '@');
5820 return @ret;
5823 # Warn if a variable is conditionally defined. This is called if we
5824 # are using the value of a variable.
5825 sub variable_conditionally_defined
5827 local ($var, $parent) = @_;
5828 if ($conditional{$var})
5830 if ($parent)
5832 &am_line_error ($parent,
5833 "warning: automake does not support conditional definition of $var in $parent");
5835 else
5837 &am_line_error ($parent,
5838 "warning: automake does not support $var being defined conditionally")
5843 # Get the value of a variable. This just returns $contents, but warns
5844 # if the variable is conditionally defined.
5845 sub variable_value
5847 local ($var) = @_;
5848 &variable_conditionally_defined ($var);
5849 return $contents{$var};
5852 # Convert a variable value to a list, split as whitespace. This will
5853 # recursively follow $(...) and ${...} inclusions. It preserves @...@
5854 # substitutions. If COND is 'all', then all values under all
5855 # conditions should be returned; if COND is a particular condition
5856 # (all conditions are surrounded by @...@) then only the value for
5857 # that condition should be returned; otherwise, warn if VAR is
5858 # conditionally defined. SCANNED is a global hash listing whose keys
5859 # are all the variables already scanned; it is an error to rescan a
5860 # variable.
5861 sub value_to_list
5863 local ($var, $val, $cond) = @_;
5864 local (@result);
5866 # Strip backslashes
5867 $val =~ s/\\(\n|$)/ /g;
5869 foreach (split (' ', $val))
5871 # If a comment seen, just leave.
5872 last if /^#/;
5874 # Handle variable substitutions.
5875 if (/^\$\{([^}]*)\}$/ || /^\$\(([^)]*)\)$/)
5877 local ($varname) = $1;
5879 # If the user uses a losing variable name, just ignore it.
5880 # This isn't ideal, but people have requested it.
5881 next if ($varname =~ /\@.*\@/);
5883 local ($from, $to);
5884 local (@temp_list);
5885 if ($varname =~ /^([^:]*):([^=]*)=(.*)$/)
5887 $varname = $1;
5888 $to = $3;
5889 ($from = $2) =~ s/(\W)/\\$1/g;
5892 # Find the value.
5893 @temp_list = &variable_value_as_list_worker ($1, $cond, $var);
5895 # Now rewrite the value if appropriate.
5896 if ($from)
5898 grep (s/$from$/$to/, @temp_list);
5901 push (@result, @temp_list);
5903 else
5905 push (@result, $_);
5909 return @result;
5912 # Return contents of variable as list, split as whitespace. This will
5913 # recursively follow $(...) and ${...} inclusions. It preserves @...@
5914 # substitutions. If COND is 'all', then all values under all
5915 # conditions should be returned; if COND is a particular condition
5916 # (all conditions are surrounded by @...@) then only the value for
5917 # that condition should be returned; otherwise, warn if VAR is
5918 # conditionally defined. If PARENT is specified, it is the name of
5919 # the including variable; this is only used for error reports.
5920 sub variable_value_as_list_worker
5922 local ($var, $cond, $parent) = @_;
5923 local (@result);
5925 if (defined $targets{$var})
5927 &am_line_error ($var, "\`$var' is target; expected variable");
5929 elsif (! defined $contents{$var})
5931 &am_line_error ($parent, "variable \`$var' not defined");
5933 elsif (defined $vars_scanned{$var})
5935 # `vars_scanned' is a global we use to keep track of which
5936 # variables we've already examined.
5937 &am_line_error ($parent, "variable \`$var' recursively defined");
5939 elsif ($cond eq 'all' && $conditional{$var})
5941 $vars_scanned{$var} = 1;
5942 local (@condvals) = split (' ', $conditional{$var});
5943 while (@condvals)
5945 shift (@condvals);
5946 local ($val) = &unquote_cond_val (shift (@condvals));
5947 push (@result, &value_to_list ($var, $val, $cond));
5950 elsif ($cond && $conditional{$var})
5952 $vars_scanned{$var} = 1;
5953 local (@condvals) = split (' ', $conditional{$var});
5954 local ($onceflag);
5955 while (@condvals)
5957 local ($vcond) = shift (@condvals);
5958 local ($val) = &unquote_cond_val (shift (@condvals));
5959 if (&conditional_true_when ($vcond, $cond))
5961 # Warn if we have an ambiguity. It's hard to know how
5962 # to handle this case correctly.
5963 &variable_conditionally_defined ($var, $parent)
5964 if $onceflag;
5965 $onceflag = 1;
5966 push (@result, &value_to_list ($var, $val, $cond));
5970 else
5972 $vars_scanned{$var} = 1;
5973 &variable_conditionally_defined ($var, $parent);
5974 $content_seen{$var} = 1;
5975 push (@result, &value_to_list ($var, $contents{$var}, $cond));
5978 # Unset our entry in vars_scanned. We only care about recursive
5979 # definitions.
5980 delete $vars_scanned{$var};
5982 return @result;
5985 # This is just a wrapper for variable_value_as_list_worker that
5986 # initializes the global hash `vars_scanned'. This hash is used to
5987 # avoid infinite recursion.
5988 sub variable_value_as_list
5990 local ($var, $cond, $parent) = @_;
5991 %vars_scanned = ();
5992 return &variable_value_as_list_worker ($var, $cond, $parent);
5995 # Define a new variable, but only if not already defined.
5996 sub define_variable
5998 local ($var, $value) = @_;
6000 if (! defined $contents{$var})
6002 $output_vars .= $var . ' = ' . $value . "\n";
6003 $contents{$var} = $value;
6004 $content_seen{$var} = 1;
6006 elsif ($var_was_plus_eq{$var})
6008 &am_line_error ($var, "internally generated variable \`$var' was set with \`+='");
6012 # Like define_variable, but the value is a list, and the variable may
6013 # be defined conditionally. The second argument is the conditional
6014 # under which the value should be defined; this should be the empty
6015 # string to define the variable unconditionally. The third argument
6016 # is a list holding the values to use for the variable. The value is
6017 # pretty printed in the output file.
6018 sub define_pretty_variable
6020 local ($var, $cond, @value) = @_;
6021 if (! defined $contents{$var}
6022 || ($cond && ! &variable_defined ($var, $cond)))
6024 $contents{$var} = join (' ', @value);
6025 if ($cond)
6027 if ($conditional{$var})
6029 $conditional{$var} .= ' ';
6031 else
6033 $conditional{$var} = '';
6035 $conditional{$var} .= ($cond
6036 . ' '
6037 . &quote_cond_val ($contents{$var}));
6039 &pretty_print ($cond . $var . ' = ', $cond, @value);
6040 $content_seen{$var} = 1;
6044 # Like define_variable, but define a variable to be the configure
6045 # substitution by the same name.
6046 sub define_configure_variable
6048 local ($var) = @_;
6049 local ($value) = '@' . $var . '@';
6050 &define_variable ($var, $value);
6053 # Define a compiler variable. We also handle defining the `LT'
6054 # version of the command when using libtool.
6055 sub define_compiler_variable
6057 local ($var, $ltcompile, $value) = @_;
6058 local ($name) = $var;
6059 &define_variable ($name, $value);
6060 &define_variable ('LT' . $name, $ltcompile . $value)
6061 if $seen_libtool;
6064 # Define a variable that represents a program to run. If in Cygnus
6065 # mode, the program is searched for in the build (or source) tree.
6066 # Otherwise no searching is done at all. Arguments are:
6067 # * VAR Name of variable to define
6068 # * WHATDIR Either `src' or `build', depending on where program should
6069 # be found. (runtest is in srcdir!)
6070 # * SUBDIR Subdir of top-level dir
6071 # * PROGRAM Name of program
6072 # * OVERRIDE If specified, the name of the program to use when not in
6073 # Cygnus mode. Defaults to PROGRAM.
6074 sub define_program_variable
6076 local ($var, $whatdir, $subdir, $program, $override) = @_;
6078 if (! $override)
6080 $override = $program;
6083 if ($cygnus_mode)
6085 local ($full) = ('$(top_' . $whatdir . 'dir)/../'
6086 . $subdir . '/' . $program);
6087 &define_variable ($var, ('`if test -f ' . $full
6088 . '; then echo ' . $full . '; else echo '
6089 . $program . '; fi`'));
6091 else
6093 &define_variable ($var, $override);
6098 ################################################################
6100 # Read Makefile.am and set up %contents. Simultaneously copy lines
6101 # from Makefile.am into $output_trailer or $output_vars as
6102 # appropriate. NOTE we put rules in the trailer section. We want
6103 # user rules to come after our generated stuff.
6104 sub read_am_file
6106 local ($amfile) = @_;
6107 local (*AM_FILE);
6109 open (AM_FILE, $amfile) || die "automake: couldn't open \`$amfile': $!\n";
6110 print "automake: reading $amfile\n" if $verbose;
6112 local ($saw_bk) = 0;
6113 local ($was_rule) = 0;
6114 local ($spacing) = '';
6115 local ($comment) = '';
6116 local ($last_var_name) = '';
6117 local ($blank) = 0;
6119 # We save the conditional stack on entry, and then check to make
6120 # sure it is the same on exit. This lets us conditonally include
6121 # other files.
6122 local (@saved_cond_stack) = @conditional_stack;
6124 while (<AM_FILE>)
6126 if (/$IGNORE_PATTERN/o)
6128 # Merely delete comments beginning with two hashes.
6130 elsif (/$WHITE_PATTERN/o)
6132 # Stick a single white line before the incoming macro or rule.
6133 $spacing = "\n";
6134 $blank = 1;
6136 elsif (/$COMMENT_PATTERN/o)
6138 # Stick comments before the incoming macro or rule. Make
6139 # sure a blank line preceeds first block of comments.
6140 $spacing = "\n" unless $blank;
6141 $blank = 1;
6142 $comment .= $spacing . $_;
6143 $spacing = '';
6145 else
6147 last;
6151 $output_vars .= $comment . "\n";
6152 $comment = '';
6153 $spacing = "\n";
6155 local ($is_ok_macro);
6156 while ($_)
6158 $_ .= "\n"
6159 unless substr ($_, -1, 1) eq "\n";
6161 # Don't look at MAINTAINER_MODE_TRUE here. That shouldn't be
6162 # used by users. @MAINT@ is an anachronism now.
6163 $_ =~ s/\@MAINT\@//g
6164 unless $seen_maint_mode;
6166 if (/$IGNORE_PATTERN/o)
6168 # Merely delete comments beginning with two hashes.
6170 elsif (/$WHITE_PATTERN/o)
6172 # Stick a single white line before the incoming macro or rule.
6173 $spacing = "\n";
6174 &am_line_error ($., "blank line following trailing backslash")
6175 if $saw_bk;
6177 elsif (/$COMMENT_PATTERN/o)
6179 # Stick comments before the incoming macro or rule.
6180 $comment .= $spacing . $_;
6181 $spacing = '';
6182 &am_line_error ($., "comment following trailing backslash")
6183 if $saw_bk;
6185 elsif ($saw_bk)
6187 if ($was_rule)
6189 $output_trailer .= join ('', @conditional_stack) . $_;
6190 $saw_bk = /\\$/;
6192 else
6194 $saw_bk = /\\$/;
6195 $contents{$last_var_name} .= ' '
6196 unless $contents{$last_var_name} =~ /\s$/;
6197 $contents{$last_var_name} .= $_;
6198 if (@conditional_stack)
6200 $conditional{$last_var_name} .= &quote_cond_val ($_);
6204 elsif (/$IF_PATTERN/o)
6206 &am_line_error ($., "$1 does not appear in AM_CONDITIONAL")
6207 if (! $configure_cond{$1});
6208 push (@conditional_stack, "\@" . $1 . "_TRUE\@");
6210 elsif (/$ELSE_PATTERN/o)
6212 if (! @conditional_stack)
6214 &am_line_error ($., "else without if");
6216 elsif ($conditional_stack[$#conditional_stack] =~ /_FALSE\@$/)
6218 &am_line_error ($., "else after else");
6220 else
6222 $conditional_stack[$#conditional_stack]
6223 =~ s/_TRUE\@$/_FALSE\@/;
6226 elsif (/$ENDIF_PATTERN/o)
6228 if (! @conditional_stack)
6230 &am_line_error ($., "endif without if");
6232 else
6234 pop @conditional_stack;
6237 elsif (/$RULE_PATTERN/o)
6239 # Found a rule.
6240 $was_rule = 1;
6241 if (defined $contents{$1}
6242 && (@conditional_stack
6243 ? ! defined $conditional{$1}
6244 : defined $conditional{$1}))
6246 &am_line_error ($1,
6247 "$1 defined both conditionally and unconditionally");
6249 # Value here doesn't matter; for targets we only note
6250 # existence.
6251 $contents{$1} = 1;
6252 $targets{$1} = 1;
6253 local ($cond_string) = join ('', @conditional_stack);
6254 if (@conditional_stack)
6256 if ($conditional{$1})
6258 &check_ambiguous_conditional ($1, $cond_string);
6259 $conditional{$1} .= ' ';
6261 else
6263 $conditional{$1} = '';
6265 $conditional{$1} .= $cond_string . ' 1';
6267 $content_lines{$1} = $.;
6268 $output_trailer .= $comment . $spacing . $cond_string . $_;
6269 $comment = $spacing = '';
6270 $saw_bk = /\\$/;
6272 # Check the rule for being a suffix rule. If so, store in
6273 # a hash.
6275 local ($source_suffix);
6276 local ($object_suffix);
6278 if (($source_suffix, $object_suffix) = ($1 =~ $SUFFIX_RULE_PATTERN))
6280 $suffix_rules{$source_suffix} = $object_suffix;
6281 print "Sources ending in .$source_suffix become .$object_suffix\n" if $verbose;
6282 $source_suffix_pattern = "(" . join ('|', keys %suffix_rules) . ")";
6285 # FIXME: make sure both suffixes are in SUFFIXES? Or set
6286 # SUFFIXES from suffix_rules?
6288 elsif (($is_ok_macro = /$MACRO_PATTERN/o)
6289 || /$BOGUS_MACRO_PATTERN/o)
6291 # Found a macro definition.
6292 $was_rule = 0;
6293 $last_var_name = $1;
6294 if (defined $contents{$1}
6295 && (@conditional_stack
6296 ? ! defined $conditional{$1}
6297 : defined $conditional{$1}))
6299 &am_line_error ($1,
6300 "$1 defined both conditionally and unconditionally");
6302 local ($value);
6303 if ($3 ne '' && substr ($3, -1) eq "\\")
6305 # We preserve the `\' because otherwise the long lines
6306 # that are generated will be truncated by broken
6307 # `sed's.
6308 $value = $3 . "\n";
6310 else
6312 $value = $3;
6314 local ($type) = $2;
6316 if (! defined $contents{$last_var_name})
6318 # The first assignment to a macro sets the line
6319 # number. Ideally I suppose we would associate line
6320 # numbers with random bits of text.
6321 $content_lines{$last_var_name} = $.;
6323 # If first assignment, set `+=' indicator.
6324 $var_was_plus_eq{$last_var_name} =
6325 ($type eq '+'
6326 && ! defined $am_var_defs{$last_var_name});
6329 if ($type eq '+')
6331 if (! defined $contents{$last_var_name}
6332 && defined $am_var_defs{$last_var_name})
6334 $contents{$last_var_name} = $am_var_defs{$last_var_name};
6336 if (substr ($contents{$last_var_name}, -1) eq "\n")
6338 # Insert a backslash before a trailing newline.
6339 $contents{$last_var_name}
6340 = substr ($contents{$last_var_name}, 0, -1) . "\\\n";
6342 $contents{$last_var_name} .= ' ' . $value;
6344 else
6346 $contents{$last_var_name} = $value;
6348 local ($cond_string) = join ('', @conditional_stack);
6349 if (@conditional_stack)
6351 local ($found) = 0;
6352 local ($val);
6353 if ($conditional{$last_var_name})
6355 if ($type eq '+')
6357 # If we're adding to the conditional, and it
6358 # exists, then we might want to simply replace
6359 # the old value with the new one.
6360 local (@new_vals, @cond_vals);
6361 @cond_vals = split (' ', $conditional{$last_var_name});
6362 while (@cond_vals)
6364 local ($vcond) = shift (@cond_vals);
6365 push (@new_vals, $vcond);
6366 if (&conditional_same ($vcond, $cond_string))
6368 $found = 1;
6369 $val = (&unquote_cond_val (shift (@cond_vals))
6370 . ' ' . $value);
6371 push (@new_vals, &quote_cond_val ($val));
6373 else
6375 push (@new_vals, shift (@cond_vals));
6378 if ($found)
6380 $conditional{$last_var_name}
6381 = join (' ', @new_vals);
6385 if (! $found)
6387 &check_ambiguous_conditional ($last_var_name,
6388 $cond_string);
6389 $conditional{$last_var_name} .= ' ';
6390 $val = $value;
6393 else
6395 $conditional{$last_var_name} = '';
6396 $val = $contents{$last_var_name};
6398 if (! $found)
6400 $conditional{$last_var_name} .= ($cond_string
6401 . ' '
6402 . &quote_cond_val ($val));
6406 # FIXME: this doesn't always work correctly; it will group
6407 # all comments for a given variable, no matter where
6408 # defined.
6409 $am_vars{$last_var_name} = $comment . $spacing;
6410 $def_type{$last_var_name} = ($type eq ':') ? ':' : '';
6411 push (@var_list, $last_var_name);
6412 $comment = $spacing = '';
6413 $saw_bk = /\\$/;
6415 # Error if bogus.
6416 &am_line_error ($., "bad macro name \`$last_var_name'")
6417 if ! $is_ok_macro;
6419 elsif (/$INCLUDE_PATTERN/o)
6421 local ($path) = $1;
6423 if ($path =~ s/^\$\(top_srcdir\)\///)
6425 push (@include_stack, "\$\(top_srcdir\)/$path");
6427 else
6429 $path =~ s/\$\(srcdir\)\///;
6430 push (@include_stack, "\$\(srcdir\)/$path");
6431 $path = $relative_dir . "/" . $path;
6433 &read_am_file ($path);
6435 else
6437 # This isn't an error; it is probably a continued rule.
6438 # In fact, this is what we assume.
6439 $was_rule = 1;
6440 $output_trailer .= ($comment . $spacing
6441 . join ('', @conditional_stack) . $_);
6442 $comment = $spacing = '';
6443 $saw_bk = /\\$/;
6446 $_ = <AM_FILE>;
6449 $output_trailer .= $comment;
6451 if (join (' ', @saved_cond_stack) ne join (' ', @conditional_stack))
6453 if (@conditional_stack)
6455 &am_error ("unterminated conditionals: " . join (' ', @conditional_stack));
6457 else
6459 # FIXME: better error message here.
6460 &am_error ("conditionals not nested in include file");
6465 # A helper for read_main_am_file which initializes configure variables
6466 # and variables from header-vars.am. This is a subr so we can call it
6467 # twice.
6468 sub define_standard_variables
6470 # Compute relative location of the top object directory.
6471 local (@topdir) = ();
6472 foreach (split (/\//, $relative_dir))
6474 next if $_ eq '.' || $_ eq '';
6475 if ($_ eq '..')
6477 pop @topdir;
6479 else
6481 push (@topdir, '..');
6484 @topdir = ('.') if ! @topdir;
6486 $top_builddir = join ('/', @topdir);
6487 local ($build_rx);
6488 ($build_rx = $top_builddir) =~ s/(\W)/\\$1/g;
6489 $output_vars .= &file_contents_with_transform
6490 ('s/\@top_builddir\@/' . $build_rx . '/g;',
6491 'header-vars');
6493 # Generate some useful variables when AC_CANONICAL_* used. FIXME:
6494 # this should use generic %configure_vars method.
6495 if ($seen_canonical)
6497 local ($curs, %vars);
6498 $vars{'host_alias'} = 'host_alias';
6499 $vars{'host_triplet'} = 'host';
6500 if ($seen_canonical == $AC_CANONICAL_SYSTEM)
6502 $vars{'build_alias'} = 'build_alias';
6503 $vars{'build_triplet'} = 'build';
6504 $vars{'target_alias'} = 'target_alias';
6505 $vars{'target_triplet'} = 'target';
6507 foreach $curs (sort keys %vars)
6509 $output_vars .= "$curs = \@$vars{$curs}\@\n";
6510 $contents{$curs} = "\@$vars{$curs}\@";
6514 local ($curs);
6515 foreach $curs (sort keys %configure_vars)
6517 &define_configure_variable ($curs);
6521 # Read main am file.
6522 sub read_main_am_file
6524 local ($amfile) = @_;
6526 # The keys here are variables we want to dump at the end of this
6527 # function. The values are corresponding comments.
6528 local (%am_vars) = ();
6529 local (@var_list) = ();
6530 local (%def_type) = ();
6532 # This supports the strange variable tricks we are about to play.
6533 if (scalar keys %contents > 0)
6535 print STDERR "automake: programming error: variable defined before read_main_am_file\n";
6536 exit 1;
6539 # We want to predefine as many variables as possible. This lets
6540 # the user set them with `+=' in Makefile.am. However, we don't
6541 # want these initial definitions to end up in the output quite
6542 # yet. So we adopt a hack: read the `.am' file twice, throwing
6543 # away the output the first time. We also squirrel away a list of
6544 # all the variables defined by the .am file so that we know which
6545 # ones to remove from the content list.
6547 # First pass.
6548 &define_standard_variables;
6549 local (%saved_contents) = %contents;
6551 # Read user file, but discard text of variable assignments we just
6552 # made.
6553 $output_vars = '';
6554 &read_am_file ($amfile);
6556 # Now dump the variables that were defined. We do it in the same
6557 # order in which they were defined (skipping duplicates).
6558 local (%done);
6559 foreach $curs (@var_list)
6561 next if $done{$curs};
6562 $done{$curs} = 1;
6564 $output_vars .= $am_vars{$curs};
6565 if ($conditional{$curs})
6567 local (@cond_vals) = split (' ', $conditional{$curs});
6568 while (@cond_vals)
6570 local ($vcond) = shift (@cond_vals);
6571 local ($val) = &unquote_cond_val (shift (@cond_vals));
6572 $output_vars .= ($vcond . $curs . ' '
6573 . $def_type{$curs} . "= ");
6574 local ($line);
6575 foreach $line (split ("\n", $val))
6577 $output_vars .= $vcond . $line . "\n";
6579 $output_vars .= "\n"
6580 if $val eq '';
6583 else
6585 $output_vars .= ($curs . ' ' . $def_type{$curs} . '= '
6586 . $contents{$curs} . "\n");
6590 # Generate copyright header for generated Makefile.in.
6591 local ($ov) = $output_vars;
6592 $output_vars = ("# $in_file_name generated automatically by automake "
6593 . $VERSION . " from $am_file_name\n");
6594 $output_vars .= $gen_copyright;
6596 # Now go through and delete all the variables that the user did
6597 # not change.
6598 local ($var);
6599 foreach $var (keys %saved_contents)
6601 if ($contents{$var} eq $saved_contents{$var})
6603 delete $contents{$var};
6607 # Re-read the standard variables, and this time keep their
6608 # contributions to the output. Then add the user's output to the
6609 # end.
6610 &define_standard_variables;
6611 $output_vars .= $ov;
6615 ################################################################
6617 sub initialize_global_constants
6619 # Values for AC_CANONICAL_*
6620 $AC_CANONICAL_HOST = 1;
6621 $AC_CANONICAL_SYSTEM = 2;
6623 # Associative array of standard directory names. Entry is TRUE if
6624 # corresponding directory should be installed during
6625 # 'install-exec' phase.
6626 %exec_dir_p =
6627 ('bin', 1,
6628 'sbin', 1,
6629 'libexec', 1,
6630 'data', 0,
6631 'sysconf', 1,
6632 'localstate', 1,
6633 'lib', 1,
6634 'info', 0,
6635 'man', 0,
6636 'include', 0,
6637 'oldinclude', 0,
6638 'pkgdata', 0,
6639 'pkglib', 1,
6640 'pkginclude', 0
6643 # Commonly found files we look for and automatically include in
6644 # DISTFILES.
6645 @common_files =
6647 "README", "THANKS", "TODO", "NEWS", "COPYING", "COPYING.LIB",
6648 "INSTALL", "ABOUT-NLS", "ChangeLog", "configure", "configure.in",
6649 "config.guess", "config.sub", "AUTHORS", "BACKLOG", "ABOUT-GNU",
6650 "libversion.in", "mdate-sh", "mkinstalldirs", "install-sh",
6651 'texinfo.tex', "ansi2knr.c", "ansi2knr.1", 'elisp-comp',
6652 'ylwrap', 'acinclude.m4', @libtoolize_files,
6653 'missing', 'depcomp', 'compile', 'py-compile'
6656 # Commonly used files we auto-include, but only sometimes.
6657 @common_sometimes =
6659 "aclocal.m4", "acconfig.h", "config.h.top",
6660 "config.h.bot", "stamp-h.in", 'stamp-vti'
6663 $USAGE = "\
6664 -a, --add-missing add missing standard files to package
6665 --amdir=DIR directory storing config files
6666 -c, --copy with -a, copy missing files (default is symlink)
6667 --cygnus assume program is part of Cygnus-style tree
6668 --force-missing force update of standard files
6669 --foreign set strictness to foreign
6670 --gnits set strictness to gnits
6671 --gnu set strictness to gnu
6672 --help print this help, then exit
6673 -i, --ignore-deps disable dependency tracking code
6674 --include-deps enable dependency tracking code
6675 --no-force only update Makefile.in's that are out of date
6676 -o DIR, --output-dir=DIR
6677 put generated Makefile.in's into DIR
6678 -v, --verbose verbosely list files processed
6679 --version print version number, then exit\n";
6681 # Copyright on generated Makefile.ins.
6682 $gen_copyright = "\
6683 # Copyright (C) 1994, 1995-9, 2000 Free Software Foundation, Inc.
6684 # This Makefile.in is free software; the Free Software Foundation
6685 # gives unlimited permission to copy and/or distribute it,
6686 # with or without modifications, as long as this notice is preserved.
6688 # This program is distributed in the hope that it will be useful,
6689 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
6690 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
6691 # PARTICULAR PURPOSE.
6694 # This complex find command will try to avoid changing the modes of
6695 # links into the source tree, in case they're hard-linked. It will
6696 # also make directories writable by everybody, because some
6697 # brain-dead tar implementations change ownership and permissions of
6698 # a directory before extracting the files, thus becoming unable to
6699 # extract them.
6700 # Ignore return result from chmod, because it might give an error
6701 # if we chmod a symlink.
6702 # Another nastiness: if the file is unreadable by us, we make it
6703 # readable regardless of the number of links to it. This only
6704 # happens in perverse cases.
6705 # We use $(install_sh) because that is a known-portable way to
6706 # modify the file in place in the source tree.
6707 $dist_header = ' -find $(distdir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \\
6708 ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \\
6709 ! -type d ! -perm -400 -exec chmod a+r {} \; -o \\
6710 ! -type d ! -perm -444 -exec $(SHELL) $(install_sh) -c -m a+r {} {} \; \\
6711 || chmod -R a+r $(distdir)
6713 $dist{'dist-bzip2'} = ("\t"
6714 . '$(AMTAR) chof - $(distdir) | bzip2 -9 -c > $(distdir).bz2'
6715 . "\n");
6716 $dist{'dist-tarZ'} = ("\t"
6717 . '$(AMTAR) chof - $(distdir) | compress -c > $(distdir).tar.Z'
6718 . "\n");
6719 $dist{'dist-shar'} = ("\t"
6720 . 'shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c > $(distdir).shar.gz'
6721 . "\n");
6722 $dist{'dist-zip'} = ("\t" . '-rm -f $(distdir).zip' . "\n" .
6723 "\t" . 'zip -rq $(distdir).zip $(distdir)' . "\n");
6725 # Note that we don't use GNU tar's `-z' option. One reason (but
6726 # not the only reason) is that some versions of tar (e.g., OSF1)
6727 # interpret `-z' differently.
6728 $dist{'dist'} = ("\t"
6729 . '$(AMTAR) chof - $(distdir) | GZIP=$(GZIP_ENV) gzip -c > $(distdir).tar.gz'
6730 . "\n");
6731 $dist_trailer = "\t" . '-chmod -R a+w $(distdir) > /dev/null 2>&1; rm -rf $(distdir)' . "\n";
6734 # (Re)-Initialize per-Makefile.am variables.
6735 sub initialize_per_input
6737 # These two variables are used when generating each Makefile.in.
6738 # They hold the Makefile.in until it is ready to be printed.
6739 $output_rules = '';
6740 $output_vars = '';
6741 $output_trailer = '';
6742 $output_all = '';
6743 $output_header = '';
6745 # Suffixes found during a run.
6746 @suffixes = ();
6748 # This holds the contents of a Makefile.am, as parsed by
6749 # read_am_file.
6750 %contents = ();
6752 # This holds the names which are targets. These also appear in
6753 # %contents.
6754 %targets = ();
6756 # This maps a variable name onto a flag. The flag is true iff the
6757 # variable was first defined with `+='.
6758 %var_was_plus_eq = ();
6760 # This holds definitions of all variables defined in .am files.
6761 # This is used during startup to determine which variables can be
6762 # assigned with `+='.
6763 %am_var_defs = ();
6765 # For a variable or target which is defined conditionally, this
6766 # holds an array of the conditional values. The array is composed
6767 # of pairs of condition strings (the variables which configure
6768 # will substitute) and values (the value of a target is
6769 # meaningless). For an unconditional variable, this is empty.
6770 %conditional = ();
6772 # This holds the line numbers at which various elements of
6773 # %contents are defined.
6774 %content_lines = ();
6776 # This holds a 1 if a particular variable was examined.
6777 %content_seen = ();
6779 # This is the conditional stack.
6780 @conditional_stack = ();
6782 # This holds the set of included files.
6783 @include_stack = ();
6785 # This holds the "relative directory" of the current Makefile.in.
6786 # Eg for src/Makefile.in, this is "src".
6787 $relative_dir = '';
6789 # This holds a list of files that are included in the
6790 # distribution.
6791 %dist_common = ();
6793 # List of dependencies for the obvious targets.
6794 @install_data = ();
6795 @install_exec = ();
6796 @uninstall = ();
6797 @installdirs = ();
6799 @info = ();
6800 @dvi = ();
6801 @all = ();
6802 @check = ();
6803 @check_tests = ();
6804 @installcheck = ();
6805 @clean = ();
6807 @phony = ();
6809 # A list of files deleted by `maintainer-clean'.
6810 @maintainer_clean_files = ();
6812 # These are pretty obvious, too. They are used to define the
6813 # SOURCES and OBJECTS variables.
6814 @sources = ();
6815 @objects = ();
6816 # Sources which go in the distribution.
6817 @dist_sources = ();
6819 # This hash maps object file names onto their corresponding source
6820 # file names. This is used to ensure that each object is created
6821 # by a single source file.
6822 %object_map = ();
6824 # This keeps track of the directories for which we've already
6825 # created `.dirstamp' code.
6826 %directory_map = ();
6828 # These variables track inclusion of various compile-related .am
6829 # files. $included_generic_compile is TRUE if the basic code has
6830 # been included. $included_knr_compile is TRUE if the ansi2knr
6831 # code has been included. $included_libtool_compile is TRUE if
6832 # libtool support has been included.
6833 $included_generic_compile = 0;
6834 $included_knr_compile = 0;
6835 $included_libtool_compile = 0;
6837 # TRUE if install targets should work recursively.
6838 $recursive_install = 0;
6840 # All .P files.
6841 %dep_files = ();
6843 # Strictness levels.
6844 $strictness = $default_strictness;
6845 $strictness_name = $default_strictness_name;
6847 # Options from AUTOMAKE_OPTIONS.
6848 %options = ();
6850 # Whether or not dependencies are handled. Can be further changed
6851 # in handle_options.
6852 $use_dependencies = $cmdline_use_dependencies;
6854 # Per Makefile.am.
6855 $local_maint_charset = $maint_charset;
6857 # All yacc and lex source filenames for this directory. Use
6858 # filenames instead of raw count so that multiple instances are
6859 # counted correctly (eg one yacc file can appear in multiple
6860 # programs without harm).
6861 %yacc_sources = ();
6862 %lex_sources = ();
6864 # This is a list of all targets to run during "make dist".
6865 @dist_targets = ();
6867 # Keys in this hash are the basenames of files which must depend
6868 # on ansi2knr.
6869 %de_ansi_files = ();
6871 # This maps the source extension of a suffix rule to its
6872 # corresponding output extension.
6873 %suffix_rules = ();
6875 # This is a regular expression which matches all the known source
6876 # suffix. A source suffix is one that appears in the first
6877 # position of a suffix rule.
6878 $source_suffix_pattern = '';
6880 # This is the name of the recursive `all' target to use.
6881 $all_target = 'all-recursive';
6883 # This keeps track of which extensions we've seen (that we care
6884 # about).
6885 %extension_seen = ();
6887 # This is random scratch space for the language finish functions.
6888 # Don't randomly overwrite it; examine other uses of keys first.
6889 %language_scratch = ();
6891 # We keep track of which objects need special (per-executable)
6892 # handling on a per-language basis.
6893 %lang_specific_files = ();
6895 # This is set when `handle_dist' has finished. Once this happens,
6896 # we should no longer push on dist_common.
6897 $handle_dist_run = 0;
6901 ################################################################
6903 # Return contents of a file from $am_dir, automatically skipping
6904 # macros or rules which are already known. Runs command on each line
6905 # as it is read; this command can modify $_.
6906 sub file_contents_with_transform
6908 local ($command, $basename) = @_;
6909 local ($file) = $am_dir . '/' . $basename . '.am';
6911 if ($command ne '' && substr ($command, -1) ne ';')
6913 die "automake: programming error in file_contents_with_transform: $command\n";
6916 open (FC_FILE, $file)
6917 || die "automake: installation error: cannot open \`$file'\n";
6918 # Looks stupid?
6919 # print "automake: reading $file\n" if $verbose;
6921 local ($was_rule) = 0;
6922 local ($result_vars) = '';
6923 local ($result_rules) = '';
6924 local ($comment) = '';
6925 local ($spacing) = "\n";
6926 local ($skipping) = 0;
6927 local ($had_chars);
6929 while (<FC_FILE>)
6931 $_ =~ s/\@MAINTAINER_MODE_TRUE\@//g
6932 unless $seen_maint_mode;
6934 $had_chars = length ($_) && $_ ne "\n";
6935 eval $command;
6936 # If the transform caused all the characters to go away, then
6937 # ignore the line. Why do this? Because in Perl 4, a "next"
6938 # inside of an eval doesn't affect a loop outside the eval.
6939 # So we can't pass in a "transform" that uses next. We used
6940 # to do this. "Empty" also means consisting of a single
6941 # newline.
6942 next if $had_chars && ($_ eq '' || $_ eq "\n");
6944 if (/$IGNORE_PATTERN/o)
6946 # Merely delete comments beginning with two hashes.
6948 elsif (/$WHITE_PATTERN/o)
6950 # Stick a single white line before the incoming macro or rule.
6951 $spacing = "\n";
6952 &am_line_error ($., "blank line following trailing backslash")
6953 if $saw_bk;
6955 elsif (/$COMMENT_PATTERN/o)
6957 # Stick comments before the incoming macro or rule.
6958 $comment .= $spacing . $_;
6959 $spacing = '';
6960 &am_line_error ($., "comment following trailing backslash")
6961 if $saw_bk;
6963 elsif ($saw_bk)
6965 if ($was_rule)
6967 $result_rules .= $_ if ! $skipping;
6969 else
6971 $result_vars .= $_ if ! $skipping;
6973 $saw_bk = /\\$/;
6975 elsif (/$RULE_PATTERN/o)
6977 # Found a rule.
6978 $was_rule = 1;
6979 $skipping = defined $contents{$1};
6980 $result_rules .= $comment . $spacing . $_ if ! $skipping;
6981 $comment = $spacing = '';
6982 $saw_bk = /\\$/;
6984 elsif (/$MACRO_PATTERN/o)
6986 # Found a variable reference.
6987 $was_rule = 0;
6988 $skipping = defined $contents{$1};
6989 $result_vars .= $comment . $spacing . $_ if ! $skipping;
6990 $comment = $spacing = '';
6991 $saw_bk = /\\$/;
6992 print STDERR "automake: programming error: .am macro \`$1' with trailing backslash\n"
6993 if $saw_bk;
6994 $am_var_defs{$1} = $3;
6996 else
6998 # This isn't an error; it is probably a continued rule.
6999 # In fact, this is what we assume.
7000 $was_rule = 1;
7001 $result_rules .= $comment . $spacing . $_ if ! $skipping;
7002 $comment = $spacing = '';
7003 $saw_bk = /\\$/;
7007 close (FC_FILE);
7008 return $result_vars . $result_rules . $comment;
7011 # Like file_contents_with_transform, but no transform.
7012 sub file_contents
7014 return &file_contents_with_transform ('', @_);
7017 # Find all variable prefixes that are used for install directories. A
7018 # prefix `zar' qualifies iff:
7019 # * `zardir' is a variable.
7020 # * `zar_PRIMARY' is a variable.
7021 sub am_primary_prefixes
7023 local ($primary, $can_dist, @prefixes) = @_;
7025 local (%valid, $varname);
7026 grep ($valid{$_} = 0, @prefixes);
7027 $valid{'EXTRA'} = 0;
7028 foreach $varname (keys %contents)
7030 if ($varname =~ /^(nobase_)?(dist_|nodist_)?(.*)_$primary$/)
7032 if (($2 ne '' && ! $can_dist)
7033 || (! defined $valid{$3}
7034 && ! &variable_defined ($3 . 'dir')
7035 # Note that a configure variable is always
7036 # legitimate. It is natural to name such
7037 # variables after the primary, so we explicitly
7038 # allow it.
7039 && ! defined $configure_vars{$varname}))
7041 &am_line_error ($varname, "invalid variable \`$varname'");
7043 else
7045 # Ensure all extended prefixes are actually used.
7046 $valid{$1 . $2 . $3} = 1;
7051 return %valid;
7054 # Handle `where_HOW' variable magic. Does all lookups, generates
7055 # install code, and possibly generates code to define the primary
7056 # variable. The first argument is the name of the .am file to munge,
7057 # the second argument is the primary variable (eg HEADERS), and all
7058 # subsequent arguments are possible installation locations. Returns
7059 # list of all values of all _HOW targets.
7061 # FIXME: this should be rewritten to be cleaner. It should be broken
7062 # up into multiple functions.
7064 # Usage is: am_install_var (OPTION..., file, HOW, where...)
7065 sub am_install_var
7067 local (@args) = @_;
7069 local ($do_clean) = 0;
7070 local ($do_require) = 1;
7071 local ($can_dist) = 0;
7072 local ($default_dist) = 0;
7074 local ($ltxform);
7075 if (defined $configure_vars{'LIBTOOL'})
7077 # Transform '@LIBTOOL ...@' to '$(LIBTOOL) ...'
7078 $ltxform = 's/\@LIBTOOL([^\@]*)\@/\$(LIBTOOL) $1/;';
7080 else
7082 # Delete '@LIBTOOL ...@'
7083 $ltxform = 's/\@LIBTOOL([^\@]*)\@//;';
7086 local ($cygxform);
7087 if (! $seen_exeext)
7089 $cygxform = 's/\@EXEEXT\@//g;';
7091 else
7093 $cygxform = 's/\@EXEEXT\@/\$(EXEEXT)/g;';
7096 while (@args)
7098 if ($args[0] eq '-clean')
7100 $do_clean = 1;
7102 elsif ($args[0] eq '-noextra')
7104 $do_require = 0;
7106 elsif ($args[0] eq '-candist')
7108 $can_dist = 1;
7110 elsif ($args[0] eq '-defaultdist')
7112 $default_dist = 1;
7113 $can_dist = 1;
7115 elsif ($args[0] !~ /^-/)
7117 last;
7119 shift (@args);
7122 local ($file, $primary, @prefixes) = @args;
7124 local (@used) = ();
7125 local (@result) = ();
7127 # Now that configure substitutions are allowed in where_HOW
7128 # variables, it is an error to actually define the primary. We
7129 # allow `JAVA', as it is customarily used to mean the Java
7130 # interpreter. This is but one of several Java hacks. Similarly,
7131 # `PYTHON' is customarily used to mean the Python interpreter.
7132 &am_line_error ($primary, "\`$primary' is an anachronism")
7133 if &variable_defined ($primary)
7134 && ($primary ne 'JAVA' && $primary ne 'PYTHON');
7137 # Look for misspellings. It is an error to have a variable ending
7138 # in a "reserved" suffix whose prefix is unknown, eg
7139 # "bni_PROGRAMS". However, unusual prefixes are allowed if a
7140 # variable of the same name (with "dir" appended) exists. For
7141 # instance, if the variable "zardir" is defined, then
7142 # "zar_PROGRAMS" becomes valid. This is to provide a little extra
7143 # flexibility in those cases which need it.
7144 local (%valid) = &am_primary_prefixes ($primary, $can_dist, @prefixes);
7146 # If a primary includes a configure substitution, then the EXTRA_
7147 # form is required. Otherwise we can't properly do our job.
7148 local ($require_extra);
7149 local ($warned_about_extra) = 0;
7151 local ($clean_file) = $file . '-clean';
7152 local ($one_name);
7153 local ($X);
7154 local ($nodir_name);
7155 local ($strip_subdir) = 1;
7156 foreach $X (sort keys %valid)
7158 $one_name = $X . '_' . $primary;
7159 if (&variable_defined ($one_name))
7161 # If subdir prefix should be preserved, do so.
7162 if ($X =~ /^nobase_/)
7164 $strip_subdir = 0;
7165 $X =~ s/^nobase_//;
7168 # If files should be distributed, do so.
7169 if ($can_dist)
7171 if (($default_dist && $one_name !~ /^nodist_/)
7172 || (! $default_dist && $one_name =~ /^dist_/))
7174 &push_dist_common ('$(' . $one_name . ')');
7176 ($nodir_name = $X) =~ s/^(dist|nodist)_//;
7178 else
7180 $nodir_name = $X;
7183 # Append actual contents of where_PRIMARY variable to
7184 # result.
7185 local ($rcurs);
7186 foreach $rcurs (&variable_value_as_list ($one_name, 'all'))
7188 # Skip configure substitutions. Possibly bogus.
7189 if ($rcurs =~ /^\@.*\@$/)
7191 if ($X eq 'EXTRA')
7193 if (! $warned_about_extra)
7195 $warned_about_extra = 1;
7197 &am_line_error ($one_name,
7198 "\`$one_name' contains configure substitution, but shouldn't");
7202 # Check here to make sure variables defined in
7203 # configure.in do not imply that EXTRA_PRIMARY
7204 # must be defined.
7205 elsif (! defined $configure_vars{$one_name})
7207 $require_extra = $one_name
7208 if $do_require;
7211 next;
7214 push (@result, $rcurs);
7217 # "EXTRA" shouldn't be used when generating clean targets,
7218 # all, or install targets.
7219 if ($X eq 'EXTRA')
7221 # We used to warn if EXTRA_FOO was defined uselessly,
7222 # but this was annoying.
7223 next;
7226 # A blatant hack: we rewrite each _PROGRAMS primary to
7227 # include EXEEXT when in Cygwin32 mode.
7228 if ($seen_exeext && $primary eq 'PROGRAMS')
7230 local (@conds) = &variable_conditions ($one_name);
7231 local (@one_binlist);
7233 # FIXME: this definitely loses aesthetically; it
7234 # redefines $ONE_NAME. Instead we should arrange for
7235 # variable definitions to be output later, instead of
7236 # at scan time.
7238 if (! @conds)
7240 @one_binlist = ();
7241 foreach $rcurs (&variable_value_as_list ($one_name, ''))
7243 if ($rcurs =~ /\./ || $rcurs =~ /^\@.*\@$/)
7245 push (@one_binlist, $rcurs);
7247 else
7249 push (@one_binlist, $rcurs . '$(EXEEXT)');
7253 delete $contents{$one_name};
7254 &define_pretty_variable ($one_name, '', @one_binlist);
7256 else
7258 local ($cond);
7259 local ($condvals) = '';
7260 foreach $cond (@conds)
7262 @one_binlist = ();
7263 local (@condval) = &variable_value_as_list ($one_name,
7264 $cond);
7265 foreach $rcurs (@condval)
7267 if ($rcurs =~ /\./ || $rcurs =~ /^\@.*\@$/)
7269 push (@one_binlist, $rcurs);
7271 else
7273 push (@one_binlist, $rcurs . '$(EXEEXT)');
7277 push (@condvals, $cond);
7278 push (@condvals, join (' ', @one_binlist));
7281 delete $contents{$one_name};
7283 while (@condvals)
7285 $cond = shift (@condvals);
7286 local (@val) = split (' ', shift (@condvals));
7287 &define_pretty_variable ($one_name, $cond, @val);
7292 if ($do_clean)
7294 $output_rules .=
7295 &file_contents_with_transform ('s/\@DIR\@/' . $X . '/go;'
7296 . $cygxform,
7297 $clean_file);
7299 push (@clean, $X . $primary);
7300 &push_phony_cleaners ($X . $primary);
7303 if ($X eq 'check')
7305 push (@check, '$(' . $one_name . ')');
7307 else
7309 push (@used, '$(' . $one_name . ')');
7311 if ($X eq 'noinst' || $X eq 'check')
7313 # Objects which don't get installed by default.
7314 next;
7317 local ($subdir_xform);
7318 if ($strip_subdir)
7320 $subdir_xform = 's/^NOBASE.*$//; s/^BASE//;';
7322 else
7324 $subdir_xform = 's/^BASE.*$//; s/^NOBASE//;';
7327 $output_rules .=
7328 &file_contents_with_transform ('s/\@DIR\@/' . $X . '/g;'
7329 . 's/\@NDIR\@/' . $nodir_name . '/go;'
7330 . $ltxform . $cygxform
7331 . $subdir_xform,
7332 $file);
7334 push (@uninstall, 'uninstall-' . $X . $primary);
7335 push (@phony, 'uninstall-' . $X . $primary);
7336 push (@installdirs, '$(DESTDIR)$(' . $X . 'dir)');
7337 if (defined $exec_dir_p{$X} ? $exec_dir_p{$X} : ($X =~ /exec/))
7339 push (@install_exec, 'install-' . $X . $primary);
7340 push (@phony, 'install-' . $X . $primary);
7342 else
7344 push (@install_data, 'install-' . $X . $primary);
7345 push (@phony, 'install-' . $X . $primary);
7350 # The JAVA variable is used as the name of the Java interpreter.
7351 # The PYTHON variable is used as the name of the Python interpreter.
7352 if (@used && $primary ne 'JAVA' && $primary ne 'PYTHON')
7354 # Define it.
7355 &define_pretty_variable ($primary, '', @used);
7356 $output_vars .= "\n";
7359 if ($require_extra && ! &variable_defined ('EXTRA_' . $primary))
7361 &am_line_error ($require_extra,
7362 "\`$require_extra' contains configure substitution, but \`EXTRA_$primary' not defined");
7365 # Push here because PRIMARY might be configure time determined.
7366 push (@all, '$(' . $primary . ')')
7367 if @used && $primary ne 'JAVA' && $primary ne 'PYTHON';
7369 # Make the result unique. This lets the user use conditionals in
7370 # a natural way, but still lets us program lazily -- we don't have
7371 # to worry about handling a particular object more than once.
7372 local (%uniquify) = ();
7373 grep ($uniquify{$_} = 1, @result);
7374 return sort keys %uniquify;
7378 ################################################################
7380 # Each key in this hash is the name of a directory holding a
7381 # Makefile.in. These variables are local to `is_make_dir'.
7382 %make_dirs = ();
7383 $make_dirs_set = 0;
7385 sub is_make_dir
7387 local ($dir) = @_;
7388 if (! $make_dirs_set)
7390 foreach $iter (@configure_input_files)
7392 $make_dirs{&dirname ($iter)} = 1;
7394 # We also want to notice Makefile.in's.
7395 foreach $iter (@other_input_files)
7397 if ($iter =~ /Makefile\.in$/)
7399 $make_dirs{&dirname ($iter)} = 1;
7402 $make_dirs_set = 1;
7404 return defined $make_dirs{$dir};
7407 ################################################################
7409 # This variable is local to the "require file" set of functions.
7410 @require_file_paths = ();
7412 # If a file name appears as a key in this hash, then it has already
7413 # been checked for. This variable is local to the "require file"
7414 # functions.
7415 %require_file_found = ();
7417 # See if we want to push this file onto dist_common. This function
7418 # encodes the rules for deciding when to do so.
7419 sub maybe_push_required_file
7421 local ($dir, $file, $fullfile) = @_;
7423 # FIXME: Once again, special-case `.'.
7424 if ($dir eq $relative_dir || $dir eq '.')
7426 &push_dist_common ($file);
7428 elsif ($relative_dir eq '.' && ! &is_make_dir ($dir))
7430 # If we are doing the topmost directory, and the file is in a
7431 # subdir which does not have a Makefile, then we distribute it
7432 # here.
7433 &push_dist_common ($fullfile);
7437 # Verify that the file must exist in the current directory. Usage:
7438 # require_file (isconfigure, line_number, strictness, file) strictness
7439 # is the strictness level at which this file becomes required. Must
7440 # set require_file_paths before calling this function.
7441 # require_file_paths is set to hold a single directory (the one in
7442 # which the first file was found) before return.
7443 sub require_file_internal
7445 local ($is_configure, $line, $mystrict, @files) = @_;
7446 local ($file, $fullfile);
7447 local ($found_it, $dangling_sym, $errfile, $errdir);
7448 local ($save_dir);
7450 foreach $file (@files)
7452 # If we've already looked for it, we're done.
7453 next if defined $require_file_found{$file};
7454 $require_file_found{$file} = 1;
7456 $found_it = 0;
7457 $dangling_sym = 0;
7458 foreach $dir (@require_file_paths)
7460 if ($dir eq '.')
7462 $fullfile = $relative_dir . "/" . $file;
7463 $errdir = $relative_dir unless $errdir;
7465 else
7467 $fullfile = $dir . "/" . $file;
7468 $errdir = $dir unless $errdir;
7471 # Use different name for "error filename". Otherwise on
7472 # an error the bad file will be reported as eg
7473 # `../../install-sh' when using the default
7474 # config_aux_path.
7475 $errfile = $errdir . '/' . $file;
7477 if (-l $fullfile && ! -f readlink ($fullfile))
7479 $dangling_sym = 1;
7480 last;
7482 elsif (-f $fullfile)
7484 $found_it = 1;
7485 &maybe_push_required_file ($dir, $file, $fullfile);
7486 $save_dir = $dir;
7487 last;
7491 if ($found_it && ! $force_missing)
7493 # Prune the path list.
7494 @require_file_paths = $save_dir;
7496 else
7498 if ($strictness >= $mystrict)
7500 if ($dangling_sym && ($force_missing || $add_missing))
7502 unlink ($fullfile);
7505 local ($trailer) = '';
7506 local ($suppress) = 0;
7508 # Only install missing files according to our desired
7509 # strictness level.
7510 local ($message) = "required file \`$errfile' not found";
7511 if ($add_missing)
7513 $suppress = 1;
7515 # Maybe run libtoolize.
7516 local @syslist = ('libtoolize', '--automake');
7517 push @syslist, '--copy'
7518 if $copy_missing;
7519 if ($seen_libtool
7520 && grep ($_ eq $file, @libtoolize_files)
7521 && system (@syslist))
7523 $message = "installing \`$errfile'";
7524 $suppress = 0;
7525 $trailer = "; cannot run \`libtoolize': $!";
7527 elsif (-f ($am_dir . '/' . $file))
7529 # Install the missing file. Symlink if we
7530 # can, copy if we must. Note: delete the file
7531 # first, in case it is a dangling symlink.
7532 $message = "installing \`$errfile'";
7533 # Windows Perl will hang if we try to delete a
7534 # file that doesn't exist.
7535 unlink ($errfile) if -f $errfile;
7536 if ($symlink_exists && ! $copy_missing)
7538 if (! symlink ($am_dir . '/' . $file, $errfile))
7540 $suppress = 0;
7541 $trailer = "; error while making link: $!";
7544 elsif (system ('cp', $am_dir . '/' . $file, $errfile))
7546 $suppress = 0;
7547 $trailer = "\n error while copying";
7551 &maybe_push_required_file (&dirname ($errfile),
7552 $errfile, $errfile);
7555 local ($save) = $exit_status;
7556 if ($is_configure)
7558 # FIXME: allow actual file to be specified.
7559 &am_conf_line_error ('configure.in', $line,
7560 "$message$trailer");
7562 else
7564 &am_line_error ($line, "$message$trailer");
7566 $exit_status = $save if $suppress;
7572 # Like require_file_with_line, but error messages refer to
7573 # configure.in, not the current Makefile.am.
7574 sub require_file_with_conf_line
7576 @require_file_paths = '.';
7577 &require_file_internal (1, @_);
7580 sub require_file_with_line
7582 @require_file_paths = '.';
7583 &require_file_internal (0, @_);
7586 sub require_file
7588 @require_file_paths = '.';
7589 &require_file_internal (0, '', @_);
7592 # Require a file that is also required by Autoconf. Looks in
7593 # configuration path, as specified by AC_CONFIG_AUX_DIR.
7594 sub require_config_file
7596 @require_file_paths = @config_aux_path;
7597 &require_file_internal (1, '', @_);
7598 local ($dir) = $require_file_paths[0];
7599 @config_aux_path = @require_file_paths;
7600 if ($dir eq '.')
7602 $config_aux_dir = '.';
7604 else
7606 $config_aux_dir = '$(top_srcdir)/' . $dir;
7610 # Assumes that the line number is in Makefile.am.
7611 sub require_conf_file_with_line
7613 @require_file_paths = @config_aux_path;
7614 &require_file_internal (0, @_);
7615 local ($dir) = $require_file_paths[0];
7616 @config_aux_path = @require_file_paths;
7617 if ($dir eq '.')
7619 $config_aux_dir = '.';
7621 else
7623 $config_aux_dir = '$(top_srcdir)/' . $dir;
7627 # Assumes that the line number is in configure.in.
7628 sub require_conf_file_with_conf_line
7630 @require_file_paths = @config_aux_path;
7631 &require_file_internal (1, @_);
7632 local ($dir) = $require_file_paths[0];
7633 @config_aux_path = @require_file_paths;
7634 if ($dir eq '.')
7636 $config_aux_dir = '.';
7638 else
7640 $config_aux_dir = '$(top_srcdir)/' . $dir;
7644 ################################################################
7646 # Push a list of files onto dist_common.
7647 sub push_dist_common
7649 local (@files) = @_;
7650 local ($file);
7652 foreach $file (@files)
7654 if (! defined $dist_common{$file})
7656 if ($handle_dist_run)
7658 print STDERR
7659 "automake: programming error: push_dist_common run after handle_dist\n";
7660 exit 1;
7662 $dist_common{$file} = 1;
7667 # Push a list of clean targets onto phony.
7668 sub push_phony_cleaners
7670 local ($base) = @_;
7671 local ($target);
7672 foreach $target ('mostly', 'dist', '', 'maintainer-')
7674 push (@phony, $target . 'clean-' . $base);
7678 # Set strictness.
7679 sub set_strictness
7681 $strictness_name = $_[0];
7682 if ($strictness_name eq 'gnu')
7684 $strictness = $GNU;
7686 elsif ($strictness_name eq 'gnits')
7688 $strictness = $GNITS;
7690 elsif ($strictness_name eq 'foreign')
7692 $strictness = $FOREIGN;
7694 else
7696 die "automake: level \`$strictness_name' not recognized\n";
7701 ################################################################
7703 # Return directory name of file.
7704 sub dirname
7706 local ($file) = @_;
7707 local ($sub);
7709 ($sub = $file) =~ s,/+[^/]+$,,g;
7710 $sub = '.' if $sub eq $file;
7711 return $sub;
7714 # Return file name of a file.
7715 sub basename
7717 local ($file) = @_;
7718 local ($sub);
7720 ($sub = $file) =~s,^.*/+,,g;
7721 return $sub;
7724 # Ensure a file exists.
7725 sub create
7727 local ($file) = @_;
7729 open (TOUCH, ">> $file");
7730 close (TOUCH);
7733 # Glob something. Do this to avoid indentation screwups everywhere we
7734 # want to glob. Gross!
7735 sub my_glob
7737 local ($pat) = @_;
7738 return <${pat}>;
7741 ################################################################
7743 # Print an error message and set exit status.
7744 sub am_error
7746 warn "automake: ${am_file}.am: ", join (' ', @_), "\n";
7747 $exit_status = 1;
7750 sub am_line_error
7752 local ($symbol, @args) = @_;
7754 if ($symbol && "$symbol" ne '-1')
7756 local ($file) = "${am_file}.am";
7758 if ($symbol =~ /^\d+$/)
7760 # SYMBOL is a line number, so just add the colon.
7761 $file .= ':' . $symbol;
7763 elsif (defined $content_lines{$symbol})
7765 # SYMBOL is a variable defined in Makefile.am, so add the
7766 # line number we saved from there.
7767 $file .= ':' . $content_lines{$symbol};
7769 elsif (defined $configure_vars{$symbol})
7771 # SYMBOL is a variable defined in configure.in, so add the
7772 # appropriate line number.
7773 $file = $configure_vars{$symbol};
7775 else
7777 # Couldn't find the line number.
7779 warn $file, ": ", join (' ', @args), "\n";
7780 $exit_status = 1;
7782 else
7784 &am_error (@args);
7788 # Like am_error, but while scanning configure.in.
7789 sub am_conf_error
7791 # FIXME: can run in subdirs.
7792 warn "automake: configure.in: ", join (' ', @_), "\n";
7793 $exit_status = 1;
7796 # Error message with line number referring to configure.in.
7797 sub am_conf_line_error
7799 local ($file, $line, @args) = @_;
7801 if ($line)
7803 warn "$file: $line: ", join (' ', @args), "\n";
7804 $exit_status = 1;
7806 else
7808 &am_conf_error (@args);
7812 # Warning message with line number referring to configure.in.
7813 # Does not affect exit_status
7814 sub am_conf_line_warning
7816 local ($saved_exit_status) = $exit_status;
7817 &am_conf_line_error (@_);
7818 $exit_status = $saved_exit_status;
7821 # Tell user where our aclocal.m4 is, but only once.
7822 sub keyed_aclocal_warning
7824 local ($key) = @_;
7825 warn "automake: macro \`$key' can be generated by \`aclocal'\n";
7828 # Print usage information.
7829 sub usage
7831 print "Usage: automake [OPTION] ... [Makefile]...\n\n";
7832 print "Generate Makefile.in for autoconf from Makefile.am\n";
7833 print $USAGE;
7834 print "\nFiles which are automatically distributed, if found:\n";
7835 $~ = "USAGE_FORMAT";
7836 local ($last, $iter, @lcomm);
7837 $last = '';
7838 foreach $iter (sort ((@common_files, @common_sometimes)))
7840 push (@lcomm, $iter) unless $iter eq $last;
7841 $last = $iter;
7844 local ($one, $two, $three, $four, $i, $max);
7845 $max = int (($#lcomm + 1) / 4);
7847 for ($i = 0; $i < $max; ++$i)
7849 $one = $lcomm[$i];
7850 $two = $lcomm[$max + $i];
7851 $three = $lcomm[2 * $max + $i];
7852 $four = $lcomm[3 * $max + $i];
7853 write;
7856 local ($mod) = ($#lcomm + 1) % 4;
7857 if ($mod != 0)
7859 $one = $lcomm[$max];
7860 $two = ($mod > 1) ? $lcomm[2 * $max] : '';
7861 $three = ($mod > 2) ? $lcomm[3 * $max] : '';
7862 $four = ($mod > 3) ? $lcomm[4 * $max] : '';
7863 write;
7866 print "\nReport bugs to <bug-automake\@gnu.org>.\n";
7868 exit 0;
7871 format USAGE_FORMAT =
7872 @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<
7873 $one, $two, $three, $four