Skip to content

Commit 7b94035

Browse files
committed
Fixed OSX compatibility
1 parent 87c1be0 commit 7b94035

File tree

2 files changed

+34
-6
lines changed

2 files changed

+34
-6
lines changed

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
Overview
22
--------
3-
This script downloads and compiles tcpdump for use on Android devices.
3+
This script downloads and compiles tcpdump for use on Android devices. It works on Linux and OSX.
44

55
It creates PIE (Position Independant Executable) files, so they also work on Lollipop and Marshmallow.
66

77
How to use
88
----------
99
Install the latest [Android NDK](http://developer.android.com/ndk/downloads/index.html) then:
1010

11-
export NDK=/path/to/ndk
12-
./build-android-tcpdump
11+
./build-android-tcpdump -n /path/to/ndk
1312

1413
Options
1514
-------

build-android-tcpdump

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ download_file() {
112112
local URL="$1"
113113
if [ "${DOWNLOADER}" = "wget" ]; then
114114
wget "${URL}"
115-
elif ["${DOWNLOADER}" = "curl"]; then
115+
elif [ "${DOWNLOADER}" = "curl" ]; then
116116
curl -O "${URL}"
117117
fi
118118
if [ $? -ne 0 ]; then
@@ -205,7 +205,7 @@ check_compiler_tools() {
205205
CC=""
206206
COMPILERS=$(find "${NDK}/toolchains/${toolchain_dir}/prebuilt" -type f -name "*-gcc")
207207
for compiler in $COMPILERS; do
208-
echo -n "Testing ${compiler}... "
208+
printf "Testing ${compiler}... "
209209
$compiler --version >/dev/null 2>&1
210210
if [ $? -eq 0 ]; then
211211
echo "OK"
@@ -218,12 +218,30 @@ check_compiler_tools() {
218218
if [ -z "${CC}" ]; then
219219
echo "ERROR: Can't find a valid compiler"
220220
fi
221+
222+
RANLIB_TOOL=""
223+
RANLIBS=$(find "${NDK}/toolchains/${toolchain_dir}/prebuilt" -type f -name "*-ranlib")
224+
for ranlib in $RANLIBS; do
225+
printf "Testing ${ranlib}... "
226+
$ranlib --version >/dev/null 2>&1
227+
if [ $? -eq 0 ]; then
228+
echo "OK"
229+
RANLIB_TOOL="${ranlib}"
230+
break
231+
fi
232+
echo "NOT VALID"
233+
done
234+
235+
if [ -z "${RANLIB_TOOL}" ]; then
236+
echo "ERROR: Can't find a valid ranlib tool"
237+
fi
238+
221239

222240
if [ "${SHOULD_STRIP}" = "yes" ]; then
223241
STRIP_TOOL=""
224242
local STRIP_TOOLS=$(find "${NDK}/toolchains/${toolchain_dir}/prebuilt" -type f -name "*-strip")
225243
for strip_tool in $STRIP_TOOLS; do
226-
echo -n "Testing ${strip_tool}... "
244+
printf "Testing ${strip_tool}... "
227245
$strip_tool --version >/dev/null 2>&1
228246
if [ $? -eq 0 ]; then
229247
echo "OK"
@@ -367,6 +385,17 @@ for ARCH in ${ARCHS}; do
367385
exit 4
368386
fi
369387

388+
if [ ! -f libpcap.a ]; then
389+
echo "ERROR: lipcap.a not generated"
390+
exit 4
391+
fi
392+
393+
${RANLIB_TOOL} libpcap.a
394+
if [ $? -ne 0 ]; then
395+
echo "ERROR: Failed executing ${RANLIB_TOOL} on libpcap.a"
396+
exit 4
397+
fi
398+
370399
echo "Compiling tcpdump for ${ARCH}..."
371400
cd "${DIR_TCPDUMP}"
372401

0 commit comments

Comments
 (0)