1$!x='f$ver(0)'
2$!
3$ pgpinsver="1.0i"
4$ pgpver="263i"
5$ pgpver_human ="2.6.3i"
6$!
7$!Program:	PGPINSTAL.COM V1.0i for PGP 2.6.3i
8$!
9$!Description:
10$!	Given the presence of appropriately named & files,
11$!	this procedure will attempt to construct a VMS executable
12$!	called PGP.EXE.
13$!
14$!Instructions:
15$!	1) Type "@PGPINSTAL" and answer the questions (do NOT type the quotes)
16$!
17$!	Note: If you know that the default answers are correct, then you can
18$!	  simply type "@PGPINSTAL 1" and the procedure will start
19$!	  directly
20$!
21$!End-User notes:
22$!	* YOU MUST BE USING VAXC or DECC!
23$!	* YOU MUST BE BUILDING PGP 2.6.3i from the source distribution!
24$!	* The debug & optimize flags are in a line beginning 'dbg='... search
25$!	  for this & modify as needed.  The default distribution is /nodebug
26$!	  and /opt=noinline (due to an _old_ vaxc optimizer bug...)
27$!	* Note that md5.c is an exception under VAX/DECC - must be /noopt or
28$!	  the compiler will hang :(
29$!	* if any {p1..p4} is nonnull then an immediate install will be attempted
30$!	* if p1 is nonnull, then p1 is assumed to be the location of pgp
31$!	  distribution & all other values default if possible.
32$!	* if p2 is nonnull, then p2 is the default UNZIP definition
33$!	* if p3 is nonnull, then p3 is the default dir for top-level
34$!	* if p4 is nonnull, then p4 is the default top-level name
35$!
36$!Implementation notes:
37$!	* There are some lines of code present in this module that are
38$!	  disabled, but they're useful reference material, so they got
39$!	  left here.
40$!	* if p1 is of the form '@label', then at top of build procedure,
41$!	  a jump is performed to the requested label to bypass portions
42$!	  of the build (needed for relinking, for example)
43$!	    o **This is NOT intended to be a supported function!**
44$!	    o P2 now must be nonnull to force immediate mode
45$!	    o This option is for debugging purposes only and most of the
46$!	      start/stop pairs are not in place, but may be added. You
47$!	      should read & understand the DCL if you want to add these.
48$!	    o The $LNK_START entrypoint can be used to re-link
49$!
50$ jumpto = f$elem(1,"@","''p1'")
51$ jump = jumpto.nes."@"
52$ if jump then p1=""
53$ immediate = ("''p1'"+"''p2'"+"''p3'"+"''p4'").nes.""
54$ if jump then p2=""
55$ if jump.and.immediate then p1="sys$login:login.com"
56$!
57$restart_install:
58$ on control_c then goto halt
59$ on control_y then goto halt
60$ say="write sys$output"
61$ ask="call ask_user"
62$ edit="edit"
63$ delete="delete"
64$ start_dir = f$environment("default")
65$ call get_hw_model
66$ hw_model = f$int(f$trnlnm("hw_model"))
67$ deassign hw_model
68$ if hw_model .ge. 1024
69$ then
70    say "%PGPINSTAL-I-ALPHA, Target architecture is ALPHA/VMS"
71$   macopts="/migrate/nowarn/nodeb/opt"
72$   lnkopts="/notrace/map"
73$   cc="cc/stan=vaxc/nomember_align"
74$   cdefs=""
75$   alpha=1
76$   vax=0
77$   archltr="a"
78$   mach="Alpha"
79$   mach2="n Alpha"
80$   estspace=11000
81$ else
82    say "%PGPINSTAL-I-VAX, Target architecture is VAX/VMS"
83$   macopts=""
84$   lnkopts="/notrace/map"
85$   cc="cc"
86$   cdefs=""
87$   alpha=0
88$   vax=1
89$   archltr="v"
90$   mach="VAX"
91$   mach2=" VAX"
92$   estspace=8500
93$ endif
94$ wait 0:0:2 !Long enough to see target message
95$ goto start_install
96$!
97$get_hw_model: subroutine
98$ mess=f$environment("message")
99$ set mess/nofacility/noident/noseverity/notext
100$ x=0
101$ set noon
102$ x=f$getsyi("hw_model")
103$ set mess 'mess'
104$ define hw_model 'x'
105$ endsubroutine
106$!
107$ask_user: subroutine !p1=question, p2=lognam_to_define, p3=default
108$ on control_c then goto bomb
109$ on control_y then goto bomb
110$retry_input:
111$ if "''p3'".nes.""
112$ then
113$   if immediate
114$   then
115$     line="''p3'"
116$   else
117$     read/end=bomb/prompt="''p1'? [''p3'] " sys$command line
118$   endif
119$ else
120$   if immediate
121$   then
122$     say "%PGPINSTAL-E-NOIMMED, Immediate installation failed"
123$     say "%PGPINSTAL-F-INPREQD, Input is required for /''p1'/"
124$     exit 20
125$   endif
126$   read/end=bomb/prompt="''p1'? " sys$command line
127$ endif
128$ if "''p3'".nes."" then if "''line'".eqs."" then line=p3
129$ if "''line'".eqs."" then -
130  say "%PGPINSTAL-E-INPREQD, Input is required here - please retry"
131$ if "''line'".eqs."" then -
132  goto retry_input
133$ define/nolog 'p2' "''line'"
134$ exit 1
135$bomb:
136$!x='f$ver(0)'
137$ say "%PGPINSTAL-F-INSABORT, Installation has been aborted"
138$ exit 2160+%x10000000
139$ endsubroutine
140$halt:
141$!x='f$ver(0)'
142$ say "%PGPINSTAL-F-INSABORT, Installation has been aborted"
143$ exit 2160+%x10000000
144$start_install:
145$ if immediate then goto skip_lecture
146$ say ""
147$ say "Hello"
148$ say ""
149$ say "Welcome to the PGP ''pgpver_human' automated build procedure for OpenVMS."
150$ say "You seem to be running on a''mach2'... Parameters will be adjusted accordingly."
151$ say ""
152$ say "There are several prerequisites for building PGP ''pgpver_human' on your ''mach':
153$ say "	1) A''mach2' (which you already appear to have...)"
154$ say "	2) A VAXC or DECC compiler & A license*"
155$ say "	3) Time & disk space (about ''estspace' blocks)"
156$ say ""
157$ say "If you do not have one or more of these items, then now would be a good"
158$ say "time to either retrieve whatever is missing, or stop this installation."
159$ say ""
160$ say "*This procedure allows substitution - you will be prompted and allowed to"
161$ say " re-specify the cc command definition."
162$ say ""
163$ say "^Z terminates when expecting input... ^Y aborts the procedure"
164$ read/end=halt/prompt="Press return..." sys$command junk
165$ say ""
166$ say ""
167$ say "You will be asked the following questions... please take a moment and"
168$ say "ascertain the answers to these before continuing.  It will make life at"
169$ say "least a tiny bit easier."
170$ say ""
171$ say "	1) What should the CC command be defined as?"
172$ say ""
173$ say "This will be defaulted if possible."
174$ say ""
175$ read/end=halt/prompt="Press return..." sys$command junk
176$ say ""
177$ say "Please note any errors you receive running this procedure.  I am trying"
178$ say "to keep this procedure up to date with the latest release of PGP, and"
179$ say "I'm also fairly sure that there are situations possible where this procedure"
180$ say "may not operate correctly."
181$ say ""
182$ say "If you do get errors - please make certain of a few things:"
183$ say "  1) That you are using VAXC or DECC as opposed to GNUC"
184$ say "  2) That your PGP''pgpver' distribution has not been tampered with"
185$ say ""
186$ read/end=halt/prompt="Press return..." sys$command junk
187$skip_lecture:
188$!
189$!Sniff out the environment & ask the user the questions
190$!
191$ if .not.immediate then -
192  say ""
193$!
194$!Look for VAXC/DECC - Allow user to override... maybe gnu works for all I know
195$ vaxc="N"
196$ ccname=""
197$ if alpha then goto skip_vaxc
198$ if (f$search("vaxc").nes."") .or. -
199     (f$search("sys$system:vaxc.exe").nes."")
200$ then
201$   vaxc="Y"
202$   ccname="VAXC"
203$   say "%PGPINSTAL-I-VAXC, VAXC.EXE located - defaulting to VAXC"
204$ endif
205$ decc="N"
206$ if vaxc then goto skip_decc
207$skip_vaxc:
208$ decc="N"
209$ if (f$search("decc$compiler").nes."") .or. -
210     (f$search("sys$system:decc$compiler.exe").nes."")
211$ then
212$   decc="Y"
213$   ccname="DECC"
214$   if cc.eqs."cc" then cc="cc/stan=vaxc"
215$   say "%PGPINSTAL-I-DECC, DECC$COMPILER located - defaulting to DECC"
216$ endif
217$skip_decc:
218$ if .not.(DECC .or. VAXC)
219$ then
220$   say "%PGPINSTAL-W-NODEFCC, No default C compiler located"
221$  !Just assume a generic equivalence based on platform architecture
222$   ccname="Generic_VAXC"
223$   if alpha then ccname="Generic_DECC"
224$ endif
225$!
226$!Modify compiler definition
227$ say "%PGPINSTAL-I-CURRCC, Current CC commpiler is ""''ccname'"""
228$ say "%PGPINSTAL-I-CCDEF, CC command is ""''cc'"""
229$ ask "Define cc as" "newcc" "''cc'"
230$ if .not.f$int($status) then exit '$status
231$ cc=f$trnlnm("newcc")
232$ deassign newcc
233$!
234$ say "%PGPINSTAL-I-CCDEF, 'CC' is defined as ''cc'"
235$re_ask1:
236$ if jump.and.immediate then goto perform_installation
237$ ask "Is this acceptable (Y/N)" "answer" "Y"
238$ if .not.f$int($status) then exit '$status
239$ answer = f$edit(f$trnlnm("answer"),"upcase,collapse")
240$ deassign answer
241$ if answer.eqs."Y" then goto perform_installation
242$ if answer.nes."N" then goto re_ask1
243$re_ask2:
244$ ask "Do you want to terminate installation (Y/N)" "answer" "Y"
245$ if .not.f$int($status) then exit '$status
246$ answer = f$edit(f$trnlnm("answer"),"upcase,collapse")
247$ deassign answer
248$ if answer.eqs."Y" then goto terminate_installation
249$ if answer.nes."N" then goto re_ask2
250$ say "%PGPINSTAL-I-RESTART, Installation process is restarting"
251$ read/end=halt/prompt="Press return..." sys$command junk
252$ immediate=0  !Disable for restart - just in case we ever get here
253$ goto restart_install
254$!
255$terminate_installation:
256$ say "%PGPINSTAL-F-TERMINATED, Installation terminated"
257$ set def 'start_dir'
258$ exit 44+%x10000000
259$!
260$perform_installation:
261$ this_file = f$environment("procedure") - "]["
262$ this_dir = f$element(0,"]",this_file)+"]"
263$ set def 'this_dir'
264$ src = "''this_dir'"
265$ rsa = "''this_dir'"
266$ obj = "sys$disk:[]"
267$!
268$start_build:
269$!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
270$!@rsabuild
271$!rsabuild:
272$!!src="[-.rsaref.source]"
273$!!obj="sys$disk:[]"
274$ sp_cflgs = ""
275$ if vax.and.decc then sp_cflgs = "/PREFIX=EXCEPT=(optind,optarg,optopt,opterr)"
276$ dbg="/NODEB/OPT=NOINLINE"
277$ dbg2=dbg
278$ if vax.and.decc then dbg2="/NODEB/NOOPT" !Kill VAX/DECC compiler bug
279$!!old_cflags = "/DEFINE=(''cdefs'""hw_model=''f$getsyi(""hw_model"")'"")''dbg'"
280$ cflags = "''dbg'''sp_cflgs'"
281$ cflags2 = "''dbg2'''sp_cflgs'"
282$ if "''cdefs'".nes."" then cflags = "/DEFINE=(''cdefs')''cflags'"
283$ if "''cdefs'".nes."" then cflags2 = "/DEFINE=(''cdefs')''cflags2'"
284$ if jump then goto rsacomp
285$! set verify
286$! library /create rsareflib
287$!x='f$ver(0)'
288$rsacomp:
289$ if jump then if f$ele(0,"_",jumpto).nes."RSA" then goto pgpbuild
290$ if jump then goto 'jumpto'
291$!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
292$!@pgpbuild
293$pgpbuild:
294$!cflags = "/DEFINE=(''cdefs'""hw_model=''f$getsyi(""hw_model"")'"")''dbg'"
295$ cflags = "''dbg'''sp_cflgs'"
296$ cflags2 = "''dbg2'''sp_cflgs'"
297$ if "''cdefs'".nes."" then cflags = "/DEFINE=(''cdefs')''cflags'"
298$ if "''cdefs'".nes."" then cflags2 = "/DEFINE=(''cdefs')''cflags2'"
299$!
300$! Now compile stuff
301$!
302$ if jump then if f$ele(0,"_",jumpto).nes."PGP" then goto pgplink
303$ if jump then goto 'jumpto'
304$ call pgp_compile pgp
305$ if .not.f$int($status) then exit '$status
306$ call pgp_compile config
307$ if .not.f$int($status) then exit '$status
308$ call pgp_compile crypto
309$ if .not.f$int($status) then exit '$status
310$ call pgp_compile keymgmt
311$ if .not.f$int($status) then exit '$status
312$ call pgp_compile keyadd
313$ if .not.f$int($status) then exit '$status
314$ call pgp_compile keymaint
315$ if .not.f$int($status) then exit '$status
316$ call pgp_compile fileio
317$ if .not.f$int($status) then exit '$status
318$ call pgp_compile mdfile
319$ if .not.f$int($status) then exit '$status
320$ call pgp_compile more
321$ if .not.f$int($status) then exit '$status
322$ call pgp_compile armor
323$ if .not.f$int($status) then exit '$status
324$ call pgp_compile mpilib
325$ if .not.f$int($status) then exit '$status
326$ call pgp_compile mpiio
327$ if .not.f$int($status) then exit '$status
328$ call pgp_compile getopt
329$ if .not.f$int($status) then exit '$status
330$ call pgp_compile genprime
331$ if .not.f$int($status) then exit '$status
332$ call pgp_compile rsagen
333$ if .not.f$int($status) then exit '$status
334$ call pgp_compile random
335$ if .not.f$int($status) then exit '$status
336$ call pgp_compile idea
337$ if .not.f$int($status) then exit '$status
338$ call pgp_compile passwd
339$ if .not.f$int($status) then exit '$status
340$ call pgp_compile md5 "''cflags2'"	!OVERRIDE /OPT STUFF FOR VAX/DECC!
341$ if .not.f$int($status) then exit '$status
342$ call pgp_compile system
343$ if .not.f$int($status) then exit '$status
344$ call pgp_compile language
345$ if .not.f$int($status) then exit '$status
346$ if vax
347$ then
348$   set ver
349$   macro'macopts'/object='obj'vax.obj 'src'vax.mar
350$!  x='f$ver(0)'
351$ endif
352$ if .not.f$int($status) then exit '$status
353$ call pgp_compile charset
354$ if .not.f$int($status) then exit '$status
355$ call pgp_compile rsaglue1
356$ if .not.f$int($status) then exit '$status
357$ call pgp_compile noise
358$ if .not.f$int($status) then exit '$status
359$ call pgp_compile randpool
360$ if .not.f$int($status) then exit '$status
361$!Alter cc flags for z stuff
362$ cflags = "/DEFINE=(''cdefs'EXPORT,NO_ASM,NOSTORE)''dbg'"
363$ call pgp_compile zbits
364$ if .not.f$int($status) then exit '$status
365$ call pgp_compile zdeflate
366$ if .not.f$int($status) then exit '$status
367$ call pgp_compile zglobals
368$ if .not.f$int($status) then exit '$status
369$ call pgp_compile zinflate
370$ if .not.f$int($status) then exit '$status
371$ call pgp_compile zip
372$ if .not.f$int($status) then exit '$status
373$ call pgp_compile zipup
374$ if .not.f$int($status) then exit '$status
375$ call pgp_compile zfile_io
376$ if .not.f$int($status) then exit '$status
377$ call pgp_compile ztrees
378$ if .not.f$int($status) then exit '$status
379$ call pgp_compile zunzip
380$ if .not.f$int($status) then exit '$status
381$ jump=0
382$ goto pgplink
383$!Last Modified:  95.03.13 21.07.29.73
384$ pgp_compile: subroutine	!p1 is file name
385$ on control_c then goto bomb
386$ on control_y then goto bomb
387$ sfile = f$parse("''p1'","''src'","sys$disk:[].c")
388$ ofile = f$parse("''obj'","''p1'","sys$disk:[].obj;")
389$ define/user c$include 'src','rsa'
390$ define/user vaxc$include sys$share:,'src','rsa'
391$ define/user sys sys$share:
392$ define/user decc$system_include sys$share:,'src','rsa'
393$ __cflags = "''cflags'"
394$ if "''p2'".nes."" then __cflags="''p2'"
395$ set verify
396$ 'cc' '__cflags' 'sfile'/object='ofile'
397$!x='f$ver(0)'
398$ exit 1
399$bomb:
400$!x='f$ver(0)'
401$ say "%PGPINSTAL-F-INSABORT, Installation has been aborted"
402$ exit 2160+%x10000000
403$ endsubroutine
404$!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
405$!@pgplink
406$pgplink:
407$ if jump then if f$ele(0,"_",jumpto).nes."LNK" then goto badjump
408$ if jump then goto 'jumpto'
409$lnk_start: !jumpto entrypoint '$LNK_START'
410$ open/write optfile pgp'pgpver'.opt
411$ write optfile "NAME=PGP''pgpver'"
412$ write optfile "IDENT=""PGP V''pgpver_human'"""
413$ if vax then -
414  write optfile "vax"
415$ copy sys$input optfile
416!
417more
418fileio
419md5
420mdfile
421getopt
422system
423mpilib
424mpiio
425random
426crypto
427rsagen
428noise
429randpool
430!
431idea
432passwd
433genprime
434pgp
435config
436language
437charset
438armor
439!
440! RSA Stuff
441!
442rsaglue1
443!
444! Key Stuff
445!
446keymgmt
447keymaint
448keyadd
449!
450! ZIP Stuff
451!
452zbits
453zdeflate
454zglobals
455zinflate
456zip
457zipup
458zfile_io
459ztrees
460zunzip
461!
462!rsareflib/library
463$ eod
464$ if vaxc then write optfile "sys$share:vaxcrtl/share"
465$ close optfile
466$lnk_link: !jumpto entrypoint '$LNK_LINK'
467$ say "LINK /exe=PGP.EXE pgp''pgpver'.opt/opt''lnkopts'"
468$ LINK /exe=PGP.EXE pgp'pgpver'.opt/opt'lnkopts'
469$ say ""
470$ pgpexe = f$search("pgp.exe")
471$ if pgpexe.eqs.""
472$ then
473$   say "It appears that PGP.EXE was not built successfully"
474$   say ""
475$   say "Sorry."
476$ else
477$   say "PGP.EXE appears to have built successfully"
478$   say ""
479$   say "The executable is ''pgpexe'"
480$   say ""
481$   say "Set default to the pgp build directory and read the documents"
482$   say "in the [.DOC] subdirectory regarding setting up PGP and creating"
483$ exit
484