1$! File: Build_GNV_curl_pcsi_text.com
2$!
3$! $Id$
4$!
5$! Build the *.pcsi$text file from the four components:
6$!    1. Generated =product header section
7$!    2. [--]readme. file from the Curl distribution, modified to fit
8$!       a pcsi$text file format.
9$!    3. [--]copying file from the Curl distribution, modified to fit
10$!       a pcsi$text file format.
11$!    4. Generated Producer section.
12$!
13$! Set the name of the release notes from the GNV_PCSI_FILENAME_BASE
14$!
15$! Copyright 2009, John Malmberg
16$!
17$! Permission to use, copy, modify, and/or distribute this software for any
18$! purpose with or without fee is hereby granted, provided that the above
19$! copyright notice and this permission notice appear in all copies.
20$!
21$! THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
22$! WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
23$! MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
24$! ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
25$! WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
26$! ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
27$! OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
28$!
29$!
30$! 15-Jun-2009  J. Malmberg
31$!
32$!===========================================================================
33$!
34$ kit_name = f$trnlnm("GNV_PCSI_KITNAME")
35$ if kit_name .eqs. ""
36$ then
37$   write sys$output "@MAKE_PCSI_CURL_KIT_NAME.COM has not been run."
38$   goto all_exit
39$ endif
40$ producer = f$trnlnm("GNV_PCSI_PRODUCER")
41$ if producer .eqs. ""
42$ then
43$   write sys$output "@MAKE_PCSI_CURL_KIT_NAME.COM has not been run."
44$   goto all_exit
45$ endif
46$ producer_full_name = f$trnlnm("GNV_PCSI_PRODUCER_FULL_NAME")
47$ if producer_full_name .eqs. ""
48$ then
49$   write sys$output "@MAKE_PCSI_CURL_KIT_NAME.COM has not been run."
50$   goto all_exit
51$ endif
52$!
53$!
54$! Parse the kit name into components.
55$!---------------------------------------
56$ producer = f$element(0, "-", kit_name)
57$ base = f$element(1, "-", kit_name)
58$ product = f$element(2, "-", kit_name)
59$ mmversion = f$element(3, "-", kit_name)
60$ majorver = f$extract(0, 3, mmversion)
61$ minorver = f$extract(3, 2, mmversion)
62$ updatepatch = f$element(4, "-", kit_name)
63$ if updatepatch .eqs. "-" then updatepatch = ""
64$!
65$!
66$ product_line = "=product ''producer' ''base' ''product'"
67$ if updatepatch .eqs. ""
68$ then
69$     product_name = " ''majorver'.''minorver'"
70$ else
71$     product_name = " ''majorver'.''minorver'-''updatepatch'"
72$ endif
73$ product_line = product_line + " ''product_name' full"
74$!
75$!
76$! If this is VAX and the file is on NFS, the names may be mangled.
77$!-----------------------------------------------------------------
78$ readme_file = ""
79$ if f$search("[--]readme.") .nes. ""
80$ then
81$   readme_file = "[--]readme."
82$ else
83$   if f$search("[--]$README.") .nes. ""
84$   then
85$       readme_file = "[--]$README."
86$   else
87$       write sys$output "Can not find readme file."
88$       goto all_exit
89$   endif
90$ endif
91$ copying_file = ""
92$ if f$search("[--]copying.") .nes. ""
93$ then
94$   copying_file = "[--]copying."
95$ else
96$   if f$search("[--]$COPYING.") .nes. ""
97$   then
98$       copying_file = "[--]$COPYING."
99$   else
100$       write sys$output "Can not find copying file."
101$       goto all_exit
102$   endif
103$ endif
104$!
105$! Create the file as a VMS text file.
106$!----------------------------------------
107$ base_file = kit_name
108$ create 'base_file'.pcsi$text
109$!
110$!
111$! Start building file.
112$!----------------------
113$ open/append ptxt 'base_file'.pcsi$text
114$ write ptxt product_line
115$!
116$!
117$! First insert the Readme file.
118$!
119$ open/read rf 'readme_file'
120$!
121$ write ptxt "1 'PRODUCT"
122$ write ptxt "=prompt ''producter' ''product' for OpenVMS"
123$!
124$rf_loop:
125$   read/end=rf_loop_end rf line_in
126$   if line_in .nes. ""
127$   then
128$!    PCSI files use the first character in for their purposes.
129$!--------------------------------------------------------------
130$     first_char = f$extract(0, 1, line_in)
131$     if first_char .nes. " " then line_in = " " + line_in
132$   endif
133$   write ptxt line_in
134$   goto rf_loop
135$rf_loop_end:
136$ close rf
137$!
138$!
139$! Now add in the copying file
140$!--------------------------------
141$ write ptxt ""
142$ write ptxt "1 'NOTICE"
143$ write ptxt ""
144$!
145$ open/read cf 'copying_file'
146$!
147$cf_loop:
148$   read/end=cf_loop_end cf line_in
149$   if line_in .nes. ""
150$   then
151$!    PCSI files use the first character in for their purposes.
152$!--------------------------------------------------------------
153$     first_char = f$extract(0, 1, line_in)
154$     if first_char .nes. " " then line_in = " " + line_in
155$   endif
156$   write ptxt line_in
157$   goto cf_loop
158$cf_loop_end:
159$ close cf
160$!
161$! Now we need the rest of the boiler plate.
162$!--------------------------------------------
163$ write ptxt ""
164$ write ptxt "1 'PRODUCER"
165$ write ptxt "=prompt ''producer_full_name'"
166$ write ptxt -
167 "This software product is provided by ''producer_full_name' with no warranty."
168$!
169$ arch_type = f$getsyi("ARCH_NAME")
170$ node_swvers = f$getsyi("node_swvers")
171$ vernum = f$extract(1, f$length(node_swvers), node_swvers)
172$ majver = f$element(0, ".", vernum)
173$ minverdash = f$element(1, ".", vernum)
174$ minver = f$element(0, "-", minverdash)
175$ dashver = f$element(1, "-", minverdash)
176$ if dashver .eqs. "-" then dashver = ""
177$ vmstag = majver + minver + dashver
178$ code = f$extract(0, 1, arch_type)
179$!
180$ write ptxt "1 NEED_VMS''vmstag'"
181$ write ptxt -
182   "=prompt OpenVMS ''vernum' or later is not installed on your system."
183$ write ptxt "This product requires OpenVMS ''vernum' or later to function."
184$ write ptxt "1 NEED_ZLIB"
185$ write ptxt "=prompt ZLIB 1.2-8 or later is not installed on your system."
186$ write ptxt "This product requires ZLIB 1.2-8 or later to function."
187$ write ptxt "1 SOURCE"
188$ write ptxt "=prompt Source modules for ''product'"
189$ write ptxt "The Source modules for ''product' will be installed."
190$ write ptxt "1 RELEASE_NOTES"
191$ write ptxt "=prompt Release notes are available in the [SYSHLP] directory."
192$!
193$ close ptxt
194$!
195$!
196$!
197$all_exit:
198$ exit
199