comparison makefile @ 15:6362d3854bb4 libtomcrypt-orig

0.96 release of LibTomCrypt
author Matt Johnston <matt@ucc.asn.au>
date Tue, 15 Jun 2004 14:07:21 +0000
parents 7faae8f46238
children 09ab3354aa21 5d99163f7e32
comparison
equal deleted inserted replaced
3:7faae8f46238 15:6362d3854bb4
7 # the time being this is actually pretty clean. The only ugly part is 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 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. 9 # a build. This is easy to remedy though, for those that have problems.
10 10
11 # The version 11 # The version
12 VERSION=0.95 12 VERSION=0.96
13 13
14 #ch1-01-1
15 # Compiler and Linker Names 14 # Compiler and Linker Names
16 #CC=gcc 15 #CC=gcc
17 #LD=ld 16 #LD=ld
18 17
19 # Archiver [makes .a files] 18 # Archiver [makes .a files]
20 #AR=ar 19 #AR=ar
21 #ARFLAGS=r 20 #ARFLAGS=r
22 #ch1-01-1 21
23
24 #ch1-01-3
25 # Compilation flags. Note the += does not write over the user's CFLAGS! 22 # Compilation flags. Note the += does not write over the user's CFLAGS!
26 CFLAGS += -c -I./ -Wall -Wsign-compare -W -Wshadow 23 CFLAGS += -c -I./ -Wall -Wsign-compare -W -Wshadow
27 # -Werror 24 # -Werror
28 25
29 # optimize for SPEED 26 # optimize for SPEED
30 #CFLAGS += -O3 -funroll-loops 27 #CFLAGS += -O3 -funroll-loops
31 28
32 #add -fomit-frame-pointer. v3.2 is buggy for certain platforms! 29 #add -fomit-frame-pointer. GCC v3.2 is buggy for certain platforms!
33 #CFLAGS += -fomit-frame-pointer 30 CFLAGS += -fomit-frame-pointer
34 31
35 # optimize for SIZE 32 # optimize for SIZE
36 CFLAGS += -Os 33 CFLAGS += -Os
37 34
38 # compile for DEBUGING 35 # compile for DEBUGING
41 38
42 #These flags control how the library gets built. 39 #These flags control how the library gets built.
43 40
44 #Output filenames for various targets. 41 #Output filenames for various targets.
45 LIBNAME=libtomcrypt.a 42 LIBNAME=libtomcrypt.a
46 TEST=test
47 HASH=hashsum 43 HASH=hashsum
48 CRYPT=encrypt 44 CRYPT=encrypt
49 SMALL=small 45 SMALL=small
50 PROF=x86_prof 46 PROF=x86_prof
51 TV=tv_gen 47 TV=tv_gen
61 #List of objects to compile. 57 #List of objects to compile.
62 58
63 #Leave MPI built-in or force developer to link against libtommath? 59 #Leave MPI built-in or force developer to link against libtommath?
64 MPIOBJECT=mpi.o 60 MPIOBJECT=mpi.o
65 61
66 OBJECTS=keyring.o gf.o strings.o base64.o \ 62 OBJECTS=error_to_string.o mpi_to_ltc_error.o base64_encode.o base64_decode.o \
67 \ 63 \
68 crypt.o crypt_find_cipher.o crypt_find_hash_any.o \ 64 crypt.o crypt_find_cipher.o crypt_find_hash_any.o \
69 crypt_hash_is_valid.o crypt_register_hash.o crypt_unregister_prng.o \ 65 crypt_hash_is_valid.o crypt_register_hash.o crypt_unregister_prng.o \
70 crypt_argchk.o crypt_find_cipher_any.o crypt_find_hash_id.o \ 66 crypt_argchk.o crypt_find_cipher_any.o crypt_find_hash_id.o \
71 crypt_prng_descriptor.o crypt_register_prng.o crypt_cipher_descriptor.o \ 67 crypt_prng_descriptor.o crypt_register_prng.o crypt_cipher_descriptor.o \
77 \ 73 \
78 rand_prime.o is_prime.o \ 74 rand_prime.o is_prime.o \
79 \ 75 \
80 ecc.o dh.o \ 76 ecc.o dh.o \
81 \ 77 \
82 rsa.o rsa_exptmod.o rsa_free.o rsa_make_key.o \ 78 rsa_decrypt_key.o rsa_encrypt_key.o rsa_exptmod.o rsa_free.o rsa_make_key.o \
83 \ 79 rsa_sign_hash.o rsa_verify_hash.o rsa_export.o rsa_import.o tim_exptmod.o \
84 dsa_export.o dsa_free.o dsa_import.o dsa_make_key.o dsa_sign_hash.o dsa_verify_hash.o dsa_verify_key.o \ 80 \
85 \ 81 dsa_export.o dsa_free.o dsa_import.o dsa_make_key.o dsa_sign_hash.o \
86 xtea.o aes.o des.o safer_tab.o safer.o saferp.o rc2.o \ 82 dsa_verify_hash.o dsa_verify_key.o \
87 rc6.o rc5.o cast5.o noekeon.o blowfish.o twofish.o skipjack.o \ 83 \
84 aes.o aes_enc.o \
85 \
86 blowfish.o des.o safer_tab.o safer.o saferp.o rc2.o xtea.o \
87 rc6.o rc5.o cast5.o noekeon.o twofish.o skipjack.o \
88 \ 88 \
89 md2.o md4.o md5.o sha1.o sha256.o sha512.o tiger.o whirl.o \ 89 md2.o md4.o md5.o sha1.o sha256.o sha512.o tiger.o whirl.o \
90 rmd128.o rmd160.o \ 90 rmd128.o rmd160.o \
91 \ 91 \
92 packet_store_header.o packet_valid_header.o \ 92 packet_store_header.o packet_valid_header.o \
101 omac_done.o omac_file.o omac_init.o omac_memory.o omac_process.o omac_test.o \ 101 omac_done.o omac_file.o omac_init.o omac_memory.o omac_process.o omac_test.o \
102 \ 102 \
103 pmac_done.o pmac_file.o pmac_init.o pmac_memory.o pmac_ntz.o pmac_process.o \ 103 pmac_done.o pmac_file.o pmac_init.o pmac_memory.o pmac_ntz.o pmac_process.o \
104 pmac_shift_xor.o pmac_test.o \ 104 pmac_shift_xor.o pmac_test.o \
105 \ 105 \
106 cbc_start.o cbc_encrypt.o cbc_decrypt.o \ 106 cbc_start.o cbc_encrypt.o cbc_decrypt.o cbc_getiv.o cbc_setiv.o \
107 cfb_start.o cfb_encrypt.o cfb_decrypt.o \ 107 cfb_start.o cfb_encrypt.o cfb_decrypt.o cfb_getiv.o cfb_setiv.o \
108 ofb_start.o ofb_encrypt.o ofb_decrypt.o \ 108 ofb_start.o ofb_encrypt.o ofb_decrypt.o ofb_getiv.o ofb_setiv.o \
109 ctr_start.o ctr_encrypt.o ctr_decrypt.o \ 109 ctr_start.o ctr_encrypt.o ctr_decrypt.o ctr_getiv.o ctr_setiv.o \
110 ecb_start.o ecb_encrypt.o ecb_decrypt.o \ 110 ecb_start.o ecb_encrypt.o ecb_decrypt.o \
111 \ 111 \
112 hash_file.o hash_filehandle.o hash_memory.o \ 112 hash_file.o hash_filehandle.o hash_memory.o \
113 \ 113 \
114 hmac_done.o hmac_file.o hmac_init.o hmac_memory.o hmac_process.o hmac_test.o \ 114 hmac_done.o hmac_file.o hmac_init.o hmac_memory.o hmac_process.o hmac_test.o \
115 \ 115 \
116 pkcs_1_mgf1.o pkcs_1_oaep_encode.o pkcs_1_oaep_decode.o \ 116 pkcs_1_mgf1.o pkcs_1_oaep_encode.o pkcs_1_oaep_decode.o \
117 pkcs_1_pss_encode.o pkcs_1_pss_decode.o pkcs_1_i2osp.o pkcs_1_os2ip.o \ 117 pkcs_1_pss_encode.o pkcs_1_pss_decode.o pkcs_1_i2osp.o pkcs_1_os2ip.o \
118 pkcs_1_v15_es_encode.o pkcs_1_v15_es_decode.o pkcs_1_v15_sa_encode.o pkcs_1_v15_sa_decode.o \
118 \ 119 \
119 pkcs_5_1.o pkcs_5_2.o \ 120 pkcs_5_1.o pkcs_5_2.o \
120 \ 121 \
121 burn_stack.o zeromem.o \ 122 burn_stack.o zeromem.o \
122 $(MPIOBJECT) 123 $(MPIOBJECT)
127 SMALLOBJECTS=demos/small.o 128 SMALLOBJECTS=demos/small.o
128 PROFS=demos/x86_prof.o 129 PROFS=demos/x86_prof.o
129 TVS=demos/tv_gen.o 130 TVS=demos/tv_gen.o
130 131
131 #Files left over from making the crypt.pdf. 132 #Files left over from making the crypt.pdf.
132 LEFTOVERS=*.dvi *.log *.aux *.toc *.idx *.ilg *.ind 133 LEFTOVERS=*.dvi *.log *.aux *.toc *.idx *.ilg *.ind *.out
133 134
134 #Compressed filenames 135 #Compressed filenames
135 COMPRESSED=crypt.tar.bz2 crypt.zip crypt.tar.gz 136 COMPRESSED=crypt-$(VERSION).tar.bz2 crypt-$(VERSION).zip
136 137
137 #Header files used by libtomcrypt. 138 #Header files used by libtomcrypt.
138 HEADERS=tommath.h mycrypt_cfg.h mycrypt_gf.h mycrypt_kr.h \ 139 HEADERS=ltc_tommath.h mycrypt_cfg.h \
139 mycrypt_misc.h mycrypt_prng.h mycrypt_cipher.h mycrypt_hash.h \ 140 mycrypt_misc.h mycrypt_prng.h mycrypt_cipher.h mycrypt_hash.h \
140 mycrypt_macros.h mycrypt_pk.h mycrypt.h mycrypt_argchk.h \ 141 mycrypt_macros.h mycrypt_pk.h mycrypt.h mycrypt_argchk.h \
141 mycrypt_custom.h mycrypt_pkcs.h 142 mycrypt_custom.h mycrypt_pkcs.h
142 143
143 #The default rule for make builds the libtomcrypt library. 144 #The default rule for make builds the libtomcrypt library.
144 default:library mycrypt.h mycrypt_cfg.h 145 default:library
145 146
147 #ciphers come in two flavours... enc+dec and enc
148 aes_enc.o: aes.c aes_tab.c
149 $(CC) $(CFLAGS) -DENCRYPT_ONLY -c aes.c -o aes_enc.o
150
146 #These are the rules to make certain object files. 151 #These are the rules to make certain object files.
147 rsa.o: rsa.c rsa_sys.c
148 ecc.o: ecc.c ecc_sys.c 152 ecc.o: ecc.c ecc_sys.c
149 dh.o: dh.c dh_sys.c 153 dh.o: dh.c dh_sys.c
150 aes.o: aes.c aes_tab.c
151 twofish.o: twofish.c twofish_tab.c
152 sha512.o: sha512.c sha384.c 154 sha512.o: sha512.c sha384.c
153 sha256.o: sha256.c sha224.c 155 sha256.o: sha256.c sha224.c
154 156
155 #This rule makes the libtomcrypt library. 157 #This rule makes the libtomcrypt library.
156 library: $(LIBNAME) 158 library: $(LIBNAME)
157 159
158 $(LIBNAME): $(OBJECTS) 160 $(LIBNAME): $(OBJECTS)
159 $(AR) $(ARFLAGS) $@ $(OBJECTS) 161 $(AR) $(ARFLAGS) $@ $(OBJECTS)
160
161 #This rule makes the test program included with libtomcrypt
162 test: library $(TESTOBJECTS)
163 $(CC) $(TESTOBJECTS) $(LIBNAME) -o $(TEST) $(WARN)
164 162
165 #This rule makes the hash program included with libtomcrypt 163 #This rule makes the hash program included with libtomcrypt
166 hashsum: library $(HASHOBJECTS) 164 hashsum: library $(HASHOBJECTS)
167 $(CC) $(HASHOBJECTS) $(LIBNAME) -o $(HASH) $(WARN) 165 $(CC) $(HASHOBJECTS) $(LIBNAME) -o $(HASH) $(WARN)
168 166
177 x86_prof: library $(PROFS) 175 x86_prof: library $(PROFS)
178 $(CC) $(PROFS) $(LIBNAME) -o $(PROF) 176 $(CC) $(PROFS) $(LIBNAME) -o $(PROF)
179 177
180 tv_gen: library $(TVS) 178 tv_gen: library $(TVS)
181 $(CC) $(TVS) $(LIBNAME) -o $(TV) 179 $(CC) $(TVS) $(LIBNAME) -o $(TV)
182
183
184 #make a profiled library (takes a while!!!)
185 #
186 # This will build the library with profile generation
187 # then run the test demo and rebuild the library.
188 #
189 # So far I've seen improvements in the MP math
190 #
191 # This works with GCC v3.3.x [tested with 3.3.3]
192 profiled: $(TESTOBJECTS)
193 make CFLAGS="$(CFLAGS) -fprofile-arcs"
194 $(CC) $(TESTOBJECTS) $(LIBNAME) -o $(TEST)
195 ./test
196 rm -f *.a *.o test demos/test.o
197 make CFLAGS="$(CFLAGS) -fbranch-probabilities"
198
199
200 #Profiling in GCC 3.4.x is a little diff.
201 #
202 #Tested with GCC v3.4.0
203 profiled34: $(TESTOBJECTS)
204 make CFLAGS="$(CFLAGS) -fprofile-generate"
205 $(CC) $(TESTOBJECTS) $(LIBNAME) -lgcov -o $(TEST)
206 ./test
207 rm -f *.a *.o test demos/test.o
208 make CFLAGS="$(CFLAGS) -fprofile-use"
209
210 180
211 #This rule installs the library and the header files. This must be run 181 #This rule installs the library and the header files. This must be run
212 #as root in order to have a high enough permission to write to the correct 182 #as root in order to have a high enough permission to write to the correct
213 #directories and to set the owner and group to root. 183 #directories and to set the owner and group to root.
214 install: library docs 184 install: library docs
215 install -d -g root -o root $(DESTDIR)$(LIBPATH) 185 install -d -g root -o root $(DESTDIR)$(LIBPATH)
216 install -d -g root -o root $(DESTDIR)$(INCPATH) 186 install -d -g root -o root $(DESTDIR)$(INCPATH)
217 install -d -g root -o root $(DESTDIR)$(DATAPATH) 187 install -d -g root -o root $(DESTDIR)$(DATAPATH)
218 install -g root -o root $(LIBNAME) $(DESTDIR)$(LIBPATH) 188 install -g root -o root $(LIBNAME) $(DESTDIR)$(LIBPATH)
219 install -g root -o root $(HEADERS) $(DESTDIR)$(INCPATH) 189 install -g root -o root $(HEADERS) $(DESTDIR)$(INCPATH)
220 install -g root -o root crypt.pdf $(DESTDIR)$(DATAPATH) 190 install -g root -o root doc/crypt.pdf $(DESTDIR)$(DATAPATH)
221 191
222 #This rule cleans the source tree of all compiled code, not including the pdf 192 #This rule cleans the source tree of all compiled code, not including the pdf
223 #documentation. 193 #documentation.
224 clean: 194 clean:
225 rm -f $(OBJECTS) $(TESTOBJECTS) $(HASHOBJECTS) $(CRYPTOBJECTS) $(SMALLOBJECTS) $(LEFTOVERS) $(LIBNAME) 195 rm -f $(OBJECTS) $(TESTOBJECTS) $(HASHOBJECTS) $(CRYPTOBJECTS) $(SMALLOBJECTS) $(LEFTOVERS) $(LIBNAME)
226 rm -f $(TEST) $(HASH) $(COMPRESSED) $(PROFS) $(PROF) $(TVS) $(TV) 196 rm -f $(TEST) $(HASH) $(COMPRESSED) $(PROFS) $(PROF) $(TVS) $(TV)
227 rm -f *.a *.dll *stackdump *.lib *.exe *.obj demos/*.obj demos/*.o *.bat *.txt *.il *.da demos/*.il demos/*.da *.dyn *.dpi \ 197 rm -f *.a *.dll *stackdump *.lib *.exe *.obj demos/*.obj demos/*.o *.bat *.txt *.il *.da demos/*.il demos/*.da *.dyn *.dpi \
228 *.gcda *.gcno demos/*.gcno demos/*.gcda *~ 198 *.gcda *.gcno demos/*.gcno demos/*.gcda *~ doc/*
199 cd demos/test ; make clean
229 200
230 #This builds the crypt.pdf file. Note that the rm -f *.pdf has been removed 201 #This builds the crypt.pdf file. Note that the rm -f *.pdf has been removed
231 #from the clean command! This is because most people would like to keep the 202 #from the clean command! This is because most people would like to keep the
232 #nice pre-compiled crypt.pdf that comes with libtomcrypt! We only need to 203 #nice pre-compiled crypt.pdf that comes with libtomcrypt! We only need to
233 #delete it if we are rebuilding it. 204 #delete it if we are rebuilding it.
234 docs: crypt.tex 205 docs: crypt.tex
235 rm -f crypt.pdf $(LEFTOVERS) 206 rm -f doc/crypt.pdf $(LEFTOVERS)
207 echo "hello" > crypt.ind
236 latex crypt > /dev/null 208 latex crypt > /dev/null
237 makeindex crypt > /dev/null 209 makeindex crypt > /dev/null
238 latex crypt > /dev/null 210 latex crypt > /dev/null
239 latex crypt > /dev/null 211 latex crypt > /dev/null
240 dvipdf crypt 212 dvipdf crypt
213 mv -ivf crypt.pdf doc/crypt.pdf
241 rm -f $(LEFTOVERS) 214 rm -f $(LEFTOVERS)
242 215
216 docdvi: crypt.tex
217 echo hello > crypt.ind
218 latex crypt > /dev/null
219 latex crypt > /dev/null
220 makeindex crypt
221 latex crypt > /dev/null
222
243 #beta 223 #beta
244 beta: clean 224 beta: clean
245 cd .. ; rm -rf crypt* libtomcrypt-$(VERSION)-beta ; mkdir libtomcrypt-$(VERSION)-beta ; \ 225 cd .. ; rm -rf crypt* libtomcrypt-$(VERSION)-beta ; mkdir libtomcrypt-$(VERSION)-beta ; \
246 cp -R ./libtomcrypt/* ./libtomcrypt-$(VERSION)-beta/ ; tar -c libtomcrypt-$(VERSION)-beta/* > crypt-$(VERSION)-beta.tar ; \ 226 cp -R ./libtomcrypt/* ./libtomcrypt-$(VERSION)-beta/ ; tar -c libtomcrypt-$(VERSION)-beta/* > crypt-$(VERSION)-beta.tar ; \
247 bzip2 -9vv crypt-$(VERSION)-beta.tar ; zip -9 -r crypt-$(VERSION)-beta.zip libtomcrypt-$(VERSION)-beta/* 227 bzip2 -9vv crypt-$(VERSION)-beta.tar ; zip -9 -r crypt-$(VERSION)-beta.zip libtomcrypt-$(VERSION)-beta/*
248 228
249 #zipup the project (take that!) 229 #zipup the project (take that!)
250 zipup: clean docs 230 zipup: clean docs
251 cd .. ; rm -rf crypt* libtomcrypt-$(VERSION) ; mkdir libtomcrypt-$(VERSION) ; \ 231 cd .. ; rm -rf crypt* libtomcrypt-$(VERSION) ; mkdir libtomcrypt-$(VERSION) ; \
252 cp -R ./libtomcrypt/* ./libtomcrypt-$(VERSION)/ ; tar -c libtomcrypt-$(VERSION)/* > crypt-$(VERSION).tar ; \ 232 cp -R ./libtomcrypt/* ./libtomcrypt-$(VERSION)/ ; tar -c libtomcrypt-$(VERSION)/* > crypt-$(VERSION).tar ; \
253 bzip2 -9vv crypt-$(VERSION).tar ; zip -9 -r crypt-$(VERSION).zip libtomcrypt-$(VERSION)/* 233 bzip2 -9vv crypt-$(VERSION).tar ; zip -9 -r crypt-$(VERSION).zip libtomcrypt-$(VERSION)/* ; \
234 gpg -b -a crypt-$(VERSION).tar.bz2 ; \
235 gpg -b -a crypt-$(VERSION).zip