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