c_read(): FIX trim string length
[s-mailx.git] / make-config.sh
bloba1662f067e41d5316708e94d36c9da15697ef6f3
1 #!/bin/sh -
2 #@ Please see INSTALL and make.rc instead.
4 LC_ALL=C
5 export LC_ALL
7 : ${SHELL:=/bin/sh}
9 # The feature set, to be kept in sync with make.rc
10 # If no documentation given, the option is used as such; if doc is a hyphen,
11 # entry is suppressed when configuration overview is printed, and also in the
12 # *features* string: most likely for obsolete features etc.
13 XOPTIONS="\
14 ICONV='Character set conversion using iconv(3)' \
15 SOCKETS='Network support' \
16 SSL='SSL/TLS (OpenSSL / LibreSSL)' \
17 SSL_ALL_ALGORITHMS='Support of all digest and cipher algorithms' \
18 SMTP='Simple Mail Transfer Protocol client' \
19 POP3='Post Office Protocol Version 3 client' \
20 IMAP='IMAP v4r1 client' \
21 GSSAPI='Generic Security Service authentication' \
22 NETRC='.netrc file support' \
23 AGENT='-' \
24 MD5='MD5 message digest (APOP, CRAM-MD5)' \
25 IDNA='Internationalized Domain Names for Applications (encode only)' \
26 IMAP_SEARCH='IMAP-style search expressions' \
27 REGEX='Regular expressions' \
28 MLE='Mailx Line Editor' \
29 HISTORY='Line editor history management' \
30 KEY_BINDINGS='Configurable key bindings' \
31 TERMCAP='Terminal capability queries (termcap(5))' \
32 TERMCAP_VIA_TERMINFO='Terminal capability queries use terminfo(5)' \
33 ERRORS='Error log message ring' \
34 SPAM_SPAMC='Spam management via spamc(1) of spamassassin(1)' \
35 SPAM_SPAMD='-' \
36 SPAM_FILTER='Freely configurable *spam-filter-..*s' \
37 DOCSTRINGS='Command documentation help strings' \
38 QUOTE_FOLD='Extended *quote-fold*ing' \
39 FILTER_HTML_TAGSOUP='Simple built-in HTML-to-text display filter' \
40 COLOUR='Coloured message display' \
41 DOTLOCK='Dotlock files and privilege-separated dotlock program' \
44 # Options which are automatically deduced from host environment, i.e., these
45 # need special treatment all around here to warp from/to OPT_ stuff
46 # setlocale, C90AMEND1, NL_LANGINFO, wcwidth
47 XOPTIONS_DETECT="\
48 LOCALES='Locale support - printable characters etc. depend on environment' \
49 MULTIBYTE_CHARSETS='Multibyte character sets' \
50 TERMINAL_CHARSET='Automatic detection of terminal character set' \
51 WIDE_GLYPHS='Wide glyph support' \
54 # Rather special options, for custom building, or which always exist.
55 # Mostly for generating the visual overview and the *features* string
56 XOPTIONS_XTRA="\
57 MIME='Multipurpose Internet Mail Extensions' \
58 SMIME='S/MIME message signing, verification, en- and decryption' \
59 CROSS_BUILD='Cross-compilation: trust any detected environment' \
60 DEBUG='Debug enabled binary, not for end-users: THANKS!' \
61 DEVEL='Computers do not blunder' \
64 # The problem is that we don't have any tools we can use right now, so
65 # encapsulate stuff in functions which get called in right order later on
67 option_reset() {
68 set -- ${OPTIONS}
69 for i
71 eval OPT_${i}=0
72 done
75 option_maximal() {
76 set -- ${OPTIONS}
77 for i
79 eval OPT_${i}=1
80 done
81 OPT_DOTLOCK=require OPT_ICONV=require OPT_REGEX=require
84 option_setup() {
85 option_parse OPTIONS_DETECT "${XOPTIONS_DETECT}"
86 option_parse OPTIONS "${XOPTIONS}"
87 option_parse OPTIONS_XTRA "${XOPTIONS_XTRA}"
88 OPT_MIME=1
90 # Predefined CONFIG= urations take precedence over anything else
91 if [ -n "${CONFIG}" ]; then
92 option_reset
93 case "${CONFIG}" in
94 [nN][uU][lL][lL])
96 [nN][uU][lL][lL][iI])
97 OPT_ICONV=require
99 [mM][iI][nN][iI][mM][aA][lL])
100 OPT_DOTLOCK=require OPT_ICONV=require OPT_REGEX=require
101 OPT_COLOUR=1
102 OPT_DOCSTRINGS=1
103 OPT_ERRORS=1
104 OPT_IDNA=1
105 OPT_MLE=1
106 OPT_HISTORY=1 OPT_KEY_BINDINGS=1
107 OPT_SPAM_FILTER=1
109 [nN][eE][tT][sS][eE][nN][dD])
110 OPT_DOTLOCK=require OPT_ICONV=require OPT_REGEX=require
111 OPT_SOCKETS=require
112 OPT_SSL=require
113 OPT_SMTP=require
114 OPT_GSSAPI=1 OPT_NETRC=1
115 OPT_AGENT=1
116 OPT_COLOUR=1
117 OPT_DOCSTRINGS=1
118 OPT_ERRORS=1
119 OPT_IDNA=1
120 OPT_MLE=1
121 OPT_HISTORY=1 OPT_KEY_BINDINGS=1
122 OPT_SPAM_FILTER=1
124 [mM][aA][xX][iI][mM][aA][lL])
125 option_maximal
127 [dD][eE][vV][eE][lL])
128 option_maximal
129 OPT_DEVEL=1 OPT_DEBUG=1 OPT_NYD2=1
131 [oO][dD][eE][vV][eE][lL])
132 option_maximal
133 OPT_DEVEL=1
136 echo >&2 "Unknown CONFIG= setting: ${CONFIG}"
137 echo >&2 ' NULL, NULLI, MINIMAL, NETSEND, MAXIMAL'
138 exit 1
140 esac
141 msg_nonl "CONFIG=${CONFIG} ... "
145 # Inter-relationships
146 option_update() {
147 if feat_no SMTP && feat_no POP3 && feat_no IMAP; then
148 OPT_SOCKETS=0
150 if feat_no SOCKETS; then
151 if feat_require SMTP; then
152 msg 'ERROR: need SOCKETS for required feature SMTP'
153 config_exit 13
155 if feat_require POP3; then
156 msg 'ERROR: need SOCKETS for required feature POP3'
157 config_exit 13
159 if feat_require IMAP; then
160 msg 'ERROR: need SOCKETS for required feature IMAP'
161 config_exit 13
163 OPT_SSL=0 OPT_SSL_ALL_ALGORITHMS=0
164 OPT_SMTP=0 OPT_POP3=0 OPT_IMAP=0
165 OPT_GSSAPI=0 OPT_NETRC=0 OPT_AGENT=0
167 if feat_no SMTP && feat_no IMAP; then
168 OPT_GSSAPI=0
171 if feat_no ICONV; then
172 if feat_yes IMAP; then
173 if feat_require IMAP; then
174 msg 'ERROR: need ICONV for required feature IMAP'
175 config_exit 13
177 msg 'ERROR: disabling IMAP due to missing ICONV'
178 OPT_IMAP=0
181 if feat_yes IDNA; then
182 if feat_require IDNA; then
183 msg 'ERROR: need ICONV for required feature IDNA'
184 config_exit 13
186 msg 'ERROR: disabling IDNA due to missing ICONV'
187 OPT_IDNA=0
191 if feat_no MLE; then
192 OPT_HISTORY=0 OPT_KEY_BINDINGS=0
195 # If we don't need MD5 leave it alone
196 if feat_no SOCKETS; then
197 OPT_MD5=0
200 if feat_no TERMCAP; then
201 OPT_TERMCAP_VIA_TERMINFO=0
204 if feat_yes DEVEL; then
205 OPT_DEBUG=1
209 rc=./make.rc
210 lst=./mk-config.lst
211 ev=./mk-config.ev
212 h=./mk-config.h h_name=mk-config.h
213 mk=./mk-config.mk
215 newlst=./mk-nconfig.lst
216 newmk=./mk-nconfig.mk
217 newev=./mk-nconfig.ev
218 newh=./mk-nconfig.h
219 tmp0=___tmp
220 tmp=./${tmp0}1$$
221 tmp2=./${tmp0}2$$
223 ## -- >8 - << OPTIONS | OS/CC >> - 8< -- ##
225 # Note that potential duplicates in PATH, C_INCLUDE_PATH etc. will be cleaned
226 # via path_check() later on once possible
228 # TODO cc_maxopt is brute simple, we should compile test program and dig real
229 # compiler versions for known compilers, then be more specific
230 cc_maxopt=100
231 _CFLAGS= _LDFLAGS=
233 os_early_setup() {
234 # We don't "have any utility": only path adjustments and such in here!
235 i="${OS:-`uname -s`}"
237 if [ ${i} = SunOS ]; then
238 msg 'SunOS / Solaris? Applying some "early setup" rules ...'
239 _os_early_setup_sunos
243 _os_early_setup_sunos() {
244 # According to standards(5), this is what we need to do
245 if [ -d /usr/xpg4 ]; then :; else
246 msg 'ERROR: On SunOS / Solaris we need /usr/xpg4 environment! Sorry.'
247 config_exit 1
249 PATH="/usr/xpg4/bin:/usr/ccs/bin:/usr/bin:${PATH}"
250 [ -d /usr/xpg6 ] && PATH="/usr/xpg6/bin:${PATH}"
251 export PATH
254 os_setup() {
255 # OSENV ends up in *build-osenv*
256 # OSFULLSPEC is used to recognize changes (i.e., machine type, updates etc.)
257 : ${OS:=`uname -s | ${tr} '[A-Z]' '[a-z]'`}
258 : ${OSENV:=`uname -srm`}
259 : ${OSFULLSPEC:=`uname -a`}
260 msg 'Operating system is %s' ${OS}
262 if [ ${OS} = sunos ]; then
263 msg ' . have special SunOS / Solaris "setup" rules ...'
264 _os_setup_sunos
265 elif [ ${OS} = unixware ]; then
266 msg ' . have special UnixWare environmental rules ...'
267 if feat_yes AUTOCC && command -v cc >/dev/null 2>&1; then
268 CC=cc
269 feat_yes DEBUG && _CFLAGS='-v -Xa -g' || _CFLAGS='-Xa -O'
271 CFLAGS="${_CFLAGS} ${EXTRA_CFLAGS}"
272 LDFLAGS="${_LDFLAGS} ${EXTRA_LDFLAGS}"
273 export CC CFLAGS LDFLAGS
274 OPT_AUTOCC=0 had_want_autocc=1 need_R_ldflags=-R
276 elif [ -n "${VERBOSE}" ]; then
277 msg ' . no special treatment for this system necessary or known'
280 # Sledgehammer: better set _GNU_SOURCE
281 # And in general: oh, boy!
282 OS_DEFINES="${OS_DEFINES}#define _GNU_SOURCE\n"
283 #OS_DEFINES="${OS_DEFINES}#define _POSIX_C_SOURCE 200809L\n"
284 #OS_DEFINES="${OS_DEFINES}#define _XOPEN_SOURCE 700\n"
285 #[ ${OS} = darwin ] && OS_DEFINES="${OS_DEFINES}#define _DARWIN_C_SOURCE\n"
287 # On pkgsrc(7) systems automatically add /usr/pkg/*
288 if [ -d /usr/pkg ]; then
289 C_INCLUDE_PATH="/usr/pkg/include:${C_INCLUDE_PATH}"
290 LD_LIBRARY_PATH="/usr/pkg/lib:${LD_LIBRARY_PATH}"
294 _os_setup_sunos() {
295 C_INCLUDE_PATH="/usr/xpg4/include:${C_INCLUDE_PATH}"
296 LD_LIBRARY_PATH="/usr/xpg4/lib:${LD_LIBRARY_PATH}"
298 # Include packages
299 if [ -d /opt/csw ]; then
300 C_INCLUDE_PATH="/opt/csw/include:${C_INCLUDE_PATH}"
301 LD_LIBRARY_PATH="/opt/csw/lib:${LD_LIBRARY_PATH}"
304 OS_DEFINES="${OS_DEFINES}#define __EXTENSIONS__\n"
305 #OS_DEFINES="${OS_DEFINES}#define _POSIX_C_SOURCE 200112L\n"
307 [ -n "${cksum}" ] || cksum=/opt/csw/gnu/cksum
308 if [ -x "${cksum}" ]; then :; else
309 msg 'ERROR: Not an executable program: %s' "${cksum}"
310 msg 'ERROR: We need a CRC-32 cksum(1), as specified in POSIX.'
311 msg 'ERROR: However, we do so only for tests.'
312 msg 'ERROR: If that is ok, set "cksum=/usr/bin/true", then rerun'
313 config_exit 1
316 if feat_yes AUTOCC; then
317 if command -v cc >/dev/null 2>&1; then
318 CC=cc
319 feat_yes DEBUG && _CFLAGS="-v -Xa -g" || _CFLAGS="-Xa -O"
321 CFLAGS="${_CFLAGS} ${EXTRA_CFLAGS}"
322 LDFLAGS="${_LDFLAGS} ${EXTRA_LDFLAGS}"
323 export CC CFLAGS LDFLAGS
324 OPT_AUTOCC=0 had_want_autocc=1 need_R_ldflags=-R
325 else
326 # Assume gcc(1), which supports -R for compat
327 cc_maxopt=2 force_no_stackprot=1 need_R_ldflags=-Wl,-R
332 # Check out compiler ($CC) and -flags ($CFLAGS)
333 cc_setup() {
334 # Even though it belongs into cc_flags we will try to compile and link
335 # something, so ensure we have a clean state regarding CFLAGS/LDFLAGS or
336 # EXTRA_CFLAGS/EXTRA_LDFLAGS
337 if feat_no AUTOCC; then
338 _cc_default
339 # Ensure those don't do any harm
340 EXTRA_CFLAGS= EXTRA_LDFLAGS=
341 export EXTRA_CFLAGS EXTRA_LDFLAGS
342 return
343 else
344 CFLAGS= LDFLAGS=
345 export CFLAGS LDFLAGS
348 [ -n "${CC}" ] && [ "${CC}" != cc ] && { _cc_default; return; }
350 msg_nonl 'Searching for a usable C compiler .. $CC='
351 if { i="`command -v clang`"; }; then
352 CC=${i}
353 elif { i="`command -v gcc`"; }; then
354 CC=${i}
355 elif { i="`command -v c99`"; }; then
356 CC=${i}
357 elif { i="`command -v tcc`"; }; then
358 CC=${i}
359 elif { i="`command -v pcc`"; }; then
360 CC=${i}
361 else
362 if [ "${CC}" = cc ]; then
364 elif { i="`command -v c89`"; }; then
365 CC=${i}
366 else
367 msg 'boing booom tschak'
368 msg 'ERROR: I cannot find a compiler!'
369 msg ' Neither of clang(1), gcc(1), tcc(1), pcc(1), c89(1) and c99(1).'
370 msg ' Please set ${CC} environment variable, maybe ${CFLAGS}, rerun.'
371 config_exit 1
374 msg '%s' "${CC}"
375 export CC
378 _cc_default() {
379 if [ -z "${CC}" ]; then
380 msg 'To go on like you have chosen, please set $CC, rerun.'
381 config_exit 1
384 if [ -z "${VERBOSE}" ] && [ -f ${lst} ] && feat_no DEBUG; then
386 else
387 msg 'Using C compiler ${CC}=%s' "${CC}"
391 cc_flags() {
392 if feat_yes AUTOCC; then
393 if [ -f ${lst} ] && feat_no DEBUG && [ -z "${VERBOSE}" ]; then
394 cc_check_silent=1
395 msg 'Detecting ${CFLAGS}/${LDFLAGS} for ${CC}=%s, just a second..' \
396 "${CC}"
397 else
398 cc_check_silent=
399 msg 'Testing usable ${CFLAGS}/${LDFLAGS} for ${CC}=%s' "${CC}"
402 i=`echo "${CC}" | ${awk} 'BEGIN{FS="/"}{print $NF}'`
403 if { echo "${i}" | ${grep} tcc; } >/dev/null 2>&1; then
404 msg ' . have special tcc(1) environmental rules ...'
405 _cc_flags_tcc
406 else
407 # As of pcc CVS 2016-04-02, stack protection support is announced but
408 # will break if used on Linux
409 if { echo "${i}" | ${grep} pcc; } >/dev/null 2>&1; then
410 force_no_stackprot=1
412 _cc_flags_generic
415 feat_no DEBUG && _CFLAGS="-DNDEBUG ${_CFLAGS}"
416 CFLAGS="${_CFLAGS} ${EXTRA_CFLAGS}"
417 LDFLAGS="${_LDFLAGS} ${EXTRA_LDFLAGS}"
418 else
419 if feat_no DEBUG; then
420 CFLAGS="-DNDEBUG ${CFLAGS}"
423 msg ''
424 export CFLAGS LDFLAGS
427 _cc_flags_tcc() {
428 __cflags=${_CFLAGS} __ldflags=${_LDFLAGS}
429 _CFLAGS= _LDFLAGS=
431 cc_check -Wall
432 cc_check -Wextra
433 cc_check -pedantic
435 if feat_yes DEBUG; then
436 # May have problems to find libtcc cc_check -b
437 cc_check -g
440 if ld_check -Wl,-rpath =./ no; then
441 need_R_ldflags=-Wl,-rpath=
442 ld_check -Wl,--enable-new-dtags
443 ld_runtime_flags # update!
446 _CFLAGS="${_CFLAGS} ${__cflags}" _LDFLAGS="${_LDFLAGS} ${__ldflags}"
447 unset __cflags __ldflags
450 _cc_flags_generic() {
451 __cflags=${_CFLAGS} __ldflags=${_LDFLAGS}
452 _CFLAGS= _LDFLAGS=
453 feat_yes DEVEL && cc_check -std=c89 || cc_check -std=c99
455 # Check -g first since some others may rely upon -g / optim. level
456 if feat_yes DEBUG; then
457 cc_check -O
458 cc_check -g
459 elif [ ${cc_maxopt} -gt 2 ] && cc_check -O3; then
461 elif [ ${cc_maxopt} -gt 1 ] && cc_check -O2; then
463 elif [ ${cc_maxopt} -gt 0 ] && cc_check -O1; then
465 else
466 cc_check -O
469 if feat_yes AMALGAMATION; then
470 cc_check -pipe
473 #if feat_yes DEVEL && cc_check -Weverything; then
475 #else
476 cc_check -Wall
477 cc_check -Wextra
478 cc_check -Wbad-function-cast
479 cc_check -Wcast-align
480 cc_check -Wcast-qual
481 cc_check -Winit-self
482 cc_check -Wmissing-prototypes
483 cc_check -Wshadow
484 cc_check -Wunused
485 cc_check -Wwrite-strings
486 cc_check -Wno-long-long
488 cc_check -pedantic
490 if feat_yes AMALGAMATION && feat_no DEVEL; then
491 cc_check -Wno-unused-function
493 feat_no DEVEL && cc_check -Wno-unused-result # XXX do right way (pragma too)
495 cc_check -fno-unwind-tables
496 cc_check -fno-asynchronous-unwind-tables
497 cc_check -fstrict-aliasing
498 if cc_check -fstrict-overflow && feat_yes DEVEL; then
499 cc_check -Wstrict-overflow=5
502 if feat_yes DEBUG || feat_yes FORCED_STACKPROT; then
503 if [ -z "${force_no_stackprot}" ]; then
504 if cc_check -fstack-protector-strong ||
505 cc_check -fstack-protector-all; then
506 cc_check -D_FORTIFY_SOURCE=2
508 else
509 msg 'Not checking for -fstack-protector compiler option,'
510 msg 'since that caused errors in a "similar" configuration.'
511 msg 'You may turn off OPT_AUTOCC and use your own settings, rerun'
515 # LD (+ dependend CC)
517 if feat_yes ASAN_ADDRESS; then
518 _ccfg=${_CFLAGS}
519 if cc_check -fsanitize=address &&
520 ld_check -fsanitize=address; then
522 else
523 feat_bail_required ASAN_ADDRESS
524 _CFLAGS=${_ccfg}
528 if feat_yes ASAN_MEMORY; then
529 _ccfg=${_CFLAGS}
530 if cc_check -fsanitize=memory &&
531 ld_check -fsanitize=memory &&
532 cc_check -fsanitize-memory-track-origins=2 &&
533 ld_check -fsanitize-memory-track-origins=2; then
535 else
536 feat_bail_required ASAN_MEMORY
537 _CFLAGS=${_ccfg}
541 ld_check -Wl,-z,relro
542 ld_check -Wl,-z,now
543 ld_check -Wl,-z,noexecstack
544 if ld_check -Wl,-rpath =./ no; then
545 need_R_ldflags=-Wl,-rpath=
546 # Choose DT_RUNPATH (after $LD_LIBRARY_PATH) over DT_RPATH (before)
547 ld_check -Wl,--enable-new-dtags
548 ld_runtime_flags # update!
549 elif ld_check -Wl,-R ./ no; then
550 need_R_ldflags=-Wl,-R
551 ld_check -Wl,--enable-new-dtags
552 ld_runtime_flags # update!
555 # Address randomization
556 _ccfg=${_CFLAGS}
557 if cc_check -fPIE || cc_check -fpie; then
558 ld_check -pie || _CFLAGS=${_ccfg}
560 unset _ccfg
562 _CFLAGS="${_CFLAGS} ${__cflags}" _LDFLAGS="${_LDFLAGS} ${__ldflags}"
563 unset __cflags __ldflags
566 ## -- >8 - <<OS/CC | SUPPORT FUNS>> - 8< -- ##
568 ## Notes:
569 ## - Heirloom sh(1) (and same origin) have _sometimes_ problems with ': >'
570 ## redirection, so use "printf '' >" instead
572 ## Very first: we undergo several states regarding I/O redirection etc.,
573 ## but need to deal with option updates from within all. Since all the
574 ## option stuff should be above the scissor line, define utility functions
575 ## and redefine them as necessary.
576 ## And, since we have those functions, simply use them for whatever
578 config_exit() {
579 exit ${1}
582 msg() {
583 fmt=${1}
584 shift
585 printf >&2 -- "${fmt}\\n" "${@}"
588 msg_nonl() {
589 fmt=${1}
590 shift
591 printf >&2 -- "${fmt}" "${@}"
594 t1=ten10one1ten10one1
595 if ( [ ${t1##*ten10} = one1 ] && [ ${t1#*ten10} = one1ten10one1 ] &&
596 [ ${t1%%one1*} = ten10 ] && [ ${t1%one1*} = ten10one1ten10 ]
597 ) > /dev/null 2>&1; then
598 good_shell=1
599 else
600 unset good_shell
602 unset t1
604 # We need some standard utilities
605 unset -f command
606 check_tool() {
607 n=${1} i=${2} opt=${3:-0}
608 # Evaluate, just in case user comes in with shell snippets (..well..)
609 eval i="${i}"
610 if type "${i}" >/dev/null 2>&1; then # XXX why have i type not command -v?
611 [ -n "${VERBOSE}" ] && msg ' . ${%s} ... %s' "${n}" "${i}"
612 eval ${n}=${i}
613 return 0
615 if [ ${opt} -eq 0 ]; then
616 msg 'ERROR: no trace of utility %s' "${n}"
617 config_exit 1
619 return 1
622 # Our feature check environment
623 feat_val_no() {
624 [ "x${1}" = x0 ] || [ "x${1}" = xn ] ||
625 [ "x${1}" = xfalse ] || [ "x${1}" = xno ] || [ "x${1}" = xoff ]
628 feat_val_yes() {
629 [ "x${1}" = x1 ] || [ "x${1}" = xy ] ||
630 [ "x${1}" = xtrue ] || [ "x${1}" = xyes ] || [ "x${1}" = xon ] ||
631 [ "x${1}" = xrequire ]
634 feat_val_require() {
635 [ "x${1}" = xrequire ]
638 _feat_check() {
639 eval i=\$OPT_${1}
640 i="`echo ${i} | ${tr} '[A-Z]' '[a-z]'`"
641 if feat_val_no "${i}"; then
642 return 1
643 elif feat_val_yes "${i}"; then
644 return 0
645 else
646 msg "ERROR: %s: 0/n/false/no/off or 1/y/true/yes/on/require, got: %s" \
647 "${1}" "${i}"
648 config_exit 11
652 feat_yes() {
653 _feat_check ${1}
656 feat_no() {
657 _feat_check ${1} && return 1
658 return 0
661 feat_require() {
662 eval i=\$OPT_${1}
663 i="`echo ${i} | ${tr} '[A-Z]' '[a-z]'`"
664 [ "x${i}" = xrequire ] || [ "x${i}" = xrequired ]
667 feat_bail_required() {
668 if feat_require ${1}; then
669 msg 'ERROR: feature OPT_%s is required but not available' "${1}"
670 config_exit 13
672 eval OPT_${1}=0
673 option_update # XXX this is rather useless here (dependency chain..)
676 option_parse() {
677 # Parse one of our XOPTIONS* in $2 and assign the sh(1) compatible list of
678 # options, without documentation, to $1
679 j=\'
680 i="`${awk} -v input=\"${2}\" '
681 BEGIN{
682 for(i = 0;;){
683 voff = match(input, /[[:alnum:]_]+(='${j}'[^'${j}']+)?/)
684 if(voff == 0)
685 break
686 v = substr(input, voff, RLENGTH)
687 input = substr(input, voff + RLENGTH)
688 doff = index(v, "=")
689 if(doff > 0){
690 d = substr(v, doff + 2, length(v) - doff - 1)
691 v = substr(v, 1, doff - 1)
693 print v
697 eval ${1}=\"${i}\"
700 option_doc_of() {
701 # Return the "documentation string" for option $1, itself if none such
702 j=\'
703 ${awk} -v want="${1}" \
704 -v input="${XOPTIONS_DETECT}${XOPTIONS}${XOPTIONS_XTRA}" '
705 BEGIN{
706 for(;;){
707 voff = match(input, /[[:alnum:]_]+(='${j}'[^'${j}']+)?/)
708 if(voff == 0)
709 break
710 v = substr(input, voff, RLENGTH)
711 input = substr(input, voff + RLENGTH)
712 doff = index(v, "=")
713 if(doff > 0){
714 d = substr(v, doff + 2, length(v) - doff - 1)
715 v = substr(v, 1, doff - 1)
716 }else
717 d = v
718 if(v == want){
719 if(d != "-")
720 print d
721 exit
728 option_join_rc() {
729 # Join the values from make.rc into what currently is defined, not
730 # overwriting yet existing settings
731 ${rm} -f ${tmp}
732 # We want read(1) to perform reverse solidus escaping in order to be able to
733 # use multiline values in make.rc; the resulting sh(1)/sed(1) code was very
734 # slow in VMs (see [fa2e248]), Aharon Robbins suggested the following
735 < ${rc} ${awk} 'BEGIN{line = ""}{
736 gsub(/^[[:space:]]+/, "", $0)
737 gsub(/[[:space:]]+$/, "", $0)
738 if(gsub(/\\$/, "", $0)){
739 line = line $0
740 next
741 }else
742 line = line $0
743 if(index(line, "#") == 1){
744 line = ""
745 }else if(length(line)){
746 print line
747 line = ""
749 }' |
750 while read line; do
751 if [ -n "${good_shell}" ]; then
752 i=${line%%=*}
753 else
754 i=`${awk} -v LINE="${line}" 'BEGIN{
755 gsub(/=.*$/, "", LINE)
756 print LINE
759 if [ "${i}" = "${line}" ]; then
760 msg 'ERROR: invalid syntax in: %s' "${line}"
761 continue
764 eval j="\$${i}" jx="\${${i}+x}"
765 if [ -n "${j}" ] || [ "${jx}" = x ]; then
766 : # Yet present
767 else
768 j=`${awk} -v LINE="${line}" 'BEGIN{
769 gsub(/^[^=]*=/, "", LINE)
770 gsub(/^\"*/, "", LINE)
771 gsub(/\"*$/, "", LINE)
772 print LINE
775 [ "${i}" = "DESTDIR" ] && continue
776 echo "${i}=\"${j}\""
777 done > ${tmp}
778 # Reread the mixed version right now
779 . ./${tmp}
782 option_evaluate() {
783 # Expand the option values, which may contain shell snippets
784 ${rm} -f ${newlst} ${newmk} ${newh}
785 exec 5<&0 6>&1 <${tmp} >${newlst}
786 while read line; do
788 if [ -n "${good_shell}" ]; then
789 i=${line%%=*}
790 [ "${i}" != "${i#OPT_}" ] && z=1
791 else
792 i=`${awk} -v LINE="${line}" 'BEGIN{
793 gsub(/=.*$/, "", LINE);\
794 print LINE
796 if echo "${i}" | ${grep} '^OPT_' >/dev/null 2>&1; then
801 eval j=\$${i}
802 if [ -n "${z}" ]; then
803 j="`echo ${j} | ${tr} '[A-Z]' '[a-z]'`"
804 if [ -z "${j}" ] || feat_val_no "${j}"; then
806 printf " /* #undef ${i} */\n" >> ${newh}
807 elif feat_val_yes "${j}"; then
808 if feat_val_require "${j}"; then
809 j=require
810 else
813 printf " /* #define ${i} */\n" >> ${newh}
814 else
815 msg 'ERROR: cannot parse <%s>' "${line}"
816 config_exit 1
818 else
819 printf "#define ${i} \"${j}\"\n" >> ${newh}
821 printf "${i} = ${j}\n" >> ${newmk}
822 printf "${i}=${j}\n"
823 eval "${i}=\"${j}\""
824 done
825 exec 0<&5 1>&6 5<&- 6<&-
828 path_check() {
829 # "path_check VARNAME" or "path_check VARNAME FLAG VARNAME"
830 varname=${1} addflag=${2} flagvarname=${3}
831 j=${IFS}
832 IFS=:
833 eval "set -- \$${1}"
834 IFS=${j}
835 j= k= y= z=
836 for i
838 [ -z "${i}" ] && continue
839 [ -d "${i}" ] || continue
840 if [ -n "${j}" ]; then
841 if { z=${y}; echo "${z}"; } | ${grep} ":${i}:" >/dev/null 2>&1; then
843 else
844 y="${y} :${i}:"
845 j="${j}:${i}"
846 # But do not link any fakeroot path into our binaries!
847 if [ -n "${addflag}" ]; then
848 case "${i}" in *fakeroot*) continue;; esac
849 k="${k} ${addflag}${i}"
852 else
853 y=" :${i}:"
854 j="${i}"
855 # But do not link any fakeroot path into our binaries!
856 if [ -n "${addflag}" ]; then
857 case "${i}" in *fakeroot*) continue;; esac
858 k="${k} ${addflag}${i}"
861 done
862 eval "${varname}=\"${j}\""
863 [ -n "${addflag}" ] && eval "${flagvarname}=\"${k}\""
864 unset varname
867 ld_runtime_flags() {
868 if [ -n "${need_R_ldflags}" ]; then
869 i=${IFS}
870 IFS=:
871 set -- ${LD_LIBRARY_PATH}
872 IFS=${i}
873 for i
875 # But do not link any fakeroot path into our binaries!
876 case "${i}" in *fakeroot*) continue;; esac
877 LDFLAGS="${LDFLAGS} ${need_R_ldflags}${i}"
878 _LDFLAGS="${_LDFLAGS} ${need_R_ldflags}${i}"
879 done
880 export LDFLAGS
882 # Disable it for a possible second run.
883 need_R_ldflags=
886 cc_check() {
887 [ -n "${cc_check_silent}" ] || msg_nonl ' . CC %s .. ' "${1}"
888 if "${CC}" ${INCS} \
889 ${_CFLAGS} ${1} ${EXTRA_CFLAGS} ${_LDFLAGS} ${EXTRA_LDFLAGS} \
890 -o ${tmp2} ${tmp}.c ${LIBS} >/dev/null 2>&1; then
891 _CFLAGS="${_CFLAGS} ${1}"
892 [ -n "${cc_check_silent}" ] || msg 'yes'
893 return 0
895 [ -n "${cc_check_silent}" ] || msg 'no'
896 return 1
899 ld_check() {
900 # $1=option [$2=option argument] [$3=if set, shall NOT be added to _LDFLAGS]
901 [ -n "${cc_check_silent}" ] || msg_nonl ' . LD %s .. ' "${1}"
902 if "${CC}" ${INCS} ${_CFLAGS} ${_LDFLAGS} ${1}${2} ${EXTRA_LDFLAGS} \
903 -o ${tmp2} ${tmp}.c ${LIBS} >/dev/null 2>&1; then
904 [ -n "${3}" ] || _LDFLAGS="${_LDFLAGS} ${1}"
905 [ -n "${cc_check_silent}" ] || msg 'yes'
906 return 0
908 [ -n "${cc_check_silent}" ] || msg 'no'
909 return 1
912 _check_preface() {
913 variable=$1 topic=$2 define=$3
915 echo '**********'
916 msg_nonl ' . %s ... ' "${topic}"
917 echo "/* checked ${topic} */" >> ${h}
918 ${rm} -f ${tmp} ${tmp}.o
919 echo '*** test program is'
920 { echo '#include <'"${h_name}"'>'; cat; } | ${tee} ${tmp}.c
921 #echo '*** the preprocessor generates'
922 #${make} -f ${makefile} ${tmp}.x
923 #${cat} ${tmp}.x
924 echo '*** results are'
927 without_check() {
928 yesno=$1 variable=$2 topic=$3 define=$4 libs=$5 incs=$6
930 echo '**********'
931 msg_nonl ' . %s ... ' "${topic}"
933 echo '*** enforced unchecked results are'
934 if feat_val_yes ${yesno}; then
935 if [ -n "${incs}" ] || [ -n "${libs}" ]; then
936 echo "*** adding INCS<${incs}> LIBS<${libs}>"
937 LIBS="${LIBS} ${libs}"
938 echo "${libs}" >> ${lib}
939 INCS="${INCS} ${incs}"
940 echo "${incs}" >> ${inc}
942 msg 'yes (deduced)'
943 echo "${define}" >> ${h}
944 eval have_${variable}=yes
945 return 0
946 else
947 echo "/* ${define} */" >> ${h}
948 msg 'no (deduced)'
949 eval unset have_${variable}
950 return 1
954 compile_check() {
955 variable=$1 topic=$2 define=$3
957 _check_preface "${variable}" "${topic}" "${define}"
959 if ${make} -f ${makefile} XINCS="${INCS}" \
960 CFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS}" \
961 ./${tmp}.o &&
962 [ -f ./${tmp}.o ]; then
963 msg 'yes'
964 echo "${define}" >> ${h}
965 eval have_${variable}=yes
966 return 0
967 else
968 echo "/* ${define} */" >> ${h}
969 msg 'no'
970 eval unset have_${variable}
971 return 1
975 _link_mayrun() {
976 run=$1 variable=$2 topic=$3 define=$4 libs=$5 incs=$6
978 _check_preface "${variable}" "${topic}" "${define}"
980 if feat_yes CROSS_BUILD; then
981 if [ ${run} = 1 ]; then
982 run=0
986 if ${make} -f ${makefile} XINCS="${INCS} ${incs}" \
987 CFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS}" \
988 XLIBS="${LIBS} ${libs}" \
989 ./${tmp} &&
990 [ -f ./${tmp} ] &&
991 { [ ${run} -eq 0 ] || ./${tmp}; }; then
992 echo "*** adding INCS<${incs}> LIBS<${libs}>; executed: ${run}"
993 msg 'yes'
994 echo "${define}" >> ${h}
995 LIBS="${LIBS} ${libs}"
996 echo "${libs}" >> ${lib}
997 INCS="${INCS} ${incs}"
998 echo "${incs}" >> ${inc}
999 eval have_${variable}=yes
1000 return 0
1001 else
1002 msg 'no'
1003 echo "/* ${define} */" >> ${h}
1004 eval unset have_${variable}
1005 return 1
1009 link_check() {
1010 _link_mayrun 0 "${1}" "${2}" "${3}" "${4}" "${5}"
1013 run_check() {
1014 _link_mayrun 1 "${1}" "${2}" "${3}" "${4}" "${5}"
1017 xrun_check() {
1018 _link_mayrun 2 "${1}" "${2}" "${3}" "${4}" "${5}"
1021 feat_def() {
1022 if feat_yes ${1}; then
1023 echo '#define HAVE_'${1}'' >> ${h}
1024 return 0
1025 else
1026 echo '/* OPT_'${1}'=0 */' >> ${h}
1027 return 1
1031 squeeze_em() {
1032 < "${1}" > "${2}" ${awk} \
1033 'BEGIN {ORS = " "} /^[^#]/ {print} {next} END {ORS = ""; print "\n"}'
1036 ## -- >8 - <<SUPPORT FUNS | RUNNING>> - 8< -- ##
1038 # First of all, create new configuration and check whether it changed
1040 # Very easy checks for the operating system in order to be able to adjust paths
1041 # or similar very basic things which we need to be able to go at all
1042 os_early_setup
1044 # Check those tools right now that we need before including $rc
1045 msg 'Checking for basic utility set'
1046 check_tool awk "${awk:-`command -v awk`}"
1047 check_tool rm "${rm:-`command -v rm`}"
1048 check_tool tr "${tr:-`command -v tr`}"
1050 # Initialize the option set
1051 msg_nonl 'Setting up configuration options ... '
1052 option_setup
1053 msg 'done'
1055 # Include $rc, but only take from it what wasn't overwritten by the user from
1056 # within the command line or from a chosen fixed CONFIG=
1057 # Note we leave alone the values
1058 trap "exit 1" HUP INT TERM
1059 trap "${rm} -f ${tmp}" EXIT
1061 msg_nonl 'Joining in %s ... ' ${rc}
1062 option_join_rc
1063 msg 'done'
1065 # We need to know about that now, in order to provide utility overwrites etc.
1066 os_setup
1068 msg 'Checking for remaining set of utilities'
1069 check_tool grep "${grep:-`command -v grep`}"
1071 # Before we step ahead with the other utilities perform a path cleanup first.
1072 path_check PATH
1074 # awk(1) above
1075 check_tool basename "${basename:-`command -v basename`}"
1076 check_tool cat "${cat:-`command -v cat`}"
1077 check_tool chmod "${chmod:-`command -v chmod`}"
1078 check_tool cp "${cp:-`command -v cp`}"
1079 check_tool cmp "${cmp:-`command -v cmp`}"
1080 # grep(1) above
1081 check_tool mkdir "${mkdir:-`command -v mkdir`}"
1082 check_tool mv "${mv:-`command -v mv`}"
1083 # rm(1) above
1084 check_tool sed "${sed:-`command -v sed`}"
1085 check_tool sort "${sort:-`command -v sort`}"
1086 check_tool tee "${tee:-`command -v tee`}"
1088 check_tool chown "${chown:-`command -v chown`}" 1 ||
1089 check_tool chown "/sbin/chown" 1 ||
1090 check_tool chown "/usr/sbin/chown"
1092 check_tool make "${MAKE:-`command -v make`}"
1093 MAKE=${make}
1094 check_tool strip "${STRIP:-`command -v strip`}" 1 &&
1095 HAVE_STRIP=1 || HAVE_STRIP=0
1097 # For ./cc-test.sh only
1098 check_tool cksum "${cksum:-`command -v cksum`}"
1100 # Update OPT_ options now, in order to get possible inter-dependencies right
1101 option_update
1103 # (No functions since some shells loose non-exported variables in traps)
1104 trap "trap \"\" HUP INT TERM; exit 1" HUP INT TERM
1105 trap "trap \"\" HUP INT TERM EXIT;\
1106 ${rm} -rf ${newlst} ${tmp0}.* ${tmp0}* ${newmk} ${newev} ${newh}" EXIT
1108 # Our configuration options may at this point still contain shell snippets,
1109 # we need to evaluate them in order to get them expanded, and we need those
1110 # evaluated values not only in our new configuration file, but also at hand..
1111 msg_nonl 'Evaluating all configuration items ... '
1112 option_evaluate
1113 msg 'done'
1115 # Add the known utility and some other variables
1116 printf "#define VAL_UAGENT \"${VAL_SID}${VAL_MAILX}\"\n" >> ${newh}
1117 printf "VAL_UAGENT = ${VAL_SID}${VAL_MAILX}\n" >> ${newmk}
1119 printf "#define VAL_PRIVSEP \"${VAL_SID}${VAL_MAILX}-privsep\"\n" >> ${newh}
1120 printf "VAL_PRIVSEP = \$(VAL_UAGENT)-privsep\n" >> ${newmk}
1121 if feat_yes DOTLOCK; then
1122 printf "OPTIONAL_PRIVSEP = \$(VAL_PRIVSEP)\n" >> ${newmk}
1123 else
1124 printf "OPTIONAL_PRIVSEP =\n" >> ${newmk}
1127 for i in \
1128 SRCDIR \
1129 awk basename cat chmod chown cp cmp grep mkdir mv rm sed sort tee tr \
1130 MAKE MAKEFLAGS make SHELL strip \
1131 cksum; do
1132 eval j=\$${i}
1133 printf "${i} = ${j}\n" >> ${newmk}
1134 printf "${i}=${j}\n" >> ${newlst}
1135 printf "${i}=\"${j}\";export ${i}; " >> ${newev}
1136 done
1137 printf "\n" >> ${newev}
1139 # Build a basic set of INCS and LIBS according to user environment.
1140 C_INCLUDE_PATH="./:${SRCDIR}:${C_INCLUDE_PATH}"
1141 path_check C_INCLUDE_PATH -I _INCS
1142 INCS="${INCS} ${_INCS}"
1143 path_check LD_LIBRARY_PATH -L _LIBS
1144 LIBS="${LIBS} ${_LIBS}"
1145 unset _INCS _LIBS
1146 export C_INCLUDE_PATH LD_LIBRARY_PATH
1148 # Some environments need runtime path flags to be able to go at all
1149 ld_runtime_flags
1151 ## Detect CC, whether we can use it, and possibly which CFLAGS we can use
1153 cc_setup
1155 ${cat} > ${tmp}.c << \!
1156 #include <stdio.h>
1157 #include <string.h>
1158 static void doit(char const *s);
1160 main(int argc, char **argv){
1161 (void)argc;
1162 (void)argv;
1163 doit("Hello world");
1164 return 0;
1166 static void
1167 doit(char const *s){
1168 char buf[12];
1169 memcpy(buf, s, strlen(s) +1);
1170 puts(s);
1174 if "${CC}" ${INCS} ${CFLAGS} ${EXTRA_CFLAGS} ${LDFLAGS} ${EXTRA_LDFLAGS} \
1175 -o ${tmp2} ${tmp}.c ${LIBS}; then
1177 else
1178 msg 'ERROR: i cannot compile a "Hello world" via'
1179 msg ' %s' \
1180 "${CC} ${INCS} ${CFLAGS} ${EXTRA_CFLAGS} ${LDFLAGS} ${EXTRA_LDFLAGS} ${LIBS}"
1181 msg 'ERROR: Please read INSTALL, rerun'
1182 config_exit 1
1185 # This may also update ld_runtime_flags() (again)
1186 cc_flags
1188 for i in \
1189 INCS LIBS \
1190 ; do
1191 eval j=\$${i}
1192 printf -- "${i}=${j}\n" >> ${newlst}
1193 done
1194 for i in \
1195 CC \
1196 CFLAGS \
1197 LDFLAGS \
1198 PATH C_INCLUDE_PATH LD_LIBRARY_PATH \
1199 OSFULLSPEC \
1200 ; do
1201 eval j=\$${i}
1202 printf -- "${i} = ${j}\n" >> ${newmk}
1203 printf -- "${i}=${j}\n" >> ${newlst}
1204 done
1206 # Now finally check whether we already have a configuration and if so, whether
1207 # all those parameters are still the same.. or something has actually changed
1208 if [ -f ${lst} ] && ${cmp} ${newlst} ${lst} >/dev/null 2>&1; then
1209 echo 'Configuration is up-to-date'
1210 exit 0
1211 elif [ -f ${lst} ]; then
1212 echo 'Configuration has been updated..'
1213 ( eval "${MAKE} -f ./mk-config.mk clean" )
1214 echo
1215 else
1216 echo 'Shiny configuration..'
1219 # Time to redefine helper 1
1220 config_exit() {
1221 ${rm} -f ${lst} ${h} ${mk}
1222 exit ${1}
1225 ${mv} -f ${newlst} ${lst}
1226 ${mv} -f ${newev} ${ev}
1227 ${mv} -f ${newh} ${h}
1228 ${mv} -f ${newmk} ${mk}
1230 if [ -z "${VERBOSE}" ]; then
1231 printf -- "ECHO_CC = @echo ' 'CC \$(@);\n" >> ${mk}
1232 printf -- "ECHO_LINK = @echo ' 'LINK \$(@);\n" >> ${mk}
1233 printf -- "ECHO_GEN = @echo ' 'GEN \$(@);\n" >> ${mk}
1234 printf -- "ECHO_TEST = @\n" >> ${mk}
1235 printf -- "ECHO_CMD = @echo ' CMD';\n" >> ${mk}
1236 printf -- "ECHO_BLOCK_BEGIN = @( \n" >> ${mk}
1237 printf -- "ECHO_BLOCK_END = ) >/dev/null\n" >> ${mk}
1240 ## Compile and link checking
1242 tmp3=./${tmp0}3$$
1243 log=./mk-config.log
1244 lib=./mk-config.lib
1245 inc=./mk-config.inc
1246 makefile=./${tmp0}.mk
1248 # (No function since some shells loose non-exported variables in traps)
1249 trap "trap \"\" HUP INT TERM;\
1250 ${rm} -f ${lst} ${h} ${mk} ${lib} ${inc}; exit 1" HUP INT TERM
1251 trap "trap \"\" HUP INT TERM EXIT;\
1252 ${rm} -rf ${tmp0}.* ${tmp0}*" EXIT
1254 # Time to redefine helper 2
1255 msg() {
1256 fmt=${1}
1257 shift
1258 printf "*** ${fmt}\\n" "${@}"
1259 printf -- "${fmt}\\n" "${@}" >&5
1261 msg_nonl() {
1262 fmt=${1}
1263 shift
1264 printf "*** ${fmt}\\n" "${@}"
1265 printf -- "${fmt}" "${@}" >&5
1268 # !!
1269 exec 5>&2 > ${log} 2>&1
1271 echo "${LIBS}" > ${lib}
1272 echo "${INCS}" > ${inc}
1273 ${cat} > ${makefile} << \!
1274 .SUFFIXES: .o .c .x .y
1275 .c.o:
1276 $(CC) -I./ $(XINCS) $(CFLAGS) -c $(<)
1277 .c.x:
1278 $(CC) -I./ $(XINCS) -E $(<) > $(@)
1280 $(CC) -I./ $(XINCS) $(CFLAGS) $(LDFLAGS) -o $(@) $(<) $(XLIBS)
1283 ## Generics
1285 # May be multiline..
1286 echo >> ${h}
1287 [ -n "${OS_DEFINES}" ] && printf -- "${OS_DEFINES}" >> ${h}
1288 echo '#define VAL_BUILD_OS "'"${OS}"'"' >> ${h}
1289 echo '#define VAL_BUILD_OSENV "'"${OSENV}"'"' >> ${h}
1291 # Generate n_err_number OS mappings
1293 feat_yes DEVEL && NV= || NV=noverbose
1294 SRCDIR="${SRCDIR}" TARGET="${h}" awk="${awk}" \
1295 ${SHELL} "${SRCDIR}"make-errors.sh ${NV} config
1297 xrun_check oserrno 'OS error mapping table generated' || config_exit 1
1299 feat_def ALWAYS_UNICODE_LOCALE
1300 feat_def AMALGAMATION
1301 feat_def CROSS_BUILD
1302 feat_def DOCSTRINGS
1303 feat_def ERRORS
1305 feat_def ASAN_ADDRESS
1306 feat_def ASAN_MEMORY
1307 feat_def DEBUG
1308 feat_def DEVEL
1309 feat_def NYD2
1310 feat_def NOMEMDBG
1312 if xrun_check inline 'inline functions' \
1313 '#define HAVE_INLINE
1314 #define n_INLINE static inline' << \!
1315 static inline int ilf(int i){return ++i;}
1316 int main(void){return ilf(-1);}
1318 then
1320 elif xrun_check inline 'inline functions (via __inline)' \
1321 '#define HAVE_INLINE
1322 #define n_INLINE static __inline' << \!
1323 static __inline int ilf(int i){return ++i;}
1324 int main(void){return ilf(-1);}
1326 then
1330 ## Test for "basic" system-calls / functionality that is used by all parts
1331 ## of our program. Once this is done fork away BASE_LIBS and other BASE_*
1332 ## macros to be used by only the subprograms (potentially).
1334 if run_check clock_gettime 'clock_gettime(2)' \
1335 '#define HAVE_CLOCK_GETTIME' << \!
1336 #include <time.h>
1337 # include <errno.h>
1338 int main(void){
1339 struct timespec ts;
1341 if(!clock_gettime(CLOCK_REALTIME, &ts) || errno != ENOSYS)
1342 return 0;
1343 return 1;
1346 then
1348 elif run_check clock_gettime 'clock_gettime(2) (via -lrt)' \
1349 '#define HAVE_CLOCK_GETTIME' '-lrt' << \!
1350 #include <time.h>
1351 # include <errno.h>
1352 int main(void){
1353 struct timespec ts;
1355 if(!clock_gettime(CLOCK_REALTIME, &ts) || errno != ENOSYS)
1356 return 0;
1357 return 1;
1360 then
1362 elif run_check gettimeofday 'gettimeofday(2)' \
1363 '#define HAVE_GETTIMEOFDAY' << \!
1364 #include <stdio.h> /* For C89 NULL */
1365 #include <sys/time.h>
1366 # include <errno.h>
1367 int main(void){
1368 struct timeval tv;
1370 if(!gettimeofday(&tv, NULL) || errno != ENOSYS)
1371 return 0;
1372 return 1;
1375 then
1377 else
1378 have_no_subsecond_time=1
1381 if run_check nanosleep 'nanosleep(2)' \
1382 '#define HAVE_NANOSLEEP' << \!
1383 #include <time.h>
1384 # include <errno.h>
1385 int main(void){
1386 struct timespec ts;
1388 ts.tv_sec = 1;
1389 ts.tv_nsec = 100000;
1390 if(!nanosleep(&ts, NULL) || errno != ENOSYS)
1391 return 0;
1392 return 1;
1395 then
1397 elif run_check nanosleep 'nanosleep(2) (via -lrt)' \
1398 '#define HAVE_NANOSLEEP' '-lrt' << \!
1399 #include <time.h>
1400 # include <errno.h>
1401 int main(void){
1402 struct timespec ts;
1404 ts.tv_sec = 1;
1405 ts.tv_nsec = 100000;
1406 if(!nanosleep(&ts, NULL) || errno != ENOSYS)
1407 return 0;
1408 return 1;
1411 then
1413 # link_check is enough for this, that function is so old, trust the proto
1414 elif link_check sleep 'sleep(3)' \
1415 '#define HAVE_SLEEP' << \!
1416 #include <unistd.h>
1417 # include <errno.h>
1418 int main(void){
1419 if(!sleep(1) || errno != ENOSYS)
1420 return 0;
1421 return 1;
1424 then
1426 else
1427 msg 'ERROR: we require one of nanosleep(2) and sleep(3).'
1428 config_exit 1
1431 if run_check userdb 'gete?[gu]id(2), getpwuid(3), getpwnam(3)' << \!
1432 #include <pwd.h>
1433 #include <unistd.h>
1434 # include <errno.h>
1435 int main(void){
1436 struct passwd *pw;
1437 gid_t gid;
1438 uid_t uid;
1440 if((gid = getgid()) != 0)
1441 gid = getegid();
1442 if((uid = getuid()) != 0)
1443 uid = geteuid();
1444 if((pw = getpwuid(uid)) == NULL && errno == ENOSYS)
1445 return 1;
1446 if((pw = getpwnam("root")) == NULL && errno == ENOSYS)
1447 return 1;
1448 return 0;
1451 then
1453 else
1454 msg 'ERROR: we require user and group info / database searches.'
1455 msg 'That much Unix we indulge ourselfs.'
1456 config_exit 1
1459 if link_check ftruncate 'ftruncate(2)' \
1460 '#define HAVE_FTRUNCATE' << \!
1461 #include <unistd.h>
1462 #include <sys/types.h>
1463 int main(void){
1464 return (ftruncate(0, 0) != 0);
1467 then
1469 else
1470 msg 'ERROR: we require the ftruncate(2) system call.'
1471 config_exit 1
1474 if run_check sa_restart 'SA_RESTART (for sigaction(2))' << \!
1475 #include <signal.h>
1476 # include <errno.h>
1477 int main(void){
1478 struct sigaction nact, oact;
1480 nact.sa_handler = SIG_DFL;
1481 sigemptyset(&nact.sa_mask);
1482 nact.sa_flags = SA_RESTART;
1483 return !(!sigaction(SIGCHLD, &nact, &oact) || errno != ENOSYS);
1486 then
1488 else
1489 msg 'ERROR: we (yet) require the SA_RESTART flag for sigaction(2).'
1490 config_exit 1
1493 if link_check snprintf 'snprintf(3)' << \!
1494 #include <stdio.h>
1495 int main(void){
1496 char b[20];
1498 snprintf(b, sizeof b, "%s", "string");
1499 return 0;
1502 then
1504 else
1505 msg 'ERROR: we require the snprintf(3) function.'
1506 config_exit 1
1509 if link_check environ 'environ(3)' << \!
1510 #include <stdio.h> /* For C89 NULL */
1511 int main(void){
1512 extern char **environ;
1514 return environ[0] == NULL;
1517 then
1519 else
1520 msg 'ERROR: we require the environ(3) array for subprocess control.'
1521 config_exit 1
1524 if link_check setenv '(un)?setenv(3)' '#define HAVE_SETENV' << \!
1525 #include <stdlib.h>
1526 int main(void){
1527 setenv("s-mailx", "i want to see it cute!", 1);
1528 unsetenv("s-mailx");
1529 return 0;
1532 then
1534 elif link_check setenv 'putenv(3)' '#define HAVE_PUTENV' << \!
1535 #include <stdlib.h>
1536 int main(void){
1537 putenv("s-mailx=i want to see it cute!");
1538 return 0;
1541 then
1543 else
1544 msg 'ERROR: we require either the setenv(3) or putenv(3) functions.'
1545 config_exit 1
1548 if link_check termios 'termios.h and tc*(3) family' << \!
1549 #include <termios.h>
1550 int main(void){
1551 struct termios tios;
1553 tcgetattr(0, &tios);
1554 tcsetattr(0, TCSANOW | TCSADRAIN | TCSAFLUSH, &tios);
1555 return 0;
1558 then
1560 else
1561 msg 'ERROR: we require termios.h and the tc*() family of functions.'
1562 msg 'That much Unix we indulge ourselfs.'
1563 config_exit 1
1566 ## optional stuff
1568 if link_check vsnprintf 'vsnprintf(3)' << \!
1569 #include <stdarg.h>
1570 #include <stdio.h>
1571 static void dome(char *buf, size_t blen, ...){
1572 va_list ap;
1574 va_start(ap, blen);
1575 vsnprintf(buf, blen, "%s", ap);
1576 va_end(ap);
1578 int main(void){
1579 char b[20];
1581 dome(b, sizeof b, "string");
1582 return 0;
1585 then
1587 else
1588 feat_bail_required ERRORS
1591 if [ "${have_vsnprintf}" = yes ]; then
1592 __va_copy() {
1593 link_check va_copy "va_copy(3) (as ${2})" \
1594 "#define HAVE_N_VA_COPY
1595 #define n_va_copy ${2}" <<_EOT
1596 #include <stdarg.h>
1597 #include <stdio.h>
1598 #if ${1}
1599 # if defined __va_copy && !defined va_copy
1600 # define va_copy __va_copy
1601 # endif
1602 #endif
1603 static void dome2(char *buf, size_t blen, va_list src){
1604 va_list ap;
1606 va_copy(ap, src);
1607 vsnprintf(buf, blen, "%s", ap);
1608 va_end(ap);
1610 static void dome(char *buf, size_t blen, ...){
1611 va_list ap;
1613 va_start(ap, blen);
1614 dome2(buf, blen, ap);
1615 va_end(ap);
1617 int main(void){
1618 char b[20];
1620 dome(b, sizeof b, "string");
1621 return 0;
1623 _EOT
1625 __va_copy 0 va_copy || __va_copy 1 __va_copy
1628 run_check pathconf 'f?pathconf(2)' '#define HAVE_PATHCONF' << \!
1629 #include <unistd.h>
1630 #include <errno.h>
1631 int main(void){
1632 int rv = 0;
1634 errno = 0;
1635 rv |= !(pathconf(".", _PC_NAME_MAX) >= 0 || errno == 0 || errno != ENOSYS);
1636 errno = 0;
1637 rv |= !(pathconf(".", _PC_PATH_MAX) >= 0 || errno == 0 || errno != ENOSYS);
1639 /* Only link check */
1640 fpathconf(0, _PC_NAME_MAX);
1642 return rv;
1646 run_check pipe2 'pipe2(2)' '#define HAVE_PIPE2' << \!
1647 #include <fcntl.h>
1648 #include <unistd.h>
1649 # include <errno.h>
1650 int main(void){
1651 int fds[2];
1653 if(!pipe2(fds, O_CLOEXEC) || errno != ENOSYS)
1654 return 0;
1655 return 1;
1659 # We use this only then for now (need NOW+1)
1660 run_check utimensat 'utimensat(2)' '#define HAVE_UTIMENSAT' << \!
1661 #include <fcntl.h> /* For AT_* */
1662 #include <sys/stat.h>
1663 # include <errno.h>
1664 int main(void){
1665 struct timespec ts[2];
1667 ts[0].tv_nsec = UTIME_NOW;
1668 ts[1].tv_nsec = UTIME_OMIT;
1669 if(!utimensat(AT_FDCWD, "", ts, 0) || errno != ENOSYS)
1670 return 0;
1671 return 1;
1677 # XXX Add POSIX check once standardized
1678 if link_check posix_random 'arc4random(3)' '#define HAVE_POSIX_RANDOM 0' << \!
1679 #include <stdlib.h>
1680 int main(void){
1681 arc4random();
1682 return 0;
1685 then
1687 elif link_check getrandom 'getrandom(2) (in sys/random.h)' \
1688 '#define HAVE_GETRANDOM(B,S) getrandom(B, S, 0)
1689 #define HAVE_GETRANDOM_HEADER <sys/random.h>' <<\!
1690 #include <sys/random.h>
1691 int main(void){
1692 char buf[256];
1693 getrandom(buf, sizeof buf, 0);
1694 return 0;
1697 then
1699 elif link_check getrandom 'getrandom(2) (via syscall(2))' \
1700 '#define HAVE_GETRANDOM(B,S) syscall(SYS_getrandom, B, S, 0)
1701 #define HAVE_GETRANDOM_HEADER <sys/syscall.h>' <<\!
1702 #include <sys/syscall.h>
1703 int main(void){
1704 char buf[256];
1705 syscall(SYS_getrandom, buf, sizeof buf, 0);
1706 return 0;
1709 then
1711 elif [ -n "${have_no_subsecond_time}" ]; then
1712 msg 'ERROR: %s %s' 'without a native random' \
1713 'one of clock_gettime(2) and gettimeofday(2) is required.'
1714 config_exit 1
1718 link_check putc_unlocked 'putc_unlocked(3)' '#define HAVE_PUTC_UNLOCKED' <<\!
1719 #include <stdio.h>
1720 int main(void){
1721 putc_unlocked('@', stdout);
1722 return 0;
1726 link_check fchdir 'fchdir(3)' '#define HAVE_FCHDIR' << \!
1727 #include <unistd.h>
1728 int main(void){
1729 fchdir(0);
1730 return 0;
1734 if run_check realpath 'realpath(3)' '#define HAVE_REALPATH' << \!
1735 #include <stdlib.h>
1736 int main(void){
1737 char x_buf[4096], *x = realpath(".", x_buf);
1739 return (x != NULL) ? 0 : 1;
1742 then
1743 if run_check realpath_malloc 'realpath(3) takes NULL' \
1744 '#define HAVE_REALPATH_NULL' << \!
1745 #include <stdlib.h>
1746 int main(void){
1747 char *x = realpath(".", NULL);
1749 if(x != NULL)
1750 free(x);
1751 return (x != NULL) ? 0 : 1;
1754 then
1759 ## optional and selectable
1761 if feat_yes DOTLOCK; then
1762 if run_check readlink 'readlink(2)' << \!
1763 #include <unistd.h>
1764 # include <errno.h>
1765 int main(void){
1766 char buf[128];
1768 if(!readlink("here", buf, sizeof buf) || errno != ENOSYS)
1769 return 0;
1770 return 1;
1773 then
1775 else
1776 feat_bail_required DOTLOCK
1780 if feat_yes DOTLOCK; then
1781 if run_check fchown 'fchown(2)' << \!
1782 #include <unistd.h>
1783 # include <errno.h>
1784 int main(void){
1785 if(!fchown(0, 0, 0) || errno != ENOSYS)
1786 return 0;
1787 return 1;
1790 then
1792 else
1793 feat_bail_required DOTLOCK
1797 ## Now it is the time to fork away the BASE_ series
1799 ${rm} -f ${tmp}
1800 squeeze_em ${inc} ${tmp}
1801 ${mv} ${tmp} ${inc}
1802 squeeze_em ${lib} ${tmp}
1803 ${mv} ${tmp} ${lib}
1805 echo "BASE_LIBS = `${cat} ${lib}`" >> ${mk}
1806 echo "BASE_INCS = `${cat} ${inc}`" >> ${mk}
1808 ## The remains are expected to be used only by the main MUA binary!
1810 OPT_LOCALES=0
1811 link_check setlocale 'setlocale(3)' '#define HAVE_SETLOCALE' << \!
1812 #include <locale.h>
1813 int main(void){
1814 setlocale(LC_ALL, "");
1815 return 0;
1818 [ -n "${have_setlocale}" ] && OPT_LOCALES=1
1820 OPT_MULTIBYTE_CHARSETS=0
1821 OPT_WIDE_GLYPHS=0
1822 OPT_TERMINAL_CHARSET=0
1823 if [ -n "${have_setlocale}" ]; then
1824 link_check c90amend1 'ISO/IEC 9899:1990/Amendment 1:1995' \
1825 '#define HAVE_C90AMEND1' << \!
1826 #include <limits.h>
1827 #include <stdlib.h>
1828 #include <wchar.h>
1829 #include <wctype.h>
1830 int main(void){
1831 char mbb[MB_LEN_MAX + 1];
1832 wchar_t wc;
1834 iswprint(L'c');
1835 towupper(L'c');
1836 mbtowc(&wc, "x", 1);
1837 mbrtowc(&wc, "x", 1, NULL);
1838 wctomb(mbb, wc);
1839 return (mblen("\0", 1) == 0);
1842 [ -n "${have_c90amend1}" ] && OPT_MULTIBYTE_CHARSETS=1
1844 if [ -n "${have_c90amend1}" ]; then
1845 link_check wcwidth 'wcwidth(3)' '#define HAVE_WCWIDTH' << \!
1846 #include <wchar.h>
1847 int main(void){
1848 wcwidth(L'c');
1849 return 0;
1852 [ -n "${have_wcwidth}" ] && OPT_WIDE_GLYPHS=1
1855 link_check nl_langinfo 'nl_langinfo(3)' '#define HAVE_NL_LANGINFO' << \!
1856 #include <langinfo.h>
1857 #include <stdlib.h>
1858 int main(void){
1859 nl_langinfo(DAY_1);
1860 return (nl_langinfo(CODESET) == NULL);
1863 [ -n "${have_nl_langinfo}" ] && OPT_TERMINAL_CHARSET=1
1864 fi # have_setlocale
1866 link_check fnmatch 'fnmatch(3)' '#define HAVE_FNMATCH' << \!
1867 #include <fnmatch.h>
1868 int main(void){
1869 return (fnmatch("*", ".", FNM_PATHNAME | FNM_PERIOD) == FNM_NOMATCH);
1873 link_check dirent_d_type 'struct dirent.d_type' '#define HAVE_DIRENT_TYPE' << \!
1874 #include <dirent.h>
1875 int main(void){
1876 struct dirent de;
1877 return !(de.d_type == DT_UNKNOWN ||
1878 de.d_type == DT_DIR || de.d_type == DT_LNK);
1882 ## optional and selectable
1884 if feat_yes ICONV; then
1885 ${cat} > ${tmp2}.c << \!
1886 #include <stdio.h> /* For C89 NULL */
1887 #include <iconv.h>
1888 int main(void){
1889 iconv_t id;
1891 id = iconv_open("foo", "bar");
1892 iconv(id, NULL, NULL, NULL, NULL);
1893 iconv_close(id);
1894 return 0;
1897 < ${tmp2}.c link_check iconv 'iconv(3) functionality' \
1898 '#define HAVE_ICONV' ||
1899 < ${tmp2}.c link_check iconv 'iconv(3) functionality (via -liconv)' \
1900 '#define HAVE_ICONV' '-liconv' ||
1901 feat_bail_required ICONV
1902 else
1903 echo '/* OPT_ICONV=0 */' >> ${h}
1904 fi # feat_yes ICONV
1906 if feat_yes SOCKETS || feat_yes SPAM_SPAMD; then
1907 ${cat} > ${tmp2}.c << \!
1908 #include <sys/types.h>
1909 #include <sys/socket.h>
1910 #include <sys/un.h>
1911 # include <errno.h>
1912 int main(void){
1913 struct sockaddr_un soun;
1915 if(socket(AF_UNIX, SOCK_STREAM, 0) == -1 && errno == ENOSYS)
1916 return 1;
1917 if(connect(0, (struct sockaddr*)&soun, 0) == -1 && errno == ENOSYS)
1918 return 1;
1919 if(shutdown(0, SHUT_RD | SHUT_WR | SHUT_RDWR) == -1 && errno == ENOSYS)
1920 return 1;
1921 return 0;
1925 < ${tmp2}.c run_check af_unix 'AF_UNIX sockets' \
1926 '#define HAVE_UNIX_SOCKETS' ||
1927 < ${tmp2}.c run_check af_unix 'AF_UNIX sockets (via -lnsl)' \
1928 '#define HAVE_UNIX_SOCKETS' '-lnsl' ||
1929 < ${tmp2}.c run_check af_unix 'AF_UNIX sockets (via -lsocket -lnsl)' \
1930 '#define HAVE_UNIX_SOCKETS' '-lsocket -lnsl'
1933 if feat_yes SOCKETS; then
1934 ${cat} > ${tmp2}.c << \!
1935 #include <sys/types.h>
1936 #include <sys/socket.h>
1937 #include <netinet/in.h>
1938 # include <errno.h>
1939 int main(void){
1940 struct sockaddr s;
1942 if(socket(AF_INET, SOCK_STREAM, 0) == -1 && errno == ENOSYS)
1943 return 1;
1944 if(connect(0, &s, 0) == -1 && errno == ENOSYS)
1945 return 1;
1946 return 0;
1950 < ${tmp2}.c run_check sockets 'sockets' \
1951 '#define HAVE_SOCKETS' ||
1952 < ${tmp2}.c run_check sockets 'sockets (via -lnsl)' \
1953 '#define HAVE_SOCKETS' '-lnsl' ||
1954 < ${tmp2}.c run_check sockets 'sockets (via -lsocket -lnsl)' \
1955 '#define HAVE_SOCKETS' '-lsocket -lnsl' ||
1956 feat_bail_required SOCKETS
1957 else
1958 echo '/* OPT_SOCKETS=0 */' >> ${h}
1959 fi # feat_yes SOCKETS
1961 if feat_yes SOCKETS; then
1962 link_check getaddrinfo 'getaddrinfo(3)' \
1963 '#define HAVE_GETADDRINFO' << \!
1964 #include <sys/types.h>
1965 #include <sys/socket.h>
1966 #include <stdio.h>
1967 #include <netdb.h>
1968 int main(void){
1969 struct addrinfo a, *ap;
1970 int lrv;
1972 switch((lrv = getaddrinfo("foo", "0", &a, &ap))){
1973 case EAI_NONAME:
1974 case EAI_SERVICE:
1975 default:
1976 fprintf(stderr, "%s\n", gai_strerror(lrv));
1977 case 0:
1978 break;
1980 return 0;
1985 if feat_yes SOCKETS && [ -z "${have_getaddrinfo}" ]; then
1986 compile_check arpa_inet_h '<arpa/inet.h>' \
1987 '#define HAVE_ARPA_INET_H' << \!
1988 #include <sys/types.h>
1989 #include <sys/socket.h>
1990 #include <netdb.h>
1991 #include <netinet/in.h>
1992 #include <arpa/inet.h>
1995 ${cat} > ${tmp2}.c << \!
1996 #include <sys/types.h>
1997 #include <sys/socket.h>
1998 #include <stdio.h>
1999 #include <string.h>
2000 #include <netdb.h>
2001 #include <netinet/in.h>
2002 #ifdef HAVE_ARPA_INET_H
2003 #include <arpa/inet.h>
2004 #endif
2005 int main(void){
2006 struct sockaddr_in servaddr;
2007 unsigned short portno;
2008 struct servent *ep;
2009 struct hostent *hp;
2010 struct in_addr **pptr;
2012 portno = 0;
2013 if((ep = getservbyname("POPPY-PORT", "tcp")) != NULL)
2014 portno = (unsigned short)ep->s_port;
2016 if((hp = gethostbyname("POPPY-HOST")) != NULL){
2017 pptr = (struct in_addr**)hp->h_addr_list;
2018 if(hp->h_addrtype != AF_INET)
2019 fprintf(stderr, "au\n");
2020 }else{
2021 switch(h_errno){
2022 case HOST_NOT_FOUND:
2023 case TRY_AGAIN:
2024 case NO_RECOVERY:
2025 case NO_DATA:
2026 break;
2027 default:
2028 fprintf(stderr, "au\n");
2029 break;
2033 memset(&servaddr, 0, sizeof servaddr);
2034 servaddr.sin_family = AF_INET;
2035 servaddr.sin_port = htons(portno);
2036 memcpy(&servaddr.sin_addr, *pptr, sizeof(struct in_addr));
2037 fprintf(stderr, "Would connect to %s:%d ...\n",
2038 inet_ntoa(**pptr), (int)portno);
2039 return 0;
2043 < ${tmp2}.c link_check gethostbyname 'get(serv|host)byname(3)' ||
2044 < ${tmp2}.c link_check gethostbyname \
2045 'get(serv|host)byname(3) (via -nsl)' '' '-lnsl' ||
2046 < ${tmp2}.c link_check gethostbyname \
2047 'get(serv|host)byname(3) (via -lsocket -nsl)' \
2048 '' '-lsocket -lnsl' ||
2049 feat_bail_required SOCKETS
2052 feat_yes SOCKETS &&
2053 run_check setsockopt 'setsockopt(2)' '#define HAVE_SETSOCKOPT' << \!
2054 #include <sys/socket.h>
2055 #include <stdlib.h>
2056 # include <errno.h>
2057 int main(void){
2058 int sockfd = 3;
2060 if(setsockopt(sockfd, SOL_SOCKET, SO_KEEPALIVE, NULL, 0) == -1 &&
2061 errno == ENOSYS)
2062 return 1;
2063 return 0;
2067 feat_yes SOCKETS && [ -n "${have_setsockopt}" ] &&
2068 link_check so_sndtimeo 'SO_SNDTIMEO' '#define HAVE_SO_SNDTIMEO' << \!
2069 #include <sys/socket.h>
2070 #include <stdlib.h>
2071 int main(void){
2072 struct timeval tv;
2073 int sockfd = 3;
2075 tv.tv_sec = 42;
2076 tv.tv_usec = 21;
2077 setsockopt(sockfd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof tv);
2078 setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof tv);
2079 return 0;
2083 feat_yes SOCKETS && [ -n "${have_setsockopt}" ] &&
2084 link_check so_linger 'SO_LINGER' '#define HAVE_SO_LINGER' << \!
2085 #include <sys/socket.h>
2086 #include <stdlib.h>
2087 int main(void){
2088 struct linger li;
2089 int sockfd = 3;
2091 li.l_onoff = 1;
2092 li.l_linger = 42;
2093 setsockopt(sockfd, SOL_SOCKET, SO_LINGER, &li, sizeof li);
2094 return 0;
2098 if feat_yes SSL; then # {{{
2099 # {{{ LibreSSL decided to define OPENSSL_VERSION_NUMBER with a useless value
2100 # instead of keeping it at the one that corresponds to the OpenSSL at fork
2101 # time: we need to test it first in order to get things right
2102 if compile_check _xssl 'TLS/SSL (LibreSSL)' \
2103 '#define HAVE_SSL
2104 #define HAVE_XSSL
2105 #define HAVE_XSSL_RESSL
2106 #define HAVE_XSSL_OPENSSL 0' << \!
2107 #include <openssl/opensslv.h>
2108 #ifdef LIBRESSL_VERSION_NUMBER
2109 #else
2110 # error nope
2111 #endif
2113 then
2114 ossl_v1_1=
2115 # TODO OPENSSL_IS_BORINGSSL, but never tried that one!
2116 elif compile_check _xssl 'TLS/SSL (OpenSSL >= v1.1.0)' \
2117 '#define HAVE_SSL
2118 #define HAVE_XSSL
2119 #define HAVE_XSSL_OPENSSL 0x10100' << \!
2120 #include <openssl/opensslv.h>
2121 #if OPENSSL_VERSION_NUMBER + 0 >= 0x10100000L
2122 #else
2123 # error nope
2124 #endif
2126 then
2127 ossl_v1_1=1
2128 elif compile_check _xssl 'TLS/SSL (OpenSSL)' \
2129 '#define HAVE_SSL
2130 #define HAVE_XSSL
2131 #define HAVE_XSSL_OPENSSL 0x10000' << \!
2132 #include <openssl/opensslv.h>
2133 #ifdef OPENSSL_VERSION_NUMBER
2134 #else
2135 # error nope
2136 #endif
2138 then
2139 ossl_v1_1=
2140 else
2141 feat_bail_required SSL
2142 fi # }}}
2144 if feat_yes SSL; then # {{{
2145 if [ -n "${ossl_v1_1}" ]; then
2146 without_check yes xssl 'TLS/SSL (new style *_client_method(3ssl))' \
2147 '#define n_XSSL_CLIENT_METHOD TLS_client_method' \
2148 '-lssl -lcrypto'
2149 elif link_check xssl 'TLS/SSL (new style *_client_method(3ssl))' \
2150 '#define n_XSSL_CLIENT_METHOD TLS_client_method' \
2151 '-lssl -lcrypto' << \!
2152 #include <openssl/ssl.h>
2153 #include <openssl/err.h>
2154 #include <openssl/x509v3.h>
2155 #include <openssl/x509.h>
2156 #include <openssl/rand.h>
2157 #ifdef OPENSSL_NO_TLS1 /* TODO only deduced from OPENSSL_NO_SSL[23]! */
2158 # error We need TLSv1.
2159 #endif
2160 int main(void){
2161 SSL_CTX *ctx = SSL_CTX_new(TLS_client_method());
2163 SSL_CTX_free(ctx);
2164 PEM_read_PrivateKey(0, 0, 0, 0);
2165 return 0;
2168 then
2170 elif link_check xssl 'TLS/SSL (old style *_client_method(3ssl))' \
2171 '#define n_XSSL_CLIENT_METHOD SSLv23_client_method' \
2172 '-lssl -lcrypto' << \!
2173 #include <openssl/ssl.h>
2174 #include <openssl/err.h>
2175 #include <openssl/x509v3.h>
2176 #include <openssl/x509.h>
2177 #include <openssl/rand.h>
2178 #if defined OPENSSL_NO_SSL3 &&\
2179 defined OPENSSL_NO_TLS1 /* TODO only deduced from OPENSSL_NO_SSL[23]! */
2180 # error We need one of SSLv3 and TLSv1.
2181 #endif
2182 int main(void){
2183 SSL_CTX *ctx = SSL_CTX_new(SSLv23_client_method());
2185 SSL_CTX_free(ctx);
2186 PEM_read_PrivateKey(0, 0, 0, 0);
2187 return 0;
2190 then
2192 else
2193 feat_bail_required SSL
2195 fi # }}}
2197 if feat_yes SSL; then # {{{
2198 if [ -n "${ossl_v1_1}" ]; then
2199 without_check yes xssl_stack_of 'TLS/SSL STACK_OF()' \
2200 '#define HAVE_XSSL_STACK_OF'
2201 elif compile_check xssl_stack_of 'TLS/SSL STACK_OF()' \
2202 '#define HAVE_XSSL_STACK_OF' << \!
2203 #include <stdio.h> /* For C89 NULL */
2204 #include <openssl/ssl.h>
2205 #include <openssl/err.h>
2206 #include <openssl/x509v3.h>
2207 #include <openssl/x509.h>
2208 #include <openssl/rand.h>
2209 int main(void){
2210 STACK_OF(GENERAL_NAME) *gens = NULL;
2212 printf("%p", gens); /* to use it */
2213 return 0;
2216 then
2220 if [ -n "${ossl_v1_1}" ]; then
2221 without_check yes xssl_conf 'TLS/SSL OpenSSL_modules_load_file()' \
2222 '#define HAVE_XSSL_CONFIG'
2223 elif link_check xssl_conf 'TLS/SSL OpenSSL_modules_load_file() support' \
2224 '#define HAVE_XSSL_CONFIG' << \!
2225 #include <stdio.h> /* For C89 NULL */
2226 #include <openssl/conf.h>
2227 int main(void){
2228 CONF_modules_load_file(NULL, NULL, CONF_MFLAGS_IGNORE_MISSING_FILE);
2229 CONF_modules_free();
2230 return 0;
2233 then
2237 if [ -n "${ossl_v1_1}" ]; then
2238 without_check yes xssl_conf_ctx 'TLS/SSL SSL_CONF_CTX support' \
2239 '#define HAVE_XSSL_CONF_CTX'
2240 elif link_check xssl_conf_ctx 'TLS/SSL SSL_CONF_CTX support' \
2241 '#define HAVE_XSSL_CONF_CTX' << \!
2242 #include <openssl/ssl.h>
2243 #include <openssl/err.h>
2244 int main(void){
2245 SSL_CTX *ctx = SSL_CTX_new(n_XSSL_CLIENT_METHOD());
2246 SSL_CONF_CTX *cctx = SSL_CONF_CTX_new();
2248 SSL_CONF_CTX_set_flags(cctx,
2249 SSL_CONF_FLAG_FILE | SSL_CONF_FLAG_CLIENT |
2250 SSL_CONF_FLAG_CERTIFICATE | SSL_CONF_FLAG_SHOW_ERRORS);
2251 SSL_CONF_CTX_set_ssl_ctx(cctx, ctx);
2252 SSL_CONF_cmd(cctx, "Protocol", "ALL");
2253 SSL_CONF_CTX_finish(cctx);
2254 SSL_CONF_CTX_free(cctx);
2255 SSL_CTX_free(ctx);
2256 return 0;
2259 then
2263 if [ -n "${ossl_v1_1}" ]; then
2264 without_check no xssl_rand_egd 'TLS/SSL RAND_egd(3ssl)' \
2265 '#define HAVE_XSSL_RAND_EGD'
2266 elif link_check xssl_rand_egd 'TLS/SSL RAND_egd(3ssl)' \
2267 '#define HAVE_XSSL_RAND_EGD' << \!
2268 #include <openssl/rand.h>
2269 int main(void){
2270 return RAND_egd("some.where") > 0;
2273 then
2277 if feat_yes SSL_ALL_ALGORITHMS; then
2278 if [ -n "${ossl_v1_1}" ]; then
2279 without_check yes ssl_all_algo 'TLS/SSL all-algorithms support' \
2280 '#define HAVE_SSL_ALL_ALGORITHMS'
2281 elif link_check ssl_all_algo 'TLS/SSL all-algorithms support' \
2282 '#define HAVE_SSL_ALL_ALGORITHMS' << \!
2283 #include <openssl/evp.h>
2284 int main(void){
2285 OpenSSL_add_all_algorithms();
2286 EVP_get_cipherbyname("two cents i never exist");
2287 EVP_cleanup();
2288 return 0;
2291 then
2293 else
2294 feat_bail_required SSL_ALL_ALGORITHMS
2297 fi # feat_yes SSL }}}
2299 if feat_yes SSL && feat_yes MD5 && feat_no NOEXTMD5; then # {{{
2300 run_check ssl_md5 'MD5 digest in the used crypto library' \
2301 '#define HAVE_XSSL_MD5' << \!
2302 #include <stdlib.h>
2303 #include <string.h>
2304 #include <openssl/md5.h>
2305 int main(void){
2306 char const dat[] = "abrakadabrafidibus";
2307 char dig[16], hex[16 * 2];
2308 MD5_CTX ctx;
2309 size_t i, j;
2311 memset(dig, 0, sizeof(dig));
2312 memset(hex, 0, sizeof(hex));
2313 MD5_Init(&ctx);
2314 MD5_Update(&ctx, dat, sizeof(dat) - 1);
2315 MD5_Final(dig, &ctx);
2317 #define hexchar(n) ((n) > 9 ? (n) - 10 + 'a' : (n) + '0')
2318 for(i = 0; i < sizeof(hex) / 2; i++){
2319 j = i << 1;
2320 hex[j] = hexchar((dig[i] & 0xf0) >> 4);
2321 hex[++j] = hexchar(dig[i] & 0x0f);
2323 return !!memcmp("6d7d0a3d949da2e96f2aa010f65d8326", hex, sizeof(hex));
2326 fi # }}}
2327 else
2328 echo '/* OPT_SSL=0 */' >> ${h}
2329 fi # }}} feat_yes SSL
2331 if [ "${have_xssl}" = yes ]; then
2332 OPT_SMIME=1
2333 else
2334 OPT_SMIME=0
2336 feat_def SMIME
2338 feat_def SMTP
2339 feat_def POP3
2340 feat_def IMAP
2342 if feat_yes GSSAPI; then
2343 ${cat} > ${tmp2}.c << \!
2344 #include <gssapi/gssapi.h>
2345 int main(void){
2346 gss_import_name(0, 0, GSS_C_NT_HOSTBASED_SERVICE, 0);
2347 gss_init_sec_context(0,0,0,0,0,0,0,0,0,0,0,0,0);
2348 return 0;
2351 ${sed} -e '1s/gssapi\///' < ${tmp2}.c > ${tmp3}.c
2353 if command -v krb5-config >/dev/null 2>&1; then
2354 i=`command -v krb5-config`
2355 GSS_LIBS="`CFLAGS= ${i} --libs gssapi`"
2356 GSS_INCS="`CFLAGS= ${i} --cflags`"
2357 i='GSS-API via krb5-config(1)'
2358 else
2359 GSS_LIBS='-lgssapi'
2360 GSS_INCS=
2361 i='GSS-API in gssapi/gssapi.h, libgssapi'
2363 if < ${tmp2}.c link_check gss \
2364 "${i}" '#define HAVE_GSSAPI' "${GSS_LIBS}" "${GSS_INCS}" ||\
2365 < ${tmp3}.c link_check gss \
2366 'GSS-API in gssapi.h, libgssapi' \
2367 '#define HAVE_GSSAPI
2368 #define GSSAPI_REG_INCLUDE' \
2369 '-lgssapi' ||\
2370 < ${tmp2}.c link_check gss 'GSS-API in libgssapi_krb5' \
2371 '#define HAVE_GSSAPI' \
2372 '-lgssapi_krb5' ||\
2373 < ${tmp3}.c link_check gss \
2374 'GSS-API in libgssapi, OpenBSD-style (pre 5.3)' \
2375 '#define HAVE_GSSAPI
2376 #define GSS_REG_INCLUDE' \
2377 '-lgssapi -lkrb5 -lcrypto' \
2378 '-I/usr/include/kerberosV' ||\
2379 < ${tmp2}.c link_check gss 'GSS-API in libgss' \
2380 '#define HAVE_GSSAPI' \
2381 '-lgss' ||\
2382 link_check gss 'GSS-API in libgssapi_krb5, old-style' \
2383 '#define HAVE_GSSAPI
2384 #define GSSAPI_OLD_STYLE' \
2385 '-lgssapi_krb5' << \!
2386 #include <gssapi/gssapi.h>
2387 #include <gssapi/gssapi_generic.h>
2388 int main(void){
2389 gss_import_name(0, 0, gss_nt_service_name, 0);
2390 gss_init_sec_context(0,0,0,0,0,0,0,0,0,0,0,0,0);
2391 return 0;
2394 then
2396 else
2397 feat_bail_required GSSAPI
2399 else
2400 echo '/* OPT_GSSAPI=0 */' >> ${h}
2401 fi # feat_yes GSSAPI
2403 feat_def NETRC
2404 feat_def AGENT
2406 if feat_yes IDNA; then
2407 if link_check idna 'GNU Libidn' '#define HAVE_IDNA HAVE_IDNA_LIBIDNA' \
2408 '-lidn' << \!
2409 #include <idna.h>
2410 #include <idn-free.h>
2411 #include <stringprep.h>
2412 int main(void){
2413 char *utf8, *idna_ascii, *idna_utf8;
2415 utf8 = stringprep_locale_to_utf8("does.this.work");
2416 if (idna_to_ascii_8z(utf8, &idna_ascii, IDNA_USE_STD3_ASCII_RULES)
2417 != IDNA_SUCCESS)
2418 return 1;
2419 idn_free(idna_ascii);
2420 /* (Rather link check only here) */
2421 idna_utf8 = stringprep_convert(idna_ascii, "UTF-8", "de_DE");
2422 return 0;
2425 then
2427 elif link_check idna 'idnkit' '#define HAVE_IDNA HAVE_IDNA_IDNKIT' \
2428 '-lidnkit' << \!
2429 #include <stdio.h>
2430 #include <idn/api.h>
2431 #include <idn/result.h>
2432 int main(void){
2433 idn_result_t r;
2434 char ace_name[256];
2435 char local_name[256];
2437 r = idn_encodename(IDN_ENCODE_APP, "does.this.work", ace_name,
2438 sizeof(ace_name));
2439 if (r != idn_success) {
2440 fprintf(stderr, "idn_encodename failed: %s\n", idn_result_tostring(r));
2441 return 1;
2443 r = idn_decodename(IDN_DECODE_APP, ace_name, local_name, sizeof(local_name));
2444 if (r != idn_success) {
2445 fprintf(stderr, "idn_decodename failed: %s\n", idn_result_tostring(r));
2446 return 1;
2448 return 0;
2451 then
2453 else
2454 feat_bail_required IDNA
2457 if [ -n "${have_idna}" ]; then
2458 echo '#define HAVE_IDNA_LIBIDNA 0' >> ${h}
2459 echo '#define HAVE_IDNA_IDNKIT 1' >> ${h}
2461 else
2462 echo '/* OPT_IDNA=0 */' >> ${h}
2465 feat_def IMAP_SEARCH
2467 if feat_yes REGEX; then
2468 if link_check regex 'regular expressions' '#define HAVE_REGEX' << \!
2469 #include <regex.h>
2470 #include <stdlib.h>
2471 int main(void){
2472 size_t xret;
2473 int status;
2474 regex_t re;
2476 status = regcomp(&re, ".*bsd", REG_EXTENDED | REG_ICASE | REG_NOSUB);
2477 xret = regerror(status, &re, NULL, 0);
2478 status = regexec(&re, "plan9", 0,NULL, 0);
2479 regfree(&re);
2480 return !(status == REG_NOMATCH);
2483 then
2485 else
2486 feat_bail_required REGEX
2488 else
2489 echo '/* OPT_REGEX=0 */' >> ${h}
2492 if feat_yes MLE && [ -n "${have_c90amend1}" ]; then
2493 have_mle=1
2494 echo '#define HAVE_MLE' >> ${h}
2495 else
2496 feat_bail_required MLE
2497 echo '/* OPT_MLE=0 */' >> ${h}
2500 # Generic have-a-line-editor switch for those who need it below
2501 if [ -n "${have_mle}" ]; then
2502 have_cle=1
2505 if [ -n "${have_cle}" ] && feat_yes HISTORY; then
2506 echo '#define HAVE_HISTORY' >> ${h}
2507 else
2508 echo '/* OPT_HISTORY=0 */' >> ${h}
2511 if [ -n "${have_mle}" ] && feat_yes KEY_BINDINGS; then
2512 echo '#define HAVE_KEY_BINDINGS' >> ${h}
2513 else
2514 echo '/* OPT_KEY_BINDINGS=0 */' >> ${h}
2517 if feat_yes TERMCAP; then
2518 __termcaplib() {
2519 link_check termcap "termcap(5) (via ${4})" \
2520 "#define HAVE_TERMCAP${3}" "${1}" << _EOT
2521 #include <stdio.h>
2522 #include <stdlib.h>
2523 ${2}
2524 #include <term.h>
2525 #define UNCONST(P) ((void*)(unsigned long)(void const*)(P))
2526 static int my_putc(int c){return putchar(c);}
2527 int main(void){
2528 char buf[1024+512], cmdbuf[2048], *cpb, *r1;
2529 int r2 = OK, r3 = ERR;
2531 tgetent(buf, getenv("TERM"));
2532 cpb = cmdbuf;
2533 r1 = tgetstr(UNCONST("cm"), &cpb);
2534 tgoto(r1, 1, 1);
2535 r2 = tgetnum(UNCONST("Co"));
2536 r3 = tgetflag(UNCONST("ut"));
2537 tputs("cr", 1, &my_putc);
2538 return (r1 == NULL || r2 == -1 || r3 == 0);
2540 _EOT
2543 __terminfolib() {
2544 link_check terminfo "terminfo(5) (via ${2})" \
2545 '#define HAVE_TERMCAP
2546 #define HAVE_TERMCAP_CURSES
2547 #define HAVE_TERMINFO' "${1}" << _EOT
2548 #include <stdio.h>
2549 #include <curses.h>
2550 #include <term.h>
2551 #define UNCONST(P) ((void*)(unsigned long)(void const*)(P))
2552 static int my_putc(int c){return putchar(c);}
2553 int main(void){
2554 int er, r0, r1, r2;
2555 char *r3, *tp;
2557 er = OK;
2558 r0 = setupterm(NULL, 1, &er);
2559 r1 = tigetflag(UNCONST("bce"));
2560 r2 = tigetnum(UNCONST("colors"));
2561 r3 = tigetstr(UNCONST("cr"));
2562 tp = tparm(r3, NULL, NULL, 0,0,0,0,0,0,0);
2563 tputs(tp, 1, &my_putc);
2564 return (r0 == ERR || r1 == -1 || r2 == -2 || r2 == -1 ||
2565 r3 == (char*)-1 || r3 == NULL);
2567 _EOT
2570 if feat_yes TERMCAP_VIA_TERMINFO; then
2571 __terminfolib -ltinfo -ltinfo ||
2572 __terminfolib -lcurses -lcurses ||
2573 __terminfolib -lcursesw -lcursesw ||
2574 feat_bail_required TERMCAP_VIA_TERMINFO
2577 if [ -z "${have_terminfo}" ]; then
2578 __termcaplib -ltermcap '' '' '-ltermcap' ||
2579 __termcaplib -ltermcap '#include <curses.h>' '
2580 #define HAVE_TERMCAP_CURSES' \
2581 'curses.h / -ltermcap' ||
2582 __termcaplib -lcurses '#include <curses.h>' '
2583 #define HAVE_TERMCAP_CURSES' \
2584 'curses.h / -lcurses' ||
2585 __termcaplib -lcursesw '#include <curses.h>' '
2586 #define HAVE_TERMCAP_CURSES' \
2587 'curses.h / -lcursesw' ||
2588 feat_bail_required TERMCAP
2590 if [ -n "${have_termcap}" ]; then
2591 run_check tgetent_null \
2592 "tgetent(3) of termcap(5) takes NULL buffer" \
2593 "#define HAVE_TGETENT_NULL_BUF" << _EOT
2594 #include <stdio.h> /* For C89 NULL */
2595 #include <stdlib.h>
2596 #ifdef HAVE_TERMCAP_CURSES
2597 # include <curses.h>
2598 #endif
2599 #include <term.h>
2600 int main(void){
2601 tgetent(NULL, getenv("TERM"));
2602 return 0;
2604 _EOT
2607 else
2608 echo '/* OPT_TERMCAP=0 */' >> ${h}
2609 echo '/* OPT_TERMCAP_VIA_TERMINFO=0 */' >> ${h}
2612 if feat_def SPAM_SPAMC; then
2613 if command -v spamc >/dev/null 2>&1; then
2614 echo "#define SPAM_SPAMC_PATH \"`command -v spamc`\"" >> ${h}
2618 if feat_yes SPAM_SPAMD && [ -n "${have_af_unix}" ]; then
2619 echo '#define HAVE_SPAM_SPAMD' >> ${h}
2620 else
2621 feat_bail_required SPAM_SPAMD
2622 echo '/* OPT_SPAM_SPAMD=0 */' >> ${h}
2625 feat_def SPAM_FILTER
2627 if feat_yes SPAM_SPAMC || feat_yes SPAM_SPAMD || feat_yes SPAM_FILTER; then
2628 echo '#define HAVE_SPAM' >> ${h}
2629 else
2630 echo '/* HAVE_SPAM */' >> ${h}
2633 if feat_yes QUOTE_FOLD &&\
2634 [ -n "${have_c90amend1}" ] && [ -n "${have_wcwidth}" ]; then
2635 echo '#define HAVE_QUOTE_FOLD' >> ${h}
2636 else
2637 feat_bail_required QUOTE_FOLD
2638 echo '/* OPT_QUOTE_FOLD=0 */' >> ${h}
2641 feat_def FILTER_HTML_TAGSOUP
2642 feat_def COLOUR
2643 feat_def DOTLOCK
2644 feat_def MD5
2645 feat_def NOMEMDBG
2647 ## Summarizing
2649 ${rm} -f ${tmp}
2650 squeeze_em ${inc} ${tmp}
2651 ${mv} ${tmp} ${inc}
2652 squeeze_em ${lib} ${tmp}
2653 ${mv} ${tmp} ${lib}
2655 # mk-config.h
2656 ${mv} ${h} ${tmp}
2657 printf '#ifndef n_MK_CONFIG_H\n# define n_MK_CONFIG_H 1\n' > ${h}
2658 ${cat} ${tmp} >> ${h}
2659 ${rm} -f ${tmp}
2660 printf '\n' >> ${h}
2662 # Create the string that is used by *features* and `version'.
2663 # Take this nice opportunity and generate a visual listing of included and
2664 # non-included features for the person who runs the configuration
2665 msg '\nThe following features are included (+) or not (-):'
2666 set -- ${OPTIONS_DETECT} ${OPTIONS} ${OPTIONS_XTRA}
2667 printf '/* The "feature string" */\n' >> ${h}
2668 # Because + is expanded by *folder* if first in "echo $features", put something
2669 printf '#define VAL_FEATURES_CNT '${#}'\n#define VAL_FEATURES "#' >> ${h}
2670 sep=
2671 for opt
2673 sdoc=`option_doc_of ${opt}`
2674 [ -z "${sdoc}" ] && continue
2675 sopt="`echo ${opt} | ${tr} '[A-Z]_' '[a-z]-'`"
2676 feat_yes ${opt} && sign=+ || sign=-
2677 printf -- "${sep}${sign}${sopt}" >> ${h}
2678 sep=','
2679 msg " %s %s: %s" ${sign} ${sopt} "${sdoc}"
2680 done
2681 # TODO instead of using sh+tr+awk+printf, use awk, drop option_doc_of, inc here
2682 #exec 5>&1 >>${h}
2683 #${awk} -v opts="${OPTIONS_DETECT} ${OPTIONS} ${OPTIONS_XTRA}" \
2684 # -v xopts="${XOPTIONS_DETECT} ${XOPTIONS} ${XOPTIONS_XTRA}" \
2685 printf '"\n' >> ${h}
2687 # Create the real mk-config.mk
2688 # Note we cannout use explicit ./ filename prefix for source and object
2689 # pathnames because of a bug in bmake(1)
2690 ${rm} -rf ${tmp0}.* ${tmp0}*
2691 srclist= objlist=
2692 if feat_no AMALGAMATION; then
2693 for i in `printf '%s\n' "${SRCDIR}"*.c | ${sort}`; do
2694 i=`basename "${i}" .c`
2695 if [ "${i}" = privsep ]; then
2696 continue
2698 objlist="${objlist} ${i}.o"
2699 srclist="${srclist} \$(SRCDIR)${i}.c"
2700 printf '%s: %s\n\t$(ECHO_CC)$(CC) $(CFLAGS) $(INCS) -c %s\n' \
2701 "${i}.o" "\$(SRCDIR)${i}.c" "\$(SRCDIR)${i}.c" >> ${mk}
2702 done
2703 printf '\nAMALGAM_TARGET =\nAMALGAM_DEP =\n' >> ${mk}
2704 else
2705 printf '%s:\n\t$(ECHO_CC)$(CC) $(CFLAGS) $(INCS) -c $(SRCDIR)%s\n' \
2706 "main.o" "main.c" >> ${mk}
2707 srclist=main.c objlist=main.o
2708 printf '\nAMALGAM_TARGET = main.o\nAMALGAM_DEP = ' >> ${mk}
2710 printf '\n/* HAVE_AMALGAMATION: include sources */\n' >> ${h}
2711 printf '#elif n_MK_CONFIG_H + 0 == 1\n' >> ${h}
2712 printf '# undef n_MK_CONFIG_H\n' >> ${h}
2713 printf '# define n_MK_CONFIG_H 2\n' >> ${h}
2714 for i in `printf '%s\n' "${SRCDIR}"*.c | ${sort}`; do
2715 i=`basename "${i}"`
2716 if [ "${i}" = main.c ] ||
2717 [ "${i}" = privsep.c ]; then
2718 continue
2720 printf '$(SRCDIR)%s ' "${i}" >> ${mk}
2721 printf '# include "%s%s"\n' "${SRCDIR}" "${i}" >> ${h}
2722 done
2723 echo >> ${mk}
2725 printf 'OBJ_SRC = %s\nOBJ = %s\n' "${srclist}" "${objlist}" >> "${mk}"
2727 printf '#endif /* n_MK_CONFIG_H */\n' >> ${h}
2729 echo "LIBS = `${cat} ${lib}`" >> ${mk}
2730 echo "INCS = `${cat} ${inc}`" >> ${mk}
2731 echo >> ${mk}
2732 ${cat} "${SRCDIR}"make-config.in >> ${mk}
2734 ## Finished!
2736 msg '\nSetup:'
2737 msg ' . System-wide resource file: %s/%s' "${VAL_SYSCONFDIR}" "${VAL_SYSCONFRC}"
2738 msg ' . bindir: %s' "${VAL_BINDIR}"
2739 if feat_yes DOTLOCK; then
2740 msg ' . libexecdir: %s' "${VAL_LIBEXECDIR}"
2742 msg ' . mandir: %s' "${VAL_MANDIR}"
2743 msg ' . M(ail)T(ransfer)A(gent): %s (argv0 %s)' "${VAL_MTA}" "${VAL_MTA_ARGV0}"
2744 msg ' . $MAIL spool directory: %s' "${VAL_MAIL}"
2745 msg ''
2747 if [ -n "${have_fnmatch}" ] && [ -n "${have_fchdir}" ]; then
2748 exit 0
2750 msg 'Remarks:'
2751 if [ -z "${have_fnmatch}" ]; then
2752 msg ' . The function fnmatch(3) could not be found.'
2753 msg ' Filename patterns like wildcard are not supported on your system'
2755 if [ -z "${have_fchdir}" ]; then
2756 msg ' . The function fchdir(2) could not be found.'
2757 msg ' We will use chdir(2) instead.'
2758 msg ' This is a problem only if the current working directory is changed'
2759 msg ' while this program is inside of it'
2761 msg ''
2763 # s-it-mode