0f2e3c3f53ddcb90677e5ff1f8ca38b9f740c354
[u/mdw/catacomb] / Makefile.m4
1 ## -*-makefile-*-
2 ##
3 ## $Id: Makefile.m4,v 1.57 2002/10/15 22:58:29 mdw Exp $
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 ##----- Revision history ----------------------------------------------------
30 ##
31 ## $Log: Makefile.m4,v $
32 ## Revision 1.57 2002/10/15 22:58:29 mdw
33 ## Fast estimation of number representation lengths.
34 ##
35 ## Revision 1.56 2001/06/16 13:01:10 mdw
36 ## New source files and tests.
37 ##
38 ## Revision 1.55 2001/05/08 22:17:41 mdw
39 ## New cipher Noekeon added.
40 ##
41 ## Revision 1.54 2001/05/07 17:32:52 mdw
42 ## New Rijndael block sizes.
43 ##
44 ## Revision 1.53 2001/04/29 18:11:19 mdw
45 ## New block cipher MARS.
46 ##
47 ## Revision 1.52 2001/04/29 17:37:35 mdw
48 ## Added SAFER block cipher.
49 ##
50 ## Revision 1.51 2001/04/19 18:26:32 mdw
51 ## Add CRC as another hash function.
52 ##
53 ## Revision 1.50 2001/04/06 22:05:10 mdw
54 ## Add support for SSL pseudo-random function.
55 ##
56 ## Revision 1.49 2001/04/04 20:10:52 mdw
57 ## Add support for the TLS pseudo-random function.
58 ##
59 ## Revision 1.48 2001/04/03 19:36:50 mdw
60 ## New block cipher DESX added.
61 ##
62 ## Revision 1.47 2001/03/03 13:14:13 mdw
63 ## Distribute md2-tab.h
64 ##
65 ## Revision 1.46 2001/02/21 20:03:22 mdw
66 ## Added support for MD2 hash function.
67 ##
68 ## Revision 1.45 2001/02/03 16:09:41 mdw
69 ## New files added.
70 ##
71 ## Revision 1.44 2000/10/15 17:49:00 mdw
72 ## New SHA variants with longer outputs.
73 ##
74 ## Revision 1.43 2000/10/08 16:01:26 mdw
75 ## Add binary poly arithmetic. Tidy table generation stuff. Distribute
76 ## calc prototypes.
77 ##
78 ## Revision 1.42 2000/10/08 12:16:06 mdw
79 ## Remove vestiges of @primorial@.
80 ##
81 ## Revision 1.41 2000/08/15 21:46:20 mdw
82 ## Set up the dependencies on primetab.[ch] and mptypes.h properly.
83 ## There's some m4 hacking, but it's worth it not to have to recompile all
84 ## the cipher modes.
85 ##
86 ## Revision 1.40 2000/08/06 10:50:55 mdw
87 ## (mkphrase): New program for generating random passphrases with measured
88 ## strength.
89 ##
90 ## Revision 1.39 2000/07/29 21:55:32 mdw
91 ## Make sure the pixie is installed setuid-root (workaround for an Automake
92 ## bug). Install new manpages.
93 ##
94 ## Revision 1.38 2000/07/29 10:54:55 mdw
95 ## Further fixing to support building using normal `make' again. ;-) I
96 ## think we're there now.
97 ##
98 ## Revision 1.37 2000/07/29 10:02:36 mdw
99 ## Lots of fixing to support `make -j' building.
100 ##
101 ## Revision 1.36 2000/07/20 20:13:38 mdw
102 ## Added Bellare and Rogaway's PSS encoding for RSA signatures.
103 ##
104 ## Revision 1.35 2000/07/16 20:00:46 mdw
105 ## Bug fixes to distribution.
106 ##
107 ## Revision 1.34 2000/07/15 20:55:32 mdw
108 ## More hashes and ciphers. An extra tool.
109 ##
110 ## Revision 1.33 2000/07/09 21:34:15 mdw
111 ## New hash functions and other stuff.
112 ##
113 ## Revision 1.32 2000/07/01 11:27:32 mdw
114 ## Name changes and new files.
115 ##
116 ## Revision 1.31 2000/06/25 13:02:07 mdw
117 ## Fix cleaning of generated files.
118 ##
119 ## Revision 1.30 2000/06/22 19:10:33 mdw
120 ## Fix Makefile to test mp-sqrt.c.
121 ##
122 ## Revision 1.29 2000/06/22 19:04:19 mdw
123 ## More new functions to be added.
124 ##
125 ## Revision 1.28 2000/06/18 23:31:18 mdw
126 ## Rearrange build order to ensure that `mptypes.h' exists by the time it's
127 ## needed.
128 ##
129 ## Revision 1.27 2000/06/17 13:28:50 mdw
130 ## Minor tidying and fixing.
131 ##
132 ## Revision 1.26 2000/06/17 10:33:43 mdw
133 ## Lots of new ciphers and other files.
134 ##
135 ## Revision 1.25 2000/02/12 18:55:40 mdw
136 ## Make it all compile properly.
137 ##
138 ## Revision 1.24 2000/02/12 18:22:26 mdw
139 ## Missed a file. Whoops.
140 ##
141 ## Revision 1.23 2000/02/12 18:21:01 mdw
142 ## Overhaul of key management (again).
143 ##
144 ## Revision 1.22 1999/12/22 16:04:06 mdw
145 ## Lots of new files.
146 ##
147 ## Revision 1.21 1999/12/13 15:47:58 mdw
148 ## Fix a couple of minor bugs in the distribution set.
149 ##
150 ## Revision 1.19 1999/12/11 10:58:24 mdw
151 ## Fix bug in test rig link flags. Add Karatsuba squaring.
152 ##
153 ## Revision 1.18 1999/12/10 23:30:01 mdw
154 ## Lots of new files.
155 ##
156 ## Revision 1.17 1999/11/25 11:38:31 mdw
157 ## Support for conversions between MPs and C integers.
158 ##
159 ## Revision 1.16 1999/11/22 20:51:33 mdw
160 ## Add yet more source files.
161 ##
162 ## Revision 1.15 1999/11/22 14:08:30 mdw
163 ## Improve dependencies for test programs.
164 ##
165 ## Revision 1.14 1999/11/22 00:17:09 mdw
166 ## Create object files for test programs so that rebuilding doesn't take so
167 ## long.
168 ##
169 ## Revision 1.12 1999/11/20 22:36:26 mdw
170 ## Improve dependencies. Move mpx testing into mpx.c.
171 ##
172 ## Revision 1.11 1999/11/20 22:24:53 mdw
173 ## Add Diffie-Hellman support.
174 ##
175 ## Revision 1.10 1999/11/19 19:28:24 mdw
176 ## Add DSA files and tests.
177 ##
178 ## Revision 1.9 1999/11/17 18:05:35 mdw
179 ## Many new files and test cases for multiprecision arithmetic.
180 ##
181 ## Revision 1.8 1999/11/13 01:56:07 mdw
182 ## Include multiprecision maths stuff.
183 ##
184 ## Revision 1.7 1999/11/11 19:01:02 mdw
185 ## Use `libtool' to generate a shared library.
186 ##
187 ## Revision 1.6 1999/11/11 17:47:34 mdw
188 ## Updates for new configuration system, and `mptypes' generator.
189 ##
190 ## Revision 1.5 1999/11/11 00:59:17 mdw
191 ## Minor reformatting.
192 ##
193 ## Revision 1.4 1999/10/24 10:20:36 mdw
194 ## Modify for standalone distribution. The library's getting far too large
195 ## to be sensibly embedded in other programs.
196 ##
197 ## Revision 1.3 1999/10/24 10:04:26 mdw
198 ## Install headers in the right directory.
199 ##
200 ## Revision 1.2 1999/10/23 12:55:35 mdw
201 ## The `CVS' directory can't be hardlinked. Don't worry about this
202 ## overmuch.
203 ##
204 ## Revision 1.1 1999/09/03 08:41:11 mdw
205 ## Initial import.
206 ##
207
208 AUTOMAKE_OPTIONS = foreign
209
210 SUBDIRS = tests
211
212 archincludedir = $(libdir)/catacomb/include
213
214 ## --- List handling macros ---
215 ##
216 ## List handling is nice, usually. Unfortunately, I based this design on
217 ## TeX list macros rather than anything sensible...
218
219 define(`_', `define(`_item', $1)define(`_item_2', $2)emit`'')
220 define(`adorn', `pushdef(`emit', `$1`'_item`'$3')$2`'popdef(`emit')')
221 define(`join',
222 `pushdef(`emit', `adorn(``_(''_item`$2', `$3', ``)'')`'')$1`'popdef(`emit')')
223 define(`addsuffix', `adorn(`', `$1', `$2')')
224 define(`lit', `adorn(`', `$1', `')')
225 define(`nl', `
226 ')
227
228 define(`allwithsuffix',
229 `addsuffix(`$1', `$3') addsuffix(`$2', `$3') dnl
230 addsuffix(join(`$1', `-', `$2'), `$3')')
231
232 ## --- Autogenerated source files ---
233
234 define(`ciphers', `dnl
235 _(des) _(desx) _(des3) _(mars) dnl
236 _(idea) _(safer) _(safersk) dnl
237 _(blowfish) _(twofish) dnl
238 _(tea) _(xtea) dnl
239 _(rc2) _(rc5) dnl
240 _(skipjack) dnl
241 _(cast128) _(cast256) dnl
242 _(square) _(rijndael) _(rijndael192) _(rijndael256) dnl
243 _(serpent) _(noekeon)')
244 define(`cipher_modes', `_(ecb) _(cbc) _(cfb) _(ofb) _(counter)')
245
246 define(`hashes', `dnl
247 _(md5) _(md4) _(md2) _(tiger) dnl
248 _(sha) _(sha256) _(sha384) _(sha512) dnl
249 _(rmd128) _(rmd160) _(rmd256) _(rmd320)')
250 define(`hash_modes', `_(mgf) _(hmac)')
251
252 MODES = \
253 adorn(`$(srcdir)/', join(`ciphers', `-', `cipher_modes'), `.c') \
254 adorn(`$(srcdir)/', join(`ciphers', `-', `cipher_modes'), `.h') \
255 adorn(`$(srcdir)/', join(`hashes', `-', `hash_modes'), `.c') \
256 adorn(`$(srcdir)/', join(`hashes', `-', `hash_modes'), `.h')
257
258 $(MODES): modes-stamp
259 modes-stamp: genmodes
260 cd $(srcdir); ./genmodes "lit(`ciphers')" "lit(`cipher_modes')"
261 cd $(srcdir); ./genmodes "lit(`hashes')" "lit(`hash_modes')"
262 echo datestamp >modes-stamp
263
264 define(`gen_tables', `dnl
265 _(des) _(blowfish) _(twofish) dnl
266 _(square) _(rijndael) dnl
267 _(safer) _(mars) _(tiger) dnl
268 _(gfshare) _(gfx-sqr)')
269
270 autoheaders: addsuffix(`gen_tables', `-tab.h') primetab.h mptypes.h
271 define(`emit', `
272 _item`'-tab.h: _item`'-mktab
273 ./_item`'-mktab >_item`'-tab.h')dnl
274 gen_tables
275
276 primetab.h: primetab.c
277 primetab.c: genprimes
278 ./genprimes -h primetab.h -c primetab.c -n 256 \
279 -t "unsigned short" -i primetab
280 archinclude_HEADERS = mptypes.h
281 mptypes.h: mptypes
282 ./mptypes >mptypes.h
283
284 BUILT_SOURCES = \
285 getdate.c modes-stamp \
286 addsuffix(join(`ciphers', `-', `cipher_modes'), `.c') \
287 addsuffix(join(`ciphers', `-', `cipher_modes'), `.h') \
288 addsuffix(join(`hashes', `-', `hash_modes'), `.c') \
289 addsuffix(join(`hashes', `-', `hash_modes'), `.h')
290
291 ## --- Building the main library ---
292
293 lib_LTLIBRARIES = libcatacomb.la
294
295 libcatacomb_la_LDFLAGS = -version-info 2:0:0
296 ## Middle number is the patchlevel. Final number is the minor version. The
297 ## difference between the first and last numbers is major version.
298
299 pkginclude_HEADERS = \
300 arena.h paranoia.h \
301 blkc.h hash.h gcipher.h ghash.h gmac.h grand.h ghash-def.h \
302 lcrand.h fibrand.h rc4.h seal.h rand.h noise.h fipstest.h maurer.h \
303 key.h key-data.h passphrase.h pixie.h lmem.h \
304 mpx.h mpw.h mpscan.h mparena.h mp.h mptext.h mpint.h \
305 exp.h mpbarrett.h mpmont.h mpcrt.h mprand.h mpmul.h \
306 gfx.h \
307 primetab.h pfilt.h rabin.h \
308 pgen.h prim.h strongprime.h limlee.h keycheck.h \
309 bbs.h rsa.h dh.h dsarand.h dsa.h \
310 oaep.h pkcs1.h pss.h tlsprf.h sslprf.h \
311 gfshare.h share.h \
312 rho.h \
313 allwithsuffix(`ciphers', `cipher_modes', `.h') \
314 allwithsuffix(`hashes', `hash_modes', `.h') \
315 addsuffix(`cipher_modes', `-def.h') \
316 addsuffix(`hash_modes', `-def.h') crc32.h
317
318 define(`MP_SOURCES',
319 `mpx.c mpx-kmul.c mpx-ksqr.c mpscan.c mparena.c \
320 mp-misc.c mp-mem.c mp-const.c mp-io.c mp-arith.c mp-test.c \
321 mp-sqrt.c mp-gcd.c mp-jacobi.c mp-modsqrt.c \
322 mpint.c mptext.c mptext-file.c mptext-string.c mptext-dstr.c \
323 mptext-len.c \
324 exp.c mpcrt.c mpmul.c mprand.c \
325 mpbarrett.c mpbarrett-mexp.c mpbarrett-exp.h \
326 mpmont.c mpmont-mexp.c mpmont-exp.h \
327 rho.c \
328 GF_SOURCES PGEN_SOURCES')
329
330 define(`GF_SOURCES',
331 `gfx.c gfx-kmul.c gfx-sqr.c')
332
333 define(`PGEN_SOURCES',
334 `pfilt.c rabin.c \
335 pgen.c pgen-stdev.c pgen-safe.c pgen-gcd.c prim.c strongprime.c \
336 limlee.c \
337 keycheck.c keycheck-mp.c keycheck-report.c \
338 bbs-rand.c bbs-gen.c bbs-jump.c bbs-fetch.c \
339 rsa-priv.c rsa-pub.c rsa-gen.c rsa-recover.c rsa-fetch.c \
340 dh-gen.c dh-limlee.c dh-check.c dh-fetch.c \
341 dsarand.c dsa-sign.c dsa-verify.c dsa-gen.c dsa-check.c \
342 key-data.c key-flags.c key-text.c key-binary.c key-pass.c \
343 key-pack.c key-misc.c key-file.c key-attr.c key-io.c key-moan.c \
344 key-error.c key-fetch.c \
345 primetab.c share.c')
346
347 libcatacomb_la_SOURCES = \
348 grand.c keysz.c \
349 lcrand.c fibrand.c rc4.c seal.c rand.c noise.c fipstest.c maurer.c \
350 arena.c \
351 passphrase.c pixie-client.c pixie-common.c lmem.c \
352 oaep.c pkcs1.c pss.c tlsprf.c sslprf.c \
353 gfshare.c \
354 MP_SOURCES karatsuba.h \
355 des-base.c des-base.h \
356 cast-s.c cast-sk.c cast-base.h cast-tab.h \
357 rijndael-base.c rijndael-base.h \
358 md2-tab.h \
359 serpent-sbox.h skipjack-tab.h tiger-base.h \
360 daftstory.h \
361 addsuffix(join(`ciphers', `-', `cipher_modes'), `.c') \
362 addsuffix(join(`hashes', `-', `hash_modes'), `.c') \
363 addsuffix(`ciphers', `.c') addsuffix(`hashes', `.c') crc32.c
364
365 des-base.lo: des-tab.h
366 blowfish.lo: blowfish-tab.h
367 twofish.lo: twofish-tab.h
368 square.lo: square-tab.h
369 rijndael-base.lo: rijndael-tab.h
370 safer.lo: safer-tab.h
371 mars.lo: mars-tab.h
372 tiger.lo: tiger-tab.h
373 gfshare.lo: gfshare-tab.h
374 gfx-sqr.lo: gfx-sqr-tab.h
375 patsubst(MP_SOURCES, `\.c\>', `.lo') dsig.o keyutil.o rspit.o: mptypes.h
376 patsubst(PGEN_SOURCES, `\.c\>', `.lo') dsig.o keyutil.o rspit.o: primetab.h
377
378 ## --- Utility programs ---
379
380 bin_PROGRAMS = dsig key pixie rspit factorial hashsum mkphrase
381 bin_SCRIPTS = catacomb-config xpixie
382 noinst_PROGRAMS = \
383 genprimes mptypes serpent-check \
384 addsuffix(`gen_tables', `-mktab')
385 LDADD = libcatacomb.la
386
387 dsig_SOURCES = dsig.c getdate.y getdate.h
388 key_SOURCES = keyutil.c getdate.y getdate.h
389 hashsum_SOURCES = hashsum.c
390 rspit_SOURCES = rspit.c
391 factorial_SOURCES = factorial.c
392 pixie_SOURCES = pixie.c pixie-common.c lmem.c arena.c
393 pixie_LDADD =
394 mkphrase_SOURCES = mkphrase.c
395
396 define(`emit', `
397 patsubst(_item, `[^a-zA-Z0-9]', `_')_mktab_SOURCES = _item`'-mktab.c
398 patsubst(_item, `[^a-zA-Z0-9]', `_')_mktab_LDADD =')dnl
399 gen_tables
400
401 serpent_check_SOURCES = serpent-check.c
402 serpent_check_LDADD =
403
404 genprimes_SOURCES = genprimes.c
405 genprimes_LDADD =
406
407 mptypes_SOURCES = mptypes.c
408 mptypes_LDADD =
409
410 ## --- Install the pixie setuid-root if we can ---
411 ##
412 ## Bodge around a bug in Automake: it doesn't call `install-exec-hook' from
413 ## `install' if there are subdirectories.
414
415 changequote(<, >)
416 install: install-exec-hook
417 install-exec-hook:
418 @pixie="$(bindir)/`echo pixie|sed $(transform)`"; \
419 if chown root $$pixie && chmod 4755 $$pixie; then \
420 echo "chown root $$pixie"; \
421 echo "chmod 4755 $$pixie"; \
422 else \
423 echo "***"; \
424 echo "*** You should probably install $$pixie setuid-root."; \
425 echo "***"; \
426 fi
427 changequote(`, ')
428
429 ## --- Documentation ---
430
431 man_MANS = key.1 hashsum.1 keyring.5 pixie.1
432
433 ## --- Other handy definitions ---
434
435 EXTRA_DIST = \
436 Makefile.m4 genmodes $(man_MANS) xpixie \
437 README.cipher README.hash README.random README.mp
438
439 dist-hook:
440 @ln getdate.c $(distdir) || ln $(srcdir)/getdate.c $(distdir) || true
441 @echo datestamp >$(distdir)/modes-stamp || true
442 @for i in calc tests; do \
443 mkdir $(distdir)/$$i; \
444 ln $(srcdir)/$$i/*[!~] $(distdir)/$$i; \
445 done || true
446 # kr=$$HOME/.catacomb/dsig-keyring; \
447 # if [ -r $$kr ]; then \
448 # cd $(distdir); \
449 # ../key -k $$kr extract -f -secret KEYRING; \
450 # find . -type f -print0 | ../dsig -k $$kr sign -0 -oMANIFEST; \
451 # fi
452
453 ## --- Testing ---
454
455 define(`testprogs', `')
456
457 define(`CTESTRIG',
458 `define(`testprogs', testprogs \
459 $1.t)dnl
460 $1.to: $1.c
461 $(COMPILE) -c -DTEST_RIG -DSRCDIR=\"$(srcdir)\" $(srcdir)/$1.c -o $1.to
462 $1.t: $1.to $1.o libcatacomb.la
463 $(CC) $(CFLAGS) $(LDFLAGS) $1.to .libs/libcatacomb.a $(LIBS) -o $1.t')
464
465 CTESTRIG(rc4)
466 CTESTRIG(seal)
467 adorn(`nl`'CTESTRIG(', `ciphers', `)')
468 adorn(`nl`'CTESTRIG(', `hashes', `)')
469 adorn(`nl`'CTESTRIG(', join(`ciphers', `-', `cipher_modes'), `)')
470 adorn(`nl`'CTESTRIG(', join(`hashes', `-', `hash_modes'), `)')
471 CTESTRIG(lcrand)
472 CTESTRIG(oaep)
473 CTESTRIG(tlsprf)
474 CTESTRIG(sslprf)
475 CTESTRIG(mpx)
476 CTESTRIG(mpx-kmul)
477 CTESTRIG(mpx-ksqr)
478 CTESTRIG(mp-arith)
479 CTESTRIG(mp-modsqrt)
480 CTESTRIG(mp-gcd)
481 CTESTRIG(mp-jacobi)
482 CTESTRIG(mp-sqrt)
483 CTESTRIG(mptext)
484 CTESTRIG(mpint)
485 CTESTRIG(mpbarrett)
486 CTESTRIG(mpbarrett-mexp)
487 CTESTRIG(mpmont)
488 CTESTRIG(mpmont-mexp)
489 CTESTRIG(mpcrt)
490 CTESTRIG(mpmul)
491 CTESTRIG(gfx)
492 CTESTRIG(gfx-kmul)
493 CTESTRIG(pgen)
494 CTESTRIG(dsa-gen)
495 CTESTRIG(dsa-sign)
496 CTESTRIG(dsa-verify)
497 CTESTRIG(bbs-rand)
498 CTESTRIG(bbs-jump)
499 CTESTRIG(gfshare)
500 CTESTRIG(share)
501 CTESTRIG(rho)
502
503 TESTS = serpent-check testprogs
504
505 CLEANFILES = \
506 *.t *.to \
507 mptypes.h primetab.c primetab.h \
508 addsuffix(`gen_tables', `-tab.h')
509
510 ## --- Makefile building (haha!) ---
511
512 $(srcdir)/Makefile.am: $(srcdir)/Makefile.m4
513 m4 $(srcdir)/Makefile.m4 >$(srcdir)/Makefile.am
514
515 DISTCLEANFILES = libtool
516
517 MAINTAINERCLEANFILES = \
518 $(srcdir)/Makefile.am \
519 $(srcdir)/getdate.c getdate.c \
520 $(MODES) modes-stamp $(srcdir)/modes-stamp
521
522 ##----- That's all, folks ---------------------------------------------------