#!/bin/bash
# Copyright (c) 2000-2015 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

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

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

# [Work around] -L${SysRootLib} force linker search sysroot/usr/lib first instead of sysroot/lib
# libuuid.so is duplicated in sysroot/lib and sysroot/usr/lib.
env CC="${CC}" LD="${LD}" AR=${AR} STRIP=${STRIP} RANLIB=${RANLIB} NM=${NM} \
	CPPFALGS="${CFLAGS}" CFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS} -L${SysRootLib}" \
	./configure ${ConfigOpt} --prefix="" \
	--enable-elf-shlibs --disable-nls --disable-tls --disable-libuuid --disable-libblkid --disable-uuidd \
	--disable-imager --enable-fsck="no" --enable-e2initrd-helper="no"

make ${MAKE_FLAGS} ${MAKE_OPTS}
