diff --git a/configure.ac b/configure.ac index e2be890..0488ffb 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 4515d46..6fc91a5 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/*