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