# New Ticket Created by  Allison Randal 
# Please include the string:  [perl #63360]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=63360 >


The attached git patch updates Rakudo's Configure.pl and Makefile.in to 
configure and build on an installed Parrot. It also adds two makefile 
templates for building Rakudo's dynops and dynpmcs. Notes:

- This patch will only work for Parrot r36904 or later. (Parrot needed 
changes to the install process and tools libraries to allow running a 
language build from an installed Parrot. Also added a script for full 
makefile template processing, including conditional lines #IF, #ELSIF, 
#ELSE, #UNLESS.)

- It requires a 'dynext/' directory in the Rakudo build directory. 
('dynext/', 'library/', and 'includes/' are the standard Parrot search 
paths, and will work in the language build directory or installed in 
'languages/langname/' or '/install/path/languages/langname/')

- The change *only* uses an installed Parrot (no longer uses Parrot 
build directory paths), but it can be installed anywhere (even within 
the Rakudo build directory, if desired).

- There's still a problem with the installed test libraries. I'll look 
into it and provide an additional patch.

Allison
>From 1d65fcb4f184ca7d8c1feaeb16fef70c919f9e88 Mon Sep 17 00:00:00 2001
From: Allison Randal <alli...@parrot.org>
Date: Thu, 19 Feb 2009 23:45:12 -0800
Subject: [PATCH] Update Configure.pl and Makefile.in to configure and build from an installed Parrot. Add two new makefiles for building dynops and dynpmcs.

---
 Configure.pl          |   41 +++++++++++++++-------------
 build/Makefile.in     |   48 +++++++++++++-------------------
 build/ops_makefile.in |   56 +++++++++++++++++++++++++++++++++++++
 build/pmc_makefile.in |   73 +++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 171 insertions(+), 47 deletions(-)
 create mode 100644 build/ops_makefile.in
 create mode 100644 build/pmc_makefile.in

diff --git a/Configure.pl b/Configure.pl
index 2b19fda..1fc5521 100644
--- a/Configure.pl
+++ b/Configure.pl
@@ -50,7 +50,7 @@ END
 }
 
 #  Create the Makefile using the information we just got
-create_makefile(%config);
+create_makefiles(%config);
 
 #  Done.
 done();
@@ -90,28 +90,31 @@ sub read_parrot_config {
 }
 
 
