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