Home | History | Annotate | Line # | Download | only in dist
makedefs revision 1.1.1.8
      1      1.1  tron #!/bin/sh
      2      1.1  tron 
      3      1.1  tron #++
      4      1.1  tron # NAME
      5      1.1  tron #	makedefs 1
      6      1.1  tron # SUMMARY
      7      1.1  tron #	makefile configuration utility
      8      1.1  tron # SYNOPSIS
      9      1.1  tron #	\fBmake makefiles \fIname=value...\fR
     10      1.1  tron # DESCRIPTION
     11      1.1  tron #	The \fBmakedefs\fR command identifies the compilation
     12      1.1  tron #	environment, and emits macro definitions on the standard output
     13      1.1  tron #	stream that can be prepended to template Makefiles.
     14      1.1  tron #
     15      1.1  tron #	Default settings can be overruled by specifying them as
     16      1.1  tron #	environment variables. Use quotes if variables contain
     17      1.1  tron #	whitespace or shell meta characters.
     18      1.1  tron # .IP \fBAUXLIBS=\fIobject_library...\fR
     19      1.1  tron #	Specifies one or more non-default object libraries.
     20      1.1  tron # .IP \fBCC=\fIcompiler_command\fR
     21      1.1  tron #	Specifies a non-default compiler. On many systems, the default
     22      1.1  tron #	is \fBgcc\fR.
     23      1.1  tron # .IP \fBCCARGS=\fIcompiler_arguments\fR
     24      1.1  tron #	Specifies non-default compiler arguments, for example, a non-default
     25      1.1  tron #	\fIinclude\fR directory.
     26      1.1  tron #	The following directives are special:
     27      1.1  tron # .RS
     28  1.1.1.8  tron # .IP \fB-DNO_DB\fR
     29  1.1.1.8  tron #	Do not build with Berkeley DB support.
     30      1.1  tron # .IP \fB-DNO_DEVPOLL\fR
     31      1.1  tron #	Do not build with Solaris /dev/poll support.
     32      1.1  tron #	By default, /dev/poll support is compiled in on platforms that
     33      1.1  tron #	are known to support it.
     34      1.1  tron # .IP \fB-DNO_EPOLL\fR
     35      1.1  tron #	Do not build with Linux EPOLL support.
     36      1.1  tron #	By default, EPOLL support is compiled in on platforms that
     37      1.1  tron #	are known to support it.
     38      1.1  tron # .IP \fB-DNO_IPV6\fR
     39      1.1  tron #	Do not build with IPv6 support.
     40      1.1  tron #	By default, IPv6 support is compiled in on platforms that
     41      1.1  tron #	are known to have IPv6 support.
     42      1.1  tron #
     43      1.1  tron #	Note: this directive is for debugging and testing only. It
     44      1.1  tron #	is not guaranteed to work on all platforms.
     45      1.1  tron # .IP \fB-DNO_KQUEUE\fR
     46      1.1  tron #	Do not build with FreeBSD/NetBSD/OpenBSD/MacOSX KQUEUE support.
     47      1.1  tron #	By default, KQUEUE support is compiled in on platforms that
     48      1.1  tron #	are known to support it.
     49  1.1.1.8  tron # .IP \fB-DNO_NIS\fR
     50  1.1.1.8  tron #	Do not build with NIS or NISPLUS support. Support for NIS
     51  1.1.1.8  tron #	is unavailable on some recent Linux and Solaris distributions.
     52      1.1  tron # .IP \fB-DNO_PCRE\fR
     53      1.1  tron #	Do not build with PCRE support.
     54      1.1  tron #	By default, PCRE support is compiled in when the \fBpcre-config\fR
     55      1.1  tron #	utility is installed.
     56  1.1.1.8  tron # .IP \fB-DNO_POSIX_GETPW_R\fR
     57  1.1.1.8  tron #	Disable support for POSIX getpwnam_r/getpwuid_r.
     58      1.1  tron # .IP \fB-DNO_SIGSETJMP\fR
     59      1.1  tron #	Use setjmp()/longjmp() instead of sigsetjmp()/siglongjmp().
     60      1.1  tron #	By default, Postfix uses sigsetjmp()/siglongjmp() when they
     61      1.1  tron #	appear to work.
     62      1.1  tron # .RE
     63      1.1  tron # .IP \fBDEBUG=\fIdebug_level\fR
     64      1.1  tron #	Specifies a non-default debugging level. The default is \fB-g\fR.
     65      1.1  tron #	Specify \fBDEBUG=\fR to turn off debugging.
     66      1.1  tron # .IP \fBOPT=\fIoptimization_level\fR
     67      1.1  tron #	Specifies a non-default optimization level. The default is \fB-O\fR.
     68      1.1  tron #	Specify \fBOPT=\fR to turn off optimization.
     69      1.1  tron # .IP \fBWARN=\fIwarning_flags\fR
     70      1.1  tron #	Specifies non-default gcc compiler warning options for use when
     71      1.1  tron #	"make" is invoked in a source subdirectory only.
     72      1.1  tron # LICENSE
     73      1.1  tron # .ad
     74      1.1  tron # .fi
     75      1.1  tron #	The Secure Mailer license must be distributed with this software.
     76      1.1  tron # AUTHOR(S)
     77      1.1  tron #	Wietse Venema
     78      1.1  tron #	IBM T.J. Watson Research
     79      1.1  tron #	P.O. Box 704
     80      1.1  tron #	Yorktown Heights, NY 10598, USA
     81      1.1  tron #--
     82      1.1  tron 
     83      1.1  tron # Emit system-dependent Makefile macro definitions to standard output.
     84      1.1  tron 
     85      1.1  tron # Defaults for most sane systems
     86      1.1  tron 
     87      1.1  tron RANLIB=ranlib
     88      1.1  tron SYSLIBS=
     89      1.1  tron AR=ar
     90      1.1  tron ARFL=rv
     91      1.1  tron 
     92      1.1  tron # Ugly function to make our error message more visible among the
     93      1.1  tron # garbage that is output by some versions of make(1).
     94      1.1  tron 
     95      1.1  tron # By now all shells must have functions.
     96      1.1  tron 
     97      1.1  tron error() {
     98      1.1  tron    # Alas, tput(1) is not portable so we can't use visual effects.
     99      1.1  tron    echo "ATTENTION:" 1>&2;
    100      1.1  tron    echo "ATTENTION:" $* 1>&2;
    101      1.1  tron    echo "ATTENTION:" 1>&2;
    102      1.1  tron    exit 1
    103      1.1  tron }
    104      1.1  tron 
    105      1.1  tron case $# in
    106      1.1  tron  # Officially supported usage.
    107      1.1  tron  0) SYSTEM=`(uname -s) 2>/dev/null`
    108      1.1  tron     RELEASE=`(uname -r) 2>/dev/null`
    109      1.1  tron     VERSION=`(uname -v) 2>/dev/null`
    110      1.1  tron     case "$VERSION" in
    111      1.1  tron      dcosx*) SYSTEM=$VERSION;;
    112      1.1  tron     esac;;
    113      1.1  tron  # Unsupported debug-only mode. Not suitable for cross-platform tests.
    114      1.1  tron  2) SYSTEM="$1"; RELEASE="$2";;
    115      1.1  tron  *) echo usage: $0 [system release] 1>&2; exit 1;;
    116      1.1  tron esac
    117      1.1  tron 
    118      1.1  tron case "$SYSTEM.$RELEASE" in
    119      1.1  tron    SCO_SV.3.2)	SYSTYPE=SCO5
    120      1.1  tron 		# Use the native compiler by default
    121      1.1  tron 		: ${CC="/usr/bin/cc -b elf"}
    122      1.1  tron 		CCARGS="$CCARGS -DPIPES_CANT_FIONREAD $CCARGS"
    123      1.1  tron 		SYSLIBS="-lsocket -ldbm"
    124      1.1  tron 		RANLIB=echo
    125      1.1  tron 		;;
    126      1.1  tron   UnixWare.5*)	SYSTYPE=UW7
    127      1.1  tron 		# Use the native compiler by default
    128      1.1  tron 		: ${CC=/usr/bin/cc}
    129      1.1  tron 		RANLIB=echo
    130      1.1  tron 		SYSLIBS="-lresolv -lsocket -lnsl"
    131      1.1  tron 		;;
    132      1.1  tron   UNIX_SV.4.2*)	case "`uname -v`" in
    133      1.1  tron 	      2.1*) SYSTYPE=UW21
    134      1.1  tron 		    # Use the native compiler by default
    135      1.1  tron 		    : ${CC=/usr/bin/cc}
    136      1.1  tron 		    RANLIB=echo
    137      1.1  tron 		    SYSLIBS="-lresolv -lsocket -lnsl -lc -L/usr/ucblib -lucb"
    138      1.1  tron 		    ;;
    139      1.1  tron 	      *) error "Seems to be UnixWare`uname -v`. Untested.";;
    140      1.1  tron 		esac
    141      1.1  tron 		;;
    142      1.1  tron   FreeBSD.2*)	SYSTYPE=FREEBSD2
    143      1.1  tron 		;;
    144      1.1  tron   FreeBSD.3*)	SYSTYPE=FREEBSD3
    145      1.1  tron 		;;
    146      1.1  tron   FreeBSD.4*)	SYSTYPE=FREEBSD4
    147      1.1  tron 		;;
    148      1.1  tron   FreeBSD.5*)	SYSTYPE=FREEBSD5
    149      1.1  tron 		;;
    150      1.1  tron   FreeBSD.6*)	SYSTYPE=FREEBSD6
    151      1.1  tron 		;;
    152      1.1  tron   FreeBSD.7*)	SYSTYPE=FREEBSD7
    153      1.1  tron 		;;
    154  1.1.1.2  tron   FreeBSD.8*)	SYSTYPE=FREEBSD8
    155  1.1.1.2  tron 		;;
    156  1.1.1.7  tron   FreeBSD.9*)	SYSTYPE=FREEBSD9
    157  1.1.1.7  tron 		;;
    158      1.1  tron   OpenBSD.2*)	SYSTYPE=OPENBSD2
    159      1.1  tron 		;;
    160      1.1  tron   OpenBSD.3*)	SYSTYPE=OPENBSD3
    161      1.1  tron 		;;
    162      1.1  tron   OpenBSD.4*)	SYSTYPE=OPENBSD4
    163      1.1  tron 		;;
    164  1.1.1.6  tron   OpenBSD.5*)	SYSTYPE=OPENBSD5
    165  1.1.1.6  tron 		;;
    166      1.1  tron   ekkoBSD.1*)	SYSTYPE=EKKOBSD1
    167      1.1  tron 		;;
    168      1.1  tron    NetBSD.1*)	SYSTYPE=NETBSD1
    169      1.1  tron 		;;
    170      1.1  tron    NetBSD.2*)	SYSTYPE=NETBSD2
    171      1.1  tron 		;;
    172      1.1  tron    NetBSD.3*)	SYSTYPE=NETBSD3
    173      1.1  tron 		;;
    174      1.1  tron    NetBSD.4*)	SYSTYPE=NETBSD4
    175      1.1  tron 		;;
    176      1.1  tron    BSD/OS.2*)	SYSTYPE=BSDI2
    177      1.1  tron 		;;
    178      1.1  tron    BSD/OS.3*)	SYSTYPE=BSDI3
    179      1.1  tron 		;;
    180      1.1  tron    BSD/OS.4*)	SYSTYPE=BSDI4
    181      1.1  tron 		;;
    182      1.1  tron  OSF1.V[3-5].*)	SYSTYPE=OSF1
    183      1.1  tron 		# Use the native compiler by default
    184      1.1  tron 		: ${CC=cc}
    185      1.1  tron 		: ${DEBUG="-g3"}
    186      1.1  tron 		case $RELEASE in
    187      1.1  tron 		V[0-4].*) CCARGS="$CCARGS -DNO_IPV6";;
    188      1.1  tron 		esac
    189      1.1  tron 		;;
    190      1.1  tron     SunOS.4*)	SYSTYPE=SUNOS4
    191      1.1  tron 		SYSLIBS=-lresolv
    192      1.1  tron 		;;
    193      1.1  tron     SunOS.5*)	SYSTYPE=SUNOS5
    194      1.1  tron 		RANLIB=echo
    195      1.1  tron 		SYSLIBS="-lresolv -lsocket -lnsl"
    196      1.1  tron 		# Stock awk breaks with >10 files.
    197      1.1  tron 		test -x /usr/xpg4/bin/awk && AWK=/usr/xpg4/bin/awk
    198  1.1.1.8  tron 		# Solaris 2.5 added usleep(), POSIX regexp, POSIX getpwnam/uid_r
    199      1.1  tron 		case $RELEASE in
    200  1.1.1.8  tron 		    5.[0-4]) CCARGS="$CCARGS -DMISSING_USLEEP -DNO_POSIX_REGEXP -DNO_POSIX_GETPW_R";;
    201      1.1  tron 		esac
    202      1.1  tron 		# Solaris 8 added IPv6 and /dev/poll
    203      1.1  tron 		case $RELEASE in
    204      1.1  tron 		    5.[0-7]|5.[0-7].*) CCARGS="$CCARGS -DNO_IPV6 -DNO_DEVPOLL";;
    205      1.1  tron 		esac
    206      1.1  tron 		# Solaris 9 added closefrom(), futimesat() and /dev/*random
    207      1.1  tron 		case $RELEASE in
    208      1.1  tron 		    5.[0-8]|5.[0-8].*) CCARGS="$CCARGS -DNO_CLOSEFROM -DNO_DEV_URANDOM -DNO_FUTIMESAT";;
    209      1.1  tron 		esac
    210      1.1  tron 		# Work around broken str*casecmp(). Do it all here instead
    211      1.1  tron 		# of having half the solution in the sys_defs.h file.
    212      1.1  tron 		CCARGS="$CCARGS -Dstrcasecmp=fix_strcasecmp \
    213      1.1  tron 		    -Dstrncasecmp=fix_strncasecmp"
    214      1.1  tron 		STRCASE="strcasecmp.o"
    215      1.1  tron 		# Avoid common types of braindamage
    216      1.1  tron 		case "$LD_LIBRARY_PATH" in
    217      1.1  tron 		?*) error "Don't set LD_LIBRARY_PATH";;
    218      1.1  tron 		esac
    219      1.1  tron 		case "${CC}" in
    220      1.1  tron 		*" "*) ;;
    221      1.1  tron 		*ucb*) error "Don't use /usr/ucb/cc or ucblib";;
    222      1.1  tron 		  cc*) case `which ${CC}` in
    223      1.1  tron 		*ucb*) error "Don't use /usr/ucb/cc or ucblib";;
    224      1.1  tron 		  esac;;
    225      1.1  tron 		esac
    226      1.1  tron 		;;
    227      1.1  tron    ULTRIX.4*)	SYSTYPE=ULTRIX4
    228      1.1  tron 		if [ -f /usr/local/lib/libdb.a ]; then
    229      1.1  tron 		    SYSLIBS="$SYSLIBS -ldb"
    230      1.1  tron 		    CCARGS="$CCARGS -DHAS_DB"
    231      1.1  tron 		    if [ -d /usr/local/include/db ]; then
    232      1.1  tron 			CCARGS="$CCARGS -I/usr/local/include/db"
    233      1.1  tron 		    fi
    234      1.1  tron 		fi
    235      1.1  tron 		for l in syslog resolv; do
    236      1.1  tron 		    if [ -f /usr/local/lib/lib$l.a ]; then
    237      1.1  tron 			SYSLIBS="$SYSLIBS -l$l"
    238      1.1  tron 		    fi
    239      1.1  tron 		done
    240      1.1  tron 		;;
    241      1.1  tron        AIX.*)	case "`uname -v`" in
    242  1.1.1.4  tron 		6)	SYSTYPE=AIX6
    243  1.1.1.4  tron 			case "$CC" in
    244  1.1.1.4  tron 			cc|*/cc|xlc|*/xlc) CCARGS="$CCARGS -w -blibpath:/usr/lib:/lib:/usr/local/lib";;
    245  1.1.1.4  tron 			esac
    246  1.1.1.4  tron 			CCARGS="$CCARGS -D_ALL_SOURCE -DHAS_POSIX_REGEXP"
    247  1.1.1.4  tron 			;;
    248      1.1  tron 		5)	SYSTYPE=AIX5
    249      1.1  tron 			case "$CC" in
    250      1.1  tron 			cc|*/cc|xlc|*/xlc) CCARGS="$CCARGS -w -blibpath:/usr/lib:/lib:/usr/local/lib";;
    251      1.1  tron 			esac
    252      1.1  tron 			CCARGS="$CCARGS -D_ALL_SOURCE -DHAS_POSIX_REGEXP"
    253      1.1  tron 			;;
    254      1.1  tron 		4)	SYSTYPE=AIX4
    255      1.1  tron 			# How embarrassing...
    256      1.1  tron 			case "$CC" in
    257      1.1  tron 			cc|*/cc|xlc|*/xlc) OPT=; CCARGS="$CCARGS -w -blibpath:/usr/lib:/lib:/usr/local/lib";;
    258      1.1  tron 			esac
    259      1.1  tron 			CCARGS="$CCARGS -D_ALL_SOURCE -DHAS_POSIX_REGEXP"
    260      1.1  tron 			;;
    261      1.1  tron 		3)	SYSTYPE=AIX3
    262      1.1  tron 			# How embarrassing...
    263      1.1  tron 			case "$CC" in
    264      1.1  tron 			cc|*/cc|xlc|*/xlc) OPT=; CCARGS="$CCARGS -w";;
    265      1.1  tron 			esac
    266      1.1  tron 			CCARGS="$CCARGS -D_ALL_SOURCE"
    267      1.1  tron 			;;
    268      1.1  tron 		*)	error "Unknown AIX version: `uname -v`.";;
    269      1.1  tron 		esac;;
    270      1.1  tron 		# Tested with RedHat 3.03 on 20020729.
    271      1.1  tron     Linux.1*)	SYSTYPE=LINUX1
    272      1.1  tron 		SYSLIBS="-ldb"
    273      1.1  tron 		;;
    274      1.1  tron     Linux.2*)	SYSTYPE=LINUX2
    275      1.1  tron 		# Postfix no longer needs DB 1.85 compatibility
    276      1.1  tron 		if [ -f /usr/include/db.h ]
    277      1.1  tron 		then
    278      1.1  tron 		    : we are all set
    279      1.1  tron 		elif [ -f /usr/include/db/db.h ]
    280      1.1  tron 		then
    281      1.1  tron 		    CCARGS="$CCARGS -I/usr/include/db"
    282      1.1  tron 		else
    283      1.1  tron 		    # No, we're not going to try db1 db2 db3 etc.
    284      1.1  tron 		    # On a properly installed system, Postfix builds
    285      1.1  tron 		    # by including <db.h> and by linking with -ldb
    286      1.1  tron 		    echo "No <db.h> include file found." 1>&2
    287      1.1  tron 		    echo "Install the appropriate db*-devel package first." 1>&2
    288      1.1  tron 		    echo "See the RELEASE_NOTES file for more information." 1>&2
    289      1.1  tron 		    exit 1
    290      1.1  tron 		fi
    291      1.1  tron 		# GDBM locks the DBM .pag file after open. This breaks postmap.
    292      1.1  tron 		# if [ -f /usr/include/gdbm-ndbm.h ]
    293      1.1  tron 		# then
    294      1.1  tron 		#     CCARGS="$CCARGS -DHAS_DBM -DPATH_NDBM_H='<gdbm-ndbm.h>'"
    295      1.1  tron 		#     GDBM_LIBS=gdbm
    296      1.1  tron 		# elif [ -f /usr/include/gdbm/ndbm.h ]
    297      1.1  tron 		# then
    298      1.1  tron 		#     CCARGS="$CCARGS -DHAS_DBM -DPATH_NDBM_H='<gdbm/ndbm.h>'"
    299      1.1  tron 		#     GDBM_LIBS=gdbm
    300      1.1  tron 		# fi
    301      1.1  tron 		SYSLIBS="-ldb"
    302      1.1  tron 		for name in nsl resolv $GDBM_LIBS
    303      1.1  tron 		do
    304      1.1  tron 		    for lib in /usr/lib64 /lib64 /usr/lib /lib
    305      1.1  tron 		    do
    306      1.1  tron 			test -e $lib/lib$name.a -o -e $lib/lib$name.so && {
    307      1.1  tron 			    SYSLIBS="$SYSLIBS -l$name"
    308      1.1  tron 			    break
    309      1.1  tron 			}
    310      1.1  tron 		    done
    311      1.1  tron 		done
    312      1.1  tron 		# Kernel 2.4 added IPv6
    313      1.1  tron 		case "$RELEASE" in
    314      1.1  tron 		2.[0-3].*) CCARGS="$CCARGS -DNO_IPV6";;
    315      1.1  tron 		esac
    316      1.1  tron 		# Kernel 2.6 added EPOLL
    317      1.1  tron 		case "$RELEASE" in
    318      1.1  tron 		2.[0-5].*) CCARGS="$CCARGS -DNO_EPOLL";;
    319      1.1  tron 		    # Workaround for retarded libc 
    320  1.1.1.3  tron 		    2.6.*)
    321  1.1.1.3  tron 		       if [ `expr "X$CCARGS" : "X.*-DNO_EPOLL"` -gt 0 ]
    322  1.1.1.3  tron                        then
    323  1.1.1.3  tron                            :
    324  1.1.1.3  tron                        elif [ ! -e /usr/include/sys/epoll.h ]
    325  1.1.1.3  tron                        then
    326  1.1.1.3  tron                            echo CCARGS="$CCARGS -DNO_EPOLL"
    327  1.1.1.3  tron                        else
    328  1.1.1.3  tron 			   trap 'rm -f makedefs.test makedefs.test.[co]' 1 2 3 15
    329      1.1  tron 			   cat >makedefs.test.c <<'EOF'
    330      1.1  tron #include <sys/types.h>
    331      1.1  tron #include <sys/epoll.h>
    332      1.1  tron #include <errno.h>
    333      1.1  tron #include <stdio.h>
    334      1.1  tron #include <stdlib.h>
    335      1.1  tron 
    336      1.1  tron int     main(int argc, char **argv)
    337      1.1  tron {
    338      1.1  tron     int     epoll_handle;
    339      1.1  tron 
    340      1.1  tron     if ((epoll_handle = epoll_create(1)) < 0) {
    341      1.1  tron 	perror("epoll_create");
    342      1.1  tron 	exit(1);
    343      1.1  tron     }
    344      1.1  tron     exit(0);
    345      1.1  tron }
    346      1.1  tron EOF
    347      1.1  tron 			   ${CC-gcc} -o makedefs.test makedefs.test.c || exit 1
    348      1.1  tron 			   ./makedefs.test 2>/dev/null ||
    349      1.1  tron 				CCARGS="$CCARGS -DNO_EPOLL"
    350  1.1.1.3  tron 			   rm -f makedefs.test makedefs.test.[co]
    351  1.1.1.3  tron 		       fi;;
    352      1.1  tron 		esac
    353      1.1  tron 		;;
    354  1.1.1.5  tron     Linux.3*)	SYSTYPE=LINUX3
    355  1.1.1.5  tron 		if [ -f /usr/include/db.h ]
    356  1.1.1.5  tron 		then
    357  1.1.1.5  tron 		    : we are all set
    358  1.1.1.5  tron 		elif [ -f /usr/include/db/db.h ]
    359  1.1.1.5  tron 		then
    360  1.1.1.5  tron 		    CCARGS="$CCARGS -I/usr/include/db"
    361  1.1.1.5  tron 		else
    362  1.1.1.5  tron 		    # On a properly installed system, Postfix builds
    363  1.1.1.5  tron 		    # by including <db.h> and by linking with -ldb
    364  1.1.1.5  tron 		    echo "No <db.h> include file found." 1>&2
    365  1.1.1.5  tron 		    echo "Install the appropriate db*-devel package first." 1>&2
    366  1.1.1.5  tron 		    echo "See the RELEASE_NOTES file for more information." 1>&2
    367  1.1.1.5  tron 		    exit 1
    368  1.1.1.5  tron 		fi
    369  1.1.1.5  tron 		SYSLIBS="-ldb"
    370  1.1.1.5  tron 		for name in nsl resolv
    371  1.1.1.5  tron 		do
    372  1.1.1.5  tron 		    for lib in /usr/lib64 /lib64 /usr/lib /lib
    373  1.1.1.5  tron 		    do
    374  1.1.1.5  tron 			test -e $lib/lib$name.a -o -e $lib/lib$name.so && {
    375  1.1.1.5  tron 			    SYSLIBS="$SYSLIBS -l$name"
    376  1.1.1.5  tron 			    break
    377  1.1.1.5  tron 			}
    378  1.1.1.5  tron 		    done
    379  1.1.1.5  tron 		done
    380  1.1.1.5  tron 		;;
    381      1.1  tron      GNU.0*|GNU/kFreeBSD.[567]*)
    382      1.1  tron      		SYSTYPE=GNU0
    383      1.1  tron 		# Postfix no longer needs DB 1.85 compatibility
    384      1.1  tron 		if [ -f /usr/include/db.h ]
    385      1.1  tron 		then
    386      1.1  tron 		    : we are all set
    387      1.1  tron 		elif [ -f /usr/include/db/db.h ]
    388      1.1  tron 		then
    389      1.1  tron 		    CCARGS="$CCARGS -I/usr/include/db"
    390      1.1  tron 		else
    391      1.1  tron 		    # No, we're not going to try db1 db2 db3 etc.
    392      1.1  tron 		    # On a properly installed system, Postfix builds
    393      1.1  tron 		    # by including <db.h> and by linking with -ldb
    394      1.1  tron 		    echo "No <db.h> include file found." 1>&2
    395      1.1  tron 		    echo "Install the appropriate db*-devel package first." 1>&2
    396      1.1  tron 		    echo "See the RELEASE_NOTES file for more information." 1>&2
    397      1.1  tron 		    exit 1
    398      1.1  tron 		fi
    399      1.1  tron 		SYSLIBS="-ldb"
    400      1.1  tron 		for name in nsl resolv
    401      1.1  tron 		do
    402      1.1  tron 		    for lib in /usr/lib64 /lib64 /usr/lib /lib
    403      1.1  tron 		    do
    404      1.1  tron 			test -e $lib/lib$name.a -o -e $lib/lib$name.so && {
    405      1.1  tron 			    SYSLIBS="$SYSLIBS -l$name"
    406      1.1  tron 			    break
    407      1.1  tron 			}
    408      1.1  tron 		    done
    409      1.1  tron 		done
    410      1.1  tron 		case "`uname -s`" in
    411      1.1  tron 		GNU)
    412      1.1  tron 			# currently no IPv6 support on Hurd
    413      1.1  tron 			CCARGS="$CCARGS -DNO_IPV6"
    414      1.1  tron 			;;
    415      1.1  tron 		esac
    416      1.1  tron 		;;
    417      1.1  tron      IRIX*.5.*)	SYSTYPE=IRIX5
    418      1.1  tron 		# Use the native compiler by default
    419      1.1  tron 		: ${CC=cc} ${DEBUG="-g3"}
    420      1.1  tron 		RANLIB=echo
    421      1.1  tron 		;;
    422      1.1  tron      IRIX*.6.*)	SYSTYPE=IRIX6
    423      1.1  tron 		# Use the native compiler by default, and allow nested comments.
    424      1.1  tron 		: ${CC="cc -woff 1009,1116,1412"}
    425      1.1  tron 		RANLIB=echo
    426      1.1  tron 		;;
    427      1.1  tron HP-UX.A.09.*)	SYSTYPE=HPUX9
    428      1.1  tron 		SYSLIBS=-ldbm
    429      1.1  tron 		CCARGS="$CCARGS -DMISSING_USLEEP"
    430      1.1  tron 		if [ -f /usr/lib/libdb.a ]; then
    431      1.1  tron 		    CCARGS="$CCARGS -DHAS_DB"
    432      1.1  tron 		    SYSLIBS="$SYSLIBS -ldb"
    433      1.1  tron 		fi
    434      1.1  tron 		;;
    435      1.1  tron HP-UX.B.10.*)	SYSTYPE=HPUX10
    436      1.1  tron 		CCARGS="$CCARGS `nm /usr/lib/libc.a 2>/dev/null |
    437      1.1  tron 		    (grep usleep >/dev/null || echo '-DMISSING_USLEEP')`"
    438      1.1  tron 		if [ -f /usr/lib/libdb.a ]; then
    439      1.1  tron 		    CCARGS="$CCARGS -DHAS_DB"
    440      1.1  tron 		    SYSLIBS=-ldb
    441      1.1  tron 		fi
    442      1.1  tron 		;;
    443      1.1  tron HP-UX.B.11.*)	SYSTYPE=HPUX11
    444      1.1  tron 		SYSLIBS=-lnsl
    445      1.1  tron 		if [ -f /usr/lib/libdb.a ]; then
    446      1.1  tron 		    CCARGS="$CCARGS -DHAS_DB"
    447      1.1  tron 		    SYSLIBS="$SYSLIBS -ldb"
    448      1.1  tron 		fi
    449      1.1  tron 		;;
    450      1.1  tron ReliantUNIX-?.5.43) SYSTYPE=ReliantUnix543
    451      1.1  tron 		RANLIB=echo
    452      1.1  tron 		SYSLIBS="-lresolv -lsocket -lnsl"
    453      1.1  tron 		;;
    454      1.1  tron     Darwin.*)   SYSTYPE=MACOSX
    455      1.1  tron 		# Use the native compiler by default
    456      1.1  tron 		: ${CC=cc}
    457      1.1  tron 		# Darwin > 1.3 uses awk and flat_namespace
    458      1.1  tron 		case $RELEASE in
    459      1.1  tron 		 1.[0-3]) AWK=gawk;;
    460      1.1  tron 		       *) AWK=awk
    461      1.1  tron 			  SYSLIBS=-flat_namespace;;
    462      1.1  tron 		esac
    463      1.1  tron 		# Darwin 7 adds IPv6 support, BIND_8_COMPAT, NO_NETINFO
    464      1.1  tron 		case $RELEASE in
    465      1.1  tron 		 [1-6].*) CCARGS="$CCARGS -DNO_IPV6";;
    466      1.1  tron 		       *) CCARGS="$CCARGS -DBIND_8_COMPAT -DNO_NETINFO";;
    467      1.1  tron 		esac
    468  1.1.1.8  tron 		# Darwin 9.0 (MacOS X 10.5) adds POSIX getpwnam_r/getpwuid_r
    469  1.1.1.8  tron 		case $RELEASE in
    470  1.1.1.8  tron 		 [1-8].*) CCARGS="$CCARGS -DNO_POSIX_GETPW_R";;
    471  1.1.1.8  tron 		esac
    472  1.1.1.3  tron 		# Darwin 10.3.0 no longer has <nameser8_compat.h>.
    473  1.1.1.3  tron 		case $RELEASE in
    474  1.1.1.3  tron 		     ?.*) CCARGS="$CCARGS -DRESOLVE_H_NEEDS_NAMESER8_COMPAT_H";;
    475  1.1.1.3  tron 		       *) CCARGS="$CCARGS -DRESOLVE_H_NEEDS_ARPA_NAMESER_COMPAT_H";;
    476  1.1.1.3  tron 		esac
    477      1.1  tron 		# kqueue and/or poll are broken up to and including MacOS X 10.5
    478      1.1  tron 		CCARGS="$CCARGS -DNO_KQUEUE"
    479      1.1  tron #		# Darwin 8.11.1 has kqueue support, but let's play safe
    480      1.1  tron #		case $RELEASE in
    481      1.1  tron #		 [1-8].*) CCARGS="$CCARGS -DNO_KQUEUE";;
    482      1.1  tron #		       *) trap 'rm -f makedefs.test makedefs.test.[co]' 1 2 3 15
    483      1.1  tron #			  cat >makedefs.test.c <<'EOF'
    484      1.1  tron #/* Adapted from libevent. */
    485      1.1  tron #
    486      1.1  tron ##include <sys/types.h>
    487      1.1  tron ##include <sys/event.h>
    488      1.1  tron ##include <sys/time.h>
    489      1.1  tron ##include <string.h>
    490      1.1  tron ##include <stdlib.h>
    491      1.1  tron ##include <stdio.h>
    492      1.1  tron #
    493      1.1  tron ##ifndef EV_SET
    494      1.1  tron ##define EV_SET(kp, id, fi, fl, ffl, da, ud) do { \
    495      1.1  tron #	struct kevent *__kp = (kp); \
    496      1.1  tron #	__kp->ident = (id); \
    497      1.1  tron #	__kp->filter = (fi); \
    498      1.1  tron #	__kp->flags = (fl); \
    499      1.1  tron #	__kp->fflags = (ffl); \
    500      1.1  tron #	__kp->data = (da); \
    501      1.1  tron #	__kp->udata = (ud); \
    502      1.1  tron #    } while(0)
    503      1.1  tron ##endif
    504      1.1  tron #
    505      1.1  tron #int     main(int argc, char **argv)
    506      1.1  tron #{
    507      1.1  tron #    int     kq;
    508      1.1  tron #    struct kevent test_change;
    509      1.1  tron #    struct kevent test_result;
    510      1.1  tron #
    511      1.1  tron #    if ((kq = kqueue()) < 0) {
    512      1.1  tron #	perror("kqueue");
    513      1.1  tron #	exit(1);
    514      1.1  tron #    }
    515      1.1  tron ##define TEST_FD (-1)
    516      1.1  tron #
    517      1.1  tron #    EV_SET(&test_change, TEST_FD, EVFILT_READ, EV_ADD, 0, 0, 0);
    518      1.1  tron #    if (kevent(kq,
    519      1.1  tron #	       &test_change, sizeof(test_change) / sizeof(struct kevent),
    520      1.1  tron #	       &test_result, sizeof(test_result) / sizeof(struct kevent),
    521      1.1  tron #	       (struct timespec *) 0) != 1 ||
    522      1.1  tron #	test_result.ident != TEST_FD ||
    523      1.1  tron #	test_result.flags != EV_ERROR) {
    524      1.1  tron #	fprintf(stderr, "Error: kevent reports errors incorrectly\n");
    525      1.1  tron #	exit(1);
    526      1.1  tron #    }
    527      1.1  tron #    exit(0);
    528      1.1  tron #}
    529      1.1  tron #EOF
    530      1.1  tron #			  $CC -o makedefs.test makedefs.test.c || exit 1
    531      1.1  tron #			  ./makedefs.test 2>/dev/null || 
    532      1.1  tron #				CCARGS="$CCARGS -DNO_KQUEUE"
    533      1.1  tron #			  rm -f makedefs.test makedefs.test.[co];;
    534      1.1  tron #		esac
    535      1.1  tron 		;;
    536      1.1  tron     dcosx.1*)	SYSTYPE=DCOSX1
    537      1.1  tron 		RANLIB=echo
    538      1.1  tron 		SYSLIBS="-lresolv -lsocket -lnsl -lc -lrpcsvc -L/usr/ucblib -lucb"
    539      1.1  tron 		;;
    540      1.1  tron 
    541      1.1  tron 	 ".")	if [ -d /NextApps ]; then
    542      1.1  tron 		    SYSTYPE=`hostinfo | sed -n \
    543      1.1  tron 			's/^.*NeXT Mach 3.*$/NEXTSTEP3/;/NEXTSTEP3/{p;q;}'`
    544      1.1  tron 		    if [ "$SYSTYPE" = "" ]; then
    545      1.1  tron 			SYSTYPE=`hostinfo | sed -n \
    546      1.1  tron 			    's/^.*NeXT Mach 4.*$/OPENSTEP4/;/OPENSTEP4/{p;q;}'`
    547      1.1  tron 		    fi
    548      1.1  tron 		    : ${CC=cc}
    549      1.1  tron 		    RANLIB="sleep 5; ranlib"
    550      1.1  tron 		else
    551      1.1  tron 		    error "Unable to determine your system type."
    552      1.1  tron 		fi
    553      1.1  tron 		;;
    554      1.1  tron 	   *)	error "Unknown system type: $SYSTEM $RELEASE";;
    555      1.1  tron esac
    556      1.1  tron 
    557      1.1  tron #
    558      1.1  tron # sigsetjmp()/siglongjmp() can be "better" than setjmp()/longjmp()
    559      1.1  tron # if used wisely (that is: almost never, just like signals).
    560      1.1  tron # Unfortunately some implementations have been buggy in the past.
    561      1.1  tron #
    562      1.1  tron case "$CCARGS" in
    563      1.1  tron  *-DNO_SIGSETJMP*) ;;
    564      1.1  tron                 *) trap 'rm -f makedefs.test makedefs.test.[co]' 1 2 3 15
    565      1.1  tron 		   cat >makedefs.test.c <<'EOF'
    566      1.1  tron #include <setjmp.h>
    567      1.1  tron #include <stdlib.h>
    568      1.1  tron #include <stdio.h>
    569      1.1  tron 
    570      1.1  tron static int count = 0;
    571      1.1  tron 
    572      1.1  tron int     main(int argc, char **argv)
    573      1.1  tron {
    574      1.1  tron     sigjmp_buf env;
    575      1.1  tron     int     retval;
    576      1.1  tron 
    577      1.1  tron     switch (retval = sigsetjmp(env, 1)) {
    578      1.1  tron     case 0:
    579      1.1  tron 	siglongjmp(env, 12345);
    580      1.1  tron     case 12345:
    581      1.1  tron 	break;
    582      1.1  tron     default:
    583      1.1  tron 	fprintf(stderr, "Error: siglongjmp ignores second argument\n");
    584      1.1  tron 	exit(1);
    585      1.1  tron     }
    586      1.1  tron 
    587      1.1  tron     switch (retval = sigsetjmp(env, 1)) {
    588      1.1  tron     case 0:
    589      1.1  tron 	if (count++ > 0) {
    590      1.1  tron 	    fprintf(stderr, "Error: not overriding siglongjmp(env, 0)\n");
    591      1.1  tron 	    exit(1);
    592      1.1  tron 	}
    593      1.1  tron 	siglongjmp(env, 0);
    594      1.1  tron     case 1:
    595      1.1  tron 	break;
    596      1.1  tron     default:
    597      1.1  tron 	fprintf(stderr, "Error: overriding siglongjmp(env, 0) with %d\n",
    598      1.1  tron 		retval);
    599      1.1  tron 	exit(1);
    600      1.1  tron     }
    601      1.1  tron     exit(0);
    602      1.1  tron }
    603      1.1  tron EOF
    604      1.1  tron 		   ${CC-gcc} -o makedefs.test makedefs.test.c || exit 1
    605      1.1  tron 		   ./makedefs.test 2>/dev/null ||
    606      1.1  tron 			CCARGS="$CCARGS -DNO_SIGSETJMP"
    607      1.1  tron 		   rm -f makedefs.test makedefs.test.[co]
    608      1.1  tron esac
    609      1.1  tron 
    610      1.1  tron #
    611      1.1  tron # OpenSSL has no configuration query utility, but we don't try to
    612      1.1  tron # guess. We assume includes in /usr/include/openssl and libraries in
    613      1.1  tron # /usr/lib, or in their /usr/local equivalents. If the OpenSSL files
    614      1.1  tron # are in a non-standard place, their locations need to be specified.
    615      1.1  tron #
    616      1.1  tron #case "$CCARGS" in
    617      1.1  tron # *-DUSE_TLS*)	;;
    618      1.1  tron #  *-DNO_TLS*)	;;
    619      1.1  tron #           *)	CCARGS="$CCARGS -DUSE_TLS"
    620      1.1  tron #		AUXLIBS="$AUXLIBS -lssl -lcrypto"
    621      1.1  tron #		;;
    622      1.1  tron #esac
    623      1.1  tron 
    624      1.1  tron #
    625      1.1  tron # PCRE 3.x has a pcre-config utility so we don't have to guess.
    626      1.1  tron #
    627      1.1  tron case "$CCARGS" in
    628      1.1  tron *-DHAS_PCRE*)	;;
    629      1.1  tron  *-DNO_PCRE*)	;;
    630      1.1  tron            *)	pcre_cflags=`(pcre-config --cflags) 2>/dev/null` &&
    631      1.1  tron 		    pcre_libs=`(pcre-config --libs) 2>/dev/null` && {
    632      1.1  tron 			CCARGS="$CCARGS -DHAS_PCRE $pcre_cflags"
    633      1.1  tron 			AUXLIBS="$AUXLIBS $pcre_libs"
    634      1.1  tron 		}
    635      1.1  tron 		;;
    636      1.1  tron esac
    637      1.1  tron 
    638      1.1  tron # Defaults that can be overruled (make makefiles CC=cc OPT=-O6 DEBUG=)
    639      1.1  tron # Disable optimizations by default when compiling for Purify. Disable
    640      1.1  tron # optimizations by default with gcc 2.8, until the compiler is known to
    641      1.1  tron # be OK. Those who dare can still overrule this (make makefiles OPT=-O).
    642      1.1  tron 
    643      1.1  tron case "$CC" in
    644      1.1  tron  *purify*) : ${OPT=};;
    645      1.1  tron */gcc|gcc) case `$CC -v` in
    646      1.1  tron 	   "gcc version 2.8"*) : ${OPT=};;
    647      1.1  tron 	   esac;;
    648      1.1  tron       *CC) error "Don't use CC. That's the C++ compiler";;
    649      1.1  tron         *) : ${OPT='-O'};;
    650      1.1  tron esac
    651      1.1  tron #
    652      1.1  tron # "gcc -W" 3.4.2 no longer reports functions that fail to return a
    653      1.1  tron # result.  Use "gcc -Wall -Wno-comment" instead. We'll figure out
    654      1.1  tron # later if the other -Wmumble options are really redundant. Having
    655      1.1  tron # een burned once by a compiler that lies about what warnings it
    656      1.1  tron # produces, not taking that chance again.
    657      1.1  tron 
    658      1.1  tron : ${CC='gcc $(WARN)'} ${OPT='-O'} ${DEBUG='-g'} ${AWK=awk} \
    659      1.1  tron ${WARN='-Wall -Wno-comment -Wformat -Wimplicit -Wmissing-prototypes \
    660      1.1  tron 	-Wparentheses -Wstrict-prototypes -Wswitch -Wuninitialized \
    661      1.1  tron 	-Wunused -Wno-missing-braces'}
    662      1.1  tron 
    663      1.1  tron export SYSTYPE AR ARFL RANLIB SYSLIBS CC OPT DEBUG AWK OPTS
    664      1.1  tron 
    665      1.1  tron # Snapshot only.
    666      1.1  tron #CCARGS="$CCARGS -DSNAPSHOT"
    667      1.1  tron 
    668      1.1  tron # Non-production: needs thorough testing, or major changes are still
    669      1.1  tron # needed before the code stabilizes.
    670      1.1  tron #CCARGS="$CCARGS -DNONPROD"
    671      1.1  tron 
    672      1.1  tron sed 's/  / /g' <<EOF
    673      1.1  tron SYSTYPE	= $SYSTYPE
    674      1.1  tron AR	= $AR
    675      1.1  tron ARFL	= $ARFL
    676      1.1  tron RANLIB	= $RANLIB
    677      1.1  tron SYSLIBS	= $AUXLIBS $SYSLIBS
    678      1.1  tron CC	= $CC $CCARGS
    679      1.1  tron OPT	= $OPT
    680      1.1  tron DEBUG	= $DEBUG
    681      1.1  tron AWK	= $AWK
    682      1.1  tron STRCASE = $STRCASE
    683      1.1  tron EXPORT	= AUXLIBS='$AUXLIBS' CCARGS='$CCARGS' OPT='$OPT' DEBUG='$DEBUG'
    684      1.1  tron WARN	= $WARN
    685      1.1  tron EOF
    686