1
$! File: GENERATE_CONFIG_H_VMS_GAWK.COM
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.
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
12
$! This generates a []config.h file and also a config_vms.h file,
13
$! which is used to supplement that file.
16
$! Copyright (C) 2014 the Free Software Foundation, Inc.
18
$! This file is part of GAWK, the GNU implementation of the
19
$! AWK Progamming Language.
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.
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.
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,
36
$! Per assignment agreement with FSF, similar procedures may be present
37
$! in other packages under other licensing agreements and copyrights
40
$! 21-Jan-2014 J. Malmberg
42
$!=========================================================================
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 + ","
49
$! Provide lower case version to simplify parsing.
50
$ args_lower = f$edit(args, "LOWERCASE")
52
$ args_len = f$length(args)
54
$ if (f$getsyi("HW_MODEL") .lt. 1024)
59
$ arch_name = arch_name + f$edit(f$getsyi("ARCH_NAME"), "UPCASE")
60
$ if (arch_name .eqs. "") then arch_name = "UNK"
64
$! Start the configuration file.
65
$! Need to do a create and then an append to make the file have the
66
$! typical file attributes of a VMS text file.
67
$ create sys$disk:[]config_vms.h
68
$ open/append cvh sys$disk:[]config_vms.h
70
$! Write the defines to prevent multiple includes.
71
$! These are probably not needed in this case,
72
$! but are best practice to put on all header files.
73
$ write cvh "#ifndef __CONFIG_VMS_H__"
74
$ write cvh "#define __CONFIG_VMS_H__"
77
$ write cvh "#if __CRTL_VER >= 70000000"
78
$ write cvh "#define VMS_V7"
80
$ write cvh "#define HAVE_TZNAME 1 /* (faked in vms/vms_misc.c) */
81
$ write cvh "#define HAVE_TZSET 1 /* (faked in vms/vms_misc.c) */
83
$ write cvh "#if __CRTL_VER >= 70200000"
84
$ write cvh "#define DYNAMIC 1"
87
$ write cvh "#define PRINTF_HAS_F_FORMAT 1"
89
$ write cvh "/* The _Noreturn keyword of C11. */"
90
$ write cvh "#ifndef _Noreturn"
91
$ write cvh "# if (3 <= __GNUC__ || (__GNUC__ == 2 && 8 <= __GNUC_MINOR__) \"
92
$ write cvh " || 0x5110 <= __SUNPRO_C)"
93
$ write cvh "# define _Noreturn __attribute__ ((__noreturn__))"
94
$ write cvh "# elif defined _MSC_VER && 1200 <= _MSC_VER"
95
$ write cvh "# define _Noreturn __declspec (noreturn)"
97
$ write cvh "# define _Noreturn"
102
$ write cvh " * VAXCRTL is pre-ANSI and does some variations of numeric"
103
$ write cvh " * formatting differently than gawk expects."
105
$ write cvh "#if defined(VAX) && !defined(__DECC)"
107
"/* '0' format modifier for %e,%f,%g gives wrong results in many cases */"
108
$ write cvh "#define VAXCRTL"
109
$ write cvh "/* %g format chooses %e format when should use %f */"
110
$ write cvh "#define GFMT_WORKAROUND 1"
114
$ write cvh " * VAX C"
117
" * As of V3.2, VAX C is not yet ANSI-compliant. But it's close enough"
119
" * for GAWK's purposes. Comment this out for VAX C V2.4 and earlier."
121
" * YYDEBUG definition is needed for combination of VAX C V2.x and Bison."
123
$ write cvh "#if defined(VAXC) && !defined(__STDC__)"
124
$ write cvh "#define __STDC__ 0"
125
$ write cvh "#define NO_TOKEN_PASTING"
126
$ write cvh "#define signed /*empty*/"
127
$ write cvh "#define inline /*empty*/"
128
$ write cvh "#ifndef __DECC /* DEC C does not support #pragma builtins */"
129
$ write cvh "#define VAXC_BUILTINS"
131
$ write cvh "/* #define YYDEBUG 0 */"
133
"#define NO_MBSUPPORT /* VAX C's preprocessor can't handle mbsupport.h */"
137
$ write cvh "#if __DECC_VER >= 60400000 && !defined(DEBUG)"
138
$ write cvh "/* disable ""new feature in C99"" diagnostics (for regex code); "
139
$ write cvh " NEWC99 ought to suffice but doesn't (at least in V6.4) */"
140
$ write cvh "#pragma message disable (NEWC99,DESIGNATORUSE)"
141
$ write cvh "#ifdef __VAX
143
$ write cvh "#pragma message disable (LONGDOUBLENYI)"
146
$! This stuff seems needed for VMS 7.3 and earlier, but not VMS 8.2+
147
$! Need some more data as to which versions these issues are fixed in.
148
$ write cvh "#if __VMS_VER <= 80200000"
149
$! mkstemp goes into an infinte loop in gawk in VAX/VMS 7.3
150
$ write cvh "#ifdef HAVE_MKSTEMP"
151
$ write cvh "#undef HAVE_MKSTEMP"
156
$! VMS not legal for ANSI compiler to pre-define
157
$ write cvh "#ifndef VMS"
158
$ write cvh "#define VMS 1"
162
$! Need to temp hide stuff that gawk is replacing or redefining before
163
$! including the header.
164
$ write cvh "/* Need to hide some stuff */"
165
$ write cvh "#define getopt hide_getopt"
166
$ write cvh "#define optopt hide_optopt"
167
$ write cvh "#define optind hide_optind"
168
$ write cvh "#define optarg hide_optarg"
169
$ write cvh "#define opterr hide_opterr"
170
$ write cvh "#define getpgrp hide_getpgrp"
171
$ write cvh "#define unsetenv hide_unsetenv"
172
$ write cvh "#define read hide_read"
173
$ write cvh "#define delete hide_delete"
174
$ write cvh "#define getcwd hide_getcwd"
175
$ write cvh "#define getgid hide_getgid"
176
$ write cvh "#define getegid hide_getegid"
177
$ write cvh "#define setgid hide_setgid"
178
$ write cvh "#define exit hide_exit"
179
$ write cvh "#define _exit hide__exit"
180
$ write cvh "#include <unistd.h>"
181
$ write cvh "#include <stdlib.h>"
182
$ write cvh "#include <stdio.h>"
183
$ write cvh "#include <time.h>"
184
$ write cvh "#include <stsdef.h>"
185
$ write cvh "#include <string.h>"
186
$ write cvh "#undef getopt"
187
$ write cvh "#undef optopt"
188
$ write cvh "#undef optind"
189
$ write cvh "#undef optarg"
190
$ write cvh "#undef opterr"
191
$ write cvh "#undef getpgrp"
192
$ write cvh "#undef getcwd"
193
$ write cvh "#undef unsetenv"
194
$ write cvh "#undef read"
195
$ write cvh "#undef delete"
196
$ write cvh "#undef getgid"
197
$ write cvh "#undef getegid"
198
$ write cvh "#undef setgid"
199
$ write cvh "#undef exit"
200
$ write cvh "#undef _exit"
202
$write cvh "#ifdef HAVE_STRNCASECMP"
203
$write cvh "#undef HAVE_STRNCASECMP"
206
$ write cvh "#define IN_CONFIG_H"
207
$ write cvh "#include ""redirect.h"""
208
$ write cvh "#undef IN_CONFIG_H"
209
$ write cvh "#define getpgrp gawk_vms_getpgrp"
210
$ write cvh "#ifdef HAVE_SETENV"
211
$ write cvh "#undef HAVE_SETENV"
213
$ write cvh "#ifdef HAVE_UNSETENV"
214
$ write cvh "#undef HAVE_UNSETENV"
216
$ write cvh "#ifdef HAVE_STRFTIME"
217
$ write cvh "#undef HAVE_STRFTIME"
218
$ write cvh "#define USE_INCLUDED_STRFTIME"
219
$ write cvh "#endif /* HAVE_STRFTIME */"
221
$ write cvh "#include <bitypes.h>"
222
$ write cvh "#define INT32_MAX __INT32_MAX"
223
$ write cvh "#define INT32_MIN __INT32_MIN"
226
$ write cvh " * DEFPATH"
227
$ write cvh " * VMS: ""/AWK_LIBRARY"" => ""AWK_LIBRARY:"""
228
$ write cvh " * The default search path for the -f option of gawk. It is"
229
$ write cvh " * used if the AWKPATH environment variable is undefined."
231
$ write cvh " * Note: OK even if no AWK_LIBRARY logical name has been defined."
234
$ write cvh "#define DEFPATH "".,/AWK_LIBRARY"""
235
$ write cvh "#define DEFLIBPATH "".,/AWK_LIBRARY"""
236
$ write cvh "#define ENVSEP ','"
239
$ write cvh " * Extended source file access."
241
$ write cvh "#define DEFAULT_FILETYPE "".awk"""
244
$ write cvh " * fork/Pipe handling."
246
$ write cvh "#define PIPES_SIMULATED 1"
248
$ write cvh "/* Extension for shared libraries */"
249
$ write cvh "#define SHLIBEXT ""exe"""
251
$! GAWK does not want to use ALLOCA
252
$ write cvh "#define NO_ALLOCA"
253
$ write cvh "#define STACK_DIRECTION (-1)"
255
$ write cvh "void decc$exit(int status);"
256
$ write cvh "#define _exit(foo) vms_exit(foo)"
257
$ write cvh "#define exit(foo) vms_exit(foo)"
259
$ write cvh "/* Use POSIX exit codes here */"
260
$ write cvh "#ifdef EXIT_FAILURE"
261
$ write cvh "#undef EXIT_FAILURE"
263
$ write cvh "#define EXIT_FAILURE (1)"
265
$ write cvh "#define EXIT_FATAL (2)"
267
$ write cvh "#ifndef C_FACILITY_NO"
268
$ write cvh "#define C_FACILITY_NO 0x350000"
271
$ write cvh "/* Build a Posix Exit with VMS severity */
272
$ write cvh "static void vms_exit(int status) {"
273
$ write cvh " int vms_status;"
274
$ write cvh " /* Fake the __posix_exit with severity added */"
275
$ write cvh " /* Undocumented correct way to do this. */"
276
$ write cvh " vms_status = 0;"
277
$ write cvh " if (status != 0) {"
278
$ write cvh " vms_status = C_FACILITY_NO | 0xA000 | STS$M_INHIB_MSG;"
279
$ write cvh " vms_status |= (status << 3);"
281
$ write cvh " if (status == EXIT_FAILURE) {"
282
$ write cvh " vms_status |= STS$K_ERROR;"
283
$ write cvh " } else if (status == EXIT_FATAL) {"
284
$ write cvh " vms_status |= STS$K_SEVERE;"
285
$ write cvh " } else {"
286
$ write cvh " vms_status |= STS$K_SUCCESS;"
288
$ write cvh " decc$exit(vms_status);"
291
$! Close out the file
294
$ write cvh "#endif /* __CONFIG_VMS_H__ */"