Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Stub ConfigureJVM.pl and Makefile-JVM.in.
  • Loading branch information
jnthn committed Apr 14, 2013
1 parent 811d92c commit 7c34883
Show file tree
Hide file tree
Showing 2 changed files with 139 additions and 0 deletions.
128 changes: 128 additions & 0 deletions ConfigureJVM.pl
@@ -0,0 +1,128 @@
#! perl
# Copyright (C) 2009-2013 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(fill_template_file fill_template_text
slurp system_or_die sorry);

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',
'make-install!', 'makefile-timing!');

# Print help if it's requested
if ($options{'help'}) {
print_help();
exit(0);
}

my $prefix = $options{'prefix'} || cwd().'/install';

# 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 @errors;

my $got;
if (!@errors) {
my @jvm_info = `java -showversion 2>&1`;
my $jvm_found = 0;
my $jvm_ok = 0;
for (@jvm_info) {
if (/java version "(\d+)\.(\d+)/) {
$jvm_found = 1;
if ($1 > 1 || $1 == 1 && $2 >= 7) {
$jvm_ok = 1;
}
$got = $_;
last;
}
}

if (!$jvm_found) {
push @errors,
"No JVM (java executable) in path; cannot continue";
}
elsif (!$jvm_ok) {
push @errors,
"Need at least JVM 1.7 (got $got)";
}
}

sorry(@errors) if @errors;

print "Using $got\n";

$config{'makefile-timing'} = $options{'makefile-timing'};
$config{'stagestats'} = '--stagestats' if $options{'makefile-timing'};
$config{'shell'} = $^O eq 'MSWin32' ? 'cmd' : 'sh';
$config{'make'} = $^O eq 'MSWin32' ? 'nmake' : 'make';

fill_template_file('tools/build/Makefile-JVM.in', 'Makefile', %config);

my $make = $config{'make'};
{
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
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:
11 changes: 11 additions & 0 deletions tools/build/Makefile-JVM.in
@@ -0,0 +1,11 @@
JAVA = java
JAVAC = javac
JAR = jar
PERL = perl
PROVE = prove

all:
echo TODO

clean:
$(PERL) -MExtUtils::Command -e rm_rf *.class *.jar src/stage1 src/stage2 bin

0 comments on commit 7c34883

Please sign in to comment.