3 $! Written By: Robert Byer
5 $! A-Com Computing, Inc.
6 $! byer@mail.all-net.net
8 $! Changes by Richard Levitte <richard@levitte.org>
10 $! This command files compiles and creates all the various different
11 $! "test" programs for the different types of encryption for OpenSSL.
12 $! It was written so it would try to determine what "C" compiler to
13 $! use or you can specify which "C" compiler to use.
15 $! The test "executables" will be placed in a directory called
16 $! [.xxx.EXE.TEST] where "xxx" denotes ALPHA, IA64, or VAX, depending
17 $! on your machine architecture.
19 $! Specify DEBUG or NODEBUG P1 to compile with or without debugger
22 $! Specify which compiler at P2 to try to compile under.
28 $! If you don't speficy a compiler, it will try to determine which
29 $! "C" compiler to use.
31 $! P3, if defined, sets a TCP/IP library to use, through one of the following
35 $! SOCKETSHR for SOCKETSHR+NETLIB
37 $! P4, if defined, sets a compiler thread NOT needed on OpenVMS 7.1 (and up)
40 $! Define A TCP/IP Library That We Will Need To Link To.
41 $! (That is, If Wee Need To Link To One.)
45 $! Check What Architecture We Are Using.
47 $ IF (F$GETSYI("CPU").LT.128)
50 $! The Architecture Is VAX.
58 $! The Architecture Is Alpha, IA64 or whatever comes in the future.
60 $ ARCH = F$EDIT( F$GETSYI( "ARCH_NAME"), "UPCASE")
61 $ IF (ARCH .EQS. "") THEN ARCH = "UNK"
63 $! End The Architecture Check.
67 $! Define The OBJ Directory.
69 $ OBJ_DIR := SYS$DISK:[-.'ARCH'.OBJ.TEST]
71 $! Define The EXE Directory.
73 $ EXE_DIR := SYS$DISK:[-.'ARCH'.EXE.TEST]
75 $! Check To Make Sure We Have Valid Command Line Parameters.
79 $! Initialise logical names and such
83 $! Tell The User What Kind of Machine We Run On.
85 $ WRITE SYS$OUTPUT "Compiling On A ",ARCH," Machine."
87 $! Define The CRYPTO-LIB We Are To Use.
89 $ CRYPTO_LIB := SYS$DISK:[-.'ARCH'.EXE.CRYPTO]LIBCRYPTO.OLB
91 $! Define The SSL We Are To Use.
93 $ SSL_LIB := SYS$DISK:[-.'ARCH'.EXE.SSL]LIBSSL.OLB
95 $! Check To See If The Architecture Specific OBJ Directory Exists.
97 $ IF (F$PARSE(OBJ_DIR).EQS."")
100 $! The EXE Directory Dosen't Exist, So Create It.
102 $ CREATE/DIRECTORY 'OBJ_DIR'
104 $! End The Architecture Specific OBJ Directory Check.
108 $! Check To See If The Architecture Specific EXE Directory Exists.
110 $ IF (F$PARSE(EXE_DIR).EQS."")
113 $! The EXE Directory Dosen't Exist, So Create It.
115 $ CREATE/DIRECTORY 'EXE_DIR'
117 $! End The Architecture Specific EXE Directory Check.
121 $! Check To See If We Have The Proper Libraries.
125 $! Check To See If We Have A Linker Option File.
127 $ GOSUB CHECK_OPT_FILE
129 $! Define The TEST Files.
130 $! NOTE: Some might think this list ugly. However, it's made this way to
131 $! reflect the EXE variable in Makefile as closely as possible,
132 $! thereby making it fairly easy to verify that the lists are the same.
134 $ TEST_FILES = "BNTEST,ECTEST,ECDSATEST,ECDHTEST,IDEATEST,"+ -
135 "MD2TEST,MD4TEST,MD5TEST,HMACTEST,WP_TEST,"+ -
136 "RC2TEST,RC4TEST,RC5TEST,"+ -
137 "DESTEST,SHATEST,SHA1TEST,SHA256T,SHA512T,"+ -
138 "MDC2TEST,RMDTEST,"+ -
139 "RANDTEST,DHTEST,ENGINETEST,"+ -
140 "BFTEST,CASTTEST,SSLTEST,EXPTEST,DSATEST,RSA_TEST,"+ -
142 $ TCPIP_PROGRAMS = ",,"
143 $ IF COMPILER .EQS. "VAXC" THEN -
144 TCPIP_PROGRAMS = ",SSLTEST,"
146 $! Define A File Counter And Set It To "0".
150 $! Top Of The File Loop.
154 $! O.K, Extract The File Name From The File List.
156 $ FILE_NAME = F$ELEMENT(FILE_COUNTER,",",TEST_FILES)
158 $! Check To See If We Are At The End Of The File List.
160 $ IF (FILE_NAME.EQS.",") THEN GOTO FILE_DONE
162 $! Increment The Counter.
164 $ FILE_COUNTER = FILE_COUNTER + 1
166 $! Create The Source File Name.
168 $ SOURCE_FILE = "SYS$DISK:[]" + FILE_NAME + ".C"
170 $! Create The Object File Name.
172 $ OBJECT_FILE = OBJ_DIR + FILE_NAME + ".OBJ"
174 $! Create The Executable File Name.
176 $ EXE_FILE = EXE_DIR + FILE_NAME + ".EXE"
177 $ ON WARNING THEN GOTO NEXT_FILE
179 $! Check To See If The File We Want To Compile Actually Exists.
181 $ IF (F$SEARCH(SOURCE_FILE).EQS."")
184 $! Tell The User That The File Dosen't Exist.
186 $ WRITE SYS$OUTPUT ""
187 $ WRITE SYS$OUTPUT "The File ",SOURCE_FILE," Dosen't Exist."
188 $ WRITE SYS$OUTPUT ""
195 $! Tell The User What We Are Building.
197 $ WRITE SYS$OUTPUT "Building The ",FILE_NAME," Test Program."
201 $ ON ERROR THEN GOTO NEXT_FILE
202 $ CC/OBJECT='OBJECT_FILE' 'SOURCE_FILE'
203 $ ON WARNING THEN GOTO NEXT_FILE
205 $! Check If What We Are About To Compile Works Without A TCP/IP Library.
207 $ IF ((TCPIP_LIB.EQS."").AND.((TCPIP_PROGRAMS-FILE_NAME).NES.TCPIP_PROGRAMS))
210 $! Inform The User That A TCP/IP Library Is Needed To Compile This Program.
212 $ WRITE SYS$OUTPUT FILE_NAME," Needs A TCP/IP Library. Can't Link. Skipping..."
215 $! End The TCP/IP Library Check.
219 $! Link The Program, Check To See If We Need To Link With RSAREF Or Not.
220 $! Check To See If We Are To Link With A Specific TCP/IP Library.
222 $ IF (TCPIP_LIB.NES."")
225 $! Don't Link With The RSAREF Routines And TCP/IP Library.
227 $ LINK/'DEBUGGER'/'TRACEBACK' /EXE='EXE_FILE' -
229 'SSL_LIB'/LIBRARY,'CRYPTO_LIB'/LIBRARY, -
230 'TCPIP_LIB','OPT_FILE'/OPTION
236 $! Don't Link With The RSAREF Routines And Link With A TCP/IP Library.
238 $ LINK/'DEBUGGER'/'TRACEBACK' /EXE='EXE_FILE' -
240 'SSL_LIB'/LIBRARY,'CRYPTO_LIB'/LIBRARY, -
243 $! End The TCP/IP Library Check.
247 $! Go Back And Do It Again.
251 $! All Done With This Library Part.
255 $! All Done, Time To Exit.
261 $! Check For The Link Option FIle.
265 $! Check To See If We Need To Make A VAX C Option File.
267 $ IF (COMPILER.EQS."VAXC")
270 $! Check To See If We Already Have A VAX C Linker Option File.
272 $ IF (F$SEARCH(OPT_FILE).EQS."")
275 $! We Need A VAX C Linker Option File.
280 ! Default System Options File To Link Agianst
281 ! The Sharable VAX C Runtime Library.
283 SYS$SHARE:VAXCRTL.EXE/SHARE
286 $! End The Option File Check.
290 $! End The VAXC Check.
294 $! Check To See If We Need A GNU C Option File.
296 $ IF (COMPILER.EQS."GNUC")
299 $! Check To See If We Already Have A GNU C Linker Option File.
301 $ IF (F$SEARCH(OPT_FILE).EQS."")
304 $! We Need A GNU C Linker Option File.
309 ! Default System Options File To Link Agianst
310 ! The Sharable C Runtime Library.
312 GNU_CC:[000000]GCCLIB/LIBRARY
313 SYS$SHARE:VAXCRTL/SHARE
316 $! End The Option File Check.
320 $! End The GNU C Check.
324 $! Check To See If We Need A DEC C Option File.
326 $ IF (COMPILER.EQS."DECC")
329 $! Check To See If We Already Have A DEC C Linker Option File.
331 $ IF (F$SEARCH(OPT_FILE).EQS."")
334 $! Figure Out If We Need A non-VAX Or A VAX Linker Option File.
336 $ IF (ARCH.EQS."VAX")
339 $! We Need A DEC C Linker Option File For VAX.
344 ! Default System Options File To Link Agianst
345 ! The Sharable DEC C Runtime Library.
347 SYS$SHARE:DECC$SHR.EXE/SHARE
354 $! Create The non-VAX Linker Option File.
359 ! Default System Options File For non-VAX To Link Agianst
360 ! The Sharable C Runtime Library.
362 SYS$SHARE:CMA$OPEN_LIB_SHR/SHARE
363 SYS$SHARE:CMA$OPEN_RTL/SHARE
366 $! End The DEC C Option File Check.
370 $! End The Option File Search.
374 $! End The DEC C Check.
378 $! Tell The User What Linker Option File We Are Using.
380 $ WRITE SYS$OUTPUT "Using Linker Option File ",OPT_FILE,"."
386 $! Check To See If We Have The Appropiate Libraries.
390 $! Look For The Library LIBCRYPTO.OLB.
392 $ IF (F$SEARCH(CRYPTO_LIB).EQS."")
395 $! Tell The User We Can't Find The LIBCRYPTO.OLB Library.
397 $ WRITE SYS$OUTPUT ""
398 $ WRITE SYS$OUTPUT "Can't Find The Library ",CRYPTO_LIB,"."
399 $ WRITE SYS$OUTPUT "We Can't Link Without It."
400 $ WRITE SYS$OUTPUT ""
402 $! Since We Can't Link Without It, Exit.
406 $! End The Crypto Library Check.
410 $! Look For The Library LIBSSL.OLB.
412 $ IF (F$SEARCH(SSL_LIB).EQS."")
415 $! Tell The User We Can't Find The LIBSSL.OLB Library.
417 $ WRITE SYS$OUTPUT ""
418 $ WRITE SYS$OUTPUT "Can't Find The Library ",SSL_LIB,"."
419 $ WRITE SYS$OUTPUT "Some Of The Test Programs Need To Link To It."
420 $ WRITE SYS$OUTPUT ""
422 $! Since We Can't Link Without It, Exit.
426 $! End The SSL Library Check.
434 $! Check The User's Options.
438 $! Check To See If P1 Is Blank.
440 $ IF (P1.EQS."NODEBUG")
443 $! P1 Is NODEBUG, So Compile Without Debugger Information.
445 $ DEBUGGER = "NODEBUG"
446 $ TRACEBACK = "NOTRACEBACK"
447 $ GCC_OPTIMIZE = "OPTIMIZE"
448 $ CC_OPTIMIZE = "OPTIMIZE"
449 $ WRITE SYS$OUTPUT "No Debugger Information Will Be Produced During Compile."
450 $ WRITE SYS$OUTPUT "Compiling With Compiler Optimization."
456 $! Check To See If We Are To Compile With Debugger Information.
458 $ IF (P1.EQS."DEBUG")
461 $! Compile With Debugger Information.
464 $ TRACEBACK = "TRACEBACK"
465 $ GCC_OPTIMIZE = "NOOPTIMIZE"
466 $ CC_OPTIMIZE = "NOOPTIMIZE"
467 $ WRITE SYS$OUTPUT "Debugger Information Will Be Produced During Compile."
468 $ WRITE SYS$OUTPUT "Compiling Without Compiler Optimization."
474 $! Tell The User Entered An Invalid Option..
476 $ WRITE SYS$OUTPUT ""
477 $ WRITE SYS$OUTPUT "The Option ",P1," Is Invalid. The Valid Options Are:"
478 $ WRITE SYS$OUTPUT ""
479 $ WRITE SYS$OUTPUT " DEBUG : Compile With The Debugger Information."
480 $ WRITE SYS$OUTPUT " NODEBUG : Compile Without The Debugger Information."
481 $ WRITE SYS$OUTPUT ""
487 $! End The Valid Arguement Check.
495 $! Check To See If P2 Is Blank.
500 $! O.K., The User Didn't Specify A Compiler, Let's Try To
501 $! Find Out Which One To Use.
503 $! Check To See If We Have GNU C.
505 $ IF (F$TRNLNM("GNU_CC").NES."")
508 $! Looks Like GNUC, Set To Use GNUC.
512 $! End The GNU C Compiler Check.
516 $! Check To See If We Have VAXC Or DECC.
518 $ IF (ARCH.NES."VAX").OR.(F$TRNLNM("DECC$CC_DEFAULT").NES."")
521 $! Looks Like DECC, Set To Use DECC.
529 $! Looks Like VAXC, Set To Use VAXC.
533 $! End The VAXC Compiler Check.
537 $! End The DECC & VAXC Compiler Check.
541 $! End The Compiler Check.
545 $! Check To See If We Have A Option For P3.
550 $! Find out what socket library we have available
552 $ IF F$PARSE("SOCKETSHR:") .NES. ""
555 $! We have SOCKETSHR, and it is my opinion that it's the best to use.
561 $ WRITE SYS$OUTPUT "Using SOCKETSHR for TCP/IP"
563 $! Else, let's look for something else
567 $! Like UCX (the reason to do this before Multinet is that the UCX
568 $! emulation is easier to use...)
570 $ IF F$TRNLNM("UCX$IPC_SHR") .NES. "" -
571 .OR. F$PARSE("SYS$SHARE:UCX$IPC_SHR.EXE") .NES. "" -
572 .OR. F$PARSE("SYS$LIBRARY:UCX$IPC.OLB") .NES. ""
575 $! Last resort: a UCX or UCX-compatible library
581 $ WRITE SYS$OUTPUT "Using UCX or an emulation thereof for TCP/IP"
589 $! Set Up Initial CC Definitions, Possibly With User Ones
591 $ CCDEFS = "TCPIP_TYPE_''P3'"
592 $ IF F$TYPE(USER_CCDEFS) .NES. "" THEN CCDEFS = CCDEFS + "," + USER_CCDEFS
594 $ IF F$TYPE(USER_CCFLAGS) .NES. "" THEN CCEXTRAFLAGS = USER_CCFLAGS
595 $ CCDISABLEWARNINGS = "LONGLONGTYPE,LONGLONGSUFX,FOUNDCR"
596 $ IF F$TYPE(USER_CCDISABLEWARNINGS) .NES. "" THEN -
597 CCDISABLEWARNINGS = CCDISABLEWARNINGS + "," + USER_CCDISABLEWARNINGS
599 $! Check To See If The User Entered A Valid Paramter.
601 $ IF (P2.EQS."VAXC").OR.(P2.EQS."DECC").OR.(P2.EQS."GNUC")
604 $! Check To See If The User Wanted DECC.
609 $! Looks Like DECC, Set To Use DECC.
613 $! Tell The User We Are Using DECC.
615 $ WRITE SYS$OUTPUT "Using DECC 'C' Compiler."
620 $ IF ARCH.EQS."VAX" .AND. F$TRNLNM("DECC$CC_DEFAULT").NES."/DECC" -
622 $ CC = CC + "/''CC_OPTIMIZE'/''DEBUGGER'/STANDARD=ANSI89" + -
623 "/NOLIST/PREFIX=ALL" + -
624 "/INCLUDE=(SYS$DISK:[-],SYS$DISK:[-.CRYPTO])" + CCEXTRAFLAGS
626 $! Define The Linker Options File Name.
628 $ OPT_FILE = "''EXE_DIR'VAX_DECC_OPTIONS.OPT"
634 $! Check To See If We Are To Use VAXC.
639 $! Looks Like VAXC, Set To Use VAXC.
643 $! Tell The User We Are Using VAX C.
645 $ WRITE SYS$OUTPUT "Using VAXC 'C' Compiler."
647 $! Compile Using VAXC.
652 $ WRITE SYS$OUTPUT "There is no VAX C on ''ARCH'!"
655 $ IF F$TRNLNM("DECC$CC_DEFAULT").EQS."/DECC" THEN CC = "CC/VAXC"
656 $ CC = CC + "/''CC_OPTIMIZE'/''DEBUGGER'/NOLIST" + -
657 "/INCLUDE=(SYS$DISK:[-],SYS$DISK:[-.CRYPTO])" + CCEXTRAFLAGS
658 $ CCDEFS = CCDEFS + ",""VAXC"""
660 $! Define <sys> As SYS$COMMON:[SYSLIB]
662 $ DEFINE/NOLOG SYS SYS$COMMON:[SYSLIB]
664 $! Define The Linker Options File Name.
666 $ OPT_FILE = "''EXE_DIR'VAX_VAXC_OPTIONS.OPT"
672 $! Check To See If We Are To Use GNU C.
677 $! Looks Like GNUC, Set To Use GNUC.
681 $! Tell The User We Are Using GNUC.
683 $ WRITE SYS$OUTPUT "Using GNU 'C' Compiler."
687 $ CC = "GCC/NOCASE_HACK/''GCC_OPTIMIZE'/''DEBUGGER'/NOLIST" + -
688 "/INCLUDE=(SYS$DISK:[-],SYS$DISK:[-.CRYPTO])" + CCEXTRAFLAGS
690 $! Define The Linker Options File Name.
692 $ OPT_FILE = "''EXE_DIR'VAX_GNUC_OPTIONS.OPT"
694 $! End The GNU C Check.
698 $! Set up default defines
700 $ CCDEFS = """FLAT_INC=1""," + CCDEFS
702 $! Finish up the definition of CC.
704 $ IF COMPILER .EQS. "DECC"
706 $ IF CCDISABLEWARNINGS .EQS. ""
708 $ CC4DISABLEWARNINGS = "DOLLARID"
710 $ CC4DISABLEWARNINGS = CCDISABLEWARNINGS + ",DOLLARID"
711 $ CCDISABLEWARNINGS = "/WARNING=(DISABLE=(" + CCDISABLEWARNINGS + "))"
713 $ CC4DISABLEWARNINGS = "/WARNING=(DISABLE=(" + CC4DISABLEWARNINGS + "))"
715 $ CCDISABLEWARNINGS = ""
716 $ CC4DISABLEWARNINGS = ""
718 $ CC = CC + "/DEFINE=(" + CCDEFS + ")" + CCDISABLEWARNINGS
720 $! Show user the result
722 $ WRITE/SYMBOL SYS$OUTPUT "Main Compiling Command: ",CC
724 $! Else The User Entered An Invalid Arguement.
728 $! Tell The User We Don't Know What They Want.
730 $ WRITE SYS$OUTPUT ""
731 $ WRITE SYS$OUTPUT "The Option ",P2," Is Invalid. The Valid Options Are:"
732 $ WRITE SYS$OUTPUT ""
733 $ WRITE SYS$OUTPUT " VAXC : To Compile With VAX C."
734 $ WRITE SYS$OUTPUT " DECC : To Compile With DEC C."
735 $ WRITE SYS$OUTPUT " GNUC : To Compile With GNU C."
736 $ WRITE SYS$OUTPUT ""
743 $! Time to check the contents, and to make sure we get the correct library.
745 $ IF P3.EQS."SOCKETSHR" .OR. P3.EQS."MULTINET" .OR. P3.EQS."UCX" -
746 .OR. P3.EQS."TCPIP" .OR. P3.EQS."NONE"
749 $! Check to see if SOCKETSHR was chosen
751 $ IF P3.EQS."SOCKETSHR"
754 $! Set the library to use SOCKETSHR
756 $ TCPIP_LIB = "SYS$DISK:[-.VMS]SOCKETSHR_SHR.OPT/OPT"
758 $! Done with SOCKETSHR
762 $! Check to see if MULTINET was chosen
764 $ IF P3.EQS."MULTINET"
767 $! Set the library to use UXC emulation.
771 $! Done with MULTINET
775 $! Check to see if UCX was chosen
780 $! Set the library to use UCX.
782 $ TCPIP_LIB = "SYS$DISK:[-.VMS]UCX_SHR_DECC.OPT/OPT"
783 $ IF F$TRNLNM("UCX$IPC_SHR") .NES. ""
785 $ TCPIP_LIB = "SYS$DISK:[-.VMS]UCX_SHR_DECC_LOG.OPT/OPT"
787 $ IF COMPILER .NES. "DECC" .AND. ARCH .EQS. "VAX" THEN -
788 TCPIP_LIB = "SYS$DISK:[-.VMS]UCX_SHR_VAXC.OPT/OPT"
795 $! Check to see if TCPIP was chosen
800 $! Set the library to use TCPIP (post UCX).
802 $ TCPIP_LIB = "SYS$DISK:[-.VMS]TCPIP_SHR_DECC.OPT/OPT"
808 $! Check to see if NONE was chosen
813 $! Do not use a TCPIP library.
823 $ WRITE SYS$OUTPUT "TCP/IP library spec: ", TCPIP_LIB
825 $! Else The User Entered An Invalid Arguement.
829 $! Tell The User We Don't Know What They Want.
831 $ WRITE SYS$OUTPUT ""
832 $ WRITE SYS$OUTPUT "The Option ",P3," Is Invalid. The Valid Options Are:"
833 $ WRITE SYS$OUTPUT ""
834 $ WRITE SYS$OUTPUT " SOCKETSHR : To link with SOCKETSHR TCP/IP library."
835 $ WRITE SYS$OUTPUT " UCX : To link with UCX TCP/IP library."
836 $ WRITE SYS$OUTPUT " TCPIP : To link with TCPIP (post UCX) TCP/IP library."
837 $ WRITE SYS$OUTPUT ""
843 $! Done with TCP/IP libraries
847 $! Special Threads For OpenVMS v7.1 Or Later
849 $! Written By: Richard Levitte
850 $! richard@levitte.org
853 $! Check To See If We Have A Option For P4.
858 $! Get The Version Of VMS We Are Using.
861 $ TMP = F$ELEMENT(0,"-",F$EXTRACT(1,4,F$GETSYI("VERSION")))
862 $ TMP = F$INTEGER(F$ELEMENT(0,".",TMP)+F$ELEMENT(1,".",TMP))
864 $! Check To See If The VMS Version Is v7.1 Or Later.
869 $! We Have OpenVMS v7.1 Or Later, So Use The Special Threads.
871 $ ISSEVEN := ,PTHREAD_USE_D4
873 $! End The VMS Version Check.
887 $! Save old value of the logical name OPENSSL
889 $ __SAVE_OPENSSL = F$TRNLNM("OPENSSL","LNM$PROCESS_TABLE")
891 $! Save directory information
893 $ __HERE = F$PARSE(F$PARSE("A.;",F$ENVIRONMENT("PROCEDURE"))-"A.;","[]A.;") - "A.;"
894 $ __HERE = F$EDIT(__HERE,"UPCASE")
895 $ __TOP = __HERE - "TEST]"
896 $ __INCLUDE = __TOP + "INCLUDE.OPENSSL]"
898 $! Set up the logical name OPENSSL to point at the include directory
900 $ DEFINE OPENSSL/NOLOG '__INCLUDE'
908 $! Restore the logical name OPENSSL if it had a value
910 $ IF __SAVE_OPENSSL .EQS. ""
914 $ DEFINE/NOLOG OPENSSL '__SAVE_OPENSSL'