1 $! File: generate_vax_transfer.com
5 $! File to generate and compile the VAX transfer vectors from reading in the
6 $! Alpha/Itanium gnv_libcurl_symbols.opt file.
8 $! This procedure patches the VAX Macro32 assembler to be case sensitive
9 $! and then compiles the generated
11 $! The output of this procedure is:
12 $! gnv_libcurl_xfer.mar_exact
13 $! gnv_libcurl_xfer.obj
14 $! gnv_libcurl_xfer.opt
15 $! macro32_exactcase.exe
17 $! Copyright 2013, John Malmberg
19 $! Permission to use, copy, modify, and/or distribute this software for any
20 $! purpose with or without fee is hereby granted, provided that the above
21 $! copyright notice and this permission notice appear in all copies.
23 $! THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
24 $! WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
25 $! MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
26 $! ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
27 $! WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
28 $! ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
29 $! OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
31 $! 20-Jul-2013 J. Malmberg
32 $!============================================================================
34 $! Save this so we can get back.
35 $ default_dir = f$environment("default")
37 $ on warning then goto all_exit
39 $! Want hard tabs in the generated file.
42 $! This procedure is used on VAX only
43 $ if (f$getsyi("HW_MODEL") .ge. 1024)
45 $ write sys$output "This procedure is only used on VAX."
50 $! Get the libcurl version to generate the ident string.
51 $! ident string is max of 31 characters.
53 $ ident_string = "unknown"
54 $ open/read cver [-.-.include.curl]curlver.h
56 $ read/end=cver_loop_end cver line_in
57 $ line_in = f$edit(line_in, "COMPRESS,TRIM")
58 $ if line_in .eqs. "" then goto cver_loop
59 $ code = f$extract(0, 1, line_in)
60 $ if code .nes. "#" then goto cver_loop
61 $ directive = f$element(0, " ", line_in)
62 $ if directive .nes. "#define" then goto cver_loop
63 $ name = f$element(1, " ", line_in)
64 $ if name .nes. "LIBCURL_VERSION" then goto cver_loop
65 $ ident_string = f$element(2, " ", line_in) - "" - ""
69 $ open/read aopt gnv_libcurl_symbols.opt
71 $! Write out the header
74 $ open/append vopt gnv_libcurl_xfer.mar_exact
75 $ write vopt tab,".IDENT /", ident_string, "/"
77 $ write vopt tab, ".PSECT LIBCURL_XFERVECTORS -"
78 $ write vopt tab,tab,tab, "PIC,USR,CON,REL,GBL,SHR,EXE,RD,NOWRT,QUAD"
80 $ write vopt tab, "SPARE", tab, "; never delete this spare"
82 $ write vopt ";", tab, "Exact case and upper case transfer vectors"
87 $! Read in symbol_vector
89 $ read/end=vector_loop_end aopt line_in
90 $ line = f$edit(line_in, "UNCOMMENT,COMPRESS,TRIM")
91 $ if line .eqs. "" then goto vector_loop
93 $ line_u = f$edit(line, "UPCASE")
94 $ key = f$element(0, "=", line_u)
95 $ if (key .eqs. "SYMBOL_VECTOR")
97 $ symbol_string = f$element(1, "=", line) - "("
98 $ symbol_type = f$element(2, "=", line_u) - ")"
99 $ symbol_name = f$element(1, "/", symbol_string)
100 $ if symbol_type .nes. "PROCEDURE"
102 $ write sys$output "%CURLBUILD-W-NOTPROC, " + -
103 $ "This procedure can only handle procedure vectors"
105 "Data vectors require manual construction for which this procedure or"
107 "the shared library needs to be updated to resolve."
109 "the preferred solution is to have a procedure return the address of the "
111 "the variable instead of having a variable, as if the size of the variable "
113 "changes, the symbol vector is no longer backwards compatible."
115 $ if (symbol_name .eqs. "/")
117 $ symbol_name = symbol_string
118 $ write vopt tab, symbol_type, tab, symbol_name
120 $ alias_count = alias_count + 1
121 $ symbol_alias = f$element(0, "/", symbol_string)
123 tab, "''symbol_type_U", tab, symbol_name, tab, symbol_alias
129 $! End of pass one, second pass needed if aliases exist
132 $ if alias_count .eq. 0 then goto finish_file
134 $! Start pass 2, write stub routine header
136 $ open/read aopt gnv_libcurl_symbols.opt
140 $! Read in symbol_vector
142 $ read/end=alias_loop_end aopt line_in
143 $ line = f$edit(line_in, "UNCOMMENT,COMPRESS,TRIM")
144 $ if line .eqs. "" then goto alias_loop
146 $ line_u = f$edit(line, "UPCASE")
147 $ key = f$element(0, "=", line_u)
148 $ if (key .eqs. "SYMBOL_VECTOR")
150 $ symbol_string = f$element(1, "=", line) - "("
151 $ symbol_type = f$element(2, "=", line_u) - ")"
152 $ symbol_name = f$element(1, "/", symbol_string)
153 $ if (symbol_name .eqs. "/")
155 $ symbol_name = symbol_string
157 $ alias_count = alias_count + 1
158 $ symbol_alias = f$element(0, "/", symbol_string)
159 $ write vopt tab, ".ENTRY", tab, symbol_alias, ", ^M<>"
163 $! read in symbol_vector
164 $! if not alias, then loop
165 $! write out subroutine name
169 $ write vopt tab, "MOVL #1, R0"
170 $ write vopt tab, "RET"
175 $ write vopt tab, ".END"
180 $! Patch the Macro32 compiler
181 $!----------------------------
182 $ patched_macro = "sys$disk:[]macro32_exactcase.exe"
183 $ if f$search(patched_macro) .eqs. ""
185 $ copy sys$system:macro32.exe 'patched_macro'
186 $ patch @macro32_exactcase.patch
188 $ define/user macro32 'patched_macro'
189 $ macro/object=gnv_libcurl_xfer.obj gnv_libcurl_xfer.mar_exact
191 $! Create the option file for linking the shared image.
192 $ create gnv_libcurl_xfer.opt
193 $ open/append lco gnv_libcurl_xfer.opt
194 $ write lco "gsmatch=lequal,1,1"
195 $ write lco "cluster=transfer_vector,,,''default_dir'gnv_libcurl_xfer"
196 $ write lco "collect=libcurl_global, libcurl_xfervectors"
202 $! Process the header
205 $! Force the mode of the file to same as text editor generated.
206 $ create gnv_libcurl_xfer.mar_exact
208 ; File: gnv_libcurl_xfer.mar_exact
210 ; VAX transfer vectors
212 ; This needs to be compiled with a specialized patch on Macro32 to make it
213 ; preserve the case of symbols instead of converting it to uppercase.
215 ; This patched Macro32 requires all directives to be in upper case.
217 ; There are three sets of symbols for transfer vectors here.
219 ; The first for upper case which matches the tradition method of generating
220 ; VAX transfer vectors.
222 ; The second is the exact case for compatibilty with open source C programs
223 ; that expect exact case symbols in images. These are separated because a
224 ; previous kit had only upper case symbols.
226 ; The third is the routine stub that is used to resolve part of the upper
227 ; case transfer vectors, with exact case entry symbols.
229 ; When you add routines, you need to add them after the second set of transfer
230 ; vectors for both upper and exact case, and then additional entry points
231 ; in upper case added to stub routines.
233 ;*************************************************************************
235 .TITLE libcurl_xfer - Transfer vector for libcurl
239 ; Macro to generate a transfer vector entry
241 .MACRO PROCEDURE NAME
249 .MACRO PROCEDUREU NAME NAMEU
259 ; Macro to reserve a spare entry.
273 $set def 'default_dir'