]> pd.if.org Git - zpackage/blob - Makefile
remove pmac and pelican
[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/poly1305/poly1305.o \
443    mac/poly1305/poly1305_file.o \
444    mac/poly1305/poly1305_memory.o \
445    mac/poly1305/poly1305_memory_multi.o \
446    mac/poly1305/poly1305_test.o \
447    mac/xcbc/xcbc_done.o \
448    mac/xcbc/xcbc_file.o \
449    mac/xcbc/xcbc_init.o \
450    mac/xcbc/xcbc_memory.o \
451    mac/xcbc/xcbc_memory_multi.o \
452    mac/xcbc/xcbc_process.o \
453    mac/xcbc/xcbc_test.o \
454    math/fp/ltc_ecc_fp_mulmod.o \
455    math/gmp_desc.o \
456    math/ltm_desc.o \
457    math/multi.o \
458    math/radix_to_bin.o \
459    math/rand_bn.o \
460    math/rand_prime.o \
461    math/tfm_desc.o \
462    misc/adler32.o \
463    misc/base64/base64_decode.o \
464    misc/base64/base64_encode.o \
465    misc/burn_stack.o \
466    misc/compare_testvector.o \
467    misc/crc32.o \
468    misc/crypt/crypt.o \
469    misc/crypt/crypt_argchk.o \
470    misc/crypt/crypt_cipher_descriptor.o \
471    misc/crypt/crypt_cipher_is_valid.o \
472    misc/crypt/crypt_constants.o \
473    misc/crypt/crypt_find_cipher.o \
474    misc/crypt/crypt_find_cipher_any.o \
475    misc/crypt/crypt_fsa.o \
476    misc/crypt/crypt_hash_descriptor.o \
477    misc/crypt/crypt_hash_is_valid.o \
478    misc/crypt/crypt_inits.o \
479    misc/crypt/crypt_ltc_mp_descriptor.o \
480    misc/crypt/crypt_prng_descriptor.o \
481    misc/crypt/crypt_prng_is_valid.o \
482    misc/crypt/crypt_prng_rng_descriptor.o \
483    misc/crypt/crypt_register_all_ciphers.o \
484    misc/crypt/crypt_register_all_hashes.o \
485    misc/crypt/crypt_register_all_prngs.o \
486    misc/crypt/crypt_register_cipher.o \
487    misc/crypt/crypt_register_hash.o \
488    misc/crypt/crypt_register_prng.o \
489    misc/crypt/crypt_sizes.o \
490    misc/crypt/crypt_unregister_cipher.o \
491    misc/crypt/crypt_unregister_hash.o \
492    misc/crypt/crypt_unregister_prng.o \
493    misc/error_to_string.o \
494    misc/hkdf/hkdf.o \
495    misc/hkdf/hkdf_test.o \
496    misc/mem_neq.o \
497    misc/pk_get_oid.o \
498    misc/pkcs5/pkcs_5_1.o \
499    misc/pkcs5/pkcs_5_2.o \
500    misc/pkcs5/pkcs_5_test.o \
501    misc/zeromem.o \
502    modes/cbc/cbc_decrypt.o \
503    modes/cbc/cbc_done.o \
504    modes/cbc/cbc_encrypt.o \
505    modes/cbc/cbc_getiv.o \
506    modes/cbc/cbc_setiv.o \
507    modes/cbc/cbc_start.o \
508    modes/cfb/cfb_decrypt.o \
509    modes/cfb/cfb_done.o \
510    modes/cfb/cfb_encrypt.o \
511    modes/cfb/cfb_getiv.o \
512    modes/cfb/cfb_setiv.o \
513    modes/cfb/cfb_start.o \
514    modes/ctr/ctr_decrypt.o \
515    modes/ctr/ctr_done.o \
516    modes/ctr/ctr_encrypt.o \
517    modes/ctr/ctr_getiv.o \
518    modes/ctr/ctr_setiv.o \
519    modes/ctr/ctr_start.o \
520    modes/ctr/ctr_test.o \
521    modes/ecb/ecb_decrypt.o \
522    modes/ecb/ecb_done.o \
523    modes/ecb/ecb_encrypt.o \
524    modes/ecb/ecb_start.o \
525    modes/f8/f8_decrypt.o \
526    modes/f8/f8_done.o \
527    modes/f8/f8_encrypt.o \
528    modes/f8/f8_getiv.o \
529    modes/f8/f8_setiv.o \
530    modes/f8/f8_start.o \
531    modes/f8/f8_test_mode.o \
532    modes/lrw/lrw_decrypt.o \
533    modes/lrw/lrw_done.o \
534    modes/lrw/lrw_encrypt.o \
535    modes/lrw/lrw_getiv.o \
536    modes/lrw/lrw_process.o \
537    modes/lrw/lrw_start.o \
538    modes/lrw/lrw_setiv.o \
539    modes/lrw/lrw_test.o \
540    modes/ofb/ofb_decrypt.o \
541    modes/ofb/ofb_done.o \
542    modes/ofb/ofb_encrypt.o \
543    modes/ofb/ofb_getiv.o \
544    modes/ofb/ofb_setiv.o \
545    modes/ofb/ofb_start.o \
546    modes/xts/xts_decrypt.o \
547    modes/xts/xts_done.o \
548    modes/xts/xts_encrypt.o \
549    modes/xts/xts_init.o \
550    modes/xts/xts_mult_x.o \
551    modes/xts/xts_test.o \
552    pk/asn1/der/bit/der_decode_bit_string.o \
553    pk/asn1/der/bit/der_decode_raw_bit_string.o \
554    pk/asn1/der/bit/der_encode_bit_string.o \
555    pk/asn1/der/bit/der_encode_raw_bit_string.o \
556    pk/asn1/der/bit/der_length_bit_string.o \
557    pk/asn1/der/boolean/der_decode_boolean.o \
558    pk/asn1/der/boolean/der_encode_boolean.o \
559    pk/asn1/der/boolean/der_length_boolean.o \
560    pk/asn1/der/choice/der_decode_choice.o \
561    pk/asn1/der/generalizedtime/der_decode_generalizedtime.o \
562    pk/asn1/der/generalizedtime/der_encode_generalizedtime.o \
563    pk/asn1/der/generalizedtime/der_length_generalizedtime.o \
564    pk/asn1/der/ia5/der_decode_ia5_string.o \
565    pk/asn1/der/ia5/der_encode_ia5_string.o \
566    pk/asn1/der/ia5/der_length_ia5_string.o \
567    pk/asn1/der/integer/der_decode_integer.o \
568    pk/asn1/der/integer/der_encode_integer.o \
569    pk/asn1/der/integer/der_length_integer.o \
570    pk/asn1/der/object_identifier/der_decode_object_identifier.o \
571    pk/asn1/der/object_identifier/der_encode_object_identifier.o \
572    pk/asn1/der/object_identifier/der_length_object_identifier.o \
573    pk/asn1/der/octet/der_decode_octet_string.o \
574    pk/asn1/der/octet/der_encode_octet_string.o \
575    pk/asn1/der/octet/der_length_octet_string.o \
576    pk/asn1/der/printable_string/der_decode_printable_string.o \
577    pk/asn1/der/printable_string/der_encode_printable_string.o \
578    pk/asn1/der/printable_string/der_length_printable_string.o \
579    pk/asn1/der/sequence/der_decode_sequence_ex.o \
580    pk/asn1/der/sequence/der_decode_sequence_flexi.o \
581    pk/asn1/der/sequence/der_decode_sequence_multi.o \
582    pk/asn1/der/sequence/der_decode_subject_public_key_info.o \
583    pk/asn1/der/sequence/der_encode_sequence_ex.o \
584    pk/asn1/der/sequence/der_encode_sequence_multi.o \
585    pk/asn1/der/sequence/der_encode_subject_public_key_info.o \
586    pk/asn1/der/sequence/der_length_sequence.o \
587    pk/asn1/der/sequence/der_sequence_free.o \
588    pk/asn1/der/sequence/der_sequence_shrink.o \
589    pk/asn1/der/set/der_encode_set.o \
590    pk/asn1/der/set/der_encode_setof.o \
591    pk/asn1/der/short_integer/der_decode_short_integer.o \
592    pk/asn1/der/short_integer/der_encode_short_integer.o \
593    pk/asn1/der/short_integer/der_length_short_integer.o \
594    pk/asn1/der/teletex_string/der_decode_teletex_string.o \
595    pk/asn1/der/teletex_string/der_length_teletex_string.o \
596    pk/asn1/der/utctime/der_decode_utctime.o \
597    pk/asn1/der/utctime/der_encode_utctime.o \
598    pk/asn1/der/utf8/der_decode_utf8_string.o \
599    pk/asn1/der/utctime/der_length_utctime.o \
600    pk/asn1/der/utf8/der_encode_utf8_string.o \
601    pk/asn1/der/utf8/der_length_utf8_string.o \
602    pk/dh/dh.o \
603    pk/dh/dh_check_pubkey.o \
604    pk/dh/dh_export.o \
605    pk/dh/dh_export_key.o \
606    pk/dh/dh_free.o \
607    pk/dh/dh_generate_key.o \
608    pk/dh/dh_import.o \
609    pk/dh/dh_set.o \
610    pk/dh/dh_set_pg_dhparam.o \
611    pk/dh/dh_shared_secret.o \
612    pk/dsa/dsa_decrypt_key.o \
613    pk/dsa/dsa_encrypt_key.o \
614    pk/dsa/dsa_export.o \
615    pk/dsa/dsa_generate_key.o \
616    pk/dsa/dsa_generate_pqg.o \
617    pk/dsa/dsa_free.o \
618    pk/dsa/dsa_import.o \
619    pk/dsa/dsa_make_key.o \
620    pk/dsa/dsa_set.o \
621    pk/dsa/dsa_set_pqg_dsaparam.o \
622    pk/dsa/dsa_shared_secret.o \
623    pk/dsa/dsa_sign_hash.o \
624    pk/dsa/dsa_verify_hash.o \
625    pk/dsa/dsa_verify_key.o \
626    pk/ecc/ecc.o \
627    pk/ecc/ecc_ansi_x963_export.o \
628    pk/ecc/ecc_ansi_x963_import.o \
629    pk/ecc/ecc_decrypt_key.o \
630    pk/ecc/ecc_encrypt_key.o \
631    pk/ecc/ecc_export.o \
632    pk/ecc/ecc_free.o \
633    pk/ecc/ecc_get_size.o \
634    pk/ecc/ecc_import.o \
635    pk/ecc/ecc_make_key.o \
636    pk/ecc/ecc_shared_secret.o \
637    pk/ecc/ecc_sign_hash.o \
638    pk/ecc/ecc_sizes.o \
639    pk/ecc/ecc_test.o \
640    pk/ecc/ecc_verify_hash.o \
641    pk/ecc/ltc_ecc_map.o \
642    pk/ecc/ltc_ecc_is_valid_idx.o \
643    pk/ecc/ltc_ecc_mul2add.o \
644    pk/ecc/ltc_ecc_mulmod.o \
645    pk/ecc/ltc_ecc_mulmod_timing.o \
646    pk/ecc/ltc_ecc_points.o \
647    pk/ecc/ltc_ecc_projective_add_point.o \
648    pk/ecc/ltc_ecc_projective_dbl_point.o \
649    pk/pkcs1/pkcs_1_i2osp.o \
650    pk/pkcs1/pkcs_1_mgf1.o \
651    pk/pkcs1/pkcs_1_oaep_decode.o \
652    pk/pkcs1/pkcs_1_oaep_encode.o \
653    pk/pkcs1/pkcs_1_os2ip.o \
654    pk/pkcs1/pkcs_1_pss_decode.o \
655    pk/pkcs1/pkcs_1_pss_encode.o \
656    pk/pkcs1/pkcs_1_v1_5_decode.o \
657    pk/pkcs1/pkcs_1_v1_5_encode.o \
658    pk/rsa/rsa_decrypt_key.o \
659    pk/rsa/rsa_encrypt_key.o \
660    pk/rsa/rsa_export.o \
661    pk/rsa/rsa_exptmod.o \
662    pk/rsa/rsa_free.o \
663    pk/rsa/rsa_get_size.o \
664    pk/rsa/rsa_import.o \
665    pk/rsa/rsa_import_pkcs8.o \
666    pk/rsa/rsa_import_x509.o \
667    pk/rsa/rsa_make_key.o \
668    pk/rsa/rsa_set.o \
669    pk/rsa/rsa_sign_hash.o \
670    pk/rsa/rsa_sign_saltlen_get.o \
671    pk/rsa/rsa_verify_hash.o \
672    prngs/chacha20.o \
673    prngs/fortuna.o \
674    prngs/rng_get_bytes.o \
675    prngs/rng_make_prng.o \
676    prngs/sprng.o \
677    stream/chacha/chacha_crypt.o \
678    stream/chacha/chacha_done.o \
679    stream/chacha/chacha_ivctr32.o \
680    stream/chacha/chacha_ivctr64.o \
681    stream/chacha/chacha_keystream.o \
682    stream/chacha/chacha_setup.o \
683    stream/chacha/chacha_test.o
684
685 libtomcrypt/%.o: CFLAGS+= -Isrc/headers -Itomsfastmath/src/headers -DARGTYPE=4 -Ilibtomcrypt/src/headers
686 libtomcrypt/%.o: CFLAGS+= \
687         -DTFM_DESC \
688         -DTFM_NO_ASM \
689         -DLTC_NOTHING \
690         -DLTC_NO_ASM \
691         -DLTC_SOURCE \
692         -DLTC_POLY1305 \
693         -DLTC_CHACHA20POLY1305_MODE \
694         -DLTC_RIJNDAEL \
695         -DLTC_CHACHA \
696         -DLTC_ECB_MODE \
697         -DLTC_CBC_MODE \
698         -DLTC_CTR_MODE \
699         -DLTC_GCM_MODE \
700         -DLTC_SHA1 \
701         -DLTC_SHA3 \
702         -DLTC_SHA512 \
703         -DLTC_SHA384 \
704         -DLTC_SHA256 \
705         -DLTC_HASH_HELPERS \
706         -DLTC_HMAC \
707         -DLTC_OMAC \
708         -DLTC_CCM_MODE \
709         -DLTC_SPRNG \
710         -DLTC_DEVRANDOM \
711         -DLTC_TRY_URANDOM_FIRST \
712         -DLTC_RNG_GET_BYTES \
713         -DLTC_RNG_MAKE_PRNG \
714         -DLTC_DER \
715         -DLTC_MRSA \
716         -DLTC_MECC \
717         -DLTC_BASE64 
718
719 tomclean:
720         rm -f $(addprefix libtomcrypt/src/, $(LTCOBJ))
721         rm -f ltc.o
722
723 ltc.o: $(addprefix libtomcrypt/src/, $(LTCOBJ))
724         ld -o $@ -r $+
725
726 crypto/rfc3986.c: crypto/rfc3986.re
727         re2c --input custom --tags -o $@ $<
728
729 rfc3986: rfc3986.c
730         $(CC) -Wall -W -Wextra -Werror -o $@ $+
731
732 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
733
734 bin/zpm-fetchurl: ltc.o crypto/tls.o tfm.o src/fetchurl.o crypto/https.o crypto/rfc3986.o
735         $(CC) $(CFLAGS) -static -o $@ $+
736
737 testddg: zpm-fetchurl
738         ./zpm-fetchurl duckduckgo.com 443 /
739
740 testgra: zpm-fetchurl
741         ./zpm-fetchurl granicus.if.org 443 /
742
743 SIGNSRC= \
744 crypto/libeddsa/sign.c \
745 crypto/libeddsa/lib/burn.c \
746 crypto/libeddsa/lib/burnstack.c \
747 crypto/libeddsa/lib/ed.c \
748 crypto/libeddsa/lib/ed25519-sha512.c \
749 crypto/libeddsa/lib/fld.c \
750 crypto/libeddsa/lib/sc.c \
751 crypto/libeddsa/lib/sha512.c \
752 crypto/libeddsa/lib/x25519.c
753
754 SIGNOBJ=$(SIGNSRC:.c=.o) lib/readpass.o lib/blake2b.o \
755         crypto/chacha.o
756
757 $(SIGNOBJ): CFLAGS=-Wall -Wextra -W -Werror -Wno-pointer-sign \
758         -Wno-missing-braces \
759         -Icrypto/libeddsa/lib -Wno-unused-command-line-argument \
760         -I.
761
762 bin/zpm-sign: $(SIGNOBJ)
763         $(CC) -Wall -Wextra -W -Werror -Wno-unused-command-line-argument -static -o $@ $+
764
765 clean:
766         rm -f *.o sqlite/*.o lib/*.o $(LZMAOBJ) liblzma.a \
767                 libelf.a libzpm.a zpm-addfile soname \
768                 *.xz \
769                 local.db \
770                 t/ctap/*.o \
771                 $(ZPKGBIN) \
772                 db.sql \
773                 elf/*.o lib/jsw/*.o \
774                 $(addprefix crypto/ref10/, $(X255OBJ)) \
775                 $(addprefix crypto/, $(TLSOBJ)) \
776                 $(addprefix tomsfastmath/src/, $(TFMOBJ)) \
777                 $(addprefix libtomcrypt/src/, $(LTCOBJ)) \
778                 $(SIGNOBJ) \
779                 x25519.o