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