Skip to content

Instantly share code, notes, and snippets.

@PEMessage
Created June 12, 2025 16:49
Show Gist options
  • Save PEMessage/cecfcfff6a5fe12c034be783159c8031 to your computer and use it in GitHub Desktop.
Save PEMessage/cecfcfff6a5fe12c034be783159c8031 to your computer and use it in GitHub Desktop.
build-static-ag.sh
#!/bin/sh
# Credit: https://www.gkbrk.com/static-zstd-binary
docker run -t \
-e UID="$(id -u)" \
-e GID="$(id -g)" \
-v "$PWD":/w \
-w /tmp \
--rm \
-it \
alpine:3.18 \
sh -c "
set -e
apk add musl-dev gcc git make autoconf automake &&
apk add pcre-dev pcre &&
apk add zlib-dev zlib-static xz-dev xz-static &&
mkdir -p /build &&
cd /build &&
git clone -b master https://github.com/satanson/the_silver_searcher . &&
aclocal &&
autoconf &&
autoheader &&
automake --add-missing
export CFLAGS='-fPIC -static -flto -O2'
./configure
make &&
chown "$UID:$GID" ag &&
chmod +x ag &&
mv ag /w/"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment