Please check the GNU Autoconf Macro Archive for Updates
AC-Archive
Autoconf Macro Archive

ac-archive.sf.net: - Project CVS - Download
Macro Index
- AM Support
- C++ Support
- C Support
- Fortran Support
- Java Support
- Cross Compilation
- Installed Packages
- Miscellaneous
- LaTeX Support
- Uncategorized
- archive macros
- adl's macros
- bkorb's macros
- guidod's macros
- latex's macros
- other's macros
- rleigh's macros
- obsoleted macros
- released macros
- search index

Documentation
- Contribute!
- History
- acincludedir m4
- acinclude (tool)
- macro howto
- ax tricks
- maintainers
- License
- Topics

generated...
2007-08-05

(C) 2007 guidod
Download the M4 Source.

ac_auto_include_headers

Back to the Main Page.

Synopsis
AC_AUTO_INCLUDE_HEADERS (HEADER-FILE, INCLUDE-FILE ...)
, 
Version

2002-03-04

Author

Scott Pakin <pakin@uiuc.edu>

License

AllPermissive
Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved. Users of this software should generally follow the principles of the MIT License includings its disclaimer.

Category

cryp.to ac-archive's Installed Packages (released)

Documentation

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.

M4 Source Code
AC_DEFUN([AC_AUTO_INCLUDE_HEADERS],
[touch $1
for ac_auto_include_file in $2; do
  ac_auto_include_have=`echo $ac_auto_include_file | sed 'y%./*abcdefghijklmnopqrstuvwxyz%__PABCDEFGHIJKLMNOPQRSTUVWXYZ%;s%[^_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789]%_%g'`
  echo "#ifdef HAVE_$ac_auto_include_have" &gt;&gt; $1
  echo "# include &lt;$ac_auto_include_file&gt;" &gt;&gt; $1
  echo "#endif" &gt;&gt; $1
  echo "" &gt;&gt; $1
done])