1 | #!@PERL@ -w
|
---|
2 | # -*- perl -*-
|
---|
3 | # @configure_input@
|
---|
4 |
|
---|
5 | eval 'case $# in 0) exec @PERL@ -S "$0";; *) exec @PERL@ -S "$0" "$@";; esac'
|
---|
6 | if 0;
|
---|
7 |
|
---|
8 | # automake - create Makefile.in from Makefile.am
|
---|
9 | # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
|
---|
10 | # 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
|
---|
11 |
|
---|
12 | # This program is free software; you can redistribute it and/or modify
|
---|
13 | # it under the terms of the GNU General Public License as published by
|
---|
14 | # the Free Software Foundation; either version 2, or (at your option)
|
---|
15 | # any later version.
|
---|
16 |
|
---|
17 | # This program is distributed in the hope that it will be useful,
|
---|
18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
20 | # GNU General Public License for more details.
|
---|
21 |
|
---|
22 | # You should have received a copy of the GNU General Public License
|
---|
23 | # along with this program; if not, write to the Free Software
|
---|
24 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
---|
25 | # 02110-1301, USA.
|
---|
26 |
|
---|
27 | # Originally written by David Mackenzie <djm@gnu.ai.mit.edu>.
|
---|
28 | # Perl reimplementation by Tom Tromey <tromey@redhat.com>, and
|
---|
29 | # Alexandre Duret-Lutz <adl@gnu.org>.
|
---|
30 |
|
---|
31 | package Language;
|
---|
32 |
|
---|
33 | BEGIN
|
---|
34 | {
|
---|
35 | my $perllibdir = $ENV{'perllibdir'} || '@datadir@/@PACKAGE@-@APIVERSION@';
|
---|
36 | unshift @INC, (split '@PATH_SEPARATOR@', $perllibdir);
|
---|
37 |
|
---|
38 | # Override SHELL. This is required on DJGPP so that system() uses
|
---|
39 | # bash, not COMMAND.COM which doesn't quote arguments properly.
|
---|
40 | # Other systems aren't expected to use $SHELL when Automake
|
---|
41 | # runs, but it should be safe to drop the `if DJGPP' guard if
|
---|
42 | # it turns up other systems need the same thing. After all,
|
---|
43 | # if SHELL is used, ./configure's SHELL is always better than
|
---|
44 | # the user's SHELL (which may be something like tcsh).
|
---|
45 | $ENV{'SHELL'} = '@SHELL@' if exists $ENV{'DJGPP'};
|
---|
46 | }
|
---|
47 |
|
---|
48 | use Automake::Struct;
|
---|
49 | struct (# Short name of the language (c, f77...).
|
---|
50 | 'name' => "\$",
|
---|
51 | # Nice name of the language (C, Fortran 77...).
|
---|
52 | 'Name' => "\$",
|
---|
53 |
|
---|
54 | # List of configure variables which must be defined.
|
---|
55 | 'config_vars' => '@',
|
---|
56 |
|
---|
57 | 'ansi' => "\$",
|
---|
58 | # `pure' is `1' or `'. A `pure' language is one where, if
|
---|
59 | # all the files in a directory are of that language, then we
|
---|
60 | # do not require the C compiler or any code to call it.
|
---|
61 | 'pure' => "\$",
|
---|
62 |
|
---|
63 | 'autodep' => "\$",
|
---|
64 |
|
---|
65 | # Name of the compiling variable (COMPILE).
|
---|
66 | 'compiler' => "\$",
|
---|
67 | # Content of the compiling variable.
|
---|
68 | 'compile' => "\$",
|
---|
69 | # Flag to require compilation without linking (-c).
|
---|
70 | 'compile_flag' => "\$",
|
---|
71 | 'extensions' => '@',
|
---|
72 | # A subroutine to compute a list of possible extensions of
|
---|
73 | # the product given the input extensions.
|
---|
74 | # (defaults to a subroutine which returns ('.$(OBJEXT)', '.lo'))
|
---|
75 | 'output_extensions' => "\$",
|
---|
76 | # A list of flag variables used in 'compile'.
|
---|
77 | # (defaults to [])
|
---|
78 | 'flags' => "@",
|
---|
79 |
|
---|
80 | # Any tag to pass to libtool while compiling.
|
---|
81 | 'libtool_tag' => "\$",
|
---|
82 |
|
---|
83 | # The file to use when generating rules for this language.
|
---|
84 | # The default is 'depend2'.
|
---|
85 | 'rule_file' => "\$",
|
---|
86 |
|
---|
87 | # Name of the linking variable (LINK).
|
---|
88 | 'linker' => "\$",
|
---|
89 | # Content of the linking variable.
|
---|
90 | 'link' => "\$",
|
---|
91 |
|
---|
92 | # Name of the linker variable (LD).
|
---|
93 | 'lder' => "\$",
|
---|
94 | # Content of the linker variable ($(CC)).
|
---|
95 | 'ld' => "\$",
|
---|
96 |
|
---|
97 | # Flag to specify the output file (-o).
|
---|
98 | 'output_flag' => "\$",
|
---|
99 | '_finish' => "\$",
|
---|
100 |
|
---|
101 | # This is a subroutine which is called whenever we finally
|
---|
102 | # determine the context in which a source file will be
|
---|
103 | # compiled.
|
---|
104 | '_target_hook' => "\$",
|
---|
105 |
|
---|
106 | # If TRUE, nodist_ sources will be compiled using specific rules
|
---|
107 | # (i.e. not inference rules). The default is FALSE.
|
---|
108 | 'nodist_specific' => "\$");
|
---|
109 |
|
---|
110 |
|
---|
111 | sub finish ($)
|
---|
112 | {
|
---|
113 | my ($self) = @_;
|
---|
114 | if (defined $self->_finish)
|
---|
115 | {
|
---|
116 | &{$self->_finish} ();
|
---|
117 | }
|
---|
118 | }
|
---|
119 |
|
---|
120 | sub target_hook ($$$$%)
|
---|
121 | {
|
---|
122 | my ($self) = @_;
|
---|
123 | if (defined $self->_target_hook)
|
---|
124 | {
|
---|
125 | &{$self->_target_hook} (@_);
|
---|
126 | }
|
---|
127 | }
|
---|
128 |
|
---|
129 | package Automake;
|
---|
130 |
|
---|
131 | use strict;
|
---|
132 | use Automake::Config;
|
---|
133 | use Automake::General;
|
---|
134 | use Automake::XFile;
|
---|
135 | use Automake::Channels;
|
---|
136 | use Automake::ChannelDefs;
|
---|
137 | use Automake::Configure_ac;
|
---|
138 | use Automake::FileUtils;
|
---|
139 | use Automake::Location;
|
---|
140 | use Automake::Condition qw/TRUE FALSE/;
|
---|
141 | use Automake::DisjConditions;
|
---|
142 | use Automake::Options;
|
---|
143 | use Automake::Version;
|
---|
144 | use Automake::Variable;
|
---|
145 | use Automake::VarDef;
|
---|
146 | use Automake::Rule;
|
---|
147 | use Automake::RuleDef;
|
---|
148 | use Automake::Wrap 'makefile_wrap';
|
---|
149 | use File::Basename;
|
---|
150 | use File::Spec;
|
---|
151 | use Carp;
|
---|
152 |
|
---|
153 | ## ----------- ##
|
---|
154 | ## Constants. ##
|
---|
155 | ## ----------- ##
|
---|
156 |
|
---|
157 | # Some regular expressions. One reason to put them here is that it
|
---|
158 | # makes indentation work better in Emacs.
|
---|
159 |
|
---|
160 | # Writing singled-quoted-$-terminated regexes is a pain because
|
---|
161 | # perl-mode thinks of $' as the ${'} variable (instead of a $ followed
|
---|
162 | # by a closing quote. Letting perl-mode think the quote is not closed
|
---|
163 | # leads to all sort of misindentations. On the other hand, defining
|
---|
164 | # regexes as double-quoted strings is far less readable. So usually
|
---|
165 | # we will write:
|
---|
166 | #
|
---|
167 | # $REGEX = '^regex_value' . "\$";
|
---|
168 |
|
---|
169 | my $IGNORE_PATTERN = '^\s*##([^#\n].*)?\n';
|
---|
170 | my $WHITE_PATTERN = '^\s*' . "\$";
|
---|
171 | my $COMMENT_PATTERN = '^#';
|
---|
172 | my $TARGET_PATTERN='[$a-zA-Z_.@%][-.a-zA-Z0-9_(){}/$+@%]*';
|
---|
173 | # A rule has three parts: a list of targets, a list of dependencies,
|
---|
174 | # and optionally actions.
|
---|
175 | my $RULE_PATTERN =
|
---|
176 | "^($TARGET_PATTERN(?:(?:\\\\\n|\\s)+$TARGET_PATTERN)*) *:([^=].*|)\$";
|
---|
177 |
|
---|
178 | # Only recognize leading spaces, not leading tabs. If we recognize
|
---|
179 | # leading tabs here then we need to make the reader smarter, because
|
---|
180 | # otherwise it will think rules like `foo=bar; \' are errors.
|
---|
181 | my $ASSIGNMENT_PATTERN = '^ *([^ \t=:+]*)\s*([:+]?)=\s*(.*)' . "\$";
|
---|
182 | # This pattern recognizes a Gnits version id and sets $1 if the
|
---|
183 | # release is an alpha release. We also allow a suffix which can be
|
---|
184 | # used to extend the version number with a "fork" identifier.
|
---|
185 | my $GNITS_VERSION_PATTERN = '\d+\.\d+([a-z]|\.\d+)?(-[A-Za-z0-9]+)?';
|
---|
186 |
|
---|
187 | my $IF_PATTERN = '^if\s+(!?)\s*([A-Za-z][A-Za-z0-9_]*)\s*(?:#.*)?' . "\$";
|
---|
188 | my $ELSE_PATTERN =
|
---|
189 | '^else(?:\s+(!?)\s*([A-Za-z][A-Za-z0-9_]*))?\s*(?:#.*)?' . "\$";
|
---|
190 | my $ENDIF_PATTERN =
|
---|
191 | '^endif(?:\s+(!?)\s*([A-Za-z][A-Za-z0-9_]*))?\s*(?:#.*)?' . "\$";
|
---|
192 | my $PATH_PATTERN = '(\w|[+/.-])+';
|
---|
193 | # This will pass through anything not of the prescribed form.
|
---|
194 | my $INCLUDE_PATTERN = ('^include\s+'
|
---|
195 | . '((\$\(top_srcdir\)/' . $PATH_PATTERN . ')'
|
---|
196 | . '|(\$\(srcdir\)/' . $PATH_PATTERN . ')'
|
---|
197 | . '|([^/\$]' . $PATH_PATTERN . '))\s*(#.*)?' . "\$");
|
---|
198 |
|
---|
199 | # Match `-d' as a command-line argument in a string.
|
---|
200 | my $DASH_D_PATTERN = "(^|\\s)-d(\\s|\$)";
|
---|
201 | # Directories installed during 'install-exec' phase.
|
---|
202 | my $EXEC_DIR_PATTERN =
|
---|
203 | '^(?:bin|sbin|libexec|sysconf|localstate|lib|pkglib|.*exec.*)' . "\$";
|
---|
204 |
|
---|
205 | # Values for AC_CANONICAL_*
|
---|
206 | use constant AC_CANONICAL_BUILD => 1;
|
---|
207 | use constant AC_CANONICAL_HOST => 2;
|
---|
208 | use constant AC_CANONICAL_TARGET => 3;
|
---|
209 |
|
---|
210 | # Values indicating when something should be cleaned.
|
---|
211 | use constant MOSTLY_CLEAN => 0;
|
---|
212 | use constant CLEAN => 1;
|
---|
213 | use constant DIST_CLEAN => 2;
|
---|
214 | use constant MAINTAINER_CLEAN => 3;
|
---|
215 |
|
---|
216 | # Libtool files.
|
---|
217 | my @libtool_files = qw(ltmain.sh config.guess config.sub);
|
---|
218 | # ltconfig appears here for compatibility with old versions of libtool.
|
---|
219 | my @libtool_sometimes = qw(ltconfig ltcf-c.sh ltcf-cxx.sh ltcf-gcj.sh);
|
---|
220 |
|
---|
221 | # Commonly found files we look for and automatically include in
|
---|
222 | # DISTFILES.
|
---|
223 | my @common_files =
|
---|
224 | (qw(ABOUT-GNU ABOUT-NLS AUTHORS BACKLOG COPYING COPYING.DOC COPYING.LIB
|
---|
225 | COPYING.LESSER ChangeLog INSTALL NEWS README THANKS TODO
|
---|
226 | ansi2knr.1 ansi2knr.c compile config.guess config.rpath config.sub
|
---|
227 | depcomp elisp-comp install-sh libversion.in mdate-sh missing
|
---|
228 | mkinstalldirs py-compile texinfo.tex ylwrap),
|
---|
229 | @libtool_files, @libtool_sometimes);
|
---|
230 |
|
---|
231 | # Commonly used files we auto-include, but only sometimes. This list
|
---|
232 | # is used for the --help output only.
|
---|
233 | my @common_sometimes =
|
---|
234 | qw(aclocal.m4 acconfig.h config.h.top config.h.bot configure
|
---|
235 | configure.ac configure.in stamp-vti);
|
---|
236 |
|
---|
237 | # Standard directories from the GNU Coding Standards, and additional
|
---|
238 | # pkg* directories from Automake. Stored in a hash for fast member check.
|
---|
239 | my %standard_prefix =
|
---|
240 | map { $_ => 1 } (qw(bin data dataroot dvi exec html include info
|
---|
241 | lib libexec lisp localstate man man1 man2 man3
|
---|
242 | man4 man5 man6 man7 man8 man9 oldinclude pdf
|
---|
243 | pkgdatadir pkgincludedir pkglibdir ps sbin
|
---|
244 | sharedstate sysconf));
|
---|
245 |
|
---|
246 | # Copyright on generated Makefile.ins.
|
---|
247 | my $gen_copyright = "\
|
---|
248 | # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
|
---|
249 | # 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
|
---|
250 | # This Makefile.in is free software; the Free Software Foundation
|
---|
251 | # gives unlimited permission to copy and/or distribute it,
|
---|
252 | # with or without modifications, as long as this notice is preserved.
|
---|
253 |
|
---|
254 | # This program is distributed in the hope that it will be useful,
|
---|
255 | # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
---|
256 | # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
---|
257 | # PARTICULAR PURPOSE.
|
---|
258 | ";
|
---|
259 |
|
---|
260 | # These constants are returned by the lang_*_rewrite functions.
|
---|
261 | # LANG_SUBDIR means that the resulting object file should be in a
|
---|
262 | # subdir if the source file is. In this case the file name cannot
|
---|
263 | # have `..' components.
|
---|
264 | use constant LANG_IGNORE => 0;
|
---|
265 | use constant LANG_PROCESS => 1;
|
---|
266 | use constant LANG_SUBDIR => 2;
|
---|
267 |
|
---|
268 | # These are used when keeping track of whether an object can be built
|
---|
269 | # by two different paths.
|
---|
270 | use constant COMPILE_LIBTOOL => 1;
|
---|
271 | use constant COMPILE_ORDINARY => 2;
|
---|
272 |
|
---|
273 | # We can't always associate a location to a variable or a rule,
|
---|
274 | # when it's defined by Automake. We use INTERNAL in this case.
|
---|
275 | use constant INTERNAL => new Automake::Location;
|
---|
276 | |
---|
277 |
|
---|
278 |
|
---|
279 | ## ---------------------------------- ##
|
---|
280 | ## Variables related to the options. ##
|
---|
281 | ## ---------------------------------- ##
|
---|
282 |
|
---|
283 | # TRUE if we should always generate Makefile.in.
|
---|
284 | my $force_generation = 1;
|
---|
285 |
|
---|
286 | # From the Perl manual.
|
---|
287 | my $symlink_exists = (eval 'symlink ("", "");', $@ eq '');
|
---|
288 |
|
---|
289 | # TRUE if missing standard files should be installed.
|
---|
290 | my $add_missing = 0;
|
---|
291 |
|
---|
292 | # TRUE if we should copy missing files; otherwise symlink if possible.
|
---|
293 | my $copy_missing = 0;
|
---|
294 |
|
---|
295 | # TRUE if we should always update files that we know about.
|
---|
296 | my $force_missing = 0;
|
---|
297 |
|
---|
298 |
|
---|
299 | ## ---------------------------------------- ##
|
---|
300 | ## Variables filled during files scanning. ##
|
---|
301 | ## ---------------------------------------- ##
|
---|
302 |
|
---|
303 | # Name of the configure.ac file.
|
---|
304 | my $configure_ac;
|
---|
305 |
|
---|
306 | # Files found by scanning configure.ac for LIBOBJS.
|
---|
307 | my %libsources = ();
|
---|
308 |
|
---|
309 | # Names used in AC_CONFIG_HEADER call.
|
---|
310 | my @config_headers = ();
|
---|
311 |
|
---|
312 | # Names used in AC_CONFIG_LINKS call.
|
---|
313 | my @config_links = ();
|
---|
314 |
|
---|
315 | # Directory where output files go. Actually, output files are
|
---|
316 | # relative to this directory.
|
---|
317 | my $output_directory;
|
---|
318 |
|
---|
319 | # List of Makefile.am's to process, and their corresponding outputs.
|
---|
320 | my @input_files = ();
|
---|
321 | my %output_files = ();
|
---|
322 |
|
---|
323 | # Complete list of Makefile.am's that exist.
|
---|
324 | my @configure_input_files = ();
|
---|
325 |
|
---|
326 | # List of files in AC_CONFIG_FILES/AC_OUTPUT without Makefile.am's,
|
---|
327 | # and their outputs.
|
---|
328 | my @other_input_files = ();
|
---|
329 | # Where each AC_CONFIG_FILES/AC_OUTPUT/AC_CONFIG_LINK/AC_CONFIG_HEADER appears.
|
---|
330 | # The keys are the files created by these macros.
|
---|
331 | my %ac_config_files_location = ();
|
---|
332 |
|
---|
333 | # Directory to search for configure-required files. This
|
---|
334 | # will be computed by &locate_aux_dir and can be set using
|
---|
335 | # AC_CONFIG_AUX_DIR in configure.ac.
|
---|
336 | # $CONFIG_AUX_DIR is the `raw' directory, valid only in the source-tree.
|
---|
337 | my $config_aux_dir = '';
|
---|
338 | my $config_aux_dir_set_in_configure_ac = 0;
|
---|
339 | # $AM_CONFIG_AUX_DIR is prefixed with $(top_srcdir), so it can be used
|
---|
340 | # in Makefiles.
|
---|
341 | my $am_config_aux_dir = '';
|
---|
342 |
|
---|
343 | # Directory to search for AC_LIBSOURCE files, as set by AC_CONFIG_LIBOBJ_DIR
|
---|
344 | # in configure.ac.
|
---|
345 | my $config_libobj_dir = '';
|
---|
346 |
|
---|
347 | # Whether AM_GNU_GETTEXT has been seen in configure.ac.
|
---|
348 | my $seen_gettext = 0;
|
---|
349 | # Whether AM_GNU_GETTEXT([external]) is used.
|
---|
350 | my $seen_gettext_external = 0;
|
---|
351 | # Where AM_GNU_GETTEXT appears.
|
---|
352 | my $ac_gettext_location;
|
---|
353 | # Whether AM_GNU_GETTEXT_INTL_SUBDIR has been seen.
|
---|
354 | my $seen_gettext_intl = 0;
|
---|
355 |
|
---|
356 | # Lists of tags supported by Libtool.
|
---|
357 | my %libtool_tags = ();
|
---|
358 | # 1 if Libtool uses LT_SUPPORTED_TAG. If it does, then it also
|
---|
359 | # uses AC_REQUIRE_AUX_FILE.
|
---|
360 | my $libtool_new_api = 0;
|
---|
361 |
|
---|
362 | # Most important AC_CANONICAL_* macro seen so far.
|
---|
363 | my $seen_canonical = 0;
|
---|
364 | # Location of that macro.
|
---|
365 | my $canonical_location;
|
---|
366 |
|
---|
367 | # Where AM_MAINTAINER_MODE appears.
|
---|
368 | my $seen_maint_mode;
|
---|
369 |
|
---|
370 | # Actual version we've seen.
|
---|
371 | my $package_version = '';
|
---|
372 |
|
---|
373 | # Where version is defined.
|
---|
374 | my $package_version_location;
|
---|
375 |
|
---|
376 | # TRUE if we've seen AC_ENABLE_MULTILIB.
|
---|
377 | my $seen_multilib = 0;
|
---|
378 |
|
---|
379 | # TRUE if we've seen AM_PROG_CC_C_O
|
---|
380 | my $seen_cc_c_o = 0;
|
---|
381 |
|
---|
382 | # Location of AC_REQUIRE_AUX_FILE calls, indexed by their argument.
|
---|
383 | my %required_aux_file = ();
|
---|
384 |
|
---|
385 | # Where AM_INIT_AUTOMAKE is called;
|
---|
386 | my $seen_init_automake = 0;
|
---|
387 |
|
---|
388 | # TRUE if we've seen AM_AUTOMAKE_VERSION.
|
---|
389 | my $seen_automake_version = 0;
|
---|
390 |
|
---|
391 | # Hash table of discovered configure substitutions. Keys are names,
|
---|
392 | # values are `FILE:LINE' strings which are used by error message
|
---|
393 | # generation.
|
---|
394 | my %configure_vars = ();
|
---|
395 |
|
---|
396 | # Ignored configure substitutions (i.e., variables not to be output in
|
---|
397 | # Makefile.in)
|
---|
398 | my %ignored_configure_vars = ();
|
---|
399 |
|
---|
400 | # Files included by $configure_ac.
|
---|
401 | my @configure_deps = ();
|
---|
402 |
|
---|
403 | # Greatest timestamp of configure's dependencies.
|
---|
404 | my $configure_deps_greatest_timestamp = 0;
|
---|
405 |
|
---|
406 | # Hash table of AM_CONDITIONAL variables seen in configure.
|
---|
407 | my %configure_cond = ();
|
---|
408 |
|
---|
409 | # This maps extensions onto language names.
|
---|
410 | my %extension_map = ();
|
---|
411 |
|
---|
412 | # List of the DIST_COMMON files we discovered while reading
|
---|
413 | # configure.in
|
---|
414 | my $configure_dist_common = '';
|
---|
415 |
|
---|
416 | # This maps languages names onto objects.
|
---|
417 | my %languages = ();
|
---|
418 | # Maps each linker variable onto a language object.
|
---|
419 | my %link_languages = ();
|
---|
420 |
|
---|
421 | # List of targets we must always output.
|
---|
422 | # FIXME: Complete, and remove falsely required targets.
|
---|
423 | my %required_targets =
|
---|
424 | (
|
---|
425 | 'all' => 1,
|
---|
426 | 'dvi' => 1,
|
---|
427 | 'pdf' => 1,
|
---|
428 | 'ps' => 1,
|
---|
429 | 'info' => 1,
|
---|
430 | 'install-info' => 1,
|
---|
431 | 'install' => 1,
|
---|
432 | 'install-data' => 1,
|
---|
433 | 'install-exec' => 1,
|
---|
434 | 'uninstall' => 1,
|
---|
435 |
|
---|
436 | # FIXME: Not required, temporary hacks.
|
---|
437 | # Well, actually they are sort of required: the -recursive
|
---|
438 | # targets will run them anyway...
|
---|
439 | 'dvi-am' => 1,
|
---|
440 | 'pdf-am' => 1,
|
---|
441 | 'ps-am' => 1,
|
---|
442 | 'info-am' => 1,
|
---|
443 | 'install-data-am' => 1,
|
---|
444 | 'install-exec-am' => 1,
|
---|
445 | 'installcheck-am' => 1,
|
---|
446 | 'uninstall-am' => 1,
|
---|
447 |
|
---|
448 | 'install-man' => 1,
|
---|
449 | );
|
---|
450 |
|
---|
451 | # Set to 1 if this run will create the Makefile.in that distribute
|
---|
452 | # the files in config_aux_dir.
|
---|
453 | my $automake_will_process_aux_dir = 0;
|
---|
454 |
|
---|
455 | # The name of the Makefile currently being processed.
|
---|
456 | my $am_file = 'BUG';
|
---|
457 | |
---|
458 |
|
---|
459 |
|
---|
460 | ################################################################
|
---|
461 |
|
---|
462 | ## ------------------------------------------ ##
|
---|
463 | ## Variables reset by &initialize_per_input. ##
|
---|
464 | ## ------------------------------------------ ##
|
---|
465 |
|
---|
466 | # Basename and relative dir of the input file.
|
---|
467 | my $am_file_name;
|
---|
468 | my $am_relative_dir;
|
---|
469 |
|
---|
470 | # Same but wrt Makefile.in.
|
---|
471 | my $in_file_name;
|
---|
472 | my $relative_dir;
|
---|
473 |
|
---|
474 | # Relative path to the top directory.
|
---|
475 | my $topsrcdir;
|
---|
476 |
|
---|
477 | # Greatest timestamp of the output's dependencies (excluding
|
---|
478 | # configure's dependencies).
|
---|
479 | my $output_deps_greatest_timestamp;
|
---|
480 |
|
---|
481 | # These two variables are used when generating each Makefile.in.
|
---|
482 | # They hold the Makefile.in until it is ready to be printed.
|
---|
483 | my $output_rules;
|
---|
484 | my $output_vars;
|
---|
485 | my $output_trailer;
|
---|
486 | my $output_all;
|
---|
487 | my $output_header;
|
---|
488 |
|
---|
489 | # This is the conditional stack, updated on if/else/endif, and
|
---|
490 | # used to build Condition objects.
|
---|
491 | my @cond_stack;
|
---|
492 |
|
---|
493 | # This holds the set of included files.
|
---|
494 | my @include_stack;
|
---|
495 |
|
---|
496 | # List of dependencies for the obvious targets.
|
---|
497 | my @all;
|
---|
498 | my @check;
|
---|
499 | my @check_tests;
|
---|
500 |
|
---|
501 | # Keys in this hash table are files to delete. The associated
|
---|
502 | # value tells when this should happen (MOSTLY_CLEAN, DIST_CLEAN, etc.)
|
---|
503 | my %clean_files;
|
---|
504 |
|
---|
505 | # Keys in this hash table are object files or other files in
|
---|
506 | # subdirectories which need to be removed. This only holds files
|
---|
507 | # which are created by compilations. The value in the hash indicates
|
---|
508 | # when the file should be removed.
|
---|
509 | my %compile_clean_files;
|
---|
510 |
|
---|
511 | # Keys in this hash table are directories where we expect to build a
|
---|
512 | # libtool object. We use this information to decide what directories
|
---|
513 | # to delete.
|
---|
514 | my %libtool_clean_directories;
|
---|
515 |
|
---|
516 | # Value of `$(SOURCES)', used by tags.am.
|
---|
517 | my @sources;
|
---|
518 | # Sources which go in the distribution.
|
---|
519 | my @dist_sources;
|
---|
520 |
|
---|
521 | # This hash maps object file names onto their corresponding source
|
---|
522 | # file names. This is used to ensure that each object is created
|
---|
523 | # by a single source file.
|
---|
524 | my %object_map;
|
---|
525 |
|
---|
526 | # This hash maps object file names onto an integer value representing
|
---|
527 | # whether this object has been built via ordinary compilation or
|
---|
528 | # libtool compilation (the COMPILE_* constants).
|
---|
529 | my %object_compilation_map;
|
---|
530 |
|
---|
531 |
|
---|
532 | # This keeps track of the directories for which we've already
|
---|
533 | # created dirstamp code. Keys are directories, values are stamp files.
|
---|
534 | # Several keys can share the same stamp files if they are equivalent
|
---|
535 | # (as are `.//foo' and `foo').
|
---|
536 | my %directory_map;
|
---|
537 |
|
---|
538 | # All .P files.
|
---|
539 | my %dep_files;
|
---|
540 |
|
---|
541 | # This is a list of all targets to run during "make dist".
|
---|
542 | my @dist_targets;
|
---|
543 |
|
---|
544 | # Keep track of all programs declared in this Makefile, without
|
---|
545 | # $(EXEEXT). @substitution@ are not listed.
|
---|
546 | my %known_programs;
|
---|
547 |
|
---|
548 | # Keys in this hash are the basenames of files which must depend on
|
---|
549 | # ansi2knr. Values are either the empty string, or the directory in
|
---|
550 | # which the ANSI source file appears; the directory must have a
|
---|
551 | # trailing `/'.
|
---|
552 | my %de_ansi_files;
|
---|
553 |
|
---|
554 | # This is the name of the redirect `all' target to use.
|
---|
555 | my $all_target;
|
---|
556 |
|
---|
557 | # This keeps track of which extensions we've seen (that we care
|
---|
558 | # about).
|
---|
559 | my %extension_seen;
|
---|
560 |
|
---|
561 | # This is random scratch space for the language finish functions.
|
---|
562 | # Don't randomly overwrite it; examine other uses of keys first.
|
---|
563 | my %language_scratch;
|
---|
564 |
|
---|
565 | # We keep track of which objects need special (per-executable)
|
---|
566 | # handling on a per-language basis.
|
---|
567 | my %lang_specific_files;
|
---|
568 |
|
---|
569 | # This is set when `handle_dist' has finished. Once this happens,
|
---|
570 | # we should no longer push on dist_common.
|
---|
571 | my $handle_dist_run;
|
---|
572 |
|
---|
573 | # Used to store a set of linkers needed to generate the sources currently
|
---|
574 | # under consideration.
|
---|
575 | my %linkers_used;
|
---|
576 |
|
---|
577 | # True if we need `LINK' defined. This is a hack.
|
---|
578 | my $need_link;
|
---|
579 |
|
---|
580 | # Was get_object_extension run?
|
---|
581 | # FIXME: This is a hack. a better switch should be found.
|
---|
582 | my $get_object_extension_was_run;
|
---|
583 |
|
---|
584 | # Record each file processed by make_paragraphs.
|
---|
585 | my %transformed_files;
|
---|
586 |
|
---|
587 | # Cache each file processed by make_paragraphs.
|
---|
588 | # (This is different from %transformed_files because
|
---|
589 | # %transformed_files is reset for each file while %am_file_cache
|
---|
590 | # it global to the run.)
|
---|
591 | my %am_file_cache;
|
---|
592 |
|
---|
593 | ################################################################
|
---|
594 |
|
---|
595 | # var_SUFFIXES_trigger ($TYPE, $VALUE)
|
---|
596 | # ------------------------------------
|
---|
597 | # This is called by Automake::Variable::define() when SUFFIXES
|
---|
598 | # is defined ($TYPE eq '') or appended ($TYPE eq '+').
|
---|
599 | # The work here needs to be performed as a side-effect of the
|
---|
600 | # macro_define() call because SUFFIXES definitions impact
|
---|
601 | # on $KNOWN_EXTENSIONS_PATTERN which is used used when parsing
|
---|
602 | # the input am file.
|
---|
603 | sub var_SUFFIXES_trigger ($$)
|
---|
604 | {
|
---|
605 | my ($type, $value) = @_;
|
---|
606 | accept_extensions (split (' ', $value));
|
---|
607 | }
|
---|
608 | Automake::Variable::hook ('SUFFIXES', \&var_SUFFIXES_trigger);
|
---|
609 |
|
---|
610 | ################################################################
|
---|
611 |
|
---|
612 | ## --------------------------------- ##
|
---|
613 | ## Forward subroutine declarations. ##
|
---|
614 | ## --------------------------------- ##
|
---|
615 | sub register_language (%);
|
---|
616 | sub file_contents_internal ($$$%);
|
---|
617 | sub define_files_variable ($\@$$);
|
---|
618 |
|
---|
619 |
|
---|
620 | # &initialize_per_input ()
|
---|
621 | # ------------------------
|
---|
622 | # (Re)-Initialize per-Makefile.am variables.
|
---|
623 | sub initialize_per_input ()
|
---|
624 | {
|
---|
625 | reset_local_duplicates ();
|
---|
626 |
|
---|
627 | $am_file_name = '';
|
---|
628 | $am_relative_dir = '';
|
---|
629 |
|
---|
630 | $in_file_name = '';
|
---|
631 | $relative_dir = '';
|
---|
632 |
|
---|
633 | $output_deps_greatest_timestamp = 0;
|
---|
634 |
|
---|
635 | $output_rules = '';
|
---|
636 | $output_vars = '';
|
---|
637 | $output_trailer = '';
|
---|
638 | $output_all = '';
|
---|
639 | $output_header = '';
|
---|
640 |
|
---|
641 | Automake::Options::reset;
|
---|
642 | Automake::Variable::reset;
|
---|
643 | Automake::Rule::reset;
|
---|
644 |
|
---|
645 | @cond_stack = ();
|
---|
646 |
|
---|
647 | @include_stack = ();
|
---|
648 |
|
---|
649 | @all = ();
|
---|
650 | @check = ();
|
---|
651 | @check_tests = ();
|
---|
652 |
|
---|
653 | %clean_files = ();
|
---|
654 |
|
---|
655 | @sources = ();
|
---|
656 | @dist_sources = ();
|
---|
657 |
|
---|
658 | %object_map = ();
|
---|
659 | %object_compilation_map = ();
|
---|
660 |
|
---|
661 | %directory_map = ();
|
---|
662 |
|
---|
663 | %dep_files = ();
|
---|
664 |
|
---|
665 | @dist_targets = ();
|
---|
666 |
|
---|
667 | %known_programs = ();
|
---|
668 |
|
---|
669 | %de_ansi_files = ();
|
---|
670 |
|
---|
671 | $all_target = '';
|
---|
672 |
|
---|
673 | %extension_seen = ();
|
---|
674 |
|
---|
675 | %language_scratch = ();
|
---|
676 |
|
---|
677 | %lang_specific_files = ();
|
---|
678 |
|
---|
679 | $handle_dist_run = 0;
|
---|
680 |
|
---|
681 | $need_link = 0;
|
---|
682 |
|
---|
683 | $get_object_extension_was_run = 0;
|
---|
684 |
|
---|
685 | %compile_clean_files = ();
|
---|
686 |
|
---|
687 | # We always include `.'. This isn't strictly correct.
|
---|
688 | %libtool_clean_directories = ('.' => 1);
|
---|
689 |
|
---|
690 | %transformed_files = ();
|
---|
691 | }
|
---|
692 |
|
---|
693 |
|
---|
694 | ################################################################
|
---|
695 |
|
---|
696 | # Initialize our list of languages that are internally supported.
|
---|
697 |
|
---|
698 | # C.
|
---|
699 | register_language ('name' => 'c',
|
---|
700 | 'Name' => 'C',
|
---|
701 | 'config_vars' => ['CC'],
|
---|
702 | 'ansi' => 1,
|
---|
703 | 'autodep' => '',
|
---|
704 | 'flags' => ['CFLAGS', 'CPPFLAGS'],
|
---|
705 | 'compiler' => 'COMPILE',
|
---|
706 | 'compile' => '$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)',
|
---|
707 | 'lder' => 'CCLD',
|
---|
708 | 'ld' => '$(CC)',
|
---|
709 | 'linker' => 'LINK',
|
---|
710 | 'link' => '$(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
|
---|
711 | 'compile_flag' => '-c',
|
---|
712 | 'libtool_tag' => 'CC',
|
---|
713 | 'extensions' => ['.c'],
|
---|
714 | '_finish' => \&lang_c_finish);
|
---|
715 |
|
---|
716 | # C++.
|
---|
717 | register_language ('name' => 'cxx',
|
---|
718 | 'Name' => 'C++',
|
---|
719 | 'config_vars' => ['CXX'],
|
---|
720 | 'linker' => 'CXXLINK',
|
---|
721 | 'link' => '$(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
|
---|
722 | 'autodep' => 'CXX',
|
---|
723 | 'flags' => ['CXXFLAGS', 'CPPFLAGS'],
|
---|
724 | 'compile' => '$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)',
|
---|
725 | 'compiler' => 'CXXCOMPILE',
|
---|
726 | 'compile_flag' => '-c',
|
---|
727 | 'output_flag' => '-o',
|
---|
728 | 'libtool_tag' => 'CXX',
|
---|
729 | 'lder' => 'CXXLD',
|
---|
730 | 'ld' => '$(CXX)',
|
---|
731 | 'pure' => 1,
|
---|
732 | 'extensions' => ['.c++', '.cc', '.cpp', '.cxx', '.C']);
|
---|
733 |
|
---|
734 | # Objective C.
|
---|
735 | register_language ('name' => 'objc',
|
---|
736 | 'Name' => 'Objective C',
|
---|
737 | 'config_vars' => ['OBJC'],
|
---|
738 | 'linker' => 'OBJCLINK',
|
---|
739 | 'link' => '$(OBJCLD) $(AM_OBJCFLAGS) $(OBJCFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
|
---|
740 | 'autodep' => 'OBJC',
|
---|
741 | 'flags' => ['OBJCFLAGS', 'CPPFLAGS'],
|
---|
742 | 'compile' => '$(OBJC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_OBJCFLAGS) $(OBJCFLAGS)',
|
---|
743 | 'compiler' => 'OBJCCOMPILE',
|
---|
744 | 'compile_flag' => '-c',
|
---|
745 | 'output_flag' => '-o',
|
---|
746 | 'lder' => 'OBJCLD',
|
---|
747 | 'ld' => '$(OBJC)',
|
---|
748 | 'pure' => 1,
|
---|
749 | 'extensions' => ['.m']);
|
---|
750 |
|
---|
751 | # Unified Parallel C.
|
---|
752 | register_language ('name' => 'upc',
|
---|
753 | 'Name' => 'Unified Parallel C',
|
---|
754 | 'config_vars' => ['UPC'],
|
---|
755 | 'linker' => 'UPCLINK',
|
---|
756 | 'link' => '$(UPCLD) $(AM_UPCFLAGS) $(UPCFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
|
---|
757 | 'autodep' => 'UPC',
|
---|
758 | 'flags' => ['UPCFLAGS', 'CPPFLAGS'],
|
---|
759 | 'compile' => '$(UPC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_UPCFLAGS) $(UPCFLAGS)',
|
---|
760 | 'compiler' => 'UPCCOMPILE',
|
---|
761 | 'compile_flag' => '-c',
|
---|
762 | 'output_flag' => '-o',
|
---|
763 | 'lder' => 'UPCLD',
|
---|
764 | 'ld' => '$(UPC)',
|
---|
765 | 'pure' => 1,
|
---|
766 | 'extensions' => ['.upc']);
|
---|
767 |
|
---|
768 | # Headers.
|
---|
769 | register_language ('name' => 'header',
|
---|
770 | 'Name' => 'Header',
|
---|
771 | 'extensions' => ['.h', '.H', '.hxx', '.h++', '.hh',
|
---|
772 | '.hpp', '.inc'],
|
---|
773 | # No output.
|
---|
774 | 'output_extensions' => sub { return () },
|
---|
775 | # Nothing to do.
|
---|
776 | '_finish' => sub { });
|
---|
777 |
|
---|
778 | # Yacc (C & C++).
|
---|
779 | register_language ('name' => 'yacc',
|
---|
780 | 'Name' => 'Yacc',
|
---|
781 | 'config_vars' => ['YACC'],
|
---|
782 | 'flags' => ['YFLAGS'],
|
---|
783 | 'compile' => '$(YACC) $(YFLAGS) $(AM_YFLAGS)',
|
---|
784 | 'compiler' => 'YACCCOMPILE',
|
---|
785 | 'extensions' => ['.y'],
|
---|
786 | 'output_extensions' => sub { (my $ext = $_[0]) =~ tr/y/c/;
|
---|
787 | return ($ext,) },
|
---|
788 | 'rule_file' => 'yacc',
|
---|
789 | '_finish' => \&lang_yacc_finish,
|
---|
790 | '_target_hook' => \&lang_yacc_target_hook,
|
---|
791 | 'nodist_specific' => 1);
|
---|
792 | register_language ('name' => 'yaccxx',
|
---|
793 | 'Name' => 'Yacc (C++)',
|
---|
794 | 'config_vars' => ['YACC'],
|
---|
795 | 'rule_file' => 'yacc',
|
---|
796 | 'flags' => ['YFLAGS'],
|
---|
797 | 'compiler' => 'YACCCOMPILE',
|
---|
798 | 'compile' => '$(YACC) $(YFLAGS) $(AM_YFLAGS)',
|
---|
799 | 'extensions' => ['.y++', '.yy', '.yxx', '.ypp'],
|
---|
800 | 'output_extensions' => sub { (my $ext = $_[0]) =~ tr/y/c/;
|
---|
801 | return ($ext,) },
|
---|
802 | '_finish' => \&lang_yacc_finish,
|
---|
803 | '_target_hook' => \&lang_yacc_target_hook,
|
---|
804 | 'nodist_specific' => 1);
|
---|
805 |
|
---|
806 | # Lex (C & C++).
|
---|
807 | register_language ('name' => 'lex',
|
---|
808 | 'Name' => 'Lex',
|
---|
809 | 'config_vars' => ['LEX'],
|
---|
810 | 'rule_file' => 'lex',
|
---|
811 | 'flags' => ['LFLAGS'],
|
---|
812 | 'compile' => '$(LEX) $(LFLAGS) $(AM_LFLAGS)',
|
---|
813 | 'compiler' => 'LEXCOMPILE',
|
---|
814 | 'extensions' => ['.l'],
|
---|
815 | 'output_extensions' => sub { (my $ext = $_[0]) =~ tr/l/c/;
|
---|
816 | return ($ext,) },
|
---|
817 | '_finish' => \&lang_lex_finish,
|
---|
818 | '_target_hook' => \&lang_lex_target_hook,
|
---|
819 | 'nodist_specific' => 1);
|
---|
820 | register_language ('name' => 'lexxx',
|
---|
821 | 'Name' => 'Lex (C++)',
|
---|
822 | 'config_vars' => ['LEX'],
|
---|
823 | 'rule_file' => 'lex',
|
---|
824 | 'flags' => ['LFLAGS'],
|
---|
825 | 'compile' => '$(LEX) $(LFLAGS) $(AM_LFLAGS)',
|
---|
826 | 'compiler' => 'LEXCOMPILE',
|
---|
827 | 'extensions' => ['.l++', '.ll', '.lxx', '.lpp'],
|
---|
828 | 'output_extensions' => sub { (my $ext = $_[0]) =~ tr/l/c/;
|
---|
829 | return ($ext,) },
|
---|
830 | '_finish' => \&lang_lex_finish,
|
---|
831 | '_target_hook' => \&lang_lex_target_hook,
|
---|
832 | 'nodist_specific' => 1);
|
---|
833 |
|
---|
834 | # Assembler.
|
---|
835 | register_language ('name' => 'asm',
|
---|
836 | 'Name' => 'Assembler',
|
---|
837 | 'config_vars' => ['CCAS', 'CCASFLAGS'],
|
---|
838 |
|
---|
839 | 'flags' => ['CCASFLAGS'],
|
---|
840 | # Users can set AM_CCASFLAGS to include DEFS, INCLUDES,
|
---|
841 | # or anything else required. They can also set CCAS.
|
---|
842 | # Or simply use Preprocessed Assembler.
|
---|
843 | 'compile' => '$(CCAS) $(AM_CCASFLAGS) $(CCASFLAGS)',
|
---|
844 | 'compiler' => 'CCASCOMPILE',
|
---|
845 | 'compile_flag' => '-c',
|
---|
846 | 'output_flag' => '-o',
|
---|
847 | 'extensions' => ['.s'],
|
---|
848 |
|
---|
849 | # With assembly we still use the C linker.
|
---|
850 | '_finish' => \&lang_c_finish);
|
---|
851 |
|
---|
852 | # Preprocessed Assembler.
|
---|
853 | register_language ('name' => 'cppasm',
|
---|
854 | 'Name' => 'Preprocessed Assembler',
|
---|
855 | 'config_vars' => ['CCAS', 'CCASFLAGS'],
|
---|
856 |
|
---|
857 | 'autodep' => 'CCAS',
|
---|
858 | 'flags' => ['CCASFLAGS', 'CPPFLAGS'],
|
---|
859 | 'compile' => '$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CCASFLAGS) $(CCASFLAGS)',
|
---|
860 | 'compiler' => 'CPPASCOMPILE',
|
---|
861 | 'compile_flag' => '-c',
|
---|
862 | 'output_flag' => '-o',
|
---|
863 | 'extensions' => ['.S'],
|
---|
864 |
|
---|
865 | # With assembly we still use the C linker.
|
---|
866 | '_finish' => \&lang_c_finish);
|
---|
867 |
|
---|
868 | # Fortran 77
|
---|
869 | register_language ('name' => 'f77',
|
---|
870 | 'Name' => 'Fortran 77',
|
---|
871 | 'config_vars' => ['F77'],
|
---|
872 | 'linker' => 'F77LINK',
|
---|
873 | 'link' => '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
|
---|
874 | 'flags' => ['FFLAGS'],
|
---|
875 | 'compile' => '$(F77) $(AM_FFLAGS) $(FFLAGS)',
|
---|
876 | 'compiler' => 'F77COMPILE',
|
---|
877 | 'compile_flag' => '-c',
|
---|
878 | 'output_flag' => '-o',
|
---|
879 | 'libtool_tag' => 'F77',
|
---|
880 | 'lder' => 'F77LD',
|
---|
881 | 'ld' => '$(F77)',
|
---|
882 | 'pure' => 1,
|
---|
883 | 'extensions' => ['.f', '.for']);
|
---|
884 |
|
---|
885 | # Fortran
|
---|
886 | register_language ('name' => 'fc',
|
---|
887 | 'Name' => 'Fortran',
|
---|
888 | 'config_vars' => ['FC'],
|
---|
889 | 'linker' => 'FCLINK',
|
---|
890 | 'link' => '$(FCLD) $(AM_FCFLAGS) $(FCFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
|
---|
891 | 'flags' => ['FCFLAGS'],
|
---|
892 | 'compile' => '$(FC) $(AM_FCFLAGS) $(FCFLAGS)',
|
---|
893 | 'compiler' => 'FCCOMPILE',
|
---|
894 | 'compile_flag' => '-c',
|
---|
895 | 'output_flag' => '-o',
|
---|
896 | 'lder' => 'FCLD',
|
---|
897 | 'ld' => '$(FC)',
|
---|
898 | 'pure' => 1,
|
---|
899 | 'extensions' => ['.f90', '.f95']);
|
---|
900 |
|
---|
901 | # Preprocessed Fortran
|
---|
902 | register_language ('name' => 'ppfc',
|
---|
903 | 'Name' => 'Preprocessed Fortran',
|
---|
904 | 'config_vars' => ['FC'],
|
---|
905 | 'linker' => 'FCLINK',
|
---|
906 | 'link' => '$(FCLD) $(AM_FCFLAGS) $(FCFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
|
---|
907 | 'lder' => 'FCLD',
|
---|
908 | 'ld' => '$(FC)',
|
---|
909 | 'flags' => ['FCFLAGS', 'CPPFLAGS'],
|
---|
910 | 'compiler' => 'PPFCCOMPILE',
|
---|
911 | 'compile' => '$(FC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FCFLAGS) $(FCFLAGS)',
|
---|
912 | 'compile_flag' => '-c',
|
---|
913 | 'output_flag' => '-o',
|
---|
914 | 'libtool_tag' => 'FC',
|
---|
915 | 'pure' => 1,
|
---|
916 | 'extensions' => ['.F90','.F95']);
|
---|
917 |
|
---|
918 | # Preprocessed Fortran 77
|
---|
919 | #
|
---|
920 | # The current support for preprocessing Fortran 77 just involves
|
---|
921 | # passing `$(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS)
|
---|
922 | # $(CPPFLAGS)' as additional flags to the Fortran 77 compiler, since
|
---|
923 | # this is how GNU Make does it; see the `GNU Make Manual, Edition 0.51
|
---|
924 | # for `make' Version 3.76 Beta' (specifically, from info file
|
---|
925 | # `(make)Catalogue of Rules').
|
---|
926 | #
|
---|
927 | # A better approach would be to write an Autoconf test
|
---|
928 | # (i.e. AC_PROG_FPP) for a Fortran 77 preprocessor, because not all
|
---|
929 | # Fortran 77 compilers know how to do preprocessing. The Autoconf
|
---|
930 | # macro AC_PROG_FPP should test the Fortran 77 compiler first for
|
---|
931 | # preprocessing capabilities, and then fall back on cpp (if cpp were
|
---|
932 | # available).
|
---|
933 | register_language ('name' => 'ppf77',
|
---|
934 | 'Name' => 'Preprocessed Fortran 77',
|
---|
935 | 'config_vars' => ['F77'],
|
---|
936 | 'linker' => 'F77LINK',
|
---|
937 | 'link' => '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
|
---|
938 | 'lder' => 'F77LD',
|
---|
939 | 'ld' => '$(F77)',
|
---|
940 | 'flags' => ['FFLAGS', 'CPPFLAGS'],
|
---|
941 | 'compiler' => 'PPF77COMPILE',
|
---|
942 | 'compile' => '$(F77) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FFLAGS) $(FFLAGS)',
|
---|
943 | 'compile_flag' => '-c',
|
---|
944 | 'output_flag' => '-o',
|
---|
945 | 'libtool_tag' => 'F77',
|
---|
946 | 'pure' => 1,
|
---|
947 | 'extensions' => ['.F']);
|
---|
948 |
|
---|
949 | # Ratfor.
|
---|
950 | register_language ('name' => 'ratfor',
|
---|
951 | 'Name' => 'Ratfor',
|
---|
952 | 'config_vars' => ['F77'],
|
---|
953 | 'linker' => 'F77LINK',
|
---|
954 | 'link' => '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
|
---|
955 | 'lder' => 'F77LD',
|
---|
956 | 'ld' => '$(F77)',
|
---|
957 | 'flags' => ['RFLAGS', 'FFLAGS'],
|
---|
958 | # FIXME also FFLAGS.
|
---|
959 | 'compile' => '$(F77) $(AM_FFLAGS) $(FFLAGS) $(AM_RFLAGS) $(RFLAGS)',
|
---|
960 | 'compiler' => 'RCOMPILE',
|
---|
961 | 'compile_flag' => '-c',
|
---|
962 | 'output_flag' => '-o',
|
---|
963 | 'libtool_tag' => 'F77',
|
---|
964 | 'pure' => 1,
|
---|
965 | 'extensions' => ['.r']);
|
---|
966 |
|
---|
967 | # Java via gcj.
|
---|
968 | register_language ('name' => 'java',
|
---|
969 | 'Name' => 'Java',
|
---|
970 | 'config_vars' => ['GCJ'],
|
---|
971 | 'linker' => 'GCJLINK',
|
---|
972 | 'link' => '$(GCJLD) $(AM_GCJFLAGS) $(GCJFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
|
---|
973 | 'autodep' => 'GCJ',
|
---|
974 | 'flags' => ['GCJFLAGS'],
|
---|
975 | 'compile' => '$(GCJ) $(AM_GCJFLAGS) $(GCJFLAGS)',
|
---|
976 | 'compiler' => 'GCJCOMPILE',
|
---|
977 | 'compile_flag' => '-c',
|
---|
978 | 'output_flag' => '-o',
|
---|
979 | 'libtool_tag' => 'GCJ',
|
---|
980 | 'lder' => 'GCJLD',
|
---|
981 | 'ld' => '$(GCJ)',
|
---|
982 | 'pure' => 1,
|
---|
983 | 'extensions' => ['.java', '.class', '.zip', '.jar']);
|
---|
984 |
|
---|
985 | ################################################################
|
---|
986 |
|
---|
987 | # Error reporting functions.
|
---|
988 |
|
---|
989 | # err_am ($MESSAGE, [%OPTIONS])
|
---|
990 | # -----------------------------
|
---|
991 | # Uncategorized errors about the current Makefile.am.
|
---|
992 | sub err_am ($;%)
|
---|
993 | {
|
---|
994 | msg_am ('error', @_);
|
---|
995 | }
|
---|
996 |
|
---|
997 | # err_ac ($MESSAGE, [%OPTIONS])
|
---|
998 | # -----------------------------
|
---|
999 | # Uncategorized errors about configure.ac.
|
---|
1000 | sub err_ac ($;%)
|
---|
1001 | {
|
---|
1002 | msg_ac ('error', @_);
|
---|
1003 | }
|
---|
1004 |
|
---|
1005 | # msg_am ($CHANNEL, $MESSAGE, [%OPTIONS])
|
---|
1006 | # ---------------------------------------
|
---|
1007 | # Messages about about the current Makefile.am.
|
---|
1008 | sub msg_am ($$;%)
|
---|
1009 | {
|
---|
1010 | my ($channel, $msg, %opts) = @_;
|
---|
1011 | msg $channel, "${am_file}.am", $msg, %opts;
|
---|
1012 | }
|
---|
1013 |
|
---|
1014 | # msg_ac ($CHANNEL, $MESSAGE, [%OPTIONS])
|
---|
1015 | # ---------------------------------------
|
---|
1016 | # Messages about about configure.ac.
|
---|
1017 | sub msg_ac ($$;%)
|
---|
1018 | {
|
---|
1019 | my ($channel, $msg, %opts) = @_;
|
---|
1020 | msg $channel, $configure_ac, $msg, %opts;
|
---|
1021 | }
|
---|
1022 |
|
---|
1023 | ################################################################
|
---|
1024 |
|
---|
1025 | # subst ($TEXT)
|
---|
1026 | # -------------
|
---|
1027 | # Return a configure-style substitution using the indicated text.
|
---|
1028 | # We do this to avoid having the substitutions directly in automake.in;
|
---|
1029 | # when we do that they are sometimes removed and this causes confusion
|
---|
1030 | # and bugs.
|
---|
1031 | sub subst ($)
|
---|
1032 | {
|
---|
1033 | my ($text) = @_;
|
---|
1034 | return '@' . $text . '@';
|
---|
1035 | }
|
---|
1036 |
|
---|
1037 | ################################################################
|
---|
1038 |
|
---|
1039 |
|
---|
1040 | # $BACKPATH
|
---|
1041 | # &backname ($REL-DIR)
|
---|
1042 | # --------------------
|
---|
1043 | # If I `cd $REL-DIR', then to come back, I should `cd $BACKPATH'.
|
---|
1044 | # For instance `src/foo' => `../..'.
|
---|
1045 | # Works with non strictly increasing paths, i.e., `src/../lib' => `..'.
|
---|
1046 | sub backname ($)
|
---|
1047 | {
|
---|
1048 | my ($file) = @_;
|
---|
1049 | my @res;
|
---|
1050 | foreach (split (/\//, $file))
|
---|
1051 | {
|
---|
1052 | next if $_ eq '.' || $_ eq '';
|
---|
1053 | if ($_ eq '..')
|
---|
1054 | {
|
---|
1055 | pop @res;
|
---|
1056 | }
|
---|
1057 | else
|
---|
1058 | {
|
---|
1059 | push (@res, '..');
|
---|
1060 | }
|
---|
1061 | }
|
---|
1062 | return join ('/', @res) || '.';
|
---|
1063 | }
|
---|
1064 |
|
---|
1065 | ################################################################
|
---|
1066 |
|
---|
1067 |
|
---|
1068 | # Handle AUTOMAKE_OPTIONS variable. Return 1 on error, 0 otherwise.
|
---|
1069 | sub handle_options
|
---|
1070 | {
|
---|
1071 | my $var = var ('AUTOMAKE_OPTIONS');
|
---|
1072 | if ($var)
|
---|
1073 | {
|
---|
1074 | if ($var->has_conditional_contents)
|
---|
1075 | {
|
---|
1076 | msg_var ('unsupported', $var,
|
---|
1077 | "`AUTOMAKE_OPTIONS' cannot have conditional contents");
|
---|
1078 | }
|
---|
1079 | foreach my $locvals ($var->value_as_list_recursive (cond_filter => TRUE,
|
---|
1080 | location => 1))
|
---|
1081 | {
|
---|
1082 | my ($loc, $value) = @$locvals;
|
---|
1083 | return 1 if (process_option_list ($loc, $value))
|
---|
1084 | }
|
---|
1085 | }
|
---|
1086 |
|
---|
1087 | if ($strictness == GNITS)
|
---|
1088 | {
|
---|
1089 | set_option ('readme-alpha', INTERNAL);
|
---|
1090 | set_option ('std-options', INTERNAL);
|
---|
1091 | set_option ('check-news', INTERNAL);
|
---|
1092 | }
|
---|
1093 |
|
---|
1094 | return 0;
|
---|
1095 | }
|
---|
1096 |
|
---|
1097 | # shadow_unconditionally ($varname, $where)
|
---|
1098 | # -----------------------------------------
|
---|
1099 | # Return a $(variable) that contains all possible values
|
---|
1100 | # $varname can take.
|
---|
1101 | # If the VAR wasn't defined conditionally, return $(VAR).
|
---|
1102 | # Otherwise we create a am__VAR_DIST variable which contains
|
---|
1103 | # all possible values, and return $(am__VAR_DIST).
|
---|
1104 | sub shadow_unconditionally ($$)
|
---|
1105 | {
|
---|
1106 | my ($varname, $where) = @_;
|
---|
1107 | my $var = var $varname;
|
---|
1108 | if ($var->has_conditional_contents)
|
---|
1109 | {
|
---|
1110 | $varname = "am__${varname}_DIST";
|
---|
1111 | my @files = uniq ($var->value_as_list_recursive);
|
---|
1112 | define_pretty_variable ($varname, TRUE, $where, @files);
|
---|
1113 | }
|
---|
1114 | return "\$($varname)"
|
---|
1115 | }
|
---|
1116 |
|
---|
1117 | # get_object_extension ($EXTENSION)
|
---|
1118 | # ---------------------------------
|
---|
1119 | # Prefix $EXTENSION with $U if ansi2knr is in use.
|
---|
1120 | sub get_object_extension ($)
|
---|
1121 | {
|
---|
1122 | my ($extension) = @_;
|
---|
1123 |
|
---|
1124 | # Check for automatic de-ANSI-fication.
|
---|
1125 | $extension = '$U' . $extension
|
---|
1126 | if option 'ansi2knr';
|
---|
1127 |
|
---|
1128 | $get_object_extension_was_run = 1;
|
---|
1129 |
|
---|
1130 | return $extension;
|
---|
1131 | }
|
---|
1132 |
|
---|
1133 | # check_user_variables (@LIST)
|
---|
1134 | # ----------------------------
|
---|
1135 | # Make sure each variable VAR in @LIST does not exist, suggest using AM_VAR
|
---|
1136 | # otherwise.
|
---|
1137 | sub check_user_variables (@)
|
---|
1138 | {
|
---|
1139 | my @dont_override = @_;
|
---|
1140 | foreach my $flag (@dont_override)
|
---|
1141 | {
|
---|
1142 | my $var = var $flag;
|
---|
1143 | if ($var)
|
---|
1144 | {
|
---|
1145 | for my $cond ($var->conditions->conds)
|
---|
1146 | {
|
---|
1147 | if ($var->rdef ($cond)->owner == VAR_MAKEFILE)
|
---|
1148 | {
|
---|
1149 | msg_cond_var ('gnu', $cond, $flag,
|
---|
1150 | "`$flag' is a user variable, "
|
---|
1151 | . "you should not override it;\n"
|
---|
1152 | . "use `AM_$flag' instead.");
|
---|
1153 | }
|
---|
1154 | }
|
---|
1155 | }
|
---|
1156 | }
|
---|
1157 | }
|
---|
1158 |
|
---|
1159 | # Call finish function for each language that was used.
|
---|
1160 | sub handle_languages
|
---|
1161 | {
|
---|
1162 | if (! option 'no-dependencies')
|
---|
1163 | {
|
---|
1164 | # Include auto-dep code. Don't include it if DEP_FILES would
|
---|
1165 | # be empty.
|
---|
1166 | if (&saw_sources_p (0) && keys %dep_files)
|
---|
1167 | {
|
---|
1168 | # Set location of depcomp.
|
---|
1169 | &define_variable ('depcomp',
|
---|
1170 | "\$(SHELL) $am_config_aux_dir/depcomp",
|
---|
1171 | INTERNAL);
|
---|
1172 | &define_variable ('am__depfiles_maybe', 'depfiles', INTERNAL);
|
---|
1173 |
|
---|
1174 | require_conf_file ("$am_file.am", FOREIGN, 'depcomp');
|
---|
1175 |
|
---|
1176 | my @deplist = sort keys %dep_files;
|
---|
1177 | # Generate each `include' individually. Irix 6 make will
|
---|
1178 | # not properly include several files resulting from a
|
---|
1179 | # variable expansion; generating many separate includes
|
---|
1180 | # seems safest.
|
---|
1181 | $output_rules .= "\n";
|
---|
1182 | foreach my $iter (@deplist)
|
---|
1183 | {
|
---|
1184 | $output_rules .= (subst ('AMDEP_TRUE')
|
---|
1185 | . subst ('am__include')
|
---|
1186 | . ' '
|
---|
1187 | . subst ('am__quote')
|
---|
1188 | . $iter
|
---|
1189 | . subst ('am__quote')
|
---|
1190 | . "\n");
|
---|
1191 | }
|
---|
1192 |
|
---|
1193 | # Compute the set of directories to remove in distclean-depend.
|
---|
1194 | my @depdirs = uniq (map { dirname ($_) } @deplist);
|
---|
1195 | $output_rules .= &file_contents ('depend',
|
---|
1196 | new Automake::Location,
|
---|
1197 | DEPDIRS => "@depdirs");
|
---|
1198 | }
|
---|
1199 | }
|
---|
1200 | else
|
---|
1201 | {
|
---|
1202 | &define_variable ('depcomp', '', INTERNAL);
|
---|
1203 | &define_variable ('am__depfiles_maybe', '', INTERNAL);
|
---|
1204 | }
|
---|
1205 |
|
---|
1206 | my %done;
|
---|
1207 |
|
---|
1208 | # Is the c linker needed?
|
---|
1209 | my $needs_c = 0;
|
---|
1210 | foreach my $ext (sort keys %extension_seen)
|
---|
1211 | {
|
---|
1212 | next unless $extension_map{$ext};
|
---|
1213 |
|
---|
1214 | my $lang = $languages{$extension_map{$ext}};
|
---|
1215 |
|
---|
1216 | my $rule_file = $lang->rule_file || 'depend2';
|
---|
1217 |
|
---|
1218 | # Get information on $LANG.
|
---|
1219 | my $pfx = $lang->autodep;
|
---|
1220 | my $fpfx = ($pfx eq '') ? 'CC' : $pfx;
|
---|
1221 |
|
---|
1222 | my ($AMDEP, $FASTDEP) =
|
---|
1223 | (option 'no-dependencies' || $lang->autodep eq 'no')
|
---|
1224 | ? ('FALSE', 'FALSE') : ('AMDEP', "am__fastdep$fpfx");
|
---|
1225 |
|
---|
1226 | my %transform = ('EXT' => $ext,
|
---|
1227 | 'PFX' => $pfx,
|
---|
1228 | 'FPFX' => $fpfx,
|
---|
1229 | 'AMDEP' => $AMDEP,
|
---|
1230 | 'FASTDEP' => $FASTDEP,
|
---|
1231 | '-c' => $lang->compile_flag || '',
|
---|
1232 | # These are not used, but they need to be defined
|
---|
1233 | # so &transform do not complain.
|
---|
1234 | SUBDIROBJ => 0,
|
---|
1235 | 'DERIVED-EXT' => 'BUG',
|
---|
1236 | DIST_SOURCE => 1,
|
---|
1237 | );
|
---|
1238 |
|
---|
1239 | # Generate the appropriate rules for this extension.
|
---|
1240 | if (((! option 'no-dependencies') && $lang->autodep ne 'no')
|
---|
1241 | || defined $lang->compile)
|
---|
1242 | {
|
---|
1243 | # Some C compilers don't support -c -o. Use it only if really
|
---|
1244 | # needed.
|
---|
1245 | my $output_flag = $lang->output_flag || '';
|
---|
1246 | $output_flag = '-o'
|
---|
1247 | if (! $output_flag
|
---|
1248 | && $lang->name eq 'c'
|
---|
1249 | && option 'subdir-objects');
|
---|
1250 |
|
---|
1251 | # Compute a possible derived extension.
|
---|
1252 | # This is not used by depend2.am.
|
---|
1253 | my $der_ext = (&{$lang->output_extensions} ($ext))[0];
|
---|
1254 |
|
---|
1255 | # When we output an inference rule like `.c.o:' we
|
---|
1256 | # have two cases to consider: either subdir-objects
|
---|
1257 | # is used, or it is not.
|
---|
1258 | #
|
---|
1259 | # In the latter case the rule is used to build objects
|
---|
1260 | # in the current directory, and dependencies always
|
---|
1261 | # go into `./$(DEPDIR)/'. We can hard-code this value.
|
---|
1262 | #
|
---|
1263 | # In the former case the rule can be used to build
|
---|
1264 | # objects in sub-directories too. Dependencies should
|
---|
1265 | # go into the appropriate sub-directories, e.g.,
|
---|
1266 | # `sub/$(DEPDIR)/'. The value of this directory
|
---|
1267 | # needs to be computed on-the-fly.
|
---|
1268 | #
|
---|
1269 | # DEPBASE holds the name of this directory, plus the
|
---|
1270 | # basename part of the object file (extensions Po, TPo,
|
---|
1271 | # Plo, TPlo will be added later as appropriate). It is
|
---|
1272 | # either hardcoded, or a shell variable (`$depbase') that
|
---|
1273 | # will be computed by the rule.
|
---|
1274 | my $depbase =
|
---|
1275 | option ('subdir-objects') ? '$$depbase' : '$(DEPDIR)/$*';
|
---|
1276 | $output_rules .=
|
---|
1277 | file_contents ($rule_file,
|
---|
1278 | new Automake::Location,
|
---|
1279 | %transform,
|
---|
1280 | GENERIC => 1,
|
---|
1281 |
|
---|
1282 | 'DERIVED-EXT' => $der_ext,
|
---|
1283 |
|
---|
1284 | DEPBASE => $depbase,
|
---|
1285 | BASE => '$*',
|
---|
1286 | SOURCE => '$<',
|
---|
1287 | OBJ => '$@',
|
---|
1288 | OBJOBJ => '$@',
|
---|
1289 | LTOBJ => '$@',
|
---|
1290 |
|
---|
1291 | COMPILE => '$(' . $lang->compiler . ')',
|
---|
1292 | LTCOMPILE => '$(LT' . $lang->compiler . ')',
|
---|
1293 | -o => $output_flag,
|
---|
1294 | SUBDIROBJ => !! option 'subdir-objects');
|
---|
1295 | }
|
---|
1296 |
|
---|
1297 | # Now include code for each specially handled object with this
|
---|
1298 | # language.
|
---|
1299 | my %seen_files = ();
|
---|
1300 | foreach my $file (@{$lang_specific_files{$lang->name}})
|
---|
1301 | {
|
---|
1302 | my ($derived, $source, $obj, $myext, %file_transform) = @$file;
|
---|
1303 |
|
---|
1304 | # We might see a given object twice, for instance if it is
|
---|
1305 | # used under different conditions.
|
---|
1306 | next if defined $seen_files{$obj};
|
---|
1307 | $seen_files{$obj} = 1;
|
---|
1308 |
|
---|
1309 | prog_error ("found " . $lang->name .
|
---|
1310 | " in handle_languages, but compiler not defined")
|
---|
1311 | unless defined $lang->compile;
|
---|
1312 |
|
---|
1313 | my $obj_compile = $lang->compile;
|
---|
1314 |
|
---|
1315 | # Rewrite each occurrence of `AM_$flag' in the compile
|
---|
1316 | # rule into `${derived}_$flag' if it exists.
|
---|
1317 | for my $flag (@{$lang->flags})
|
---|
1318 | {
|
---|
1319 | my $val = "${derived}_$flag";
|
---|
1320 | $obj_compile =~ s/\(AM_$flag\)/\($val\)/
|
---|
1321 | if set_seen ($val);
|
---|
1322 | }
|
---|
1323 |
|
---|
1324 | my $libtool_tag = '';
|
---|
1325 | if ($lang->libtool_tag && exists $libtool_tags{$lang->libtool_tag})
|
---|
1326 | {
|
---|
1327 | $libtool_tag = '--tag=' . $lang->libtool_tag . ' '
|
---|
1328 | }
|
---|
1329 |
|
---|
1330 | my $ptltflags = "${derived}_LIBTOOLFLAGS";
|
---|
1331 | $ptltflags = 'AM_LIBTOOLFLAGS' unless set_seen $ptltflags;
|
---|
1332 |
|
---|
1333 | my $obj_ltcompile =
|
---|
1334 | "\$(LIBTOOL) $libtool_tag\$($ptltflags) \$(LIBTOOLFLAGS) "
|
---|
1335 | . "--mode=compile $obj_compile";
|
---|
1336 |
|
---|
1337 | # We _need_ `-o' for per object rules.
|
---|
1338 | my $output_flag = $lang->output_flag || '-o';
|
---|
1339 |
|
---|
1340 | my $depbase = dirname ($obj);
|
---|
1341 | $depbase = ''
|
---|
1342 | if $depbase eq '.';
|
---|
1343 | $depbase .= '/'
|
---|
1344 | unless $depbase eq '';
|
---|
1345 | $depbase .= '$(DEPDIR)/' . basename ($obj);
|
---|
1346 |
|
---|
1347 | # Support for deansified files in subdirectories is ugly
|
---|
1348 | # enough to deserve an explanation.
|
---|
1349 | #
|
---|
1350 | # A Note about normal ansi2knr processing first. On
|
---|
1351 | #
|
---|
1352 | # AUTOMAKE_OPTIONS = ansi2knr
|
---|
1353 | # bin_PROGRAMS = foo
|
---|
1354 | # foo_SOURCES = foo.c
|
---|
1355 | #
|
---|
1356 | # we generate rules similar to:
|
---|
1357 | #
|
---|
1358 | # foo: foo$U.o; link ...
|
---|
1359 | # foo$U.o: foo$U.c; compile ...
|
---|
1360 | # foo_.c: foo.c; ansi2knr ...
|
---|
1361 | #
|
---|
1362 | # this is fairly compact, and will call ansi2knr depending
|
---|
1363 | # on the value of $U (`' or `_').
|
---|
1364 | #
|
---|
1365 | # It's harder with subdir sources. On
|
---|
1366 | #
|
---|
1367 | # AUTOMAKE_OPTIONS = ansi2knr
|
---|
1368 | # bin_PROGRAMS = foo
|
---|
1369 | # foo_SOURCES = sub/foo.c
|
---|
1370 | #
|
---|
1371 | # we have to create foo_.c in the current directory.
|
---|
1372 | # (Unless the user asks 'subdir-objects'.) This is important
|
---|
1373 | # in case the same file (`foo.c') is compiled from other
|
---|
1374 | # directories with different cpp options: foo_.c would
|
---|
1375 | # be preprocessed for only one set of options if it were
|
---|
1376 | # put in the subdirectory.
|
---|
1377 | #
|
---|
1378 | # Because foo$U.o must be built from either foo_.c or
|
---|
1379 | # sub/foo.c we can't be as concise as in the first example.
|
---|
1380 | # Instead we output
|
---|
1381 | #
|
---|
1382 | # foo: foo$U.o; link ...
|
---|
1383 | # foo_.o: foo_.c; compile ...
|
---|
1384 | # foo.o: sub/foo.c; compile ...
|
---|
1385 | # foo_.c: foo.c; ansi2knr ...
|
---|
1386 | #
|
---|
1387 | # This is why we'll now transform $rule_file twice
|
---|
1388 | # if we detect this case.
|
---|
1389 | # A first time we output the compile rule with `$U'
|
---|
1390 | # replaced by `_' and the source directory removed,
|
---|
1391 | # and another time we simply remove `$U'.
|
---|
1392 | #
|
---|
1393 | # Note that at this point $source (as computed by
|
---|
1394 | # &handle_single_transform) is `sub/foo$U.c'.
|
---|
1395 | # This can be confusing: it can be used as-is when
|
---|
1396 | # subdir-objects is set, otherwise you have to know
|
---|
1397 | # it really means `foo_.c' or `sub/foo.c'.
|
---|
1398 | my $objdir = dirname ($obj);
|
---|
1399 | my $srcdir = dirname ($source);
|
---|
1400 | if ($lang->ansi && $obj =~ /\$U/)
|
---|
1401 | {
|
---|
1402 | prog_error "`$obj' contains \$U, but `$source' doesn't."
|
---|
1403 | if $source !~ /\$U/;
|
---|
1404 |
|
---|
1405 | (my $source_ = $source) =~ s/\$U/_/g;
|
---|
1406 | # Output an additional rule if _.c and .c are not in
|
---|
1407 | # the same directory. (_.c is always in $objdir.)
|
---|
1408 | if ($objdir ne $srcdir)
|
---|
1409 | {
|
---|
1410 | (my $obj_ = $obj) =~ s/\$U/_/g;
|
---|
1411 | (my $depbase_ = $depbase) =~ s/\$U/_/g;
|
---|
1412 | $source_ = basename ($source_);
|
---|
1413 |
|
---|
1414 | $output_rules .=
|
---|
1415 | file_contents ($rule_file,
|
---|
1416 | new Automake::Location,
|
---|
1417 | %transform,
|
---|
1418 | GENERIC => 0,
|
---|
1419 |
|
---|
1420 | DEPBASE => $depbase_,
|
---|
1421 | BASE => $obj_,
|
---|
1422 | SOURCE => $source_,
|
---|
1423 | OBJ => "$obj_$myext",
|
---|
1424 | OBJOBJ => "$obj_.obj",
|
---|
1425 | LTOBJ => "$obj_.lo",
|
---|
1426 |
|
---|
1427 | COMPILE => $obj_compile,
|
---|
1428 | LTCOMPILE => $obj_ltcompile,
|
---|
1429 | -o => $output_flag,
|
---|
1430 | %file_transform);
|
---|
1431 | $obj =~ s/\$U//g;
|
---|
1432 | $depbase =~ s/\$U//g;
|
---|
1433 | $source =~ s/\$U//g;
|
---|
1434 | }
|
---|
1435 | }
|
---|
1436 |
|
---|
1437 | $output_rules .=
|
---|
1438 | file_contents ($rule_file,
|
---|
1439 | new Automake::Location,
|
---|
1440 | %transform,
|
---|
1441 | GENERIC => 0,
|
---|
1442 |
|
---|
1443 | DEPBASE => $depbase,
|
---|
1444 | BASE => $obj,
|
---|
1445 | SOURCE => $source,
|
---|
1446 | # Use $myext and not `.o' here, in case
|
---|
1447 | # we are actually building a new source
|
---|
1448 | # file -- e.g. via yacc.
|
---|
1449 | OBJ => "$obj$myext",
|
---|
1450 | OBJOBJ => "$obj.obj",
|
---|
1451 | LTOBJ => "$obj.lo",
|
---|
1452 |
|
---|
1453 | COMPILE => $obj_compile,
|
---|
1454 | LTCOMPILE => $obj_ltcompile,
|
---|
1455 | -o => $output_flag,
|
---|
1456 | %file_transform);
|
---|
1457 | }
|
---|
1458 |
|
---|
1459 | # The rest of the loop is done once per language.
|
---|
1460 | next if defined $done{$lang};
|
---|
1461 | $done{$lang} = 1;
|
---|
1462 |
|
---|
1463 | # Load the language dependent Makefile chunks.
|
---|
1464 | my %lang = map { uc ($_) => 0 } keys %languages;
|
---|
1465 | $lang{uc ($lang->name)} = 1;
|
---|
1466 | $output_rules .= file_contents ('lang-compile',
|
---|
1467 | new Automake::Location,
|
---|
1468 | %transform, %lang);
|
---|
1469 |
|
---|
1470 | # If the source to a program consists entirely of code from a
|
---|
1471 | # `pure' language, for instance C++ or Fortran 77, then we
|
---|
1472 | # don't need the C compiler code. However if we run into
|
---|
1473 | # something unusual then we do generate the C code. There are
|
---|
1474 | # probably corner cases here that do not work properly.
|
---|
1475 | # People linking Java code to Fortran code deserve pain.
|
---|
1476 | $needs_c ||= ! $lang->pure;
|
---|
1477 |
|
---|
1478 | define_compiler_variable ($lang)
|
---|
1479 | if ($lang->compile);
|
---|
1480 |
|
---|
1481 | define_linker_variable ($lang)
|
---|
1482 | if ($lang->link);
|
---|
1483 |
|
---|
1484 | require_variables ("$am_file.am", $lang->Name . " source seen",
|
---|
1485 | TRUE, @{$lang->config_vars});
|
---|
1486 |
|
---|
1487 | # Call the finisher.
|
---|
1488 | $lang->finish;
|
---|
1489 |
|
---|
1490 | # Flags listed in `->flags' are user variables (per GNU Standards),
|
---|
1491 | # they should not be overridden in the Makefile...
|
---|
1492 | my @dont_override = @{$lang->flags};
|
---|
1493 | # ... and so is LDFLAGS.
|
---|
1494 | push @dont_override, 'LDFLAGS' if $lang->link;
|
---|
1495 |
|
---|
1496 | check_user_variables @dont_override;
|
---|
1497 | }
|
---|
1498 |
|
---|
1499 | # If the project is entirely C++ or entirely Fortran 77 (i.e., 1
|
---|
1500 | # suffix rule was learned), don't bother with the C stuff. But if
|
---|
1501 | # anything else creeps in, then use it.
|
---|
1502 | $needs_c = 1
|
---|
1503 | if $need_link || suffix_rules_count > 1;
|
---|
1504 |
|
---|
1505 | if ($needs_c)
|
---|
1506 | {
|
---|
1507 | &define_compiler_variable ($languages{'c'})
|
---|
1508 | unless defined $done{$languages{'c'}};
|
---|
1509 | define_linker_variable ($languages{'c'});
|
---|
1510 | }
|
---|
1511 | }
|
---|
1512 |
|
---|
1513 |
|
---|
1514 | # append_exeext { PREDICATE } $MACRO
|
---|
1515 | # ----------------------------------
|
---|
1516 | # Append $(EXEEXT) to each filename in $F appearing in the Makefile
|
---|
1517 | # variable $MACRO if &PREDICATE($F) is true. @substitutions@ are
|
---|
1518 | # ignored.
|
---|
1519 | #
|
---|
1520 | # This is typically used on all filenames of *_PROGRAMS, and filenames
|
---|
1521 | # of TESTS that are programs.
|
---|
1522 | sub append_exeext (&$)
|
---|
1523 | {
|
---|
1524 | my ($pred, $macro) = @_;
|
---|
1525 |
|
---|
1526 | transform_variable_recursively
|
---|
1527 | ($macro, $macro, 'am__EXEEXT', 0, INTERNAL,
|
---|
1528 | sub {
|
---|
1529 | my ($subvar, $val, $cond, $full_cond) = @_;
|
---|
1530 | # Append $(EXEEXT) unless the user did it already, or it's a
|
---|
1531 | # @substitution@.
|
---|
1532 | $val .= '$(EXEEXT)'
|
---|
1533 | if $val !~ /(?:\$\(EXEEXT\)$|^[@]\w+[@]$)/ && &$pred ($val);
|
---|
1534 | return $val;
|
---|
1535 | });
|
---|
1536 | }
|
---|
1537 |
|
---|
1538 |
|
---|
1539 | # Check to make sure a source defined in LIBOBJS is not explicitly
|
---|
1540 | # mentioned. This is a separate function (as opposed to being inlined
|
---|
1541 | # in handle_source_transform) because it isn't always appropriate to
|
---|
1542 | # do this check.
|
---|
1543 | sub check_libobjs_sources
|
---|
1544 | {
|
---|
1545 | my ($one_file, $unxformed) = @_;
|
---|
1546 |
|
---|
1547 | foreach my $prefix ('', 'EXTRA_', 'dist_', 'nodist_',
|
---|
1548 | 'dist_EXTRA_', 'nodist_EXTRA_')
|
---|
1549 | {
|
---|
1550 | my @files;
|
---|
1551 | my $varname = $prefix . $one_file . '_SOURCES';
|
---|
1552 | my $var = var ($varname);
|
---|
1553 | if ($var)
|
---|
1554 | {
|
---|
1555 | @files = $var->value_as_list_recursive;
|
---|
1556 | }
|
---|
1557 | elsif ($prefix eq '')
|
---|
1558 | {
|
---|
1559 | @files = ($unxformed . '.c');
|
---|
1560 | }
|
---|
1561 | else
|
---|
1562 | {
|
---|
1563 | next;
|
---|
1564 | }
|
---|
1565 |
|
---|
1566 | foreach my $file (@files)
|
---|
1567 | {
|
---|
1568 | err_var ($prefix . $one_file . '_SOURCES',
|
---|
1569 | "automatically discovered file `$file' should not" .
|
---|
1570 | " be explicitly mentioned")
|
---|
1571 | if defined $libsources{$file};
|
---|
1572 | }
|
---|
1573 | }
|
---|
1574 | }
|
---|
1575 |
|
---|
1576 |
|
---|
1577 | # @OBJECTS
|
---|
1578 | # handle_single_transform ($VAR, $TOPPARENT, $DERIVED, $OBJ, $FILE, %TRANSFORM)
|
---|
1579 | # -----------------------------------------------------------------------------
|
---|
1580 | # Does much of the actual work for handle_source_transform.
|
---|
1581 | # Arguments are:
|
---|
1582 | # $VAR is the name of the variable that the source filenames come from
|
---|
1583 | # $TOPPARENT is the name of the _SOURCES variable which is being processed
|
---|
1584 | # $DERIVED is the name of resulting executable or library
|
---|
1585 | # $OBJ is the object extension (e.g., `$U.lo')
|
---|
1586 | # $FILE the source file to transform
|
---|
1587 | # %TRANSFORM contains extras arguments to pass to file_contents
|
---|
1588 | # when producing explicit rules
|
---|
1589 | # Result is a list of the names of objects
|
---|
1590 | # %linkers_used will be updated with any linkers needed
|
---|
1591 | sub handle_single_transform ($$$$$%)
|
---|
1592 | {
|
---|
1593 | my ($var, $topparent, $derived, $obj, $_file, %transform) = @_;
|
---|
1594 | my @files = ($_file);
|
---|
1595 | my @result = ();
|
---|
1596 | my $nonansi_obj = $obj;
|
---|
1597 | $nonansi_obj =~ s/\$U//g;
|
---|
1598 |
|
---|
1599 | # Turn sources into objects. We use a while loop like this
|
---|
1600 | # because we might add to @files in the loop.
|
---|
1601 | while (scalar @files > 0)
|
---|
1602 | {
|
---|
1603 | $_ = shift @files;
|
---|
1604 |
|
---|
1605 | # Configure substitutions in _SOURCES variables are errors.
|
---|
1606 | if (/^\@.*\@$/)
|
---|
1607 | {
|
---|
1608 | my $parent_msg = '';
|
---|
1609 | $parent_msg = "\nand is referred to from `$topparent'"
|
---|
1610 | if $topparent ne $var->name;
|
---|
1611 | err_var ($var,
|
---|
1612 | "`" . $var->name . "' includes configure substitution `$_'"
|
---|
1613 | . $parent_msg . ";\nconfigure " .
|
---|
1614 | "substitutions are not allowed in _SOURCES variables");
|
---|
1615 | next;
|
---|
1616 | }
|
---|
1617 |
|
---|
1618 | # If the source file is in a subdirectory then the `.o' is put
|
---|
1619 | # into the current directory, unless the subdir-objects option
|
---|
1620 | # is in effect.
|
---|
1621 |
|
---|
1622 | # Split file name into base and extension.
|
---|
1623 | next if ! /^(?:(.*)\/)?([^\/]*)($KNOWN_EXTENSIONS_PATTERN)$/;
|
---|
1624 | my $full = $_;
|
---|
1625 | my $directory = $1 || '';
|
---|
1626 | my $base = $2;
|
---|
1627 | my $extension = $3;
|
---|
1628 |
|
---|
1629 | # We must generate a rule for the object if it requires its own flags.
|
---|
1630 | my $renamed = 0;
|
---|
1631 | my ($linker, $object);
|
---|
1632 |
|
---|
1633 | # This records whether we've seen a derived source file (e.g.
|
---|
1634 | # yacc output).
|
---|
1635 | my $derived_source = 0;
|
---|
1636 |
|
---|
1637 | # This holds the `aggregate context' of the file we are
|
---|
1638 | # currently examining. If the file is compiled with
|
---|
1639 | # per-object flags, then it will be the name of the object.
|
---|
1640 | # Otherwise it will be `AM'. This is used by the target hook
|
---|
1641 | # language function.
|
---|
1642 | my $aggregate = 'AM';
|
---|
1643 |
|
---|
1644 | $extension = &derive_suffix ($extension, $nonansi_obj);
|
---|
1645 | my $lang;
|
---|
1646 | if ($extension_map{$extension} &&
|
---|
1647 | ($lang = $languages{$extension_map{$extension}}))
|
---|
1648 | {
|
---|
1649 | # Found the language, so see what it says.
|
---|
1650 | &saw_extension ($extension);
|
---|
1651 |
|
---|
1652 | # Do we have per-executable flags for this executable?
|
---|
1653 | my $have_per_exec_flags = 0;
|
---|
1654 | my @peflags = @{$lang->flags};
|
---|
1655 | push @peflags, 'LIBTOOLFLAGS' if $nonansi_obj eq '.lo';
|
---|
1656 | foreach my $flag (@peflags)
|
---|
1657 | {
|
---|
1658 | if (set_seen ("${derived}_$flag"))
|
---|
1659 | {
|
---|
1660 | $have_per_exec_flags = 1;
|
---|
1661 | last;
|
---|
1662 | }
|
---|
1663 | }
|
---|
1664 |
|
---|
1665 | # Note: computed subr call. The language rewrite function
|
---|
1666 | # should return one of the LANG_* constants. It could
|
---|
1667 | # also return a list whose first value is such a constant
|
---|
1668 | # and whose second value is a new source extension which
|
---|
1669 | # should be applied. This means this particular language
|
---|
1670 | # generates another source file which we must then process
|
---|
1671 | # further.
|
---|
1672 | my $subr = \&{'lang_' . $lang->name . '_rewrite'};
|
---|
1673 | my ($r, $source_extension)
|
---|
1674 | = &$subr ($directory, $base, $extension,
|
---|
1675 | $nonansi_obj, $have_per_exec_flags, $var);
|
---|
1676 | # Skip this entry if we were asked not to process it.
|
---|
1677 | next if $r == LANG_IGNORE;
|
---|
1678 |
|
---|
1679 | # Now extract linker and other info.
|
---|
1680 | $linker = $lang->linker;
|
---|
1681 |
|
---|
1682 | my $this_obj_ext;
|
---|
1683 | if (defined $source_extension)
|
---|
1684 | {
|
---|
1685 | $this_obj_ext = $source_extension;
|
---|
1686 | $derived_source = 1;
|
---|
1687 | }
|
---|
1688 | elsif ($lang->ansi)
|
---|
1689 | {
|
---|
1690 | $this_obj_ext = $obj;
|
---|
1691 | }
|
---|
1692 | else
|
---|
1693 | {
|
---|
1694 | $this_obj_ext = $nonansi_obj;
|
---|
1695 | }
|
---|
1696 | $object = $base . $this_obj_ext;
|
---|
1697 |
|
---|
1698 | if ($have_per_exec_flags)
|
---|
1699 | {
|
---|
1700 | # We have a per-executable flag in effect for this
|
---|
1701 | # object. In this case we rewrite the object's
|
---|
1702 | # name to ensure it is unique.
|
---|
1703 |
|
---|
1704 | # We choose the name `DERIVED_OBJECT' to ensure
|
---|
1705 | # (1) uniqueness, and (2) continuity between
|
---|
1706 | # invocations. However, this will result in a
|
---|
1707 | # name that is too long for losing systems, in
|
---|
1708 | # some situations. So we provide _SHORTNAME to
|
---|
1709 | # override.
|
---|
1710 |
|
---|
1711 | my $dname = $derived;
|
---|
1712 | my $var = var ($derived . '_SHORTNAME');
|
---|
1713 | if ($var)
|
---|
1714 | {
|
---|
1715 | # FIXME: should use the same Condition as
|
---|
1716 | # the _SOURCES variable. But this is really
|
---|
1717 | # silly overkill -- nobody should have
|
---|
1718 | # conditional shortnames.
|
---|
1719 | $dname = $var->variable_value;
|
---|
1720 | }
|
---|
1721 | $object = $dname . '-' . $object;
|
---|
1722 |
|
---|
1723 | prog_error ($lang->name . " flags defined without compiler")
|
---|
1724 | if ! defined $lang->compile;
|
---|
1725 |
|
---|
1726 | $renamed = 1;
|
---|
1727 | }
|
---|
1728 |
|
---|
1729 | # If rewrite said it was ok, put the object into a
|
---|
1730 | # subdir.
|
---|
1731 | if ($r == LANG_SUBDIR && $directory ne '')
|
---|
1732 | {
|
---|
1733 | $object = $directory . '/' . $object;
|
---|
1734 | }
|
---|
1735 |
|
---|
1736 | # If the object file has been renamed (because per-target
|
---|
1737 | # flags are used) we cannot compile the file with an
|
---|
1738 | # inference rule: we need an explicit rule.
|
---|
1739 | #
|
---|
1740 | # If the source is in a subdirectory and the object is in
|
---|
1741 | # the current directory, we also need an explicit rule.
|
---|
1742 | #
|
---|
1743 | # If both source and object files are in a subdirectory
|
---|
1744 | # (this happens when the subdir-objects option is used),
|
---|
1745 | # then the inference will work.
|
---|
1746 | #
|
---|
1747 | # The latter case deserves a historical note. When the
|
---|
1748 | # subdir-objects option was added on 1999-04-11 it was
|
---|
1749 | # thought that inferences rules would work for
|
---|
1750 | # subdirectory objects too. Later, on 1999-11-22,
|
---|
1751 | # automake was changed to output explicit rules even for
|
---|
1752 | # subdir-objects. Nobody remembers why, but this occurred
|
---|
1753 | # soon after the merge of the user-dep-gen-branch so it
|
---|
1754 | # might be related. In late 2003 people complained about
|
---|
1755 | # the size of the generated Makefile.ins (libgcj, with
|
---|
1756 | # 2200+ subdir objects was reported to have a 9MB
|
---|
1757 | # Makefile), so we now rely on inference rules again.
|
---|
1758 | # Maybe we'll run across the same issue as in the past,
|
---|
1759 | # but at least this time we can document it. However since
|
---|
1760 | # dependency tracking has evolved it is possible that
|
---|
1761 | # our old problem no longer exists.
|
---|
1762 | # Using inference rules for subdir-objects has been tested
|
---|
1763 | # with GNU make, Solaris make, Ultrix make, BSD make,
|
---|
1764 | # HP-UX make, and OSF1 make successfully.
|
---|
1765 | if ($renamed
|
---|
1766 | || ($directory ne '' && ! option 'subdir-objects')
|
---|
1767 | # We must also use specific rules for a nodist_ source
|
---|
1768 | # if its language requests it.
|
---|
1769 | || ($lang->nodist_specific && ! $transform{'DIST_SOURCE'}))
|
---|
1770 | {
|
---|
1771 | my $obj_sans_ext = substr ($object, 0,
|
---|
1772 | - length ($this_obj_ext));
|
---|
1773 | my $full_ansi = $full;
|
---|
1774 | if ($lang->ansi && option 'ansi2knr')
|
---|
1775 | {
|
---|
1776 | $full_ansi =~ s/$KNOWN_EXTENSIONS_PATTERN$/\$U$&/;
|
---|
1777 | $obj_sans_ext .= '$U';
|
---|
1778 | }
|
---|
1779 |
|
---|
1780 | my @specifics = ($full_ansi, $obj_sans_ext,
|
---|
1781 | # Only use $this_obj_ext in the derived
|
---|
1782 | # source case because in the other case we
|
---|
1783 | # *don't* want $(OBJEXT) to appear here.
|
---|
1784 | ($derived_source ? $this_obj_ext : '.o'));
|
---|
1785 |
|
---|
1786 | # If we renamed the object then we want to use the
|
---|
1787 | # per-executable flag name. But if this is simply a
|
---|
1788 | # subdir build then we still want to use the AM_ flag
|
---|
1789 | # name.
|
---|
1790 | if ($renamed)
|
---|
1791 | {
|
---|
1792 | unshift @specifics, $derived;
|
---|
1793 | $aggregate = $derived;
|
---|
1794 | }
|
---|
1795 | else
|
---|
1796 | {
|
---|
1797 | unshift @specifics, 'AM';
|
---|
1798 | }
|
---|
1799 |
|
---|
1800 | # Each item on this list is a reference to a list consisting
|
---|
1801 | # of four values followed by additional transform flags for
|
---|
1802 | # file_contents. The four values are the derived flag prefix
|
---|
1803 | # (e.g. for `foo_CFLAGS', it is `foo'), the name of the
|
---|
1804 | # source file, the base name of the output file, and
|
---|
1805 | # the extension for the object file.
|
---|
1806 | push (@{$lang_specific_files{$lang->name}},
|
---|
1807 | [@specifics, %transform]);
|
---|
1808 | }
|
---|
1809 | }
|
---|
1810 | elsif ($extension eq $nonansi_obj)
|
---|
1811 | {
|
---|
1812 | # This is probably the result of a direct suffix rule.
|
---|
1813 | # In this case we just accept the rewrite.
|
---|
1814 | $object = "$base$extension";
|
---|
1815 | $object = "$directory/$object" if $directory ne '';
|
---|
1816 | $linker = '';
|
---|
1817 | }
|
---|
1818 | else
|
---|
1819 | {
|
---|
1820 | # No error message here. Used to have one, but it was
|
---|
1821 | # very unpopular.
|
---|
1822 | # FIXME: we could potentially do more processing here,
|
---|
1823 | # perhaps treating the new extension as though it were a
|
---|
1824 | # new source extension (as above). This would require
|
---|
1825 | # more restructuring than is appropriate right now.
|
---|
1826 | next;
|
---|
1827 | }
|
---|
1828 |
|
---|
1829 | err_am "object `$object' created by `$full' and `$object_map{$object}'"
|
---|
1830 | if (defined $object_map{$object}
|
---|
1831 | && $object_map{$object} ne $full);
|
---|
1832 |
|
---|
1833 | my $comp_val = (($object =~ /\.lo$/)
|
---|
1834 | ? COMPILE_LIBTOOL : COMPILE_ORDINARY);
|
---|
1835 | (my $comp_obj = $object) =~ s/\.lo$/.\$(OBJEXT)/;
|
---|
1836 | if (defined $object_compilation_map{$comp_obj}
|
---|
1837 | && $object_compilation_map{$comp_obj} != 0
|
---|
1838 | # Only see the error once.
|
---|
1839 | && ($object_compilation_map{$comp_obj}
|
---|
1840 | != (COMPILE_LIBTOOL | COMPILE_ORDINARY))
|
---|
1841 | && $object_compilation_map{$comp_obj} != $comp_val)
|
---|
1842 | {
|
---|
1843 | err_am "object `$comp_obj' created both with libtool and without";
|
---|
1844 | }
|
---|
1845 | $object_compilation_map{$comp_obj} |= $comp_val;
|
---|
1846 |
|
---|
1847 | if (defined $lang)
|
---|
1848 | {
|
---|
1849 | # Let the language do some special magic if required.
|
---|
1850 | $lang->target_hook ($aggregate, $object, $full, %transform);
|
---|
1851 | }
|
---|
1852 |
|
---|
1853 | if ($derived_source)
|
---|
1854 | {
|
---|
1855 | prog_error ($lang->name . " has automatic dependency tracking")
|
---|
1856 | if $lang->autodep ne 'no';
|
---|
1857 | # Make sure this new source file is handled next. That will
|
---|
1858 | # make it appear to be at the right place in the list.
|
---|
1859 | unshift (@files, $object);
|
---|
1860 | # Distribute derived sources unless the source they are
|
---|
1861 | # derived from is not.
|
---|
1862 | &push_dist_common ($object)
|
---|
1863 | unless ($topparent =~ /^(?:nobase_)?nodist_/);
|
---|
1864 | next;
|
---|
1865 | }
|
---|
1866 |
|
---|
1867 | $linkers_used{$linker} = 1;
|
---|
1868 |
|
---|
1869 | push (@result, $object);
|
---|
1870 |
|
---|
1871 | if (! defined $object_map{$object})
|
---|
1872 | {
|
---|
1873 | my @dep_list = ();
|
---|
1874 | $object_map{$object} = $full;
|
---|
1875 |
|
---|
1876 | # If resulting object is in subdir, we need to make
|
---|
1877 | # sure the subdir exists at build time.
|
---|
1878 | if ($object =~ /\//)
|
---|
1879 | {
|
---|
1880 | # FIXME: check that $DIRECTORY is somewhere in the
|
---|
1881 | # project
|
---|
1882 |
|
---|
1883 | # For Java, the way we're handling it right now, a
|
---|
1884 | # `..' component doesn't make sense.
|
---|
1885 | if ($lang && $lang->name eq 'java' && $object =~ /(\/|^)\.\.\//)
|
---|
1886 | {
|
---|
1887 | err_am "`$full' should not contain a `..' component";
|
---|
1888 | }
|
---|
1889 |
|
---|
1890 | # Make sure object is removed by `make mostlyclean'.
|
---|
1891 | $compile_clean_files{$object} = MOSTLY_CLEAN;
|
---|
1892 | # If we have a libtool object then we also must remove
|
---|
1893 | # the ordinary .o.
|
---|
1894 | if ($object =~ /\.lo$/)
|
---|
1895 | {
|
---|
1896 | (my $xobj = $object) =~ s,lo$,\$(OBJEXT),;
|
---|
1897 | $compile_clean_files{$xobj} = MOSTLY_CLEAN;
|
---|
1898 |
|
---|
1899 | # Remove any libtool object in this directory.
|
---|
1900 | $libtool_clean_directories{$directory} = 1;
|
---|
1901 | }
|
---|
1902 |
|
---|
1903 | push (@dep_list, require_build_directory ($directory));
|
---|
1904 |
|
---|
1905 | # If we're generating dependencies, we also want
|
---|
1906 | # to make sure that the appropriate subdir of the
|
---|
1907 | # .deps directory is created.
|
---|
1908 | push (@dep_list,
|
---|
1909 | require_build_directory ($directory . '/$(DEPDIR)'))
|
---|
1910 | unless option 'no-dependencies';
|
---|
1911 | }
|
---|
1912 |
|
---|
1913 | &pretty_print_rule ($object . ':', "\t", @dep_list)
|
---|
1914 | if scalar @dep_list > 0;
|
---|
1915 | }
|
---|
1916 |
|
---|
1917 | # Transform .o or $o file into .P file (for automatic
|
---|
1918 | # dependency code).
|
---|
1919 | if ($lang && $lang->autodep ne 'no')
|
---|
1920 | {
|
---|
1921 | my $depfile = $object;
|
---|
1922 | $depfile =~ s/\.([^.]*)$/.P$1/;
|
---|
1923 | $depfile =~ s/\$\(OBJEXT\)$/o/;
|
---|
1924 | $dep_files{dirname ($depfile) . '/$(DEPDIR)/'
|
---|
1925 | . basename ($depfile)} = 1;
|
---|
1926 | }
|
---|
1927 | }
|
---|
1928 |
|
---|
1929 | return @result;
|
---|
1930 | }
|
---|
1931 |
|
---|
1932 |
|
---|
1933 | # $LINKER
|
---|
1934 | # define_objects_from_sources ($VAR, $OBJVAR, $NODEFINE, $ONE_FILE,
|
---|
1935 | # $OBJ, $PARENT, $TOPPARENT, $WHERE, %TRANSFORM)
|
---|
1936 | # ---------------------------------------------------------------------------
|
---|
1937 | # Define an _OBJECTS variable for a _SOURCES variable (or subvariable)
|
---|
1938 | #
|
---|
1939 | # Arguments are:
|
---|
1940 | # $VAR is the name of the _SOURCES variable
|
---|
1941 | # $OBJVAR is the name of the _OBJECTS variable if known (otherwise
|
---|
1942 | # it will be generated and returned).
|
---|
1943 | # $NODEFINE is a boolean: if true, $OBJVAR will not be defined (but
|
---|
1944 | # work done to determine the linker will be).
|
---|
1945 | # $ONE_FILE is the canonical (transformed) name of object to build
|
---|
1946 | # $OBJ is the object extension (i.e. either `.o' or `.lo').
|
---|
1947 | # $TOPPARENT is the _SOURCES variable being processed.
|
---|
1948 | # $WHERE context into which this definition is done
|
---|
1949 | # %TRANSFORM extra arguments to pass to file_contents when producing
|
---|
1950 | # rules
|
---|
1951 | #
|
---|
1952 | # Result is a pair ($LINKER, $OBJVAR):
|
---|
1953 | # $LINKER is a boolean, true if a linker is needed to deal with the objects
|
---|
1954 | sub define_objects_from_sources ($$$$$$$%)
|
---|
1955 | {
|
---|
1956 | my ($var, $objvar, $nodefine, $one_file,
|
---|
1957 | $obj, $topparent, $where, %transform) = @_;
|
---|
1958 |
|
---|
1959 | my $needlinker = "";
|
---|
1960 |
|
---|
1961 | transform_variable_recursively
|
---|
1962 | ($var, $objvar, 'am__objects', $nodefine, $where,
|
---|
1963 | # The transform code to run on each filename.
|
---|
1964 | sub {
|
---|
1965 | my ($subvar, $val, $cond, $full_cond) = @_;
|
---|
1966 | my @trans = handle_single_transform ($subvar, $topparent,
|
---|
1967 | $one_file, $obj, $val,
|
---|
1968 | %transform);
|
---|
1969 | $needlinker = "true" if @trans;
|
---|
1970 | return @trans;
|
---|
1971 | });
|
---|
1972 |
|
---|
1973 | return $needlinker;
|
---|
1974 | }
|
---|
1975 |
|
---|
1976 |
|
---|
1977 | # handle_source_transform ($CANON_TARGET, $TARGET, $OBJEXT, $WHERE, %TRANSFORM)
|
---|
1978 | # -----------------------------------------------------------------------------
|
---|
1979 | # Handle SOURCE->OBJECT transform for one program or library.
|
---|
1980 | # Arguments are:
|
---|
1981 | # canonical (transformed) name of target to build
|
---|
1982 | # actual target of object to build
|
---|
1983 | # object extension (i.e., either `.o' or `$o')
|
---|
1984 | # location of the source variable
|
---|
1985 | # extra arguments to pass to file_contents when producing rules
|
---|
1986 | # Return the name of the linker variable that must be used.
|
---|
1987 | # Empty return means just use `LINK'.
|
---|
1988 | sub handle_source_transform ($$$$%)
|
---|
1989 | {
|
---|
1990 | # one_file is canonical name. unxformed is given name. obj is
|
---|
1991 | # object extension.
|
---|
1992 | my ($one_file, $unxformed, $obj, $where, %transform) = @_;
|
---|
1993 |
|
---|
1994 | my $linker = '';
|
---|
1995 |
|
---|
1996 | # No point in continuing if _OBJECTS is defined.
|
---|
1997 | return if reject_var ($one_file . '_OBJECTS',
|
---|
1998 | $one_file . '_OBJECTS should not be defined');
|
---|
1999 |
|
---|
2000 | my %used_pfx = ();
|
---|
2001 | my $needlinker;
|
---|
2002 | %linkers_used = ();
|
---|
2003 | foreach my $prefix ('', 'EXTRA_', 'dist_', 'nodist_',
|
---|
2004 | 'dist_EXTRA_', 'nodist_EXTRA_')
|
---|
2005 | {
|
---|
2006 | my $varname = $prefix . $one_file . "_SOURCES";
|
---|
2007 | my $var = var $varname;
|
---|
2008 | next unless $var;
|
---|
2009 |
|
---|
2010 | # We are going to define _OBJECTS variables using the prefix.
|
---|
2011 | # Then we glom them all together. So we can't use the null
|
---|
2012 | # prefix here as we need it later.
|
---|
2013 | my $xpfx = ($prefix eq '') ? 'am_' : $prefix;
|
---|
2014 |
|
---|
2015 | # Keep track of which prefixes we saw.
|
---|
2016 | $used_pfx{$xpfx} = 1
|
---|
2017 | unless $prefix =~ /EXTRA_/;
|
---|
2018 |
|
---|
2019 | push @sources, "\$($varname)";
|
---|
2020 | push @dist_sources, shadow_unconditionally ($varname, $where)
|
---|
2021 | unless (option ('no-dist') || $prefix =~ /^nodist_/);
|
---|
2022 |
|
---|
2023 | $needlinker |=
|
---|
2024 | define_objects_from_sources ($varname,
|
---|
2025 | $xpfx . $one_file . '_OBJECTS',
|
---|
2026 | $prefix =~ /EXTRA_/,
|
---|
2027 | $one_file, $obj, $varname, $where,
|
---|
2028 | DIST_SOURCE => ($prefix !~ /^nodist_/),
|
---|
2029 | %transform);
|
---|
2030 | }
|
---|
2031 | if ($needlinker)
|
---|
2032 | {
|
---|
2033 | $linker ||= &resolve_linker (%linkers_used);
|
---|
2034 | }
|
---|
2035 |
|
---|
2036 | my @keys = sort keys %used_pfx;
|
---|
2037 | if (scalar @keys == 0)
|
---|
2038 | {
|
---|
2039 | # The default source for libfoo.la is libfoo.c, but for
|
---|
2040 | # backward compatibility we first look at libfoo_la.c
|
---|
2041 | my $old_default_source = "$one_file.c";
|
---|
2042 | (my $default_source = $unxformed) =~ s,(\.[^./\\]*)?$,.c,;
|
---|
2043 | if ($old_default_source ne $default_source
|
---|
2044 | && (rule $old_default_source
|
---|
2045 | || rule '$(srcdir)/' . $old_default_source
|
---|
2046 | || rule '${srcdir}/' . $old_default_source
|
---|
2047 | || -f $old_default_source))
|
---|
2048 | {
|
---|
2049 | my $loc = $where->clone;
|
---|
2050 | $loc->pop_context;
|
---|
2051 | msg ('obsolete', $loc,
|
---|
2052 | "the default source for `$unxformed' has been changed "
|
---|
2053 | . "to `$default_source'.\n(Using `$old_default_source' for "
|
---|
2054 | . "backward compatibility.)");
|
---|
2055 | $default_source = $old_default_source;
|
---|
2056 | }
|
---|
2057 | # If a rule exists to build this source with a $(srcdir)
|
---|
2058 | # prefix, use that prefix in our variables too. This is for
|
---|
2059 | # the sake of BSD Make.
|
---|
2060 | if (rule '$(srcdir)/' . $default_source
|
---|
2061 | || rule '${srcdir}/' . $default_source)
|
---|
2062 | {
|
---|
2063 | $default_source = '$(srcdir)/' . $default_source;
|
---|
2064 | }
|
---|
2065 |
|
---|
2066 | &define_variable ($one_file . "_SOURCES", $default_source, $where);
|
---|
2067 | push (@sources, $default_source);
|
---|
2068 | push (@dist_sources, $default_source);
|
---|
2069 |
|
---|
2070 | %linkers_used = ();
|
---|
2071 | my (@result) =
|
---|
2072 | handle_single_transform ($one_file . '_SOURCES',
|
---|
2073 | $one_file . '_SOURCES',
|
---|
2074 | $one_file, $obj,
|
---|
2075 | $default_source, %transform);
|
---|
2076 | $linker ||= &resolve_linker (%linkers_used);
|
---|
2077 | define_pretty_variable ($one_file . '_OBJECTS', TRUE, $where, @result);
|
---|
2078 | }
|
---|
2079 | else
|
---|
2080 | {
|
---|
2081 | @keys = map { '$(' . $_ . $one_file . '_OBJECTS)' } @keys;
|
---|
2082 | define_pretty_variable ($one_file . '_OBJECTS', TRUE, $where, @keys);
|
---|
2083 | }
|
---|
2084 |
|
---|
2085 | # If we want to use `LINK' we must make sure it is defined.
|
---|
2086 | if ($linker eq '')
|
---|
2087 | {
|
---|
2088 | $need_link = 1;
|
---|
2089 | }
|
---|
2090 |
|
---|
2091 | return $linker;
|
---|
2092 | }
|
---|
2093 |
|
---|
2094 |
|
---|
2095 | # handle_lib_objects ($XNAME, $VAR)
|
---|
2096 | # ---------------------------------
|
---|
2097 | # Special-case ALLOCA and LIBOBJS substitutions in _LDADD or _LIBADD variables.
|
---|
2098 | # Also, generate _DEPENDENCIES variable if appropriate.
|
---|
2099 | # Arguments are:
|
---|
2100 | # transformed name of object being built, or empty string if no object
|
---|
2101 | # name of _LDADD/_LIBADD-type variable to examine
|
---|
2102 | # Returns 1 if LIBOBJS seen, 0 otherwise.
|
---|
2103 | sub handle_lib_objects
|
---|
2104 | {
|
---|
2105 | my ($xname, $varname) = @_;
|
---|
2106 |
|
---|
2107 | my $var = var ($varname);
|
---|
2108 | prog_error "handle_lib_objects: `$varname' undefined"
|
---|
2109 | unless $var;
|
---|
2110 | prog_error "handle_lib_objects: unexpected variable name `$varname'"
|
---|
2111 | unless $varname =~ /^(.*)(?:LIB|LD)ADD$/;
|
---|
2112 | my $prefix = $1 || 'AM_';
|
---|
2113 |
|
---|
2114 | my $seen_libobjs = 0;
|
---|
2115 | my $flagvar = 0;
|
---|
2116 |
|
---|
2117 | transform_variable_recursively
|
---|
2118 | ($varname, $xname . '_DEPENDENCIES', 'am__DEPENDENCIES',
|
---|
2119 | ! $xname, INTERNAL,
|
---|
2120 | # Transformation function, run on each filename.
|
---|
2121 | sub {
|
---|
2122 | my ($subvar, $val, $cond, $full_cond) = @_;
|
---|
2123 |
|
---|
2124 | if ($val =~ /^-/)
|
---|
2125 | {
|
---|
2126 | # Skip -lfoo and -Ldir silently; these are explicitly allowed.
|
---|
2127 | if ($val !~ /^-[lL]/ &&
|
---|
2128 | # Skip -dlopen and -dlpreopen; these are explicitly allowed
|
---|
2129 | # for Libtool libraries or programs. (Actually we are a bit
|
---|
2130 | # laxe here since this code also applies to non-libtool
|
---|
2131 | # libraries or programs, for which -dlopen and -dlopreopen
|
---|
2132 | # are pure nonsense. Diagnosing this doesn't seems very
|
---|
2133 | # important: the developer will quickly get complaints from
|
---|
2134 | # the linker.)
|
---|
2135 | $val !~ /^-dl(?:pre)?open$/ &&
|
---|
2136 | # Only get this error once.
|
---|
2137 | ! $flagvar)
|
---|
2138 | {
|
---|
2139 | $flagvar = 1;
|
---|
2140 | # FIXME: should display a stack of nested variables
|
---|
2141 | # as context when $var != $subvar.
|
---|
2142 | err_var ($var, "linker flags such as `$val' belong in "
|
---|
2143 | . "`${prefix}LDFLAGS");
|
---|
2144 | }
|
---|
2145 | return ();
|
---|
2146 | }
|
---|
2147 | elsif ($val !~ /^\@.*\@$/)
|
---|
2148 | {
|
---|
2149 | # Assume we have a file of some sort, and output it into the
|
---|
2150 | # dependency variable. Autoconf substitutions are not output;
|
---|
2151 | # rarely is a new dependency substituted into e.g. foo_LDADD
|
---|
2152 | # -- but bad things (e.g. -lX11) are routinely substituted.
|
---|
2153 | # Note that LIBOBJS and ALLOCA are exceptions to this rule,
|
---|
2154 | # and handled specially below.
|
---|
2155 | return $val;
|
---|
2156 | }
|
---|
2157 | elsif ($val =~ /^\@(LT)?LIBOBJS\@$/)
|
---|
2158 | {
|
---|
2159 | handle_LIBOBJS ($subvar, $cond, $1);
|
---|
2160 | $seen_libobjs = 1;
|
---|
2161 | return $val;
|
---|
2162 | }
|
---|
2163 | elsif ($val =~ /^\@(LT)?ALLOCA\@$/)
|
---|
2164 | {
|
---|
2165 | handle_ALLOCA ($subvar, $cond, $1);
|
---|
2166 | return $val;
|
---|
2167 | }
|
---|
2168 | else
|
---|
2169 | {
|
---|
2170 | return ();
|
---|
2171 | }
|
---|
2172 | });
|
---|
2173 |
|
---|
2174 | return $seen_libobjs;
|
---|
2175 | }
|
---|
2176 |
|
---|
2177 | # handle_LIBOBJS_or_ALLOCA ($VAR)
|
---|
2178 | # -------------------------------
|
---|
2179 | # Definitions common to LIBOBJS and ALLOCA.
|
---|
2180 | # VAR should be one of LIBOBJS, LTLIBOBJS, ALLOCA, or LTALLOCA.
|
---|
2181 | sub handle_LIBOBJS_or_ALLOCA ($)
|
---|
2182 | {
|
---|
2183 | my ($var) = @_;
|
---|
2184 |
|
---|
2185 | my $dir = '';
|
---|
2186 |
|
---|
2187 | # If LIBOBJS files must be built in another directory we have
|
---|
2188 | # to define LIBOBJDIR and ensure the files get cleaned.
|
---|
2189 | # Otherwise LIBOBJDIR can be left undefined, and the cleaning
|
---|
2190 | # is achieved by `rm -f *.$(OBJEXT)' in compile.am.
|
---|
2191 | if ($config_libobj_dir
|
---|
2192 | && $relative_dir ne $config_libobj_dir)
|
---|
2193 | {
|
---|
2194 | if (option 'subdir-objects')
|
---|
2195 | {
|
---|
2196 | # In the top-level Makefile we do not use $(top_builddir), because
|
---|
2197 | # we are already there, and since the targets are built without
|
---|
2198 | # a $(top_builddir), it helps BSD Make to match them with
|
---|
2199 | # dependencies.
|
---|
2200 | $dir = "$config_libobj_dir/" if $config_libobj_dir ne '.';
|
---|
2201 | $dir = "$topsrcdir/$dir" if $relative_dir ne '.';
|
---|
2202 | define_variable ('LIBOBJDIR', "$dir", INTERNAL);
|
---|
2203 | $clean_files{"\$($var)"} = MOSTLY_CLEAN;
|
---|
2204 | # If LTLIBOBJS is used, we must also clear LIBOBJS (which might
|
---|
2205 | # be created by libtool as a side-effect of creating LTLIBOBJS).
|
---|
2206 | $clean_files{"\$($var)"} = MOSTLY_CLEAN if $var =~ s/^LT//;
|
---|
2207 |
|
---|
2208 | }
|
---|
2209 | else
|
---|
2210 | {
|
---|
2211 | error ("`\$($var)' cannot be used outside `$dir' if"
|
---|
2212 | . " `subdir-objects' is not set");
|
---|
2213 | }
|
---|
2214 | }
|
---|
2215 |
|
---|
2216 | return $dir;
|
---|
2217 | }
|
---|
2218 |
|
---|
2219 | sub handle_LIBOBJS ($$$)
|
---|
2220 | {
|
---|
2221 | my ($var, $cond, $lt) = @_;
|
---|
2222 | my $myobjext = $lt ? 'lo' : 'o';
|
---|
2223 | $lt ||= '';
|
---|
2224 |
|
---|
2225 | $var->requires_variables ("\@${lt}LIBOBJS\@ used", $lt . 'LIBOBJS')
|
---|
2226 | if ! keys %libsources;
|
---|
2227 |
|
---|
2228 | my $dir = handle_LIBOBJS_or_ALLOCA "${lt}LIBOBJS";
|
---|
2229 |
|
---|
2230 | foreach my $iter (keys %libsources)
|
---|
2231 | {
|
---|
2232 | if ($iter =~ /\.[cly]$/)
|
---|
2233 | {
|
---|
2234 | &saw_extension ($&);
|
---|
2235 | &saw_extension ('.c');
|
---|
2236 | }
|
---|
2237 |
|
---|
2238 | if ($iter =~ /\.h$/)
|
---|
2239 | {
|
---|
2240 | require_libsource_with_macro ($cond, $var, FOREIGN, $iter);
|
---|
2241 | }
|
---|
2242 | elsif ($iter ne 'alloca.c')
|
---|
2243 | {
|
---|
2244 | my $rewrite = $iter;
|
---|
2245 | $rewrite =~ s/\.c$/.P$myobjext/;
|
---|
2246 | $dep_files{$dir . '$(DEPDIR)/' . $rewrite} = 1;
|
---|
2247 | $rewrite = "^" . quotemeta ($iter) . "\$";
|
---|
2248 | # Only require the file if it is not a built source.
|
---|
2249 | my $bs = var ('BUILT_SOURCES');
|
---|
2250 | if (! $bs || ! grep (/$rewrite/, $bs->value_as_list_recursive))
|
---|
2251 | {
|
---|
2252 | require_libsource_with_macro ($cond, $var, FOREIGN, $iter);
|
---|
2253 | }
|
---|
2254 | }
|
---|
2255 | }
|
---|
2256 | }
|
---|
2257 |
|
---|
2258 | sub handle_ALLOCA ($$$)
|
---|
2259 | {
|
---|
2260 | my ($var, $cond, $lt) = @_;
|
---|
2261 | my $myobjext = $lt ? 'lo' : 'o';
|
---|
2262 | $lt ||= '';
|
---|
2263 | my $dir = handle_LIBOBJS_or_ALLOCA "${lt}ALLOCA";
|
---|
2264 |
|
---|
2265 | $var->requires_variables ("\@${lt}ALLOCA\@ used", $lt . 'ALLOCA');
|
---|
2266 | $dep_files{$dir . '$(DEPDIR)/alloca.P' . $myobjext} = 1;
|
---|
2267 | require_libsource_with_macro ($cond, $var, FOREIGN, 'alloca.c');
|
---|
2268 | &saw_extension ('.c');
|
---|
2269 | }
|
---|
2270 |
|
---|
2271 | # Canonicalize the input parameter
|
---|
2272 | sub canonicalize
|
---|
2273 | {
|
---|
2274 | my ($string) = @_;
|
---|
2275 | $string =~ tr/A-Za-z0-9_\@/_/c;
|
---|
2276 | return $string;
|
---|
2277 | }
|
---|
2278 |
|
---|
2279 | # Canonicalize a name, and check to make sure the non-canonical name
|
---|
2280 | # is never used. Returns canonical name. Arguments are name and a
|
---|
2281 | # list of suffixes to check for.
|
---|
2282 | sub check_canonical_spelling
|
---|
2283 | {
|
---|
2284 | my ($name, @suffixes) = @_;
|
---|
2285 |
|
---|
2286 | my $xname = &canonicalize ($name);
|
---|
2287 | if ($xname ne $name)
|
---|
2288 | {
|
---|
2289 | foreach my $xt (@suffixes)
|
---|
2290 | {
|
---|
2291 | reject_var ("$name$xt", "use `$xname$xt', not `$name$xt'");
|
---|
2292 | }
|
---|
2293 | }
|
---|
2294 |
|
---|
2295 | return $xname;
|
---|
2296 | }
|
---|
2297 |
|
---|
2298 |
|
---|
2299 | # handle_compile ()
|
---|
2300 | # -----------------
|
---|
2301 | # Set up the compile suite.
|
---|
2302 | sub handle_compile ()
|
---|
2303 | {
|
---|
2304 | return
|
---|
2305 | unless $get_object_extension_was_run;
|
---|
2306 |
|
---|
2307 | # Boilerplate.
|
---|
2308 | my $default_includes = '';
|
---|
2309 | if (! option 'nostdinc')
|
---|
2310 | {
|
---|
2311 | my @incs = ('-I.');
|
---|
2312 |
|
---|
2313 | my $var = var 'CONFIG_HEADER';
|
---|
2314 | if ($var)
|
---|
2315 | {
|
---|
2316 | foreach my $hdr (split (' ', $var->variable_value))
|
---|
2317 | {
|
---|
2318 | push @incs, '-I' . dirname ($hdr);
|
---|
2319 | }
|
---|
2320 | }
|
---|
2321 | # We want `-I. -I$(srcdir)', but the latter -I is redundant
|
---|
2322 | # and unaesthetic in non-VPATH builds. We use `-I.@am__isrc@`
|
---|
2323 | # instead. It will be replaced by '-I.' or '-I. -I$(srcdir)'.
|
---|
2324 | # Items in CONFIG_HEADER are never in $(srcdir) so it is safe
|
---|
2325 | # to just append @am__isrc@.
|
---|
2326 | $default_includes = ' ' . uniq (@incs) . subst ('am__isrc');
|
---|
2327 | }
|
---|
2328 |
|
---|
2329 | my (@mostly_rms, @dist_rms);
|
---|
2330 | foreach my $item (sort keys %compile_clean_files)
|
---|
2331 | {
|
---|
2332 | if ($compile_clean_files{$item} == MOSTLY_CLEAN)
|
---|
2333 | {
|
---|
2334 | push (@mostly_rms, "\t-rm -f $item");
|
---|
2335 | }
|
---|
2336 | elsif ($compile_clean_files{$item} == DIST_CLEAN)
|
---|
2337 | {
|
---|
2338 | push (@dist_rms, "\t-rm -f $item");
|
---|
2339 | }
|
---|
2340 | else
|
---|
2341 | {
|
---|
2342 | prog_error 'invalid entry in %compile_clean_files';
|
---|
2343 | }
|
---|
2344 | }
|
---|
2345 |
|
---|
2346 | my ($coms, $vars, $rules) =
|
---|
2347 | &file_contents_internal (1, "$libdir/am/compile.am",
|
---|
2348 | new Automake::Location,
|
---|
2349 | ('DEFAULT_INCLUDES' => $default_includes,
|
---|
2350 | 'MOSTLYRMS' => join ("\n", @mostly_rms),
|
---|
2351 | 'DISTRMS' => join ("\n", @dist_rms)));
|
---|
2352 | $output_vars .= $vars;
|
---|
2353 | $output_rules .= "$coms$rules";
|
---|
2354 |
|
---|
2355 | # Check for automatic de-ANSI-fication.
|
---|
2356 | if (option 'ansi2knr')
|
---|
2357 | {
|
---|
2358 | my ($ansi2knr_filename, $ansi2knr_where) = @{option 'ansi2knr'};
|
---|
2359 | my $ansi2knr_dir = '';
|
---|
2360 |
|
---|
2361 | require_variables ($ansi2knr_where, "option `ansi2knr' is used",
|
---|
2362 | TRUE, "ANSI2KNR", "U");
|
---|
2363 |
|
---|
2364 | # topdir is where ansi2knr should be.
|
---|
2365 | if ($ansi2knr_filename eq 'ansi2knr')
|
---|
2366 | {
|
---|
2367 | # Only require ansi2knr files if they should appear in
|
---|
2368 | # this directory.
|
---|
2369 | require_file ($ansi2knr_where, FOREIGN,
|
---|
2370 | 'ansi2knr.c', 'ansi2knr.1');
|
---|
2371 |
|
---|
2372 | # ansi2knr needs to be built before subdirs, so unshift it.
|
---|
2373 | unshift (@all, '$(ANSI2KNR)');
|
---|
2374 | }
|
---|
2375 | else
|
---|
2376 | {
|
---|
2377 | $ansi2knr_dir = dirname ($ansi2knr_filename);
|
---|
2378 | }
|
---|
2379 |
|
---|
2380 | $output_rules .= &file_contents ('ansi2knr',
|
---|
2381 | new Automake::Location,
|
---|
2382 | 'ANSI2KNR-DIR' => $ansi2knr_dir);
|
---|
2383 |
|
---|
2384 | }
|
---|
2385 | }
|
---|
2386 |
|
---|
2387 | # handle_libtool ()
|
---|
2388 | # -----------------
|
---|
2389 | # Handle libtool rules.
|
---|
2390 | sub handle_libtool
|
---|
2391 | {
|
---|
2392 | return unless var ('LIBTOOL');
|
---|
2393 |
|
---|
2394 | # Libtool requires some files, but only at top level.
|
---|
2395 | # (Starting with Libtool 2.0 we do not have to bother. These
|
---|
2396 | # requirements are done with AC_REQUIRE_AUX_FILE.)
|
---|
2397 | require_conf_file_with_macro (TRUE, 'LIBTOOL', FOREIGN, @libtool_files)
|
---|
2398 | if $relative_dir eq '.' && ! $libtool_new_api;
|
---|
2399 |
|
---|
2400 | my @libtool_rms;
|
---|
2401 | foreach my $item (sort keys %libtool_clean_directories)
|
---|
2402 | {
|
---|
2403 | my $dir = ($item eq '.') ? '' : "$item/";
|
---|
2404 | # .libs is for Unix, _libs for DOS.
|
---|
2405 | push (@libtool_rms, "\t-rm -rf ${dir}.libs ${dir}_libs");
|
---|
2406 | }
|
---|
2407 |
|
---|
2408 | check_user_variables 'LIBTOOLFLAGS';
|
---|
2409 |
|
---|
2410 | # Output the libtool compilation rules.
|
---|
2411 | $output_rules .= &file_contents ('libtool',
|
---|
2412 | new Automake::Location,
|
---|
2413 | LTRMS => join ("\n", @libtool_rms));
|
---|
2414 | }
|
---|
2415 |
|
---|
2416 | # handle_programs ()
|
---|
2417 | # ------------------
|
---|
2418 | # Handle C programs.
|
---|
2419 | sub handle_programs
|
---|
2420 | {
|
---|
2421 | my @proglist = &am_install_var ('progs', 'PROGRAMS',
|
---|
2422 | 'bin', 'sbin', 'libexec', 'pkglib',
|
---|
2423 | 'noinst', 'check');
|
---|
2424 | return if ! @proglist;
|
---|
2425 |
|
---|
2426 | my $seen_global_libobjs =
|
---|
2427 | var ('LDADD') && &handle_lib_objects ('', 'LDADD');
|
---|
2428 |
|
---|
2429 | foreach my $pair (@proglist)
|
---|
2430 | {
|
---|
2431 | my ($where, $one_file) = @$pair;
|
---|
2432 |
|
---|
2433 | my $seen_libobjs = 0;
|
---|
2434 | my $obj = get_object_extension '.$(OBJEXT)';
|
---|
2435 |
|
---|
2436 | # Strip any $(EXEEXT) suffix the user might have added, or this
|
---|
2437 | # will confuse &handle_source_transform and &check_canonical_spelling.
|
---|
2438 | # We'll add $(EXEEXT) back later anyway.
|
---|
2439 | $one_file =~ s/\$\(EXEEXT\)$//;
|
---|
2440 |
|
---|
2441 | $known_programs{$one_file} = $where;
|
---|
2442 |
|
---|
2443 | # Canonicalize names and check for misspellings.
|
---|
2444 | my $xname = &check_canonical_spelling ($one_file, '_LDADD', '_LDFLAGS',
|
---|
2445 | '_SOURCES', '_OBJECTS',
|
---|
2446 | '_DEPENDENCIES');
|
---|
2447 |
|
---|
2448 | $where->push_context ("while processing program `$one_file'");
|
---|
2449 | $where->set (INTERNAL->get);
|
---|
2450 |
|
---|
2451 | my $linker = &handle_source_transform ($xname, $one_file, $obj, $where,
|
---|
2452 | NONLIBTOOL => 1, LIBTOOL => 0);
|
---|
2453 |
|
---|
2454 | if (var ($xname . "_LDADD"))
|
---|
2455 | {
|
---|
2456 | $seen_libobjs = &handle_lib_objects ($xname, $xname . '_LDADD');
|
---|
2457 | }
|
---|
2458 | else
|
---|
2459 | {
|
---|
2460 | # User didn't define prog_LDADD override. So do it.
|
---|
2461 | &define_variable ($xname . '_LDADD', '$(LDADD)', $where);
|
---|
2462 |
|
---|
2463 | # This does a bit too much work. But we need it to
|
---|
2464 | # generate _DEPENDENCIES when appropriate.
|
---|
2465 | if (var ('LDADD'))
|
---|
2466 | {
|
---|
2467 | $seen_libobjs = &handle_lib_objects ($xname, 'LDADD');
|
---|
2468 | }
|
---|
2469 | }
|
---|
2470 |
|
---|
2471 | reject_var ($xname . '_LIBADD',
|
---|
2472 | "use `${xname}_LDADD', not `${xname}_LIBADD'");
|
---|
2473 |
|
---|
2474 | set_seen ($xname . '_DEPENDENCIES');
|
---|
2475 | set_seen ($xname . '_LDFLAGS');
|
---|
2476 |
|
---|
2477 | # Determine program to use for link.
|
---|
2478 | my $xlink = &define_per_target_linker_variable ($linker, $xname);
|
---|
2479 |
|
---|
2480 | # If the resulting program lies into a subdirectory,
|
---|
2481 | # make sure this directory will exist.
|
---|
2482 | my $dirstamp = require_build_directory_maybe ($one_file);
|
---|
2483 |
|
---|
2484 | $output_rules .= &file_contents ('program',
|
---|
2485 | $where,
|
---|
2486 | PROGRAM => $one_file,
|
---|
2487 | XPROGRAM => $xname,
|
---|
2488 | XLINK => $xlink,
|
---|
2489 | DIRSTAMP => $dirstamp,
|
---|
2490 | EXEEXT => '$(EXEEXT)');
|
---|
2491 |
|
---|
2492 | if ($seen_libobjs || $seen_global_libobjs)
|
---|
2493 | {
|
---|
2494 | if (var ($xname . '_LDADD'))
|
---|
2495 | {
|
---|
2496 | &check_libobjs_sources ($xname, $xname . '_LDADD');
|
---|
2497 | }
|
---|
2498 | elsif (var ('LDADD'))
|
---|
2499 | {
|
---|
2500 | &check_libobjs_sources ($xname, 'LDADD');
|
---|
2501 | }
|
---|
2502 | }
|
---|
2503 | }
|
---|
2504 | }
|
---|
2505 |
|
---|
2506 |
|
---|
2507 | # handle_libraries ()
|
---|
2508 | # -------------------
|
---|
2509 | # Handle libraries.
|
---|
2510 | sub handle_libraries
|
---|
2511 | {
|
---|
2512 | my @liblist = &am_install_var ('libs', 'LIBRARIES',
|
---|
2513 | 'lib', 'pkglib', 'noinst', 'check');
|
---|
2514 | return if ! @liblist;
|
---|
2515 |
|
---|
2516 | my @prefix = am_primary_prefixes ('LIBRARIES', 0, 'lib', 'pkglib',
|
---|
2517 | 'noinst', 'check');
|
---|
2518 |
|
---|
2519 | if (@prefix)
|
---|
2520 | {
|
---|
2521 | my $var = rvar ($prefix[0] . '_LIBRARIES');
|
---|
2522 | $var->requires_variables ('library used', 'RANLIB');
|
---|
2523 | }
|
---|
2524 |
|
---|
2525 | &define_variable ('AR', 'ar', INTERNAL);
|
---|
2526 | &define_variable ('ARFLAGS', 'cru', INTERNAL);
|
---|
2527 |
|
---|
2528 | foreach my $pair (@liblist)
|
---|
2529 | {
|
---|
2530 | my ($where, $onelib) = @$pair;
|
---|
2531 |
|
---|
2532 | my $seen_libobjs = 0;
|
---|
2533 | # Check that the library fits the standard naming convention.
|
---|
2534 | my $bn = basename ($onelib);
|
---|
2535 | if ($bn !~ /^lib.*\.a$/)
|
---|
2536 | {
|
---|
2537 | $bn =~ s/^(?:lib)?(.*?)(?:\.[^.]*)?$/lib$1.a/;
|
---|
2538 | my $suggestion = dirname ($onelib) . "/$bn";
|
---|
2539 | $suggestion =~ s|^\./||g;
|
---|
2540 | msg ('error-gnu/warn', $where,
|
---|
2541 | "`$onelib' is not a standard library name\n"
|
---|
2542 | . "did you mean `$suggestion'?")
|
---|
2543 | }
|
---|
2544 |
|
---|
2545 | $where->push_context ("while processing library `$onelib'");
|
---|
2546 | $where->set (INTERNAL->get);
|
---|
2547 |
|
---|
2548 | my $obj = get_object_extension '.$(OBJEXT)';
|
---|
2549 |
|
---|
2550 | # Canonicalize names and check for misspellings.
|
---|
2551 | my $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_SOURCES',
|
---|
2552 | '_OBJECTS', '_DEPENDENCIES',
|
---|
2553 | '_AR');
|
---|
2554 |
|
---|
2555 | if (! var ($xlib . '_AR'))
|
---|
2556 | {
|
---|
2557 | &define_variable ($xlib . '_AR', '$(AR) $(ARFLAGS)', $where);
|
---|
2558 | }
|
---|
2559 |
|
---|
2560 | # Generate support for conditional object inclusion in
|
---|
2561 | # libraries.
|
---|
2562 | if (var ($xlib . '_LIBADD'))
|
---|
2563 | {
|
---|
2564 | if (&handle_lib_objects ($xlib, $xlib . '_LIBADD'))
|
---|
2565 | {
|
---|
2566 | $seen_libobjs = 1;
|
---|
2567 | }
|
---|
2568 | }
|
---|
2569 | else
|
---|
2570 | {
|
---|
2571 | &define_variable ($xlib . "_LIBADD", '', $where);
|
---|
2572 | }
|
---|
2573 |
|
---|
2574 | reject_var ($xlib . '_LDADD',
|
---|
2575 | "use `${xlib}_LIBADD', not `${xlib}_LDADD'");
|
---|
2576 |
|
---|
2577 | # Make sure we at look at this.
|
---|
2578 | set_seen ($xlib . '_DEPENDENCIES');
|
---|
2579 |
|
---|
2580 | &handle_source_transform ($xlib, $onelib, $obj, $where,
|
---|
2581 | NONLIBTOOL => 1, LIBTOOL => 0);
|
---|
2582 |
|
---|
2583 | # If the resulting library lies into a subdirectory,
|
---|
2584 | # make sure this directory will exist.
|
---|
2585 | my $dirstamp = require_build_directory_maybe ($onelib);
|
---|
2586 |
|
---|
2587 | $output_rules .= &file_contents ('library',
|
---|
2588 | $where,
|
---|
2589 | LIBRARY => $onelib,
|
---|
2590 | XLIBRARY => $xlib,
|
---|
2591 | DIRSTAMP => $dirstamp);
|
---|
2592 |
|
---|
2593 | if ($seen_libobjs)
|
---|
2594 | {
|
---|
2595 | if (var ($xlib . '_LIBADD'))
|
---|
2596 | {
|
---|
2597 | &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
|
---|
2598 | }
|
---|
2599 | }
|
---|
2600 | }
|
---|
2601 | }
|
---|
2602 |
|
---|
2603 |
|
---|
2604 | # handle_ltlibraries ()
|
---|
2605 | # ---------------------
|
---|
2606 | # Handle shared libraries.
|
---|
2607 | sub handle_ltlibraries
|
---|
2608 | {
|
---|
2609 | my @liblist = &am_install_var ('ltlib', 'LTLIBRARIES',
|
---|
2610 | 'noinst', 'lib', 'pkglib', 'check');
|
---|
2611 | return if ! @liblist;
|
---|
2612 |
|
---|
2613 | my @prefix = am_primary_prefixes ('LTLIBRARIES', 0, 'lib', 'pkglib',
|
---|
2614 | 'noinst', 'check');
|
---|
2615 |
|
---|
2616 | if (@prefix)
|
---|
2617 | {
|
---|
2618 | my $var = rvar ($prefix[0] . '_LTLIBRARIES');
|
---|
2619 | $var->requires_variables ('Libtool library used', 'LIBTOOL');
|
---|
2620 | }
|
---|
2621 |
|
---|
2622 | my %instdirs = ();
|
---|
2623 | my %instconds = ();
|
---|
2624 | my %liblocations = (); # Location (in Makefile.am) of each library.
|
---|
2625 |
|
---|
2626 | foreach my $key (@prefix)
|
---|
2627 | {
|
---|
2628 | # Get the installation directory of each library.
|
---|
2629 | (my $dir = $key) =~ s/^nobase_//;
|
---|
2630 | my $var = rvar ($key . '_LTLIBRARIES');
|
---|
2631 |
|
---|
2632 | # We reject libraries which are installed in several places
|
---|
2633 | # in the same condition, because we can only specify one
|
---|
2634 | # `-rpath' option.
|
---|
2635 | $var->traverse_recursively
|
---|
2636 | (sub
|
---|
2637 | {
|
---|
2638 | my ($var, $val, $cond, $full_cond) = @_;
|
---|
2639 | my $hcond = $full_cond->human;
|
---|
2640 | my $where = $var->rdef ($cond)->location;
|
---|
2641 | # A library cannot be installed in different directory
|
---|
2642 | # in overlapping conditions.
|
---|
2643 | if (exists $instconds{$val})
|
---|
2644 | {
|
---|
2645 | my ($msg, $acond) =
|
---|
2646 | $instconds{$val}->ambiguous_p ($val, $full_cond);
|
---|
2647 |
|
---|
2648 | if ($msg)
|
---|
2649 | {
|
---|
2650 | error ($where, $msg, partial => 1);
|
---|
2651 |
|
---|
2652 | my $dirtxt = "installed in `$dir'";
|
---|
2653 | $dirtxt = "built for `$dir'"
|
---|
2654 | if $dir eq 'EXTRA' || $dir eq 'noinst' || $dir eq 'check';
|
---|
2655 | my $dircond =
|
---|
2656 | $full_cond->true ? "" : " in condition $hcond";
|
---|
2657 |
|
---|
2658 | error ($where, "`$val' should be $dirtxt$dircond ...",
|
---|
2659 | partial => 1);
|
---|
2660 |
|
---|
2661 | my $hacond = $acond->human;
|
---|
2662 | my $adir = $instdirs{$val}{$acond};
|
---|
2663 | my $adirtxt = "installed in `$adir'";
|
---|
2664 | $adirtxt = "built for `$adir'"
|
---|
2665 | if ($adir eq 'EXTRA' || $adir eq 'noinst'
|
---|
2666 | || $adir eq 'check');
|
---|
2667 | my $adircond = $acond->true ? "" : " in condition $hacond";
|
---|
2668 |
|
---|
2669 | my $onlyone = ($dir ne $adir) ?
|
---|
2670 | ("\nLibtool libraries can be built for only one "
|
---|
2671 | . "destination.") : "";
|
---|
2672 |
|
---|
2673 | error ($liblocations{$val}{$acond},
|
---|
2674 | "... and should also be $adirtxt$adircond.$onlyone");
|
---|
2675 | return;
|
---|
2676 | }
|
---|
2677 | }
|
---|
2678 | else
|
---|
2679 | {
|
---|
2680 | $instconds{$val} = new Automake::DisjConditions;
|
---|
2681 | }
|
---|
2682 | $instdirs{$val}{$full_cond} = $dir;
|
---|
2683 | $liblocations{$val}{$full_cond} = $where;
|
---|
2684 | $instconds{$val} = $instconds{$val}->merge ($full_cond);
|
---|
2685 | },
|
---|
2686 | sub
|
---|
2687 | {
|
---|
2688 | return ();
|
---|
2689 | },
|
---|
2690 | skip_ac_subst => 1);
|
---|
2691 | }
|
---|
2692 |
|
---|
2693 | foreach my $pair (@liblist)
|
---|
2694 | {
|
---|
2695 | my ($where, $onelib) = @$pair;
|
---|
2696 |
|
---|
2697 | my $seen_libobjs = 0;
|
---|
2698 | my $obj = get_object_extension '.lo';
|
---|
2699 |
|
---|
2700 | # Canonicalize names and check for misspellings.
|
---|
2701 | my $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_LDFLAGS',
|
---|
2702 | '_SOURCES', '_OBJECTS',
|
---|
2703 | '_DEPENDENCIES');
|
---|
2704 |
|
---|
2705 | # Check that the library fits the standard naming convention.
|
---|
2706 | my $libname_rx = '^lib.*\.la';
|
---|
2707 | my $ldvar = var ("${xlib}_LDFLAGS") || var ('AM_LDFLAGS');
|
---|
2708 | my $ldvar2 = var ('LDFLAGS');
|
---|
2709 | if (($ldvar && grep (/-module/, $ldvar->value_as_list_recursive))
|
---|
2710 | || ($ldvar2 && grep (/-module/, $ldvar2->value_as_list_recursive)))
|
---|
2711 | {
|
---|
2712 | # Relax name checking for libtool modules.
|
---|
2713 | $libname_rx = '\.la';
|
---|
2714 | }
|
---|
2715 |
|
---|
2716 | my $bn = basename ($onelib);
|
---|
2717 | if ($bn !~ /$libname_rx$/)
|
---|
2718 | {
|
---|
2719 | my $type = 'library';
|
---|
2720 | if ($libname_rx eq '\.la')
|
---|
2721 | {
|
---|
2722 | $bn =~ s/^(lib|)(.*?)(?:\.[^.]*)?$/$1$2.la/;
|
---|
2723 | $type = 'module';
|
---|
2724 | }
|
---|
2725 | else
|
---|
2726 | {
|
---|
2727 | $bn =~ s/^(?:lib)?(.*?)(?:\.[^.]*)?$/lib$1.la/;
|
---|
2728 | }
|
---|
2729 | my $suggestion = dirname ($onelib) . "/$bn";
|
---|
2730 | $suggestion =~ s|^\./||g;
|
---|
2731 | msg ('error-gnu/warn', $where,
|
---|
2732 | "`$onelib' is not a standard libtool $type name\n"
|
---|
2733 | . "did you mean `$suggestion'?")
|
---|
2734 | }
|
---|
2735 |
|
---|
2736 | $where->push_context ("while processing Libtool library `$onelib'");
|
---|
2737 | $where->set (INTERNAL->get);
|
---|
2738 |
|
---|
2739 | # Make sure we look at these.
|
---|
2740 | set_seen ($xlib . '_LDFLAGS');
|
---|
2741 | set_seen ($xlib . '_DEPENDENCIES');
|
---|
2742 |
|
---|
2743 | # Generate support for conditional object inclusion in
|
---|
2744 | # libraries.
|
---|
2745 | if (var ($xlib . '_LIBADD'))
|
---|
2746 | {
|
---|
2747 | if (&handle_lib_objects ($xlib, $xlib . '_LIBADD'))
|
---|
2748 | {
|
---|
2749 | $seen_libobjs = 1;
|
---|
2750 | }
|
---|
2751 | }
|
---|
2752 | else
|
---|
2753 | {
|
---|
2754 | &define_variable ($xlib . "_LIBADD", '', $where);
|
---|
2755 | }
|
---|
2756 |
|
---|
2757 | reject_var ("${xlib}_LDADD",
|
---|
2758 | "use `${xlib}_LIBADD', not `${xlib}_LDADD'");
|
---|
2759 |
|
---|
2760 |
|
---|
2761 | my $linker = &handle_source_transform ($xlib, $onelib, $obj, $where,
|
---|
2762 | NONLIBTOOL => 0, LIBTOOL => 1);
|
---|
2763 |
|
---|
2764 | # Determine program to use for link.
|
---|
2765 | my $xlink = &define_per_target_linker_variable ($linker, $xlib);
|
---|
2766 |
|
---|
2767 | my $rpathvar = "am_${xlib}_rpath";
|
---|
2768 | my $rpath = "\$($rpathvar)";
|
---|
2769 | foreach my $rcond ($instconds{$onelib}->conds)
|
---|
2770 | {
|
---|
2771 | my $val;
|
---|
2772 | if ($instdirs{$onelib}{$rcond} eq 'EXTRA'
|
---|
2773 | || $instdirs{$onelib}{$rcond} eq 'noinst'
|
---|
2774 | || $instdirs{$onelib}{$rcond} eq 'check')
|
---|
2775 | {
|
---|
2776 | # It's an EXTRA_ library, so we can't specify -rpath,
|
---|
2777 | # because we don't know where the library will end up.
|
---|
2778 | # The user probably knows, but generally speaking automake
|
---|
2779 | # doesn't -- and in fact configure could decide
|
---|
2780 | # dynamically between two different locations.
|
---|
2781 | $val = '';
|
---|
2782 | }
|
---|
2783 | else
|
---|
2784 | {
|
---|
2785 | $val = ('-rpath $(' . $instdirs{$onelib}{$rcond} . 'dir)');
|
---|
2786 | }
|
---|
2787 | if ($rcond->true)
|
---|
2788 | {
|
---|
2789 | # If $rcond is true there is only one condition and
|
---|
2790 | # there is no point defining an helper variable.
|
---|
2791 | $rpath = $val;
|
---|
2792 | }
|
---|
2793 | else
|
---|
2794 | {
|
---|
2795 | define_pretty_variable ($rpathvar, $rcond, INTERNAL, $val);
|
---|
2796 | }
|
---|
2797 | }
|
---|
2798 |
|
---|
2799 | # If the resulting library lies into a subdirectory,
|
---|
2800 | # make sure this directory will exist.
|
---|
2801 | my $dirstamp = require_build_directory_maybe ($onelib);
|
---|
2802 |
|
---|
2803 | # Remember to cleanup .libs/ in this directory.
|
---|
2804 | my $dirname = dirname $onelib;
|
---|
2805 | $libtool_clean_directories{$dirname} = 1;
|
---|
2806 |
|
---|
2807 | $output_rules .= &file_contents ('ltlibrary',
|
---|
2808 | $where,
|
---|
2809 | LTLIBRARY => $onelib,
|
---|
2810 | XLTLIBRARY => $xlib,
|
---|
2811 | RPATH => $rpath,
|
---|
2812 | XLINK => $xlink,
|
---|
2813 | DIRSTAMP => $dirstamp);
|
---|
2814 | if ($seen_libobjs)
|
---|
2815 | {
|
---|
2816 | if (var ($xlib . '_LIBADD'))
|
---|
2817 | {
|
---|
2818 | &check_libobjs_sources ($xlib, $xlib . '_LIBADD');
|
---|
2819 | }
|
---|
2820 | }
|
---|
2821 | }
|
---|
2822 | }
|
---|
2823 |
|
---|
2824 | # See if any _SOURCES variable were misspelled.
|
---|
2825 | sub check_typos ()
|
---|
2826 | {
|
---|
2827 | # It is ok if the user sets this particular variable.
|
---|
2828 | set_seen 'AM_LDFLAGS';
|
---|
2829 |
|
---|
2830 | foreach my $primary ('SOURCES', 'LIBADD', 'LDADD', 'LDFLAGS', 'DEPENDENCIES')
|
---|
2831 | {
|
---|
2832 | foreach my $var (variables $primary)
|
---|
2833 | {
|
---|
2834 | my $varname = $var->name;
|
---|
2835 | # A configure variable is always legitimate.
|
---|
2836 | next if exists $configure_vars{$varname};
|
---|
2837 |
|
---|
2838 | for my $cond ($var->conditions->conds)
|
---|
2839 | {
|
---|
2840 | $varname =~ /^(?:nobase_)?(?:dist_|nodist_)?(.*)_[[:alnum:]]+$/;
|
---|
2841 | msg_var ('syntax', $var, "variable `$varname' is defined but no"
|
---|
2842 | . " program or\nlibrary has `$1' as canonic name"
|
---|
2843 | . " (possible typo)")
|
---|
2844 | unless $var->rdef ($cond)->seen;
|
---|
2845 | }
|
---|
2846 | }
|
---|
2847 | }
|
---|
2848 | }
|
---|
2849 |
|
---|
2850 |
|
---|
2851 | # Handle scripts.
|
---|
2852 | sub handle_scripts
|
---|
2853 | {
|
---|
2854 | # NOTE we no longer automatically clean SCRIPTS, because it is
|
---|
2855 | # useful to sometimes distribute scripts verbatim. This happens
|
---|
2856 | # e.g. in Automake itself.
|
---|
2857 | &am_install_var ('-candist', 'scripts', 'SCRIPTS',
|
---|
2858 | 'bin', 'sbin', 'libexec', 'pkgdata',
|
---|
2859 | 'noinst', 'check');
|
---|
2860 | }
|
---|
2861 |
|
---|
2862 |
|
---|
2863 |
|
---|
2864 |
|
---|
2865 | ## ------------------------ ##
|
---|
2866 | ## Handling Texinfo files. ##
|
---|
2867 | ## ------------------------ ##
|
---|
2868 |
|
---|
2869 | # ($OUTFILE, $VFILE, @CLEAN_FILES)
|
---|
2870 | # &scan_texinfo_file ($FILENAME)
|
---|
2871 | # ------------------------------
|
---|
2872 | # $OUTFILE - name of the info file produced by $FILENAME.
|
---|
2873 | # $VFILE - name of the version.texi file used (undef if none).
|
---|
2874 | # @CLEAN_FILES - list of byproducts (indexes etc.)
|
---|
2875 | sub scan_texinfo_file ($)
|
---|
2876 | {
|
---|
2877 | my ($filename) = @_;
|
---|
2878 |
|
---|
2879 | # Some of the following extensions are always created, no matter
|
---|
2880 | # whether indexes are used or not. Other (like cps, fns, ... pgs)
|
---|
2881 | # are only created when they are used. We used to scan $FILENAME
|
---|
2882 | # for their use, but that is not enough: they could be used in
|
---|
2883 | # included files. We can't scan included files because we don't
|
---|
2884 | # know the include path. Therefore we always erase these files, no
|
---|
2885 | # matter whether they are used or not.
|
---|
2886 | #
|
---|
2887 | # (tmp is only created if an @macro is used and a certain e-TeX
|
---|
2888 | # feature is not available.)
|
---|
2889 | my %clean_suffixes =
|
---|
2890 | map { $_ => 1 } (qw(aux log toc tmp
|
---|
2891 | cp cps
|
---|
2892 | fn fns
|
---|
2893 | ky kys
|
---|
2894 | vr vrs
|
---|
2895 | tp tps
|
---|
2896 | pg pgs)); # grep 'new.*index' texinfo.tex
|
---|
2897 |
|
---|
2898 | my $texi = new Automake::XFile "< $filename";
|
---|
2899 | verb "reading $filename";
|
---|
2900 |
|
---|
2901 | my ($outfile, $vfile);
|
---|
2902 | while ($_ = $texi->getline)
|
---|
2903 | {
|
---|
2904 | if (/^\@setfilename +(\S+)/)
|
---|
2905 | {
|
---|
2906 | # Honor only the first @setfilename. (It's possible to have
|
---|
2907 | # more occurrences later if the manual shows examples of how
|
---|
2908 | # to use @setfilename...)
|
---|
2909 | next if $outfile;
|
---|
2910 |
|
---|
2911 | $outfile = $1;
|
---|
2912 | if ($outfile =~ /\.([^.]+)$/ && $1 ne 'info')
|
---|
2913 | {
|
---|
2914 | error ("$filename:$.",
|
---|
2915 | "output `$outfile' has unrecognized extension");
|
---|
2916 | return;
|
---|
2917 | }
|
---|
2918 | }
|
---|
2919 | # A "version.texi" file is actually any file whose name matches
|
---|
2920 | # "vers*.texi".
|
---|
2921 | elsif (/^\@include\s+(vers[^.]*\.texi)\s*$/)
|
---|
2922 | {
|
---|
2923 | $vfile = $1;
|
---|
2924 | }
|
---|
2925 |
|
---|
2926 | # Try to find new or unused indexes.
|
---|
2927 |
|
---|
2928 | # Creating a new category of index.
|
---|
2929 | elsif (/^\@def(code)?index (\w+)/)
|
---|
2930 | {
|
---|
2931 | $clean_suffixes{$2} = 1;
|
---|
2932 | $clean_suffixes{"$2s"} = 1;
|
---|
2933 | }
|
---|
2934 |
|
---|
2935 | # Merging an index into an another.
|
---|
2936 | elsif (/^\@syn(code)?index (\w+) (\w+)/)
|
---|
2937 | {
|
---|
2938 | delete $clean_suffixes{"$2s"};
|
---|
2939 | $clean_suffixes{"$3s"} = 1;
|
---|
2940 | }
|
---|
2941 |
|
---|
2942 | }
|
---|
2943 |
|
---|
2944 | if (! $outfile)
|
---|
2945 | {
|
---|
2946 | err_am "`$filename' missing \@setfilename";
|
---|
2947 | return;
|
---|
2948 | }
|
---|
2949 |
|
---|
2950 | my $infobase = basename ($filename);
|
---|
2951 | $infobase =~ s/\.te?xi(nfo)?$//;
|
---|
2952 | return ($outfile, $vfile,
|
---|
2953 | map { "$infobase.$_" } (sort keys %clean_suffixes));
|
---|
2954 | }
|
---|
2955 |
|
---|
2956 |
|
---|
2957 | # ($DIRSTAMP, @CLEAN_FILES)
|
---|
2958 | # output_texinfo_build_rules ($SOURCE, $DEST, $INSRC, @DEPENDENCIES)
|
---|
2959 | # ------------------------------------------------------------------
|
---|
2960 | # SOURCE - the source Texinfo file
|
---|
2961 | # DEST - the destination Info file
|
---|
2962 | # INSRC - wether DEST should be built in the source tree
|
---|
2963 | # DEPENDENCIES - known dependencies
|
---|
2964 | sub output_texinfo_build_rules ($$$@)
|
---|
2965 | {
|
---|
2966 | my ($source, $dest, $insrc, @deps) = @_;
|
---|
2967 |
|
---|
2968 | # Split `a.texi' into `a' and `.texi'.
|
---|
2969 | my ($spfx, $ssfx) = ($source =~ /^(.*?)(\.[^.]*)?$/);
|
---|
2970 | my ($dpfx, $dsfx) = ($dest =~ /^(.*?)(\.[^.]*)?$/);
|
---|
2971 |
|
---|
2972 | $ssfx ||= "";
|
---|
2973 | $dsfx ||= "";
|
---|
2974 |
|
---|
2975 | # We can output two kinds of rules: the "generic" rules use Make
|
---|
2976 | # suffix rules and are appropriate when $source and $dest do not lie
|
---|
2977 | # in a sub-directory; the "specific" rules are needed in the other
|
---|
2978 | # case.
|
---|
2979 | #
|
---|
2980 | # The former are output only once (this is not really apparent here,
|
---|
2981 | # but just remember that some logic deeper in Automake will not
|
---|
2982 | # output the same rule twice); while the later need to be output for
|
---|
2983 | # each Texinfo source.
|
---|
2984 | my $generic;
|
---|
2985 | my $makeinfoflags;
|
---|
2986 | my $sdir = dirname $source;
|
---|
2987 | if ($sdir eq '.' && dirname ($dest) eq '.')
|
---|
2988 | {
|
---|
2989 | $generic = 1;
|
---|
2990 | $makeinfoflags = '-I $(srcdir)';
|
---|
2991 | }
|
---|
2992 | else
|
---|
2993 | {
|
---|
2994 | $generic = 0;
|
---|
2995 | $makeinfoflags = "-I $sdir -I \$(srcdir)/$sdir";
|
---|
2996 | }
|
---|
2997 |
|
---|
2998 | # A directory can contain two kinds of info files: some built in the
|
---|
2999 | # source tree, and some built in the build tree. The rules are
|
---|
3000 | # different in each case. However we cannot output two different
|
---|
3001 | # set of generic rules. Because in-source builds are more usual, we
|
---|
3002 | # use generic rules in this case and fall back to "specific" rules
|
---|
3003 | # for build-dir builds. (It should not be a problem to invert this
|
---|
3004 | # if needed.)
|
---|
3005 | $generic = 0 unless $insrc;
|
---|
3006 |
|
---|
3007 | # We cannot use a suffix rule to build info files with an empty
|
---|
3008 | # extension. Otherwise we would output a single suffix inference
|
---|
3009 | # rule, with separate dependencies, as in
|
---|
3010 | #
|
---|
3011 | # .texi:
|
---|
3012 | # $(MAKEINFO) ...
|
---|
3013 | # foo.info: foo.texi
|
---|
3014 | #
|
---|
3015 | # which confuse Solaris make. (See the Autoconf manual for
|
---|
3016 | # details.) Therefore we use a specific rule in this case. This
|
---|
3017 | # applies to info files only (dvi and pdf files always have an
|
---|
3018 | # extension).
|
---|
3019 | my $generic_info = ($generic && $dsfx) ? 1 : 0;
|
---|
3020 |
|
---|
3021 | # If the resulting file lie into a subdirectory,
|
---|
3022 | # make sure this directory will exist.
|
---|
3023 | my $dirstamp = require_build_directory_maybe ($dest);
|
---|
3024 |
|
---|
3025 | my $dipfx = ($insrc ? '$(srcdir)/' : '') . $dpfx;
|
---|
3026 |
|
---|
3027 | $output_rules .= file_contents ('texibuild',
|
---|
3028 | new Automake::Location,
|
---|
3029 | DEPS => "@deps",
|
---|
3030 | DEST_PREFIX => $dpfx,
|
---|
3031 | DEST_INFO_PREFIX => $dipfx,
|
---|
3032 | DEST_SUFFIX => $dsfx,
|
---|
3033 | DIRSTAMP => $dirstamp,
|
---|
3034 | GENERIC => $generic,
|
---|
3035 | GENERIC_INFO => $generic_info,
|
---|
3036 | INSRC => $insrc,
|
---|
3037 | MAKEINFOFLAGS => $makeinfoflags,
|
---|
3038 | SOURCE => ($generic
|
---|
3039 | ? '$<' : $source),
|
---|
3040 | SOURCE_INFO => ($generic_info
|
---|
3041 | ? '$<' : $source),
|
---|
3042 | SOURCE_REAL => $source,
|
---|
3043 | SOURCE_SUFFIX => $ssfx,
|
---|
3044 | );
|
---|
3045 | return ($dirstamp, "$dpfx.dvi", "$dpfx.pdf", "$dpfx.ps", "$dpfx.html");
|
---|
3046 | }
|
---|
3047 |
|
---|
3048 |
|
---|
3049 | # $TEXICLEANS
|
---|
3050 | # handle_texinfo_helper ($info_texinfos)
|
---|
3051 | # --------------------------------------
|
---|
3052 | # Handle all Texinfo source; helper for handle_texinfo.
|
---|
3053 | sub handle_texinfo_helper ($)
|
---|
3054 | {
|
---|
3055 | my ($info_texinfos) = @_;
|
---|
3056 | my (@infobase, @info_deps_list, @texi_deps);
|
---|
3057 | my %versions;
|
---|
3058 | my $done = 0;
|
---|
3059 | my @texi_cleans;
|
---|
3060 |
|
---|
3061 | # Build a regex matching user-cleaned files.
|
---|
3062 | my $d = var 'DISTCLEANFILES';
|
---|
3063 | my $c = var 'CLEANFILES';
|
---|
3064 | my @f = ();
|
---|
3065 | push @f, $d->value_as_list_recursive (inner_expand => 1) if $d;
|
---|
3066 | push @f, $c->value_as_list_recursive (inner_expand => 1) if $c;
|
---|
3067 | @f = map { s|[^A-Za-z_0-9*\[\]\-]|\\$&|g; s|\*|[^/]*|g; $_; } @f;
|
---|
3068 | my $user_cleaned_files = '^(?:' . join ('|', @f) . ')$';
|
---|
3069 |
|
---|
3070 | foreach my $texi
|
---|
3071 | ($info_texinfos->value_as_list_recursive (inner_expand => 1))
|
---|
3072 | {
|
---|
3073 | my $infobase = $texi;
|
---|
3074 | $infobase =~ s/\.(txi|texinfo|texi)$//;
|
---|
3075 |
|
---|
3076 | if ($infobase eq $texi)
|
---|
3077 | {
|
---|
3078 | # FIXME: report line number.
|
---|
3079 | err_am "texinfo file `$texi' has unrecognized extension";
|
---|
3080 | next;
|
---|
3081 | }
|
---|
3082 |
|
---|
3083 | push @infobase, $infobase;
|
---|
3084 |
|
---|
3085 | # If 'version.texi' is referenced by input file, then include
|
---|
3086 | # automatic versioning capability.
|
---|
3087 | my ($out_file, $vtexi, @clean_files) =
|
---|
3088 | scan_texinfo_file ("$relative_dir/$texi")
|
---|
3089 | or next;
|
---|
3090 | push (@texi_cleans, @clean_files);
|
---|
3091 |
|
---|
3092 | # If the Texinfo source is in a subdirectory, create the
|
---|
3093 | # resulting info in this subdirectory. If it is in the current
|
---|
3094 | # directory, try hard to not prefix "./" because it breaks the
|
---|
3095 | # generic rules.
|
---|
3096 | my $outdir = dirname ($texi) . '/';
|
---|
3097 | $outdir = "" if $outdir eq './';
|
---|
3098 | $out_file = $outdir . $out_file;
|
---|
3099 |
|
---|
3100 | # Until Automake 1.6.3, .info files were built in the
|
---|
3101 | # source tree. This was an obstacle to the support of
|
---|
3102 | # non-distributed .info files, and non-distributed .texi
|
---|
3103 | # files.
|
---|
3104 | #
|
---|
3105 | # * Non-distributed .texi files is important in some packages
|
---|
3106 | # where .texi files are built at make time, probably using
|
---|
3107 | # other binaries built in the package itself, maybe using
|
---|
3108 | # tools or information found on the build host. Because
|
---|
3109 | # these files are not distributed they are always rebuilt
|
---|
3110 | # at make time; they should therefore not lie in the source
|
---|
3111 | # directory. One plan was to support this using
|
---|
3112 | # nodist_info_TEXINFOS or something similar. (Doing this
|
---|
3113 | # requires some sanity checks. For instance Automake should
|
---|
3114 | # not allow:
|
---|
3115 | # dist_info_TEXINFO = foo.texi
|
---|
3116 | # nodist_foo_TEXINFO = included.texi
|
---|
3117 | # because a distributed file should never depend on a
|
---|
3118 | # non-distributed file.)
|
---|
3119 | #
|
---|
3120 | # * If .texi files are not distributed, then .info files should
|
---|
3121 | # not be distributed either. There are also cases where one
|
---|
3122 | # want to distribute .texi files, but do not want to
|
---|
3123 | # distribute the .info files. For instance the Texinfo package
|
---|
3124 | # distributes the tool used to build these files; it would
|
---|
3125 | # be a waste of space to distribute them. It's not clear
|
---|
3126 | # which syntax we should use to indicate that .info files should
|
---|
3127 | # not be distributed. Akim Demaille suggested that eventually
|
---|
3128 | # we switch to a new syntax:
|
---|
3129 | # | Maybe we should take some inspiration from what's already
|
---|
3130 | # | done in the rest of Automake. Maybe there is too much
|
---|
3131 | # | syntactic sugar here, and you want
|
---|
3132 | # | nodist_INFO = bar.info
|
---|
3133 | # | dist_bar_info_SOURCES = bar.texi
|
---|
3134 | # | bar_texi_DEPENDENCIES = foo.texi
|
---|
3135 | # | with a bit of magic to have bar.info represent the whole
|
---|
3136 | # | bar*info set. That's a lot more verbose that the current
|
---|
3137 | # | situation, but it is # not new, hence the user has less
|
---|
3138 | # | to learn.
|
---|
3139 | # |
|
---|
3140 | # | But there is still too much room for meaningless specs:
|
---|
3141 | # | nodist_INFO = bar.info
|
---|
3142 | # | dist_bar_info_SOURCES = bar.texi
|
---|
3143 | # | dist_PS = bar.ps something-written-by-hand.ps
|
---|
3144 | # | nodist_bar_ps_SOURCES = bar.texi
|
---|
3145 | # | bar_texi_DEPENDENCIES = foo.texi
|
---|
3146 | # | here bar.texi is dist_ in line 2, and nodist_ in 4.
|
---|
3147 | #
|
---|
3148 | # Back to the point, it should be clear that in order to support
|
---|
3149 | # non-distributed .info files, we need to build them in the
|
---|
3150 | # build tree, not in the source tree (non-distributed .texi
|
---|
3151 | # files are less of a problem, because we do not output build
|
---|
3152 | # rules for them). In Automake 1.7 .info build rules have been
|
---|
3153 | # largely cleaned up so that .info files get always build in the
|
---|
3154 | # build tree, even when distributed. The idea was that
|
---|
3155 | # (1) if during a VPATH build the .info file was found to be
|
---|
3156 | # absent or out-of-date (in the source tree or in the
|
---|
3157 | # build tree), Make would rebuild it in the build tree.
|
---|
3158 | # If an up-to-date source-tree of the .info file existed,
|
---|
3159 | # make would not rebuild it in the build tree.
|
---|
3160 | # (2) having two copies of .info files, one in the source tree
|
---|
3161 | # and one (newer) in the build tree is not a problem
|
---|
3162 | # because `make dist' always pick files in the build tree
|
---|
3163 | # first.
|
---|
3164 | # However it turned out the be a bad idea for several reasons:
|
---|
3165 | # * Tru64, OpenBSD, and FreeBSD (not NetBSD) Make do not behave
|
---|
3166 | # like GNU Make on point (1) above. These implementations
|
---|
3167 | # of Make would always rebuild .info files in the build
|
---|
3168 | # tree, even if such files were up to date in the source
|
---|
3169 | # tree. Consequently, it was impossible to perform a VPATH
|
---|
3170 | # build of a package containing Texinfo files using these
|
---|
3171 | # Make implementations.
|
---|
3172 | # (Refer to the Autoconf Manual, section "Limitation of
|
---|
3173 | # Make", paragraph "VPATH", item "target lookup", for
|
---|
3174 | # an account of the differences between these
|
---|
3175 | # implementations.)
|
---|
3176 | # * The GNU Coding Standards require these files to be built
|
---|
3177 | # in the source-tree (when they are distributed, that is).
|
---|
3178 | # * Keeping a fresher copy of distributed files in the
|
---|
3179 | # build tree can be annoying during development because
|
---|
3180 | # - if the files is kept under CVS, you really want it
|
---|
3181 | # to be updated in the source tree
|
---|
3182 | # - it is confusing that `make distclean' does not erase
|
---|
3183 | # all files in the build tree.
|
---|
3184 | #
|
---|
3185 | # Consequently, starting with Automake 1.8, .info files are
|
---|
3186 | # built in the source tree again. Because we still plan to
|
---|
3187 | # support non-distributed .info files at some point, we
|
---|
3188 | # have a single variable ($INSRC) that controls whether
|
---|
3189 | # the current .info file must be built in the source tree
|
---|
3190 | # or in the build tree. Actually this variable is switched
|
---|
3191 | # off for .info files that appear to be cleaned; this is
|
---|
3192 | # for backward compatibility with package such as Texinfo,
|
---|
3193 | # which do things like
|
---|
3194 | # info_TEXINFOS = texinfo.txi info-stnd.texi info.texi
|
---|
3195 | # DISTCLEANFILES = texinfo texinfo-* info*.info*
|
---|
3196 | # # Do not create info files for distribution.
|
---|
3197 | # dist-info:
|
---|
3198 | # in order not to distribute .info files.
|
---|
3199 | my $insrc = ($out_file =~ $user_cleaned_files) ? 0 : 1;
|
---|
3200 |
|
---|
3201 | my $soutdir = '$(srcdir)/' . $outdir;
|
---|
3202 | $outdir = $soutdir if $insrc;
|
---|
3203 |
|
---|
3204 | # If user specified file_TEXINFOS, then use that as explicit
|
---|
3205 | # dependency list.
|
---|
3206 | @texi_deps = ();
|
---|
3207 | push (@texi_deps, "$soutdir$vtexi") if $vtexi;
|
---|
3208 |
|
---|
3209 | my $canonical = canonicalize ($infobase);
|
---|
3210 | if (var ($canonical . "_TEXINFOS"))
|
---|
3211 | {
|
---|
3212 | push (@texi_deps, '$(' . $canonical . '_TEXINFOS)');
|
---|
3213 | push_dist_common ('$(' . $canonical . '_TEXINFOS)');
|
---|
3214 | }
|
---|
3215 |
|
---|
3216 | my ($dirstamp, @cfiles) =
|
---|
3217 | output_texinfo_build_rules ($texi, $out_file, $insrc, @texi_deps);
|
---|
3218 | push (@texi_cleans, @cfiles);
|
---|
3219 |
|
---|
3220 | push (@info_deps_list, $out_file);
|
---|
3221 |
|
---|
3222 | # If a vers*.texi file is needed, emit the rule.
|
---|
3223 | if ($vtexi)
|
---|
3224 | {
|
---|
3225 | err_am ("`$vtexi', included in `$texi', "
|
---|
3226 | . "also included in `$versions{$vtexi}'")
|
---|
3227 | if defined $versions{$vtexi};
|
---|
3228 | $versions{$vtexi} = $texi;
|
---|
3229 |
|
---|
3230 | # We number the stamp-vti files. This is doable since the
|
---|
3231 | # actual names don't matter much. We only number starting
|
---|
3232 | # with the second one, so that the common case looks nice.
|
---|
3233 | my $vti = ($done ? $done : 'vti');
|
---|
3234 | ++$done;
|
---|
3235 |
|
---|
3236 | # This is ugly, but it is our historical practice.
|
---|
3237 | if ($config_aux_dir_set_in_configure_ac)
|
---|
3238 | {
|
---|
3239 | require_conf_file_with_macro (TRUE, 'info_TEXINFOS', FOREIGN,
|
---|
3240 | 'mdate-sh');
|
---|
3241 | }
|
---|
3242 | else
|
---|
3243 | {
|
---|
3244 | require_file_with_macro (TRUE, 'info_TEXINFOS',
|
---|
3245 | FOREIGN, 'mdate-sh');
|
---|
3246 | }
|
---|
3247 |
|
---|
3248 | my $conf_dir;
|
---|
3249 | if ($config_aux_dir_set_in_configure_ac)
|
---|
3250 | {
|
---|
3251 | $conf_dir = "$am_config_aux_dir/";
|
---|
3252 | }
|
---|
3253 | else
|
---|
3254 | {
|
---|
3255 | $conf_dir = '$(srcdir)/';
|
---|
3256 | }
|
---|
3257 | $output_rules .= file_contents ('texi-vers',
|
---|
3258 | new Automake::Location,
|
---|
3259 | TEXI => $texi,
|
---|
3260 | VTI => $vti,
|
---|
3261 | STAMPVTI => "${soutdir}stamp-$vti",
|
---|
3262 | VTEXI => "$soutdir$vtexi",
|
---|
3263 | MDDIR => $conf_dir,
|
---|
3264 | DIRSTAMP => $dirstamp);
|
---|
3265 | }
|
---|
3266 | }
|
---|
3267 |
|
---|
3268 | # Handle location of texinfo.tex.
|
---|
3269 | my $need_texi_file = 0;
|
---|
3270 | my $texinfodir;
|
---|
3271 | if (var ('TEXINFO_TEX'))
|
---|
3272 | {
|
---|
3273 | # The user defined TEXINFO_TEX so assume he knows what he is
|
---|
3274 | # doing.
|
---|
3275 | $texinfodir = ('$(srcdir)/'
|
---|
3276 | . dirname (variable_value ('TEXINFO_TEX')));
|
---|
3277 | }
|
---|
3278 | elsif (option 'cygnus')
|
---|
3279 | {
|
---|
3280 | $texinfodir = '$(top_srcdir)/../texinfo';
|
---|
3281 | define_variable ('TEXINFO_TEX', "$texinfodir/texinfo.tex", INTERNAL);
|
---|
3282 | }
|
---|
3283 | elsif ($config_aux_dir_set_in_configure_ac)
|
---|
3284 | {
|
---|
3285 | $texinfodir = $am_config_aux_dir;
|
---|
3286 | define_variable ('TEXINFO_TEX', "$texinfodir/texinfo.tex", INTERNAL);
|
---|
3287 | $need_texi_file = 2; # so that we require_conf_file later
|
---|
3288 | }
|
---|
3289 | else
|
---|
3290 | {
|
---|
3291 | $texinfodir = '$(srcdir)';
|
---|
3292 | $need_texi_file = 1;
|
---|
3293 | }
|
---|
3294 | define_variable ('am__TEXINFO_TEX_DIR', $texinfodir, INTERNAL);
|
---|
3295 |
|
---|
3296 | push (@dist_targets, 'dist-info');
|
---|
3297 |
|
---|
3298 | if (! option 'no-installinfo')
|
---|
3299 | {
|
---|
3300 | # Make sure documentation is made and installed first. Use
|
---|
3301 | # $(INFO_DEPS), not 'info', because otherwise recursive makes
|
---|
3302 | # get run twice during "make all".
|
---|
3303 | unshift (@all, '$(INFO_DEPS)');
|
---|
3304 | }
|
---|
3305 |
|
---|
3306 | define_files_variable ("DVIS", @infobase, 'dvi', INTERNAL);
|
---|
3307 | define_files_variable ("PDFS", @infobase, 'pdf', INTERNAL);
|
---|
3308 | define_files_variable ("PSS", @infobase, 'ps', INTERNAL);
|
---|
3309 | define_files_variable ("HTMLS", @infobase, 'html', INTERNAL);
|
---|
3310 |
|
---|
3311 | # This next isn't strictly needed now -- the places that look here
|
---|
3312 | # could easily be changed to look in info_TEXINFOS. But this is
|
---|
3313 | # probably better, in case noinst_TEXINFOS is ever supported.
|
---|
3314 | define_variable ("TEXINFOS", variable_value ('info_TEXINFOS'), INTERNAL);
|
---|
3315 |
|
---|
3316 | # Do some error checking. Note that this file is not required
|
---|
3317 | # when in Cygnus mode; instead we defined TEXINFO_TEX explicitly
|
---|
3318 | # up above.
|
---|
3319 | if ($need_texi_file && ! option 'no-texinfo.tex')
|
---|
3320 | {
|
---|
3321 | if ($need_texi_file > 1)
|
---|
3322 | {
|
---|
3323 | require_conf_file_with_macro (TRUE, 'info_TEXINFOS', FOREIGN,
|
---|
3324 | 'texinfo.tex');
|
---|
3325 | }
|
---|
3326 | else
|
---|
3327 | {
|
---|
3328 | require_file_with_macro (TRUE, 'info_TEXINFOS', FOREIGN,
|
---|
3329 | 'texinfo.tex');
|
---|
3330 | }
|
---|
3331 | }
|
---|
3332 |
|
---|
3333 | return makefile_wrap ("", "\t ", @texi_cleans);
|
---|
3334 | }
|
---|
3335 |
|
---|
3336 |
|
---|
3337 | # handle_texinfo ()
|
---|
3338 | # -----------------
|
---|
3339 | # Handle all Texinfo source.
|
---|
3340 | sub handle_texinfo ()
|
---|
3341 | {
|
---|
3342 | reject_var 'TEXINFOS', "`TEXINFOS' is an anachronism; use `info_TEXINFOS'";
|
---|
3343 | # FIXME: I think this is an obsolete future feature name.
|
---|
3344 | reject_var 'html_TEXINFOS', "HTML generation not yet supported";
|
---|
3345 |
|
---|
3346 | my $info_texinfos = var ('info_TEXINFOS');
|
---|
3347 | my $texiclean = "";
|
---|
3348 | if ($info_texinfos)
|
---|
3349 | {
|
---|
3350 | $texiclean = handle_texinfo_helper ($info_texinfos);
|
---|
3351 | }
|
---|
3352 | $output_rules .= file_contents ('texinfos',
|
---|
3353 | new Automake::Location,
|
---|
3354 | TEXICLEAN => $texiclean,
|
---|
3355 | 'LOCAL-TEXIS' => !!$info_texinfos);
|
---|
3356 | }
|
---|
3357 |
|
---|
3358 |
|
---|
3359 | # Handle any man pages.
|
---|
3360 | sub handle_man_pages
|
---|
3361 | {
|
---|
3362 | reject_var 'MANS', "`MANS' is an anachronism; use `man_MANS'";
|
---|
3363 |
|
---|
3364 | # Find all the sections in use. We do this by first looking for
|
---|
3365 | # "standard" sections, and then looking for any additional
|
---|
3366 | # sections used in man_MANS.
|
---|
3367 | my (%sections, %vlist);
|
---|
3368 | # We handle nodist_ for uniformity. man pages aren't distributed
|
---|
3369 | # by default so it isn't actually very important.
|
---|
3370 | foreach my $pfx ('', 'dist_', 'nodist_')
|
---|
3371 | {
|
---|
3372 | # Add more sections as needed.
|
---|
3373 | foreach my $section ('0'..'9', 'n', 'l')
|
---|
3374 | {
|
---|
3375 | my $varname = $pfx . 'man' . $section . '_MANS';
|
---|
3376 | if (var ($varname))
|
---|
3377 | {
|
---|
3378 | $sections{$section} = 1;
|
---|
3379 | $varname = '$(' . $varname . ')';
|
---|
3380 | $vlist{$varname} = 1;
|
---|
3381 |
|
---|
3382 | &push_dist_common ($varname)
|
---|
3383 | if $pfx eq 'dist_';
|
---|
3384 | }
|
---|
3385 | }
|
---|
3386 |
|
---|
3387 | my $varname = $pfx . 'man_MANS';
|
---|
3388 | my $var = var ($varname);
|
---|
3389 | if ($var)
|
---|
3390 | {
|
---|
3391 | foreach ($var->value_as_list_recursive)
|
---|
3392 | {
|
---|
3393 | # A page like `foo.1c' goes into man1dir.
|
---|
3394 | if (/\.([0-9a-z])([a-z]*)$/)
|
---|
3395 | {
|
---|
3396 | $sections{$1} = 1;
|
---|
3397 | }
|
---|
3398 | }
|
---|
3399 |
|
---|
3400 | $varname = '$(' . $varname . ')';
|
---|
3401 | $vlist{$varname} = 1;
|
---|
3402 | &push_dist_common ($varname)
|
---|
3403 | if $pfx eq 'dist_';
|
---|
3404 | }
|
---|
3405 | }
|
---|
3406 |
|
---|
3407 | return unless %sections;
|
---|
3408 |
|
---|
3409 | # Now for each section, generate an install and uninstall rule.
|
---|
3410 | # Sort sections so output is deterministic.
|
---|
3411 | foreach my $section (sort keys %sections)
|
---|
3412 | {
|
---|
3413 | $output_rules .= &file_contents ('mans',
|
---|
3414 | new Automake::Location,
|
---|
3415 | SECTION => $section);
|
---|
3416 | }
|
---|
3417 |
|
---|
3418 | my @mans = sort keys %vlist;
|
---|
3419 | $output_vars .= file_contents ('mans-vars',
|
---|
3420 | new Automake::Location,
|
---|
3421 | MANS => "@mans");
|
---|
3422 |
|
---|
3423 | push (@all, '$(MANS)')
|
---|
3424 | unless option 'no-installman';
|
---|
3425 | }
|
---|
3426 |
|
---|
3427 | # Handle DATA variables.
|
---|
3428 | sub handle_data
|
---|
3429 | {
|
---|
3430 | &am_install_var ('-noextra', '-candist', 'data', 'DATA',
|
---|
3431 | 'data', 'dataroot', 'dvi', 'html', 'pdf', 'ps',
|
---|
3432 | 'sysconf', 'sharedstate', 'localstate',
|
---|
3433 | 'pkgdata', 'lisp', 'noinst', 'check');
|
---|
3434 | }
|
---|
3435 |
|
---|
3436 | # Handle TAGS.
|
---|
3437 | sub handle_tags
|
---|
3438 | {
|
---|
3439 | my @tag_deps = ();
|
---|
3440 | my @ctag_deps = ();
|
---|
3441 | if (var ('SUBDIRS'))
|
---|
3442 | {
|
---|
3443 | $output_rules .= ("tags-recursive:\n"
|
---|
3444 | . "\tlist=\'\$(SUBDIRS)\'; for subdir in \$\$list; do \\\n"
|
---|
3445 | # Never fail here if a subdir fails; it
|
---|
3446 | # isn't important.
|
---|
3447 | . "\t test \"\$\$subdir\" = . || (cd \$\$subdir"
|
---|
3448 | . " && \$(MAKE) \$(AM_MAKEFLAGS) tags); \\\n"
|
---|
3449 | . "\tdone\n");
|
---|
3450 | push (@tag_deps, 'tags-recursive');
|
---|
3451 | &depend ('.PHONY', 'tags-recursive');
|
---|
3452 |
|
---|
3453 | $output_rules .= ("ctags-recursive:\n"
|
---|
3454 | . "\tlist=\'\$(SUBDIRS)\'; for subdir in \$\$list; do \\\n"
|
---|
3455 | # Never fail here if a subdir fails; it
|
---|
3456 | # isn't important.
|
---|
3457 | . "\t test \"\$\$subdir\" = . || (cd \$\$subdir"
|
---|
3458 | . " && \$(MAKE) \$(AM_MAKEFLAGS) ctags); \\\n"
|
---|
3459 | . "\tdone\n");
|
---|
3460 | push (@ctag_deps, 'ctags-recursive');
|
---|
3461 | &depend ('.PHONY', 'ctags-recursive');
|
---|
3462 | }
|
---|
3463 |
|
---|
3464 | if (&saw_sources_p (1)
|
---|
3465 | || var ('ETAGS_ARGS')
|
---|
3466 | || @tag_deps)
|
---|
3467 | {
|
---|
3468 | my @config;
|
---|
3469 | foreach my $spec (@config_headers)
|
---|
3470 | {
|
---|
3471 | my ($out, @ins) = split_config_file_spec ($spec);
|
---|
3472 | foreach my $in (@ins)
|
---|
3473 | {
|
---|
3474 | # If the config header source is in this directory,
|
---|
3475 | # require it.
|
---|
3476 | push @config, basename ($in)
|
---|
3477 | if $relative_dir eq dirname ($in);
|
---|
3478 | }
|
---|
3479 | }
|
---|
3480 | $output_rules .= &file_contents ('tags',
|
---|
3481 | new Automake::Location,
|
---|
3482 | CONFIG => "@config",
|
---|
3483 | TAGSDIRS => "@tag_deps",
|
---|
3484 | CTAGSDIRS => "@ctag_deps");
|
---|
3485 |
|
---|
3486 | set_seen 'TAGS_DEPENDENCIES';
|
---|
3487 | }
|
---|
3488 | elsif (reject_var ('TAGS_DEPENDENCIES',
|
---|
3489 | "doesn't make sense to define `TAGS_DEPENDENCIES'"
|
---|
3490 | . "without\nsources or `ETAGS_ARGS'"))
|
---|
3491 | {
|
---|
3492 | }
|
---|
3493 | else
|
---|
3494 | {
|
---|
3495 | # Every Makefile must define some sort of TAGS rule.
|
---|
3496 | # Otherwise, it would be possible for a top-level "make TAGS"
|
---|
3497 | # to fail because some subdirectory failed.
|
---|
3498 | $output_rules .= "tags: TAGS\nTAGS:\n\n";
|
---|
3499 | # Ditto ctags.
|
---|
3500 | $output_rules .= "ctags: CTAGS\nCTAGS:\n\n";
|
---|
3501 | }
|
---|
3502 | }
|
---|
3503 |
|
---|
3504 | # Handle multilib support.
|
---|
3505 | sub handle_multilib
|
---|
3506 | {
|
---|
3507 | if ($seen_multilib && $relative_dir eq '.')
|
---|
3508 | {
|
---|
3509 | $output_rules .= &file_contents ('multilib', new Automake::Location);
|
---|
3510 | push (@all, 'all-multi');
|
---|
3511 | }
|
---|
3512 | }
|
---|
3513 |
|
---|
3514 |
|
---|
3515 | # user_phony_rule ($NAME)
|
---|
3516 | # -----------------------
|
---|
3517 | # Return false if rule $NAME does not exist. Otherwise,
|
---|
3518 | # declare it as phony, complete its definition (in case it is
|
---|
3519 | # conditional), and return its Automake::Rule instance.
|
---|
3520 | sub user_phony_rule ($)
|
---|
3521 | {
|
---|
3522 | my ($name) = @_;
|
---|
3523 | my $rule = rule $name;
|
---|
3524 | if ($rule)
|
---|
3525 | {
|
---|
3526 | depend ('.PHONY', $name);
|
---|
3527 | # Define $NAME in all condition where it is not already defined,
|
---|
3528 | # so that it is always OK to depend on $NAME.
|
---|
3529 | for my $c ($rule->not_always_defined_in_cond (TRUE)->conds)
|
---|
3530 | {
|
---|
3531 | Automake::Rule::define ($name, 'internal', RULE_AUTOMAKE,
|
---|
3532 | $c, INTERNAL);
|
---|
3533 | $output_rules .= $c->subst_string . "$name:\n";
|
---|
3534 | }
|
---|
3535 | }
|
---|
3536 | return $rule;
|
---|
3537 | }
|
---|
3538 |
|
---|
3539 |
|
---|
3540 | # $BOOLEAN
|
---|
3541 | # &for_dist_common ($A, $B)
|
---|
3542 | # -------------------------
|
---|
3543 | # Subroutine for &handle_dist: sort files to dist.
|
---|
3544 | #
|
---|
3545 | # We put README first because it then becomes easier to make a
|
---|
3546 | # Usenet-compliant shar file (in these, README must be first).
|
---|
3547 | #
|
---|
3548 | # FIXME: do more ordering of files here.
|
---|
3549 | sub for_dist_common
|
---|
3550 | {
|
---|
3551 | return 0
|
---|
3552 | if $a eq $b;
|
---|
3553 | return -1
|
---|
3554 | if $a eq 'README';
|
---|
3555 | return 1
|
---|
3556 | if $b eq 'README';
|
---|
3557 | return $a cmp $b;
|
---|
3558 | }
|
---|
3559 |
|
---|
3560 | # handle_dist
|
---|
3561 | # -----------
|
---|
3562 | # Handle 'dist' target.
|
---|
3563 | sub handle_dist ()
|
---|
3564 | {
|
---|
3565 | # Substitutions for distdir.am
|
---|
3566 | my %transform;
|
---|
3567 |
|
---|
3568 | # Define DIST_SUBDIRS. This must always be done, regardless of the
|
---|
3569 | # no-dist setting: target like `distclean' or `maintainer-clean' use it.
|
---|
3570 | my $subdirs = var ('SUBDIRS');
|
---|
3571 | if ($subdirs)
|
---|
3572 | {
|
---|
3573 | # If SUBDIRS is conditionally defined, then set DIST_SUBDIRS
|
---|
3574 | # to all possible directories, and use it. If DIST_SUBDIRS is
|
---|
3575 | # defined, just use it.
|
---|
3576 |
|
---|
3577 | # Note that we check DIST_SUBDIRS first on purpose, so that
|
---|
3578 | # we don't call has_conditional_contents for now reason.
|
---|
3579 | # (In the past one project used so many conditional subdirectories
|
---|
3580 | # that calling has_conditional_contents on SUBDIRS caused
|
---|
3581 | # automake to grow to 150Mb -- this should not happen with
|
---|
3582 | # the current implementation of has_conditional_contents,
|
---|
3583 | # but it's more efficient to avoid the call anyway.)
|
---|
3584 | if (var ('DIST_SUBDIRS'))
|
---|
3585 | {
|
---|
3586 | }
|
---|
3587 | elsif ($subdirs->has_conditional_contents)
|
---|
3588 | {
|
---|
3589 | define_pretty_variable
|
---|
3590 | ('DIST_SUBDIRS', TRUE, INTERNAL,
|
---|
3591 | uniq ($subdirs->value_as_list_recursive));
|
---|
3592 | }
|
---|
3593 | else
|
---|
3594 | {
|
---|
3595 | # We always define this because that is what `distclean'
|
---|
3596 | # wants.
|
---|
3597 | define_pretty_variable ('DIST_SUBDIRS', TRUE, INTERNAL,
|
---|
3598 | '$(SUBDIRS)');
|
---|
3599 | }
|
---|
3600 | }
|
---|
3601 |
|
---|
3602 | # The remaining definitions are only required when a dist target is used.
|
---|
3603 | return if option 'no-dist';
|
---|
3604 |
|
---|
3605 | # At least one of the archive formats must be enabled.
|
---|
3606 | if ($relative_dir eq '.')
|
---|
3607 | {
|
---|
3608 | my $archive_defined = option 'no-dist-gzip' ? 0 : 1;
|
---|
3609 | $archive_defined ||=
|
---|
3610 | grep { option "dist-$_" } ('shar', 'zip', 'tarZ', 'bzip2');
|
---|
3611 | error (option 'no-dist-gzip',
|
---|
3612 | "no-dist-gzip specified but no dist-* specified, "
|
---|
3613 | . "at least one archive format must be enabled")
|
---|
3614 | unless $archive_defined;
|
---|
3615 | }
|
---|
3616 |
|
---|
3617 | # Look for common files that should be included in distribution.
|
---|
3618 | # If the aux dir is set, and it does not have a Makefile.am, then
|
---|
3619 | # we check for these files there as well.
|
---|
3620 | my $check_aux = 0;
|
---|
3621 | if ($relative_dir eq '.'
|
---|
3622 | && $config_aux_dir_set_in_configure_ac)
|
---|
3623 | {
|
---|
3624 | if (! &is_make_dir ($config_aux_dir))
|
---|
3625 | {
|
---|
3626 | $check_aux = 1;
|
---|
3627 | }
|
---|
3628 | }
|
---|
3629 | foreach my $cfile (@common_files)
|
---|
3630 | {
|
---|
3631 | if (dir_has_case_matching_file ($relative_dir, $cfile)
|
---|
3632 | # The file might be absent, but if it can be built it's ok.
|
---|
3633 | || rule $cfile)
|
---|
3634 | {
|
---|
3635 | &push_dist_common ($cfile);
|
---|
3636 | }
|
---|
3637 |
|
---|
3638 | # Don't use `elsif' here because a file might meaningfully
|
---|
3639 | # appear in both directories.
|
---|
3640 | if ($check_aux && dir_has_case_matching_file ($config_aux_dir, $cfile))
|
---|
3641 | {
|
---|
3642 | &push_dist_common ("$config_aux_dir/$cfile")
|
---|
3643 | }
|
---|
3644 | }
|
---|
3645 |
|
---|
3646 | # We might copy elements from $configure_dist_common to
|
---|
3647 | # %dist_common if we think we need to. If the file appears in our
|
---|
3648 | # directory, we would have discovered it already, so we don't
|
---|
3649 | # check that. But if the file is in a subdir without a Makefile,
|
---|
3650 | # we want to distribute it here if we are doing `.'. Ugly!
|
---|
3651 | if ($relative_dir eq '.')
|
---|
3652 | {
|
---|
3653 | foreach my $file (split (' ' , $configure_dist_common))
|
---|
3654 | {
|
---|
3655 | push_dist_common ($file)
|
---|
3656 | unless is_make_dir (dirname ($file));
|
---|
3657 | }
|
---|
3658 | }
|
---|
3659 |
|
---|
3660 | # Files to distributed. Don't use ->value_as_list_recursive
|
---|
3661 | # as it recursively expands `$(dist_pkgdata_DATA)' etc.
|
---|
3662 | my @dist_common = split (' ', rvar ('DIST_COMMON')->variable_value);
|
---|
3663 | @dist_common = uniq (sort for_dist_common (@dist_common));
|
---|
3664 | variable_delete 'DIST_COMMON';
|
---|
3665 | define_pretty_variable ('DIST_COMMON', TRUE, INTERNAL, @dist_common);
|
---|
3666 |
|
---|
3667 | # Now that we've processed DIST_COMMON, disallow further attempts
|
---|
3668 | # to set it.
|
---|
3669 | $handle_dist_run = 1;
|
---|
3670 |
|
---|
3671 | # Scan EXTRA_DIST to see if we need to distribute anything from a
|
---|
3672 | # subdir. If so, add it to the list. I didn't want to do this
|
---|
3673 | # originally, but there were so many requests that I finally
|
---|
3674 | # relented.
|
---|
3675 | my $extra_dist = var ('EXTRA_DIST');
|
---|
3676 |
|
---|
3677 | $transform{'DISTCHECK-HOOK'} = !! rule 'distcheck-hook';
|
---|
3678 | $transform{'GETTEXT'} = $seen_gettext && !$seen_gettext_external;
|
---|
3679 |
|
---|
3680 | # If the target `dist-hook' exists, make sure it is run. This
|
---|
3681 | # allows users to do random weird things to the distribution
|
---|
3682 | # before it is packaged up.
|
---|
3683 | push (@dist_targets, 'dist-hook')
|
---|
3684 | if user_phony_rule 'dist-hook';
|
---|
3685 | $transform{'DIST-TARGETS'} = join (' ', @dist_targets);
|
---|
3686 |
|
---|
3687 | my $flm = option ('filename-length-max');
|
---|
3688 | my $filename_filter = $flm ? '.' x $flm->[1] : '';
|
---|
3689 |
|
---|
3690 | $output_rules .= &file_contents ('distdir',
|
---|
3691 | new Automake::Location,
|
---|
3692 | %transform,
|
---|
3693 | FILENAME_FILTER => $filename_filter);
|
---|
3694 | }
|
---|
3695 |
|
---|
3696 |
|
---|
3697 | # check_directory ($NAME, $WHERE)
|
---|
3698 | # -------------------------------
|
---|
3699 | # Ensure $NAME is a directory, and that it uses sane name.
|
---|
3700 | # Use $WHERE as a location in the diagnostic, if any.
|
---|
3701 | sub check_directory ($$)
|
---|
3702 | {
|
---|
3703 | my ($dir, $where) = @_;
|
---|
3704 |
|
---|
3705 | error $where, "required directory $relative_dir/$dir does not exist"
|
---|
3706 | unless -d "$relative_dir/$dir";
|
---|
3707 |
|
---|
3708 | # If an `obj/' directory exists, BSD make will enter it before
|
---|
3709 | # reading `Makefile'. Hence the `Makefile' in the current directory
|
---|
3710 | # will not be read.
|
---|
3711 | #
|
---|
3712 | # % cat Makefile
|
---|
3713 | # all:
|
---|
3714 | # echo Hello
|
---|
3715 | # % cat obj/Makefile
|
---|
3716 | # all:
|
---|
3717 | # echo World
|
---|
3718 | # % make # GNU make
|
---|
3719 | # echo Hello
|
---|
3720 | # Hello
|
---|
3721 | # % pmake # BSD make
|
---|
3722 | # echo World
|
---|
3723 | # World
|
---|
3724 | msg ('portability', $where,
|
---|
3725 | "naming a subdirectory `obj' causes troubles with BSD make")
|
---|
3726 | if $dir eq 'obj';
|
---|
3727 |
|
---|
3728 | # `aux' is probably the most important of the following forbidden name,
|
---|
3729 | # since it's tempting to use it as an AC_CONFIG_AUX_DIR.
|
---|
3730 | msg ('portability', $where,
|
---|
3731 | "name `$dir' is reserved on W32 and DOS platforms")
|
---|
3732 | if grep (/^\Q$dir\E$/i, qw/aux lpt1 lpt2 lpt3 com1 com2 com3 com4 con prn/);
|
---|
3733 | }
|
---|
3734 |
|
---|
3735 | # check_directories_in_var ($VARIABLE)
|
---|
3736 | # ------------------------------------
|
---|
3737 | # Recursively check all items in variables $VARIABLE as directories
|
---|
3738 | sub check_directories_in_var ($)
|
---|
3739 | {
|
---|
3740 | my ($var) = @_;
|
---|
3741 | $var->traverse_recursively
|
---|
3742 | (sub
|
---|
3743 | {
|
---|
3744 | my ($var, $val, $cond, $full_cond) = @_;
|
---|
3745 | check_directory ($val, $var->rdef ($cond)->location);
|
---|
3746 | return ();
|
---|
3747 | },
|
---|
3748 | undef,
|
---|
3749 | skip_ac_subst => 1);
|
---|
3750 | }
|
---|
3751 |
|
---|
3752 | # &handle_subdirs ()
|
---|
3753 | # ------------------
|
---|
3754 | # Handle subdirectories.
|
---|
3755 | sub handle_subdirs ()
|
---|
3756 | {
|
---|
3757 | my $subdirs = var ('SUBDIRS');
|
---|
3758 | return
|
---|
3759 | unless $subdirs;
|
---|
3760 |
|
---|
3761 | check_directories_in_var $subdirs;
|
---|
3762 |
|
---|
3763 | my $dsubdirs = var ('DIST_SUBDIRS');
|
---|
3764 | check_directories_in_var $dsubdirs
|
---|
3765 | if $dsubdirs;
|
---|
3766 |
|
---|
3767 | $output_rules .= &file_contents ('subdirs', new Automake::Location);
|
---|
3768 | rvar ('RECURSIVE_TARGETS')->rdef (TRUE)->{'pretty'} = VAR_SORTED; # Gross!
|
---|
3769 | }
|
---|
3770 |
|
---|
3771 |
|
---|
3772 | # ($REGEN, @DEPENDENCIES)
|
---|
3773 | # &scan_aclocal_m4
|
---|
3774 | # ----------------
|
---|
3775 | # If aclocal.m4 creation is automated, return the list of its dependencies.
|
---|
3776 | sub scan_aclocal_m4 ()
|
---|
3777 | {
|
---|
3778 | my $regen_aclocal = 0;
|
---|
3779 |
|
---|
3780 | set_seen 'CONFIG_STATUS_DEPENDENCIES';
|
---|
3781 | set_seen 'CONFIGURE_DEPENDENCIES';
|
---|
3782 |
|
---|
3783 | if (-f 'aclocal.m4')
|
---|
3784 | {
|
---|
3785 | &define_variable ("ACLOCAL_M4", '$(top_srcdir)/aclocal.m4', INTERNAL);
|
---|
3786 |
|
---|
3787 | my $aclocal = new Automake::XFile "< aclocal.m4";
|
---|
3788 | my $line = $aclocal->getline;
|
---|
3789 | $regen_aclocal = $line =~ 'generated automatically by aclocal';
|
---|
3790 | }
|
---|
3791 |
|
---|
3792 | my @ac_deps = ();
|
---|
3793 |
|
---|
3794 | if (set_seen ('ACLOCAL_M4_SOURCES'))
|
---|
3795 | {
|
---|
3796 | push (@ac_deps, '$(ACLOCAL_M4_SOURCES)');
|
---|
3797 | msg_var ('obsolete', 'ACLOCAL_M4_SOURCES',
|
---|
3798 | "`ACLOCAL_M4_SOURCES' is obsolete.\n"
|
---|
3799 | . "It should be safe to simply remove it.");
|
---|
3800 | }
|
---|
3801 |
|
---|
3802 | # Note that it might be possible that aclocal.m4 doesn't exist but
|
---|
3803 | # should be auto-generated. This case probably isn't very
|
---|
3804 | # important.
|
---|
3805 |
|
---|
3806 | return ($regen_aclocal, @ac_deps);
|
---|
3807 | }
|
---|
3808 |
|
---|
3809 |
|
---|
3810 | # Helper function for substitute_ac_subst_variables.
|
---|
3811 | sub substitute_ac_subst_variables_worker($)
|
---|
3812 | {
|
---|
3813 | my ($token) = @_;
|
---|
3814 | return "\@$token\@" if var $token;
|
---|
3815 | return "\${$token\}";
|
---|
3816 | }
|
---|
3817 |
|
---|
3818 | # substitute_ac_subst_variables ($TEXT)
|
---|
3819 | # -------------------------------------
|
---|
3820 | # Replace any occurrence of ${FOO} in $TEXT by @FOO@ if FOO is an AC_SUBST
|
---|
3821 | # variable.
|
---|
3822 | sub substitute_ac_subst_variables ($)
|
---|
3823 | {
|
---|
3824 | my ($text) = @_;
|
---|
3825 | $text =~ s/\${([^ \t=:+{}]+)}/&substitute_ac_subst_variables_worker ($1)/ge;
|
---|
3826 | return $text;
|
---|
3827 | }
|
---|
3828 |
|
---|
3829 | # @DEPENDENCIES
|
---|
3830 | # &prepend_srcdir (@INPUTS)
|
---|
3831 | # -------------------------
|
---|
3832 | # Prepend $(srcdir) or $(top_srcdir) to all @INPUTS. The idea is that
|
---|
3833 | # if an input file has a directory part the same as the current
|
---|
3834 | # directory, then the directory part is simply replaced by $(srcdir).
|
---|
3835 | # But if the directory part is different, then $(top_srcdir) is
|
---|
3836 | # prepended.
|
---|
3837 | sub prepend_srcdir (@)
|
---|
3838 | {
|
---|
3839 | my (@inputs) = @_;
|
---|
3840 | my @newinputs;
|
---|
3841 |
|
---|
3842 | foreach my $single (@inputs)
|
---|
3843 | {
|
---|
3844 | if (dirname ($single) eq $relative_dir)
|
---|
3845 | {
|
---|
3846 | push (@newinputs, '$(srcdir)/' . basename ($single));
|
---|
3847 | }
|
---|
3848 | else
|
---|
3849 | {
|
---|
3850 | push (@newinputs, '$(top_srcdir)/' . $single);
|
---|
3851 | }
|
---|
3852 | }
|
---|
3853 | return @newinputs;
|
---|
3854 | }
|
---|
3855 |
|
---|
3856 | # @DEPENDENCIES
|
---|
3857 | # rewrite_inputs_into_dependencies ($OUTPUT, @INPUTS)
|
---|
3858 | # ---------------------------------------------------
|
---|
3859 | # Compute a list of dependencies appropriate for the rebuild
|
---|
3860 | # rule of
|
---|
3861 | # AC_CONFIG_FILES($OUTPUT:$INPUT[0]:$INPUTS[1]:...)
|
---|
3862 | # Also distribute $INPUTs which are not build by another AC_CONFIG_FILES.
|
---|
3863 | sub rewrite_inputs_into_dependencies ($@)
|
---|
3864 | {
|
---|
3865 | my ($file, @inputs) = @_;
|
---|
3866 | my @res = ();
|
---|
3867 |
|
---|
3868 | for my $i (@inputs)
|
---|
3869 | {
|
---|
3870 | # We cannot create dependencies on shell variables.
|
---|
3871 | next if (substitute_ac_subst_variables $i) =~ /\$/;
|
---|
3872 |
|
---|
3873 | if (exists $ac_config_files_location{$i})
|
---|
3874 | {
|
---|
3875 | my $di = dirname $i;
|
---|
3876 | if ($di eq $relative_dir)
|
---|
3877 | {
|
---|
3878 | $i = basename $i;
|
---|
3879 | }
|
---|
3880 | # In the top-level Makefile we do not use $(top_builddir), because
|
---|
3881 | # we are already there, and since the targets are built without
|
---|
3882 | # a $(top_builddir), it helps BSD Make to match them with
|
---|
3883 | # dependencies.
|
---|
3884 | elsif ($relative_dir ne '.')
|
---|
3885 | {
|
---|
3886 | $i = '$(top_builddir)/' . $i;
|
---|
3887 | }
|
---|
3888 | }
|
---|
3889 | else
|
---|
3890 | {
|
---|
3891 | msg ('error', $ac_config_files_location{$file},
|
---|
3892 | "required file `$i' not found")
|
---|
3893 | unless $i =~ /\$/ || exists $output_files{$i} || -f $i;
|
---|
3894 | ($i) = prepend_srcdir ($i);
|
---|
3895 | push_dist_common ($i);
|
---|
3896 | }
|
---|
3897 | push @res, $i;
|
---|
3898 | }
|
---|
3899 | return @res;
|
---|
3900 | }
|
---|
3901 |
|
---|
3902 |
|
---|
3903 |
|
---|
3904 | # &handle_configure ($MAKEFILE_AM, $MAKEFILE_IN, $MAKEFILE, @INPUTS)
|
---|
3905 | # ------------------------------------------------------------------
|
---|
3906 | # Handle remaking and configure stuff.
|
---|
3907 | # We need the name of the input file, to do proper remaking rules.
|
---|
3908 | sub handle_configure ($$$@)
|
---|
3909 | {
|
---|
3910 | my ($makefile_am, $makefile_in, $makefile, @inputs) = @_;
|
---|
3911 |
|
---|
3912 | prog_error 'empty @inputs'
|
---|
3913 | unless @inputs;
|
---|
3914 |
|
---|
3915 | my ($rel_makefile_am, $rel_makefile_in) = prepend_srcdir ($makefile_am,
|
---|
3916 | $makefile_in);
|
---|
3917 | my $rel_makefile = basename $makefile;
|
---|
3918 |
|
---|
3919 | my $colon_infile = ':' . join (':', @inputs);
|
---|
3920 | $colon_infile = '' if $colon_infile eq ":$makefile.in";
|
---|
3921 | my @rewritten = rewrite_inputs_into_dependencies ($makefile, @inputs);
|
---|
3922 | my ($regen_aclocal_m4, @aclocal_m4_deps) = scan_aclocal_m4;
|
---|
3923 | define_pretty_variable ('am__aclocal_m4_deps', TRUE, INTERNAL,
|
---|
3924 | @configure_deps, @aclocal_m4_deps,
|
---|
3925 | '$(top_srcdir)/' . $configure_ac);
|
---|
3926 | my @configuredeps = ('$(am__aclocal_m4_deps)', '$(CONFIGURE_DEPENDENCIES)');
|
---|
3927 | push @configuredeps, '$(ACLOCAL_M4)' if -f 'aclocal.m4';
|
---|
3928 | define_pretty_variable ('am__configure_deps', TRUE, INTERNAL,
|
---|
3929 | @configuredeps);
|
---|
3930 |
|
---|
3931 | $output_rules .= file_contents
|
---|
3932 | ('configure',
|
---|
3933 | new Automake::Location,
|
---|
3934 | MAKEFILE => $rel_makefile,
|
---|
3935 | 'MAKEFILE-DEPS' => "@rewritten",
|
---|
3936 | 'CONFIG-MAKEFILE' => ($relative_dir eq '.') ? '$@' : '$(subdir)/$@',
|
---|
3937 | 'MAKEFILE-IN' => $rel_makefile_in,
|
---|
3938 | 'MAKEFILE-IN-DEPS' => "@include_stack",
|
---|
3939 | 'MAKEFILE-AM' => $rel_makefile_am,
|
---|
3940 | STRICTNESS => global_option 'cygnus'
|
---|
3941 | ? 'cygnus' : $strictness_name,
|
---|
3942 | 'USE-DEPS' => global_option 'no-dependencies'
|
---|
3943 | ? ' --ignore-deps' : '',
|
---|
3944 | 'MAKEFILE-AM-SOURCES' => "$makefile$colon_infile",
|
---|
3945 | 'REGEN-ACLOCAL-M4' => $regen_aclocal_m4);
|
---|
3946 |
|
---|
3947 | if ($relative_dir eq '.')
|
---|
3948 | {
|
---|
3949 | &push_dist_common ('acconfig.h')
|
---|
3950 | if -f 'acconfig.h';
|
---|
3951 | }
|
---|
3952 |
|
---|
3953 | # If we have a configure header, require it.
|
---|
3954 | my $hdr_index = 0;
|
---|
3955 | my @distclean_config;
|
---|
3956 | foreach my $spec (@config_headers)
|
---|
3957 | {
|
---|
3958 | $hdr_index += 1;
|
---|
3959 | # $CONFIG_H_PATH: config.h from top level.
|
---|
3960 | my ($config_h_path, @ins) = split_config_file_spec ($spec);
|
---|
3961 | my $config_h_dir = dirname ($config_h_path);
|
---|
3962 |
|
---|
3963 | # If the header is in the current directory we want to build
|
---|
3964 | # the header here. Otherwise, if we're at the topmost
|
---|
3965 | # directory and the header's directory doesn't have a
|
---|
3966 | # Makefile, then we also want to build the header.
|
---|
3967 | if ($relative_dir eq $config_h_dir
|
---|
3968 | || ($relative_dir eq '.' && ! &is_make_dir ($config_h_dir)))
|
---|
3969 | {
|
---|
3970 | my ($cn_sans_dir, $stamp_dir);
|
---|
3971 | if ($relative_dir eq $config_h_dir)
|
---|
3972 | {
|
---|
3973 | $cn_sans_dir = basename ($config_h_path);
|
---|
3974 | $stamp_dir = '';
|
---|
3975 | }
|
---|
3976 | else
|
---|
3977 | {
|
---|
3978 | $cn_sans_dir = $config_h_path;
|
---|
3979 | if ($config_h_dir eq '.')
|
---|
3980 | {
|
---|
3981 | $stamp_dir = '';
|
---|
3982 | }
|
---|
3983 | else
|
---|
3984 | {
|
---|
3985 | $stamp_dir = $config_h_dir . '/';
|
---|
3986 | }
|
---|
3987 | }
|
---|
3988 |
|
---|
3989 | # This will also distribute all inputs.
|
---|
3990 | @ins = rewrite_inputs_into_dependencies ($config_h_path, @ins);
|
---|
3991 |
|
---|
3992 | # Cannot define rebuild rules for filenames with shell variables.
|
---|
3993 | next if (substitute_ac_subst_variables $config_h_path) =~ /\$/;
|
---|
3994 |
|
---|
3995 | # Header defined in this directory.
|
---|
3996 | my @files;
|
---|
3997 | if (-f $config_h_path . '.top')
|
---|
3998 | {
|
---|
3999 | push (@files, "$cn_sans_dir.top");
|
---|
4000 | }
|
---|
4001 | if (-f $config_h_path . '.bot')
|
---|
4002 | {
|
---|
4003 | push (@files, "$cn_sans_dir.bot");
|
---|
4004 | }
|
---|
4005 |
|
---|
4006 | push_dist_common (@files);
|
---|
4007 |
|
---|
4008 | # For now, acconfig.h can only appear in the top srcdir.
|
---|
4009 | if (-f 'acconfig.h')
|
---|
4010 | {
|
---|
4011 | push (@files, '$(top_srcdir)/acconfig.h');
|
---|
4012 | }
|
---|
4013 |
|
---|
4014 | my $stamp = "${stamp_dir}stamp-h${hdr_index}";
|
---|
4015 | $output_rules .=
|
---|
4016 | file_contents ('remake-hdr',
|
---|
4017 | new Automake::Location,
|
---|
4018 | FILES => "@files",
|
---|
4019 | CONFIG_H => $cn_sans_dir,
|
---|
4020 | CONFIG_HIN => $ins[0],
|
---|
4021 | CONFIG_H_DEPS => "@ins",
|
---|
4022 | CONFIG_H_PATH => $config_h_path,
|
---|
4023 | STAMP => "$stamp");
|
---|
4024 |
|
---|
4025 | push @distclean_config, $cn_sans_dir, $stamp;
|
---|
4026 | }
|
---|
4027 | }
|
---|
4028 |
|
---|
4029 | $output_rules .= file_contents ('clean-hdr',
|
---|
4030 | new Automake::Location,
|
---|
4031 | FILES => "@distclean_config")
|
---|
4032 | if @distclean_config;
|
---|
4033 |
|
---|
4034 | # Distribute and define mkinstalldirs only if it is already present
|
---|
4035 | # in the package, for backward compatibility (some people may still
|
---|
4036 | # use $(mkinstalldirs)).
|
---|
4037 | my $mkidpath = "$config_aux_dir/mkinstalldirs";
|
---|
4038 | if (-f $mkidpath)
|
---|
4039 | {
|
---|
4040 | # Use require_file so that any existing script gets updated
|
---|
4041 | # by --force-missing.
|
---|
4042 | require_conf_file ($mkidpath, FOREIGN, 'mkinstalldirs');
|
---|
4043 | define_variable ('mkinstalldirs',
|
---|
4044 | "\$(SHELL) $am_config_aux_dir/mkinstalldirs", INTERNAL);
|
---|
4045 | }
|
---|
4046 | else
|
---|
4047 | {
|
---|
4048 | # Use $(install_sh), not $(MKDIR_P) because the latter requires
|
---|
4049 | # at least one argument, and $(mkinstalldirs) used to work
|
---|
4050 | # even without arguments (e.g. $(mkinstalldirs) $(conditional_dir)).
|
---|
4051 | define_variable ('mkinstalldirs', '$(install_sh) -d', INTERNAL);
|
---|
4052 | }
|
---|
4053 |
|
---|
4054 | reject_var ('CONFIG_HEADER',
|
---|
4055 | "`CONFIG_HEADER' is an anachronism; now determined "
|
---|
4056 | . "automatically\nfrom `$configure_ac'");
|
---|
4057 |
|
---|
4058 | my @config_h;
|
---|
4059 | foreach my $spec (@config_headers)
|
---|
4060 | {
|
---|
4061 | my ($out, @ins) = split_config_file_spec ($spec);
|
---|
4062 | # Generate CONFIG_HEADER define.
|
---|
4063 | if ($relative_dir eq dirname ($out))
|
---|
4064 | {
|
---|
4065 | push @config_h, basename ($out);
|
---|
4066 | }
|
---|
4067 | else
|
---|
4068 | {
|
---|
4069 | push @config_h, "\$(top_builddir)/$out";
|
---|
4070 | }
|
---|
4071 | }
|
---|
4072 | define_variable ("CONFIG_HEADER", "@config_h", INTERNAL)
|
---|
4073 | if @config_h;
|
---|
4074 |
|
---|
4075 | # Now look for other files in this directory which must be remade
|
---|
4076 | # by config.status, and generate rules for them.
|
---|
4077 | my @actual_other_files = ();
|
---|
4078 | foreach my $lfile (@other_input_files)
|
---|
4079 | {
|
---|
4080 | my $file;
|
---|
4081 | my @inputs;
|
---|
4082 | if ($lfile =~ /^([^:]*):(.*)$/)
|
---|
4083 | {
|
---|
4084 | # This is the ":" syntax of AC_OUTPUT.
|
---|
4085 | $file = $1;
|
---|
4086 | @inputs = split (':', $2);
|
---|
4087 | }
|
---|
4088 | else
|
---|
4089 | {
|
---|
4090 | # Normal usage.
|
---|
4091 | $file = $lfile;
|
---|
4092 | @inputs = $file . '.in';
|
---|
4093 | }
|
---|
4094 |
|
---|
4095 | # Automake files should not be stored in here, but in %MAKE_LIST.
|
---|
4096 | prog_error ("$lfile in \@other_input_files\n"
|
---|
4097 | . "\@other_input_files = (@other_input_files)")
|
---|
4098 | if -f $file . '.am';
|
---|
4099 |
|
---|
4100 | my $local = basename ($file);
|
---|
4101 |
|
---|
4102 | # We skip files that aren't in this directory. However, if
|
---|
4103 | # the file's directory does not have a Makefile, and we are
|
---|
4104 | # currently doing `.', then we create a rule to rebuild the
|
---|
4105 | # file in the subdir.
|
---|
4106 | my $fd = dirname ($file);
|
---|
4107 | if ($fd ne $relative_dir)
|
---|
4108 | {
|
---|
4109 | if ($relative_dir eq '.' && ! &is_make_dir ($fd))
|
---|
4110 | {
|
---|
4111 | $local = $file;
|
---|
4112 | }
|
---|
4113 | else
|
---|
4114 | {
|
---|
4115 | next;
|
---|
4116 | }
|
---|
4117 | }
|
---|
4118 |
|
---|
4119 | my @rewritten_inputs = rewrite_inputs_into_dependencies ($file, @inputs);
|
---|
4120 |
|
---|
4121 | # Cannot output rules for shell variables.
|
---|
4122 | next if (substitute_ac_subst_variables $local) =~ /\$/;
|
---|
4123 |
|
---|
4124 | $output_rules .= ($local . ': '
|
---|
4125 | . '$(top_builddir)/config.status '
|
---|
4126 | . "@rewritten_inputs\n"
|
---|
4127 | . "\t"
|
---|
4128 | . 'cd $(top_builddir) && '
|
---|
4129 | . '$(SHELL) ./config.status '
|
---|
4130 | . ($relative_dir eq '.' ? '' : '$(subdir)/')
|
---|
4131 | . '$@'
|
---|
4132 | . "\n");
|
---|
4133 | push (@actual_other_files, $local);
|
---|
4134 | }
|
---|
4135 |
|
---|
4136 | # For links we should clean destinations and distribute sources.
|
---|
4137 | foreach my $spec (@config_links)
|
---|
4138 | {
|
---|
4139 | my ($link, $file) = split /:/, $spec;
|
---|
4140 | # Some people do AC_CONFIG_LINKS($computed). We only handle
|
---|
4141 | # the DEST:SRC form.
|
---|
4142 | next unless $file;
|
---|
4143 | my $where = $ac_config_files_location{$link};
|
---|
4144 |
|
---|
4145 | # Skip destinations that contain shell variables.
|
---|
4146 | if ((substitute_ac_subst_variables $link) !~ /\$/)
|
---|
4147 | {
|
---|
4148 | # We skip links that aren't in this directory. However, if
|
---|
4149 | # the link's directory does not have a Makefile, and we are
|
---|
4150 | # currently doing `.', then we add the link to CONFIG_CLEAN_FILES
|
---|
4151 | # in `.'s Makefile.in.
|
---|
4152 | my $local = basename ($link);
|
---|
4153 | my $fd = dirname ($link);
|
---|
4154 | if ($fd ne $relative_dir)
|
---|
4155 | {
|
---|
4156 | if ($relative_dir eq '.' && ! &is_make_dir ($fd))
|
---|
4157 | {
|
---|
4158 | $local = $link;
|
---|
4159 | }
|
---|
4160 | else
|
---|
4161 | {
|
---|
4162 | $local = undef;
|
---|
4163 | }
|
---|
4164 | }
|
---|
4165 | push @actual_other_files, $local if $local;
|
---|
4166 | }
|
---|
4167 |
|
---|
4168 | # Do not process sources that contain shell variables.
|
---|
4169 | if ((substitute_ac_subst_variables $file) !~ /\$/)
|
---|
4170 | {
|
---|
4171 | my $fd = dirname ($file);
|
---|
4172 |
|
---|
4173 | # We distribute files that are in this directory.
|
---|
4174 | # At the top-level (`.') we also distribute files whose
|
---|
4175 | # directory does not have a Makefile.
|
---|
4176 | if (($fd eq $relative_dir)
|
---|
4177 | || ($relative_dir eq '.' && ! &is_make_dir ($fd)))
|
---|
4178 | {
|
---|
4179 | # The following will distribute $file as a side-effect when
|
---|
4180 | # it is appropriate (i.e., when $file is not already an output).
|
---|
4181 | # We do not need the result, just the side-effect.
|
---|
4182 | rewrite_inputs_into_dependencies ($link, $file);
|
---|
4183 | }
|
---|
4184 | }
|
---|
4185 | }
|
---|
4186 |
|
---|
4187 | # These files get removed by "make distclean".
|
---|
4188 | define_pretty_variable ('CONFIG_CLEAN_FILES', TRUE, INTERNAL,
|
---|
4189 | @actual_other_files);
|
---|
4190 | }
|
---|
4191 |
|
---|
4192 | # Handle C headers.
|
---|
4193 | sub handle_headers
|
---|
4194 | {
|
---|
4195 | my @r = &am_install_var ('-defaultdist', 'header', 'HEADERS', 'include',
|
---|
4196 | 'oldinclude', 'pkginclude',
|
---|
4197 | 'noinst', 'check');
|
---|
4198 | foreach (@r)
|
---|
4199 | {
|
---|
4200 | next unless $_->[1] =~ /\..*$/;
|
---|
4201 | &saw_extension ($&);
|
---|
4202 | }
|
---|
4203 | }
|
---|
4204 |
|
---|
4205 | sub handle_gettext
|
---|
4206 | {
|
---|
4207 | return if ! $seen_gettext || $relative_dir ne '.';
|
---|
4208 |
|
---|
4209 | my $subdirs = var 'SUBDIRS';
|
---|
4210 |
|
---|
4211 | if (! $subdirs)
|
---|
4212 | {
|
---|
4213 | err_ac "AM_GNU_GETTEXT used but SUBDIRS not defined";
|
---|
4214 | return;
|
---|
4215 | }
|
---|
4216 |
|
---|
4217 | # Perform some sanity checks to help users get the right setup.
|
---|
4218 | # We disable these tests when po/ doesn't exist in order not to disallow
|
---|
4219 | # unusual gettext setups.
|
---|
4220 | #
|
---|
4221 | # Bruno Haible:
|
---|
4222 | # | The idea is:
|
---|
4223 | # |
|
---|
4224 | # | 1) If a package doesn't have a directory po/ at top level, it
|
---|
4225 | # | will likely have multiple po/ directories in subpackages.
|
---|
4226 | # |
|
---|
4227 | # | 2) It is useful to warn for the absence of intl/ if AM_GNU_GETTEXT
|
---|
4228 | # | is used without 'external'. It is also useful to warn for the
|
---|
4229 | # | presence of intl/ if AM_GNU_GETTEXT([external]) is used. Both
|
---|
4230 | # | warnings apply only to the usual layout of packages, therefore
|
---|
4231 | # | they should both be disabled if no po/ directory is found at
|
---|
4232 | # | top level.
|
---|
4233 |
|
---|
4234 | if (-d 'po')
|
---|
4235 | {
|
---|
4236 | my @subdirs = $subdirs->value_as_list_recursive;
|
---|
4237 |
|
---|
4238 | msg_var ('syntax', $subdirs,
|
---|
4239 | "AM_GNU_GETTEXT used but `po' not in SUBDIRS")
|
---|
4240 | if ! grep ($_ eq 'po', @subdirs);
|
---|
4241 |
|
---|
4242 | # intl/ is not required when AM_GNU_GETTEXT is called with the
|
---|
4243 | # `external' option and AM_GNU_GETTEXT_INTL_SUBDIR is not called.
|
---|
4244 | msg_var ('syntax', $subdirs,
|
---|
4245 | "AM_GNU_GETTEXT used but `intl' not in SUBDIRS")
|
---|
4246 | if (! ($seen_gettext_external && ! $seen_gettext_intl)
|
---|
4247 | && ! grep ($_ eq 'intl', @subdirs));
|
---|
4248 |
|
---|
4249 | # intl/ should not be used with AM_GNU_GETTEXT([external]), except
|
---|
4250 | # if AM_GNU_GETTEXT_INTL_SUBDIR is called.
|
---|
4251 | msg_var ('syntax', $subdirs,
|
---|
4252 | "`intl' should not be in SUBDIRS when "
|
---|
4253 | . "AM_GNU_GETTEXT([external]) is used")
|
---|
4254 | if ($seen_gettext_external && ! $seen_gettext_intl
|
---|
4255 | && grep ($_ eq 'intl', @subdirs));
|
---|
4256 | }
|
---|
4257 |
|
---|
4258 | require_file ($ac_gettext_location, GNU, 'ABOUT-NLS');
|
---|
4259 | }
|
---|
4260 |
|
---|
4261 | # Handle footer elements.
|
---|
4262 | sub handle_footer
|
---|
4263 | {
|
---|
4264 | reject_rule ('.SUFFIXES',
|
---|
4265 | "use variable `SUFFIXES', not target `.SUFFIXES'");
|
---|
4266 |
|
---|
4267 | # Note: AIX 4.1 /bin/make will fail if any suffix rule appears
|
---|
4268 | # before .SUFFIXES. So we make sure that .SUFFIXES appears before
|
---|
4269 | # anything else, by sticking it right after the default: target.
|
---|
4270 | $output_header .= ".SUFFIXES:\n";
|
---|
4271 | my $suffixes = var 'SUFFIXES';
|
---|
4272 | my @suffixes = Automake::Rule::suffixes;
|
---|
4273 | if (@suffixes || $suffixes)
|
---|
4274 | {
|
---|
4275 | # Make sure SUFFIXES has unique elements. Sort them to ensure
|
---|
4276 | # the output remains consistent. However, $(SUFFIXES) is
|
---|
4277 | # always at the start of the list, unsorted. This is done
|
---|
4278 | # because make will choose rules depending on the ordering of
|
---|
4279 | # suffixes, and this lets the user have some control. Push
|
---|
4280 | # actual suffixes, and not $(SUFFIXES). Some versions of make
|
---|
4281 | # do not like variable substitutions on the .SUFFIXES line.
|
---|
4282 | my @user_suffixes = ($suffixes
|
---|
4283 | ? $suffixes->value_as_list_recursive : ());
|
---|
4284 |
|
---|
4285 | my %suffixes = map { $_ => 1 } @suffixes;
|
---|
4286 | delete @suffixes{@user_suffixes};
|
---|
4287 |
|
---|
4288 | $output_header .= (".SUFFIXES: "
|
---|
4289 | . join (' ', @user_suffixes, sort keys %suffixes)
|
---|
4290 | . "\n");
|
---|
4291 | }
|
---|
4292 |
|
---|
4293 | $output_trailer .= file_contents ('footer', new Automake::Location);
|
---|
4294 | }
|
---|
4295 |
|
---|
4296 |
|
---|
4297 | # Generate `make install' rules.
|
---|
4298 | sub handle_install ()
|
---|
4299 | {
|
---|
4300 | $output_rules .= &file_contents
|
---|
4301 | ('install',
|
---|
4302 | new Automake::Location,
|
---|
4303 | maybe_BUILT_SOURCES => (set_seen ('BUILT_SOURCES')
|
---|
4304 | ? (" \$(BUILT_SOURCES)\n"
|
---|
4305 | . "\t\$(MAKE) \$(AM_MAKEFLAGS)")
|
---|
4306 | : ''),
|
---|
4307 | 'installdirs-local' => (user_phony_rule 'installdirs-local'
|
---|
4308 | ? ' installdirs-local' : ''),
|
---|
4309 | am__installdirs => variable_value ('am__installdirs') || '');
|
---|
4310 | }
|
---|
4311 |
|
---|
4312 |
|
---|
4313 | # Deal with all and all-am.
|
---|
4314 | sub handle_all ($)
|
---|
4315 | {
|
---|
4316 | my ($makefile) = @_;
|
---|
4317 |
|
---|
4318 | # Output `all-am'.
|
---|
4319 |
|
---|
4320 | # Put this at the beginning for the sake of non-GNU makes. This
|
---|
4321 | # is still wrong if these makes can run parallel jobs. But it is
|
---|
4322 | # right enough.
|
---|
4323 | unshift (@all, basename ($makefile));
|
---|
4324 |
|
---|
4325 | foreach my $spec (@config_headers)
|
---|
4326 | {
|
---|
4327 | my ($out, @ins) = split_config_file_spec ($spec);
|
---|
4328 | push (@all, basename ($out))
|
---|
4329 | if dirname ($out) eq $relative_dir;
|
---|
4330 | }
|
---|
4331 |
|
---|
4332 | # Install `all' hooks.
|
---|
4333 | push (@all, "all-local")
|
---|
4334 | if user_phony_rule "all-local";
|
---|
4335 |
|
---|
4336 | &pretty_print_rule ("all-am:", "\t\t", @all);
|
---|
4337 | &depend ('.PHONY', 'all-am', 'all');
|
---|
4338 |
|
---|
4339 |
|
---|
4340 | # Output `all'.
|
---|
4341 |
|
---|
4342 | my @local_headers = ();
|
---|
4343 | push @local_headers, '$(BUILT_SOURCES)'
|
---|
4344 | if var ('BUILT_SOURCES');
|
---|
4345 | foreach my $spec (@config_headers)
|
---|
4346 | {
|
---|
4347 | my ($out, @ins) = split_config_file_spec ($spec);
|
---|
4348 | push @local_headers, basename ($out)
|
---|
4349 | if dirname ($out) eq $relative_dir;
|
---|
4350 | }
|
---|
4351 |
|
---|
4352 | if (@local_headers)
|
---|
4353 | {
|
---|
4354 | # We need to make sure config.h is built before we recurse.
|
---|
4355 | # We also want to make sure that built sources are built
|
---|
4356 | # before any ordinary `all' targets are run. We can't do this
|
---|
4357 | # by changing the order of dependencies to the "all" because
|
---|
4358 | # that breaks when using parallel makes. Instead we handle
|
---|
4359 | # things explicitly.
|
---|
4360 | $output_all .= ("all: @local_headers"
|
---|
4361 | . "\n\t"
|
---|
4362 | . '$(MAKE) $(AM_MAKEFLAGS) '
|
---|
4363 | . (var ('SUBDIRS') ? 'all-recursive' : 'all-am')
|
---|
4364 | . "\n\n");
|
---|
4365 | }
|
---|
4366 | else
|
---|
4367 | {
|
---|
4368 | $output_all .= "all: " . (var ('SUBDIRS')
|
---|
4369 | ? 'all-recursive' : 'all-am') . "\n\n";
|
---|
4370 | }
|
---|
4371 | }
|
---|
4372 |
|
---|
4373 |
|
---|
4374 | # &do_check_merge_target ()
|
---|
4375 | # -------------------------
|
---|
4376 | # Handle check merge target specially.
|
---|
4377 | sub do_check_merge_target ()
|
---|
4378 | {
|
---|
4379 | # Include user-defined local form of target.
|
---|
4380 | push @check_tests, 'check-local'
|
---|
4381 | if user_phony_rule 'check-local';
|
---|
4382 |
|
---|
4383 | # In --cygnus mode, check doesn't depend on all.
|
---|
4384 | if (option 'cygnus')
|
---|
4385 | {
|
---|
4386 | # Just run the local check rules.
|
---|
4387 | pretty_print_rule ('check-am:', "\t\t", @check);
|
---|
4388 | }
|
---|
4389 | else
|
---|
4390 | {
|
---|
4391 | # The check target must depend on the local equivalent of
|
---|
4392 | # `all', to ensure all the primary targets are built. Then it
|
---|
4393 | # must build the local check rules.
|
---|
4394 | $output_rules .= "check-am: all-am\n";
|
---|
4395 | pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ",
|
---|
4396 | @check)
|
---|
4397 | if @check;
|
---|
4398 | }
|
---|
4399 | pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ",
|
---|
4400 | @check_tests)
|
---|
4401 | if @check_tests;
|
---|
4402 |
|
---|
4403 | depend '.PHONY', 'check', 'check-am';
|
---|
4404 | # Handle recursion. We have to honor BUILT_SOURCES like for `all:'.
|
---|
4405 | $output_rules .= ("check: "
|
---|
4406 | . (var ('BUILT_SOURCES')
|
---|
4407 | ? "\$(BUILT_SOURCES)\n\t\$(MAKE) \$(AM_MAKEFLAGS) "
|
---|
4408 | : '')
|
---|
4409 | . (var ('SUBDIRS') ? 'check-recursive' : 'check-am')
|
---|
4410 | . "\n");
|
---|
4411 | }
|
---|
4412 |
|
---|
4413 | # handle_clean ($MAKEFILE)
|
---|
4414 | # ------------------------
|
---|
4415 | # Handle all 'clean' targets.
|
---|
4416 | sub handle_clean ($)
|
---|
4417 | {
|
---|
4418 | my ($makefile) = @_;
|
---|
4419 |
|
---|
4420 | # Clean the files listed in user variables if they exist.
|
---|
4421 | $clean_files{'$(MOSTLYCLEANFILES)'} = MOSTLY_CLEAN
|
---|
4422 | if var ('MOSTLYCLEANFILES');
|
---|
4423 | $clean_files{'$(CLEANFILES)'} = CLEAN
|
---|
4424 | if var ('CLEANFILES');
|
---|
4425 | $clean_files{'$(DISTCLEANFILES)'} = DIST_CLEAN
|
---|
4426 | if var ('DISTCLEANFILES');
|
---|
4427 | $clean_files{'$(MAINTAINERCLEANFILES)'} = MAINTAINER_CLEAN
|
---|
4428 | if var ('MAINTAINERCLEANFILES');
|
---|
4429 |
|
---|
4430 | # Built sources are automatically removed by maintainer-clean.
|
---|
4431 | $clean_files{'$(BUILT_SOURCES)'} = MAINTAINER_CLEAN
|
---|
4432 | if var ('BUILT_SOURCES');
|
---|
4433 |
|
---|
4434 | # Compute a list of "rm"s to run for each target.
|
---|
4435 | my %rms = (MOSTLY_CLEAN, [],
|
---|
4436 | CLEAN, [],
|
---|
4437 | DIST_CLEAN, [],
|
---|
4438 | MAINTAINER_CLEAN, []);
|
---|
4439 |
|
---|
4440 | foreach my $file (keys %clean_files)
|
---|
4441 | {
|
---|
4442 | my $when = $clean_files{$file};
|
---|
4443 | prog_error 'invalid entry in %clean_files'
|
---|
4444 | unless exists $rms{$when};
|
---|
4445 |
|
---|
4446 | my $rm = "rm -f $file";
|
---|
4447 | # If file is a variable, make sure when don't call `rm -f' without args.
|
---|
4448 | $rm ="test -z \"$file\" || $rm"
|
---|
4449 | if ($file =~ /^\s*\$(\(.*\)|\{.*\})\s*$/);
|
---|
4450 |
|
---|
4451 | push @{$rms{$when}}, "\t-$rm\n";
|
---|
4452 | }
|
---|
4453 |
|
---|
4454 | $output_rules .= &file_contents
|
---|
4455 | ('clean',
|
---|
4456 | new Automake::Location,
|
---|
4457 | MOSTLYCLEAN_RMS => join ('', sort @{$rms{&MOSTLY_CLEAN}}),
|
---|
4458 | CLEAN_RMS => join ('', sort @{$rms{&CLEAN}}),
|
---|
4459 | DISTCLEAN_RMS => join ('', sort @{$rms{&DIST_CLEAN}}),
|
---|
4460 | MAINTAINER_CLEAN_RMS => join ('', sort @{$rms{&MAINTAINER_CLEAN}}),
|
---|
4461 | MAKEFILE => basename $makefile,
|
---|
4462 | );
|
---|
4463 | }
|
---|
4464 |
|
---|
4465 |
|
---|
4466 | # &target_cmp ($A, $B)
|
---|
4467 | # --------------------
|
---|
4468 | # Subroutine for &handle_factored_dependencies to let `.PHONY' and
|
---|
4469 | # other `.TARGETS' be last.
|
---|
4470 | sub target_cmp
|
---|
4471 | {
|
---|
4472 | return 0 if $a eq $b;
|
---|
4473 |
|
---|
4474 | my $a1 = substr ($a, 0, 1);
|
---|
4475 | my $b1 = substr ($b, 0, 1);
|
---|
4476 | if ($a1 ne $b1)
|
---|
4477 | {
|
---|
4478 | return -1 if $b1 eq '.';
|
---|
4479 | return 1 if $a1 eq '.';
|
---|
4480 | }
|
---|
4481 | return $a cmp $b;
|
---|
4482 | }
|
---|
4483 |
|
---|
4484 |
|
---|
4485 | # &handle_factored_dependencies ()
|
---|
4486 | # --------------------------------
|
---|
4487 | # Handle everything related to gathered targets.
|
---|
4488 | sub handle_factored_dependencies
|
---|
4489 | {
|
---|
4490 | # Reject bad hooks.
|
---|
4491 | foreach my $utarg ('uninstall-data-local', 'uninstall-data-hook',
|
---|
4492 | 'uninstall-exec-local', 'uninstall-exec-hook',
|
---|
4493 | 'uninstall-dvi-local',
|
---|
4494 | 'uninstall-html-local',
|
---|
4495 | 'uninstall-info-local',
|
---|
4496 | 'uninstall-pdf-local',
|
---|
4497 | 'uninstall-ps-local')
|
---|
4498 | {
|
---|
4499 | my $x = $utarg;
|
---|
4500 | $x =~ s/-.*-/-/;
|
---|
4501 | reject_rule ($utarg, "use `$x', not `$utarg'");
|
---|
4502 | }
|
---|
4503 |
|
---|
4504 | reject_rule ('install-local',
|
---|
4505 | "use `install-data-local' or `install-exec-local', "
|
---|
4506 | . "not `install-local'");
|
---|
4507 |
|
---|
4508 | reject_rule ('install-hook',
|
---|
4509 | "use `install-data-hook' or `install-exec-hook', "
|
---|
4510 | . "not `install-hook'");
|
---|
4511 |
|
---|
4512 | # Install the -local hooks.
|
---|
4513 | foreach (keys %dependencies)
|
---|
4514 | {
|
---|
4515 | # Hooks are installed on the -am targets.
|
---|
4516 | s/-am$// or next;
|
---|
4517 | depend ("$_-am", "$_-local")
|
---|
4518 | if user_phony_rule "$_-local";
|
---|
4519 | }
|
---|
4520 |
|
---|
4521 | # Install the -hook hooks.
|
---|
4522 | # FIXME: Why not be as liberal as we are with -local hooks?
|
---|
4523 | foreach ('install-exec', 'install-data', 'uninstall')
|
---|
4524 | {
|
---|
4525 | if (user_phony_rule "$_-hook")
|
---|
4526 | {
|
---|
4527 | $actions{"$_-am"} .=
|
---|
4528 | ("\t\@\$(NORMAL_INSTALL)\n"
|
---|
4529 | . "\t" . '$(MAKE) $(AM_MAKEFLAGS) ' . "$_-hook\n");
|
---|
4530 | depend ('.MAKE', "$_-am");
|
---|
4531 | }
|
---|
4532 | }
|
---|
4533 |
|
---|
4534 | # All the required targets are phony.
|
---|
4535 | depend ('.PHONY', keys %required_targets);
|
---|
4536 |
|
---|
4537 | # Actually output gathered targets.
|
---|
4538 | foreach (sort target_cmp keys %dependencies)
|
---|
4539 | {
|
---|
4540 | # If there is nothing about this guy, skip it.
|
---|
4541 | next
|
---|
4542 | unless (@{$dependencies{$_}}
|
---|
4543 | || $actions{$_}
|
---|
4544 | || $required_targets{$_});
|
---|
4545 |
|
---|
4546 | # Define gathered targets in undefined conditions.
|
---|
4547 | # FIXME: Right now we must handle .PHONY as an exception,
|
---|
4548 | # because people write things like
|
---|
4549 | # .PHONY: myphonytarget
|
---|
4550 | # to append dependencies. This would not work if Automake
|
---|
4551 | # refrained from defining its own .PHONY target as it does
|
---|
4552 | # with other overridden targets.
|
---|
4553 | # Likewise for `.MAKE'.
|
---|
4554 | my @undefined_conds = (TRUE,);
|
---|
4555 | if ($_ ne '.PHONY' && $_ ne '.MAKE')
|
---|
4556 | {
|
---|
4557 | @undefined_conds =
|
---|
4558 | Automake::Rule::define ($_, 'internal',
|
---|
4559 | RULE_AUTOMAKE, TRUE, INTERNAL);
|
---|
4560 | }
|
---|
4561 | my @uniq_deps = uniq (sort @{$dependencies{$_}});
|
---|
4562 | foreach my $cond (@undefined_conds)
|
---|
4563 | {
|
---|
4564 | my $condstr = $cond->subst_string;
|
---|
4565 | &pretty_print_rule ("$condstr$_:", "$condstr\t", @uniq_deps);
|
---|
4566 | $output_rules .= $actions{$_} if defined $actions{$_};
|
---|
4567 | $output_rules .= "\n";
|
---|
4568 | }
|
---|
4569 | }
|
---|
4570 | }
|
---|
4571 |
|
---|
4572 |
|
---|
4573 | # &handle_tests_dejagnu ()
|
---|
4574 | # ------------------------
|
---|
4575 | sub handle_tests_dejagnu
|
---|
4576 | {
|
---|
4577 | push (@check_tests, 'check-DEJAGNU');
|
---|
4578 | $output_rules .= file_contents ('dejagnu', new Automake::Location);
|
---|
4579 | }
|
---|
4580 |
|
---|
4581 |
|
---|
4582 | # Handle TESTS variable and other checks.
|
---|
4583 | sub handle_tests
|
---|
4584 | {
|
---|
4585 | if (option 'dejagnu')
|
---|
4586 | {
|
---|
4587 | &handle_tests_dejagnu;
|
---|
4588 | }
|
---|
4589 | else
|
---|
4590 | {
|
---|
4591 | foreach my $c ('DEJATOOL', 'RUNTEST', 'RUNTESTFLAGS')
|
---|
4592 | {
|
---|
4593 | reject_var ($c, "`$c' defined but `dejagnu' not in "
|
---|
4594 | . "`AUTOMAKE_OPTIONS'");
|
---|
4595 | }
|
---|
4596 | }
|
---|
4597 |
|
---|
4598 | if (var ('TESTS'))
|
---|
4599 | {
|
---|
4600 | push (@check_tests, 'check-TESTS');
|
---|
4601 | $output_rules .= &file_contents ('check', new Automake::Location);
|
---|
4602 |
|
---|
4603 | # Tests that are known programs should have $(EXEEXT) appended.
|
---|
4604 | append_exeext { exists $known_programs{$_[0]} } 'TESTS';
|
---|
4605 | }
|
---|
4606 | }
|
---|
4607 |
|
---|
4608 | # Handle Emacs Lisp.
|
---|
4609 | sub handle_emacs_lisp
|
---|
4610 | {
|
---|
4611 | my @elfiles = &am_install_var ('-candist', 'lisp', 'LISP',
|
---|
4612 | 'lisp', 'noinst');
|
---|
4613 |
|
---|
4614 | return if ! @elfiles;
|
---|
4615 |
|
---|
4616 | define_pretty_variable ('am__ELFILES', TRUE, INTERNAL,
|
---|
4617 | map { $_->[1] } @elfiles);
|
---|
4618 | define_pretty_variable ('am__ELCFILES', TRUE, INTERNAL,
|
---|
4619 | '$(am__ELFILES:.el=.elc)');
|
---|
4620 | # This one can be overridden by users.
|
---|
4621 | define_pretty_variable ('ELCFILES', TRUE, INTERNAL, '$(LISP:.el=.elc)');
|
---|
4622 |
|
---|
4623 | push @all, '$(ELCFILES)';
|
---|
4624 |
|
---|
4625 | require_variables ($elfiles[0][0], "Emacs Lisp sources seen", TRUE,
|
---|
4626 | 'EMACS', 'lispdir');
|
---|
4627 | require_conf_file ($elfiles[0][0], FOREIGN, 'elisp-comp');
|
---|
4628 | &define_variable ('elisp_comp', "$am_config_aux_dir/elisp-comp", INTERNAL);
|
---|
4629 | }
|
---|
4630 |
|
---|
4631 | # Handle Python
|
---|
4632 | sub handle_python
|
---|
4633 | {
|
---|
4634 | my @pyfiles = &am_install_var ('-defaultdist', 'python', 'PYTHON',
|
---|
4635 | 'noinst');
|
---|
4636 | return if ! @pyfiles;
|
---|
4637 |
|
---|
4638 | require_variables ($pyfiles[0][0], "Python sources seen", TRUE, 'PYTHON');
|
---|
4639 | require_conf_file ($pyfiles[0][0], FOREIGN, 'py-compile');
|
---|
4640 | &define_variable ('py_compile', "$am_config_aux_dir/py-compile", INTERNAL);
|
---|
4641 | }
|
---|
4642 |
|
---|
4643 | # Handle Java.
|
---|
4644 | sub handle_java
|
---|
4645 | {
|
---|
4646 | my @sourcelist = &am_install_var ('-candist',
|
---|
4647 | 'java', 'JAVA',
|
---|
4648 | 'java', 'noinst', 'check');
|
---|
4649 | return if ! @sourcelist;
|
---|
4650 |
|
---|
4651 | my @prefix = am_primary_prefixes ('JAVA', 1,
|
---|
4652 | 'java', 'noinst', 'check');
|
---|
4653 |
|
---|
4654 | my $dir;
|
---|
4655 | foreach my $curs (@prefix)
|
---|
4656 | {
|
---|
4657 | next
|
---|
4658 | if $curs eq 'EXTRA';
|
---|
4659 |
|
---|
4660 | err_var "${curs}_JAVA", "multiple _JAVA primaries in use"
|
---|
4661 | if defined $dir;
|
---|
4662 | $dir = $curs;
|
---|
4663 | }
|
---|
4664 |
|
---|
4665 |
|
---|
4666 | push (@all, 'class' . $dir . '.stamp');
|
---|
4667 | }
|
---|
4668 |
|
---|
4669 |
|
---|
4670 | # Handle some of the minor options.
|
---|
4671 | sub handle_minor_options
|
---|
4672 | {
|
---|
4673 | if (option 'readme-alpha')
|
---|
4674 | {
|
---|
4675 | if ($relative_dir eq '.')
|
---|
4676 | {
|
---|
4677 | if ($package_version !~ /^$GNITS_VERSION_PATTERN$/)
|
---|
4678 | {
|
---|
4679 | msg ('error-gnits', $package_version_location,
|
---|
4680 | "version `$package_version' doesn't follow " .
|
---|
4681 | "Gnits standards");
|
---|
4682 | }
|
---|
4683 | if (defined $1 && -f 'README-alpha')
|
---|
4684 | {
|
---|
4685 | # This means we have an alpha release. See
|
---|
4686 | # GNITS_VERSION_PATTERN for details.
|
---|
4687 | push_dist_common ('README-alpha');
|
---|
4688 | }
|
---|
4689 | }
|
---|
4690 | }
|
---|
4691 | }
|
---|
4692 |
|
---|
4693 | ################################################################
|
---|
4694 |
|
---|
4695 | # ($OUTPUT, @INPUTS)
|
---|
4696 | # &split_config_file_spec ($SPEC)
|
---|
4697 | # -------------------------------
|
---|
4698 | # Decode the Autoconf syntax for config files (files, headers, links
|
---|
4699 | # etc.).
|
---|
4700 | sub split_config_file_spec ($)
|
---|
4701 | {
|
---|
4702 | my ($spec) = @_;
|
---|
4703 | my ($output, @inputs) = split (/:/, $spec);
|
---|
4704 |
|
---|
4705 | push @inputs, "$output.in"
|
---|
4706 | unless @inputs;
|
---|
4707 |
|
---|
4708 | return ($output, @inputs);
|
---|
4709 | }
|
---|
4710 |
|
---|
4711 | # $input
|
---|
4712 | # locate_am (@POSSIBLE_SOURCES)
|
---|
4713 | # -----------------------------
|
---|
4714 | # AC_CONFIG_FILES allow specifications such as Makefile:top.in:mid.in:bot.in
|
---|
4715 | # This functions returns the first *.in file for which a *.am exists.
|
---|
4716 | # It returns undef otherwise.
|
---|
4717 | sub locate_am (@)
|
---|
4718 | {
|
---|
4719 | my (@rest) = @_;
|
---|
4720 | my $input;
|
---|
4721 | foreach my $file (@rest)
|
---|
4722 | {
|
---|
4723 | if (($file =~ /^(.*)\.in$/) && -f "$1.am")
|
---|
4724 | {
|
---|
4725 | $input = $file;
|
---|
4726 | last;
|
---|
4727 | }
|
---|
4728 | }
|
---|
4729 | return $input;
|
---|
4730 | }
|
---|
4731 |
|
---|
4732 | my %make_list;
|
---|
4733 |
|
---|
4734 | # &scan_autoconf_config_files ($WHERE, $CONFIG-FILES)
|
---|
4735 | # ---------------------------------------------------
|
---|
4736 | # Study $CONFIG-FILES which is the first argument to AC_CONFIG_FILES
|
---|
4737 | # (or AC_OUTPUT).
|
---|
4738 | sub scan_autoconf_config_files ($$)
|
---|
4739 | {
|
---|
4740 | my ($where, $config_files) = @_;
|
---|
4741 |
|
---|
4742 | # Look at potential Makefile.am's.
|
---|
4743 | foreach (split ' ', $config_files)
|
---|
4744 | {
|
---|
4745 | # Must skip empty string for Perl 4.
|
---|
4746 | next if $_ eq "\\" || $_ eq '';
|
---|
4747 |
|
---|
4748 | # Handle $local:$input syntax.
|
---|
4749 | my ($local, @rest) = split (/:/);
|
---|
4750 | @rest = ("$local.in",) unless @rest;
|
---|
4751 | my $input = locate_am @rest;
|
---|
4752 | if ($input)
|
---|
4753 | {
|
---|
4754 | # We have a file that automake should generate.
|
---|
4755 | $make_list{$input} = join (':', ($local, @rest));
|
---|
4756 | }
|
---|
4757 | else
|
---|
4758 | {
|
---|
4759 | # We have a file that automake should cause to be
|
---|
4760 | # rebuilt, but shouldn't generate itself.
|
---|
4761 | push (@other_input_files, $_);
|
---|
4762 | }
|
---|
4763 | $ac_config_files_location{$local} = $where;
|
---|
4764 | }
|
---|
4765 | }
|
---|
4766 |
|
---|
4767 |
|
---|
4768 | # &scan_autoconf_traces ($FILENAME)
|
---|
4769 | # ---------------------------------
|
---|
4770 | sub scan_autoconf_traces ($)
|
---|
4771 | {
|
---|
4772 | my ($filename) = @_;
|
---|
4773 |
|
---|
4774 | # Macros to trace, with their minimal number of arguments.
|
---|
4775 | #
|
---|
4776 | # IMPORTANT: If you add a macro here, you should also add this macro
|
---|
4777 | # ========= to Automake-preselection in autoconf/lib/autom4te.in.
|
---|
4778 | my %traced = (
|
---|
4779 | AC_CANONICAL_BUILD => 0,
|
---|
4780 | AC_CANONICAL_HOST => 0,
|
---|
4781 | AC_CANONICAL_TARGET => 0,
|
---|
4782 | AC_CONFIG_AUX_DIR => 1,
|
---|
4783 | AC_CONFIG_FILES => 1,
|
---|
4784 | AC_CONFIG_HEADERS => 1,
|
---|
4785 | AC_CONFIG_LIBOBJ_DIR => 1,
|
---|
4786 | AC_CONFIG_LINKS => 1,
|
---|
4787 | AC_INIT => 0,
|
---|
4788 | AC_LIBSOURCE => 1,
|
---|
4789 | AC_REQUIRE_AUX_FILE => 1,
|
---|
4790 | AC_SUBST_TRACE => 1,
|
---|
4791 | AM_AUTOMAKE_VERSION => 1,
|
---|
4792 | AM_CONDITIONAL => 2,
|
---|
4793 | AM_ENABLE_MULTILIB => 0,
|
---|
4794 | AM_GNU_GETTEXT => 0,
|
---|
4795 | AM_GNU_GETTEXT_INTL_SUBDIR => 0,
|
---|
4796 | AM_INIT_AUTOMAKE => 0,
|
---|
4797 | AM_MAINTAINER_MODE => 0,
|
---|
4798 | AM_PROG_CC_C_O => 0,
|
---|
4799 | _AM_SUBST_NOTMAKE => 1,
|
---|
4800 | LT_SUPPORTED_TAG => 1,
|
---|
4801 | _LT_AC_TAGCONFIG => 0,
|
---|
4802 | m4_include => 1,
|
---|
4803 | m4_sinclude => 1,
|
---|
4804 | sinclude => 1,
|
---|
4805 | );
|
---|
4806 |
|
---|
4807 | my $traces = ($ENV{AUTOCONF} || 'autoconf') . " ";
|
---|
4808 |
|
---|
4809 | # Use a separator unlikely to be used, not `:', the default, which
|
---|
4810 | # has a precise meaning for AC_CONFIG_FILES and so on.
|
---|
4811 | $traces .= join (' ',
|
---|
4812 | map { "--trace=$_" . ':\$f:\$l::\$n::\${::}%' }
|
---|
4813 | (keys %traced));
|
---|
4814 |
|
---|
4815 | my $tracefh = new Automake::XFile ("$traces $filename |");
|
---|
4816 | verb "reading $traces";
|
---|
4817 |
|
---|
4818 | while ($_ = $tracefh->getline)
|
---|
4819 | {
|
---|
4820 | chomp;
|
---|
4821 | my ($here, @args) = split (/::/);
|
---|
4822 | my $where = new Automake::Location $here;
|
---|
4823 | my $macro = $args[0];
|
---|
4824 |
|
---|
4825 | prog_error ("unrequested trace `$macro'")
|
---|
4826 | unless exists $traced{$macro};
|
---|
4827 |
|
---|
4828 | # Skip and diagnose malformed calls.
|
---|
4829 | if ($#args < $traced{$macro})
|
---|
4830 | {
|
---|
4831 | msg ('syntax', $where, "not enough arguments for $macro");
|
---|
4832 | next;
|
---|
4833 | }
|
---|
4834 |
|
---|
4835 | # Alphabetical ordering please.
|
---|
4836 | if ($macro eq 'AC_CANONICAL_BUILD')
|
---|
4837 | {
|
---|
4838 | if ($seen_canonical <= AC_CANONICAL_BUILD)
|
---|
4839 | {
|
---|
4840 | $seen_canonical = AC_CANONICAL_BUILD;
|
---|
4841 | $canonical_location = $where;
|
---|
4842 | }
|
---|
4843 | }
|
---|
4844 | elsif ($macro eq 'AC_CANONICAL_HOST')
|
---|
4845 | {
|
---|
4846 | if ($seen_canonical <= AC_CANONICAL_HOST)
|
---|
4847 | {
|
---|
4848 | $seen_canonical = AC_CANONICAL_HOST;
|
---|
4849 | $canonical_location = $where;
|
---|
4850 | }
|
---|
4851 | }
|
---|
4852 | elsif ($macro eq 'AC_CANONICAL_TARGET')
|
---|
4853 | {
|
---|
4854 | $seen_canonical = AC_CANONICAL_TARGET;
|
---|
4855 | $canonical_location = $where;
|
---|
4856 | }
|
---|
4857 | elsif ($macro eq 'AC_CONFIG_AUX_DIR')
|
---|
4858 | {
|
---|
4859 | if ($seen_init_automake)
|
---|
4860 | {
|
---|
4861 | error ($where, "AC_CONFIG_AUX_DIR must be called before "
|
---|
4862 | . "AM_INIT_AUTOMAKE...", partial => 1);
|
---|
4863 | error ($seen_init_automake, "... AM_INIT_AUTOMAKE called here");
|
---|
4864 | }
|
---|
4865 | $config_aux_dir = $args[1];
|
---|
4866 | $config_aux_dir_set_in_configure_ac = 1;
|
---|
4867 | $relative_dir = '.';
|
---|
4868 | check_directory ($config_aux_dir, $where);
|
---|
4869 | }
|
---|
4870 | elsif ($macro eq 'AC_CONFIG_FILES')
|
---|
4871 | {
|
---|
4872 | # Look at potential Makefile.am's.
|
---|
4873 | scan_autoconf_config_files ($where, $args[1]);
|
---|
4874 | }
|
---|
4875 | elsif ($macro eq 'AC_CONFIG_HEADERS')
|
---|
4876 | {
|
---|
4877 | foreach my $spec (split (' ', $args[1]))
|
---|
4878 | {
|
---|
4879 | my ($dest, @src) = split (':', $spec);
|
---|
4880 | $ac_config_files_location{$dest} = $where;
|
---|
4881 | push @config_headers, $spec;
|
---|
4882 | }
|
---|
4883 | }
|
---|
4884 | elsif ($macro eq 'AC_CONFIG_LIBOBJ_DIR')
|
---|
4885 | {
|
---|
4886 | $config_libobj_dir = $args[1];
|
---|
4887 | $relative_dir = '.';
|
---|
4888 | check_directory ($config_libobj_dir, $where);
|
---|
4889 | }
|
---|
4890 | elsif ($macro eq 'AC_CONFIG_LINKS')
|
---|
4891 | {
|
---|
4892 | foreach my $spec (split (' ', $args[1]))
|
---|
4893 | {
|
---|
4894 | my ($dest, $src) = split (':', $spec);
|
---|
4895 | $ac_config_files_location{$dest} = $where;
|
---|
4896 | push @config_links, $spec;
|
---|
4897 | }
|
---|
4898 | }
|
---|
4899 | elsif ($macro eq 'AC_INIT')
|
---|
4900 | {
|
---|
4901 | if (defined $args[2])
|
---|
4902 | {
|
---|
4903 | $package_version = $args[2];
|
---|
4904 | $package_version_location = $where;
|
---|
4905 | }
|
---|
4906 | }
|
---|
4907 | elsif ($macro eq 'AC_LIBSOURCE')
|
---|
4908 | {
|
---|
4909 | $libsources{$args[1]} = $here;
|
---|
4910 | }
|
---|
4911 | elsif ($macro eq 'AC_REQUIRE_AUX_FILE')
|
---|
4912 | {
|
---|
4913 | # Only remember the first time a file is required.
|
---|
4914 | $required_aux_file{$args[1]} = $where
|
---|
4915 | unless exists $required_aux_file{$args[1]};
|
---|
4916 | }
|
---|
4917 | elsif ($macro eq 'AC_SUBST_TRACE')
|
---|
4918 | {
|
---|
4919 | # Just check for alphanumeric in AC_SUBST_TRACE. If you do
|
---|
4920 | # AC_SUBST(5), then too bad.
|
---|
4921 | $configure_vars{$args[1]} = $where
|
---|
4922 | if $args[1] =~ /^\w+$/;
|
---|
4923 | }
|
---|
4924 | elsif ($macro eq 'AM_AUTOMAKE_VERSION')
|
---|
4925 | {
|
---|
4926 | error ($where,
|
---|
4927 | "version mismatch. This is Automake $VERSION,\n" .
|
---|
4928 | "but the definition used by this AM_INIT_AUTOMAKE\n" .
|
---|
4929 | "comes from Automake $args[1]. You should recreate\n" .
|
---|
4930 | "aclocal.m4 with aclocal and run automake again.\n",
|
---|
4931 | # $? = 63 is used to indicate version mismatch to missing.
|
---|
4932 | exit_code => 63)
|
---|
4933 | if $VERSION ne $args[1];
|
---|
4934 |
|
---|
4935 | $seen_automake_version = 1;
|
---|
4936 | }
|
---|
4937 | elsif ($macro eq 'AM_CONDITIONAL')
|
---|
4938 | {
|
---|
4939 | $configure_cond{$args[1]} = $where;
|
---|
4940 | }
|
---|
4941 | elsif ($macro eq 'AM_ENABLE_MULTILIB')
|
---|
4942 | {
|
---|
4943 | $seen_multilib = $where;
|
---|
4944 | }
|
---|
4945 | elsif ($macro eq 'AM_GNU_GETTEXT')
|
---|
4946 | {
|
---|
4947 | $seen_gettext = $where;
|
---|
4948 | $ac_gettext_location = $where;
|
---|
4949 | $seen_gettext_external = grep ($_ eq 'external', @args);
|
---|
4950 | }
|
---|
4951 | elsif ($macro eq 'AM_GNU_GETTEXT_INTL_SUBDIR')
|
---|
4952 | {
|
---|
4953 | $seen_gettext_intl = $where;
|
---|
4954 | }
|
---|
4955 | elsif ($macro eq 'AM_INIT_AUTOMAKE')
|
---|
4956 | {
|
---|
4957 | $seen_init_automake = $where;
|
---|
4958 | if (defined $args[2])
|
---|
4959 | {
|
---|
4960 | $package_version = $args[2];
|
---|
4961 | $package_version_location = $where;
|
---|
4962 | }
|
---|
4963 | elsif (defined $args[1])
|
---|
4964 | {
|
---|
4965 | exit $exit_code
|
---|
4966 | if (process_global_option_list ($where,
|
---|
4967 | split (' ', $args[1])));
|
---|
4968 | }
|
---|
4969 | }
|
---|
4970 | elsif ($macro eq 'AM_MAINTAINER_MODE')
|
---|
4971 | {
|
---|
4972 | $seen_maint_mode = $where;
|
---|
4973 | }
|
---|
4974 | elsif ($macro eq 'AM_PROG_CC_C_O')
|
---|
4975 | {
|
---|
4976 | $seen_cc_c_o = $where;
|
---|
4977 | }
|
---|
4978 | elsif ($macro eq '_AM_SUBST_NOTMAKE')
|
---|
4979 | {
|
---|
4980 | $ignored_configure_vars{$args[1]} = $where;
|
---|
4981 | }
|
---|
4982 | elsif ($macro eq 'm4_include'
|
---|
4983 | || $macro eq 'm4_sinclude'
|
---|
4984 | || $macro eq 'sinclude')
|
---|
4985 | {
|
---|
4986 | # Skip missing `sinclude'd files.
|
---|
4987 | next if $macro ne 'm4_include' && ! -f $args[1];
|
---|
4988 |
|
---|
4989 | # Some modified versions of Autoconf don't use
|
---|
4990 | # frozen files. Consequently it's possible that we see all
|
---|
4991 | # m4_include's performed during Autoconf's startup.
|
---|
4992 | # Obviously we don't want to distribute Autoconf's files
|
---|
4993 | # so we skip absolute filenames here.
|
---|
4994 | push @configure_deps, '$(top_srcdir)/' . $args[1]
|
---|
4995 | unless $here =~ m,^(?:\w:)?[\\/],;
|
---|
4996 | # Keep track of the greatest timestamp.
|
---|
4997 | if (-e $args[1])
|
---|
4998 | {
|
---|
4999 | my $mtime = mtime $args[1];
|
---|
5000 | $configure_deps_greatest_timestamp = $mtime
|
---|
5001 | if $mtime > $configure_deps_greatest_timestamp;
|
---|
5002 | }
|
---|
5003 | }
|
---|
5004 | elsif ($macro eq 'LT_SUPPORTED_TAG')
|
---|
5005 | {
|
---|
5006 | $libtool_tags{$args[1]} = 1;
|
---|
5007 | $libtool_new_api = 1;
|
---|
5008 | }
|
---|
5009 | elsif ($macro eq '_LT_AC_TAGCONFIG')
|
---|
5010 | {
|
---|
5011 | # _LT_AC_TAGCONFIG is an old macro present in Libtool 1.5.
|
---|
5012 | # We use it to detect whether tags are supported. Our
|
---|
5013 | # preferred interface is LT_SUPPORTED_TAG, but it was
|
---|
5014 | # introduced in Libtool 1.6.
|
---|
5015 | if (0 == keys %libtool_tags)
|
---|
5016 | {
|
---|
5017 | # Hardcode the tags supported by Libtool 1.5.
|
---|
5018 | %libtool_tags = (CC => 1, CXX => 1, GCJ => 1, F77 => 1);
|
---|
5019 | }
|
---|
5020 | }
|
---|
5021 | }
|
---|
5022 |
|
---|
5023 | $tracefh->close;
|
---|
5024 | }
|
---|
5025 |
|
---|
5026 |
|
---|
5027 | # &scan_autoconf_files ()
|
---|
5028 | # -----------------------
|
---|
5029 | # Check whether we use `configure.ac' or `configure.in'.
|
---|
5030 | # Scan it (and possibly `aclocal.m4') for interesting things.
|
---|
5031 | # We must scan aclocal.m4 because there might be AC_SUBSTs and such there.
|
---|
5032 | sub scan_autoconf_files ()
|
---|
5033 | {
|
---|
5034 | # Reinitialize libsources here. This isn't really necessary,
|
---|
5035 | # since we currently assume there is only one configure.ac. But
|
---|
5036 | # that won't always be the case.
|
---|
5037 | %libsources = ();
|
---|
5038 |
|
---|
5039 | # Keep track of the youngest configure dependency.
|
---|
5040 | $configure_deps_greatest_timestamp = mtime $configure_ac;
|
---|
5041 | if (-e 'aclocal.m4')
|
---|
5042 | {
|
---|
5043 | my $mtime = mtime 'aclocal.m4';
|
---|
5044 | $configure_deps_greatest_timestamp = $mtime
|
---|
5045 | if $mtime > $configure_deps_greatest_timestamp;
|
---|
5046 | }
|
---|
5047 |
|
---|
5048 | scan_autoconf_traces ($configure_ac);
|
---|
5049 |
|
---|
5050 | @configure_input_files = sort keys %make_list;
|
---|
5051 | # Set input and output files if not specified by user.
|
---|
5052 | if (! @input_files)
|
---|
5053 | {
|
---|
5054 | @input_files = @configure_input_files;
|
---|
5055 | %output_files = %make_list;
|
---|
5056 | }
|
---|
5057 |
|
---|
5058 |
|
---|
5059 | if (! $seen_init_automake)
|
---|
5060 | {
|
---|
5061 | err_ac ("no proper invocation of AM_INIT_AUTOMAKE was found.\nYou "
|
---|
5062 | . "should verify that $configure_ac invokes AM_INIT_AUTOMAKE,"
|
---|
5063 | . "\nthat aclocal.m4 is present in the top-level directory,\n"
|
---|
5064 | . "and that aclocal.m4 was recently regenerated "
|
---|
5065 | . "(using aclocal).");
|
---|
5066 | }
|
---|
5067 | else
|
---|
5068 | {
|
---|
5069 | if (! $seen_automake_version)
|
---|
5070 | {
|
---|
5071 | if (-f 'aclocal.m4')
|
---|
5072 | {
|
---|
5073 | error ($seen_init_automake,
|
---|
5074 | "your implementation of AM_INIT_AUTOMAKE comes from " .
|
---|
5075 | "an\nold Automake version. You should recreate " .
|
---|
5076 | "aclocal.m4\nwith aclocal and run automake again.\n",
|
---|
5077 | # $? = 63 is used to indicate version mismatch to missing.
|
---|
5078 | exit_code => 63);
|
---|
5079 | }
|
---|
5080 | else
|
---|
5081 | {
|
---|
5082 | error ($seen_init_automake,
|
---|
5083 | "no proper implementation of AM_INIT_AUTOMAKE was " .
|
---|
5084 | "found,\nprobably because aclocal.m4 is missing...\n" .
|
---|
5085 | "You should run aclocal to create this file, then\n" .
|
---|
5086 | "run automake again.\n");
|
---|
5087 | }
|
---|
5088 | }
|
---|
5089 | }
|
---|
5090 |
|
---|
5091 | locate_aux_dir ();
|
---|
5092 |
|
---|
5093 | # Reorder @input_files so that the Makefile that distributes aux
|
---|
5094 | # files is processed last. This is important because each directory
|
---|
5095 | # can require auxiliary scripts and we should wait until they have
|
---|
5096 | # been installed before distributing them.
|
---|
5097 |
|
---|
5098 | # The Makefile.in that distribute the aux files is the one in
|
---|
5099 | # $config_aux_dir or the top-level Makefile.
|
---|
5100 | my $auxdirdist = is_make_dir ($config_aux_dir) ? $config_aux_dir : '.';
|
---|
5101 | my @new_input_files = ();
|
---|
5102 | while (@input_files)
|
---|
5103 | {
|
---|
5104 | my $in = pop @input_files;
|
---|
5105 | my @ins = split (/:/, $output_files{$in});
|
---|
5106 | if (dirname ($ins[0]) eq $auxdirdist)
|
---|
5107 | {
|
---|
5108 | push @new_input_files, $in;
|
---|
5109 | $automake_will_process_aux_dir = 1;
|
---|
5110 | }
|
---|
5111 | else
|
---|
5112 | {
|
---|
5113 | unshift @new_input_files, $in;
|
---|
5114 | }
|
---|
5115 | }
|
---|
5116 | @input_files = @new_input_files;
|
---|
5117 |
|
---|
5118 | # If neither the auxdir/Makefile nor the ./Makefile are generated
|
---|
5119 | # by Automake, we won't distribute the aux files anyway. Assume
|
---|
5120 | # the user know what (s)he does, and pretend we will distribute
|
---|
5121 | # them to disable the error in require_file_internal.
|
---|
5122 | $automake_will_process_aux_dir = 1 if ! is_make_dir ($auxdirdist);
|
---|
5123 |
|
---|
5124 | # Look for some files we need. Always check for these. This
|
---|
5125 | # check must be done for every run, even those where we are only
|
---|
5126 | # looking at a subdir Makefile. We must set relative_dir for
|
---|
5127 | # maybe_push_required_file to work.
|
---|
5128 | $relative_dir = '.';
|
---|
5129 | foreach my $file (keys %required_aux_file)
|
---|
5130 | {
|
---|
5131 | require_conf_file ($required_aux_file{$file}->get, FOREIGN, $file)
|
---|
5132 | }
|
---|
5133 | err_am "`install.sh' is an anachronism; use `install-sh' instead"
|
---|
5134 | if -f $config_aux_dir . '/install.sh';
|
---|
5135 |
|
---|
5136 | # Preserve dist_common for later.
|
---|
5137 | $configure_dist_common = variable_value ('DIST_COMMON') || '';
|
---|
5138 |
|
---|
5139 | }
|
---|
5140 |
|
---|
5141 | ################################################################
|
---|
5142 |
|
---|
5143 | # Set up for Cygnus mode.
|
---|
5144 | sub check_cygnus
|
---|
5145 | {
|
---|
5146 | my $cygnus = option 'cygnus';
|
---|
5147 | return unless $cygnus;
|
---|
5148 |
|
---|
5149 | set_strictness ('foreign');
|
---|
5150 | set_option ('no-installinfo', $cygnus);
|
---|
5151 | set_option ('no-dependencies', $cygnus);
|
---|
5152 | set_option ('no-dist', $cygnus);
|
---|
5153 |
|
---|
5154 | err_ac "`AM_MAINTAINER_MODE' required when --cygnus specified"
|
---|
5155 | if !$seen_maint_mode;
|
---|
5156 | }
|
---|
5157 |
|
---|
5158 | # Do any extra checking for GNU standards.
|
---|
5159 | sub check_gnu_standards
|
---|
5160 | {
|
---|
5161 | if ($relative_dir eq '.')
|
---|
5162 | {
|
---|
5163 | # In top level (or only) directory.
|
---|
5164 | require_file ("$am_file.am", GNU,
|
---|
5165 | qw/INSTALL NEWS README AUTHORS ChangeLog/);
|
---|
5166 |
|
---|
5167 | # Accept one of these three licenses; default to COPYING.
|
---|
5168 | # Make sure we do not overwrite an existing license.
|
---|
5169 | my $license;
|
---|
5170 | foreach (qw /COPYING COPYING.LIB COPYING.LESSER/)
|
---|
5171 | {
|
---|
5172 | if (-f $_)
|
---|
5173 | {
|
---|
5174 | $license = $_;
|
---|
5175 | last;
|
---|
5176 | }
|
---|
5177 | }
|
---|
5178 | require_file ("$am_file.am", GNU, 'COPYING')
|
---|
5179 | unless $license;
|
---|
5180 | }
|
---|
5181 |
|
---|
5182 | for my $opt ('no-installman', 'no-installinfo')
|
---|
5183 | {
|
---|
5184 | msg ('error-gnu', option $opt,
|
---|
5185 | "option `$opt' disallowed by GNU standards")
|
---|
5186 | if option $opt;
|
---|
5187 | }
|
---|
5188 | }
|
---|
5189 |
|
---|
5190 | # Do any extra checking for GNITS standards.
|
---|
5191 | sub check_gnits_standards
|
---|
5192 | {
|
---|
5193 | if ($relative_dir eq '.')
|
---|
5194 | {
|
---|
5195 | # In top level (or only) directory.
|
---|
5196 | require_file ("$am_file.am", GNITS, 'THANKS');
|
---|
5197 | }
|
---|
5198 | }
|
---|
5199 |
|
---|
5200 | ################################################################
|
---|
5201 | #
|
---|
5202 | # Functions to handle files of each language.
|
---|
5203 |
|
---|
5204 | # Each `lang_X_rewrite($DIRECTORY, $BASE, $EXT)' function follows a
|
---|
5205 | # simple formula: Return value is LANG_SUBDIR if the resulting object
|
---|
5206 | # file should be in a subdir if the source file is, LANG_PROCESS if
|
---|
5207 | # file is to be dealt with, LANG_IGNORE otherwise.
|
---|
5208 |
|
---|
5209 | # Much of the actual processing is handled in
|
---|
5210 | # handle_single_transform. These functions exist so that
|
---|
5211 | # auxiliary information can be recorded for a later cleanup pass.
|
---|
5212 | # Note that the calls to these functions are computed, so don't bother
|
---|
5213 | # searching for their precise names in the source.
|
---|
5214 |
|
---|
5215 | # This is just a convenience function that can be used to determine
|
---|
5216 | # when a subdir object should be used.
|
---|
5217 | sub lang_sub_obj
|
---|
5218 | {
|
---|
5219 | return option 'subdir-objects' ? LANG_SUBDIR : LANG_PROCESS;
|
---|
5220 | }
|
---|
5221 |
|
---|
5222 | # Rewrite a single C source file.
|
---|
5223 | sub lang_c_rewrite
|
---|
5224 | {
|
---|
5225 | my ($directory, $base, $ext, $nonansi_obj, $have_per_exec_flags, $var) = @_;
|
---|
5226 |
|
---|
5227 | if (option 'ansi2knr' && $base =~ /_$/)
|
---|
5228 | {
|
---|
5229 | # FIXME: include line number in error.
|
---|
5230 | err_am "C source file `$base.c' would be deleted by ansi2knr rules";
|
---|
5231 | }
|
---|
5232 |
|
---|
5233 | my $r = LANG_PROCESS;
|
---|
5234 | if (option 'subdir-objects')
|
---|
5235 | {
|
---|
5236 | $r = LANG_SUBDIR;
|
---|
5237 | if ($directory && $directory ne '.')
|
---|
5238 | {
|
---|
5239 | $base = $directory . '/' . $base;
|
---|
5240 |
|
---|
5241 | # libtool is always able to put the object at the proper place,
|
---|
5242 | # so we do not have to require AM_PROG_CC_C_O when building .lo files.
|
---|
5243 | msg_var ('portability', $var,
|
---|
5244 | "compiling `$base.c' in subdir requires "
|
---|
5245 | . "`AM_PROG_CC_C_O' in `$configure_ac'",
|
---|
5246 | uniq_scope => US_GLOBAL,
|
---|
5247 | uniq_part => 'AM_PROG_CC_C_O subdir')
|
---|
5248 | unless $seen_cc_c_o || $nonansi_obj eq '.lo';
|
---|
5249 | }
|
---|
5250 |
|
---|
5251 | # In this case we already have the directory information, so
|
---|
5252 | # don't add it again.
|
---|
5253 | $de_ansi_files{$base} = '';
|
---|
5254 | }
|
---|
5255 | else
|
---|
5256 | {
|
---|
5257 | $de_ansi_files{$base} = (($directory eq '.' || $directory eq '')
|
---|
5258 | ? ''
|
---|
5259 | : "$directory/");
|
---|
5260 | }
|
---|
5261 |
|
---|
5262 | if (! $seen_cc_c_o
|
---|
5263 | && $have_per_exec_flags
|
---|
5264 | && ! option 'subdir-objects'
|
---|
5265 | && $nonansi_obj ne '.lo')
|
---|
5266 | {
|
---|
5267 | msg_var ('portability',
|
---|
5268 | $var, "compiling `$base.c' with per-target flags requires "
|
---|
5269 | . "`AM_PROG_CC_C_O' in `$configure_ac'",
|
---|
5270 | uniq_scope => US_GLOBAL,
|
---|
5271 | uniq_part => 'AM_PROG_CC_C_O per-target')
|
---|
5272 | }
|
---|
5273 |
|
---|
5274 | return $r;
|
---|
5275 | }
|
---|
5276 |
|
---|
5277 | # Rewrite a single C++ source file.
|
---|
5278 | sub lang_cxx_rewrite
|
---|
5279 | {
|
---|
5280 | return &lang_sub_obj;
|
---|
5281 | }
|
---|
5282 |
|
---|
5283 | # Rewrite a single header file.
|
---|
5284 | sub lang_header_rewrite
|
---|
5285 | {
|
---|
5286 | # Header files are simply ignored.
|
---|
5287 | return LANG_IGNORE;
|
---|
5288 | }
|
---|
5289 |
|
---|
5290 | # Rewrite a single yacc file.
|
---|
5291 | sub lang_yacc_rewrite
|
---|
5292 | {
|
---|
5293 | my ($directory, $base, $ext) = @_;
|
---|
5294 |
|
---|
5295 | my $r = &lang_sub_obj;
|
---|
5296 | (my $newext = $ext) =~ tr/y/c/;
|
---|
5297 | return ($r, $newext);
|
---|
5298 | }
|
---|
5299 |
|
---|
5300 | # Rewrite a single yacc++ file.
|
---|
5301 | sub lang_yaccxx_rewrite
|
---|
5302 | {
|
---|
5303 | my ($directory, $base, $ext) = @_;
|
---|
5304 |
|
---|
5305 | my $r = &lang_sub_obj;
|
---|
5306 | (my $newext = $ext) =~ tr/y/c/;
|
---|
5307 | return ($r, $newext);
|
---|
5308 | }
|
---|
5309 |
|
---|
5310 | # Rewrite a single lex file.
|
---|
5311 | sub lang_lex_rewrite
|
---|
5312 | {
|
---|
5313 | my ($directory, $base, $ext) = @_;
|
---|
5314 |
|
---|
5315 | my $r = &lang_sub_obj;
|
---|
5316 | (my $newext = $ext) =~ tr/l/c/;
|
---|
5317 | return ($r, $newext);
|
---|
5318 | }
|
---|
5319 |
|
---|
5320 | # Rewrite a single lex++ file.
|
---|
5321 | sub lang_lexxx_rewrite
|
---|
5322 | {
|
---|
5323 | my ($directory, $base, $ext) = @_;
|
---|
5324 |
|
---|
5325 | my $r = &lang_sub_obj;
|
---|
5326 | (my $newext = $ext) =~ tr/l/c/;
|
---|
5327 | return ($r, $newext);
|
---|
5328 | }
|
---|
5329 |
|
---|
5330 | # Rewrite a single assembly file.
|
---|
5331 | sub lang_asm_rewrite
|
---|
5332 | {
|
---|
5333 | return &lang_sub_obj;
|
---|
5334 | }
|
---|
5335 |
|
---|
5336 | # Rewrite a single preprocessed assembly file.
|
---|
5337 | sub lang_cppasm_rewrite
|
---|
5338 | {
|
---|
5339 | return &lang_sub_obj;
|
---|
5340 | }
|
---|
5341 |
|
---|
5342 | # Rewrite a single Fortran 77 file.
|
---|
5343 | sub lang_f77_rewrite
|
---|
5344 | {
|
---|
5345 | return LANG_PROCESS;
|
---|
5346 | }
|
---|
5347 |
|
---|
5348 | # Rewrite a single Fortran file.
|
---|
5349 | sub lang_fc_rewrite
|
---|
5350 | {
|
---|
5351 | return LANG_PROCESS;
|
---|
5352 | }
|
---|
5353 |
|
---|
5354 | # Rewrite a single preprocessed Fortran file.
|
---|
5355 | sub lang_ppfc_rewrite
|
---|
5356 | {
|
---|
5357 | return LANG_PROCESS;
|
---|
5358 | }
|
---|
5359 |
|
---|
5360 | # Rewrite a single preprocessed Fortran 77 file.
|
---|
5361 | sub lang_ppf77_rewrite
|
---|
5362 | {
|
---|
5363 | return LANG_PROCESS;
|
---|
5364 | }
|
---|
5365 |
|
---|
5366 | # Rewrite a single ratfor file.
|
---|
5367 | sub lang_ratfor_rewrite
|
---|
5368 | {
|
---|
5369 | return LANG_PROCESS;
|
---|
5370 | }
|
---|
5371 |
|
---|
5372 | # Rewrite a single Objective C file.
|
---|
5373 | sub lang_objc_rewrite
|
---|
5374 | {
|
---|
5375 | return &lang_sub_obj;
|
---|
5376 | }
|
---|
5377 |
|
---|
5378 | # Rewrite a single Unified Parallel C file.
|
---|
5379 | sub lang_upc_rewrite
|
---|
5380 | {
|
---|
5381 | return &lang_sub_obj;
|
---|
5382 | }
|
---|
5383 |
|
---|
5384 | # Rewrite a single Java file.
|
---|
5385 | sub lang_java_rewrite
|
---|
5386 | {
|
---|
5387 | return LANG_SUBDIR;
|
---|
5388 | }
|
---|
5389 |
|
---|
5390 | # The lang_X_finish functions are called after all source file
|
---|
5391 | # processing is done. Each should handle defining rules for the
|
---|
5392 | # language, etc. A finish function is only called if a source file of
|
---|
5393 | # the appropriate type has been seen.
|
---|
5394 |
|
---|
5395 | sub lang_c_finish
|
---|
5396 | {
|
---|
5397 | # Push all libobjs files onto de_ansi_files. We actually only
|
---|
5398 | # push files which exist in the current directory, and which are
|
---|
5399 | # genuine source files.
|
---|
5400 | foreach my $file (keys %libsources)
|
---|
5401 | {
|
---|
5402 | if ($file =~ /^(.*)\.[cly]$/ && -f "$relative_dir/$file")
|
---|
5403 | {
|
---|
5404 | $de_ansi_files{$1} = ''
|
---|
5405 | }
|
---|
5406 | }
|
---|
5407 |
|
---|
5408 | if (option 'ansi2knr' && keys %de_ansi_files)
|
---|
5409 | {
|
---|
5410 | # Make all _.c files depend on their corresponding .c files.
|
---|
5411 | my @objects;
|
---|
5412 | foreach my $base (sort keys %de_ansi_files)
|
---|
5413 | {
|
---|
5414 | # Each _.c file must depend on ansi2knr; otherwise it
|
---|
5415 | # might be used in a parallel build before it is built.
|
---|
5416 | # We need to support files in the srcdir and in the build
|
---|
5417 | # dir (because these files might be auto-generated. But
|
---|
5418 | # we can't use $< -- some makes only define $< during a
|
---|
5419 | # suffix rule.
|
---|
5420 | my $ansfile = $de_ansi_files{$base} . $base . '.c';
|
---|
5421 | $output_rules .= ($base . "_.c: $ansfile \$(ANSI2KNR)\n\t"
|
---|
5422 | . '$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) '
|
---|
5423 | . '`if test -f $(srcdir)/' . $ansfile
|
---|
5424 | . '; then echo $(srcdir)/' . $ansfile
|
---|
5425 | . '; else echo ' . $ansfile . '; fi` '
|
---|
5426 | . "| sed 's/^# \\([0-9]\\)/#line \\1/' "
|
---|
5427 | . '| $(ANSI2KNR) > $@'
|
---|
5428 | # If ansi2knr fails then we shouldn't
|
---|
5429 | # create the _.c file
|
---|
5430 | . " || rm -f \$\@\n");
|
---|
5431 | push (@objects, $base . '_.$(OBJEXT)');
|
---|
5432 | push (@objects, $base . '_.lo')
|
---|
5433 | if var ('LIBTOOL');
|
---|
5434 |
|
---|
5435 | # Explicitly clean the _.c files if they are in a
|
---|
5436 | # subdirectory. (In the current directory they get erased
|
---|
5437 | # by a `rm -f *_.c' rule.)
|
---|
5438 | $clean_files{$base . '_.c'} = MOSTLY_CLEAN
|
---|
5439 | if dirname ($base) ne '.';
|
---|
5440 | }
|
---|
5441 |
|
---|
5442 | # Make all _.o (and _.lo) files depend on ansi2knr.
|
---|
5443 | # Use a sneaky little hack to make it print nicely.
|
---|
5444 | &pretty_print_rule ('', '', @objects, ':', '$(ANSI2KNR)');
|
---|
5445 | }
|
---|
5446 | }
|
---|
5447 |
|
---|
5448 | # This is a yacc helper which is called whenever we have decided to
|
---|
5449 | # compile a yacc file.
|
---|
5450 | sub lang_yacc_target_hook
|
---|
5451 | {
|
---|
5452 | my ($self, $aggregate, $output, $input, %transform) = @_;
|
---|
5453 |
|
---|
5454 | my $flag = $aggregate . "_YFLAGS";
|
---|
5455 | my $flagvar = var $flag;
|
---|
5456 | my $YFLAGSvar = var 'YFLAGS';
|
---|
5457 | if (($flagvar && $flagvar->variable_value =~ /$DASH_D_PATTERN/o)
|
---|
5458 | || ($YFLAGSvar && $YFLAGSvar->variable_value =~ /$DASH_D_PATTERN/o))
|
---|
5459 | {
|
---|
5460 | (my $output_base = $output) =~ s/$KNOWN_EXTENSIONS_PATTERN$//;
|
---|
5461 | my $header = $output_base . '.h';
|
---|
5462 |
|
---|
5463 | # Found a `-d' that applies to the compilation of this file.
|
---|
5464 | # Add a dependency for the generated header file, and arrange
|
---|
5465 | # for that file to be included in the distribution.
|
---|
5466 | foreach my $cond (Automake::Rule::define (${header}, 'internal',
|
---|
5467 | RULE_AUTOMAKE, TRUE,
|
---|
5468 | INTERNAL))
|
---|
5469 | {
|
---|
5470 | my $condstr = $cond->subst_string;
|
---|
5471 | $output_rules .=
|
---|
5472 | "$condstr${header}: $output\n"
|
---|
5473 | # Recover from removal of $header
|
---|
5474 | . "$condstr\t\@if test ! -f \$@; then \\\n"
|
---|
5475 | . "$condstr\t rm -f $output; \\\n"
|
---|
5476 | . "$condstr\t \$(MAKE) \$(AM_MAKEFLAGS) $output; \\\n"
|
---|
5477 | . "$condstr\telse :; fi\n";
|
---|
5478 | }
|
---|
5479 | # Distribute the generated file, unless its .y source was
|
---|
5480 | # listed in a nodist_ variable. (&handle_source_transform
|
---|
5481 | # will set DIST_SOURCE.)
|
---|
5482 | &push_dist_common ($header)
|
---|
5483 | if $transform{'DIST_SOURCE'};
|
---|
5484 |
|
---|
5485 | # If the files are built in the build directory, then we want
|
---|
5486 | # to remove them with `make clean'. If they are in srcdir
|
---|
5487 | # they shouldn't be touched. However, we can't determine this
|
---|
5488 | # statically, and the GNU rules say that yacc/lex output files
|
---|
5489 | # should be removed by maintainer-clean. So that's what we
|
---|
5490 | # do.
|
---|
5491 | $clean_files{$header} = MAINTAINER_CLEAN;
|
---|
5492 | }
|
---|
5493 | # Erase $OUTPUT on `make maintainer-clean' (by GNU standards).
|
---|
5494 | # See the comment above for $HEADER.
|
---|
5495 | $clean_files{$output} = MAINTAINER_CLEAN;
|
---|
5496 | }
|
---|
5497 |
|
---|
5498 | # This is a lex helper which is called whenever we have decided to
|
---|
5499 | # compile a lex file.
|
---|
5500 | sub lang_lex_target_hook
|
---|
5501 | {
|
---|
5502 | my ($self, $aggregate, $output, $input) = @_;
|
---|
5503 | # If the files are built in the build directory, then we want to
|
---|
5504 | # remove them with `make clean'. If they are in srcdir they
|
---|
5505 | # shouldn't be touched. However, we can't determine this
|
---|
5506 | # statically, and the GNU rules say that yacc/lex output files
|
---|
5507 | # should be removed by maintainer-clean. So that's what we do.
|
---|
5508 | $clean_files{$output} = MAINTAINER_CLEAN;
|
---|
5509 | }
|
---|
5510 |
|
---|
5511 | # This is a helper for both lex and yacc.
|
---|
5512 | sub yacc_lex_finish_helper
|
---|
5513 | {
|
---|
5514 | return if defined $language_scratch{'lex-yacc-done'};
|
---|
5515 | $language_scratch{'lex-yacc-done'} = 1;
|
---|
5516 |
|
---|
5517 | # FIXME: for now, no line number.
|
---|
5518 | require_conf_file ($configure_ac, FOREIGN, 'ylwrap');
|
---|
5519 | &define_variable ('YLWRAP', "$am_config_aux_dir/ylwrap", INTERNAL);
|
---|
5520 | }
|
---|
5521 |
|
---|
5522 | sub lang_yacc_finish
|
---|
5523 | {
|
---|
5524 | return if defined $language_scratch{'yacc-done'};
|
---|
5525 | $language_scratch{'yacc-done'} = 1;
|
---|
5526 |
|
---|
5527 | reject_var 'YACCFLAGS', "`YACCFLAGS' obsolete; use `YFLAGS' instead";
|
---|
5528 |
|
---|
5529 | yacc_lex_finish_helper;
|
---|
5530 | }
|
---|
5531 |
|
---|
5532 |
|
---|
5533 | sub lang_lex_finish
|
---|
5534 | {
|
---|
5535 | return if defined $language_scratch{'lex-done'};
|
---|
5536 | $language_scratch{'lex-done'} = 1;
|
---|
5537 |
|
---|
5538 | yacc_lex_finish_helper;
|
---|
5539 | }
|
---|
5540 |
|
---|
5541 |
|
---|
5542 | # Given a hash table of linker names, pick the name that has the most
|
---|
5543 | # precedence. This is lame, but something has to have global
|
---|
5544 | # knowledge in order to eliminate the conflict. Add more linkers as
|
---|
5545 | # required.
|
---|
5546 | sub resolve_linker
|
---|
5547 | {
|
---|
5548 | my (%linkers) = @_;
|
---|
5549 |
|
---|
5550 | foreach my $l (qw(GCJLINK CXXLINK F77LINK FCLINK OBJCLINK UPCLINK))
|
---|
5551 | {
|
---|
5552 | return $l if defined $linkers{$l};
|
---|
5553 | }
|
---|
5554 | return 'LINK';
|
---|
5555 | }
|
---|
5556 |
|
---|
5557 | # Called to indicate that an extension was used.
|
---|
5558 | sub saw_extension
|
---|
5559 | {
|
---|
5560 | my ($ext) = @_;
|
---|
5561 | if (! defined $extension_seen{$ext})
|
---|
5562 | {
|
---|
5563 | $extension_seen{$ext} = 1;
|
---|
5564 | }
|
---|
5565 | else
|
---|
5566 | {
|
---|
5567 | ++$extension_seen{$ext};
|
---|
5568 | }
|
---|
5569 | }
|
---|
5570 |
|
---|
5571 | # Return the number of files seen for a given language. Knows about
|
---|
5572 | # special cases we care about. FIXME: this is hideous. We need
|
---|
5573 | # something that involves real language objects. For instance yacc
|
---|
5574 | # and yaccxx could both derive from a common yacc class which would
|
---|
5575 | # know about the strange ylwrap requirement. (Or better yet we could
|
---|
5576 | # just not support legacy yacc!)
|
---|
5577 | sub count_files_for_language
|
---|
5578 | {
|
---|
5579 | my ($name) = @_;
|
---|
5580 |
|
---|
5581 | my @names;
|
---|
5582 | if ($name eq 'yacc' || $name eq 'yaccxx')
|
---|
5583 | {
|
---|
5584 | @names = ('yacc', 'yaccxx');
|
---|
5585 | }
|
---|
5586 | elsif ($name eq 'lex' || $name eq 'lexxx')
|
---|
5587 | {
|
---|
5588 | @names = ('lex', 'lexxx');
|
---|
5589 | }
|
---|
5590 | else
|
---|
5591 | {
|
---|
5592 | @names = ($name);
|
---|
5593 | }
|
---|
5594 |
|
---|
5595 | my $r = 0;
|
---|
5596 | foreach $name (@names)
|
---|
5597 | {
|
---|
5598 | my $lang = $languages{$name};
|
---|
5599 | foreach my $ext (@{$lang->extensions})
|
---|
5600 | {
|
---|
5601 | $r += $extension_seen{$ext}
|
---|
5602 | if defined $extension_seen{$ext};
|
---|
5603 | }
|
---|
5604 | }
|
---|
5605 |
|
---|
5606 | return $r
|
---|
5607 | }
|
---|
5608 |
|
---|
5609 | # Called to ask whether source files have been seen . If HEADERS is 1,
|
---|
5610 | # headers can be included.
|
---|
5611 | sub saw_sources_p
|
---|
5612 | {
|
---|
5613 | my ($headers) = @_;
|
---|
5614 |
|
---|
5615 | # count all the sources
|
---|
5616 | my $count = 0;
|
---|
5617 | foreach my $val (values %extension_seen)
|
---|
5618 | {
|
---|
5619 | $count += $val;
|
---|
5620 | }
|
---|
5621 |
|
---|
5622 | if (!$headers)
|
---|
5623 | {
|
---|
5624 | $count -= count_files_for_language ('header');
|
---|
5625 | }
|
---|
5626 |
|
---|
5627 | return $count > 0;
|
---|
5628 | }
|
---|
5629 |
|
---|
5630 |
|
---|
5631 | # register_language (%ATTRIBUTE)
|
---|
5632 | # ------------------------------
|
---|
5633 | # Register a single language.
|
---|
5634 | # Each %ATTRIBUTE is of the form ATTRIBUTE => VALUE.
|
---|
5635 | sub register_language (%)
|
---|
5636 | {
|
---|
5637 | my (%option) = @_;
|
---|
5638 |
|
---|
5639 | # Set the defaults.
|
---|
5640 | $option{'ansi'} = 0
|
---|
5641 | unless defined $option{'ansi'};
|
---|
5642 | $option{'autodep'} = 'no'
|
---|
5643 | unless defined $option{'autodep'};
|
---|
5644 | $option{'linker'} = ''
|
---|
5645 | unless defined $option{'linker'};
|
---|
5646 | $option{'flags'} = []
|
---|
5647 | unless defined $option{'flags'};
|
---|
5648 | $option{'output_extensions'} = sub { return ( '.$(OBJEXT)', '.lo' ) }
|
---|
5649 | unless defined $option{'output_extensions'};
|
---|
5650 | $option{'nodist_specific'} = 0
|
---|
5651 | unless defined $option{'nodist_specific'};
|
---|
5652 |
|
---|
5653 | my $lang = new Language (%option);
|
---|
5654 |
|
---|
5655 | # Fill indexes.
|
---|
5656 | $extension_map{$_} = $lang->name foreach @{$lang->extensions};
|
---|
5657 | $languages{$lang->name} = $lang;
|
---|
5658 | my $link = $lang->linker;
|
---|
5659 | if ($link)
|
---|
5660 | {
|
---|
5661 | if (exists $link_languages{$link})
|
---|
5662 | {
|
---|
5663 | prog_error ("`$link' has different definitions in "
|
---|
5664 | . $lang->name . " and " . $link_languages{$link}->name)
|
---|
5665 | if $lang->link ne $link_languages{$link}->link;
|
---|
5666 | }
|
---|
5667 | else
|
---|
5668 | {
|
---|
5669 | $link_languages{$link} = $lang;
|
---|
5670 | }
|
---|
5671 | }
|
---|
5672 |
|
---|
5673 | # Update the pattern of known extensions.
|
---|
5674 | accept_extensions (@{$lang->extensions});
|
---|
5675 |
|
---|
5676 | # Upate the $suffix_rule map.
|
---|
5677 | foreach my $suffix (@{$lang->extensions})
|
---|
5678 | {
|
---|
5679 | foreach my $dest (&{$lang->output_extensions} ($suffix))
|
---|
5680 | {
|
---|
5681 | register_suffix_rule (INTERNAL, $suffix, $dest);
|
---|
5682 | }
|
---|
5683 | }
|
---|
5684 | }
|
---|
5685 |
|
---|
5686 | # derive_suffix ($EXT, $OBJ)
|
---|
5687 | # --------------------------
|
---|
5688 | # This function is used to find a path from a user-specified suffix $EXT
|
---|
5689 | # to $OBJ or to some other suffix we recognize internally, e.g. `cc'.
|
---|
5690 | sub derive_suffix ($$)
|
---|
5691 | {
|
---|
5692 | my ($source_ext, $obj) = @_;
|
---|
5693 |
|
---|
5694 | while (! $extension_map{$source_ext}
|
---|
5695 | && $source_ext ne $obj
|
---|
5696 | && exists $suffix_rules->{$source_ext}
|
---|
5697 | && exists $suffix_rules->{$source_ext}{$obj})
|
---|
5698 | {
|
---|
5699 | $source_ext = $suffix_rules->{$source_ext}{$obj}[0];
|
---|
5700 | }
|
---|
5701 |
|
---|
5702 | return $source_ext;
|
---|
5703 | }
|
---|
5704 |
|
---|
5705 |
|
---|
5706 | ################################################################
|
---|
5707 |
|
---|
5708 | # Pretty-print something and append to output_rules.
|
---|
5709 | sub pretty_print_rule
|
---|
5710 | {
|
---|
5711 | $output_rules .= &makefile_wrap (@_);
|
---|
5712 | }
|
---|
5713 |
|
---|
5714 |
|
---|
5715 | ################################################################
|
---|
5716 |
|
---|
5717 |
|
---|
5718 | ## -------------------------------- ##
|
---|
5719 | ## Handling the conditional stack. ##
|
---|
5720 | ## -------------------------------- ##
|
---|
5721 |
|
---|
5722 |
|
---|
5723 | # $STRING
|
---|
5724 | # make_conditional_string ($NEGATE, $COND)
|
---|
5725 | # ----------------------------------------
|
---|
5726 | sub make_conditional_string ($$)
|
---|
5727 | {
|
---|
5728 | my ($negate, $cond) = @_;
|
---|
5729 | $cond = "${cond}_TRUE"
|
---|
5730 | unless $cond =~ /^TRUE|FALSE$/;
|
---|
5731 | $cond = Automake::Condition::conditional_negate ($cond)
|
---|
5732 | if $negate;
|
---|
5733 | return $cond;
|
---|
5734 | }
|
---|
5735 |
|
---|
5736 |
|
---|
5737 | my %_am_macro_for_cond =
|
---|
5738 | (
|
---|
5739 | AMDEP => "one of the compiler tests\n"
|
---|
5740 | . " AC_PROG_CC, AC_PROG_CXX, AC_PROG_CXX, AC_PROG_OBJC,\n"
|
---|
5741 | . " AM_PROG_AS, AM_PROG_GCJ, AM_PROG_UPC",
|
---|
5742 | am__fastdepCC => 'AC_PROG_CC',
|
---|
5743 | am__fastdepCCAS => 'AM_PROG_AS',
|
---|
5744 | am__fastdepCXX => 'AC_PROG_CXX',
|
---|
5745 | am__fastdepGCJ => 'AM_PROG_GCJ',
|
---|
5746 | am__fastdepOBJC => 'AC_PROG_OBJC',
|
---|
5747 | am__fastdepUPC => 'AM_PROG_UPC'
|
---|
5748 | );
|
---|
5749 |
|
---|
5750 | # $COND
|
---|
5751 | # cond_stack_if ($NEGATE, $COND, $WHERE)
|
---|
5752 | # --------------------------------------
|
---|
5753 | sub cond_stack_if ($$$)
|
---|
5754 | {
|
---|
5755 | my ($negate, $cond, $where) = @_;
|
---|
5756 |
|
---|
5757 | if (! $configure_cond{$cond} && $cond !~ /^TRUE|FALSE$/)
|
---|
5758 | {
|
---|
5759 | my $text = "$cond does not appear in AM_CONDITIONAL";
|
---|
5760 | my $scope = US_LOCAL;
|
---|
5761 | if (exists $_am_macro_for_cond{$cond})
|
---|
5762 | {
|
---|
5763 | my $mac = $_am_macro_for_cond{$cond};
|
---|
5764 | $text .= "\n The usual way to define `$cond' is to add ";
|
---|
5765 | $text .= ($mac =~ / /) ? $mac : "`$mac'";
|
---|
5766 | $text .= "\n to `$configure_ac' and run `aclocal' and `autoconf' again.";
|
---|
5767 | # These warnings appear in Automake files (depend2.am),
|
---|
5768 | # so there is no need to display them more than once:
|
---|
5769 | $scope = US_GLOBAL;
|
---|
5770 | }
|
---|
5771 | error $where, $text, uniq_scope => $scope;
|
---|
5772 | }
|
---|
5773 |
|
---|
5774 | push (@cond_stack, make_conditional_string ($negate, $cond));
|
---|
5775 |
|
---|
5776 | return new Automake::Condition (@cond_stack);
|
---|
5777 | }
|
---|
5778 |
|
---|
5779 |
|
---|
5780 | # $COND
|
---|
5781 | # cond_stack_else ($NEGATE, $COND, $WHERE)
|
---|
5782 | # ----------------------------------------
|
---|
5783 | sub cond_stack_else ($$$)
|
---|
5784 | {
|
---|
5785 | my ($negate, $cond, $where) = @_;
|
---|
5786 |
|
---|
5787 | if (! @cond_stack)
|
---|
5788 | {
|
---|
5789 | error $where, "else without if";
|
---|
5790 | return FALSE;
|
---|
5791 | }
|
---|
5792 |
|
---|
5793 | $cond_stack[$#cond_stack] =
|
---|
5794 | Automake::Condition::conditional_negate ($cond_stack[$#cond_stack]);
|
---|
5795 |
|
---|
5796 | # If $COND is given, check against it.
|
---|
5797 | if (defined $cond)
|
---|
5798 | {
|
---|
5799 | $cond = make_conditional_string ($negate, $cond);
|
---|
5800 |
|
---|
5801 | error ($where, "else reminder ($negate$cond) incompatible with "
|
---|
5802 | . "current conditional: $cond_stack[$#cond_stack]")
|
---|
5803 | if $cond_stack[$#cond_stack] ne $cond;
|
---|
5804 | }
|
---|
5805 |
|
---|
5806 | return new Automake::Condition (@cond_stack);
|
---|
5807 | }
|
---|
5808 |
|
---|
5809 |
|
---|
5810 | # $COND
|
---|
5811 | # cond_stack_endif ($NEGATE, $COND, $WHERE)
|
---|
5812 | # -----------------------------------------
|
---|
5813 | sub cond_stack_endif ($$$)
|
---|
5814 | {
|
---|
5815 | my ($negate, $cond, $where) = @_;
|
---|
5816 | my $old_cond;
|
---|
5817 |
|
---|
5818 | if (! @cond_stack)
|
---|
5819 | {
|
---|
5820 | error $where, "endif without if";
|
---|
5821 | return TRUE;
|
---|
5822 | }
|
---|
5823 |
|
---|
5824 | # If $COND is given, check against it.
|
---|
5825 | if (defined $cond)
|
---|
5826 | {
|
---|
5827 | $cond = make_conditional_string ($negate, $cond);
|
---|
5828 |
|
---|
5829 | error ($where, "endif reminder ($negate$cond) incompatible with "
|
---|
5830 | . "current conditional: $cond_stack[$#cond_stack]")
|
---|
5831 | if $cond_stack[$#cond_stack] ne $cond;
|
---|
5832 | }
|
---|
5833 |
|
---|
5834 | pop @cond_stack;
|
---|
5835 |
|
---|
5836 | return new Automake::Condition (@cond_stack);
|
---|
5837 | }
|
---|
5838 |
|
---|
5839 |
|
---|
5840 |
|
---|
5841 |
|
---|
5842 |
|
---|
5843 | ## ------------------------ ##
|
---|
5844 | ## Handling the variables. ##
|
---|
5845 | ## ------------------------ ##
|
---|
5846 |
|
---|
5847 |
|
---|
5848 | # &define_pretty_variable ($VAR, $COND, $WHERE, @VALUE)
|
---|
5849 | # -----------------------------------------------------
|
---|
5850 | # Like define_variable, but the value is a list, and the variable may
|
---|
5851 | # be defined conditionally. The second argument is the Condition
|
---|
5852 | # under which the value should be defined; this should be the empty
|
---|
5853 | # string to define the variable unconditionally. The third argument
|
---|
5854 | # is a list holding the values to use for the variable. The value is
|
---|
5855 | # pretty printed in the output file.
|
---|
5856 | sub define_pretty_variable ($$$@)
|
---|
5857 | {
|
---|
5858 | my ($var, $cond, $where, @value) = @_;
|
---|
5859 |
|
---|
5860 | if (! vardef ($var, $cond))
|
---|
5861 | {
|
---|
5862 | Automake::Variable::define ($var, VAR_AUTOMAKE, '', $cond, "@value",
|
---|
5863 | '', $where, VAR_PRETTY);
|
---|
5864 | rvar ($var)->rdef ($cond)->set_seen;
|
---|
5865 | }
|
---|
5866 | }
|
---|
5867 |
|
---|
5868 |
|
---|
5869 | # define_variable ($VAR, $VALUE, $WHERE)
|
---|
5870 | # --------------------------------------
|
---|
5871 | # Define a new Automake Makefile variable VAR to VALUE, but only if
|
---|
5872 | # not already defined.
|
---|
5873 | sub define_variable ($$$)
|
---|
5874 | {
|
---|
5875 | my ($var, $value, $where) = @_;
|
---|
5876 | define_pretty_variable ($var, TRUE, $where, $value);
|
---|
5877 | }
|
---|
5878 |
|
---|
5879 |
|
---|
5880 | # define_files_variable ($VAR, \@BASENAME, $EXTENSION, $WHERE)
|
---|
5881 | # -----------------------------------------------------------
|
---|
5882 | # Define the $VAR which content is the list of file names composed of
|
---|
5883 | # a @BASENAME and the $EXTENSION.
|
---|
5884 | sub define_files_variable ($\@$$)
|
---|
5885 | {
|
---|
5886 | my ($var, $basename, $extension, $where) = @_;
|
---|
5887 | define_variable ($var,
|
---|
5888 | join (' ', map { "$_.$extension" } @$basename),
|
---|
5889 | $where);
|
---|
5890 | }
|
---|
5891 |
|
---|
5892 |
|
---|
5893 | # Like define_variable, but define a variable to be the configure
|
---|
5894 | # substitution by the same name.
|
---|
5895 | sub define_configure_variable ($)
|
---|
5896 | {
|
---|
5897 | my ($var) = @_;
|
---|
5898 |
|
---|
5899 | my $pretty = VAR_ASIS;
|
---|
5900 | my $owner = VAR_CONFIGURE;
|
---|
5901 |
|
---|
5902 | # Some variables we do not want to output. For instance it
|
---|
5903 | # would be a bad idea to output `U = @U@` when `@U@` can be
|
---|
5904 | # substituted as `\`.
|
---|
5905 | $pretty = VAR_SILENT if exists $ignored_configure_vars{$var};
|
---|
5906 |
|
---|
5907 | # ANSI2KNR is a variable that Automake wants to redefine, so
|
---|
5908 | # it must be owned by Automake. (It is also used as a proof
|
---|
5909 | # that AM_C_PROTOTYPES has been run, that's why we do not simply
|
---|
5910 | # omit the AC_SUBST.)
|
---|
5911 | $owner = VAR_AUTOMAKE if $var eq 'ANSI2KNR';
|
---|
5912 |
|
---|
5913 | Automake::Variable::define ($var, $owner, '', TRUE, subst $var,
|
---|
5914 | '', $configure_vars{$var}, $pretty);
|
---|
5915 | }
|
---|
5916 |
|
---|
5917 |
|
---|
5918 | # define_compiler_variable ($LANG)
|
---|
5919 | # --------------------------------
|
---|
5920 | # Define a compiler variable. We also handle defining the `LT'
|
---|
5921 | # version of the command when using libtool.
|
---|
5922 | sub define_compiler_variable ($)
|
---|
5923 | {
|
---|
5924 | my ($lang) = @_;
|
---|
5925 |
|
---|
5926 | my ($var, $value) = ($lang->compiler, $lang->compile);
|
---|
5927 | my $libtool_tag = '';
|
---|
5928 | $libtool_tag = '--tag=' . $lang->libtool_tag . ' '
|
---|
5929 | if $lang->libtool_tag && exists $libtool_tags{$lang->libtool_tag};
|
---|
5930 | &define_variable ($var, $value, INTERNAL);
|
---|
5931 | &define_variable ("LT$var",
|
---|
5932 | "\$(LIBTOOL) $libtool_tag\$(AM_LIBTOOLFLAGS) "
|
---|
5933 | . "\$(LIBTOOLFLAGS) --mode=compile $value",
|
---|
5934 | INTERNAL)
|
---|
5935 | if var ('LIBTOOL');
|
---|
5936 | }
|
---|
5937 |
|
---|
5938 |
|
---|
5939 | # define_linker_variable ($LANG)
|
---|
5940 | # ------------------------------
|
---|
5941 | # Define linker variables.
|
---|
5942 | sub define_linker_variable ($)
|
---|
5943 | {
|
---|
5944 | my ($lang) = @_;
|
---|
5945 |
|
---|
5946 | my $libtool_tag = '';
|
---|
5947 | $libtool_tag = '--tag=' . $lang->libtool_tag . ' '
|
---|
5948 | if $lang->libtool_tag && exists $libtool_tags{$lang->libtool_tag};
|
---|
5949 | # CCLD = $(CC).
|
---|
5950 | &define_variable ($lang->lder, $lang->ld, INTERNAL);
|
---|
5951 | # CCLINK = $(CCLD) blah blah...
|
---|
5952 | &define_variable ($lang->linker,
|
---|
5953 | ((var ('LIBTOOL') ?
|
---|
5954 | "\$(LIBTOOL) $libtool_tag\$(AM_LIBTOOLFLAGS) "
|
---|
5955 | . "\$(LIBTOOLFLAGS) --mode=link " : '')
|
---|
5956 | . $lang->link),
|
---|
5957 | INTERNAL);
|
---|
5958 | }
|
---|
5959 |
|
---|
5960 | sub define_per_target_linker_variable ($$)
|
---|
5961 | {
|
---|
5962 | my ($linker, $target) = @_;
|
---|
5963 |
|
---|
5964 | # If the user wrote a custom link command, we don't define ours.
|
---|
5965 | return "${target}_LINK"
|
---|
5966 | if set_seen "${target}_LINK";
|
---|
5967 |
|
---|
5968 | my $xlink = $linker ? $linker : 'LINK';
|
---|
5969 |
|
---|
5970 | my $lang = $link_languages{$xlink};
|
---|
5971 | prog_error "Unknown language for linker variable `$xlink'"
|
---|
5972 | unless $lang;
|
---|
5973 |
|
---|
5974 | my $link_command = $lang->link;
|
---|
5975 | if (var 'LIBTOOL')
|
---|
5976 | {
|
---|
5977 | my $libtool_tag = '';
|
---|
5978 | $libtool_tag = '--tag=' . $lang->libtool_tag . ' '
|
---|
5979 | if $lang->libtool_tag && exists $libtool_tags{$lang->libtool_tag};
|
---|
5980 |
|
---|
5981 | $link_command =
|
---|
5982 | "\$(LIBTOOL) $libtool_tag\$(AM_LIBTOOLFLAGS) \$(LIBTOOLFLAGS) "
|
---|
5983 | . "--mode=link " . $link_command;
|
---|
5984 | }
|
---|
5985 |
|
---|
5986 | # Rewrite each occurrence of `AM_$flag' in the link
|
---|
5987 | # command into `${derived}_$flag' if it exists.
|
---|
5988 | my $orig_command = $link_command;
|
---|
5989 | my @flags = (@{$lang->flags}, 'LDFLAGS');
|
---|
5990 | push @flags, 'LIBTOOLFLAGS' if var 'LIBTOOL';
|
---|
5991 | for my $flag (@flags)
|
---|
5992 | {
|
---|
5993 | my $val = "${target}_$flag";
|
---|
5994 | $link_command =~ s/\(AM_$flag\)/\($val\)/
|
---|
5995 | if set_seen ($val);
|
---|
5996 | }
|
---|
5997 |
|
---|
5998 | # If the computed command is the same as the generic command, use
|
---|
5999 | # the command linker variable.
|
---|
6000 | return $lang->linker
|
---|
6001 | if $link_command eq $orig_command;
|
---|
6002 |
|
---|
6003 | &define_variable ("${target}_LINK", $link_command, INTERNAL);
|
---|
6004 | return "${target}_LINK";
|
---|
6005 | }
|
---|
6006 |
|
---|
6007 | ################################################################
|
---|
6008 |
|
---|
6009 | # &check_trailing_slash ($WHERE, $LINE)
|
---|
6010 | # --------------------------------------
|
---|
6011 | # Return 1 iff $LINE ends with a slash.
|
---|
6012 | # Might modify $LINE.
|
---|
6013 | sub check_trailing_slash ($\$)
|
---|
6014 | {
|
---|
6015 | my ($where, $line) = @_;
|
---|
6016 |
|
---|
6017 | # Ignore `##' lines.
|
---|
6018 | return 0 if $$line =~ /$IGNORE_PATTERN/o;
|
---|
6019 |
|
---|
6020 | # Catch and fix a common error.
|
---|
6021 | msg "syntax", $where, "whitespace following trailing backslash"
|
---|
6022 | if $$line =~ s/\\\s+\n$/\\\n/;
|
---|
6023 |
|
---|
6024 | return $$line =~ /\\$/;
|
---|
6025 | }
|
---|
6026 |
|
---|
6027 |
|
---|
6028 | # &read_am_file ($AMFILE, $WHERE)
|
---|
6029 | # -------------------------------
|
---|
6030 | # Read Makefile.am and set up %contents. Simultaneously copy lines
|
---|
6031 | # from Makefile.am into $output_trailer, or define variables as
|
---|
6032 | # appropriate. NOTE we put rules in the trailer section. We want
|
---|
6033 | # user rules to come after our generated stuff.
|
---|
6034 | sub read_am_file ($$)
|
---|
6035 | {
|
---|
6036 | my ($amfile, $where) = @_;
|
---|
6037 |
|
---|
6038 | my $am_file = new Automake::XFile ("< $amfile");
|
---|
6039 | verb "reading $amfile";
|
---|
6040 |
|
---|
6041 | # Keep track of the youngest output dependency.
|
---|
6042 | my $mtime = mtime $amfile;
|
---|
6043 | $output_deps_greatest_timestamp = $mtime
|
---|
6044 | if $mtime > $output_deps_greatest_timestamp;
|
---|
6045 |
|
---|
6046 | my $spacing = '';
|
---|
6047 | my $comment = '';
|
---|
6048 | my $blank = 0;
|
---|
6049 | my $saw_bk = 0;
|
---|
6050 | my $var_look = VAR_ASIS;
|
---|
6051 |
|
---|
6052 | use constant IN_VAR_DEF => 0;
|
---|
6053 | use constant IN_RULE_DEF => 1;
|
---|
6054 | use constant IN_COMMENT => 2;
|
---|
6055 | my $prev_state = IN_RULE_DEF;
|
---|
6056 |
|
---|
6057 | while ($_ = $am_file->getline)
|
---|
6058 | {
|
---|
6059 | $where->set ("$amfile:$.");
|
---|
6060 | if (/$IGNORE_PATTERN/o)
|
---|
6061 | {
|
---|
6062 | # Merely delete comments beginning with two hashes.
|
---|
6063 | }
|
---|
6064 | elsif (/$WHITE_PATTERN/o)
|
---|
6065 | {
|
---|
6066 | error $where, "blank line following trailing backslash"
|
---|
6067 | if $saw_bk;
|
---|
6068 | # Stick a single white line before the incoming macro or rule.
|
---|
6069 | $spacing = "\n";
|
---|
6070 | $blank = 1;
|
---|
6071 | # Flush all comments seen so far.
|
---|
6072 | if ($comment ne '')
|
---|
6073 | {
|
---|
6074 | $output_vars .= $comment;
|
---|
6075 | $comment = '';
|
---|
6076 | }
|
---|
6077 | }
|
---|
6078 | elsif (/$COMMENT_PATTERN/o)
|
---|
6079 | {
|
---|
6080 | # Stick comments before the incoming macro or rule. Make
|
---|
6081 | # sure a blank line precedes the first block of comments.
|
---|
6082 | $spacing = "\n" unless $blank;
|
---|
6083 | $blank = 1;
|
---|
6084 | $comment .= $spacing . $_;
|
---|
6085 | $spacing = '';
|
---|
6086 | $prev_state = IN_COMMENT;
|
---|
6087 | }
|
---|
6088 | else
|
---|
6089 | {
|
---|
6090 | last;
|
---|
6091 | }
|
---|
6092 | $saw_bk = check_trailing_slash ($where, $_);
|
---|
6093 | }
|
---|
6094 |
|
---|
6095 | # We save the conditional stack on entry, and then check to make
|
---|
6096 | # sure it is the same on exit. This lets us conditionally include
|
---|
6097 | # other files.
|
---|
6098 | my @saved_cond_stack = @cond_stack;
|
---|
6099 | my $cond = new Automake::Condition (@cond_stack);
|
---|
6100 |
|
---|
6101 | my $last_var_name = '';
|
---|
6102 | my $last_var_type = '';
|
---|
6103 | my $last_var_value = '';
|
---|
6104 | my $last_where;
|
---|
6105 | # FIXME: shouldn't use $_ in this loop; it is too big.
|
---|
6106 | while ($_)
|
---|
6107 | {
|
---|
6108 | $where->set ("$amfile:$.");
|
---|
6109 |
|
---|
6110 | # Make sure the line is \n-terminated.
|
---|
6111 | chomp;
|
---|
6112 | $_ .= "\n";
|
---|
6113 |
|
---|
6114 | # Don't look at MAINTAINER_MODE_TRUE here. That shouldn't be
|
---|
6115 | # used by users. @MAINT@ is an anachronism now.
|
---|
6116 | $_ =~ s/\@MAINT\@//g
|
---|
6117 | unless $seen_maint_mode;
|
---|
6118 |
|
---|
6119 | my $new_saw_bk = check_trailing_slash ($where, $_);
|
---|
6120 |
|
---|
6121 | if (/$IGNORE_PATTERN/o)
|
---|
6122 | {
|
---|
6123 | # Merely delete comments beginning with two hashes.
|
---|
6124 |
|
---|
6125 | # Keep any backslash from the previous line.
|
---|
6126 | $new_saw_bk = $saw_bk;
|
---|
6127 | }
|
---|
6128 | elsif (/$WHITE_PATTERN/o)
|
---|
6129 | {
|
---|
6130 | # Stick a single white line before the incoming macro or rule.
|
---|
6131 | $spacing = "\n";
|
---|
6132 | error $where, "blank line following trailing backslash"
|
---|
6133 | if $saw_bk;
|
---|
6134 | }
|
---|
6135 | elsif (/$COMMENT_PATTERN/o)
|
---|
6136 | {
|
---|
6137 | error $where, "comment following trailing backslash"
|
---|
6138 | if $saw_bk && $comment eq '';
|
---|
6139 |
|
---|
6140 | # Stick comments before the incoming macro or rule.
|
---|
6141 | $comment .= $spacing . $_;
|
---|
6142 | $spacing = '';
|
---|
6143 | $prev_state = IN_COMMENT;
|
---|
6144 | }
|
---|
6145 | elsif ($saw_bk)
|
---|
6146 | {
|
---|
6147 | if ($prev_state == IN_RULE_DEF)
|
---|
6148 | {
|
---|
6149 | my $cond = new Automake::Condition @cond_stack;
|
---|
6150 | $output_trailer .= $cond->subst_string;
|
---|
6151 | $output_trailer .= $_;
|
---|
6152 | }
|
---|
6153 | elsif ($prev_state == IN_COMMENT)
|
---|
6154 | {
|
---|
6155 | # If the line doesn't start with a `#', add it.
|
---|
6156 | # We do this because a continued comment like
|
---|
6157 | # # A = foo \
|
---|
6158 | # bar \
|
---|
6159 | # baz
|
---|
6160 | # is not portable. BSD make doesn't honor
|
---|
6161 | # escaped newlines in comments.
|
---|
6162 | s/^#?/#/;
|
---|
6163 | $comment .= $spacing . $_;
|
---|
6164 | }
|
---|
6165 | else # $prev_state == IN_VAR_DEF
|
---|
6166 | {
|
---|
6167 | $last_var_value .= ' '
|
---|
6168 | unless $last_var_value =~ /\s$/;
|
---|
6169 | $last_var_value .= $_;
|
---|
6170 |
|
---|
6171 | if (!/\\$/)
|
---|
6172 | {
|
---|
6173 | Automake::Variable::define ($last_var_name, VAR_MAKEFILE,
|
---|
6174 | $last_var_type, $cond,
|
---|
6175 | $last_var_value, $comment,
|
---|
6176 | $last_where, VAR_ASIS)
|
---|
6177 | if $cond != FALSE;
|
---|
6178 | $comment = $spacing = '';
|
---|
6179 | }
|
---|
6180 | }
|
---|
6181 | }
|
---|
6182 |
|
---|
6183 | elsif (/$IF_PATTERN/o)
|
---|
6184 | {
|
---|
6185 | $cond = cond_stack_if ($1, $2, $where);
|
---|
6186 | }
|
---|
6187 | elsif (/$ELSE_PATTERN/o)
|
---|
6188 | {
|
---|
6189 | $cond = cond_stack_else ($1, $2, $where);
|
---|
6190 | }
|
---|
6191 | elsif (/$ENDIF_PATTERN/o)
|
---|
6192 | {
|
---|
6193 | $cond = cond_stack_endif ($1, $2, $where);
|
---|
6194 | }
|
---|
6195 |
|
---|
6196 | elsif (/$RULE_PATTERN/o)
|
---|
6197 | {
|
---|
6198 | # Found a rule.
|
---|
6199 | $prev_state = IN_RULE_DEF;
|
---|
6200 |
|
---|
6201 | # For now we have to output all definitions of user rules
|
---|
6202 | # and can't diagnose duplicates (see the comment in
|
---|
6203 | # Automake::Rule::define). So we go on and ignore the return value.
|
---|
6204 | Automake::Rule::define ($1, $amfile, RULE_USER, $cond, $where);
|
---|
6205 |
|
---|
6206 | check_variable_expansions ($_, $where);
|
---|
6207 |
|
---|
6208 | $output_trailer .= $comment . $spacing;
|
---|
6209 | my $cond = new Automake::Condition @cond_stack;
|
---|
6210 | $output_trailer .= $cond->subst_string;
|
---|
6211 | $output_trailer .= $_;
|
---|
6212 | $comment = $spacing = '';
|
---|
6213 | }
|
---|
6214 | elsif (/$ASSIGNMENT_PATTERN/o)
|
---|
6215 | {
|
---|
6216 | # Found a macro definition.
|
---|
6217 | $prev_state = IN_VAR_DEF;
|
---|
6218 | $last_var_name = $1;
|
---|
6219 | $last_var_type = $2;
|
---|
6220 | $last_var_value = $3;
|
---|
6221 | $last_where = $where->clone;
|
---|
6222 | if ($3 ne '' && substr ($3, -1) eq "\\")
|
---|
6223 | {
|
---|
6224 | # We preserve the `\' because otherwise the long lines
|
---|
6225 | # that are generated will be truncated by broken
|
---|
6226 | # `sed's.
|
---|
6227 | $last_var_value = $3 . "\n";
|
---|
6228 | }
|
---|
6229 | # Normally we try to output variable definitions in the
|
---|
6230 | # same format they were input. However, POSIX compliant
|
---|
6231 | # systems are not required to support lines longer than
|
---|
6232 | # 2048 bytes (most notably, some sed implementation are
|
---|
6233 | # limited to 4000 bytes, and sed is used by config.status
|
---|
6234 | # to rewrite Makefile.in into Makefile). Moreover nobody
|
---|
6235 | # would really write such long lines by hand since it is
|
---|
6236 | # hardly maintainable. So if a line is longer that 1000
|
---|
6237 | # bytes (an arbitrary limit), assume it has been
|
---|
6238 | # automatically generated by some tools, and flatten the
|
---|
6239 | # variable definition. Otherwise, keep the variable as it
|
---|
6240 | # as been input.
|
---|
6241 | $var_look = VAR_PRETTY if length ($last_var_value) >= 1000;
|
---|
6242 |
|
---|
6243 | if (!/\\$/)
|
---|
6244 | {
|
---|
6245 | Automake::Variable::define ($last_var_name, VAR_MAKEFILE,
|
---|
6246 | $last_var_type, $cond,
|
---|
6247 | $last_var_value, $comment,
|
---|
6248 | $last_where, $var_look)
|
---|
6249 | if $cond != FALSE;
|
---|
6250 | $comment = $spacing = '';
|
---|
6251 | $var_look = VAR_ASIS;
|
---|
6252 | }
|
---|
6253 | }
|
---|
6254 | elsif (/$INCLUDE_PATTERN/o)
|
---|
6255 | {
|
---|
6256 | my $path = $1;
|
---|
6257 |
|
---|
6258 | if ($path =~ s/^\$\(top_srcdir\)\///)
|
---|
6259 | {
|
---|
6260 | push (@include_stack, "\$\(top_srcdir\)/$path");
|
---|
6261 | # Distribute any included file.
|
---|
6262 |
|
---|
6263 | # Always use the $(top_srcdir) prefix in DIST_COMMON,
|
---|
6264 | # otherwise OSF make will implicitly copy the included
|
---|
6265 | # file in the build tree during `make distdir' to satisfy
|
---|
6266 | # the dependency.
|
---|
6267 | # (subdircond2.test and subdircond3.test will fail.)
|
---|
6268 | push_dist_common ("\$\(top_srcdir\)/$path");
|
---|
6269 | }
|
---|
6270 | else
|
---|
6271 | {
|
---|
6272 | $path =~ s/\$\(srcdir\)\///;
|
---|
6273 | push (@include_stack, "\$\(srcdir\)/$path");
|
---|
6274 | # Always use the $(srcdir) prefix in DIST_COMMON,
|
---|
6275 | # otherwise OSF make will implicitly copy the included
|
---|
6276 | # file in the build tree during `make distdir' to satisfy
|
---|
6277 | # the dependency.
|
---|
6278 | # (subdircond2.test and subdircond3.test will fail.)
|
---|
6279 | push_dist_common ("\$\(srcdir\)/$path");
|
---|
6280 | $path = $relative_dir . "/" . $path if $relative_dir ne '.';
|
---|
6281 | }
|
---|
6282 | $where->push_context ("`$path' included from here");
|
---|
6283 | &read_am_file ($path, $where);
|
---|
6284 | $where->pop_context;
|
---|
6285 | }
|
---|
6286 | else
|
---|
6287 | {
|
---|
6288 | # This isn't an error; it is probably a continued rule.
|
---|
6289 | # In fact, this is what we assume.
|
---|
6290 | $prev_state = IN_RULE_DEF;
|
---|
6291 | check_variable_expansions ($_, $where);
|
---|
6292 | $output_trailer .= $comment . $spacing;
|
---|
6293 | my $cond = new Automake::Condition @cond_stack;
|
---|
6294 | $output_trailer .= $cond->subst_string;
|
---|
6295 | $output_trailer .= $_;
|
---|
6296 | $comment = $spacing = '';
|
---|
6297 | error $where, "`#' comment at start of rule is unportable"
|
---|
6298 | if $_ =~ /^\t\s*\#/;
|
---|
6299 | }
|
---|
6300 |
|
---|
6301 | $saw_bk = $new_saw_bk;
|
---|
6302 | $_ = $am_file->getline;
|
---|
6303 | }
|
---|
6304 |
|
---|
6305 | $output_trailer .= $comment;
|
---|
6306 |
|
---|
6307 | error ($where, "trailing backslash on last line")
|
---|
6308 | if $saw_bk;
|
---|
6309 |
|
---|
6310 | error ($where, (@cond_stack ? "unterminated conditionals: @cond_stack"
|
---|
6311 | : "too many conditionals closed in include file"))
|
---|
6312 | if "@saved_cond_stack" ne "@cond_stack";
|
---|
6313 | }
|
---|
6314 |
|
---|
6315 |
|
---|
6316 | # define_standard_variables ()
|
---|
6317 | # ----------------------------
|
---|
6318 | # A helper for read_main_am_file which initializes configure variables
|
---|
6319 | # and variables from header-vars.am.
|
---|
6320 | sub define_standard_variables
|
---|
6321 | {
|
---|
6322 | my $saved_output_vars = $output_vars;
|
---|
6323 | my ($comments, undef, $rules) =
|
---|
6324 | file_contents_internal (1, "$libdir/am/header-vars.am",
|
---|
6325 | new Automake::Location);
|
---|
6326 |
|
---|
6327 | foreach my $var (sort keys %configure_vars)
|
---|
6328 | {
|
---|
6329 | &define_configure_variable ($var);
|
---|
6330 | }
|
---|
6331 |
|
---|
6332 | $output_vars .= $comments . $rules;
|
---|
6333 | }
|
---|
6334 |
|
---|
6335 | # Read main am file.
|
---|
6336 | sub read_main_am_file
|
---|
6337 | {
|
---|
6338 | my ($amfile) = @_;
|
---|
6339 |
|
---|
6340 | # This supports the strange variable tricks we are about to play.
|
---|
6341 | prog_error (macros_dump () . "variable defined before read_main_am_file")
|
---|
6342 | if (scalar (variables) > 0);
|
---|
6343 |
|
---|
6344 | # Generate copyright header for generated Makefile.in.
|
---|
6345 | # We do discard the output of predefined variables, handled below.
|
---|
6346 | $output_vars = ("# $in_file_name generated by automake "
|
---|
6347 | . $VERSION . " from $am_file_name.\n");
|
---|
6348 | $output_vars .= '# ' . subst ('configure_input') . "\n";
|
---|
6349 | $output_vars .= $gen_copyright;
|
---|
6350 |
|
---|
6351 | # We want to predefine as many variables as possible. This lets
|
---|
6352 | # the user set them with `+=' in Makefile.am.
|
---|
6353 | &define_standard_variables;
|
---|
6354 |
|
---|
6355 | # Read user file, which might override some of our values.
|
---|
6356 | &read_am_file ($amfile, new Automake::Location);
|
---|
6357 | }
|
---|
6358 |
|
---|
6359 |
|
---|
6360 |
|
---|
6361 | ################################################################
|
---|
6362 |
|
---|
6363 | # $FLATTENED
|
---|
6364 | # &flatten ($STRING)
|
---|
6365 | # ------------------
|
---|
6366 | # Flatten the $STRING and return the result.
|
---|
6367 | sub flatten
|
---|
6368 | {
|
---|
6369 | $_ = shift;
|
---|
6370 |
|
---|
6371 | s/\\\n//somg;
|
---|
6372 | s/\s+/ /g;
|
---|
6373 | s/^ //;
|
---|
6374 | s/ $//;
|
---|
6375 |
|
---|
6376 | return $_;
|
---|
6377 | }
|
---|
6378 |
|
---|
6379 | # transform($TOKEN, \%PAIRS)
|
---|
6380 | # ==========================
|
---|
6381 | # If ($TOKEN, $VAL) is in %PAIRS:
|
---|
6382 | # - replaces %$TOKEN% with $VAL,
|
---|
6383 | # - enables/disables ?$TOKEN? and ?!$TOKEN?,
|
---|
6384 | # - replaces %?$TOKEN% with TRUE or FALSE.
|
---|
6385 | sub transform($$)
|
---|
6386 | {
|
---|
6387 | my ($token, $transform) = @_;
|
---|
6388 |
|
---|
6389 | if (substr ($token, 0, 1) eq '%')
|
---|
6390 | {
|
---|
6391 | my $cond = (substr ($token, 1, 1) eq '?') ? 1 : 0;
|
---|
6392 | $token = substr ($token, 1 + $cond, -1);
|
---|
6393 | my $val = $transform->{$token};
|
---|
6394 | prog_error "Unknown %token% `$token'" unless defined $val;
|
---|
6395 | if ($cond)
|
---|
6396 | {
|
---|
6397 | return $val ? 'TRUE' : 'FALSE';
|
---|
6398 | }
|
---|
6399 | else
|
---|
6400 | {
|
---|
6401 | return $val;
|
---|
6402 | }
|
---|
6403 | }
|
---|
6404 | # Now $token is '?xxx?' or '?!xxx?'.
|
---|
6405 | my $neg = (substr ($token, 1, 1) eq '!') ? 1 : 0;
|
---|
6406 | $token = substr ($token, 1 + $neg, -1);
|
---|
6407 | my $val = $transform->{$token};
|
---|
6408 | prog_error "Unknown ?token? `$token' (neg = $neg)" unless defined $val;
|
---|
6409 | return (!!$val == $neg) ? '##%' : '';
|
---|
6410 | }
|
---|
6411 |
|
---|
6412 | # @PARAGRAPHS
|
---|
6413 | # &make_paragraphs ($MAKEFILE, [%TRANSFORM])
|
---|
6414 | # ------------------------------------------
|
---|
6415 | # Load a $MAKEFILE, apply the %TRANSFORM, and return it as a list of
|
---|
6416 | # paragraphs.
|
---|
6417 | sub make_paragraphs ($%)
|
---|
6418 | {
|
---|
6419 | my ($file, %transform) = @_;
|
---|
6420 |
|
---|
6421 | # Complete %transform with global options.
|
---|
6422 | # Note that %transform goes last, so it overrides global options.
|
---|
6423 | %transform = ('CYGNUS' => !! option 'cygnus',
|
---|
6424 | 'MAINTAINER-MODE'
|
---|
6425 | => $seen_maint_mode ? subst ('MAINTAINER_MODE_TRUE') : '',
|
---|
6426 |
|
---|
6427 | 'BZIP2' => !! option 'dist-bzip2',
|
---|
6428 | 'COMPRESS' => !! option 'dist-tarZ',
|
---|
6429 | 'GZIP' => ! option 'no-dist-gzip',
|
---|
6430 | 'SHAR' => !! option 'dist-shar',
|
---|
6431 | 'ZIP' => !! option 'dist-zip',
|
---|
6432 |
|
---|
6433 | 'INSTALL-INFO' => ! option 'no-installinfo',
|
---|
6434 | 'INSTALL-MAN' => ! option 'no-installman',
|
---|
6435 | 'CK-NEWS' => !! option 'check-news',
|
---|
6436 |
|
---|
6437 | 'SUBDIRS' => !! var ('SUBDIRS'),
|
---|
6438 | 'TOPDIR_P' => $relative_dir eq '.',
|
---|
6439 |
|
---|
6440 | 'BUILD' => ($seen_canonical >= AC_CANONICAL_BUILD),
|
---|
6441 | 'HOST' => ($seen_canonical >= AC_CANONICAL_HOST),
|
---|
6442 | 'TARGET' => ($seen_canonical >= AC_CANONICAL_TARGET),
|
---|
6443 |
|
---|
6444 | 'LIBTOOL' => !! var ('LIBTOOL'),
|
---|
6445 | 'NONLIBTOOL' => 1,
|
---|
6446 | 'FIRST' => ! $transformed_files{$file},
|
---|
6447 | %transform);
|
---|
6448 |
|
---|
6449 | $transformed_files{$file} = 1;
|
---|
6450 | $_ = $am_file_cache{$file};
|
---|
6451 |
|
---|
6452 | if (! defined $_)
|
---|
6453 | {
|
---|
6454 | verb "reading $file";
|
---|
6455 | # Swallow the whole file.
|
---|
6456 | my $fc_file = new Automake::XFile "< $file";
|
---|
6457 | my $saved_dollar_slash = $/;
|
---|
6458 | undef $/;
|
---|
6459 | $_ = $fc_file->getline;
|
---|
6460 | $/ = $saved_dollar_slash;
|
---|
6461 | $fc_file->close;
|
---|
6462 |
|
---|
6463 | # Remove ##-comments.
|
---|
6464 | # Besides we don't need more than two consecutive new-lines.
|
---|
6465 | s/(?:$IGNORE_PATTERN|(?<=\n\n)\n+)//gom;
|
---|
6466 |
|
---|
6467 | $am_file_cache{$file} = $_;
|
---|
6468 | }
|
---|
6469 |
|
---|
6470 | # Substitute Automake template tokens.
|
---|
6471 | s/(?:%\??[\w\-]+%|\?!?[\w\-]+\?)/transform($&, \%transform)/ge;
|
---|
6472 | # transform() may have added some ##%-comments to strip.
|
---|
6473 | # (we use `##%' instead of `##' so we can distinguish ##%##%##% from
|
---|
6474 | # ####### and do not remove the latter.)
|
---|
6475 | s/^[ \t]*(?:##%)+.*\n//gm;
|
---|
6476 |
|
---|
6477 | # Split at unescaped new lines.
|
---|
6478 | my @lines = split (/(?<!\\)\n/, $_);
|
---|
6479 | my @res;
|
---|
6480 |
|
---|
6481 | while (defined ($_ = shift @lines))
|
---|
6482 | {
|
---|
6483 | my $paragraph = $_;
|
---|
6484 | # If we are a rule, eat as long as we start with a tab.
|
---|
6485 | if (/$RULE_PATTERN/smo)
|
---|
6486 | {
|
---|
6487 | while (defined ($_ = shift @lines) && $_ =~ /^\t/)
|
---|
6488 | {
|
---|
6489 | $paragraph .= "\n$_";
|
---|
6490 | }
|
---|
6491 | unshift (@lines, $_);
|
---|
6492 | }
|
---|
6493 |
|
---|
6494 | # If we are a comments, eat as much comments as you can.
|
---|
6495 | elsif (/$COMMENT_PATTERN/smo)
|
---|
6496 | {
|
---|
6497 | while (defined ($_ = shift @lines)
|
---|
6498 | && $_ =~ /$COMMENT_PATTERN/smo)
|
---|
6499 | {
|
---|
6500 | $paragraph .= "\n$_";
|
---|
6501 | }
|
---|
6502 | unshift (@lines, $_);
|
---|
6503 | }
|
---|
6504 |
|
---|
6505 | push @res, $paragraph;
|
---|
6506 | }
|
---|
6507 |
|
---|
6508 | return @res;
|
---|
6509 | }
|
---|
6510 |
|
---|
6511 |
|
---|
6512 |
|
---|
6513 | # ($COMMENT, $VARIABLES, $RULES)
|
---|
6514 | # &file_contents_internal ($IS_AM, $FILE, $WHERE, [%TRANSFORM])
|
---|
6515 | # -------------------------------------------------------------
|
---|
6516 | # Return contents of a file from $libdir/am, automatically skipping
|
---|
6517 | # macros or rules which are already known. $IS_AM iff the caller is
|
---|
6518 | # reading an Automake file (as opposed to the user's Makefile.am).
|
---|
6519 | sub file_contents_internal ($$$%)
|
---|
6520 | {
|
---|
6521 | my ($is_am, $file, $where, %transform) = @_;
|
---|
6522 |
|
---|
6523 | $where->set ($file);
|
---|
6524 |
|
---|
6525 | my $result_vars = '';
|
---|
6526 | my $result_rules = '';
|
---|
6527 | my $comment = '';
|
---|
6528 | my $spacing = '';
|
---|
6529 |
|
---|
6530 | # The following flags are used to track rules spanning across
|
---|
6531 | # multiple paragraphs.
|
---|
6532 | my $is_rule = 0; # 1 if we are processing a rule.
|
---|
6533 | my $discard_rule = 0; # 1 if the current rule should not be output.
|
---|
6534 |
|
---|
6535 | # We save the conditional stack on entry, and then check to make
|
---|
6536 | # sure it is the same on exit. This lets us conditionally include
|
---|
6537 | # other files.
|
---|
6538 | my @saved_cond_stack = @cond_stack;
|
---|
6539 | my $cond = new Automake::Condition (@cond_stack);
|
---|
6540 |
|
---|
6541 | foreach (make_paragraphs ($file, %transform))
|
---|
6542 | {
|
---|
6543 | # FIXME: no line number available.
|
---|
6544 | $where->set ($file);
|
---|
6545 |
|
---|
6546 | # Sanity checks.
|
---|
6547 | error $where, "blank line following trailing backslash:\n$_"
|
---|
6548 | if /\\$/;
|
---|
6549 | error $where, "comment following trailing backslash:\n$_"
|
---|
6550 | if /\\#/;
|
---|
6551 |
|
---|
6552 | if (/^$/)
|
---|
6553 | {
|
---|
6554 | $is_rule = 0;
|
---|
6555 | # Stick empty line before the incoming macro or rule.
|
---|
6556 | $spacing = "\n";
|
---|
6557 | }
|
---|
6558 | elsif (/$COMMENT_PATTERN/mso)
|
---|
6559 | {
|
---|
6560 | $is_rule = 0;
|
---|
6561 | # Stick comments before the incoming macro or rule.
|
---|
6562 | $comment = "$_\n";
|
---|
6563 | }
|
---|
6564 |
|
---|
6565 | # Handle inclusion of other files.
|
---|
6566 | elsif (/$INCLUDE_PATTERN/o)
|
---|
6567 | {
|
---|
6568 | if ($cond != FALSE)
|
---|
6569 | {
|
---|
6570 | my $file = ($is_am ? "$libdir/am/" : '') . $1;
|
---|
6571 | $where->push_context ("`$file' included from here");
|
---|
6572 | # N-ary `.=' fails.
|
---|
6573 | my ($com, $vars, $rules)
|
---|
6574 | = file_contents_internal ($is_am, $file, $where, %transform);
|
---|
6575 | $where->pop_context;
|
---|
6576 | $comment .= $com;
|
---|
6577 | $result_vars .= $vars;
|
---|
6578 | $result_rules .= $rules;
|
---|
6579 | }
|
---|
6580 | }
|
---|
6581 |
|
---|
6582 | # Handling the conditionals.
|
---|
6583 | elsif (/$IF_PATTERN/o)
|
---|
6584 | {
|
---|
6585 | $cond = cond_stack_if ($1, $2, $file);
|
---|
6586 | }
|
---|
6587 | elsif (/$ELSE_PATTERN/o)
|
---|
6588 | {
|
---|
6589 | $cond = cond_stack_else ($1, $2, $file);
|
---|
6590 | }
|
---|
6591 | elsif (/$ENDIF_PATTERN/o)
|
---|
6592 | {
|
---|
6593 | $cond = cond_stack_endif ($1, $2, $file);
|
---|
6594 | }
|
---|
6595 |
|
---|
6596 | # Handling rules.
|
---|
6597 | elsif (/$RULE_PATTERN/mso)
|
---|
6598 | {
|
---|
6599 | $is_rule = 1;
|
---|
6600 | $discard_rule = 0;
|
---|
6601 | # Separate relationship from optional actions: the first
|
---|
6602 | # `new-line tab" not preceded by backslash (continuation
|
---|
6603 | # line).
|
---|
6604 | my $paragraph = $_;
|
---|
6605 | /^(.*?)(?:(?<!\\)\n(\t.*))?$/s;
|
---|
6606 | my ($relationship, $actions) = ($1, $2 || '');
|
---|
6607 |
|
---|
6608 | # Separate targets from dependencies: the first colon.
|
---|
6609 | $relationship =~ /^([^:]+\S+) *: *(.*)$/som;
|
---|
6610 | my ($targets, $dependencies) = ($1, $2);
|
---|
6611 | # Remove the escaped new lines.
|
---|
6612 | # I don't know why, but I have to use a tmp $flat_deps.
|
---|
6613 | my $flat_deps = &flatten ($dependencies);
|
---|
6614 | my @deps = split (' ', $flat_deps);
|
---|
6615 |
|
---|
6616 | foreach (split (' ' , $targets))
|
---|
6617 | {
|
---|
6618 | # FIXME: 1. We are not robust to people defining several targets
|
---|
6619 | # at once, only some of them being in %dependencies. The
|
---|
6620 | # actions from the targets in %dependencies are usually generated
|
---|
6621 | # from the content of %actions, but if some targets in $targets
|
---|
6622 | # are not in %dependencies the ELSE branch will output
|
---|
6623 | # a rule for all $targets (i.e. the targets which are both
|
---|
6624 | # in %dependencies and $targets will have two rules).
|
---|
6625 |
|
---|
6626 | # FIXME: 2. The logic here is not able to output a
|
---|
6627 | # multi-paragraph rule several time (e.g. for each condition
|
---|
6628 | # it is defined for) because it only knows the first paragraph.
|
---|
6629 |
|
---|
6630 | # FIXME: 3. We are not robust to people defining a subset
|
---|
6631 | # of a previously defined "multiple-target" rule. E.g.
|
---|
6632 | # `foo:' after `foo bar:'.
|
---|
6633 |
|
---|
6634 | # Output only if not in FALSE.
|
---|
6635 | if (defined $dependencies{$_} && $cond != FALSE)
|
---|
6636 | {
|
---|
6637 | &depend ($_, @deps);
|
---|
6638 | if ($actions{$_})
|
---|
6639 | {
|
---|
6640 | $actions{$_} .= "\n$actions" if $actions;
|
---|
6641 | }
|
---|
6642 | else
|
---|
6643 | {
|
---|
6644 | $actions{$_} = $actions;
|
---|
6645 | }
|
---|
6646 | }
|
---|
6647 | else
|
---|
6648 | {
|
---|
6649 | # Free-lance dependency. Output the rule for all the
|
---|
6650 | # targets instead of one by one.
|
---|
6651 | my @undefined_conds =
|
---|
6652 | Automake::Rule::define ($targets, $file,
|
---|
6653 | $is_am ? RULE_AUTOMAKE : RULE_USER,
|
---|
6654 | $cond, $where);
|
---|
6655 | for my $undefined_cond (@undefined_conds)
|
---|
6656 | {
|
---|
6657 | my $condparagraph = $paragraph;
|
---|
6658 | $condparagraph =~ s/^/$undefined_cond->subst_string/gme;
|
---|
6659 | $result_rules .= "$spacing$comment$condparagraph\n";
|
---|
6660 | }
|
---|
6661 | if (scalar @undefined_conds == 0)
|
---|
6662 | {
|
---|
6663 | # Remember to discard next paragraphs
|
---|
6664 | # if they belong to this rule.
|
---|
6665 | # (but see also FIXME: #2 above.)
|
---|
6666 | $discard_rule = 1;
|
---|
6667 | }
|
---|
6668 | $comment = $spacing = '';
|
---|
6669 | last;
|
---|
6670 | }
|
---|
6671 | }
|
---|
6672 | }
|
---|
6673 |
|
---|
6674 | elsif (/$ASSIGNMENT_PATTERN/mso)
|
---|
6675 | {
|
---|
6676 | my ($var, $type, $val) = ($1, $2, $3);
|
---|
6677 | error $where, "variable `$var' with trailing backslash"
|
---|
6678 | if /\\$/;
|
---|
6679 |
|
---|
6680 | $is_rule = 0;
|
---|
6681 |
|
---|
6682 | Automake::Variable::define ($var,
|
---|
6683 | $is_am ? VAR_AUTOMAKE : VAR_MAKEFILE,
|
---|
6684 | $type, $cond, $val, $comment, $where,
|
---|
6685 | VAR_ASIS)
|
---|
6686 | if $cond != FALSE;
|
---|
6687 |
|
---|
6688 | $comment = $spacing = '';
|
---|
6689 | }
|
---|
6690 | else
|
---|
6691 | {
|
---|
6692 | # This isn't an error; it is probably some tokens which
|
---|
6693 | # configure is supposed to replace, such as `@SET-MAKE@',
|
---|
6694 | # or some part of a rule cut by an if/endif.
|
---|
6695 | if (! $cond->false && ! ($is_rule && $discard_rule))
|
---|
6696 | {
|
---|
6697 | s/^/$cond->subst_string/gme;
|
---|
6698 | $result_rules .= "$spacing$comment$_\n";
|
---|
6699 | }
|
---|
6700 | $comment = $spacing = '';
|
---|
6701 | }
|
---|
6702 | }
|
---|
6703 |
|
---|
6704 | error ($where, @cond_stack ?
|
---|
6705 | "unterminated conditionals: @cond_stack" :
|
---|
6706 | "too many conditionals closed in include file")
|
---|
6707 | if "@saved_cond_stack" ne "@cond_stack";
|
---|
6708 |
|
---|
6709 | return ($comment, $result_vars, $result_rules);
|
---|
6710 | }
|
---|
6711 |
|
---|
6712 |
|
---|
6713 | # $CONTENTS
|
---|
6714 | # &file_contents ($BASENAME, $WHERE, [%TRANSFORM])
|
---|
6715 | # ------------------------------------------------
|
---|
6716 | # Return contents of a file from $libdir/am, automatically skipping
|
---|
6717 | # macros or rules which are already known.
|
---|
6718 | sub file_contents ($$%)
|
---|
6719 | {
|
---|
6720 | my ($basename, $where, %transform) = @_;
|
---|
6721 | my ($comments, $variables, $rules) =
|
---|
6722 | file_contents_internal (1, "$libdir/am/$basename.am", $where,
|
---|
6723 | %transform);
|
---|
6724 | return "$comments$variables$rules";
|
---|
6725 | }
|
---|
6726 |
|
---|
6727 |
|
---|
6728 | # @PREFIX
|
---|
6729 | # &am_primary_prefixes ($PRIMARY, $CAN_DIST, @PREFIXES)
|
---|
6730 | # -----------------------------------------------------
|
---|
6731 | # Find all variable prefixes that are used for install directories. A
|
---|
6732 | # prefix `zar' qualifies iff:
|
---|
6733 | #
|
---|
6734 | # * `zardir' is a variable.
|
---|
6735 | # * `zar_PRIMARY' is a variable.
|
---|
6736 | #
|
---|
6737 | # As a side effect, it looks for misspellings. It is an error to have
|
---|
6738 | # a variable ending in a "reserved" suffix whose prefix is unknown, e.g.
|
---|
6739 | # "bin_PROGRAMS". However, unusual prefixes are allowed if a variable
|
---|
6740 | # of the same name (with "dir" appended) exists. For instance, if the
|
---|
6741 | # variable "zardir" is defined, then "zar_PROGRAMS" becomes valid.
|
---|
6742 | # This is to provide a little extra flexibility in those cases which
|
---|
6743 | # need it.
|
---|
6744 | sub am_primary_prefixes ($$@)
|
---|
6745 | {
|
---|
6746 | my ($primary, $can_dist, @prefixes) = @_;
|
---|
6747 |
|
---|
6748 | local $_;
|
---|
6749 | my %valid = map { $_ => 0 } @prefixes;
|
---|
6750 | $valid{'EXTRA'} = 0;
|
---|
6751 | foreach my $var (variables $primary)
|
---|
6752 | {
|
---|
6753 | # Automake is allowed to define variables that look like primaries
|
---|
6754 | # but which aren't. E.g. INSTALL_sh_DATA.
|
---|
6755 | # Autoconf can also define variables like INSTALL_DATA, so
|
---|
6756 | # ignore all configure variables (at least those which are not
|
---|
6757 | # redefined in Makefile.am).
|
---|
6758 | # FIXME: We should make sure that these variables are not
|
---|
6759 | # conditionally defined (or else adjust the condition below).
|
---|
6760 | my $def = $var->def (TRUE);
|
---|
6761 | next if $def && $def->owner != VAR_MAKEFILE;
|
---|
6762 |
|
---|
6763 | my $varname = $var->name;
|
---|
6764 |
|
---|
6765 | if ($varname =~ /^(nobase_)?(dist_|nodist_)?(.*)_[[:alnum:]]+$/)
|
---|
6766 | {
|
---|
6767 | my ($base, $dist, $X) = ($1 || '', $2 || '', $3 || '');
|
---|
6768 | if ($dist ne '' && ! $can_dist)
|
---|
6769 | {
|
---|
6770 | err_var ($var,
|
---|
6771 | "invalid variable `$varname': `dist' is forbidden");
|
---|
6772 | }
|
---|
6773 | # Standard directories must be explicitly allowed.
|
---|
6774 | elsif (! defined $valid{$X} && exists $standard_prefix{$X})
|
---|
6775 | {
|
---|
6776 | err_var ($var,
|
---|
6777 | "`${X}dir' is not a legitimate directory " .
|
---|
6778 | "for `$primary'");
|
---|
6779 | }
|
---|
6780 | # A not explicitly valid directory is allowed if Xdir is defined.
|
---|
6781 | elsif (! defined $valid{$X} &&
|
---|
6782 | $var->requires_variables ("`$varname' is used", "${X}dir"))
|
---|
6783 | {
|
---|
6784 | # Nothing to do. Any error message has been output
|
---|
6785 | # by $var->requires_variables.
|
---|
6786 | }
|
---|
6787 | else
|
---|
6788 | {
|
---|
6789 | # Ensure all extended prefixes are actually used.
|
---|
6790 | $valid{"$base$dist$X"} = 1;
|
---|
6791 | }
|
---|
6792 | }
|
---|
6793 | else
|
---|
6794 | {
|
---|
6795 | prog_error "unexpected variable name: $varname";
|
---|
6796 | }
|
---|
6797 | }
|
---|
6798 |
|
---|
6799 | # Return only those which are actually defined.
|
---|
6800 | return sort grep { var ($_ . '_' . $primary) } keys %valid;
|
---|
6801 | }
|
---|
6802 |
|
---|
6803 |
|
---|
6804 | # Handle `where_HOW' variable magic. Does all lookups, generates
|
---|
6805 | # install code, and possibly generates code to define the primary
|
---|
6806 | # variable. The first argument is the name of the .am file to munge,
|
---|
6807 | # the second argument is the primary variable (e.g. HEADERS), and all
|
---|
6808 | # subsequent arguments are possible installation locations.
|
---|
6809 | #
|
---|
6810 | # Returns list of [$location, $value] pairs, where
|
---|
6811 | # $value's are the values in all where_HOW variable, and $location
|
---|
6812 | # there associated location (the place here their parent variables were
|
---|
6813 | # defined).
|
---|
6814 | #
|
---|
6815 | # FIXME: this should be rewritten to be cleaner. It should be broken
|
---|
6816 | # up into multiple functions.
|
---|
6817 | #
|
---|
6818 | # Usage is: am_install_var (OPTION..., file, HOW, where...)
|
---|
6819 | sub am_install_var
|
---|
6820 | {
|
---|
6821 | my (@args) = @_;
|
---|
6822 |
|
---|
6823 | my $do_require = 1;
|
---|
6824 | my $can_dist = 0;
|
---|
6825 | my $default_dist = 0;
|
---|
6826 | while (@args)
|
---|
6827 | {
|
---|
6828 | if ($args[0] eq '-noextra')
|
---|
6829 | {
|
---|
6830 | $do_require = 0;
|
---|
6831 | }
|
---|
6832 | elsif ($args[0] eq '-candist')
|
---|
6833 | {
|
---|
6834 | $can_dist = 1;
|
---|
6835 | }
|
---|
6836 | elsif ($args[0] eq '-defaultdist')
|
---|
6837 | {
|
---|
6838 | $default_dist = 1;
|
---|
6839 | $can_dist = 1;
|
---|
6840 | }
|
---|
6841 | elsif ($args[0] !~ /^-/)
|
---|
6842 | {
|
---|
6843 | last;
|
---|
6844 | }
|
---|
6845 | shift (@args);
|
---|
6846 | }
|
---|
6847 |
|
---|
6848 | my ($file, $primary, @prefix) = @args;
|
---|
6849 |
|
---|
6850 | # Now that configure substitutions are allowed in where_HOW
|
---|
6851 | # variables, it is an error to actually define the primary. We
|
---|
6852 | # allow `JAVA', as it is customarily used to mean the Java
|
---|
6853 | # interpreter. This is but one of several Java hacks. Similarly,
|
---|
6854 | # `PYTHON' is customarily used to mean the Python interpreter.
|
---|
6855 | reject_var $primary, "`$primary' is an anachronism"
|
---|
6856 | unless $primary eq 'JAVA' || $primary eq 'PYTHON';
|
---|
6857 |
|
---|
6858 | # Get the prefixes which are valid and actually used.
|
---|
6859 | @prefix = am_primary_prefixes ($primary, $can_dist, @prefix);
|
---|
6860 |
|
---|
6861 | # If a primary includes a configure substitution, then the EXTRA_
|
---|
6862 | # form is required. Otherwise we can't properly do our job.
|
---|
6863 | my $require_extra;
|
---|
6864 |
|
---|
6865 | my @used = ();
|
---|
6866 | my @result = ();
|
---|
6867 |
|
---|
6868 | foreach my $X (@prefix)
|
---|
6869 | {
|
---|
6870 | my $nodir_name = $X;
|
---|
6871 | my $one_name = $X . '_' . $primary;
|
---|
6872 | my $one_var = var $one_name;
|
---|
6873 |
|
---|
6874 | my $strip_subdir = 1;
|
---|
6875 | # If subdir prefix should be preserved, do so.
|
---|
6876 | if ($nodir_name =~ /^nobase_/)
|
---|
6877 | {
|
---|
6878 | $strip_subdir = 0;
|
---|
6879 | $nodir_name =~ s/^nobase_//;
|
---|
6880 | }
|
---|
6881 |
|
---|
6882 | # If files should be distributed, do so.
|
---|
6883 | my $dist_p = 0;
|
---|
6884 | if ($can_dist)
|
---|
6885 | {
|
---|
6886 | $dist_p = (($default_dist && $nodir_name !~ /^nodist_/)
|
---|
6887 | || (! $default_dist && $nodir_name =~ /^dist_/));
|
---|
6888 | $nodir_name =~ s/^(dist|nodist)_//;
|
---|
6889 | }
|
---|
6890 |
|
---|
6891 |
|
---|
6892 | # Use the location of the currently processed variable.
|
---|
6893 | # We are not processing a particular condition, so pick the first
|
---|
6894 | # available.
|
---|
6895 | my $tmpcond = $one_var->conditions->one_cond;
|
---|
6896 | my $where = $one_var->rdef ($tmpcond)->location->clone;
|
---|
6897 |
|
---|
6898 | # Append actual contents of where_PRIMARY variable to
|
---|
6899 | # @result, skipping @substitutions@.
|
---|
6900 | foreach my $locvals ($one_var->value_as_list_recursive (location => 1))
|
---|
6901 | {
|
---|
6902 | my ($loc, $value) = @$locvals;
|
---|
6903 | # Skip configure substitutions.
|
---|
6904 | if ($value =~ /^\@.*\@$/)
|
---|
6905 | {
|
---|
6906 | if ($nodir_name eq 'EXTRA')
|
---|
6907 | {
|
---|
6908 | error ($where,
|
---|
6909 | "`$one_name' contains configure substitution, "
|
---|
6910 | . "but shouldn't");
|
---|
6911 | }
|
---|
6912 | # Check here to make sure variables defined in
|
---|
6913 | # configure.ac do not imply that EXTRA_PRIMARY
|
---|
6914 | # must be defined.
|
---|
6915 | elsif (! defined $configure_vars{$one_name})
|
---|
6916 | {
|
---|
6917 | $require_extra = $one_name
|
---|
6918 | if $do_require;
|
---|
6919 | }
|
---|
6920 | }
|
---|
6921 | else
|
---|
6922 | {
|
---|
6923 | push (@result, $locvals);
|
---|
6924 | }
|
---|
6925 | }
|
---|
6926 | # A blatant hack: we rewrite each _PROGRAMS primary to include
|
---|
6927 | # EXEEXT.
|
---|
6928 | append_exeext { 1 } $one_name
|
---|
6929 | if $primary eq 'PROGRAMS';
|
---|
6930 | # "EXTRA" shouldn't be used when generating clean targets,
|
---|
6931 | # all, or install targets. We used to warn if EXTRA_FOO was
|
---|
6932 | # defined uselessly, but this was annoying.
|
---|
6933 | next
|
---|
6934 | if $nodir_name eq 'EXTRA';
|
---|
6935 |
|
---|
6936 | if ($nodir_name eq 'check')
|
---|
6937 | {
|
---|
6938 | push (@check, '$(' . $one_name . ')');
|
---|
6939 | }
|
---|
6940 | else
|
---|
6941 | {
|
---|
6942 | push (@used, '$(' . $one_name . ')');
|
---|
6943 | }
|
---|
6944 |
|
---|
6945 | # Is this to be installed?
|
---|
6946 | my $install_p = $nodir_name ne 'noinst' && $nodir_name ne 'check';
|
---|
6947 |
|
---|
6948 | # If so, with install-exec? (or install-data?).
|
---|
6949 | my $exec_p = ($nodir_name =~ /$EXEC_DIR_PATTERN/o);
|
---|
6950 |
|
---|
6951 | my $check_options_p = $install_p && !! option 'std-options';
|
---|
6952 |
|
---|
6953 | # Use the location of the currently processed variable as context.
|
---|
6954 | $where->push_context ("while processing `$one_name'");
|
---|
6955 |
|
---|
6956 | # The variable containing all file to distribute.
|
---|
6957 | my $distvar = "\$($one_name)";
|
---|
6958 | $distvar = shadow_unconditionally ($one_name, $where)
|
---|
6959 | if ($dist_p && $one_var->has_conditional_contents);
|
---|
6960 |
|
---|
6961 | # Singular form of $PRIMARY.
|
---|
6962 | (my $one_primary = $primary) =~ s/S$//;
|
---|
6963 | $output_rules .= &file_contents ($file, $where,
|
---|
6964 | PRIMARY => $primary,
|
---|
6965 | ONE_PRIMARY => $one_primary,
|
---|
6966 | DIR => $X,
|
---|
6967 | NDIR => $nodir_name,
|
---|
6968 | BASE => $strip_subdir,
|
---|
6969 |
|
---|
6970 | EXEC => $exec_p,
|
---|
6971 | INSTALL => $install_p,
|
---|
6972 | DIST => $dist_p,
|
---|
6973 | DISTVAR => $distvar,
|
---|
6974 | 'CK-OPTS' => $check_options_p);
|
---|
6975 | }
|
---|
6976 |
|
---|
6977 | # The JAVA variable is used as the name of the Java interpreter.
|
---|
6978 | # The PYTHON variable is used as the name of the Python interpreter.
|
---|
6979 | if (@used && $primary ne 'JAVA' && $primary ne 'PYTHON')
|
---|
6980 | {
|
---|
6981 | # Define it.
|
---|
6982 | define_pretty_variable ($primary, TRUE, INTERNAL, @used);
|
---|
6983 | $output_vars .= "\n";
|
---|
6984 | }
|
---|
6985 |
|
---|
6986 | err_var ($require_extra,
|
---|
6987 | "`$require_extra' contains configure substitution,\n"
|
---|
6988 | . "but `EXTRA_$primary' not defined")
|
---|
6989 | if ($require_extra && ! var ('EXTRA_' . $primary));
|
---|
6990 |
|
---|
6991 | # Push here because PRIMARY might be configure time determined.
|
---|
6992 | push (@all, '$(' . $primary . ')')
|
---|
6993 | if @used && $primary ne 'JAVA' && $primary ne 'PYTHON';
|
---|
6994 |
|
---|
6995 | # Make the result unique. This lets the user use conditionals in
|
---|
6996 | # a natural way, but still lets us program lazily -- we don't have
|
---|
6997 | # to worry about handling a particular object more than once.
|
---|
6998 | # We will keep only one location per object.
|
---|
6999 | my %result = ();
|
---|
7000 | for my $pair (@result)
|
---|
7001 | {
|
---|
7002 | my ($loc, $val) = @$pair;
|
---|
7003 | $result{$val} = $loc;
|
---|
7004 | }
|
---|
7005 | my @l = sort keys %result;
|
---|
7006 | return map { [$result{$_}->clone, $_] } @l;
|
---|
7007 | }
|
---|
7008 |
|
---|
7009 |
|
---|
7010 | ################################################################
|
---|
7011 |
|
---|
7012 | # Each key in this hash is the name of a directory holding a
|
---|
7013 | # Makefile.in. These variables are local to `is_make_dir'.
|
---|
7014 | my %make_dirs = ();
|
---|
7015 | my $make_dirs_set = 0;
|
---|
7016 |
|
---|
7017 | sub is_make_dir
|
---|
7018 | {
|
---|
7019 | my ($dir) = @_;
|
---|
7020 | if (! $make_dirs_set)
|
---|
7021 | {
|
---|
7022 | foreach my $iter (@configure_input_files)
|
---|
7023 | {
|
---|
7024 | $make_dirs{dirname ($iter)} = 1;
|
---|
7025 | }
|
---|
7026 | # We also want to notice Makefile.in's.
|
---|
7027 | foreach my $iter (@other_input_files)
|
---|
7028 | {
|
---|
7029 | if ($iter =~ /Makefile\.in$/)
|
---|
7030 | {
|
---|
7031 | $make_dirs{dirname ($iter)} = 1;
|
---|
7032 | }
|
---|
7033 | }
|
---|
7034 | $make_dirs_set = 1;
|
---|
7035 | }
|
---|
7036 | return defined $make_dirs{$dir};
|
---|
7037 | }
|
---|
7038 |
|
---|
7039 | ################################################################
|
---|
7040 |
|
---|
7041 | # Find the aux dir. This should match the algorithm used by
|
---|
7042 | # ./configure. (See the Autoconf documentation for for
|
---|
7043 | # AC_CONFIG_AUX_DIR.)
|
---|
7044 | sub locate_aux_dir ()
|
---|
7045 | {
|
---|
7046 | if (! $config_aux_dir_set_in_configure_ac)
|
---|
7047 | {
|
---|
7048 | # The default auxiliary directory is the first
|
---|
7049 | # of ., .., or ../.. that contains install-sh.
|
---|
7050 | # Assume . if install-sh doesn't exist yet.
|
---|
7051 | for my $dir (qw (. .. ../..))
|
---|
7052 | {
|
---|
7053 | if (-f "$dir/install-sh")
|
---|
7054 | {
|
---|
7055 | $config_aux_dir = $dir;
|
---|
7056 | last;
|
---|
7057 | }
|
---|
7058 | }
|
---|
7059 | $config_aux_dir = '.' unless $config_aux_dir;
|
---|
7060 | }
|
---|
7061 | # Avoid unsightly '/.'s.
|
---|
7062 | $am_config_aux_dir =
|
---|
7063 | '$(top_srcdir)' . ($config_aux_dir eq '.' ? "" : "/$config_aux_dir");
|
---|
7064 | $am_config_aux_dir =~ s,/*$,,;
|
---|
7065 | }
|
---|
7066 |
|
---|
7067 |
|
---|
7068 | # &maybe_push_required_file ($DIR, $FILE, $FULLFILE)
|
---|
7069 | # --------------------------------------------------
|
---|
7070 | # See if we want to push this file onto dist_common. This function
|
---|
7071 | # encodes the rules for deciding when to do so.
|
---|
7072 | sub maybe_push_required_file
|
---|
7073 | {
|
---|
7074 | my ($dir, $file, $fullfile) = @_;
|
---|
7075 |
|
---|
7076 | if ($dir eq $relative_dir)
|
---|
7077 | {
|
---|
7078 | push_dist_common ($file);
|
---|
7079 | return 1;
|
---|
7080 | }
|
---|
7081 | elsif ($relative_dir eq '.' && ! &is_make_dir ($dir))
|
---|
7082 | {
|
---|
7083 | # If we are doing the topmost directory, and the file is in a
|
---|
7084 | # subdir which does not have a Makefile, then we distribute it
|
---|
7085 | # here.
|
---|
7086 |
|
---|
7087 | # If a required file is above the source tree, it is important
|
---|
7088 | # to prefix it with `$(srcdir)' so that no VPATH search is
|
---|
7089 | # performed. Otherwise problems occur with Make implementations
|
---|
7090 | # that rewrite and simplify rules whose dependencies are found in a
|
---|
7091 | # VPATH location. Here is an example with OSF1/Tru64 Make.
|
---|
7092 | #
|
---|
7093 | # % cat Makefile
|
---|
7094 | # VPATH = sub
|
---|
7095 | # distdir: ../a
|
---|
7096 | # echo ../a
|
---|
7097 | # % ls
|
---|
7098 | # Makefile a
|
---|
7099 | # % make
|
---|
7100 | # echo a
|
---|
7101 | # a
|
---|
7102 | #
|
---|
7103 | # Dependency `../a' was found in `sub/../a', but this make
|
---|
7104 | # implementation simplified it as `a'. (Note that the sub/
|
---|
7105 | # directory does not even exist.)
|
---|
7106 | #
|
---|
7107 | # This kind of VPATH rewriting seems hard to cancel. The
|
---|
7108 | # distdir.am hack against VPATH rewriting works only when no
|
---|
7109 | # simplification is done, i.e., for dependencies which are in
|
---|
7110 | # subdirectories, not in enclosing directories. Hence, in
|
---|
7111 | # the latter case we use a full path to make sure no VPATH
|
---|
7112 | # search occurs.
|
---|
7113 | $fullfile = '$(srcdir)/' . $fullfile
|
---|
7114 | if $dir =~ m,^\.\.(?:$|/),;
|
---|
7115 |
|
---|
7116 | push_dist_common ($fullfile);
|
---|
7117 | return 1;
|
---|
7118 | }
|
---|
7119 | return 0;
|
---|
7120 | }
|
---|
7121 |
|
---|
7122 |
|
---|
7123 | # If a file name appears as a key in this hash, then it has already
|
---|
7124 | # been checked for. This allows us not to report the same error more
|
---|
7125 | # than once.
|
---|
7126 | my %required_file_not_found = ();
|
---|
7127 |
|
---|
7128 | # &require_file_internal ($WHERE, $MYSTRICT, $DIRECTORY, @FILES)
|
---|
7129 | # --------------------------------------------------------------
|
---|
7130 | # Verify that the file must exist in $DIRECTORY, or install it.
|
---|
7131 | # $MYSTRICT is the strictness level at which this file becomes required.
|
---|
7132 | sub require_file_internal ($$$@)
|
---|
7133 | {
|
---|
7134 | my ($where, $mystrict, $dir, @files) = @_;
|
---|
7135 |
|
---|
7136 | foreach my $file (@files)
|
---|
7137 | {
|
---|
7138 | my $fullfile = "$dir/$file";
|
---|
7139 | my $found_it = 0;
|
---|
7140 | my $dangling_sym = 0;
|
---|
7141 |
|
---|
7142 | if (-l $fullfile && ! -f $fullfile)
|
---|
7143 | {
|
---|
7144 | $dangling_sym = 1;
|
---|
7145 | }
|
---|
7146 | elsif (dir_has_case_matching_file ($dir, $file))
|
---|
7147 | {
|
---|
7148 | $found_it = 1;
|
---|
7149 | maybe_push_required_file ($dir, $file, $fullfile);
|
---|
7150 | }
|
---|
7151 |
|
---|
7152 | # `--force-missing' only has an effect if `--add-missing' is
|
---|
7153 | # specified.
|
---|
7154 | if ($found_it && (! $add_missing || ! $force_missing))
|
---|
7155 | {
|
---|
7156 | next;
|
---|
7157 | }
|
---|
7158 | else
|
---|
7159 | {
|
---|
7160 | # If we've already looked for it, we're done. You might
|
---|
7161 | # wonder why we don't do this before searching for the
|
---|
7162 | # file. If we do that, then something like
|
---|
7163 | # AC_OUTPUT(subdir/foo foo) will fail to put foo.in into
|
---|
7164 | # DIST_COMMON.
|
---|
7165 | if (! $found_it)
|
---|
7166 | {
|
---|
7167 | next if defined $required_file_not_found{$fullfile};
|
---|
7168 | $required_file_not_found{$fullfile} = 1;
|
---|
7169 | }
|
---|
7170 |
|
---|
7171 | if ($strictness >= $mystrict)
|
---|
7172 | {
|
---|
7173 | if ($dangling_sym && $add_missing)
|
---|
7174 | {
|
---|
7175 | unlink ($fullfile);
|
---|
7176 | }
|
---|
7177 |
|
---|
7178 | my $trailer = '';
|
---|
7179 | my $suppress = 0;
|
---|
7180 |
|
---|
7181 | # Only install missing files according to our desired
|
---|
7182 | # strictness level.
|
---|
7183 | my $message = "required file `$fullfile' not found";
|
---|
7184 | if ($add_missing)
|
---|
7185 | {
|
---|
7186 | if (-f "$libdir/$file")
|
---|
7187 | {
|
---|
7188 | $suppress = 1;
|
---|
7189 |
|
---|
7190 | # Install the missing file. Symlink if we
|
---|
7191 | # can, copy if we must. Note: delete the file
|
---|
7192 | # first, in case it is a dangling symlink.
|
---|
7193 | $message = "installing `$fullfile'";
|
---|
7194 | # Windows Perl will hang if we try to delete a
|
---|
7195 | # file that doesn't exist.
|
---|
7196 | unlink ($fullfile) if -f $fullfile;
|
---|
7197 | if ($symlink_exists && ! $copy_missing)
|
---|
7198 | {
|
---|
7199 | if (! symlink ("$libdir/$file", $fullfile))
|
---|
7200 | {
|
---|
7201 | $suppress = 0;
|
---|
7202 | $trailer = "; error while making link: $!";
|
---|
7203 | }
|
---|
7204 | }
|
---|
7205 | elsif (system ('cp', "$libdir/$file", $fullfile))
|
---|
7206 | {
|
---|
7207 | $suppress = 0;
|
---|
7208 | $trailer = "\n error while copying";
|
---|
7209 | }
|
---|
7210 | reset_dir_cache ($dir);
|
---|
7211 | }
|
---|
7212 |
|
---|
7213 | if (! maybe_push_required_file (dirname ($fullfile),
|
---|
7214 | $file, $fullfile))
|
---|
7215 | {
|
---|
7216 | if (! $found_it && ! $automake_will_process_aux_dir)
|
---|
7217 | {
|
---|
7218 | # We have added the file but could not push it
|
---|
7219 | # into DIST_COMMON, probably because this is
|
---|
7220 | # an auxiliary file and we are not processing
|
---|
7221 | # the top level Makefile. Furthermore Automake
|
---|
7222 | # hasn't been asked to create the Makefile.in
|
---|
7223 | # that distribute the aux dir files.
|
---|
7224 | error ($where, 'Please make a full run of automake'
|
---|
7225 | . " so $fullfile gets distributed.");
|
---|
7226 | }
|
---|
7227 | }
|
---|
7228 | }
|
---|
7229 | else
|
---|
7230 | {
|
---|
7231 | $trailer = "\n `automake --add-missing' can install `$file'"
|
---|
7232 | if -f "$libdir/$file";
|
---|
7233 | }
|
---|
7234 |
|
---|
7235 | # If --force-missing was specified, and we have
|
---|
7236 | # actually found the file, then do nothing.
|
---|
7237 | next
|
---|
7238 | if $found_it && $force_missing;
|
---|
7239 |
|
---|
7240 | # If we couldn't install the file, but it is a target in
|
---|
7241 | # the Makefile, don't print anything. This allows files
|
---|
7242 | # like README, AUTHORS, or THANKS to be generated.
|
---|
7243 | next
|
---|
7244 | if !$suppress && rule $file;
|
---|
7245 |
|
---|
7246 | msg ($suppress ? 'note' : 'error', $where, "$message$trailer");
|
---|
7247 | }
|
---|
7248 | }
|
---|
7249 | }
|
---|
7250 | }
|
---|
7251 |
|
---|
7252 | # &require_file ($WHERE, $MYSTRICT, @FILES)
|
---|
7253 | # -----------------------------------------
|
---|
7254 | sub require_file ($$@)
|
---|
7255 | {
|
---|
7256 | my ($where, $mystrict, @files) = @_;
|
---|
7257 | require_file_internal ($where, $mystrict, $relative_dir, @files);
|
---|
7258 | }
|
---|
7259 |
|
---|
7260 | # &require_file_with_macro ($COND, $MACRO, $MYSTRICT, @FILES)
|
---|
7261 | # -----------------------------------------------------------
|
---|
7262 | sub require_file_with_macro ($$$@)
|
---|
7263 | {
|
---|
7264 | my ($cond, $macro, $mystrict, @files) = @_;
|
---|
7265 | $macro = rvar ($macro) unless ref $macro;
|
---|
7266 | require_file ($macro->rdef ($cond)->location, $mystrict, @files);
|
---|
7267 | }
|
---|
7268 |
|
---|
7269 | # &require_libsource_with_macro ($COND, $MACRO, $MYSTRICT, @FILES)
|
---|
7270 | # ----------------------------------------------------------------
|
---|
7271 | # Require an AC_LIBSOURCEd file. If AC_CONFIG_LIBOBJ_DIR was called, it
|
---|
7272 | # must be in that directory. Otherwise expect it in the current directory.
|
---|
7273 | sub require_libsource_with_macro ($$$@)
|
---|
7274 | {
|
---|
7275 | my ($cond, $macro, $mystrict, @files) = @_;
|
---|
7276 | $macro = rvar ($macro) unless ref $macro;
|
---|
7277 | if ($config_libobj_dir)
|
---|
7278 | {
|
---|
7279 | require_file_internal ($macro->rdef ($cond)->location, $mystrict,
|
---|
7280 | $config_libobj_dir, @files);
|
---|
7281 | }
|
---|
7282 | else
|
---|
7283 | {
|
---|
7284 | require_file ($macro->rdef ($cond)->location, $mystrict, @files);
|
---|
7285 | }
|
---|
7286 | }
|
---|
7287 |
|
---|
7288 | # &require_conf_file ($WHERE, $MYSTRICT, @FILES)
|
---|
7289 | # ----------------------------------------------
|
---|
7290 | # Looks in configuration path, as specified by AC_CONFIG_AUX_DIR.
|
---|
7291 | sub require_conf_file ($$@)
|
---|
7292 | {
|
---|
7293 | my ($where, $mystrict, @files) = @_;
|
---|
7294 | require_file_internal ($where, $mystrict, $config_aux_dir, @files);
|
---|
7295 | }
|
---|
7296 |
|
---|
7297 |
|
---|
7298 | # &require_conf_file_with_macro ($COND, $MACRO, $MYSTRICT, @FILES)
|
---|
7299 | # ----------------------------------------------------------------
|
---|
7300 | sub require_conf_file_with_macro ($$$@)
|
---|
7301 | {
|
---|
7302 | my ($cond, $macro, $mystrict, @files) = @_;
|
---|
7303 | require_conf_file (rvar ($macro)->rdef ($cond)->location,
|
---|
7304 | $mystrict, @files);
|
---|
7305 | }
|
---|
7306 |
|
---|
7307 | ################################################################
|
---|
7308 |
|
---|
7309 | # &require_build_directory ($DIRECTORY)
|
---|
7310 | # ------------------------------------
|
---|
7311 | # Emit rules to create $DIRECTORY if needed, and return
|
---|
7312 | # the file that any target requiring this directory should be made
|
---|
7313 | # dependent upon.
|
---|
7314 | # We don't want to emit the rule twice, and want to reuse it
|
---|
7315 | # for directories with equivalent names (e.g., `foo/bar' and `./foo//bar').
|
---|
7316 | sub require_build_directory ($)
|
---|
7317 | {
|
---|
7318 | my $directory = shift;
|
---|
7319 |
|
---|
7320 | return $directory_map{$directory} if exists $directory_map{$directory};
|
---|
7321 |
|
---|
7322 | my $cdir = File::Spec->canonpath ($directory);
|
---|
7323 |
|
---|
7324 | if (exists $directory_map{$cdir})
|
---|
7325 | {
|
---|
7326 | my $stamp = $directory_map{$cdir};
|
---|
7327 | $directory_map{$directory} = $stamp;
|
---|
7328 | return $stamp;
|
---|
7329 | }
|
---|
7330 |
|
---|
7331 | my $dirstamp = "$cdir/\$(am__dirstamp)";
|
---|
7332 |
|
---|
7333 | $directory_map{$directory} = $dirstamp;
|
---|
7334 | $directory_map{$cdir} = $dirstamp;
|
---|
7335 |
|
---|
7336 | # Set a variable for the dirstamp basename.
|
---|
7337 | define_pretty_variable ('am__dirstamp', TRUE, INTERNAL,
|
---|
7338 | '$(am__leading_dot)dirstamp');
|
---|
7339 |
|
---|
7340 | # Directory must be removed by `make distclean'.
|
---|
7341 | $clean_files{$dirstamp} = DIST_CLEAN;
|
---|
7342 |
|
---|
7343 | $output_rules .= ("$dirstamp:\n"
|
---|
7344 | . "\t\@\$(MKDIR_P) $directory\n"
|
---|
7345 | . "\t\@: > $dirstamp\n");
|
---|
7346 |
|
---|
7347 | return $dirstamp;
|
---|
7348 | }
|
---|
7349 |
|
---|
7350 | # &require_build_directory_maybe ($FILE)
|
---|
7351 | # --------------------------------------
|
---|
7352 | # If $FILE lies in a subdirectory, emit a rule to create this
|
---|
7353 | # directory and return the file that $FILE should be made
|
---|
7354 | # dependent upon. Otherwise, just return the empty string.
|
---|
7355 | sub require_build_directory_maybe ($)
|
---|
7356 | {
|
---|
7357 | my $file = shift;
|
---|
7358 | my $directory = dirname ($file);
|
---|
7359 |
|
---|
7360 | if ($directory ne '.')
|
---|
7361 | {
|
---|
7362 | return require_build_directory ($directory);
|
---|
7363 | }
|
---|
7364 | else
|
---|
7365 | {
|
---|
7366 | return '';
|
---|
7367 | }
|
---|
7368 | }
|
---|
7369 |
|
---|
7370 | ################################################################
|
---|
7371 |
|
---|
7372 | # Push a list of files onto dist_common.
|
---|
7373 | sub push_dist_common
|
---|
7374 | {
|
---|
7375 | prog_error "push_dist_common run after handle_dist"
|
---|
7376 | if $handle_dist_run;
|
---|
7377 | Automake::Variable::define ('DIST_COMMON', VAR_AUTOMAKE, '+', TRUE, "@_",
|
---|
7378 | '', INTERNAL, VAR_PRETTY);
|
---|
7379 | }
|
---|
7380 |
|
---|
7381 |
|
---|
7382 | ################################################################
|
---|
7383 |
|
---|
7384 | # generate_makefile ($MAKEFILE_AM, $MAKEFILE_IN)
|
---|
7385 | # ----------------------------------------------
|
---|
7386 | # Generate a Makefile.in given the name of the corresponding Makefile and
|
---|
7387 | # the name of the file output by config.status.
|
---|
7388 | sub generate_makefile ($$)
|
---|
7389 | {
|
---|
7390 | my ($makefile_am, $makefile_in) = @_;
|
---|
7391 |
|
---|
7392 | # Reset all the Makefile.am related variables.
|
---|
7393 | initialize_per_input;
|
---|
7394 |
|
---|
7395 | # AUTOMAKE_OPTIONS can contains -W flags to disable or enable
|
---|
7396 | # warnings for this file. So hold any warning issued before
|
---|
7397 | # we have processed AUTOMAKE_OPTIONS.
|
---|
7398 | buffer_messages ('warning');
|
---|
7399 |
|
---|
7400 | # Name of input file ("Makefile.am") and output file
|
---|
7401 | # ("Makefile.in"). These have no directory components.
|
---|
7402 | $am_file_name = basename ($makefile_am);
|
---|
7403 | $in_file_name = basename ($makefile_in);
|
---|
7404 |
|
---|
7405 | # $OUTPUT is encoded. If it contains a ":" then the first element
|
---|
7406 | # is the real output file, and all remaining elements are input
|
---|
7407 | # files. We don't scan or otherwise deal with these input files,
|
---|
7408 | # other than to mark them as dependencies. See
|
---|
7409 | # &scan_autoconf_files for details.
|
---|
7410 | my ($makefile, @inputs) = split (/:/, $output_files{$makefile_in});
|
---|
7411 |
|
---|
7412 | $relative_dir = dirname ($makefile);
|
---|
7413 | $am_relative_dir = dirname ($makefile_am);
|
---|
7414 | $topsrcdir = backname ($relative_dir);
|
---|
7415 |
|
---|
7416 | read_main_am_file ($makefile_am);
|
---|
7417 | if (handle_options)
|
---|
7418 | {
|
---|
7419 | # Process buffered warnings.
|
---|
7420 | flush_messages;
|
---|
7421 | # Fatal error. Just return, so we can continue with next file.
|
---|
7422 | return;
|
---|
7423 | }
|
---|
7424 | # Process buffered warnings.
|
---|
7425 | flush_messages;
|
---|
7426 |
|
---|
7427 | # There are a few install-related variables that you should not define.
|
---|
7428 | foreach my $var ('PRE_INSTALL', 'POST_INSTALL', 'NORMAL_INSTALL')
|
---|
7429 | {
|
---|
7430 | my $v = var $var;
|
---|
7431 | if ($v)
|
---|
7432 | {
|
---|
7433 | my $def = $v->def (TRUE);
|
---|
7434 | prog_error "$var not defined in condition TRUE"
|
---|
7435 | unless $def;
|
---|
7436 | reject_var $var, "`$var' should not be defined"
|
---|
7437 | if $def->owner != VAR_AUTOMAKE;
|
---|
7438 | }
|
---|
7439 | }
|
---|
7440 |
|
---|
7441 | # Catch some obsolete variables.
|
---|
7442 | msg_var ('obsolete', 'INCLUDES',
|
---|
7443 | "`INCLUDES' is the old name for `AM_CPPFLAGS' (or `*_CPPFLAGS')")
|
---|
7444 | if var ('INCLUDES');
|
---|
7445 |
|
---|
7446 | # Must do this after reading .am file.
|
---|
7447 | define_variable ('subdir', $relative_dir, INTERNAL);
|
---|
7448 |
|
---|
7449 | # If DIST_SUBDIRS is defined, make sure SUBDIRS is, so that
|
---|
7450 | # recursive rules are enabled.
|
---|
7451 | define_pretty_variable ('SUBDIRS', TRUE, INTERNAL, '')
|
---|
7452 | if var 'DIST_SUBDIRS' && ! var 'SUBDIRS';
|
---|
7453 |
|
---|
7454 | # Check first, because we might modify some state.
|
---|
7455 | check_cygnus;
|
---|
7456 | check_gnu_standards;
|
---|
7457 | check_gnits_standards;
|
---|
7458 |
|
---|
7459 | handle_configure ($makefile_am, $makefile_in, $makefile, @inputs);
|
---|
7460 | handle_gettext;
|
---|
7461 | handle_libraries;
|
---|
7462 | handle_ltlibraries;
|
---|
7463 | handle_programs;
|
---|
7464 | handle_scripts;
|
---|
7465 |
|
---|
7466 | # These must be run after all the sources are scanned. They
|
---|
7467 | # use variables defined by &handle_libraries, &handle_ltlibraries,
|
---|
7468 | # or &handle_programs.
|
---|
7469 | handle_compile;
|
---|
7470 | handle_languages;
|
---|
7471 | handle_libtool;
|
---|
7472 |
|
---|
7473 | # Variables used by distdir.am and tags.am.
|
---|
7474 | define_pretty_variable ('SOURCES', TRUE, INTERNAL, @sources);
|
---|
7475 | if (! option 'no-dist')
|
---|
7476 | {
|
---|
7477 | define_pretty_variable ('DIST_SOURCES', TRUE, INTERNAL, @dist_sources);
|
---|
7478 | }
|
---|
7479 |
|
---|
7480 | handle_multilib;
|
---|
7481 | handle_texinfo;
|
---|
7482 | handle_emacs_lisp;
|
---|
7483 | handle_python;
|
---|
7484 | handle_java;
|
---|
7485 | handle_man_pages;
|
---|
7486 | handle_data;
|
---|
7487 | handle_headers;
|
---|
7488 | handle_subdirs;
|
---|
7489 | handle_tags;
|
---|
7490 | handle_minor_options;
|
---|
7491 | # Must come after handle_programs so that %known_programs is up-to-date.
|
---|
7492 | handle_tests;
|
---|
7493 |
|
---|
7494 | # This must come after most other rules.
|
---|
7495 | handle_dist;
|
---|
7496 |
|
---|
7497 | handle_footer;
|
---|
7498 | do_check_merge_target;
|
---|
7499 | handle_all ($makefile);
|
---|
7500 |
|
---|
7501 | # FIXME: Gross!
|
---|
7502 | if (var ('lib_LTLIBRARIES') && var ('bin_PROGRAMS'))
|
---|
7503 | {
|
---|
7504 | $output_rules .= "install-binPROGRAMS: install-libLTLIBRARIES\n\n";
|
---|
7505 | }
|
---|
7506 |
|
---|
7507 | handle_install;
|
---|
7508 | handle_clean ($makefile);
|
---|
7509 | handle_factored_dependencies;
|
---|
7510 |
|
---|
7511 | # Comes last, because all the above procedures may have
|
---|
7512 | # defined or overridden variables.
|
---|
7513 | $output_vars .= output_variables;
|
---|
7514 |
|
---|
7515 | check_typos;
|
---|
7516 |
|
---|
7517 | my ($out_file) = $output_directory . '/' . $makefile_in;
|
---|
7518 |
|
---|
7519 | if ($exit_code != 0)
|
---|
7520 | {
|
---|
7521 | verb "not writing $out_file because of earlier errors";
|
---|
7522 | return;
|
---|
7523 | }
|
---|
7524 |
|
---|
7525 | if (! -d ($output_directory . '/' . $am_relative_dir))
|
---|
7526 | {
|
---|
7527 | mkdir ($output_directory . '/' . $am_relative_dir, 0755);
|
---|
7528 | }
|
---|
7529 |
|
---|
7530 | # We make sure that `all:' is the first target.
|
---|
7531 | my $output =
|
---|
7532 | "$output_vars$output_all$output_header$output_rules$output_trailer";
|
---|
7533 |
|
---|
7534 | # Decide whether we must update the output file or not.
|
---|
7535 | # We have to update in the following situations.
|
---|
7536 | # * $force_generation is set.
|
---|
7537 | # * any of the output dependencies is younger than the output
|
---|
7538 | # * the contents of the output is different (this can happen
|
---|
7539 | # if the project has been populated with a file listed in
|
---|
7540 | # @common_files since the last run).
|
---|
7541 | # Output's dependencies are split in two sets:
|
---|
7542 | # * dependencies which are also configure dependencies
|
---|
7543 | # These do not change between each Makefile.am
|
---|
7544 | # * other dependencies, specific to the Makefile.am being processed
|
---|
7545 | # (such as the Makefile.am itself, or any Makefile fragment
|
---|
7546 | # it includes).
|
---|
7547 | my $timestamp = mtime $out_file;
|
---|
7548 | if (! $force_generation
|
---|
7549 | && $configure_deps_greatest_timestamp < $timestamp
|
---|
7550 | && $output_deps_greatest_timestamp < $timestamp
|
---|
7551 | && $output eq contents ($out_file))
|
---|
7552 | {
|
---|
7553 | verb "$out_file unchanged";
|
---|
7554 | # No need to update.
|
---|
7555 | return;
|
---|
7556 | }
|
---|
7557 |
|
---|
7558 | if (-e $out_file)
|
---|
7559 | {
|
---|
7560 | unlink ($out_file)
|
---|
7561 | or fatal "cannot remove $out_file: $!\n";
|
---|
7562 | }
|
---|
7563 |
|
---|
7564 | my $gm_file = new Automake::XFile "> $out_file";
|
---|
7565 | verb "creating $out_file";
|
---|
7566 | print $gm_file $output;
|
---|
7567 | }
|
---|
7568 |
|
---|
7569 | ################################################################
|
---|
7570 |
|
---|
7571 |
|
---|
7572 |
|
---|
7573 |
|
---|
7574 | ################################################################
|
---|
7575 |
|
---|
7576 | # Print usage information.
|
---|
7577 | sub usage ()
|
---|
7578 | {
|
---|
7579 | print "Usage: $0 [OPTION] ... [Makefile]...
|
---|
7580 |
|
---|
7581 | Generate Makefile.in for configure from Makefile.am.
|
---|
7582 |
|
---|
7583 | Operation modes:
|
---|
7584 | --help print this help, then exit
|
---|
7585 | --version print version number, then exit
|
---|
7586 | -v, --verbose verbosely list files processed
|
---|
7587 | --no-force only update Makefile.in's that are out of date
|
---|
7588 | -W, --warnings=CATEGORY report the warnings falling in CATEGORY
|
---|
7589 |
|
---|
7590 | Dependency tracking:
|
---|
7591 | -i, --ignore-deps disable dependency tracking code
|
---|
7592 | --include-deps enable dependency tracking code
|
---|
7593 |
|
---|
7594 | Flavors:
|
---|
7595 | --cygnus assume program is part of Cygnus-style tree
|
---|
7596 | --foreign set strictness to foreign
|
---|
7597 | --gnits set strictness to gnits
|
---|
7598 | --gnu set strictness to gnu
|
---|
7599 |
|
---|
7600 | Library files:
|
---|
7601 | -a, --add-missing add missing standard files to package
|
---|
7602 | --libdir=DIR directory storing library files
|
---|
7603 | -c, --copy with -a, copy missing files (default is symlink)
|
---|
7604 | -f, --force-missing force update of standard files
|
---|
7605 |
|
---|
7606 | ";
|
---|
7607 | Automake::ChannelDefs::usage;
|
---|
7608 |
|
---|
7609 | my ($last, @lcomm);
|
---|
7610 | $last = '';
|
---|
7611 | foreach my $iter (sort ((@common_files, @common_sometimes)))
|
---|
7612 | {
|
---|
7613 | push (@lcomm, $iter) unless $iter eq $last;
|
---|
7614 | $last = $iter;
|
---|
7615 | }
|
---|
7616 |
|
---|
7617 | my @four;
|
---|
7618 | print "\nFiles which are automatically distributed, if found:\n";
|
---|
7619 | format USAGE_FORMAT =
|
---|
7620 | @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<
|
---|
7621 | $four[0], $four[1], $four[2], $four[3]
|
---|
7622 | .
|
---|
7623 | $~ = "USAGE_FORMAT";
|
---|
7624 |
|
---|
7625 | my $cols = 4;
|
---|
7626 | my $rows = int(@lcomm / $cols);
|
---|
7627 | my $rest = @lcomm % $cols;
|
---|
7628 |
|
---|
7629 | if ($rest)
|
---|
7630 | {
|
---|
7631 | $rows++;
|
---|
7632 | }
|
---|
7633 | else
|
---|
7634 | {
|
---|
7635 | $rest = $cols;
|
---|
7636 | }
|
---|
7637 |
|
---|
7638 | for (my $y = 0; $y < $rows; $y++)
|
---|
7639 | {
|
---|
7640 | @four = ("", "", "", "");
|
---|
7641 | for (my $x = 0; $x < $cols; $x++)
|
---|
7642 | {
|
---|
7643 | last if $y + 1 == $rows && $x == $rest;
|
---|
7644 |
|
---|
7645 | my $idx = (($x > $rest)
|
---|
7646 | ? ($rows * $rest + ($rows - 1) * ($x - $rest))
|
---|
7647 | : ($rows * $x));
|
---|
7648 |
|
---|
7649 | $idx += $y;
|
---|
7650 | $four[$x] = $lcomm[$idx];
|
---|
7651 | }
|
---|
7652 | write;
|
---|
7653 | }
|
---|
7654 |
|
---|
7655 | print "\nReport bugs to <bug-automake\@gnu.org>.\n";
|
---|
7656 |
|
---|
7657 | # --help always returns 0 per GNU standards.
|
---|
7658 | exit 0;
|
---|
7659 | }
|
---|
7660 |
|
---|
7661 |
|
---|
7662 | # &version ()
|
---|
7663 | # -----------
|
---|
7664 | # Print version information
|
---|
7665 | sub version ()
|
---|
7666 | {
|
---|
7667 | print <<EOF;
|
---|
7668 | automake (GNU $PACKAGE) $VERSION
|
---|
7669 | Written by Tom Tromey <tromey\@redhat.com>
|
---|
7670 | and Alexandre Duret-Lutz <adl\@gnu.org>.
|
---|
7671 |
|
---|
7672 | Copyright 2006 Free Software Foundation, Inc.
|
---|
7673 | This is free software; see the source for copying conditions. There is NO
|
---|
7674 | warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
---|
7675 | EOF
|
---|
7676 | # --version always returns 0 per GNU standards.
|
---|
7677 | exit 0;
|
---|
7678 | }
|
---|
7679 |
|
---|
7680 | ################################################################
|
---|
7681 |
|
---|
7682 | # Parse command line.
|
---|
7683 | sub parse_arguments ()
|
---|
7684 | {
|
---|
7685 | # Start off as gnu.
|
---|
7686 | set_strictness ('gnu');
|
---|
7687 |
|
---|
7688 | my $cli_where = new Automake::Location;
|
---|
7689 | my %cli_options =
|
---|
7690 | (
|
---|
7691 | 'libdir=s' => \$libdir,
|
---|
7692 | 'gnu' => sub { set_strictness ('gnu'); },
|
---|
7693 | 'gnits' => sub { set_strictness ('gnits'); },
|
---|
7694 | 'cygnus' => sub { set_global_option ('cygnus', $cli_where); },
|
---|
7695 | 'foreign' => sub { set_strictness ('foreign'); },
|
---|
7696 | 'include-deps' => sub { unset_global_option ('no-dependencies'); },
|
---|
7697 | 'i|ignore-deps' => sub { set_global_option ('no-dependencies',
|
---|
7698 | $cli_where); },
|
---|
7699 | 'no-force' => sub { $force_generation = 0; },
|
---|
7700 | 'f|force-missing' => \$force_missing,
|
---|
7701 | 'o|output-dir=s' => \$output_directory,
|
---|
7702 | 'a|add-missing' => \$add_missing,
|
---|
7703 | 'c|copy' => \$copy_missing,
|
---|
7704 | 'v|verbose' => sub { setup_channel 'verb', silent => 0; },
|
---|
7705 | 'W|warnings=s' => \&parse_warnings,
|
---|
7706 | # These long options (--Werror and --Wno-error) for backward
|
---|
7707 | # compatibility. Use -Werror and -Wno-error today.
|
---|
7708 | 'Werror' => sub { parse_warnings 'W', 'error'; },
|
---|
7709 | 'Wno-error' => sub { parse_warnings 'W', 'no-error'; },
|
---|
7710 | );
|
---|
7711 | use Getopt::Long;
|
---|
7712 | Getopt::Long::config ("bundling", "pass_through");
|
---|
7713 |
|
---|
7714 | # See if --version or --help is used. We want to process these before
|
---|
7715 | # anything else because the GNU Coding Standards require us to
|
---|
7716 | # `exit 0' after processing these options, and we can't guarantee this
|
---|
7717 | # if we treat other options first. (Handling other options first
|
---|
7718 | # could produce error diagnostics, and in this condition it is
|
---|
7719 | # confusing if Automake does `exit 0'.)
|
---|
7720 | my %cli_options_1st_pass =
|
---|
7721 | (
|
---|
7722 | 'version' => \&version,
|
---|
7723 | 'help' => \&usage,
|
---|
7724 | # Recognize all other options (and their arguments) but do nothing.
|
---|
7725 | map { $_ => sub {} } (keys %cli_options)
|
---|
7726 | );
|
---|
7727 | my @ARGV_backup = @ARGV;
|
---|
7728 | Getopt::Long::GetOptions %cli_options_1st_pass
|
---|
7729 | or exit 1;
|
---|
7730 | @ARGV = @ARGV_backup;
|
---|
7731 |
|
---|
7732 | # Now *really* process the options. This time we know that --help
|
---|
7733 | # and --version are not present, but we specify them nonetheless so
|
---|
7734 | # that ambiguous abbreviation are diagnosed.
|
---|
7735 | Getopt::Long::GetOptions %cli_options, 'version' => sub {}, 'help' => sub {}
|
---|
7736 | or exit 1;
|
---|
7737 |
|
---|
7738 | if (defined $output_directory)
|
---|
7739 | {
|
---|
7740 | msg 'obsolete', "`--output-dir' is deprecated\n";
|
---|
7741 | }
|
---|
7742 | else
|
---|
7743 | {
|
---|
7744 | # In the next release we'll remove this entirely.
|
---|
7745 | $output_directory = '.';
|
---|
7746 | }
|
---|
7747 |
|
---|
7748 | return unless @ARGV;
|
---|
7749 |
|
---|
7750 | if ($ARGV[0] =~ /^-./)
|
---|
7751 | {
|
---|
7752 | my %argopts;
|
---|
7753 | for my $k (keys %cli_options)
|
---|
7754 | {
|
---|
7755 | if ($k =~ /(.*)=s$/)
|
---|
7756 | {
|
---|
7757 | map { $argopts{(length ($_) == 1)
|
---|
7758 | ? "-$_" : "--$_" } = 1; } (split (/\|/, $1));
|
---|
7759 | }
|
---|
7760 | }
|
---|
7761 | if ($ARGV[0] eq '--')
|
---|
7762 | {
|
---|
7763 | shift @ARGV;
|
---|
7764 | }
|
---|
7765 | elsif (exists $argopts{$ARGV[0]})
|
---|
7766 | {
|
---|
7767 | fatal ("option `$ARGV[0]' requires an argument\n"
|
---|
7768 | . "Try `$0 --help' for more information.");
|
---|
7769 | }
|
---|
7770 | else
|
---|
7771 | {
|
---|
7772 | fatal ("unrecognized option `$ARGV[0]'.\n"
|
---|
7773 | . "Try `$0 --help' for more information.");
|
---|
7774 | }
|
---|
7775 | }
|
---|
7776 |
|
---|
7777 | my $errspec = 0;
|
---|
7778 | foreach my $arg (@ARGV)
|
---|
7779 | {
|
---|
7780 | fatal ("empty argument\nTry `$0 --help' for more information.")
|
---|
7781 | if ($arg eq '');
|
---|
7782 |
|
---|
7783 | # Handle $local:$input syntax.
|
---|
7784 | my ($local, @rest) = split (/:/, $arg);
|
---|
7785 | @rest = ("$local.in",) unless @rest;
|
---|
7786 | my $input = locate_am @rest;
|
---|
7787 | if ($input)
|
---|
7788 | {
|
---|
7789 | push @input_files, $input;
|
---|
7790 | $output_files{$input} = join (':', ($local, @rest));
|
---|
7791 | }
|
---|
7792 | else
|
---|
7793 | {
|
---|
7794 | error "no Automake input file found for `$arg'";
|
---|
7795 | $errspec = 1;
|
---|
7796 | }
|
---|
7797 | }
|
---|
7798 | fatal "no input file found among supplied arguments"
|
---|
7799 | if $errspec && ! @input_files;
|
---|
7800 | }
|
---|
7801 |
|
---|
7802 | ################################################################
|
---|
7803 |
|
---|
7804 | # Parse the WARNINGS environment variable.
|
---|
7805 | parse_WARNINGS;
|
---|
7806 |
|
---|
7807 | # Parse command line.
|
---|
7808 | parse_arguments;
|
---|
7809 |
|
---|
7810 | $configure_ac = require_configure_ac;
|
---|
7811 |
|
---|
7812 | # Do configure.ac scan only once.
|
---|
7813 | scan_autoconf_files;
|
---|
7814 |
|
---|
7815 | if (! @input_files)
|
---|
7816 | {
|
---|
7817 | my $msg = '';
|
---|
7818 | $msg = "\nDid you forget AC_CONFIG_FILES([Makefile]) in $configure_ac?"
|
---|
7819 | if -f 'Makefile.am';
|
---|
7820 | fatal ("no `Makefile.am' found for any configure output$msg");
|
---|
7821 | }
|
---|
7822 |
|
---|
7823 | # Now do all the work on each file.
|
---|
7824 | foreach my $file (@input_files)
|
---|
7825 | {
|
---|
7826 | ($am_file = $file) =~ s/\.in$//;
|
---|
7827 | if (! -f ($am_file . '.am'))
|
---|
7828 | {
|
---|
7829 | error "`$am_file.am' does not exist";
|
---|
7830 | }
|
---|
7831 | else
|
---|
7832 | {
|
---|
7833 | # Any warning setting now local to this Makefile.am.
|
---|
7834 | dup_channel_setup;
|
---|
7835 |
|
---|
7836 | generate_makefile ($am_file . '.am', $file);
|
---|
7837 |
|
---|
7838 | # Back out any warning setting.
|
---|
7839 | drop_channel_setup;
|
---|
7840 | }
|
---|
7841 | }
|
---|
7842 |
|
---|
7843 | exit $exit_code;
|
---|
7844 |
|
---|
7845 |
|
---|
7846 | ### Setup "GNU" style for perl-mode and cperl-mode.
|
---|
7847 | ## Local Variables:
|
---|
7848 | ## perl-indent-level: 2
|
---|
7849 | ## perl-continued-statement-offset: 2
|
---|
7850 | ## perl-continued-brace-offset: 0
|
---|
7851 | ## perl-brace-offset: 0
|
---|
7852 | ## perl-brace-imaginary-offset: 0
|
---|
7853 | ## perl-label-offset: -2
|
---|
7854 | ## cperl-indent-level: 2
|
---|
7855 | ## cperl-brace-offset: 0
|
---|
7856 | ## cperl-continued-brace-offset: 0
|
---|
7857 | ## cperl-label-offset: -2
|
---|
7858 | ## cperl-extra-newline-before-brace: t
|
---|
7859 | ## cperl-merge-trailing-else: nil
|
---|
7860 | ## cperl-continued-statement-offset: 2
|
---|
7861 | ## End:
|
---|