From 157204ca16be3ac80b801b8b620850d46f32643a Mon Sep 17 00:00:00 2001 From: Francois Perrad Date: Fri, 6 Nov 2009 16:09:26 +0100 Subject: [PATCH] convert Configure to PIR (from Perl) --- Configure.pir | 57 ++++++++++++++++++++++++++++++++++ Configure.pl | 66 ---------------------------------------- config/makefiles/pmc.in | 2 +- config/makefiles/root.in | 2 +- 4 files changed, 59 insertions(+), 68 deletions(-) create mode 100644 Configure.pir delete mode 100644 Configure.pl diff --git a/Configure.pir b/Configure.pir new file mode 100644 index 0000000..3706b1b --- /dev/null +++ b/Configure.pir @@ -0,0 +1,57 @@ +#! /usr/local/bin/parrot +# Copyright (C) 2009, Parrot Foundation. + +.include 'sysinfo.pasm' +.include 'iglobals.pasm' + +.sub 'main' :main + load_bytecode 'Configure.pbc' + + # Wave to the friendly users + print "Hello, I'm Configure. My job is to poke and prod\n" + print "your system to figure out how to build Lua.\n" + + .local pmc config + $P0 = getinterp + config = $P0[.IGLOBALS_CONFIG_HASH] + .local string OS + OS = sysinfo .SYSINFO_PARROT_OS + + # Here, do the job + push_eh _handler + genfile('config/makefiles/root.in', 'Makefile', config) + genfile('config/makefiles/pmc.in', 'src/pmc/Makefile', config) + pop_eh + + # Give the user a hint of next action + .local string make + make = config['make'] + print "Configure completed for platform '" + print OS + print "'.\n" + print "You can now type '" + print make + print "' to build Lua.\n" + print "You may also type '" + print make + print " test' to run the Lua test suite.\n" + print "\nHappy Hacking.\n" + end + + _handler: + .local pmc e + .local string msg + .get_results (e) + printerr "\n" + msg = e + printerr msg + printerr "\n" + end +.end + +# Local Variables: +# mode: pir +# fill-column: 100 +# End: +# vim: expandtab shiftwidth=4 ft=pir: + diff --git a/Configure.pl b/Configure.pl deleted file mode 100644 index 6717de1..0000000 --- a/Configure.pl +++ /dev/null @@ -1,66 +0,0 @@ -# Copyright (C) 2009, Parrot Foundation. -# $Id$ - -use strict; -use warnings; -use 5.008; - -# Get a list of parrot-configs to invoke. -my @parrot_config_exe = ( - 'parrot/parrot_config', - '../../parrot_config', - 'parrot_config', -); - -# Get configuration information from parrot_config -my %config = read_parrot_config(@parrot_config_exe); -unless (%config) { - die "Unable to locate parrot_config."; -} - -# Create the Makefile using the information we just got -create_makefiles(%config); - -sub read_parrot_config { - my @parrot_config_exe = @_; - my %config = (); - for my $exe (@parrot_config_exe) { - no warnings; - if (open my $PARROT_CONFIG, '-|', "$exe --dump") { - print "Reading configuration information from $exe\n"; - while (<$PARROT_CONFIG>) { - $config{$1} = $2 if (/(\w+) => '(.*)'/); - } - close $PARROT_CONFIG; - last if %config; - } - } - %config; -} - - -# Generate Makefiles from a configuration -sub create_makefiles { - my %config = @_; - my %makefiles = ( - 'config/makefiles/root.in' => 'Makefile', - 'config/makefiles/pmc.in' => 'src/pmc/Makefile', -# 'config/makefiles/ops.in' => 'src/ops/Makefile', - ); - my $build_tool = $config{libdir} . $config{versiondir} - . '/tools/dev/gen_makefile.pl'; - - foreach my $template (keys %makefiles) { - my $makefile = $makefiles{$template}; - print "Creating $makefile\n"; - system($config{perl}, $build_tool, $template, $makefile); - } -} - -# Local Variables: -# mode: cperl -# cperl-indent-level: 4 -# fill-column: 100 -# End: -# vim: expandtab shiftwidth=4: - diff --git a/config/makefiles/pmc.in b/config/makefiles/pmc.in index e09d21d..570452c 100644 --- a/config/makefiles/pmc.in +++ b/config/makefiles/pmc.in @@ -141,7 +141,7 @@ uninstall: $(RM_F) $(INSTALL_DIR)/$(LUA_GROUP)$(LOAD_EXT) Makefile: ../../config/makefiles/pmc.in - cd ../.. && $(PERL) Configure.pl + cd ../.. && $(PARROT) Configure.pir clean: $(RM_F) $(CLEANUPS) diff --git a/config/makefiles/root.in b/config/makefiles/root.in index 214182e..427fcc6 100644 --- a/config/makefiles/root.in +++ b/config/makefiles/root.in @@ -334,7 +334,7 @@ installable_luap@exe@: luap.pbc $(PBC_TO_EXE) luap.pbc --install Makefile: config/makefiles/root.in - $(PERL) Configure.pl + $(PARROT) Configure.pir help: @echo ""