# Template file for 'libfirm'
pkgname=libfirm
version=1.22.0
revision=2
build_style=gnu-makefile
hostmakedepends="perl python3"
short_desc="Graph based SSA intermediate code representation"
maintainer="Leah Neukirchen <leah@vuxu.org>"
license="LGPL-2.1-or-later"
homepage="http://libfirm.org/"
distfiles="https://github.com/MatzeB/${pkgname}/archive/${pkgname}-${version}.tar.gz"
checksum=2e681db62610a41394f1aa3a62583acff8a67cea138354be6b3d2d8d390665c3

case "$XBPS_TARGET_MACHINE" in
	aarch64*|ppc*) broken="Unsupported long double format" ;;
esac

do_configure() {
	cat <<EOF >config.mak
variant = release
CFLAGS_release = $CFLAGS -Wno-error
LINKFLAGS_release = $LDFLAGS -Wl,-soname=${pkgname}.so.${version%.*}
V = 1
CC = $CC
EOF
}

do_build() {
	export PERL5LIB=$wrksrc
	vsed -i Makefile -e 's;"\\#;"#;'
	make ${makejobs}
}

post_install() {
	vinstall build/release/libfirm.so 644 usr/lib libfirm.so.${version%.*}
	ln -s libfirm.so.${version%.*} ${DESTDIR}/usr/lib/libfirm.so
}

libfirm-devel_package() {
	short_desc+=" - development files"
	depends="${sourcepkg}>=${version}_${revision}"
	pkg_install() {
		vmove usr/include
		vmove usr/lib/*.so
		vmove usr/lib/*.a
	}
}
