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

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
#sles 10
%if 0%{?suse_version} == 1010 
BuildRequires:  xorg-x11-libs
#sles > 10 & suse
BuildRequires:  xorg-x11-libSM-devel
%define special_libsm 1
%define special_expat 1
%define special_gconf 1

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

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

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

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

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

# 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}

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.

%setup -q

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


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

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



%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


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

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

%files -f wxstd.lang
%doc docs/changes.txt docs/gpl.txt docs/lgpl.txt docs/licence.txt
%doc docs/licendoc.txt docs/preamble.txt docs/readme.txt

%files devel
%dir %{_libdir}/wx
%dir %{_libdir}/wx/include
%dir %{_libdir}/wx/config
%dir %{_datadir}/bakefile

%files -n wxBase
%doc docs/changes.txt docs/gpl.txt docs/lgpl.txt docs/licence.txt
%doc docs/licendoc.txt docs/preamble.txt docs/readme.txt