1COMPONENT_SUBMODULES += libsodium
2
3# Common root directory for all source directories
4LSRC := libsodium/src/libsodium
5
6COMPONENT_SRCDIRS := port
7
8# Derived from libsodium/src/libsodium/Makefile.am
9# (ignoring the !MINIMAL set)
10COMPONENT_SRCDIRS += \
11	$(LSRC)/crypto_aead/chacha20poly1305/sodium \
12	$(LSRC)/crypto_aead/xchacha20poly1305/sodium \
13	$(LSRC)/crypto_auth \
14	$(LSRC)/crypto_auth/hmacsha256 \
15	$(LSRC)/crypto_auth/hmacsha512 \
16	$(LSRC)/crypto_auth/hmacsha512256 \
17	$(LSRC)/crypto_box \
18	$(LSRC)/crypto_box/curve25519xsalsa20poly1305 \
19	$(LSRC)/crypto_core/ed25519 \
20	$(LSRC)/crypto_core/ed25519/ref10 \
21	$(LSRC)/crypto_core/hchacha20 \
22	$(LSRC)/crypto_core/hsalsa20/ref2 \
23	$(LSRC)/crypto_core/hsalsa20 \
24	$(LSRC)/crypto_core/salsa/ref \
25	$(LSRC)/crypto_generichash \
26	$(LSRC)/crypto_generichash/blake2b \
27	$(LSRC)/crypto_generichash/blake2b/ref \
28	$(LSRC)/crypto_hash \
29	$(LSRC)/crypto_hash/sha256 \
30	$(LSRC)/crypto_hash/sha512 \
31	$(LSRC)/crypto_kdf/blake2b \
32	$(LSRC)/crypto_kdf \
33	$(LSRC)/crypto_kx \
34	$(LSRC)/crypto_onetimeauth \
35	$(LSRC)/crypto_onetimeauth/poly1305 \
36	$(LSRC)/crypto_onetimeauth/poly1305/donna \
37	$(LSRC)/crypto_pwhash/argon2 \
38	$(LSRC)/crypto_pwhash \
39	$(LSRC)/crypto_pwhash/scryptsalsa208sha256 \
40	$(LSRC)/crypto_pwhash/scryptsalsa208sha256/nosse \
41	$(LSRC)/crypto_scalarmult \
42	$(LSRC)/crypto_scalarmult/curve25519 \
43	$(LSRC)/crypto_scalarmult/curve25519/ref10 \
44	$(LSRC)/crypto_scalarmult/curve25519/sandy2x \
45	$(LSRC)/crypto_scalarmult/ed25519/ref10 \
46	$(LSRC)/crypto_scalarmult/ristretto255/ref10 \
47	$(LSRC)/crypto_secretbox \
48	$(LSRC)/crypto_secretbox/xsalsa20poly1305 \
49	$(LSRC)/crypto_shorthash \
50	$(LSRC)/crypto_shorthash/siphash24 \
51	$(LSRC)/crypto_shorthash/siphash24/ref \
52	$(LSRC)/crypto_sign \
53	$(LSRC)/crypto_sign/ed25519 \
54	$(LSRC)/crypto_sign/ed25519/ref10 \
55	$(LSRC)/crypto_stream/chacha20 \
56	$(LSRC)/crypto_stream/chacha20/ref \
57	$(LSRC)/crypto_stream \
58	$(LSRC)/crypto_stream/salsa20 \
59    $(LSRC)/crypto_stream/salsa20/ref \
60	$(LSRC)/crypto_stream/xsalsa20 \
61	$(LSRC)/crypto_verify/sodium \
62	$(LSRC)/randombytes \
63	$(LSRC)/sodium
64
65ifdef CONFIG_LIBSODIUM_USE_MBEDTLS_SHA
66COMPONENT_SRCDIRS += port/crypto_hash_mbedtls
67else
68COMPONENT_SRCDIRS += \
69	$(LSRC)/crypto_hash/sha256/cp \
70    $(LSRC)/crypto_hash/sha512/cp
71endif
72
73# Fix some warnings in current libsodium source files
74# (not applied to whole component as we compile some of our own files, also.)
75$(LSRC)/crypto_pwhash/argon2/argon2-fill-block-ref.o: CFLAGS += -Wno-unknown-pragmas
76$(LSRC)/crypto_pwhash/argon2/pwhash_argon2i.o: CFLAGS += -Wno-type-limits
77$(LSRC)/crypto_pwhash/argon2/pwhash_argon2id.o: CFLAGS += -Wno-type-limits
78$(LSRC)/crypto_pwhash/argon2/argon2-core.o: CFLAGS += -Wno-type-limits
79$(LSRC)/crypto_pwhash/scryptsalsa208sha256/pwhash_scryptsalsa208sha256.o: CFLAGS += -Wno-type-limits
80$(LSRC)/sodium/utils.o: CFLAGS += -Wno-unused-variable
81
82COMPONENT_ADD_INCLUDEDIRS := $(LSRC)/include port_include
83COMPONENT_PRIV_INCLUDEDIRS := $(LSRC)/include/sodium port_include/sodium port
84
85
86# Not using autoconf, but this needs to be set
87CFLAGS += -DCONFIGURED -Wno-unused-function
88
89# Add the options from configure.ac (this needs checking if new versions are added )
90CFLAGS +=  -DNATIVE_LITTLE_ENDIAN -DHAVE_WEAK_SYMBOLS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS
91
92# randombytes.c needs to pull in platform-specific implementation
93$(LSRC)/randombytes/randombytes.o: CFLAGS+=-DRANDOMBYTES_DEFAULT_IMPLEMENTATION
94
95# Temporary suppress "fallthrough" warnings until they are fixed in libsodium repo
96$(LSRC)/crypto_shorthash/siphash24/ref/shorthash_siphashx24_ref.o: CFLAGS += -Wno-implicit-fallthrough
97$(LSRC)/crypto_shorthash/siphash24/ref/shorthash_siphash24_ref.o: CFLAGS += -Wno-implicit-fallthrough
98