Home | History | Annotate | Line # | Download | only in dist
makedefs revision 1.4
      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   ekkoBSD.1*)	SYSTYPE=EKKOBSD1
    156 		;;
    157    NetBSD.1*)	SYSTYPE=NETBSD1
    158 		;;
    159    NetBSD.2*)	SYSTYPE=NETBSD2
    160 		;;
    161    NetBSD.3*)	SYSTYPE=NETBSD3
    162 		;;
    163    NetBSD.4*)	SYSTYPE=NETBSD4
    164 		;;
    165    NetBSD.5*)	SYSTYPE=NETBSD5
    166 		;;
    167    BSD/OS.2*)	SYSTYPE=BSDI2
    168 		;;
    169    BSD/OS.3*)	SYSTYPE=BSDI3
    170 		;;
    171    BSD/OS.4*)	SYSTYPE=BSDI4
    172 		;;
    173  OSF1.V[3-5].*)	SYSTYPE=OSF1
    174 		# Use the native compiler by default
    175 		: ${CC=cc}
    176 		: ${DEBUG="-g3"}
    177 		case $RELEASE in
    178 		V[0-4].*) CCARGS="$CCARGS -DNO_IPV6";;
    179 		esac
    180 		;;
    181     SunOS.4*)	SYSTYPE=SUNOS4
    182 		SYSLIBS=-lresolv
    183 		;;
    184     SunOS.5*)	SYSTYPE=SUNOS5
    185 		RANLIB=echo
    186 		SYSLIBS="-lresolv -lsocket -lnsl"
    187 		# Stock awk breaks with >10 files.
    188 		test -x /usr/xpg4/bin/awk && AWK=/usr/xpg4/bin/awk
    189 		# Solaris 2.5 added usleep() and POSIX regular expressions
    190 		case $RELEASE in
    191 		    5.[0-4]) CCARGS="$CCARGS -DMISSING_USLEEP -DNO_POSIX_REGEXP";;
    192 		esac
    193 		# Solaris 8 added IPv6 and /dev/poll
    194 		case $RELEASE in
    195 		    5.[0-7]|5.[0-7].*) CCARGS="$CCARGS -DNO_IPV6 -DNO_DEVPOLL";;
    196 		esac
    197 		# Solaris 9 added closefrom(), futimesat() and /dev/*random
    198 		case $RELEASE in
    199 		    5.[0-8]|5.[0-8].*) CCARGS="$CCARGS -DNO_CLOSEFROM -DNO_DEV_URANDOM -DNO_FUTIMESAT";;
    200 		esac
    201 		# Work around broken str*casecmp(). Do it all here instead
    202 		# of having half the solution in the sys_defs.h file.
    203 		CCARGS="$CCARGS -Dstrcasecmp=fix_strcasecmp \
    204 		    -Dstrncasecmp=fix_strncasecmp"
    205 		STRCASE="strcasecmp.o"
    206 		# Avoid common types of braindamage
    207 		case "$LD_LIBRARY_PATH" in
    208 		?*) error "Don't set LD_LIBRARY_PATH";;
    209 		esac
    210 		case "${CC}" in
    211 		*" "*) ;;
    212 		*ucb*) error "Don't use /usr/ucb/cc or ucblib";;
    213 		  cc*) case `which ${CC}` in
    214 		*ucb*) error "Don't use /usr/ucb/cc or ucblib";;
    215 		  esac;;
    216 		esac
    217 		;;
    218    ULTRIX.4*)	SYSTYPE=ULTRIX4
    219 		if [ -f /usr/local/lib/libdb.a ]; then
    220 		    SYSLIBS="$SYSLIBS -ldb"
    221 		    CCARGS="$CCARGS -DHAS_DB"
    222 		    if [ -d /usr/local/include/db ]; then
    223 			CCARGS="$CCARGS -I/usr/local/include/db"
    224 		    fi
    225 		fi
    226 		for l in syslog resolv; do
    227 		    if [ -f /usr/local/lib/lib$l.a ]; then
    228 			SYSLIBS="$SYSLIBS -l$l"
    229 		    fi
    230 		done
    231 		;;
    232        AIX.*)	case "`uname -v`" in
    233 		6)	SYSTYPE=AIX6
    234 			case "$CC" in
    235 			cc|*/cc|xlc|*/xlc) CCARGS="$CCARGS -w -blibpath:/usr/lib:/lib:/usr/local/lib";;
    236 			esac
    237 			CCARGS="$CCARGS -D_ALL_SOURCE -DHAS_POSIX_REGEXP"
    238 			;;
    239 		5)	SYSTYPE=AIX5
    240 			case "$CC" in
    241 			cc|*/cc|xlc|*/xlc) CCARGS="$CCARGS -w -blibpath:/usr/lib:/lib:/usr/local/lib";;
    242 			esac
    243 			CCARGS="$CCARGS -D_ALL_SOURCE -DHAS_POSIX_REGEXP"
    244 			;;
    245 		4)	SYSTYPE=AIX4
    246 			# How embarrassing...
    247 			case "$CC" in
    248 			cc|*/cc|xlc|*/xlc) OPT=; CCARGS="$CCARGS -w -blibpath:/usr/lib:/lib:/usr/local/lib";;
    249 			esac
    250 			CCARGS="$CCARGS -D_ALL_SOURCE -DHAS_POSIX_REGEXP"
    251 			;;
    252 		3)	SYSTYPE=AIX3
    253 			# How embarrassing...
    254 			case "$CC" in
    255 			cc|*/cc|xlc|*/xlc) OPT=; CCARGS="$CCARGS -w";;
    256 			esac
    257 			CCARGS="$CCARGS -D_ALL_SOURCE"
    258 			;;
    259 		*)	error "Unknown AIX version: `uname -v`.";;
    260 		esac;;
    261 		# Tested with RedHat 3.03 on 20020729.
    262     Linux.1*)	SYSTYPE=LINUX1
    263 		SYSLIBS="-ldb"
    264 		;;
    265     Linux.2*)	SYSTYPE=LINUX2
    266 		# Postfix no longer needs DB 1.85 compatibility
    267 		if [ -f /usr/include/db.h ]
    268 		then
    269 		    : we are all set
    270 		elif [ -f /usr/include/db/db.h ]
    271 		then
    272 		    CCARGS="$CCARGS -I/usr/include/db"
    273 		else
    274 		    # No, we're not going to try db1 db2 db3 etc.
    275 		    # On a properly installed system, Postfix builds
    276 		    # by including <db.h> and by linking with -ldb
    277 		    echo "No <db.h> include file found." 1>&2
    278 		    echo "Install the appropriate db*-devel package first." 1>&2
    279 		    echo "See the RELEASE_NOTES file for more information." 1>&2
    280 		    exit 1
    281 		fi
    282 		# GDBM locks the DBM .pag file after open. This breaks postmap.
    283 		# if [ -f /usr/include/gdbm-ndbm.h ]
    284 		# then
    285 		#     CCARGS="$CCARGS -DHAS_DBM -DPATH_NDBM_H='<gdbm-ndbm.h>'"
    286 		#     GDBM_LIBS=gdbm
    287 		# elif [ -f /usr/include/gdbm/ndbm.h ]
    288 		# then
    289 		#     CCARGS="$CCARGS -DHAS_DBM -DPATH_NDBM_H='<gdbm/ndbm.h>'"
    290 		#     GDBM_LIBS=gdbm
    291 		# fi
    292 		SYSLIBS="-ldb"
    293 		for name in nsl resolv $GDBM_LIBS
    294 		do
    295 		    for lib in /usr/lib64 /lib64 /usr/lib /lib
    296 		    do
    297 			test -e $lib/lib$name.a -o -e $lib/lib$name.so && {
    298 			    SYSLIBS="$SYSLIBS -l$name"
    299 			    break
    300 			}
    301 		    done
    302 		done
    303 		# Kernel 2.4 added IPv6
    304 		case "$RELEASE" in
    305 		2.[0-3].*) CCARGS="$CCARGS -DNO_IPV6";;
    306 		esac
    307 		# Kernel 2.6 added EPOLL
    308 		case "$RELEASE" in
    309 		2.[0-5].*) CCARGS="$CCARGS -DNO_EPOLL";;
    310 		    # Workaround for retarded libc 
    311 		    2.6.*)
    312 		       if [ `expr "X$CCARGS" : "X.*-DNO_EPOLL"` -gt 0 ]
    313                        then
    314                            :
    315                        elif [ ! -e /usr/include/sys/epoll.h ]
    316                        then
    317                            echo CCARGS="$CCARGS -DNO_EPOLL"
    318                        else
    319 			   trap 'rm -f makedefs.test makedefs.test.[co]' 1 2 3 15
    320 			   cat >makedefs.test.c <<'EOF'
    321 #include <sys/types.h>
    322 #include <sys/epoll.h>
    323 #include <errno.h>
    324 #include <stdio.h>
    325 #include <stdlib.h>
    326 
    327 int     main(int argc, char **argv)
    328 {
    329     int     epoll_handle;
    330 
    331     if ((epoll_handle = epoll_create(1)) < 0) {
    332 	perror("epoll_create");
    333 	exit(1);
    334     }
    335     exit(0);
    336 }
    337 EOF
    338 			   ${CC-gcc} -o makedefs.test makedefs.test.c || exit 1
    339 			   ./makedefs.test 2>/dev/null ||
    340 				CCARGS="$CCARGS -DNO_EPOLL"
    341 			   rm -f makedefs.test makedefs.test.[co]
    342 		       fi;;
    343 		esac
    344 		;;
    345     Linux.3*)	SYSTYPE=LINUX3
    346 		if [ -f /usr/include/db.h ]
    347 		then
    348 		    : we are all set
    349 		elif [ -f /usr/include/db/db.h ]
    350 		then
    351 		    CCARGS="$CCARGS -I/usr/include/db"
    352 		else
    353 		    # On a properly installed system, Postfix builds
    354 		    # by including <db.h> and by linking with -ldb
    355 		    echo "No <db.h> include file found." 1>&2
    356 		    echo "Install the appropriate db*-devel package first." 1>&2
    357 		    echo "See the RELEASE_NOTES file for more information." 1>&2
    358 		    exit 1
    359 		fi
    360 		SYSLIBS="-ldb"
    361 		for name in nsl resolv
    362 		do
    363 		    for lib in /usr/lib64 /lib64 /usr/lib /lib
    364 		    do
    365 			test -e $lib/lib$name.a -o -e $lib/lib$name.so && {
    366 			    SYSLIBS="$SYSLIBS -l$name"
    367 			    break
    368 			}
    369 		    done
    370 		done
    371 		;;
    372      GNU.0*|GNU/kFreeBSD.[567]*)
    373      		SYSTYPE=GNU0
    374 		# Postfix no longer needs DB 1.85 compatibility
    375 		if [ -f /usr/include/db.h ]
    376 		then
    377 		    : we are all set
    378 		elif [ -f /usr/include/db/db.h ]
    379 		then
    380 		    CCARGS="$CCARGS -I/usr/include/db"
    381 		else
    382 		    # No, we're not going to try db1 db2 db3 etc.
    383 		    # On a properly installed system, Postfix builds
    384 		    # by including <db.h> and by linking with -ldb
    385 		    echo "No <db.h> include file found." 1>&2
    386 		    echo "Install the appropriate db*-devel package first." 1>&2
    387 		    echo "See the RELEASE_NOTES file for more information." 1>&2
    388 		    exit 1
    389 		fi
    390 		SYSLIBS="-ldb"
    391 		for name in nsl resolv
    392 		do
    393 		    for lib in /usr/lib64 /lib64 /usr/lib /lib
    394 		    do
    395 			test -e $lib/lib$name.a -o -e $lib/lib$name.so && {
    396 			    SYSLIBS="$SYSLIBS -l$name"
    397 			    break
    398 			}
    399 		    done
    400 		done
    401 		case "`uname -s`" in
    402 		GNU)
    403 			# currently no IPv6 support on Hurd
    404 			CCARGS="$CCARGS -DNO_IPV6"
    405 			;;
    406 		esac
    407 		;;
    408      IRIX*.5.*)	SYSTYPE=IRIX5
    409 		# Use the native compiler by default
    410 		: ${CC=cc} ${DEBUG="-g3"}
    411 		RANLIB=echo
    412 		;;
    413      IRIX*.6.*)	SYSTYPE=IRIX6
    414 		# Use the native compiler by default, and allow nested comments.
    415 		: ${CC="cc -woff 1009,1116,1412"}
    416 		RANLIB=echo
    417 		;;
    418 HP-UX.A.09.*)	SYSTYPE=HPUX9
    419 		SYSLIBS=-ldbm
    420 		CCARGS="$CCARGS -DMISSING_USLEEP"
    421 		if [ -f /usr/lib/libdb.a ]; then
    422 		    CCARGS="$CCARGS -DHAS_DB"
    423 		    SYSLIBS="$SYSLIBS -ldb"
    424 		fi
    425 		;;
    426 HP-UX.B.10.*)	SYSTYPE=HPUX10
    427 		CCARGS="$CCARGS `nm /usr/lib/libc.a 2>/dev/null |
    428 		    (grep usleep >/dev/null || echo '-DMISSING_USLEEP')`"
    429 		if [ -f /usr/lib/libdb.a ]; then
    430 		    CCARGS="$CCARGS -DHAS_DB"
    431 		    SYSLIBS=-ldb
    432 		fi
    433 		;;
    434 HP-UX.B.11.*)	SYSTYPE=HPUX11
    435 		SYSLIBS=-lnsl
    436 		if [ -f /usr/lib/libdb.a ]; then
    437 		    CCARGS="$CCARGS -DHAS_DB"
    438 		    SYSLIBS="$SYSLIBS -ldb"
    439 		fi
    440 		;;
    441 ReliantUNIX-?.5.43) SYSTYPE=ReliantUnix543
    442 		RANLIB=echo
    443 		SYSLIBS="-lresolv -lsocket -lnsl"
    444 		;;
    445     Darwin.*)   SYSTYPE=MACOSX
    446 		# Use the native compiler by default
    447 		: ${CC=cc}
    448 		# Darwin > 1.3 uses awk and flat_namespace
    449 		case $RELEASE in
    450 		 1.[0-3]) AWK=gawk;;
    451 		       *) AWK=awk
    452 			  SYSLIBS=-flat_namespace;;
    453 		esac
    454 		# Darwin 7 adds IPv6 support, BIND_8_COMPAT, NO_NETINFO
    455 		case $RELEASE in
    456 		 [1-6].*) CCARGS="$CCARGS -DNO_IPV6";;
    457 		       *) CCARGS="$CCARGS -DBIND_8_COMPAT -DNO_NETINFO";;
    458 		esac
    459 		# Darwin 10.3.0 no longer has <nameser8_compat.h>.
    460 		case $RELEASE in
    461 		     ?.*) CCARGS="$CCARGS -DRESOLVE_H_NEEDS_NAMESER8_COMPAT_H";;
    462 		       *) CCARGS="$CCARGS -DRESOLVE_H_NEEDS_ARPA_NAMESER_COMPAT_H";;
    463 		esac
    464 		# kqueue and/or poll are broken up to and including MacOS X 10.5
    465 		CCARGS="$CCARGS -DNO_KQUEUE"
    466 #		# Darwin 8.11.1 has kqueue support, but let's play safe
    467 #		case $RELEASE in
    468 #		 [1-8].*) CCARGS="$CCARGS -DNO_KQUEUE";;
    469 #		       *) trap 'rm -f makedefs.test makedefs.test.[co]' 1 2 3 15
    470 #			  cat >makedefs.test.c <<'EOF'
    471 #/* Adapted from libevent. */
    472 #
    473 ##include <sys/types.h>
    474 ##include <sys/event.h>
    475 ##include <sys/time.h>
    476 ##include <string.h>
    477 ##include <stdlib.h>
    478 ##include <stdio.h>
    479 #
    480 ##ifndef EV_SET
    481 ##define EV_SET(kp, id, fi, fl, ffl, da, ud) do { \
    482 #	struct kevent *__kp = (kp); \
    483 #	__kp->ident = (id); \
    484 #	__kp->filter = (fi); \
    485 #	__kp->flags = (fl); \
    486 #	__kp->fflags = (ffl); \
    487 #	__kp->data = (da); \
    488 #	__kp->udata = (ud); \
    489 #    } while(0)
    490 ##endif
    491 #
    492 #int     main(int argc, char **argv)
    493 #{
    494 #    int     kq;
    495 #    struct kevent test_change;
    496 #    struct kevent test_result;
    497 #
    498 #    if ((kq = kqueue()) < 0) {
    499 #	perror("kqueue");
    500 #	exit(1);
    501 #    }
    502 ##define TEST_FD (-1)
    503 #
    504 #    EV_SET(&test_change, TEST_FD, EVFILT_READ, EV_ADD, 0, 0, 0);
    505 #    if (kevent(kq,
    506 #	       &test_change, sizeof(test_change) / sizeof(struct kevent),
    507 #	       &test_result, sizeof(test_result) / sizeof(struct kevent),
    508 #	       (struct timespec *) 0) != 1 ||
    509 #	test_result.ident != TEST_FD ||
    510 #	test_result.flags != EV_ERROR) {
    511 #	fprintf(stderr, "Error: kevent reports errors incorrectly\n");
    512 #	exit(1);
    513 #    }
    514 #    exit(0);
    515 #}
    516 #EOF
    517 #			  $CC -o makedefs.test makedefs.test.c || exit 1
    518 #			  ./makedefs.test 2>/dev/null || 
    519 #				CCARGS="$CCARGS -DNO_KQUEUE"
    520 #			  rm -f makedefs.test makedefs.test.[co];;
    521 #		esac
    522 		;;
    523     dcosx.1*)	SYSTYPE=DCOSX1
    524 		RANLIB=echo
    525 		SYSLIBS="-lresolv -lsocket -lnsl -lc -lrpcsvc -L/usr/ucblib -lucb"
    526 		;;
    527 
    528 	 ".")	if [ -d /NextApps ]; then
    529 		    SYSTYPE=`hostinfo | sed -n \
    530 			's/^.*NeXT Mach 3.*$/NEXTSTEP3/;/NEXTSTEP3/{p;q;}'`
    531 		    if [ "$SYSTYPE" = "" ]; then
    532 			SYSTYPE=`hostinfo | sed -n \
    533 			    's/^.*NeXT Mach 4.*$/OPENSTEP4/;/OPENSTEP4/{p;q;}'`
    534 		    fi
    535 		    : ${CC=cc}
    536 		    RANLIB="sleep 5; ranlib"
    537 		else
    538 		    error "Unable to determine your system type."
    539 		fi
    540 		;;
    541 	   *)	error "Unknown system type: $SYSTEM $RELEASE";;
    542 esac
    543 
    544 #
    545 # sigsetjmp()/siglongjmp() can be "better" than setjmp()/longjmp()
    546 # if used wisely (that is: almost never, just like signals).
    547 # Unfortunately some implementations have been buggy in the past.
    548 #
    549 case "$CCARGS" in
    550  *-DNO_SIGSETJMP*) ;;
    551                 *) trap 'rm -f makedefs.test makedefs.test.[co]' 1 2 3 15
    552 		   cat >makedefs.test.c <<'EOF'
    553 #include <setjmp.h>
    554 #include <stdlib.h>
    555 #include <stdio.h>
    556 
    557 static int count = 0;
    558 
    559 int     main(int argc, char **argv)
    560 {
    561     sigjmp_buf env;
    562     int     retval;
    563 
    564     switch (retval = sigsetjmp(env, 1)) {
    565     case 0:
    566 	siglongjmp(env, 12345);
    567     case 12345:
    568 	break;
    569     default:
    570 	fprintf(stderr, "Error: siglongjmp ignores second argument\n");
    571 	exit(1);
    572     }
    573 
    574     switch (retval = sigsetjmp(env, 1)) {
    575     case 0:
    576 	if (count++ > 0) {
    577 	    fprintf(stderr, "Error: not overriding siglongjmp(env, 0)\n");
    578 	    exit(1);
    579 	}
    580 	siglongjmp(env, 0);
    581     case 1:
    582 	break;
    583     default:
    584 	fprintf(stderr, "Error: overriding siglongjmp(env, 0) with %d\n",
    585 		retval);
    586 	exit(1);
    587     }
    588     exit(0);
    589 }
    590 EOF
    591 		   ${CC-gcc} -o makedefs.test makedefs.test.c || exit 1
    592 		   ./makedefs.test 2>/dev/null ||
    593 			CCARGS="$CCARGS -DNO_SIGSETJMP"
    594 		   rm -f makedefs.test makedefs.test.[co]
    595 esac
    596 
    597 #
    598 # OpenSSL has no configuration query utility, but we don't try to
    599 # guess. We assume includes in /usr/include/openssl and libraries in
    600 # /usr/lib, or in their /usr/local equivalents. If the OpenSSL files
    601 # are in a non-standard place, their locations need to be specified.
    602 #
    603 #case "$CCARGS" in
    604 # *-DUSE_TLS*)	;;
    605 #  *-DNO_TLS*)	;;
    606 #           *)	CCARGS="$CCARGS -DUSE_TLS"
    607 #		AUXLIBS="$AUXLIBS -lssl -lcrypto"
    608 #		;;
    609 #esac
    610 
    611 #
    612 # PCRE 3.x has a pcre-config utility so we don't have to guess.
    613 #
    614 case "$CCARGS" in
    615 *-DHAS_PCRE*)	;;
    616  *-DNO_PCRE*)	;;
    617            *)	pcre_cflags=`(pcre-config --cflags) 2>/dev/null` &&
    618 		    pcre_libs=`(pcre-config --libs) 2>/dev/null` && {
    619 			CCARGS="$CCARGS -DHAS_PCRE $pcre_cflags"
    620 			AUXLIBS="$AUXLIBS $pcre_libs"
    621 		}
    622 		;;
    623 esac
    624 
    625 # Defaults that can be overruled (make makefiles CC=cc OPT=-O6 DEBUG=)
    626 # Disable optimizations by default when compiling for Purify. Disable
    627 # optimizations by default with gcc 2.8, until the compiler is known to
    628 # be OK. Those who dare can still overrule this (make makefiles OPT=-O).
    629 
    630 case "$CC" in
    631  *purify*) : ${OPT=};;
    632 */gcc|gcc) case `$CC -v` in
    633 	   "gcc version 2.8"*) : ${OPT=};;
    634 	   esac;;
    635       *CC) error "Don't use CC. That's the C++ compiler";;
    636         *) : ${OPT='-O'};;
    637 esac
    638 #
    639 # "gcc -W" 3.4.2 no longer reports functions that fail to return a
    640 # result.  Use "gcc -Wall -Wno-comment" instead. We'll figure out
    641 # later if the other -Wmumble options are really redundant. Having
    642 # een burned once by a compiler that lies about what warnings it
    643 # produces, not taking that chance again.
    644 
    645 : ${CC='gcc $(WARN)'} ${OPT='-O'} ${DEBUG='-g'} ${AWK=awk} \
    646 ${WARN='-Wall -Wno-comment -Wformat -Wimplicit -Wmissing-prototypes \
    647 	-Wparentheses -Wstrict-prototypes -Wswitch -Wuninitialized \
    648 	-Wunused -Wno-missing-braces'}
    649 
    650 export SYSTYPE AR ARFL RANLIB SYSLIBS CC OPT DEBUG AWK OPTS
    651 
    652 # Snapshot only.
    653 #CCARGS="$CCARGS -DSNAPSHOT"
    654 
    655 # Non-production: needs thorough testing, or major changes are still
    656 # needed before the code stabilizes.
    657 #CCARGS="$CCARGS -DNONPROD"
    658 
    659 sed 's/  / /g' <<EOF
    660 SYSTYPE	= $SYSTYPE
    661 AR	= $AR
    662 ARFL	= $ARFL
    663 RANLIB	= $RANLIB
    664 SYSLIBS	= $AUXLIBS $SYSLIBS
    665 CC	= $CC $CCARGS
    666 OPT	= $OPT
    667 DEBUG	= $DEBUG
    668 AWK	= $AWK
    669 STRCASE = $STRCASE
    670 EXPORT	= AUXLIBS='$AUXLIBS' CCARGS='$CCARGS' OPT='$OPT' DEBUG='$DEBUG'
    671 WARN	= $WARN
    672 EOF
    673