-#  Generate a Makefile from a configuration
-sub create_makefile {
+#  Generate Makefiles from a configuration
+sub create_makefiles {
     my %config = @_;
-    open my $ROOTIN, "<build/Makefile.in" or
-        die "Unable to read build/Makefile.in \n";
-    my $maketext = join('', <$ROOTIN>);
-    close $ROOTIN;
-
-    $config{'win32_libparrot_copy'} = $^O eq 'MSWin32' ? 'copy $(BUILD_DIR)\libparrot.dll .' : '';
-    $maketext =~ s/@(\w+)@/$config{$1}/g;
-    if ($^O eq 'MSWin32') {
-        $maketext =~ s{/}{\\}g;
+    my %makefiles = (
+        "build/Makefile.in" => "Makefile",
+        "build/pmc_makefile.in" => "src/pmc/Makefile",
+        "build/ops_makefile.in" => "src/ops/Makefile",
+    );
+    my $build_tool = $config{perl} . " " 
+        . $config{libdir}
+        . $config{versiondir}
+        . $config{slash}
+        . "tools"
+        . $config{slash}
+        . "dev"
+        . $config{slash}
+        . "gen_makefile.pl";
+
+    foreach my $template (keys %makefiles) {
+        my $makefile = $makefiles{$template};
+	print "Creating $makefile\n";
+        system("$build_tool $template $makefile");
     }
-
-    print "Creating Makefile\n";
-    open(MAKEFILE, ">Makefile") ||
-        die "Unable to write Makefile\n";
-    print MAKEFILE $maketext;
-    close(MAKEFILE);
 }
 
-
 sub done {
     my $make = $config{'make'};
     print <<"END";
diff --git a/build/Makefile.in b/build/Makefile.in
index 5a00f3e..b486b23 100644
--- a/build/Makefile.in
+++ b/build/Makefile.in
@@ -5,7 +5,10 @@
 PARROT_ARGS =
 
 # values from parrot_config
-BUILD_DIR     = @build_dir@
+VERSION_DIR   = @versiondir@
+LIB_DIR       = @lib...@$(VERSION_DIR)
+BIN_DIR       = @bindir@
+TOOLS_DIR     = @lib...@$(VERSION_DIR)@sl...@tools@sl...@lib
 LOAD_EXT      = @load_ext@
 O             = @o@
 EXE           = @exe@
@@ -14,24 +17,21 @@ PERL          = @perl@
 RM_F          = @rm_f@
 
 # Various paths
-PARROT_DYNEXT = $(BUILD_DIR)/runtime/parrot/dynext
-PERL6GRAMMAR  = $(BUILD_DIR)/runtime/parrot/library/PGE/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
+NQP           = $(LIB_DIR)/languages/nqp/nqp.pbc
+PCT           = $(LIB_DIR)/library/PCT.pbc
 PMC_DIR       = src/pmc
-OPSDIR        = src/ops
+OPS_DIR       = src/ops
 OPSLIB        = perl6
-OPS_FILE      = src/ops/perl6.ops
+OPS_FILE      = $(OPS_DIR)/perl6.ops
 
 # Set up extensions
 
 # Setup some commands
-PARROT        = $(BUILD_DIR)/parrot$(EXE)
+PARROT        = $(BIN_DIR)/parrot$(EXE)
 CAT           = $(PERL) -MExtUtils::Command -e cat
-BUILD_DYNPMC  = $(PERL) $(BUILD_DIR)/tools/build/dynpmc.pl
-BUILD_DYNOPS  = $(PERL) $(BUILD_DIR)/tools/build/dynoplibs.pl
-RECONFIGURE   = $(PERL) $(BUILD_DIR)/tools/dev/reconfigure.pl
-PBC_TO_EXE    = $(BUILD_DIR)/pbc_to_exe$(EXE)
+PBC_TO_EXE    = $(BIN_DIR)/pbc_to_exe$(EXE)
 
 SOURCES = perl6.pir \
   src/gen_grammar.pir \
@@ -43,7 +43,7 @@ SOURCES = perl6.pir \
   src/parser/methods.pir \
   src/parser/quote_expression.pir \
   $(PERL6_GROUP) \
-  src/ops/perl6_ops$(LOAD_EXT)
+  $(OPS_DIR)/perl6_ops$(LOAD_EXT)
 
 BUILTINS_PIR = \
   src/classes/ClassHOW.pir \
@@ -110,8 +110,6 @@ SETTING = \
   src/setting/Pair.pm \
   src/setting/Whatever.pm \
 
-PMCS        = perl6str objectref perl6scalar mutablevar perl6multisub
-
 PMC_SOURCES = $(PMC_DIR)/perl6str.pmc $(PMC_DIR)/objectref.pmc $(PMC_DIR)/perl6scalar.pmc \
               $(PMC_DIR)/mutablevar.pmc $(PMC_DIR)/perl6multisub.pmc
 
@@ -157,7 +155,7 @@ all: perl6$(EXE)
 # (We're not quite ready to make this a default target.)
 perl6$(EXE): perl6.pbc
 	$(PBC_TO_EXE) perl6.pbc
-	@win32_libparrot_copy@
+#IF(win32):	copy $(LIB_DIR)\libparrot.dll .
 
 spectest_checkout : t/spec
 
@@ -190,7 +188,7 @@ Test.pir: Test.pm perl6.pbc
 	$(PARROT) $(PARROT_ARGS) perl6.pbc --target=pir --output=Test.pir Test.pm
 
 $(PMC_DIR)/objectref.pmc : $(PMC_DIR)/objectref_pmc.template build/gen_objectref_pmc.pl
-	$(PERL) -I$(BUILD_DIR)/lib build/gen_objectref_pmc.pl $(PMC_DIR)/objectref_pmc.template \
+	$(PERL) -I$(TOOLS_DIR) build/gen_objectref_pmc.pl $(PMC_DIR)/objectref_pmc.template \
 		$(PMC_DIR)/objectref.pmc
 
 src/gen_grammar.pir: $(PERL6GRAMMAR) src/parser/grammar.pg src/parser/grammar-oper.pg
@@ -214,17 +212,11 @@ src/gen_junction.pir: build/gen_junction_pir.pl
 src/gen_setting.pm: build/gen_setting_pm.pl $(SETTING)
 	$(PERL) build/gen_setting_pm.pl $(SETTING) > src/gen_setting.pm
 
-$(PERL6_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)
-
-src/ops/perl6_ops$(LOAD_EXT) : $(OPS_FILE)
-	@cd $(OPSDIR) && $(BUILD_DYNOPS) generate $(OPSLIB)
-	@cd $(OPSDIR) && $(BUILD_DYNOPS) compile $(OPSLIB)
-	@cd $(OPSDIR) && $(BUILD_DYNOPS) linklibs $(OPSLIB)
-	@cd $(OPSDIR) && $(BUILD_DYNOPS) copy "--destination=$(PARROT_DYNEXT)" $(OPSLIB)
+$(PERL6_GROUP): $(PARROT) $(PMC_SOURCES) $(PMC_DIR)/Makefile
+	$(MAKE) $(PMC_DIR)
+
+$(OPS_DIR)/perl6_ops$(LOAD_EXT) : $(OPS_FILE) $(OPS_DIR)/Makefile
+	$(MAKE) $(OPS_DIR)
 
 
 ##  local copy of Parrot
diff --git a/build/ops_makefile.in b/build/ops_makefile.in
new file mode 100644
index 0000000..94e9298
--- /dev/null
+++ b/build/ops_makefile.in
@@ -0,0 +1,56 @@
+# Copyright (C) 2009, The Perl Foundation.
+# $Id: $
+
+PERL          = @perl@
+RM_F          = @rm_f@
+CHMOD         = @chmod@
+CP            = @cp@
+VERSION_DIR   = @versiondir@
+INCLUDE_DIR   = @include...@$(VERSION_DIR)
+LIB_DIR       = @lib...@$(VERSION_DIR)
+INSTALL_DIR   = ....@slash@....@slash@dynext
+O             = @o@
+LOAD_EXT      = @load_ext@
+CC            = @cc@ -c
+LD            = @ld@
+LDFLAGS       = @ldflags@ @ld_debug@ @rpath_blib@ @linkflags@
+LD_LOAD_FLAGS = @ld_load_flags@
+CFLAGS        = @ccflags@ @cc_shared@ @cc_debug@ @ccwarn@ @cc_hasjit@ @cg_flag@ @gc_flag@
+CC_OUT        = @cc_o_out@
+LD_OUT        = @ld_out@
+#IF(parrot_is_shared):LIBPARROT = @libparrot_ldflags@
+#ELSE:LIBPARROT =
+
+BUILD_TOOLS_DIR = $(LIB_DIR)@sl...@tools@sl...@build
+OPS2C           = $(PERL) $(BUILD_TOOLS_DIR)@sl...@ops2c.pl
+
+INCLUDES        = -I$(INCLUDE_DIR) -I$(INCLUDE_DIR)@sl...@pmc
+LINKARGS        = $(LDFLAGS) $(LD_LOAD_FLAGS) $(LIBPARROT)
+
+OPS_FILE = perl6.ops
+
+
+all : install
+
+generate : $(OPS_FILE)
+	$(OPS2C) C --dynamic $(OPS_FILE)
+	$(OPS2C) CSwitch --dynamic $(OPS_FILE)
+#IF(cg_flag):	$(OPS2C) CGoto --dynamic $(OPS_FILE)
+#IF(cg_flag):	$(OPS2C) CGP --dynamic $(OPS_FILE)
+
+compile : generate
+	$(CC) $(CC_OUT) perl6_ops$(O) $(INCLUDES) $(CFLAGS) perl6_ops.c
+	$(CC) $(CC_OUT) perl6_ops_switch$(O) $(INCLUDES) $(CFLAGS) perl6_ops_switch.c
+#IF(cg_flag):	$(CC) $(CC_OUT) perl6_ops_cg$(O) $(INCLUDES) $(CFLAGS) perl6_ops_cg.c
+#IF(cg_flag):	$(CC) $(CC_OUT) perl6_ops_cgp$(O) $(INCLUDES) $(CFLAGS) perl6_ops_cgp.c
+
+linklibs : compile
+	$(LD) $(LD_OUT) perl6_ops$(LOAD_EXT) perl6_ops$(O) $(LINKARGS)
+	$(LD) $(LD_OUT) perl6_ops_switch$(LOAD_EXT) perl6_ops_switch$(O) $(LINKARGS)
+#IF(cg_flag):	$(LD) $(LD_OUT) perl6_ops_cg$(LOAD_EXT) perl6_ops_cg$(O) $(LINKARGS)
+#IF(cg_flag):	$(LD) $(LD_OUT) perl6_ops_cgp$(LOAD_EXT) perl6_ops_cgp$(O) $(LINKARGS)
+
+install : linklibs
+#IF(cygwin or hpux):	CHMOD 0775 "*$(LOAD_EXT)"
+	$(CP) "*$(LOAD_EXT)" $(INSTALL_DIR)
+
diff --git a/build/pmc_makefile.in b/build/pmc_makefile.in
new file mode 100644
index 0000000..40d71e2
--- /dev/null
+++ b/build/pmc_makefile.in
@@ -0,0 +1,73 @@
+# Copyright (C) 2009, The Perl Foundation.
+# $Id: $
+
+PERL          = @perl@
+RM_F          = @rm_f@
+CHMOD         = @chmod@
+CP            = @cp@
+VERSION_DIR   = @versiondir@
+INCLUDE_DIR   = @include...@$(VERSION_DIR)
+LIB_DIR       = @lib...@$(VERSION_DIR)
+SRC_DIR       = @src...@$(VERSION_DIR)
+INSTALL_DIR   = ../../dynext
+O             = @o@
+LOAD_EXT      = @load_ext@
+CC            = @cc@ -c
+LD            = @ld@
+LDFLAGS       = @ldflags@ @ld_debug@
+LD_LOAD_FLAGS = @ld_load_flags@
+CFLAGS        = @ccflags@ @cc_shared@ @cc_debug@ @ccwarn@ @cc_hasjit@ @cg_flag@ @gc_flag@
+CC_OUT        = @cc_o_out@
+LD_OUT        = @ld_out@
+#IF(parrot_is_shared):LIBPARROT = @libparrot_ldflags@
+#ELSE:LIBPARROT =
+
+BUILD_TOOLS_DIR = $(LIB_DIR)@sl...@tools@sl...@build
+PMC2C_INCLUDES  = --include $(SRC_DIR) --include $(SRC_DIR)@sl...@pmc
+PMC2C           = $(PERL) $(BUILD_TOOLS_DIR)@sl...@pmc2c.pl
+PMC2CD = $(PMC2C) --dump $(PMC2C_INCLUDES)
+PMC2CC = $(PMC2C) --c $(PMC2C_INCLUDES)
+
+INCLUDES        = -I$(INCLUDE_DIR) -I$(INCLUDE_DIR)@sl...@pmc
+LINKARGS        = $(LDFLAGS) $(LD_LOAD_FLAGS) $(LIBPARROT)
+
+PMC_SOURCES = \
+  perl6str.pmc \
+  objectref.pmc \
+  perl6scalar.pmc \
+  mutablevar.pmc \
+  perl6multisub.pmc
+
+PERL6_GROUP = perl6_group
+
+
+all : install
+
+generate : $(PMC_SOURCES)
+	$(PMC2CD) perl6str.pmc
+	$(PMC2CD) objectref.pmc
+	$(PMC2CD) perl6scalar.pmc
+	$(PMC2CD) mutablevar.pmc
+	$(PMC2CD) perl6multisub.pmc
+	$(PMC2CC) perl6str.pmc
+	$(PMC2CC) objectref.pmc
+	$(PMC2CC) perl6scalar.pmc
+	$(PMC2CC) mutablevar.pmc
+	$(PMC2CC) perl6multisub.pmc
+	$(PMC2C) --library $(PERL6_GROUP) --c $(PMC_SOURCES)
+
+compile : generate
+	$(CC) $(CC_OUT) perl6str$(O) $(INCLUDES) $(CFLAGS) perl6str.c
+	$(CC) $(CC_OUT) objectref$(O) $(INCLUDES) $(CFLAGS) objectref.c
+	$(CC) $(CC_OUT) perl6scalar$(O) $(INCLUDES) $(CFLAGS) perl6scalar.c
+	$(CC) $(CC_OUT) mutablevar$(O) $(INCLUDES) $(CFLAGS) mutablevar.c
+	$(CC) $(CC_OUT) perl6multisub$(O) $(INCLUDES) $(CFLAGS) perl6multisub.c
+	$(CC) $(CC_OUT) lib-$(PERL6_GROUP)$(O) $(INCLUDES) $(CFLAGS) $(PERL6_GROUP).c
+
+linklibs : compile
+	$(LD) $(LD_OUT) $(PERL6_GROUP)$(LOAD_EXT) lib-$(PERL6_GROUP)$(O) perl6str$(O) objectref$(O) perl6scalar$(O) mutablevar$(O) perl6multisub$(O) $(LINKARGS)
+
+install : linklibs
+#IF(cygwin or hpux):	CHMOD 0775 "*$(LOAD_EXT)"
+	$(CP) "*$(LOAD_EXT)" $(INSTALL_DIR)
+
-- 
1.5.6.3

Reply via email to