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


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

if pkg-config libsynogpl --exists; then
	GPL_CFLAGS="`pkg-config libsynogpl --cflags`"
	GPL_LIBS="`pkg-config libsynogpl --libs`"
else
	GPL_CFLAGS=`/usr/syno/bin/libsynogpl-config --cflags`
	GPL_LIBS=`/usr/syno/bin/libsynogpl-config --libs`
fi

DL_CFLAGS="`/source/libsynodownload/lib/libsynodlgpl-config --cflags`"
DL_LIBS="`/source/libsynodownload/lib/libsynodlgpl-config --libs`"

env CC="${CC}" CXX="${CXX}" LD="${LD}" AR="${AR}" NM="${NM}" STRIP="${STRIP_ORI}" RANLIB="${RANLIB}" \
	CFLAGS="${CFLAGS} -I/usr/syno/include" \
	CPPFLAGS="${CFLAGS} ${GPL_CFLAGS} ${DL_CFLAGS} -DSYNO_DOWNLOAD_STATION -std=c++11" \
	LDFLAGS="${LDFLAGS} ${GPL_LIBS} ${DL_LIBS} -L/usr/syno/lib -Wl,-rpath=/var/packages/DownloadStation/target/lib" \
	./configure ${ConfigOpt} \
	--prefix=/usr \
	--sysconfdir=/etc \
	--disable-nls \
	--without-libiconv-prefix \
	--without-libintl-prefix \
	--without-included-regex \
	--disable-static \
	--with-openssl \
	--with-expat="${SysRootPrefix}" \
	--with-readline="${SysRootPrefix}" \
	--with-zlib="${SysRootPrefix}"

make ${MAKE_FLAGS}
