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