3
$! $Id: config_h.com,v 1.1.1.1 2012/12/02 19:25:21 wb8tyw Exp $
5
$! This procedure attempts to figure out how to build a config.h file
6
$! for the current project.
8
$! The P1 parameter of "NOBUILTINS" inhibits the default #include <builtins.h>
9
$! that is normally added. This include can cause side effects if
10
$! special VMS compiler settings are used.
12
$! The CONFIGURE shell script will be examined for hints and a few symbols
13
$! but most of the tests will not produce valid results on OpenVMS. Some
14
$! will produce false positives and some will produce false negatives.
16
$! It is easier to just read the config.h_in file and make up tests based
19
$! This file will create an empty config_vms.h file if one does not exist.
20
$! The config_vms.h is intended for manual edits to handle things that
21
$! this procedure can not.
23
$! The config_vms.h will be invoked by the resulting config.h file.
25
$! This procedure knows about the DEC C RTL on the system it is on.
26
$! Future versions may be handle the GNV, the OpenVMS porting library,
29
$! This procedure may not guess the options correctly for all architectures,
30
$! and is a work in progress.
32
$! Copyright (C) 2014 the Free Software Foundation, Inc.
34
$! This file is part of GAWK, the GNU implementation of the
35
$! AWK Progamming Language.
37
$! GAWK is free software; you can redistribute it and/or modify
38
$! it under the terms of the GNU General Public License as published by
39
$! the Free Software Foundation; either version 3 of the License, or
40
$! (at your option) any later version.
42
$! GAWK is distributed in the hope that it will be useful,
43
$! but WITHOUT ANY WARRANTY; without even the implied warranty of
44
$! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
45
$! GNU General Public License for more details.
47
$! You should have received a copy of the GNU General Public License
48
$! along with this program; if not, write to the Free Software
49
$! Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
52
$! Per assignment agreement with FSF, similar procedures may be present
53
$! in other packages under other licensing agreements and copyrights
55
$! 15-Jan-2001 J. Malmberg Original
56
$! 29-Apr-2001 J. Malmberg Also look for config.*in* in a [.include]
58
$! 30-Apr-2001 J. Malmberg Update for SAMBA checks
59
$! 09-Apr-2005 J. Malmberg Update for RSYNC and large file.
60
$! 29-Sep-2011 J. Malmberg Update for Bash 4.2
61
$! 01-Mar-2012 J. Malmberg Warn about getcwd(0,0)
62
$! 21-Dec-2012 J. Malmberg Update for gawk
63
$!============================================================================
69
$on control_y then goto control_y
70
$on warning then goto general_error
72
$! Some information for writing timestamps to created files
73
$!----------------------------------------------------------
74
$my_proc = f$environment("PROCEDURE")
75
$my_proc_file = f$parse(my_proc,,,"NAME") + f$parse(my_proc,,,"TYPE")
77
$datetime = f$element(0,".",f$cvtime(,"ABSOLUTE","DATETIME"))
78
$username = f$edit(f$getjpi("","USERNAME"),"TRIM")
80
$pid = f$getjpi("","PID")
81
$tfile1 = "SYS$SCRATCH:config_h_temp1_''pid'.TEMP"
82
$dchfile = "SYS$SCRATCH:config_h_decc_''pid'.TEMP"
83
$configure_script = "SYS$SCRATCH:configure_script_''pid'.TEMP"
85
$! Get the system type
86
$!----------------------
87
$arch_type = f$getsyi("arch_type")
89
$! Does config_vms.h exist?
90
$!-------------------------
91
$update_config_vms = 0
92
$file = f$search("sys$disk:[]config_vms.h")
95
$ write sys$output "Found existing custom file ''file'."
97
$ update_config_vms = 1
98
$ write sys$output "Creating new sys$disk:[]config_vms.h for you."
99
$ gosub write_config_vms
103
$! On some platforms, DCL search has problems with searching a file
104
$! on a NFS mounted volume. So copy it to sys$scratch:
106
$if f$search(configure_script) .nes. "" then delete 'configure_script';*
107
$copy PRJ_ROOT:configure 'configure_script'
110
$! Write out the header
111
$!----------------------
112
$gosub write_config_h_header
116
$! config.h.in could have at least five different names depending
117
$! on how it was transferred to OpenVMS
118
$!------------------------------------------------------------------
119
$cfile = f$search("sys$disk:[]config.h.in")
122
$ cfile = f$search("sys$disk:[]config.h_in")
125
$ cfile = f$search("sys$disk:[]configh.in")
128
$ cfile = f$search("sys$disk:[]config__2eh.in")
131
$ cfile = f$search("sys$disk:[]config.h__2ein")
136
$if f$trnlnm("PRJ_INCLUDE") .nes. ""
138
$ cfile = f$search("PRJ_INCLUDE:config.h.in")
141
$ cfile = f$search("PRJ_INCLUDE:config.h_in")
144
$ cfile = f$search("PRJ_INCLUDE:config__2eh.in")
147
$ cfile = f$search("PRJ_INCLUDE:config__2eh.in")
150
$ cfile = f$search("PRJ_INCLUDE:config.h__2ein")
158
$ write sys$output "Can not find sys$disk:config.h.in"
159
$ line_out = "Looked for config.h.in, config.h_in, configh.in, "
160
$ line_out = line_out + "config__2eh.in, "config.h__2ein"
161
$ write/symbol sys$output line_out
162
$ if f$trnlnm("PRJ_INCLUDE") .nes. ""
164
$ write sys$output "Also looked in PRJ_INCLUDE: for these files."
169
" /* Could not find sys$disk:config.h.in */"
171
" /* Looked also for config.h_in, configh.in, config__2eh.in, */"
173
" /* config.h__2ein */"
174
$ if f$trnlnm("PRJ_INCLUDE") .nes. ""
177
" /* Also looked in PRJ_INCLUDE: for these files. */"
180
"/*--------------------------------------------------------------*/
186
$! Locate the DECC libraries in use
187
$!-----------------------------------
188
$decc_rtldef = f$parse("decc$rtldef","sys$library:.tlb;0")
189
$decc_shr = f$parse("decc$shr","sys$share:.exe;0")
191
$! Dump the DECC header names into a file
192
$!----------------------------------------
193
$if f$search(dchfile) .nes. "" then delete 'dchfile';*
194
$if f$search(tfile1) .nes. "" then delete 'tfile1';*
195
$define/user sys$output 'tfile1'
196
$library/list 'decc_rtldef'
197
$open/read/error=rtldef_loop1_end tf1 'tfile1'
198
$open/write/error=rtldef_loop1_end tf2 'dchfile'
200
$ read/end=rtldef_loop1_end tf1 line_in
201
$ line_in = f$edit(line_in,"TRIM,COMPRESS")
202
$ key1 = f$element(0," ",line_in)
203
$ key2 = f$element(1," ",line_in)
204
$ if key1 .eqs. " " .or. key1 .eqs. "" then goto rtldef_loop1
205
$ if key2 .nes. " " .and. key2 .nes. "" then goto rtldef_loop1
206
$ write tf2 "|",key1,"|"
209
$if f$trnlnm("tf1","lnm$process",,"SUPERVISOR") .nes. "" then close tf1
210
$if f$trnlnm("tf2","lnm$process",,"SUPERVISOR") .nes. "" then close tf2
211
$if f$search(tfile1) .nes. "" then delete 'tfile1';*
214
$! Now calculate what should be in the file from reading
215
$! config.h.in and CONFIGURE.
216
$!---------------------------------------------------------------
217
$open/read inf 'cfile'
222
$ read/end=cfgh_in_loop1_end inf line_in
223
$ xline = f$edit(line_in,"TRIM,COMPRESS")
225
$! Blank line handling
226
$!---------------------
232
$ xlen = f$length(xline)
233
$ key = f$extract(0,2,xline)
235
$! deal with comments by copying exactly
236
$!-----------------------------------------
237
$ if (do_comment .eq. 1) .or. (key .eqs. "/*")
241
$ key = f$extract(xlen - 2, 2, xline)
242
$ if key .eqs. "*/" then do_comment = 0
246
$! Some quick parsing
247
$!----------------------
248
$ keyif = f$extract(0,3,xline)
249
$ key1 = f$element(0," ",xline)
250
$ key2 = f$element(1," ",xline)
251
$ key2a = f$element(0,"_",key2)
252
$ key2b = f$element(1,"_",key2)
253
$ key2_len = f$length(key2)
254
$ key2_h = f$extract(key2_len - 2, 2, key2)
255
$ key2_t = f$extract(key2_len - 5, 5, key2)
256
$ if key2_t .eqs. "_TYPE" then key2_h = "_T"
258
$ if f$locate("64", xline) .lt. xlen then key64 = 1
260
$!write sys$output "xline = ''xline'"
262
$! Comment out this section of the ifblock
263
$!-----------------------------------------
266
$ write tf "/* ", xline, " */"
267
$ if keyif .eqs. "#en" then if_block = 0
271
$! Handle the end of an ifblock
272
$!-------------------------------
273
$ if keyif .eqs. "#en"
280
$ if key1 .eqs. "#ifndef"
282
$! Manual check for _ALL_SOURCE on AIX error
283
$!-----------------------------------------------
284
$ if key2 .eqs. "_ALL_SOURCE"
286
$ write tf "/* ", xline, " */"
288
$! Ignore the rest of the block
289
$!--------------------------------------
296
$! Default action for an #if/#else/#endif
297
$!------------------------------------------
298
$ if keyif .eqs. "#if" .or. keyif .eqs. "#el"
306
$! Process "normal?" stuff
307
$!---------------------------
308
$ if key1 .eqs. "#undef"
310
$ key2c = f$element(2, "_", key2)
311
$ if (key2c .eqs. "_") .or. (key2c .eqs. "H") then key2c = ""
312
$ key2d = f$element(3, "_", key2)
313
$ if (key2d .eqs. "_") .or. (key2d .eqs. "H") then key2d = ""
314
$ key2e = f$element(4, "_", key2)
315
$ if (key2e .eqs. "_") .or. (key2e .eqs. "H") then key2e = ""
318
$ if key2e .eqs. "TYPE"
327
$ if key2 .eqs. "bits16_t"
329
$ write tf "#ifndef ''key2'"
330
$ write tf "#define ''key2' short"
335
$ if key2 .eqs. "u_bits16_t"
337
$ write tf "#ifndef ''key2'"
338
$ write tf "#define ''key2' unsigned short"
343
$ if key2 .eqs. "bits32_t"
345
$ write tf "#ifndef ''key2'"
346
$ write tf "#define ''key2' int"
351
$ if key2 .eqs. "u_bits32_t"
353
$ write tf "#ifndef ''key2'"
354
$ write tf "#define ''key2' unsigned int"
359
$ if key2 .eqs. "intmax_t"
361
$ write tf "#ifndef ''key2'"
362
$ write tf "#ifdef __VAX"
363
$ write tf "#define ''key2' long"
365
$ write tf "#define ''key2' long long"
371
$ if key2 .eqs. "uintmax_t"
373
$ write tf "#ifndef ''key2'"
374
$ write tf "#ifdef __VAX"
375
$ write tf "#define ''key2' unsigned long"
377
$ write tf "#define ''key2' unsigned long long"
383
$ if key2 .eqs. "socklen_t"
385
$ write tf "#ifndef ''key2'"
386
$ write tf "#define ''key2' int"
391
$ if key2 .eqs. "GETGROUPS_T"
393
$ write tf "#ifndef ''key2'"
394
$ write tf "#define ''key2' gid_t"
399
$ if key2 .eqs. "HAVE_DECL_SYS_SIGLIST"
401
$ write tf "#ifndef ''key2'"
402
$ write tf "#define ''key2' 0"
407
$ if key2 .eqs. "HAVE_SYS_ERRLIST"
409
$ write tf "#ifndef ''key2'"
410
$ write tf "#define ''key2' 1"
415
$ if key2 .eqs. "HAVE_STRUCT_DIRENT_D_INO"
417
$ write tf "#ifndef ''key2'"
418
$ write tf "#define ''key2' 1"
423
$! ! The header files have this information, however
424
$! ! The ioctl() call only works on sockets.
425
$! if key2 .eqs. "FIONREAD_IN_SYS_IOCTL"
427
$! write tf "#ifndef ''key2'"
428
$! write tf "#define ''key2' 1"
430
$! goto cfgh_in_loop1
433
$! ! The header files have this information, however
434
$! ! The ioctl() call only works on sockets.
435
$! if key2 .eqs. "GWINSZ_IN_SYS_IOCTL"
437
$! write tf "#ifndef ''key2'"
438
$! write tf "#define ''key2' 1"
440
$! goto cfgh_in_loop1
443
$! ! The header files have this information, however
444
$! ! The ioctl() call only works on sockets.
445
$! if key2 .eqs. "STRUCT_WINSIZE_IN_SYS_IOCTL"
447
$! write tf "#ifndef ''key2'"
448
$! write tf "#define ''key2' 0"
450
$! goto cfgh_in_loop1
453
$ if key2 .eqs. "HAVE_STRUCT_TM_TM_ZONE"
455
$ write tf "#ifndef ''key2'"
456
$ write tf "#define ''key2' 1"
461
$ if key2 .eqs. "HAVE_TM_ZONE"
463
$ write tf "#ifndef ''key2'"
464
$ write tf "#define ''key2' 1"
469
$ if key2 .eqs. "HAVE_TIMEVAL"
471
$ write tf "#ifndef ''key2'"
472
$ write tf "#define ''key2' 1"
477
$ if key2 .eqs. "HAVE_TZNAME"
479
$ write tf "#if __CRTL_VER >= 70000000"
480
$ write tf "#ifndef ''key2'"
481
$ write tf "#define ''key2' 1"
487
$ if key2 .eqs. "WEXITSTATUS_OFFSET"
489
$ write tf "#ifndef ''key2'"
490
$ write tf "#define ''key2' 2"
495
$ if key2 .eqs. "HAVE_GETPW_DECLS"
497
$ write tf "#ifndef ''key2'"
498
$ write tf "#define ''key2' 1"
503
$ if key2 .eqs. "HAVE_DECL_CONFSTR"
505
$ write tf "#ifndef ''key2'"
506
$ write tf "#define ''key2' 1"
511
$ if key2 .eqs. "HAVE_DECL_PRINTF"
513
$ write tf "#ifndef ''key2'"
514
$ write tf "#define ''key2' 1"
519
$ if key2 .eqs. "HAVE_DECL_SBRK"
521
$ write tf "#ifndef ''key2'"
522
$ write tf "#define ''key2' 1"
527
$ if key2 .eqs. "HAVE_DECL_STRSIGNAL"
529
$ write tf "#ifndef ''key2'"
530
$ write tf "#define ''key2' 0"
535
$ if key2a .eqs. "HAVE_DECL_STRTOLD"
537
$ write tf "#ifndef ''key2'"
538
$ write tf "#define ''key2' 0"
543
$ if key2 .eqs. "HAVE_DECL_STRTOIMAX"
545
$ write tf "#ifndef ''key2'"
546
$ write tf "#define ''key2' 0"
551
$ if key2 .eqs. "HAVE_DECL_STRTOL"
553
$ write tf "#ifndef ''key2'"
554
$ write tf "#define ''key2' 1"
559
$ if key2 .eqs. "HAVE_DECL_STRTOLL"
561
$ write tf "#ifndef ''key2'"
562
$ write tf "#define ''key2' 1"
567
$ if key2 .eqs. "HAVE_DECL_STRTOUL"
569
$ write tf "#ifndef ''key2'"
570
$ write tf "#define ''key2' 1"
575
$ if key2 .eqs. "HAVE_DECL_STRTOULL"
577
$ write tf "#ifndef ''key2'"
578
$ write tf "#define ''key2' 1"
583
$ if key2 .eqs. "HAVE_DECL_STRTOUMAX"
585
$ write tf "#ifndef ''key2'"
586
$ write tf "#define ''key2' 0"
591
$ if key2 .eqs. "GETPGRP_VOID"
593
$ write tf "#ifndef ''key2'"
594
$ write tf "#define ''key2' 1"
599
$ if key2 .eqs. "NAMED_PIPES_MISSING"
601
$ write tf "#ifndef ''key2'"
602
$ write tf "#define ''key2' 1"
607
$ if key2 .eqs. "OPENDIR_NOT_ROBUST"
609
$ write tf "#ifndef ''key2'"
610
$ write tf "#define ''key2' 1"
615
$ if key2 .eqs. "PGRP_PIPE"
617
$ write tf "#ifndef ''key2'"
618
$ write tf "#define ''key2' 1"
623
$ if key2 .eqs. "CAN_REDEFINE_GETENV"
625
$ write tf "#ifndef ''key2'"
626
$ write tf "#define ''key2' 1"
631
$ if key2 .eqs. "HAVE_PRINTF_A_FORMAT"
633
$ write tf "#ifndef ''key2'"
634
$ write tf "#define ''key2' 1"
639
$ if key2 .eqs. "CTYPE_NON_ASCII"
641
$ write tf "#ifndef ''key2'"
642
$ write tf "#define ''key2' 1"
647
$ if key2 .eqs. "HAVE_LANGINFO_CODESET"
649
$ write tf "#ifndef ''key2'"
650
$ write tf "#define ''key2' 1"
655
$ if key2 .eqs. "HAVE_LC_MESSAGES"
657
$ write tf "#ifndef ''key2'"
658
$ write tf "#define ''key2' 1"
663
$! This wants execve() to do this automagically to pass.
664
$! if key2 .eqs. "HAVE_HASH_BANG_EXEC"
666
$! write tf "#ifndef ''key2'"
667
$! write tf "#define ''key2' 1"
669
$! goto cfgh_in_loop1
672
$ if key2 .eqs. "ICONV_CONST"
674
$ write tf "#ifndef ''key2'"
675
$ write tf "#define ''key2'"
680
$ if key2 .eqs. "VOID_SIGHANDLER"
682
$ write tf "#ifndef ''key2'"
683
$ write tf "#define ''key2' 1"
688
$ if key2 .eqs. "HAVE_POSIX_SIGNALS"
690
$ write tf "#ifndef ''key2'"
691
$ write tf "#define ''key2' 1"
696
$ if key2 .eqs. "UNUSABLE_RT_SIGNALS"
698
$ write tf "#ifndef ''key2'"
699
$ write tf "#define ''key2' 1"
704
$ if key2a .eqs. "HAVE_DECL_FPURGE"
706
$ write tf "#ifndef ''key2a'"
707
$ write tf "#define ''key2a' 1"
712
$ if key2 .eqs. "HAVE_DECL_SETREGID"
714
$ write tf "#ifndef ''key2'"
715
$ write tf "#define ''key2' 1"
720
$ if key2 .eqs. "HAVE_POSIX_SIGSETJMP"
722
$ write tf "#ifndef ''key2'"
723
$ write tf "#define ''key2' 1"
728
$ if key2 .eqs. "HAVE_LIBDL"
730
$ write tf "#ifndef ''key2'"
731
$ write tf "#define ''key2' 1"
736
$ if key2 .eqs. "STRCOLL_BROKEN"
738
$ write tf "#ifndef ''key2'"
739
$ write tf "#define ''key2' 1"
744
$ if key2 .eqs. "DUP_BROKEN"
746
$ write tf "#ifndef ''key2'"
747
$ write tf "#define ''key2' 1"
752
$! This is for a test that getcwd(0,0) works.
753
$! It does not on VMS.
754
$!--------------------------
755
$ if key2 .eqs. "GETCWD_BROKEN"
757
$ write sys$output ""
759
"%CONFIG_H-I-NONPORT, ''key2' being tested for!"
761
"-CONFIG_H-I-GETCWD, GETCWD(0,0) does not work on VMS."
763
"-CONFIG_H-I-GETCWD2, Work around hack probably required."
765
"-CONFIG_H-I-REVIEW, Manual Code review required!"
766
$ if update_config_vms
768
$ open/append tfcv sys$disk:[]config_vms.h
771
"/* Check config.h for use of ''key2' settings */"
779
$ if key2a .eqs. "HAVE" .or. key2a .eqs. "STAT"
782
$! Process extra underscores
783
$!------------------------------------
784
$ if f$locate("HAVE___", key2) .lt. key2_len
786
$ key2b = "__" + key2d
790
$ if f$locate("HAVE__", key2) .lt. key2_len
792
$ key2b = "_" + key2c
798
$ if key2_h .eqs. "_H"
801
$! Looking for a header file
802
$!---------------------------------------
804
$ if key2c .nes. "" then headf = headf + "_" + key2c
805
$ if key2d .nes. "" then headf = headf + "_" + key2d
807
$! (key2b .eqs. "READLINE")
809
$! Some special parsing
810
$!------------------------------------------
811
$ if (key2b .eqs. "SYS") .or. (key2b .eqs. "ARPA") .or. -
812
(key2b .eqs. "NET") .or. (key2b .eqs. "NETINET")
817
$ if key2d .nes. "" then headf = key2c + "_" + key2d
821
$! And of course what's life with out some special cases
822
$!--------------------------------------------------------------------
823
$ if key2b .eqs. "FILE"
825
$ write sys$output ""
827
"%CONFIG_H-I-NONPORT, ''key2' being asked for!"
829
"-CONFIG_H-I-FILE_OLD, file.h will not be configured as is obsolete!"
831
"-CONFIG_H_I-FCNTL_NEW, "Expecting fcntl.h to be configured instead!"
833
"-CONFIG_H_I-FCNTL_CHK, "Unable to verify at this time!"
835
"-CONFIG_H-I-REVIEW, Manual Code review required!"
837
$ if update_config_vms
839
$ open/append tfcv sys$disk:[]config_vms.h
842
"/* Check config.h for use of fcntl.h instead of file.h */"
848
$! Now look it up in the DEC C RTL
849
$!---------------------------------------------
850
$ define/user sys$output nl:
851
$ define/user sys$error nl:
852
$ search/output=nl: 'dchfile' |'headf'|/exact
853
$ if '$severity' .eq. 1
855
$ if key64 then write tf "#ifndef __VAX"
856
$ write tf "#ifndef ''key2'"
857
$ write tf "#define ''key2' 1"
858
$if p2 .nes. "" then write sys$output "''dchfile' - #define ''key2' 1"
860
$ if key64 then write tf "#endif"
866
$! Looking for a routine or a symbol
867
$!------------------------------------------------
868
$ if key2c .eqs. "MACRO"
870
$ if (key2b .eqs. "FILE") .or. (key2b .eqs. "DATE") -
871
.or. (key2b .eqs. "LINE") .or. (key2b .eqs. "TIME")
873
$ write tf "#ifndef HAVE_''key2b'"
874
$ write tf "#define HAVE_''key2b' 1"
880
$! Special false tests
881
$!-------------------------------------
884
$ if key2b .eqs. "_FCNTL" .or. key2b .eqs. "__FCNTL"
886
$ write tf "/* #undef HAVE_''key2b' */"
890
$ if key2b .eqs. "_STAT" .or. key2b .eqs. "__STAT"
892
$ write tf "/* #undef HAVE_''key2b' */"
896
$ if key2b .eqs. "_READ" .or. key2b .eqs. "__READ"
898
$ write tf "/* #undef HAVE_''key2b' */"
904
$ if key2c .nes. "" then keysym = keysym + "_" + key2c
905
$ if key2d .nes. "" then keysym = keysym + "_" + key2d
906
$ if key2e .nes. "" then keysym = keysym + "_" + key2e
909
$! Stat structure members
910
$!-------------------------------------
911
$ if key2b .eqs. "STRUCT"
913
$ if key2c .eqs. "STAT" .and (key2d .nes. "")
915
$ key2b = key2b + "_" + key2c + "_" + key2d
921
$ if (key2b .eqs. "ST") .or. (key2b .eqs. "STRUCT_STAT_ST")
923
$ keysym = "ST" + "_" + key2c
924
$ keysym = f$edit(keysym,"LOWERCASE")
926
$ if key2a .eqs. "STAT"
928
$ if (f$locate("STATVFS", key2b) .eq. 0) .and. key2c .eqs. ""
930
$ keysym = f$edit(key2b, "LOWERCASE")
932
$!$ if (key2b .eqs. "STATVFS" .or. key2b .eqs. "STATFS2" -
933
$! .or. key2b .eqs. "STATFS3") .and. key2c .nes. ""
935
$ if (key2b .eqs. "STATVFS") .and. key2c .nes. ""
937
$! Should really verify that the structure
938
$! named by key2b actually exists first.
939
$!------------------------------------------------------------
941
$! Statvfs structure members
942
$!-------------------------------------------------
943
$ keysym = "f_" + f$edit(key2c,"LOWERCASE")
947
$! UTMPX structure members
948
$!--------------------------------------
949
$ if key2b .eqs. "UT" .and. key2c .eqs. "UT"
951
$ keysym = "ut_" + f$edit(key2d,"LOWERCASE")
954
$ if f$locate("MMAP",key2) .lt. key2_len
956
$ write sys$output ""
958
"%CONFIG_H-I-NONPORT, ''key2' being asked for!"
960
"-CONFIG_H-I-MMAP, MMAP operations only work on STREAM and BINARY files!"
962
"-CONFIG_H-I-REVIEW, Manual Code review required!"
963
$ if update_config_vms
965
$ open/append tfcv sys$disk:[]config_vms.h
968
"/* Check config.h for use of ''key2' settings */"
975
$ if keysym .eqs. "CRYPT"
977
$ write sys$output ""
979
"%CONFIG_H-I-NONPORT, ''key2' being asked for!"
981
"-CONFIG_H-I-CRYPT, CRYPT operations on the VMS SYSUAF may not work!"
983
"-CONFIG_H-I-REVIEW, Manual Code review required!"
984
$ if update_config_vms
986
$ open/append tfcv sys$disk:[]config_vms.h
989
"/* Check config.h for use of ''keysym' */"
996
$ if keysym .eqs. "EXECL"
998
$ write sys$output ""
1000
"%CONFIG_H-I-NONPORT, ''key2' being asked for!"
1001
$ write sys$output -
1002
"-CONFIG_H-I-EXCEL, EXECL configured, Will probably not work."
1003
$ write sys$output -
1004
"-CONFIG_H-I-REVIEW, Manual Code review required!"
1005
$ if update_config_vms
1007
$ open/append tfcv sys$disk:[]config_vms.h
1010
"/* Check config.h for use of ''keysym' */"
1017
$! Process if cpp supports ANSI-C stringizing '#' operator
1018
$!-----------------------------------------------------------------------
1019
$ if keysym .eqs. "STRINGIZE"
1021
$ write tf "#ifndef HAVE_STRINGIZE"
1022
$ write tf "#define HAVE_STRINGSIZE 1"
1024
$ goto cfgh_in_loop1
1027
$ if keysym .eqs. "VOLATILE"
1029
$ write tf "#ifndef HAVE_VOLATILE"
1030
$ write tf "#define HAVE_VOLATILE 1"
1032
$ goto cfgh_in_loop1
1035
$ if keysym .eqs. "ALLOCA"
1037
$ write tf "#ifndef HAVE_ALLOCA"
1038
$ write tf "#define HAVE_ALLOCA 1"
1040
$ goto cfgh_in_loop1
1043
$ if keysym .eqs. "ERRNO_DECL"
1045
$ write tf "#ifndef HAVE_ERRNO_DECL"
1046
$ write tf "#define HAVE_ERRNO_DECL 1"
1048
$ goto cfgh_in_loop1
1051
$ if keysym .eqs. "LONGLONG"
1053
$ write tf "#ifndef __VAX"
1054
$ write tf "#pragma message disable longlongtype"
1055
$ write tf "#ifndef HAVE_LONGLONG"
1056
$ write tf "#define HAVE_LONGLONG 1"
1059
$ goto cfgh_in_loop1
1062
$! May need to test compiler version
1063
$!-----------------------------------------------
1064
$ if (keysym .eqs. "LONG_LONG") .or. -
1065
(keysym .eqs. "LONG_LONG_INT")
1067
$ write tf "#ifndef __VAX"
1068
$ write tf "#pragma message disable longlongtype"
1069
$ write tf "#ifndef HAVE_''keysym'"
1070
$ write tf "#define HAVE_''keysym' 1"
1073
$ goto cfgh_in_loop1
1076
$! May need to test compiler version
1077
$!-----------------------------------------------
1078
$ if keysym .eqs. "UNSIGNED_LONG_LONG"
1080
$ write tf "#ifndef __VAX"
1081
$ write tf "#pragma message disable longlongtype"
1082
$ write tf "#ifndef HAVE_UNSIGNED_LONG_LONG"
1083
$ write tf "#define HAVE_UNSIGNED_LONG_LONG 1"
1086
$ goto cfgh_in_loop1
1089
$! May need to test compiler version
1090
$!-----------------------------------------------
1091
$ if keysym .eqs. "UNSIGNED_LONG_LONG_INT"
1093
$ write tf "#ifndef __VAX"
1094
$ write tf "#pragma message disable longlongtype"
1095
$ write tf "#ifndef HAVE_UNSIGNED_LONG_LONG_INT"
1096
$ write tf "#define HAVE_UNSIGNED_LONG_LONG_INT 1"
1099
$ goto cfgh_in_loop1
1102
$! May need to test compiler version
1103
$!-----------------------------------------------
1104
$ if keysym .eqs. "LONG_DOUBLE"
1106
$ write tf "#ifndef __VAX"
1107
$ write tf "#pragma message disable longlongtype"
1108
$ write tf "#ifndef HAVE_LONG_DOUBLE"
1109
$ write tf "#define HAVE_LONG_DOUBLE 1"
1112
$ goto cfgh_in_loop1
1115
$ if keysym .eqs. "FCNTL_LOCK"
1117
$ write sys$output -
1118
"%CONFIG_H-I-NONPORT, ''key2' being asked for!
1119
$ write sys$output -
1120
"-CONFIG_H-I-REVIEW, Manual Code review required!"
1121
$ goto cfgh_in_loop1
1125
$! These libraries are provided by the DEC C RTL
1126
$!-------------------------------------------------------------
1127
$ if keysym .eqs. "LIBINET" .or. keysym .eqs. "LIBSOCKET"
1129
$ write tf "#ifndef HAVE_''keysym'"
1130
$ write tf "#define HAVE_''keysym' 1"
1131
$if p2 .nes. "" then write sys$output "''decc_shr' #define ''keysym' 1"
1133
$ goto cfgh_in_loop1
1137
$ if keysym .eqs. "HERRNO" then keysym = "h_errno"
1138
$ if keysym .eqs. "UTIMBUF" then keysym = "utimbuf"
1139
$ if key2c .eqs. "STRUCT"
1141
$ keysym = f$edit(key2d,"LOWERCASE")
1143
$ if key2_h .eqs. "_T"
1145
$ if key2_t .eqs. "_TYPE"
1147
$ keysym = f$extract(0, key2_len - 5, key2) - "HAVE_"
1149
$ keysym = f$edit(keysym,"LOWERCASE")
1153
$! Check the DEC C RTL shared image first
1154
$!------------------------------------------------------
1155
$ if f$search(tfile1) .nes. "" then delete 'tfile1';*
1156
$ define/user sys$output nl:
1157
$ define/user sys$error nl:
1158
$ search/format=nonull/out='tfile1' 'decc_shr' 'keysym'
1159
$ if '$severity' .eq. 1
1162
$! Not documented, but from observation
1163
$!------------------------------------------------------
1164
$ define/user sys$output nl:
1165
$ define/user sys$error nl:
1166
$ if arch_type .eq. 3
1168
$ keyterm = "''keysym'<SOH>"
1170
$ if arch_type .eq. 2
1172
$ keyterm = "''keysym'<BS>"
1174
$ keyterm = "''keysym'<STX>"
1177
$ search/out=nl: 'tfile1' -
1178
"$''keyterm'","$g''keyterm'","$__utc_''keyterm'",-
1179
"$__utctz_''keyterm'","$__bsd44_''keyterm'","$bsd_''keyterm'",-
1180
"$''keysym'decc$","$G''keysym'decc$","$GX''keyterm'"
1181
$ severity = '$severity'
1184
$! Of course the 64 bit stuff is different
1185
$!---------------------------------------------------------
1186
$ if severity .ne. 1 .and. key64
1188
$ define/user sys$output nl:
1189
$ define/user sys$error nl:
1190
$ search/out=nl: 'tfile1' "$_''keyterm'"
1191
$! search/out 'tfile1' "$_''keyterm'"
1192
$ severity = '$severity'
1195
$! UNIX compatability routines
1196
$!---------------------------------------------
1197
$ if severity .ne. 1
1199
$ define/user sys$output nl:
1200
$ define/user sys$error nl:
1201
$ search/out=nl: 'tfile1' -
1202
"$__unix_''keyterm'","$__vms_''keyterm'","$_posix_''keyterm'"
1203
$ severity = '$severity'
1206
$! VAX special handling routines
1207
$!---------------------------------------------
1208
$ if (severity .ne. 1) .and. (arch_type .eq. 1)
1210
$ define/user sys$output nl:
1211
$ define/user sys$error nl:
1212
$ search/out=nl: 'tfile1' "DECC$''keysym'<SOH>"
1213
$ severity = '$severity'
1216
$! Show the result of the search
1217
$!------------------------------------------------
1218
$ if 'severity' .eq. 1
1220
$ if key64 then write tf "#ifndef __VAX"
1221
$ write tf "#ifndef ''key2'"
1222
$ write tf "#define ''key2' 1"
1223
$if p2 .nes. "" then write sys$output "''decc_shr' #define ''key2' 1"
1225
$ if key64 then write tf "#endif"
1226
$ goto cfgh_in_loop1
1229
$ if f$search(tfile1) .nes. "" then delete 'tfile1';*
1231
$! Check the DECC Header files next
1232
$!----------------------------------------------
1233
$ define/user sys$output nl:
1234
$ define/user sys$error nl:
1235
$ search/out=nl: 'decc_rtldef' -
1236
"''keysym';", "''keysym'[", "struct ''keysym'"/exact
1237
$ severity = '$severity'
1238
$ if severity .eq. 1
1240
$ if key64 then write tf "#ifndef __VAX"
1241
$ write tf "#ifndef ''key2'"
1242
$ write tf "#define ''key2' 1"
1243
$if p2 .nes. "" then write sys$output "''decc_rtldef' #define ''key2' 1"
1245
$ if key64 then write tf "#endif"
1246
$ goto cfgh_in_loop1
1250
$ write tf "/* ", xline, " */"
1251
$ goto cfgh_in_loop1
1255
$! Process SIZEOF directives found in SAMBA
1256
$!------------------------------------------------
1257
$ if key2a .eqs. "SIZEOF"
1259
$ if key2b .eqs. "INO" .and. key2_h .eqs. "_T"
1261
$ write tf "#ifndef SIZEOF_INO_T"
1262
$ write tf "#define SIZEOF_INO_T (6)"
1264
$ goto cfgh_in_loop1
1266
$ if key2b .eqs. "INTMAX" .and. key2_h .eqs. "_T"
1268
$ write tf "#ifndef SIZEOF_INTMAX_T"
1269
$ write tf "#ifdef __VAX"
1270
$ write tf "#define SIZEOF_INTMAX_T (4)"
1272
$ write tf "#define SIZEOF_INTMAX_T (8)"
1275
$ goto cfgh_in_loop1
1277
$ if key2b .eqs. "OFF" .and. key2_h .eqs. "_T"
1279
$ write tf "#ifndef SIZEOF_OFF_T"
1280
$ write tf "#ifdef __VAX"
1281
$ write tf "#define SIZEOF_OFF_T (4)"
1283
$ write tf "#define SIZEOF_OFF_T (8)"
1286
$ goto cfgh_in_loop1
1288
$ if key2b .eqs. "CHAR" .and. key2_h .eqs. "_P"
1290
$ write tf "#ifndef SIZEOF_CHAR_P"
1291
$ write tf "#define SIZEOF_CHAR_P (4)"
1293
$ goto cfgh_in_loop1
1295
$ if (key2b .eqs. "INT")
1297
$ write tf "#ifndef SIZEOF_''key2b'"
1298
$ write tf "#define SIZEOF_''key2b' (4)"
1300
$ goto cfgh_in_loop1
1302
$ if key2b .eqs. "UNSIGNED"
1304
$ if key2c .eqs. "INT" .or. key2c .eqs. "LONG"
1306
$ write tf "#ifndef SIZEOF_''key2b'_''key2c'"
1307
$ write tf "#define SIZEOF_''key2b'_''key2c' (4)"
1309
$ goto cfgh_in_loop1
1312
$ if key2b .eqs. "DOUBLE"
1314
$ write tf "#ifndef SIZEOF_DOUBLE"
1315
$ write tf "#define SIZEOF_DOUBLE (8)"
1317
$ goto cfgh_in_loop1
1319
$ if key2b .eqs. "LONG"
1323
$ write tf "#ifndef SIZEOF_LONG"
1324
$ write tf "#define SIZEOF_LONG (4)"
1327
$ write tf "#ifndef SIZEOF_LONG_LONG"
1328
$ write tf "#ifndef __VAX"
1329
$ write tf "#define SIZEOF_LONG_LONG (8)"
1333
$ goto cfgh_in_loop1
1335
$ if key2b .eqs. "SHORT"
1337
$ write tf "#ifndef SIZEOF_SHORT"
1338
$ write tf "#define SIZEOF_SHORT (2)"
1340
$ goto cfgh_in_loop1
1342
$ write tf "/* ", xline, " */"
1343
$ goto cfgh_in_loop1
1346
$! Process NEED directives
1347
$!-------------------------------
1348
$ if key2a .eqs. "NEED"
1350
$ if key2b .eqs. "STRINGS" .and. key2_h .eqs. "_H"
1352
$ write tf "#ifndef NEED_STRINGS_H"
1353
$ write tf "#define NEED_STRINGS_H 1"
1355
$ goto cfgh_in_loop1
1357
$ write tf "/* ", xline, " */"
1358
$ goto cfgh_in_loop1
1362
$! Process STATFS directives
1363
$!-------------------------------
1364
$! if key2a .eqs. "STATFS"
1366
$! write tf "/* ", xline, " */"
1367
$! goto cfgh_in_loop1
1370
$! Process inline directive
1371
$!------------------------------
1372
$ if key2 .eqs. "inline"
1374
$ write tf "#ifndef inline"
1375
$ write tf "#define inline __inline"
1377
$ goto cfgh_in_loop1
1380
$! Process restrict directive
1381
$!--------------------------------
1382
$ if key2 .eqs. "restrict"
1384
$ write tf "#ifndef restrict"
1385
$ write tf "#define restrict __restrict"
1387
$ goto cfgh_in_loop1
1390
$! Process RETSIGTYPE directive
1391
$!----------------------------------
1392
$ if key2 .eqs. "RETSIGTYPE"
1394
$ write tf "#ifndef RETSIGTYPE"
1395
$ write tf "#define RETSIGTYPE void"
1397
$ goto cfgh_in_loop1
1400
$! Process STDC_HEADERS (SAMBA!)
1401
$!---------------------------
1402
$ if key2 .eqs. "STDC_HEADERS"
1404
$ write tf "#ifndef STDC_HEADERS"
1405
$ write tf "#define STDC_HEADERS 1"
1407
$ goto cfgh_in_loop1
1410
$! Process PROTOTYPES directive
1411
$!-------------------------------------
1412
$ if key2 .eqs. "PROTOTYPES"
1414
$ write tf "#ifndef PROTOTYPES"
1415
$ write tf "#define PROTOTYPES 1"
1417
$ goto cfgh_in_loop1
1420
$! Special for SEEKDIR_RETURNS_VOID
1421
$!---------------------------------------
1422
$ if key2 .eqs. "SEEKDIR_RETURNS_VOID"
1424
$ write tf "#ifndef SEEKDIR_RETURNS_VOID"
1425
$ write tf "#define SEEKDIR_RETURNS_VOID 1"
1429
$! TIME_WITH_SYS_TIME note: On VMS time.h and sys/time.h are same module.
1431
$! TIME_T_IN_SYS_TYPES_H
1432
$!------------------------------
1433
$ if key2 .eqs. "TIME_T_IN_TYPES_H"
1435
$ write tf "#ifndef ''key2'"
1436
$ write tf "#define ''key2' 1"
1440
$! Unknown - See if CONFIGURE can give a clue for this
1441
$!----------------------------------------------------------
1444
$! gproj_name = proj_name - "_VMS" - "-VMS"
1445
$ if f$search(tfile1) .nes. "" then delete 'tfile1';*
1446
$ define/user sys$output nl:
1447
$ define/user sys$error nl:
1448
$! if f$locate("FILE", key2) .lt. key2_len then pflag = 1
1449
$! if f$locate("DIR", key2) .eq. key2_len - 3 then pflag = 1
1450
$! if f$locate("PATH", key2) .eq. key2_len - 4 then pflag = 1
1452
$ search/out='tfile1' 'configure_script' "''key2'="/exact
1453
$ search_sev = '$severity'
1454
$ if 'search_sev' .eq. 1
1456
$ open/read/err=unknown_cf_rd_error sf 'tfile1'
1457
$search_file_rd_loop:
1458
$ read/end=unknown_cf_rd_err sf line_in
1459
$ line_in = f$edit(line_in, "TRIM")
1460
$ skey1 = f$element(0,"=",line_in)
1461
$ if skey1 .eqs. key2
1463
$ skey2 = f$element(1,"=",line_in)
1464
$ skey2a = f$extract(0,2,skey2)
1466
$! Keep these two cases separate to make it easier to add
1467
$! more future intelligence to this routine
1468
$!----------------------------------------------------------------------
1469
$ if skey2a .eqs. """`"
1473
$! write tf "#ifndef ''key2'"
1474
$! write tf "#define ",key2," """,gproj_name,"_",key2,""""
1475
$! write tf "#endif"
1477
$! Ignore this for now
1478
$!------------------------------------------
1479
$ write tf "/* ", xline, " */"
1482
$ goto found_in_configure
1484
$ if skey2a .eqs. """$"
1488
$! write tf "#ifndef ''key2'"
1489
$! write tf "#define ",key2," """,gproj_name,"_",key2,""""
1490
$! write tf "#endif"
1492
$! Ignore this for now
1493
$!-------------------------------------------
1494
$ write tf "/* ", xline, " */"
1497
$ goto found_in_configure
1499
$ if f$extract(0, 1, skey2) .eqs. "'"
1501
$ skey2 = skey2 - "'" - "'"
1503
$ write tf "#ifndef ''key2'"
1504
$ write tf "#define ",key2," """,skey2,""""
1508
$ goto search_file_rd_loop
1511
$! write tf "#ifndef ''key2'"
1512
$! write tf "#define ",key2," """,gproj_name,"_",key2,""""
1513
$! write tf "#endif"
1517
$found_in_configure:
1519
$ if f$trnlnm("sf","lnm$process",,"SUPERVISOR") .nes. ""
1523
$ if f$search(tfile1) .nes. "" then delete 'tfile1';*
1524
$ if set_flag .eq. 1 then goto cfgh_in_loop1
1530
$! If it falls through everything else, comment it out
1531
$!-----------------------------------------------------
1532
$ write tf "/* ", xline, " */"
1533
$ goto cfgh_in_loop1
1538
$! Write out the tail
1539
$!--------------------
1541
$gosub write_config_h_tail
1543
$! Exit and clean up
1544
$!--------------------
1549
$if f$trnlnm("sf","lnm$process",,"SUPERVISOR") .nes. "" then close sf
1550
$if f$trnlnm("tf","lnm$process",,"SUPERVISOR") .nes. "" then close tf
1551
$if f$trnlnm("inf","lnm$process",,"SUPERVISOR") .nes. "" then close inf
1552
$if f$trnlnm("tf1","lnm$process",,"SUPERVISOR") .nes. "" then close tf1
1553
$if f$trnlnm("tf2","lnm$process",,"SUPERVISOR") .nes. "" then close tf2
1554
$if f$trnlnm("tfcv","lnm$process",,"SUPERVISOR") .nes. "" then close tfcv
1555
$if f$type(tfile1) .eqs. "STRING"
1557
$ if f$search(tfile1) .nes. "" then delete 'tfile1';*
1559
$if f$type(dchfile) .eqs. "STRING"
1561
$ if f$search(dchfile) .nes. "" then delete 'dchfile';*
1563
$if f$type(configure_script) .eqs. "STRING"
1565
$ if f$search(configure_script) .nes. "" then delete 'configure_script';*
1571
$ status = ss_control_y
1576
$! Gosub to write a new config_vms.h
1577
$!-----------------------------------
1579
$outfile = "sys$disk:[]config_vms.h"
1581
$open/append tf 'outfile'
1582
$write tf "/* File: config_vms.h"
1584
$write tf "** This file contains the manual edits needed for porting"
1585
$!write tf "** the ''proj_name' package to OpenVMS.
1587
$write tf "** Edit this file as needed. The procedure that automatically"
1588
$write tf "** generated this header stub will not overwrite or make any"
1589
$write tf "** changes to this file."
1592
"** ", datetime, tab, username, tab, "Generated by ''my_proc_file'"
1595
"**========================================================================*/"
1600
$! gosub to write out a documentation header for config.h
1601
$!----------------------------------------------------------------
1602
$write_config_h_header:
1603
$outfile = "sys$disk:[]config.h"
1605
$open/append tf 'outfile'
1606
$write tf "#ifndef CONFIG_H"
1607
$write tf "#define CONFIG_H"
1608
$write tf "/* File: config.h"
1611
"** This file contains the options needed for porting "
1612
$write tf "** the project on a VMS system."
1614
$write tf "** Try not to make any edits to this file, as it is"
1615
$write tf "** automagically generated."
1617
$write tf "** Manual edits should be made to the config_vms.h file."
1620
"** ", datetime, tab, username, tab, "Generated by ''my_proc_file'"
1623
"**========================================================================*/"
1625
$write tf "#if (__CRTL_VER >= 70200000) && !defined (__VAX)"
1626
$write tf "#define _LARGEFILE 1"
1629
$write tf "#ifndef __VAX"
1630
$write tf "#ifdef __CRTL_VER"
1631
$write tf "#if __CRTL_VER >= 80200000"
1632
$write tf "#define _USE_STD_STAT 1"
1638
$if P1 .nes. "NOBUILTINS"
1640
$ write tf " /* Allow compiler builtins */"
1641
$ write tf "/*-------------------------*/"
1642
$ write tf "#ifdef __DECC_VER"
1643
$ write tf "#include <non_existant_dir:builtins.h>"
1650
$! gosub to write out the tail for config.h and close it
1651
$!---------------------------------------------------------
1652
$write_config_h_tail:
1654
$write tf " /* Include the hand customized settings */"
1655
$write tf "/*--------------------------------------*/"
1656
$write tf "#include ""sys$disk:config_vms.h"""
1658
$write tf "#endif /* CONFIG_H */"