Radovan Baranec wrote:
Hi,
I am fighting with this problem few hours. I`ve changed cpointer.pmc and
tried to test these changes. In doc stands that I should run realclean
and then Configure.pl to add new PMC to the set of built-in PMCs. But
these scripts are only in downloaded files they are not in installed
files. So what should I do? Should I change cpointer.pmc in downloaded
files or in installed files, then run realclean and then Configure.pl
from downloaded files or what? I`ve already tried both of it with no
success.
Those instructions are for adding a new PMC to the Parrot core. When
you're creating PMCs outside the core, you should create your own new
PMC instead of editing an installed PMC directly. Copy the cpointer.pmc
source file and change the name to something like mycpointer.pmc. Edit
the file to change the name in the pmclass line and add 'dynpmc':
pmclass MyCPointer dynpmc need_ext {
/* Copy of all ATTRs and VTABLE functions. */
}
Also change every instance of the old name ("CPointer" or "CPOINTER") to
the new name (also in CamelCase or ALLCAPS).
Then you'll need a few command-line calls to build and install the PMC,
easiest in a makefile. I've attached a Makefile.in template which you
can turn into a makefile with the command (all one line):
perl /usr/local/lib/parrot/1.4.0/tools/dev/gen_makefile.pl Makefile.in
Makefile
Most of the file is just getting configuration values from Parrot. The
actual work is the final 5 lines.
Create a dump format of the PMC:
$(PMC2CD) mycpointer.pmc
Generate the C file for the PMC:
$(PMC2CC) mycpointer.pmc
Compile the C file to a dynamic object:
$(CC) -c @cc_o_...@mycpointer$(O) $(INCLUDES) $(CFLAGS)
$(LD) @ld_...@mycpointer$(LOAD_EXT) mycpointer$(O) $(LINKARGS)
Install the shared library in the dynamic extension directory:
$(CP) "mycpointer$(LOAD_EXT)" $(INSTALL_DIR)
Run 'sudo make install' (or your platform equivalent), then you can use
your new PMC. Here's a small PIR file that uses it:
.loadlib 'mycpointer'
.sub main :main
$P0 = new 'MyCPointer'
#...
.end
Allison
PERL = @perl@
CP = @cp@
VERSION_DIR = @versiondir@
INCLUDE_DIR = @include...@$(VERSION_DIR)
LIB_DIR = @lib...@$(VERSION_DIR)
SRC_DIR = @src...@$(VERSION_DIR)
BUILD_TOOLS_DIR = $(LIB_DIR)@sl...@tools@sl...@build
INSTALL_DIR = $(LIB_DIR)@sl...@dynext
CC = @cc@
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@
O = @o@
LOAD_EXT = @load_ext@
PMC2C_INCLUDES = --include $(SRC_DIR) --include $(SRC_DIR)@sl...@pmc
PMC2C = $(PERL) $(BUILD_TOOLS_DIR)@[email protected]
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)
build:
$(PMC2CD) mycpointer.pmc
$(PMC2CC) mycpointer.pmc
$(CC) -c @cc_o_...@mycpointer$(O) $(INCLUDES) $(CFLAGS) mycpointer.c
$(LD) @ld_...@mycpointer$(LOAD_EXT) mycpointer$(O) $(LINKARGS)
install:
$(CP) "mycpointer$(LOAD_EXT)" $(INSTALL_DIR)
_______________________________________________
http://lists.parrot.org/mailman/listinfo/parrot-dev