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