build_libcurl_pc.com 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. $! File: build_libcurl_pc.com
  2. $!
  3. $! $Id:$
  4. $!
  5. $! Build the libcurl.pc file from the libcurl.pc.in file
  6. $!
  7. $! Copyright 2013 - 2022, John Malmberg
  8. $!
  9. $! Permission to use, copy, modify, and/or distribute this software for any
  10. $! purpose with or without fee is hereby granted, provided that the above
  11. $! copyright notice and this permission notice appear in all copies.
  12. $!
  13. $! THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  14. $! WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  15. $! MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  16. $! ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  17. $! WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  18. $! ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
  19. $! OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  20. $!
  21. $! SPDX-License-Identifier: ISC
  22. $!
  23. $! 15-Jun-2013 J. Malmberg
  24. $!
  25. $!===========================================================================
  26. $!
  27. $! Skip this if the libcurl.pc already exists.
  28. $ if f$search("[--]libcurl.pc") .nes. "" then goto all_exit
  29. $!
  30. $! Need to know the kit type.
  31. $ kit_name = f$trnlnm("GNV_PCSI_KITNAME")
  32. $ if kit_name .eqs. ""
  33. $ then
  34. $ write sys$output "@MAKE_PCSI_CURL_KIT_NAME.COM has not been run."
  35. $ goto all_exit
  36. $ endif
  37. $!
  38. $!
  39. $! Parse the kit name into components.
  40. $!---------------------------------------
  41. $ producer = f$element(0, "-", kit_name)
  42. $ base = f$element(1, "-", kit_name)
  43. $ product = f$element(2, "-", kit_name)
  44. $ mmversion = f$element(3, "-", kit_name)
  45. $ majorver = f$extract(0, 3, mmversion)
  46. $ minorver = f$extract(3, 2, mmversion)
  47. $ updatepatch = f$element(4, "-", kit_name)
  48. $ if updatepatch .eqs. "-" then updatepatch = ""
  49. $!
  50. $! kit type of "D" means a daily build
  51. $ kit_type = f$edit(f$extract(0, 1, majorver), "upcase")
  52. $!
  53. $ pc_file_in = "[--]libcurl^.pc.in"
  54. $!
  55. $ if f$search(pc_file_in) .eqs. ""
  56. $ then
  57. $ pc_file_in = "[--]libcurl.pc$5nin"
  58. $ if f$search(pc_file_in) .eqs. ""
  59. $ then
  60. $ pc_file_in = "[--]libcurl.pc_in"
  61. $ if f$search(pc_file_in) .eqs. ""
  62. $ then
  63. $ write sys$output "Can not find libcurl.pc.in."
  64. $ goto all_exit
  65. $ endif
  66. $ endif
  67. $ endif
  68. $!
  69. $ if (f$getsyi("HW_MODEL") .lt. 1024)
  70. $ then
  71. $ arch_name = "VAX"
  72. $ else
  73. $ arch_name = ""
  74. $ arch_name = arch_name + f$edit(f$getsyi("ARCH_NAME"), "UPCASE")
  75. $ if (arch_name .eqs. "") then arch_name = "UNK"
  76. $ endif
  77. $!
  78. $!
  79. $ curl_version = "0.0.0"
  80. $ open/read vf [--.src]tool_version.h
  81. $version_loop:
  82. $ read vf/end=version_loop_end line_in
  83. $ if line_in .eqs. "" then goto version_loop
  84. $ key = f$element(0, " ", line_in)
  85. $ if key .nes. "#define" then goto version_loop
  86. $ name = f$element(1, " ", line_in)
  87. $ if name .eqs. "VERSION"
  88. $ then
  89. $ curl_version = f$element(2, " ", line_in) - """" - """"
  90. $ else
  91. $ goto version_loop
  92. $ endif
  93. $version_loop_end:
  94. $ close vf
  95. $!
  96. $!
  97. $ create [--]libcurl.pc
  98. $ open/append pco [--]libcurl.pc
  99. $ open/read pci 'pc_file_in'
  100. $pc_file_loop:
  101. $ read pci/end=pc_file_loop_end line_in
  102. $!
  103. $! blank lines
  104. $ if line_in .eqs. ""
  105. $ then
  106. $ write pco ""
  107. $ goto pc_file_loop
  108. $ endif
  109. $!
  110. $! comment lines
  111. $ key = f$extract(0, 1, line_in)
  112. $ if key .eqs. "#"
  113. $ then
  114. $ write pco line_in
  115. $ goto pc_file_loop
  116. $ endif
  117. $!
  118. $! Special handling for libs.
  119. $ if f$locate("Libs:", line_in) .eq. 0
  120. $ then
  121. $ write pco "#",line_in
  122. $ goto pc_file_loop
  123. $ endif
  124. $! No substitution line
  125. $ line_in_len = f$length(line_in)
  126. $ if f$locate("@", line_in) .ge. line_in_len
  127. $ then
  128. $ write pco line_in
  129. $ goto pc_file_loop
  130. $ endif
  131. $!
  132. $ if f$locate("@prefix@", line_in) .lt line_in_len
  133. $ then
  134. $ if kit_type .nes. "D"
  135. $ then
  136. $ write pco "prefix=/usr"
  137. $ else
  138. $ write pco "prefix=/beta"
  139. $ endif
  140. $ goto pc_file_loop
  141. $ endif
  142. $ if f$locate("@exec_prefix@", line_in) .lt line_in_len
  143. $ then
  144. $ if kit_type .nes. "D"
  145. $ then
  146. $ write pco "exec_prefix=/usr"
  147. $ else
  148. $ write pco "exec_prefix=/beta"
  149. $ endif
  150. $ goto pc_file_loop
  151. $ endif
  152. $ if f$locate("@libdir@", line_in) .lt line_in_len
  153. $ then
  154. $ write pco "libdir=$(exec_prefix}/lib"
  155. $ goto pc_file_loop
  156. $ endif
  157. $ if f$locate("@includedir@", line_in) .lt line_in_len
  158. $ then
  159. $ write pco "includedir=$(prefix}/include"
  160. $ goto pc_file_loop
  161. $ endif
  162. $ if f$locate("@SUPPORT_PROTOCOLS@", line_in) .lt line_in_len
  163. $ then
  164. $ proto1 = "DICT FILE FTP FTPS GOPHER HTTP HTTPS IMAP IMAPS"
  165. $ proto2 = " LDAP LDAPS POP3 POP3S RTSP SMTP SMTPS TELNET TFTP"
  166. $ proto = proto1 + proto2
  167. $ write pco "supported_protocols=""" + proto + """"
  168. $ goto pc_file_loop
  169. $ endif
  170. $ if f$locate("@SUPPORT_FEATURES@", line_in) .lt line_in_len
  171. $ then
  172. $ if arch_name .eqs. "VAX"
  173. $ then
  174. $ write pco "supported_features=""SSL libz NTLM"""
  175. $ else
  176. $ write pco "supported_features=""SSL IPv6 libz NTLM"""
  177. $ endif
  178. $ goto pc_file_loop
  179. $ endif
  180. $ if f$locate("@CURLVERSION@", line_in) .lt line_in_len
  181. $ then
  182. $ write pco "Version: ''curl_version'"
  183. $ goto pc_file_loop
  184. $ endif
  185. $ if f$locate("@LIBCURL_LIBS@", line_in) .lt line_in_len
  186. $ then
  187. $ if arch_name .eqs. "VAX"
  188. $ then
  189. $ write pco "Libs.private: -lssl -lcrypto -lz"
  190. $ else
  191. $ write pco "Libs.private: -lssl -lcrypto -lgssapi -lz"
  192. $ endif
  193. $ goto pc_file_loop
  194. $ endif
  195. $ if f$locate("@CPPFLAG_CURL_STATICLIB@", line_in) .lt line_in_len
  196. $ then
  197. $ write pco "Cflags: -I${includedir} -DCURL_STATICLIB"
  198. $ goto pc_file_loop
  199. $ endif
  200. $!
  201. $pc_file_loop_end:
  202. $ close pco
  203. $ close pci
  204. $!
  205. $all_exit:
  206. $ exit