[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: AC_CHECK_HEADER question
From: |
Zack Weinberg |
Subject: |
Re: AC_CHECK_HEADER question |
Date: |
Sun, 17 Mar 2013 20:05:59 -0400 |
On Sun, Mar 17, 2013 at 5:35 PM, Jan van Dijk <address@hidden> wrote:
>
> That is a bit disappointing, though: it generates a lot of extra work for the
> configure.ac author, only to find out what autoconf already knows: where it
> could find a particular header file. It will also make the scripts less
> robust.
Thing is, Autoconf *doesn't* know where the header is. When you do
AC_CHECK_HEADER([superlu/slu_util.h])
that gets translated to something along the lines of
printf '#include <%s>\n' 'superlu/slu_util.h' > conftest.c
if $CC $CFLAGS $CPPFLAGS -c -o conftest.o conftest.c >>config.log 2>&1
then
action-if-found
else
action-if-not-found
fi
So it's the *C compiler* that searches for the header file, and it
doesn't tell the configure script where it found it.
You could do something like this instead:
superlu_found=no
for sludir in '' 'superlu/' #...
do
AC_CHECK_HEADER([${sludir}slu_util.h],
[AC_DEFINE_UNQUOTED([SLU_SLU_UTIL_H], ["\"${sludir}slu_util.h\""],
[Define to the proper way to include slu_util.h])
AC_DEFINE_UNQUOTED([SLU_SLU_OTHER_H], ["\"${sludir}slu_other.h\""],
[Define to the proper way to include slu_other.h])
# ... all other slu headers that may be required ...
superlu_found=yes
break])
done
if test $superlu_found = no; then
AC_MSG_FAILURE([unable to find superlu headers])
fi
You then write things like
#include SLU_SLU_UTIL_H
in your code. Unfortunately, you need to define one of these macros
for _every_ SLU header you need. You might think it was possible to
write a macro that would let you do
#include SLUHDR(slu_util.h)
but it isn't (because you cannot token-paste a letter with a /).
zw