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