When the $CFLAGS variable contains the -DED25519_SHA512 option (by
default it doesn't), the code from src/optional/sha512.c is
automatically linked to the final libraries (libmonocypher.a and
libmonocypher.so).
That way, users who need to install a
ED25519 compliant version of
Monocypher can do so simply by altering the compilation options with the
$CFLAGS variable.
Activating the option replaces it by Ed25519 (EdDSA with Curve25519 and
SHA-512). When this option is activated, you will need to link the
final program with a suitable SHA-512 implementation. You can use the
-`sha512.c` and `sha512.h` files provided in `src/optional`.
+`sha512.c` and `sha512.h` files provided in `src/optional`. The
+makefile does this linking automatically whenever the `$CFLAGS` variable
+contains the `-DED25519_SHA512` option. For instance:
+
+ $ make CFLAGS="-O2 -DED25519_SHA512"
The `-DBLAKE2_NO_UNROLLING` option is a performance tweak. By default,
Monocypher unrolls the Blake2b inner loop, because it is over 25% faster
TARBALL_VERSION=$$(cat VERSION.md)
TARBALL_DIR=.
+ifeq ($(findstring -DED25519_SHA512, $(CFLAGS)),)
+LINK_SHA512=
+else
+LINK_SHA512=lib/sha512.o
+endif
+
.PHONY: all library static-library dynamic-library \
install install-doc \
check test speed \
./$<
# Monocypher libraries
-lib/libmonocypher.a: lib/monocypher.o
+lib/libmonocypher.a: lib/monocypher.o $(LINK_SHA512)
ar cr $@ $^
lib/libmonocypher.so: lib/libmonocypher.so.2
@mkdir -p $(@D)
ln -s $$(basename $<) $@
-lib/libmonocypher.so.2: lib/monocypher.o
+lib/libmonocypher.so.2: lib/monocypher.o $(LINK_SHA512)
@mkdir -p $(@D)
$(CC) $(CFLAGS) -shared -o $@ $^
lib/sha512.o : src/optional/sha512.c src/optional/sha512.h