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