1#
2# Include makefile used by makefile + makefile.shared
3#  (GNU $(MAKE) only)
4
5# The version - BEWARE: VERSION, VERSION_PC and VERSION_LT are updated via ./updatemakes.sh
6VERSION=1.18.2
7VERSION_PC=1.18.2
8# http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
9VERSION_LT=1:1
10
11# Compiler and Linker Names
12ifndef CROSS_COMPILE
13  CROSS_COMPILE:=
14endif
15
16# We only need to go through this dance of determining the right compiler if we're using
17# cross compilation, otherwise $(CC) is fine as-is.
18ifneq (,$(CROSS_COMPILE))
19ifeq ($(origin CC),default)
20CSTR := "\#ifdef __clang__\nCLANG\n\#endif\n"
21ifeq ($(PLATFORM),FreeBSD)
22  # XXX: FreeBSD needs extra escaping for some reason
23  CSTR := $$$(CSTR)
24endif
25ifneq (,$(shell echo $(CSTR) | $(CC) -E - | grep CLANG))
26  CC := $(CROSS_COMPILE)clang
27else
28  CC := $(CROSS_COMPILE)cc
29endif # Clang
30endif # cc is Make's default
31endif # CROSS_COMPILE non-empty
32
33LD:=$(CROSS_COMPILE)ld
34AR:=$(CROSS_COMPILE)ar
35
36# Archiver [makes .a files]
37#AR=ar
38ARFLAGS:=r
39
40ifndef MAKE
41# BSDs refer to GNU Make as gmake
42ifneq (,$(findstring $(PLATFORM),FreeBSD OpenBSD DragonFly NetBSD))
43  MAKE=gmake
44else
45  MAKE=make
46endif
47endif
48
49ifndef INSTALL_CMD
50$(error your makefile must define INSTALL_CMD)
51endif
52ifndef UNINSTALL_CMD
53$(error your makefile must define UNINSTALL_CMD)
54endif
55
56ifndef EXTRALIBS
57ifneq ($(shell echo $(CFLAGS) | grep USE_LTM),)
58EXTRALIBS=$(shell PKG_CONFIG_PATH=$(LIBPATH)/pkgconfig pkg-config libtommath --libs)
59else
60ifneq ($(shell echo $(CFLAGS) | grep USE_TFM),)
61EXTRALIBS=$(shell PKG_CONFIG_PATH=$(LIBPATH)/pkgconfig pkg-config tomsfastmath --libs)
62endif
63endif
64endif
65
66need-help := $(filter help,$(MAKECMDGOALS))
67define print-help
68$(if $(need-help),$(info $1 -- $2))
69endef
70
71#
72# Compilation flags. Note the += does not write over the user's CFLAGS!
73#
74# Also note that we're extending the environments' CFLAGS.
75# If you think that our CFLAGS are not nice you can easily override them
76# by giving them as a parameter to make:
77#  $(MAKE) CFLAGS="-I./src/headers/ -DLTC_SOURCE ..." ...
78#
79LTC_CFLAGS += -I./src/headers/ -Wall -Wsign-compare -Wshadow -DLTC_SOURCE
80
81ifdef OLD_GCC
82LTC_CFLAGS += -W
83# older GCCs can't handle the "rotate with immediate" ROLc/RORc/etc macros
84# define this to help
85LTC_CFLAGS += -DLTC_NO_ROLC
86else
87LTC_CFLAGS += -Wextra
88# additional warnings
89LTC_CFLAGS += -Wsystem-headers -Wbad-function-cast -Wcast-align
90LTC_CFLAGS += -Wstrict-prototypes -Wpointer-arith
91LTC_CFLAGS += -Wdeclaration-after-statement
92LTC_CFLAGS += -Wwrite-strings
93endif
94
95ifdef LTC_DEBUG
96$(info Debug build)
97# compile for DEBUGGING (required for ccmalloc checking!!!)
98LTC_CFLAGS += -g3 -DLTC_NO_ASM
99ifneq (,$(strip $(LTC_DEBUG)))
100LTC_CFLAGS += -DLTC_TEST_DBG=$(LTC_DEBUG)
101else
102LTC_CFLAGS += -DLTC_TEST_DBG
103endif
104else
105
106ifdef LTC_SMALL
107# optimize for SIZE
108LTC_CFLAGS += -Os -DLTC_SMALL_CODE
109else
110
111ifndef IGNORE_SPEED
112# optimize for SPEED
113LTC_CFLAGS += -O3 -funroll-loops
114
115# add -fomit-frame-pointer.  hinders debugging!
116LTC_CFLAGS += -fomit-frame-pointer
117endif
118
119endif # COMPILE_SMALL
120endif # COMPILE_DEBUG
121
122
123ifneq ($(findstring clang,$(CC)),)
124LTC_CFLAGS += -Wno-typedef-redefinition -Wno-tautological-compare -Wno-builtin-requires-header -Wno-missing-field-initializers
125endif
126ifneq ($(findstring mingw,$(CC)),)
127LTC_CFLAGS += -Wno-shadow -Wno-attributes
128endif
129ifeq ($(PLATFORM), Darwin)
130LTC_CFLAGS += -Wno-nullability-completeness
131endif
132
133
134GIT_VERSION := $(shell { [ -e .git ] && which git 2>/dev/null 1>&2 ; } && { printf git- ; git describe --tags --always --dirty ; } || echo $(VERSION))
135ifneq ($(GIT_VERSION),)
136LTC_CFLAGS += -DGIT_VERSION=\"$(GIT_VERSION)\"
137endif
138
139LTC_CFLAGS := $(LTC_CFLAGS) $(CFLAGS)
140
141ifneq ($(findstring -DLTC_PTHREAD,$(LTC_CFLAGS)),)
142LTC_LDFLAGS += -pthread
143endif
144
145LTC_LDFLAGS := $(LTC_LDFLAGS) $(LDFLAGS)
146
147#List of demo objects
148DSOURCES = $(wildcard demos/*.c)
149DOBJECTS = $(DSOURCES:.c=.o)
150
151#List of tests headers
152THEADERS = $(wildcard tests/*.h)
153
154TEST=test
155
156# Demos that are even somehow useful and could be installed as a system-tool
157USEFUL_DEMOS   = hashsum
158
159# Demos that are usable but only rarely $(MAKE) sense to be installed
160USEABLE_DEMOS  = ltcrypt sizes constants
161
162# Demos that are used for testing or measuring
163TEST_DEMOS     = small tv_gen
164
165# Demos that are in one config broken
166#  openssl-enc - can't be build with LTC_EASY
167#  timing      - not really broken, but older cc builds spit warnings
168BROKEN_DEMOS   = openssl-enc timing
169
170# Combine demos in groups
171UNBROKEN_DEMOS = $(TEST_DEMOS) $(USEABLE_DEMOS) $(USEFUL_DEMOS)
172DEMOS          = $(UNBROKEN_DEMOS) $(BROKEN_DEMOS)
173
174#LIBPATH  The directory for libtomcrypt to be installed to.
175#INCPATH  The directory to install the header files for libtomcrypt.
176#DATAPATH The directory to install the pdf docs.
177#BINPATH  The directory to install the binaries provided.
178DESTDIR  ?=
179PREFIX   ?= /usr/local
180LIBPATH  ?= $(PREFIX)/lib
181INCPATH  ?= $(PREFIX)/include
182DATAPATH ?= $(PREFIX)/share/doc/libtomcrypt/pdf
183BINPATH  ?= $(PREFIX)/bin
184
185#Who do we install as?
186ifdef INSTALL_USER
187USER=$(INSTALL_USER)
188else
189USER=root
190endif
191
192ifdef INSTALL_GROUP
193GROUP=$(INSTALL_GROUP)
194else
195GROUP=wheel
196endif
197
198
199#The first rule is also the default rule and builds the libtomcrypt library.
200library: $(call print-help,library,Builds the library) $(LIBNAME)
201
202
203# List of objects to compile (all goes to libtomcrypt.a)
204OBJECTS=src/ciphers/aes/aes.o src/ciphers/aes/aes_enc.o src/ciphers/anubis.o src/ciphers/blowfish.o \
205src/ciphers/camellia.o src/ciphers/cast5.o src/ciphers/des.o src/ciphers/kasumi.o src/ciphers/khazad.o \
206src/ciphers/kseed.o src/ciphers/multi2.o src/ciphers/noekeon.o src/ciphers/rc2.o src/ciphers/rc5.o \
207src/ciphers/rc6.o src/ciphers/safer/safer.o src/ciphers/safer/saferp.o src/ciphers/skipjack.o \
208src/ciphers/twofish/twofish.o src/ciphers/xtea.o src/encauth/ccm/ccm_add_aad.o \
209src/encauth/ccm/ccm_add_nonce.o src/encauth/ccm/ccm_done.o src/encauth/ccm/ccm_init.o \
210src/encauth/ccm/ccm_memory.o src/encauth/ccm/ccm_process.o src/encauth/ccm/ccm_reset.o \
211src/encauth/ccm/ccm_test.o src/encauth/chachapoly/chacha20poly1305_add_aad.o \
212src/encauth/chachapoly/chacha20poly1305_decrypt.o src/encauth/chachapoly/chacha20poly1305_done.o \
213src/encauth/chachapoly/chacha20poly1305_encrypt.o src/encauth/chachapoly/chacha20poly1305_init.o \
214src/encauth/chachapoly/chacha20poly1305_memory.o src/encauth/chachapoly/chacha20poly1305_setiv.o \
215src/encauth/chachapoly/chacha20poly1305_setiv_rfc7905.o \
216src/encauth/chachapoly/chacha20poly1305_test.o src/encauth/eax/eax_addheader.o \
217src/encauth/eax/eax_decrypt.o src/encauth/eax/eax_decrypt_verify_memory.o src/encauth/eax/eax_done.o \
218src/encauth/eax/eax_encrypt.o src/encauth/eax/eax_encrypt_authenticate_memory.o \
219src/encauth/eax/eax_init.o src/encauth/eax/eax_test.o src/encauth/gcm/gcm_add_aad.o \
220src/encauth/gcm/gcm_add_iv.o src/encauth/gcm/gcm_done.o src/encauth/gcm/gcm_gf_mult.o \
221src/encauth/gcm/gcm_init.o src/encauth/gcm/gcm_memory.o src/encauth/gcm/gcm_mult_h.o \
222src/encauth/gcm/gcm_process.o src/encauth/gcm/gcm_reset.o src/encauth/gcm/gcm_test.o \
223src/encauth/ocb/ocb_decrypt.o src/encauth/ocb/ocb_decrypt_verify_memory.o \
224src/encauth/ocb/ocb_done_decrypt.o src/encauth/ocb/ocb_done_encrypt.o src/encauth/ocb/ocb_encrypt.o \
225src/encauth/ocb/ocb_encrypt_authenticate_memory.o src/encauth/ocb/ocb_init.o src/encauth/ocb/ocb_ntz.o \
226src/encauth/ocb/ocb_shift_xor.o src/encauth/ocb/ocb_test.o src/encauth/ocb/s_ocb_done.o \
227src/encauth/ocb3/ocb3_add_aad.o src/encauth/ocb3/ocb3_decrypt.o src/encauth/ocb3/ocb3_decrypt_last.o \
228src/encauth/ocb3/ocb3_decrypt_verify_memory.o src/encauth/ocb3/ocb3_done.o \
229src/encauth/ocb3/ocb3_encrypt.o src/encauth/ocb3/ocb3_encrypt_authenticate_memory.o \
230src/encauth/ocb3/ocb3_encrypt_last.o src/encauth/ocb3/ocb3_init.o src/encauth/ocb3/ocb3_int_ntz.o \
231src/encauth/ocb3/ocb3_int_xor_blocks.o src/encauth/ocb3/ocb3_test.o src/hashes/blake2b.o \
232src/hashes/blake2s.o src/hashes/chc/chc.o src/hashes/helper/hash_file.o \
233src/hashes/helper/hash_filehandle.o src/hashes/helper/hash_memory.o \
234src/hashes/helper/hash_memory_multi.o src/hashes/md2.o src/hashes/md4.o src/hashes/md5.o \
235src/hashes/rmd128.o src/hashes/rmd160.o src/hashes/rmd256.o src/hashes/rmd320.o src/hashes/sha1.o \
236src/hashes/sha2/sha224.o src/hashes/sha2/sha256.o src/hashes/sha2/sha384.o src/hashes/sha2/sha512.o \
237src/hashes/sha2/sha512_224.o src/hashes/sha2/sha512_256.o src/hashes/sha3.o src/hashes/sha3_test.o \
238src/hashes/tiger.o src/hashes/whirl/whirl.o src/mac/blake2/blake2bmac.o \
239src/mac/blake2/blake2bmac_file.o src/mac/blake2/blake2bmac_memory.o \
240src/mac/blake2/blake2bmac_memory_multi.o src/mac/blake2/blake2bmac_test.o src/mac/blake2/blake2smac.o \
241src/mac/blake2/blake2smac_file.o src/mac/blake2/blake2smac_memory.o \
242src/mac/blake2/blake2smac_memory_multi.o src/mac/blake2/blake2smac_test.o src/mac/f9/f9_done.o \
243src/mac/f9/f9_file.o src/mac/f9/f9_init.o src/mac/f9/f9_memory.o src/mac/f9/f9_memory_multi.o \
244src/mac/f9/f9_process.o src/mac/f9/f9_test.o src/mac/hmac/hmac_done.o src/mac/hmac/hmac_file.o \
245src/mac/hmac/hmac_init.o src/mac/hmac/hmac_memory.o src/mac/hmac/hmac_memory_multi.o \
246src/mac/hmac/hmac_process.o src/mac/hmac/hmac_test.o src/mac/omac/omac_done.o src/mac/omac/omac_file.o \
247src/mac/omac/omac_init.o src/mac/omac/omac_memory.o src/mac/omac/omac_memory_multi.o \
248src/mac/omac/omac_process.o src/mac/omac/omac_test.o src/mac/pelican/pelican.o \
249src/mac/pelican/pelican_memory.o src/mac/pelican/pelican_test.o src/mac/pmac/pmac_done.o \
250src/mac/pmac/pmac_file.o src/mac/pmac/pmac_init.o src/mac/pmac/pmac_memory.o \
251src/mac/pmac/pmac_memory_multi.o src/mac/pmac/pmac_ntz.o src/mac/pmac/pmac_process.o \
252src/mac/pmac/pmac_shift_xor.o src/mac/pmac/pmac_test.o src/mac/poly1305/poly1305.o \
253src/mac/poly1305/poly1305_file.o src/mac/poly1305/poly1305_memory.o \
254src/mac/poly1305/poly1305_memory_multi.o src/mac/poly1305/poly1305_test.o src/mac/xcbc/xcbc_done.o \
255src/mac/xcbc/xcbc_file.o src/mac/xcbc/xcbc_init.o src/mac/xcbc/xcbc_memory.o \
256src/mac/xcbc/xcbc_memory_multi.o src/mac/xcbc/xcbc_process.o src/mac/xcbc/xcbc_test.o \
257src/math/fp/ltc_ecc_fp_mulmod.o src/math/gmp_desc.o src/math/ltm_desc.o src/math/multi.o \
258src/math/radix_to_bin.o src/math/rand_bn.o src/math/rand_prime.o src/math/tfm_desc.o src/misc/adler32.o \
259src/misc/base64/base64_decode.o src/misc/base64/base64_encode.o src/misc/burn_stack.o \
260src/misc/compare_testvector.o src/misc/crc32.o src/misc/crypt/crypt.o src/misc/crypt/crypt_argchk.o \
261src/misc/crypt/crypt_cipher_descriptor.o src/misc/crypt/crypt_cipher_is_valid.o \
262src/misc/crypt/crypt_constants.o src/misc/crypt/crypt_find_cipher.o \
263src/misc/crypt/crypt_find_cipher_any.o src/misc/crypt/crypt_find_cipher_id.o \
264src/misc/crypt/crypt_find_hash.o src/misc/crypt/crypt_find_hash_any.o \
265src/misc/crypt/crypt_find_hash_id.o src/misc/crypt/crypt_find_hash_oid.o \
266src/misc/crypt/crypt_find_prng.o src/misc/crypt/crypt_fsa.o src/misc/crypt/crypt_hash_descriptor.o \
267src/misc/crypt/crypt_hash_is_valid.o src/misc/crypt/crypt_inits.o \
268src/misc/crypt/crypt_ltc_mp_descriptor.o src/misc/crypt/crypt_prng_descriptor.o \
269src/misc/crypt/crypt_prng_is_valid.o src/misc/crypt/crypt_prng_rng_descriptor.o \
270src/misc/crypt/crypt_register_all_ciphers.o src/misc/crypt/crypt_register_all_hashes.o \
271src/misc/crypt/crypt_register_all_prngs.o src/misc/crypt/crypt_register_cipher.o \
272src/misc/crypt/crypt_register_hash.o src/misc/crypt/crypt_register_prng.o src/misc/crypt/crypt_sizes.o \
273src/misc/crypt/crypt_unregister_cipher.o src/misc/crypt/crypt_unregister_hash.o \
274src/misc/crypt/crypt_unregister_prng.o src/misc/error_to_string.o src/misc/hkdf/hkdf.o \
275src/misc/hkdf/hkdf_test.o src/misc/mem_neq.o src/misc/pk_get_oid.o src/misc/pkcs5/pkcs_5_1.o \
276src/misc/pkcs5/pkcs_5_2.o src/misc/pkcs5/pkcs_5_test.o src/misc/zeromem.o src/modes/cbc/cbc_decrypt.o \
277src/modes/cbc/cbc_done.o src/modes/cbc/cbc_encrypt.o src/modes/cbc/cbc_getiv.o \
278src/modes/cbc/cbc_setiv.o src/modes/cbc/cbc_start.o src/modes/cfb/cfb_decrypt.o \
279src/modes/cfb/cfb_done.o src/modes/cfb/cfb_encrypt.o src/modes/cfb/cfb_getiv.o \
280src/modes/cfb/cfb_setiv.o src/modes/cfb/cfb_start.o src/modes/ctr/ctr_decrypt.o \
281src/modes/ctr/ctr_done.o src/modes/ctr/ctr_encrypt.o src/modes/ctr/ctr_getiv.o \
282src/modes/ctr/ctr_setiv.o src/modes/ctr/ctr_start.o src/modes/ctr/ctr_test.o \
283src/modes/ecb/ecb_decrypt.o src/modes/ecb/ecb_done.o src/modes/ecb/ecb_encrypt.o \
284src/modes/ecb/ecb_start.o src/modes/f8/f8_decrypt.o src/modes/f8/f8_done.o src/modes/f8/f8_encrypt.o \
285src/modes/f8/f8_getiv.o src/modes/f8/f8_setiv.o src/modes/f8/f8_start.o src/modes/f8/f8_test_mode.o \
286src/modes/lrw/lrw_decrypt.o src/modes/lrw/lrw_done.o src/modes/lrw/lrw_encrypt.o \
287src/modes/lrw/lrw_getiv.o src/modes/lrw/lrw_process.o src/modes/lrw/lrw_setiv.o \
288src/modes/lrw/lrw_start.o src/modes/lrw/lrw_test.o src/modes/ofb/ofb_decrypt.o src/modes/ofb/ofb_done.o \
289src/modes/ofb/ofb_encrypt.o src/modes/ofb/ofb_getiv.o src/modes/ofb/ofb_setiv.o \
290src/modes/ofb/ofb_start.o src/modes/xts/xts_decrypt.o src/modes/xts/xts_done.o \
291src/modes/xts/xts_encrypt.o src/modes/xts/xts_init.o src/modes/xts/xts_mult_x.o \
292src/modes/xts/xts_test.o src/pk/asn1/der/bit/der_decode_bit_string.o \
293src/pk/asn1/der/bit/der_decode_raw_bit_string.o src/pk/asn1/der/bit/der_encode_bit_string.o \
294src/pk/asn1/der/bit/der_encode_raw_bit_string.o src/pk/asn1/der/bit/der_length_bit_string.o \
295src/pk/asn1/der/boolean/der_decode_boolean.o src/pk/asn1/der/boolean/der_encode_boolean.o \
296src/pk/asn1/der/boolean/der_length_boolean.o src/pk/asn1/der/choice/der_decode_choice.o \
297src/pk/asn1/der/generalizedtime/der_decode_generalizedtime.o \
298src/pk/asn1/der/generalizedtime/der_encode_generalizedtime.o \
299src/pk/asn1/der/generalizedtime/der_length_generalizedtime.o \
300src/pk/asn1/der/ia5/der_decode_ia5_string.o src/pk/asn1/der/ia5/der_encode_ia5_string.o \
301src/pk/asn1/der/ia5/der_length_ia5_string.o src/pk/asn1/der/integer/der_decode_integer.o \
302src/pk/asn1/der/integer/der_encode_integer.o src/pk/asn1/der/integer/der_length_integer.o \
303src/pk/asn1/der/object_identifier/der_decode_object_identifier.o \
304src/pk/asn1/der/object_identifier/der_encode_object_identifier.o \
305src/pk/asn1/der/object_identifier/der_length_object_identifier.o \
306src/pk/asn1/der/octet/der_decode_octet_string.o src/pk/asn1/der/octet/der_encode_octet_string.o \
307src/pk/asn1/der/octet/der_length_octet_string.o \
308src/pk/asn1/der/printable_string/der_decode_printable_string.o \
309src/pk/asn1/der/printable_string/der_encode_printable_string.o \
310src/pk/asn1/der/printable_string/der_length_printable_string.o \
311src/pk/asn1/der/sequence/der_decode_sequence_ex.o \
312src/pk/asn1/der/sequence/der_decode_sequence_flexi.o \
313src/pk/asn1/der/sequence/der_decode_sequence_multi.o \
314src/pk/asn1/der/sequence/der_decode_subject_public_key_info.o \
315src/pk/asn1/der/sequence/der_encode_sequence_ex.o \
316src/pk/asn1/der/sequence/der_encode_sequence_multi.o \
317src/pk/asn1/der/sequence/der_encode_subject_public_key_info.o \
318src/pk/asn1/der/sequence/der_length_sequence.o src/pk/asn1/der/sequence/der_sequence_free.o \
319src/pk/asn1/der/sequence/der_sequence_shrink.o src/pk/asn1/der/set/der_encode_set.o \
320src/pk/asn1/der/set/der_encode_setof.o src/pk/asn1/der/short_integer/der_decode_short_integer.o \
321src/pk/asn1/der/short_integer/der_encode_short_integer.o \
322src/pk/asn1/der/short_integer/der_length_short_integer.o \
323src/pk/asn1/der/teletex_string/der_decode_teletex_string.o \
324src/pk/asn1/der/teletex_string/der_length_teletex_string.o \
325src/pk/asn1/der/utctime/der_decode_utctime.o src/pk/asn1/der/utctime/der_encode_utctime.o \
326src/pk/asn1/der/utctime/der_length_utctime.o src/pk/asn1/der/utf8/der_decode_utf8_string.o \
327src/pk/asn1/der/utf8/der_encode_utf8_string.o src/pk/asn1/der/utf8/der_length_utf8_string.o \
328src/pk/dh/dh.o src/pk/dh/dh_check_pubkey.o src/pk/dh/dh_export.o src/pk/dh/dh_export_key.o \
329src/pk/dh/dh_free.o src/pk/dh/dh_generate_key.o src/pk/dh/dh_import.o src/pk/dh/dh_set.o \
330src/pk/dh/dh_set_pg_dhparam.o src/pk/dh/dh_shared_secret.o src/pk/dsa/dsa_decrypt_key.o \
331src/pk/dsa/dsa_encrypt_key.o src/pk/dsa/dsa_export.o src/pk/dsa/dsa_free.o \
332src/pk/dsa/dsa_generate_key.o src/pk/dsa/dsa_generate_pqg.o src/pk/dsa/dsa_import.o \
333src/pk/dsa/dsa_make_key.o src/pk/dsa/dsa_set.o src/pk/dsa/dsa_set_pqg_dsaparam.o \
334src/pk/dsa/dsa_shared_secret.o src/pk/dsa/dsa_sign_hash.o src/pk/dsa/dsa_verify_hash.o \
335src/pk/dsa/dsa_verify_key.o src/pk/ecc/ecc.o src/pk/ecc/ecc_ansi_x963_export.o \
336src/pk/ecc/ecc_ansi_x963_import.o src/pk/ecc/ecc_decrypt_key.o src/pk/ecc/ecc_encrypt_key.o \
337src/pk/ecc/ecc_export.o src/pk/ecc/ecc_free.o src/pk/ecc/ecc_get_size.o src/pk/ecc/ecc_import.o \
338src/pk/ecc/ecc_make_key.o src/pk/ecc/ecc_shared_secret.o src/pk/ecc/ecc_sign_hash.o \
339src/pk/ecc/ecc_sizes.o src/pk/ecc/ecc_test.o src/pk/ecc/ecc_verify_hash.o \
340src/pk/ecc/ltc_ecc_is_valid_idx.o src/pk/ecc/ltc_ecc_map.o src/pk/ecc/ltc_ecc_mul2add.o \
341src/pk/ecc/ltc_ecc_mulmod.o src/pk/ecc/ltc_ecc_mulmod_timing.o src/pk/ecc/ltc_ecc_points.o \
342src/pk/ecc/ltc_ecc_projective_add_point.o src/pk/ecc/ltc_ecc_projective_dbl_point.o \
343src/pk/katja/katja_decrypt_key.o src/pk/katja/katja_encrypt_key.o src/pk/katja/katja_export.o \
344src/pk/katja/katja_exptmod.o src/pk/katja/katja_free.o src/pk/katja/katja_import.o \
345src/pk/katja/katja_make_key.o src/pk/pkcs1/pkcs_1_i2osp.o src/pk/pkcs1/pkcs_1_mgf1.o \
346src/pk/pkcs1/pkcs_1_oaep_decode.o src/pk/pkcs1/pkcs_1_oaep_encode.o src/pk/pkcs1/pkcs_1_os2ip.o \
347src/pk/pkcs1/pkcs_1_pss_decode.o src/pk/pkcs1/pkcs_1_pss_encode.o src/pk/pkcs1/pkcs_1_v1_5_decode.o \
348src/pk/pkcs1/pkcs_1_v1_5_encode.o src/pk/rsa/rsa_decrypt_key.o src/pk/rsa/rsa_encrypt_key.o \
349src/pk/rsa/rsa_export.o src/pk/rsa/rsa_exptmod.o src/pk/rsa/rsa_free.o src/pk/rsa/rsa_get_size.o \
350src/pk/rsa/rsa_import.o src/pk/rsa/rsa_import_pkcs8.o src/pk/rsa/rsa_import_x509.o \
351src/pk/rsa/rsa_make_key.o src/pk/rsa/rsa_set.o src/pk/rsa/rsa_sign_hash.o \
352src/pk/rsa/rsa_sign_saltlen_get.o src/pk/rsa/rsa_verify_hash.o src/prngs/chacha20.o src/prngs/fortuna.o \
353src/prngs/rc4.o src/prngs/rng_get_bytes.o src/prngs/rng_make_prng.o src/prngs/sober128.o \
354src/prngs/sprng.o src/prngs/yarrow.o src/stream/chacha/chacha_crypt.o src/stream/chacha/chacha_done.o \
355src/stream/chacha/chacha_ivctr32.o src/stream/chacha/chacha_ivctr64.o \
356src/stream/chacha/chacha_keystream.o src/stream/chacha/chacha_setup.o src/stream/chacha/chacha_test.o \
357src/stream/rc4/rc4_stream.o src/stream/rc4/rc4_test.o src/stream/sober128/sober128_stream.o \
358src/stream/sober128/sober128_test.o
359
360# List of test objects to compile (all goes to libtomcrypt_prof.a)
361TOBJECTS=tests/base64_test.o tests/cipher_hash_test.o tests/common.o tests/der_test.o tests/dh_test.o \
362tests/dsa_test.o tests/ecc_test.o tests/file_test.o tests/katja_test.o tests/mac_test.o tests/misc_test.o \
363tests/modes_test.o tests/mpi_test.o tests/multi_test.o tests/no_prng.o tests/pkcs_1_eme_test.o \
364tests/pkcs_1_emsa_test.o tests/pkcs_1_oaep_test.o tests/pkcs_1_pss_test.o tests/pkcs_1_test.o \
365tests/prng_test.o tests/rotate_test.o tests/rsa_test.o tests/store_test.o tests/test.o
366
367# The following headers will be installed by "make install"
368HEADERS=src/headers/tomcrypt.h src/headers/tomcrypt_argchk.h src/headers/tomcrypt_cfg.h \
369src/headers/tomcrypt_cipher.h src/headers/tomcrypt_custom.h src/headers/tomcrypt_hash.h \
370src/headers/tomcrypt_mac.h src/headers/tomcrypt_macros.h src/headers/tomcrypt_math.h \
371src/headers/tomcrypt_misc.h src/headers/tomcrypt_pk.h src/headers/tomcrypt_pkcs.h \
372src/headers/tomcrypt_prng.h
373
374#These are the rules to $(MAKE) certain object files.
375src/ciphers/aes/aes.o: src/ciphers/aes/aes.c src/ciphers/aes/aes_tab.c
376src/ciphers/twofish/twofish.o: src/ciphers/twofish/twofish.c src/ciphers/twofish/twofish_tab.c
377src/hashes/whirl/whirl.o: src/hashes/whirl/whirl.c src/hashes/whirl/whirltab.c
378src/hashes/sha2/sha512.o: src/hashes/sha2/sha512.c src/hashes/sha2/sha384.c
379src/hashes/sha2/sha512_224.o: src/hashes/sha2/sha512.c src/hashes/sha2/sha512_224.c
380src/hashes/sha2/sha512_256.o: src/hashes/sha2/sha512.c src/hashes/sha2/sha512_256.c
381src/hashes/sha2/sha256.o: src/hashes/sha2/sha256.c src/hashes/sha2/sha224.c
382
383$(DOBJECTS): LTC_CFLAGS := -Itests $(LTC_CFLAGS)
384$(TOBJECTS): LTC_CFLAGS := -Itests $(LTC_CFLAGS)
385
386#Dependencies on *.h
387$(OBJECTS): $(HEADERS)
388$(DOBJECTS): $(HEADERS) $(THEADERS)
389$(TOBJECTS): $(HEADERS) $(THEADERS)
390
391all: $(call print-help,all,Builds the library and all demos and test utils (test $(UNBROKEN_DEMOS) $(BROKEN_DEMOS))) all_test $(BROKEN_DEMOS)
392
393all_test: $(call print-help,all_test,Builds the library and all unbroken demos and test utils (test $(UNBROKEN_DEMOS))) test $(UNBROKEN_DEMOS)
394
395bins: $(call print-help,bins,Builds the library and all useful demos) $(USEFUL_DEMOS)
396
397#build the doxy files (requires Doxygen, tetex and patience)
398doxygen: $(call print-help,doxygen,Builds the doxygen html documentation)
399	$(MAKE) -C doc/ $@ V=$(V)
400doxy: $(call print-help,doxy,Builds the complete doxygen documentation including refman.pdf (takes long to generate))
401	$(MAKE) -C doc/ $@ V=$(V)
402docs: $(call print-help,docs,Builds the Developer Manual)
403	$(MAKE) -C doc/ $@ V=$(V)
404
405doc/crypt.pdf: $(call print-help,doc/crypt.pdf,Builds the Developer Manual)
406	$(MAKE) -C doc/ crypt.pdf V=$(V)
407
408
409install_all: $(call print-help,install_all,Install everything - library bins docs tests) install install_bins install_docs
410
411INSTALL_OPTS ?= -m 644
412
413.common_install: $(LIBNAME)
414	install -p -d $(DESTDIR)$(INCPATH)
415	install -p -d $(DESTDIR)$(LIBPATH)
416	$(INSTALL_CMD) -p $(INSTALL_OPTS) $(LIBNAME) $(DESTDIR)$(LIBPATH)/$(LIBNAME)
417	install -p -m 644 $(HEADERS) $(DESTDIR)$(INCPATH)
418
419$(DESTDIR)$(BINPATH):
420	install -p -d $(DESTDIR)$(BINPATH)
421
422.common_install_bins: $(USEFUL_DEMOS) $(DESTDIR)$(BINPATH)
423	$(INSTALL_CMD) -p -m 775 $(USEFUL_DEMOS) $(DESTDIR)$(BINPATH)
424
425install_docs: $(call print-help,install_docs,Installs the Developer Manual) doc/crypt.pdf
426	install -p -d $(DESTDIR)$(DATAPATH)
427	install -p -m 644 doc/crypt.pdf $(DESTDIR)$(DATAPATH)
428
429install_test: $(call print-help,install_test,Installs the self-test binary) test $(DESTDIR)$(BINPATH)
430	$(INSTALL_CMD) -p -m 775 $< $(DESTDIR)$(BINPATH)
431
432install_hooks: $(call print-help,install_hooks,Installs the git hooks)
433	for s in `ls hooks/`; do ln -s ../../hooks/$$s .git/hooks/$$s; done
434
435HEADER_FILES=$(notdir $(HEADERS))
436.common_uninstall:
437	$(UNINSTALL_CMD) $(DESTDIR)$(LIBPATH)/$(LIBNAME)
438	rm $(HEADER_FILES:%=$(DESTDIR)$(INCPATH)/%)
439
440#This rule cleans the source tree of all compiled code, not including the pdf
441#documentation.
442clean: $(call print-help,clean,Clean everything besides the pdf documentation)
443	find . -type f    -name "*.o"   \
444               -o -name "*.lo"  \
445               -o -name "*.a"   \
446               -o -name "*.la"  \
447               -o -name "*.obj" \
448               -o -name "*.lib" \
449               -o -name "*.exe" \
450               -o -name "*.dll" \
451               -o -name "*.so"  \
452               -o -name "*.gcov"\
453               -o -name "*.gcda"\
454               -o -name "*.gcno"\
455               -o -name "*.il"  \
456               -o -name "*.dyn" \
457               -o -name "*.dpi"  | xargs rm -f
458	rm -f $(TIMING) $(TEST) $(DEMOS)
459	rm -f *_tv.txt
460	rm -f *.pc
461	rm -rf `find . -type d -name "*.libs" | xargs`
462	$(MAKE) -C doc/ clean
463
464zipup: $(call print-help,zipup,Prepare the archives for a release) doc/crypt.pdf
465	@# Update the index, so diff-index won't fail in case the pdf has been created.
466	@#   As the pdf creation modifies crypt.tex, git sometimes detects the
467	@#   modified file, but misses that it's put back to its original version.
468	@git update-index --refresh
469	@git diff-index --quiet HEAD -- || ( echo "FAILURE: uncommited changes or not a git" && exit 1 )
470	@perl helper.pl --check-all || ( echo "FAILURE: helper.pl --check-all errors" && exit 1 )
471	rm -rf libtomcrypt-$(VERSION) crypt-$(VERSION).*
472	@# files/dirs excluded from "git archive" are defined in .gitattributes
473	git archive --format=tar --prefix=libtomcrypt-$(VERSION)/ HEAD | tar x
474	@echo 'fixme check'
475	-@(find libtomcrypt-$(VERSION)/ -type f | xargs grep 'FIXM[E]') && echo '############## BEWARE: the "fixme" marker was found !!! ##############' || true
476	mkdir -p libtomcrypt-$(VERSION)/doc
477	cp doc/crypt.pdf libtomcrypt-$(VERSION)/doc/crypt.pdf
478	tar -c libtomcrypt-$(VERSION)/ | xz -6e -c - > crypt-$(VERSION).tar.xz
479	zip -9rq crypt-$(VERSION).zip libtomcrypt-$(VERSION)
480	rm -rf libtomcrypt-$(VERSION)
481	gpg -b -a crypt-$(VERSION).tar.xz
482	gpg -b -a crypt-$(VERSION).zip
483
484codecheck: $(call print-help,codecheck,Check the code of the library)
485	perl helper.pl -a
486	perlcritic *.pl
487
488help: $(call print-help,help,That's what you're currently looking at)
489