I think I misread the original question but since nothing in my other answer is incorrect per se I'll add another answer.
In order to use custom paths in AC_CHECK_HEADER
and AC_CHECK_LIBS
one has to (temporarily) set CFLAGS
and LDFLAGS
accordingly:
CFLAGS_backup="${CFLAGS}"
LDFLAGS_backup="${LDFLAGS}"
CFLAGS="-I/path/to/an/additional/include/ ${CFLAGS}"
LDFLAGS="-L/path/to/the/lib/ ${LDFLAGS}"
AC_CHECK_HEADER(...)
AC_CHECK_LIB(...)
## reset CFLAGS and LDFLAGS
CFLAGS="${CFLAGS_backup}"
LDFLAGS="${LDFLAGS_backup}"
Within AC_CHECK_*
you'd typically set GETTEXT_CFLAGS
or LIBINTL_LIBS
as variables and export them for use in automake per AC_SUBST([GETTEXT_CFLAGS])
and AC_SUBST([LIBINTL_LIBS])
respectively.
Unfortunately, you cannot access AM_CFLAGS
or AM_LDFLAGS
in configure.ac.
Now in Makefile.am
you can use
AM_CFLAGS = $(GETTEXT_CFLAGS) <other stuff>
AM_LDFLAGS = $(GETTEXT_LIBS) <other stuff>
For convenience, typically, you'd expose a parameter to the user as well, either via AC_ARG_WITH
or AC_ARG_VAR
, so they can use --with-gettext
or LIBINTL_LIBS=...
along with the configure command.
Seeing as autoconf is really only m4 you could wrap the above in a macro yourself. And seeing as we talk about gettext here, there is already such a thing: AM_GNU_GETTEXT
, an m4 macro that you could use in your configure.ac after you called gettextize
.
./configure CFLAGS=-I/path/to/gettext/include LDFLAGS=-L/path/to/gettext/lib
for nonstandard library locations, and those would be used by theAC_CHECK_HEADERS
andAC_CHECK_LIB
macros if I recall correctly. See this answer for example. – Neron