File wxGTK.spec of Package wxGTK

%define x11libdir %{_prefix}/X11R6/%{_lib}

%define wxconfig_name gtk2-unicode-release-static-2.8
%define config_flags --disable-shared --enable-unicode


Name:           wxGTK
Version:        2.8.12
Release:        1.1
Summary:        GTK2 port of the wxWidgets GUI library
# The wxWindows licence is the LGPL with a specific exemption allowing
# distribution of derived binaries under any terms. (This will eventually
# change to be "wxWidgets License" once that is approved by OSI.)
License:        wxWidgets
Group:          System Environment/Libraries
URL:            http://www.wxwidgets.org/
Source0:        http://dl.sf.net/wxwindows/%{name}-%{version}.tar.gz

BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}

BuildRequires:  gtk2-devel, zlib-devel >= 1.1.4
BuildRequires:  libpng-devel, libjpeg-devel, libtiff-devel
BuildRequires:  autoconf, gettext
BuildRequires:  gcc-c++ libstdc++-devel

#opensuse and also sles!
%if 0%{?suse_version}
BuildRequires:  libexpat-devel
BuildRequires:  gconf2-devel
#sles 9
%if 0%{?sles_version} == 9
BuildRequires:  pkgconfig
BuildRequires:  XFree86-libs
%else
#sles 10
%if 0%{?suse_version} == 1010 
BuildRequires:  xorg-x11-libs
%else
#sles > 10 & suse
BuildRequires:  xorg-x11-libSM-devel
%endif
%endif
%define special_libsm 1
%define special_expat 1
%define special_gconf 1
%endif

#mandriva
%if 0%{?mandriva_version}
%ifarch x86_64
BuildRequires:  lib64sm6
%else
BuildRequires:  libsm6
%endif
BuildRequires:  libGConf2-devel
%define special_libsm 1
%define special_gconf 1
%endif

#rhel
%if 0%{?rhel_version}
#rhel4
%if 0%{?rhel_version} < 500
BuildRequires:  xorg-x11-libs
%define special_libsm 1
%endif
%endif

#defaults, if not set sepcial
%if 0%{?special_expat}
%else
BuildRequires:  expat-devel
%endif

%if 0%{?special_gconf}
%else
BuildRequires:  GConf2-devel
%endif


%if 0%{?special_libsm}
%else
BuildRequires:  libSM-devel
%endif

# all of these are for previous Fedora Extras sub-packages
Obsoletes:      wxGTK2 < 2.6.2-1
Provides:       wxGTK2 = %{version}
Obsoletes:      compat-wxGTK2 < %{version}
Obsoletes:      compat-wxGTK  < %{version}

Obsoletes:      wxGTK-common < 2.6.2-1
Provides:       wxGTK-common = %{version}
Obsoletes:      compat-wxGTK-common < %{version}

Obsoletes:      wxGTK2-xrc < 2.6.2-1
Obsoletes:      wxGTK-xrc < 2.6.2-1
Provides:       wxGTK2-xrc = %{version}
Provides:       wxGTK-xrc = %{version}
Obsoletes:      compat-wxGTK2-xrc < %{version}
Obsoletes:      compat-wxGTK-xrc < %{version}

Obsoletes:      wxGTK2-stc < 2.6.2-1
Obsoletes:      wxGTK-stc < 2.6.2-1
Provides:       wxGTK2-stc = %{version}
Provides:       wxGTK-stc = %{version}
Obsoletes:      compat-wxGTK2-stc < %{version}
Obsoletes:      compat-wxGTK-stc < %{version}

Requires:       wxBase = %{version}

%description
wxWidgets/GTK2 is the GTK2 port of the C++ cross-platform wxWidgets
GUI library, offering classes for all common GUI controls as well as a
comprehensive set of helper classes for most common application tasks,
ranging from networking to HTML display and image manipulation.


%package        devel
Group:          Development/Libraries
Summary:        Development files for the wxGTK2 library
Requires:       %{name} = %{version}
Requires:       wxBase = %{version}
Requires:       gtk2-devel
Obsoletes:      wxGTK2-devel < %{version}
Provides:       wxGTK2-devel = %{version}
Obsoletes:      wxGTK-common-devel < %{version}
Provides:       wxGTK-common-devel = %{version}
Obsoletes:      compat-wxGTK2-devel < %{version}
Obsoletes:      compat-wxGTK-devel  < %{version}
Obsoletes:      compat-wxGTK-common-devel < %{version}

%description devel
This package include files needed to link with the wxGTK2 library.



