applied VMS patch from Dan Sugalski
authorDan Sugalski <dan@sidhe.org>
Fri, 19 Jun 1998 15:36:34 +0000 (08:36 -0700)
committerGurusamy Sarathy <gsar@cpan.org>
Sun, 21 Jun 1998 06:55:18 +0000 (06:55 +0000)
Message-Id: <980619153634.2063ee12@cedar.osshe.edu>
Subject: [PATCH 5.004_67] Enhancements to the VMS configuration procedures

p4raw-id: //depot/perl@1174

configure.com
lib/ExtUtils/MM_VMS.pm
perl.h
vms/descrip_mms.template
vms/gen_shrfls.pl
vms/subconfigure.com

index 57fb5c5..7eef1ca 100644 (file)
@@ -20,24 +20,22 @@ $! $ SET DEFAULT [USER.PERL5_00n]
 $! $ @[.vms]Configure "-des"
 $!
 $! That's it. If you get into a bind trying to build perl on VMS then 
-$! definitely read through the README.VMS file as well as the top of the 
-$! [.VMS]DESCRIP.MMS file.  
+$! definitely read through the README.VMS file.
 $! Beyond that send email to VMSPerl@cor.newman.upenn.edu 
 $!
 $! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 $!
-$! This CONFIGURE.COM prototype is available from:
-$! http://w4.lns.cornell.edu/~pvhp/perl/vms/devel/configure.com
 $! send suggestions to: 
-$!  Peter Prymmer pvhp@lns62.lns.cornell.edu or pvhp@forte.com
+$!  Dan Sugalski <sugalskd@ous.edu>
 $! Thank you!!!!
 $!
 $! Adapted and converted from Larry Wall & Andy Dougherty's
-$! "Configure generated by metaconfig 3.0 PL60."
+$! "Configure generated by metaconfig 3.0 PL60." by Peter Prymmer
 $! (a Bourne sh[ell] script for configuring the installation of perl on VMS)
 $! in the perl5.002|3 epoch (spring/summer 1996)
 $! with much valuable help from Charles Bailey & 
 $! the whole VMSPerl crew.
+$! Extended and messed about with by Dan Sugalski
 $!
 $! SET NOVERIFY
 $ sav_ver = F$VERIFY(sav_ver)
@@ -48,7 +46,13 @@ $ cat  = "type"
 $ gcc_symbol = "gcc"
 $ ans = ""
 $ macros = ""
+$ use_debugging_perl = "Y"
 $ C_Compiler_Replace = "CC="
+$ Thread_Live_Dangerously = "MT="
+$ use_two_pot_malloc = "N"
+$ use_pack_malloc = "N"
+$ use_debugmalloc = "N"
+$ preload_env = "N"
 $ vms_default_directory_name = F$ENVIRONMENT("DEFAULT")
 $! max_allowed_dir_depth = 3  ! e.g. [A.B.PERL5_00n] not [A.B.C.PERL5_00n]
 $ max_allowed_dir_depth = 2  ! e.g. [FOO.PERL5_00n] not [FOO.BAR.PERL5_00n]
@@ -495,7 +499,7 @@ THIS PACKAGE SEEMS TO BE INCOMPLETE.
 You have the option of continuing the configuration process, despite the
 distinct possibility that your kit is damaged, by typing 'y'es.  If you
 do, don't blame me if something goes wrong.  I advise you to type 'n'o
-and contact the author (pvhp@lns62.lns.cornell.edu).
+and contact the author (sugalskd@ous.edu).
 
 $     READ SYS$COMMAND/PROMPT="Continue? [n] " ans
 $     IF ans
@@ -1245,11 +1249,13 @@ $   IF F$LOCATE("dec",ans).NE.F$LENGTH(ans)
 $   THEN
 $     Mcc = "cc/decc"
 $     Using_Dec_C = "Yes"
+$     C_COMPILER_Replace = "CC=cc=''Mcc'"
 $   ENDIF
 $   IF F$LOCATE("vax",ans).NE.F$LENGTH(ans)
 $   THEN
 $     Mcc = "cc/vaxc"
 $     Using_Vax_C = "Yes"
+$     C_COMPILER_Replace = "CC=cc=''Mcc'"
 $   ENDIF
 $   IF Mcc.NES.dflt
 $   THEN
@@ -1267,6 +1273,7 @@ $   ELSE
 $     IF Mcc .EQS. "cc/decc"
 $     THEN
 $       Using_Dec_C = "Yes"
+$       C_COMPILER_Replace = "CC=cc=''Mcc'"
 $     ENDIF
 $   ENDIF
 $ ELSE 
@@ -1274,14 +1281,17 @@ $   Mcc = dflt
 $   IF Mcc .EQS. "cc/decc"
 $   THEN
 $     Using_Dec_C = "Yes"
