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