]> git.lizzy.rs Git - zlib.git/blob - make_vms.com
zlib 1.2.3.1
[zlib.git] / make_vms.com
1 $! make libz under VMS written by
2 $! Martin P.J. Zinser
3 $!
4 $! In case of problems with the install you might contact me at
5 $! zinser@zinser.no-ip.info(preferred) or
6 $! zinser@sysdev.deutsche-boerse.com (work)
7 $!
8 $! Make procedure history for Zlib
9 $!
10 $!------------------------------------------------------------------------------
11 $! Version history
12 $! 0.01 20060120 First version to receive a number
13 $!
14 $ on error then goto err_exit
15 $!
16 $!
17 $! Just some general constants...
18 $!
19 $ true  = 1
20 $ false = 0
21 $ tmpnam = "temp_" + f$getjpi("","pid")
22 $ its_decc = false
23 $ its_vaxc = false
24 $ its_gnuc = false
25 $ s_case   = False
26 $!
27 $! Setup variables holding "config" information
28 $!
29 $ Make     = ""
30 $ name     = "Zlib"
31 $ version  = "?.?.?"
32 $ v_string = "ZLIB_VERSION"
33 $ v_file   = "zlib.h"
34 $ ccopt    = ""
35 $ lopts    = ""
36 $ dnsrl   = ""
37 $ linkonly = false
38 $ optfile  = name + ".opt"
39 $ axp      = f$getsyi("HW_MODEL").ge.1024
40 $!
41 $! Check for MMK/MMS
42 $!
43 $ If F$Search ("Sys$System:MMS.EXE") .nes. "" Then Make = "MMS"
44 $ If F$Type (MMK) .eqs. "STRING" Then Make = "MMK"
45 $!
46 $!
47 $ gosub find_version
48 $!
49 $ gosub check_opts
50 $!
51 $! Look for the compiler used
52 $!
53 $ gosub check_compiler
54 $ if its_decc
55 $ then
56 $   ccopt = "/prefix=all" + ccopt
57 $   if f$trnlnm("SYS") .eqs. ""
58 $   then
59 $     if axp
60 $     then
61 $       define sys sys$library:
62 $     else
63 $       ccopt = "/decc" + ccopt
64 $       define sys decc$library_include:
65 $     endif
66 $   endif
67 $ endif
68 $ if its_vaxc .or. its_gnuc
69 $ then
70 $    if f$trnlnm("SYS").eqs."" then define sys sys$library:
71 $ endif
72 $!
73 $! Build the thing plain or with mms
74 $!
75 $ write sys$output "Compiling Zlib sources ..."
76 $ if make.eqs.""
77 $  then
78 $   dele example.obj;*,minigzip.obj;*
79 $   CALL MAKE adler32.OBJ "CC ''CCOPT' adler32" -
80                 adler32.c zlib.h zconf.h
81 $   CALL MAKE compress.OBJ "CC ''CCOPT' compress" -
82                 compress.c zlib.h zconf.h
83 $   CALL MAKE crc32.OBJ "CC ''CCOPT' crc32" -
84                 crc32.c zlib.h zconf.h
85 $   CALL MAKE deflate.OBJ "CC ''CCOPT' deflate" -
86                 deflate.c deflate.h zutil.h zlib.h zconf.h
87 $   CALL MAKE gzio.OBJ "CC ''CCOPT' gzio" -
88                 gzio.c zutil.h zlib.h zconf.h
89 $   CALL MAKE infback.OBJ "CC ''CCOPT' infback" -
90                 infback.c zutil.h inftrees.h inflate.h inffast.h inffixed.h
91 $   CALL MAKE inffast.OBJ "CC ''CCOPT' inffast" -
92                 inffast.c zutil.h zlib.h zconf.h inffast.h
93 $   CALL MAKE inflate.OBJ "CC ''CCOPT' inflate" -
94                 inflate.c zutil.h zlib.h zconf.h infblock.h
95 $   CALL MAKE inftrees.OBJ "CC ''CCOPT' inftrees" -
96                 inftrees.c zutil.h zlib.h zconf.h inftrees.h
97 $   CALL MAKE trees.OBJ "CC ''CCOPT' trees" -
98                 trees.c deflate.h zutil.h zlib.h zconf.h
99 $   CALL MAKE uncompr.OBJ "CC ''CCOPT' uncompr" -
100                 uncompr.c zlib.h zconf.h
101 $   CALL MAKE zutil.OBJ "CC ''CCOPT' zutil" -
102                 zutil.c zutil.h zlib.h zconf.h
103 $   write sys$output "Building Zlib ..."
104 $   CALL MAKE libz.OLB "lib/crea libz.olb *.obj" *.OBJ
105 $   write sys$output "Building example..."
106 $   CALL MAKE example.OBJ "CC ''CCOPT' example" -
107                 example.c zlib.h zconf.h
108 $   call make example.exe "LINK example,libz.olb/lib" example.obj libz.olb
109 $   if f$search("x11vms:xvmsutils.olb") .nes. ""
110 $   then
111 $     write sys$output "Building minigzip..."
112 $     CALL MAKE minigzip.OBJ "CC ''CCOPT' minigzip" -
113                 minigzip.c zlib.h zconf.h
114 $     call make minigzip.exe -
115                 "LINK minigzip,libz.olb/lib,x11vms:xvmsutils.olb/lib" -
116                 minigzip.obj libz.olb
117 $   endif
118 $  else
119 $   gosub crea_mms
120 $   write sys$output "Make ''name' ''version' with ''Make' "
121 $   'make'
122 $  endif
123 $!
124 $! Alpha gets a shareable image
125 $!
126 $ If axp
127 $ Then
128 $   gosub crea_olist
129 $   write sys$output "Creating libzshr.exe"
130 $   call anal_obj_axp modules.opt _link.opt
131 $   if s_case
132 $   then
133 $      open/append optf modules.opt
134 $      write optf "case_sensitive=YES"
135 $      close optf
136 $   endif
137 $   LINK_'lopts'/SHARE=libzshr.exe modules.opt/opt,_link.opt/opt
138 $ endif
139 $ write sys$output "Zlib build completed"
140 $ exit
141 $CC_ERR:
142 $ write sys$output "C compiler required to build ''name'"
143 $ goto err_exit
144 $ERR_EXIT:
145 $ set message/facil/ident/sever/text
146 $ close/nolog optf
147 $ write sys$output "Exiting..."
148 $ exit 2
149 $!
150 $!
151 $MAKE: SUBROUTINE   !SUBROUTINE TO CHECK DEPENDENCIES
152 $ V = 'F$Verify(0)
153 $! P1 = What we are trying to make
154 $! P2 = Command to make it
155 $! P3 - P8  What it depends on
156 $
157 $ If F$Search(P1) .Eqs. "" Then Goto Makeit
158 $ Time = F$CvTime(F$File(P1,"RDT"))
159 $arg=3
160 $Loop:
161 $       Argument = P'arg
162 $       If Argument .Eqs. "" Then Goto Exit
163 $       El=0
164 $Loop2:
165 $       File = F$Element(El," ",Argument)
166 $       If File .Eqs. " " Then Goto Endl
167 $       AFile = ""
168 $Loop3:
169 $       OFile = AFile
170 $       AFile = F$Search(File)
171 $       If AFile .Eqs. "" .Or. AFile .Eqs. OFile Then Goto NextEl
172 $       If F$CvTime(F$File(AFile,"RDT")) .Ges. Time Then Goto Makeit
173 $       Goto Loop3
174 $NextEL:
175 $       El = El + 1
176 $       Goto Loop2
177 $EndL:
178 $ arg=arg+1
179 $ If arg .Le. 8 Then Goto Loop
180 $ Goto Exit
181 $
182 $Makeit:
183 $ VV=F$VERIFY(0)
184 $ write sys$output P2
185 $ 'P2
186 $ VV='F$Verify(VV)
187 $Exit:
188 $ If V Then Set Verify
189 $ENDSUBROUTINE
190 $!------------------------------------------------------------------------------
191 $!
192 $! Check command line options and set symbols accordingly
193 $!
194 $ CHECK_OPTS:
195 $ i = 1
196 $ OPT_LOOP:
197 $ if i .lt. 9
198 $ then
199 $   cparm = f$edit(p'i',"upcase")
200 $   if cparm .eqs. "DEBUG"
201 $   then
202 $     ccopt = ccopt + "/noopt/deb"
203 $     lopts = lopts + "/deb"
204 $   endif
205 $   if f$locate("CCOPT=",cparm) .lt. f$length(cparm)
206 $   then
207 $     start = f$locate("=",cparm) + 1
208 $     len   = f$length(cparm) - start
209 $     ccopt = ccopt + f$extract(start,len,cparm)
210 $     if f$locate("AS_IS",f$edit(ccopt,"UPCASE")) .lt. f$length(ccopt) -
211          then s_case = true
212 $   endif
213 $   if cparm .eqs. "LINK" then linkonly = true
214 $   if f$locate("LOPTS=",cparm) .lt. f$length(cparm)
215 $   then
216 $     start = f$locate("=",cparm) + 1
217 $     len   = f$length(cparm) - start
218 $     lopts = lopts + f$extract(start,len,cparm)
219 $   endif
220 $   if f$locate("CC=",cparm) .lt. f$length(cparm)
221 $   then
222 $     start  = f$locate("=",cparm) + 1
223 $     len    = f$length(cparm) - start
224 $     cc_com = f$extract(start,len,cparm)
225       if (cc_com .nes. "DECC") .and. -
226          (cc_com .nes. "VAXC") .and. -
227          (cc_com .nes. "GNUC")
228 $     then
229 $       write sys$output "Unsupported compiler choice ''cc_com' ignored"
230 $       write sys$output "Use DECC, VAXC, or GNUC instead"
231 $     else
232 $       if cc_com .eqs. "DECC" then its_decc = true
233 $       if cc_com .eqs. "VAXC" then its_vaxc = true
234 $       if cc_com .eqs. "GNUC" then its_gnuc = true
235 $     endif
236 $   endif
237 $   if f$locate("MAKE=",cparm) .lt. f$length(cparm)
238 $   then
239 $     start  = f$locate("=",cparm) + 1
240 $     len    = f$length(cparm) - start
241 $     mmks = f$extract(start,len,cparm)
242 $     if (mmks .eqs. "MMK") .or. (mmks .eqs. "MMS")
243 $     then
244 $       make = mmks
245 $     else
246 $       write sys$output "Unsupported make choice ''mmks' ignored"
247 $       write sys$output "Use MMK or MMS instead"
248 $     endif
249 $   endif
250 $   i = i + 1
251 $   goto opt_loop
252 $ endif
253 $ return
254 $!------------------------------------------------------------------------------
255 $!
256 $! Look for the compiler used
257 $!
258 $! Version history
259 $! 0.01 20040223 First version to receive a number
260 $! 0.02 20040229 Save/set value of decc$no_rooted_search_lists
261 $CHECK_COMPILER:
262 $ if (.not. (its_decc .or. its_vaxc .or. its_gnuc))
263 $ then
264 $   its_decc = (f$search("SYS$SYSTEM:DECC$COMPILER.EXE") .nes. "")
265 $   its_vaxc = .not. its_decc .and. (F$Search("SYS$System:VAXC.Exe") .nes. "")
266 $   its_gnuc = .not. (its_decc .or. its_vaxc) .and. (f$trnlnm("gnu_cc") .nes. "")
267 $ endif
268 $!
269 $! Exit if no compiler available
270 $!
271 $ if (.not. (its_decc .or. its_vaxc .or. its_gnuc))
272 $ then goto CC_ERR
273 $ else
274 $   if its_decc
275 $   then
276 $     write sys$output "CC compiler check ... Compaq C"
277 $     if f$trnlnm("decc$no_rooted_search_lists") .nes. ""
278 $     then
279 $       dnrsl = f$trnlnm("decc$no_rooted_search_lists")
280 $     endif
281 $     define decc$no_rooted_search_lists 1
282 $   else
283 $     if its_vaxc then write sys$output "CC compiler check ... VAX C"
284 $     if its_gnuc then write sys$output "CC compiler check ... GNU C"
285 $     if f$trnlnm(topt) then write topt "sys$share:vaxcrtl.exe/share"
286 $     if f$trnlnm(optf) then write optf "sys$share:vaxcrtl.exe/share"
287 $   endif
288 $ endif
289 $ return
290 $!------------------------------------------------------------------------------
291 $!
292 $! If MMS/MMK are available dump out the descrip.mms if required
293 $!
294 $CREA_MMS:
295 $ write sys$output "Creating descrip.mms..."
296 $ create descrip.mms
297 $ open/append out descrip.mms
298 $ copy sys$input: out
299 $ deck
300 # descrip.mms: MMS description file for building zlib on VMS
301 # written by Martin P.J. Zinser
302 # <zinser@zinser.no-ip.info or zinser@sysdev.deutsche-boerse.com>
303
304 OBJS = adler32.obj, compress.obj, crc32.obj, gzio.obj, uncompr.obj, infback.obj\
305        deflate.obj, trees.obj, zutil.obj, inflate.obj, \
306        inftrees.obj, inffast.obj
307
308 $ eod
309 $ write out "CFLAGS=", ccopt
310 $ write out "LOPTS=", lopts
311 $ copy sys$input: out
312 $ deck
313
314 all : example.exe minigzip.exe libz.olb
315         @ write sys$output " Example applications available"
316
317 libz.olb : libz.olb($(OBJS))
318         @ write sys$output " libz available"
319
320 example.exe : example.obj libz.olb
321               link $(LOPTS) example,libz.olb/lib
322
323 minigzip.exe : minigzip.obj libz.olb
324               link $(LOPTS) minigzip,libz.olb/lib,x11vms:xvmsutils.olb/lib
325
326 clean :
327         delete *.obj;*,libz.olb;*,*.opt;*,*.exe;*
328
329
330 # Other dependencies.
331 adler32.obj  : adler32.c zutil.h zlib.h zconf.h
332 compress.obj : compress.c zlib.h zconf.h
333 crc32.obj    : crc32.c zutil.h zlib.h zconf.h
334 deflate.obj  : deflate.c deflate.h zutil.h zlib.h zconf.h
335 example.obj  : example.c zlib.h zconf.h
336 gzio.obj     : gzio.c zutil.h zlib.h zconf.h
337 inffast.obj  : inffast.c zutil.h zlib.h zconf.h inftrees.h inffast.h
338 inflate.obj  : inflate.c zutil.h zlib.h zconf.h
339 inftrees.obj : inftrees.c zutil.h zlib.h zconf.h inftrees.h
340 minigzip.obj : minigzip.c zlib.h zconf.h
341 trees.obj    : trees.c deflate.h zutil.h zlib.h zconf.h
342 uncompr.obj  : uncompr.c zlib.h zconf.h
343 zutil.obj    : zutil.c zutil.h zlib.h zconf.h
344 infback.obj  : infback.c zutil.h inftrees.h inflate.h inffast.h inffixed.h
345 $ eod
346 $ close out
347 $ return
348 $!------------------------------------------------------------------------------
349 $!
350 $! Read list of core library sources from makefile.in and create options
351 $! needed to build shareable image
352 $!
353 $CREA_OLIST:
354 $ open/read min makefile.in
355 $ open/write mod modules.opt
356 $ src_check = "OBJS ="
357 $MRLOOP:
358 $ read/end=mrdone min rec
359 $ if (f$extract(0,6,rec) .nes. src_check) then goto mrloop
360 $ rec = rec - src_check
361 $ gosub extra_filnam
362 $ if (f$element(1,"\",rec) .eqs. "\") then goto mrdone
363 $MRSLOOP:
364 $ read/end=mrdone min rec
365 $ gosub extra_filnam
366 $ if (f$element(1,"\",rec) .nes. "\") then goto mrsloop
367 $MRDONE:
368 $ close min
369 $ close mod
370 $ return
371 $!------------------------------------------------------------------------------
372 $!
373 $! Take record extracted in crea_olist and split it into single filenames
374 $!
375 $EXTRA_FILNAM:
376 $ myrec = f$edit(rec - "\", "trim,compress")
377 $ i = 0
378 $FELOOP:
379 $ srcfil = f$element(i," ", myrec)
380 $ if (srcfil .nes. " ")
381 $ then
382 $   write mod f$parse(srcfil,,,"NAME"), ".obj"
383 $   i = i + 1
384 $   goto feloop
385 $ endif
386 $ return
387 $!------------------------------------------------------------------------------
388 $!
389 $! Find current Zlib version number
390 $!
391 $FIND_VERSION:
392 $ open/read h_in 'v_file'
393 $hloop:
394 $ read/end=hdone h_in rec
395 $ rec = f$edit(rec,"TRIM")
396 $ if (f$extract(0,1,rec) .nes. "#") then goto hloop
397 $ rec = f$edit(rec - "#", "TRIM")
398 $ if f$element(0," ",rec) .nes. "define" then goto hloop
399 $ if f$element(1," ",rec) .eqs. v_string
400 $ then
401 $   version = 'f$element(2," ",rec)'
402 $   goto hdone
403 $ endif
404 $ goto hloop
405 $hdone:
406 $ close h_in
407 $ return
408 $!------------------------------------------------------------------------------
409 $!
410 $! Analyze Object files for OpenVMS AXP to extract Procedure and Data 
411 $! information to build a symbol vector for a shareable image
412 $! All the "brains" of this logic was suggested by Hartmut Becker
413 $! (Hartmut.Becker@compaq.com). All the bugs were introduced by me
414 $! (zinser@zinser.no-ip.info), so if you do have problem reports please do not
415 $! bother Hartmut/HP, but get in touch with me
416 $!
417 $! Version history
418 $! 0.01 20040406 Skip over shareable images in option file
419 $! 0.02 20041109 Fix option file for shareable images with case_sensitive=YES
420 $! 0.03 20050107 Skip over Identification labels in option file
421 $! 0.04 20060117 Add uppercase alias to code compiled with /name=as_is
422 $!
423 $ ANAL_OBJ_AXP: Subroutine   
424 $ V = 'F$Verify(0)
425 $ SAY := "WRITE_ SYS$OUTPUT"
426
427 $ IF F$SEARCH("''P1'") .EQS. ""
428 $ THEN
429 $    SAY "ANAL_OBJ_AXP-E-NOSUCHFILE:  Error, inputfile ''p1' not available"
430 $    goto exit_aa
431 $ ENDIF
432 $ IF "''P2'" .EQS. ""
433 $ THEN
434 $    SAY "ANAL_OBJ_AXP:  Error, no output file provided"
435 $    goto exit_aa
436 $ ENDIF
437 $
438 $ open/read in 'p1
439 $ create a.tmp
440 $ open/append atmp a.tmp
441 $ loop:
442 $ read/end=end_loop in line
443 $ if f$locate("/SHARE",f$edit(line,"upcase")) .lt. f$length(line)
444 $ then
445 $   write sys$output "ANAL_SKP_SHR-i-skipshare, ''line'"
446 $   goto loop
447 $ endif
448 $ if f$locate("IDENTIFICATION=",f$edit(line,"upcase")) .lt. f$length(line)
449 $ then
450 $   write sys$output "ANAL_OBJ_AXP-i-ident: Identification ", -
451                      f$element(1,"=",line)
452 $   goto loop
453 $ endif
454 $ f= f$search(line)
455 $ if f .eqs. ""
456 $ then
457 $       write sys$output "ANAL_OBJ_AXP-w-nosuchfile, ''line'"
458 $       goto loop
459 $ endif
460 $ define/user sys$output nl:
461 $ define/user sys$error nl:
462 $ anal/obj/gsd 'f /out=x.tmp
463 $ open/read xtmp x.tmp
464 $ XLOOP:
465 $ read/end=end_xloop xtmp xline
466 $ xline = f$edit(xline,"compress")
467 $ write atmp xline
468 $ goto xloop
469 $ END_XLOOP:
470 $ close xtmp
471 $ goto loop
472 $ end_loop:
473 $ close in
474 $ close atmp
475 $ if f$search("a.tmp") .eqs. "" -
476         then $ exit
477 $ ! all global definitions
478 $ search a.tmp "symbol:","EGSY$V_DEF 1","EGSY$V_NORM 1"/out=b.tmp
479 $ ! all procedures
480 $ search b.tmp "EGSY$V_NORM 1"/wind=(0,1) /out=c.tmp
481 $ search c.tmp "symbol:"/out=d.tmp
482 $ define/user sys$output nl:
483 $ edito/edt/command=sys$input d.tmp
484 sub/symbol: "/symbol_vector=(/whole
485 sub/"/=PROCEDURE)/whole
486 exit
487 $ ! all data
488 $ search b.tmp "EGSY$V_DEF 1"/wind=(0,1) /out=e.tmp
489 $ search e.tmp "symbol:"/out=f.tmp
490 $ define/user sys$output nl:
491 $ edito/edt/command=sys$input f.tmp
492 sub/symbol: "/symbol_vector=(/whole
493 sub/"/=DATA)/whole
494 exit
495 $ sort/nodupl d.tmp,f.tmp g.tmp
496 $ open/read raw_vector g.tmp
497 $ open/write case_vector 'p2'
498 $ RAWLOOP:
499 $ read/end=end_rawloop raw_vector raw_element
500 $ write case_vector raw_element
501 $ if f$locate("=PROCEDURE)",raw_element) .lt. f$length(raw_element)
502 $ then
503 $     name = f$element(1,"=",raw_element) - "("
504 $     if f$edit(name,"UPCASE") .nes. name then -
505           write case_vector f$fao(" symbol_vector=(!AS/!AS=PROCEDURE)", - 
506                                   f$edit(name,"UPCASE"), name) 
507 $ endif
508 $ if f$locate("=DATA)",raw_element) .lt. f$length(raw_element)
509 $ then
510 $     name = f$element(1,"=",raw_element) - "("
511 $     if f$edit(name,"UPCASE") .nes. name then -
512           write case_vector f$fao(" symbol_vector=(!AS/!AS=DATA)", - 
513                                   f$edit(name,"UPCASE"), name) 
514 $ endif
515 $ goto rawloop
516 $ END_RAWLOOP:
517 $ close raw_vector
518 $ close case_vector
519 $ delete a.tmp;*,b.tmp;*,c.tmp;*,d.tmp;*,e.tmp;*,f.tmp;*,g.tmp;*
520 $ if f$search("x.tmp") .nes. "" -
521         then $ delete x.tmp;*
522 $!
523 $ EXIT_AA:
524 $ if V then set verify
525 $ endsubroutine 
526 $!------------------------------------------------------------------------------