Given a HEADER-FILE and a space-separated list of INCLUDE-FILEs,
AC_AUTO_INCLUDE_HEADERS will append to HEADER-FILE a conditional
#include for each INCLUDE-FILE. For instance, the following macro
call:
AC_AUTO_INCLUDE_HEADERS([config-inc.h], [sys/foobar.h])
will append the following text to config-inc.h:
#ifdef HAVE_SYS_FOOBAR_H
# include <sys/foobar.h>
#endif
AC_AUTO_INCLUDE_HEADERS makes it easy to auto-generate a single header
file that can then be #include'd by multiple files in a project.
Because the #ifdef's are appended to HEADER-FILE, it's also convenient
to include additional text in that file. For instance:
cat <<\CIH_EOF > config-inc.h
/* This file was generated automatically by configure. */
#ifndef _CONFIG_INC_H_
#define _CONFIG_INC_H_
#include <stdio.h>
CIH_EOF
AC_AUTO_INCLUDE_HEADERS([config-inc.h], [arpa/inet.h dlfcn.h errno.h])
echo "#endif" >> config-inc.h
Here's an easy way to get a complete list of header files from config.h:
cat config.h | perl -ane '/ HAVE_\S+_H / && do {$_=$F[$#F-1]; s/^HAVE_//; s/_H/.h/; s|_|/|g; tr/A-Z/a-z/; print "$_ "}'
You can then manually edit the resulting list.