%define build_compat32 %{?_with_compat32:1}%{!?_with_compat32:0}

Name:		libbsd
Version:	0.10.0
Release:	1%{?_dist_release}
Summary:	Library providing BSD-compatible functions for portability
Group:		System Environment/Libraries

License:	BSD and ISC and Copyright only and Public Domain
URL:		https://libbsd.freedesktop.org/
Source0:	https://libbsd.freedesktop.org/releases/libbsd-%{version}.tar.xz

Vendor:			Project Vine
Distribution:	Vine Linux

%description
libbsd provides useful functions commonly found on BSD systems, and
lacking on others like GNU systems, thus making it easier to port
projects with strong BSD origins, without needing to embed the same
code over and over again on each project.

%package devel
Summary:	Development files for libbsd
Group:		Development/Libraries
Requires:	libbsd = %{version}-%{release}
Requires:	pkgconfig

%description devel
Development files for the libbsd library.

%package ctor-static
Summary:	Development files for libbsd-ctor
Group:		Development/Libraries
Requires:	%{name}-devel = %{version}-%{release}
Requires:	pkgconfig

%description ctor-static
Development files for the libbsd-ctor library.

# compat32
%package -n compat32-%{name}
Summary:	Library providing BSD-compatible functions for portability
Group:          System Environment/Libraries
Requires:	libbsd = %{version}-%{release}

%description -n compat32-%{name}
libbsd provides useful functions commonly found on BSD systems, and
lacking on others like GNU systems, thus making it easier to port
projects with strong BSD origins, without needing to embed the same
code over and over again on each project.


%package -n compat32-%{name}-devel
Summary:	Development files for libbsd
Group:          Development/Libraries
Requires:       compat32-%{name} = %{version}-%{release}
Requires:	compat32-pkgconfig
Requires:       %{name}-devel = %{version}-%{release}

%description -n compat32-%{name}-devel
Development files for the libbsd library.

%package -n compat32-%{name}-ctor-static
Summary:	Development files for libbsd-ctor
Group:          Development/Libraries
Requires:       compat32-%{name}-devel = %{version}-%{release}
Requires:	compat32-pkgconfig
Requires:       %{name}-devel = %{version}-%{release}

%description -n compat32-%{name}-ctor-static
Development files for the libbsd-ctor library.

%prep
%setup -q

%build
%configure
make CFLAGS="%{optflags}" %{?_smp_mflags} \
     libdir=%{_libdir} \
     usrlibdir=%{_libdir} \
     exec_prefix=%{_prefix}

%install
rm -rf %{buildroot}
make libdir=%{_libdir} \
     usrlibdir=%{_libdir} \
     exec_prefix=%{_prefix} \
     DESTDIR=%{buildroot} \
     install

# don't want static library or libtool archive
rm %{buildroot}%{_libdir}/%{name}.a
rm %{buildroot}%{_libdir}/%{name}.la

%clean
rm -rf %{buildroot}

%post -p /sbin/ldconfig

%postun -p /sbin/ldconfig

%if %{build_compat32}
%post -n compat32-%{name} -p /sbin/ldconfig

%postun -n compat32-%{name} -p /sbin/ldconfig
%endif

%files
%license COPYING
%doc README TODO ChangeLog
%{_libdir}/%{name}.so.*

%files devel
%{_mandir}/man3/*.3bsd.*
%{_mandir}/man7/%{name}.7.*
%{_includedir}/bsd
%{_libdir}/%{name}.so
%{_libdir}/pkgconfig/%{name}.pc
%{_libdir}/pkgconfig/%{name}-overlay.pc

%files ctor-static
%{_libdir}/pkgconfig/%{name}-ctor.pc
%{_libdir}/%{name}-ctor.a

# compat32
%if %{build_compat32}
%files -n compat32-%{name}
%defattr(-,root,root)
%{_libdir}/%{name}.so.*

%files -n compat32-%{name}-devel
%defattr(-,root,root)
%{_libdir}/%{name}.so
%{_libdir}/pkgconfig/%{name}.pc
%{_libdir}/pkgconfig/%{name}-overlay.pc

%files -n compat32-%{name}-ctor-static
%{_libdir}/pkgconfig/%{name}-ctor.pc
%{_libdir}/%{name}-ctor.a
%endif


%changelog
* Sat Mar 28 2020 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 0.10.0-1
- new upstream release.

* Thu Feb 22 2018 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 0.8.7-1
- new upstream release.
- added ctor-static subpackage.

* Sun Feb  1 2015 Ryoichi INAGAKI <ryo1@toki.waseda.jp> 0.7.0-1
- new upstream release.
- added compat32 subpackages

* Sun Jan 12 2014 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 0.6.0-1
- new upstream release.

* Mon Dec 17 2012 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 0.4.2-1
- new upstream release.
- initial build for Vine Linux.

* Fri Jan 13 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.3.0-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild

* Sat Oct 08 2011 Eric Smith <eric@brouhaha.com> - 0.3.0-1
- Update to latest upstream release.
- Removed Patch0, fixed upstream.
- Removed BuildRoot, clean, defattr.

* Fri Jan 29 2010 Eric Smith <eric@brouhaha.com> - 0.2.0-3
- changes based on review by Sebastian Dziallas

* Fri Jan 29 2010 Eric Smith <eric@brouhaha.com> - 0.2.0-2
- changes based on review comments by Jussi Lehtola and Ralf Corsepious

* Thu Jan 28 2010 Eric Smith <eric@brouhaha.com> - 0.2.0-1
- initial version
