NetBSD/gnu/dist/postfix/makedefs

409 lines
11 KiB
Plaintext
Raw Normal View History

#!/bin/sh
#++
# NAME
# makedefs 1
# SUMMARY
# makefile configuration utility
# SYNOPSIS
2004-04-27 09:07:46 +04:00
# \fBmake makefiles \fIname=value...\fR
# DESCRIPTION
2005-08-19 01:46:19 +04:00
# The \fBmakedefs\fR command identifies the 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.
2005-08-19 01:46:19 +04:00
# The following directives are special:
# .RS
# .IP \fB-DNO_IPV6\fR
# Do not build with IPv6 support.
# By default, IPv6 support is compiled in on platforms that
# are known to have IPv6 support.
# .IP \fB-DNO_PCRE\fR
# Do not build with PCRE support.
# By default, PCRE support is compiled in when the \fBpcre-config\fR
# utility is installed.
# .RE
# .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.
2004-04-27 09:07:46 +04:00
# .IP \fBWARN=\fIwarning_flags\fR
# Specifies non-default gcc compiler warning options for use when
# "make" is invoked in a source subdirectory only.
# 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
2005-08-19 01:46:19 +04:00
# Ugly function to make our error message more visible among the
# garbage that is output by some versions of make(1).
# By now all shells must have functions.
error() {
# Alas, tput(1) is not portable so we can't use visual effects.
echo "ATTENTION:" 1>&2;
echo "ATTENTION:" $* 1>&2;
echo "ATTENTION:" 1>&2;
exit 1
}
SYSTEM=`(uname -s) 2>/dev/null`
RELEASE=`(uname -r) 2>/dev/null`
VERSION=`(uname -v) 2>/dev/null`
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"}
2004-04-27 09:07:46 +04:00
CCARGS="$CCARGS -DPIPES_CANT_FIONREAD $CCARGS"
SYSLIBS="-lsocket -ldbm"
RANLIB=echo
;;
UnixWare.5*) SYSTYPE=UW7
# Use the native compiler by default
: ${CC=/usr/bin/cc}
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"
;;
2005-08-19 01:46:19 +04:00
*) error "Seems to be UnixWare`uname -v`. Untested.";;
esac
;;
FreeBSD.2*) SYSTYPE=FREEBSD2
;;
FreeBSD.3*) SYSTYPE=FREEBSD3
;;
FreeBSD.4*) SYSTYPE=FREEBSD4
;;
2001-03-13 20:45:02 +03:00
FreeBSD.5*) SYSTYPE=FREEBSD5
;;
2006-01-05 05:25:20 +03:00
FreeBSD.6*) SYSTYPE=FREEBSD6
;;
OpenBSD.2*) SYSTYPE=OPENBSD2
;;
2002-02-03 02:54:35 +03:00
OpenBSD.3*) SYSTYPE=OPENBSD3
;;
2004-04-27 09:07:46 +04:00
ekkoBSD.1*) SYSTYPE=EKKOBSD1
;;
NetBSD.1*) SYSTYPE=NETBSD1
;;
2004-04-27 09:07:46 +04:00
NetBSD.2*) SYSTYPE=NETBSD2
;;
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"}
2005-08-19 01:46:19 +04:00
case $RELEASE in
V[0-4].*) CCARGS="$CCARGS -DNO_IPV6";;
esac
;;
SunOS.4*) SYSTYPE=SUNOS4
SYSLIBS=-lresolv
;;
SunOS.5*) SYSTYPE=SUNOS5
RANLIB=echo
SYSLIBS="-lresolv -lsocket -lnsl"
2005-08-19 01:46:19 +04:00
# Solaris 8 added usleep() and POSIX regular expressions
case $RELEASE in
5.[0-4]) CCARGS="$CCARGS -DMISSING_USLEEP -DNO_POSIX_REGEXP";;
esac
# Solaris 8 added IPv6
case $RELEASE in
2005-08-19 01:46:19 +04:00
5.[0-7]|5.[0-7].*) CCARGS="$CCARGS -DNO_IPV6";;
esac
# Solaris 9 added closefrom() and /dev/*random
case $RELEASE in
5.[0-8]|5.[0-8].*) CCARGS="$CCARGS -DNO_CLOSEFROM -DNO_DEV_URANDOM";;
esac
2002-06-09 02:49:50 +04:00
# Work around broken str*casecmp(). Do it all here instead
# of having half the solution in the sys_defs.h file.
CCARGS="$CCARGS -Dstrcasecmp=fix_strcasecmp \
-Dstrncasecmp=fix_strncasecmp"
STRCASE="strcasecmp.o"
# Avoid common types of braindamage
case "$LD_LIBRARY_PATH" in
2005-08-19 01:46:19 +04:00
?*) error "Don't set LD_LIBRARY_PATH";;
esac
2005-08-19 01:46:19 +04:00
case "${CC}" in
*ucb*) error "Don't use /usr/ucb/cc or ucblib";;
cc*) case `which ${CC}` in
*ucb*) error "Don't use /usr/ucb/cc or ucblib";;
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
2005-08-19 01:46:19 +04:00
5) SYSTYPE=AIX5
2002-02-03 02:54:35 +03:00
case "$CC" in
cc|*/cc|xlc|*/xlc) CCARGS="$CCARGS -w -blibpath:/usr/lib:/lib:/usr/local/lib";;
esac
CCARGS="$CCARGS -D_ALL_SOURCE -DHAS_POSIX_REGEXP"
;;
4) SYSTYPE=AIX4
# How embarrassing...
case "$CC" in
2001-03-13 20:45:02 +03:00
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"
;;
2005-08-19 01:46:19 +04:00
*) error "Unknown AIX version: `uname -v`.";;
esac;;
2002-12-24 23:38:22 +03:00
# Tested with RedHat 3.03 on 20020729.
Linux.1*) SYSTYPE=LINUX1
SYSLIBS="-ldb"
;;
Linux.2*) SYSTYPE=LINUX2
2001-03-13 20:45:02 +03:00
# 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
2001-03-13 20:45:02 +03:00
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
2002-06-09 02:49:50 +04:00
# GDBM locks the DBM .pag file after open. This breaks postmap.
# if [ -f /usr/include/gdbm-ndbm.h ]
# then
# CCARGS="$CCARGS -DHAS_DBM -DPATH_NDBM_H='<gdbm-ndbm.h>'"
# GDBM_LIBS=gdbm
# elif [ -f /usr/include/gdbm/ndbm.h ]
# then
# CCARGS="$CCARGS -DHAS_DBM -DPATH_NDBM_H='<gdbm/ndbm.h>'"
# GDBM_LIBS=gdbm
# fi
2001-03-13 20:45:02 +03:00
SYSLIBS="-ldb"
2003-03-08 22:43:56 +03:00
for name in nsl resolv $GDBM_LIBS
2001-03-13 20:45:02 +03:00
do
2003-03-08 22:43:56 +03:00
for lib in /usr/lib64 /lib64 /usr/lib /lib
do
test -e $lib/lib$name.a -o -e $lib/lib$name.so && {
SYSLIBS="$SYSLIBS -l$name"
break
}
done
2001-03-13 20:45:02 +03:00
done
2005-08-19 01:46:19 +04:00
case "$RELEASE" in
2.[0-3].*) CCARGS="$CCARGS -DNO_IPV6";;
esac
;;
IRIX*.5.*) SYSTYPE=IRIX5
# Use the native compiler by default
2004-04-27 09:07:46 +04:00
: ${CC=cc} ${DEBUG="-g3"}
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"
;;
2002-02-03 02:54:35 +03:00
Rhapsody.5*|Darwin.*)
2004-03-27 19:31:19 +03:00
SYSTYPE=MACOSX
2001-03-13 20:45:02 +03:00
# Use the native compiler by default
: ${CC=cc}
2002-02-03 02:54:35 +03:00
case $RELEASE in
2004-03-27 19:31:19 +03:00
1.[0-3]) AWK=gawk
2005-08-19 01:46:19 +04:00
CCARGS="$CCARGS -DNO_IPV6"
2004-03-27 19:31:19 +03:00
;;
[2-6].*) AWK=awk
2005-08-19 01:46:19 +04:00
CCARGS="$CCARGS -DNO_IPV6"
2004-03-27 19:31:19 +03:00
SYSLIBS=-flat_namespace
;;
2002-02-03 02:54:35 +03:00
*) AWK=awk
SYSLIBS=-flat_namespace
2004-03-27 19:31:19 +03:00
CCARGS="$CCARGS -DBIND_8_COMPAT -DNO_NETINFO"
2002-02-03 02:54:35 +03:00
;;
esac
2001-03-13 20:45:02 +03:00
;;
"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
2005-08-19 01:46:19 +04:00
error "Unable to determine your system type."
fi
;;
2005-08-19 01:46:19 +04:00
*) error "Unknown system type: $SYSTEM $RELEASE";;
esac
2005-08-19 01:46:19 +04:00
#
# OpenSSL has no configuration query utility, but we don't try to
# guess. We assume includes in /usr/include/openssl and libraries in
# /usr/lib, or in their /usr/local equivalents. If the OpenSSL files
# are in a non-standard place, their locations need to be specified.
#
#case "$CCARGS" in
# *-DUSE_TLS*) ;;
# *-DNO_TLS*) ;;
# *) CCARGS="$CCARGS -DUSE_TLS"
# AUXLIBS="$AUXLIBS -lssl -lcrypto"
# ;;
#esac
2003-03-08 22:43:56 +03:00
#
# PCRE 3.x has a pcre-config utility so we don't have to guess.
#
case "$CCARGS" in
*-DHAS_PCRE*) ;;
*-DNO_PCRE*) ;;
*) pcre_cflags=`(pcre-config --cflags) 2>/dev/null` &&
pcre_libs=`(pcre-config --libs) 2>/dev/null` && {
CCARGS="$CCARGS -DHAS_PCRE $pcre_cflags"
AUXLIBS="$AUXLIBS $pcre_libs"
}
;;
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;;
2005-08-19 01:46:19 +04:00
*CC) error "Don't use CC. That's the C++ compiler";;
*) : ${OPT='-O'};;
esac
2004-04-27 09:07:46 +04:00
: ${CC='gcc $(WARN)'} ${OPT='-O'} ${DEBUG='-g'} ${AWK=awk} \
${WARN='-W -Wformat -Wimplicit -Wmissing-prototypes \
-Wparentheses -Wstrict-prototypes -Wswitch -Wuninitialized \
-Wunused'}
export SYSTYPE AR ARFL RANLIB SYSLIBS CC OPT DEBUG AWK OPTS
2005-08-19 01:46:19 +04:00
# Snapshot only.
#CCARGS="$CCARGS -DSNAPSHOT"
sed 's/ / /g' <<EOF
SYSTYPE = $SYSTYPE
AR = $AR
ARFL = $ARFL
RANLIB = $RANLIB
SYSLIBS = $AUXLIBS $SYSLIBS
CC = $CC $CCARGS
OPT = $OPT
DEBUG = $DEBUG
AWK = $AWK
2002-06-09 02:49:50 +04:00
STRCASE = $STRCASE
2002-12-24 23:38:22 +03:00
EXPORT = AUXLIBS='$AUXLIBS' CCARGS='$CCARGS' OPT='$OPT' DEBUG='$DEBUG'
2004-04-27 09:07:46 +04:00
WARN = $WARN
EOF