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$! CCQUAL=x Add "x" to the C compiler qualifiers. 22$! DEBUG Compile and link with debug. 23$! IEEE Use IEEE floating point. (Alpha.) 24$! LARGE Enable large-file support. (Non-VAX, VMS >= V7.2.) 25$! LDAP Enable LDAP support. 26$! LIST Create C compiler listings and linker maps. 27$! NOHPSSL Don't use HP SSL, even if available. 28$! NOSSL Don't use any SSL, even if available. 29$! OSSLOLB Use OpenSSL object libraries (.OLB), even if shared 30$! images (.EXE) are available. 31$! 32$! DCL Symbols: 33$! 34$! CURL_CCDEFS="c_macro_1=value1 [, c_macro_2=value2 [...]]" 35$! Compile with these additional C macros defined. 36$! 37$! Revisions: 38$! 39$! 2-DEC-2003, MSK, the "original" version. 40$! It works for me. Your mileage may vary. 41$! 13-JAN-2004, MSK, moved this procedure to the [.packages.vms] directory 42$! and updated it to do hardware dependent builds. 43$! 29-JAN-2004, MSK, moved logical defines into defines.com 44$! 6-FEB-2004, MSK, put in various SSL support bits 45$! 9-MAR-2004, MSK, the config-vms.h* files are now copied to the lib and 46$! src directories as curl_config.h. 47$! 15-MAR-2004, MSK, All of the curlmsg*.* files have also been moved to 48$! this build directory. They will be copied to the src 49$! directory before build. The .msg file will be compiled 50$! to get the .obj for messages, but the .h and .sdl files 51$! are not automatically created since they partly rely on 52$! the freeware SDL tool. 53$! 8-FEB-2005, MSK, merged the two config-vms.h* files into one that uses 54$! USE_SSLEAY to define if the target has SSL support built 55$! in. Changed the cc/define parameter accordingly. 56$! 11-FEB-2005, MSK, If [--.LIB]AMIGAOS.C and NWLIB.C are there, rename them 57$! 23-MAR-2005, MSK, relocated cc_qual define so that DEBUG option would work 58$! 25-APR-2007, STL, allow compilation in 64-bit mode. 59$! 13-DEC-2009. SMS, Changed to skip unwanted source files without 60$! renaming the original files. 61$! Eliminated needless, persistent logical names. 62$! Added CURL_CCDEFS DCL symbol for user-specified C 63$! macro definitions. 64$! Added CLEAN and CLEAN_ALL options. 65$! Added CCQUAL option for user-specified C compiler 66$! qualifiers. 67$! Added IEEE option for IEEE floating point (Alpha). 68$! Added LARGE option for large-file support. 69$! Added OSSLOLB option, and support for OpenSSL 70$! shared images. 71$! Changed to put listing and map files into lisdir:. 72$! Changed to avoid case confusion on ODS5 disks. 73$! Added more default dev:[dir] save+restore. 74$! Moved remaining "defines.com" code (back) into 75$! here, eliminating the hard-coded OpenSSL nonsense. 76$! Changed to use F$GETSYI( "ARCH_NAME") (or 77$! equivalent) to name architecture-specific product 78$! file destination directory, and to create the 79$! directory if needed (obviating inclusion of these 80$! directories and dummy files in the distribution 81$! kit). 82$! Changed the "compile" subroutine to break the CC 83$! command across multiple lines to avoid DCL 84$! line-too-long problems. 85$! Changed "vo_c" messages to show the CC qualifiers 86$! once, not with every compile command. 87$! 88$! 89$! Save the original default dev:[dir], and arrange for its restoration 90$! at exit. 91$! 92$ curl = "" 93$ orig_def = f$environment( "DEFAULT") 94$ on error then goto Common_Exit 95$ on control_y then goto Common_Exit 96$! 97$ ctrl_y = 1556 98$ proc = f$environment( "PROCEDURE") 99$ proc_dev_dir = - 100 f$parse( proc, , , "DEVICE")+ f$parse( proc, , , "DIRECTORY") 101$! 102$! Verbose output message stuff. Define symbol to "write sys$output" or "!". 103$! vo_c - verbose output for compile 104$! vo_l - link 105$! vo_o - object check 106$! 107$ vo_c = "write sys$output" 108$ vo_l = "write sys$output" 109$ vo_o = "!" 110$! 111$! Determine the main distribution directory ("[--]") in an 112$! ODS5-tolerant (case-insensitive) way. (We do assume that the only 113$! "]" is the one at the end.) 114$! 115$ set default 'proc_dev_dir' 116$ set default [--] 117$ top_dev_dir = f$environment( "DEFAULT")- "]" 118$! 119$! Define the architecture-specific product file destination directory 120$! name(s). 121$! 122$ if (f$getsyi( "HW_MODEL") .lt. 1024) 123$ then 124$ arch_name = "VAX" 125$ else 126$ arch_name = "" 127$ arch_name = arch_name+ f$edit( f$getsyi( "ARCH_NAME"), "UPCASE") 128$ if (arch_name .eqs. "") then arch_name = "UNK" 129$ endif 130$! 131$ exedir = proc_dev_dir- "]"+ ".''arch_name']" 132$ lisdir = exedir 133$ objdir = exedir 134$! 135$! Interpret command-line options. 136$! 137$ hpssl = 0 138$ ldap = 0 139$ list = 0 140$ nohpssl = 0 141$ nossl = 0 142$ openssl = 0 143$ osslolb = 0 144$ cc_qual1 = "" 145$ cc_qual2 = "" 146$ cc_defs = "HAVE_CONFIG_H=1" 147$ if (f$type( CURL_CCDEFS) .nes. "") 148$ then 149$ CURL_CCDEFS = f$edit( CURL_CCDEFS, "TRIM") 150$ cc_defs = cc_defs+ ", "+ CURL_CCDEFS 151$ endif 152$ link_qual = "" 153$ msg_qual = "/object = ''objdir'" 154$ ssl_opt = "" 155$! 156$ arg = 1 157$arg_loop: 158$ p = "p''arg'" 159$ arg_val = 'p' 160$ if (arg_val .eqs. "") then goto arg_loop_out 161$ arg_val = f$edit( arg_val, "upcase") 162$! 163$ if (arg_val .eqs. "CLEAN") 164$ then 165$ prods = "''exedir'*.*;*" 166$ if (f$search( prods) .nes. "") then delete /log 'prods' 167$ prods = proc_dev_dir+ arch_name+ ".DIR;1" 168$ if (f$search( prods) .nes. "") then delete /log 'prods' 169$ goto Common_Exit 170$ endif 171$! 172$ if (arg_val .eqs. "CLEAN_ALL") 173$ then 174$ prods = proc_dev_dir- "]"+ ".ALPHA]*.*;*" 175$ if (f$search( prods) .nes. "") then delete /log 'prods' 176$ prods = proc_dev_dir+ "ALPHA"+ ".DIR;1" 177$ if (f$search( prods) .nes. "") then delete /log 'prods' 178$ prods = proc_dev_dir- "]"+ ".IA64]*.*;*" 179$ if (f$search( prods) .nes. "") then delete /log 'prods' 180$ prods = proc_dev_dir+ "IA64"+ ".DIR;1" 181$ if (f$search( prods) .nes. "") then delete /log 'prods' 182$ prods = proc_dev_dir- "]"+ ".VAX]*.*;*" 183$ if (f$search( prods) .nes. "") then delete /log 'prods' 184$ prods = proc_dev_dir+ "VAX"+ ".DIR;1" 185$ if (f$search( prods) .nes. "") then delete /log 'prods' 186$ goto Common_Exit 187$ endif 188$! 189$ if (arg_val .eqs. "64") 190$ then 191$ cc_qual1 = cc_qual1+ " /POINTER = 64" 192$ goto arg_loop_end 193$ endif 194$! 195$ if (f$extract( 0, 6, arg_val) .eqs. "CCQUAL") 196$ then 197$ opts = f$edit( arg_val, "COLLAPSE") 198$ eq = f$locate( "=", opts) 199$ cc_qual2 = f$extract( (eq+ 1), 1000, opts) 200$ goto arg_loop_end 201$ endif 202$! 203$ if (arg_val .eqs. "DEBUG") 204$ then 205$ cc_qual1 = cc_qual1+ " /debug /nooptimize" 206$ link_qual = link_qual+ " /debug" 207$ goto arg_loop_end 208$ endif 209$! 210$ if (arg_val .eqs. "IEEE") 211$ then 212$ cc_qual1 = cc_qual1+ " /FLOAT = IEEE_FLOAT" 213$ goto arg_loop_end 214$ endif 215$! 216$ if (arg_val .eqs. "LARGE") 217$ then 218$ if (arch_name .eqs. "VAX") 219$ then 220$ write sys$output """LARGE"" is ignored on VAX." 221$ else 222$ cc_defs = cc_defs+ ", _LARGEFILE=1" 223$ endif 224$ goto arg_loop_end 225$ endif 226$! 227$ if (arg_val .eqs. "LDAP") 228$ then 229$ ldap = 1 230$ goto arg_loop_end 231$ endif 232$! 233$ if (f$extract( 0, 4, arg_val) .eqs. "LIST") 234$ then 235$ list = 1 236$ cc_qual1 = cc_qual1+ " /list = ''lisdir' /show = (all, nomessages)" 237$ link_qual = link_qual+ " /map = ''lisdir'" 238$ msg_qual = msg_qual+ " /list = ''lisdir'" 239$ goto arg_loop_end 240$ endif 241$! 242$ if (arg_val .eqs. "NOHPSSL") 243$ then 244$ nohpssl = 1 245$ goto arg_loop_end 246$ endif 247$! 248$ if (arg_val .eqs. "NOSSL") 249$ then 250$ nossl = 1 251$ goto arg_loop_end 252$ endif 253$! 254$ if (arg_val .eqs. "OSSLOLB") 255$ then 256$ osslolb = 1 257$ goto arg_loop_end 258$ endif 259$! 260$ write sys$output "Unrecognized command-line option: ''arg_val'" 261$ goto Common_Exit 262$! 263$arg_loop_end: 264$ arg = arg+ 1 265$ goto arg_loop 266$arg_loop_out: 267$! 268$! CC /LIST, LINK /MAP, and MESSAGE /LIST are defaults in batch mode, 269$! so be explicit when they're not desired. 270$! 271$ if (list .eq. 0) 272$ then 273$ cc_qual1 = cc_qual1+ " /nolist" 274$ link_qual = link_qual+ " /nomap" 275$ msg_qual = msg_qual+ " /nolist" 276$ endif 277$! 278$! Create product directory, if needed. 279$! 280$ if (f$search( proc_dev_dir+ arch_name+ ".DIR;1") .eqs. "") 281$ then 282$ create /directory 'exedir' 283$ endif 284$! 285$! Detect available (but not prohibited) SSL software. 286$! 287$ if (.not. nossl) 288$ then 289$ if (f$trnlnm( "OPENSSL") .nes. "") 290$ then 291$ cc_defs = cc_defs+ ", USE_SSLEAY=1" 292$ if ((f$trnlnm( "SSL$INCLUDE") .nes. "") .and. (.not. nohpssl)) 293$ then 294$! Use HP SSL. 295$ hpssl = 1 296$ ssl_opt = ", ''proc_dev_dir'hpssl_"+ - 297 f$getsyi("ARCH_NAME")+ ".opt /options" 298$ else 299$! Use OpenSSL. Assume object libraries, unless shared images 300$! are found (and not prohibited). 301$ openssl = 1 302$ ssl_opt = ", ssllib:libssl.olb /library"+ - 303 ", ssllib:libcrypto.olb /library" 304$ if (osslolb .eq. 0) 305$ then 306 if ((f$search( "ssllib:ssl_libcrypto.exe") .nes. "") .and. - 307 (f$search( "ssllib:ssl_libssl.exe") .nes. "")) 308$ then 309$! OpenSSL shared images with "SSL_xxx.EXE names. 310$ openssl = 2 311$ ssl_opt = ", ''proc_dev_dir'openssl_ssl_"+ - 312 f$getsyi("ARCH_NAME")+ ".opt /options" 313$ else 314$ if ((f$search( "ssllib:libcrypto.exe") .nes. "") .and. - 315 (f$search( "ssllib:libssl.exe") .nes. "")) 316$ then 317$! OpenSSL shared images with "xxx.EXE names. 318$ openssl = 3 319$ ssl_opt = ", ''proc_dev_dir'openssl_"+ - 320 f$getsyi("ARCH_NAME")+ ".opt /options" 321$ endif 322$ endif 323$ endif 324$ endif 325$ endif 326$ endif 327$! 328$! LDAP. 329$! 330$ if (ldap .eq. 0) 331$ then 332$ cc_defs = cc_defs+ ", CURL_DISABLE_LDAP=1" 333$ endif 334$! 335$! Form CC qualifiers. 336$! 337$ cc_defs = "/define = (''cc_defs')" 338$ cc_qual2 = cc_qual2+ " /object = ''objdir'"+ - 339 " /include = ([-.lib], [-.src],"+ - 340 " [-.packages.vms], [-.packages.vms.''arch_name'])" 341$! 342$ 'vo_c' "CC opts:", - 343 " ''cc_defs'", - 344 " ''cc_qual1'", - 345 " ''cc_qual2'" 346$! 347$! Inform the victim of our plans. 348$! 349$ if (hpssl) 350$ then 351$ 'vo_c' "%CURL-I-BLDHPSSL, building with HP SSL support" 352$ else 353$ if (openssl .ne. 0) 354$ then 355$ if (openssl .eq. 1) 356$ then 357$ 'vo_c' - 358 "%CURL-I-BLDOSSL_OLB, building with OpenSSL (object library) support" 359$ else 360$ 'vo_c' - 361 "%CURL-I-BLDOSSL_EXE, building with OpenSSL (shared image) support" 362$ endif 363$ else 364$ 'vo_c' "%CURL-I-BLDNOSSL, building with NO SSL support" 365$ endif 366$ endif 367$! 368$! Announce destination and SSL directories. 369$! 370$ 'vo_c' " OBJDIR = ''objdir'" 371$ 'vo_c' " EXEDIR = ''exedir'" 372$! 373$ if (openssl .ne. 0) 374$ then 375$ ssllib = f$trnlnm( "ssllib") 376$ if (ssllib .eqs. "") 377$ then 378$ ssllib = "(undefined)" 379$ endif 380$ 'vo_c' " SSLLIB = ''ssllib'" 381$! 382$ if (openssl .eq. 1) 383$ then 384$ ossl_lib1 = f$trnlnm( "ssllib")+ "LIBSSL.OLB" 385$ ossl_lib2 = f$trnlnm( "ssllib")+ "LIBCRYPTO.OLB" 386$ msg = "object libraries" 387$ else 388$ if (openssl .eq. 2) 389$ then 390$ ossl_lib1 = f$trnlnm( "ssllib")+ "SSL_LIBSSL.EXE" 391$ ossl_lib2 = f$trnlnm( "ssllib")+ "SSL_LIBCRYPTO.EXE" 392$ else 393$ ossl_lib1 = f$trnlnm( "ssllib")+ "LIBSSL.EXE" 394$ ossl_lib2 = f$trnlnm( "ssllib")+ "LIBCRYPTO.EXE" 395$ endif 396$ msg = "shared images" 397$ endif 398$ if ((f$search( ossl_lib1) .eqs. "") .or. - 399 (f$search( ossl_lib2) .eqs. "")) 400$ then 401$ write sys$output "Can't find OpenSSL ''msg':" 402$ write sys$output " ''ossl_lib1'" 403$ write sys$output " ''ossl_lib2'" 404$ goto Common_Exit 405$ endif 406$ endif 407$! 408$! Define the "curl" (process) logical name for "#include <curl/xxx.h>". 409$! 410$ curl = f$trnlnm( "curl", "LNM$PROCESS") 411$ if (curl .nes. "") 412$ then 413$ write sys$output "" 414$ write sys$output - 415 "Process logical name ""curl"" is already defined, but this procedure" 416$ write sys$output - 417 "would override that definition. Use a command like" 418$ write sys$output - 419 " deassign /process curl" 420$ write sys$output - 421 "to cancel that logical name definition, and then and re-run this procedure." 422$ write sys$output "" 423$ goto Common_Exit 424$ endif 425$ define curl 'top_dev_dir'.include.curl] 426$! 427$! Copy the VMS-specific config file into the product directory. 428$! 429$ call MoveIfDiff 'top_dev_dir'.lib]config-vms.h 'objdir'curl_config.h 430$! 431$ on control_y then goto Common_Exit 432$! 433$ set default 'proc_dev_dir' 434$ call build "[--.lib]" "*.c" "''objdir'CURLLIB.OLB" "amigaos, nwlib, nwos" 435$ if ($status .eq. ctrl_y) then goto Common_Exit 436$ call build "[--.src]" "*.c" "''objdir'CURLSRC.OLB" 437$ if ($status .eq. ctrl_y) then goto Common_Exit 438$ call build "[]" "*.msg" "''objdir'CURLSRC.OLB" 439$ if ($status .eq. ctrl_y) then goto Common_Exit 440$! 441$ ldap_opt = "" 442$ if (ldap .ne. 0) then ldap_opt = ", ''proc_dev_dir'ldap.opt /options" 443$! 444$ if (openssl .ne. 0) 445$ then 446$ if (openssl .eq. 1) 447$ then 448$ 'vo_l' "%CURL-I-LINK_OSSL, linking with OpenSSL (object library)" 449$ else 450$ 'vo_l' "%CURL-I-LINK_HPSSL, linking with OpenSSL (shared image)" 451$ endif 452$ else 453$ if (hpssl) 454$ then 455$ 'vo_l' "%CURL-I-LINK_HPSSL, linking with HP SSL" 456$ else 457$ 'vo_l' "%CURL-I-LINK_NOSSL, linking with NO SSL support" 458$ endif 459$ endif 460$! 461$ link 'link_qual' /executable = 'exedir'CURL.EXE - 462 'objdir'curlsrc.olb /library /include = (main, curlmsg), - 463 'objdir'curllib.olb /library - 464 'ssl_opt' - 465 'ldap_opt' 466$! 467$ goto Common_Exit 468$! 469$! Subroutine to build everything with a filetype passed in via P2 in 470$! the directory passed in via P1 and put it in the object library named 471$! via P3. Exclude items in P4. 472$! 473$build: subroutine 474$ build_def = f$environment( "default") 475$ on control_y then goto EndLoop ! SS$_CONTROLY 476$ sts = 1 ! SS$_NORMAL. 477$! set noon 478$ set default 'p1' 479$ search = p2 480$ reset = f$search("reset") 481$ if f$search( p3) .eqs. "" 482$ then 483$ librarian /create /object 'p3' 484$ endif 485$ reject_list__ = ","+ f$edit( p4, "COLLAPSE, UPCASE")+ "," 486$ reject_list___len = f$length( reject_list__) 487$ reset = f$search( "reset", 1) 488$Loop: 489$ file = f$search( search, 1) 490$ if file .eqs. "" then goto EndLoop 491$! Skip a name if it's in the P4 exclusion list. 492$ if (p4 .nes. "") 493$ then 494$ name__ = ","+ - 495 f$edit( f$parse( file, , , "NAME", "SYNTAX_ONLY"), "UPCASE")+ - 496 "," 497$ if (f$locate( name__, reject_list__) .lt. reject_list___len) 498$ then 499$ goto Loop 500$ endif 501$ endif 502$ objfile = f$parse( "''objdir'.OBJ;", file) 503$ obj = f$search( objfile, 2) 504$ if (obj .nes. "") 505$ then 506$ if (f$cvtime(f$file(file,"rdt")) .gts. f$cvtime(f$file(obj,"rdt"))) 507$ then 508$ call compile 'file' 509$ sts = $status 510$ if .not. sts 511$ then 512$ goto EndLoop 513$ endif 514$ librarian /object 'p3' 'objfile' 515$ else 516$ 'vo_o' "%CURL-I-OBJUTD, ", objfile, " is up to date" 517$ endif 518$ else 519$ 'vo_o' "%CURL-I-OBJDNE, ", file, " does not exist" 520$ call compile 'file' 521$ sts = $status 522$ if .not. sts 523$ then 524$ goto EndLoop 525$ endif 526$ librarian /object 'p3' 'objfile' 527$ endif 528$ goto Loop 529$EndLoop: 530$!!! purge 531$ set default 'build_def' 532$ exit 'sts' 533$ endsubroutine ! Build 534$! 535$! Based on the file TYPE, do the right compile command. 536$! Only C and MSG supported. 537$! 538$compile: subroutine 539$ on control_y then return ctrl_y ! SS$_CONTROLY 540$! set noon 541$ file = p1 542$ qual = p2+ p3+ p4+ p5+ p6+ p7+ p8 543$ typ = f$edit( f$parse( file, , , "TYPE"), "UPCASE") - "." 544$ if (typ .eqs. "C") 545$ then 546$ 'vo_c' "CC (opts) ", file 547$ CC 'cc_defs' - 548 'cc_qual1' - 549 'cc_qual2' - 550 'file' 551$ else 552$ cmd_msg = "MESSAGE "+ msg_qual 553$ x = cmd_'typ' 554$ 'vo_c' x," ",file 555$ 'x' 'file' 556$ endif 557$ ENDSUBROUTINE ! Compile 558$! 559$! Do a diff of the file specified in P1 with that in P2. If different 560$! copy P1 to P2. This also covers if P2 doesn't exist, but not if P2 561$! is an invalid filespec. 562$! 563$MoveIfDiff: subroutine 564$ set NoOn 565$ define /user_mode sys$error nl: 566$ define /user_mode sys$output nl: 567$ differences 'p1' 'p2' 568$ status = $status 569$ if ( status .ne. %X006C8009) ! if status is not "no diff" 570$ then 571$ copy 'p1' 'p2' 572$ purge /nolog 'p2' 573$ endif 574$ on control_y then return ctrl_y ! SS$_CONTROLY 575$ ENDSUBROUTINE ! MoveIfDiff 576$! 577$Common_Exit: 578$ set default 'orig_def' 579$ if ((curl .eqs. "") .and. (f$trnlnm( "curl", "LNM$PROCESS") .nes. "")) 580$ then 581$ deassign curl 582$ endif 583$ exit 584