xref: /curl/packages/vms/config_h.com (revision b042d529)
1$! File: config_h.com
2$!
3$! This procedure attempts to figure out how to build a config.h file
4$! for the current project.
5$!
6$! P1 specifies the config.h.in file or equivalent.  If it is not specified
7$! then this procedure will search for several common names of the file.
8$!
9$! The CONFIGURE shell script will be examined for hints and a few symbols
10$! but most of the tests will not produce valid results on OpenVMS.  Some
11$! will produce false positives and some will produce false negatives.
12$!
13$! It is easier to just read the config.h_in file and make up tests based
14$! on what is in it!
15$!
16$! This file will create an empty config_vms.h file if one does not exist.
17$! The config_vms.h is intended for manual edits to handle things that
18$! this procedure can not.
19$!
20$! The config_vms.h will be invoked by the resulting config.h file.
21$!
22$! This procedure knows about the DEC C RTL on the system it is on.
23$! Future versions may be handle the GNV, the OpenVMS porting library,
24$! and others.
25$!
26$! This procedure may not guess the options correctly for all architectures,
27$! and is a work in progress.
28$!
29$! Copyright (C) John Malmberg
30$!
31$! Permission to use, copy, modify, and/or distribute this software for any
32$! purpose with or without fee is hereby granted, provided that the above
33$! copyright notice and this permission notice appear in all copies.
34$!
35$! THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
36$! WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
37$! MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
38$! ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
39$! WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
40$! ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
41$! OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
42$!
43$! SPDX-License-Identifier: ISC
44$!
45$!============================================================================
46$!
47$ss_normal = 1
48$ss_abort = 44
49$ss_control_y = 1556
50$status = ss_normal
51$on control_y then goto control_y
52$on warning then goto general_error
53$!on warning then set ver
54$!
55$! Some information for writing timestamps to created files
56$!----------------------------------------------------------
57$my_proc = f$environment("PROCEDURE")
58$my_proc_file = f$parse(my_proc,,,"NAME") + f$parse(my_proc,,,"TYPE")
59$tab[0,8] = 9
60$datetime = f$element(0,".",f$cvtime(,"ABSOLUTE","DATETIME"))
61$username = f$edit(f$getjpi("","USERNAME"),"TRIM")
62$!
63$pid = f$getjpi("","PID")
64$tfile1 = "SYS$SCRATCH:config_h_temp1_''pid'.TEMP"
65$dchfile = "SYS$SCRATCH:config_h_decc_''pid'.TEMP"
66$starhfile = "SYS$SCRATCH:config_h_starlet_''pid'.TEMP"
67$configure_script = "SYS$SCRATCH:configure_script_''pid'.TEMP"
68$!
69$!  Get the system type
70$!----------------------
71$arch_type = f$getsyi("arch_type")
72$!
73$! Does config_vms.h exist?
74$!-------------------------
75$update_config_vms = 0
76$file = f$search("sys$disk:[]config_vms.h")
77$if file .nes. ""
78$then
79$   write sys$output "Found existing custom file ''file'."
80$else
81$   update_config_vms = 1
82$   write sys$output "Creating new sys$disk:[]config_vms.h for you."
83$   gosub write_config_vms
84$endif
85$!
86$!
87$! On some platforms, DCL search has problems with searching a file
88$! on a NFS mounted volume.  So copy it to sys$scratch:
89$!
90$if f$search(configure_script) .nes. "" then delete 'configure_script';*
91$copy sys$disk:[]configure 'configure_script'
92$!
93$ssl_header_dir = "OPENSSL:"
94$if f$trnlnm("OPENSSL") .eqs. ""
95$then
96$    ssl_header_dir = "SSL$INCLUDE:"
97$endif
98$!
99$!
100$! Write out the header
101$!----------------------
102$gosub write_config_h_header
103$!
104$!
105$!
106$! config.h.in could have at least five different names depending
107$! on how it was transferred to OpenVMS
108$!------------------------------------------------------------------
109$if p1 .nes. ""
110$then
111$   cfile = p1
112$else
113$   cfile = f$search("sys$disk:[]config.h.in")
114$   if cfile .eqs. ""
115$   then
116$       cfile = f$search("sys$disk:[]config.h_in")
117$       if cfile .eqs. ""
118$       then
119$           cfile = f$search("sys$disk:[]configh.in")
120$           if cfile .eqs. ""
121$           then
122$               cfile = f$search("sys$disk:[]config__2eh.in")
123$               if cfile .eqs. ""
124$               then
125$                   cfile = f$search("sys$disk:[]config.h__2ein")
126$               endif
127$           endif
128$       endif
129$   endif
130$endif
131$if f$trnlnm("PRJ_INCLUDE") .nes. ""
132$then
133$   cfile = f$search("PRJ_INCLUDE:config.h.in")
134$   if cfile .eqs. ""
135$   then
136$       cfile = f$search("PRJ_INCLUDE:config.h_in")
137$       if cfile .eqs. ""
138$       then
139$           cfile = f$search("PRJ_INCLUDE:config__2eh.in")
140$           if cfile .eqs. ""
141$           then
142$               cfile = f$search("PRJ_INCLUDE:config__2eh.in")
143$               if cfile .eqs. ""
144$               then
145$                   cfile = f$search("PRJ_INCLUDE:config.h__2ein")
146$               endif
147$           endif
148$       endif
149$    endif
150$endif
151$if cfile .eqs. ""
152$then
153$   write sys$output "Can not find sys$disk:config.h.in"
154$   line_out = "Looked for config.h.in, config.h_in, configh.in, "
155$   line_out = line_out + "config__2eh.in, config.h__2ein"
156$   write/symbol sys$output line_out
157$   if f$trnlnm("PRJ_INCLUDE") .nes. ""
158$   then
159$       write sys$output "Also looked in PRJ_INCLUDE: for these files."
160$   endif
161$!
162$   write tf ""
163$   write tf -
164        "   /* Could not find sys$disk:config.h.in                           */"
165$   write tf -
166        "  /*  Looked also for config.h_in, configh.in, config__2eh.in,     */"
167$   write tf -
168        " /*   config.h__2ein                                              */"
169$   if f$trnlnm("PRJ_INCLUDE") .nes. ""
170$   then
171$       write tf -
172        " /* Also looked in PRJ_INCLUDE: for these files.                 */"
173$   endif
174$   write tf -
175        "/*--------------------------------------------------------------*/
176$   write tf ""
177$   goto write_tail
178$endif
179$!
180$!
181$! Locate the DECC libraries in use
182$!-----------------------------------
183$decc_rtldef = f$parse("decc$rtldef","sys$library:.tlb;0")
184$decc_starletdef = f$parse("sys$starlet_c","sys$library:.tlb;0")
185$decc_shr = f$parse("decc$shr","sys$share:.exe;0")
186$!
187$! Dump the DECC header names into a file
188$!----------------------------------------
189$if f$search(dchfile) .nes. "" then delete 'dchfile';*
190$if f$search(tfile1) .nes. "" then delete 'tfile1';*
191$define/user sys$output 'tfile1'
192$library/list 'decc_rtldef'
193$open/read/error=rtldef_loop1_end tf1 'tfile1'
194$open/write/error=rtldef_loop1_end tf2 'dchfile'
195$rtldef_loop1:
196$   read/end=rtldef_loop1_end tf1 line_in
197$   line_in = f$edit(line_in,"TRIM,COMPRESS")
198$   key1 = f$element(0," ",line_in)
199$   key2 = f$element(1," ",line_in)
200$   if key1 .eqs. " " .or. key1 .eqs. "" then goto rtldef_loop1
201$   if key2 .nes. " " .and. key2 .nes. "" then goto rtldef_loop1
202$   write tf2 "|",key1,"|"
203$   goto rtldef_loop1
204$rtldef_loop1_end:
205$if f$trnlnm("tf1","lnm$process",,"SUPERVISOR") .nes. "" then close tf1
206$if f$trnlnm("tf2","lnm$process",,"SUPERVISOR") .nes. "" then close tf2
207$if f$search(tfile1) .nes. "" then delete 'tfile1';*
208$!
209$! Dump the STARLET header names into a file
210$!----------------------------------------
211$if f$search(starhfile) .nes. "" then delete 'starhfile';*
212$if f$search(tfile1) .nes. "" then delete 'tfile1';*
213$define/user sys$output 'tfile1'
214$library/list 'decc_starletdef'
215$open/read/error=stardef_loop1_end tf1 'tfile1'
216$open/write/error=stardef_loop1_end tf2 'starhfile'
217$stardef_loop1:
218$   read/end=stardef_loop1_end tf1 line_in
219$   line_in = f$edit(line_in,"TRIM,COMPRESS")
220$   key1 = f$element(0," ",line_in)
221$   key2 = f$element(1," ",line_in)
222$   if key1 .eqs. " " .or. key1 .eqs. "" then goto stardef_loop1
223$   if key2 .nes. " " .and. key2 .nes. "" then goto stardef_loop1
224$   write tf2 "|",key1,"|"
225$   goto stardef_loop1
226$stardef_loop1_end:
227$if f$trnlnm("tf1","lnm$process",,"SUPERVISOR") .nes. "" then close tf1
228$if f$trnlnm("tf2","lnm$process",,"SUPERVISOR") .nes. "" then close tf2
229$if f$search(tfile1) .nes. "" then delete 'tfile1';*
230$!
231$!
232$! Now calculate what should be in the file from reading
233$! config.h.in and CONFIGURE.
234$!---------------------------------------------------------------
235$open/read inf 'cfile'
236$do_comment = 0
237$if_block = 0
238$cfgh_in_loop1:
239$!set nover
240$   read/end=cfgh_in_loop1_end inf line_in
241$   xline = f$edit(line_in,"TRIM,COMPRESS")
242$!
243$!  Blank line handling
244$!---------------------
245$   if xline .eqs. ""
246$   then
247$       write tf ""
248$       goto cfgh_in_loop1
249$   endif
250$   xlen = f$length(xline)
251$   key = f$extract(0,2,xline)
252$!
253$!  deal with comments by copying exactly
254$!-----------------------------------------
255$   if (do_comment .eq. 1) .or. (key .eqs. "/*")
256$   then
257$       do_comment = 1
258$       write tf line_in
259$       key = f$extract(xlen - 2, 2, xline)
260$       if key .eqs. "*/" then do_comment = 0
261$       goto cfgh_in_loop1
262$   endif
263$!
264$!  Some quick parsing
265$!----------------------
266$   keyif = f$extract(0,3,xline)
267$   key1 = f$element(0," ",xline)
268$   key2 = f$element(1," ",xline)
269$   key2a = f$element(0,"_",key2)
270$   key2b = f$element(1,"_",key2)
271$   key2_len = f$length(key2)
272$   key2_h = f$extract(key2_len - 2, 2, key2)
273$   key2_t = f$extract(key2_len - 5, 5, key2)
274$   if key2_t .eqs. "_TYPE" then key2_h = "_T"
275$   key64 = 0
276$   if f$locate("64", xline) .lt. xlen then key64 = 1
277$!
278$!write sys$output "xline = ''xline'"
279$!
280$!  Comment out this section of the ifblock
281$!-----------------------------------------
282$   if if_block .ge. 3
283$   then
284$       write tf "/* ", xline, " */"
285$       if keyif .eqs. "#en" then if_block = 0
286$       goto cfgh_in_loop1
287$   endif
288$!
289$!  Handle the end of an ifblock
290$!-------------------------------
291$   if keyif .eqs. "#en"
292$   then
293$       write tf xline
294$       if_block = 0
295$       goto cfgh_in_loop1
296$   endif
297$!
298$   if key1 .eqs. "#ifndef"
299$   then
300$!      Manual check for _ALL_SOURCE on AIX error
301$!-----------------------------------------------
302$       if key2 .eqs. "_ALL_SOURCE"
303$       then
304$          write tf "/* ", xline, " */"
305$!
306$!         Ignore the rest of the block
307$!--------------------------------------
308$          if_block = 3
309$          goto cfgh_in_loop1
310$       endif
311$   endif
312$!
313$!
314$!  Default action for an #if/#else/#endif
315$!------------------------------------------
316$   if keyif .eqs. "#if" .or. keyif .eqs. "#el"
317$   then
318$       if_block = 1
319$       write tf xline
320$       goto cfgh_in_loop1
321$   endif
322$!
323$!
324$!  Process "normal?" stuff
325$!---------------------------
326$   if key1 .eqs. "#undef"
327$   then
328$       key2c = f$element(2, "_", key2)
329$       if (key2c .eqs. "_") .or. (key2c .eqs. "H") then key2c = ""
330$       key2d = f$element(3, "_", key2)
331$       if (key2d .eqs. "_") .or. (key2d .eqs. "H") then key2d = ""
332$       key2e = f$element(4, "_", key2)
333$       if (key2e .eqs. "_") .or. (key2e .eqs. "H") then key2e = ""
334$       if key2d .eqs. "T"
335$       then
336$           if key2e .eqs. "TYPE"
337$           then
338$               key2_h = "_T"
339$               key2d = ""
340$           endif
341$       endif
342$!
343$       double_under = 0
344$!
345$!      Process FCNTL directives
346$!-------------------------------------
347$       if (key2b .eqs. "FCNTL") .and. (key2c .eqs. "O") .and. -
348           (key2d .eqs. "NONBLOCK")
349$       then
350$           write tf "#ifndef ''key2'"
351$           write tf "#define ''key2' 1"
352$           write tf "#endif"
353$           goto cfgh_in_loop1
354$       endif
355$!
356$!      Process GETADDRINFO directives
357$!-------------------------------------
358$       if key2 .eqs. "GETADDRINFO_THREADSAFE"
359$       then
360$           write tf "#ifndef ''key2'"
361$           write tf "#define ''key2' 1"
362$           write tf "#endif"
363$           goto cfgh_in_loop1
364$       endif
365$!
366$!      Process IOCTL directives
367$!-------------------------------------
368$       if (key2b .eqs. "IOCTL") .and. (key2c .nes. "")
369$       then
370$           if (key2c .eqs. "FIONBIO") .or. (key2c .eqs. "SIOCGIFADDR")
371$           then
372$               write tf "#ifndef ''key2'"
373$               write tf "#define ''key2' 1"
374$               write tf "#endif"
375$               goto cfgh_in_loop1
376$           endif
377$       endif
378$!
379$!
380$!      Manual check for LL on
381$!-----------------------------------------------
382$       if key2 .eqs. "LL"
383$       then
384$          write tf "#ifndef __VAX
385$          write tf "#define HAVE_''key2' 1"
386$          write tf "#endif"
387$          goto cfgh_in_loop1
388$       endif
389$!
390$       if key2 .eqs. "bool_t"
391$       then
392$           write tf "#ifndef ''key2'"
393$           write tf "#define ''key2' short"
394$           write tf "#endif"
395$           goto cfgh_in_loop1
396$       endif
397$!
398$       if key2 .eqs. "bits16_t"
399$       then
400$           write tf "#ifndef ''key2'"
401$           write tf "#define ''key2' short"
402$           write tf "#endif"
403$           goto cfgh_in_loop1
404$       endif
405$!
406$       if key2 .eqs. "u_bits16_t"
407$       then
408$           write tf "#ifndef ''key2'"
409$           write tf "#define ''key2' unsigned short"
410$           write tf "#endif"
411$           goto cfgh_in_loop1
412$       endif
413$!
414$       if key2 .eqs. "bits32_t"
415$       then
416$           write tf "#ifndef ''key2'"
417$           write tf "#define ''key2' int"
418$           write tf "#endif"
419$           goto cfgh_in_loop1
420$       endif
421$!
422$       if key2 .eqs. "u_bits32_t"
423$       then
424$           write tf "#ifndef ''key2'"
425$           write tf "#define ''key2' unsigned int"
426$           write tf "#endif"
427$           goto cfgh_in_loop1
428$       endif
429$!
430$       if key2 .eqs. "intmax_t"
431$       then
432$           write tf "#ifndef ''key2'"
433$           write tf "#ifdef __VAX"
434$           write tf "#define ''key2' long"
435$           write tf "#else"
436$           write tf "#define ''key2' long long"
437$           write tf "#endif"
438$           write tf "#endif"
439$           goto cfgh_in_loop1
440$       endif
441$!
442$       if key2 .eqs. "uintmax_t"
443$       then
444$           write tf "#ifndef ''key2'"
445$           write tf "#ifdef __VAX"
446$           write tf "#define ''key2' unsigned long"
447$           write tf "#else"
448$           write tf "#define ''key2' unsigned long long"
449$           write tf "#endif"
450$           write tf "#endif"
451$           goto cfgh_in_loop1
452$       endif
453$!
454$       if key2 .eqs. "socklen_t"
455$       then
456$           write tf "#ifndef ''key2'"
457$           write tf "#define ''key2' int"
458$           write tf "#endif"
459$           goto cfgh_in_loop1
460$       endif
461$!
462$       if key2 .eqs. "GETGROUPS_T"
463$       then
464$           write tf "#ifndef ''key2'"
465$           write tf "#define ''key2' gid_t"
466$           write tf "#endif"
467$           goto cfgh_in_loop1
468$       endif
469$!
470$       if key2 .eqs. "HAVE_DECL_SYS_SIGLIST"
471$       then
472$           write tf "#ifndef ''key2'"
473$           write tf "#define ''key2' 0"
474$           write tf "#endif"
475$           goto cfgh_in_loop1
476$       endif
477$!
478$       if key2 .eqs. "HAVE_SYS_ERRLIST"
479$       then
480$           write tf "#ifndef ''key2'"
481$           write tf "#define ''key2' 1"
482$           write tf "#endif"
483$           goto cfgh_in_loop1
484$       endif
485$!
486$       if key2 .eqs. "HAVE_STRUCT_DIRENT_D_INO"
487$       then
488$           write tf "#ifndef ''key2'"
489$           write tf "#define ''key2' 1"
490$           write tf "#endif"
491$           goto cfgh_in_loop1
492$       endif
493$!
494$       if key2 .eqs. "HAVE_STRUCT_TIMEVAL"
495$       then
496$           write tf "#ifndef ''key2'"
497$           write tf "#define ''key2' 1"
498$           write tf "#endif"
499$           goto cfgh_in_loop1
500$       endif
501$!
502$!      ! The header files have this information, however
503$!      ! The ioctl() call only works on sockets.
504$!      if key2 .eqs. "FIONREAD_IN_SYS_IOCTL"
505$!      then
506$!          write tf "#ifndef ''key2'"
507$!          write tf "#define ''key2' 1"
508$!          write tf "#endif"
509$!          goto cfgh_in_loop1
510$!      endif
511$!
512$!      ! The header files have this information, however
513$!      ! The ioctl() call only works on sockets.
514$!      if key2 .eqs. "GWINSZ_IN_SYS_IOCTL"
515$!      then
516$!          write tf "#ifndef ''key2'"
517$!          write tf "#define ''key2' 1"
518$!          write tf "#endif"
519$!          goto cfgh_in_loop1
520$!      endif
521$!
522$!      ! The header files have this information, however
523$!      ! The ioctl() call only works on sockets.
524$!      if key2 .eqs. "STRUCT_WINSIZE_IN_SYS_IOCTL"
525$!      then
526$!          write tf "#ifndef ''key2'"
527$!          write tf "#define ''key2' 0"
528$!          write tf "#endif"
529$!          goto cfgh_in_loop1
530$!      endif
531$!
532$       if key2 .eqs. "HAVE_STRUCT_TM_TM_ZONE"
533$       then
534$           write tf "#ifndef ''key2'"
535$           write tf "#define ''key2' 1"
536$           write tf "#endif"
537$           goto cfgh_in_loop1
538$       endif
539$!
540$       if key2 .eqs. "HAVE_TM_ZONE"
541$       then
542$           write tf "#ifndef ''key2'"
543$           write tf "#define ''key2' 1"
544$           write tf "#endif"
545$           goto cfgh_in_loop1
546$       endif
547$!
548$       if key2 .eqs. "HAVE_TIMEVAL"
549$       then
550$           write tf "#ifndef ''key2'"
551$           write tf "#define ''key2' 1"
552$           write tf "#endif"
553$           goto cfgh_in_loop1
554$       endif
555$!
556$       if key2 .eqs. "WEXITSTATUS_OFFSET"
557$       then
558$           write tf "#ifndef ''key2'"
559$           write tf "#define ''key2' 2"
560$           write tf "#endif"
561$           goto cfgh_in_loop1
562$       endif
563$!
564$       if key2 .eqs. "HAVE_GETPW_DECLS"
565$       then
566$           write tf "#ifndef ''key2'"
567$           write tf "#define ''key2' 1"
568$           write tf "#endif"
569$           goto cfgh_in_loop1
570$       endif
571$!
572$       if key2 .eqs. "HAVE_DECL_CONFSTR"
573$       then
574$           write tf "#ifndef ''key2'"
575$           write tf "#define ''key2' 1"
576$           write tf "#endif"
577$           goto cfgh_in_loop1
578$       endif
579$!
580$       if key2 .eqs. "HAVE_DECL_PRINTF"
581$       then
582$           write tf "#ifndef ''key2'"
583$           write tf "#define ''key2' 1"
584$           write tf "#endif"
585$           goto cfgh_in_loop1
586$       endif
587$!
588$       if key2 .eqs. "HAVE_DECL_SBRK"
589$       then
590$           write tf "#ifndef ''key2'"
591$           write tf "#define ''key2' 1"
592$           write tf "#endif"
593$           goto cfgh_in_loop1
594$       endif
595$!
596$       if key2 .eqs. "HAVE_DECL_STRSIGNAL"
597$       then
598$           write tf "#ifndef ''key2'"
599$           write tf "#define ''key2' 0"
600$           write tf "#endif"
601$           goto cfgh_in_loop1
602$       endif
603$!
604$       if key2a .eqs. "HAVE_DECL_STRTOLD"
605$       then
606$           write tf "#ifndef ''key2'"
607$           write tf "#define ''key2' 0"
608$           write tf "#endif"
609$           goto cfgh_in_loop1
610$       endif
611$!
612$       if key2 .eqs. "HAVE_DECL_STRTOIMAX"
613$       then
614$           write tf "#ifndef ''key2'"
615$           write tf "#define ''key2' 0"
616$           write tf "#endif"
617$           goto cfgh_in_loop1
618$       endif
619$!
620$       if key2 .eqs. "HAVE_DECL_STRTOL"
621$       then
622$           write tf "#ifndef ''key2'"
623$           write tf "#define ''key2' 1"
624$           write tf "#endif"
625$           goto cfgh_in_loop1
626$       endif
627$!
628$       if key2 .eqs. "HAVE_DECL_STRTOLL"
629$       then
630$           write tf "#ifndef ''key2'"
631$           write tf "#define ''key2' 1"
632$           write tf "#endif"
633$           goto cfgh_in_loop1
634$       endif
635$!
636$       if key2 .eqs. "HAVE_DECL_STRTOUL"
637$       then
638$           write tf "#ifndef ''key2'"
639$           write tf "#define ''key2' 1"
640$           write tf "#endif"
641$           goto cfgh_in_loop1
642$       endif
643$!
644$       if key2 .eqs. "HAVE_DECL_STRTOULL"
645$       then
646$           write tf "#ifndef ''key2'"
647$           write tf "#define ''key2' 1"
648$           write tf "#endif"
649$           goto cfgh_in_loop1
650$       endif
651$!
652$       if key2 .eqs. "HAVE_DECL_STRTOUMAX"
653$       then
654$           write tf "#ifndef ''key2'"
655$           write tf "#define ''key2' 0"
656$           write tf "#endif"
657$           goto cfgh_in_loop1
658$       endif
659$!
660$       if key2 .eqs. "GETPGRP_VOID"
661$       then
662$           write tf "#ifndef ''key2'"
663$           write tf "#define ''key2' 1"
664$           write tf "#endif"
665$           goto cfgh_in_loop1
666$       endif
667$!
668$       if key2 .eqs. "NAMED_PIPES_MISSING"
669$       then
670$           write tf "#ifndef ''key2'"
671$           write tf "#define ''key2' 1"
672$           write tf "#endif"
673$           goto cfgh_in_loop1
674$       endif
675$!
676$       if key2 .eqs. "OPENDIR_NOT_ROBUST"
677$       then
678$           write tf "#ifndef ''key2'"
679$           write tf "#define ''key2' 1"
680$           write tf "#endif"
681$           goto cfgh_in_loop1
682$       endif
683$!
684$       if key2 .eqs. "PGRP_PIPE"
685$       then
686$           write tf "#ifndef ''key2'"
687$           write tf "#define ''key2' 1"
688$           write tf "#endif"
689$           goto cfgh_in_loop1
690$       endif
691$!
692$       if key2 .eqs. "CAN_REDEFINE_GETENV"
693$       then
694$           write tf "#ifndef ''key2'"
695$           write tf "#define ''key2' 1"
696$           write tf "#endif"
697$           goto cfgh_in_loop1
698$       endif
699$!
700$       if key2 .eqs. "HAVE_PRINTF_A_FORMAT"
701$       then
702$           write tf "#ifndef ''key2'"
703$           write tf "#define ''key2' 1"
704$           write tf "#endif"
705$           goto cfgh_in_loop1
706$       endif
707$!
708$       if key2 .eqs. "CTYPE_NON_ASCII"
709$       then
710$           write tf "#ifndef ''key2'"
711$           write tf "#define ''key2' 1"
712$           write tf "#endif"
713$           goto cfgh_in_loop1
714$       endif
715$!
716$       if key2 .eqs. "HAVE_LANGINFO_CODESET"
717$       then
718$           write tf "#ifndef ''key2'"
719$           write tf "#define ''key2' 0"
720$           write tf "#endif"
721$           goto cfgh_in_loop1
722$       endif
723$!
724$!      This wants execve() to do this automagically to pass.
725$!      if key2 .eqs. "HAVE_HASH_BANG_EXEC"
726$!      then
727$!          write tf "#ifndef ''key2'"
728$!          write tf "#define ''key2' 1"
729$!          write tf "#endif"
730$!          goto cfgh_in_loop1
731$!      endif
732$!
733$       if key2 .eqs. "ICONV_CONST"
734$       then
735$           write tf "#ifndef ''key2'"
736$           write tf "#define ''key2'"
737$           write tf "#endif"
738$           goto cfgh_in_loop1
739$       endif
740$!
741$       if key2 .eqs. "VOID_SIGHANDLER"
742$       then
743$           write tf "#ifndef ''key2'"
744$           write tf "#define ''key2' 1"
745$           write tf "#endif"
746$           goto cfgh_in_loop1
747$       endif
748$!
749$       if key2 .eqs. "HAVE_POSIX_SIGNALS"
750$       then
751$           write tf "#ifndef ''key2'"
752$           write tf "#define ''key2' 1"
753$           write tf "#endif"
754$           goto cfgh_in_loop1
755$       endif
756$!
757$       if key2 .eqs. "UNUSABLE_RT_SIGNALS"
758$       then
759$           write tf "#ifndef ''key2'"
760$           write tf "#define ''key2' 1"
761$           write tf "#endif"
762$           goto cfgh_in_loop1
763$       endif
764$!
765$       if key2a .eqs. "HAVE_DECL_FPURGE"
766$       then
767$           write tf "#ifndef ''key2a'"
768$           write tf "#define ''key2a' 1"
769$           write tf "#endif"
770$           goto cfgh_in_loop1
771$       endif
772$!
773$       if key2 .eqs. "HAVE_DECL_SETREGID"
774$       then
775$           write tf "#ifndef ''key2'"
776$           write tf "#define ''key2' 1"
777$           write tf "#endif"
778$           goto cfgh_in_loop1
779$       endif
780$!
781$       if key2 .eqs. "HAVE_POSIX_SIGSETJMP"
782$       then
783$           write tf "#ifndef ''key2'"
784$           write tf "#define ''key2' 1"
785$           write tf "#endif"
786$           goto cfgh_in_loop1
787$       endif
788$!
789$       if key2b .eqs. "RAND" .and. key2c .nes. "" .and. key2d .eqs. ""
790$       then
791$           if (key2c .eqs. "EGD") .or. -
792               (key2c .eqs. "STATUS") .or. -
793               (key2c .eqs. "SCREEN")
794$           then
795$               if f$search("''ssl_header_dir'rand.h") .nes. ""
796$               then
797$                   write tf "#ifndef ''key2'"
798$                   write tf "#define ''key2' 1"
799$                   write tf "#endif"
800$               else
801$                   write tf "/* #undef ''key2' */"
802$               endif
803$           endif
804$       endif
805$!
806$       if key2 .eqs. "STRCOLL_BROKEN"
807$       then
808$           write tf "#ifndef ''key2'"
809$           write tf "#define ''key2' 1"
810$           write tf "#endif"
811$           goto cfgh_in_loop1
812$       endif
813$!
814$       if key2 .eqs. "DUP_BROKEN"
815$       then
816$           write tf "#ifndef ''key2'"
817$           write tf "#define ''key2' 1"
818$           write tf "#endif"
819$           goto cfgh_in_loop1
820$       endif
821$!
822$!      This is for a test that getcwd(0,0) works.
823$!      It does not on VMS.
824$!--------------------------
825$       if key2 .eqs. "GETCWD_BROKEN"
826$       then
827$           write sys$output ""
828$           write sys$output -
829  "%CONFIG_H-I-NONPORT, ''key2' being tested for!"
830$                  write sys$output -
831 "-CONFIG_H-I-GETCWD, GETCWD(0,0) does not work on VMS."
832$                  write sys$output -
833 "-CONFIG_H-I-GETCWD2, Work around hack probably required."
834$                  write sys$output -
835 "-CONFIG_H-I-REVIEW, Manual Code review required!"
836$                   if update_config_vms
837$                   then
838$                       open/append tfcv sys$disk:[]config_vms.h
839$                       write tfcv ""
840$                       write tfcv -
841                "/* Check config.h for use of ''key2' settings */"
842$                       write tfcv ""
843$                       close tfcv
844$                   endif
845$
846$           goto cfgh_in_loop1
847$       endif
848$!
849$       if (key2a .eqs. "HAVE") .or. (key2a .eqs. "STAT") .or. -
850           (key2 .eqs. "USE_IPV6") .or. (key2b .eqs. "LDAP")
851$       then
852$!
853$!          Process extra underscores
854$!------------------------------------
855$           if f$locate("HAVE___", key2) .lt. key2_len
856$           then
857$               key2b = "__" + key2d
858$               key2d = ""
859$               double_under = 1
860$           else
861$               if f$locate("HAVE__", key2) .lt. key2_len
862$               then
863$                   key2b = "_" + key2c
864$                   key2c = ""
865$                   double_under = 1
866$               endif
867$           endif
868$!
869$           if (key2_h .eqs. "_H") .or. (key2 .eqs. "USE_IPV6") .or. -
870               (key2b .eqs. "LDAP")
871$           then
872$!
873$!              Looking for a header file
874$!---------------------------------------
875$               headf = key2b
876$               if key2c .nes. "" then headf = headf + "_" + key2c
877$               if key2d .nes. "" then headf = headf + "_" + key2d
878$!
879$!                 (key2b .eqs. "READLINE")
880$!
881$!              Some special parsing
882$!------------------------------------------
883$               if (key2b .eqs. "SYS") .or. (key2b .eqs. "ARPA") .or. -
884                   (key2b .eqs. "NET") .or. (key2b .eqs. "NETINET")
885$               then
886$                   if key2c .nes. ""
887$                   then
888$                       headf = key2c
889$                       if key2d .nes. "" then headf = key2c + "_" + key2d
890$                   endif
891$               endif
892$!
893$!              And of course what's life with out some special cases
894$!--------------------------------------------------------------------
895$               if key2 .eqs. "USE_IPV6"
896$               then
897$                   headf = "in6"
898$               endif
899$!
900$               if key2b .eqs. "LDAP"
901$               then
902$                   if (key2 .eqs. "HAVE_LDAP_SSL") .or. -
903                       (key2 .eqs. "HAVE_LDAP_URL_PARSE")
904$                   then
905$                       headf = "ldap"
906$                   endif
907$               endif
908$!
909$!
910$               if key2b .eqs. "FILE"
911$               then
912$                  write sys$output ""
913$                  write sys$output -
914  "%CONFIG_H-I-NONPORT, ''key2' being asked for!"
915$                  write sys$output -
916 "-CONFIG_H-I-FILE_OLD, file.h will not be configured as is obsolete!"
917$                  write sys$output -
918 "-CONFIG_H_I-FCNTL_NEW, "Expecting fcntl.h to be configured instead!"
919$                  write sys$output -
920 "-CONFIG_H_I-FCNTL_CHK, "Unable to verify at this time!"
921$                  write sys$output -
922 "-CONFIG_H-I-REVIEW, Manual Code review required!"
923$!
924$                   if update_config_vms
925$                   then
926$                       open/append tfcv sys$disk:[]config_vms.h
927$                       write tfcv ""
928$                       write tfcv -
929                "/* Check config.h for use of fcntl.h instead of file.h */"
930$                       write tfcv ""
931$                       close tfcv
932$                   endif
933$               endif
934$!
935$!              Now look it up in the DEC C RTL
936$!---------------------------------------------
937$               define/user sys$output nl:
938$               define/user sys$error nl:
939$               search/output=nl: 'dchfile' |'headf'|/exact
940$               if '$severity' .eq. 1
941$               then
942$                   if key64 then write tf "#ifndef __VAX"
943$                   write tf "#ifndef ''key2'"
944$                   write tf "#define ''key2' 1"
945$if p2 .nes. "" then write sys$output "''dchfile' - #define ''key2' 1"
946$                   write tf "#endif"
947$                   if key64 then write tf "#endif"
948$set nover
949$                   goto cfgh_in_loop1
950$               endif
951$!
952$!
953$!              Now look it up in the DEC C STARLET_C
954$!---------------------------------------------
955$               define/user sys$output nl:
956$               define/user sys$error nl:
957$               search/output=nl: 'starhfile' |'headf'|/exact
958$               if '$severity' .eq. 1
959$               then
960$                   if key64 then write tf "#ifndef __VAX"
961$                   write tf "#ifndef ''key2'"
962$                   write tf "#define ''key2' 1"
963$if p2 .nes. "" then write sys$output "''starfile' - #define ''key2' 1"
964$                   write tf "#endif"
965$                   if key64 then write tf "#endif"
966$set nover
967$                   goto cfgh_in_loop1
968$               endif
969$!
970$!              Now look for OPENSSL headers
971$!---------------------------------------------------------
972$               if key2b .eqs. "OPENSSL"
973$               then
974$                   headf = headf - "OPENSSL_"
975$                   header = f$search("''ssl_header_dir'''headf'.h")
976$                   if header .nes. ""
977$                   then
978$                       write tf "#ifndef ''key2'"
979$                       write tf "#define ''key2' 1"
980$                       write tf "#endif"
981$set nover
982$                       goto cfgh_in_loop1
983$                   endif
984$               endif
985$!
986$!              Now look for Kerberos
987$!------------------------------------------------------------
988$               if key2b .eqs. "GSSAPI"
989$               then
990$                   header_dir = "sys$sysroot:[kerberos.include]"
991$                   headf = headf - "GSSAPI_"
992$                   header = f$search("''header_dir'''headf'.h")
993$                   if header .nes. ""
994$                   then
995$                       write tf "#ifndef ''key2'"
996$                       write tf "#define ''key2' 1"
997$                       write tf "#endif"
998$set nover
999$                       goto cfgh_in_loop1
1000$                   endif
1001$               endif
1002$!
1003$set nover
1004$           else
1005$!
1006$!              Looking for a routine or a symbol
1007$!------------------------------------------------
1008$               if key2c .eqs. "MACRO"
1009$               then
1010$                   if (key2b .eqs. "FILE") .or. (key2b .eqs. "DATE") -
1011                        .or. (key2b .eqs. "LINE") .or. (key2b .eqs. "TIME")
1012$                   then
1013$                       write tf "#ifndef HAVE_''key2b'"
1014$                       write tf "#define HAVE_''key2b' 1"
1015$                       write tf "#endif"
1016$                   endif
1017$                   goto cfgh_in_loop1
1018$               endif
1019$!
1020$!              Special false tests
1021$!-------------------------------------
1022$               if double_under
1023$               then
1024$                   if key2b .eqs. "_FCNTL" .or. key2b .eqs. "__FCNTL"
1025$                   then
1026$                       write tf "/* #undef HAVE_''key2b' */"
1027$                       goto cfgh_in_loop1
1028$                   endif
1029$!
1030$                   if key2b .eqs. "_STAT" .or. key2b .eqs. "__STAT"
1031$                   then
1032$                       write tf "/* #undef HAVE_''key2b' */"
1033$                       goto cfgh_in_loop1
1034$                   endif
1035$!
1036$                   if key2b .eqs. "_READ" .or. key2b .eqs. "__READ"
1037$                   then
1038$                       write tf "/* #undef HAVE_''key2b' */"
1039$                       goto cfgh_in_loop1
1040$                   endif
1041$               endif
1042$!
1043$               keysym = key2b
1044$               if key2c .nes. "" then keysym = keysym + "_" + key2c
1045$               if key2d .nes. "" then keysym = keysym + "_" + key2d
1046$               if key2e .nes. "" then keysym = keysym + "_" + key2e
1047$!
1048$!
1049$!              Stat structure members
1050$!-------------------------------------
1051$               if key2b .eqs. "STRUCT"
1052$               then
1053$                   if key2c .eqs. "STAT" .and (key2d .nes. "")
1054$                   then
1055$                       key2b = key2b + "_" + key2c + "_" + key2d
1056$                       key2c = key2e
1057$                       key2d = ""
1058$                       key2e = ""
1059$                   endif
1060$               endif
1061$               if (key2b .eqs. "ST") .or. (key2b .eqs. "STRUCT_STAT_ST")
1062$               then
1063$                   keysym = "ST" + "_" + key2c
1064$                   keysym = f$edit(keysym,"LOWERCASE")
1065$               endif
1066$               if key2a .eqs. "STAT"
1067$               then
1068$                   if (f$locate("STATVFS", key2b) .eq. 0) .and. key2c .eqs. ""
1069$                   then
1070$                       keysym = f$edit(key2b, "LOWERCASE")
1071$                   endif
1072$!$                 if (key2b .eqs. "STATVFS" .or. key2b .eqs. "STATFS2" -
1073$!                      .or. key2b .eqs. "STATFS3") .and. key2c .nes. ""
1074$!
1075$                   if (key2b .eqs. "STATVFS") .and. key2c .nes. ""
1076$                   then
1077$!                      Should really verify that the structure
1078$!                      named by key2b actually exists first.
1079$!------------------------------------------------------------
1080$!
1081$!                      Statvfs structure members
1082$!-------------------------------------------------
1083$                       keysym = "f_" + f$edit(key2c,"LOWERCASE")
1084$                   endif
1085$               endif
1086$!
1087$!              UTMPX structure members
1088$!--------------------------------------
1089$               if key2b .eqs. "UT" .and. key2c .eqs. "UT"
1090$               then
1091$                   keysym = "ut_" + f$edit(key2d,"LOWERCASE")
1092$               endif
1093$!
1094$               if f$locate("MMAP",key2) .lt. key2_len
1095$               then
1096$                  write sys$output ""
1097$                  write sys$output -
1098  "%CONFIG_H-I-NONPORT, ''key2' being asked for!"
1099$                  write sys$output -
1100 "-CONFIG_H-I-MMAP, MMAP operations only work on STREAM and BINARY files!"
1101$                  write sys$output -
1102 "-CONFIG_H-I-REVIEW, Manual Code review required!"
1103$                   if update_config_vms
1104$                   then
1105$                       open/append tfcv sys$disk:[]config_vms.h
1106$                       write tfcv ""
1107$                       write tfcv -
1108                "/* Check config.h for use of ''key2' settings */"
1109$                       write tfcv ""
1110$                       close tfcv
1111$                   endif
1112$               endif
1113$!
1114$!
1115$               if keysym .eqs. "CRYPT"
1116$               then
1117$                  write sys$output ""
1118$                  write sys$output -
1119  "%CONFIG_H-I-NONPORT, ''key2' being asked for!"
1120$                  write sys$output -
1121 "-CONFIG_H-I-CRYPT, CRYPT operations on the VMS SYSUAF may not work!"
1122$                  write sys$output -
1123 "-CONFIG_H-I-REVIEW, Manual Code review required!"
1124$                   if update_config_vms
1125$                   then
1126$                       open/append tfcv sys$disk:[]config_vms.h
1127$                       write tfcv ""
1128$                       write tfcv -
1129                "/* Check config.h for use of ''keysym' */"
1130$                       write tfcv ""
1131$                       close tfcv
1132$                   endif
1133$               endif
1134$!
1135$!
1136$               if keysym .eqs. "EXECL"
1137$               then
1138$                  write sys$output ""
1139$                  write sys$output -
1140  "%CONFIG_H-I-NONPORT, ''key2' being asked for!"
1141$                  write sys$output -
1142 "-CONFIG_H-I-EXCEL, EXECL configured, Will probably not work."
1143$                  write sys$output -
1144 "-CONFIG_H-I-REVIEW, Manual Code review required!"
1145$                   if update_config_vms
1146$                   then
1147$                       open/append tfcv sys$disk:[]config_vms.h
1148$                       write tfcv ""
1149$                       write tfcv -
1150                "/* Check config.h for use of ''keysym' */"
1151$                       write tfcv ""
1152$                       close tfcv
1153$                   endif
1154$               endif
1155$!
1156$!
1157$!              Process if cpp supports ANSI-C stringizing '#' operator
1158$!-----------------------------------------------------------------------
1159$               if keysym .eqs. "STRINGIZE"
1160$               then
1161$                   write tf "#ifndef HAVE_STRINGIZE"
1162$                   write tf "#define HAVE_STRINGSIZE 1"
1163$                   write tf "#endif"
1164$                   goto cfgh_in_loop1
1165$               endif
1166$!
1167$               if keysym .eqs. "VOLATILE"
1168$               then
1169$                   write tf "#ifndef HAVE_VOLATILE"
1170$                   write tf "#define HAVE_VOLATILE 1"
1171$                   write tf "#endif"
1172$                   goto cfgh_in_loop1
1173$               endif
1174$!
1175$               if keysym .eqs. "ALLOCA"
1176$               then
1177$                   write tf "#ifndef HAVE_ALLOCA"
1178$                   write tf "#define HAVE_ALLOCA 1"
1179$                   write tf "#endif"
1180$                   goto cfgh_in_loop1
1181$               endif
1182$!
1183$               if keysym .eqs. "ERRNO_DECL"
1184$               then
1185$                   write tf "#ifndef HAVE_ERRNO_DECL"
1186$                   write tf "#define HAVE_ERRNO_DECL 1"
1187$                   write tf "#endif"
1188$                   goto cfgh_in_loop1
1189$               endif
1190$!
1191$               if keysym .eqs. "LONGLONG"
1192$               then
1193$                   write tf "#ifndef __VAX"
1194$                   write tf "#pragma message disable longlongtype"
1195$                   write tf "#ifndef HAVE_LONGLONG"
1196$                   write tf "#define HAVE_LONGLONG 1"
1197$                   write tf "#endif"
1198$                   write tf "#endif"
1199$                   goto cfgh_in_loop1
1200$               endif
1201$!
1202$!              May need to test compiler version
1203$!-----------------------------------------------
1204$               if keysym .eqs. "LONG_LONG"
1205$               then
1206$                   write tf "#ifndef __VAX"
1207$                   write tf "#pragma message disable longlongtype"
1208$                   write tf "#ifndef HAVE_LONG_LONG"
1209$                   write tf "#define HAVE_LONG_LONG 1"
1210$                   write tf "#endif"
1211$                   write tf "#endif"
1212$                   goto cfgh_in_loop1
1213$               endif
1214$!
1215$!              May need to test compiler version
1216$!-----------------------------------------------
1217$               if keysym .eqs. "UNSIGNED_LONG_LONG"
1218$               then
1219$                   write tf "#ifndef __VAX"
1220$                   write tf "#pragma message disable longlongtype"
1221$                   write tf "#ifndef HAVE_UNSIGNED_LONG_LONG"
1222$                   write tf "#define HAVE_UNSIGNED_LONG_LONG 1"
1223$                   write tf "#endif"
1224$                   write tf "#endif"
1225$                   goto cfgh_in_loop1
1226$               endif
1227$!
1228$!              May need to test compiler version
1229$!-----------------------------------------------
1230$               if keysym .eqs. "UNSIGNED_LONG_LONG_INT"
1231$               then
1232$                   write tf "#ifndef __VAX"
1233$                   write tf "#pragma message disable longlongtype"
1234$                   write tf "#ifndef HAVE_UNSIGNED_LONG_LONG_INT"
1235$                   write tf "#define HAVE_UNSIGNED_LONG_LONG_INT 1"
1236$                   write tf "#endif"
1237$                   write tf "#endif"
1238$                   goto cfgh_in_loop1
1239$               endif
1240$!
1241$!              May need to test compiler version
1242$!-----------------------------------------------
1243$               if keysym .eqs. "LONG_DOUBLE"
1244$               then
1245$                   write tf "#ifndef __VAX"
1246$                   write tf "#pragma message disable longlongtype"
1247$                   write tf "#ifndef HAVE_LONG_DOUBLE"
1248$                   write tf "#define HAVE_LONG_DOUBLE 1"
1249$                   write tf "#endif"
1250$                   write tf "#endif"
1251$                   goto cfgh_in_loop1
1252$               endif
1253$!
1254$               if keysym .eqs. "FCNTL_LOCK"
1255$               then
1256$                   write sys$output -
1257  "%CONFIG_H-I-NONPORT, ''key2' being asked for!
1258$                  write sys$output -
1259 "-CONFIG_H-I-REVIEW, Manual Code review required!"
1260$                   goto cfgh_in_loop1
1261$               endif
1262$!
1263$!
1264$!              These libraries are provided by the DEC C RTL
1265$!-------------------------------------------------------------
1266$               if keysym .eqs. "LIBINET" .or. keysym .eqs. "LIBSOCKET"
1267$               then
1268$                   write tf "#ifndef HAVE_''keysym'"
1269$                   write tf "#define HAVE_''keysym' 1"
1270$if p2 .nes. "" then write sys$output "''decc_shr' #define ''keysym' 1"
1271$                   write tf "#endif
1272$                   goto cfgh_in_loop1
1273$               endif
1274$!
1275$               if keysym .eqs. "HERRNO" then keysym = "h_errno"
1276$               if keysym .eqs. "UTIMBUF" then keysym = "utimbuf"
1277$               if key2c .eqs. "STRUCT"
1278$               then
1279$                   keysym = f$edit(key2d,"LOWERCASE")
1280$               else
1281$                   if key2_h .eqs. "_T"
1282$                   then
1283$                       if key2_t .eqs. "_TYPE"
1284$                       then
1285$                           keysym = f$extract(0, key2_len - 5, key2) - "HAVE_"
1286$                       endif
1287$                       keysym = f$edit(keysym,"LOWERCASE")
1288$                   endif
1289$               endif
1290$!
1291$!              Check the DEC C RTL shared image first
1292$!------------------------------------------------------
1293$               if f$search(tfile1) .nes. "" then delete 'tfile1';*
1294$               define/user sys$output nl:
1295$               define/user sys$error nl:
1296$               search/format=nonull/out='tfile1' 'decc_shr' 'keysym'
1297$               if '$severity' .eq. 1
1298$               then
1299$!
1300$!                  Not documented, but from observation
1301$!------------------------------------------------------
1302$                   define/user sys$output nl:
1303$                   define/user sys$error nl:
1304$                   if arch_type .eq. 3
1305$                   then
1306$                       keyterm = "''keysym'<SOH>"
1307$                   else
1308$                       if arch_type .eq. 2
1309$                       then
1310$                           keyterm = "''keysym'<BS>"
1311$                       else
1312$                           keyterm = "''keysym'<STX>"
1313$                       endif
1314$                   endif
1315$                   search/out=nl: 'tfile1' -
1316   "$''keyterm'","$g''keyterm'","$__utc_''keyterm'",-
1317   "$__utctz_''keyterm'","$__bsd44_''keyterm'","$bsd_''keyterm'",-
1318   "$''keysym'decc$","$G''keysym'decc$","$GX''keyterm'"
1319$                   severity = '$severity'
1320$!
1321$!
1322$!                  Of course the 64-bit stuff is different
1323$!---------------------------------------------------------
1324$                   if severity .ne. 1 .and. key64
1325$                   then
1326$                       define/user sys$output nl:
1327$                       define/user sys$error nl:
1328$                       search/out=nl: 'tfile1' "$_''keyterm'"
1329$!                      search/out 'tfile1' "$_''keyterm'"
1330$                       severity = '$severity'
1331$                   endif
1332$!
1333$!                  Unix compatibility routines
1334$!---------------------------------------------
1335$                   if severity .ne. 1
1336$                   then
1337$                       define/user sys$output nl:
1338$                       define/user sys$error nl:
1339$                       search/out=nl: 'tfile1' -
1340    "$__unix_''keyterm'","$__vms_''keyterm'","$_posix_''keyterm'"
1341$                       severity = '$severity'
1342$                   endif
1343$!
1344$!                  Show the result of the search
1345$!------------------------------------------------
1346$                   if 'severity' .eq. 1
1347$                   then
1348$                       if key64 then write tf "#ifndef __VAX"
1349$                       write tf "#ifndef ''key2'"
1350$                       write tf "#define ''key2' 1"
1351$if p2 .nes. "" then write sys$output "''decc_shr' #define ''key2' 1"
1352$                       write tf "#endif"
1353$                       if key64 then write tf "#endif"
1354$                       goto cfgh_in_loop1
1355$                   endif
1356$               endif
1357$               if f$search(tfile1) .nes. "" then delete 'tfile1';*
1358$!
1359$!              Check the DECC Header files next
1360$!----------------------------------------------
1361$               define/user sys$output nl:
1362$               define/user sys$error nl:
1363$               search/out=nl: 'decc_rtldef' -
1364                    "''keysym';", "''keysym'[", "struct ''keysym'"/exact
1365$               severity = '$severity'
1366$               if severity .eq. 1
1367$               then
1368$                   if key64 then write tf "#ifndef __VAX"
1369$                   write tf "#ifndef ''key2'"
1370$                   write tf "#define ''key2' 1"
1371$if p2 .nes. "" then write sys$output "''decc_rtldef' #define ''key2' 1"
1372$                   write tf "#endif"
1373$                   if key64 then write tf "#endif"
1374$                   goto cfgh_in_loop1
1375$               endif
1376$!
1377$!              Check kerberos
1378$!--------------------------------------------
1379$               if f$search("SYS$SYSROOT:[kerberos]include.dir") .nes. ""
1380$               then
1381$                   test_mit = "SYS$SYSROOT:[kerberos.include]gssapi_krb5.h"
1382$                   if (key2 .eqs. "HAVE_GSSAPI")
1383$                   then
1384$                       write tf "#ifndef ''key2'"
1385$                       write tf "#define ''key2' 1"
1386$                       write tf "#endif"
1387$                       goto cfgh_in_loop1
1388$                   endif
1389$               endif
1390$!
1391$           endif
1392$           write tf "/* ", xline, " */"
1393$           goto cfgh_in_loop1
1394$       endif
1395$!
1396$!
1397$!      Process SIZEOF directives found in SAMBA and others
1398$!----------------------------------------------------------
1399$       if key2a .eqs. "SIZEOF"
1400$       then
1401$           if key2b .eqs. "INO" .and. key2_h .eqs. "_T"
1402$           then
1403$               write tf "#ifndef SIZEOF_INO_T"
1404$               write tf "#if !__USING_STD_STAT
1405$               write tf "#define SIZEOF_INO_T 6"
1406$               write tf "#else
1407$               write tf "#define SIZEOF_INO_T 8"
1408$               write tf "#endif
1409$               write tf "#endif"
1410$               goto cfgh_in_loop1
1411$           endif
1412$           if key2b .eqs. "INTMAX" .and. key2_h .eqs. "_T"
1413$           then
1414$               write tf "#ifndef SIZEOF_INTMAX_T"
1415$               write tf "#ifdef __VAX"
1416$               write tf "#define SIZEOF_INTMAX_T 4"
1417$               write tf "#else"
1418$               write tf "#define SIZEOF_INTMAX_T 8"
1419$               write tf "#endif"
1420$               write tf "#endif"
1421$               goto cfgh_in_loop1
1422$           endif
1423$           if key2b .eqs. "OFF" .and. key2_h .eqs. "_T"
1424$           then
1425$               write tf "#ifndef SIZEOF_OFF_T"
1426$               write tf "#if __USE_OFF64_T"
1427$               write tf "#define SIZEOF_OFF_T 8"
1428$               write tf "#else"
1429$               write tf "#define SIZEOF_OFF_T 4"
1430$               write tf "#endif"
1431$               write tf "#endif"
1432$               goto cfgh_in_loop1
1433$           endif
1434$           if key2b .eqs. "CHAR" .and. key2_h .eqs. "_P"
1435$           then
1436$               write tf "#ifndef SIZEOF_CHAR_P"
1437$               write tf "#if __INITIAL_POINTER_SIZE == 64"
1438$               write tf "#define SIZEOF_CHAR_P 8"
1439$               write tf "#else"
1440$               write tf "#define SIZEOF_CHAR_P 4"
1441$               write tf "#endif"
1442$               goto cfgh_in_loop1
1443$           endif
1444$           if key2b .eqs. "VOIDP"
1445$           then
1446$               write tf "#ifndef SIZEOF_VOIDP"
1447$               write tf "#if __INITIAL_POINTER_SIZE == 64"
1448$               write tf "#define SIZEOF_VOIDP 8"
1449$               write tf "#else"
1450$               write tf "#define SIZEOF_VOIDP 4"
1451$               write tf "#endif"
1452$               write tf "#endif"
1453$               goto cfgh_in_loop1
1454$           endif
1455$           if key2b .eqs. "INT"
1456$           then
1457$               write tf "#ifndef SIZEOF_INT"
1458$               write tf "#define SIZEOF_INT 4"
1459$               write tf "#endif"
1460$               goto cfgh_in_loop1
1461$           endif
1462$           if key2b .eqs. "SIZE" .and. key2_h .eqs. "_T"
1463$           then
1464$               write tf "#ifndef SIZEOF_SIZE_T"
1465$               write tf "#define SIZEOF_SIZE_T 4"
1466$               write tf "#endif"
1467$               goto cfgh_in_loop1
1468$           endif
1469$           if key2b .eqs. "TIME" .and. key2_h .eqs. "_T"
1470$           then
1471$               write tf "#ifndef SIZEOF_TIME_T"
1472$               write tf "#define SIZEOF_TIME_T 4"
1473$               write tf "#endif"
1474$               goto cfgh_in_loop1
1475$           endif
1476$           if key2b .eqs. "DOUBLE"
1477$           then
1478$               write tf "#ifndef SIZEOF_DOUBLE"
1479$               write tf "#define SIZEOF_DOUBLE 8"
1480$               write tf "#endif"
1481$               goto cfgh_in_loop1
1482$           endif
1483$           if key2b .eqs. "LONG"
1484$           then
1485$               if key2c .eqs. ""
1486$               then
1487$                   write tf "#ifndef SIZEOF_LONG"
1488$                   write tf "#define SIZEOF_LONG 4"
1489$                   write tf "#endif"
1490$               else
1491$                   write tf "#ifndef SIZEOF_LONG_LONG"
1492$                   write tf "#ifndef __VAX"
1493$                   write tf "#define SIZEOF_LONG_LONG 8"
1494$                   write tf "#endif"
1495$                   write tf "#endif"
1496$               endif
1497$               goto cfgh_in_loop1
1498$           endif
1499$           write tf "/* ", xline, " */"
1500$           goto cfgh_in_loop1
1501$       endif
1502$!
1503$!      Process NEED directives
1504$!-------------------------------
1505$       if key2a .eqs. "NEED"
1506$       then
1507$           if key2b .eqs. "STRINGS" .and. key2_h .eqs. "_H"
1508$           then
1509$               write tf "#ifndef NEED_STRINGS_H"
1510$               write tf "#define NEED_STRINGS_H 1"
1511$               write tf "#endif"
1512$               goto cfgh_in_loop1
1513$           endif
1514$           write tf "/* ", xline, " */"
1515$           goto cfgh_in_loop1
1516$       endif
1517$!
1518$!      Process GETHOSTNAME directives
1519$!-------------------------------------
1520$       if key2 .eqs. "GETHOSTNAME_TYPE_ARG2"
1521$       then
1522$           write tf "#ifndef ''key2'"
1523$           write tf "#ifdef _DECC_V4_SOURCE"
1524$           write tf "#define ''key2' int"
1525$           write tf "#else"
1526$           write tf "#define ''key2' size_t"
1527$           write tf "#endif"
1528$           write tf "#endif"
1529$           goto cfgh_in_loop1
1530$       endif
1531$!
1532$!      Process GETNAMEINFO directives
1533$!-------------------------------------
1534$       if key2a .eqs. "GETNAMEINFO"
1535$       then
1536$           if key2 .eqs. "GETNAMEINFO_QUAL_ARG1"
1537$           then
1538$               write tf "#ifndef ''key2'"
1539$               write tf "#define ''key2' const"
1540$               write tf "#endif"
1541$               goto cfgh_in_loop1
1542$           endif
1543$           if key2 .eqs. "GETNAMEINFO_TYPE_ARG1"
1544$           then
1545$               write tf "#ifndef ''key2'"
1546$               write tf "#define ''key2' struct sockaddr *"
1547$               write tf "#endif"
1548$               goto cfgh_in_loop1
1549$           endif
1550$           if key2 .eqs. "GETNAMEINFO_TYPE_ARG2"
1551$           then
1552$               write tf "#ifndef ''key2'"
1553$               write tf "#define ''key2' size_t"
1554$               write tf "#endif"
1555$               goto cfgh_in_loop1
1556$           endif
1557$           if key2 .eqs. "GETNAMEINFO_TYPE_ARG46"
1558$           then
1559$               write tf "#ifndef ''key2'"
1560$               write tf "#define ''key2' size_t"
1561$               write tf "#endif"
1562$               goto cfgh_in_loop1
1563$           endif
1564$           if key2 .eqs. "GETNAMEINFO_TYPE_ARG7"
1565$           then
1566$               write tf "#ifndef ''key2'"
1567$               write tf "#define ''key2' int"
1568$               write tf "#endif"
1569$               goto cfgh_in_loop1
1570$           endif
1571$       endif
1572$!
1573$!      Process RECV directives
1574$!-------------------------------------
1575$       if key2a .eqs. "RECV"
1576$       then
1577$           if key2 .eqs. "RECV_TYPE_ARG1"
1578$           then
1579$               write tf "#ifndef ''key2'"
1580$               write tf "#define ''key2' int"
1581$               write tf "#endif"
1582$               goto cfgh_in_loop1
1583$           endif
1584$           if key2 .eqs. "RECV_TYPE_ARG2"
1585$           then
1586$               write tf "#ifndef ''key2'"
1587$               write tf "#define ''key2' void *"
1588$               write tf "#endif"
1589$               goto cfgh_in_loop1
1590$           endif
1591$           if key2 .eqs. "RECV_TYPE_ARG3"
1592$           then
1593$               write tf "#ifndef ''key2'"
1594$               write tf "#define ''key2' size_t"
1595$               write tf "#endif"
1596$               goto cfgh_in_loop1
1597$           endif
1598$           if key2 .eqs. "RECV_TYPE_ARG4"
1599$           then
1600$               write tf "#ifndef ''key2'"
1601$               write tf "#define ''key2' int"
1602$               write tf "#endif"
1603$               goto cfgh_in_loop1
1604$           endif
1605$           if key2 .eqs. "RECV_TYPE_RETV"
1606$           then
1607$               write tf "#ifndef ''key2'"
1608$               write tf "#define ''key2' int"
1609$               write tf "#endif"
1610$               goto cfgh_in_loop1
1611$           endif
1612$       endif
1613$!
1614$!      Process SEND directives
1615$!-------------------------------------
1616$       if key2a .eqs. "SEND"
1617$       then
1618$           if key2 .eqs. "SEND_QUAL_ARG2"
1619$           then
1620$               write tf "#ifndef ''key2'"
1621$               write tf "#define ''key2' const"
1622$               write tf "#endif"
1623$               goto cfgh_in_loop1
1624$           endif
1625$           if key2 .eqs. "SEND_TYPE_ARG1"
1626$           then
1627$               write tf "#ifndef ''key2'"
1628$               write tf "#define ''key2' int"
1629$               write tf "#endif"
1630$               goto cfgh_in_loop1
1631$           endif
1632$           if key2 .eqs. "SEND_TYPE_ARG2"
1633$           then
1634$               write tf "#ifndef ''key2'"
1635$               write tf "#define ''key2' void *"
1636$               write tf "#endif"
1637$               goto cfgh_in_loop1
1638$           endif
1639$           if key2 .eqs. "SEND_TYPE_ARG3"
1640$           then
1641$               write tf "#ifndef ''key2'"
1642$               write tf "#define ''key2' size_t"
1643$               write tf "#endif"
1644$               goto cfgh_in_loop1
1645$           endif
1646$           if key2 .eqs. "SEND_TYPE_ARG4"
1647$           then
1648$               write tf "#ifndef ''key2'"
1649$               write tf "#define ''key2' int"
1650$               write tf "#endif"
1651$               goto cfgh_in_loop1
1652$           endif
1653$           if key2 .eqs. "SEND_TYPE_RETV"
1654$           then
1655$               write tf "#ifndef ''key2'"
1656$               write tf "#define ''key2' int"
1657$               write tf "#endif"
1658$               goto cfgh_in_loop1
1659$           endif
1660$       endif
1661$!
1662$!
1663$!      Process STATFS directives
1664$!-------------------------------
1665$!      if key2a .eqs. "STATFS"
1666$!      then
1667$!          write tf "/* ", xline, " */"
1668$!          goto cfgh_in_loop1
1669$!      endif
1670$!
1671$!      Process inline directive
1672$!------------------------------
1673$       if key2 .eqs. "inline"
1674$       then
1675$           write tf "#ifndef inline"
1676$           write tf "#define inline __inline"
1677$           write tf "#endif"
1678$           goto cfgh_in_loop1
1679$       endif
1680$!
1681$!      Process restrict directive
1682$!--------------------------------
1683$       if key2 .eqs. "restrict"
1684$       then
1685$           write tf "#ifndef restrict"
1686$           write tf "#define restrict __restrict"
1687$           write tf "#endif"
1688$           goto cfgh_in_loop1
1689$       endif
1690$!
1691$!      Process STDC_HEADERS (SAMBA!)
1692$!---------------------------
1693$       if key2 .eqs. "STDC_HEADERS"
1694$       then
1695$           write tf "#ifndef STDC_HEADERS"
1696$           write tf "#define STDC_HEADERS 1"
1697$           write tf "#endif"
1698$           goto cfgh_in_loop1
1699$       endif
1700$!
1701$!      Process PROTOTYPES directive
1702$!-------------------------------------
1703$       if key2 .eqs. "PROTOTYPES"
1704$       then
1705$           write tf "#ifndef PROTOTYPES"
1706$           write tf "#define PROTOTYPES 1"
1707$           write tf "#endif"
1708$           goto cfgh_in_loop1
1709$       endif
1710$!
1711$!      Special for SEEKDIR_RETURNS_VOID
1712$!---------------------------------------
1713$       if key2 .eqs. "SEEKDIR_RETURNS_VOID"
1714$       then
1715$           write tf "#ifndef SEEKDIR_RETURNS_VOID"
1716$           write tf "#define SEEKDIR_RETURNS_VOID 1"
1717$           write tf "#endif"
1718$       endif
1719$!
1720$!      Unknown - See if CONFIGURE can give a clue for this
1721$!----------------------------------------------------------
1722$       pflag = 0
1723$       set_flag = 0
1724$!      gproj_name = proj_name - "_VMS" - "-VMS"
1725$       if f$search(tfile1) .nes. "" then delete 'tfile1';*
1726$       define/user sys$output nl:
1727$       define/user sys$error nl:
1728$!      if f$locate("FILE", key2) .lt. key2_len then pflag = 1
1729$!      if f$locate("DIR", key2) .eq. key2_len - 3 then pflag = 1
1730$!      if f$locate("PATH", key2) .eq. key2_len - 4 then pflag = 1
1731$!
1732$       search/out='tfile1' 'configure_script' "''key2'="/exact
1733$       search_sev = '$severity'
1734$       if 'search_sev' .eq. 1
1735$       then
1736$           open/read/err=unknown_cf_rd_error sf 'tfile1'
1737$search_file_rd_loop:
1738$           read/end=unknown_cf_rd_err sf line_in
1739$           line_in = f$edit(line_in, "TRIM")
1740$           skey1 = f$element(0,"=",line_in)
1741$           if skey1 .eqs. key2
1742$           then
1743$               skey2 = f$element(1,"=",line_in)
1744$               skey2a = f$extract(0,2,skey2)
1745$!
1746$!
1747$!              We can not handle assignment to shell symbols.
1748$!              For now skip them.
1749$!------------------------------------------------------------
1750$               if f$locate("$", skey2) .lt. f$length(skey2)
1751$               then
1752$                   write tf "/* ", xline, " */"
1753$                   set_flag = 1
1754$                   goto found_in_configure
1755$               endif
1756$!
1757$!              Keep these two cases separate to make it easier to add
1758$!              more future intelligence to this routine
1759$!----------------------------------------------------------------------
1760$               if skey2a .eqs. """`"
1761$               then
1762$!                  if pflag .eq. 1
1763$!                  then
1764$!                      write tf "#ifndef ''key2'"
1765$!                      write tf "#define ",key2," """,gproj_name,"_",key2,""""
1766$!                      write tf "#endif"
1767$!                  else
1768$!                      Ignore this for now
1769$!------------------------------------------
1770$                       write tf "/* ", xline, " */"
1771$!                  endif
1772$                   set_flag = 1
1773$                   goto found_in_configure
1774$               endif
1775$               if skey2a .eqs. """$"
1776$               then
1777$!                  if pflag .eq. 1
1778$!                  then
1779$!                      write tf "#ifndef ''key2'"
1780$!                      write tf "#define ",key2," """,gproj_name,"_",key2,""""
1781$!                      write tf "#endif"
1782$!                  else
1783$!                      Ignore this for now
1784$!-------------------------------------------
1785$                       write tf "/* ", xline, " */"
1786$!                  endif
1787$                   set_flag = 1
1788$                   goto found_in_configure
1789$               endif
1790$!
1791$!              Remove multiple layers of quotes if present
1792$!----------------------------------------------------------
1793$               if f$extract(0, 1, skey2) .eqs. "'"
1794$               then
1795$                   skey2 = skey2 - "'" - "'" - "'" - "'"
1796$               endif
1797$               if f$extract(0, 1, skey2) .eqs. """"
1798$               then
1799$                   skey2 = skey2 - """" - """" - """" - """"
1800$               endif
1801$               write tf "#ifndef ''key2'"
1802$               if skey2 .eqs. ""
1803$               then
1804$                   write tf "#define ",key2
1805$               else
1806$!                  Only quote non-numbers
1807$!----------------------------------------
1808$                   if f$string(skey2+0) .eqs. skey2
1809$                   then
1810$                       write tf "#define ",key2," ",skey2
1811$                   else
1812$                       write tf "#define ",key2," """,skey2,""""
1813$                   endif
1814$               endif
1815$               write tf "#endif"
1816$               set_flag = 1
1817$           else
1818$               goto search_file_rd_loop
1819$!              if pflag .eq. 1
1820$!              then
1821$!                  write tf "#ifndef ''key2'"
1822$!                  write tf "#define ",key2," """,gproj_name,"_",key2,""""
1823$!                  write tf "#endif"
1824$!                  set_flag = 1
1825$!              endif
1826$           endif
1827$found_in_configure:
1828$unknown_cf_rd_err:
1829$           if f$trnlnm("sf","lnm$process",,"SUPERVISOR") .nes. ""
1830$           then
1831$               close sf
1832$           endif
1833$           if f$search(tfile1) .nes. "" then delete 'tfile1';*
1834$           if set_flag .eq. 1 then goto cfgh_in_loop1
1835$       endif
1836$   endif
1837$!
1838$!
1839$!
1840$!  If it falls through everything else, comment it out
1841$!-----------------------------------------------------
1842$   write tf "/* ", xline, " */"
1843$   goto cfgh_in_loop1
1844$cfgh_in_loop1_end:
1845$close inf
1846$!
1847$!
1848$! Write out the tail
1849$!--------------------
1850$write_tail:
1851$gosub write_config_h_tail
1852$!
1853$! Exit and clean up
1854$!--------------------
1855$general_error:
1856$status = '$status'
1857$all_exit:
1858$set noon
1859$if f$trnlnm("sf","lnm$process",,"SUPERVISOR") .nes. "" then close sf
1860$if f$trnlnm("tf","lnm$process",,"SUPERVISOR") .nes. "" then close tf
1861$if f$trnlnm("inf","lnm$process",,"SUPERVISOR") .nes. "" then close inf
1862$if f$trnlnm("tf1","lnm$process",,"SUPERVISOR") .nes. "" then close tf1
1863$if f$trnlnm("tf2","lnm$process",,"SUPERVISOR") .nes. "" then close tf2
1864$if f$trnlnm("tfcv","lnm$process",,"SUPERVISOR") .nes. "" then close tfcv
1865$if f$type(tfile1) .eqs. "STRING"
1866$then
1867$   if f$search(tfile1) .nes. "" then delete 'tfile1';*
1868$endif
1869$if f$type(dchfile) .eqs. "STRING"
1870$then
1871$   if f$search(dchfile) .nes. "" then delete 'dchfile';*
1872$endif
1873$if f$type(starhfile) .eqs. "STRING"
1874$then
1875$   if f$search(starhfile) .nes. "" then delete 'starhfile';*
1876$endif
1877$if f$type(configure_script) .eqs. "STRING"
1878$then
1879$   if f$search(configure_script) .nes. "" then delete 'configure_script';*
1880$endif
1881$exit 'status'
1882$!
1883$!
1884$control_y:
1885$   status = ss_control_y
1886$   goto all_exit
1887$!
1888$!
1889$!
1890$! Gosub to write a new config_vms.h
1891$!-----------------------------------
1892$write_config_vms:
1893$outfile = "sys$disk:[]config_vms.h"
1894$create 'outfile'
1895$open/append tf 'outfile'
1896$write tf "/* File: config_vms.h"
1897$write tf "**"
1898$write tf "** This file contains the manual edits needed for porting"
1899$!write tf "** the ''proj_name' package to OpenVMS.
1900$write tf "**"
1901$write tf "** Edit this file as needed.  The procedure that automatically"
1902$write tf "** generated this header stub will not overwrite or make any"
1903$write tf "** changes to this file."
1904$write tf "**"
1905$write tf -
1906 "** ", datetime, tab, username, tab, "Generated by ''my_proc_file'"
1907$write tf "**"
1908$write tf -
1909 "**========================================================================*/"
1910$write tf ""
1911$close tf
1912$return
1913$!
1914$! gosub to write out a documentation header for config.h
1915$!----------------------------------------------------------------
1916$write_config_h_header:
1917$outfile = "sys$disk:[]config.h"
1918$create 'outfile'
1919$open/append tf 'outfile'
1920$write tf "#ifndef CONFIG_H"
1921$write tf "#define CONFIG_H"
1922$write tf "/* File: config.h"
1923$write tf "**"
1924$write tf -
1925  "** This file contains the options needed for porting "
1926$write tf "** the project on a VMS system."
1927$write tf "**"
1928$write tf "** Try not to make any edits to this file, as it is"
1929$write tf "** automagically generated."
1930$write tf "**"
1931$write tf "** Manual edits should be made to the config_vms.h file."
1932$write tf "**"
1933$write tf -
1934 "** ", datetime, tab, username, tab, "Generated by ''my_proc_file'"
1935$write tf "**"
1936$write tf -
1937 "**========================================================================*/"
1938$write tf ""
1939$write tf "#if (__CRTL_VER >= 70200000) && !defined (__VAX)"
1940$write tf "#define _LARGEFILE 1"
1941$write tf "#endif"
1942$write tf ""
1943$write tf "#ifndef __VAX"
1944$write tf "#ifdef __CRTL_VER"
1945$write tf "#if __CRTL_VER >= 80200000"
1946$write tf "#define _USE_STD_STAT 1"
1947$write tf "#endif"
1948$write tf "#endif"
1949$write tf "#endif"
1950$write tf ""
1951$!
1952$write tf " /* Allow compiler builtins */"
1953$write tf "/*-------------------------*/"
1954$write tf "#ifdef __DECC_VER"
1955$write tf "#include <non_existent_dir:builtins.h>"
1956$write tf "#endif"
1957$!
1958$write tf ""
1959$return
1960$!
1961$! gosub to write out the tail for config.h and close it
1962$!---------------------------------------------------------
1963$write_config_h_tail:
1964$write tf ""
1965$write tf " /* Include the hand customized settings */"
1966$write tf "/*--------------------------------------*/"
1967$write tf "#include ""config_vms.h"""
1968$write tf ""
1969$write tf "#endif /* CONFIG_H */"
1970$close tf
1971$return
1972$!
1973