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