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 |
---|
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. |
---|
8 | # |
---|
9 | # Rev. 3-Dec-1996 Charles Bailey bailey@genetics.upenn.edu |
---|
10 | # |
---|
11 | |
---|
12 | #==== Locations of installed Perl components |
---|
13 | $prefix='perl_root'; |
---|
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]"; |
---|
21 | |
---|
22 | unshift(@INC,'lib'); # In case someone didn't define Perl_Root |
---|
23 | # before the build |
---|
24 | |
---|
25 | if ($ARGV[0] eq '-f') { |
---|
26 | open(ARGS,$ARGV[1]) or die "Can't read data from $ARGV[1]: $!\n"; |
---|
27 | @ARGV = (); |
---|
28 | while (<ARGS>) { |
---|
29 | push(@ARGV,split(/\|/,$_)); |
---|
30 | } |
---|
31 | close ARGS; |
---|
32 | } |
---|
33 | |
---|
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 = "[]";} |
---|
37 | |
---|
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. |
---|
43 | EndOfGasp |
---|
44 | } |
---|
45 | $outdir = ''; |
---|
46 | open(IN,"$infile") || die "Can't open $infile: $!\n"; |
---|
47 | open(OUT,">${outdir}Config.sh") || die "Can't open ${outdir}Config.sh: $!\n"; |
---|
48 | |
---|
49 | $time = localtime; |
---|
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/; |
---|
58 | |
---|
59 | print OUT <<EndOfIntro; |
---|
60 | # This file generated by GenConfig.pl on a VMS system. |
---|
61 | # Input obtained from: |
---|
62 | # $infile |
---|
63 | # $0 |
---|
64 | # Time: $time |
---|
65 | |
---|
66 | package='perl5' |
---|
67 | CONFIG='true' |
---|
68 | cf_time='$time' |
---|
69 | cf_by='$cf_by' |
---|
70 | ccdlflags='' |
---|
71 | cccdlflags='' |
---|
72 | mab='' |
---|
73 | libpth='/sys\$share /sys\$library' |
---|
74 | ld='Link' |
---|
75 | lddlflags='/Share' |
---|
76 | ranlib='' |
---|
77 | ar='' |
---|
78 | eunicefix=':' |
---|
79 | hint='none' |
---|
80 | hintfile='' |
---|
81 | shrplib='define' |
---|
82 | usemymalloc='n' |
---|
83 | usevfork='true' |
---|
84 | useposix='false' |
---|
85 | spitshell='write sys\$output ' |
---|
86 | dlsrc='dl_vms.c' |
---|
87 | binexp='$installbin' |
---|
88 | man1ext='rno' |
---|
89 | man3ext='rno' |
---|
90 | arch='VMS_$archsufx' |
---|
91 | archname='VMS_$archsufx' |
---|
92 | osvers='$osvers' |
---|
93 | prefix='$prefix' |
---|
94 | builddir='$builddir' |
---|
95 | installbin='$installbin' |
---|
96 | installscript='$installscript' |
---|
97 | installman1dir='$installman1dir' |
---|
98 | installman3dir='$installman3dir' |
---|
99 | installprivlib='$installprivlib' |
---|
100 | installarchlib='$installarchlib' |
---|
101 | installsitelib='$installsitelib' |
---|
102 | installsitearch='$installsitearch' |
---|
103 | path_sep='|' |
---|
104 | startperl='\$ perl 'f\$env("procedure")' 'p1' 'p2' 'p3' 'p4' 'p5' 'p6' 'p7' 'p8' ! |
---|
105 | \$ exit++ + ++\$status != 0 and \$exit = \$status = undef;' |
---|
106 | EndOfIntro |
---|
107 | |
---|
108 | foreach (@ARGV) { |
---|
109 | ($key,$val) = split('=',$_,2); |
---|
110 | if ($key eq 'cc') { # Figure out which C compiler we're using |
---|
111 | my($cc,$ccflags) = split('/',$val,2); |
---|
112 | my($d_attr); |
---|
113 | $ccflags = "/$ccflags"; |
---|
114 | if ($ccflags =~s!/DECC!!ig) { |
---|
115 | $cc .= '/DECC'; |
---|
116 | $cctype = 'decc'; |
---|
117 | $d_attr = 'undef'; |
---|
118 | } |
---|
119 | elsif ($ccflags =~s!/VAXC!!ig) { |
---|
120 | $cc .= '/VAXC'; |
---|
121 | $cctype = 'vaxc'; |
---|
122 | $d_attr = 'undef'; |
---|
123 | } |
---|
124 | elsif (`$val/NoObject/NoList _nla0:/Version` =~ /GNU C version (\S+)/) { |
---|
125 | $cctype = 'gcc'; |
---|
126 | $d_attr = 'define'; |
---|
127 | print OUT "gccversion='$1'\n"; |
---|
128 | } |
---|
129 | elsif ($archsufx eq 'VAX' && |
---|
130 | # Check exit status too, in case message is turned off |
---|
131 | ( `$val/NoObject/NoList /prefix=all _nla0:` =~ /IVQUAL/ || |
---|
132 | $? == 0x38240 )) { |
---|
133 | $cctype = 'vaxc'; |
---|
134 | $d_attr = 'undef'; |
---|
135 | } |
---|
136 | else { |
---|
137 | $cctype = 'decc'; |
---|
138 | $d_attr = 'undef'; |
---|
139 | } |
---|
140 | print OUT "vms_cc_type='$cctype'\n"; |
---|
141 | print OUT "d_attribut='$d_attr'\n"; |
---|
142 | print OUT "cc='$cc'\n"; |
---|
143 | if ( ($cctype eq 'decc' and $archsufx eq 'VAX') || $cctype eq 'gcc') { |
---|
144 | # gcc and DECC for VAX requires filename in /object qualifier, so we |
---|
145 | # have to remove it here. Alas, this means we lose the user's |
---|
146 | # object file suffix if it's not .obj. |
---|
147 | $ccflags =~ s#/obj(?:ect)?=[^/\s]+##i; |
---|
148 | } |
---|
149 | print OUT "ccflags='$ccflags'\n"; |
---|
150 | $dosock = ($ccflags =~ m!/DEF[^/]+VMS_DO_SOCKETS!i and |
---|
151 | $ccflags !~ m!/UND[^/]+VMS_DO_SOCKETS!i); |
---|
152 | print OUT "d_vms_do_sockets=",$dosock ? "'define'\n" : "'undef'\n"; |
---|
153 | print OUT "d_socket=",$dosock ? "'define'\n" : "'undef'\n"; |
---|
154 | print OUT "d_sockpair=",$dosock ? "'define'\n" : "'undef'\n"; |
---|
155 | print OUT "d_gethent=",$dosock ? "'define'\n" : "'undef'\n"; |
---|
156 | print OUT "d_select=",$dosock ? "'define'\n" : "'undef'\n"; |
---|
157 | print OUT "i_niin=",$dosock ? "'define'\n" : "'undef'\n"; |
---|
158 | print OUT "i_neterrno=",$dosock ? "'define'\n" : "'undef'\n"; |
---|
159 | |
---|
160 | if ($cctype eq 'decc') { $rtlhas = 'define'; } |
---|
161 | else { $rtlhas = 'undef'; } |
---|
162 | foreach (qw[ d_stdstdio d_stdio_ptr_lval d_stdio_cnt_lval d_stdiobase |
---|
163 | d_locconv d_setlocale i_locale d_mbstowcs d_mbtowc |
---|
164 | d_wcstombs d_wctomb d_mblen d_mktime d_strcoll d_strxfrm ]) { |
---|
165 | print OUT "$_='$rtlhas'\n"; |
---|
166 | } |
---|
167 | next; |
---|
168 | } |
---|
169 | elsif ($key eq 'exe_ext') { |
---|
170 | my($nodot) = $val; |
---|
171 | $nodot =~ s!\.!!; |
---|
172 | print OUT "so='$nodot'\ndlext='$nodot'\n"; |
---|
173 | } |
---|
174 | elsif ($key eq 'obj_ext') { print OUT "dlobj='dl_vms$val'\n"; } |
---|
175 | print OUT "$key='$val'\n"; |
---|
176 | } |
---|
177 | |
---|
178 | # Are there any other logicals which TCP/IP stacks use for the host name? |
---|
179 | $myname = $ENV{'ARPANET_HOST_NAME'} || $ENV{'INTERNET_HOST_NAME'} || |
---|
180 | $ENV{'MULTINET_HOST_NAME'} || $ENV{'UCX$INET_HOST'} || |
---|
181 | $ENV{'TCPWARE_DOMAINNAME'} || $ENV{'NEWS_ADDRESS'}; |
---|
182 | if (!$myname) { |
---|
183 | ($myname) = `hostname` =~ /^(\S+)/; |
---|
184 | if ($myname =~ /IVVERB/) { |
---|
185 | warn "Can't determine TCP/IP hostname" if $dosock; |
---|
186 | $myname = ''; |
---|
187 | } |
---|
188 | } |
---|
189 | $myname = $ENV{'SYS$NODE'} unless $myname; |
---|
190 | ($myhostname,$mydomain) = split(/\./,$myname,2); |
---|
191 | print OUT "myhostname='$myhostname'\n" if $myhostname; |
---|
192 | if ($mydomain) { |
---|
193 | print OUT "mydomain='.$mydomain'\n"; |
---|
194 | print OUT "perladmin='$cf_by\@$myhostname.$mydomain'\n"; |
---|
195 | print OUT "cf_email='$cf_by\@$myhostname.$mydomain'\n"; |
---|
196 | } |
---|
197 | else { |
---|
198 | print OUT "perladmin='$cf_by'\n"; |
---|
199 | print OUT "cf_email='$cf_by'\n"; |
---|
200 | } |
---|
201 | chomp($hwname = `Write Sys\$Output F\$GetSyi("HW_NAME")`); |
---|
202 | $hwname = $archsufx if $hwname =~ /IVKEYW/; # *really* old VMS version |
---|
203 | print OUT "myuname='VMS $myname $osvers $hwname'\n"; |
---|
204 | |
---|
205 | # Before we read the C header file, find out what config.sh constants are |
---|
206 | # equivalent to the C preprocessor macros |
---|
207 | if (open(SH,"${outdir}config_h.SH")) { |
---|
208 | while (<SH>) { |
---|
209 | next unless m%^#(?!if).*\$%; |
---|
210 | s/^#//; s!(.*?)\s*/\*.*!$1!; |
---|
211 | my(@words) = split; |
---|
212 | $words[1] =~ s/\(.*//; # Clip off args from macro |
---|
213 | # Did we use a shell variable for the preprocessor directive? |
---|
214 | if ($words[0] =~ m!^\$(\w+)!) { $pp_vars{$words[1]} = $1; } |
---|
215 | if (@words > 2) { # We may also have a shell var in the value |
---|
216 | shift @words; # Discard preprocessor directive |
---|
217 | my($token) = shift @words; # and keep constant name |
---|
218 | my($word); |
---|
219 | foreach $word (@words) { |
---|
220 | next unless $word =~ m!\$(\w+)!; |
---|
221 | $val_vars{$token} = $1; |
---|
222 | last; |
---|
223 | } |
---|
224 | } |
---|
225 | } |
---|
226 | close SH; |
---|
227 | } |
---|
228 | else { warn "Couldn't read ${outdir}config_h.SH: $!\n"; } |
---|
229 | $pp_vars{UNLINK_ALL_VERSIONS} = 'd_unlink_all_versions'; # VMS_specific |
---|
230 | |
---|
231 | # OK, now read the C header file, and retcon statements into config.sh |
---|
232 | while (<IN>) { # roll through the comment header in Config.VMS |
---|
233 | last if /config-start/; |
---|
234 | } |
---|
235 | |
---|
236 | while (<IN>) { |
---|
237 | chop; |
---|
238 | while (/\\\s*$/) { # pick up contination lines |
---|
239 | my $line = $_; |
---|
240 | $line =~ s/\\\s*$//; |
---|
241 | $_ = <IN>; |
---|
242 | s/^\s*//; |
---|
243 | $_ = $line . $_; |
---|
244 | } |
---|
245 | next unless my ($blocked,$un,$token,$val) = |
---|
246 | m%^(\/\*)?\s*\#\s*(un)?def\w*\s+([A-Za-z0-9]\w+)\S*\s*(.*)%; |
---|
247 | if (/config-skip/) { |
---|
248 | delete $pp_vars{$token} if exists $pp_vars{$token}; |
---|
249 | delete $val_vars{$token} if exists $val_vars{$token}; |
---|
250 | next; |
---|
251 | } |
---|
252 | $val =~ s!\s*/\*.*!!; # strip off trailing comment |
---|
253 | my($had_val); # Maybe a macro with args that we just #undefd or commented |
---|
254 | if (!length($val) and $val_vars{$token} and ($un || $blocked)) { |
---|
255 | print OUT "$val_vars{$token}=''\n" unless exists $done{$val_vars{$token}}; |
---|
256 | $done{$val_vars{$token}}++; |
---|
257 | delete $val_vars{$token}; |
---|
258 | $had_val = 1; |
---|
259 | } |
---|
260 | $state = ($blocked || $un) ? 'undef' : 'define'; |
---|
261 | if ($pp_vars{$token}) { |
---|
262 | print OUT "$pp_vars{$token}='$state'\n" unless exists $done{$pp_vars{$token}}; |
---|
263 | $done{$pp_vars{$token}}++; |
---|
264 | delete $pp_vars{$token}; |
---|
265 | } |
---|
266 | elsif (not length $val and not $had_val) { |
---|
267 | # Wups -- should have been shell var for C preprocessor directive |
---|
268 | warn "Constant $token not found in config_h.SH\n"; |
---|
269 | $token = lc $token; |
---|
270 | $token = "d_$token" unless $token =~ /^i_/; |
---|
271 | print OUT "$token='$state'\n"; |
---|
272 | } |
---|
273 | next unless length $val; |
---|
274 | $val =~ s/^"//; $val =~ s/"$//; # remove end quotes |
---|
275 | $val =~ s/","/ /g; # make signal list look nice |
---|
276 | # Library directory; convert to VMS syntax |
---|
277 | $val = VMS::Filespec::vmspath($val) if ($token =~ /EXP$/); |
---|
278 | if ($val_vars{$token}) { |
---|
279 | print OUT "$val_vars{$token}='$val'\n" unless exists $done{$val_vars{$token}}; |
---|
280 | if ($val_vars{$token} =~ s/exp$//) { |
---|
281 | print OUT "$val_vars{$token}='$val'\n" unless exists $done{$val_vars{$token}};; |
---|
282 | } |
---|
283 | $done{$val_vars{$token}}++; |
---|
284 | delete $val_vars{$token}; |
---|
285 | } |
---|
286 | elsif (!$pp_vars{$token}) { # Haven't seen it previously, either |
---|
287 | warn "Constant $token not found in config_h.SH (val=|$val|)\n"; |
---|
288 | $token = lc $token; |
---|
289 | print OUT "$token='$val'\n"; |
---|
290 | if ($token =~ s/exp$//) {print OUT "$token='$val'\n";} |
---|
291 | } |
---|
292 | } |
---|
293 | close IN; |
---|
294 | # Special case -- preprocessor manifest "VMS" is defined automatically |
---|
295 | # on VMS systems, but is also used erroneously by the Perl build process |
---|
296 | # as the manifest for the obsolete variable $d_eunice. |
---|
297 | print OUT "d_eunice='undef'\n"; delete $pp_vars{VMS}; |
---|
298 | |
---|
299 | foreach (sort keys %pp_vars) { |
---|
300 | warn "Didn't see $_ in $infile\n"; |
---|
301 | } |
---|
302 | foreach (sort keys %val_vars) { |
---|
303 | warn "Didn't see $_ in $infile(val)\n"; |
---|
304 | } |
---|
305 | |
---|
306 | if (open(OPT,"${outdir}crtl.opt")) { |
---|
307 | while (<OPT>) { |
---|
308 | next unless m#/(sha|lib)#i; |
---|
309 | chomp; |
---|
310 | if (/crtl/i || /gcclib/i) { push(@crtls,$_); } |
---|
311 | else { push(@libs,$_); } |
---|
312 | } |
---|
313 | close OPT; |
---|
314 | print OUT "libs='",join(' ',@libs),"'\n"; |
---|
315 | push(@crtls,'(DECCRTL)') if $cctype eq 'decc'; |
---|
316 | print OUT "libc='",join(' ',@crtls),"'\n"; |
---|
317 | } |
---|
318 | else { warn "Can't read ${outdir}crtl.opt - skipping 'libs' & 'libc'"; } |
---|
319 | |
---|
320 | if (open(PL,"${outdir}patchlevel.h")) { |
---|
321 | while (<PL>) { |
---|
322 | if (/^#define PATCHLEVEL\s+(\S+)/) { print OUT "PATCHLEVEL='$1'\n"; } |
---|
323 | elsif (/^#define SUBVERSION\s+(\S+)/) { print OUT "SUBVERSION='$1'\n"; } |
---|
324 | } |
---|
325 | close PL; |
---|
326 | } |
---|
327 | else { warn "Can't read ${outdir}patchlevel.h - skipping 'PATCHLEVEL'"; } |
---|
328 | |
---|
329 | # simple pager support for perldoc |
---|
330 | if (`most not..file` =~ /IVVERB/) { |
---|
331 | $pager = 'more'; |
---|
332 | if (`more nl:` =~ /IVVERB/) { $pager = 'type/page'; } |
---|
333 | } |
---|
334 | else { $pager = 'most'; } |
---|
335 | print OUT "pager='$pager'\n"; |
---|
336 | |
---|
337 | close OUT; |
---|