File twsgluum.spec of Package twsgluum

#
# spec file for package twsgluum
#
# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#


%define build_release_tarball 1
%if 0%{?sles_version}
# don't know how to make rpmlint happy on SLE
%define build_release_tarball 0
%endif

Name:           twsgluum
Version:        0.2.0.git90.8fd1f
Release:        0
Summary:        Glue between IB's tws and unsermarkt
License:        BSD-3-Clause
Group:          Productivity/Text/Utilities
URL:            https://github.com/hroptatyr/twsgluum/
Source:         %{name}-%{version}.tar.xz
%if %{build_release_tarball}
Source1:        %{name}-rpmlintrc
%endif
# required for git builds only
BuildRequires:  autoconf
BuildRequires:  automake
BuildRequires:  gengetopt
BuildRequires:  gperf
# required for dist builds
BuildRequires:  gcc-c++
BuildRequires:  libev-devel
BuildRequires:  pkgconfig
BuildRequires:  twsapi-devel
BuildRequires:  unserding-devel
BuildRequires:  unsermarkt-devel
BuildRequires:  uterus-devel
BuildRequires:  xz
%if 0%{?centos_version:1} || 0%{?fedora_version:1} || 0%{?rhel_version:1}
BuildRequires:  expat-devel
%else
BuildRequires:  libexpat-devel
%endif
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%description
These tools connect InteractiveBroker's TWSAPI to unserding networks
using the tick data encoders from uterus.

%if %{build_release_tarball}
%package release-tarball
Summary:        Tarball to be released by upstream
Group:          Development/Libraries/Other
Requires:       do_not_install_this_but_unrpm

%description release-tarball
This packackge contains a clean "make dist" tarball to be released by
upstream maintainers. Do not install this package. Just unrpm it. In
doubt you'll never need it at all.
%endif

%prep
%setup -q

%build
test -f .version || echo %{version} | sed 's/\.git0\..*//g' > .version
autoreconf -vfi
# expat.pc is missing on most distros with expat < 2.1
if ! pkg-config --exists expat; then
    export expat_CFLAGS=" "
    export expat_LIBS="-lexpat"
fi
%configure \
    --docdir=%{_docdir}/%{name}
make V=1

%install
%{?make_install} %{!?make_install:make install DESTDIR=%{buildroot}}
# install dist tarball and create file list for release-tarball package
%if %{build_release_tarball}
make dist
dist_tarball="$(find -maxdepth 1 -name "%{name}-*.tar.xz")"
dist_tarball_dst="$(echo "%{distribution}" | sed 's,.* ,/release_obs_,g')"
mkdir -p "%{buildroot}${dist_tarball_dst}"
cp -a "${dist_tarball}" "%{buildroot}${dist_tarball_dst}"
echo "%dir ${dist_tarball_dst}" > /tmp/files_release_tarball
echo "${dist_tarball_dst}/${dist_tarball}" >> /tmp/files_release_tarball
%endif

%check
make check
# redirect distcheck output to not confuse our rpmlint
if ! make distcheck DVIS="" &> make_distcheck.log ;then
    cat make_distcheck.log
    echo "make distcheck failed"
    exit 1
fi

%clean
rm -rf %{buildroot}

%files
%defattr(-,root,root,-)
%ifnarch %arm aarch64
%{_bindir}/ibex
%{_bindir}/ibfx
%endif
%{_bindir}/ox-tws
%{_bindir}/pf-tws
%{_bindir}/quo-tws

%if %{build_release_tarball}
%files release-tarball -f /tmp/files_release_tarball
%defattr(-,root,root,-)
%endif

%changelog
openSUSE Build Service is sponsored by