Simon Cozens:
# Yeah, that was it! Brent, do you want to take care of that.
# (config_h.in would be better, since it gets mindshare from the
# current Perl 5 build process.)

Didn't take long--patch below sig.  You'll also have to rename
config.h.in to config_h.in yourself.

--Brent Dax
[EMAIL PROTECTED]

They *will* pay for what they've done.


--- c:\old_parrot\Configure.pl  Tue Sep 11 02:44:00 2001
+++ Configure.pl        Fri Sep 14 02:02:10 2001
@@ -1,11 +1,18 @@
 #!/usr/bin/perl -w
 #so we get -w

-#Configre.pl, written by Brent Dax
+#Configure.pl, written by Brent Dax

 use strict;
 use Config;

+my($DDOK)=undef;
+eval {
+       require Data::Dumper;
+       Data::Dumper->import();
+       $DDOK=1;
+};
+
 #print the header
 print <<"END";
 Parrot Configure
@@ -22,11 +29,17 @@
 #defaults for them.
 #XXX Figure out better defaults
 my(%c)=(
-       iv => ($Config{ivtype}||'long'),
-       nv => ($Config{nvtype}||'long double')
+       iv =>           ($Config{ivtype}||'long'),
+       nv =>           ($Config{nvtype}||'long double'),
+       cc =>           $Config{cc},
+       ccflags =>      '-Wall -o $@',
+       libs =>         $Config{libs}
 );

-#inquire about numeric sizes
+#ask questions
+prompt("What C compiler do you want to use?", 'cc');
+prompt("What flags would you like passed to your C compiler?",
'ccflags');
+prompt("Which libraries would you like your C compiler to include?" ,
'libs');
 prompt("How big would you like integers to be?", 'iv');
 prompt("How about your floats?", 'nv');

@@ -40,25 +53,22 @@

 #set up HAS_HEADER_
 foreach(grep {/^i_/} keys %Config) {
+       $c{$_}=$Config{$_};
        $c{headers}.=defineifdef((/^i_(.*)$/));
 }

-#now let's assemble the config.h file
-my $config_h;
-{
-       local $/;
-       open(CONFIG_HT, "<config.h.in") or die $!;
-       $config_h=<CONFIG_HT>;
-       close CONFIG_HT;
-}
+print <<"END";

-# ${field} is replaced with $c{field}
-$config_h =~ s/\$\{(\w+)\}/$c{$1}/g;
+Okay, that's finished.  I'm now going to write your very
+own Makefile, config.h, and Parrot::Config to disk.
+END

-#write out the config.h file
-open(CONFIG_H, ">config.h");
-print CONFIG_H $config_h;
-close CONFIG_H;
+#now let's assemble the config.h file
+buildfile("config_h");
+#and the makefile
+buildfile("Makefile");
+#and Parrot::Config
+buildconfigpm();

 print <<"END";

@@ -91,3 +101,48 @@
        $c{$field}=$input||$c{$field};
 }

+sub buildfile {
+       my($filename)=shift;
+
+       local $/;
+       open(IN, "<$filename.in") or die "Can't open $filename.in: $!";
+       my $text=<IN>;
+       close(IN) or die "Can't close $filename.in: $!";
+
+       $text =~ s/\$\{(\w+)\}/$c{$1}/g;
+       $filename =~ s/_/./;    #config_h => config.h
+
+       open(OUT, ">$filename") or die "Can't open $filename: $!";
+       print OUT $text;
+       close(OUT) or die "Can't close $filename: $!";
+}
+
+sub buildconfigpm {
+       unless($DDOK) {
+               print <<"END";
+
+Your system doesn't have Data::Dumper installed, so I couldn't
+build Parrot::Config.  If you want Parrot::Config installed,
+use CPAN.pm to install Data::Dumper and run this script again.
+END
+
+               return;
+       }
+
+       my %C=%c;
+       delete $C{headers};
+       my $dd=new Data::Dumper([\%C]);
+       $dd->Names(['*PConfig']);
+
+       local $/;
+       open(IN, "<Config_pm.in") or die "Can't open Config_pm.in: $!";
+       my $text=<IN>;
+       close(IN) or die "Can't close Config.pm_in: $!";
+
+       $text =~ s/#DUMPER OUTPUT HERE/$dd->Dump()/eg;
+
+       mkdir("Parrot") or ( $! =~ /File exists/i or die "Can't make directory
./Parrot: $!");
+       open(OUT, ">Parrot/Config.pm") or die "Can't open file
Parrot/Config.pm: $!";
+       print OUT $text;
+       close(OUT) or die "Can't close file Parrot/Config.pm: $!";
+}
--- /dev/null   Wed Dec 31 16:00:00 1969
+++ Config_pm.in        Thu Sep 13 23:40:00 2001
@@ -0,0 +1,14 @@
+package Parrot::Config;
+
+use strict;
+use warnings;
+use Exporter;
+
+use vars qw(@ISA @EXPORT %PConfig);
+@ISA=qw(Exporter);
+
+@EXPORT=qw(%PConfig);
+
+#DUMPER OUTPUT HERE
+
+1;

Reply via email to