%package -n     wxBase
Summary:        Non-GUI support classes from the wxWidgets library
Group:          System Environment/Libraries

%description -n wxBase
Every wxWidgets application must link against this library. It contains
mandatory classes that any wxWidgets code depends on (like wxString) and
portability classes that abstract differences between platforms. wxBase can
be used to develop console mode applications -- it does not require any GUI
libraries or the X Window System.


%prep
%setup -q

sed -i -e 's|/usr/lib\b|%{_libdir}|' wx-config.in configure


%build

# must do this to regenerate ./configure if patching to a cvs
# version.
#autoconf

export GDK_USE_XFT=1

# this code dereferences type-punned pointers like there's no tomorrow.
CFLAGS="$RPM_OPT_FLAGS -fno-strict-aliasing"
CXXFLAGS="$RPM_OPT_FLAGS -fno-strict-aliasing"

# --disable-optimise prevents our $RPM_OPT_FLAGS being overridden
# (see OPTIMISE in configure).
%configure \
  --x-libraries=%{x11libdir} \
  --enable-soname \
  --disable-optimise \
  --enable-debug_info \
  --enable-intl \
  --enable-no_deps \
  --disable-rpath \
  --enable-geometry \
  --enable-display \
  --enable-timer \
  --enable-compat24 \
  %{config_flags} \

make %{?_smp_mflags}
make %{?_smp_mflags} -C contrib/src/stc
make %{?_smp_mflags} -C contrib/src/ogl
make %{?_smp_mflags} -C contrib/src/gizmos
make %{?_smp_mflags} -C contrib/src/svg

# Why isn't this this part of the main build? Need to investigate.
make %{?_smp_mflags} -C locale allmo

%install
rm -rf $RPM_BUILD_ROOT

%makeinstall

%makeinstall -C contrib/src/stc
%makeinstall -C contrib/src/ogl
%makeinstall -C contrib/src/gizmos
%makeinstall -C contrib/src/svg


# this ends up being a symlink into the buildroot directly -- 
# not what we want!
rm $RPM_BUILD_ROOT%{_bindir}/wx-config
ln -s %{_libdir}/wx/config/%{wxconfig_name} $RPM_BUILD_ROOT%{_bindir}/wx-config

%find_lang wxstd
%find_lang wxmsw
cat wxmsw.lang >> wxstd.lang

%clean
rm -rf $RPM_BUILD_ROOT


%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig


%post -n wxBase -p /sbin/ldconfig
%postun -n wxBase -p /sbin/ldconfig


%files -f wxstd.lang
%defattr(-,root,root,-)
%doc docs/changes.txt docs/gpl.txt docs/lgpl.txt docs/licence.txt
%doc docs/licendoc.txt docs/preamble.txt docs/readme.txt
%{_libdir}/libwx_gtk2u_adv-*.a
%{_libdir}/libwx_gtk2u_aui-*.a
%{_libdir}/libwx_gtk2u_core-*.a
%{_libdir}/libwx_gtk2u_gizmos-*.a
%{_libdir}/libwx_gtk2u_gizmos_xrc*.a
%{_libdir}/libwx_gtk2u_html-*.a
%{_libdir}/libwx_gtk2u_ogl-*.a
%{_libdir}/libwx_gtk2u_qa-*.a
%{_libdir}/libwx_gtk2u_richtext-*.a
%{_libdir}/libwx_gtk2u_stc-*.a
%{_libdir}/libwx_gtk2u_svg-*.a
%{_libdir}/libwx_gtk2u_xrc-*.a

%files devel
%defattr(-,root,root,-)
%{_bindir}/wx-config
%{_bindir}/wxrc*
%{_includedir}/wx-2.8
%{_libdir}/libwx*.a
%dir %{_libdir}/wx
%dir %{_libdir}/wx/include
%{_libdir}/wx/include/gtk2*
%dir %{_libdir}/wx/config
%{_libdir}/wx/config/gtk2*
%{_datadir}/aclocal/*
%dir %{_datadir}/bakefile
%{_datadir}/bakefile/presets/


%files -n wxBase
%defattr(-,root,root,-)
%doc docs/changes.txt docs/gpl.txt docs/lgpl.txt docs/licence.txt
%doc docs/licendoc.txt docs/preamble.txt docs/readme.txt
%{_libdir}/libwx_baseu-*.a
%{_libdir}/libwx_baseu_net-*.a
%{_libdir}/libwx_baseu_xml-*.a
%{_libdir}/libwxregexu-*.a