Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

configure does not handle alternative prefix well #34

Open
grumpybozo opened this issue May 25, 2021 · 3 comments
Open

configure does not handle alternative prefix well #34

grumpybozo opened this issue May 25, 2021 · 3 comments

Comments

@grumpybozo
Copy link
Contributor

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.

@bigio
Copy link
Contributor

bigio commented Aug 3, 2021

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)

@grumpybozo
Copy link
Contributor Author

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

@bigio
Copy link
Contributor

bigio commented May 16, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants