1#!/bin/sh -e 2 3# This script runs one build with setup environment variables: CC, CMAKE and 4# REMOTE. 5: "${CC:=gcc}" 6: "${CMAKE:=no}" 7: "${REMOTE:=no}" 8: "${LIBPCAP_TAINTED:=no}" 9: "${MAKE_BIN:=make}" 10 11. ./build_common.sh 12# Install directory prefix 13if [ -z "$PREFIX" ]; then 14 PREFIX=`mktempdir libpcap_build` 15 echo "PREFIX set to '$PREFIX'" 16 DELETE_PREFIX=yes 17fi 18 19print_cc_version 20 21# The norm is to compile without any warnings, but libpcap builds on some OSes 22# are not warning-free for one or another reason. If you manage to fix one of 23# these cases, please remember to remove respective exemption below to help any 24# later warnings in the same matrix subset trigger an error. 25# shellcheck disable=SC2221,SC2222 26case `cc_id`/`os_id` in 27gcc-*/Linux-*) 28 # This warning is a bit odd. It is steadily present in Cirrus CI, but not 29 # in Buildbot. On my Linux system with the same exact distribution and GCC 30 # as Cirrus CI it reproduces only if GCC receives the "-g" flag: 31 # make CFLAGS=-g -- does not reproduce 32 # CFLAGS=-g make -- reproduces 33 # make -- reproduces 34 # 35 # pcap-linux.c:947:8: warning: ignoring return value of 'write', declared 36 # with attribute warn_unused_result [-Wunused-result] 37 # 38 # And even this way it does not make GCC exit with an error when it has 39 # reported the warning and has received the "-Werror" flag. So let's keep 40 # this block no-op for now. 41 ;; 42clang-*/NetBSD-*) 43 # pcap-bpf.c:1044:18: warning: implicit conversion loses integer precision: 44 # 'uint64_t' (aka 'unsigned long') to 'u_int' (aka 'unsigned int') 45 # [-Wshorten-64-to-32] 46 # pcap-bpf.c:1045:18: warning: implicit conversion loses integer precision: 47 # 'uint64_t' (aka 'unsigned long') to 'u_int' (aka 'unsigned int') 48 # [-Wshorten-64-to-32] 49 # pcap-bpf.c:1274:39: warning: implicit conversion loses integer precision: 50 # 'long' to 'suseconds_t' (aka 'int') [-Wshorten-64-to-32] 51 LIBPCAP_TAINTED=yes 52 ;; 53clang-15.*/*) 54 # grammar.c:1369:14: warning: variable 'pcap_nerrs' set but not used 55 # [-Wunused-but-set-variable] 56 LIBPCAP_TAINTED=yes 57 ;; 58clang-*/SunOS-5.11) 59 # (Solaris 11 and OpenIndiana) 60 # pcap-bpf.c:1044:18: warning: implicit conversion loses integer precision: 61 # 'uint64_t' (aka 'unsigned long') to 'u_int' (aka 'unsigned int') 62 # [-Wshorten-64-to-32] 63 # pcap-bpf.c:1045:18: warning: implicit conversion loses integer precision: 64 # 'uint64_t' (aka 'unsigned long') to 'u_int' (aka 'unsigned int') 65 # [-Wshorten-64-to-32] 66 # fad-getad.c:266:52: warning: implicit conversion loses integer precision: 67 # 'uint64_t'(aka 'unsigned long') to 'bpf_u_int32' (aka 'unsigned int') 68 # [-Wshorten-64-to-32] 69 # (Solaris 11) 70 # pcap-bpf.c:1843:22: warning: implicit conversion loses integer precision: 71 # 'long' to 'int' [-Wshorten-64-to-32] 72 # (OpenIndiana) 73 # rpcapd.c:393:18: warning: this function declaration is not a prototype 74 # [-Wstrict-prototypes] 75 [ "`uname -p`" = i386 ] && LIBPCAP_TAINTED=yes 76 ;; 77suncc-5.1[45]/SunOS-5.11) 78 # "scanner.l", line 257: warning: statement not reached 79 # (186 warnings for scanner.l) 80 # 81 # "./filtertest.c", line 259: warning: statement not reached 82 # "./filtertest.c", line 276: warning: statement not reached 83 # "./filtertest.c", line 281: warning: statement not reached 84 LIBPCAP_TAINTED=yes 85 ;; 86*/Haiku-*) 87 # (GCC 8.3.0 and later, Clang 9.0.1.) 88 # pcap-haiku.cpp:55:21: warning: unused variable 'handlep' [-Wunused-variable] 89 # pcap-haiku.cpp:50:37: warning: unused parameter 'maxPackets' [-Wunused-parameter] 90 # pcap-haiku.cpp:111:47: warning: unused parameter 'buffer' [-Wunused-parameter] 91 # pcap-haiku.cpp:111:59: warning: unused parameter 'size' [-Wunused-parameter] 92 # pcap-haiku.cpp:268:26: warning: unused parameter 'name' [-Wunused-parameter] 93 # pcap-haiku.cpp:274:26: warning: unused parameter 'name' [-Wunused-parameter] 94 # pcap-haiku.cpp:274:58: warning: unused parameter 'errbuf' [-Wunused-parameter] 95 # 96 # (The warnings below come from GCC and Clang in CMake builds after installing 97 # all system updates.) 98 # gencode.c:4143:9: warning: converting a packed 'struct in6_addr' pointer 99 # (alignment 1) to a 'uint32_t' {aka 'unsigned int'} pointer (alignment 4) may 100 # result in an unaligned pointer value [-Waddress-of-packed-member] 101 # gencode.c:4144:9: warning: converting a packed 'struct in6_addr' pointer 102 # (alignment 1) to a 'uint32_t' {aka 'unsigned int'} pointer (alignment 4) may 103 # result in an unaligned pointer value [-Waddress-of-packed-member] 104 # gencode.c:7189:9: warning: converting a packed 'struct in6_addr' pointer 105 # (alignment 1) to a 'uint32_t' {aka 'unsigned int'} pointer (alignment 4) may 106 # result in an unaligned pointer value [-Waddress-of-packed-member] 107 # gencode.c:7190:9: warning: converting a packed 'struct in6_addr' pointer 108 # (alignment 1) to a 'uint32_t' {aka 'unsigned int'} pointer (alignment 4) may 109 # result in an unaligned pointer value [-Waddress-of-packed-member] 110 LIBPCAP_TAINTED=yes 111 ;; 112esac 113[ "$LIBPCAP_TAINTED" != yes ] && CFLAGS=`cc_werr_cflags` 114 115if [ "$CMAKE" = no ]; then 116 run_after_echo ./configure --prefix="$PREFIX" --enable-remote="$REMOTE" 117else 118 # Remove the leftovers from any earlier in-source builds, so this 119 # out-of-source build does not break because of that. 120 # https://gitlab.kitware.com/cmake/community/-/wikis/FAQ#what-is-an-out-of-source-build 121 # (The contents of build/ remaining after an earlier unsuccessful attempt 122 # can fail subsequent build attempts too, sometimes in non-obvious ways, 123 # so remove that directory as well.) 124 run_after_echo rm -rf CMakeFiles/ CMakeCache.txt build/ 125 run_after_echo mkdir build 126 run_after_echo cd build 127 run_after_echo cmake ${CFLAGS:+-DEXTRA_CFLAGS="$CFLAGS"} \ 128 -DCMAKE_INSTALL_PREFIX="$PREFIX" -DENABLE_REMOTE="$REMOTE" .. 129fi 130run_after_echo "$MAKE_BIN" -s clean 131if [ "$CMAKE" = no ]; then 132 run_after_echo "$MAKE_BIN" -s ${CFLAGS:+CFLAGS="$CFLAGS"} 133 run_after_echo "$MAKE_BIN" -s testprogs ${CFLAGS:+CFLAGS="$CFLAGS"} 134else 135 # The "-s" flag is a no-op and CFLAGS is set using -DEXTRA_CFLAGS above. 136 run_after_echo "$MAKE_BIN" 137 run_after_echo "$MAKE_BIN" testprogs 138fi 139run_after_echo "$MAKE_BIN" install 140# VALGRIND_CMD is meant either to collapse or to expand. 141# shellcheck disable=SC2086 142if [ "$CMAKE" = no ]; then 143 run_after_echo $VALGRIND_CMD testprogs/findalldevstest 144 run_after_echo "$MAKE_BIN" releasetar 145else 146 run_after_echo $VALGRIND_CMD run/findalldevstest 147fi 148handle_matrix_debug 149if [ "$DELETE_PREFIX" = yes ]; then 150 run_after_echo rm -rf "$PREFIX" 151fi 152# vi: set tabstop=4 softtabstop=0 expandtab shiftwidth=4 smarttab autoindent : 153