From 1390fb0b5ab5d5ab493988d76a891193120fca82 Mon Sep 17 00:00:00 2001 From: Aki Tuomi Date: Mon, 7 Oct 2024 14:51:03 +0300 Subject: [PATCH] Makefile.am: Link only dovecot statically We only want to link dovecot statically because fully static builds do not work with modern libc. This breaks e.g. DNS resolution. --- configure.ac | 12 ++++++++++-- src/Makefile.am | 15 ++++++--------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/configure.ac b/configure.ac index 8ac0015..65ab8c4 100644 --- a/configure.ac +++ b/configure.ac @@ -20,6 +20,16 @@ AC_PROG_CPP LT_INIT DC_DOVECOT + +AS_IF([test "$DOVECOT_INSTALLED" = 'no'], [ + LIBDOVECOT=$abs_dovecotdir/src/lib-dovecot/libdovecot.la + LIBDOVECOT_SSL=$abs_dovecotdir/src/lib-ssl-iostream/libssl_iostream_openssl.la +], [ + LIBDOVECOT=$dovecot_pkglibdir/libdovecot.la + LIBDOVECOT_SSL=$dovecot_pkglibdir/libssl_iostream_openssl.la +]) +AC_SUBST([LIBDOVECOT_SSL]) + CFLAGS="$CFLAGS $EXTRA_CFLAGS" LIBS="$DOVECOT_LIBS" BINARY_CFLAGS="$PIE_CFLAGS" @@ -27,8 +37,6 @@ BINARY_LDFLAGS="$PIE_LDFLAGS $RELRO_LDFLAGS" AC_SUBST(BINARY_CFLAGS) AC_SUBST(BINARY_LDFLAGS) -AM_CONDITIONAL(STATIC_OPENSSL, test "$enable_shared" != "yes") - AS_IF([test "$AR_FLAGS" = "cru"], [AR_FLAGS="cr"], []) AC_SUBST([AR_FLAGS]) diff --git a/src/Makefile.am b/src/Makefile.am index d1d3ff0..0402ce4 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,6 +1,7 @@ bin_PROGRAMS = imaptest -AM_CPPFLAGS = $(LIBDOVECOT_INCLUDE) $(LIBDOVECOT_SMTP_INCLUDE) +AM_CPPFLAGS = $(LIBDOVECOT_INCLUDE) -DSTATIC_OPENSSL=1 +imaptest_LDFLAGS = $(AM_LDFLAGS) imaptest_SOURCES = \ checkpoint.c \ @@ -43,14 +44,10 @@ noinst_HEADERS = \ user.h imaptest_CFLAGS = $(AM_CPPFLAGS) $(BINARY_CFLAGS) -imaptest_LDADD = $(LIBDOVECOT_SMTP) $(LIBDOVECOT) -lm $(BINARY_LDFLAGS) -imaptest_DEPENDENCIES = $(LIBDOVECOT_SMTP_DEPS) $(LIBDOVECOT_DEPS) - -if STATIC_OPENSSL -AM_CPPFLAGS += -DSTATIC_OPENSSL -imaptest_LDADD += $(LIBDOVECOT_OPENSSL) $(DOVECOT_SSL_LIBS) -imaptest_DEPENDENCIES += $(LIBDOVECOT_OPENSSL_DEPS) -endif +imaptest_LDADD = $(LIBDOVECOT) \ + $(LIBDOVECOT_SSL) \ + -lm $(BINARY_LDFLAGS) +imaptest_LDFLAGS += -static-libtool-libs EXTRA_DIST = \ tests/append \