]> The Tcpdump Group git mirrors - libpcap/blob - build.sh
Merge pull request #1039 from gokulkumar792/add_bar_and_ba_ctl_frames
[libpcap] / build.sh
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
13 if [ -z "$PREFIX" ]; then
14 # shellcheck disable=SC2006
15 PREFIX=`mktempdir libpcap_build`
16 echo "PREFIX set to '$PREFIX'"
17 DELETE_PREFIX=yes
18 fi
19
20 print_cc_version
21
22 # The norm is to compile without any warnings, but libpcap builds on some OSes
23 # are not warning-free for one or another reason. If you manage to fix one of
24 # these cases, please remember to remove respective exemption below to help any
25 # later warnings in the same matrix subset trigger an error.
26 # shellcheck disable=SC2006,SC2221,SC2222
27 case `cc_id`/`os_id` in
28 gcc-*/Linux-*)
29 # This warning is a bit odd. It is steadily present in Cirrus CI, but not
30 # in Buildbot. On my Linux system with the same exact distribution and GCC
31 # as Cirrus CI it reproduces only if GCC receives the "-g" flag:
32 # make CFLAGS=-g -- does not reproduce
33 # CFLAGS=-g make -- reproduces
34 # make -- reproduces
35 #
36 # pcap-linux.c:947:8: warning: ignoring return value of 'write', declared
37 # with attribute warn_unused_result [-Wunused-result]
38 #
39 # And even this way it does not make GCC exit with an error when it has
40 # reported the warning and has received the "-Werror" flag. So let's keep
41 # this block no-op for now.
42 ;;
43 clang-*/NetBSD-*)
44 # pcap-bpf.c:1044:18: warning: implicit conversion loses integer precision:
45 # 'uint64_t' (aka 'unsigned long') to 'u_int' (aka 'unsigned int')
46 # [-Wshorten-64-to-32]
47 # pcap-bpf.c:1045:18: warning: implicit conversion loses integer precision:
48 # 'uint64_t' (aka 'unsigned long') to 'u_int' (aka 'unsigned int')
49 # [-Wshorten-64-to-32]
50 # pcap-bpf.c:1274:39: warning: implicit conversion loses integer precision:
51 # 'long' to 'suseconds_t' (aka 'int') [-Wshorten-64-to-32]
52 LIBPCAP_TAINTED=yes
53 ;;
54 clang-*/SunOS-5.11)
55 # (Solaris 11 and OpenIndiana)
56 # pcap-bpf.c:1044:18: warning: implicit conversion loses integer precision:
57 # 'uint64_t' (aka 'unsigned long') to 'u_int' (aka 'unsigned int')
58 # [-Wshorten-64-to-32]
59 # pcap-bpf.c:1045:18: warning: implicit conversion loses integer precision:
60 # 'uint64_t' (aka 'unsigned long') to 'u_int' (aka 'unsigned int')
61 # [-Wshorten-64-to-32]
62 # fad-getad.c:266:52: warning: implicit conversion loses integer precision:
63 # 'uint64_t'(aka 'unsigned long') to 'bpf_u_int32' (aka 'unsigned int')
64 # [-Wshorten-64-to-32]
65 # (Solaris 11)
66 # pcap-bpf.c:1843:22: warning: implicit conversion loses integer precision:
67 # 'long' to 'int' [-Wshorten-64-to-32]
68 # (OpenIndiana)
69 # rpcapd.c:393:18: warning: this function declaration is not a prototype
70 # [-Wstrict-prototypes]
71 [ "`uname -p`" = i386 ] && LIBPCAP_TAINTED=yes
72 ;;
73 suncc-5.1[45]/SunOS-5.11)
74 # "scanner.l", line 257: warning: statement not reached
75 # (186 warnings for scanner.l)
76 #
77 # "./filtertest.c", line 259: warning: statement not reached
78 # "./filtertest.c", line 276: warning: statement not reached
79 # "./filtertest.c", line 281: warning: statement not reached
80 LIBPCAP_TAINTED=yes
81 ;;
82 esac
83 # shellcheck disable=SC2006
84 [ "$LIBPCAP_TAINTED" != yes ] && CFLAGS=`cc_werr_cflags`
85
86 if [ "$CMAKE" = no ]; then
87 run_after_echo ./configure --prefix="$PREFIX" --enable-remote="$REMOTE"
88 else
89 # Remove the leftovers from any earlier in-source builds, so this
90 # out-of-source build does not break because of that.
91 # https://gitlab.kitware.com/cmake/community/-/wikis/FAQ#what-is-an-out-of-source-build
92 run_after_echo rm -rf CMakeFiles/ CMakeCache.txt
93 [ ! -d build ] && run_after_echo mkdir build
94 run_after_echo cd build
95 run_after_echo cmake ${CFLAGS:+-DEXTRA_CFLAGS="$CFLAGS"} \
96 -DCMAKE_INSTALL_PREFIX="$PREFIX" -DENABLE_REMOTE="$REMOTE" ..
97 fi
98 run_after_echo "$MAKE_BIN" -s clean
99 if [ "$CMAKE" = no ]; then
100 run_after_echo "$MAKE_BIN" -s ${CFLAGS:+CFLAGS="$CFLAGS"}
101 run_after_echo "$MAKE_BIN" -s testprogs ${CFLAGS:+CFLAGS="$CFLAGS"}
102 else
103 # The "-s" flag is a no-op and CFLAGS is set using -DEXTRA_CFLAGS above.
104 run_after_echo "$MAKE_BIN"
105 run_after_echo "$MAKE_BIN" testprogs
106 fi
107 run_after_echo "$MAKE_BIN" install
108 if [ "$CMAKE" = no ]; then
109 run_after_echo testprogs/findalldevstest
110 run_after_echo "$MAKE_BIN" releasetar
111 else
112 run_after_echo run/findalldevstest
113 fi
114 handle_matrix_debug
115 if [ "$DELETE_PREFIX" = yes ]; then
116 run_after_echo rm -rf "$PREFIX"
117 fi
118 # vi: set tabstop=4 softtabstop=0 expandtab shiftwidth=4 smarttab autoindent :