Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 553 lines (402 sloc) 11.327 kb
11b744f @simoncozens Configure system from Brent Dax <brentdax@cpan.org>
simoncozens authored
1 #!/usr/bin/perl -w
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
2 #
3 # Configure.pl
4 #
5 # $Id$
6 #
7 # Author: Brent Dax
8 #
11b744f @simoncozens Configure system from Brent Dax <brentdax@cpan.org>
simoncozens authored
9
10 use strict;
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
11
11b744f @simoncozens Configure system from Brent Dax <brentdax@cpan.org>
simoncozens authored
12 use Config;
205f653 @brentdax Win32 compatibility, Configure hints, 5.005 compatibility, MANIFEST chec...
brentdax authored
13 use Getopt::Long;
59345b3 @brentdax Fix issues with ivsize and nvsize
brentdax authored
14 use ExtUtils::Manifest qw(manicheck);
6b3e60e Patch from Jason Diamond to make win32 platform stuff work:
Gregor N. Purdy authored
15 use File::Copy;
19fa0d4 @tomhughes Stop Configure trying to make op_info.c and op.h as op_info.c no longer
tomhughes authored
16
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
17 use Parrot::BuildUtil;
18
19
20 #
21 # Read the array and scalar forms of the version.
22 # from the VERSION file.
23 #
24
25 my $parrot_version = parrot_version();
26 my @parrot_version = parrot_version();
27
28
29 #
30 # Handle options:
31 #
32
59345b3 @brentdax Fix issues with ivsize and nvsize
brentdax authored
33 my($opt_debugging, $opt_defaults, $opt_version, $opt_help) = (0, 0, 0, 0);
34 my(%opt_defines);
19fa0d4 @tomhughes Stop Configure trying to make op_info.c and op.h as op_info.c no longer
tomhughes authored
35 my $result = GetOptions(
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
36 'debugging!' => \$opt_debugging,
37 'defaults!' => \$opt_defaults,
38 'version' => \$opt_version,
39 'help' => \$opt_help,
40 'define=s' => \%opt_defines,
205f653 @brentdax Win32 compatibility, Configure hints, 5.005 compatibility, MANIFEST chec...
brentdax authored
41 );
42
59345b3 @brentdax Fix issues with ivsize and nvsize
brentdax authored
43 if($opt_version) {
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
44 print "Parrot Version $parrot_version Configure\n";
45 print '$Id$' . "\n";
46 exit;
205f653 @brentdax Win32 compatibility, Configure hints, 5.005 compatibility, MANIFEST chec...
brentdax authored
47 }
48
59345b3 @brentdax Fix issues with ivsize and nvsize
brentdax authored
49 if($opt_help) {
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
50 print <<"EOT";
205f653 @brentdax Win32 compatibility, Configure hints, 5.005 compatibility, MANIFEST chec...
brentdax authored
51 $0 - Parrot Configure
52 Options:
53 --debugging Enable debugging
54 --defaults Accept all default values
55 --define name=value Defines value name as value
56 --help This text
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
57 --version Show version
205f653 @brentdax Win32 compatibility, Configure hints, 5.005 compatibility, MANIFEST chec...
brentdax authored
58 EOT
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
59 exit;
205f653 @brentdax Win32 compatibility, Configure hints, 5.005 compatibility, MANIFEST chec...
brentdax authored
60 }
11b744f @simoncozens Configure system from Brent Dax <brentdax@cpan.org>
simoncozens authored
61
1d93957 @simoncozens Configure now generates Makefile
simoncozens authored
62 my($DDOK)=undef;
63 eval {
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
64 require Data::Dumper;
65 Data::Dumper->import();
66 $DDOK=1;
1d93957 @simoncozens Configure now generates Makefile
simoncozens authored
67 };
68
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
69 #
70 # print the header
71 #
72
11b744f @simoncozens Configure system from Brent Dax <brentdax@cpan.org>
simoncozens authored
73 print <<"END";
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
74 Parrot Version $parrot_version Configure
75 Copyright (C) 2001-2002 Yet Another Society
11b744f @simoncozens Configure system from Brent Dax <brentdax@cpan.org>
simoncozens authored
76
77 Since you're running this script, you obviously have
78 Perl 5--I'll be pulling some defaults from its configuration.
79
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
80 Checking the MANIFEST to make sure you have a complete Parrot kit...
11b744f @simoncozens Configure system from Brent Dax <brentdax@cpan.org>
simoncozens authored
81 END
82
59345b3 @brentdax Fix issues with ivsize and nvsize
brentdax authored
83 check_manifest();
205f653 @brentdax Win32 compatibility, Configure hints, 5.005 compatibility, MANIFEST chec...
brentdax authored
84
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
85 #
86 # Some versions don't seem to have ivtype or nvtype--provide
87 # defaults for them.
88 # XXX Figure out better defaults
89 #
88663c9 Initial JIT implementation.
Gregor N. Purdy authored
90
729af11 Attempt to fix Win32 builds.
Gregor N. Purdy authored
91 my ($archname, $cpuarch, $osname);
ee77a0a Both test_parrot (via test_main.c) and the intepreter itself (via
Gregor N. Purdy authored
92 my ($jitarchname, $jitcpuarch, $jitosname, $jitcapable);
88663c9 Initial JIT implementation.
Gregor N. Purdy authored
93
729af11 Attempt to fix Win32 builds.
Gregor N. Purdy authored
94 $archname = $Config{archname};
95 ($cpuarch, $osname) = split('-', $archname);
96
55f5eb2 Make jitarch calculation not get tripped up by extra components to
Gregor N. Purdy authored
97 $jitarchname = "$cpuarch-$osname";
729af11 Attempt to fix Win32 builds.
Gregor N. Purdy authored
98 $jitarchname =~ s/-(net|free|open)bsd$/-bsd/i;
ee77a0a Both test_parrot (via test_main.c) and the intepreter itself (via
Gregor N. Purdy authored
99
100 if (-e "Parrot/Jit/$jitarchname.pm") {
101 $jitcapable = 1;
102 }
103 else {
104 $jitcapable = 0;
105 $jitarchname = 'i386-nojit';
106 }
729af11 Attempt to fix Win32 builds.
Gregor N. Purdy authored
107
108 ($jitcpuarch, $jitosname) = split('-', $jitarchname);
88663c9 Initial JIT implementation.
Gregor N. Purdy authored
109
11b744f @simoncozens Configure system from Brent Dax <brentdax@cpan.org>
simoncozens authored
110 my(%c)=(
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
111 iv => ($Config{ivtype} || 'long'),
112 intvalsize => undef,
113
114 nv => ($Config{nvtype} || 'double'),
115 numvalsize => undef,
116
117 opcode_t => ($Config{ivtype} || 'long'),
118 longsize => undef,
119
120 cc => $Config{cc},
121
122 #
123 # ADD C COMPILER FLAGS HERE
124 #
125
126 ccflags => $Config{ccflags},
127 libs => $Config{libs},
128 cc_debug => '-g',
129 o => '.o', # object files extension
130 exe => $Config{_exe},
131
132 ld => $Config{ld},
133 ld_out => '-o ', # ld output file
134 ld_debug => '', # include debug info in executable
135
136 perl => $^X,
137 test_prog => 'test_parrot' . $Config{_exe},
138 debugging => $opt_debugging,
139 rm_f => 'rm -f',
140 stacklow => '(~0xfff)',
141 intlow => '(~0xfff)',
142 numlow => '(~0xfff)',
143 strlow => '(~0xfff)',
144 pmclow => '(~0xfff)',
145 make => $Config{make},
146 make_set_make => $Config{make_set_make},
147
148 platform => $^O,
149
150 cpuarch => $cpuarch,
151 osname => $osname,
152 archname => $archname,
153
154 jitcpuarch => $jitcpuarch,
155 jitosname => $jitosname,
156 jitarchname => $jitarchname,
157 jitcapable => $jitcapable,
158
159 cp => 'cp',
160 slash => '/',
161
162 VERSION => $parrot_version,
163 MAJOR => $parrot_version[0],
164 MINOR => $parrot_version[1],
165 PATCH => $parrot_version[2],
11b744f @simoncozens Configure system from Brent Dax <brentdax@cpan.org>
simoncozens authored
166 );
167
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
168
169 #
170 # Copy the things from --define foo=bar
171 #
172
5cac2b3 @brentdax Cleaner VMS support, more info for Parrot::Config to remember, more flex...
brentdax authored
173 @c{keys %opt_defines}=values %opt_defines;
205f653 @brentdax Win32 compatibility, Configure hints, 5.005 compatibility, MANIFEST chec...
brentdax authored
174
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
175
176 #
177 # Set up default values
178 #
179
59345b3 @brentdax Fix issues with ivsize and nvsize
brentdax authored
180 my $hints = "hints/" . lc($^O) . ".pl";
181 if(-f $hints) {
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
182 local($/);
183 open HINT, "< $hints" or die "Unable to open hints file '$hints'";
184 my $hint = <HINT>;
185 close HINT;
186 eval $hint or die "Error in hints file $hints: '$@/$!'";
205f653 @brentdax Win32 compatibility, Configure hints, 5.005 compatibility, MANIFEST chec...
brentdax authored
187 }
188
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
189
190 #
191 # Ask questions
192 #
193
1d93957 @simoncozens Configure now generates Makefile
simoncozens authored
194 prompt("What C compiler do you want to use?", 'cc');
205f653 @brentdax Win32 compatibility, Configure hints, 5.005 compatibility, MANIFEST chec...
brentdax authored
195 prompt("How about your linker?", 'ld');
1d93957 @simoncozens Configure now generates Makefile
simoncozens authored
196 prompt("What flags would you like passed to your C compiler?", 'ccflags');
197 prompt("Which libraries would you like your C compiler to include?", 'libs');
11b744f @simoncozens Configure system from Brent Dax <brentdax@cpan.org>
simoncozens authored
198 prompt("How big would you like integers to be?", 'iv');
205f653 @brentdax Win32 compatibility, Configure hints, 5.005 compatibility, MANIFEST chec...
brentdax authored
199 prompt("And your floats?", 'nv');
7af7b70 Changed opcode_t from a union to a configurable type.
Tanton Gibbs authored
200 prompt("What is your native opcode type?", 'opcode_t');
11b744f @simoncozens Configure system from Brent Dax <brentdax@cpan.org>
simoncozens authored
201
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
202
203 #
971ed20 Made things a bit more platform-independent. Makefile still
Dan Sugalski authored
204 # Copy the appropriate platform-specific file over
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
205 #
206
971ed20 Made things a bit more platform-independent. Makefile still
Dan Sugalski authored
207 if (-e "platforms/$c{platform}.h") {
208 copy("platforms/$c{platform}.h", "include/parrot/platform.h");
209 copy("platforms/$c{platform}.c", "platform.c");
210 }
211 else {
212 copy("platforms/generic.h", "include/parrot/platform.h");
213 copy("platforms/generic.c", "platform.c");
214 }
215
205f653 @brentdax Win32 compatibility, Configure hints, 5.005 compatibility, MANIFEST chec...
brentdax authored
216 unless( $c{debugging} ) {
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
217 $c{ld_debug} = ' ';
218 $c{cc_debug} = ' ';
205f653 @brentdax Win32 compatibility, Configure hints, 5.005 compatibility, MANIFEST chec...
brentdax authored
219 }
11b744f @simoncozens Configure system from Brent Dax <brentdax@cpan.org>
simoncozens authored
220
221 print <<"END";
222
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
223 Probing Perl 5's configuration to determine which headers you have (this could
224 take a while on slow machines)...
11b744f @simoncozens Configure system from Brent Dax <brentdax@cpan.org>
simoncozens authored
225 END
226
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
227
228 #
229 # Set up HAS_HEADER_
230 #
231
11b744f @simoncozens Configure system from Brent Dax <brentdax@cpan.org>
simoncozens authored
232 foreach(grep {/^i_/} keys %Config) {
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
233 $c{$_}=$Config{$_};
234 $c{headers}.=defineifdef((/^i_(.*)$/));
11b744f @simoncozens Configure system from Brent Dax <brentdax@cpan.org>
simoncozens authored
235 }
236
1d93957 @simoncozens Configure now generates Makefile
simoncozens authored
237 print <<"END";
11b744f @simoncozens Configure system from Brent Dax <brentdax@cpan.org>
simoncozens authored
238
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
239 Determining C data type sizes by compiling and running a small C program (this
240 could take a while):
241
59345b3 @brentdax Fix issues with ivsize and nvsize
brentdax authored
242 END
243
5cac2b3 @brentdax Cleaner VMS support, more info for Parrot::Config to remember, more flex...
brentdax authored
244 {
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
245 my %newc;
19fa0d4 @tomhughes Stop Configure trying to make op_info.c and op.h as op_info.c no longer
tomhughes authored
246
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
247 buildfile("test_c");
248 compiletestc();
249 %newc=eval(runtestc()) or die "Can't run the test program: $!";
5cac2b3 @brentdax Cleaner VMS support, more info for Parrot::Config to remember, more flex...
brentdax authored
250
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
251 @c{keys %newc}=values %newc;
5cac2b3 @brentdax Cleaner VMS support, more info for Parrot::Config to remember, more flex...
brentdax authored
252
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
253 unlink('test.c', "test_siz$c{exe}", "test$c{o}");
4c1a2b9 VMS tweaks
Dan Sugalski authored
254 }
59345b3 @brentdax Fix issues with ivsize and nvsize
brentdax authored
255
256 print <<"END";
257
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
258 Figuring out the formats to pass to pack() for the various Parrot internal
259 types...
6fba438 @simoncozens Abstract the argument and opcode packing types and functions out into
simoncozens authored
260 END
261
e5cb406 @brentdax More changes for 64-bit compatibility
brentdax authored
262
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
263 #
9a97be1 @simoncozens The Great Renaming.
simoncozens authored
264 # Alas perl5.7.2 doesn't have an INTVAL flag for pack().
6fba438 @simoncozens Abstract the argument and opcode packing types and functions out into
simoncozens authored
265 # The ! modifier only works for perl 5.6.x or greater.
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
266 #
267
9a97be1 @simoncozens The Great Renaming.
simoncozens authored
268 foreach ('intvalsize', 'opcode_t_size') {
269 my $which = $_ eq 'intvalsize' ? 'packtype_i' : 'packtype_op';
e5cb406 @brentdax More changes for 64-bit compatibility
brentdax authored
270 if (($] >= 5.006) && ($c{$_} == $c{longsize}) ) {
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
271 $c{$which} = 'l!';
e5cb406 @brentdax More changes for 64-bit compatibility
brentdax authored
272 }
273 elsif ($c{$_} == 4) {
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
274 $c{$which} = 'l';
e5cb406 @brentdax More changes for 64-bit compatibility
brentdax authored
275 }
276 else {
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
277 die "Configure.pl: Unable to find a suitable packtype for $_.\n";
e5cb406 @brentdax More changes for 64-bit compatibility
brentdax authored
278 }
6fba438 @simoncozens Abstract the argument and opcode packing types and functions out into
simoncozens authored
279 }
280
281 $c{packtype_n} = 'd';
282
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
283
284 #
285 # Build config.h, the Makfefiles and Types.pm:
286 #
287 # Also build Parrot/Config.pm
288 #
289
6fba438 @simoncozens Abstract the argument and opcode packing types and functions out into
simoncozens authored
290 print <<"END";
291
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
292 Building a preliminary version of include/parrot/config.h, your Makefiles, and
293 other files:
294
1d93957 @simoncozens Configure now generates Makefile
simoncozens authored
295 END
11b744f @simoncozens Configure system from Brent Dax <brentdax@cpan.org>
simoncozens authored
296
62bace3 Committed some files that were missed in the last *.h moving commmit.
Gregor N. Purdy authored
297 buildfile("config_h", "include/parrot");
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
298
1d93957 @simoncozens Configure now generates Makefile
simoncozens authored
299 buildfile("Makefile");
133486e (Hopefully the last time...)
Jeff Goff authored
300 buildfile("classes/Makefile");
38f17ac Added a 'languages' target to the top-level Makefile.in, and modified th...
Gregor N. Purdy authored
301 buildfile("languages/Makefile");
302 buildfile("languages/jako/Makefile");
04ce4cd Build tweaks.
Dan Sugalski authored
303 buildfile("languages/miniperl/Makefile");
304 buildfile("languages/scheme/Makefile");
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
305
6fba438 @simoncozens Abstract the argument and opcode packing types and functions out into
simoncozens authored
306 buildfile("Types_pm", "Parrot");
11b744f @simoncozens Configure system from Brent Dax <brentdax@cpan.org>
simoncozens authored
307
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
308 buildconfigpm();
309
310
311 #
312 # And now we figure out how big our things are
313 #
314
9d000b4 Made the changes to figure out mask bits for various register and stack
Dan Sugalski authored
315 print <<"END";
316
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
317 Checking some things by compiling and running another small C program (this
318 could take a while):
319
9d000b4 Made the changes to figure out mask bits for various register and stack
Dan Sugalski authored
320 END
321
322 {
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
323 my %newc;
19fa0d4 @tomhughes Stop Configure trying to make op_info.c and op.h as op_info.c no longer
tomhughes authored
324
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
325 open NEEDED, ">include/parrot/vtable.h";
326 close NEEDED;
327 buildfile("testparrotsizes_c");
328 compiletestc("testparrotsizes");
329 %newc=eval(runtestc()) or die "Can't run the test program: $!";
9d000b4 Made the changes to figure out mask bits for various register and stack
Dan Sugalski authored
330
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
331 @c{keys %newc}=values %newc;
9d000b4 Made the changes to figure out mask bits for various register and stack
Dan Sugalski authored
332
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
333 @c{qw(stacklow intlow numlow strlow pmclow)} = lowbitmask(@c{qw(stackchunk iregchunk nregchunk sregchunk pregchunk)});
9d000b4 Made the changes to figure out mask bits for various register and stack
Dan Sugalski authored
334
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
335 unlink('testparrotsizes.c', "test_siz$c{exe}", "test$c{o}");
336 unlink("include/parrot/vtable.h");
9d000b4 Made the changes to figure out mask bits for various register and stack
Dan Sugalski authored
337 }
338
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
339
340 #
341 # Rewrite the config file with the updated info
342 #
343
344 print <<"END";
345
346 Updating include/parrot/config.h:
347
348 END
349
9d000b4 Made the changes to figure out mask bits for various register and stack
Dan Sugalski authored
350 buildfile("config_h", "include/parrot");
351
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
352
353 #
354 # Wrap up:
355 #
356
11b744f @simoncozens Configure system from Brent Dax <brentdax@cpan.org>
simoncozens authored
357 print <<"END";
358
359 Okay, we're done!
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
360
361 You can now use `make' (or your platform's equivalent to `make') to build your
362 Parrot. After that, you can use `make test' to run the test suite.
11b744f @simoncozens Configure system from Brent Dax <brentdax@cpan.org>
simoncozens authored
363
364 Happy Hacking,
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
365
366 The Parrot Team
367
11b744f @simoncozens Configure system from Brent Dax <brentdax@cpan.org>
simoncozens authored
368 END
369
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
370 exit(0);
371
372
373 ###############################################################################
374 ###############################################################################
375 ##
376 ## Support Subroutines
377 ##
378 ###############################################################################
379 ###############################################################################
380
381
382 #
383 # defineifdef()
384 #
385 # Give us the #define we may need for header X
386 #
387
11b744f @simoncozens Configure system from Brent Dax <brentdax@cpan.org>
simoncozens authored
388 sub defineifdef {
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
389 my $thing=shift;
390
391 if($Config{"i_$thing"}) {
392 return "#define HAS_HEADER_\U$thing\E\n";
393 }
394 else {
395 return "#undef HAS_HEADER_\U$thing\E\n"; #XXX do we want this?
396 }
11b744f @simoncozens Configure system from Brent Dax <brentdax@cpan.org>
simoncozens authored
397 }
398
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
399
400 #
401 # prompt()
402 #
403 # Prompt for something from the user.
404 #
405
11b744f @simoncozens Configure system from Brent Dax <brentdax@cpan.org>
simoncozens authored
406 sub prompt {
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
407 return if $opt_defaults;
205f653 @brentdax Win32 compatibility, Configure hints, 5.005 compatibility, MANIFEST chec...
brentdax authored
408
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
409 my($message, $field)=(@_);
410 my($input);
411 print "$message [$c{$field}] ";
412 chomp($input=<STDIN>);
413 $c{$field}=$input||$c{$field};
11b744f @simoncozens Configure system from Brent Dax <brentdax@cpan.org>
simoncozens authored
414 }
415
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
416
417 #
418 # buildfile()
419 #
420
1d93957 @simoncozens Configure now generates Makefile
simoncozens authored
421 sub buildfile {
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
422 my($source_filename, $path)=@_;
423 $path||='.';
424
425 my $target_filename = $source_filename;
426 $target_filename =~ s/_/./; #config_h => config.h
1d93957 @simoncozens Configure now generates Makefile
simoncozens authored
427
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
428 printf " Building %-30s from %s...\n", "$path/$target_filename",
429 "$source_filename.in";
1d93957 @simoncozens Configure now generates Makefile
simoncozens authored
430
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
431 local $/;
432 open(IN, "<$source_filename.in") or die "Can't open $source_filename.in: $!";
433 my $text=<IN>;
434 close(IN) or die "Can't close $source_filename.in: $!";
1d93957 @simoncozens Configure now generates Makefile
simoncozens authored
435
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
436 $text =~ s/\$\{(\w+)\}/$c{$1}/g;
437
438 open(OUT, ">$path/$target_filename") or die "Can't open $path/$target_filename: $!";
439 print OUT $text;
440 close(OUT) or die "Can't close $target_filename: $!";
1d93957 @simoncozens Configure now generates Makefile
simoncozens authored
441 }
442
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
443
444 #
445 # buildconfigpm()
446 #
447
1d93957 @simoncozens Configure now generates Makefile
simoncozens authored
448 sub buildconfigpm {
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
449 unless($DDOK) {
450 print <<"END";
1d93957 @simoncozens Configure now generates Makefile
simoncozens authored
451
452 Your system doesn't have Data::Dumper installed, so I couldn't
453 build Parrot::Config. If you want Parrot::Config installed,
454 use CPAN.pm to install Data::Dumper and run this script again.
455 END
456
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
457 return;
458 }
459
460 printf " Building %-30s from %s...\n", "Parrot/Config.pm",
461 "Config_pm.in";
1d93957 @simoncozens Configure now generates Makefile
simoncozens authored
462
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
463 my %C=%c;
464 delete $C{headers};
465 my $dd=new Data::Dumper([\%C]);
466 $dd->Names(['*PConfig']);
1d93957 @simoncozens Configure now generates Makefile
simoncozens authored
467
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
468 local $/;
469 open(IN, "<Config_pm.in") or die "Can't open Config_pm.in: $!";
470 my $text=<IN>;
471 close(IN) or die "Can't close Config.pm_in: $!";
1d93957 @simoncozens Configure now generates Makefile
simoncozens authored
472
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
473 $text =~ s/#DUMPER OUTPUT HERE/$dd->Dump()/eg;
1d93957 @simoncozens Configure now generates Makefile
simoncozens authored
474
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
475 open(OUT, ">Parrot/Config.pm") or die "Can't open file Parrot/Config.pm: $!";
476 print OUT $text;
477 close(OUT) or die "Can't close file Parrot/Config.pm: $!";
1d93957 @simoncozens Configure now generates Makefile
simoncozens authored
478 }
205f653 @brentdax Win32 compatibility, Configure hints, 5.005 compatibility, MANIFEST chec...
brentdax authored
479
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
480
481 #
482 # check_manifest()
483 #
484
205f653 @brentdax Win32 compatibility, Configure hints, 5.005 compatibility, MANIFEST chec...
brentdax authored
485 sub check_manifest {
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
486 print "\n";
205f653 @brentdax Win32 compatibility, Configure hints, 5.005 compatibility, MANIFEST chec...
brentdax authored
487
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
488 my(@missing)=manicheck();
59345b3 @brentdax Fix issues with ivsize and nvsize
brentdax authored
489
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
490 if(@missing) {
491 print <<"END";
205f653 @brentdax Win32 compatibility, Configure hints, 5.005 compatibility, MANIFEST chec...
brentdax authored
492
493 Ack, some files were missing! I can't continue running
19fa0d4 @tomhughes Stop Configure trying to make op_info.c and op.h as op_info.c no longer
tomhughes authored
494 without everything here. Please try to find the above
205f653 @brentdax Win32 compatibility, Configure hints, 5.005 compatibility, MANIFEST chec...
brentdax authored
495 files and then try running Configure again.
59345b3 @brentdax Fix issues with ivsize and nvsize
brentdax authored
496
205f653 @brentdax Win32 compatibility, Configure hints, 5.005 compatibility, MANIFEST chec...
brentdax authored
497 END
59345b3 @brentdax Fix issues with ivsize and nvsize
brentdax authored
498
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
499 exit;
500 }
501 else {
502 print <<"END";
19fa0d4 @tomhughes Stop Configure trying to make op_info.c and op.h as op_info.c no longer
tomhughes authored
503 Okay, we found everything. Next you'll need to answer
504 a few questions about your system. Rules are the same
505 as Perl 5's Configure--defaults are in square brackets,
205f653 @brentdax Win32 compatibility, Configure hints, 5.005 compatibility, MANIFEST chec...
brentdax authored
506 and you can hit enter to accept them.
507
508 END
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
509 }
62bace3 Committed some files that were missed in the last *.h moving commmit.
Gregor N. Purdy authored
510 }
5cac2b3 @brentdax Cleaner VMS support, more info for Parrot::Config to remember, more flex...
brentdax authored
511
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
512
513 #
514 # compiletestc()
515 #
516
5cac2b3 @brentdax Cleaner VMS support, more info for Parrot::Config to remember, more flex...
brentdax authored
517 sub compiletestc {
9d000b4 Made the changes to figure out mask bits for various register and stack
Dan Sugalski authored
518 my $name;
519 $name = shift;
520 $name = "test" unless $name;
133486e (Hopefully the last time...)
Jeff Goff authored
521 system("$c{cc} $c{ccflags} -I./include -o test_siz$c{exe} $name.c") and die "C compiler died!";
5cac2b3 @brentdax Cleaner VMS support, more info for Parrot::Config to remember, more flex...
brentdax authored
522 }
523
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
524
525 #
526 # runtestc()
527 #
528
5cac2b3 @brentdax Cleaner VMS support, more info for Parrot::Config to remember, more flex...
brentdax authored
529 sub runtestc {
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
530 `./test_siz$c{exe}`
9d000b4 Made the changes to figure out mask bits for various register and stack
Dan Sugalski authored
531 }
532
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
533
534 #
535 # lowbitmas()
536 #
537 # Find the bitmask for the low bits of any passed-in size.
538 #
539
9d000b4 Made the changes to figure out mask bits for various register and stack
Dan Sugalski authored
540 sub lowbitmask {
541 my @returns;
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
542
9d000b4 Made the changes to figure out mask bits for various register and stack
Dan Sugalski authored
543 foreach (@_) {
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
544 my $vector = unpack("b*", pack("V", $_));
545 my $offset = rindex($vector, "1")+1;
546 my $mask = 2**$offset - 1;
547 push @returns, "(~0x".sprintf("%x", $mask).")";
9d000b4 Made the changes to figure out mask bits for various register and stack
Dan Sugalski authored
548 }
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
549
9d000b4 Made the changes to figure out mask bits for various register and stack
Dan Sugalski authored
550 return @returns;
551 }
a3cd162 Build enhancements. Originally to support building shared libraries, but...
Gregor N. Purdy authored
552
Something went wrong with that request. Please try again.