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

%define xpyb_version 1.2

Summary:        A C binding to the X11 protocol
Summary(ja):    X11 プロトコルの C による実装
Name:           libxcb
Version:        1.16
Release:        1%{?_dist_release}
Group:          system
Vendor:         Project Vine
Distribution:   Vine Linux

License:        MIT
URL:            https://www.x.org/
Source0:        https://www.x.org/releases/individual/lib/%{name}-%{version}.tar.xz
# This is stolen straight from the pthread-stubs source:
# http://cgit.freedesktop.org/xcb/pthread-stubs/blob/?id=6900598192bacf5fd9a34619b11328f746a5956d
# we don't need the library because glibc has working pthreads, but we need
# the pkgconfig file so libs that link against libxcb know this...
Source1:        pthread-stubs.pc.in

BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root
BuildRequires:  autoconf
BuildRequires:  automake
BuildRequires:  libtool
BuildRequires:  pkgconfig
#BuildRequires:  doxygen
#BuildRequires:  graphviz
BuildRequires:  libXau-devel
BuildRequires:  libxslt
BuildRequires:  xcb-proto >= 1.6
BuildRequires:  xorg-x11-proto-devel
BuildRequires:  xorg-x11-util-macros
BuildRequires:  python3-devel

Obsoletes:	%{name}-python < 1.8

%description
The X protocol C-language Binding (XCB) is a replacement for Xlib featuring a
small footprint, latency hiding, direct access to the protocol, improved
threading support, and extensibility.


%package        devel
Summary:        Development files for %{name}
Summary(ja):    %{name} の開発用ファイル
Group:          programming
Requires:       %{name} = %{version}-%{release}
Requires:       pkgconfig

%description    devel
The %{name}-devel package contains libraries and header files for
developing applications that use %{name}.


%package        doc
Summary:        Documentation for %{name}
Group:          documentation

%description    doc
The %{name}-doc package contains documentation for the %{name} library.


%package        -n compat32-%{name}
Summary:        A C binding to the X11 protocol
Summary(ja):    X11 プロトコルの C による実装
Group:          system,legacy

%description    -n compat32-%{name}
The X protocol C-language Binding (XCB) is a replacement for Xlib featuring a
small footprint, latency hiding, direct access to the protocol, improved
threading support, and extensibility.


%package        -n compat32-%{name}-devel
Summary:        Development files for %{name}
Summary(ja):    %{name} の開発用ファイル
Group:          programming,legacy
Requires:       compat32-%{name} = %{version}-%{release}
Requires:       %{name}-devel = %{version}-%{release}

%description    -n compat32-%{name}-devel
The %{name}-devel package contains libraries and header files for
developing applications that use %{name}.


%debug_package


%prep
%setup -q


%build
sed -i 's/pthread-stubs //' configure.ac
autoreconf -v --install
export PYTHON=%{__python3}
%configure \
	--disable-static \
	--docdir=%{_pkgdocdir} \
	--disable-selinux \
	--enable-xkb \
	--disable-xprint \
	--disable-silent-rules

# Remove rpath from libtool (extra insurance if autoreconf is ever dropped)
sed -i 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' libtool
sed -i 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' libtool

make %{?_smp_mflags}


%install
rm -rf $RPM_BUILD_ROOT
make install DESTDIR=$RPM_BUILD_ROOT

sed 's,@libdir@,%{_libdir},;s,@prefix@,%{_prefix},;s,@exec_prefix@,%{_exec_prefix},' %{SOURCE1} > $RPM_BUILD_ROOT%{_libdir}/pkgconfig/pthread-stubs.pc

find $RPM_BUILD_ROOT -name '*.la' -delete


%clean
rm -rf $RPM_BUILD_ROOT


