/
Configure.nqp
55 lines (43 loc) · 1.58 KB
/
Configure.nqp
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
# Purpose: Use Parrot's config info to configure our Makefile.
#
# Usage:
# parrot_nqp Configure.nqp
# TODO: The PARROTREVISON file contains a minimum svn revision of Parrot that is
# needed to make this build. Check that we meet that minimum requirement.
our @ARGS;
our %VM;
our $OS;
MAIN();
sub MAIN () {
# Wave to the friendly users
say("Hello, I'm Configure. My job is to poke and prod your system");
say("to figure out how to build parrot-linear-algebra.\n");
# Load Parrot config and glue functions
pir::load_bytecode('PGE.pbc');
pir::load_bytecode('config/config-helpers.pir');
# Slurp in the unconfigured Makefile text
my $unconfigured := slurp(@ARGS[0] || 'config/Makefile.in');
# Set up our custom @foo@ markers.
if ($OS ne 'openbsd') {
%VM<config>{'linkblas'} := '-lblas';
}
# Replace all of the @foo@ markers
my $replaced := subst($unconfigured, rx('\@<ident>\@'), replacement);
# Fix paths on Windows
if ($OS eq 'MSWin32') {
$replaced := subst($replaced, rx('/'), '\\');
}
# Spew out the final makefile
spew(@ARGS[1] || 'Makefile', $replaced);
# Give the user a hint of next action
say("Configure completed.");
say("You can now type '" ~ %VM<config><make> ~ "' to build parrot-linear-algebra.\n");
say("You may also type '" ~ %VM<config><make> ~ " test' to run the test suite.\n");
say("Happy Hacking,");
say("\tThe parrot-linear-algebra Team");
}
sub replacement ($match) {
my $key := $match<ident>;
my $config := %VM<config>{$key} || '';
return $config;
}