Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. $! BUILDBZ2.COM
  2. $!
  3. $!     Build procedure for LIBBZ2_NS support library used with the
  4. $!     VMS versions of UnZip/ZipInfo and UnZipSFX
  5. $!
  6. $!     Last revised:  2007-12-29  CS.
  7. $!
  8. $!     Command args:
  9. $!     - select compiler environment: "VAXC", "DECC", "GNUC"
  10. $!     - select compiler listings: "LIST"  Note that the whole argument
  11. $!       is added to the compiler command, so more elaborate options
  12. $!       like "LIST/SHOW=ALL" (quoted or space-free) may be specified.
  13. $!     - supply additional compiler options: "CCOPTS=xxx"  Allows the
  14. $!       user to add compiler command options like /ARCHITECTURE or
  15. $!       /[NO]OPTIMIZE.  For example, CCOPTS=/ARCH=HOST/OPTI=TUNE=HOST
  16. $!       or CCOPTS=/DEBUG/NOOPTI.  These options must be quoted or
  17. $!       space-free.
  18. $!
  19. $!     To specify additional options, define the symbol LOCAL_BZIP2
  20. $!     as a comma-separated list of the C macros to be defined, and
  21. $!     then run BUILDBZ2.COM.  For example:
  22. $!
  23. $!             $ LOCAL_BZIP2 = "RETURN_CODES"
  24. $!             $ @ []BUILDBZ2.COM
  25. $!
  26. $!     If you edit this procedure to set LOCAL_BZIP2 here, be sure to
  27. $!     use only one "=", to avoid affecting other procedures.
  28. $!
  29. $!
  30. $ on error then goto error
  31. $ on control_y then goto error
  32. $ OLD_VERIFY = f$verify(0)
  33. $!
  34. $ edit := edit                  ! override customized edit commands
  35. $ say := write sys$output
  36. $!
  37. $!##################### Read settings from environment ########################
  38. $!
  39. $ if (f$type(LOCAL_BZIP2) .eqs. "")
  40. $ then
  41. $     local_bzip2 = ""
  42. $ else  ! Trim blanks and append comma if missing
  43. $     local_bzip2 = f$edit(local_bzip2, "TRIM")
  44. $     if (f$extract((f$length(local_bzip2) - 1), 1, local_bzip2) .nes. ",")
  45. $     then
  46. $         local_bzip2 = local_bzip2 + ", "
  47. $     endif
  48. $ endif
  49. $!
  50. $!##################### Customizing section #############################
  51. $!
  52. $ unzx_unx = "UNZIP"
  53. $ unzx_cli = "UNZIP_CLI"
  54. $ unzsfx_unx = "UNZIPSFX"
  55. $ unzsfx_cli = "UNZIPSFX_CLI"
  56. $!
  57. $ CCOPTS = ""
  58. $ LINKOPTS = "/notraceback"
  59. $ LISTING = " /nolist"
  60. $ MAY_USE_DECC = 1
  61. $ MAY_USE_GNUC = 0
  62. $!
  63. $! Process command line parameters requesting optional features.
  64. $!
  65. $ arg_cnt = 1
  66. $ argloop:
  67. $     current_arg_name = "P''arg_cnt'"
  68. $     curr_arg = f$edit( 'current_arg_name', "UPCASE")
  69. $     if (curr_arg .eqs. "") then goto argloop_out
  70. $!
  71. $     if (f$extract( 0, 5, curr_arg) .eqs. "CCOPT")
  72. $     then
  73. $         opts = f$edit( curr_arg, "COLLAPSE")
  74. $         eq = f$locate( "=", opts)
  75. $         CCOPTS = f$extract( (eq+ 1), 1000, opts)
  76. $         goto argloop_end
  77. $     endif
  78. $!
  79. $     if (f$extract( 0, 4, curr_arg) .eqs. "LIST")
  80. $     then
  81. $         LISTING = "/''curr_arg'"      ! But see below for mods.
  82. $         goto argloop_end
  83. $     endif
  84. $!
  85. $     if (curr_arg .eqs. "VAXC")
  86. $     then
  87. $         MAY_USE_DECC = 0
  88. $         MAY_USE_GNUC = 0
  89. $         goto argloop_end
  90. $     endif
  91. $!
  92. $     if (curr_arg .eqs. "DECC")
  93. $     then
  94. $         MAY_USE_DECC = 1
  95. $         MAY_USE_GNUC = 0
  96. $         goto argloop_end
  97. $     endif
  98. $!
  99. $     if (curr_arg .eqs. "GNUC")
  100. $     then
  101. $         MAY_USE_DECC = 0
  102. $         MAY_USE_GNUC = 1
  103. $         goto argloop_end
  104. $     endif
  105. $!
  106. $     say "Unrecognized command-line option: ''curr_arg'"
  107. $     goto error
  108. $!
  109. $     argloop_end:
  110. $     arg_cnt = arg_cnt + 1
  111. $ goto argloop
  112. $ argloop_out:
  113. $!
  114. $!#######################################################################
  115. $!
  116. $! Find out current disk, directory, compiler and options
  117. $!
  118. $ workdir = f$environment("default")
  119. $ here = f$parse(workdir, , , "device") + f$parse(workdir, , , "directory")
  120. $!
  121. $! Sense the host architecture (Alpha, Itanium, or VAX).
  122. $!
  123. $ if (f$getsyi("HW_MODEL") .lt. 1024)
  124. $ then
  125. $     arch = "VAX"
  126. $ else
  127. $     if (f$getsyi("ARCH_TYPE") .eq. 2)
  128. $     then
  129. $         arch = "ALPHA"
  130. $     else
  131. $         if (f$getsyi("ARCH_TYPE") .eq. 3)
  132. $         then
  133. $             arch = "IA64"
  134. $         else
  135. $             arch = "unknown_arch"
  136. $         endif
  137. $     endif
  138. $ endif
  139. $!
  140. $ dest = arch
  141. $ cmpl = "DEC/Compaq/HP C"
  142. $ opts = ""
  143. $ if (arch .nes. "VAX")
  144. $ then
  145. $     HAVE_DECC_VAX = 0
  146. $     USE_DECC_VAX = 0
  147. $!
  148. $     if (MAY_USE_GNUC)
  149. $     then
  150. $         say "GNU C is not supported for ''arch'."
  151. $         say "You must use DEC/Compaq/HP C to build UnZip."
  152. $         goto error
  153. $     endif
  154. $!
  155. $     if (.not. MAY_USE_DECC)
  156. $     then
  157. $         say "VAX C is not supported for ''arch'."
  158. $         say "You must use DEC/Compaq/HP C to build UnZip."
  159. $         goto error
  160. $     endif
  161. $!
  162. $     cc = "cc /standard=relax /prefix=all /ansi /names=(as_is)"
  163. $     defs = "''local_bzip2'"
  164. $ else
  165. $     HAVE_DECC_VAX = (f$search("SYS$SYSTEM:DECC$COMPILER.EXE") .nes. "")
  166. $     HAVE_VAXC_VAX = (f$search("SYS$SYSTEM:VAXC.EXE") .nes. "")
  167. $     MAY_HAVE_GNUC = (f$trnlnm("GNU_CC") .nes. "")
  168. $     if (HAVE_DECC_VAX .and. MAY_USE_DECC)
  169. $     then
  170. $         ! We use DECC:
  171. $         USE_DECC_VAX = 1
  172. $         cc = "cc /decc /prefix=all /names=(as_is)"
  173. $         defs = "''local_bzip2'"
  174. $     else
  175. $         ! We use VAXC (or GNU C):
  176. $         USE_DECC_VAX = 0
  177. $         defs = "''local_bzip2'"
  178. $         if ((.not. HAVE_VAXC_VAX .and. MAY_HAVE_GNUC) .or. MAY_USE_GNUC)
  179. $         then
  180. $             cc = "gcc"
  181. $             dest = "''dest'G"
  182. $             cmpl = "GNU C"
  183. $             opts = "GNU_CC:[000000]GCCLIB.OLB /LIBRARY,"
  184. $         else
  185. $             if (HAVE_DECC_VAX)
  186. $             then
  187. $                 cc = "cc /vaxc"
  188. $             else
  189. $                 cc = "cc"
  190. $             endif
  191. $             dest = "''dest'V"
  192. $             cmpl = "VAX C"
  193. $         endif
  194. $     endif
  195. $ endif
  196. $!
  197. $! Reveal the plan.  If compiling, set some compiler options.
  198. $!
  199. $     say "Compiling bzip2 on ''arch' using ''cmpl'."
  200. $!
  201. $     DEF_NS = "/define = (''defs'BZ_NO_STDIO, VMS)"
  202. $!
  203. $! If [.'dest'] does not exist, either complain (link-only) or make it.
  204. $!
  205. $ if (f$search("''dest'.dir;1") .eqs. "")
  206. $ then
  207. $     create /directory [.'dest']
  208. $ endif
  209. $!
  210. $! Arrange to get arch-specific list file placement, if listing, and if
  211. $! the user didn't specify a particular "/LIST =" destination.
  212. $!
  213. $     L = f$edit(LISTING, "COLLAPSE")
  214. $     if ((f$extract(0, 5, L) .eqs. "/LIST") .and. -
  215.        (f$extract(4, 1, L) .nes. "="))
  216. $     then
  217. $         LISTING = " /LIST = [.''dest']" + f$extract(5, 1000, LISTING)
  218. $     endif
  219. $!
  220. $! Define compiler command.
  221. $!
  222. $     cc = cc + " /include = ([])" + LISTING + CCOPTS
  223. $!
  224. $! Show interesting facts.
  225. $!
  226. $ say "   architecture = ''arch' (destination = [.''dest'])"
  227. $ say "   cc = ''cc'"
  228. $ say ""
  229. $!
  230. $ tmp = f$verify( 1)    ! Turn echo on to see what's happening.
  231. $!
  232. $!------------------------------- BZip2 section ------------------------------
  233. $!
  234. $! Compile the sources.
  235. $!
  236. $     cc 'DEF_NS' /object = [.'dest']blocksort.OBJ blocksort.c
  237. $     cc 'DEF_NS' /object = [.'dest']huffman.OBJ huffman.c
  238. $     cc 'DEF_NS' /object = [.'dest']crctable.OBJ crctable.c
  239. $     cc 'DEF_NS' /object = [.'dest']randtable.OBJ randtable.c
  240. $     cc 'DEF_NS' /object = [.'dest']compress.OBJ compress.c
  241. $     cc 'DEF_NS' /object = [.'dest']decompress.OBJ decompress.c
  242. $     cc 'DEF_NS' /object = [.'dest']bzlib.OBJ bzlib.c
  243. $!
  244. $! Create the object library.
  245. $!
  246. $     if (f$search( "[.''dest']LIBBZ2_NS.OLB") .eqs. "") then -
  247.        libr /object /create [.'dest']LIBBZ2_NS.OLB
  248. $!
  249. $     libr /object /replace [.'dest']LIBBZ2_NS.OLB -
  250.        [.'dest']blocksort.OBJ, -
  251.        [.'dest']huffman.OBJ, -
  252.        [.'dest']crctable.OBJ, -
  253.        [.'dest']randtable.OBJ, -
  254.        [.'dest']compress.OBJ, -
  255.        [.'dest']decompress.OBJ, -
  256.        [.'dest']bzlib.OBJ
  257. $!
  258. $! Restore the original default directory, deassign the temporary
  259. $! logical names, and restore the DCL verify status.
  260. $!
  261. $ error:
  262. $!
  263. $ if (f$type(here) .nes. "")
  264. $ then
  265. $     if (here .nes. "")
  266. $     then
  267. $         set default 'here'
  268. $     endif
  269. $ endif
  270. $!
  271. $ if (f$type(OLD_VERIFY) .nes. "")
  272. $ then
  273. $     tmp = f$verify(OLD_VERIFY)
  274. $ endif
  275. $!
  276. $ exit
  277. $!
  278.