Browse files

Win32 compatibility, Configure hints, 5.005 compatibility, MANIFEST c…

…hecking

git-svn-id: https://svn.parrot.org/parrot/trunk@116 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information...
1 parent 839ccb2 commit 205f6530746c1c74ddd079e84ac8b0afc9150c65 @brentdax brentdax committed Sep 16, 2001
Showing with 164 additions and 35 deletions.
  1. +102 −9 Configure.pl
  2. +35 −19 Makefile.in
  3. +2 −3 lib/Parrot/Opcode.pm
  4. +13 −2 parrot.h
  5. +6 −1 src/test_main.c
  6. +6 −1 test_main.c
View
111 Configure.pl
@@ -5,6 +5,35 @@
use strict;
use Config;
+use Getopt::Long;
+
+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,
+);
+
+if( $opt_version ) {
+ print '$Id$' . "\n";
+ exit;
+}
+
+if( $opt_help ) {
+ 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
+EOT
+ exit;
+}
my($DDOK)=undef;
eval {
@@ -21,29 +50,58 @@
Since you're running this script, you obviously have
Perl 5--I'll be pulling some defaults from its configuration.
-Rules are the same as Perl 5's Configure--defaults are in
-square brackets, and you can hit enter to accept them.
+First, I'm gonna check the manifest, to make sure you got 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
my(%c)=(
- iv => ($Config{ivtype}||'long'),
- nv => ($Config{nvtype}||'long double'),
- cc => $Config{cc},
- ccflags => $Config{ccflags},
- libs => $Config{libs},
- perl => $^X,
+ iv => ($Config{ivtype}||'long'),
+ nv => ($Config{nvtype}||'double'),
+ cc => $Config{cc},
+ #ADD C COMPILER FLAGS HERE
+ ccflags => $Config{ccflags}." -I.. -I./include",
+ libs => $Config{libs},
+ perl => $^X,
+ 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
+ debugging => $opt_debugging,
);
+foreach my $i ( keys %opt_defines ) {
+ $c{$i} = $opt_defines{$i};
+}
+
+# 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: '$@/$!'";
+}
+
#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');
prompt("Which libraries would you like your C compiler to include?", 'libs');
prompt("How big would you like integers to be?", 'iv');
-prompt("How about your floats?", 'nv');
+prompt("And your floats?", 'nv');
+unless( $c{debugging} ) {
+ $c{ld_debug} = ' ';
+ $c{cc_denug} = ' ';
+}
print <<"END";
@@ -95,6 +153,8 @@ sub defineifdef {
#prompt for something from the user
sub prompt {
+ return if $opt_defaults;
+
my($message, $field)=(@_);
my($input);
print "$message [$c{$field}] ";
@@ -147,3 +207,36 @@ END
print OUT $text;
close(OUT) or die "Can't close file Parrot/Config.pm: $!";
}
+
+sub check_manifest {
+ my $not_ok;
+ open(MANIFEST, "MANIFEST");
+
+ while(<MANIFEST>) {
+ chomp;
+ unless(-e $_) {
+ print "File $_ is missing!\n";
+ $not_ok=1;
+ }
+ }
+
+ if($not_ok) {
+ print <<"END";
+
+Ack, some files were missing! I can't continue running
+without everything here. Please try to find the above
+files and then try running Configure again.
+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
+ }
+}
View
54 Makefile.in
@@ -1,59 +1,75 @@
-O = .o
+O = ${o}
H_FILES = config.h exceptions.h io.h op.h register.h string.h events.h interpreter.h memory.h parrot.h stacks.h bytecode.h global_setup.h
O_FILES = global_setup$(O) interpreter$(O) parrot$(O) register$(O) basic_opcodes$(O) memory$(O) bytecode$(O) string$(O) strnative$(O)
-C_FLAGS = ${ccflags} -I..
+#DO NOT ADD C COMPILER FLAGS HERE
+#Add them in Configure.pl--look for the
+#comment 'ADD C COMPILER FLAGS HERE'
+C_FLAGS = ${ccflags} ${cc_debug}
C_LIBS = ${libs}
CC = ${cc} $(C_FLAGS)
+LD = ${ld}
+PERL = ${perl}
+TEST_PROG = test_prog${exe}
-all : $(O_FILES)
+all : $(TEST_PROG)
+#XXX This target is not portable to Win32
shared: libparrot.so
libparrot.so: $(O_FILES)
$(CC) -shared $(C_LIBS) -o $@ $(O_FILES)
-test_prog: test_main$(O) $(O_FILES)
- $(CC) $(C_LIBS) -o test_prog $(O_FILES) test_main$(O)
+$(TEST_PROG): test_main$(O) $(O_FILES)
+ $(LD) $(C_LIBS) ${ld_debug} ${ld_out}$(TEST_PROG) $(O_FILES) test_main$(O)
test_main$(O): $(H_FILES)
+ $(CC) -o $*$(O) -c $*.c
global_setup$(O): $(H_FILES)
+ $(CC) -o $*$(O) -c $*.c
string$(O): $(H_FILES)
-
+ $(CC) -o $*$(O) -c $*.c
+
strnative$(O): $(H_FILES)
-
+ $(CC) -o $*$(O) -c $*.c
+
interp_guts.h: opcode_table build_interp_starter.pl
- ${perl} build_interp_starter.pl
+ $(PERL) build_interp_starter.pl
interpreter$(O): interpreter.c $(H_FILES) interp_guts.h
memory$(O): $(H_FILES)
+ $(CC) -o $*$(O) -c $*.c
bytecode$(O): $(H_FILES)
-
+ $(CC) -o $*$(O) -c $*.c
+
parrot$(O): $(H_FILES)
-
+ $(CC) -o $*$(O) -c $*.c
+
register$(O): $(H_FILES)
-
+ $(CC) -o $*$(O) -c $*.c
+
basic_opcodes$(O): $(H_FILES) basic_opcodes.c
-
+ $(CC) -o $*$(O) -c $*.c
+
basic_opcodes.c: basic_opcodes.ops process_opfunc.pl interp_guts.h
- ${perl} process_opfunc.pl basic_opcodes.ops
+ $(PERL) process_opfunc.pl basic_opcodes.ops
op.h: opcode_table make_op_header.pl
- ${perl} make_op_header.pl opcode_table > op.h
+ $(PERL) make_op_header.pl opcode_table > op.h
config.h: Configure.pl config_h.in
- ${perl} Configure.pl
-
-test: test_prog
- perl t/harness
+ $(PERL) Configure.pl
clean:
- rm -f *$(O) *.s basic_opcodes.c interp_guts.h op.h test_prog
+ rm -f *$(O) *.s basic_opcodes.c interp_guts.h op.h $(TEST_PROG)
+
+test:
+ $(PERL) t/harness
View
5 lib/Parrot/Opcode.pm
@@ -1,12 +1,11 @@
package Parrot::Opcode;
-use 5.6.0;
use strict;
use Symbol;
use Digest::MD5 qw(&md5_hex);
-our %opcode;
-our $fingerprint;
+my %opcode;
+my $fingerprint;
sub _load {
my $file = @_ ? shift : "opcode_table";
View
15 parrot.h
@@ -25,8 +25,19 @@
#include <stdio.h>
/*#include <types.h> */
#include <time.h>
-#include <unistd.h>
-#include <sys/mman.h>
+
+#ifdef WIN32
+# include <io.h>
+#endif
+
+#ifdef HAS_HEADER_UNISTD
+# include <unistd.h>
+#endif
+
+#ifdef HAS_HEADER_SYSMMAN
+# include <sys/mman.h>
+#endif
+
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
View
7 src/test_main.c
@@ -72,7 +72,12 @@ main(int argc, char **argv) {
return 1;
}
- program_code = mmap(0, file_stat.st_size, PROT_READ, MAP_SHARED, fd, 0);
+#ifndef HAS_HEADER_SYSMMAN
+ program_code = mem_sys_allocate(file_stat.st_size);
+ _read(fd, program_code, file_stat.st_size);
+#else
+ program_code = mmap(0, file_stat.st_size, PROT_READ, MAP_SHARED, fd, 0);
+#endif
if (!program_code) {
printf("Can't mmap, code %i\n", errno);
return 1;
View
7 test_main.c
@@ -72,7 +72,12 @@ main(int argc, char **argv) {
return 1;
}
- program_code = mmap(0, file_stat.st_size, PROT_READ, MAP_SHARED, fd, 0);
+#ifndef HAS_HEADER_SYSMMAN
+ program_code = mem_sys_allocate(file_stat.st_size);
+ _read(fd, program_code, file_stat.st_size);
+#else
+ program_code = mmap(0, file_stat.st_size, PROT_READ, MAP_SHARED, fd, 0);
+#endif
if (!program_code) {
printf("Can't mmap, code %i\n", errno);
return 1;

0 comments on commit 205f653

Please sign in to comment.