File xtables-addons.spec of Package xtables-addons

#
# spec file for package xtables-addons
#
# Copyright (c) 2022 SUSE LLC
#
# 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 https://bugs.opensuse.org/
#


%bcond_with clang

Name:           xtables-addons
Version:        3.19
Release:        0
Summary:        IP Packet Filter Administration Extensions
License:        GPL-2.0-only AND GPL-2.0-or-later
Group:          Productivity/Networking/Security
URL:            http://xtables-addons.sf.net/

#Git-Clone:	git://git.inai.de/xtables-addons
Source:         https://inai.de/files/%name/%name-%version.tar.xz
Source2:        https://inai.de/files/%name/%name-%version.tar.asc
Source3:        %name-preamble
Source4:        %name.keyring
Patch1:         sle-kernels.patch
BuildRequires:  %kernel_module_package_buildreqs
BuildRequires:  automake
BuildRequires:  kernel-syms >= 4.16
BuildRequires:  libtool
BuildRequires:  pkg-config >= 0.21
BuildRequires:  xz
BuildRequires:  pkgconfig(xtables) >= 1.6.0
Requires:       perl(Getopt::Long)
Requires:       perl(Net::CIDR::Lite)
Requires:       perl(Socket)
Requires:       perl(Text::CSV_XS)
Requires:       perl(strict)
Requires:       perl(warnings)
Recommends:     %name-kmp
Recommends:     xtables-geoip

%define xtlibdir %(pkg-config xtables --variable=xtlibdir)

%kernel_module_package -n %name -p %name-preamble -x um pv xen

%description
Xtables is used to set up, maintain, and inspect the tables of IP
packet filter rules in the Linux kernel.

Xtables-addons is the successor to patch-o-matic(-ng). Likewise, it
contains extensions that were not, or are not yet, accepted in the
main kernel/iptables packages.

%package KMP
Summary:        IP Packet Filter Administration Extensions
Group:          System/Kernel

%description KMP
Xtables is used to set up, maintain, and inspect the tables of IP
packet filter rules in the Linux kernel.

Xtables-addons is the successor to patch-o-matic(-ng). Likewise, it
contains extensions that were not, or are not yet, accepted in the
main kernel/iptables packages.

%prep
%autosetup -p1

%build
mkdir -p ${HOME}/.cache/build
touch ${HOME}/.cache/build/%{name}.env

%if %{with clang}
export GCC=no CC=clang CPP='clang -E' CXX=clang++ LD='ld.lld' CCLD='clang -fuse-ld=lld.ld' CXXLD='clang -fuse-ld=lld.ld' AR=llvm-ar AS=llvm-as NM=llvm-nm OBJCOPY=llvm-objcopy OBJDUMP=llvm-objdump RANLIB=llvm-ranlib DLLTOOL=llvm-dlltool
export MAKE_ARGS="$MAKE_ARGS %{?_smp_mflags}"
export HOST_EXTRACFLAGS="-v -fPIC -O3 -fuse-ld=lld -fno-fast-math -fglobal-isel -flto=thin"
export HOST_EXTRALDFLAGS="-fPIC -O3 -fuse-ld=lld -Wl,-O1"
export CFLAGS="${HOST_EXTRACFLAGS}" FFLAGS="${HOST_EXTRACFLAGS}" FCFLAGS="${HOST_EXTRACFLAGS}"
export CFLAGS_MODULE="${CFLAGS}"
export LDFLAGS="${HOST_EXTRALDFLAGS}"
export LDFLAGS_MODULE="${LDFLAGS}"
export KCFLAGS="${CFLAGS}"

cat > ${HOME}/.cache/build/%{name}.env <<EOF
alias gcc=clang
alias ld=ld.lld
export GCC=no CC=clang CPP='clang -E' CXX=clang++ LD='ld.lld' CCLD='clang -fuse-ld=lld.ld' CXXLD='clang -fuse-ld=lld.ld' AR=llvm-ar AS=llvm-as NM=llvm-nm OBJCOPY=llvm-objcopy OBJDUMP=llvm-objdump RANLIB=llvm-ranlib DLLTOOL=llvm-dlltool
export MAKE_ARGS="${MAKE_ARGS} LLVM=1 LLVM_IAS=1 CC=clang AR=llvm-ar AS=llvm-as NM=llvm-nm OBJCOPY=llvm-objcopy OBJDUMP=llvm-objdump RANLIB=llvm-ranlib DLLTOOL=llvm-dlltool"
export HOST_EXTRACFLAGS="-v -fPIC -O3 -fuse-ld=lld -fno-fast-math -fglobal-isel -flto=thin"
export HOST_EXTRALDFLAGS="-fPIC -O3 -fuse-ld=lld -Wl,-O1"
export CFLAGS="${HOST_EXTRACFLAGS}" FFLAGS="${HOST_EXTRACFLAGS}" FCFLAGS="${HOST_EXTRACFLAGS}"
export CFLAGS_MODULE="${CFLAGS}"
export LDFLAGS="${HOST_EXTRALDFLAGS}"
export LDFLAGS_MODULE="${LDFLAGS}"
export KCFLAGS="${CFLAGS}"
EOF

source ${HOME}/.cache/build/%{name}.env

GCC=no CC=${CC} CPP="${CPP} -E" CXX=${CXX} LD="${LD}" CCLD="${CCLD}" CXXLD="${CXXLD}" \
AR=${AR} AS=${AS} NM=${NM} OBJCOPY=${OBJCOPY} OBJDUMP=${OBJDUMP} RANLIB=${RANLIB} \
CFLAGS="${HOST_EXTRACFLAGS}" FFLAGS="${HOST_EXTRACFLAGS}" FCFLAGS="${HOST_EXTRACFLAGS}" LDFLAGS="${HOST_EXTRALDFLAGS}" \
%endif
autoreconf -fiv
pushd ../
for flavor in %flavors_to_build; do
	cp -a "%name-%version" "%name-$flavor-%version"
	pushd "%name-$flavor-%version/"
	%configure --with-kbuild="/usr/src/linux-obj/%_target_cpu/$flavor" || { cat config.log; exit 1; }
	%make_build %{?linux_make_arch} ${MAKE_ARGS} \
%if %{with clang}
    GCC=no CC=${CC} CPP="${CPP} -E" CXX=${CXX} LD="${LD}" CCLD="${CCLD}" CXXLD="${CXXLD}" \
    LD='ld.lld' CCLD='clang -fuse-ld=lld.ld' CXXLD='clang -fuse-ld=lld.ld' \
%endif
    V=1
	popd
done

%install
b="%buildroot"
# kernel's make install is picky about flags changing between %%build and %%install
source ${HOME}/.cache/build/%{name}.env
pushd ../
for flavor in %flavors_to_build; do
	pushd "%name-$flavor-%version/"
	%make_install %{?linux_make_arch} \
%if %{with clang}
    GCC=no CC=${CC} CPP="${CPP} -E" CXX=${CXX} LD="${LD}" CCLD="${CCLD}" CXXLD="${CXXLD}" \
    LD='ld.lld' CCLD='clang -fuse-ld=lld.ld' CXXLD='clang -fuse-ld=lld.ld' \
%endif
    V=1
	popd
done
# There is no -devel package. So no need for these files.
find "$b/%_prefix" -iname "*.la" -delete
find "$b/%_libdir" -maxdepth 1 -type l -iname "*.so" -delete

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

%files
%_bindir/xt_geoip*
%_mandir/man*/*
%_sbindir/*
%_libdir/*.so.*
%xtlibdir/
%_libexecdir/xtables-addons/
%license LICENSE

%changelog
openSUSE Build Service is sponsored by