1 .移植準備
1 ,原始碼地址:
http://sourceforge.net/projects/iperf/files/iperf/2.0.4%20source/iperf-2.0.4.tar.gz/download , 下載 iperf-2.0.4.tar.gz ,並放到 Adroid_root/external ;
2 ,解壓到 Adroid_root/external/ iperf-2.0.4.tar.gz;
tar –zxvf iperf-2.0.4.tar.gz
2. 建立 Android.mk
cat Android.mk
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := /
compat/Thread.c /
compat/error.c /
compat/delay.cpp /
compat/gettimeofday.c /
compat/inet_ntop.c /
compat/inet_pton.c /
compat/signal.c /
compat/snprintf.c /
compat/string.c
LOCAL_SRC_FILES += /
src/Client.cpp /
src/Extractor.c /
src/Launch.cpp /
src/List.cpp /
src/Listener.cpp /
src/Locale.c /
src/PerfSocket.cpp /
src/ReportCSV.c /
src/ReportDefault.c /
src/Reporter.c /
src/Server.cpp /
src/Settings.cpp /
src/SocketAddr.c /
src/main.cpp /
src/sockets.c /
src/stdio.c /
src/tcp_window_size.c /
src/gnu_getopt.c /
src/gnu_getopt_long.c /
src/service.c
LOCAL_C_INCLUDES += /
$(LOCAL_PATH) /
$(LOCAL_PATH)/include
LOCAL_CFLAGS += -O2
LOCAL_CFLAGS += -DHAVE_CONFIG_H
LOCAL_LDLIBS += -lpthread
LOCAL_SHARED_LIBRARIES := libc libm libcutils libnetutils
LOCAL_MODULE := iperf
#LOCAL_FORCE_STATIC_EXECUTABLE := true
LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
#LOCAL_UNSTRIPPED_PATH := $(TARGET_ROOT_OUT_UNSTRIPPED)
#LOCAL_MODULE_TAGS := eng user
include $(BUILD_EXECUTABLE)
3. 先產生需要的標頭檔
./configure –host=arm
4. 代碼修改
將 external/testtools/iperf/src/Listener.cpp:382 行改成:
mreq.ipv6mr_ifindex = 0;
把 compact/signal.c 裡面的 #include "util.h"
改成 #include “../include/util.h”
把 src/sockets.c 裡面的 #include "util.h"
改成 #include “../include/util.h”
5. 編譯
$cd Adroid_root
$source build/envsetup.sh
$mmm external/iperf-2.0.4
6. 目標檔案
在 Android_root/build/out/target/product/generic/symbols/system/bin/ 目錄下就可以看到你剛才編譯產生的檔案了;這個目錄裡的檔案是帶符號資訊的,方便調試