%global api_ver 0.50
%global priority 90
%global vala_binaries vala valac vala-gen-introspect vapigen
%global vala_manpages valac vala-gen-introspect vapigen

Name:           vala
Version:        0.50.8
Release:        2
Summary:        Compiler Using the GObject Type System
License:        LGPLv2+ and BSD
URL:            https://wiki.gnome.org/Projects/Vala
Source0:        https://download.gnome.org/sources/vala/0.50/vala-%{version}.tar.xz

BuildRequires:  flex bison glib2-devel gobject-introspection-devel
BuildRequires:  graphviz-devel libxslt dbus-x11
BuildRequires:  dbus-x11 chrpath
Requires(pre):  %{_sbindir}/alternatives
Requires:       vala-devel = %{version}-%{release} gobject-introspection-devel
Requires:       %{name} = %{version}-%{release}
Provides:       vala(api) = %{api_ver}
Obsoletes:      vala-tools < 0.34.0
Conflicts:      vala-tools < 0.34.0
Provides:       vala-tools = %{version}-%{release}

%description
Compiler Using the GObject Type System.

%package    devel
Summary:    Library and and head file for vala compiler
Provides:   vala-devel = %{version}-%{release}
Obsoletes:  vala-devel < 0.43

%description devel
Library and and head file for vala compiler.

%package    help
Summary:    Help documents for vala
Requires:   %{name} = %{version}-%{release} devhelp

%description  help
Help documents for vala.

%prep
%autosetup -n %{name}-%{version} -p1

%build
%configure
sed -i 's|/lib /usr/lib|/lib /usr/lib /lib64 /usr/lib64|' libtool
%make_build

%install
%make_install

install -d $RPM_BUILD_ROOT%{_datadir}/vala/vapi
%delete_la

chrpath -d %{buildroot}/%{_bindir}/valadoc-0.50
chrpath -d %{buildroot}/%{_bindir}/valac-0.50
chrpath -d %{buildroot}/%{_libdir}/libvaladoc-0.50.so.0.0.0
mkdir -p %{buildroot}/etc/ld.so.conf.d
echo "%{_libdir}/%{name}-0.50" > %{buildroot}/etc/ld.so.conf.d/%{name}-%{_arch}.conf
%check
make check

%pre
if [ $1 -gt 1 ] ; then
    for f in %{vala_binaries};
    do
        %{_sbindir}/alternatives --remove-all $f >& /dev/null || :
    done
    for f in %{vala_manpages};

    do
        %{_sbindir}/alternatives --remove-all $f.1.gz >& /dev/null || :
    done
fi

%post
/sbin/ldconfig

%postun
/sbin/ldconfig

%files
%license COPYING
%{_bindir}/vala
%{_bindir}/vala-%{api_ver}
%{_bindir}/valac
%{_bindir}/valac-%{api_ver}
%{_bindir}/vala-gen-introspect
%{_bindir}/vala-gen-introspect-%{api_ver}
%{_bindir}/vapigen
%{_bindir}/vapigen-%{api_ver}
%{_libdir}/pkgconfig/vapigen*.pc
%{_libdir}/vala-%{api_ver}/
%{_datadir}/aclocal/vala.m4
%{_datadir}/aclocal/vapigen.m4
%{_datadir}/vala/
%{_datadir}/vala-%{api_ver}/
%{_bindir}/valadoc
%{_bindir}/valadoc-%{api_ver}
%{_libdir}/libvaladoc-%{api_ver}.so.0*
%{_libdir}/valadoc-%{api_ver}/
%{_datadir}/valadoc-%{api_ver}/

%config(noreplace) /etc/ld.so.conf.d/*

%files devel
%license COPYING
%{_libdir}/libvala-%{api_ver}.so.*
%{_includedir}/vala-%{api_ver}
%{_libdir}/libvala-%{api_ver}.so
%{_libdir}/pkgconfig/libvala-%{api_ver}.pc
%{_includedir}/valadoc-%{api_ver}/
%{_libdir}/libvaladoc-%{api_ver}.so
%{_libdir}/pkgconfig/valadoc-%{api_ver}.pc

%files help
%{_mandir}/man1/valac.1*
%{_mandir}/man1/valac-%{api_ver}.1*
%{_mandir}/man1/vala-gen-introspect.1*
%{_mandir}/man1/vala-gen-introspect-%{api_ver}.1*
%{_mandir}/man1/vapigen.1*
%{_mandir}/man1/vapigen-%{api_ver}.1*
%{_mandir}/man1/valadoc-%{api_ver}.1*
%{_mandir}/man1/valadoc.1*
%doc %{_datadir}/devhelp/books/vala-%{api_ver}

%changelog
* Thu Dec 2 2021 caodongxia <caodongxia@huawei.com> - 0.50.8-2
- Remove rpath

* Wed Jul 21 2021 yushaogui <yushaogui@huawei.com> - 0.50.8-1
- Upgrade to 0.50.8
- Update api_ver, Version, Release, Source0

* Mon Dec 9 2019 openEuler Buildteam <buildteam@openeuler.org> - 0.42.2-2
- Package init
