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