I am trying to set up my project to use the autotools build system for distribution. However, I am having a problem when it comes to including a few extra libraries.
My code depends on a few libraries:
One I wrote (I'll call libfoo)
One that is third party (I'll call libbar)
Eigen3 (which is just header files)
These are all already compiled and installed in my $HOME directory. I do not need to build them as part of this project.
The flags I need are
-std=c++11 (Got this taken care of)
and
-I/path/to/include/libfoo (or libbar, or Eigen3)
and
-L/path/to/lib/ (Where libfoo and libbar reside)
and
-lfoo
to compile and link against libfoo and libbar
The problem is that I want to set up checks for the presence of libfoo and libbar and their headers (I have a check for Eigen3 set up already). The issue is that macros like AC_CHECK_HEADERS and AC_CHECK_LIB don't seem to want to include the required CPPFLAGS or LDFLAGS, no matter how I try to define them, so the configuration step fails.
AC_LANG_PUSH([C++])
AC_CHECK_HEADERS([libfoo/foo.h], , [echo "Did not find libfoo headers"; exit -1])
AC_LANG_POP([C++])
Reading config.log shows that configure is trying to compile against the header using
g++ -std=c++11 (other flags...)
but is failing due to the missing flags above (The error is "Cannot find Eigen3/dense", or similar, indicating the missing -I flag)
I'm a newbie to autotools, so I may be missing something obvious, but I've read through a good amount of help and manuals and have so far failed to figure out what I need to do to set this up.
Related: I want the user to be able to manually specify the location of libfoo and libbar via --with-libfoo-include (etc) if needed, so I also need to be able to specify where configure detects these libraries. How can this be done?