+$     C_COMPILER_Replace = "CC=cc=''Mcc'"
 $   ENDIF
 $   IF Mcc .EQS. "cc/vaxc"
 $   THEN
 $     Using_Vax_C = "Yes"
+$     C_COMPILER_Replace = "CC=cc=''Mcc'"
 $   ENDIF
 $   IF Mcc .EQS. "gcc"
 $   THEN
 $     Using_Gnu_C = "Yes"
+$     C_COMPILER_Replace = "CC=cc=''Mcc'"
 $   ENDIF
 $ ENDIF
 $Decc_Version_check:
@@ -1670,28 +1680,103 @@ $   echo "This version of Perl can be built with threads. While really nifty,
 $   echo "they are a beta feature, and there is a speed penalty for perl
 $   echo "programs if you build with threads *even if you don't use them*
 $   echo ""
-$   dflt = "y"
+$   dflt = "n"
 $   rp = "Build with threads? [''dflt'] "
 $   GOSUB myread
 $   if ans.eqs."" then ans = dflt
 $   if (f$extract(0, 1, "''ans'").eqs."Y").or.(f$extract(0, 1, "''ans'").eqs."y")
 $   THEN
 $     use_threads="T"
+$     ! Are they on VMS 7.1 on an alpha?
+$     if (Archname.eqs."VMS_AXP").and.("''f$extract(1,3, f$getsyi(""version""))'".ges."7.1")
+$     THEN
+$       echo ""
+$       echo "Threaded perl can be linked to use multiple kernel threads
+$       echo "and system upcalls on VMS 7.1+ on Alpha systems. This feature
+$       echo "allows multiple threads to execute simultaneously on an SMP
+$       echo "system as well as preventing a single thread from blocking
+$       echo "all the threads in a program, even on a single-processor
+$       echo "machine. Unfortunately this feature isn't safe on an
+$       echo "unpatched 7.1 system. (Several OS patches were required when
+$       echo "this procedure was written)
+$       echo ""
+$       dflt = "N"
+$       rp = "Enable multiple kernel threads and upcalls? [''dflt'] "
+$       gosub myread
+$       if ans.eqs."" then ans="''dflt'"
+$       if f$extract(0, 1, f$edit(ans,"TRIM,COMPRESS,UPCASE")).eqs."Y"
+$       THEN
+$         Thread_Live_Dangerously = "MT=MT=1"
+$       ENDIF
+$     ENDIF
 $   ENDIF
 $ ENDIF
 $!
+$! Pre-load %ENV?
+$ echo ""
+$ echo "Because of the way perl fetches the list of logical names
+$ echo "for the %ENV hash (we spawn a subprocess that does a
+$ echo "SHOW LOGICALS *, which is expensive), we defer fetching it
+$ echo "until the first time a program iterates over the %ENV hash.
+$ echo "This means things like 'exists($ENV{'SYS$MANAGER'})' will
+$ echo "return false unless you've already accessed $ENV{SYS$MANAGER}
+$ echo "or done something like a keys %ENV."
+$ echo ""
+$ echo "If you choose, perl can populate the %ENV hash at startup.
+$ echo "This will exact both a memory penalty (to store the keys) and
+$ echo "a time penalty (to spawn the subprocess) every time you invoke
+$ echo "perl. Depending on your system, this might not be a big deal.
+$ echo ""
+$ dflt = "N"
+$ rp = "Populate %ENV at startup time? [''dflt'] "
+$ GOSUB myread
+$ if ans.eqs."" then ans="''dflt'"
+$ preload_env = f$extract(0, 1, f$edit(ans,"TRIM,COMPRESS,UPCASE"))
+$!
 $! Ask if they want to use perl's memory allocator
 $ echo ""
 $ echo "Perl has a built-in memory allocator that's tuned for perl's
 $ echo "normal memory usage. It's oftentimes better than the standard
 $ echo "system memory allocator. It also has the advantage of providing
-$ echo "memory allocation statistics.
+$ echo "memory allocation statistics, if you choose to enable them.
 $ echo ""
 $ dflt = "N"
 $ rp = "Build with perl's memory allocator? [''dflt'] "
 $ GOSUB myread
 $ if ans.eqs."" then ans="''dflt'"
 $ mymalloc = f$extract(0, 1, f$edit(ans,"TRIM,COMPRESS,UPCASE"))
