Skip to content

Commit

Permalink
Merge pull request universal-ctags#2258 from k-takata/enable-static
Browse files Browse the repository at this point in the history
buildsys: Add --enable-static option to ./configure
  • Loading branch information
k-takata authored Oct 25, 2019
2 parents 9fed4a4 + fb0fd53 commit efce8b1
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
23 changes: 23 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,10 @@ AC_ARG_ENABLE([debugging],
[AS_HELP_STRING([--enable-debugging],
[enable debugging features])])

AC_ARG_ENABLE([static],
[AS_HELP_STRING([--enable-static],
[enable static linking (mainly for MinGW)])])

AC_ARG_PROGRAM

# Process configuration options
Expand Down Expand Up @@ -449,6 +453,10 @@ AC_C_CONST
AC_OBJEXT
AC_EXEEXT

if test "${enable_static}" = "yes"; then
LDFLAGS="$LDFLAGS -static"
fi

# Check for host type
case "$host" in
i?86-*-mingw* | x86_64-*-mingw*)
Expand Down Expand Up @@ -592,6 +600,12 @@ AC_CHECK_FUNCS(scandir,have_scandir=yes)
have_dirent_h=no
AC_CHECK_HEADERS(dirent.h,have_dirent_h=yes)

dnl Dummy check for setting $PKG_CONFIG.
PKG_CHECK_EXISTS([dummy])
if test "${enable_static}" = "yes"; then
PKG_CONFIG="$PKG_CONFIG --static"
fi

AC_ARG_ENABLE([xml],
[AS_HELP_STRING([--disable-xml],
[disable xml support])])
Expand All @@ -609,6 +623,15 @@ AS_IF([test "x$enable_xml" != "xno"], [
])
AM_CONDITIONAL(HAVE_LIBXML, test "x$have_libxml" = xyes)

if test "${enable_static}" = "yes"; then
if test "${have_libxml}" = "yes"; then
if test "${host_mingw}" = "yes"; then
dnl -DLIBXML_STATIC needs to be added manually.
LIBXML_CFLAGS="$LIBXML_CFLAGS -DLIBXML_STATIC"
fi
fi
fi

AC_ARG_ENABLE([json],
[AS_HELP_STRING([--disable-json],
[disable json support])])
Expand Down
2 changes: 1 addition & 1 deletion docs/windows.rst
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ If you want to build a single static-linked binary, you can use the following co
.. code-block:: bash
./autogen.sh
./configure --disable-external-sort EXTRA_CFLAGS=-DLIBXML_STATIC LDFLAGS=-static LIBS='-lz -llzma -lws2_32'
./configure --disable-external-sort --enable-static
make
``--disable-external-sort`` is a recommended option for Windows builds.
Expand Down
2 changes: 1 addition & 1 deletion win32/appveyor.bat
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ bash -lc "for i in {1..3}; do pacman --noconfirm --noprogressbar -S --needed min

bash -lc "./autogen.sh"
:: Use static link.
bash -lc "./configure --enable-iconv --disable-external-sort EXTRA_CFLAGS=-DLIBXML_STATIC LDFLAGS=-static LIBS='-lz -llzma -lws2_32' && make"
bash -lc "./configure --disable-external-sort --enable-static && make"

@echo off
goto :eof
Expand Down

0 comments on commit efce8b1

Please sign in to comment.