From 91a3cb475d0d06b882beeb74becee689c3a35f4a Mon Sep 17 00:00:00 2001 From: Robert Scheck Date: Sat, 7 Mar 2026 20:39:38 +0100 Subject: [PATCH] Optimize apxs usage Ensure more complex default CFLAGS, e.g. on Fedora and RHEL, are handled gracefully by apxs. While building RPM packages, installation happens to $DESTDIR, this needs to be passed to apxs, too. Co-Authored-By: William Storey --- configure.ac | 8 ++++++++ src/Makefile.am | 7 +++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index e2be890c..0488ffb4 100644 --- a/configure.ac +++ b/configure.ac @@ -4,6 +4,7 @@ AC_ARG_WITH(apxs, AS_HELP_STRING([--with-apxs=NAME],[name of your apxs executabl AC_CONFIG_AUX_DIR([.]) AM_INIT_AUTOMAKE AC_PROG_CC +AC_PROG_MKDIR_P # Copied from http://stackoverflow.com/a/10682813/9832 and tweaked for C (as # opposed to C++) @@ -40,6 +41,13 @@ if test "$APXS" = no; then AC_MSG_ERROR([apxs not found. set apxs with --with-apxs.]) fi AC_SUBST(APXS) + +LIBEXECDIR=`$APXS -q LIBEXECDIR 2>/dev/null` +if test -z "${LIBEXECDIR}"; then + AC_MSG_ERROR([apxs returned empty LIBEXECDIR]) +fi +AC_SUBST(LIBEXECDIR) + AC_CHECK_HEADERS([maxminddb.h]) AC_CHECK_LIB(maxminddb, MMDB_lib_version, [ AC_DEFINE([HAVE_LIBMAXMINDDB], [1], [Have found libmaxminddb]) diff --git a/src/Makefile.am b/src/Makefile.am index 4515d468..6fc91a56 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,15 +1,18 @@ AUTOMAKE_OPTIONS = foreign +LIBEXECDIR = @LIBEXECDIR@ WC=-Wc,"$(CFLAGS)" +WL=-Wl,"$(LDFLAGS) $(LIBMAXMINDDB_LDFLAGS)" # the default target all: module # compile the DSO file module: mod_maxminddb.c $(TARGET) - $(APXS) -c $(LDFLAGS) $(LIBMAXMINDDB_LDFLAGS) $(LIBS) $(WC) $(APXS_LDFLAGS) mod_maxminddb.c + $(APXS) -c $(WL) $(LIBS) $(WC) $(APXS_LDFLAGS) mod_maxminddb.c install-exec-local: module - $(APXS) -i -a -n maxminddb .libs/mod_maxminddb.so + $(MKDIR_P) $(DESTDIR)$(LIBEXECDIR) + $(APXS) -i -S LIBEXECDIR=$(DESTDIR)$(LIBEXECDIR) -a -n maxminddb .libs/mod_maxminddb.so CLEANFILES= *.la *.lo *.o *.so *.slo .libs/*