From 3477a9453bdb55c597b9c929ad43e121792c7671 Mon Sep 17 00:00:00 2001 From: Daniel Arbelo Arrocha Date: Fri, 16 Oct 2009 17:05:25 -0300 Subject: [PATCH] Add a new, modernized, Configure.pl and adjust the Makefile template to build against an installed parrot. Some targets still need work, but matrixy now builds and can run the interactive REPL. --- Configure.pl | 80 ++++++++++++++++++++++++++++++++++++++++ config/makefiles/root.in | 66 ++++++++++----------------------- 2 files changed, 99 insertions(+), 47 deletions(-) create mode 100644 Configure.pl diff --git a/Configure.pl b/Configure.pl new file mode 100644 index 0000000..1dee55a --- /dev/null +++ b/Configure.pl @@ -0,0 +1,80 @@ +=head1 NAME + +Configure.pl - a configure script for a high level language running on Parrot + +=head1 SYNOPSIS + + perl Configure.pl --help + + perl Configure.pl + + perl Configure.pl --parrot_config= + +=cut + +use strict; +use warnings; +use 5.008; + +use Getopt::Long qw(:config auto_help); + +our ( $opt_parrot_config ); +GetOptions( 'parrot_config=s' ); + +# Get a list of parrot-configs to invoke. +my @parrot_config_exe = $opt_parrot_config + ? ( $opt_parrot_config ) + : ( + 'parrot/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', + ); + 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/root.in b/config/makefiles/root.in index 37d8af6..f4284d8 100644 --- a/config/makefiles/root.in +++ b/config/makefiles/root.in @@ -1,10 +1,12 @@ -## $Id$ - ## arguments we want to run parrot with PARROT_ARGS = ## configuration settings -BUILD_DIR = @build_dir@ +INCLUDE_DIR := @includedir@@versiondir@ +LIB_DIR := @libdir@@versiondir@ +SRC_DIR := @srcdir@@versiondir@ +TOOLS_DIR := @libdir@@versiondir@/tools/lib + LOAD_EXT = @load_ext@ O = @o@ @@ -13,38 +15,29 @@ PERL = @perl@ RM_F = @rm_f@ CP = @cp@ CAT = @cat@ -PARROT = ../../parrot@exe@ -BUILD_DYNPMC = $(PERL) $(BUILD_DIR)/tools/build/dynpmc.pl -#IF(darwin): +PARROT = @bindir@/parrot@exe@ +NQP = @bindir@/parrot_nqp@exe@ + #IF(darwin):# MACOSX_DEPLOYMENT_TARGET must be defined for OS X compilation/linking #IF(darwin):export MACOSX_DEPLOYMENT_TARGET := @osx_version@ ## places to look for things -PARROT_DYNEXT = $(BUILD_DIR)/runtime/parrot/dynext -PGE_LIBRARY = $(BUILD_DIR)/runtime/parrot/library/PGE -PERL6GRAMMAR = $(PGE_LIBRARY)/Perl6Grammar.pbc -NQP = $(BUILD_DIR)/compilers/nqp/nqp.pbc -PCT = $(BUILD_DIR)/runtime/parrot/library/PCT.pbc +PARROT_DYNEXT = $(LIB_DIR)/dynext +PERL6GRAMMAR = $(LIB_DIR)/library/PGE/Perl6Grammar.pbc +PCT = $(LIB_DIR)/PCT.pbc PMC_DIR = src/pmc all: matrixy.pbc -MATRIXY_GROUP = $(PMC_DIR)/matrixy_group$(LOAD_EXT) - -SOURCES = matrixy.pir \ - src/gen_grammar.pir \ - src/gen_actions.pir \ - src/gen_builtins.pir \ - src/gen_internals.pir \ -# $(MATRIXY_GROUP) +SOURCES = \ + matrixy.pir src/gen_grammar.pir \ + src/gen_actions.pir src/gen_builtins.pir \ + src/gen_internals.pir -BUILTINS_PIR = @builtins_pir@ +BUILTINS_PIR = src/builtins/*.pir -INTERNALS_PIR = @internals_pir@ - -# PMCS = matrixy -# PMC_SOURCES = $(PMC_DIR)/matrixy.pmc +INTERNALS_PIR = src/internals/*.pir # the default target matrixy.pbc: $(PARROT) $(SOURCES) @@ -56,9 +49,8 @@ src/gen_grammar.pir: $(PERL6GRAMMAR) src/parser/grammar.pg src/parser/grammar-op src/parser/grammar.pg \ src/parser/grammar-oper.pg \ -src/gen_actions.pir: $(NQP) $(PCT) src/parser/actions.pm - $(PARROT) $(PARROT_ARGS) $(NQP) --output=src/gen_actions.pir \ - --target=pir src/parser/actions.pm +src/gen_actions.pir: src/parser/actions.pm + $(NQP) --output=src/gen_actions.pir --target=pir src/parser/actions.pm src/gen_builtins.pir: $(BUILTINS_PIR) $(CAT) $(BUILTINS_PIR) >src/gen_builtins.pir @@ -66,12 +58,6 @@ src/gen_builtins.pir: $(BUILTINS_PIR) src/gen_internals.pir: $(INTERNALS_PIR) $(CAT) $(INTERNALS_PIR) >src/gen_internals.pir -$(MATRIXY_GROUP): $(PARROT) $(PMC_SOURCES) - cd $(PMC_DIR) && $(BUILD_DYNPMC) generate $(PMCS) - cd $(PMC_DIR) && $(BUILD_DYNPMC) compile $(PMCS) - cd $(PMC_DIR) && $(BUILD_DYNPMC) linklibs $(PMCS) - cd $(PMC_DIR) && $(BUILD_DYNPMC) copy --destination=$(PARROT_DYNEXT) $(PMCS) - # regenerate the Makefile Makefile: config/makefiles/root.in $(PERL) Configure.pl @@ -106,22 +92,8 @@ CLEANUPS = \ matrixy.pbc \ "src/gen_*.pir" -PMC_CLEANUPS = \ - "$(PMC_DIR)/*.h" \ - "$(PMC_DIR)/*.c" \ - "$(PMC_DIR)/*.dump" \ - "$(PMC_DIR)/*$(O)" \ -#IF(win32): "$(PMC_DIR)/*.exp" \ -#IF(win32): "$(PMC_DIR)/*.ilk" \ -#IF(win32): "$(PMC_DIR)/*.manifest" \ -#IF(win32): "$(PMC_DIR)/*.pdb" \ -#IF(win32): "$(PMC_DIR)/*.lib" \ - "$(PMC_DIR)/*$(LOAD_EXT)" - - clean: testclean $(RM_F) $(CLEANUPS) -# $(RM_F) $(PMC_CLEANUPS) realclean: clean $(RM_F) Makefile