Skip to content
Newer
Older
100644 167 lines (131 sloc) 3.59 KB
04f9724 Add configure script, piggy-backing on parrot's reconfigure to generate
wcoleda authored
1 #! perl
2
3 use strict;
4 use warnings;
be1652f Add a command-line option to Configure.pl, to pass in a full path to …
wcoleda authored
5 use Getopt::Long;
8f955a7 @leto Remove svn cruft from Configure.pl and borrow moritz++'s code to pars…
leto authored
6 use Data::Dumper;
04f9724 Add configure script, piggy-backing on parrot's reconfigure to generate
wcoleda authored
7
c88d762 Add Parrot::Installed.pm
wcoleda authored
8 use Fatal qw(open);
9
be1652f Add a command-line option to Configure.pl, to pass in a full path to …
wcoleda authored
10 my %options;
11 GetOptions(\%options, 'parrot-config=s', 'help|?') or usage();
12 usage() if $options{'help'};
13
14 my $config = $options{'parrot-config'} || "parrot_config";
15
c5d9eb6 make it easier to pull in more parrot config info
wcoleda authored
16 my %opt;
17
46189ca Issue 87 - add a warning if ICU is not present.
wcoleda authored
18 my @keys = qw(
19 bindir
20 has_icu
21 libdir
22 make
23 perl
85ac914 @leto Fetch the sha1 and git_describe config keys, and turn the version che…
leto authored
24 sha1
25 git_describe
46189ca Issue 87 - add a warning if ICU is not present.
wcoleda authored
26 slash
27 VERSION
28 versiondir
29 );
c5d9eb6 make it easier to pull in more parrot config info
wcoleda authored
30
31 foreach my $key (@keys) {
32 my $value = `$config $key`
92f0bf9 Require a minimum parrot revision or release.
wcoleda authored
33 or die "Unable to find parrot_config, $config\n";
c5d9eb6 make it easier to pull in more parrot config info
wcoleda authored
34 chomp $value;
35 $opt{$key} = $value;
36 }
37
92f0bf9 Require a minimum parrot revision or release.
wcoleda authored
38 # Which version of parrot do we need?
8f955a7 @leto Remove svn cruft from Configure.pl and borrow moritz++'s code to pars…
leto authored
39 open my $cfh, '<', 'config/PARROT_GIT_DESCRIBE';
92f0bf9 Require a minimum parrot revision or release.
wcoleda authored
40 while (<$cfh>) {
41 next if /^#/;
42 next if /^\s+$/;
cefe45f @coke Change diagnostic message to be more user-friendly
coke authored
43 warn "Using parrot version: " . $opt{git_describe} . "\n";
92f0bf9 Require a minimum parrot revision or release.
wcoleda authored
44 }
45
46189ca Issue 87 - add a warning if ICU is not present.
wcoleda authored
46 warn <<END_WARN
47 !! Partcl relies on ICU, which is not linked with this parrot.
48 Some features may not work.
49
50 END_WARN
51 unless $opt{has_icu};
52
d034e86 @coke We are using git for version control now, can't use svn/git-svn to ge…
coke authored
53 my $partcl_revision = `$^X tools/rev.pl`;
133bf68 improve smolder support.
wcoleda authored
54
c5d9eb6 make it easier to pull in more parrot config info
wcoleda authored
55 my $build_tool = $opt{perl} . ' '
56 . $opt{libdir}
57 . $opt{versiondir}
58 . $opt{slash}
59 . 'tools'
60 . $opt{slash}
61 . 'dev'
62 . $opt{slash}
63 . 'gen_makefile.pl';
72b645a Move closer to building against an installed parrot.
wcoleda authored
64
65 my %makefiles = (
66 "config/makefiles/root.in" => "Makefile",
67 );
68
69 foreach my $template (keys %makefiles) {
70 my $makefile = $makefiles{$template};
71 print "Creating $makefile\n";
133bf68 improve smolder support.
wcoleda authored
72 if (system("$build_tool $template $makefile --partcl_revision=$partcl_revision") != 0) {
c5d9eb6 make it easier to pull in more parrot config info
wcoleda authored
73 die "Unable to create makefile; did you run parrot's 'make install-dev' ?\n";
74 }
72b645a Move closer to building against an installed parrot.
wcoleda authored
75 }
76
8f955a7 @leto Remove svn cruft from Configure.pl and borrow moritz++'s code to pars…
leto authored
77 sub parse_git_describe {
78 my $g = shift;
79 $g =~ /^REL(?:EASE)?_(\d+)_(\d+)_(\d+)-(\d+)-g[a-f0-9]*$/
80 or die "Invalid revision specifier: '$g' "
81 ."(expected something of format RELEASE_1_2_3-123-gdeadbee)\n";
82 my @c = ($1, $2, $3, $4);
83 return @c;
84 }
85
86 sub compare_describe_strings {
87 my ($s1, $s2) = @_;
88 my @a = parse_git_describe($s1);
89 my @b = parse_git_describe($s2);
90 for (0..3) {
91 my $cmp = $a[$_] <=> $b[$_];
92 return $cmp if $cmp;
93 }
94 return 0;
95 }
96
97
c88d762 Add Parrot::Installed.pm
wcoleda authored
98
99 print "Creating Parrot::Installed\n";
100
101 open my $fh, '>', 'lib/Parrot/Installed.pm';
102
103 print {$fh} "package Parrot::Installed;\n";
c5d9eb6 make it easier to pull in more parrot config info
wcoleda authored
104 print {$fh} "use lib qw($opt{libdir}$opt{versiondir}/tools/lib);\n";
c88d762 Add Parrot::Installed.pm
wcoleda authored
105 print {$fh} "1;\n";
106
d7c074d Instead of having a hardcoded shebang for the parrot only tests,
wcoleda authored
107 print "Generating miscellaneous files\n";
108
c5d9eb6 make it easier to pull in more parrot config info
wcoleda authored
109 my $parrot = "$opt{bindir}/parrot";
c741adc - make tools/spectcl a generated file to track parrot location
wcoleda authored
110 add_shebang($parrot, 't/internals/select_switches.t', 'config/misc/select_switches_t.in');
111 add_shebang($parrot, 't/internals/select_option.t', 'config/misc/select_option_t.in');
112 replace_parrot($parrot, 'tools/spectcl', 'config/misc/spectcl.in');
113 chmod 0755, 'tools/spectcl';
d7c074d Instead of having a hardcoded shebang for the parrot only tests,
wcoleda authored
114
72b645a Move closer to building against an installed parrot.
wcoleda authored
115 print <<"END";
116
c5d9eb6 make it easier to pull in more parrot config info
wcoleda authored
117 You can now use '$opt{make}' to build partcl.
72b645a Move closer to building against an installed parrot.
wcoleda authored
118 END
119
120 exit;
be1652f Add a command-line option to Configure.pl, to pass in a full path to …
wcoleda authored
121
122 sub usage {
123 die <<"EOM"
124 Usage: $0 [--parrot-config=/path/to/parrot_config]
125 EOM
126 }
d7c074d Instead of having a hardcoded shebang for the parrot only tests,
wcoleda authored
127
128 sub add_shebang {
129 my $exe = shift;
130 my $target = shift;
131 my $source = shift;
132
133 my $shebang = "#!$exe";
134
135 my $contents;
136 {
137 local undef $/;
138 open my $fh, '<', $source;
139 $contents = <$fh>;
140 }
c5d9eb6 make it easier to pull in more parrot config info
wcoleda authored
141
d7c074d Instead of having a hardcoded shebang for the parrot only tests,
wcoleda authored
142 open my $ofh, '>', $target;
143 print {$ofh} $shebang, "\n";
144 print {$ofh} $contents;
145 }
c741adc - make tools/spectcl a generated file to track parrot location
wcoleda authored
146
147 # This is like gen_makefiles, but that adds an inappropriate header.
148 sub replace_parrot {
149 my $exe = shift;
150 my $target = shift;
151 my $source = shift;
152
153 my $contents;
154 {
155 local undef $/;
156 open my $fh, '<', $source;
157 $contents = <$fh>;
158 }
159 $contents =~ s/\@parrot\@/$exe/g;
160
161 open my $ofh, '>', $target;
162 print {$ofh} $contents;
163 }
92f0bf9 Require a minimum parrot revision or release.
wcoleda authored
164
165 # Convert dotted version to an int.
166 sub version_int { sprintf('%d%03d%03d', split(/\./, $_[0]))}
Something went wrong with that request. Please try again.