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

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

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

if IsGLIBCPlatform; then
	env CC=${CC} LD=${LD} AR=${AR} STRIP=${STRIP} RANLIB=${RANLIB} NM=${NM} \
		CFLAGS="-Os ${CFLAGS}" LDFLAGS="${LDFLAGS}" \
		./configure ${ConfigOpt} \
		--disable-nls --disable-tls \
		--disable-debugfs --disable-imager --disable-resizer --disable-defrag
	if Is64BitPlatform; then
		MAKE_OPTS='SYNO_MKE2FS_64BITS="yes"'
	else
		MAKE_OPTS=""
	fi
else
	# these platform have no libpthread.so (uclibc)
	env CC="${STATIC_CC}" LD="${STATIC_LD}" AR=${STATIC_AR} STRIP=${STATIC_STRIP} RANLIB=${STATIC_RANLIB} NM=${STATIC_NM} \
		CFLAGS="-Os ${STATIC_CFLAGS}" LDFLAGS="${STATIC_LDFLAGS}" \
		./configure ${ConfigOpt} \
		--disable-nls --disable-tls \
		--disable-debugfs --disable-imager --disable-resizer --disable-defrag \
		ac_cv_lib_pthread_sem_init=no ac_cv_lib_rt_sem_init=no ac_cv_lib_rt_sem_init=no
		MAKE_OPTS=""
fi

make ${MAKE_FLAGS} ${MAKE_OPTS}
