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