Raja's Exocortex

Building stunnel static binary

stunnel is used by Google Secure LDAP service.

#TODO static binary for running in Sophos firewall and using Google Secure LDAP.

Use Alpine as builder

docker run --rm -ti -v `pwd`:/build alpine sh

docker commands run inside alpine container


cd /build
wget https://www.stunnel.org/downloads/stunnel-5.67.tar.gz
tar xf stunnel-5.67.tar.gz
cd stunnel-5.67

apk add build-base linux-headers openssl-dev openssl-libs-static

export CLAGS='-static'
export LDFLAGS='-static'

./configure --enable-static

# Crude hack to enforce static linking
sed -i 's/^stunnel_LDFLAGS = /&-all-static /' src/Makefile.in

export CFLAGS='-Os -fomit-frame-pointer -pipe'

./configure \
  --prefix=/usr/local \
  --sysconfdir=/etc \
  --localstatedir=/var \
  --disable-fips \
  --disable-shared \
  --enable-static \
  --disable-silent-rules

make -j2

strip src/stunnel

# static binary is src/stunnel