##
##  vortex.spec -- OpenPKG RPM Package Specification
##  Copyright (c) 2000-2025 OpenPKG Project <http://openpkg.org/>
##
##  Permission to use, copy, modify, and distribute this software for
##  any purpose with or without fee is hereby granted, provided that
##  the above copyright notice and this permission notice appear in all
##  copies.
##
##  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
##  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
##  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
##  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
##  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
##  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
##  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
##  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
##  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
##  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
##  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
##  SUCH DAMAGE.
##

#   package version
%define       V_external 1.1.12
%define       V_internal b5014.g5015

#   package information
Name:         vortex
Summary:      BEEP Core Network Protocol Toolkit
URL:          http://vortex.aspl.es/
Vendor:       ASPL
Packager:     OpenPKG Project
Distribution: OpenPKG Community
Class:        EVAL
Group:        Networking
License:      LGPL
Version:      %{V_external}
Release:      20120726

#   package options
%option       with_ssl     yes
%option       with_sasl    yes
%option       with_xmlrpc  yes

#   list of sources
Source0:      http://vortexlibrary.googlecode.com/files/vortex-%{V_external}.%{V_internal}.tar.gz
Patch0:       vortex.patch

#   build information
BuildPreReq:  OpenPKG, openpkg >= 20160101, pkgconfig
PreReq:       OpenPKG, openpkg >= 20160101
BuildPreReq:  axl >= 0.6.2, glib, readline
PreReq:       axl >= 0.6.2, glib, readline
%if "%{with_ssl}" == "yes"
BuildPreReq:  openssl
PreReq:       openssl
%endif
%if "%{with_sasl}" == "yes"
BuildPreReq:  libgsasl
PreReq:       libgsasl
%endif

%description
    Vortex is a C implementation of the BEEP Core network protocol (RFC
    3080, RFC 3081), implemented on top of TCP/IP. Additionally, it
    comes with SSL/TLS and SASL profiles plus a complete XML-RPC over
    BEEP (RFC 3529) implementation.

%track
    prog vortex = {
        version   = %{V_external}.%{V_internal}
        url       = http://code.google.com/p/vortexlibrary/downloads/list
        regex     = vortex-(__VER__)\.tar\.gz
    }

%prep
    %setup -q -n vortex-%{V_external}.%{V_internal}
    %patch -p0

%build
    CC="%{l_cc}"
    CFLAGS="%{l_cflags -O}"
    CPPFLAGS="%{l_cppflags}"
    LDFLAGS="%{l_ldflags}"
    CFLAGS="%{l_cppflags} `pkg-config gthread-2.0 glib-2.0 --cflags`"
    LIBS="%{l_ldflags} `pkg-config gthread-2.0 glib-2.0 --libs`"
    CFLAGS="$CFLAGS `pkg-config readline --cflags`"
    LIBS="$LIBS `pkg-config readline --libs`"
%if "%{with_ssl}" == "yes"
    CFLAGS="$CFLAGS `pkg-config openssl --cflags`"
    LIBS="$LIBS `pkg-config openssl --libs`"
%endif
    export CC CFLAGS CPPFLAGS LDFLAGS LIBS
    ./configure \
        --prefix=%{l_prefix} \
%if "%{with_ssl}" == "yes"
        --enable-tls-support \
%else
        --disable-tls-support \
%endif
%if "%{with_sasl}" == "yes"
        --enable-sasl-support \
%else
        --disable-sasl-support \
%endif
%if "%{with_xmlrpc}" == "yes"
        --enable-xml-rpc-support \
%else
        --disable-xml-rpc-support \
%endif
        --disable-vortex-log \
        --disable-vortex-doc \
        --disable-py-vortex \
        --disable-py-vortex-log \
        --disable-shared

    %{l_make} %{l_mflags -O}

%install
    %{l_make} %{l_mflags} install AM_MAKEFLAGS="DESTDIR=$RPM_BUILD_ROOT"
    strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true
    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std}

%files -f files

%clean

