#!/bin/sh -e
srcdir=${SRCDIR:-$(dirname "$0")}
eval ". $srcdir/config.sh"

random=none
case "$(uname)" in
	Linux)
		random=linux
		;;
	OpenBSD|FreeBSD|NetBSD|Darwin)
		random=arc4
		;;
	*)
		if [ -c /dev/urandom ] && [ -r /dev/urandom ]
		then
			random=urandom
		else
			echo "Error: no random provider is known for this platform" >&2
			exit 1
		fi
		;;
esac

mkchallenge() {
	genrules mkchallenge \
		src/random-$random.c \
		src/util.c \
		src/mkchallenge.c
}

mkproof() {
	genrules mkproof \
		argon2i/src/argon2.c \
		argon2i/src/core.c \
		argon2i/src/blake2/blake2b.c \
		argon2i/src/encoding.c \
		argon2i/src/ref.c \
		src/random-$random.c \
		src/util.c \
		src/mkproof.c
}

checkproof() {
	genrules checkproof \
		argon2i/src/argon2.c \
		argon2i/src/core.c \
		argon2i/src/blake2/blake2b.c \
		argon2i/src/encoding.c \
		argon2i/src/ref.c \
		src/util.c \
		src/checkproof.c
}

all="mkchallenge mkproof checkproof"

run_configure