+$ if mymalloc.eqs."Y"
+$ THEN
+$   if use_debugging_perl.eqs."Y"
+$   THEN
+$     echo ""
+$     echo "Perl can keep statistics on memory usage if you choose to use
+$     echo "them. This is useful for debugging, but does have some
+$     echo "performance overhead.
+$     echo ""
+$     dflt = "N"
+$     rp = "Do you want the debugging memory allocator? [''dflt'] "
+$     gosub myread
+$     if ans.eqs."" then ans="''dflt'"
+$     use_debugmalloc = f$extract(0, 1, f$edit(ans, "TRIM,COMPRESS,UPCASE"))
+$   ENDIF
+$   ! Check which memory allocator we want
+$   echo ""
+$   echo "There are currently three different memory allocators: the
+$   echo "default (which is a pretty good general-purpose memory manager),
+$   echo "the TWO_POT allocator (which is optimized to save memory for
+$   echo "larger allocations), and PACK_MALLOC (which is optimized to save
+$   echo "memory for smaller allocations). They're all good, but if your
+$   echo "usage tends towards larger chunks use TWO_POT, otherwise use
+$   echo "PACK_MALLOC."
+$   echo ""
+$   dflt = "DEFAULT"
+$   rp = "Memory allocator (DEFAULT, TWO_POT, PACK_MALLOC) [''dflt'] "
+$   GOSUB myread
+$   if ans.eqs."" then ans = "''dflt'"
+$   if ans.eqs."TWO_POT" then use_two_pot_malloc = "Y"
+$   if ans.eqs."PACK_MALLOC" then use_pack_malloc = "Y"
+$ ENDIF
 $!
 $! Ask for their default list of extensions to build
 $ echo ""
index e3bd7df..34a0d34 100644 (file)
@@ -852,16 +852,17 @@ sub cflags {
     }
 
     $libperl or $libperl = $self->{LIBPERL_A} || "libperl.olb";
