/
Configure.pl
executable file
Β·210 lines (187 loc) Β· 7.41 KB
/
Configure.pl
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
#!/usr/bin/env perl
# Copyright (C) 2009-2019 The Perl Foundation
use 5.10.1;
use strict;
use warnings;
use Text::ParseWords;
use Getopt::Long;
use File::Spec;
use Cwd;
use FindBin;
BEGIN {
unless ( -e '3rdparty/nqp-configure/LICENSE' ) {
print "Updating nqp-configure submodule...\n";
my $msg =
qx{git submodule sync --quiet 3rdparty/nqp-configure && git submodule --quiet update --init 3rdparty/nqp-configure 2>&1};
if ( $? >> 8 == 0 ) { print "OK\n" }
else {
if ( $msg =~ /[']([^']+)[']\s+already exists and is not an empty/ )
{
print "\n===SORRY=== ERROR: "
. "Cannot update submodule because directory exists and is not empty.\n"
. ">>> Please delete the following folder and try again:\n$1\n\n";
exit 1;
}
}
}
}
use lib ( "$FindBin::Bin/tools/lib",
"$FindBin::Bin/3rdparty/nqp-configure/lib" );
use NQP::Config qw<system_or_die>;
use NQP::Config::Rakudo;
$| = 1;
my $cfg = NQP::Config::Rakudo->new;
my $config = $cfg->config( no_ctx => 1 );
my $lang = $cfg->cfg('lang');
# We don't use ExtUtils::Command in Configure.pl, but it is used in the Makefile
# Try `use`ing it here so users know if they need to install this module
# (not included with *every* Perl installation)
use ExtUtils::Command;
MAIN: {
if ( -r 'config.default' ) {
unshift @ARGV, shellwords( slurp('config.default') );
}
my $config_status = "$config->{lclang}_config_status";
$config->{$config_status} = join ' ', map { qq("$_") } @ARGV;
GetOptions(
$cfg->options, 'help!',
'prefix=s', 'libdir=s',
'sysroot=s', 'sdkroot=s',
'no-relocatable', 'backends=s',
'no-clean', 'with-nqp=s',
'gen-nqp:s', 'gen-moar:s',
'moar-option=s@', 'git-protocol=s',
'ignore-errors', 'make-install!',
'makefile-timing!', 'git-depth=s',
'git-reference=s', 'github-user=s',
'rakudo-repo=s', 'nqp-repo=s',
'moar-repo=s', 'roast-repo=s',
'expand=s', 'out=s',
'set-var=s@',
)
or do {
print_help();
exit(1);
};
# Print help if it's requested
if ( $cfg->opt('help') ) {
print_help();
exit(0);
}
if ( $cfg->opt('ignore-errors') ) {
print
"===WARNING!===\nErrors are being ignored.\nIn the case of any errors the script may behave unexpectedly.\n";
}
$cfg->configure_paths;
$cfg->configure_from_options;
$cfg->configure_refine_vars;
$cfg->configure_relocatability;
$cfg->configure_repo_urls;
$cfg->configure_commands;
$cfg->configure_misc;
$cfg->configure_backends;
# Save options in config.status
$cfg->save_config_status;
$cfg->options->{'gen-nqp'} ||= '' if $cfg->has_option('gen-moar');
$cfg->gen_nqp;
$cfg->configure_active_backends;
$cfg->expand_template;
unless ( $cfg->opt('expand') ) {
my $make = $cfg->cfg('make');
unless ( $cfg->opt('no-clean') ) {
no warnings;
print "Cleaning up ...\n";
if ( open my $CLEAN, '-|', "$make clean" ) {
my @slurp = <$CLEAN>;
close($CLEAN);
}
}
if ( $cfg->opt('make-install') ) {
system_or_die($make);
system_or_die( $make, 'install' );
print "\n$lang has been built and installed.\n";
}
else {
print "\nYou can now use '$make' to build $lang.\n";
print "After that, '$make test' will run some tests and\n";
print "'$make install' will install $lang.\n";
}
}
exit 0;
}
# Print some help text.
sub print_help {
print <<"END";
Configure.pl - $lang Configure
General Options:
--help Show this text
--prefix=<path> Install files in dir; also look for executables there
--libdir=<path> Install architecture-specific files in dir; Perl6 modules
included
--no-relocatable
Create a perl6 with a fixed NQP and Perl6 home dir
instead of dynamically identifying it (On AIX MoarVM is
always built non-relocatable, since AIX misses
a necessary mechanism.)
--sdkroot=<path> When given, use for searching build tools here, e.g.
nqp, java, node etc.
--sysroot=<path> When given, use for searching runtime components here
--backends=jvm,moar,js
Which backend(s) to use (or ALL for all of them)
--gen-nqp[=branch]
Download, build, and install a copy of NQP before writing
the Makefile
--gen-moar[=branch]
Download, build, and install a copy of MoarVM to use
before writing the Makefile
--with-nqp=<path>
Provide path to already installed nqp
--make-install Install Rakudo after configuration is done
--moar-option='--option=value'
Options to pass to MoarVM's Configure.pl
For example: --moar-option='--compiler=clang'
--github-user=<user>
Fetch all repositories (rakudo, nqp, roast, MoarVM) from
this github user. Note that the user must have all
required repos forked from the originals.
--rakudo-repo=<url>
--nqp-repo=<url>
--moar-repo=<url>
--roast-repo=<url>
User-defined URL to fetch corresponding components
from. The URL will also be used to setup git push.
--git-protocol={ssh,https,git}
Protocol used for cloning git repos
--git-depth=<number>
Use the --git-depth option for git clone with parameter number
--git-reference=<path>
Use --git-reference option to identify local path where git repositories are stored
For example: --git-reference=/home/user/repo/for_perl6
Folders 'nqp' and 'MoarVM' with corresponding git repos should be in for_perl6 folder
--makefile-timing Enable timing of individual makefile commands
--no-clean Skip cleanup before installation
--ignore-errors Ignore errors (such as the version of NQP)
--expand=<template>
Expand template file. With this option Makefile is not
generated. The result is send to stdout unless --out
specified.
--out=<file> Filename to send output of --expand into.
--set-var="config_variable=value"
Sets a config_variable to "value". Can be used multiple
times.
Please note that the --gen-moar and --gen-nqp options are there for convenience
only and will actually immediately - at Configure time - compile and install
moar and nqp respectively. They will live under the path given to --prefix,
unless other targeting options are used. To configure how MoarVM should be
compiled, use the --moar-option flag and view MoarVM's Configure.pl for more
information on its configuration options.
Configure.pl also reads options from 'config.default' in the current directory.
END
return;
}
# Local Variables:
# mode: cperl
# cperl-indent-level: 4
# fill-column: 100
# End:
# vim: expandtab shiftwidth=4: