forked from the-tcpdump-group/tcpdump
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·151 lines (138 loc) · 5.03 KB
/
build.sh
File metadata and controls
executable file
·151 lines (138 loc) · 5.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#!/bin/sh -e
# Same as in libpcap.
if [ -n "$TARGET" ] && [ -z "$CC" ]; then
echo "Error: CC must be set if TARGET is set." >&2
exit 1
fi
# This script runs one build with setup environment variables: BUILD_LIBPCAP,
# REMOTE, CC, CMAKE, CRYPTO and SMB.
: "${BUILD_LIBPCAP:=no}"
: "${REMOTE:=no}"
: "${CC:=gcc}"
: "${CMAKE:=no}"
: "${CRYPTO:=no}"
: "${SMB:=no}"
: "${TCPDUMP_TAINTED:=no}"
: "${TCPDUMP_CMAKE_TAINTED:=no}"
: "${MAKE_BIN:=make}"
# At least one OS (AIX 7) where this software can build does not have at least
# one command (mktemp) required for a successful run of "make releasetar".
: "${TEST_RELEASETAR:=yes}"
if [ -n "$TARGET" ] && [ "$CMAKE" != no ]; then
echo "Error: this script does not implement cross-compiling with CMake." >&2
exit 1
fi
. ./build_common.sh
# Install directory prefix
if [ -z "$PREFIX" ]; then
PREFIX=`mktempdir tcpdump_build`
echo "PREFIX set to '$PREFIX'"
DELETE_PREFIX=yes
fi
TCPDUMP_BIN="$PREFIX/bin/tcpdump"
# For TESTrun
export TCPDUMP_BIN
print_cc_version
# The norm is to compile without any warnings, but tcpdump builds on some OSes
# are not warning-free for one or another reason. If you manage to fix one of
# these cases, please remember to remove respective exemption below to help any
# later warnings in the same matrix subset trigger an error.
case `cc_id`/`os_id` in
tcc-*/*)
# print-802_11.c:3317: warning: assignment discards qualifiers from pointer
# target type
TCPDUMP_TAINTED=yes
;;
suncc-5.14/SunOS-5.10|suncc-5.15/SunOS-5.10)
# "tcpdump.c", line 347: warning: function "exit_tcpdump" marked as not
# returning, might return
# "netdissect.c", line 317: warning: function "nd_trunc_longjmp" marked as
# not returning, might return
# "print.c", line 530: warning: function "ndo_error" marked as not
# returning, might return
TCPDUMP_TAINTED=yes
;;
*)
;;
esac
[ "$TCPDUMP_TAINTED" != yes ] && CFLAGS=`cc_werr_cflags`
case `cc_id`/`os_id` in
clang-*/SunOS-5.11)
# Work around https://www.illumos.org/issues/16369
[ "`uname -o`" = illumos ] && grep -Fq OpenIndiana /etc/release && CFLAGS="-Wno-fuse-ld-path${CFLAGS:+ $CFLAGS}"
;;
esac
# If necessary, set TCPDUMP_CMAKE_TAINTED here to exempt particular cmake from
# warnings. Use as specific terms as possible (e.g. some specific version and
# some specific OS).
[ "$TCPDUMP_CMAKE_TAINTED" != yes ] && CMAKE_OPTIONS='-Werror=dev'
if [ "$CMAKE" = no ]; then
if [ "$BUILD_LIBPCAP" = yes ]; then
echo "Using PKG_CONFIG_PATH=$PKG_CONFIG_PATH"
run_after_echo ./autogen.sh
run_after_echo ./configure --with-crypto="$CRYPTO" \
${TARGET:+--host=$TARGET} \
--enable-smb="$SMB" --prefix="$PREFIX"
LD_LIBRARY_PATH="$PREFIX/lib"
export LD_LIBRARY_PATH
else
run_after_echo ./autogen.sh
run_after_echo ./configure --with-crypto="$CRYPTO" \
${TARGET:+--host=$TARGET} \
--enable-smb="$SMB" --prefix="$PREFIX" --disable-local-libpcap
fi
else
# See libpcap build.sh for the rationale.
run_after_echo rm -rf CMakeFiles/ CMakeCache.txt build/
run_after_echo mkdir build
run_after_echo cd build
if [ "$BUILD_LIBPCAP" = yes ]; then
run_after_echo cmake ${CMAKE_OPTIONS:+"$CMAKE_OPTIONS"} \
-DWITH_CRYPTO="$CRYPTO" -DENABLE_SMB="$SMB" \
${CFLAGS:+-DEXTRA_CFLAGS="$CFLAGS"} \
-DCMAKE_INSTALL_PREFIX="$PREFIX" -DCMAKE_PREFIX_PATH="$PREFIX" ..
LD_LIBRARY_PATH="$PREFIX/lib"
export LD_LIBRARY_PATH
else
run_after_echo cmake ${CMAKE_OPTIONS:+"$CMAKE_OPTIONS"} \
-DWITH_CRYPTO="$CRYPTO" -DENABLE_SMB="$SMB" \
${CFLAGS:+-DEXTRA_CFLAGS="$CFLAGS"} \
-DCMAKE_INSTALL_PREFIX="$PREFIX" ..
fi
fi
run_after_echo "$MAKE_BIN" -s clean
if [ "$CMAKE" = no ]; then
run_after_echo "$MAKE_BIN" -s ${CFLAGS:+CFLAGS="$CFLAGS"}
else
# The "-s" flag is a no-op and CFLAGS is set using -DEXTRA_CFLAGS above.
run_after_echo "$MAKE_BIN"
fi
run_after_echo "$MAKE_BIN" install
print_so_deps "$TCPDUMP_BIN"
[ -z "$TARGET" ] && run_after_echo "$TCPDUMP_BIN" -h
[ -z "$TARGET" ] && run_after_echo "$TCPDUMP_BIN" -D
if [ -z "$TARGET" ] && [ "$CIRRUS_CI" = true ]; then
# Likewise for the "-J" flag and HAVE_PCAP_SET_TSTAMP_TYPE.
run_after_echo sudo \
${LD_LIBRARY_PATH:+LD_LIBRARY_PATH="$LD_LIBRARY_PATH"} \
"$TCPDUMP_BIN" -J
run_after_echo sudo \
${LD_LIBRARY_PATH:+LD_LIBRARY_PATH="$LD_LIBRARY_PATH"} \
"$TCPDUMP_BIN" -L
fi
if [ -z "$TARGET" ] && [ "$BUILD_LIBPCAP" = yes ]; then
run_after_echo "$MAKE_BIN" check
fi
if [ "$CMAKE" = no ]; then
[ "$TEST_RELEASETAR" = yes ] && run_after_echo "$MAKE_BIN" releasetar
fi
if [ -z "$TARGET" ] && [ "$CIRRUS_CI" = true ]; then
run_after_echo sudo \
${LD_LIBRARY_PATH:+LD_LIBRARY_PATH="$LD_LIBRARY_PATH"} \
"$TCPDUMP_BIN" -#n -c 10
fi
handle_matrix_debug
if [ "$DELETE_PREFIX" = yes ]; then
run_after_echo rm -rf "$PREFIX"
fi
# vi: set tabstop=4 softtabstop=0 expandtab shiftwidth=4 smarttab autoindent :