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

EAPI=6

CMAKE_MIN_VERSION="3.0"

inherit cmake-utils flag-o-matic gnome2-utils

DESCRIPTION="A software synthesizer based on ZynAddSubFX"
HOMEPAGE="http://yoshimi.sourceforge.net/"
SRC_URI="mirror://sourceforge/${PN}/${P}.tar.bz2"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS=""
IUSE="+lv2"

COMMON_DEPEND=">=dev-libs/mxml-2.5
	>=media-libs/alsa-lib-1.0.17
	media-libs/fontconfig
	media-libs/libsndfile
	sci-libs/fftw:3.0
	|| ( sys-libs/glibc
		sys-libs/musl )
	sys-libs/ncurses:0=
	sys-libs/readline
	sys-libs/zlib
	virtual/jack
	x11-libs/cairo[X]
	x11-libs/fltk:1[opengl]
	lv2? ( media-libs/lv2 )"
DEPEND="${COMMON_DEPEND}
	virtual/pkgconfig"
RDEPEND=${COMMON_DEPEND}

RESTRICT="mirror"

PATCHES=( "${FILESDIR}/${PN}-1.4.1-underlinking.patch" )
DOCS=( Changelog README.txt )

CMAKE_USE_DIR="${WORKDIR}/${P}/src"

src_prepare() {
	sed -e "s#/doc/yoshimi#/doc/${PF}#" -i src/CMakeLists.txt || die
	sed -i \
		-e '/set (CMAKE_CXX_FLAGS_RELEASE/d' \
		src/CMakeLists.txt || die
	cmake-utils_src_prepare
}

src_configure() {
	append-ldflags -pthread
	local mycmakeargs=( -DLV2Plugin=$(usex lv2 ON OFF) )
	cmake-utils_src_configure
}

pkg_postinst() {
	gnome2_icon_cache_update
}

pkg_postrm() {
	gnome2_icon_cache_update
}