What is the normal way of dealing with non-standard library locations in an autoconf script?
-
09-09-2019 - |
Question
I'm trying to use the GNU autoconf/automake toolchain for the first time, so the answer to my question might be trivial.
The program needs OpenGL/GLUT where the headers and libraries are installed in a non standard location. I found these macros that should do all the checking for me. I'm simply calling it with AX_CHECK_GLUT. How do I make the macro find the libraries? I'm looking for something like
./configure --with-glut-dir=/home/hanno/glut
More generally: What is the normal way of dealing with non-standard library locations in an autoconf script? Of course, I can play around with CPPFLAGS and LIBS variables, but I have the feeling that I'm missing something.
Solution
The way the Autotools are designed, a package author doesn't have to do anything to support prerequisite installed in non-standard locations. The output of ./configure --help
includes the following lines:
LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
nonstandard directory <lib dir>
CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I<include dir> if
you have headers in a nonstandard directory <include dir>
Therefore, if the installer has a prerequisite installed in a non standard location, he will have to issue
./configure CPPFLAGS=-I/non-standard-dir/include LDFLAGS=-L/non-standard-dir/lib
Because CPPFLAGS
and LDFLAGS
are used by configure
checks and Makefile
rules, everything should work.
Some package authors like to offer a --with-
package=location
option as a shorthand for the above, but this normally is not the purpose of --with-
package options. These options are better used to specify whether an optional package should be used, or how a prerequisite should be fulfilled.