This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
patch up egcs-1.1.2-mingw32 build (builds a working miniperl, but not
[perl5.git] / makedef.pl
index 50cbcbb..63a09bd 100644 (file)
@@ -1,23 +1,49 @@
 #
 # Create the export list for perl.
 #
-# Needed by WIN32 for creating perl.dll and by AIX for creating libperl.a
-# when -Dusershrplib is in effect.
+# Needed by WIN32 and OS/2 for creating perl.dll
+# and by AIX for creating libperl.a when -Dusershrplib is in effect.
 #
 # reads global.sym, pp.sym, perlvars.h, intrpvar.h, thrdvar.h, config.h
+# On OS/2 reads miniperl.map as well
 
 my $PLATFORM;
 my $CCTYPE;
 
+my %bincompat5005 =
+      (Perl_call_argv          =>      "perl_call_argv",
+       Perl_call_method                =>      "perl_call_method",
+       Perl_call_pv            =>      "perl_call_pv",
+       Perl_call_sv            =>      "perl_call_sv",
+       Perl_get_av             =>      "perl_get_av",
+       Perl_get_cv             =>      "perl_get_cv",
+       Perl_get_hv             =>      "perl_get_hv",
+       Perl_get_sv             =>      "perl_get_sv",
+       Perl_init_i18nl10n      =>      "perl_init_i18nl10n",
+       Perl_init_i18nl14n      =>      "perl_init_i18nl14n",
+       Perl_new_collate                =>      "perl_new_collate",
+       Perl_new_ctype          =>      "perl_new_ctype",
+       Perl_new_numeric                =>      "perl_new_numeric",
+       Perl_require_pv         =>      "perl_require_pv",
+       Perl_safesyscalloc      =>      "Perl_safecalloc",
+       Perl_safesysfree                =>      "Perl_safefree",
+       Perl_safesysmalloc      =>      "Perl_safemalloc",
+       Perl_safesysrealloc     =>      "Perl_saferealloc",
+       Perl_set_numeric_local  =>      "perl_set_numeric_local",
+       Perl_set_numeric_standard  =>   "perl_set_numeric_standard");
+
+my $bincompat5005 = join("|", keys %bincompat5005);
+
 while (@ARGV)
  {
   my $flag = shift;
   $define{$1} = 1 if ($flag =~ /^-D(\w+)$/);
+  $define{$1} = $2 if ($flag =~ /^-D(\w+)=(.+)$/);
   $CCTYPE   = $1 if ($flag =~ /^CCTYPE=(\w+)$/);
   $PLATFORM = $1 if ($flag =~ /^PLATFORM=(\w+)$/);
  } 
 
-my @PLATFORM = qw(aix win32);
+my @PLATFORM = qw(aix win32 os2);
 my %PLATFORM;
 @PLATFORM{@PLATFORM} = ();
 
@@ -51,6 +77,10 @@ unless ($PLATFORM eq 'win32') {
            $_ = $1;
            $define{$1} = 1 while /-D(\w+)/g;
        }
+       if ($PLATFORM eq 'os2') {
+           $CONFIG_ARGS = $1 if /^(?:config_args)='(.+)'$/;
+           $ARCHNAME = $1 if /^(?:archname)='(.+)'$/;
+       }
     }
     close(CFG);
 }
@@ -62,13 +92,14 @@ while (<CFG>)
   $define{$1} = 1 if /^\s*#\s*define\s+(USE_THREADS)\b/;
   $define{$1} = 1 if /^\s*#\s*define\s+(USE_PERLIO)\b/;
   $define{$1} = 1 if /^\s*#\s*define\s+(MULTIPLICITY)\b/;
+  $define{$1} = 1 if /^\s*#\s*define\s+(PERL_BINCOMPAT_5005)\b/;
  }
 close(CFG);
 
 if ($PLATFORM eq 'win32') {
     warn join(' ',keys %define)."\n";
     if ($define{PERL_OBJECT}) {
-       print "LIBRARY PerlCore\n";
+       print "LIBRARY Perl56\n";
        print "DESCRIPTION 'Perl interpreter'\n";
        print "EXPORTS\n";
 #    output_symbol("perl_alloc");
@@ -93,6 +124,27 @@ if ($PLATFORM eq 'win32') {
        }
        print "EXPORTS\n";
     } 
+} elsif ($PLATFORM eq 'os2') {
+    ($v = $]) =~ s/(\d\.\d\d\d)(\d\d)$/$1_$2/;
+    $v .= '-thread' if $ARCHNAME =~ /-thread/;
+    #$sum = 0;
+    #for (split //, $v) {
+    #  $sum = ($sum * 33) + ord;
+    #  $sum &= 0xffffff;
+    #}
+    #$sum += $sum >> 5;
+    #$sum &= 0xffff;
+    #$sum = printf '%X', $sum;
+    ($dll = $define{PERL_DLL}) =~ s/\.dll$//i;
+    # print STDERR "'$dll' <= '$define{PERL_DLL}'\n";
+    print <<"---EOP---";
+LIBRARY '$dll' INITINSTANCE TERMINSTANCE
+DESCRIPTION '\@#perl5-porters\@perl.org:$v#\@ Perl interpreter, configured as $CONFIG_ARGS'
+STACKSIZE 32768
+CODE LOADONCALL
+DATA LOADONCALL NONSHARED MULTIPLE
+EXPORTS
+---EOP---
 } elsif ($PLATFORM eq 'aix') {
     print "#!\n";
 }
