#!/bin/bash
# Copyright (c) 2000-2019 Synology Inc. All rights reserved.

case ${MakeClean} in
	[Yy][Ee][Ss])
		make clean
		;;
esac

case ${CleanOnly} in
	[Yy][Ee][Ss])
		return
		;;
esac

if checkPlatformFunction SYNO_FEA_GNUTLS_ENABLE_CRYPTODEV; then
	CRYPTODEV="--enable-cryptodev"
fi

COMMON_CONFIG="
	--prefix=/ \
	--disable-doc \
	--disable-bash-tests \
	--disable-tests \
	--disable-full-test-suite \
	--with-included-libtasn1 \
	--with-included-unistring \
	--disable-static \
	--disable-guile \
	--disable-nls \
	--disable-srp-authentication \
	--enable-psk-authentication \
	--without-p11-kit \
	--without-tpm \
	--disable-cxx \
	${CRYPTODEV}
	"

env CC="$CC" CXX="$CXX" LD="$LD" AR="$AR" STRIP="$STRIP" RANLIB="${RANLIB}" NM="$NM" \
	CFLAGS="${CFLAGS} -U_FORTIFY_SOURCE -Wno-format-security -Wformat=0" LDFLAGS="${LDFLAGS}" \
		./configure ${ConfigOpt} ${COMMON_CONFIG}

make ${MAKE_FLAGS}
