• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# MAKEFILE for linux GCC
2#
3# Tom St Denis
4# Modified by Clay Culver
5
6# The version
7VERSION=1.16
8
9VPATH=@srcdir@
10srcdir=@srcdir@
11
12# Compiler and Linker Names
13#CC=gcc
14#LD=ld
15
16# Archiver [makes .a files]
17#AR=ar
18#ARFLAGS=r
19
20# Compilation flags. Note the += does not write over the user's CFLAGS!
21# The rest of the flags come from the parent Dropbear makefile
22CFLAGS += -c -I$(srcdir)/src/headers/ -I$(srcdir)/../
23
24# additional warnings (newer GCC 3.4 and higher)
25ifdef GCC_34
26CFLAGS += -Wsystem-headers -Wdeclaration-after-statement -Wbad-function-cast -Wcast-align -Wstrict-prototypes -Wmissing-prototypes \
27		  -Wmissing-declarations -Wpointer-arith
28endif
29
30ifndef IGNORE_SPEED
31
32# optimize for SPEED
33#CFLAGS += -O3 -funroll-loops
34
35# add -fomit-frame-pointer.  hinders debugging!
36#CFLAGS += -fomit-frame-pointer
37
38# optimize for SIZE
39#CFLAGS += -Os -DLTC_SMALL_CODE
40
41endif
42
43# older GCCs can't handle the "rotate with immediate" ROLc/RORc/etc macros
44# define this to help
45#CFLAGS += -DLTC_NO_ROLC
46
47# compile for DEBUGING (required for ccmalloc checking!!!)
48#CFLAGS += -g3 -DLTC_NO_ASM
49
50#Output filenames for various targets.
51ifndef LIBNAME
52   LIBNAME=libtomcrypt.a
53endif
54ifndef LIBTEST
55   LIBTEST=libtomcrypt_prof.a
56endif
57LIBTEST_S=$(LIBTEST)
58
59HASH=hashsum
60CRYPT=encrypt
61SMALL=small
62PROF=x86_prof
63TV=tv_gen
64MULTI=multi
65TIMING=timing
66TEST=test
67
68#LIBPATH-The directory for libtomcrypt to be installed to.
69#INCPATH-The directory to install the header files for libtomcrypt.
70#DATAPATH-The directory to install the pdf docs.
71ifndef DESTDIR
72   DESTDIR=
73endif
74
75ifndef LIBPATH
76   LIBPATH=/usr/lib
77endif
78ifndef INCPATH
79   INCPATH=/usr/include
80endif
81ifndef DATAPATH
82   DATAPATH=/usr/share/doc/libtomcrypt/pdf
83endif
84
85#Who do we install as?
86ifdef INSTALL_USER
87USER=$(INSTALL_USER)
88else
89USER=root
90endif
91
92ifdef INSTALL_GROUP
93GROUP=$(INSTALL_GROUP)
94else
95GROUP=wheel
96endif
97
98#List of objects to compile.
99#START_INS
100OBJECTS=src/ciphers/aes/aes_enc.o src/ciphers/aes/aes.o src/ciphers/anubis.o src/ciphers/blowfish.o \
101src/ciphers/cast5.o src/ciphers/des.o src/ciphers/kasumi.o src/ciphers/khazad.o src/ciphers/kseed.o \
102src/ciphers/noekeon.o src/ciphers/rc2.o src/ciphers/rc5.o src/ciphers/rc6.o src/ciphers/safer/safer.o \
103src/ciphers/safer/safer_tab.o src/ciphers/safer/saferp.o src/ciphers/skipjack.o \
104src/ciphers/twofish/twofish.o src/ciphers/xtea.o src/encauth/ccm/ccm_memory.o \
105src/encauth/ccm/ccm_test.o src/encauth/eax/eax_addheader.o src/encauth/eax/eax_decrypt.o \
106src/encauth/eax/eax_decrypt_verify_memory.o src/encauth/eax/eax_done.o src/encauth/eax/eax_encrypt.o \
107src/encauth/eax/eax_encrypt_authenticate_memory.o src/encauth/eax/eax_init.o \
108src/encauth/eax/eax_test.o src/encauth/gcm/gcm_add_aad.o src/encauth/gcm/gcm_add_iv.o \
109src/encauth/gcm/gcm_done.o src/encauth/gcm/gcm_gf_mult.o src/encauth/gcm/gcm_init.o \
110src/encauth/gcm/gcm_memory.o src/encauth/gcm/gcm_mult_h.o src/encauth/gcm/gcm_process.o \
111src/encauth/gcm/gcm_reset.o src/encauth/gcm/gcm_test.o src/encauth/ocb/ocb_decrypt.o \
112src/encauth/ocb/ocb_decrypt_verify_memory.o src/encauth/ocb/ocb_done_decrypt.o \
113src/encauth/ocb/ocb_done_encrypt.o src/encauth/ocb/ocb_encrypt.o \
114src/encauth/ocb/ocb_encrypt_authenticate_memory.o src/encauth/ocb/ocb_init.o src/encauth/ocb/ocb_ntz.o \
115src/encauth/ocb/ocb_shift_xor.o src/encauth/ocb/ocb_test.o src/encauth/ocb/s_ocb_done.o \
116src/hashes/chc/chc.o src/hashes/helper/hash_file.o src/hashes/helper/hash_filehandle.o \
117src/hashes/helper/hash_memory.o src/hashes/helper/hash_memory_multi.o src/hashes/md2.o src/hashes/md4.o \
118src/hashes/md5.o src/hashes/rmd128.o src/hashes/rmd160.o src/hashes/rmd256.o src/hashes/rmd320.o \
119src/hashes/sha1.o src/hashes/sha2/sha256.o src/hashes/sha2/sha512.o src/hashes/tiger.o \
120src/hashes/whirl/whirl.o src/mac/f9/f9_done.o src/mac/f9/f9_file.o src/mac/f9/f9_init.o \
121src/mac/f9/f9_memory.o src/mac/f9/f9_memory_multi.o src/mac/f9/f9_process.o src/mac/f9/f9_test.o \
122src/mac/hmac/hmac_done.o src/mac/hmac/hmac_file.o src/mac/hmac/hmac_init.o src/mac/hmac/hmac_memory.o \
123src/mac/hmac/hmac_memory_multi.o src/mac/hmac/hmac_process.o src/mac/hmac/hmac_test.o \
124src/mac/omac/omac_done.o src/mac/omac/omac_file.o src/mac/omac/omac_init.o src/mac/omac/omac_memory.o \
125src/mac/omac/omac_memory_multi.o src/mac/omac/omac_process.o src/mac/omac/omac_test.o \
126src/mac/pelican/pelican.o src/mac/pelican/pelican_memory.o src/mac/pelican/pelican_test.o \
127src/mac/pmac/pmac_done.o src/mac/pmac/pmac_file.o src/mac/pmac/pmac_init.o src/mac/pmac/pmac_memory.o \
128src/mac/pmac/pmac_memory_multi.o src/mac/pmac/pmac_ntz.o src/mac/pmac/pmac_process.o \
129src/mac/pmac/pmac_shift_xor.o src/mac/pmac/pmac_test.o src/mac/xcbc/xcbc_done.o \
130src/mac/xcbc/xcbc_file.o src/mac/xcbc/xcbc_init.o src/mac/xcbc/xcbc_memory.o \
131src/mac/xcbc/xcbc_memory_multi.o src/mac/xcbc/xcbc_process.o src/mac/xcbc/xcbc_test.o \
132src/math/fp/ltc_ecc_fp_mulmod.o src/math/gmp_desc.o src/math/ltm_desc.o src/math/multi.o \
133src/math/rand_prime.o src/math/tfm_desc.o src/misc/base64/base64_decode.o \
134src/misc/base64/base64_encode.o src/misc/burn_stack.o src/misc/crypt/crypt.o \
135src/misc/crypt/crypt_argchk.o src/misc/crypt/crypt_cipher_descriptor.o \
136src/misc/crypt/crypt_cipher_is_valid.o src/misc/crypt/crypt_find_cipher.o \
137src/misc/crypt/crypt_find_cipher_any.o src/misc/crypt/crypt_find_cipher_id.o \
138src/misc/crypt/crypt_find_hash.o src/misc/crypt/crypt_find_hash_any.o \
139src/misc/crypt/crypt_find_hash_id.o src/misc/crypt/crypt_find_hash_oid.o \
140src/misc/crypt/crypt_find_prng.o src/misc/crypt/crypt_fsa.o src/misc/crypt/crypt_hash_descriptor.o \
141src/misc/crypt/crypt_hash_is_valid.o src/misc/crypt/crypt_ltc_mp_descriptor.o \
142src/misc/crypt/crypt_prng_descriptor.o src/misc/crypt/crypt_prng_is_valid.o \
143src/misc/crypt/crypt_register_cipher.o src/misc/crypt/crypt_register_hash.o \
144src/misc/crypt/crypt_register_prng.o src/misc/crypt/crypt_unregister_cipher.o \
145src/misc/crypt/crypt_unregister_hash.o src/misc/crypt/crypt_unregister_prng.o \
146src/misc/error_to_string.o src/misc/pkcs5/pkcs_5_1.o src/misc/pkcs5/pkcs_5_2.o src/misc/zeromem.o \
147src/modes/cbc/cbc_decrypt.o src/modes/cbc/cbc_done.o src/modes/cbc/cbc_encrypt.o \
148src/modes/cbc/cbc_getiv.o src/modes/cbc/cbc_setiv.o src/modes/cbc/cbc_start.o \
149src/modes/cfb/cfb_decrypt.o src/modes/cfb/cfb_done.o src/modes/cfb/cfb_encrypt.o \
150src/modes/cfb/cfb_getiv.o src/modes/cfb/cfb_setiv.o src/modes/cfb/cfb_start.o \
151src/modes/ctr/ctr_decrypt.o src/modes/ctr/ctr_done.o src/modes/ctr/ctr_encrypt.o \
152src/modes/ctr/ctr_getiv.o src/modes/ctr/ctr_setiv.o src/modes/ctr/ctr_start.o src/modes/ctr/ctr_test.o \
153src/modes/ecb/ecb_decrypt.o src/modes/ecb/ecb_done.o src/modes/ecb/ecb_encrypt.o \
154src/modes/ecb/ecb_start.o src/modes/f8/f8_decrypt.o src/modes/f8/f8_done.o src/modes/f8/f8_encrypt.o \
155src/modes/f8/f8_getiv.o src/modes/f8/f8_setiv.o src/modes/f8/f8_start.o src/modes/f8/f8_test_mode.o \
156src/modes/lrw/lrw_decrypt.o src/modes/lrw/lrw_done.o src/modes/lrw/lrw_encrypt.o \
157src/modes/lrw/lrw_getiv.o src/modes/lrw/lrw_process.o src/modes/lrw/lrw_setiv.o \
158src/modes/lrw/lrw_start.o src/modes/lrw/lrw_test.o src/modes/ofb/ofb_decrypt.o src/modes/ofb/ofb_done.o \
159src/modes/ofb/ofb_encrypt.o src/modes/ofb/ofb_getiv.o src/modes/ofb/ofb_setiv.o \
160src/modes/ofb/ofb_start.o
161
162HEADERS=src/headers/tomcrypt_cfg.h src/headers/tomcrypt_mac.h src/headers/tomcrypt_macros.h \
163src/headers/tomcrypt_custom.h src/headers/tomcrypt_argchk.h src/headers/tomcrypt_cipher.h \
164src/headers/tomcrypt_pk.h src/headers/tomcrypt_hash.h src/headers/tomcrypt_math.h \
165src/headers/tomcrypt_misc.h src/headers/tomcrypt.h src/headers/tomcrypt_pkcs.h \
166src/headers/tomcrypt_prng.h testprof/tomcrypt_test.h
167
168#END_INS
169
170TESTOBJECTS=demos/test.o
171HASHOBJECTS=demos/hashsum.o
172CRYPTOBJECTS=demos/encrypt.o
173SMALLOBJECTS=demos/small.o
174TVS=demos/tv_gen.o
175MULTIS=demos/multi.o
176TIMINGS=demos/timing.o
177TESTS=demos/test.o
178
179#Files left over from making the crypt.pdf.
180LEFTOVERS=*.dvi *.log *.aux *.toc *.idx *.ilg *.ind *.out
181
182#Compressed filenames
183COMPRESSED=crypt-$(VERSION).tar.bz2 crypt-$(VERSION).zip
184
185#The default rule for make builds the libtomcrypt library.
186default:library
187
188#ciphers come in two flavours... enc+dec and enc
189src/ciphers/aes/aes_enc.o: src/ciphers/aes/aes.c src/ciphers/aes/aes_tab.c
190	$(CC) $(CFLAGS) -DENCRYPT_ONLY -c $< -o src/ciphers/aes/aes_enc.o
191
192#These are the rules to make certain object files.
193src/ciphers/aes/aes.o: src/ciphers/aes/aes.c src/ciphers/aes/aes_tab.c
194src/ciphers/twofish/twofish.o: src/ciphers/twofish/twofish.c src/ciphers/twofish/twofish_tab.c
195src/hashes/whirl/whirl.o: src/hashes/whirl/whirl.c src/hashes/whirl/whirltab.c
196src/hashes/sha2/sha512.o: src/hashes/sha2/sha512.c src/hashes/sha2/sha384.c
197src/hashes/sha2/sha256.o: src/hashes/sha2/sha256.c src/hashes/sha2/sha224.c
198
199#This rule makes the libtomcrypt library.
200library: $(LIBNAME)
201
202testprof/$(LIBTEST):
203	cd testprof ; CFLAGS="$(CFLAGS)" LIBTEST_S=$(LIBTEST_S) $(MAKE)
204
205$(LIBNAME): $(OBJECTS)
206	$(AR) $(ARFLAGS) $@ $(OBJECTS)
207	$(RANLIB) $@
208
209#This rule makes the hash program included with libtomcrypt
210hashsum: library $(HASHOBJECTS)
211	$(CC) $(HASHOBJECTS) $(LIBNAME) $(EXTRALIBS) -o $(HASH) $(WARN)
212
213#makes the crypt program
214crypt: library $(CRYPTOBJECTS)
215	$(CC) $(CRYPTOBJECTS) $(LIBNAME) $(EXTRALIBS) -o $(CRYPT) $(WARN)
216
217#makes the small program
218small: library $(SMALLOBJECTS)
219	$(CC) $(SMALLOBJECTS) $(LIBNAME) $(EXTRALIBS) -o $(SMALL) $(WARN)
220
221tv_gen: library $(TVS)
222	$(CC) $(LDFLAGS) $(TVS) $(LIBNAME) $(EXTRALIBS) -o $(TV)
223
224multi: library $(MULTIS)
225	$(CC) $(MULTIS) $(LIBNAME) $(EXTRALIBS) -o $(MULTI)
226
227timing: library testprof/$(LIBTEST) $(TIMINGS)
228	$(CC) $(LDFLAGS) $(TIMINGS) testprof/$(LIBTEST) $(LIBNAME) $(EXTRALIBS) -o $(TIMING)
229
230test: library testprof/$(LIBTEST) $(TESTS)
231	$(CC) $(LDFLAGS) $(TESTS) testprof/$(LIBTEST) $(LIBNAME) $(EXTRALIBS) -o $(TEST)
232
233#This rule installs the library and the header files. This must be run
234#as root in order to have a high enough permission to write to the correct
235#directories and to set the owner and group to root.
236ifndef NODOCS
237install: library docs
238else
239install: library
240endif
241	install -d -g $(GROUP) -o $(USER) $(DESTDIR)$(LIBPATH)
242	install -d -g $(GROUP) -o $(USER) $(DESTDIR)$(INCPATH)
243	install -d -g $(GROUP) -o $(USER) $(DESTDIR)$(DATAPATH)
244	install -g $(GROUP) -o $(USER) $(LIBNAME) $(DESTDIR)$(LIBPATH)
245	install -g $(GROUP) -o $(USER) $(HEADERS) $(DESTDIR)$(INCPATH)
246ifndef NODOCS
247	install -g $(GROUP) -o $(USER) doc/crypt.pdf $(DESTDIR)$(DATAPATH)
248endif
249
250install_test: testprof/$(LIBTEST)
251	install -d -g $(GROUP) -o $(USER) $(DESTDIR)$(LIBPATH)
252	install -d -g $(GROUP) -o $(USER) $(DESTDIR)$(INCPATH)
253	install -g $(GROUP) -o $(USER) testprof/$(LIBTEST) $(DESTDIR)$(LIBPATH)
254
255profile:
256	CFLAGS="$(CFLAGS) -fprofile-generate" $(MAKE) timing EXTRALIBS="$(EXTRALIBS) -lgcov"
257	./timing
258	rm -f timing `find . -type f | grep [.][ao] | xargs`
259	CFLAGS="$(CFLAGS) -fprofile-use" $(MAKE) timing EXTRALIBS="$(EXTRALIBS) -lgcov"
260
261
262#This rule cleans the source tree of all compiled code, not including the pdf
263#documentation.
264clean:
265	-rm -f $(OBJECTS)
266	-rm -f libtomcrypt.a
267
268#build the doxy files (requires Doxygen, tetex and patience)
269doxy:
270	doxygen
271	cd doc/doxygen/latex ; ${MAKE} ; mv -f refman.pdf ../../.
272	echo The huge doxygen PDF should be available as doc/refman.pdf
273
274#This builds the crypt.pdf file. Note that the rm -f *.pdf has been removed
275#from the clean command! This is because most people would like to keep the
276#nice pre-compiled crypt.pdf that comes with libtomcrypt! We only need to
277#delete it if we are rebuilding it.
278docs: crypt.tex
279	rm -f doc/crypt.pdf $(LEFTOVERS)
280	echo "hello" > crypt.ind
281	latex crypt > /dev/null
282	latex crypt > /dev/null
283	makeindex crypt.idx > /dev/null
284	perl fixupind.pl
285	latex crypt > /dev/null
286	dvipdf crypt
287	mv -ivf crypt.pdf doc/crypt.pdf
288	rm -f $(LEFTOVERS)
289
290docdvi: crypt.tex
291	echo hello > crypt.ind
292	latex crypt > /dev/null
293	latex crypt > /dev/null
294	makeindex crypt.idx
295	perl fixupind.pl
296	latex crypt > /dev/null
297	latex crypt > /dev/null
298
299#zipup the project (take that!)
300no_oops: clean
301	cd .. ; cvs commit
302	echo Scanning for scratch/dirty files
303	find . -type f | grep -v CVS | xargs -n 1 bash mess.sh
304
305zipup: no_oops docs
306	cd .. ; rm -rf crypt* libtomcrypt-$(VERSION) ; mkdir libtomcrypt-$(VERSION) ; \
307	cp -R ./libtomcrypt/* ./libtomcrypt-$(VERSION)/ ; \
308	cd libtomcrypt-$(VERSION) ; rm -rf `find . -type d | grep CVS | xargs` ; cd .. ; \
309	tar -cjvf crypt-$(VERSION).tar.bz2 libtomcrypt-$(VERSION) ; \
310	zip -9r crypt-$(VERSION).zip libtomcrypt-$(VERSION) ; \
311	gpg -b -a crypt-$(VERSION).tar.bz2 ; gpg -b -a crypt-$(VERSION).zip ; \
312	mv -fv crypt* ~ ; rm -rf libtomcrypt-$(VERSION)
313
314
315# $Source: /cvs/libtom/libtomcrypt/makefile,v $
316# $Revision: 1.145 $
317# $Date: 2006/12/02 19:23:21 $
318