@@ -163,6 +215,11 @@ Perl_my_memset
 PL_cshlen
 PL_cshname
 PL_opsave
+
+Perl_do_exec
+Perl_getenv_len
+Perl_my_pclose
+Perl_my_popen
 )];
 } elsif ($PLATFORM eq 'aix') {
     skip_symbols([qw(
@@ -190,6 +247,49 @@ PL_sys_intern
 )]);
 }
 
+if ($PLATFORM eq 'os2') {
+    emit_symbols([qw(
+ctermid
+get_sysinfo
+Perl_OS2_init
+OS2_Perl_data
+dlopen
+dlsym
+dlerror
+my_tmpfile
+my_tmpnam
+my_flock
+malloc_mutex
+threads_mutex
+nthreads
+nthreads_cond
+os2_cond_wait
+os2_stat
+pthread_join
+pthread_create
+pthread_detach
+XS_Cwd_change_drive
+XS_Cwd_current_drive
+XS_Cwd_extLibpath
+XS_Cwd_extLibpath_set
+XS_Cwd_sys_abspath
+XS_Cwd_sys_chdir
+XS_Cwd_sys_cwd
+XS_Cwd_sys_is_absolute
+XS_Cwd_sys_is_relative
+XS_Cwd_sys_is_rooted
+XS_DynaLoader_mod2fname
+XS_File__Copy_syscopy
+Perl_Register_MQ
+Perl_Deregister_MQ
+Perl_Serve_Messages
+Perl_Process_Messages
+init_PMWIN_entries
+PMWIN_entries
+Perl_hab_GET
+)]);
+}
+
 if ($define{'PERL_OBJECT'}) {
   skip_symbols [qw(
     Perl_getenv_len
@@ -267,6 +367,7 @@ unless ($define{'USE_THREADS'} or $define{'PERL_IMPLICIT_CONTEXT'}
                   Perl_die_nocontext
                   Perl_deb_nocontext
                   Perl_form_nocontext
+                  Perl_mess_nocontext
                   Perl_warn_nocontext
                   Perl_warner_nocontext
                   Perl_newSVpvf_nocontext
@@ -314,7 +415,7 @@ if ($define{'PERL_GLOBAL_STRUCT'})
  {
   my $global = readvar($perlvars_h);
   skip_symbols $global;
-  emit_symbols [qw(Perl_GetVars)];
+  emit_symbol('Perl_GetVars');
   emit_symbols [qw(PL_Vars PL_VarsPtr)] unless $CCTYPE eq 'GCC';
  } 
 
@@ -554,6 +655,15 @@ win32_os_id
        try_symbol($symbol);
     }
 }
+elsif ($PLATFORM eq 'os2') {
+  open MAP, 'miniperl.map' or die 'Cannot read miniperl.map';
+  /^\s*[\da-f:]+\s+(\w+)/i and $mapped{$1}++ foreach <MAP>;
+  close MAP or die 'Cannot close miniperl.map';
+  
+  @missing = grep { !exists $mapped{$_} and !exists $bincompat5005{$_} }
+    keys %export;
+  delete $export{$_} foreach @missing;
+}
 
 # Now all symbols should be defined because
 # next we are going to output them.
@@ -571,9 +681,11 @@ sub emit_symbol {
 
 sub output_symbol {
     my $symbol = shift;
+    $symbol = $bincompat5005{$symbol}
+       if $define{PERL_BINCOMPAT_5005} and $symbol =~ /^($bincompat5005)$/;
     if ($PLATFORM eq 'win32') {
-       print "\t$symbol\n";
        $symbol = "_$symbol" if $CCTYPE eq 'BORLAND';
+       print "\t$symbol\n";
 # XXX: binary compatibility between compilers is an exercise
 # in frustration :-(
 #        if ($CCTYPE eq "BORLAND") {
@@ -595,6 +707,8 @@ sub output_symbol {
 #          print "\t$symbol\n";
 #          print "\t_$symbol = $symbol\n";
 #      }
+    } elsif ($PLATFORM eq 'os2') {
+       print qq(    "$symbol"\n);
     } elsif ($PLATFORM eq 'aix') {
        print "$symbol\n";
     }