Don't let the home-grown readdir() on VMS return results with
[p5sagit/p5-mst-13.2.git] / vms / myconfig.com
1 $! #!/bin/sh  ---> MYCONFIG.COM
2
3 $! # This script is designed to provide a handy summary of the configuration
4 $! # information being used to build perl. This is especially useful if you
5 $! # are requesting help from comp.lang.perl.misc on usenet or via mail.
6
7 $! DCL-ified by Peter Prymmer <pvhp@lns62.lns.cornell.edu> 22-DEC-1995
8 $! DCL usage (choose one):
9 $!      @MYCONFIG                                                       !or
10 $!      @MYCONFIG/OUTPUT=MYCONFIG.OUT                                   !or
11 $!      @MYCONFIG [node::][which$disk:][[dir.subdir]]CONFIG.SH          !or
12 $!      @MYCONFIG/OUTPUT=MYCONFIG.OUT [node::][w$disk:][[dir]]CONFIG.SH
13 $!  version 2:
14 $! Incorporates Charles Bailey's ideas about bootstrapping system info - 
15 $! myconfig.com is now callable as a "myconfig" target in your maker and
16 $! may even work if miniperl.exe and config.sh files fail to be made.
17 $! Thus if: 
18 $!      MMK/DESCRIP=[.VMS]                             !(or MMS or MAKE)
19 $! does not work then try:
20 $!      MMK/DESCRIP=[.VMS]/OUTPUT=MYPERLBUILD.PROBLEM  !(or MMS or MAKE)
21 $! Then discuss the MYPERLBUILD.PROBLEM file with a local expert.
22 $! If that still does not work then try:
23 $!      MMK/DESCRIP=[.VMS]/OUT=MYNONFIG.OUT MYCONFIG   !(or MMS or MAKE)
24 $! send output (MYNONFIG.OUT) to an outside expert and ask politely for help.
25
26 $ ECHO = "WRITE SYS$OUTPUT " 
27 $ RATHER_LONG_DEFAULT_DIRECTORY_NAME = F$ENVIRONMENT("DEFAULT")
28
29 $ if (p1.nes."").and.(p2.eqs."")
30 $   then RATHER_LONG_FILENAME_TO_FIND = p1 !no typo-checking (experts only)
31 $   else RATHER_LONG_FILENAME_TO_FIND = "CONFIG.SH"
32 $ endif
33 $Research:
34 $ RATHER_LONG_FILENAME_SEARCH = F$Search(RATHER_LONG_FILENAME_TO_FIND)
35 $ if RATHER_LONG_FILENAME_SEARCH.EQS."" 
36 $   then
37 $     if f$parse(f$environment("DEFAULT"),,,"DIRECTORY",).NES."[000000]"
38 $       then 
39 $         set default [-]
40 $         goto Research
41 $       else
42 $         ECHO "Can't find the perl config.sh file produced by Configure"
43 $         set default 'RATHER_LONG_DEFAULT_DIRECTORY_NAME'
44 $!         exit 3
45 $         goto cannot_find_config_sh
46 $     endif
47 $ endif
48
49 $ open/read RATHER_LONG_CONFIG_FILE_HANDLE 'RATHER_LONG_FILENAME_SEARCH' 
50 $Loop:
51 $  read/end_of_file = Done RATHER_LONG_CONFIG_FILE_HANDLE  line
52 $  name = f$extract(0,f$locate("=",line),line)
53 $  start = f$locate("'",line)+1
54 $  stop = f$locate("'",line)
55 $  value = f$extract(start,stop-start,line)
56 $  if (f$locate("#",name).eqs.f$length(name)).and. -
57       (name.nes."").and. -
58       (name.nes."'") -               !bug in genconfig.pl (vms) for osvers='' ?
59         then $$'name' = "'" + value  !$ not necessary but looks more sh-ish
60 $ goto Loop
61
62 $Done:
63 $ close RATHER_LONG_CONFIG_FILE_HANDLE 
64 $ goto spit_it_out
65
66 $cannot_find_config_sh:
67 $! these parameters are assumed to be passed from make/mm[s|k]:
68 $!   p1=$(CC),    p2=$(CFLAGS), p3=$(LINKFLAGS), 
69 $!   p4=$(LIBS1), p5=$(LIBS2),  p6=$(SOCKLIB),
70 $!   p7=$(EXT),   p8=$(DBG)
71 $! so assign to appropriate $var:
72 $ $cc = "'"+p1+"'"            ! p1=$(CC) from make
73 $ $ccflags = "'"+p2+"'"       ! p2=$(CFLAGS) from make
74 $ $ldflags = "'"+p3+"'"       ! p3=$(LINKFLAGS) from make 
75 $ $libs = "'"+p4+" "+p5+" "+p6+"'" ! p4$(LIBS1),p5$(LIBS2),p6$(SOCKLIB)frm make
76 $ $staticexts = "'"+p7+"'"         ! p7=$(EXT) from make
77
78 $!  hard-coded stuff (for now): 
79 $ $cppflags = "'"+"'"  !(vestigal)
80 $ $optimize = "'"+"'"  !descrip.mms has /Optimize=2 in $(XTRACCFLAGS)
81
82 $!  following assigns done via `dcl` calls in genconfig.pl anyway:
83 $ $osname = "'"+f$edit(f$getsyi("NODE_SWTYPE"),"COLLAPSE") !genconfig.pl has "osname='VMS'"
84 $ $osvers = f$edit(f$getsyi("VERSION")-"V","COLLAPSE")
85 $ if f$getsyi("HW_MODEL").GT.1024
86 $   then $$archname = "'VMS_AXP'"  !string from descrip.mms vmsperl 12-21-95
87 $   else $$archname = "'VMS_VAX'"  !string from descrip.mms vmsperl 12-21-95
88 $ endif
89 $ $myname = ""
90 $  if $myname.eqs."" then $$myname = f$trnlnm("ARPANET_HOST_NAME")
91 $  if $myname.eqs."" then $$myname = f$trnlnm("INTERNET_HOST_NAME")
92 $  if $myname.eqs."" then $$myname = f$trnlnm("MULTINET_HOST_NAME")
93 $  if $myname.eqs."" then $$myname = f$trnlnm("UCX$INET_HOST_NAME")
94 $  if $myname.eqs."" then $$myname = f$trnlnm("TCPWARE_DOMAINNAME")
95 $  if $myname.eqs."" then $$myname = f$trnlnm("NEWS_ADDRESS")
96 $  if $myname.eqs."" then $$myname = f$trnlnm("SYS$NODE")
97 $!  Is this same as genconfig.pl ? (spacing/order unknown):
98 $ $myuname=$osname+" "+$myname+" "+$osvers+" "+F$GetSyi("HW_NAME")+"'"
99 $ $osname = $osname+"'"
100 $ $osvers = "'"+$osvers+"'"
101
102 $look_for_patchlevel_h:
103 $!
104 $ RATHER_LONG_FILENAME_TO_FIND = "PATCHLEVEL.H"
105 $Research_patchlevel_h:
106 $ RATHER_LONG_FILENAME_SEARCH = F$Search(RATHER_LONG_FILENAME_TO_FIND)
107 $ if RATHER_LONG_FILENAME_SEARCH.EQS."" 
108 $   then
109 $     if f$parse(f$environment("DEFAULT"),,,"DIRECTORY",).NES."[000000]"
110 $       then 
111 $         set default [-]
112 $         goto Research_patchlevel_h
113 $       else
114 $         ECHO "Can't find the header file patchlevel.h used to make config.sh"
115 $         set default 'RATHER_LONG_DEFAULT_DIRECTORY_NAME'
116 $         goto look_for_genconfig.pl
117 $     endif
118 $ endif
119
120 $ open/read RATHER_LONG_CONFIG_FILE_HANDLE 'RATHER_LONG_FILENAME_SEARCH' 
121 $read_patchlevel_h:
122 $ read/end_of_file = patchlevel_h_Done RATHER_LONG_CONFIG_FILE_HANDLE  line
123 $ if f$locate("PERL_VERSION",line).ne.f$length(line)
124 $   then
125 $     line = f$edit(line,"TRIM,COMPRESS")
126 $     $PATCHLEVEL = f$element(2," ",line)
127 $     if f$type($SUBVERSION).nes."" then goto patchlevel_h_Done
128 $ endif
129 $ if f$locate("PERL_SUBVERSION",line).ne.f$length(line)
130 $   then
131 $     line = f$edit(line,"TRIM,COMPRESS")
132 $     $SUBVERSION = f$element(2," ",line)
133 $     if f$type($PATCHLEVEL).nes."" then goto patchlevel_h_Done
134 $ endif
135 $ goto read_patchlevel_h
136
137 $patchlevel_h_Done:
138 $ close RATHER_LONG_CONFIG_FILE_HANDLE 
139 $ if $PATCHLEVEL.eqs.""
140 $   then
141 $     echo "warning: PERL_VERSION was not found in ''RATHER_LONG_FILENAME_TO_FIND':" 
142 $ endif
143
144 $look_for_genconfig_pl:
145 $!
146 $ if f$search("VMS.DIR").nes."" then set default [.vms]
147 $ RATHER_LONG_FILENAME_TO_FIND = "GENCONFIG.PL"
148 $ genconfig_pl_dir = ""
149 $Research_genconfig_pl:
150 $ RATHER_LONG_FILENAME_SEARCH = F$Search(RATHER_LONG_FILENAME_TO_FIND)
151 $ if RATHER_LONG_FILENAME_SEARCH.EQS."" 
152 $   then
153 $     if f$parse(f$environment("DEFAULT"),,,"DIRECTORY",).NES."[000000]"
154 $       then 
155 $         set default [-]
156 $         goto Research_genconfig_pl
157 $       else
158 $         ECHO "Can't find the perl genconfig.pl used to make config.sh"
159 $         set default 'RATHER_LONG_DEFAULT_DIRECTORY_NAME'
160 $         goto look_for_config_vms
161 $     endif
162 $   else    !genconfig.pl has been found
163 $     genconfig_pl_dir = f$parse(f$environment("DEFAULT"),,,"DIRECTORY",)
164 $ endif
165
166 $ cnfg_keys = "package/hintfile/ld/dlext/d_stdstdio/"
167 $ cnfg_keys = cnfg_keys + "usevfork/usemymalloc/so/libpth/"
168 $ cnfg_keys = cnfg_keys + "dlsrc/cccdlflags/ccdlflags/lddlflags/"
169
170 $ cnfg_vars = "$package/$hint/$ld/$dlext/$d_stdstdio/"
171 $ cnfg_vars = cnfg_vars + "$usevfork/$usemymalloc/$so/$libpth/"
172 $ cnfg_vars = cnfg_vars + "$dlsrc/$cccdlflags/$ccdlflags/$lddlflags/" 
173
174 $ open/read RATHER_LONG_CONFIG_FILE_HANDLE 'RATHER_LONG_FILENAME_SEARCH' 
175 $read_genconfig_pl:
176 $ read/end_of_file = Genconfig_pl_Done RATHER_LONG_CONFIG_FILE_HANDLE  line
177 $ if f$locate("=",line).ne.f$length(line)   !then may be an assigment
178 $   then
179 $     name = f$edit( f$extract(0,f$locate("=",line),line), "COLLAPSE")
180 $     num = 0
181 $key_genconfig_pl:
182 $     key = f$element(num,"/",cnfg_keys)
183 $     if (key .nes. "/").and.(key .nes. "") !not end of cnfg_keys
184 $       then
185 $         if key.eqs.name  !then is key
186 $           then
187 $             start = f$locate("=",line)+1
188 $             stop = f$length(line)
189 $             value = f$extract(start,stop-start,line)
190 $             var = f$element(num,"/",cnfg_vars)
191 $             'var' = value  
192 $             cnfg_keys = cnfg_keys - ("''name'/" ) !trim to shorten future matches
193 $             cnfg_vars = cnfg_vars - ("''var'/" ) !trim to shorten future matches
194 $         endif
195 $         num = num + 1
196 $         goto key_genconfig_pl
197 $     endif ! not end of cnfg_keys
198 $ endif ! then may be an assigment
199 $ goto read_genconfig_pl
200
201 $Genconfig_pl_Done:
202 $ close RATHER_LONG_CONFIG_FILE_HANDLE 
203 $ if cnfg_vars.nes.""
204 $   then
205 $     echo "warning: the following variables were not found in ''RATHER_LONG_FILENAME_TO_FIND':" 
206 $     echo "''cnfg_vars'"
207 $ endif
208
209 $ if (p8.nes."").and.($ld.nes."") then $ld = $ld + " DBG='"+p8+"'" 
210
211 $look_for_config_vms:
212 $ RATHER_LONG_FILENAME_TO_FIND = "''genconfig_pl_dir'CONFIG.VMS"
213
214 $Research_config_vms:
215 $ RATHER_LONG_FILENAME_SEARCH = F$Search(RATHER_LONG_FILENAME_TO_FIND)
216 $ if RATHER_LONG_FILENAME_SEARCH.EQS."" 
217 $   then
218 $     if f$parse(f$environment("DEFAULT"),,,"DIRECTORY",).NES."[000000]"
219 $       then 
220 $         set default [-]
221 $         goto Research_config_vms
222 $       else
223 $         ECHO "Can't find the perl config.vms used to make config.sh"
224 $         set default 'RATHER_LONG_DEFAULT_DIRECTORY_NAME'
225 $         stop
226 $         exit 3 
227 $     endif
228 $ endif
229
230 $ cnfg_keys = "MEM_ALIGNBYTES/CASTNEGFLOAT/CASTFLAGS/RANDBITS/STDCHAR/"
231 $ cnfg_keys = cnfg_keys+"CASTI32/INTSIZE/VOIDFLAGS/DLSYM_NEEDS_UNDERSCORE"
232
233 $ cnfg_vars = "$alignbytes/$d_castneg/$castflags/$randbits/$stdchar/"
234 $ cnfg_vars = cnfg_vars+"$d_casti32/$intsize/$voidflags/$d_dlsymun/"
235
236 $ open/read RATHER_LONG_CONFIG_FILE_HANDLE 'RATHER_LONG_FILENAME_SEARCH' 
237 $read_config_vms:
238 $ read/end_of_file = config_vms_Done RATHER_LONG_CONFIG_FILE_HANDLE  line
239 $! look for "#define" or "#undef"
240 $ if (f$length(line).ne.0).and.-
241    ((f$locate("#define",line).eq.0).or.(f$locate("#undef",line).eq.0)) 
242 $   then
243 $     line = f$edit(line,"COMPRESS, TRIM")
244 $     name = f$element(1," ",line) !macro
245 $     num = 0
246 $key_config_vms:
247 $     key = f$element(num,"/",cnfg_keys)
248 $     if (key .nes. "/").and.(key .nes. "") !not end of cnfg_keys
249 $       then
250 $         if key.eqs.name  !then is key
251 $           then
252 $             var = f$element(num,"/",cnfg_vars)
253 $             cnfg_keys = cnfg_keys - ("''name'/" ) !trim to shorten future matches
254 $             cnfg_vars = cnfg_vars - ("''var'/" ) !trim to shorten future matches
255 $             if (f$locate("#undef",line).eq.0)
256 $               then
257 $                 'var' = "'undef'"
258 $               else                  !is a #define
259 $strip_comment:
260 $                 start = f$locate("/*",line)
261 $                 if start.ne.f$length(line) !comment started
262 $                   then
263 $                     if f$locate("*/",line).ne.f$length(line) !comment stopped
264 $                       then stop = f$locate("*/",line)+2
265 $                       else stop = f$locate("*/",line)
266 $                     endif
267 $                     comment = f$extract(start,stop-start,line)
268 $                     line = line - comment
269 $                     goto strip_comment
270 $                 endif
271 $                 line = f$edit(line,"TRIM")
272 $                 start = f$locate(key,line)+f$length(key)
273 $                 stop = f$length(line)
274 $                 value = f$edit(f$extract(start,stop-start,line),"TRIM")
275 $                 if (value.nes."") 
276 $                   then 
277 $                     'var' = "'"+value+"'"
278 $                   else 
279 $                     'var' = "'define'"
280 $                 endif
281 $             endif            !#define
282 $         endif                ! is key of interest
283 $         num = num + 1
284 $         goto key_config_vms
285 $     endif ! not end of cnfg_keys
286 $ endif ! then may be #define or #undef of interest
287 $ goto read_config_vms
288
289 $config_vms_Done:
290 $ close RATHER_LONG_CONFIG_FILE_HANDLE 
291 $ if cnfg_vars.nes.""
292 $   then
293 $     echo "warning: the following variables were not found in ''RATHER_LONG_FILENAME_TO_FIND':" 
294 $     echo "''cnfg_vars'"
295 $ endif
296
297 $spit_it_out:
298 $! $spitshell = ECHO !<<!GROK!THIS! 
299 $ ECHO " "
300 $ ECHO "Summary of my ''$package' (version ''$PATCHLEVEL' subversion ''$SUBVERSION') configuration:"
301 $ ECHO "  Platform:"
302 $ ECHO "    osname=''$osname', osvers=''$osvers', archname=''$archname'"
303 $ ECHO "     uname=''$myuname'"                             !->d_has_uname?
304 $ ECHO "     hint=''$hint' d_sigaction='undef'"             !->hintfile?
305 $ ECHO "     static exts=''$staticexts'"                    ! added for VMS
306 $ ECHO "   Compiler:"
307 $ ECHO "     cc=''$cc', optimize=''$optimize', ld=''$ld'"
308 $ ECHO "     cppflags=''$cppflags'"
309 $ ECHO "     ccflags =''$ccflags'"                          !->vms_cc_type?
310 $ ECHO "     ldflags =''$ldflags'"
311 $ ECHO "     stdchar=''$stdchar', d_stdstdio=''$d_stdstdio', usevfork=''$usevfork'"
312 $ ECHO "     voidflags=''$voidflags', castflags=''$castflags', d_casti32=''$d_casti32', d_castneg=''$d_castneg'"
313 $ ECHO "     intsize=''$intsize', alignbytes=''$alignbytes', usemymalloc=''$usemymalloc', randbits=''$randbits'"
314 $ ECHO "   Libraries:"
315 $ ECHO "     so=''$so'"
316 $ ECHO "     libpth=''$libpth'"
317 $ ECHO "     libs=''$libs'"
318 $ ECHO "     libc=''$libc'"
319 $ ECHO "   Dynamic Linking:"
320 $ ECHO "     dlsrc=''$dlsrc', dlext=''$dlext', d_dlsymun=''$d_dlsymun'"
321 $ ECHO "     cccdlflags=''$cccdlflags', ccdlflags=''$ccdlflags', lddlflags=''$lddlflags'"
322 $ ECHO " " 
323 $ !GROK!THIS!
324 $ SET DEFAULT 'RATHER_LONG_DEFAULT_DIRECTORY_NAME'
325 $ EXIT