NetBSD/gnu/dist/postfix/makedefs

313 lines
7.9 KiB
Bash

#!/bin/sh
#++
# NAME
# makedefs 1
# SUMMARY
# makefile configuration utility
# SYNOPSIS
# \fBmakedefs\fR
# DESCRIPTION
# The \fBmakedefs\fR command identifies the program compilation
# environment, and emits macro definitions on the standard output
# stream that can be prepended to template Makefiles.
#
# Default settings can be overruled by specifying them as
# environment variables. Use quotes if variables contain
# whitespace or shell meta characters.
# .IP \fBAUXLIBS=\fIobject_library...\fR
# Specifies one or more non-default object libraries.
# .IP \fBCC=\fIcompiler_command\fR
# Specifies a non-default compiler. On many systems, the default
# is \fBgcc\fR.
# .IP \fBCCARGS=\fIcompiler_arguments\fR
# Specifies non-default compiler arguments, for example, a non-default
# \fIinclude\fR directory.
# .IP \fBDEBUG=\fIdebug_level\fR
# Specifies a non-default debugging level. The default is \fB-g\fR.
# Specify \fBDEBUG=\fR to turn off debugging.
# .IP \fBOPT=\fIoptimization_level\fR
# Specifies a non-default optimization level. The default is \fB-O\fR.
# Specify \fBOPT=\fR to turn off optimization.
# LICENSE
# .ad
# .fi
# The Secure Mailer license must be distributed with this software.
# AUTHOR(S)
# Wietse Venema
# IBM T.J. Watson Research
# P.O. Box 704
# Yorktown Heights, NY 10598, USA
#--
# Emit system-dependent Makefile macro definitions to standard output.
# Defaults for most sane systems
RANLIB=ranlib
SYSLIBS=
AR=ar
ARFL=rv
SYSTEM=`(uname -s) 2>/dev/null`
RELEASE=`(uname -r) 2>/dev/null`
VERSION=`(uname -v) 2>/dev/null`
if test -f /usr/include/netinet6/in6.h; then
grep __KAME__ /usr/include/netinet6/in6.h 2>&1 >/dev/null
if [ $? = 1 ]; then
INET6=
else
if [ -f /usr/local/v6/lib/libinet6.a ]; then
INET6=kame
else
INET6=kame-merged
fi
fi
fi
if [ -z "$INET6" -a -f /usr/include/netinet/ip6.h -a -f /usr/include/linux/icmpv6.h ]; then
INET6=linux
fi
case "$VERSION" in
dcosx*) SYSTEM=$VERSION;;
esac
case "$SYSTEM.$RELEASE" in
SCO_SV.3.2) SYSTYPE=SCO5
# Use the native compiler by default
: ${CC="/usr/bin/cc -b elf"}
: ${DEBUG=}
SYSLIBS="-lsocket -ldbm"
RANLIB=echo
;;
UnixWare.5*) SYSTYPE=UW7
# Use the native compiler by default
: ${CC=/usr/bin/cc}
: ${DEBUG=}
RANLIB=echo
SYSLIBS="-lresolv -lsocket -lnsl"
;;
UNIX_SV.4.2*) case "`uname -v`" in
2.1*) SYSTYPE=UW21
# Use the native compiler by default
: ${CC=/usr/bin/cc}
RANLIB=echo
SYSLIBS="-lresolv -lsocket -lnsl -lc -L/usr/ucblib -lucb"
;;
*) echo "Seems to be UnixWare`uname -v`. Untested." 1>&2;
exit 1;;
esac
;;
FreeBSD.2*) SYSTYPE=FREEBSD2
;;
FreeBSD.3*) SYSTYPE=FREEBSD3
;;
FreeBSD.4*) SYSTYPE=FREEBSD4
;;
FreeBSD.5*) SYSTYPE=FREEBSD5
;;
OpenBSD.2*) SYSTYPE=OPENBSD2
;;
NetBSD.1*) SYSTYPE=NETBSD1
;;
BSD/OS.2*) SYSTYPE=BSDI2
;;
BSD/OS.3*) SYSTYPE=BSDI3
;;
BSD/OS.4*) SYSTYPE=BSDI4
;;
OSF1.V[3-5].*) SYSTYPE=OSF1
# Use the native compiler by default
: ${CC=cc}
: ${DEBUG="-g3"}
;;
SunOS.4*) SYSTYPE=SUNOS4
SYSLIBS=-lresolv
;;
SunOS.5*) SYSTYPE=SUNOS5
RANLIB=echo
SYSLIBS="-lresolv -lsocket -lnsl"
case $RELEASE in
5.[0-4]) CCARGS="$CCARGS -DMISSING_USLEEP";;
*) CCARGS="$CCARGS -DHAS_POSIX_REGEXP";;
esac
# Avoid common types of braindamage
case "$LD_LIBRARY_PATH" in
?*) echo "Don't set LD_LIBRARY_PATH" 1>&2; exit 1;;
esac
case "$CC" in
*ucb*) echo "Don't use /usr/ucb/cc or ucblib" 1>&2; exit 1;;
cc*) case `which cc` in
*ucb*) echo "Don't use /usr/ucb/cc or ucblib" 1>&2; exit 1;;
esac;;
esac
;;
ULTRIX.4*) SYSTYPE=ULTRIX4
if [ -f /usr/local/lib/libdb.a ]; then
SYSLIBS="$SYSLIBS -ldb"
CCARGS="$CCARGS -DHAS_DB"
if [ -d /usr/local/include/db ]; then
CCARGS="$CCARGS -I/usr/local/include/db"
fi
fi
for l in syslog resolv; do
if [ -f /usr/local/lib/lib$l.a ]; then
SYSLIBS="$SYSLIBS -l$l"
fi
done
;;
AIX.*) case "`uname -v`" in
4) SYSTYPE=AIX4
# How embarrassing...
case "$CC" in
cc|*/cc|xlc|*/xlc) OPT=; CCARGS="$CCARGS -w -blibpath:/usr/lib:/lib:/usr/local/lib";;
esac
CCARGS="$CCARGS -D_ALL_SOURCE -DHAS_POSIX_REGEXP"
;;
3) SYSTYPE=AIX3
# How embarrassing...
case "$CC" in
cc|*/cc|xlc|*/xlc) OPT=; CCARGS="$CCARGS -w";;
esac
CCARGS="$CCARGS -D_ALL_SOURCE"
;;
*) echo "Unknown AIX version: `uname -v`." 1>&2; exit 1;;
esac;;
Linux.2*) SYSTYPE=LINUX2
# Postfix no longer needs DB 1.85 compatibility
if [ -f /usr/include/db.h ]
then
: we are all set
elif [ -f /usr/include/db/db.h ]
then
CCARGS="$CCARGS -I/usr/include/db"
else
# No, we're not going to try db1 db2 db3 etc.
# On a properly installed system, Postfix builds
# by including <db.h> and by linking with -ldb
echo "No <db.h> include file found." 1>&2
echo "Install the appropriate db*-devel package first." 1>&2
echo "See the RELEASE_NOTES file for more information." 1>&2
exit 1
fi
SYSLIBS="-ldb"
for name in nsl resolv
do
test -f /usr/lib/lib$name.a && SYSLIBS="$SYSLIBS -l$name"
done
;;
IRIX*.5.*) SYSTYPE=IRIX5
# Use the native compiler by default
: ${CC=cc}
RANLIB=echo
;;
IRIX*.6.*) SYSTYPE=IRIX6
# Use the native compiler by default, and allow nested comments.
: ${CC="cc -woff 1009,1116,1412"}
RANLIB=echo
;;
HP-UX.A.09.*) SYSTYPE=HPUX9
SYSLIBS=-ldbm
CCARGS="$CCARGS -DMISSING_USLEEP"
if [ -f /usr/lib/libdb.a ]; then
CCARGS="$CCARGS -DHAS_DB"
SYSLIBS="$SYSLIBS -ldb"
fi
;;
HP-UX.B.10.*) SYSTYPE=HPUX10
CCARGS="$CCARGS `nm /usr/lib/libc.a 2>/dev/null |
(grep usleep >/dev/null || echo '-DMISSING_USLEEP')`"
if [ -f /usr/lib/libdb.a ]; then
CCARGS="$CCARGS -DHAS_DB"
SYSLIBS=-ldb
fi
;;
HP-UX.B.11.*) SYSTYPE=HPUX11
SYSLIBS=-lnsl
if [ -f /usr/lib/libdb.a ]; then
CCARGS="$CCARGS -DHAS_DB"
SYSLIBS="$SYSLIBS -ldb"
fi
;;
ReliantUNIX-?.5.43) SYSTYPE=ReliantUnix543
RANLIB=echo
SYSLIBS="-lresolv -lsocket -lnsl"
;;
Rhapsody.5*|Darwin.1.*)
SYSTYPE=RHAPSODY5
# Use the native compiler by default
: ${CC=cc}
AWK=gawk
;;
"Mac OS".10*) SYSTYPE=MACOSX
# Use the native compiler by default
: ${CC=cc}
AWK=gawk
;;
dcosx.1*) SYSTYPE=DCOSX1
RANLIB=echo
SYSLIBS="-lresolv -lsocket -lnsl -lc -lrpcsvc -L/usr/ucblib -lucb"
;;
".") if [ -d /NextApps ]; then
SYSTYPE=`hostinfo | sed -n \
's/^.*NeXT Mach 3.*$/NEXTSTEP3/;/NEXTSTEP3/{p;q;}'`
if [ "$SYSTYPE" = "" ]; then
SYSTYPE=`hostinfo | sed -n \
's/^.*NeXT Mach 4.*$/OPENSTEP4/;/OPENSTEP4/{p;q;}'`
fi
: ${CC=cc}
RANLIB="sleep 5; ranlib"
else
echo "Unable to determine your system type." 1>&2; exit 1
fi
;;
*) echo "Unknown system type: $SYSTEM $RELEASE" 1>&2; exit 1;;
esac
# Defaults that can be overruled (make makefiles CC=cc OPT=-O6 DEBUG=)
# Disable optimizations by default when compiling for Purify. Disable
# optimizations by default with gcc 2.8, until the compiler is known to
# be OK. Those who dare can still overrule this (make makefiles OPT=-O).
case "$CC" in
*purify*) : ${OPT=};;
*/gcc|gcc) case `$CC -v` in
"gcc version 2.8"*) : ${OPT=};;
esac;;
*CC) echo "Don't use CC. That's the C++ compiler" 1>&2; exit 1;;
*) : ${OPT='-O'};;
esac
: ${CC='gcc $(WARN)'} ${OPT='-O'} ${DEBUG='-g'} ${AWK=awk}
case "$INET6" in
kame)
CCARGS="$CCARGS -DINET6 -D__ss_family=ss_family -D__ss_len=ss_len"
if test -f /usr/local/v6/lib/libinet6.a; then
SYSLIBS="$SYSLIBS -L/usr/local/v6/lib -linet6"
fi
;;
kame-merged)
CCARGS="$CCARGS -DINET6 -D__ss_family=ss_family -D__ss_len=ss_len"
;;
linux)
CCARGS="$CCARGS -DINET6"
;;
esac
export SYSTYPE AR ARFL RANLIB SYSLIBS CC OPT DEBUG AWK OPTS
sed 's/ / /g' <<EOF
SYSTYPE = $SYSTYPE
AR = $AR
ARFL = $ARFL
RANLIB = $RANLIB
SYSLIBS = $AUXLIBS $SYSLIBS
CC = $CC $CCARGS
OPT = $OPT
DEBUG = $DEBUG
AWK = $AWK
EXPORT = AUXLIBS="$AUXLIBS" CCARGS="$CCARGS" OPT="$OPT" DEBUG="$DEBUG"
EOF