MIMEDefang icon indicating copy to clipboard operation
MIMEDefang copied to clipboard

configure does not handle alternative prefix well

Open grumpybozo opened this issue 3 years ago • 3 comments

With the command line:

./configure --prefix=/opt/local/ --with-user=defang --with-milterinc=/opt/local/include --with-milterlib=/opt/local/lib/

The configure script works out its libmilter issues like this:

checking for libmilter/mfapi.h... /opt/local/include/libmilter/mfapi.h checking for libmilter.a... no checking for libsm.a... no checking for libmilter.so... /opt/local/lib/libmilter.so checking whether libmilter requires -lsm... yes checking whether libsm requires -lldap... /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/nm: no: No such file or directory. no configure: creating ./config.status

And this in config.log:

configure:6621: checking whether libmilter requires -lsm configure:6635: gcc -o conftest -g -O2 -fPIC -L/opt/local/lib conftest.c -lpthread -lresolv -lmilter >&5 conftest.c:40:10: fatal error: 'libmilter/mfapi.h' file not found #include "libmilter/mfapi.h" ^ 1 error generated. configure:6635: $? = 1

The 'make' then fails at link time because there is no libsm. This can be hacked around by copying libsm.a from a sendmail build, but that's BAD.

Adding "CFLAGS=-I/opt/local/include" to the command line fixes BOTH the incorrect detection of the need for '-lsm' and the error from 'nm':

CFLAGS=-I/opt/local/include ./configure --prefix=/opt/local/ --with-user=defang --with-milterinc=/opt/local/include --with-milterlib=/opt/local/lib [...] checking for libmilter/mfapi.h... /opt/local/include/libmilter/mfapi.h checking for libmilter.a... no checking for libsm.a... no checking for libmilter.so... /opt/local/lib/libmilter.so checking whether libmilter requires -lsm... no checking whether libmilter requires -lldap... no configure: creating ./config.status

I am sure there must be something trivially easy to do involving autoconf to make $PREFIX propagate down into CFLAGS as it does to LDFLAGS, but I have yet to figure that out. Help appreciated.

grumpybozo avatar May 25 '21 16:05 grumpybozo

Untested but it's worth a try:

diff --git a/configure.ac b/configure.ac
index 1030178..eae85f1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -718,7 +718,6 @@ AC_PATH_PROG(MINCLUDE, libmilter/mfapi.h, no, $MILTERINC:$SMMILTER:/usr/include:
 
 dnl Fix up the include stuff
 MINCLUDE=`dirname "$MINCLUDE"`
-MINCLUDE=`dirname "$MINCLUDE"`
 
 dnl If MINCLUDE is "/usr/include", do NOT add to include path, because
 dnl this messes up compilation with gcc on Solaris.
@@ -777,6 +776,7 @@ AC_SUBST(LIBS_WITHOUT_PTHREAD)
 dnl evaluated versions of conf dir
 CONFDIR_EVAL=`echo ${sysconfdir}${CONFSUBDIR}`
 AC_SUBST(CONFDIR_EVAL)
+AC_SUBST(CFLAGS)
 AC_SUBST(LDFLAGS)
 AC_SUBST(PERLPREFIX)
 AC_SUBST(PERLSITEPREFIX)

bigio avatar Aug 03 '21 20:08 bigio

No, that results in MINCLUDE having 'libmilter' as the last element, which it should not.

grumpybozo avatar May 13 '22 20:05 grumpybozo

Is this enough ?

diff --git a/configure.ac b/configure.ac
index 2d7169c..8040094 100644
--- a/configure.ac
+++ b/configure.ac
@@ -755,7 +755,7 @@ dnl this messes up compilation with gcc on Solaris.
 if test "$MINCLUDE" = "/usr/include" ; then
    MINCLUDE=""
 else
-   MINCLUDE="-I${MINCLUDE}"
+   MINCLUDE="${CFLAGS} -I${MINCLUDE}"
 fi
 
 dnl find libmilter.a and libsm.a

bigio avatar May 16 '22 13:05 bigio