Merge branch 'master' of git+ssh://metalzone.distorted.org.uk/~mdw/public-git/catacomb/
[u/mdw/catacomb] / Makefile.m4
... / ...
CommitLineData
1## -*-m4-*-
2##
3## $Id$
4##
5## Makefile for Catacomb
6##
7## (c) 1999 Straylight/Edgeware
8##
9
10##----- Licensing notice ----------------------------------------------------
11##
12## This file is part of Catacomb.
13##
14## Catacomb is free software; you can redistribute it and/or modify
15## it under the terms of the GNU Library General Public License as
16## published by the Free Software Foundation; either version 2 of the
17## License, or (at your option) any later version.
18##
19## Catacomb is distributed in the hope that it will be useful,
20## but WITHOUT ANY WARRANTY; without even the implied warranty of
21## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22## GNU Library General Public License for more details.
23##
24## You should have received a copy of the GNU Library General Public
25## License along with Catacomb; if not, write to the Free
26## Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
27## MA 02111-1307, USA.
28
29AUTOMAKE_OPTIONS = foreign
30
31SUBDIRS = tests
32
33archincludedir = $(libdir)/catacomb/include
34
35## --- List handling macros ---
36##
37## List handling is nice, usually. Unfortunately, I based this design on
38## TeX list macros rather than anything sensible...
39
40define(`_', `define(`_item', $1)define(`_item_2', $2)emit`'')
41define(`adorn', `pushdef(`emit', `$1`'_item`'$3')$2`'popdef(`emit')')
42define(`join',
43`pushdef(`emit', `adorn(``_(''_item`$2', `$3', ``)'')`'')$1`'popdef(`emit')')
44define(`addsuffix', `adorn(`', `$1', `$2')')
45define(`lit', `adorn(`', `$1', `')')
46define(`nl', `
47')
48
49define(`allwithsuffix',
50`addsuffix(`$1', `$3') addsuffix(`$2', `$3') dnl
51addsuffix(join(`$1', `-', `$2'), `$3')')
52
53## --- Autogenerated source files ---
54
55define(`ciphers', `dnl
56_(des) _(desx) _(des3) _(mars) dnl
57_(idea) _(safer) _(safersk) dnl
58_(blowfish) _(twofish) dnl
59_(tea) _(xtea) dnl
60_(rc2) _(rc5) dnl
61_(skipjack) dnl
62_(cast128) _(cast256) dnl
63_(square) _(rijndael) _(rijndael192) _(rijndael256) dnl
64_(serpent) _(noekeon)')
65define(`cipher_modes', `_(ecb) _(cbc) _(cfb) _(ofb) _(counter)')
66
67define(`hashes', `dnl
68_(md5) _(md4) _(md2) _(tiger) _(has160) dnl
69_(sha) _(sha224) _(sha256) _(sha384) _(sha512) dnl
70_(whirlpool) _(whirlpool256) dnl
71_(rmd128) _(rmd160) _(rmd256) _(rmd320)')
72define(`hash_modes', `_(mgf) _(hmac)')
73
74MODES = \
75 adorn(`$(srcdir)/', join(`ciphers', `-', `cipher_modes'), `.c') \
76 adorn(`$(srcdir)/', join(`ciphers', `-', `cipher_modes'), `.h') \
77 adorn(`$(srcdir)/', join(`hashes', `-', `hash_modes'), `.c') \
78 adorn(`$(srcdir)/', join(`hashes', `-', `hash_modes'), `.h')
79
80$(MODES): modes-stamp
81modes-stamp: genmodes
82 cd $(srcdir); ./genmodes "lit(`ciphers')" "lit(`cipher_modes')"
83 cd $(srcdir); ./genmodes "lit(`hashes')" "lit(`hash_modes')"
84 echo datestamp >modes-stamp
85
86define(`gen_tables', `dnl
87_(des) _(blowfish) _(twofish) dnl
88_(square) _(rijndael) _(whirlpool) dnl
89_(safer) _(mars) _(tiger) dnl
90_(gfshare) _(gfx-sqr)')
91
92autoheaders: addsuffix(`gen_tables', `-tab.h') primetab.h mptypes.h
93define(`emit', `
94_item`'-tab.h: _item`'-mktab$(EXEEXT)
95 ./_item`'-mktab >_item`'-tab.h.new
96 mv _item`'-tab.h.new _item`'-tab.h')dnl
97gen_tables
98
99primetab.h: primetab.c
100primetab.c: genprimes$(EXEEXT)
101 ./genprimes -h primetab.h -c primetab.c \
102 -s CATACOMB_PRIMETAB_H -n 256 \
103 -t "unsigned short" -i primetab
104archinclude_HEADERS = mptypes.h
105mptypes.h: mptypes$(EXEEXT)
106 ./mptypes >mptypes.h.new
107 mv mptypes.h.new mptypes.h
108
109ectab.c: ectab.in ec-gentab.awk mpdump$(EXEEXT)
110 $(srcdir)/ec-gentab.awk <$(srcdir)/ectab.in >ectab.c.new
111 mv ectab.c.new ectab.c
112
113ptab.c: ptab.in p-gentab.awk mpdump$(EXEEXT)
114 $(srcdir)/p-gentab.awk <$(srcdir)/ptab.in >ptab.c.new
115 mv ptab.c.new ptab.c
116
117bintab.c: bintab.in bin-gentab.awk mpdump$(EXEEXT)
118 $(srcdir)/bin-gentab.awk <$(srcdir)/bintab.in >bintab.c.new
119 mv bintab.c.new bintab.c
120
121gciphertab.c: gengctab
122 $(srcdir)/gengctab gccipher gcipher >gciphertab.c.new \
123 "lit(join(`ciphers', `-', `cipher_modes')) \
124 lit(join(`hashes', `-', `_(mgf)')) \
125 rc4 seal"
126 mv gciphertab.c.new gciphertab.c
127
128gmactab.c: gengctab
129 $(srcdir)/gengctab gcmac gmac >gmactab.c.new \
130 "lit(join(`hashes', `-', `_(hmac)'))"
131 mv gmactab.c.new gmactab.c
132
133ghashtab.c: gengctab
134 $(srcdir)/gengctab gchash ghash >ghashtab.c.new \
135 "lit(`hashes') \
136 crc32=gcrc32"
137 mv ghashtab.c.new ghashtab.c
138
139BUILT_SOURCES = \
140 getdate.c modes-stamp gciphertab.c gmactab.c ghashtab.c \
141 addsuffix(join(`ciphers', `-', `cipher_modes'), `.c') \
142 addsuffix(join(`ciphers', `-', `cipher_modes'), `.h') \
143 addsuffix(join(`hashes', `-', `hash_modes'), `.c') \
144 addsuffix(join(`hashes', `-', `hash_modes'), `.h')
145
146## --- Building the main library ---
147
148lib_LTLIBRARIES = libcatacomb.la
149
150libcatacomb_la_LDFLAGS = -version-info 3:0:1
151## Middle number is the patchlevel. Final number is the minor version. The
152## difference between the first and last numbers is major version.
153
154pkginclude_HEADERS = \
155 arena.h paranoia.h buf.h qdparse.h \
156 blkc.h hash.h gcipher.h ghash.h gmac.h grand.h ghash-def.h \
157 lcrand.h fibrand.h rc4.h seal.h rand.h noise.h fipstest.h maurer.h \
158 key.h key-error.h key-data.h passphrase.h pixie.h lmem.h \
159 mpx.h bitops.h mpw.h mpscan.h mparena.h mp.h mptext.h mpint.h \
160 exp.h mpbarrett.h mpmont.h mpreduce.h mp-exp.h \
161 mpcrt.h mprand.h mpmul.h \
162 gfx.h gf.h gfreduce.h gfn.h gf-exp.h \
163 primetab.h pfilt.h rabin.h \
164 pgen.h prim.h strongprime.h limlee.h keycheck.h \
165 bbs.h rsa.h dh.h dsarand.h dsa.h gdsa.h gkcdsa.h \
166 tlsprf.h sslprf.h \
167 gfshare.h share.h \
168 rho.h \
169 field.h field-guts.h field-exp.h \
170 ec.h ec-guts.h ec-exp.h ec-test.h ectab.h ec-keys.h ec-raw.h \
171 ptab.h bintab.h group.h group-guts.h \
172 allwithsuffix(`ciphers', `cipher_modes', `.h') \
173 allwithsuffix(`hashes', `hash_modes', `.h') \
174 addsuffix(`cipher_modes', `-def.h') \
175 addsuffix(`hash_modes', `-def.h') crc32.h
176
177define(`MP_SOURCES',
178 `mpx.c mpx-kmul.c mpx-ksqr.c mpscan.c mparena.c qdparse.c \
179 mp-misc.c mp-mem.c mp-const.c mp-io.c mp-arith.c mp-test.c \
180 mp-sqrt.c mp-gcd.c mp-jacobi.c mp-modsqrt.c mp-exp.c \
181 mpint.c mptext.c mptext-file.c mptext-string.c mptext-dstr.c \
182 mptext-len.c \
183 exp.c mpcrt.c mpmul.c mprand.c \
184 mpbarrett.c mpbarrett-exp.c mpbarrett-mexp.c mpbarrett-exp.h \
185 mpmont.c mpmont-exp.c mpmont-mexp.c mpmont-exp.h \
186 mpreduce.c mpreduce-exp.h \
187 group-stdops.c group-exp.c group-exp.h g-prime.c g-bin.c \
188 group-parse.c \
189 group-string.c group-file.c group-dstr.c \
190 rho.c buf.c ptab.c bintab.c \
191 GF_SOURCES PGEN_SOURCES EC_SOURCES')
192
193define(`GF_SOURCES',
194 `gfx.c gfx-kmul.c gfx-sqr.c gf-arith.c gf-exp.c gf-gcd.c \
195 gfreduce.c gfreduce-exp.h gfn.c')
196
197define(`EC_SOURCES',
198 `field.c field-parse.c field-exp.c \
199 f-prime.c f-niceprime.c f-binpoly.c \
200 ec.c ec-exp.c ec-prime.c ec-bin.c ec-test.c ec-info.c ectab.c \
201 ec-fetch.c ec-raw.c g-ec.c')
202
203define(`PGEN_SOURCES',
204 `pfilt.c rabin.c \
205 pgen.c pgen-stdev.c pgen-gcd.c pgen-simul.c \
206 prim.c strongprime.c limlee.c \
207 keycheck.c keycheck-mp.c keycheck-report.c \
208 bbs-rand.c bbs-gen.c bbs-jump.c bbs-fetch.c \
209 rsa-priv.c rsa-pub.c rsa-gen.c rsa-recover.c rsa-fetch.c \
210 oaep.c pkcs1.c pss.c \
211 dh-gen.c dh-limlee.c dh-kcdsa.c dh-check.c dh-fetch.c dh-param.c \
212 dsarand.c dsa-sign.c dsa-verify.c dsa-gen.c dsa-check.c \
213 gdsa.c gkcdsa.c \
214 key-data.c key-flags.c key-text.c key-binary.c key-pass.c \
215 key-pack.c key-misc.c key-file.c key-attr.c key-io.c key-moan.c \
216 key-error.c key-fetch.c \
217 primetab.c share.c')
218
219libcatacomb_la_SOURCES = \
220 grand.c keysz.c \
221 lcrand.c fibrand.c rc4.c seal.c rand.c noise.c fipstest.c maurer.c \
222 arena.c \
223 passphrase.c pixie-common.c lmem.c \
224 tlsprf.c sslprf.c \
225 gfshare.c \
226 MP_SOURCES karatsuba.h \
227 gciphertab.c ghashtab.c gmactab.c \
228 des-base.c des-base.h \
229 desx-tab.h \
230 rc2-tab.h \
231 skipjack-tab.h \
232 cast-s.c cast-sk.c cast-base.h cast-tab.h \
233 rijndael-base.c rijndael-base.h \
234 md2-tab.h \
235 serpent-sbox.h skipjack-tab.h tiger-base.h \
236 daftstory.h \
237 addsuffix(join(`ciphers', `-', `cipher_modes'), `.c') \
238 addsuffix(join(`hashes', `-', `hash_modes'), `.c') \
239 addsuffix(`ciphers', `.c') addsuffix(`hashes', `.c') crc32.c
240
241des-base.lo: des-tab.h
242blowfish.lo: blowfish-tab.h
243twofish.lo: twofish-tab.h
244square.lo: square-tab.h
245rijndael-base.lo: rijndael-tab.h
246whirlpool.lo: whirlpool-tab.h
247safer.lo: safer-tab.h
248mars.lo: mars-tab.h
249tiger.lo: tiger-tab.h
250gfshare.lo: gfshare-tab.h
251gfx-sqr.lo: gfx-sqr-tab.h
252
253## --- Utility programs ---
254
255bin_PROGRAMS = \
256 dsig key pixie cookie rspit factorial hashsum mkphrase \
257 catcrypt catsign
258noinst_LIBRARIES = libcatcrypt.a
259bin_SCRIPTS = catacomb-config xpixie
260noinst_PROGRAMS = \
261 genprimes mptypes serpent-check bittest mpdump \
262 perftest \
263 addsuffix(`gen_tables', `-mktab')
264LDADD = libcatcrypt.a libcatacomb.la
265
266define(`LIBCAT_SRC', `cc.h getdate.h dnl
267 cc-sig.c cc-subcmd.c cc-enc.c cc-kem.c cc-list.c')
268libcatcrypt_a_SOURCES = LIBCAT_SRC getdate.y
269
270patsubst(MP_SOURCES, `\.c\>', `.lo') dsig.o keyutil.o rspit.o \
271 patsubst(LIBCAT_SRC, `\.c\>', `.o'): \
272 mptypes.h primetab.h
273
274dsig_SOURCES = dsig.c
275cookie_SOURCES = cookie.c
276catcrypt_SOURCES = catcrypt.c
277catsign_SOURCES = catsign.c
278key_SOURCES = keyutil.c
279hashsum_SOURCES = hashsum.c
280rspit_SOURCES = rspit.c
281factorial_SOURCES = factorial.c
282perftest_SOURCES = perftest.c
283pixie_SOURCES = pixie.c pixie-common.c lmem.c arena.c passphrase.c
284pixie_LDADD =
285pixie_CFLAGS = $(AM_CFLAGS)
286mkphrase_SOURCES = mkphrase.c
287bittest_SOURCES = bittest.c
288bittest_LDADD =
289
290define(`emit', `
291patsubst(_item, `[^a-zA-Z0-9]', `_')_mktab_SOURCES = _item`'-mktab.c
292patsubst(_item, `[^a-zA-Z0-9]', `_')_mktab_LDADD =')dnl
293gen_tables
294
295serpent_check_SOURCES = serpent-check.c
296serpent_check_LDADD =
297
298genprimes_SOURCES = genprimes.c
299genprimes_LDADD =
300
301mptypes_SOURCES = mptypes.c
302mptypes_LDADD =
303
304mpdump_SOURCES = \
305 mpdump.c \
306 mpx.c mpx-kmul.c mpx-ksqr.c mpscan.c mparena.c \
307 mp-misc.c mp-mem.c mp-const.c mp-arith.c mp-io.c \
308 mptext.c mptext-string.c
309mpdump_LDADD =
310mpdump_CFLAGS = $(AM_CFLAGS)
311
312## --- Install the pixie setuid-root if we can ---
313##
314## Bodge around a bug in Automake: it doesn't call `install-exec-hook' from
315## `install' if there are subdirectories.
316
317changequote(<, >)
318# install: install-exec-hook
319install-exec-hook:
320 @pixie="$(DESTDIR)$(bindir)/`echo pixie|sed $(transform)`"; \
321 if chown root $$pixie && chmod 4755 $$pixie; then \
322 echo "chown root $$pixie"; \
323 echo "chmod 4755 $$pixie"; \
324 else \
325 echo "***"; \
326 echo "*** You should probably install $$pixie setuid-root."; \
327 echo "***"; \
328 fi
329changequote(`, ')
330
331## --- Documentation ---
332
333man_MANS = \
334 key.1 dsig.1 cookie.1 catcrypt.1 catsign.1 hashsum.1 mkphrase.1 \
335 keyring.5 pixie.1
336
337## --- Other handy definitions ---
338
339EXTRA_DIST = \
340 Makefile.m4 genmodes gengctab $(man_MANS) xpixie \
341 group-test.c rsa-test.c \
342 ectab.in ec-gentab.awk \
343 ptab.in p-gentab.awk \
344 bintab.in bin-gentab.awk \
345 README.cipher README.hash README.random README.mp \
346 debian/rules debian/copyright debian/control debian/changelog \
347 debian/catacomb-bin.postinst debian/catacomb-bin.config \
348 debian/catacomb-bin.prerm debian/catacomb-bin.templates
349
350dist-hook:
351 @for i in getdate.c gciphertab.c ghashtab.c gmactab.c; do \
352 ln $$i $(distdir) || ln $(srcdir)/$$i $(distdir) || true; \
353 done
354 @echo datestamp >$(distdir)/modes-stamp || true
355 @for i in calc tests; do \
356 mkdir $(distdir)/$$i; \
357 ln $(srcdir)/$$i/*[!~] $(distdir)/$$i; \
358 done || true
359# kr=$$HOME/.catacomb/dsig-keyring; \
360# if [ -r $$kr ]; then \
361# cd $(distdir); \
362# ../key -k $$kr extract -f -secret KEYRING; \
363# find . -type f -print0 | ../dsig -k $$kr sign -0 -oMANIFEST; \
364# fi
365
366## --- Testing ---
367
368define(`testprogs', `')
369
370define(`CTESTRIG',
371`define(`testprogs', testprogs \
372 $1.t$(EXEEXT))dnl
373$1.to: $1.c
374 $(COMPILE) -c -DTEST_RIG -DSRCDIR=\"$(srcdir)\" $(srcdir)/$1.c -o $1.to
375$1.t$(EXEEXT): $1.to libcatacomb.la
376 $(CC) $(CFLAGS) $(LDFLAGS) $1.to .libs/libcatacomb.a $(LIBS) -o $1.t$(EXEEXT)')
377
378CTESTRIG(rc4)
379CTESTRIG(seal)
380adorn(`nl`'CTESTRIG(', `ciphers', `)')
381adorn(`nl`'CTESTRIG(', `hashes', `)')
382adorn(`nl`'CTESTRIG(', join(`ciphers', `-', `cipher_modes'), `)')
383adorn(`nl`'CTESTRIG(', join(`hashes', `-', `hash_modes'), `)')
384CTESTRIG(lcrand)
385CTESTRIG(tlsprf)
386CTESTRIG(sslprf)
387CTESTRIG(mpx)
388CTESTRIG(mpx-kmul)
389CTESTRIG(mpx-ksqr)
390CTESTRIG(mp-arith)
391CTESTRIG(mp-modsqrt)
392CTESTRIG(mp-gcd)
393CTESTRIG(mp-jacobi)
394CTESTRIG(mp-sqrt)
395CTESTRIG(mptext)
396CTESTRIG(mpint)
397CTESTRIG(mpbarrett)
398CTESTRIG(mpbarrett-exp)
399CTESTRIG(mpbarrett-mexp)
400CTESTRIG(mpmont)
401CTESTRIG(mpmont-exp)
402CTESTRIG(mpmont-mexp)
403CTESTRIG(mpreduce)
404CTESTRIG(mpcrt)
405CTESTRIG(mpmul)
406CTESTRIG(rsa-test)
407CTESTRIG(gfx)
408CTESTRIG(gfx-sqr)
409CTESTRIG(gfx-kmul)
410CTESTRIG(gf-arith)
411CTESTRIG(gf-gcd)
412CTESTRIG(gfreduce)
413CTESTRIG(gfn)
414CTESTRIG(ec-prime)
415CTESTRIG(ec-bin)
416CTESTRIG(ec-test)
417CTESTRIG(ec-info)
418CTESTRIG(dh-param)
419CTESTRIG(group-test)
420CTESTRIG(gdsa)
421CTESTRIG(gkcdsa)
422CTESTRIG(pgen)
423CTESTRIG(dsa-gen)
424CTESTRIG(dsa-sign)
425CTESTRIG(dsa-verify)
426CTESTRIG(bbs-rand)
427CTESTRIG(bbs-jump)
428CTESTRIG(gfshare)
429CTESTRIG(share)
430CTESTRIG(rho)
431
432TESTS = serpent-check bittest testprogs
433
434CLEANFILES = \
435 *.t$(EXEEXT) *.to \
436 mptypes.h primetab.c primetab.h ectab.c ptab.c bintab.c \
437 addsuffix(`gen_tables', `-tab.h')
438
439## --- Makefile building (haha!) ---
440
441$(srcdir)/Makefile.am: $(srcdir)/Makefile.m4
442 m4 $(srcdir)/Makefile.m4 >$(srcdir)/Makefile.am.new
443 mv $(srcdir)/Makefile.am.new $(srcdir)/Makefile.am
444
445DISTCLEANFILES = libtool
446
447MAINTAINERCLEANFILES = \
448 $(srcdir)/Makefile.am \
449 $(srcdir)/getdate.c getdate.c \
450 $(MODES) modes-stamp $(srcdir)/modes-stamp
451
452##----- That's all, folks ---------------------------------------------------