diff --git a/CREDITS b/CREDITS index 2bcd033..c2bc60f 100644 --- a/CREDITS +++ b/CREDITS @@ -20,6 +20,7 @@ E: amos@coscom.net N: Allison Randal E: allison@parrot.org D: Track function renames in parrot +D: Build partcl against installed parrot N: Jerry Gay a.k.a. particle E: Jerry.Gay@gmail.com diff --git a/Configure.pl b/Configure.pl index e2ae96f..c0fdf81 100644 --- a/Configure.pl +++ b/Configure.pl @@ -3,5 +3,43 @@ use strict; use warnings; -chdir '../..'; -`$^X -Ilib tools/dev/reconfigure.pl --step=gen::languages --languages=tcl`; +my $perlbin = `parrot_config perl`; +my $libdir = `parrot_config libdir`; +my $versiondir = `parrot_config versiondir`; +my $slash = `parrot_config slash`; +my $make = `parrot_config make`; + +chomp($perlbin); +chomp($libdir); +chomp($versiondir); +chomp($slash); +chomp($make); + +my $build_tool = $perlbin . " " + . $libdir + . $versiondir + . $slash + . "tools" + . $slash + . "dev" + . $slash + . "gen_makefile.pl"; + +my %makefiles = ( + "config/makefiles/root.in" => "Makefile", + "config/makefiles/pmc.in" => "src/pmc/Makefile", + "config/makefiles/ops.in" => "src/ops/Makefile", +); + +foreach my $template (keys %makefiles) { + my $makefile = $makefiles{$template}; + print "Creating $makefile\n"; + system("$build_tool $template $makefile"); +} + +print <<"END"; + +You can now use '$make' to build Partcl. +END + +exit; diff --git a/config/makefiles/ops.in b/config/makefiles/ops.in new file mode 100644 index 0000000..6ba9663 --- /dev/null +++ b/config/makefiles/ops.in @@ -0,0 +1,74 @@ +PERL = @perl@ +RM_F = @rm_f@ +CHMOD = @chmod@ +CP = @cp@ +VERSION_DIR = @versiondir@ +INCLUDE_DIR = @includedir@$(VERSION_DIR) +LIB_DIR = @libdir@$(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)@slash@tools@slash@build +OPS2C = $(PERL) $(BUILD_TOOLS_DIR)@slash@ops2c.pl + +INCLUDES = -I$(INCLUDE_DIR) -I$(INCLUDE_DIR)@slash@pmc +LINKARGS = $(LDFLAGS) $(LD_LOAD_FLAGS) $(LIBPARROT) + +OPS_FILE = tcl.ops + +OPS_TARGETS := \ +#IF(cg_flag): tcl_ops_cg$(LOAD_EXT) \ +#IF(cg_flag): tcl_ops_cgp$(LOAD_EXT) \ + tcl_ops$(LOAD_EXT) \ + tcl_ops_switch$(LOAD_EXT) \ + + +all : $(OPS_TARGETS) +#IF(cygwin or hpux): CHMOD 0775 "*$(LOAD_EXT)" + $(CP) "*$(LOAD_EXT)" $(INSTALL_DIR) + +tcl_ops$(LOAD_EXT): tcl_ops$(O) + $(LD) $(LD_OUT) tcl_ops$(LOAD_EXT) tcl_ops$(O) $(LINKARGS) + +tcl_ops$(O): tcl_ops.c + $(CC) $(CC_OUT) tcl_ops$(O) $(INCLUDES) $(CFLAGS) tcl_ops.c + +tcl_ops.c: $(OPS_FILE) + $(OPS2C) C --dynamic $(OPS_FILE) + +tcl_ops_switch$(LOAD_EXT): tcl_ops_switch$(O) + $(LD) $(LD_OUT) tcl_ops_switch$(LOAD_EXT) tcl_ops_switch$(O) $(LINKARGS) + +tcl_ops_switch$(O): tcl_ops_switch.c + $(CC) $(CC_OUT) tcl_ops_switch$(O) $(INCLUDES) $(CFLAGS) tcl_ops_switch.c + +tcl_ops_switch.c: $(OPS_FILE) + $(OPS2C) CSwitch --dynamic $(OPS_FILE) + +tcl_ops_cg$(LOAD_EXT): tcl_ops_cg$(O) + $(LD) $(LD_OUT) tcl_ops_cg$(LOAD_EXT) tcl_ops_cg$(O) $(LINKARGS) + +tcl_ops_cg$(O): tcl_ops_cg.c + $(CC) $(CC_OUT) tcl_ops_cg$(O) $(INCLUDES) $(CFLAGS) tcl_ops_cg.c + +tcl_ops_cg.c: $(OPS_FILE) + $(OPS2C) CGoto --dynamic $(OPS_FILE) + +tcl_ops_cgp$(LOAD_EXT): tcl_ops_cgp$(O) + $(LD) $(LD_OUT) tcl_ops_cgp$(LOAD_EXT) tcl_ops_cgp$(O) $(LINKARGS) + +tcl_ops_cgp$(O): tcl_ops_cgp.c + $(CC) $(CC_OUT) tcl_ops_cgp$(O) $(INCLUDES) $(CFLAGS) tcl_ops_cgp.c + +tcl_ops_cgp.c: $(OPS_FILE) + $(OPS2C) CGP --dynamic $(OPS_FILE) diff --git a/config/makefiles/pmc.in b/config/makefiles/pmc.in new file mode 100644 index 0000000..b953e16 --- /dev/null +++ b/config/makefiles/pmc.in @@ -0,0 +1,109 @@ +PERL = @perl@ +RM_F = @rm_f@ +CHMOD = @chmod@ +CP = @cp@ +VERSION_DIR = @versiondir@ +INCLUDE_DIR = @includedir@$(VERSION_DIR) +LIB_DIR = @libdir@$(VERSION_DIR) +SRC_DIR = @srcdir@$(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)@slash@tools@slash@build +PMC2C_INCLUDES = --include $(SRC_DIR) --include $(SRC_DIR)@slash@pmc +PMC2C = $(PERL) $(BUILD_TOOLS_DIR)@slash@pmc2c.pl +PMC2CD = $(PMC2C) --dump $(PMC2C_INCLUDES) +PMC2CC = $(PMC2C) --c $(PMC2C_INCLUDES) + +INCLUDES = -I$(INCLUDE_DIR) -I$(INCLUDE_DIR)@slash@pmc +LINKARGS = $(LDFLAGS) $(LD_LOAD_FLAGS) $(LIBPARROT) + +PMC_SOURCES = \ + tclobject.pmc \ + tclstring.pmc \ + tclint.pmc \ + tclfloat.pmc \ + tcllist.pmc \ + tcldict.pmc + + +TCL_GROUP = tcl_group + +all : $(TCL_GROUP)$(LOAD_EXT) +#IF(cygwin or hpux): CHMOD 0775 "*$(LOAD_EXT)" + $(CP) "*$(LOAD_EXT)" $(INSTALL_DIR) + + +$(TCL_GROUP)$(LOAD_EXT): tclobject$(O) tclstring$(O) tclint$(O) tclfloat$(O) tcllist$(O) tcldict$(O) lib-$(TCL_GROUP)$(O) + $(LD) $(LD_OUT) $(TCL_GROUP)$(LOAD_EXT) lib-$(TCL_GROUP)$(O) tclobject$(O) tclstring$(O) tclint$(O) tclfloat$(O) tcllist$(O) tcldict$(O) $(LINKARGS) + +lib-$(TCL_GROUP)$(O): $(TCL_GROUP).c + $(CC) $(CC_OUT) lib-$(TCL_GROUP)$(O) $(INCLUDES) $(CFLAGS) $(TCL_GROUP).c + +$(TCL_GROUP).c: $(PMC_SOURCES) + $(PMC2C) --library $(TCL_GROUP) --c $(PMC_SOURCES) + +tclobject.dump: tclobject.pmc + $(PMC2CD) tclobject.pmc + +tclobject.c: tclobject.dump + $(PMC2CC) tclobject.pmc + +tclobject$(O): tclobject.c + $(CC) $(CC_OUT) tclobject$(O) $(INCLUDES) $(CFLAGS) tclobject.c + +tclstring.dump: tclstring.pmc + $(PMC2CD) tclstring.pmc + +tclstring.c: tclstring.dump + $(PMC2CC) tclstring.pmc + +tclstring$(O): tclstring.c + $(CC) $(CC_OUT) tclstring$(O) $(INCLUDES) $(CFLAGS) tclstring.c + +tclint.dump: tclint.pmc + $(PMC2CD) tclint.pmc + +tclint.c: tclint.dump + $(PMC2CC) tclint.pmc + +tclint$(O): tclint.c + $(CC) $(CC_OUT) tclint$(O) $(INCLUDES) $(CFLAGS) tclint.c + +tclfloat.dump: tclfloat.pmc + $(PMC2CD) tclfloat.pmc + +tclfloat.c: tclfloat.dump + $(PMC2CC) tclfloat.pmc + +tclfloat$(O): tclfloat.c + $(CC) $(CC_OUT) tclfloat$(O) $(INCLUDES) $(CFLAGS) tclfloat.c + +tcllist.dump: tcllist.pmc + $(PMC2CD) tcllist.pmc + +tcllist.c: tcllist.dump + $(PMC2CC) tcllist.pmc + +tcllist$(O): tcllist.c + $(CC) $(CC_OUT) tcllist$(O) $(INCLUDES) $(CFLAGS) tcllist.c + +tcldict.dump: tcldict.pmc + $(PMC2CD) tcldict.pmc + +tcldict.c: tcldict.dump + $(PMC2CC) tcldict.pmc + +tcldict$(O): tcldict.c + $(CC) $(CC_OUT) tcldict$(O) $(INCLUDES) $(CFLAGS) tcldict.c + diff --git a/config/makefiles/root.in b/config/makefiles/root.in index 8c536c3..dea799a 100644 --- a/config/makefiles/root.in +++ b/config/makefiles/root.in @@ -1,18 +1,19 @@ RM_F = @rm_f@ PERL = @perl@ -PARROT = ../../parrot@exe@ -BUILD_DIR = @build_dir@ -RECONFIGURE = $(PERL) $(BUILD_DIR)/tools/dev/reconfigure.pl -PBC_TO_EXE = $(BUILD_DIR)/pbc_to_exe@exe@ +VERSION_DIR = @versiondir@ +INCLUDE_DIR = @includedir@$(VERSION_DIR) +LIB_DIR = @libdir@$(VERSION_DIR) +BIN_DIR = @bindir@ +PARROT = $(BIN_DIR)/parrot@exe@ +TOOLS_DIR = @libdir@$(VERSION_DIR)@slash@tools +RECONFIGURE = $(PERL) $(LIB_DIR)/tools/dev/gen_makefile.pl +PBC_TO_EXE = $(BIN_DIR)/pbc_to_exe@exe@ #CONDITIONED_LINE(darwin): #CONDITIONED_LINE(darwin):# MACOSX_DEPLOYMENT_TARGET must be defined for OS X compilation/linking #CONDITIONED_LINE(darwin):export MACOSX_DEPLOYMENT_TARGET := @osx_version@ TCL_LIB = library -PMCBUILD = $(PERL) @build_dir@/tools/build/dynpmc.pl -OPSBUILD = $(PERL) @build_dir@/tools/build/dynoplibs.pl -DESTDIR = @build_dir@/runtime/parrot/dynext O = @o@ PMCDIR = src/pmc OPSDIR = src/ops @@ -25,19 +26,8 @@ CC_SHARED = @cc_shared@ CFLAGS = @ccflags@ @cc_debug@ @ccwarn@ @cc_hasjit@ @cg_flag@ @gc_flag@ $(CC_SHARED) CC = @cc@ - -TGE_DIR = ../../compilers/tge -PERL6GRAMMAR = ../../runtime/parrot/library/PGE/Perl6Grammar.pbc - -# can't use $(wildcard) and friends for PMCS, as these have to be in -# dependency order; with no duplicates. -PMCS = \ - tclobject \ - tclstring \ - tclint \ - tclfloat \ - tcllist \ - tcldict +TGE_DIR = $(LIB_DIR)/languages/tge +PERL6GRAMMAR = $(LIB_DIR)/library/PGE/Perl6Grammar.pbc RUNTIME_PIR = runtime/builtin/after.pir runtime/builtin/linsert.pir \ runtime/builtin/append.pir runtime/builtin/list.pir \ @@ -127,25 +117,13 @@ CLASSES = \ $(CLASSDIR)/tracearray.pir pmcs: - @cd $(PMCDIR) && $(PMCBUILD) generate $(PMCS) - @cd $(PMCDIR) && $(PMCBUILD) compile $(PMCS) - @cd $(PMCDIR) && $(PMCBUILD) linklibs $(PMCS) - @cd $(PMCDIR) && $(PMCBUILD) copy "--destination=$(DESTDIR)" $(PMCS) - -# THIS WAS COPIED FROM THE ROOT MAKEFILE -# Passing an empty argument in @ARGV to cc_flags.pl to indicate where extra -Is -# (etc) should go. Otherwise it will insert them after the first space, which -# makes life go horribly wrong if $(CC) contains spaces but can't have -I -# arguments (etc) injected in the middle. -# There is probably a better way to do this, but I can't work it out right now. + $(MAKE) $(PMCDIR) + .c$(O) : - @$(PERL) ../../tools/dev/cc_flags.pl ../../CFLAGS $(CC) "" $(CFLAGS) -I@build_dir@@slash@include @cc_o_out@$@ -c $< + $(CC) $(CFLAGS) -I$(INCLUDE_DIR) @cc_o_out@$@ -c $< ops: src/binary$(O) - @cd $(OPSDIR) && $(OPSBUILD) generate tcl - @cd $(OPSDIR) && $(OPSBUILD) compile tcl - @cd $(OPSDIR) && $(OPSBUILD) linklibs tcl ../binary$(O) - @cd $(OPSDIR) && $(OPSBUILD) copy "--destination=$(DESTDIR)" tcl + $(MAKE) $(OPSDIR) runtime/builtins.pir: $(DEPS) tools/gen_builtins.pl $(PERL) tools/gen_builtins.pl > runtime/builtins.pir @@ -159,11 +137,8 @@ tclsh@exe@: tcl.pbc $(PBC_TO_EXE) $(PBC_TO_EXE) tcl.pbc $(RENAME) tcl@exe@ tclsh@exe@ -$(PBC_TO_EXE): - $(MAKE) $(BUILD_DIR) ./pbc_to_exe@exe@ - test: tcl.pbc - $(PERL) t/harness + $(PERL) -I$(TOOLS_DIR)/lib t/harness spectest: tcl.pbc $(PERL) tools/tcl_test.pl @@ -215,7 +190,9 @@ realclean: clean distclean: realclean -# regenerate the Makefile -Makefile: config/makefiles/root.in - cd $(BUILD_DIR) && $(RECONFIGURE) --step=gen::languages --languages=tcl +# regenerate the Makefiles +Makefile: config/makefiles/root.in config/makefiles/pmc.in config/makefiles/ops.in + $(RECONFIGURE) config/makefiles/root.in Makefile + $(RECONFIGURE) config/makefiles/pmc.in $(PMCDIR)/Makefile + $(RECONFIGURE) config/makefiles/ops.in $(OPSDIR)/Makefile diff --git a/dynext/README b/dynext/README new file mode 100644 index 0000000..a510460 --- /dev/null +++ b/dynext/README @@ -0,0 +1 @@ +This directory holds dynamic extensions for Partcl. diff --git a/runtime/conversions.pir b/runtime/conversions.pir index 1841411..906dfba 100644 --- a/runtime/conversions.pir +++ b/runtime/conversions.pir @@ -431,7 +431,7 @@ do_wrapper: pir.'emit'(".HLL 'Tcl'") pir.'emit'(".loadlib 'tcl_ops'") pir.'emit'('.namespace %0', namespace) - pir.'emit'(".include 'languages/tcl/src/returncodes.pasm'") + pir.'emit'(".include 'src/returncodes.pasm'") pir.'emit'(".sub '_anon' :anon") pir .= result pir.'emit'(' .return(%0)', ret) @@ -439,7 +439,7 @@ do_wrapper: pir.'emit'(<<"END_PIR") .sub '_init' :init - load_bytecode 'languages/tcl/runtime/tcllib.pir' + load_bytecode 'runtime/tcllib.pir' .end END_PIR diff --git a/runtime/tcllib.pir b/runtime/tcllib.pir index 421b5ab..94fbf93 100644 --- a/runtime/tcllib.pir +++ b/runtime/tcllib.pir @@ -16,31 +16,31 @@ providing a compreg-compatible method. .HLL 'parrot' .loadlib 'tcl_ops' -.include 'languages/tcl/src/macros.pir' +.include 'src/macros.pir' .include 'cclass.pasm' .namespace [ 'TclExpr'; 'PAST'; 'Grammar' ] -.include 'languages/tcl/src/grammar/expr/pge2past.pir' +.include 'src/grammar/expr/pge2past.pir' .namespace [ 'TclExpr'; 'PIR'; 'Grammar' ] -.include 'languages/tcl/src/grammar/expr/past2pir.pir' +.include 'src/grammar/expr/past2pir.pir' -.include 'languages/tcl/src/grammar/expr/past.pir' +.include 'src/grammar/expr/past.pir' # all the builtin commands (HLL: Tcl - loads 'tcl_group') -.include 'languages/tcl/runtime/builtins.pir' +.include 'runtime/builtins.pir' # library files (HLL: _Tcl) -.include 'languages/tcl/runtime/conversions.pir' -.include 'languages/tcl/runtime/string_to_list.pir' -.include 'languages/tcl/runtime/variables.pir' -.include 'languages/tcl/runtime/options.pir' +.include 'runtime/conversions.pir' +.include 'runtime/string_to_list.pir' +.include 'runtime/variables.pir' +.include 'runtime/options.pir' # class files (HLL: _Tcl) -.include 'languages/tcl/src/class/tclarray.pir' -.include 'languages/tcl/src/class/tclconst.pir' -.include 'languages/tcl/src/class/tclproc.pir' -.include 'languages/tcl/src/class/tracearray.pir' +.include 'src/class/tclarray.pir' +.include 'src/class/tclconst.pir' +.include 'src/class/tclproc.pir' +.include 'src/class/tracearray.pir' # create the 'tcl' namespace -- see RT #39852 # https://rt.perl.org/rt3/Ticket/Display.html?id=39852 @@ -55,7 +55,7 @@ providing a compreg-compatible method. .sub load_macros :load :anon $P0 = compreg 'PIR' - $P0 = $P0(".sub main\n.include 'languages/tcl/src/macros.pir'\n.end") + $P0 = $P0(".sub main\n.include 'src/macros.pir'\n.end") $P0() .end @@ -250,14 +250,14 @@ got_platform: .end .HLL 'parrot' -.include 'languages/tcl/src/grammar/expr/expression.pir' -.include 'languages/tcl/src/grammar/expr/parse.pir' -.include 'languages/tcl/src/grammar/expr/functions.pir' -.include 'languages/tcl/src/grammar/expr/operators.pir' +.include 'src/grammar/expr/expression.pir' +.include 'src/grammar/expr/parse.pir' +.include 'src/grammar/expr/functions.pir' +.include 'src/grammar/expr/operators.pir' .HLL 'tcl' .namespace [ 'tcl'; 'mathop' ] -.include 'languages/tcl/src/mathops.pir' +.include 'src/mathops.pir' # Load the standard library .HLL 'Tcl' diff --git a/src/macros.pir b/src/macros.pir index 1de5a4f..a711da3 100644 --- a/src/macros.pir +++ b/src/macros.pir @@ -1,4 +1,4 @@ -.include 'languages/tcl/src/returncodes.pasm' +.include 'src/returncodes.pasm' =head1 exception handling macros diff --git a/src/tclsh.pir b/src/tclsh.pir index a96b84f..f3c798c 100644 --- a/src/tclsh.pir +++ b/src/tclsh.pir @@ -9,8 +9,8 @@ .HLL 'Tcl' .loadlib 'tcl_group' -.include 'languages/tcl/src/returncodes.pasm' -.include 'languages/tcl/src/macros.pir' +.include 'src/returncodes.pasm' +.include 'src/macros.pir' .macro set_tcl_argv() argc = argv # update diff --git a/tools/gen_builtins.pl b/tools/gen_builtins.pl index 3aece2c..b1c6029 100755 --- a/tools/gen_builtins.pl +++ b/tools/gen_builtins.pl @@ -22,7 +22,7 @@ .loadlib 'tcl_group' END_PIR -print " .include 'languages/tcl/$static_dir/$_.pir'\n" for @static_cmds; +print " .include '$static_dir/$_.pir'\n" for @static_cmds; sub pir_cmds_in_dir { my ($dir) = @_;