[OpenAFS-devel] initial afsconfig.h.in patch

Russ Allbery rra@stanford.edu
02 May 2001 19:01:17 -0700


Sam Hartman <hartmans@mit.edu> writes:

> For external APIs, you really want to avoid architecture-specific header
> files at all.  We've had many times where we have regretted that krb5.h
> is generated at compile time in Kerberos.  It's hard; you may even argue
> it's not worth doing in the specific case.

We ran into the same issue with INN, but there were a few things that we
*really* wanted to have in the installed headers that were determined at
configure time (such as the parameters that the user specified to
configure, or the correct means to get a usable "bool" so that we could
use it in function signatures).

The solution I came up with is the following little awk script, which
prepends INN_ to the configure symbols to move them out of the autoconf
namespace.  We then use the INN_ version of the symbols in installed
header files, and the unqualified version in the files internal to INN.

As we need more symbols, we'll just add them to the script.

#! /bin/sh

##  $Id: mksystem,v 1.1 2001/02/24 07:59:06 rra Exp $
##
##  Create include/inn/system.h from include/config.h.
##
##  include/config.h is generated by autoconf and contains all of the test
##  results for a platform.  Most of these are only used when building INN,
##  but some of them are needed for various definitions in the header files
##  for INN's libraries.  We want to be able to install those header files
##  and their prerequisites, but we don't want to define the normal symbols
##  defined by autoconf since they're too likely to conflict with other
##  packages.
##
##  This script takes the path to include/config.h as its only argument and
##  generates a file suitable for being included as <inn/system.h>.  It
##  contains only the autoconf results needed for INN's API, and the symbols
##  that might conflict with autoconf results in other packages have INN_
##  prepended.

cat <<EOF
/* Automatically generated by mksystem from config.h; do not edit. */

/* This header contains information obtained by INN at configure time that
   is needed by INN headers.  Autoconf results that may conflict with the
   autoconf results of another package have INN_ prepended to the
   preprocessor symbols. */

#ifndef INN_SYSTEM_H
#define INN_SYSTEM_H 1

EOF

awk -f - $1 <<'---END-OF-AWK-SCRIPT---'

/^#define HAVE_INTTYPES_H/      { print save $1 " INN_" $2 " " $3 "\n" }
/^#define HAVE_STDBOOL_H/       { print save $1 " INN_" $2 " " $3 "\n" }
/^#define HAVE_SYS_BITTYPES_H/  { print save $1 " INN_" $2 " " $3 "\n" }

{ save = $0 "\n" }

---END-OF-AWK-SCRIPT---

cat <<EOF
#endif /* INN_SYSTEM_H */
EOF

-- 
Russ Allbery (rra@stanford.edu)             <http://www.eyrie.org/~eagle/>