tce-load -i compiletc libnl-dev openssl-1.1.1-dev dbus-dev libxml2-dev readline-dev

wget https://w1.fi/releases/wpa_supplicant-2.9.tar.gz
wget https://w1.fi/security/2019-7/0001-AP-Silently-ignore-management-frame-from-unexpected-.patch

cd wpa_supplicant-2.9

patch -Np1 -i ../0001-AP-Silently-ignore-management-frame-from-unexpected-.patch

cat > wpa_supplicant/.config << "EOF"
CONFIG_BACKEND=file
CONFIG_BGSCAN_SIMPLE=y
CONFIG_CTRL_IFACE=y
CONFIG_DEBUG_FILE=y
CONFIG_DEBUG_SYSLOG=y
CONFIG_DEBUG_SYSLOG_FACILITY=LOG_DAEMON
CONFIG_DRIVER_NL80211=y
CONFIG_DRIVER_WEXT=y
CONFIG_DRIVER_WIRED=y
CONFIG_EAP_GTC=y
CONFIG_EAP_LEAP=y
CONFIG_EAP_MD5=y
CONFIG_EAP_MSCHAPV2=y
CONFIG_EAP_OTP=y
CONFIG_EAP_PEAP=y
CONFIG_EAP_TLS=y
CONFIG_EAP_TTLS=y
CONFIG_IEEE8021X_EAPOL=y
CONFIG_IEEE80211R=y
CONFIG_IPV6=y
CONFIG_LIBNL32=y
CONFIG_PEERKEY=y
CONFIG_PKCS12=y
CONFIG_READLINE=y
CONFIG_SMARTCARD=y
CONFIG_WPS=y
CONFIG_CTRL_IFACE_DBUS=y
CONFIG_CTRL_IFACE_DBUS_NEW=y
CONFIG_CTRL_IFACE_DBUS_INTRO=y
CFLAGS += -I/usr/local/include/libnl3
EOF

cd wpa_supplicant

find . -name Makefile -type f -exec sed -i 's/-O2//g' {} \;
find . -name Makefile -type f -exec sed -i 's/-g//g' {} \;

edit Makefile
LIBS_c += -lreadline -lncursesw

make CC="gcc -flto -march=i486 -mtune=i686 -Os -pipe" CXX="g++ -flto -march=i486 -mtune=i686 -Os -pipe -fno-exceptions -fno-rtti" BINDIR=/usr/local/sbin LIBDIR=/usr/local/lib [0m 30.28s]

sudo install -m755 wpa_cli /usr/local/sbin/
sudo install -m755 wpa_passphrase /usr/local/sbin/
sudo install -m755 wpa_supplicant /usr/local/sbin/

sudo mkdir -p /usr/local/share/dbus-1/system-services
sudo install -m644 dbus/fi.w1.wpa_supplicant1.service /usr/local/share/dbus-1/system-services/
sudo mkdir -p /usr/local/etc/dbus-1/system.d/
sudo install -m644 dbus/dbus-wpa_supplicant.conf /usr/local/etc/dbus-1/system.d/wpa_supplicant.conf