# Note that this is NOT a relocatable package

%define glib2_base_version 2.48.0
%define glib2_version %{glib2_base_version}-1
%define pango_base_version 1.40.0
%define pango_version %{pango_base_version}-1
%define atk_base_version 2.20.0
%define atk_version %{atk_base_version}-1
%define cairo_base_version 1.14.4
%define cairo_version %{cairo_base_version}-1
%define gdkpixbuf2_base_version 2.32.0
%define gdkpixbuf2_version %{gdkpixbuf2_base_version}-1
%define gobject_introspection_version 1.46.0

%define base_version 3.24.29
%define bin_version 3.0.0

# biarch support
%define build_compat32 %{?_with_compat32:1}%{!?_with_compat32:0}
%define _query_suffix %{nil}
%if %{build_compat32}
%define _query_suffix -32
%endif

%define _unpackaged_files_terminate_build 1

Summary: The GIMP ToolKit (GTK+), a library for creating GUIs for X.
Summary(ja): X 用 GUI 作成ライブラリ: GIMP ツールキット(GTK+)
Name: gtk3
Version: %{base_version}
Release: 1%{?_dist_release}
Group: system
Vendor: Project Vine
Distribution: Vine Linux

License: LGPL
URL: https://www.gtk.org
%global shortver %(echo %{version} | cut -d . -f 1,2)
Source0: https://download.gnome.org/sources/gtk+/%{shortver}/gtk+-%{version}.tar.xz

# for Vine
Patch100: gtk+-3.14.0-vine-default-theme.patch

BuildRoot: %{_tmppath}/gtk-%{version}-root
BuildRequires: atk-devel >= %{atk_version}
BuildRequires: at-spi2-atk-devel
BuildRequires: pango-devel >= %{pango_version}
BuildRequires: glib2-devel >= %{glib2_version}
BuildRequires: cairo-devel >= %{cairo_version}
BuildRequires: fribidi-devel
BuildRequires: gdk-pixbuf2-devel >= %{gdkpixbuf2_version}
BuildRequires: gtk2-devel
BuildRequires: gobject-introspection-devel >= %{gobject_introspection_version}
BuildRequires: libtiff-devel >= 3.7
BuildRequires: libjpeg-turbo-devel
BuildRequires: libpng-devel
BuildRequires: jasper-devel
BuildRequires: colord-devel
BuildRequires: gtk-doc >= 1.20
BuildRequires: gamin-devel
BuildRequires: cups-devel
BuildRequires: rest-devel
BuildRequires: json-glib-devel
BuildRequires: libepoxy-devel
BuildRequires: libICE-devel
BuildRequires: libXext-devel
BuildRequires: libXi-devel
BuildRequires: libXrandr-devel >= 1.3.0
BuildRequires: libXrender-devel
BuildRequires: libXcursor-devel
BuildRequires: libXfixes-devel
BuildRequires: libXinerama-devel
BuildRequires: libXcomposite-devel
BuildRequires: libXdamage-devel
BuildRequires: pkgconfig(egl)
BuildRequires: pkgconfig(wayland-client)
BuildRequires: pkgconfig(wayland-cursor)
BuildRequires: pkgconfig(wayland-egl)
BuildRequires: pkgconfig(wayland-protocols)
BuildRequires: pkgconfig(xkbcommon)

# required for icon themes apis to work
Requires: hicolor-icon-theme
Requires: libXrandr >= 1.3.0
Requires: libwayland-client%{?_isa}
Requires: libwayland-cursor%{?_isa}
Provides: gtk-update-icon-cache = %{version}-%{release}

# We need to prereq these so we can run gtk-query-immodules-2.0
Requires(post): glib2 >= %{glib2_version}
Requires(post): atk >= %{atk_version}
Requires(post): pango >= %{pango_version}
Requires(post): libSM >= 1.1.0
# We need to prereq libtiff >= 3.7 to run gdk-pixbuf-query-loaders
Requires(post): libtiff >= 3.7

%description
GTK+ is a multi-platform toolkit for creating graphical user
interfaces. Offering a complete set of widgets, GTK+ is suitable for
projects ranging from small one-off tools to complete application
suites.


%package devel
Summary: Development tools for GTK+ applications.
Summary(ja): GTK+ (GIMP ツールキット) アプリケーション開発ツール
Group: programming
Requires: %{name} = %{version}-%{release}
Requires: pango-devel >= %{pango_version}
Requires: atk-devel >= %{atk_version}
Requires: glib2-devel >= %{glib2_version}
Requires: gdk-pixbuf2-devel >= %{gdkpixbuf2_version}
Requires: libX11-devel, libXcursor-devel, libXinerama-devel
Requires: libXext-devel, libXi-devel, libXrandr-devel
Requires: libXfixes-devel, libXcomposite-devel
Requires: libpng-devel

%description devel
The gtk+-devel package contains the header files and developer
docs for the GTK+ widget toolkit.  


#######################################################################
# compat32
%package -n compat32-%{name}
Summary: The GIMP ToolKit (GTK+), a library for creating GUIs for X.
Summary(ja): X 用 GUI 作成ライブラリ: GIMP ツールキット(GTK+)
Group: system
Requires(post): compat32-glib2 >= %{glib2_version}
Requires(post): compat32-atk >= %{atk_version}
Requires(post): compat32-pango >= %{pango_version}
Requires(post): compat32-libSM >= 1.1.0
Requires(post): compat32-libtiff >= 3.7
Requires: compat32-libXrandr >= 1.3.0

%description -n compat32-%{name}
GTK+ is a multi-platform toolkit for creating graphical user
interfaces. Offering a complete set of widgets, GTK+ is suitable for
projects ranging from small one-off tools to complete application
suites.

%package -n compat32-%{name}-devel
Summary: Development tools for GTK+ applications.
Summary(ja): GTK+ (GIMP ツールキット) アプリケーション開発ツール
Group: programming
Requires: compat32-%{name} = %{version}-%{release}
Requires: %{name}-devel = %{version}
Requires: compat32-libX11-devel, compat32-libXcursor-devel, compat32-libXinerama-devel
Requires: compat32-libXext-devel, compat32-libXi-devel, compat32-libXrandr-devel
Requires: compat32-libXfixes-devel, compat32-libXcomposite-devel
Requires: compat32-libpng-devel

%description -n compat32-%{name}-devel
The gtk+-devel package contains the header files and developer
docs for the GTK+ widget toolkit.  


%debug_package


%prep
%setup -q -n gtk+-%{version}
%patch100 -p1 -b .vine-default-theme

#for i in config.guess config.sub ; do
#	test -f %{_datadir}/libtool/$i && cp %{_datadir}/libtool/$i .
#done

%build
export CFLAGS='-fno-strict-aliasing %optflags'
%configure \
	--enable-gtk2-dependency \
	--enable-man \
	--enable-gtk-doc \
	--enable-debug=minimum \
	--disable-rebuilds \
	--disable-glibtest \
	--enable-introspection=yes \
	--enable-xkb=yes \
	--enable-xinerama=yes \
	--enable-xrandr=yes \
	--enable-xfixes=yes \
	--enable-xcomposite=yes \
	--enable-xdamage=yes \
	--enable-x11-backend \
	--enable-wayland-backend \
	--disable-packagekit \
	--enable-colord=yes


# fight unused direct deps
sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool

make %{?_smp_mflags}

%install
rm -rf $RPM_BUILD_ROOT

make install DESTDIR=$RPM_BUILD_ROOT RUN_QUERY_IMMODULES_TEST=false RUN_QUERY_LOADER_TEST=false

%find_lang gtk30
%find_lang gtk30-properties

cat gtk30.lang gtk30-properties.lang > all.lang

mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/gtk-3.0

# We need to have separate 32-bit and 64-bit binaries
# for places where we have two copies of the GTK+ package installed.
# (we might have x86_64 and i686 packages on the same system, for example.)
%if %{build_compat32}
   cp $RPM_BUILD_ROOT%{_bindir}/gtk-query-immodules-3.0 \
      $RPM_BUILD_ROOT%{_bindir}/gtk-query-immodules-3.0%{_query_suffix}
%endif
touch $RPM_BUILD_ROOT%{_libdir}/gtk-3.0/%{bin_version}/immodules.cache

mkdir -p $RPM_BUILD_ROOT%{_libdir}/gtk-3.0/modules
mkdir -p $RPM_BUILD_ROOT%{_libdir}/gtk-3.0/immodules

mv %{buildroot}%{_bindir}/gtk-update-icon-cache %{buildroot}%{_bindir}/gtk-update-icon-cache-3.0

# Remove unpackaged files
find $RPM_BUILD_ROOT -type f -name "*.la" -exec rm -f {} ';'
rm -rf $RPM_BUILD_ROOT%{_datadir}/themes/Raleigh

%clean
rm -rf $RPM_BUILD_ROOT

%post
if [ $1 = 1 ]; then
	update-alternatives \
		--install %{_bindir}/gtk-update-icon-cache gtk-update-icon-cache \
			%{_bindir}/gtk-update-icon-cache-3.0 30
fi

%postun 
if [ $1 -gt 0 ]; then
	%{_bindir}/gtk-query-immodules-3.0 --update-cache || : > /dev/null 2>&1
else
	update-alternatives \
		--remove gtk-update-icon-cache %{_bindir}/gtk-update-icon-cache-3.0
fi

%transfiletriggerin -- %{_libdir}/gtk-3.0/3.0.0/immodules
gtk-query-immodules-3.0 --update-cache &>/dev/null || :

