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

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

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

if checkPlatformFunction SYNO_PLAT_E2FSPROGS_IGNORE_METADATA_CSUM; then
	MAKE_OPTS=${MAKE_OPTS}' SYNO_IGNORE_METADATA_CSUM="yes"'
	CFLAGS=${CFLAGS}' -DSYNO_IGNORE_METADATA_CSUM'
fi

if checkPlatformFunction SYNO_FEA_SUPPORT_RBD; then
	MAKE_OPTS=${MAKE_OPTS}' SYNO_SUPPORT_RBD="yes"'
	CFLAGS=${CFLAGS}' -DSYNO_SUPPORT_RBD'
fi

env CC=${CC} LD=${LD} AR=${AR} STRIP=${STRIP} RANLIB=${RANLIB} NM=${NM} \
	CFLAGS="-Os -fno-exceptions -fno-asynchronous-unwind-tables -fno-unwind-tables ${CFLAGS}" LDFLAGS="${LDFLAGS}" \
	./configure ${ConfigOpt} \
	--enable-libblkid \
	--disable-nls \
	--disable-tls \
	--disable-debugfs \
	--disable-imager \
	--disable-resizer \
	--disable-defrag \
	--disable-testio-debug \
	--disable-uuidd \
	--disable-mmp \
	--disable-bmap-stats \
	--disable-tdb
if Is64BitPlatform; then
	MAKE_OPTS=${MAKE_OPTS}' SYNO_MKE2FS_64BITS="yes"'
else
	MAKE_OPTS=""
fi

make ${MAKE_FLAGS} ${MAKE_OPTS}
