最近在调试WIFI softap功能,发现netd源码中包含"iwpriv"相关的注释,这个工具应该会对WIFI调试非常有用,于是准备将其移植到Android上。
首先到这里下载源码,然后解压,按照网上搜出来的方法,把目录里头Makefile的CC,AR等改成交叉编译所用的,但是发现make all的时候报缺少头文件错误。用-I将头文件引入之后在ld阶段又报缺少crt0.o。折腾了半天之后依然无果,于是决定直接在目录下加个Android.mk用Android的make来编译。
一次尝试之后竟然成功了,泪流满面,以下是具体步骤:
1,在目录下cp -f wirless.29.h wirelss.h (自带的Makefile就是这么干的,根据版本选择头文件,我下载的是.29版本)
2,在目录下加入Android.mk,内容如下:
# Copyright (C) 2008 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
LOCAL_PATH := $(call my-dir)
ifneq ($(TARGET_SIMULATOR),true)
include $(CLEAR_VARS)
LOCAL_MODULE := libiw
LOCAL_MODULE_TAGS := eng
LOCAL_SRC_FILES := iwlib.c
LOCAL_C_INCLUDE += LOCAL_PATH
#LOCAL_SHARED_LIBRARIES := libiw
LOCAL_PRELINK_MODULE := false
include $(BUILD_SHARED_LIBRARY)
#================================================
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := eng
LOCAL_SRC_FILES := iwpriv.c
LOCAL_SHARED_LIBRARIES := libiw
LOCAL_MODULE := iwpriv
include $(BUILD_EXECUTABLE)
#================================================
#================================================
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := eng
LOCAL_SRC_FILES := iwlist.c
LOCAL_SHARED_LIBRARIES := libiw
LOCAL_MODULE := iwlist
include $(BUILD_EXECUTABLE)
#================================================
#================================================
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := eng
LOCAL_SRC_FILES := iwconfig.c
LOCAL_SHARED_LIBRARIES := libiw
LOCAL_MODULE := iwconfig
include $(BUILD_EXECUTABLE)
#================================================
#================================================
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := eng
LOCAL_SRC_FILES := iwspy.c
LOCAL_SHARED_LIBRARIES := libiw
LOCAL_MODULE := iwspy
include $(BUILD_EXECUTABLE)
#================================================
#================================================
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := eng
LOCAL_SRC_FILES := iwgetid.c
LOCAL_SHARED_LIBRARIES := libiw
LOCAL_MODULE := iwgetid
include $(BUILD_EXECUTABLE)
#================================================
#================================================
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := eng
LOCAL_SRC_FILES := iwevent.c
LOCAL_SHARED_LIBRARIES := libiw
LOCAL_MODULE := iwevent
include $(BUILD_EXECUTABLE)
#================================================
endif # !TARGET_SIMULATOR
PS: 有用自带的Makefile编译成功的同学请指点一下啊。