1$!------------------------------------------------------------------------------
2$! make "PNG: The Definitive Guide" demo programs (for X) under OpenVMS
3$!
4$! Script created by Martin Zinser for libpng; modified by Greg Roelofs
5$! for standalone pngbook source distribution.
6$!
7$!
8$!    Set locations where zlib and libpng sources live.
9$!
10$ zpath   = ""
11$ pngpath = ""
12$!
13$ if f$search("[---.zlib]zlib.h").nes."" then zpath = "[---.zlib]"
14$ if f$search("[--]png.h").nes."" then pngpath = "[--]"
15$!
16$ if f$search("[-.zlib]zlib.h").nes."" then zpath = "[-.zlib]"
17$ if f$search("[-.libpng]png.h").nes."" then pngpath = "[-.libpng]"
18$!
19$ if zpath .eqs. ""
20$ then
21$   write sys$output "zlib include not found. Exiting..."
22$   exit 2
23$ endif
24$!
25$ if pngpath .eqs. ""
26$ then
27$   write sys$output "libpng include not found. Exiting..."
28$   exit 2
29$ endif
30$!
31$!    Look for the compiler used.
32$!
33$ ccopt="/include=(''zpath',''pngpath')"
34$ if f$getsyi("HW_MODEL").ge.1024
35$ then
36$  ccopt = "/prefix=all"+ccopt
37$  comp  = "__decc__=1"
38$  if f$trnlnm("SYS").eqs."" then define sys sys$library:
39$ else
40$  if f$search("SYS$SYSTEM:DECC$COMPILER.EXE").eqs.""
41$   then
42$    if f$trnlnm("SYS").eqs."" then define sys sys$library:
43$    if f$search("SYS$SYSTEM:VAXC.EXE").eqs.""
44$     then
45$      comp  = "__gcc__=1"
46$      CC :== GCC
47$     else
48$      comp = "__vaxc__=1"
49$     endif
50$   else
51$    if f$trnlnm("SYS").eqs."" then define sys decc$library_include:
52$    ccopt = "/decc/prefix=all"+ccopt
53$    comp  = "__decc__=1"
54$  endif
55$ endif
56$ open/write lopt lib.opt
57$ write lopt "''pngpath'libpng.olb/lib"
58$ write lopt "''zpath'libz.olb/lib"
59$ close lopt
60$ open/write xopt x11.opt
61$ write xopt "sys$library:decw$xlibshr.exe/share"
62$ close xopt
63$!
64$!    Build 'em.
65$!
66$ write sys$output "Compiling PNG book programs ..."
67$   CALL MAKE readpng.OBJ "cc ''CCOPT' readpng" -
68	readpng.c readpng.h
69$   CALL MAKE readpng2.OBJ "cc ''CCOPT' readpng2" -
70	readpng2.c readpng2.h
71$   CALL MAKE writepng.OBJ "cc ''CCOPT' writepng" -
72	writepng.c writepng.h
73$   write sys$output "Building rpng-x..."
74$   CALL MAKE rpng-x.OBJ "cc ''CCOPT' rpng-x" -
75	rpng-x.c readpng.h
76$   call make rpng-x.exe -
77	"LINK rpng-x,readpng,lib.opt/opt,x11.opt/opt" -
78	rpng-x.obj readpng.obj
79$   write sys$output "Building rpng2-x..."
80$   CALL MAKE rpng2-x.OBJ "cc ''CCOPT' rpng2-x" -
81	rpng2-x.c readpng2.h
82$   call make rpng2-x.exe -
83	"LINK rpng2-x,readpng2,lib.opt/opt,x11.opt/opt" -
84	rpng2-x.obj readpng2.obj
85$   write sys$output "Building wpng..."
86$   CALL MAKE wpng.OBJ "cc ''CCOPT' wpng" -
87	wpng.c writepng.h
88$   call make wpng.exe -
89	"LINK wpng,writepng,lib.opt/opt" -
90	wpng.obj writepng.obj
91$ exit
92$!
93$!
94$MAKE: SUBROUTINE   !SUBROUTINE TO CHECK DEPENDENCIES
95$ V = 'F$Verify(0)
96$! P1 = What we are trying to make
97$! P2 = Command to make it
98$! P3 - P8  What it depends on
99$
100$ If F$Search(P1) .Eqs. "" Then Goto Makeit
101$ Time = F$CvTime(F$File(P1,"RDT"))
102$arg=3
103$Loop:
104$       Argument = P'arg
105$       If Argument .Eqs. "" Then Goto Exit
106$       El=0
107$Loop2:
108$       File = F$Element(El," ",Argument)
109$       If File .Eqs. " " Then Goto Endl
110$       AFile = ""
111$Loop3:
112$       OFile = AFile
113$       AFile = F$Search(File)
114$       If AFile .Eqs. "" .Or. AFile .Eqs. OFile Then Goto NextEl
115$       If F$CvTime(F$File(AFile,"RDT")) .Ges. Time Then Goto Makeit
116$       Goto Loop3
117$NextEL:
118$       El = El + 1
119$       Goto Loop2
120$EndL:
121$ arg=arg+1
122$ If arg .Le. 8 Then Goto Loop
123$ Goto Exit
124$
125$Makeit:
126$ VV=F$VERIFY(0)
127$ write sys$output P2
128$ 'P2
129$ VV='F$Verify(VV)
130$Exit:
131$ If V Then Set Verify
132$ENDSUBROUTINE
133