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

if Is64BitPlatform; then
	MAKE_OPTS='SYNO_MKE2FS_64BITS="yes"'
else
	MAKE_OPTS=""
fi

if checkPlatformFunction SYNO_FEA_E2FSPROGS_ALPINE; then
	MAKE_OPTS='SYNO_MKE2FS_64BITS="yes"'
fi

if checkPlatformFunction SYNO_FEA_E2FSPROGS_HI3536NVR; then
	MAKE_OPTS='SYNO_MKE2FS_64BITS="yes"'
fi

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_OLD_GLIBC_WRAPPER; then
	CFLAGS="$CFLAGS -DSYNO_TOOLCHAIN_WORKAROUND"
fi

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

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

env CC="$CC" LD="$LD" AR="$AR" STRIP="$STRIP" RANLIB="$RANLIB" NM="$NM" \
    CPPFALGS="$CFLAGS" CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" LIBS="$LIBS" \
./configure $ConfigOpt \
    --prefix="" \
    --enable-elf-shlibs \
    --disable-libuuid \
    --disable-libblkid \
    --disable-nls \
    --disable-uuidd \
    --enable-fsck="no" \
    --enable-e2initrd-helper="no"

make $MAKE_FLAGS $MAKE_OPTS

