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

# source: james

# release tarball
PKGVER=5.8.1
TARBALL=kamailio-${PKGVER}_src.tar.gz
MD5SUM=dae9e18dfcb70e002c34cbe55e9eda7a
SRC_URL=https://www.kamailio.org/pub/kamailio/$PKGVER/src/$TARBALL
BUNDLE=

# git-master tarball
#PKGVER=
#MD5SUM=
#hash=
#hash7=${hash#???????}; hash7=${hash%$hash7}
#TARBALL=kamailio-$PKGVER-$hash7.tar.gz
#SRC_URL=https://github.com/kamailio/kamailio/archive/$hash.tar.gz

SLACKREQ="libxml2 libjansson libjson-c libunistring libpcre openssl sqlite3"
SLACKDESC="kamailio: kamailio $PKGVER (SIP Server)
kamailio: 
kamailio: Kamailio® (successor of former OpenSER and SER) is an Open Source 
kamailio: SIP Server released under GPLv2+, able to handle thousands of call 
kamailio: setups per second. Kamailio can be used to build large platforms for 
kamailio: VoIP and realtime communications – presence, WebRTC, Instant 
kamailio: messaging and other applications.
kamailio: 
kamailio: https://www.kamailio.org/
kamailio: 
kamailio: 
"
SLACKSUG="mariadb postgresql"

### default pkg_download
### default pkg_prepare
### default pkg_package
### build
pkg_build() {
	cd /tmp/kamailio* &&

	make cfg \
		quiet=verbose \
	    prefix=/usr   \
		cfg_prefix=/  \
		cfg_target=/etc/kamailio/ \
		FLAVOUR=kamailio          \
		BASEDIR=/                 \
		group_include="standard standard-dep stable db sqlite mysql postgres" \
		include_modules="presence xmpp lcr dialplan tls jansson websocket \
		pua pua_bla pua_dialoginfo pua_json pua_reginfo pua_rpc pua_usrloc pua_xmpp \
		xhttp_pi" \
	&&

	make all &&
	make install &&
	pkg_build_slackdesc	&&

	# examples and stuff
	cp -a misc /usr/share/doc/kamailio &&
	
	# make sure new installation don't overwrite old config file
	mv /etc/kamailio/kamailio.cfg{,.example} &&
	mv /etc/kamailio/tls.cfg{,.example} &&
	mv /etc/kamailio/kamctlrc{,.example} &&
	mv /etc/kamailio/pi_framework.xml{,.example} &&
	return 0
}
