1. 环境准备
系统环境:
Distributor ID: Ubuntu
Description: Ubuntu 22.04.3 LTS
Release: 22.04
Codename: jammy
源码下载地址:
libnl:
https://www.linuxfromscratch.org/blfs/view/svn/basicnet/libnl.html
openssl:
https://www.openssl.org/source/
wpa_supplicant、hostapd
http://w1.fi/releases/
2. 代码编译
2.1 libnl
tar xzf libnl-3.8.0.tar.gz
cd libnl-3.8.0/
./configure --prefix=/home/linux/tmp/wpa_supplicant/install --host=arm-anykav500-linux-uclibcgnueabi
make
make install
2.2 openssl
tar xzf openssl-1.1.1v.tar.gz
cd openssl-1.1.1v/
./config shared no-asm --prefix=/home/linux/tmp/wpa_supplicant/install --cross-compile-prefix=arm-anykav500-linux-uclibcgnueabi-
调整Makefile:
# Variables starting with CNF_ are common variables for all product types
CNF_CPPFLAGS=-DNDEBUG
CNF_CFLAGS=-pthread -m64
CNF_CXXFLAGS=-std=c++11 -pthread -m64
删除-m64
,继续进行编译:
make
make install
2.3 wpa_supplicant
tar xzf wpa_supplicant-2.10.tar.gz
cd wpa_supplicant-2.10/wpa_supplicant/
修改defconfig:
# Uncomment following two lines and fix the paths if you have installed OpenSSL
# or GnuTLS in non-default location
-#CFLAGS += -I/usr/local/openssl/include
-#LIBS += -L/usr/local/openssl/lib
+CFLAGS += -I/home/linux/tmp/wpa_supplicant/install/include
+LIBS += -L/home/linux/tmp/wpa_supplicant/install/lib
# Some Red Hat versions seem to include kerberos header files from OpenSSL, but
# the kerberos files are not in the default include path. Following line can be
@@ -37,8 +37,9 @@ CONFIG_DRIVER_NL80211=y
# driver_nl80211.c requires libnl. If you are compiling it yourself
# you may need to point hostapd to your version of libnl.
#
-#CFLAGS += -I$<path to libnl include files>
-#LIBS += -L$<path to libnl library files>
+CFLAGS += -I/home/linux/tmp/wpa_supplicant/install/include/libnl3
+CFLAGS += -I/home/linux/tmp/wpa_supplicant/libnl-3.8.0/include/linux-private
+LIBS += -L/home/linux/tmp/wpa_supplicant/install/lib
# Additional directories for cross-compilation on Linux host for mingw target
#CFLAGS += -I/opt/mingw/mingw32/include/ddk
#LIBS += -L/opt/mingw/mingw32/lib
-#CC=mingw32-gcc
+CC=arm-anykav500-linux-uclibcgnueabi-gcc
# Driver interface for wired Ethernet drivers
-CONFIG_DRIVER_WIRED=y
+#CONFIG_DRIVER_WIRED=y
# internal = Internal TLSv1 implementation (experimental)
# linux = Linux kernel AF_ALG and internal TLSv1 implementation (experimental)
# none = Empty template
-#CONFIG_TLS=openssl
+CONFIG_TLS=openssl
# Add support for new DBus control interface
# (fi.w1.wpa_supplicant1)
-CONFIG_CTRL_IFACE_DBUS_NEW=y
+#CONFIG_CTRL_IFACE_DBUS_NEW=y
# Add introspection support for new DBus control interface
-CONFIG_CTRL_IFACE_DBUS_INTRO=y
+#CONFIG_CTRL_IFACE_DBUS_INTRO=y
# Add support for writing debug log to a file (/tmp/wpa_supplicant-log-#.txt)
-CONFIG_DEBUG_FILE=y
+#CONFIG_DEBUG_FILE=y
# should be noted that this is mainly aimed at simple cases like
# WPA2-Personal while more complex configurations like WPA2-Enterprise with an
# external RADIUS server can be supported with hostapd.
-CONFIG_AP=y
+#CONFIG_AP=y
# P2P (Wi-Fi Direct)
# This can be used to enable P2P support in wpa_supplicant. See README-P2P for
# more information on P2P operations.
-CONFIG_P2P=y
+#CONFIG_P2P=y
# Wi-Fi Display
# This can be used to enable Wi-Fi Display extensions for P2P using an external
# program to control the additional information exchanges in the messages.
-CONFIG_WIFI_DISPLAY=y
+#CONFIG_WIFI_DISPLAY=y
# Support RSN on IBSS networks
# This is needed to be able to use mode=1 network profile with proto=RSN and
# key_mgmt=WPA-PSK (i.e., full key management instead of WPA-None).
-CONFIG_IBSS_RSN=y
+#CONFIG_IBSS_RSN=y
修改Makefile:
_OBJS_VAR := OBJS
include ../src/objs.mk
wpa_supplicant: $(BCHECK) $(OBJS) $(EXTRA_progs)
- $(Q)$(LDO) $(LDFLAGS) -o wpa_supplicant $(OBJS) $(LIBS) $(EXTRALIBS)
+ $(Q)$(LDO) $(LDFLAGS) -o wpa_supplicant $(OBJS) $(LIBS) $(EXTRALIBS) -static
@$(E) " LD " $@
_OBJS_VAR := OBJS_t
@@ -1909,13 +1909,13 @@ preauth_test: $(OBJS_t2)
_OBJS_VAR := OBJS_p
include ../src/objs.mk
wpa_passphrase: $(OBJS_p)
- $(Q)$(LDO) $(LDFLAGS) -o wpa_passphrase $(OBJS_p) $(LIBS_p) $(LIBS)
+ $(Q)$(LDO) $(LDFLAGS) -o wpa_passphrase $(OBJS_p) $(LIBS_p) $(LIBS) -static
@$(E) " LD " $@
_OBJS_VAR := OBJS_c
include ../src/objs.mk
wpa_cli: $(OBJS_c)
- $(Q)$(LDO) $(LDFLAGS) -o wpa_cli $(OBJS_c) $(LIBS_c)
+ $(Q)$(LDO) $(LDFLAGS) -o wpa_cli $(OBJS_c) $(LIBS_c) -static
编译:
cp defconfig .config
export PKG_CONFIG_PATH=/home/linux/tmp/wpa_supplicant/install/lib/pkgconfig:$PKG_CONFIG_PATH
make
make DESTDIR=/home/linux/tmp/wpa_supplicant/install install
2.4 hostapd
tar xzf hostapd-2.10.tar.gz
cd hostapd-2.10/hostapd
修改defconfig:
# driver_nl80211.c requires libnl. If you are compiling it yourself
# you may need to point hostapd to your version of libnl.
#
-#CFLAGS += -I$<path to libnl include files>
-#LIBS += -L$<path to libnl library files>
+CFLAGS += -I/home/linux/tmp/wpa_supplicant/install/include
+LIBS += -L/home/linux/tmp/wpa_supplicant/install/lib
+CFLAGS += -I/home/linux/tmp/wpa_supplicant/install/include/openssl
# internal = Internal TLSv1 implementation (experimental)
# linux = Linux kernel AF_ALG and internal TLSv1 implementation (experimental)
# none = Empty template
-#CONFIG_TLS=openssl
+CONFIG_TLS=openssl
修改Makefile:
ALL=hostapd hostapd_cli
CONFIG_FILE = .config
+CC=arm-anykav500-linux-uclibcgnueabi-gcc
+
include ../src/build.rules
hostapd: $(OBJS)
- $(Q)$(CC) $(LDFLAGS) -o hostapd $(OBJS) $(LIBS)
+ $(Q)$(CC) $(LDFLAGS) -o hostapd $(OBJS) $(LIBS) -static
@$(E) " LD " $@
hostapd_cli: $(OBJS_c)
- $(Q)$(CC) $(LDFLAGS) -o hostapd_cli $(OBJS_c) $(LIBS_c)
+ $(Q)$(CC) $(LDFLAGS) -o hostapd_cli $(OBJS_c) $(LIBS_c) -static
@$(E) " LD " $@
编译:
cp defconfig .config
make
make DESTDIR=/home/linux/tmp/wpa_supplicant/install install