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