forked from kergoth/automake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
automake.in
8614 lines (7495 loc) · 250 KB
/
automake.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!@PERL@ -w
# -*- perl -*-
# @configure_input@
eval 'case $# in 0) exec @PERL@ -S "$0";; *) exec @PERL@ -S "$0" "$@";; esac'
if 0;
# automake - create Makefile.in from Makefile.am
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software
# Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Originally written by David Mackenzie <[email protected]>.
# Perl reimplementation by Tom Tromey <[email protected]>, and
# Alexandre Duret-Lutz <[email protected]>.
package Language;
BEGIN
{
my $perllibdir = $ENV{'perllibdir'} || '@datadir@/@PACKAGE@-@APIVERSION@';
unshift @INC, (split '@PATH_SEPARATOR@', $perllibdir);
# Override SHELL. This is required on DJGPP so that system() uses
# bash, not COMMAND.COM which doesn't quote arguments properly.
# Other systems aren't expected to use $SHELL when Automake
# runs, but it should be safe to drop the `if DJGPP' guard if
# it turns up other systems need the same thing. After all,
# if SHELL is used, ./configure's SHELL is always better than
# the user's SHELL (which may be something like tcsh).
$ENV{'SHELL'} = '@SHELL@' if exists $ENV{'DJDIR'};
}
use Automake::Struct;
struct (# Short name of the language (c, f77...).
'name' => "\$",
# Nice name of the language (C, Fortran 77...).
'Name' => "\$",
# List of configure variables which must be defined.
'config_vars' => '@',
# `pure' is `1' or `'. A `pure' language is one where, if
# all the files in a directory are of that language, then we
# do not require the C compiler or any code to call it.
'pure' => "\$",
'autodep' => "\$",
# Name of the compiling variable (COMPILE).
'compiler' => "\$",
# Content of the compiling variable.
'compile' => "\$",
# Flag to require compilation without linking (-c).
'compile_flag' => "\$",
'extensions' => '@',
# A subroutine to compute a list of possible extensions of
# the product given the input extensions.
# (defaults to a subroutine which returns ('.$(OBJEXT)', '.lo'))
'output_extensions' => "\$",
# A list of flag variables used in 'compile'.
# (defaults to [])
'flags' => "@",
# Any tag to pass to libtool while compiling.
'libtool_tag' => "\$",
# The file to use when generating rules for this language.
# The default is 'depend2'.
'rule_file' => "\$",
# Name of the linking variable (LINK).
'linker' => "\$",
# Content of the linking variable.
'link' => "\$",
# Name of the compiler variable (CC).
'ccer' => "\$",
# Name of the linker variable (LD).
'lder' => "\$",
# Content of the linker variable ($(CC)).
'ld' => "\$",
# Flag to specify the output file (-o).
'output_flag' => "\$",
'_finish' => "\$",
# This is a subroutine which is called whenever we finally
# determine the context in which a source file will be
# compiled.
'_target_hook' => "\$",
# If TRUE, nodist_ sources will be compiled using specific rules
# (i.e. not inference rules). The default is FALSE.
'nodist_specific' => "\$");
sub finish ($)
{
my ($self) = @_;
if (defined $self->_finish)
{
&{$self->_finish} (@_);
}
}
sub target_hook ($$$$%)
{
my ($self) = @_;
if (defined $self->_target_hook)
{
&{$self->_target_hook} (@_);
}
}
package Automake;
use strict;
use Automake::Config;
BEGIN
{
if ($perl_threads)
{
require threads;
import threads;
require Thread::Queue;
import Thread::Queue;
}
}
use Automake::General;
use Automake::XFile;
use Automake::Channels;
use Automake::ChannelDefs;
use Automake::Configure_ac;
use Automake::FileUtils;
use Automake::Location;
use Automake::Condition qw/TRUE FALSE/;
use Automake::DisjConditions;
use Automake::Options;
use Automake::Version;
use Automake::Variable;
use Automake::VarDef;
use Automake::Rule;
use Automake::RuleDef;
use Automake::Wrap 'makefile_wrap';
use File::Basename;
use File::Spec;
use Carp;
## ----------- ##
## Constants. ##
## ----------- ##
# Some regular expressions. One reason to put them here is that it
# makes indentation work better in Emacs.
# Writing singled-quoted-$-terminated regexes is a pain because
# perl-mode thinks of $' as the ${'} variable (instead of a $ followed
# by a closing quote. Letting perl-mode think the quote is not closed
# leads to all sort of misindentations. On the other hand, defining
# regexes as double-quoted strings is far less readable. So usually
# we will write:
#
# $REGEX = '^regex_value' . "\$";
my $IGNORE_PATTERN = '^\s*##([^#\n].*)?\n';
my $WHITE_PATTERN = '^\s*' . "\$";
my $COMMENT_PATTERN = '^#';
my $TARGET_PATTERN='[$a-zA-Z0-9_.@%][-.a-zA-Z0-9_(){}/$+@%]*';
# A rule has three parts: a list of targets, a list of dependencies,
# and optionally actions.
my $RULE_PATTERN =
"^($TARGET_PATTERN(?:(?:\\\\\n|\\s)+$TARGET_PATTERN)*) *:([^=].*|)\$";
# Only recognize leading spaces, not leading tabs. If we recognize
# leading tabs here then we need to make the reader smarter, because
# otherwise it will think rules like `foo=bar; \' are errors.
my $ASSIGNMENT_PATTERN = '^ *([^ \t=:+]*)\s*([:+]?)=\s*(.*)' . "\$";
# This pattern recognizes a Gnits version id and sets $1 if the
# release is an alpha release. We also allow a suffix which can be
# used to extend the version number with a "fork" identifier.
my $GNITS_VERSION_PATTERN = '\d+\.\d+([a-z]|\.\d+)?(-[A-Za-z0-9]+)?';
my $IF_PATTERN = '^if\s+(!?)\s*([A-Za-z][A-Za-z0-9_]*)\s*(?:#.*)?' . "\$";
my $ELSE_PATTERN =
'^else(?:\s+(!?)\s*([A-Za-z][A-Za-z0-9_]*))?\s*(?:#.*)?' . "\$";
my $ENDIF_PATTERN =
'^endif(?:\s+(!?)\s*([A-Za-z][A-Za-z0-9_]*))?\s*(?:#.*)?' . "\$";
my $PATH_PATTERN = '(\w|[+/.-])+';
# This will pass through anything not of the prescribed form.
my $INCLUDE_PATTERN = ('^include\s+'
. '((\$\(top_srcdir\)/' . $PATH_PATTERN . ')'
. '|(\$\(srcdir\)/' . $PATH_PATTERN . ')'
. '|([^/\$]' . $PATH_PATTERN . '))\s*(#.*)?' . "\$");
# Directories installed during 'install-exec' phase.
my $EXEC_DIR_PATTERN =
'^(?:bin|sbin|libexec|sysconf|localstate|lib|pkglib|.*exec.*)' . "\$";
# Values for AC_CANONICAL_*
use constant AC_CANONICAL_BUILD => 1;
use constant AC_CANONICAL_HOST => 2;
use constant AC_CANONICAL_TARGET => 3;
# Values indicating when something should be cleaned.
use constant MOSTLY_CLEAN => 0;
use constant CLEAN => 1;
use constant DIST_CLEAN => 2;
use constant MAINTAINER_CLEAN => 3;
# Libtool files.
my @libtool_files = qw(ltmain.sh config.guess config.sub);
# ltconfig appears here for compatibility with old versions of libtool.
my @libtool_sometimes = qw(ltconfig ltcf-c.sh ltcf-cxx.sh ltcf-gcj.sh);
# Commonly found files we look for and automatically include in
# DISTFILES.
my @common_files =
(qw(ABOUT-GNU ABOUT-NLS AUTHORS BACKLOG COPYING COPYING.DOC COPYING.LIB
COPYING.LESSER ChangeLog INSTALL NEWS README THANKS TODO
ar-lib compile config.guess config.rpath
config.sub depcomp elisp-comp install-sh libversion.in mdate-sh
missing mkinstalldirs py-compile texinfo.tex ylwrap),
@libtool_files, @libtool_sometimes);
# Commonly used files we auto-include, but only sometimes. This list
# is used for the --help output only.
my @common_sometimes =
qw(aclocal.m4 acconfig.h config.h.top config.h.bot configure
configure.ac configure.in stamp-vti);
# Standard directories from the GNU Coding Standards, and additional
# pkg* directories from Automake. Stored in a hash for fast member check.
my %standard_prefix =
map { $_ => 1 } (qw(bin data dataroot doc dvi exec html include info
lib libexec lisp locale localstate man man1 man2
man3 man4 man5 man6 man7 man8 man9 oldinclude pdf
pkgdata pkginclude pkglib pkglibexec ps sbin
sharedstate sysconf));
# Copyright on generated Makefile.ins.
my $gen_copyright = "\
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software
# Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
";
# These constants are returned by the lang_*_rewrite functions.
# LANG_SUBDIR means that the resulting object file should be in a
# subdir if the source file is. In this case the file name cannot
# have `..' components.
use constant LANG_IGNORE => 0;
use constant LANG_PROCESS => 1;
use constant LANG_SUBDIR => 2;
# These are used when keeping track of whether an object can be built
# by two different paths.
use constant COMPILE_LIBTOOL => 1;
use constant COMPILE_ORDINARY => 2;
# We can't always associate a location to a variable or a rule,
# when it's defined by Automake. We use INTERNAL in this case.
use constant INTERNAL => new Automake::Location;
# Serialization keys for message queues.
use constant QUEUE_MESSAGE => "msg";
use constant QUEUE_CONF_FILE => "conf file";
use constant QUEUE_LOCATION => "location";
use constant QUEUE_STRING => "string";
## ---------------------------------- ##
## Variables related to the options. ##
## ---------------------------------- ##
# TRUE if we should always generate Makefile.in.
my $force_generation = 1;
# From the Perl manual.
my $symlink_exists = (eval 'symlink ("", "");', $@ eq '');
# TRUE if missing standard files should be installed.
my $add_missing = 0;
# TRUE if we should copy missing files; otherwise symlink if possible.
my $copy_missing = 0;
# TRUE if we should always update files that we know about.
my $force_missing = 0;
## ---------------------------------------- ##
## Variables filled during files scanning. ##
## ---------------------------------------- ##
# Name of the configure.ac file.
my $configure_ac;
# Files found by scanning configure.ac for LIBOBJS.
my %libsources = ();
# Names used in AC_CONFIG_HEADER call.
my @config_headers = ();
# Names used in AC_CONFIG_LINKS call.
my @config_links = ();
# List of Makefile.am's to process, and their corresponding outputs.
my @input_files = ();
my %output_files = ();
# Complete list of Makefile.am's that exist.
my @configure_input_files = ();
# List of files in AC_CONFIG_FILES/AC_OUTPUT without Makefile.am's,
# and their outputs.
my @other_input_files = ();
# Where each AC_CONFIG_FILES/AC_OUTPUT/AC_CONFIG_LINK/AC_CONFIG_HEADER appears.
# The keys are the files created by these macros.
my %ac_config_files_location = ();
# The condition under which AC_CONFIG_FOOS appears.
my %ac_config_files_condition = ();
# Directory to search for configure-required files. This
# will be computed by &locate_aux_dir and can be set using
# AC_CONFIG_AUX_DIR in configure.ac.
# $CONFIG_AUX_DIR is the `raw' directory, valid only in the source-tree.
my $config_aux_dir = '';
my $config_aux_dir_set_in_configure_ac = 0;
# $AM_CONFIG_AUX_DIR is prefixed with $(top_srcdir), so it can be used
# in Makefiles.
my $am_config_aux_dir = '';
# Directory to search for AC_LIBSOURCE files, as set by AC_CONFIG_LIBOBJ_DIR
# in configure.ac.
my $config_libobj_dir = '';
# Whether AM_GNU_GETTEXT has been seen in configure.ac.
my $seen_gettext = 0;
# Whether AM_GNU_GETTEXT([external]) is used.
my $seen_gettext_external = 0;
# Where AM_GNU_GETTEXT appears.
my $ac_gettext_location;
# Whether AM_GNU_GETTEXT_INTL_SUBDIR has been seen.
my $seen_gettext_intl = 0;
# Lists of tags supported by Libtool.
my %libtool_tags = ();
# 1 if Libtool uses LT_SUPPORTED_TAG. If it does, then it also
# uses AC_REQUIRE_AUX_FILE.
my $libtool_new_api = 0;
# Most important AC_CANONICAL_* macro seen so far.
my $seen_canonical = 0;
# Location of that macro.
my $canonical_location;
# Where AM_MAINTAINER_MODE appears.
my $seen_maint_mode;
# Actual version we've seen.
my $package_version = '';
# Where version is defined.
my $package_version_location;
# TRUE if we've seen AM_ENABLE_MULTILIB.
my $seen_multilib = 0;
# TRUE if we've seen AM_PROG_AR
my $seen_ar = 0;
# TRUE if we've seen AM_PROG_CC_C_O
my $seen_cc_c_o = 0;
# Location of AC_REQUIRE_AUX_FILE calls, indexed by their argument.
my %required_aux_file = ();
# Where AM_INIT_AUTOMAKE is called;
my $seen_init_automake = 0;
# TRUE if we've seen AM_AUTOMAKE_VERSION.
my $seen_automake_version = 0;
# Hash table of discovered configure substitutions. Keys are names,
# values are `FILE:LINE' strings which are used by error message
# generation.
my %configure_vars = ();
# Ignored configure substitutions (i.e., variables not to be output in
# Makefile.in)
my %ignored_configure_vars = ();
# Files included by $configure_ac.
my @configure_deps = ();
# Greatest timestamp of configure's dependencies.
my $configure_deps_greatest_timestamp = 0;
# Hash table of AM_CONDITIONAL variables seen in configure.
my %configure_cond = ();
# This maps extensions onto language names.
my %extension_map = ();
# List of the DIST_COMMON files we discovered while reading
# configure.in
my $configure_dist_common = '';
# This maps languages names onto objects.
my %languages = ();
# Maps each linker variable onto a language object.
my %link_languages = ();
# maps extensions to needed source flags.
my %sourceflags = ();
# List of targets we must always output.
# FIXME: Complete, and remove falsely required targets.
my %required_targets =
(
'all' => 1,
'dvi' => 1,
'pdf' => 1,
'ps' => 1,
'info' => 1,
'install-info' => 1,
'install' => 1,
'install-data' => 1,
'install-exec' => 1,
'uninstall' => 1,
# FIXME: Not required, temporary hacks.
# Well, actually they are sort of required: the -recursive
# targets will run them anyway...
'html-am' => 1,
'dvi-am' => 1,
'pdf-am' => 1,
'ps-am' => 1,
'info-am' => 1,
'install-data-am' => 1,
'install-exec-am' => 1,
'install-html-am' => 1,
'install-dvi-am' => 1,
'install-pdf-am' => 1,
'install-ps-am' => 1,
'install-info-am' => 1,
'installcheck-am' => 1,
'uninstall-am' => 1,
'install-man' => 1,
);
# Queue to push require_conf_file requirements to.
my $required_conf_file_queue;
# The name of the Makefile currently being processed.
my $am_file = 'BUG';
################################################################
## ------------------------------------------ ##
## Variables reset by &initialize_per_input. ##
## ------------------------------------------ ##
# Basename and relative dir of the input file.
my $am_file_name;
my $am_relative_dir;
# Same but wrt Makefile.in.
my $in_file_name;
my $relative_dir;
# Relative path to the top directory.
my $topsrcdir;
# Greatest timestamp of the output's dependencies (excluding
# configure's dependencies).
my $output_deps_greatest_timestamp;
# These variables are used when generating each Makefile.in.
# They hold the Makefile.in until it is ready to be printed.
my $output_vars;
my $output_all;
my $output_header;
my $output_rules;
my $output_trailer;
# This is the conditional stack, updated on if/else/endif, and
# used to build Condition objects.
my @cond_stack;
# This holds the set of included files.
my @include_stack;
# List of dependencies for the obvious targets.
my @all;
my @check;
my @check_tests;
# Keys in this hash table are files to delete. The associated
# value tells when this should happen (MOSTLY_CLEAN, DIST_CLEAN, etc.)
my %clean_files;
# Keys in this hash table are object files or other files in
# subdirectories which need to be removed. This only holds files
# which are created by compilations. The value in the hash indicates
# when the file should be removed.
my %compile_clean_files;
# Keys in this hash table are directories where we expect to build a
# libtool object. We use this information to decide what directories
# to delete.
my %libtool_clean_directories;
# Value of `$(SOURCES)', used by tags.am.
my @sources;
# Sources which go in the distribution.
my @dist_sources;
# This hash maps object file names onto their corresponding source
# file names. This is used to ensure that each object is created
# by a single source file.
my %object_map;
# This hash maps object file names onto an integer value representing
# whether this object has been built via ordinary compilation or
# libtool compilation (the COMPILE_* constants).
my %object_compilation_map;
# This keeps track of the directories for which we've already
# created dirstamp code. Keys are directories, values are stamp files.
# Several keys can share the same stamp files if they are equivalent
# (as are `.//foo' and `foo').
my %directory_map;
# All .P files.
my %dep_files;
# This is a list of all targets to run during "make dist".
my @dist_targets;
# Keep track of all programs declared in this Makefile, without
# $(EXEEXT). @substitutions@ are not listed.
my %known_programs;
my %known_libraries;
# This keeps track of which extensions we've seen (that we care
# about).
my %extension_seen;
# This is random scratch space for the language finish functions.
# Don't randomly overwrite it; examine other uses of keys first.
my %language_scratch;
# We keep track of which objects need special (per-executable)
# handling on a per-language basis.
my %lang_specific_files;
# This is set when `handle_dist' has finished. Once this happens,
# we should no longer push on dist_common.
my $handle_dist_run;
# Used to store a set of linkers needed to generate the sources currently
# under consideration.
my %linkers_used;
# True if we need `LINK' defined. This is a hack.
my $need_link;
# Does the generated Makefile have to build some compiled object
# (for binary programs, or plain or libtool libraries)?
my $must_handle_compiled_objects;
# Record each file processed by make_paragraphs.
my %transformed_files;
################################################################
## ---------------------------------------------- ##
## Variables not reset by &initialize_per_input. ##
## ---------------------------------------------- ##
# Cache each file processed by make_paragraphs.
# (This is different from %transformed_files because
# %transformed_files is reset for each file while %am_file_cache
# it global to the run.)
my %am_file_cache;
################################################################
# var_SUFFIXES_trigger ($TYPE, $VALUE)
# ------------------------------------
# This is called by Automake::Variable::define() when SUFFIXES
# is defined ($TYPE eq '') or appended ($TYPE eq '+').
# The work here needs to be performed as a side-effect of the
# macro_define() call because SUFFIXES definitions impact
# on $KNOWN_EXTENSIONS_PATTERN which is used used when parsing
# the input am file.
sub var_SUFFIXES_trigger ($$)
{
my ($type, $value) = @_;
accept_extensions (split (' ', $value));
}
Automake::Variable::hook ('SUFFIXES', \&var_SUFFIXES_trigger);
################################################################
## --------------------------------- ##
## Forward subroutine declarations. ##
## --------------------------------- ##
sub register_language (%);
sub file_contents_internal ($$$%);
sub define_files_variable ($\@$$);
# &initialize_per_input ()
# ------------------------
# (Re)-Initialize per-Makefile.am variables.
sub initialize_per_input ()
{
reset_local_duplicates ();
$am_file_name = undef;
$am_relative_dir = undef;
$in_file_name = undef;
$relative_dir = undef;
$topsrcdir = undef;
$output_deps_greatest_timestamp = 0;
$output_vars = '';
$output_all = '';
$output_header = '';
$output_rules = '';
$output_trailer = '';
Automake::Options::reset;
Automake::Variable::reset;
Automake::Rule::reset;
@cond_stack = ();
@include_stack = ();
@all = ();
@check = ();
@check_tests = ();
%clean_files = ();
%compile_clean_files = ();
# We always include `.'. This isn't strictly correct.
%libtool_clean_directories = ('.' => 1);
@sources = ();
@dist_sources = ();
%object_map = ();
%object_compilation_map = ();
%directory_map = ();
%dep_files = ();
@dist_targets = ();
%known_programs = ();
%known_libraries= ();
%extension_seen = ();
%language_scratch = ();
%lang_specific_files = ();
$handle_dist_run = 0;
$need_link = 0;
$must_handle_compiled_objects = 0;
%transformed_files = ();
}
################################################################
# Initialize our list of languages that are internally supported.
# C.
register_language ('name' => 'c',
'Name' => 'C',
'config_vars' => ['CC'],
'autodep' => '',
'flags' => ['CFLAGS', 'CPPFLAGS'],
'ccer' => 'CC',
'compiler' => 'COMPILE',
'compile' => '$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)',
'lder' => 'CCLD',
'ld' => '$(CC)',
'linker' => 'LINK',
'link' => '$(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
'compile_flag' => '-c',
'libtool_tag' => 'CC',
'extensions' => ['.c']);
# C++.
register_language ('name' => 'cxx',
'Name' => 'C++',
'config_vars' => ['CXX'],
'linker' => 'CXXLINK',
'link' => '$(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
'autodep' => 'CXX',
'flags' => ['CXXFLAGS', 'CPPFLAGS'],
'compile' => '$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)',
'ccer' => 'CXX',
'compiler' => 'CXXCOMPILE',
'compile_flag' => '-c',
'output_flag' => '-o',
'libtool_tag' => 'CXX',
'lder' => 'CXXLD',
'ld' => '$(CXX)',
'pure' => 1,
'extensions' => ['.c++', '.cc', '.cpp', '.cxx', '.C']);
# Objective C.
register_language ('name' => 'objc',
'Name' => 'Objective C',
'config_vars' => ['OBJC'],
'linker' => 'OBJCLINK',
'link' => '$(OBJCLD) $(AM_OBJCFLAGS) $(OBJCFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
'autodep' => 'OBJC',
'flags' => ['OBJCFLAGS', 'CPPFLAGS'],
'compile' => '$(OBJC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_OBJCFLAGS) $(OBJCFLAGS)',
'ccer' => 'OBJC',
'compiler' => 'OBJCCOMPILE',
'compile_flag' => '-c',
'output_flag' => '-o',
'lder' => 'OBJCLD',
'ld' => '$(OBJC)',
'pure' => 1,
'extensions' => ['.m']);
# Unified Parallel C.
register_language ('name' => 'upc',
'Name' => 'Unified Parallel C',
'config_vars' => ['UPC'],
'linker' => 'UPCLINK',
'link' => '$(UPCLD) $(AM_UPCFLAGS) $(UPCFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
'autodep' => 'UPC',
'flags' => ['UPCFLAGS', 'CPPFLAGS'],
'compile' => '$(UPC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_UPCFLAGS) $(UPCFLAGS)',
'ccer' => 'UPC',
'compiler' => 'UPCCOMPILE',
'compile_flag' => '-c',
'output_flag' => '-o',
'lder' => 'UPCLD',
'ld' => '$(UPC)',
'pure' => 1,
'extensions' => ['.upc']);
# Headers.
register_language ('name' => 'header',
'Name' => 'Header',
'extensions' => ['.h', '.H', '.hxx', '.h++', '.hh',
'.hpp', '.inc'],
# No output.
'output_extensions' => sub { return () },
# Nothing to do.
'_finish' => sub { });
# Vala
register_language ('name' => 'vala',
'Name' => 'Vala',
'config_vars' => ['VALAC'],
'flags' => [],
'compile' => '$(VALAC) $(AM_VALAFLAGS) $(VALAFLAGS)',
'ccer' => 'VALAC',
'compiler' => 'VALACOMPILE',
'extensions' => ['.vala'],
'output_extensions' => sub { (my $ext = $_[0]) =~ s/vala$/c/;
return ($ext,) },
'rule_file' => 'vala',
'_finish' => \&lang_vala_finish,
'_target_hook' => \&lang_vala_target_hook,
'nodist_specific' => 1);
# Yacc (C & C++).
register_language ('name' => 'yacc',
'Name' => 'Yacc',
'config_vars' => ['YACC'],
'flags' => ['YFLAGS'],
'compile' => '$(YACC) $(AM_YFLAGS) $(YFLAGS)',
'ccer' => 'YACC',
'compiler' => 'YACCCOMPILE',
'extensions' => ['.y'],
'output_extensions' => sub { (my $ext = $_[0]) =~ tr/y/c/;
return ($ext,) },
'rule_file' => 'yacc',
'_finish' => \&lang_yacc_finish,
'_target_hook' => \&lang_yacc_target_hook,
'nodist_specific' => 1);
register_language ('name' => 'yaccxx',
'Name' => 'Yacc (C++)',
'config_vars' => ['YACC'],
'rule_file' => 'yacc',
'flags' => ['YFLAGS'],
'ccer' => 'YACC',
'compiler' => 'YACCCOMPILE',
'compile' => '$(YACC) $(AM_YFLAGS) $(YFLAGS)',
'extensions' => ['.y++', '.yy', '.yxx', '.ypp'],
'output_extensions' => sub { (my $ext = $_[0]) =~ tr/y/c/;
return ($ext,) },
'_finish' => \&lang_yacc_finish,
'_target_hook' => \&lang_yacc_target_hook,
'nodist_specific' => 1);
# Lex (C & C++).
register_language ('name' => 'lex',
'Name' => 'Lex',
'config_vars' => ['LEX'],
'rule_file' => 'lex',
'flags' => ['LFLAGS'],
'compile' => '$(LEX) $(AM_LFLAGS) $(LFLAGS)',
'ccer' => 'LEX',
'compiler' => 'LEXCOMPILE',
'extensions' => ['.l'],
'output_extensions' => sub { (my $ext = $_[0]) =~ tr/l/c/;
return ($ext,) },
'_finish' => \&lang_lex_finish,
'_target_hook' => \&lang_lex_target_hook,
'nodist_specific' => 1);
register_language ('name' => 'lexxx',
'Name' => 'Lex (C++)',
'config_vars' => ['LEX'],
'rule_file' => 'lex',
'flags' => ['LFLAGS'],
'compile' => '$(LEX) $(AM_LFLAGS) $(LFLAGS)',
'ccer' => 'LEX',
'compiler' => 'LEXCOMPILE',
'extensions' => ['.l++', '.ll', '.lxx', '.lpp'],
'output_extensions' => sub { (my $ext = $_[0]) =~ tr/l/c/;
return ($ext,) },
'_finish' => \&lang_lex_finish,
'_target_hook' => \&lang_lex_target_hook,
'nodist_specific' => 1);
# Assembler.
register_language ('name' => 'asm',
'Name' => 'Assembler',
'config_vars' => ['CCAS', 'CCASFLAGS'],
'flags' => ['CCASFLAGS'],
# Users can set AM_CCASFLAGS to include DEFS, INCLUDES,
# or anything else required. They can also set CCAS.
# Or simply use Preprocessed Assembler.
'compile' => '$(CCAS) $(AM_CCASFLAGS) $(CCASFLAGS)',
'ccer' => 'CCAS',
'compiler' => 'CCASCOMPILE',
'compile_flag' => '-c',
'output_flag' => '-o',
'extensions' => ['.s']);
# Preprocessed Assembler.
register_language ('name' => 'cppasm',
'Name' => 'Preprocessed Assembler',
'config_vars' => ['CCAS', 'CCASFLAGS'],
'autodep' => 'CCAS',
'flags' => ['CCASFLAGS', 'CPPFLAGS'],
'compile' => '$(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CCASFLAGS) $(CCASFLAGS)',
'ccer' => 'CPPAS',
'compiler' => 'CPPASCOMPILE',
'compile_flag' => '-c',
'output_flag' => '-o',
'extensions' => ['.S', '.sx']);
# Fortran 77
register_language ('name' => 'f77',
'Name' => 'Fortran 77',
'config_vars' => ['F77'],
'linker' => 'F77LINK',
'link' => '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
'flags' => ['FFLAGS'],
'compile' => '$(F77) $(AM_FFLAGS) $(FFLAGS)',
'ccer' => 'F77',
'compiler' => 'F77COMPILE',
'compile_flag' => '-c',
'output_flag' => '-o',
'libtool_tag' => 'F77',
'lder' => 'F77LD',
'ld' => '$(F77)',
'pure' => 1,
'extensions' => ['.f', '.for']);
# Fortran
register_language ('name' => 'fc',
'Name' => 'Fortran',
'config_vars' => ['FC'],
'linker' => 'FCLINK',
'link' => '$(FCLD) $(AM_FCFLAGS) $(FCFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
'flags' => ['FCFLAGS'],
'compile' => '$(FC) $(AM_FCFLAGS) $(FCFLAGS)',
'ccer' => 'FC',
'compiler' => 'FCCOMPILE',
'compile_flag' => '-c',
'output_flag' => '-o',
'libtool_tag' => 'FC',
'lder' => 'FCLD',
'ld' => '$(FC)',
'pure' => 1,
'extensions' => ['.f90', '.f95', '.f03', '.f08']);
# Preprocessed Fortran
register_language ('name' => 'ppfc',
'Name' => 'Preprocessed Fortran',
'config_vars' => ['FC'],
'linker' => 'FCLINK',
'link' => '$(FCLD) $(AM_FCFLAGS) $(FCFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
'lder' => 'FCLD',
'ld' => '$(FC)',
'flags' => ['FCFLAGS', 'CPPFLAGS'],
'ccer' => 'PPFC',
'compiler' => 'PPFCCOMPILE',
'compile' => '$(FC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FCFLAGS) $(FCFLAGS)',
'compile_flag' => '-c',
'output_flag' => '-o',
'libtool_tag' => 'FC',
'pure' => 1,
'extensions' => ['.F90','.F95', '.F03', '.F08']);
# Preprocessed Fortran 77
#
# The current support for preprocessing Fortran 77 just involves
# passing `$(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS)
# $(CPPFLAGS)' as additional flags to the Fortran 77 compiler, since
# this is how GNU Make does it; see the `GNU Make Manual, Edition 0.51
# for `make' Version 3.76 Beta' (specifically, from info file
# `(make)Catalogue of Rules').
#
# A better approach would be to write an Autoconf test
# (i.e. AC_PROG_FPP) for a Fortran 77 preprocessor, because not all
# Fortran 77 compilers know how to do preprocessing. The Autoconf
# macro AC_PROG_FPP should test the Fortran 77 compiler first for
# preprocessing capabilities, and then fall back on cpp (if cpp were
# available).
register_language ('name' => 'ppf77',
'Name' => 'Preprocessed Fortran 77',
'config_vars' => ['F77'],
'linker' => 'F77LINK',
'link' => '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
'lder' => 'F77LD',
'ld' => '$(F77)',
'flags' => ['FFLAGS', 'CPPFLAGS'],
'ccer' => 'PPF77',
'compiler' => 'PPF77COMPILE',
'compile' => '$(F77) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FFLAGS) $(FFLAGS)',
'compile_flag' => '-c',
'output_flag' => '-o',
'libtool_tag' => 'F77',
'pure' => 1,
'extensions' => ['.F']);
# Ratfor.
register_language ('name' => 'ratfor',
'Name' => 'Ratfor',
'config_vars' => ['F77'],
'linker' => 'F77LINK',
'link' => '$(F77LD) $(AM_FFLAGS) $(FFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
'lder' => 'F77LD',
'ld' => '$(F77)',
'flags' => ['RFLAGS', 'FFLAGS'],
# FIXME also FFLAGS.