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