From b98e70f6a845d3a0e5520ea6e59600b2f70714d4 Mon Sep 17 00:00:00 2001 From: Ulya Trofimovich Date: Sun, 27 Jan 2019 10:06:22 +0000 Subject: [PATCH] Adjusted build system to correctly build DLLs for windows. Adjustments: - configure.ac: pass win32-dll option to LT_INIT - Makefile_libre2c_posix.am: use -no-undefined in LDFLAGS - use slibtool: https://github.com/midipix-project/slibtool for windows builds The problem with libtool is that it doesn't allow to link libstdc++ and libgcc statically, which is necessary to build portable DLLs with Mingw. Libtool adds -nostdlib option to LDFLAGS and links some predefined objects that pull in dependency on dynamic libstdc++ and libgcc, even in the presence of -static-libstdc++ -static-libgcc. --- re2c/Makefile.libre2c_posix.am | 2 +- re2c/__build_mingw.sh | 4 ++-- re2c/configure.ac | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/re2c/Makefile.libre2c_posix.am b/re2c/Makefile.libre2c_posix.am index b02ba351..005c110b 100644 --- a/re2c/Makefile.libre2c_posix.am +++ b/re2c/Makefile.libre2c_posix.am @@ -3,7 +3,7 @@ lib_LTLIBRARIES += libre2c_posix.la libre2c_posix_la_CXXFLAGS = $(AM_CXXFLAGS) -libre2c_posix_la_LDFLAGS = -module +libre2c_posix_la_LDFLAGS = -module -no-undefined libre2c_posix_la_HDR = \ libre2c_posix/lex.h \ diff --git a/re2c/__build_mingw.sh b/re2c/__build_mingw.sh index 3fc951ba..13c3c8ae 100755 --- a/re2c/__build_mingw.sh +++ b/re2c/__build_mingw.sh @@ -5,9 +5,9 @@ rm -rf $builddir mkdir $builddir cd $builddir -../configure \ +../configure LDFLAGS="-static-libstdc++ -static-libgcc" \ --enable-debug \ --enable-libs \ --host i686-w64-mingw32 \ - && make -j5 + && make -j5 LIBTOOL="dlibtool" cd .. diff --git a/re2c/configure.ac b/re2c/configure.ac index 582d952e..8c444ed9 100644 --- a/re2c/configure.ac +++ b/re2c/configure.ac @@ -3,7 +3,7 @@ AM_INIT_AUTOMAKE([foreign subdir-objects dist-xz no-dist-gzip]) AM_SILENT_RULES([yes]) -LT_INIT([dlopen]) +LT_INIT([dlopen win32-dll]) AC_CONFIG_MACRO_DIRS([m4]) -- 2.40.0