#!/bin/sh - # # @(#)$Id: mkconfig 549 2008-11-09 02:59:30Z jneitzel $ # # Write out an appropriate "config.h" file. # This script is invoked automatically from the Makefile. # Thus, the user does not need to run it manually. # # Exit w/ a status of 0 on success. # Exit w/ a status of 1 on error. # -- # Jeffrey Allen Neitzel # CONFIG_H="config.h" rm -f $CONFIG_H trap 'status=$? ; rm -f $CONFIG_H ; exit $status' HUP INT QUIT TERM # # This function searches for the pathname of utility and defines # constant w/ the resulting value. If utility cannot be found, # constant is defined as the empty string. # # usage: definePathnameConstant constant utility # definePathnameConstant() { constant="$1" utility="$2" dirlist="/bin /sbin /usr/bin /usr/sbin /usr/libexec /usr/games" for dir in $dirlist ; do pathname="" if test -f "$dir/$utility" -a -x "$dir/$utility" ; then pathname="$dir/$utility" ; break fi done echo "#define $constant \"$pathname\"" } UNAME_S="`uname -s`" UNAME_SRM="`uname -srm`" PROGNAME="`basename $0`" if test $# -ne 0 ; then echo 'usage: $(SHELL) ./'"$PROGNAME" >&2 ; exit 1 ; fi if test X"$UNAME_S" = X -o X"$UNAME_SRM" = X ; then echo "$PROGNAME: Fatal uname(1) error" >&2 ; exit 1 fi cat <$CONFIG_H /* * osh - an enhanced port of the Sixth Edition (V6) UNIX Thompson shell */ /* * _XOPEN_SOURCE and/or _BSD_SOURCE should be defined only if needed * to avoid compilation errors or warnings for the osh package on a * given system. The systems where these feature test macros are * (known to be) needed are defined in the mkconfig script. * * This includes only Linux and SunOS (Solaris/OpenSolaris) * at the present time. * * Configured for: $UNAME_SRM */ #ifndef CONFIG_H #define CONFIG_H `definePathnameConstant PATH_LOGIN login` `definePathnameConstant PATH_NEWGRP newgrp` EOI case "$UNAME_S" in *BSD|Darwin|DragonFly) echo "/* $UNAME_S: No need for _XOPEN_SOURCE or _BSD_SOURCE */" \ >>$CONFIG_H ;; Linux) echo '#define _XOPEN_SOURCE 600' >>$CONFIG_H echo '#define _BSD_SOURCE' >>$CONFIG_H ;; SunOS) echo '#define _XOPEN_SOURCE 600' >>$CONFIG_H ;; *) # # This may or may not cause a compilation error. # Simply try it to see if it works or not. # echo "$PROGNAME: WARNING: Check \"$CONFIG_H\" if compilation fails." >&2 cat <>$CONFIG_H /* * WARNING: $UNAME_SRM: Unknown system * * Please report this result to the developer if possible. */ EOI ;; esac echo >>$CONFIG_H echo '#endif /* !CONFIG_H */' >>$CONFIG_H