### this file is sourced not run
PKGBUILD=1
PKGARCH=x86_64

# source: james

# release tarball
#PKGVER=
#TARBALL=
#MD5SUM=
#SRC_URL=
BUNDLE=

# git-master tarball
PKGVER=2024.06.07 # pull date
#MD5SUM=
#hash=7f445467795c7da031cf3be6c31ac29f5e9f0740
#hash7=${hash#???????}; hash7=${hash%$hash7}
#TARBALL=flexisip-$PKGVER-$hash7.tar.gz
#SRC_URL=https://github.com/BelledonneCommunications/flexisip/archive/$hash.tar.gz
#SRC_URL=https://gitlab.linphone.org/BC/public/flexisip/-/archive/$hash/flexisip-$hash.tar.gz
# we can't use directly, since it still needs about 2GB worth of submodules

SLACKREQ='libjansson libnghttp2 libxerces-c mariadb' # build-time pyhon3-pystache python3-six git
SLACKDESC="flexisip: flexisip $PKGVER (SIP Server)
flexisip: 
flexisip: Flexisip is a complete and scalable SIP server suite that includes 
flexisip: several modules: a proxy, a presence server, a conference server, a 
flexisip: back-to-back user agent, and Flexisip account manager for the 
flexisip: creation and administration of SIP accounts.
flexisip: 
flexisip: https://www.linphone.org/flexisip-server
flexisip: 
flexisip: 
flexisip: 
"
SLACKSUG='postgresql redis'

### default pkg_download
### prepare
pkg_prepare() {
	if [ -d /mnt/sdc1/flexisip-git ]; then
		echo "Copying sources to build directory ..."
		cp -a /mnt/sdc1/flexisip-git tmp
	else
		echo "Source not available"
		return 1
	fi
}

### default pkg_package
### build
pkg_build() {
	CMAKEFLAGS="$CMAKEFLAGS       \
		-DENABLE_SNMP=OFF         \
		-DINTERNAL_LIBHIREDIS=ON  \
		-DINTERNAL_JSONCPP=ON     \
		-DENABLE_B2BUA=ON         \
		-DENABLE_SOCI_POSTGRESQL_BACKEND=ON \
		-DCMAKE_INSTALL_PREFIX=/opt/flexisip-$PKGVER \
		-DCMAKE_BUILD_TYPE=Release \
		-DSYSCONF_INSTALL_DIR=/etc \
	" &&
	pkg_build_cmake &&	
	pkg_build_slackdesc	&&

	# adjustments
	ln -sfv /opt/flexisip-$PKGVER /opt/flexisip &&
	mv /etc/flexisip/flexisip.conf{,.sample} &&
	true
}
