File: | /tmp/build/automake |
Coverage: | 93.5% |
line | stmt | bran | cond | sub | pod | time | code |
---|---|---|---|---|---|---|---|
1 | #!/usr/bin/perl -w | ||||||
2 | # -*- perl -*- | ||||||
3 | # Generated from automake.in; do not edit by hand. | ||||||
4 | |||||||
5 | 1159 | 3368 | eval 'case $# in 0) exec /usr/bin/perl -S "$0";; *) exec /usr/bin/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, 2007, 2008, 2009, 2010 Free Software | ||||||
11 | # Foundation, Inc. | ||||||
12 | |||||||
13 | # This program is free software; you can redistribute it and/or modify | ||||||
14 | # it under the terms of the GNU General Public License as published by | ||||||
15 | # the Free Software Foundation; either version 2, or (at your option) | ||||||
16 | # any later version. | ||||||
17 | |||||||
18 | # This program is distributed in the hope that it will be useful, | ||||||
19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||
20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||||
21 | # GNU General Public License for more details. | ||||||
22 | |||||||
23 | # You should have received a copy of the GNU General Public License | ||||||
24 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||||||
25 | |||||||
26 | # Originally written by David Mackenzie <djm@gnu.ai.mit.edu>. | ||||||
27 | # Perl reimplementation by Tom Tromey <tromey@redhat.com>, and | ||||||
28 | # Alexandre Duret-Lutz <adl@gnu.org>. | ||||||
29 | |||||||
30 | package Language; | ||||||
31 | |||||||
32 | BEGIN | ||||||
33 | { | ||||||
34 | 1159 | 12924 | my $perllibdir = $ENV{'perllibdir'} || '/usr/local/share/automake-1.11a'; | ||||
35 | 1159 | 5052 | unshift @INC, (split ':', $perllibdir); | ||||
36 | |||||||
37 | # Override SHELL. This is required on DJGPP so that system() uses | ||||||
38 | # bash, not COMMAND.COM which doesn't quote arguments properly. | ||||||
39 | # Other systems aren't expected to use $SHELL when Automake | ||||||
40 | # runs, but it should be safe to drop the `if DJGPP' guard if | ||||||
41 | # it turns up other systems need the same thing. After all, | ||||||
42 | # if SHELL is used, ./configure's SHELL is always better than | ||||||
43 | # the user's SHELL (which may be something like tcsh). | ||||||
44 | 1159 | 5020 | $ENV{'SHELL'} = '/bin/bash' if exists $ENV{'DJDIR'}; | ||||
45 | } | ||||||
46 | |||||||
47 | 1159 1159 1159 | 16293 1239 7717 | use Automake::Struct; | ||||
48 | 1159 | 13202 | struct (# Short name of the language (c, f77...). | ||||
49 | 'name' => "\$", | ||||||
50 | # Nice name of the language (C, Fortran 77...). | ||||||
51 | 'Name' => "\$", | ||||||
52 | |||||||
53 | # List of configure variables which must be defined. | ||||||
54 | 'config_vars' => '@', | ||||||
55 | |||||||
56 | 'ansi' => "\$", | ||||||
57 | # `pure' is `1' or `'. A `pure' language is one where, if | ||||||
58 | # all the files in a directory are of that language, then we | ||||||
59 | # do not require the C compiler or any code to call it. | ||||||
60 | 'pure' => "\$", | ||||||
61 | |||||||
62 | 'autodep' => "\$", | ||||||
63 | |||||||
64 | # Name of the compiling variable (COMPILE). | ||||||
65 | 'compiler' => "\$", | ||||||
66 | # Content of the compiling variable. | ||||||
67 | 'compile' => "\$", | ||||||
68 | # Flag to require compilation without linking (-c). | ||||||
69 | 'compile_flag' => "\$", | ||||||
70 | 'extensions' => '@', | ||||||
71 | # A subroutine to compute a list of possible extensions of | ||||||
72 | # the product given the input extensions. | ||||||
73 | # (defaults to a subroutine which returns ('.$(OBJEXT)', '.lo')) | ||||||
74 | 'output_extensions' => "\$", | ||||||
75 | # A list of flag variables used in 'compile'. | ||||||
76 | # (defaults to []) | ||||||
77 | 'flags' => "@", | ||||||
78 | |||||||
79 | # Any tag to pass to libtool while compiling. | ||||||
80 | 'libtool_tag' => "\$", | ||||||
81 | |||||||
82 | # The file to use when generating rules for this language. | ||||||
83 | # The default is 'depend2'. | ||||||
84 | 'rule_file' => "\$", | ||||||
85 | |||||||
86 | # Name of the linking variable (LINK). | ||||||
87 | 'linker' => "\$", | ||||||
88 | # Content of the linking variable. | ||||||
89 | 'link' => "\$", | ||||||
90 | |||||||
91 | # Name of the compiler variable (CC). | ||||||
92 | 'ccer' => "\$", | ||||||
93 | |||||||
94 | # Name of the linker variable (LD). | ||||||
95 | 'lder' => "\$", | ||||||
96 | # Content of the linker variable ($(CC)). | ||||||
97 | 'ld' => "\$", | ||||||
98 | |||||||
99 | # Flag to specify the output file (-o). | ||||||
100 | 'output_flag' => "\$", | ||||||
101 | '_finish' => "\$", | ||||||
102 | |||||||
103 | # This is a subroutine which is called whenever we finally | ||||||
104 | # determine the context in which a source file will be | ||||||
105 | # compiled. | ||||||
106 | '_target_hook' => "\$", | ||||||
107 | |||||||
108 | # If TRUE, nodist_ sources will be compiled using specific rules | ||||||
109 | # (i.e. not inference rules). The default is FALSE. | ||||||
110 | 'nodist_specific' => "\$"); | ||||||
111 | |||||||
112 | |||||||
113 | sub finish ($) | ||||||
114 | { | ||||||
115 | 678 | 1696 | my ($self) = @_; | ||||
116 | 678 | 3322 | if (defined $self->_finish) | ||||
117 | { | ||||||
118 | 593 593 | 1187 1618 | &{$self->_finish} (@_); | ||||
119 | } | ||||||
120 | } | ||||||
121 | |||||||
122 | sub target_hook ($$$$%) | ||||||
123 | { | ||||||
124 | 1419 | 2841 | my ($self) = @_; | ||||
125 | 1419 | 5355 | if (defined $self->_target_hook) | ||||
126 | { | ||||||
127 | 90 90 | 140 218 | &{$self->_target_hook} (@_); | ||||
128 | } | ||||||
129 | } | ||||||
130 | |||||||
131 | package Automake; | ||||||
132 | |||||||
133 | 1159 1159 1159 | 4740 1103 2858 | use strict; | ||||
134 | 1159 1159 1159 | 8030 1200 6975 | use Automake::Config; | ||||
135 | BEGIN | ||||||
136 | { | ||||||
137 | 1159 | 5884 | if ($perl_threads) | ||||
138 | { | ||||||
139 | 1159 | 7663 | require threads; | ||||
140 | 1159 | 3530 | import threads; | ||||
141 | 1159 | 8573 | require Thread::Queue; | ||||
142 | 1159 | 12911 | import Thread::Queue; | ||||
143 | } | ||||||
144 | } | ||||||
145 | 1159 1159 1159 | 8179 1284 6760 | use Automake::General; | ||||
146 | 1159 1159 1159 | 9019 2016 9991 | use Automake::XFile; | ||||
147 | 1159 1159 1159 | 5128 1350 6604 | use Automake::Channels; | ||||
148 | 1159 1159 1159 | 4875 1512 6592 | use Automake::ChannelDefs; | ||||
149 | 1159 1159 1159 | 10785 1486 7075 | use Automake::Configure_ac; | ||||
150 | 1159 1159 1159 | 4624 1290 3215 | use Automake::FileUtils; | ||||
151 | 1159 1159 1159 | 2784 1608 10310 | use Automake::Location; | ||||
152 | 1159 1159 1159 | 7823 1446 8576 | use Automake::Condition qw/TRUE FALSE/; | ||||
153 | 1159 1159 1159 | 63015 1483 8759 | use Automake::DisjConditions; | ||||
154 | 1159 1159 1159 | 8540 1372 7147 | use Automake::Options; | ||||
155 | 1159 1159 1159 | 4597 1148 3296 | use Automake::Version; | ||||
156 | 1159 1159 1159 | 8281 1795 9196 | use Automake::Variable; | ||||
157 | 1159 1159 1159 | 4864 1340 3510 | use Automake::VarDef; | ||||
158 | 1159 1159 1159 | 9086 1585 7804 | use Automake::Rule; | ||||
159 | 1159 1159 1159 | 4576 1221 3120 | use Automake::RuleDef; | ||||
160 | 1159 1159 1159 | 4434 1204 3367 | use Automake::Wrap 'makefile_wrap'; | ||||
161 | 1159 1159 1159 | 4714 1225 8566 | use File::Basename; | ||||
162 | 1159 1159 1159 | 4746 1339 8601 | use File::Spec; | ||||
163 | 1159 1159 1159 | 4021 1214 3190 | use Carp; | ||||
164 | |||||||
165 | ## ----------- ## | ||||||
166 | ## Constants. ## | ||||||
167 | ## ----------- ## | ||||||
168 | |||||||
169 | # Some regular expressions. One reason to put them here is that it | ||||||
170 | # makes indentation work better in Emacs. | ||||||
171 | |||||||
172 | # Writing singled-quoted-$-terminated regexes is a pain because | ||||||
173 | # perl-mode thinks of $' as the ${'} variable (instead of a $ followed | ||||||
174 | # by a closing quote. Letting perl-mode think the quote is not closed | ||||||
175 | # leads to all sort of misindentations. On the other hand, defining | ||||||
176 | # regexes as double-quoted strings is far less readable. So usually | ||||||
177 | # we will write: | ||||||
178 | # | ||||||
179 | # $REGEX = '^regex_value' . "\$"; | ||||||
180 | |||||||
181 | 1159 | 2973 | my $IGNORE_PATTERN = '^\s*##([^#\n].*)?\n'; | ||||
182 | 1159 | 2222 | my $WHITE_PATTERN = '^\s*' . "\$"; | ||||
183 | 1159 | 2139 | my $COMMENT_PATTERN = '^#'; | ||||
184 | 1159 | 1865 | my $TARGET_PATTERN='[$a-zA-Z0-9_.@%][-.a-zA-Z0-9_(){}/$+@%]*'; | ||||
185 | # A rule has three parts: a list of targets, a list of dependencies, | ||||||
186 | # and optionally actions. | ||||||
187 | 1159 | 4447 | my $RULE_PATTERN = | ||||
188 | "^($TARGET_PATTERN(?:(?:\\\\\n|\\s)+$TARGET_PATTERN)*) *:([^=].*|)\$"; | ||||||
189 | |||||||
190 | # Only recognize leading spaces, not leading tabs. If we recognize | ||||||
191 | # leading tabs here then we need to make the reader smarter, because | ||||||
192 | # otherwise it will think rules like `foo=bar; \' are errors. | ||||||
193 | 1159 | 1935 | my $ASSIGNMENT_PATTERN = '^ *([^ \t=:+]*)\s*([:+]?)=\s*(.*)' . "\$"; | ||||
194 | # This pattern recognizes a Gnits version id and sets $1 if the | ||||||
195 | # release is an alpha release. We also allow a suffix which can be | ||||||
196 | # used to extend the version number with a "fork" identifier. | ||||||
197 | 1159 | 1835 | my $GNITS_VERSION_PATTERN = '\d+\.\d+([a-z]|\.\d+)?(-[A-Za-z0-9]+)?'; | ||||
198 | |||||||
199 | 1159 | 1804 | my $IF_PATTERN = '^if\s+(!?)\s*([A-Za-z][A-Za-z0-9_]*)\s*(?:#.*)?' . "\$"; | ||||
200 | 1159 | 1731 | my $ELSE_PATTERN = | ||||
201 | '^else(?:\s+(!?)\s*([A-Za-z][A-Za-z0-9_]*))?\s*(?:#.*)?' . "\$"; | ||||||
202 | 1159 | 1754 | my $ENDIF_PATTERN = | ||||
203 | '^endif(?:\s+(!?)\s*([A-Za-z][A-Za-z0-9_]*))?\s*(?:#.*)?' . "\$"; | ||||||
204 | 1159 | 1852 | my $PATH_PATTERN = '(\w|[+/.-])+'; | ||||
205 | # This will pass through anything not of the prescribed form. | ||||||
206 | 1159 | 4975 | my $INCLUDE_PATTERN = ('^include\s+' | ||||
207 | . '((\$\(top_srcdir\)/' . $PATH_PATTERN . ')' | ||||||
208 | . '|(\$\(srcdir\)/' . $PATH_PATTERN . ')' | ||||||
209 | . '|([^/\$]' . $PATH_PATTERN . '))\s*(#.*)?' . "\$"); | ||||||
210 | |||||||
211 | # Match `-d' as a command-line argument in a string. | ||||||
212 | 1159 | 1725 | my $DASH_D_PATTERN = "(^|\\s)-d(\\s|\$)"; | ||||
213 | # Directories installed during 'install-exec' phase. | ||||||
214 | 1159 | 1919 | my $EXEC_DIR_PATTERN = | ||||
215 | '^(?:bin|sbin|libexec|sysconf|localstate|lib|pkglib|.*exec.*)' . "\$"; | ||||||
216 | |||||||
217 | # Values for AC_CANONICAL_* | ||||||
218 | 1159 1159 1159 | 4742 1276 3639 | use constant AC_CANONICAL_BUILD => 1; | ||||
219 | 1159 1159 1159 | 4538 1269 3075 | use constant AC_CANONICAL_HOST => 2; | ||||
220 | 1159 1159 1159 | 4678 1226 2965 | use constant AC_CANONICAL_TARGET => 3; | ||||
221 | |||||||
222 | # Values indicating when something should be cleaned. | ||||||
223 | 1159 1159 1159 | 4430 1236 2821 | use constant MOSTLY_CLEAN => 0; | ||||
224 | 1159 1159 1159 | 4309 1387 3143 | use constant CLEAN => 1; | ||||
225 | 1159 1159 1159 | 4448 1298 2915 | use constant DIST_CLEAN => 2; | ||||
226 | 1159 1159 1159 | 5213 1847 3080 | use constant MAINTAINER_CLEAN => 3; | ||||
227 | |||||||
228 | # Libtool files. | ||||||
229 | 1159 | 4161 | my @libtool_files = qw(ltmain.sh config.guess config.sub); | ||||
230 | # ltconfig appears here for compatibility with old versions of libtool. | ||||||
231 | 1159 | 3023 | my @libtool_sometimes = qw(ltconfig ltcf-c.sh ltcf-cxx.sh ltcf-gcj.sh); | ||||
232 | |||||||
233 | # Commonly found files we look for and automatically include in | ||||||
234 | # DISTFILES. | ||||||
235 | 1159 | 10658 | my @common_files = | ||||
236 | (qw(ABOUT-GNU ABOUT-NLS AUTHORS BACKLOG COPYING COPYING.DOC COPYING.LIB | ||||||
237 | COPYING.LESSER ChangeLog INSTALL NEWS README THANKS TODO | ||||||
238 | ansi2knr.1 ansi2knr.c ar-lib compile config.guess config.rpath | ||||||
239 | config.sub depcomp elisp-comp install-sh libversion.in mdate-sh | ||||||
240 | missing mkinstalldirs py-compile texinfo.tex ylwrap), | ||||||
241 | @libtool_files, @libtool_sometimes); | ||||||
242 | |||||||
243 | # Commonly used files we auto-include, but only sometimes. This list | ||||||
244 | # is used for the --help output only. | ||||||
245 | 1159 | 3915 | my @common_sometimes = | ||||
246 | qw(aclocal.m4 acconfig.h config.h.top config.h.bot configure | ||||||
247 | configure.ac configure.in stamp-vti); | ||||||
248 | |||||||
249 | # Standard directories from the GNU Coding Standards, and additional | ||||||
250 | # pkg* directories from Automake. Stored in a hash for fast member check. | ||||||
251 | 37088 | 67662 | my %standard_prefix = | ||||
252 | 1159 | 5299 | map { $_ => 1 } (qw(bin data dataroot dvi exec html include info | ||||
253 | lib libexec lisp localstate man man1 man2 man3 | ||||||
254 | man4 man5 man6 man7 man8 man9 oldinclude pdf | ||||||
255 | pkgdatadir pkgincludedir pkglibdir pkglibexecdir | ||||||
256 | ps sbin sharedstate sysconf)); | ||||||
257 | |||||||
258 | # Copyright on generated Makefile.ins. | ||||||
259 | 1159 | 5054 | my $gen_copyright = "\ | ||||
260 | # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, | ||||||
261 | # 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software | ||||||
262 | # Foundation, Inc. | ||||||
263 | # This Makefile.in is free software; the Free Software Foundation | ||||||
264 | # gives unlimited permission to copy and/or distribute it, | ||||||
265 | # with or without modifications, as long as this notice is preserved. | ||||||
266 | |||||||
267 | # This program is distributed in the hope that it will be useful, | ||||||
268 | # but WITHOUT ANY WARRANTY, to the extent permitted by law; without | ||||||
269 | # even the implied warranty of MERCHANTABILITY or FITNESS FOR A | ||||||
270 | # PARTICULAR PURPOSE. | ||||||
271 | "; | ||||||
272 | |||||||
273 | # These constants are returned by the lang_*_rewrite functions. | ||||||
274 | # LANG_SUBDIR means that the resulting object file should be in a | ||||||
275 | # subdir if the source file is. In this case the file name cannot | ||||||
276 | # have `..' components. | ||||||
277 | 1159 1159 1159 | 4739 1326 3010 | use constant LANG_IGNORE => 0; | ||||
278 | 1159 1159 1159 | 4558 1248 2971 | use constant LANG_PROCESS => 1; | ||||
279 | 1159 1159 1159 | 5239 4816 3202 | use constant LANG_SUBDIR => 2; | ||||
280 | |||||||
281 | # These are used when keeping track of whether an object can be built | ||||||
282 | # by two different paths. | ||||||
283 | 1159 1159 1159 | 4302 1204 2937 | use constant COMPILE_LIBTOOL => 1; | ||||
284 | 1159 1159 1159 | 4266 1582 3077 | use constant COMPILE_ORDINARY => 2; | ||||
285 | |||||||
286 | # We can't always associate a location to a variable or a rule, | ||||||
287 | # when it's defined by Automake. We use INTERNAL in this case. | ||||||
288 | 1159 1159 1159 | 4481 1387 4795 | use constant INTERNAL => new Automake::Location; | ||||
289 | |||||||
290 | # Serialization keys for message queues. | ||||||
291 | 1159 1159 1159 | 4780 1314 2983 | use constant QUEUE_MESSAGE => "msg"; | ||||
292 | 1159 1159 1159 | 4303 1246 2821 | use constant QUEUE_CONF_FILE => "conf file"; | ||||
293 | 1159 1159 1159 | 4260 1248 2839 | use constant QUEUE_LOCATION => "location"; | ||||
294 | 1159 1159 1159 | 4338 1235 2883 | use constant QUEUE_STRING => "string"; | ||||
295 | |||||||
296 | |||||||
297 | ## ---------------------------------- ## | ||||||
298 | ## Variables related to the options. ## | ||||||
299 | ## ---------------------------------- ## | ||||||
300 | |||||||
301 | # TRUE if we should always generate Makefile.in. | ||||||
302 | 1159 | 2263 | my $force_generation = 1; | ||||
303 | |||||||
304 | # From the Perl manual. | ||||||
305 | 1159 | 25068 | my $symlink_exists = (eval 'symlink ("", "");', $@ eq ''); | ||||
306 | |||||||
307 | # TRUE if missing standard files should be installed. | ||||||
308 | 1159 | 2569 | my $add_missing = 0; | ||||
309 | |||||||
310 | # TRUE if we should copy missing files; otherwise symlink if possible. | ||||||
311 | 1159 | 1919 | my $copy_missing = 0; | ||||
312 | |||||||
313 | # TRUE if we should always update files that we know about. | ||||||
314 | 1159 | 1574 | my $force_missing = 0; | ||||
315 | |||||||
316 | |||||||
317 | ## ---------------------------------------- ## | ||||||
318 | ## Variables filled during files scanning. ## | ||||||
319 | ## ---------------------------------------- ## | ||||||
320 | |||||||
321 | # Name of the configure.ac file. | ||||||
322 | 1159 | 1456 | my $configure_ac; | ||||
323 | |||||||
324 | # Files found by scanning configure.ac for LIBOBJS. | ||||||
325 | 1159 | 2193 | my %libsources = (); | ||||
326 | |||||||
327 | # Names used in AC_CONFIG_HEADER call. | ||||||
328 | 1159 | 2198 | my @config_headers = (); | ||||
329 | |||||||
330 | # Names used in AC_CONFIG_LINKS call. | ||||||
331 | 1159 | 1716 | my @config_links = (); | ||||
332 | |||||||
333 | # Directory where output files go. Actually, output files are | ||||||
334 | # relative to this directory. | ||||||
335 | 1159 | 1414 | my $output_directory; | ||||
336 | |||||||
337 | # List of Makefile.am's to process, and their corresponding outputs. | ||||||
338 | 1159 | 1732 | my @input_files = (); | ||||
339 | 1159 | 1877 | my %output_files = (); | ||||
340 | |||||||
341 | # Complete list of Makefile.am's that exist. | ||||||
342 | 1159 | 1661 | my @configure_input_files = (); | ||||
343 | |||||||
344 | # List of files in AC_CONFIG_FILES/AC_OUTPUT without Makefile.am's, | ||||||
345 | # and their outputs. | ||||||
346 | 1159 | 1621 | my @other_input_files = (); | ||||
347 | # Where each AC_CONFIG_FILES/AC_OUTPUT/AC_CONFIG_LINK/AC_CONFIG_HEADER appears. | ||||||
348 | # The keys are the files created by these macros. | ||||||
349 | 1159 | 1842 | my %ac_config_files_location = (); | ||||
350 | # The condition under which AC_CONFIG_FOOS appears. | ||||||
351 | 1159 | 1905 | my %ac_config_files_condition = (); | ||||
352 | |||||||
353 | # List of include fragments, with location, patterns, and condition. | ||||||
354 | 1159 | 1798 | my @early_fragments = (); | ||||
355 | 1159 | 1657 | my @late_fragments = (); | ||||
356 | |||||||
357 | # Directory to search for configure-required files. This | ||||||
358 | # will be computed by &locate_aux_dir and can be set using | ||||||
359 | # AC_CONFIG_AUX_DIR in configure.ac. | ||||||
360 | # $CONFIG_AUX_DIR is the `raw' directory, valid only in the source-tree. | ||||||
361 | 1159 | 1786 | my $config_aux_dir = ''; | ||||
362 | 1159 | 1690 | my $config_aux_dir_set_in_configure_ac = 0; | ||||
363 | # $AM_CONFIG_AUX_DIR is prefixed with $(top_srcdir), so it can be used | ||||||
364 | # in Makefiles. | ||||||
365 | 1159 | 1820 | my $am_config_aux_dir = ''; | ||||
366 | |||||||
367 | # Directory to search for AC_LIBSOURCE files, as set by AC_CONFIG_LIBOBJ_DIR | ||||||
368 | # in configure.ac. | ||||||
369 | 1159 | 1709 | my $config_libobj_dir = ''; | ||||
370 | |||||||
371 | # Whether AM_GNU_GETTEXT has been seen in configure.ac. | ||||||
372 | 1159 | 1682 | my $seen_gettext = 0; | ||||
373 | # Whether AM_GNU_GETTEXT([external]) is used. | ||||||
374 | 1159 | 1694 | my $seen_gettext_external = 0; | ||||
375 | # Where AM_GNU_GETTEXT appears. | ||||||
376 | 1159 | 1446 | my $ac_gettext_location; | ||||
377 | # Whether AM_GNU_GETTEXT_INTL_SUBDIR has been seen. | ||||||
378 | 1159 | 2136 | my $seen_gettext_intl = 0; | ||||
379 | |||||||
380 | # Lists of tags supported by Libtool. | ||||||
381 | 1159 | 2421 | my %libtool_tags = (); | ||||
382 | # 1 if Libtool uses LT_SUPPORTED_TAG. If it does, then it also | ||||||
383 | # uses AC_REQUIRE_AUX_FILE. | ||||||
384 | 1159 | 1541 | my $libtool_new_api = 0; | ||||
385 | |||||||
386 | # Most important AC_CANONICAL_* macro seen so far. | ||||||
387 | 1159 | 1493 | my $seen_canonical = 0; | ||||
388 | # Location of that macro. | ||||||
389 | 1159 | 1312 | my $canonical_location; | ||||
390 | |||||||
391 | # Where AM_MAINTAINER_MODE appears. | ||||||
392 | 1159 | 1512 | my $seen_maint_mode; | ||||
393 | |||||||
394 | # Actual version we've seen. | ||||||
395 | 1159 | 1831 | my $package_version = ''; | ||||
396 | |||||||
397 | # Where version is defined. | ||||||
398 | 1159 | 1314 | my $package_version_location; | ||||
399 | |||||||
400 | # TRUE if we've seen AM_ENABLE_MULTILIB. | ||||||
401 | 1159 | 1684 | my $seen_multilib = 0; | ||||
402 | |||||||
403 | # TRUE if we've seen AM_PROG_CC_C_O | ||||||
404 | 1159 | 1803 | my $seen_cc_c_o = 0; | ||||
405 | |||||||
406 | # Location of AC_REQUIRE_AUX_FILE calls, indexed by their argument. | ||||||
407 | 1159 | 1765 | my %required_aux_file = (); | ||||
408 | |||||||
409 | # Where AM_INIT_AUTOMAKE is called; | ||||||
410 | 1159 | 1547 | my $seen_init_automake = 0; | ||||
411 | |||||||
412 | # TRUE if we've seen AM_AUTOMAKE_VERSION. | ||||||
413 | 1159 | 1589 | my $seen_automake_version = 0; | ||||
414 | |||||||
415 | # Hash table of discovered configure substitutions. Keys are names, | ||||||
416 | # values are `FILE:LINE' strings which are used by error message | ||||||
417 | # generation. | ||||||
418 | 1159 | 1743 | my %configure_vars = (); | ||||
419 | |||||||
420 | # Ignored configure substitutions (i.e., variables not to be output in | ||||||
421 | # Makefile.in) | ||||||
422 | 1159 | 1652 | my %ignored_configure_vars = (); | ||||
423 | |||||||
424 | # Files included by $configure_ac. | ||||||
425 | 1159 | 1704 | my @configure_deps = (); | ||||
426 | |||||||
427 | # Greatest timestamp of configure's dependencies. | ||||||
428 | 1159 | 1557 | my $configure_deps_greatest_timestamp = 0; | ||||
429 | |||||||
430 | # Hash table of AM_CONDITIONAL variables seen in configure. | ||||||
431 | 1159 | 1756 | my %configure_cond = (); | ||||
432 | |||||||
433 | # This maps extensions onto language names. | ||||||
434 | 1159 | 1735 | my %extension_map = (); | ||||
435 | |||||||
436 | # List of the DIST_COMMON files we discovered while reading | ||||||
437 | # configure.in | ||||||
438 | 1159 | 1869 | my $configure_dist_common = ''; | ||||
439 | |||||||
440 | # This maps languages names onto objects. | ||||||
441 | 1159 | 1755 | my %languages = (); | ||||
442 | # Maps each linker variable onto a language object. | ||||||
443 | 1159 | 1757 | my %link_languages = (); | ||||
444 | |||||||
445 | # maps extensions to needed source flags. | ||||||
446 | 1159 | 1827 | my %sourceflags = (); | ||||
447 | |||||||
448 | # List of targets we must always output. | ||||||
449 | # FIXME: Complete, and remove falsely required targets. | ||||||
450 | 1159 | 16617 | my %required_targets = | ||||
451 | ( | ||||||
452 | 'all' => 1, | ||||||
453 | 'dvi' => 1, | ||||||
454 | 'pdf' => 1, | ||||||
455 | 'ps' => 1, | ||||||
456 | 'info' => 1, | ||||||
457 | 'install-info' => 1, | ||||||
458 | 'install' => 1, | ||||||
459 | 'install-data' => 1, | ||||||
460 | 'install-exec' => 1, | ||||||
461 | 'uninstall' => 1, | ||||||
462 | |||||||
463 | # FIXME: Not required, temporary hacks. | ||||||
464 | # Well, actually they are sort of required: the -recursive | ||||||
465 | # targets will run them anyway... | ||||||
466 | 'html-am' => 1, | ||||||
467 | 'dvi-am' => 1, | ||||||
468 | 'pdf-am' => 1, | ||||||
469 | 'ps-am' => 1, | ||||||
470 | 'info-am' => 1, | ||||||
471 | 'install-data-am' => 1, | ||||||
472 | 'install-exec-am' => 1, | ||||||
473 | 'install-html-am' => 1, | ||||||
474 | 'install-dvi-am' => 1, | ||||||
475 | 'install-pdf-am' => 1, | ||||||
476 | 'install-ps-am' => 1, | ||||||
477 | 'install-info-am' => 1, | ||||||
478 | 'installcheck-am' => 1, | ||||||
479 | 'uninstall-am' => 1, | ||||||
480 | |||||||
481 | 'install-man' => 1, | ||||||
482 | ); | ||||||
483 | |||||||
484 | # Set to 1 if this run will create the Makefile.in that distributes | ||||||
485 | # the files in config_aux_dir. | ||||||
486 | 1159 | 1628 | my $automake_will_process_aux_dir = 0; | ||||
487 | |||||||
488 | # The name of the Makefile currently being processed. | ||||||
489 | 1159 | 1706 | my $am_file = 'BUG'; | ||||
490 | |||||||
491 | |||||||
492 | ################################################################ | ||||||
493 | |||||||
494 | ## ------------------------------------------ ## | ||||||
495 | ## Variables reset by &initialize_per_input. ## | ||||||
496 | ## ------------------------------------------ ## | ||||||
497 | |||||||
498 | # Basename and relative dir of the input file. | ||||||
499 | 1159 | 1395 | my $am_file_name; | ||||
500 | 1159 | 1265 | my $am_relative_dir; | ||||
501 | |||||||
502 | # Same but wrt Makefile.in. | ||||||
503 | 1159 | 1287 | my $in_file_name; | ||||
504 | 1159 | 1271 | my $relative_dir; | ||||
505 | |||||||
506 | # Relative path to the top directory. | ||||||
507 | 1159 | 1303 | my $topsrcdir; | ||||
508 | |||||||
509 | # Greatest timestamp of the output's dependencies (excluding | ||||||
510 | # configure's dependencies). | ||||||
511 | 1159 | 1237 | my $output_deps_greatest_timestamp; | ||||
512 | |||||||
513 | # These variables are used when generating each Makefile.in. | ||||||
514 | # They hold the Makefile.in until it is ready to be printed. | ||||||
515 | 1159 | 1242 | my $output_vars; | ||||
516 | 1159 | 1248 | my $output_all; | ||||
517 | 1159 | 1249 | my $output_header; | ||||
518 | 1159 | 1421 | my $output_rules; | ||||
519 | 1159 | 1273 | my $output_trailer; | ||||
520 | |||||||
521 | # This is the conditional stack, updated on if/else/endif, and | ||||||
522 | # used to build Condition objects. | ||||||
523 | 1159 | 1296 | my @cond_stack; | ||||
524 | |||||||
525 | # This holds the set of included files. | ||||||
526 | 1159 | 1294 | my @include_stack; | ||||
527 | |||||||
528 | # List of dependencies for the obvious targets. | ||||||
529 | 1159 | 1343 | my @all; | ||||
530 | 1159 | 1332 | my @check; | ||||
531 | 1159 | 1425 | my @check_tests; | ||||
532 | |||||||
533 | # Keys in this hash table are files to delete. The associated | ||||||
534 | # value tells when this should happen (MOSTLY_CLEAN, DIST_CLEAN, etc.) | ||||||
535 | 1159 | 1673 | my %clean_files; | ||||
536 | |||||||
537 | # Keys in this hash table are object files or other files in | ||||||
538 | # subdirectories which need to be removed. This only holds files | ||||||
539 | # which are created by compilations. The value in the hash indicates | ||||||
540 | # when the file should be removed. | ||||||
541 | 1159 | 1475 | my %compile_clean_files; | ||||
542 | |||||||
543 | # Keys in this hash table are directories where we expect to build a | ||||||
544 | # libtool object. We use this information to decide what directories | ||||||
545 | # to delete. | ||||||
546 | 1159 | 1558 | my %libtool_clean_directories; | ||||
547 | |||||||
548 | # Value of `$(SOURCES)', used by tags.am. | ||||||
549 | 1159 | 2096 | my @sources; | ||||
550 | # Sources which go in the distribution. | ||||||
551 | 1159 | 1978 | my @dist_sources; | ||||
552 | |||||||
553 | # This hash maps object file names onto their corresponding source | ||||||
554 | # file names. This is used to ensure that each object is created | ||||||
555 | # by a single source file. | ||||||
556 | 1159 | 1349 | my %object_map; | ||||
557 | |||||||
558 | # This hash maps object file names onto an integer value representing | ||||||
559 | # whether this object has been built via ordinary compilation or | ||||||
560 | # libtool compilation (the COMPILE_* constants). | ||||||
561 | 1159 | 1250 | my %object_compilation_map; | ||||
562 | |||||||
563 | |||||||
564 | # This keeps track of the directories for which we've already | ||||||
565 | # created dirstamp code. Keys are directories, values are stamp files. | ||||||
566 | # Several keys can share the same stamp files if they are equivalent | ||||||
567 | # (as are `.//foo' and `foo'). | ||||||
568 | 1159 | 1290 | my %directory_map; | ||||
569 | |||||||
570 | # All .P files. | ||||||
571 | 1159 | 1239 | my %dep_files; | ||||
572 | |||||||
573 | # This is a list of all targets to run during "make dist". | ||||||
574 | 1159 | 1229 | my @dist_targets; | ||||
575 | |||||||
576 | # Keep track of all programs declared in this Makefile, without | ||||||
577 | # $(EXEEXT). @substitutions@ are not listed. | ||||||
578 | 1159 | 1267 | my %known_programs; | ||||
579 | 1159 | 1267 | my %known_libraries; | ||||
580 | |||||||
581 | # Keys in this hash are the basenames of files which must depend on | ||||||
582 | # ansi2knr. Values are either the empty string, or the directory in | ||||||
583 | # which the ANSI source file appears; the directory must have a | ||||||
584 | # trailing `/'. | ||||||
585 | 1159 | 1320 | my %de_ansi_files; | ||||
586 | |||||||
587 | # This keeps track of which extensions we've seen (that we care | ||||||
588 | # about). | ||||||
589 | 1159 | 1291 | my %extension_seen; | ||||
590 | |||||||
591 | # This is random scratch space for the language finish functions. | ||||||
592 | # Don't randomly overwrite it; examine other uses of keys first. | ||||||
593 | 1159 | 1218 | my %language_scratch; | ||||
594 | |||||||
595 | # We keep track of which objects need special (per-executable) | ||||||
596 | # handling on a per-language basis. | ||||||
597 | 1159 | 1215 | my %lang_specific_files; | ||||
598 | |||||||
599 | # This is set when `handle_dist' has finished. Once this happens, | ||||||
600 | # we should no longer push on dist_common. | ||||||
601 | 1159 | 1231 | my $handle_dist_run; | ||||
602 | |||||||
603 | # Used to store a set of linkers needed to generate the sources currently | ||||||
604 | # under consideration. | ||||||
605 | 1159 | 1285 | my %linkers_used; | ||||
606 | |||||||
607 | # True if we need `LINK' defined. This is a hack. | ||||||
608 | 1159 | 1352 | my $need_link; | ||||
609 | |||||||
610 | # Was get_object_extension run? | ||||||
611 | # FIXME: This is a hack. a better switch should be found. | ||||||
612 | 1159 | 1380 | my $get_object_extension_was_run; | ||||
613 | |||||||
614 | # Record each file processed by make_paragraphs. | ||||||
615 | 1159 | 1287 | my %transformed_files; | ||||
616 | |||||||
617 | |||||||
618 | ################################################################ | ||||||
619 | |||||||
620 | ## ---------------------------------------------- ## | ||||||
621 | ## Variables not reset by &initialize_per_input. ## | ||||||
622 | ## ---------------------------------------------- ## | ||||||
623 | |||||||
624 | # Cache each file processed by make_paragraphs. | ||||||
625 | # (This is different from %transformed_files because | ||||||
626 | # %transformed_files is reset for each file while %am_file_cache | ||||||
627 | # it global to the run.) | ||||||
628 | 1159 | 1445 | my %am_file_cache; | ||||
629 | |||||||
630 | ################################################################ | ||||||
631 | |||||||
632 | # var_SUFFIXES_trigger ($TYPE, $VALUE) | ||||||
633 | # ------------------------------------ | ||||||
634 | # This is called by Automake::Variable::define() when SUFFIXES | ||||||
635 | # is defined ($TYPE eq '') or appended ($TYPE eq '+'). | ||||||
636 | # The work here needs to be performed as a side-effect of the | ||||||
637 | # macro_define() call because SUFFIXES definitions impact | ||||||
638 | # on $KNOWN_EXTENSIONS_PATTERN which is used used when parsing | ||||||
639 | # the input am file. | ||||||
640 | sub var_SUFFIXES_trigger ($$) | ||||||
641 | { | ||||||
642 | 11 | 31 | my ($type, $value) = @_; | ||||
643 | 11 | 88 | accept_extensions (split (' ', $value)); | ||||
644 | } | ||||||
645 | 1159 | 6342 | Automake::Variable::hook ('SUFFIXES', \&var_SUFFIXES_trigger); | ||||
646 | |||||||
647 | ################################################################ | ||||||
648 | |||||||
649 | ## --------------------------------- ## | ||||||
650 | ## Forward subroutine declarations. ## | ||||||
651 | ## --------------------------------- ## | ||||||
652 | sub register_language (%); | ||||||
653 | sub file_contents_internal ($$$%); | ||||||
654 | sub define_files_variable ($\@$$); | ||||||
655 | |||||||
656 | |||||||
657 | # &initialize_per_input () | ||||||
658 | # ------------------------ | ||||||
659 | # (Re)-Initialize per-Makefile.am variables. | ||||||
660 | sub initialize_per_input () | ||||||
661 | { | ||||||
662 | 1322 | 5348 | reset_local_duplicates (); | ||||
663 | |||||||
664 | 1322 | 2368 | $am_file_name = undef; | ||||
665 | 1322 | 1895 | $am_relative_dir = undef; | ||||
666 | |||||||
667 | 1322 | 1937 | $in_file_name = undef; | ||||
668 | 1322 | 1904 | $relative_dir = undef; | ||||
669 | 1322 | 2354 | $topsrcdir = undef; | ||||
670 | |||||||
671 | 1322 | 2076 | $output_deps_greatest_timestamp = 0; | ||||
672 | |||||||
673 | 1322 | 2433 | $output_vars = ''; | ||||
674 | 1322 | 2060 | $output_all = ''; | ||||
675 | 1322 | 1985 | $output_header = ''; | ||||
676 | 1322 | 1975 | $output_rules = ''; | ||||
677 | 1322 | 2028 | $output_trailer = ''; | ||||
678 | |||||||
679 | 1322 | 8465 | Automake::Options::reset; | ||||
680 | 1322 | 4562 | Automake::Variable::reset; | ||||
681 | 1322 | 7698 | Automake::Rule::reset; | ||||
682 | |||||||
683 | 1322 | 2821 | @cond_stack = (); | ||||
684 | |||||||
685 | 1322 | 2138 | @include_stack = (); | ||||
686 | |||||||
687 | 1322 | 2123 | @all = (); | ||||
688 | 1322 | 2271 | @check = (); | ||||
689 | 1322 | 2095 | @check_tests = (); | ||||
690 | |||||||
691 | 1322 | 3098 | %clean_files = (); | ||||
692 | 1322 | 2426 | %compile_clean_files = (); | ||||
693 | |||||||
694 | # We always include `.'. This isn't strictly correct. | ||||||
695 | 1322 | 3540 | %libtool_clean_directories = ('.' => 1); | ||||
696 | |||||||
697 | 1322 | 2315 | @sources = (); | ||||
698 | 1322 | 2233 | @dist_sources = (); | ||||
699 | |||||||
700 | 1322 | 2171 | %object_map = (); | ||||
701 | 1322 | 2213 | %object_compilation_map = (); | ||||
702 | |||||||
703 | 1322 | 1934 | %directory_map = (); | ||||
704 | |||||||
705 | 1322 | 2006 | %dep_files = (); | ||||
706 | |||||||
707 | 1322 | 2084 | @dist_targets = (); | ||||
708 | |||||||
709 | 1322 | 2323 | %known_programs = (); | ||||
710 | 1322 | 2011 | %known_libraries= (); | ||||
711 | |||||||
712 | 1322 | 2019 | %de_ansi_files = (); | ||||
713 | |||||||
714 | 1322 | 1990 | %extension_seen = (); | ||||
715 | |||||||
716 | 1322 | 1913 | %language_scratch = (); | ||||
717 | |||||||
718 | 1322 | 2060 | %lang_specific_files = (); | ||||
719 | |||||||
720 | 1322 | 2006 | $handle_dist_run = 0; | ||||
721 | |||||||
722 | 1322 | 1850 | $need_link = 0; | ||||
723 | |||||||
724 | 1322 | 1916 | $get_object_extension_was_run = 0; | ||||
725 | |||||||
726 | 1322 | 2945 | %transformed_files = (); | ||||
727 | } | ||||||
728 | |||||||
729 | |||||||
730 | ################################################################ | ||||||
731 | |||||||
732 | # Initialize our list of languages that are internally supported. | ||||||
733 | |||||||
734 | # C. | ||||||
735 | 1159 | 14973 | register_language ('name' => 'c', | ||||
736 | 'Name' => 'C', | ||||||
737 | 'config_vars' => ['CC'], | ||||||
738 | 'ansi' => 1, | ||||||
739 | 'autodep' => '', | ||||||
740 | 'flags' => ['CFLAGS', 'CPPFLAGS'], | ||||||
741 | 'ccer' => 'CC', | ||||||
742 | 'compiler' => 'COMPILE', | ||||||
743 | 'compile' => '$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)', | ||||||
744 | 'lder' => 'CCLD', | ||||||
745 | 'ld' => '$(CC)', | ||||||
746 | 'linker' => 'LINK', | ||||||
747 | 'link' => '$(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@', | ||||||
748 | 'compile_flag' => '-c', | ||||||
749 | 'libtool_tag' => 'CC', | ||||||
750 | 'extensions' => ['.c'], | ||||||
751 | '_finish' => \&lang_c_finish); | ||||||
752 | |||||||
753 | # C++. | ||||||
754 | 1159 | 9551 | register_language ('name' => 'cxx', | ||||
755 | 'Name' => 'C++', | ||||||
756 | 'config_vars' => ['CXX'], | ||||||
757 | 'linker' => 'CXXLINK', | ||||||
758 | 'link' => '$(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@', | ||||||
759 | 'autodep' => 'CXX', | ||||||
760 | 'flags' => ['CXXFLAGS', 'CPPFLAGS'], | ||||||
761 | 'compile' => '$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)', | ||||||
762 | 'ccer' => 'CXX', | ||||||
763 | 'compiler' => 'CXXCOMPILE', | ||||||
764 | 'compile_flag' => '-c', | ||||||
765 | 'output_flag' => '-o', | ||||||
766 | 'libtool_tag' => 'CXX', | ||||||
767 | 'lder' => 'CXXLD', | ||||||
768 | 'ld' => '$(CXX)', | ||||||
769 | 'pure' => 1, | ||||||
770 | 'extensions' => ['.c++', '.cc', '.cpp', '.cxx', '.C']); | ||||||
771 | |||||||
772 | # Objective C. | ||||||
773 | 1159 | 8360 | register_language ('name' => 'objc', | ||||
774 | 'Name' => 'Objective C', | ||||||
775 | 'config_vars' => ['OBJC'], | ||||||
776 | 'linker' => 'OBJCLINK', | ||||||
777 | 'link' => '$(OBJCLD) $(AM_OBJCFLAGS) $(OBJCFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@', | ||||||
778 | 'autodep' => 'OBJC', | ||||||
779 | 'flags' => ['OBJCFLAGS', 'CPPFLAGS'], | ||||||
780 | 'compile' => '$(OBJC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_OBJCFLAGS) $(OBJCFLAGS)', | ||||||
781 | 'ccer' => 'OBJC', | ||||||
782 | 'compiler' => 'OBJCCOMPILE', | ||||||
783 | 'compile_flag' => '-c', | ||||||
784 | 'output_flag' => '-o', | ||||||
785 | 'lder' => 'OBJCLD', | ||||||
786 | 'ld' => '$(OBJC)', | ||||||
787 | 'pure' => 1, | ||||||
788 | 'extensions' => ['.m']); | ||||||
789 | |||||||
790 | # Unified Parallel C. | ||||||
791 | 1159 | 8345 | register_language ('name' => 'upc', | ||||
792 | 'Name' => 'Unified Parallel C', | ||||||
793 | 'config_vars' => ['UPC'], | ||||||
794 | 'linker' => 'UPCLINK', | ||||||
795 | 'link' => '$(UPCLD) $(AM_UPCFLAGS) $(UPCFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@', | ||||||
796 | 'autodep' => 'UPC', | ||||||
797 | 'flags' => ['UPCFLAGS', 'CPPFLAGS'], | ||||||
798 | 'compile' => '$(UPC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_UPCFLAGS) $(UPCFLAGS)', | ||||||
799 | 'ccer' => 'UPC', | ||||||
800 | 'compiler' => 'UPCCOMPILE', | ||||||
801 | 'compile_flag' => '-c', | ||||||
802 | 'output_flag' => '-o', | ||||||
803 | 'lder' => 'UPCLD', | ||||||
804 | 'ld' => '$(UPC)', | ||||||
805 | 'pure' => 1, | ||||||
806 | 'extensions' => ['.upc']); | ||||||
807 | |||||||
808 | # Headers. | ||||||
809 | register_language ('name' => 'header', | ||||||
810 | 'Name' => 'Header', | ||||||
811 | 'extensions' => ['.h', '.H', '.hxx', '.h++', '.hh', | ||||||
812 | '.hpp', '.inc'], | ||||||
813 | # No output. | ||||||
814 | 8113 | 19945 | 'output_extensions' => sub { return () }, | ||||
815 | # Nothing to do. | ||||||
816 | 1159 21 | 12947 40 | '_finish' => sub { }); | ||||
817 | |||||||
818 | # Vala | ||||||
819 | register_language ('name' => 'vala', | ||||||
820 | 'Name' => 'Vala', | ||||||
821 | 'config_vars' => ['VALAC'], | ||||||
822 | 'flags' => [], | ||||||
823 | 'compile' => '$(VALAC) $(AM_VALAFLAGS) $(VALAFLAGS)', | ||||||
824 | 'ccer' => 'VALAC', | ||||||
825 | 'compiler' => 'VALACOMPILE', | ||||||
826 | 'extensions' => ['.vala'], | ||||||
827 | 1161 | 9359 | 'output_extensions' => sub { (my $ext = $_[0]) =~ s/vala$/c/; | ||||
828 | 1161 | 2639 | return ($ext,) }, | ||||
829 | 1159 | 11644 | 'rule_file' => 'vala', | ||||
830 | '_finish' => \&lang_vala_finish, | ||||||
831 | '_target_hook' => \&lang_vala_target_hook, | ||||||
832 | 'nodist_specific' => 1); | ||||||
833 | |||||||
834 | # Yacc (C & C++). | ||||||
835 | register_language ('name' => 'yacc', | ||||||
836 | 'Name' => 'Yacc', | ||||||
837 | 'config_vars' => ['YACC'], | ||||||
838 | 'flags' => ['YFLAGS'], | ||||||
839 | 'compile' => '$(YACC) $(AM_YFLAGS) $(YFLAGS)', | ||||||
840 | 'ccer' => 'YACC', | ||||||
841 | 'compiler' => 'YACCCOMPILE', | ||||||
842 | 'extensions' => ['.y'], | ||||||
843 | 1193 | 8344 | 'output_extensions' => sub { (my $ext = $_[0]) =~ tr/y/c/; | ||||
844 | 1193 | 3865 | return ($ext,) }, | ||||
845 | 1159 | 11483 | 'rule_file' => 'yacc', | ||||
846 | '_finish' => \&lang_yacc_finish, | ||||||
847 | '_target_hook' => \&lang_yacc_target_hook, | ||||||
848 | 'nodist_specific' => 1); | ||||||
849 | register_language ('name' => 'yaccxx', | ||||||
850 | 'Name' => 'Yacc (C++)', | ||||||
851 | 'config_vars' => ['YACC'], | ||||||
852 | 'rule_file' => 'yacc', | ||||||
853 | 'flags' => ['YFLAGS'], | ||||||
854 | 'ccer' => 'YACC', | ||||||
855 | 'compiler' => 'YACCCOMPILE', | ||||||
856 | 'compile' => '$(YACC) $(AM_YFLAGS) $(YFLAGS)', | ||||||
857 | 'extensions' => ['.y++', '.yy', '.yxx', '.ypp'], | ||||||
858 | 4642 | 7481 | 'output_extensions' => sub { (my $ext = $_[0]) =~ tr/y/c/; | ||||
859 | 4642 | 9067 | return ($ext,) }, | ||||
860 | 1159 | 12053 | '_finish' => \&lang_yacc_finish, | ||||
861 | '_target_hook' => \&lang_yacc_target_hook, | ||||||
862 | 'nodist_specific' => 1); | ||||||
863 | |||||||
864 | # Lex (C & C++). | ||||||
865 | register_language ('name' => 'lex', | ||||||
866 | 'Name' => 'Lex', | ||||||
867 | 'config_vars' => ['LEX'], | ||||||
868 | 'rule_file' => 'lex', | ||||||
869 | 'flags' => ['LFLAGS'], | ||||||
870 | 'compile' => '$(LEX) $(AM_LFLAGS) $(LFLAGS)', | ||||||
871 | 'ccer' => 'LEX', | ||||||
872 | 'compiler' => 'LEXCOMPILE', | ||||||
873 | 'extensions' => ['.l'], | ||||||
874 | 1174 | 2599 | 'output_extensions' => sub { (my $ext = $_[0]) =~ tr/l/c/; | ||||
875 | 1174 | 2576 | return ($ext,) }, | ||||
876 | 1159 | 12186 | '_finish' => \&lang_lex_finish, | ||||
877 | '_target_hook' => \&lang_lex_target_hook, | ||||||
878 | 'nodist_specific' => 1); | ||||||
879 | register_language ('name' => 'lexxx', | ||||||
880 | 'Name' => 'Lex (C++)', | ||||||
881 | 'config_vars' => ['LEX'], | ||||||
882 | 'rule_file' => 'lex', | ||||||
883 | 'flags' => ['LFLAGS'], | ||||||
884 | 'compile' => '$(LEX) $(AM_LFLAGS) $(LFLAGS)', | ||||||
885 | 'ccer' => 'LEX', | ||||||
886 | 'compiler' => 'LEXCOMPILE', | ||||||
887 | 'extensions' => ['.l++', '.ll', '.lxx', '.lpp'], | ||||||
888 | 4643 | 7487 | 'output_extensions' => sub { (my $ext = $_[0]) =~ tr/l/c/; | ||||
889 | 4643 | 8929 | return ($ext,) }, | ||||
890 | 1159 | 11835 | '_finish' => \&lang_lex_finish, | ||||
891 | '_target_hook' => \&lang_lex_target_hook, | ||||||
892 | 'nodist_specific' => 1); | ||||||
893 | |||||||
894 | # Assembler. | ||||||
895 | 1159 | 7864 | register_language ('name' => 'asm', | ||||
896 | 'Name' => 'Assembler', | ||||||
897 | 'config_vars' => ['CCAS', 'CCASFLAGS'], | ||||||
898 | |||||||
899 | 'flags' => ['CCASFLAGS'], | ||||||
900 | # Users can set AM_CCASFLAGS to include DEFS, INCLUDES, | ||||||
901 | # or anything else required. They can also set CCAS. | ||||||
902 | # Or simply use Preprocessed Assembler. | ||||||
903 | 'compile' => '$(CCAS) $(AM_CCASFLAGS) $(CCASFLAGS)', | ||||||
904 | 'ccer' => 'CCAS', | ||||||
905 | 'compiler' => 'CCASCOMPILE', | ||||||
906 | 'compile_flag' => '-c', | ||||||
907 | 'output_flag' => '-o', | ||||||
908 | 'extensions' => ['.s'], | ||||||
909 | |||||||
910 | # With assembly we still use the C linker. | ||||||
911 | '_finish' => \&lang_c_finish); | ||||||
912 | |||||||
913 | # Preprocessed Assembler. | ||||||
914 | 1159 | 9068 | register_language ('name' => 'cppasm', | ||||
915 | 'Name' => 'Preprocessed Assembler', | ||||||
916 | 'config_vars' => ['CCAS', 'CCASFLAGS'], | ||||||
917 | |||||||
918 | 'autodep' => 'CCAS', | ||||||
919 | 'flags' => ['CCASFLAGS', 'CPPFLAGS'], | ||||||
920 | 'compile' => '$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CCASFLAGS) $(CCASFLAGS)', | ||||||
921 | 'ccer' => 'CPPAS', | ||||||
922 | 'compiler' => 'CPPASCOMPILE', | ||||||
923 | 'compile_flag' => '-c', | ||||||
924 | 'output_flag' => '-o', | ||||||
925 | 'extensions' => ['.S', '.sx'], | ||||||
926 | |||||||
927 | # With assembly we still use the C linker. | ||||||
928 | '_finish' => \&lang_c_finish); | ||||||
929 | |||||||
930 | # Fortran 77 | ||||||
931 | 1159 | 8588 | register_language ('name' => 'f77', | ||||
932 | 'Name' => 'Fortran 77', | ||||||
933 | 'config_vars' => ['F77'], | ||||||
934 | 'linker' => 'F77LINK', | ||||||
935 | 'link' => '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@', | ||||||
936 | 'flags' => ['FFLAGS'], | ||||||
937 | 'compile' => '$(F77) $(AM_FFLAGS) $(FFLAGS)', | ||||||
938 | 'ccer' => 'F77', | ||||||
939 | 'compiler' => 'F77COMPILE', | ||||||
940 | 'compile_flag' => '-c', | ||||||
941 | 'output_flag' => '-o', | ||||||
942 | 'libtool_tag' => 'F77', | ||||||
943 | 'lder' => 'F77LD', | ||||||
944 | 'ld' => '$(F77)', | ||||||
945 | 'pure' => 1, | ||||||
946 | 'extensions' => ['.f', '.for']); | ||||||
947 | |||||||
948 | # Fortran | ||||||
949 | 1159 | 8961 | register_language ('name' => 'fc', | ||||
950 | 'Name' => 'Fortran', | ||||||
951 | 'config_vars' => ['FC'], | ||||||
952 | 'linker' => 'FCLINK', | ||||||
953 | 'link' => '$(FCLD) $(AM_FCFLAGS) $(FCFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@', | ||||||
954 | 'flags' => ['FCFLAGS'], | ||||||
955 | 'compile' => '$(FC) $(AM_FCFLAGS) $(FCFLAGS)', | ||||||
956 | 'ccer' => 'FC', | ||||||
957 | 'compiler' => 'FCCOMPILE', | ||||||
958 | 'compile_flag' => '-c', | ||||||
959 | 'output_flag' => '-o', | ||||||
960 | 'libtool_tag' => 'FC', | ||||||
961 | 'lder' => 'FCLD', | ||||||
962 | 'ld' => '$(FC)', | ||||||
963 | 'pure' => 1, | ||||||
964 | 'extensions' => ['.f90', '.f95', '.f03', '.f08']); | ||||||
965 | |||||||
966 | # Preprocessed Fortran | ||||||
967 | 1159 | 9143 | register_language ('name' => 'ppfc', | ||||
968 | 'Name' => 'Preprocessed Fortran', | ||||||
969 | 'config_vars' => ['FC'], | ||||||
970 | 'linker' => 'FCLINK', | ||||||
971 | 'link' => '$(FCLD) $(AM_FCFLAGS) $(FCFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@', | ||||||
972 | 'lder' => 'FCLD', | ||||||
973 | 'ld' => '$(FC)', | ||||||
974 | 'flags' => ['FCFLAGS', 'CPPFLAGS'], | ||||||
975 | 'ccer' => 'PPFC', | ||||||
976 | 'compiler' => 'PPFCCOMPILE', | ||||||
977 | 'compile' => '$(FC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FCFLAGS) $(FCFLAGS)', | ||||||
978 | 'compile_flag' => '-c', | ||||||
979 | 'output_flag' => '-o', | ||||||
980 | 'libtool_tag' => 'FC', | ||||||
981 | 'pure' => 1, | ||||||
982 | 'extensions' => ['.F90','.F95', '.F03', '.F08']); | ||||||
983 | |||||||
984 | # Preprocessed Fortran 77 | ||||||
985 | # | ||||||
986 | # The current support for preprocessing Fortran 77 just involves | ||||||
987 | # passing `$(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) | ||||||
988 | # $(CPPFLAGS)' as additional flags to the Fortran 77 compiler, since | ||||||
989 | # this is how GNU Make does it; see the `GNU Make Manual, Edition 0.51 | ||||||
990 | # for `make' Version 3.76 Beta' (specifically, from info file | ||||||
991 | # `(make)Catalogue of Rules'). | ||||||
992 | # | ||||||
993 | # A better approach would be to write an Autoconf test | ||||||
994 | # (i.e. AC_PROG_FPP) for a Fortran 77 preprocessor, because not all | ||||||
995 | # Fortran 77 compilers know how to do preprocessing. The Autoconf | ||||||
996 | # macro AC_PROG_FPP should test the Fortran 77 compiler first for | ||||||
997 | # preprocessing capabilities, and then fall back on cpp (if cpp were | ||||||
998 | # available). | ||||||
999 | 1159 | 8695 | register_language ('name' => 'ppf77', | ||||
1000 | 'Name' => 'Preprocessed Fortran 77', | ||||||
1001 | 'config_vars' => ['F77'], | ||||||
1002 | 'linker' => 'F77LINK', | ||||||
1003 | 'link' => '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@', | ||||||
1004 | 'lder' => 'F77LD', | ||||||
1005 | 'ld' => '$(F77)', | ||||||
1006 | 'flags' => ['FFLAGS', 'CPPFLAGS'], | ||||||
1007 | 'ccer' => 'PPF77', | ||||||
1008 | 'compiler' => 'PPF77COMPILE', | ||||||
1009 | 'compile' => '$(F77) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FFLAGS) $(FFLAGS)', | ||||||
1010 | 'compile_flag' => '-c', | ||||||
1011 | 'output_flag' => '-o', | ||||||
1012 | 'libtool_tag' => 'F77', | ||||||
1013 | 'pure' => 1, | ||||||
1014 | 'extensions' => ['.F']); | ||||||
1015 | |||||||
1016 | # Ratfor. | ||||||
1017 | 1159 | 8144 | register_language ('name' => 'ratfor', | ||||
1018 | 'Name' => 'Ratfor', | ||||||
1019 | 'config_vars' => ['F77'], | ||||||
1020 | 'linker' => 'F77LINK', | ||||||
1021 | 'link' => '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@', | ||||||
1022 | 'lder' => 'F77LD', | ||||||
1023 | 'ld' => '$(F77)', | ||||||
1024 | 'flags' => ['RFLAGS', 'FFLAGS'], | ||||||
1025 | # FIXME also FFLAGS. | ||||||
1026 | 'compile' => '$(F77) $(AM_FFLAGS) $(FFLAGS) $(AM_RFLAGS) $(RFLAGS)', | ||||||
1027 | 'ccer' => 'F77', | ||||||
1028 | 'compiler' => 'RCOMPILE', | ||||||
1029 | 'compile_flag' => '-c', | ||||||
1030 | 'output_flag' => '-o', | ||||||
1031 | 'libtool_tag' => 'F77', | ||||||
1032 | 'pure' => 1, | ||||||
1033 | 'extensions' => ['.r']); | ||||||
1034 | |||||||
1035 | # Java via gcj. | ||||||
1036 | 1159 | 9113 | register_language ('name' => 'java', | ||||
1037 | 'Name' => 'Java', | ||||||
1038 | 'config_vars' => ['GCJ'], | ||||||
1039 | 'linker' => 'GCJLINK', | ||||||
1040 | 'link' => '$(GCJLD) $(AM_GCJFLAGS) $(GCJFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@', | ||||||
1041 | 'autodep' => 'GCJ', | ||||||
1042 | 'flags' => ['GCJFLAGS'], | ||||||
1043 | 'compile' => '$(GCJ) $(AM_GCJFLAGS) $(GCJFLAGS)', | ||||||
1044 | 'ccer' => 'GCJ', | ||||||
1045 | 'compiler' => 'GCJCOMPILE', | ||||||
1046 | 'compile_flag' => '-c', | ||||||
1047 | 'output_flag' => '-o', | ||||||
1048 | 'libtool_tag' => 'GCJ', | ||||||
1049 | 'lder' => 'GCJLD', | ||||||
1050 | 'ld' => '$(GCJ)', | ||||||
1051 | 'pure' => 1, | ||||||
1052 | 'extensions' => ['.java', '.class', '.zip', '.jar']); | ||||||
1053 | |||||||
1054 | ################################################################ | ||||||
1055 | |||||||
1056 | # Error reporting functions. | ||||||
1057 | |||||||
1058 | # err_am ($MESSAGE, [%OPTIONS]) | ||||||
1059 | # ----------------------------- | ||||||
1060 | # Uncategorized errors about the current Makefile.am. | ||||||
1061 | sub err_am ($;%) | ||||||
1062 | { | ||||||
1063 | 4 | 16 | msg_am ('error', @_); | ||||
1064 | } | ||||||
1065 | |||||||
1066 | # err_ac ($MESSAGE, [%OPTIONS]) | ||||||
1067 | # ----------------------------- | ||||||
1068 | # Uncategorized errors about configure.ac. | ||||||
1069 | sub err_ac ($;%) | ||||||
1070 | { | ||||||
1071 | 10 | 43 | msg_ac ('error', @_); | ||||
1072 | } | ||||||
1073 | |||||||
1074 | # msg_am ($CHANNEL, $MESSAGE, [%OPTIONS]) | ||||||
1075 | # --------------------------------------- | ||||||
1076 | # Messages about about the current Makefile.am. | ||||||
1077 | sub msg_am ($$;%) | ||||||
1078 | { | ||||||
1079 | 4 | 12 | my ($channel, $msg, %opts) = @_; | ||||
1080 | 4 | 34 | msg $channel, "${am_file}.am", $msg, %opts; | ||||
1081 | } | ||||||
1082 | |||||||
1083 | # msg_ac ($CHANNEL, $MESSAGE, [%OPTIONS]) | ||||||
1084 | # --------------------------------------- | ||||||
1085 | # Messages about about configure.ac. | ||||||
1086 | sub msg_ac ($$;%) | ||||||
1087 | { | ||||||
1088 | 12 | 39 | my ($channel, $msg, %opts) = @_; | ||||
1089 | 12 | 61 | msg $channel, $configure_ac, $msg, %opts; | ||||
1090 | } | ||||||
1091 | |||||||
1092 | ################################################################ | ||||||
1093 | |||||||
1094 | # subst ($TEXT) | ||||||
1095 | # ------------- | ||||||
1096 | # Return a configure-style substitution using the indicated text. | ||||||
1097 | # We do this to avoid having the substitutions directly in automake.in; | ||||||
1098 | # when we do that they are sometimes removed and this causes confusion | ||||||
1099 | # and bugs. | ||||||
1100 | sub subst ($) | ||||||
1101 | { | ||||||
1102 | 115451 | 154854 | my ($text) = @_; | ||||
1103 | 115451 | 447903 | return '@' . $text . '@'; | ||||
1104 | } | ||||||
1105 | |||||||
1106 | ################################################################ | ||||||
1107 | |||||||
1108 | |||||||
1109 | # $BACKPATH | ||||||
1110 | # &backname ($REL-DIR) | ||||||
1111 | # -------------------- | ||||||
1112 | # If I `cd $REL-DIR', then to come back, I should `cd $BACKPATH'. | ||||||
1113 | # For instance `src/foo' => `../..'. | ||||||
1114 | # Works with non strictly increasing paths, i.e., `src/../lib' => `..'. | ||||||
1115 | sub backname ($) | ||||||
1116 | { | ||||||
1117 | 1322 | 3457 | my ($file) = @_; | ||||
1118 | 1322 | 2019 | my @res; | ||||
1119 | 1322 | 6717 | foreach (split (/\//, $file)) | ||||
1120 | { | ||||||
1121 | 1333 | 10464 | next if $_ eq '.' || $_ eq ''; | ||||
1122 | 223 | 613 | if ($_ eq '..') | ||||
1123 | { | ||||||
1124 | pop @res | ||||||
1125 | 0 | 0 | or prog_error ("trying to reverse path `$file' pointing outside tree"); | ||||
1126 | } | ||||||
1127 | else | ||||||
1128 | { | ||||||
1129 | 223 | 720 | push (@res, '..'); | ||||
1130 | } | ||||||
1131 | } | ||||||
1132 | 1322 | 13141 | return join ('/', @res) || '.'; | ||||
1133 | } | ||||||
1134 | |||||||
1135 | ################################################################ | ||||||
1136 | |||||||
1137 | # `silent-rules' mode handling functions. | ||||||
1138 | |||||||
1139 | # verbose_var (NAME) | ||||||
1140 | # ------------------ | ||||||
1141 | # The public variable stem used to implement `silent-rules'. | ||||||
1142 | sub verbose_var ($) | ||||||
1143 | { | ||||||
1144 | 1175 | 1925 | my ($name) = @_; | ||||
1145 | 1175 | 2974 | return 'AM_V_' . $name; | ||||
1146 | } | ||||||
1147 | |||||||
1148 | # verbose_private_var (NAME) | ||||||
1149 | # -------------------------- | ||||||
1150 | # The naming policy for the private variables for `silent-rules'. | ||||||
1151 | sub verbose_private_var ($) | ||||||
1152 | { | ||||||
1153 | 862 | 1900 | my ($name) = @_; | ||||
1154 | 862 | 1686 | return 'am__v_' . $name; | ||||
1155 | } | ||||||
1156 | |||||||
1157 | # define_verbose_var (NAME, VAL) | ||||||
1158 | # ------------------------------ | ||||||
1159 | # For `silent-rules' mode, setup VAR and dispatcher, to expand to VAL if silent. | ||||||
1160 | sub define_verbose_var ($$) | ||||||
1161 | { | ||||||
1162 | 862 | 1742 | my ($name, $val) = @_; | ||||
1163 | 862 | 1695 | my $var = verbose_var ($name); | ||||
1164 | 862 | 1736 | my $pvar = verbose_private_var ($name); | ||||
1165 | 862 | 1346 | my $silent_var = $pvar . '_0'; | ||||
1166 | 862 | 2109 | if (option 'silent-rules') | ||||
1167 | { | ||||||
1168 | # Using `$V' instead of `$(V)' breaks IRIX make. | ||||||
1169 | 304 | 738 | define_variable ($var, '$(' . $pvar . '_$(V))', INTERNAL); | ||||
1170 | 304 | 892 | define_variable ($pvar . '_', '$(' . $pvar . '_$(AM_DEFAULT_VERBOSITY))', INTERNAL); | ||||
1171 | 304 | 749 | Automake::Variable::define ($silent_var, VAR_AUTOMAKE, '', TRUE, $val, | ||||
1172 | '', INTERNAL, VAR_ASIS) | ||||||
1173 | if (! vardef ($silent_var, TRUE)); | ||||||
1174 | } | ||||||
1175 | } | ||||||
1176 | |||||||
1177 | # Above should not be needed in the general automake code. | ||||||
1178 | |||||||
1179 | # verbose_flag (NAME) | ||||||
1180 | # ------------------- | ||||||
1181 | # Contents of %VERBOSE%: variable to expand before rule command. | ||||||
1182 | sub verbose_flag ($) | ||||||
1183 | { | ||||||
1184 | 7657 | 14973 | my ($name) = @_; | ||||
1185 | 7657 | 18002 | return '$(' . verbose_var ($name) . ')' | ||||
1186 | if (option 'silent-rules'); | ||||||
1187 | 7366 | 22237 | return ''; | ||||
1188 | } | ||||||
1189 | |||||||
1190 | sub verbose_nodep_flag ($) | ||||||
1191 | { | ||||||
1192 | 553 | 1401 | my ($name) = @_; | ||||
1193 | 553 | 1687 | return '$(' . verbose_var ($name) . subst ('am__nodep') . ')' | ||||
1194 | if (option 'silent-rules'); | ||||||
1195 | 531 | 1185 | return ''; | ||||
1196 | } | ||||||
1197 | |||||||
1198 | # silent_flag | ||||||
1199 | # ----------- | ||||||
1200 | # Contents of %SILENT%: variable to expand to `@' when silent. | ||||||
1201 | sub silent_flag () | ||||||
1202 | { | ||||||
1203 | 1043 | 2322 | return verbose_flag ('at'); | ||||
1204 | } | ||||||
1205 | |||||||
1206 | # define_verbose_tagvar (NAME) | ||||||
1207 | # ---------------------------- | ||||||
1208 | # Engage the needed `silent-rules' machinery for tag NAME. | ||||||
1209 | sub define_verbose_tagvar ($) | ||||||
1210 | { | ||||||
1211 | 3533 | 6842 | my ($name) = @_; | ||||
1212 | 3533 | 8494 | if (option 'silent-rules') | ||||
1213 | { | ||||||
1214 | 116 | 531 | define_verbose_var ($name, '@echo " '. $name . ' ' x (8 - length ($name)) . '" $@;'); | ||||
1215 | 116 | 247 | define_verbose_var ('at', '@'); | ||||
1216 | } | ||||||
1217 | } | ||||||
1218 | |||||||
1219 | # define_verbose_texinfo | ||||||
1220 | # ---------------------- | ||||||
1221 | # Engage the needed `silent-rules' machinery for assorted texinfo commands. | ||||||
1222 | sub define_verbose_texinfo () | ||||||
1223 | { | ||||||
1224 | 51 | 204 | my @tagvars = ('DVIPS', 'MAKEINFO', 'INFOHTML', 'TEXI2DVI', 'TEXI2PDF'); | ||||
1225 | 51 | 174 | foreach my $tag (@tagvars) | ||||
1226 | { | ||||||
1227 | 255 | 409 | define_verbose_tagvar($tag); | ||||
1228 | } | ||||||
1229 | 51 | 242 | define_verbose_var('texinfo', '-q'); | ||||
1230 | 51 | 114 | define_verbose_var('texidevnull', '> /dev/null'); | ||||
1231 | } | ||||||
1232 | |||||||
1233 | # define_verbose_libtool | ||||||
1234 | # ---------------------- | ||||||
1235 | # Engage the needed `silent-rules' machinery for `libtool --silent'. | ||||||
1236 | sub define_verbose_libtool () | ||||||
1237 | { | ||||||
1238 | 528 | 1461 | define_verbose_var ('lt', '--silent'); | ||||
1239 | 528 | 1204 | return verbose_flag ('lt'); | ||||
1240 | } | ||||||
1241 | |||||||
1242 | |||||||
1243 | ################################################################ | ||||||
1244 | |||||||
1245 | |||||||
1246 | # Handle AUTOMAKE_OPTIONS variable. Return 1 on error, 0 otherwise. | ||||||
1247 | sub handle_options | ||||||
1248 | { | ||||||
1249 | 1321 | 4933 | my $var = var ('AUTOMAKE_OPTIONS'); | ||||
1250 | 1321 | 3861 | if ($var) | ||||
1251 | { | ||||||
1252 | 129 | 765 | if ($var->has_conditional_contents) | ||||
1253 | { | ||||||
1254 | 1 | 5 | msg_var ('unsupported', $var, | ||||
1255 | "`AUTOMAKE_OPTIONS' cannot have conditional contents"); | ||||||
1256 | } | ||||||
1257 | 129 | 667 | foreach my $locvals ($var->value_as_list_recursive (cond_filter => TRUE, | ||||
1258 | location => 1)) | ||||||
1259 | { | ||||||
1260 | 131 | 335 | my ($loc, $value) = @$locvals; | ||||
1261 | 131 | 753 | return 1 if (process_option_list ($loc, $value)) | ||||
1262 | } | ||||||
1263 | } | ||||||
1264 | |||||||
1265 | # Override portability-recursive warning. | ||||||
1266 | 1319 | 5824 | switch_warning ('no-portability-recursive') | ||||
1267 | if option 'silent-rules'; | ||||||
1268 | |||||||
1269 | 1319 | 4235 | if ($strictness == GNITS) | ||||
1270 | { | ||||||
1271 | 11 | 50 | set_option ('readme-alpha', INTERNAL); | ||||
1272 | 11 | 29 | set_option ('std-options', INTERNAL); | ||||
1273 | 11 | 26 | set_option ('check-news', INTERNAL); | ||||
1274 | } | ||||||
1275 | |||||||
1276 | 1319 | 3792 | return 0; | ||||
1277 | } | ||||||
1278 | |||||||
1279 | # shadow_unconditionally ($varname, $where) | ||||||
1280 | # ----------------------------------------- | ||||||
1281 | # Return a $(variable) that contains all possible values | ||||||
1282 | # $varname can take. | ||||||
1283 | # If the VAR wasn't defined conditionally, return $(VAR). | ||||||
1284 | # Otherwise we create an am__VAR_DIST variable which contains | ||||||
1285 | # all possible values, and return $(am__VAR_DIST). | ||||||
1286 | sub shadow_unconditionally ($$) | ||||||
1287 | { | ||||||
1288 | 844 | 2107 | my ($varname, $where) = @_; | ||||
1289 | 844 | 2158 | my $var = var $varname; | ||||
1290 | 844 | 3662 | if ($var->has_conditional_contents) | ||||
1291 | { | ||||||
1292 | 37 | 107 | $varname = "am__${varname}_DIST"; | ||||
1293 | 37 | 130 | my @files = uniq ($var->value_as_list_recursive); | ||||
1294 | 37 | 275 | define_pretty_variable ($varname, TRUE, $where, @files); | ||||
1295 | } | ||||||
1296 | 844 | 2706 | return "\$($varname)" | ||||
1297 | } | ||||||
1298 | |||||||
1299 | # get_object_extension ($EXTENSION) | ||||||
1300 | # --------------------------------- | ||||||
1301 | # Prefix $EXTENSION with $U if ansi2knr is in use. | ||||||
1302 | sub get_object_extension ($) | ||||||
1303 | { | ||||||
1304 | 1120 | 2519 | my ($extension) = @_; | ||||
1305 | |||||||
1306 | # Check for automatic de-ANSI-fication. | ||||||
1307 | 1120 | 3112 | $extension = '$U' . $extension | ||||
1308 | if option 'ansi2knr'; | ||||||
1309 | |||||||
1310 | 1120 | 1611 | $get_object_extension_was_run = 1; | ||||
1311 | |||||||
1312 | 1120 | 2242 | return $extension; | ||||
1313 | } | ||||||
1314 | |||||||
1315 | # get_libtool_tag ($LANG) | ||||||
1316 | # ----------------------- | ||||||
1317 | # Libtool tag string for $LANG. | ||||||
1318 | sub get_libtool_tag | ||||||
1319 | { | ||||||
1320 | 2102 | 3535 | my ($lang) = @_; | ||||
1321 | 2102 | 2793 | my $libtool_tag = ''; | ||||
1322 | 2102 | 7303 | $libtool_tag = '--tag=' . $lang->libtool_tag . ' ' | ||||
1323 | if $lang->libtool_tag && exists $libtool_tags{$lang->libtool_tag}; | ||||||
1324 | 2102 | 4615 | return $libtool_tag; | ||||
1325 | } | ||||||
1326 | |||||||
1327 | # check_user_variables (@LIST) | ||||||
1328 | # ---------------------------- | ||||||
1329 | # Make sure each variable VAR in @LIST does not exist, suggest using AM_VAR | ||||||
1330 | # otherwise. | ||||||
1331 | sub check_user_variables (@) | ||||||
1332 | { | ||||||
1333 | 774 | 2051 | my @dont_override = @_; | ||||
1334 | 774 | 2329 | foreach my $flag (@dont_override) | ||||
1335 | { | ||||||
1336 | 1894 | 4455 | my $var = var $flag; | ||||
1337 | 1894 | 4523 | if ($var) | ||||
1338 | { | ||||||
1339 | 1727 | 4636 | for my $cond ($var->conditions->conds) | ||||
1340 | { | ||||||
1341 | 1727 | 4417 | if ($var->rdef ($cond)->owner == VAR_MAKEFILE) | ||||
1342 | { | ||||||
1343 | 13 | 89 | msg_cond_var ('gnu', $cond, $flag, | ||||
1344 | "`$flag' is a user variable, " | ||||||
1345 | . "you should not override it;\n" | ||||||
1346 | . "use `AM_$flag' instead"); | ||||||
1347 | } | ||||||
1348 | } | ||||||
1349 | } | ||||||
1350 | } | ||||||
1351 | } | ||||||
1352 | |||||||
1353 | # Call finish function for each language that was used. | ||||||
1354 | sub handle_languages | ||||||
1355 | { | ||||||
1356 | 1319 | 5647 | if (! option 'no-dependencies') | ||||
1357 | { | ||||||
1358 | # Include auto-dep code. Don't include it if DEP_FILES would | ||||||
1359 | # be empty. | ||||||
1360 | 1291 | 6293 | if (&saw_sources_p (0) && keys %dep_files) | ||||
1361 | { | ||||||
1362 | # Set location of depcomp. | ||||||
1363 | 525 | 2548 | &define_variable ('depcomp', | ||||
1364 | "\$(SHELL) $am_config_aux_dir/depcomp", | ||||||
1365 | INTERNAL); | ||||||
1366 | 525 | 1663 | &define_variable ('am__depfiles_maybe', 'depfiles', INTERNAL); | ||||
1367 | |||||||
1368 | 525 | 2525 | require_conf_file ("$am_file.am", FOREIGN, 'depcomp'); | ||||
1369 | |||||||
1370 | 525 | 3262 | my @deplist = sort keys %dep_files; | ||||
1371 | # Generate each `include' individually. Irix 6 make will | ||||||
1372 | # not properly include several files resulting from a | ||||||
1373 | # variable expansion; generating many separate includes | ||||||
1374 | # seems safest. | ||||||
1375 | 525 | 1260 | $output_rules .= "\n"; | ||||
1376 | 525 | 2052 | foreach my $iter (@deplist) | ||||
1377 | { | ||||||
1378 | 969 | 2134 | $output_rules .= (subst ('AMDEP_TRUE') | ||||
1379 | . subst ('am__include') | ||||||
1380 | . ' ' | ||||||
1381 | . subst ('am__quote') | ||||||
1382 | . $iter | ||||||
1383 | . subst ('am__quote') | ||||||
1384 | . "\n"); | ||||||
1385 | } | ||||||
1386 | |||||||
1387 | # Compute the set of directories to remove in distclean-depend. | ||||||
1388 | 525 969 | 1501 45899 | my @depdirs = uniq (map { dirname ($_) } @deplist); | ||||
1389 | 525 | 2279 | $output_rules .= &file_contents ('depend', | ||||
1390 | new Automake::Location, | ||||||
1391 | DEPDIRS => "@depdirs"); | ||||||
1392 | } | ||||||
1393 | } | ||||||
1394 | else | ||||||
1395 | { | ||||||
1396 | 28 | 139 | &define_variable ('depcomp', '', INTERNAL); | ||||
1397 | 28 | 78 | &define_variable ('am__depfiles_maybe', '', INTERNAL); | ||||
1398 | } | ||||||
1399 | |||||||
1400 | 1319 | 3130 | my %done; | ||||
1401 | |||||||
1402 | # Is the c linker needed? | ||||||
1403 | 1319 | 2578 | my $needs_c = 0; | ||||
1404 | 1319 | 6489 | foreach my $ext (sort keys %extension_seen) | ||||
1405 | { | ||||||
1406 | 705 | 2569 | next unless $extension_map{$ext}; | ||||
1407 | |||||||
1408 | 705 | 1643 | my $lang = $languages{$extension_map{$ext}}; | ||||
1409 | |||||||
1410 | 705 | 4775 | my $rule_file = $lang->rule_file || 'depend2'; | ||||
1411 | |||||||
1412 | # Get information on $LANG. | ||||||
1413 | 705 | 2834 | my $pfx = $lang->autodep; | ||||
1414 | 705 | 2157 | my $fpfx = ($pfx eq '') ? 'CC' : $pfx; | ||||
1415 | |||||||
1416 | 705 | 2208 | my ($AMDEP, $FASTDEP) = | ||||
1417 | (option 'no-dependencies' || $lang->autodep eq 'no') | ||||||
1418 | ? ('FALSE', 'FALSE') : ('AMDEP', "am__fastdep$fpfx"); | ||||||
1419 | |||||||
1420 | 705 | 3593 | my $verbose = verbose_flag ($lang->ccer || 'GEN'); | ||||
1421 | 705 | 3125 | my $verbose_nodep = ($AMDEP eq 'FALSE') | ||||
1422 | ? $verbose : verbose_nodep_flag ($lang->ccer || 'GEN'); | ||||||
1423 | 705 | 1955 | my $silent = silent_flag (); | ||||
1424 | |||||||
1425 | 705 | 4123 | my %transform = ('EXT' => $ext, | ||||
1426 | 'PFX' => $pfx, | ||||||
1427 | 'FPFX' => $fpfx, | ||||||
1428 | 'AMDEP' => $AMDEP, | ||||||
1429 | 'FASTDEP' => $FASTDEP, | ||||||
1430 | '-c' => $lang->compile_flag || '', | ||||||
1431 | # These are not used, but they need to be defined | ||||||
1432 | # so &transform do not complain. | ||||||
1433 | SUBDIROBJ => 0, | ||||||
1434 | 'DERIVED-EXT' => 'BUG', | ||||||
1435 | DIST_SOURCE => 1, | ||||||
1436 | VERBOSE => $verbose, | ||||||
1437 | 'VERBOSE-NODEP' => $verbose_nodep, | ||||||
1438 | SILENT => $silent, | ||||||
1439 | ); | ||||||
1440 | |||||||
1441 | # Generate the appropriate rules for this extension. | ||||||
1442 | 705 | 2449 | if (((! option 'no-dependencies') && $lang->autodep ne 'no') | ||||
1443 | || defined $lang->compile) | ||||||
1444 | { | ||||||
1445 | # Some C compilers don't support -c -o. Use it only if really | ||||||
1446 | # needed. | ||||||
1447 | 684 | 4313 | my $output_flag = $lang->output_flag || ''; | ||||
1448 | 684 | 4871 | $output_flag = '-o' | ||||
1449 | if (! $output_flag | ||||||
1450 | && $lang->name eq 'c' | ||||||
1451 | && option 'subdir-objects'); | ||||||
1452 | |||||||
1453 | # Compute a possible derived extension. | ||||||
1454 | # This is not used by depend2.am. | ||||||
1455 | 684 684 | 1532 3216 | my $der_ext = (&{$lang->output_extensions} ($ext))[0]; | ||||
1456 | |||||||
1457 | # When we output an inference rule like `.c.o:' we | ||||||
1458 | # have two cases to consider: either subdir-objects | ||||||
1459 | # is used, or it is not. | ||||||
1460 | # | ||||||
1461 | # In the latter case the rule is used to build objects | ||||||
1462 | # in the current directory, and dependencies always | ||||||
1463 | # go into `./$(DEPDIR)/'. We can hard-code this value. | ||||||
1464 | # | ||||||
1465 | # In the former case the rule can be used to build | ||||||
1466 | # objects in sub-directories too. Dependencies should | ||||||
1467 | # go into the appropriate sub-directories, e.g., | ||||||
1468 | # `sub/$(DEPDIR)/'. The value of this directory | ||||||
1469 | # needs to be computed on-the-fly. | ||||||
1470 | # | ||||||
1471 | # DEPBASE holds the name of this directory, plus the | ||||||
1472 | # basename part of the object file (extensions Po, TPo, | ||||||
1473 | # Plo, TPlo will be added later as appropriate). It is | ||||||
1474 | # either hardcoded, or a shell variable (`$depbase') that | ||||||
1475 | # will be computed by the rule. | ||||||
1476 | 684 | 2159 | my $depbase = | ||||
1477 | option ('subdir-objects') ? '$$depbase' : '$(DEPDIR)/$*'; | ||||||
1478 | 684 | 2449 | $output_rules .= | ||||
1479 | file_contents ($rule_file, | ||||||
1480 | new Automake::Location, | ||||||
1481 | %transform, | ||||||
1482 | GENERIC => 1, | ||||||
1483 | |||||||
1484 | 'DERIVED-EXT' => $der_ext, | ||||||
1485 | |||||||
1486 | DEPBASE => $depbase, | ||||||
1487 | BASE => '$*', | ||||||
1488 | SOURCE => '$<', | ||||||
1489 | SOURCEFLAG => $sourceflags{$ext} || '', | ||||||
1490 | OBJ => '$@', | ||||||
1491 | OBJOBJ => '$@', | ||||||
1492 | LTOBJ => '$@', | ||||||
1493 | |||||||
1494 | COMPILE => '$(' . $lang->compiler . ')', | ||||||
1495 | LTCOMPILE => '$(LT' . $lang->compiler . ')', | ||||||
1496 | -o => $output_flag, | ||||||
1497 | SUBDIROBJ => !! option 'subdir-objects'); | ||||||
1498 | } | ||||||
1499 | |||||||
1500 | # Now include code for each specially handled object with this | ||||||
1501 | # language. | ||||||
1502 | 705 | 3002 | my %seen_files = (); | ||||
1503 | 705 705 | 1128 2938 | foreach my $file (@{$lang_specific_files{$lang->name}}) | ||||
1504 | { | ||||||
1505 | 158 | 728 | my ($derived, $source, $obj, $myext, $srcext, %file_transform) = @$file; | ||||
1506 | |||||||
1507 | # We might see a given object twice, for instance if it is | ||||||
1508 | # used under different conditions. | ||||||
1509 | 158 | 424 | next if defined $seen_files{$obj}; | ||||
1510 | 157 | 315 | $seen_files{$obj} = 1; | ||||
1511 | |||||||
1512 | 157 | 570 | prog_error ("found " . $lang->name . | ||||
1513 | " in handle_languages, but compiler not defined") | ||||||
1514 | unless defined $lang->compile; | ||||||
1515 | |||||||
1516 | 157 | 417 | my $obj_compile = $lang->compile; | ||||
1517 | |||||||
1518 | # Rewrite each occurrence of `AM_$flag' in the compile | ||||||
1519 | # rule into `${derived}_$flag' if it exists. | ||||||
1520 | 157 157 | 203 498 | for my $flag (@{$lang->flags}) | ||||
1521 | { | ||||||
1522 | 264 | 571 | my $val = "${derived}_$flag"; | ||||
1523 | 264 | 733 | $obj_compile =~ s/\(AM_$flag\)/\($val\)/ | ||||
1524 | if set_seen ($val); | ||||||
1525 | } | ||||||
1526 | |||||||
1527 | 157 | 529 | my $libtool_tag = get_libtool_tag ($lang); | ||||
1528 | 157 | 304 | my $ptltflags = "${derived}_LIBTOOLFLAGS"; | ||||
1529 | 157 | 390 | $ptltflags = 'AM_LIBTOOLFLAGS' unless set_seen $ptltflags; | ||||
1530 | |||||||
1531 | 157 | 356 | my $ltverbose = define_verbose_libtool (); | ||||
1532 | 157 | 693 | my $obj_ltcompile = | ||||
1533 | "\$(LIBTOOL) $ltverbose $libtool_tag\$($ptltflags) \$(LIBTOOLFLAGS) " | ||||||
1534 | . "--mode=compile $obj_compile"; | ||||||
1535 | |||||||
1536 | # We _need_ `-o' for per object rules. | ||||||
1537 | 157 | 540 | my $output_flag = $lang->output_flag || '-o'; | ||||
1538 | |||||||
1539 | 157 | 509 | my $depbase = dirname ($obj); | ||||
1540 | 157 | 17995 | $depbase = '' | ||||
1541 | if $depbase eq '.'; | ||||||
1542 | 157 | 381 | $depbase .= '/' | ||||
1543 | unless $depbase eq ''; | ||||||
1544 | 157 | 429 | $depbase .= '$(DEPDIR)/' . basename ($obj); | ||||
1545 | |||||||
1546 | # Support for deansified files in subdirectories is ugly | ||||||
1547 | # enough to deserve an explanation. | ||||||
1548 | # | ||||||
1549 | # A Note about normal ansi2knr processing first. On | ||||||
1550 | # | ||||||
1551 | # AUTOMAKE_OPTIONS = ansi2knr | ||||||
1552 | # bin_PROGRAMS = foo | ||||||
1553 | # foo_SOURCES = foo.c | ||||||
1554 | # | ||||||
1555 | # we generate rules similar to: | ||||||
1556 | # | ||||||
1557 | # foo: foo$U.o; link ... | ||||||
1558 | # foo$U.o: foo$U.c; compile ... | ||||||
1559 | # foo_.c: foo.c; ansi2knr ... | ||||||
1560 | # | ||||||
1561 | # this is fairly compact, and will call ansi2knr depending | ||||||
1562 | # on the value of $U (`' or `_'). | ||||||
1563 | # | ||||||
1564 | # It's harder with subdir sources. On | ||||||
1565 | # | ||||||
1566 | # AUTOMAKE_OPTIONS = ansi2knr | ||||||
1567 | # bin_PROGRAMS = foo | ||||||
1568 | # foo_SOURCES = sub/foo.c | ||||||
1569 | # | ||||||
1570 | # we have to create foo_.c in the current directory. | ||||||
1571 | # (Unless the user asks 'subdir-objects'.) This is important | ||||||
1572 | # in case the same file (`foo.c') is compiled from other | ||||||
1573 | # directories with different cpp options: foo_.c would | ||||||
1574 | # be preprocessed for only one set of options if it were | ||||||
1575 | # put in the subdirectory. | ||||||
1576 | # | ||||||
1577 | # Because foo$U.o must be built from either foo_.c or | ||||||
1578 | # sub/foo.c we can't be as concise as in the first example. | ||||||
1579 | # Instead we output | ||||||
1580 | # | ||||||
1581 | # foo: foo$U.o; link ... | ||||||
1582 | # foo_.o: foo_.c; compile ... | ||||||
1583 | # foo.o: sub/foo.c; compile ... | ||||||
1584 | # foo_.c: foo.c; ansi2knr ... | ||||||
1585 | # | ||||||
1586 | # This is why we'll now transform $rule_file twice | ||||||
1587 | # if we detect this case. | ||||||
1588 | # A first time we output the compile rule with `$U' | ||||||
1589 | # replaced by `_' and the source directory removed, | ||||||
1590 | # and another time we simply remove `$U'. | ||||||
1591 | # | ||||||
1592 | # Note that at this point $source (as computed by | ||||||
1593 | # &handle_single_transform) is `sub/foo$U.c'. | ||||||
1594 | # This can be confusing: it can be used as-is when | ||||||
1595 | # subdir-objects is set, otherwise you have to know | ||||||
1596 | # it really means `foo_.c' or `sub/foo.c'. | ||||||
1597 | 157 | 371 | my $objdir = dirname ($obj); | ||||
1598 | 157 | 14250 | my $srcdir = dirname ($source); | ||||
1599 | 157 | 14275 | if ($lang->ansi && $obj =~ /\$U/) | ||||
1600 | { | ||||||
1601 | 2 | 9 | prog_error "`$obj' contains \$U, but `$source' doesn't" | ||||
1602 | if $source !~ /\$U/; | ||||||
1603 | |||||||
1604 | 2 | 11 | (my $source_ = $source) =~ s/\$U/_/g; | ||||
1605 | # Output an additional rule if _.c and .c are not in | ||||||
1606 | # the same directory. (_.c is always in $objdir.) | ||||||
1607 | 2 | 6 | if ($objdir ne $srcdir) | ||||
1608 | { | ||||||
1609 | 1 | 4 | (my $obj_ = $obj) =~ s/\$U/_/g; | ||||
1610 | 1 | 3 | (my $depbase_ = $depbase) =~ s/\$U/_/g; | ||||
1611 | 1 | 2 | $source_ = basename ($source_); | ||||
1612 | |||||||
1613 | 1 | 4 | $output_rules .= | ||||
1614 | file_contents ($rule_file, | ||||||
1615 | new Automake::Location, | ||||||
1616 | %transform, | ||||||
1617 | GENERIC => 0, | ||||||
1618 | |||||||
1619 | DEPBASE => $depbase_, | ||||||
1620 | BASE => $obj_, | ||||||
1621 | SOURCE => $source_, | ||||||
1622 | SOURCEFLAG => $sourceflags{$srcext} || '', | ||||||
1623 | OBJ => "$obj_$myext", | ||||||
1624 | OBJOBJ => "$obj_.obj", | ||||||
1625 | LTOBJ => "$obj_.lo", | ||||||
1626 | |||||||
1627 | COMPILE => $obj_compile, | ||||||
1628 | LTCOMPILE => $obj_ltcompile, | ||||||
1629 | -o => $output_flag, | ||||||
1630 | %file_transform); | ||||||
1631 | 1 | 5 | $obj =~ s/\$U//g; | ||||
1632 | 1 | 3 | $depbase =~ s/\$U//g; | ||||
1633 | 1 | 4 | $source =~ s/\$U//g; | ||||
1634 | } | ||||||
1635 | } | ||||||
1636 | |||||||
1637 | $output_rules .= | ||||||
1638 | 157 | 584 | file_contents ($rule_file, | ||||
1639 | new Automake::Location, | ||||||
1640 | %transform, | ||||||
1641 | GENERIC => 0, | ||||||
1642 | |||||||
1643 | DEPBASE => $depbase, | ||||||
1644 | BASE => $obj, | ||||||
1645 | SOURCE => $source, | ||||||
1646 | SOURCEFLAG => $sourceflags{$srcext} || '', | ||||||
1647 | # Use $myext and not `.o' here, in case | ||||||
1648 | # we are actually building a new source | ||||||
1649 | # file -- e.g. via yacc. | ||||||
1650 | OBJ => "$obj$myext", | ||||||
1651 | OBJOBJ => "$obj.obj", | ||||||
1652 | LTOBJ => "$obj.lo", | ||||||
1653 | |||||||
1654 | VERBOSE => $verbose, | ||||||
1655 | 'VERBOSE-NODEP' => $verbose_nodep, | ||||||
1656 | SILENT => $silent, | ||||||
1657 | COMPILE => $obj_compile, | ||||||
1658 | LTCOMPILE => $obj_ltcompile, | ||||||
1659 | -o => $output_flag, | ||||||
1660 | %file_transform); | ||||||
1661 | } | ||||||
1662 | |||||||
1663 | # The rest of the loop is done once per language. | ||||||
1664 | 705 | 2970 | next if defined $done{$lang}; | ||||
1665 | 678 | 1908 | $done{$lang} = 1; | ||||
1666 | |||||||
1667 | # Load the language dependent Makefile chunks. | ||||||
1668 | 678 12204 | 3756 25554 | my %lang = map { uc ($_) => 0 } keys %languages; | ||||
1669 | 678 | 3570 | $lang{uc ($lang->name)} = 1; | ||||
1670 | 678 | 2644 | $output_rules .= file_contents ('lang-compile', | ||||
1671 | new Automake::Location, | ||||||
1672 | %transform, %lang); | ||||||
1673 | |||||||
1674 | # If the source to a program consists entirely of code from a | ||||||
1675 | # `pure' language, for instance C++ or Fortran 77, then we | ||||||
1676 | # don't need the C compiler code. However if we run into | ||||||
1677 | # something unusual then we do generate the C code. There are | ||||||
1678 | # probably corner cases here that do not work properly. | ||||||
1679 | # People linking Java code to Fortran code deserve pain. | ||||||
1680 | 678 | 5602 | $needs_c ||= ! $lang->pure; | ||||
1681 | |||||||
1682 | 678 | 2948 | define_compiler_variable ($lang) | ||||
1683 | if ($lang->compile); | ||||||
1684 | |||||||
1685 | 678 | 2967 | define_linker_variable ($lang) | ||||
1686 | if ($lang->link); | ||||||
1687 | |||||||
1688 | 678 | 2565 | require_variables ("$am_file.am", $lang->Name . " source seen", | ||||
1689 | 678 | 4120 | TRUE, @{$lang->config_vars}); | ||||
1690 | |||||||
1691 | # Call the finisher. | ||||||
1692 | 678 | 3633 | $lang->finish; | ||||
1693 | |||||||
1694 | # Flags listed in `->flags' are user variables (per GNU Standards), | ||||||
1695 | # they should not be overridden in the Makefile... | ||||||
1696 | 678 678 | 1212 2576 | my @dont_override = @{$lang->flags}; | ||||
1697 | # ... and so is LDFLAGS. | ||||||
1698 | 678 | 2069 | push @dont_override, 'LDFLAGS' if $lang->link; | ||||
1699 | |||||||
1700 | 678 | 2746 | check_user_variables @dont_override; | ||||
1701 | } | ||||||
1702 | |||||||
1703 | # If the project is entirely C++ or entirely Fortran 77 (i.e., 1 | ||||||
1704 | # suffix rule was learned), don't bother with the C stuff. But if | ||||||
1705 | # anything else creeps in, then use it. | ||||||
1706 | 1319 | 11468 | $needs_c = 1 | ||||
1707 | if $need_link || suffix_rules_count > 1; | ||||||
1708 | |||||||
1709 | 1319 | 3749 | if ($needs_c) | ||||
1710 | { | ||||||
1711 | 528 | 2213 | &define_compiler_variable ($languages{'c'}) | ||||
1712 | unless defined $done{$languages{'c'}}; | ||||||
1713 | 528 | 1478 | define_linker_variable ($languages{'c'}); | ||||
1714 | } | ||||||
1715 | |||||||
1716 | # Always provide the user with `AM_V_GEN' for `silent-rules' mode. | ||||||
1717 | 1319 | 5309 | define_verbose_tagvar ('GEN'); | ||||
1718 | } | ||||||
1719 | |||||||
1720 | |||||||
1721 | # append_exeext { PREDICATE } $MACRO | ||||||
1722 | # ---------------------------------- | ||||||
1723 | # Append $(EXEEXT) to each filename in $F appearing in the Makefile | ||||||
1724 | # variable $MACRO if &PREDICATE($F) is true. @substitutions@ are | ||||||
1725 | # ignored. | ||||||
1726 | # | ||||||
1727 | # This is typically used on all filenames of *_PROGRAMS, and filenames | ||||||
1728 | # of TESTS that are programs. | ||||||
1729 | sub append_exeext (&$) | ||||||
1730 | { | ||||||
1731 | 700 | 2630 | my ($pred, $macro) = @_; | ||||
1732 | |||||||
1733 | transform_variable_recursively | ||||||
1734 | ($macro, $macro, 'am__EXEEXT', 0, INTERNAL, | ||||||
1735 | sub { | ||||||
1736 | 1004 | 2400 | my ($subvar, $val, $cond, $full_cond) = @_; | ||||
1737 | # Append $(EXEEXT) unless the user did it already, or it's a | ||||||
1738 | # @substitution@. | ||||||
1739 | 1004 | 7771 | $val .= '$(EXEEXT)' | ||||
1740 | if $val !~ /(?:\$\(EXEEXT\)$|^[@]\w+[@]$)/ && &$pred ($val); | ||||||
1741 | 1004 | 3270 | return $val; | ||||
1742 | 700 | 6015 | }); | ||||
1743 | } | ||||||
1744 | |||||||
1745 | |||||||
1746 | # Check to make sure a source defined in LIBOBJS is not explicitly | ||||||
1747 | # mentioned. This is a separate function (as opposed to being inlined | ||||||
1748 | # in handle_source_transform) because it isn't always appropriate to | ||||||
1749 | # do this check. | ||||||
1750 | sub check_libobjs_sources | ||||||
1751 | { | ||||||
1752 | 55 | 159 | my ($one_file, $unxformed) = @_; | ||||
1753 | |||||||
1754 | 55 | 187 | foreach my $prefix ('', 'EXTRA_', 'dist_', 'nodist_', | ||||
1755 | 'dist_EXTRA_', 'nodist_EXTRA_') | ||||||
1756 | { | ||||||
1757 | 330 | 315 | my @files; | ||||
1758 | 330 | 608 | my $varname = $prefix . $one_file . '_SOURCES'; | ||||
1759 | 330 | 693 | my $var = var ($varname); | ||||
1760 | 330 | 954 | if ($var) | ||||
1761 | { | ||||||
1762 | 55 | 220 | @files = $var->value_as_list_recursive; | ||||
1763 | } | ||||||
1764 | elsif ($prefix eq '') | ||||||
1765 | { | ||||||
1766 | 0 | 0 | @files = ($unxformed . '.c'); | ||||
1767 | } | ||||||
1768 | else | ||||||
1769 | { | ||||||
1770 | 275 | 595 | next; | ||||
1771 | } | ||||||
1772 | |||||||
1773 | 55 | 433 | foreach my $file (@files) | ||||
1774 | { | ||||||
1775 | 23 | 134 | err_var ($prefix . $one_file . '_SOURCES', | ||||
1776 | "automatically discovered file `$file' should not" . | ||||||
1777 | " be explicitly mentioned") | ||||||
1778 | if defined $libsources{$file}; | ||||||
1779 | } | ||||||
1780 | } | ||||||
1781 | } | ||||||
1782 | |||||||
1783 | |||||||
1784 | # @OBJECTS | ||||||
1785 | # handle_single_transform ($VAR, $TOPPARENT, $DERIVED, $OBJ, $FILE, %TRANSFORM) | ||||||
1786 | # ----------------------------------------------------------------------------- | ||||||
1787 | # Does much of the actual work for handle_source_transform. | ||||||
1788 | # Arguments are: | ||||||
1789 | # $VAR is the name of the variable that the source filenames come from | ||||||
1790 | # $TOPPARENT is the name of the _SOURCES variable which is being processed | ||||||
1791 | # $DERIVED is the name of resulting executable or library | ||||||
1792 | # $OBJ is the object extension (e.g., `$U.lo') | ||||||
1793 | # $FILE the source file to transform | ||||||
1794 | # %TRANSFORM contains extras arguments to pass to file_contents | ||||||
1795 | # when producing explicit rules | ||||||
1796 | # Result is a list of the names of objects | ||||||
1797 | # %linkers_used will be updated with any linkers needed | ||||||
1798 | sub handle_single_transform ($$$$$%) | ||||||
1799 | { | ||||||
1800 | 1396 | 6005 | my ($var, $topparent, $derived, $obj, $_file, %transform) = @_; | ||||
1801 | 1396 | 2683 | my @files = ($_file); | ||||
1802 | 1396 | 2256 | my @result = (); | ||||
1803 | 1396 | 1890 | my $nonansi_obj = $obj; | ||||
1804 | 1396 | 3561 | $nonansi_obj =~ s/\$U//g; | ||||
1805 | |||||||
1806 | # Turn sources into objects. We use a while loop like this | ||||||
1807 | # because we might add to @files in the loop. | ||||||
1808 | 1396 | 4129 | while (scalar @files > 0) | ||||
1809 | { | ||||||
1810 | 1486 | 2947 | $_ = shift @files; | ||||
1811 | |||||||
1812 | # Configure substitutions in _SOURCES variables are errors. | ||||||
1813 | 1486 | 4048 | if (/^\@.*\@$/) | ||||
1814 | { | ||||||
1815 | 2 | 4 | my $parent_msg = ''; | ||||
1816 | 2 | 7 | $parent_msg = "\nand is referred to from `$topparent'" | ||||
1817 | if $topparent ne $var->name; | ||||||
1818 | 2 | 7 | err_var ($var, | ||||
1819 | "`" . $var->name . "' includes configure substitution `$_'" | ||||||
1820 | . $parent_msg . ";\nconfigure " . | ||||||
1821 | "substitutions are not allowed in _SOURCES variables"); | ||||||
1822 | 2 | 8 | next; | ||||
1823 | } | ||||||
1824 | |||||||
1825 | # If the source file is in a subdirectory then the `.o' is put | ||||||
1826 | # into the current directory, unless the subdir-objects option | ||||||
1827 | # is in effect. | ||||||
1828 | |||||||
1829 | # Split file name into base and extension. | ||||||
1830 | 1484 | 59198 | next if ! /^(?:(.*)\/)?([^\/]*)($KNOWN_EXTENSIONS_PATTERN)$/; | ||||
1831 | 1471 | 2827 | my $full = $_; | ||||
1832 | 1471 | 9637 | my $directory = $1 || ''; | ||||
1833 | 1471 | 2645 | my $base = $2; | ||||
1834 | 1471 | 2492 | my $extension = $3; | ||||
1835 | |||||||
1836 | # We must generate a rule for the object if it requires its own flags. | ||||||
1837 | 1471 | 1824 | my $renamed = 0; | ||||
1838 | 1471 | 1886 | my ($linker, $object); | ||||
1839 | |||||||
1840 | # This records whether we've seen a derived source file (e.g. | ||||||
1841 | # yacc output). | ||||||
1842 | 1471 | 1685 | my $derived_source = 0; | ||||
1843 | |||||||
1844 | # This holds the `aggregate context' of the file we are | ||||||
1845 | # currently examining. If the file is compiled with | ||||||
1846 | # per-object flags, then it will be the name of the object. | ||||||
1847 | # Otherwise it will be `AM'. This is used by the target hook | ||||||
1848 | # language function. | ||||||
1849 | 1471 | 1810 | my $aggregate = 'AM'; | ||||
1850 | |||||||
1851 | 1471 | 4298 | $extension = &derive_suffix ($extension, $nonansi_obj); | ||||
1852 | 1471 | 1745 | my $lang; | ||||
1853 | 1471 | 10787 | if ($extension_map{$extension} && | ||||
1854 | ($lang = $languages{$extension_map{$extension}})) | ||||||
1855 | { | ||||||
1856 | # Found the language, so see what it says. | ||||||
1857 | 1462 | 4474 | &saw_extension ($extension); | ||||
1858 | |||||||
1859 | # Do we have per-executable flags for this executable? | ||||||
1860 | 1462 | 2074 | my $have_per_exec_flags = 0; | ||||
1861 | 1462 1462 | 1663 7254 | my @peflags = @{$lang->flags}; | ||||
1862 | 1462 | 3880 | push @peflags, 'LIBTOOLFLAGS' if $nonansi_obj eq '.lo'; | ||||
1863 | 1462 | 3400 | foreach my $flag (@peflags) | ||||
1864 | { | ||||||
1865 | 2751 | 8293 | if (set_seen ("${derived}_$flag")) | ||||
1866 | { | ||||||
1867 | 80 | 112 | $have_per_exec_flags = 1; | ||||
1868 | 80 | 124 | last; | ||||
1869 | } | ||||||
1870 | } | ||||||
1871 | |||||||
1872 | # Note: computed subr call. The language rewrite function | ||||||
1873 | # should return one of the LANG_* constants. It could | ||||||
1874 | # also return a list whose first value is such a constant | ||||||
1875 | # and whose second value is a new source extension which | ||||||
1876 | # should be applied. This means this particular language | ||||||
1877 | # generates another source file which we must then process | ||||||
1878 | # further. | ||||||
1879 | 1462 1462 | 2148 6098 | my $subr = \&{'lang_' . $lang->name . '_rewrite'}; | ||||
1880 | 1462 | 5850 | my ($r, $source_extension) | ||||
1881 | = &$subr ($directory, $base, $extension, | ||||||
1882 | $nonansi_obj, $have_per_exec_flags, $var); | ||||||
1883 | # Skip this entry if we were asked not to process it. | ||||||
1884 | 1462 | 3363 | next if $r == LANG_IGNORE; | ||||
1885 | |||||||
1886 | # Now extract linker and other info. | ||||||
1887 | 1419 | 6544 | $linker = $lang->linker; | ||||
1888 | |||||||
1889 | 1419 | 1728 | my $this_obj_ext; | ||||
1890 | 1419 | 6750 | if (defined $source_extension) | ||||
1891 | { | ||||||
1892 | 90 | 121 | $this_obj_ext = $source_extension; | ||||
1893 | 90 | 120 | $derived_source = 1; | ||||
1894 | } | ||||||
1895 | elsif ($lang->ansi) | ||||||
1896 | { | ||||||
1897 | 1158 | 1644 | $this_obj_ext = $obj; | ||||
1898 | } | ||||||
1899 | else | ||||||
1900 | { | ||||||
1901 | 171 | 248 | $this_obj_ext = $nonansi_obj; | ||||
1902 | } | ||||||
1903 | 1419 | 2239 | $object = $base . $this_obj_ext; | ||||
1904 | |||||||
1905 | 1419 | 2837 | if ($have_per_exec_flags) | ||||
1906 | { | ||||||
1907 | # We have a per-executable flag in effect for this | ||||||
1908 | # object. In this case we rewrite the object's | ||||||
1909 | # name to ensure it is unique. | ||||||
1910 | |||||||
1911 | # We choose the name `DERIVED_OBJECT' to ensure | ||||||
1912 | # (1) uniqueness, and (2) continuity between | ||||||
1913 | # invocations. However, this will result in a | ||||||
1914 | # name that is too long for losing systems, in | ||||||
1915 | # some situations. So we provide _SHORTNAME to | ||||||
1916 | # override. | ||||||
1917 | |||||||
1918 | 80 | 115 | my $dname = $derived; | ||||
1919 | 80 | 242 | my $var = var ($derived . '_SHORTNAME'); | ||||
1920 | 80 | 180 | if ($var) | ||||
1921 | { | ||||||
1922 | # FIXME: should use the same Condition as | ||||||
1923 | # the _SOURCES variable. But this is really | ||||||
1924 | # silly overkill -- nobody should have | ||||||
1925 | # conditional shortnames. | ||||||
1926 | 2 | 7 | $dname = $var->variable_value; | ||||
1927 | } | ||||||
1928 | 80 | 164 | $object = $dname . '-' . $object; | ||||
1929 | |||||||
1930 | 80 | 327 | prog_error ($lang->name . " flags defined without compiler") | ||||
1931 | if ! defined $lang->compile; | ||||||
1932 | |||||||
1933 | 80 | 140 | $renamed = 1; | ||||
1934 | } | ||||||
1935 | |||||||
1936 | # If rewrite said it was ok, put the object into a | ||||||
1937 | # subdir. | ||||||
1938 | 1419 | 4778 | if ($r == LANG_SUBDIR && $directory ne '') | ||||
1939 | { | ||||||
1940 | 55 | 137 | $object = $directory . '/' . $object; | ||||
1941 | } | ||||||
1942 | |||||||
1943 | # If the object file has been renamed (because per-target | ||||||
1944 | # flags are used) we cannot compile the file with an | ||||||
1945 | # inference rule: we need an explicit rule. | ||||||
1946 | # | ||||||
1947 | # If the source is in a subdirectory and the object is in | ||||||
1948 | # the current directory, we also need an explicit rule. | ||||||
1949 | # | ||||||
1950 | # If both source and object files are in a subdirectory | ||||||
1951 | # (this happens when the subdir-objects option is used), | ||||||
1952 | # then the inference will work. | ||||||
1953 | # | ||||||
1954 | # The latter case deserves a historical note. When the | ||||||
1955 | # subdir-objects option was added on 1999-04-11 it was | ||||||
1956 | # thought that inferences rules would work for | ||||||
1957 | # subdirectory objects too. Later, on 1999-11-22, | ||||||
1958 | # automake was changed to output explicit rules even for | ||||||
1959 | # subdir-objects. Nobody remembers why, but this occurred | ||||||
1960 | # soon after the merge of the user-dep-gen-branch so it | ||||||
1961 | # might be related. In late 2003 people complained about | ||||||
1962 | # the size of the generated Makefile.ins (libgcj, with | ||||||
1963 | # 2200+ subdir objects was reported to have a 9MB | ||||||
1964 | # Makefile), so we now rely on inference rules again. | ||||||
1965 | # Maybe we'll run across the same issue as in the past, | ||||||
1966 | # but at least this time we can document it. However since | ||||||
1967 | # dependency tracking has evolved it is possible that | ||||||
1968 | # our old problem no longer exists. | ||||||
1969 | # Using inference rules for subdir-objects has been tested | ||||||
1970 | # with GNU make, Solaris make, Ultrix make, BSD make, | ||||||
1971 | # HP-UX make, and OSF1 make successfully. | ||||||
1972 | 1419 | 15216 | if ($renamed | ||||
1973 | || ($directory ne '' && ! option 'subdir-objects') | ||||||
1974 | # We must also use specific rules for a nodist_ source | ||||||
1975 | # if its language requests it. | ||||||
1976 | || ($lang->nodist_specific && ! $transform{'DIST_SOURCE'})) | ||||||
1977 | { | ||||||
1978 | 123 | 349 | my $obj_sans_ext = substr ($object, 0, | ||||
1979 | - length ($this_obj_ext)); | ||||||
1980 | 123 | 145 | my $full_ansi; | ||||
1981 | 123 | 476 | if ($directory ne '') | ||||
1982 | { | ||||||
1983 | 46 | 116 | $full_ansi = $directory . '/' . $base . $extension; | ||||
1984 | } | ||||||
1985 | else | ||||||
1986 | { | ||||||
1987 | 77 | 141 | $full_ansi = $base . $extension; | ||||
1988 | } | ||||||
1989 | |||||||
1990 | 123 | 344 | if ($lang->ansi && option 'ansi2knr') | ||||
1991 | { | ||||||
1992 | 2 | 142 | $full_ansi =~ s/$KNOWN_EXTENSIONS_PATTERN$/\$U$&/; | ||||
1993 | 2 | 4 | $obj_sans_ext .= '$U'; | ||||
1994 | } | ||||||
1995 | |||||||
1996 | 123 | 636 | my @specifics = ($full_ansi, $obj_sans_ext, | ||||
1997 | # Only use $this_obj_ext in the derived | ||||||
1998 | # source case because in the other case we | ||||||
1999 | # *don't* want $(OBJEXT) to appear here. | ||||||
2000 | ($derived_source ? $this_obj_ext : '.o'), | ||||||
2001 | $extension); | ||||||
2002 | |||||||
2003 | # If we renamed the object then we want to use the | ||||||
2004 | # per-executable flag name. But if this is simply a | ||||||
2005 | # subdir build then we still want to use the AM_ flag | ||||||
2006 | # name. | ||||||
2007 | 123 | 336 | if ($renamed) | ||||
2008 | { | ||||||
2009 | 80 | 151 | unshift @specifics, $derived; | ||||
2010 | 80 | 126 | $aggregate = $derived; | ||||
2011 | } | ||||||
2012 | else | ||||||
2013 | { | ||||||
2014 | 43 | 98 | unshift @specifics, 'AM'; | ||||
2015 | } | ||||||
2016 | |||||||
2017 | # Each item on this list is a reference to a list consisting | ||||||
2018 | # of four values followed by additional transform flags for | ||||||
2019 | # file_contents. The four values are the derived flag prefix | ||||||
2020 | # (e.g. for `foo_CFLAGS', it is `foo'), the name of the | ||||||
2021 | # source file, the base name of the output file, and | ||||||
2022 | # the extension for the object file. | ||||||
2023 | 123 123 | 171 324 | push (@{$lang_specific_files{$lang->name}}, | ||||
2024 | [@specifics, %transform]); | ||||||
2025 | } | ||||||
2026 | } | ||||||
2027 | elsif ($extension eq $nonansi_obj) | ||||||
2028 | { | ||||||
2029 | # This is probably the result of a direct suffix rule. | ||||||
2030 | # In this case we just accept the rewrite. | ||||||
2031 | 7 | 13 | $object = "$base$extension"; | ||||
2032 | 7 | 17 | $object = "$directory/$object" if $directory ne ''; | ||||
2033 | 7 | 13 | $linker = ''; | ||||
2034 | } | ||||||
2035 | else | ||||||
2036 | { | ||||||
2037 | # No error message here. Used to have one, but it was | ||||||
2038 | # very unpopular. | ||||||
2039 | # FIXME: we could potentially do more processing here, | ||||||
2040 | # perhaps treating the new extension as though it were a | ||||||
2041 | # new source extension (as above). This would require | ||||||
2042 | # more restructuring than is appropriate right now. | ||||||
2043 | 2 | 7 | next; | ||||
2044 | } | ||||||
2045 | |||||||
2046 | 1426 | 6272 | err_am "object `$object' created by `$full' and `$object_map{$object}'" | ||||
2047 | if (defined $object_map{$object} | ||||||
2048 | && $object_map{$object} ne $full); | ||||||
2049 | |||||||
2050 | 1426 | 6367 | my $comp_val = (($object =~ /\.lo$/) | ||||
2051 | ? COMPILE_LIBTOOL : COMPILE_ORDINARY); | ||||||
2052 | 1426 | 3316 | (my $comp_obj = $object) =~ s/\.lo$/.\$(OBJEXT)/; | ||||
2053 | 1426 | 10245 | if (defined $object_compilation_map{$comp_obj} | ||||
2054 | && $object_compilation_map{$comp_obj} != 0 | ||||||
2055 | # Only see the error once. | ||||||
2056 | && ($object_compilation_map{$comp_obj} | ||||||
2057 | != (COMPILE_LIBTOOL | COMPILE_ORDINARY)) | ||||||
2058 | && $object_compilation_map{$comp_obj} != $comp_val) | ||||||
2059 | { | ||||||
2060 | 1 | 4 | err_am "object `$comp_obj' created both with libtool and without"; | ||||
2061 | } | ||||||
2062 | 1426 | 3218 | $object_compilation_map{$comp_obj} |= $comp_val; | ||||
2063 | |||||||
2064 | 1426 | 3244 | if (defined $lang) | ||||
2065 | { | ||||||
2066 | # Let the language do some special magic if required. | ||||||
2067 | 1419 | 7524 | $lang->target_hook ($aggregate, $object, $full, %transform); | ||||
2068 | } | ||||||
2069 | |||||||
2070 | 1426 | 3391 | if ($derived_source) | ||||
2071 | { | ||||||
2072 | 90 | 386 | prog_error ($lang->name . " has automatic dependency tracking") | ||||
2073 | if $lang->autodep ne 'no'; | ||||||
2074 | # Make sure this new source file is handled next. That will | ||||||
2075 | # make it appear to be at the right place in the list. | ||||||
2076 | 90 | 209 | unshift (@files, $object); | ||||
2077 | # Distribute derived sources unless the source they are | ||||||
2078 | # derived from is not. | ||||||
2079 | 90 | 469 | &push_dist_common ($object) | ||||
2080 | unless ($topparent =~ /^(?:nobase_)?nodist_/); | ||||||
2081 | 90 | 275 | next; | ||||
2082 | } | ||||||
2083 | |||||||
2084 | 1336 | 2677 | $linkers_used{$linker} = 1; | ||||
2085 | |||||||
2086 | 1336 | 2631 | push (@result, $object); | ||||
2087 | |||||||
2088 | 1336 | 3649 | if (! defined $object_map{$object}) | ||||
2089 | { | ||||||
2090 | 991 | 1730 | my @dep_list = (); | ||||
2091 | 991 | 2137 | $object_map{$object} = $full; | ||||
2092 | |||||||
2093 | # If resulting object is in subdir, we need to make | ||||||
2094 | # sure the subdir exists at build time. | ||||||
2095 | 991 | 3351 | if ($object =~ /\//) | ||||
2096 | { | ||||||
2097 | # FIXME: check that $DIRECTORY is somewhere in the | ||||||
2098 | # project | ||||||
2099 | |||||||
2100 | # For Java, the way we're handling it right now, a | ||||||
2101 | # `..' component doesn't make sense. | ||||||
2102 | 46 | 280 | if ($lang && $lang->name eq 'java' && $object =~ /(\/|^)\.\.\//) | ||||
2103 | { | ||||||
2104 | 1 | 5 | err_am "`$full' should not contain a `..' component"; | ||||
2105 | } | ||||||
2106 | |||||||
2107 | # Make sure object is removed by `make mostlyclean'. | ||||||
2108 | 46 | 128 | $compile_clean_files{$object} = MOSTLY_CLEAN; | ||||
2109 | # If we have a libtool object then we also must remove | ||||||
2110 | # the ordinary .o. | ||||||
2111 | 46 | 163 | if ($object =~ /\.lo$/) | ||||
2112 | { | ||||||
2113 | 5 | 19 | (my $xobj = $object) =~ s,lo$,\$(OBJEXT),; | ||||
2114 | 5 | 8 | $compile_clean_files{$xobj} = MOSTLY_CLEAN; | ||||
2115 | |||||||
2116 | # Remove any libtool object in this directory. | ||||||
2117 | 5 | 15 | $libtool_clean_directories{$directory} = 1; | ||||
2118 | } | ||||||
2119 | |||||||
2120 | 46 | 202 | push (@dep_list, require_build_directory ($directory)); | ||||
2121 | |||||||
2122 | # If we're generating dependencies, we also want | ||||||
2123 | # to make sure that the appropriate subdir of the | ||||||
2124 | # .deps directory is created. | ||||||
2125 | 46 | 139 | push (@dep_list, | ||||
2126 | require_build_directory ($directory . '/$(DEPDIR)')) | ||||||
2127 | unless option 'no-dependencies'; | ||||||
2128 | } | ||||||
2129 | |||||||
2130 | 991 | 3023 | &pretty_print_rule ($object . ':', "\t", @dep_list) | ||||
2131 | if scalar @dep_list > 0; | ||||||
2132 | } | ||||||
2133 | |||||||
2134 | # Transform .o or $o file into .P file (for automatic | ||||||
2135 | # dependency code). | ||||||
2136 | 1336 | 8300 | if ($lang && $lang->autodep ne 'no') | ||||
2137 | { | ||||||
2138 | 1268 | 1926 | my $depfile = $object; | ||||
2139 | 1268 | 9821 | $depfile =~ s/\.([^.]*)$/.P$1/; | ||||
2140 | 1268 | 3773 | $depfile =~ s/\$\(OBJEXT\)$/o/; | ||||
2141 | 1268 | 1853 | $depfile =~ s,//*,/,; | ||||
2142 | 1268 | 1718 | $depfile =~ s,^\./,,; | ||||
2143 | 1268 | 4325 | $dep_files{dirname ($depfile) . '/$(DEPDIR)/' | ||||
2144 | . basename ($depfile)} = 1; | ||||||
2145 | } | ||||||
2146 | } | ||||||
2147 | |||||||
2148 | 1396 | 4920 | return @result; | ||||
2149 | } | ||||||
2150 | |||||||
2151 | |||||||
2152 | # $LINKER | ||||||
2153 | # define_objects_from_sources ($VAR, $OBJVAR, $NODEFINE, $ONE_FILE, | ||||||
2154 | # $OBJ, $PARENT, $TOPPARENT, $WHERE, %TRANSFORM) | ||||||
2155 | # --------------------------------------------------------------------------- | ||||||
2156 | # Define an _OBJECTS variable for a _SOURCES variable (or subvariable) | ||||||
2157 | # | ||||||
2158 | # Arguments are: | ||||||
2159 | # $VAR is the name of the _SOURCES variable | ||||||
2160 | # $OBJVAR is the name of the _OBJECTS variable if known (otherwise | ||||||
2161 | # it will be generated and returned). | ||||||
2162 | # $NODEFINE is a boolean: if true, $OBJVAR will not be defined (but | ||||||
2163 | # work done to determine the linker will be). | ||||||
2164 | # $ONE_FILE is the canonical (transformed) name of object to build | ||||||
2165 | # $OBJ is the object extension (i.e. either `.o' or `.lo'). | ||||||
2166 | # $TOPPARENT is the _SOURCES variable being processed. | ||||||
2167 | # $WHERE context into which this definition is done | ||||||
2168 | # %TRANSFORM extra arguments to pass to file_contents when producing | ||||||
2169 | # rules | ||||||
2170 | # | ||||||
2171 | # Result is a pair ($LINKER, $OBJVAR): | ||||||
2172 | # $LINKER is a boolean, true if a linker is needed to deal with the objects | ||||||
2173 | sub define_objects_from_sources ($$$$$$$%) | ||||||
2174 | { | ||||||
2175 | 845 | 4712 | my ($var, $objvar, $nodefine, $one_file, | ||||
2176 | $obj, $topparent, $where, %transform) = @_; | ||||||
2177 | |||||||
2178 | 845 | 1341 | my $needlinker = ""; | ||||
2179 | |||||||
2180 | transform_variable_recursively | ||||||
2181 | ($var, $objvar, 'am__objects', $nodefine, $where, | ||||||
2182 | # The transform code to run on each filename. | ||||||
2183 | sub { | ||||||
2184 | 1102 | 2622 | my ($subvar, $val, $cond, $full_cond) = @_; | ||||
2185 | 1102 | 5031 | my @trans = handle_single_transform ($subvar, $topparent, | ||||
2186 | $one_file, $obj, $val, | ||||||
2187 | %transform); | ||||||
2188 | 1102 | 2950 | $needlinker = "true" if @trans; | ||||
2189 | 1102 | 3125 | return @trans; | ||||
2190 | 845 | 7381 | }); | ||||
2191 | |||||||
2192 | 845 | 5785 | return $needlinker; | ||||
2193 | } | ||||||
2194 | |||||||
2195 | |||||||
2196 | # handle_source_transform ($CANON_TARGET, $TARGET, $OBJEXT, $WHERE, %TRANSFORM) | ||||||
2197 | # ----------------------------------------------------------------------------- | ||||||
2198 | # Handle SOURCE->OBJECT transform for one program or library. | ||||||
2199 | # Arguments are: | ||||||
2200 | # canonical (transformed) name of target to build | ||||||
2201 | # actual target of object to build | ||||||
2202 | # object extension (i.e., either `.o' or `$o') | ||||||
2203 | # location of the source variable | ||||||
2204 | # extra arguments to pass to file_contents when producing rules | ||||||
2205 | # Return the name of the linker variable that must be used. | ||||||
2206 | # Empty return means just use `LINK'. | ||||||
2207 | sub handle_source_transform ($$$$%) | ||||||
2208 | { | ||||||
2209 | # one_file is canonical name. unxformed is given name. obj is | ||||||
2210 | # object extension. | ||||||
2211 | 1120 | 4836 | my ($one_file, $unxformed, $obj, $where, %transform) = @_; | ||||
2212 | |||||||
2213 | 1120 | 1973 | my $linker = ''; | ||||
2214 | |||||||
2215 | # No point in continuing if _OBJECTS is defined. | ||||||
2216 | 1120 | 4320 | return if reject_var ($one_file . '_OBJECTS', | ||||
2217 | $one_file . '_OBJECTS should not be defined'); | ||||||
2218 | |||||||
2219 | 1119 | 2033 | my %used_pfx = (); | ||||
2220 | 1119 | 1290 | my $needlinker; | ||||
2221 | 1119 | 1859 | %linkers_used = (); | ||||
2222 | 1119 | 3563 | foreach my $prefix ('', 'EXTRA_', 'dist_', 'nodist_', | ||||
2223 | 'dist_EXTRA_', 'nodist_EXTRA_') | ||||||
2224 | { | ||||||
2225 | 6714 | 11538 | my $varname = $prefix . $one_file . "_SOURCES"; | ||||
2226 | 6714 | 14034 | my $var = var $varname; | ||||
2227 | 6714 | 14847 | next unless $var; | ||||
2228 | |||||||
2229 | # We are going to define _OBJECTS variables using the prefix. | ||||||
2230 | # Then we glom them all together. So we can't use the null | ||||||
2231 | # prefix here as we need it later. | ||||||
2232 | 845 | 3022 | my $xpfx = ($prefix eq '') ? 'am_' : $prefix; | ||||
2233 | |||||||
2234 | # Keep track of which prefixes we saw. | ||||||
2235 | 845 | 3534 | $used_pfx{$xpfx} = 1 | ||||
2236 | unless $prefix =~ /EXTRA_/; | ||||||
2237 | |||||||
2238 | 845 | 2275 | push @sources, "\$($varname)"; | ||||
2239 | 845 | 2449 | push @dist_sources, shadow_unconditionally ($varname, $where) | ||||
2240 | unless (option ('no-dist') || $prefix =~ /^nodist_/); | ||||||
2241 | |||||||
2242 | 845 | 6678 | $needlinker |= | ||||
2243 | define_objects_from_sources ($varname, | ||||||
2244 | $xpfx . $one_file . '_OBJECTS', | ||||||
2245 | $prefix =~ /EXTRA_/, | ||||||
2246 | $one_file, $obj, $varname, $where, | ||||||
2247 | DIST_SOURCE => ($prefix !~ /^nodist_/), | ||||||
2248 | %transform); | ||||||
2249 | } | ||||||
2250 | 1119 | 2971 | if ($needlinker) | ||||
2251 | { | ||||||
2252 | 772 | 3799 | $linker ||= &resolve_linker (%linkers_used); | ||||
2253 | } | ||||||
2254 | |||||||
2255 | 1119 | 4074 | my @keys = sort keys %used_pfx; | ||||
2256 | 1119 | 3647 | if (scalar @keys == 0) | ||||
2257 | { | ||||||
2258 | # The default source for libfoo.la is libfoo.c, but for | ||||||
2259 | # backward compatibility we first look at libfoo_la.c, | ||||||
2260 | # if no default source suffix is given. | ||||||
2261 | 294 | 585 | my $old_default_source = "$one_file.c"; | ||||
2262 | 294 | 736 | my $ext_var = var ('AM_DEFAULT_SOURCE_EXT'); | ||||
2263 | 294 | 891 | my $default_source_ext = $ext_var ? variable_value ($ext_var) : '.c'; | ||||
2264 | 294 | 1169 | msg_var ('unsupported', $ext_var, $ext_var->name . " can assume at most one value") | ||||
2265 | if $default_source_ext =~ /[\t ]/; | ||||||
2266 | 294 | 1915 | (my $default_source = $unxformed) =~ s,(\.[^./\\]*)?$,$default_source_ext,; | ||||
2267 | 294 | 1929 | if ($old_default_source ne $default_source | ||||
2268 | && !$ext_var | ||||||
2269 | && (rule $old_default_source | ||||||
2270 | || rule '$(srcdir)/' . $old_default_source | ||||||
2271 | || rule '${srcdir}/' . $old_default_source | ||||||
2272 | || -f $old_default_source)) | ||||||
2273 | { | ||||||
2274 | 4 | 11 | my $loc = $where->clone; | ||||
2275 | 4 | 13 | $loc->pop_context; | ||||
2276 | 4 | 27 | msg ('obsolete', $loc, | ||||
2277 | "the default source for `$unxformed' has been changed " | ||||||
2278 | . "to `$default_source'.\n(Using `$old_default_source' for " | ||||||
2279 | . "backward compatibility.)"); | ||||||
2280 | 4 | 12 | $default_source = $old_default_source; | ||||
2281 | } | ||||||
2282 | # If a rule exists to build this source with a $(srcdir) | ||||||
2283 | # prefix, use that prefix in our variables too. This is for | ||||||
2284 | # the sake of BSD Make. | ||||||
2285 | 294 | 1037 | if (rule '$(srcdir)/' . $default_source | ||||
2286 | || rule '${srcdir}/' . $default_source) | ||||||
2287 | { | ||||||
2288 | 2 | 5 | $default_source = '$(srcdir)/' . $default_source; | ||||
2289 | } | ||||||
2290 | |||||||
2291 | 294 | 860 | &define_variable ($one_file . "_SOURCES", $default_source, $where); | ||||
2292 | 294 | 647 | push (@sources, $default_source); | ||||
2293 | 294 | 473 | push (@dist_sources, $default_source); | ||||
2294 | |||||||
2295 | 294 | 514 | %linkers_used = (); | ||||
2296 | 294 | 1949 | my (@result) = | ||||
2297 | handle_single_transform ($one_file . '_SOURCES', | ||||||
2298 | $one_file . '_SOURCES', | ||||||
2299 | $one_file, $obj, | ||||||
2300 | $default_source, %transform); | ||||||
2301 | 294 | 1476 | $linker ||= &resolve_linker (%linkers_used); | ||||
2302 | 294 | 940 | define_pretty_variable ($one_file . '_OBJECTS', TRUE, $where, @result); | ||||
2303 | } | ||||||
2304 | else | ||||||
2305 | { | ||||||
2306 | 825 832 | 1543 3939 | @keys = map { '$(' . $_ . $one_file . '_OBJECTS)' } @keys; | ||||
2307 | 825 | 2766 | define_pretty_variable ($one_file . '_OBJECTS', TRUE, $where, @keys); | ||||
2308 | } | ||||||
2309 | |||||||
2310 | # If we want to use `LINK' we must make sure it is defined. | ||||||
2311 | 1119 | 3399 | if ($linker eq '') | ||||
2312 | { | ||||||
2313 | 53 | 86 | $need_link = 1; | ||||
2314 | } | ||||||
2315 | |||||||
2316 | 1119 | 3629 | return $linker; | ||||
2317 | } | ||||||
2318 | |||||||
2319 | |||||||
2320 | # handle_lib_objects ($XNAME, $VAR) | ||||||
2321 | # --------------------------------- | ||||||
2322 | # Special-case ALLOCA and LIBOBJS substitutions in _LDADD or _LIBADD variables. | ||||||
2323 | # Also, generate _DEPENDENCIES variable if appropriate. | ||||||
2324 | # Arguments are: | ||||||
2325 | # transformed name of object being built, or empty string if no object | ||||||
2326 | # name of _LDADD/_LIBADD-type variable to examine | ||||||
2327 | # Returns 1 if LIBOBJS seen, 0 otherwise. | ||||||
2328 | sub handle_lib_objects | ||||||
2329 | { | ||||||
2330 | 172 | 465 | my ($xname, $varname) = @_; | ||||
2331 | |||||||
2332 | 172 | 444 | my $var = var ($varname); | ||||
2333 | 172 | 585 | prog_error "`$varname' undefined" | ||||
2334 | unless $var; | ||||||
2335 | 172 | 1396 | prog_error "unexpected variable name `$varname'" | ||||
2336 | unless $varname =~ /^(.*)(?:LIB|LD)ADD$/; | ||||||
2337 | 172 | 820 | my $prefix = $1 || 'AM_'; | ||||
2338 | |||||||
2339 | 172 | 258 | my $seen_libobjs = 0; | ||||
2340 | 172 | 258 | my $flagvar = 0; | ||||
2341 | |||||||
2342 | transform_variable_recursively | ||||||
2343 | ($varname, $xname . '_DEPENDENCIES', 'am__DEPENDENCIES', | ||||||
2344 | ! $xname, INTERNAL, | ||||||
2345 | # Transformation function, run on each filename. | ||||||
2346 | sub { | ||||||
2347 | 239 | 596 | my ($subvar, $val, $cond, $full_cond) = @_; | ||||
2348 | |||||||
2349 | 239 | 1882 | if ($val =~ /^-/) | ||||
2350 | { | ||||||
2351 | # Skip -lfoo and -Ldir silently; these are explicitly allowed. | ||||||
2352 | 12 | 114 | if ($val !~ /^-[lL]/ && | ||||
2353 | # Skip -dlopen and -dlpreopen; these are explicitly allowed | ||||||
2354 | # for Libtool libraries or programs. (Actually we are a bit | ||||||
2355 | # laxe here since this code also applies to non-libtool | ||||||
2356 | # libraries or programs, for which -dlopen and -dlopreopen | ||||||
2357 | # are pure nonsense. Diagnosing this doesn't seem very | ||||||
2358 | # important: the developer will quickly get complaints from | ||||||
2359 | # the linker.) | ||||||
2360 | $val !~ /^-dl(?:pre)?open$/ && | ||||||
2361 | # Only get this error once. | ||||||
2362 | ! $flagvar) | ||||||
2363 | { | ||||||
2364 | 0 | 0 | $flagvar = 1; | ||||
2365 | # FIXME: should display a stack of nested variables | ||||||
2366 | # as context when $var != $subvar. | ||||||
2367 | 0 | 0 | err_var ($var, "linker flags such as `$val' belong in " | ||||
2368 | . "`${prefix}LDFLAGS'"); | ||||||
2369 | } | ||||||
2370 | 12 | 34 | return (); | ||||
2371 | } | ||||||
2372 | elsif ($val !~ /^\@.*\@$/) | ||||||
2373 | { | ||||||
2374 | # Assume we have a file of some sort, and output it into the | ||||||
2375 | # dependency variable. Autoconf substitutions are not output; | ||||||
2376 | # rarely is a new dependency substituted into e.g. foo_LDADD | ||||||
2377 | # -- but bad things (e.g. -lX11) are routinely substituted. | ||||||
2378 | # Note that LIBOBJS and ALLOCA are exceptions to this rule, | ||||||
2379 | # and handled specially below. | ||||||
2380 | 114 | 382 | return $val; | ||||
2381 | } | ||||||
2382 | elsif ($val =~ /^\@(LT)?LIBOBJS\@$/) | ||||||
2383 | { | ||||||
2384 | 58 | 295 | handle_LIBOBJS ($subvar, $cond, $1); | ||||
2385 | 58 | 115 | $seen_libobjs = 1; | ||||
2386 | 58 | 191 | return $val; | ||||
2387 | } | ||||||
2388 | elsif ($val =~ /^\@(LT)?ALLOCA\@$/) | ||||||
2389 | { | ||||||
2390 | 14 | 57 | handle_ALLOCA ($subvar, $cond, $1); | ||||
2391 | 14 | 49 | return $val; | ||||
2392 | } | ||||||
2393 | else | ||||||
2394 | { | ||||||
2395 | 41 | 126 | return (); | ||||
2396 | } | ||||||
2397 | 172 | 2269 | }); | ||||
2398 | |||||||
2399 | 172 | 1615 | return $seen_libobjs; | ||||
2400 | } | ||||||
2401 | |||||||
2402 | # handle_LIBOBJS_or_ALLOCA ($VAR) | ||||||
2403 | # ------------------------------- | ||||||
2404 | # Definitions common to LIBOBJS and ALLOCA. | ||||||
2405 | # VAR should be one of LIBOBJS, LTLIBOBJS, ALLOCA, or LTALLOCA. | ||||||
2406 | sub handle_LIBOBJS_or_ALLOCA ($) | ||||||
2407 | { | ||||||
2408 | 72 | 168 | my ($var) = @_; | ||||
2409 | |||||||
2410 | 72 | 126 | my $dir = ''; | ||||
2411 | |||||||
2412 | # If LIBOBJS files must be built in another directory we have | ||||||
2413 | # to define LIBOBJDIR and ensure the files get cleaned. | ||||||
2414 | # Otherwise LIBOBJDIR can be left undefined, and the cleaning | ||||||
2415 | # is achieved by `rm -f *.$(OBJEXT)' in compile.am. | ||||||
2416 | 72 | 424 | if ($config_libobj_dir | ||||
2417 | && $relative_dir ne $config_libobj_dir) | ||||||
2418 | { | ||||||
2419 | 20 | 63 | if (option 'subdir-objects') | ||||
2420 | { | ||||||
2421 | # In the top-level Makefile we do not use $(top_builddir), because | ||||||
2422 | # we are already there, and since the targets are built without | ||||||
2423 | # a $(top_builddir), it helps BSD Make to match them with | ||||||
2424 | # dependencies. | ||||||
2425 | 14 | 47 | $dir = "$config_libobj_dir/" if $config_libobj_dir ne '.'; | ||||
2426 | 14 | 46 | $dir = "$topsrcdir/$dir" if $relative_dir ne '.'; | ||||
2427 | 14 | 36 | define_variable ('LIBOBJDIR', "$dir", INTERNAL); | ||||
2428 | 14 | 61 | $clean_files{"\$($var)"} = MOSTLY_CLEAN; | ||||
2429 | # If LTLIBOBJS is used, we must also clear LIBOBJS (which might | ||||||
2430 | # be created by libtool as a side-effect of creating LTLIBOBJS). | ||||||
2431 | 14 | 70 | $clean_files{"\$($var)"} = MOSTLY_CLEAN if $var =~ s/^LT//; | ||||
2432 | } | ||||||
2433 | else | ||||||
2434 | { | ||||||
2435 | 6 | 57 | error ("`\$($var)' cannot be used outside `$config_libobj_dir' if" | ||||
2436 | . " `subdir-objects' is not set"); | ||||||
2437 | } | ||||||
2438 | } | ||||||
2439 | |||||||
2440 | 72 | 176 | return $dir; | ||||
2441 | } | ||||||
2442 | |||||||
2443 | sub handle_LIBOBJS ($$$) | ||||||
2444 | { | ||||||
2445 | 58 | 208 | my ($var, $cond, $lt) = @_; | ||||
2446 | 58 | 290 | my $myobjext = $lt ? 'lo' : 'o'; | ||||
2447 | 58 | 166 | $lt ||= ''; | ||||
2448 | |||||||
2449 | 58 | 228 | $var->requires_variables ("\@${lt}LIBOBJS\@ used", $lt . 'LIBOBJS') | ||||
2450 | if ! keys %libsources; | ||||||
2451 | |||||||
2452 | 58 | 272 | my $dir = handle_LIBOBJS_or_ALLOCA "${lt}LIBOBJS"; | ||||
2453 | |||||||
2454 | 58 | 239 | foreach my $iter (keys %libsources) | ||||
2455 | { | ||||||
2456 | 71 | 406 | if ($iter =~ /\.[cly]$/) | ||||
2457 | { | ||||||
2458 | 71 | 297 | &saw_extension ($&); | ||||
2459 | 71 | 140 | &saw_extension ('.c'); | ||||
2460 | } | ||||||
2461 | |||||||
2462 | 71 | 319 | if ($iter =~ /\.h$/) | ||||
2463 | { | ||||||
2464 | 0 | 0 | require_libsource_with_macro ($cond, $var, FOREIGN, $iter); | ||||
2465 | } | ||||||
2466 | elsif ($iter ne 'alloca.c') | ||||||
2467 | { | ||||||
2468 | 69 | 150 | my $rewrite = $iter; | ||||
2469 | 69 | 333 | $rewrite =~ s/\.c$/.P$myobjext/; | ||||
2470 | 69 | 236 | $dep_files{$dir . '$(DEPDIR)/' . $rewrite} = 1; | ||||
2471 | 69 | 189 | $rewrite = "^" . quotemeta ($iter) . "\$"; | ||||
2472 | # Only require the file if it is not a built source. | ||||||
2473 | 69 | 188 | my $bs = var ('BUILT_SOURCES'); | ||||
2474 | 69 | 292 | if (! $bs || ! grep (/$rewrite/, $bs->value_as_list_recursive)) | ||||
2475 | { | ||||||
2476 | 68 | 225 | require_libsource_with_macro ($cond, $var, FOREIGN, $iter); | ||||
2477 | } | ||||||
2478 | } | ||||||
2479 | } | ||||||
2480 | } | ||||||
2481 | |||||||
2482 | sub handle_ALLOCA ($$$) | ||||||
2483 | { | ||||||
2484 | 14 | 49 | my ($var, $cond, $lt) = @_; | ||||
2485 | 14 | 45 | my $myobjext = $lt ? 'lo' : 'o'; | ||||
2486 | 14 | 40 | $lt ||= ''; | ||||
2487 | 14 | 72 | my $dir = handle_LIBOBJS_or_ALLOCA "${lt}ALLOCA"; | ||||
2488 | |||||||
2489 | 14 | 77 | $var->requires_variables ("\@${lt}ALLOCA\@ used", $lt . 'ALLOCA'); | ||||
2490 | 14 | 53 | $dep_files{$dir . '$(DEPDIR)/alloca.P' . $myobjext} = 1; | ||||
2491 | 14 | 63 | require_libsource_with_macro ($cond, $var, FOREIGN, 'alloca.c'); | ||||
2492 | 14 | 96 | &saw_extension ('.c'); | ||||
2493 | } | ||||||
2494 | |||||||
2495 | # Canonicalize the input parameter | ||||||
2496 | sub canonicalize | ||||||
2497 | { | ||||||
2498 | 1184 | 2486 | my ($string) = @_; | ||||
2499 | 1184 | 2703 | $string =~ tr/A-Za-z0-9_\@/_/c; | ||||
2500 | 1184 | 2452 | return $string; | ||||
2501 | } | ||||||
2502 | |||||||
2503 | # Canonicalize a name, and check to make sure the non-canonical name | ||||||
2504 | # is never used. Returns canonical name. Arguments are name and a | ||||||
2505 | # list of suffixes to check for. | ||||||
2506 | sub check_canonical_spelling | ||||||
2507 | { | ||||||
2508 | 1120 | 3676 | my ($name, @suffixes) = @_; | ||||
2509 | |||||||
2510 | 1120 | 3535 | my $xname = &canonicalize ($name); | ||||
2511 | 1120 | 3318 | if ($xname ne $name) | ||||
2512 | { | ||||||
2513 | 633 | 1436 | foreach my $xt (@suffixes) | ||||
2514 | { | ||||||
2515 | 3165 | 12089 | reject_var ("$name$xt", "use `$xname$xt', not `$name$xt'"); | ||||
2516 | } | ||||||
2517 | } | ||||||
2518 | |||||||
2519 | 1120 | 2631 | return $xname; | ||||
2520 | } | ||||||
2521 | |||||||
2522 | |||||||
2523 | # handle_compile () | ||||||
2524 | # ----------------- | ||||||
2525 | # Set up the compile suite. | ||||||
2526 | sub handle_compile () | ||||||
2527 | { | ||||||
2528 | return | ||||||
2529 | 1319 | 4419 | unless $get_object_extension_was_run; | ||||
2530 | |||||||
2531 | # Boilerplate. | ||||||
2532 | 576 | 1183 | my $default_includes = ''; | ||||
2533 | 576 | 1642 | if (! option 'nostdinc') | ||||
2534 | { | ||||||
2535 | 575 | 1970 | my @incs = ('-I.', subst ('am__isrc')); | ||||
2536 | |||||||
2537 | 575 | 1730 | my $var = var 'CONFIG_HEADER'; | ||||
2538 | 575 | 1488 | if ($var) | ||||
2539 | { | ||||||
2540 | 5 | 19 | foreach my $hdr (split (' ', $var->variable_value)) | ||||
2541 | { | ||||||
2542 | 6 | 130 | push @incs, '-I' . dirname ($hdr); | ||||
2543 | } | ||||||
2544 | } | ||||||
2545 | # We want `-I. -I$(srcdir)', but the latter -I is redundant | ||||||
2546 | # and unaesthetic in non-VPATH builds. We use `-I.@am__isrc@` | ||||||
2547 | # instead. It will be replaced by '-I.' or '-I. -I$(srcdir)'. | ||||||
2548 | # Items in CONFIG_HEADER are never in $(srcdir) so it is safe | ||||||
2549 | # to just put @am__isrc@ right after `-I.', without a space. | ||||||
2550 | 575 | 4262 | ($default_includes = ' ' . uniq (@incs)) =~ s/ @/@/; | ||||
2551 | } | ||||||
2552 | |||||||
2553 | 576 | 1241 | my (@mostly_rms, @dist_rms); | ||||
2554 | 576 | 3169 | foreach my $item (sort keys %compile_clean_files) | ||||
2555 | { | ||||||
2556 | 51 | 149 | if ($compile_clean_files{$item} == MOSTLY_CLEAN) | ||||
2557 | { | ||||||
2558 | 51 | 166 | push (@mostly_rms, "\t-rm -f $item"); | ||||
2559 | } | ||||||
2560 | elsif ($compile_clean_files{$item} == DIST_CLEAN) | ||||||
2561 | { | ||||||
2562 | 0 | 0 | push (@dist_rms, "\t-rm -f $item"); | ||||
2563 | } | ||||||
2564 | else | ||||||
2565 | { | ||||||
2566 | 0 | 0 | prog_error 'invalid entry in %compile_clean_files'; | ||||
2567 | } | ||||||
2568 | } | ||||||
2569 | |||||||
2570 | 576 | 2551 | $output_rules .= &file_contents ('compile', | ||||
2571 | new Automake::Location, | ||||||
2572 | 'DEFAULT_INCLUDES' => $default_includes, | ||||||
2573 | 'MOSTLYRMS' => join ("\n", @mostly_rms), | ||||||
2574 | 'DISTRMS' => join ("\n", @dist_rms)); | ||||||
2575 | |||||||
2576 | # Check for automatic de-ANSI-fication. | ||||||
2577 | 576 | 2698 | if (option 'ansi2knr') | ||||
2578 | { | ||||||
2579 | 13 13 | 24 33 | my ($ansi2knr_filename, $ansi2knr_where) = @{option 'ansi2knr'}; | ||||
2580 | 13 | 21 | my $ansi2knr_dir = ''; | ||||
2581 | |||||||
2582 | 13 | 76 | require_variables ($ansi2knr_where, "option `ansi2knr' is used", | ||||
2583 | TRUE, "ANSI2KNR", "U"); | ||||||
2584 | |||||||
2585 | # topdir is where ansi2knr should be. | ||||||
2586 | 13 | 37 | if ($ansi2knr_filename eq 'ansi2knr') | ||||
2587 | { | ||||||
2588 | # Only require ansi2knr files if they should appear in | ||||||
2589 | # this directory. | ||||||
2590 | 12 | 40 | require_file ($ansi2knr_where, FOREIGN, | ||||
2591 | 'ansi2knr.c', 'ansi2knr.1'); | ||||||
2592 | |||||||
2593 | # ansi2knr needs to be built before subdirs, so unshift it. | ||||||
2594 | 12 | 35 | unshift (@all, '$(ANSI2KNR)'); | ||||
2595 | } | ||||||
2596 | else | ||||||
2597 | { | ||||||
2598 | 1 | 3 | $ansi2knr_dir = dirname ($ansi2knr_filename); | ||||
2599 | } | ||||||
2600 | |||||||
2601 | 13 | 152 | $output_rules .= &file_contents ('ansi2knr', | ||||
2602 | new Automake::Location, | ||||||
2603 | 'ANSI2KNR-DIR' => $ansi2knr_dir); | ||||||
2604 | |||||||
2605 | } | ||||||
2606 | } | ||||||
2607 | |||||||
2608 | # handle_libtool () | ||||||
2609 | # ----------------- | ||||||
2610 | # Handle libtool rules. | ||||||
2611 | sub handle_libtool | ||||||
2612 | { | ||||||
2613 | 1319 | 4316 | return unless var ('LIBTOOL'); | ||||
2614 | |||||||
2615 | # Libtool requires some files, but only at top level. | ||||||
2616 | # (Starting with Libtool 2.0 we do not have to bother. These | ||||||
2617 | # requirements are done with AC_REQUIRE_AUX_FILE.) | ||||||
2618 | 92 | 828 | require_conf_file_with_macro (TRUE, 'LIBTOOL', FOREIGN, @libtool_files) | ||||
2619 | if $relative_dir eq '.' && ! $libtool_new_api; | ||||||
2620 | |||||||
2621 | 92 | 133 | my @libtool_rms; | ||||
2622 | 92 | 481 | foreach my $item (sort keys %libtool_clean_directories) | ||||
2623 | { | ||||||
2624 | 113 | 362 | my $dir = ($item eq '.') ? '' : "$item/"; | ||||
2625 | # .libs is for Unix, _libs for DOS. | ||||||
2626 | 113 | 433 | push (@libtool_rms, "\t-rm -rf ${dir}.libs ${dir}_libs"); | ||||
2627 | } | ||||||
2628 | |||||||
2629 | 92 | 252 | check_user_variables 'LIBTOOLFLAGS'; | ||||
2630 | |||||||
2631 | # Output the libtool compilation rules. | ||||||
2632 | 92 | 361 | $output_rules .= &file_contents ('libtool', | ||||
2633 | new Automake::Location, | ||||||
2634 | LTRMS => join ("\n", @libtool_rms)); | ||||||
2635 | } | ||||||
2636 | |||||||
2637 | # handle_programs () | ||||||
2638 | # ------------------ | ||||||
2639 | # Handle C programs. | ||||||
2640 | sub handle_programs | ||||||
2641 | { | ||||||
2642 | 1319 | 5232 | my @proglist = &am_install_var ('progs', 'PROGRAMS', | ||||
2643 | 'bin', 'sbin', 'libexec', 'pkglib', | ||||||
2644 | 'noinst', 'check'); | ||||||
2645 | 1319 | 4396 | return if ! @proglist; | ||||
2646 | |||||||
2647 | 475 | 1508 | my $seen_global_libobjs = | ||||
2648 | var ('LDADD') && &handle_lib_objects ('', 'LDADD'); | ||||||
2649 | |||||||
2650 | 475 | 1930 | foreach my $pair (@proglist) | ||||
2651 | { | ||||||
2652 | 734 | 1749 | my ($where, $one_file) = @$pair; | ||||
2653 | |||||||
2654 | 734 | 1050 | my $seen_libobjs = 0; | ||||
2655 | 734 | 2672 | my $obj = get_object_extension '.$(OBJEXT)'; | ||||
2656 | |||||||
2657 | 734 | 1676 | $known_programs{$one_file} = $where; | ||||
2658 | |||||||
2659 | # Canonicalize names and check for misspellings. | ||||||
2660 | 734 | 3346 | my $xname = &check_canonical_spelling ($one_file, '_LDADD', '_LDFLAGS', | ||||
2661 | '_SOURCES', '_OBJECTS', | ||||||
2662 | '_DEPENDENCIES'); | ||||||
2663 | |||||||
2664 | 734 | 2974 | $where->push_context ("while processing program `$one_file'"); | ||||
2665 | 734 | 1995 | $where->set (INTERNAL->get); | ||||
2666 | |||||||
2667 | 734 | 3820 | my $linker = &handle_source_transform ($xname, $one_file, $obj, $where, | ||||
2668 | NONLIBTOOL => 1, LIBTOOL => 0); | ||||||
2669 | |||||||
2670 | 734 | 2715 | if (var ($xname . "_LDADD")) | ||||
2671 | { | ||||||
2672 | 70 | 327 | $seen_libobjs = &handle_lib_objects ($xname, $xname . '_LDADD'); | ||||
2673 | } | ||||||
2674 | else | ||||||
2675 | { | ||||||
2676 | # User didn't define prog_LDADD override. So do it. | ||||||
2677 | 664 | 2229 | &define_variable ($xname . '_LDADD', '$(LDADD)', $where); | ||||
2678 | |||||||
2679 | # This does a bit too much work. But we need it to | ||||||
2680 | # generate _DEPENDENCIES when appropriate. | ||||||
2681 | 664 | 1958 | if (var ('LDADD')) | ||||
2682 | { | ||||||
2683 | 24 | 61 | $seen_libobjs = &handle_lib_objects ($xname, 'LDADD'); | ||||
2684 | } | ||||||
2685 | } | ||||||
2686 | |||||||
2687 | 734 | 3736 | reject_var ($xname . '_LIBADD', | ||||
2688 | "use `${xname}_LDADD', not `${xname}_LIBADD'"); | ||||||
2689 | |||||||
2690 | 734 | 2256 | set_seen ($xname . '_DEPENDENCIES'); | ||||
2691 | 734 | 2375 | set_seen ('EXTRA_' . $xname . '_DEPENDENCIES'); | ||||
2692 | 734 | 2196 | set_seen ($xname . '_LDFLAGS'); | ||||
2693 | |||||||
2694 | # Determine program to use for link. | ||||||
2695 | 734 | 3067 | my($xlink, $vlink) = &define_per_target_linker_variable ($linker, $xname); | ||||
2696 | 734 | 3088 | $vlink = verbose_flag ($vlink || 'GEN'); | ||||
2697 | |||||||
2698 | # If the resulting program lies into a subdirectory, | ||||||
2699 | # make sure this directory will exist. | ||||||
2700 | 734 | 2400 | my $dirstamp = require_build_directory_maybe ($one_file); | ||||
2701 | |||||||
2702 | 734 | 2100 | $libtool_clean_directories{dirname ($one_file)} = 1; | ||||
2703 | |||||||
2704 | 734 | 68142 | $output_rules .= &file_contents ('program', | ||||
2705 | $where, | ||||||
2706 | PROGRAM => $one_file, | ||||||
2707 | XPROGRAM => $xname, | ||||||
2708 | XLINK => $xlink, | ||||||
2709 | VERBOSE => $vlink, | ||||||
2710 | DIRSTAMP => $dirstamp, | ||||||
2711 | EXEEXT => '$(EXEEXT)'); | ||||||
2712 | |||||||
2713 | 734 | 6877 | if ($seen_libobjs || $seen_global_libobjs) | ||||
2714 | { | ||||||
2715 | 15 | 62 | if (var ($xname . '_LDADD')) | ||||
2716 | { | ||||||
2717 | 15 | 73 | &check_libobjs_sources ($xname, $xname . '_LDADD'); | ||||
2718 | } | ||||||
2719 | elsif (var ('LDADD')) | ||||||
2720 | { | ||||||
2721 | 0 | 0 | &check_libobjs_sources ($xname, 'LDADD'); | ||||
2722 | } | ||||||
2723 | } | ||||||
2724 | } | ||||||
2725 | } | ||||||
2726 | |||||||
2727 | |||||||
2728 | # handle_libraries () | ||||||
2729 | # ------------------- | ||||||
2730 | # Handle libraries. | ||||||
2731 | sub handle_libraries | ||||||
2732 | { | ||||||
2733 | 1319 | 7282 | my @liblist = &am_install_var ('libs', 'LIBRARIES', | ||||
2734 | 'lib', 'pkglib', 'noinst', 'check'); | ||||||
2735 | 1319 | 5706 | return if ! @liblist; | ||||
2736 | |||||||
2737 | 161 | 560 | my @prefix = am_primary_prefixes ('LIBRARIES', 0, 'lib', 'pkglib', | ||||
2738 | 'noinst', 'check'); | ||||||
2739 | |||||||
2740 | 161 | 1518 | if (@prefix) | ||||
2741 | { | ||||||
2742 | 161 | 600 | my $var = rvar ($prefix[0] . '_LIBRARIES'); | ||||
2743 | 161 | 721 | $var->requires_variables ('library used', 'RANLIB'); | ||||
2744 | } | ||||||
2745 | |||||||
2746 | 161 | 502 | &define_variable ('AR', 'ar', INTERNAL); | ||||
2747 | 161 | 558 | &define_variable ('ARFLAGS', 'cru', INTERNAL); | ||||
2748 | 161 | 874 | &define_verbose_tagvar ('AR'); | ||||
2749 | |||||||
2750 | 161 | 628 | foreach my $pair (@liblist) | ||||
2751 | { | ||||||
2752 | 274 | 754 | my ($where, $onelib) = @$pair; | ||||
2753 | |||||||
2754 | 274 | 410 | my $seen_libobjs = 0; | ||||
2755 | # Check that the library fits the standard naming convention. | ||||||
2756 | 274 | 944 | my $bn = basename ($onelib); | ||||
2757 | 274 | 1895 | if ($bn !~ /^lib.*\.a$/) | ||||
2758 | { | ||||||
2759 | 1 | 11 | $bn =~ s/^(?:lib)?(.*?)(?:\.[^.]*)?$/lib$1.a/; | ||||
2760 | 1 | 2 | my $suggestion = dirname ($onelib) . "/$bn"; | ||||
2761 | 1 | 103 | $suggestion =~ s|^\./||g; | ||||
2762 | 1 | 5 | msg ('error-gnu/warn', $where, | ||||
2763 | "`$onelib' is not a standard library name\n" | ||||||
2764 | . "did you mean `$suggestion'?") | ||||||
2765 | } | ||||||
2766 | |||||||
2767 | 274 | 1411 | ($known_libraries{$onelib} = $bn) =~ s/\.a$//; | ||||
2768 | |||||||
2769 | 274 | 1326 | $where->push_context ("while processing library `$onelib'"); | ||||
2770 | 274 | 763 | $where->set (INTERNAL->get); | ||||
2771 | |||||||
2772 | 274 | 1197 | my $obj = get_object_extension '.$(OBJEXT)'; | ||||
2773 | |||||||
2774 | # Canonicalize names and check for misspellings. | ||||||
2775 | 274 | 1516 | my $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_SOURCES', | ||||
2776 | '_OBJECTS', '_DEPENDENCIES', | ||||||
2777 | '_AR'); | ||||||
2778 | |||||||
2779 | 274 | 820 | if (! var ($xlib . '_AR')) | ||||
2780 | { | ||||||
2781 | 274 | 1176 | &define_variable ($xlib . '_AR', '$(AR) $(ARFLAGS)', $where); | ||||
2782 | } | ||||||
2783 | |||||||
2784 | # Generate support for conditional object inclusion in | ||||||
2785 | # libraries. | ||||||
2786 | 274 | 1024 | if (var ($xlib . '_LIBADD')) | ||||
2787 | { | ||||||
2788 | 37 | 270 | if (&handle_lib_objects ($xlib, $xlib . '_LIBADD')) | ||||
2789 | { | ||||||
2790 | 27 | 53 | $seen_libobjs = 1; | ||||
2791 | } | ||||||
2792 | } | ||||||
2793 | else | ||||||
2794 | { | ||||||
2795 | 237 | 650 | &define_variable ($xlib . "_LIBADD", '', $where); | ||||
2796 | } | ||||||
2797 | |||||||
2798 | 274 | 1395 | reject_var ($xlib . '_LDADD', | ||||
2799 | "use `${xlib}_LIBADD', not `${xlib}_LDADD'"); | ||||||
2800 | |||||||
2801 | # Make sure we at look at this. | ||||||
2802 | 274 | 956 | set_seen ($xlib . '_DEPENDENCIES'); | ||||
2803 | 274 | 900 | set_seen ('EXTRA_' . $xlib . '_DEPENDENCIES'); | ||||
2804 | |||||||
2805 | 274 | 1494 | &handle_source_transform ($xlib, $onelib, $obj, $where, | ||||
2806 | NONLIBTOOL => 1, LIBTOOL => 0); | ||||||
2807 | |||||||
2808 | # If the resulting library lies into a subdirectory, | ||||||
2809 | # make sure this directory will exist. | ||||||
2810 | 274 | 908 | my $dirstamp = require_build_directory_maybe ($onelib); | ||||
2811 | 274 | 839 | my $verbose = verbose_flag ('AR'); | ||||
2812 | 274 | 658 | my $silent = silent_flag (); | ||||
2813 | |||||||
2814 | 274 | 1032 | $output_rules .= &file_contents ('library', | ||||
2815 | $where, | ||||||
2816 | VERBOSE => $verbose, | ||||||
2817 | SILENT => $silent, | ||||||
2818 | LIBRARY => $onelib, | ||||||
2819 | XLIBRARY => $xlib, | ||||||
2820 | DIRSTAMP => $dirstamp); | ||||||
2821 | |||||||
2822 | 274 | 1479 | if ($seen_libobjs) | ||||
2823 | { | ||||||
2824 | 27 | 105 | if (var ($xlib . '_LIBADD')) | ||||
2825 | { | ||||||
2826 | 27 | 167 | &check_libobjs_sources ($xlib, $xlib . '_LIBADD'); | ||||
2827 | } | ||||||
2828 | } | ||||||
2829 | } | ||||||
2830 | } | ||||||
2831 | |||||||
2832 | |||||||
2833 | # handle_ltlibraries () | ||||||
2834 | # --------------------- | ||||||
2835 | # Handle shared libraries. | ||||||
2836 | sub handle_ltlibraries | ||||||
2837 | { | ||||||
2838 | 1319 | 5324 | my @liblist = &am_install_var ('ltlib', 'LTLIBRARIES', | ||||
2839 | 'noinst', 'lib', 'pkglib', 'check'); | ||||||
2840 | 1319 | 4653 | return if ! @liblist; | ||||
2841 | |||||||
2842 | 73 | 247 | my @prefix = am_primary_prefixes ('LTLIBRARIES', 0, 'lib', 'pkglib', | ||||
2843 | 'noinst', 'check'); | ||||||
2844 | |||||||
2845 | 73 | 405 | if (@prefix) | ||||
2846 | { | ||||||
2847 | 73 | 278 | my $var = rvar ($prefix[0] . '_LTLIBRARIES'); | ||||
2848 | 73 | 428 | $var->requires_variables ('Libtool library used', 'LIBTOOL'); | ||||
2849 | } | ||||||
2850 | |||||||
2851 | 73 | 171 | my %instdirs = (); | ||||
2852 | 73 | 112 | my %instsubdirs = (); | ||||
2853 | 73 | 127 | my %instconds = (); | ||||
2854 | 73 | 125 | my %liblocations = (); # Location (in Makefile.am) of each library. | ||||
2855 | |||||||
2856 | 73 | 250 | foreach my $key (@prefix) | ||||
2857 | { | ||||||
2858 | # Get the installation directory of each library. | ||||||
2859 | 87 | 149 | my $dir = $key; | ||||
2860 | 87 | 153 | my $strip_subdir = 1; | ||||
2861 | 87 | 337 | if ($dir =~ /^nobase_/) | ||||
2862 | { | ||||||
2863 | 7 | 23 | $dir =~ s/^nobase_//; | ||||
2864 | 7 | 10 | $strip_subdir = 0; | ||||
2865 | } | ||||||
2866 | 87 | 339 | my $var = rvar ($key . '_LTLIBRARIES'); | ||||
2867 | |||||||
2868 | # We reject libraries which are installed in several places | ||||||
2869 | # in the same condition, because we can only specify one | ||||||
2870 | # `-rpath' option. | ||||||
2871 | $var->traverse_recursively | ||||||
2872 | (sub | ||||||
2873 | { | ||||||
2874 | 121 | 298 | my ($var, $val, $cond, $full_cond) = @_; | ||||
2875 | 121 | 433 | my $hcond = $full_cond->human; | ||||
2876 | 121 | 364 | my $where = $var->rdef ($cond)->location; | ||||
2877 | 121 | 197 | my $ldir = ''; | ||||
2878 | 121 | 332 | $ldir = '/' . dirname ($val) | ||||
2879 | if (!$strip_subdir); | ||||||
2880 | # A library cannot be installed in different directories | ||||||
2881 | # in overlapping conditions. | ||||||
2882 | 121 | 1830 | if (exists $instconds{$val}) | ||||
2883 | { | ||||||
2884 | 9 | 29 | my ($msg, $acond) = | ||||
2885 | $instconds{$val}->ambiguous_p ($val, $full_cond); | ||||||
2886 | |||||||
2887 | 9 | 23 | if ($msg) | ||||
2888 | { | ||||||
2889 | 4 | 18 | error ($where, $msg, partial => 1); | ||||
2890 | 4 | 19 | my $dirtxt = "installed " . ($strip_subdir ? "in" : "below") . " `$dir'"; | ||||
2891 | 4 | 46 | $dirtxt = "built for `$dir'" | ||||
2892 | if $dir eq 'EXTRA' || $dir eq 'noinst' || $dir eq 'check'; | ||||||
2893 | 4 | 13 | my $dircond = | ||||
2894 | $full_cond->true ? "" : " in condition $hcond"; | ||||||
2895 | |||||||
2896 | 4 | 19 | error ($where, "`$val' should be $dirtxt$dircond ...", | ||||
2897 | partial => 1); | ||||||
2898 | |||||||
2899 | 4 | 13 | my $hacond = $acond->human; | ||||
2900 | 4 | 9 | my $adir = $instdirs{$val}{$acond}; | ||||
2901 | 4 | 8 | my $adirtxt = "installed in `$adir'"; | ||||
2902 | 4 | 40 | $adirtxt = "built for `$adir'" | ||||
2903 | if ($adir eq 'EXTRA' || $adir eq 'noinst' | ||||||
2904 | || $adir eq 'check'); | ||||||
2905 | 4 | 10 | my $adircond = $acond->true ? "" : " in condition $hacond"; | ||||
2906 | |||||||
2907 | 4 | 10 | my $onlyone = ($dir ne $adir) ? | ||||
2908 | ("\nLibtool libraries can be built for only one " | ||||||
2909 | . "destination") : ""; | ||||||
2910 | |||||||
2911 | 4 | 20 | error ($liblocations{$val}{$acond}, | ||||
2912 | "... and should also be $adirtxt$adircond.$onlyone"); | ||||||
2913 | 4 | 15 | return; | ||||
2914 | } | ||||||
2915 | } | ||||||
2916 | else | ||||||
2917 | { | ||||||
2918 | 112 | 359 | $instconds{$val} = new Automake::DisjConditions; | ||||
2919 | } | ||||||
2920 | 117 | 399 | $instdirs{$val}{$full_cond} = $dir; | ||||
2921 | 117 | 327 | $instsubdirs{$val}{$full_cond} = $ldir; | ||||
2922 | 117 | 311 | $liblocations{$val}{$full_cond} = $where; | ||||
2923 | 117 | 546 | $instconds{$val} = $instconds{$val}->merge ($full_cond); | ||||
2924 | }, | ||||||
2925 | sub | ||||||
2926 | { | ||||||
2927 | 90 | 1654 | return (); | ||||
2928 | }, | ||||||
2929 | 87 | 1960 | skip_ac_subst => 1); | ||||
2930 | } | ||||||
2931 | |||||||
2932 | 73 | 195 | foreach my $pair (@liblist) | ||||
2933 | { | ||||||
2934 | 112 | 268 | my ($where, $onelib) = @$pair; | ||||
2935 | |||||||
2936 | 112 | 160 | my $seen_libobjs = 0; | ||||
2937 | 112 | 508 | my $obj = get_object_extension '.lo'; | ||||
2938 | |||||||
2939 | # Canonicalize names and check for misspellings. | ||||||
2940 | 112 | 620 | my $xlib = &check_canonical_spelling ($onelib, '_LIBADD', '_LDFLAGS', | ||||
2941 | '_SOURCES', '_OBJECTS', | ||||||
2942 | '_DEPENDENCIES'); | ||||||
2943 | |||||||
2944 | # Check that the library fits the standard naming convention. | ||||||
2945 | 112 | 159 | my $libname_rx = '^lib.*\.la'; | ||||
2946 | 112 | 357 | my $ldvar = var ("${xlib}_LDFLAGS") || var ('AM_LDFLAGS'); | ||||
2947 | 112 | 294 | my $ldvar2 = var ('LDFLAGS'); | ||||
2948 | 112 | 1003 | if (($ldvar && grep (/-module/, $ldvar->value_as_list_recursive)) | ||||
2949 | || ($ldvar2 && grep (/-module/, $ldvar2->value_as_list_recursive))) | ||||||
2950 | { | ||||||
2951 | # Relax name checking for libtool modules. | ||||||
2952 | 16 | 30 | $libname_rx = '\.la'; | ||||
2953 | } | ||||||
2954 | |||||||
2955 | 112 | 896 | my $bn = basename ($onelib); | ||||
2956 | 112 | 1509 | if ($bn !~ /$libname_rx$/) | ||||
2957 | { | ||||||
2958 | 5 | 11 | my $type = 'library'; | ||||
2959 | 5 | 12 | if ($libname_rx eq '\.la') | ||||
2960 | { | ||||||
2961 | 1 | 11 | $bn =~ s/^(lib|)(.*?)(?:\.[^.]*)?$/$1$2.la/; | ||||
2962 | 1 | 2 | $type = 'module'; | ||||
2963 | } | ||||||
2964 | else | ||||||
2965 | { | ||||||
2966 | 4 | 52 | $bn =~ s/^(?:lib)?(.*?)(?:\.[^.]*)?$/lib$1.la/; | ||||
2967 | } | ||||||
2968 | 5 | 29 | my $suggestion = dirname ($onelib) . "/$bn"; | ||||
2969 | 5 | 581 | $suggestion =~ s|^\./||g; | ||||
2970 | 5 | 40 | msg ('error-gnu/warn', $where, | ||||
2971 | "`$onelib' is not a standard libtool $type name\n" | ||||||
2972 | . "did you mean `$suggestion'?") | ||||||
2973 | } | ||||||
2974 | |||||||
2975 | 112 | 639 | ($known_libraries{$onelib} = $bn) =~ s/\.la$//; | ||||
2976 | |||||||
2977 | 112 | 527 | $where->push_context ("while processing Libtool library `$onelib'"); | ||||
2978 | 112 | 332 | $where->set (INTERNAL->get); | ||||
2979 | |||||||
2980 | # Make sure we look at these. | ||||||
2981 | 112 | 394 | set_seen ($xlib . '_LDFLAGS'); | ||||
2982 | 112 | 361 | set_seen ($xlib . '_DEPENDENCIES'); | ||||
2983 | 112 | 387 | set_seen ('EXTRA_' . $xlib . '_DEPENDENCIES'); | ||||
2984 | |||||||
2985 | # Generate support for conditional object inclusion in | ||||||
2986 | # libraries. | ||||||
2987 | 112 | 388 | if (var ($xlib . '_LIBADD')) | ||||
2988 | { | ||||||
2989 | 26 | 174 | if (&handle_lib_objects ($xlib, $xlib . '_LIBADD')) | ||||
2990 | { | ||||||
2991 | 13 | 25 | $seen_libobjs = 1; | ||||
2992 | } | ||||||
2993 | } | ||||||
2994 | else | ||||||
2995 | { | ||||||
2996 | 86 | 315 | &define_variable ($xlib . "_LIBADD", '', $where); | ||||
2997 | } | ||||||
2998 | |||||||
2999 | 112 | 600 | reject_var ("${xlib}_LDADD", | ||||
3000 | "use `${xlib}_LIBADD', not `${xlib}_LDADD'"); | ||||||
3001 | |||||||
3002 | |||||||
3003 | 112 | 663 | my $linker = &handle_source_transform ($xlib, $onelib, $obj, $where, | ||||
3004 | NONLIBTOOL => 0, LIBTOOL => 1); | ||||||
3005 | |||||||
3006 | # Determine program to use for link. | ||||||
3007 | 112 | 498 | my($xlink, $vlink) = &define_per_target_linker_variable ($linker, $xlib); | ||||
3008 | 112 | 425 | $vlink = verbose_flag ($vlink || 'GEN'); | ||||
3009 | |||||||
3010 | 112 | 296 | my $rpathvar = "am_${xlib}_rpath"; | ||||
3011 | 112 | 247 | my $rpath = "\$($rpathvar)"; | ||||
3012 | 112 | 430 | foreach my $rcond ($instconds{$onelib}->conds) | ||||
3013 | { | ||||||
3014 | 117 | 153 | my $val; | ||||
3015 | 117 | 1634 | if ($instdirs{$onelib}{$rcond} eq 'EXTRA' | ||||
3016 | || $instdirs{$onelib}{$rcond} eq 'noinst' | ||||||
3017 | || $instdirs{$onelib}{$rcond} eq 'check') | ||||||
3018 | { | ||||||
3019 | # It's an EXTRA_ library, so we can't specify -rpath, | ||||||
3020 | # because we don't know where the library will end up. | ||||||
3021 | # The user probably knows, but generally speaking automake | ||||||
3022 | # doesn't -- and in fact configure could decide | ||||||
3023 | # dynamically between two different locations. | ||||||
3024 | 36 | 70 | $val = ''; | ||||
3025 | } | ||||||
3026 | else | ||||||
3027 | { | ||||||
3028 | 81 | 289 | $val = ('-rpath $(' . $instdirs{$onelib}{$rcond} . 'dir)'); | ||||
3029 | 81 | 475 | $val .= $instsubdirs{$onelib}{$rcond} | ||||
3030 | if defined $instsubdirs{$onelib}{$rcond}; | ||||||
3031 | } | ||||||
3032 | 117 | 357 | if ($rcond->true) | ||||
3033 | { | ||||||
3034 | # If $rcond is true there is only one condition and | ||||||
3035 | # there is no point defining an helper variable. | ||||||
3036 | 99 | 274 | $rpath = $val; | ||||
3037 | } | ||||||
3038 | else | ||||||
3039 | { | ||||||
3040 | 18 | 41 | define_pretty_variable ($rpathvar, $rcond, INTERNAL, $val); | ||||
3041 | } | ||||||
3042 | } | ||||||
3043 | |||||||
3044 | # If the resulting library lies into a subdirectory, | ||||||
3045 | # make sure this directory will exist. | ||||||
3046 | 112 | 407 | my $dirstamp = require_build_directory_maybe ($onelib); | ||||
3047 | |||||||
3048 | # Remember to cleanup .libs/ in this directory. | ||||||
3049 | 112 | 292 | my $dirname = dirname $onelib; | ||||
3050 | 112 | 10323 | $libtool_clean_directories{$dirname} = 1; | ||||
3051 | |||||||
3052 | 112 | 488 | $output_rules .= &file_contents ('ltlibrary', | ||||
3053 | $where, | ||||||
3054 | LTLIBRARY => $onelib, | ||||||
3055 | XLTLIBRARY => $xlib, | ||||||
3056 | RPATH => $rpath, | ||||||
3057 | XLINK => $xlink, | ||||||
3058 | VERBOSE => $vlink, | ||||||
3059 | DIRSTAMP => $dirstamp); | ||||||
3060 | 112 | 793 | if ($seen_libobjs) | ||||
3061 | { | ||||||
3062 | 13 | 55 | if (var ($xlib . '_LIBADD')) | ||||
3063 | { | ||||||
3064 | 13 | 83 | &check_libobjs_sources ($xlib, $xlib . '_LIBADD'); | ||||
3065 | } | ||||||
3066 | } | ||||||
3067 | } | ||||||
3068 | } | ||||||
3069 | |||||||
3070 | # See if any _SOURCES variable were misspelled. | ||||||
3071 | sub check_typos () | ||||||
3072 | { | ||||||
3073 | # It is ok if the user sets this particular variable. | ||||||
3074 | 1319 | 5531 | set_seen 'AM_LDFLAGS'; | ||||
3075 | |||||||
3076 | 1319 | 6845 | foreach my $primary ('SOURCES', 'LIBADD', 'LDADD', 'LDFLAGS', 'DEPENDENCIES') | ||||
3077 | { | ||||||
3078 | 6595 | 16509 | foreach my $var (variables $primary) | ||||
3079 | { | ||||||
3080 | 3828 | 10055 | my $varname = $var->name; | ||||
3081 | # A configure variable is always legitimate. | ||||||
3082 | 3828 | 10681 | next if exists $configure_vars{$varname}; | ||||
3083 | |||||||
3084 | 3827 | 10670 | for my $cond ($var->conditions->conds) | ||||
3085 | { | ||||||
3086 | 3898 | 21692 | $varname =~ /^(?:EXTRA_)?(?:nobase_)?(?:dist_|nodist_)?(.*)_[[:alnum:]]+$/; | ||||
3087 | 3898 | 11329 | msg_var ('syntax', $var, "variable `$varname' is defined but no" | ||||
3088 | . " program or\nlibrary has `$1' as canonical name" | ||||||
3089 | . " (possible typo)") | ||||||
3090 | unless $var->rdef ($cond)->seen; | ||||||
3091 | } | ||||||
3092 | } | ||||||
3093 | } | ||||||
3094 | } | ||||||
3095 | |||||||
3096 | |||||||
3097 | # Handle scripts. | ||||||
3098 | sub handle_scripts | ||||||
3099 | { | ||||||
3100 | # NOTE we no longer automatically clean SCRIPTS, because it is | ||||||
3101 | # useful to sometimes distribute scripts verbatim. This happens | ||||||
3102 | # e.g. in Automake itself. | ||||||
3103 | 1319 | 4976 | &am_install_var ('-candist', 'scripts', 'SCRIPTS', | ||||
3104 | 'bin', 'sbin', 'libexec', 'pkgdata', | ||||||
3105 | 'noinst', 'check'); | ||||||
3106 | } | ||||||
3107 | |||||||
3108 | |||||||
3109 | |||||||
3110 | |||||||
3111 | ## ------------------------ ## | ||||||
3112 | ## Handling Texinfo files. ## | ||||||
3113 | ## ------------------------ ## | ||||||
3114 | |||||||
3115 | # ($OUTFILE, $VFILE, @CLEAN_FILES) | ||||||
3116 | # &scan_texinfo_file ($FILENAME) | ||||||
3117 | # ------------------------------ | ||||||
3118 | # $OUTFILE - name of the info file produced by $FILENAME. | ||||||
3119 | # $VFILE - name of the version.texi file used (undef if none). | ||||||
3120 | # @CLEAN_FILES - list of byproducts (indexes etc.) | ||||||
3121 | sub scan_texinfo_file ($) | ||||||
3122 | { | ||||||
3123 | 61 | 145 | my ($filename) = @_; | ||||
3124 | |||||||
3125 | # Some of the following extensions are always created, no matter | ||||||
3126 | # whether indexes are used or not. Other (like cps, fns, ... pgs) | ||||||
3127 | # are only created when they are used. We used to scan $FILENAME | ||||||
3128 | # for their use, but that is not enough: they could be used in | ||||||
3129 | # included files. We can't scan included files because we don't | ||||||
3130 | # know the include path. Therefore we always erase these files, no | ||||||
3131 | # matter whether they are used or not. | ||||||
3132 | # | ||||||
3133 | # (tmp is only created if an @macro is used and a certain e-TeX | ||||||
3134 | # feature is not available.) | ||||||
3135 | 976 | 2186 | my %clean_suffixes = | ||||
3136 | 61 | 222 | map { $_ => 1 } (qw(aux log toc tmp | ||||
3137 | cp cps | ||||||
3138 | fn fns | ||||||
3139 | ky kys | ||||||
3140 | vr vrs | ||||||
3141 | tp tps | ||||||
3142 | pg pgs)); # grep 'new.*index' texinfo.tex | ||||||
3143 | |||||||
3144 | 61 | 520 | my $texi = new Automake::XFile "< $filename"; | ||||
3145 | 61 | 297 | verb "reading $filename"; | ||||
3146 | |||||||
3147 | 61 | 151 | my ($outfile, $vfile); | ||||
3148 | 61 | 232 | while ($_ = $texi->getline) | ||||
3149 | { | ||||||
3150 | 251 | 1643 | if (/^\@setfilename +(\S+)/) | ||||
3151 | { | ||||||
3152 | # Honor only the first @setfilename. (It's possible to have | ||||||
3153 | # more occurrences later if the manual shows examples of how | ||||||
3154 | # to use @setfilename...) | ||||||
3155 | 62 | 285 | next if $outfile; | ||||
3156 | |||||||
3157 | 61 | 164 | $outfile = $1; | ||||
3158 | 61 | 1741 | if ($outfile =~ /\.([^.]+)$/ && $1 ne 'info') | ||||
3159 | { | ||||||
3160 | 1 | 13 | error ("$filename:$.", | ||||
3161 | "output `$outfile' has unrecognized extension"); | ||||||
3162 | 1 | 15 | return; | ||||
3163 | } | ||||||
3164 | } | ||||||
3165 | # A "version.texi" file is actually any file whose name matches | ||||||
3166 | # "vers*.texi". | ||||||
3167 | elsif (/^\@include\s+(vers[^.]*\.texi)\s*$/) | ||||||
3168 | { | ||||||
3169 | 23 | 102 | $vfile = $1; | ||||
3170 | } | ||||||
3171 | |||||||
3172 | # Try to find new or unused indexes. | ||||||
3173 | |||||||
3174 | # Creating a new category of index. | ||||||
3175 | elsif (/^\@def(code)?index (\w+)/) | ||||||
3176 | { | ||||||
3177 | 3 | 14 | $clean_suffixes{$2} = 1; | ||||
3178 | 3 | 14 | $clean_suffixes{"$2s"} = 1; | ||||
3179 | } | ||||||
3180 | |||||||
3181 | # Merging an index into an another. | ||||||
3182 | elsif (/^\@syn(code)?index (\w+) (\w+)/) | ||||||
3183 | { | ||||||
3184 | 1 | 3 | delete $clean_suffixes{"$2s"}; | ||||
3185 | 1 | 4 | $clean_suffixes{"$3s"} = 1; | ||||
3186 | } | ||||||
3187 | |||||||
3188 | } | ||||||
3189 | |||||||
3190 | 60 | 540 | if (! $outfile) | ||||
3191 | { | ||||||
3192 | 0 | 0 | err_am "`$filename' missing \@setfilename"; | ||||
3193 | 0 | 0 | return; | ||||
3194 | } | ||||||
3195 | |||||||
3196 | 60 | 242 | my $infobase = basename ($filename); | ||||
3197 | 60 | 315 | $infobase =~ s/\.te?xi(nfo)?$//; | ||||
3198 | 965 | 2709 | return ($outfile, $vfile, | ||||
3199 | 60 | 613 | map { "$infobase.$_" } (sort keys %clean_suffixes)); | ||||
3200 | } | ||||||
3201 | |||||||
3202 | |||||||
3203 | # ($DIRSTAMP, @CLEAN_FILES) | ||||||
3204 | # output_texinfo_build_rules ($SOURCE, $DEST, $INSRC, @DEPENDENCIES) | ||||||
3205 | # ------------------------------------------------------------------ | ||||||
3206 | # SOURCE - the source Texinfo file | ||||||
3207 | # DEST - the destination Info file | ||||||
3208 | # INSRC - wether DEST should be built in the source tree | ||||||
3209 | # DEPENDENCIES - known dependencies | ||||||
3210 | sub output_texinfo_build_rules ($$$@) | ||||||
3211 | { | ||||||
3212 | 60 | 195 | my ($source, $dest, $insrc, @deps) = @_; | ||||
3213 | |||||||
3214 | # Split `a.texi' into `a' and `.texi'. | ||||||
3215 | 60 | 425 | my ($spfx, $ssfx) = ($source =~ /^(.*?)(\.[^.]*)?$/); | ||||
3216 | 60 | 302 | my ($dpfx, $dsfx) = ($dest =~ /^(.*?)(\.[^.]*)?$/); | ||||
3217 | |||||||
3218 | 60 | 228 | $ssfx ||= ""; | ||||
3219 | 60 | 160 | $dsfx ||= ""; | ||||
3220 | |||||||
3221 | # We can output two kinds of rules: the "generic" rules use Make | ||||||
3222 | # suffix rules and are appropriate when $source and $dest do not lie | ||||||
3223 | # in a sub-directory; the "specific" rules are needed in the other | ||||||
3224 | # case. | ||||||
3225 | # | ||||||
3226 | # The former are output only once (this is not really apparent here, | ||||||
3227 | # but just remember that some logic deeper in Automake will not | ||||||
3228 | # output the same rule twice); while the later need to be output for | ||||||
3229 | # each Texinfo source. | ||||||
3230 | 60 | 65 | my $generic; | ||||
3231 | 60 | 66 | my $makeinfoflags; | ||||
3232 | 60 | 144 | my $sdir = dirname $source; | ||||
3233 | 60 | 5824 | if ($sdir eq '.' && dirname ($dest) eq '.') | ||||
3234 | { | ||||||
3235 | 54 | 5031 | $generic = 1; | ||||
3236 | 54 | 106 | $makeinfoflags = '-I $(srcdir)'; | ||||
3237 | } | ||||||
3238 | else | ||||||
3239 | { | ||||||
3240 | 6 | 12 | $generic = 0; | ||||
3241 | 6 | 18 | $makeinfoflags = "-I $sdir -I \$(srcdir)/$sdir"; | ||||
3242 | } | ||||||
3243 | |||||||
3244 | # A directory can contain two kinds of info files: some built in the | ||||||
3245 | # source tree, and some built in the build tree. The rules are | ||||||
3246 | # different in each case. However we cannot output two different | ||||||
3247 | # set of generic rules. Because in-source builds are more usual, we | ||||||
3248 | # use generic rules in this case and fall back to "specific" rules | ||||||
3249 | # for build-dir builds. (It should not be a problem to invert this | ||||||
3250 | # if needed.) | ||||||
3251 | 60 | 182 | $generic = 0 unless $insrc; | ||||
3252 | |||||||
3253 | # We cannot use a suffix rule to build info files with an empty | ||||||
3254 | # extension. Otherwise we would output a single suffix inference | ||||||
3255 | # rule, with separate dependencies, as in | ||||||
3256 | # | ||||||
3257 | # .texi: | ||||||
3258 | # $(MAKEINFO) ... | ||||||
3259 | # foo.info: foo.texi | ||||||
3260 | # | ||||||
3261 | # which confuse Solaris make. (See the Autoconf manual for | ||||||
3262 | # details.) Therefore we use a specific rule in this case. This | ||||||
3263 | # applies to info files only (dvi and pdf files always have an | ||||||
3264 | # extension). | ||||||
3265 | 60 | 375 | my $generic_info = ($generic && $dsfx) ? 1 : 0; | ||||
3266 | |||||||
3267 | # If the resulting file lie into a subdirectory, | ||||||
3268 | # make sure this directory will exist. | ||||||
3269 | 60 | 238 | my $dirstamp = require_build_directory_maybe ($dest); | ||||
3270 | |||||||
3271 | 60 | 192 | my $dipfx = ($insrc ? '$(srcdir)/' : '') . $dpfx; | ||||
3272 | |||||||
3273 | 60 | 341 | $output_rules .= file_contents ('texibuild', | ||||
3274 | new Automake::Location, | ||||||
3275 | AM_V_MAKEINFO => verbose_flag('MAKEINFO'), | ||||||
3276 | AM_V_TEXI2DVI => verbose_flag('TEXI2DVI'), | ||||||
3277 | AM_V_TEXI2PDF => verbose_flag('TEXI2PDF'), | ||||||
3278 | DEPS => "@deps", | ||||||
3279 | DEST_PREFIX => $dpfx, | ||||||
3280 | DEST_INFO_PREFIX => $dipfx, | ||||||
3281 | DEST_SUFFIX => $dsfx, | ||||||
3282 | DIRSTAMP => $dirstamp, | ||||||
3283 | GENERIC => $generic, | ||||||
3284 | GENERIC_INFO => $generic_info, | ||||||
3285 | INSRC => $insrc, | ||||||
3286 | MAKEINFOFLAGS => $makeinfoflags, | ||||||
3287 | SILENT => silent_flag(), | ||||||
3288 | SOURCE => ($generic | ||||||
3289 | ? '$<' : $source), | ||||||
3290 | SOURCE_INFO => ($generic_info | ||||||
3291 | ? '$<' : $source), | ||||||
3292 | SOURCE_REAL => $source, | ||||||
3293 | SOURCE_SUFFIX => $ssfx, | ||||||
3294 | TEXIQUIET => verbose_flag('texinfo'), | ||||||
3295 | TEXIDEVNULL => verbose_flag('texidevnull'), | ||||||
3296 | ); | ||||||
3297 | 60 | 559 | return ($dirstamp, "$dpfx.dvi", "$dpfx.pdf", "$dpfx.ps", "$dpfx.html"); | ||||
3298 | } | ||||||
3299 | |||||||
3300 | |||||||
3301 | # ($MOSTLYCLEAN, $TEXICLEAN, $MAINTCLEAN) | ||||||
3302 | # handle_texinfo_helper ($info_texinfos) | ||||||
3303 | # -------------------------------------- | ||||||
3304 | # Handle all Texinfo source; helper for handle_texinfo. | ||||||
3305 | sub handle_texinfo_helper ($) | ||||||
3306 | { | ||||||
3307 | 51 | 143 | my ($info_texinfos) = @_; | ||||
3308 | 51 | 89 | my (@infobase, @info_deps_list, @texi_deps); | ||||
3309 | 51 | 58 | my %versions; | ||||
3310 | 51 | 84 | my $done = 0; | ||||
3311 | 51 | 174 | my (@mostly_cleans, @texi_cleans, @maint_cleans) = ('', '', ''); | ||||
3312 | |||||||
3313 | # Build a regex matching user-cleaned files. | ||||||
3314 | 51 | 176 | my $d = var 'DISTCLEANFILES'; | ||||
3315 | 51 | 139 | my $c = var 'CLEANFILES'; | ||||
3316 | 51 | 83 | my @f = (); | ||||
3317 | 51 | 155 | push @f, $d->value_as_list_recursive (inner_expand => 1) if $d; | ||||
3318 | 51 | 148 | push @f, $c->value_as_list_recursive (inner_expand => 1) if $c; | ||||
3319 | 51 4 4 4 | 143 45 20 14 | @f = map { s|[^A-Za-z_0-9*\[\]\-]|\\$&|g; s|\*|[^/]*|g; $_; } @f; | ||||
3320 | 51 | 234 | my $user_cleaned_files = '^(?:' . join ('|', @f) . ')$'; | ||||
3321 | |||||||
3322 | 51 | 446 | foreach my $texi | ||||
3323 | ($info_texinfos->value_as_list_recursive (inner_expand => 1)) | ||||||
3324 | { | ||||||
3325 | 61 | 126 | my $infobase = $texi; | ||||
3326 | 61 | 420 | $infobase =~ s/\.(txi|texinfo|texi)$//; | ||||
3327 | |||||||
3328 | 61 | 259 | if ($infobase eq $texi) | ||||
3329 | { | ||||||
3330 | # FIXME: report line number. | ||||||
3331 | 0 | 0 | err_am "texinfo file `$texi' has unrecognized extension"; | ||||
3332 | 0 | 0 | next; | ||||
3333 | } | ||||||
3334 | |||||||
3335 | 61 | 150 | push @infobase, $infobase; | ||||
3336 | |||||||
3337 | # If 'version.texi' is referenced by input file, then include | ||||||
3338 | # automatic versioning capability. | ||||||
3339 | 61 | 373 | my ($out_file, $vtexi, @clean_files) = | ||||
3340 | scan_texinfo_file ("$relative_dir/$texi") | ||||||
3341 | or next; | ||||||
3342 | 60 | 378 | push (@mostly_cleans, @clean_files); | ||||
3343 | |||||||
3344 | # If the Texinfo source is in a subdirectory, create the | ||||||
3345 | # resulting info in this subdirectory. If it is in the current | ||||||
3346 | # directory, try hard to not prefix "./" because it breaks the | ||||||
3347 | # generic rules. | ||||||
3348 | 60 | 180 | my $outdir = dirname ($texi) . '/'; | ||||
3349 | 60 | 6549 | $outdir = "" if $outdir eq './'; | ||||
3350 | 60 | 100 | $out_file = $outdir . $out_file; | ||||
3351 | |||||||
3352 | # Until Automake 1.6.3, .info files were built in the | ||||||
3353 | # source tree. This was an obstacle to the support of | ||||||
3354 | # non-distributed .info files, and non-distributed .texi | ||||||
3355 | # files. | ||||||
3356 | # | ||||||
3357 | # * Non-distributed .texi files is important in some packages | ||||||
3358 | # where .texi files are built at make time, probably using | ||||||
3359 | # other binaries built in the package itself, maybe using | ||||||
3360 | # tools or information found on the build host. Because | ||||||
3361 | # these files are not distributed they are always rebuilt | ||||||
3362 | # at make time; they should therefore not lie in the source | ||||||
3363 | # directory. One plan was to support this using | ||||||
3364 | # nodist_info_TEXINFOS or something similar. (Doing this | ||||||
3365 | # requires some sanity checks. For instance Automake should | ||||||
3366 | # not allow: | ||||||
3367 | # dist_info_TEXINFOS = foo.texi | ||||||
3368 | # nodist_foo_TEXINFOS = included.texi | ||||||
3369 | # because a distributed file should never depend on a | ||||||
3370 | # non-distributed file.) | ||||||
3371 | # | ||||||
3372 | # * If .texi files are not distributed, then .info files should | ||||||
3373 | # not be distributed either. There are also cases where one | ||||||
3374 | # wants to distribute .texi files, but does not want to | ||||||
3375 | # distribute the .info files. For instance the Texinfo package | ||||||
3376 | # distributes the tool used to build these files; it would | ||||||
3377 | # be a waste of space to distribute them. It's not clear | ||||||
3378 | # which syntax we should use to indicate that .info files should | ||||||
3379 | # not be distributed. Akim Demaille suggested that eventually | ||||||
3380 | # we switch to a new syntax: | ||||||
3381 | # | Maybe we should take some inspiration from what's already | ||||||
3382 | # | done in the rest of Automake. Maybe there is too much | ||||||
3383 | # | syntactic sugar here, and you want | ||||||
3384 | # | nodist_INFO = bar.info | ||||||
3385 | # | dist_bar_info_SOURCES = bar.texi | ||||||
3386 | # | bar_texi_DEPENDENCIES = foo.texi | ||||||
3387 | # | with a bit of magic to have bar.info represent the whole | ||||||
3388 | # | bar*info set. That's a lot more verbose that the current | ||||||
3389 | # | situation, but it is # not new, hence the user has less | ||||||
3390 | # | to learn. | ||||||
3391 | # | | ||||||
3392 | # | But there is still too much room for meaningless specs: | ||||||
3393 | # | nodist_INFO = bar.info | ||||||
3394 | # | dist_bar_info_SOURCES = bar.texi | ||||||
3395 | # | dist_PS = bar.ps something-written-by-hand.ps | ||||||
3396 | # | nodist_bar_ps_SOURCES = bar.texi | ||||||
3397 | # | bar_texi_DEPENDENCIES = foo.texi | ||||||
3398 | # | here bar.texi is dist_ in line 2, and nodist_ in 4. | ||||||
3399 | # | ||||||
3400 | # Back to the point, it should be clear that in order to support | ||||||
3401 | # non-distributed .info files, we need to build them in the | ||||||
3402 | # build tree, not in the source tree (non-distributed .texi | ||||||
3403 | # files are less of a problem, because we do not output build | ||||||
3404 | # rules for them). In Automake 1.7 .info build rules have been | ||||||
3405 | # largely cleaned up so that .info files get always build in the | ||||||
3406 | # build tree, even when distributed. The idea was that | ||||||
3407 | # (1) if during a VPATH build the .info file was found to be | ||||||
3408 | # absent or out-of-date (in the source tree or in the | ||||||
3409 | # build tree), Make would rebuild it in the build tree. | ||||||
3410 | # If an up-to-date source-tree of the .info file existed, | ||||||
3411 | # make would not rebuild it in the build tree. | ||||||
3412 | # (2) having two copies of .info files, one in the source tree | ||||||
3413 | # and one (newer) in the build tree is not a problem | ||||||
3414 | # because `make dist' always pick files in the build tree | ||||||
3415 | # first. | ||||||
3416 | # However it turned out the be a bad idea for several reasons: | ||||||
3417 | # * Tru64, OpenBSD, and FreeBSD (not NetBSD) Make do not behave | ||||||
3418 | # like GNU Make on point (1) above. These implementations | ||||||
3419 | # of Make would always rebuild .info files in the build | ||||||
3420 | # tree, even if such files were up to date in the source | ||||||
3421 | # tree. Consequently, it was impossible to perform a VPATH | ||||||
3422 | # build of a package containing Texinfo files using these | ||||||
3423 | # Make implementations. | ||||||
3424 | # (Refer to the Autoconf Manual, section "Limitation of | ||||||
3425 | # Make", paragraph "VPATH", item "target lookup", for | ||||||
3426 | # an account of the differences between these | ||||||
3427 | # implementations.) | ||||||
3428 | # * The GNU Coding Standards require these files to be built | ||||||
3429 | # in the source-tree (when they are distributed, that is). | ||||||
3430 | # * Keeping a fresher copy of distributed files in the | ||||||
3431 | # build tree can be annoying during development because | ||||||
3432 | # - if the files is kept under CVS, you really want it | ||||||
3433 | # to be updated in the source tree | ||||||
3434 | # - it is confusing that `make distclean' does not erase | ||||||
3435 | # all files in the build tree. | ||||||
3436 | # | ||||||
3437 | # Consequently, starting with Automake 1.8, .info files are | ||||||
3438 | # built in the source tree again. Because we still plan to | ||||||
3439 | # support non-distributed .info files at some point, we | ||||||
3440 | # have a single variable ($INSRC) that controls whether | ||||||
3441 | # the current .info file must be built in the source tree | ||||||
3442 | # or in the build tree. Actually this variable is switched | ||||||
3443 | # off for .info files that appear to be cleaned; this is | ||||||
3444 | # for backward compatibility with package such as Texinfo, | ||||||
3445 | # which do things like | ||||||
3446 | # info_TEXINFOS = texinfo.txi info-stnd.texi info.texi | ||||||
3447 | # DISTCLEANFILES = texinfo texinfo-* info*.info* | ||||||
3448 | # # Do not create info files for distribution. | ||||||
3449 | # dist-info: | ||||||
3450 | # in order not to distribute .info files. | ||||||
3451 | 60 | 731 | my $insrc = ($out_file =~ $user_cleaned_files) ? 0 : 1; | ||||
3452 | |||||||
3453 | 60 | 122 | my $soutdir = '$(srcdir)/' . $outdir; | ||||
3454 | 60 | 284 | $outdir = $soutdir if $insrc; | ||||
3455 | |||||||
3456 | # If user specified file_TEXINFOS, then use that as explicit | ||||||
3457 | # dependency list. | ||||||
3458 | 60 | 100 | @texi_deps = (); | ||||
3459 | 60 | 237 | push (@texi_deps, "$soutdir$vtexi") if $vtexi; | ||||
3460 | |||||||
3461 | 60 | 277 | my $canonical = canonicalize ($infobase); | ||||
3462 | 60 | 250 | if (var ($canonical . "_TEXINFOS")) | ||||
3463 | { | ||||||
3464 | 4 | 12 | push (@texi_deps, '$(' . $canonical . '_TEXINFOS)'); | ||||
3465 | 4 | 15 | push_dist_common ('$(' . $canonical . '_TEXINFOS)'); | ||||
3466 | } | ||||||
3467 | |||||||
3468 | 60 | 258 | my ($dirstamp, @cfiles) = | ||||
3469 | output_texinfo_build_rules ($texi, $out_file, $insrc, @texi_deps); | ||||||
3470 | 60 | 172 | push (@texi_cleans, @cfiles); | ||||
3471 | |||||||
3472 | 60 | 125 | push (@info_deps_list, $out_file); | ||||
3473 | |||||||
3474 | # If a vers*.texi file is needed, emit the rule. | ||||||
3475 | 60 | 260 | if ($vtexi) | ||||
3476 | { | ||||||
3477 | 23 | 66 | err_am ("`$vtexi', included in `$texi', " | ||||
3478 | . "also included in `$versions{$vtexi}'") | ||||||
3479 | if defined $versions{$vtexi}; | ||||||
3480 | 23 | 53 | $versions{$vtexi} = $texi; | ||||
3481 | |||||||
3482 | # We number the stamp-vti files. This is doable since the | ||||||
3483 | # actual names don't matter much. We only number starting | ||||||
3484 | # with the second one, so that the common case looks nice. | ||||||
3485 | 23 | 65 | my $vti = ($done ? $done : 'vti'); | ||||
3486 | 23 | 35 | ++$done; | ||||
3487 | |||||||
3488 | # This is ugly, but it is our historical practice. | ||||||
3489 | 23 | 52 | if ($config_aux_dir_set_in_configure_ac) | ||||
3490 | { | ||||||
3491 | 1 | 4 | require_conf_file_with_macro (TRUE, 'info_TEXINFOS', FOREIGN, | ||||
3492 | 'mdate-sh'); | ||||||
3493 | } | ||||||
3494 | else | ||||||
3495 | { | ||||||
3496 | 22 | 117 | require_file_with_macro (TRUE, 'info_TEXINFOS', | ||||
3497 | FOREIGN, 'mdate-sh'); | ||||||
3498 | } | ||||||
3499 | |||||||
3500 | 23 | 42 | my $conf_dir; | ||||
3501 | 23 | 55 | if ($config_aux_dir_set_in_configure_ac) | ||||
3502 | { | ||||||
3503 | 1 | 2 | $conf_dir = "$am_config_aux_dir/"; | ||||
3504 | } | ||||||
3505 | else | ||||||
3506 | { | ||||||
3507 | 22 | 44 | $conf_dir = '$(srcdir)/'; | ||||
3508 | } | ||||||
3509 | 23 | 91 | $output_rules .= file_contents ('texi-vers', | ||||
3510 | new Automake::Location, | ||||||
3511 | TEXI => $texi, | ||||||
3512 | VTI => $vti, | ||||||
3513 | STAMPVTI => "${soutdir}stamp-$vti", | ||||||
3514 | VTEXI => "$soutdir$vtexi", | ||||||
3515 | MDDIR => $conf_dir, | ||||||
3516 | DIRSTAMP => $dirstamp); | ||||||
3517 | } | ||||||
3518 | } | ||||||
3519 | |||||||
3520 | # Handle location of texinfo.tex. | ||||||
3521 | 51 | 632 | my $need_texi_file = 0; | ||||
3522 | 51 | 73 | my $texinfodir; | ||||
3523 | 51 | 166 | if (var ('TEXINFO_TEX')) | ||||
3524 | { | ||||||
3525 | # The user defined TEXINFO_TEX so assume he knows what he is | ||||||
3526 | # doing. | ||||||
3527 | 1 | 4 | $texinfodir = ('$(srcdir)/' | ||||
3528 | . dirname (variable_value ('TEXINFO_TEX'))); | ||||||
3529 | } | ||||||
3530 | elsif (option 'cygnus') | ||||||
3531 | { | ||||||
3532 | 3 | 5 | $texinfodir = '$(top_srcdir)/../texinfo'; | ||||
3533 | 3 | 12 | define_variable ('TEXINFO_TEX', "$texinfodir/texinfo.tex", INTERNAL); | ||||
3534 | } | ||||||
3535 | elsif ($config_aux_dir_set_in_configure_ac) | ||||||
3536 | { | ||||||
3537 | 2 | 4 | $texinfodir = $am_config_aux_dir; | ||||
3538 | 2 | 9 | define_variable ('TEXINFO_TEX', "$texinfodir/texinfo.tex", INTERNAL); | ||||
3539 | 2 | 5 | $need_texi_file = 2; # so that we require_conf_file later | ||||
3540 | } | ||||||
3541 | else | ||||||
3542 | { | ||||||
3543 | 45 | 86 | $texinfodir = '$(srcdir)'; | ||||
3544 | 45 | 77 | $need_texi_file = 1; | ||||
3545 | } | ||||||
3546 | 51 | 279 | define_variable ('am__TEXINFO_TEX_DIR', $texinfodir, INTERNAL); | ||||
3547 | |||||||
3548 | 51 | 154 | push (@dist_targets, 'dist-info'); | ||||
3549 | |||||||
3550 | 51 | 153 | if (! option 'no-installinfo') | ||||
3551 | { | ||||||
3552 | # Make sure documentation is made and installed first. Use | ||||||
3553 | # $(INFO_DEPS), not 'info', because otherwise recursive makes | ||||||
3554 | # get run twice during "make all". | ||||||
3555 | 47 | 108 | unshift (@all, '$(INFO_DEPS)'); | ||||
3556 | } | ||||||
3557 | |||||||
3558 | 51 | 277 | define_files_variable ("DVIS", @infobase, 'dvi', INTERNAL); | ||||
3559 | 51 | 175 | define_files_variable ("PDFS", @infobase, 'pdf', INTERNAL); | ||||
3560 | 51 | 168 | define_files_variable ("PSS", @infobase, 'ps', INTERNAL); | ||||
3561 | 51 | 169 | define_files_variable ("HTMLS", @infobase, 'html', INTERNAL); | ||||
3562 | |||||||
3563 | # This next isn't strictly needed now -- the places that look here | ||||||
3564 | # could easily be changed to look in info_TEXINFOS. But this is | ||||||
3565 | # probably better, in case noinst_TEXINFOS is ever supported. | ||||||
3566 | 51 | 240 | define_variable ("TEXINFOS", variable_value ('info_TEXINFOS'), INTERNAL); | ||||
3567 | |||||||
3568 | # Do some error checking. Note that this file is not required | ||||||
3569 | # when in Cygnus mode; instead we defined TEXINFO_TEX explicitly | ||||||
3570 | # up above. | ||||||
3571 | 51 | 326 | if ($need_texi_file && ! option 'no-texinfo.tex') | ||||
3572 | { | ||||||
3573 | 47 | 172 | if ($need_texi_file > 1) | ||||
3574 | { | ||||||
3575 | 2 | 7 | require_conf_file_with_macro (TRUE, 'info_TEXINFOS', FOREIGN, | ||||
3576 | 'texinfo.tex'); | ||||||
3577 | } | ||||||
3578 | else | ||||||
3579 | { | ||||||
3580 | 45 | 192 | require_file_with_macro (TRUE, 'info_TEXINFOS', FOREIGN, | ||||
3581 | 'texinfo.tex'); | ||||||
3582 | } | ||||||
3583 | } | ||||||
3584 | |||||||
3585 | 51 | 476 | return (makefile_wrap ("", "\t ", @mostly_cleans), | ||||
3586 | makefile_wrap ("", "\t ", @texi_cleans), | ||||||
3587 | makefile_wrap ("", "\t ", @maint_cleans)); | ||||||
3588 | } | ||||||
3589 | |||||||
3590 | |||||||
3591 | # handle_texinfo () | ||||||
3592 | # ----------------- | ||||||
3593 | # Handle all Texinfo source. | ||||||
3594 | sub handle_texinfo () | ||||||
3595 | { | ||||||
3596 | 1319 | 5259 | reject_var 'TEXINFOS', "`TEXINFOS' is an anachronism; use `info_TEXINFOS'"; | ||||
3597 | # FIXME: I think this is an obsolete future feature name. | ||||||
3598 | 1319 | 4493 | reject_var 'html_TEXINFOS', "HTML generation not yet supported"; | ||||
3599 | |||||||
3600 | 1319 | 3838 | my $info_texinfos = var ('info_TEXINFOS'); | ||||
3601 | 1319 | 4193 | my ($mostlyclean, $clean, $maintclean) = ('', '', ''); | ||||
3602 | 1319 | 4104 | if ($info_texinfos) | ||||
3603 | { | ||||||
3604 | 51 | 146 | define_verbose_texinfo; | ||||
3605 | 51 | 286 | ($mostlyclean, $clean, $maintclean) = handle_texinfo_helper ($info_texinfos); | ||||
3606 | 51 | 153 | chomp $mostlyclean; | ||||
3607 | 51 | 67 | chomp $clean; | ||||
3608 | 51 | 83 | chomp $maintclean; | ||||
3609 | } | ||||||
3610 | |||||||
3611 | 1319 | 5016 | $output_rules .= file_contents ('texinfos', | ||||
3612 | new Automake::Location, | ||||||
3613 | AM_V_DVIPS => verbose_flag('DVIPS'), | ||||||
3614 | MOSTLYCLEAN => $mostlyclean, | ||||||
3615 | TEXICLEAN => $clean, | ||||||
3616 | MAINTCLEAN => $maintclean, | ||||||
3617 | 'LOCAL-TEXIS' => !!$info_texinfos, | ||||||
3618 | TEXIQUIET => verbose_flag('texinfo')); | ||||||
3619 | } | ||||||
3620 | |||||||
3621 | |||||||
3622 | # Handle any man pages. | ||||||
3623 | sub handle_man_pages | ||||||
3624 | { | ||||||
3625 | 1319 | 4579 | reject_var 'MANS', "`MANS' is an anachronism; use `man_MANS'"; | ||||
3626 | |||||||
3627 | # Skip the expensive code if no MANS. | ||||||
3628 | return | ||||||
3629 | 1319 | 3863 | if ! variables ('MANS'); | ||||
3630 | |||||||
3631 | # Find all the sections in use. We do this by first looking for | ||||||
3632 | # "standard" sections, and then looking for any additional | ||||||
3633 | # sections used in man_MANS. | ||||||
3634 | 20 | 51 | my (%sections, %notrans_sections, %trans_sections, | ||||
3635 | %notrans_vars, %trans_vars, %notrans_sect_vars, %trans_sect_vars); | ||||||
3636 | # We handle nodist_ for uniformity. man pages aren't distributed | ||||||
3637 | # by default so it isn't actually very important. | ||||||
3638 | 20 | 110 | foreach my $npfx ('', 'notrans_') | ||||
3639 | { | ||||||
3640 | 40 | 77 | foreach my $pfx ('', 'dist_', 'nodist_') | ||||
3641 | { | ||||||
3642 | # Add more sections as needed. | ||||||
3643 | 120 | 234 | foreach my $section ('0'..'9', 'n', 'l') | ||||
3644 | { | ||||||
3645 | 1440 | 2748 | my $varname = $npfx . $pfx . 'man' . $section . '_MANS'; | ||||
3646 | 1440 | 2766 | if (var ($varname)) | ||||
3647 | { | ||||||
3648 | 16 | 45 | $sections{$section} = 1; | ||||
3649 | 16 | 35 | $varname = '$(' . $varname . ')'; | ||||
3650 | 16 | 35 | if ($npfx eq 'notrans_') | ||||
3651 | { | ||||||
3652 | 6 | 11 | $notrans_sections{$section} = 1; | ||||
3653 | 6 | 12 | $notrans_sect_vars{$varname} = 1; | ||||
3654 | } | ||||||
3655 | else | ||||||
3656 | { | ||||||
3657 | 10 | 20 | $trans_sections{$section} = 1; | ||||
3658 | 10 | 24 | $trans_sect_vars{$varname} = 1; | ||||
3659 | } | ||||||
3660 | |||||||
3661 | 16 | 46 | &push_dist_common ($varname) | ||||
3662 | if $pfx eq 'dist_'; | ||||||
3663 | } | ||||||
3664 | } | ||||||
3665 | |||||||
3666 | 120 | 223 | my $varname = $npfx . $pfx . 'man_MANS'; | ||||
3667 | 120 | 255 | my $var = var ($varname); | ||||
3668 | 120 | 292 | if ($var) | ||||
3669 | { | ||||||
3670 | 28 | 113 | foreach ($var->value_as_list_recursive) | ||||
3671 | { | ||||||
3672 | # A page like `foo.1c' goes into man1dir. | ||||||
3673 | 201 | 661 | if (/\.([0-9a-z])([a-z]*)$/) | ||||
3674 | { | ||||||
3675 | 201 | 389 | $sections{$1} = 1; | ||||
3676 | 201 | 332 | if ($npfx eq 'notrans_') | ||||
3677 | { | ||||||
3678 | 91 | 168 | $notrans_sections{$1} = 1; | ||||
3679 | } | ||||||
3680 | else | ||||||
3681 | { | ||||||
3682 | 110 | 240 | $trans_sections{$1} = 1; | ||||
3683 | } | ||||||
3684 | } | ||||||
3685 | } | ||||||
3686 | |||||||
3687 | 28 | 230 | $varname = '$(' . $varname . ')'; | ||||
3688 | 28 | 67 | if ($npfx eq 'notrans_') | ||||
3689 | { | ||||||
3690 | 7 | 16 | $notrans_vars{$varname} = 1; | ||||
3691 | } | ||||||
3692 | else | ||||||
3693 | { | ||||||
3694 | 21 | 54 | $trans_vars{$varname} = 1; | ||||
3695 | } | ||||||
3696 | 28 | 102 | &push_dist_common ($varname) | ||||
3697 | if $pfx eq 'dist_'; | ||||||
3698 | } | ||||||
3699 | } | ||||||
3700 | } | ||||||
3701 | |||||||
3702 | 20 | 230 | return unless %sections; | ||||
3703 | |||||||
3704 | 20 | 31 | my @unsorted_deps; | ||||
3705 | |||||||
3706 | # Build section independent variables. | ||||||
3707 | 20 | 40 | my $have_notrans = %notrans_vars; | ||||
3708 | 20 | 79 | my @notrans_list = sort keys %notrans_vars; | ||||
3709 | 20 | 50 | my $have_trans = %trans_vars; | ||||
3710 | 20 | 76 | my @trans_list = sort keys %trans_vars; | ||||
3711 | |||||||
3712 | # Now for each section, generate an install and uninstall rule. | ||||||
3713 | # Sort sections so output is deterministic. | ||||||
3714 | 20 | 87 | foreach my $section (sort keys %sections) | ||||
3715 | { | ||||||
3716 | # Build section dependent variables. | ||||||
3717 | 33 | 192 | my $notrans_mans = $have_notrans || exists $notrans_sections{$section}; | ||||
3718 | 33 | 98 | my $trans_mans = $have_trans || exists $trans_sections{$section}; | ||||
3719 | 33 | 56 | my (%notrans_this_sect, %trans_this_sect); | ||||
3720 | 33 | 74 | my $expr = 'man' . $section . '_MANS'; | ||||
3721 | 33 | 96 | foreach my $varname (keys %notrans_sect_vars) | ||||
3722 | { | ||||||
3723 | 26 | 183 | if ($varname =~ /$expr/) | ||||
3724 | { | ||||||
3725 | 6 | 16 | $notrans_this_sect{$varname} = 1; | ||||
3726 | } | ||||||
3727 | } | ||||||
3728 | 33 | 85 | foreach my $varname (keys %trans_sect_vars) | ||||
3729 | { | ||||||
3730 | 33 | 224 | if ($varname =~ /$expr/) | ||||
3731 | { | ||||||
3732 | 10 | 30 | $trans_this_sect{$varname} = 1; | ||||
3733 | } | ||||||
3734 | } | ||||||
3735 | 33 | 113 | my @notrans_sect_list = sort keys %notrans_this_sect; | ||||
3736 | 33 | 96 | my @trans_sect_list = sort keys %trans_this_sect; | ||||
3737 | 33 | 118 | @unsorted_deps = (keys %notrans_vars, keys %trans_vars, | ||||
3738 | keys %notrans_this_sect, keys %trans_this_sect); | ||||||
3739 | 33 | 120 | my @deps = sort @unsorted_deps; | ||||
3740 | 33 | 161 | $output_rules .= &file_contents ('mans', | ||||
3741 | new Automake::Location, | ||||||
3742 | SECTION => $section, | ||||||
3743 | DEPS => "@deps", | ||||||
3744 | NOTRANS_MANS => $notrans_mans, | ||||||
3745 | NOTRANS_SECT_LIST => "@notrans_sect_list", | ||||||
3746 | HAVE_NOTRANS => $have_notrans, | ||||||
3747 | NOTRANS_LIST => "@notrans_list", | ||||||
3748 | TRANS_MANS => $trans_mans, | ||||||
3749 | TRANS_SECT_LIST => "@trans_sect_list", | ||||||
3750 | HAVE_TRANS => $have_trans, | ||||||
3751 | TRANS_LIST => "@trans_list"); | ||||||
3752 | } | ||||||
3753 | |||||||
3754 | 20 | 94 | @unsorted_deps = (keys %notrans_vars, keys %trans_vars, | ||||
3755 | keys %notrans_sect_vars, keys %trans_sect_vars); | ||||||
3756 | 20 | 88 | my @mans = sort @unsorted_deps; | ||||
3757 | 20 | 77 | $output_vars .= file_contents ('mans-vars', | ||||
3758 | new Automake::Location, | ||||||
3759 | MANS => "@mans"); | ||||||
3760 | |||||||
3761 | 20 | 91 | push (@all, '$(MANS)') | ||||
3762 | unless option 'no-installman'; | ||||||
3763 | } | ||||||
3764 | |||||||
3765 | # Handle DATA variables. | ||||||
3766 | sub handle_data | ||||||
3767 | { | ||||||
3768 | 1319 | 6166 | &am_install_var ('-noextra', '-candist', 'data', 'DATA', | ||||
3769 | 'data', 'dataroot', 'dvi', 'html', 'pdf', 'ps', | ||||||
3770 | 'sysconf', 'sharedstate', 'localstate', | ||||||
3771 | 'pkgdata', 'lisp', 'noinst', 'check'); | ||||||
3772 | } | ||||||
3773 | |||||||
3774 | # Handle TAGS. | ||||||
3775 | sub handle_tags | ||||||
3776 | { | ||||||
3777 | 1319 | 2555 | my @tag_deps = (); | ||||
3778 | 1319 | 2119 | my @ctag_deps = (); | ||||
3779 | 1319 | 2492 | my @cscope_deps = (); | ||||
3780 | 1319 | 3969 | if (var ('SUBDIRS')) | ||||
3781 | { | ||||||
3782 | 171 | 369 | $output_rules .= ("tags-recursive:\n" | ||||
3783 | . "\tlist=\'\$(SUBDIRS)\'; for subdir in \$\$list; do \\\n" | ||||||
3784 | # Never fail here if a subdir fails; it | ||||||
3785 | # isn't important. | ||||||
3786 | . "\t test \"\$\$subdir\" = . || (\$(am__cd) \$\$subdir" | ||||||
3787 | . " && \$(MAKE) \$(AM_MAKEFLAGS) tags); \\\n" | ||||||
3788 | . "\tdone\n"); | ||||||
3789 | 171 | 380 | push (@tag_deps, 'tags-recursive'); | ||||
3790 | 171 | 470 | &depend ('.PHONY', 'tags-recursive'); | ||||
3791 | 171 | 466 | &depend ('.MAKE', 'tags-recursive'); | ||||
3792 | |||||||
3793 | 171 | 313 | $output_rules .= ("ctags-recursive:\n" | ||||
3794 | . "\tlist=\'\$(SUBDIRS)\'; for subdir in \$\$list; do \\\n" | ||||||
3795 | # Never fail here if a subdir fails; it | ||||||
3796 | # isn't important. | ||||||
3797 | . "\t test \"\$\$subdir\" = . || (\$(am__cd) \$\$subdir" | ||||||
3798 | . " && \$(MAKE) \$(AM_MAKEFLAGS) ctags); \\\n" | ||||||
3799 | . "\tdone\n"); | ||||||
3800 | 171 | 335 | push (@ctag_deps, 'ctags-recursive'); | ||||
3801 | 171 | 472 | &depend ('.PHONY', 'ctags-recursive'); | ||||
3802 | 171 | 482 | &depend ('.MAKE', 'ctags-recursive'); | ||||
3803 | |||||||
3804 | 171 | 313 | $output_rules .= ("cscopelist-recursive:\n" | ||||
3805 | . "\tlist=\'\$(SUBDIRS)\'; for subdir in \$\$list; do \\\n" | ||||||
3806 | # Never fail here if a subdir fails; it | ||||||
3807 | # isn't important. | ||||||
3808 | . "\t test \"\$\$subdir\" = . || (\$(am__cd) \$\$subdir" | ||||||
3809 | . " && \$(MAKE) \$(AM_MAKEFLAGS) cscopelist); \\\n" | ||||||
3810 | . "\tdone\n"); | ||||||
3811 | 171 | 314 | push (@cscope_deps, 'cscopelist-recursive'); | ||||
3812 | 171 | 453 | &depend ('.PHONY', 'cscopelist-recursive'); | ||||
3813 | 171 | 467 | &depend ('.MAKE', 'cscopelist-recursive'); | ||||
3814 | } | ||||||
3815 | |||||||
3816 | 1319 | 4713 | if (&saw_sources_p (1) | ||||
3817 | || var ('ETAGS_ARGS') | ||||||
3818 | || @tag_deps) | ||||||
3819 | { | ||||||
3820 | 719 | 1130 | my @config; | ||||
3821 | 719 | 2682 | foreach my $spec (@config_headers) | ||||
3822 | { | ||||||
3823 | 9 | 168 | my ($out, @ins) = split_config_file_spec ($spec); | ||||
3824 | 9 | 17 | foreach my $in (@ins) | ||||
3825 | { | ||||||
3826 | # If the config header source is in this directory, | ||||||
3827 | # require it. | ||||||
3828 | 11 | 216 | push @config, basename ($in) | ||||
3829 | if $relative_dir eq dirname ($in); | ||||||
3830 | } | ||||||
3831 | } | ||||||
3832 | 719 | 4466 | $output_rules .= &file_contents ('tags', | ||||
3833 | new Automake::Location, | ||||||
3834 | CONFIG => "@config", | ||||||
3835 | TAGSDIRS => "@tag_deps", | ||||||
3836 | CTAGSDIRS => "@ctag_deps", | ||||||
3837 | CSCOPEDIRS => "@cscope_deps"); | ||||||
3838 | |||||||
3839 | 719 | 4297 | set_seen 'TAGS_DEPENDENCIES'; | ||||
3840 | } | ||||||
3841 | elsif (reject_var ('TAGS_DEPENDENCIES', | ||||||
3842 | "it doesn't make sense to define `TAGS_DEPENDENCIES'" | ||||||
3843 | . " without\nsources or `ETAGS_ARGS'")) | ||||||
3844 | { | ||||||
3845 | } | ||||||
3846 | else | ||||||
3847 | { | ||||||
3848 | # Every Makefile must define some sort of TAGS rule. | ||||||
3849 | # Otherwise, it would be possible for a top-level "make TAGS" | ||||||
3850 | # to fail because some subdirectory failed. | ||||||
3851 | 599 | 2191 | $output_rules .= "tags: TAGS\nTAGS:\n\n"; | ||||
3852 | # Ditto ctags and cscope. | ||||||
3853 | 599 | 1148 | $output_rules .= "ctags: CTAGS\nCTAGS:\n\n"; | ||||
3854 | 599 | 1370 | $output_rules .= "cscope cscopelist:\n\n"; | ||||
3855 | } | ||||||
3856 | } | ||||||
3857 | |||||||
3858 | # Handle multilib support. | ||||||
3859 | sub handle_multilib | ||||||
3860 | { | ||||||
3861 | 1319 | 6341 | if ($seen_multilib && $relative_dir eq '.') | ||||
3862 | { | ||||||
3863 | 2 | 9 | $output_rules .= &file_contents ('multilib', new Automake::Location); | ||||
3864 | 2 | 10 | push (@all, 'all-multi'); | ||||
3865 | } | ||||||
3866 | } | ||||||
3867 | |||||||
3868 | |||||||
3869 | # user_phony_rule ($NAME) | ||||||
3870 | # ----------------------- | ||||||
3871 | # Return false if rule $NAME does not exist. Otherwise, | ||||||
3872 | # declare it as phony, complete its definition (in case it is | ||||||
3873 | # conditional), and return its Automake::Rule instance. | ||||||
3874 | sub user_phony_rule ($) | ||||||
3875 | { | ||||||
3876 | 32964 | 51224 | my ($name) = @_; | ||||
3877 | 32964 | 66266 | my $rule = rule $name; | ||||
3878 | 32964 | 56549 | if ($rule) | ||||
3879 | { | ||||||
3880 | 255 | 652 | depend ('.PHONY', $name); | ||||
3881 | # Define $NAME in all condition where it is not already defined, | ||||||
3882 | # so that it is always OK to depend on $NAME. | ||||||
3883 | 255 | 1202 | for my $c ($rule->not_always_defined_in_cond (TRUE)->conds) | ||||
3884 | { | ||||||
3885 | 4 | 14 | Automake::Rule::define ($name, 'internal', RULE_AUTOMAKE, | ||||
3886 | $c, INTERNAL); | ||||||
3887 | 4 | 13 | $output_rules .= $c->subst_string . "$name:\n"; | ||||
3888 | } | ||||||
3889 | } | ||||||
3890 | 32964 | 83007 | return $rule; | ||||
3891 | } | ||||||
3892 | |||||||
3893 | |||||||
3894 | # $BOOLEAN | ||||||
3895 | # &for_dist_common ($A, $B) | ||||||
3896 | # ------------------------- | ||||||
3897 | # Subroutine for &handle_dist: sort files to dist. | ||||||
3898 | # | ||||||
3899 | # We put README first because it then becomes easier to make a | ||||||
3900 | # Usenet-compliant shar file (in these, README must be first). | ||||||
3901 | # | ||||||
3902 | # FIXME: do more ordering of files here. | ||||||
3903 | sub for_dist_common | ||||||
3904 | { | ||||||
3905 | 22903 | 42419 | return 0 | ||||
3906 | if $a eq $b; | ||||||
3907 | 21729 | 37339 | return -1 | ||||
3908 | if $a eq 'README'; | ||||||
3909 | 21460 | 35077 | return 1 | ||||
3910 | if $b eq 'README'; | ||||||
3911 | 21313 | 23077 | return $a cmp $b; | ||||
3912 | } | ||||||
3913 | |||||||
3914 | # handle_dist | ||||||
3915 | # ----------- | ||||||
3916 | # Handle 'dist' target. | ||||||
3917 | sub handle_dist () | ||||||
3918 | { | ||||||
3919 | # Substitutions for distdir.am | ||||||
3920 | 1319 | 1958 | my %transform; | ||||
3921 | |||||||
3922 | # Define DIST_SUBDIRS. This must always be done, regardless of the | ||||||
3923 | # no-dist setting: target like `distclean' or `maintainer-clean' use it. | ||||||
3924 | 1319 | 3764 | my $subdirs = var ('SUBDIRS'); | ||||
3925 | 1319 | 3777 | if ($subdirs) | ||||
3926 | { | ||||||
3927 | # If SUBDIRS is conditionally defined, then set DIST_SUBDIRS | ||||||
3928 | # to all possible directories, and use it. If DIST_SUBDIRS is | ||||||
3929 | # defined, just use it. | ||||||
3930 | |||||||
3931 | # Note that we check DIST_SUBDIRS first on purpose, so that | ||||||
3932 | # we don't call has_conditional_contents for now reason. | ||||||
3933 | # (In the past one project used so many conditional subdirectories | ||||||
3934 | # that calling has_conditional_contents on SUBDIRS caused | ||||||
3935 | # automake to grow to 150Mb -- this should not happen with | ||||||
3936 | # the current implementation of has_conditional_contents, | ||||||
3937 | # but it's more efficient to avoid the call anyway.) | ||||||
3938 | 171 | 510 | if (var ('DIST_SUBDIRS')) | ||||
3939 | { | ||||||
3940 | } | ||||||
3941 | elsif ($subdirs->has_conditional_contents) | ||||||
3942 | { | ||||||
3943 | 5 | 21 | define_pretty_variable | ||||
3944 | ('DIST_SUBDIRS', TRUE, INTERNAL, | ||||||
3945 | uniq ($subdirs->value_as_list_recursive)); | ||||||
3946 | } | ||||||
3947 | else | ||||||
3948 | { | ||||||
3949 | # We always define this because that is what `distclean' | ||||||
3950 | # wants. | ||||||
3951 | 163 | 597 | define_pretty_variable ('DIST_SUBDIRS', TRUE, INTERNAL, | ||||
3952 | '$(SUBDIRS)'); | ||||||
3953 | } | ||||||
3954 | } | ||||||
3955 | |||||||
3956 | # The remaining definitions are only required when a dist target is used. | ||||||
3957 | 1319 | 4177 | return if option 'no-dist'; | ||||
3958 | |||||||
3959 | # At least one of the archive formats must be enabled. | ||||||
3960 | 1308 | 5197 | if ($relative_dir eq '.') | ||||
3961 | { | ||||||
3962 | 1091 | 4011 | my $archive_defined = option 'no-dist-gzip' ? 0 : 1; | ||||
3963 | 42 | 96 | $archive_defined ||= | ||||
3964 | 1091 | 3825 | grep { option "dist-$_" } qw(shar zip tarZ bzip2 lzip lzma xz); | ||||
3965 | 1091 | 3554 | error (option 'no-dist-gzip', | ||||
3966 | "no-dist-gzip specified but no dist-* specified,\n" | ||||||
3967 | . "at least one archive format must be enabled") | ||||||
3968 | unless $archive_defined; | ||||||
3969 | } | ||||||
3970 | |||||||
3971 | # Look for common files that should be included in distribution. | ||||||
3972 | # If the aux dir is set, and it does not have a Makefile.am, then | ||||||
3973 | # we check for these files there as well. | ||||||
3974 | 1308 | 2620 | my $check_aux = 0; | ||||
3975 | 1308 | 12745 | if ($relative_dir eq '.' | ||||
3976 | && $config_aux_dir_set_in_configure_ac) | ||||||
3977 | { | ||||||
3978 | 19 | 65 | if (! &is_make_dir ($config_aux_dir)) | ||||
3979 | { | ||||||
3980 | 9 | 14 | $check_aux = 1; | ||||
3981 | } | ||||||
3982 | } | ||||||
3983 | 1308 | 7154 | foreach my $cfile (@common_files) | ||||
3984 | { | ||||||
3985 | 49704 | 110765 | if (dir_has_case_matching_file ($relative_dir, $cfile) | ||||
3986 | # The file might be absent, but if it can be built it's ok. | ||||||
3987 | || rule $cfile) | ||||||
3988 | { | ||||||
3989 | 4228 | 9294 | &push_dist_common ($cfile); | ||||
3990 | } | ||||||
3991 | |||||||
3992 | # Don't use `elsif' here because a file might meaningfully | ||||||
3993 | # appear in both directories. | ||||||
3994 | 49704 | 143596 | if ($check_aux && dir_has_case_matching_file ($config_aux_dir, $cfile)) | ||||
3995 | { | ||||||
3996 | 21 | 64 | &push_dist_common ("$config_aux_dir/$cfile") | ||||
3997 | } | ||||||
3998 | } | ||||||
3999 | |||||||
4000 | # We might copy elements from $configure_dist_common to | ||||||
4001 | # %dist_common if we think we need to. If the file appears in our | ||||||
4002 | # directory, we would have discovered it already, so we don't | ||||||
4003 | # check that. But if the file is in a subdir without a Makefile, | ||||||
4004 | # we want to distribute it here if we are doing `.'. Ugly! | ||||||
4005 | 1308 | 5342 | if ($relative_dir eq '.') | ||||
4006 | { | ||||||
4007 | 1091 | 4538 | foreach my $file (split (' ' , $configure_dist_common)) | ||||
4008 | { | ||||||
4009 | 2512 | 8298 | push_dist_common ($file) | ||||
4010 | unless is_make_dir (dirname ($file)); | ||||||
4011 | } | ||||||
4012 | } | ||||||
4013 | |||||||
4014 | # Files to distributed. Don't use ->value_as_list_recursive | ||||||
4015 | # as it recursively expands `$(dist_pkgdata_DATA)' etc. | ||||||
4016 | 1308 | 9052 | my @dist_common = split (' ', rvar ('DIST_COMMON')->variable_value); | ||||
4017 | 1308 | 1389 | @dist_common = uniq (sort for_dist_common (@dist_common)); | ||||
4018 | 1308 | 7064 | variable_delete 'DIST_COMMON'; | ||||
4019 | 1308 | 5305 | define_pretty_variable ('DIST_COMMON', TRUE, INTERNAL, @dist_common); | ||||
4020 | |||||||
4021 | # Now that we've processed DIST_COMMON, disallow further attempts | ||||||
4022 | # to set it. | ||||||
4023 | 1308 | 2714 | $handle_dist_run = 1; | ||||
4024 | |||||||
4025 | # Scan EXTRA_DIST to see if we need to distribute anything from a | ||||||
4026 | # subdir. If so, add it to the list. I didn't want to do this | ||||||
4027 | # originally, but there were so many requests that I finally | ||||||
4028 | # relented. | ||||||
4029 | 1308 | 4317 | my $extra_dist = var ('EXTRA_DIST'); | ||||
4030 | |||||||
4031 | 1308 | 4317 | $transform{'DISTCHECK-HOOK'} = !! rule 'distcheck-hook'; | ||||
4032 | 1308 | 6684 | $transform{'GETTEXT'} = $seen_gettext && !$seen_gettext_external; | ||||
4033 | |||||||
4034 | # If the target `dist-hook' exists, make sure it is run. This | ||||||
4035 | # allows users to do random weird things to the distribution | ||||||
4036 | # before it is packaged up. | ||||||
4037 | 1308 | 6215 | push (@dist_targets, 'dist-hook') | ||||
4038 | if user_phony_rule 'dist-hook'; | ||||||
4039 | 1308 | 4612 | $transform{'DIST-TARGETS'} = join (' ', @dist_targets); | ||||
4040 | |||||||
4041 | 1308 | 4498 | my $flm = option ('filename-length-max'); | ||||
4042 | 1308 | 4748 | my $filename_filter = $flm ? '.' x $flm->[1] : ''; | ||||
4043 | |||||||
4044 | 1308 | 5278 | $output_rules .= &file_contents ('distdir', | ||||
4045 | new Automake::Location, | ||||||
4046 | %transform, | ||||||
4047 | FILENAME_FILTER => $filename_filter); | ||||||
4048 | } | ||||||
4049 | |||||||
4050 | |||||||
4051 | # check_directory ($NAME, $WHERE) | ||||||
4052 | # ------------------------------- | ||||||
4053 | # Ensure $NAME is a directory, and that it uses a sane name. | ||||||
4054 | # Use $WHERE as a location in the diagnostic, if any. | ||||||
4055 | sub check_directory ($$) | ||||||
4056 | { | ||||||
4057 | 276 | 679 | my ($dir, $where) = @_; | ||||
4058 | |||||||
4059 | 276 | 2766 | error $where, "required directory $relative_dir/$dir does not exist" | ||||
4060 | unless -d "$relative_dir/$dir"; | ||||||
4061 | |||||||
4062 | # If an `obj/' directory exists, BSD make will enter it before | ||||||
4063 | # reading `Makefile'. Hence the `Makefile' in the current directory | ||||||
4064 | # will not be read. | ||||||
4065 | # | ||||||
4066 | # % cat Makefile | ||||||
4067 | # all: | ||||||
4068 | # echo Hello | ||||||
4069 | # % cat obj/Makefile | ||||||
4070 | # all: | ||||||
4071 | # echo World | ||||||
4072 | # % make # GNU make | ||||||
4073 | # echo Hello | ||||||
4074 | # Hello | ||||||
4075 | # % pmake # BSD make | ||||||
4076 | # echo World | ||||||
4077 | # World | ||||||
4078 | 276 | 879 | msg ('portability', $where, | ||||
4079 | "naming a subdirectory `obj' causes troubles with BSD make") | ||||||
4080 | if $dir eq 'obj'; | ||||||
4081 | |||||||
4082 | # `aux' is probably the most important of the following forbidden name, | ||||||
4083 | # since it's tempting to use it as an AC_CONFIG_AUX_DIR. | ||||||
4084 | 276 | 7405 | msg ('portability', $where, | ||||
4085 | "name `$dir' is reserved on W32 and DOS platforms") | ||||||
4086 | if grep (/^\Q$dir\E$/i, qw/aux lpt1 lpt2 lpt3 com1 com2 com3 com4 con prn/); | ||||||
4087 | } | ||||||
4088 | |||||||
4089 | # check_directories_in_var ($VARIABLE) | ||||||
4090 | # ------------------------------------ | ||||||
4091 | # Recursively check all items in variables $VARIABLE as directories | ||||||
4092 | sub check_directories_in_var ($) | ||||||
4093 | { | ||||||
4094 | 174 | 448 | my ($var) = @_; | ||||
4095 | $var->traverse_recursively | ||||||
4096 | (sub | ||||||
4097 | { | ||||||
4098 | 232 | 611 | my ($var, $val, $cond, $full_cond) = @_; | ||||
4099 | 232 | 726 | check_directory ($val, $var->rdef ($cond)->location); | ||||
4100 | 232 | 766 | return (); | ||||
4101 | }, | ||||||
4102 | undef, | ||||||
4103 | 174 | 1940 | skip_ac_subst => 1); | ||||
4104 | } | ||||||
4105 | |||||||
4106 | # &handle_subdirs () | ||||||
4107 | # ------------------ | ||||||
4108 | # Handle subdirectories. | ||||||
4109 | sub handle_subdirs () | ||||||
4110 | { | ||||||
4111 | 1319 | 4346 | my $subdirs = var ('SUBDIRS'); | ||||
4112 | return | ||||||
4113 | 1319 | 4400 | unless $subdirs; | ||||
4114 | |||||||
4115 | 171 | 1043 | check_directories_in_var $subdirs; | ||||
4116 | |||||||
4117 | 171 | 1091 | my $dsubdirs = var ('DIST_SUBDIRS'); | ||||
4118 | 171 | 540 | check_directories_in_var $dsubdirs | ||||
4119 | if $dsubdirs; | ||||||
4120 | |||||||
4121 | 171 | 707 | $output_rules .= &file_contents ('subdirs', new Automake::Location); | ||||
4122 | 171 | 991 | rvar ('RECURSIVE_TARGETS')->rdef (TRUE)->{'pretty'} = VAR_SORTED; # Gross! | ||||
4123 | } | ||||||
4124 | |||||||
4125 | |||||||
4126 | # ($REGEN, @DEPENDENCIES) | ||||||
4127 | # &scan_aclocal_m4 | ||||||
4128 | # ---------------- | ||||||
4129 | # If aclocal.m4 creation is automated, return the list of its dependencies. | ||||||
4130 | sub scan_aclocal_m4 () | ||||||
4131 | { | ||||||
4132 | 1319 | 2490 | my $regen_aclocal = 0; | ||||
4133 | |||||||
4134 | 1319 | 6705 | set_seen 'CONFIG_STATUS_DEPENDENCIES'; | ||||
4135 | 1319 | 3634 | set_seen 'CONFIGURE_DEPENDENCIES'; | ||||
4136 | |||||||
4137 | 1319 | 9324 | if (-f 'aclocal.m4') | ||||
4138 | { | ||||||
4139 | 1319 | 3581 | &define_variable ("ACLOCAL_M4", '$(top_srcdir)/aclocal.m4', INTERNAL); | ||||
4140 | |||||||
4141 | 1319 | 7623 | my $aclocal = new Automake::XFile "< aclocal.m4"; | ||||
4142 | 1319 | 4684 | my $line = $aclocal->getline; | ||||
4143 | 1319 | 15813 | $regen_aclocal = $line =~ 'generated automatically by aclocal'; | ||||
4144 | } | ||||||
4145 | |||||||
4146 | 1319 | 2992 | my @ac_deps = (); | ||||
4147 | |||||||
4148 | 1319 | 4147 | if (set_seen ('ACLOCAL_M4_SOURCES')) | ||||
4149 | { | ||||||
4150 | 0 | 0 | push (@ac_deps, '$(ACLOCAL_M4_SOURCES)'); | ||||
4151 | 0 | 0 | msg_var ('obsolete', 'ACLOCAL_M4_SOURCES', | ||||
4152 | "`ACLOCAL_M4_SOURCES' is obsolete.\n" | ||||||
4153 | . "It should be safe to simply remove it"); | ||||||
4154 | } | ||||||
4155 | |||||||
4156 | # Note that it might be possible that aclocal.m4 doesn't exist but | ||||||
4157 | # should be auto-generated. This case probably isn't very | ||||||
4158 | # important. | ||||||
4159 | |||||||
4160 | 1319 | 4018 | return ($regen_aclocal, @ac_deps); | ||||
4161 | } | ||||||
4162 | |||||||
4163 | |||||||
4164 | # Helper function for substitute_ac_subst_variables. | ||||||
4165 | sub substitute_ac_subst_variables_worker($) | ||||||
4166 | { | ||||||
4167 | 6 | 16 | my ($token) = @_; | ||||
4168 | 6 | 15 | return "\@$token\@" if var $token; | ||||
4169 | 1 | 4 | return "\${$token\}"; | ||||
4170 | } | ||||||
4171 | |||||||
4172 | # substitute_ac_subst_variables ($TEXT) | ||||||
4173 | # ------------------------------------- | ||||||
4174 | # Replace any occurrence of ${FOO} in $TEXT by @FOO@ if FOO is an AC_SUBST | ||||||
4175 | # variable. | ||||||
4176 | sub substitute_ac_subst_variables ($) | ||||||
4177 | { | ||||||
4178 | 1677 | 3877 | my ($text) = @_; | ||||
4179 | 1677 6 | 5097 21 | $text =~ s/\${([^ \t=:+{}]+)}/&substitute_ac_subst_variables_worker ($1)/ge; | ||||
4180 | 1677 | 6476 | return $text; | ||||
4181 | } | ||||||
4182 | |||||||
4183 | # @DEPENDENCIES | ||||||
4184 | # &prepend_srcdir (@INPUTS) | ||||||
4185 | # ------------------------- | ||||||
4186 | # Prepend $(srcdir) or $(top_srcdir) to all @INPUTS. The idea is that | ||||||
4187 | # if an input file has a directory part the same as the current | ||||||
4188 | # directory, then the directory part is simply replaced by $(srcdir). | ||||||
4189 | # But if the directory part is different, then $(top_srcdir) is | ||||||
4190 | # prepended. | ||||||
4191 | sub prepend_srcdir (@) | ||||||
4192 | { | ||||||
4193 | 2792 | 6769 | my (@inputs) = @_; | ||||
4194 | 2792 | 3131 | my @newinputs; | ||||
4195 | |||||||
4196 | 2792 | 6162 | foreach my $single (@inputs) | ||||
4197 | { | ||||||
4198 | 4111 | 10697 | if (dirname ($single) eq $relative_dir) | ||||
4199 | { | ||||||
4200 | 4066 | 416035 | push (@newinputs, '$(srcdir)/' . basename ($single)); | ||||
4201 | } | ||||||
4202 | else | ||||||
4203 | { | ||||||
4204 | 45 | 4249 | push (@newinputs, '$(top_srcdir)/' . $single); | ||||
4205 | } | ||||||
4206 | } | ||||||
4207 | 2792 | 8158 | return @newinputs; | ||||
4208 | } | ||||||
4209 | |||||||
4210 | # @DEPENDENCIES | ||||||
4211 | # rewrite_inputs_into_dependencies ($OUTPUT, @INPUTS) | ||||||
4212 | # --------------------------------------------------- | ||||||
4213 | # Compute a list of dependencies appropriate for the rebuild | ||||||
4214 | # rule of | ||||||
4215 | # AC_CONFIG_FILES($OUTPUT:$INPUT[0]:$INPUTS[1]:...) | ||||||
4216 | # Also distribute $INPUTs which are not built by another AC_CONFIG_FOOS. | ||||||
4217 | sub rewrite_inputs_into_dependencies ($@) | ||||||
4218 | { | ||||||
4219 | 1455 | 4226 | my ($file, @inputs) = @_; | ||||
4220 | 1455 | 2391 | my @res = (); | ||||
4221 | |||||||
4222 | 1455 | 4462 | for my $i (@inputs) | ||||
4223 | { | ||||||
4224 | # We cannot create dependencies on shell variables. | ||||||
4225 | 1485 | 6232 | next if (substitute_ac_subst_variables $i) =~ /\$/; | ||||
4226 | |||||||
4227 | 1480 | 6945 | if (exists $ac_config_files_location{$i} && $i ne $file) | ||||
4228 | { | ||||||
4229 | 7 | 17 | my $di = dirname $i; | ||||
4230 | 7 | 652 | if ($di eq $relative_dir) | ||||
4231 | { | ||||||
4232 | 3 | 8 | $i = basename $i; | ||||
4233 | } | ||||||
4234 | # In the top-level Makefile we do not use $(top_builddir), because | ||||||
4235 | # we are already there, and since the targets are built without | ||||||
4236 | # a $(top_builddir), it helps BSD Make to match them with | ||||||
4237 | # dependencies. | ||||||
4238 | elsif ($relative_dir ne '.') | ||||||
4239 | { | ||||||
4240 | 3 | 8 | $i = '$(top_builddir)/' . $i; | ||||
4241 | } | ||||||
4242 | } | ||||||
4243 | else | ||||||
4244 | { | ||||||
4245 | 1473 | 16951 | msg ('error', $ac_config_files_location{$file}, | ||||
4246 | "required file `$i' not found") | ||||||
4247 | unless $i =~ /\$/ || exists $output_files{$i} || -f $i; | ||||||
4248 | 1473 | 3452 | ($i) = prepend_srcdir ($i); | ||||
4249 | 1473 | 5064 | push_dist_common ($i); | ||||
4250 | } | ||||||
4251 | 1480 | 4253 | push @res, $i; | ||||
4252 | } | ||||||
4253 | 1455 | 4530 | return @res; | ||||
4254 | } | ||||||
4255 | |||||||
4256 | |||||||
4257 | |||||||
4258 | # &handle_configure ($MAKEFILE_AM, $MAKEFILE_IN, $MAKEFILE, @INPUTS) | ||||||
4259 | # ------------------------------------------------------------------ | ||||||
4260 | # Handle remaking and configure stuff. | ||||||
4261 | # We need the name of the input file, to do proper remaking rules. | ||||||
4262 | sub handle_configure ($$$@) | ||||||
4263 | { | ||||||
4264 | 1319 | 6590 | my ($makefile_am, $makefile_in, $makefile, @inputs) = @_; | ||||
4265 | |||||||
4266 | 1319 | 3942 | prog_error 'empty @inputs' | ||||
4267 | unless @inputs; | ||||||
4268 | |||||||
4269 | 1319 | 7077 | my ($rel_makefile_am, $rel_makefile_in) = prepend_srcdir ($makefile_am, | ||||
4270 | $makefile_in); | ||||||
4271 | 1319 | 3539 | my $rel_makefile = basename $makefile; | ||||
4272 | |||||||
4273 | 1319 | 4588 | my $colon_infile = ':' . join (':', @inputs); | ||||
4274 | 1319 | 5488 | $colon_infile = '' if $colon_infile eq ":$makefile.in"; | ||||
4275 | 1319 | 5875 | my @rewritten = rewrite_inputs_into_dependencies ($makefile, @inputs); | ||||
4276 | 1319 | 6274 | my ($regen_aclocal_m4, @aclocal_m4_deps) = scan_aclocal_m4; | ||||
4277 | 1319 | 7332 | define_pretty_variable ('am__aclocal_m4_deps', TRUE, INTERNAL, | ||||
4278 | @configure_deps, @aclocal_m4_deps, | ||||||
4279 | '$(top_srcdir)/' . $configure_ac); | ||||||
4280 | 1319 | 4192 | my @configuredeps = ('$(am__aclocal_m4_deps)', '$(CONFIGURE_DEPENDENCIES)'); | ||||
4281 | 1319 | 8229 | push @configuredeps, '$(ACLOCAL_M4)' if -f 'aclocal.m4'; | ||||
4282 | 1319 | 3911 | define_pretty_variable ('am__configure_deps', TRUE, INTERNAL, | ||||
4283 | @configuredeps); | ||||||
4284 | |||||||
4285 | 1319 | 6890 | my $automake_options = '--' . (global_option 'cygnus' ? 'cygnus' : $strictness_name) | ||||
4286 | . (global_option 'no-dependencies' ? ' --ignore-deps' : ''); | ||||||
4287 | |||||||
4288 | 1319 | 4926 | $output_rules .= file_contents | ||||
4289 | ('configure', | ||||||
4290 | new Automake::Location, | ||||||
4291 | MAKEFILE => $rel_makefile, | ||||||
4292 | 'MAKEFILE-DEPS' => "@rewritten", | ||||||
4293 | 'CONFIG-MAKEFILE' => ($relative_dir eq '.') ? '$@' : '$(subdir)/$@', | ||||||
4294 | 'MAKEFILE-IN' => $rel_makefile_in, | ||||||
4295 | 'MAKEFILE-IN-DEPS' => "@include_stack", | ||||||
4296 | 'MAKEFILE-AM' => $rel_makefile_am, | ||||||
4297 | 'AUTOMAKE-OPTIONS' => $automake_options, | ||||||
4298 | 'MAKEFILE-AM-SOURCES' => "$makefile$colon_infile", | ||||||
4299 | 'REGEN-ACLOCAL-M4' => $regen_aclocal_m4, | ||||||
4300 | VERBOSE => verbose_flag ('GEN')); | ||||||
4301 | |||||||
4302 | 1319 | 6416 | if ($relative_dir eq '.') | ||||
4303 | { | ||||||
4304 | 1101 | 14687 | &push_dist_common ('acconfig.h') | ||||
4305 | if -f 'acconfig.h'; | ||||||
4306 | } | ||||||
4307 | |||||||
4308 | # If we have a configure header, require it. | ||||||
4309 | 1319 | 2262 | my $hdr_index = 0; | ||||
4310 | 1319 | 1877 | my @distclean_config; | ||||
4311 | 1319 | 5658 | foreach my $spec (@config_headers) | ||||
4312 | { | ||||||
4313 | 36 | 60 | $hdr_index += 1; | ||||
4314 | # $CONFIG_H_PATH: config.h from top level. | ||||||
4315 | 36 | 105 | my ($config_h_path, @ins) = split_config_file_spec ($spec); | ||||
4316 | 36 | 114 | my $config_h_dir = dirname ($config_h_path); | ||||
4317 | |||||||
4318 | # If the header is in the current directory we want to build | ||||||
4319 | # the header here. Otherwise, if we're at the topmost | ||||||
4320 | # directory and the header's directory doesn't have a | ||||||
4321 | # Makefile, then we also want to build the header. | ||||||
4322 | 36 | 3950 | if ($relative_dir eq $config_h_dir | ||||
4323 | || ($relative_dir eq '.' && ! &is_make_dir ($config_h_dir))) | ||||||
4324 | { | ||||||
4325 | 32 | 50 | my ($cn_sans_dir, $stamp_dir); | ||||
4326 | 32 | 81 | if ($relative_dir eq $config_h_dir) | ||||
4327 | { | ||||||
4328 | 22 | 57 | $cn_sans_dir = basename ($config_h_path); | ||||
4329 | 22 | 42 | $stamp_dir = ''; | ||||
4330 | } | ||||||
4331 | else | ||||||
4332 | { | ||||||
4333 | 10 | 19 | $cn_sans_dir = $config_h_path; | ||||
4334 | 10 | 23 | if ($config_h_dir eq '.') | ||||
4335 | { | ||||||
4336 | 0 | 0 | $stamp_dir = ''; | ||||
4337 | } | ||||||
4338 | else | ||||||
4339 | { | ||||||
4340 | 10 | 19 | $stamp_dir = $config_h_dir . '/'; | ||||
4341 | } | ||||||
4342 | } | ||||||
4343 | |||||||
4344 | # This will also distribute all inputs. | ||||||
4345 | 32 | 79 | @ins = rewrite_inputs_into_dependencies ($config_h_path, @ins); | ||||
4346 | |||||||
4347 | # Cannot define rebuild rules for filenames with shell variables. | ||||||
4348 | 32 | 78 | next if (substitute_ac_subst_variables $config_h_path) =~ /\$/; | ||||
4349 | |||||||
4350 | # Header defined in this directory. | ||||||
4351 | 32 | 46 | my @files; | ||||
4352 | 32 | 276 | if (-f $config_h_path . '.top') | ||||
4353 | { | ||||||
4354 | 0 | 0 | push (@files, "$cn_sans_dir.top"); | ||||
4355 | } | ||||||
4356 | 32 | 162 | if (-f $config_h_path . '.bot') | ||||
4357 | { | ||||||
4358 | 0 | 0 | push (@files, "$cn_sans_dir.bot"); | ||||
4359 | } | ||||||
4360 | |||||||
4361 | 32 | 70 | push_dist_common (@files); | ||||
4362 | |||||||
4363 | # For now, acconfig.h can only appear in the top srcdir. | ||||||
4364 | 32 | 163 | if (-f 'acconfig.h') | ||||
4365 | { | ||||||
4366 | 2 | 4 | push (@files, '$(top_srcdir)/acconfig.h'); | ||||
4367 | } | ||||||
4368 | |||||||
4369 | 32 | 93 | my $stamp = "${stamp_dir}stamp-h${hdr_index}"; | ||||
4370 | 32 | 113 | $output_rules .= | ||||
4371 | file_contents ('remake-hdr', | ||||||
4372 | new Automake::Location, | ||||||
4373 | FILES => "@files", | ||||||
4374 | CONFIG_H => $cn_sans_dir, | ||||||
4375 | CONFIG_HIN => $ins[0], | ||||||
4376 | CONFIG_H_DEPS => "@ins", | ||||||
4377 | CONFIG_H_PATH => $config_h_path, | ||||||
4378 | STAMP => "$stamp"); | ||||||
4379 | |||||||
4380 | 32 | 152 | push @distclean_config, $cn_sans_dir, $stamp; | ||||
4381 | } | ||||||
4382 | } | ||||||
4383 | |||||||
4384 | 1319 | 3708 | $output_rules .= file_contents ('clean-hdr', | ||||
4385 | new Automake::Location, | ||||||
4386 | FILES => "@distclean_config") | ||||||
4387 | if @distclean_config; | ||||||
4388 | |||||||
4389 | # Distribute and define mkinstalldirs only if it is already present | ||||||
4390 | # in the package, for backward compatibility (some people may still | ||||||
4391 | # use $(mkinstalldirs)). | ||||||
4392 | 1319 | 5355 | my $mkidpath = "$config_aux_dir/mkinstalldirs"; | ||||
4393 | 1319 | 8447 | if (-f $mkidpath) | ||||
4394 | { | ||||||
4395 | # Use require_file so that any existing script gets updated | ||||||
4396 | # by --force-missing. | ||||||
4397 | 1 | 5 | require_conf_file ($mkidpath, FOREIGN, 'mkinstalldirs'); | ||||
4398 | 1 | 4 | define_variable ('mkinstalldirs', | ||||
4399 | "\$(SHELL) $am_config_aux_dir/mkinstalldirs", INTERNAL); | ||||||
4400 | } | ||||||
4401 | else | ||||||
4402 | { | ||||||
4403 | # Use $(install_sh), not $(MKDIR_P) because the latter requires | ||||||
4404 | # at least one argument, and $(mkinstalldirs) used to work | ||||||
4405 | # even without arguments (e.g. $(mkinstalldirs) $(conditional_dir)). | ||||||
4406 | 1318 | 4681 | define_variable ('mkinstalldirs', '$(install_sh) -d', INTERNAL); | ||||
4407 | } | ||||||
4408 | |||||||
4409 | 1319 | 10175 | reject_var ('CONFIG_HEADER', | ||||
4410 | "`CONFIG_HEADER' is an anachronism; now determined " | ||||||
4411 | . "automatically\nfrom `$configure_ac'"); | ||||||
4412 | |||||||
4413 | 1319 | 2054 | my @config_h; | ||||
4414 | 1319 | 3160 | foreach my $spec (@config_headers) | ||||
4415 | { | ||||||
4416 | 36 | 81 | my ($out, @ins) = split_config_file_spec ($spec); | ||||
4417 | # Generate CONFIG_HEADER define. | ||||||
4418 | 36 | 100 | if ($relative_dir eq dirname ($out)) | ||||
4419 | { | ||||||
4420 | 22 | 2202 | push @config_h, basename ($out); | ||||
4421 | } | ||||||
4422 | else | ||||||
4423 | { | ||||||
4424 | 14 | 1352 | push @config_h, "\$(top_builddir)/$out"; | ||||
4425 | } | ||||||
4426 | } | ||||||
4427 | 1319 | 3671 | define_variable ("CONFIG_HEADER", "@config_h", INTERNAL) | ||||
4428 | if @config_h; | ||||||
4429 | |||||||
4430 | # Now look for other files in this directory which must be remade | ||||||
4431 | # by config.status, and generate rules for them. | ||||||
4432 | 1319 | 2520 | my @actual_other_files = (); | ||||
4433 | # These get cleaned only in a VPATH build. | ||||||
4434 | 1319 | 2175 | my @actual_other_vpath_files = (); | ||||
4435 | 1319 | 3159 | foreach my $lfile (@other_input_files) | ||||
4436 | { | ||||||
4437 | 123 | 127 | my $file; | ||||
4438 | 123 | 130 | my @inputs; | ||||
4439 | 123 | 536 | if ($lfile =~ /^([^:]*):(.*)$/) | ||||
4440 | { | ||||||
4441 | # This is the ":" syntax of AC_OUTPUT. | ||||||
4442 | 66 | 137 | $file = $1; | ||||
4443 | 66 | 238 | @inputs = split (':', $2); | ||||
4444 | } | ||||||
4445 | else | ||||||
4446 | { | ||||||
4447 | # Normal usage. | ||||||
4448 | 57 | 86 | $file = $lfile; | ||||
4449 | 57 | 158 | @inputs = $file . '.in'; | ||||
4450 | } | ||||||
4451 | |||||||
4452 | # Automake files should not be stored in here, but in %MAKE_LIST. | ||||||
4453 | 123 | 759 | prog_error ("$lfile in \@other_input_files\n" | ||||
4454 | . "\@other_input_files = (@other_input_files)") | ||||||
4455 | if -f $file . '.am'; | ||||||
4456 | |||||||
4457 | 123 | 358 | my $local = basename ($file); | ||||
4458 | |||||||
4459 | # We skip files that aren't in this directory. However, if | ||||||
4460 | # the file's directory does not have a Makefile, and we are | ||||||
4461 | # currently doing `.', then we create a rule to rebuild the | ||||||
4462 | # file in the subdir. | ||||||
4463 | 123 | 311 | my $fd = dirname ($file); | ||||
4464 | 123 | 11815 | if ($fd ne $relative_dir) | ||||
4465 | { | ||||||
4466 | 54 | 273 | if ($relative_dir eq '.' && ! &is_make_dir ($fd)) | ||||
4467 | { | ||||||
4468 | 17 | 31 | $local = $file; | ||||
4469 | } | ||||||
4470 | else | ||||||
4471 | { | ||||||
4472 | 37 | 85 | next; | ||||
4473 | } | ||||||
4474 | } | ||||||
4475 | |||||||
4476 | 86 | 236 | my @rewritten_inputs = rewrite_inputs_into_dependencies ($file, @inputs); | ||||
4477 | |||||||
4478 | # Cannot output rules for shell variables. | ||||||
4479 | 86 | 194 | next if (substitute_ac_subst_variables $local) =~ /\$/; | ||||
4480 | |||||||
4481 | 83 | 174 | my $condstr = ''; | ||||
4482 | 83 | 150 | my $cond = $ac_config_files_condition{$lfile}; | ||||
4483 | 83 | 199 | if (defined $cond) | ||||
4484 | { | ||||||
4485 | 9 | 24 | $condstr = $cond->subst_string; | ||||
4486 | 9 | 29 | Automake::Rule::define ($local, $configure_ac, RULE_AUTOMAKE, $cond, | ||||
4487 | $ac_config_files_location{$file}); | ||||||
4488 | } | ||||||
4489 | 83 | 647 | $output_rules .= ($condstr . $local . ': ' | ||||
4490 | . '$(top_builddir)/config.status ' | ||||||
4491 | . "@rewritten_inputs\n" | ||||||
4492 | . $condstr . "\t" | ||||||
4493 | . 'cd $(top_builddir) && ' | ||||||
4494 | . '$(SHELL) ./config.status ' | ||||||
4495 | . ($relative_dir eq '.' ? '' : '$(subdir)/') | ||||||
4496 | . '$@' | ||||||
4497 | . "\n"); | ||||||
4498 | 83 | 257 | push (@actual_other_files, $local); | ||||
4499 | } | ||||||
4500 | |||||||
4501 | # For links we should clean destinations and distribute sources. | ||||||
4502 | 1319 | 3427 | foreach my $spec (@config_links) | ||||
4503 | { | ||||||
4504 | 39 | 112 | my ($link, $file) = split /:/, $spec; | ||||
4505 | # Some people do AC_CONFIG_LINKS($computed). We only handle | ||||||
4506 | # the DEST:SRC form. | ||||||
4507 | 39 | 78 | next unless $file; | ||||
4508 | 37 | 58 | my $where = $ac_config_files_location{$link}; | ||||
4509 | |||||||
4510 | # Skip destinations that contain shell variables. | ||||||
4511 | 37 | 68 | if ((substitute_ac_subst_variables $link) !~ /\$/) | ||||
4512 | { | ||||||
4513 | # We skip links that aren't in this directory. However, if | ||||||
4514 | # the link's directory does not have a Makefile, and we are | ||||||
4515 | # currently doing `.', then we add the link to CONFIG_CLEAN_FILES | ||||||
4516 | # in `.'s Makefile.in. | ||||||
4517 | 35 | 78 | my $local = basename ($link); | ||||
4518 | 35 | 81 | my $fd = dirname ($link); | ||||
4519 | 35 | 3271 | if ($fd ne $relative_dir) | ||||
4520 | { | ||||||
4521 | 21 | 93 | if ($relative_dir eq '.' && ! &is_make_dir ($fd)) | ||||
4522 | { | ||||||
4523 | 4 | 8 | $local = $link; | ||||
4524 | } | ||||||
4525 | else | ||||||
4526 | { | ||||||
4527 | 17 | 24 | $local = undef; | ||||
4528 | } | ||||||
4529 | } | ||||||
4530 | 35 | 67 | if ($file ne $link) | ||||
4531 | { | ||||||
4532 | 27 | 63 | push @actual_other_files, $local if $local; | ||||
4533 | } | ||||||
4534 | else | ||||||
4535 | { | ||||||
4536 | 8 | 19 | push @actual_other_vpath_files, $local if $local; | ||||
4537 | } | ||||||
4538 | } | ||||||
4539 | |||||||
4540 | # Do not process sources that contain shell variables. | ||||||
4541 | 37 | 68 | if ((substitute_ac_subst_variables $file) !~ /\$/) | ||||
4542 | { | ||||||
4543 | 35 | 67 | my $fd = dirname ($file); | ||||
4544 | |||||||
4545 | # We distribute files that are in this directory. | ||||||
4546 | # At the top-level (`.') we also distribute files whose | ||||||
4547 | # directory does not have a Makefile. | ||||||
4548 | 35 | 3264 | if (($fd eq $relative_dir) | ||||
4549 | || ($relative_dir eq '.' && ! &is_make_dir ($fd))) | ||||||
4550 | { | ||||||
4551 | # The following will distribute $file as a side-effect when | ||||||
4552 | # it is appropriate (i.e., when $file is not already an output). | ||||||
4553 | # We do not need the result, just the side-effect. | ||||||
4554 | 18 | 41 | rewrite_inputs_into_dependencies ($link, $file); | ||||
4555 | } | ||||||
4556 | } | ||||||
4557 | } | ||||||
4558 | |||||||
4559 | # These files get removed by "make distclean". | ||||||
4560 | 1319 | 3688 | define_pretty_variable ('am__CONFIG_CLEAN_FILES', TRUE, INTERNAL, | ||||
4561 | @actual_other_files) | ||||||
4562 | if @actual_other_files; | ||||||
4563 | # Likewise, but only in a VPATH build. | ||||||
4564 | 1319 | 6294 | define_pretty_variable ('am__CONFIG_CLEAN_VPATH_FILES', TRUE, INTERNAL, | ||||
4565 | @actual_other_vpath_files) | ||||||
4566 | if @actual_other_vpath_files; | ||||||
4567 | } | ||||||
4568 | |||||||
4569 | # Handle C headers. | ||||||
4570 | sub handle_headers | ||||||
4571 | { | ||||||
4572 | 1319 | 4630 | my @r = &am_install_var ('-defaultdist', 'header', 'HEADERS', 'include', | ||||
4573 | 'oldinclude', 'pkginclude', | ||||||
4574 | 'noinst', 'check'); | ||||||
4575 | 1319 | 3771 | foreach (@r) | ||||
4576 | { | ||||||
4577 | 400 | 2015 | next unless $_->[1] =~ /\..*$/; | ||||
4578 | 394 | 825 | &saw_extension ($&); | ||||
4579 | } | ||||||
4580 | } | ||||||
4581 | |||||||
4582 | sub handle_gettext | ||||||
4583 | { | ||||||
4584 | 1319 | 6219 | return if ! $seen_gettext || $relative_dir ne '.'; | ||||
4585 | |||||||
4586 | 15 | 43 | my $subdirs = var 'SUBDIRS'; | ||||
4587 | |||||||
4588 | 15 | 43 | if (! $subdirs) | ||||
4589 | { | ||||||
4590 | 4 | 11 | err_ac "AM_GNU_GETTEXT used but SUBDIRS not defined"; | ||||
4591 | 4 | 9 | return; | ||||
4592 | } | ||||||
4593 | |||||||
4594 | # Perform some sanity checks to help users get the right setup. | ||||||
4595 | # We disable these tests when po/ doesn't exist in order not to disallow | ||||||
4596 | # unusual gettext setups. | ||||||
4597 | # | ||||||
4598 | # Bruno Haible: | ||||||
4599 | # | The idea is: | ||||||
4600 | # | | ||||||
4601 | # | 1) If a package doesn't have a directory po/ at top level, it | ||||||
4602 | # | will likely have multiple po/ directories in subpackages. | ||||||
4603 | # | | ||||||
4604 | # | 2) It is useful to warn for the absence of intl/ if AM_GNU_GETTEXT | ||||||
4605 | # | is used without 'external'. It is also useful to warn for the | ||||||
4606 | # | presence of intl/ if AM_GNU_GETTEXT([external]) is used. Both | ||||||
4607 | # | warnings apply only to the usual layout of packages, therefore | ||||||
4608 | # | they should both be disabled if no po/ directory is found at | ||||||
4609 | # | top level. | ||||||
4610 | |||||||
4611 | 11 | 74 | if (-d 'po') | ||||
4612 | { | ||||||
4613 | 10 | 47 | my @subdirs = $subdirs->value_as_list_recursive; | ||||
4614 | |||||||
4615 | 10 | 112 | msg_var ('syntax', $subdirs, | ||||
4616 | "AM_GNU_GETTEXT used but `po' not in SUBDIRS") | ||||||
4617 | if ! grep ($_ eq 'po', @subdirs); | ||||||
4618 | |||||||
4619 | # intl/ is not required when AM_GNU_GETTEXT is called with the | ||||||
4620 | # `external' option and AM_GNU_GETTEXT_INTL_SUBDIR is not called. | ||||||
4621 | 10 | 143 | msg_var ('syntax', $subdirs, | ||||
4622 | "AM_GNU_GETTEXT used but `intl' not in SUBDIRS") | ||||||
4623 | if (! ($seen_gettext_external && ! $seen_gettext_intl) | ||||||
4624 | && ! grep ($_ eq 'intl', @subdirs)); | ||||||
4625 | |||||||
4626 | # intl/ should not be used with AM_GNU_GETTEXT([external]), except | ||||||
4627 | # if AM_GNU_GETTEXT_INTL_SUBDIR is called. | ||||||
4628 | 10 | 156 | msg_var ('syntax', $subdirs, | ||||
4629 | "`intl' should not be in SUBDIRS when " | ||||||
4630 | . "AM_GNU_GETTEXT([external]) is used") | ||||||
4631 | if ($seen_gettext_external && ! $seen_gettext_intl | ||||||
4632 | && grep ($_ eq 'intl', @subdirs)); | ||||||
4633 | } | ||||||
4634 | |||||||
4635 | 11 | 39 | require_file ($ac_gettext_location, GNU, 'ABOUT-NLS'); | ||||
4636 | } | ||||||
4637 | |||||||
4638 | # Handle footer elements. | ||||||
4639 | sub handle_footer | ||||||
4640 | { | ||||||
4641 | 1319 | 8456 | reject_rule ('.SUFFIXES', | ||||
4642 | "use variable `SUFFIXES', not target `.SUFFIXES'"); | ||||||
4643 | |||||||
4644 | # Note: AIX 4.1 /bin/make will fail if any suffix rule appears | ||||||
4645 | # before .SUFFIXES. So we make sure that .SUFFIXES appears before | ||||||
4646 | # anything else, by sticking it right after the default: target. | ||||||
4647 | 1319 | 2717 | $output_header .= ".SUFFIXES:\n"; | ||||
4648 | 1319 | 4911 | my $suffixes = var 'SUFFIXES'; | ||||
4649 | 1319 | 5142 | my @suffixes = Automake::Rule::suffixes; | ||||
4650 | 1319 | 9024 | if (@suffixes || $suffixes) | ||||
4651 | { | ||||||
4652 | # Make sure SUFFIXES has unique elements. Sort them to ensure | ||||||
4653 | # the output remains consistent. However, $(SUFFIXES) is | ||||||
4654 | # always at the start of the list, unsorted. This is done | ||||||
4655 | # because make will choose rules depending on the ordering of | ||||||
4656 | # suffixes, and this lets the user have some control. Push | ||||||
4657 | # actual suffixes, and not $(SUFFIXES). Some versions of make | ||||||
4658 | # do not like variable substitutions on the .SUFFIXES line. | ||||||
4659 | 644 | 2110 | my @user_suffixes = ($suffixes | ||||
4660 | ? $suffixes->value_as_list_recursive : ()); | ||||||
4661 | |||||||
4662 | 644 3532 | 1472 7964 | my %suffixes = map { $_ => 1 } @suffixes; | ||||
4663 | 644 | 1405 | delete @suffixes{@user_suffixes}; | ||||
4664 | |||||||
4665 | 644 | 5432 | $output_header .= (".SUFFIXES: " | ||||
4666 | . join (' ', @user_suffixes, sort keys %suffixes) | ||||||
4667 | . "\n"); | ||||||
4668 | } | ||||||
4669 | |||||||
4670 | 1319 | 6271 | $output_trailer .= file_contents ('footer', new Automake::Location); | ||||
4671 | } | ||||||
4672 | |||||||
4673 | |||||||
4674 | # Generate `make install' rules. | ||||||
4675 | sub handle_install () | ||||||
4676 | { | ||||||
4677 | 1319 | 5700 | $output_rules .= &file_contents | ||||
4678 | ('install', | ||||||
4679 | new Automake::Location, | ||||||
4680 | maybe_BUILT_SOURCES => (set_seen ('BUILT_SOURCES') | ||||||
4681 | ? (" \$(BUILT_SOURCES)\n" | ||||||
4682 | . "\t\$(MAKE) \$(AM_MAKEFLAGS)") | ||||||
4683 | : ''), | ||||||
4684 | 'installdirs-local' => (user_phony_rule 'installdirs-local' | ||||||
4685 | ? ' installdirs-local' : ''), | ||||||
4686 | am__installdirs => variable_value ('am__installdirs') || '', | ||||||
4687 | MULTI => $seen_multilib && $relative_dir eq '.'); | ||||||
4688 | } | ||||||
4689 | |||||||
4690 | |||||||
4691 | # Deal with all and all-am. | ||||||
4692 | sub handle_all ($) | ||||||
4693 | { | ||||||
4694 | 1319 | 3514 | my ($makefile) = @_; | ||||
4695 | |||||||
4696 | # Output `all-am'. | ||||||
4697 | |||||||
4698 | # Put this at the beginning for the sake of non-GNU makes. This | ||||||
4699 | # is still wrong if these makes can run parallel jobs. But it is | ||||||
4700 | # right enough. | ||||||
4701 | 1319 | 6504 | unshift (@all, basename ($makefile)); | ||||
4702 | |||||||
4703 | 1319 | 4568 | foreach my $spec (@config_headers) | ||||
4704 | { | ||||||
4705 | 36 | 478 | my ($out, @ins) = split_config_file_spec ($spec); | ||||
4706 | 36 | 103 | push (@all, basename ($out)) | ||||
4707 | if dirname ($out) eq $relative_dir; | ||||||
4708 | } | ||||||
4709 | |||||||
4710 | # Install `all' hooks. | ||||||
4711 | 1319 | 5064 | push (@all, "all-local") | ||||
4712 | if user_phony_rule "all-local"; | ||||||
4713 | |||||||
4714 | 1319 | 6120 | &pretty_print_rule ("all-am:", "\t\t", @all); | ||||
4715 | 1319 | 4656 | &depend ('.PHONY', 'all-am', 'all'); | ||||
4716 | |||||||
4717 | |||||||
4718 | # Output `all'. | ||||||
4719 | |||||||
4720 | 1319 | 2720 | my @local_headers = (); | ||||
4721 | 1319 | 4155 | push @local_headers, '$(BUILT_SOURCES)' | ||||
4722 | if var ('BUILT_SOURCES'); | ||||||
4723 | 1319 | 3175 | foreach my $spec (@config_headers) | ||||
4724 | { | ||||||
4725 | 36 | 431 | my ($out, @ins) = split_config_file_spec ($spec); | ||||
4726 | 36 | 87 | push @local_headers, basename ($out) | ||||
4727 | if dirname ($out) eq $relative_dir; | ||||||
4728 | } | ||||||
4729 | |||||||
4730 | 1319 | 5099 | if (@local_headers) | ||||
4731 | { | ||||||
4732 | # We need to make sure config.h is built before we recurse. | ||||||
4733 | # We also want to make sure that built sources are built | ||||||
4734 | # before any ordinary `all' targets are run. We can't do this | ||||||
4735 | # by changing the order of dependencies to the "all" because | ||||||
4736 | # that breaks when using parallel makes. Instead we handle | ||||||
4737 | # things explicitly. | ||||||
4738 | 38 | 212 | $output_all .= ("all: @local_headers" | ||||
4739 | . "\n\t" | ||||||
4740 | . '$(MAKE) $(AM_MAKEFLAGS) ' | ||||||
4741 | . (var ('SUBDIRS') ? 'all-recursive' : 'all-am') | ||||||
4742 | . "\n\n"); | ||||||
4743 | 38 | 303 | depend ('.MAKE', 'all'); | ||||
4744 | } | ||||||
4745 | else | ||||||
4746 | { | ||||||
4747 | 1281 | 4183 | $output_all .= "all: " . (var ('SUBDIRS') | ||||
4748 | ? 'all-recursive' : 'all-am') . "\n\n"; | ||||||
4749 | } | ||||||
4750 | } | ||||||
4751 | |||||||
4752 | |||||||
4753 | # &do_check_merge_target () | ||||||
4754 | # ------------------------- | ||||||
4755 | # Handle check merge target specially. | ||||||
4756 | sub do_check_merge_target () | ||||||
4757 | { | ||||||
4758 | # Include user-defined local form of target. | ||||||
4759 | 1319 | 4799 | push @check_tests, 'check-local' | ||||
4760 | if user_phony_rule 'check-local'; | ||||||
4761 | |||||||
4762 | # In --cygnus mode, check doesn't depend on all. | ||||||
4763 | 1319 | 5100 | if (option 'cygnus') | ||||
4764 | { | ||||||
4765 | # Just run the local check rules. | ||||||
4766 | 10 | 48 | pretty_print_rule ('check-am:', "\t\t", @check); | ||||
4767 | } | ||||||
4768 | else | ||||||
4769 | { | ||||||
4770 | # The check target must depend on the local equivalent of | ||||||
4771 | # `all', to ensure all the primary targets are built. Then it | ||||||
4772 | # must build the local check rules. | ||||||
4773 | 1309 | 3503 | $output_rules .= "check-am: all-am\n"; | ||||
4774 | 1309 | 4113 | if (@check) | ||||
4775 | { | ||||||
4776 | 58 | 221 | pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ", | ||||
4777 | @check); | ||||||
4778 | 58 | 197 | depend ('.MAKE', 'check-am'); | ||||
4779 | } | ||||||
4780 | } | ||||||
4781 | 1319 | 3690 | if (@check_tests) | ||||
4782 | { | ||||||
4783 | 113 | 402 | pretty_print_rule ("\t\$(MAKE) \$(AM_MAKEFLAGS)", "\t ", | ||||
4784 | @check_tests); | ||||||
4785 | 113 | 368 | depend ('.MAKE', 'check-am'); | ||||
4786 | } | ||||||
4787 | |||||||
4788 | 1319 | 5074 | depend '.PHONY', 'check', 'check-am'; | ||||
4789 | # Handle recursion. We have to honor BUILT_SOURCES like for `all:'. | ||||||
4790 | 1319 | 5035 | $output_rules .= ("check: " | ||||
4791 | . (var ('BUILT_SOURCES') | ||||||
4792 | ? "\$(BUILT_SOURCES)\n\t\$(MAKE) \$(AM_MAKEFLAGS) " | ||||||
4793 | : '') | ||||||
4794 | . (var ('SUBDIRS') ? 'check-recursive' : 'check-am') | ||||||
4795 | . "\n"); | ||||||
4796 | 1319 | 4200 | depend ('.MAKE', 'check') | ||||
4797 | if var ('BUILT_SOURCES'); | ||||||
4798 | } | ||||||
4799 | |||||||
4800 | # handle_clean ($MAKEFILE) | ||||||
4801 | # ------------------------ | ||||||
4802 | # Handle all 'clean' targets. | ||||||
4803 | sub handle_clean ($) | ||||||
4804 | { | ||||||
4805 | 1319 | 3586 | my ($makefile) = @_; | ||||
4806 | |||||||
4807 | # Clean the files listed in user variables if they exist. | ||||||
4808 | 1319 | 4931 | $clean_files{'$(MOSTLYCLEANFILES)'} = MOSTLY_CLEAN | ||||
4809 | if var ('MOSTLYCLEANFILES'); | ||||||
4810 | 1319 | 4864 | $clean_files{'$(CLEANFILES)'} = CLEAN | ||||
4811 | if var ('CLEANFILES'); | ||||||
4812 | 1319 | 4737 | $clean_files{'$(DISTCLEANFILES)'} = DIST_CLEAN | ||||
4813 | if var ('DISTCLEANFILES'); | ||||||
4814 | 1319 | 4463 | $clean_files{'$(MAINTAINERCLEANFILES)'} = MAINTAINER_CLEAN | ||||
4815 | if var ('MAINTAINERCLEANFILES'); | ||||||
4816 | |||||||
4817 | # Built sources are automatically removed by maintainer-clean. | ||||||
4818 | 1319 | 4709 | $clean_files{'$(BUILT_SOURCES)'} = MAINTAINER_CLEAN | ||||
4819 | if var ('BUILT_SOURCES'); | ||||||
4820 | |||||||
4821 | # Compute a list of "rm"s to run for each target. | ||||||
4822 | 1319 | 13190 | my %rms = (MOSTLY_CLEAN, [], | ||||
4823 | CLEAN, [], | ||||||
4824 | DIST_CLEAN, [], | ||||||
4825 | MAINTAINER_CLEAN, []); | ||||||
4826 | |||||||
4827 | 1319 | 6037 | foreach my $file (keys %clean_files) | ||||
4828 | { | ||||||
4829 | 576 | 1053 | my $when = $clean_files{$file}; | ||||
4830 | 576 | 1532 | prog_error 'invalid entry in %clean_files' | ||||
4831 | unless exists $rms{$when}; | ||||||
4832 | |||||||
4833 | 576 | 1205 | my $rm = "rm -f $file"; | ||||
4834 | # If file is a variable, make sure when don't call `rm -f' without args. | ||||||
4835 | 576 | 3205 | $rm ="test -z \"$file\" || $rm" | ||||
4836 | if ($file =~ /^\s*\$(\(.*\)|\{.*\})\s*$/); | ||||||
4837 | |||||||
4838 | 576 576 | 764 2247 | push @{$rms{$when}}, "\t-$rm\n"; | ||||
4839 | } | ||||||
4840 | |||||||
4841 | 1319 | 2592 | my $distclean_config = ''; | ||||
4842 | 1319 | 2269 | my $onlyvpath = ''; | ||||
4843 | 1319 | 3081 | for my $var ('CONFIG_CLEAN_FILES', 'CONFIG_CLEAN_VPATH_FILES') | ||||
4844 | { | ||||||
4845 | 2638 | 4660 | for my $prefix ('', 'am__') | ||||
4846 | { | ||||||
4847 | 5276 | 14384 | $distclean_config .= "\t-" . $onlyvpath . "test -z \"\$(" . $prefix . $var | ||||
4848 | . ")\" || rm -f \$(" . $prefix . $var . ")\n" | ||||||
4849 | if var ($prefix . $var); | ||||||
4850 | } | ||||||
4851 | 2638 | 5372 | $onlyvpath = "test . = \"\$(srcdir)\" || "; | ||||
4852 | } | ||||||
4853 | |||||||
4854 | 1319 | 10155 | $output_rules .= &file_contents | ||||
4855 | ('clean', | ||||||
4856 | new Automake::Location, | ||||||
4857 | 1319 | 6263 | MOSTLYCLEAN_RMS => join ('', sort @{$rms{&MOSTLY_CLEAN}}), | ||||
4858 | 1319 | 6356 | CLEAN_RMS => join ('', sort @{$rms{&CLEAN}}), | ||||
4859 | 1319 | 7311 | DISTCLEAN_RMS => join ('', sort @{$rms{&DIST_CLEAN}}) . $distclean_config, | ||||
4860 | 1319 | 5762 | MAINTAINER_CLEAN_RMS => join ('', sort @{$rms{&MAINTAINER_CLEAN}}), | ||||
4861 | MAKEFILE => basename $makefile, | ||||||
4862 | ); | ||||||
4863 | } | ||||||
4864 | |||||||
4865 | |||||||
4866 | # &target_cmp ($A, $B) | ||||||
4867 | # -------------------- | ||||||
4868 | # Subroutine for &handle_factored_dependencies to let `.PHONY' and | ||||||
4869 | # other `.TARGETS' be last. | ||||||
4870 | sub target_cmp | ||||||
4871 | { | ||||||
4872 | 191255 | 319449 | return 0 if $a eq $b; | ||||
4873 | |||||||
4874 | 191255 | 229654 | my $a1 = substr ($a, 0, 1); | ||||
4875 | 191255 | 225265 | my $b1 = substr ($b, 0, 1); | ||||
4876 | 191255 | 323562 | if ($a1 ne $b1) | ||||
4877 | { | ||||||
4878 | 105520 | 173014 | return -1 if $b1 eq '.'; | ||||
4879 | 96287 | 167381 | return 1 if $a1 eq '.'; | ||||
4880 | } | ||||||
4881 | 179384 | 185694 | return $a cmp $b; | ||||
4882 | } | ||||||
4883 | |||||||
4884 | |||||||
4885 | # &handle_factored_dependencies () | ||||||
4886 | # -------------------------------- | ||||||
4887 | # Handle everything related to gathered targets. | ||||||
4888 | sub handle_factored_dependencies | ||||||
4889 | { | ||||||
4890 | # Reject bad hooks. | ||||||
4891 | 1319 | 6103 | foreach my $utarg ('uninstall-data-local', 'uninstall-data-hook', | ||||
4892 | 'uninstall-exec-local', 'uninstall-exec-hook', | ||||||
4893 | 'uninstall-dvi-local', | ||||||
4894 | 'uninstall-html-local', | ||||||
4895 | 'uninstall-info-local', | ||||||
4896 | 'uninstall-pdf-local', | ||||||
4897 | 'uninstall-ps-local') | ||||||
4898 | { | ||||||
4899 | 11871 | 13657 | my $x = $utarg; | ||||
4900 | 11871 | 31121 | $x =~ s/-.*-/-/; | ||||
4901 | 11871 | 39665 | reject_rule ($utarg, "use `$x', not `$utarg'"); | ||||
4902 | } | ||||||
4903 | |||||||
4904 | 1319 | 4488 | reject_rule ('install-local', | ||||
4905 | "use `install-data-local' or `install-exec-local', " | ||||||
4906 | . "not `install-local'"); | ||||||
4907 | |||||||
4908 | 1319 | 4111 | reject_rule ('install-hook', | ||||
4909 | "use `install-data-hook' or `install-exec-hook', " | ||||||
4910 | . "not `install-hook'"); | ||||||
4911 | |||||||
4912 | # Install the -local hooks. | ||||||
4913 | 1319 | 9364 | foreach (keys %dependencies) | ||||
4914 | { | ||||||
4915 | # Hooks are installed on the -am targets. | ||||||
4916 | 48803 | 124480 | s/-am$// or next; | ||||
4917 | 23742 | 47393 | depend ("$_-am", "$_-local") | ||||
4918 | if user_phony_rule "$_-local"; | ||||||
4919 | } | ||||||
4920 | |||||||
4921 | # Install the -hook hooks. | ||||||
4922 | # FIXME: Why not be as liberal as we are with -local hooks? | ||||||
4923 | 1319 | 5854 | foreach ('install-exec', 'install-data', 'uninstall') | ||||
4924 | { | ||||||
4925 | 3957 | 8888 | if (user_phony_rule "$_-hook") | ||||
4926 | { | ||||||
4927 | 5 | 20 | depend ('.MAKE', "$_-am"); | ||||
4928 | 5 | 24 | register_action("$_-am", | ||||
4929 | ("\t\@\$(NORMAL_INSTALL)\n" | ||||||
4930 | . "\t\$(MAKE) \$(AM_MAKEFLAGS) $_-hook")); | ||||||
4931 | } | ||||||
4932 | } | ||||||
4933 | |||||||
4934 | # All the required targets are phony. | ||||||
4935 | 1319 | 11303 | depend ('.PHONY', keys %required_targets); | ||||
4936 | |||||||
4937 | # Actually output gathered targets. | ||||||
4938 | 1319 | 1270 | foreach (sort target_cmp keys %dependencies) | ||||
4939 | { | ||||||
4940 | # If there is nothing about this guy, skip it. | ||||||
4941 | next | ||||||
4942 | 48803 48803 | 45788 289070 | unless (@{$dependencies{$_}} | ||||
4943 | || $actions{$_} | ||||||
4944 | || $required_targets{$_}); | ||||||
4945 | |||||||
4946 | # Define gathered targets in undefined conditions. | ||||||
4947 | # FIXME: Right now we must handle .PHONY as an exception, | ||||||
4948 | # because people write things like | ||||||
4949 | # .PHONY: myphonytarget | ||||||
4950 | # to append dependencies. This would not work if Automake | ||||||
4951 | # refrained from defining its own .PHONY target as it does | ||||||
4952 | # with other overridden targets. | ||||||
4953 | # Likewise for `.MAKE'. | ||||||
4954 | 46185 | 69150 | my @undefined_conds = (TRUE,); | ||||
4955 | 46185 | 218282 | if ($_ ne '.PHONY' && $_ ne '.MAKE') | ||||
4956 | { | ||||||
4957 | 43547 | 112831 | @undefined_conds = | ||||
4958 | Automake::Rule::define ($_, 'internal', | ||||||
4959 | RULE_AUTOMAKE, TRUE, INTERNAL); | ||||||
4960 | } | ||||||
4961 | 46185 46185 | 57378 218870 | my @uniq_deps = uniq (sort @{$dependencies{$_}}); | ||||
4962 | 46185 | 74608 | foreach my $cond (@undefined_conds) | ||||
4963 | { | ||||||
4964 | 46177 | 107465 | my $condstr = $cond->subst_string; | ||||
4965 | 46177 | 125634 | &pretty_print_rule ("$condstr$_:", "$condstr\t", @uniq_deps); | ||||
4966 | 46177 | 131844 | $output_rules .= $actions{$_} if defined $actions{$_}; | ||||
4967 | 46177 | 115103 | $output_rules .= "\n"; | ||||
4968 | } | ||||||
4969 | } | ||||||
4970 | } | ||||||
4971 | |||||||
4972 | |||||||
4973 | # &handle_tests_dejagnu () | ||||||
4974 | # ------------------------ | ||||||
4975 | sub handle_tests_dejagnu | ||||||
4976 | { | ||||||
4977 | 10 | 40 | push (@check_tests, 'check-DEJAGNU'); | ||||
4978 | 10 | 61 | $output_rules .= file_contents ('dejagnu', new Automake::Location); | ||||
4979 | } | ||||||
4980 | |||||||
4981 | |||||||
4982 | # handle_tests ($MAKEFILE) | ||||||
4983 | # ------------------------ | ||||||
4984 | # Handle TESTS variable and other checks. | ||||||
4985 | sub handle_tests ($) | ||||||
4986 | { | ||||||
4987 | 1319 | 3455 | my ($makefile) = @_; | ||||
4988 | |||||||
4989 | 1319 | 4284 | if (option 'dejagnu') | ||||
4990 | { | ||||||
4991 | 10 | 32 | &handle_tests_dejagnu; | ||||
4992 | } | ||||||
4993 | else | ||||||
4994 | { | ||||||
4995 | 1309 | 4944 | foreach my $c ('DEJATOOL', 'RUNTEST', 'RUNTESTFLAGS') | ||||
4996 | { | ||||||
4997 | 3927 | 14291 | reject_var ($c, "`$c' defined but `dejagnu' not in " | ||||
4998 | . "`AUTOMAKE_OPTIONS'"); | ||||||
4999 | } | ||||||
5000 | } | ||||||
5001 | |||||||
5002 | 1319 | 4177 | if (var ('TESTS')) | ||||
5003 | { | ||||||
5004 | 84 | 195 | push (@check_tests, 'check-TESTS'); | ||||
5005 | 84 | 373 | $output_rules .= &file_contents ('check', new Automake::Location, | ||||
5006 | COLOR => !! option 'color-tests', | ||||||
5007 | PARALLEL_TESTS => !! option 'parallel-tests', | ||||||
5008 | MAKEFILE => basename $makefile); | ||||||
5009 | |||||||
5010 | # Tests that are known programs should have $(EXEEXT) appended. | ||||||
5011 | # For matching purposes, we need to adjust XFAIL_TESTS as well. | ||||||
5012 | 84 181 | 1061 799 | append_exeext { exists $known_programs{$_[0]} } 'TESTS'; | ||||
5013 | 84 35 | 543 141 | append_exeext { exists $known_programs{$_[0]} } 'XFAIL_TESTS' | ||||
5014 | if (var ('XFAIL_TESTS')); | ||||||
5015 | |||||||
5016 | 84 | 373 | if (option 'parallel-tests') | ||||
5017 | { | ||||||
5018 | 46 | 186 | define_variable ('TEST_SUITE_LOG', 'test-suite.log', INTERNAL); | ||||
5019 | 46 | 128 | define_variable ('TEST_SUITE_HTML', '$(TEST_SUITE_LOG:.log=.html)', INTERNAL); | ||||
5020 | 46 | 94 | my $suff = '.test'; | ||||
5021 | 46 | 79 | my $at_exeext = ''; | ||||
5022 | 46 | 121 | my $handle_exeext = exists $configure_vars{'EXEEXT'}; | ||||
5023 | 46 | 134 | if ($handle_exeext) | ||||
5024 | { | ||||||
5025 | 24 | 77 | $at_exeext = subst ('EXEEXT'); | ||||
5026 | 24 | 68 | $suff = $at_exeext . ' ' . $suff; | ||||
5027 | } | ||||||
5028 | 46 | 126 | define_variable ('TEST_EXTENSIONS', $suff, INTERNAL); | ||||
5029 | # FIXME: this mishandles conditions. | ||||||
5030 | 46 | 160 | my @test_suffixes = (var 'TEST_EXTENSIONS')->value_as_list_recursive; | ||||
5031 | 46 | 335 | if ($handle_exeext) | ||||
5032 | { | ||||||
5033 | 24 | 83 | unshift (@test_suffixes, $at_exeext) | ||||
5034 | unless $test_suffixes[0] eq $at_exeext; | ||||||
5035 | } | ||||||
5036 | 46 | 106 | unshift (@test_suffixes, ''); | ||||
5037 | |||||||
5038 | transform_variable_recursively | ||||||
5039 | ('TESTS', 'TEST_LOGS', 'am__testlogs', 1, INTERNAL, | ||||||
5040 | sub { | ||||||
5041 | 126 | 274 | my ($subvar, $val, $cond, $full_cond) = @_; | ||||
5042 | 126 | 165 | my $obj = $val; | ||||
5043 | 126 | 360 | return $obj | ||||
5044 | if $val =~ /^\@.*\@$/; | ||||||
5045 | 124 | 280 | $obj =~ s/\$\(EXEEXT\)$//o; | ||||
5046 | |||||||
5047 | 124 | 286 | if ($val =~ /(\$\((top_)?srcdir\))\//o) | ||||
5048 | { | ||||||
5049 | 2 | 7 | msg ('error', $subvar->rdef ($cond)->location, | ||||
5050 | "parallel-tests: using `$1' in TESTS is currently broken: `$val'"); | ||||||
5051 | } | ||||||
5052 | |||||||
5053 | 124 | 226 | foreach my $test_suffix (@test_suffixes) | ||||
5054 | { | ||||||
5055 | next | ||||||
5056 | 325 | 1462 | if $test_suffix eq $at_exeext || $test_suffix eq ''; | ||||
5057 | 134 | 659 | return substr ($obj, 0, length ($obj) - length ($test_suffix)) . '.log' | ||||
5058 | if substr ($obj, - length ($test_suffix)) eq $test_suffix; | ||||||
5059 | } | ||||||
5060 | 78 | 129 | $obj .= '.log'; | ||||
5061 | 78 | 116 | my $compile = 'LOG_COMPILE'; | ||||
5062 | 78 | 168 | define_variable ($compile, | ||||
5063 | '$(LOG_COMPILER) $(AM_LOG_FLAGS) $(LOG_FLAGS)', INTERNAL); | ||||||
5064 | 78 | 269 | $output_rules .= file_contents ('check2', new Automake::Location, | ||||
5065 | GENERIC => 0, | ||||||
5066 | OBJ => $obj, | ||||||
5067 | SOURCE => $val, | ||||||
5068 | COMPILE =>'$(' . $compile . ')', | ||||||
5069 | EXT => '', | ||||||
5070 | am__EXEEXT => 'FALSE'); | ||||||
5071 | 78 | 339 | return $obj; | ||||
5072 | 46 | 664 | }); | ||||
5073 | |||||||
5074 | 46 | 417 | my $nhelper=1; | ||||
5075 | 46 | 83 | my $prev = 'TESTS'; | ||||
5076 | 46 | 83 | my $post = ''; | ||||
5077 | 46 | 134 | my $last_suffix = $test_suffixes[$#test_suffixes]; | ||||
5078 | 46 | 99 | my $cur = ''; | ||||
5079 | 46 | 116 | foreach my $test_suffix (@test_suffixes) | ||||
5080 | { | ||||||
5081 | 118 | 284 | if ($test_suffix eq $last_suffix) | ||||
5082 | { | ||||||
5083 | 46 | 73 | $cur = 'TEST_LOGS'; | ||||
5084 | } | ||||||
5085 | else | ||||||
5086 | { | ||||||
5087 | 72 | 160 | $cur = 'am__test_logs' . $nhelper; | ||||
5088 | } | ||||||
5089 | 118 | 533 | define_variable ($cur, | ||||
5090 | '$(' . $prev . ':' . $test_suffix . $post . '=.log)', INTERNAL); | ||||||
5091 | 118 | 192 | $post = '.log'; | ||||
5092 | 118 | 139 | $prev = $cur; | ||||
5093 | 118 | 142 | $nhelper++; | ||||
5094 | 118 | 745 | if ($test_suffix ne $at_exeext && $test_suffix ne '') | ||||
5095 | { | ||||||
5096 | 48 | 248 | (my $ext = $test_suffix) =~ s/^\.//; | ||||
5097 | 48 | 109 | $ext = uc $ext; | ||||
5098 | 48 | 124 | my $compile = $ext . '_LOG_COMPILE'; | ||||
5099 | 48 | 241 | define_variable ($compile, | ||||
5100 | '$(' . $ext . '_LOG_COMPILER) $(AM_' . $ext . '_LOG_FLAGS)' | ||||||
5101 | . ' $(' . $ext . '_LOG_FLAGS)', INTERNAL); | ||||||
5102 | 48 | 157 | my $am_exeext = $handle_exeext ? 'am__EXEEXT' : 'FALSE'; | ||||
5103 | 48 | 191 | $output_rules .= file_contents ('check2', new Automake::Location, | ||||
5104 | GENERIC => 1, | ||||||
5105 | OBJ => '', | ||||||
5106 | SOURCE => '$<', | ||||||
5107 | COMPILE => '$(' . $compile . ')', | ||||||
5108 | EXT => $test_suffix, | ||||||
5109 | am__EXEEXT => $am_exeext); | ||||||
5110 | } | ||||||
5111 | } | ||||||
5112 | |||||||
5113 | 46 | 145 | define_variable ('TEST_LOGS_TMP', '$(TEST_LOGS:.log=.log-t)', INTERNAL); | ||||
5114 | |||||||
5115 | 46 | 137 | $clean_files{'$(TEST_LOGS_TMP)'} = MOSTLY_CLEAN; | ||||
5116 | 46 | 94 | $clean_files{'$(TEST_LOGS)'} = MOSTLY_CLEAN; | ||||
5117 | 46 | 88 | $clean_files{'$(TEST_SUITE_LOG)'} = MOSTLY_CLEAN; | ||||
5118 | 46 | 195 | $clean_files{'$(TEST_SUITE_HTML)'} = MOSTLY_CLEAN; | ||||
5119 | } | ||||||
5120 | } | ||||||
5121 | } | ||||||
5122 | |||||||
5123 | # Handle Emacs Lisp. | ||||||
5124 | sub handle_emacs_lisp | ||||||
5125 | { | ||||||
5126 | 1319 | 6315 | my @elfiles = &am_install_var ('-candist', 'lisp', 'LISP', | ||||
5127 | 'lisp', 'noinst'); | ||||||
5128 | |||||||
5129 | 1319 | 5124 | return if ! @elfiles; | ||||
5130 | |||||||
5131 | 30 | 75 | define_pretty_variable ('am__ELFILES', TRUE, INTERNAL, | ||||
5132 | 13 | 35 | map { $_->[1] } @elfiles); | ||||
5133 | 13 | 36 | define_pretty_variable ('am__ELCFILES', TRUE, INTERNAL, | ||||
5134 | '$(am__ELFILES:.el=.elc)'); | ||||||
5135 | # This one can be overridden by users. | ||||||
5136 | 13 | 39 | define_pretty_variable ('ELCFILES', TRUE, INTERNAL, '$(LISP:.el=.elc)'); | ||||
5137 | |||||||
5138 | 13 | 33 | push @all, '$(ELCFILES)'; | ||||
5139 | |||||||
5140 | 13 | 83 | require_variables ($elfiles[0][0], "Emacs Lisp sources seen", TRUE, | ||||
5141 | 'EMACS', 'lispdir'); | ||||||
5142 | 13 | 58 | require_conf_file ($elfiles[0][0], FOREIGN, 'elisp-comp'); | ||||
5143 | 13 | 65 | &define_variable ('elisp_comp', "$am_config_aux_dir/elisp-comp", INTERNAL); | ||||
5144 | } | ||||||
5145 | |||||||
5146 | # Handle Python | ||||||
5147 | sub handle_python | ||||||
5148 | { | ||||||
5149 | 1319 | 4584 | my @pyfiles = &am_install_var ('-defaultdist', 'python', 'PYTHON', | ||||
5150 | 'noinst'); | ||||||
5151 | 1319 | 4863 | return if ! @pyfiles; | ||||
5152 | |||||||
5153 | 10 | 50 | require_variables ($pyfiles[0][0], "Python sources seen", TRUE, 'PYTHON'); | ||||
5154 | 10 | 43 | require_conf_file ($pyfiles[0][0], FOREIGN, 'py-compile'); | ||||
5155 | 10 | 52 | &define_variable ('py_compile', "$am_config_aux_dir/py-compile", INTERNAL); | ||||
5156 | } | ||||||
5157 | |||||||
5158 | # Handle Java. | ||||||
5159 | sub handle_java | ||||||
5160 | { | ||||||
5161 | 1319 | 5116 | my @sourcelist = &am_install_var ('-candist', | ||||
5162 | 'java', 'JAVA', | ||||||
5163 | 'java', 'noinst', 'check'); | ||||||
5164 | 1319 | 4604 | return if ! @sourcelist; | ||||
5165 | |||||||
5166 | 7 | 22 | my @prefix = am_primary_prefixes ('JAVA', 1, | ||||
5167 | 'java', 'noinst', 'check'); | ||||||
5168 | |||||||
5169 | 7 | 15 | my $dir; | ||||
5170 | 7 | 15 | foreach my $curs (@prefix) | ||||
5171 | { | ||||||
5172 | next | ||||||
5173 | 7 | 20 | if $curs eq 'EXTRA'; | ||||
5174 | |||||||
5175 | 7 | 17 | err_var "${curs}_JAVA", "multiple _JAVA primaries in use" | ||||
5176 | if defined $dir; | ||||||
5177 | 7 | 17 | $dir = $curs; | ||||
5178 | } | ||||||
5179 | |||||||
5180 | |||||||
5181 | 7 | 43 | push (@all, 'class' . $dir . '.stamp'); | ||||
5182 | } | ||||||
5183 | |||||||
5184 | |||||||
5185 | # Handle some of the minor options. | ||||||
5186 | sub handle_minor_options | ||||||
5187 | { | ||||||
5188 | 1319 | 5136 | if (option 'readme-alpha') | ||||
5189 | { | ||||||
5190 | 13 | 42 | if ($relative_dir eq '.') | ||||
5191 | { | ||||||
5192 | 11 | 343 | if ($package_version !~ /^$GNITS_VERSION_PATTERN$/) | ||||
5193 | { | ||||||
5194 | 1 | 5 | msg ('error-gnits', $package_version_location, | ||||
5195 | "version `$package_version' doesn't follow " . | ||||||
5196 | "Gnits standards"); | ||||||
5197 | } | ||||||
5198 | 11 | 111 | if (defined $1 && -f 'README-alpha') | ||||
5199 | { | ||||||
5200 | # This means we have an alpha release. See | ||||||
5201 | # GNITS_VERSION_PATTERN for details. | ||||||
5202 | 2 | 6 | push_dist_common ('README-alpha'); | ||||
5203 | } | ||||||
5204 | } | ||||||
5205 | } | ||||||
5206 | } | ||||||
5207 | |||||||
5208 | ################################################################ | ||||||
5209 | |||||||
5210 | # ($OUTPUT, @INPUTS) | ||||||
5211 | # &split_config_file_spec ($SPEC) | ||||||
5212 | # ------------------------------- | ||||||
5213 | # Decode the Autoconf syntax for config files (files, headers, links | ||||||
5214 | # etc.). | ||||||
5215 | sub split_config_file_spec ($) | ||||||
5216 | { | ||||||
5217 | 153 | 321 | my ($spec) = @_; | ||||
5218 | 153 | 444 | my ($output, @inputs) = split (/:/, $spec); | ||||
5219 | |||||||
5220 | 153 | 426 | push @inputs, "$output.in" | ||||
5221 | unless @inputs; | ||||||
5222 | |||||||
5223 | 153 | 423 | return ($output, @inputs); | ||||
5224 | } | ||||||
5225 | |||||||
5226 | # $input | ||||||
5227 | # locate_am (@POSSIBLE_SOURCES) | ||||||
5228 | # ----------------------------- | ||||||
5229 | # AC_CONFIG_FILES allow specifications such as Makefile:top.in:mid.in:bot.in | ||||||
5230 | # This functions returns the first *.in file for which a *.am exists. | ||||||
5231 | # It returns undef otherwise. | ||||||
5232 | sub locate_am (@) | ||||||
5233 | { | ||||||
5234 | 1453 | 4325 | my (@rest) = @_; | ||||
5235 | 1453 | 4147 | my $input; | ||||
5236 | 1453 | 4745 | foreach my $file (@rest) | ||||
5237 | { | ||||||
5238 | 1474 | 33897 | if (($file =~ /^(.*)\.in$/) && -f "$1.am") | ||||
5239 | { | ||||||
5240 | 1364 | 2444 | $input = $file; | ||||
5241 | 1364 | 3125 | last; | ||||
5242 | } | ||||||
5243 | } | ||||||
5244 | 1453 | 4417 | return $input; | ||||
5245 | } | ||||||
5246 | |||||||
5247 | 1159 | 2542 | my %make_list; | ||||
5248 | |||||||
5249 | # &scan_autoconf_config_files ($WHERE, $CONFIG-FILES) | ||||||
5250 | # --------------------------------------------------- | ||||||
5251 | # Study $CONFIG-FILES which is the first argument to AC_CONFIG_FILES | ||||||
5252 | # (or AC_OUTPUT). | ||||||
5253 | sub scan_autoconf_config_files ($$) | ||||||
5254 | { | ||||||
5255 | 1313 | 3859 | my ($where, $config_files) = @_; | ||||
5256 | |||||||
5257 | # Look at potential Makefile.am's. | ||||||
5258 | 1313 | 6749 | foreach (split ' ', $config_files) | ||||
5259 | { | ||||||
5260 | # Must skip empty string for Perl 4. | ||||||
5261 | 1411 | 14496 | next if $_ eq "\\" || $_ eq ''; | ||||
5262 | |||||||
5263 | # Handle $local:$input syntax. | ||||||
5264 | 1411 | 7975 | my ($local, @rest) = split (/:/); | ||||
5265 | 1411 | 7274 | @rest = ("$local.in",) unless @rest; | ||||
5266 | 1411 | 5924 | msg ('portability', $where, | ||||
5267 | "omit leading `./' from config file names such as `$local'," | ||||||
5268 | . "\nas not all make implementations treat `file' and `./file' equally") | ||||||
5269 | if ($local =~ /^\.\//); | ||||||
5270 | 1411 | 6053 | my $input = locate_am @rest; | ||||
5271 | 1411 | 3497 | if ($input) | ||||
5272 | { | ||||||
5273 | # We have a file that automake should generate. | ||||||
5274 | 1323 | 7076 | $make_list{$input} = join (':', ($local, @rest)); | ||||
5275 | } | ||||||
5276 | else | ||||||
5277 | { | ||||||
5278 | # We have a file that automake should cause to be | ||||||
5279 | # rebuilt, but shouldn't generate itself. | ||||||
5280 | 88 | 329 | push (@other_input_files, $_); | ||||
5281 | } | ||||||
5282 | 1411 | 4915 | $ac_config_files_location{$local} = $where; | ||||
5283 | 1411 | 10674 | $ac_config_files_condition{$local} = | ||||
5284 | new Automake::Condition (@cond_stack) | ||||||
5285 | if (@cond_stack); | ||||||
5286 | } | ||||||
5287 | } | ||||||
5288 | |||||||
5289 | |||||||
5290 | # &scan_autoconf_traces ($FILENAME) | ||||||
5291 | # --------------------------------- | ||||||
5292 | sub scan_autoconf_traces ($) | ||||||
5293 | { | ||||||
5294 | 1133 | 2659 | my ($filename) = @_; | ||||
5295 | |||||||
5296 | # Macros to trace, with their minimal number of arguments. | ||||||
5297 | # | ||||||
5298 | # IMPORTANT: If you add a macro here, you should also add this macro | ||||||
5299 | # ========= to Automake-preselection in autoconf/lib/autom4te.in. | ||||||
5300 | 1133 | 24137 | my %traced = ( | ||||
5301 | AC_CANONICAL_BUILD => 0, | ||||||
5302 | AC_CANONICAL_HOST => 0, | ||||||
5303 | AC_CANONICAL_TARGET => 0, | ||||||
5304 | AC_CONFIG_AUX_DIR => 1, | ||||||
5305 | AC_CONFIG_FILES => 1, | ||||||
5306 | AC_CONFIG_HEADERS => 1, | ||||||
5307 | AC_CONFIG_LIBOBJ_DIR => 1, | ||||||
5308 | AC_CONFIG_LINKS => 1, | ||||||
5309 | AC_FC_SRCEXT => 1, | ||||||
5310 | AC_INIT => 0, | ||||||
5311 | AC_LIBSOURCE => 1, | ||||||
5312 | AC_REQUIRE_AUX_FILE => 1, | ||||||
5313 | AC_SUBST_TRACE => 1, | ||||||
5314 | AM_AUTOMAKE_VERSION => 1, | ||||||
5315 | AM_CONDITIONAL => 2, | ||||||
5316 | AM_ENABLE_MULTILIB => 0, | ||||||
5317 | AM_GNU_GETTEXT => 0, | ||||||
5318 | AM_GNU_GETTEXT_INTL_SUBDIR => 0, | ||||||
5319 | AM_INIT_AUTOMAKE => 0, | ||||||
5320 | AM_MAINTAINER_MODE => 0, | ||||||
5321 | AM_MAKEFILE_INCLUDE => 1, | ||||||
5322 | AM_PROG_CC_C_O => 0, | ||||||
5323 | AM_SILENT_RULES => 0, | ||||||
5324 | _AM_SUBST_NOTMAKE => 1, | ||||||
5325 | _AM_COND_IF => 1, | ||||||
5326 | _AM_COND_ELSE => 1, | ||||||
5327 | _AM_COND_ENDIF => 1, | ||||||
5328 | LT_SUPPORTED_TAG => 1, | ||||||
5329 | _LT_AC_TAGCONFIG => 0, | ||||||
5330 | m4_include => 1, | ||||||
5331 | m4_sinclude => 1, | ||||||
5332 | sinclude => 1, | ||||||
5333 | ); | ||||||
5334 | |||||||
5335 | 1133 | 8986 | my $traces = ($ENV{AUTOCONF} || 'autoconf') . " "; | ||||
5336 | |||||||
5337 | # Use a separator unlikely to be used, not `:', the default, which | ||||||
5338 | # has a precise meaning for AC_CONFIG_FILES and so on. | ||||||
5339 | 36256 | 69649 | $traces .= join (' ', | ||||
5340 | 1133 | 6986 | map { "--trace=$_" . ':\$f:\$l::\$d::\$n::\${::}%' } | ||||
5341 | (keys %traced)); | ||||||
5342 | |||||||
5343 | 1133 | 11916 | my $tracefh = new Automake::XFile ("$traces $filename |"); | ||||
5344 | 1133 | 25901 | verb "reading $traces"; | ||||
5345 | |||||||
5346 | 1133 | 5444 | @cond_stack = (); | ||||
5347 | 1133 | 2996 | my $where; | ||||
5348 | |||||||
5349 | 1133 | 9461 | while ($_ = $tracefh->getline) | ||||
5350 | { | ||||||
5351 | 112830 | 133370 | chomp; | ||||
5352 | 112830 | 385981 | my ($here, $depth, @args) = split (/::/); | ||||
5353 | 112830 | 338398 | $where = new Automake::Location $here; | ||||
5354 | 112830 | 137432 | my $macro = $args[0]; | ||||
5355 | |||||||
5356 | 112830 | 235961 | prog_error ("unrequested trace `$macro'") | ||||
5357 | unless exists $traced{$macro}; | ||||||
5358 | |||||||
5359 | # Skip and diagnose malformed calls. | ||||||
5360 | 112830 | 363185 | if ($#args < $traced{$macro}) | ||||
5361 | { | ||||||
5362 | 4 | 19 | msg ('syntax', $where, "not enough arguments for $macro"); | ||||
5363 | 4 | 19 | next; | ||||
5364 | } | ||||||
5365 | |||||||
5366 | # Alphabetical ordering please. | ||||||
5367 | 112826 | 1120401 | if ($macro eq 'AC_CANONICAL_BUILD') | ||||
5368 | { | ||||||
5369 | 88 | 578 | if ($seen_canonical <= AC_CANONICAL_BUILD) | ||||
5370 | { | ||||||
5371 | 1 | 1 | $seen_canonical = AC_CANONICAL_BUILD; | ||||
5372 | 1 | 4 | $canonical_location = $where; | ||||
5373 | } | ||||||
5374 | } | ||||||
5375 | elsif ($macro eq 'AC_CANONICAL_HOST') | ||||||
5376 | { | ||||||
5377 | 87 | 358 | if ($seen_canonical <= AC_CANONICAL_HOST) | ||||
5378 | { | ||||||
5379 | 85 | 132 | $seen_canonical = AC_CANONICAL_HOST; | ||||
5380 | 85 | 373 | $canonical_location = $where; | ||||
5381 | } | ||||||
5382 | } | ||||||
5383 | elsif ($macro eq 'AC_CANONICAL_TARGET') | ||||||
5384 | { | ||||||
5385 | 2 | 5 | $seen_canonical = AC_CANONICAL_TARGET; | ||||
5386 | 2 | 11 | $canonical_location = $where; | ||||
5387 | } | ||||||
5388 | elsif ($macro eq 'AC_CONFIG_AUX_DIR') | ||||||
5389 | { | ||||||
5390 | 20 | 68 | if ($seen_init_automake) | ||||
5391 | { | ||||||
5392 | 1 | 7 | error ($where, "AC_CONFIG_AUX_DIR must be called before " | ||||
5393 | . "AM_INIT_AUTOMAKE ...", partial => 1); | ||||||
5394 | 1 | 4 | error ($seen_init_automake, "... AM_INIT_AUTOMAKE called here"); | ||||
5395 | } | ||||||
5396 | 20 | 90 | $config_aux_dir = $args[1]; | ||||
5397 | 20 | 45 | $config_aux_dir_set_in_configure_ac = 1; | ||||
5398 | 20 | 56 | $relative_dir = '.'; | ||||
5399 | 20 | 161 | check_directory ($config_aux_dir, $where); | ||||
5400 | } | ||||||
5401 | elsif ($macro eq 'AC_CONFIG_FILES') | ||||||
5402 | { | ||||||
5403 | # Look at potential Makefile.am's. | ||||||
5404 | 1313 | 9285 | scan_autoconf_config_files ($where, $args[1]); | ||||
5405 | } | ||||||
5406 | elsif ($macro eq 'AC_CONFIG_HEADERS') | ||||||
5407 | { | ||||||
5408 | 23 | 143 | foreach my $spec (split (' ', $args[1])) | ||||
5409 | { | ||||||
5410 | 32 | 122 | my ($dest, @src) = split (':', $spec); | ||||
5411 | 32 | 75 | $ac_config_files_location{$dest} = $where; | ||||
5412 | 32 | 171 | push @config_headers, $spec; | ||||
5413 | } | ||||||
5414 | } | ||||||
5415 | elsif ($macro eq 'AC_CONFIG_LIBOBJ_DIR') | ||||||
5416 | { | ||||||
5417 | 24 | 114 | $config_libobj_dir = $args[1]; | ||||
5418 | 24 | 64 | $relative_dir = '.'; | ||||
5419 | 24 | 190 | check_directory ($config_libobj_dir, $where); | ||||
5420 | } | ||||||
5421 | elsif ($macro eq 'AC_CONFIG_LINKS') | ||||||
5422 | { | ||||||
5423 | 17 | 58 | foreach my $spec (split (' ', $args[1])) | ||||
5424 | { | ||||||
5425 | 20 | 47 | my ($dest, $src) = split (':', $spec); | ||||
5426 | 20 | 41 | $ac_config_files_location{$dest} = $where; | ||||
5427 | 20 | 92 | push @config_links, $spec; | ||||
5428 | } | ||||||
5429 | } | ||||||
5430 | elsif ($macro eq 'AC_FC_SRCEXT') | ||||||
5431 | { | ||||||
5432 | 5 | 9 | my $suffix = $args[1]; | ||||
5433 | # These flags are used as %SOURCEFLAG% in depend2.am, | ||||||
5434 | # where the trailing space is important. | ||||||
5435 | 5 | 76 | $sourceflags{'.' . $suffix} = '$(FCFLAGS_' . $suffix . ') ' | ||||
5436 | if ($suffix eq 'f90' || $suffix eq 'f95' || $suffix eq 'f03' || $suffix eq 'f08'); | ||||||
5437 | } | ||||||
5438 | elsif ($macro eq 'AC_INIT') | ||||||
5439 | { | ||||||
5440 | 1128 | 9420 | if (defined $args[2]) | ||||
5441 | { | ||||||
5442 | 1067 | 5834 | $package_version = $args[2]; | ||||
5443 | 1067 | 7769 | $package_version_location = $where; | ||||
5444 | } | ||||||
5445 | } | ||||||
5446 | elsif ($macro eq 'AC_LIBSOURCE') | ||||||
5447 | { | ||||||
5448 | 94 | 508 | $libsources{$args[1]} = $here; | ||||
5449 | } | ||||||
5450 | elsif ($macro eq 'AC_REQUIRE_AUX_FILE') | ||||||
5451 | { | ||||||
5452 | # Only remember the first time a file is required. | ||||||
5453 | 3759 | 21117 | $required_aux_file{$args[1]} = $where | ||||
5454 | unless exists $required_aux_file{$args[1]}; | ||||||
5455 | } | ||||||
5456 | elsif ($macro eq 'AC_SUBST_TRACE') | ||||||
5457 | { | ||||||
5458 | # Just check for alphanumeric in AC_SUBST_TRACE. If you do | ||||||
5459 | # AC_SUBST(5), then too bad. | ||||||
5460 | 96343 | 737643 | $configure_vars{$args[1]} = $where | ||||
5461 | if $args[1] =~ /^\w+$/; | ||||||
5462 | } | ||||||
5463 | elsif ($macro eq 'AM_AUTOMAKE_VERSION') | ||||||
5464 | { | ||||||
5465 | 1121 | 4509 | error ($where, | ||||
5466 | "version mismatch. This is Automake $VERSION,\n" . | ||||||
5467 | "but the definition used by this AM_INIT_AUTOMAKE\n" . | ||||||
5468 | "comes from Automake $args[1]. You should recreate\n" . | ||||||
5469 | "aclocal.m4 with aclocal and run automake again.\n", | ||||||
5470 | # $? = 63 is used to indicate version mismatch to missing. | ||||||
5471 | exit_code => 63) | ||||||
5472 | if $VERSION ne $args[1]; | ||||||
5473 | |||||||
5474 | 1121 | 4878 | $seen_automake_version = 1; | ||||
5475 | } | ||||||
5476 | elsif ($macro eq 'AM_CONDITIONAL') | ||||||
5477 | { | ||||||
5478 | 1705 | 10024 | $configure_cond{$args[1]} = $where; | ||||
5479 | } | ||||||
5480 | elsif ($macro eq 'AM_ENABLE_MULTILIB') | ||||||
5481 | { | ||||||
5482 | 2 | 10 | $seen_multilib = $where; | ||||
5483 | } | ||||||
5484 | elsif ($macro eq 'AM_GNU_GETTEXT') | ||||||
5485 | { | ||||||
5486 | 15 | 34 | $seen_gettext = $where; | ||||
5487 | 15 | 32 | $ac_gettext_location = $where; | ||||
5488 | 15 | 105 | $seen_gettext_external = grep ($_ eq 'external', @args); | ||||
5489 | } | ||||||
5490 | elsif ($macro eq 'AM_GNU_GETTEXT_INTL_SUBDIR') | ||||||
5491 | { | ||||||
5492 | 3 | 14 | $seen_gettext_intl = $where; | ||||
5493 | } | ||||||
5494 | elsif ($macro eq 'AM_INIT_AUTOMAKE') | ||||||
5495 | { | ||||||
5496 | 1122 | 2638 | $seen_init_automake = $where; | ||||
5497 | 1122 | 8620 | if (defined $args[2]) | ||||
5498 | { | ||||||
5499 | 64 | 266 | $package_version = $args[2]; | ||||
5500 | 64 | 342 | $package_version_location = $where; | ||||
5501 | } | ||||||
5502 | elsif (defined $args[1]) | ||||||
5503 | { | ||||||
5504 | 69 | 807 | exit $exit_code | ||||
5505 | if (process_global_option_list ($where, | ||||||
5506 | split (' ', $args[1]))); | ||||||
5507 | } | ||||||
5508 | } | ||||||
5509 | elsif ($macro eq 'AM_MAINTAINER_MODE') | ||||||
5510 | { | ||||||
5511 | 25 | 117 | $seen_maint_mode = $where; | ||||
5512 | } | ||||||
5513 | elsif ($macro eq 'AM_MAKEFILE_INCLUDE') | ||||||
5514 | { | ||||||
5515 | 19 | 29 | my $fragment = $args[1]; | ||||
5516 | 19 | 68 | my $placement = $args[2] || 'late'; | ||||
5517 | 19 | 75 | my $pattern = $args[3] || '.*'; | ||||
5518 | 19 | 32 | my @conds = @cond_stack; | ||||
5519 | 19 | 35 | if ($placement eq 'early') | ||||
5520 | { | ||||||
5521 | 7 | 57 | unshift @early_fragments, | ||||
5522 | [ $fragment, $where, $pattern, \@conds ]; | ||||||
5523 | } | ||||||
5524 | else | ||||||
5525 | { | ||||||
5526 | 12 | 82 | push @late_fragments, | ||||
5527 | [ $fragment, $where, $pattern, \@conds ]; | ||||||
5528 | } | ||||||
5529 | } | ||||||
5530 | elsif ($macro eq 'AM_PROG_CC_C_O') | ||||||
5531 | { | ||||||
5532 | 73 | 349 | $seen_cc_c_o = $where; | ||||
5533 | } | ||||||
5534 | elsif ($macro eq 'AM_SILENT_RULES') | ||||||
5535 | { | ||||||
5536 | 20 | 202 | set_global_option ('silent-rules', $where); | ||||
5537 | } | ||||||
5538 | elsif ($macro eq '_AM_COND_IF') | ||||||
5539 | { | ||||||
5540 | 24 | 151 | cond_stack_if ('', $args[1], $where); | ||||
5541 | 24 | 152 | error ($where, "missing m4 quoting, macro depth $depth") | ||||
5542 | if ($depth != 1); | ||||||
5543 | } | ||||||
5544 | elsif ($macro eq '_AM_COND_ELSE') | ||||||
5545 | { | ||||||
5546 | 6 | 31 | cond_stack_else ('!', $args[1], $where); | ||||
5547 | 6 | 39 | error ($where, "missing m4 quoting, macro depth $depth") | ||||
5548 | if ($depth != 1); | ||||||
5549 | } | ||||||
5550 | elsif ($macro eq '_AM_COND_ENDIF') | ||||||
5551 | { | ||||||
5552 | 24 | 97 | cond_stack_endif (undef, undef, $where); | ||||
5553 | 24 | 134 | error ($where, "missing m4 quoting, macro depth $depth") | ||||
5554 | if ($depth != 1); | ||||||
5555 | } | ||||||
5556 | elsif ($macro eq '_AM_SUBST_NOTMAKE') | ||||||
5557 | { | ||||||
5558 | 5632 | 24838 | $ignored_configure_vars{$args[1]} = $where; | ||||
5559 | } | ||||||
5560 | elsif ($macro eq 'm4_include' | ||||||
5561 | || $macro eq 'm4_sinclude' | ||||||
5562 | || $macro eq 'sinclude') | ||||||
5563 | { | ||||||
5564 | # Skip missing `sinclude'd files. | ||||||
5565 | 63 | 374 | next if $macro ne 'm4_include' && ! -f $args[1]; | ||||
5566 | |||||||
5567 | # Some modified versions of Autoconf don't use | ||||||
5568 | # frozen files. Consequently it's possible that we see all | ||||||
5569 | # m4_include's performed during Autoconf's startup. | ||||||
5570 | # Obviously we don't want to distribute Autoconf's files | ||||||
5571 | # so we skip absolute filenames here. | ||||||
5572 | 61 | 639 | push @configure_deps, '$(top_srcdir)/' . $args[1] | ||||
5573 | unless $here =~ m,^(?:\w:)?[\\/],; | ||||||
5574 | # Keep track of the greatest timestamp. | ||||||
5575 | 61 | 491 | if (-e $args[1]) | ||||
5576 | { | ||||||
5577 | 61 | 466 | my $mtime = mtime $args[1]; | ||||
5578 | 61 | 422 | $configure_deps_greatest_timestamp = $mtime | ||||
5579 | if $mtime > $configure_deps_greatest_timestamp; | ||||||
5580 | } | ||||||
5581 | } | ||||||
5582 | elsif ($macro eq 'LT_SUPPORTED_TAG') | ||||||
5583 | { | ||||||
5584 | 69 | 193 | $libtool_tags{$args[1]} = 1; | ||||
5585 | 69 | 295 | $libtool_new_api = 1; | ||||
5586 | } | ||||||
5587 | elsif ($macro eq '_LT_AC_TAGCONFIG') | ||||||
5588 | { | ||||||
5589 | # _LT_AC_TAGCONFIG is an old macro present in Libtool 1.5. | ||||||
5590 | # We use it to detect whether tags are supported. Our | ||||||
5591 | # preferred interface is LT_SUPPORTED_TAG, but it was | ||||||
5592 | # introduced in Libtool 1.6. | ||||||
5593 | 0 | 0 | if (0 == keys %libtool_tags) | ||||
5594 | { | ||||||
5595 | # Hardcode the tags supported by Libtool 1.5. | ||||||
5596 | 0 | 0 | %libtool_tags = (CC => 1, CXX => 1, GCJ => 1, F77 => 1); | ||||
5597 | } | ||||||
5598 | } | ||||||
5599 | } | ||||||
5600 | |||||||
5601 | 1132 | 10912 | error ($where, "condition stack not properly closed") | ||||
5602 | if (@cond_stack); | ||||||
5603 | |||||||
5604 | 1132 | 11619 | $tracefh->close; | ||||
5605 | } | ||||||
5606 | |||||||
5607 | |||||||
5608 | # &scan_autoconf_files () | ||||||
5609 | # ----------------------- | ||||||
5610 | # Check whether we use `configure.ac' or `configure.in'. | ||||||
5611 | # Scan it (and possibly `aclocal.m4') for interesting things. | ||||||
5612 | # We must scan aclocal.m4 because there might be AC_SUBSTs and such there. | ||||||
5613 | sub scan_autoconf_files () | ||||||
5614 | { | ||||||
5615 | # Reinitialize libsources here. This isn't really necessary, | ||||||
5616 | # since we currently assume there is only one configure.ac. But | ||||||
5617 | # that won't always be the case. | ||||||
5618 | 1133 | 9965 | %libsources = (); | ||||
5619 | |||||||
5620 | # Keep track of the youngest configure dependency. | ||||||
5621 | 1133 | 8530 | $configure_deps_greatest_timestamp = mtime $configure_ac; | ||||
5622 | 1133 | 7537 | if (-e 'aclocal.m4') | ||||
5623 | { | ||||||
5624 | 1126 | 3553 | my $mtime = mtime 'aclocal.m4'; | ||||
5625 | 1126 | 4707 | $configure_deps_greatest_timestamp = $mtime | ||||
5626 | if $mtime > $configure_deps_greatest_timestamp; | ||||||
5627 | } | ||||||
5628 | |||||||
5629 | 1133 | 3388 | scan_autoconf_traces ($configure_ac); | ||||
5630 | |||||||
5631 | 1127 | 150320 | @configure_input_files = sort keys %make_list; | ||||
5632 | # Set input and output files if not specified by user. | ||||||
5633 | 1127 | 4696 | if (! @input_files) | ||||
5634 | { | ||||||
5635 | 1086 | 2499 | @input_files = @configure_input_files; | ||||
5636 | 1086 | 4278 | %output_files = %make_list; | ||||
5637 | } | ||||||
5638 | |||||||
5639 | |||||||
5640 | 1127 | 3908 | if (! $seen_init_automake) | ||||
5641 | { | ||||||
5642 | 6 | 63 | my $msg = "no proper invocation of AM_INIT_AUTOMAKE was found.\nYou " | ||||
5643 | . "should verify that $configure_ac invokes AM_INIT_AUTOMAKE," | ||||||
5644 | . "\nthat aclocal.m4 is present in the top-level directory,\n" | ||||||
5645 | . "and that aclocal.m4 was recently regenerated " | ||||||
5646 | . "(using aclocal)"; | ||||||
5647 | 6 | 18 | if ($add_missing) | ||||
5648 | { | ||||||
5649 | 2 | 17 | msg_ac 'unsupported', $msg; | ||||
5650 | } | ||||||
5651 | else | ||||||
5652 | { | ||||||
5653 | 4 | 30 | err_ac $msg; | ||||
5654 | } | ||||||
5655 | } | ||||||
5656 | else | ||||||
5657 | { | ||||||
5658 | 1121 | 3698 | if (! $seen_automake_version) | ||||
5659 | { | ||||||
5660 | 0 | 0 | if (-f 'aclocal.m4') | ||||
5661 | { | ||||||
5662 | 0 | 0 | error ($seen_init_automake, | ||||
5663 | "your implementation of AM_INIT_AUTOMAKE comes from " . | ||||||
5664 | "an\nold Automake version. You should recreate " . | ||||||
5665 | "aclocal.m4\nwith aclocal and run automake again", | ||||||
5666 | # $? = 63 is used to indicate version mismatch to missing. | ||||||
5667 | exit_code => 63); | ||||||
5668 | } | ||||||
5669 | else | ||||||
5670 | { | ||||||
5671 | 0 | 0 | error ($seen_init_automake, | ||||
5672 | "no proper implementation of AM_INIT_AUTOMAKE was " . | ||||||
5673 | "found,\nprobably because aclocal.m4 is missing.\n" . | ||||||
5674 | "You should run aclocal to create this file, then\n" . | ||||||
5675 | "run automake again"); | ||||||
5676 | } | ||||||
5677 | } | ||||||
5678 | } | ||||||
5679 | |||||||
5680 | 1127 | 8105 | locate_aux_dir (); | ||||
5681 | |||||||
5682 | # Reorder @input_files so that the Makefile that distributes aux | ||||||
5683 | # files is processed last. This is important because each directory | ||||||
5684 | # can require auxiliary scripts and we should wait until they have | ||||||
5685 | # been installed before distributing them. | ||||||
5686 | |||||||
5687 | # The Makefile.in that distribute the aux files is the one in | ||||||
5688 | # $config_aux_dir or the top-level Makefile. | ||||||
5689 | 1127 | 7150 | my $auxdirdist = is_make_dir ($config_aux_dir) ? $config_aux_dir : '.'; | ||||
5690 | 1127 | 2625 | my @new_input_files = (); | ||||
5691 | 1127 | 4231 | while (@input_files) | ||||
5692 | { | ||||||
5693 | 1323 | 2989 | my $in = pop @input_files; | ||||
5694 | 1323 | 8245 | my @ins = split (/:/, $output_files{$in}); | ||||
5695 | 1323 | 5316 | if (dirname ($ins[0]) eq $auxdirdist) | ||||
5696 | { | ||||||
5697 | 1104 | 104613 | push @new_input_files, $in; | ||||
5698 | 1104 | 5827 | $automake_will_process_aux_dir = 1; | ||||
5699 | } | ||||||
5700 | else | ||||||
5701 | { | ||||||
5702 | 219 | 20596 | unshift @new_input_files, $in; | ||||
5703 | } | ||||||
5704 | } | ||||||
5705 | 1127 | 2954 | @input_files = @new_input_files; | ||||
5706 | |||||||
5707 | # If neither the auxdir/Makefile nor the ./Makefile are generated | ||||||
5708 | # by Automake, we won't distribute the aux files anyway. Assume | ||||||
5709 | # the user know what (s)he does, and pretend we will distribute | ||||||
5710 | # them to disable the error in require_file_internal. | ||||||
5711 | 1127 | 3410 | $automake_will_process_aux_dir = 1 if ! is_make_dir ($auxdirdist); | ||||
5712 | |||||||
5713 | # Look for some files we need. Always check for these. This | ||||||
5714 | # check must be done for every run, even those where we are only | ||||||
5715 | # looking at a subdir Makefile. We must set relative_dir for | ||||||
5716 | # maybe_push_required_file to work. | ||||||
5717 | # Sort the files for stable verbose output. | ||||||
5718 | 1127 | 2533 | $relative_dir = '.'; | ||||
5719 | 1127 | 8704 | foreach my $file (sort keys %required_aux_file) | ||||
5720 | { | ||||||
5721 | 2577 | 13510 | require_conf_file ($required_aux_file{$file}->get, FOREIGN, $file) | ||||
5722 | } | ||||||
5723 | 1127 | 12857 | err_am "`install.sh' is an anachronism; use `install-sh' instead" | ||||
5724 | if -f $config_aux_dir . '/install.sh'; | ||||||
5725 | |||||||
5726 | # Preserve dist_common for later. | ||||||
5727 | 1127 | 12148 | $configure_dist_common = variable_value ('DIST_COMMON') || ''; | ||||
5728 | |||||||
5729 | } | ||||||
5730 | |||||||
5731 | ################################################################ | ||||||
5732 | |||||||
5733 | # Set up for Cygnus mode. | ||||||
5734 | sub check_cygnus | ||||||
5735 | { | ||||||
5736 | 1319 | 4312 | my $cygnus = option 'cygnus'; | ||||
5737 | 1319 | 3837 | return unless $cygnus; | ||||
5738 | |||||||
5739 | 10 | 49 | set_strictness ('foreign'); | ||||
5740 | 10 | 54 | set_option ('no-installinfo', $cygnus); | ||||
5741 | 10 | 31 | set_option ('no-dependencies', $cygnus); | ||||
5742 | 10 | 27 | set_option ('no-dist', $cygnus); | ||||
5743 | |||||||
5744 | 10 | 39 | err_ac "`AM_MAINTAINER_MODE' required when --cygnus specified" | ||||
5745 | if !$seen_maint_mode; | ||||||
5746 | } | ||||||
5747 | |||||||
5748 | # Do any extra checking for GNU standards. | ||||||
5749 | sub check_gnu_standards | ||||||
5750 | { | ||||||
5751 | 1319 | 4759 | if ($relative_dir eq '.') | ||||
5752 | { | ||||||
5753 | # In top level (or only) directory. | ||||||
5754 | 1101 | 7532 | require_file ("$am_file.am", GNU, | ||||
5755 | qw/INSTALL NEWS README AUTHORS ChangeLog/); | ||||||
5756 | |||||||
5757 | # Accept one of these three licenses; default to COPYING. | ||||||
5758 | # Make sure we do not overwrite an existing license. | ||||||
5759 | 1101 | 1870 | my $license; | ||||
5760 | 1101 | 2888 | foreach (qw /COPYING COPYING.LIB COPYING.LESSER/) | ||||
5761 | { | ||||||
5762 | 3232 | 15760 | if (-f $_) | ||||
5763 | { | ||||||
5764 | 36 | 64 | $license = $_; | ||||
5765 | 36 | 74 | last; | ||||
5766 | } | ||||||
5767 | } | ||||||
5768 | 1101 | 5668 | require_file ("$am_file.am", GNU, 'COPYING') | ||||
5769 | unless $license; | ||||||
5770 | } | ||||||
5771 | |||||||
5772 | 1319 | 5286 | for my $opt ('no-installman', 'no-installinfo') | ||||
5773 | { | ||||||
5774 | 2638 | 6712 | msg ('error-gnu', option $opt, | ||||
5775 | "option `$opt' disallowed by GNU standards") | ||||||
5776 | if option $opt; | ||||||
5777 | } | ||||||
5778 | } | ||||||
5779 | |||||||
5780 | # Do any extra checking for GNITS standards. | ||||||
5781 | sub check_gnits_standards | ||||||
5782 | { | ||||||
5783 | 1319 | 4445 | if ($relative_dir eq '.') | ||||
5784 | { | ||||||
5785 | # In top level (or only) directory. | ||||||
5786 | 1101 | 3480 | require_file ("$am_file.am", GNITS, 'THANKS'); | ||||
5787 | } | ||||||
5788 | } | ||||||
5789 | |||||||
5790 | ################################################################ | ||||||
5791 | # | ||||||
5792 | # Functions to handle files of each language. | ||||||
5793 | |||||||
5794 | # Each `lang_X_rewrite($DIRECTORY, $BASE, $EXT)' function follows a | ||||||
5795 | # simple formula: Return value is LANG_SUBDIR if the resulting object | ||||||
5796 | # file should be in a subdir if the source file is, LANG_PROCESS if | ||||||
5797 | # file is to be dealt with, LANG_IGNORE otherwise. | ||||||
5798 | |||||||
5799 | # Much of the actual processing is handled in | ||||||
5800 | # handle_single_transform. These functions exist so that | ||||||
5801 | # auxiliary information can be recorded for a later cleanup pass. | ||||||
5802 | # Note that the calls to these functions are computed, so don't bother | ||||||
5803 | # searching for their precise names in the source. | ||||||
5804 | |||||||
5805 | # This is just a convenience function that can be used to determine | ||||||
5806 | # when a subdir object should be used. | ||||||
5807 | sub lang_sub_obj | ||||||
5808 | { | ||||||
5809 | 248 | 683 | return option 'subdir-objects' ? LANG_SUBDIR : LANG_PROCESS; | ||||
5810 | } | ||||||
5811 | |||||||
5812 | # Rewrite a single C source file. | ||||||
5813 | sub lang_c_rewrite | ||||||
5814 | { | ||||||
5815 | 1158 | 3511 | my ($directory, $base, $ext, $nonansi_obj, $have_per_exec_flags, $var) = @_; | ||||
5816 | |||||||
5817 | 1158 | 2824 | if (option 'ansi2knr' && $base =~ /_$/) | ||||
5818 | { | ||||||
5819 | # FIXME: include line number in error. | ||||||
5820 | 0 | 0 | err_am "C source file `$base.c' would be deleted by ansi2knr rules"; | ||||
5821 | } | ||||||
5822 | |||||||
5823 | 1158 | 1667 | my $r = LANG_PROCESS; | ||||
5824 | 1158 | 2573 | if (option 'subdir-objects') | ||||
5825 | { | ||||||
5826 | 82 | 111 | $r = LANG_SUBDIR; | ||||
5827 | 82 | 453 | if ($directory && $directory ne '.') | ||||
5828 | { | ||||||
5829 | 36 | 82 | $base = $directory . '/' . $base; | ||||
5830 | |||||||
5831 | # libtool is always able to put the object at the proper place, | ||||||
5832 | # so we do not have to require AM_PROG_CC_C_O when building .lo files. | ||||||
5833 | 36 | 159 | msg_var ('portability', $var, | ||||
5834 | "compiling `$base.c' in subdir requires " | ||||||
5835 | . "`AM_PROG_CC_C_O' in `$configure_ac'", | ||||||
5836 | uniq_scope => US_GLOBAL, | ||||||
5837 | uniq_part => 'AM_PROG_CC_C_O subdir') | ||||||
5838 | unless $seen_cc_c_o || $nonansi_obj eq '.lo'; | ||||||
5839 | } | ||||||
5840 | |||||||
5841 | # In this case we already have the directory information, so | ||||||
5842 | # don't add it again. | ||||||
5843 | 82 | 216 | $de_ansi_files{$base} = ''; | ||||
5844 | } | ||||||
5845 | else | ||||||
5846 | { | ||||||
5847 | 1076 | 8823 | $de_ansi_files{$base} = (($directory eq '.' || $directory eq '') | ||||
5848 | ? '' | ||||||
5849 | : "$directory/"); | ||||||
5850 | } | ||||||
5851 | |||||||
5852 | 1158 | 8194 | if (! $seen_cc_c_o | ||||
5853 | && $have_per_exec_flags | ||||||
5854 | && ! option 'subdir-objects' | ||||||
5855 | && $nonansi_obj ne '.lo') | ||||||
5856 | { | ||||||
5857 | 1 | 8 | msg_var ('portability', | ||||
5858 | $var, "compiling `$base.c' with per-target flags requires " | ||||||
5859 | . "`AM_PROG_CC_C_O' in `$configure_ac'", | ||||||
5860 | uniq_scope => US_GLOBAL, | ||||||
5861 | uniq_part => 'AM_PROG_CC_C_O per-target') | ||||||
5862 | } | ||||||
5863 | |||||||
5864 | 1158 | 2551 | return $r; | ||||
5865 | } | ||||||
5866 | |||||||
5867 | # Rewrite a single C++ source file. | ||||||
5868 | sub lang_cxx_rewrite | ||||||
5869 | { | ||||||
5870 | 81 | 185 | return &lang_sub_obj; | ||||
5871 | } | ||||||
5872 | |||||||
5873 | # Rewrite a single header file. | ||||||
5874 | sub lang_header_rewrite | ||||||
5875 | { | ||||||
5876 | # Header files are simply ignored. | ||||||
5877 | 43 | 90 | return LANG_IGNORE; | ||||
5878 | } | ||||||
5879 | |||||||
5880 | # Rewrite a single Vala source file. | ||||||
5881 | sub lang_vala_rewrite | ||||||
5882 | { | ||||||
5883 | 6 | 13 | my ($directory, $base, $ext) = @_; | ||||
5884 | |||||||
5885 | 6 | 24 | (my $newext = $ext) =~ s/vala$/c/; | ||||
5886 | 6 | 13 | return (LANG_SUBDIR, $newext); | ||||
5887 | } | ||||||
5888 | |||||||
5889 | # Rewrite a single yacc file. | ||||||
5890 | sub lang_yacc_rewrite | ||||||
5891 | { | ||||||
5892 | 47 | 131 | my ($directory, $base, $ext) = @_; | ||||
5893 | |||||||
5894 | 47 | 101 | my $r = &lang_sub_obj; | ||||
5895 | 47 | 91 | (my $newext = $ext) =~ tr/y/c/; | ||||
5896 | 47 | 113 | return ($r, $newext); | ||||
5897 | } | ||||||
5898 | |||||||
5899 | # Rewrite a single yacc++ file. | ||||||
5900 | sub lang_yaccxx_rewrite | ||||||
5901 | { | ||||||
5902 | 6 | 17 | my ($directory, $base, $ext) = @_; | ||||
5903 | |||||||
5904 | 6 | 11 | my $r = &lang_sub_obj; | ||||
5905 | 6 | 11 | (my $newext = $ext) =~ tr/y/c/; | ||||
5906 | 6 | 15 | return ($r, $newext); | ||||
5907 | } | ||||||
5908 | |||||||
5909 | # Rewrite a single lex file. | ||||||
5910 | sub lang_lex_rewrite | ||||||
5911 | { | ||||||
5912 | 24 | 68 | my ($directory, $base, $ext) = @_; | ||||
5913 | |||||||
5914 | 24 | 48 | my $r = &lang_sub_obj; | ||||
5915 | 24 | 50 | (my $newext = $ext) =~ tr/l/c/; | ||||
5916 | 24 | 53 | return ($r, $newext); | ||||
5917 | } | ||||||
5918 | |||||||
5919 | # Rewrite a single lex++ file. | ||||||
5920 | sub lang_lexxx_rewrite | ||||||
5921 | { | ||||||
5922 | 7 | 16 | my ($directory, $base, $ext) = @_; | ||||
5923 | |||||||
5924 | 7 | 15 | my $r = &lang_sub_obj; | ||||
5925 | 7 | 14 | (my $newext = $ext) =~ tr/l/c/; | ||||
5926 | 7 | 16 | return ($r, $newext); | ||||
5927 | } | ||||||
5928 | |||||||
5929 | # Rewrite a single assembly file. | ||||||
5930 | sub lang_asm_rewrite | ||||||
5931 | { | ||||||
5932 | 9 | 25 | return &lang_sub_obj; | ||||
5933 | } | ||||||
5934 | |||||||
5935 | # Rewrite a single preprocessed assembly file. | ||||||
5936 | sub lang_cppasm_rewrite | ||||||
5937 | { | ||||||
5938 | 13 | 36 | return &lang_sub_obj; | ||||
5939 | } | ||||||
5940 | |||||||
5941 | # Rewrite a single Fortran 77 file. | ||||||
5942 | sub lang_f77_rewrite | ||||||
5943 | { | ||||||
5944 | 22 | 56 | return &lang_sub_obj; | ||||
5945 | } | ||||||
5946 | |||||||
5947 | # Rewrite a single Fortran file. | ||||||
5948 | sub lang_fc_rewrite | ||||||
5949 | { | ||||||
5950 | 24 | 53 | return &lang_sub_obj; | ||||
5951 | } | ||||||
5952 | |||||||
5953 | # Rewrite a single preprocessed Fortran file. | ||||||
5954 | sub lang_ppfc_rewrite | ||||||
5955 | { | ||||||
5956 | 2 | 6 | return &lang_sub_obj; | ||||
5957 | } | ||||||
5958 | |||||||
5959 | # Rewrite a single preprocessed Fortran 77 file. | ||||||
5960 | sub lang_ppf77_rewrite | ||||||
5961 | { | ||||||
5962 | 2 | 4 | return &lang_sub_obj; | ||||
5963 | } | ||||||
5964 | |||||||
5965 | # Rewrite a single ratfor file. | ||||||
5966 | sub lang_ratfor_rewrite | ||||||
5967 | { | ||||||
5968 | 2 | 5 | return &lang_sub_obj; | ||||
5969 | } | ||||||
5970 | |||||||
5971 | # Rewrite a single Objective C file. | ||||||
5972 | sub lang_objc_rewrite | ||||||
5973 | { | ||||||
5974 | 4 | 9 | return &lang_sub_obj; | ||||
5975 | } | ||||||
5976 | |||||||
5977 | # Rewrite a single Unified Parallel C file. | ||||||
5978 | sub lang_upc_rewrite | ||||||
5979 | { | ||||||
5980 | 5 | 13 | return &lang_sub_obj; | ||||
5981 | } | ||||||
5982 | |||||||
5983 | # Rewrite a single Java file. | ||||||
5984 | sub lang_java_rewrite | ||||||
5985 | { | ||||||
5986 | 7 | 25 | return LANG_SUBDIR; | ||||
5987 | } | ||||||
5988 | |||||||
5989 | # The lang_X_finish functions are called after all source file | ||||||
5990 | # processing is done. Each should handle defining rules for the | ||||||
5991 | # language, etc. A finish function is only called if a source file of | ||||||
5992 | # the appropriate type has been seen. | ||||||
5993 | |||||||
5994 | sub lang_c_finish | ||||||
5995 | { | ||||||
5996 | # Push all libobjs files onto de_ansi_files. We actually only | ||||||
5997 | # push files which exist in the current directory, and which are | ||||||
5998 | # genuine source files. | ||||||
5999 | 516 | 2577 | foreach my $file (keys %libsources) | ||||
6000 | { | ||||||
6001 | 81 | 1599 | if ($file =~ /^(.*)\.[cly]$/ && -f "$relative_dir/$file") | ||||
6002 | { | ||||||
6003 | 48 | 229 | $de_ansi_files{$1} = '' | ||||
6004 | } | ||||||
6005 | } | ||||||
6006 | |||||||
6007 | 516 | 1772 | if (option 'ansi2knr' && keys %de_ansi_files) | ||||
6008 | { | ||||||
6009 | # Make all _.c files depend on their corresponding .c files. | ||||||
6010 | 13 | 20 | my @objects; | ||||
6011 | 13 | 61 | foreach my $base (sort keys %de_ansi_files) | ||||
6012 | { | ||||||
6013 | # Each _.c file must depend on ansi2knr; otherwise it | ||||||
6014 | # might be used in a parallel build before it is built. | ||||||
6015 | # We need to support files in the srcdir and in the build | ||||||
6016 | # dir (because these files might be auto-generated. But | ||||||
6017 | # we can't use $< -- some makes only define $< during a | ||||||
6018 | # suffix rule. | ||||||
6019 | 18 | 609 | my $ansfile = $de_ansi_files{$base} . $base . '.c'; | ||||
6020 | 18 | 129 | $output_rules .= ($base . "_.c: $ansfile \$(ANSI2KNR)\n\t" | ||||
6021 | . '$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) ' | ||||||
6022 | . '`if test -f $(srcdir)/' . $ansfile | ||||||
6023 | . '; then echo $(srcdir)/' . $ansfile | ||||||
6024 | . '; else echo ' . $ansfile . '; fi` ' | ||||||
6025 | . "| sed 's/^# \\([0-9]\\)/#line \\1/' " | ||||||
6026 | . '| $(ANSI2KNR) > $@' | ||||||
6027 | # If ansi2knr fails then we shouldn't | ||||||
6028 | # create the _.c file | ||||||
6029 | . " || rm -f \$\@\n"); | ||||||
6030 | 18 | 42 | push (@objects, $base . '_.$(OBJEXT)'); | ||||
6031 | 18 | 58 | push (@objects, $base . '_.lo') | ||||
6032 | if var ('LIBTOOL'); | ||||||
6033 | |||||||
6034 | # Explicitly clean the _.c files if they are in a | ||||||
6035 | # subdirectory. (In the current directory they get erased | ||||||
6036 | # by a `rm -f *_.c' rule.) | ||||||
6037 | 18 | 59 | $clean_files{$base . '_.c'} = MOSTLY_CLEAN | ||||
6038 | if dirname ($base) ne '.'; | ||||||
6039 | } | ||||||
6040 | |||||||
6041 | # Make all _.o (and _.lo) files depend on ansi2knr. | ||||||
6042 | # Use a sneaky little hack to make it print nicely. | ||||||
6043 | 13 | 1523 | &pretty_print_rule ('', '', @objects, ':', '$(ANSI2KNR)'); | ||||
6044 | } | ||||||
6045 | } | ||||||
6046 | |||||||
6047 | sub lang_vala_finish_target ($$) | ||||||
6048 | { | ||||||
6049 | 4 | 8 | my ($self, $name) = @_; | ||||
6050 | |||||||
6051 | 4 | 9 | my $derived = canonicalize ($name); | ||||
6052 | 4 | 7 | my $varname = $derived . '_SOURCES'; | ||||
6053 | 4 | 12 | my $var = var ($varname); | ||||
6054 | |||||||
6055 | 4 | 11 | if ($var) | ||||
6056 | { | ||||||
6057 | 4 | 14 | foreach my $file ($var->value_as_list_recursive) | ||||
6058 | { | ||||||
6059 | 6 | 122 | $output_rules .= "\$(srcdir)/$file: \$(srcdir)/${derived}_vala.stamp\n" | ||||
6060 | . "\t\@if test -f \$@; then :; else rm -f \$(srcdir)/${derived}_vala.stamp; fi\n" | ||||||
6061 | . "\t\@if test -f \$@; then :; else \\\n" | ||||||
6062 | . "\t \$(am__cd) \$(srcdir) && \$(MAKE) \$(AM_MAKEFLAGS) ${derived}_vala.stamp; \\\n" | ||||||
6063 | . "\tfi\n" | ||||||
6064 | if $file =~ s/(.*)\.vala$/$1.c/; | ||||||
6065 | } | ||||||
6066 | } | ||||||
6067 | |||||||
6068 | # Add rebuild rules for generated header and vapi files | ||||||
6069 | 4 | 35 | my $flags = var ($derived . '_VALAFLAGS'); | ||||
6070 | 4 | 10 | if ($flags) | ||||
6071 | { | ||||||
6072 | 1 | 2 | my $lastflag = ''; | ||||
6073 | 1 | 3 | foreach my $flag ($flags->value_as_list_recursive) | ||||
6074 | { | ||||||
6075 | 1 | 17 | if (grep (/$lastflag/, ('-H', '-h', '--header', '--internal-header', | ||||
6076 | '--vapi', '--internal-vapi', '--gir'))) | ||||||
6077 | { | ||||||
6078 | 0 | 0 | my $headerfile = $flag; | ||||
6079 | 0 | 0 | $output_rules .= "\$(srcdir)/$headerfile: \$(srcdir)/${derived}_vala.stamp\n" | ||||
6080 | . "\t\@if test -f \$@; then :; else rm -f \$(srcdir)/${derived}_vala.stamp; fi\n" | ||||||
6081 | . "\t\@if test -f \$@; then :; else \\\n" | ||||||
6082 | . "\t \$(am__cd) \$(srcdir) && \$(MAKE) \$(AM_MAKEFLAGS) ${derived}_vala.stamp; \\\n" | ||||||
6083 | . "\tfi\n"; | ||||||
6084 | |||||||
6085 | # valac is not used when building from dist tarballs | ||||||
6086 | # distribute the generated files | ||||||
6087 | 0 | 0 | push_dist_common ($headerfile); | ||||
6088 | 0 | 0 | $clean_files{$headerfile} = MAINTAINER_CLEAN; | ||||
6089 | } | ||||||
6090 | 1 | 3 | $lastflag = $flag; | ||||
6091 | } | ||||||
6092 | } | ||||||
6093 | |||||||
6094 | 4 | 16 | my $compile = $self->compile; | ||||
6095 | |||||||
6096 | # Rewrite each occurrence of `AM_VALAFLAGS' in the compile | ||||||
6097 | # rule into `${derived}_VALAFLAGS' if it exists. | ||||||
6098 | 4 | 7 | my $val = "${derived}_VALAFLAGS"; | ||||
6099 | 4 | 12 | $compile =~ s/\(AM_VALAFLAGS\)/\($val\)/ | ||||
6100 | if set_seen ($val); | ||||||
6101 | |||||||
6102 | # VALAFLAGS is a user variable (per GNU Standards), | ||||||
6103 | # it should not be overridden in the Makefile... | ||||||
6104 | 4 | 11 | check_user_variables ['VALAFLAGS']; | ||||
6105 | |||||||
6106 | 4 | 12 | my $dirname = dirname ($name); | ||||
6107 | |||||||
6108 | # Only generate C code, do not run C compiler | ||||||
6109 | 4 | 427 | $compile .= " -C"; | ||||
6110 | |||||||
6111 | 4 | 9 | my $verbose = verbose_flag ('VALAC'); | ||||
6112 | 4 | 7 | my $silent = silent_flag (); | ||||
6113 | |||||||
6114 | 4 | 23 | $output_rules .= | ||||
6115 | "${derived}_vala.stamp: \$(${derived}_SOURCES)\n". | ||||||
6116 | "\t${verbose}${compile} \$(${derived}_SOURCES)\n". | ||||||
6117 | "\t${silent}touch \$@\n"; | ||||||
6118 | |||||||
6119 | 4 | 12 | push_dist_common ("${derived}_vala.stamp"); | ||||
6120 | |||||||
6121 | 4 | 26 | $clean_files{"${derived}_vala.stamp"} = MAINTAINER_CLEAN; | ||||
6122 | } | ||||||
6123 | |||||||
6124 | # Add output rules to invoke valac and create stamp file as a witness | ||||||
6125 | # to handle multiple outputs. This function is called after all source | ||||||
6126 | # file processing is done. | ||||||
6127 | sub lang_vala_finish | ||||||
6128 | { | ||||||
6129 | 2 | 8 | my ($self) = @_; | ||||
6130 | |||||||
6131 | 2 | 8 | foreach my $prog (keys %known_programs) | ||||
6132 | { | ||||||
6133 | 2 | 9 | lang_vala_finish_target ($self, $prog); | ||||
6134 | } | ||||||
6135 | |||||||
6136 | 2 | 11 | while (my ($name) = each %known_libraries) | ||||
6137 | { | ||||||
6138 | 2 | 109 | lang_vala_finish_target ($self, $name); | ||||
6139 | } | ||||||
6140 | } | ||||||
6141 | |||||||
6142 | # The built .c files should be cleaned only on maintainer-clean | ||||||
6143 | # as the .c files are distributed. This function is called for each | ||||||
6144 | # .vala source file. | ||||||
6145 | sub lang_vala_target_hook | ||||||
6146 | { | ||||||
6147 | 6 | 21 | my ($self, $aggregate, $output, $input, %transform) = @_; | ||||
6148 | |||||||
6149 | 6 | 18 | $clean_files{$output} = MAINTAINER_CLEAN; | ||||
6150 | } | ||||||
6151 | |||||||
6152 | # This is a yacc helper which is called whenever we have decided to | ||||||
6153 | # compile a yacc file. | ||||||
6154 | sub lang_yacc_target_hook | ||||||
6155 | { | ||||||
6156 | 53 | 235 | my ($self, $aggregate, $output, $input, %transform) = @_; | ||||
6157 | |||||||
6158 | 53 | 113 | my $flag = $aggregate . "_YFLAGS"; | ||||
6159 | 53 | 138 | my $flagvar = var $flag; | ||||
6160 | 53 | 141 | my $YFLAGSvar = var 'YFLAGS'; | ||||
6161 | 53 | 455 | if (($flagvar && $flagvar->variable_value =~ /$DASH_D_PATTERN/o) | ||||
6162 | || ($YFLAGSvar && $YFLAGSvar->variable_value =~ /$DASH_D_PATTERN/o)) | ||||||
6163 | { | ||||||
6164 | 26 | 1398 | (my $output_base = $output) =~ s/$KNOWN_EXTENSIONS_PATTERN$//; | ||||
6165 | 26 | 65 | my $header = $output_base . '.h'; | ||||
6166 | |||||||
6167 | # Found a `-d' that applies to the compilation of this file. | ||||||
6168 | # Add a dependency for the generated header file, and arrange | ||||||
6169 | # for that file to be included in the distribution. | ||||||
6170 | 26 | 112 | foreach my $cond (Automake::Rule::define (${header}, 'internal', | ||||
6171 | RULE_AUTOMAKE, TRUE, | ||||||
6172 | INTERNAL)) | ||||||
6173 | { | ||||||
6174 | 21 | 75 | my $condstr = $cond->subst_string; | ||||
6175 | 21 | 190 | $output_rules .= | ||||
6176 | "$condstr${header}: $output\n" | ||||||
6177 | # Recover from removal of $header | ||||||
6178 | . "$condstr\t\@if test ! -f \$@; then rm -f $output; else :; fi\n" | ||||||
6179 | . "$condstr\t\@if test ! -f \$@; then \$(MAKE) \$(AM_MAKEFLAGS) $output; else :; fi\n"; | ||||||
6180 | } | ||||||
6181 | # Distribute the generated file, unless its .y source was | ||||||
6182 | # listed in a nodist_ variable. (&handle_source_transform | ||||||
6183 | # will set DIST_SOURCE.) | ||||||
6184 | 26 | 120 | &push_dist_common ($header) | ||||
6185 | if $transform{'DIST_SOURCE'}; | ||||||
6186 | |||||||
6187 | # If the files are built in the build directory, then we want | ||||||
6188 | # to remove them with `make clean'. If they are in srcdir | ||||||
6189 | # they shouldn't be touched. However, we can't determine this | ||||||
6190 | # statically, and the GNU rules say that yacc/lex output files | ||||||
6191 | # should be removed by maintainer-clean. So that's what we | ||||||
6192 | # do. | ||||||
6193 | 26 | 60 | $clean_files{$header} = MAINTAINER_CLEAN; | ||||
6194 | } | ||||||
6195 | # Erase $OUTPUT on `make maintainer-clean' (by GNU standards). | ||||||
6196 | # See the comment above for $HEADER. | ||||||
6197 | 53 | 206 | $clean_files{$output} = MAINTAINER_CLEAN; | ||||
6198 | } | ||||||
6199 | |||||||
6200 | # This is a lex helper which is called whenever we have decided to | ||||||
6201 | # compile a lex file. | ||||||
6202 | sub lang_lex_target_hook | ||||||
6203 | { | ||||||
6204 | 31 | 91 | my ($self, $aggregate, $output, $input) = @_; | ||||
6205 | # If the files are built in the build directory, then we want to | ||||||
6206 | # remove them with `make clean'. If they are in srcdir they | ||||||
6207 | # shouldn't be touched. However, we can't determine this | ||||||
6208 | # statically, and the GNU rules say that yacc/lex output files | ||||||
6209 | # should be removed by maintainer-clean. So that's what we do. | ||||||
6210 | 31 | 84 | $clean_files{$output} = MAINTAINER_CLEAN; | ||||
6211 | } | ||||||
6212 | |||||||
6213 | # This is a helper for both lex and yacc. | ||||||
6214 | sub yacc_lex_finish_helper | ||||||
6215 | { | ||||||
6216 | 54 | 169 | return if defined $language_scratch{'lex-yacc-done'}; | ||||
6217 | 48 | 105 | $language_scratch{'lex-yacc-done'} = 1; | ||||
6218 | |||||||
6219 | # FIXME: for now, no line number. | ||||||
6220 | 48 | 163 | require_conf_file ($configure_ac, FOREIGN, 'ylwrap'); | ||||
6221 | 48 | 189 | &define_variable ('YLWRAP', "$am_config_aux_dir/ylwrap", INTERNAL); | ||||
6222 | } | ||||||
6223 | |||||||
6224 | sub lang_yacc_finish | ||||||
6225 | { | ||||||
6226 | 36 | 136 | return if defined $language_scratch{'yacc-done'}; | ||||
6227 | 36 | 87 | $language_scratch{'yacc-done'} = 1; | ||||
6228 | |||||||
6229 | 36 | 133 | reject_var 'YACCFLAGS', "`YACCFLAGS' obsolete; use `YFLAGS' instead"; | ||||
6230 | |||||||
6231 | 36 | 107 | yacc_lex_finish_helper; | ||||
6232 | } | ||||||
6233 | |||||||
6234 | |||||||
6235 | sub lang_lex_finish | ||||||
6236 | { | ||||||
6237 | 18 | 68 | return if defined $language_scratch{'lex-done'}; | ||||
6238 | 18 | 39 | $language_scratch{'lex-done'} = 1; | ||||
6239 | |||||||
6240 | 18 | 58 | yacc_lex_finish_helper; | ||||
6241 | } | ||||||
6242 | |||||||
6243 | |||||||
6244 | # Given a hash table of linker names, pick the name that has the most | ||||||
6245 | # precedence. This is lame, but something has to have global | ||||||
6246 | # knowledge in order to eliminate the conflict. Add more linkers as | ||||||
6247 | # required. | ||||||
6248 | sub resolve_linker | ||||||
6249 | { | ||||||
6250 | 1066 | 2738 | my (%linkers) = @_; | ||||
6251 | |||||||
6252 | 1066 | 2749 | foreach my $l (qw(GCJLINK CXXLINK F77LINK FCLINK OBJCLINK UPCLINK)) | ||||
6253 | { | ||||||
6254 | 6089 | 13881 | return $l if defined $linkers{$l}; | ||||
6255 | } | ||||||
6256 | 979 | 2398 | return 'LINK'; | ||||
6257 | } | ||||||
6258 | |||||||
6259 | # Called to indicate that an extension was used. | ||||||
6260 | sub saw_extension | ||||||
6261 | { | ||||||
6262 | 2012 | 4133 | my ($ext) = @_; | ||||
6263 | 2012 | 4957 | if (! defined $extension_seen{$ext}) | ||||
6264 | { | ||||||
6265 | 817 | 2566 | $extension_seen{$ext} = 1; | ||||
6266 | } | ||||||
6267 | else | ||||||
6268 | { | ||||||
6269 | 1195 | 2607 | ++$extension_seen{$ext}; | ||||
6270 | } | ||||||
6271 | } | ||||||
6272 | |||||||
6273 | # Return the number of files seen for a given language. Knows about | ||||||
6274 | # special cases we care about. FIXME: this is hideous. We need | ||||||
6275 | # something that involves real language objects. For instance yacc | ||||||
6276 | # and yaccxx could both derive from a common yacc class which would | ||||||
6277 | # know about the strange ylwrap requirement. (Or better yet we could | ||||||
6278 | # just not support legacy yacc!) | ||||||
6279 | sub count_files_for_language | ||||||
6280 | { | ||||||
6281 | 1291 | 3222 | my ($name) = @_; | ||||
6282 | |||||||
6283 | 1291 | 1846 | my @names; | ||||
6284 | 1291 | 19986 | if ($name eq 'yacc' || $name eq 'yaccxx') | ||||
6285 | { | ||||||
6286 | 0 | 0 | @names = ('yacc', 'yaccxx'); | ||||
6287 | } | ||||||
6288 | elsif ($name eq 'lex' || $name eq 'lexxx') | ||||||
6289 | { | ||||||
6290 | 0 | 0 | @names = ('lex', 'lexxx'); | ||||
6291 | } | ||||||
6292 | else | ||||||
6293 | { | ||||||
6294 | 1291 | 3404 | @names = ($name); | ||||
6295 | } | ||||||
6296 | |||||||
6297 | 1291 | 2760 | my $r = 0; | ||||
6298 | 1291 | 3575 | foreach $name (@names) | ||||
6299 | { | ||||||
6300 | 1291 | 3819 | my $lang = $languages{$name}; | ||||
6301 | 1291 1291 | 1892 9162 | foreach my $ext (@{$lang->extensions}) | ||||
6302 | { | ||||||
6303 | 9037 | 24535 | $r += $extension_seen{$ext} | ||||
6304 | if defined $extension_seen{$ext}; | ||||||
6305 | } | ||||||
6306 | } | ||||||
6307 | |||||||
6308 | 1291 | 3671 | return $r | ||||
6309 | } | ||||||
6310 | |||||||
6311 | # Called to ask whether source files have been seen . If HEADERS is 1, | ||||||
6312 | # headers can be included. | ||||||
6313 | sub saw_sources_p | ||||||
6314 | { | ||||||
6315 | 2610 | 5696 | my ($headers) = @_; | ||||
6316 | |||||||
6317 | # count all the sources | ||||||
6318 | 2610 | 4080 | my $count = 0; | ||||
6319 | 2610 | 7635 | foreach my $val (values %extension_seen) | ||||
6320 | { | ||||||
6321 | 1494 | 3429 | $count += $val; | ||||
6322 | } | ||||||
6323 | |||||||
6324 | 2610 | 7534 | if (!$headers) | ||||
6325 | { | ||||||
6326 | 1291 | 5212 | $count -= count_files_for_language ('header'); | ||||
6327 | } | ||||||
6328 | |||||||
6329 | 2610 | 18954 | return $count > 0; | ||||
6330 | } | ||||||
6331 | |||||||
6332 | |||||||
6333 | # register_language (%ATTRIBUTE) | ||||||
6334 | # ------------------------------ | ||||||
6335 | # Register a single language. | ||||||
6336 | # Each %ATTRIBUTE is of the form ATTRIBUTE => VALUE. | ||||||
6337 | sub register_language (%) | ||||||
6338 | { | ||||||
6339 | 20862 | 108096 | my (%option) = @_; | ||||
6340 | |||||||
6341 | # Set the defaults. | ||||||
6342 | 20862 | 57260 | $option{'ansi'} = 0 | ||||
6343 | unless defined $option{'ansi'}; | ||||||
6344 | 20862 | 51130 | $option{'autodep'} = 'no' | ||||
6345 | unless defined $option{'autodep'}; | ||||||
6346 | 20862 | 46056 | $option{'linker'} = '' | ||||
6347 | unless defined $option{'linker'}; | ||||||
6348 | 20862 | 40910 | $option{'flags'} = [] | ||||
6349 | unless defined $option{'flags'}; | ||||||
6350 | 31913 | 63383 | $option{'output_extensions'} = sub { return ( '.$(OBJEXT)', '.lo' ) } | ||||
6351 | 20862 | 80121 | unless defined $option{'output_extensions'}; | ||||
6352 | 20862 | 52645 | $option{'nodist_specific'} = 0 | ||||
6353 | unless defined $option{'nodist_specific'}; | ||||||
6354 | |||||||
6355 | 20862 | 96233 | my $lang = new Language (%option); | ||||
6356 | |||||||
6357 | # Fill indexes. | ||||||
6358 | 20862 20862 20862 | 31109 22027 47662 | $extension_map{$_} = $lang->name foreach @{$lang->extensions}; | ||||
6359 | 20862 | 50309 | $languages{$lang->name} = $lang; | ||||
6360 | 20862 | 47094 | my $link = $lang->linker; | ||||
6361 | 20862 | 36398 | if ($link) | ||||
6362 | { | ||||||
6363 | 11590 | 20652 | if (exists $link_languages{$link}) | ||||
6364 | { | ||||||
6365 | 3477 | 9067 | prog_error ("`$link' has different definitions in " | ||||
6366 | . $lang->name . " and " . $link_languages{$link}->name) | ||||||
6367 | if $lang->link ne $link_languages{$link}->link; | ||||||
6368 | } | ||||||
6369 | else | ||||||
6370 | { | ||||||
6371 | 8113 | 16228 | $link_languages{$link} = $lang; | ||||
6372 | } | ||||||
6373 | } | ||||||
6374 | |||||||
6375 | # Update the pattern of known extensions. | ||||||
6376 | 20862 20862 | 20637 42552 | accept_extensions (@{$lang->extensions}); | ||||
6377 | |||||||
6378 | # Upate the $suffix_rule map. | ||||||
6379 | 20862 20862 | 45543 44865 | foreach my $suffix (@{$lang->extensions}) | ||||
6380 | { | ||||||
6381 | 52155 52155 | 58545 110710 | foreach my $dest (&{$lang->output_extensions} ($suffix)) | ||||
6382 | { | ||||||
6383 | 75335 | 170177 | register_suffix_rule (INTERNAL, $suffix, $dest); | ||||
6384 | } | ||||||
6385 | } | ||||||
6386 | } | ||||||
6387 | |||||||
6388 | # derive_suffix ($EXT, $OBJ) | ||||||
6389 | # -------------------------- | ||||||
6390 | # This function is used to find a path from a user-specified suffix $EXT | ||||||
6391 | # to $OBJ or to some other suffix we recognize internally, e.g. `cc'. | ||||||
6392 | sub derive_suffix ($$) | ||||||
6393 | { | ||||||
6394 | 1471 | 3382 | my ($source_ext, $obj) = @_; | ||||
6395 | |||||||
6396 | 1471 | 9106 | while (! $extension_map{$source_ext} | ||||
6397 | && $source_ext ne $obj | ||||||
6398 | && exists $suffix_rules->{$source_ext} | ||||||
6399 | && exists $suffix_rules->{$source_ext}{$obj}) | ||||||
6400 | { | ||||||
6401 | 25 | 207 | $source_ext = $suffix_rules->{$source_ext}{$obj}[0]; | ||||
6402 | } | ||||||
6403 | |||||||
6404 | 1471 | 3050 | return $source_ext; | ||||
6405 | } | ||||||
6406 | |||||||
6407 | |||||||
6408 | ################################################################ | ||||||
6409 | |||||||
6410 | # Pretty-print something and append to output_rules. | ||||||
6411 | sub pretty_print_rule | ||||||
6412 | { | ||||||
6413 | 47736 | 116859 | $output_rules .= &makefile_wrap (@_); | ||||
6414 | } | ||||||
6415 | |||||||
6416 | |||||||
6417 | ################################################################ | ||||||
6418 | |||||||
6419 | |||||||
6420 | ## -------------------------------- ## | ||||||
6421 | ## Handling the conditional stack. ## | ||||||
6422 | ## -------------------------------- ## | ||||||
6423 | |||||||
6424 | |||||||
6425 | # $STRING | ||||||
6426 | # make_conditional_string ($NEGATE, $COND) | ||||||
6427 | # ---------------------------------------- | ||||||
6428 | sub make_conditional_string ($$) | ||||||
6429 | { | ||||||
6430 | 151114 | 236856 | my ($negate, $cond) = @_; | ||||
6431 | 151114 | 404487 | $cond = "${cond}_TRUE" | ||||
6432 | unless $cond =~ /^TRUE|FALSE$/; | ||||||
6433 | 151114 | 277891 | $cond = Automake::Condition::conditional_negate ($cond) | ||||
6434 | if $negate; | ||||||
6435 | 151114 | 270369 | return $cond; | ||||
6436 | } | ||||||
6437 | |||||||
6438 | |||||||
6439 | 1159 | 9407 | my %_am_macro_for_cond = | ||||
6440 | ( | ||||||
6441 | AMDEP => "one of the compiler tests\n" | ||||||
6442 | . " AC_PROG_CC, AC_PROG_CXX, AC_PROG_CXX, AC_PROG_OBJC,\n" | ||||||
6443 | . " AM_PROG_AS, AM_PROG_GCJ, AM_PROG_UPC", | ||||||
6444 | am__fastdepCC => 'AC_PROG_CC', | ||||||
6445 | am__fastdepCCAS => 'AM_PROG_AS', | ||||||
6446 | am__fastdepCXX => 'AC_PROG_CXX', | ||||||
6447 | am__fastdepGCJ => 'AM_PROG_GCJ', | ||||||
6448 | am__fastdepOBJC => 'AC_PROG_OBJC', | ||||||
6449 | am__fastdepUPC => 'AM_PROG_UPC' | ||||||
6450 | ); | ||||||
6451 | |||||||
6452 | # $COND | ||||||
6453 | # cond_stack_if ($NEGATE, $COND, $WHERE) | ||||||
6454 | # -------------------------------------- | ||||||
6455 | sub cond_stack_if ($$$) | ||||||
6456 | { | ||||||
6457 | 69306 | 186347 | my ($negate, $cond, $where) = @_; | ||||
6458 | |||||||
6459 | 69306 | 443608 | if (! $configure_cond{$cond} && $cond !~ /^TRUE|FALSE$/) | ||||
6460 | { | ||||||
6461 | 95 | 189 | my $text = "$cond does not appear in AM_CONDITIONAL"; | ||||
6462 | 95 | 112 | my $scope = US_LOCAL; | ||||
6463 | 95 | 228 | if (exists $_am_macro_for_cond{$cond}) | ||||
6464 | { | ||||||
6465 | 93 | 141 | my $mac = $_am_macro_for_cond{$cond}; | ||||
6466 | 93 | 176 | $text .= "\n The usual way to define `$cond' is to add "; | ||||
6467 | 93 | 291 | $text .= ($mac =~ / /) ? $mac : "`$mac'"; | ||||
6468 | 93 | 173 | $text .= "\n to `$configure_ac' and run `aclocal' and `autoconf' again"; | ||||
6469 | # These warnings appear in Automake files (depend2.am), | ||||||
6470 | # so there is no need to display them more than once: | ||||||
6471 | 93 | 119 | $scope = US_GLOBAL; | ||||
6472 | } | ||||||
6473 | 95 | 312 | error $where, $text, uniq_scope => $scope; | ||||
6474 | } | ||||||
6475 | |||||||
6476 | 69306 | 139872 | push (@cond_stack, make_conditional_string ($negate, $cond)); | ||||
6477 | |||||||
6478 | 69306 | 233387 | return new Automake::Condition (@cond_stack); | ||||
6479 | } | ||||||
6480 | |||||||
6481 | |||||||
6482 | # $COND | ||||||
6483 | # cond_stack_else ($NEGATE, $COND, $WHERE) | ||||||
6484 | # ---------------------------------------- | ||||||
6485 | sub cond_stack_else ($$$) | ||||||
6486 | { | ||||||
6487 | 14060 | 40734 | my ($negate, $cond, $where) = @_; | ||||
6488 | |||||||
6489 | 14060 | 31891 | if (! @cond_stack) | ||||
6490 | { | ||||||
6491 | 2 | 13 | error $where, "else without if"; | ||||
6492 | 2 | 6 | return FALSE; | ||||
6493 | } | ||||||
6494 | |||||||
6495 | 14058 | 46546 | $cond_stack[$#cond_stack] = | ||||
6496 | Automake::Condition::conditional_negate ($cond_stack[$#cond_stack]); | ||||||
6497 | |||||||
6498 | # If $COND is given, check against it. | ||||||
6499 | 14058 | 33013 | if (defined $cond) | ||||
6500 | { | ||||||
6501 | 13993 | 24849 | $cond = make_conditional_string ($negate, $cond); | ||||
6502 | |||||||
6503 | 13993 | 42292 | error ($where, "else reminder ($negate$cond) incompatible with " | ||||
6504 | . "current conditional: $cond_stack[$#cond_stack]") | ||||||
6505 | if $cond_stack[$#cond_stack] ne $cond; | ||||||
6506 | } | ||||||
6507 | |||||||
6508 | 14058 | 43176 | return new Automake::Condition (@cond_stack); | ||||
6509 | } | ||||||
6510 | |||||||
6511 | |||||||
6512 | # $COND | ||||||
6513 | # cond_stack_endif ($NEGATE, $COND, $WHERE) | ||||||
6514 | # ----------------------------------------- | ||||||
6515 | sub cond_stack_endif ($$$) | ||||||
6516 | { | ||||||
6517 | 69305 | 180490 | my ($negate, $cond, $where) = @_; | ||||
6518 | 69305 | 62265 | my $old_cond; | ||||
6519 | |||||||
6520 | 69305 | 137617 | if (! @cond_stack) | ||||
6521 | { | ||||||
6522 | 3 | 13 | error $where, "endif without if"; | ||||
6523 | 3 | 10 | return TRUE; | ||||
6524 | } | ||||||
6525 | |||||||
6526 | # If $COND is given, check against it. | ||||||
6527 | 69302 | 133399 | if (defined $cond) | ||||
6528 | { | ||||||
6529 | 67815 | 109047 | $cond = make_conditional_string ($negate, $cond); | ||||
6530 | |||||||
6531 | 67815 | 198948 | error ($where, "endif reminder ($negate$cond) incompatible with " | ||||
6532 | . "current conditional: $cond_stack[$#cond_stack]") | ||||||
6533 | if $cond_stack[$#cond_stack] ne $cond; | ||||||
6534 | } | ||||||
6535 | |||||||
6536 | 69302 | 72287 | pop @cond_stack; | ||||
6537 | |||||||
6538 | 69302 | 206742 | return new Automake::Condition (@cond_stack); | ||||
6539 | } | ||||||
6540 | |||||||
6541 | |||||||
6542 | |||||||
6543 | |||||||
6544 | |||||||
6545 | ## ------------------------ ## | ||||||
6546 | ## Handling the variables. ## | ||||||
6547 | ## ------------------------ ## | ||||||
6548 | |||||||
6549 | |||||||
6550 | # &define_pretty_variable ($VAR, $COND, $WHERE, @VALUE) | ||||||
6551 | # ----------------------------------------------------- | ||||||
6552 | # Like define_variable, but the value is a list, and the variable may | ||||||
6553 | # be defined conditionally. The second argument is the condition | ||||||
6554 | # under which the value should be defined; this should be the empty | ||||||
6555 | # string to define the variable unconditionally. The third argument | ||||||
6556 | # is a list holding the values to use for the variable. The value is | ||||||
6557 | # pretty printed in the output file. | ||||||
6558 | sub define_pretty_variable ($$$@) | ||||||
6559 | { | ||||||
6560 | 21825 | 55668 | my ($var, $cond, $where, @value) = @_; | ||||
6561 | |||||||
6562 | 21825 | 53528 | if (! vardef ($var, $cond)) | ||||
6563 | { | ||||||
6564 | 19316 | 76289 | Automake::Variable::define ($var, VAR_AUTOMAKE, '', $cond, "@value", | ||||
6565 | '', $where, VAR_PRETTY); | ||||||
6566 | 19316 | 50372 | rvar ($var)->rdef ($cond)->set_seen; | ||||
6567 | } | ||||||
6568 | } | ||||||
6569 | |||||||
6570 | |||||||
6571 | # define_variable ($VAR, $VALUE, $WHERE) | ||||||
6572 | # -------------------------------------- | ||||||
6573 | # Define a new Automake Makefile variable VAR to VALUE, but only if | ||||||
6574 | # not already defined. | ||||||
6575 | sub define_variable ($$$) | ||||||
6576 | { | ||||||
6577 | 12546 | 28381 | my ($var, $value, $where) = @_; | ||||
6578 | 12546 | 25888 | define_pretty_variable ($var, TRUE, $where, $value); | ||||
6579 | } | ||||||
6580 | |||||||
6581 | |||||||
6582 | # define_files_variable ($VAR, \@BASENAME, $EXTENSION, $WHERE) | ||||||
6583 | # ------------------------------------------------------------ | ||||||
6584 | # Define the $VAR which content is the list of file names composed of | ||||||
6585 | # a @BASENAME and the $EXTENSION. | ||||||
6586 | sub define_files_variable ($\@$$) | ||||||
6587 | { | ||||||
6588 | 204 | 427 | my ($var, $basename, $extension, $where) = @_; | ||||
6589 | 244 | 793 | define_variable ($var, | ||||
6590 | 204 | 378 | join (' ', map { "$_.$extension" } @$basename), | ||||
6591 | $where); | ||||||
6592 | } | ||||||
6593 | |||||||
6594 | |||||||
6595 | # Like define_variable, but define a variable to be the configure | ||||||
6596 | # substitution by the same name. | ||||||
6597 | sub define_configure_variable ($) | ||||||
6598 | { | ||||||
6599 | 109414 | 161945 | my ($var) = @_; | ||||
6600 | |||||||
6601 | 109414 | 111735 | my $pretty = VAR_ASIS; | ||||
6602 | 109414 | 104003 | my $owner = VAR_CONFIGURE; | ||||
6603 | |||||||
6604 | # Some variables we do not want to output. For instance it | ||||||
6605 | # would be a bad idea to output `U = @U@` when `@U@` can be | ||||||
6606 | # substituted as `\`. | ||||||
6607 | 109414 | 197426 | $pretty = VAR_SILENT if exists $ignored_configure_vars{$var}; | ||||
6608 | |||||||
6609 | # ANSI2KNR is a variable that Automake wants to redefine, so | ||||||
6610 | # it must be owned by Automake. (It is also used as a proof | ||||||
6611 | # that AM_C_PROTOTYPES has been run, that's why we do not simply | ||||||
6612 | # omit the AC_SUBST.) | ||||||
6613 | 109414 | 188828 | $owner = VAR_AUTOMAKE if $var eq 'ANSI2KNR'; | ||||
6614 | |||||||
6615 | 109414 | 205356 | Automake::Variable::define ($var, $owner, '', TRUE, subst $var, | ||||
6616 | '', $configure_vars{$var}, $pretty); | ||||||
6617 | } | ||||||
6618 | |||||||
6619 | |||||||
6620 | # define_compiler_variable ($LANG) | ||||||
6621 | # -------------------------------- | ||||||
6622 | # Define a compiler variable. We also handle defining the `LT' | ||||||
6623 | # version of the command when using libtool. | ||||||
6624 | sub define_compiler_variable ($) | ||||||
6625 | { | ||||||
6626 | 688 | 1581 | my ($lang) = @_; | ||||
6627 | |||||||
6628 | 688 | 2309 | my ($var, $value) = ($lang->compiler, $lang->compile); | ||||
6629 | 688 | 2685 | my $libtool_tag = get_libtool_tag ($lang); | ||||
6630 | 688 | 2066 | &define_variable ($var, $value, INTERNAL); | ||||
6631 | 688 | 2101 | if (var ('LIBTOOL')) | ||||
6632 | { | ||||||
6633 | 78 | 226 | my $verbose = define_verbose_libtool (); | ||||
6634 | 78 | 435 | &define_variable ("LT$var", | ||||
6635 | "\$(LIBTOOL) $verbose $libtool_tag\$(AM_LIBTOOLFLAGS) " | ||||||
6636 | . "\$(LIBTOOLFLAGS) --mode=compile $value", | ||||||
6637 | INTERNAL); | ||||||
6638 | } | ||||||
6639 | 688 | 2687 | define_verbose_tagvar ($lang->ccer || 'GEN'); | ||||
6640 | } | ||||||
6641 | |||||||
6642 | |||||||
6643 | # define_linker_variable ($LANG) | ||||||
6644 | # ------------------------------ | ||||||
6645 | # Define linker variables. | ||||||
6646 | sub define_linker_variable ($) | ||||||
6647 | { | ||||||
6648 | 1110 | 2259 | my ($lang) = @_; | ||||
6649 | |||||||
6650 | 1110 | 2053 | my $libtool_tag = get_libtool_tag ($lang); | ||||
6651 | # CCLD = $(CC). | ||||||
6652 | 1110 | 3824 | &define_variable ($lang->lder, $lang->ld, INTERNAL); | ||||
6653 | # CCLINK = $(CCLD) blah blah... | ||||||
6654 | 1110 | 2098 | my $link = ''; | ||||
6655 | 1110 | 2650 | if (var ('LIBTOOL')) | ||||
6656 | { | ||||||
6657 | 146 | 276 | my $verbose = define_verbose_libtool (); | ||||
6658 | 146 | 470 | $link = "\$(LIBTOOL) $verbose $libtool_tag\$(AM_LIBTOOLFLAGS) " | ||||
6659 | . "\$(LIBTOOLFLAGS) --mode=link "; | ||||||
6660 | } | ||||||
6661 | 1110 | 3969 | &define_variable ($lang->linker, $link . $lang->link, INTERNAL); | ||||
6662 | 1110 | 3476 | &define_variable ($lang->compiler, $lang); | ||||
6663 | 1110 | 3366 | &define_verbose_tagvar ($lang->lder || 'GEN'); | ||||
6664 | } | ||||||
6665 | |||||||
6666 | sub define_per_target_linker_variable ($$) | ||||||
6667 | { | ||||||
6668 | 846 | 2093 | my ($linker, $target) = @_; | ||||
6669 | |||||||
6670 | # If the user wrote a custom link command, we don't define ours. | ||||||
6671 | 846 | 2757 | return "${target}_LINK" | ||||
6672 | if set_seen "${target}_LINK"; | ||||||
6673 | |||||||
6674 | 844 | 2269 | my $xlink = $linker ? $linker : 'LINK'; | ||||
6675 | |||||||
6676 | 844 | 1769 | my $lang = $link_languages{$xlink}; | ||||
6677 | 844 | 2052 | prog_error "Unknown language for linker variable `$xlink'" | ||||
6678 | unless $lang; | ||||||
6679 | |||||||
6680 | 844 | 5043 | my $link_command = $lang->link; | ||||
6681 | 844 | 2389 | if (var 'LIBTOOL') | ||||
6682 | { | ||||||
6683 | 147 | 498 | my $libtool_tag = get_libtool_tag ($lang); | ||||
6684 | 147 | 402 | my $verbose = define_verbose_libtool (); | ||||
6685 | 147 | 601 | $link_command = | ||||
6686 | "\$(LIBTOOL) $verbose $libtool_tag\$(AM_LIBTOOLFLAGS) \$(LIBTOOLFLAGS) " | ||||||
6687 | . "--mode=link " . $link_command; | ||||||
6688 | } | ||||||
6689 | |||||||
6690 | # Rewrite each occurrence of `AM_$flag' in the link | ||||||
6691 | # command into `${derived}_$flag' if it exists. | ||||||
6692 | 844 | 1483 | my $orig_command = $link_command; | ||||
6693 | 844 844 | 1180 2487 | my @flags = (@{$lang->flags}, 'LDFLAGS'); | ||||
6694 | 844 | 2326 | push @flags, 'LIBTOOLFLAGS' if var 'LIBTOOL'; | ||||
6695 | 844 | 2459 | for my $flag (@flags) | ||||
6696 | { | ||||||
6697 | 2650 | 4950 | my $val = "${target}_$flag"; | ||||
6698 | 2650 | 5799 | $link_command =~ s/\(AM_$flag\)/\($val\)/ | ||||
6699 | if set_seen ($val); | ||||||
6700 | } | ||||||
6701 | |||||||
6702 | # If the computed command is the same as the generic command, use | ||||||
6703 | # the command linker variable. | ||||||
6704 | 844 | 4223 | return ($lang->linker, $lang->lder) | ||||
6705 | if $link_command eq $orig_command; | ||||||
6706 | |||||||
6707 | 54 | 185 | &define_variable ("${target}_LINK", $link_command, INTERNAL); | ||||
6708 | 54 | 362 | return ("${target}_LINK", $lang->lder); | ||||
6709 | } | ||||||
6710 | |||||||
6711 | ################################################################ | ||||||
6712 | |||||||
6713 | # &check_trailing_slash ($WHERE, $LINE) | ||||||
6714 | # ------------------------------------- | ||||||
6715 | # Return 1 iff $LINE ends with a slash. | ||||||
6716 | # Might modify $LINE. | ||||||
6717 | sub check_trailing_slash ($\$) | ||||||
6718 | { | ||||||
6719 | 10588 | 17445 | my ($where, $line) = @_; | ||||
6720 | |||||||
6721 | # Ignore `##' lines. | ||||||
6722 | 10588 | 38210 | return 0 if $$line =~ /$IGNORE_PATTERN/o; | ||||
6723 | |||||||
6724 | # Catch and fix a common error. | ||||||
6725 | 10481 | 23832 | msg "syntax", $where, "whitespace following trailing backslash" | ||||
6726 | if $$line =~ s/\\\s+\n$/\\\n/; | ||||||
6727 | |||||||
6728 | 10481 | 25362 | return $$line =~ /\\$/; | ||||
6729 | } | ||||||
6730 | |||||||
6731 | |||||||
6732 | # &read_am_file ($AMFILE, $WHERE) | ||||||
6733 | # ------------------------------- | ||||||
6734 | # Read Makefile.am and set up %contents. Simultaneously copy lines | ||||||
6735 | # from Makefile.am into $output_trailer, or define variables as | ||||||
6736 | # appropriate. NOTE we put rules in the trailer section. We want | ||||||
6737 | # user rules to come after our generated stuff. | ||||||
6738 | sub read_am_file ($$) | ||||||
6739 | { | ||||||
6740 | 1372 | 4005 | my ($amfile, $where) = @_; | ||||
6741 | |||||||
6742 | 1372 | 9860 | my $am_file = new Automake::XFile ("< $amfile"); | ||||
6743 | 1371 | 7165 | verb "reading $amfile"; | ||||
6744 | |||||||
6745 | # Keep track of the youngest output dependency. | ||||||
6746 | 1371 | 11732 | my $mtime = mtime $amfile; | ||||
6747 | 1371 | 4764 | $output_deps_greatest_timestamp = $mtime | ||||
6748 | if $mtime > $output_deps_greatest_timestamp; | ||||||
6749 | |||||||
6750 | 1371 | 2450 | my $spacing = ''; | ||||
6751 | 1371 | 2136 | my $comment = ''; | ||||
6752 | 1371 | 2064 | my $blank = 0; | ||||
6753 | 1371 | 1912 | my $saw_bk = 0; | ||||
6754 | 1371 | 2428 | my $var_look = VAR_ASIS; | ||||
6755 | |||||||
6756 | 1159 1159 1159 | 12067 1986 8000 | use constant IN_VAR_DEF => 0; | ||||
6757 | 1159 1159 1159 | 4734 1552 3400 | use constant IN_RULE_DEF => 1; | ||||
6758 | 1159 1159 1159 | 5004 1604 3380 | use constant IN_COMMENT => 2; | ||||
6759 | 1371 | 3310 | my $prev_state = IN_RULE_DEF; | ||||
6760 | |||||||
6761 | 1371 | 5940 | while ($_ = $am_file->getline) | ||||
6762 | { | ||||||
6763 | 1222 | 15548 | $where->set ("$amfile:$."); | ||||
6764 | 1222 | 43524 | if (/$IGNORE_PATTERN/o) | ||||
6765 | { | ||||||
6766 | # Merely delete comments beginning with two hashes. | ||||||
6767 | } | ||||||
6768 | elsif (/$WHITE_PATTERN/o) | ||||||
6769 | { | ||||||
6770 | 17 | 72 | error $where, "blank line following trailing backslash" | ||||
6771 | if $saw_bk; | ||||||
6772 | # Stick a single white line before the incoming macro or rule. | ||||||
6773 | 17 | 29 | $spacing = "\n"; | ||||
6774 | 17 | 32 | $blank = 1; | ||||
6775 | # Flush all comments seen so far. | ||||||
6776 | 17 | 65 | if ($comment ne '') | ||||
6777 | { | ||||||
6778 | 3 | 9 | $output_vars .= $comment; | ||||
6779 | 3 | 4 | $comment = ''; | ||||
6780 | } | ||||||
6781 | } | ||||||
6782 | elsif (/$COMMENT_PATTERN/o) | ||||||
6783 | { | ||||||
6784 | # Stick comments before the incoming macro or rule. Make | ||||||
6785 | # sure a blank line precedes the first block of comments. | ||||||
6786 | 34 | 111 | $spacing = "\n" unless $blank; | ||||
6787 | 34 | 53 | $blank = 1; | ||||
6788 | 34 | 78 | $comment .= $spacing . $_; | ||||
6789 | 34 | 43 | $spacing = ''; | ||||
6790 | 34 | 61 | $prev_state = IN_COMMENT; | ||||
6791 | } | ||||||
6792 | else | ||||||
6793 | { | ||||||
6794 | 1160 | 2880 | last; | ||||
6795 | } | ||||||
6796 | 62 | 272 | $saw_bk = check_trailing_slash ($where, $_); | ||||
6797 | } | ||||||
6798 | |||||||
6799 | # We save the conditional stack on entry, and then check to make | ||||||
6800 | # sure it is the same on exit. This lets us conditionally include | ||||||
6801 | # other files. | ||||||
6802 | 1371 | 3370 | my @saved_cond_stack = @cond_stack; | ||||
6803 | 1371 | 9778 | my $cond = new Automake::Condition (@cond_stack); | ||||
6804 | |||||||
6805 | 1371 | 2441 | my $last_var_name = ''; | ||||
6806 | 1371 | 2230 | my $last_var_type = ''; | ||||
6807 | 1371 | 2087 | my $last_var_value = ''; | ||||
6808 | 1371 | 1965 | my $last_where; | ||||
6809 | # FIXME: shouldn't use $_ in this loop; it is too big. | ||||||
6810 | 1371 | 4512 | while ($_) | ||||
6811 | { | ||||||
6812 | 10526 | 44849 | $where->set ("$amfile:$."); | ||||
6813 | |||||||
6814 | # Make sure the line is \n-terminated. | ||||||
6815 | 10526 | 14839 | chomp; | ||||
6816 | 10526 | 12578 | $_ .= "\n"; | ||||
6817 | |||||||
6818 | # Don't look at MAINTAINER_MODE_TRUE here. That shouldn't be | ||||||
6819 | # used by users. @MAINT@ is an anachronism now. | ||||||
6820 | 10526 | 26247 | $_ =~ s/\@MAINT\@//g | ||||
6821 | unless $seen_maint_mode; | ||||||
6822 | |||||||
6823 | 10526 | 22799 | my $new_saw_bk = check_trailing_slash ($where, $_); | ||||
6824 | |||||||
6825 | 10526 | 209165 | if (/$IGNORE_PATTERN/o) | ||||
6826 | { | ||||||
6827 | # Merely delete comments beginning with two hashes. | ||||||
6828 | |||||||
6829 | # Keep any backslash from the previous line. | ||||||
6830 | 96 | 150 | $new_saw_bk = $saw_bk; | ||||
6831 | } | ||||||
6832 | elsif (/$WHITE_PATTERN/o) | ||||||
6833 | { | ||||||
6834 | # Stick a single white line before the incoming macro or rule. | ||||||
6835 | 1008 | 1339 | $spacing = "\n"; | ||||
6836 | 1008 | 2120 | error $where, "blank line following trailing backslash" | ||||
6837 | if $saw_bk; | ||||||
6838 | } | ||||||
6839 | elsif (/$COMMENT_PATTERN/o) | ||||||
6840 | { | ||||||
6841 | 64 | 269 | error $where, "comment following trailing backslash" | ||||
6842 | if $saw_bk && $prev_state != IN_COMMENT; | ||||||
6843 | |||||||
6844 | # Stick comments before the incoming macro or rule. | ||||||
6845 | 64 | 136 | $comment .= $spacing . $_; | ||||
6846 | 64 | 84 | $spacing = ''; | ||||
6847 | 64 | 89 | $prev_state = IN_COMMENT; | ||||
6848 | } | ||||||
6849 | elsif ($saw_bk) | ||||||
6850 | { | ||||||
6851 | 139 | 383 | if ($prev_state == IN_RULE_DEF) | ||||
6852 | { | ||||||
6853 | 69 | 195 | my $cond = new Automake::Condition @cond_stack; | ||||
6854 | 69 | 176 | $output_trailer .= $cond->subst_string; | ||||
6855 | 69 | 127 | $output_trailer .= $_; | ||||
6856 | } | ||||||
6857 | elsif ($prev_state == IN_COMMENT) | ||||||
6858 | { | ||||||
6859 | # If the line doesn't start with a `#', add it. | ||||||
6860 | # We do this because a continued comment like | ||||||
6861 | # # A = foo \ | ||||||
6862 | # bar \ | ||||||
6863 | # baz | ||||||
6864 | # is not portable. BSD make doesn't honor | ||||||
6865 | # escaped newlines in comments. | ||||||
6866 | 6 | 20 | s/^#?/#/; | ||||
6867 | 6 | 15 | $comment .= $spacing . $_; | ||||
6868 | } | ||||||
6869 | else # $prev_state == IN_VAR_DEF | ||||||
6870 | { | ||||||
6871 | 64 | 270 | $last_var_value .= ' ' | ||||
6872 | unless $last_var_value =~ /\s$/; | ||||||
6873 | 64 | 111 | $last_var_value .= $_; | ||||
6874 | |||||||
6875 | 64 | 208 | if (!/\\$/) | ||||
6876 | { | ||||||
6877 | 34 | 178 | Automake::Variable::define ($last_var_name, VAR_MAKEFILE, | ||||
6878 | $last_var_type, $cond, | ||||||
6879 | $last_var_value, $comment, | ||||||
6880 | $last_where, VAR_ASIS) | ||||||
6881 | if $cond != FALSE; | ||||||
6882 | 34 | 77 | $comment = $spacing = ''; | ||||
6883 | } | ||||||
6884 | } | ||||||
6885 | } | ||||||
6886 | |||||||
6887 | elsif (/$IF_PATTERN/o) | ||||||
6888 | { | ||||||
6889 | 178 | 807 | $cond = cond_stack_if ($1, $2, $where); | ||||
6890 | } | ||||||
6891 | elsif (/$ELSE_PATTERN/o) | ||||||
6892 | { | ||||||
6893 | 71 | 359 | $cond = cond_stack_else ($1, $2, $where); | ||||
6894 | } | ||||||
6895 | elsif (/$ENDIF_PATTERN/o) | ||||||
6896 | { | ||||||
6897 | 177 | 559 | $cond = cond_stack_endif ($1, $2, $where); | ||||
6898 | } | ||||||
6899 | |||||||
6900 | elsif (/$RULE_PATTERN/o) | ||||||
6901 | { | ||||||
6902 | # Found a rule. | ||||||
6903 | 886 | 1361 | $prev_state = IN_RULE_DEF; | ||||
6904 | |||||||
6905 | # For now we have to output all definitions of user rules | ||||||
6906 | # and can't diagnose duplicates (see the comment in | ||||||
6907 | # Automake::Rule::define). So we go on and ignore the return value. | ||||||
6908 | 886 | 4876 | Automake::Rule::define ($1, $amfile, RULE_USER, $cond, $where); | ||||
6909 | |||||||
6910 | 886 | 2463 | check_variable_expansions ($_, $where); | ||||
6911 | |||||||
6912 | 886 | 1770 | $output_trailer .= $comment . $spacing; | ||||
6913 | 886 | 2757 | my $cond = new Automake::Condition @cond_stack; | ||||
6914 | 886 | 2723 | $output_trailer .= $cond->subst_string; | ||||
6915 | 886 | 1478 | $output_trailer .= $_; | ||||
6916 | 886 | 1395 | $comment = $spacing = ''; | ||||
6917 | } | ||||||
6918 | elsif (/$ASSIGNMENT_PATTERN/o) | ||||||
6919 | { | ||||||
6920 | # Found a macro definition. | ||||||
6921 | 5350 | 6594 | $prev_state = IN_VAR_DEF; | ||||
6922 | 5350 | 10449 | $last_var_name = $1; | ||||
6923 | 5350 | 7735 | $last_var_type = $2; | ||||
6924 | 5350 | 7618 | $last_var_value = $3; | ||||
6925 | 5350 | 14083 | $last_where = $where->clone; | ||||
6926 | 5350 | 45287 | if ($3 ne '' && substr ($3, -1) eq "\\") | ||||
6927 | { | ||||||
6928 | # We preserve the `\' because otherwise the long lines | ||||||
6929 | # that are generated will be truncated by broken | ||||||
6930 | # `sed's. | ||||||
6931 | 39 | 95 | $last_var_value = $3 . "\n"; | ||||
6932 | } | ||||||
6933 | # Normally we try to output variable definitions in the | ||||||
6934 | # same format they were input. However, POSIX compliant | ||||||
6935 | # systems are not required to support lines longer than | ||||||
6936 | # 2048 bytes (most notably, some sed implementation are | ||||||
6937 | # limited to 4000 bytes, and sed is used by config.status | ||||||
6938 | # to rewrite Makefile.in into Makefile). Moreover nobody | ||||||
6939 | # would really write such long lines by hand since it is | ||||||
6940 | # hardly maintainable. So if a line is longer that 1000 | ||||||
6941 | # bytes (an arbitrary limit), assume it has been | ||||||
6942 | # automatically generated by some tools, and flatten the | ||||||
6943 | # variable definition. Otherwise, keep the variable as it | ||||||
6944 | # as been input. | ||||||
6945 | 5350 | 12062 | $var_look = VAR_PRETTY if length ($last_var_value) >= 1000; | ||||
6946 | |||||||
6947 | 5350 | 13909 | if (!/\\$/) | ||||
6948 | { | ||||||
6949 | 5311 | 22267 | Automake::Variable::define ($last_var_name, VAR_MAKEFILE, | ||||
6950 | $last_var_type, $cond, | ||||||
6951 | $last_var_value, $comment, | ||||||
6952 | $last_where, $var_look) | ||||||
6953 | if $cond != FALSE; | ||||||
6954 | 5311 | 7714 | $comment = $spacing = ''; | ||||
6955 | 5311 | 7160 | $var_look = VAR_ASIS; | ||||
6956 | } | ||||||
6957 | } | ||||||
6958 | elsif (/$INCLUDE_PATTERN/o) | ||||||
6959 | { | ||||||
6960 | 28 | 84 | my $path = $1; | ||||
6961 | |||||||
6962 | 28 | 134 | if ($path =~ s/^\$\(top_srcdir\)\///) | ||||
6963 | { | ||||||
6964 | 3 | 9 | push (@include_stack, "\$\(top_srcdir\)/$path"); | ||||
6965 | # Distribute any included file. | ||||||
6966 | |||||||
6967 | # Always use the $(top_srcdir) prefix in DIST_COMMON, | ||||||
6968 | # otherwise OSF make will implicitly copy the included | ||||||
6969 | # file in the build tree during `make distdir' to satisfy | ||||||
6970 | # the dependency. | ||||||
6971 | # (subdircond2.test and subdircond3.test will fail.) | ||||||
6972 | 3 | 8 | push_dist_common ("\$\(top_srcdir\)/$path"); | ||||
6973 | } | ||||||
6974 | else | ||||||
6975 | { | ||||||
6976 | 25 | 75 | $path =~ s/\$\(srcdir\)\///; | ||||
6977 | 25 | 91 | push (@include_stack, "\$\(srcdir\)/$path"); | ||||
6978 | # Always use the $(srcdir) prefix in DIST_COMMON, | ||||||
6979 | # otherwise OSF make will implicitly copy the included | ||||||
6980 | # file in the build tree during `make distdir' to satisfy | ||||||
6981 | # the dependency. | ||||||
6982 | # (subdircond2.test and subdircond3.test will fail.) | ||||||
6983 | 25 | 109 | push_dist_common ("\$\(srcdir\)/$path"); | ||||
6984 | 25 | 96 | $path = $relative_dir . "/" . $path if $relative_dir ne '.'; | ||||
6985 | } | ||||||
6986 | 28 | 192 | $where->push_context ("`$path' included from here"); | ||||
6987 | 28 | 628 | &read_am_file ($path, $where); | ||||
6988 | 28 | 110 | $where->pop_context; | ||||
6989 | } | ||||||
6990 | else | ||||||
6991 | { | ||||||
6992 | # This isn't an error; it is probably a continued rule. | ||||||
6993 | # In fact, this is what we assume. | ||||||
6994 | 2529 | 3047 | $prev_state = IN_RULE_DEF; | ||||
6995 | 2529 | 6148 | check_variable_expansions ($_, $where); | ||||
6996 | 2529 | 4484 | $output_trailer .= $comment . $spacing; | ||||
6997 | 2529 | 7241 | my $cond = new Automake::Condition @cond_stack; | ||||
6998 | 2529 | 6278 | $output_trailer .= $cond->subst_string; | ||||
6999 | 2529 | 4198 | $output_trailer .= $_; | ||||
7000 | 2529 | 3234 | $comment = $spacing = ''; | ||||
7001 | 2529 | 6625 | error $where, "`#' comment at start of rule is unportable" | ||||
7002 | if $_ =~ /^\t\s*\#/; | ||||||
7003 | } | ||||||
7004 | |||||||
7005 | 10526 | 11648 | $saw_bk = $new_saw_bk; | ||||
7006 | 10526 | 25113 | $_ = $am_file->getline; | ||||
7007 | } | ||||||
7008 | |||||||
7009 | 1371 | 2772 | $output_trailer .= $comment; | ||||
7010 | |||||||
7011 | 1371 | 3772 | error ($where, "trailing backslash on last line") | ||||
7012 | if $saw_bk; | ||||||
7013 | |||||||
7014 | 1371 | 19477 | error ($where, (@cond_stack ? "unterminated conditionals: @cond_stack" | ||||
7015 | : "too many conditionals closed in include file")) | ||||||
7016 | if "@saved_cond_stack" ne "@cond_stack"; | ||||||
7017 | } | ||||||
7018 | |||||||
7019 | |||||||
7020 | # define_standard_variables () | ||||||
7021 | # ---------------------------- | ||||||
7022 | # A helper for read_main_am_file which initializes configure variables | ||||||
7023 | # and variables from header-vars.am. | ||||||
7024 | sub define_standard_variables | ||||||
7025 | { | ||||||
7026 | 1322 | 3458 | my $saved_output_vars = $output_vars; | ||||
7027 | 1322 | 8803 | my ($comments, undef, $rules) = | ||||
7028 | file_contents_internal (1, "$libdir/am/header-vars.am", | ||||||
7029 | new Automake::Location); | ||||||
7030 | |||||||
7031 | 1322 | 69335 | foreach my $var (sort keys %configure_vars) | ||||
7032 | { | ||||||
7033 | 109414 | 178713 | &define_configure_variable ($var); | ||||
7034 | } | ||||||
7035 | |||||||
7036 | 1322 | 8961 | $output_vars .= $comments . $rules; | ||||
7037 | } | ||||||
7038 | |||||||
7039 | # Read main am file. | ||||||
7040 | sub read_main_am_file | ||||||
7041 | { | ||||||
7042 | 1322 | 3463 | my ($amfile) = @_; | ||||
7043 | |||||||
7044 | # This supports the strange variable tricks we are about to play. | ||||||
7045 | 1322 | 4926 | prog_error ("variable defined before read_main_am_file\n" . variables_dump ()) | ||||
7046 | if (scalar (variables) > 0); | ||||||
7047 | |||||||
7048 | # Generate copyright header for generated Makefile.in. | ||||||
7049 | # We do discard the output of predefined variables, handled below. | ||||||
7050 | 1322 | 7813 | $output_vars = ("# $in_file_name generated by automake " | ||||
7051 | . $VERSION . " from $am_file_name.\n"); | ||||||
7052 | 1322 | 5297 | $output_vars .= '# ' . subst ('configure_input') . "\n"; | ||||
7053 | 1322 | 3759 | $output_vars .= $gen_copyright; | ||||
7054 | |||||||
7055 | # We want to predefine as many variables as possible. This lets | ||||||
7056 | # the user set them with `+=' in Makefile.am. | ||||||
7057 | 1322 | 5183 | &define_standard_variables; | ||||
7058 | |||||||
7059 | 1322 | 3466 | my @saved_cond_stack = @cond_stack; | ||||
7060 | 1322 | 5226 | foreach my $frag (@early_fragments) | ||||
7061 | { | ||||||
7062 | 11 | 33 | my ($fragment, $where, $pattern, $cond) = @$frag; | ||||
7063 | 11 | 457 | if ($amfile =~ /$pattern/) | ||||
7064 | { | ||||||
7065 | 10 | 20 | my $file = '$(top_srcdir)/' . $fragment; | ||||
7066 | 10 | 17 | push @include_stack, $file; | ||||
7067 | 10 | 30 | push_dist_common ($file); | ||||
7068 | 10 | 33 | @cond_stack = @$cond | ||||
7069 | if defined $cond; | ||||||
7070 | 10 | 56 | $where->push_context ("`$fragment' prepended to `$amfile'"); | ||||
7071 | 10 | 34 | &read_am_file ($fragment, $where); | ||||
7072 | 10 | 31 | $where->pop_context; | ||||
7073 | } | ||||||
7074 | } | ||||||
7075 | |||||||
7076 | # Read user file, which might override some of our values. | ||||||
7077 | 1322 | 5048 | &read_am_file ($amfile, new Automake::Location); | ||||
7078 | |||||||
7079 | 1322 | 4750 | foreach my $frag (@late_fragments) | ||||
7080 | { | ||||||
7081 | 14 | 39 | my ($fragment, $where, $pattern, $cond) = @$frag; | ||||
7082 | 14 | 100 | if ($amfile =~ /$pattern/) | ||||
7083 | { | ||||||
7084 | 12 | 24 | my $file = '$(top_srcdir)/' . $fragment; | ||||
7085 | 12 | 20 | push @include_stack, $file; | ||||
7086 | 12 | 25 | push_dist_common ($file); | ||||
7087 | 12 | 45 | @cond_stack = @$cond | ||||
7088 | if defined $cond; | ||||||
7089 | 12 | 50 | $where->push_context ("`$fragment' appended to `$amfile'"); | ||||
7090 | 12 | 20 | &read_am_file ($fragment, $where); | ||||
7091 | 11 | 38 | $where->pop_context; | ||||
7092 | } | ||||||
7093 | } | ||||||
7094 | 1321 | 3986 | @cond_stack = @saved_cond_stack; | ||||
7095 | } | ||||||
7096 | |||||||
7097 | |||||||
7098 | |||||||
7099 | ################################################################ | ||||||
7100 | |||||||
7101 | # $FLATTENED | ||||||
7102 | # &flatten ($STRING) | ||||||
7103 | # ------------------ | ||||||
7104 | # Flatten the $STRING and return the result. | ||||||
7105 | sub flatten | ||||||
7106 | { | ||||||
7107 | 213714 | 276873 | $_ = shift; | ||||
7108 | |||||||
7109 | 213714 | 261303 | s/\\\n//somg; | ||||
7110 | 213714 | 310451 | s/\s+/ /g; | ||||
7111 | 213714 | 209667 | s/^ //; | ||||
7112 | 213714 | 203041 | s/ $//; | ||||
7113 | |||||||
7114 | 213714 | 393071 | return $_; | ||||
7115 | } | ||||||
7116 | |||||||
7117 | |||||||
7118 | # transform_token ($TOKEN, \%PAIRS, $KEY) | ||||||
7119 | # ======================================= | ||||||
7120 | # Return the value associated to $KEY in %PAIRS, as used on $TOKEN | ||||||
7121 | # (which should be ?KEY? or any of the special %% requests).. | ||||||
7122 | sub transform_token ($$$) | ||||||
7123 | { | ||||||
7124 | 577311 | 1140507 | my ($token, $transform, $key) = @_; | ||||
7125 | 577311 | 853221 | my $res = $transform->{$key}; | ||||
7126 | 577311 | 1012259 | prog_error "Unknown key `$key' in `$token'" unless defined $res; | ||||
7127 | 577311 | 2496406 | return $res; | ||||
7128 | } | ||||||
7129 | |||||||
7130 | |||||||
7131 | # transform ($TOKEN, \%PAIRS) | ||||||
7132 | # =========================== | ||||||
7133 | # If ($TOKEN, $VAL) is in %PAIRS: | ||||||
7134 | # - replaces %KEY% with $VAL, | ||||||
7135 | # - enables/disables ?KEY? and ?!KEY?, | ||||||
7136 | # - replaces %?KEY% with TRUE or FALSE. | ||||||
7137 | # - replaces %KEY?IFTRUE%, %KEY:IFFALSE%, and %KEY?IFTRUE:IFFALSE% with | ||||||
7138 | # IFTRUE / IFFALSE, as appropriate. | ||||||
7139 | sub transform ($$) | ||||||
7140 | { | ||||||
7141 | 577311 | 1152568 | my ($token, $transform) = @_; | ||||
7142 | |||||||
7143 | # %KEY%. | ||||||
7144 | # Must be before the following pattern to exclude the case | ||||||
7145 | # when there is neither IFTRUE nor IFFALSE. | ||||||
7146 | 577311 | 2349124 | if ($token =~ /^%([\w\-]+)%$/) | ||||
7147 | { | ||||||
7148 | 291798 | 501344 | return transform_token ($token, $transform, $1); | ||||
7149 | } | ||||||
7150 | # %KEY?IFTRUE%, %KEY:IFFALSE%, and %KEY?IFTRUE:IFFALSE%. | ||||||
7151 | elsif ($token =~ /^%([\w\-]+)(?:\?([^?:%]+))?(?::([^?:%]+))?%$/) | ||||||
7152 | { | ||||||
7153 | 3978 | 7919 | return transform_token ($token, $transform, $1) ? ($2 || '') : ($3 || ''); | ||||
7154 | } | ||||||
7155 | # %?KEY%. | ||||||
7156 | elsif ($token =~ /^%\?([\w\-]+)%$/) | ||||||
7157 | { | ||||||
7158 | 139160 | 249049 | return transform_token ($token, $transform, $1) ? 'TRUE' : 'FALSE'; | ||||
7159 | } | ||||||
7160 | # ?KEY? and ?!KEY?. | ||||||
7161 | elsif ($token =~ /^ \? (!?) ([\w\-]+) \? $/x) | ||||||
7162 | { | ||||||
7163 | 142375 | 315707 | my $neg = ($1 eq '!') ? 1 : 0; | ||||
7164 | 142375 | 242964 | my $val = transform_token ($token, $transform, $2); | ||||
7165 | 142375 | 764792 | return (!!$val == $neg) ? '##%' : ''; | ||||
7166 | } | ||||||
7167 | else | ||||||
7168 | { | ||||||
7169 | 0 | 0 | prog_error "Unknown request format: $token"; | ||||
7170 | } | ||||||
7171 | } | ||||||
7172 | |||||||
7173 | |||||||
7174 | # @PARAGRAPHS | ||||||
7175 | # &make_paragraphs ($MAKEFILE, [%TRANSFORM]) | ||||||
7176 | # ------------------------------------------ | ||||||
7177 | # Load a $MAKEFILE, apply the %TRANSFORM, and return it as a list of | ||||||
7178 | # paragraphs. | ||||||
7179 | sub make_paragraphs ($%) | ||||||
7180 | { | ||||||
7181 | 17372 | 68593 | my ($file, %transform) = @_; | ||||
7182 | |||||||
7183 | # Complete %transform with global options. | ||||||
7184 | # Note that %transform goes last, so it overrides global options. | ||||||
7185 | 17372 | 48455 | %transform = ('CYGNUS' => !! option 'cygnus', | ||||
7186 | 'MAINTAINER-MODE' | ||||||
7187 | => $seen_maint_mode ? subst ('MAINTAINER_MODE_TRUE') : '', | ||||||
7188 | |||||||
7189 | 'XZ' => !! option 'dist-xz', | ||||||
7190 | 'LZMA' => !! option 'dist-lzma', | ||||||
7191 | 'LZIP' => !! option 'dist-lzip', | ||||||
7192 | 'BZIP2' => !! option 'dist-bzip2', | ||||||
7193 | 'COMPRESS' => !! option 'dist-tarZ', | ||||||
7194 | 'GZIP' => ! option 'no-dist-gzip', | ||||||
7195 | 'SHAR' => !! option 'dist-shar', | ||||||
7196 | 'ZIP' => !! option 'dist-zip', | ||||||
7197 | |||||||
7198 | 'INSTALL-INFO' => ! option 'no-installinfo', | ||||||
7199 | 'INSTALL-MAN' => ! option 'no-installman', | ||||||
7200 | 'HAVE-MANS' => !! var ('MANS'), | ||||||
7201 | 'CK-NEWS' => !! option 'check-news', | ||||||
7202 | |||||||
7203 | 'SUBDIRS' => !! var ('SUBDIRS'), | ||||||
7204 | 'TOPDIR_P' => $relative_dir eq '.', | ||||||
7205 | |||||||
7206 | 'BUILD' => ($seen_canonical >= AC_CANONICAL_BUILD), | ||||||
7207 | 'HOST' => ($seen_canonical >= AC_CANONICAL_HOST), | ||||||
7208 | 'TARGET' => ($seen_canonical >= AC_CANONICAL_TARGET), | ||||||
7209 | |||||||
7210 | 'LIBTOOL' => !! var ('LIBTOOL'), | ||||||
7211 | 'NONLIBTOOL' => 1, | ||||||
7212 | 'FIRST' => ! $transformed_files{$file}, | ||||||
7213 | %transform); | ||||||
7214 | |||||||
7215 | 17372 | 100608 | $transformed_files{$file} = 1; | ||||
7216 | 17372 | 44218 | $_ = $am_file_cache{$file}; | ||||
7217 | |||||||
7218 | 17372 | 40929 | if (! defined $_) | ||||
7219 | { | ||||||
7220 | 13204 | 47363 | verb "reading $file"; | ||||
7221 | # Swallow the whole file. | ||||||
7222 | 13204 | 85256 | my $fc_file = new Automake::XFile "< $file"; | ||||
7223 | 13204 | 29638 | my $saved_dollar_slash = $/; | ||||
7224 | 13204 | 26843 | undef $/; | ||||
7225 | 13204 | 41470 | $_ = $fc_file->getline; | ||||
7226 | 13204 | 26296 | $/ = $saved_dollar_slash; | ||||
7227 | 13204 | 40034 | $fc_file->close; | ||||
7228 | |||||||
7229 | # Remove ##-comments. | ||||||
7230 | # Besides we don't need more than two consecutive new-lines. | ||||||
7231 | 13204 | 6248778 | s/(?:$IGNORE_PATTERN|(?<=\n\n)\n+)//gom; | ||||
7232 | |||||||
7233 | 13204 | 76474 | $am_file_cache{$file} = $_; | ||||
7234 | } | ||||||
7235 | |||||||
7236 | # Substitute Automake template tokens. | ||||||
7237 | 17372 577311 | 128100 1117114 | s/(?: % \?? [\w\-]+ % | ||||
7238 | | % [\w\-]+ (?:\?[^?:%]+)? (?::[^?:%]+)? % | ||||||
7239 | | \? !? [\w\-]+ \? | ||||||
7240 | )/transform($&, \%transform)/gex; | ||||||
7241 | # transform() may have added some ##%-comments to strip. | ||||||
7242 | # (we use `##%' instead of `##' so we can distinguish ##%##%##% from | ||||||
7243 | # ####### and do not remove the latter.) | ||||||
7244 | 17372 | 3604777 | s/^[ \t]*(?:##%)+.*\n//gm; | ||||
7245 | |||||||
7246 | # Split at unescaped new lines. | ||||||
7247 | 17372 | 598977 | my @lines = split (/(?<!\\)\n/, $_); | ||||
7248 | 17372 | 52462 | my @res; | ||||
7249 | |||||||
7250 | 17372 | 55948 | while (defined ($_ = shift @lines)) | ||||
7251 | { | ||||||
7252 | 609783 | 683496 | my $paragraph = $_; | ||||
7253 | # If we are a rule, eat as long as we start with a tab. | ||||||
7254 | 609783 | 1926865 | if (/$RULE_PATTERN/smo) | ||||
7255 | { | ||||||
7256 | 213714 | 1229660 | while (defined ($_ = shift @lines) && $_ =~ /^\t/) | ||||
7257 | { | ||||||
7258 | 129632 | 795188 | $paragraph .= "\n$_"; | ||||
7259 | } | ||||||
7260 | 213714 | 358066 | unshift (@lines, $_); | ||||
7261 | } | ||||||
7262 | |||||||
7263 | # If we are a comments, eat as much comments as you can. | ||||||
7264 | elsif (/$COMMENT_PATTERN/smo) | ||||||
7265 | { | ||||||
7266 | 3472 | 41994 | while (defined ($_ = shift @lines) | ||||
7267 | && $_ =~ /$COMMENT_PATTERN/smo) | ||||||
7268 | { | ||||||
7269 | 5802 | 40210 | $paragraph .= "\n$_"; | ||||
7270 | } | ||||||
7271 | 3472 | 6973 | unshift (@lines, $_); | ||||
7272 | } | ||||||
7273 | |||||||
7274 | 609783 | 1627876 | push @res, $paragraph; | ||||
7275 | } | ||||||
7276 | |||||||
7277 | 17372 | 263534 | return @res; | ||||
7278 | } | ||||||
7279 | |||||||
7280 | |||||||
7281 | |||||||
7282 | # ($COMMENT, $VARIABLES, $RULES) | ||||||
7283 | # &file_contents_internal ($IS_AM, $FILE, $WHERE, [%TRANSFORM]) | ||||||
7284 | # ------------------------------------------------------------- | ||||||
7285 | # Return contents of a file from $libdir/am, automatically skipping | ||||||
7286 | # macros or rules which are already known. $IS_AM iff the caller is | ||||||
7287 | # reading an Automake file (as opposed to the user's Makefile.am). | ||||||
7288 | sub file_contents_internal ($$$%) | ||||||
7289 | { | ||||||
7290 | 17372 | 72213 | my ($is_am, $file, $where, %transform) = @_; | ||||
7291 | |||||||
7292 | 17372 | 45811 | $where->set ($file); | ||||
7293 | |||||||
7294 | 17372 | 21011 | my $result_vars = ''; | ||||
7295 | 17372 | 19620 | my $result_rules = ''; | ||||
7296 | 17372 | 19243 | my $comment = ''; | ||||
7297 | 17372 | 18763 | my $spacing = ''; | ||||
7298 | |||||||
7299 | # The following flags are used to track rules spanning across | ||||||
7300 | # multiple paragraphs. | ||||||
7301 | 17372 | 19248 | my $is_rule = 0; # 1 if we are processing a rule. | ||||
7302 | 17372 | 19244 | my $discard_rule = 0; # 1 if the current rule should not be output. | ||||
7303 | |||||||
7304 | # We save the conditional stack on entry, and then check to make | ||||||
7305 | # sure it is the same on exit. This lets us conditionally include | ||||||
7306 | # other files. | ||||||
7307 | 17372 | 27314 | my @saved_cond_stack = @cond_stack; | ||||
7308 | 17372 | 57649 | my $cond = new Automake::Condition (@cond_stack); | ||||
7309 | |||||||
7310 | 17372 | 62265 | foreach (make_paragraphs ($file, %transform)) | ||||
7311 | { | ||||||
7312 | # FIXME: no line number available. | ||||||
7313 | 609783 | 1451976 | $where->set ($file); | ||||
7314 | |||||||
7315 | # Sanity checks. | ||||||
7316 | 609783 | 1166615 | error $where, "blank line following trailing backslash:\n$_" | ||||
7317 | if /\\$/; | ||||||
7318 | 609783 | 1019710 | error $where, "comment following trailing backslash:\n$_" | ||||
7319 | if /\\#/; | ||||||
7320 | |||||||
7321 | 609783 | 4581111 | if (/^$/) | ||||
7322 | { | ||||||
7323 | 125380 | 129470 | $is_rule = 0; | ||||
7324 | # Stick empty line before the incoming macro or rule. | ||||||
7325 | 125380 | 186632 | $spacing = "\n"; | ||||
7326 | } | ||||||
7327 | elsif (/$COMMENT_PATTERN/mso) | ||||||
7328 | { | ||||||
7329 | 3472 | 4722 | $is_rule = 0; | ||||
7330 | # Stick comments before the incoming macro or rule. | ||||||
7331 | 3472 | 7489 | $comment = "$_\n"; | ||||
7332 | } | ||||||
7333 | |||||||
7334 | # Handle inclusion of other files. | ||||||
7335 | elsif (/$INCLUDE_PATTERN/o) | ||||||
7336 | { | ||||||
7337 | 2735 | 8913 | if ($cond != FALSE) | ||||
7338 | { | ||||||
7339 | 1323 | 5768 | my $file = ($is_am ? "$libdir/am/" : '') . $1; | ||||
7340 | 1323 | 5069 | $where->push_context ("`$file' included from here"); | ||||
7341 | # N-ary `.=' fails. | ||||||
7342 | 1323 | 12671 | my ($com, $vars, $rules) | ||||
7343 | = file_contents_internal ($is_am, $file, $where, %transform); | ||||||
7344 | 1323 | 4838 | $where->pop_context; | ||||
7345 | 1323 | 2198 | $comment .= $com; | ||||
7346 | 1323 | 1466 | $result_vars .= $vars; | ||||
7347 | 1323 | 2599 | $result_rules .= $rules; | ||||
7348 | } | ||||||
7349 | } | ||||||
7350 | |||||||
7351 | # Handling the conditionals. | ||||||
7352 | elsif (/$IF_PATTERN/o) | ||||||
7353 | { | ||||||
7354 | 69104 | 139214 | $cond = cond_stack_if ($1, $2, $file); | ||||
7355 | } | ||||||
7356 | elsif (/$ELSE_PATTERN/o) | ||||||
7357 | { | ||||||
7358 | 13983 | 32408 | $cond = cond_stack_else ($1, $2, $file); | ||||
7359 | } | ||||||
7360 | elsif (/$ENDIF_PATTERN/o) | ||||||
7361 | { | ||||||
7362 | 69104 | 133265 | $cond = cond_stack_endif ($1, $2, $file); | ||||
7363 | } | ||||||
7364 | |||||||
7365 | # Handling rules. | ||||||
7366 | elsif (/$RULE_PATTERN/mso) | ||||||
7367 | { | ||||||
7368 | 213714 | 234957 | $is_rule = 1; | ||||
7369 | 213714 | 209793 | $discard_rule = 0; | ||||
7370 | # Separate relationship from optional actions: the first | ||||||
7371 | # `new-line tab" not preceded by backslash (continuation | ||||||
7372 | # line). | ||||||
7373 | 213714 | 251389 | my $paragraph = $_; | ||||
7374 | 213714 | 1349246 | /^(.*?)(?:(?<!\\)\n(\t.*))?$/s; | ||||
7375 | 213714 | 1101517 | my ($relationship, $actions) = ($1, $2 || ''); | ||||
7376 | |||||||
7377 | # Separate targets from dependencies: the first colon. | ||||||
7378 | 213714 | 681163 | $relationship =~ /^([^:]+\S+) *: *(.*)$/som; | ||||
7379 | 213714 | 432005 | my ($targets, $dependencies) = ($1, $2); | ||||
7380 | # Remove the escaped new lines. | ||||||
7381 | # I don't know why, but I have to use a tmp $flat_deps. | ||||||
7382 | 213714 | 370240 | my $flat_deps = &flatten ($dependencies); | ||||
7383 | 213714 | 502302 | my @deps = split (' ', $flat_deps); | ||||
7384 | |||||||
7385 | 213714 | 467382 | foreach (split (' ', $targets)) | ||||
7386 | { | ||||||
7387 | # FIXME: 1. We are not robust to people defining several targets | ||||||
7388 | # at once, only some of them being in %dependencies. The | ||||||
7389 | # actions from the targets in %dependencies are usually generated | ||||||
7390 | # from the content of %actions, but if some targets in $targets | ||||||
7391 | # are not in %dependencies the ELSE branch will output | ||||||
7392 | # a rule for all $targets (i.e. the targets which are both | ||||||
7393 | # in %dependencies and $targets will have two rules). | ||||||
7394 | |||||||
7395 | # FIXME: 2. The logic here is not able to output a | ||||||
7396 | # multi-paragraph rule several time (e.g. for each condition | ||||||
7397 | # it is defined for) because it only knows the first paragraph. | ||||||
7398 | |||||||
7399 | # FIXME: 3. We are not robust to people defining a subset | ||||||
7400 | # of a previously defined "multiple-target" rule. E.g. | ||||||
7401 | # `foo:' after `foo bar:'. | ||||||
7402 | |||||||
7403 | # Output only if not in FALSE. | ||||||
7404 | 221280 | 956343 | if (defined $dependencies{$_} && $cond != FALSE) | ||||
7405 | { | ||||||
7406 | 91646 | 225207 | &depend ($_, @deps); | ||||
7407 | 91646 | 206405 | register_action ($_, $actions); | ||||
7408 | } | ||||||
7409 | else | ||||||
7410 | { | ||||||
7411 | # Free-lance dependency. Output the rule for all the | ||||||
7412 | # targets instead of one by one. | ||||||
7413 | 129634 | 420792 | my @undefined_conds = | ||||
7414 | Automake::Rule::define ($targets, $file, | ||||||
7415 | $is_am ? RULE_AUTOMAKE : RULE_USER, | ||||||
7416 | $cond, $where); | ||||||
7417 | 129634 | 206492 | for my $undefined_cond (@undefined_conds) | ||||
7418 | { | ||||||
7419 | 59773 | 83214 | my $condparagraph = $paragraph; | ||||
7420 | 59773 314378 | 196205 681596 | $condparagraph =~ s/^/$undefined_cond->subst_string/gme; | ||||
7421 | 59773 | 236494 | $result_rules .= "$spacing$comment$condparagraph\n"; | ||||
7422 | } | ||||||
7423 | 129634 | 269861 | if (scalar @undefined_conds == 0) | ||||
7424 | { | ||||||
7425 | # Remember to discard next paragraphs | ||||||
7426 | # if they belong to this rule. | ||||||
7427 | # (but see also FIXME: #2 above.) | ||||||
7428 | 69862 | 84983 | $discard_rule = 1; | ||||
7429 | } | ||||||
7430 | 129634 | 172799 | $comment = $spacing = ''; | ||||
7431 | 129634 | 261937 | last; | ||||
7432 | } | ||||||
7433 | } | ||||||
7434 | } | ||||||
7435 | |||||||
7436 | elsif (/$ASSIGNMENT_PATTERN/mso) | ||||||
7437 | { | ||||||
7438 | 80624 | 245951 | my ($var, $type, $val) = ($1, $2, $3); | ||||
7439 | 80624 | 160841 | error $where, "variable `$var' with trailing backslash" | ||||
7440 | if /\\$/; | ||||||
7441 | |||||||
7442 | 80624 | 84111 | $is_rule = 0; | ||||
7443 | |||||||
7444 | 80624 | 276380 | Automake::Variable::define ($var, | ||||
7445 | $is_am ? VAR_AUTOMAKE : VAR_MAKEFILE, | ||||||
7446 | $type, $cond, $val, $comment, $where, | ||||||
7447 | VAR_ASIS) | ||||||
7448 | if $cond != FALSE; | ||||||
7449 | |||||||
7450 | 80624 | 155023 | $comment = $spacing = ''; | ||||
7451 | } | ||||||
7452 | else | ||||||
7453 | { | ||||||
7454 | # This isn't an error; it is probably some tokens which | ||||||
7455 | # configure is supposed to replace, such as `@SET-MAKE@', | ||||||
7456 | # or some part of a rule cut by an if/endif. | ||||||
7457 | 31667 | 76042 | if (! $cond->false && ! ($is_rule && $discard_rule)) | ||||
7458 | { | ||||||
7459 | 14969 72985 | 48846 159300 | s/^/$cond->subst_string/gme; | ||||
7460 | 14969 | 41849 | $result_rules .= "$spacing$comment$_\n"; | ||||
7461 | } | ||||||
7462 | 31667 | 61896 | $comment = $spacing = ''; | ||||
7463 | } | ||||||
7464 | } | ||||||
7465 | |||||||
7466 | 17372 | 110609 | error ($where, @cond_stack ? | ||||
7467 | "unterminated conditionals: @cond_stack" : | ||||||
7468 | "too many conditionals closed in include file") | ||||||
7469 | if "@saved_cond_stack" ne "@cond_stack"; | ||||||
7470 | |||||||
7471 | 17372 | 102581 | return ($comment, $result_vars, $result_rules); | ||||
7472 | } | ||||||
7473 | |||||||
7474 | |||||||
7475 | # $CONTENTS | ||||||
7476 | # &file_contents ($BASENAME, $WHERE, [%TRANSFORM]) | ||||||
7477 | # ------------------------------------------------ | ||||||
7478 | # Return contents of a file from $libdir/am, automatically skipping | ||||||
7479 | # macros or rules which are already known. | ||||||
7480 | sub file_contents ($$%) | ||||||
7481 | { | ||||||
7482 | 14727 | 89049 | my ($basename, $where, %transform) = @_; | ||||
7483 | 14727 | 75731 | my ($comments, $variables, $rules) = | ||||
7484 | file_contents_internal (1, "$libdir/am/$basename.am", $where, | ||||||
7485 | %transform); | ||||||
7486 | 14727 | 149801 | return "$comments$variables$rules"; | ||||
7487 | } | ||||||
7488 | |||||||
7489 | |||||||
7490 | # @PREFIX | ||||||
7491 | # &am_primary_prefixes ($PRIMARY, $CAN_DIST, @PREFIXES) | ||||||
7492 | # ----------------------------------------------------- | ||||||
7493 | # Find all variable prefixes that are used for install directories. A | ||||||
7494 | # prefix `zar' qualifies iff: | ||||||
7495 | # | ||||||
7496 | # * `zardir' is a variable. | ||||||
7497 | # * `zar_PRIMARY' is a variable. | ||||||
7498 | # | ||||||
7499 | # As a side effect, it looks for misspellings. It is an error to have | ||||||
7500 | # a variable ending in a "reserved" suffix whose prefix is unknown, e.g. | ||||||
7501 | # "bni_PROGRAMS". However, unusual prefixes are allowed if a variable | ||||||
7502 | # of the same name (with "dir" appended) exists. For instance, if the | ||||||
7503 | # variable "zardir" is defined, then "zar_PROGRAMS" becomes valid. | ||||||
7504 | # This is to provide a little extra flexibility in those cases which | ||||||
7505 | # need it. | ||||||
7506 | sub am_primary_prefixes ($$@) | ||||||
7507 | { | ||||||
7508 | 12112 | 30919 | my ($primary, $can_dist, @prefixes) = @_; | ||||
7509 | |||||||
7510 | 12112 | 13305 | local $_; | ||||
7511 | 12112 58993 | 17756 123143 | my %valid = map { $_ => 0 } @prefixes; | ||||
7512 | 12112 | 26965 | $valid{'EXTRA'} = 0; | ||||
7513 | 12112 | 32152 | foreach my $var (variables $primary) | ||||
7514 | { | ||||||
7515 | # Automake is allowed to define variables that look like primaries | ||||||
7516 | # but which aren't. E.g. INSTALL_sh_DATA. | ||||||
7517 | # Autoconf can also define variables like INSTALL_DATA, so | ||||||
7518 | # ignore all configure variables (at least those which are not | ||||||
7519 | # redefined in Makefile.am). | ||||||
7520 | # FIXME: We should make sure that these variables are not | ||||||
7521 | # conditionally defined (or else adjust the condition below). | ||||||
7522 | 4708 | 14212 | my $def = $var->def (TRUE); | ||||
7523 | 4708 | 25171 | next if $def && $def->owner != VAR_MAKEFILE; | ||||
7524 | |||||||
7525 | 2067 | 5386 | my $varname = $var->name; | ||||
7526 | |||||||
7527 | 2067 | 12863 | if ($varname =~ /^(nobase_)?(dist_|nodist_)?(.*)_[[:alnum:]]+$/) | ||||
7528 | { | ||||||
7529 | 2067 | 24412 | my ($base, $dist, $X) = ($1 || '', $2 || '', $3 || ''); | ||||
7530 | 2067 | 23404 | if ($dist ne '' && ! $can_dist) | ||||
7531 | { | ||||||
7532 | 2 | 9 | err_var ($var, | ||||
7533 | "invalid variable `$varname': `dist' is forbidden"); | ||||||
7534 | } | ||||||
7535 | # Standard directories must be explicitly allowed. | ||||||
7536 | elsif (! defined $valid{$X} && exists $standard_prefix{$X}) | ||||||
7537 | { | ||||||
7538 | 2 | 15 | err_var ($var, | ||||
7539 | "`${X}dir' is not a legitimate directory " . | ||||||
7540 | "for `$primary'"); | ||||||
7541 | } | ||||||
7542 | # A not explicitly valid directory is allowed if Xdir is defined. | ||||||
7543 | elsif (! defined $valid{$X} && | ||||||
7544 | $var->requires_variables ("`$varname' is used", "${X}dir")) | ||||||
7545 | { | ||||||
7546 | # Nothing to do. Any error message has been output | ||||||
7547 | # by $var->requires_variables. | ||||||
7548 | } | ||||||
7549 | else | ||||||
7550 | { | ||||||
7551 | # Ensure all extended prefixes are actually used. | ||||||
7552 | 2056 | 7863 | $valid{"$base$dist$X"} = 1; | ||||
7553 | } | ||||||
7554 | } | ||||||
7555 | else | ||||||
7556 | { | ||||||
7557 | 0 | 0 | prog_error "unexpected variable name: $varname"; | ||||
7558 | } | ||||||
7559 | } | ||||||
7560 | |||||||
7561 | # Return only those which are actually defined. | ||||||
7562 | 12112 72354 | 33029 174253 | return sort grep { var ($_ . '_' . $primary) } keys %valid; | ||||
7563 | } | ||||||
7564 | |||||||
7565 | |||||||
7566 | # Handle `where_HOW' variable magic. Does all lookups, generates | ||||||
7567 | # install code, and possibly generates code to define the primary | ||||||
7568 | # variable. The first argument is the name of the .am file to munge, | ||||||
7569 | # the second argument is the primary variable (e.g. HEADERS), and all | ||||||
7570 | # subsequent arguments are possible installation locations. | ||||||
7571 | # | ||||||
7572 | # Returns list of [$location, $value] pairs, where | ||||||
7573 | # $value's are the values in all where_HOW variable, and $location | ||||||
7574 | # there associated location (the place here their parent variables were | ||||||
7575 | # defined). | ||||||
7576 | # | ||||||
7577 | # FIXME: this should be rewritten to be cleaner. It should be broken | ||||||
7578 | # up into multiple functions. | ||||||
7579 | # | ||||||
7580 | # Usage is: am_install_var (OPTION..., file, HOW, where...) | ||||||
7581 | sub am_install_var | ||||||
7582 | { | ||||||
7583 | 11871 | 37787 | my (@args) = @_; | ||||
7584 | |||||||
7585 | 11871 | 13886 | my $do_require = 1; | ||||
7586 | 11871 | 12144 | my $can_dist = 0; | ||||
7587 | 11871 | 12319 | my $default_dist = 0; | ||||
7588 | 11871 | 24239 | while (@args) | ||||
7589 | { | ||||||
7590 | 21104 | 82887 | if ($args[0] eq '-noextra') | ||||
7591 | { | ||||||
7592 | 1319 | 1989 | $do_require = 0; | ||||
7593 | } | ||||||
7594 | elsif ($args[0] eq '-candist') | ||||||
7595 | { | ||||||
7596 | 5276 | 7272 | $can_dist = 1; | ||||
7597 | } | ||||||
7598 | elsif ($args[0] eq '-defaultdist') | ||||||
7599 | { | ||||||
7600 | 2638 | 3221 | $default_dist = 1; | ||||
7601 | 2638 | 3585 | $can_dist = 1; | ||||
7602 | } | ||||||
7603 | elsif ($args[0] !~ /^-/) | ||||||
7604 | { | ||||||
7605 | 11871 | 13502 | last; | ||||
7606 | } | ||||||
7607 | 9233 | 19447 | shift (@args); | ||||
7608 | } | ||||||
7609 | |||||||
7610 | 11871 | 30238 | my ($file, $primary, @prefix) = @args; | ||||
7611 | |||||||
7612 | # Now that configure substitutions are allowed in where_HOW | ||||||
7613 | # variables, it is an error to actually define the primary. We | ||||||
7614 | # allow `JAVA', as it is customarily used to mean the Java | ||||||
7615 | # interpreter. This is but one of several Java hacks. Similarly, | ||||||
7616 | # `PYTHON' is customarily used to mean the Python interpreter. | ||||||
7617 | 11871 | 83499 | reject_var $primary, "`$primary' is an anachronism" | ||||
7618 | unless $primary eq 'JAVA' || $primary eq 'PYTHON'; | ||||||
7619 | |||||||
7620 | # Get the prefixes which are valid and actually used. | ||||||
7621 | 11871 | 28278 | @prefix = am_primary_prefixes ($primary, $can_dist, @prefix); | ||||
7622 | |||||||
7623 | # If a primary includes a configure substitution, then the EXTRA_ | ||||||
7624 | # form is required. Otherwise we can't properly do our job. | ||||||
7625 | 11871 | 18036 | my $require_extra; | ||||
7626 | |||||||
7627 | 11871 | 13834 | my @used = (); | ||||
7628 | 11871 | 13701 | my @result = (); | ||||
7629 | |||||||
7630 | 11871 | 22735 | foreach my $X (@prefix) | ||||
7631 | { | ||||||
7632 | 1700 | 2860 | my $nodir_name = $X; | ||||
7633 | 1700 | 3636 | my $one_name = $X . '_' . $primary; | ||||
7634 | 1700 | 4257 | my $one_var = var $one_name; | ||||
7635 | |||||||
7636 | 1700 | 2591 | my $strip_subdir = 1; | ||||
7637 | # If subdir prefix should be preserved, do so. | ||||||
7638 | 1700 | 6231 | if ($nodir_name =~ /^nobase_/) | ||||
7639 | { | ||||||
7640 | 517 | 753 | $strip_subdir = 0; | ||||
7641 | 517 | 1429 | $nodir_name =~ s/^nobase_//; | ||||
7642 | } | ||||||
7643 | |||||||
7644 | # If files should be distributed, do so. | ||||||
7645 | 1700 | 2341 | my $dist_p = 0; | ||||
7646 | 1700 | 4029 | if ($can_dist) | ||||
7647 | { | ||||||
7648 | 748 | 7030 | $dist_p = (($default_dist && $nodir_name !~ /^nodist_/) | ||||
7649 | || (! $default_dist && $nodir_name =~ /^dist_/)); | ||||||
7650 | 748 | 2277 | $nodir_name =~ s/^(dist|nodist)_//; | ||||
7651 | } | ||||||
7652 | |||||||
7653 | |||||||
7654 | # Use the location of the currently processed variable. | ||||||
7655 | # We are not processing a particular condition, so pick the first | ||||||
7656 | # available. | ||||||
7657 | 1700 | 5171 | my $tmpcond = $one_var->conditions->one_cond; | ||||
7658 | 1700 | 5565 | my $where = $one_var->rdef ($tmpcond)->location->clone; | ||||
7659 | |||||||
7660 | # Append actual contents of where_PRIMARY variable to | ||||||
7661 | # @result, skipping @substitutions@. | ||||||
7662 | 1700 | 7259 | foreach my $locvals ($one_var->value_as_list_recursive (location => 1)) | ||||
7663 | { | ||||||
7664 | 2638 | 4748 | my ($loc, $value) = @$locvals; | ||||
7665 | # Skip configure substitutions. | ||||||
7666 | 2638 | 6999 | if ($value =~ /^\@.*\@$/) | ||||
7667 | { | ||||||
7668 | 31 | 140 | if ($nodir_name eq 'EXTRA') | ||||
7669 | { | ||||||
7670 | 2 | 17 | error ($where, | ||||
7671 | "`$one_name' contains configure substitution, " | ||||||
7672 | . "but shouldn't"); | ||||||
7673 | } | ||||||
7674 | # Check here to make sure variables defined in | ||||||
7675 | # configure.ac do not imply that EXTRA_PRIMARY | ||||||
7676 | # must be defined. | ||||||
7677 | elsif (! defined $configure_vars{$one_name}) | ||||||
7678 | { | ||||||
7679 | 28 | 142 | $require_extra = $one_name | ||||
7680 | if $do_require; | ||||||
7681 | } | ||||||
7682 | } | ||||||
7683 | else | ||||||
7684 | { | ||||||
7685 | # Strip any $(EXEEXT) suffix the user might have added, or this | ||||||
7686 | # will confuse &handle_source_transform and &check_canonical_spelling. | ||||||
7687 | # We'll add $(EXEEXT) back later anyway. | ||||||
7688 | # Do it here rather than in handle_programs so the uniquifying at the | ||||||
7689 | # end of this function works. | ||||||
7690 | 2607 742 | 6254 2162 | ${$locvals}[1] =~ s/\$\(EXEEXT\)$// | ||||
7691 | if $primary eq 'PROGRAMS'; | ||||||
7692 | |||||||
7693 | 2607 | 5953 | push (@result, $locvals); | ||||
7694 | } | ||||||
7695 | } | ||||||
7696 | # A blatant hack: we rewrite each _PROGRAMS primary to include | ||||||
7697 | # EXEEXT. | ||||||
7698 | 1700 736 | 17777 3927 | append_exeext { 1 } $one_name | ||||
7699 | if $primary eq 'PROGRAMS'; | ||||||
7700 | # "EXTRA" shouldn't be used when generating clean targets, | ||||||
7701 | # all, or install targets. We used to warn if EXTRA_FOO was | ||||||
7702 | # defined uselessly, but this was annoying. | ||||||
7703 | next | ||||||
7704 | 1700 | 6663 | if $nodir_name eq 'EXTRA'; | ||||
7705 | |||||||
7706 | 1677 | 3997 | if ($nodir_name eq 'check') | ||||
7707 | { | ||||||
7708 | 64 | 209 | push (@check, '$(' . $one_name . ')'); | ||||
7709 | } | ||||||
7710 | else | ||||||
7711 | { | ||||||
7712 | 1613 | 4851 | push (@used, '$(' . $one_name . ')'); | ||||
7713 | } | ||||||
7714 | |||||||
7715 | # Is this to be installed? | ||||||
7716 | 1677 | 8964 | my $install_p = $nodir_name ne 'noinst' && $nodir_name ne 'check'; | ||||
7717 | |||||||
7718 | # If so, with install-exec? (or install-data?). | ||||||
7719 | 1677 | 27965 | my $exec_p = ($nodir_name =~ /$EXEC_DIR_PATTERN/o); | ||||
7720 | |||||||
7721 | 1677 | 9696 | my $check_options_p = $install_p && !! option 'std-options'; | ||||
7722 | |||||||
7723 | # Use the location of the currently processed variable as context. | ||||||
7724 | 1677 | 8137 | $where->push_context ("while processing `$one_name'"); | ||||
7725 | |||||||
7726 | # The variable containing all files to distribute. | ||||||
7727 | 1677 | 3580 | my $distvar = "\$($one_name)"; | ||||
7728 | 1677 | 11492 | $distvar = shadow_unconditionally ($one_name, $where) | ||||
7729 | if ($dist_p && $one_var->has_conditional_contents); | ||||||
7730 | |||||||
7731 | # Singular form of $PRIMARY. | ||||||
7732 | 1677 | 6516 | (my $one_primary = $primary) =~ s/S$//; | ||||
7733 | 1677 | 6719 | $output_rules .= &file_contents ($file, $where, | ||||
7734 | PRIMARY => $primary, | ||||||
7735 | ONE_PRIMARY => $one_primary, | ||||||
7736 | DIR => $X, | ||||||
7737 | NDIR => $nodir_name, | ||||||
7738 | BASE => $strip_subdir, | ||||||
7739 | |||||||
7740 | EXEC => $exec_p, | ||||||
7741 | INSTALL => $install_p, | ||||||
7742 | DIST => $dist_p, | ||||||
7743 | DISTVAR => $distvar, | ||||||
7744 | 'CK-OPTS' => $check_options_p); | ||||||
7745 | } | ||||||
7746 | |||||||
7747 | # The JAVA variable is used as the name of the Java interpreter. | ||||||
7748 | # The PYTHON variable is used as the name of the Python interpreter. | ||||||
7749 | 11871 | 52046 | if (@used && $primary ne 'JAVA' && $primary ne 'PYTHON') | ||||
7750 | { | ||||||
7751 | # Define it. | ||||||
7752 | 1057 | 3588 | define_pretty_variable ($primary, TRUE, INTERNAL, @used); | ||||
7753 | } | ||||||
7754 | |||||||
7755 | 11871 | 33620 | err_var ($require_extra, | ||||
7756 | "`$require_extra' contains configure substitution,\n" | ||||||
7757 | . "but `EXTRA_$primary' not defined") | ||||||
7758 | if ($require_extra && ! var ('EXTRA_' . $primary)); | ||||||
7759 | |||||||
7760 | # Push here because PRIMARY might be configure time determined. | ||||||
7761 | 11871 | 53303 | push (@all, '$(' . $primary . ')') | ||||
7762 | if @used && $primary ne 'JAVA' && $primary ne 'PYTHON'; | ||||||
7763 | |||||||
7764 | # Make the result unique. This lets the user use conditionals in | ||||||
7765 | # a natural way, but still lets us program lazily -- we don't have | ||||||
7766 | # to worry about handling a particular object more than once. | ||||||
7767 | # We will keep only one location per object. | ||||||
7768 | 11871 | 17811 | my %result = (); | ||||
7769 | 11871 | 19367 | for my $pair (@result) | ||||
7770 | { | ||||||
7771 | 2607 | 4654 | my ($loc, $val) = @$pair; | ||||
7772 | 2607 | 6215 | $result{$val} = $loc; | ||||
7773 | } | ||||||
7774 | 11871 | 30348 | my @l = sort keys %result; | ||||
7775 | 11871 2583 | 32186 7692 | return map { [$result{$_}->clone, $_] } @l; | ||||
7776 | } | ||||||
7777 | |||||||
7778 | |||||||
7779 | ################################################################ | ||||||
7780 | |||||||
7781 | # Each key in this hash is the name of a directory holding a | ||||||
7782 | # Makefile.in. These variables are local to `is_make_dir'. | ||||||
7783 | 1159 | 2401 | my %make_dirs = (); | ||||
7784 | 1159 | 1990 | my $make_dirs_set = 0; | ||||
7785 | |||||||
7786 | sub is_make_dir | ||||||
7787 | { | ||||||
7788 | 4898 | 285186 | my ($dir) = @_; | ||||
7789 | 4898 | 12001 | if (! $make_dirs_set) | ||||
7790 | { | ||||||
7791 | 1127 | 4107 | foreach my $iter (@configure_input_files) | ||||
7792 | { | ||||||
7793 | 1323 | 43723 | $make_dirs{dirname ($iter)} = 1; | ||||
7794 | } | ||||||
7795 | # We also want to notice Makefile.in's. | ||||||
7796 | 1127 | 178833 | foreach my $iter (@other_input_files) | ||||
7797 | { | ||||||
7798 | 88 | 329 | if ($iter =~ /Makefile\.in$/) | ||||
7799 | { | ||||||
7800 | 0 | 0 | $make_dirs{dirname ($iter)} = 1; | ||||
7801 | } | ||||||
7802 | } | ||||||
7803 | 1127 | 2255 | $make_dirs_set = 1; | ||||
7804 | } | ||||||
7805 | 4898 | 21291 | return defined $make_dirs{$dir}; | ||||
7806 | } | ||||||
7807 | |||||||
7808 | ################################################################ | ||||||
7809 | |||||||
7810 | # Find the aux dir. This should match the algorithm used by | ||||||
7811 | # ./configure. (See the Autoconf documentation for for | ||||||
7812 | # AC_CONFIG_AUX_DIR.) | ||||||
7813 | sub locate_aux_dir () | ||||||
7814 | { | ||||||
7815 | 1127 | 4133 | if (! $config_aux_dir_set_in_configure_ac) | ||||
7816 | { | ||||||
7817 | # The default auxiliary directory is the first | ||||||
7818 | # of ., .., or ../.. that contains install-sh. | ||||||
7819 | # Assume . if install-sh doesn't exist yet. | ||||||
7820 | 1107 | 5128 | for my $dir (qw (. .. ../..)) | ||||
7821 | { | ||||||
7822 | 1149 | 14872 | if (-f "$dir/install-sh") | ||||
7823 | { | ||||||
7824 | 1089 | 3291 | $config_aux_dir = $dir; | ||||
7825 | 1089 | 2851 | last; | ||||
7826 | } | ||||||
7827 | } | ||||||
7828 | 1107 | 3537 | $config_aux_dir = '.' unless $config_aux_dir; | ||||
7829 | } | ||||||
7830 | # Avoid unsightly '/.'s. | ||||||
7831 | $am_config_aux_dir = | ||||||
7832 | 1127 | 6582 | '$(top_srcdir)' . ($config_aux_dir eq '.' ? "" : "/$config_aux_dir"); | ||||
7833 | 1127 | 16718 | $am_config_aux_dir =~ s,/*$,,; | ||||
7834 | } | ||||||
7835 | |||||||
7836 | |||||||
7837 | # &maybe_push_required_file ($DIR, $FILE, $FULLFILE) | ||||||
7838 | # -------------------------------------------------- | ||||||
7839 | # See if we want to push this file onto dist_common. This function | ||||||
7840 | # encodes the rules for deciding when to do so. | ||||||
7841 | sub maybe_push_required_file | ||||||
7842 | { | ||||||
7843 | 3643 | 50051 | my ($dir, $file, $fullfile) = @_; | ||||
7844 | |||||||
7845 | 3643 | 8769 | if ($dir eq $relative_dir) | ||||
7846 | { | ||||||
7847 | 3489 | 11725 | push_dist_common ($file); | ||||
7848 | 3489 | 6724 | return 1; | ||||
7849 | } | ||||||
7850 | elsif ($relative_dir eq '.' && ! &is_make_dir ($dir)) | ||||||
7851 | { | ||||||
7852 | # If we are doing the topmost directory, and the file is in a | ||||||
7853 | # subdir which does not have a Makefile, then we distribute it | ||||||
7854 | # here. | ||||||
7855 | |||||||
7856 | # If a required file is above the source tree, it is important | ||||||
7857 | # to prefix it with `$(srcdir)' so that no VPATH search is | ||||||
7858 | # performed. Otherwise problems occur with Make implementations | ||||||
7859 | # that rewrite and simplify rules whose dependencies are found in a | ||||||
7860 | # VPATH location. Here is an example with OSF1/Tru64 Make. | ||||||
7861 | # | ||||||
7862 | # % cat Makefile | ||||||
7863 | # VPATH = sub | ||||||
7864 | # distdir: ../a | ||||||
7865 | # echo ../a | ||||||
7866 | # % ls | ||||||
7867 | # Makefile a | ||||||
7868 | # % make | ||||||
7869 | # echo a | ||||||
7870 | # a | ||||||
7871 | # | ||||||
7872 | # Dependency `../a' was found in `sub/../a', but this make | ||||||
7873 | # implementation simplified it as `a'. (Note that the sub/ | ||||||
7874 | # directory does not even exist.) | ||||||
7875 | # | ||||||
7876 | # This kind of VPATH rewriting seems hard to cancel. The | ||||||
7877 | # distdir.am hack against VPATH rewriting works only when no | ||||||
7878 | # simplification is done, i.e., for dependencies which are in | ||||||
7879 | # subdirectories, not in enclosing directories. Hence, in | ||||||
7880 | # the latter case we use a full path to make sure no VPATH | ||||||
7881 | # search occurs. | ||||||
7882 | 40 | 161 | $fullfile = '$(srcdir)/' . $fullfile | ||||
7883 | if $dir =~ m,^\.\.(?:$|/),; | ||||||
7884 | |||||||
7885 | 40 | 168 | push_dist_common ($fullfile); | ||||
7886 | 40 | 98 | return 1; | ||||
7887 | } | ||||||
7888 | 114 | 256 | return 0; | ||||
7889 | } | ||||||
7890 | |||||||
7891 | |||||||
7892 | # If a file name appears as a key in this hash, then it has already | ||||||
7893 | # been checked for. This allows us not to report the same error more | ||||||
7894 | # than once. | ||||||
7895 | 1159 | 2303 | my %required_file_not_found = (); | ||||
7896 | |||||||
7897 | # &require_file_internal ($WHERE, $MYSTRICT, $DIRECTORY, @FILES) | ||||||
7898 | # -------------------------------------------------------------- | ||||||
7899 | # Verify that the file must exist in $DIRECTORY, or install it. | ||||||
7900 | # $MYSTRICT is the strictness level at which this file becomes required. | ||||||
7901 | sub require_file_internal ($$$@) | ||||||
7902 | { | ||||||
7903 | 6616 | 18497 | my ($where, $mystrict, $dir, @files) = @_; | ||||
7904 | |||||||
7905 | 6616 | 12855 | foreach my $file (@files) | ||||
7906 | { | ||||||
7907 | 11032 | 21169 | my $fullfile = "$dir/$file"; | ||||
7908 | 11032 | 12240 | my $found_it = 0; | ||||
7909 | 11032 | 12273 | my $dangling_sym = 0; | ||||
7910 | 11032 | 27086 | if ($file =~ /\//) | ||||
7911 | { | ||||||
7912 | 0 | 0 | $dir = (($dir eq '') ? '' : (($dir eq '.') ? '' : $dir . '/' )) . dirname ($file); | ||||
7913 | 0 | 0 | $file = basename ($file); | ||||
7914 | } | ||||||
7915 | |||||||
7916 | 11032 | 126624 | if (-l $fullfile && ! -f $fullfile) | ||||
7917 | { | ||||||
7918 | 1 | 3 | $dangling_sym = 1; | ||||
7919 | } | ||||||
7920 | elsif (dir_has_case_matching_file ($dir, $file)) | ||||||
7921 | { | ||||||
7922 | 3297 | 4691 | $found_it = 1; | ||||
7923 | 3297 | 10809 | maybe_push_required_file ($dir, $file, $fullfile); | ||||
7924 | } | ||||||
7925 | |||||||
7926 | # `--force-missing' only has an effect if `--add-missing' is | ||||||
7927 | # specified. | ||||||
7928 | 11032 | 44591 | if ($found_it && (! $add_missing || ! $force_missing)) | ||||
7929 | { | ||||||
7930 | 3269 | 12475 | next; | ||||
7931 | } | ||||||
7932 | else | ||||||
7933 | { | ||||||
7934 | # If we've already looked for it, we're done. You might | ||||||
7935 | # wonder why we don't do this before searching for the | ||||||
7936 | # file. If we do that, then something like | ||||||
7937 | # AC_OUTPUT(subdir/foo foo) will fail to put foo.in into | ||||||
7938 | # DIST_COMMON. | ||||||
7939 | 7763 | 15667 | if (! $found_it) | ||||
7940 | { | ||||||
7941 | 7735 | 16642 | next if defined $required_file_not_found{$fullfile}; | ||||
7942 | 7735 | 16403 | $required_file_not_found{$fullfile} = 1; | ||||
7943 | } | ||||||
7944 | |||||||
7945 | 7763 | 24990 | if ($strictness >= $mystrict) | ||||
7946 | { | ||||||
7947 | 363 | 1226 | if ($dangling_sym && $add_missing) | ||||
7948 | { | ||||||
7949 | 1 | 26 | unlink ($fullfile); | ||||
7950 | } | ||||||
7951 | |||||||
7952 | 363 | 649 | my $trailer = ''; | ||||
7953 | 363 | 583 | my $trailer2 = ''; | ||||
7954 | 363 | 510 | my $suppress = 0; | ||||
7955 | |||||||
7956 | # Only install missing files according to our desired | ||||||
7957 | # strictness level. | ||||||
7958 | 363 | 941 | my $message = "required file `$fullfile' not found"; | ||||
7959 | 363 | 943 | if ($add_missing) | ||||
7960 | { | ||||||
7961 | 346 | 5354 | if (-f "$libdir/$file") | ||||
7962 | { | ||||||
7963 | 330 | 502 | $suppress = 1; | ||||
7964 | |||||||
7965 | # Install the missing file. Symlink if we | ||||||
7966 | # can, copy if we must. Note: delete the file | ||||||
7967 | # first, in case it is a dangling symlink. | ||||||
7968 | 330 | 758 | $message = "installing `$fullfile'"; | ||||
7969 | |||||||
7970 | # The license file should not be volatile. | ||||||
7971 | 330 | 836 | if ($file eq "COPYING") | ||||
7972 | { | ||||||
7973 | 6 | 13 | $message .= " using GNU General Public License v3 file"; | ||||
7974 | 6 | 10 | $trailer2 = "\n Consider adding the COPYING file" | ||||
7975 | . " to the version control system" | ||||||
7976 | . "\n for your code, to avoid questions" | ||||||
7977 | . " about which license your project uses"; | ||||||
7978 | } | ||||||
7979 | |||||||
7980 | # Windows Perl will hang if we try to delete a | ||||||
7981 | # file that doesn't exist. | ||||||
7982 | 330 | 1887 | unlink ($fullfile) if -f $fullfile; | ||||
7983 | 330 | 152938 | if ($symlink_exists && ! $copy_missing) | ||||
7984 | { | ||||||
7985 | 278 | 57000 | if (! symlink ("$libdir/$file", $fullfile) | ||||
7986 | || ! -e $fullfile) | ||||||
7987 | { | ||||||
7988 | 2 | 2 | $suppress = 0; | ||||
7989 | 2 | 25 | $trailer = "; error while making link: $!"; | ||||
7990 | } | ||||||
7991 | } | ||||||
7992 | elsif (system ('cp', "$libdir/$file", $fullfile)) | ||||||
7993 | { | ||||||
7994 | 0 | 0 | $suppress = 0; | ||||
7995 | 0 | 0 | $trailer = "\n error while copying"; | ||||
7996 | } | ||||||
7997 | 330 | 2748 | set_dir_cache_file ($dir, $file); | ||||
7998 | } | ||||||
7999 | |||||||
8000 | 346 | 1454 | if (! maybe_push_required_file (dirname ($fullfile), | ||||
8001 | $file, $fullfile)) | ||||||
8002 | { | ||||||
8003 | 21 | 187 | if (! $found_it && ! $automake_will_process_aux_dir) | ||||
8004 | { | ||||||
8005 | # We have added the file but could not push it | ||||||
8006 | # into DIST_COMMON, probably because this is | ||||||
8007 | # an auxiliary file and we are not processing | ||||||
8008 | # the top level Makefile. Furthermore Automake | ||||||
8009 | # hasn't been asked to create the Makefile.in | ||||||
8010 | # that distributes the aux dir files. | ||||||
8011 | 1 | 7 | error ($where, 'please rerun automake without ' | ||||
8012 | . "Makefile arguments\n" | ||||||
8013 | . "so $fullfile gets distributed"); | ||||||
8014 | } | ||||||
8015 | } | ||||||
8016 | } | ||||||
8017 | else | ||||||
8018 | { | ||||||
8019 | 17 | 322 | $trailer = "\n `automake --add-missing' can install `$file'" | ||||
8020 | if -f "$libdir/$file"; | ||||||
8021 | } | ||||||
8022 | |||||||
8023 | # If --force-missing was specified, and we have | ||||||
8024 | # actually found the file, then do nothing. | ||||||
8025 | next | ||||||
8026 | 363 | 1595 | if $found_it && $force_missing; | ||||
8027 | |||||||
8028 | # If we couldn't install the file, but it is a target in | ||||||
8029 | # the Makefile, don't print anything. This allows files | ||||||
8030 | # like README, AUTHORS, or THANKS to be generated. | ||||||
8031 | next | ||||||
8032 | 335 | 1307 | if !$suppress && rule $file; | ||||
8033 | |||||||
8034 | 334 | 2144 | msg ($suppress ? 'note' : 'error', $where, "$message$trailer$trailer2"); | ||||
8035 | } | ||||||
8036 | } | ||||||
8037 | } | ||||||
8038 | } | ||||||
8039 | |||||||
8040 | # &require_file ($WHERE, $MYSTRICT, @FILES) | ||||||
8041 | # ----------------------------------------- | ||||||
8042 | sub require_file ($$@) | ||||||
8043 | { | ||||||
8044 | 3409 | 10091 | my ($where, $mystrict, @files) = @_; | ||||
8045 | 3409 | 8138 | require_file_internal ($where, $mystrict, $relative_dir, @files); | ||||
8046 | } | ||||||
8047 | |||||||
8048 | # &require_file_with_macro ($COND, $MACRO, $MYSTRICT, @FILES) | ||||||
8049 | # ----------------------------------------------------------- | ||||||
8050 | sub require_file_with_macro ($$$@) | ||||||
8051 | { | ||||||
8052 | 67 | 221 | my ($cond, $macro, $mystrict, @files) = @_; | ||||
8053 | 67 | 270 | $macro = rvar ($macro) unless ref $macro; | ||||
8054 | 67 | 223 | require_file ($macro->rdef ($cond)->location, $mystrict, @files); | ||||
8055 | } | ||||||
8056 | |||||||
8057 | # &require_libsource_with_macro ($COND, $MACRO, $MYSTRICT, @FILES) | ||||||
8058 | # ---------------------------------------------------------------- | ||||||
8059 | # Require an AC_LIBSOURCEd file. If AC_CONFIG_LIBOBJ_DIR was called, it | ||||||
8060 | # must be in that directory. Otherwise expect it in the current directory. | ||||||
8061 | sub require_libsource_with_macro ($$$@) | ||||||
8062 | { | ||||||
8063 | 82 | 256 | my ($cond, $macro, $mystrict, @files) = @_; | ||||
8064 | 82 | 261 | $macro = rvar ($macro) unless ref $macro; | ||||
8065 | 82 | 356 | if ($config_libobj_dir) | ||||
8066 | { | ||||||
8067 | 30 | 107 | require_file_internal ($macro->rdef ($cond)->location, $mystrict, | ||||
8068 | $config_libobj_dir, @files); | ||||||
8069 | } | ||||||
8070 | else | ||||||
8071 | { | ||||||
8072 | 52 | 156 | require_file ($macro->rdef ($cond)->location, $mystrict, @files); | ||||
8073 | } | ||||||
8074 | } | ||||||
8075 | |||||||
8076 | # Queue to push require_conf_file requirements to. | ||||||
8077 | 1159 | 1693 | my $required_conf_file_queue; | ||||
8078 | |||||||
8079 | # &queue_required_conf_file ($QUEUE, $KEY, $DIR, $WHERE, $MYSTRICT, @FILES) | ||||||
8080 | # ------------------------------------------------------------------------- | ||||||
8081 | sub queue_required_conf_file ($$$$@) | ||||||
8082 | { | ||||||
8083 | 0 | 0 | my ($queue, $key, $dir, $where, $mystrict, @files) = @_; | ||||
8084 | 0 | 0 | my @serial_loc; | ||||
8085 | 0 | 0 | if (ref $where) | ||||
8086 | { | ||||||
8087 | 0 | 0 | @serial_loc = (QUEUE_LOCATION, $where->serialize ()); | ||||
8088 | } | ||||||
8089 | else | ||||||
8090 | { | ||||||
8091 | 0 | 0 | @serial_loc = (QUEUE_STRING, $where); | ||||
8092 | } | ||||||
8093 | 0 | 0 | $queue->enqueue ($key, $dir, @serial_loc, $mystrict, 0 + @files, @files); | ||||
8094 | } | ||||||
8095 | |||||||
8096 | # &require_queued_conf_file ($QUEUE) | ||||||
8097 | # ---------------------------------- | ||||||
8098 | sub require_queued_conf_file ($) | ||||||
8099 | { | ||||||
8100 | 0 | 0 | my ($queue) = @_; | ||||
8101 | 0 | 0 | my $where; | ||||
8102 | 0 | 0 | my $dir = $queue->dequeue (); | ||||
8103 | 0 | 0 | my $loc_key = $queue->dequeue (); | ||||
8104 | 0 | 0 | if ($loc_key eq QUEUE_LOCATION) | ||||
8105 | { | ||||||
8106 | 0 | 0 | $where = Automake::Location::deserialize ($queue); | ||||
8107 | } | ||||||
8108 | elsif ($loc_key eq QUEUE_STRING) | ||||||
8109 | { | ||||||
8110 | 0 | 0 | $where = $queue->dequeue (); | ||||
8111 | } | ||||||
8112 | else | ||||||
8113 | { | ||||||
8114 | 0 | 0 | prog_error "unexpected key $loc_key"; | ||||
8115 | } | ||||||
8116 | 0 | 0 | my $mystrict = $queue->dequeue (); | ||||
8117 | 0 | 0 | my $nfiles = $queue->dequeue (); | ||||
8118 | 0 | 0 | my @files; | ||||
8119 | push @files, $queue->dequeue () | ||||||
8120 | 0 0 | 0 0 | foreach (1 .. $nfiles); | ||||
8121 | |||||||
8122 | # Dequeuing happens outside of per-makefile context, so we have to | ||||||
8123 | # set the variables used by require_file_internal and the functions | ||||||
8124 | # it calls. Gross! | ||||||
8125 | 0 | 0 | $relative_dir = $dir; | ||||
8126 | 0 | 0 | require_file_internal ($where, $mystrict, $config_aux_dir, @files); | ||||
8127 | } | ||||||
8128 | |||||||
8129 | # &require_conf_file ($WHERE, $MYSTRICT, @FILES) | ||||||
8130 | # ---------------------------------------------- | ||||||
8131 | # Looks in configuration path, as specified by AC_CONFIG_AUX_DIR; | ||||||
8132 | # worker threads may queue up the action to be serialized by the master. | ||||||
8133 | # | ||||||
8134 | # FIXME: this seriously relies on the semantics of require_file_internal | ||||||
8135 | # and maybe_push_required_file, in that we exploit the fact that only the | ||||||
8136 | # contents of the last handled output file may be impacted (which in turn | ||||||
8137 | # is dealt with by the master thread). | ||||||
8138 | sub require_conf_file ($$@) | ||||||
8139 | { | ||||||
8140 | 3177 | 9486 | my ($where, $mystrict, @files) = @_; | ||||
8141 | 3177 | 7807 | if (defined $required_conf_file_queue) | ||||
8142 | { | ||||||
8143 | 0 | 0 | queue_required_conf_file ($required_conf_file_queue, QUEUE_CONF_FILE, | ||||
8144 | $relative_dir, $where, $mystrict, @files); | ||||||
8145 | } | ||||||
8146 | else | ||||||
8147 | { | ||||||
8148 | 3177 | 12832 | require_file_internal ($where, $mystrict, $config_aux_dir, @files); | ||||
8149 | } | ||||||
8150 | } | ||||||
8151 | |||||||
8152 | |||||||
8153 | # &require_conf_file_with_macro ($COND, $MACRO, $MYSTRICT, @FILES) | ||||||
8154 | # ---------------------------------------------------------------- | ||||||
8155 | sub require_conf_file_with_macro ($$$@) | ||||||
8156 | { | ||||||
8157 | 3 | 10 | my ($cond, $macro, $mystrict, @files) = @_; | ||||
8158 | 3 | 9 | require_conf_file (rvar ($macro)->rdef ($cond)->location, | ||||
8159 | $mystrict, @files); | ||||||
8160 | } | ||||||
8161 | |||||||
8162 | ################################################################ | ||||||
8163 | |||||||
8164 | # &require_build_directory ($DIRECTORY) | ||||||
8165 | # ------------------------------------- | ||||||
8166 | # Emit rules to create $DIRECTORY if needed, and return | ||||||
8167 | # the file that any target requiring this directory should be made | ||||||
8168 | # dependent upon. | ||||||
8169 | # We don't want to emit the rule twice, and want to reuse it | ||||||
8170 | # for directories with equivalent names (e.g., `foo/bar' and `./foo//bar'). | ||||||
8171 | sub require_build_directory ($) | ||||||
8172 | { | ||||||
8173 | 536 | 1119 | my $directory = shift; | ||||
8174 | |||||||
8175 | 536 | 2271 | return $directory_map{$directory} if exists $directory_map{$directory}; | ||||
8176 | |||||||
8177 | 200 | 1502 | my $cdir = File::Spec->canonpath ($directory); | ||||
8178 | |||||||
8179 | 200 | 7513 | if (exists $directory_map{$cdir}) | ||||
8180 | { | ||||||
8181 | 2 | 3 | my $stamp = $directory_map{$cdir}; | ||||
8182 | 2 | 3 | $directory_map{$directory} = $stamp; | ||||
8183 | 2 | 4 | return $stamp; | ||||
8184 | } | ||||||
8185 | |||||||
8186 | 198 | 457 | my $dirstamp = "$cdir/\$(am__dirstamp)"; | ||||
8187 | |||||||
8188 | 198 | 473 | $directory_map{$directory} = $dirstamp; | ||||
8189 | 198 | 317 | $directory_map{$cdir} = $dirstamp; | ||||
8190 | |||||||
8191 | # Set a variable for the dirstamp basename. | ||||||
8192 | 198 | 520 | define_pretty_variable ('am__dirstamp', TRUE, INTERNAL, | ||||
8193 | '$(am__leading_dot)dirstamp'); | ||||||
8194 | |||||||
8195 | # Directory must be removed by `make distclean'. | ||||||
8196 | 198 | 588 | $clean_files{$dirstamp} = DIST_CLEAN; | ||||
8197 | |||||||
8198 | 198 | 1874 | $output_rules .= ("$dirstamp:\n" | ||||
8199 | . "\t\@\$(MKDIR_P) $directory\n" | ||||||
8200 | . "\t\@: > $dirstamp\n"); | ||||||
8201 | |||||||
8202 | 198 | 566 | return $dirstamp; | ||||
8203 | } | ||||||
8204 | |||||||
8205 | # &require_build_directory_maybe ($FILE) | ||||||
8206 | # -------------------------------------- | ||||||
8207 | # If $FILE lies in a subdirectory, emit a rule to create this | ||||||
8208 | # directory and return the file that $FILE should be made | ||||||
8209 | # dependent upon. Otherwise, just return the empty string. | ||||||
8210 | sub require_build_directory_maybe ($) | ||||||
8211 | { | ||||||
8212 | 1180 | 2612 | my $file = shift; | ||||
8213 | 1180 | 3098 | my $directory = dirname ($file); | ||||
8214 | |||||||
8215 | 1180 | 116729 | if ($directory ne '.') | ||||
8216 | { | ||||||
8217 | 444 | 1395 | return require_build_directory ($directory); | ||||
8218 | } | ||||||
8219 | else | ||||||
8220 | { | ||||||
8221 | 736 | 1855 | return ''; | ||||
8222 | } | ||||||
8223 | } | ||||||
8224 | |||||||
8225 | ################################################################ | ||||||
8226 | |||||||
8227 | # Push a list of files onto dist_common. | ||||||
8228 | sub push_dist_common | ||||||
8229 | { | ||||||
8230 | 9528 | 19509 | prog_error "push_dist_common run after handle_dist" | ||||
8231 | if $handle_dist_run; | ||||||
8232 | 9528 | 46912 | Automake::Variable::define ('DIST_COMMON', VAR_AUTOMAKE, '+', TRUE, "@_", | ||||
8233 | '', INTERNAL, VAR_PRETTY); | ||||||
8234 | } | ||||||
8235 | |||||||
8236 | |||||||
8237 | ################################################################ | ||||||
8238 | |||||||
8239 | # generate_makefile ($MAKEFILE_AM, $MAKEFILE_IN) | ||||||
8240 | # ---------------------------------------------- | ||||||
8241 | # Generate a Makefile.in given the name of the corresponding Makefile and | ||||||
8242 | # the name of the file output by config.status. | ||||||
8243 | sub generate_makefile ($$) | ||||||
8244 | { | ||||||
8245 | 1322 | 3433 | my ($makefile_am, $makefile_in) = @_; | ||||
8246 | |||||||
8247 | # Reset all the Makefile.am related variables. | ||||||
8248 | 1322 | 6974 | initialize_per_input; | ||||
8249 | |||||||
8250 | # AUTOMAKE_OPTIONS can contains -W flags to disable or enable | ||||||
8251 | # warnings for this file. So hold any warning issued before | ||||||
8252 | # we have processed AUTOMAKE_OPTIONS. | ||||||
8253 | 1322 | 7079 | buffer_messages ('warning'); | ||||
8254 | |||||||
8255 | # Name of input file ("Makefile.am") and output file | ||||||
8256 | # ("Makefile.in"). These have no directory components. | ||||||
8257 | 1322 | 6992 | $am_file_name = basename ($makefile_am); | ||||
8258 | 1322 | 3678 | $in_file_name = basename ($makefile_in); | ||||
8259 | |||||||
8260 | # $OUTPUT is encoded. If it contains a ":" then the first element | ||||||
8261 | # is the real output file, and all remaining elements are input | ||||||
8262 | # files. We don't scan or otherwise deal with these input files, | ||||||
8263 | # other than to mark them as dependencies. See | ||||||
8264 | # &scan_autoconf_files for details. | ||||||
8265 | 1322 | 8681 | my ($makefile, @inputs) = split (/:/, $output_files{$makefile_in}); | ||||
8266 | |||||||
8267 | 1322 | 4360 | $relative_dir = dirname ($makefile); | ||||
8268 | 1322 | 130178 | $am_relative_dir = dirname ($makefile_am); | ||||
8269 | 1322 | 125713 | $topsrcdir = backname ($relative_dir); | ||||
8270 | |||||||
8271 | 1322 | 9838 | read_main_am_file ($makefile_am); | ||||
8272 | 1321 | 8450 | if (handle_options) | ||||
8273 | { | ||||||
8274 | # Process buffered warnings. | ||||||
8275 | 2 | 8 | flush_messages; | ||||
8276 | # Fatal error. Just return, so we can continue with next file. | ||||||
8277 | 2 | 6 | return; | ||||
8278 | } | ||||||
8279 | # Process buffered warnings. | ||||||
8280 | 1319 | 5349 | flush_messages; | ||||
8281 | |||||||
8282 | # There are a few install-related variables that you should not define. | ||||||
8283 | 1319 | 5424 | foreach my $var ('PRE_INSTALL', 'POST_INSTALL', 'NORMAL_INSTALL') | ||||
8284 | { | ||||||
8285 | 3957 | 9023 | my $v = var $var; | ||||
8286 | 3957 | 8647 | if ($v) | ||||
8287 | { | ||||||
8288 | 3957 | 10466 | my $def = $v->def (TRUE); | ||||
8289 | 3957 | 8349 | prog_error "$var not defined in condition TRUE" | ||||
8290 | unless $def; | ||||||
8291 | 3957 | 11035 | reject_var $var, "`$var' should not be defined" | ||||
8292 | if $def->owner != VAR_AUTOMAKE; | ||||||
8293 | } | ||||||
8294 | } | ||||||
8295 | |||||||
8296 | # Catch some obsolete variables. | ||||||
8297 | 1319 | 4781 | msg_var ('obsolete', 'INCLUDES', | ||||
8298 | "`INCLUDES' is the old name for `AM_CPPFLAGS' (or `*_CPPFLAGS')") | ||||||
8299 | if var ('INCLUDES'); | ||||||
8300 | |||||||
8301 | # Must do this after reading .am file. | ||||||
8302 | 1319 | 6340 | define_variable ('subdir', $relative_dir, INTERNAL); | ||||
8303 | |||||||
8304 | # If DIST_SUBDIRS is defined, make sure SUBDIRS is, so that | ||||||
8305 | # recursive rules are enabled. | ||||||
8306 | 1319 | 4479 | define_pretty_variable ('SUBDIRS', TRUE, INTERNAL, '') | ||||
8307 | if var 'DIST_SUBDIRS' && ! var 'SUBDIRS'; | ||||||
8308 | |||||||
8309 | # Check first, because we might modify some state. | ||||||
8310 | 1319 | 6153 | check_cygnus; | ||||
8311 | 1319 | 4506 | check_gnu_standards; | ||||
8312 | 1319 | 4068 | check_gnits_standards; | ||||
8313 | |||||||
8314 | 1319 | 11438 | handle_configure ($makefile_am, $makefile_in, $makefile, @inputs); | ||||
8315 | 1319 | 4853 | handle_gettext; | ||||
8316 | 1319 | 8613 | handle_libraries; | ||||
8317 | 1319 | 6938 | handle_ltlibraries; | ||||
8318 | 1319 | 5718 | handle_programs; | ||||
8319 | 1319 | 6888 | handle_scripts; | ||||
8320 | |||||||
8321 | # These must be run after all the sources are scanned. They | ||||||
8322 | # use variables defined by &handle_libraries, &handle_ltlibraries, | ||||||
8323 | # or &handle_programs. | ||||||
8324 | 1319 | 5520 | handle_compile; | ||||
8325 | 1319 | 5634 | handle_languages; | ||||
8326 | 1319 | 5805 | handle_libtool; | ||||
8327 | |||||||
8328 | # Variables used by distdir.am and tags.am. | ||||||
8329 | 1319 | 4626 | define_pretty_variable ('SOURCES', TRUE, INTERNAL, @sources); | ||||
8330 | 1319 | 4846 | if (! option 'no-dist') | ||||
8331 | { | ||||||
8332 | 1308 | 3825 | define_pretty_variable ('DIST_SOURCES', TRUE, INTERNAL, @dist_sources); | ||||
8333 | } | ||||||
8334 | |||||||
8335 | 1319 | 7260 | handle_multilib; | ||||
8336 | 1319 | 6452 | handle_texinfo; | ||||
8337 | 1319 | 9392 | handle_emacs_lisp; | ||||
8338 | 1319 | 5540 | handle_python; | ||||
8339 | 1319 | 4279 | handle_java; | ||||
8340 | 1319 | 5902 | handle_man_pages; | ||||
8341 | 1319 | 4912 | handle_data; | ||||
8342 | 1319 | 5897 | handle_headers; | ||||
8343 | 1319 | 5141 | handle_subdirs; | ||||
8344 | 1319 | 4053 | handle_tags; | ||||
8345 | 1319 | 4878 | handle_minor_options; | ||||
8346 | # Must come after handle_programs so that %known_programs is up-to-date. | ||||||
8347 | 1319 | 6896 | handle_tests ($makefile); | ||||
8348 | |||||||
8349 | # This must come after most other rules. | ||||||
8350 | 1319 | 5605 | handle_dist; | ||||
8351 | |||||||
8352 | 1319 | 9464 | handle_footer; | ||||
8353 | 1319 | 9964 | do_check_merge_target; | ||||
8354 | 1319 | 6704 | handle_all ($makefile); | ||||
8355 | |||||||
8356 | # FIXME: Gross! | ||||||
8357 | 1319 | 4866 | if (var ('lib_LTLIBRARIES') && var ('bin_PROGRAMS')) | ||||
8358 | { | ||||||
8359 | 12 | 33 | $output_rules .= "install-binPROGRAMS: install-libLTLIBRARIES\n\n"; | ||||
8360 | } | ||||||
8361 | 1319 | 4186 | if (var ('nobase_lib_LTLIBRARIES') && var ('bin_PROGRAMS')) | ||||
8362 | { | ||||||
8363 | 3 | 7 | $output_rules .= "install-binPROGRAMS: install-nobase_libLTLIBRARIES\n\n"; | ||||
8364 | } | ||||||
8365 | |||||||
8366 | 1319 | 3707 | handle_install; | ||||
8367 | 1319 | 10335 | handle_clean ($makefile); | ||||
8368 | 1319 | 7403 | handle_factored_dependencies; | ||||
8369 | |||||||
8370 | # Comes last, because all the above procedures may have | ||||||
8371 | # defined or overridden variables. | ||||||
8372 | 1319 | 8597 | $output_vars .= output_variables; | ||||
8373 | |||||||
8374 | 1319 | 6157 | check_typos; | ||||
8375 | |||||||
8376 | 1319 | 6828 | my ($out_file) = $output_directory . '/' . $makefile_in; | ||||
8377 | |||||||
8378 | 1319 | 5026 | if ($exit_code != 0) | ||||
8379 | { | ||||||
8380 | 201 | 1090 | verb "not writing $out_file because of earlier errors"; | ||||
8381 | 201 | 747 | return; | ||||
8382 | } | ||||||
8383 | |||||||
8384 | 1118 | 13397 | if (! -d ($output_directory . '/' . $am_relative_dir)) | ||||
8385 | { | ||||||
8386 | 0 | 0 | mkdir ($output_directory . '/' . $am_relative_dir, 0755); | ||||
8387 | } | ||||||
8388 | |||||||
8389 | # We make sure that `all:' is the first target. | ||||||
8390 | 1118 | 36721 | my $output = | ||||
8391 | "$output_vars$output_all$output_header$output_rules$output_trailer"; | ||||||
8392 | |||||||
8393 | # Decide whether we must update the output file or not. | ||||||
8394 | # We have to update in the following situations. | ||||||
8395 | # * $force_generation is set. | ||||||
8396 | # * any of the output dependencies is younger than the output | ||||||
8397 | # * the contents of the output is different (this can happen | ||||||
8398 | # if the project has been populated with a file listed in | ||||||
8399 | # @common_files since the last run). | ||||||
8400 | # Output's dependencies are split in two sets: | ||||||
8401 | # * dependencies which are also configure dependencies | ||||||
8402 | # These do not change between each Makefile.am | ||||||
8403 | # * other dependencies, specific to the Makefile.am being processed | ||||||
8404 | # (such as the Makefile.am itself, or any Makefile fragment | ||||||
8405 | # it includes). | ||||||
8406 | 1118 | 5761 | my $timestamp = mtime $out_file; | ||||
8407 | 1118 | 7688 | if (! $force_generation | ||||
8408 | && $configure_deps_greatest_timestamp < $timestamp | ||||||
8409 | && $output_deps_greatest_timestamp < $timestamp | ||||||
8410 | && $output eq contents ($out_file)) | ||||||
8411 | { | ||||||
8412 | 5 | 22 | verb "$out_file unchanged"; | ||||
8413 | # No need to update. | ||||||
8414 | 5 | 19 | return; | ||||
8415 | } | ||||||
8416 | |||||||
8417 | 1113 | 4897 | if (-e $out_file) | ||||
8418 | { | ||||||
8419 | 180 | 14708 | unlink ($out_file) | ||||
8420 | or fatal "cannot remove $out_file: $!"; | ||||||
8421 | } | ||||||
8422 | |||||||
8423 | 1113 | 9806 | my $gm_file = new Automake::XFile "> $out_file"; | ||||
8424 | 1113 | 6367 | verb "creating $out_file"; | ||||
8425 | 1113 | 101879 | print $gm_file $output; | ||||
8426 | } | ||||||
8427 | |||||||
8428 | ################################################################ | ||||||
8429 | |||||||
8430 | |||||||
8431 | |||||||
8432 | |||||||
8433 | ################################################################ | ||||||
8434 | |||||||
8435 | # Print usage information. | ||||||
8436 | sub usage () | ||||||
8437 | { | ||||||
8438 | 7 | 1830 | print "Usage: $0 [OPTION]... [Makefile]... | ||||
8439 | |||||||
8440 | Generate Makefile.in for configure from Makefile.am. | ||||||
8441 | |||||||
8442 | Operation modes: | ||||||
8443 | --help print this help, then exit | ||||||
8444 | --version print version number, then exit | ||||||
8445 | -v, --verbose verbosely list files processed | ||||||
8446 | --no-force only update Makefile.in's that are out of date | ||||||
8447 | -W, --warnings=CATEGORY report the warnings falling in CATEGORY | ||||||
8448 | |||||||
8449 | Dependency tracking: | ||||||
8450 | -i, --ignore-deps disable dependency tracking code | ||||||
8451 | --include-deps enable dependency tracking code | ||||||
8452 | |||||||
8453 | Flavors: | ||||||
8454 | --cygnus assume program is part of Cygnus-style tree | ||||||
8455 | --foreign set strictness to foreign | ||||||
8456 | --gnits set strictness to gnits | ||||||
8457 | --gnu set strictness to gnu | ||||||
8458 | |||||||
8459 | Library files: | ||||||
8460 | -a, --add-missing add missing standard files to package | ||||||
8461 | --libdir=DIR directory storing library files | ||||||
8462 | -c, --copy with -a, copy missing files (default is symlink) | ||||||
8463 | -f, --force-missing force update of standard files | ||||||
8464 | |||||||
8465 | "; | ||||||
8466 | 7 | 29 | Automake::ChannelDefs::usage; | ||||
8467 | |||||||
8468 | 7 | 10 | my ($last, @lcomm); | ||||
8469 | 7 | 15 | $last = ''; | ||||
8470 | 7 | 106 | foreach my $iter (sort ((@common_files, @common_sometimes))) | ||||
8471 | { | ||||||
8472 | 322 | 686 | push (@lcomm, $iter) unless $iter eq $last; | ||||
8473 | 322 | 392 | $last = $iter; | ||||
8474 | } | ||||||
8475 | |||||||
8476 | 7 | 11 | my @four; | ||||
8477 | 7 | 16 | print "\nFiles which are automatically distributed, if found:\n"; | ||||
8478 | format USAGE_FORMAT = | ||||||
8479 | @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<< | ||||||
8480 | $four[0], $four[1], $four[2], $four[3] | ||||||
8481 | . | ||||||
8482 | 7 | 94 | $~ = "USAGE_FORMAT"; | ||||
8483 | |||||||
8484 | 7 | 9 | my $cols = 4; | ||||
8485 | 7 | 25 | my $rows = int(@lcomm / $cols); | ||||
8486 | 7 | 21 | my $rest = @lcomm % $cols; | ||||
8487 | |||||||
8488 | 7 | 20 | if ($rest) | ||||
8489 | { | ||||||
8490 | 0 | 0 | $rows++; | ||||
8491 | } | ||||||
8492 | else | ||||||
8493 | { | ||||||
8494 | 7 | 18 | $rest = $cols; | ||||
8495 | } | ||||||
8496 | |||||||
8497 | for (my $y = 0; $y < $rows; $y++) | ||||||
8498 | { | ||||||
8499 | 77 | 176 | @four = ("", "", "", ""); | ||||
8500 | for (my $x = 0; $x < $cols; $x++) | ||||||
8501 | { | ||||||
8502 | 308 | 883 | last if $y + 1 == $rows && $x == $rest; | ||||
8503 | |||||||
8504 | 308 | 555 | my $idx = (($x > $rest) | ||||
8505 | ? ($rows * $rest + ($rows - 1) * ($x - $rest)) | ||||||
8506 | : ($rows * $x)); | ||||||
8507 | |||||||
8508 | 308 | 298 | $idx += $y; | ||||
8509 | 308 | 866 | $four[$x] = $lcomm[$idx]; | ||||
8510 | 77 | 81 | } | ||||
8511 | 77 | 227 | write; | ||||
8512 | 7 | 9 | } | ||||
8513 | |||||||
8514 | 7 | 13 | print ' | ||||
8515 | Report bugs to <bug-automake@gnu.org>. | ||||||
8516 | GNU Automake home page: <http://www.gnu.org/software/automake/>. | ||||||
8517 | General help using GNU software: <http://www.gnu.org/gethelp/>. | ||||||
8518 | '; | ||||||
8519 | |||||||
8520 | # --help always returns 0 per GNU standards. | ||||||
8521 | 7 | 15 | exit 0; | ||||
8522 | } | ||||||
8523 | |||||||
8524 | |||||||
8525 | # &version () | ||||||
8526 | # ----------- | ||||||
8527 | # Print version information | ||||||
8528 | sub version () | ||||||
8529 | { | ||||||
8530 | 11 | 2661 | print <<EOF; | ||||
8531 | automake (GNU $PACKAGE) $VERSION | ||||||
8532 | Copyright (C) 2010 Free Software Foundation, Inc. | ||||||
8533 | License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl-2.0.html> | ||||||
8534 | This is free software: you are free to change and redistribute it. | ||||||
8535 | There is NO WARRANTY, to the extent permitted by law. | ||||||
8536 | |||||||
8537 | Written by Tom Tromey <tromey\@redhat.com> | ||||||
8538 | and Alexandre Duret-Lutz <adl\@gnu.org>. | ||||||
8539 | EOF | ||||||
8540 | # --version always returns 0 per GNU standards. | ||||||
8541 | 11 | 24 | exit 0; | ||||
8542 | } | ||||||
8543 | |||||||
8544 | ################################################################ | ||||||
8545 | |||||||
8546 | # Parse command line. | ||||||
8547 | sub parse_arguments () | ||||||
8548 | { | ||||||
8549 | # Start off as gnu. | ||||||
8550 | 1159 | 4977 | set_strictness ('gnu'); | ||||
8551 | |||||||
8552 | 1159 | 5973 | my $cli_where = new Automake::Location; | ||||
8553 | my %cli_options = | ||||||
8554 | ( | ||||||
8555 | 'libdir=s' => \$libdir, | ||||||
8556 | 15 | 8843 | 'gnu' => sub { set_strictness ('gnu'); }, | ||||
8557 | 6 | 5338 | 'gnits' => sub { set_strictness ('gnits'); }, | ||||
8558 | 7 | 5770 | 'cygnus' => sub { set_global_option ('cygnus', $cli_where); }, | ||||
8559 | 1140 | 2392430 | 'foreign' => sub { set_strictness ('foreign'); }, | ||||
8560 | 6 | 1382 | 'include-deps' => sub { unset_global_option ('no-dependencies'); }, | ||||
8561 | 4 | 1028 | 'i|ignore-deps' => sub { set_global_option ('no-dependencies', | ||||
8562 | $cli_where); }, | ||||||
8563 | 9 | 2373 | 'no-force' => sub { $force_generation = 0; }, | ||||
8564 | 'f|force-missing' => \$force_missing, | ||||||
8565 | 'o|output-dir=s' => \$output_directory, | ||||||
8566 | 'a|add-missing' => \$add_missing, | ||||||
8567 | 'c|copy' => \$copy_missing, | ||||||
8568 | 0 | 0 | 'v|verbose' => sub { setup_channel 'verb', silent => 0; }, | ||||
8569 | 'W|warnings=s' => \&parse_warnings, | ||||||
8570 | # These long options (--Werror and --Wno-error) for backward | ||||||
8571 | # compatibility. Use -Werror and -Wno-error today. | ||||||
8572 | 1 | 228 | 'Werror' => sub { parse_warnings 'W', 'error'; }, | ||||
8573 | 0 | 0 | 'Wno-error' => sub { parse_warnings 'W', 'no-error'; }, | ||||
8574 | 1159 | 42340 | ); | ||||
8575 | 1159 1159 1159 | 22348 1817 5136 | use Getopt::Long; | ||||
8576 | 1159 | 7129 | Getopt::Long::config ("bundling", "pass_through"); | ||||
8577 | |||||||
8578 | # See if --version or --help is used. We want to process these before | ||||||
8579 | # anything else because the GNU Coding Standards require us to | ||||||
8580 | # `exit 0' after processing these options, and we can't guarantee this | ||||||
8581 | # if we treat other options first. (Handling other options first | ||||||
8582 | # could produce error diagnostics, and in this condition it is | ||||||
8583 | # confusing if Automake does `exit 0'.) | ||||||
8584 | my %cli_options_1st_pass = | ||||||
8585 | ( | ||||||
8586 | 'version' => \&version, | ||||||
8587 | 'help' => \&usage, | ||||||
8588 | # Recognize all other options (and their arguments) but do nothing. | ||||||
8589 | 1159 18544 5136 | 126452 68205 3221696 | map { $_ => sub {} } (keys %cli_options) | ||||
8590 | ); | ||||||
8591 | 1159 | 6922 | my @ARGV_backup = @ARGV; | ||||
8592 | 1159 | 7402 | Getopt::Long::GetOptions %cli_options_1st_pass | ||||
8593 | or exit 1; | ||||||
8594 | 1141 | 48532 | @ARGV = @ARGV_backup; | ||||
8595 | |||||||
8596 | # Now *really* process the options. This time we know that --help | ||||||
8597 | # and --version are not present, but we specify them nonetheless so | ||||||
8598 | # that ambiguous abbreviation are diagnosed. | ||||||
8599 | 0 0 | 0 0 | Getopt::Long::GetOptions %cli_options, 'version' => sub {}, 'help' => sub {} | ||||
8600 | 1141 | 9616 | or exit 1; | ||||
8601 | |||||||
8602 | 1141 | 121768 | if (defined $output_directory) | ||||
8603 | { | ||||||
8604 | 1 | 4 | msg 'obsolete', "`--output-dir' is deprecated"; | ||||
8605 | } | ||||||
8606 | else | ||||||
8607 | { | ||||||
8608 | # In the next release we'll remove this entirely. | ||||||
8609 | 1140 | 2755 | $output_directory = '.'; | ||||
8610 | } | ||||||
8611 | |||||||
8612 | 1141 | 28114 | return unless @ARGV; | ||||
8613 | |||||||
8614 | 48 | 177 | if ($ARGV[0] =~ /^-./) | ||||
8615 | { | ||||||
8616 | 7 | 9 | my %argopts; | ||||
8617 | 7 | 26 | for my $k (keys %cli_options) | ||||
8618 | { | ||||||
8619 | 112 | 261 | if ($k =~ /(.*)=s$/) | ||||
8620 | { | ||||||
8621 | 21 35 | 61 156 | map { $argopts{(length ($_) == 1) | ||||
8622 | ? "-$_" : "--$_" } = 1; } (split (/\|/, $1)); | ||||||
8623 | } | ||||||
8624 | } | ||||||
8625 | 7 | 39 | if ($ARGV[0] eq '--') | ||||
8626 | { | ||||||
8627 | 2 | 6 | shift @ARGV; | ||||
8628 | } | ||||||
8629 | elsif (exists $argopts{$ARGV[0]}) | ||||||
8630 | { | ||||||
8631 | 2 | 16 | fatal ("option `$ARGV[0]' requires an argument.\n" | ||||
8632 | . "Try `$0 --help' for more information"); | ||||||
8633 | } | ||||||
8634 | else | ||||||
8635 | { | ||||||
8636 | 3 | 21 | fatal ("unrecognized option `$ARGV[0]'.\n" | ||||
8637 | . "Try `$0 --help' for more information"); | ||||||
8638 | } | ||||||
8639 | } | ||||||
8640 | |||||||
8641 | 43 | 84 | my $errspec = 0; | ||||
8642 | 43 | 117 | foreach my $arg (@ARGV) | ||||
8643 | { | ||||||
8644 | 43 | 152 | fatal ("empty argument\nTry `$0 --help' for more information") | ||||
8645 | if ($arg eq ''); | ||||||
8646 | |||||||
8647 | # Handle $local:$input syntax. | ||||||
8648 | 42 | 165 | my ($local, @rest) = split (/:/, $arg); | ||||
8649 | 42 | 200 | @rest = ("$local.in",) unless @rest; | ||||
8650 | 42 | 161 | my $input = locate_am @rest; | ||||
8651 | 42 | 108 | if ($input) | ||||
8652 | { | ||||||
8653 | 41 | 100 | push @input_files, $input; | ||||
8654 | 41 | 221 | $output_files{$input} = join (':', ($local, @rest)); | ||||
8655 | } | ||||||
8656 | else | ||||||
8657 | { | ||||||
8658 | 1 | 5 | error "no Automake input file found for `$arg'"; | ||||
8659 | 1 | 3 | $errspec = 1; | ||||
8660 | } | ||||||
8661 | } | ||||||
8662 | 42 | 1168 | fatal "no input file found among supplied arguments" | ||||
8663 | if $errspec && ! @input_files; | ||||||
8664 | } | ||||||
8665 | |||||||
8666 | |||||||
8667 | # handle_makefile ($MAKEFILE_IN) | ||||||
8668 | # ------------------------------ | ||||||
8669 | # Deal with $MAKEFILE_IN. | ||||||
8670 | sub handle_makefile ($) | ||||||
8671 | { | ||||||
8672 | 1322 | 3720 | my ($file) = @_; | ||||
8673 | 1322 | 9098 | ($am_file = $file) =~ s/\.in$//; | ||||
8674 | 1322 | 9698 | if (! -f ($am_file . '.am')) | ||||
8675 | { | ||||||
8676 | 0 | 0 | error "`$am_file.am' does not exist"; | ||||
8677 | } | ||||||
8678 | else | ||||||
8679 | { | ||||||
8680 | # Any warning setting now local to this Makefile.am. | ||||||
8681 | 1322 | 8108 | dup_channel_setup; | ||||
8682 | |||||||
8683 | 1322 | 7350 | generate_makefile ($am_file . '.am', $file); | ||||
8684 | |||||||
8685 | # Back out any warning setting. | ||||||
8686 | 1321 | 6594 | drop_channel_setup; | ||||
8687 | } | ||||||
8688 | } | ||||||
8689 | |||||||
8690 | # handle_makefiles_serial () | ||||||
8691 | # -------------------------- | ||||||
8692 | # Deal with all makefiles, without threads. | ||||||
8693 | sub handle_makefiles_serial () | ||||||
8694 | { | ||||||
8695 | 1121 | 3613 | foreach my $file (@input_files) | ||||
8696 | { | ||||||
8697 | 1322 | 4514 | handle_makefile ($file); | ||||
8698 | } | ||||||
8699 | } | ||||||
8700 | |||||||
8701 | # get_number_of_threads () | ||||||
8702 | # ------------------------ | ||||||
8703 | # Logic for deciding how many worker threads to use. | ||||||
8704 | sub get_number_of_threads | ||||||
8705 | { | ||||||
8706 | 1121 | 11394 | my $nthreads = $ENV{'AUTOMAKE_JOBS'} || 0; | ||||
8707 | |||||||
8708 | 1121 | 7805 | $nthreads = 0 | ||||
8709 | unless $nthreads =~ /^[0-9]+$/; | ||||||
8710 | |||||||
8711 | # It doesn't make sense to use more threads than makefiles, | ||||||
8712 | 1121 | 2020 | my $max_threads = @input_files; | ||||
8713 | |||||||
8714 | # but a single worker thread is helpful for exposing bugs. | ||||||
8715 | 1121 | 9628 | if ($automake_will_process_aux_dir && $max_threads > 1) | ||||
8716 | { | ||||||
8717 | 152 | 304 | $max_threads--; | ||||
8718 | } | ||||||
8719 | 1121 | 3074 | if ($nthreads > $max_threads) | ||||
8720 | { | ||||||
8721 | 0 | 0 | $nthreads = $max_threads; | ||||
8722 | } | ||||||
8723 | 1121 | 4465 | return $nthreads; | ||||
8724 | } | ||||||
8725 | |||||||
8726 | # handle_makefiles_threaded ($NTHREADS) | ||||||
8727 | # ------------------------------------- | ||||||
8728 | # Deal with all makefiles, using threads. The general strategy is to | ||||||
8729 | # spawn NTHREADS worker threads, dispatch makefiles to them, and let the | ||||||
8730 | # worker threads push back everything that needs serialization: | ||||||
8731 | # * warning and (normal) error messages, for stable stderr output | ||||||
8732 | # order and content (avoiding duplicates, for example), | ||||||
8733 | # * races when installing aux files (and respective messages), | ||||||
8734 | # * races when collecting aux files for distribution. | ||||||
8735 | # | ||||||
8736 | # The latter requires that the makefile that deals with the aux dir | ||||||
8737 | # files be handled last, done by the master thread. | ||||||
8738 | sub handle_makefiles_threaded ($) | ||||||
8739 | { | ||||||
8740 | 0 | my ($nthreads) = @_; | |||||
8741 | |||||||
8742 | 0 | my @queued_input_files = @input_files; | |||||
8743 | 0 | my $last_input_file = undef; | |||||
8744 | 0 | if ($automake_will_process_aux_dir) | |||||
8745 | { | ||||||
8746 | 0 | $last_input_file = pop @queued_input_files; | |||||
8747 | } | ||||||
8748 | |||||||
8749 | # The file queue distributes all makefiles, the message queues | ||||||
8750 | # collect all serializations needed for respective files. | ||||||
8751 | 0 | my $file_queue = Thread::Queue->new; | |||||
8752 | 0 | my %msg_queues; | |||||
8753 | 0 | foreach my $file (@queued_input_files) | |||||
8754 | { | ||||||
8755 | 0 | $msg_queues{$file} = Thread::Queue->new; | |||||
8756 | } | ||||||
8757 | |||||||
8758 | 0 | verb "spawning $nthreads worker threads"; | |||||
8759 | 0 | my @threads = (1 .. $nthreads); | |||||
8760 | 0 | foreach my $t (@threads) | |||||
8761 | { | ||||||
8762 | $t = threads->new (sub | ||||||
8763 | { | ||||||
8764 | 0 | while (my $file = $file_queue->dequeue) | |||||
8765 | { | ||||||
8766 | 0 | verb "handling $file"; | |||||
8767 | 0 | my $queue = $msg_queues{$file}; | |||||
8768 | 0 | setup_channel_queue ($queue, QUEUE_MESSAGE); | |||||
8769 | 0 | $required_conf_file_queue = $queue; | |||||
8770 | 0 | handle_makefile ($file); | |||||
8771 | 0 | $queue->enqueue (undef); | |||||
8772 | 0 | setup_channel_queue (undef, undef); | |||||
8773 | 0 | $required_conf_file_queue = undef; | |||||
8774 | } | ||||||
8775 | 0 | return $exit_code; | |||||
8776 | 0 | }); | |||||
8777 | } | ||||||
8778 | |||||||
8779 | # Queue all normal makefiles. | ||||||
8780 | 0 | verb "queuing " . @queued_input_files . " input files"; | |||||
8781 | 0 | $file_queue->enqueue (@queued_input_files, (undef) x @threads); | |||||
8782 | |||||||
8783 | # Collect and process serializations. | ||||||
8784 | 0 | foreach my $file (@queued_input_files) | |||||
8785 | { | ||||||
8786 | 0 | verb "dequeuing messages for " . $file; | |||||
8787 | 0 | reset_local_duplicates (); | |||||
8788 | 0 | my $queue = $msg_queues{$file}; | |||||
8789 | 0 | while (my $key = $queue->dequeue) | |||||
8790 | { | ||||||
8791 | 0 | if ($key eq QUEUE_MESSAGE) | |||||
8792 | { | ||||||
8793 | 0 | pop_channel_queue ($queue); | |||||
8794 | } | ||||||
8795 | elsif ($key eq QUEUE_CONF_FILE) | ||||||
8796 | { | ||||||
8797 | 0 | require_queued_conf_file ($queue); | |||||
8798 | } | ||||||
8799 | else | ||||||
8800 | { | ||||||
8801 | 0 | prog_error "unexpected key $key"; | |||||
8802 | } | ||||||
8803 | } | ||||||
8804 | } | ||||||
8805 | |||||||
8806 | 0 | foreach my $t (@threads) | |||||
8807 | { | ||||||
8808 | 0 | my @exit_thread = $t->join; | |||||
8809 | 0 | $exit_code = $exit_thread[0] | |||||
8810 | if ($exit_thread[0] > $exit_code); | ||||||
8811 | } | ||||||
8812 | |||||||
8813 | # The master processes the last file. | ||||||
8814 | 0 | if ($automake_will_process_aux_dir) | |||||
8815 | { | ||||||
8816 | 0 | verb "processing last input file"; | |||||
8817 | 0 | handle_makefile ($last_input_file); | |||||
8818 | } | ||||||
8819 | } | ||||||
8820 | |||||||
8821 | ################################################################ | ||||||
8822 | |||||||
8823 | # Parse the WARNINGS environment variable. | ||||||
8824 | 1159 | 4638 | parse_WARNINGS; | ||||
8825 | |||||||
8826 | # Parse command line. | ||||||
8827 | 1159 | 3601 | parse_arguments; | ||||
8828 | |||||||
8829 | 1134 | 4861 | $configure_ac = require_configure_ac; | ||||
8830 | |||||||
8831 | # Do configure.ac scan only once. | ||||||
8832 | 1133 | 5031 | scan_autoconf_files; | ||||
8833 | |||||||
8834 | 1127 | 4191 | if (! @input_files) | ||||
8835 | { | ||||||
8836 | 8 | 29 | my $msg = ''; | ||||
8837 | 8 | 46 | $msg = "\nDid you forget AC_CONFIG_FILES([Makefile]) in $configure_ac?" | ||||
8838 | if -f 'Makefile.am'; | ||||||
8839 | 8 | 23 | $msg = "no `Makefile.am' found for any configure output$msg"; | ||||
8840 | 8 | 77 | if (! -f 'Makefile.am' && $add_missing) | ||||
8841 | { | ||||||
8842 | 2 | 10 | msg 'unsupported', $msg . "\n(only installing missing files)"; | ||||
8843 | } | ||||||
8844 | else | ||||||
8845 | { | ||||||
8846 | 6 | 39 | fatal $msg; | ||||
8847 | } | ||||||
8848 | } | ||||||
8849 | |||||||
8850 | 1121 | 7350 | my $nthreads = get_number_of_threads (); | ||||
8851 | |||||||
8852 | 1121 | 11129 | if ($perl_threads && $nthreads >= 1) | ||||
8853 | { | ||||||
8854 | 0 | 0 | handle_makefiles_threaded ($nthreads); | ||||
8855 | } | ||||||
8856 | else | ||||||
8857 | { | ||||||
8858 | 1121 | 3874 | handle_makefiles_serial (); | ||||
8859 | } | ||||||
8860 | |||||||
8861 | 1120 | 2217 | exit $exit_code; | ||||
8862 | |||||||
8863 | |||||||
8864 | ### Setup "GNU" style for perl-mode and cperl-mode. | ||||||
8865 | ## Local Variables: | ||||||
8866 | ## perl-indent-level: 2 | ||||||
8867 | ## perl-continued-statement-offset: 2 | ||||||
8868 | ## perl-continued-brace-offset: 0 | ||||||
8869 | ## perl-brace-offset: 0 | ||||||
8870 | ## perl-brace-imaginary-offset: 0 | ||||||
8871 | ## perl-label-offset: -2 | ||||||
8872 | ## cperl-indent-level: 2 | ||||||
8873 | ## cperl-brace-offset: 0 | ||||||
8874 | ## cperl-continued-brace-offset: 0 | ||||||
8875 | ## cperl-label-offset: -2 | ||||||
8876 | ## cperl-extra-newline-before-brace: t | ||||||
8877 | ## cperl-merge-trailing-else: nil | ||||||
8878 | ## cperl-continued-statement-offset: 2 | ||||||
8879 | ## End: |