# Template file for 'efl'
pkgname=efl
version=1.24.4
revision=1
build_style=meson
configure_args="
 -Dembedded-lz4=false
 -Dcrypto=openssl
 -Dnetwork-backend=none
 -Decore-imf-loaders-disabler=$(vopt_if ibus '' ibus,)scim
 -Devas-loaders-disabler=$(vopt_if lottie '[]' json)
 -Demotion-loaders-disabler=$(vopt_if gstreamer '' gstreamer1,)$(vopt_if vlc '' libvlc,)gstreamer,xine
 -Demotion-generic-loaders-disabler=vlc
 -Dopengl=$(vopt_if opengl $(vopt_if gles2 es-egl full) none)
 $(vopt_bool elogind systemd)
 $(vopt_bool x11 x11)
 $(vopt_bool x11 xpresent)
 $(vopt_bool x11 xinput2) $(vopt_bool x11 xinput22)
 $(vopt_bool framebuffer fb)
 $(vopt_bool wayland wl)
 $(vopt_bool drm drm)
 $(vopt_bool gstreamer gstreamer)
 $(vopt_bool pulseaudio pulseaudio)
 $(vopt_bool harfbuzz harfbuzz)
 $(vopt_bool simd native-arch-optimization)
 $(vopt_bool glib glib)"
hostmakedepends="pkg-config gettext"
makedepends="
 gettext-devel libressl-devel liblz4-devel glib-devel ibus-devel
 fontconfig-devel fribidi-devel $(vopt_if harfbuzz harfbuzz-devel)
 libjpeg-turbo-devel libpng-devel giflib-devel tiff-devel libwebp-devel
 avahi-libs-devel eudev-libudev-devel bullet-devel
 libsndfile-devel libmount-devel LuaJIT-devel poppler-cpp-devel
 librsvg-devel libspectre-devel libraw-devel libopenjpeg2-devel
 $(vopt_if drm 'libdrm-devel libinput-devel libxkbcommon-devel')
 $(vopt_if elogind elogind-devel)
 $(vopt_if gstreamer gst-plugins-base1-devel)
 $(vopt_if opengl MesaLib-devel)
 $(vopt_if vlc vlc-devel)
 $(vopt_if wayland 'wayland-protocols wayland-devel')
 $(vopt_if x11 'libXcomposite-devel libXcursor-devel libXp-devel
 libXrandr-devel libXScrnSaver-devel libXdamage-devel
 libXrender-devel libXi-devel libXinerama-devel libXpresent-devel
 xcb-util-devel xcb-util-keysyms-devel xcb-util-image-devel
 xcb-util-renderutil-devel xcb-util-wm-devel xorgproto')
 $(vopt_if pulseaudio pulseaudio-devel)
 $(vopt_if lottie rlottie-devel)
 $(vopt_if ibus ibus-devel)"
short_desc="Enlightenment Foundation Libraries"
maintainer="q66 <daniel@octaforge.org>"
license="LGPL-2.1-only"
homepage="https://enlightenment.org"
changelog="https://git.enlightenment.org/core/efl.git/plain/NEWS"
distfiles="https://download.enlightenment.org/rel/libs/efl/efl-${version}.tar.xz"
checksum=617e6b29d2478259acac72e2867d1908249c01a323ff3284948e999d4787f901

if [ "$XBPS_CHECK_PKGS" ]; then
	configure_args+=" -Dbuild-tests=true"
	hostmakedepends+=" check-devel"
else
	configure_args+=" -Dbuild-tests=false"
fi

if [ "$CROSS_BUILD" ]; then
	hostmakedepends+=" gettext-devel efl-devel"
fi

case "$XBPS_TARGET_MACHINE" in
	mips*) CFLAGS="-Os";;
esac

# TODO: add option for scim (don't have it packaged)
build_options="elogind harfbuzz pulseaudio gstreamer vlc x11 wayland
 opengl gles2 drm framebuffer simd lottie glib ibus"
# wayland_egl and gl_drm need gles, so use that by default
build_options_default="elogind harfbuzz pulseaudio gstreamer x11 wayland
 opengl gles2 drm glib ibus"
desc_option_simd="Enable support for SSE3/NEON/AltiVec"
desc_option_vlc="Enable support for VLC multimedia backend"
desc_option_lottie="Enable support for Lottie JSON"
desc_option_glib="Enable GLib integration"
desc_option_ibus="Enable IBus input method support (needs glib)"

# sanitize options
if [ -n "$build_option_wayland" -a -z "$build_option_drm" ]; then
	broken="wayland requires drm"
fi
if [ -n "$build_option_ibus" -a -z "$build_option_glib" ]; then
	broken="ibus requires glib integration"
fi
if [ -n "$build_option_gles2" -a -z "$build_option_opengl" ]; then
	broken="gles2 needs opengl"
fi

# Architecture optimizations
case "$XBPS_TARGET_MACHINE" in
	aarch64*|ppc64*)
		# Enable NEON (ARM) or AltiVec (PowerPC)
		build_options_default+=" simd"
		;;
	*)
		# Do not enable on x86 because it requires SSE3
		# Do not enable on 32-bit ARM by default either
		;;
esac

post_install() {
	# don't want service file junk
	rm -rf ${DESTDIR}/usr/lib/systemd
	# don't want systemd system module
	rm -rf ${DESTDIR}/usr/lib/ecore/system/systemd
}

efl-devel_package() {
	short_desc+=" - development files"
	depends="${makedepends} efl>=${version}_${revision}"
	pkg_install() {
		vmove usr/include
		vmove "usr/lib/*.so"
		vmove usr/lib/cmake
		vmove usr/lib/pkgconfig
	}
}