Skip to content

Instantly share code, notes, and snippets.

@dishuostec
Created February 15, 2017 11:31
Show Gist options
  • Save dishuostec/28cb05ee17ae576e99efecdcad411ce1 to your computer and use it in GitHub Desktop.
Save dishuostec/28cb05ee17ae576e99efecdcad411ce1 to your computer and use it in GitHub Desktop.
cross compile haproxy with static openssl and pcre for mips

cross compile haproxy for asuswrt-merlin use docker image dockcross/linux-mipsel

useage:

  1. put cross_compile.sh in current directory

  2. run

    docker run -it --rm -v=$PWD:/mnt/files dockcross/linux-mipsel /bin/bash /mnt/files/cross_compile.sh
  3. then you will get haproxy in current directory

# currect wrong env
export CROSS_TRIPLE=mipsel-linux-gnu
export AS=/usr/bin/mipsel-linux-gnu-as
export AR=/usr/bin/mipsel-linux-gnu-ar
export CC=/usr/bin/mipsel-linux-gnu-gcc
export CPP=/usr/bin/mipsel-linux-gnu-cpp-4.9
export CXX=/usr/bin/mipsel-linux-gnu-g++
export LD=/usr/bin/mipsel-linux-gnu-ld
# compile openssl
export CROSS_COMPILE_SSL=/var/tmp/ssl
cd /work
curl -fSL https://www.openssl.org/source/openssl-1.0.2k.tar.gz -o openssl.tar.gz
mkdir openssl
tar -xf openssl.tar.gz -C openssl --strip-components=1
cd /work/openssl
mkdir $CROSS_COMPILE_SSL
./Configure --prefix=$CROSS_COMPILE_SSL no-shared linux-mips32
make -j
make install_sw
# compile pcre
export CROSS_COMPILE_PCRE=/var/tmp/pcre
cd /work
curl -fSL https://ftp.pcre.org/pub/pcre/pcre-8.40.tar.gz -o pcre.tar.gz
mkdir pcre
tar -xf pcre.tar.gz -C pcre --strip-components=1
cd /work/pcre
./configure --prefix=$CROSS_COMPILE_PCRE --host=arm-linux --enable-utf8 --enable-unicode-properties
make -j
make install
# compile haporxy
cd /work
curl -fSL https://www.haproxy.org/download/1.7/src/haproxy-1.7.2.tar.gz -o haproxy.tar.gz
mkdir haproxy
tar -xf haproxy.tar.gz -C haproxy --strip-components=1
cd /work/haproxy
make -j CC=$CC ARCH=mips32 CPU=custom TARGET=custom SSL_INC=$CROSS_COMPILE_SSL/include/ SSL_LIB=$CROSS_COMPILE_SSL/lib USE_LIBCRYPT=1 USE_LINUX_SPLICE=1 USE_LINUX_TPROXY=1 USE_OPENSSL=1 USE_PCRE=1 PCREDIR=$CROSS_COMPILE_PCRE USE_STATIC_PCRE=1 ADDLIB=-ldl
# test
qemu-mipsel haproxy -vv
# copy file
cp haproxy /mnt/files/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment