All -- I'm working on getting shared library building working, and this is a step in that direction. I made a few changes to the build stuff to scratch a few itches along the way.
I'm of a mind to commit this, but I wanted to give you all an opportunity to have a look first. I've attached the patch itself and the commit log message. Regards, -- Gregor ____________________________________________________________________ / Inspiration >> Innovation >> Excellence (TM) \ Gregor N. Purdy [EMAIL PROTECTED] Focus Research, Inc. http://www.focusresearch.com/ 8080 Beckett Center Drive #203 513-860-3570 vox West Chester, OH 45069 513-860-3579 fax \____________________________________________________________________/ [[EMAIL PROTECTED]]$ ping osama.taliban.af PING osama.taliban.af (68.69.65.68) from 20.1.9.11 : 56 bytes of data. >From 85.83.77.67: Time to live exceeded
? t.s ? tryme ? nestedloops.pasm ? nestedloops.pbc ? x.pasm ? x.pbc ? parrot.pl ? Parrot/Interpreter.pm ? docs/Makefile.new ? examples/shootout Index: .cvsignore =================================================================== RCS file: /home/perlcvs/parrot/.cvsignore,v retrieving revision 1.12 diff -a -u -r1.12 .cvsignore --- .cvsignore 15 Dec 2001 01:39:40 -0000 1.12 +++ .cvsignore 30 Dec 2001 14:37:26 -0000 @@ -1,3 +1,4 @@ +blib core_ops.c core_ops_prederef.c Makefile Index: Configure.pl =================================================================== RCS file: /home/perlcvs/parrot/Configure.pl,v retrieving revision 1.44 diff -a -u -r1.44 Configure.pl --- Configure.pl 26 Dec 2001 05:12:25 -0000 1.44 +++ Configure.pl 30 Dec 2001 14:37:26 -0000 @@ -1,66 +1,92 @@ #!/usr/bin/perl -w -#so we get -w - -#Configure.pl, written by Brent Dax +# +# Configure.pl +# +# $Id: $ +# +# Author: Brent Dax +# use strict; + use Config; use Getopt::Long; use ExtUtils::Manifest qw(manicheck); use File::Copy; +use Parrot::BuildUtil; + + +# +# Read the array and scalar forms of the version. +# from the VERSION file. +# + +my $parrot_version = parrot_version(); +my @parrot_version = parrot_version(); + + +# +# Handle options: +# + my($opt_debugging, $opt_defaults, $opt_version, $opt_help) = (0, 0, 0, 0); my(%opt_defines); my $result = GetOptions( - 'debugging!' => \$opt_debugging, - 'defaults!' => \$opt_defaults, - 'version' => \$opt_version, - 'help' => \$opt_help, - 'define=s' => \%opt_defines, + 'debugging!' => \$opt_debugging, + 'defaults!' => \$opt_defaults, + 'version' => \$opt_version, + 'help' => \$opt_help, + 'define=s' => \%opt_defines, ); if($opt_version) { - print '$Id: Configure.pl,v 1.44 2001/12/26 05:12:25 gregor Exp $' . "\n"; - exit; + print "Parrot Version $parrot_version Configure\n"; + print '$Id: Configure.pl,v 1.44 2001/12/26 05:12:25 gregor Exp $' . "\n"; + exit; } if($opt_help) { - print <<"EOT"; + print <<"EOT"; $0 - Parrot Configure Options: --debugging Enable debugging --defaults Accept all default values --define name=value Defines value name as value --help This text - --version Show assembler version + --version Show version EOT - exit; + exit; } my($DDOK)=undef; eval { - require Data::Dumper; - Data::Dumper->import(); - $DDOK=1; + require Data::Dumper; + Data::Dumper->import(); + $DDOK=1; }; -#print the header +# +# print the header +# + print <<"END"; -Parrot Configure -Copyright (C) 2001 Yet Another Society +Parrot Version $parrot_version Configure +Copyright (C) 2001-2002 Yet Another Society Since you're running this script, you obviously have Perl 5--I'll be pulling some defaults from its configuration. -First, I'm gonna check the manifest, to make sure you got a -complete Parrot kit. +Checking the MANIFEST to make sure you have a complete Parrot kit... END check_manifest(); -#Some versions don't seem to have ivtype or nvtype--provide -#defaults for them. -#XXX Figure out better defaults +# +# Some versions don't seem to have ivtype or nvtype--provide +# defaults for them. +# XXX Figure out better defaults +# my ($archname, $cpuarch, $osname); my ($jitarchname, $jitcpuarch, $jitosname, $jitcapable); @@ -82,68 +108,89 @@ ($jitcpuarch, $jitosname) = split('-', $jitarchname); my(%c)=( - iv => ($Config{ivtype} ||'long'), - intvalsize => undef, + iv => ($Config{ivtype} || 'long'), + intvalsize => undef, - nv => ($Config{nvtype} ||'double'), - numvalsize => undef, + nv => ($Config{nvtype} || 'double'), + numvalsize => undef, - opcode_t => ($Config{ivtype} ||'long'), - longsize => undef, + opcode_t => ($Config{ivtype} || 'long'), + longsize => undef, - cc => $Config{cc}, - #ADD C COMPILER FLAGS HERE - ccflags => $Config{ccflags}, - libs => $Config{libs}, - cc_debug => '-g', - o => '.o', # object files extension - exe => $Config{_exe}, - - ld => $Config{ld}, - ld_out => '-o ', # ld output file - ld_debug => '', # include debug info in executable - - perl => $^X, - test_prog => 'test_parrot' . $Config{_exe}, - debugging => $opt_debugging, - rm_f => 'rm -f', - stacklow => '(~0xfff)', - intlow => '(~0xfff)', - numlow => '(~0xfff)', - strlow => '(~0xfff)', - pmclow => '(~0xfff)', - make=> $Config{make}, - make_set_make=> $Config{make_set_make}, - - platform => $^O, - - cpuarch => $cpuarch, - osname => $osname, - archname => $archname, - - jitcpuarch => $jitcpuarch, - jitosname => $jitosname, - jitarchname => $jitarchname, - jitcapable => $jitcapable, - - cp => 'cp', - slash => '/', + cc => $Config{cc}, + + # + # ADD C COMPILER FLAGS HERE + # + + ccflags => $Config{ccflags}, + libs => $Config{libs}, + cc_debug => '-g', + o => '.o', # object files extension + exe => $Config{_exe}, + + ld => $Config{ld}, + ld_out => '-o ', # ld output file + ld_debug => '', # include debug info in executable + + perl => $^X, + test_prog => 'test_parrot' . $Config{_exe}, + debugging => $opt_debugging, + rm_f => 'rm -f', + stacklow => '(~0xfff)', + intlow => '(~0xfff)', + numlow => '(~0xfff)', + strlow => '(~0xfff)', + pmclow => '(~0xfff)', + make => $Config{make}, + make_set_make => $Config{make_set_make}, + + platform => $^O, + + cpuarch => $cpuarch, + osname => $osname, + archname => $archname, + + jitcpuarch => $jitcpuarch, + jitosname => $jitosname, + jitarchname => $jitarchname, + jitcapable => $jitcapable, + + cp => 'cp', + slash => '/', + + VERSION => $parrot_version, + MAJOR => $parrot_version[0], + MINOR => $parrot_version[1], + PATCH => $parrot_version[2], ); -#copy the things from --define foo=bar + +# +# Copy the things from --define foo=bar +# + @c{keys %opt_defines}=values %opt_defines; -# set up default values + +# +# Set up default values +# + my $hints = "hints/" . lc($^O) . ".pl"; if(-f $hints) { - local($/); - open HINT, "< $hints" or die "Unable to open hints file '$hints'"; - my $hint = <HINT>; - close HINT; - eval $hint or die "Error in hints file $hints: '$@/$!'"; + local($/); + open HINT, "< $hints" or die "Unable to open hints file '$hints'"; + my $hint = <HINT>; + close HINT; + eval $hint or die "Error in hints file $hints: '$@/$!'"; } -#ask questions + +# +# Ask questions +# + prompt("What C compiler do you want to use?", 'cc'); prompt("How about your linker?", 'ld'); prompt("What flags would you like passed to your C compiler?", 'ccflags'); @@ -152,7 +199,11 @@ prompt("And your floats?", 'nv'); prompt("What is your native opcode type?", 'opcode_t'); + +# # Copy the appropriate platform-specific file over +# + if (-e "platforms/$c{platform}.h") { copy("platforms/$c{platform}.h", "include/parrot/platform.h"); copy("platforms/$c{platform}.c", "platform.c"); @@ -163,201 +214,281 @@ } unless( $c{debugging} ) { - $c{ld_debug} = ' '; - $c{cc_debug} = ' '; + $c{ld_debug} = ' '; + $c{cc_debug} = ' '; } print <<"END"; -Okay. Now I'm gonna probe Perl 5's configuration to see -what headers you have around. This could take a bit on slow -machines... +Probing Perl 5's configuration to determine which headers you have (this could +take a while on slow machines)... END -#set up HAS_HEADER_ + +# +# Set up HAS_HEADER_ +# + foreach(grep {/^i_/} keys %Config) { - $c{$_}=$Config{$_}; - $c{headers}.=defineifdef((/^i_(.*)$/)); + $c{$_}=$Config{$_}; + $c{headers}.=defineifdef((/^i_(.*)$/)); } print <<"END"; -Alright, now I'm gonna check some stuff by compiling and running -a small C program. This could take a bit... +Determining C data type sizes by compiling and running a small C program (this +could take a while): + END { - my %newc; + my %newc; - buildfile("test_c"); - compiletestc(); - %newc=eval(runtestc()) or die "Can't run the test program: $!"; + buildfile("test_c"); + compiletestc(); + %newc=eval(runtestc()) or die "Can't run the test program: $!"; - @c{keys %newc}=values %newc; + @c{keys %newc}=values %newc; - unlink('test.c', "test_siz$c{exe}", "test$c{o}"); + unlink('test.c', "test_siz$c{exe}", "test$c{o}"); } print <<"END"; -Done. Now I'm figuring out what formats to pass to pack() for the -various Parrot internal types. +Figuring out the formats to pass to pack() for the various Parrot internal +types... END +# # Alas perl5.7.2 doesn't have an INTVAL flag for pack(). # The ! modifier only works for perl 5.6.x or greater. +# + foreach ('intvalsize', 'opcode_t_size') { my $which = $_ eq 'intvalsize' ? 'packtype_i' : 'packtype_op'; if (($] >= 5.006) && ($c{$_} == $c{longsize}) ) { - $c{$which} = 'l!'; + $c{$which} = 'l!'; } elsif ($c{$_} == 4) { - $c{$which} = 'l'; - } - elsif ($c{$_} == 8) { - $c{$which} = 'q'; + $c{$which} = 'l'; } else { - die "Configure.pl: Unable to find a suitable packtype for $_.\n"; + die "Configure.pl: Unable to find a suitable packtype for $_.\n"; } } $c{packtype_n} = 'd'; + +# +# Build config.h, the Makfefiles and Types.pm: +# +# Also build Parrot/Config.pm +# + print <<"END"; -Okay, that's finished. I'm now going to write your very -own Makefile, config.h, Parrot::Types, and Parrot::Config to disk. +Building a preliminary version of include/parrot/config.h, your Makefiles, and +other files: + END -# now let's assemble the config.h file buildfile("config_h", "include/parrot"); -# and the makefile + buildfile("Makefile"); buildfile("classes/Makefile"); buildfile("languages/Makefile"); buildfile("languages/jako/Makefile"); buildfile("languages/miniperl/Makefile"); buildfile("languages/scheme/Makefile"); -# and Parrot::Config -buildconfigpm(); -# and the types file + buildfile("Types_pm", "Parrot"); -# and now we figure out how big our things are +buildconfigpm(); + + +# +# And now we figure out how big our things are +# + print <<"END"; -Alright, now I'm gonna check some stuff by compiling and running -another small C program. This could take a bit... +Checking some things by compiling and running another small C program (this +could take a while): + END { - my %newc; + my %newc; - open NEEDED, ">include/parrot/vtable.h"; - close NEEDED; - buildfile("testparrotsizes_c"); - compiletestc("testparrotsizes"); - %newc=eval(runtestc()) or die "Can't run the test program: $!"; + open NEEDED, ">include/parrot/vtable.h"; + close NEEDED; + buildfile("testparrotsizes_c"); + compiletestc("testparrotsizes"); + %newc=eval(runtestc()) or die "Can't run the test program: $!"; - @c{keys %newc}=values %newc; + @c{keys %newc}=values %newc; - @c{qw(stacklow intlow numlow strlow pmclow)} = lowbitmask(@c{qw(stackchunk iregchunk nregchunk sregchunk pregchunk)}); + @c{qw(stacklow intlow numlow strlow pmclow)} = lowbitmask(@c{qw(stackchunk +iregchunk nregchunk sregchunk pregchunk)}); - unlink('testparrotsizes.c', "test_siz$c{exe}", "test$c{o}"); - unlink("include/parrot/vtable.h"); + unlink('testparrotsizes.c', "test_siz$c{exe}", "test$c{o}"); + unlink("include/parrot/vtable.h"); } -# rewrite the config file with the updated info + +# +# Rewrite the config file with the updated info +# + +print <<"END"; + +Updating include/parrot/config.h: + +END + buildfile("config_h", "include/parrot"); + +# +# Wrap up: +# + print <<"END"; Okay, we're done! -You can now use `make parrot' (or your platform's equivalent to `make') -to build your Parrot. + +You can now use `make' (or your platform's equivalent to `make') to build your +Parrot. After that, you can use `make test' to run the test suite. Happy Hacking, - The Parrot Team + + The Parrot Team + END -#give us the #define we may need for header X +exit(0); + + +############################################################################### +############################################################################### +## +## Support Subroutines +## +############################################################################### +############################################################################### + + +# +# defineifdef() +# +# Give us the #define we may need for header X +# + sub defineifdef { - my $thing=shift; + my $thing=shift; - if($Config{"i_$thing"}) { - return "#define HAS_HEADER_\U$thing\E\n"; - } - else { - return "#undef HAS_HEADER_\U$thing\E\n"; #XXX do we want this? - } + if($Config{"i_$thing"}) { + return "#define HAS_HEADER_\U$thing\E\n"; + } + else { + return "#undef HAS_HEADER_\U$thing\E\n"; #XXX do we want this? + } } -#prompt for something from the user + +# +# prompt() +# +# Prompt for something from the user. +# + sub prompt { - return if $opt_defaults; + return if $opt_defaults; - my($message, $field)=(@_); - my($input); - print "$message [$c{$field}] "; - chomp($input=<STDIN>); - $c{$field}=$input||$c{$field}; + my($message, $field)=(@_); + my($input); + print "$message [$c{$field}] "; + chomp($input=<STDIN>); + $c{$field}=$input||$c{$field}; } + +# +# buildfile() +# + sub buildfile { - my($filename, $path)=@_; - $path||='.'; + my($source_filename, $path)=@_; + $path||='.'; - local $/; - open(IN, "<$filename.in") or die "Can't open $filename.in: $!"; - my $text=<IN>; - close(IN) or die "Can't close $filename.in: $!"; - - $text =~ s/\$\{(\w+)\}/$c{$1}/g; - $filename =~ s/_/./; #config_h => config.h - - open(OUT, ">$path/$filename") or die "Can't open $path/$filename: $!"; - print OUT $text; - close(OUT) or die "Can't close $filename: $!"; + my $target_filename = $source_filename; + $target_filename =~ s/_/./; #config_h => config.h + + printf " Building %-30s from %s...\n", "$path/$target_filename", + "$source_filename.in"; + + local $/; + open(IN, "<$source_filename.in") or die "Can't open $source_filename.in: $!"; + my $text=<IN>; + close(IN) or die "Can't close $source_filename.in: $!"; + + $text =~ s/\$\{(\w+)\}/$c{$1}/g; + + open(OUT, ">$path/$target_filename") or die "Can't open $path/$target_filename: +$!"; + print OUT $text; + close(OUT) or die "Can't close $target_filename: $!"; } + +# +# buildconfigpm() +# + sub buildconfigpm { - unless($DDOK) { - print <<"END"; + unless($DDOK) { + print <<"END"; Your system doesn't have Data::Dumper installed, so I couldn't build Parrot::Config. If you want Parrot::Config installed, use CPAN.pm to install Data::Dumper and run this script again. END - return; - } + return; + } + + printf " Building %-30s from %s...\n", "Parrot/Config.pm", + "Config_pm.in"; + + my %C=%c; + delete $C{headers}; + my $dd=new Data::Dumper([\%C]); + $dd->Names(['*PConfig']); + + local $/; + open(IN, "<Config_pm.in") or die "Can't open Config_pm.in: $!"; + my $text=<IN>; + close(IN) or die "Can't close Config.pm_in: $!"; - my %C=%c; - delete $C{headers}; - my $dd=new Data::Dumper([\%C]); - $dd->Names(['*PConfig']); - - local $/; - open(IN, "<Config_pm.in") or die "Can't open Config_pm.in: $!"; - my $text=<IN>; - close(IN) or die "Can't close Config.pm_in: $!"; - - $text =~ s/#DUMPER OUTPUT HERE/$dd->Dump()/eg; - - open(OUT, ">Parrot/Config.pm") or die "Can't open file Parrot/Config.pm: $!"; - print OUT $text; - close(OUT) or die "Can't close file Parrot/Config.pm: $!"; + $text =~ s/#DUMPER OUTPUT HERE/$dd->Dump()/eg; + + open(OUT, ">Parrot/Config.pm") or die "Can't open file Parrot/Config.pm: $!"; + print OUT $text; + close(OUT) or die "Can't close file Parrot/Config.pm: $!"; } + +# +# check_manifest() +# + sub check_manifest { - print "\n"; + print "\n"; - my(@missing)=manicheck(); + my(@missing)=manicheck(); - if(@missing) { - print <<"END"; + if(@missing) { + print <<"END"; Ack, some files were missing! I can't continue running without everything here. Please try to find the above @@ -365,19 +496,24 @@ END - exit; - } - else { - print <<"END"; + exit; + } + else { + print <<"END"; Okay, we found everything. Next you'll need to answer a few questions about your system. Rules are the same as Perl 5's Configure--defaults are in square brackets, and you can hit enter to accept them. END - } + } } + +# +# compiletestc() +# + sub compiletestc { my $name; $name = shift; @@ -385,18 +521,32 @@ system("$c{cc} $c{ccflags} -I./include -o test_siz$c{exe} $name.c") and die "C compiler died!"; } + +# +# runtestc() +# + sub runtestc { - `./test_siz$c{exe}` + `./test_siz$c{exe}` } -# Find the bitmask for the low bits of any passed-in size + +# +# lowbitmas() +# +# Find the bitmask for the low bits of any passed-in size. +# + sub lowbitmask { my @returns; + foreach (@_) { - my $vector = unpack("b*", pack("V", $_)); - my $offset = rindex($vector, "1")+1; - my $mask = 2**$offset - 1; - push @returns, "(~0x".sprintf("%x", $mask).")"; + my $vector = unpack("b*", pack("V", $_)); + my $offset = rindex($vector, "1")+1; + my $mask = 2**$offset - 1; + push @returns, "(~0x".sprintf("%x", $mask).")"; } + return @returns; } + Index: Makefile.in =================================================================== RCS file: /home/perlcvs/parrot/Makefile.in,v retrieving revision 1.88 diff -a -u -r1.88 Makefile.in --- Makefile.in 30 Dec 2001 12:16:42 -0000 1.88 +++ Makefile.in 30 Dec 2001 14:37:26 -0000 @@ -1,8 +1,63 @@ O = ${o} +SO = .so +A = .a RM_F = ${rm_f} +RM_RF = ${rm_f} -r +AR_CRS = ar crs INC=include/parrot + +############################################################################### +# +# "STICKY" GENERATED FILES: +# +# These files are created when Configure.pl runs. +# +# We don't delete these on 'clean' only on 'realclean'. +# That way, we don't have to re-Configure.pl after making +# clean. +# +############################################################################### + +GEN_MAKEFILES = Makefile classes/Makefile languages/Makefile \ +languages/jako/Makefile languages/miniperl/Makefile languages/scheme/Makefile + +GEN_CONFIGS = include/parrot/config.h include/parrot/platform.h Parrot/Config.pm \ +Parrot/Types.pm platform.c + +STICKY_FILES = $(GEN_CONFIGS) $(GEN_MAKEFILES) + + +############################################################################### +# +# "FLUID" GENERATED FILES: +# +# These files are created during the build process. +# +# We *do* delete these on 'clean'. +# +############################################################################### + +GEN_OPSFILES = vtable.ops + +GEN_HEADERS = $(INC)/vtable.h $INC/jit_struct.h $(INC)/oplib/core_ops.h \ +$(INC)/oplib/core_ops_prederef.h + +GEN_SOURCES = core_ops.c core_ops_prederef.c vtable_ops.c + +GEN_MODULES = Parrot/Jit.pm Parrot/PMC.pm Parrot/Types.pm \ +Parrot/OpLib/core.pm + +FLUID_FILES = $(GEN_OPSFILES) $(GEN_HEADERS) $(GEN_SOURCES) $(GEN_MODULES) + + +############################################################################### +# +# OTHER FILE GROUPS: +# +############################################################################### + H_FILES = $(INC)/config.h $(INC)/exceptions.h $(INC)/io.h $(INC)/op.h \ $(INC)/register.h $(INC)/string.h $(INC)/events.h $(INC)/interpreter.h \ $(INC)/memory.h $(INC)/parrot.h $(INC)/stacks.h $(INC)/packfile.h \ @@ -14,16 +69,29 @@ CLASS_O_FILES = classes/default$(O) classes/perlint$(O) classes/perlstring$(O) \ classes/perlnum$(O) classes/perlarray$(O) classes/perlundef$(O) -O_FILES = global_setup$(O) interpreter$(O) parrot$(O) register$(O) \ -core_ops$(O) core_ops_prederef$(O) memory$(O) packfile$(O) stacks$(O) string$(O) encoding$(O) \ -chartype$(O) runops_cores$(O) trace$(O) pmc$(O) key$(O) \ -encodings/singlebyte$(O) encodings/utf8$(O) encodings/utf16$(O) \ -encodings/utf32$(O) chartypes/unicode$(O) chartypes/usascii$(O) resources$(O) \ -platform$(O) $(CLASS_O_FILES) jit$(O) - -#DO NOT ADD C COMPILER FLAGS HERE -#Add them in Configure.pl--look for the -#comment 'ADD C COMPILER FLAGS HERE' +ENCODING_O_FILES = encodings/singlebyte$(O) encodings/utf8$(O) encodings/utf16$(O) \ +encodings/utf32$(O) + +CHARTYPE_O_FILES = chartypes/unicode$(O) chartypes/usascii$(O) + +INTERP_O_FILES = global_setup$(O) interpreter$(O) parrot$(O) register$(O) \ +core_ops$(O) core_ops_prederef$(O) memory$(O) packfile$(O) stacks$(O) \ +string$(O) encoding$(O) chartype$(O) runops_cores$(O) trace$(O) pmc$(O) key$(O) \ +platform$(O) jit$(O) resources$(O) + +O_FILES = $(INTERP_O_FILES) $(CLASS_O_FILES) $(ENCODING_O_FILES) $(CHARTYPE_O_FILES) + + +############################################################################### +# +# BUILD TOOL CONFIGURATIONS: +# +# DO NOT ADD C COMPILER FLAGS HERE +# Add them in Configure.pl--look for the +# comment 'ADD C COMPILER FLAGS HERE' +# +############################################################################### + CFLAGS = ${ccflags} ${cc_debug} -I./include C_LIBS = ${libs} @@ -31,10 +99,30 @@ CC = ${cc} LD = ${ld} PERL = ${perl} + + +############################################################################### +# +# BUILD TARGET CONFIGURATIONS: +# +############################################################################### + TEST_PROG = ${test_prog} +TEST_PROG_SO = ${test_prog}_so PDUMP = pdump${exe} + + +############################################################################### +# +# MAKE CONFIGURATION: +# +############################################################################### + +# # This is set to MAKE=$make if your $make command doesn't # do it for you. +# + ${make_set_make} .c$(O): @@ -42,22 +130,74 @@ all : $(TEST_PROG) $(PDUMP) examples/assembly/mops${exe} examples/mops/mops${exe} docs -#XXX This target is not portable to Win32 +$(TEST_PROG): test_main$(O) $(O_FILES) Parrot/OpLib/core.pm Parrot/PMC.pm + $(CC) $(CFLAGS) -o $(TEST_PROG) $(O_FILES) test_main$(O) $(C_LIBS) -shared: Libparrot.so libcore_prederef_0_3.so -libparrot.so: $(O_FILES) - $(CC) -shared $(C_LIBS) -o $@ $(O_FILES) +############################################################################### +# +# Shared Library Targets: +# +# XXX This target is not portable to Win32 +# +############################################################################### -libcore_prederef_0_3.so: core_ops_prederef$(O) - $(CC) -shared $(C_LIBS) -o $@ $(O_FILES) +blib: + mkdir -p blib -$(TEST_PROG): test_main$(O) $(O_FILES) Parrot/OpLib/core.pm Parrot/PMC.pm - $(CC) $(CFLAGS) -o $(TEST_PROG) $(O_FILES) test_main$(O) $(C_LIBS) +blib_lib: + mkdir -p blib/lib + +shared: blib_lib blib/lib/libparrot$(SO) blib/lib/libcore_prederef$(SO) +$(TEST_PROG_SO) + +blib/lib/libparrot$(SO).${VERSION}: $(O_FILES) + $(CC) -shared -Wl,-soname,libparrot$(SO).${MAJOR} -o +blib/lib/libparrot$(SO).${VERSION} $(O_FILES) + +blib/lib/libparrot$(SO).${MAJOR}.${MINOR}: blib/lib/libparrot$(SO).${VERSION} + rm -f $@ + cd blib/lib; ln -s libparrot$(SO).${VERSION} libparrot$(SO).${MAJOR}.${MINOR} + +blib/lib/libparrot$(SO).${MAJOR}: blib/lib/libparrot$(SO).${MAJOR}.${MINOR} + rm -f $@ + cd blib/lib; ln -s libparrot$(SO).${MAJOR}.${MINOR} libparrot$(SO).${MAJOR} + +blib/lib/libparrot$(SO): blib/lib/libparrot$(SO).${MAJOR} + rm -f $@ + cd blib/lib; ln -s libparrot$(SO).${MAJOR} libparrot$(SO) + +blib/lib/libcore_prederef$(SO).${VERSION}: core_ops_prederef$(O) + $(CC) -shared -Wl,-soname,libparrot$(SO).${MAJOR} -o +blib/lib/libcore_prederef$(SO).${VERSION} core_ops_prederef$(O) + +blib/lib/libcore_prederef$(SO).${MAJOR}.${MINOR}: +blib/lib/libcore_prederef$(SO).${VERSION} + rm -f $@ + cd blib/lib; ln -s libcore_prederef$(SO).${VERSION} +libcore_prederef$(SO)..${MAJOR}.${MINOR} + +blib/lib/libcore_prederef$(SO).${MAJOR}: +blib/lib/libcore_prederef$(SO).${MAJOR}.${MINOR} + rm -f $@ + cd blib/lib; ln -s libcore_prederef$(SO).${MAJOR}.${MINOR} +libcore_prederef$(SO).${MAJOR} + +blib/lib/libcore_prederef$(SO): blib/lib/libcore_prederef$(SO).${MAJOR} + rm -f $@ + cd blib/lib; ln -s libcore_prederef$(SO).${MAJOR} libcore_prederef$(SO) + +$(TEST_PROG_SO): test_main$(O) blib/lib/libparrot$(SO) Parrot/OpLib/core.pm +Parrot/PMC.pm + $(CC) $(CFLAGS) -o $(TEST_PROG) test_main$(O) $(C_LIBS) -L blib/lib -lparrot + + +# +# Parrot Dump +# $(PDUMP): pdump$(O) $(O_FILES) $(CC) $(CFLAGS) -o $(PDUMP) $(O_FILES) pdump$(O) $(C_LIBS) + +############################################################################### +# +# Other Dependencies and Build Rules: +# +############################################################################### + test_main$(O): test_main.c $(H_FILES) examples/assembly/mops.pbc: examples/assembly/mops.pasm assemble.pl @@ -138,7 +278,7 @@ vtable.ops: make_vtable_ops.pl $(PERL) make_vtable_ops.pl > vtable.ops -$(INC)/config.h: Configure.pl config_h.in +$(STICKY_FILES): Configure.pl config_h.in $(PERL) Configure.pl $(INC)/vtable.h: vtable.tbl vtable_h.pl @@ -160,37 +300,62 @@ languages.dummy: cd languages && $(MAKE) && cd .. -clean: - $(RM_F) *$(O) chartypes/*$(O) encodings/*$(O) - $(RM_F) *.s core_ops.c core_ops_prederef.c $(TEST_PROG) $(PDUMP) - $(RM_F) $(INC)/vtable.h - $(RM_F) $(INC)/oplib/core_ops.h $(INC)/oplib/core_ops_prederef.h - $(RM_F) vtable.ops + +############################################################################### +# +# Testing Targets: +# +############################################################################### + +test: $(TEST_PROG) assemble.pl .test_dummy + +.test_dummy: + $(PERL) t/harness + + +############################################################################### +# +# Cleaning Targets: +# +############################################################################### + +clean: testclean + $(RM_F) $(O_FILES) + $(RM_F) *.s + $(RM_F) $(FLUID_FILES) $(RM_F) $(TEST_PROG) $(PDUMP) - $(RM_F) t/op/*.pasm t/op/*.pbc t/op/*.out $(RM_F) examples/assembly/mops${exe} examples/assembly/mops.c $(RM_F) examples/assembly/mops$(O) examples/assembly/mops.pbc $(RM_F) examples/mops/mops$(O) examples/mops/mops${exe} - $(RM_F) Parrot/OpLib/core.pm - $(RM_F) Parrot/Jit.pm - $(RM_F) include/parrot/jit_struct.h - $(RM_F) libparrot.so libcore_prederef_0_3.so + $(RM_RF) blib $(RM_F) *~ cd docs && $(MAKE) clean && cd .. cd classes && $(MAKE) clean && cd .. cd languages && $(MAKE) clean && cd .. +testclean: + $(RM_F) t/op/*.pasm t/op/*.pbc t/op/*.out + +realclean: clean + $(RM_F) $(STICKY_FILES) + distclean: $(PERL) -MExtUtils::Manifest=filecheck -le '$$ExtUtils::Manifest::Quiet=1;unlink $$_ for filecheck()' cvsclean: $(PERL) -MExtUtils::Manifest=filecheck -le '$$ExtUtils::Manifest::Quiet=1; do { unlink $$_ unless $$_ =~ m!(?:CVS/|\.cvs)! } for filecheck()' -test: $(TEST_PROG) assemble.pl .test_dummy -.test_dummy: - $(PERL) t/harness + +############################################################################### +# +# CVS Targets: +# +############################################################################### update: cvs -q update -dP + +status: + cvs -n -q upd -dP Index: VERSION =================================================================== RCS file: VERSION diff -N VERSION --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ VERSION 30 Dec 2001 14:37:26 -0000 @@ -0,0 +1 @@ +0.0.3 Index: config_h.in =================================================================== RCS file: /home/perlcvs/parrot/config_h.in,v retrieving revision 1.12 diff -a -u -r1.12 config_h.in --- config_h.in 27 Dec 2001 17:08:47 -0000 1.12 +++ config_h.in 30 Dec 2001 14:37:26 -0000 @@ -37,10 +37,13 @@ #define JIT_ARCHNAME "${jitarchname}" #define JIT_CAPABLE ${jitcapable} -#define PARROT_CORE_OPLIB_NAME "core" -#define PARROT_CORE_OPLIB_MAJOR_VERSION 0 -#define PARROT_CORE_OPLIB_MINOR_VERSION 3 -#define PARROT_CORE_OPLIB_INIT Parrot_DynOp_core_0_3 +#define PARROT_VERSION "${VERSION}" +#define PARROT_MAJOR_VERSION ${MAJOR} +#define PARROT_MINOR_VERSION ${MINOR} +#define PARROT_PATCH_VERSION ${PATCH} + +#define PARROT_CORE_OPLIB_NAME "core" +#define PARROT_CORE_OPLIB_INIT Parrot_DynOp_core_${MAJOR}_${MINOR}_${PATCH} ${headers} Index: core.ops =================================================================== RCS file: /home/perlcvs/parrot/core.ops,v retrieving revision 1.61 diff -a -u -r1.61 core.ops --- core.ops 30 Dec 2001 12:04:56 -0000 1.61 +++ core.ops 30 Dec 2001 14:37:27 -0000 @@ -2,7 +2,7 @@ ** core.ops */ -VERSION = 0.3; +VERSION = PARROT_VERSION; =head1 NAME Index: interpreter.c =================================================================== RCS file: /home/perlcvs/parrot/interpreter.c,v retrieving revision 1.43 diff -a -u -r1.43 interpreter.c --- interpreter.c 29 Dec 2001 22:12:37 -0000 1.43 +++ interpreter.c 30 Dec 2001 14:37:28 -0000 @@ -93,12 +93,12 @@ char file_name[50]; char func_name[50]; - sprintf(file_name, "lib%s_prederef_%d_%d.so", PARROT_CORE_OPLIB_NAME, - PARROT_CORE_OPLIB_MAJOR_VERSION, PARROT_CORE_OPLIB_MINOR_VERSION); + sprintf(file_name, "lib%s_prederef.so.%s", PARROT_CORE_OPLIB_NAME, + PARROT_VERSION); - sprintf(func_name, "Parrot_DynOp_%s_prederef_%d_%d", - PARROT_CORE_OPLIB_NAME, PARROT_CORE_OPLIB_MAJOR_VERSION, - PARROT_CORE_OPLIB_MINOR_VERSION); + sprintf(func_name, "Parrot_DynOp_%s_prederef_%d_%d_%d", + PARROT_CORE_OPLIB_NAME, PARROT_MAJOR_VERSION, + PARROT_MINOR_VERSION, PARROT_PATCH_VERSION); /* ** Get a handle to the library file: @@ -107,9 +107,8 @@ prederef_oplib_handle = Parrot_dlopen(file_name); if (!prederef_oplib_handle) { - fprintf(stderr, "Unable to dynamically load oplib file '%s' for oplib '%s_prederef' version %d.%d!\n", - file_name, PARROT_CORE_OPLIB_NAME, PARROT_CORE_OPLIB_MAJOR_VERSION, - PARROT_CORE_OPLIB_MINOR_VERSION); + fprintf(stderr, "Unable to dynamically load oplib file '%s' for oplib +'%s_prederef' version %s!\n", + file_name, PARROT_CORE_OPLIB_NAME, PARROT_VERSION); exit(1); } @@ -121,10 +120,8 @@ prederef_oplib_init = Parrot_dlsym(prederef_oplib_handle, func_name); if (!prederef_oplib_init) { - fprintf(stderr, "No exported symbol for oplib init function '%s' from oplib file '%s' for oplib '%s_prederef' version %d.%d!\n", - func_name, file_name, - PARROT_CORE_OPLIB_NAME, PARROT_CORE_OPLIB_MAJOR_VERSION, - PARROT_CORE_OPLIB_MINOR_VERSION); + fprintf(stderr, "No exported symbol for oplib init function '%s' from oplib file +'%s' for oplib '%s_prederef' version %s!\n", + func_name, file_name, PARROT_CORE_OPLIB_NAME, PARROT_VERSION); exit(1); } @@ -136,10 +133,9 @@ prederef_oplib = prederef_oplib_init(); if (!prederef_oplib) { - fprintf(stderr, "No oplib info returned by oplib init function '%s' from oplib file '%s' for oplib '%s_prederef' version %d.%d!\n", + fprintf(stderr, "No oplib info returned by oplib init function '%s' from oplib +file '%s' for oplib '%s_prederef' version %s!\n", func_name, file_name, - PARROT_CORE_OPLIB_NAME, PARROT_CORE_OPLIB_MAJOR_VERSION, - PARROT_CORE_OPLIB_MINOR_VERSION); + PARROT_CORE_OPLIB_NAME, PARROT_VERSION); exit(1); } @@ -150,10 +146,9 @@ prederef_op_count = prederef_oplib->op_count; if (prederef_op_count <= 0) { - fprintf(stderr, "Illegal op count (%d) from oplib file '%s' for oplib '%s_prederef' version %d.%d!\n", + fprintf(stderr, "Illegal op count (%d) from oplib file '%s' for oplib +'%s_prederef' version %s!\n", prederef_op_count, file_name, - PARROT_CORE_OPLIB_NAME, PARROT_CORE_OPLIB_MAJOR_VERSION, - PARROT_CORE_OPLIB_MINOR_VERSION); + PARROT_CORE_OPLIB_NAME, PARROT_VERSION); exit(1); } @@ -164,10 +159,9 @@ prederef_op_info = prederef_oplib->op_info_table; if (!prederef_op_info) { - fprintf(stderr, "No op info table in oplib file '%s' for oplib '%s_prederef' version %d.%d!\n", + fprintf(stderr, "No op info table in oplib file '%s' for oplib '%s_prederef' +version %s!\n", file_name, - PARROT_CORE_OPLIB_NAME, PARROT_CORE_OPLIB_MAJOR_VERSION, - PARROT_CORE_OPLIB_MINOR_VERSION); + PARROT_CORE_OPLIB_NAME, PARROT_VERSION); exit(1); } @@ -178,10 +172,9 @@ prederef_op_func = prederef_oplib->op_func_table; if (!prederef_op_func) { - fprintf(stderr, "No op func table in oplib file '%s' for oplib '%s_prederef' version %d.%d!\n", + fprintf(stderr, "No op func table in oplib file '%s' for oplib '%s_prederef' +version %s!\n", file_name, - PARROT_CORE_OPLIB_NAME, PARROT_CORE_OPLIB_MAJOR_VERSION, - PARROT_CORE_OPLIB_MINOR_VERSION); + PARROT_CORE_OPLIB_NAME, PARROT_VERSION); exit(1); } } Index: make_vtable_ops.pl =================================================================== RCS file: /home/perlcvs/parrot/make_vtable_ops.pl,v retrieving revision 1.12 diff -a -u -r1.12 make_vtable_ops.pl --- make_vtable_ops.pl 28 Dec 2001 18:20:12 -0000 1.12 +++ make_vtable_ops.pl 30 Dec 2001 14:37:28 -0000 @@ -1,7 +1,8 @@ use Parrot::Vtable; + my %vtable = parse_vtable(); -print "VERSION = 0.3;\n\n"; +print "VERSION = PARROT_VERSION;\n\n"; while (<DATA>) { next if /^#/ or /^$/; Index: obscure.ops =================================================================== RCS file: /home/perlcvs/parrot/obscure.ops,v retrieving revision 1.4 diff -a -u -r1.4 obscure.ops --- obscure.ops 27 Dec 2001 17:08:47 -0000 1.4 +++ obscure.ops 30 Dec 2001 14:37:28 -0000 @@ -4,7 +4,7 @@ #include <math.h> -VERSION = 0.3; +VERSION = PARROT_VERSION; =head1 NAME Index: ops2c.pl =================================================================== RCS file: /home/perlcvs/parrot/ops2c.pl,v retrieving revision 1.8 diff -a -u -r1.8 ops2c.pl --- ops2c.pl 27 Dec 2001 17:08:47 -0000 1.8 +++ ops2c.pl 30 Dec 2001 14:37:28 -0000 @@ -53,9 +53,10 @@ my $ops = new Parrot::OpsFile $file; -my $version = $ops->version; +my $version = $ops->version; my $major_version = $ops->major_version; my $minor_version = $ops->minor_version; +my $patch_version = $ops->patch_version; for $file (@ARGV) { die "$0: Could not read ops file '$file'!\n" unless -e $file; @@ -107,7 +108,7 @@ #include "parrot/parrot.h" #include "parrot/oplib.h" -extern op_lib_t * Parrot_DynOp_${base}${suffix}_${major_version}_${minor_version}(void); +extern op_lib_t * +Parrot_DynOp_${base}${suffix}_${major_version}_${minor_version}_${patch_version}(void); END_C @@ -230,12 +231,13 @@ "$base", $major_version, $minor_version, + $patch_version, $num_ops, op_info_table, op_func_table }; -op_lib_t * Parrot_DynOp_${base}${suffix}_${major_version}_${minor_version}(void) { +op_lib_t * +Parrot_DynOp_${base}${suffix}_${major_version}_${minor_version}_${patch_version}(void) + { return &op_lib; } Index: Parrot/BuildUtil.pm =================================================================== RCS file: Parrot/BuildUtil.pm diff -N Parrot/BuildUtil.pm --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ Parrot/BuildUtil.pm 30 Dec 2001 14:37:28 -0000 @@ -0,0 +1,61 @@ +# +# BuildUtil.pm +# + +use strict; + +package Parrot::BuildUtil; + + +BEGIN { + use Exporter; + use vars qw(@ISA @EXPORT); + @ISA = qw(Exporter); + @EXPORT = qw(&parrot_version); +} + + +# +# parrot_version() +# + +my $parrot_version; +my @parrot_version; + +sub parrot_version +{ + if (defined $parrot_version) { + if (wantarray) { return @parrot_version; } + else { return $parrot_version; } + } + + # + # Obtain the official version number from the VERSION file. + # + + open VERSION, "<VERSION" or die "Could not open VERSION file!"; + $parrot_version = <VERSION>; + chomp $parrot_version; + close VERSION; + + $parrot_version =~ s/\s+//g; + + @parrot_version = split(/\./, $parrot_version); + + die "Too few components to VERSION file contents: '$parrot_version' (should be 3)!" + if scalar(@parrot_version) < 3; + + die "Too many components to VERSION file contents: '$parrot_version' (should be 3)!" + if scalar(@parrot_version) > 3; + + foreach (@parrot_version) { + die "Illegal version component: '$_' in VERSION file!" + unless m/^[1-9]*[0-9]$/; + } + + if (wantarray) { return @parrot_version; } + else { return $parrot_version; } +} + +1; + Index: Parrot/OpsFile.pm =================================================================== RCS file: /home/perlcvs/parrot/Parrot/OpsFile.pm,v retrieving revision 1.9 diff -a -u -r1.9 OpsFile.pm --- Parrot/OpsFile.pm 27 Dec 2001 17:08:48 -0000 1.9 +++ Parrot/OpsFile.pm 30 Dec 2001 14:37:28 -0000 @@ -96,7 +96,7 @@ $seen_pod = 1 if m|^=|; unless ($seen_op or m|^(inline\s+)?op\s+|) { - if (m/^\s*VERSION\s*=\s*(\d+\.\d+)\s*;\s*$/) { + if (m/^\s*VERSION\s*=\s*"(\d+\.\d+\.\d+)"\s*;\s*$/) { if (exists $self->{VERSION}) { die "VERSION MULTIPLY DEFINED!"; } @@ -105,12 +105,20 @@ $_ = ''; } + elsif (m/^\s*VERSION\s*=\s*PARROT_VERSION\s*;\s*$/) { + if (exists $self->{VERSION}) { + die "VERSION MULTIPLY DEFINED!"; + } + + $self->version($PConfig{VERSION}); + + $_ = ''; + } $self->{PREAMBLE} .= $_ unless $seen_pod or $count; # Lines up to first op def. next; }; - die "No 'VERSION = ...;' line found before beginning of ops in file '$orig'!\n" unless defined $self->version; @@ -333,11 +341,22 @@ { my $self = shift; - if (@_) { + if (@_ == 1) { $self->{VERSION} = shift; } + elsif (@_ == 3) { + $self->{VERSION} = join('.', @_); + } + elsif (@_ == 0) { + if (wantarray) { + return split(/\./, $self->{VERSION}); + } + else { + return $self->{VERSION}; + } + } else { - return $self->{VERSION}; + die "Parrot::OpsFile::version(): Illegal argument count" . scalar(@_) .. "!"; } } @@ -350,7 +369,7 @@ { my $self = shift; - $self->{VERSION} =~ m/^(\d+)\.\d+$/; + $self->{VERSION} =~ m/^(\d+)\.\d+\.\d+$/; return $1; } @@ -364,10 +383,25 @@ { my $self = shift; - $self->{VERSION} =~ m/^\d+\.(\d+)$/; + $self->{VERSION} =~ m/^\d+\.(\d+)\.\d+$/; return $1; } + + +# +# patch_version() +# + +sub patch_version +{ + my $self = shift; + + $self->{VERSION} =~ m/^\d+\.\d+\.(\d+)$/; + + return $1; +} + # Index: include/parrot/oplib.h =================================================================== RCS file: /home/perlcvs/parrot/include/parrot/oplib.h,v retrieving revision 1.1 diff -a -u -r1.1 oplib.h --- include/parrot/oplib.h 27 Dec 2001 17:08:48 -0000 1.1 +++ include/parrot/oplib.h 30 Dec 2001 14:37:28 -0000 @@ -25,6 +25,7 @@ char * name; INTVAL major_version; INTVAL minor_version; + INTVAL patch_version; INTVAL op_count; op_info_t * op_info_table; void * op_func_table;
Build enhancements. Originally to support building shared libraries, but now of broader impact. * .cvsignore: Ignore the blib/ directory, about which more later. * Configure.pl: * Got rid of TAB formatting and lined a few things up. * Added header comment with CVS Id variable, and a few other block header comments. * Uses new Parrot::BuildUtil module to determine the Parrot version. * Reworded a few messages, added a couple, and wrapped messages to 79 columns. * Added 2002 to the Copyright statement. * Added new configure variables: VERSION, MAJOR, MINOR and PATCH NOTE: Please see the 'Alas perl5.7.2' comment. 5.7.2 is greater than 5.6.0, but the comment implies it isn't. * Makefile.in: * Added $(SO), $(A) and $(AR_CRS) defines for library building. * Added $(RM_RF) define for removing directory trees * Grouped generated files into two classes: "sticky" (made by configure, persisting across 'make clean') and 'fluid' (made during the build process, deleted by 'make clean'). * Added header comments. * Added target for test_prog linked with shared library. * Added rules to build shared libraries in blib/lib. The libraries are built with trailing version numbers in their file names, and then symbolic links are created for shorter and no version tag variants. * Added some missing dependencies * Added some missing 'make clean' targets. * Added 'make realclean' target that deletes files created by Configure.pl (including Makefile), forcing a re-configure. * Added a 'status' CVS target. * VERSION: New file, contains only the version. This version number is propagated to a few places, such as the core oplib version number. This reduces the amount of coordination that has to happen to get version number stuff throughout the tree in sync and updated prior to cutting a new release. Feel free to grep for '0.0.3' to see the other files that contain the version number (but, do that in a fresh CVS copy, or after doing 'make realclean'). * config_h.in: Renamed PARROT_CORE_OPLIB_*_VERSION to PARROT_*_VERSION, since the oplib and Parrot itself share a version number now. Added PARROT_PATCH_VERSION (the third component) and PARROT_VERSION (a string). * core.ops: Uses new notation "VERSION = PARROT_VERSION" instead of specifying the version by hand. Non-core oplibs will set this to a quoted dot-string with three natural number components without leading zeros. * interpreter.c: Make use of PARROT_VERSION to simplify some sprintf()s, and to get the complete version number in the resulting strings (including the new PATCH portion). * make_vtable_ops.pl: Put the "VERSION = PARROT_VERSION" line int the generated file. * obscure.ops: Use the new "VERSION = PARROT_VERSION" technique. * ops2c.pl: Account for the PATCH version, too. This affects the name of the oplib init function, and the oplib info struct initializer. * Parrot/BuildUtil.pm: New file for reading in and validating the contents of the new VERSION file. Other build utilities could go here in futuer. * Parrot/OpsFile.pm: * Allow three components in version number, and require that the value be in double quotes. * Allow "VERSION = PARROT_VERSION", substituting the shared Parrot VERSION in that case. * include/parrot/oplib.h: Add the patch_version member.