#! /bin/sh

##  $Id: mksystem,v 1.2 2002/03/31 22:43:58 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_C99_VAMACROS/    { print save $1 " INN_" $2 " " $3 "\n" }
/^#define HAVE_GNU_VAMACROS/    { print save $1 " INN_" $2 " " $3 "\n" }
/^#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
