Skip to content

Commit

Permalink
Makefile.am: Link only dovecot statically
Browse files Browse the repository at this point in the history
We only want to link dovecot statically because fully
static builds do not work with modern libc. This breaks
e.g. DNS resolution.
  • Loading branch information
cmouse committed Oct 7, 2024
1 parent 1ff2da6 commit 1390fb0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
12 changes: 10 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,23 @@ 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"
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])

Expand Down
15 changes: 6 additions & 9 deletions src/Makefile.am
Original file line number Diff line number Diff line change
@@ -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 \
Expand Down Expand Up @@ -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 \
Expand Down

0 comments on commit 1390fb0

Please sign in to comment.