# Template file for 'swirc'
pkgname=swirc
version=3.5.3
revision=1
build_style=configure
configure_args="$(vopt_with notify libnotify)"
make_build_args="PREFIX=/usr"
make_check_args="PREFIX=/usr"
make_install_args="PREFIX=/usr"
hostmakedepends="gettext-devel-tools pkg-config which"
makedepends="gettext-devel hunspell-devel libcurl-devel libidn-devel
 ncurses-devel openssl-devel $(vopt_if notify libnotify-devel)"
checkdepends="cmocka-devel"
short_desc="Curses ICB and IRC client"
maintainer="Markus Uhlin <markus@nifty-networks.net>"
license="BSD-3-Clause, ISC, MIT"
homepage="https://www.nifty-networks.net/swirc"
changelog="https://raw.githubusercontent.com/uhlin/swirc/master/CHANGELOG.md"
distfiles="https://www.nifty-networks.net/swirc/releases/swirc-${version}.tgz"
checksum=f7256d45437316ef5bc984f550bf6adec8d3833437761af525b21a3e2c844a0b

build_options="notify"
build_options_default="notify"

post_configure() {
	local _file="options.mk"

	if [ ! -f "$_file" ]; then
		msg_error "cannot find $_file\n"
	fi

	vsed -i "$_file" -e "s/CC =/CC ?=/"
	vsed -i "$_file" -e "s/CXX =/CXX ?=/"
	vsed -i "$_file" -e "s/LDFLAGS =/LDFLAGS ?=/"
}

do_check() {
	# The usage of the "-Wl,-z,now" and "-Wl,-z,relro" LDFLAGS
	# results in linking errors and are disabled during "make
	# check".
	LDFLAGS="-L/usr/local/lib" make check
}

post_check() {
	# "make clean" is needed here because after running "make
	# check" multiple objects in the main source dir and its
	# subdirectories have been compiled with the intention to make
	# unittesting possible by simulating real behavior. The
	# main-symbol is also stripped (i.e. removed) from the main.o
	# file during the "make check" phase. Thus a fresh rebuild is
	# needed.
	make clean
	make -Cpo
	make ${makejobs}
}

post_install() {
	vlicense License.rtf
}
