I am having a bear of a time getting autoconf to check for the presence of a particular header file.
Let's call the header dependency "inky.h", and let's say that inky is a library that was installed (seperately) with the prefix set to "/usr/local". This put "inky.h" in /usr/local/inky/inky.h and libinky.so in /usr/local/lib.
Now, I'm trying to verify the presence of inky.h in my applications configure.ac as follows:
dnl # Setup temp LDFLAGS and look for inky library/header
LDFLAGS_SAVE=${LDFLAGS};
CPPFLAGS_SAVE=${CPPFLAGS};
dnl # Look for inky on the user specified inky install path
LDFLAGS ="-L${inky_library_path}";
CPPFLAGS="-I${inky_include_path}/inky";
AC_MSG_NOTICE([Looking for inky.h using: ${CPPFLAGS}]);
dnl # This check finds inky.h just fine. This check was only used for debugging
AC_CHECK_FILE(
[${inky_include_path}/inky/inky.h],
[AC_MSG_NOTICE([Found inky.h])],
[AC_MSG_NOTICE([Didn't find inky.h])]
)
dnl # Look for the inky header file. If it isn't found, terminate.
AC_CHECK_HEADER(inky.h,
[],
[AC_MSG_ERROR([Couldn't find or include inky.h])]
)
This produces the following output from ./configure (after an autoreconf -vfi):
configure: Looking for inky.y in fetk include path: -I/usr/local/include/inky.y
checking for /usr/local/include/inky/inky.h... yes
configure: Found inky.h
checking inky.h usability... no
checking inky.h presence... yes
configure: WARNING: inky.h: present but cannot be compiled
configure: WARNING: inky.h: check for missing prerequisite headers?
configure: WARNING: inky.h: see the Autoconf documentation
configure: WARNING: inky.h: section "Present But Cannot Be Compiled"
configure: WARNING: inky.h: proceeding with the compiler's result
checking for inky.h... no
configure: error: Couldn't find or include inky.h
Now, this appears to be the case because inky.h includes 2 other headers, so I add them in on the fourth parameter of AC_CHECK_HEADER like so:
dnl # Look for the inky header file. If it isn't found, terminate.
AC_CHECK_HEADER(inky.h,
[],
[AC_MSG_ERROR([Couldn't find or include inky.h])],
[dinky.h plinky.h]
)
Which renders this output from ./configure:
configure: Looking for inky in fetk include path: -I/usr/local/include/inky
checking for /usr/local/include/inky/inky.h... yes
configure: Found inky.h
checking for inky.h... no
configure: error: Couldn't find or include inky.h
I'm at my wits end with autoconf. Does anyone have any idea where I'm going wrong here. Is it possible to get configure to provide more details about what is failing? Why can I find the file itself, but the AC_CHECK_HEADER macro fails?
Also, please don' tell me to use a different package distribution suite. I would never have chosen Autoconf myself, but I do have to add some dependencies to a pre-existing project.
Also note that the actual library is not named "inky." However, there is an issue of "official use only" for this project, so I have changed the names to protect the...well, to protect myself!
[Edit - Closing] Figured out the problem. See my answer.
LDFLAGS
and="..."
(unless you want to run the programLDFALGS
with="..."
as first argument. – Motivity