# Copyright 1999-2019 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=7

inherit multiprocessing toolchain-funcs vcs-snapshot

MY_PV="eb5ef9d"
MY_P="${PN}-${MY_PV}"

DESCRIPTION="Command Line Interface compiler for C++"
HOMEPAGE="https://www.codesynthesis.com/projects/cli"
SRC_URI="https://git.codesynthesis.com/cgit/${PN}/${PN}/snapshot/${MY_PV}.tar.gz -> ${MY_P}.tar.gz"

LICENSE="MIT"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE="static-libs"

RDEPEND=">=dev-cpp/libcutl-1.11"
DEPEND="${RDEPEND}"
BDEPEND="dev-util/build2"

S="${WORKDIR}/${MY_P}"

src_configure() {
	local myconfigargs=(
		config.cxx="$(tc-getCXX)"
		config.cxx.coptions="${CXXFLAGS}"
		config.cxx.loptions="${LDFLAGS}"
		config.bin.ar="$(tc-getAR)"
		config.bin.ranlib="$(tc-getRANLIB)"
		config.bin.lib="$(usex static-libs both shared)"
		config.install.root="${ED}/usr/"
		config.install.lib="exec_root/$(get_libdir)"
		config.install.doc="data_root/share/doc/${PF}"
	)

	MAKE=b MAKEOPTS="--jobs $(makeopts_jobs) --verbose 3" \
	emake "${myconfigargs[@]}" configure
}

src_compile() {
	tc-is-gcc && export CCACHE_DISABLE=1
	set -- b --jobs "$(makeopts_jobs)" --verbose 3 || die "set failed"
	echo "${@}" || die "echo failed"
	"${@}" || die "b failed"
}

src_test() {
	MAKE=b MAKEOPTS="--jobs $(makeopts_jobs)" emake test
}

src_install() {
	MAKE=b MAKEOPTS="--jobs $(makeopts_jobs) --verbose 3" emake install
	einstalldocs
}