Skip to content

Commit

Permalink
Add a new, modernized, Configure.pl and adjust the Makefile template …
Browse files Browse the repository at this point in the history
…to build against an installed parrot. Some targets still need work, but matrixy now builds and can run the interactive REPL.
  • Loading branch information
darbelo committed Oct 16, 2009
1 parent 3d25d22 commit 3477a94
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 47 deletions.
80 changes: 80 additions & 0 deletions 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=<path_to_parrot>
=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:
66 changes: 19 additions & 47 deletions 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@

Expand All @@ -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)
Expand All @@ -56,22 +49,15 @@ 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

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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 3477a94

Please sign in to comment.