home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / crypl200.zip / MAKEFILE < prev    next >
Text File  |  1996-10-13  |  13KB  |  445 lines

  1. #****************************************************************************
  2. #*                                                                            *
  3. #*                        Makefile for the encryption library                    *
  4. #*                                                                            *
  5. #****************************************************************************
  6.  
  7. # Naming information: Major and minor version numbers, project and library
  8. # names, and default target (this is changed depending on whether we're
  9. # building the static or shared library).
  10.  
  11. MAJ        = 1
  12. MIN        = 20
  13. PROJ    = crypt
  14. LIBNAME    = lib$(PROJ).a
  15. SLIBNAME = lib$(PROJ).so
  16. TARGET    = $(LIBNAME)
  17.  
  18. # Compiler and linker options
  19.  
  20. CFLAGS    = -c -D__UNIX__ -O2 -I. $(ENDIAN) $(CMDC)
  21. SCFLAGS = -fpic -c -D__UNIX__ -O2 -I. $(ENDIAN) $(CMDC)
  22. LFLAGS    = $(CMDL)
  23.  
  24. # Paths and command names
  25.  
  26. OUTPATH    =                    # Where object files go (/tmp is a good place)
  27. LD        = $(CC)                # Linker
  28.  
  29. # The object files which make up the library
  30.  
  31. OBJS    = $(OUTPATH)crypt.o $(OUTPATH)cryptapi.o $(OUTPATH)cryptcap.o \
  32.           $(OUTPATH)cryptdbx.o $(OUTPATH)cryptobj.o $(OUTPATH)lib_3des.o \
  33.           $(OUTPATH)lib_blow.o $(OUTPATH)lib_cert.o $(OUTPATH)lib_des.o \
  34.           $(OUTPATH)lib_dh.o $(OUTPATH)lib_dsa.o $(OUTPATH)lib_idea.o \
  35.           $(OUTPATH)lib_md2.o $(OUTPATH)lib_md4.o $(OUTPATH)lib_md5.o \
  36.           $(OUTPATH)lib_mdc.o $(OUTPATH)lib_null.o $(OUTPATH)lib_pkcs.o \
  37.           $(OUTPATH)lib_rc2.o $(OUTPATH)lib_rc4.o $(OUTPATH)lib_rc5.o \
  38.           $(OUTPATH)lib_rand.o $(OUTPATH)lib_ripe.o $(OUTPATH)lib_rsa.o \
  39.           $(OUTPATH)lib_safr.o $(OUTPATH)lib_sha.o $(OUTPATH)asn1.o \
  40.           $(OUTPATH)asn1keys.o $(OUTPATH)asn1objs.o $(OUTPATH)pgp_idea.o \
  41.           $(OUTPATH)pgp_key.o $(OUTPATH)x509_key.o $(OUTPATH)bn.o \
  42.           $(OUTPATH)bn00.o $(OUTPATH)lbn00.o $(OUTPATH)lbnmem.o \
  43.           $(OUTPATH)legal.o $(OUTPATH)blowfish.o $(OUTPATH)idea.o \
  44.           $(OUTPATH)ecb3_enc.o $(OUTPATH)ecb_enc.o $(OUTPATH)set_key.o \
  45.           $(OUTPATH)md2.o $(OUTPATH)md4.o $(OUTPATH)md5.o \
  46.           $(OUTPATH)ripemd.o $(OUTPATH)rc2.o $(OUTPATH)rc4.o \
  47.           $(OUTPATH)rc5.o $(OUTPATH)safer.o $(OUTPATH)sha.o \
  48.           $(OUTPATH)sha1.o $(OUTPATH)stream.o
  49.  
  50. # The key management functions all make use of the ASN.1 library, so we
  51. # define the dependancies once here
  52.  
  53. ASN1_DEP = capi.h crypt.h keymgmt/asn1.h keymgmt/asn1keys.h \
  54.            keymgmt/asn1objs.h keymgmt/asn1oid.h keymgmt/ber.h keymgmt/stream.h
  55.  
  56. #****************************************************************************
  57. #*                                                                            *
  58. #*                            Default and High-level Targets                    *
  59. #*                                                                            *
  60. #****************************************************************************
  61.  
  62. # Build the endianness-test program, find the system type and use a
  63. # conditional make depending on that and the endianness (who needs autoconf
  64. # in order to be ugly).
  65.  
  66. default:
  67.         @make endian > /dev/null
  68.         @make ENDIAN=`./endian` `uname`
  69.  
  70. endian:                    endian.c
  71.                         @$(CC) endian.c -o endian
  72.  
  73. # Build the shared library
  74.  
  75. shared:
  76.         @make TARGET=$(SLIBNAME) CFLAGS="$(SCFLAGS)"
  77.  
  78. # Frohe Ostern.
  79.  
  80. babies:
  81.         @echo "Good grief, what do you think I am?  The Unix environment is capable, but"
  82.         @echo "not that capable."
  83.  
  84. cookies:
  85.         @echo "Mix 250g flour, 150g sugar, 125g butter, an egg, a few drops of vanilla"
  86.         @echo "essence, and 1 tsp baking powder into a dough, cut cookies from rolls of"
  87.         @echo "dough, bake for about 15 minutes at 180C until they turn very light brown"
  88.         @echo "at the edges."
  89.  
  90. love:
  91.         @echo "Nicht wahr?"
  92.         @echo
  93.  
  94. #****************************************************************************
  95. #*                                                                            *
  96. #*                    Rules to build the encryption library                    *
  97. #*                                                                            *
  98. #****************************************************************************
  99.  
  100. # Main directory
  101.  
  102. $(OUTPATH)crypt.o:        capi.h crypt.h crypt.c
  103.                         $(CC) $(CFLAGS) crypt.c
  104.  
  105. $(OUTPATH)cryptapi.o:    capi.h crypt.h hash/md2.h hash/md4.h hash/md5.h \
  106.                         hash/sha.h cryptapi.c
  107.                         $(CC) $(CFLAGS) cryptapi.c
  108.  
  109. $(OUTPATH)cryptcap.o:    capi.h crypt.h cryptcap.c
  110.                         $(CC) $(CFLAGS) cryptcap.c
  111.  
  112. $(OUTPATH)cryptdbx.o:    capi.h crypt.h keymgmt/keymgmt.h cryptdbx.c
  113.                         $(CC) $(CFLAGS) cryptdbx.c
  114.  
  115. $(OUTPATH)cryptobj.o:    capi.h crypt.h $(ASN1_DEP) cryptobj.c
  116.                         $(CC) $(CFLAGS) cryptobj.c
  117.  
  118. $(OUTPATH)lib_3des.o:    capi.h crypt.h libdes/des.h lib_3des.c
  119.                         $(CC) $(CFLAGS) lib_3des.c
  120.  
  121. $(OUTPATH)lib_blow.o:    capi.h crypt.h blowfish/blowfish.h lib_blow.c
  122.                         $(CC) $(CFLAGS) lib_blow.c
  123.  
  124. $(OUTPATH)lib_cert.o:    capi.h crypt.h lib_cert.c
  125.                         $(CC) $(CFLAGS) lib_cert.c
  126.  
  127. $(OUTPATH)lib_des.o:    capi.h crypt.h testdes.h libdes/des.h lib_des.c
  128.                         $(CC) $(CFLAGS) lib_des.c
  129.  
  130. $(OUTPATH)lib_dh.o:        capi.h crypt.h lib_dh.c
  131.                         $(CC) $(CFLAGS) lib_dh.c
  132.  
  133. $(OUTPATH)lib_dsa.o:    capi.h crypt.h bnlib/bn.h lib_dsa.c
  134.                         $(CC) $(CFLAGS) lib_dsa.c
  135.  
  136. $(OUTPATH)lib_idea.o:    capi.h crypt.h idea/idea.h testidea.h lib_idea.c
  137.                         $(CC) $(CFLAGS) lib_idea.c
  138.  
  139. $(OUTPATH)lib_md2.o:    capi.h crypt.h hash/md2.h lib_md2.c
  140.                         $(CC) $(CFLAGS) lib_md2.c
  141.  
  142. $(OUTPATH)lib_md4.o:    capi.h crypt.h hash/md4.h lib_md4.c
  143.                         $(CC) $(CFLAGS) lib_md4.c
  144.  
  145. $(OUTPATH)lib_md5.o:    capi.h crypt.h hash/md5.h lib_md5.c
  146.                         $(CC) $(CFLAGS) lib_md5.c
  147.  
  148. $(OUTPATH)lib_mdc.o:    capi.h crypt.h hash/sha.h lib_mdc.c
  149.                         $(CC) $(CFLAGS) lib_mdc.c
  150.  
  151. $(OUTPATH)lib_null.o:    capi.h crypt.h lib_null.c
  152.                         $(CC) $(CFLAGS) lib_null.c
  153.  
  154. $(OUTPATH)lib_pkcs.o:    capi.h crypt.h $(ASN1_DEP) lib_pkcs.c
  155.                         $(CC) $(CFLAGS) lib_pkcs.c
  156.  
  157. $(OUTPATH)lib_rc2.o:    capi.h crypt.h rc/rc2.h lib_rc2.c
  158.                         $(CC) $(CFLAGS) lib_rc2.c
  159.  
  160. $(OUTPATH)lib_rc4.o:    capi.h crypt.h testrc4.h rc/rc4.h lib_rc4.c
  161.                         $(CC) $(CFLAGS) lib_rc4.c
  162.  
  163. $(OUTPATH)lib_rc5.o:    capi.h crypt.h rc/rc5.h lib_rc5.c
  164.                         $(CC) $(CFLAGS) lib_rc5.c
  165.  
  166. $(OUTPATH)lib_ripe.o:    capi.h crypt.h hash/ripemd.h lib_ripe.c
  167.                         $(CC) $(CFLAGS) lib_ripe.c
  168.  
  169. $(OUTPATH)lib_rand.o:    capi.h crypt.h lib_rand.c
  170.                         $(CC) $(CFLAGS) lib_rand.c
  171.  
  172. $(OUTPATH)lib_rsa.o:    capi.h crypt.h bnlib/bn.h lib_rsa.c
  173.                         $(CC) $(CFLAGS) lib_rsa.c
  174.  
  175. $(OUTPATH)lib_safr.o:    capi.h crypt.h testsafr.h safer/safer.h lib_safr.c
  176.                         $(CC) $(CFLAGS) lib_safr.c
  177.  
  178. $(OUTPATH)lib_sha.o:    capi.h crypt.h hash/sha.h lib_sha.c
  179.                         $(CC) $(CFLAGS) lib_sha.c
  180.  
  181. $(OUTPATH)testapp.o:    capi.h testapp.c
  182.                         $(CC) $(CFLAGS) testapp.c
  183.  
  184. $(OUTPATH)testhl.o:        capi.h crypt.h testhl.c
  185.                         $(CC) $(CFLAGS) testhl.c
  186.  
  187. $(OUTPATH)testlib.o:    capi.h crypt.h testlib.c
  188.                         $(CC) $(CFLAGS) testlib.c
  189.  
  190. # bnlib subdirectory
  191.  
  192. $(OUTPATH)bn.o:            bnlib/bn.h bnlib/bn.c
  193.                         $(CC) $(CFLAGS) -DNDEBUG -DHAVE_CONFIG_H=1 bnlib/bn.c
  194.  
  195. $(OUTPATH)bn00.o:        bnlib/bn.h bnlib/bn00.c
  196.                         $(CC) $(CFLAGS) -DNDEBUG -DHAVE_CONFIG_H=1 bnlib/bn00.c
  197.  
  198. $(OUTPATH)lbn00.o:        bnlib/bn.h bnlib/lbn00.c
  199.                         $(CC) $(CFLAGS) -DNDEBUG -DHAVE_CONFIG_H=1 bnlib/lbn00.c
  200.  
  201. $(OUTPATH)lbnmem.o:        bnlib/bn.h bnlib/lbnmem.c
  202.                         $(CC) $(CFLAGS) -DNDEBUG -DHAVE_CONFIG_H=1 bnlib/lbnmem.c
  203.  
  204. $(OUTPATH)legal.o:        bnlib/legal.c
  205.                         $(CC) $(CFLAGS) -DNDEBUG -DHAVE_CONFIG_H=1 bnlib/legal.c
  206.  
  207. # blowfish subdirectory
  208.  
  209. $(OUTPATH)blowfish.o:    crypt.h blowfish/blowfish.h blowfish/blowfish.c
  210.                         $(CC) $(CFLAGS) blowfish/blowfish.c
  211.  
  212. # hash subdirectory
  213.  
  214. $(OUTPATH)md2.o:        crypt.h hash/md2.h hash/md2.c
  215.                         $(CC) $(CFLAGS) hash/md2.c
  216.  
  217. $(OUTPATH)md4.o:        crypt.h hash/md4.h hash/md4.c
  218.                         $(CC) $(CFLAGS) hash/md4.c
  219.  
  220. $(OUTPATH)md5.o:        crypt.h hash/md5.h hash/md5.c
  221.                         $(CC) $(CFLAGS) hash/md5.c
  222.  
  223. $(OUTPATH)ripemd.o:        crypt.h hash/ripemd.h hash/ripemd.c
  224.                         $(CC) $(CFLAGS) hash/ripemd.c
  225.  
  226. $(OUTPATH)sha.o:        crypt.h hash/sha.h hash/shacore.c hash/sha.c
  227.                         $(CC) $(CFLAGS) hash/sha.c
  228.  
  229. $(OUTPATH)sha1.o:        crypt.h hash/sha.h hash/shacore.c hash/sha1.c
  230.                         $(CC) $(CFLAGS) hash/sha1.c
  231.  
  232. # idea subdirectory
  233.  
  234. $(OUTPATH)idea.o:        crypt.h idea/idea.h idea/idea.c
  235.                         $(CC) $(CFLAGS) idea/idea.c
  236.  
  237. # keymgmt subdirectory
  238.  
  239. $(OUTPATH)asn1.o:        $(ASN1_DEP) keymgmt/asn1.c
  240.                         $(CC) $(CFLAGS) keymgmt/asn1.c
  241.  
  242. $(OUTPATH)asn1keys.o:    $(ASN1_DEP) keymgmt/asn1keys.c
  243.                         $(CC) $(CFLAGS) keymgmt/asn1keys.c
  244.  
  245. $(OUTPATH)asn1objs.o:    $(ASN1_DEP) keymgmt/asn1objs.c
  246.                         $(CC) $(CFLAGS) keymgmt/asn1objs.c
  247.  
  248. $(OUTPATH)pgp_idea.o:    crypt.h keymgmt/pgp_idea.h keymgmt/pgp_idea.c
  249.                         $(CC) $(CFLAGS) keymgmt/pgp_idea.c
  250.  
  251. $(OUTPATH)pgp_key.o:    crypt.h keymgmt/keymgmt.h keymgmt/pgp_idea.h \
  252.                         keymgmt/pgp_key.c
  253.                         $(CC) $(CFLAGS) keymgmt/pgp_key.c
  254.  
  255. $(OUTPATH)stream.o:        $(ASN1_DEP) keymgmt/stream.c
  256.                         $(CC) $(CFLAGS) keymgmt/stream.c
  257.  
  258. $(OUTPATH)x509_key.o:    $(ASN1_DEP) keymgmt/keymgmt.h keymgmt/x509_key.c
  259.                         $(CC) $(CFLAGS) keymgmt/x509_key.c
  260.  
  261. # libdes subdirectory
  262.  
  263. $(OUTPATH)ecb3_enc.o:    libdes/des.h libdes/des_locl.h libdes/ecb3_enc.c
  264.                         $(CC) $(CFLAGS) libdes/ecb3_enc.c
  265.  
  266. $(OUTPATH)ecb_enc.o:    libdes/des.h libdes/des_locl.h libdes/spr.h \
  267.                         libdes/version.h libdes/ecb_enc.c
  268.                         $(CC) $(CFLAGS) libdes/ecb_enc.c
  269.  
  270. $(OUTPATH)pcbc_enc.o:    libdes/des.h libdes/des_locl.h libdes/pcbc_enc.c
  271.                         $(CC) $(CFLAGS) libdes/pcbc_enc.c
  272.  
  273. $(OUTPATH)set_key.o:    libdes/des.h libdes/des_locl.h libdes/podd.h \
  274.                         libdes/sk.h libdes/set_key.c
  275.                         $(CC) $(CFLAGS) libdes/set_key.c
  276.  
  277. # rc subdirectory
  278.  
  279. $(OUTPATH)rc2.o:        rc/rc2.h rc/rc2.c
  280.                         $(CC) $(CFLAGS) rc/rc2.c
  281.  
  282. $(OUTPATH)rc4.o:        rc/rc4.h rc/rc4.c
  283.                         $(CC) $(CFLAGS) rc/rc4.c
  284.  
  285. $(OUTPATH)rc5.o:        rc/rc5.h rc/rc5.c
  286.                         $(CC) $(CFLAGS) rc/rc5.c
  287.  
  288. # safer subdirectory
  289.  
  290. $(OUTPATH)safer.o:        safer/safer.h safer/safer.c
  291.                         $(CC) $(CFLAGS) safer/safer.c
  292.  
  293. # Create the library, either as a static or shared library.  The main test
  294. # program is also listed as a dependency since we need to use OS-specific
  295. # compiler options for it which a simple 'make testlib' won't give us (yuck).
  296.  
  297. $(LIBNAME):                $(OBJS) $(OUTPATH)testhl.o $(OUTPATH)testlib.o
  298.                         ar rc $(LIBNAME) $(OBJS)
  299.  
  300. $(SLIBNAME):            $(OBJS) $(OUTPATH)testhl.o $(OUTPATH)testlib.o
  301.                         $(LD) -shared -o $(SLIBNAME).$(MAJ).$(MIN) $(OBJS)
  302.  
  303. # Link everything into the test programs
  304.  
  305. testlib:    $(LIBNAME) $(OUTPATH)testhl.o $(OUTPATH)testlib.o
  306.             @$(LD) -o testlib $(LFLAGS) $(OUTPATH)testhl.o \
  307.             $(OUTPATH)testlib.o -L. -l$(PROJ)
  308.  
  309. testapp:    $(LIBNAME) $(OUTPATH)testapp.o
  310.             @$(LD) -o testapp $(LFLAGS) $(OUTPATH)testapp.o -L. -l$(PROJ)
  311.  
  312. stestlib:    $(SLIBNAME) $(OUTPATH)testhl.o $(OUTPATH)testlib.o
  313.             @$(LD) -o testlib $(LFLAGS) $(OUTPATH)testhl.o \
  314.             $(OUTPATH)testlib.o $(SLIBNAME).$(MAJ).$(MIN)
  315.  
  316. stestapp:    $(SLIBNAME) $(OUTPATH)testapp.o
  317.             @$(LD) -o testapp $(LFLAGS) $(OUTPATH)testapp.o \
  318.             $(SLIBNAME).$(MAJ).$(MIN)
  319.  
  320. #****************************************************************************
  321. #*                                                                            *
  322. #*                        Defines for each variation of Unix                    *
  323. #*                                                                            *
  324. #****************************************************************************
  325.  
  326. # Aches: Use cc (it may be buggy, but it sure can optimize (actually the
  327. #         bugs only appear when you turn on optimization)).
  328.  
  329. AIX:
  330.         @make $(TARGET)
  331.  
  332. # Apollo: Use cc
  333.  
  334. Apollo:
  335.         @make $(TARGET)
  336.  
  337. # AUX: The only Unix so bloated it has /etc.etc.etc
  338.  
  339. # 386 BSD's: Use gcc (which is the default anyway)
  340.  
  341. BSD386:
  342.         @make $(TARGET)
  343. iBSD:
  344.         @make $(TARGET)
  345.  
  346. # Convex: Use cc.
  347.  
  348. Convex:
  349.         @make $(TARGET)
  350.  
  351. # DGUX: Use cc (which is a modified gcc)
  352.  
  353. dgux:
  354.         @make $(TARGET) CMDC="-ansi"
  355.  
  356. # Esix: Run away!!  Run away!!
  357.  
  358. # PHUX: Use cc.  Need to use '-Aa -D_HPUX_SOURCE' as compiler options to get
  359. #        the C compiler into ANSI C mode with UNIX symbols.  In addition the
  360. #        PHUX compilers don't recognise the -O2 in CFLAGS but use +O3 instead,
  361. #        however we need to retain both in case someone is using gcc instead
  362. #        of cc/c89.  Unfortunately this leads to two compiler warnings for
  363. #        each compiled file.
  364.  
  365. HP-UX:
  366.         @make $(TARGET) CMDC="-Aa -D_HPUX_SOURCE +O3"
  367.  
  368. # Irix: Use cc with the -acpp flag for maximum ANSI-ness
  369.  
  370. IRIX:
  371.         @make $(TARGET) CMDC="-acpp"
  372. IRIX64:
  373.         @make $(TARGET) CMDC="-acpp"
  374.  
  375. # ISC Unix: Use gcc
  376.  
  377. ISC:
  378.         @make $(TARGET) CC=gcc
  379.  
  380. # Linux: Use gcc (which is the default anyway)
  381.  
  382. Linux:
  383.         @make $(TARGET)
  384.  
  385. # MiNT: Use gcc
  386.  
  387. MiNT:
  388.         @make $(TARGET) CC=gcc
  389.  
  390. # NeXT 3.0: Use cc
  391.  
  392. NeXT:
  393.         @make $(TARGET) CMDL="-object -s"
  394.  
  395. # OSF 1: Use gcc
  396.  
  397. OSF1:
  398.         @make $(TARGET) CC=gcc
  399.  
  400. # QNX 4.x: Use cc -ml, ld -N32768 -ml
  401.  
  402. QNX:
  403.         @make $(TARGET) CMDC="-ml" CMDL="-N32768 -ml"
  404.  
  405. # SCO: Use cc.
  406.  
  407. SCO:
  408.         @make $(TARGET) CC=cc
  409.  
  410. # Sun/Slowaris: Use gcc.  Interesting note:  There has never been a single
  411. #                report of this makefile not working on a Sun box.  Shows how
  412. #                popular the Sun compiler is...
  413. #                SunOS 4.x doesn't have memmove() so we use bcopy() instead
  414. #                (this doesn't hurt for Solaris, and means we don't have to
  415. #                try to detect the OS version).
  416.  
  417. SunOS:
  418.         @make $(TARGET) CC=gcc CMDC="-D\"memmove(d,s,n)=bcopy(s,d,n)\""
  419.  
  420. # SVR4: Use cc.  Better results can be obtained by upgrading your OS to
  421. #        4.4 BSD.
  422.  
  423. SVR4:
  424.         @make $(TARGET)
  425.  
  426. # Ultrix: Use vcc or gcc
  427.  
  428. ULTRIX:
  429.         @make $(TARGET) CC=gcc
  430.  
  431. # Amdahl UTS 4: Use cc
  432.  
  433. UTS4:
  434.         @make $(TARGET) CMDC="-Xc"
  435.  
  436. #****************************************************************************
  437. #*                                                                            *
  438. #*                        Clean up after make has finished                    *
  439. #*                                                                            *
  440. #****************************************************************************
  441.  
  442. clean:
  443.         rm -f *.o core testlib stestlib testapp stestapp endian $(LIBNAME) \
  444.         $(SLIBNAME)
  445.