%transfiletriggerpostun -- %{_libdir}/gtk-3.0/3.0.0/immodules
gtk-query-immodules-3.0 --update-cache &>/dev/null || :

%posttrans
if [ ! -L %{_bindir}/gtk-update-icon-cache ]; then
	rm -f %{_bindir}/gtk-update-icon-cache
	update-alternatives \
		--install %{_bindir}/gtk-update-icon-cache gtk-update-icon-cache \
			%{_bindir}/gtk-update-icon-cache-3.0 30
fi

%if %{build_compat32}
%transfiletriggerin -n compat32-%{name} -- %{_libdir}/gtk-3.0/3.0.0/immodules
gtk-query-immodules-3.0%{_query_suffix} --update-cache &>/dev/null || :

%transfiletriggerpostun -n compat32-%{name} -- %{_libdir}/gtk-3.0/3.0.0/immodules
gtk-query-immodules-3.0%{_query_suffix} --update-cache &>/dev/null || :
%endif


%files -f all.lang
%defattr(-, root, root)
%license COPYING
%doc AUTHORS ChangeLog NEWS README
%{_bindir}/gtk3-demo
%{_bindir}/gtk3-demo-application
%{_bindir}/gtk3-widget-factory
%{_bindir}/gtk-encode-symbolic-svg
%{_bindir}/gtk3-icon-browser
%{_bindir}/gtk-builder-tool
%{_bindir}/gtk-launch
%{_bindir}/gtk-query-settings
%{_bindir}/gtk-update-icon-cache-3.0
%{_bindir}/gtk-query-immodules-3.0
%{_libdir}/libgtk-3.so.*
%{_libdir}/libgdk-3.so.*
%{_libdir}/libgailutil-3.so.*
%dir %{_libdir}/gtk-3.0
%{_libdir}/gtk-3.0/%{bin_version}
%dir %{_libdir}/gtk-3.0/modules
%{_libdir}/girepository-1.0/*.typelib
%{_datadir}/applications/gtk3-demo.desktop
%{_datadir}/applications/gtk3-icon-browser.desktop
%{_datadir}/applications/gtk3-widget-factory.desktop
%{_datadir}/gettext/its/gtkbuilder*
%{_datadir}/gtk-3.0
%{_datadir}/icons/hicolor/*/apps/*
%{_datadir}/themes/Default
%{_datadir}/themes/Emacs
%dir %{_sysconfdir}/gtk-3.0
%{_sysconfdir}/gtk-3.0/im-multipress.conf
%{_datadir}/glib-2.0/schemas/*.xml

%files devel
%defattr(-, root, root)
%{_libdir}/lib*.so
%dir %{_libdir}/gtk-3.0
%{_datadir}/gtk-doc/
%{_datadir}/gir-1.0/*.gir
%{_mandir}/man1/*
%exclude %{_mandir}/man1/gtk-update-icon-cache.1.gz
%{_includedir}/*
%{_datadir}/aclocal/*
%{_libdir}/pkgconfig/*

# compat32
%if %{build_compat32}
%files -n compat32-%{name}
%defattr(-, root, root)
%{_bindir}/gtk-query-immodules-3.0%{_query_suffix}
%{_libdir}/libgtk-3.so.*
%{_libdir}/libgdk-3.so.*
%{_libdir}/libgailutil-3.so.*
%dir %{_libdir}/gtk-3.0
%{_libdir}/gtk-3.0/%{bin_version}
%dir %{_libdir}/gtk-3.0/modules
%dir %{_sysconfdir}/gtk-3.0

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

%changelog
* Sun May 09 2021 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 3.24.29-1
- new upstream release.

* Sun Mar 28 2021 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 3.24.28-1
- new upstream release.
- added wayland support.

* Mon Mar 08 2021 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 3.24.26-2
- added "Provides: /usr/bin/gtk-update-icon-cache".

* Mon Mar 08 2021 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 3.24.26-1
- new upstream release.
- enabled gtk-update-icon-cache.
- added triggers.

* Fri Feb 12 2021 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 3.24.24-1
- new upstream release.

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

* Wed Jul 29 2020 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 3.24.21-1
- new upstream release.

* Tue May 05 2020 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 3.24.20-1
- new upstream release.
- dropped Patch0, 10010, 10019 and 10020.
- dropped Source10001.

* Sat Dec 29 2018 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 3.22.30-1
- update to 3.22.30
- dropped Patch10019.
- imported Patch10019 and 10020 from CentOS.

* Mon Mar 26 2018 IWAI, Masaharu <iwaim.sub@gmail.com> 3.22.10-1
- update to 3.22.10
- sync CentOS 7 - 3.22.10-5.el7_4
 - add ja.po (Source10001)
 - add patches (Patch10018, 10019)

* Thu Jul 14 2016 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.20.6-1
- new upstream release

* Sat Dec 19 2015 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.18.6-1
- new upstream release

* Fri Nov 20 2015 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.18.5-1
- new upstream release

* Fri Nov 13 2015 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.18.4-1
- new upstream release

* Thu Oct 29 2015 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.18.2-1
- new upstream release

* Sat Oct 10 2015 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.16.7-1
- new upstream release

* Sun Jul 26 2015 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.16.6-1
- new upstream release

* Fri Jul 10 2015 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.16.5-1
- new upstream release

* Thu Jun 11 2015 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.16.4-1
- new upstream release

* Thu May 14 2015 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.16.3-1
- new upstream release

* Wed Apr 15 2015 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.16.2-1
- new upstream release

* Sat Mar 28 2015 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.16.0-1
- new upstream release
- add BuildRequires: libepoxy-devel

* Sun Mar 01 2015 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.14.9-1
- new upstream release

* Sun Feb 01 2015 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.14.8-1
- new upstream release

* Mon Jan 12 2015 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.14.7-1
- new upstream release

* Mon Dec 22 2014 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.14.6-1
- new upstream release

* Sun Nov 16 2014 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.14.5-1
- new upstream release
- add BuildRequires: gtk2-devel, rest-devel, json-glib-devel

* Sun Oct 26 2014 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.14.4-1
- new upstream release
- update Patch100 (gtk+-3.14.0-vine-default-theme.patch)

* Wed May 14 2014 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.12.2-1
- new upstream release

* Sun Apr 13 2014 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.12.1-1
- new upstream release

* Sat Mar 29 2014 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.12.0-1
- new upstream release
- update Patch100 (gtk+-3.12.0-vine-default-theme.patch)

* Sat Feb 08 2014 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.10.7-1
- new upstream release

* Sat Dec 07 2013 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.10.6-1
- new upstream release

* Sat Nov 30 2013 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.10.5-1
- new upstream release

* Sat Oct 26 2013 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.10.2-1
- new upstream release
- update Patch0 (gtk3-3.10.0-gtk-widget-size-allocate.patch)
- remove Patch1 (gtk3-3.8.2-immodule.patch)

* Fri Sep 06 2013 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.8.4-1
- new upstream release

* Tue Aug 13 2013 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.8.2-2
- add Patch1 (gtk3-3.8.2-immodule.patch)

* Sat May 18 2013 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.8.2-1
- new upstream release

* Fri Apr 26 2013 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.8.1-1
- new upstream release

* Tue Jan 08 2013 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.6.4-1
- new upstream release

* Fri Jan 04 2013 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.6.3-1
- new upstream release

* Sun Nov 11 2012 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.6.2-1
- new upstream release

* Tue Oct 16 2012 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.6.1-1
- new upstream release

* Wed Sep 26 2012 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.6.0-1
- new upstream release
- add BuildRequires: at-spi2-atk-devel

* Mon Jul 16 2012 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.4.4-1
- new upstream release

* Sat May 12 2012 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.4.3-1
- new upstream release

* Sun May 06 2012 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.4.2-1
- new upstream release

* Sun Apr 22 2012 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.4.1-1
- new upstream release
- update Patch100 (gtk+-3.4.0-vine-default-theme.patch)

* Sun Mar 18 2012 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.2.4-1
- new upstream release

* Fri Dec 23 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.2.3-1
- new upstream release

* Wed Nov 16 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.2.2-1
- new upstream release
- remove Patch1

* Sun Oct 16 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.2.1-1
- new upstream release
- add Patch1 (gtk3-3.2.1-bug658772.patch)

* Wed Sep 28 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.2.0-1
- new upstream release

* Fri Sep 23 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.1.92-1
- new upstream release

* Tue Sep 06 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.1.18-1
- new upstream release

* Sat Sep 03 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.1.16-1
- new upstream release

* Tue Aug 23 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.1.12-1
- new upstream release
- add Patch0 (gtk3-3.1.12-gtk-widget-size-allocate.patch)

* Sun Aug 14 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.1.10-2
- fix %%files

* Sat Jul 30 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.1.10-1
- new upstream release
- add BuildRequires: colord-devel

* Sun Jun 26 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.0.11-1
- new upstream release

* Sun Apr 24 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.0.9-1
- new upstream release

* Sat Apr 09 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.0.8-1
- new upstream release

* Sun Apr 03 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.0.7-1
- new upstream release

* Sun Mar 27 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.0.6-1
- new upstream release

* Wed Mar 23 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.0.4-1
- new upstream release

* Sat Mar 19 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.0.3-1
- new upstream release

* Sun Mar 13 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.0.2-1
- new upstream release

* Tue Feb 22 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.0.1-1
- new upstream release

* Fri Feb 18 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 3.0.0-1
- initial build for Vine Linux

