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