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