makefile 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. # MAKEFILE for linux GCC
  2. #
  3. # Tom St Denis
  4. # Modified by Clay Culver
  5. # The version
  6. VERSION=0.98
  7. # Compiler and Linker Names
  8. #CC=gcc
  9. #LD=ld
  10. # Archiver [makes .a files]
  11. #AR=ar
  12. #ARFLAGS=r
  13. # Compilation flags. Note the += does not write over the user's CFLAGS!
  14. CFLAGS += -c -I./ -Wall -Wsign-compare -W -Wshadow
  15. # -Werror
  16. # optimize for SPEED
  17. #CFLAGS += -O3 -funroll-loops
  18. #add -fomit-frame-pointer. hinders debugging!
  19. CFLAGS += -fomit-frame-pointer
  20. # optimize for SIZE
  21. CFLAGS += -Os
  22. # compile for DEBUGING (required for ccmalloc checking!!!)
  23. #CFLAGS += -g3
  24. #These flags control how the library gets built.
  25. #Output filenames for various targets.
  26. LIBNAME=libtomcrypt.a
  27. HASH=hashsum
  28. CRYPT=encrypt
  29. SMALL=small
  30. PROF=x86_prof
  31. TV=tv_gen
  32. #LIBPATH-The directory for libtomcrypt to be installed to.
  33. #INCPATH-The directory to install the header files for libtomcrypt.
  34. #DATAPATH-The directory to install the pdf docs.
  35. DESTDIR=
  36. LIBPATH=/usr/lib
  37. INCPATH=/usr/include
  38. DATAPATH=/usr/share/doc/libtomcrypt/pdf
  39. #List of objects to compile.
  40. #Leave MPI built-in or force developer to link against libtommath?
  41. MPIOBJECT=mpi.o
  42. OBJECTS=error_to_string.o mpi_to_ltc_error.o base64_encode.o base64_decode.o \
  43. \
  44. crypt.o crypt_find_cipher.o crypt_find_hash_any.o \
  45. crypt_hash_is_valid.o crypt_register_hash.o crypt_unregister_prng.o \
  46. crypt_argchk.o crypt_find_cipher_any.o crypt_find_hash_id.o \
  47. crypt_prng_descriptor.o crypt_register_prng.o crypt_cipher_descriptor.o \
  48. crypt_find_cipher_id.o crypt_find_prng.o crypt_prng_is_valid.o \
  49. crypt_unregister_cipher.o crypt_cipher_is_valid.o crypt_find_hash.o \
  50. crypt_hash_descriptor.o crypt_register_cipher.o crypt_unregister_hash.o \
  51. \
  52. sober128.o fortuna.o sprng.o yarrow.o rc4.o rng_get_bytes.o rng_make_prng.o \
  53. \
  54. rand_prime.o is_prime.o \
  55. \
  56. ecc.o dh.o \
  57. \
  58. rsa_decrypt_key.o rsa_encrypt_key.o rsa_exptmod.o rsa_free.o rsa_make_key.o \
  59. rsa_sign_hash.o rsa_verify_hash.o rsa_export.o rsa_import.o tim_exptmod.o \
  60. rsa_v15_encrypt_key.o rsa_v15_decrypt_key.o rsa_v15_sign_hash.o rsa_v15_verify_hash.o \
  61. \
  62. dsa_export.o dsa_free.o dsa_import.o dsa_make_key.o dsa_sign_hash.o \
  63. dsa_verify_hash.o dsa_verify_key.o \
  64. \
  65. aes.o aes_enc.o \
  66. \
  67. blowfish.o des.o safer_tab.o safer.o saferp.o rc2.o xtea.o \
  68. rc6.o rc5.o cast5.o noekeon.o twofish.o skipjack.o \
  69. \
  70. md2.o md4.o md5.o sha1.o sha256.o sha512.o tiger.o whirl.o \
  71. rmd128.o rmd160.o \
  72. \
  73. packet_store_header.o packet_valid_header.o \
  74. \
  75. eax_addheader.o eax_decrypt.o eax_decrypt_verify_memory.o eax_done.o eax_encrypt.o \
  76. eax_encrypt_authenticate_memory.o eax_init.o eax_test.o \
  77. \
  78. ocb_decrypt.o ocb_decrypt_verify_memory.o ocb_done_decrypt.o ocb_done_encrypt.o \
  79. ocb_encrypt.o ocb_encrypt_authenticate_memory.o ocb_init.o ocb_ntz.o \
  80. ocb_shift_xor.o ocb_test.o s_ocb_done.o \
  81. \
  82. omac_done.o omac_file.o omac_init.o omac_memory.o omac_process.o omac_test.o \
  83. \
  84. pmac_done.o pmac_file.o pmac_init.o pmac_memory.o pmac_ntz.o pmac_process.o \
  85. pmac_shift_xor.o pmac_test.o \
  86. \
  87. cbc_start.o cbc_encrypt.o cbc_decrypt.o cbc_getiv.o cbc_setiv.o \
  88. cfb_start.o cfb_encrypt.o cfb_decrypt.o cfb_getiv.o cfb_setiv.o \
  89. ofb_start.o ofb_encrypt.o ofb_decrypt.o ofb_getiv.o ofb_setiv.o \
  90. ctr_start.o ctr_encrypt.o ctr_decrypt.o ctr_getiv.o ctr_setiv.o \
  91. ecb_start.o ecb_encrypt.o ecb_decrypt.o \
  92. \
  93. hash_file.o hash_filehandle.o hash_memory.o \
  94. \
  95. hmac_done.o hmac_file.o hmac_init.o hmac_memory.o hmac_process.o hmac_test.o \
  96. \
  97. pkcs_1_mgf1.o pkcs_1_oaep_encode.o pkcs_1_oaep_decode.o \
  98. pkcs_1_pss_encode.o pkcs_1_pss_decode.o pkcs_1_i2osp.o pkcs_1_os2ip.o \
  99. pkcs_1_v15_es_encode.o pkcs_1_v15_es_decode.o pkcs_1_v15_sa_encode.o pkcs_1_v15_sa_decode.o \
  100. \
  101. pkcs_5_1.o pkcs_5_2.o \
  102. \
  103. burn_stack.o zeromem.o \
  104. $(MPIOBJECT)
  105. TESTOBJECTS=demos/test.o
  106. HASHOBJECTS=demos/hashsum.o
  107. CRYPTOBJECTS=demos/encrypt.o
  108. SMALLOBJECTS=demos/small.o
  109. PROFS=demos/x86_prof.o
  110. TVS=demos/tv_gen.o
  111. #Files left over from making the crypt.pdf.
  112. LEFTOVERS=*.dvi *.log *.aux *.toc *.idx *.ilg *.ind *.out
  113. #Compressed filenames
  114. COMPRESSED=crypt-$(VERSION).tar.bz2 crypt-$(VERSION).zip
  115. #Header files used by libtomcrypt.
  116. HEADERS=ltc_tommath.h mycrypt_cfg.h \
  117. mycrypt_misc.h mycrypt_prng.h mycrypt_cipher.h mycrypt_hash.h \
  118. mycrypt_macros.h mycrypt_pk.h mycrypt.h mycrypt_argchk.h \
  119. mycrypt_custom.h mycrypt_pkcs.h
  120. #The default rule for make builds the libtomcrypt library.
  121. default:library
  122. #ciphers come in two flavours... enc+dec and enc
  123. aes_enc.o: aes.c aes_tab.c
  124. $(CC) $(CFLAGS) -DENCRYPT_ONLY -c aes.c -o aes_enc.o
  125. #These are the rules to make certain object files.
  126. aes.o: aes.c aes_tab.c
  127. twofish.o: twofish.c twofish_tab.c
  128. whirl.o: whirl.c whirltab.c
  129. ecc.o: ecc.c ecc_sys.c
  130. dh.o: dh.c dh_sys.c
  131. sha512.o: sha512.c sha384.c
  132. sha256.o: sha256.c sha224.c
  133. #This rule makes the libtomcrypt library.
  134. library: $(LIBNAME)
  135. $(LIBNAME): $(OBJECTS)
  136. $(AR) $(ARFLAGS) $@ $(OBJECTS)
  137. #This rule makes the hash program included with libtomcrypt
  138. hashsum: library $(HASHOBJECTS)
  139. $(CC) $(HASHOBJECTS) $(LIBNAME) -o $(HASH) $(WARN)
  140. #makes the crypt program
  141. crypt: library $(CRYPTOBJECTS)
  142. $(CC) $(CRYPTOBJECTS) $(LIBNAME) -o $(CRYPT) $(WARN)
  143. #makes the small program
  144. small: library $(SMALLOBJECTS)
  145. $(CC) $(SMALLOBJECTS) $(LIBNAME) -o $(SMALL) $(WARN)
  146. x86_prof: library $(PROFS)
  147. $(CC) $(PROFS) $(LIBNAME) $(EXTRALIBS) -o $(PROF)
  148. tv_gen: library $(TVS)
  149. $(CC) $(TVS) $(LIBNAME) $(EXTRALIBS) -o $(TV)
  150. #This rule installs the library and the header files. This must be run
  151. #as root in order to have a high enough permission to write to the correct
  152. #directories and to set the owner and group to root.
  153. install: library docs
  154. install -d -g root -o root $(DESTDIR)$(LIBPATH)
  155. install -d -g root -o root $(DESTDIR)$(INCPATH)
  156. install -d -g root -o root $(DESTDIR)$(DATAPATH)
  157. install -g root -o root $(LIBNAME) $(DESTDIR)$(LIBPATH)
  158. install -g root -o root $(HEADERS) $(DESTDIR)$(INCPATH)
  159. install -g root -o root doc/crypt.pdf $(DESTDIR)$(DATAPATH)
  160. #This rule cleans the source tree of all compiled code, not including the pdf
  161. #documentation.
  162. clean:
  163. rm -f $(OBJECTS) $(TESTOBJECTS) $(HASHOBJECTS) $(CRYPTOBJECTS) $(SMALLOBJECTS) $(LEFTOVERS) $(LIBNAME)
  164. rm -f $(TEST) $(HASH) $(COMPRESSED) $(PROFS) $(PROF) $(TVS) $(TV)
  165. rm -f *.a *.dll *stackdump *.lib *.exe *.obj demos/*.obj demos/*.o *.bat *.txt *.il *.da demos/*.il demos/*.da *.dyn *.dpi \
  166. *.gcda *.gcno demos/*.gcno demos/*.gcda *~ doc/*
  167. cd demos/test ; make clean
  168. #This builds the crypt.pdf file. Note that the rm -f *.pdf has been removed
  169. #from the clean command! This is because most people would like to keep the
  170. #nice pre-compiled crypt.pdf that comes with libtomcrypt! We only need to
  171. #delete it if we are rebuilding it.
  172. docs: crypt.tex
  173. rm -f doc/crypt.pdf $(LEFTOVERS)
  174. echo "hello" > crypt.ind
  175. latex crypt > /dev/null
  176. latex crypt > /dev/null
  177. makeindex crypt.idx > /dev/null
  178. latex crypt > /dev/null
  179. dvipdf crypt
  180. mv -ivf crypt.pdf doc/crypt.pdf
  181. rm -f $(LEFTOVERS)
  182. docdvi: crypt.tex
  183. echo hello > crypt.ind
  184. latex crypt > /dev/null
  185. latex crypt > /dev/null
  186. makeindex crypt.idx
  187. latex crypt > /dev/null
  188. #pretty build
  189. pretty:
  190. perl pretty.build
  191. #for GCC 3.4+
  192. profiled:
  193. make clean
  194. make CFLAGS="$(CFLAGS) -fprofile-generate" EXTRALIBS=-lgcov x86_prof
  195. ./x86_prof
  196. rm *.o *.a x86_prof
  197. make CFLAGS="$(CFLAGS) -fprofile-use" EXTRALIBS=-lgcov x86_prof
  198. #beta
  199. beta: clean
  200. cd .. ; rm -rf crypt* libtomcrypt-$(VERSION)-beta ; mkdir libtomcrypt-$(VERSION)-beta ; \
  201. cp -R ./libtomcrypt/* ./libtomcrypt-$(VERSION)-beta/ ; tar -c libtomcrypt-$(VERSION)-beta/* > crypt-$(VERSION)-beta.tar ; \
  202. bzip2 -9vv crypt-$(VERSION)-beta.tar ; zip -9 -r crypt-$(VERSION)-beta.zip libtomcrypt-$(VERSION)-beta/*
  203. #zipup the project (take that!)
  204. zipup: clean docs
  205. cd .. ; rm -rf crypt* libtomcrypt-$(VERSION) ; mkdir libtomcrypt-$(VERSION) ; \
  206. cp -R ./libtomcrypt/* ./libtomcrypt-$(VERSION)/ ; tar -c libtomcrypt-$(VERSION)/* > crypt-$(VERSION).tar ; \
  207. bzip2 -9vv crypt-$(VERSION).tar ; zip -9 -r crypt-$(VERSION).zip libtomcrypt-$(VERSION)/* ; \
  208. gpg -b -a crypt-$(VERSION).tar.bz2 ; gpg -b -a crypt-$(VERSION).zip