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
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.
9 # Rev. 3-Dec-1996 Charles Bailey bailey@genetics.upenn.edu
12 #==== Locations of installed Perl components
14 $builddir="$prefix:[000000]";
15 $installbin="$prefix:[000000]";
16 $installscript="$prefix:[000000]";
17 $installman1dir="$prefix:[man.man1]";
18 $installman3dir="$prefix:[man.man3]";
19 $installprivlib="$prefix:[lib]";
20 $installsitelib="$prefix:[lib.site_perl]";
22 unshift(@INC,'lib'); # In case someone didn't define Perl_Root
25 if ($ARGV[0] eq '-f') {
26 open(ARGS,$ARGV[1]) or die "Can't read data from $ARGV[1]: $!\n";
29 push(@ARGV,split(/\|/,$_));
34 if (-f "config.vms") { $infile = "config.vms"; $outdir = "[-]"; }
35 elsif (-f "[.vms]config.vms") { $infile = "[.vms]config.vms"; $outdir = "[]"; }
36 elsif (-f "config.h") { $infile = "config.h"; $outdir = "[]";}
38 if ($infile) { print "Generating Config.sh from $infile . . .\n"; }
39 else { die <<EndOfGasp;
40 Can't find config.vms or config.h to read!
41 Please run this script from the perl source directory or
42 the VMS subdirectory in the distribution.
46 open(IN,"$infile") || die "Can't open $infile: $!\n";
47 open(OUT,">${outdir}Config.sh") || die "Can't open ${outdir}Config.sh: $!\n";
50 $cf_by = (getpwuid($<))[0];
51 $archsufx = `Write Sys\$Output F\$GetSyi("HW_MODEL")` > 1024 ? 'AXP' : 'VAX';
52 ($vers = $]) =~ tr/./_/;
53 $installarchlib = VMS::Filespec::vmspath($installprivlib);
54 $installarchlib =~ s#\]#.VMS_$archsufx.$vers\]#;
55 $installsitearch = VMS::Filespec::vmspath($installsitelib);
56 $installsitearch =~ s#\]#.VMS_$archsufx\]#;
57 ($osvers = `Write Sys\$Output F\$GetSyi("VERSION")`) =~ s/^V?(\S+)\s*\n?$/$1/;
59 print OUT <<EndOfIntro;
60 # This file generated by GenConfig.pl on a VMS system.
61 # Input obtained from:
73 libpth='/sys\$share /sys\$library'
87 spitshell='write sys\$output '
93 archname='VMS_$archsufx'
97 installbin='$installbin'
98 installscript='$installscript'
99 installman1dir='$installman1dir'
100 installman3dir='$installman3dir'
101 installprivlib='$installprivlib'
102 installarchlib='$installarchlib'
103 installsitelib='$installsitelib'
104 installsitearch='$installsitearch'
108 ($key,$val) = split('=',$_,2);
109 if ($key eq 'cc') { # Figure out which C compiler we're using
110 my($cc,$ccflags) = split('/',$val,2);
112 $ccflags = "/$ccflags";
113 if ($ccflags =~s!/DECC!!ig) {
118 elsif ($ccflags =~s!/VAXC!!ig) {
123 elsif (`$val/NoObject/NoList _nla0:/Version` =~ /GNU C version (\S+)/) {
126 print OUT "gccversion='$1'\n";
128 elsif ($archsufx eq 'VAX' &&
129 # Check exit status too, in case message is turned off
130 ( `$val/NoObject/NoList /prefix=all _nla0:` =~ /IVQUAL/ ||
139 print OUT "vms_cc_type='$cctype'\n";
140 print OUT "d_attribut='$d_attr'\n";
141 print OUT "cc='$cc'\n";
142 if ( ($cctype eq 'decc' and $archsufx eq 'VAX') || $cctype eq 'gcc') {
143 # gcc and DECC for VAX requires filename in /object qualifier, so we
144 # have to remove it here. Alas, this means we lose the user's
145 # object file suffix if it's not .obj.
146 $ccflags =~ s#/obj(?:ect)?=[^/\s]+##i;
148 print OUT "ccflags='$ccflags'\n";
149 $dosock = ($ccflags =~ m!/DEF[^/]+VMS_DO_SOCKETS!i and
150 $ccflags !~ m!/UND[^/]+VMS_DO_SOCKETS!i);
151 print OUT "d_vms_do_sockets=",$dosock ? "'define'\n" : "'undef'\n";
152 print OUT "d_socket=",$dosock ? "'define'\n" : "'undef'\n";
153 print OUT "d_sockpair=",$dosock ? "'define'\n" : "'undef'\n";
154 print OUT "d_gethent=",$dosock ? "'define'\n" : "'undef'\n";
155 print OUT "d_select=",$dosock ? "'define'\n" : "'undef'\n";
156 print OUT "i_niin=",$dosock ? "'define'\n" : "'undef'\n";
157 print OUT "i_neterrno=",$dosock ? "'define'\n" : "'undef'\n";
159 if ($cctype eq 'decc') { $rtlhas = 'define'; }
160 else { $rtlhas = 'undef'; }
161 foreach (qw[ d_stdstdio d_stdio_ptr_lval d_stdio_cnt_lval d_stdiobase
162 d_locconv d_setlocale i_locale d_mbstowcs d_mbtowc
163 d_wcstombs d_wctomb d_mblen d_mktime d_strcoll d_strxfrm ]) {
164 print OUT "$_='$rtlhas'\n";
168 elsif ($key eq 'exe_ext') {
171 print OUT "so='$nodot'\ndlext='$nodot'\n";
173 elsif ($key eq 'obj_ext') { print OUT "dlobj='dl_vms$val'\n"; }
174 print OUT "$key='$val'\n";
177 # Are there any other logicals which TCP/IP stacks use for the host name?
178 $myname = $ENV{'ARPANET_HOST_NAME'} || $ENV{'INTERNET_HOST_NAME'} ||
179 $ENV{'MULTINET_HOST_NAME'} || $ENV{'UCX$INET_HOST'} ||
180 $ENV{'TCPWARE_DOMAINNAME'} || $ENV{'NEWS_ADDRESS'};
182 ($myname) = `hostname` =~ /^(\S+)/;
183 if ($myname =~ /IVVERB/) {
184 warn "Can't determine TCP/IP hostname" if $dosock;
188 $myname = $ENV{'SYS$NODE'} unless $myname;
189 ($myhostname,$mydomain) = split(/\./,$myname,2);
190 print OUT "myhostname='$myhostname'\n" if $myhostname;
192 print OUT "mydomain='.$mydomain'\n";
193 print OUT "perladmin='$cf_by\@$myhostname.$mydomain'\n";
194 print OUT "cf_email='$cf_by\@$myhostname.$mydomain'\n";
197 print OUT "perladmin='$cf_by'\n";
198 print OUT "cf_email='$cf_by'\n";
200 chomp($hwname = `Write Sys\$Output F\$GetSyi("HW_NAME")`);
201 $hwname = $archsufx if $hwname =~ /IVKEYW/; # *really* old VMS version
202 print OUT "myuname='VMS $myname $osvers $hwname'\n";
204 # Before we read the C header file, find out what config.sh constants are
205 # equivalent to the C preprocessor macros
206 if (open(SH,"${outdir}config_h.SH")) {
208 next unless m%^#(?!if).*\$%;
209 s/^#//; s!(.*?)\s*/\*.*!$1!;
211 $words[1] =~ s/\(.*//; # Clip off args from macro
212 # Did we use a shell variable for the preprocessor directive?
213 if ($words[0] =~ m!^\$(\w+)!) { $pp_vars{$words[1]} = $1; }
214 if (@words > 2) { # We may also have a shell var in the value
215 shift @words; # Discard preprocessor directive
216 my($token) = shift @words; # and keep constant name
218 foreach $word (@words) {
219 next unless $word =~ m!\$(\w+)!;
220 $val_vars{$token} = $1;
227 else { warn "Couldn't read ${outdir}config_h.SH: $!\n"; }
228 $pp_vars{UNLINK_ALL_VERSIONS} = 'd_unlink_all_versions'; # VMS_specific
230 # OK, now read the C header file, and retcon statements into config.sh
231 while (<IN>) { # roll through the comment header in Config.VMS
232 last if /config-start/;
237 while (/\\\s*$/) { # pick up contination lines
244 next unless my ($blocked,$un,$token,$val) =
245 m%^(\/\*)?\s*\#\s*(un)?def\w*\s+([A-Za-z0-9]\w+)\S*\s*(.*)%;
247 delete $pp_vars{$token} if exists $pp_vars{$token};
248 delete $val_vars{$token} if exists $val_vars{$token};
251 $val =~ s!\s*/\*.*!!; # strip off trailing comment
252 my($had_val); # Maybe a macro with args that we just #undefd or commented
253 if (!length($val) and $val_vars{$token} and ($un || $blocked)) {
254 print OUT "$val_vars{$token}=''\n";
255 delete $val_vars{$token};
258 $state = ($blocked || $un) ? 'undef' : 'define';
259 if ($pp_vars{$token}) {
260 print OUT "$pp_vars{$token}='$state'\n";
261 delete $pp_vars{$token};
263 elsif (not length $val and not $had_val) {
264 # Wups -- should have been shell var for C preprocessor directive
265 warn "Constant $token not found in config_h.SH\n";
267 $token = "d_$token" unless $token =~ /^i_/;
268 print OUT "$token='$state'\n";
270 next unless length $val;
271 $val =~ s/^"//; $val =~ s/"$//; # remove end quotes
272 $val =~ s/","/ /g; # make signal list look nice
273 # Library directory; convert to VMS syntax
274 $val = VMS::Filespec::vmspath($val) if ($token =~ /EXP$/);
275 if ($val_vars{$token}) {
276 print OUT "$val_vars{$token}='$val'\n";
277 if ($val_vars{$token} =~ s/exp$//) {print OUT "$val_vars{$token}='$val'\n";}
278 delete $val_vars{$token};
280 elsif (!$pp_vars{$token}) { # Haven't seen it previously, either
281 warn "Constant $token not found in config_h.SH (val=|$val|)\n";
283 print OUT "$token='$val'\n";
284 if ($token =~ s/exp$//) {print OUT "$token='$val'\n";}
288 # Special case -- preprocessor manifest "VMS" is defined automatically
289 # on VMS systems, but is also used erroneously by the Perl build process
290 # as the manifest for the obsolete variable $d_eunice.
291 print OUT "d_eunice='undef'\n"; delete $pp_vars{VMS};
293 foreach (sort keys %pp_vars) {
294 warn "Didn't see $_ in $infile\n";
296 foreach (sort keys %val_vars) {
297 warn "Didn't see $_ in $infile(val)\n";
300 if (open(OPT,"${outdir}crtl.opt")) {
302 next unless m#/(sha|lib)#i;
304 if (/crtl/i || /gcclib/i) { push(@crtls,$_); }
305 else { push(@libs,$_); }
308 print OUT "libs='",join(' ',@libs),"'\n";
309 push(@crtls,'(DECCRTL)') if $cctype eq 'decc';
310 print OUT "libc='",join(' ',@crtls),"'\n";
312 else { warn "Can't read ${outdir}crtl.opt - skipping 'libs' & 'libc'"; }
314 if (open(PL,"${outdir}patchlevel.h")) {
316 if (/^#define PATCHLEVEL\s+(\S+)/) { print OUT "PATCHLEVEL='$1'\n"; }
317 elsif (/^#define SUBVERSION\s+(\S+)/) { print OUT "SUBVERSION='$1'\n"; }
321 else { warn "Can't read ${outdir}patchlevel.h - skipping 'PATCHLEVEL'"; }
323 # simple pager support for perldoc
324 if (`most not..file` =~ /IVVERB/) {
326 if (`more nl:` =~ /IVVERB/) { $pager = 'type/page'; }
328 else { $pager = 'most'; }
329 print OUT "pager='$pager'\n";