makefile 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. # MAKEFILE for linux GCC
  2. #
  3. # Tom St Denis
  4. # Modified by Clay Culver
  5. # The version
  6. VERSION=0.99
  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-all-loops
  18. #add -fomit-frame-pointer. hinders debugging!
  19. #CFLAGS += -fomit-frame-pointer
  20. # optimize for SIZE
  21. CFLAGS += -Os -DSMALL_CODE
  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 chc.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. der_encode_integer.o der_decode_integer.o der_length_integer.o \
  104. der_put_multi_integer.o der_get_multi_integer.o \
  105. \
  106. burn_stack.o zeromem.o \
  107. \
  108. $(MPIOBJECT)
  109. TESTOBJECTS=demos/test.o
  110. HASHOBJECTS=demos/hashsum.o
  111. CRYPTOBJECTS=demos/encrypt.o
  112. SMALLOBJECTS=demos/small.o
  113. PROFS=demos/x86_prof.o
  114. TVS=demos/tv_gen.o
  115. #Files left over from making the crypt.pdf.
  116. LEFTOVERS=*.dvi *.log *.aux *.toc *.idx *.ilg *.ind *.out
  117. #Compressed filenames
  118. COMPRESSED=crypt-$(VERSION).tar.bz2 crypt-$(VERSION).zip
  119. #Header files used by libtomcrypt.
  120. HEADERS=ltc_tommath.h mycrypt_cfg.h \
  121. mycrypt_misc.h mycrypt_prng.h mycrypt_cipher.h mycrypt_hash.h \
  122. mycrypt_macros.h mycrypt_pk.h mycrypt.h mycrypt_argchk.h \
  123. mycrypt_custom.h mycrypt_pkcs.h tommath_class.h tommath_superclass.h
  124. #The default rule for make builds the libtomcrypt library.
  125. default:library
  126. #ciphers come in two flavours... enc+dec and enc
  127. aes_enc.o: aes.c aes_tab.c
  128. $(CC) $(CFLAGS) -DENCRYPT_ONLY -c aes.c -o aes_enc.o
  129. #These are the rules to make certain object files.
  130. aes.o: aes.c aes_tab.c
  131. twofish.o: twofish.c twofish_tab.c
  132. whirl.o: whirl.c whirltab.c
  133. ecc.o: ecc.c ecc_sys.c
  134. dh.o: dh.c dh_sys.c
  135. sha512.o: sha512.c sha384.c
  136. sha256.o: sha256.c sha224.c
  137. #This rule makes the libtomcrypt library.
  138. library: $(LIBNAME)
  139. $(LIBNAME): $(OBJECTS)
  140. $(AR) $(ARFLAGS) $@ $(OBJECTS)
  141. #This rule makes the hash program included with libtomcrypt
  142. hashsum: library $(HASHOBJECTS)
  143. $(CC) $(HASHOBJECTS) $(LIBNAME) -o $(HASH) $(WARN)
  144. #makes the crypt program
  145. crypt: library $(CRYPTOBJECTS)
  146. $(CC) $(CRYPTOBJECTS) $(LIBNAME) -o $(CRYPT) $(WARN)
  147. #makes the small program
  148. small: library $(SMALLOBJECTS)
  149. $(CC) $(SMALLOBJECTS) $(LIBNAME) -o $(SMALL) $(WARN)
  150. x86_prof: library $(PROFS)
  151. $(CC) $(PROFS) $(LIBNAME) $(EXTRALIBS) -o $(PROF)
  152. tv_gen: library $(TVS)
  153. $(CC) $(TVS) $(LIBNAME) $(EXTRALIBS) -o $(TV)
  154. #This rule installs the library and the header files. This must be run
  155. #as root in order to have a high enough permission to write to the correct
  156. #directories and to set the owner and group to root.
  157. install: library docs
  158. install -d -g root -o root $(DESTDIR)$(LIBPATH)
  159. install -d -g root -o root $(DESTDIR)$(INCPATH)
  160. install -d -g root -o root $(DESTDIR)$(DATAPATH)
  161. install -g root -o root $(LIBNAME) $(DESTDIR)$(LIBPATH)
  162. install -g root -o root $(HEADERS) $(DESTDIR)$(INCPATH)
  163. install -g root -o root doc/crypt.pdf $(DESTDIR)$(DATAPATH)
  164. install_lib: library
  165. install -d -g root -o root $(DESTDIR)$(LIBPATH)
  166. install -d -g root -o root $(DESTDIR)$(INCPATH)
  167. install -g root -o root $(LIBNAME) $(DESTDIR)$(LIBPATH)
  168. install -g root -o root $(HEADERS) $(DESTDIR)$(INCPATH)
  169. #This rule cleans the source tree of all compiled code, not including the pdf
  170. #documentation.
  171. clean:
  172. rm -f $(OBJECTS) $(TESTOBJECTS) $(HASHOBJECTS) $(CRYPTOBJECTS) $(SMALLOBJECTS) $(LEFTOVERS) $(LIBNAME)
  173. rm -f $(TEST) $(HASH) $(COMPRESSED) $(PROFS) $(PROF) $(TVS) $(TV)
  174. rm -f *.la *.lo *.o *.a *.dll *stackdump *.lib *.exe *.obj demos/*.obj demos/*.o *.bat *.txt *.il *.da demos/*.il demos/*.da *.dyn *.dpi \
  175. *.gcda *.gcno demos/*.gcno demos/*.gcda *~ doc/*
  176. cd demos/test ; make clean
  177. rm -rf .libs demos/.libs demos/test/.libs
  178. #This builds the crypt.pdf file. Note that the rm -f *.pdf has been removed
  179. #from the clean command! This is because most people would like to keep the
  180. #nice pre-compiled crypt.pdf that comes with libtomcrypt! We only need to
  181. #delete it if we are rebuilding it.
  182. docs: crypt.tex
  183. rm -f doc/crypt.pdf $(LEFTOVERS)
  184. echo "hello" > crypt.ind
  185. latex crypt > /dev/null
  186. latex crypt > /dev/null
  187. makeindex crypt.idx > /dev/null
  188. latex crypt > /dev/null
  189. dvipdf crypt
  190. mv -ivf crypt.pdf doc/crypt.pdf
  191. rm -f $(LEFTOVERS)
  192. docdvi: crypt.tex
  193. echo hello > crypt.ind
  194. latex crypt > /dev/null
  195. latex crypt > /dev/null
  196. makeindex crypt.idx
  197. latex crypt > /dev/null
  198. #pretty build
  199. pretty:
  200. perl pretty.build
  201. #for GCC 3.4+
  202. profiled:
  203. make clean
  204. make CFLAGS="$(CFLAGS) -fprofile-generate" EXTRALIBS=-lgcov x86_prof
  205. ./x86_prof
  206. rm *.o *.a x86_prof
  207. make CFLAGS="$(CFLAGS) -fprofile-use" EXTRALIBS=-lgcov x86_prof
  208. #zipup the project (take that!)
  209. zipup: clean docs
  210. cd .. ; rm -rf crypt* libtomcrypt-$(VERSION) ; mkdir libtomcrypt-$(VERSION) ; \
  211. cp -R ./libtomcrypt/* ./libtomcrypt-$(VERSION)/ ; tar -c libtomcrypt-$(VERSION)/* > crypt-$(VERSION).tar ; \
  212. bzip2 -9vv crypt-$(VERSION).tar ; zip -9 -r crypt-$(VERSION).zip libtomcrypt-$(VERSION)/* ; \
  213. gpg -b -a crypt-$(VERSION).tar.bz2 ; gpg -b -a crypt-$(VERSION).zip