aboutsummaryrefslogtreecommitdiff
path: root/packages/vms/build_curlbuild_h.com
blob: cc74bb26c00c1e74ff904f1dc6d02affd672244c (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
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
$! File: config_h.com
$!
$! $Id: config_h.com,v 1.1.1.1 2012/12/02 19:25:21 wb8tyw Exp $
$!
$! This procedure attempts to figure out how to build a config.h file
$! for the current project.
$!
$! P1 specifies the config.h.in file or equivalent.  If it is not specified
$! then this procedure will search for several common names of the file.
$!
$! The CONFIGURE shell script will be examined for hints and a few symbols
$! but most of the tests will not produce valid results on OpenVMS.  Some
$! will produce false positives and some will produce false negatives.
$!
$! It is easier to just read the config.h_in file and make up tests based
$! on what is in it!
$!
$! This file will create an empty config_vms.h file if one does not exist.
$! The config_vms.h is intended for manual edits to handle things that
$! this procedure can not.
$!
$! The config_vms.h will be invoked by the resulting config.h file.
$!
$! This procedure knows about the DEC C RTL on the system it is on.
$! Future versions may be handle the GNV, the OpenVMS porting library,
$! and others.
$!
$! This procedure may not guess the options correctly for all architectures,
$! and is a work in progress.
$!
$! Copyright 2011, John Malmberg
$!
$! Permission to use, copy, modify, and/or distribute this software for any
$! purpose with or without fee is hereby granted, provided that the above
$! copyright notice and this permission notice appear in all copies.
$!
$! THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
$! WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
$! MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
$! ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
$! WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
$! ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
$! OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
$!
$! 15-Jan-2001	J. Malmberg	Original
$! 29-Apr-2001	J. Malmberg	Also look for config.*in* in a [.include]
$!				subdirectory
$! 30-Apr-2001	J. Malmberg	Update for SAMBA checks
$! 09-Apr-2005	J. Malmberg	Update for RSYNC and large file.
$! 29-Sep-2011	J. Malmberg	Update for Bash 4.2
$! 01-Mar-2012	J. Malmberg	Warn about getcwd(0,0)
$! 21-Dec-2012	J. Malmberg	Update for gawk
$! 29-Dec-2012	J. Malmberg	Update for curl
$!============================================================================
$!
$ss_normal = 1
$ss_abort = 44
$ss_control_y = 1556
$status = ss_normal
$on control_y then goto control_y
$on warning then goto general_error
$!
$! Some information for writing timestamps to created files
$!----------------------------------------------------------
$my_proc = f$environment("PROCEDURE")
$my_proc_file = f$parse(my_proc,,,"NAME") + f$parse(my_proc,,,"TYPE")
$tab[0,8] = 9
$datetime = f$element(0,".",f$cvtime(,"ABSOLUTE","DATETIME"))
$username = f$edit(f$getjpi("","USERNAME"),"TRIM")
$!
$pid = f$getjpi("","PID")
$tfile1 = "SYS$SCRATCH:config_h_temp1_''pid'.TEMP"
$dchfile = "SYS$SCRATCH:config_h_decc_''pid'.TEMP"
$configure_script = "SYS$SCRATCH:configure_script_''pid'.TEMP"
$!
$!  Get the system type
$!----------------------
$arch_type = f$getsyi("arch_type")
$!
$!
$! Write out the header
$!----------------------
$gosub write_curlbuild_h_header
$!
$!
$! config.h.in could have at least five different names depending
$! on how it was transferred to OpenVMS
$!------------------------------------------------------------------
$base_curlbuild = "sys$disk:[.include.curl]"
$if p1 .nes. ""
$then
$   cfile = p1
$else
$   cfile = f$search("''base_curlbuild'curlbuild.h.in")
$   if cfile .eqs. ""
$   then
$	cfile = f$search("''base_curlbuild'curlbuild.h_in")
$	if cfile .eqs. ""
$	then
$	    cfile = f$search("''base_curlbuild'curlbuildh.in")
$	    if cfile .eqs. ""
$	    then
$		cfile = f$search("''base_curlbuild'curlbuild__2eh.in")
$		if cfile .eqs. ""
$		then
$		    cfile = f$search("''base_curlbuild'curlbuild.h__2ein")
$		    if cfile .eqs. ""
$		    then
$			cfile = f$search("''base_curlbuild'curlbuild.h$5nin")
$		    endif
$		endif
$	    endif
$	endif
$   endif
$endif
$!
$if cfile .eqs. ""
$then
$   write sys$output "Can not find ''base_curlbuild'curlbuild.h.in"
$   line_out = "Looked for curlbuild.h.in, curlbuild.h_in, curlbuild.in, "
$   line_out = line_out + "curlbuild__2eh.in, curlbuild.h__2ein, "
$   line_out = line_out + "curlbuild.h$5nin"
$   write/symbol sys$output line_out
$   goto general_error
$endif
$!
$open/read inf 'cfile'
$do_comment = 0
$if_block = 0
$cfgh_in_loop1:
$!set nover
$   read/end=cfgh_in_loop1_end inf line_in
$   xline = f$edit(line_in,"TRIM,COMPRESS")
$!
$!  Blank line handling
$!---------------------
$   if xline .eqs. ""
$   then
$	write tf ""
$	goto cfgh_in_loop1
$   endif
$   xlen = f$length(xline)
$   key = f$extract(0,2,xline)
$!
$!  deal with comments by copying exactly
$!-----------------------------------------
$   if (do_comment .eq. 1) .or. (key .eqs. "/*")
$   then
$	do_comment = 1
$	write tf line_in
$	key = f$extract(xlen - 2, 2, xline)
$	if key .eqs. "*/" then do_comment = 0
$	goto cfgh_in_loop1
$   endif
$!
$!  Some quick parsing
$!----------------------
$   keyif = f$extract(0,3,xline)
$   key1 = f$element(0," ",xline)
$   key2 = f$element(1," ",xline)
$   key2a = f$element(0,"_",key2)
$   key2b = f$element(1,"_",key2)
$   key2_len = f$length(key2)
$   key2_h = f$extract(key2_len - 2, 2, key2)
$   key2_t = f$extract(key2_len - 5, 5, key2)
$   if key2_t .eqs. "_TYPE" then key2_h = "_T"
$   key64 = 0
$   if f$locate("64", xline) .lt. xlen then key64 = 1
$!
$!write sys$output "xline = ''xline'"
$!
$   if key1 .nes. "#undef"
$   then
$	write tf line_in
$	goto cfgh_in_loop1
$   endif
$!
$!  All versions of VMS have sys/types.h
$!----------------------------------------
$   if (key2 .eqs. "CURL_PULL_SYS_TYPES_H")
$   then
$	write tf "#define ''key2' 1"
$	goto cfgh_in_loop1
$   endif
$!
$!  Most have sys/socket.h
$!-------------------------
$   if (key2 .eqs. "CURL_PULL_SYS_SOCKET_H")
$   then
$	write tf "#ifdef HAVE_SYS_SOCKET_H"
$	write tf "#define ''key2' 1"
$	write tf "#else"
$	write tf "#undef ''key2'"
$	write tf "#endif"
$	goto cfgh_in_loop1
$   endif
$!
$!  VAX/VMS 7.3 does not have sys/poll.h
$!----------------------------------------
$   if (key2 .eqs. "CURL_PULL_SYS_POLL_H")
$   then
$	write tf "#ifdef HAVE_POLL_H"
$	write tf "#define ''key2' 1"
$	write tf "#else"
$	write tf "#undef ''key2'"
$	write tf "#endif"
$	goto cfgh_in_loop1
$   endif
$!
$   if (key2 .eqs. "CURL_SIZEOF_LONG")
$   then
$	write tf "#define ''key2' SIZEOF_INT"
$	goto cfgh_in_loop1
$   endif
$!
$   if (key2 .eqs. "CURL_SIZEOF_CURL_SOCKLEN_T")
$   then
$	write tf "#define ''key2' SIZEOF_INT"
$	goto cfgh_in_loop1
$   endif
$!
$   if (key2 .eqs. "CURL_TYPEOF_CURL_SOCKLEN_T")
$   then
$	write tf "#define ''key2' size_t"
$	goto cfgh_in_loop1
$   endif
$!
$   if (key2 .eqs. "CURL_TYPEOF_CURL_OFF_T")
$   then
$	write tf "#define ''key2' off_t"
$	goto cfgh_in_loop1
$   endif
$!
$   if (key2 .eqs. "CURL_FORMAT_CURL_OFF_T")
$   then
$	write tf "#if (SIZEOF_OFF_T == 8)"
$	write tf "#define ''key2' ""lld"""
$	write tf "#else"
$	write tf "#define ''key2' ""ld"""
$	write tf "#endif"
$	goto cfgh_in_loop1
$   endif
$!
$   if (key2 .eqs. "CURL_FORMAT_CURL_OFF_TU")
$   then
$	write tf "#if (SIZEOF_OFF_T == 8)"
$	write tf "#define ''key2' ""llu"""
$	write tf "#else"
$	write tf "#define ''key2' ""lu"""
$	write tf "#endif"
$	goto cfgh_in_loop1
$   endif
$!
$   if (key2 .eqs. "CURL_FORMAT_OFF_T")
$   then
$	write tf "#if (SIZEOF_OFF_T == 8)"
$	write tf "#define ''key2' ""%lld"""
$	write tf "#else"
$	write tf "#define ''key2' ""%ld"""
$	write tf "#endif"
$	goto cfgh_in_loop1
$   endif
$!
$   if (key2 .eqs. "CURL_SIZEOF_CURL_OFF_T")
$   then
$	write tf "#define ''key2' SIZEOF_OFF_T"
$	goto cfgh_in_loop1
$   endif
$!
$   if (key2 .eqs. "CURL_SUFFIX_CURL_OFF_T")
$   then
$	write tf "#if (SIZEOF_OFF_T == 8)"
$	write tf "#define ''key2' LL"
$	write tf "#else"
$	write tf "#define ''key2' L"
$	write tf "#endif"
$	goto cfgh_in_loop1
$   endif
$!
$   if (key2 .eqs. "CURL_SUFFIX_CURL_OFF_TU")
$   then
$	write tf "#if (SIZEOF_OFF_T == 8)"
$	write tf "#define ''key2' ULL"
$	write tf "#else"
$	write tf "#define ''key2' UL"
$	write tf "#endif"
$	goto cfgh_in_loop1
$   endif
$!
$!
$!
$!  If it falls through everything else, comment it out
$!-----------------------------------------------------
$   write tf "/* ", xline, " */"
$   goto cfgh_in_loop1
$cfgh_in_loop1_end:
$close inf
$close tf
$!
$! Exit and clean up
$!--------------------
$general_error:
$status = '$status'
$all_exit:
$set noon
$if f$trnlnm("tf","lnm$process",,"SUPERVISOR") .nes. "" then close tf
$if f$trnlnm("inf","lnm$process",,"SUPERVISOR") .nes. "" then close inf
$exit 'status'
$!
$!
$control_y:
$   status = ss_control_y
$   goto all_exit
$!
$!
$! gosub to write out a documentation header for config.h
$!----------------------------------------------------------------
$write_curlbuild_h_header:
$outfile = "sys$disk:[.include.curl]curlbuild.h"
$create 'outfile'
$open/append tf 'outfile'
$write tf -
 "/* [.include.curl]curlbuild.h.  Generated from curlbuild.h.in by */"
$write tf -
 "/* ", my_proc_file, tab, datetime, tab, username, tab, "         */"
$write tf ""
$return