分类: LINUX
2009-06-09 18:50:40
1. 创建Android.mk
# Copyright 2009 The Android Open Source Project
LOCAL_PATH:= $(call my-dir)
################## build libecc ###################
include $(CLEAR_VARS)
LOCAL_SRC_FILES := ECC2.2-2008/ecc.c
LOCAL_C_INCLUDES += \
$(LOCAL_PATH)/ECC2.2-2008
LOCAL_CFLAGS += -Wall -W -O2 -DIWN_ECC_GCCINT64 -DASUE
LOCAL_MODULE := libecc
#LOCAL_STATIC_LIBRARIES := libcutils libc libm
include $(BUILD_STATIC_LIBRARY)
################## build libiwnwai_asue ###################
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
libiwnwai_asue/cert.c \
libiwnwai_asue/common.c \
libiwnwai_asue/hmac_sha256.c \
libiwnwai_asue/interface.c \
libiwnwai_asue/wapi.c
LOCAL_C_INCLUDES += \
$(LOCAL_PATH)/libiwnwai_asue/include
LOCAL_CFLAGS += -Wall -O2
LOCAL_MODULE := libiwnwai_asue
#LOCAL_STATIC_LIBRARIES := libcutils libc libm
include $(BUILD_STATIC_LIBRARY)
################## build libsms4 ###################
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
sms4/sms4lib/lib/sms
sms4/sms4lib/lib/wpi_pcrypt.c
LOCAL_C_INCLUDES += \
$(LOCAL_PATH)/sms4/sms4lib/lib
LOCAL_CFLAGS += -Wall -O2 -DLE
LOCAL_MODULE := libsms4
#LOCAL_STATIC_LIBRARIES := libcutils libc libm
include $(BUILD_STATIC_LIBRARY)
################## build wapic ###################
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
wapic/common.c \
wapic /config.c \
wapic /ctrl_iface.c \
wapic /driver_wext.c \
wapic /drivers.c \
wapic /eloop.c \
wapic /l2_packet_linux.c \
wapic /main.c \
wapic /wapi.c \
wapic /wapi_asue.c \
wapic /wapi_asue_retry.c \
wapic /wapi_config.c \
wapic /wapi_sm.c
LOCAL_C_INCLUDES += \
$(LOCAL_PATH)/wapic_exe/include
LOCAL_CFLAGS += -Wall -fsigned-char -O2 -DCONFIG_DRIVER_WEXT
LOCAL_MODULE:= wapic
LOCAL_STATIC_LIBRARIES := libecc libiwnwai_asue libsms4
# libcutils libc libm
#LOCAL_FORCE_STATIC_EXECUTABLE := true
#LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
#LOCAL_UNSTRIPPED_PATH := $(TARGET_ROOT_OUT_UNSTRIPPED)
#LOCAL_MODULE_TAGS := eng
include $(BUILD_EXECUTABLE)
################## copy config files ###################
wapi_cer := $(TARGET_OUT_ETC)/wifi/user.cer
$(wapi_cer) : $(LOCAL_PATH)/wapic /user.cer | $(ACP)
$(transform-prebuilt-to-target)
ALL_PREBUILT += $(wapi_cer)
wapi_conf := $(TARGET_OUT_ETC)/wifi/wapi.conf
$(wapi_conf) : $(LOCAL_PATH)/wapic /wapi.conf | $(ACP)
$(transform-prebuilt-to-target)
ALL_PREBUILT += $(wapi_conf)
2. 编译
mmm external/wapi_asue_src
在链接时报错:
out/target/product/littleton/obj/STATIC_LIBRARIES/libiwnwai_asue_intermediates/libiwnwai_asue.a(interface.o): In function `WIFI_lib_init':
external/tools/wapi_asue_app_
out/target/product/littleton/obj/STATIC_LIBRARIES/libiwnwai_asue_intermediates/libiwnwai_asue.a(wapi.o): In function `asue_x_x_p_derivation':
external/tools/wapi_asue_app_
原因:经查看libecc.a中确定包含ECC_Init 等API,为什么链接时就不行呢?经过一些时间的浪费,终于找到原因,LIB库的链接顺序不正确,将
LOCAL_STATIC_LIBRARIES := libecc libiwnwai_asue libsms4
改为
LOCAL_STATIC_LIBRARIES := libiwnwai_asue libsms4 libecc
编译即可。
继续编译,链接时仍有报错:
target Non-prelinked: wapic (out/target/product/littleton/symbols/system/bin/wapic)
out/host/linux-x86/bin/acp -fpt out/target/product/littleton/obj/EXECUTABLES/wapic_intermediates/LINKED/wapic out/target/product/littleton/symbols/system/bin/wapic
target Strip: wapic (out/target/product/littleton/obj/EXECUTABLES/wapic_intermediates/wapic)
out/host/linux-x86/bin/soslim --strip --shady --quiet out/target/product/littleton/symbols/system/bin/wapic --outfile out/target/product/littleton/obj/EXECUTABLES/wapic_intermediates/wapic
build/tools/soslim/main.c(167): Cannot create file out/target/product/littleton/obj/EXECUTABLES/wapic_intermediates/wapic: Is a directory (21)!
make: *** [out/target/product/littleton/obj/EXECUTABLES/wapic_intermediates/wapic] Error 1
wapic是我们目标程序的名字,竟然报错说是一个目录名。进入out/target/product/littleton/obj/EXECUTABLES/wapic_intermediates/目录,发现wapic目录确实存在,并且存放了原代码中编译的.o文件,看来目标程序要放的目录是不可以有同名的目录存在的。
将原代码中wapi_asue_src/ wapic 的目录名改为其它名称。再次编译,OK。
由于LIB的顺序问题,又浪费了一个多小时时间。