]> The Tcpdump Group git mirrors - libpcap/blob - build.sh
Remove some apparently-unneeded includes.
[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 *)
38 ;;
39 esac
40 [ "$LIBPCAP_TAINTED" != yes ] && CFLAGS=`cc_werr_cflags`
41
42 case `cc_id`/`os_id` in
43 clang-*/SunOS-5.11)
44 # Work around https://www.illumos.org/issues/16369
45 [ "`uname -o`" = illumos ] && grep -Fq OpenIndiana /etc/release && CFLAGS="-Wno-fuse-ld-path${CFLAGS:+ $CFLAGS}"
46 ;;
47 esac
48
49 # If necessary, set LIBPCAP_CMAKE_TAINTED here to exempt particular cmake from
50 # warnings. Use as specific terms as possible (e.g. some specific version and
51 # some specific OS).
52
53 [ "$LIBPCAP_CMAKE_TAINTED" != yes ] && CMAKE_OPTIONS='-Werror=dev'
54
55 if [ "$CMAKE" = no ]; then
56 run_after_echo ./autogen.sh
57 run_after_echo ./configure --prefix="$PREFIX" --enable-ipv6="$IPV6" --enable-remote="$REMOTE"
58 else
59 # Remove the leftovers from any earlier in-source builds, so this
60 # out-of-source build does not break because of that.
61 # https://gitlab.kitware.com/cmake/community/-/wikis/FAQ#what-is-an-out-of-source-build
62 # (The contents of build/ remaining after an earlier unsuccessful attempt
63 # can fail subsequent build attempts too, sometimes in non-obvious ways,
64 # so remove that directory as well.)
65 run_after_echo rm -rf CMakeFiles/ CMakeCache.txt build/
66 run_after_echo mkdir build
67 run_after_echo cd build
68 run_after_echo cmake --version
69 run_after_echo cmake ${CFLAGS:+-DEXTRA_CFLAGS="$CFLAGS"} \
70 ${CMAKE_OPTIONS:+"$CMAKE_OPTIONS"} \
71 -DCMAKE_INSTALL_PREFIX="$PREFIX" -DINET6="$IPV6" -DENABLE_REMOTE="$REMOTE" ..
72 fi
73 run_after_echo "$MAKE_BIN" -s clean
74 if [ "$CMAKE" = no ]; then
75 run_after_echo "$MAKE_BIN" -s ${CFLAGS:+CFLAGS="$CFLAGS"}
76 run_after_echo "$MAKE_BIN" -s testprogs ${CFLAGS:+CFLAGS="$CFLAGS"}
77 else
78 # The "-s" flag is a no-op and CFLAGS is set using -DEXTRA_CFLAGS above.
79 run_after_echo "$MAKE_BIN"
80 run_after_echo "$MAKE_BIN" testprogs
81 fi
82 run_after_echo "$MAKE_BIN" install
83
84 run_after_echo "$PREFIX/bin/pcap-config" --help
85 run_after_echo "$PREFIX/bin/pcap-config" --version
86 run_after_echo "$PREFIX/bin/pcap-config" --cflags
87 run_after_echo "$PREFIX/bin/pcap-config" --libs
88 run_after_echo "$PREFIX/bin/pcap-config" --additional-libs
89 run_after_echo "$PREFIX/bin/pcap-config" --libs --static
90 run_after_echo "$PREFIX/bin/pcap-config" --additional-libs --static
91 run_after_echo "$PREFIX/bin/pcap-config" --libs --static-pcap-only
92 run_after_echo "$PREFIX/bin/pcap-config" --additional-libs --static-pcap-only
93
94 [ "$REMOTE" = yes ] && run_after_echo "$PREFIX/sbin/rpcapd" -h
95
96 # VALGRIND_CMD is meant either to collapse or to expand.
97 # shellcheck disable=SC2086
98 if [ "$CMAKE" = no ]; then
99 run_after_echo $VALGRIND_CMD testprogs/findalldevstest
100 [ "$TEST_RELEASETAR" = yes ] && run_after_echo "$MAKE_BIN" releasetar
101 else
102 run_after_echo $VALGRIND_CMD run/findalldevstest
103 fi
104 handle_matrix_debug
105 if [ "$DELETE_PREFIX" = yes ]; then
106 run_after_echo rm -rf "$PREFIX"
107 fi
108 # vi: set tabstop=4 softtabstop=0 expandtab shiftwidth=4 smarttab autoindent :