DB_File OS/2 changes subsumed into new version of DB_File
[p5sagit/p5-mst-13.2.git] / vms / genconfig.pl
CommitLineData
a0d0e21e 1#!/usr/bin/perl
2# Habit . . .
3#
4# Extract info from Config.VMS, and add extra data here, to generate Config.sh
5# Edit the static information after __END__ to reflect your site and options
748a9306 6# that went into your perl binary. In addition, values which change from run
7# to run may be supplied on the command line as key=val pairs.
a0d0e21e 8#
e518068a 9# Rev. 13-Dec-1995 Charles Bailey bailey@genetics.upenn.edu
a0d0e21e 10#
11
12unshift(@INC,'lib'); # In case someone didn't define Perl_Root
13 # before the build
a0d0e21e 14
a5f75d66 15if ($ARGV[0] eq '-f') {
16 open(ARGS,$ARGV[1]) or die "Can't read data from $ARGV[1]: $!\n";
17 @ARGV = ();
18 while (<ARGS>) {
19 push(@ARGV,split(/\|/,$_));
20 }
21 close ARGS;
22}
23
a0d0e21e 24if (-f "config.vms") { $infile = "config.vms"; $outdir = "[-]"; }
25elsif (-f "[.vms]config.vms") { $infile = "[.vms]config.vms"; $outdir = "[]"; }
26elsif (-f "config.h") { $infile = "config.h"; $outdir = "[]";}
27
28if ($infile) { print "Generating Config.sh from $infile . . .\n"; }
29else { die <<EndOfGasp;
30Can't find config.vms or config.h to read!
31 Please run this script from the perl source directory or
32 the VMS subdirectory in the distribution.
33EndOfGasp
34}
35$outdir = '';
36open(IN,"$infile") || die "Can't open $infile: $!\n";
37open(OUT,">${outdir}Config.sh") || die "Can't open ${outdir}Config.sh: $!\n";
a0d0e21e 38
e518068a 39$time = localtime;
748a9306 40print OUT <<EndOfIntro;
a0d0e21e 41# This file generated by GenConfig.pl on a VMS system.
42# Input obtained from:
43# $infile
44# $0
45# Time: $time
46
e518068a 47package='perl5'
48CONFIG='true'
49cf_time='$time'
e518068a 50ld='Link'
51lddlflags='/Share'
e518068a 52ranlib=''
53ar=''
54eunicefix=':'
c07a80fd 55hint='none'
e518068a 56hintfile=''
57intsize='4'
58alignbytes='8'
59shrplib='define'
60usemymalloc='n'
c07a80fd 61spitshell='write sys\$output '
a0d0e21e 62EndOfIntro
63
e518068a 64$cf_by = (getpwuid($<))[0];
c07a80fd 65print OUT "cf_by='$cf_by'\n";
e518068a 66
67$hw_model = `Write Sys\$Output F\$GetSyi("HW_MODEL")`;
68chomp $hw_model;
69if ($hw_model > 1024) {
70 print OUT "arch='VMS_AXP'\n";
71 print OUT "archname='VMS_AXP'\n";
72 $archsufx = "AXP";
73}
74else {
75 print OUT "arch='VMS_VAX'\n";
76 print OUT "archname='VMS_VAX'\n";
77 $archsufx = 'VAX';
78}
79$osvers = `Write Sys\$Output F\$GetSyi("VERSION")`;
c07a80fd 80$osvers =~ s/^V?(\S+)\s*\n?$/$1/;
e518068a 81print OUT "osvers='$osvers'\n";
748a9306 82foreach (@ARGV) {
83 ($key,$val) = split('=',$_,2);
e518068a 84 if ($key eq 'cc') { # Figure out which C compiler we're using
c07a80fd 85 my($cc,$ccflags) = split('/',$val,2);
86 my($d_attr);
87 $ccflags = "/$ccflags";
88 if ($ccflags =~s!/DECC!!ig) {
89 $cc .= '/DECC';
90 $cctype = 'decc';
91 $d_attr = 'undef';
92 }
93 elsif ($ccflags =~s!/VAXC!!ig) {
94 $cc .= '/VAXC';
95 $cctype = 'vaxc';
96 $d_attr = 'undef';
97 }
98 elsif (`$val/NoObject/NoList _nla0:/Version` =~ /GNU/) {
99 $cctype = 'gcc';
100 $d_attr = 'define';
e518068a 101 }
102 elsif ($archsufx eq 'VAX' &&
103 `$val/NoObject/NoList /prefix=all _nla0:` =~ /IVQUAL/) {
c07a80fd 104 $cctype = 'vaxc';
105 $d_attr = 'undef';
e518068a 106 }
107 else {
c07a80fd 108 $cctype = 'decc';
109 $d_attr = 'undef';
110 }
111 print OUT "vms_cc_type='$cctype'\n";
112 print OUT "d_attribut='$d_attr'\n";
113 print OUT "cc='$cc'\n";
114 if ( ($cctype eq 'decc' and $archsufx eq 'VAX') || $cctype eq 'gcc') {
115 # gcc and DECC for VAX requires filename in /object qualifier, so we
e518068a 116 # have to remove it here. Alas, this means we lose the user's
117 # object file suffix if it's not .obj.
c07a80fd 118 $ccflags =~ s#/obj(?:ect)?=[^/\s]+##i;
e518068a 119 }
c07a80fd 120 print OUT "ccflags='$ccflags'\n";
121 $dosock = ($ccflags =~ m!/DEF[^/]+VMS_DO_SOCKETS!i and
122 $ccflags !~ m!/UND[^/]+VMS_DO_SOCKETS!i);
123 next;
e518068a 124 }
748a9306 125 print OUT "$key=\'$val\'\n";
c07a80fd 126}
127
128# Are there any other logicals which TCP/IP stacks use for the host name?
129$myname = $ENV{'ARPANET_HOST_NAME'} || $ENV{'INTERNET_HOST_NAME'} ||
130 $ENV{'MULTINET_HOST_NAME'} || $ENV{'UCX$INET_HOST'} ||
131 $ENV{'TCPWARE_DOMAINNAME'} || $ENV{'NEWS_ADDRESS'};
132if (!$myname) {
133 ($myname) = `hostname` =~ /^(\S+)/;
134 if ($myname =~ /IVVERB/) {
135 warn "Can't determine TCP/IP hostname" if $dosock;
136 $myname = '';
e518068a 137 }
748a9306 138}
c07a80fd 139$myname = $ENV{'SYS$NODE'} unless $myname;
140($myhostname,$mydomain) = split(/\./,$myname,2);
141print OUT "myhostname='$myhostname'\n" if $myhostname;
142if ($mydomain) {
143 print OUT "mydomain='.$mydomain'\n";
144 print OUT "perladmin='$cf_by\@$myhostname.$mydomain'\n";
145 print OUT "cf_email='$cf_by\@$myhostname.$mydomain'\n";
146}
147else {
148 print OUT "perladmin='$cf_by'\n";
149 print OUT "cf_email='$cf_by'\n";
150}
151chomp($hwname = `Write Sys\$Output F\$GetSyi("HW_NAME")`);
152$hwname = $archsufx if $hwname =~ /IVKEYW/; # *really* old VMS version
153print OUT "myuname='VMS $myname $osvers $hwname'\n";
748a9306 154
a0d0e21e 155while (<IN>) { # roll through the comment header in Config.VMS
e518068a 156 last if /config-start/;
a0d0e21e 157}
158
159while (<IN>) {
160 chop;
161 while (/\\\s*$/) { # pick up contination lines
162 my $line = $_;
163 $line =~ s/\\\s*$//;
164 $_ = <IN>;
165 s/^\s*//;
166 $_ = $line . $_;
167 }
c07a80fd 168 next unless my ($blocked,$un,$token,$val) = m%^(\/\*)?\s*\#\s*(un)?def\w*\s*([A-za-z0-9]\w+)\S*\s*(.*)%;
a0d0e21e 169 next if /config-skip/;
170 $state = ($blocked || $un) ? 'undef' : 'define';
171 $token =~ tr/A-Z/a-z/;
e518068a 172 $token =~ s/_exp$/exp/; # Config.pm has 'privlibexp' etc. where config.h
173 # has 'privlib_exp' etc.
c07a80fd 174 # Fixup differences between Configure vars and config.h manifests
175 # This isn't comprehensize; we fix 'em as we need 'em.
176 $token = 'castneg' if $token eq 'castnegfloat';
177 $token = 'dlsymun' if $token eq 'dlsym_needs_underscore';
178 $token = 'stdstdio' if $token eq 'use_stdio_ptr';
179 $token = 'stdiobase' if $token eq 'use_stdio_base';
a0d0e21e 180 $val =~ s%/\*.*\*/\s*%%g; $val =~ s/\s*$//; # strip off trailing comment
181 $val =~ s/^"//; $val =~ s/"$//; # remove end quotes
182 $val =~ s/","/ /g; # make signal list look nice
748a9306 183 if ($val) { print OUT "$token=\'$val\'\n"; }
a0d0e21e 184 else {
185 $token = "d_$token" unless $token =~ /^i_/;
e518068a 186 print OUT "$token='$state'\n";
748a9306 187 }
a0d0e21e 188}
189close IN;
190
191while (<DATA>) {
192 next if /^\s*#/ or /^\s*$/;
193 s/#.*$//; s/\s*$//;
194 ($key,$val) = split('=',$_,2);
748a9306 195 print OUT "$key='$val'\n";
196 eval "\$$key = '$val'";
197}
198# Add in some of the architecture-dependent stuff which has to be consistent
199print OUT "d_vms_do_sockets=",$dosock ? "'define'\n" : "'undef'\n";
200print OUT "d_has_sockets=",$dosock ? "'define'\n" : "'undef'\n";
748a9306 201$archlib = &VMS::Filespec::vmspath($privlib);
748a9306 202$installarchlib = &VMS::Filespec::vmspath($installprivlib);
482b294c 203$sitearch = &VMS::Filespec::vmspath($sitelib);
204$archlib =~ s#\]#.VMS_$archsufx\]#;
a5f75d66 205$sitearch =~ s#\]#.VMS_$archsufx\]#;
482b294c 206print OUT "oldarchlib='$archlib'\n";
207print OUT "oldarchlibexp='$archlib'\n";
208($vers = $]) =~ tr/./_/;
209$archlib =~ s#\]#.$vers\]#;
210$installarchlib =~ s#\]#.VMS_$archsufx.$vers\]#;
748a9306 211print OUT "archlib='$archlib'\n";
e518068a 212print OUT "archlibexp='$archlib'\n";
748a9306 213print OUT "installarchlib='$installarchlib'\n";
482b294c 214print OUT "sitearch='$sitearch'\n";
215print OUT "sitearchexp='$sitearch'\n";
a0d0e21e 216
e518068a 217if (open(OPT,"${outdir}crtl.opt")) {
218 while (<OPT>) {
219 next unless m#/(sha|lib)#i;
220 chomp;
c07a80fd 221 if (/crtl/i || /gcclib/i) { push(@crtls,$_); }
222 else { push(@libs,$_); }
e518068a 223 }
224 close OPT;
225 print OUT "libs='",join(' ',@libs),"'\n";
c07a80fd 226 push(@crtls,'(DECCRTL)') if $cctype eq 'decc';
227 print OUT "libc='",join(' ',@crtls),"'\n";
228}
229else { warn "Can't read ${outdir}crtl.opt - skipping 'libs' & 'libc'"; }
230
231if (open(PL,"${outdir}patchlevel.h")) {
232 while (<PL>) {
8ae5b802 233 if (/^#define PATCHLEVEL\s+(\S+)/) { print OUT "PATCHLEVEL='$1'\n"; }
234 elsif (/^#define SUBVERSION\s+(\S+)/) { print OUT "SUBVERSION='$1'\n"; }
c07a80fd 235 }
236 close PL;
e518068a 237}
c07a80fd 238else { warn "Can't read ${outdir}patchlevel.h - skipping 'PATCHLEVEL'"; }
e518068a 239
240# simple pager support for perldoc
8ae5b802 241if (`most` =~ /IVVERB/) {
e518068a 242 $pager = 'more';
243 if (`more nl:` =~ /IVVERB/) { $pager = 'type/page'; }
244}
245else { $pager = 'most'; }
246print OUT "pager='$pager'\n";
247
248close OUT;
a0d0e21e 249__END__
250
251# This list is incomplete in comparison to what ends up in config.sh, but
252# should contain the essentials. Some of these definitions reflect
253# options chosen when building perl or site-specific data; these should
254# be hand-edited appropriately. Someday, perhaps, we'll get this automated.
255
256# The definitions in this block are constant across most systems, and
257# should only rarely need to be changed.
748a9306 258ccdlflags=
259cccdlflags=
748a9306 260usedl=true
a0d0e21e 261dlobj=dl_vms.obj
262dlsrc=dl_vms.c
263so=exe
264dlext=exe
265libpth=/sys$share /sys$library
e518068a 266usevfork=false
267castflags=0
a0d0e21e 268signal_t=void
269timetype=long
a0d0e21e 270builddir=perl_root:[000000]
e518068a 271prefix=perl_root
482b294c 272installprivlib=perl_root:[lib] # The *lib constants should match the
273privlib=perl_root:[lib] # equivalent *(?:ARCH)LIB_EXP constants
274sitelib=perl_root:[lib.site_perl] # in config.h
748a9306 275installbin=perl_root:[000000]
e518068a 276installman1dir=perl_root:[man.man1]
277installman3dir=perl_root:[man.man3]
c07a80fd 278man1ext=rno
279man3ext=rno
e518068a 280binexp=perl_root:[000000] # should be same as installbin
c07a80fd 281useposix=false