]> pd.if.org Git - zpackage/blob - Makefile
package signature work
[zpackage] / Makefile
1 CC=clang --target=x86_64-pc-linux-musl
2 CC=/usr/musl/bin/musl-clang
3 LD=lld
4 #CC=/usr/musl/bin/musl-gcc
5 #CFLAGS=-Wall -W -Wextra -Werror -Wno-implicit-fallthrough -std=c99 -Ilib -Isqlite -Ielf -I. -Ilzma/api --target=x86_64-pc-linux-musl
6 CFLAGS=-Wall -W -Wextra -Werror -Wno-implicit-fallthrough -std=c99 -Ilib -Isqlite -Ielf -I. -Ilzma/api -Wno-unused-command-line-argument
7
8 ZPMVER:=$(shell git describe --tags --match 'v[0-9]*' | sed -e 's/^v//' | sed -e 's/-g.\+//' | sed -e 's/-/./g')
9
10 LZMAFLAGS=-Ilzma/api -Ilzma/tuklib -Ilzma/lzma -Ilzma/common -Ilzma/check -Ilzma/lz -Ilzma/rangecoder -Ilzma/simple -Ilzma/delta -DHAVE_CHECK_CRC64 -DHAVE_CHECK_CRC32 -DHAVE_ENCODER_LZMA2 -DHAVE_DECODER_LZMA2 -DHAVE_MF_BT4
11
12 #LDFLAGS=-fuse-ld=lld -L. -static
13 LDFLAGS=-fuse-ld=/usr/musl/bin/ld.musl-clang -L. -static
14
15 LZMACHECKSRC=lzma/check/check.c lzma/check/crc32_fast.c lzma/check/crc64_fast.c lzma/check/crc32_table.c lzma/check/crc64_table.c
16 LZMASRC=$(shell ls lzma/lzma/*.c lzma/common/*.c lzma/lz/*.c) $(LZMACHECKSRC) lzma/rangecoder/price_table.c
17 LZMAOBJ=$(filter-out lzma/common/stream_encoder_mt.o, $(LZMASRC:%.c=%.o))
18
19 JSWSRC=lib/jsw/jsw_avltree.c \
20 lib/jsw/jsw_atree.c \
21 lib/jsw/jsw_hlib.c \
22 lib/jsw/jsw_rbtree.c
23
24 JSWOBJ=$(JSWSRC:%.c=%.o)
25 LIBZPMSRC=sha256.c db.c compress.c uncompress.c zpm.c zpm_hash.c \
26           foreach_path.c vercmp.c findpkg.c quote.c dbquery.c script_hash.c \
27           parse.c integ.c seterror.c notes.c createpkg.c buffer.c \
28           blake2/ref/blake2b-ref.o
29
30 LIBZPMOBJ=$(addprefix lib/, $(LIBZPMSRC:%.c=%.o))
31
32 curdir=$(shell pwd)
33
34 ZPKGBIN=zpm-addfile zpm-extract zpm-init zpm-vercmp zpm-stat zpm-hash \
35         zpm-findpkg zpm-shell zpm-soneed zpm-foreach-path zpm-parse \
36         zpm-script zpm-soname zpm-syncfs zpm-packagehash zpm-verify \
37         zpm-elftype zpm-quote zpm-note zpm-search zpm-add zpm-fetchurl \
38         zpm-sign
39
40 SCRIPTS=zpm zpm-install zpm-merge zpm-list zpm-test zpm-log \
41         zpm-contents zpm-uninstall zpm-pathmod zpm-rmpackage zpm-newpackage \
42         zpm-pkg zpm-pkgfile zpm-gc zpm-repo zpm-update zpm-confgit \
43         zpm-pkgdeps
44
45 MANPAGES=$(shell ls doc/*.8)
46 #MANPAGES=doc/zpm.8 $(addprefix doc/zpm-, list.8 contents.8 hash.8 quote.8 pathmod.8 note.8 vercmp.8 repo.8 gc.8)
47 COMPILED=$(ZPKGBIN)
48 PROGRAMS=$(SCRIPTS) $(COMPILED)
49
50 def: programs
51         strip $(ZPKGBIN)
52
53 d:
54         printf '%s\n' $(LZMAOBJ)
55         printf '%s\n' $(PATH)
56
57 libzpm.a: $(LIBZPMOBJ) sqlite/sqlite3.o \
58         $(LZMAOBJ) \
59         $(JSWOBJ)
60         ar rcuv $@ $?
61
62 package: zpm-$(ZPMVER)-1.zpm
63
64 lzmaupdate:
65         find xz/src/liblzma -type d -name .deps -prune \
66                 -o -type f -printf '%P\n' \
67                 | xargs -IZ echo Z Z Z \
68                 | xargs printf 'test -e lzma/%s && cp xz/src/liblzma/%s lzma/%s\n' \
69                 | sh
70
71 #lzma/lz/lz_decoder.o: lzma/lz/lz_decoder.c
72 #lzma/lz/lz_encoder.o: lzma/lz/lz_encoder.c
73
74 lzma/%.o: lzma/%.c
75         $(CC) $(CFLAGS) $(LZMAFLAGS) -c -o $@ $<
76
77 lib/liblzma.a: $(LZMAOBJ)
78         ar rcuv $@ $?
79
80 lib/libjsw.a: $(JSWOBJ)
81         ar rcuv $@ $?
82
83 ZPM:= ./zpm -P.
84
85 zpm-$(ZPMVER)-1.zpm: programs $(MANPAGES)
86         rm -f $@
87         $(ZPM) newpackage -C zpm-$(ZPMVER)-1
88         $(ZPM) add -v -u root -g root -f $@ -P /sbin zpm-$(ZPMVER)-1 $(sort $(PROGRAMS))
89         $(ZPM) add -v -u root -g root -f $@ -P /usr/share/man/man8 -S doc $(MANPAGES)
90
91 tarball: zpm-$(ZPMVER)-1.tar.xz
92
93 zpm-$(ZPMVER)-1.tar.xz: programs
94         rm -f $@
95         tar -cJf $@ --transform='s|^|sbin/|' \
96                 $(PROGRAMS)
97
98 lzma.c: mklzma
99         sh mklzma
100
101 lzma.o: lzma.c
102         gcc -std=c99 -Wall -c -o $@ $<
103
104 stest: $(ZPKGBIN)
105         PATH=$(curdir)/t:$(curdir):$(PATH) t/$(T).t
106
107 t/ctap/prove: t/ctap/prove.o
108         $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $+
109
110 test: $(ZPKGBIN) t/ctap/prove
111         @PATH=$(curdir)/t:$(curdir):$(PATH) t/ctap/prove t/*.t
112
113 programs: $(ZPKGBIN)
114
115 uncompress: uncompress.o 
116         $(CC) $(CFLAGS) -o $@ $+ -llzma
117
118 zpm-elftype: elf/elftype.o
119         $(CC) $(CFLAGS) -Ielf $(LDFLAGS) -o $@ $+
120
121 zpm-soname: elf/soname.o
122         $(CC) $(CFLAGS) -Ielf $(LDFLAGS) -o $@ $+
123
124 zpm-soneed: elf/needed.o
125         $(CC) $(CFLAGS) -Ielf $(LDFLAGS) -o $@ $+
126
127 zpm-addfile: src/addfile.o libzpm.a libelf.a
128         $(CC) -Ielf $(CFLAGS) $(LDFLAGS) -o $@ $< -lzpm -lelf
129
130 lib/sha256.o: CFLAGS+=-O3
131 lib/blake2/ref/blake2b-ref.o: CFLAGS+=-O3
132
133 zpm-hash: libzpm.a
134 zpm-hash: src/hash.o lib/sha256.o
135         $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< -lzpm
136
137 zpm-blake2: src/blake2.o lib/sha256.o lib/blake2/ref/blake2b-ref.o
138         $(CC) -O3 $(CFLAGS) $(LDFLAGS) -o $@ $+
139
140 zpm-verify: src/verify.o t/ctap/ctap.o libzpm.a
141         $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< t/ctap/ctap.o -lzpm -lelf
142
143 zpm-init: src/init.o libzpm.a
144         $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< -lzpm -lelf
145
146 zpm-stat: src/stat.o
147         $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $<
148
149 zpm-extract: src/extract.o libzpm.a
150         $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< -lzpm -lelf
151
152 zpm-script: src/script.o libzpm.a
153         $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< -lzpm -lelf
154         
155 zpm-packagehash: src/packagehash.o libzpm.a
156         $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< -lzpm -lelf
157
158 src/foreach-path.o: CFLAGS+=-Wno-unused-parameter
159 src/script.o: CFLAGS+=-Wno-unused-parameter
160
161 zpm-foreach-path: src/foreach-path.o libzpm.a sqlite/sqlite3.h
162         $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< -lzpm -lelf
163
164 zpm-findpkg: src/findpkg.o libzpm.a
165         $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< -lzpm -lelf
166
167 zpm-search: src/search.o libzpm.a
168         $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< -lzpm -lelf
169
170 zpm-note: src/note.o libzpm.a
171         $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< -lzpm -lelf
172
173 zpm-syncfs: src/syncfs.o libzpm.a libelf.a
174         $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< -lzpm -lelf -lm
175
176 zpm-parse: src/parse.o lib/parse.o
177         $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $+
178
179 zpm-add: src/add.o libzpm.a libelf.a
180         $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< -lzpm -lelf
181
182 zpm-quote: src/quote.o
183         $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $<
184
185 db.sql: schema/main.sql schema/syncconflicts.sql schema/syncinfo.sql schema/preserve_packages.sql schema/age.sql schema/sign.sql
186         echo 'begin;' > $@
187         cat $+ >> $@
188         echo 'commit;' >> $@
189
190 newdb.c: db.sql
191         echo "char createdb[] = {" > $@
192         xxd -i < $< >> $@
193         echo ", 0};" >> $@
194
195 sqlite/sqlite3.o: sqlite/sqlite3.c sqlite/config.h
196         $(CC) -Wall -Wno-unused-command-line-argument -std=c99 -Ilib -D_HAVE_SQLITE_CONFIG_H=1 -c -o $@ $<
197
198 sqlite/extensions.o: sqlite/extensions.c
199         $(CC) -O3 -Wall -std=c99 -I. -Isqlite -DSQLITE_CORE=1 -c -o $@ $<
200
201 sqlite/shell.o: sqlite/shell.c sqlite/config.h Makefile
202         $(CC) -Wall -Wno-unused-command-line-argument -std=c99 -Ilib \
203                 -DSQLITE_OMIT_LOAD_EXTENSION=1 \
204                 '-DSQLITE_SHELL_INIT_PROC(x)=zpm_setup_extensions(x)' \
205                 -D_POSIX_C_SOURCE=200112L -c -o $@ $<
206
207 lib/zpm.o: newdb.c
208
209 zpm-vercmp: src/vercmp.o lib/vercmp.o lib/parse.o
210         $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $+
211         
212 zpm-shell: sqlite/sqlite3.o sqlite/shell.o sqlite/extensions.o lib/vercmp.o lib/parse.o
213         $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $+
214
215 libelf.a: elf/libelf.o
216         ar rcuv $@ $?
217
218 install: $(COMPILED) $(MANPAGES)
219         test -d $(DESTDIR)/sbin || install -d $(DESTDIR)/sbin
220         test -d $(DESTDIR)/var/lib/zpm || install -d $(DESTDIR)/var/lib/zpm
221         test -d $(DESTDIR)/var/lib/zpm/packages || install -d $(DESTDIR)/var/lib/zpm/packages
222         install $(PROGRAMS) $(DESTDIR)/sbin
223         mkdir -p $(DESTDIR)/usr/share/man/man8
224         install -m644 $(MANPAGES) $(DESTDIR)/usr/share/man/man8
225
226 scan-prep: clean sqlite/sqlite3.o sqlite/shell.o lib/liblzma.a
227         @echo scan-build -v -o report make -j10
228
229 # crypto/tls items
230 X255OBJ= \
231 base.o \
232 fe_0.o \
233 fe_1.o \
234 fe_add.o \
235 fe_copy.o \
236 fe_cswap.o \
237 fe_frombytes.o \
238 fe_invert.o \
239 fe_mul.o \
240 fe_mul121666.o \
241 fe_sq.o \
242 fe_sub.o \
243 fe_tobytes.o \
244 scalarmult.o
245
246 TLSOBJ= tlse.o x25519.o chacha.o base64.o pem.o forward.o handshake.o \
247         buffer.o parse_client_hello.o parse_message.o cipher_supported.o \
248         packet_update.o hmac_message.o hkdf.o hash.o cipher_name.o
249
250 crypto/x25519.o: $(addprefix crypto/ref10/, $(X255OBJ))
251         ld -o $@ -r $+
252
253 crypto/%.o: CFLAGS+=-Icrypto -DTFM_DESC -DTFM_NO_ASM \
254         -Itomsfastmath/src/headers \
255         -Wno-pointer-sign -Wno-missing-braces -Ilibtomcrypt/src/headers
256
257 #       -DDEBUG
258
259 #       /usr/musl/bin/musl-clang -Wall -Wextra -Wno-missing-braces -Werror -Wno-pointer-sign -I. -DTFM_DESC -DTFM_NO_ASM -I ../libtomcrypt/src/headers -I ../tomsfastmath/src/headers -DSTRICT_TLS -DIGNORE_SESSION_ID --rtlib=compiler-rt   -c -o tlse.o tlse.c
260
261 #/usr/musl/bin/musl-clang -Wall -Wextra -Wno-missing-braces -Werror -Wno-pointer-sign -I. -DTFM_DESC -DTFM_NO_ASM -I ../libtomcrypt/src/headers -I ../tomsfastmath/src/headers -DSTRICT_TLS -DIGNORE_SESSION_ID --rtlib=compiler-rt   -c -o tlse.o tlse.c
262
263 tls.o: $(addprefix crypto/, $(TLSOBJ))
264         ld -o $@ -r $+
265
266 TFMOBJ= \
267    addsub/fp_add.o \
268    addsub/fp_add_d.o \
269    addsub/fp_addmod.o \
270    addsub/fp_cmp.o \
271    addsub/fp_cmp_d.o \
272    addsub/fp_cmp_mag.o \
273    addsub/fp_sub.o \
274    addsub/fp_sub_d.o \
275    addsub/fp_submod.o \
276    addsub/s_fp_add.o \
277    addsub/s_fp_sub.o \
278    bin/fp_radix_size.o \
279    bin/fp_read_radix.o \
280    bin/fp_read_signed_bin.o \
281    bin/fp_reverse.o \
282    bin/fp_read_unsigned_bin.o \
283    bin/fp_signed_bin_size.o \
284    bin/fp_s_rmap.o \
285    bin/fp_toradix.o \
286    bin/fp_toradix_n.o \
287    bin/fp_to_signed_bin.o \
288    bin/fp_to_unsigned_bin.o \
289    bin/fp_unsigned_bin_size.o \
290    bit/fp_cnt_lsb.o \
291    bit/fp_count_bits.o \
292    bit/fp_div_2.o \
293    bit/fp_div_2d.o \
294    bit/fp_lshd.o \
295    bit/fp_mod_2d.o \
296    bit/fp_rshd.o \
297    divide/fp_div.o \
298    divide/fp_div_d.o \
299    divide/fp_mod.o \
300    divide/fp_mod_d.o \
301    exptmod/fp_2expt.o \
302    exptmod/fp_exptmod.o \
303    misc/fp_ident.o \
304    misc/fp_rand.o \
305    misc/fp_set.o \
306    mont/fp_montgomery_calc_normalization.o \
307    mont/fp_montgomery_reduce.o \
308    mont/fp_montgomery_setup.o \
309    mul/fp_mul_2.o \
310    mul/fp_mul_2d.o \
311    mul/fp_mul.o \
312    mul/fp_mul_comba_12.o \
313    mul/fp_mul_comba_17.o \
314    mul/fp_mul_comba_20.o \
315    mul/fp_mul_comba_24.o \
316    mul/fp_mul_comba_28.o \
317    mul/fp_mul_comba_32.o \
318    mul/fp_mul_comba_3.o \
319    mul/fp_mul_comba_48.o \
320    mul/fp_mul_comba_4.o \
321    mul/fp_mul_comba_64.o \
322    mul/fp_mul_comba_6.o \
323    mul/fp_mul_comba_7.o \
324    mul/fp_mul_comba_8.o \
325    mul/fp_mul_comba.o \
326    mul/fp_mul_comba_small_set.o \
327    mul/fp_mul_d.o \
328    mul/fp_mul_comba_9.o \
329    mul/fp_mulmod.o \
330    numtheory/fp_gcd.o \
331    numtheory/fp_invmod.o \
332    numtheory/fp_isprime.o \
333    numtheory/fp_isprime_ex.o \
334    numtheory/fp_lcm.o \
335    numtheory/fp_prime_miller_rabin.o \
336    numtheory/fp_prime_random_ex.o \
337    sqr/fp_sqr.o \
338    sqr/fp_sqr_comba_12.o \
339    sqr/fp_sqr_comba_17.o \
340    sqr/fp_sqr_comba_20.o \
341    sqr/fp_sqr_comba_24.o \
342    sqr/fp_sqr_comba_28.o \
343    sqr/fp_sqr_comba_32.o \
344    sqr/fp_sqr_comba_48.o \
345    sqr/fp_sqr_comba_3.o \
346    sqr/fp_sqr_comba_4.o \
347    sqr/fp_sqr_comba_64.o \
348    sqr/fp_sqr_comba_6.o \
349    sqr/fp_sqr_comba_7.o \
350    sqr/fp_sqr_comba_8.o \
351    sqr/fp_sqr_comba_9.o \
352    sqr/fp_sqr_comba.o \
353    sqr/fp_sqr_comba_generic.o \
354    sqr/fp_sqr_comba_small_set.o \
355    sqr/fp_sqrmod.o
356
357 tomsfastmath/src/addsub/%.o: CFLAGS+=-DTFM_DESC -DTFM_NO_ASM -Itomsfastmath/src/headers -DARGTYPE=4
358 tomsfastmath/src/%.o: CFLAGS+=-DTFM_DESC -DTFM_NO_ASM -Itomsfastmath/src/headers -DARGTYPE=4
359
360 tfm.o: $(addprefix tomsfastmath/src/, $(TFMOBJ))
361         ld -o $@ -r $+
362
363 LTCOBJ= \
364    ciphers/aes/aes.o \
365    ciphers/anubis.o \
366    ciphers/blowfish.o \
367    ciphers/camellia.o \
368    ciphers/cast5.o \
369    ciphers/des.o \
370    ciphers/kasumi.o \
371    ciphers/khazad.o \
372    ciphers/kseed.o \
373    ciphers/multi2.o \
374    ciphers/noekeon.o \
375    ciphers/rc2.o \
376    ciphers/rc5.o \
377    ciphers/rc6.o \
378    ciphers/safer/safer.o \
379    ciphers/safer/saferp.o \
380    ciphers/skipjack.o \
381    ciphers/twofish/twofish.o \
382    ciphers/xtea.o \
383    encauth/ccm/ccm_add_aad.o \
384    encauth/ccm/ccm_add_nonce.o \
385    encauth/ccm/ccm_done.o \
386    encauth/ccm/ccm_init.o \
387    encauth/ccm/ccm_memory.o \
388    encauth/ccm/ccm_process.o \
389    encauth/ccm/ccm_reset.o \
390    encauth/ccm/ccm_test.o \
391    encauth/chachapoly/chacha20poly1305_add_aad.o \
392    encauth/chachapoly/chacha20poly1305_decrypt.o \
393    encauth/chachapoly/chacha20poly1305_done.o \
394    encauth/chachapoly/chacha20poly1305_encrypt.o \
395    encauth/chachapoly/chacha20poly1305_init.o \
396    encauth/chachapoly/chacha20poly1305_memory.o \
397    encauth/chachapoly/chacha20poly1305_setiv.o \
398    encauth/chachapoly/chacha20poly1305_setiv_rfc7905.o \
399    encauth/chachapoly/chacha20poly1305_test.o \
400    encauth/eax/eax_addheader.o \
401    encauth/eax/eax_decrypt.o \
402    encauth/eax/eax_decrypt_verify_memory.o \
403    encauth/eax/eax_done.o \
404    encauth/eax/eax_encrypt.o \
405    encauth/eax/eax_encrypt_authenticate_memory.o \
406    encauth/eax/eax_init.o \
407    encauth/eax/eax_test.o \
408    encauth/gcm/gcm_add_aad.o \
409    encauth/gcm/gcm_add_iv.o \
410    encauth/gcm/gcm_done.o \
411    encauth/gcm/gcm_gf_mult.o \
412    encauth/gcm/gcm_init.o \
413    encauth/gcm/gcm_memory.o \
414    encauth/gcm/gcm_mult_h.o \
415    encauth/gcm/gcm_process.o \
416    encauth/gcm/gcm_reset.o \
417    encauth/gcm/gcm_test.o \
418    misc/crypt/crypt_find_cipher_id.o \
419    misc/crypt/crypt_find_hash_any.o \
420    misc/crypt/crypt_find_hash.o \
421    encauth/ocb/ocb_decrypt.o \
422    encauth/ocb/ocb_decrypt_verify_memory.o \
423    encauth/ocb/ocb_done_decrypt.o \
424    encauth/ocb/ocb_done_encrypt.o \
425    misc/crypt/crypt_find_hash_id.o \
426    misc/crypt/crypt_find_hash_oid.o \
427    encauth/ocb/ocb_encrypt.o \
428    encauth/ocb/ocb_encrypt_authenticate_memory.o \
429    encauth/ocb/ocb_init.o \
430    encauth/ocb/ocb_ntz.o \
431    encauth/ocb/ocb_shift_xor.o \
432    encauth/ocb/ocb_test.o \
433    encauth/ocb/s_ocb_done.o \
434    encauth/ocb3/ocb3_add_aad.o \
435    encauth/ocb3/ocb3_decrypt.o \
436    encauth/ocb3/ocb3_decrypt_last.o \
437    encauth/ocb3/ocb3_decrypt_verify_memory.o \
438    encauth/ocb3/ocb3_done.o \
439    encauth/ocb3/ocb3_encrypt.o \
440    encauth/ocb3/ocb3_encrypt_authenticate_memory.o \
441    encauth/ocb3/ocb3_encrypt_last.o \
442    encauth/ocb3/ocb3_init.o \
443    encauth/ocb3/ocb3_int_ntz.o \
444    encauth/ocb3/ocb3_int_xor_blocks.o \
445    encauth/ocb3/ocb3_test.o \
446    hashes/blake2b.o \
447    hashes/blake2s.o \
448    hashes/chc/chc.o \
449    hashes/helper/hash_file.o \
450    hashes/helper/hash_filehandle.o \
451    hashes/helper/hash_memory.o \
452    hashes/helper/hash_memory_multi.o \
453    hashes/md2.o \
454    hashes/md4.o \
455    hashes/md5.o \
456    hashes/rmd128.o \
457    hashes/rmd160.o \
458    hashes/rmd256.o \
459    hashes/rmd320.o \
460    hashes/sha1.o \
461    hashes/sha2/sha224.o \
462    hashes/sha2/sha256.o \
463    hashes/sha2/sha384.o \
464    hashes/sha2/sha512.o \
465    hashes/sha2/sha512_224.o \
466    hashes/sha2/sha512_256.o \
467    hashes/sha3.o \
468    hashes/sha3_test.o \
469    hashes/tiger.o \
470    hashes/whirl/whirl.o \
471    mac/blake2/blake2bmac.o \
472    mac/blake2/blake2bmac_file.o \
473    mac/blake2/blake2bmac_memory.o \
474    mac/blake2/blake2bmac_memory_multi.o \
475    mac/blake2/blake2bmac_test.o \
476    mac/blake2/blake2smac.o \
477    mac/blake2/blake2smac_file.o \
478    mac/blake2/blake2smac_memory.o \
479    mac/blake2/blake2smac_memory_multi.o \
480    mac/blake2/blake2smac_test.o \
481    mac/f9/f9_done.o \
482    mac/f9/f9_file.o \
483    mac/f9/f9_init.o \
484    mac/f9/f9_memory.o \
485    mac/f9/f9_memory_multi.o \
486    mac/f9/f9_process.o \
487    mac/f9/f9_test.o \
488    mac/hmac/hmac_done.o \
489    mac/hmac/hmac_file.o \
490    mac/hmac/hmac_init.o \
491    mac/hmac/hmac_memory.o \
492    mac/hmac/hmac_memory_multi.o \
493    mac/hmac/hmac_process.o \
494    mac/hmac/hmac_test.o \
495    mac/omac/omac_done.o \
496    mac/omac/omac_file.o \
497    mac/omac/omac_init.o \
498    mac/omac/omac_memory.o \
499    mac/omac/omac_memory_multi.o \
500    mac/omac/omac_process.o \
501    misc/crypt/crypt_find_prng.o \
502    mac/omac/omac_test.o \
503    mac/pelican/pelican.o \
504    mac/pelican/pelican_memory.o \
505    mac/pelican/pelican_test.o \
506    mac/pmac/pmac_done.o \
507    mac/pmac/pmac_file.o \
508    mac/pmac/pmac_init.o \
509    mac/pmac/pmac_memory.o \
510    mac/pmac/pmac_memory_multi.o \
511    mac/pmac/pmac_ntz.o \
512    mac/pmac/pmac_process.o \
513    mac/pmac/pmac_shift_xor.o \
514    mac/pmac/pmac_test.o \
515    mac/poly1305/poly1305.o \
516    mac/poly1305/poly1305_file.o \
517    mac/poly1305/poly1305_memory.o \
518    mac/poly1305/poly1305_memory_multi.o \
519    mac/poly1305/poly1305_test.o \
520    mac/xcbc/xcbc_done.o \
521    mac/xcbc/xcbc_file.o \
522    mac/xcbc/xcbc_init.o \
523    mac/xcbc/xcbc_memory.o \
524    mac/xcbc/xcbc_memory_multi.o \
525    mac/xcbc/xcbc_process.o \
526    mac/xcbc/xcbc_test.o \
527    math/fp/ltc_ecc_fp_mulmod.o \
528    math/gmp_desc.o \
529    math/ltm_desc.o \
530    math/multi.o \
531    math/radix_to_bin.o \
532    math/rand_bn.o \
533    math/rand_prime.o \
534    math/tfm_desc.o \
535    misc/adler32.o \
536    misc/base64/base64_decode.o \
537    misc/base64/base64_encode.o \
538    misc/burn_stack.o \
539    misc/compare_testvector.o \
540    misc/crc32.o \
541    misc/crypt/crypt.o \
542    misc/crypt/crypt_argchk.o \
543    misc/crypt/crypt_cipher_descriptor.o \
544    misc/crypt/crypt_cipher_is_valid.o \
545    misc/crypt/crypt_constants.o \
546    misc/crypt/crypt_find_cipher.o \
547    misc/crypt/crypt_find_cipher_any.o \
548    misc/crypt/crypt_fsa.o \
549    misc/crypt/crypt_hash_descriptor.o \
550    misc/crypt/crypt_hash_is_valid.o \
551    misc/crypt/crypt_inits.o \
552    misc/crypt/crypt_ltc_mp_descriptor.o \
553    misc/crypt/crypt_prng_descriptor.o \
554    misc/crypt/crypt_prng_is_valid.o \
555    misc/crypt/crypt_prng_rng_descriptor.o \
556    misc/crypt/crypt_register_all_ciphers.o \
557    misc/crypt/crypt_register_all_hashes.o \
558    misc/crypt/crypt_register_all_prngs.o \
559    misc/crypt/crypt_register_cipher.o \
560    misc/crypt/crypt_register_hash.o \
561    misc/crypt/crypt_register_prng.o \
562    misc/crypt/crypt_sizes.o \
563    misc/crypt/crypt_unregister_cipher.o \
564    misc/crypt/crypt_unregister_hash.o \
565    misc/crypt/crypt_unregister_prng.o \
566    misc/error_to_string.o \
567    misc/hkdf/hkdf.o \
568    misc/hkdf/hkdf_test.o \
569    misc/mem_neq.o \
570    misc/pk_get_oid.o \
571    misc/pkcs5/pkcs_5_1.o \
572    misc/pkcs5/pkcs_5_2.o \
573    misc/pkcs5/pkcs_5_test.o \
574    misc/zeromem.o \
575    modes/cbc/cbc_decrypt.o \
576    modes/cbc/cbc_done.o \
577    modes/cbc/cbc_encrypt.o \
578    modes/cbc/cbc_getiv.o \
579    modes/cbc/cbc_setiv.o \
580    modes/cbc/cbc_start.o \
581    modes/cfb/cfb_decrypt.o \
582    modes/cfb/cfb_done.o \
583    modes/cfb/cfb_encrypt.o \
584    modes/cfb/cfb_getiv.o \
585    modes/cfb/cfb_setiv.o \
586    modes/cfb/cfb_start.o \
587    modes/ctr/ctr_decrypt.o \
588    modes/ctr/ctr_done.o \
589    modes/ctr/ctr_encrypt.o \
590    modes/ctr/ctr_getiv.o \
591    modes/ctr/ctr_setiv.o \
592    modes/ctr/ctr_start.o \
593    modes/ctr/ctr_test.o \
594    modes/ecb/ecb_decrypt.o \
595    modes/ecb/ecb_done.o \
596    modes/ecb/ecb_encrypt.o \
597    modes/ecb/ecb_start.o \
598    modes/f8/f8_decrypt.o \
599    modes/f8/f8_done.o \
600    modes/f8/f8_encrypt.o \
601    modes/f8/f8_getiv.o \
602    modes/f8/f8_setiv.o \
603    modes/f8/f8_start.o \
604    modes/f8/f8_test_mode.o \
605    modes/lrw/lrw_decrypt.o \
606    modes/lrw/lrw_done.o \
607    modes/lrw/lrw_encrypt.o \
608    modes/lrw/lrw_getiv.o \
609    modes/lrw/lrw_process.o \
610    modes/lrw/lrw_start.o \
611    modes/lrw/lrw_setiv.o \
612    modes/lrw/lrw_test.o \
613    modes/ofb/ofb_decrypt.o \
614    modes/ofb/ofb_done.o \
615    modes/ofb/ofb_encrypt.o \
616    modes/ofb/ofb_getiv.o \
617    modes/ofb/ofb_setiv.o \
618    modes/ofb/ofb_start.o \
619    modes/xts/xts_decrypt.o \
620    modes/xts/xts_done.o \
621    modes/xts/xts_encrypt.o \
622    modes/xts/xts_init.o \
623    modes/xts/xts_mult_x.o \
624    modes/xts/xts_test.o \
625    pk/asn1/der/bit/der_decode_bit_string.o \
626    pk/asn1/der/bit/der_decode_raw_bit_string.o \
627    pk/asn1/der/bit/der_encode_bit_string.o \
628    pk/asn1/der/bit/der_encode_raw_bit_string.o \
629    pk/asn1/der/bit/der_length_bit_string.o \
630    pk/asn1/der/boolean/der_decode_boolean.o \
631    pk/asn1/der/boolean/der_encode_boolean.o \
632    pk/asn1/der/boolean/der_length_boolean.o \
633    pk/asn1/der/choice/der_decode_choice.o \
634    pk/asn1/der/generalizedtime/der_decode_generalizedtime.o \
635    pk/asn1/der/generalizedtime/der_encode_generalizedtime.o \
636    pk/asn1/der/generalizedtime/der_length_generalizedtime.o \
637    pk/asn1/der/ia5/der_decode_ia5_string.o \
638    pk/asn1/der/ia5/der_encode_ia5_string.o \
639    pk/asn1/der/ia5/der_length_ia5_string.o \
640    pk/asn1/der/integer/der_decode_integer.o \
641    pk/asn1/der/integer/der_encode_integer.o \
642    pk/asn1/der/integer/der_length_integer.o \
643    pk/asn1/der/object_identifier/der_decode_object_identifier.o \
644    pk/asn1/der/object_identifier/der_encode_object_identifier.o \
645    pk/asn1/der/object_identifier/der_length_object_identifier.o \
646    pk/asn1/der/octet/der_decode_octet_string.o \
647    pk/asn1/der/octet/der_encode_octet_string.o \
648    pk/asn1/der/octet/der_length_octet_string.o \
649    pk/asn1/der/printable_string/der_decode_printable_string.o \
650    pk/asn1/der/printable_string/der_encode_printable_string.o \
651    pk/asn1/der/printable_string/der_length_printable_string.o \
652    pk/asn1/der/sequence/der_decode_sequence_ex.o \
653    pk/asn1/der/sequence/der_decode_sequence_flexi.o \
654    pk/asn1/der/sequence/der_decode_sequence_multi.o \
655    pk/asn1/der/sequence/der_decode_subject_public_key_info.o \
656    pk/asn1/der/sequence/der_encode_sequence_ex.o \
657    pk/asn1/der/sequence/der_encode_sequence_multi.o \
658    pk/asn1/der/sequence/der_encode_subject_public_key_info.o \
659    pk/asn1/der/sequence/der_length_sequence.o \
660    pk/asn1/der/sequence/der_sequence_free.o \
661    pk/asn1/der/sequence/der_sequence_shrink.o \
662    pk/asn1/der/set/der_encode_set.o \
663    pk/asn1/der/set/der_encode_setof.o \
664    pk/asn1/der/short_integer/der_decode_short_integer.o \
665    pk/asn1/der/short_integer/der_encode_short_integer.o \
666    pk/asn1/der/short_integer/der_length_short_integer.o \
667    pk/asn1/der/teletex_string/der_decode_teletex_string.o \
668    pk/asn1/der/teletex_string/der_length_teletex_string.o \
669    pk/asn1/der/utctime/der_decode_utctime.o \
670    pk/asn1/der/utctime/der_encode_utctime.o \
671    pk/asn1/der/utf8/der_decode_utf8_string.o \
672    pk/asn1/der/utctime/der_length_utctime.o \
673    pk/asn1/der/utf8/der_encode_utf8_string.o \
674    pk/asn1/der/utf8/der_length_utf8_string.o \
675    pk/dh/dh.o \
676    pk/dh/dh_check_pubkey.o \
677    pk/dh/dh_export.o \
678    pk/dh/dh_export_key.o \
679    pk/dh/dh_free.o \
680    pk/dh/dh_generate_key.o \
681    pk/dh/dh_import.o \
682    pk/dh/dh_set.o \
683    pk/dh/dh_set_pg_dhparam.o \
684    pk/dh/dh_shared_secret.o \
685    pk/dsa/dsa_decrypt_key.o \
686    pk/dsa/dsa_encrypt_key.o \
687    pk/dsa/dsa_export.o \
688    pk/dsa/dsa_generate_key.o \
689    pk/dsa/dsa_generate_pqg.o \
690    pk/dsa/dsa_free.o \
691    pk/dsa/dsa_import.o \
692    pk/dsa/dsa_make_key.o \
693    pk/dsa/dsa_set.o \
694    pk/dsa/dsa_set_pqg_dsaparam.o \
695    pk/dsa/dsa_shared_secret.o \
696    pk/dsa/dsa_sign_hash.o \
697    pk/dsa/dsa_verify_hash.o \
698    pk/dsa/dsa_verify_key.o \
699    pk/ecc/ecc.o \
700    pk/ecc/ecc_ansi_x963_export.o \
701    pk/ecc/ecc_ansi_x963_import.o \
702    pk/ecc/ecc_decrypt_key.o \
703    pk/ecc/ecc_encrypt_key.o \
704    pk/ecc/ecc_export.o \
705    pk/ecc/ecc_free.o \
706    pk/ecc/ecc_get_size.o \
707    pk/ecc/ecc_import.o \
708    pk/ecc/ecc_make_key.o \
709    pk/ecc/ecc_shared_secret.o \
710    pk/ecc/ecc_sign_hash.o \
711    pk/ecc/ecc_sizes.o \
712    pk/ecc/ecc_test.o \
713    pk/ecc/ecc_verify_hash.o \
714    pk/ecc/ltc_ecc_map.o \
715    pk/ecc/ltc_ecc_is_valid_idx.o \
716    pk/ecc/ltc_ecc_mul2add.o \
717    pk/ecc/ltc_ecc_mulmod.o \
718    pk/ecc/ltc_ecc_mulmod_timing.o \
719    pk/ecc/ltc_ecc_points.o \
720    pk/ecc/ltc_ecc_projective_add_point.o \
721    pk/ecc/ltc_ecc_projective_dbl_point.o \
722    pk/katja/katja_decrypt_key.o \
723    pk/katja/katja_encrypt_key.o \
724    pk/katja/katja_export.o \
725    pk/katja/katja_exptmod.o \
726    pk/katja/katja_free.o \
727    pk/katja/katja_import.o \
728    pk/katja/katja_make_key.o \
729    pk/pkcs1/pkcs_1_i2osp.o \
730    pk/pkcs1/pkcs_1_mgf1.o \
731    pk/pkcs1/pkcs_1_oaep_decode.o \
732    pk/pkcs1/pkcs_1_oaep_encode.o \
733    pk/pkcs1/pkcs_1_os2ip.o \
734    pk/pkcs1/pkcs_1_pss_decode.o \
735    pk/pkcs1/pkcs_1_pss_encode.o \
736    pk/pkcs1/pkcs_1_v1_5_decode.o \
737    pk/pkcs1/pkcs_1_v1_5_encode.o \
738    pk/rsa/rsa_decrypt_key.o \
739    pk/rsa/rsa_encrypt_key.o \
740    pk/rsa/rsa_export.o \
741    pk/rsa/rsa_exptmod.o \
742    pk/rsa/rsa_free.o \
743    pk/rsa/rsa_get_size.o \
744    pk/rsa/rsa_import.o \
745    pk/rsa/rsa_import_pkcs8.o \
746    pk/rsa/rsa_import_x509.o \
747    pk/rsa/rsa_make_key.o \
748    pk/rsa/rsa_set.o \
749    pk/rsa/rsa_sign_hash.o \
750    pk/rsa/rsa_sign_saltlen_get.o \
751    pk/rsa/rsa_verify_hash.o \
752    prngs/chacha20.o \
753    prngs/fortuna.o \
754    prngs/rc4.o \
755    prngs/rng_get_bytes.o \
756    prngs/rng_make_prng.o \
757    prngs/sober128.o \
758    prngs/sprng.o \
759    prngs/yarrow.o \
760    stream/chacha/chacha_crypt.o \
761    stream/chacha/chacha_done.o \
762    stream/chacha/chacha_ivctr32.o \
763    stream/chacha/chacha_ivctr64.o \
764    stream/chacha/chacha_keystream.o \
765    stream/chacha/chacha_setup.o \
766    stream/chacha/chacha_test.o \
767    stream/rc4/rc4_stream.o \
768    stream/rc4/rc4_test.o \
769    stream/sober128/sober128_stream.o \
770    stream/sober128/sober128_test.o
771
772 libtomcrypt/%.o: CFLAGS+=-DTFM_DESC -Isrc/headers -Itomsfastmath/src/headers -DARGTYPE=4 -DLTC_NO_ASM -DTFM_NO_ASM -Ilibtomcrypt/src/headers -DLTC_SOURCE
773
774 ltc.o: $(addprefix libtomcrypt/src/, $(LTCOBJ))
775         ld -o $@ -r $+
776
777 crypto/rfc3986.c: crypto/rfc3986.re
778         re2c --input custom --tags -o $@ $<
779
780 rfc3986: rfc3986.c
781         $(CC) -Wall -W -Wextra -Werror -o $@ $+
782
783 src/fetchurl.o: CFLAGS+=-DTFM_DESC -Isrc/headers -Itomsfastmath/src/headers -DARGTYPE=4 -DLTC_NO_ASM -DTFM_NO_ASM -Ilibtomcrypt/src/headers -DLTC_SOURCE -Icrypto -Wno-pointer-sign
784
785 zpm-fetchurl: ltc.o tls.o tfm.o src/fetchurl.o crypto/https.o crypto/rfc3986.o
786         $(CC) $(CFLAGS) -static -o $@ $+
787
788 testddg: zpm-fetchurl
789         ./zpm-fetchurl duckduckgo.com 443 /
790
791 testgra: zpm-fetchurl
792         ./zpm-fetchurl granicus.if.org 443 /
793
794 SIGNSRC= \
795 crypto/libeddsa/sign.c \
796 crypto/libeddsa/lib/burn.c \
797 crypto/libeddsa/lib/burnstack.c \
798 crypto/libeddsa/lib/ed.c \
799 crypto/libeddsa/lib/ed25519-sha512.c \
800 crypto/libeddsa/lib/fld.c \
801 crypto/libeddsa/lib/sc.c \
802 crypto/libeddsa/lib/sha512.c \
803 crypto/libeddsa/lib/x25519.c
804
805 SIGNOBJ=$(SIGNSRC:.c=.o) lib/readpass.o lib/blake2/ref/blake2b-ref.o \
806         crypto/chacha.o
807
808 $(SIGNOBJ): CFLAGS=-Wall -Wextra -W -Werror -Wno-pointer-sign \
809         -Wno-missing-braces \
810         -Icrypto/libeddsa/lib -Wno-unused-command-line-argument \
811         -I.
812
813 zpm-sign: $(SIGNOBJ)
814         $(CC) -Wall -Wextra -W -Werror -Wno-unused-command-line-argument -static -o $@ $+
815
816 clean:
817         rm -f *.o sqlite/*.o lib/*.o $(LZMAOBJ) liblzma.a \
818                 libelf.a libzpm.a zpm-addfile soname \
819                 *.xz \
820                 local.db \
821                 t/ctap/*.o \
822                 $(ZPKGBIN) \
823                 db.sql \
824                 elf/*.o lib/jsw/*.o \
825                 $(addprefix crypto/ref10/, $(X255OBJ)) \
826                 $(addprefix crypto/, $(TLSOBJ)) \
827                 $(addprefix tomsfastmath/src/, $(TFMOBJ)) \
828                 $(addprefix libtomcrypt/src/, $(LTCOBJ)) \
829                 $(SIGNOBJ) \
830                 x25519.o