selftests: netfilter: fix a build error on openSUSE
authorGeliang Tang <geliang.tang@suse.com>
Wed, 2 Mar 2022 05:29:13 +0000 (13:29 +0800)
committerShuah Khan <skhan@linuxfoundation.org>
Thu, 3 Mar 2022 22:17:54 +0000 (15:17 -0700)
This patch fixed the following build error on openSUSE Leap 15.3:

=======================================================================
 gcc     nf-queue.c -lmnl -o tools/testing/selftests/netfilter/nf-queue
 nf-queue.c:13:10: fatal error: libmnl/libmnl.h: No such file or directory
  #include <libmnl/libmnl.h>
           ^~~~~~~~~~~~~~~~~
 compilation terminated.
=======================================================================

It is because libmnl.h is put in the directory of
"/usr/include/libmnl/libmnl/" on openSUSE, not "/usr/include/libmnl/":

 > rpm -ql libmnl-devel
 /usr/include/libmnl
 /usr/include/libmnl/libmnl
 /usr/include/libmnl/libmnl/libmnl.h
 /usr/lib64/libmnl.so
 /usr/lib64/pkgconfig/libmnl.pc

Suggested-by: Kai Liu <kai.liu@suse.com>
Signed-off-by: Geliang Tang <geliang.tang@suse.com>
Reviewed-by: Shuah Khan <skhan@linuxfoundation.org>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
tools/testing/selftests/netfilter/Makefile

index e4f845dd942b3f32a07c74414f9a2f20c598ea8e..8136c1fab7ab9e18baa10cafa7d1dc69c8f81988 100644 (file)
@@ -8,6 +8,7 @@ TEST_PROGS := nft_trans_stress.sh nft_fib.sh nft_nat.sh bridge_brouter.sh \
        ipip-conntrack-mtu.sh conntrack_tcp_unreplied.sh \
        conntrack_vrf.sh nft_synproxy.sh
 
+CFLAGS += $(shell pkg-config --cflags libmnl 2>/dev/null || echo "-I/usr/include/libmnl")
 LDLIBS = -lmnl
 TEST_GEN_FILES =  nf-queue