20
20
# Compilation flags. Note the += does not write over the user's CFLAGS!
21
21
# The rest of the flags come from the parent Dropbear makefile
22
CFLAGS += -c -I$(srcdir)
22
CFLAGS += -c -I$(srcdir)/src/headers/ -I$(srcdir)/../
24
# additional warnings (newer GCC 3.4 and higher)
25
#CFLAGS += -Wsystem-headers -Wdeclaration-after-statement -Wbad-function-cast -Wcast-align -Wstrict-prototypes -Wmissing-prototypes \
26
# -Wmissing-declarations -Wpointer-arith
25
28
# optimize for SPEED
26
#CFLAGS += -O3 -funroll-all-loops
29
#CFLAGS += -O3 -funroll-loops
28
#add -fomit-frame-pointer. hinders debugging!
31
# add -fomit-frame-pointer. hinders debugging!
29
32
#CFLAGS += -fomit-frame-pointer
31
34
# optimize for SIZE
32
#CFLAGS += -Os -DSMALL_CODE
35
#CFLAGS += -Os -DLTC_SMALL_CODE
37
# older GCCs can't handle the "rotate with immediate" ROLc/RORc/etc macros
39
#CFLAGS += -DLTC_NO_ROLC
34
41
# compile for DEBUGING (required for ccmalloc checking!!!)
37
#These flags control how the library gets built.
42
#CFLAGS += -g3 -DLTC_NO_ASM
39
44
#Output filenames for various targets.
40
45
LIBNAME=libtomcrypt.a
46
LIBTEST=testprof/libtomcrypt_prof.a
47
56
#LIBPATH-The directory for libtomcrypt to be installed to.
48
57
#INCPATH-The directory to install the header files for libtomcrypt.
52
61
INCPATH=/usr/include
53
62
DATAPATH=/usr/share/doc/libtomcrypt/pdf
64
#Who do we install as?
72
GROUP=$(INSTALL_GROUP)
55
77
#List of objects to compile.
57
79
#Leave MPI built-in or force developer to link against libtommath?
80
#MPIOBJECT=src/misc/mpi/mpi.o
59
81
#Dropbear uses libtommath
62
OBJECTS=error_to_string.o mpi_to_ltc_error.o base64_encode.o base64_decode.o \
64
crypt.o crypt_find_cipher.o crypt_find_hash_any.o \
65
crypt_hash_is_valid.o crypt_register_hash.o crypt_unregister_prng.o \
66
crypt_argchk.o crypt_find_cipher_any.o crypt_find_hash_id.o \
67
crypt_prng_descriptor.o crypt_register_prng.o crypt_cipher_descriptor.o \
68
crypt_find_cipher_id.o crypt_find_prng.o crypt_prng_is_valid.o \
69
crypt_unregister_cipher.o crypt_cipher_is_valid.o crypt_find_hash.o \
70
crypt_hash_descriptor.o crypt_register_cipher.o crypt_unregister_hash.o \
72
rand_prime.o is_prime.o \
79
md5.o sha1.o sha512.o \
81
cbc_start.o cbc_encrypt.o cbc_decrypt.o cbc_getiv.o cbc_setiv.o \
82
ecb_start.o ecb_encrypt.o ecb_decrypt.o \
86
hmac_done.o hmac_file.o hmac_init.o hmac_memory.o hmac_process.o hmac_test.o \
88
burn_stack.o zeromem.o \
84
OBJECTS=src/ciphers/aes/aes_enc.o $(MPIOBJECT) src/ciphers/aes/aes.o src/ciphers/anubis.o \
85
src/ciphers/blowfish.o src/ciphers/cast5.o src/ciphers/des.o src/ciphers/khazad.o src/ciphers/noekeon.o \
86
src/ciphers/rc2.o src/ciphers/rc5.o src/ciphers/rc6.o src/ciphers/safer/safer.o \
87
src/ciphers/safer/safer_tab.o src/ciphers/safer/saferp.o src/ciphers/skipjack.o \
88
src/ciphers/twofish/twofish.o src/ciphers/xtea.o src/encauth/ccm/ccm_memory.o \
89
src/encauth/ccm/ccm_test.o src/encauth/eax/eax_addheader.o src/encauth/eax/eax_decrypt.o \
90
src/encauth/eax/eax_decrypt_verify_memory.o src/encauth/eax/eax_done.o src/encauth/eax/eax_encrypt.o \
91
src/encauth/eax/eax_encrypt_authenticate_memory.o src/encauth/eax/eax_init.o \
92
src/encauth/eax/eax_test.o src/encauth/gcm/gcm_add_aad.o src/encauth/gcm/gcm_add_iv.o \
93
src/encauth/gcm/gcm_done.o src/encauth/gcm/gcm_gf_mult.o src/encauth/gcm/gcm_init.o \
94
src/encauth/gcm/gcm_memory.o src/encauth/gcm/gcm_process.o src/encauth/gcm/gcm_reset.o \
95
src/encauth/gcm/gcm_test.o src/encauth/ocb/ocb_decrypt.o src/encauth/ocb/ocb_decrypt_verify_memory.o \
96
src/encauth/ocb/ocb_done_decrypt.o src/encauth/ocb/ocb_done_encrypt.o src/encauth/ocb/ocb_encrypt.o \
97
src/encauth/ocb/ocb_encrypt_authenticate_memory.o src/encauth/ocb/ocb_init.o src/encauth/ocb/ocb_ntz.o \
98
src/encauth/ocb/ocb_shift_xor.o src/encauth/ocb/ocb_test.o src/encauth/ocb/s_ocb_done.o \
99
src/hashes/chc/chc.o src/hashes/helper/hash_file.o src/hashes/helper/hash_filehandle.o \
100
src/hashes/helper/hash_memory.o src/hashes/helper/hash_memory_multi.o src/hashes/md2.o src/hashes/md4.o \
101
src/hashes/md5.o src/hashes/rmd128.o src/hashes/rmd160.o src/hashes/sha1.o src/hashes/sha2/sha256.o \
102
src/hashes/sha2/sha512.o src/hashes/tiger.o src/hashes/whirl/whirl.o src/mac/hmac/hmac_done.o \
103
src/mac/hmac/hmac_file.o src/mac/hmac/hmac_init.o src/mac/hmac/hmac_memory.o \
104
src/mac/hmac/hmac_memory_multi.o src/mac/hmac/hmac_process.o src/mac/hmac/hmac_test.o \
105
src/mac/omac/omac_done.o src/mac/omac/omac_file.o src/mac/omac/omac_init.o src/mac/omac/omac_memory.o \
106
src/mac/omac/omac_memory_multi.o src/mac/omac/omac_process.o src/mac/omac/omac_test.o \
107
src/mac/pelican/pelican.o src/mac/pelican/pelican_memory.o src/mac/pelican/pelican_test.o \
108
src/mac/pmac/pmac_done.o src/mac/pmac/pmac_file.o src/mac/pmac/pmac_init.o src/mac/pmac/pmac_memory.o \
109
src/mac/pmac/pmac_memory_multi.o src/mac/pmac/pmac_ntz.o src/mac/pmac/pmac_process.o \
110
src/mac/pmac/pmac_shift_xor.o src/mac/pmac/pmac_test.o src/misc/base64/base64_decode.o \
111
src/misc/base64/base64_encode.o src/misc/burn_stack.o src/misc/crypt/crypt.o \
112
src/misc/crypt/crypt_argchk.o src/misc/crypt/crypt_cipher_descriptor.o \
113
src/misc/crypt/crypt_cipher_is_valid.o src/misc/crypt/crypt_find_cipher.o \
114
src/misc/crypt/crypt_find_cipher_any.o src/misc/crypt/crypt_find_cipher_id.o \
115
src/misc/crypt/crypt_find_hash.o src/misc/crypt/crypt_find_hash_any.o \
116
src/misc/crypt/crypt_find_hash_id.o src/misc/crypt/crypt_find_prng.o \
117
src/misc/crypt/crypt_hash_descriptor.o src/misc/crypt/crypt_hash_is_valid.o \
118
src/misc/crypt/crypt_prng_descriptor.o src/misc/crypt/crypt_prng_is_valid.o \
119
src/misc/crypt/crypt_register_cipher.o src/misc/crypt/crypt_register_hash.o \
120
src/misc/crypt/crypt_register_prng.o src/misc/crypt/crypt_unregister_cipher.o \
121
src/misc/crypt/crypt_unregister_hash.o src/misc/crypt/crypt_unregister_prng.o \
122
src/misc/error_to_string.o src/misc/mpi/is_prime.o src/misc/mpi/mpi_to_ltc_error.o \
123
src/misc/mpi/rand_prime.o src/misc/pkcs5/pkcs_5_1.o src/misc/pkcs5/pkcs_5_2.o src/misc/zeromem.o \
124
src/modes/cbc/cbc_decrypt.o src/modes/cbc/cbc_done.o src/modes/cbc/cbc_encrypt.o \
125
src/modes/cbc/cbc_getiv.o src/modes/cbc/cbc_setiv.o src/modes/cbc/cbc_start.o \
126
src/modes/cfb/cfb_decrypt.o src/modes/cfb/cfb_done.o src/modes/cfb/cfb_encrypt.o \
127
src/modes/cfb/cfb_getiv.o src/modes/cfb/cfb_setiv.o src/modes/cfb/cfb_start.o \
128
src/modes/ctr/ctr_decrypt.o src/modes/ctr/ctr_done.o src/modes/ctr/ctr_encrypt.o \
129
src/modes/ctr/ctr_getiv.o src/modes/ctr/ctr_setiv.o src/modes/ctr/ctr_start.o \
130
src/modes/ecb/ecb_decrypt.o src/modes/ecb/ecb_done.o src/modes/ecb/ecb_encrypt.o \
131
src/modes/ecb/ecb_start.o src/modes/ofb/ofb_decrypt.o src/modes/ofb/ofb_done.o \
132
src/modes/ofb/ofb_encrypt.o src/modes/ofb/ofb_getiv.o src/modes/ofb/ofb_setiv.o \
133
src/modes/ofb/ofb_start.o
135
HEADERS=src/headers/tommath_superclass.h src/headers/tomcrypt_cfg.h src/headers/tomcrypt_mac.h \
136
src/headers/tomcrypt_macros.h src/headers/tomcrypt_custom.h src/headers/tomcrypt_argchk.h \
137
src/headers/tomcrypt_cipher.h src/headers/tomcrypt_pk.h src/headers/tommath_class.h \
138
src/headers/ltc_tommath.h src/headers/tomcrypt_hash.h src/headers/tomcrypt_misc.h \
139
src/headers/tomcrypt.h src/headers/tomcrypt_pkcs.h src/headers/tomcrypt_prng.h testprof/tomcrypt_test.h
92
141
TESTOBJECTS=demos/test.o
93
142
HASHOBJECTS=demos/hashsum.o
94
143
CRYPTOBJECTS=demos/encrypt.o
95
144
SMALLOBJECTS=demos/small.o
96
PROFS=demos/x86_prof.o
97
145
TVS=demos/tv_gen.o
147
TIMINGS=demos/timing.o
99
150
#Files left over from making the crypt.pdf.
100
151
LEFTOVERS=*.dvi *.log *.aux *.toc *.idx *.ilg *.ind *.out
102
153
#Compressed filenames
103
154
COMPRESSED=crypt-$(VERSION).tar.bz2 crypt-$(VERSION).zip
105
#Header files used by libtomcrypt.
106
HEADERS=ltc_tommath.h mycrypt_cfg.h \
107
mycrypt_misc.h mycrypt_prng.h mycrypt_cipher.h mycrypt_hash.h \
108
mycrypt_macros.h mycrypt_pk.h mycrypt.h mycrypt_argchk.h \
109
mycrypt_custom.h mycrypt_pkcs.h
111
156
#The default rule for make builds the libtomcrypt library.
114
159
#ciphers come in two flavours... enc+dec and enc
115
aes_enc.o: aes.c aes_tab.c
116
$(CC) $(CFLAGS) -DENCRYPT_ONLY -c $(srcdir)/aes.c -o aes_enc.o
160
src/ciphers/aes/aes_enc.o: src/ciphers/aes/aes.c src/ciphers/aes/aes_tab.c
161
$(CC) $(CFLAGS) -DENCRYPT_ONLY -c src/ciphers/aes/aes.c -o src/ciphers/aes/aes_enc.o
118
163
#These are the rules to make certain object files.
119
aes.o: aes.c aes_tab.c
120
twofish.o: twofish.c twofish_tab.c
121
whirl.o: whirl.c whirltab.c
122
ecc.o: ecc.c ecc_sys.c
124
sha512.o: sha512.c sha384.c
125
sha256.o: sha256.c sha224.c
164
src/ciphers/aes/aes.o: src/ciphers/aes/aes.c src/ciphers/aes/aes_tab.c
165
src/ciphers/twofish/twofish.o: src/ciphers/twofish/twofish.c src/ciphers/twofish/twofish_tab.c
166
src/hashes/whirl/whirl.o: src/hashes/whirl/whirl.c src/hashes/whirl/whirltab.c
167
src/pk/ecc/ecc.o: src/pk/ecc/ecc.c src/pk/ecc/ecc_sys.c
168
src/pk/dh/dh.o: src/pk/dh/dh.c src/pk/dh/dh_sys.c
169
src/hashes/sha2/sha512.o: src/hashes/sha2/sha512.c src/hashes/sha2/sha384.c
170
src/hashes/sha2/sha256.o: src/hashes/sha2/sha256.c src/hashes/sha2/sha224.c
127
172
#This rule makes the libtomcrypt library.
128
173
library: $(LIBNAME)
176
cd testprof ; CFLAGS="$(CFLAGS)" make
130
178
$(LIBNAME): $(OBJECTS)
131
179
$(AR) $(ARFLAGS) $@ $(OBJECTS)
134
182
#This rule makes the hash program included with libtomcrypt
135
183
hashsum: library $(HASHOBJECTS)
143
191
small: library $(SMALLOBJECTS)
144
192
$(CC) $(SMALLOBJECTS) $(LIBNAME) -o $(SMALL) $(WARN)
146
x86_prof: library $(PROFS)
147
$(CC) $(PROFS) $(LIBNAME) $(EXTRALIBS) -o $(PROF)
149
194
tv_gen: library $(TVS)
150
$(CC) $(TVS) $(LIBNAME) $(EXTRALIBS) -o $(TV)
195
$(CC) $(TVS) $(LIBNAME) -o $(TV)
197
multi: library $(MULTIS)
198
$(CC) $(MULTIS) $(LIBNAME) -o $(MULTI)
200
timing: library $(LIBTEST) $(TIMINGS)
201
$(CC) $(TIMINGS) $(LIBTEST) $(LIBNAME) $(EXTRALIBS) -o $(TIMING)
203
test: library $(LIBTEST) $(TESTS)
204
$(CC) $(TESTS) $(LIBTEST) $(LIBNAME) -o $(TEST)
152
207
#This rule installs the library and the header files. This must be run
153
208
#as root in order to have a high enough permission to write to the correct
154
209
#directories and to set the owner and group to root.
155
210
install: library docs
156
install -d -g root -o root $(DESTDIR)$(LIBPATH)
157
install -d -g root -o root $(DESTDIR)$(INCPATH)
158
install -d -g root -o root $(DESTDIR)$(DATAPATH)
159
install -g root -o root $(LIBNAME) $(DESTDIR)$(LIBPATH)
160
install -g root -o root $(HEADERS) $(DESTDIR)$(INCPATH)
161
install -g root -o root doc/crypt.pdf $(DESTDIR)$(DATAPATH)
164
install -d -g root -o root $(DESTDIR)$(LIBPATH)
165
install -d -g root -o root $(DESTDIR)$(INCPATH)
166
install -g root -o root $(LIBNAME) $(DESTDIR)$(LIBPATH)
167
install -g root -o root $(HEADERS) $(DESTDIR)$(INCPATH)
211
install -d -g $(GROUP) -o $(USER) $(DESTDIR)$(LIBPATH)
212
install -d -g $(GROUP) -o $(USER) $(DESTDIR)$(INCPATH)
213
install -d -g $(GROUP) -o $(USER) $(DESTDIR)$(DATAPATH)
214
install -g $(GROUP) -o $(USER) $(LIBNAME) $(DESTDIR)$(LIBPATH)
215
install -g $(GROUP) -o $(USER) $(HEADERS) $(DESTDIR)$(INCPATH)
216
install -g $(GROUP) -o $(USER) doc/crypt.pdf $(DESTDIR)$(DATAPATH)
218
install_test: $(LIBTEST)
219
install -d -g $(GROUP) -o $(USER) $(DESTDIR)$(LIBPATH)
220
install -d -g $(GROUP) -o $(USER) $(DESTDIR)$(INCPATH)
221
install -g $(GROUP) -o $(USER) $(LIBTEST) $(DESTDIR)$(LIBPATH)
224
CFLAGS="$(CFLAGS) -fprofile-generate" make timing EXTRALIBS=-lgcov
226
rm -f timing `find . -type f | grep [.][ao] | xargs`
227
CFLAGS="$(CFLAGS) -fprofile-use" make timing EXTRALIBS=-lgcov
169
230
#This rule cleans the source tree of all compiled code, not including the pdf
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
236
#build the doxy files (requires Doxygen, tetex and patience)
239
cd doc/doxygen/latex ; make ; mv -f refman.pdf ../../.
240
echo The huge doxygen PDF should be available as doc/refman.pdf
179
242
#This builds the crypt.pdf file. Note that the rm -f *.pdf has been removed
180
243
#from the clean command! This is because most people would like to keep the
181
244
#nice pre-compiled crypt.pdf that comes with libtomcrypt! We only need to
182
245
#delete it if we are rebuilding it.
184
-rm -f doc/crypt.pdf $(LEFTOVERS)
247
rm -f doc/crypt.pdf $(LEFTOVERS)
185
248
echo "hello" > crypt.ind
186
249
latex crypt > /dev/null
187
250
latex crypt > /dev/null
198
261
makeindex crypt.idx
199
262
latex crypt > /dev/null
208
make CFLAGS="$(CFLAGS) -fprofile-generate" EXTRALIBS=-lgcov x86_prof
211
make CFLAGS="$(CFLAGS) -fprofile-use" EXTRALIBS=-lgcov x86_prof
213
264
#zipup the project (take that!)
267
echo Scanning for scratch/dirty files
268
find . -type f | grep -v CVS | xargs -n 1 bash mess.sh
215
271
cd .. ; rm -rf crypt* libtomcrypt-$(VERSION) ; mkdir libtomcrypt-$(VERSION) ; \
216
cp -R ./libtomcrypt/* ./libtomcrypt-$(VERSION)/ ; tar -c libtomcrypt-$(VERSION)/* > crypt-$(VERSION).tar ; \
217
bzip2 -9vv crypt-$(VERSION).tar ; zip -9 -r crypt-$(VERSION).zip libtomcrypt-$(VERSION)/* ; \
218
gpg -b -a crypt-$(VERSION).tar.bz2 ; gpg -b -a crypt-$(VERSION).zip
272
cp -R ./libtomcrypt/* ./libtomcrypt-$(VERSION)/ ; \
273
cd libtomcrypt-$(VERSION) ; rm -rf `find . -type d | grep CVS | xargs` ; cd .. ; \
274
tar -cjvf crypt-$(VERSION).tar.bz2 libtomcrypt-$(VERSION) ; \
275
zip -9r crypt-$(VERSION).zip libtomcrypt-$(VERSION) ; \
276
gpg -b -a crypt-$(VERSION).tar.bz2 ; gpg -b -a crypt-$(VERSION).zip ; \
277
mv -fv crypt* ~ ; rm -rf libtomcrypt-$(VERSION)
280
# $Source: /cvs/libtom/libtomcrypt/makefile,v $
282
# $Date: 2005/06/19 18:03:24 $