Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 94 lines (72 sloc) 1.918 kb
11b744f @simoncozens Configure system from Brent Dax <brentdax@cpan.org>
simoncozens authored
1 #!/usr/bin/perl -w
2 #so we get -w
3
4 #Configre.pl, written by Brent Dax
5
6 use strict;
7 use Config;
8
9 #print the header
10 print <<"END";
11 Parrot Configure
12 Copyright (C) 2001 Yet Another Society
13
14 Since you're running this script, you obviously have
15 Perl 5--I'll be pulling some defaults from its configuration.
16
17 Rules are the same as Perl 5's Configure--defaults are in
18 square brackets, and you can hit enter to accept them.
19 END
20
21 #Some versions don't seem to have ivtype or nvtype--provide
22 #defaults for them.
23 #XXX Figure out better defaults
24 my(%c)=(
25 iv => ($Config{ivtype}||'long'),
26 nv => ($Config{nvtype}||'long double')
27 );
28
29 #inquire about numeric sizes
30 prompt("How big would you like integers to be?", 'iv');
31 prompt("How about your floats?", 'nv');
32
33
34 print <<"END";
35
36 Okay. Now I'm gonna probe Perl 5's configuration to see
37 what headers you have around. This could take a bit on slow
38 machines...
39 END
40
41 #set up HAS_HEADER_
42 foreach(grep {/^i_/} keys %Config) {
43 $c{headers}.=defineifdef((/^i_(.*)$/));
44 }
45
46 #now let's assemble the config.h file
47 my $config_h;
48 {
49 local $/;
50 open(CONFIG_HT, "<config.h.in") or die $!;
51 $config_h=<CONFIG_HT>;
52 close CONFIG_HT;
53 }
54
55 # ${field} is replaced with $c{field}
56 $config_h =~ s/\$\{(\w+)\}/$c{$1}/g;
57
58 #write out the config.h file
59 open(CONFIG_H, ">config.h");
60 print CONFIG_H $config_h;
61 close CONFIG_H;
62
63 print <<"END";
64
65 Okay, we're done!
66 You can now use `make test_prog' (or your platform's equivalent to `make')
67 to build your Parrot.
68
69 Happy Hacking,
70 The Parrot Team
71 END
72
73 #give us the #define we may need for header X
74 sub defineifdef {
75 my $thing=shift;
76
77 if($Config{"i_$thing"}) {
78 return "#define HAS_HEADER_\U$thing\E\n";
79 }
80 else {
81 return "#undef HAS_HEADER_\U$thing\E\n"; #XXX do we want this?
82 }
83 }
84
85 #prompt for something from the user
86 sub prompt {
87 my($message, $field)=(@_);
88 my($input);
89 print "$message [$c{$field}] ";
90 chomp($input=<STDIN>);
91 $c{$field}=$input||$c{$field};
92 }
93
Something went wrong with that request. Please try again.