-    if ($libperl =~ s/^$Config{'dbgprefix'}//) { $libperl =~ s/perl([^Dd]*)\./perld$1./; }
-    if ($libperl =~ /libperl(\w+)\./i) {
-       my($type) = uc $1;
-       my(%map) = ( 'D'  => 'DEBUGGING', 'E' => 'EMBED', 'M' => 'MULTIPLICITY',
-                    'DE' => 'DEBUGGING,EMBED', 'DM' => 'DEBUGGING,MULTIPLICITY',
-                    'EM' => 'EMBED,MULTIPLICITY', 'DEM' => 'DEBUGGING,EMBED,MULTIPLICITY' );
-       my($add) = join(',', grep { $quals !~ /\b$_\b/ } split(/,/,$map{$type}));
-       $quals =~ s:/define=\(([^\)]+)\):/Define=($1,$add):i if $add;
-       $self->{PERLTYPE} ||= $type;
-    }
+# This whole section is commented out, since I don't think it's necessary (or applicable)
+#    if ($libperl =~ s/^$Config{'dbgprefix'}//) { $libperl =~ s/perl([^Dd]*)\./perld$1./; }
+#    if ($libperl =~ /libperl(\w+)\./i) {
+#      my($type) = uc $1;
+#      my(%map) = ( 'D'  => 'DEBUGGING', 'E' => 'EMBED', 'M' => 'MULTIPLICITY',
+#                   'DE' => 'DEBUGGING,EMBED', 'DM' => 'DEBUGGING,MULTIPLICITY',
+#                   'EM' => 'EMBED,MULTIPLICITY', 'DEM' => 'DEBUGGING,EMBED,MULTIPLICITY' );
+#      my($add) = join(',', grep { $quals !~ /\b$_\b/ } split(/,/,$map{$type}));
+#      $quals =~ s:/define=\(([^\)]+)\):/Define=($1,$add):i if $add;
+#      $self->{PERLTYPE} ||= $type;
+#    }
 
     # Likewise with $self->{INC} and /Include
     if ($self->{'INC'}) {
diff --git a/perl.h b/perl.h
index 7df5f89..f6d24d7 100644 (file)
--- a/perl.h
+++ b/perl.h
@@ -373,7 +373,7 @@ register struct op *op asm(stringify(OP_IN_REGISTER));
 #   ifdef HIDEMYMALLOC
 #      define malloc  Mymalloc
 #      define calloc  Mycalloc
-#      define realloc Myremalloc
+#      define realloc Myrealloc
 #      define free    Myfree
 Malloc_t Mymalloc _((MEM_SIZE nbytes));
 Malloc_t Mycalloc _((MEM_SIZE elements, MEM_SIZE size));
@@ -384,11 +384,21 @@ Free_t   Myfree _((Malloc_t where));
 #      define malloc  Perl_malloc
 #      define calloc  Perl_calloc
 #      define realloc Perl_realloc
+/* VMS' external symbols are case-insensitive, and there's already a */
+/* perl_free in perl.h */
+#ifdef VMS
+#      define free    Perl_myfree
+#else
 #      define free    Perl_free
+#endif
 Malloc_t Perl_malloc _((MEM_SIZE nbytes));
 Malloc_t Perl_calloc _((MEM_SIZE elements, MEM_SIZE size));
 Malloc_t Perl_realloc _((Malloc_t where, MEM_SIZE nbytes));
+#ifdef VMS
+Free_t   Perl_myfree _((Malloc_t where));
+#else
 Free_t   Perl_free _((Malloc_t where));
+#endif
 #   endif
 
 #   undef safemalloc
index e27fbeb..1cf96ba 100644 (file)
 #:
 #: Lines beginning with "#:" will be removed by mms2make.pl when converting
 #: this file to MAKE syntax.
-#:
-#:     Usage:
-#: Building with VAX C, on system without DEC C installed or with VAX C default:
-#:     $ MMS
-#: Building with VAX C, on system with DEC C installed as default C compiler:
-#:     $ MMS /MACRO=("cc=CC/VAXC")
-#: Building with DEC C, on system without VAX C installed or with DEC C default:
-#:     $ MMS /MACRO=("decc=1")
-#: Building with DEC C, on system with VAX C installed as default C compiler:
-#:     $ MMS /MACRO=("decc=1","cc=CC/DECC")
-#: Building with GNU C
-#:     $ MMS /MACRO=("gnuc=1")
-#: To each of the above, add /Macro="__AXP__=1" if building on an AXP,
-#:                           /Macro="__DEBUG__=1" to build a debug version
-#:                           (i.e. VMS debugger, not perl -D), and
-#:                           /Macro="SOCKETSHR_SOCKETS=1" to include
-#:                           SOCKETSHR socket support.
-#:                           /Macro="DECC_SOCKETS=1" to include UCX (or
-#:                           compatible) socket support
-#:                          /Macro="OLDTHREADED=1" to compile with the old
-#:                          pthreads API (VMS version 6.2 and previous)
-#:                           /Macro="THREADED=1" to compile with full POSIX
-#:                           threads. (VMS 7.0 and above)
-#:                           /Macro="FAKETHREADED=1" to compile with the
-#:                           fake threads package
 #
 #      tidy      -- purge files generated by executing this file
 #      clean     -- remove all intermediate (e.g. object files, C files generated
@@ -52,6 +27,9 @@
 ~ARCH-TYPE~ = 1
 ~THREAD~
 ~SOCKET~
+~MALLOC~
+~CC~
+~MT~
 
 #: >>>>> Architecture-specific options <<<<<
 .ifdef AXE
@@ -71,7 +49,6 @@ E = .exe
 .endif
 
 .ifdef __AXP__
-DECC = 1
 ARCH = VMS_AXP
 OBJVAL = $(O)
 .else
@@ -79,9 +56,13 @@ ARCH = VMS_VAX
 OBJVAL = $(MMS$TARGET_NAME)$(O)
 .endif
 
-# Updated by fndvers.com -- do not edit by hand
 PERL_VERSION = 5_00$PATCHLEVEL$SUBVERSION
 
+.ifdef MALLOC
+MALLOC_O = ,malloc$(O)
+MALLOC_C = ,malloc$(C)
+.endif
+
 .ifdef DECC_SOCKETS
 SOCKET=1
 .endif
@@ -127,7 +108,7 @@ PIPES_BROKEN = 1
 # (fixed in gcc 2.6.3)
 XTRACCFLAGS = /Obj=$(MMS$TARGET_NAME)$(O)/NoCase_Hack/Optimize=2
 DBGSPECFLAGS =
-XTRADEF = ,GNUC_ATTRIBUTE_CHECK
+XTRADEF = 
 XTRAOBJS =
 LIBS1 = GNU_CC:[000000]GCCLIB.OLB/Library
 LIBS2 = Sys$Share:VAXCRTL/Shareable
@@ -151,7 +132,6 @@ DBGSPECFLAGS = /Show=All
        @ If F$TrnLnm("Sys").eqs."" .and. F$TrnLnm("DECC$System_Include").eqs."" Then Define/NoLog SYS DECC$Library_Include
 .endif
 
-LIBS2 = 
 XTRACCFLAGS = /Include=[]/Standard=Relaxed_ANSI/Prefix=All/Obj=$(OBJVAL)
 XTRADEF =
 POSIX = POSIX
@@ -185,10 +165,10 @@ DBG =
 #: for information on changing socket support
 .ifdef SOCKET
 .ifdef DECC_SOCKETS
-SOCKDEF = ,VMS_DO_SOCKETS,DECCRTL_SOCKETS
+SOCKDEF = 
 SOCKLIB = 
 .else
-SOCKDEF = ,VMS_DO_SOCKETS
+SOCKDEF = 
 SOCKLIB = SocketShr/Share
 .endif
 # N.B. the targets for $(SOCKC) and $(SOCKH) assume that the permanent
@@ -211,24 +191,26 @@ SOCKOBJ =
 SOCKPM =
 .endif
 
-THREAD = 
-
 .ifdef THREADED
 THREADDEF = 
 THREAD = THREAD
 .endif
 
 .ifdef OLDTHREADED
-THREADDEF = ,OLD_PTHREADS_API
+THREADDEF = 
 THREAD = THREAD
+.ifdef LIBS2
+LIBS2 = $(LIBS2),sys$share:cma$lib_shr/share,cma$rtl/share
+.else
 LIBS2 = sys$share:cma$lib_shr/share,cma$rtl/share
+.endif
 .ifdef __AXP__
 LIBS2 = $(LIBS2),sys$share:cma$open_lib_shr/share,cma$open_rtl/share
 .endif
 .endif
 
 .ifdef FAKETHREADED
-THREADDEF = ,FAKE_THREADS
+THREADDEF = 
 THREADH = fakethr.h
 acth = $(ARCHCORE)fakethr.h
 THREAD = THREAD
@@ -238,7 +220,7 @@ acth =
 .endif
 
 # C preprocessor manifest "DEBUGGING" ==> perl -D, not the VMS debugger
-CFLAGS = /Define=(DEBUGGING$(SOCKDEF)$(XTRADEF)$(THREADDEF))$(XTRACCFLAGS)$(DBGCCFLAGS)
+CFLAGS = $(XTRACCFLAGS)$(DBGCCFLAGS)
 LINKFLAGS = $(DBGLINKFLAGS)
 
 MAKE = $(MMS)
@@ -273,6 +255,10 @@ EXT = $(MYEXT)
 extobj = $(myextobj)
 .endif
 
+.ifdef LIBS2
+.else
+LIBS2=
+.endif
 
 #### End of system configuration section. ####
 
@@ -285,12 +271,12 @@ h5 = embedvar.h, intrpvar.h, perlvars.h, thrdvar.h, atomic.h
 h = $(h1), $(h2), $(h3), $(h4), $(h5) $(SOCKHLIS) $(THREADH)
 
 c1 = av.c, scope.c, op.c, doop.c, doio.c, dump.c, hv.c, mg.c, universal.c, perlio.c
-c2 = perl.c, perly.c, pp.c, pp_hot.c, pp_ctl.c, pp_sys.c, regcomp.c, regexec.c
+c2 = perl.c, perly.c, pp.c, pp_hot.c, pp_ctl.c, pp_sys.c, regcomp.c, regexec.c $(MALLOC_C)
 c3 = gv.c, sv.c, taint.c, toke.c, util.c, deb.c, run.c, globals.c, vms.c, byterun.c $(SOCKCLIS)
 
 c = $(c1), $(c2), $(c3), miniperlmain.c, perlmain.c, byteperl.c
 
-obj1 = perl$(O), gv$(O), toke$(O), perly$(O), op$(O), regcomp$(O), dump$(O), util$(O), mg$(O), perlio$(O)
+obj1 = perl$(O), gv$(O), toke$(O), perly$(O), op$(O), regcomp$(O), dump$(O), util$(O), mg$(O), perlio$(O) $(MALLOC_O)
 obj2 = hv$(O), av$(O), run$(O), pp_hot$(O), sv$(O), pp$(O), scope$(O), pp_ctl$(O), pp_sys$(O)
 obj3 = doop$(O), doio$(O), regexec$(O), taint$(O), deb$(O), universal$(O), globals$(O), vms$(O), byterun$(O) $(SOCKOBJ)
 
@@ -408,7 +394,11 @@ perl : $(DBG)perl$(E) $(DBG)byteperl$(E)
 
 $(DBG)perl$(E) : perlmain$(O), $(DBG)perlshr$(E), $(MINIPERL_EXE)
        @ @[.vms]genopt "PerlShr.Opt/Write" "|" "''F$Environment("Default")'$(DBG)PerlShr$(E)/Share"
+.ifdef MT
+       Link $(LINKFLAGS)/Exe=$(MMS$TARGET) perlmain$(O), perlshr.opt/Option, perlshr_attr.opt/Option $(CRTLOPTS)/THREAD=(MULTI,UPCALL)
+.else
        Link $(LINKFLAGS)/Exe=$(MMS$TARGET) perlmain$(O), perlshr.opt/Option, perlshr_attr.opt/Option $(CRTLOPTS)
+.endif
 
 $(DBG)byteperl$(E) : byteperl$(O), $(DBG)perlshr$(E), $(MINIPERL_EXE)
        @ @[.vms]genopt "PerlShr.Opt/Write" "|" "''F$Environment("Default")'$(DBG)PerlShr$(E)/Share"
@@ -450,7 +440,7 @@ $(ARCHDIR)config.pm : [.lib]config.pm
 [.lib]config.pm : config.h $(MINIPERL_EXE)
        $(MINIPERL) ConfigPM.
 
-[.ext.dynaloader]dl_vms.c : $(ARCHDIR)Config.pm [.ext.dynaloader]dl_vms.xs [.lib.ExtUtils]XSSymSet.pm $(MINIPERL_EXE)
+[.ext.dynaloader]dl_vms.c : [.ext.dynaloader]dl_vms.xs $(ARCHDIR)Config.pm [.lib.ExtUtils]XSSymSet.pm $(MINIPERL_EXE)
        $(XSUBPP) $(MMS$SOURCE) >$(MMS$TARGET)
 
 [.ext.dynaloader]dl_vms$(O) : [.ext.dynaloader]dl_vms.c
@@ -461,7 +451,7 @@ $(ARCHDIR)config.pm : [.lib]config.pm
        @ If F$Search("[.lib]auto.dir").eqs."" Then Create/Directory [.lib.auto]
        @ $(MINIPERL) -e "use AutoSplit; autosplit_lib_modules(@ARGV)" [.lib]DynaLoader.pm
 
-[.ext.dynaloader]dynaloader.pm : [.ext.dynaloader]dynaloader.pm_pl
+[.ext.dynaloader]dynaloader.pm : [.ext.dynaloader]dynaloader_pm.pl
        $(MINIPERL) $(MMS$SOURCE)
        @ Rename/Log dynaloader.pm [.ext.dynaloader]
 
index 9d5748d..f07b885 100644 (file)
@@ -64,11 +64,24 @@ $docc = ($cc_cmd !~ /^~~/);
 print "\$docc = $docc\n" if $debug;
 
 if ($docc) {
+  if (-f 'perl.h') { $dir = '[]'; }
+  elsif (-f '[-]perl.h') { $dir = '[-]'; }
+  else { die "$0: Can't find perl.h\n"; }
+
+  # Go see if debugging is enabled in config.h
+  $config = $dir . "config.h";
+  open CONFIG, "< $config";
+  while(<CONFIG>) {
+    $debugging_enabled++ if /define\s+DEBUGGING/;
+    $hide_mymalloc++ if /define\s+EMBEDMYMALLOC/;
+    $use_mymalloc++ if /define\s+MYMALLOC/;
+  }
+  
   # put quotes back onto defines - they were removed by DCL on the way in
   if (($prefix,$defines,$suffix) =
          ($cc_cmd =~ m#(.*)/Define=(.*?)([/\s].*)#i)) {
     $defines =~ s/^\((.*)\)$/$1/;
-    $debugging_enabled = $defines =~ /\bDEBUGGING\b/;
+    $debugging_enabled ||= $defines =~ /\bDEBUGGING\b/;
     @defines = split(/,/,$defines);
     $cc_cmd = "$prefix/Define=(" . join(',',grep($_ = "\"$_\"",@defines)) 
               . ')' . $suffix;
@@ -88,9 +101,6 @@ if ($docc) {
   print "\$isvaxc: $isvaxc\n" if $debug;
   print "\$debugging_enabled: $debugging_enabled\n" if $debug;
 
-  if (-f 'perl.h') { $dir = '[]'; }
-  elsif (-f '[-]perl.h') { $dir = '[-]'; }
-  else { die "$0: Can't find perl.h\n"; }
 }
 else { 
   ($junk,$junk,$cpp_file,$cc_cmd) = split(/~~/,$cc_cmd,4);
@@ -188,6 +198,14 @@ sub scan_func {
   }
 }
 
+# Go add some right up front if we need 'em
+if ($use_mymalloc) {
+  $fcns{'Perl_malloc'}++;
+  $fcns{'Perl_calloc'}++;
+  $fcns{'Perl_realloc'}++;
+  $fcns{'Perl_myfree'}++;
+}
+
 $used_expectation_enum = $used_opcode_enum = 0; # avoid warnings
 if ($docc) {
   open(CPP,"${cc_cmd}/NoObj/PreProc=Sys\$Output ${dir}perl.h|")
index 50d178f..8222860 100644 (file)
@@ -16,6 +16,14 @@ $ Dec_C_Version := "''Dec_C_Version'"
 $ Dec_C_Version = Dec_C_Version + 0
 $ Vms_Ver := "''f$extract(1,3, f$getsyi(""version""))'"
 $ perl_extensions := "''extensions'"
+$ if f$length(Mcc) .eq. 0 then Mcc := "cc"
+$ MCC = f$edit(mcc, "UPCASE")
+$ IF Mcc.eqs."CC
+$ THEN
+$   C_Compiler_Replace := "CC="
+$ ELSE
+$   C_Compiler_Replace := "CC=CC=''Mcc'"
+$ ENDIF
 $ if "''Using_Dec_C'" .eqs. "Yes"
 $ THEN
 $   Checkcc := "''Mcc'/prefix=all"
@@ -23,7 +31,6 @@ $ ELSE
 $   Checkcc := "''Mcc'"
 $ ENDIF
 $ cc_flags = ""
-$ if f$length(Mcc) .eq. 0 then Mcc := "cc"
 $! Some constant defaults.
 $
 $ hwname = f$getsyi("HW_NAME")
@@ -31,13 +38,7 @@ $ myname = myhostname
 $ if "''myname'" .eqs. "" THEN myname = f$trnlnm("SYS$NODE")
 $ perl_package="''package'"
 $ perl_baserev = "''baserev'"
-$ cc_defines="DEBUGGING"
-$ IF ("''Has_Socketshr'".eqs."T") .or. ("''Has_Dec_C_Sockets'".eqs."T") THEN cc_defines = cc_defines + ",VMS_DO_SOCKETS"
-$ if ("''Has_Dec_C_Sockets'".eqs."T") then cc_defines = cc_defines + ",DECCRTL_SOCKETS"
-$! if ("''Use_Threads'".eqs."T")
-$! then 
-$!   cc_defines = cc_defines + ",MULTIPLICITY"
-$! endif
+$ cc_defines=""
 $ perl_CONFIG="true"
 $ perl_i_netdb="undef"
 $ perl_d_gnulibc="undef"
@@ -409,7 +410,9 @@ $ WS "#endif
 $ WS "#include <stdio.h>
 $ WS "int main()
 $ WS "{"
-$ WS "printf(""%i\n"", sizeof(double));
+$ WS "int foo;
+$ WS "foo = sizeof(double);
+$ WS "printf(""%d\n"", foo);
 $ WS "exit(0);
 $ WS "}"
 $ CS
@@ -450,7 +453,7 @@ $ WS "#endif
 $ WS "#include <stdio.h>
 $ WS "int main()
 $ WS "{"
-$ WS "printf(""%i\n"", sizeof(long double));
+$ WS "printf(""%d\n"", sizeof(long double));
 $ WS "exit(0);
 $ WS "}"
 $ CS
@@ -508,7 +511,7 @@ $ WS "#endif
 $ WS "#include <stdio.h>
 $ WS "int main()
 $ WS "{"
-$ WS "printf(""%i\n"", sizeof(long long));
+$ WS "printf(""%d\n"", sizeof(long long));
 $ WS "exit(0);
 $ WS "}"
 $ CS
@@ -557,7 +560,7 @@ $ WS "#endif
 $ WS "#include <stdio.h>
 $ WS "int main()
 $ WS "{"
-$ WS "printf(""%i\n"", sizeof(int));
+$ WS "printf(""%d\n"", sizeof(int));
 $ WS "exit(0);
 $ WS "}"
 $ CS
@@ -603,7 +606,7 @@ $ WS "#endif
 $ WS "#include <stdio.h>
 $ WS "int main()
 $ WS "{"
-$ WS "printf(""%i\n"", sizeof(short));
+$ WS "printf(""%d\n"", sizeof(short));
 $ WS "exit(0);
 $ WS "}"
 $ CS
@@ -643,7 +646,9 @@ $ WS "#endif
 $ WS "#include <stdio.h>
 $ WS "int main()
 $ WS "{"
-$ WS "printf(""%i\n"", sizeof(long));
+$ WS "int foo;
+$ WS "foo = sizeof(long);
+$ WS "printf(""%d\n"", foo);
 $ WS "exit(0);
 $ WS "}"
 $ CS
@@ -1599,10 +1604,14 @@ $ WS "#endif
 $ WS "#include <stdio.h>
 $ WS "int main()
 $ WS "{"
-$ WS "printf(""%i\n"", sizeof(void *));
+$ WS "int foo;
+$ WS "foo = sizeof(char *);
+$ WS "printf(""%d\n"", foo);
 $ WS "exit(0);
 $ WS "}"
 $ CS
+$! copy temp.c sys$output
+$!
 $   DEFINE SYS$ERROR _NLA0:
 $   DEFINE SYS$OUTPUT _NLA0:
 $   ON ERROR THEN CONTINUE
@@ -1818,11 +1827,11 @@ $ perl_sitearchexp="''perl_prefix':[lib.site_perl.''perl_arch']"
 $ perl_sitearch="''perl_prefix':[lib.site_perl.''perl_arch']"
 $ if "''Using_Dec_C'" .eqs. "Yes"
 $ THEN
-$ perl_ccflags="/Define=(''cc_defines')/Include=[]/Standard=Relaxed_ANSI/Prefix=All/Obj=''perl_obj_ext'/NoList''cc_flags'"
+$ perl_ccflags="/Include=[]/Standard=Relaxed_ANSI/Prefix=All/Obj=''perl_obj_ext'/NoList''cc_flags'"
 $ ELSE
 $   IF "''Using_Vax_C'" .eqs. "Yes"
 $   THEN
-$     perl_ccflags="/Define=(''cc_defines')/Include=[]/Obj=''perl_obj_ext'/NoList''cc_flags'"
+$     perl_ccflags="/Include=[]/Obj=''perl_obj_ext'/NoList''cc_flags'"
 $   ENDIF
 $ ENDIF
 $!
@@ -2228,8 +2237,64 @@ $ else
 $   link munchconfig
 $ endif
 $ WRITE_RESULT "Writing config.h"
-$ define/user sys$output [-]config.h
+$ !
+$ ! we need an fdl file
+$ CREATE [-]CONFIG.FDL
+RECORD
+  FORMAT STREAM_LF
+$ CREATE /FDL=[-]CONFIG.FDL [-]CONFIG.LOCAL
+$ ! First spit out the header info with the local defines (to get
+$ ! around the 255 character command line limit)
+$ OPEN/APPEND CONFIG [-]config.local
+$ if use_debugging_perl.eqs."Y"
+$ THEN
+$   WRITE CONFIG "#define DEBUGGING"
+$ ENDIF
+$ if preload_env.eqs."Y"
+$ THEN
+$    WRITE CONFIG "#define PRIME_ENV_AT_STARTUP"
+$ ENDIF
+$ if use_two_pot_malloc.eqs."Y"
+$ THEN
+$    WRITE CONFIG "#define TWO_POT_OPTIMIZE"
+$ endif
+$ if mymalloc.eqs."Y"
+$ THEN
+$    WRITE CONFIG "#define EMBEDMYMALLOC"
+$ ENDIF
+$ if use_pack_malloc.eqs."Y"
+$ THEN
+$    WRITE CONFIG "#define PACK_MALLOC"
+$ endif
+$ if use_debugmalloc.eqs."Y"
+$ THEN
+$    write config "#define DEBUGGING_MSTATS"
+$ ENDIF
+$ if "''Using_Gnu_C'" .eqs."Yes"
+$ THEN
+$   WRITE CONFIG "#define GNUC_ATTRIBUTE_CHECK"
+$ ENDIF
+$ if "''Has_Dec_C_Sockets'".eqs."T"
+$ THEN
+$    WRITE CONFIG "#define VMS_DO_SOCKETS"
+$    WRITE CONFIG "#define DECCRTL_SOCKETS"
+$ ENDIF
+$ if "''Has_Socketshr'".eqs."T"
+$ THEN
+$    WRITE CONFIG "#define VMS_DO_SOCKETS"
+$ ENDIF
+$ CLOSE CONFIG
+$!
+$! Now build the normal config.h
+$ define/user sys$output [-]config.main
 $ mcr []munchconfig [-]config.sh [-]config_h.sh
+$ ! Concatenate them together
+$ copy [-]config.local,[-]config.main [-]config.h
+$! Clean up
+$ DELETE/NOLOG [-]CONFIG.MAIN;*
+$ DELETE/NOLOG [-]CONFIG.LOCAL;*
+$ DELETE/NOLOG [-]CONFIG.FDL;*
+$!
 $ if "''Using_Dec_C'" .eqs."Yes"
 $ THEN
 $ DECC_REPLACE = "DECC=decc=1"
@@ -2261,6 +2326,14 @@ $     THREAD_REPLACE = "THREAD=OLDTHREADED=1"
 $   ELSE
 $     THREAD_REPLACE = "THREAD=THREADED=1"
 $   ENDIF
+$ ELSE
+$   THREAD_REPLACE = "THREAD="
+$ ENDIF
+$ if mymalloc.eqs."Y"
+$ THEN
+$   MALLOC_REPLACE = "MALLOC=MALLOC=1"
+$ ELSE
+$   MALLOC_REPLACE = "MALLOC="
 $ ENDIF
 $ if f$getsyi("HW_MODEL").ge.1024
 $ THEN
@@ -2271,7 +2344,7 @@ $ ENDIF
 $ WRITE_RESULT "Writing DESCRIP.MMS"
 $!set ver
 $ define/user sys$output [-]descrip.mms
-$ mcr []munchconfig [-]config.sh descrip_mms.template "''DECC_REPLACE'" "''ARCH_TYPE'" "''GNUC_REPLACE'" "''SOCKET_REPLACE'" "''THREAD_REPLACE'" "''C_Compiler_Replace'"
+$ mcr []munchconfig [-]config.sh descrip_mms.template "''DECC_REPLACE'" "''ARCH_TYPE'" "''GNUC_REPLACE'" "''SOCKET_REPLACE'" "''THREAD_REPLACE'" "''C_Compiler_Replace'" "''MALLOC_REPLACE'" "''Thread_Live_Dangerously'"
 $! set nover
 $!
 $! Clean up after ourselves