-
Notifications
You must be signed in to change notification settings - Fork 0
/
Configure.pl
189 lines (156 loc) · 5.97 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
#! perl
# Copyright (C) 2009 The Perl Foundation
use 5.008;
use strict;
use warnings;
use Text::ParseWords;
use Getopt::Long;
use Cwd;
use lib "tools/lib";
use NQP::Configure qw(cmp_rev read_parrot_config
fill_template_file fill_template_text
slurp system_or_die verify_install sorry gen_parrot);
MAIN: {
if (-r "config.default") {
unshift @ARGV, shellwords(slurp('config.default'));
}
my %config;
$config{'nqp_config_status'} = join(' ', map { "\"$_\""} @ARGV);
my $exe = $NQP::Configure::exe;
my %options;
GetOptions(\%options, 'help!', 'prefix=s',
'with-parrot=s', 'gen-parrot:s',
'make-install!', 'makefile-timing!',
'parrot-config=s', 'parrot-option=s@');
# Print help if it's requested
if ($options{'help'}) {
print_help();
exit(0);
}
# Deprecated --parrot-config option
if ($options{'parrot-config'}) {
sorry "The --parrot-config option has been removed.",
"Use --with-parrot to specify the parrot executable to use."
}
my $prefix = $options{'prefix'} || cwd().'/install';
my $with_parrot = $options{'with-parrot'};
my $gen_parrot = $options{'gen-parrot'};
# Save options in config.status
unlink('config.status');
if (open(my $CONFIG_STATUS, '>', 'config.status')) {
print $CONFIG_STATUS
"$^X Configure.pl $config{'nqp_config_status'} \$*\n";
close($CONFIG_STATUS);
}
my ($par_want) = split(' ', slurp('tools/build/PARROT_REVISION'));
if (defined $gen_parrot) {
$with_parrot = gen_parrot($par_want, %options, prefix => $prefix);
}
my @errors;
my %par_config;
if ($with_parrot) {
%par_config = read_parrot_config($with_parrot)
or push @errors, "Unable to read configuration from $with_parrot.";
}
else {
%par_config = read_parrot_config("$prefix/bin/parrot$exe", "parrot$exe")
or push @errors, "Unable to find parrot.";
$with_parrot = fill_template_text('@bindir@/parrot@exe@', %par_config);
}
%config = (%config, %par_config);
my $par_have = $config{'parrot::git_describe'} || '';
if ($par_have && cmp_rev($par_have, $par_want) < 0) {
push @errors, "Parrot revision $par_want required (currently $par_have).";
}
if (!@errors) {
push @errors, verify_install([@NQP::Configure::required_parrot_files],
%config);
push @errors,
"(Perhaps you need to 'make install', 'make install-dev',",
"or install the 'devel' package for Parrot?)"
if @errors;
}
if (@errors && !defined $gen_parrot) {
push @errors,
"\nTo automatically clone (git) and build a copy of Parrot $par_want,",
"try re-running Configure.pl with the '--gen-parrot' option.",
"Or, use '--with-parrot=' to explicitly specify the Parrot",
"executable to use to build NQP.";
}
sorry(@errors) if @errors;
print "Using $with_parrot (version $config{'parrot::git_describe'}).\n";
$config{'makefile-timing'} = $options{'makefile-timing'};
$config{'stagestats'} = '--stagestats' if $options{'makefile-timing'};
$config{'shell'} = $^O eq 'MSWin32' ? 'cmd' : 'sh';
if ($^O eq 'MSWin32' or $^O eq 'cygwin') {
$config{'dll'} = '$(PARROT_BIN_DIR)/$(PARROT_LIB_SHARED)';
$config{'dllcopy'} = '$(PARROT_LIB_SHARED)';
$config{'make_dllcopy'} =
'$(PARROT_DLL_COPY) : $(PARROT_DLL)'."\n\t".'$(CP) $(PARROT_DLL) .';
}
my $make = fill_template_text('@make@', %config);
if ($make eq 'nmake') {
system_or_die('cd 3rdparty\dyncall && Configure.bat' .
($config{'parrot::archname'} =~ /x64/ ? ' /target-x64' : ''));
$config{'dyncall_build'} = 'cd 3rdparty\dyncall && nmake Nmakefile';
}
else {
if ($^O eq 'MSWin32') {
my $configure_args =
$config{'parrot::archname'} =~ /x86/ ? ' /target-x86' : ' /target-x64';
$configure_args .= $config{'parrot::cc'} eq 'gcc' ? ' /tool-gcc' : '';
system_or_die('cd 3rdparty\dyncall && Configure.bat' . $configure_args);
$config{'dyncall_build'} = "cd 3rdparty/dyncall && $make BUILD_DIR=. -f GNUmakefile";
} else {
system_or_die('cd 3rdparty/dyncall && sh configure');
if ($^O eq 'netbsd') {
$config{'dyncall_build'} = "cd 3rdparty/dyncall && BUILD_DIR=. $make -f BSDmakefile";
} else {
$config{'dyncall_build'} = "cd 3rdparty/dyncall && BUILD_DIR=. $make";
}
}
}
fill_template_file('tools/build/Makefile.in', 'Makefile', %config);
{
no warnings;
print "Cleaning up ...\n";
if (open my $CLEAN, '-|', "$make clean") {
my @slurp = <$CLEAN>;
close($CLEAN);
}
}
if ($options{'make-install'}) {
system_or_die($make);
system_or_die($make, 'install');
print "\nNQP has been built and installed.\n";
}
else {
print "You can now use '$make' to build NQP.\n";
print "After that, '$make test' will run some tests and\n";
print "'$make install' will install NQP.\n";
}
exit 0;
}
# Print some help text.
sub print_help {
print <<'END';
Configure.pl - NQP Configure
General Options:
--help Show this text
--prefix=dir Install files in dir
--with-parrot=path/to/bin/parrot
Parrot executable to use to build NQP
--gen-parrot[=branch]
Download and build a copy of Parrot to use
--parrot-option='--option=value'
Options to pass to parrot configuration for --gen-parrot
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: