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