Brent Dax:
# Mattia Barbon:
# # > ## +#if defined(WIN32)
# # > ## +    program_code = malloc( file_stat.st_size );
# # > ## +#else
# # >
# # > #Should we be using malloc, or are we supposed to use our
# # own allocator?
# # > #(I haven't been munging in the C, so I don't really
# # know--it just looks
# # > #a little suspicious.)
# # >
# # > In memory.{h,c} there is a mem_sys_allocate(IV) that I
# # would suggest.
# # Of course you're right.
# # New patch Attached
# #
# # The attached patch replaces things.diff ( testsuite.diff should be
# # OK )
# 
# I've made some small changes, including some comments so people don't
# keep putting new C compiler flags in the wrong place.  Most 
# of the other
# changes were things like formatting.  Patch attached.  I'll 
# commit this
# myself if nobody has any objections.  (Once this is 
# committed, I'll work
# on the parrot/config.h stuff, and merge that in to this patch.)

Ack, forgot to actually *attach* the file...

--Brent Dax
[EMAIL PROTECTED]

They *will* pay for what they've done.
--- parrot-cvs\parrot\Configure.pl      Fri Sep 14 17:57:42 2001
+++ parrot\parrot\Configure.pl  Sat Sep 15 16:01:18 2001
@@ -5,7 +5,36 @@
 
 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 {
        require Data::Dumper;
@@ -29,21 +58,48 @@
 #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./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 +151,8 @@
 
 #prompt for something from the user
 sub prompt {
+       return if $opt_defaults;
+
        my($message, $field)=(@_);
        my($input);
        print "$message [$c{$field}] ";
--- parrot-cvs\parrot\Makefile.in       Fri Sep 14 17:57:42 2001
+++ parrot\parrot\Makefile.in   Sat Sep 15 16:01:24 2001
@@ -1,21 +1,27 @@
-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}
 
-all : $(O_FILES)
+TEST_PROG=test_prog${exe}
 
-test_prog: test_main$(O) $(O_FILES)
-       $(CC) $(C_LIBS) -o test_prog $(O_FILES) test_main$(O)
+all : $(TEST_PROG)
 
+$(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)
 
 global_setup$(O): $(H_FILES)
@@ -49,4 +55,5 @@
        ${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)
+       -rm -f *.opt *.ilk *.pdb
--- parrot-cvs\parrot\parrot.h  Fri Sep 14 07:08:00 2001
+++ parrot\parrot\parrot.h      Sat Sep 15 15:49:56 2001
@@ -19,8 +19,12 @@
 #include <stdio.h>
 /*#include <types.h> */
 #include <time.h>
-#include <unistd.h>
-#include <sys/mman.h>
+#if defined(WIN32)
+#  include <io.h>
+#else
+#  include <unistd.h>
+#  include <sys/mman.h>
+#endif
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
--- parrot-cvs\parrot\test_main.c       Fri Sep 14 07:08:00 2001
+++ parrot\parrot\test_main.c   Sat Sep 15 15:49:56 2001
@@ -66,12 +66,19 @@
       return 1;
     }
 
+#if defined(WIN32)
+    program_code = malloc( 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;
     }
 
+#if defined(WIN32)
+    _read( fd, program_code, file_stat.st_size );
+#endif
     program_code = init_bytecode(program_code);
 
     runops(interpreter, program_code);
--- parrot.cvs/hints/mswin32.pl Thu Jan  1 01:00:00 1970
+++ parrot/hints/mswin32.pl     Fri Sep 14 17:33:48 2001
@@ -0,0 +1,18 @@
+{
+       my $is_msvc = grep { $c{cc} eq $_ } ( qw(cl cl.exe) );
+       my $is_mingw = grep { $c{cc} eq $_ } ( qw(gcc gcc.exe) );
+
+       if( $is_msvc ) {
+               $c{o} = '.obj';
+               $c{ld_out} = '-out:';
+               $c{cc_debug} = '-Zi';
+               $c{ld_debug} = '-debug';
+       }
+       elsif( $is_mingw ) {
+               $c{ld} = 'gcc';
+               # if your perl is ActivePerl, then libs are .lib files,
+               # not necessary, and gcc does not like them
+               $c{libs} = ' ' if $c{libs} =~ m/\.lib\s/i;
+       }
+}
+
--- parrot.cvs/test_main.c      Fri Sep 14 18:00:36 2001
+++ parrot/test_main.c  Fri Sep 14 17:49:42 2001
@@ -67,5 +67,9 @@
     }
 
+#if defined(WIN32)
+    program_code = mem_sys_allocate( 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);
@@ -73,4 +77,7 @@
     }
 
+#if defined(WIN32)
+    _read( fd, program_code, file_stat.st_size );
+#endif
     program_code = init_bytecode(program_code);

Reply via email to