Debian Codegraph @

vms/generate_config_vms_h_gawk.com

raw
1 $! File: GENERATE_CONFIG_H_VMS_GAWK.COM
2 $!
3 $! Gawk like most open source products uses a variant of a config.h file.
4 $! Depending on the curl version, this could be config.h or curl_config.h.
5 $!
6 $! For GNV based builds, the configure script is run and that produces
7 $! a [curl_]config.h file. Configure scripts on VMS generally do not
8 $! know how to do everything, so there is also a [-.lib]config-vms.h file
9 $! that has VMS specific code that compensates for bugs in some of the
10 $! VMS shared images.
11 $!
12 $! This generates a []config.h file and also a config_vms.h file,
13 $! which is used to supplement that file.
14 $!
15 $!
16 $! Copyright (C) 2014, 2016, 2019, 2023, 2024 the Free Software Foundation, Inc.
17 $!
18 $! This file is part of GAWK, the GNU implementation of the
19 $! AWK Programming Language.
20 $!
21 $! GAWK is free software; you can redistribute it and/or modify
22 $! it under the terms of the GNU General Public License as published by
23 $! the Free Software Foundation; either version 3 of the License, or
24 $! (at your option) any later version.
25 $!
26 $! GAWK is distributed in the hope that it will be useful,
27 $! but WITHOUT ANY WARRANTY; without even the implied warranty of
28 $! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29 $! GNU General Public License for more details.
30 $!
31 $! You should have received a copy of the GNU General Public License
32 $! along with this program; if not, write to the Free Software
33 $! Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
34 $! USA
35 $!
36 $! Per assignment agreement with FSF, similar procedures may be present
37 $! in other packages under other licensing agreements and copyrights
38 $!
39 $!
40 $! 21-Jan-2014 J. Malmberg
41 $!
42 $!=========================================================================
43 $!
44 $! Allow arguments to be grouped together with comma or separated by spaces
45 $! Do no know if we will need more than 8.
46 $ args = "," + p1 + "," + p2 + "," + p3 + "," + p4 + ","
47 $ args = args + p5 + "," + p6 + "," + p7 + "," + p8 + ","
48 $!
49 $! Provide lower case version to simplify parsing.
50 $ args_lower = f$edit(args, "LOWERCASE")
51 $!
52 $ args_len = f$length(args)
53 $!
54 $ hw_model = f$getsyi("HW_MODEL")
55 $ if hw_model .gt 0 .and. hw_model .lt. 1024
56 $ then
57 $ arch_name = "VAX"
58 $ else
59 $ arch_name = ""
60 $ arch_name = arch_name + f$edit(f$getsyi("ARCH_NAME"), "UPCASE")
61 $ if (arch_name .eqs. "") then arch_name = "UNK"
62 $ endif
63 $!
64 $!
65 $ pipe lib/list sys$library:decc$rtldef.tlb | search sys$input: stdint
66 $ if '$SEVERITY' .ne. 1
67 $ then
68 $ create sys$disk:[]stdint.h
69 $ open/append stdint_h sys$disk:[]stdint.h
70 $ write stdint_h "/* Fake stdint.h for gnulib */"
71 $ write stdint_h "#ifndef FAKE_STDINT"
72 $ write stdint_h "#define FAKE_STDINT"
73 $ write stdint_h "#include <fake_vms_path/limits.h>"
74 $ write stdint_h "#define PTRDIFF_MAX (__INT32_MAX)"
75 $ write stdint_h "#ifndef SIZE_MAX"
76 $ write stdint_h "#define SIZE_MAX (__UINT32_MAX)"
77 $ write stdint_h "#endif /* __VAX */"
78 $ write stdint_h "#endif /* FAKE_STDINT */"
79 $ close stdint_h
80 $ endif
81 $!
82 $!
83 $! Start the configuration file.
84 $! Need to do a create and then an append to make the file have the
85 $! typical file attributes of a VMS text file.
86 $ create sys$disk:[]config_vms.h
87 $ open/append cvh sys$disk:[]config_vms.h
88 $!
89 $! Write the defines to prevent multiple includes.
90 $! These are probably not needed in this case,
91 $! but are best practice to put on all header files.
92 $ write cvh "#ifndef __CONFIG_VMS_H__"
93 $ write cvh "#define __CONFIG_VMS_H__"
94 $ write cvh ""
95 $!
96 $ write cvh "#if __CRTL_VER >= 70000000"
97 $ write cvh "#define VMS_V7"
98 $ write cvh "#else"
99 $ write cvh "#define HAVE_TZNAME 1 /* (faked in vms/vms_misc.c) */
100 $ write cvh "#define HAVE_TZSET 1 /* (faked in vms/vms_misc.c) */
101 $ write cvh "#endif"
102 $ write cvh "#if __CRTL_VER >= 70200000"
103 $ write cvh "#define DYNAMIC 1"
104 $ write cvh "#endif"
105 $ write cvh ""
106 $ write cvh "#define PRINTF_HAS_F_FORMAT 1"
107 $ write cvh ""
108 $ write cvh "/* The _Noreturn keyword of C11. */"
109 $ write cvh "#ifndef _Noreturn"
110 $ write cvh "# if (3 <= __GNUC__ || (__GNUC__ == 2 && 8 <= __GNUC_MINOR__) \"
111 $ write cvh " || 0x5110 <= __SUNPRO_C)"
112 $ write cvh "# define _Noreturn __attribute__ ((__noreturn__))"
113 $ write cvh "# elif defined _MSC_VER && 1200 <= _MSC_VER"
114 $ write cvh "# define _Noreturn __declspec (noreturn)"
115 $ write cvh "# else"
116 $ write cvh "# define _Noreturn"
117 $ write cvh "# endif"
118 $ write cvh "#endif"
119 $ write cvh ""
120 $ write cvh "/*"
121 $ write cvh " * VAXCRTL is pre-ANSI and does some variations of numeric"
122 $ write cvh " * formatting differently than gawk expects."
123 $ write cvh " */"
124 $ write cvh "#if defined(VAX) && !defined(__DECC)"
125 $ write cvh -
126 "/* '0' format modifier for %e,%f,%g gives wrong results in many cases */"
127 $ write cvh "#define VAXCRTL"
128 $ write cvh "/* %g format chooses %e format when should use %f */"
129 $ write cvh "#define GFMT_WORKAROUND 1"
130 $ write cvh "#endif"
131 $ write cvh ""
132 $ write cvh "/*"
133 $ write cvh " * VAX C"
134 $ write cvh " *"
135 $ write cvh -
136 " * As of V3.2, VAX C is not yet ANSI-compliant. But it's close enough"
137 $ write cvh -
138 " * for GAWK's purposes. Comment this out for VAX C V2.4 and earlier."
139 $ write cvh -
140 " * YYDEBUG definition is needed for combination of VAX C V2.x and Bison."
141 $ write cvh " */"
142 $ write cvh "#if defined(VAXC) && !defined(__STDC__)"
143 $ write cvh "#define __STDC__ 0"
144 $ write cvh "#define NO_TOKEN_PASTING"
145 $ write cvh "#define signed /*empty*/"
146 $ write cvh "#define inline /*empty*/"
147 $ write cvh "#ifndef __DECC /* DEC C does not support #pragma builtins */"
148 $ write cvh "#define VAXC_BUILTINS"
149 $ write cvh "#endif"
150 $ write cvh "/* #define YYDEBUG 0 */"
151 $ write cvh "#endif"
152 $ write cvh ""
153 $ write cvh ""
154 $ write cvh "#if __DECC_VER >= 60400000 && !defined(DEBUG)"
155 $ write cvh "/* disable ""new feature in C99"" diagnostics (for regex code); "
156 $ write cvh " NEWC99 ought to suffice but doesn't (at least in V6.4) */"
157 $ write cvh "#pragma message disable (NEWC99,DESIGNATORUSE)"
158 $ write cvh "#ifdef __VAX
159 $ write cvh "#endif
160 $ write cvh "#pragma message disable (LONGDOUBLENYI)"
161 $ write cvh "#endif"
162 $!
163 $! This stuff seems needed for VMS 7.3 and earlier, but not VMS 8.2+
164 $! Need some more data as to which versions these issues are fixed in.
165 $ write cvh "#if __VMS_VER <= 80200000"
166 $! mkstemp goes into an infinite loop in gawk in VAX/VMS 7.3
167 $ write cvh "#ifdef HAVE_MKSTEMP"
168 $ write cvh "#undef HAVE_MKSTEMP"
169 $ write cvh "#endif"
170 $ write cvh "#endif"
171 $ write cvh ""
172 $!
173 $! VMS not legal for ANSI compiler to pre-define
174 $ write cvh "#ifndef VMS"
175 $ write cvh "#define VMS 1"
176 $ write cvh "#endif"
177 $ write cvh ""
178 $!
179 $! Need to temp hide stuff that gawk is replacing or redefining before
180 $! including the header.
181 $ write cvh "/* Need to hide some stuff */"
182 $ write cvh "#define getopt hide_getopt"
183 $ write cvh "#define optopt hide_optopt"
184 $ write cvh "#define optind hide_optind"
185 $ write cvh "#define optarg hide_optarg"
186 $ write cvh "#define opterr hide_opterr"
187 $ write cvh "#define getpgrp hide_getpgrp"
188 $ write cvh "#define unsetenv hide_unsetenv"
189 $ write cvh "#define read hide_read"
190 $ write cvh "#define delete hide_delete"
191 $ write cvh "#define getcwd hide_getcwd"
192 $ write cvh "#define getgid hide_getgid"
193 $ write cvh "#define getegid hide_getegid"
194 $ write cvh "#define setgid hide_setgid"
195 $ write cvh "#define exit hide_exit"
196 $ write cvh "#define _exit hide__exit"
197 $ write cvh "#include <unistd.h>"
198 $ write cvh "#include <stdlib.h>"
199 $ write cvh "#include <stdio.h>"
200 $ write cvh "#include <time.h>"
201 $ write cvh "#include <stsdef.h>"
202 $ write cvh "#include <string.h>"
203 $ write cvh "#ifndef _POSIX_C_SOURCE"
204 $ write cvh "#define _POSIX_C_SOURCE 2"
205 $ write cvh "#define _XOPEN_SOURCE 1"
206 $ write cvh "#define _XOPEN_SOURCE_EXTENDED 1"
207 $ write cvh "#include <stat.h>"
208 $ write cvh "#undef _POSIX_C_SOURCE"
209 $ write cvh "#undef _XOPEN_SOURCE"
210 $ write cvh "#undef _XOPEN_SOURCE_EXTENDED"
211 $ write cvh "#endif"
212 $ write cvh "#define HAVE_STRPTIME 1"
213 $ write cvh "#undef getopt"
214 $ write cvh "#undef optopt"
215 $ write cvh "#undef optind"
216 $ write cvh "#undef optarg"
217 $ write cvh "#undef opterr"
218 $ write cvh "#undef getpgrp"
219 $ write cvh "#undef getcwd"
220 $ write cvh "#undef unsetenv"
221 $ write cvh "#undef read"
222 $ write cvh "#undef delete"
223 $ write cvh "#undef getgid"
224 $ write cvh "#undef getegid"
225 $ write cvh "#undef setgid"
226 $ write cvh "#undef exit"
227 $ write cvh "#undef _exit"
228 $!
229 $write cvh "#ifdef HAVE_STRNCASECMP"
230 $write cvh "#undef HAVE_STRNCASECMP"
231 $write cvh "#endif"
232 $!
233 $ write cvh "#define IN_CONFIG_H"
234 $ write cvh "#include ""redirect.h"""
235 $ write cvh "#undef IN_CONFIG_H"
236 $ write cvh "#define getpgrp gawk_vms_getpgrp"
237 $ write cvh "#ifdef HAVE_SETENV"
238 $ write cvh "#undef HAVE_SETENV"
239 $ write cvh "#endif"
240 $ write cvh "#ifdef HAVE_UNSETENV"
241 $ write cvh "#undef HAVE_UNSETENV"
242 $ write cvh "#endif"
243 $ write cvh "#ifdef HAVE_STRFTIME"
244 $ write cvh "#undef HAVE_STRFTIME"
245 $ write cvh "#define USE_INCLUDED_STRFTIME"
246 $ write cvh "#endif /* HAVE_STRFTIME */"
247 $ write cvh ""
248 $ write cvh "#include <bitypes.h>"
249 $ write cvh "#ifndef INT32_MAX"
250 $ write cvh "#define INT32_MAX __INT32_MAX"
251 $ write cvh "#endif"
252 $ write cvh "#ifndef INT32_MIN"
253 $ write cvh "#define INT32_MIN __INT32_MIN"
254 $ write cvh "#endif"
255 $ write cvh ""
256 $ write cvh "/*"
257 $ write cvh " * DEFPATH"
258 $ write cvh " * VMS: ""/AWK_LIBRARY"" => ""AWK_LIBRARY:"""
259 $ write cvh " * The default search path for the -f option of gawk. It is"
260 $ write cvh " * used if the AWKPATH environment variable is undefined."
261 $ write cvh " *"
262 $ write cvh " * Note: OK even if no AWK_LIBRARY logical name has been defined."
263 $ write cvh " */"
264 $ write cvh ""
265 $ write cvh "#define DEFPATH "".,/AWK_LIBRARY"""
266 $ write cvh "#define DEFLIBPATH "".,/AWK_LIBRARY"""
267 $ write cvh "#define ENVSEP ','"
268 $ write cvh ""
269 $ write cvh "/*"
270 $ write cvh " * Extended source file access."
271 $ write cvh " */"
272 $ write cvh "#define DEFAULT_FILETYPE "".awk"""
273 $ write cvh ""
274 $ write cvh "/*"
275 $ write cvh " * fork/Pipe handling."
276 $ write cvh " */"
277 $ write cvh "#define PIPES_SIMULATED 1"
278 $ write cvh ""
279 $ write cvh "/* Extension for shared libraries */"
280 $ write cvh "#define SHLIBEXT ""exe"""
281 $ write cvh ""
282 $! GAWK does not want to use ALLOCA
283 $ write cvh "#define NO_ALLOCA"
284 $ write cvh "#define STACK_DIRECTION (-1)"
285 $ write cvh ""
286 $ write cvh "void decc$exit(int status);"
287 $ write cvh "#define _exit(foo) vms_exit(foo)"
288 $ write cvh "#define exit(foo) vms_exit(foo)"
289 $ write cvh ""
290 $ write cvh "/* Use POSIX exit codes here */"
291 $ write cvh "#ifdef EXIT_FAILURE"
292 $ write cvh "#undef EXIT_FAILURE"
293 $ write cvh "#endif"
294 $ write cvh "#define EXIT_FAILURE (1)"
295 $ write cvh ""
296 $ write cvh "#define EXIT_FATAL (2)"
297 $ write cvh ""
298 $ write cvh "#ifndef C_FACILITY_NO"
299 $ write cvh "#define C_FACILITY_NO 0x350000"
300 $ write cvh "#endif"
301 $ write cvh ""
302 $ write cvh "/* Build a Posix Exit with VMS severity */
303 $ write cvh "static void vms_exit(int status) {"
304 $ write cvh " int vms_status;"
305 $ write cvh " /* Fake the __posix_exit with severity added */"
306 $ write cvh " /* Undocumented correct way to do this. */"
307 $ write cvh " vms_status = 0;"
308 $ write cvh " if (status != 0) {"
309 $ write cvh " vms_status = C_FACILITY_NO | 0xA000 | STS$M_INHIB_MSG;"
310 $ write cvh " vms_status |= (status << 3);"
311 $ write cvh " }"
312 $ write cvh " if (status == EXIT_FAILURE) {"
313 $ write cvh " vms_status |= STS$K_ERROR;"
314 $ write cvh " } else if (status == EXIT_FATAL) {"
315 $ write cvh " vms_status |= STS$K_SEVERE;"
316 $ write cvh " } else {"
317 $ write cvh " vms_status |= STS$K_SUCCESS;"
318 $ write cvh " }"
319 $ write cvh " decc$exit(vms_status);"
320 $ write cvh "}"
321 $ write cvh ""
322 $ write cvh "#define TIME_T_UNSIGNED 1"
323 $ write cvh "#include ""custom.h"""
324 $ write cvh "/* TEMP Fixup for V9.2-2 termios header not compatible */"
325 $ write cvh "#ifdef HAVE_TERMIOS_H"
326 $ write cvh "#undef HAVE_TERMIOS_H"
327 $ write cvh "#endif"
328 $ write cvh ""
329 $
330 $!
331 $! Close out the file
332 $!
333 $ write cvh ""
334 $ write cvh "#endif /* __CONFIG_VMS_H__ */"
335 $ close cvh
336 $!
337 $all_exit:
338 $ exit