]> The Tcpdump Group git mirrors - libpcap/blob - build.sh
Address/note warnings from Clang 3.4 on Ubuntu 14.04.6.
[libpcap] / build.sh
1 #!/bin/sh -e
2
3 # This script runs one build with setup environment variables: CC, CMAKE, IPV6
4 # and REMOTE.
5 : "${CC:=gcc}"
6 : "${CMAKE:=no}"
7 : "${IPV6:=no}"
8 : "${REMOTE:=no}"
9 : "${LIBPCAP_TAINTED:=no}"
10 : "${LIBPCAP_CMAKE_TAINTED:=no}"
11 : "${MAKE_BIN:=make}"
12 # At least one OS (AIX 7) where this software can build does not have at least
13 # one command (mktemp) required for a successful run of "make releasetar".
14 : "${TEST_RELEASETAR:=yes}"
15
16 . ./build_common.sh
17 # Install directory prefix
18 if [ -z "$PREFIX" ]; then
19 PREFIX=`mktempdir libpcap_build`
20 echo "PREFIX set to '$PREFIX'"
21 DELETE_PREFIX=yes
22 fi
23
24 print_cc_version
25
26 # The norm is to compile without any warnings, but libpcap builds on some OSes
27 # are not warning-free for one or another reason. If you manage to fix one of
28 # these cases, please remember to remove respective exemption below to help any
29 # later warnings in the same matrix subset trigger an error.
30 # shellcheck disable=SC2221,SC2222
31 case `cc_id`/`os_id` in
32 tcc-*/*)
33 # At least one warning is expected because TCC does not implement
34 # thread-local storage.
35 LIBPCAP_TAINTED=yes
36 ;;
37 clang-3.4/Linux-*)
38 # pcap-netfilter-linux.c:427:10: error: will never be executed
39 # [-Werror,-Wunreachable-code]
40 # pcap.c:3812:4: error: will never be executed
41 # [-Werror,-Wunreachable-code]
42 # scanner.l:662:3: warning: will never be executed [-Wunreachable-code]
43 # gencode.c:7061:3: warning: will never be executed [-Wunreachable-code]
44 LIBPCAP_TAINTED=yes
45 ;;
46 *)
47 ;;
48 esac
49 [ "$LIBPCAP_TAINTED" != yes ] && CFLAGS=`cc_werr_cflags`
50
51 case `cc_id`/`os_id` in
52 clang-*/SunOS-5.11)
53 # Work around https://www.illumos.org/issues/16369
54 [ "`uname -o`" = illumos ] && grep -Fq OpenIndiana /etc/release && CFLAGS="-Wno-fuse-ld-path${CFLAGS:+ $CFLAGS}"
55 ;;
56 esac
57
58 # If necessary, set LIBPCAP_CMAKE_TAINTED here to exempt particular cmake from
59 # warnings. Use as specific terms as possible (e.g. some specific version and
60 # some specific OS).
61
62 [ "$LIBPCAP_CMAKE_TAINTED" != yes ] && CMAKE_OPTIONS='-Werror=dev'
63
64 if [ "$CMAKE" = no ]; then
65 run_after_echo ./autogen.sh
66 run_after_echo ./configure --prefix="$PREFIX" --enable-ipv6="$IPV6" --enable-remote="$REMOTE"
67 else
68 # Remove the leftovers from any earlier in-source builds, so this
69 # out-of-source build does not break because of that.
70 # https://gitlab.kitware.com/cmake/community/-/wikis/FAQ#what-is-an-out-of-source-build
71 # (The contents of build/ remaining after an earlier unsuccessful attempt
72 # can fail subsequent build attempts too, sometimes in non-obvious ways,
73 # so remove that directory as well.)
74 run_after_echo rm -rf CMakeFiles/ CMakeCache.txt build/
75 run_after_echo mkdir build
76 run_after_echo cd build
77 run_after_echo cmake --version
78 run_after_echo cmake ${CFLAGS:+-DEXTRA_CFLAGS="$CFLAGS"} \
79 ${CMAKE_OPTIONS:+"$CMAKE_OPTIONS"} \
80 -DCMAKE_INSTALL_PREFIX="$PREFIX" -DINET6="$IPV6" -DENABLE_REMOTE="$REMOTE" ..
81 fi
82 run_after_echo "$MAKE_BIN" -s clean
83 if [ "$CMAKE" = no ]; then
84 run_after_echo "$MAKE_BIN" -s ${CFLAGS:+CFLAGS="$CFLAGS"}
85 run_after_echo "$MAKE_BIN" -s testprogs ${CFLAGS:+CFLAGS="$CFLAGS"}
86 else
87 # The "-s" flag is a no-op and CFLAGS is set using -DEXTRA_CFLAGS above.
88 run_after_echo "$MAKE_BIN"
89 run_after_echo "$MAKE_BIN" testprogs
90 fi
91 run_after_echo "$MAKE_BIN" install
92
93 run_after_echo "$PREFIX/bin/pcap-config" --help
94 run_after_echo "$PREFIX/bin/pcap-config" --version
95 run_after_echo "$PREFIX/bin/pcap-config" --cflags
96 run_after_echo "$PREFIX/bin/pcap-config" --libs
97 run_after_echo "$PREFIX/bin/pcap-config" --additional-libs
98 run_after_echo "$PREFIX/bin/pcap-config" --libs --static
99 run_after_echo "$PREFIX/bin/pcap-config" --additional-libs --static
100 run_after_echo "$PREFIX/bin/pcap-config" --libs --static-pcap-only
101 run_after_echo "$PREFIX/bin/pcap-config" --additional-libs --static-pcap-only
102
103 [ "$REMOTE" = yes ] && run_after_echo "$PREFIX/sbin/rpcapd" -h
104
105 # VALGRIND_CMD is meant either to collapse or to expand.
106 # shellcheck disable=SC2086
107 if [ "$CMAKE" = no ]; then
108 FILTERTEST_BIN="$VALGRIND_CMD testprogs/filtertest"
109 export FILTERTEST_BIN
110 run_after_echo "$MAKE_BIN" -s check
111 run_after_echo $VALGRIND_CMD testprogs/findalldevstest
112 [ "$TEST_RELEASETAR" = yes ] && run_after_echo "$MAKE_BIN" releasetar
113 else
114 FILTERTEST_BIN="$VALGRIND_CMD run/filtertest"
115 export FILTERTEST_BIN
116 run_after_echo "$MAKE_BIN" -s check
117 run_after_echo $VALGRIND_CMD run/findalldevstest
118 fi
119 handle_matrix_debug
120 if [ "$DELETE_PREFIX" = yes ]; then
121 run_after_echo rm -rf "$PREFIX"
122 fi
123 # vi: set tabstop=4 softtabstop=0 expandtab shiftwidth=4 smarttab autoindent :