Skip to content

Instantly share code, notes, and snippets.

@ihciah
Last active February 8, 2021 07:32
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save ihciah/de493989bd43f76f17ff143daa036e20 to your computer and use it in GitHub Desktop.
Save ihciah/de493989bd43f76f17ff143daa036e20 to your computer and use it in GitHub Desktop.
小米路由器 Pro (R3P) 静态编译 shadowsocks
#!/bin/bash
export SDK=/home/emmmmm/Fun/xiaomi/sdk_package
export WORKDIR=/home/emmmmm/Fun/xiaomi/build
export LIBEV_VER=4.24
export CARES_VER=1.14.0
export PCRE_VER=8.42
export MBEDTLS_VER=2.6.0
export LIBSODIUM_VER=1.0.16
export PATH=$SDK/toolchain/bin:$PATH
export HOST=mipsel-xiaomi-linux-uclibc
export CC=$HOST-gcc
export CXX=$HOST-g++
mkdir -p $WORKDIR
pushd $WORKDIR
# mbedTLS
wget "https://tls.mbed.org/download/mbedtls-$MBEDTLS_VER-gpl.tgz" -O mbedtls-$MBEDTLS_VER-gpl.tgz
tar -zxf mbedtls-$MBEDTLS_VER-gpl.tgz
pushd mbedtls-$MBEDTLS_VER
mkdir $WORKDIR/mbedtls
LDFLAGS=-static make CFLAGS=-fPIC DESTDIR=$WORKDIR/mbedtls install
popd
# libsodium
wget "https://download.libsodium.org/libsodium/releases/libsodium-$LIBSODIUM_VER.tar.gz" -O libsodium-$LIBSODIUM_VER.tar.gz
tar -zxf libsodium-$LIBSODIUM_VER.tar.gz
pushd libsodium-$LIBSODIUM_VER
./configure --prefix=$WORKDIR/libsodium --host=$HOST --disable-ssp --disable-shared
make -j8 && make install
popd
# libev
wget "http://dist.schmorp.de/libev/libev-$LIBEV_VER.tar.gz" -O libev-$LIBEV_VER.tar.gz
tar -zxf libev-$LIBEV_VER.tar.gz
pushd libev-$LIBEV_VER
mkdir $WORKDIR/libev
./configure --prefix=$WORKDIR/libev --host=$HOST --disable-shared
make -j8 && make install
popd
# pcre
wget "https://ftp.pcre.org/pub/pcre/pcre-$PCRE_VER.zip" -O pcre-$PCRE_VER.zip
unzip pcre-$PCRE_VER.zip
pushd pcre-$PCRE_VER
mkdir $WORKDIR/pcre
./configure --prefix=$WORKDIR/pcre --host=$HOST --disable-shared --enable-utf8 --enable-unicode-properties
make -j8 && make install
popd
# c-ares
wget "https://c-ares.haxx.se/download/c-ares-$CARES_VER.tar.gz" -O c-ares-$CARES_VER.tar.gz
tar -zxf c-ares-$CARES_VER.tar.gz
pushd c-ares-$CARES_VER
mkdir $WORKDIR/c-ares
./configure --prefix=$WORKDIR/c-ares --host=$HOST --disable-shared
make -j8 && make install
popd
# shadowsocks-libev
mkdir $WORKDIR/ss
git clone https://github.com/shadowsocks/shadowsocks-libev
pushd shadowsocks-libev
git submodule init && git submodule update
./autogen.sh
LIBS="-lpthread -lm" ./configure --prefix=$WORKDIR/ss --host=$HOST --enable-static --disable-ssp --disable-documentation --with-pcre=$WORKDIR/pcre --with-mbedtls=$WORKDIR/mbedtls --with-sodium=$WORKDIR/libsodium --with-cares=$WORKDIR/c-ares --with-ev=$WORKDIR/libev
make -j8 && make install
popd
popd
echo "Done. Script by ihciah."
echo "Shadowsocks binary built at $WORKDIR/ss/bin"
@ourcubk
Copy link

ourcubk commented May 5, 2019

@t0nyt4ng
Copy link

t0nyt4ng commented Jan 9, 2021

为什么我用你这个脚本编译出来的ss-redir有1.6M,而你上面编译出来的只有625.6K
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment