Skip to content

Commit c47fee1

Browse files
committed
Stub ConfigureMoar.pl and Makefile-Moar.in.
1 parent f90f0ae commit c47fee1

File tree

2 files changed

+148
-0
lines changed

2 files changed

+148
-0
lines changed

ConfigureMoar.pl

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
#! perl
2+
# Copyright (C) 2009-2013 The Perl Foundation
3+
4+
use 5.008;
5+
use strict;
6+
use warnings;
7+
use Text::ParseWords;
8+
use Getopt::Long;
9+
use Cwd qw(cwd realpath);
10+
use lib "tools/lib";
11+
use NQP::Configure qw(fill_template_file fill_template_text
12+
slurp system_or_die sorry);
13+
14+
MAIN: {
15+
if (-r "config.default") {
16+
unshift @ARGV, shellwords(slurp('config.default'));
17+
}
18+
19+
my %config;
20+
$config{'nqp_config_status'} = join(' ', map { "\"$_\""} @ARGV);
21+
22+
my %options;
23+
GetOptions(\%options, 'help!', 'prefix=s',
24+
'make-install!', 'makefile-timing!', 'no-clean!');
25+
26+
# Print help if it's requested
27+
if ($options{'help'}) {
28+
print_help();
29+
exit(0);
30+
}
31+
32+
my $prefix = $options{'prefix'} || die "--prefix is required";
33+
$prefix = realpath($prefix);
34+
my $slash = $^O eq 'MSWin32' ? '\\' : '/';
35+
36+
# Save options in config.status
37+
unlink('config.status');
38+
if (open(my $CONFIG_STATUS, '>', 'config.status')) {
39+
print $CONFIG_STATUS
40+
"$^X Configure.pl $config{'nqp_config_status'} \$*\n";
41+
close($CONFIG_STATUS);
42+
}
43+
44+
my @errors;
45+
46+
my $moar_path = "$prefix${slash}bin${slash}moar" . ($^O =~ /MSWin32/ ? '.exe' : '');
47+
my @moar_info = `$moar_path --help`;
48+
my $moar_found = 0;
49+
for (@moar_info) {
50+
if (/USAGE: moar/) {
51+
$moar_found = 1;
52+
last;
53+
}
54+
}
55+
if (!$moar_found) {
56+
push @errors,
57+
"No MoarVM (moar executable) found using the --prefix";
58+
}
59+
60+
sorry(@errors) if @errors;
61+
62+
$config{'makefile-timing'} = $options{'makefile-timing'};
63+
$config{'stagestats'} = '--stagestats' if $options{'makefile-timing'};
64+
$config{'shell'} = $^O eq 'MSWin32' ? 'cmd' : 'sh';
65+
$config{'make'} = $^O eq 'MSWin32' ? 'nmake' : 'make';
66+
$config{'cpsep'} = $^O eq 'MSWin32' ? ';' : ':';
67+
$config{'slash'} = $slash;
68+
$config{'runner'} = $^O eq 'MSWin32' ? 'nqp.bat' : 'nqp';
69+
$config{'prefix'} = $prefix;
70+
71+
fill_template_file('tools/build/Makefile-Moar.in', 'Makefile', %config);
72+
73+
my $make = $config{'make'};
74+
unless ($options{'no-clean'}) {
75+
no warnings;
76+
print "Cleaning up ...\n";
77+
if (open my $CLEAN, '-|', "$make clean") {
78+
my @slurp = <$CLEAN>;
79+
close($CLEAN);
80+
}
81+
}
82+
83+
if ($options{'make-install'}) {
84+
system_or_die($make);
85+
system_or_die($make, 'install');
86+
print "\nNQP has been built and installed.\n";
87+
}
88+
else {
89+
print "You can now use '$make' to build NQP.\n";
90+
print "After that, '$make test' will run some tests and\n";
91+
print "'$make install' will install NQP.\n";
92+
}
93+
94+
exit 0;
95+
}
96+
97+
98+
# Print some help text.
99+
sub print_help {
100+
print <<'END';
101+
Configure.pl - NQP Configure
102+
103+
General Options:
104+
--help Show this text
105+
--prefix=dir Indicates prefix of MoarVM installation
106+
--make-install Automatically run make & make install
107+
--makefile-timing Enable timing of individual makefile commands
108+
--no-clean Do not run make clean
109+
110+
Configure.pl also reads options from 'config.default' in the current directory.
111+
END
112+
113+
return;
114+
}
115+
116+
# Local Variables:
117+
# mode: cperl
118+
# cperl-indent-level: 4
119+
# fill-column: 100
120+
# End:
121+
# vim: expandtab shiftwidth=4:

tools/build/Makefile-Moar.in

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
PERL = perl
2+
PROVE = prove
3+
4+
PREFIX = @prefix@
5+
BIN_DIR = $(PREFIX)/bin
6+
MOAR = $(BIN_DIR)/moar
7+
NQP_LANG_DIR = $(PREFIX)/languages/nqp
8+
9+
MKPATH = $(PERL) -MExtUtils::Command -e mkpath
10+
CP = $(PERL) -MExtUtils::Command -e cp
11+
CHMOD = $(PERL) -MExtUtils::Command -e chmod
12+
13+
STAGE0 = src/vm/moar/stage0
14+
STAGE1 = src/stage1
15+
STAGE2 = src/stage2
16+
17+
STAGE0_NQP = $(MOAR) --libpath=$(STAGE0) $(STAGE0)/nqp.moarvm --bootstrap
18+
STAGE1_NQP = $(MOAR) --libpath=$(STAGE1) $(STAGE1)/nqp.moarvm --bootstrap
19+
20+
all:
21+
echo "to do"
22+
23+
clean:
24+
$(PERL) -MExtUtils::Command -e rm_rf *.moarvm src/stage1 src/stage2 nqp nqp.bat
25+
26+
# nqp::makefile <-- tells NQP::Configure to treat this file as a makefile,
27+
# performing win32 slash and makefile conversions

0 commit comments

Comments
 (0)