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$!
152$!===========================================================================
153$!
154$!
155$! Save the original default dev:[dir], and arrange for its restoration
156$! at exit.
157$!------------------------------------------------------------------------
158$ curl = ""
159$ orig_def = f$environment("DEFAULT")
160$ on error then goto Common_Exit
161$ on control_y then goto Common_Exit
162$!
163$ ctrl_y  = 1556
164$ proc = f$environment("PROCEDURE")
165$ proc_fid = f$file_attributes(proc, "FID")
166$ proc_dev = f$parse(proc, , , "DEVICE")
167$ proc_dir = f$parse(proc, , , "DIRECTORY")
168$ proc_name = f$parse(proc, , , "NAME")
169$ proc_type = f$parse(proc, , , "TYPE")
170$ proc_dev_dir = proc_dev + proc_dir
171$!
172$! Have to manually parse the device for a search list.
173$! Can not use the f$parse() as it will return the first name
174$! in the search list.
175$!
176$ orig_def_dev = f$element(0, ":", orig_def) + ":"
177$ if orig_def_dev .eqs. "::" then orig_def_dev = "sys$disk:"
178$ test_proc = orig_def_dev + proc_dir + proc_name + proc_type
179$!
180$! If we can find this file using the default directory
181$! then we know that we should use the original device from the
182$! default directory which could be a search list.
183$!
184$ test_proc_fid = f$file_attributes(test_proc, "FID")
185$!
186$ if (test_proc_fid .eq. proc_fid)
187$ then
188$   proc_dev_dir = orig_def_dev + proc_dir
189$ endif
190$!
191$!
192$! Verbose output message stuff.  Define symbol to "write sys$output" or "!".
193$! vo_c - verbose output for compile
194$! vo_l - link
195$! vo_o - object check
196$!
197$ vo_c := "write sys$output"
198$ vo_l := "write sys$output"
199$ vo_o := "!"
200$!
201$! Determine the main distribution directory ("[--]") in an
202$! ODS5-tolerant (case-insensitive) way.  (We do assume that the only
203$! "]" or ">" is the one at the end.)
204$!
205$! Some non-US VMS installations report ">" for the directory delimiter
206$! so do not assume that it is "]".
207$!
208$ orig_def_len = f$length(orig_def)
209$ delim = f$extract(orig_def_len - 1, 1, orig_def)
210$!
211$ set default 'proc_dev_dir'
212$ set default [--]
213$ base_dev_dir = f$environment("default")
214$ top_dev_dir = base_dev_dir - delim
215$!
216$!
217$!
218$! Define the architecture-specific product file destination directory
219$! name(s).
220$!
221$ parse_style = "TRADITIONAL"
222$ if (f$getsyi("HW_MODEL") .lt. 1024)
223$ then
224$    arch_name = "VAX"
225$ else
226$    arch_name = ""
227$    arch_name = arch_name + f$edit(f$getsyi("ARCH_NAME"), "UPCASE")
228$    if (arch_name .eqs. "") then arch_name = "UNK"
229$!
230$!   Extended parsing option starts with VMS 7.3-1.
231$!   There is no 7.4, so that simplifies the parse a bit.
232$!
233$    node_swvers = f$getsyi("node_swvers")
234$    version_patch = f$extract(1, f$length(node_swvers), node_swvers)
235$    maj_ver = f$element(0, ".", version_patch)
236$    min_ver_patch = f$element(1, ".", version_patch)
237$    min_ver = f$element(0, "-", min_ver_patch)
238$    patch = f$element(1, "-", min_ver_patch)
239$    if patch .eqs. "-" then patch = ""
240$    parse_x = 0
241$    if maj_ver .ges. "8"
242$    then
243$       parse_x = 1
244$    else
245$       if maj_ver .eqs. "7" .and. min_ver .ges. "3" .and. patch .nes. ""
246$       then
247$          parse_x = 1
248$       endif
249$    endif
250$    if parse_x
251$    then
252$       parse_style = f$getjpi("", "parse_style_perm")
253$    endif
254$ endif
255$!
256$ exedir = proc_dev_dir - delim + ".''arch_name'" + delim
257$ lisdir = exedir
258$ objdir = exedir
259$!
260$! When building on a search list, need to do a create to make sure that
261$! the output directory exists, since the clean procedure tries to delete
262$! it.
263$ create/dir 'exedir'/prot=o:rwed
264$!
265$! Interpret command-line options.
266$!
267$ hpssl = 0
268$ ldap = 1
269$ list = 0
270$ full_list = 0
271$ nohpssl = 0
272$ nossl = 0
273$ openssl = 0
274$ osslolb = 0
275$ nozlib = 0
276$ nokerberos = 0
277$ cc_names = "/names=(shortened, as_is)/repository='exedir'
278$ cc_defs = "HAVE_CONFIG_H=1"
279$ cc_list = "/list='objdir'/show=(expan, includ)/machine
280$ cc_full_list = "/list='objdir'/show=(all, nomessages)/machine
281$ link_qual = ""
282$ if arch_name .eqs. "VAX"
283$ then
284$    cc_debug = "/nodebug/optimize"
285$    !cc_defs = cc_defs + ""
286$    cc_float = ""
287$    cc_large = ""
288$ else
289$    cc_debug = "/debug/optimize"
290$    cc_defs = cc_defs + ",_USE_STD_STAT"
291$    cc_float = "/float=ieee/ieee_mode=denorm_results"
292$    cc_large = ",_LARGEFILE"
293$ endif
294$ cc_qual1 = ""
295$ cc_qual2 = ""
296$ if (f$type(CURL_CCDEFS) .nes. "")
297$ then
298$    CURL_CCDEFS = f$edit(CURL_CCDEFS, "TRIM")
299$    cc_defs = cc_defs + ", " + CURL_CCDEFS
300$ endif
301$ msg_qual = "/object = ''objdir'"
302$ ssl_opt = ""
303$!
304$! Allow arguments to be grouped together with comma or separated by spaces
305$! Do no know if we will need more than 8.
306$ args = "," + p1 + "," + p2 + "," + p3 + "," + p4 + ","
307$ args = args + p5 + "," + p6 + "," + p7 + "," + p8 + ","
308$!
309$! Provide lower case version to simplify parsing.
310$ args_lower = f$edit(args, "LOWERCASE,COLLAPSE")
311$!
312$ args_len = f$length(args)
313$ args_lower_len = f$length(args_lower)
314$!
315$ clean = 0
316$ if f$locate(",clean,", args_lower) .lt. args_lower_len
317$ then
318$   clean = 1
319$ endif
320$ clean_all = 0
321$ if f$locate(",clean_all,", args_lower) .lt. args_lower_len
322$ then
323$    clean = 1
324$    clean_all = 1
325$ endif
326$ if f$locate(",realclean,", args_lower) .lt. args_lower_len
327$ then
328$    clean = 1
329$    clean_all = 1
330$ endif
331$!
332$ if clean .ne. 0
333$ then
334$   prods = "''exedir'*.*;*"
335$   if (f$search(prods) .nes. "") then delete /log 'prods'
336$   prods = proc_dev_dir + arch_name + ".DIR;1"
337$   if (f$search(prods) .nes. "") then set prot=o:rwed 'prods'
338$   if (f$search(prods) .nes. "") then delete /log 'prods'
339$   file = "[]config_vms.h"
340$   if f$search(file) .nes. "" then delete/log 'file';*
341$   file = "[]config.h"
342$   if f$search(file) .nes. "" then delete/log 'file';*
343$   file = "[]curl-config."
344$   if f$search(file) .nes. "" then delete/log 'file';*
345$   file = "[]libcurl.pc"
346$   if f$search(file) .nes. "" then delete/log 'file';*
347$   file = "[.lib.cxx_repository]cxx$demangler_db."
348$   if f$search(file) .nes. "" then delete/log 'file';*
349$   file = "[.src.cxx_repository]cxx$demangler_db."
350$   if f$search(file) .nes. "" then delete/log 'file';*
351$   file = "[.lib]config_vms.h"
352$   if f$search(file) .nes. "" then delete/log 'file';*
353$   file = "[...]curl_crtl_init"
354$   if f$search("''file'.lis") .nes. "" then delete/log 'file'.lis;*
355$   if f$search("''file'.obj") .nes. "" then delete/log 'file'.obj;*
356$   file = "[...]gnv$curlmsg"
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$   if f$search("''file'.exe") .nes. "" then delete/log 'file'.exe;*
360$   file = "[...]curlmsg"
361$   if f$search("''file'.lis") .nes. "" then delete/log 'file'.lis;*
362$   if f$search("''file'.obj") .nes. "" then delete/log 'file'.obj;*
363$   if f$search("''file'.exe") .nes. "" then delete/log 'file'.exe;*
364$   file = "[...]report_openssl_version"
365$   if f$search("''file'.lis") .nes. "" then delete/log 'file'.lis;*
366$   if f$search("''file'.obj") .nes. "" then delete/log 'file'.obj;*
367$   if f$search("''file'.exe") .nes. "" then delete/log 'file'.exe;*
368$   file = "[...]hp_ssl_release_info.txt"
369$   if f$search(file) .nes. "" then delete/log 'file';*
370$   file = "[...]gnv_libcurl_xfer.mar_exact"
371$   if f$search(file) .nes. "" then delete/log 'file';*
372$   file = "[...]gnv_libcurl_xfer"
373$   if f$search("''file'.lis") .nes. "" then delete/log 'file'.lis;*
374$   if f$search("''file'.obj") .nes. "" then delete/log 'file'.obj;*
375$   if f$search("''file'.opt") .nes. "" then delete/log 'file'.opt;*
376$   file = "[...]curl-*_original_src.bck"
377$   if f$search(file) .nes. "" then delete/log 'file';*
378$   file = "[...]curl_d-*_original_src.bck"
379$   if f$search(file) .nes. "" then delete/log 'file';*
380$   file = "[...]curl-*_vms_src.bck"
381$   if f$search(file) .nes. "" then delete/log 'file';*
382$   file = "[...]curl_d-*_vms_src.bck"
383$   if f$search(file) .nes. "" then delete/log 'file';*
384$   file = "[...]curl-*.release_notes"
385$   if f$search(file) .nes. "" then delete/log 'file';*
386$   file = "[...]curl_d-*.release_notes"
387$   if f$search(file) .nes. "" then delete/log 'file';*
388$   file = "[...]*curl*.pcsi$desc"
389$   if f$search(file) .nes. "" then delete/log 'file';*
390$   file = "[...]*curl_d*.pcsi$desc"
391$   if f$search(file) .nes. "" then delete/log 'file';*
392$   file = "[...]*curl*.pcsi$text"
393$   if f$search(file) .nes. "" then delete/log 'file';*
394$   file = "[...]*curl_d*.pcsi$text"
395$   if f$search(file) .nes. "" then delete/log 'file';*
396$!
397$   if clean_all .eq. 0 then goto Common_Exit
398$ endif
399$!
400$!
401$ if clean_all .ne. 0
402$ then
403$   file = "[...]gnv$libcurl"
404$   if f$search("''file'.exe") .nes. "" then delete/log 'file'.exe;*
405$   if f$search("''file'.map") .nes. "" then delete/log 'file'.map;*
406$   if f$search("''file'.dsf") .nes. "" then delete/log 'file'.dsf;*
407$   file = "[.src]curl"
408$   if f$search("''file'.exe") .nes. "" then delete/log 'file'.exe;*
409$   if f$search("''file'.map") .nes. "" then delete/log 'file'.map;*
410$   if f$search("''file'.dsf") .nes. "" then delete/log 'file'.dsf;*
411$   prods = proc_dev_dir - delim + ".ALPHA" + delim + "*.*;*"
412$   if (f$search(prods) .nes. "") then delete /log 'prods'
413$   prods = proc_dev_dir + "ALPHA" + ".DIR;1"
414$   if (f$search(prods) .nes. "") then set prot=o:rwed 'prods'
415$   if (f$search(prods) .nes. "") then delete /log 'prods'
416$   prods = proc_dev_dir - delim + ".IA64" + delim + "*.*;*"
417$   if (f$search(prods) .nes. "") then delete /log 'prods'
418$   prods = proc_dev_dir + "IA64" + ".DIR;1"
419$   if (f$search(prods) .nes. "") then set prot=o:rwed 'prods'
420$   if (f$search(prods) .nes. "") then delete /log 'prods'
421$   prods = proc_dev_dir - delim + ".VAX" + delim + "*.*;*"
422$   if (f$search(prods) .nes. "") then delete /log 'prods'
423$   prods = proc_dev_dir + "VAX"+ ".DIR;1"
424$   if (f$search(prods) .nes. "") then set prot=o:rwed 'prods'
425$   if (f$search(prods) .nes. "") then delete /log 'prods'
426$   file = "[...]macro32_exactcase"
427$   if f$search("''file'.exe") .nes. "" then delete/log 'file'.exe;*
428$   if f$search("''file'.jnl") .nes. "" then delete/log 'file'.jnl;*
429$   goto Common_Exit
430$ endif
431$!
432$ build_64 = 0
433$ if f$locate(",64,", args_lower) .lt. args_lower_len
434$ then
435$   cc_qual1 = cc_qual1 + " /POINTER = 64"
436$   build_64 = 1
437$ endif
438$!
439$ args_loc = f$locate(",ccqual=", args_lower)
440$ if args_loc .lt. args_lower_len
441$ then
442$   arg = f$extract(args_loc + 1, args_lower_len, args_lower)
443$   arg_val = f$element(0, ",", arg)
444$   cc_qual2 = f$element(1, "=", arg_val);
445$ endif
446$!
447$! On Alpha/IA64 no size penalty for compiling /debug/optimize
448$! by default.
449$ if f$locate(",debug,", args_lower) .lt. args_lower_len
450$ then
451$   cc_debug = "/debug/nooptimize"
452$ endif
453$!
454$! We normally want IEEE float if it is available.  Programs that are
455$! calling libcurl will typically prefer IEEE behavior, unless on the
456$! VAX where we have no choice.
457$!
458$ if f$locate(",noieee,", args_lower) .lt. args_lower_len
459$ then
460$   cc_float = ""
461$ endif
462$!
463$! Normally we want large file if it is available.
464$ if f$locate(",nolarge,", args_lower) .lt. args_lower_len
465$ then
466$   write sys$output "Handling of large files disabled."
467$   cc_large = ""
468$ endif
469$ if cc_large .nes. ""
470$ then
471$   cc_defs = cc_defs + cc_large
472$ endif
473$!
474$ if f$locate(",noldap,", args_lower) .lt. args_lower_len
475$ then
476$   ldap = 0
477$ endif
478$!
479$ if f$locate(",list,", args_lower) .lt. args_lower_len
480$ then
481$   list = 1
482$ endif
483$ if f$locate(",fulllist,", args_lower) .lt. args_lower_len
484$ then
485$    list = 1
486$    full_list = 1
487$ endif
488$!
489$ if f$locate(",nohpssl,", args_lower) .lt. args_lower_len
490$ then
491$   nohpssl = 1
492$ endif
493$!
494$ if f$locate(",nossl,", args_lower) .lt. args_lower_len
495$ then
496$   nossl = 1
497$ endif
498$!
499$ if f$locate(",osslolb,", args_lower) .lt. args_lower_len
500$ then
501$    osslolb = 1
502$ endif
503$!
504$ if f$locate(",nozlib,", args_lower) .lt. args_lower_len
505$ then
506$   nozlib = 1
507$ endif
508$!
509$ if f$locate(",nokerberos,", args_lower) .lt. args_lower_len
510$ then
511$   nokerberos = 1
512$ endif
513$!
514$!
515$! CC /LIST, LINK /MAP, and MESSAGE /LIST are defaults in batch mode,
516$! so be explicit when they're not desired.
517$!
518$
519$ if list .eq. 0
520$ then
521$   cc_qual1 = cc_qual1 + "/nolist"
522$   msg_qual = msg_qual + "/nolist"
523$ else
524$   msg_qual = msg_qual + "/list='objdir'"
525$   if (full_list .ne. 0)
526$   then
527$       cc_qual1 = cc_qual1 + cc_full_list
528$   else
529$       cc_qual1 = cc_qual1 + cc_list
530$   endif
531$ endif
532$ cc_qual1 = cc_qual1 + cc_names + cc_float + cc_debug
533$!
534$! Create product directory, if needed.
535$!
536$ if (f$search(proc_dev_dir + arch_name + ".DIR;1") .eqs. "")
537$ then
538$    create /directory 'exedir'
539$ endif
540$!
541$! Detect available (but not prohibited) SSL software.
542$!
543$ libsslshr_line = ""
544$ libcryptoshr_line = ""
545$ if (.not. nossl)
546$ then
547$   if (f$trnlnm("OPENSSL") .nes. "")
548$   then
549$!        cc_defs = cc_defs + ", USE_SSLEAY=1"
550$        if ((f$trnlnm("SSL$INCLUDE") .nes. "") .and. (.not. nohpssl))
551$        then
552$!          Use HP SSL.
553$           hpssl = 1
554$!
555$!          Older SSL only has lib*_shr32 images
556$!-----------------------------------------------
557$           libsslshr = "sys$share:ssl$libssl_shr"
558$           if (f$search("''libsslshr'.exe") .eqs. "") .or. (.not. build_64)
559$           then
560$               libsslshr = libsslshr + "32"
561$           endif
562$           libcryptoshr = "sys$share:ssl$libcrypto_shr"
563$           if (f$search("''libcryptoshr'.exe") .eqs. "") .or. (.not. build_64)
564$           then
565$               libcryptoshr = libcryptoshr + "32"
566$           endif
567$           libsslshr_line = "''libsslshr'.exe/share"
568$           libcryptoshr_line = "''libcryptoshr'.exe/share"
569$       else
570$!          Use OpenSSL.  Assume object libraries, unless shared images
571$!          are found (and not prohibited).
572$!          TODO: We do not know how to automatically choose based on the
573$!          pointer size.
574$!
575$           openssl = 1
576$           libsslshr_line = "ssllib:libssl.olb/lib"
577$           libcryptoshr_line = "ssllib:libcrypto.olb/lib"
578$           ssl_opt = ", ssllib:libssl.olb /library" + -
579                ", ssllib:libcrypto.olb /library"
580$           if (osslolb .eq. 0)
581$           then
582                if ((f$search("ssllib:ssl_libcrypto.exe") .nes. "")  .and. -
583                    (f$search("ssllib:ssl_libssl.exe") .nes. ""))
584$                then
585$!                   OpenSSL shared images with "SSL_xxx.EXE names.
586$                    openssl = 2
587$                    libsslshr_line = "ssllib:ssl_libssl_shr.exe/share"
588$                    libcryptoshr_line = "ssllib:ssl_libcrypto_shr.exe/share"
589$                else
590$                    if ((f$search("ssllib:libcrypto.exe") .nes. "") .and. -
591                         (f$search("ssllib:libssl.exe") .nes. ""))
592$                    then
593$!                       OpenSSL shared images with "xxx.EXE names.
594$                        openssl = 3
595$                        libsslshr_line = "ssllib:libssl_shr.exe/share"
596$                        libcryptoshr_line = "ssllib:libcrypto_shr.exe/share"
597$                    endif
598$                endif
599$           endif
600$       endif
601$   endif
602$ endif
603$!
604$! LDAP.
605$!
606$ if f$search("SYS$SHARE:LDAP$SHR.EXE") .eqs. ""
607$ then
608$   ldap = 0
609$ endif
610$ if (ldap .eq. 0)
611$ then
612$!   cc_defs = cc_defs + ", CURL_DISABLE_LDAP=1"
613$ else
614$   'vo_c' "%CURL-I-BLDHPLDAP, building with HP LDAP support"
615$ endif
616$!
617$! KERBEROS
618$ gssrtlshr_line = ""
619$ try_shr = "sys$share:gss$rtl"
620$ if f$search("''try_shr'.exe") .eqs. ""
621$ then
622$   nokerberos = 1
623$ endif
624$ curl_sys_krbinc = ""
625$ if nokerberos .eq. 0
626$ then
627$   'vo_c' "%CURL-I-BLDHPKERBEROS, building with HP KERBEROS support"
628$   curl_sys_krbinc = "sys$sysroot:[kerberos.include]"
629$   gssrtlshr_line = "''try_shr'/share"
630$ endif
631$!
632$!
633$! LIBZ
634$ libzshr_line = ""
635$ try_shr = "gnv$libzshr"
636$ if build_64
637$ then
638$!  First look for 64 bit
639$   if f$search("''try_shr'64") .eqs. ""
640$   then
641$!      Second look for the J.F. Pieronne 64 bit shared image
642$       try_shr = "LIBZ_SHR64"
643$       if f$search(try_shr) .eqs. "" then nozlib = 1
644$   endif
645$ else
646$!  First look for 32 bit
647$   if f$search("''try_shr'32") .eqs. ""
648$   then
649$!      Second look for old 32 bit image
650$       if f$search(try_shr) .eqs. ""
651$       then
652$!          Third look for the J.F. Pieronne 32 bit shared image
653$           try_shr = "LIBZ_SHR32"
654$           if f$search(try_shr) .eqs. "" then nozlib = 1
655$       endif
656$   endif
657$ endif
658$ if f$search(try_shr) .eqs. ""
659$ then
660$   nozlib = 1
661$ endif
662$ curl_sys_zlibinc = ""
663$ if nozlib .eq. 0
664$ then
665$   libzshr_line = "''try_shr'/share"
666$   if f$locate("LIBZ", try_shr) .eq. 0
667$   then
668$       'vo_c' "%CURL-I-BLDJFPLIBZ, building with JFP LIBZ support"
669$       curl_sys_zlibinc = "LIBZ:"
670$   else
671$       'vo_c' "%CURL-I-BLDGNVLIBZ, building with GNV LIBZ support"
672$       curl_sys_zlibinc = "GNV$ZLIB_INCLUDE:"
673$   endif
674$ endif
675$!
676$! Form CC qualifiers.
677$!
678$ cc_defs = "/define = (''cc_defs')"
679$ cc_qual2 = cc_qual2 + " /object = ''objdir'"
680$ cc_qual2 = cc_qual2 + " /include = ([-.lib], [-.src],"
681$ cc_qual2 = cc_qual2 + " [-.packages.vms], [-.packages.vms.''arch_name'])"
682$ cc_qual2 = cc_qual2 + "/nested_include_directory=none"
683$!
684$ 'vo_c' "CC opts:", -
685  " ''cc_defs'", -
686  " ''cc_qual1'", -
687  " ''cc_qual2'"
688$!
689$! Inform the victim of our plans.
690$!
691$ if (hpssl)
692$ then
693$    'vo_c' "%CURL-I-BLDHPSSL, building with HP SSL support"
694$ else
695$    if (openssl .ne. 0)
696$    then
697$       if (openssl .eq. 1)
698$       then
699$          'vo_c' -
700 "%CURL-I-BLDOSSL_OLB, building with OpenSSL (object library) support"
701$       else
702$          'vo_c' -
703 "%CURL-I-BLDOSSL_EXE, building with OpenSSL (shared image) support"
704$       endif
705$    else
706$       'vo_c' "%CURL-I-BLDNOSSL, building with NO SSL support"
707$    endif
708$ endif
709$!
710$! Announce destination and SSL directories.
711$!
712$ 'vo_c' "   OBJDIR = ''objdir'"
713$ 'vo_c' "   EXEDIR = ''exedir'"
714$!
715$ if (openssl .ne. 0)
716$ then
717$   ssllib = f$trnlnm("ssllib")
718$   if (ssllib .eqs. "")
719$   then
720$       ssllib = "(undefined)"
721$   endif
722$   'vo_c' "   SSLLIB = ''ssllib'"
723$!
724$! TODO: Why are we translating the logical name?
725$! The logical aname used to find the shared image should just be used
726$! as translating it could result in the wrong location at run time.
727$   if (openssl .eq. 1)
728$   then
729$       ossl_lib1 = f$trnlnm("ssllib")+ "LIBSSL.OLB"
730$       ossl_lib2 = f$trnlnm("ssllib")+ "LIBCRYPTO.OLB"
731$       msg = "object libraries"
732$   else
733$       if (openssl .eq. 2)
734$       then
735$           ossl_lib1 = f$trnlnm("ssllib")+ "SSL_LIBSSL.EXE"
736$           ossl_lib2 = f$trnlnm("ssllib")+ "SSL_LIBCRYPTO.EXE"
737$       else
738$           ossl_lib1 = f$trnlnm("ssllib")+ "LIBSSL.EXE"
739$           ossl_lib2 = f$trnlnm("ssllib")+ "LIBCRYPTO.EXE"
740$       endif
741$       msg = "shared images"
742$   endif
743$   if ((f$search(ossl_lib1) .eqs. "") .or. -
744        (f$search(ossl_lib2) .eqs. ""))
745$   then
746$       write sys$output "Can't find OpenSSL ''msg':"
747$       write sys$output "   ''ossl_lib1'"
748$       write sys$output "   ''ossl_lib2'"
749$       goto Common_Exit
750$   endif
751$ endif
752$!
753$! Define the "curl" (process) logical name for "#include <curl/xxx.h>".
754$!
755$ curl = f$trnlnm("curl", "LNM$PROCESS")
756$ if (curl .nes. "")
757$ then
758$   write sys$output ""
759$   write sys$output -
760 "Process logical name ""curl"" is already defined, but this procedure"
761$   write sys$output -
762 "would override that definition.  Use a command like"
763$   write sys$output -
764 "      deassign /process curl"
765$   write sys$output -
766 "to cancel that logical name definition, and then and re-run this procedure."
767$   write sys$output ""
768$   goto Common_Exit
769$ endif
770$ curl_logical = top_dev_dir + ".include.curl" + delim
771$ curl_sys_inc2 = curl_logical
772$ curl_sys_inc1 = top_dev_dir + ".include" + delim
773$! define curl 'top_dev_dir'.include.curl'delim'
774$!
775$! Generate config file into the product directory.
776$!
777$! call MoveIfDiff [.lib]config-vms.h 'objdir'curl_config.h
778$!
779$ conf_params = ""
780$ if nossl .ne. 0 then conf_params = conf_params + ",nossl"
781$ if nohpssl .ne. 0 then conf_params = conf_params + ",nohpssl,"
782$ if ldap .eq. 0 then conf_params = conf_params + ",noldap,"
783$ if nozlib .ne. 0 then conf_params = conf_params + ",nozlib,"
784$ if nokerberos .ne. 0 then conf_params = conf_params + ",nokerberos"
785$ conf_params = conf_params - ","
786$!
787$!
788$ new_conf = f$search("''objdir'curl_config.h")
789$ if new_conf .eqs. ""
790$ then
791$!   set ver
792$   write sys$output "Generating curl custom config_vms.h"
793$   @'proc_dev_dir'generate_config_vms_h_curl.com ''conf_params'
794$!
795$   write sys$output "Generating curl_config.h"
796$   conf_in = f$search("[.lib]curl_config*.*in")
797$   if conf_in .eqs. ""
798$   then
799$       write sys$output "Can not find [.lib]curl_config*.*in file!"
800$       goto common_exit
801$   endif
802$   @'proc_dev_dir'config_h.com 'conf_in'
803$   copy config.h 'objdir'curl_config.h
804$   delete config.h;
805$!   set nover
806$ endif
807$!
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$ call build "[--.lib]" "*.c" "''objdir'CURLLIB.OLB" "amigaos, nwlib, nwos"
823$ if ($status .eq. ctrl_y) then goto Common_Exit
824$ call build "[--.src]" "*.c" "''objdir'CURLSRC.OLB"
825$ if ($status .eq. ctrl_y) then goto Common_Exit
826$ call build "[]" "*.msg" "''objdir'CURLSRC.OLB"
827$ if ($status .eq. ctrl_y) then goto Common_Exit
828$!
829$!
830$ if (openssl .ne. 0)
831$ then
832$   if (openssl .eq. 1)
833$   then
834$       'vo_l' "%CURL-I-LINK_OSSL, linking with OpenSSL (object library)"
835$   else
836$       'vo_l' "%CURL-I-LINK_HPSSL, linking with OpenSSL (shared image)"
837$   endif
838$ else
839$   if (hpssl)
840$   then
841$       'vo_l' "%CURL-I-LINK_HPSSL, linking with HP SSL"
842$   else
843$       'vo_l' "%CURL-I-LINK_NOSSL, linking with NO SSL support"
844$   endif
845$ endif
846$!
847$!
848$! GNV helper files for building the test curl binary.
849$!-----------------------------------------------
850$ create 'exedir'gnv$curl.opt
851$ open/append opt 'exedir'gnv$curl.opt
852$ if libzshr_line .nes. "" then write opt libzshr_line
853$ if gssrtlshr_line .nes. "" then write opt gssrtlshr_line
854$ if libcryptoshr_line .nes. "" then write opt libcryptoshr_line
855$ if libsslshr_line .nes. "" then write opt libsslshr_line
856$ close opt
857$!
858$!
859$! Create the libcurl
860$!------------------------------------------------------
861$ create 'exedir'gnv_libcurl_linker.opt
862$ open/append opt 'exedir'gnv_libcurl_linker.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$! If we are not on VAX, then we want the debug symbol table in
871$! a separate file.
872$! VAX needs the tool_main unquoted in uppercase,
873$! Alpha and IA64 need tool_main quoted in exact case when parse style is
874$! extended.
875$ link_dsf1 = ""
876$ link_dsf2 = ""
877$ tool_main = "tool_main"
878$ if arch_name .nes. "VAX"
879$ then
880$   if parse_style .eqs. "EXTENDED"
881$   then
882$      tool_main = """tool_main"""
883$   endif
884$   link_dsf1 = "/dsf=" + exedir + "CURL.DSF"
885$   link_dsf2 = "/dsf=" + exedir + "CURL_DEBUG.DSF"
886$ endif
887$ if (list .eq. 0)
888$ then
889$   link_map1 = "/nomap"
890$   link_map2 = "/nomap"
891$ else
892$   link_map1 = "/map=" + exedir + "CURL.MAP"
893$   link_map2 = "/map=" + exedir + "CURL_DEBUG.MAP"
894$ endif
895$!
896$!
897$! Make a normal image.
898$ set ver
899$ link 'link_map1' 'link_dsf1' /executable = 'exedir'CURL.EXE -
900   'objdir'curlsrc.olb /library /include = ('tool_main', curlmsg), -
901   'objdir'curllib.olb /library, -
902   'exedir'gnv$curl.opt/opt
903$!
904$! Also make a debug copy.
905$ link/debug 'link_map2' 'link_dsf2' /executable = 'exedir'CURL_DEBUG.EXE -
906   'objdir'curlsrc.olb /library /include = ('tool_main', curlmsg), -
907   'objdir'curllib.olb /library, -
908   'exedir'gnv$curl.opt/opt
909$ set nover
910$!
911$ goto Common_Exit
912$!
913$! Subroutine to build everything with a filetype passed in via P2 in
914$! the directory passed in via P1 and put it in the object library named
915$! via P3.  Exclude items in P4.
916$!
917$build:   subroutine
918$   build_def = f$environment("default")
919$   on control_y then goto EndLoop ! SS$_CONTROLY
920$   sts = 1 ! SS$_NORMAL.
921$!   set noon
922$   set default 'p1'
923$   search = p2
924$   reset = f$search("reset")
925$   if f$search( p3) .eqs. ""
926$   then
927$       librarian /create /object 'p3'
928$   endif
929$   reject_list__ = "," + f$edit(p4, "COLLAPSE, UPCASE") + ","
930$   reject_list___len = f$length(reject_list__)
931$   reset = f$search( "reset", 1)
932$Loop:
933$   file = f$search( search, 1)
934$   if file .eqs. "" then goto EndLoop
935$!  Skip a name if it's in the P4 exclusion list.
936$   if (p4 .nes. "")
937$   then
938$       name__ = "," + -
939            f$edit(f$parse(file, , , "NAME", "SYNTAX_ONLY"), "UPCASE") + -
940            ","
941$       if (f$locate(name__, reject_list__) .lt. reject_list___len)
942$       then
943$          goto Loop
944$       endif
945$   endif
946$   objfile = f$parse("''objdir'.OBJ;", file)
947$   obj = f$search(objfile, 2)
948$   if (obj .nes. "")
949$   then
950$       if (f$cvtime(f$file(file,"rdt")) .gts. f$cvtime(f$file(obj,"rdt")))
951$       then
952$           call compile 'file'
953$           sts = $status
954$           if .not. sts
955$           then
956$               goto EndLoop
957$           endif
958$           librarian /object 'p3' 'objfile'
959$       else
960$           'vo_o' "%CURL-I-OBJUTD, ", objfile, " is up to date"
961$       endif
962$   else
963$       'vo_o' "%CURL-I-OBJDNE, ", file, " does not exist"
964$       call compile 'file'
965$       sts = $status
966$       if .not. sts
967$       then
968$           goto EndLoop
969$       endif
970$       librarian /object 'p3' 'objfile'
971$   endif
972$   goto Loop
973$EndLoop:
974$!!!    purge
975$   set default 'build_def'
976$   exit 'sts'
977$ endsubroutine   ! Build
978$!
979$! Based on the file TYPE, do the right compile command.
980$! Only C and MSG supported.
981$!
982$compile:   subroutine
983$   on control_y then return ctrl_y ! SS$_CONTROLY
984$!   set noon
985$   file = p1
986$   qual = p2+ p3+ p4+ p5+ p6+ p7+ p8
987$   typ = f$edit(f$parse(file, , , "TYPE"), "UPCASE") - "."
988$   if (typ .eqs. "C")
989$   then
990$       'vo_c' "CC (opts) ", file
991$       define/user curl 'curl_logical'
992$       if curl_sys_krbinc .nes. "" then define/user gssapi 'curl_sys_krbinc'
993$       define/user decc$system_include 'sys_inc'
994$       CC 'cc_defs' -
995         'cc_qual1' -
996         'cc_qual2' -
997         'file'
998$   else
999$       cmd_msg = "MESSAGE " + msg_qual
1000$       x = cmd_'typ'
1001$       'vo_c' x, " ", file
1002$       'x' 'file'
1003$   endif
1004$ ENDSUBROUTINE   ! Compile
1005$!
1006$! Do a diff of the file specified in P1 with that in P2.  If different
1007$! copy P1 to P2.  This also covers if P2 doesn't exist, but not if P2
1008$! is an invalid filespec.
1009$!
1010$MoveIfDiff:  subroutine
1011$   set NoOn
1012$   define /user_mode sys$error nl:
1013$   define /user_mode sys$output nl:
1014$   differences 'p1' 'p2'
1015$   status = $status
1016$   if (status .ne. %X006C8009) ! if status is not "no diff"
1017$   then
1018$       copy 'p1' 'p2'
1019$       purge /nolog 'p2'
1020$   endif
1021$   on control_y then return ctrl_y ! SS$_CONTROLY
1022$ ENDSUBROUTINE   ! MoveIfDiff
1023$!
1024$Common_Exit:
1025$ set default 'orig_def'
1026$ exit
1027