Marty Kuhrt's provided files for the VMS package
[platform/upstream/curl.git] / packages / vms / build_vms.com
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 based on logicals, or lack thereof.  If SSL$INCLUDE
7 $! is defined, then it assumed that hp's SSL product has been installed.
8 $! If OPENSSL is defined, but SSL$INCLUDE isn't, then the OpenSSL defined
9 $! via the defines.com procedure will be used.  If neither logical is 
10 $! defined, then SSL support will not be compiled/linked in.
11 $!
12 $! If CURL_BUILD_NOSSL is defined to anything, then no SSL support will
13 $! be built in.  This way you can build without SSL support on systems
14 $! that have it without the "automatic" build/link "features".
15 $!
16 $! If CURL_BUILD_NOHPSSL is defined to anything, it will override the
17 $! SSL$INCLUDE check.  This way you can build against OpenSSL, even if
18 $! you have hp SSL installed.
19 $!
20 $! Parameter(s):
21 $!
22 $! P1 - LISTING will create .lis files during the C compile
23 $!      DEBUG will compile and link with debug
24 $!
25 $! Revisions:
26 $!
27 $!  2-DEC-2003, MSK, the "original" version. <marty@barra.com>
28 $!                   It works for me.  Your mileage may vary.
29 $! 13-JAN-2004, MSK, moved this procedure to the [.packages.vms] directory
30 $!                   and updated it to do hardware dependant builds.
31 $! 29-JAN-2004, MSK, moved logical defines into defines.com
32 $!  6-FEB-2004, MSK, put in various SSL support bits
33 $!  9-MAR-2004, MSK, the config-vms.h* files are now copied to the lib and
34 $!                   src directories as config.h.
35 $!
36 $ on control_y then goto Common_Exit
37 $ origdir = f$environment("DEFAULT")
38 $ proc    = f$environment("PROCEDURE")
39 $ thisdir = f$parse( proc,,,"DEVICE") + f$parse( proc,,,"DIRECTORY")
40 $!
41 $! Verbose output message stuff.  Define symbol to "write sys$output" or "!".
42 $! vo_c - verbose output for compile
43 $! vo_l - link
44 $! vo_o - object check
45 $!
46 $ vo_c = "write sys$output"
47 $ vo_l = "write sys$output"
48 $ vo_o = "!"
49 $!
50 $ defines = thisdir + "defines.com"
51 $ if f$search( defines) .eqs. "" 
52 $ then
53 $    write sys$output "%CURL-F-DEFFNF, cannot find defines.com procedure"
54 $    exit %X18290 ! FNF
55 $ endif
56 $ set def 'thisdir'
57 $ cc_qual = "/define=HAVE_CONFIG_H=1/OBJ=OBJDIR:"
58 $ link_qual = ""
59 $ if p1 .eqs. "LISTING" then cc_qual = cc_qual + "/LIST/MACHINE"
60 $ if p1 .eqs. "DEBUG" 
61 $ then 
62 $    cc_qual = cc_qual + "/LIST/MACHINE/DEBUG/NOOPT"
63 $    link_qual = "/DEBUG"
64 $ endif
65 $ msg_qual = "/OBJ=OBJDIR:"
66 $!
67 $ hpssl   = 0
68 $ openssl = 0
69 $ if f$trnlnm( "CURL_BUILD_NOSSL") .eqs. ""
70 $ then
71 $    if f$trnlnm( "OPENSSL") .nes. "" 
72 $    then
73 $       openssl = 1
74 $       if ( f$trnlnm( "SSL$INCLUDE") .nes. "") .and. -
75            ( f$trnlnm( "CURL_BUILD_NOHPSSL") .eqs. "")
76 $       then hpssl = 1
77 $       endif
78 $    endif
79 $ endif
80 $!
81 $! Put the right main config file in the two source directories for the build.
82 $!
83 $ if ( openssl .eq. 1) .or. ( hpssl .eq. 1)
84 $ then
85 $    'vo_c' "%CURL-I-BLDSSL, building with SSL support"
86 $    source_h = "CONFIG-VMS.H_WITH_SSL"
87 $ else
88 $    'vo_c' "%CURL-I-BLDNOSSL, building without SSL support"
89 $    source_h = "CONFIG-VMS.H_WITHOUT_SSL"
90 $ endif
91 $!
92 $! Only do the copy if the source and destination files are different.
93 $! Put this block into Set NoOn mode so that if the diff command triggers
94 $! an error while error message reporting is turned off, then it won't 
95 $! just exit the command procedure mysteriously.
96 $!
97 $ set noon
98 $ set message/nof/noi/nos/not
99 $ diff/out=nla0: 'source_h' [--.SRC]CONFIG.H
100 $ status = $status
101 $ set message/f/i/s/t
102 $ if ( status .ne. %X006C8009) ! if status is not "no diff"
103 $ then
104 $    copy 'source_h' [--.SRC]CONFIG.H
105 $    purge/nolog [--.SRC]CONFIG.H
106 $ endif
107 $ set message/nof/noi/nos/not
108 $ diff/out=nla0: 'source_h' [--.LIB]CONFIG.H
109 $ status = $status
110 $ set message/f/i/s/t
111 $ if ( status .ne. %X006C8009) ! if status is not "no diff"
112 $ then
113 $    copy 'source_h' [--.LIB]CONFIG.H
114 $    purge/nolog [--.LIB]CONFIG.H
115 $ endif
116 $ on control_y then goto Common_Exit
117 $!
118 $ call build "[--.lib]" "*.c" "objdir:curllib.olb"
119 $ call build "[--.src]" "*.c" "objdir:curlsrc.olb"
120 $ call build "[--.src]" "*.msg" "objdir:curlsrc.olb"
121 $ if ( openssl .eq. 1) .and. ( hpssl .eq. 0)
122 $ then
123 $    'vo_l' "%CURL-I-LINK_OSSL, linking with OpenSSL"
124 $    link 'link_qual'/exe=exedir:curl.exe -
125           objdir:curlsrc/lib/include=(main,curlmsg),-
126           objdir:curllib/lib, libssl/lib, libcrypto/lib
127 $ endif
128 $ if ( openssl .eq. 1) .and. ( hpssl .eq. 1)
129 $ then
130 $    'vo_l' "%CURL-I-LINK_HPSSL, linking with hp SSL option"
131 $    optfile = "[]hpssl_" + f$getsyi("ARCH_NAME") + ".opt/opt"
132 $    link 'link_qual'/exe=exedir:curl.exe -
133           objdir:curlsrc/lib/include=(main,curlmsg),-
134           objdir:curllib/lib, 'optfile'
135 $ endif
136 $ if ( openssl .eq. 0) .and. ( hpssl .eq. 0)
137 $ then
138 $    'vo_l' "%CURL-I-LINK_NOSSL, linking without SSL support"
139 $    link 'link_qual'/exe=exedir:curl.exe -
140           objdir:curlsrc/lib/include=(main,curlmsg),-
141           objdir:curllib/lib
142 $ endif
143 $!
144 $ goto Common_Exit
145 $!
146 $! Subroutine to build everything with a filetype passed in via P2 in 
147 $! the directory passed in via P1 and put it in the object library named 
148 $! via P3
149 $!
150 $build:   subroutine
151 $ on control_y then exit 2
152 $ set noon
153 $   set default 'p1'
154 $   search = p2
155 $   reset = f$search("reset")
156 $   if f$search( p3) .eqs. ""
157 $   then
158 $      LIB/CREATE/OBJECT 'p3'
159 $   endif
160 $   reset = f$search("reset",1)
161 $Loop:
162 $   file = f$search(search,1)
163 $   if file .eqs. "" then goto EndLoop
164 $      objfile = f$parse("objdir:.OBJ;",file)
165 $      obj = f$search( objfile, 2)
166 $      if (obj .nes. "")
167 $      then
168 $         if (f$cvtime(f$file(file,"rdt")) .gts. f$cvtime(f$file(obj,"rdt")))
169 $         then
170 $            call compile 'file'
171 $            if .not. $status then exit $status
172 $            lib/object 'p3' 'objfile'
173 $         else
174 $            'vo_o' "%CURL-I-OBJUTD, ", objfile, " is up to date"
175 $         endif
176 $      else
177 $         'vo_o' "%CURL-I-OBJDNE, ", file, " does not exist"
178 $         call compile 'file'
179 $         if .not. $status then exit $status
180 $         lib/object 'p3' 'objfile'
181 $      endif
182 $   goto Loop
183 $EndLoop:
184 $   !purge
185 $   set def 'origdir'
186 $   endsubroutine   ! Build
187 $!
188 $! Based on the file TYPE, do the right compile command.  
189 $! Only C and MSG supported.
190 $!
191 $compile:   subroutine
192 $   on control_y then exit 2
193 $   set noon
194 $   file = p1
195 $   qual = p2+p3+p4+p5+p6+p7+p8
196 $   typ = f$parse(file,,,"TYPE") - "."
197 $   cmd_c = "CC "+cc_qual
198 $   cmd_msg = "MESSAGE "+msg_qual
199 $   x = cmd_'typ'
200 $   'vo_c' x," ",file
201 $   'x' 'file'
202 $   ENDSUBROUTINE   ! Compile
203 $!
204 $Common_Exit:
205 $   set default 'origdir'
206 $   exit