#! /bin/bash PLATFORM='hi3519dv500' PLATFORM_COMPILE=aarch64-v01c01-linux-musl- COMPILE_CC="$PLATFORM_COMPILE"gcc COMPILE_STRIP="$PLATFORM_COMPILE"strip COMPILE_AR="$PLATFORM_COMPILE"ar COMPILE_RANLIB="$PLATFORM_COMPILE"ranlib INSTALL_DIR=__install_$PLATFORM ROOT_DIR=$(pwd) LIBNL_DIR=$ROOT_DIR/libnl-3.2.25 OPENSSL_DIR=$ROOT_DIR/openssl-1.1.1w HOSTAPD_DIR=$ROOT_DIR/hostapd-2.10 WPA_DIR=$ROOT_DIR/wpa_supplicant-2.10 WIRELESS_TOOLS_DIR=$ROOT_DIR/wireless_tools.29 OUT_PUT_DIR=$ROOT_DIR/output build_libnl() { cd $ROOT_DIR if [ ! -f libnl-3.2.25.tar.gz ];then wget https://www.infradead.org/~tgr/libnl/files/libnl-3.2.25.tar.gz if [ ! -f libnl-3.2.25.tar.gz ];then exit fi fi if [ ! -d libnl-3.2.25 ];then tar -xvf libnl-3.2.25.tar.gz fi cd $LIBNL_DIR mkdir -p $INSTALL_DIR ./configure --host=arm CC=$COMPILE_CC --prefix=$(pwd)/$INSTALL_DIR --enable-static make clean make -j8 make install } build_openssl() { cd $ROOT_DIR if [ ! -f openssl-1.1.1w.tar.gz ];then wget https://www.openssl.org/source/old/1.1.1/openssl-1.1.1w.tar.gz if [ ! -f openssl-1.1.1w.tar.gz ];then exit fi fi if [ ! -d openssl-1.1.1w ];then tar -xvf openssl-1.1.1w.tar.gz fi cd $OPENSSL_DIR mkdir -p $INSTALL_DIR ./config no-asm no-shared no-async --prefix=$PWD/$INSTALL_DIR #修改Makefile #PLATFORM=linux-x86 sed -i s/^PLATFORM.*/PLATFORM="linux-armv7"/g ./Makefile #CROSS_COMPILE sed -i s/^CROSS_COMPILE.*/CROSS_COMPILE="$PLATFORM_COMPILE"/g ./Makefile #删除所有的 -m32 -m64选项 sed -i "s/-m64//g" ./Makefile sed -i "s/-m32//g" ./Makefile make clean make -j8 make install } create_patch() { if [ `grep -c "PLATFORM_NAME" ./Makefile` -eq '0' ];then sed -i '5a PLATFORM_NAME='$PLATFORM ./Makefile else sed -i s/^PLATFORM_NAME.*/PLATFORM_NAME=$PLATFORM/g ./Makefile fi #修改Makefile cat > patch.txt << EOF ifeq (\$(PLATFORM_NAME),$PLATFORM) CC=$COMPILE_CC CFLAGS += -I$LIBNL_DIR/$INSTALL_DIR/include LIBS += -L$LIBNL_DIR/$INSTALL_DIR/lib -lnl-3 CFLAGS += -I$OPENSSL_DIR/$INSTALL_DIR/include LIBS += -L$OPENSSL_DIR/$INSTALL_DIR/lib -lcrypto -lssl LDFLAGS += -lpthread -lm -ldl BINDIR := ./$INSTALL_DIR/bin endif EOF if [ `grep -c "$INSTALL_DIR" ./Makefile` -eq '0' ];then sed -i '6 r patch.txt' ./Makefile fi } build_hostapd() { cd $ROOT_DIR if [ ! -f hostapd-2.10.tar.gz ];then wget https://w1.fi/releases/hostapd-2.10.tar.gz if [ ! -f hostapd-2.10.tar.gz ];then exit fi fi if [ ! -d hostapd-2.10 ];then tar -xvf hostapd-2.10.tar.gz fi cd $HOSTAPD_DIR/hostapd mkdir -p $INSTALL_DIR cp defconfig .config export PKG_CONFIG_PATH=$LIBNL_DIR/$INSTALL_DIR/lib/pkgconfig/:$PKG_CONFIG_PATH create_patch make clean make -j8 make install $COMPILE_STRIP -g ./$INSTALL_DIR/bin/* } build_wpa_supplicant() { cd $ROOT_DIR if [ ! -f wpa_supplicant-2.10.tar.gz ];then wget https://w1.fi/releases/wpa_supplicant-2.10.tar.gz if [ ! -f wpa_supplicant-2.10.tar.gz ];then exit fi fi if [ ! -d wpa_supplicant-2.10 ];then tar -xvf wpa_supplicant-2.10.tar.gz fi cd $WPA_DIR/wpa_supplicant mkdir -p $INSTALL_DIR cp defconfig .config #edit .config #CONFIG_MACSEC=y #CONFIG_DRIVER_MACSEC_LINUX=y #CONFIG_CTRL_IFACE_DBUS_NEW=y #CONFIG_CTRL_IFACE_DBUS_INTRO=y sed -i s/^"CONFIG_MACSEC=y".*/"#CONFIG_MACSEC=y"/g .config sed -i s/^"CONFIG_DRIVER_MACSEC_LINUX=y".*/"#CONFIG_DRIVER_MACSEC_LINUX=y"/g .config sed -i s/^"CONFIG_CTRL_IFACE_DBUS_NEW=y".*/"#CONFIG_CTRL_IFACE_DBUS_NEW=y"/g .config sed -i s/^"CONFIG_CTRL_IFACE_DBUS_INTRO=y".*/"#CONFIG_CTRL_IFACE_DBUS_INTRO=y"/g .config export PKG_CONFIG_PATH=$LIBNL_DIR/$INSTALL_DIR/lib/pkgconfig/:$PKG_CONFIG_PATH create_patch make clean make -j8 make install $COMPILE_STRIP -g ./$INSTALL_DIR/bin/* } build_wireless_tools() { cd $ROOT_DIR if [ ! -f wireless_tools.29.tar.gz ];then wget https://hewlettpackard.github.io/wireless-tools/wireless_tools.29.tar.gz if [ ! -f wireless_tools.29.tar.gz ];then exit fi fi if [ ! -d wireless_tools.29.tar.gz ];then tar -xvf wireless_tools.29.tar.gz fi cd $WIRELESS_TOOLS_DIR mkdir -p $INSTALL_DIR sed -i "/PREFIX = /d" ./Makefile sed -i '4a PREFIX = '$WIRELESS_TOOLS_DIR'/'$INSTALL_DIR ./Makefile sed -i s/^"CC = .*"/"CC = ""$COMPILE_CC"/g ./Makefile sed -i s/^"AR = .*"/"AR = ""$COMPILE_AR"/g ./Makefile sed -i s/^"RANLIB = .*"/"RANLIB = ""$COMPILE_RANLIB"/g ./Makefile sed -i s/^"# BUILD_STATIC = y".*/"BUILD_STATIC = y"/g ./Makefile make clean make -j8 make install $COMPILE_STRIP -g ./$INSTALL_DIR/sbin/* } build_all() { build_libnl build_openssl build_wpa_supplicant build_hostapd build_wireless_tools cd $ROOT_DIR mkdir -p $OUT_PUT_DIR/$INSTALL_DIR cp $WPA_DIR/wpa_supplicant/$INSTALL_DIR/bin/* $OUT_PUT_DIR/$INSTALL_DIR -rf cp $HOSTAPD_DIR/hostapd/$INSTALL_DIR/bin/* $OUT_PUT_DIR/$INSTALL_DIR -rf cp $WIRELESS_TOOLS_DIR/$INSTALL_DIR/sbin/* $OUT_PUT_DIR/$INSTALL_DIR -rf } build_all
标签:shell,tar,Makefile,WiFi,一键,COMPILE,PLATFORM,ROOT,DIR From: https://www.cnblogs.com/TiddlerYu/p/18311524