%files
%defattr(-,root,root,-)
%license COPYING
%doc NEWS README.md
%{_libdir}/*.so.*

%files devel
%defattr(-,root,root,-)
%{_includedir}/xcb
%{_libdir}/*.so
%{_libdir}/pkgconfig/*.pc

%files doc
%defattr(-,root,root,-)
%doc %{_pkgdocdir}/tutorial
%{_mandir}/man3/*

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

%files  -n compat32-%{name}-devel
%defattr(-,root,root,-)
%{_libdir}/*.so
%endif


%changelog
* Thu Oct 19 2023 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 1.16-1
- new upstream release.

* Tue Sep 13 2022 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 1.15-1
- new upstream release.
- dropped ldconfig scriptlets.

* Fri Aug 07 2020 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 1.14-1
- new upstream release.

* Thu Sep 05 2019 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 1.13-1
- new upstream release.

* Fri Oct 31 2014 Ryoichi INAGAKI <ryo1@toki.waseda.jp> 1.11-1
- new upstream release

* Thu Dec 26 2013 Yoji TOYODA <bsyamato@sea.plala.or.jp> 1.10-1
- new upstream release

* Sun Jun 02 2013 Yoji TOYODA <bsyamato@sea.plala.or.jp> 1.9.1-1
- new upstream release
  (including security fix for CVE-2013-2064)

* Sat Nov 17 2012 Daisuke SUZUKI <daisuke@linux.or.jp> 1.9-2
- add Source1: pthread-stubs.pc, remove patch10

* Mon Oct 08 2012 Yoji TOYODA <bsyamato@sea.plala.or.jp> 1.9-1
- new upstream release

* Sat Mar 10 2012 Yoji TOYODA <bsyamato@sea.plala.or.jp> 1.8.1-1
- new upstream release
- update Patch10 (libxcb-1.8.1-no-pthread-stubs.patch)

* Sun Jan 29 2012 Yoji TOYODA <bsyamato@sea.plala.or.jp> 1.8-1
- new upstream release
- remove Source2
- remove python sub package

* Sun Nov 07 2010 Yoji TOYODA <bsyamato@sea.plala.or.jp> 1.7-1
- new upstream release
- update Patch10

* Tue Sep 21 2010 Yoji TOYODA <bsyamato@sea.plala.or.jp> 1.5-3
- add BuildRequires: python-devel

* Tue Sep 21 2010 IWAI, Masaharu <iwai@alib.jp> 1.5-2
- build with rpm-4.8.1-1 for pkg-config file

* Mon Mar 08 2010 Daisuke SUZUKI <daisuke@linux.or.jp> 1.5-1
- new upstream release

* Tue Feb 02 2010 Shu KONNO <owa@bg.wakwak.com> 1.4-2
- rebuild with python-2.6

* Tue Nov 17 2009 Daisuke SUZUKI <daisuke@linux.or.jp> 1.4-1
- new upstream release
- add libxcb python binding (xpyb)

* Sun May 03 2009 NAKAMURA Kenta <kenta@vinelinux.org> 1.2-2
- added compat32 package for x86_64 arch support

* Wed Mar 18 2009 Daisuke SUZUKI <daisuke@linux.or.jp> 1.2-1
- new upstream release

* Mon Sep 29 2008 Shu KONNO <owa@bg.wakwak.com> 1.1-2
- spec in utf-8
- added japanese summary

* Sun May 18 2008 Daisuke SUZUKI <daisuke@linux.or.jp> 1.1-1
- new versioning policy

* Sun Jan 13 2008 Daisuke SUZUKI <daisuke@linux.or.jp> 1.1-0vl1
- initial build for Vine Linux

* Mon Nov 12 2007 Adam Jackson <ajax@redhat.com> 1.1-1
- libxcb 1.1

* Fri Aug 24 2007 Adam Jackson <ajax@redhat.com> 1.0-3
- libxcb-1.0-abstract-socket.patch: When connecting to the X server, prefer
  abstract-namespace unix sockets to filesystem-bound sockets.

* Wed Aug 22 2007 Adam Jackson <ajax@redhat.com> - 1.0-2
- Rebuild for PPC toolchain bug

* Fri Jun 29 2007 Adam Jackson <ajax@redhat.com> 1.0-1
- Initial revision.
