1$! BUILD_VMS.COM
2$!
3$! I've taken the original build_vms.com, supplied by Nico Baggus, if
4$! memory serves me correctly, and made some modifications.
5$!
6$! SSL support is controlled by logical names.  If SSL$INCLUDE is
7$! defined, then it is assumed that HP's SSL product has been installed.
8$! If OPENSSL is defined, but SSL$INCLUDE is not, then OpenSSL will be
9$! used.  If neither logical name is defined, then SSL support will not
10$! be compiled/linked in.  Command-line options NOHPSSL and NOSSL can be
11$! specified to override the automatic SSL selection.
12$!
13$! Command-line Options:
14$!
15$!    CLEAN     Delete product files for this host architecture.  (No
16$!              build done.)
17$!    CLEAN_ALL Delete product files for all host architectures.  (No
18$!              build done.)
19$!
20$!    64        Compile with 64-bit pointers.
21$!              Note, you must match the pointer size that the OpenSSL
22$!              shared image expects.
23$!              Currently curl is not building properly with 64 bit pointers
24$!              on VMS because it is trying to cast pointers to 32 bit
25$!              integers and some OpenVMS library routines called by curl
26$!              do not yet support 64 bit pointers.
27$!    CCQUAL=x  Add "x" to the C compiler qualifiers.
28$!              Default qualifiers are:
29$!                  /standard=relaxed
30$!                  /names=(as_is, shortened)
31$!                  /repository=[.'arch']
32$!                  /nested_include_directory=none
33$!                  /define=(_LARGEFILE=1,_USE_STD_STAT=1) (non-vax)
34$!                  /float=ieee/ieee_mode=denorm_results (non-vax)
35$!    DEBUG     Compile debug and nooptimize
36$!              Alpha/IA64 always compiles /debug.
37$!              Always link a debug image.
38$!    NOIEEE    Do not use IEEE floating point.  (Alpha/I64)
39$!              VAX must always use DFLOAT
40$!    NOLARGE   Disable large-file support if large file support available.
41$!              (Non-VAX, VMS >= V7.2.)
42$!    NOLDAP    Disable LDAP support if LDAP is available.
43$!    NOKERBEROS   Disable Kerberos support if Kerberos is available.
44$!    LIST      Create C compiler listings and linker maps.
45$!                 /list/show=(expan,includ)/machine
46$!    FULLLIST  Full detailed listing.
47$!                 /list/show=(all, nomessages)/machine
48$!    NOHPSSL   Don't use HP SSL, even if available.
49$!              Note, you must match the pointer size that the OpenSSL
50$!              shared image expects.  This procedure will select the
51$!              correct HP OpenSSL image.
52$!    NOSSL     Don't use any SSL, even if available.
53$!    OSSLOLB   Use OpenSSL object libraries (.OLB), even if shared
54$!              images (.EXE) are available.
55$!    NOZLIB    Don't use GNV$ZLIB shared image even if available.
56$!    REALCLEAN Delete product files for all host architectures.  (No
57$!              build done.)  Alias for CLEAN_ALL
58$!
59$! DCL Symbols:
60$!
61$!    CURL_CCDEFS="c_macro_1=value1 [, c_macro_2=value2 [...]]"
62$!              Compile with these additional C macros defined.
63$!
64$! Revisions:
65$!
66$!  2-DEC-2003, MSK, the "original" version.
67$!                   It works for me.  Your mileage may vary.
68$! 13-JAN-2004, MSK, moved this procedure to the [.packages.vms] directory
69$!                   and updated it to do hardware dependent builds.
70$! 29-JAN-2004, MSK, moved logical defines into defines.com
71$!  6-FEB-2004, MSK, put in various SSL support bits
72$!  9-MAR-2004, MSK, the config-vms.h* files are now copied to the lib and
73$!                   src directories as curl_config.h.
74$! 15-MAR-2004, MSK, All of the curlmsg*.* files have also been moved to
75$!                   this build directory.  They will be copied to the src
76$!                   directory before build.  The .msg file will be compiled
77$!                   to get the .obj for messages, but the .h and .sdl files
78$!                   are not automatically created since they partly rely on
79$!                   the freeware SDL tool.
80$!  8-FEB-2005, MSK, merged the two config-vms.h* files into one that uses
81$!                   USE_SSLEAY to define if the target has SSL support built
82$!                   in.  Changed the cc/define parameter accordingly.
83$! 11-FEB-2005, MSK, If [--.LIB]AMIGAOS.C and NWLIB.C are there, rename them
84$! 23-MAR-2005, MSK, relocated cc_qual define so that DEBUG option would work
85$! 25-APR-2007, STL, allow compilation in 64-bit mode.
86$! 13-DEC-2009. SMS, Changed to skip unwanted source files without
87$!                   renaming the original files.
88$!                   Eliminated needless, persistent logical names.
89$!                   Added CURL_CCDEFS DCL symbol for user-specified C
90$!                   macro definitions.
91$!                   Added CLEAN and CLEAN_ALL options.
92$!                   Added CCQUAL option for user-specified C compiler
93$!                   qualifiers.
94$!                   Added IEEE option for IEEE floating point (Alpha).
95$!                   Added LARGE option for large-file support.
96$!                   Added OSSLOLB option, and support for OpenSSL
97$!                   shared images.
98$!                   Changed to put listing and map files into lisdir:.
99$!                   Changed to avoid case confusion on ODS5 disks.
100$!                   Added more default dev:[dir] save+restore.
101$!                   Moved remaining "defines.com" code (back) into
102$!                   here, eliminating the hard-coded OpenSSL nonsense.
103$!                   Changed to use F$GETSYI("ARCH_NAME") (or
104$!                   equivalent) to name architecture-specific product
105$!                   file destination directory, and to create the
106$!                   directory if needed (obviating inclusion of these
107$!                   directories and dummy files in the distribution
108$!                   kit).
109$!                   Changed the "compile" subroutine to break the CC
110$!                   command across multiple lines to avoid DCL
111$!                   line-too-long problems.
112$!                   Changed "vo_c" messages to show the CC qualifiers
113$!                   once, not with every compile command.
114$! 01-Jan-2013  J. Malmberg
115$!                   VMS build procedures need to be able to work with
116$!                   the default set to a search list, with created or
117$!                   modified files only in the first member of the search
118$!                   list.
119$!                   Whitespace change to be more compatible with current
120$!                   practices.
121$!                   One pass option parsing instead of loop.
122$!                   GNV ZLIB shared image support.
123$!                   KERBEROS support where available.
124$!                   LDAP default to on where available
125$!                   LARGEFILE default to on where available
126$!                   IEEE float default to on where available.
127$!                   Generate the curl_config.h file from system inspection.
128$!                   Linker finds ldap with out option file.
129$! 13-Mar-2013, Tom Grace
130$!                   Added missing slash in cc_full_list.
131$!                   Removed unwanted extra quotes inside symbol tool_main
132$!                   for non-VAX architectures that triggered link failure.
133$!                   Replaced curl_sys_inc with sys_inc.
134$! 19-Mar-2013, John Malmberg
135$!                   symbol tool_main needs to be quoted when parse style is
136$!                   set to exended in versions of VMS greater than 7.3-1.
137$!                   Remove curlbuild.h generation as it should be pre-built
138$!                   in the curl release or daily tarball.
139$! 12-Jul-2013, John Malmberg
140$!                   Adjust to find and use ZLIB from the Jean-Francois
141$!                   Pieronne shared image and newer GNV ZLIB kit that
142$!                   is upward compatible with Jean-Francois's kit.
143$!                   Remove tabs from file.
144$!                   Fixed DCL formatting as follows:
145$!                      * Labels have no space after leading $.
146$!                      * 1 space after $ for first level.
147$!                      * 3 spaces after $ for second level.  Line start + 4.
148$!                      * 7 spaces after $ for third level.  Line start + 8.
149$!                      * Each level after that indents 4 characters.
150$!                      * then/else/endif same indentation as if statement.
151$! 17-Nov-2014, Michael Steve
152$!                   Modified build to handle new location of the VTLS lib
153$!                   source within zip archive. Not a pretty fix.
154$!
155$!===========================================================================
156$!
157$!
158$! Save the original default dev:[dir], and arrange for its restoration
159$! at exit.
160$!------------------------------------------------------------------------
161$ curl = ""
162$ orig_def = f$environment("DEFAULT")
163$ on error then goto Common_Exit
164$ on control_y then goto Common_Exit
165$!
166$ ctrl_y  = 1556
167$ proc = f$environment("PROCEDURE")
168$ proc_fid = f$file_attributes(proc, "FID")
169$ proc_dev = f$parse(proc, , , "DEVICE")
170$ proc_dir = f$parse(proc, , , "DIRECTORY")
171$ proc_name = f$parse(proc, , , "NAME")
172$ proc_type = f$parse(proc, , , "TYPE")
173$ proc_dev_dir = proc_dev + proc_dir
174$!
175$! Have to manually parse the device for a search list.
176$! Can not use the f$parse() as it will return the first name
177$! in the search list.
178$!
179$ orig_def_dev = f$element(0, ":", orig_def) + ":"
180$ if orig_def_dev .eqs. "::" then orig_def_dev = "sys$disk:"
181$ test_proc = orig_def_dev + proc_dir + proc_name + proc_type
182$!
183$! If we can find this file using the default directory
184$! then we know that we should use the original device from the
185$! default directory which could be a search list.
186$!
187$ test_proc_fid = f$file_attributes(test_proc, "FID")
188$!
189$ if (test_proc_fid .eq. proc_fid)
190$ then
191$   proc_dev_dir = orig_def_dev + proc_dir
192$ endif
193$!
194$!
195$! Verbose output message stuff.  Define symbol to "write sys$output" or "!".
196$! vo_c - verbose output for compile
197$! vo_l - link
198$! vo_o - object check
199$!
200$ vo_c := "write sys$output"
201$ vo_l := "write sys$output"
202$ vo_o := "!"
203$!
204$! Determine the main distribution directory ("[--]") in an
205$! ODS5-tolerant (case-insensitive) way.  (We do assume that the only
206$! "]" or ">" is the one at the end.)
207$!
208$! Some non-US VMS installations report ">" for the directory delimiter
209$! so do not assume that it is "]".
210$!
211$ orig_def_len = f$length(orig_def)
212$ delim = f$extract(orig_def_len - 1, 1, orig_def)
213$!
214$ set default 'proc_dev_dir'
215$ set default [--]
216$ base_dev_dir = f$environment("default")
217$ top_dev_dir = base_dev_dir - delim
218$!
219$!
220$!
221$! Define the architecture-specific product file destination directory
222$! name(s).
223$!
224$ parse_style = "TRADITIONAL"
225$ if (f$getsyi("HW_MODEL") .lt. 1024)
226$ then
227$    arch_name = "VAX"
228$ else
229$    arch_name = ""
230$    arch_name = arch_name + f$edit(f$getsyi("ARCH_NAME"), "UPCASE")
231$    if (arch_name .eqs. "") then arch_name = "UNK"
232$!
233$!   Extended parsing option starts with VMS 7.3-1.
234$!   There is no 7.4, so that simplifies the parse a bit.
235$!
236$    node_swvers = f$getsyi("node_swvers")
237$    version_patch = f$extract(1, f$length(node_swvers), node_swvers)
238$    maj_ver = f$element(0, ".", version_patch)
239$    min_ver_patch = f$element(1, ".", version_patch)
240$    min_ver = f$element(0, "-", min_ver_patch)
241$    patch = f$element(1, "-", min_ver_patch)
242$    if patch .eqs. "-" then patch = ""
243$    parse_x = 0
244$    if maj_ver .ges. "8"
245$    then
246$       parse_x = 1
247$    else
248$       if maj_ver .eqs. "7" .and. min_ver .ges. "3" .and. patch .nes. ""
249$       then
250$          parse_x = 1
251$       endif
252$    endif
253$    if parse_x
254$    then
255$       parse_style = f$getjpi("", "parse_style_perm")
256$    endif
257$ endif
258$!
259$ exedir = proc_dev_dir - delim + ".''arch_name'" + delim
260$ lisdir = exedir
261$ objdir = exedir
262$!
263$! When building on a search list, need to do a create to make sure that
264$! the output directory exists, since the clean procedure tries to delete
265$! it.
266$ create/dir 'exedir'/prot=o:rwed
267$!
268$! Interpret command-line options.
269$!
270$ hpssl = 0
271$ ldap = 1
272$ list = 0
273$ full_list = 0
274$ nohpssl = 0
275$ nossl = 0
276$ openssl = 0
277$ osslolb = 0
278$ nozlib = 0
279$ nokerberos = 0
280$ cc_names = "/names=(shortened, as_is)/repository='exedir'
281$ cc_defs = "HAVE_CONFIG_H=1"
282$ cc_list = "/list='objdir'/show=(expan, includ)/machine
283$ cc_full_list = "/list='objdir'/show=(all, nomessages)/machine
284$ link_qual = ""
285$ if arch_name .eqs. "VAX"
286$ then
287$    cc_debug = "/nodebug/optimize"
288$    !cc_defs = cc_defs + ""
289$    cc_float = ""
290$    cc_large = ""
291$ else
292$    cc_debug = "/debug/optimize"
293$    cc_defs = cc_defs + ",_USE_STD_STAT"
294$    cc_float = "/float=ieee/ieee_mode=denorm_results"
295$    cc_large = ",_LARGEFILE"
296$ endif
297$ cc_qual1 = ""
298$ cc_qual2 = ""
299$ if (f$type(CURL_CCDEFS) .nes. "")
300$ then
301$    CURL_CCDEFS = f$edit(CURL_CCDEFS, "TRIM")
302$    cc_defs = cc_defs + ", " + CURL_CCDEFS
303$ endif
304$ msg_qual = "/object = ''objdir'"
305$ ssl_opt = ""
306$!
307$! Allow arguments to be grouped together with comma or separated by spaces
308$! Do no know if we will need more than 8.
309$ args = "," + p1 + "," + p2 + "," + p3 + "," + p4 + ","
310$ args = args + p5 + "," + p6 + "," + p7 + "," + p8 + ","
311$!
312$! Provide lower case version to simplify parsing.
313$ args_lower = f$edit(args, "LOWERCASE,COLLAPSE")
314$!
315$ args_len = f$length(args)
316$ args_lower_len = f$length(args_lower)
317$!
318$ clean = 0
319$ if f$locate(",clean,", args_lower) .lt. args_lower_len
320$ then
321$   clean = 1
322$ endif
323$ clean_all = 0
324$ if f$locate(",clean_all,", args_lower) .lt. args_lower_len
325$ then
326$    clean = 1
327$    clean_all = 1
328$ endif
329$ if f$locate(",realclean,", args_lower) .lt. args_lower_len
330$ then
331$    clean = 1
332$    clean_all = 1
333$ endif
334$!
335$ if clean .ne. 0
336$ then
337$   prods = "''exedir'*.*;*"
338$   if (f$search(prods) .nes. "") then delete /log 'prods'
339$   prods = proc_dev_dir + arch_name + ".DIR;1"
340$   if (f$search(prods) .nes. "") then set prot=o:rwed 'prods'
341$   if (f$search(prods) .nes. "") then delete /log 'prods'
342$   file = "[]config_vms.h"
343$   if f$search(file) .nes. "" then delete/log 'file';*
344$   file = "[]config.h"
345$   if f$search(file) .nes. "" then delete/log 'file';*
346$   file = "[]curl-config."
347$   if f$search(file) .nes. "" then delete/log 'file';*
348$   file = "[]libcurl.pc"
349$   if f$search(file) .nes. "" then delete/log 'file';*
350$   file = "[.lib.cxx_repository]cxx$demangler_db."
351$   if f$search(file) .nes. "" then delete/log 'file';*
352$   file = "[.src.cxx_repository]cxx$demangler_db."
353$   if f$search(file) .nes. "" then delete/log 'file';*
354$   file = "[.lib]config_vms.h"
355$   if f$search(file) .nes. "" then delete/log 'file';*
356$   file = "[...]curl_crtl_init"
357$   if f$search("''file'.lis") .nes. "" then delete/log 'file'.lis;*
358$   if f$search("''file'.obj") .nes. "" then delete/log 'file'.obj;*
359$   file = "[...]gnv$curlmsg"
360$   if f$search("''file'.lis") .nes. "" then delete/log 'file'.lis;*
361$   if f$search("''file'.obj") .nes. "" then delete/log 'file'.obj;*
362$   if f$search("''file'.exe") .nes. "" then delete/log 'file'.exe;*
363$   file = "[...]curlmsg"
364$   if f$search("''file'.lis") .nes. "" then delete/log 'file'.lis;*
365$   if f$search("''file'.obj") .nes. "" then delete/log 'file'.obj;*
366$   if f$search("''file'.exe") .nes. "" then delete/log 'file'.exe;*
367$   file = "[...]report_openssl_version"
368$   if f$search("''file'.lis") .nes. "" then delete/log 'file'.lis;*
369$   if f$search("''file'.obj") .nes. "" then delete/log 'file'.obj;*
370$   if f$search("''file'.exe") .nes. "" then delete/log 'file'.exe;*
371$   file = "[...]hp_ssl_release_info.txt"
372$   if f$search(file) .nes. "" then delete/log 'file';*
373$   file = "[...]gnv_libcurl_xfer.mar_exact"
374$   if f$search(file) .nes. "" then delete/log 'file';*
375$   file = "[...]gnv_libcurl_xfer"
376$   if f$search("''file'.lis") .nes. "" then delete/log 'file'.lis;*
377$   if f$search("''file'.obj") .nes. "" then delete/log 'file'.obj;*
378$   if f$search("''file'.opt") .nes. "" then delete/log 'file'.opt;*
379$   file = "[...]curl-*_original_src.bck"
380$   if f$search(file) .nes. "" then delete/log 'file';*
381$   file = "[...]curl_d-*_original_src.bck"
382$   if f$search(file) .nes. "" then delete/log 'file';*
383$   file = "[...]curl-*_vms_src.bck"
384$   if f$search(file) .nes. "" then delete/log 'file';*
385$   file = "[...]curl_d-*_vms_src.bck"
386$   if f$search(file) .nes. "" then delete/log 'file';*
387$   file = "[...]curl-*.release_notes"
388$   if f$search(file) .nes. "" then delete/log 'file';*
389$   file = "[...]curl_d-*.release_notes"
390$   if f$search(file) .nes. "" then delete/log 'file';*
391$   file = "[...]*curl*.pcsi$desc"
392$   if f$search(file) .nes. "" then delete/log 'file';*
393$   file = "[...]*curl_d*.pcsi$desc"
394$   if f$search(file) .nes. "" then delete/log 'file';*
395$   file = "[...]*curl*.pcsi$text"
396$   if f$search(file) .nes. "" then delete/log 'file';*
397$   file = "[...]*curl_d*.pcsi$text"
398$   if f$search(file) .nes. "" then delete/log 'file';*
399$!
400$   if clean_all .eq. 0 then goto Common_Exit
401$ endif
402$!
403$!
404$ if clean_all .ne. 0
405$ then
406$   file = "[...]gnv$libcurl"
407$   if f$search("''file'.exe") .nes. "" then delete/log 'file'.exe;*
408$   if f$search("''file'.map") .nes. "" then delete/log 'file'.map;*
409$   if f$search("''file'.dsf") .nes. "" then delete/log 'file'.dsf;*
410$   file = "[.src]curl"
411$   if f$search("''file'.exe") .nes. "" then delete/log 'file'.exe;*
412$   if f$search("''file'.map") .nes. "" then delete/log 'file'.map;*
413$   if f$search("''file'.dsf") .nes. "" then delete/log 'file'.dsf;*
414$   prods = proc_dev_dir - delim + ".ALPHA" + delim + "*.*;*"
415$   if (f$search(prods) .nes. "") then delete /log 'prods'
416$   prods = proc_dev_dir + "ALPHA" + ".DIR;1"
417$   if (f$search(prods) .nes. "") then set prot=o:rwed 'prods'
418$   if (f$search(prods) .nes. "") then delete /log 'prods'
419$   prods = proc_dev_dir - delim + ".IA64" + delim + "*.*;*"
420$   if (f$search(prods) .nes. "") then delete /log 'prods'
421$   prods = proc_dev_dir + "IA64" + ".DIR;1"
422$   if (f$search(prods) .nes. "") then set prot=o:rwed 'prods'
423$   if (f$search(prods) .nes. "") then delete /log 'prods'
424$   prods = proc_dev_dir - delim + ".VAX" + delim + "*.*;*"
425$   if (f$search(prods) .nes. "") then delete /log 'prods'
426$   prods = proc_dev_dir + "VAX"+ ".DIR;1"
427$   if (f$search(prods) .nes. "") then set prot=o:rwed 'prods'
428$   if (f$search(prods) .nes. "") then delete /log 'prods'
429$   file = "[...]macro32_exactcase"
430$   if f$search("''file'.exe") .nes. "" then delete/log 'file'.exe;*
431$   if f$search("''file'.jnl") .nes. "" then delete/log 'file'.jnl;*
432$   goto Common_Exit
433$ endif
434$!
435$ build_64 = 0
436$ if f$locate(",64,", args_lower) .lt. args_lower_len
437$ then
438$   cc_qual1 = cc_qual1 + " /POINTER = 64"
439$   build_64 = 1
440$ endif
441$!
442$ args_loc = f$locate(",ccqual=", args_lower)
443$ if args_loc .lt. args_lower_len
444$ then
445$   arg = f$extract(args_loc + 1, args_lower_len, args_lower)
446$   arg_val = f$element(0, ",", arg)
447$   cc_qual2 = f$element(1, "=", arg_val);
448$ endif
449$!
450$! On Alpha/IA64 no size penalty for compiling /debug/optimize
451$! by default.
452$ if f$locate(",debug,", args_lower) .lt. args_lower_len
453$ then
454$   cc_debug = "/debug/nooptimize"
455$ endif
456$!
457$! We normally want IEEE float if it is available.  Programs that are
458$! calling libcurl will typically prefer IEEE behavior, unless on the
459$! VAX where we have no choice.
460$!
461$ if f$locate(",noieee,", args_lower) .lt. args_lower_len
462$ then
463$   cc_float = ""
464$ endif
465$!
466$! Normally we want large file if it is available.
467$ if f$locate(",nolarge,", args_lower) .lt. args_lower_len
468$ then
469$   write sys$output "Handling of large files disabled."
470$   cc_large = ""
471$ endif
472$ if cc_large .nes. ""
473$ then
474$   cc_defs = cc_defs + cc_large
475$ endif
476$!
477$ if f$locate(",noldap,", args_lower) .lt. args_lower_len
478$ then
479$   ldap = 0
480$ endif
481$!
482$ if f$locate(",list,", args_lower) .lt. args_lower_len
483$ then
484$   list = 1
485$ endif
486$ if f$locate(",fulllist,", args_lower) .lt. args_lower_len
487$ then
488$    list = 1
489$    full_list = 1
490$ endif
491$!
492$ if f$locate(",nohpssl,", args_lower) .lt. args_lower_len
493$ then
494$   nohpssl = 1
495$ endif
496$!
497$ if f$locate(",nossl,", args_lower) .lt. args_lower_len
498$ then
499$   nossl = 1
500$ endif
501$!
502$ if f$locate(",osslolb,", args_lower) .lt. args_lower_len
503$ then
504$    osslolb = 1
505$ endif
506$!
507$ if f$locate(",nozlib,", args_lower) .lt. args_lower_len
508$ then
509$   nozlib = 1
510$ endif
511$!
512$ if f$locate(",nokerberos,", args_lower) .lt. args_lower_len
513$ then
514$   nokerberos = 1
515$ endif
516$!
517$!
518$! CC /LIST, LINK /MAP, and MESSAGE /LIST are defaults in batch mode,
519$! so be explicit when they're not desired.
520$!
521$
522$ if list .eq. 0
523$ then
524$   cc_qual1 = cc_qual1 + "/nolist"
525$   msg_qual = msg_qual + "/nolist"
526$ else
527$   msg_qual = msg_qual + "/list='objdir'"
528$   if (full_list .ne. 0)
529$   then
530$       cc_qual1 = cc_qual1 + cc_full_list
531$   else
532$       cc_qual1 = cc_qual1 + cc_list
533$   endif
534$ endif
535$ cc_qual1 = cc_qual1 + cc_names + cc_float + cc_debug
536$!
537$! Create product directory, if needed.
538$!
539$ if (f$search(proc_dev_dir + arch_name + ".DIR;1") .eqs. "")
540$ then
541$    create /directory 'exedir'
542$ endif
543$!
544$! Detect available (but not prohibited) SSL software.
545$!
546$ libsslshr_line = ""
547$ libcryptoshr_line = ""
548$ if (.not. nossl)
549$ then
550$   if (f$trnlnm("OPENSSL") .nes. "")
551$   then
552$!        cc_defs = cc_defs + ", USE_OPENSSL=1"
553$        if ((f$trnlnm("SSL$INCLUDE") .nes. "") .and. (.not. nohpssl))
554$        then
555$!          Use HP SSL.
556$           hpssl = 1
557$!
558$!          Older SSL only has lib*_shr32 images
559$!-----------------------------------------------
560$           libsslshr = "sys$share:ssl$libssl_shr"
561$           if (f$search("''libsslshr'.exe") .eqs. "") .or. (.not. build_64)
562$           then
563$               libsslshr = libsslshr + "32"
564$           endif
565$           libcryptoshr = "sys$share:ssl$libcrypto_shr"
566$           if (f$search("''libcryptoshr'.exe") .eqs. "") .or. (.not. build_64)
567$           then
568$               libcryptoshr = libcryptoshr + "32"
569$           endif
570$           libsslshr_line = "''libsslshr'.exe/share"
571$           libcryptoshr_line = "''libcryptoshr'.exe/share"
572$       else
573$!          Use OpenSSL.  Assume object libraries, unless shared images
574$!          are found (and not prohibited).
575$!          TODO: We do not know how to automatically choose based on the
576$!          pointer size.
577$!
578$           openssl = 1
579$           libsslshr_line = "ssllib:libssl.olb/lib"
580$           libcryptoshr_line = "ssllib:libcrypto.olb/lib"
581$           ssl_opt = ", ssllib:libssl.olb /library" + -
582                ", ssllib:libcrypto.olb /library"
583$           if (osslolb .eq. 0)
584$           then
585                if ((f$search("ssllib:ssl_libcrypto.exe") .nes. "")  .and. -
586                    (f$search("ssllib:ssl_libssl.exe") .nes. ""))
587$                then
588$!                   OpenSSL shared images with "SSL_xxx.EXE names.
589$                    openssl = 2
590$                    libsslshr_line = "ssllib:ssl_libssl_shr.exe/share"
591$                    libcryptoshr_line = "ssllib:ssl_libcrypto_shr.exe/share"
592$                else
593$                    if ((f$search("ssllib:libcrypto.exe") .nes. "") .and. -
594                         (f$search("ssllib:libssl.exe") .nes. ""))
595$                    then
596$!                       OpenSSL shared images with "xxx.EXE names.
597$                        openssl = 3
598$                        libsslshr_line = "ssllib:libssl_shr.exe/share"
599$                        libcryptoshr_line = "ssllib:libcrypto_shr.exe/share"
600$                    endif
601$                endif
602$           endif
603$       endif
604$   endif
605$ endif
606$!
607$! LDAP.
608$!
609$ if f$search("SYS$SHARE:LDAP$SHR.EXE") .eqs. ""
610$ then
611$   ldap = 0
612$ endif
613$ if (ldap .eq. 0)
614$ then
615$!   cc_defs = cc_defs + ", CURL_DISABLE_LDAP=1"
616$ else
617$   'vo_c' "%CURL-I-BLDHPLDAP, building with HP LDAP support"
618$ endif
619$!
620$! KERBEROS
621$ gssrtlshr_line = ""
622$ try_shr = "sys$share:gss$rtl"
623$ if f$search("''try_shr'.exe") .eqs. ""
624$ then
625$   nokerberos = 1
626$ endif
627$ curl_sys_krbinc = ""
628$ if nokerberos .eq. 0
629$ then
630$   'vo_c' "%CURL-I-BLDHPKERBEROS, building with HP KERBEROS support"
631$   curl_sys_krbinc = "sys$sysroot:[kerberos.include]"
632$   gssrtlshr_line = "''try_shr'/share"
633$ endif
634$!
635$!
636$! LIBZ
637$ libzshr_line = ""
638$ try_shr = "gnv$libzshr"
639$ if build_64
640$ then
641$!  First look for 64 bit
642$   if f$search("''try_shr'64") .eqs. ""
643$   then
644$!      Second look for the J.F. Pieronne 64 bit shared image
645$       try_shr = "LIBZ_SHR64"
646$       if f$search(try_shr) .eqs. "" then nozlib = 1
647$   endif
648$ else
649$!  First look for 32 bit
650$   if f$search("''try_shr'32") .eqs. ""
651$   then
652$!      Second look for old 32 bit image
653$       if f$search(try_shr) .eqs. ""
654$       then
655$!          Third look for the J.F. Pieronne 32 bit shared image
656$           try_shr = "LIBZ_SHR32"
657$           if f$search(try_shr) .eqs. "" then nozlib = 1
658$       endif
659$   endif
660$ endif
661$ if f$search(try_shr) .eqs. ""
662$ then
663$   nozlib = 1
664$ endif
665$ curl_sys_zlibinc = ""
666$ if nozlib .eq. 0
667$ then
668$   libzshr_line = "''try_shr'/share"
669$   if f$locate("LIBZ", try_shr) .eq. 0
670$   then
671$       'vo_c' "%CURL-I-BLDJFPLIBZ, building with JFP LIBZ support"
672$       curl_sys_zlibinc = "LIBZ:"
673$   else
674$       'vo_c' "%CURL-I-BLDGNVLIBZ, building with GNV LIBZ support"
675$       curl_sys_zlibinc = "GNV$ZLIB_INCLUDE:"
676$   endif
677$ endif
678$!
679$! Form CC qualifiers.
680$!
681$ cc_defs = "/define = (''cc_defs')"
682$ cc_qual2 = cc_qual2 + " /object = ''objdir'"
683$ cc_qual2 = cc_qual2 + "/nested_include_directory=none"
684$!
685$ 'vo_c' "CC opts:", -
686  " ''cc_defs'", -
687  " ''cc_qual1'", -
688  " ''cc_qual2'"
689$!
690$! Inform the victim of our plans.
691$!
692$ if (hpssl)
693$ then
694$    'vo_c' "%CURL-I-BLDHPSSL, building with HP SSL support"
695$ else
696$    if (openssl .ne. 0)
697$    then
698$       if (openssl .eq. 1)
699$       then
700$          'vo_c' -
701 "%CURL-I-BLDOSSL_OLB, building with OpenSSL (object library) support"
702$       else
703$          'vo_c' -
704 "%CURL-I-BLDOSSL_EXE, building with OpenSSL (shared image) support"
705$       endif
706$    else
707$       'vo_c' "%CURL-I-BLDNOSSL, building with NO SSL support"
708$    endif
709$ endif
710$!
711$! Announce destination and SSL directories.
712$!
713$ 'vo_c' "   OBJDIR = ''objdir'"
714$ 'vo_c' "   EXEDIR = ''exedir'"
715$!
716$ if (openssl .ne. 0)
717$ then
718$   ssllib = f$trnlnm("ssllib")
719$   if (ssllib .eqs. "")
720$   then
721$       ssllib = "(undefined)"
722$   endif
723$   'vo_c' "   SSLLIB = ''ssllib'"
724$!
725$! TODO: Why are we translating the logical name?
726$! The logical aname used to find the shared image should just be used
727$! as translating it could result in the wrong location at run time.
728$   if (openssl .eq. 1)
729$   then
730$       ossl_lib1 = f$trnlnm("ssllib")+ "LIBSSL.OLB"
731$       ossl_lib2 = f$trnlnm("ssllib")+ "LIBCRYPTO.OLB"
732$       msg = "object libraries"
733$   else
734$       if (openssl .eq. 2)
735$       then
736$           ossl_lib1 = f$trnlnm("ssllib")+ "SSL_LIBSSL.EXE"
737$           ossl_lib2 = f$trnlnm("ssllib")+ "SSL_LIBCRYPTO.EXE"
738$       else
739$           ossl_lib1 = f$trnlnm("ssllib")+ "LIBSSL.EXE"
740$           ossl_lib2 = f$trnlnm("ssllib")+ "LIBCRYPTO.EXE"
741$       endif
742$       msg = "shared images"
743$   endif
744$   if ((f$search(ossl_lib1) .eqs. "") .or. -
745        (f$search(ossl_lib2) .eqs. ""))
746$   then
747$       write sys$output "Can't find OpenSSL ''msg':"
748$       write sys$output "   ''ossl_lib1'"
749$       write sys$output "   ''ossl_lib2'"
750$       goto Common_Exit
751$   endif
752$ endif
753$!
754$! Define the "curl" (process) logical name for "#include <curl/xxx.h>".
755$!
756$ curl = f$trnlnm("curl", "LNM$PROCESS")
757$ if (curl .nes. "")
758$ then
759$   write sys$output ""
760$   write sys$output -
761 "Process logical name ""curl"" is already defined, but this procedure"
762$   write sys$output -
763 "would override that definition.  Use a command like"
764$   write sys$output -
765 "      deassign /process curl"
766$   write sys$output -
767 "to cancel that logical name definition, and then and re-run this procedure."
768$   write sys$output ""
769$   goto Common_Exit
770$ endif
771$ curl_logical = top_dev_dir + ".include.curl" + delim
772$ curl_sys_inc2 = curl_logical
773$ curl_sys_inc1 = top_dev_dir + ".include" + delim
774$! define curl 'top_dev_dir'.include.curl'delim'
775$!
776$! Generate config file into the product directory.
777$!
778$! call MoveIfDiff [.lib]config-vms.h 'objdir'curl_config.h
779$!
780$ conf_params = ""
781$ if nossl .ne. 0 then conf_params = conf_params + ",nossl"
782$ if nohpssl .ne. 0 then conf_params = conf_params + ",nohpssl,"
783$ if ldap .eq. 0 then conf_params = conf_params + ",noldap,"
784$ if nozlib .ne. 0 then conf_params = conf_params + ",nozlib,"
785$ if nokerberos .ne. 0 then conf_params = conf_params + ",nokerberos"
786$ conf_params = conf_params - ","
787$!
788$!
789$ new_conf = f$search("''objdir'curl_config.h")
790$ if new_conf .eqs. ""
791$ then
792$!   set ver
793$   write sys$output "Generating curl custom config_vms.h"
794$   @'proc_dev_dir'generate_config_vms_h_curl.com ''conf_params'
795$!
796$   write sys$output "Generating curl_config.h"
797$   conf_in = f$search("[.lib]curl_config*.*in")
798$   if conf_in .eqs. ""
799$   then
800$       write sys$output "Can not find [.lib]curl_config*.*in file!"
801$       goto common_exit
802$   endif
803$   @'proc_dev_dir'config_h.com 'conf_in'
804$   copy config.h 'objdir'curl_config.h
805$   delete config.h;
806$!   set nover
807$ endif
808$!
809$!
810$ on control_y then goto Common_Exit
811$!
812$ set default 'proc_dev_dir'
813$ sys_inc = "''curl_sys_inc1', ''curl_sys_inc2', ''curl_logical'"
814$ if curl_sys_krbinc .nes. ""
815$ then
816$   sys_inc = sys_inc + ",''curl_sys_krbinc'"
817$ endif
818$ if curl_sys_zlibinc .nes. ""
819$ then
820$   sys_inc = sys_inc + ",''curl_sys_zlibinc'"
821$ endif
822$! Build LIB
823$ cc_include = "/include=([-.lib],[-.lib.vtls],[-.packages.vms]"
824$ cc_include = cc_include + ",[-.packages.vms.''arch_name'])"
825$ call build "[--.lib]" "*.c" "''objdir'CURLLIB.OLB" "amigaos, nwlib, nwos"
826$ if ($status .eq. ctrl_y) then goto Common_Exit
827$! Build VTLS
828$ cc_include = "/include=([--.lib.vtls],[--.lib],[--.src]"
829$ cc_include = cc_include + ",[--.packages.vms],[--.packages.vms.''arch_name'])"
830$ call build "[--.lib.vtls]" "*.c" "''objdir'CURLLIB.OLB" "amigaos, nwlib, nwos"
831$! Build SRC
832$ cc_include = "/include=([-.src],[-.lib],[-.lib.vtls]"
833$ cc_include = cc_include + ",[-.packages.vms],[-.packages.vms.''arch_name'])"
834$ call build "[--.src]" "*.c" "''objdir'CURLSRC.OLB"
835$ if ($status .eq. ctrl_y) then goto Common_Exit
836$! Build MSG
837$ call build "[]" "*.msg" "''objdir'CURLSRC.OLB"
838$ if ($status .eq. ctrl_y) then goto Common_Exit
839$!
840$!
841$ if (openssl .ne. 0)
842$ then
843$   if (openssl .eq. 1)
844$   then
845$       'vo_l' "%CURL-I-LINK_OSSL, linking with OpenSSL (object library)"
846$   else
847$       'vo_l' "%CURL-I-LINK_HPSSL, linking with OpenSSL (shared image)"
848$   endif
849$ else
850$   if (hpssl)
851$   then
852$       'vo_l' "%CURL-I-LINK_HPSSL, linking with HP SSL"
853$   else
854$       'vo_l' "%CURL-I-LINK_NOSSL, linking with NO SSL support"
855$   endif
856$ endif
857$!
858$!
859$! GNV helper files for building the test curl binary.
860$!-----------------------------------------------
861$ create 'exedir'gnv$curl.opt
862$ open/append opt 'exedir'gnv$curl.opt
863$ if libzshr_line .nes. "" then write opt libzshr_line
864$ if gssrtlshr_line .nes. "" then write opt gssrtlshr_line
865$ if libcryptoshr_line .nes. "" then write opt libcryptoshr_line
866$ if libsslshr_line .nes. "" then write opt libsslshr_line
867$ close opt
868$!
869$!
870$! Create the libcurl
871$!------------------------------------------------------
872$ create 'exedir'gnv_libcurl_linker.opt
873$ open/append opt 'exedir'gnv_libcurl_linker.opt
874$ if libzshr_line .nes. "" then write opt libzshr_line
875$ if gssrtlshr_line .nes. "" then write opt gssrtlshr_line
876$ if libcryptoshr_line .nes. "" then write opt libcryptoshr_line
877$ if libsslshr_line .nes. "" then write opt libsslshr_line
878$ close opt
879$!
880$!
881$! If we are not on VAX, then we want the debug symbol table in
882$! a separate file.
883$! VAX needs the tool_main unquoted in uppercase,
884$! Alpha and IA64 need tool_main quoted in exact case when parse style is
885$! extended.
886$ link_dsf1 = ""
887$ link_dsf2 = ""
888$ tool_main = "tool_main"
889$ if arch_name .nes. "VAX"
890$ then
891$   if parse_style .eqs. "EXTENDED"
892$   then
893$      tool_main = """tool_main"""
894$   endif
895$   link_dsf1 = "/dsf=" + exedir + "CURL.DSF"
896$   link_dsf2 = "/dsf=" + exedir + "CURL_DEBUG.DSF"
897$ endif
898$ if (list .eq. 0)
899$ then
900$   link_map1 = "/nomap"
901$   link_map2 = "/nomap"
902$ else
903$   link_map1 = "/map=" + exedir + "CURL.MAP"
904$   link_map2 = "/map=" + exedir + "CURL_DEBUG.MAP"
905$ endif
906$!
907$!
908$! Make a normal image.
909$ set ver
910$ link 'link_map1' 'link_dsf1' /executable = 'exedir'CURL.EXE -
911   'objdir'curlsrc.olb /library /include = ('tool_main', curlmsg), -
912   'objdir'curllib.olb /library, -
913   'exedir'gnv$curl.opt/opt
914$!
915$! Also make a debug copy.
916$ link/debug 'link_map2' 'link_dsf2' /executable = 'exedir'CURL_DEBUG.EXE -
917   'objdir'curlsrc.olb /library /include = ('tool_main', curlmsg), -
918   'objdir'curllib.olb /library, -
919   'exedir'gnv$curl.opt/opt
920$ set nover
921$!
922$ goto Common_Exit
923$!
924$! Subroutine to build everything with a filetype passed in via P2 in
925$! the directory passed in via P1 and put it in the object library named
926$! via P3.  Exclude items in P4.
927$!
928$build:   subroutine
929$   build_def = f$environment("default")
930$   on control_y then goto EndLoop ! SS$_CONTROLY
931$   sts = 1 ! SS$_NORMAL.
932$!   set noon
933$   set default 'p1'
934$   search = "sys$disk:" + p2
935$   reset = f$search("reset")
936$   if f$search( p3) .eqs. ""
937$   then
938$       librarian /create /object 'p3'
939$   endif
940$   reject_list__ = "," + f$edit(p4, "COLLAPSE, UPCASE") + ","
941$   reject_list___len = f$length(reject_list__)
942$   reset = f$search( "reset", 1)
943$Loop:
944$   file = f$search( search, 1)
945$   if file .eqs. "" then goto EndLoop
946$!  Skip a name if it's in the P4 exclusion list.
947$   if (p4 .nes. "")
948$   then
949$       name__ = "," + -
950            f$edit(f$parse(file, , , "NAME", "SYNTAX_ONLY"), "UPCASE") + -
951            ","
952$       if (f$locate(name__, reject_list__) .lt. reject_list___len)
953$       then
954$          goto Loop
955$       endif
956$   endif
957$   objfile = f$parse("''objdir'.OBJ;", file)
958$   obj = f$search(objfile, 2)
959$   if (obj .nes. "")
960$   then
961$       if (f$cvtime(f$file(file,"rdt")) .gts. f$cvtime(f$file(obj,"rdt")))
962$       then
963$           call compile 'file'
964$           sts = $status
965$           if .not. sts
966$           then
967$               goto EndLoop
968$           endif
969$           librarian /object 'p3' 'objfile'
970$       else
971$           'vo_o' "%CURL-I-OBJUTD, ", objfile, " is up to date"
972$       endif
973$   else
974$       'vo_o' "%CURL-I-OBJDNE, ", file, " does not exist"
975$       call compile 'file'
976$       sts = $status
977$       if .not. sts
978$       then
979$           goto EndLoop
980$       endif
981$       librarian /object 'p3' 'objfile'
982$   endif
983$   goto Loop
984$EndLoop:
985$!!!    purge
986$   set default 'build_def'
987$   exit 'sts'
988$ endsubroutine   ! Build
989$!
990$! Based on the file TYPE, do the right compile command.
991$! Only C and MSG supported.
992$!
993$compile:   subroutine
994$   on control_y then return ctrl_y ! SS$_CONTROLY
995$!   set noon
996$   file = p1
997$   qual = p2+ p3+ p4+ p5+ p6+ p7+ p8
998$   typ = f$edit(f$parse(file, , , "TYPE"), "UPCASE") - "."
999$   if (typ .eqs. "C")
1000$   then
1001$       'vo_c' "CC (opts) ", file
1002$       define/user curl 'curl_logical'
1003$       if curl_sys_krbinc .nes. "" then define/user gssapi 'curl_sys_krbinc'
1004$       define/user decc$system_include 'sys_inc'
1005$       CC 'cc_defs' -
1006         'cc_qual1' -
1007         'cc_qual2' -
1008         'cc_include' -
1009         'file'
1010$   else
1011$       cmd_msg = "MESSAGE " + msg_qual
1012$       x = cmd_'typ'
1013$       'vo_c' x, " ", file
1014$       'x' 'file'
1015$   endif
1016$ ENDSUBROUTINE   ! Compile
1017$!
1018$! Do a diff of the file specified in P1 with that in P2.  If different
1019$! copy P1 to P2.  This also covers if P2 doesn't exist, but not if P2
1020$! is an invalid filespec.
1021$!
1022$MoveIfDiff:  subroutine
1023$   set NoOn
1024$   define /user_mode sys$error nl:
1025$   define /user_mode sys$output nl:
1026$   differences 'p1' 'p2'
1027$   status = $status
1028$   if (status .ne. %X006C8009) ! if status is not "no diff"
1029$   then
1030$       copy 'p1' 'p2'
1031$       purge /nolog 'p2'
1032$   endif
1033$   on control_y then return ctrl_y ! SS$_CONTROLY
1034$ ENDSUBROUTINE   ! MoveIfDiff
1035$!
1036$Common_Exit:
1037$ set default 'orig_def'
1038$ exit
1039