From 7aed094bc8c7f43ce0d5e20e94dd9e40afadb60a Mon Sep 17 00:00:00 2001 From: Daniel Lange Date: Wed, 29 May 2024 18:09:03 +0200 Subject: [PATCH] Allow static building with `./build.sh --enable-static` Closes #373 --- README.md | 3 +++ configure.ac | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/README.md b/README.md index bd806763..710e5c24 100644 --- a/README.md +++ b/README.md @@ -422,6 +422,9 @@ from `/usr/local/lib`, causing a library load error when running `ugrep`. To correct this, add `export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/lib"` to your `~/.bashrc` file. Or run `sudo ldconfig /usr/local/lib`. +**Note:** you can build static executables by supplying `--enable-static` +as an argument to `./build.sh`. + ### Other platforms: step 3 build Build `ugrep` on Unix-like systems with colors enabled by default: diff --git a/configure.ac b/configure.ac index be41b410..3bdcc32f 100644 --- a/configure.ac +++ b/configure.ac @@ -389,6 +389,24 @@ fi AC_SUBST(ZSH_COMPLETION_DIR) AM_CONDITIONAL([ENABLE_ZSH_COMPLETION],[test "x$with_zsh_completion_dir" != "xno"]) +################################################################################ +# Static or dynamic (default) linking +################################################################################ + +AC_ARG_ENABLE(static, + [AS_HELP_STRING([--enable-static], + [build static ugrep binaries])], + [enable_static=yes], + [enable_static=no]) +AC_MSG_CHECKING(for --enable-static) +if test "x$enable_static" == "xyes"; then + CFLAGS="$CFLAGS -static" + LDFLAGS="$LDFLAGS -static" + AC_MSG_RESULT(yes) +else + AC_MSG_RESULT(no) +fi + ################################################################################ # Installation preferences ################################################################################