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