#!/bin/sh
# This creates the .h file with architecture-specific constants.  Output
# goes to stdout, so you need to copy into the appropriate file.
#
# usage: arch_include

if [ "" = "$EGREP" ]; then
  EGREP=egrep
fi

if [ "" = "$CC" ]; then
  CC=gcc
fi

# EGREP=/usr/xpg4/bin/egrep

echo '// This file is automatically generated; see lib/Makefile'
echo '#ifdef _EXTRACT_SIGNALCONSTS'
echo '#include <signal.h>' | ${CC} -E -dD - | $EGREP -e '^#define[[:space:]]+SIG[A-Z0-9]+[[:space:]]+[A-Z0-9]+[[:space:]]*$'
if [ $? != 0 ]; then
  echo Error: arch_include.  Maybe you have the wrong version of egrep.
  echo Use 'export EGREP=<whatever>' to override the default in bash.
  exit 1
fi
echo '#endif'
# This doesn't verify that we got all six lines and all eval to nums
echo '#ifdef _EXTRACT_STDIOCONSTS'
echo '#include <stdio.h>' | ${CC} -E -dD - | $EGREP -e '#define[[:space:]]+(TMP_MAX|FOPEN_MAX|FILENAME_MAX|L_tmpnam|L_cuserid|L_ctermid)'
if [ $? != 0 ]; then
  echo Error: arch_include.  Maybe you have the wrong version of egrep.
  echo Use 'export EGREP=<whatever>' to override the default in bash.
  exit 1
fi
echo '#endif'

